videofeeds/scheduleddlplugin/inc/vcnsscheduleddownloadmpxclient.h
changeset 0 96612d01cf9f
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:    Class for handling mpx collection interactions*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VCXNSDOWNLOADCLIENTHANDLER_H_
       
    21 #define VCXNSDOWNLOADCLIENTHANDLER_H_
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <mpxcollectionobserver.h>
       
    27 
       
    28 #include "CIptvUtil.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CIptvService;
       
    32 class CIptvMediaContent;
       
    33 class MMPXCollectionUtility;
       
    34 class CIptvVodContentClient;
       
    35 class CIptvVodDlDownloadEvent;
       
    36 
       
    37 /**
       
    38 * MVcxNsMpxClientObserver
       
    39 * 
       
    40 * class specifies the interface for CVcxNsScheduledDownloadMpxClient callback function.
       
    41 * Client must inherit this and implement the virtual functions.
       
    42 */
       
    43 class MVcxNsMpxClientObserver
       
    44     {
       
    45         
       
    46 public: // New functions
       
    47 
       
    48     /**
       
    49     * This emulates old fashion dl client events
       
    50     */
       
    51     virtual void HandleVodDlDownloadEvent( CIptvVodDlDownloadEvent& aEvent ) = 0;
       
    52     
       
    53     };
       
    54 
       
    55 /**
       
    56 * Class CVcxNsScheduledDownloadMpxClient handles mpx collection client interactions.
       
    57 *
       
    58 * @lib iptvscheduleddownloadplugin.lib
       
    59 */
       
    60 class CVcxNsScheduledDownloadMpxClient : public CBase,
       
    61                                          public MMPXCollectionObserver
       
    62     {
       
    63 
       
    64 public:
       
    65 
       
    66     /**
       
    67      * Two-phased constructor. 
       
    68      */
       
    69     static CVcxNsScheduledDownloadMpxClient* NewL( MVcxNsMpxClientObserver& aObserver,
       
    70                                                    CIptvVodContentClient& aContentClient,
       
    71                                                    TUint32 aServiceId );
       
    72 
       
    73     /**
       
    74      * Destructor.
       
    75      */    
       
    76     virtual ~CVcxNsScheduledDownloadMpxClient();
       
    77     
       
    78     /**
       
    79      * Download content from service.
       
    80      * @param aIapId
       
    81      * @param aService   Service.
       
    82      * @param aContentId Content ID identifier.
       
    83      * @param aName      Content name.
       
    84      * @param aIndex     Content access index.
       
    85      * @param aDltype    Type of the requested download, currently only EIptvDownloadTypeImmediate
       
    86      *                   supported.
       
    87      * @return           Error code, indicates if download is started successfully. If return code is
       
    88      *                   EIptvDlNoError, then further download status is reported via events, on error
       
    89      *                   no further events will arrive.
       
    90      */
       
    91     TIptvDlError DownloadL(
       
    92         TUint32 aIapId,
       
    93         CIptvService* aService,
       
    94         TIptvContentId aContentId,
       
    95         const TDesC& aName );
       
    96     
       
    97     /**
       
    98      * Cancels download.
       
    99      * Operation includes clean up that removes files from file system,
       
   100      * deletes data related to FileId and releases FileId identifier.
       
   101      * @param aServiceId
       
   102      * @param aContentId
       
   103      * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
       
   104      *         KErrNotFound if download was not found from VOD DL Manager, file might still be in
       
   105      *         My Videos.
       
   106      */
       
   107     TInt CancelDownloadL(
       
   108         TUint32 aServiceId,
       
   109         TUint32 aContentId );    
       
   110 
       
   111     /**
       
   112      * Get the mpx media object by id.
       
   113      * @param aMpxIds
       
   114      */
       
   115     void GetMediaByMpxIdReqL(  RArray<TUint32>& aMpxIds  );
       
   116     
       
   117     /**
       
   118      *  Check media's download state and do routines if necessary.
       
   119      * 
       
   120      *  @param aMediaId media object id which to check.
       
   121      */
       
   122     void CheckMediaStateL( TUint32 aMediaId );
       
   123 
       
   124     /**
       
   125      * Append the given content to download list.
       
   126      * 
       
   127      * List takes ownership of given object.
       
   128      * 
       
   129      * @param aContent Content
       
   130      */
       
   131     void AppendToDownloadList( CIptvMediaContent* aContent );
       
   132 
       
   133     /**
       
   134      * Remove the given content from download list.
       
   135      * 
       
   136      * Pointed object is deleted.
       
   137      * 
       
   138      * @param aContent Content
       
   139      */
       
   140     void RemoveFromDownloadList( CIptvMediaContent* aContent );
       
   141 
       
   142     /**
       
   143      * Find a content by url from download list.
       
   144      */
       
   145     CIptvMediaContent* SearchFromDownloadList( const TDesC& aUri );
       
   146 
       
   147     /**
       
   148      * Find a content by mpx id from download list.
       
   149      */
       
   150     CIptvMediaContent* SearchFromDownloadList( const TUint32 aMpxId );
       
   151     
       
   152     /**
       
   153      * Find a content by service and content id from download list.
       
   154      */
       
   155     CIptvMediaContent* SearchFromDownloadList( const TUint32 aServiceId, 
       
   156                                                const TUint32 aContentId );
       
   157 
       
   158 // From Base classes
       
   159 
       
   160     /**
       
   161     *  From MMPXCollectionObserver->MMPXCollectionMediaObserver
       
   162     *  Handle extended media properties
       
   163     *
       
   164     *  @param aMedia media 
       
   165     *  @param aError error code    
       
   166     */
       
   167     void HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, 
       
   168                                  TInt /*aError*/ );
       
   169 
       
   170     /** 
       
   171     *  From MMPXCollectionUtilityObserver.
       
   172     *  Handle collection message
       
   173     *  NOTE: only one of HandleCollectionMessage callback can be implemented
       
   174     * 
       
   175     *  @param aMessage collection message, ownership not transferred. 
       
   176     *         Please check aMsg is not NULL before using it. If aErr is not 
       
   177     *         KErrNone, plugin might still call back with more info in the aMsg.
       
   178     *  @param aErr system error code.
       
   179     */
       
   180     void HandleCollectionMessage( CMPXMessage* /*aMsg*/, TInt /*aErr*/ ); 
       
   181 
       
   182     /**
       
   183     *  From MMPXCollectionUtilityObserver.
       
   184     *  Handles the collection entries being opened. Typically called
       
   185     *  when client has Open()'d a folder
       
   186     *
       
   187     *  @param aEntries collection entries opened
       
   188     *  @param aIndex focused entry
       
   189     *  @param aComplete ETrue no more entries. EFalse more entries
       
   190     *                   expected
       
   191     *  @param aError error code   
       
   192     */
       
   193     void HandleOpenL( const CMPXMedia& /*aEntries*/,
       
   194                       TInt /*aIndex*/, TBool /*aComplete*/, TInt /*aError*/ );
       
   195 
       
   196     /**
       
   197     *  From MMPXCollectionUtilityObserver.
       
   198     *  Handles the item being opened. Typically called
       
   199     *  when client has Open()'d an item. Client typically responds by
       
   200     *  'playing' the item via the playlist
       
   201     *
       
   202     *  @param aPlaylist collection playlist
       
   203     *  @param aError error code   
       
   204     */                         
       
   205     void HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/ );
       
   206 
       
   207     /**
       
   208     *  From MMPXCollectionUtilityObserver.
       
   209     *  Handle completion of a asynchronous command
       
   210     *  All clients should implement this callback
       
   211     *  @param aCommandResult result of the command, NULL if error
       
   212     *  @param aError error code    
       
   213     */
       
   214     void HandleCommandComplete( CMPXCommand* /*aCommandResult*/, TInt /*aError*/ );
       
   215     
       
   216     /**
       
   217      *  Marks given items as watched to MPX col.
       
   218      * 
       
   219      *  @param aArray media object array to be processed.
       
   220      */
       
   221     void MarkItemsAsWatchedL( CMPXMediaArray* aArray );
       
   222     
       
   223     /**
       
   224      *  Sets given items last play pos to MPX col.
       
   225      * 
       
   226      *  @param aArray media object array to be processed.
       
   227      */
       
   228     void WriteLastPlayPosL( CMPXMediaArray* aArray );
       
   229 
       
   230 private:
       
   231 
       
   232     /**
       
   233      * Starts download of given item.
       
   234      * 
       
   235      * @param aAddress          Address of the downloaded content
       
   236      * @param aName             Name of the downloaded content
       
   237      * @param aIapId            Iap id for the download
       
   238      * @param aIsReadOnlyIap    Is the give iap read-only
       
   239      * @param aUserName         UserName of the downloaded content
       
   240      * @param aPassword         Password of the downloaded content
       
   241      * @return                  System-wide error code
       
   242      */
       
   243     TInt DoDownloadL( const TDesC& aAddress,
       
   244                       const TDesC& aName,
       
   245                       TUint32 aIapId,
       
   246                       TBool aIsReadOnlyIap,
       
   247                       const TDesC& aUserName,
       
   248                       const TDesC& aPassword );
       
   249     
       
   250     /**
       
   251      * Links the mpx media objects to contents.
       
   252      * 
       
   253      * @param aArray Mpx media array containing the data.
       
   254      */
       
   255     void LinkMediaObjectsL( CMPXMediaArray* aArray  );
       
   256 
       
   257     /**
       
   258      * Sets the mpx media object to downloaded content
       
   259      * item and refreshes the content view, if visible.
       
   260      * 
       
   261      * @param aMedia Mpx media containing the data.
       
   262      */
       
   263     void SearchAndAddMpxMediaL( CMPXMedia* aMedia );
       
   264     
       
   265     /** 
       
   266      * Calls HandleSingleCollectionMessageL() for every message.
       
   267      * 
       
   268      *  @param aMessage collection message, ownership not transferred. 
       
   269      *         Please check aMsg is not NULL before using it. If aErr is not 
       
   270      *         KErrNone, plugin might still call back with more info in the aMsg.
       
   271      *  @param aErr system error code.
       
   272      */
       
   273     void ExplodeCollectionMessagesL( CMPXMessage* aMsg, TInt aErr ); 
       
   274 
       
   275     /**
       
   276      * Handles one sinlgle message
       
   277      * 
       
   278      *  @param aMessage collection message, ownership not transferred. 
       
   279      *         Please check aMsg is not NULL before using it. If aErr is not 
       
   280      *         KErrNone, plugin might still call back with more info in the aMsg.
       
   281      *  @param aErr system error code.
       
   282      */
       
   283     void HandleSingleCollectionMessageL( CMPXMessage* aMsg, TInt aErr  );
       
   284     
       
   285     /**
       
   286      * HandleSingleCollectionMessage's implementation.
       
   287      * 
       
   288      *  Handle collection message
       
   289      *  NOTE: only one of HandleCollectionMessage callback can be implemented
       
   290      * 
       
   291      *  @param aMessage collection message, ownership not transferred. 
       
   292      *         Please check aMsg is not NULL before using it. If aErr is not 
       
   293      *         KErrNone, plugin might still call back with more info in the aMsg.
       
   294      *  @param aErr system error code.
       
   295      */
       
   296     void DoHandleSingleCollectionMessageL( CMPXMessage* aMsg, TInt aErr );
       
   297     
       
   298     /**
       
   299      *  Handle mpx item changed -collection message
       
   300      * 
       
   301      *  @param aMessage collection message, ownership not transferred. 
       
   302      *         Please check aMsg is not NULL before using it. If aErr is not 
       
   303      *         KErrNone, plugin might still call back with more info in the aMsg.
       
   304      *  @param aErr system error code.
       
   305      */
       
   306     void HandleMpxItemChangedL( CMPXMessage* aMsg, TInt aErr );
       
   307 
       
   308     /**
       
   309      *  Copy ecg data to mpx database
       
   310      * 
       
   311      *  @param aContent Source content, where copy values from.
       
   312      *  @param aMedia   Target media object, where to copy the values.
       
   313      */
       
   314     void CopyEcgDataToMpxColL( CIptvMediaContent *aContent, CMPXMedia *aMedia );
       
   315     
       
   316     /**
       
   317      *  Get CMPXMedia.
       
   318      * 
       
   319      *  @param aMediaId media object id, which to get.
       
   320      *  @return CMPXMedia object. Ownership not transferred.
       
   321      */
       
   322     CMPXMedia* GetMpxMediaFromList( TUint32 aMediaId );
       
   323 
       
   324     CVcxNsScheduledDownloadMpxClient(  MVcxNsMpxClientObserver& aObserver,
       
   325                                        CIptvVodContentClient& aContentClient,
       
   326                                        TUint32 aServiceId );
       
   327 
       
   328     void ConstructL();
       
   329 
       
   330 private:
       
   331     
       
   332     /**
       
   333     * MMPXCollectionUtility* 
       
   334     */
       
   335     MMPXCollectionUtility* iCollectionUtility;
       
   336     
       
   337     /**
       
   338     * The currently / previously downloaded contents.
       
   339     */  
       
   340     RPointerArray<CIptvMediaContent> iDownloadedContents;
       
   341 
       
   342     /**
       
   343     * The downloaded content's mpx items.
       
   344     */  
       
   345     RPointerArray<CMPXMedia> iDownloadedMedias;
       
   346     
       
   347     /**
       
   348     * MVcxNsMpxClientObserver
       
   349     */
       
   350     MVcxNsMpxClientObserver& iObserver; 
       
   351     
       
   352     /**
       
   353     * CIptvVodContentClient
       
   354     */
       
   355     CIptvVodContentClient& iContentClient;
       
   356     
       
   357     /**
       
   358     * Current service id
       
   359     */
       
   360     TUint32 iServiceId;
       
   361 
       
   362     };
       
   363 
       
   364 #endif // VCXNSDOWNLOADCLIENTHANDLER_H_