diff options
author | aavit <eirik.aavitsland@digia.com> | 2014-11-14 15:01:55 +0100 |
---|---|---|
committer | aavit <eirik.aavitsland@digia.com> | 2014-11-14 15:25:43 +0100 |
commit | 7c5126a80c95f262ff3c480604b57532d9ed9079 (patch) | |
tree | 053fba4f2f3ccd2b231b310ab49b9db39491d095 /src/imports | |
parent | 1f0de42b9d5a8ef665e6799019eed898b0396586 (diff) | |
parent | 9b2dd9f64bdd5c2349407ae8517ae974eda97885 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Ib0a08de8aaf17f2803d51bded8d0dcfb14e9c206
Diffstat (limited to 'src/imports')
22 files changed, 167 insertions, 103 deletions
diff --git a/src/imports/nativemedia/SurfaceTexture.cpp b/src/imports/nativemedia/SurfaceTexture.cpp index 2f4eb57..05207ad 100644 --- a/src/imports/nativemedia/SurfaceTexture.cpp +++ b/src/imports/nativemedia/SurfaceTexture.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) diff --git a/src/imports/nativemedia/SurfaceTexture.h b/src/imports/nativemedia/SurfaceTexture.h index 9c72362..552d465 100644 --- a/src/imports/nativemedia/SurfaceTexture.h +++ b/src/imports/nativemedia/SurfaceTexture.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) diff --git a/src/imports/nativemedia/main.cpp b/src/imports/nativemedia/main.cpp index f78c12b..b14b3d0 100644 --- a/src/imports/nativemedia/main.cpp +++ b/src/imports/nativemedia/main.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include <QtGui> diff --git a/src/imports/nativemedia/omx.cpp b/src/imports/nativemedia/omx.cpp index 9c68d57..b2ad4bc 100644 --- a/src/imports/nativemedia/omx.cpp +++ b/src/imports/nativemedia/omx.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include <OMXAL/OpenMAXAL.h> diff --git a/src/imports/nativemedia/omxmodule.cpp b/src/imports/nativemedia/omxmodule.cpp index a6e6f4d..2daa154 100644 --- a/src/imports/nativemedia/omxmodule.cpp +++ b/src/imports/nativemedia/omxmodule.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "omxnode.h" diff --git a/src/imports/nativemedia/omxnode.cpp b/src/imports/nativemedia/omxnode.cpp index b7ad101..27ec1da 100644 --- a/src/imports/nativemedia/omxnode.cpp +++ b/src/imports/nativemedia/omxnode.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "omxnode.h" diff --git a/src/imports/nativemedia/omxnode.h b/src/imports/nativemedia/omxnode.h index 433f9ec..e658378 100644 --- a/src/imports/nativemedia/omxnode.h +++ b/src/imports/nativemedia/omxnode.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef OMXNODE_H diff --git a/src/imports/nativemedia/omxplayer.h b/src/imports/nativemedia/omxplayer.h index 9127dfc..05bb224 100644 --- a/src/imports/nativemedia/omxplayer.h +++ b/src/imports/nativemedia/omxplayer.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef OMXPLAYER_H diff --git a/src/imports/nativemedia/test.qml b/src/imports/nativemedia/test.qml index ad6a7f2..01a1bfd 100644 --- a/src/imports/nativemedia/test.qml +++ b/src/imports/nativemedia/test.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ import QtQuick 2.0 diff --git a/src/imports/utils/plugin.cpp b/src/imports/utils/plugin.cpp index 3adf633..4012e96 100644 --- a/src/imports/utils/plugin.cpp +++ b/src/imports/utils/plugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include <b2qtdevice.h> diff --git a/src/imports/wifi/pluginmain.cpp b/src/imports/wifi/pluginmain.cpp index 51a2e7c..bc72906 100644 --- a/src/imports/wifi/pluginmain.cpp +++ b/src/imports/wifi/pluginmain.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,78 +13,18 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "qwifimanager.h" +#include "qwifiinterface.h" -#include <QtCore/QDir> -#include <QtCore/QDebug> -#include <QtCore/QByteArray> #include <QtQml/QQmlExtensionPlugin> #include <QtQml/qqml.h> -#ifdef Q_OS_ANDROID -#include <hardware_legacy/wifi.h> -#endif -/*! - \qmltype Interface - \inqmlmodule Qt.labs.wifi - \ingroup wifi-qmltypes - \brief The Interface element provides the module API. - - This element cannot be directly created. It can only be accessed via a namespace import. - - \code - import Qt.labs.wifi 0.1 - import Qt.labs.wifi 0.1 as Wifi - - Component.onCompleted: { - if (Wifi.Interface.wifiSupported()) { - var component = Qt.createComponent("WifiMenu.qml") - } else { - print("WiFi functionality not available on this device.") - } - } - \endcode -*/ - -/*! - \qmlmethod bool Interface::wifiSupported() - - Returns true if the device is WiFi capable (provides a WiFi driver), otherwise returns false. -*/ - - -class QWifiGlobal : public QObject -{ - Q_OBJECT -public: - explicit QWifiGlobal(QObject *parent = 0) - : QObject(parent) {} - ~QWifiGlobal() {} - - Q_INVOKABLE bool wifiSupported() const - { - bool hasInterface = QDir().exists(QStringLiteral("/sys/class/net/wlan0")); - if (!hasInterface) - qWarning() << "QWifiGlobal: could not find wifi interface in /sys/class/net/"; -#ifdef Q_OS_ANDROID - if (hasInterface && wifi_load_driver() == 0 && wifi_start_supplicant(0) == 0) { - return true; - } else { - qWarning() << "QWifiGlobal: wifi driver is not available"; - return false; - } -#else - return hasInterface; -#endif - } -}; - static QObject *global_object_wifi(QQmlEngine *, QJSEngine *) { - return new QWifiGlobal; + return new QWifiInterface; } class QWifiPlugin : public QQmlExtensionPlugin @@ -99,7 +39,7 @@ public: qmlRegisterType<QWifiManager>(uri, 0, 1, "WifiManager"); qmlRegisterType<QWifiNetworkListModel>(); - qmlRegisterSingletonType<QWifiGlobal>(uri, 0, 1, "Interface", global_object_wifi); + qmlRegisterSingletonType<QWifiInterface>(uri, 0, 1, "Interface", global_object_wifi); } }; diff --git a/src/imports/wifi/qwifi_elinux.cpp b/src/imports/wifi/qwifi_elinux.cpp index 551d887..32e1aa3 100644 --- a/src/imports/wifi/qwifi_elinux.cpp +++ b/src/imports/wifi/qwifi_elinux.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "qwifi_elinux.h" diff --git a/src/imports/wifi/qwifi_elinux.h b/src/imports/wifi/qwifi_elinux.h index 92a04f8..a89642f 100644 --- a/src/imports/wifi/qwifi_elinux.h +++ b/src/imports/wifi/qwifi_elinux.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef LOCAL_WIFI_H diff --git a/src/imports/wifi/qwifiinterface.cpp b/src/imports/wifi/qwifiinterface.cpp new file mode 100644 index 0000000..acd7716 --- /dev/null +++ b/src/imports/wifi/qwifiinterface.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use the contact form at +** http://www.qt.io +** +** This file is part of Qt Enterprise Embedded. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** the contact form at http://www.qt.io +** +****************************************************************************/ +#include "qwifiinterface.h" + +/*! + \qmltype Interface + \inqmlmodule Qt.labs.wifi + \ingroup wifi-qmltypes + \brief The Interface element provides the module API. + + This element cannot be directly created. It can only be accessed via a namespace import. + + \code + import Qt.labs.wifi 0.1 + import Qt.labs.wifi 0.1 as Wifi + + Component.onCompleted: { + if (Wifi.Interface.wifiSupported()) { + var component = Qt.createComponent("WifiMenu.qml") + } else { + print("WiFi functionality not available on this device.") + } + } + \endcode +*/ + +/*! + \qmlmethod bool Interface::wifiSupported() + + Returns true if the device is WiFi capable (provides a WiFi driver), otherwise returns false. +*/ + +bool QWifiInterface::wifiSupported() const +{ +#ifdef Q_OS_ANDROID + const char *fwpath = 0; + // reload wifi firmware + fwpath = (char *)wifi_get_fw_path(WIFI_GET_FW_PATH_STA); + if (!fwpath) { + qWarning() << "QWifiInterface: failed to get firmware path"; + return false; + } + if (wifi_change_fw_path((const char *)fwpath)) { + qWarning() << "QWifiInterface: failed to change firmware path"; + return false; + } +#endif + const bool hasInterface = QDir().exists(QStringLiteral("/sys/class/net/wlan0")); + if (!hasInterface) + qWarning() << "QWifiInterface: could not find wifi interface in /sys/class/net/"; +#ifdef Q_OS_ANDROID + if (hasInterface && wifi_load_driver() == 0 && wifi_start_supplicant(0) == 0) { + return true; + } else { + qWarning() << "QWifiInterface: wifi driver is not available"; + return false; + } +#else + return hasInterface; +#endif +} diff --git a/src/imports/wifi/qwifiinterface.h b/src/imports/wifi/qwifiinterface.h new file mode 100644 index 0000000..06abd79 --- /dev/null +++ b/src/imports/wifi/qwifiinterface.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use the contact form at +** http://www.qt.io +** +** This file is part of Qt Enterprise Embedded. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** the contact form at http://www.qt.io +** +****************************************************************************/ +#ifndef QWIFIINTERFACE_H +#define QWIFIINTERFACE_H + +#include <QtCore/QDir> +#include <QtCore/QDebug> +#ifdef Q_OS_ANDROID +#include <hardware_legacy/wifi.h> +#include <cutils/properties.h> +#endif + +class QWifiInterface : public QObject +{ + Q_OBJECT +public: + explicit QWifiInterface(QObject *parent = 0) + : QObject(parent) {} + ~QWifiInterface() {} + + Q_INVOKABLE bool wifiSupported() const; +}; + +#endif // QWIFIHELPERS_H diff --git a/src/imports/wifi/qwifimanager.cpp b/src/imports/wifi/qwifimanager.cpp index 8eec3e0..2574cd2 100644 --- a/src/imports/wifi/qwifimanager.cpp +++ b/src/imports/wifi/qwifimanager.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,10 +13,11 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "qwifimanager.h" +#include "qwifiinterface.h" #include <QtCore> #ifdef Q_OS_ANDROID @@ -422,6 +423,10 @@ QWifiManager::QWifiManager() , m_startingUp(true) , m_network(0) { + if (!QWifiInterface().wifiSupported()) + // give a warning about API misuse + qWarning() << "WifiManager may not work as expected on this device. Use the API provided by QtWifi " + "library to verify if device has support for Wi-Fi before creating an instance of WifiManager!"; #ifdef Q_OS_ANDROID char interface[PROPERTY_VALUE_MAX]; property_get(WIFI_INTERFACE, interface, NULL); diff --git a/src/imports/wifi/qwifimanager.h b/src/imports/wifi/qwifimanager.h index 3af123f..7acc360 100644 --- a/src/imports/wifi/qwifimanager.h +++ b/src/imports/wifi/qwifimanager.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef QWIFIMANAGER_H diff --git a/src/imports/wifi/qwifinetwork.cpp b/src/imports/wifi/qwifinetwork.cpp index d4c20ef..84e3b5b 100644 --- a/src/imports/wifi/qwifinetwork.cpp +++ b/src/imports/wifi/qwifinetwork.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "qwifinetwork.h" diff --git a/src/imports/wifi/qwifinetwork.h b/src/imports/wifi/qwifinetwork.h index 5ecc6a3..5a92e17 100644 --- a/src/imports/wifi/qwifinetwork.h +++ b/src/imports/wifi/qwifinetwork.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef QWIFINETWORK_H diff --git a/src/imports/wifi/qwifinetworklistmodel.cpp b/src/imports/wifi/qwifinetworklistmodel.cpp index f95af36..1886413 100644 --- a/src/imports/wifi/qwifinetworklistmodel.cpp +++ b/src/imports/wifi/qwifinetworklistmodel.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #include "qwifinetworklistmodel.h" diff --git a/src/imports/wifi/qwifinetworklistmodel.h b/src/imports/wifi/qwifinetworklistmodel.h index 91ca231..0cb9846 100644 --- a/src/imports/wifi/qwifinetworklistmodel.h +++ b/src/imports/wifi/qwifinetworklistmodel.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ +** http://www.qt.io ** ** This file is part of Qt Enterprise Embedded. ** @@ -13,7 +13,7 @@ ** a written agreement between you and Digia. ** ** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ +** the contact form at http://www.qt.io ** ****************************************************************************/ #ifndef QWIFINETWORKLISTMODEL_H diff --git a/src/imports/wifi/wifi.pro b/src/imports/wifi/wifi.pro index fcb6cdd..dabf8cb 100644 --- a/src/imports/wifi/wifi.pro +++ b/src/imports/wifi/wifi.pro @@ -7,13 +7,15 @@ IMPORT_VERSION = 0.1 HEADERS += \ qwifimanager.h \ qwifinetwork.h \ - qwifinetworklistmodel.h + qwifinetworklistmodel.h \ + qwifiinterface.h SOURCES += \ pluginmain.cpp \ qwifimanager.cpp \ qwifinetwork.cpp \ - qwifinetworklistmodel.cpp + qwifinetworklistmodel.cpp \ + qwifiinterface.cpp android: { LIBS += -lhardware_legacy -lcutils |