qtinternetradio/ui/src/irnowplayingview.cpp
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 #include <hbtoolbar.h>
       
    18 #include <QPixmap>
    17 #include <QPixmap>
    19 #include <hbaction.h>
    18 #include <hbaction.h>
    20 #include <hblabel.h>
    19 #include <hblabel.h>
       
    20 #include <hbmarqueeitem.h>
    21 #include <hbnotificationdialog.h>
    21 #include <hbnotificationdialog.h>
    22 #include <QSettings>
    22 #include <QSettings>
       
    23 #include <QFontMetricsF>
       
    24 #include <QCoreApplication>
       
    25 #include <HbColorScheme>
       
    26 #include <HbEvent>
    23 
    27 
    24 #ifdef NOWPLAYING_VIEW_OPTION_B
    28 #ifdef NOWPLAYING_VIEW_OPTION_B
    25 #include <hbframedrawer.h>
    29 #include <hbframedrawer.h>
    26 #include <hbframeitem.h>
    30 #include <hbframeitem.h>
    27 #endif
    31 #endif
    28 
    32 
    29 
    33 #ifdef STATISTIC_REPORT_TEST_ENABLED
       
    34 #include <hbmenu.h>
       
    35 #endif
       
    36     
    30 #include "irviewmanager.h"
    37 #include "irviewmanager.h"
    31 #include "irapplication.h"
    38 #include "irapplication.h"
    32 #include "irplaycontroller.h"
    39 #include "irplaycontroller.h"
    33 #include "irqisdsdatastructure.h"
    40 #include "irqisdsdatastructure.h"
    34 #include "irqmetadata.h"
    41 #include "irqmetadata.h"
    45 #include "irqutility.h"
    52 #include "irqutility.h"
    46 #include "irqlogger.h"
    53 #include "irqlogger.h"
    47 #include "irplaylist.h"
    54 #include "irplaylist.h"
    48 #include "irstationdetailsview.h"
    55 #include "irstationdetailsview.h"
    49 #include "irservicedef.h"
    56 #include "irservicedef.h"
       
    57 #include "irqsettings.h"
       
    58 #include "irqlogger.h"
    50 
    59 
    51 #ifdef ADV_ENABLED
    60 #ifdef ADV_ENABLED
    52 #include <QTimer>
    61 #include <QTimer>
    53 #include <qgraphicssceneevent.h>
    62 #include <qgraphicssceneevent.h>
    54 static const QString KDefaultAdvLink(""); // default advertisement link
    63 static const QString KDefaultAdvLink(""); // default advertisement link
    55 #endif
    64 #endif
    56 
    65 
    57 const int KNowPlayingLogoSize = 300; // Now playing logo size
    66 const int KNowPlayingLogoSize = 300; // Now playing logo size
       
    67 
    58 static const QString KDefaultStationLogo("qtg_large_internet_radio");
    68 static const QString KDefaultStationLogo("qtg_large_internet_radio");
    59 static const QString KPlayButtonIcon("qtg_mono_play");
    69 static const QString KPlayButtonIcon("qtg_mono_play");
    60 static const QString KStopButtonIcon("qtg_mono_stop");
    70 static const QString KStopButtonIcon("qtg_mono_stop");
       
    71 
       
    72 static const QString KArtistColor("qtc_lcd_content_normal");
       
    73 static const QString KSongColor("qtc_lcd_content_normal");
       
    74 static const QString KStationColor("qtc_lcd_content_normal");
    61 
    75 
    62 #ifdef NOWPLAYING_VIEW_OPTION_B
    76 #ifdef NOWPLAYING_VIEW_OPTION_B
    63 static const QString KLcdGraphics("qtg_fr_lcd");
    77 static const QString KLcdGraphics("qtg_fr_lcd");
    64 #endif
    78 #endif
    65 
    79 
    74     iStatisticsReporter(NULL),
    88     iStatisticsReporter(NULL),
    75     iStationShare(NULL),
    89     iStationShare(NULL),
    76     iPlayStopAction(NULL),
    90     iPlayStopAction(NULL),
    77     iLaunchActionNeeded(false),
    91     iLaunchActionNeeded(false),
    78     iLogoDownloadState(EIdle),    
    92     iLogoDownloadState(EIdle),    
    79     iSongName(NULL),
    93     iSongNameLabel(NULL),
       
    94     iSongNameMarquee(NULL),
    80     iArtistName(NULL),
    95     iArtistName(NULL),
    81     iStationName(NULL),
    96     iStationName(NULL),
    82     iStationLogo(NULL),
    97     iStationLogo(NULL),
    83     iLogoNeedUpdate(true),    
    98     iLogoNeedUpdate(true),    
    84     iFindinNmsAllowed(false),
    99     iFindinNmsAllowed(false),
    87     ,iAdvImage(NULL)
   102     ,iAdvImage(NULL)
    88     ,iAdvImageNeedUpdate(true)
   103     ,iAdvImageNeedUpdate(true)
    89     ,iAdvUrl(KDefaultAdvLink)    
   104     ,iAdvUrl(KDefaultAdvLink)    
    90 #endif
   105 #endif
    91 {
   106 {
       
   107     LOG_METHOD;
    92     initialize();
   108     initialize();
    93     
   109     
    94     //if this view is not starting view, finish all initialization in constructor
   110     //if this view is not starting view, finish all initialization in constructor
    95     if (getViewManager()->views().count() > 0)
   111     if (getViewManager()->views().count() > 0)
    96     {
   112     {
   103 /*
   119 /*
   104  * Description : destructor
   120  * Description : destructor
   105  */
   121  */
   106 IRNowPlayingView::~IRNowPlayingView()
   122 IRNowPlayingView::~IRNowPlayingView()
   107 {
   123 {
       
   124     LOG_METHOD;
   108     if (iStatisticsReporter)
   125     if (iStatisticsReporter)
   109     {
   126     {
   110         iStatisticsReporter->closeInstance();
   127         iStatisticsReporter->closeInstance();
   111     }
   128     }
   112     
   129     
   117 /*
   134 /*
   118  * Description: initializing.
   135  * Description: initializing.
   119  */
   136  */
   120 void IRNowPlayingView::initialize()
   137 void IRNowPlayingView::initialize()
   121 {
   138 {
       
   139     LOG_METHOD;
   122     setObjectName(NOW_PLAYING_VIEW_OBJECT_NAME);
   140     setObjectName(NOW_PLAYING_VIEW_OBJECT_NAME);
   123     QObjectList roots;
   141     QObjectList roots;
   124     roots.append(this);
   142     roots.append(this);
   125     iLoader.setObjectTree(roots);
   143     iLoader.setObjectTree(roots);
   126 
   144 
   128     iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME);
   146     iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME);
   129     
   147     
   130     initMenu();
   148     initMenu();
   131     initToolBar();
   149     initToolBar();
   132     initWidget();    
   150     initWidget();    
       
   151 #ifdef SUBTITLE_STR_BY_LOCID
       
   152     setTitle(hbTrId("txt_irad_title_internet_radio"));
       
   153          
       
   154 #else
       
   155     setTitle("Internet radio");      
       
   156 #endif
   133 }
   157 }
   134 
   158 
   135 /*
   159 /*
   136  * Description : create menu for now playing view
   160  * Description : create menu for now playing view
   137  */
   161  */
   138 void IRNowPlayingView::initMenu()
   162 void IRNowPlayingView::initMenu()
   139 {
   163 {
   140 #ifdef SONGRECOGNITION_ENABLED  
   164     LOG_METHOD;
   141     if(IRQUtility::identifySongAvailable())
   165     if (iApplication->getSettings()->getIdentifySongEnabled())
   142     {
   166     {
   143         LOG("Song Recognition is Available");
   167         int songRecognitionAppUid = iApplication->getSettings()->getSongRecognitionAppUid();
   144         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_YES_SEC);
   168         if(IRQUtility::findAppByUid(songRecognitionAppUid))
       
   169         {
       
   170             LOG("Song Recognition is Available");
       
   171             iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_YES_SEC);
       
   172         }
       
   173         else
       
   174         {
       
   175             LOG("Song Recognition is NOT Available");
       
   176             iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_NO_SEC);
       
   177         }
   145     }
   178     }
   146     else
   179     else
   147     {
   180     {
   148         LOG("Song Recognition is NOT Available");
   181         LOG("Song Recognition is Disabled");
   149         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_NO_SEC);
   182         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_NO_SEC);
   150     }
   183     }
   151 #else
   184     
   152     LOG("Song Recognition is Disabled");
       
   153     iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, NOW_PLAYING_VIEW_SONG_RECOG_NO_SEC);
       
   154 #endif    
       
   155     HbAction *openWebAddressAction = qobject_cast<HbAction *> (iLoader.findObject(GO_TO_STATION_ACTION));
   185     HbAction *openWebAddressAction = qobject_cast<HbAction *> (iLoader.findObject(GO_TO_STATION_ACTION));
   156     HbAction *shareStationAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_SHARE_STATION_ACTION));
   186     HbAction *shareStationAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_SHARE_STATION_ACTION));
   157     HbAction *settings = qobject_cast<HbAction *> (iLoader.findObject(SETTINGS_ACTION));
   187     HbAction *settings = qobject_cast<HbAction *> (iLoader.findObject(SETTINGS_ACTION));
   158     HbAction *exitAction = qobject_cast<HbAction *> (iLoader.findObject(EXIT_ACTION));
   188     HbAction *exitAction = qobject_cast<HbAction *> (iLoader.findObject(EXIT_ACTION));
   159     HbAction *songRecAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_IDENTIFYSONG));
   189     HbAction *songRecAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_IDENTIFYSONG));
   161     connect(openWebAddressAction, SIGNAL(triggered()), this, SLOT(handleGoToStationAction()));
   191     connect(openWebAddressAction, SIGNAL(triggered()), this, SLOT(handleGoToStationAction()));
   162     connect(shareStationAction, SIGNAL(triggered()), this, SLOT(handleShareStationAction()));
   192     connect(shareStationAction, SIGNAL(triggered()), this, SLOT(handleShareStationAction()));
   163     connect(settings, SIGNAL(triggered()), this, SLOT(handleSettingAction()));
   193     connect(settings, SIGNAL(triggered()), this, SLOT(handleSettingAction()));
   164     connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit()));  
   194     connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit()));  
   165     connect(songRecAction, SIGNAL(triggered()), this, SLOT(handleIdentifySongAction()));    
   195     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
   166 }
   206 }
   167 
   207 
   168 /*
   208 /*
   169  * Description : create tool bar for now playing view
   209  * Description : create tool bar for now playing view
   170  */
   210  */
   171 void IRNowPlayingView::initToolBar()
   211 void IRNowPlayingView::initToolBar()
   172 {
   212 {
       
   213     LOG_METHOD;
   173     HbAction *musicStoreAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_MUSICSTORE));
   214     HbAction *musicStoreAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_MUSICSTORE));
   174     iPlayStopAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_PLAYSTOP));
   215     iPlayStopAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_PLAYSTOP));
   175     HbAction *add2FavAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_ADDTOFAV));
   216     HbAction *add2FavAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_ADDTOFAV));
   176     HbAction *flipAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_FLIP));
   217     HbAction *flipAction = qobject_cast<HbAction *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_FLIP));
   177 
   218 
   178     connect(musicStoreAction, SIGNAL(triggered()), this, SLOT(handleMusicStoreAction()));
   219     connect(musicStoreAction, SIGNAL(triggered()), this, SLOT(handleMusicStoreAction()));
   179     connect(iPlayStopAction, SIGNAL(triggered()), this, SLOT(handlePlayStopAction()));
   220     connect(iPlayStopAction, SIGNAL(triggered()), this, SLOT(handlePlayStopAction()));
   180     connect(add2FavAction, SIGNAL(triggered()), this, SLOT(handleAddToFavAction()));
   221     connect(add2FavAction, SIGNAL(triggered()), this, SLOT(handleAddToFavAction()));
   181     connect(flipAction, SIGNAL(triggered()), this, SLOT(handleDetailInfoAction()));
   222     connect(flipAction, SIGNAL(triggered()), this, SLOT(handleDetailInfoAction()));
   182     
       
   183     //could be removed after toolbar issue is ok
       
   184     HbToolBar *viewToolBar = toolBar();
       
   185     viewToolBar->addAction(musicStoreAction);
       
   186     viewToolBar->addAction(iPlayStopAction);
       
   187     viewToolBar->addAction(add2FavAction);
       
   188     viewToolBar->addAction(flipAction);
       
   189 }
   223 }
   190 
   224 
   191 void IRNowPlayingView::initWidget()
   225 void IRNowPlayingView::initWidget()
   192 {
   226 {
       
   227     LOG_METHOD;
   193     iStationLogo = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_STATION_LOGO));
   228     iStationLogo = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_STATION_LOGO));
   194     iSongName = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_SONG_NAME));
   229     iSongNameLabel = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_SONG_NAME_LABEL));
       
   230     iSongNameMarquee = qobject_cast<HbMarqueeItem *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_SONG_NAME_MARQUEE));
       
   231     iSongNameMarquee->setLoopCount(-1);
   195     iArtistName = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_ARTIST_NAME));
   232     iArtistName = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_ARTIST_NAME));
   196     iStationName = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_STATION_NAME));   
   233     iStationName = qobject_cast<HbLabel *> (iLoader.findObject(NOW_PLAYING_VIEW_OBJECT_STATION_NAME));   
   197     iStationLogo->setIcon(HbIcon(KDefaultStationLogo));   
   234     iStationLogo->setIcon(HbIcon(KDefaultStationLogo));   
   198     iStationName->setPlainText("");
   235     iStationName->setPlainText("");
   199     iSongName->setPlainText("");
   236     updateSongName(QString(""));
   200     iArtistName->setPlainText("");    
   237     iArtistName->setPlainText("");    
       
   238     
       
   239     iArtistName->setTextColor(HbColorScheme::color(KArtistColor));
       
   240     iSongNameLabel->setTextColor(HbColorScheme::color(KSongColor));
       
   241     iSongNameMarquee->setTextColor(HbColorScheme::color(KSongColor));
       
   242     iStationName->setTextColor(HbColorScheme::color(KStationColor));
   201     
   243     
   202 #ifdef NOWPLAYING_VIEW_OPTION_B
   244 #ifdef NOWPLAYING_VIEW_OPTION_B
   203 	HbWidget * viewContainer = qobject_cast<HbWidget *> (iLoader.findObject(VIEW_CONTAINER));
   245 	HbWidget * viewContainer = qobject_cast<HbWidget *> (iLoader.findObject(VIEW_CONTAINER));
   204     HbFrameDrawer* drawer = new HbFrameDrawer(KLcdGraphics, HbFrameDrawer::NinePieces);
   246     HbFrameDrawer* drawer = new HbFrameDrawer(KLcdGraphics, HbFrameDrawer::NinePieces);
   205     HbFrameItem* backgroundItem = new HbFrameItem(drawer, viewContainer);
   247     HbFrameItem* backgroundItem = new HbFrameItem(drawer, viewContainer);
   218 /*
   260 /*
   219  * Description : update station name and category according to the information in preset
   261  * Description : update station name and category according to the information in preset
   220  */
   262  */
   221 void IRNowPlayingView::updateWidgets()
   263 void IRNowPlayingView::updateWidgets()
   222 {
   264 {
       
   265     LOG_METHOD;
   223     if (iLaunchActionNeeded) // if lunch as starting view, leave the update action to launchAction()
   266     if (iLaunchActionNeeded) // if lunch as starting view, leave the update action to launchAction()
   224     {
   267     {
   225         return;
   268         return;
   226     }
   269     }
   227     
   270     
   230         iStationName->setPlainText(iPlayController->getNowPlayingPreset()->name);
   273         iStationName->setPlainText(iPlayController->getNowPlayingPreset()->name);
   231     }
   274     }
   232     loadStationLogo();
   275     loadStationLogo();
   233 }
   276 }
   234 
   277 
       
   278 void IRNowPlayingView::updateSongName(const QString &aSongName)
       
   279 {
       
   280     LOG_METHOD;
       
   281     iSongNameMarquee->stopAnimation();	
       
   282     iSongNameLabel->hide();
       
   283     iSongNameMarquee->hide();
       
   284     
       
   285     iSongNameLabel->setPlainText(aSongName);
       
   286     iSongNameMarquee->setText(aSongName);
       
   287         
       
   288     QFontMetricsF metrics(iSongNameLabel->font());
       
   289     LOG_FORMAT("song name = %s, song name length = %f, label width = %f",
       
   290                 STRING2CHAR(aSongName), 
       
   291                 metrics.boundingRect(aSongName).width(),
       
   292                 iSongNameLabel->contentsRect().width()
       
   293                 );
       
   294     if (metrics.boundingRect(aSongName).width() > iSongNameLabel->contentsRect().width())
       
   295     {
       
   296         iSongNameMarquee->show();
       
   297         iSongNameMarquee->startAnimation();
       
   298     }
       
   299     else
       
   300     {
       
   301         iSongNameLabel->show();
       
   302     }
       
   303 }
       
   304 
   235 void IRNowPlayingView::updateMusicStoreStatus()
   305 void IRNowPlayingView::updateMusicStoreStatus()
   236 {
   306 {
       
   307     LOG_METHOD;
   237     IRQPreset *preset = iPlayController->getNowPlayingPreset();
   308     IRQPreset *preset = iPlayController->getNowPlayingPreset();
   238     if(preset && (0 == preset->musicStoreStatus.compare("yes",Qt::CaseInsensitive)))
   309     if(preset && (0 == preset->musicStoreStatus.compare("yes",Qt::CaseInsensitive)))
   239     {
   310     {
   240         iFindinNmsAllowed = true;
   311         iFindinNmsAllowed = true;
   241     }
   312     }
   249 /*
   320 /*
   250  * Description : Update logo info
   321  * Description : Update logo info
   251  */
   322  */
   252 void IRNowPlayingView::updateStationLogo()
   323 void IRNowPlayingView::updateStationLogo()
   253 {    
   324 {    
       
   325     LOG_METHOD;
   254     if( !iLogoNeedUpdate
   326     if( !iLogoNeedUpdate
   255         || iLogoDownloadState != EIdle )
   327         || iLogoDownloadState != EIdle )
   256     {
   328     {
   257         return;
   329         return;
   258     }
   330     }
   285 /*
   357 /*
   286  * Description : Update advertisement image
   358  * Description : Update advertisement image
   287  */
   359  */
   288 void IRNowPlayingView::updateAdvImage()
   360 void IRNowPlayingView::updateAdvImage()
   289 {
   361 {
       
   362     LOG_METHOD;
   290     if( !iAdvImageNeedUpdate
   363     if( !iAdvImageNeedUpdate
   291         || iLogoDownloadState != EIdle )
   364         || iLogoDownloadState != EIdle )
   292     {
   365     {
   293         return;
   366         return;
   294     }
   367     }
   319  * Return      : EIR_DoDefault : caller does default handling
   392  * Return      : EIR_DoDefault : caller does default handling
   320  *               EIR_NoDefault : caller doesn't do default handling
   393  *               EIR_NoDefault : caller doesn't do default handling
   321  */
   394  */
   322 TIRHandleResult IRNowPlayingView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason)
   395 TIRHandleResult IRNowPlayingView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason)
   323 {
   396 {
       
   397     LOG_METHOD;
       
   398 	LOG_FORMAT("aCommand = %d", (int)aCommand);
   324     if (!initCompleted())
   399     if (!initCompleted())
   325     {
   400     {
   326         return EIR_NoDefault;
   401         return EIR_NoDefault;
   327     }
   402     }
   328     
   403     
   364 /*
   439 /*
   365  * Description : actions when view is launched.
   440  * Description : actions when view is launched.
   366  */
   441  */
   367 void IRNowPlayingView::launchAction()
   442 void IRNowPlayingView::launchAction()
   368 {      
   443 {      
       
   444     LOG_METHOD;
   369     setUseNetworkReason(EIR_UseNetwork_StartingView);
   445     setUseNetworkReason(EIR_UseNetwork_StartingView);
   370     updateForLauchAction();
   446     updateForLauchAction();
   371 #ifdef HS_WIDGET_ENABLED	
   447 #ifdef HS_WIDGET_ENABLED	
   372     iPlayController->setConnectingStationName(iStationName->plainText());
   448     iPlayController->setConnectingStationName(iStationName->plainText());
   373 #endif	
   449 #endif	
   374     iApplication->verifyNetworkConnectivity();
   450     iApplication->verifyNetworkConnectivity();
   375     getViewManager()->pushViewById(EIRView_MainView);
   451     if( iApplication->isEmbeddedInstance())
       
   452     {
       
   453         getViewManager()->pushViewById(EIRView_PlsView);        
       
   454     }
       
   455     else
       
   456     {
       
   457         getViewManager()->pushViewById(EIRView_MainView);         
       
   458     }
       
   459     
   376     iLaunchActionNeeded = false;
   460     iLaunchActionNeeded = false;
   377 }
   461 }
   378 
   462 
   379 void IRNowPlayingView::lazyInit()
   463 void IRNowPlayingView::lazyInit()
   380 {
   464 {
       
   465     LOG_METHOD;
   381     iLaunchActionNeeded = true;
   466     iLaunchActionNeeded = true;
   382     
   467     
   383     if (!initCompleted())
   468     if (!initCompleted())
   384     {       
   469     {       
   385         normalInit();
   470         normalInit();
   386         
   471         
   387         //initization from handleCommand()
   472         //initization from handleCommand()
   388         handleCommand(EIR_ViewCommand_TOBEACTIVATED, EIR_ViewCommandReason_Show);
   473         handleCommand(EIR_ViewCommand_TOBEACTIVATED, EIR_ViewCommandReason_Show);
   389         handleCommand(EIR_ViewCommand_ACTIVATED, EIR_ViewCommandReason_Show);
   474         handleCommand(EIR_ViewCommand_ACTIVATED, EIR_ViewCommandReason_Show);
       
   475         
       
   476         emit applicationReady();
   390     }
   477     }
   391 }
   478 }
   392 
   479 
   393 void IRNowPlayingView::normalInit()
   480 void IRNowPlayingView::normalInit()
   394 {
   481 {
       
   482     LOG_METHOD;
   395     if (!initCompleted())
   483     if (!initCompleted())
   396     {
   484     {
   397         IRBaseView::lazyInit();
   485         IRBaseView::lazyInit();
   398         
   486         
   399         iStatisticsReporter = IRQStatisticsReporter::openInstance();
   487         iStatisticsReporter = IRQStatisticsReporter::openInstance();
   415     }
   503     }
   416 }
   504 }
   417 
   505 
   418 void IRNowPlayingView::updateForLauchAction()
   506 void IRNowPlayingView::updateForLauchAction()
   419 {
   507 {
       
   508     LOG_METHOD;
   420     //nowplaying view as starting view can have two cases : one is for last played station, the other is for 
   509     //nowplaying view as starting view can have two cases : one is for last played station, the other is for 
   421     //the only one item in play list file    
   510     //the only one item in play list file    
   422     IRPlayList *playList = iApplication->getPlayList();
   511     IRPlayList *playList = iApplication->getPlayList();
   423     if (playList && 1 == playList->getNumberOfEntries())
   512     if (playList && 1 == playList->getNumberOfEntries())
   424     {
   513     {
   438         delete preset;
   527         delete preset;
   439     }
   528     }
   440     else
   529     else
   441     {
   530     {
   442         IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();
   531         IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();
   443         IRQPreset *lastPreset = lastPlayedStationInfo->getLastPlayedStation();
   532         if( lastPlayedStationInfo )
   444         if (lastPreset)
       
   445         {
   533         {
   446             iStationName->setPlainText(lastPreset->name); 
   534             IRQPreset *lastPreset = lastPlayedStationInfo->getLastPlayedStation();
   447             iFindinNmsAllowed = (0 == lastPreset->musicStoreStatus.compare("yes",Qt::CaseInsensitive));
   535             if (lastPreset)
   448         }
   536             {
   449         else
   537                 iStationName->setPlainText(lastPreset->name); 
   450         {
   538                 iFindinNmsAllowed = (0 == lastPreset->musicStoreStatus.compare("yes",Qt::CaseInsensitive));
   451             iStationName->setPlainText(QString("")); 
   539             }
   452             iFindinNmsAllowed = false;
   540             else
       
   541             {
       
   542                 iStationName->setPlainText(QString("")); 
       
   543                 iFindinNmsAllowed = false;
       
   544             }             
   453         }
   545         }
   454         loadStationLogo();
   546         loadStationLogo();
   455     }
   547     }
   456 }
   548 }
   457 
   549 
   459  * SLOTs for Logo Download
   551  * SLOTs for Logo Download
   460  *******************************************************************************************************
   552  *******************************************************************************************************
   461  */
   553  */
   462 void IRNowPlayingView::handleLogoDownloaded(IRQPreset* aPreset)
   554 void IRNowPlayingView::handleLogoDownloaded(IRQPreset* aPreset)
   463 {
   555 {
       
   556     LOG_METHOD;
   464     if( EIdle == iLogoDownloadState )
   557     if( EIdle == iLogoDownloadState )
   465     {        
   558     {        
   466         return;
   559         return;
   467     } 
   560     } 
   468             
   561             
   546  * SLOT for Network Event
   639  * SLOT for Network Event
   547  *******************************************************************************************************
   640  *******************************************************************************************************
   548  */
   641  */
   549 void IRNowPlayingView::handleNetworkEvent(IRQNetworkEvent aEvent)
   642 void IRNowPlayingView::handleNetworkEvent(IRQNetworkEvent aEvent)
   550 {
   643 {
       
   644     LOG_METHOD;
       
   645 	LOG_FORMAT("aEvent = %d", (int)aEvent );
   551     if( this != getViewManager()->currentView() )
   646     if( this != getViewManager()->currentView() )
   552     {
   647     {
   553         return;
   648         return;
   554     }
   649     }
   555     
   650     
   566                     iPlayController->connectToChannel(preset, EIRQAdhocExternal);
   661                     iPlayController->connectToChannel(preset, EIRQAdhocExternal);
   567                     delete preset;
   662                     delete preset;
   568                 }
   663                 }
   569                 else
   664                 else
   570                 {
   665                 {
   571                     IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();
   666                     IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();                    
   572                     IRQPreset *lastPreset = lastPlayedStationInfo->getLastPlayedStation();
   667                     if( lastPlayedStationInfo )
   573                     if (lastPreset)
       
   574                     {
   668                     {
   575                         iPlayController->connectToChannel( lastPreset, lastPlayedStationInfo->connectedFrom() );
   669                         IRQPreset *lastPreset = NULL;
   576                     }
   670                         lastPreset = lastPlayedStationInfo->getLastPlayedStation();
       
   671 						if (lastPreset)
       
   672                         {
       
   673                             iPlayController->connectToChannel( lastPreset, lastPlayedStationInfo->connectedFrom() );
       
   674                         }
       
   675                     }                    
   577                 }
   676                 }
   578             }
   677             }
   579             else if( EIR_UseNetwork_PlayStation == getUseNetworkReason() )
   678             else if( EIR_UseNetwork_PlayStation == getUseNetworkReason() )
   580             {
   679             {
   581                 iPlayController->resume();
   680                 iPlayController->resume();
   594  *******************************************************************************************************
   693  *******************************************************************************************************
   595  */
   694  */
   596 
   695 
   597 void IRNowPlayingView::handleOrientationChanged(Qt::Orientation aOrientation)
   696 void IRNowPlayingView::handleOrientationChanged(Qt::Orientation aOrientation)
   598 {
   697 {
       
   698     LOG_METHOD;
       
   699     
   599     if (aOrientation == Qt::Vertical)
   700     if (aOrientation == Qt::Vertical)
   600     {
   701     {   
       
   702         LOG("load portrait layout");
   601         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, PORTRAIT_SEC);
   703         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, PORTRAIT_SEC);
   602     }
   704     }
   603     else
   705     else
   604     {
   706     {
       
   707         LOG("load landscape layout");
   605         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, LANDSCAPE_SEC);      
   708         iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME, LANDSCAPE_SEC);      
   606     }
   709     }
       
   710     // re-load only update the size of the widget, the rect of the widget will get updated only after re-layout.
       
   711     updateGeometry();
       
   712     QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
       
   713     // re-select between label and marquee.
       
   714     updateSongName(iSongNameLabel->plainText());
   607 }
   715 }
   608 
   716 
   609 /********************************************************************************************************
   717 /********************************************************************************************************
   610  * SLOT for Play Controller
   718  * SLOT for Play Controller
   611  *******************************************************************************************************
   719  *******************************************************************************************************
   612  */
   720  */
   613 void IRNowPlayingView::handlePlayStarted()
   721 void IRNowPlayingView::handlePlayStarted()
   614 {
   722 {
       
   723     LOG_METHOD;
   615     iPlayStopAction->setIcon(HbIcon(KStopButtonIcon));
   724     iPlayStopAction->setIcon(HbIcon(KStopButtonIcon));
   616 }
   725 }
   617 
   726 
   618 void IRNowPlayingView::handlePlayStopped()
   727 void IRNowPlayingView::handlePlayStopped()
   619 {
   728 {
       
   729     LOG_METHOD;
   620     iPlayStopAction->setIcon(HbIcon(KPlayButtonIcon));
   730     iPlayStopAction->setIcon(HbIcon(KPlayButtonIcon));
   621     iSongName->setPlainText("");
   731     updateSongName(QString(""));
   622     iArtistName->setPlainText("");
   732     iArtistName->setPlainText("");
   623     iSongNameAvailable = false;
   733     iSongNameAvailable = false;
   624 }
   734 }
   625 
   735 
   626 void IRNowPlayingView::updateMetaData(IRQMetaData* aMetaData)
   736 void IRNowPlayingView::updateMetaData(IRQMetaData* aMetaData)
   627 {
   737 {
       
   738     LOG_METHOD;
   628     iSongNameAvailable = false;
   739     iSongNameAvailable = false;
   629     if(aMetaData)
   740     if(aMetaData)
   630     {
   741     {
   631         iSongName->setPlainText(aMetaData->getSongName());
   742         updateSongName(aMetaData->getSongName());
   632         iArtistName->setPlainText(aMetaData->getArtistName());
   743         iArtistName->setPlainText(aMetaData->getArtistName());
   633         if(!aMetaData->getSongName().isEmpty() ||
   744         if(!aMetaData->getSongName().isEmpty() ||
   634            !aMetaData->getArtistName().isEmpty())
   745            !aMetaData->getArtistName().isEmpty())
   635         {
   746         {
   636             iSongNameAvailable = true;
   747             iSongNameAvailable = true;
   637         }
   748         }
   638     }
   749     }
   639     else
   750     else
   640     {
   751     {
   641         iSongName->setPlainText("");
   752         updateSongName(QString(""));
   642         iArtistName->setPlainText("");  
   753         iArtistName->setPlainText("");  
   643     }
   754     }
   644 }
   755 }
   645 
   756 
   646 /********************************************************************************************************
   757 /********************************************************************************************************
   647  * SLOT for Media Key
   758  * SLOT for Media Key
   648  *******************************************************************************************************
   759  *******************************************************************************************************
   649  */
   760  */
   650 void IRNowPlayingView::handlePlayPauseMediaKey()
   761 void IRNowPlayingView::handlePlayPauseMediaKey()
   651 {
   762 {
       
   763     LOG_METHOD;
   652     iPlayController->resume();
   764     iPlayController->resume();
   653 }
   765 }
   654 
   766 
   655 void IRNowPlayingView::handleStopMediaKey()
   767 void IRNowPlayingView::handleStopMediaKey()
   656 {
   768 {
       
   769     LOG_METHOD;
   657     iPlayController->stop(EIRQUserTerminated);
   770     iPlayController->stop(EIRQUserTerminated);
   658 }
   771 }
   659 
   772 
   660 /********************************************************************************************************
   773 /********************************************************************************************************
   661  * SLOT for Toolbar Action
   774  * SLOT for Toolbar Action
   662  *******************************************************************************************************
   775  *******************************************************************************************************
   663  */
   776  */
   664 void IRNowPlayingView::handleMusicStoreAction()
   777 void IRNowPlayingView::handleMusicStoreAction()
   665 {
   778 {
       
   779     LOG_METHOD;
   666     if(!iFindinNmsAllowed)
   780     if(!iFindinNmsAllowed)
   667     {
   781     {
   668 #ifdef SUBTITLE_STR_BY_LOCID
   782 #ifdef SUBTITLE_STR_BY_LOCID
   669         popupNote(hbTrId("txt_irad_info_not_allowed_by_this_station"), HbMessageBox::MessageTypeInformation);
   783         popupNote(hbTrId("txt_irad_info_not_allowed_by_this_station"), HbMessageBox::MessageTypeInformation);
   670 #else
   784 #else
   671         popupNote(hbTrId("Not allowed by this station"), HbMessageBox::MessageTypeInformation);        
   785         popupNote(hbTrId("Not allowed by station"), HbMessageBox::MessageTypeInformation);        
   672 #endif
   786 #endif
   673         return;        
   787         return;        
   674     }
   788     }
   675     
   789     
   676     if(!iSongNameAvailable)
   790     if(!iSongNameAvailable)
   677     {
   791     {
       
   792 #ifdef SUBTITLE_STR_BY_LOCID
   678         popupNote(hbTrId("txt_irad_info_no_song_info"), HbMessageBox::MessageTypeInformation);
   793         popupNote(hbTrId("txt_irad_info_no_song_info"), HbMessageBox::MessageTypeInformation);
       
   794 #else
       
   795         popupNote(hbTrId("No song info"), HbMessageBox::MessageTypeInformation);        
       
   796 #endif        
   679         return;        
   797         return;        
   680     }
   798     }
   681     
   799     
   682     // Need to log the find song in NMS event, iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRFind,channelId); 
   800     // Need to log the find song in NMS event, iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRNmsFind,channelId); 
   683 #ifdef SUBTITLE_STR_BY_LOCID
   801 #ifdef SUBTITLE_STR_BY_LOCID
   684     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
   802     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
   685 #else
   803 #else
   686     popupNote(hbTrId("Music store not available"), HbMessageBox::MessageTypeInformation);    
   804     popupNote(hbTrId("Music store not ready"), HbMessageBox::MessageTypeInformation);    
   687 #endif
   805 #endif
   688 }
   806 }
   689 
   807 
   690 void IRNowPlayingView::handleIdentifySongAction()
   808 void IRNowPlayingView::handleIdentifySongAction()
   691 {
   809 {
   692     if(IRQUtility::openSongRecognition())
   810     LOG_METHOD;
       
   811     if(IRQUtility::launchAppByUid(iSettings->getSongRecognitionAppUid()))
   693     {
   812     {
   694         iStatisticsReporter->logSongRecogEvent();
   813         iStatisticsReporter->logSongRecogEvent();
   695     }
   814     }
   696 }
   815 }
   697 
   816 
   698 
   817 
   699 void IRNowPlayingView::handlePlayStopAction()
   818 void IRNowPlayingView::handlePlayStopAction()
   700 {
   819 {
       
   820     LOG_METHOD;
   701     switch (iPlayController->state())
   821     switch (iPlayController->state())
   702     {
   822     {
   703         case IRPlayController::EPlaying:
   823         case IRPlayController::EPlaying:
   704             iPlayController->stop(EIRQUserTerminated);
   824             iPlayController->stop(EIRQUserTerminated);
   705             return;
   825             return;
   724     }
   844     }
   725 }
   845 }
   726 
   846 
   727 void IRNowPlayingView::handleAddToFavAction()
   847 void IRNowPlayingView::handleAddToFavAction()
   728 {
   848 {
       
   849     LOG_METHOD;
   729     IRQPreset *nowPlayingPreset = iPlayController->getNowPlayingPreset();
   850     IRQPreset *nowPlayingPreset = iPlayController->getNowPlayingPreset();
   730     int retValue = iFavorites->addPreset(*nowPlayingPreset);
   851     int retValue = iFavorites->addPreset(*nowPlayingPreset);
   731     HbNotificationDialog *add2FavNote = new HbNotificationDialog();
   852     HbNotificationDialog *add2FavNote = new HbNotificationDialog();
   732     add2FavNote->setModal(true);
   853     add2FavNote->setModal(true);
   733     add2FavNote->setAttribute(Qt::WA_DeleteOnClose);
   854     add2FavNote->setAttribute(Qt::WA_DeleteOnClose);
   769     }
   890     }
   770 }
   891 }
   771 
   892 
   772 void IRNowPlayingView::handleDetailInfoAction()
   893 void IRNowPlayingView::handleDetailInfoAction()
   773 {
   894 {
       
   895     LOG_METHOD;
   774     getViewManager()->activateView(EIRView_StationDetailsView);
   896     getViewManager()->activateView(EIRView_StationDetailsView);
   775     IRStationDetailsView *channelHistoryView = static_cast<IRStationDetailsView*>(getViewManager()->getView(EIRView_StationDetailsView));
   897     IRStationDetailsView *channelHistoryView = static_cast<IRStationDetailsView*>(getViewManager()->getView(EIRView_StationDetailsView));
   776     channelHistoryView->setDetails();
   898     channelHistoryView->setDetails();
   777 
   899 
   778 }
   900 }
   781  * SLOT for Menu Action
   903  * SLOT for Menu Action
   782  *******************************************************************************************************
   904  *******************************************************************************************************
   783  */
   905  */
   784 void IRNowPlayingView::handleGoToStationAction()
   906 void IRNowPlayingView::handleGoToStationAction()
   785 {
   907 {
       
   908     LOG_METHOD;
   786     getViewManager()->activateView(EIRView_OpenWebAddressView);
   909     getViewManager()->activateView(EIRView_OpenWebAddressView);
   787 }
   910 }
   788 
   911 
   789 void IRNowPlayingView::handleShareStationAction()
   912 void IRNowPlayingView::handleShareStationAction()
   790 {
   913 {
       
   914     LOG_METHOD;
   791     if (NULL == iStationShare)
   915     if (NULL == iStationShare)
   792     {
   916     {
   793         iStationShare = new IRStationShare();
   917         iStationShare = new IRStationShare();
   794     }
   918     }
   795     iStationShare->shareStations(*iPlayController->getNowPlayingPreset());
   919     iStationShare->shareStations(*iPlayController->getNowPlayingPreset());
   796 }
   920 }
   797 
   921 
   798 void IRNowPlayingView::handleSettingAction()
   922 void IRNowPlayingView::handleSettingAction()
   799 {
   923 {
       
   924     LOG_METHOD_ENTER;
   800     getViewManager()->activateView(EIRView_SettingsView);
   925     getViewManager()->activateView(EIRView_SettingsView);
   801 }
   926 }
   802 
   927 
   803 #ifdef ADV_ENABLED
   928 #ifdef ADV_ENABLED
   804 void IRNowPlayingView::mousePressEvent(QGraphicsSceneMouseEvent *aEvent)
   929 void IRNowPlayingView::mousePressEvent(QGraphicsSceneMouseEvent *aEvent)
   805 {
   930 {
       
   931     LOG_METHOD_ENTER;
   806     QRectF advRect = iAdvImage->geometry();
   932     QRectF advRect = iAdvImage->geometry();
   807     QPointF pos = aEvent->pos();
   933     QPointF pos = aEvent->pos();
   808     
   934     
   809     if (advRect.contains(pos))
   935     if (advRect.contains(pos))
   810     {
   936     {
   812     }
   938     }
   813 }
   939 }
   814 
   940 
   815 void IRNowPlayingView::openAdvLink()
   941 void IRNowPlayingView::openAdvLink()
   816 {
   942 {
       
   943     LOG_METHOD_ENTER;
   817     IRQUtility::openAdvLink(iAdvUrl);
   944     IRQUtility::openAdvLink(iAdvUrl);
   818 }
   945 }
   819 #endif
   946 #endif
   820 
   947 
       
   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     
   821 void IRNowPlayingView::loadStationLogo()
   969 void IRNowPlayingView::loadStationLogo()
   822 {
   970 {
       
   971     LOG_METHOD;
   823     if (iPlayController->isStationLogoAvailable())    
   972     if (iPlayController->isStationLogoAvailable())    
   824     { 
   973     { 
   825         QSettings settings(KIrSettingOrganization, KIrSettingApplication);
   974         QSettings settings(KIrSettingOrganization, KIrSettingApplication);
   826         if (settings.value(KIrSettingStationLogo).canConvert<QPixmap>())
   975         if (settings.value(KIrSettingStationLogo).canConvert<QPixmap>())
   827         {
   976         {
   850 #endif
   999 #endif
   851 }
  1000 }
   852 
  1001 
   853 void saveStationLogo(const QPixmap &aStationLogo)
  1002 void saveStationLogo(const QPixmap &aStationLogo)
   854 {
  1003 {
       
  1004     LOG_METHOD_ENTER;
   855     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
  1005     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
   856     QVariant logoData(QVariant::Pixmap);
  1006     QVariant logoData(QVariant::Pixmap);
   857     logoData.setValue(aStationLogo);
  1007     logoData.setValue(aStationLogo);
   858     settings.setValue(KIrSettingStationLogo,logoData);    
  1008     settings.setValue(KIrSettingStationLogo,logoData);    
   859 }
  1009 }
       
  1010 //Implemented to receive theme change event
       
  1011 //@param QEvent, The change events to be received  
       
  1012 //
       
  1013 void IRNowPlayingView::changeEvent(QEvent *event)
       
  1014 {
       
  1015     if (HbEvent::ThemeChanged == event->type())
       
  1016     {
       
  1017         // get the text color from theme and 
       
  1018         // set it to corresponding labels
       
  1019         iArtistName->setTextColor(HbColorScheme::color(KArtistColor));
       
  1020         iSongNameLabel->setTextColor(HbColorScheme::color(KSongColor));
       
  1021         iSongNameMarquee->setTextColor(HbColorScheme::color(KSongColor));
       
  1022         iStationName->setTextColor(HbColorScheme::color(KStationColor));
       
  1023           
       
  1024     }
       
  1025     
       
  1026     HbWidget::changeEvent(event);
       
  1027 }