musichomescreen_multiview/musiccontentpublisher/src/musiccontentpublisher.cpp
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 #include <mpxlog.h>                     // MPX_DEBUG
       
    19 #include <liwservicehandler.h>
       
    20 #include <liwvariant.h>
       
    21 #include <liwgenericparam.h>
       
    22 
       
    23 #include <mcpplugin.h>
       
    24 #include <mcppluginuids.hrh>
       
    25 #include <fbs.h>
       
    26 #include <coemain.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <gdi.h>
       
    29 #include <musichomescreen.rsg>
       
    30 #include <bautils.h>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 #include <s32mem.h>
       
    33 #include <e32hashtab.h>
       
    34 
       
    35 #include "cpglobals.h" //This will be moved to domain API (HSFW)
       
    36 #include "musiccontentpublisher.h"
       
    37 #include "pluginmanager.h"
       
    38 #include "mcpharvesterpublisherobserver.h"
       
    39 
       
    40 _LIT( KPubData,        "publisher" );
       
    41 
       
    42 
       
    43 _LIT8( KMyActive, "active" );
       
    44 _LIT8( KMyDeActive, "deactive");
       
    45 _LIT8( KMySuspend, "suspend");
       
    46 _LIT8( KMyResume, "resume");
       
    47 _LIT8( KMyActionMap, "action_map" );
       
    48 _LIT8( KMyItem, "item" );
       
    49 _LIT8( KMyAdd, "Add" );
       
    50 _LIT8( KMyItemId, "item_id" );
       
    51 _LIT( KMyActionName, "data" );
       
    52 
       
    53 _LIT( KEmpty, "" );
       
    54 _LIT( KLoc, "LOC:");
       
    55 _LIT( KWildCard, "*");
       
    56 
       
    57 _LIT( KNowPlaying, "LOC:NOW PLAYING" );
       
    58 _LIT( KLastPlayed, "LOC:LAST PLAYED" );
       
    59 _LIT( KMask, "_mask");
       
    60 _LIT( KMWPublisher, "MWPublisher");
       
    61 _LIT( KactionMessageToMusicPlayer, "MessageToMusicPlayer" );
       
    62 _LIT( KGoToAlbumView, "GoToAlbumView" );
       
    63 _LIT8( KMessage, "message" );
       
    64 
       
    65 //for application launcher AHPlugin
       
    66 const TInt KMmUid3AsTInt( 0x101f4cd2 );
       
    67 const TInt KMSGUidAsTInt( 0x10003A39 );
       
    68 _LIT8( KAdditionalData, "additional_data" );
       
    69 _LIT( KLaunchApp, "launch_application" );
       
    70 _LIT( KMessageWithTail, "message_with_tail" );
       
    71 _LIT8( KMessageForMMOpenMusicSuiteWithHide, "mm://root/musicsuite?exit=hide");
       
    72 
       
    73 _LIT( KResourceFile, "z:musichomescreen.rsc");
       
    74 
       
    75 // ======== MEMBER FUNCTIONS ========
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Constructor
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CMusicContentPublisher::CMusicContentPublisher( MLiwInterface* aCPSInterface )
       
    82     {
       
    83     iCPSInterface = aCPSInterface;
       
    84     iActivePlugin=NULL;
       
    85     iIsPublisherActive = EFalse;
       
    86 
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Symbian 2nd phase constructor can leave.
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CMusicContentPublisher::ConstructL()
       
    94     {
       
    95     MPX_DEBUG1("CMusicContentPublisher::ConstructL <---");
       
    96     //Load the destination translation table.
       
    97     TInt dstl (sizeof(KMCPDestinationInfo)/sizeof(TMCPDestinationItem));
       
    98     for (TInt i = 0; i < dstl; i++)
       
    99         {
       
   100         iDestinationMap.InsertL(KMCPDestinationInfo[i].id, 
       
   101                 KMCPDestinationInfo[i]);
       
   102         }
       
   103     
       
   104     dstl = (sizeof(KMCPImageDestinationInfo)/sizeof(
       
   105             TMCPImageDestinationInfoItem));
       
   106     for (TInt i = 0; i < dstl; i++)
       
   107         {
       
   108         iImageDestinationSizeMap.Insert(KMCPImageDestinationInfo[i].id,
       
   109                 TSize(KMCPImageDestinationInfo[i].sizex,
       
   110                         KMCPImageDestinationInfo[i].sizey));
       
   111         }
       
   112     
       
   113     MPX_DEBUG1("CMusicContentPublisher::ConstructL loading resources");
       
   114     //Load Loc strings
       
   115     RFs fs;
       
   116     User::LeaveIfError(fs.Connect());
       
   117     CleanupClosePushL(fs);  
       
   118     TFileName fileName;
       
   119     TParse* parseObj = new(ELeave) TParse();
       
   120     TInt errInt = parseObj->Set( KResourceFile(),&KDC_APP_RESOURCE_DIR,NULL );
       
   121     if(KErrNone != errInt)
       
   122       {
       
   123       delete parseObj;
       
   124       User::Leave(errInt);
       
   125       }
       
   126     fileName = parseObj->FullName();
       
   127     delete parseObj;
       
   128     BaflUtils::NearestLanguageFile(fs,fileName);
       
   129     if(!BaflUtils::FileExists(fs,fileName))
       
   130         {
       
   131         User::Leave(KErrNotFound);
       
   132         }
       
   133     RResourceFile resourceFile;
       
   134     resourceFile.OpenL(fs,fileName);
       
   135     CleanupClosePushL(resourceFile);
       
   136     resourceFile.ConfirmSignatureL();
       
   137     GetLocalizedStringL(resourceFile, iLastPlayedBuffer, R_MUSICHOMESCREEN_LAST_PLAYED);
       
   138     GetLocalizedStringL(resourceFile, iNowPlayingBuffer, R_MUSICHOMESCREEN_NOW_PLAYING);
       
   139     GetLocalizedStringL(resourceFile, iGoToMusicBuffer, R_MUSICHOMESCREEN_GO_TO_MUSIC);
       
   140     CleanupStack::PopAndDestroy(&resourceFile);
       
   141     CleanupStack::PopAndDestroy(&fs);
       
   142     MPX_DEBUG1("CMusicContentPublisher::ConstructL resources loaded");
       
   143     
       
   144     // connect to the skin server, to receive skin changed event.
       
   145     iAknsSrvSession.Connect(this);
       
   146     
       
   147     // enable skin.
       
   148     AknsUtils::InitSkinSupportL();
       
   149 
       
   150     MPX_DEBUG1("CMusicContentPublisher::ConstructL subscribing to observer");
       
   151  
       
   152     TUint id = RegisterPublisherL( 
       
   153             KMWPublisher,
       
   154             KAll, 
       
   155             KAll );
       
   156         
       
   157     if( id != 0 )
       
   158         {
       
   159     CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
       
   160 
       
   161     filter->InsertL( KPublisherId, TLiwVariant( KMWPublisher ) );
       
   162     filter->InsertL( KContentId, TLiwVariant( KAll) );
       
   163     filter->InsertL( KContentType, TLiwVariant( KAll ) );
       
   164 
       
   165     iHPObserver = CMCPHarvesterPublisherObserver::NewL(this);
       
   166     iHPObserver->RegisterL(filter);
       
   167     CleanupStack::PopAndDestroy(filter);
       
   168         }
       
   169     //Reset the music menu info
       
   170     InstallEmptyActionL(EMusicMenuMusicInfoTrigger);
       
   171     PublishTextL( NULL, EMusicMenuMusicInfoLine1, iLastPlayedBuffer->Des() );
       
   172     PublishTextL( NULL, EMusicMenuMusicInfoLine2, KEmpty );
       
   173     PublishImageL( NULL, EMusicMenuMusicInfoImage1, KEmpty );
       
   174     
       
   175     MPX_DEBUG1("CMusicContentPublisher::ConstructL --->");
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // Two-phased constructor.
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 CMusicContentPublisher* CMusicContentPublisher::NewL(  
       
   183         MLiwInterface* aCPSInterface )
       
   184     {
       
   185     CMusicContentPublisher* self = new ( ELeave ) CMusicContentPublisher( 
       
   186             aCPSInterface );
       
   187     CleanupStack::PushL( self );
       
   188     self->ConstructL();
       
   189     CleanupStack::Pop( self );
       
   190     return self;
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // Destructor
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 CMusicContentPublisher::~CMusicContentPublisher()
       
   198     {
       
   199     
       
   200     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher <---");
       
   201     if(iHPObserver)
       
   202         {
       
   203         MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher deleting observer");
       
   204         delete iHPObserver; 
       
   205         }
       
   206     delete iNowPlayingBuffer;
       
   207     delete iLastPlayedBuffer;
       
   208     delete iGoToMusicBuffer;
       
   209     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher closing destination maps");
       
   210     iImageDestinationSizeMap.Close();
       
   211     iDestinationMap.Close();
       
   212     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher resetting bitmap cache");
       
   213     ResetBitmapCache();
       
   214     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher closing skin server session");
       
   215     iAknsSrvSession.Close();
       
   216     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher deleting plugin manager");
       
   217     delete iPluginManager;
       
   218     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher resetting publishing buffers");
       
   219     ResetPublishingBuffers();
       
   220     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher --->");
       
   221     if ( iInstanceId )
       
   222     	{
       
   223     	delete iInstanceId;
       
   224     	}
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // 
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 void CMusicContentPublisher::InstallGoToMusicL(
       
   232         TMCPTriggerDestination aDestination )
       
   233     {
       
   234     MPX_DEBUG1("CMusicContentPublisher::InstallGoToMusicL <---");
       
   235     CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC();
       
   236     CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC();
       
   237     mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10282E5F ) ) );
       
   238     mapData->InsertL( KType, TLiwVariant( KLaunchApp ) );
       
   239     mapData->InsertL( KLaunchMethod, TLiwVariant( KMessageWithTail ) );
       
   240     mapData->InsertL(KApplicationUid,
       
   241             TLiwVariant(TInt32(KMmUid3AsTInt) ) );
       
   242         mapData->InsertL( KAdditionalData, 
       
   243             TLiwVariant( KMessageForMMOpenMusicSuiteWithHide ) );
       
   244     mapData->InsertL(KMessageUid,
       
   245             TLiwVariant(TInt32(KMSGUidAsTInt) ) );
       
   246     
       
   247     mapTrigger->InsertL( KData, TLiwVariant( mapData ) );
       
   248     
       
   249     PublishActionL( NULL, aDestination, mapTrigger );
       
   250     
       
   251     CleanupStack::PopAndDestroy( mapData );
       
   252     CleanupStack::PopAndDestroy( mapTrigger );
       
   253     MPX_DEBUG1("CMusicContentPublisher::InstallGoToMusicL --->");
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // 
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 void CMusicContentPublisher::InstallGoToAlbumL(
       
   261         TMCPTriggerDestination aDestination )
       
   262     {
       
   263     MPX_DEBUG1("CMusicContentPublisher::InstallGoToAlbumL <---");
       
   264     CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC();
       
   265     CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC();
       
   266     
       
   267     mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10207C16 ) ) );
       
   268        mapData->InsertL( KType, TLiwVariant( KactionMessageToMusicPlayer ) );
       
   269        mapData->InsertL( KMessage, TLiwVariant( KGoToAlbumView ) );
       
   270     mapTrigger->InsertL( KData, TLiwVariant( mapData ) );
       
   271     
       
   272     PublishActionL( NULL, aDestination, mapTrigger );
       
   273     
       
   274     CleanupStack::PopAndDestroy( mapData );
       
   275     CleanupStack::PopAndDestroy( mapTrigger );
       
   276     MPX_DEBUG1("CMusicContentPublisher::InstallGoToAlbumL --->");
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // 
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 void CMusicContentPublisher::InstallEmptyActionL(
       
   284         TMCPTriggerDestination aDestination )
       
   285     {
       
   286     MPX_DEBUG1("CMusicContentPublisher::InstallEmptyActionL <---");
       
   287     CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC();
       
   288     PublishActionL( NULL, aDestination, mapTrigger );
       
   289     CleanupStack::PopAndDestroy( mapTrigger );
       
   290     MPX_DEBUG1("CMusicContentPublisher::InstallEmptyActionL --->");
       
   291     }
       
   292 // ---------------------------------------------------------------------------
       
   293 // 
       
   294 // ---------------------------------------------------------------------------
       
   295 //
       
   296 void CMusicContentPublisher::MapEnumToDestinationInfoL(TInt aEnum,
       
   297         TPtrC& aType, TPtrC8& aDataKey, TPtrC& aContent)
       
   298     {
       
   299     MPX_DEBUG1("CMusicContentPublisher::MapEnumToDestinationInfoL <---");
       
   300     TMCPDestinationItem* tmpdstitemp;
       
   301     tmpdstitemp = iDestinationMap.Find(aEnum);
       
   302     
       
   303     if (tmpdstitemp)
       
   304         {
       
   305         TPtrC type ( reinterpret_cast<const TUint16*>(
       
   306                 tmpdstitemp->type) );
       
   307         TPtrC8 dataKey ( reinterpret_cast<const TUint8*>(
       
   308                 tmpdstitemp->dataKey ) );
       
   309         TPtrC content ( reinterpret_cast<const TUint16*>(
       
   310                     tmpdstitemp->content) );
       
   311 
       
   312         aType.Set(type);
       
   313         aDataKey.Set(dataKey);
       
   314 
       
   315         if ( !content.Compare( KWildCard ) )
       
   316             {
       
   317             aContent.Set( iInstanceId->Des() );
       
   318             }
       
   319         else
       
   320             {
       
   321             aContent.Set(content);
       
   322             }
       
   323         }
       
   324     else
       
   325         {
       
   326         //API user provided an invalid destination or the destination is not
       
   327         //defined properly.
       
   328         __ASSERT_DEBUG(EFalse,User::Invariant());
       
   329         }
       
   330     MPX_DEBUG1("CMusicContentPublisher::MapEnumToDestinationInfoL --->");
       
   331     }
       
   332 
       
   333 // ----------------------------------------------------------------------------
       
   334 // Get a heap descriptor from the resource file
       
   335 // ----------------------------------------------------------------------------
       
   336 //
       
   337 void CMusicContentPublisher::GetLocalizedStringL(RResourceFile& aResourceFile,
       
   338         HBufC*& aRetBuf, TInt aResourceId )
       
   339    {
       
   340    MPX_DEBUG1("CMusicContentPublisher::GetLocalizedStringL <---");
       
   341    HBufC8* dataBuffer = aResourceFile.AllocReadLC(aResourceId);
       
   342    TResourceReader theReader;
       
   343    theReader.SetBuffer(dataBuffer);
       
   344    aRetBuf = theReader.ReadHBufCL();
       
   345    CleanupStack::PopAndDestroy(dataBuffer);
       
   346    MPX_DEBUG1("CMusicContentPublisher::GetLocalizedStringL --->");
       
   347    }
       
   348 
       
   349 // ----------------------------------------------------------------------------
       
   350 // Publishes buffered data and actions.
       
   351 // ----------------------------------------------------------------------------
       
   352 //
       
   353 void CMusicContentPublisher::DoPublishL()
       
   354     {
       
   355     MPX_DEBUG1("CMusicContentPublisher::DoPublishL <---");
       
   356     THashMapIter<TInt, TMyBufferItem> dataIter( iPublishingDataBuffers );
       
   357     MPX_DEBUG1("CMusicContentPublisher::DoPublishL publishing data");
       
   358     
       
   359     TMyBufferItem const* itemptr;
       
   360     itemptr = dataIter.NextValue();
       
   361     while (itemptr)
       
   362         {
       
   363         CLiwGenericParamList* inParam = CLiwGenericParamList::NewLC();
       
   364         CLiwGenericParamList* outParam = CLiwGenericParamList::NewLC();
       
   365         
       
   366         TPtrC8 dataKey;
       
   367         TPtrC type;
       
   368         TPtrC content;
       
   369         MapEnumToDestinationInfoL(*dataIter.CurrentKey(), type, dataKey, content);
       
   370         
       
   371         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   372         inParam->AppendL( cptype );
       
   373         CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC( );
       
   374         
       
   375         
       
   376         RMemReadStream rs( itemptr->buf, itemptr->size );
       
   377         CLiwDefaultMap* map = CLiwDefaultMap::NewLC( rs );
       
   378          
       
   379         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   380         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   381         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   382         cpdatamap->InsertL( KDataMap  , TLiwVariant( map ) );
       
   383     
       
   384         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   385         inParam->AppendL( item );
       
   386  
       
   387         iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   388         CleanupStack::PopAndDestroy( map );
       
   389         CleanupStack::PopAndDestroy( cpdatamap );
       
   390         CleanupStack::PopAndDestroy( outParam );
       
   391         CleanupStack::PopAndDestroy( inParam );
       
   392         
       
   393         itemptr = dataIter.NextValue();
       
   394         }
       
   395         
       
   396     //The order in wich we publish is important, actions should be published after the data contents.
       
   397     THashMapIter<TInt, TMyBufferItem> actionIter( iPublishingActionBuffers );
       
   398     MPX_DEBUG1("CMusicContentPublisher::DoPublishL publishing actions");
       
   399     
       
   400     itemptr = NULL;
       
   401     itemptr = actionIter.NextValue();
       
   402     while (itemptr)
       
   403         {
       
   404         CLiwGenericParamList* inParam = CLiwGenericParamList::NewLC();
       
   405         CLiwGenericParamList* outParam = CLiwGenericParamList::NewLC();
       
   406         
       
   407         TPtrC8 dataKey;
       
   408         TPtrC type;
       
   409         TPtrC content;
       
   410         MapEnumToDestinationInfoL( *actionIter.CurrentKey(), type, dataKey, content );
       
   411         
       
   412         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   413         inParam->AppendL( cptype );
       
   414         CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC( );
       
   415         
       
   416         
       
   417         RMemReadStream rs( itemptr->buf, itemptr->size );
       
   418         CLiwDefaultMap* map = CLiwDefaultMap::NewLC( rs );
       
   419          
       
   420         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   421         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   422         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   423         cpdatamap->InsertL( KMyActionMap  , TLiwVariant( map ) );
       
   424     
       
   425         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   426         inParam->AppendL( item );
       
   427  
       
   428         iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   429         CleanupStack::PopAndDestroy( map );
       
   430         CleanupStack::PopAndDestroy( cpdatamap );
       
   431         CleanupStack::PopAndDestroy( outParam );
       
   432         CleanupStack::PopAndDestroy( inParam );
       
   433         
       
   434         itemptr = actionIter.NextValue();
       
   435         }
       
   436     MPX_DEBUG1("CMusicContentPublisher::CMusicContentPublisher::DoPublishL --->");
       
   437     }
       
   438 
       
   439 // ---------------------------------------------------------------------------
       
   440 // Resets all the graphical elements.
       
   441 // ---------------------------------------------------------------------------
       
   442 //
       
   443 void CMusicContentPublisher::ResetL()
       
   444     {
       
   445     MPX_DEBUG1("CMusicContentPublisher::ResetL <---");
       
   446     //Plugin deletion is handled by the pluginmanager.
       
   447     iActivePlugin = NULL;
       
   448     //Reset The Widget
       
   449     PublishImageL(NULL,EMusicWidgetImage1,KEmpty);
       
   450     InstallGoToAlbumL(EMusicWidgetTrigger1);
       
   451     PublishTextL( NULL,EMusicWidgetText1, KEmpty );
       
   452     PublishImageL(NULL,EMusicWidgetToolbarB1,KEmpty);
       
   453     PublishImageL(NULL,EMusicWidgetToolbarB2,KEmpty);
       
   454     PublishImageL(NULL,EMusicWidgetToolbarB3,KEmpty);
       
   455     InstallEmptyActionL(EMusicWidgetTB1Trigger);
       
   456     InstallEmptyActionL(EMusicWidgetTB2Trigger);
       
   457     InstallEmptyActionL(EMusicWidgetTB3Trigger);
       
   458     PublishTextL( NULL,EMusicWidgetDefaultText, iGoToMusicBuffer->Des() );  
       
   459     InstallGoToAlbumL(EMusicWidgetTrigger2);
       
   460 
       
   461     //Reset the music menu info
       
   462     InstallEmptyActionL(EMusicMenuMusicInfoTrigger);
       
   463     PublishTextL( NULL, EMusicMenuMusicInfoLine1, iLastPlayedBuffer->Des() );
       
   464     PublishTextL( NULL, EMusicMenuMusicInfoLine2, KEmpty );
       
   465     PublishImageL( NULL, EMusicMenuMusicInfoImage1, KEmpty );
       
   466     MPX_DEBUG1("CMusicContentPublisher::Reset --->");
       
   467     }
       
   468 // ---------------------------------------------------------------------------
       
   469 // 
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 TSize CMusicContentPublisher::GetImageDestinationSize(
       
   473         TMCPImageDestination aDst)
       
   474     {
       
   475     MPX_DEBUG1("CMusicContentPublisher::GetImageDestinationSize <---");
       
   476     TSize * ret;
       
   477     ret = iImageDestinationSizeMap.Find(aDst);
       
   478     if (ret)
       
   479         {
       
   480         MPX_DEBUG1("CMusicContentPublisher::GetImageDestinationSize --->");
       
   481         return *ret;    
       
   482         }
       
   483     else
       
   484         {
       
   485         MPX_DEBUG1("CMusicContentPublisher::GetImageDestinationSize --->");
       
   486         return TSize(0,0);
       
   487         }
       
   488     }
       
   489 
       
   490 
       
   491 // ---------------------------------------------------------------------------
       
   492 // Destroys the bitmaps saved on the cache.
       
   493 // ---------------------------------------------------------------------------
       
   494 //
       
   495 void CMusicContentPublisher::ResetBitmapCache()
       
   496     {
       
   497     MPX_DEBUG1("CMusicContentPublisher::ResetBitmapCache <---");
       
   498     THashMapIter<TInt, TBmpMsk> iter(iBitmapCache);
       
   499     TBmpMsk const* ptr = iter.NextValue();
       
   500     CFbsBitmap* bmp( NULL );
       
   501     CFbsBitmap* msk( NULL );
       
   502     while ( ptr )
       
   503         {
       
   504         bmp = ptr->bitmap;
       
   505         msk = ptr->mask;
       
   506         delete bmp;
       
   507         bmp = NULL;
       
   508         delete msk;
       
   509         msk = NULL;
       
   510         ptr = iter.NextValue();
       
   511         }
       
   512     iBitmapCache.Close();
       
   513     MPX_DEBUG1("CMusicContentPublisher::ResetBitmapCache --->");
       
   514     }
       
   515     
       
   516 // ---------------------------------------------------------------------------
       
   517 // Destroys the publishing buffers.
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 void CMusicContentPublisher::ResetPublishingBuffers()
       
   521     {
       
   522     THashMapIter<TInt, TMyBufferItem> dataIter( iPublishingDataBuffers );
       
   523     THashMapIter<TInt, TMyBufferItem> actionIter( iPublishingActionBuffers );
       
   524     
       
   525     TMyBufferItem const* itemptr;
       
   526     itemptr = dataIter.NextValue();
       
   527     while (itemptr)
       
   528         {
       
   529         User::Free(itemptr->buf);
       
   530         dataIter.RemoveCurrent();
       
   531         itemptr = dataIter.NextValue();
       
   532         }
       
   533     iPublishingDataBuffers.Close();
       
   534     itemptr = NULL;
       
   535     itemptr = actionIter.NextValue();
       
   536     while (itemptr)
       
   537         {
       
   538         User::Free(itemptr->buf);
       
   539         actionIter.RemoveCurrent();
       
   540         itemptr = actionIter.NextValue();
       
   541         }
       
   542     iPublishingActionBuffers.Close();
       
   543     }
       
   544 
       
   545 TUint CMusicContentPublisher::RegisterPublisherL( 
       
   546     const TDesC& aPublisherId, 
       
   547     const TDesC& aContentId,
       
   548     const TDesC& aContentType )
       
   549     {
       
   550     MPX_DEBUG1("CMusicContentPublisher::RegisterPublisherL <---");
       
   551     TUint id( 0 );
       
   552     if( iCPSInterface )
       
   553         {   
       
   554         CLiwGenericParamList* inparam( CLiwGenericParamList::NewLC() );
       
   555         CLiwGenericParamList* outparam( CLiwGenericParamList::NewLC() );
       
   556 
       
   557         TLiwGenericParam type( KType, TLiwVariant( KPubData ));
       
   558         inparam->AppendL( type );
       
   559         CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   560         CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
       
   561         CLiwDefaultMap* actionmap( NULL );
       
   562 
       
   563         // Create the data map for publisher registry
       
   564         cpdatamap->InsertL( KContentType, TLiwVariant( aContentType ));
       
   565         cpdatamap->InsertL( KContentId, TLiwVariant( aContentId ));
       
   566         cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
       
   567 
       
   568         
       
   569         // Create the action map for publisher registry
       
   570         actionmap = CLiwDefaultMap::NewLC();
       
   571         actionmap->InsertL(KMyActive, TLiwVariant( KMyActionName ));
       
   572         actionmap->InsertL(KMyDeActive, TLiwVariant( KMyActionName ));
       
   573         actionmap->InsertL(KMySuspend, TLiwVariant( KMyActionName ));
       
   574         actionmap->InsertL(KMyResume, TLiwVariant( KMyActionName ));
       
   575  
       
   576         cpdatamap->InsertL( KMyActionMap, TLiwVariant(actionmap));
       
   577         CleanupStack::PopAndDestroy( actionmap );
       
   578         
       
   579         TLiwGenericParam item( KMyItem, TLiwVariant( cpdatamap ));        
       
   580         inparam->AppendL( item );
       
   581         
       
   582         iCPSInterface->ExecuteCmdL( KMyAdd , *inparam, *outparam);
       
   583         id = ExtractItemId(*outparam);
       
   584         
       
   585         CleanupStack::PopAndDestroy( datamap );
       
   586         CleanupStack::PopAndDestroy( cpdatamap );
       
   587         item.Reset();
       
   588         type.Reset();   
       
   589         CleanupStack::PopAndDestroy(outparam);
       
   590         CleanupStack::PopAndDestroy(inparam);
       
   591         }
       
   592     MPX_DEBUG1("CMusicContentPublisher::RegisterPublisherL --->");
       
   593     return id;
       
   594     }
       
   595 
       
   596 TUint CMusicContentPublisher::ExtractItemId( const CLiwGenericParamList& aInParamList )
       
   597     {
       
   598     MPX_DEBUG1("CMusicContentPublisher::ExtractItemId <---");
       
   599     TUint result ( 0 );
       
   600     TInt pos( 0 );
       
   601     aInParamList.FindFirst( pos, KMyItemId );
       
   602     if( pos != KErrNotFound )
       
   603         {
       
   604         // item id present - extract and return
       
   605         aInParamList[pos].Value().Get( result );
       
   606         }
       
   607     MPX_DEBUG1("CMusicContentPublisher::ExtractItemId --->");
       
   608     return result;
       
   609     }
       
   610  
       
   611  // ---------------------------------------------------------------------------
       
   612 // removes CPS entry for the required destination
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 void CMusicContentPublisher::RemoveL( TInt aDestination )
       
   616     {
       
   617     MPX_DEBUG1("CMusicContentPublisher::RemoveL <---");
       
   618     if( iCPSInterface )
       
   619         {
       
   620         CLiwGenericParamList * inParam = CLiwGenericParamList::NewLC();
       
   621         CLiwGenericParamList * outParam = CLiwGenericParamList::NewLC();
       
   622         TPtrC8 dataKey;
       
   623         TPtrC type;
       
   624         TPtrC content;
       
   625         MapEnumToDestinationInfoL(aDestination, type, dataKey, content);
       
   626         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   627         inParam->AppendL( cptype );
       
   628         CLiwDefaultMap * cpdatamap = CLiwDefaultMap::NewLC( );
       
   629         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   630         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   631         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   632         TLiwGenericParam item( KFilter, TLiwVariant( cpdatamap ) ); 
       
   633         inParam->AppendL( item );
       
   634         iCPSInterface->ExecuteCmdL( KDelete , *inParam, *outParam);
       
   635         CleanupStack::PopAndDestroy( cpdatamap );
       
   636         CleanupStack::PopAndDestroy( outParam );
       
   637         CleanupStack::PopAndDestroy( inParam );
       
   638         }  
       
   639     MPX_DEBUG1("CMusicContentPublisher::RemoveL --->");
       
   640     }
       
   641 
       
   642 // ---------------------------------------------------------------------------
       
   643 // Publishes an image from path to the required destination
       
   644 // ---------------------------------------------------------------------------
       
   645 //
       
   646 void CMusicContentPublisher::PublishImageL( CMCPPlugin* aPlugin,  
       
   647         TMCPImageDestination aDestination, 
       
   648         const TDesC& aImagePath )
       
   649     {
       
   650     MPX_DEBUG1("CMusicContentPublisher::PublishImageL <---");
       
   651     if( iCPSInterface && iActivePlugin == aPlugin )
       
   652         {
       
   653         CLiwGenericParamList * inParam = CLiwGenericParamList::NewLC();
       
   654         CLiwGenericParamList * outParam = CLiwGenericParamList::NewLC();
       
   655         
       
   656         TPtrC8 dataKey;
       
   657         TPtrC type;
       
   658         TPtrC content;
       
   659         MapEnumToDestinationInfoL(aDestination, type, dataKey, content);
       
   660         
       
   661         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   662         inParam->AppendL( cptype );
       
   663         CLiwDefaultMap * cpdatamap = CLiwDefaultMap::NewLC( );
       
   664         CLiwDefaultMap * map = CLiwDefaultMap::NewLC( );
       
   665         
       
   666          
       
   667         map->InsertL(dataKey, TLiwVariant( aImagePath ) );
       
   668         
       
   669         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   670         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   671         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   672         cpdatamap->InsertL( KDataMap  , TLiwVariant( map ) );
       
   673     
       
   674         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   675         inParam->AppendL( item );
       
   676         
       
   677         if ( aDestination >= EMusicMenuMusicInfoImage1 )
       
   678             {
       
   679             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   680             }
       
   681         else
       
   682             {
       
   683             if ( iIsPublisherActive )
       
   684                 {
       
   685                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   686                 }
       
   687             TMyBufferItem* ptr;
       
   688             ptr = iPublishingDataBuffers.Find(aDestination);
       
   689             if (ptr) //remove the old one
       
   690                 {
       
   691                 User::Free(ptr->buf);
       
   692                 iPublishingDataBuffers.Remove(aDestination);
       
   693                 }
       
   694             TInt sz = map->Size();
       
   695             TMyBufferItem bufferitem;
       
   696             bufferitem.size = map->Size();
       
   697             bufferitem.buf = User::AllocL(map->Size());
       
   698             RMemWriteStream ws(bufferitem.buf, bufferitem.size);
       
   699             map->ExternalizeL(ws);
       
   700             iPublishingDataBuffers.Insert(aDestination, bufferitem);
       
   701             }
       
   702         CleanupStack::PopAndDestroy( map );
       
   703         CleanupStack::PopAndDestroy( cpdatamap );
       
   704         CleanupStack::PopAndDestroy( outParam );
       
   705         CleanupStack::PopAndDestroy( inParam );
       
   706         }   
       
   707     MPX_DEBUG1("CMusicContentPublisher::PublishImageL --->");
       
   708     }
       
   709 
       
   710 // ---------------------------------------------------------------------------
       
   711 // Publishes an image from bitmap handle to the required destination
       
   712 // ---------------------------------------------------------------------------
       
   713 //
       
   714 void CMusicContentPublisher::PublishImageL( CMCPPlugin* aPlugin, 
       
   715         TMCPImageDestination aDestination,
       
   716         TInt aBitmapHandle,
       
   717         TInt aMaskBitmapHandle)
       
   718     {
       
   719     MPX_DEBUG1("CMusicContentPublisher::PublishImageL <---");
       
   720     if( iCPSInterface && iActivePlugin == aPlugin )
       
   721         {
       
   722         CLiwGenericParamList * inParam = CLiwGenericParamList::NewLC();
       
   723         CLiwGenericParamList * outParam = CLiwGenericParamList::NewLC();
       
   724         
       
   725         TPtrC8 dataKey;
       
   726         TPtrC type;
       
   727         TPtrC content;
       
   728         MapEnumToDestinationInfoL(aDestination, type, dataKey, content);
       
   729         
       
   730         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   731         inParam->AppendL( cptype );
       
   732         CLiwDefaultMap * cpdatamap = CLiwDefaultMap::NewLC( );
       
   733         CLiwDefaultMap * map = CLiwDefaultMap::NewLC( );
       
   734         
       
   735          
       
   736         if (aDestination == EMusicMenuMusicInfoImage1)
       
   737             {
       
   738             //Matrix Menu expects a Tint32 (TVariantTypeId::EVariantTypeTInt32)   
       
   739             map->InsertL(dataKey, TLiwVariant( TInt32( aBitmapHandle ) ) );
       
   740             }
       
   741         else 
       
   742             {
       
   743             //Homescreen expects a TBool/TInt 
       
   744             //(TVariantTypeId::EVariantTypeTBool)
       
   745             map->InsertL(dataKey, TLiwVariant( aBitmapHandle ) );
       
   746             }
       
   747         
       
   748         if (aMaskBitmapHandle)
       
   749             {
       
   750             HBufC8* maskResult = HBufC8::NewLC( 
       
   751                     dataKey.Length() + KMask().Length() );
       
   752             TPtr8 maskResultPtr = maskResult->Des();
       
   753             maskResultPtr.Append( dataKey );
       
   754             maskResultPtr.Append( KMask );
       
   755             if (aDestination == EMusicMenuMusicInfoImage1)
       
   756                 {
       
   757                 //Matrix Menu expects a Tint32 (TVariantTypeId::EVariantTypeTInt32)   
       
   758                 map->InsertL(maskResultPtr, TLiwVariant( (TInt32)aMaskBitmapHandle ) );
       
   759                 }
       
   760             else 
       
   761                 {
       
   762                 //Homescreen expects a TBool/TInt 
       
   763                 //(TVariantTypeId::EVariantTypeTBool)
       
   764                 map->InsertL(maskResultPtr, TLiwVariant( aMaskBitmapHandle ) );
       
   765                 }
       
   766             CleanupStack::PopAndDestroy( maskResult );
       
   767             }
       
   768         
       
   769         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   770         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   771         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   772         cpdatamap->InsertL( KDataMap  , TLiwVariant( map ) );
       
   773     
       
   774         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   775         inParam->AppendL( item );
       
   776         
       
   777         if ( aDestination >= EMusicMenuMusicInfoImage1 )
       
   778             {
       
   779             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   780             }
       
   781         else
       
   782             {
       
   783             if ( iIsPublisherActive )
       
   784                 {
       
   785                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );  	
       
   786                 }
       
   787             TMyBufferItem* ptr;
       
   788             ptr = iPublishingDataBuffers.Find(aDestination);
       
   789             if (ptr) //remove the old one
       
   790                 {
       
   791                 User::Free(ptr->buf);
       
   792                 iPublishingDataBuffers.Remove(aDestination);
       
   793                 }
       
   794             TInt sz = map->Size();
       
   795             TMyBufferItem bufferitem;
       
   796             bufferitem.size = map->Size();
       
   797             bufferitem.buf = User::AllocL(map->Size());
       
   798             RMemWriteStream ws(bufferitem.buf, bufferitem.size);
       
   799             map->ExternalizeL(ws);
       
   800             iPublishingDataBuffers.Insert(aDestination, bufferitem);
       
   801             }
       
   802         CleanupStack::PopAndDestroy( map );
       
   803         CleanupStack::PopAndDestroy( cpdatamap );
       
   804         CleanupStack::PopAndDestroy( outParam );
       
   805         CleanupStack::PopAndDestroy( inParam );
       
   806         }
       
   807     MPX_DEBUG1("CMusicContentPublisher::PublishImageL --->");
       
   808     }
       
   809 
       
   810 // ---------------------------------------------------------------------------
       
   811 // Publishes an image from skin id and mif to the required destination
       
   812 // ---------------------------------------------------------------------------
       
   813 //
       
   814 void CMusicContentPublisher::PublishImageL(CMCPPlugin* aPlugin, 
       
   815         TMCPImageDestination aDestination,
       
   816         const TAknsItemID& aID,
       
   817         const TDesC& aFilename,
       
   818         const TInt aFileBitmapId,
       
   819         const TInt aFileMaskId )
       
   820     {
       
   821     MPX_DEBUG1("CMusicContentPublisher::PublishImageL <---");
       
   822     TBmpMsk* bitmapandmask;
       
   823     bitmapandmask = iBitmapCache.Find(aID.iMajor+aID.iMinor);
       
   824     CFbsBitmap* bitmap = NULL;
       
   825     CFbsBitmap* mask = NULL;
       
   826     if (!bitmapandmask)
       
   827         {
       
   828         // Load from skin
       
   829         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   830         AknsUtils::CreateIconL(
       
   831                     skin,
       
   832                     aID,
       
   833                     bitmap,
       
   834                     mask,
       
   835                     aFilename,
       
   836                     aFileBitmapId,
       
   837                     aFileMaskId);
       
   838         AknIconUtils::SetSize(
       
   839                 bitmap,
       
   840                 GetImageDestinationSize(aDestination),
       
   841                 EAspectRatioPreserved );
       
   842         AknIconUtils::SetSize(mask,
       
   843                 GetImageDestinationSize(aDestination),
       
   844                 EAspectRatioPreserved );
       
   845         TBmpMsk bmpAndMsk;
       
   846         bmpAndMsk.bitmap=bitmap;
       
   847         bmpAndMsk.mask=mask;
       
   848         iBitmapCache.Insert(aID.iMajor+aID.iMinor,bmpAndMsk);
       
   849         bitmapandmask = iBitmapCache.Find(aID.iMajor+aID.iMinor);
       
   850         __ASSERT_DEBUG(bitmapandmask,User::Invariant());
       
   851         }
       
   852     bitmap = bitmapandmask->bitmap;
       
   853     mask = bitmapandmask->mask;
       
   854     
       
   855     PublishImageL( aPlugin, aDestination, bitmap->Handle() , mask->Handle()); 
       
   856     MPX_DEBUG1("CMusicContentPublisher::PublishImageL --->");
       
   857     }
       
   858 
       
   859 // ---------------------------------------------------------------------------
       
   860 // Publishes a text from path to the required destination
       
   861 // ---------------------------------------------------------------------------
       
   862 //
       
   863 void CMusicContentPublisher::PublishTextL( CMCPPlugin* aPlugin, 
       
   864         TMCPTextDestination aDestination, 
       
   865         const TDesC& aText )
       
   866     {
       
   867     MPX_DEBUG1("CMusicContentPublisher::PublishTextL <---");
       
   868     if( iCPSInterface && iActivePlugin == aPlugin)
       
   869         {
       
   870         CLiwGenericParamList * inParam = CLiwGenericParamList::NewLC();
       
   871         CLiwGenericParamList * outParam = CLiwGenericParamList::NewLC();
       
   872         
       
   873         TPtrC8 dataKey;
       
   874         TPtrC type;
       
   875         TPtrC content;
       
   876         MapEnumToDestinationInfoL(aDestination, type, dataKey, content);
       
   877         
       
   878         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   879         inParam->AppendL( cptype );
       
   880         CLiwDefaultMap * cpdatamap = CLiwDefaultMap::NewLC( );
       
   881         CLiwDefaultMap * map = CLiwDefaultMap::NewLC( );
       
   882         
       
   883         if (KErrNotFound == aText.Find(KLoc))
       
   884             {
       
   885             map->InsertL( dataKey , TLiwVariant( aText ) );    
       
   886             }
       
   887         else
       
   888             {
       
   889             if ( ! aText.Compare( KNowPlaying ) )
       
   890                 {
       
   891                 map->InsertL( dataKey , TLiwVariant( iNowPlayingBuffer ) );
       
   892                 }
       
   893             else if ( ! aText.Compare( KLastPlayed ) )
       
   894                 {
       
   895                 map->InsertL( dataKey , TLiwVariant( iLastPlayedBuffer ) );
       
   896                 }
       
   897             else
       
   898                 {
       
   899                 map->InsertL( dataKey , TLiwVariant( aText ) );
       
   900                 }
       
   901             }
       
   902         
       
   903         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   904         cpdatamap->InsertL( KContentType , TLiwVariant( type ) );
       
   905         cpdatamap->InsertL( KContentId  , TLiwVariant( content ) );
       
   906         cpdatamap->InsertL( KDataMap  , TLiwVariant( map ) );
       
   907         
       
   908         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   909         inParam->AppendL( item );
       
   910         
       
   911         if ( aDestination >= EMusicMenuMusicInfoLine1 )
       
   912             {
       
   913             if (aText  != KEmpty)
       
   914                 {
       
   915                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   916                 }
       
   917             else
       
   918                 {
       
   919                 iCPSInterface->ExecuteCmdL( KDelete , *inParam, *outParam);
       
   920                 }
       
   921             }
       
   922         else
       
   923             {
       
   924             if ( iIsPublisherActive )
       
   925                 {
       
   926                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );        	
       
   927                 }
       
   928             TMyBufferItem* ptr;
       
   929             ptr = iPublishingDataBuffers.Find(aDestination);
       
   930             if (ptr) //remove the old one
       
   931                 {
       
   932                 User::Free(ptr->buf);
       
   933                 iPublishingDataBuffers.Remove(aDestination);
       
   934                 }
       
   935             TInt sz = map->Size();
       
   936             TMyBufferItem bufferitem;
       
   937             bufferitem.size = map->Size();
       
   938             bufferitem.buf = User::AllocL(map->Size());
       
   939             RMemWriteStream ws(bufferitem.buf, bufferitem.size);
       
   940             map->ExternalizeL(ws);
       
   941             iPublishingDataBuffers.Insert(aDestination, bufferitem);
       
   942             }
       
   943         CleanupStack::PopAndDestroy( map );
       
   944         CleanupStack::PopAndDestroy( cpdatamap );
       
   945         CleanupStack::PopAndDestroy( outParam );
       
   946         CleanupStack::PopAndDestroy( inParam );
       
   947         }  
       
   948     MPX_DEBUG1("CMusicContentPublisher::PublishTextL --->");
       
   949     }
       
   950 
       
   951 // ---------------------------------------------------------------------------
       
   952 // Publishes an action from a trigger map to the required destination
       
   953 // ---------------------------------------------------------------------------
       
   954 //
       
   955 void CMusicContentPublisher::PublishActionL( CMCPPlugin* aPlugin, 
       
   956         TMCPTriggerDestination aDestination,
       
   957         CLiwDefaultMap* aTriggerMap )
       
   958     {
       
   959     MPX_DEBUG1("CMusicContentPublisher::PublishActionL <---");
       
   960      if( iCPSInterface && iActivePlugin == aPlugin)
       
   961         {
       
   962         CLiwGenericParamList * inParam = CLiwGenericParamList::NewLC();
       
   963         CLiwGenericParamList * outParam = CLiwGenericParamList::NewLC();
       
   964         
       
   965         TPtrC8 triggerKey;
       
   966         TPtrC hostType;
       
   967         TPtrC hostContent;
       
   968         
       
   969         MapEnumToDestinationInfoL(aDestination, hostType, triggerKey, 
       
   970                 hostContent);
       
   971         
       
   972         TLiwGenericParam cptype( KType , TLiwVariant( KCpData ) );
       
   973         inParam->AppendL( cptype );
       
   974         
       
   975         CLiwDefaultMap * cpdatamap = CLiwDefaultMap::NewLC( );
       
   976         cpdatamap->InsertL( KPublisherId , TLiwVariant( KMWPublisher ) );
       
   977         cpdatamap->InsertL( KContentType , TLiwVariant( hostType ) );
       
   978         cpdatamap->InsertL( KContentId  , TLiwVariant( hostContent ) );
       
   979         
       
   980         CLiwDefaultMap * actionmap = CLiwDefaultMap::NewLC( );
       
   981         actionmap->InsertL( triggerKey , TLiwVariant( aTriggerMap ) );
       
   982         cpdatamap->InsertL( KActionMap  , TLiwVariant( actionmap ) );
       
   983         
       
   984         TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ) ); 
       
   985         inParam->AppendL( item );
       
   986         
       
   987         if ( aDestination >= EMusicMenuMusicInfoTrigger )
       
   988             {
       
   989             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   990             }
       
   991         else
       
   992             {
       
   993             if ( iIsPublisherActive )
       
   994                 {
       
   995             	  iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
       
   996                 }
       
   997             TMyBufferItem* ptr;
       
   998             ptr = iPublishingActionBuffers.Find(aDestination);
       
   999             if (ptr) //remove the old one
       
  1000                 {
       
  1001                 User::Free(ptr->buf);
       
  1002                 iPublishingActionBuffers.Remove(aDestination);
       
  1003                 }
       
  1004             TInt sz = actionmap->Size();
       
  1005             TMyBufferItem bufferitem;
       
  1006             bufferitem.size = actionmap->Size();
       
  1007             bufferitem.buf = User::AllocL(actionmap->Size());
       
  1008             RMemWriteStream ws(bufferitem.buf, bufferitem.size);
       
  1009             actionmap->ExternalizeL(ws);
       
  1010             iPublishingActionBuffers.Insert(aDestination, bufferitem);
       
  1011             }
       
  1012         CleanupStack::PopAndDestroy( actionmap );
       
  1013         CleanupStack::PopAndDestroy( cpdatamap );
       
  1014         CleanupStack::PopAndDestroy( outParam );
       
  1015         CleanupStack::PopAndDestroy( inParam );
       
  1016         }
       
  1017     MPX_DEBUG1("CMusicContentPublisher::PublishActionL --->");
       
  1018     }
       
  1019 
       
  1020 // ---------------------------------------------------------------------------
       
  1021 // Called when a plugin becomes active, it deactivates the previous plugin.
       
  1022 // ---------------------------------------------------------------------------
       
  1023 //
       
  1024 void CMusicContentPublisher::BecameActiveL( CMCPPlugin* aPlugin )
       
  1025     {
       
  1026     MPX_DEBUG1("CMusicContentPublisher::BecameActiveL <---");
       
  1027     if ( iActivePlugin != aPlugin )
       
  1028         {
       
  1029         if ( iActivePlugin )
       
  1030             {
       
  1031             MPX_DEBUG1("CMusicContentPublisher::BecameActiveL deactivating old plugin");
       
  1032             iActivePlugin->Deactivate();
       
  1033             MPX_DEBUG1("CMusicContentPublisher::BecameActiveL plugin deactivated");
       
  1034             PublishImageL( iActivePlugin, EMusicMenuMusicInfoImage1, KEmpty );
       
  1035             }
       
  1036         iActivePlugin = aPlugin;
       
  1037         }
       
  1038     MPX_DEBUG1("CMusicContentPublisher::BecameActiveL --->");
       
  1039     }
       
  1040 // ---------------------------------------------------------------------------
       
  1041 // From CContentHarvesterPlugin
       
  1042 // This function updates information in CPS storage
       
  1043 // ---------------------------------------------------------------------------
       
  1044 //    
       
  1045 void CMusicContentPublisher::UpdateL() 
       
  1046     {
       
  1047     MPX_DEBUG1("CMusicContentPublisher::UpdateL <---");
       
  1048     if ( !iPluginManager )
       
  1049         {
       
  1050         MPX_DEBUG1("CMusicContentPublisher::UpdateL creating the plugin manager");
       
  1051         iPluginManager = CPluginManager::NewL(
       
  1052                 TUid::Uid( KMCPPluginUid ), 
       
  1053                 static_cast<MMCPPluginObserver*>( this ),
       
  1054                 this );
       
  1055         }
       
  1056     MPX_DEBUG1("CMusicContentPublisher::UpdateL --->");
       
  1057     }
       
  1058 
       
  1059 // ---------------------------------------------------------------------------
       
  1060 // From MAknsSkinChangeObserver.
       
  1061 // Called by the skin server when skin content is changed and the
       
  1062 // connected client wants to be informed.
       
  1063 // ---------------------------------------------------------------------------
       
  1064 // 
       
  1065 void CMusicContentPublisher::SkinContentChanged()
       
  1066     {
       
  1067     MPX_DEBUG1("CMusicContentPublisher::SkinContentChanged <---");
       
  1068     ResetBitmapCache();
       
  1069     if(iActivePlugin)
       
  1070         {
       
  1071         iActivePlugin->SkinChanged();
       
  1072         }
       
  1073     MPX_DEBUG1("CMusicContentPublisher::SkinContentChanged --->");
       
  1074     }
       
  1075 
       
  1076 void CMusicContentPublisher::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
       
  1077     {
       
  1078     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL <---");
       
  1079     if ( aTrigger == KMyActive )
       
  1080         {
       
  1081         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate");
       
  1082         if ( !iInstanceId )
       
  1083             {
       
  1084             iInstanceId = aContentId.AllocL();
       
  1085         	  //Reset The Widget
       
  1086         	  MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate --> Reset Widget");
       
  1087         	  RDebug::Print(aContentId);
       
  1088             PublishImageL(NULL,EMusicWidgetImage1,KEmpty);
       
  1089         	InstallGoToAlbumL( EMusicWidgetTrigger1 );
       
  1090             PublishTextL( NULL,EMusicWidgetText1, KEmpty );
       
  1091             PublishImageL(NULL,EMusicWidgetToolbarB1,KEmpty);
       
  1092             PublishImageL(NULL,EMusicWidgetToolbarB2,KEmpty);
       
  1093             PublishImageL(NULL,EMusicWidgetToolbarB3,KEmpty);
       
  1094             InstallEmptyActionL(EMusicWidgetTB1Trigger);
       
  1095             InstallEmptyActionL(EMusicWidgetTB2Trigger);
       
  1096             InstallEmptyActionL(EMusicWidgetTB3Trigger);
       
  1097             PublishTextL( NULL,EMusicWidgetDefaultText, iGoToMusicBuffer->Des() );
       
  1098 			InstallGoToAlbumL( EMusicWidgetTrigger2 );
       
  1099             }
       
  1100         else
       
  1101             {
       
  1102             delete iInstanceId;
       
  1103             iInstanceId = NULL;
       
  1104             iInstanceId = aContentId.AllocL();
       
  1105             }
       
  1106         }
       
  1107     else if ( aTrigger ==  KMyDeActive)
       
  1108         {
       
  1109         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL deactivate");
       
  1110         //Removing al the CPS entrys to prevent flicker of old text and unwanted images (old/expired handles).
       
  1111         RemoveL( EMusicWidgetImage1 );
       
  1112         RemoveL( EMusicWidgetText1 );
       
  1113         RemoveL( EMusicWidgetToolbarB1 );
       
  1114         RemoveL( EMusicWidgetToolbarB2 );
       
  1115         RemoveL( EMusicWidgetToolbarB3 );
       
  1116         RemoveL( EMusicWidgetDefaultText );
       
  1117         }
       
  1118     else if ( aTrigger ==  KMySuspend)
       
  1119         {
       
  1120         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL suspend");
       
  1121         iIsPublisherActive = EFalse;
       
  1122         }
       
  1123     else if ( aTrigger ==  KMyResume)
       
  1124         {
       
  1125         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL resume");
       
  1126         iIsPublisherActive = ETrue;
       
  1127         DoPublishL();
       
  1128         }
       
  1129     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL --->");
       
  1130     }
       
  1131 
       
  1132 
       
  1133 //  End of File
       
  1134