wpa_gui: Port to Qt5
This adds support for Qt5 while still preserving support for building with Qt4. The same source code builds with both Qt versions now. The functionality should be identical. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
e1ede80d3b
commit
8d2ed87d82
17 changed files with 99 additions and 91 deletions
|
@ -41,8 +41,8 @@ AddInterface::AddInterface(WpaGui *_wpagui, QWidget *parent)
|
||||||
interfaceWidget->headerItem()->setText(0, tr("driver"));
|
interfaceWidget->headerItem()->setText(0, tr("driver"));
|
||||||
interfaceWidget->headerItem()->setText(1, tr("interface"));
|
interfaceWidget->headerItem()->setText(1, tr("interface"));
|
||||||
interfaceWidget->headerItem()->setText(2, tr("description"));
|
interfaceWidget->headerItem()->setText(2, tr("description"));
|
||||||
interfaceWidget->setItemsExpandable(FALSE);
|
interfaceWidget->setItemsExpandable(false);
|
||||||
interfaceWidget->setRootIsDecorated(FALSE);
|
interfaceWidget->setRootIsDecorated(false);
|
||||||
vboxLayout->addWidget(interfaceWidget);
|
vboxLayout->addWidget(interfaceWidget);
|
||||||
|
|
||||||
connect(interfaceWidget,
|
connect(interfaceWidget,
|
||||||
|
@ -196,9 +196,9 @@ void AddInterface::interfaceSelected(QTreeWidgetItem *sel)
|
||||||
*/
|
*/
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s",
|
"INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s",
|
||||||
sel->text(1).toAscii().constData(),
|
sel->text(1).toLocal8Bit().constData(),
|
||||||
"default",
|
"default",
|
||||||
sel->text(0).toAscii().constData(),
|
sel->text(0).toLocal8Bit().constData(),
|
||||||
"yes", "", "");
|
"yes", "", "");
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
#include <QtGui/QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
class WpaGui;
|
class WpaGui;
|
||||||
|
|
||||||
|
|
|
@ -73,15 +73,15 @@ void EventListModel::addEvent(QString time, QString msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WFlags)
|
EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WindowFlags)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
|
|
||||||
eventListView->setItemsExpandable(FALSE);
|
eventListView->setItemsExpandable(false);
|
||||||
eventListView->setRootIsDecorated(FALSE);
|
eventListView->setRootIsDecorated(false);
|
||||||
elm = new EventListModel(parent);
|
elm = new EventListModel(parent);
|
||||||
eventListView->setModel(elm);
|
eventListView->setModel(elm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class EventHistory : public QDialog, public Ui::EventHistory
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EventHistory(QWidget *parent = 0, const char *name = 0,
|
EventHistory(QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = false, Qt::WFlags fl = 0);
|
bool modal = false, Qt::WindowFlags fl = 0);
|
||||||
~EventHistory();
|
~EventHistory();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -14,24 +14,14 @@
|
||||||
#include <QtCore/QTranslator>
|
#include <QtCore/QTranslator>
|
||||||
#include "wpagui.h"
|
#include "wpagui.h"
|
||||||
|
|
||||||
|
WpaGuiApp::WpaGuiApp(int &argc, char **argv) :
|
||||||
class WpaGuiApp : public QApplication
|
QApplication(argc, argv),
|
||||||
{
|
argc(argc),
|
||||||
public:
|
argv(argv)
|
||||||
WpaGuiApp(int &argc, char **argv);
|
|
||||||
|
|
||||||
#ifndef QT_NO_SESSIONMANAGER
|
|
||||||
virtual void saveState(QSessionManager &manager);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WpaGui *w;
|
|
||||||
};
|
|
||||||
|
|
||||||
WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_SESSIONMANAGER
|
#if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
|
||||||
void WpaGuiApp::saveState(QSessionManager &manager)
|
void WpaGuiApp::saveState(QSessionManager &manager)
|
||||||
{
|
{
|
||||||
QApplication::saveState(manager);
|
QApplication::saveState(manager);
|
||||||
|
|
|
@ -26,7 +26,8 @@ enum {
|
||||||
#define WPA_GUI_KEY_DATA "[key is configured]"
|
#define WPA_GUI_KEY_DATA "[key is configured]"
|
||||||
|
|
||||||
|
|
||||||
NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool, Qt::WFlags)
|
NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool,
|
||||||
|
Qt::WindowFlags)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -237,7 +238,7 @@ void NetworkConfig::addNetwork()
|
||||||
} else
|
} else
|
||||||
id = edit_network_id;
|
id = edit_network_id;
|
||||||
|
|
||||||
setNetworkParam(id, "ssid", ssidEdit->text().toAscii().constData(),
|
setNetworkParam(id, "ssid", ssidEdit->text().toLocal8Bit().constData(),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
|
const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
|
||||||
|
@ -291,14 +292,14 @@ void NetworkConfig::addNetwork()
|
||||||
setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
|
setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
|
||||||
}
|
}
|
||||||
if (pskEdit->isEnabled() &&
|
if (pskEdit->isEnabled() &&
|
||||||
strcmp(pskEdit->text().toAscii().constData(),
|
strcmp(pskEdit->text().toLocal8Bit().constData(),
|
||||||
WPA_GUI_KEY_DATA) != 0)
|
WPA_GUI_KEY_DATA) != 0)
|
||||||
setNetworkParam(id, "psk",
|
setNetworkParam(id, "psk",
|
||||||
pskEdit->text().toAscii().constData(),
|
pskEdit->text().toLocal8Bit().constData(),
|
||||||
psklen != 64);
|
psklen != 64);
|
||||||
if (eapSelect->isEnabled()) {
|
if (eapSelect->isEnabled()) {
|
||||||
const char *eap =
|
const char *eap =
|
||||||
eapSelect->currentText().toAscii().constData();
|
eapSelect->currentText().toLocal8Bit().constData();
|
||||||
setNetworkParam(id, "eap", eap, false);
|
setNetworkParam(id, "eap", eap, false);
|
||||||
if (strcmp(eap, "SIM") == 0 || strcmp(eap, "AKA") == 0)
|
if (strcmp(eap, "SIM") == 0 || strcmp(eap, "AKA") == 0)
|
||||||
setNetworkParam(id, "pcsc", "", true);
|
setNetworkParam(id, "pcsc", "", true);
|
||||||
|
@ -314,21 +315,21 @@ void NetworkConfig::addNetwork()
|
||||||
if (inner.startsWith("EAP-"))
|
if (inner.startsWith("EAP-"))
|
||||||
snprintf(phase2, sizeof(phase2), "auth=%s",
|
snprintf(phase2, sizeof(phase2), "auth=%s",
|
||||||
inner.right(inner.size() - 4).
|
inner.right(inner.size() - 4).
|
||||||
toAscii().constData());
|
toLocal8Bit().constData());
|
||||||
} else if (eap.compare("TTLS") == 0) {
|
} else if (eap.compare("TTLS") == 0) {
|
||||||
if (inner.startsWith("EAP-"))
|
if (inner.startsWith("EAP-"))
|
||||||
snprintf(phase2, sizeof(phase2), "autheap=%s",
|
snprintf(phase2, sizeof(phase2), "autheap=%s",
|
||||||
inner.right(inner.size() - 4).
|
inner.right(inner.size() - 4).
|
||||||
toAscii().constData());
|
toLocal8Bit().constData());
|
||||||
else
|
else
|
||||||
snprintf(phase2, sizeof(phase2), "auth=%s",
|
snprintf(phase2, sizeof(phase2), "auth=%s",
|
||||||
inner.toAscii().constData());
|
inner.toLocal8Bit().constData());
|
||||||
} else if (eap.compare("FAST") == 0) {
|
} else if (eap.compare("FAST") == 0) {
|
||||||
const char *provisioning = NULL;
|
const char *provisioning = NULL;
|
||||||
if (inner.startsWith("EAP-")) {
|
if (inner.startsWith("EAP-")) {
|
||||||
snprintf(phase2, sizeof(phase2), "auth=%s",
|
snprintf(phase2, sizeof(phase2), "auth=%s",
|
||||||
inner.right(inner.size() - 4).
|
inner.right(inner.size() - 4).
|
||||||
toAscii().constData());
|
toLocal8Bit().constData());
|
||||||
provisioning = "fast_provisioning=2";
|
provisioning = "fast_provisioning=2";
|
||||||
} else if (inner.compare("GTC(auth) + MSCHAPv2(prov)")
|
} else if (inner.compare("GTC(auth) + MSCHAPv2(prov)")
|
||||||
== 0) {
|
== 0) {
|
||||||
|
@ -354,21 +355,21 @@ void NetworkConfig::addNetwork()
|
||||||
setNetworkParam(id, "phase2", "NULL", false);
|
setNetworkParam(id, "phase2", "NULL", false);
|
||||||
if (identityEdit->isEnabled() && identityEdit->text().length() > 0)
|
if (identityEdit->isEnabled() && identityEdit->text().length() > 0)
|
||||||
setNetworkParam(id, "identity",
|
setNetworkParam(id, "identity",
|
||||||
identityEdit->text().toAscii().constData(),
|
identityEdit->text().toLocal8Bit().constData(),
|
||||||
true);
|
true);
|
||||||
else
|
else
|
||||||
setNetworkParam(id, "identity", "NULL", false);
|
setNetworkParam(id, "identity", "NULL", false);
|
||||||
if (passwordEdit->isEnabled() && passwordEdit->text().length() > 0 &&
|
if (passwordEdit->isEnabled() && passwordEdit->text().length() > 0 &&
|
||||||
strcmp(passwordEdit->text().toAscii().constData(),
|
strcmp(passwordEdit->text().toLocal8Bit().constData(),
|
||||||
WPA_GUI_KEY_DATA) != 0)
|
WPA_GUI_KEY_DATA) != 0)
|
||||||
setNetworkParam(id, "password",
|
setNetworkParam(id, "password",
|
||||||
passwordEdit->text().toAscii().constData(),
|
passwordEdit->text().toLocal8Bit().constData(),
|
||||||
true);
|
true);
|
||||||
else if (passwordEdit->text().length() == 0)
|
else if (passwordEdit->text().length() == 0)
|
||||||
setNetworkParam(id, "password", "NULL", false);
|
setNetworkParam(id, "password", "NULL", false);
|
||||||
if (cacertEdit->isEnabled() && cacertEdit->text().length() > 0)
|
if (cacertEdit->isEnabled() && cacertEdit->text().length() > 0)
|
||||||
setNetworkParam(id, "ca_cert",
|
setNetworkParam(id, "ca_cert",
|
||||||
cacertEdit->text().toAscii().constData(),
|
cacertEdit->text().toLocal8Bit().constData(),
|
||||||
true);
|
true);
|
||||||
else
|
else
|
||||||
setNetworkParam(id, "ca_cert", "NULL", false);
|
setNetworkParam(id, "ca_cert", "NULL", false);
|
||||||
|
@ -388,7 +389,7 @@ void NetworkConfig::addNetwork()
|
||||||
|
|
||||||
if (idstrEdit->isEnabled() && idstrEdit->text().length() > 0)
|
if (idstrEdit->isEnabled() && idstrEdit->text().length() > 0)
|
||||||
setNetworkParam(id, "id_str",
|
setNetworkParam(id, "id_str",
|
||||||
idstrEdit->text().toAscii().constData(),
|
idstrEdit->text().toLocal8Bit().constData(),
|
||||||
true);
|
true);
|
||||||
else
|
else
|
||||||
setNetworkParam(id, "id_str", "NULL", false);
|
setNetworkParam(id, "id_str", "NULL", false);
|
||||||
|
@ -396,7 +397,7 @@ void NetworkConfig::addNetwork()
|
||||||
if (prioritySpinBox->isEnabled()) {
|
if (prioritySpinBox->isEnabled()) {
|
||||||
QString prio;
|
QString prio;
|
||||||
prio = prio.setNum(prioritySpinBox->value());
|
prio = prio.setNum(prioritySpinBox->value());
|
||||||
setNetworkParam(id, "priority", prio.toAscii().constData(),
|
setNetworkParam(id, "priority", prio.toLocal8Bit().constData(),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +469,7 @@ void NetworkConfig::writeWepKey(int network_id, QLineEdit *edit, int id)
|
||||||
* Assume hex key if only hex characters are present and length matches
|
* Assume hex key if only hex characters are present and length matches
|
||||||
* with 40, 104, or 128-bit key
|
* with 40, 104, or 128-bit key
|
||||||
*/
|
*/
|
||||||
txt = edit->text().toAscii().constData();
|
txt = edit->text().toLocal8Bit().constData();
|
||||||
if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
|
if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
|
||||||
return;
|
return;
|
||||||
len = strlen(txt);
|
len = strlen(txt);
|
||||||
|
|
|
@ -20,7 +20,7 @@ class NetworkConfig : public QDialog, public Ui::NetworkConfig
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkConfig(QWidget *parent = 0, const char *name = 0,
|
NetworkConfig(QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = false, Qt::WFlags fl = 0);
|
bool modal = false, Qt::WindowFlags fl = 0);
|
||||||
~NetworkConfig();
|
~NetworkConfig();
|
||||||
|
|
||||||
virtual void paramsFromScanResults(QTreeWidgetItem *sel);
|
virtual void paramsFromScanResults(QTreeWidgetItem *sel);
|
||||||
|
|
|
@ -62,7 +62,7 @@ enum peer_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Peers::Peers(QWidget *parent, const char *, bool, Qt::WFlags)
|
Peers::Peers(QWidget *parent, const char *, bool, Qt::WindowFlags)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -323,13 +323,13 @@ void Peers::enter_pin()
|
||||||
|
|
||||||
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
||||||
snprintf(cmd, sizeof(cmd), "WPS_ER_PIN %s %s %s",
|
snprintf(cmd, sizeof(cmd), "WPS_ER_PIN %s %s %s",
|
||||||
uuid.toAscii().constData(),
|
uuid.toLocal8Bit().constData(),
|
||||||
input.get_string().toAscii().constData(),
|
input.get_string().toLocal8Bit().constData(),
|
||||||
addr.toAscii().constData());
|
addr.toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
snprintf(cmd, sizeof(cmd), "WPS_PIN %s %s",
|
snprintf(cmd, sizeof(cmd), "WPS_PIN %s %s",
|
||||||
addr.toAscii().constData(),
|
addr.toLocal8Bit().constData(),
|
||||||
input.get_string().toAscii().constData());
|
input.get_string().toLocal8Bit().constData());
|
||||||
}
|
}
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
|
@ -868,7 +868,7 @@ void Peers::event_notify(WpaMsg msg)
|
||||||
QStandardItem *item = find_addr(addr);
|
QStandardItem *item = find_addr(addr);
|
||||||
if (item == NULL || item->data(peer_role_type).toInt() !=
|
if (item == NULL || item->data(peer_role_type).toInt() !=
|
||||||
PEER_TYPE_ASSOCIATED_STATION)
|
PEER_TYPE_ASSOCIATED_STATION)
|
||||||
add_single_station(addr.toAscii().constData());
|
add_single_station(addr.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,8 +1350,8 @@ void Peers::ctx_p2p_connect()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
|
||||||
addr.toAscii().constData(),
|
addr.toLocal8Bit().constData(),
|
||||||
arg.toAscii().constData());
|
arg.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1384,8 +1384,8 @@ void Peers::ctx_p2p_connect()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s",
|
||||||
addr.toAscii().constData(),
|
addr.toLocal8Bit().constData(),
|
||||||
arg.toAscii().constData());
|
arg.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1408,7 +1408,7 @@ void Peers::ctx_p2p_req_pin()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s display",
|
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s display",
|
||||||
addr.toAscii().constData());
|
addr.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1431,7 +1431,7 @@ void Peers::ctx_p2p_show_pin()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s keypad",
|
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s keypad",
|
||||||
addr.toAscii().constData());
|
addr.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1452,7 +1452,7 @@ void Peers::ctx_p2p_display_pin()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pin",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pin",
|
||||||
addr.toAscii().constData());
|
addr.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1480,8 +1480,8 @@ void Peers::ctx_p2p_display_pin_pd()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
|
||||||
addr.toAscii().constData(),
|
addr.toLocal8Bit().constData(),
|
||||||
arg.toAscii().constData());
|
arg.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1515,8 +1515,8 @@ void Peers::ctx_p2p_enter_pin()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s keypad",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s keypad",
|
||||||
addr.toAscii().constData(),
|
addr.toLocal8Bit().constData(),
|
||||||
arg.toAscii().constData());
|
arg.toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
@ -1535,7 +1535,7 @@ void Peers::ctx_p2p_remove_group()
|
||||||
char reply[100];
|
char reply[100];
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_GROUP_REMOVE %s",
|
snprintf(cmd, sizeof(cmd), "P2P_GROUP_REMOVE %s",
|
||||||
ctx_item->data(peer_role_ifname).toString().toAscii().
|
ctx_item->data(peer_role_ifname).toString().toLocal8Bit().
|
||||||
constData());
|
constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
|
@ -1713,13 +1713,13 @@ void Peers::connect_pbc()
|
||||||
int peer_type = ctx_item->data(peer_role_type).toInt();
|
int peer_type = ctx_item->data(peer_role_type).toInt();
|
||||||
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
||||||
snprintf(cmd, sizeof(cmd), "WPS_ER_PBC %s",
|
snprintf(cmd, sizeof(cmd), "WPS_ER_PBC %s",
|
||||||
ctx_item->data(peer_role_uuid).toString().toAscii().
|
ctx_item->data(peer_role_uuid).toString().toLocal8Bit().
|
||||||
constData());
|
constData());
|
||||||
} else if (peer_type == PEER_TYPE_P2P ||
|
} else if (peer_type == PEER_TYPE_P2P ||
|
||||||
peer_type == PEER_TYPE_P2P_CLIENT) {
|
peer_type == PEER_TYPE_P2P_CLIENT) {
|
||||||
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pbc",
|
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pbc",
|
||||||
ctx_item->data(peer_role_address).toString().
|
ctx_item->data(peer_role_address).toString().
|
||||||
toAscii().constData());
|
toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
snprintf(cmd, sizeof(cmd), "WPS_PBC");
|
snprintf(cmd, sizeof(cmd), "WPS_PBC");
|
||||||
}
|
}
|
||||||
|
@ -1750,8 +1750,8 @@ void Peers::learn_ap_config()
|
||||||
size_t reply_len;
|
size_t reply_len;
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "WPS_ER_LEARN %s %s",
|
snprintf(cmd, sizeof(cmd), "WPS_ER_LEARN %s %s",
|
||||||
uuid.toAscii().constData(),
|
uuid.toLocal8Bit().constData(),
|
||||||
input.get_string().toAscii().constData());
|
input.get_string().toLocal8Bit().constData());
|
||||||
reply_len = sizeof(reply) - 1;
|
reply_len = sizeof(reply) - 1;
|
||||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Peers : public QDialog, public Ui::Peers
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Peers(QWidget *parent = 0, const char *name = 0,
|
Peers(QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = false, Qt::WFlags fl = 0);
|
bool modal = false, Qt::WindowFlags fl = 0);
|
||||||
~Peers();
|
~Peers();
|
||||||
void setWpaGui(WpaGui *_wpagui);
|
void setWpaGui(WpaGui *_wpagui);
|
||||||
void event_notify(WpaMsg msg);
|
void event_notify(WpaMsg msg);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "scanresultsitem.h"
|
#include "scanresultsitem.h"
|
||||||
|
|
||||||
|
|
||||||
ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
|
ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WindowFlags)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -27,8 +27,8 @@ ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
|
||||||
SLOT(bssSelected(QTreeWidgetItem *)));
|
SLOT(bssSelected(QTreeWidgetItem *)));
|
||||||
|
|
||||||
wpagui = NULL;
|
wpagui = NULL;
|
||||||
scanResultsWidget->setItemsExpandable(FALSE);
|
scanResultsWidget->setItemsExpandable(false);
|
||||||
scanResultsWidget->setRootIsDecorated(FALSE);
|
scanResultsWidget->setRootIsDecorated(false);
|
||||||
scanResultsWidget->setItemDelegate(new SignalBar(scanResultsWidget));
|
scanResultsWidget->setItemDelegate(new SignalBar(scanResultsWidget));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ScanResults : public QDialog, public Ui::ScanResults
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScanResults(QWidget *parent = 0, const char *name = 0,
|
ScanResults(QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = false, Qt::WFlags fl = 0);
|
bool modal = false, Qt::WindowFlags fl = 0);
|
||||||
~ScanResults();
|
~ScanResults();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef SCANRESULTSITEM_H
|
#ifndef SCANRESULTSITEM_H
|
||||||
#define SCANRESULTSITEM_H
|
#define SCANRESULTSITEM_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
class ScanResultsItem : public QTreeWidgetItem
|
class ScanResultsItem : public QTreeWidgetItem
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
|
|
||||||
UserDataRequest::UserDataRequest(QWidget *parent, const char *, bool,
|
UserDataRequest::UserDataRequest(QWidget *parent, const char *, bool,
|
||||||
Qt::WFlags)
|
Qt::WindowFlags)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -89,6 +89,6 @@ void UserDataRequest::sendReply()
|
||||||
QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
|
QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
|
||||||
QString::number(networkid) + ':' +
|
QString::number(networkid) + ':' +
|
||||||
queryEdit->text();
|
queryEdit->text();
|
||||||
wpagui->ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
wpagui->ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class UserDataRequest : public QDialog, public Ui::UserDataRequest
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserDataRequest(QWidget *parent = 0, const char *name = 0,
|
UserDataRequest(QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = false, Qt::WFlags fl = 0);
|
bool modal = false, Qt::WindowFlags fl = 0);
|
||||||
~UserDataRequest();
|
~UserDataRequest();
|
||||||
|
|
||||||
int setParams(WpaGui *_wpagui, const char *reqMsg);
|
int setParams(WpaGui *_wpagui, const char *reqMsg);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
LANGUAGE = C++
|
LANGUAGE = C++
|
||||||
TRANSLATIONS = lang/wpa_gui_de.ts
|
TRANSLATIONS = lang/wpa_gui_de.ts
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
CONFIG += qt warn_on release
|
CONFIG += qt warn_on release
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
|
WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *,
|
||||||
|
Qt::WindowFlags)
|
||||||
: QMainWindow(parent), app(_app)
|
: QMainWindow(parent), app(_app)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -159,7 +160,7 @@ WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
|
||||||
textStatus->setText(tr("connecting to wpa_supplicant"));
|
textStatus->setText(tr("connecting to wpa_supplicant"));
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
connect(timer, SIGNAL(timeout()), SLOT(ping()));
|
connect(timer, SIGNAL(timeout()), SLOT(ping()));
|
||||||
timer->setSingleShot(FALSE);
|
timer->setSingleShot(false);
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
|
||||||
signalMeterTimer = new QTimer(this);
|
signalMeterTimer = new QTimer(this);
|
||||||
|
@ -238,8 +239,9 @@ void WpaGui::languageChange()
|
||||||
void WpaGui::parse_argv()
|
void WpaGui::parse_argv()
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
WpaGuiApp *app = qobject_cast<WpaGuiApp*>(qApp);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = getopt(qApp->argc(), qApp->argv(), "i:m:p:tq");
|
c = getopt(app->argc, app->argv, "i:m:p:tq");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -750,7 +752,7 @@ void WpaGui::helpContents()
|
||||||
void WpaGui::helpAbout()
|
void WpaGui::helpAbout()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, "wpa_gui for wpa_supplicant",
|
QMessageBox::about(this, "wpa_gui for wpa_supplicant",
|
||||||
"Copyright (c) 2003-2013,\n"
|
"Copyright (c) 2003-2015,\n"
|
||||||
"Jouni Malinen <j@w1.fi>\n"
|
"Jouni Malinen <j@w1.fi>\n"
|
||||||
"and contributors.\n"
|
"and contributors.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -1066,7 +1068,7 @@ void WpaGui::selectNetwork( const QString &sel )
|
||||||
else
|
else
|
||||||
cmd = "any";
|
cmd = "any";
|
||||||
cmd.prepend("SELECT_NETWORK ");
|
cmd.prepend("SELECT_NETWORK ");
|
||||||
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
|
||||||
triggerUpdate();
|
triggerUpdate();
|
||||||
stopWpsRun(false);
|
stopWpsRun(false);
|
||||||
}
|
}
|
||||||
|
@ -1082,11 +1084,11 @@ void WpaGui::enableNetwork(const QString &sel)
|
||||||
cmd.truncate(cmd.indexOf(':'));
|
cmd.truncate(cmd.indexOf(':'));
|
||||||
else if (!cmd.startsWith("all")) {
|
else if (!cmd.startsWith("all")) {
|
||||||
debug("Invalid editNetwork '%s'",
|
debug("Invalid editNetwork '%s'",
|
||||||
cmd.toAscii().constData());
|
cmd.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmd.prepend("ENABLE_NETWORK ");
|
cmd.prepend("ENABLE_NETWORK ");
|
||||||
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
|
||||||
triggerUpdate();
|
triggerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,11 +1103,11 @@ void WpaGui::disableNetwork(const QString &sel)
|
||||||
cmd.truncate(cmd.indexOf(':'));
|
cmd.truncate(cmd.indexOf(':'));
|
||||||
else if (!cmd.startsWith("all")) {
|
else if (!cmd.startsWith("all")) {
|
||||||
debug("Invalid editNetwork '%s'",
|
debug("Invalid editNetwork '%s'",
|
||||||
cmd.toAscii().constData());
|
cmd.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmd.prepend("DISABLE_NETWORK ");
|
cmd.prepend("DISABLE_NETWORK ");
|
||||||
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
|
||||||
triggerUpdate();
|
triggerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1191,11 +1193,11 @@ void WpaGui::removeNetwork(const QString &sel)
|
||||||
cmd.truncate(cmd.indexOf(':'));
|
cmd.truncate(cmd.indexOf(':'));
|
||||||
else if (!cmd.startsWith("all")) {
|
else if (!cmd.startsWith("all")) {
|
||||||
debug("Invalid editNetwork '%s'",
|
debug("Invalid editNetwork '%s'",
|
||||||
cmd.toAscii().constData());
|
cmd.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmd.prepend("REMOVE_NETWORK ");
|
cmd.prepend("REMOVE_NETWORK ");
|
||||||
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
|
||||||
triggerUpdate();
|
triggerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1255,14 +1257,14 @@ int WpaGui::getNetworkDisabled(const QString &sel)
|
||||||
int pos = cmd.indexOf(':');
|
int pos = cmd.indexOf(':');
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
debug("Invalid getNetworkDisabled '%s'",
|
debug("Invalid getNetworkDisabled '%s'",
|
||||||
cmd.toAscii().constData());
|
cmd.toLocal8Bit().constData());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cmd.truncate(pos);
|
cmd.truncate(pos);
|
||||||
cmd.prepend("GET_NETWORK ");
|
cmd.prepend("GET_NETWORK ");
|
||||||
cmd.append(" disabled");
|
cmd.append(" disabled");
|
||||||
|
|
||||||
if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) >= 0
|
if (ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len) >= 0
|
||||||
&& reply_len >= 1) {
|
&& reply_len >= 1) {
|
||||||
reply[reply_len] = '\0';
|
reply[reply_len] = '\0';
|
||||||
if (!str_match(reply, "FAIL"))
|
if (!str_match(reply, "FAIL"))
|
||||||
|
@ -1345,7 +1347,7 @@ void WpaGui::saveConfig()
|
||||||
|
|
||||||
void WpaGui::selectAdapter( const QString & sel )
|
void WpaGui::selectAdapter( const QString & sel )
|
||||||
{
|
{
|
||||||
if (openCtrlConnection(sel.toAscii().constData()) < 0)
|
if (openCtrlConnection(sel.toLocal8Bit().constData()) < 0)
|
||||||
debug("Failed to open control connection to "
|
debug("Failed to open control connection to "
|
||||||
"wpa_supplicant.");
|
"wpa_supplicant.");
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
@ -1719,7 +1721,7 @@ void WpaGui::wpsApPin()
|
||||||
size_t reply_len = sizeof(reply);
|
size_t reply_len = sizeof(reply);
|
||||||
|
|
||||||
QString cmd("WPS_REG " + bssFromScan + " " + wpsApPinEdit->text());
|
QString cmd("WPS_REG " + bssFromScan + " " + wpsApPinEdit->text());
|
||||||
if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) < 0)
|
if (ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wpsStatusText->setText(tr("Waiting for AP/Enrollee"));
|
wpsStatusText->setText(tr("Waiting for AP/Enrollee"));
|
||||||
|
|
|
@ -16,6 +16,20 @@
|
||||||
|
|
||||||
class UserDataRequest;
|
class UserDataRequest;
|
||||||
|
|
||||||
|
class WpaGuiApp : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
WpaGuiApp(int &argc, char **argv);
|
||||||
|
|
||||||
|
#if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
|
||||||
|
virtual void saveState(QSessionManager &manager);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
WpaGui *w;
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
};
|
||||||
|
|
||||||
class WpaGui : public QMainWindow, public Ui::WpaGui
|
class WpaGui : public QMainWindow, public Ui::WpaGui
|
||||||
{
|
{
|
||||||
|
@ -35,7 +49,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
|
WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
|
||||||
Qt::WFlags fl = 0);
|
Qt::WindowFlags fl = 0);
|
||||||
~WpaGui();
|
~WpaGui();
|
||||||
|
|
||||||
virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
|
virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
|
||||||
|
|
Loading…
Reference in a new issue