videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h
changeset 0 96612d01cf9f
child 16 67eb01668b0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h	Mon Jan 18 20:21:12 2010 +0200
@@ -0,0 +1,232 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+#ifndef VCXMYVIDEOSCOLLECTIONUTIL_H
+#define VCXMYVIDEOSCOLLECTIONUTIL_H
+
+// INCLUDES
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class RFs;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Util functions.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(TVcxMyVideosCollectionUtil)
+    {
+    public:
+    
+        /**
+        * Creates media container and sets up empty media array to it.
+        *
+        * @return CMPXMedia media list.
+        */
+        static CMPXMedia* CreateEmptyMediaListL();
+
+        /**
+        * Creates message list and sets up empty message array to it.
+        *
+        * @return CMPXMessage message list.
+        */
+        static CMPXMedia* CreateEmptyMessageListL();
+        
+        /**
+        * Tries to find aMdsIds from aFromList and if found, copies them
+        * to aToList. KMPXMediaArrayContents arrays must be set for aFromList
+        * and aToList, othewise leave (KErrArgument) occurs.
+        *
+        * @param aFromList Items are copied from here.
+        * @param aToList   Items are copied here.
+        * @param aMdsIds   Item IDs which are copied.
+        */
+        static void CopyFromListToListL(
+                CMPXMedia& aFromList,
+                CMPXMedia& aToList,
+                RArray<TUint32>& aMdsIds );
+
+        /**
+        * Tries to find aMdsIds from aFromArray and if found, copies them
+        * to aToList. KMPXMediaArrayContents arrays must be set for aToList,
+        * othewise leave (KErrArgument) occurs.
+        *
+        * @param aFromArray Items are copied from here.
+        * @param aToList    Items are copied here.
+        * @param aMdsIds    Item IDs which are copied.
+        */
+        static void CopyFromListToListL(
+                RArray<CMPXMedia*>& aFromArray,
+                CMPXMedia& aToList,
+                RArray<TUint32>& aMdsIds );
+
+        /**
+        * Converts drive letter to drive number.
+        *
+        * @param aDrive drive letter
+        * @return       drive number
+        */
+        static TInt DriveLetter2DriveNumber( const TDesC &aDrive );
+
+        /**
+        * Checks that file system does not have aPath file already, if it does
+        * then the aPath is changed to unique by adding digits to it. Result
+        * is stored to aUniquePath, (event if it is the same as aPath).
+        *
+        * @param aFs          Open session to file server.
+        * @param aPath        File name to make unique.
+        * @param aUniquePath  Generated unique path.
+        */
+        static void MakeUniqueFileNameL( RFs& aFs, const TDesC& aPath, TDes& aUniquePath );
+        
+        /**
+        * Gets KVcxMediaMyVideosOrigin attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        Origin, see values from TVcxMyVideosOrigin in vcxmyvideosdefs.h
+        */
+        static TUint8 OriginL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KMPXMediaGeneralFlags attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        Flags, see values from TVcxMyVideosVideoFlags in vcxmyvideosdefs.h
+        */        
+        static TUint32 FlagsL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        Download ID in Download Manager.
+        */        
+        static TUint32 DownloadIdL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KVcxMediaMyVideosDownloadState attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        Download state.
+        */        
+        static TVcxMyVideosDownloadState DownloadStateL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KMPXMediaGeneralId attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        ID.
+        */
+        static TMPXItemId IdL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KVcxMediaMyVideosDuration attribute of aVideo.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        Duration.
+        */        
+        static TReal32 DurationL( CMPXMedia& aVideo );
+        
+        /**
+        * Gets KMPXMediaGeneralTitle attribute of the video.
+        *
+        * @return  KMPXMediaGeneralTitle value. If attribute is not supported,
+        *          then KNullDesC is returned.
+        */
+        static const TDesC& Title( CMPXMedia& aVideo );
+
+        /**
+        * Gets KVcxMediaMyVideosRating attribute of the video.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        KVcxMediaMyVideosRating value. If attribute is not supported,
+        *                then 0 is returned.
+        */        
+        static TUint8 RatingL( CMPXMedia& aVideo );
+
+        /**
+        * Gets KVcxMediaMyAudioFourCc attribute of the video.
+        *
+        * @param aVideo  Media object to fetch parameter from.
+        * @return        KVcxMediaMyAudioFourCc value. If attribute is not supported,
+        *                then 0 is returned.
+        */
+        static TUint32 AudioFourCcL( CMPXMedia& aVideo );
+
+        /**
+        * Checks if aAttrs contains attributes which are not supported in aVideo.
+        *
+        * @param aVideo   Attributes to check from.
+        * @param aAttrs   Attributes to check.
+        * @param aNonSupportedAttrCanBeFoundFromMds  Set to ETrue if at least one of non supported
+        *                                            attributes can be found from MDS.
+        * @return         ETrue if all aAttrs attributes are supported in aVideo, EFalse
+        *                 otherwise.
+        */
+        static TBool AreSupported( CMPXMedia& aVideo, const TArray<TMPXAttribute>& aAttrs,
+                TBool& aNonSupportedAttrCanBeFoundFromMds );
+
+        /**
+        * Checks if aAttrs belongs to "full" set of parameters which is saved to MDS but not
+        * cached by collection.
+        *
+        * @param aAttr    Attribute to check.
+        * @return         ETrue if aAttr belongs to full set and can be found from MDS, EFalse
+        *                 otherwise.
+        */
+        static TBool AttrBelongsToFullSet( const TMPXAttribute& aAttr );
+        
+        /**
+        * Converts collection category ID to origin.
+        *
+        * @param aCategoryId  Category ID
+        * @return             Returns Origin or KErrNotFound if not found. KVcxMvcCategoryIdAll
+        *                     returns also KErrNotFound.
+        */
+        static TInt Origin( TInt aCategoryId );
+
+#ifdef _DEBUG
+        /**
+        * Prints process names which have file handle open to aFileName
+        *
+        * @param aFileName  File to check for open file handles.
+        */
+        static void PrintOpenFileHandlesL( const TDesC& aFileName, RFs& aFs );
+        
+        /**
+        * Gets process name.
+        *
+        * @param aThreadId    Thread ID
+        * @param aProcessName Upon completion process name is written here.
+        */
+        static void GetProcessName( TInt aThreadId, TFullName& aProcessName );
+
+    private:
+        TBuf<500> iProcessName;        
+#endif
+    };
+#endif   // VCXMYVIDEOSCOLLECTIONUTIL_H
+
+