44 #include "../qnetworksession_impl.h" 46 #include <QtNetwork/private/qnetworkconfiguration_p.h> 48 #include <QtCore/qstringlist.h> 49 #include <QtCore/qcoreapplication.h> 51 #include <QtCore/qdebug.h> 53 #ifndef QT_NO_BEARERMANAGEMENT 81 #ifdef BEARER_MANAGEMENT_DEBUG 87 #ifdef BEARER_MANAGEMENT_DEBUG 117 if (result != ERROR_SUCCESS) {
118 #ifdef BEARER_MANAGEMENT_DEBUG 119 qDebug(
"%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
136 if (result != ERROR_SUCCESS) {
137 #ifdef BEARER_MANAGEMENT_DEBUG 138 qDebug(
"%s: WlanGetAvailableNetworkList failed with error %ld\n",
139 __FUNCTION__, result);
146 for (
unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
178 if (seenNetworks.
contains(networkName))
181 seenNetworks.
append(networkName);
186 bool changed =
false;
195 if (ptr->
name != networkName) {
196 ptr->
name = networkName;
200 if (ptr->
state != state) {
215 ptr->
name = networkName;
258 if (result != ERROR_SUCCESS) {
259 #ifdef BEARER_MANAGEMENT_DEBUG 260 qDebug(
"%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
272 reinterpret_cast<PVOID *>(&connectionAttributes), 0);
273 if (result != ERROR_SUCCESS) {
274 #ifdef BEARER_MANAGEMENT_DEBUG 275 if (result != ERROR_INVALID_STATE)
276 qDebug(
"%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
284 QString guid(
"{%1-%2-%3-%4%5-%6%7%8%9%10%11}");
286 guid = guid.
arg(interface.InterfaceGuid.Data1, 8, 16,
QChar(
'0'));
287 guid = guid.
arg(interface.InterfaceGuid.Data2, 4, 16,
QChar(
'0'));
288 guid = guid.
arg(interface.InterfaceGuid.Data3, 4, 16,
QChar(
'0'));
289 for (
int i = 0; i < 8; ++i)
290 guid = guid.
arg(interface.InterfaceGuid.Data4[i], 2, 16,
QChar(
'0'));
316 if (result != ERROR_SUCCESS) {
317 #ifdef BEARER_MANAGEMENT_DEBUG 318 qDebug(
"%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
329 if (result != ERROR_SUCCESS) {
330 #ifdef BEARER_MANAGEMENT_DEBUG 331 qDebug(
"%s: WlanGetAvailableNetworkList failed with error %ld\n",
332 __FUNCTION__, result);
337 for (
unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
376 if (result != ERROR_SUCCESS) {
377 #ifdef BEARER_MANAGEMENT_DEBUG 378 qDebug(
"%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
393 if (result != ERROR_SUCCESS) {
394 #ifdef BEARER_MANAGEMENT_DEBUG 395 qDebug(
"%s: WlanGetAvailableNetworkList failed with error %ld\n",
396 __FUNCTION__, result);
401 for (
unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
424 if (result != ERROR_SUCCESS) {
425 #ifdef BEARER_MANAGEMENT_DEBUG 426 qDebug(
"%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
456 QString interface = getInterfaceFromId(id);
458 if (interface.isEmpty()) {
472 for (
int i = 0; i < 6; ++i)
476 if (result != ERROR_SUCCESS) {
477 #ifdef BEARER_MANAGEMENT_DEBUG 478 qDebug(
"%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
504 if (result != ERROR_SUCCESS) {
505 #ifdef BEARER_MANAGEMENT_DEBUG 506 qDebug(
"%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
515 bool requested =
false;
518 if (result != ERROR_SUCCESS) {
519 #ifdef BEARER_MANAGEMENT_DEBUG 520 qDebug(
"%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
579 if (
handle != INVALID_HANDLE_VALUE)
585 if (result != ERROR_SUCCESS) {
586 #ifdef BEARER_MANAGEMENT_DEBUG 587 if (result != ERROR_SERVICE_NOT_ACTIVE)
588 qDebug(
"%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
597 #ifdef BEARER_MANAGEMENT_DEBUG 598 if (result != ERROR_SUCCESS)
599 qDebug(
"%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
602 return handle != INVALID_HANDLE_VALUE;
607 if (
handle != INVALID_HANDLE_VALUE) {
609 handle = INVALID_HANDLE_VALUE;
622 #endif // QT_NO_BEARERMANAGEMENT static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
QNativeWifiEngine(QObject *parent=0)
bool requiresPolling() const
uint qHash(const QProcEnvKey &key)
bool hasIdentifier(const QString &id)
DOT11_BSS_TYPE dot11BssType
Q_INVOKABLE void requestUpdate()
#define QT_END_NAMESPACE
This macro expands to.
void lock()
Locks the mutex.
WlanRegisterNotificationProto local_WlanRegisterNotification
WlanDisconnectProto local_WlanDisconnect
DOT11_BSSID_LIST * pDesiredBssidList
WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]
void disconnectFromId(const QString &id)
ushort toUShort(bool *ok=0, int base=10) const
Returns the string converted to an unsigned short using base base, which is 10 by default and must be...
QNetworkConfiguration::StateFlags state
QNetworkSession::State sessionStateForId(const QString &id)
void configurationChanged(QNetworkConfigurationPrivatePointer config)
WLAN_CONNECTION_MODE wlanConnectionMode
The QByteArray class provides an array of bytes.
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
WlanOpenHandleProto local_WlanOpenHandle
void unlock()
Unlocks this mutex locker.
WlanQueryInterfaceProto local_WlanQueryInterface
WlanConnectProto local_WlanConnect
QNetworkSessionPrivate * createSessionBackend()
State
This enum describes the connectivity state of the session.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
UCHAR ucSSID[DOT11_SSID_MAX_LENGTH]
The QChar class provides a 16-bit Unicode character.
QNetworkConfiguration::BearerType bearerType
WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void relock()
Relocks an unlocked mutex locker.
Q_CORE_EXPORT void qDebug(const char *,...)
WlanCloseHandleProto local_WlanCloseHandle
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
T takeFirst()
Removes the first item in the list and returns it.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
WLAN_INTERFACE_INFO InterfaceInfo[1]
void configurationAdded(QNetworkConfigurationPrivatePointer config)
void connectToId(const QString &id)
QNetworkConfigurationManager::Capabilities capabilities() const
static const char * data(const QByteArray &arr)
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
static void split(QT_FT_Vector *b)
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
void clear()
Clears the contents of the string and makes it empty.
QNetworkConfiguration::Type type
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
Q_INVOKABLE void initialize()
QNetworkConfigurationPrivatePointer defaultConfiguration()
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
QString getInterfaceFromId(const QString &id)
WlanFreeMemoryProto local_WlanFreeMemory
WlanScanProto local_WlanScan
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
WlanEnumInterfacesProto local_WlanEnumInterfaces
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.