Changeset 113
- Timestamp:
- 10/28/07 23:41:34 (1 year ago)
- Location:
- Mulberry/branches/v4.1d1/Sources_Common
- Files:
-
- 25 modified
-
Calendar_Store/CCalendarStoreNode.cpp (modified) (2 diffs)
-
Calendar_Store/CCalendarStoreNode.h (modified) (1 diff)
-
Calendar_Store/CCalendarStoreXML.cpp (modified) (2 diffs)
-
Calendar_Store/CCalendarStoreXML.h (modified) (1 diff)
-
Calendar_Store/Clients/CCalDAVCalendarClient.cpp (modified) (1 diff)
-
Calendar_Store/Clients/CCalDAVCalendarClient.h (modified) (1 diff)
-
Calendar_Store/Clients/CCalendarClient.h (modified) (1 diff)
-
Calendar_Store/Clients/CLocalCalendarClient.cpp (modified) (1 diff)
-
Calendar_Store/Clients/CLocalCalendarClient.h (modified) (1 diff)
-
Calendar_Store/Clients/CWebDAVCalendarClient.cpp (modified) (15 diffs)
-
Calendar_Store/Clients/CWebDAVCalendarClient.h (modified) (3 diffs)
-
Calendar_Store/Clients/CWebDAVDefinitions.cpp (modified) (1 diff)
-
Calendar_Store/Clients/CWebDAVDefinitions.h (modified) (1 diff)
-
Calendar_Store/Protocols/CCalendarProtocol.cpp (modified) (12 diffs)
-
Calendar_Store/Protocols/CCalendarProtocol.h (modified) (2 diffs)
-
HTTP/WebDAVClient/CWebDAVPropFindParser.cpp (modified) (1 diff)
-
HTTP/WebDAVClient/CWebDAVSession.cpp (modified) (1 diff)
-
HTTP/WebDAVClient/CWebDAVSession.h (modified) (1 diff)
-
Mail/Protocols/CAdbkProtocol.cp (modified) (7 diffs)
-
Mail/Protocols/CAdbkProtocol.h (modified) (2 diffs)
-
VCard_Store/CVCardStoreXML.cpp (modified) (2 diffs)
-
VCard_Store/CVCardStoreXML.h (modified) (1 diff)
-
VCard_Store/Clients/CLocalVCardClient.cpp (modified) (1 diff)
-
VCard_Store/Clients/CWebDAVVCardClient.cpp (modified) (5 diffs)
-
VCard_Store/Clients/CWebDAVVCardClient.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/CCalendarStoreNode.cpp
r86 r113 909 909 xmllib::XMLObject::WriteValue(doc, xmlnode, cXMLElement_name, cdstring(GetShortName())); 910 910 911 // Set last sync child node911 // Set sync child nodes 912 912 if (mLastSync != 0) 913 913 xmllib::XMLObject::WriteValue(doc, xmlnode, cXMLElement_lastsync, mLastSync); … … 974 974 SetName(new_name); 975 975 976 // Get last sync976 // Get sync details 977 977 xmllib::XMLObject::ReadValue(xmlnode, cXMLElement_lastsync, mLastSync); 978 978 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/CCalendarStoreNode.h
r86 r113 264 264 const char* mShortName; // Pointer to the last part of the path name 265 265 uint32_t mSize; // Disk size 266 mutable uint32_t mLastSync; // Las ysync time266 mutable uint32_t mLastSync; // Last sync time 267 267 SACLRight mMyRights; // User's rights on this mailbox 268 268 CCalendarACLList* mACLs; // List of ACLs on this mailbox -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/CCalendarStoreXML.cpp
r19 r113 41 41 42 42 <!ELEMENT calendarlist (calendarnode*) > 43 <!ATTLIST calendarlist version CDATA #REQUIRED > 43 <!ATTLIST calendarlist version CDATA #REQUIRED 44 datestamp CDATA ""> 44 45 45 46 <!ELEMENT calendarnode (name, last-sync?, webcal?, calendarnode*) > … … 69 70 const xmllib::XMLName cXMLElement_calendarlist("calendarlist"); 70 71 const char* cXMLAttribute_version = "version"; 72 const char* cXMLAttribute_datestamp = "datestamp"; 71 73 72 74 const xmllib::XMLName cXMLElement_calendarnode("calendarnode"); -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/CCalendarStoreXML.h
r19 r113 31 31 extern const xmllib::XMLName cXMLElement_calendarlist; 32 32 extern const char* cXMLAttribute_version; 33 extern const char* cXMLAttribute_datestamp; 33 34 extern const char* cXMLAttribute_has_expanded; 34 35 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CCalDAVCalendarClient.cpp
r96 r113 198 198 bool CCalDAVCalendarClient::_CalendarChanged(const CCalendarStoreNode& node, iCal::CICalendar& cal) 199 199 { 200 // For CalDAV we always have to do a component sync 201 return true; 200 // Start UI action 201 StINETClientAction _action(this, "Status::Calendar::Checking", "Error::Calendar::OSErrCheckCalendar", "Error::Calendar::NoBadCheckCalendar", node.GetName()); 202 203 // Determine URL and lock 204 cdstring rurl = GetRURL(&node); 205 cdstring lock_token = GetLockToken(rurl); 206 207 // Get current CTag 208 cdstring ctag = GetProperty(rurl, lock_token, http::calendarserver::cProperty_getctag); 209 210 // Changed if ctags are different 211 return ctag.empty() || (ctag != cal.GetETag()); 212 } 213 214 void CCalDAVCalendarClient::_UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal) 215 { 216 // Start UI action 217 StINETClientAction _action(this, "Status::Calendar::Checking", "Error::Calendar::OSErrCheckCalendar", "Error::Calendar::NoBadCheckCalendar", node.GetName()); 218 219 // Determine URL and lock 220 cdstring rurl = GetRURL(&node); 221 cdstring lock_token = GetLockToken(rurl); 222 223 // Get current CTag 224 cdstring ctag = GetProperty(rurl, lock_token, http::calendarserver::cProperty_getctag); 225 226 cal.SetETag(ctag); 202 227 } 203 228 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CCalDAVCalendarClient.h
r86 r113 62 62 virtual void _CreateCalendar(const CCalendarStoreNode& node); 63 63 virtual bool _CalendarChanged(const CCalendarStoreNode& node, iCal::CICalendar& cal); 64 virtual void _UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal); 64 65 65 66 virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CCalendarClient.h
r86 r113 60 60 virtual bool _CheckCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) = 0; 61 61 virtual bool _CalendarChanged(const CCalendarStoreNode& node, iCal::CICalendar& cal) = 0; 62 virtual void _UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal) = 0; 62 63 virtual void _SizeCalendar(CCalendarStoreNode& node) = 0; 63 64 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CLocalCalendarClient.cpp
r86 r113 486 486 } 487 487 488 void CLocalCalendarClient::_UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal) 489 { 490 // Nothing to do for local as this is only used when sync'ing with server 491 } 492 488 493 void CLocalCalendarClient::_SizeCalendar(CCalendarStoreNode& node) 489 494 { -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CLocalCalendarClient.h
r86 r113 68 68 virtual bool _CheckCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 69 69 virtual bool _CalendarChanged(const CCalendarStoreNode& node, iCal::CICalendar& cal); 70 virtual void _UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal); 70 71 virtual void _SizeCalendar(CCalendarStoreNode& node); 71 72 -
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 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVCalendarClient.h
r86 r113 77 77 virtual bool _CheckCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 78 78 virtual bool _CalendarChanged(const CCalendarStoreNode& node, iCal::CICalendar& cal); 79 virtual void _UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal); 79 80 virtual void _SizeCalendar(CCalendarStoreNode& node); 80 81 … … 121 122 virtual void SetServerCapability(const cdstring& txt); 122 123 123 virtual CHTTPAuthorization* GetAuthorization(bool first_time, const cdstr ing& www_authenticate);124 virtual CHTTPAuthorization* GetAuthorization(bool first_time, const cdstrvect& www_authenticate); 124 125 bool CheckCurrentAuthorization() const; 125 126 virtual void DoRequest(CHTTPRequestResponse* request); … … 141 142 142 143 cdstring GetETag(const cdstring& rurl, const cdstring& lock_token = cdstring::null_str); 144 cdstring GetProperty(const cdstring& rurl, const cdstring& lock_token, const xmllib::XMLName& property); 143 145 cdstrvect GetHrefListProperty(const cdstring& rurl, const xmllib::XMLName& propname); 144 146 bool GetSelfProperties(const cdstring& rurl, const xmllib::XMLNameList& props, cdstrmap& results); -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVDefinitions.cpp
r86 r113 195 195 } 196 196 197 } 197 namespace calendarserver 198 { 199 const char* cNamespace = "http://calendarserver.org/ns/"; 200 201 const xmllib::XMLName cProperty_getctag("getctag", cNamespace); 202 } 203 204 } -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVDefinitions.h
r86 r113 196 196 } 197 197 198 namespace calendarserver 199 { 200 extern const char* cNamespace; 201 202 extern const xmllib::XMLName cProperty_getctag; 203 } 204 198 205 } // namespace http 199 206 -
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Protocols/CCalendarProtocol.cpp
r86 r113 32 32 #include "CConnectionManager.h" 33 33 #include "CLocalCalendarClient.h" 34 #include "CPasswordManager.h" 34 35 #include "CPreferences.h" 35 36 #include "CWebDAVCalendarClient.h" … … 38 39 39 40 #include "CICalendarSync.h" 41 #include "CICalendarDateTime.h" 42 #include "CICalendarDuration.h" 40 43 41 44 #include "XMLDocument.h" … … 60 63 mCacheIsPrimary = false; 61 64 mSyncingList = false; 65 mListedFromCache = false; 62 66 63 67 // Only WebDAV servers can disconnect … … 482 486 // Only bother if it contains something 483 487 if (!auth->GetPswd().empty()) 488 { 484 489 CCalendarProtocol::SetCachedPswd(auth->GetUID(), auth->GetPswd()); 490 CPasswordManager::GetManager()->AddPassword(GetAccount(), auth->GetPswd()); 491 } 485 492 } 486 493 … … 569 576 else 570 577 { 571 // Now get new list 572 mClient->_ListCalendars(&mStoreRoot); 573 574 // Always keep disconnected cache list in sync with server 575 if (mCacheClient != NULL) 576 { 577 DumpCalendars(); 578 } 578 // First try the disconnected cache - but only use if current 579 if (mListedFromCache || ((mCacheClient == NULL) || !ReadCalendars(true))) 580 { 581 // Now get new list 582 mClient->_ListCalendars(&mStoreRoot); 583 584 // Always keep disconnected cache list in sync with server 585 if (mCacheClient != NULL) 586 { 587 DumpCalendars(); 588 } 589 } 590 else 591 mListedFromCache = true; 579 592 } 580 593 … … 1006 1019 // 2.1 Add new components to server and cache info 1007 1020 // 2.2 Remove deleted components from server and cached server info if still present on server 1008 // 2.3 Cache info for changed items for later sync 1021 // 2.3 Cache info for changed items for later sync (or change them immediately if the server has not changed 1009 1022 // 1010 1023 // 3. Scan list of local components … … 1020 1033 // 4. Copy remaining items in server set to local cache - they are new items 1021 1034 // 1035 // We only need to do steps 3 & 4 if the data on the server is known to have changed. 1036 // 1022 1037 1023 1038 // Now do it... … … 1025 1040 // Step 1 1026 1041 cdstrmap comps; 1027 mClient->_GetComponentInfo(node, cal, comps); 1042 bool server_changed = mClient->_CalendarChanged(node, cal); 1043 if (server_changed) 1044 mClient->_GetComponentInfo(node, cal, comps); 1045 else 1046 { 1047 mCacheClient->_ReadFullCalendar(node, cal); 1048 } 1028 1049 1029 1050 // Step 2 … … 1063 1084 // Step 2.3 1064 1085 else if ((*iter).second.GetAction() == iCal::CICalendarComponentRecord::eChanged) 1065 cache_changed.insert(cdstrmap::value_type((*iter).second.GetRURL(), (*iter).second.GetETag())); 1086 { 1087 if (server_changed) 1088 cache_changed.insert(cdstrmap::value_type((*iter).second.GetRURL(), (*iter).second.GetETag())); 1089 else 1090 { 1091 // Change it on the server 1092 const iCal::CICalendarComponent* comp = cal.GetComponentByKey((*iter).first); 1093 mClient->_ChangeComponent(node, cal, *comp); 1094 cache_changed.insert(cdstrmap::value_type((*iter).second.GetRURL(), (*iter).second.GetETag())); 1095 } 1096 } 1066 1097 } 1067 1098 1068 1099 1069 1100 // Now do sync 1070 1071 // Get component info from cache 1072 iCal::CICalendarComponentDBList dbs;