radioapp/radioapplication/src/radioapplication.cpp
changeset 24 6df133bd92e1
child 28 075425b8d9a4
equal deleted inserted replaced
23:a2b50a479edf 24:6df133bd92e1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <QTimer>
       
    20 #include <HbDeviceMessageBox>
       
    21 
       
    22 // User includes
       
    23 #include "radioapplication.h"
       
    24 #include "radiowindow.h"
       
    25 #include "radiouiengine.h"
       
    26 #include "radio_global.h"
       
    27 #include "radiologger.h"
       
    28 
       
    29 #ifdef BUILD_WIN32
       
    30 #   include "testwindow_win32.h"
       
    31 #   define CREATE_WIN32_TEST_WINDOW \
       
    32         mWin32Window.reset( new Win32Window() ); \
       
    33         mMainWindow->setParent( mWin32Window.data() ); \
       
    34         mWin32Window->addHbWindow( mMainWindow.data() ); \
       
    35         mWin32Window->show();
       
    36 #   define INIT_WIN32_TEST_WINDOW \
       
    37         mWin32Window->init();
       
    38 #else
       
    39 #   define CREATE_WIN32_TEST_WINDOW
       
    40 #   define INIT_WIN32_TEST_WINDOW
       
    41 #endif // BUILD_WIN32
       
    42 
       
    43 /*!
       
    44  * Constructor
       
    45  */
       
    46 RadioApplication::RadioApplication( int &argc, char *argv[] ) :
       
    47     HbApplication( argc, argv )
       
    48 {
       
    49     // Initializes the radio engine utils if UI logs are entered into the engine log
       
    50     INIT_COMBINED_LOGGER
       
    51 
       
    52     LOG_TIMESTAMP( "Start radio" );
       
    53     setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) );
       
    54 
       
    55     QTimer::singleShot( 0, this, SLOT(init()) );
       
    56 }
       
    57 
       
    58 /*!
       
    59  *
       
    60  */
       
    61 RadioApplication::~RadioApplication()
       
    62 {
       
    63     // Destructor needs to be defined. See explanation from RadioEngineWrapperPrivate destructor.
       
    64     // Releases the radio engine utils if it was initialized in the beginning
       
    65     RELEASE_COMBINED_LOGGER
       
    66 }
       
    67 
       
    68 /*!
       
    69  *Private slot
       
    70  *
       
    71  */
       
    72 void RadioApplication::init()
       
    73 {
       
    74     bool okToStart = !RadioUiEngine::isOfflineProfile();
       
    75 
       
    76     if ( !okToStart ) {
       
    77         HbDeviceMessageBox box( hbTrId( "txt_rad_info_activate_radio_in_offline_mode" ), HbMessageBox::MessageTypeQuestion );
       
    78         box.setTimeout( HbPopup::NoTimeout );
       
    79         box.exec();
       
    80         okToStart = box.isAcceptAction( box.triggeredAction() );
       
    81     }
       
    82 
       
    83     if ( okToStart ) {
       
    84 
       
    85         // MainWindow needs to be alive to be able to show the offline query dialog.
       
    86         // The window is only constructed half-way at this point because we may need to shut down if
       
    87         // offline usage is not allowed
       
    88         mMainWindow.reset( new RadioWindow() );
       
    89 
       
    90         CREATE_WIN32_TEST_WINDOW
       
    91 
       
    92         INIT_WIN32_TEST_WINDOW
       
    93 
       
    94         // Construct the real views
       
    95         mMainWindow->init();
       
    96 
       
    97         mMainWindow->show();
       
    98     } else {
       
    99         quit();
       
   100     }
       
   101 }