Show
Ignore:
Timestamp:
10/28/07 23:41:34 (1 year ago)
Author:
daboo
Message:

Calendar ctag handling. Don't list the calendars/address books when first starting up if
we have a fresh cache.

Files:
1 modified

Legend:

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

    r96 r113  
    2929//#include "CDisplayItem.h" 
    3030#include "CGeneralException.h" 
     31#include "CPasswordManager.h" 
    3132#include "CStatusWindow.h" 
    3233#include "CStreamFilter.h" 
     
    568569} 
    569570 
     571void CWebDAVCalendarClient::_UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal) 
     572{ 
     573        // Start UI action 
     574        StINETClientAction _action(this, "Status::Calendar::Checking", "Error::Calendar::OSErrCheckCalendar", "Error::Calendar::NoBadCheckCalendar", node.GetName()); 
     575 
     576        // Determine URL and lock 
     577        cdstring rurl = GetRURL(&node); 
     578        cdstring lock_token = GetLockToken(rurl); 
     579 
     580        // Get current ETag 
     581        cdstring etag = GetETag(rurl, lock_token); 
     582         
     583        cal.SetETag(etag); 
     584} 
     585 
    570586void CWebDAVCalendarClient::_SizeCalendar(CCalendarStoreNode& node) 
    571587{ 
     
    11231139cdstring CWebDAVCalendarClient::GetETag(const cdstring& rurl, const cdstring& lock_token) 
    11241140{ 
     1141        cdstring result = GetProperty(rurl, lock_token, http::webdav::cProperty_getetag); 
     1142 
     1143        // Handle server bug: ETag value MUST be quoted per HTTP/1.1 €3.11 
     1144        if (!result.empty() && !result.isquoted()) 
     1145                result.quote(true); 
     1146 
     1147        return result; 
     1148} 
     1149 
     1150cdstring CWebDAVCalendarClient::GetProperty(const cdstring& rurl, const cdstring& lock_token, const xmllib::XMLName& property) 
     1151{ 
    11251152        cdstring result; 
    11261153 
    11271154        // Create WebDAV propfind 
    11281155        xmllib::XMLNameList props; 
    1129         props.push_back(http::webdav::cProperty_getetag); 
     1156        props.push_back(property); 
    11301157        auto_ptr<http::webdav::CWebDAVPropFind> request(new http::webdav::CWebDAVPropFind(this, rurl, http::webdav::eDepth0, props)); 
    11311158        http::CHTTPOutputDataString dout; 
     
    11421169 
    11431170                // Look at each propfind result and determine type of calendar 
     1171                cdstring decoded_rurl = rurl; 
     1172                decoded_rurl.DecodeURL(); 
    11441173                for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter = parser.Results().begin(); iter != parser.Results().end(); iter++) 
    11451174                { 
     
    11491178                 
    11501179                        // Must match rurl 
    1151                         if (name.compare_end(rurl)) 
     1180                        if (name.compare_end(decoded_rurl)) 
    11521181                        { 
    1153                                 if ((*iter)->GetTextProperties().count(http::webdav::cProperty_getetag.FullName()) != 0) 
     1182                                if ((*iter)->GetTextProperties().count(property.FullName()) != 0) 
    11541183                                { 
    1155                                         result = (*(*iter)->GetTextProperties().find(http::webdav::cProperty_getetag.FullName())).second; 
    1156                                          
    1157                                         // Handle server bug: ETag value MUST be quoted per HTTP/1.1 €3.11 
    1158                                         if (!result.isquoted()) 
    1159                                                 result.quote(true); 
     1184                                        result = (*(*iter)->GetTextProperties().find(property.FullName())).second; 
    11601185                                        break; 
    11611186                                } 
     
    11661191        { 
    11671192                HandleHTTPError(request.get()); 
    1168                 return result; 
    11691193        } 
    11701194 
     
    11931217 
    11941218                // Look at each propfind result and extract any Hrefs 
     1219                cdstring decoded_rurl = rurl; 
     1220                decoded_rurl.DecodeURL(); 
    11951221                for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter1 = parser.Results().begin(); iter1 != parser.Results().end(); iter1++) 
    11961222                { 
     
    12001226                 
    12011227                        // Must match rurl 
    1202                         if (name.compare_end(rurl)) 
     1228                        if (name.compare_end(decoded_rurl)) 
    12031229                        { 
    12041230                                if ((*iter1)->GetNodeProperties().count(propname.FullName()) != 0) 
     
    12421268 
    12431269                // Look at each principal-match result and return first one that is appropriate 
     1270                cdstring decoded_rurl = rurl; 
     1271                decoded_rurl.DecodeURL(); 
    12441272                for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter1 = parser.Results().begin(); iter1 != parser.Results().end(); iter1++) 
    12451273                { 
     
    12471275                        cdstring name((*iter1)->GetResource()); 
    12481276                        name.DecodeURL(); 
    1249                         if ((parser.Results().size() > 1) && (name.find("/users/") == cdstring::npos)) 
    1250                                 continue; 
     1277                        //if ((parser.Results().size() > 1) && (name.find("/users/") == cdstring::npos)) 
     1278                        //      continue; 
    12511279                 
    12521280                        for(xmllib::XMLNameList::const_iterator iter2 = props.begin(); iter2 != props.end(); iter2++) 
     
    12631291                                } 
    12641292                        } 
     1293                         
     1294                        // We'll take the first one, whatever that is 
     1295                        break; 
    12651296                } 
    12661297        } 
     
    15281559                        return; 
    15291560                } 
     1561                 
     1562                // Recache user id & password after successful logon 
     1563                if (GetAccount()->GetAuthenticator().RequiresUserPswd()) 
     1564                { 
     1565                        CAuthenticatorUserPswd* auth = GetAccount()->GetAuthenticatorUserPswd(); 
     1566 
     1567                        // Only bother if it contains something 
     1568                        if (!auth->GetPswd().empty()) 
     1569                        { 
     1570                                CPasswordManager::GetManager()->AddPassword(GetAccount(), auth->GetPswd()); 
     1571                        } 
     1572                } 
    15301573        } 
    15311574         
     
    15561599 
    15571600                                // Get authorization object (prompt the user) and redo the request 
    1558                                 mAuthorization = GetAuthorization(first_time, request->GetResponseHeader(cHeaderWWWAuthenticate)); 
     1601                                cdstrvect hdrs; 
     1602                                mAuthorization = GetAuthorization(first_time, request->GetResponseHeaders(cHeaderWWWAuthenticate, hdrs)); 
    15591603                                 
    15601604                                // Check for auth cancellation 
     
    15741618                        } 
    15751619                         
     1620                        // Recache user id & password after successful logon 
     1621                        if (!first_time && GetAccount()->GetAuthenticator().RequiresUserPswd()) 
     1622                        { 
     1623                                CAuthenticatorUserPswd* auth = GetAccount()->GetAuthenticatorUserPswd(); 
     1624 
     1625                                // Only bother if it contains something 
     1626                                if (!auth->GetPswd().empty()) 
     1627                                { 
     1628                                        CPasswordManager::GetManager()->AddPassword(GetAccount(), auth->GetPswd()); 
     1629                                } 
     1630                        } 
     1631 
    15761632                        // If we get here we are complete with auth loop 
    15771633                        break; 
     
    16131669} 
    16141670 
    1615 CHTTPAuthorization* CWebDAVCalendarClient::GetAuthorization(bool first_time, const cdstring& www_authenticate) 
     1671CHTTPAuthorization* CWebDAVCalendarClient::GetAuthorization(bool first_time, const cdstrvect& www_authenticate) 
    16161672{ 
    16171673        // Loop while trying to authentciate