videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp
branchRCL_3
changeset 45 baf439b22ddd
parent 26 67eb01668b0e
child 56 839377eedc2b
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp	Wed Jun 09 09:44:23 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp	Mon Jun 21 15:43:03 2010 +0300
@@ -100,7 +100,7 @@
     MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL");
     
     User::LeaveIfError( iFs.Connect() );
-#ifdef VIDEO_COLLECTION_PLUGIN_TB92        
+#ifndef VCX_ALBUMS        
     iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs );    
 #else
     iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() );
@@ -403,9 +403,10 @@
 //
 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent(
         TMPXChangeEventType aEvent,
-        RArray<TUint32>& aId )
+        RArray<TUint32>& aId,
+        TInt aEventsLeft )
     {
-    TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId ));
+    TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId, aEventsLeft ));
     if ( err != KErrNone )
         {
         MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err);
@@ -418,7 +419,8 @@
 //
 void CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL(
         TMPXChangeEventType aEvent,
-        RArray<TUint32>& aId )
+        RArray<TUint32>& aId,
+        TInt /*aEventsLeft*/ )
     {
     MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL");
     
@@ -433,9 +435,14 @@
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------.");
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" );
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'");
-                        
-            iCache->RemoveL( aId );
-#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+
+            iCache->RemoveL( aId, EFalse );
+            
+            CategoriesL().ResetVideoCountersL();
+            CategoriesL().UpdateCategoriesL( *iCache->iVideoList, 0 );
+            CategoriesL().UpdateCategoriesNewVideoNamesL();
+            
+#ifdef VCX_ALBUMS 
             AlbumsL().RemoveAlbumsL( aId );
 #endif
             }
@@ -460,9 +467,14 @@
             // We receive add events for all object types. When fetching the item from MDS we use
             // video condition and only video objects are added to cache. Items which were detected
             // to not be videos are added to nonVideoIds.
-            iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds );
+            iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled,
+                    &nonVideoIds, EFalse /* dont update categories*/ );
 
-#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            CategoriesL().ResetVideoCountersL();
+            CategoriesL().UpdateCategoriesL( *iCache->iVideoList, 0 );
+            CategoriesL().UpdateCategoriesNewVideoNamesL();
+            
+#ifdef VCX_ALBUMS
 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection
             
             //After the call nonVideoIds will contain only items which were actually added
@@ -485,7 +497,7 @@
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |");
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'");
             CMPXMedia* video;
-#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+#ifdef VCX_ALBUMS
             CMPXMedia* album;
 #endif
             TInt count = aId.Count();
@@ -501,7 +513,7 @@
                     }
                 else
                     {
-#ifdef VIDEO_COLLECTION_PLUGIN_TB92
+#ifndef VCX_ALBUMS
                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS");
                     aId.Remove( i );
 #else
@@ -545,7 +557,7 @@
                 }
             }
 
-#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+#ifdef VCX_ALBUMS
     //nonVideoIds are albums
     count = nonVideoIds.Count();
     for ( TInt i = 0; i < count; i++ )
@@ -709,6 +721,7 @@
                     SetTransactionIdL( cmd, *message );
                             
                     iMessageList->AddL( message );
+                    CleanupStack::Pop( message );            //  <-3
                     iMessageList->SendL();
 
                     if ( videoListFetchingWasCancelled )
@@ -717,7 +730,6 @@
                         RestartVideoListFetchingL();
                         }
 
-                    CleanupStack::Pop( message );            //  <-3
                     CleanupStack::PopAndDestroy( &mdsIds2 ); //  <-2
                     CleanupStack::PopAndDestroy( &mdsIds );  //  <-1
                         
@@ -964,7 +976,7 @@
     ids.Reset();
     CleanupClosePushL( ids ); // 1->
     ids.AppendL( mpxId.iId1 );
-    HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache
+    HandleMyVideosDbEvent( EMPXItemInserted, ids, 0 ); //this will fetch from mds to cache
     CleanupStack::PopAndDestroy( &ids ); // <-1
     }