wpa_gui: Add peer dialog option for WPS PBC
Use advertised configuration methods to determine whether WPS PBC and/or PIN methods should be allowed.
This commit is contained in:
parent
175bba7986
commit
d6211fbb2e
2 changed files with 50 additions and 6 deletions
|
@ -140,16 +140,32 @@ void Peers::context_menu(const QPoint &pos)
|
||||||
menu->addAction(Peers::ItemType(type))->setEnabled(false);
|
menu->addAction(Peers::ItemType(type))->setEnabled(false);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
if (type == PEER_TYPE_ASSOCIATED_STATION ||
|
int config_methods = -1;
|
||||||
type == PEER_TYPE_AP_WPS ||
|
QVariant var = ctx_item->data(peer_role_config_methods);
|
||||||
type == PEER_TYPE_WPS_PIN_NEEDED ||
|
if (var.isValid())
|
||||||
type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
config_methods = var.toInt();
|
||||||
/* TODO: only for peers that are requesting WPS PIN
|
|
||||||
* method */
|
if ((type == PEER_TYPE_ASSOCIATED_STATION ||
|
||||||
|
type == PEER_TYPE_AP_WPS ||
|
||||||
|
type == PEER_TYPE_WPS_PIN_NEEDED ||
|
||||||
|
type == PEER_TYPE_WPS_ER_ENROLLEE) &&
|
||||||
|
(config_methods == -1 || (config_methods & 0x010c))) {
|
||||||
menu->addAction(tr("Enter WPS PIN"), this,
|
menu->addAction(tr("Enter WPS PIN"), this,
|
||||||
SLOT(enter_pin()));
|
SLOT(enter_pin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == PEER_TYPE_AP_WPS) {
|
||||||
|
menu->addAction(tr("Connect (PBC)"), this,
|
||||||
|
SLOT(connect_pbc()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((type == PEER_TYPE_ASSOCIATED_STATION ||
|
||||||
|
type == PEER_TYPE_WPS_ER_ENROLLEE) &&
|
||||||
|
config_methods >= 0 && (config_methods & 0x0080)) {
|
||||||
|
menu->addAction(tr("Enroll (PBC)"), this,
|
||||||
|
SLOT(connect_pbc()));
|
||||||
|
}
|
||||||
|
|
||||||
menu->addAction(tr("Properties"), this, SLOT(properties()));
|
menu->addAction(tr("Properties"), this, SLOT(properties()));
|
||||||
} else {
|
} else {
|
||||||
ctx_item = NULL;
|
ctx_item = NULL;
|
||||||
|
@ -754,3 +770,30 @@ void Peers::properties()
|
||||||
|
|
||||||
msg.exec();
|
msg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Peers::connect_pbc()
|
||||||
|
{
|
||||||
|
if (ctx_item == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char cmd[100];
|
||||||
|
char reply[100];
|
||||||
|
size_t reply_len;
|
||||||
|
|
||||||
|
int peer_type = ctx_item->data(peer_role_type).toInt();
|
||||||
|
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
|
||||||
|
snprintf(cmd, sizeof(cmd), "WPS_ER_PBC %s",
|
||||||
|
ctx_item->data(peer_role_uuid).toString().toAscii().
|
||||||
|
constData());
|
||||||
|
} else {
|
||||||
|
snprintf(cmd, sizeof(cmd), "WPS_PBC");
|
||||||
|
}
|
||||||
|
reply_len = sizeof(reply) - 1;
|
||||||
|
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setIcon(QMessageBox::Warning);
|
||||||
|
msg.setText("Failed to start WPS PBC.");
|
||||||
|
msg.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void context_menu(const QPoint &pos);
|
virtual void context_menu(const QPoint &pos);
|
||||||
virtual void enter_pin();
|
virtual void enter_pin();
|
||||||
|
virtual void connect_pbc();
|
||||||
virtual void ctx_refresh();
|
virtual void ctx_refresh();
|
||||||
virtual void properties();
|
virtual void properties();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue