Show
Ignore:
Timestamp:
02/03/08 20:17:26 (10 months ago)
Author:
cyrusdaboo
Message:

Add check calendar command/toolbar button to do fast checks of all active/open calendars.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Mulberry/branches/v4.1d1/Sources_Common/Calendar_Store/Protocols/CCalendarProtocol.cpp

    r113 r160  
    813813bool CCalendarProtocol::CheckCalendar(const CCalendarStoreNode& node, iCal::CICalendar& cal) 
    814814{ 
    815         bool result = mClient->_CheckCalendar(node, cal); 
    816          
    817         // Always keep disconnected cache in sync with server 
    818         if (result && (mCacheClient != NULL)) 
    819         { 
    820                 // If cache does not exist, create it 
    821                 if (!mCacheClient->_TestCalendar(node)) 
    822                 { 
    823                         mCacheClient->_CreateCalendar(node); 
    824                         mCacheClient->_WriteFullCalendar(node, cal); 
     815        bool result = false; 
     816 
     817        // See if offline or disconnected        
     818        if (IsOffline() || IsDisconnected()) 
     819        { 
     820                // Nothing to do here. We will assume that local files are always 
     821                // up to date. 
     822        } 
     823        else 
     824        { 
     825                // Look for local cache first 
     826                if ((mCacheClient != NULL) && !mCacheIsPrimary) 
     827                { 
     828                        // Read in the calendar cache if it exists 
     829                        if (mCacheClient->_TestCalendar(node)) 
     830                                mCacheClient->_ReadFullCalendar(node, cal); 
     831 
     832                        // Sync cache with server doing playback if needed 
     833                        SyncFromServer(node, cal); 
    825834                } 
    826835                else 
    827836                { 
    828                         // Get temp copy of cached calendar 
    829                         iCal::CICalendar temp; 
    830                         mCacheClient->_ReadFullCalendar(node, temp); 
    831                          
    832                         // Sync changes in cache 
    833                         bool server_changed = false; 
    834                         if (temp.GetETag() == cal.GetETag()) 
    835                         { 
    836                                 if (temp.NeedsSync()) 
    837                                 { 
    838                                         // Local overwrites server 
    839                                         cal.Clear(); 
    840                                         mCacheClient->_ReadFullCalendar(node, cal); 
    841                                         cal.ClearRecording(); 
    842                                         server_changed = true; 
    843                                 } 
    844                         } 
    845                         else 
    846                         { 
    847                                 if (!temp.NeedsSync()) 
    848                                 { 
    849                                         // Server overwrites local - nothing to do just fall through to write 
    850                                 } 
    851                                 else 
    852                                 { 
    853                                         // Sync the two 
    854                                         iCal::CICalendarSync sync(temp, cal); 
    855                                         sync.Sync(); 
    856                                          
    857                                         // Local overwrites server 
    858                                         cal.Clear(); 
    859                                         mCacheClient->_ReadFullCalendar(node, cal); 
    860                                         cal.ClearRecording(); 
    861                                 } 
    862                         } 
    863  
    864                         // Update the server if needed 
    865                         if (server_changed) 
    866                         { 
    867                                 mClient->_WriteFullCalendar(node, cal); 
    868                         } 
    869  
    870                         // Now write out the new cache data, this will overwrite any recorded 
    871                         // changes that have been sync'd so they will not be sync'd again 
    872                         mCacheClient->_WriteFullCalendar(node, cal); 
    873                 } 
    874         } 
    875          
     837                        // Just read full calendar from server 
     838                        result = mClient->_CalendarChanged(node, cal); 
     839                        if (result) 
     840                                ReadFullCalendar(node, cal); 
     841                } 
     842        } 
     843 
    876844        return result; 
    877845} 
     
    10411009                cdstrmap comps; 
    10421010                bool server_changed = mClient->_CalendarChanged(node, cal); 
     1011                bool changes_made = false; 
    10431012                if (server_changed) 
    10441013                        mClient->_GetComponentInfo(node, cal, comps); 
     
    10621031                                        // Add component to server 
    10631032                                        mClient->_AddComponent(node, cal, *comp); 
     1033                                        changes_made = true; 
    10641034 
    10651035                                        // Add to added cache 
     
    10761046                                        // Remove component from server 
    10771047                                        mClient->_RemoveComponent(node, cal, (*iter).second.GetRURL()); 
     1048                                        changes_made = true; 
    10781049                                         
    10791050                                        // Remove from server component info 
     
    10921063                                        const iCal::CICalendarComponent* comp = cal.GetComponentByKey((*iter).first); 
    10931064                                        mClient->_ChangeComponent(node, cal, *comp); 
     1065                                        changes_made = true; 
    10941066                                        cache_changed.insert(cdstrmap::value_type((*iter).second.GetRURL(), (*iter).second.GetETag())); 
    10951067                                } 
     
    11471119                                                // Write changed cache component to server 
    11481120                                                mClient->_ChangeComponent(node, cal, *cache_comp); 
     1121                                                changes_made = true; 
    11491122                                        } 
    11501123                                         
     
    11651138                                                                // Cache is newer than server - cache overwrites to server 
    11661139                                                                mClient->_ChangeComponent(node, cal, *cache_comp); 
     1140                                                                changes_made = true; 
    11671141                                                        } 
    11681142                                                        else if (result == -1) 
     
    12301204                cal.ClearRecording(); 
    12311205                 
    1232                 // Get the current server sync token 
    1233                 mClient->_UpdateSyncToken(node, cal); 
     1206                // Get the current server sync token if changes were made or it was differemt 
     1207                if (server_changed || changes_made) 
     1208                        mClient->_UpdateSyncToken(node, cal); 
    12341209 
    12351210                // Now write back cache