videocollection/mpxmyvideoscollection/tsrc/ut_collectionplugintest/inc/vcxmyvideoscollectionutil.h
branchRCL_3
changeset 70 375929f879c2
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VCXMYVIDEOSCOLLECTIONUTIL_H
       
    21 #define VCXMYVIDEOSCOLLECTIONUTIL_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <vcxmyvideosdefs.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CMPXMedia;
       
    28 class RFs;
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 * Util functions.
       
    36 *
       
    37 * @lib mpxmyvideoscollectionplugin.lib
       
    38 */
       
    39 NONSHARABLE_CLASS(TVcxMyVideosCollectionUtil)
       
    40     {
       
    41     public:
       
    42     
       
    43         /**
       
    44         * Creates media container and sets up empty media array to it.
       
    45         *
       
    46         * @return CMPXMedia media list.
       
    47         */
       
    48         static CMPXMedia* CreateEmptyMediaListL();
       
    49 
       
    50         /**
       
    51         * Creates message list and sets up empty message array to it.
       
    52         *
       
    53         * @return CMPXMessage message list.
       
    54         */
       
    55         static CMPXMedia* CreateEmptyMessageListL();
       
    56         
       
    57         /**
       
    58         * Tries to find aMdsIds from aFromList and if found, copies them
       
    59         * to aToList. KMPXMediaArrayContents arrays must be set for aFromList
       
    60         * and aToList, othewise leave (KErrArgument) occurs.
       
    61         *
       
    62         * @param aFromList Items are copied from here.
       
    63         * @param aToList   Items are copied here.
       
    64         * @param aMdsIds   Item IDs which are copied.
       
    65         */
       
    66         static void CopyFromListToListL(
       
    67                 CMPXMedia& aFromList,
       
    68                 CMPXMedia& aToList,
       
    69                 RArray<TUint32>& aMdsIds );
       
    70 
       
    71         /**
       
    72         * Tries to find aMdsIds from aFromArray and if found, copies them
       
    73         * to aToList. KMPXMediaArrayContents arrays must be set for aToList,
       
    74         * othewise leave (KErrArgument) occurs.
       
    75         *
       
    76         * @param aFromArray Items are copied from here.
       
    77         * @param aToList    Items are copied here.
       
    78         * @param aMdsIds    Item IDs which are copied.
       
    79         */
       
    80         static void CopyFromListToListL(
       
    81                 RArray<CMPXMedia*>& aFromArray,
       
    82                 CMPXMedia& aToList,
       
    83                 RArray<TUint32>& aMdsIds );
       
    84 
       
    85         /**
       
    86         * Appends all items from aFromList to aToList. New items will point to
       
    87         * same shared memory.
       
    88         *
       
    89         * @param aToList   List in which items are appended to.
       
    90         * @param aFromList List in which items are copied from.
       
    91         */
       
    92         static void AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList );
       
    93 
       
    94         /**
       
    95         * Converts drive letter to drive number.
       
    96         *
       
    97         * @param aDrive drive letter
       
    98         * @return       drive number
       
    99         */
       
   100         static TInt DriveLetter2DriveNumber( const TDesC &aDrive );
       
   101 
       
   102         /**
       
   103         * Checks that file system does not have aPath file already, if it does
       
   104         * then the aPath is changed to unique by adding digits to it. Result
       
   105         * is stored to aUniquePath, (event if it is the same as aPath).
       
   106         *
       
   107         * @param aFs          Open session to file server.
       
   108         * @param aPath        File name to make unique.
       
   109         * @param aUniquePath  Generated unique path.
       
   110         */
       
   111         static void MakeUniqueFileNameL( RFs& aFs, const TDesC& aPath, TDes& aUniquePath );
       
   112         
       
   113         /**
       
   114         * Gets KVcxMediaMyVideosOrigin attribute of aVideo.
       
   115         *
       
   116         * @param aVideo  Media object to fetch parameter from.
       
   117         * @return        Origin, see values from TVcxMyVideosOrigin in vcxmyvideosdefs.h
       
   118         */
       
   119         static TUint8 OriginL( CMPXMedia& aVideo );
       
   120 
       
   121         /**
       
   122         * Gets KMPXMediaGeneralFlags attribute of aVideo.
       
   123         *
       
   124         * @param aVideo  Media object to fetch parameter from.
       
   125         * @return        Flags, see values from TVcxMyVideosVideoFlags in vcxmyvideosdefs.h
       
   126         */        
       
   127         static TUint32 FlagsL( CMPXMedia& aVideo );
       
   128 
       
   129         /**
       
   130          * Gets KMPXMediaGeneralDate (creation date) of aVideo.
       
   131          * 
       
   132          * @param aVideo  Media object to fetch parameter from.
       
   133          * @return        Creation date, works with TTime.
       
   134          */
       
   135         static TInt64 CreationDateL( CMPXMedia& aVideo );
       
   136 
       
   137         /**
       
   138         * Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
       
   139         *
       
   140         * @param aVideo  Media object to fetch parameter from.
       
   141         * @return        Download ID in Download Manager.
       
   142         */        
       
   143         static TUint32 DownloadIdL( CMPXMedia& aVideo );
       
   144 
       
   145         /**
       
   146         * Gets KVcxMediaMyVideosDownloadState attribute of aVideo.
       
   147         *
       
   148         * @param aVideo  Media object to fetch parameter from.
       
   149         * @return        Download state.
       
   150         */        
       
   151         static TVcxMyVideosDownloadState DownloadStateL( CMPXMedia& aVideo );
       
   152 
       
   153         /**
       
   154         * Gets KMPXMediaGeneralId attribute of aVideo.
       
   155         *
       
   156         * @param aVideo  Media object to fetch parameter from.
       
   157         * @return        ID.
       
   158         */
       
   159         static TMPXItemId IdL( const CMPXMedia& aVideo );
       
   160 
       
   161         /**
       
   162         * Gets KVcxMediaMyVideosDuration attribute of aVideo.
       
   163         *
       
   164         * @param aVideo  Media object to fetch parameter from.
       
   165         * @return        Duration.
       
   166         */        
       
   167         static TReal32 DurationL( CMPXMedia& aVideo );
       
   168         
       
   169         /**
       
   170         * Gets KMPXMediaGeneralTitle attribute of the video.
       
   171         *
       
   172         * @return  KMPXMediaGeneralTitle value. If attribute is not supported,
       
   173         *          then KNullDesC is returned.
       
   174         */
       
   175         static const TDesC& Title( const CMPXMedia& aVideo );
       
   176 
       
   177         /**
       
   178         * Gets KVcxMediaMyVideosRating attribute of the video.
       
   179         *
       
   180         * @param aVideo  Media object to fetch parameter from.
       
   181         * @return        KVcxMediaMyVideosRating value. If attribute is not supported,
       
   182         *                then 0 is returned.
       
   183         */        
       
   184         static TUint8 RatingL( CMPXMedia& aVideo );
       
   185 
       
   186         /**
       
   187         * Gets KVcxMediaMyAudioFourCc attribute of the video.
       
   188         *
       
   189         * @param aVideo  Media object to fetch parameter from.
       
   190         * @return        KVcxMediaMyAudioFourCc value. If attribute is not supported,
       
   191         *                then 0 is returned.
       
   192         */
       
   193         static TUint32 AudioFourCcL( CMPXMedia& aVideo );
       
   194 
       
   195         /**
       
   196         * Checks if aAttrs contains attributes which are not supported in aVideo.
       
   197         *
       
   198         * @param aVideo   Attributes to check from.
       
   199         * @param aAttrs   Attributes to check.
       
   200         * @param aNonSupportedAttrCanBeFoundFromMds  Set to ETrue if at least one of non supported
       
   201         *                                            attributes can be found from MDS.
       
   202         * @return         ETrue if all aAttrs attributes are supported in aVideo, EFalse
       
   203         *                 otherwise.
       
   204         */
       
   205         static TBool AreSupported( CMPXMedia& aVideo, const TArray<TMPXAttribute>& aAttrs,
       
   206                 TBool& aNonSupportedAttrCanBeFoundFromMds );
       
   207 
       
   208         /**
       
   209         * Checks if aAttrs belongs to "full" set of parameters which is saved to MDS but not
       
   210         * cached by collection.
       
   211         *
       
   212         * @param aAttr    Attribute to check.
       
   213         * @return         ETrue if aAttr belongs to full set and can be found from MDS, EFalse
       
   214         *                 otherwise.
       
   215         */
       
   216         static TBool AttrBelongsToFullSet( const TMPXAttribute& aAttr );
       
   217         
       
   218         /**
       
   219         * Converts collection category ID to origin.
       
   220         *
       
   221         * @param aCategoryId  Category ID
       
   222         * @return             Returns Origin or KErrNotFound if not found. KVcxMvcCategoryIdAll
       
   223         *                     returns also KErrNotFound.
       
   224         */
       
   225         static TInt Origin( TInt aCategoryId );
       
   226 
       
   227         /**
       
   228          * Gets KMPXMediaArrayContents attribute from aMedia. Leaves
       
   229          * with KErrArgument is attribute is not supported.
       
   230          * 
       
   231          * @param aMedia  Media where from the attribute is fetched.
       
   232          * @return        Pointer to media array.
       
   233          */
       
   234         static CMPXMediaArray* MediaArrayL( const CMPXMedia& aMedia );
       
   235         
       
   236         /**
       
   237          * Gets KVcxMediaMyVideosInt32Value attribute from aMedia. Leaves
       
   238          * with KErrArgument if attribute is not supported.
       
   239          * 
       
   240          * @param aMedia  Media where from the attribute is fetched.
       
   241          * @return        Value of KVcxMediaMyVideosInt32Value attribute.
       
   242          */
       
   243         static TInt32 Int32ValueL( CMPXMedia& aMedia );
       
   244 
       
   245         /**
       
   246          * Gets KVcxMediaMyVideosUint32Value attribute from aMedia. Leaves
       
   247          * with KErrArgument if attribute is not supported.
       
   248          * 
       
   249          * @param aMedia  Media where from the attribute is fetched.
       
   250          * @return        Value of KVcxMediaMyVideosUint32Value attribute.
       
   251          */
       
   252         static TUint32 Uint32ValueL( CMPXMedia& aMedia );
       
   253         
       
   254         /**
       
   255          * Gets KVcxMediaMyVideosCategoryItemCount attribute from aVideo.
       
   256          *
       
   257          * @param aMedia  Media where from the attribute is fetched.
       
   258          * @return        Returns 0, if attribute is not supported.
       
   259          */
       
   260         static TUint32 CategoryItemCountL( CMPXMedia& aVideo );
       
   261 
       
   262         /**
       
   263          * Gets KVcxMediaMyVideosCategoryNewItemCount attribute from aVideo.
       
   264          * 
       
   265          * @param aMedia  Media where from the attribute is fetched.
       
   266          * @return        Returns 0, if attribute is not supported.
       
   267          */
       
   268         static TUint32 CategoryNewItemCountL( CMPXMedia& aVideo );
       
   269         
       
   270         /**
       
   271          * Gets KVcxMediaMyVideosCategoryNewItemName attribute from aVideo.
       
   272          *
       
   273          * @param aMedia  Media where from the attribute is fetched.
       
   274          * @return        Category new video name.
       
   275          */
       
   276         static const TDesC& CategoryNewVideoName( const CMPXMedia& aVideo );
       
   277         
       
   278         /**
       
   279          * Gets KMPXMediaGeneralId attributes from aMediaArray and
       
   280          * puts them to aIdArray. aIdArray is reset before adding.
       
   281          * 
       
   282          * @param aMediaArray  Media array containing media items which
       
   283          *                     have KMPXMediaGeneralId attribute set.
       
   284          * @param aIdArray     Array where to the IDs are written to.
       
   285          */
       
   286         static void GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
       
   287                 RArray<TUint32>& aIdArray );
       
   288         
       
   289 #ifdef _DEBUG
       
   290         /**
       
   291         * Prints process names which have file handle open to aFileName
       
   292         *
       
   293         * @param aFileName  File to check for open file handles.
       
   294         */
       
   295         static void PrintOpenFileHandlesL( const TDesC& aFileName, RFs& aFs );
       
   296         
       
   297         /**
       
   298         * Gets process name.
       
   299         *
       
   300         * @param aThreadId    Thread ID
       
   301         * @param aProcessName Upon completion process name is written here.
       
   302         */
       
   303         static void GetProcessName( TInt aThreadId, TFullName& aProcessName );
       
   304 
       
   305     private:
       
   306         TBuf<500> iProcessName;        
       
   307 #endif
       
   308         
       
   309     public:     // Friend classes
       
   310         
       
   311         friend class CCollectionPluginTest;        
       
   312     };
       
   313 #endif   // VCXMYVIDEOSCOLLECTIONUTIL_H
       
   314 
       
   315