qtinternetradio/ui/src/irapplication.cpp
changeset 15 065198191975
parent 14 896e9dbc5f19
child 16 5723da102db1
equal deleted inserted replaced
14:896e9dbc5f19 15:065198191975
   109     createComponents();
   109     createComponents();
   110     // get advertisement setting
   110     // get advertisement setting
   111     iSettings->getGlobalAdvFlag(iEnableGlobalAdv);
   111     iSettings->getGlobalAdvFlag(iEnableGlobalAdv);
   112     setupConnection();
   112     setupConnection();
   113     
   113     
   114     if ( !iIsEmbedded )
   114     if ( !XQServiceUtil::isService() )
   115     {
   115     {
   116         setLaunchView();
   116         setLaunchView();
   117     }
   117     }
   118     
   118     
   119     QString name = XQServiceUtil::interfaceName();
   119     QString name = XQServiceUtil::interfaceName();
   172  * Parameters  : None
   172  * Parameters  : None
   173  * Return      : None
   173  * Return      : None
   174  */
   174  */
   175 void IRApplication::setLaunchView()
   175 void IRApplication::setLaunchView()
   176 {
   176 {
       
   177     LOG_METHOD;
   177     //get starting view id according to activate reason
   178     //get starting view id according to activate reason
   178     TIRViewId viewId = EIRView_CategoryView;
   179     TIRViewId viewId = EIRView_CategoryView;
   179     HbApplication *hbApp = qobject_cast<HbApplication*>(qApp);
   180     HbApplication *hbApp = qobject_cast<HbApplication*>(qApp);
   180 
   181 
   181     if (hbApp->activateReason() == Hb::ActivationReasonActivity)
   182     if (hbApp->activateReason() == Hb::ActivationReasonActivity)
   215  * Return      : true : network connection has been established
   216  * Return      : true : network connection has been established
   216  *               false : network connection has not been established
   217  *               false : network connection has not been established
   217  */
   218  */
   218 bool IRApplication::verifyNetworkConnectivity(const QString &aConnectingText)
   219 bool IRApplication::verifyNetworkConnectivity(const QString &aConnectingText)
   219 {
   220 {
       
   221     LOG_METHOD;
   220     Q_ASSERT(iNetworkController);
   222     Q_ASSERT(iNetworkController);
   221     
   223     
   222     bool ret = true;
   224     bool ret = true;
   223     
   225     
   224     if (!iNetworkController->getNetworkStatus())
   226     if (!iNetworkController->getNetworkStatus())
   236     return ret;
   238     return ret;
   237 } 
   239 } 
   238 
   240 
   239 void IRApplication::startLoadingAnimation(const QObject *aReceiver, const char *aFunc)
   241 void IRApplication::startLoadingAnimation(const QObject *aReceiver, const char *aFunc)
   240 {
   242 {
   241     LOG_METHOD_ENTER;
   243     LOG_METHOD;;
   242     
   244     
   243     //for downloading logos in stations view, favorites view and history view, network connection
   245     //for downloading logos in stations view, favorites view and history view, network connection
   244     //is initiated by low layer, we don't show any dialog
   246     //is initiated by low layer, we don't show any dialog
   245     if (!iNetworkController->getNetworkStatus())
   247     if (!iNetworkController->getNetworkStatus())
   246     {
   248     {
   293     iLoadingNote->show();
   295     iLoadingNote->show();
   294 }
   296 }
   295 
   297 
   296 void IRApplication::stopLoadingAnimation()
   298 void IRApplication::stopLoadingAnimation()
   297 {
   299 {
   298     LOG_METHOD_ENTER;
   300     LOG_METHOD;;
   299 
   301 
   300     // this function is the endpoint of cancel loading actions for all views
   302     // this function is the endpoint of cancel loading actions for all views
   301 	// so we can do cleanup action here, including player stop action.
   303 	// so we can do cleanup action here, including player stop action.
   302 	// No need to stop the player in each views in the slot connected to the cancel signal of the loading note
   304 	// No need to stop the player in each views in the slot connected to the cancel signal of the loading note
   303     if (!getPlayController()->isPlaying())
   305     if (!getPlayController()->isPlaying())
   326  * Parameters  : None
   328  * Parameters  : None
   327  * Return      : the pointer to the network controller object
   329  * Return      : the pointer to the network controller object
   328  */
   330  */
   329 IRQNetworkController* IRApplication::getNetworkController()
   331 IRQNetworkController* IRApplication::getNetworkController()
   330 {
   332 {
       
   333     LOG_METHOD;
   331     if(NULL == iNetworkController)
   334     if(NULL == iNetworkController)
   332     {
   335     {
   333         iNetworkController = IRQNetworkController::openInstance(); 
   336         iNetworkController = IRQNetworkController::openInstance(); 
   334         connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)),
   337         connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)),
   335                this, SLOT(networkEventNotified(IRQNetworkEvent)));
   338                this, SLOT(networkEventNotified(IRQNetworkEvent)));
   342  * Parameters  : None
   345  * Parameters  : None
   343  * Return      : the pointer to the isds client object
   346  * Return      : the pointer to the isds client object
   344  */
   347  */
   345 IRQIsdsClient* IRApplication::getIsdsClient()
   348 IRQIsdsClient* IRApplication::getIsdsClient()
   346 {
   349 {
       
   350     LOG_METHOD;
   347     if(NULL == iIsdsClient)
   351     if(NULL == iIsdsClient)
   348     {
   352     {
   349         iIsdsClient = IRQIsdsClient::openInstance(); 
   353         iIsdsClient = IRQIsdsClient::openInstance(); 
   350     }
   354     }
   351     return iIsdsClient;
   355     return iIsdsClient;
   356  * Parameters  : None
   360  * Parameters  : None
   357  * Return      : the pointer to the play controller object
   361  * Return      : the pointer to the play controller object
   358  */
   362  */
   359 IRPlayController* IRApplication::getPlayController()
   363 IRPlayController* IRApplication::getPlayController()
   360 {
   364 {
       
   365     LOG_METHOD;
   361     if(NULL == iPlayController)
   366     if(NULL == iPlayController)
   362     {
   367     {
   363         iPlayController = new IRPlayController(this);
   368         iPlayController = new IRPlayController(this);
   364     }
   369     }
   365     return iPlayController;
   370     return iPlayController;
   366 }
   371 }
   367 
   372 
   368 IRLastPlayedStationInfo* IRApplication::getLastPlayedStationInfo()
   373 IRLastPlayedStationInfo* IRApplication::getLastPlayedStationInfo()
   369 {
   374 {
       
   375     LOG_METHOD;
   370     if( iIsEmbedded )
   376     if( iIsEmbedded )
   371     {
   377     {
   372         return NULL;
   378         return NULL;
   373     } 
   379     } 
   374     
   380     
   379     return iLastPlayedStationInfo;
   385     return iLastPlayedStationInfo;
   380 }
   386 }
   381 
   387 
   382 IRQFavoritesDB* IRApplication::getFavoritesDB()
   388 IRQFavoritesDB* IRApplication::getFavoritesDB()
   383 {
   389 {
       
   390     LOG_METHOD;
   384     if(NULL == iFavPresets)
   391     if(NULL == iFavPresets)
   385     {
   392     {
   386         iFavPresets = new IRQFavoritesDB();
   393         iFavPresets = new IRQFavoritesDB();
   387     }
   394     }
   388     return iFavPresets;
   395     return iFavPresets;
   389 }
   396 }
   390 
   397 
   391 IRQSettings * IRApplication::getSettings()
   398 IRQSettings * IRApplication::getSettings()
   392 {
   399 {
       
   400     LOG_METHOD;
   393     if(NULL == iSettings)
   401     if(NULL == iSettings)
   394     {
   402     {
   395         iSettings = IRQSettings::openInstance();
   403         iSettings = IRQSettings::openInstance();
   396     }   
   404     }   
   397     return iSettings;
   405     return iSettings;
   398 }
   406 }
   399 
   407 
   400 IRMediaKeyObserver* IRApplication::getMediaKeyObserver()
   408 IRMediaKeyObserver* IRApplication::getMediaKeyObserver()
   401 {
   409 {
       
   410     LOG_METHOD;
   402     if(NULL == iMediaKeyObserver)
   411     if(NULL == iMediaKeyObserver)
   403     {
   412     {
   404     iMediaKeyObserver = new IRMediaKeyObserver(this);
   413     iMediaKeyObserver = new IRMediaKeyObserver(this);
   405     }
   414     }
   406     return iMediaKeyObserver;
   415     return iMediaKeyObserver;
   407 }
   416 }
   408 
   417 
   409 
   418 
   410 IRQAdvClient* IRApplication::getAdvClient()
   419 IRQAdvClient* IRApplication::getAdvClient()
   411 {
   420 {
       
   421     LOG_METHOD;
   412     if(iEnableGlobalAdv && (NULL == iAdvertisementClient))
   422     if(iEnableGlobalAdv && (NULL == iAdvertisementClient))
   413     {
   423     {
   414         //iAdvertisementClient = IRQAdvClient::openInstance();
   424         //iAdvertisementClient = IRQAdvClient::openInstance();
   415     }
   425     }
   416 
   426 
   417     return iAdvertisementClient;
   427     return iAdvertisementClient;
   418 }
   428 }
   419 
   429 
   420 IRPlayList* IRApplication::getPlayList() const
   430 IRPlayList* IRApplication::getPlayList() const
   421 {
   431 {
       
   432     LOG_METHOD;
   422     if (NULL == iFileViewService)
   433     if (NULL == iFileViewService)
   423     {
   434     {
   424         return NULL;
   435         return NULL;
   425     }
   436     }
   426     
   437     
   433  * Parameters  : None
   444  * Parameters  : None
   434  * Return      : None
   445  * Return      : None
   435  */
   446  */
   436 void IRApplication::createComponents()
   447 void IRApplication::createComponents()
   437 {
   448 {
       
   449     LOG_METHOD;
   438     getSettings();
   450     getSettings();
   439 #ifdef HS_WIDGET_ENABLED    
   451 #ifdef HS_WIDGET_ENABLED    
   440     if( !iIsEmbedded )
   452     if( !iIsEmbedded )
   441     {
   453     {
   442         iControlService = new IrControlService(this);
   454         iControlService = new IrControlService(this);
   451  * Parameters   : None
   463  * Parameters   : None
   452  * Return       : None
   464  * Return       : None
   453  */
   465  */
   454 void IRApplication::destroyComponents()
   466 void IRApplication::destroyComponents()
   455 {	
   467 {	
       
   468     LOG_METHOD;
   456     delete iPlayController;
   469     delete iPlayController;
   457     iPlayController = NULL;
   470     iPlayController = NULL;
   458     
   471     
   459     delete iSystemEventHandler;
   472     delete iSystemEventHandler;
   460     iSystemEventHandler = NULL;
   473     iSystemEventHandler = NULL;
   492 #endif	
   505 #endif	
   493 }
   506 }
   494 
   507 
   495 void IRApplication::setupConnection()
   508 void IRApplication::setupConnection()
   496 {
   509 {
       
   510     LOG_METHOD;
   497     connect(this, SIGNAL(quit()), qApp, SLOT(quit()));
   511     connect(this, SIGNAL(quit()), qApp, SLOT(quit()));
   498 }
   512 }
   499 
   513 
   500 void IRApplication::cancelConnect()
   514 void IRApplication::cancelConnect()
   501 {
   515 {
       
   516     LOG_METHOD;
   502     if (iConnectingCanceled)
   517     if (iConnectingCanceled)
   503     {
   518     {
   504         return;
   519         return;
   505     }
   520     }
   506     
   521     
   520 
   535 
   521    
   536    
   522 //connect to signal 'networkEventNotified' from IRQNetworkController
   537 //connect to signal 'networkEventNotified' from IRQNetworkController
   523 void IRApplication::networkEventNotified(IRQNetworkEvent aEvent)
   538 void IRApplication::networkEventNotified(IRQNetworkEvent aEvent)
   524 {
   539 {
       
   540     LOG_METHOD;
   525     LOG_SLOT_CALLER;
   541     LOG_SLOT_CALLER;
       
   542     LOG_FORMAT("IRQNetworkEvent = %d", aEvent);
   526     switch (aEvent)
   543     switch (aEvent)
   527     {
   544     {
   528         case EIRQNetworkConnectionConnecting :
   545         case EIRQNetworkConnectionConnecting :
   529             startLoadingAnimation(this, SLOT(cancelConnect()));
   546             startLoadingAnimation(this, SLOT(cancelConnect()));
   530             iConnectingCanceled = false;
   547             iConnectingCanceled = false;
   581      
   598      
   582 }
   599 }
   583 
   600 
   584 void IRApplication::loadGenre()
   601 void IRApplication::loadGenre()
   585 {
   602 {
       
   603     LOG_METHOD;
   586     LOG_SLOT_CALLER;
   604     LOG_SLOT_CALLER;
   587     bool hasCache = iIsdsClient->isdsIsCategoryCached(IRQIsdsClient::EGenre);
   605     bool hasCache = iIsdsClient->isdsIsCategoryCached(IRQIsdsClient::EGenre);
   588 
   606 
   589     if (!hasCache)
   607     if (!hasCache)
   590     {
   608     {
   600     categoryView->loadCategory(IRQIsdsClient::EGenre);
   618     categoryView->loadCategory(IRQIsdsClient::EGenre);
   601 } 
   619 } 
   602 
   620 
   603 void IRApplication::initApp()
   621 void IRApplication::initApp()
   604 {
   622 {
       
   623     LOG_METHOD;
   605     getNetworkController();    
   624     getNetworkController();    
   606     
   625     
   607     IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView());
   626     IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView());
   608     if (view)
   627     if (view)
   609     {
   628     {
   610         view->lazyInit();
       
   611         view->launchAction();
   629         view->launchAction();
   612     }
   630     }
   613     getMediaKeyObserver();	
   631     getMediaKeyObserver();	
   614     startSystemEventMonitor();
   632     startSystemEventMonitor();
   615 
   633 
   627         if (psUtils.defineProperty(irStartupKey, XQSettingsManager::TypeInt))
   645         if (psUtils.defineProperty(irStartupKey, XQSettingsManager::TypeInt))
   628         {
   646         {
   629             settingsManager.writeItemValue(irStartupKey, (int)QDateTime::currentDateTime().toTime_t());
   647             settingsManager.writeItemValue(irStartupKey, (int)QDateTime::currentDateTime().toTime_t());
   630         } 
   648         } 
   631     }
   649     }
   632 #endif        
   650 #endif
       
   651 
       
   652     emit applicationReady();
   633 }
   653 }
   634 
   654 
   635 bool IRApplication::event(QEvent* e)
   655 bool IRApplication::event(QEvent* e)
   636 {
   656 {
   637     if(e->type() == iInitEvent)
   657     if(e->type() == iInitEvent)
   638     {
   658     {
       
   659         LOG_METHOD;
   639         initApp();
   660         initApp();
   640         return true;        
   661         return true;        
   641     }
   662     }
   642     
   663     
   643     return QObject::event(e);
   664     return QObject::event(e);
   644 }
   665 }
   645 
   666 
   646 TIRHandleResult IRApplication::handleConnectionEstablished()
   667 TIRHandleResult IRApplication::handleConnectionEstablished()
   647 {
   668 {
       
   669     LOG_METHOD;
   648     TIRHandleResult retVal = EIR_DoDefault;
   670     TIRHandleResult retVal = EIR_DoDefault;
   649     switch (iUseNetworkReason)
   671     switch (iUseNetworkReason)
   650     {
   672     {
   651         case EIR_UseNetwork_LoadCategory:
   673         case EIR_UseNetwork_LoadCategory:
   652         {
   674         {
   668     
   690     
   669     iUseNetworkReason = EIR_UseNetwork_NoReason;    
   691     iUseNetworkReason = EIR_UseNetwork_NoReason;    
   670     return retVal;
   692     return retVal;
   671 }
   693 }
   672 
   694 
       
   695 #ifdef TERMS_CONDITIONS_VIEW_ENABLED 
   673 void IRApplication::handleTermsConsAccepted()
   696 void IRApplication::handleTermsConsAccepted()
   674 {
   697 {
       
   698     LOG_METHOD;
   675     iSettings->reSetFlagTermsAndConditions();
   699     iSettings->reSetFlagTermsAndConditions();
   676     IRBaseView * termsConsView = iViewManager->getView(EIRView_TermsConsView);
   700     IRBaseView * termsConsView = iViewManager->getView(EIRView_TermsConsView);
   677     iViewManager->removeView(termsConsView);
   701     iViewManager->removeView(termsConsView);
   678     termsConsView->deleteLater();
   702     termsConsView->deleteLater();
   679     
   703     
   680     iViewManager->activateView(iStartingViewId); 
   704     iViewManager->activateView(iStartingViewId); 
   681     QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
       
   682     QEvent* initEvent = new QEvent(iInitEvent);
   705     QEvent* initEvent = new QEvent(iInitEvent);
   683     QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); 	 
   706     QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); 	 
   684 }
   707 }
       
   708 #endif
   685 
   709 
   686 void IRApplication::launchStartingView(TIRViewId aViewId)
   710 void IRApplication::launchStartingView(TIRViewId aViewId)
   687 {
   711 {
       
   712     LOG_METHOD;
   688     iStartingViewId = aViewId;
   713     iStartingViewId = aViewId;
   689     /* bool isFirstTimeUsage = false;
   714 #ifdef TERMS_CONDITIONS_VIEW_ENABLED     
       
   715     bool isFirstTimeUsage = false;
   690     iSettings->isFlagTermsAndConditions(isFirstTimeUsage);
   716     iSettings->isFlagTermsAndConditions(isFirstTimeUsage);
   691     
   717     
   692     if(isFirstTimeUsage)
   718     if(isFirstTimeUsage)
   693     {
   719     {
   694         iViewManager->activateView(EIRView_TermsConsView);  
   720         iViewManager->activateView(EIRView_TermsConsView);  
   695 		QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);    
   721     }
   696     }
   722     else
   697     else*/
   723 #endif    
   698     {
   724     {
   699         iViewManager->activateView(iStartingViewId);
   725         iViewManager->activateView(iStartingViewId);
   700         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
       
   701         QEvent* initEvent = new QEvent(iInitEvent);
   726         QEvent* initEvent = new QEvent(iInitEvent);
   702         QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority);         
   727         QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority);         
   703     }
   728     }
   704     
   729     
   705     iAppFullyStarted = true;
   730     iAppFullyStarted = true;
   714 {
   739 {
   715     return iIsEmbedded;
   740     return iIsEmbedded;
   716 }
   741 }
   717 void IRApplication::setExitingView()
   742 void IRApplication::setExitingView()
   718 {  
   743 {  
       
   744     LOG_METHOD;
   719     TIRViewId viewId = iViewManager->getExitingView();
   745     TIRViewId viewId = iViewManager->getExitingView();
   720     if(EIRView_InvalidId != viewId)
   746     if(EIRView_InvalidId != viewId)
   721     {
   747     {
   722         getSettings()->setStartingViewId(viewId);
   748         getSettings()->setStartingViewId(viewId);
   723     }
   749     }
   725 
   751 
   726 
   752 
   727 #ifdef HS_WIDGET_ENABLED
   753 #ifdef HS_WIDGET_ENABLED
   728 bool IRApplication::startPlaying()
   754 bool IRApplication::startPlaying()
   729 {
   755 {
       
   756     LOG_METHOD;
   730     // if any loading is in progress, disallow to play
   757     // if any loading is in progress, disallow to play
   731     if (iLoadingNote && iLoadingNote->isVisible())
   758     if (iLoadingNote && iLoadingNote->isVisible())
   732     {
   759     {
   733         LOG( "IRApplication::startPlaying() in the return false1");
   760         LOG( "IRApplication::startPlaying() in the return false1");
   734         return false;
   761         return false;
   754     }
   781     }
   755 }
   782 }
   756 
   783 
   757 void IRApplication::cancelPlayerLoading()
   784 void IRApplication::cancelPlayerLoading()
   758 {
   785 {
       
   786     LOG_METHOD;
   759     if (IRPlayController::EConnecting == getPlayController()->state() 
   787     if (IRPlayController::EConnecting == getPlayController()->state() 
   760         || IRPlayController::EBuffering == getPlayController()->state())
   788         || IRPlayController::EBuffering == getPlayController()->state())
   761     {       
   789     {       
   762         if (iLoadingNote && iLoadingNote->isVisible())
   790         if (iLoadingNote && iLoadingNote->isVisible())
   763         {
   791         {