summaryrefslogtreecommitdiffstats
path: root/src/imports/wifi/pluginmain.cpp
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@digia.com>2014-01-02 15:57:14 +0100
committerGatis Paeglis <gatis.paeglis@digia.com>2014-01-28 12:01:04 +0200
commit696510db8f43427a9bb6ff249f688851f531cd12 (patch)
tree37fcf832449de02879b7ce3a7287588c53c6bbd5 /src/imports/wifi/pluginmain.cpp
parent95a00d27cda8b8bea27192f7ee9eb2b5ae6eb405 (diff)
Fix dhcp issues and improve public API
- Use qconnectivity daemon for dhcp requests. Since dhcp requests are executed in other process we don't block gui thread for this lengthy operation. - Why not to use "do_dhcp_request" - it is a legacy implementation of a dhcp client and is not used anywhere in the Android source code itself. It appears that do_dhcp_request was not removed from the libhardware_legacy to keep compatibility for others, whose code might still depend on it. - Differnet changes to the internal implementation and the public API. - Add 'Interface' singleton type, installing a singleton type allows developers to provide arbitrary functionality to a client without requiring individual instances of the type to be instantiated by the client. We use this to determine if Android has wifi interface. Change-Id: I836f3a2a587b1ebf9f670ed08b10fe3483504b9e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com>
Diffstat (limited to 'src/imports/wifi/pluginmain.cpp')
-rw-r--r--src/imports/wifi/pluginmain.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/imports/wifi/pluginmain.cpp b/src/imports/wifi/pluginmain.cpp
index 58aa590..0eeff78 100644
--- a/src/imports/wifi/pluginmain.cpp
+++ b/src/imports/wifi/pluginmain.cpp
@@ -21,6 +21,36 @@
#include <QtQml/QQmlExtensionPlugin>
#include <QtQml/qqml.h>
+#include <QtCore/QDir>
+#include <QtCore/QByteArray>
+
+class QWifiGlobal : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QWifiGlobal(QObject *parent = 0)
+ : QObject(parent) {}
+ ~QWifiGlobal() {}
+
+ Q_INVOKABLE bool wifiSupported() const
+ {
+ char interface[PROPERTY_VALUE_MAX];
+ property_get("wifi.interface", interface, NULL);
+ // standard linux kernel path
+ QByteArray path;
+ path.append("/sys/class/net/").append(interface);
+ bool interfaceFound = QDir().exists(path.constData());
+ if (!interfaceFound)
+ qWarning() << "QWifiGlobal: could not find wifi interface in " << path;
+ return interfaceFound;
+ }
+};
+
+static QObject *global_object_wifi(QQmlEngine *, QJSEngine *)
+{
+ return new QWifiGlobal;
+}
+
class QWifiPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
@@ -31,11 +61,10 @@ public:
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.wifi"));
- qmlRegisterType<QWifiManager>(uri, 0, 1, "QWifiManager");
+ qmlRegisterType<QWifiManager>(uri, 0, 1, "WifiManager");
qmlRegisterType<QWifiNetworkList>();
+ qmlRegisterSingletonType<QWifiGlobal>(uri, 0, 1, "Interface", global_object_wifi);
}
};
#include "pluginmain.moc"
-
-