videocollection/videocollectionwrapper/inc/videocollectionlistener.h
changeset 15 cf5481c2bc0b
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2009 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 "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:   VideoCollectionListener class definition*
       
    15 */
       
    16 
       
    17 #ifndef __VIDEOCOLLECTIONLISTENER_H
       
    18 #define __VIDEOCOLLECTIONLISTENER_H
       
    19 
       
    20 // INCLUDES
       
    21 #include <QObject>
       
    22 #include <mpxcollectionobserver.h>
       
    23 
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class VideoCollectionClient;
       
    27 class VideoCollectionUtils;
       
    28 class VideoDataSignalReceiver;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 class VideoCollectionListener : public QObject, public MMPXCollectionObserver
       
    32 {
       
    33     /**
       
    34      * define to be able to use signals and slots
       
    35      */
       
    36     Q_OBJECT
       
    37    
       
    38     /**
       
    39      * disable copy-constructor and assignment operator
       
    40      */
       
    41     Q_DISABLE_COPY(VideoCollectionListener) 
       
    42       
       
    43 public: 
       
    44     
       
    45     /**
       
    46      * Constructor
       
    47      */
       
    48     VideoCollectionListener(VideoCollectionClient &collectionClient,
       
    49                             VideoDataSignalReceiver &mSignalReceiver);
       
    50 
       
    51     /**
       
    52      * Destructor.
       
    53      */
       
    54     virtual ~VideoCollectionListener();
       
    55      
       
    56 signals:
       
    57 
       
    58     /**
       
    59      * Emitted when new video list is available.
       
    60      * 
       
    61      * If client needs to maintains media-array, it should create
       
    62      * a copy from provided array pointer
       
    63      * 
       
    64      * @param pointer to new media array, ownership is NOT transferred
       
    65      */
       
    66     void newVideoList(CMPXMediaArray*);
       
    67     
       
    68     /**
       
    69      * Emitted from HandleOpenL when mNewArrayRequest is false.
       
    70      * In this case we moght have not got all videos from previous
       
    71      * HandleOpenL so we need to provide this list to client for it to
       
    72      * check wether there are some new videos to be appended
       
    73      * 
       
    74      * @param pointer to appendable media array, ownership is NOT transferred
       
    75      */
       
    76     void videoListAppended(CMPXMediaArray*);       
       
    77     
       
    78     /**
       
    79      * Emitted when a single video item has fetched.
       
    80      * 
       
    81      * @param pointer to Video item. Ownership is NOT transferred
       
    82      */
       
    83     void newVideoAvailable(CMPXMedia*);
       
    84     
       
    85     /**
       
    86      * Emitted when received an avent about externally removed video.
       
    87      * 
       
    88      * @param video id
       
    89      */
       
    90     void videoDeleted(TMPXItemId);
       
    91            
       
    92     /**
       
    93      * Emitted when multiple video deletion command is completed.
       
    94      * 
       
    95      * @param int contains count of overall deleted items
       
    96      * @param media-array containing possible failed medias. Ownership is NOT transferred
       
    97      */
       
    98     void videoDeleteCompleted(int, QList<TMPXItemId>*);
       
    99     
       
   100     /**
       
   101      * Emitted when all details for a video have been fetched.
       
   102      * 
       
   103      * @param id of video whose details have bee fetched.
       
   104      */
       
   105     void videoDetailsCompleted(TMPXItemId);
       
   106     
       
   107     /**
       
   108      * Emitted when album items are recieved.
       
   109      * 
       
   110      * @param albumId, Album which items are received.
       
   111      * @param albumItems, Items belonging to the current album.
       
   112      */
       
   113     void albumListAvailable(TMPXItemId albumId, CMPXMediaArray *albumItems);
       
   114         
       
   115 private: // From MMPXCollectionObserver
       
   116 
       
   117     /**
       
   118      * Handle extended media properties
       
   119      *
       
   120      * not implemented here
       
   121      * 
       
   122      * @param aMedia media 
       
   123      * @param aError error code    
       
   124      */
       
   125     void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
       
   126     
       
   127     /**
       
   128      * Handles the collection entries being opened. Typically called
       
   129      * when client has Open()'d a folder.
       
   130      * Uses mNewArrayRequest flag to indicate wether newVideoList or
       
   131      * videoArrayAppended is emitted. If flag value is true, newVideolist 
       
   132      * is emitted and flag value is setted false. This is because only one 
       
   133      * newVideoList signal alloved per content request. 
       
   134      *
       
   135      * @param aEntries collection entries opened
       
   136      * @param aIndex focused entry
       
   137      * @param aComplete ETrue no more entries. EFalse more entries
       
   138      *                  expected
       
   139      * @param aError error code   
       
   140      */
       
   141     void HandleOpenL( const CMPXMedia& aEntries,
       
   142                       TInt aIndex,
       
   143                       TBool aComplete,
       
   144                       TInt aError );
       
   145 
       
   146     /**
       
   147      * Handles the item being opened. Typically called
       
   148      * when client has Open()'d an item. Client typically responds by
       
   149      * 'playing' the item via the playlist.
       
   150      * 
       
   151      * Not implemented here.
       
   152      *
       
   153      * @param aPlaylist collection playlist
       
   154      * @param aError error code   
       
   155      */                         
       
   156     void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError );
       
   157 
       
   158     /**
       
   159      * Handle completion of a asynchronous command
       
   160      *
       
   161      * @param aCommandResult result of the command, NULL if error
       
   162      * @param aError error code    
       
   163      */
       
   164     void HandleCommandComplete( CMPXCommand* aCommandResult, TInt aError );
       
   165 
       
   166     /** 
       
   167      * Handle collection message
       
   168      * NOTE: only one of HandleCollectionMessage callback can be implemented
       
   169      * 
       
   170      * @param aMessage collection message, ownership not transferred. 
       
   171      *        Please check aMsg is not NULL before using it. If aErr is not 
       
   172      *        KErrNone, plugin might still call back with more info in the aMsg.
       
   173      * @param aErr system error code.
       
   174      */
       
   175     void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr ); 
       
   176   
       
   177 private: 
       
   178     
       
   179     /**
       
   180      * Default constructor should not be used
       
   181      */
       
   182     VideoCollectionListener();
       
   183     
       
   184     /**
       
   185      * called by the HandleCollectionMessage(), in case message received
       
   186      * contains array -based data.
       
   187      * 
       
   188      * @param aMessage
       
   189      */
       
   190     void handleMyVideosMessageArray(CMPXMessage *aMessage);
       
   191     
       
   192     /**
       
   193      * redirects the actual messagehandling based on given myVideosMsgId.
       
   194      * Messages to handle contains KVcxCommandIdMyVideos as their 
       
   195      * general message id 
       
   196      * 
       
   197      * @param myVideosMsgId message id parsed by the caller
       
   198      * @param aMessage
       
   199      */
       
   200     void handleMyVideosMPXMessage(int &myVideosMsgId, CMPXMessage *aMessage);
       
   201     
       
   202     /**
       
   203      * messages that do fall into KVcxCommandIdMyVideos, are passed here 
       
   204      * to be treated as "common" mpx messages.
       
   205      * 
       
   206      * @param myVideosMsgId message id parsed by the caller
       
   207      * @param aMessage
       
   208      */
       
   209     void handleMPXMessage(TMPXMessageId &mpxMsgId, CMPXMessage *aMessage);
       
   210     
       
   211     /**
       
   212      * Handles general MPX message (TMPXMessageId == KMPXMessageGeneral)
       
   213      * In here we handle only the collection opening case: when collection
       
   214      * informs it has opened and browsed to all videos category, we need to 
       
   215      * open collection to it's current state in order to get video list. 
       
   216      * 
       
   217      * @param aMessage collection message.
       
   218      */
       
   219     void handleGeneralMPXMessage(CMPXMessage* aMessage); 
       
   220  
       
   221     /**
       
   222      * Handles item changed message.
       
   223      * 
       
   224      * @param aMessage collection message.
       
   225      */
       
   226     void handleMyVideosItemsChanged( CMPXMessage* aMessage);        
       
   227     
       
   228     /**
       
   229      * Handles delete related message.
       
   230      * 
       
   231      * @param aMessage collection message.
       
   232      */
       
   233     void handleMyVideosDeleteMessage(CMPXMessage* aMessage);         
       
   234 
       
   235     /**
       
   236      * Handles response message when MPX Media object requested.
       
   237      *
       
   238      * @param aMessage collection message.
       
   239      */
       
   240     void handleGetMediasByMpxIdResp(CMPXMessage* aMessage);
       
   241     
       
   242     /**
       
   243     * Handles response message when video details requested.
       
   244     * 
       
   245     * @param aMessage collection message.
       
   246     */
       
   247     void handleGetVideoDetailsResp(CMPXMessage* aMessage);
       
   248 
       
   249     
       
   250 private:
       
   251     
       
   252     /**
       
   253      * Reference to collection client
       
   254      */
       
   255     VideoCollectionClient &mCollectionClient;
       
   256     
       
   257     /**
       
   258      * reference to collection message signal receiver.
       
   259      * Used as observer for performance.
       
   260      */
       
   261     VideoDataSignalReceiver &mSignalReceiver;
       
   262     
       
   263     /**
       
   264      * Reference to utility objetc used to parse CMPXMessages and
       
   265      * CMPXMedias
       
   266      */
       
   267     VideoCollectionUtils &mVideoUtils;
       
   268         
       
   269  };
       
   270 
       
   271 #endif // __VIDEOCOLLECTIONLISTENER_H