author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 12 | cc75c76972ee |
parent 7 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the examples of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
#ifndef QSYM_IAP_UTIL_H |
|
42 |
#define QSYM_IAP_UTIL_H |
|
43 |
||
44 |
// Symbian |
|
45 |
#include <utf.h> |
|
46 |
#include <es_sock.h> |
|
47 |
#include <in_sock.h> |
|
48 |
#include <es_enum.h> |
|
49 |
#include <in_iface.h> |
|
50 |
#include <commdbconnpref.h> |
|
51 |
#include <e32cmn.h> |
|
52 |
||
53 |
// OpenC |
|
54 |
#include <sys/socket.h> |
|
55 |
#include <net/if.h> |
|
56 |
||
57 |
//Qt |
|
58 |
#include <QSettings> |
|
59 |
#include <QStringList> |
|
60 |
//#include <QTextCodec> |
|
61 |
||
62 |
_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
63 |
_LIT(KIapTableIdField, "IAP\Id"); |
0 | 64 |
_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional |
65 |
_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory |
|
66 |
_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory |
|
67 |
_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional |
|
68 |
_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional |
|
69 |
_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional |
|
70 |
||
71 |
const QLatin1String qtOrganizationTag("Trolltech"); |
|
72 |
const QLatin1String qtNetworkModuleTag("QtNetwork"); |
|
73 |
const QLatin1String iapGroupTag("IAP"); |
|
74 |
const QLatin1String iapNamesArrayTag("Names"); |
|
75 |
const QLatin1String iapNameItemTag("Name"); |
|
76 |
||
77 |
static QTextCodec *utf16LETextCodec = 0; |
|
78 |
||
79 |
void clearIapNamesSettings(QSettings &settings) { |
|
80 |
settings.beginGroup(qtNetworkModuleTag); |
|
81 |
settings.beginGroup(iapGroupTag); |
|
82 |
settings.remove(iapNamesArrayTag); |
|
83 |
settings.endGroup(); |
|
84 |
settings.endGroup(); |
|
85 |
} |
|
86 |
||
87 |
void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { |
|
88 |
clearIapNamesSettings(settings); |
|
89 |
settings.beginGroup(qtNetworkModuleTag); |
|
90 |
settings.beginGroup(iapGroupTag); |
|
91 |
settings.beginWriteArray(iapNamesArrayTag); |
|
92 |
for (int index = 0; index < iapNames.size(); ++index) { |
|
93 |
settings.setArrayIndex(index); |
|
94 |
settings.setValue(iapNameItemTag, iapNames.at(index)); |
|
95 |
} |
|
96 |
settings.endArray(); |
|
97 |
settings.endGroup(); |
|
98 |
settings.endGroup(); |
|
99 |
} |
|
100 |
||
101 |
void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { |
|
102 |
settings.beginGroup(qtNetworkModuleTag); |
|
103 |
settings.beginGroup(iapGroupTag); |
|
104 |
int last = settings.beginReadArray(iapNamesArrayTag); |
|
105 |
for (int index = 0; index < last; ++index) { |
|
106 |
settings.setArrayIndex(index); |
|
107 |
iapNames.append(settings.value(iapNameItemTag).toString()); |
|
108 |
} |
|
109 |
settings.endArray(); |
|
110 |
settings.endGroup(); |
|
111 |
settings.endGroup(); |
|
112 |
} |
|
113 |
||
114 |
static QString qt_TNameToQString(TName data) { |
|
115 |
if(utf16LETextCodec == 0) |
|
116 |
utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); |
|
117 |
||
118 |
QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); |
|
119 |
return utf16LETextCodec->toUnicode(tmpByteArray); |
|
120 |
} |
|
121 |
||
122 |
static QString qt_InterfaceInfoL() |
|
123 |
{ |
|
124 |
QString output; |
|
125 |
||
126 |
TBuf8<512> buffer; |
|
127 |
TBuf<128> t; |
|
128 |
TAutoClose<RSocketServ> ss; |
|
129 |
User::LeaveIfError(ss.iObj.Connect()); |
|
130 |
ss.PushL(); |
|
131 |
||
132 |
TAutoClose<RSocket> sock; |
|
133 |
User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); |
|
134 |
sock.PushL(); |
|
135 |
||
136 |
User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); |
|
137 |
||
138 |
TProtocolDesc in; |
|
139 |
User::LeaveIfError(sock.iObj.Info(in)); |
|
140 |
printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); |
|
141 |
||
142 |
TPckgBuf<TSoInetInterfaceInfo> info, next; |
|
143 |
||
144 |
TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); |
|
145 |
if(res!=KErrNone) |
|
146 |
User::Leave(res); |
|
147 |
TInt count = 0; |
|
148 |
while(res==KErrNone) { |
|
149 |
res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); |
|
150 |
||
151 |
if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { |
|
152 |
printf("Interface %d\n", count++); |
|
153 |
||
154 |
printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); |
|
155 |
printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); |
|
156 |
||
157 |
printf("State "); |
|
158 |
switch (info().iState) |
|
159 |
{ |
|
160 |
case EIfPending: |
|
161 |
printf("pending\n"); |
|
162 |
break; |
|
163 |
case EIfUp: |
|
164 |
printf("up\n"); |
|
165 |
break; |
|
166 |
case EIfBusy: |
|
167 |
printf("busy\n"); |
|
168 |
break; |
|
169 |
default: |
|
170 |
printf("down\n"); |
|
171 |
break; |
|
172 |
} |
|
173 |
||
174 |
printf("Mtu %d\n", info().iMtu); |
|
175 |
printf("Speed Metric %d\n", info().iSpeedMetric); |
|
176 |
||
177 |
printf("Features:"); |
|
178 |
info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); |
|
179 |
info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); |
|
180 |
info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); |
|
181 |
info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); |
|
182 |
info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); |
|
183 |
info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); |
|
184 |
info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); |
|
185 |
info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); |
|
186 |
printf("\n"); |
|
187 |
||
188 |
TName address; |
|
189 |
info().iAddress.Output(address); |
|
190 |
printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
191 |
||
192 |
if(info().iAddress.IsLinkLocal()) { |
|
193 |
printf(" -link local\n"); |
|
194 |
} else if(info().iAddress.IsSiteLocal()) { |
|
195 |
printf(" -site local\n"); |
|
196 |
} else { |
|
197 |
printf(" -global\n"); |
|
198 |
} |
|
199 |
||
200 |
info().iNetMask.Output(address); |
|
201 |
printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
202 |
||
203 |
info().iBrdAddr.Output(address); |
|
204 |
printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
205 |
||
206 |
info().iDefGate.Output(address); |
|
207 |
printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
208 |
||
209 |
info().iNameSer1.Output(address); |
|
210 |
printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
211 |
||
212 |
info().iNameSer2.Output(address); |
|
213 |
printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); |
|
214 |
||
215 |
if (info().iHwAddr.Family() != KAFUnspec) { |
|
216 |
printf("Hardware address "); |
|
217 |
TUint j; |
|
218 |
for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { |
|
219 |
if(j < (TUint)info().iHwAddr.Length()) { |
|
220 |
printf("%02X", info().iHwAddr[j]); |
|
221 |
} else { |
|
222 |
printf("??"); |
|
223 |
} |
|
224 |
if(j < sizeof(SSockAddr) + 5) |
|
225 |
printf("-"); |
|
226 |
else |
|
227 |
printf("\n"); |
|
228 |
} |
|
229 |
} |
|
230 |
} |
|
231 |
if(res == KErrNone) { |
|
232 |
info = next; |
|
233 |
printf("\n"); |
|
234 |
} else { |
|
235 |
printf("\n"); |
|
236 |
} |
|
237 |
} |
|
238 |
||
239 |
sock.Pop(); |
|
240 |
ss.Pop(); |
|
241 |
||
242 |
return output; |
|
243 |
} |
|
244 |
||
245 |
static QString qt_RouteInfoL() { |
|
246 |
QString output; |
|
247 |
TAutoClose<RSocketServ> ss; |
|
248 |
User::LeaveIfError(ss.iObj.Connect()); |
|
249 |
ss.PushL(); |
|
250 |
||
251 |
TAutoClose<RSocket> sock; |
|
252 |
User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); |
|
253 |
sock.PushL(); |
|
254 |
||
255 |
TSoInetRouteInfo routeInfo; |
|
256 |
TPckg<TSoInetRouteInfo> routeInfoPkg(routeInfo); |
|
257 |
||
258 |
TName destAddr; |
|
259 |
TName netMask; |
|
260 |
TName gateway; |
|
261 |
TName ifAddr; |
|
262 |
||
263 |
// Begins enumeration of routes by setting this option |
|
264 |
User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); |
|
265 |
||
266 |
// The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone |
|
267 |
for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) |
|
268 |
{ |
|
269 |
// Extract the destination and netmask |
|
270 |
routeInfo.iDstAddr.Output(destAddr); |
|
271 |
routeInfo.iNetMask.Output(netMask); |
|
272 |
routeInfo.iGateway.Output(gateway); |
|
273 |
routeInfo.iIfAddr.Output(ifAddr); |
|
274 |
/* |
|
275 |
if(destAddr.Length() <= 2) |
|
276 |
continue; |
|
277 |
||
278 |
if(netMask.Find(_L("255.255.255.255")) != KErrNotFound |
|
279 |
|| netMask.Find(_L("0.0.0.0")) != KErrNotFound |
|
280 |
|| netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) |
|
281 |
continue; |
|
282 |
*/ |
|
283 |
printf("Route Info #[%i]\n", i); |
|
284 |
printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); |
|
285 |
printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); |
|
286 |
printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); |
|
287 |
printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); |
|
288 |
printf("\n"); |
|
289 |
} |
|
290 |
||
291 |
sock.Pop(); |
|
292 |
ss.Pop(); |
|
293 |
||
294 |
return output; |
|
295 |
} |
|
296 |
||
297 |
QString qt_TDesC2QStringL(const TDesC& aDescriptor) |
|
298 |
{ |
|
299 |
#ifdef QT_NO_UNICODE |
|
300 |
return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); |
|
301 |
#else |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
302 |
return QString((const QChar *)aDescriptor.Ptr(), aDescriptor.Length()); |
0 | 303 |
#endif |
304 |
} |
|
305 |
||
306 |
static bool qt_SetDefaultIapName(const QString &iapName, int &error) { |
|
307 |
struct ifreq ifReq; |
|
308 |
// clear structure |
|
309 |
memset(&ifReq, 0, sizeof(struct ifreq)); |
|
310 |
// set IAP name value |
|
311 |
// make sure it is in UTF8 |
|
312 |
strcpy(ifReq.ifr_name, iapName.toUtf8().data()); |
|
313 |
||
314 |
if(setdefaultif(&ifReq) == 0) { |
|
315 |
// OK |
|
316 |
error = 0; |
|
317 |
return true; |
|
318 |
} else { |
|
319 |
error = errno; |
|
320 |
return false; |
|
321 |
} |
|
322 |
||
323 |
} |
|
324 |
static bool qt_SetDefaultSnapId(const int snapId, int &error) { |
|
325 |
struct ifreq ifReq; |
|
326 |
// clear structure |
|
327 |
memset(&ifReq, 0, sizeof(struct ifreq)); |
|
328 |
// set SNAP ID value |
|
329 |
ifReq.ifr_ifru.snap_id = snapId; |
|
330 |
||
331 |
if(setdefaultif(&ifReq) == 0) { |
|
332 |
// OK |
|
333 |
error = 0; |
|
334 |
return true; |
|
335 |
} else { |
|
336 |
error = errno; |
|
337 |
return false; |
|
338 |
} |
|
339 |
||
340 |
} |
|
341 |
||
342 |
static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { |
|
343 |
if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { |
|
344 |
// no need to update |
|
345 |
} else { |
|
346 |
if(iapNameValue != QString("Easy WLAN")) { |
|
347 |
// new selection alway on top |
|
348 |
iapNames.removeAll(iapNameValue); |
|
349 |
iapNames.prepend(iapNameValue); |
|
350 |
writeIapNamesSettings(settings, iapNames); |
|
351 |
} else { |
|
352 |
// Unbeliveable ... if IAP dodn't exist before |
|
353 |
// no matter what you choose from IAP selection list |
|
354 |
// you will get "Easy WLAN" as IAP name value |
|
355 |
||
356 |
// somehow commsdb is not in sync |
|
357 |
} |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
static QString qt_OfferIapDialog() { |
|
362 |
TBuf8<256> iapName; |
|
363 |
||
364 |
RSocketServ socketServ; |
|
365 |
CleanupClosePushL(socketServ); |
|
366 |
||
367 |
RConnection connection; |
|
368 |
CleanupClosePushL(connection); |
|
369 |
||
370 |
socketServ.Connect(); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
371 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
372 |
TCommDbConnPref prefs; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
373 |
prefs.SetDialogPreference(ECommDbDialogPrefPrompt); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
374 |
|
0 | 375 |
connection.Open(socketServ); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
376 |
connection.Start(prefs); |
0 | 377 |
|
378 |
connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); |
|
379 |
//connection.Stop(); |
|
380 |
||
381 |
iapName.ZeroTerminate(); |
|
382 |
QString strIapName((char*)iapName.Ptr()); |
|
383 |
||
384 |
int error = 0; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
385 |
if(!strIapName.isEmpty()) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
386 |
if(!qt_SetDefaultIapName(strIapName, error)) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
387 |
//printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
388 |
strIapName = QString(""); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
389 |
} |
0 | 390 |
} |
391 |
||
392 |
CleanupStack::PopAndDestroy(&connection); |
|
393 |
CleanupStack::PopAndDestroy(&socketServ); |
|
394 |
||
395 |
return strIapName; |
|
396 |
} |
|
397 |
||
398 |
static QString qt_CheckForActiveConnection() { |
|
399 |
TUint count; |
|
400 |
||
401 |
RSocketServ serv; |
|
402 |
CleanupClosePushL(serv); |
|
403 |
||
404 |
RConnection conn; |
|
405 |
CleanupClosePushL(conn); |
|
406 |
||
407 |
serv.Connect(); |
|
408 |
conn.Open(serv); |
|
409 |
||
410 |
TConnectionInfoBuf connInfo; |
|
411 |
||
412 |
TBuf8<256> iapName; |
|
413 |
TBuf8<256> iapServiceType; |
|
414 |
||
415 |
QString strIapName; |
|
416 |
||
417 |
if (conn.EnumerateConnections(count) == KErrNone) { |
|
418 |
if(count > 0) { |
|
419 |
for (TUint i = 1; i <= count; i++) { |
|
420 |
if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { |
|
421 |
RConnection tempConn; |
|
422 |
CleanupClosePushL(tempConn); |
|
423 |
tempConn.Open(serv); |
|
424 |
if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { |
|
425 |
tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); |
|
426 |
tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); |
|
427 |
//tempConn.Stop(); |
|
428 |
iapName.ZeroTerminate(); |
|
429 |
iapServiceType.ZeroTerminate(); |
|
430 |
||
431 |
// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { |
|
432 |
// activeLanConnectionFound = ETrue; |
|
433 |
// break; |
|
434 |
// } |
|
435 |
strIapName = QString((char*)iapName.Ptr()); |
|
436 |
int error = 0; |
|
437 |
if(!qt_SetDefaultIapName(strIapName, error)) { |
|
438 |
//printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); |
|
439 |
strIapName = QString(""); |
|
440 |
} |
|
441 |
||
442 |
CleanupStack::PopAndDestroy(&tempConn); |
|
443 |
break; |
|
444 |
} |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
//conn.Stop(); |
|
451 |
||
452 |
CleanupStack::PopAndDestroy(&conn); |
|
453 |
CleanupStack::PopAndDestroy(&serv); |
|
454 |
||
455 |
return strIapName; |
|
456 |
} |
|
457 |
||
458 |
static QString qt_CheckSettingsForConnection(QStringList& iapNames) { |
|
459 |
QString strIapName; |
|
460 |
for(int index = 0; index < iapNames.size(); ++index) { |
|
461 |
strIapName = iapNames.at(index); |
|
462 |
int error = 0; |
|
463 |
if(!qt_SetDefaultIapName(strIapName, error)) { |
|
464 |
//printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); |
|
465 |
strIapName = QString(""); |
|
466 |
} else { |
|
467 |
return strIapName; |
|
468 |
} |
|
469 |
} |
|
470 |
return strIapName; |
|
471 |
} |
|
472 |
||
473 |
static void qt_SetDefaultIapL() |
|
474 |
{ |
|
475 |
// settings @ /c/data/.config/Trolltech.com |
|
476 |
QSettings settings(QSettings::UserScope, qtOrganizationTag); |
|
477 |
// populate iap name list |
|
478 |
QStringList iapNames; |
|
479 |
readIapNamesSettings(settings, iapNames); |
|
480 |
||
481 |
QString iapNameValue; |
|
482 |
||
483 |
iapNameValue = qt_CheckForActiveConnection(); |
|
484 |
||
485 |
if(!iapNameValue.isEmpty()) { |
|
486 |
qt_SaveIapName(settings, iapNames, iapNameValue); |
|
487 |
return; |
|
488 |
} |
|
489 |
||
490 |
iapNameValue = qt_CheckSettingsForConnection(iapNames); |
|
491 |
||
492 |
if(!iapNameValue.isEmpty()) { |
|
493 |
qt_SaveIapName(settings, iapNames, iapNameValue); |
|
494 |
return; |
|
495 |
} |
|
496 |
||
497 |
/* |
|
498 |
* no active LAN connections yet |
|
499 |
* no IAP in settings |
|
500 |
* offer IAP dialog to user |
|
501 |
*/ |
|
502 |
iapNameValue = qt_OfferIapDialog(); |
|
503 |
qt_SaveIapName(settings, iapNames, iapNameValue); |
|
504 |
return; |
|
505 |
||
506 |
} |
|
507 |
||
508 |
static int qt_SetDefaultIap() |
|
509 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
#ifndef __WINS__ |
0 | 511 |
TRAPD(err1, qt_SetDefaultIapL()); |
512 |
// TRAPD(err2, qt_InterfaceInfoL()); |
|
513 |
// TRAPD(err3, qt_RouteInfoL()); |
|
514 |
return err1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
515 |
#else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
516 |
return 0; // IAP dialog not required for emulator |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
517 |
#endif |
0 | 518 |
} |
519 |
||
520 |
#endif // QSYM_IAP_UTIL_H |