qtmobility/src/bearer/qnlaengine_win.cpp
branchRCL_3
changeset 10 cd2778e5acfe
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     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 
       
    42 #include "qnlaengine_win_p.h"
       
    43 #include "qnetworkconfiguration_p.h"
       
    44 
       
    45 #include <QtCore/qthread.h>
       
    46 #include <QtCore/qmutex.h>
       
    47 #include <QtCore/qcoreapplication.h>
       
    48 #include <QtCore/qstringlist.h>
       
    49 
       
    50 #include <QtCore/qdebug.h>
       
    51 
       
    52 #include "qnetworksessionengine_win_p.h"
       
    53 
       
    54 QTM_BEGIN_NAMESPACE
       
    55 
       
    56 Q_GLOBAL_STATIC(QNlaEngine, nlaEngine)
       
    57 
       
    58 QWindowsSockInit::QWindowsSockInit()
       
    59 :   version(0)
       
    60 {
       
    61     //### should we try for 2.2 on all platforms ??
       
    62     WSAData wsadata;
       
    63 
       
    64     // IPv6 requires Winsock v2.0 or better.
       
    65     if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
       
    66         qWarning("QBearerManagementAPI: WinSock v2.0 initialization failed.");
       
    67     } else {
       
    68         version = 0x20;
       
    69     }
       
    70 }
       
    71 
       
    72 QWindowsSockInit::~QWindowsSockInit()
       
    73 {
       
    74     WSACleanup();
       
    75 }
       
    76 
       
    77 #ifdef BEARER_MANAGEMENT_DEBUG
       
    78 static void printBlob(NLA_BLOB *blob)
       
    79 {
       
    80     qDebug() << "==== BEGIN NLA_BLOB ====";
       
    81 
       
    82     qDebug() << "type:" << blob->header.type;
       
    83     qDebug() << "size:" << blob->header.dwSize;
       
    84     qDebug() << "next offset:" << blob->header.nextOffset;
       
    85 
       
    86     switch (blob->header.type) {
       
    87     case NLA_RAW_DATA:
       
    88         qDebug() << "Raw Data";
       
    89         qDebug() << '\t' << blob->data.rawData;
       
    90         break;
       
    91     case NLA_INTERFACE:
       
    92         qDebug() << "Interface";
       
    93         qDebug() << "\ttype:" << blob->data.interfaceData.dwType;
       
    94         qDebug() << "\tspeed:" << blob->data.interfaceData.dwSpeed;
       
    95         qDebug() << "\tadapter:" << blob->data.interfaceData.adapterName;
       
    96         break;
       
    97     case NLA_802_1X_LOCATION:
       
    98         qDebug() << "802.1x Location";
       
    99         qDebug() << '\t' << blob->data.locationData.information;
       
   100         break;
       
   101     case NLA_CONNECTIVITY:
       
   102         qDebug() << "Connectivity";
       
   103         qDebug() << "\ttype:" << blob->data.connectivity.type;
       
   104         qDebug() << "\tinternet:" << blob->data.connectivity.internet;
       
   105         break;
       
   106     case NLA_ICS:
       
   107         qDebug() << "ICS";
       
   108         qDebug() << "\tspeed:" << blob->data.ICS.remote.speed;
       
   109         qDebug() << "\ttype:" << blob->data.ICS.remote.type;
       
   110         qDebug() << "\tstate:" << blob->data.ICS.remote.state;
       
   111         qDebug() << "\tmachine name:" << blob->data.ICS.remote.machineName;
       
   112         qDebug() << "\tshared adapter name:" << blob->data.ICS.remote.sharedAdapterName;
       
   113         break;
       
   114     default:
       
   115         qDebug() << "UNKNOWN BLOB TYPE";
       
   116     }
       
   117 
       
   118     qDebug() << "===== END NLA_BLOB =====";
       
   119 }
       
   120 #endif
       
   121 
       
   122 static QString qGetInterfaceType(const QString &interface)
       
   123 {
       
   124 #ifdef Q_OS_WINCE
       
   125     Q_UNUSED(interface)
       
   126 #else
       
   127     unsigned long oid;
       
   128     DWORD bytesWritten;
       
   129 
       
   130     NDIS_MEDIUM medium;
       
   131     NDIS_PHYSICAL_MEDIUM physicalMedium;
       
   132 
       
   133     HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
       
   134                                FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
       
   135     if (handle == INVALID_HANDLE_VALUE)
       
   136         return QLatin1String("Unknown");
       
   137 
       
   138     oid = OID_GEN_MEDIA_SUPPORTED;
       
   139     bytesWritten = 0;
       
   140     bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
       
   141                                   &medium, sizeof(medium), &bytesWritten, 0);
       
   142     if (!result) {
       
   143         CloseHandle(handle);
       
   144         return QLatin1String("Unknown");
       
   145     }
       
   146 
       
   147     oid = OID_GEN_PHYSICAL_MEDIUM;
       
   148     bytesWritten = 0;
       
   149     result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
       
   150                              &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
       
   151     if (!result) {
       
   152         CloseHandle(handle);
       
   153 
       
   154         if (medium == NdisMedium802_3)
       
   155             return QLatin1String("Ethernet");
       
   156         else
       
   157             return QLatin1String("Unknown");
       
   158     }
       
   159 
       
   160     CloseHandle(handle);
       
   161 
       
   162     if (medium == NdisMedium802_3) {
       
   163         switch (physicalMedium) {
       
   164         case NdisPhysicalMediumWirelessLan:
       
   165             return QLatin1String("WLAN");
       
   166         case NdisPhysicalMediumBluetooth:
       
   167             return QLatin1String("Bluetooth");
       
   168         case NdisPhysicalMediumWiMax:
       
   169             return QLatin1String("WiMAX");
       
   170         default:
       
   171 #ifdef BEARER_MANAGEMENT_DEBUG
       
   172             qDebug() << "Physical Medium" << physicalMedium;
       
   173 #endif
       
   174             return QLatin1String("Ethernet");
       
   175         }
       
   176     }
       
   177 
       
   178 #ifdef BEARER_MANAGEMENT_DEBUG
       
   179     qDebug() << medium << physicalMedium;
       
   180 #endif
       
   181 
       
   182 #endif
       
   183 
       
   184     return QLatin1String("Unknown");
       
   185 }
       
   186 
       
   187 class QNlaThread : public QThread
       
   188 {
       
   189     Q_OBJECT
       
   190 
       
   191 public:
       
   192     QNlaThread(QNlaEngine *parent = 0);
       
   193     ~QNlaThread();
       
   194 
       
   195     QList<QNetworkConfigurationPrivate *> getConfigurations();
       
   196 
       
   197     void forceUpdate();
       
   198 
       
   199 protected:
       
   200     virtual void run();
       
   201 
       
   202 private:
       
   203     void updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs);
       
   204     DWORD parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const;
       
   205     QNetworkConfigurationPrivate *parseQuerySet(const WSAQUERYSET *querySet) const;
       
   206     void fetchConfigurations();
       
   207 
       
   208 signals:
       
   209     void networksChanged();
       
   210 
       
   211 private:
       
   212     QMutex mutex;
       
   213     HANDLE handle;
       
   214     bool done;
       
   215     QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
       
   216 };
       
   217 
       
   218 QNlaThread::QNlaThread(QNlaEngine *parent)
       
   219 :   QThread(parent), handle(0), done(false)
       
   220 {
       
   221 }
       
   222 
       
   223 QNlaThread::~QNlaThread()
       
   224 {
       
   225     mutex.lock();
       
   226 
       
   227     done = true;
       
   228 
       
   229     if (handle) {
       
   230         /* cancel completion event */
       
   231         if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
       
   232             qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
       
   233     }
       
   234     mutex.unlock();
       
   235 
       
   236     wait();
       
   237 }
       
   238 
       
   239 QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations()
       
   240 {
       
   241     QMutexLocker locker(&mutex);
       
   242 
       
   243     QList<QNetworkConfigurationPrivate *> foundConfigurations;
       
   244 
       
   245     for (int i = 0; i < fetchedConfigurations.count(); ++i) {
       
   246         QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
       
   247         config->name = fetchedConfigurations.at(i)->name;
       
   248         config->isValid = fetchedConfigurations.at(i)->isValid;
       
   249         config->id = fetchedConfigurations.at(i)->id;
       
   250         config->state = fetchedConfigurations.at(i)->state;
       
   251         config->type = fetchedConfigurations.at(i)->type;
       
   252         config->roamingSupported = fetchedConfigurations.at(i)->roamingSupported;
       
   253         config->purpose = fetchedConfigurations.at(i)->purpose;
       
   254         config->internet = fetchedConfigurations.at(i)->internet;
       
   255         if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
       
   256             config->bearer = engine->bearerName(config->id);
       
   257         }
       
   258 
       
   259         foundConfigurations.append(config);
       
   260     }
       
   261 
       
   262     return foundConfigurations;
       
   263 }
       
   264 
       
   265 void QNlaThread::forceUpdate()
       
   266 {
       
   267     mutex.lock();
       
   268 
       
   269     if (handle) {
       
   270         /* cancel completion event */
       
   271         if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
       
   272             qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
       
   273         handle = 0;
       
   274     }
       
   275     mutex.unlock();
       
   276 }
       
   277 
       
   278 void QNlaThread::run()
       
   279 {
       
   280     WSAEVENT changeEvent = WSACreateEvent();
       
   281     if (changeEvent == WSA_INVALID_EVENT) {
       
   282         qWarning("WSACreateEvent error %d", WSAGetLastError());
       
   283         return;
       
   284     }
       
   285 
       
   286     while (true) {
       
   287         fetchConfigurations();
       
   288 
       
   289         WSAQUERYSET qsRestrictions;
       
   290 
       
   291         memset(&qsRestrictions, 0, sizeof(qsRestrictions));
       
   292         qsRestrictions.dwSize = sizeof(qsRestrictions);
       
   293         qsRestrictions.dwNameSpace = NS_NLA;
       
   294 
       
   295         mutex.lock();
       
   296         if (done) {
       
   297             mutex.unlock();
       
   298             break;
       
   299         }
       
   300         int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL, &handle);
       
   301         mutex.unlock();
       
   302 
       
   303         if (result == SOCKET_ERROR) {
       
   304             qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
       
   305             break;
       
   306         }
       
   307 
       
   308         WSACOMPLETION completion;
       
   309         WSAOVERLAPPED overlapped;
       
   310 
       
   311         memset(&overlapped, 0, sizeof(overlapped));
       
   312         overlapped.hEvent = changeEvent;
       
   313 
       
   314         memset(&completion, 0, sizeof(completion));
       
   315         completion.Type = NSP_NOTIFY_EVENT;
       
   316         completion.Parameters.Event.lpOverlapped = &overlapped;
       
   317 
       
   318         DWORD bytesReturned = 0;
       
   319         result = WSANSPIoctl(handle, SIO_NSP_NOTIFY_CHANGE, 0, 0, 0, 0,
       
   320                              &bytesReturned, &completion);
       
   321         if (result == SOCKET_ERROR) {
       
   322             int error = WSAGetLastError();
       
   323             if (error != WSA_IO_PENDING) {
       
   324                 qWarning("WSANSPIoctl error %d", error);
       
   325                 break;
       
   326             }
       
   327         }
       
   328 
       
   329 #ifndef Q_OS_WINCE
       
   330         // Not interested in unrelated IO completion events
       
   331         // although we also don't want to block them
       
   332         while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION) {}
       
   333 #else
       
   334         WaitForSingleObject(changeEvent, WSA_INFINITE);
       
   335 #endif
       
   336 
       
   337         mutex.lock();
       
   338         if (handle) {
       
   339             result = WSALookupServiceEnd(handle);
       
   340             if (result == SOCKET_ERROR) {
       
   341                 qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
       
   342                 mutex.unlock();
       
   343                 break;
       
   344             }
       
   345             handle = 0;
       
   346         }
       
   347         mutex.unlock();
       
   348     }
       
   349 
       
   350     WSACloseEvent(changeEvent);
       
   351 }
       
   352 
       
   353 void QNlaThread::updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs)
       
   354 {
       
   355     mutex.lock();
       
   356 
       
   357     while (!fetchedConfigurations.isEmpty())
       
   358         delete fetchedConfigurations.takeFirst();
       
   359 
       
   360     fetchedConfigurations = configs;
       
   361 
       
   362     mutex.unlock();
       
   363 
       
   364     emit networksChanged();
       
   365 }
       
   366 
       
   367 DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const
       
   368 {
       
   369 #ifdef BEARER_MANAGEMENT_DEBUG
       
   370     printBlob(blob);
       
   371 #endif
       
   372 
       
   373     switch (blob->header.type) {
       
   374     case NLA_RAW_DATA:
       
   375 #ifdef BEARER_MANAGEMENT_DEBUG
       
   376         qWarning("%s: unhandled header type NLA_RAW_DATA", __FUNCTION__);
       
   377 #endif
       
   378         break;
       
   379     case NLA_INTERFACE:
       
   380         cpPriv->state = QNetworkConfiguration::Active;
       
   381         if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
       
   382             engine->configurationInterface[cpPriv->id.toUInt()] =
       
   383                 QString(blob->data.interfaceData.adapterName);
       
   384         }
       
   385         break;
       
   386     case NLA_802_1X_LOCATION:
       
   387 #ifdef BEARER_MANAGEMENT_DEBUG
       
   388         qWarning("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__);
       
   389 #endif
       
   390         break;
       
   391     case NLA_CONNECTIVITY:
       
   392         if (blob->data.connectivity.internet == NLA_INTERNET_YES)
       
   393             cpPriv->internet = true;
       
   394         else
       
   395             cpPriv->internet = false;
       
   396 #ifdef BEARER_MANAGEMENT_DEBUG
       
   397         qWarning("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__);
       
   398 #endif
       
   399         break;
       
   400     case NLA_ICS:
       
   401 #ifdef BEARER_MANAGEMENT_DEBUG
       
   402         qWarning("%s: unhandled header type NLA_ICS", __FUNCTION__);
       
   403 #endif
       
   404         break;
       
   405     default:
       
   406 #ifdef BEARER_MANAGEMENT_DEBUG
       
   407         qWarning("%s: unhandled header type %d", __FUNCTION__, blob->header.type);
       
   408 #endif
       
   409         ;
       
   410     }
       
   411 
       
   412     return blob->header.nextOffset;
       
   413 }
       
   414 
       
   415 QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *querySet) const
       
   416 {
       
   417     QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
       
   418 
       
   419     cpPriv->name = QString::fromWCharArray(querySet->lpszServiceInstanceName);
       
   420     cpPriv->isValid = true;
       
   421     cpPriv->id = QString::number(qHash(QLatin1String("NLA:") + cpPriv->name));
       
   422     cpPriv->state = QNetworkConfiguration::Defined;
       
   423     cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
       
   424 
       
   425 #ifdef BEARER_MANAGEMENT_DEBUG
       
   426     qDebug() << "size:" << querySet->dwSize;
       
   427     qDebug() << "service instance name:" << QString::fromUtf16(querySet->lpszServiceInstanceName);
       
   428     qDebug() << "service class id:" << querySet->lpServiceClassId;
       
   429     qDebug() << "version:" << querySet->lpVersion;
       
   430     qDebug() << "comment:" << QString::fromUtf16(querySet->lpszComment);
       
   431     qDebug() << "namespace:" << querySet->dwNameSpace;
       
   432     qDebug() << "namespace provider id:" << querySet->lpNSProviderId;
       
   433     qDebug() << "context:" << QString::fromUtf16(querySet->lpszContext);
       
   434     qDebug() << "number of protocols:" << querySet->dwNumberOfProtocols;
       
   435     qDebug() << "protocols:" << querySet->lpafpProtocols;
       
   436     qDebug() << "query string:" << QString::fromUtf16(querySet->lpszQueryString);
       
   437     qDebug() << "number of cs addresses:" << querySet->dwNumberOfCsAddrs;
       
   438     qDebug() << "cs addresses:" << querySet->lpcsaBuffer;
       
   439     qDebug() << "output flags:" << querySet->dwOutputFlags;
       
   440 #endif
       
   441 
       
   442     if (querySet->lpBlob) {
       
   443 #ifdef BEARER_MANAGEMENT_DEBUG
       
   444         qDebug() << "blob size:" << querySet->lpBlob->cbSize;
       
   445         qDebug() << "blob data:" << querySet->lpBlob->pBlobData;
       
   446 #endif
       
   447 
       
   448         DWORD offset = 0;
       
   449         do {
       
   450             NLA_BLOB *blob = reinterpret_cast<NLA_BLOB *>(querySet->lpBlob->pBlobData + offset);
       
   451             DWORD nextOffset = parseBlob(blob, cpPriv);
       
   452             if (nextOffset == offset)
       
   453                 break;
       
   454             else
       
   455                 offset = nextOffset;
       
   456         } while (offset != 0 && offset < querySet->lpBlob->cbSize);
       
   457     }
       
   458 
       
   459     return cpPriv;
       
   460 }
       
   461 
       
   462 void QNlaThread::fetchConfigurations()
       
   463 {
       
   464     QList<QNetworkConfigurationPrivate *> foundConfigurations;
       
   465 
       
   466     WSAQUERYSET qsRestrictions;
       
   467     HANDLE hLookup = 0;
       
   468 
       
   469     memset(&qsRestrictions, 0, sizeof(qsRestrictions));
       
   470     qsRestrictions.dwSize = sizeof(qsRestrictions);
       
   471     qsRestrictions.dwNameSpace = NS_NLA;
       
   472 
       
   473     int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL | LUP_DEEP, &hLookup);
       
   474     if (result == SOCKET_ERROR) {
       
   475         qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
       
   476         mutex.lock();
       
   477         fetchedConfigurations.clear();
       
   478         mutex.unlock();
       
   479     }
       
   480 
       
   481     char buffer[0x10000];
       
   482     while (result == 0) {
       
   483         DWORD bufferLength = sizeof(buffer);
       
   484         result = WSALookupServiceNext(hLookup, LUP_RETURN_ALL,
       
   485                                       &bufferLength, reinterpret_cast<WSAQUERYSET *>(buffer));
       
   486 
       
   487         if (result == SOCKET_ERROR) {
       
   488             int error = WSAGetLastError();
       
   489 
       
   490             if (error == WSA_E_NO_MORE)
       
   491                 break;
       
   492 
       
   493             if (error == WSAEFAULT) {
       
   494                 qDebug() << "buffer not big enough" << bufferLength;
       
   495                 break;
       
   496             }
       
   497 
       
   498             qWarning("WSALookupServiceNext error %d", WSAGetLastError());
       
   499             break;
       
   500         }
       
   501 
       
   502         QNetworkConfigurationPrivate *cpPriv =
       
   503             parseQuerySet(reinterpret_cast<WSAQUERYSET *>(buffer));
       
   504 
       
   505         foundConfigurations.append(cpPriv);
       
   506     }
       
   507 
       
   508     if (hLookup) {
       
   509         result = WSALookupServiceEnd(hLookup);
       
   510         if (result == SOCKET_ERROR) {
       
   511             qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
       
   512         }
       
   513     }
       
   514 
       
   515     updateConfigurations(foundConfigurations);
       
   516 }
       
   517 
       
   518 QNlaEngine::QNlaEngine(QObject *parent)
       
   519 :   QNetworkSessionEngine(parent), nlaThread(0)
       
   520 {
       
   521     nlaThread = new QNlaThread(this);
       
   522     connect(nlaThread, SIGNAL(networksChanged()),
       
   523             this, SIGNAL(configurationsChanged()));
       
   524     nlaThread->start();
       
   525 
       
   526     qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
       
   527 }
       
   528 
       
   529 QNlaEngine::~QNlaEngine()
       
   530 {
       
   531     delete nlaThread;
       
   532 }
       
   533 
       
   534 QList<QNetworkConfigurationPrivate *> QNlaEngine::getConfigurations(bool *ok)
       
   535 {
       
   536     if (ok)
       
   537         *ok = true;
       
   538 
       
   539     return nlaThread->getConfigurations();
       
   540 }
       
   541 
       
   542 QString QNlaEngine::getInterfaceFromId(const QString &id)
       
   543 {
       
   544     return configurationInterface.value(id.toUInt());
       
   545 }
       
   546 
       
   547 bool QNlaEngine::hasIdentifier(const QString &id)
       
   548 {
       
   549     if (configurationInterface.contains(id.toUInt()))
       
   550         return true;
       
   551 
       
   552     bool result = false;
       
   553     QList<QNetworkConfigurationPrivate *> l = nlaThread->getConfigurations();
       
   554     while (!l.isEmpty()) {
       
   555         QNetworkConfigurationPrivate* cpPriv = l.takeFirst();
       
   556         if (!result && cpPriv->id == id) {
       
   557             result = true;
       
   558         }
       
   559         delete cpPriv;
       
   560     }
       
   561    
       
   562     return result; 
       
   563 }
       
   564 
       
   565 QString QNlaEngine::bearerName(const QString &id)
       
   566 {
       
   567     QString interface = getInterfaceFromId(id);
       
   568 
       
   569     if (interface.isEmpty())
       
   570         return QString();
       
   571 
       
   572     return qGetInterfaceType(interface);
       
   573 }
       
   574 
       
   575 void QNlaEngine::connectToId(const QString &id)
       
   576 {
       
   577     emit connectionError(id, OperationNotSupported);
       
   578 }
       
   579 
       
   580 void QNlaEngine::disconnectFromId(const QString &id)
       
   581 {
       
   582     emit connectionError(id, OperationNotSupported);
       
   583 }
       
   584 
       
   585 void QNlaEngine::requestUpdate()
       
   586 {
       
   587     nlaThread->forceUpdate();
       
   588 }
       
   589 
       
   590 QNlaEngine *QNlaEngine::instance()
       
   591 {
       
   592     return nlaEngine();
       
   593 }
       
   594 
       
   595 #include "qnlaengine_win.moc"
       
   596 #include "moc_qnlaengine_win_p.cpp"
       
   597 QTM_END_NAMESPACE
       
   598 
       
   599 
       
   600