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 "infowidgetengine.h"
|
|
19 |
#include "infowidgetnetworkhandler.h"
|
|
20 |
#include "infowidgetsathandler.h"
|
|
21 |
#include <networkhandlingproxy.h>
|
|
22 |
#include "infowidgetlogging.h"
|
|
23 |
#include "infowidgetpreferences.h"
|
|
24 |
|
|
25 |
/*!
|
|
26 |
\class InfoWidgetEngine
|
|
27 |
\brief Engine functionality of
|
|
28 |
Operator info widget
|
|
29 |
*/
|
|
30 |
|
|
31 |
|
|
32 |
/*!
|
|
33 |
InfoWidgetEngine::InfoWidgetEngine
|
|
34 |
*/
|
|
35 |
InfoWidgetEngine::InfoWidgetEngine(QObject *parent):
|
|
36 |
QObject(parent),
|
|
37 |
m_networkHandler(new InfoWidgetNetworkHandler),
|
|
38 |
m_satHandler(new InfoWidgetSatHandler)
|
|
39 |
{
|
|
40 |
DPRINT << ": IN";
|
|
41 |
|
|
42 |
QObject::connect(
|
|
43 |
m_networkHandler.data(), SIGNAL(networkError(int, int)),
|
|
44 |
this, SLOT(handleNetworkError(int, int)));
|
|
45 |
|
|
46 |
QObject::connect(
|
|
47 |
m_networkHandler.data(), SIGNAL(networkDataChanged()),
|
|
48 |
this, SLOT(updateNetworkDataToModel()));
|
|
49 |
|
|
50 |
QObject::connect(m_satHandler.data(),
|
|
51 |
SIGNAL(handleError(int, int)),
|
|
52 |
this, SLOT(handleSatError(int, int)));
|
|
53 |
|
|
54 |
QObject::connect(m_satHandler.data(),
|
|
55 |
SIGNAL(handleMessage(int)),
|
|
56 |
this, SLOT(updateSatDataToModel()));
|
|
57 |
|
|
58 |
updateNetworkDataToModel();
|
|
59 |
updateSatDataToModel();
|
|
60 |
|
|
61 |
DPRINT << ": OUT";
|
|
62 |
}
|
|
63 |
|
|
64 |
/*!
|
|
65 |
InfoWidgetEngine::~InfoWidgetEngine
|
|
66 |
*/
|
|
67 |
InfoWidgetEngine::~InfoWidgetEngine()
|
|
68 |
{
|
|
69 |
DPRINT;
|
|
70 |
}
|
|
71 |
|
|
72 |
/*!
|
|
73 |
InfoWidgetEngine::logModelData
|
|
74 |
|
|
75 |
Utility function for logging model data
|
|
76 |
*/
|
|
77 |
void InfoWidgetEngine::logModelData()
|
|
78 |
{
|
|
79 |
DPRINT << ": mcn name: " << m_modelData.mcnName();
|
|
80 |
DPRINT << ": mcn type: " << m_modelData.mcnIndicatorType();
|
|
81 |
DPRINT << ": service provider name: " <<
|
|
82 |
m_modelData.serviceProviderName();
|
|
83 |
DPRINT << ": service provider display required: " <<
|
|
84 |
m_modelData.serviceProviderNameDisplayRequired();
|
|
85 |
|
|
86 |
DPRINT << ": homezone text tag: " <<
|
|
87 |
m_modelData.homeZoneTextTag();
|
|
88 |
DPRINT << ": homezone indicator type: " <<
|
|
89 |
m_modelData.homeZoneIndicatorType();
|
|
90 |
DPRINT << ": active line: " <<
|
|
91 |
m_modelData.activeLine();
|
|
92 |
}
|
|
93 |
|
|
94 |
/*!
|
|
95 |
InfoWidgetEngine::modelData
|
|
96 |
|
|
97 |
Getter for model data.
|
|
98 |
*/
|
|
99 |
const InfoWidgetEngine::ModelData& InfoWidgetEngine::modelData() const
|
|
100 |
{
|
|
101 |
DPRINT;
|
|
102 |
return m_modelData;
|
|
103 |
}
|
|
104 |
|
|
105 |
/*!
|
|
106 |
InfoWidgetEngine::updateNetworkDataToModel
|
|
107 |
*/
|
|
108 |
void InfoWidgetEngine::updateNetworkDataToModel()
|
|
109 |
{
|
|
110 |
DPRINT << ": IN";
|
|
111 |
|
|
112 |
m_networkHandler->logCurrentInfo();
|
|
113 |
|
|
114 |
if (m_networkHandler->isOnline()) {
|
|
115 |
// Read network handler data to model data
|
|
116 |
m_modelData.setServiceProviderName(
|
|
117 |
m_networkHandler->serviceProviderName());
|
|
118 |
m_modelData.setServiceProviderNameDisplayRequired(
|
|
119 |
m_networkHandler->serviceProviderNameDisplayRequired());
|
|
120 |
|
|
121 |
m_modelData.setMcnName(m_networkHandler->mcnName());
|
|
122 |
m_modelData.setMcnIndicatorType(
|
|
123 |
m_networkHandler->mcnIndicatorType());
|
|
124 |
|
|
125 |
m_modelData.setHomeZoneIndicatorType(
|
|
126 |
m_networkHandler->homeZoneIndicatorType());
|
|
127 |
m_modelData.setHomeZoneTextTag(
|
|
128 |
m_networkHandler->homeZoneTextTag());
|
|
129 |
} else {
|
|
130 |
// Not registered to network, clear data
|
|
131 |
m_modelData.setServiceProviderName(QString(""));
|
|
132 |
m_modelData.setMcnName(QString(""));
|
|
133 |
m_modelData.setHomeZoneTextTag(QString(""));
|
|
134 |
}
|
|
135 |
|
|
136 |
emit modelChanged();
|
|
137 |
|
|
138 |
DPRINT << ": OUT";
|
|
139 |
}
|
|
140 |
|
|
141 |
/*!
|
|
142 |
InfoWidgetEngine::updateSatDataToModel
|
|
143 |
*/
|
|
144 |
void InfoWidgetEngine::updateSatDataToModel()
|
|
145 |
{
|
|
146 |
DPRINT << ": IN";
|
|
147 |
|
|
148 |
if (m_satHandler) {
|
|
149 |
// Log current network data
|
|
150 |
m_satHandler->logCurrentInfo();
|
|
151 |
// Read SAT handler data to model data
|
|
152 |
m_modelData.setSatDisplayText(
|
|
153 |
m_satHandler->satDisplayText());
|
|
154 |
|
|
155 |
emit modelChanged();
|
|
156 |
}
|
|
157 |
|
|
158 |
DPRINT << ": OUT";
|
|
159 |
}
|
|
160 |
|
|
161 |
/*!
|
|
162 |
InfoWidgetEngine::updateLineDataToModel
|
|
163 |
*/
|
|
164 |
void InfoWidgetEngine::updateLineDataToModel()
|
|
165 |
{
|
|
166 |
DPRINT;
|
|
167 |
}
|
|
168 |
|
|
169 |
/*!
|
|
170 |
InfoWidgetEngine::handleNetworkError
|
|
171 |
*/
|
|
172 |
void InfoWidgetEngine::handleNetworkError(
|
|
173 |
int operation, int errorCode)
|
|
174 |
{
|
|
175 |
DPRINT << ": operation: " << operation <<
|
|
176 |
" error code: " << errorCode;
|
|
177 |
}
|
|
178 |
|
|
179 |
/*!
|
|
180 |
InfoWidgetEngine::handleSatError
|
|
181 |
*/
|
|
182 |
void InfoWidgetEngine::handleSatError(
|
|
183 |
int operation, int errorCode)
|
|
184 |
{
|
|
185 |
DPRINT << ": operation: " << operation <<
|
|
186 |
" error code: " << errorCode;
|
|
187 |
}
|
|
188 |
|
|
189 |
/*!
|
|
190 |
InfoWidgetEngine::handleLineError
|
|
191 |
*/
|
|
192 |
void InfoWidgetEngine::handleLineError(
|
|
193 |
int operation, int errorCode)
|
|
194 |
{
|
|
195 |
DPRINT << ": operation: " << operation << " error code: " << errorCode;
|
|
196 |
}
|
|
197 |
|
|
198 |
/*!
|
|
199 |
InfoWidgetEngine::preferenceChanged
|
|
200 |
*/
|
|
201 |
void InfoWidgetEngine::preferenceChanged(
|
|
202 |
int option, int displaySetting)
|
|
203 |
{
|
|
204 |
DPRINT << "option: " << option << " displaySetting: " << displaySetting;
|
|
205 |
switch(option){
|
|
206 |
case InfoWidgetPreferences::DisplayMcn:
|
|
207 |
if (displaySetting == InfoWidgetPreferences::DisplayOn) {
|
|
208 |
m_networkHandler->enableMcn();
|
|
209 |
} else {
|
|
210 |
m_networkHandler->disableMcn();
|
|
211 |
}
|
|
212 |
break;
|
|
213 |
case InfoWidgetPreferences::DisplaySatText:
|
|
214 |
m_satHandler->connect(displaySetting);
|
|
215 |
break;
|
|
216 |
default:
|
|
217 |
break;
|
|
218 |
}
|
|
219 |
DPRINT << ": OUT";
|
|
220 |
}
|
|
221 |
|
|
222 |
/*!
|
|
223 |
InfoWidgetEngine::suspend
|
|
224 |
|
|
225 |
Called when widget is deactivated
|
|
226 |
and widget should suspend all
|
|
227 |
possible activities
|
|
228 |
*/
|
|
229 |
void InfoWidgetEngine::suspend()
|
|
230 |
{
|
|
231 |
DPRINT;
|
|
232 |
m_networkHandler->suspend();
|
|
233 |
}
|
|
234 |
|
|
235 |
/*!
|
|
236 |
InfoWidgetEngine::preferenceChanged
|
|
237 |
|
|
238 |
Called when widget is activated
|
|
239 |
and widget can resume activities
|
|
240 |
*/
|
|
241 |
void InfoWidgetEngine::resume()
|
|
242 |
{
|
|
243 |
DPRINT;
|
|
244 |
m_networkHandler->resume();
|
|
245 |
}
|
|
246 |
|
|
247 |
|
|
248 |
// End of File.
|
|
249 |
|