--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h Thu Apr 01 23:32:44 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h Fri Apr 16 18:13:14 2010 +0300
@@ -31,6 +31,140 @@
// CLASS DECLARATION
/**
+ * Contains information about video.
+ * These are stored to CVcxMyVideosVideoListIndex::iVideoArray.
+ */
+NONSHARABLE_CLASS(TVcxMyVideosVideo)
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ TVcxMyVideosVideo();
+
+ /**
+ * = operator.
+ */
+ TVcxMyVideosVideo& operator=( const TVcxMyVideosVideo& aVideo );
+ public:
+
+ /**
+ * Set values.
+ *
+ * @param aMdsId MDS ID
+ * @param aPos Position in CVcxMyVideosVideoCache::iVideoList
+ * @param aVideo Pointer to CVcxMyVideosVideoCache::iVideoList item,
+ * ownership does not move.
+ */
+ void Set( TUint32 aMdsId, TInt aPos, CMPXMedia* aVideo );
+
+ public:
+ TUint32 iMdsId; // Video object ID in MDS.
+ CMPXMedia* iVideo; // Pointer to CVcxMyVideosVideoCache::iVideoList item
+ TInt iPos; // Items position in CVcxMyVideosVideoCache::iVideoList
+ };
+
+/**
+* Used for keeping videos in MDS ID order for fast access.
+* (Indexes CVcxMyVideosVideoCache::iVideoList).
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosVideoListIndex) : public CBase
+ {
+public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor
+ * @return Object constructed
+ */
+ static CVcxMyVideosVideoListIndex* NewL();
+
+ /**
+ * Destructor
+ */
+ virtual ~CVcxMyVideosVideoListIndex();
+
+public:
+
+ /**
+ * Sets up iVideoArray from aVideoList. Sorting is also done.
+ *
+ * @param aVideoList Video list to use for constructing iVideoArray.
+ */
+ void SetL( const CMPXMedia& aVideoList );
+
+ /**
+ * Finds video by MDS ID from the index. Uses bisection method.
+ *
+ * @param aVideo The found video data is written here.
+ * @return KErrNotFound if not found, index of the item in iVideoArray
+ * otherwise.
+ */
+ TInt Find( TUint32 aMdsId, TVcxMyVideosVideo& aVideo );
+
+ /**
+ * Removes video from index.
+ *
+ * @param aMdsId ID if the item to be removed.
+ * @param aCompress If ETrue, compresses the video array.
+ * @return KErrNotFound if not found, index of the removed item otherwise.
+ */
+ TInt Remove( TUint32 aMdsId, TBool aCompress = ETrue );
+
+ /**
+ * Adds video to index. Keeps sorting order.
+ *
+ * @param aVideo Video to be added, ownership does not move.
+ * @param aPos aVideo's position in CVcxMyVideosVideoCache::iVideoList.
+ */
+ void AddL( CMPXMedia* aVideo, TInt aPos );
+
+#ifdef _DEBUG
+ /**
+ * Returns reference to video array.
+ */
+ const RArray<TVcxMyVideosVideo>& VideoArray();
+#endif
+
+private:
+ /**
+ * Constructor
+ */
+ CVcxMyVideosVideoListIndex();
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL ();
+
+ /**
+ * Sorts iVideoArray by MDS ID.
+ */
+ void Sort();
+
+ /**
+ * Used for keeping RArray<TVcxMyVideosVideo> in integer order by
+ * TVcxMyVideosVideo::iMdsId.
+ *
+ * @param aVideo1 Video to compare
+ * @param aVideo2 Video to compare
+ * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
+ * aVideo2.
+ */
+ static TInt CompareVideosByMdsId( const TVcxMyVideosVideo& aVideo1,
+ const TVcxMyVideosVideo& aVideo2 );
+
+private:
+
+ /**
+ * Video array which is kept in order by MDS ID.
+ */
+ RArray<TVcxMyVideosVideo> iVideoArray;
+ };
+
+/**
* Used for storing MDS items to RAM for fast access.
*
* @lib mpxmyvideoscollectionplugin.lib
@@ -52,6 +186,19 @@
*/
virtual ~CVcxMyVideosVideoCache();
+ public:
+
+ /**
+ * @return ETrue if iVideoList is complete. (All items have
+ * been fetched from MDS.)
+ */
+ TBool IsComplete();
+
+ /**
+ * Set to ETrue when all items have been fetched from MDS.
+ */
+ void SetComplete( TBool aComplete );
+
private:
/**
* Constructor
@@ -176,7 +323,14 @@
* @return Position, KErrNotFound if item is not in iVideoList.
*/
TInt PosOnVideoListL( CMPXMedia& aVideo );
-
+
+#ifdef _DEBUG
+ /**
+ * Checks that iVideoListIndex is correctly formed.
+ */
+ void CheckVideoListIndexL();
+#endif
+
public:
/**
* Creates filtered video list from iVideoList. This is used for
@@ -327,11 +481,6 @@
* is removed.
*/
RArray<CMPXMedia*> iPartialVideoList;
-
- /**
- * If ETrue then iVideoList does not contain all items from MDS.
- */
- TBool iVideoListIsPartial;
/**
* Sorting order which was used last time when list was queryed from MDS.
@@ -343,11 +492,22 @@
*/
TBool IsFetchingVideoList;
private:
+
+ /**
+ * If ETrue then iVideoList contains all items from MDS.
+ */
+ TBool iVideoListIsComplete;
/**
* My Videos collection plugin, owner of this object.
*/
- CVcxMyVideosCollectionPlugin& iCollection;
+ CVcxMyVideosCollectionPlugin& iCollection;
+
+ /**
+ * Index which keeps TVcxMyVidesVideo items indexed in MDS ID
+ * order for fast access.
+ */
+ CVcxMyVideosVideoListIndex* iVideoListIndex;
};
#endif // VCXMYVIDEOSVIDEOCACHE_H