musichomescreen_multiview/musiccontentpublisher/inc/musiccontentpublisher.h
branchRCL_3
changeset 26 3de6c4cf6b67
equal deleted inserted replaced
25:14979e23cb5e 26:3de6c4cf6b67
       
     1 /*
       
     2 * Copyright (c) 2008-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 "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:  Manages MCP plugins, and content publishing.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_MUSICCONTENTPUBLISHER_H
       
    20 #define C_MUSICCONTENTPUBLISHER_H 
       
    21 
       
    22 #include <contentharvesterplugin.h>
       
    23 #include <mcppluginobserver.h>
       
    24 #include <libc/stddef.h>  // For wchar_t
       
    25 #include <e32hashtab.h>
       
    26 #include <AknsSrvClient.h>
       
    27 
       
    28 #include "musiccontentmap.h"
       
    29 
       
    30 class MLiwInterface;
       
    31 class CPluginManager;
       
    32 class CFbsBitmap;
       
    33 class CCoeEnv;
       
    34 class TAknsItemID;
       
    35 class CMCPHarvesterPublisherObserver;
       
    36 
       
    37 
       
    38 struct TMCPDestinationItem
       
    39     {
       
    40     const TInt id;
       
    41     const wchar_t* type;
       
    42     const char* dataKey;
       
    43     const char* maskKey;
       
    44     };
       
    45 
       
    46 struct TMCPImageDestinationInfoItem
       
    47     {
       
    48     const TMCPImageDestination id;
       
    49     const TInt sizex;
       
    50     const TInt sizey;
       
    51     };
       
    52 
       
    53 
       
    54 struct TBmpMsk
       
    55     {
       
    56     CFbsBitmap *bitmap;
       
    57     CFbsBitmap *mask;
       
    58     };
       
    59 
       
    60 
       
    61 const TMCPDestinationItem KMCPDestinationInfo[] =
       
    62     {
       
    63      { EMusicWidgetImage1,      L"area1_image1", "area1_image1_data", "area1_image1_data_mask" }
       
    64     ,{ EMusicWidgetText1,       L"area2_text1",  "area2_text1_data", ""}
       
    65     ,{ EMusicWidgetToolbarB1,   L"toolbar_b1", "toolbar_b1_data", "toolbar_b1_data_mask" }
       
    66     ,{ EMusicWidgetToolbarB2,   L"toolbar_b2", "toolbar_b2_data", "toolbar_b2_data_mask" }
       
    67     ,{ EMusicWidgetToolbarB3,   L"toolbar_b3", "toolbar_b3_data", "toolbar_b3_data_mask" }
       
    68     ,{ EMusicWidgetDefaultText, L"default_text",  "default_text_data", "" }
       
    69     
       
    70     ,{ EMusicWidgetTrigger1,    L"area1_image1", "MWTrigger1", "" }
       
    71     ,{ EMusicWidgetTrigger2,    L"default_text",  "MWTrigger2", "" }
       
    72     ,{ EMusicWidgetTB1Trigger,  L"toolbar_b1", "TB1Trigger", "" }
       
    73     ,{ EMusicWidgetTB2Trigger,  L"toolbar_b2", "TB2Trigger", "" }
       
    74     ,{ EMusicWidgetTB3Trigger,  L"toolbar_b3", "TB3Trigger", "" }
       
    75     };
       
    76 
       
    77 
       
    78 const TMCPImageDestinationInfoItem KMCPImageDestinationInfo[] =
       
    79 
       
    80     {
       
    81         {EMusicWidgetImage1, 70, 70}
       
    82     ,
       
    83         {EMusicWidgetToolbarB1, 41,41}
       
    84     ,
       
    85         {EMusicWidgetToolbarB2, 41,41}
       
    86     ,
       
    87         {EMusicWidgetToolbarB3, 41,41}
       
    88 
       
    89     };
       
    90 
       
    91 /**
       
    92  *  Music Content Publisher (a Content Harvester plugin)
       
    93  *
       
    94  *  @lib musiccontentpublisher.dll
       
    95  *  @since S60 S60 v5.0
       
    96  */
       
    97 class CMusicContentPublisher : public CContentHarvesterPlugin
       
    98                        ,public MMCPPluginObserver
       
    99                        ,public MAknsSkinChangeObserver
       
   100     {
       
   101 
       
   102 public:
       
   103 
       
   104 // from base class MMCPPluginObserver
       
   105     /**
       
   106      * from MMCPPluginObserver
       
   107      * Called when an image needs to be updated.
       
   108      *
       
   109      * @since S60 5.0
       
   110      * @param aPlugin Where the mesage is coming from.
       
   111      * @param aDestination Where the image is to be placed.
       
   112      * @param aImagePath Source path of the Image.
       
   113      */
       
   114     void PublishImageL(CMCPPlugin* aPlugin,
       
   115             TMCPImageDestination aDestination, const TDesC& aImagePath);
       
   116 
       
   117     /**
       
   118      * from MMCPPluginObserver
       
   119      * Called when an image needs to be updated.
       
   120      *
       
   121      * @since S60 5.0
       
   122      * @param aPlugin Where the mesage is coming from.
       
   123      * @param aDestination Where the image is to be placed.
       
   124      * @param aBitmapHandle Bitmap handle to the image.
       
   125      * @param aMaskBitmapHandle Mask Bitmap handle for the image.
       
   126      */
       
   127     void PublishImageL(CMCPPlugin* aPlugin, 
       
   128             TMCPImageDestination aDestination,
       
   129             TInt aBitmapHandle,
       
   130             TInt aMaskBitmapHandle = NULL);
       
   131     
       
   132     /**
       
   133      * from MMCPPluginObserver
       
   134      * Called when an image needs to be updated.
       
   135      *
       
   136      * @since S60 5.0
       
   137      * @param aPlugin Where the mesage is coming from.
       
   138      * @param aDestination Where the image is to be placed.
       
   139      * @param aID major and minor Skin ID info.
       
   140      * @param aFilename fallback mif/mbm file.
       
   141      * @param aFileBitmapId bitmap id within the fallback file.
       
   142      * @param aFileMaskId mask id within the fallback file.
       
   143      */
       
   144     void PublishImageL(CMCPPlugin* aPlugin, 
       
   145             TMCPImageDestination aDestination,
       
   146             const TAknsItemID& aID,
       
   147             const TDesC& aFilename,
       
   148             const TInt aFileBitmapId,
       
   149             const TInt aFileMaskId );
       
   150 
       
   151     /**
       
   152      * from MMCPPluginObserver
       
   153      * Called when a text needs to be updated.
       
   154      *
       
   155      * @since S60 5.0
       
   156      * @param aPlugin Where the mesage is coming from.
       
   157      * @param aDestination Where the text is to be placed.
       
   158      * @param aText Descriptor containing the text.
       
   159      */
       
   160     void PublishTextL( CMCPPlugin* aPlugin, 
       
   161             TMCPTextDestination aDestination, const TDesC& aText );
       
   162 
       
   163     /**
       
   164      * from MMCPPluginObserver
       
   165      * Called when an action needs to be updated.
       
   166      *
       
   167      * @since S60 5.0
       
   168      * @param aPlugin Where the mesage is coming from.
       
   169      * @param aDestination Destination trigger that should launch the action.
       
   170      * @param aTrigerMap LIW Map containint the action that can be interpreted
       
   171      * by the specified action handler plugin.
       
   172      */
       
   173     void PublishActionL( CMCPPlugin* aPlugin, 
       
   174             TMCPTriggerDestination aDestination, 
       
   175             CLiwDefaultMap* aTrigerMap );
       
   176     
       
   177     /**
       
   178      * from MMCPPluginObserver
       
   179      * Called when a plugin becomes active.
       
   180      *
       
   181      * @since S60 5.0
       
   182      * @param aPlugin Where the mesage is coming from.
       
   183      */
       
   184     void BecameActiveL( CMCPPlugin* aPlugin );
       
   185     
       
   186     /**
       
   187      * from MMCPPluginObserver
       
   188      * Called when a plugin becomes active.
       
   189      *
       
   190      * @since S60 5.0
       
   191      * @param aDst The image destination.
       
   192      * @return The size of the image destination.
       
   193      */
       
   194     TSize GetImageDestinationSize(TMCPImageDestination aDst);
       
   195     
       
   196     /**
       
   197      * From MAknsSkinChangeObserver.
       
   198      * Called by the skin server when skin content is changed and the
       
   199      * connected client wants to be informed.
       
   200      *
       
   201      * @since 2.0
       
   202      */
       
   203     void SkinContentChanged();
       
   204 
       
   205     /**
       
   206      * From MAknsSkinChangeObserver.
       
   207      * Called by the skin server to indicate that the current skin
       
   208      * configuration has changed.
       
   209      *
       
   210      * @param aReason Reason code.
       
   211      *
       
   212      * @since 2.5
       
   213      */
       
   214     void SkinConfigurationChanged(
       
   215             const TAknsSkinStatusConfigurationChangeReason /*aReason*/){};
       
   216 
       
   217     /**
       
   218      * From MAknsSkinChangeObserver.
       
   219      * Called by the skin server to indicate that the available
       
   220      * skin packages have changed.
       
   221      *
       
   222      * @param aReason Reason code.
       
   223      *
       
   224      * @since 2.5
       
   225      */
       
   226     void SkinPackageChanged(const TAknsSkinStatusPackageChangeReason /*aReason*/){};
       
   227 
       
   228     void HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger );
       
   229     /**
       
   230      * Two-phased constructor.
       
   231      */
       
   232     static CMusicContentPublisher* NewL( MLiwInterface* aCPSInterface );
       
   233 
       
   234 
       
   235 
       
   236     // from base class CContentHarvesterPlugin
       
   237     /**
       
   238      * From CContentHarvesterPlugin
       
   239      * This is called by the Content Harvester Server to signal an update. 
       
   240      */
       
   241     void UpdateL();
       
   242     
       
   243     /**
       
   244      * Destructor.
       
   245      */
       
   246     virtual ~CMusicContentPublisher();
       
   247     
       
   248     /**
       
   249      * Resets the destinations with default values and removes active plugin.
       
   250      */
       
   251     void ResetL();
       
   252 
       
   253 private:
       
   254 
       
   255     /**
       
   256      * Default constructor.
       
   257      */
       
   258     CMusicContentPublisher( MLiwInterface* aCPSInterface );
       
   259 
       
   260     /**
       
   261      * Perform the second phase construction 
       
   262      */
       
   263     void ConstructL();
       
   264     
       
   265     /**
       
   266      * Publish default content
       
   267      */
       
   268     void PublishDefaultL();
       
   269 
       
   270     /**
       
   271      * Installs an action, mainly for readability purposes.
       
   272      *
       
   273      * @since S60 5.0
       
   274      * @param aDestination Destination trigger that should launch the action.
       
   275      */
       
   276     void InstallGoToMusicL(TMCPTriggerDestination aDestination);
       
   277     
       
   278     /**
       
   279      * Installs an action, mainly for readability purposes.
       
   280      *
       
   281      * @since S60 5.0
       
   282      * @param aDestination Destination trigger that should launch the action.
       
   283      */
       
   284     void InstallGoToAlbumL(TMCPTriggerDestination aDestination);
       
   285     
       
   286     /**
       
   287      * Installs an rmpty action, mainly for readability purposes.
       
   288      *
       
   289      * @since S60 5.0
       
   290      * @param aDestination Destination trigger that should launch the action.
       
   291      */
       
   292     void InstallEmptyActionL(TMCPTriggerDestination aDestination);
       
   293    
       
   294     /**
       
   295      * Resets the Bitmap cache.
       
   296      *
       
   297      * @since S60 5.0
       
   298      */
       
   299     void ResetBitmapCache();
       
   300     
       
   301     TUint RegisterPublisherL( 
       
   302         const TDesC& aPublisherId, 
       
   303         const TDesC& aContentId,
       
   304         const TDesC& aContentType );
       
   305     
       
   306     TUint ExtractItemId( const CLiwGenericParamList& aInParamList );
       
   307    
       
   308     /**
       
   309      * Get a heap descriptor from the resource file
       
   310      *
       
   311      * @since S60 5.0
       
   312      */
       
   313     void GetLocalizedStringL(RResourceFile& aResourceFile, HBufC*& aRetBuf,
       
   314             TInt aResourceId);
       
   315 
       
   316     void PublishDeferred();
       
   317     static TInt DoPublish(TAny * aMusicContentPublisher);
       
   318     void DoPublishAllL();
       
   319     void DoPublishModifiedL();
       
   320     void DoPublishDeleteAllL();
       
   321     void DoPublishCmdL(const TDesC8& aCmd, const TDesC8& aKey, const CLiwMap * aValue);
       
   322 
       
   323     
       
   324 	/**
       
   325     * Callback function for CPeriodic.
       
   326     * Defer the creation of MCP plugin to allow the rest of homescreen plugins to be loaded and updated.
       
   327     * This is a temporary solution which shall be replaced with HarvesterServer in Starterlist. 
       
   328 	* HarvesterServer shall then do the time consuming initialization of MPX Collection and Playback 
       
   329 	* and Harvester servers instead.
       
   330     */
       
   331 
       
   332     static TInt UpdateCallback(TAny* aContentPublisher);
       
   333     
       
   334 	void DoUpdate();
       
   335 
       
   336 private: // data
       
   337 
       
   338     /**
       
   339      * Instance of CPS interface used for update with CPS.
       
   340      * Not own
       
   341      */
       
   342     MLiwInterface* iCPSInterface;
       
   343 
       
   344     /**
       
   345      * Creates the plugins and manages the plugins table.
       
   346      * Own.
       
   347      */
       
   348     CPluginManager* iPluginManager;
       
   349     
       
   350     /**
       
   351      * Pointer to the active plugin.
       
   352      * Not own.
       
   353      */    
       
   354     CMCPPlugin* iActivePlugin;
       
   355     
       
   356     /**
       
   357      * mapping for the destination translation.
       
   358      */    
       
   359     struct TDestinationItem {
       
   360     	  explicit TDestinationItem(const TMCPDestinationItem& aItem);
       
   361         TPtrC  iType;
       
   362         TPtrC8 iDataKey;
       
   363         TPtrC8 iMaskKey;
       
   364     };
       
   365     RHashMap<TInt, TDestinationItem>    iDestinationMap;
       
   366     
       
   367     /**
       
   368      * mapping for the destination  image info translation.
       
   369      */    
       
   370     RHashMap<TInt, TSize> iImageDestinationSizeMap;
       
   371     
       
   372     /**
       
   373      * bitmap cache map.
       
   374      */    
       
   375     RHashMap<TInt, TBmpMsk> iBitmapCache;
       
   376     
       
   377     /**
       
   378      * The published data
       
   379      */
       
   380     RMusicContentMap iPublishingDataMap;
       
   381     RMusicContentMap iPublishingActionMap;
       
   382     
       
   383     /**
       
   384     * Deferred callback to DoPublishL
       
   385     */
       
   386     CAsyncCallBack * iDeferredPublish;
       
   387     
       
   388     /**
       
   389     * Skin server session.
       
   390     */
       
   391     RAknsSrvSession iAknsSrvSession;
       
   392     
       
   393     /**
       
   394     * Buffers for the localized strings
       
   395     */
       
   396     HBufC* iNowPlayingBuffer;
       
   397     HBufC* iLastPlayedBuffer;
       
   398     HBufC* iGoToMusicBuffer;
       
   399 
       
   400     CMCPHarvesterPublisherObserver* iHPObserver;
       
   401     TBool iWidgetForeground;
       
   402 
       
   403     HBufC* iInstanceId;
       
   404     
       
   405 	// timer to start creating mcpplugin
       
   406     CPeriodic* iUpdateIdle;    
       
   407    
       
   408     };
       
   409 
       
   410 #endif // C_MUSICCONTENTPUBLISHER_H
       
   411 
       
   412 //  End of File