videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionutil.cpp
changeset 34 bbb98528c666
parent 0 96612d01cf9f
child 35 3738fe97f027
equal deleted inserted replaced
33:48e74db5d516 34:bbb98528c666
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
    17 
    19 
    18 
    20 
    19 
    21 // INCLUDE FILES
    20 // INCLUDE FILES
    22 #include <mpxmedia.h>
    21 #include <mpxmedia.h>
   164                 break;
   163                 break;
   165                 }                
   164                 }                
   166             }
   165             }
   167         }
   166         }
   168     }
   167     }
   169     
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // TVcxMyVideosCollectionUtil::AppendToListL
       
   171 // New items in aToList will point to same shared memory as items in aFromList.
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void TVcxMyVideosCollectionUtil::AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList )
       
   175     {
       
   176     CMPXMedia* media;
       
   177     CMPXMediaArray* toArray   = aToList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   178     CMPXMediaArray* fromArray = aFromList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   179     TInt count = fromArray->Count();
       
   180     for ( TInt i = 0; i < count; i++ )
       
   181         {
       
   182         media = CMPXMedia::NewL( *(fromArray->AtL( i )) ); // points to same shared memory
       
   183         toArray->AppendL( media ); //ownership moves
       
   184         }
       
   185     }
       
   186 
   170 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   171 // This helper function converts drive letter to drive number
   188 // This helper function converts drive letter to drive number
   172 // ---------------------------------------------------------------------------
   189 // ---------------------------------------------------------------------------
   173 //
   190 //
   174 TInt TVcxMyVideosCollectionUtil::DriveLetter2DriveNumber( const TDesC &aDrive )
   191 TInt TVcxMyVideosCollectionUtil::DriveLetter2DriveNumber( const TDesC &aDrive )
   211             }
   228             }
   212         else
   229         else
   213             {
   230             {
   214             aUniquePath  = aPath.Mid( 0, pos );
   231             aUniquePath  = aPath.Mid( 0, pos );
   215             }
   232             }
   216         counterDigits.Format(_L("%d"), counter++);
   233         _LIT(KPercentD, "%d");
       
   234         counterDigits.Format( KPercentD, counter++ );
   217         aUniquePath.Append( '_' );
   235         aUniquePath.Append( '_' );
   218         aUniquePath.Append( '(' );
   236         aUniquePath.Append( '(' );
   219         aUniquePath.AppendJustify( counterDigits, KMaxDigits, TAlign( ERight ), '0' );
   237         aUniquePath.AppendJustify( counterDigits, KMaxDigits, TAlign( ERight ), '0' );
   220         aUniquePath.Append( ')' );
   238         aUniquePath.Append( ')' );
   221         if ( pos != KErrNotFound )
   239         if ( pos != KErrNotFound )
   456         case KVcxMvcCategoryIdOther:
   474         case KVcxMvcCategoryIdOther:
   457             return EVcxMyVideosOriginOther;
   475             return EVcxMyVideosOriginOther;
   458         }
   476         }
   459     return KErrNotFound;
   477     return KErrNotFound;
   460     }
   478     }
   461     
   479 
       
   480 // ----------------------------------------------------------------------------
       
   481 // TVcxMyVideosCollectionUtil::MediaArrayL
       
   482 // ----------------------------------------------------------------------------
       
   483 //
       
   484 CMPXMediaArray* TVcxMyVideosCollectionUtil::MediaArrayL( CMPXMedia& aMedia )
       
   485     {
       
   486     if ( !aMedia.IsSupported( KMPXMediaArrayContents ) )
       
   487         {
       
   488         User::Leave( KErrArgument );
       
   489         }
       
   490 
       
   491     return aMedia.Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   492     }
       
   493 
       
   494 // ----------------------------------------------------------------------------
       
   495 // TVcxMyVideosCollectionUtil::Int32ValueL
       
   496 // ----------------------------------------------------------------------------
       
   497 //
       
   498 TInt32 TVcxMyVideosCollectionUtil::Int32ValueL( CMPXMedia& aMedia )
       
   499     {
       
   500     if ( !aMedia.IsSupported( KVcxMediaMyVideosInt32Value ) )
       
   501         {
       
   502         User::Leave( KErrArgument );
       
   503         }
       
   504     return aMedia.ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
       
   505     }
       
   506 
       
   507 // ----------------------------------------------------------------------------
       
   508 // TVcxMyVideosCollectionUtil::Uint32ValueL
       
   509 // ----------------------------------------------------------------------------
       
   510 //
       
   511 TUint32 TVcxMyVideosCollectionUtil::Uint32ValueL( CMPXMedia& aMedia )
       
   512     {
       
   513     if ( !aMedia.IsSupported( KVcxMediaMyVideosUint32Value ) )
       
   514         {
       
   515         User::Leave( KErrArgument );
       
   516         }
       
   517     return aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosUint32Value );
       
   518     }
       
   519 
       
   520 // ----------------------------------------------------------------------------
       
   521 // TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL
       
   522 // ----------------------------------------------------------------------------
       
   523 //
       
   524 void TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
       
   525         RArray<TUint32>& aIdArray )
       
   526     {
       
   527     TInt count = aMediaArray.Count();
       
   528     aIdArray.Reset();
       
   529     aIdArray.ReserveL( count );
       
   530     for ( TInt i = 0; i < count; i++ )
       
   531         {
       
   532         aIdArray.AppendL( IdL( *aMediaArray.AtL( i ) ).iId1 );
       
   533         }
       
   534     }
       
   535 
   462 #ifdef _DEBUG
   536 #ifdef _DEBUG
   463 // ----------------------------------------------------------------------------
   537 // ----------------------------------------------------------------------------
   464 // TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL
   538 // TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL
   465 // ----------------------------------------------------------------------------
   539 // ----------------------------------------------------------------------------
   466 //
   540 //
   498 // TVcxMyVideosCollectionUtil::GetProcessName
   572 // TVcxMyVideosCollectionUtil::GetProcessName
   499 // ----------------------------------------------------------------------------
   573 // ----------------------------------------------------------------------------
   500 //
   574 //
   501 void TVcxMyVideosCollectionUtil::GetProcessName( TInt aThreadId, TFullName& aProcessName )
   575 void TVcxMyVideosCollectionUtil::GetProcessName( TInt aThreadId, TFullName& aProcessName )
   502     {
   576     {
   503   	TFindThread find(_L("*"));
   577     _LIT(KAsterixDes, "*");
       
   578   	TFindThread find( KAsterixDes );
   504   	while( find.Next( aProcessName ) == KErrNone )
   579   	while( find.Next( aProcessName ) == KErrNone )
   505         {
   580         {
   506       	RThread thread;
   581       	RThread thread;
   507       	TInt err = thread.Open( aProcessName );
   582       	TInt err = thread.Open( aProcessName );
   508       	
   583