Changeset 169

Show
Ignore:
Timestamp:
07/04/08 14:57:53 (3 months ago)
Author:
cyrusdaboo
Message:

Only read web calendars when the etag has changed. Also extract user value from web calendar URIs
and use that for authentication.

Location:
Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients
Files:
7 modified

Legend:

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

    r113 r169  
    320320} 
    321321 
    322 void CCalDAVCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) 
     322void CCalDAVCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed) 
    323323{ 
    324324        // Start UI action 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CCalDAVCalendarClient.h

    r113 r169  
    6464        virtual void _UpdateSyncToken(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
    6565 
    66         virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
     66        virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed=false); 
    6767        virtual void _WriteFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
    6868 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CCalendarClient.h

    r113 r169  
    6363        virtual void _SizeCalendar(CCalendarStoreNode& node) = 0; 
    6464 
    65         virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) = 0; 
     65        virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed=false) = 0; 
    6666        virtual void _WriteFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) = 0; 
    6767 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CLocalCalendarClient.cpp

    r113 r169  
    526526} 
    527527 
    528 void CLocalCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) 
     528void CLocalCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed) 
    529529{ 
    530530        // Get name for new file 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CLocalCalendarClient.h

    r113 r169  
    7171        virtual void _SizeCalendar(CCalendarStoreNode& node); 
    7272         
    73         virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
     73        virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed=false); 
    7474        virtual void _WriteFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
    7575 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVCalendarClient.cpp

    r113 r169  
    673673} 
    674674 
    675 void CWebDAVCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) 
     675void CWebDAVCalendarClient::_ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed) 
    676676{ 
    677677        // Start UI action 
     
    692692                acct->SetServerIP(parsed.Server()); 
    693693                 
     694                // Handle authentication 
     695                if (!parsed.User().empty()) 
     696                { 
     697                        acct->GetAuthenticatorUserPswd()->SetUID(parsed.User()); 
     698                } 
     699 
    694700                // Set TLS type 
    695701                if ((parsed.SchemeType() == CURL::eHTTP) || (parsed.SchemeType() == CURL::eWebcal)) 
     
    713719        // Create WebDAV GET 
    714720        auto_ptr<http::webdav::CWebDAVGet> request(new http::webdav::CWebDAVGet(this, rurl)); 
     721        if (if_changed) 
     722                request->SetETag(cal.GetETag(), false); 
    715723        http::CHTTPOutputDataString dout; 
    716724        request->SetData(&dout); 
     
    719727        RunSession(request.get()); 
    720728         
    721          
    722729        // Check response status 
     730        bool changed = true; 
    723731        switch(request->GetStatusCode()) 
    724732        { 
    725733        case http::eStatus_OK: 
    726734                // Do default action 
     735                break; 
     736        case http::eStatus_NotModified: 
     737                // Nothing more to do 
     738                changed = false; 
    727739                break; 
    728740        default: 
     
    732744        } 
    733745 
    734         // Read calendar from file 
    735         cdstring data = dout.GetData(); 
    736         std::istrstream is(data.c_str()); 
    737         cal.Parse(is); 
    738          
    739         // Update ETag 
    740         if (request->GetNewETag() != NULL) 
    741         { 
    742                 cdstring temp(*request->GetNewETag()); 
    743  
    744                 // Handle server bug: ETag value MUST be quoted per HTTP/1.1 €3.11 
    745                 if (!temp.isquoted()) 
    746                         temp.quote(true); 
    747                  
    748                 cal.SetETag(temp); 
    749         } 
    750         else 
    751                 cal.SetETag(cdstring::null_str); 
    752          
    753         // Check read-only status 
    754         auto_ptr<http::webdav::CWebDAVOptions> optrequest(new http::webdav::CWebDAVOptions(this, rurl)); 
    755  
    756         // Process it 
    757         RunSession(optrequest.get()); 
    758          
    759          
    760         // Check response status 
    761         switch(optrequest->GetStatusCode()) 
    762         { 
    763         case http::eStatus_OK: 
    764         case http::eStatus_NoContent: 
    765                 // Do default action 
    766                 break; 
    767         case eStatus_NotImplemented: 
    768                 // Ignore failure 
    769                 return; 
    770         default: 
    771                 // Handle error and exit here 
    772                 HandleHTTPError(optrequest.get()); 
    773                 return; 
    774         } 
    775  
    776         // Look for PUT 
    777         cal.SetReadOnly(!optrequest->IsAllowed(http::cRequestPUT)); 
     746        if (changed) 
     747        { 
     748                // Read calendar from file 
     749                cdstring data = dout.GetData(); 
     750                std::istrstream is(data.c_str()); 
     751                cal.Parse(is); 
     752                 
     753                // Update ETag 
     754                if (request->GetNewETag() != NULL) 
     755                { 
     756                        cdstring temp(*request->GetNewETag()); 
     757 
     758                        // Handle server bug: ETag value MUST be quoted per HTTP/1.1 €3.11 
     759                        if (!temp.isquoted()) 
     760                                temp.quote(true); 
     761                         
     762                        cal.SetETag(temp); 
     763                } 
     764                else 
     765                        cal.SetETag(cdstring::null_str); 
     766                 
     767                // Check read-only status 
     768                auto_ptr<http::webdav::CWebDAVOptions> optrequest(new http::webdav::CWebDAVOptions(this, rurl)); 
     769 
     770                // Process it 
     771                RunSession(optrequest.get()); 
     772                 
     773                 
     774                // Check response status 
     775                switch(optrequest->GetStatusCode()) 
     776                { 
     777                case http::eStatus_OK: 
     778                case http::eStatus_NoContent: 
     779                        // Do default action 
     780                        break; 
     781                case eStatus_NotImplemented: 
     782                        // Ignore failure 
     783                        return; 
     784                default: 
     785                        // Handle error and exit here 
     786                        HandleHTTPError(optrequest.get()); 
     787                        return; 
     788                } 
     789 
     790                // Look for PUT 
     791                cal.SetReadOnly(!optrequest->IsAllowed(http::cRequestPUT)); 
     792        } 
    778793} 
    779794 
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Clients/CWebDAVCalendarClient.h

    r113 r169  
    8080        virtual void _SizeCalendar(CCalendarStoreNode& node); 
    8181 
    82         virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
     82        virtual void _ReadFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal, bool if_changed=false); 
    8383        virtual void _WriteFullCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal); 
    8484