summaryrefslogtreecommitdiffstats
path: root/src/wifi/qwifidevice.cpp
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2015-06-28 12:49:14 +0200
committerGatis Paeglis <gatis.paeglis@theqtcompany.com>2015-06-29 11:10:08 +0300
commit4ef20296ae47d134fd76f5682dc0a9a4a4994f0b (patch)
treecf5251e0a8143720381e18e72ec0642ee64d5bdf /src/wifi/qwifidevice.cpp
parent3e6d9c660931ffd06174784c71af30d7fbe40802 (diff)
Use a custom supplicant configuration file
A default configuration file contains: network={ key_mgmt=NONE } which means that supplicant will try to connect to *any* network where key_mgmt is set to NONE. We don't want that. Change-Id: Ibde643dfa2371cffdec2bfc53f96957fda7ac452 Reviewed-by: Kalle Viironen <kalle.viironen@theqtcompany.com>
Diffstat (limited to 'src/wifi/qwifidevice.cpp')
-rw-r--r--src/wifi/qwifidevice.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/wifi/qwifidevice.cpp b/src/wifi/qwifidevice.cpp
index 0e421b7..0b52780 100644
--- a/src/wifi/qwifidevice.cpp
+++ b/src/wifi/qwifidevice.cpp
@@ -27,6 +27,39 @@
QT_BEGIN_NAMESPACE
+class QWifiDevicePrivate
+{
+ Q_DECLARE_PUBLIC(QWifiDevice)
+public:
+ QWifiDevicePrivate(QWifiDevice *device);
+
+ // methods
+ void createSupplicantConfig();
+ // member variables
+ QWifiDevice *const q_ptr;
+};
+
+QWifiDevicePrivate::QWifiDevicePrivate(QWifiDevice *device)
+ : q_ptr(device)
+{
+}
+
+void QWifiDevicePrivate::createSupplicantConfig()
+{
+ QFile supplicantConfig(QStringLiteral("/etc/wpa_supplicant.qtwifi.conf"));
+ if (supplicantConfig.exists())
+ return;
+
+ if (supplicantConfig.open(QIODevice::WriteOnly)) {
+ supplicantConfig.write("ctrl_interface=/var/run/wpa_supplicant\n"
+ "ctrl_interface_group=0\n"
+ "update_config=1\n");
+ } else {
+ qCWarning(B2QT_WIFI) << "failed to create supplicant configuration file.";
+ }
+}
+
+
/*!
\class QWifiDevice
\inmodule B2Qt.Wifi.Cpp
@@ -49,7 +82,9 @@ QT_BEGIN_NAMESPACE
*/
QWifiDevice::QWifiDevice()
+ : d_ptr(new QWifiDevicePrivate(this))
{
+ d_ptr->createSupplicantConfig();
}
QWifiDevice::~QWifiDevice()