Changeset 113 for Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVCalendarClient.cpp
- Timestamp:
- 10/28/07 23:41:34 (1 year ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVCalendarClient.cpp
r96 r113 29 29 //#include "CDisplayItem.h" 30 30 #include "CGeneralException.h" 31 #include "CPasswordManager.h" 31 32 #include "CStatusWindow.h" 32 33 #include "CStreamFilter.h" … … 568 569 } 569 570 571 void 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 570 586 void CWebDAVCalendarClient::_SizeCalendar(CCalendarStoreNode& node) 571 587 { … … 1123 1139 cdstring CWebDAVCalendarClient::GetETag(const cdstring& rurl, const cdstring& lock_token) 1124 1140 { 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 1150 cdstring CWebDAVCalendarClient::GetProperty(const cdstring& rurl, const cdstring& lock_token, const xmllib::XMLName& property) 1151 { 1125 1152 cdstring result; 1126 1153 1127 1154 // Create WebDAV propfind 1128 1155 xmllib::XMLNameList props; 1129 props.push_back( http::webdav::cProperty_getetag);1156 props.push_back(property); 1130 1157 auto_ptr<http::webdav::CWebDAVPropFind> request(new http::webdav::CWebDAVPropFind(this, rurl, http::webdav::eDepth0, props)); 1131 1158 http::CHTTPOutputDataString dout; … … 1142 1169 1143 1170 // Look at each propfind result and determine type of calendar 1171 cdstring decoded_rurl = rurl; 1172 decoded_rurl.DecodeURL(); 1144 1173 for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter = parser.Results().begin(); iter != parser.Results().end(); iter++) 1145 1174 { … … 1149 1178 1150 1179 // Must match rurl 1151 if (name.compare_end( rurl))1180 if (name.compare_end(decoded_rurl)) 1152 1181 { 1153 if ((*iter)->GetTextProperties().count( http::webdav::cProperty_getetag.FullName()) != 0)1182 if ((*iter)->GetTextProperties().count(property.FullName()) != 0) 1154 1183 { 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; 1160 1185 break; 1161 1186 } … … 1166 1191 { 1167 1192 HandleHTTPError(request.get()); 1168 return result;1169 1193 } 1170 1194 … … 1193 1217 1194 1218 // Look at each propfind result and extract any Hrefs 1219 cdstring decoded_rurl = rurl; 1220 decoded_rurl.DecodeURL(); 1195 1221 for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter1 = parser.Results().begin(); iter1 != parser.Results().end(); iter1++) 1196 1222 { … … 1200 1226 1201 1227 // Must match rurl 1202 if (name.compare_end( rurl))1228 if (name.compare_end(decoded_rurl)) 1203 1229 { 1204 1230 if ((*iter1)->GetNodeProperties().count(propname.FullName()) != 0) … … 1242 1268 1243 1269 // Look at each principal-match result and return first one that is appropriate 1270 cdstring decoded_rurl = rurl; 1271 decoded_rurl.DecodeURL(); 1244 1272 for(http::webdav::CWebDAVPropFindParser::CPropFindResults::const_iterator iter1 = parser.Results().begin(); iter1 != parser.Results().end(); iter1++) 1245 1273 { … … 1247 1275 cdstring name((*iter1)->GetResource()); 1248 1276 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; 1251 1279 1252 1280 for(xmllib::XMLNameList::const_iterator iter2 = props.begin(); iter2 != props.end(); iter2++) … … 1263 1291 } 1264 1292 } 1293 1294 // We'll take the first one, whatever that is 1295 break; 1265 1296 } 1266 1297 } … … 1528 1559 return; 1529 1560 } 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 } 1530 1573 } 1531 1574 … … 1556 1599 1557 1600 // 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)); 1559 1603 1560 1604 // Check for auth cancellation … … 1574 1618 } 1575 1619 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 1576 1632 // If we get here we are complete with auth loop 1577 1633 break; … … 1613 1669 } 1614 1670 1615 CHTTPAuthorization* CWebDAVCalendarClient::GetAuthorization(bool first_time, const cdstr ing& www_authenticate)1671 CHTTPAuthorization* CWebDAVCalendarClient::GetAuthorization(bool first_time, const cdstrvect& www_authenticate) 1616 1672 { 1617 1673 // Loop while trying to authentciate