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

Lots of CardDAV stuff.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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}