radioapp/radioapplication/src/radioapplication.cpp
changeset 51 bbebb0235466
parent 44 0a3ad94fc71c
equal deleted inserted replaced
47:74b7c6e79031 51:bbebb0235466
    49 
    49 
    50 /*!
    50 /*!
    51  * Constructor
    51  * Constructor
    52  */
    52  */
    53 RadioApplication::RadioApplication( int &argc, char *argv[] ) :
    53 RadioApplication::RadioApplication( int &argc, char *argv[] ) :
    54     HbApplication( argc, argv, Hb::NoSplash ),
    54     HbApplication( argc, argv, XQServiceUtil::isService(argc, argv) ? Hb::NoSplash : Hb::DefaultApplicationFlags ),
    55     mSettingsManager( new XQSettingsManager( this ) )
    55     mMainWindow( new RadioWindow() ),
       
    56     mSettingsManager( new XQSettingsManager( this ) ),
       
    57     mInitialisationDone( false )
    56 {
    58 {
    57     // Initializes the radio engine utils if UI logs are entered into the engine log
    59     // Initializes the radio engine utils if UI logs are entered into the engine log
    58     INIT_COMBINED_LOGGER
    60     INIT_COMBINED_LOGGER
    59 
    61 
    60     LOG_TIMESTAMP( "Start radio" );
    62     LOG_TIMESTAMP( "Start radio" );
       
    63 
       
    64     QTimer::singleShot( 0, this, SLOT( construct() ) );
       
    65 }
       
    66 
       
    67 /*!
       
    68  *
       
    69  */
       
    70 RadioApplication::~RadioApplication()
       
    71 {
       
    72     // Destructor needs to be defined. See explanation from RadioEngineWrapperPrivate destructor.
       
    73     // Releases the radio engine utils if it was initialized in the beginning
       
    74     RELEASE_COMBINED_LOGGER
       
    75 }
       
    76 
       
    77 /*!
       
    78  * Private slot
       
    79  *
       
    80  */
       
    81 void RadioApplication::construct()
       
    82 {
    61     setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) );
    83     setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) );
    62 
    84 
    63     if ( XQServiceUtil::isService() ) {
    85     if ( XQServiceUtil::isService() ) {
    64 
       
    65         // Radio was started as a highway service from homescreen widget.
    86         // Radio was started as a highway service from homescreen widget.
    66         // Widget has already done the offline mode check so we can start without checking
    87         // Widget has already done the offline mode check so we can start without checking
    67         init();
    88         init();
    68 
    89 
    69     } else {
    90     } else {
    73         } else {
    94         } else {
    74             init();
    95             init();
    75         }
    96         }
    76 
    97 
    77     }
    98     }
    78 }
       
    79 
    99 
    80 /*!
       
    81  *
       
    82  */
       
    83 RadioApplication::~RadioApplication()
       
    84 {
       
    85     // Destructor needs to be defined. See explanation from RadioEngineWrapperPrivate destructor.
       
    86     // Releases the radio engine utils if it was initialized in the beginning
       
    87     RELEASE_COMBINED_LOGGER
       
    88 }
   100 }
    89 
   101 
    90 /*!
   102 /*!
    91  * Private slot
   103  * Private slot
    92  *
   104  *
   110 
   122 
   111         // If main window has not been created yet it means the offline question was asked during startup
   123         // If main window has not been created yet it means the offline question was asked during startup
   112         // so we must continue with the startup sequence. If the main window was already created it means
   124         // so we must continue with the startup sequence. If the main window was already created it means
   113         // the question was asked when the radio was already running and the offline mode was activated.
   125         // the question was asked when the radio was already running and the offline mode was activated.
   114         // In that case there is no need to do anything since the user wants to continue listening to radio.
   126         // In that case there is no need to do anything since the user wants to continue listening to radio.
   115         if ( !mMainWindow ) {
   127         if ( !mInitialisationDone ) {
   116             init();
   128             init();
   117         }
   129         }
   118 
   130 
   119     } else {
   131     } else {
   120         quit();
   132         quit();
   129     // Try to optimize startup time by launching the radio server process as soon as possible.
   141     // Try to optimize startup time by launching the radio server process as soon as possible.
   130     // This way the server and UI are being initialized at the same time and the startup is faster.
   142     // This way the server and UI are being initialized at the same time and the startup is faster.
   131 //        RadioUiEngine::launchRadioServer();
   143 //        RadioUiEngine::launchRadioServer();
   132 
   144 
   133     // Splash screen needs to be shown when not started by homescreen widget
   145     // Splash screen needs to be shown when not started by homescreen widget
   134     if ( !XQServiceUtil::isService() ) {
       
   135         HbSplashScreen::setAppId( "0x2002FF4E" );
       
   136         HbSplashScreen::start();
       
   137     }
       
   138 
   146 
   139     Radio::connect( mSettingsManager,   SIGNAL(valueChanged(XQSettingsKey,QVariant)),
   147     Radio::connect( mSettingsManager,   SIGNAL(valueChanged(XQSettingsKey,QVariant)),
   140                     this,               SLOT(checkOfflineMode()) );
   148                     this,               SLOT(checkOfflineMode()) );
   141 
   149 
   142     bool monitoringStarted = mSettingsManager->startMonitoring( gConnectionKey );
   150     bool monitoringStarted = mSettingsManager->startMonitoring( gConnectionKey );
   143     LOG_ASSERT( monitoringStarted, LOG( "Failed to start monitoring Offline mode!" ) );
   151     LOG_ASSERT( monitoringStarted, LOG( "Failed to start monitoring Offline mode!" ) );
   144     Q_UNUSED( monitoringStarted );
   152     Q_UNUSED( monitoringStarted );
   145 
   153 
   146     mMainWindow.reset( new RadioWindow() );
       
   147 
       
   148     CREATE_WIN32_TEST_WINDOW
   154     CREATE_WIN32_TEST_WINDOW
   149 
   155 
   150     INIT_WIN32_TEST_WINDOW
   156     INIT_WIN32_TEST_WINDOW
   151 
   157 
   152     // Construct the real views
   158     // Construct the real views
   153     mMainWindow->init();
   159     mMainWindow->init();
       
   160     mInitialisationDone = true;
   154 
   161 
   155     mMainWindow->show();
   162     mMainWindow->show();
   156 }
   163 }
   157 
   164 
   158 /*!
   165 /*!