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