radioapp/radioapplication/src/radioapplication.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 33 11b6825f0862
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <QTimer>
    19 #include <QTimer>
       
    20 #include <qsysteminfo.h>
    20 #include <HbDeviceMessageBox>
    21 #include <HbDeviceMessageBox>
       
    22 #include <xqserviceutil.h>
       
    23 #include <HbSplashScreen>
    21 
    24 
    22 // User includes
    25 // User includes
    23 #include "radioapplication.h"
    26 #include "radioapplication.h"
    24 #include "radiowindow.h"
    27 #include "radiowindow.h"
    25 #include "radiouiengine.h"
    28 #include "radiouiengine.h"
    42 
    45 
    43 /*!
    46 /*!
    44  * Constructor
    47  * Constructor
    45  */
    48  */
    46 RadioApplication::RadioApplication( int &argc, char *argv[] ) :
    49 RadioApplication::RadioApplication( int &argc, char *argv[] ) :
    47     HbApplication( argc, argv )
    50     HbApplication( argc, argv, Hb::NoSplash )
    48 {
    51 {
    49     // Initializes the radio engine utils if UI logs are entered into the engine log
    52     // Initializes the radio engine utils if UI logs are entered into the engine log
    50     INIT_COMBINED_LOGGER
    53     INIT_COMBINED_LOGGER
    51 
    54 
    52     LOG_TIMESTAMP( "Start radio" );
    55     LOG_TIMESTAMP( "Start radio" );
    53     setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) );
    56     setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) );
       
    57 
       
    58     if ( !XQServiceUtil::isService() ) {
       
    59         HbSplashScreen::start();
       
    60     }
    54 
    61 
    55     QTimer::singleShot( 0, this, SLOT(init()) );
    62     QTimer::singleShot( 0, this, SLOT(init()) );
    56 }
    63 }
    57 
    64 
    58 /*!
    65 /*!
    64     // Releases the radio engine utils if it was initialized in the beginning
    71     // Releases the radio engine utils if it was initialized in the beginning
    65     RELEASE_COMBINED_LOGGER
    72     RELEASE_COMBINED_LOGGER
    66 }
    73 }
    67 
    74 
    68 /*!
    75 /*!
    69  *Private slot
    76  * Private slot
    70  *
    77  *
    71  */
    78  */
    72 void RadioApplication::init()
    79 void RadioApplication::init()
    73 {
    80 {
    74     bool okToStart = !RadioUiEngine::isOfflineProfile();
    81     // If started as a service, there is no need for offline-check
       
    82     bool okToStart = XQServiceUtil::isService();
       
    83     QScopedPointer<QtMobility::QSystemDeviceInfo> deviceInfo( new QtMobility::QSystemDeviceInfo() );
    75 
    84 
    76     if ( !okToStart ) {
    85     if ( !okToStart ) {
    77         HbDeviceMessageBox box( hbTrId( "txt_rad_info_activate_radio_in_offline_mode" ), HbMessageBox::MessageTypeQuestion );
    86         if ( deviceInfo->currentProfile() != QtMobility::QSystemDeviceInfo::OfflineProfile ) {
    78         box.setTimeout( HbPopup::NoTimeout );
    87             okToStart = true;
    79         box.exec();
    88         } else {
    80         okToStart = box.isAcceptAction( box.triggeredAction() );
    89             // Device is in offline profile, ask the user for permission to start
       
    90             HbDeviceMessageBox box( hbTrId( "txt_rad_info_activate_radio_in_offline_mode" ), HbMessageBox::MessageTypeQuestion );
       
    91             box.setTimeout( HbPopup::NoTimeout );
       
    92             box.exec();
       
    93             okToStart = box.isAcceptAction( box.triggeredAction() );
       
    94         }
    81     }
    95     }
    82 
    96 
    83     if ( okToStart ) {
    97     if ( okToStart ) {
    84 
    98 
    85         // MainWindow needs to be alive to be able to show the offline query dialog.
    99         // Try to optimize startup time by launching the radio server process as soon as possible.
    86         // The window is only constructed half-way at this point because we may need to shut down if
   100         // This way the server and UI are being initialized at the same time and the startup is faster.
    87         // offline usage is not allowed
   101 //        RadioUiEngine::launchRadioServer();
       
   102 
    88         mMainWindow.reset( new RadioWindow() );
   103         mMainWindow.reset( new RadioWindow() );
    89 
   104 
    90         CREATE_WIN32_TEST_WINDOW
   105         CREATE_WIN32_TEST_WINDOW
    91 
   106 
    92         INIT_WIN32_TEST_WINDOW
   107         INIT_WIN32_TEST_WINDOW
    93 
   108 
    94         // Construct the real views
   109         // Construct the real views
    95         mMainWindow->init();
   110         mMainWindow->init( deviceInfo.take() );
    96 
   111 
    97         mMainWindow->show();
   112         mMainWindow->show();
    98     } else {
   113     } else {
    99         quit();
   114         quit();
   100     }
   115     }