videocollection/hgmyvideos/src/vcxhgmyvideoscollectionclient.cpp
branchRCL_3
changeset 64 3eb824b18d67
parent 57 befca0ec475f
child 70 375929f879c2
--- a/videocollection/hgmyvideos/src/vcxhgmyvideoscollectionclient.cpp	Tue Sep 14 21:23:06 2010 +0300
+++ b/videocollection/hgmyvideos/src/vcxhgmyvideoscollectionclient.cpp	Wed Sep 15 12:15:24 2010 +0300
@@ -47,6 +47,7 @@
 const TInt KVcxHgEventLevelCategory = 2;
 const TInt KVcxHgEventLevelVideo    = 3;
 
+const TInt KVcxMpxLevelRoot       = 1;
 const TInt KVcxMpxLevelCategories = 2;
 const TInt KVcxMpxLevelVideos     = 3;
 
@@ -220,9 +221,20 @@
         }
     else if ( iCollectionLevel == KVcxMpxLevelVideos )
         {
-        // OpenL() will return a list if there has been any changes.
-        // No reply if list is same as with previous OpenL().
-        iCollectionUtility->Collection().OpenL();
+		TInt currentIndex = CategoryIndexL();
+		
+        if ( aIndex == currentIndex )
+            {
+            // OpenL() will return a list if there has been any changes.
+            // No reply if list is same as with previous OpenL().
+            iCollectionUtility->Collection().OpenL();
+            }
+        else
+            {
+            iCollectionUtility->Collection().BackL( );
+            iCollectionUtility->Collection().OpenL( aIndex );
+            iCollectionLevel = KErrNotFound;
+            }
         }
     else
         {
@@ -381,16 +393,30 @@
     IPTVLOGSTRING2_LOW_LEVEL( 
                 "CVcxHgMyVideosCollectionClient::PlayVideoL: Play video at collection index %d", aMpxItemId.iId1 );
     
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL(path);
+    CMPXCollectionPath* collectionPath = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( collectionPath );
     
-    path->AppendL( KVcxUidMyVideosMpxCollection );
-    path->AppendL( KVcxMvcCategoryIdAll );
-    path->AppendL( aMpxItemId );
-    path->SelectL( aMpxItemId );
-    
-    iCollectionUtility->Collection().OpenL( *path );
-    CleanupStack::PopAndDestroy(path);
+    if ( collectionPath->Levels() == KVcxMpxLevelVideos )
+        {
+        collectionPath->DeselectAll();
+        collectionPath->SelectL( aMpxItemId );
+        iCollectionUtility->Collection().OpenL( *collectionPath );
+	    }
+    else
+        {
+        CMPXCollectionPath* customPath = CMPXCollectionPath::NewL();
+        CleanupStack::PushL(customPath);
+        
+        customPath->AppendL( KVcxUidMyVideosMpxCollection );
+        customPath->AppendL( KVcxMvcCategoryIdAll );
+        customPath->AppendL( aMpxItemId );
+        customPath->SelectL( aMpxItemId );
+       
+        iCollectionUtility->Collection().OpenL( *customPath );
+        CleanupStack::PopAndDestroy( customPath );
+        }
+
+    CleanupStack::PopAndDestroy( collectionPath );
     }
 
 // -----------------------------------------------------------------------------
@@ -1140,6 +1166,24 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CVcxHgMyVideosCollectionClient::CategoryIndexL()
+// -----------------------------------------------------------------------------
+//
+TInt CVcxHgMyVideosCollectionClient::CategoryIndexL()
+    {
+    CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( path );
+    TInt index ( -1 );
+    if ( path->Levels() > KVcxMpxLevelCategories )
+        {
+        index = path->Index( KVcxMpxLevelRoot );
+        }
+    CleanupStack::PopAndDestroy( path );
+    
+    return index;
+    }
+
 #if defined(_DEBUG) && IPTV_LOGGING_METHOD != 0
 // -----------------------------------------------------------------------------
 // CVcxHgMyVideosCollectionClient::DebugPrintVideoListL()