upnpsharing/upnpcontentserver/inc/upnpcontentmetadatautility.h
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 0 7f85d04be362
equal deleted inserted replaced
32:3785f754ee62 38:5360b7ddc251
    26 
    26 
    27 // INCLUDES
    27 // INCLUDES
    28 // System
    28 // System
    29 #include <e32base.h>
    29 #include <e32base.h>
    30 #include <MCLFOperationObserver.h>
    30 #include <MCLFOperationObserver.h>
    31 #include <MCLFChangedItemObserver.h>
       
    32 #include <MCLFItem.h>
    31 #include <MCLFItem.h>
    33 #include <badesca.h>
    32 #include <badesca.h>
    34 
    33 // Internal
    35 // upnp stack api
       
    36 #include <upnpitem.h>
       
    37 
       
    38 // upnpframework / avcontroller helper api
       
    39 #include "upnpconstantdefs.h" // for upnp-specific stuff
    34 #include "upnpconstantdefs.h" // for upnp-specific stuff
    40 
       
    41 // homeconnect internal
       
    42 #include "upnpcontentserverdefs.h"
    35 #include "upnpcontentserverdefs.h"
    43 #include "upnpcontentserverhandler.h"
    36 #include "upnpcontentserverhandler.h"
    44 
       
    45 
       
    46 // CONSTANTS
       
    47 const TInt KMaxRefreshCount = 3;
       
    48 
    37 
    49 // FORWARD DECLARATIONS
    38 // FORWARD DECLARATIONS
    50 class MCLFContentListingEngine;
    39 class MCLFContentListingEngine;
    51 class MCLFItemListModel;
    40 class MCLFItemListModel;
    52 class CUpnpCustomGrouper;
    41 class TClfMediaType;
    53 class CUpnpPostFilter;
       
    54 class MUpnpMetadataObserver;
       
    55 class CUPnPMetaDataUtility;
       
    56 
    42 
       
    43 using namespace UpnpContentServer;
    57 
    44 
    58 // CLASS DECLARATION
    45 // CLASS DECLARATION
    59 
    46 
    60 /**
    47 /**
    61  *  Class to collect files from phone to share.
    48  *  Class to collect files from phone to share.
    65  *  @since S60 3.1
    52  *  @since S60 3.1
    66  */
    53  */
    67 class CUpnpContentMetadataUtility : public CBase,
    54 class CUpnpContentMetadataUtility : public CBase,
    68                                 public MCLFOperationObserver
    55                                 public MCLFOperationObserver
    69     {
    56     {
       
    57     
    70 public:  // Constructors and destructor
    58 public:  // Constructors and destructor
    71 
    59 
    72     /**
    60     /**
    73      * Two-phased constructor.
    61      * Two-phased constructor.
    74      */
    62      */
    80     virtual ~CUpnpContentMetadataUtility();
    68     virtual ~CUpnpContentMetadataUtility();
    81 
    69 
    82 public: // New functions
    70 public: // New functions
    83 
    71 
    84     /**
    72     /**
    85      * Updates metadata for the item
       
    86      * @since S60 3.1
       
    87      * @param aMediaType Media type of oitem to be updated
       
    88      * @param aItem pointer to item
       
    89      * @param aFileName Reference to item filename
       
    90      * @return ETrue if the item was found from this model
       
    91      */
       
    92     TBool UpdateMetadataL( const TUpnpMediaType& aMediaType,
       
    93                            CUpnpItem* aItem,
       
    94                            const TDesC& aFileName );
       
    95 
       
    96     /**
       
    97      * Returns music model
    73      * Returns music model
    98      * @since S60 3.1
    74      * @since S60 5.2
    99      * @return MCLFItemListModel reference to model
    75      * @return MCLFItemListModel reference to model
   100      */
    76      */
   101     const MCLFItemListModel& MusicFiles() const;
    77     const MCLFItemListModel* MusicFiles();
   102 
    78 
   103     /**
    79     /**
   104      * Returns image model
    80      * Returns image model
   105      * @since S60 3.1
    81      * @since S60 5.2
   106      * @return MCLFItemListModel reference to model
    82      * @return MCLFItemListModel reference to model
   107      */
    83      */
   108     const MCLFItemListModel& ImageFiles() const;
    84     const MCLFItemListModel* ImageFiles();
   109 
       
   110 
    85 
   111     /**
    86     /**
   112      * Returns video model
    87      * Returns video model
   113      * @since S60 3.1
    88      * @since S60 5.2
   114      * @return MCLFItemListModel reference to model
    89      * @return MCLFItemListModel reference to model
   115      */
    90      */
   116     const MCLFItemListModel& VideoFiles() const;
    91     const MCLFItemListModel* VideoFiles();
   117 
       
   118 
       
   119     /**
       
   120      * Returns collection model
       
   121      * @since S60 3.1
       
   122      * @return MCLFItemListModel reference to model
       
   123      */
       
   124     const MCLFItemListModel& Collections() const;
       
   125 
       
   126 
       
   127     /**
       
   128      * Collects items from selected collection to the model
       
   129      * @since S60 3.1
       
   130      * @param aNameOfCollection, collection name
       
   131      */
       
   132     void CollectionItemsL( const TDesC& aNameOfCollection );
       
   133 
       
   134 
       
   135     /**
       
   136      * Extract files from descriptor to the array
       
   137      * @since S60 3.1
       
   138      * @param aFileArray, file name array
       
   139      * @param aFiles, file name descriptor
       
   140      */
       
   141     void GetCollectionFileNamesL( CDesCArray& aFileArray,
       
   142                                   const TDesC& aFiles ) const;
       
   143 
       
   144     /**
       
   145      * Returns true if refresh is still ongoing
       
   146      * @since S60 3.1
       
   147      * @return Status of the refresh operation
       
   148      */
       
   149     TBool RefreshOngoing() const;
       
   150 
       
   151     /**
       
   152      * Clears all postfilters
       
   153      * @since S60 3.1
       
   154      *
       
   155      */
       
   156     void ClearPostFiltersL();
       
   157 
       
   158     /**
       
   159      * Creates UPnP item from CLF Item
       
   160      * @since S60 3.1
       
   161      * @param aCLFItem reference to original item
       
   162      * @param aParentId Parent id of the item
       
   163      * @return CUpnpItem new item allocation
       
   164      */
       
   165     CUpnpItem* CreateItemL( const MCLFItem& aCLFItem,
       
   166                             const TDesC8&  aParentId ) const;
       
   167 
       
   168     /**
       
   169      * Creates UPnP item from CLF Item
       
   170      * @since S60 3.1
       
   171      * @param aFullFilenme Filename of the item
       
   172      * @param aParentId Parent id of the item
       
   173      * @return CUpnpItem new item allocation
       
   174      */
       
   175     CUpnpItem* CreateItemL(
       
   176         const TDesC& aFullFilename,
       
   177         const TDesC8& aParentId ) const;
       
   178 
       
   179     /**
       
   180      * Sets the callback for informing about refresh state
       
   181      * @since S60 3.1
       
   182      * @param aHandler pointer to observer
       
   183      */
       
   184     void SetCallback( MUpnpMetadataObserver* aObserver );
       
   185 
       
   186 
    92 
   187 protected: // From MCLFOperationObserver
    93 protected: // From MCLFOperationObserver
   188 
    94 
   189     /**
    95     /**
   190      * Abstract method to get list model operation events. This method is
    96      * Abstract method to get list model operation events. This method is
   195      *        succeed.
   101      *        succeed.
   196      */
   102      */
   197     void HandleOperationEventL( TCLFOperationEvent aOperationEvent,
   103     void HandleOperationEventL( TCLFOperationEvent aOperationEvent,
   198                                 TInt aError );
   104                                 TInt aError );
   199 
   105 
   200 protected:  // From MCLFChangedItemObserver
       
   201 
       
   202     /**
       
   203      * From MCLFChangedItemObserver Method to handle changed item event.
       
   204      * @since S60 3.1
       
   205      * @param aItemIDArray List of changed item IDs
       
   206      */
       
   207     void HandleItemChangeL( const TArray<TCLFItemId>& aItemIDArray );
       
   208 
       
   209     /**
       
   210      * From MCLFChangedItemObserver Method is used to handle errors in
       
   211      * changed item event.
       
   212      * @since S60 3.1
       
   213      * @param aError System wide error code.
       
   214      */
       
   215     void HandleError( TInt aError );
       
   216 
       
   217 
       
   218 private:
   106 private:
   219 
   107 
   220     /**
   108     /**
   221      * C++ default constructor.
   109      * C++ default constructor.
   222      */
   110      */
   224 
   112 
   225     /**
   113     /**
   226      * By default Symbian 2nd phase constructor is private.
   114      * By default Symbian 2nd phase constructor is private.
   227      */
   115      */
   228     void ConstructL();
   116     void ConstructL();
       
   117     
       
   118     /**
       
   119      * Refreshes the selected model information
       
   120      * @since S60 5.2
       
   121      * @param aCLFMediaType CLF media type
       
   122      */
       
   123     void RefreshModelL( TCLFMediaType aCLFMediaType );
       
   124 
       
   125     /**
       
   126      * Wait for refresh operation to complete
       
   127      * @since S60 5.2
       
   128      */
       
   129     void WaitForRefreshToComplete();
   229 
   130 
   230 private:    // Data
   131 private:    // Data
   231     // Content listing engine (owned)
   132     // Content listing engine (owned)
   232     MCLFContentListingEngine* iEngine;
   133     MCLFContentListingEngine* iEngine;
   233 
   134 
   238     MCLFItemListModel* iImageModel;
   139     MCLFItemListModel* iImageModel;
   239 
   140 
   240     // Content listing model for videos (owned)
   141     // Content listing model for videos (owned)
   241     MCLFItemListModel* iVideoModel;
   142     MCLFItemListModel* iVideoModel;
   242 
   143 
   243     // Content listing model for collections (owned)
   144     // Waiter for Refresh processes (owned)
   244     MCLFItemListModel* iCollectionModel;
   145     CActiveSchedulerWait* iWait;
   245 
   146 
   246     // Custom grouper for collection grouping (owned)
       
   247     CUpnpCustomGrouper* iCustomGrouper;
       
   248 
       
   249     // Status to indicate if refresh operation is ongoing
       
   250     TBool iRefreshOngoing;
       
   251 
       
   252     // Keeps count of refreshed models
       
   253     TInt iRefreshCounter;
       
   254 
       
   255     // Post filter for filtering (owned)
       
   256     CUpnpPostFilter* iPostFilter;
       
   257 
       
   258     // Callback interface
       
   259     // not owned
       
   260     MUpnpMetadataObserver* iHandler;
       
   261 
       
   262     // The index maintained during the multiple CLF operations
       
   263     TInt iClfIndex;
       
   264     
       
   265     // Utility class for CLF
       
   266     CUPnPMetaDataUtility* iMetaDataUtility; // owned
       
   267     };
   147     };
   268 
   148 
   269 #endif      // __UPNPCONTENTMETADATAUTILITY_H__
   149 #endif      // __UPNPCONTENTMETADATAUTILITY_H__
   270 
   150 
   271 // End of File
   151 // End of File