activityfw/storage/server/src/afstoragesynctask.cpp
changeset 107 b34d53f6acdf
parent 99 7aaf39b772ac
child 112 dbfb5e38438b
equal deleted inserted replaced
106:e78d6e055a5b 107:b34d53f6acdf
    39         AddActivityL(dataStorage, msg);
    39         AddActivityL(dataStorage, msg);
    40         break;
    40         break;
    41     case UpdateActivity:
    41     case UpdateActivity:
    42         UpdateActivityL(dataStorage, msg);
    42         UpdateActivityL(dataStorage, msg);
    43         break;
    43         break;
       
    44     case SaveActivity:
       
    45         SaveActivityL(dataStorage, msg);
       
    46         break;        
    44     case RemoveActivity:
    47     case RemoveActivity:
    45         DeleteActivityL(dataStorage, msg);
    48         DeleteActivityL(dataStorage, msg);
    46         break;
    49         break;
    47     case RemoveApplicationActivities:
    50     case RemoveApplicationActivities:
    48         DeleteApplicationActivitiesL(dataStorage, msg);
    51         DeleteApplicationActivitiesL(dataStorage, msg);
    49         break;
    52         break;
    50     default:
    53     default:
    51         //this code shouldn't be called. fatal error: means wrong session implementation 
    54         //this code shouldn't be called. fatal error: means wrong session implementation 
    52         User::Panic(KUnsupportedStorageSyncTask, KErrGeneral);
    55         User::Panic(KUnsupportedStorageSyncTask, KErrGeneral);
    53     };
    56     };
    54     msg.Complete(KErrNone);
    57     if(SaveActivity != msg.Function()) {
       
    58         //function SaveActivityL complete message. DON'T DO THIS HERE
       
    59         msg.Complete(KErrNone);
       
    60     }
    55     NotifyChangeL(observers, msg);
    61     NotifyChangeL(observers, msg);
    56 }
    62 }
    57 
    63 
    58 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    59 /**
    65 /**
    78                    entry->Flags() & CAfEntry::Persistent);
    84                    entry->Flags() & CAfEntry::Persistent);
    79     CreateThumbnailL(thumbnailPath, bitmapHdl());
    85     CreateThumbnailL(thumbnailPath, bitmapHdl());
    80     entry->SetImageSrcL(thumbnailPath);
    86     entry->SetImageSrcL(thumbnailPath);
    81     dataStorage.AddActivityL(*entry);
    87     dataStorage.AddActivityL(*entry);
    82     CleanupStack::PopAndDestroy(&thumbnailPath);
    88     CleanupStack::PopAndDestroy(&thumbnailPath);
    83     
       
    84     CleanupStack::PopAndDestroy(entry);
    89     CleanupStack::PopAndDestroy(entry);
    85 }
    90 }
    86 
    91 
    87 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
    88 /**
    93 /**
   100     RBuf thumbnailPath;
   105     RBuf thumbnailPath;
   101     CleanupClosePushL(thumbnailPath);
   106     CleanupClosePushL(thumbnailPath);
   102     DeleteActivityScreenshotL(dataStorage, 
   107     DeleteActivityScreenshotL(dataStorage, 
   103                     entry->ApplicationId(), 
   108                     entry->ApplicationId(), 
   104                     entry->ActivityId());
   109                     entry->ActivityId());
   105     
       
   106     dataStorage.ThumbnailPathL(thumbnailPath, 
   110     dataStorage.ThumbnailPathL(thumbnailPath, 
   107                    dataStorage.Fs(), 
   111                    dataStorage.Fs(), 
   108                    entry->ApplicationId(), 
   112                    entry->ApplicationId(), 
   109                    entry->ActivityId(),
   113                    entry->ActivityId(),
   110                    entry->Flags() & CAfEntry::Persistent);
   114                    entry->Flags() & CAfEntry::Persistent);
   111     CreateThumbnailL(thumbnailPath, bitmapHdl());
   115     CreateThumbnailL(thumbnailPath, bitmapHdl());
   112     entry->SetImageSrcL(thumbnailPath);
   116     entry->SetImageSrcL(thumbnailPath);
   113     dataStorage.UpdateActivityL(*entry);
   117     dataStorage.UpdateActivityL(*entry);
       
   118     CleanupStack::PopAndDestroy(&thumbnailPath);
       
   119     CleanupStack::PopAndDestroy(entry);
       
   120 }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 /**
       
   124  * Handle saving activiy
       
   125  * @param dataStorage - data storage
       
   126  * @param msg - request message
       
   127  */
       
   128 void AfStorageSyncTask::SaveActivityL(CAfStorage& dataStorage, const RMessage2& msg)
       
   129 {
       
   130     TPckgBuf<TInt> bitmapHdl(0);
       
   131     CAfEntry *entry = CAfEntry::NewLC(msg);
       
   132     msg.ReadL(1, bitmapHdl);
       
   133         
       
   134     RBuf thumbnailPath;
       
   135     CleanupClosePushL(thumbnailPath);
       
   136     DeleteActivityScreenshotL(dataStorage, 
       
   137                     entry->ApplicationId(), 
       
   138                     entry->ActivityId());
       
   139     
       
   140     dataStorage.ThumbnailPathL(thumbnailPath, 
       
   141                    dataStorage.Fs(), 
       
   142                    entry->ApplicationId(), 
       
   143                    entry->ActivityId(),
       
   144                    entry->Flags() & CAfEntry::Persistent);
       
   145     CreateThumbnailL(thumbnailPath, bitmapHdl());
       
   146     //all data is retrieved. compleate message to improve response time
       
   147     msg.Complete(KErrNone);
       
   148     TRAP_IGNORE(entry->SetImageSrcL(thumbnailPath);
       
   149     dataStorage.SaveActivityL(*entry);)
   114     CleanupStack::PopAndDestroy(&thumbnailPath);
   150     CleanupStack::PopAndDestroy(&thumbnailPath);
   115     CleanupStack::PopAndDestroy(entry);
   151     CleanupStack::PopAndDestroy(entry);
   116 }
   152 }
   117 
   153 
   118 // -----------------------------------------------------------------------------
   154 // -----------------------------------------------------------------------------