37
|
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 |
#include <hbdevicemessagebox.h>
|
|
19 |
#include <HbAction.h>
|
|
20 |
#include <CpPluginLauncher.h>
|
|
21 |
#include <hbinstance.h>
|
|
22 |
#include <HbView.h>
|
|
23 |
#include <xqserviceutil.h>
|
|
24 |
|
|
25 |
#include "networkhandlingstarter_p.h"
|
|
26 |
#include "networkhandlingstarterlogging.h"
|
|
27 |
#include "cnetworklistener.h"
|
|
28 |
|
|
29 |
/*!
|
|
30 |
Constructor of NetworkHandlingStarterPrivate.
|
|
31 |
*/
|
|
32 |
NetworkHandlingStarterPrivate::NetworkHandlingStarterPrivate(QObject *parent) :
|
|
33 |
QObject(parent), m_note(NULL)
|
|
34 |
{
|
|
35 |
DPRINT << ": IN";
|
|
36 |
|
|
37 |
QT_TRAP_THROWING(m_networkListener = CNetworkListener::NewL(*this));
|
|
38 |
|
|
39 |
DPRINT << ": OUT";
|
|
40 |
}
|
|
41 |
|
|
42 |
/*!
|
|
43 |
Destructor of NetworkHandlingStarterPrivate.
|
|
44 |
*/
|
|
45 |
NetworkHandlingStarterPrivate::~NetworkHandlingStarterPrivate()
|
|
46 |
{
|
|
47 |
DPRINT << ": IN";
|
|
48 |
|
|
49 |
delete m_networkListener;
|
|
50 |
if (m_note) {
|
|
51 |
delete m_note;
|
|
52 |
}
|
|
53 |
|
|
54 |
DPRINT << ": OUT";
|
|
55 |
}
|
|
56 |
|
|
57 |
/*!
|
|
58 |
NetworkHandlingStarterPrivate::ShowNote()
|
|
59 |
*/
|
|
60 |
void NetworkHandlingStarterPrivate::ShowNote()
|
|
61 |
{
|
|
62 |
DPRINT << ": IN";
|
|
63 |
|
|
64 |
if (m_note) {
|
|
65 |
m_note->close();
|
|
66 |
delete m_note;
|
|
67 |
m_note = NULL;
|
|
68 |
}
|
|
69 |
m_note = new HbDeviceMessageBox(
|
|
70 |
hbTrId("txt_phone_info_network_lost_select_network"),
|
|
71 |
HbMessageBox::MessageTypeQuestion);
|
|
72 |
HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_yes"), m_note);
|
|
73 |
m_note->setAction(primaryAction, HbDeviceMessageBox::AcceptButtonRole);
|
|
74 |
HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_no"), m_note);
|
|
75 |
m_note->setAction(secondaryAction,HbDeviceMessageBox::RejectButtonRole);
|
|
76 |
QObject::connect(
|
|
77 |
primaryAction, SIGNAL(triggered()),
|
|
78 |
this, SLOT(LaunchCpNetworkPluginView()));
|
|
79 |
m_note->setTimeout(0);
|
|
80 |
m_note->show();
|
|
81 |
|
|
82 |
DPRINT << ": OUT";
|
|
83 |
}
|
|
84 |
|
|
85 |
/*!
|
|
86 |
NetworkHandlingStarterPrivate::RemoveNote()
|
|
87 |
*/
|
|
88 |
void NetworkHandlingStarterPrivate::RemoveNote()
|
|
89 |
{
|
|
90 |
DPRINT << ": IN";
|
|
91 |
|
|
92 |
if (m_note) {
|
|
93 |
m_note->close();
|
|
94 |
delete m_note;
|
|
95 |
m_note = NULL;
|
|
96 |
}
|
|
97 |
|
|
98 |
DPRINT << ": OUT";
|
|
99 |
}
|
|
100 |
|
|
101 |
/*!
|
|
102 |
NetworkHandlingStarterPrivate::InitaliseCpNetworkPluginView()
|
|
103 |
*/
|
|
104 |
void NetworkHandlingStarterPrivate::InitaliseCpNetworkPluginView()
|
|
105 |
{
|
|
106 |
DPRINT << ": IN";
|
|
107 |
|
|
108 |
HbMainWindow *mainWnd = MainWindow();
|
|
109 |
if (mainWnd) {
|
|
110 |
if (CpPluginLauncher::launchCpPluginView(
|
|
111 |
"resource\\qt\\plugins\\controlpanel\\cpnetworkplugin.qtplugin")) {
|
|
112 |
foreach (HbView *view, mainWnd->views()) {
|
|
113 |
if (QString(view->metaObject()->className()) ==
|
|
114 |
QString("CpNetworkPluginView")) {
|
|
115 |
QObject::connect(
|
|
116 |
view, SIGNAL(aboutToClose()),
|
|
117 |
this, SLOT(ViewDone()));
|
|
118 |
QObject::connect(
|
|
119 |
this, SIGNAL(SearchAvailableNetworks()),
|
|
120 |
view, SLOT(SearchAvailableNetworks()));
|
|
121 |
}
|
|
122 |
}
|
|
123 |
}
|
|
124 |
}
|
|
125 |
|
|
126 |
DPRINT << ": OUT";
|
|
127 |
}
|
|
128 |
|
|
129 |
/*!
|
|
130 |
NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
|
|
131 |
*/
|
|
132 |
void NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
|
|
133 |
{
|
|
134 |
DPRINT << ": IN";
|
|
135 |
|
|
136 |
InitaliseCpNetworkPluginView();
|
|
137 |
HbMainWindow *mainWnd = MainWindow();
|
|
138 |
if (mainWnd) {
|
|
139 |
mainWnd->show();
|
|
140 |
XQServiceUtil::toBackground(false);
|
|
141 |
}
|
|
142 |
emit SearchAvailableNetworks();
|
|
143 |
|
|
144 |
DPRINT << ": OUT";
|
|
145 |
}
|
|
146 |
|
|
147 |
/*!
|
|
148 |
NetworkHandlingStarterPrivate::ViewDone()
|
|
149 |
*/
|
|
150 |
void NetworkHandlingStarterPrivate::ViewDone()
|
|
151 |
{
|
|
152 |
HbMainWindow *mainWnd = MainWindow();
|
|
153 |
if (mainWnd) {
|
|
154 |
mainWnd->hide();
|
|
155 |
}
|
|
156 |
XQServiceUtil::toBackground(true);
|
|
157 |
}
|
|
158 |
|
|
159 |
/*!
|
|
160 |
NetworkHandlingStarterPrivate::MainWindow()
|
|
161 |
*/
|
|
162 |
|
|
163 |
HbMainWindow * NetworkHandlingStarterPrivate::MainWindow()
|
|
164 |
{
|
|
165 |
HbMainWindow *window(NULL);
|
|
166 |
QList<HbMainWindow*> mainWindows = hbInstance->allMainWindows();
|
|
167 |
if (!mainWindows.isEmpty()) {
|
|
168 |
window = mainWindows.front();
|
|
169 |
}
|
|
170 |
return window;
|
|
171 |
}
|
|
172 |
|
|
173 |
// End of File.
|