videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionplugin.h
changeset 0 96612d01cf9f
child 15 cf5481c2bc0b
child 26 67eb01668b0e
child 34 bbb98528c666
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:    Implementation of My Videos MPX Collection Plugin interface*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VCXMYVIDEOSCOLLECTIONPLUGIN_H
       
    21 #define VCXMYVIDEOSCOLLECTIONPLUGIN_H
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include <mpxcollectionplugin.h>
       
    26 #include <mpxcollectionpath.h>
       
    27 #include <mpxcollectionmessagedefs.h>
       
    28 #include <vcxmyvideosdefs.h>
       
    29 
       
    30 #include "vcxmyvideosactivetask.h"
       
    31 
       
    32 #include "vcxmyvideosmdsdb.h"
       
    33 #include "vcxmyvideosdownloadutil.h"
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CVcxMyVideosMdsDb;
       
    37 class CMPXResource;
       
    38 class CMPXMediaArray;
       
    39 class CVcxMyVideosDownloadUtil;
       
    40 class CVcxMyVideosVideoCache;
       
    41 class CVcxMyVideosCategories;
       
    42 class CVcxMyVideosMessageList;
       
    43 class CVcxMyVideosAsyncFileOperations;
       
    44 class CVcxMyVideosOpenHandler;
       
    45 
       
    46 // CONSTANTS
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 * Plug-in, provides access to My Videos collection.
       
    52 *
       
    53 * @lib mpxmyvideoscollectionplugin.lib
       
    54 */
       
    55 NONSHARABLE_CLASS(CVcxMyVideosCollectionPlugin) :
       
    56     public CMPXCollectionPlugin,
       
    57     public MVcxMyVideosMdsDbObserver,
       
    58     public MVcxMyVideosActiveTaskObserver,
       
    59     public MVcxMyVideosDownloadUtilObserver
       
    60     {    
       
    61     public: // Constructors and destructor
       
    62 
       
    63         friend class CVcxMyVideosOpenHandler;
       
    64         friend class CVcxMyVideosVideoCache;
       
    65         
       
    66         /**
       
    67         * Two-phased constructor
       
    68         * @param aInitParams: initialization parameters
       
    69         * @return object constructed
       
    70         */
       
    71         static CVcxMyVideosCollectionPlugin* NewL (TAny* aInitParams);
       
    72 
       
    73         /**
       
    74         * Destructor
       
    75         */
       
    76         virtual ~CVcxMyVideosCollectionPlugin();
       
    77 
       
    78     public: // from base classes
       
    79         /**
       
    80         * From CMPXCollectionPlugin
       
    81         * Navigates to the given path.  This method is serviced
       
    82         * asynchronously and HandleOpenL is called upon completion
       
    83         * @param aPath a path
       
    84         * @param aAttrs attributes requested
       
    85         * @param aFilter filter to apply or NULL if none
       
    86         */
       
    87         void OpenL(const CMPXCollectionPath& aPath,
       
    88                    const TArray<TMPXAttribute>& aAttrs,
       
    89                    CMPXFilter* aFilter);
       
    90         
       
    91         /**
       
    92         * From CMPXCollectionPlugin
       
    93         * Get the extended properties of the item referred to by the
       
    94         * specified collection path.  This method is serviced asynchronously and
       
    95         * HandleMediaL is called upon completion
       
    96         * @param aPath a collection path referring to the item to retrieve the
       
    97         *               extended properties for
       
    98         * @param aAttr: array of attributes requested
       
    99         * @param aCaps platsec capabilities of client requesting media; plug-in
       
   100         *        should also verify its process capabilities (not yet supported)
       
   101         * @aParam aSpecs specifications for attributes (not yet supported)
       
   102         */
       
   103         void MediaL(const CMPXCollectionPath& aPath,
       
   104                     const TArray<TMPXAttribute>& aAttrs,
       
   105                     const TArray<TCapability>& aCaps,
       
   106                     CMPXAttributeSpecs* aSpecs);
       
   107 
       
   108         /**
       
   109         * From CMPXCollectionPlugin
       
   110         * Cancel outstanding request.
       
   111         */
       
   112         void CancelRequest();
       
   113 
       
   114         /**
       
   115         * From CMPXCollectionPlugin
       
   116         * Executes the given CMPXCommand command on the collection
       
   117         * @param aCmd a command
       
   118         */
       
   119         void CommandL(CMPXCommand& aCmd);
       
   120 
       
   121         /**
       
   122         * From CMPXCollectionPlugin
       
   123         *  Find the items matching the media specifications.  This method is serviced
       
   124         *  asynchronously and HandleFindAllL is called upon completion
       
   125         *  @param aCriteria Properties of the item that is to be found
       
   126         *  @param aAttrs Requested attributes to return
       
   127         */
       
   128         void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs);
       
   129 
       
   130         /**
       
   131         *  From CMPXCollectionPlugin
       
   132         *  Find the items matching the media specifications
       
   133         *  @param aCriteria Properties of the item that is to be found
       
   134         *  @param aAttrs Requested attributes to return
       
   135         *  @return results of the search. Method abandons ownership of results.
       
   136         */
       
   137         CMPXMedia* FindAllSyncL(const CMPXMedia& aCriteria,
       
   138                                 const TArray<TMPXAttribute>& aAttrs);
       
   139 
       
   140         /**
       
   141         * Get the list of supported capabilities
       
   142         * @return TCollectionCapability, bitmask of supported capabilities
       
   143         */
       
   144         TCollectionCapability GetCapabilities();
       
   145 
       
   146         /**
       
   147         * DEPRECATED
       
   148         * From CMPXCollectionPlugin
       
   149         * Executes the given TMPXCollectionCommand command on the collection
       
   150         * @param aCmd a command
       
   151         * @param aArg an argument
       
   152         */
       
   153         void CommandL(TMPXCollectionCommand /*aCmd*/, TInt /*aArg = 0*/) {}
       
   154 
       
   155         /**
       
   156         * DEPRECATED
       
   157         * From CMPXCollectionPlugin
       
   158         * Adds an episode to the collection
       
   159         * @param aMedia Properties of the item
       
   160         */
       
   161         void AddL(const CMPXMedia& /*aMedia*/) {}
       
   162 
       
   163         /**
       
   164         * DEPRECATED
       
   165         * From CMPXCollectionPlugin
       
   166         * Remove an item(s) from the collection database using the given path
       
   167         * Note that the selection indices are hidden within the path
       
   168         * @param aPath: path to the item to be removed
       
   169         *
       
   170         */
       
   171         void RemoveL(const CMPXCollectionPath& /*aPath*/) {}
       
   172 
       
   173         /**
       
   174         *  DEPRECATED
       
   175         *  Remove item(s) from the collection database using the given media properties
       
   176         *  @param aMedia Properties of the item(s) to be removed. May cantain a URI
       
   177         *                 or metadata. All item(s) matching the specified properties
       
   178         *                 will be removed.
       
   179         */
       
   180         void RemoveL(const CMPXMedia& /*aMedia*/) {}
       
   181 
       
   182         /**
       
   183         *  DEPRECATED
       
   184         *  Sets/updates the specified media for an item in the collection.  Media
       
   185         *  is identified by specifying an ID or URI.
       
   186         *  @param aMedia: new property values for the item
       
   187         */
       
   188         void SetL(const CMPXMedia& /*aMedia*/) {}
       
   189 
       
   190         /**
       
   191         * From MMPXDbActiveTaskObserver
       
   192         */
       
   193         TBool HandleStepL();
       
   194 
       
   195         /**
       
   196         * From MMPXDbActiveTaskObserver
       
   197         */
       
   198         void HandleOperationCompleted( TInt aErr );
       
   199 
       
   200         /**
       
   201         * From MVcxMyVideosMdsDbObserver.
       
   202         */
       
   203         void HandleMyVideosDbEvent( TMPXChangeEventType aEvent,
       
   204                 RArray<TUint32>& aId );
       
   205 
       
   206         /**
       
   207         * Leaving version of HandleMyVideosDbEvent.
       
   208         */
       
   209         void DoHandleMyVideosDbEventL( TMPXChangeEventType aEvent,
       
   210                 RArray<TUint32>& aId );
       
   211                 
       
   212         /**
       
   213         * From MVcxMyVideosMdsDbObserver.
       
   214         * Handler function for list fetching events. This callback is called as a response
       
   215         * to CreateVideoList( aSync = EFalse ).
       
   216         *
       
   217         * @param aVideoList           List of videos fetched from MDS.
       
   218         * @param aNewItemsStartIndex  Start position for the new items added.
       
   219         * @param aComplete            ETrue if list is complete and no more items are expected,
       
   220         *                             EFalse if there are more to come.
       
   221         */
       
   222         void HandleCreateVideoListResp( CMPXMedia* aVideoList, TInt aNewItemsStartIndex,
       
   223                 TBool aComplete );
       
   224 
       
   225         /**
       
   226         * From MVcxMyVideosMdsDbObserver. Called when media is removed or inserted.
       
   227         */
       
   228         void HandleObjectPresentNotification();
       
   229 
       
   230         /**
       
   231         * Leaving version of HandleObjectPresentNotification.
       
   232         */
       
   233         void DoHandleObjectPresentNotificationL();
       
   234                 
       
   235         /**
       
   236         * From CVcxMyVideosDownloadUtilObserver.
       
   237         */
       
   238         void HandleDlEvent( TVcxMyVideosDownloadState aState,
       
   239                 TUint32 aDownloadId, TInt aProgress, TInt64 aDownloaded,
       
   240                 TInt32 aError, TInt32 aGlobalError );
       
   241 
       
   242         /**
       
   243         * Leaving version of HandleDlEvent.
       
   244         */
       
   245         void DoHandleDlEventL( TVcxMyVideosDownloadState aState,
       
   246                 TUint32 aDownloadId, TInt aProgress, TInt64 aDownloaded,
       
   247                 TInt32 aError, TInt32 aGlobalError );
       
   248  
       
   249     private:
       
   250         /**
       
   251         * Constructor
       
   252         */
       
   253         CVcxMyVideosCollectionPlugin();
       
   254 
       
   255         /**
       
   256         * Symbian 2nd phase constructor.
       
   257         */
       
   258         void ConstructL ();
       
   259 
       
   260         /**
       
   261         * Synchronizes set of videos in cache with Download Manager.
       
   262         * Download related attributes are set in cache if corresponding
       
   263         * download is found.
       
   264         *
       
   265         * @param aItemsInCache  Array of MDS IDs. 
       
   266         */
       
   267         void SyncWithDownloadsL( RArray<TUint32>& aItemsInCache );
       
   268 
       
   269         /**
       
   270         * Synchronizes video with Download Manager.
       
   271         *
       
   272         * @aVideo       Video to synchronize.
       
   273         * @aEventAdded  Set to ETrue if event was added to iMessageList, does not change the
       
   274         *               value otherwise.
       
   275         */
       
   276         void SyncVideoWithDownloadsL( CMPXMedia& aVideo, TBool& aEventAdded,
       
   277                 TBool aAddEvent = ETrue );
       
   278 
       
   279         /**
       
   280         * Copies download attributes from aDownload to aVideo.
       
   281         *
       
   282         * @param aVideo        Video in cache.
       
   283         * @param aDownload     Corresponding download in Download Manager.
       
   284         * @param aSendMpxEvent ETrue if MPX item has been modified and caller should
       
   285         *                      send the modification event.
       
   286         */
       
   287         void SyncVideoAndDownloadL(
       
   288                 CMPXMedia& aVideo,
       
   289                 RHttpDownload& aDownload,
       
   290                 TBool& aSendMpxEvent );
       
   291                         
       
   292         /**
       
   293         * Copies KVcxMediaMyVideosTransactionId field from aRequest to aResp.
       
   294         */
       
   295         void SetTransactionIdL( CMPXMedia& aRequest, CMPXMedia& aResp );
       
   296                
       
   297         /**
       
   298         * Generates and sends resp message for Move,Copy and Delete operations.
       
   299         * Does nothing if there is some other operation going on.
       
   300         * This function is called when operation is interrupted from a leave or
       
   301         * cancel request.
       
   302         * Leaves with KErrNotFound if no operation was in progress.
       
   303         *
       
   304         * @param aErr  Error code which is set for non handled items in the resp array.
       
   305         */
       
   306         void CancelOperationL( TInt aErr );
       
   307  
       
   308         /**
       
   309         * Returns reference to iAsyncFileOperations member.
       
   310         *
       
   311         * @return reference to iAsyncFileOperations.
       
   312         */        
       
   313         CVcxMyVideosAsyncFileOperations& AsyncFileOperationsL();
       
   314         
       
   315         /**
       
   316         * Called by iCache when it notices that current video list fetching has to
       
   317         * be done again from the scratch. This is called only when there is video list
       
   318         * fetching ongoing.
       
   319         */
       
   320         void RestartVideoListFetchingL();
       
   321 
       
   322 
       
   323         /**
       
   324         * Sets download ID to 0 and download state to none. Updates MDS and sends
       
   325         * modified event.
       
   326         *
       
   327         * @param aDownloadId  Download ID of the MPX item.
       
   328         */
       
   329         void SetDownloadIdToZeroL( TUint aDownloadId );
       
   330 
       
   331 
       
   332 #ifdef _DEBUG
       
   333         /**
       
   334         * Returns download state as a descriptor.
       
   335         */
       
   336         const TDesC& DownloadState( TUint8 aDlState );
       
   337 #endif
       
   338 
       
   339     public:
       
   340 
       
   341         /**
       
   342         * Adds video to MDS and cache.
       
   343         *
       
   344         * @param aVideo video to add, KMPXMediaGeneralId will be set to new value.
       
   345         */
       
   346         void AddVideoToMdsAndCacheL( CMPXMedia& aVideo );
       
   347 
       
   348         /**
       
   349         * Sets video parameters in iCache and MDS from aVideo.
       
   350         *
       
   351         * @param aVideo  Media used to copy parameters from.
       
   352         */
       
   353         void SetVideoL( CMPXMedia& aVideo );
       
   354 
       
   355         /**
       
   356         * Sends My Videos message to clients. Transaction ID is copied from
       
   357         * aCommand if it is available.
       
   358         *
       
   359         * @param aMessageId Message id.
       
   360         * @param aCommand   Command which has caused the message, optional.
       
   361         *                   Ownership does not move.
       
   362         */
       
   363         void SendMyVideosMessageL( TUint32 aMessageId, CMPXCommand* aCommand = NULL );
       
   364 
       
   365         /**
       
   366         * Synchronizes video list with Download Manager.
       
   367         *
       
   368         * @param aVideoList  Video list to synchronize.
       
   369         * @param aStartPos   Items before aStartPos index are left out from synchronizing.
       
   370         * @param aSendEvents If ETrue and modifications are done to the list, then
       
   371         *                    MPX events are sent.
       
   372         */
       
   373         void SyncVideoListWithDownloadsL( CMPXMedia& aVideoList, 
       
   374                 TBool aSendEvents, TInt aStartPos = 0 );
       
   375         
       
   376         /**
       
   377         * Returns reference to iDownloadUtil. If iDownloadUtil is NULL then
       
   378         * it is created.
       
   379         */
       
   380         CVcxMyVideosDownloadUtil& DownloadUtilL();
       
   381 
       
   382         /**
       
   383         * Sends messages to clients. If udeb version, adds messageid
       
   384         * parameter to the message for debugging purposes. May or may not
       
   385         * contain media list as parameter.
       
   386         *
       
   387         * @param aMessages  Messages to send.
       
   388         */
       
   389         void SendMessages( CMPXMessage& aMessages );
       
   390 
       
   391         /**
       
   392         * Creates iCategories if its not created yet and returns reference to it.
       
   393         *
       
   394         * @return Reference to iCategories member.
       
   395         */
       
   396         CVcxMyVideosCategories& CategoriesL();
       
   397         
       
   398         /**
       
   399         * Notifies to mediator listeners that a download has completed.
       
   400         *
       
   401         * @param aVideo Downloaded video.
       
   402         */
       
   403         void NotifyDownloadCompletedL( CMPXMedia& aVideo );
       
   404 
       
   405         /**
       
   406         * Notifies to mediator listeners that count of new videos has decreased.
       
   407         * 
       
   408         * @param aVideo Removed or watched video.  
       
   409         */
       
   410         void NotifyNewVideosCountDecreasedL( CMPXMedia& aVideo );
       
   411         
       
   412     public:
       
   413         /**
       
   414         * MDS database handler, own.
       
   415         */
       
   416         CVcxMyVideosMdsDb* iMyVideosMdsDb;
       
   417 
       
   418         /**
       
   419         * MDS items are cached here for fast access.
       
   420         * Own.
       
   421         */
       
   422         CVcxMyVideosVideoCache* iCache;
       
   423 
       
   424         /**
       
   425         * Messages are grouped here for sending.
       
   426         */        
       
   427         CVcxMyVideosMessageList* iMessageList;
       
   428 
       
   429         /**
       
   430         * File server session.
       
   431         */
       
   432         RFs iFs;
       
   433 
       
   434         /**
       
   435         * Executes command in several small steps.
       
   436         */
       
   437         CVcxMyVideosActiveTask* iActiveTask;
       
   438                 
       
   439     private:
       
   440 
       
   441         /**
       
   442         * Contains category list, accessed through CategoriesL() function.
       
   443         * Own.
       
   444         */
       
   445         CVcxMyVideosCategories* iCategories;
       
   446                             
       
   447         /**
       
   448         * Download util, own.
       
   449         */
       
   450         CVcxMyVideosDownloadUtil* iDownloadUtil;
       
   451                                                                         
       
   452         /**
       
   453         * Target drive for Move operation.
       
   454         */
       
   455         TInt iTargetDrive;
       
   456         
       
   457         /**
       
   458         * Performs multiple Move,Copy and Delete operations step by step. Own.
       
   459         */
       
   460         CVcxMyVideosAsyncFileOperations* iAsyncFileOperations;
       
   461         
       
   462         /**
       
   463         * Contains collection Open operation related functionality.
       
   464         */
       
   465         CVcxMyVideosOpenHandler* iOpenHandler;
       
   466         
       
   467         /**
       
   468         * Used for clearing orphan downloads only once.
       
   469         */
       
   470         TBool iOrphanDownloadsCleared;
       
   471 
       
   472                         
       
   473 #ifdef _DEBUG
       
   474         /**
       
   475         * Used for debugging that client receives all events.
       
   476         */
       
   477         TInt iTotalMessagesSent;
       
   478         TInt iMessagesInArraySent;
       
   479 #endif
       
   480 
       
   481     };
       
   482 
       
   483 #endif   // VCXMYVIDEOSCOLLECTIONPLUGIN_H
       
   484 
       
   485