Show
Ignore:
Timestamp:
01/13/08 12:24:39 (11 months ago)
Author:
cyrusdaboo
Message:

Support address book queries on multiple fields in a single request.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/CardDAVClient/CCardDAVQueryReport.cpp

    r148 r149  
    3434using namespace carddav;  
    3535 
    36 CCardDAVQueryReport::CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type) : 
     36CCardDAVQueryReport::CCardDAVQueryReport(CWebDAVSession* session, const cdstring& ruri, const cdstrvect& search_props, const cdstring& search_text, const cdstring& match_type) : 
    3737        CWebDAVReport(session, ruri) 
    3838{ 
    39         InitRequestData(search_prop, search_text, match_type); 
     39        InitRequestData(search_props, search_text, match_type); 
    4040} 
    4141 
     
    4646 
    4747 
    48 void CCardDAVQueryReport::InitRequestData(const cdstring& search_prop, const cdstring& search_text, const cdstring& match_type) 
     48void CCardDAVQueryReport::InitRequestData(const cdstrvect& search_props, 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, match_type); 
     52        GenerateXML(os, search_props, 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, const cdstring& match_type) 
     58void CCardDAVQueryReport::GenerateXML(std::ostream& os, const cdstrvect& search_props, const cdstring& search_text, const cdstring& match_type) 
    5959{ 
    6060        using namespace xmllib; 
     
    7171        //           <C:text-match match-type="...">...</C:text-match> 
    7272        //         </C:prop-filter> 
     73        //     ... 
    7374        //       </C:filter> 
    7475        //   ... 
     
    9899        xmllib::XMLNode* filter = new xmllib::XMLNode(&xmldoc, query, cElement_filter.Name(), carddav_namespc); 
    99100         
    100         // <CardDAV:prop-filter name="..."> element 
    101         xmllib::XMLNode* prop_filter = new xmllib::XMLNode(&xmldoc, filter, cElement_propfilter.Name(), carddav_namespc); 
    102         prop_filter->AddAttribute(cAttribute_name.Name(), search_prop); 
     101        for(cdstrvect::const_iterator iter = search_props.begin(); iter != search_props.end(); iter++) 
     102        { 
     103                // <CardDAV:prop-filter name="..."> element 
     104                xmllib::XMLNode* prop_filter = new xmllib::XMLNode(&xmldoc, filter, cElement_propfilter.Name(), carddav_namespc); 
     105                prop_filter->AddAttribute(cAttribute_name.Name(), *iter); 
    103106 
    104         // <C:text-match match-type="...">...</C:text-match> 
    105         xmllib::XMLNode* text_match = new xmllib::XMLNode(&xmldoc, prop_filter, cElement_textmatch.Name(), carddav_namespc, search_text); 
    106         text_match->AddAttribute(cAttribute_matchtype.Name(), match_type); 
     107                // <C:text-match match-type="...">...</C:text-match> 
     108                xmllib::XMLNode* text_match = new xmllib::XMLNode(&xmldoc, prop_filter, cElement_textmatch.Name(), carddav_namespc, search_text); 
     109                text_match->AddAttribute(cAttribute_matchtype.Name(), match_type); 
     110        } 
    107111 
    108112        // Now we have the complete document, so write it out (no indentation)