qtinternetradio/ui/src/irnowplayingview.cpp
changeset 15 065198191975
parent 14 896e9dbc5f19
child 16 5723da102db1
equal deleted inserted replaced
14:896e9dbc5f19 15:065198191975
    28 #ifdef NOWPLAYING_VIEW_OPTION_B
    28 #ifdef NOWPLAYING_VIEW_OPTION_B
    29 #include <hbframedrawer.h>
    29 #include <hbframedrawer.h>
    30 #include <hbframeitem.h>
    30 #include <hbframeitem.h>
    31 #endif
    31 #endif
    32 
    32 
    33 #ifdef STATISTIC_REPORT_TEST_ENABLED
       
    34 #include <hbmenu.h>
       
    35 #endif
       
    36     
       
    37 #include "irviewmanager.h"
    33 #include "irviewmanager.h"
    38 #include "irapplication.h"
    34 #include "irapplication.h"
    39 #include "irplaycontroller.h"
    35 #include "irplaycontroller.h"
    40 #include "irqisdsdatastructure.h"
    36 #include "irqisdsdatastructure.h"
    41 #include "irqmetadata.h"
    37 #include "irqmetadata.h"
    75 
    71 
    76 #ifdef NOWPLAYING_VIEW_OPTION_B
    72 #ifdef NOWPLAYING_VIEW_OPTION_B
    77 static const QString KLcdGraphics("qtg_fr_lcd");
    73 static const QString KLcdGraphics("qtg_fr_lcd");
    78 #endif
    74 #endif
    79 
    75 
       
    76 #ifdef STATISTIC_REPORT_TEST_ENABLED    
       
    77 static const int KDummySongRecognitionUid = 0xE4EF7D71;
       
    78 static const int KDummyMusicStoreUid = 0xE609761B;
       
    79 #endif
    80 
    80 
    81 static void saveStationLogo(const QPixmap &aStationLogo);
    81 static void saveStationLogo(const QPixmap &aStationLogo);
    82 
    82 
    83 /*
    83 /*
    84  * Description : constructor
    84  * Description : constructor
    86 IRNowPlayingView::IRNowPlayingView(IRApplication* aApplication, TIRViewId aViewId) :
    86 IRNowPlayingView::IRNowPlayingView(IRApplication* aApplication, TIRViewId aViewId) :
    87     IRBaseView(aApplication, aViewId),
    87     IRBaseView(aApplication, aViewId),
    88     iStatisticsReporter(NULL),
    88     iStatisticsReporter(NULL),
    89     iStationShare(NULL),
    89     iStationShare(NULL),
    90     iPlayStopAction(NULL),
    90     iPlayStopAction(NULL),
    91     iLaunchActionNeeded(false),
       
    92     iLogoDownloadState(EIdle),    
    91     iLogoDownloadState(EIdle),    
    93     iSongNameLabel(NULL),
    92     iSongNameLabel(NULL),
    94     iSongNameMarquee(NULL),
    93     iSongNameMarquee(NULL),
    95     iArtistName(NULL),
    94     iArtistName(NULL),
    96     iStationName(NULL),
    95     iStationName(NULL),
   103     ,iAdvImageNeedUpdate(true)
   102     ,iAdvImageNeedUpdate(true)
   104     ,iAdvUrl(KDefaultAdvLink)    
   103     ,iAdvUrl(KDefaultAdvLink)    
   105 #endif
   104 #endif
   106 {
   105 {
   107     LOG_METHOD;
   106     LOG_METHOD;
       
   107     
       
   108     iLaunchActionNeeded = (0 == getViewManager()->views().count()); // this is the starting view
       
   109         
   108     initialize();
   110     initialize();
   109     
   111     
   110     //if this view is not starting view, finish all initialization in constructor
   112     iStatisticsReporter = IRQStatisticsReporter::openInstance();
   111     if (getViewManager()->views().count() > 0)
   113         
   112     {
   114     connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(updateMetaData(IRQMetaData*)));
   113         normalInit();
   115     connect(iPlayController, SIGNAL(playingStarted()), this, SLOT(handlePlayStarted()));
   114     }
   116     connect(iPlayController, SIGNAL(playingStopped()), this, SLOT(handlePlayStopped()));
       
   117 
       
   118     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
       
   119             this, SLOT(handleNetworkEvent(IRQNetworkEvent)));
       
   120     connect(iApplication->getMediaKeyObserver(), SIGNAL(playPausePressed()), 
       
   121             this, SLOT(handlePlayPauseMediaKey()));
       
   122     connect(iApplication->getMediaKeyObserver(), SIGNAL(stopPressed()), 
       
   123             this, SLOT(handleStopMediaKey()));
       
   124     connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ),
       
   125              this, SLOT( handleOrientationChanged(Qt::Orientation) ) );
   115     
   126     
   116     setFlag(EViewFlag_StickyViewEnabled);
   127     setFlag(EViewFlag_StickyViewEnabled);
   117 }
   128 }
   118 
   129 
   119 /*
   130 /*
   148     initMenu();
   159     initMenu();
   149     initToolBar();
   160     initToolBar();
   150     initWidget();    
   161     initWidget();    
   151 #ifdef SUBTITLE_STR_BY_LOCID
   162 #ifdef SUBTITLE_STR_BY_LOCID
   152     setTitle(hbTrId("txt_irad_title_internet_radio"));
   163     setTitle(hbTrId("txt_irad_title_internet_radio"));
   153          
       
   154 #else
   164 #else
   155     setTitle("Internet radio");      
   165     setTitle("Internet radio");      
   156 #endif
   166 #endif
       
   167     handleOrientationChanged(getViewManager()->orientation());
   157 }
   168 }
   158 
   169 
   159 /*
   170 /*
   160  * Description : create menu for now playing view
   171  * Description : create menu for now playing view
   161  */
   172  */
   190 
   201 
   191     connect(openWebAddressAction, SIGNAL(triggered()), this, SLOT(handleGoToStationAction()));
   202     connect(openWebAddressAction, SIGNAL(triggered()), this, SLOT(handleGoToStationAction()));
   192     connect(shareStationAction, SIGNAL(triggered()), this, SLOT(handleShareStationAction()));
   203     connect(shareStationAction, SIGNAL(triggered()), this, SLOT(handleShareStationAction()));
   193     connect(settings, SIGNAL(triggered()), this, SLOT(handleSettingAction()));
   204     connect(settings, SIGNAL(triggered()), this, SLOT(handleSettingAction()));
   194     connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit()));  
   205     connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit()));  
   195     connect(songRecAction, SIGNAL(triggered()), this, SLOT(handleIdentifySongAction()));    
   206     connect(songRecAction, SIGNAL(triggered()), this, SLOT(handleIdentifySongAction()));
   196     
       
   197 #ifdef STATISTIC_REPORT_TEST_ENABLED
       
   198     HbAction *dummySongIdentifyAction = menu()->addAction("Dummy Identify Song");
       
   199     HbAction *dummyGoToNmsAction = menu()->addAction("Dummy Go to Music Store");
       
   200     HbAction *dummyFindInNmsAction = menu()->addAction("Dummy Find in Music Store");
       
   201     
       
   202     connect(dummySongIdentifyAction, SIGNAL(triggered()), this, SLOT(handleDummySongIdentify()));   
       
   203     connect(dummyGoToNmsAction, SIGNAL(triggered()), this, SLOT(handleDummyGoToNms()));
       
   204     connect(dummyFindInNmsAction, SIGNAL(triggered()), this, SLOT(handleDummyFindInNms()));    
       
   205 #endif
       
   206 }
   207 }
   207 
   208 
   208 /*
   209 /*
   209  * Description : create tool bar for now playing view
   210  * Description : create tool bar for now playing view
   210  */
   211  */
   234     iStationLogo->setIcon(HbIcon(KDefaultStationLogo));   
   235     iStationLogo->setIcon(HbIcon(KDefaultStationLogo));   
   235     iStationName->setPlainText("");
   236     iStationName->setPlainText("");
   236     updateSongName(QString(""));
   237     updateSongName(QString(""));
   237     iArtistName->setPlainText("");    
   238     iArtistName->setPlainText("");    
   238     
   239     
       
   240     connect(iSongNameLabel, SIGNAL(geometryChanged()), this, SLOT(handleGeometryChanged()));
       
   241     
   239     iArtistName->setTextColor(HbColorScheme::color(KArtistColor));
   242     iArtistName->setTextColor(HbColorScheme::color(KArtistColor));
   240     iSongNameLabel->setTextColor(HbColorScheme::color(KSongColor));
   243     iSongNameLabel->setTextColor(HbColorScheme::color(KSongColor));
   241     iSongNameMarquee->setTextColor(HbColorScheme::color(KSongColor));
   244     iSongNameMarquee->setTextColor(HbColorScheme::color(KSongColor));
   242     iStationName->setTextColor(HbColorScheme::color(KStationColor));
   245     iStationName->setTextColor(HbColorScheme::color(KStationColor));
   243     
   246     
   394  */
   397  */
   395 TIRHandleResult IRNowPlayingView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason)
   398 TIRHandleResult IRNowPlayingView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason)
   396 {
   399 {
   397     LOG_METHOD;
   400     LOG_METHOD;
   398 	LOG_FORMAT("aCommand = %d", (int)aCommand);
   401 	LOG_FORMAT("aCommand = %d", (int)aCommand);
   399     if (!initCompleted())
       
   400     {
       
   401         return EIR_NoDefault;
       
   402     }
       
   403     
   402     
   404     Q_UNUSED(aReason);
   403     Q_UNUSED(aReason);
   405     TIRHandleResult ret = EIR_DoDefault;
   404     TIRHandleResult ret = EIR_DoDefault;
   406 
   405 
   407     switch (aCommand)
   406     switch (aCommand)
   458     }
   457     }
   459     
   458     
   460     iLaunchActionNeeded = false;
   459     iLaunchActionNeeded = false;
   461 }
   460 }
   462 
   461 
   463 void IRNowPlayingView::lazyInit()
       
   464 {
       
   465     LOG_METHOD;
       
   466     iLaunchActionNeeded = true;
       
   467     
       
   468     if (!initCompleted())
       
   469     {       
       
   470         normalInit();
       
   471         
       
   472         //initization from handleCommand()
       
   473         handleCommand(EIR_ViewCommand_TOBEACTIVATED, EIR_ViewCommandReason_Show);
       
   474         handleCommand(EIR_ViewCommand_ACTIVATED, EIR_ViewCommandReason_Show);
       
   475         
       
   476         emit applicationReady();
       
   477     }
       
   478 }
       
   479 
       
   480 void IRNowPlayingView::normalInit()
       
   481 {
       
   482     LOG_METHOD;
       
   483     if (!initCompleted())
       
   484     {
       
   485         IRBaseView::lazyInit();
       
   486         
       
   487         iStatisticsReporter = IRQStatisticsReporter::openInstance();
       
   488             
       
   489         connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(updateMetaData(IRQMetaData*)));
       
   490         connect(iPlayController, SIGNAL(playingStarted()), this, SLOT(handlePlayStarted()));
       
   491         connect(iPlayController, SIGNAL(playingStopped()), this, SLOT(handlePlayStopped()));
       
   492 
       
   493         connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
       
   494                 this, SLOT(handleNetworkEvent(IRQNetworkEvent)));
       
   495         connect(iApplication->getMediaKeyObserver(), SIGNAL(playPausePressed()), 
       
   496                 this, SLOT(handlePlayPauseMediaKey()));
       
   497         connect(iApplication->getMediaKeyObserver(), SIGNAL(stopPressed()), 
       
   498                 this, SLOT(handleStopMediaKey()));
       
   499         connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ),
       
   500                  this, SLOT( handleOrientationChanged(Qt::Orientation) ) );
       
   501         
       
   502         setInitCompleted(true);
       
   503     }
       
   504 }
       
   505 
   462 
   506 void IRNowPlayingView::updateForLauchAction()
   463 void IRNowPlayingView::updateForLauchAction()
   507 {
   464 {
   508     LOG_METHOD;
   465     LOG_METHOD;
   509     //nowplaying view as starting view can have two cases : one is for last played station, the other is for 
   466     //nowplaying view as starting view can have two cases : one is for last played station, the other is for 
   707         LOG("load landscape layout");
   664         LOG("load landscape layout");
   708         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, LANDSCAPE_SEC);      
   665         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, LANDSCAPE_SEC);      
   709     }
   666     }
   710     // re-load only update the size of the widget, the rect of the widget will get updated only after re-layout.
   667     // re-load only update the size of the widget, the rect of the widget will get updated only after re-layout.
   711     updateGeometry();
   668     updateGeometry();
   712     QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
   669 }
   713     // re-select between label and marquee.
   670 
       
   671 void IRNowPlayingView::handleGeometryChanged()
       
   672 {
       
   673     LOG_METHOD;
   714     updateSongName(iSongNameLabel->plainText());
   674     updateSongName(iSongNameLabel->plainText());
   715 }
   675 }
   716 
   676 
   717 /********************************************************************************************************
   677 /********************************************************************************************************
   718  * SLOT for Play Controller
   678  * SLOT for Play Controller
   775  *******************************************************************************************************
   735  *******************************************************************************************************
   776  */
   736  */
   777 void IRNowPlayingView::handleMusicStoreAction()
   737 void IRNowPlayingView::handleMusicStoreAction()
   778 {
   738 {
   779     LOG_METHOD;
   739     LOG_METHOD;
       
   740    
   780     if(!iFindinNmsAllowed)
   741     if(!iFindinNmsAllowed)
   781     {
   742     {
       
   743 #ifdef STATISTIC_REPORT_TEST_ENABLED    
       
   744     if(IRQUtility::launchAppByUid(KDummyMusicStoreUid))
       
   745     {
       
   746         iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsLaunch,iPlayController->getNowPlayingPreset()->presetId);
       
   747     }
       
   748 #else // STATISTIC_REPORT_TEST_ENABLED
   782 #ifdef SUBTITLE_STR_BY_LOCID
   749 #ifdef SUBTITLE_STR_BY_LOCID
   783         popupNote(hbTrId("txt_irad_info_not_allowed_by_this_station"), HbMessageBox::MessageTypeInformation);
   750         popupNote(hbTrId("txt_irad_info_not_allowed_by_this_station"), HbMessageBox::MessageTypeInformation);
   784 #else
   751 #else  // SUBTITLE_STR_BY_LOCID
   785         popupNote(hbTrId("Not allowed by station"), HbMessageBox::MessageTypeInformation);        
   752         popupNote(hbTrId("Not allowed by station"), HbMessageBox::MessageTypeInformation);        
   786 #endif
   753 #endif // SUBTITLE_STR_BY_LOCID
       
   754 #endif // STATISTIC_REPORT_TEST_ENABLED        
   787         return;        
   755         return;        
   788     }
   756     }
   789     
   757     
   790     if(!iSongNameAvailable)
   758     if(!iSongNameAvailable)
   791     {
   759     {
       
   760 #ifdef STATISTIC_REPORT_TEST_ENABLED    
       
   761     if(IRQUtility::launchAppByUid(KDummyMusicStoreUid))
       
   762     {
       
   763         iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsLaunch,iPlayController->getNowPlayingPreset()->presetId);
       
   764     }
       
   765 #else // STATISTIC_REPORT_TEST_ENABLED        
   792 #ifdef SUBTITLE_STR_BY_LOCID
   766 #ifdef SUBTITLE_STR_BY_LOCID
   793         popupNote(hbTrId("txt_irad_info_no_song_info"), HbMessageBox::MessageTypeInformation);
   767         popupNote(hbTrId("txt_irad_info_no_song_info"), HbMessageBox::MessageTypeInformation);
   794 #else
   768 #else // SUBTITLE_STR_BY_LOCID
   795         popupNote(hbTrId("No song info"), HbMessageBox::MessageTypeInformation);        
   769         popupNote(hbTrId("No song info"), HbMessageBox::MessageTypeInformation);        
   796 #endif        
   770 #endif // SUBTITLE_STR_BY_LOCID
       
   771 #endif // STATISTIC_REPORT_TEST_ENABLED        
   797         return;        
   772         return;        
   798     }
   773     }
   799     
   774     
   800     // Need to log the find song in NMS event, iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsFind,channelId); 
   775 #ifdef STATISTIC_REPORT_TEST_ENABLED    
       
   776     if(IRQUtility::launchAppByUid(KDummyMusicStoreUid))
       
   777     {
       
   778         iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsFind,iPlayController->getNowPlayingPreset()->presetId);
       
   779     }
       
   780 #else // STATISTIC_REPORT_TEST_ENABLED     
   801 #ifdef SUBTITLE_STR_BY_LOCID
   781 #ifdef SUBTITLE_STR_BY_LOCID
   802     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
   782     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
       
   783 #else  // SUBTITLE_STR_BY_LOCID
       
   784     popupNote(hbTrId("Music store not ready"), HbMessageBox::MessageTypeInformation);    
       
   785 #endif // SUBTITLE_STR_BY_LOCID
       
   786 #endif // STATISTIC_REPORT_TEST_ENABLED 
       
   787 }
       
   788 
       
   789 void IRNowPlayingView::handleIdentifySongAction()
       
   790 {
       
   791     LOG_METHOD;
       
   792 #ifdef STATISTIC_REPORT_TEST_ENABLED    
       
   793     if(IRQUtility::launchAppByUid(KDummySongRecognitionUid))
   803 #else
   794 #else
   804     popupNote(hbTrId("Music store not ready"), HbMessageBox::MessageTypeInformation);    
       
   805 #endif
       
   806 }
       
   807 
       
   808 void IRNowPlayingView::handleIdentifySongAction()
       
   809 {
       
   810     LOG_METHOD;
       
   811     if(IRQUtility::launchAppByUid(iSettings->getSongRecognitionAppUid()))
   795     if(IRQUtility::launchAppByUid(iSettings->getSongRecognitionAppUid()))
   812     {
   796 #endif         
       
   797     {       
   813         iStatisticsReporter->logSongRecogEvent();
   798         iStatisticsReporter->logSongRecogEvent();
   814     }
   799     }
   815 }
   800 }
   816 
   801 
   817 
   802 
   942 {
   927 {
   943     LOG_METHOD_ENTER;
   928     LOG_METHOD_ENTER;
   944     IRQUtility::openAdvLink(iAdvUrl);
   929     IRQUtility::openAdvLink(iAdvUrl);
   945 }
   930 }
   946 #endif
   931 #endif
   947 
   932    
   948 #ifdef STATISTIC_REPORT_TEST_ENABLED
       
   949 void IRNowPlayingView::handleDummySongIdentify()
       
   950 {
       
   951     iStatisticsReporter->logSongRecogEvent();   
       
   952     popupNote("Identify Song ...", HbMessageBox::MessageTypeInformation);
       
   953 }
       
   954 
       
   955 void IRNowPlayingView::handleDummyGoToNms()
       
   956 {
       
   957     iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsLaunch,iPlayController->getNowPlayingPreset()->presetId);     
       
   958     popupNote("Go to Music Store ...", HbMessageBox::MessageTypeInformation);
       
   959 }
       
   960 
       
   961 void IRNowPlayingView::handleDummyFindInNms()
       
   962 {
       
   963     iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsFind,iPlayController->getNowPlayingPreset()->presetId);  
       
   964     popupNote("Find in Music Store ...", HbMessageBox::MessageTypeInformation);
       
   965 }
       
   966 
       
   967 #endif
       
   968     
       
   969 void IRNowPlayingView::loadStationLogo()
   933 void IRNowPlayingView::loadStationLogo()
   970 {
   934 {
   971     LOG_METHOD;
   935     LOG_METHOD;
   972     if (iPlayController->isStationLogoAvailable())    
   936     if (iPlayController->isStationLogoAvailable())    
   973     { 
   937     {