~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/network-ftp-sym-iap-util-h.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

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