Qt 4.8
main.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qnativewifiengine.h"
43 #include "platformdefs.h"
44 
45 #include <QtCore/private/qsystemlibrary_p.h>
46 
47 #include <QtNetwork/private/qbearerplugin_p.h>
48 
49 #ifndef QT_NO_BEARERMANAGEMENT
50 
52 
53 static void resolveLibrary()
54 {
55  static bool triedResolve = false;
56  if (!triedResolve) {
57  QSystemLibrary wlanapi(QLatin1String("wlanapi"));
58  if (wlanapi.load()) {
60  wlanapi.resolve("WlanOpenHandle");
62  wlanapi.resolve("WlanRegisterNotification");
64  wlanapi.resolve("WlanEnumInterfaces");
66  wlanapi.resolve("WlanGetAvailableNetworkList");
68  wlanapi.resolve("WlanQueryInterface");
70  wlanapi.resolve("WlanConnect");
72  wlanapi.resolve("WlanDisconnect");
74  wlanapi.resolve("WlanScan");
76  wlanapi.resolve("WlanFreeMemory");
78  wlanapi.resolve("WlanCloseHandle");
79  }
80  triedResolve = true;
81  }
82 }
83 
85 {
86 public:
89 
90  QStringList keys() const;
91  QBearerEngine *create(const QString &key) const;
92 };
93 
95 {
96 }
97 
99 {
100 }
101 
103 {
104  return QStringList() << QLatin1String("nativewifi");
105 }
106 
108 {
109  if (key != QLatin1String("nativewifi"))
110  return 0;
111 
112  resolveLibrary();
113 
114  // native wifi dll not available
116  return 0;
117 
118  QNativeWifiEngine *engine = new QNativeWifiEngine;
119 
120  // could not initialise subsystem
121  if (engine && !engine->available()) {
122  delete engine;
123  return 0;
124  }
125 
126  return engine;
127 }
128 
130 Q_EXPORT_PLUGIN2(qnativewifibearer, QNativeWifiEnginePlugin)
131 
133 
134 #endif // QT_NO_BEARERMANAGEMENT
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
DWORD(WINAPI * WlanQueryInterfaceProto)(HANDLE hClientHandle, const GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved, PDWORD pdwDataSize, PVOID *ppData, WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType)
Definition: platformdefs.h:303
QBearerEngine * create(const QString &key) const
Definition: main.cpp:107
WlanConnectProto local_WlanConnect
DWORD(WINAPI * WlanCloseHandleProto)(HANDLE hClientHandle, PVOID pReserved)
Definition: platformdefs.h:314
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
VOID(WINAPI * WlanFreeMemoryProto)(PVOID pMemory)
Definition: platformdefs.h:313
QStringList keys() const
Definition: main.cpp:102
DWORD(WINAPI * WlanOpenHandleProto)(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle)
Definition: platformdefs.h:292
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool load(bool onlySystemDirectory=true)
WlanOpenHandleProto local_WlanOpenHandle
WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList
DWORD(WINAPI * WlanConnectProto)(HANDLE hClientHandle, const GUID *pInterfaceGuid, const WLAN_CONNECTION_PARAMETERS *pConnectionParameters, PVOID pReserved)
Definition: platformdefs.h:306
Q_EXPORT_PLUGIN2(qjpcodecs, JPTextCodecs)
Q_EXPORT_STATIC_PLUGIN(JPTextCodecs)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
DWORD(WINAPI * WlanGetAvailableNetworkListProto)(HANDLE hClientHandle, const GUID *pInterfaceGuid, DWORD dwFlags, PVOID pReserved, WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList)
Definition: platformdefs.h:300
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
WlanScanProto local_WlanScan
WlanFreeMemoryProto local_WlanFreeMemory
static void resolveLibrary()
Definition: main.cpp:53
WlanDisconnectProto local_WlanDisconnect
WlanEnumInterfacesProto local_WlanEnumInterfaces
DWORD(WINAPI * WlanEnumInterfacesProto)(HANDLE hClientHandle, PVOID pReserved, WLAN_INTERFACE_INFO_LIST **ppInterfaceList)
Definition: platformdefs.h:298
void * resolve(const char *symbol)
int key
WlanRegisterNotificationProto local_WlanRegisterNotification
DWORD(WINAPI * WlanScanProto)(HANDLE hClientHandle, const GUID *pInterfaceGuid, const DOT11_SSID *pDot11Ssid, const WLAN_RAW_DATA *pIeData, PVOID pReserved)
Definition: platformdefs.h:311
WlanQueryInterfaceProto local_WlanQueryInterface
DWORD(WINAPI * WlanRegisterNotificationProto)(HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate, WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext, PVOID pReserved, PDWORD pdwPrevNotifSource)
Definition: platformdefs.h:294
DWORD(WINAPI * WlanDisconnectProto)(HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved)
Definition: platformdefs.h:309
WlanCloseHandleProto local_WlanCloseHandle