musichomescreen_multiview/musiccontentpublisher/src/musiccontentpublisher.cpp
changeset 2 b70d77332e66
parent 0 ff3acec5bc43
child 17 c8156a91d13c
equal deleted inserted replaced
1:8118492f1bdf 2:b70d77332e66
    76 
    76 
    77 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    78 // Constructor
    78 // Constructor
    79 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    80 //
    80 //
    81 CMusicContentPublisher::CMusicContentPublisher( MLiwInterface* aCPSInterface )
    81 CMusicContentPublisher::CMusicContentPublisher( MLiwInterface* aCPSInterface ):
    82     {
    82         iCPSInterface (aCPSInterface)
    83     iCPSInterface = aCPSInterface;
    83     {
    84     iActivePlugin=NULL;
       
    85     iIsPublisherActive = EFalse;
       
    86 
       
    87     }
    84     }
    88 
    85 
    89 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    90 // Symbian 2nd phase constructor can leave.
    87 // Symbian 2nd phase constructor can leave.
    91 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
   305         TPtrC type ( reinterpret_cast<const TUint16*>(
   302         TPtrC type ( reinterpret_cast<const TUint16*>(
   306                 tmpdstitemp->type) );
   303                 tmpdstitemp->type) );
   307         TPtrC8 dataKey ( reinterpret_cast<const TUint8*>(
   304         TPtrC8 dataKey ( reinterpret_cast<const TUint8*>(
   308                 tmpdstitemp->dataKey ) );
   305                 tmpdstitemp->dataKey ) );
   309         TPtrC content ( reinterpret_cast<const TUint16*>(
   306         TPtrC content ( reinterpret_cast<const TUint16*>(
   310                     tmpdstitemp->content) );
   307                 tmpdstitemp->content) );
   311 
   308 
   312         aType.Set(type);
   309         aType.Set(type);
   313         aDataKey.Set(dataKey);
   310         aDataKey.Set(dataKey);
   314 
   311 
   315         if ( !content.Compare( KWildCard ) )
   312         if ( !content.Compare( KWildCard ) )
   316             {
   313             {
   317             aContent.Set( iInstanceId->Des() );
   314             aContent.Set(iInstanceId ? iInstanceId->Des(): KNullDesC() );
   318             }
   315             }
   319         else
   316         else
   320             {
   317             {
   321             aContent.Set(content);
   318             aContent.Set(content);
   322             }
   319             }
   678             {
   675             {
   679             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   676             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   680             }
   677             }
   681         else
   678         else
   682             {
   679             {
   683             if ( iIsPublisherActive )
   680             if ( iWidgetForeground )
   684                 {
   681                 {
   685                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   682                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   686                 }
   683                 }
   687             TMyBufferItem* ptr;
   684             TMyBufferItem* ptr;
   688             ptr = iPublishingDataBuffers.Find(aDestination);
   685             ptr = iPublishingDataBuffers.Find(aDestination);
   778             {
   775             {
   779             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   776             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   780             }
   777             }
   781         else
   778         else
   782             {
   779             {
   783             if ( iIsPublisherActive )
   780             if ( iWidgetForeground )
   784                 {
   781                 {
   785                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );  	
   782                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );  	
   786                 }
   783                 }
   787             TMyBufferItem* ptr;
   784             TMyBufferItem* ptr;
   788             ptr = iPublishingDataBuffers.Find(aDestination);
   785             ptr = iPublishingDataBuffers.Find(aDestination);
   919                 iCPSInterface->ExecuteCmdL( KDelete , *inParam, *outParam);
   916                 iCPSInterface->ExecuteCmdL( KDelete , *inParam, *outParam);
   920                 }
   917                 }
   921             }
   918             }
   922         else
   919         else
   923             {
   920             {
   924             if ( iIsPublisherActive )
   921             if ( iWidgetForeground )
   925                 {
   922                 {
   926                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );        	
   923                 iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );        	
   927                 }
   924                 }
   928             TMyBufferItem* ptr;
   925             TMyBufferItem* ptr;
   929             ptr = iPublishingDataBuffers.Find(aDestination);
   926             ptr = iPublishingDataBuffers.Find(aDestination);
   988             {
   985             {
   989             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   986             iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   990             }
   987             }
   991         else
   988         else
   992             {
   989             {
   993             if ( iIsPublisherActive )
   990             if ( iWidgetForeground )
   994                 {
   991                 {
   995             	  iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   992             	  iCPSInterface->ExecuteCmdL( KAdd , *inParam, *outParam );
   996                 }
   993                 }
   997             TMyBufferItem* ptr;
   994             TMyBufferItem* ptr;
   998             ptr = iPublishingActionBuffers.Find(aDestination);
   995             ptr = iPublishingActionBuffers.Find(aDestination);
  1074     }
  1071     }
  1075 
  1072 
  1076 void CMusicContentPublisher::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
  1073 void CMusicContentPublisher::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
  1077     {
  1074     {
  1078     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL <---");
  1075     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL <---");
  1079     if ( aTrigger == KMyActive )
  1076     if ( aTrigger == KMyActive && !iWidgetActivated)
  1080         {
  1077         {
       
  1078         iWidgetActivated = ETrue;
  1081         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate");
  1079         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate");
  1082         if ( !iInstanceId )
  1080         if ( !iInstanceId )
  1083             {
  1081             {
  1084             iInstanceId = aContentId.AllocL();
  1082             iInstanceId = aContentId.AllocL();
  1085         	  //Reset The Widget
  1083             //Reset The Widget
  1086         	  MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate --> Reset Widget");
  1084             MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL activate --> Reset Widget");
  1087         	  RDebug::Print(aContentId);
  1085             RDebug::Print(aContentId);
  1088             PublishImageL(NULL,EMusicWidgetImage1,KEmpty);
  1086             PublishImageL(NULL,EMusicWidgetImage1,KEmpty);
  1089         	InstallGoToAlbumL( EMusicWidgetTrigger1 );
  1087             InstallGoToAlbumL( EMusicWidgetTrigger1 );
  1090             PublishTextL( NULL,EMusicWidgetText1, KEmpty );
  1088             PublishTextL( NULL,EMusicWidgetText1, KEmpty );
  1091             PublishImageL(NULL,EMusicWidgetToolbarB1,KEmpty);
  1089             PublishImageL(NULL,EMusicWidgetToolbarB1,KEmpty);
  1092             PublishImageL(NULL,EMusicWidgetToolbarB2,KEmpty);
  1090             PublishImageL(NULL,EMusicWidgetToolbarB2,KEmpty);
  1093             PublishImageL(NULL,EMusicWidgetToolbarB3,KEmpty);
  1091             PublishImageL(NULL,EMusicWidgetToolbarB3,KEmpty);
  1094             InstallEmptyActionL(EMusicWidgetTB1Trigger);
  1092             InstallEmptyActionL(EMusicWidgetTB1Trigger);
  1095             InstallEmptyActionL(EMusicWidgetTB2Trigger);
  1093             InstallEmptyActionL(EMusicWidgetTB2Trigger);
  1096             InstallEmptyActionL(EMusicWidgetTB3Trigger);
  1094             InstallEmptyActionL(EMusicWidgetTB3Trigger);
  1097             PublishTextL( NULL,EMusicWidgetDefaultText, iGoToMusicBuffer->Des() );
  1095             PublishTextL( NULL,EMusicWidgetDefaultText, iGoToMusicBuffer->Des() );
  1098 			InstallGoToAlbumL( EMusicWidgetTrigger2 );
  1096             InstallGoToAlbumL( EMusicWidgetTrigger2 );
  1099             }
  1097             }
  1100         else
  1098         else
  1101             {
  1099             {
  1102             delete iInstanceId;
  1100             delete iInstanceId;
  1103             iInstanceId = NULL;
  1101             iInstanceId = NULL;
  1104             iInstanceId = aContentId.AllocL();
  1102             iInstanceId = aContentId.AllocL();
  1105             }
  1103             }
  1106         }
  1104         }
  1107     else if ( aTrigger ==  KMyDeActive)
  1105     else if ( aTrigger ==  KMyDeActive && iWidgetActivated)
  1108         {
  1106         {
       
  1107         iWidgetActivated = EFalse;
  1109         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL deactivate");
  1108         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL deactivate");
  1110         //Removing al the CPS entrys to prevent flicker of old text and unwanted images (old/expired handles).
  1109         //Removing al the CPS entrys to prevent flicker of old text and unwanted images (old/expired handles).
  1111         RemoveL( EMusicWidgetImage1 );
  1110         RemoveL( EMusicWidgetImage1 );
  1112         RemoveL( EMusicWidgetText1 );
  1111         RemoveL( EMusicWidgetText1 );
  1113         RemoveL( EMusicWidgetToolbarB1 );
  1112         RemoveL( EMusicWidgetToolbarB1 );
  1114         RemoveL( EMusicWidgetToolbarB2 );
  1113         RemoveL( EMusicWidgetToolbarB2 );
  1115         RemoveL( EMusicWidgetToolbarB3 );
  1114         RemoveL( EMusicWidgetToolbarB3 );
  1116         RemoveL( EMusicWidgetDefaultText );
  1115         RemoveL( EMusicWidgetDefaultText );
  1117         }
  1116         }
  1118     else if ( aTrigger ==  KMySuspend)
  1117     else if ( aTrigger ==  KMySuspend && iWidgetActivated && iWidgetForeground)
  1119         {
  1118         {
  1120         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL suspend");
  1119         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL suspend");
  1121         iIsPublisherActive = EFalse;
  1120         iWidgetForeground = EFalse;
  1122         }
  1121         }
  1123     else if ( aTrigger ==  KMyResume)
  1122     else if ( aTrigger ==  KMyResume && iWidgetActivated && !iWidgetForeground)
  1124         {
  1123         {
  1125         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL resume");
  1124         MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL resume");
  1126         iIsPublisherActive = ETrue;
  1125         iWidgetForeground = ETrue;
  1127         DoPublishL();
  1126         DoPublishL();
  1128         }
  1127         }
  1129     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL --->");
  1128     MPX_DEBUG1("CMusicContentPublisher::HandlePublisherNotificationL --->");
  1130     }
  1129     }
  1131 
  1130