videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h
changeset 0 96612d01cf9f
child 16 67eb01668b0e
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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 
       
    21 #ifndef VCXMYVIDEOSCOLLECTIONUTIL_H
       
    22 #define VCXMYVIDEOSCOLLECTIONUTIL_H
       
    23 
       
    24 // INCLUDES
       
    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         * Converts drive letter to drive number.
       
    87         *
       
    88         * @param aDrive drive letter
       
    89         * @return       drive number
       
    90         */
       
    91         static TInt DriveLetter2DriveNumber( const TDesC &aDrive );
       
    92 
       
    93         /**
       
    94         * Checks that file system does not have aPath file already, if it does
       
    95         * then the aPath is changed to unique by adding digits to it. Result
       
    96         * is stored to aUniquePath, (event if it is the same as aPath).
       
    97         *
       
    98         * @param aFs          Open session to file server.
       
    99         * @param aPath        File name to make unique.
       
   100         * @param aUniquePath  Generated unique path.
       
   101         */
       
   102         static void MakeUniqueFileNameL( RFs& aFs, const TDesC& aPath, TDes& aUniquePath );
       
   103         
       
   104         /**
       
   105         * Gets KVcxMediaMyVideosOrigin attribute of aVideo.
       
   106         *
       
   107         * @param aVideo  Media object to fetch parameter from.
       
   108         * @return        Origin, see values from TVcxMyVideosOrigin in vcxmyvideosdefs.h
       
   109         */
       
   110         static TUint8 OriginL( CMPXMedia& aVideo );
       
   111 
       
   112         /**
       
   113         * Gets KMPXMediaGeneralFlags attribute of aVideo.
       
   114         *
       
   115         * @param aVideo  Media object to fetch parameter from.
       
   116         * @return        Flags, see values from TVcxMyVideosVideoFlags in vcxmyvideosdefs.h
       
   117         */        
       
   118         static TUint32 FlagsL( CMPXMedia& aVideo );
       
   119 
       
   120         /**
       
   121         * Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
       
   122         *
       
   123         * @param aVideo  Media object to fetch parameter from.
       
   124         * @return        Download ID in Download Manager.
       
   125         */        
       
   126         static TUint32 DownloadIdL( CMPXMedia& aVideo );
       
   127 
       
   128         /**
       
   129         * Gets KVcxMediaMyVideosDownloadState attribute of aVideo.
       
   130         *
       
   131         * @param aVideo  Media object to fetch parameter from.
       
   132         * @return        Download state.
       
   133         */        
       
   134         static TVcxMyVideosDownloadState DownloadStateL( CMPXMedia& aVideo );
       
   135 
       
   136         /**
       
   137         * Gets KMPXMediaGeneralId attribute of aVideo.
       
   138         *
       
   139         * @param aVideo  Media object to fetch parameter from.
       
   140         * @return        ID.
       
   141         */
       
   142         static TMPXItemId IdL( CMPXMedia& aVideo );
       
   143 
       
   144         /**
       
   145         * Gets KVcxMediaMyVideosDuration attribute of aVideo.
       
   146         *
       
   147         * @param aVideo  Media object to fetch parameter from.
       
   148         * @return        Duration.
       
   149         */        
       
   150         static TReal32 DurationL( CMPXMedia& aVideo );
       
   151         
       
   152         /**
       
   153         * Gets KMPXMediaGeneralTitle attribute of the video.
       
   154         *
       
   155         * @return  KMPXMediaGeneralTitle value. If attribute is not supported,
       
   156         *          then KNullDesC is returned.
       
   157         */
       
   158         static const TDesC& Title( CMPXMedia& aVideo );
       
   159 
       
   160         /**
       
   161         * Gets KVcxMediaMyVideosRating attribute of the video.
       
   162         *
       
   163         * @param aVideo  Media object to fetch parameter from.
       
   164         * @return        KVcxMediaMyVideosRating value. If attribute is not supported,
       
   165         *                then 0 is returned.
       
   166         */        
       
   167         static TUint8 RatingL( CMPXMedia& aVideo );
       
   168 
       
   169         /**
       
   170         * Gets KVcxMediaMyAudioFourCc attribute of the video.
       
   171         *
       
   172         * @param aVideo  Media object to fetch parameter from.
       
   173         * @return        KVcxMediaMyAudioFourCc value. If attribute is not supported,
       
   174         *                then 0 is returned.
       
   175         */
       
   176         static TUint32 AudioFourCcL( CMPXMedia& aVideo );
       
   177 
       
   178         /**
       
   179         * Checks if aAttrs contains attributes which are not supported in aVideo.
       
   180         *
       
   181         * @param aVideo   Attributes to check from.
       
   182         * @param aAttrs   Attributes to check.
       
   183         * @param aNonSupportedAttrCanBeFoundFromMds  Set to ETrue if at least one of non supported
       
   184         *                                            attributes can be found from MDS.
       
   185         * @return         ETrue if all aAttrs attributes are supported in aVideo, EFalse
       
   186         *                 otherwise.
       
   187         */
       
   188         static TBool AreSupported( CMPXMedia& aVideo, const TArray<TMPXAttribute>& aAttrs,
       
   189                 TBool& aNonSupportedAttrCanBeFoundFromMds );
       
   190 
       
   191         /**
       
   192         * Checks if aAttrs belongs to "full" set of parameters which is saved to MDS but not
       
   193         * cached by collection.
       
   194         *
       
   195         * @param aAttr    Attribute to check.
       
   196         * @return         ETrue if aAttr belongs to full set and can be found from MDS, EFalse
       
   197         *                 otherwise.
       
   198         */
       
   199         static TBool AttrBelongsToFullSet( const TMPXAttribute& aAttr );
       
   200         
       
   201         /**
       
   202         * Converts collection category ID to origin.
       
   203         *
       
   204         * @param aCategoryId  Category ID
       
   205         * @return             Returns Origin or KErrNotFound if not found. KVcxMvcCategoryIdAll
       
   206         *                     returns also KErrNotFound.
       
   207         */
       
   208         static TInt Origin( TInt aCategoryId );
       
   209 
       
   210 #ifdef _DEBUG
       
   211         /**
       
   212         * Prints process names which have file handle open to aFileName
       
   213         *
       
   214         * @param aFileName  File to check for open file handles.
       
   215         */
       
   216         static void PrintOpenFileHandlesL( const TDesC& aFileName, RFs& aFs );
       
   217         
       
   218         /**
       
   219         * Gets process name.
       
   220         *
       
   221         * @param aThreadId    Thread ID
       
   222         * @param aProcessName Upon completion process name is written here.
       
   223         */
       
   224         static void GetProcessName( TInt aThreadId, TFullName& aProcessName );
       
   225 
       
   226     private:
       
   227         TBuf<500> iProcessName;        
       
   228 #endif
       
   229     };
       
   230 #endif   // VCXMYVIDEOSCOLLECTIONUTIL_H
       
   231 
       
   232