Changeset 148

Show
Ignore:
Timestamp:
01/02/08 00:03:39 (9 months ago)
Author:
daboo
Message:

Lots of CardDAV stuff.

Location:
Mulberry/branches/v4.1d1/Sources_Common
Files:
28 modified

Legend:

Unmodified
Added
Removed
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVDefinitions.cpp

    r113 r148  
    4444const xmllib::XMLName   cElement_propstat("propstat", cNamespace); 
    4545 
    46 const xmllib::XMLName cProperty_getcontentlength("getcontentlength", cNamespace); 
     46const xmllib::XMLName   cElement_propertyupdate("propertyupdate", cNamespace); 
     47const xmllib::XMLName   cElement_set("set", cNamespace); 
     48const xmllib::XMLName   cElement_remove("remove", cNamespace); 
     49 
     50const xmllib::XMLName   cProperty_getcontentlength("getcontentlength", cNamespace); 
    4751const xmllib::XMLName   cProperty_getcontenttype("getcontenttype", cNamespace); 
    4852const xmllib::XMLName   cProperty_resourcetype("resourcetype", cNamespace); 
     
    8892const xmllib::XMLName   cElement_principal_match("principal-match", cNamespace); 
    8993 
     94// Extended MKCOL 
     95const xmllib::XMLName   cElement_mkcol("mkcol", cNamespace); 
     96const xmllib::XMLName   cElement_mkcol_response("mkcol-response", cNamespace); 
     97 
    9098} 
    9199 
     
    102110 
    103111        const xmllib::XMLName   cElement_calendardata("calendar-data", cNamespace); 
    104                 const xmllib::XMLName   cAttribute_returncontenttype("return-content-type", cNamespace); 
    105112 
    106113        const xmllib::XMLName   cElement_comp("comp", cNamespace); 
     
    119126        const xmllib::XMLName   cElement_paramfilter("param-filter", cNamespace); 
    120127 
    121         const xmllib::XMLName   cElement_isdefined("is-defined", cNamespace); 
     128        const xmllib::XMLName   cElement_isnotdefined("is-not-defined", cNamespace); 
    122129        const xmllib::XMLName   cElement_textmatch("text-match", cNamespace); 
    123130                const xmllib::XMLName   cAttribute_caseless("caseless", cNamespace); 
     
    154161 
    155162const char*     cNamespace = "urn:ietf:params:xml:ns:carddav"; 
    156 const xmllib::XMLName   cProperty_carddavadbk("adbk", cNamespace); 
    157  
    158 const xmllib::XMLName   cElement_adbkquery("adbk-query", cNamespace); 
    159 const xmllib::XMLName   cElement_adbkmultiget("adbk-multiget", cNamespace); 
    160  
    161         const xmllib::XMLName   cElement_adbkdata("adbk-data", cNamespace); 
    162                 const xmllib::XMLName   cAttribute_returncontenttype("return-content-type", cNamespace); 
     163const xmllib::XMLName   cProperty_carddavadbk("addressbook", cNamespace); 
     164 
     165const xmllib::XMLName   cElement_adbkquery("addressbook-query", cNamespace); 
     166const xmllib::XMLName   cElement_adbkmultiget("addressbook-multiget", cNamespace); 
     167 
     168        const xmllib::XMLName   cElement_adbkdata("address-data", cNamespace); 
    163169 
    164170        const xmllib::XMLName   cElement_allprop("allprop", cNamespace); 
     
    168174 
    169175        const xmllib::XMLName   cElement_filter("filter", cNamespace); 
    170         const xmllib::XMLName   cElement_compfilter("comp-filter", cNamespace); 
    171176        const xmllib::XMLName   cElement_propfilter("prop-filter", cNamespace); 
    172177        const xmllib::XMLName   cElement_paramfilter("param-filter", cNamespace); 
    173178 
    174         const xmllib::XMLName   cElement_isdefined("is-defined", cNamespace); 
     179        const xmllib::XMLName   cElement_isnotdefined("is-not-defined", cNamespace); 
    175180        const xmllib::XMLName   cElement_textmatch("text-match", cNamespace); 
    176                 const xmllib::XMLName   cAttribute_caseless("caseless", cNamespace); 
     181                const xmllib::XMLName   cAttribute_collation("collation", cNamespace); 
     182                const xmllib::XMLName   cAttribute_negate_condition("negate-condition", cNamespace); 
    177183                const xmllib::XMLName   cAttribute_matchtype("match-type", cNamespace); 
    178184 
    179         const xmllib::XMLName   cAttributeValue_yes("caseless_yes", cNamespace); 
    180         const xmllib::XMLName   cAttributeValue_no("caseless_no", cNamespace); 
     185        const xmllib::XMLName   cAttributeValue_yes("yes", cNamespace); 
     186        const xmllib::XMLName   cAttributeValue_no("no", cNamespace); 
    181187 
    182188        const xmllib::XMLName   cAttributeValue_matchtype_starts("starts-with", cNamespace); 
    183189        const xmllib::XMLName   cAttributeValue_matchtype_ends("ends-with", cNamespace); 
    184190        const xmllib::XMLName   cAttributeValue_matchtype_contains("contains", cNamespace); 
    185         const xmllib::XMLName   cAttributeValue_matchtype_is("is", cNamespace); 
     191        const xmllib::XMLName   cAttributeValue_matchtype_is("equals", cNamespace); 
    186192 
    187193} 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVDefinitions.h

    r113 r148  
    4646extern const xmllib::XMLName    cElement_propstat; 
    4747 
     48extern const xmllib::XMLName    cElement_propertyupdate; 
     49extern const xmllib::XMLName    cElement_set; 
     50extern const xmllib::XMLName    cElement_remove; 
     51 
    4852extern const xmllib::XMLName    cProperty_getcontentlength; 
    4953extern const xmllib::XMLName    cProperty_getcontenttype; 
     
    9498extern const xmllib::XMLName    cElement_principal_match; 
    9599 
     100// Extended MKCOL 
     101extern const xmllib::XMLName    cElement_mkcol; 
     102extern const xmllib::XMLName    cElement_mkcol_response; 
     103 
    96104} 
    97105 
     
    109117 
    110118        extern const xmllib::XMLName    cElement_calendardata; 
    111                 extern const xmllib::XMLName    cAttribute_returncontenttype; 
    112119 
    113120        extern const xmllib::XMLName    cElement_comp; 
     
    126133        extern const xmllib::XMLName    cElement_paramfilter; 
    127134 
    128         extern const xmllib::XMLName    cElement_isdefined; 
     135        extern const xmllib::XMLName    cElement_isnotdefined; 
    129136        extern const xmllib::XMLName    cElement_textmatch; 
    130137                extern const xmllib::XMLName    cAttribute_caseless; 
     
    167174 
    168175        extern const xmllib::XMLName    cElement_adbkdata; 
    169                 extern const xmllib::XMLName    cAttribute_returncontenttype; 
    170176 
    171177        extern const xmllib::XMLName    cElement_allprop; 
     
    179185        extern const xmllib::XMLName    cElement_paramfilter; 
    180186 
    181         extern const xmllib::XMLName    cElement_isdefined; 
     187        extern const xmllib::XMLName    cElement_isnotdefined; 
    182188        extern const xmllib::XMLName    cElement_textmatch; 
    183                 extern const xmllib::XMLName    cAttribute_caseless; 
     189                extern const xmllib::XMLName    cAttribute_collation; 
     190                extern const xmllib::XMLName    cAttribute_negate_condition; 
     191                extern const xmllib::XMLName    cAttribute_matchtype; 
    184192 
    185193        extern const xmllib::XMLName    cAttributeValue_yes; 
    186194        extern const xmllib::XMLName    cAttributeValue_no; 
    187195 
     196        extern const xmllib::XMLName    cAttributeValue_matchtype_starts; 
     197        extern const xmllib::XMLName    cAttributeValue_matchtype_ends; 
     198        extern const xmllib::XMLName    cAttributeValue_matchtype_contains; 
     199        extern const xmllib::XMLName    cAttributeValue_matchtype_is; 
     200 
    188201} 
    189202 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVMakeAdbk.cpp

    r86 r148  
    2424#include "CCardDAVMakeAdbk.h" 
    2525 
     26#include "CHTTPDataString.h" 
     27#include "CWebDAVDefinitions.h" 
     28#include "XMLDocument.h" 
     29#include "XMLNode.h" 
     30 
     31#include <strstream> 
     32 
     33using namespace webdav;  
    2634using namespace carddav;  
    2735 
    2836CCardDAVMakeAdbk::CCardDAVMakeAdbk(CWebDAVSession* session, const cdstring& ruri) : 
    29         CWebDAVRequestResponse(session, eRequest_MKADBK, ruri) 
     37        CWebDAVMakeCollection(session, ruri) 
    3038{ 
     39        InitRequestData(); 
    3140} 
    3241 
     
    3645} 
    3746 
     47void CCardDAVMakeAdbk::InitRequestData() 
     48{ 
     49        // Write XML info to a string 
     50        std::ostrstream os; 
     51        GenerateXML(os); 
     52        os << ends; 
     53 
     54        mRequestData = new CHTTPInputDataString(os.str(), "text/xml; charset=utf-8"); 
     55} 
     56 
     57void CCardDAVMakeAdbk::GenerateXML(ostream& os) 
     58{ 
     59        using namespace xmllib; 
     60 
     61        // Structure of document is: 
     62        // 
     63        // <DAV:mkcol> 
     64        //   <DAV:set> 
     65        //     <DAV:prop> 
     66        //       <DAV:resource-type> 
     67        //         <DAV:collection/> 
     68        //         <CARDDAV:addressbook/> 
     69        //       </DAV:resource-type> 
     70        //     </DAV:prop> 
     71        //   </DAV:set> 
     72        // </DAV:mkcol> 
     73         
     74        // Create document and get the root 
     75        xmllib::XMLDocument xmldoc; 
     76         
     77        // <DAV:mkcol> element 
     78        xmllib::XMLNode* mkcol = xmldoc.GetRoot(); 
     79        xmllib::XMLNamespace dav_namespc(http::webdav::cNamespace, "D"); 
     80        xmllib::XMLNamespace carddav_namespc(carddav::cNamespace, "C"); 
     81        mkcol->SetName(http::webdav::cElement_mkcol.Name(), dav_namespc); 
     82        mkcol->AddNamespace(dav_namespc); 
     83         
     84        // <DAV:set> element 
     85        xmllib::XMLNode* set = new xmllib::XMLNode(&xmldoc, mkcol, cElement_set.Name(), dav_namespc); 
     86         
     87        // <DAV:prop> element 
     88        xmllib::XMLNode* prop = new xmllib::XMLNode(&xmldoc, set, cElement_prop.Name(), dav_namespc); 
     89         
     90        // <DAV:resourcetype> element 
     91        xmllib::XMLNode* resourcetype = new xmllib::XMLNode(&xmldoc, prop, cProperty_resourcetype.Name(), dav_namespc); 
     92         
     93        // <DAV:collection> element 
     94        new xmllib::XMLNode(&xmldoc, resourcetype, cProperty_collection.Name(), dav_namespc); 
     95         
     96        // <DAV:resourcetype> element 
     97        new xmllib::XMLNode(&xmldoc, resourcetype, cProperty_carddavadbk.Name(), carddav_namespc); 
     98         
     99        // Now we have the complete document, so write it out (no indentation) 
     100        xmldoc.Generate(os, false); 
     101} 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVMakeAdbk.h

    r86 r148  
    2525#define CCardDAVMakeAdbk_H 
    2626 
    27 #include "CWebDAVRequestResponse.h" 
     27#include "CWebDAVMakeCollection.h" 
    2828 
    2929using namespace http;  
     
    3434namespace carddav { 
    3535 
    36 class CCardDAVMakeAdbk: public CWebDAVRequestResponse 
     36class CCardDAVMakeAdbk: public CWebDAVMakeCollection 
    3737{ 
    3838public: 
    3939        CCardDAVMakeAdbk(CWebDAVSession* session, const cdstring& ruri); 
    4040        virtual ~CCardDAVMakeAdbk(); 
     41 
     42 
     43protected: 
     44        void    InitRequestData(); 
     45         
     46        void    GenerateXML(std::ostream& os); 
    4147 
    4248}; 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVMultigetReport.cpp

    r86 r148  
    6262        // Structure of document is: 
    6363        // 
    64         // <CardDAV:adbk-multiget> 
     64        // <CardDAV:addressbook-multiget> 
    6565        //   <DAV:prop> 
    6666        //     <DAV:getetag> 
     67        //     <CardDAV:address-data/> 
    6768        //   </DAV:prop> 
    68         //   <CardDAV:adbk-data/> 
    6969        //   <DAV:href>...</DAV:href> 
    7070        //   ... 
    71         // </CardDAV:adbk-multiget> 
     71        // </CardDAV:addressbook-multiget> 
    7272         
    7373        // Create document and get the root 
    7474        xmllib::XMLDocument xmldoc; 
    7575 
    76         // <CardDAV:adbk-multiget> element 
     76        // <CardDAV:addressbook-multiget> element 
    7777        xmllib::XMLNode* multiget = xmldoc.GetRoot(); 
    7878        xmllib::XMLNamespace dav_namespc(webdav::cNamespace, "D"); 
     
    8888        new xmllib::XMLNode(&xmldoc, prop, cProperty_getetag.Name(), dav_namespc); 
    8989         
    90         // <CardDAV:adbk-data> element 
    91         new xmllib::XMLNode(&xmldoc, multiget, cElement_adbkdata.Name(), carddav_namespc); 
     90        // <CardDAV:address-data> element 
     91        new xmllib::XMLNode(&xmldoc, prop, cElement_adbkdata.Name(), carddav_namespc); 
    9292         
    9393        // Do for each href 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVQueryReport.cpp

    r86 r148  
    3434using namespace carddav;  
    3535 
    36 CCardDAVQueryReport::CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstring& search_prop, const cdstring& search_text) : 
     36CCardDAVQueryReport::CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type) : 
    3737        CWebDAVReport(session, ruri) 
    3838{ 
    39         InitRequestData(search_prop, search_text); 
     39        InitRequestData(search_prop, search_text, match_type); 
    4040} 
    4141 
     
    4646 
    4747 
    48 void CCardDAVQueryReport::InitRequestData(const cdstring& search_prop, const cdstring& search_text) 
     48void CCardDAVQueryReport::InitRequestData(const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type) 
    4949{ 
    5050        // Write XML info to a string 
    5151        std::ostrstream os; 
    52         GenerateXML(os, search_prop, search_text); 
     52        GenerateXML(os, search_prop, search_text, match_type); 
    5353        os << ends; 
    5454         
     
    5656} 
    5757 
    58 void CCardDAVQueryReport::GenerateXML(std::ostream& os, const cdstring& search_prop, const cdstring& search_text) 
     58void CCardDAVQueryReport::GenerateXML(std::ostream& os, const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type) 
    5959{ 
    6060        using namespace xmllib; 
     
    6565        //   <DAV:prop> 
    6666        //     <DAV:getetag> 
     67        //     <C:adbk-data/> 
    6768        //   </DAV:prop> 
    68         //   <C:adbk-data/> 
    6969        //       <C:filter> 
    70         //       <C:comp-filter> 
    7170        //         <C:prop-filter name="..."> 
    72         //           <C:text-match caseless="yes">...</C:text-match> 
     71        //           <C:text-match match-type="...">...</C:text-match> 
    7372        //         </C:prop-filter> 
    74         //       </C:comp-filter> 
    7573        //       </C:filter> 
    7674        //   ... 
     
    9492        new xmllib::XMLNode(&xmldoc, prop, cProperty_getetag.Name(), dav_namespc); 
    9593         
    96         // <CardDAV:adbk-data> element 
    97         new xmllib::XMLNode(&xmldoc, query, cElement_adbkdata.Name(), carddav_namespc); 
     94        // <CardDAV:addressbook-data> element 
     95        new xmllib::XMLNode(&xmldoc, prop, cElement_adbkdata.Name(), carddav_namespc); 
    9896         
    9997        // <CardDAV:filter> element 
    10098        xmllib::XMLNode* filter = new xmllib::XMLNode(&xmldoc, query, cElement_filter.Name(), carddav_namespc); 
    10199         
    102         // <CardDAV:comp-filter> element 
    103         xmllib::XMLNode* comp_filter = new xmllib::XMLNode(&xmldoc, filter, cElement_compfilter.Name(), carddav_namespc); 
    104          
    105100        // <CardDAV:prop-filter name="..."> element 
    106         xmllib::XMLNode* prop_filter = new xmllib::XMLNode(&xmldoc, comp_filter, cElement_propfilter.Name(), carddav_namespc); 
     101        xmllib::XMLNode* prop_filter = new xmllib::XMLNode(&xmldoc, filter, cElement_propfilter.Name(), carddav_namespc); 
    107102        prop_filter->AddAttribute(cAttribute_name.Name(), search_prop); 
    108103 
    109         // <C:text-match caseless="yes">...</C:text-match> 
     104        // <C:text-match match-type="...">...</C:text-match> 
    110105        xmllib::XMLNode* text_match = new xmllib::XMLNode(&xmldoc, prop_filter, cElement_textmatch.Name(), carddav_namespc, search_text); 
    111         text_match->AddAttribute(cAttribute_caseless.Name(), cAttributeValue_yes.Name()); 
     106        text_match->AddAttribute(cAttribute_matchtype.Name(), match_type); 
    112107 
    113108        // Now we have the complete document, so write it out (no indentation) 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVQueryReport.h

    r86 r148  
    3737{ 
    3838public: 
    39         CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstring& search_prop, const cdstring& search_text); 
     39        CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type); 
    4040        virtual ~CCardDAVQueryReport(); 
    4141 
    4242protected: 
    43         void    InitRequestData(const cdstring& search_prop, const cdstring& search_text); 
     43        void    InitRequestData(const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type); 
    4444         
    45         void    GenerateXML(std::ostream& os, const cdstring& search_prop, const cdstring& search_text); 
     45        void    GenerateXML(std::ostream& os, const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type); 
    4646}; 
    4747 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVReportParser.cpp

    r86 r148  
    4040using namespace xmllib;  
    4141 
     42CCardDAVReportParser::CCardDAVReportParser(vCard::CVCardAddressBook& vadbk) 
     43{ 
     44        mVAdbk = &vadbk; 
     45        mAdbk = NULL; 
     46        mAddrs = NULL; 
     47        mAddItems = false; 
     48} 
     49 
    4250CCardDAVReportParser::CCardDAVReportParser(vCard::CVCardAddressBook& vadbk, CAddressBook* adbk, bool add) 
    4351{ 
    4452        mVAdbk = &vadbk; 
    4553        mAdbk = adbk; 
     54        mAddrs = NULL; 
     55        mAddItems = add; 
     56} 
     57 
     58CCardDAVReportParser::CCardDAVReportParser(vCard::CVCardAddressBook& vadbk, CAddressList* addrs, bool add) 
     59{ 
     60        mVAdbk = &vadbk; 
     61        mAdbk = NULL; 
     62        mAddrs = addrs; 
    4663        mAddItems = add; 
    4764} 
     
    7188                else if ((*iter)->CompareFullName(cElement_propstat)) 
    7289                { 
    73                         ParsePropStat(*iter, etag); 
    74                 } 
    75                  
    76                 // Is it adbk-data 
    77                 else if ((*iter)->CompareFullName(cElement_adbkdata)) 
    78                 { 
    79                         ParseAdbkData(*iter, href, etag); 
     90                        ParsePropStat(*iter, href, etag); 
    8091                } 
    8192        } 
    8293} 
    8394 
    84 void CCardDAVReportParser::ParsePropStat(const xmllib::XMLNode* response, cdstring& etag) 
     95void CCardDAVReportParser::ParsePropStat(const xmllib::XMLNode* response, const cdstring& href, cdstring& etag) 
    8596{ 
    8697        // Scan the propstat node the status - we only process OK status 
     
    110121                                if ((*iter)->CompareFullName(webdav::cElement_prop)) 
    111122                                { 
    112                                         ParseProp(*iter, etag); 
     123                                        ParseProp(*iter, href, etag); 
    113124                                } 
    114125                        } 
     
    118129} 
    119130 
    120 void CCardDAVReportParser::ParseProp(const xmllib::XMLNode* response, cdstring& etag) 
     131void CCardDAVReportParser::ParseProp(const xmllib::XMLNode* response, const cdstring& href, cdstring& etag) 
    121132{ 
    122133        // Scan the prop node - each child is processed 
    123134        for(XMLNodeList::const_iterator iter = response->Children().begin(); iter != response->Children().end(); iter++) 
    124135        { 
    125                 ParsePropElement(*iter, etag); 
     136                ParsePropElement(*iter, href, etag); 
    126137        } 
    127138} 
    128139 
    129 void CCardDAVReportParser::ParsePropElement(const xmllib::XMLNode* response, cdstring& etag) 
     140void CCardDAVReportParser::ParsePropElement(const xmllib::XMLNode* response, const cdstring& href, cdstring& etag) 
    130141{ 
    131142        // Here we need to detect the type of element and dispatch accordingly 
     
    143154                etag = response->Data(); 
    144155        } 
     156                 
     157        // Is it adbk-data 
     158        else if (response->CompareFullName(cElement_adbkdata)) 
     159        { 
     160                ParseAdbkData(response, href, etag); 
     161        } 
    145162} 
    146163 
     
    155172        std::istrstream is(response->Data().c_str()); 
    156173        vCard::CVCardVCard* vcard = mVAdbk->ParseComponent(is, last_path, etag); 
    157         if ((mAdbk != NULL) && mAddItems) 
    158                 vcardstore::MapFromVCard(mAdbk, *vcard); 
     174        if ((vcard != NULL) && mAddItems) 
     175        { 
     176                if (mAdbk != NULL) 
     177                        vcardstore::MapFromVCard(mAdbk, *vcard); 
     178                else if (mAddrs != NULL) 
     179                        vcardstore::MapFromVCard(mAddrs, *vcard); 
     180        } 
    159181} 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVReportParser.h

    r86 r148  
    3838 
    3939class CAddressBook; 
     40class CAddressList; 
    4041 
    4142namespace http { 
     
    4647{ 
    4748public: 
    48         CCardDAVReportParser(vCard::CVCardAddressBook& vadbk, CAddressBook* adbk = NULL, bool add = false); 
     49        CCardDAVReportParser(vCard::CVCardAddressBook& vadbk); 
     50        CCardDAVReportParser(vCard::CVCardAddressBook& vadbk, CAddressBook* adbk, bool add = false); 
     51        CCardDAVReportParser(vCard::CVCardAddressBook& vadbk, CAddressList* addrs, bool add = false); 
    4952        virtual ~CCardDAVReportParser(); 
    5053         
     
    5356        vCard::CVCardAddressBook*       mVAdbk; 
    5457        CAddressBook*                           mAdbk; 
     58        CAddressList*                           mAddrs; 
    5559        bool                                            mAddItems; 
    5660 
     
    5862 
    5963        virtual void ParseResponse(const xmllib::XMLNode* response); 
    60         virtual void ParsePropStat(const xmllib::XMLNode* response, cdstring& etag); 
    61         virtual void ParseProp(const xmllib::XMLNode* response, cdstring& etag);