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