author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 18:12:57 +0300 | |
changeset 32 | 189d20c34778 |
parent 28 | 075425b8d9a4 |
child 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> |
22 |
||
23 |
// User includes |
|
24 |
#include "radioapplication.h" |
|
25 |
#include "radiowindow.h" |
|
26 |
#include "radiouiengine.h" |
|
27 |
#include "radio_global.h" |
|
28 |
#include "radiologger.h" |
|
29 |
||
30 |
#ifdef BUILD_WIN32 |
|
31 |
# include "testwindow_win32.h" |
|
32 |
# define CREATE_WIN32_TEST_WINDOW \ |
|
33 |
mWin32Window.reset( new Win32Window() ); \ |
|
34 |
mMainWindow->setParent( mWin32Window.data() ); \ |
|
35 |
mWin32Window->addHbWindow( mMainWindow.data() ); \ |
|
36 |
mWin32Window->show(); |
|
37 |
# define INIT_WIN32_TEST_WINDOW \ |
|
38 |
mWin32Window->init(); |
|
39 |
#else |
|
40 |
# define CREATE_WIN32_TEST_WINDOW |
|
41 |
# define INIT_WIN32_TEST_WINDOW |
|
42 |
#endif // BUILD_WIN32 |
|
43 |
||
44 |
/*! |
|
45 |
* Constructor |
|
46 |
*/ |
|
47 |
RadioApplication::RadioApplication( int &argc, char *argv[] ) : |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
48 |
HbApplication( argc, argv, Hb::NoSplash ) |
24 | 49 |
{ |
50 |
// Initializes the radio engine utils if UI logs are entered into the engine log |
|
51 |
INIT_COMBINED_LOGGER |
|
52 |
||
53 |
LOG_TIMESTAMP( "Start radio" ); |
|
54 |
setApplicationName( hbTrId( "txt_rad_title_fm_radio" ) ); |
|
55 |
||
56 |
QTimer::singleShot( 0, this, SLOT(init()) ); |
|
57 |
} |
|
58 |
||
59 |
/*! |
|
60 |
* |
|
61 |
*/ |
|
62 |
RadioApplication::~RadioApplication() |
|
63 |
{ |
|
64 |
// Destructor needs to be defined. See explanation from RadioEngineWrapperPrivate destructor. |
|
65 |
// Releases the radio engine utils if it was initialized in the beginning |
|
66 |
RELEASE_COMBINED_LOGGER |
|
67 |
} |
|
68 |
||
69 |
/*! |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
70 |
* Private slot |
24 | 71 |
* |
72 |
*/ |
|
73 |
void RadioApplication::init() |
|
74 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
// If started as a service, there is no need for offline-check |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
76 |
const Hb::ActivationReason reason = activateReason(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
77 |
bool okToStart = reason == Hb::ActivationReasonService; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
78 |
QScopedPointer<QtMobility::QSystemDeviceInfo> deviceInfo( new QtMobility::QSystemDeviceInfo() ); |
24 | 79 |
|
80 |
if ( !okToStart ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
if ( deviceInfo->currentProfile() != QtMobility::QSystemDeviceInfo::OfflineProfile ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
82 |
okToStart = true; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
83 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
84 |
// 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
|
85 |
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
|
86 |
box.setTimeout( HbPopup::NoTimeout ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
87 |
box.exec(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
88 |
okToStart = box.isAcceptAction( box.triggeredAction() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
89 |
} |
24 | 90 |
} |
91 |
||
92 |
if ( okToStart ) { |
|
93 |
||
94 |
// MainWindow needs to be alive to be able to show the offline query dialog. |
|
95 |
// The window is only constructed half-way at this point because we may need to shut down if |
|
96 |
// offline usage is not allowed |
|
97 |
mMainWindow.reset( new RadioWindow() ); |
|
98 |
||
99 |
CREATE_WIN32_TEST_WINDOW |
|
100 |
||
101 |
INIT_WIN32_TEST_WINDOW |
|
102 |
||
103 |
// Construct the real views |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
104 |
mMainWindow->init( deviceInfo.take() ); |
24 | 105 |
|
106 |
mMainWindow->show(); |
|
107 |
} else { |
|
108 |
quit(); |
|
109 |
} |
|
110 |
} |