2 * wpa_gui - Peers class
3 * Copyright (c) 2009, Atheros Communications
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
16 #include <QImageReader>
17 #include <QMessageBox>
19 #include "common/wpa_ctrl.h"
21 #include "stringquery.h"
26 peer_role_address
= Qt::UserRole
+ 1,
30 peer_role_pri_dev_type
,
32 peer_role_config_methods
,
33 peer_role_dev_passwd_id
,
39 * - add current AP info (e.g., from WPS) in station mode
43 PEER_TYPE_ASSOCIATED_STATION
,
46 PEER_TYPE_WPS_PIN_NEEDED
,
48 PEER_TYPE_WPS_ER_AP_UNCONFIGURED
,
49 PEER_TYPE_WPS_ER_ENROLLEE
,
50 PEER_TYPE_WPS_ENROLLEE
54 Peers::Peers(QWidget
*parent
, const char *, bool, Qt::WFlags
)
59 if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
61 default_icon
= new QIcon(":/icons/wpa_gui.svg");
62 ap_icon
= new QIcon(":/icons/ap.svg");
63 laptop_icon
= new QIcon(":/icons/laptop.svg");
65 default_icon
= new QIcon(":/icons/wpa_gui.png");
66 ap_icon
= new QIcon(":/icons/ap.png");
67 laptop_icon
= new QIcon(":/icons/laptop.png");
70 peers
->setModel(&model
);
71 peers
->setResizeMode(QListView::Adjust
);
73 peers
->setContextMenuPolicy(Qt::CustomContextMenu
);
74 connect(peers
, SIGNAL(customContextMenuRequested(const QPoint
&)),
75 this, SLOT(context_menu(const QPoint
&)));
81 void Peers::setWpaGui(WpaGui
*_wpagui
)
96 void Peers::languageChange()
102 QString
Peers::ItemType(int type
)
106 case PEER_TYPE_ASSOCIATED_STATION
:
107 title
= tr("Associated station");
112 case PEER_TYPE_AP_WPS
:
113 title
= tr("WPS AP");
115 case PEER_TYPE_WPS_PIN_NEEDED
:
116 title
= tr("WPS PIN needed");
118 case PEER_TYPE_WPS_ER_AP
:
119 title
= tr("ER: WPS AP");
121 case PEER_TYPE_WPS_ER_AP_UNCONFIGURED
:
122 title
= tr("ER: WPS AP (Unconfigured)");
124 case PEER_TYPE_WPS_ER_ENROLLEE
:
125 title
= tr("ER: WPS Enrollee");
127 case PEER_TYPE_WPS_ENROLLEE
:
128 title
= tr("WPS Enrollee");
135 void Peers::context_menu(const QPoint
&pos
)
137 QMenu
*menu
= new QMenu
;
141 QModelIndex idx
= peers
->indexAt(pos
);
143 ctx_item
= model
.itemFromIndex(idx
);
144 int type
= ctx_item
->data(peer_role_type
).toInt();
145 menu
->addAction(Peers::ItemType(type
))->setEnabled(false);
146 menu
->addSeparator();
148 int config_methods
= -1;
149 QVariant var
= ctx_item
->data(peer_role_config_methods
);
151 config_methods
= var
.toInt();
153 if ((type
== PEER_TYPE_ASSOCIATED_STATION
||
154 type
== PEER_TYPE_AP_WPS
||
155 type
== PEER_TYPE_WPS_PIN_NEEDED
||
156 type
== PEER_TYPE_WPS_ER_ENROLLEE
||
157 type
== PEER_TYPE_WPS_ENROLLEE
) &&
158 (config_methods
== -1 || (config_methods
& 0x010c))) {
159 menu
->addAction(tr("Enter WPS PIN"), this,
163 if (type
== PEER_TYPE_AP_WPS
) {
164 menu
->addAction(tr("Connect (PBC)"), this,
165 SLOT(connect_pbc()));
168 if ((type
== PEER_TYPE_ASSOCIATED_STATION
||
169 type
== PEER_TYPE_WPS_ER_ENROLLEE
||
170 type
== PEER_TYPE_WPS_ENROLLEE
) &&
171 config_methods
>= 0 && (config_methods
& 0x0080)) {
172 menu
->addAction(tr("Enroll (PBC)"), this,
173 SLOT(connect_pbc()));
176 if (type
== PEER_TYPE_WPS_ER_AP
) {
177 menu
->addAction(tr("Learn Configuration"), this,
178 SLOT(learn_ap_config()));
181 menu
->addAction(tr("Properties"), this, SLOT(properties()));
184 menu
->addAction(QString(tr("Refresh")), this,
185 SLOT(ctx_refresh()));
188 menu
->exec(peers
->mapToGlobal(pos
));
192 void Peers::enter_pin()
194 if (ctx_item
== NULL
)
197 int peer_type
= ctx_item
->data(peer_role_type
).toInt();
200 if (peer_type
== PEER_TYPE_WPS_ER_ENROLLEE
)
201 uuid
= ctx_item
->data(peer_role_uuid
).toString();
203 addr
= ctx_item
->data(peer_role_address
).toString();
205 StringQuery
input(tr("PIN:"));
206 input
.setWindowTitle(tr("PIN for ") + ctx_item
->text());
207 if (input
.exec() != QDialog::Accepted
)
214 if (peer_type
== PEER_TYPE_WPS_ER_ENROLLEE
) {
215 snprintf(cmd
, sizeof(cmd
), "WPS_ER_PIN %s %s",
216 uuid
.toAscii().constData(),
217 input
.get_string().toAscii().constData());
219 snprintf(cmd
, sizeof(cmd
), "WPS_PIN %s %s",
220 addr
.toAscii().constData(),
221 input
.get_string().toAscii().constData());
223 reply_len
= sizeof(reply
) - 1;
224 if (wpagui
->ctrlRequest(cmd
, reply
, &reply_len
) < 0) {
226 msg
.setIcon(QMessageBox::Warning
);
227 msg
.setText(tr("Failed to set the WPS PIN."));
233 void Peers::ctx_refresh()
239 void Peers::add_station(QString info
)
241 QStringList lines
= info
.split(QRegExp("\\n"));
244 for (QStringList::Iterator it
= lines
.begin();
245 it
!= lines
.end(); it
++) {
246 int pos
= (*it
).indexOf('=') + 1;
250 if ((*it
).startsWith("wpsDeviceName="))
251 name
= (*it
).mid(pos
);
257 QStandardItem
*item
= new QStandardItem(*laptop_icon
, name
);
259 item
->setData(lines
[0], peer_role_address
);
260 item
->setData(PEER_TYPE_ASSOCIATED_STATION
,
262 item
->setData(info
, peer_role_details
);
263 item
->setToolTip(ItemType(PEER_TYPE_ASSOCIATED_STATION
));
264 model
.appendRow(item
);
269 void Peers::add_stations()
276 reply_len
= sizeof(reply
) - 1;
277 if (wpagui
->ctrlRequest("STA-FIRST", reply
, &reply_len
) < 0)
281 reply
[reply_len
] = '\0';
284 while (*txt
!= '\0' && *txt
!= '\n')
287 if (strncmp(reply
, "FAIL", 4) == 0 ||
288 strncmp(reply
, "UNKNOWN", 7) == 0)
293 reply_len
= sizeof(reply
) - 1;
294 snprintf(cmd
, sizeof(cmd
), "STA-NEXT %s", reply
);
295 res
= wpagui
->ctrlRequest(cmd
, reply
, &reply_len
);
300 void Peers::add_single_station(const char *addr
)
306 reply_len
= sizeof(reply
) - 1;
307 snprintf(cmd
, sizeof(cmd
), "STA %s", addr
);
308 if (wpagui
->ctrlRequest(cmd
, reply
, &reply_len
) < 0)
311 reply
[reply_len
] = '\0';
314 while (*txt
!= '\0' && *txt
!= '\n')
317 if (strncmp(reply
, "FAIL", 4) == 0 ||
318 strncmp(reply
, "UNKNOWN", 7) == 0)
325 void Peers::remove_bss(int id
)
327 if (model
.rowCount() == 0)
330 QModelIndexList lst
= model
.match(model
.index(0, 0), peer_role_bss_id
,
334 model
.removeRow(lst
[0].row());
338 bool Peers::add_bss(const char *cmd
)
343 reply_len
= sizeof(reply
) - 1;
344 if (wpagui
->ctrlRequest(cmd
, reply
, &reply_len
) < 0)
346 reply
[reply_len
] = '\0';
349 if (bss
.isEmpty() || bss
.startsWith("FAIL"))
352 QString ssid
, bssid
, flags
, wps_name
, pri_dev_type
;
355 QStringList lines
= bss
.split(QRegExp("\\n"));
356 for (QStringList::Iterator it
= lines
.begin();
357 it
!= lines
.end(); it
++) {
358 int pos
= (*it
).indexOf('=') + 1;
362 if ((*it
).startsWith("bssid="))
363 bssid
= (*it
).mid(pos
);
364 else if ((*it
).startsWith("id="))
365 id
= (*it
).mid(pos
).toInt();
366 else if ((*it
).startsWith("flags="))
367 flags
= (*it
).mid(pos
);
368 else if ((*it
).startsWith("ssid="))
369 ssid
= (*it
).mid(pos
);
370 else if ((*it
).startsWith("wps_device_name="))
371 wps_name
= (*it
).mid(pos
);
372 else if ((*it
).startsWith("wps_primary_device_type="))
373 pri_dev_type
= (*it
).mid(pos
);
376 QString name
= wps_name
;
378 name
= ssid
+ "\n" + bssid
;
380 QStandardItem
*item
= new QStandardItem(*ap_icon
, name
);
382 item
->setData(bssid
, peer_role_address
);
384 item
->setData(id
, peer_role_bss_id
);
386 if (flags
.contains("[WPS"))
387 type
= PEER_TYPE_AP_WPS
;
390 item
->setData(type
, peer_role_type
);
392 for (int i
= 0; i
< lines
.size(); i
++) {
393 if (lines
[i
].length() > 60) {
394 lines
[i
].remove(60, lines
[i
].length());
398 item
->setToolTip(ItemType(type
));
399 item
->setData(lines
.join("\n"), peer_role_details
);
400 if (!pri_dev_type
.isEmpty())
401 item
->setData(pri_dev_type
,
402 peer_role_pri_dev_type
);
404 item
->setData(ssid
, peer_role_ssid
);
405 model
.appendRow(item
);
412 void Peers::add_scan_results()
419 snprintf(cmd
, sizeof(cmd
), "BSS %d", index
++);
429 void Peers::update_peers()
436 size_t replylen
= sizeof(reply
) - 1;
437 wpagui
->ctrlRequest("WPS_ER_START", reply
, &replylen
);
444 QStandardItem
* Peers::find_addr(QString addr
)
446 if (model
.rowCount() == 0)
449 QModelIndexList lst
= model
.match(model
.index(0, 0), peer_role_address
,
453 return model
.itemFromIndex(lst
[0]);
457 QStandardItem
* Peers::find_uuid(QString uuid
)
459 if (model
.rowCount() == 0)
462 QModelIndexList lst
= model
.match(model
.index(0, 0), peer_role_uuid
,
466 return model
.itemFromIndex(lst
[0]);
470 void Peers::event_notify(WpaMsg msg
)
472 QString text
= msg
.getMsg();
474 if (text
.startsWith(WPS_EVENT_PIN_NEEDED
)) {
476 * WPS-PIN-NEEDED 5a02a5fa-9199-5e7c-bc46-e183d3cb32f7
478 * [Wireless Client|Company|cmodel|123|12345|1-0050F204-1]
480 QStringList items
= text
.split(' ');
481 QString uuid
= items
[1];
482 QString addr
= items
[2];
485 QStandardItem
*item
= find_addr(addr
);
489 int pos
= text
.indexOf('[');
491 int pos2
= text
.lastIndexOf(']');
493 items
= text
.mid(pos
+ 1, pos2
- pos
- 1).
500 item
= new QStandardItem(*laptop_icon
, name
);
502 item
->setData(addr
, peer_role_address
);
503 item
->setData(PEER_TYPE_WPS_PIN_NEEDED
,
505 item
->setToolTip(ItemType(PEER_TYPE_WPS_PIN_NEEDED
));
506 item
->setData(items
.join("\n"), peer_role_details
);
507 item
->setData(items
[5], peer_role_pri_dev_type
);
508 model
.appendRow(item
);
513 if (text
.startsWith(AP_STA_CONNECTED
)) {
514 /* AP-STA-CONNECTED 02:2a:c4:18:5b:f3 */
515 QStringList items
= text
.split(' ');
516 QString addr
= items
[1];
517 QStandardItem
*item
= find_addr(addr
);
518 if (item
== NULL
|| item
->data(peer_role_type
).toInt() !=
519 PEER_TYPE_ASSOCIATED_STATION
)
520 add_single_station(addr
.toAscii().constData());
524 if (text
.startsWith(AP_STA_DISCONNECTED
)) {
525 /* AP-STA-DISCONNECTED 02:2a:c4:18:5b:f3 */
526 QStringList items
= text
.split(' ');
527 QString addr
= items
[1];
529 if (model
.rowCount() == 0)
532 QModelIndexList lst
= model
.match(model
.index(0, 0),
533 peer_role_address
, addr
);
534 for (int i
= 0; i
< lst
.size(); i
++) {
535 QStandardItem
*item
= model
.itemFromIndex(lst
[i
]);
536 if (item
&& item
->data(peer_role_type
).toInt() ==
537 PEER_TYPE_ASSOCIATED_STATION
)
538 model
.removeRow(lst
[i
].row());
543 if (text
.startsWith(WPS_EVENT_ER_AP_ADD
)) {
545 * WPS-ER-AP-ADD 87654321-9abc-def0-1234-56789abc0002
546 * 02:11:22:33:44:55 pri_dev_type=6-0050F204-1 wps_state=1
547 * |Very friendly name|Company|Long description of the model|
548 * WAP|http://w1.fi/|http://w1.fi/hostapd/
550 QStringList items
= text
.split(' ');
551 if (items
.size() < 5)
553 QString uuid
= items
[1];
554 QString addr
= items
[2];
555 QString pri_dev_type
= items
[3].mid(13);
556 int wps_state
= items
[4].mid(10).toInt();
558 int pos
= text
.indexOf('|');
561 items
= text
.mid(pos
+ 1).split('|');
562 if (items
.size() < 1)
565 QStandardItem
*item
= find_uuid(uuid
);
569 item
= new QStandardItem(*ap_icon
, items
[0]);
571 item
->setData(uuid
, peer_role_uuid
);
572 item
->setData(addr
, peer_role_address
);
573 int type
= wps_state
== 2 ? PEER_TYPE_WPS_ER_AP
:
574 PEER_TYPE_WPS_ER_AP_UNCONFIGURED
;
575 item
->setData(type
, peer_role_type
);
576 item
->setToolTip(ItemType(type
));
577 item
->setData(pri_dev_type
, peer_role_pri_dev_type
);
578 item
->setData(items
.join(QString("\n")),
580 model
.appendRow(item
);
586 if (text
.startsWith(WPS_EVENT_ER_AP_REMOVE
)) {
587 /* WPS-ER-AP-REMOVE 87654321-9abc-def0-1234-56789abc0002 */
588 QStringList items
= text
.split(' ');
589 if (items
.size() < 2)
591 if (model
.rowCount() == 0)
594 QModelIndexList lst
= model
.match(model
.index(0, 0),
595 peer_role_uuid
, items
[1]);
596 for (int i
= 0; i
< lst
.size(); i
++) {
597 QStandardItem
*item
= model
.itemFromIndex(lst
[i
]);
599 (item
->data(peer_role_type
).toInt() ==
600 PEER_TYPE_WPS_ER_AP
||
601 item
->data(peer_role_type
).toInt() ==
602 PEER_TYPE_WPS_ER_AP_UNCONFIGURED
))
603 model
.removeRow(lst
[i
].row());
608 if (text
.startsWith(WPS_EVENT_ER_ENROLLEE_ADD
)) {
610 * WPS-ER-ENROLLEE-ADD 2b7093f1-d6fb-5108-adbb-bea66bb87333
611 * 02:66:a0:ee:17:27 M1=1 config_methods=0x14d dev_passwd_id=0
612 * pri_dev_type=1-0050F204-1
613 * |Wireless Client|Company|cmodel|123|12345|
615 QStringList items
= text
.split(' ');
616 if (items
.size() < 3)
618 QString uuid
= items
[1];
619 QString addr
= items
[2];
620 QString pri_dev_type
= items
[6].mid(13);
621 int config_methods
= -1;
622 int dev_passwd_id
= -1;
624 for (int i
= 3; i
< items
.size(); i
++) {
625 int pos
= items
[i
].indexOf('=') + 1;
628 QString val
= items
[i
].mid(pos
);
629 if (items
[i
].startsWith("config_methods=")) {
630 config_methods
= val
.toInt(0, 0);
631 } else if (items
[i
].startsWith("dev_passwd_id=")) {
632 dev_passwd_id
= val
.toInt();
636 int pos
= text
.indexOf('|');
639 items
= text
.mid(pos
+ 1).split('|');
640 if (items
.size() < 1)
642 QString name
= items
[0];
643 if (name
.length() == 0)
646 remove_enrollee_uuid(uuid
);
649 item
= new QStandardItem(*laptop_icon
, name
);
651 item
->setData(uuid
, peer_role_uuid
);
652 item
->setData(addr
, peer_role_address
);
653 item
->setData(PEER_TYPE_WPS_ER_ENROLLEE
,
655 item
->setToolTip(ItemType(PEER_TYPE_WPS_ER_ENROLLEE
));
656 item
->setData(items
.join(QString("\n")),
658 item
->setData(pri_dev_type
, peer_role_pri_dev_type
);
659 if (config_methods
>= 0)
660 item
->setData(config_methods
,
661 peer_role_config_methods
);
662 if (dev_passwd_id
>= 0)
663 item
->setData(dev_passwd_id
,
664 peer_role_dev_passwd_id
);
665 model
.appendRow(item
);
671 if (text
.startsWith(WPS_EVENT_ER_ENROLLEE_REMOVE
)) {
673 * WPS-ER-ENROLLEE-REMOVE 2b7093f1-d6fb-5108-adbb-bea66bb87333
676 QStringList items
= text
.split(' ');
677 if (items
.size() < 2)
679 remove_enrollee_uuid(items
[1]);
683 if (text
.startsWith(WPS_EVENT_ENROLLEE_SEEN
)) {
684 /* TODO: need to time out this somehow or remove on successful
687 * WPS-ENROLLEE-SEEN 02:00:00:00:01:00
688 * 572cf82f-c957-5653-9b16-b5cfb298abf1 1-0050F204-1 0x80 4 1
690 * (MAC addr, UUID-E, pri dev type, config methods,
691 * dev passwd id, request type, [dev name])
693 QStringList items
= text
.split(' ');
694 if (items
.size() < 7)
696 QString addr
= items
[1];
697 QString uuid
= items
[2];
698 QString pri_dev_type
= items
[3];
699 int config_methods
= items
[4].toInt(0, 0);
700 int dev_passwd_id
= items
[5].toInt();
703 int pos
= text
.indexOf('[');
705 int pos2
= text
.lastIndexOf(']');
708 text
.mid(pos
+ 1, pos2
- pos
- 1).
718 item
= find_uuid(uuid
);
720 QVariant var
= item
->data(peer_role_config_methods
);
721 QVariant var2
= item
->data(peer_role_dev_passwd_id
);
722 if ((var
.isValid() && config_methods
!= var
.toInt()) ||
723 (var2
.isValid() && dev_passwd_id
!= var2
.toInt()))
724 remove_enrollee_uuid(uuid
);
729 item
= new QStandardItem(*laptop_icon
, name
);
731 item
->setData(uuid
, peer_role_uuid
);
732 item
->setData(addr
, peer_role_address
);
733 item
->setData(PEER_TYPE_WPS_ENROLLEE
,
735 item
->setToolTip(ItemType(PEER_TYPE_WPS_ENROLLEE
));
736 item
->setData(items
.join(QString("\n")),
738 item
->setData(pri_dev_type
, peer_role_pri_dev_type
);
739 item
->setData(config_methods
,
740 peer_role_config_methods
);
741 item
->setData(dev_passwd_id
, peer_role_dev_passwd_id
);
742 model
.appendRow(item
);
748 if (text
.startsWith(WPA_EVENT_BSS_ADDED
)) {
749 /* CTRL-EVENT-BSS-ADDED 34 00:11:22:33:44:55 */
750 QStringList items
= text
.split(' ');
751 if (items
.size() < 2)
754 snprintf(cmd
, sizeof(cmd
), "BSS ID-%d", items
[1].toInt());
759 if (text
.startsWith(WPA_EVENT_BSS_REMOVED
)) {
760 /* CTRL-EVENT-BSS-REMOVED 34 00:11:22:33:44:55 */
761 QStringList items
= text
.split(' ');
762 if (items
.size() < 2)
764 remove_bss(items
[1].toInt());
770 void Peers::closeEvent(QCloseEvent
*)
774 size_t replylen
= sizeof(reply
) - 1;
775 wpagui
->ctrlRequest("WPS_ER_STOP", reply
, &replylen
);
780 void Peers::done(int r
)
787 void Peers::remove_enrollee_uuid(QString uuid
)
789 if (model
.rowCount() == 0)
792 QModelIndexList lst
= model
.match(model
.index(0, 0),
793 peer_role_uuid
, uuid
);
794 for (int i
= 0; i
< lst
.size(); i
++) {
795 QStandardItem
*item
= model
.itemFromIndex(lst
[i
]);
798 int type
= item
->data(peer_role_type
).toInt();
799 if (type
== PEER_TYPE_WPS_ER_ENROLLEE
||
800 type
== PEER_TYPE_WPS_ENROLLEE
)
801 model
.removeRow(lst
[i
].row());
806 void Peers::properties()
808 if (ctx_item
== NULL
)
811 QMessageBox
msg(this);
812 msg
.setStandardButtons(QMessageBox::Ok
);
813 msg
.setDefaultButton(QMessageBox::Ok
);
814 msg
.setEscapeButton(QMessageBox::Ok
);
815 msg
.setWindowTitle(tr("Peer Properties"));
817 int type
= ctx_item
->data(peer_role_type
).toInt();
818 QString title
= Peers::ItemType(type
);
820 msg
.setText(title
+ QString("\n") + tr("Name: ") + ctx_item
->text());
825 var
= ctx_item
->data(peer_role_address
);
827 info
+= tr("Address: ") + var
.toString() + QString("\n");
829 var
= ctx_item
->data(peer_role_uuid
);
831 info
+= tr("UUID: ") + var
.toString() + QString("\n");
833 var
= ctx_item
->data(peer_role_pri_dev_type
);
835 info
+= tr("Primary Device Type: ") + var
.toString() +
838 var
= ctx_item
->data(peer_role_ssid
);
840 info
+= tr("SSID: ") + var
.toString() + QString("\n");
842 var
= ctx_item
->data(peer_role_config_methods
);
844 int methods
= var
.toInt();
845 info
+= tr("Configuration Methods: ");
846 if (methods
& 0x0001)
847 info
+= tr("[USBA]");
848 if (methods
& 0x0002)
849 info
+= tr("[Ethernet]");
850 if (methods
& 0x0004)
851 info
+= tr("[Label]");
852 if (methods
& 0x0008)
853 info
+= tr("[Display]");
854 if (methods
& 0x0010)
855 info
+= tr("[Ext. NFC Token]");
856 if (methods
& 0x0020)
857 info
+= tr("[Int. NFC Token]");
858 if (methods
& 0x0040)
859 info
+= tr("[NFC Interface]");
860 if (methods
& 0x0080)
861 info
+= tr("[Push Button]");
862 if (methods
& 0x0100)
863 info
+= tr("[Keypad]");
867 var
= ctx_item
->data(peer_role_dev_passwd_id
);
869 info
+= tr("Device Password ID: ") + var
.toString();
870 switch (var
.toInt()) {
872 info
+= tr(" (Default PIN)");
875 info
+= tr(" (User-specified PIN)");
878 info
+= tr(" (Machine-specified PIN)");
881 info
+= tr(" (Rekey)");
884 info
+= tr(" (Push Button)");
887 info
+= tr(" (Registrar-specified)");
893 msg
.setInformativeText(info
);
895 var
= ctx_item
->data(peer_role_details
);
897 msg
.setDetailedText(var
.toString());
903 void Peers::connect_pbc()
905 if (ctx_item
== NULL
)
912 int peer_type
= ctx_item
->data(peer_role_type
).toInt();
913 if (peer_type
== PEER_TYPE_WPS_ER_ENROLLEE
) {
914 snprintf(cmd
, sizeof(cmd
), "WPS_ER_PBC %s",
915 ctx_item
->data(peer_role_uuid
).toString().toAscii().
918 snprintf(cmd
, sizeof(cmd
), "WPS_PBC");
920 reply_len
= sizeof(reply
) - 1;
921 if (wpagui
->ctrlRequest(cmd
, reply
, &reply_len
) < 0) {
923 msg
.setIcon(QMessageBox::Warning
);
924 msg
.setText(tr("Failed to start WPS PBC."));
930 void Peers::learn_ap_config()
932 if (ctx_item
== NULL
)
935 QString uuid
= ctx_item
->data(peer_role_uuid
).toString();
937 StringQuery
input(tr("AP PIN:"));
938 input
.setWindowTitle(tr("AP PIN for ") + ctx_item
->text());
939 if (input
.exec() != QDialog::Accepted
)
946 snprintf(cmd
, sizeof(cmd
), "WPS_ER_LEARN %s %s",
947 uuid
.toAscii().constData(),
948 input
.get_string().toAscii().constData());
949 reply_len
= sizeof(reply
) - 1;
950 if (wpagui
->ctrlRequest(cmd
, reply
, &reply_len
) < 0) {
952 msg
.setIcon(QMessageBox::Warning
);
953 msg
.setText(tr("Failed to start learning AP configuration."));