videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 38 ff53afa8ad05
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
   249 // ----------------------------------------------------------------------------
   249 // ----------------------------------------------------------------------------
   250 //
   250 //
   251 void CVcxMyVideosCollectionPlugin::CommandL(
   251 void CVcxMyVideosCollectionPlugin::CommandL(
   252     CMPXCommand& aCmd)
   252     CMPXCommand& aCmd)
   253     {
   253     {
   254     MPX_FUNC("CVcxMyVideosCollectionPlugin::CommandL 2");
   254     MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() start");
   255 
   255 
   256     if ( !aCmd.IsSupported( KMPXCommandGeneralId ) )
   256     if ( !aCmd.IsSupported( KMPXCommandGeneralId ) )
   257         {
   257         {
   258         User::Leave( KErrArgument );
   258         User::Leave( KErrArgument );
   259         }
   259         }
   347                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: UNKNOWN SYNC COMMAND ARRIVED");
   347                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: UNKNOWN SYNC COMMAND ARRIVED");
   348                 User::Leave( KErrNotSupported );
   348                 User::Leave( KErrNotSupported );
   349                 }
   349                 }
   350             }
   350             }
   351         }
   351         }
   352             
   352     MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() exit");            
   353     }
   353     }
   354 
   354 
   355 // ----------------------------------------------------------------------------
   355 // ----------------------------------------------------------------------------
   356 // Find the items matching the media specifications
   356 // Find the items matching the media specifications
   357 // ----------------------------------------------------------------------------
   357 // ----------------------------------------------------------------------------
   389 // CVcxMyVideosCollectionPlugin::SendMessages
   389 // CVcxMyVideosCollectionPlugin::SendMessages
   390 // ----------------------------------------------------------------------------------------------------------
   390 // ----------------------------------------------------------------------------------------------------------
   391 //
   391 //
   392 void CVcxMyVideosCollectionPlugin::SendMessages( CMPXMessage& aMessages )
   392 void CVcxMyVideosCollectionPlugin::SendMessages( CMPXMessage& aMessages )
   393     {
   393     {
   394 #if _DEBUG
       
   395     TRAP_IGNORE(
       
   396 
       
   397     if ( aMessages.IsSupported( KMPXMessageArrayContents ) )
       
   398         {
       
   399         const CMPXMessageArray* messageArray =
       
   400             aMessages.Value<CMPXMessageArray>(KMPXMessageArrayContents);
       
   401             
       
   402         for( TInt i = 0; i < messageArray->Count(); i++ )
       
   403             {            
       
   404             MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: sending message ID: %d in array", ++iTotalMessagesSent);
       
   405             messageArray->AtL( i )->SetTObjectValueL<TUint32>( KVcxMediaMyVideosMessageId, iTotalMessagesSent );
       
   406             iMessagesInArraySent++;
       
   407             }    
       
   408 
       
   409         MPX_DEBUG3("CVcxMyVideosCollectionPlugin:: total messages sent (MSG ID): %d, messages in array sent: %d",
       
   410             iTotalMessagesSent, iMessagesInArraySent);
       
   411         }
       
   412     else
       
   413         {
       
   414         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: NO ARRAY IN MESSAGE!!!");
       
   415         return;
       
   416         }
       
   417 
       
   418     );
       
   419 #endif
       
   420 
       
   421     iObs->HandleMessage( aMessages );
   394     iObs->HandleMessage( aMessages );
   422     }
   395     }
   423 
   396 
   424 // ----------------------------------------------------------------------------------------------------------
   397 // ----------------------------------------------------------------------------------------------------------
   425 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent
   398 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent
   427 //
   400 //
   428 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent(
   401 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent(
   429         TMPXChangeEventType aEvent,
   402         TMPXChangeEventType aEvent,
   430         RArray<TUint32>& aId )
   403         RArray<TUint32>& aId )
   431     {
   404     {
   432     //MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent");
       
   433     TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId ));
   405     TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId ));
   434     if ( err != KErrNone )
   406     if ( err != KErrNone )
   435         {
   407         {
   436         MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err);
   408         MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err);
   437         }
   409         }
   686                         }
   658                         }
   687 
   659 
   688                     if ( !iCache->iVideoList )
   660                     if ( !iCache->iVideoList )
   689                         {
   661                         {
   690                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iCache->iVideoList");
   662                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iCache->iVideoList");
   691                         iCache->iVideoListIsPartial = ETrue;
   663                         iCache->SetComplete( EFalse );
   692                         iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
   664                         iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
   693                         }
   665                         }
   694 
   666 
   695                     TBool videoListFetchingWasCancelled = EFalse;
   667                     TBool videoListFetchingWasCancelled = EFalse;
   696                         
   668                         
   697                     if ( iCache->iVideoListIsPartial )
   669                     if ( !iCache->IsComplete() )
   698                         {                            
   670                         {                            
   699                         // Load items to cache
   671                         // Load items to cache
   700                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: loading requested items to iCache->iVideoList");
   672                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: loading requested items to iCache->iVideoList");
   701                         
   673                         
   702                         iCache->AddVideosFromMdsL( mdsIds, videoListFetchingWasCancelled );
   674                         iCache->AddVideosFromMdsL( mdsIds, videoListFetchingWasCancelled );
  1118             EVcxMyVideosVideoListOrderChanged );
  1090             EVcxMyVideosVideoListOrderChanged );
  1119 
  1091 
  1120     iMessageList->SendL();    
  1092     iMessageList->SendL();    
  1121     }
  1093     }
  1122 
  1094 
  1123 #if 0
       
  1124 // ----------------------------------------------------------------------------
       
  1125 // CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL
       
  1126 // ----------------------------------------------------------------------------
       
  1127 //
       
  1128 void CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL( TUint aDownloadId )
       
  1129     {
       
  1130     CMPXMedia* video = iCache->FindVideoByDownloadIdL( aDownloadId );
       
  1131     if ( video )
       
  1132         {
       
  1133         video->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
       
  1134         video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState,
       
  1135                 static_cast<TUint8>( EVcxMyVideosDlStateNone ) );
       
  1136         iMyVideosMdsDb->UpdateVideoL( *video );
       
  1137         iMessageList->AddEventL( TVcxMyVideosCollectionUtil::IdL(
       
  1138                 *video ), EMPXItemModified );
       
  1139         iMessageList->SendL();
       
  1140         }
       
  1141     }
       
  1142     
       
  1143 #ifdef _DEBUG
       
  1144 // ----------------------------------------------------------------------------
       
  1145 // CVcxMyVideosCollectionPlugin::DownloadState
       
  1146 // ----------------------------------------------------------------------------
       
  1147 //
       
  1148 const TDesC& CVcxMyVideosCollectionPlugin::DownloadState( TUint8 aDlState )
       
  1149     {
       
  1150     _LIT(KDlStateNoneDes, "None");
       
  1151     _LIT(KDlStateDownloadingDes, "Downloading");
       
  1152     _LIT(KDlStateFailedDes, "Failed");
       
  1153     _LIT(KDlStatePausedDes, "Paused");
       
  1154     _LIT(KDlStateDownloadedDes, "Downloaded");
       
  1155 
       
  1156     switch ( aDlState )
       
  1157         {
       
  1158         case EVcxMyVideosDlStateNone:
       
  1159             return KDlStateNoneDes;
       
  1160         case EVcxMyVideosDlStateDownloading:
       
  1161             return KDlStateDownloadingDes;
       
  1162         case EVcxMyVideosDlStateFailed:
       
  1163             return KDlStateFailedDes;
       
  1164         case EVcxMyVideosDlStatePaused:
       
  1165             return KDlStatePausedDes;
       
  1166         case EVcxMyVideosDlStateDownloaded:
       
  1167             return KDlStateDownloadedDes;
       
  1168         default:
       
  1169             return KNullDesC;
       
  1170         }
       
  1171     }
       
  1172 #endif
       
  1173 
       
  1174 #endif