author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 19 | afea38384506 |
parent 33 | 11b6825f0862 |
permissions | -rw-r--r-- |
24 | 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> |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
20 |
#include <qsysteminfo.h> |
24 | 21 |
#include <HbDeviceMessageBox> |
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
22 |
#include <xqserviceutil.h> |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
23 |
#include <HbSplashScreen> |
24 | 24 |
|
25 |
// User includes |
|
26 |
#include "radioapplication.h" |
|
27 |
#include "radiowindow.h" |
|
28 |
#include "radiouiengine.h" |
|
29 |
#include "radio_global.h" |
|
30 |
#include "radiologger.h" |
|
31 |
||
32 |
#ifdef BUILD_WIN32 |
|
33 |
# include "testwindow_win32.h" |
|
34 |
# define CREATE_WIN32_TEST_WINDOW \ |
|
35 |
mWin32Window.reset( new Win32Window() ); \ |
|
36 |
mMainWindow->setParent( mWin32Window.data() ); \ |
|
37 |
mWin32Window->addHbWindow( mMainWindow.data() ); \ |
|
38 |
mWin32Window->show(); |
|
39 |
# define INIT_WIN32_TEST_WINDOW \ |
|
40 |
mWin32Window->init(); |
|
41 |
#else |
|
42 |
# define CREATE_WIN32_TEST_WINDOW |
|
43 |
# define INIT_WIN32_TEST_WINDOW |
|
44 |
#endif // BUILD_WIN32 |
|
45 |
||
46 |
/*! |
|
47 |
* Constructor |
|
48 |
*/ |
|
49 |
RadioApplication::RadioApplication( int &argc, char *argv[] ) : |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
50 |
HbApplication( argc, argv, Hb::NoSplash ) |
24 | 51 |
{ |
52 |
// Initializes the radio engine utils if UI logs are entered into the engine log |
|
53 |
INIT_COMBINED_LOGGER |
|
54 |
||
55 |
LOG_TIMESTAMP( "Start radio" ); |
|
56 |
setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) ); |
|
57 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
58 |
if ( !XQServiceUtil::isService() ) { |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
59 |
HbSplashScreen::start(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
60 |
} |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
61 |
|
24 | 62 |
QTimer::singleShot( 0, this, SLOT(init()) ); |
63 |
} |
|
64 |
||
65 |
/*! |
|
66 |
* |
|
67 |
*/ |
|
68 |
RadioApplication::~RadioApplication() |
|
69 |
{ |
|
70 |
// Destructor needs to be defined. See explanation from RadioEngineWrapperPrivate destructor. |
|
71 |
// Releases the radio engine utils if it was initialized in the beginning |
|
72 |
RELEASE_COMBINED_LOGGER |
|
73 |
} |
|
74 |
||
75 |
/*! |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
76 |
* Private slot |
24 | 77 |
* |
78 |
*/ |
|
79 |
void RadioApplication::init() |
|
80 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
// If started as a service, there is no need for offline-check |
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
82 |
bool okToStart = XQServiceUtil::isService(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
83 |
QScopedPointer<QtMobility::QSystemDeviceInfo> deviceInfo( new QtMobility::QSystemDeviceInfo() ); |
24 | 84 |
|
85 |
if ( !okToStart ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
86 |
if ( deviceInfo->currentProfile() != QtMobility::QSystemDeviceInfo::OfflineProfile ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
87 |
okToStart = true; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
88 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
89 |
// Device is in offline profile, ask the user for permission to start |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
90 |
HbDeviceMessageBox box( hbTrId( "txt_rad_info_activate_radio_in_offline_mode" ), HbMessageBox::MessageTypeQuestion ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
91 |
box.setTimeout( HbPopup::NoTimeout ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
92 |
box.exec(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
93 |
okToStart = box.isAcceptAction( box.triggeredAction() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
94 |
} |
24 | 95 |
} |
96 |
||
97 |
if ( okToStart ) { |
|
98 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
99 |
// Try to optimize startup time by launching the radio server process as soon as possible. |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
100 |
// This way the server and UI are being initialized at the same time and the startup is faster. |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
101 |
// RadioUiEngine::launchRadioServer(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
102 |
|
24 | 103 |
mMainWindow.reset( new RadioWindow() ); |
104 |
||
105 |
CREATE_WIN32_TEST_WINDOW |
|
106 |
||
107 |
INIT_WIN32_TEST_WINDOW |
|
108 |
||
109 |
// Construct the real views |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
110 |
mMainWindow->init( deviceInfo.take() ); |
24 | 111 |
|
112 |
mMainWindow->show(); |
|
113 |
} else { |
|
114 |
quit(); |
|
115 |
} |
|
116 |
} |