networkconfig.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. * wpa_gui - NetworkConfig class
  3. * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
  4. *
  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.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include <QMessageBox>
  15. #include "networkconfig.h"
  16. #include "wpagui.h"
  17. enum {
  18. AUTH_NONE = 0,
  19. AUTH_IEEE8021X = 1,
  20. AUTH_WPA_PSK = 2,
  21. AUTH_WPA_EAP = 3,
  22. AUTH_WPA2_PSK = 4,
  23. AUTH_WPA2_EAP = 5
  24. };
  25. #define WPA_GUI_KEY_DATA "[key is configured]"
  26. NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool, Qt::WFlags)
  27. : QDialog(parent)
  28. {
  29. setupUi(this);
  30. connect(authSelect, SIGNAL(activated(int)), this,
  31. SLOT(authChanged(int)));
  32. connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
  33. connect(addButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
  34. connect(encrSelect, SIGNAL(activated(const QString &)), this,
  35. SLOT(encrChanged(const QString &)));
  36. connect(removeButton, SIGNAL(clicked()), this, SLOT(removeNetwork()));
  37. wpagui = NULL;
  38. new_network = false;
  39. }
  40. NetworkConfig::~NetworkConfig()
  41. {
  42. }
  43. void NetworkConfig::languageChange()
  44. {
  45. retranslateUi(this);
  46. }
  47. void NetworkConfig::paramsFromScanResults(QTreeWidgetItem *sel)
  48. {
  49. new_network = true;
  50. /* SSID BSSID frequency signal flags */
  51. setWindowTitle(sel->text(0));
  52. ssidEdit->setText(sel->text(0));
  53. QString flags = sel->text(4);
  54. int auth, encr = 0;
  55. if (flags.indexOf("[WPA2-EAP") >= 0)
  56. auth = AUTH_WPA2_EAP;
  57. else if (flags.indexOf("[WPA-EAP") >= 0)
  58. auth = AUTH_WPA_EAP;
  59. else if (flags.indexOf("[WPA2-PSK") >= 0)
  60. auth = AUTH_WPA2_PSK;
  61. else if (flags.indexOf("[WPA-PSK") >= 0)
  62. auth = AUTH_WPA_PSK;
  63. else
  64. auth = AUTH_NONE;
  65. if (flags.indexOf("-CCMP") >= 0)
  66. encr = 1;
  67. else if (flags.indexOf("-TKIP") >= 0)
  68. encr = 0;
  69. else if (flags.indexOf("WEP") >= 0)
  70. encr = 1;
  71. else
  72. encr = 0;
  73. authSelect->setCurrentIndex(auth);
  74. authChanged(auth);
  75. encrSelect->setCurrentIndex(encr);
  76. wepEnabled(auth == AUTH_NONE && encr == 1);
  77. getEapCapa();
  78. }
  79. void NetworkConfig::authChanged(int sel)
  80. {
  81. pskEdit->setEnabled(sel == AUTH_WPA_PSK || sel == AUTH_WPA2_PSK);
  82. bool eap = sel == AUTH_IEEE8021X || sel == AUTH_WPA_EAP ||
  83. sel == AUTH_WPA2_EAP;
  84. eapSelect->setEnabled(eap);
  85. identityEdit->setEnabled(eap);
  86. passwordEdit->setEnabled(eap);
  87. cacertEdit->setEnabled(eap);
  88. while (encrSelect->count())
  89. encrSelect->removeItem(0);
  90. if (sel == AUTH_NONE || sel == AUTH_IEEE8021X) {
  91. encrSelect->addItem("None");
  92. encrSelect->addItem("WEP");
  93. encrSelect->setCurrentIndex(sel == AUTH_NONE ? 0 : 1);
  94. } else {
  95. encrSelect->addItem("TKIP");
  96. encrSelect->addItem("CCMP");
  97. encrSelect->setCurrentIndex((sel == AUTH_WPA2_PSK ||
  98. sel == AUTH_WPA2_EAP) ? 1 : 0);
  99. }
  100. wepEnabled(sel == AUTH_IEEE8021X);
  101. }
  102. void NetworkConfig::addNetwork()
  103. {
  104. char reply[10], cmd[256];
  105. size_t reply_len;
  106. int id;
  107. int psklen = pskEdit->text().length();
  108. int auth = authSelect->currentIndex();
  109. if (auth == AUTH_WPA_PSK || auth == AUTH_WPA2_PSK) {
  110. if (psklen < 8 || psklen > 64) {
  111. QMessageBox::warning(this, "WPA Pre-Shared Key Error",
  112. "WPA-PSK requires a passphrase "
  113. "of 8 to 63 characters\n"
  114. "or 64 hex digit PSK");
  115. pskEdit->setFocus();
  116. return;
  117. }
  118. }
  119. if (idstrEdit->isEnabled() && !idstrEdit->text().isEmpty()) {
  120. QRegExp rx("^(\\w|-)+$");
  121. if (rx.indexIn(idstrEdit->text()) < 0) {
  122. QMessageBox::warning(this, "Network ID Error",
  123. "Network ID String contains "
  124. "non-word characters.\n"
  125. "It must be a simple string, "
  126. "without spaces, containing\n"
  127. "only characters in this range: "
  128. "[A-Za-z0-9_-]\n");
  129. idstrEdit->setFocus();
  130. return;
  131. }
  132. }
  133. if (wpagui == NULL)
  134. return;
  135. memset(reply, 0, sizeof(reply));
  136. reply_len = sizeof(reply) - 1;
  137. if (new_network) {
  138. wpagui->ctrlRequest("ADD_NETWORK", reply, &reply_len);
  139. if (reply[0] == 'F') {
  140. QMessageBox::warning(this, "wpa_gui", "Failed to add "
  141. "network to wpa_supplicant\n"
  142. "configuration.");
  143. return;
  144. }
  145. id = atoi(reply);
  146. } else
  147. id = edit_network_id;
  148. setNetworkParam(id, "ssid", ssidEdit->text().toAscii().constData(),
  149. true);
  150. const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
  151. switch (auth) {
  152. case AUTH_NONE:
  153. key_mgmt = "NONE";
  154. break;
  155. case AUTH_IEEE8021X:
  156. key_mgmt = "IEEE8021X";
  157. break;
  158. case AUTH_WPA_PSK:
  159. key_mgmt = "WPA-PSK";
  160. proto = "WPA";
  161. break;
  162. case AUTH_WPA_EAP:
  163. key_mgmt = "WPA-EAP";
  164. proto = "WPA";
  165. break;
  166. case AUTH_WPA2_PSK:
  167. key_mgmt = "WPA-PSK";
  168. proto = "WPA2";
  169. break;
  170. case AUTH_WPA2_EAP:
  171. key_mgmt = "WPA-EAP";
  172. proto = "WPA2";
  173. break;
  174. }
  175. if (auth == AUTH_WPA_PSK || auth == AUTH_WPA_EAP ||
  176. auth == AUTH_WPA2_PSK || auth == AUTH_WPA2_EAP) {
  177. int encr = encrSelect->currentIndex();
  178. if (encr == 0)
  179. pairwise = "TKIP";
  180. else
  181. pairwise = "CCMP";
  182. }
  183. if (proto)
  184. setNetworkParam(id, "proto", proto, false);
  185. if (key_mgmt)
  186. setNetworkParam(id, "key_mgmt", key_mgmt, false);
  187. if (pairwise) {
  188. setNetworkParam(id, "pairwise", pairwise, false);
  189. setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
  190. }
  191. if (pskEdit->isEnabled() &&
  192. strcmp(passwordEdit->text().toAscii().constData(),
  193. WPA_GUI_KEY_DATA) != 0)
  194. setNetworkParam(id, "psk",
  195. pskEdit->text().toAscii().constData(),
  196. psklen != 64);
  197. if (eapSelect->isEnabled()) {
  198. const char *eap =
  199. eapSelect->currentText().toAscii().constData();
  200. setNetworkParam(id, "eap", eap, false);
  201. if (strcmp(eap, "SIM") == 0 || strcmp(eap, "AKA") == 0)
  202. setNetworkParam(id, "pcsc", "", true);
  203. }
  204. if (identityEdit->isEnabled())
  205. setNetworkParam(id, "identity",
  206. identityEdit->text().toAscii().constData(),
  207. true);
  208. if (passwordEdit->isEnabled() &&
  209. strcmp(passwordEdit->text().toAscii().constData(),
  210. WPA_GUI_KEY_DATA) != 0)
  211. setNetworkParam(id, "password",
  212. passwordEdit->text().toAscii().constData(),
  213. true);
  214. if (cacertEdit->isEnabled())
  215. setNetworkParam(id, "ca_cert",
  216. cacertEdit->text().toAscii().constData(),
  217. true);
  218. writeWepKey(id, wep0Edit, 0);
  219. writeWepKey(id, wep1Edit, 1);
  220. writeWepKey(id, wep2Edit, 2);
  221. writeWepKey(id, wep3Edit, 3);
  222. if (wep0Radio->isEnabled() && wep0Radio->isChecked())
  223. setNetworkParam(id, "wep_tx_keyidx", "0", false);
  224. else if (wep1Radio->isEnabled() && wep1Radio->isChecked())
  225. setNetworkParam(id, "wep_tx_keyidx", "1", false);
  226. else if (wep2Radio->isEnabled() && wep2Radio->isChecked())
  227. setNetworkParam(id, "wep_tx_keyidx", "2", false);
  228. else if (wep3Radio->isEnabled() && wep3Radio->isChecked())
  229. setNetworkParam(id, "wep_tx_keyidx", "3", false);
  230. if (idstrEdit->isEnabled())
  231. setNetworkParam(id, "id_str",
  232. idstrEdit->text().toAscii().constData(),
  233. true);
  234. if (prioritySpinBox->isEnabled()) {
  235. QString prio;
  236. prio = prio.setNum(prioritySpinBox->value());
  237. setNetworkParam(id, "priority", prio.toAscii().constData(),
  238. false);
  239. }
  240. snprintf(cmd, sizeof(cmd), "ENABLE_NETWORK %d", id);
  241. reply_len = sizeof(reply);
  242. wpagui->ctrlRequest(cmd, reply, &reply_len);
  243. if (strncmp(reply, "OK", 2) != 0) {
  244. QMessageBox::warning(this, "wpa_gui", "Failed to enable "
  245. "network in wpa_supplicant\n"
  246. "configuration.");
  247. /* Network was added, so continue anyway */
  248. }
  249. wpagui->triggerUpdate();
  250. wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
  251. close();
  252. }
  253. void NetworkConfig::setWpaGui(WpaGui *_wpagui)
  254. {
  255. wpagui = _wpagui;
  256. }
  257. int NetworkConfig::setNetworkParam(int id, const char *field,
  258. const char *value, bool quote)
  259. {
  260. char reply[10], cmd[256];
  261. size_t reply_len;
  262. snprintf(cmd, sizeof(cmd), "SET_NETWORK %d %s %s%s%s",
  263. id, field, quote ? "\"" : "", value, quote ? "\"" : "");
  264. reply_len = sizeof(reply);
  265. wpagui->ctrlRequest(cmd, reply, &reply_len);
  266. return strncmp(reply, "OK", 2) == 0 ? 0 : -1;
  267. }
  268. void NetworkConfig::encrChanged(const QString &sel)
  269. {
  270. wepEnabled(sel.indexOf("WEP") == 0);
  271. }
  272. void NetworkConfig::wepEnabled(bool enabled)
  273. {
  274. wep0Edit->setEnabled(enabled);
  275. wep1Edit->setEnabled(enabled);
  276. wep2Edit->setEnabled(enabled);
  277. wep3Edit->setEnabled(enabled);
  278. wep0Radio->setEnabled(enabled);
  279. wep1Radio->setEnabled(enabled);
  280. wep2Radio->setEnabled(enabled);
  281. wep3Radio->setEnabled(enabled);
  282. }
  283. void NetworkConfig::writeWepKey(int network_id, QLineEdit *edit, int id)
  284. {
  285. char buf[10];
  286. bool hex;
  287. const char *txt, *pos;
  288. size_t len;
  289. if (!edit->isEnabled() || edit->text().isEmpty())
  290. return;
  291. /*
  292. * Assume hex key if only hex characters are present and length matches
  293. * with 40, 104, or 128-bit key
  294. */
  295. txt = edit->text().toAscii().constData();
  296. if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
  297. return;
  298. len = strlen(txt);
  299. if (len == 0)
  300. return;
  301. pos = txt;
  302. hex = true;
  303. while (*pos) {
  304. if (!((*pos >= '0' && *pos <= '9') ||
  305. (*pos >= 'a' && *pos <= 'f') ||
  306. (*pos >= 'A' && *pos <= 'F'))) {
  307. hex = false;
  308. break;
  309. }
  310. pos++;
  311. }
  312. if (hex && len != 10 && len != 26 && len != 32)
  313. hex = false;
  314. snprintf(buf, sizeof(buf), "wep_key%d", id);
  315. setNetworkParam(network_id, buf, txt, !hex);
  316. }
  317. static int key_value_isset(const char *reply, size_t reply_len)
  318. {
  319. return reply_len > 0 && (reply_len < 4 || memcmp(reply, "FAIL", 4) != 0);
  320. }
  321. void NetworkConfig::paramsFromConfig(int network_id)
  322. {
  323. int i, res;
  324. edit_network_id = network_id;
  325. getEapCapa();
  326. char reply[1024], cmd[256], *pos;
  327. size_t reply_len;
  328. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ssid", network_id);
  329. reply_len = sizeof(reply) - 1;
  330. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  331. reply_len >= 2 && reply[0] == '"') {
  332. reply[reply_len] = '\0';
  333. pos = strchr(reply + 1, '"');
  334. if (pos)
  335. *pos = '\0';
  336. ssidEdit->setText(reply + 1);
  337. }
  338. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d proto", network_id);
  339. reply_len = sizeof(reply) - 1;
  340. int wpa = 0;
  341. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  342. reply[reply_len] = '\0';
  343. if (strstr(reply, "RSN") || strstr(reply, "WPA2"))
  344. wpa = 2;
  345. else if (strstr(reply, "WPA"))
  346. wpa = 1;
  347. }
  348. int auth = AUTH_NONE, encr = 0;
  349. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d key_mgmt", network_id);
  350. reply_len = sizeof(reply) - 1;
  351. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  352. reply[reply_len] = '\0';
  353. if (strstr(reply, "WPA-EAP"))
  354. auth = wpa & 2 ? AUTH_WPA2_EAP : AUTH_WPA_EAP;
  355. else if (strstr(reply, "WPA-PSK"))
  356. auth = wpa & 2 ? AUTH_WPA2_PSK : AUTH_WPA_PSK;
  357. else if (strstr(reply, "IEEE8021X")) {
  358. auth = AUTH_IEEE8021X;
  359. encr = 1;
  360. }
  361. }
  362. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d pairwise", network_id);
  363. reply_len = sizeof(reply) - 1;
  364. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  365. reply[reply_len] = '\0';
  366. if (strstr(reply, "CCMP") && auth != AUTH_NONE)
  367. encr = 1;
  368. else if (strstr(reply, "TKIP"))
  369. encr = 0;
  370. else if (strstr(reply, "WEP"))
  371. encr = 1;
  372. else
  373. encr = 0;
  374. }
  375. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d psk", network_id);
  376. reply_len = sizeof(reply) - 1;
  377. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  378. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  379. reply[reply_len] = '\0';
  380. pos = strchr(reply + 1, '"');
  381. if (pos)
  382. *pos = '\0';
  383. pskEdit->setText(reply + 1);
  384. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  385. pskEdit->setText(WPA_GUI_KEY_DATA);
  386. }
  387. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d identity", network_id);
  388. reply_len = sizeof(reply) - 1;
  389. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  390. reply_len >= 2 && reply[0] == '"') {
  391. reply[reply_len] = '\0';
  392. pos = strchr(reply + 1, '"');
  393. if (pos)
  394. *pos = '\0';
  395. identityEdit->setText(reply + 1);
  396. }
  397. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d password", network_id);
  398. reply_len = sizeof(reply) - 1;
  399. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  400. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  401. reply[reply_len] = '\0';
  402. pos = strchr(reply + 1, '"');
  403. if (pos)
  404. *pos = '\0';
  405. passwordEdit->setText(reply + 1);
  406. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  407. passwordEdit->setText(WPA_GUI_KEY_DATA);
  408. }
  409. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ca_cert", network_id);
  410. reply_len = sizeof(reply) - 1;
  411. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  412. reply_len >= 2 && reply[0] == '"') {
  413. reply[reply_len] = '\0';
  414. pos = strchr(reply + 1, '"');
  415. if (pos)
  416. *pos = '\0';
  417. cacertEdit->setText(reply + 1);
  418. }
  419. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d eap", network_id);
  420. reply_len = sizeof(reply) - 1;
  421. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  422. reply_len >= 1) {
  423. reply[reply_len] = '\0';
  424. for (i = 0; i < eapSelect->count(); i++) {
  425. if (eapSelect->itemText(i).compare(reply) == 0) {
  426. eapSelect->setCurrentIndex(i);
  427. break;
  428. }
  429. }
  430. }
  431. for (i = 0; i < 4; i++) {
  432. QLineEdit *wepEdit;
  433. switch (i) {
  434. default:
  435. case 0:
  436. wepEdit = wep0Edit;
  437. break;
  438. case 1:
  439. wepEdit = wep1Edit;
  440. break;
  441. case 2:
  442. wepEdit = wep2Edit;
  443. break;
  444. case 3:
  445. wepEdit = wep3Edit;
  446. break;
  447. }
  448. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_key%d",
  449. network_id, i);
  450. reply_len = sizeof(reply) - 1;
  451. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  452. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  453. reply[reply_len] = '\0';
  454. pos = strchr(reply + 1, '"');
  455. if (pos)
  456. *pos = '\0';
  457. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  458. encr = 1;
  459. wepEdit->setText(reply + 1);
  460. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  461. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  462. encr = 1;
  463. wepEdit->setText(WPA_GUI_KEY_DATA);
  464. }
  465. }
  466. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_tx_keyidx", network_id);
  467. reply_len = sizeof(reply) - 1;
  468. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
  469. {
  470. reply[reply_len] = '\0';
  471. switch (atoi(reply)) {
  472. case 0:
  473. wep0Radio->setChecked(true);
  474. break;
  475. case 1:
  476. wep1Radio->setChecked(true);
  477. break;
  478. case 2:
  479. wep2Radio->setChecked(true);
  480. break;
  481. case 3:
  482. wep3Radio->setChecked(true);
  483. break;
  484. }
  485. }
  486. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d id_str", network_id);
  487. reply_len = sizeof(reply) - 1;
  488. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  489. reply_len >= 2 && reply[0] == '"') {
  490. reply[reply_len] = '\0';
  491. pos = strchr(reply + 1, '"');
  492. if (pos)
  493. *pos = '\0';
  494. idstrEdit->setText(reply + 1);
  495. }
  496. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d priority", network_id);
  497. reply_len = sizeof(reply) - 1;
  498. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
  499. {
  500. reply[reply_len] = '\0';
  501. prioritySpinBox->setValue(atoi(reply));
  502. }
  503. authSelect->setCurrentIndex(auth);
  504. authChanged(auth);
  505. encrSelect->setCurrentIndex(encr);
  506. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  507. wepEnabled(encr == 1);
  508. removeButton->setEnabled(true);
  509. addButton->setText("Save");
  510. }
  511. void NetworkConfig::removeNetwork()
  512. {
  513. char reply[10], cmd[256];
  514. size_t reply_len;
  515. if (QMessageBox::information(this, "wpa_gui",
  516. "This will permanently remove the "
  517. "network\n"
  518. "from the configuration. Do you really "
  519. "want\n"
  520. "to remove this network?", "Yes", "No")
  521. != 0)
  522. return;
  523. snprintf(cmd, sizeof(cmd), "REMOVE_NETWORK %d", edit_network_id);
  524. reply_len = sizeof(reply);
  525. wpagui->ctrlRequest(cmd, reply, &reply_len);
  526. if (strncmp(reply, "OK", 2) != 0) {
  527. QMessageBox::warning(this, "wpa_gui",
  528. "Failed to remove network from "
  529. "wpa_supplicant\n"
  530. "configuration.");
  531. } else {
  532. wpagui->triggerUpdate();
  533. wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
  534. }
  535. close();
  536. }
  537. void NetworkConfig::newNetwork()
  538. {
  539. new_network = true;
  540. getEapCapa();
  541. }
  542. void NetworkConfig::getEapCapa()
  543. {
  544. char reply[256];
  545. size_t reply_len;
  546. if (wpagui == NULL)
  547. return;
  548. reply_len = sizeof(reply) - 1;
  549. if (wpagui->ctrlRequest("GET_CAPABILITY eap", reply, &reply_len) < 0)
  550. return;
  551. reply[reply_len] = '\0';
  552. QString res(reply);
  553. QStringList types = res.split(QChar(' '));
  554. eapSelect->insertItems(-1, types);
  555. }