activityfw/storage/server/src/afstoragesynctask.cpp
changeset 124 e36b2f4799c0
parent 115 3ab5c078b490
child 125 26079c1bb561
equal deleted inserted replaced
121:0b3699f6c654 124:e36b2f4799c0
    33 void AfStorageSyncTask::ExecuteL(MAfTaskStorage& observers,
    33 void AfStorageSyncTask::ExecuteL(MAfTaskStorage& observers,
    34                                  CAfStorage& dataStorage, 
    34                                  CAfStorage& dataStorage, 
    35                                  const RMessage2& msg)
    35                                  const RMessage2& msg)
    36 {
    36 {
    37     switch (msg.Function()) {
    37     switch (msg.Function()) {
    38     case AddActivity: 
       
    39         AddActivityL(dataStorage, msg);
       
    40         break;
       
    41     case UpdateActivity:
       
    42         UpdateActivityL(dataStorage, msg);
       
    43         break;
       
    44     case SaveActivity:
    38     case SaveActivity:
    45         SaveActivityL(dataStorage, msg);
    39         SaveActivityL(dataStorage, msg);
    46         break;        
    40         break;        
    47     case RemoveActivity:
    41     case RemoveActivity:
    48         DeleteActivityL(dataStorage, msg);
    42         DeleteActivityL(dataStorage, msg);
    57     if(SaveActivity != msg.Function()) {
    51     if(SaveActivity != msg.Function()) {
    58         //function SaveActivityL complete message. DON'T DO THIS HERE
    52         //function SaveActivityL complete message. DON'T DO THIS HERE
    59         msg.Complete(KErrNone);
    53         msg.Complete(KErrNone);
    60     }
    54     }
    61     NotifyChangeL(observers, msg);
    55     NotifyChangeL(observers, msg);
    62 }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 /**
       
    66  * Handle adding new activity.
       
    67  * @param dataStorage - data storage
       
    68  * @param msg - request message
       
    69  */
       
    70 void AfStorageSyncTask::AddActivityL(CAfStorage& dataStorage, 
       
    71                                      const RMessage2& msg)
       
    72 {
       
    73     //Read message and bitmap handle
       
    74     TPckgBuf<TInt> bitmapHdl(0);
       
    75     CAfEntry *entry = CAfEntry::NewLC(msg);
       
    76     msg.ReadL(1, bitmapHdl);
       
    77     
       
    78     RBuf thumbnailPath;
       
    79     CleanupClosePushL(thumbnailPath);
       
    80     dataStorage.ThumbnailPathL(thumbnailPath, 
       
    81                    dataStorage.Fs(), 
       
    82                    entry->ApplicationId(), 
       
    83                    entry->ActivityId(),
       
    84                    entry->Flags() & CAfEntry::Persistent);
       
    85     CreateThumbnailL(thumbnailPath, bitmapHdl());
       
    86     entry->SetImageSrcL(thumbnailPath);
       
    87     dataStorage.AddActivityL(*entry);
       
    88     CleanupStack::PopAndDestroy(&thumbnailPath);
       
    89     CleanupStack::PopAndDestroy(entry);
       
    90 }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 /**
       
    94  * Handle updating existing activiy
       
    95  * @param dataStorage - data storage
       
    96  * @param msg - request message
       
    97  */
       
    98 void AfStorageSyncTask::UpdateActivityL(CAfStorage& dataStorage, 
       
    99                                         const RMessage2& msg)
       
   100 {
       
   101     TPckgBuf<TInt> bitmapHdl(0);
       
   102     CAfEntry *entry = CAfEntry::NewLC(msg);
       
   103     msg.ReadL(1, bitmapHdl);
       
   104         
       
   105     RBuf thumbnailPath;
       
   106     CleanupClosePushL(thumbnailPath);
       
   107     DeleteActivityScreenshotL(dataStorage, 
       
   108                     entry->ApplicationId(), 
       
   109                     entry->ActivityId());
       
   110     dataStorage.ThumbnailPathL(thumbnailPath, 
       
   111                    dataStorage.Fs(), 
       
   112                    entry->ApplicationId(), 
       
   113                    entry->ActivityId(),
       
   114                    entry->Flags() & CAfEntry::Persistent);
       
   115     CreateThumbnailL(thumbnailPath, bitmapHdl());
       
   116     entry->SetImageSrcL(thumbnailPath);
       
   117     dataStorage.UpdateActivityL(*entry);
       
   118     CleanupStack::PopAndDestroy(&thumbnailPath);
       
   119     CleanupStack::PopAndDestroy(entry);
       
   120 }
    56 }
   121 
    57 
   122 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
   123 /**
    59 /**
   124  * Handle saving activiy
    60  * Handle saving activiy