networkconfig.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. setNetworkParam(id, "eap",
  199. eapSelect->currentText().toAscii().constData(),
  200. false);
  201. if (identityEdit->isEnabled())
  202. setNetworkParam(id, "identity",
  203. identityEdit->text().toAscii().constData(),
  204. true);
  205. if (passwordEdit->isEnabled() &&
  206. strcmp(passwordEdit->text().toAscii().constData(),
  207. WPA_GUI_KEY_DATA) != 0)
  208. setNetworkParam(id, "password",
  209. passwordEdit->text().toAscii().constData(),
  210. true);
  211. if (cacertEdit->isEnabled())
  212. setNetworkParam(id, "ca_cert",
  213. cacertEdit->text().toAscii().constData(),
  214. true);
  215. writeWepKey(id, wep0Edit, 0);
  216. writeWepKey(id, wep1Edit, 1);
  217. writeWepKey(id, wep2Edit, 2);
  218. writeWepKey(id, wep3Edit, 3);
  219. if (wep0Radio->isEnabled() && wep0Radio->isChecked())
  220. setNetworkParam(id, "wep_tx_keyidx", "0", false);
  221. else if (wep1Radio->isEnabled() && wep1Radio->isChecked())
  222. setNetworkParam(id, "wep_tx_keyidx", "1", false);
  223. else if (wep2Radio->isEnabled() && wep2Radio->isChecked())
  224. setNetworkParam(id, "wep_tx_keyidx", "2", false);
  225. else if (wep3Radio->isEnabled() && wep3Radio->isChecked())
  226. setNetworkParam(id, "wep_tx_keyidx", "3", false);
  227. if (idstrEdit->isEnabled())
  228. setNetworkParam(id, "id_str",
  229. idstrEdit->text().toAscii().constData(),
  230. true);
  231. if (prioritySpinBox->isEnabled()) {
  232. QString prio;
  233. prio = prio.setNum(prioritySpinBox->value());
  234. setNetworkParam(id, "priority", prio.toAscii().constData(),
  235. false);
  236. }
  237. snprintf(cmd, sizeof(cmd), "ENABLE_NETWORK %d", id);
  238. reply_len = sizeof(reply);
  239. wpagui->ctrlRequest(cmd, reply, &reply_len);
  240. if (strncmp(reply, "OK", 2) != 0) {
  241. QMessageBox::warning(this, "wpa_gui", "Failed to enable "
  242. "network in wpa_supplicant\n"
  243. "configuration.");
  244. /* Network was added, so continue anyway */
  245. }
  246. wpagui->triggerUpdate();
  247. wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
  248. close();
  249. }
  250. void NetworkConfig::setWpaGui(WpaGui *_wpagui)
  251. {
  252. wpagui = _wpagui;
  253. }
  254. int NetworkConfig::setNetworkParam(int id, const char *field,
  255. const char *value, bool quote)
  256. {
  257. char reply[10], cmd[256];
  258. size_t reply_len;
  259. snprintf(cmd, sizeof(cmd), "SET_NETWORK %d %s %s%s%s",
  260. id, field, quote ? "\"" : "", value, quote ? "\"" : "");
  261. reply_len = sizeof(reply);
  262. wpagui->ctrlRequest(cmd, reply, &reply_len);
  263. return strncmp(reply, "OK", 2) == 0 ? 0 : -1;
  264. }
  265. void NetworkConfig::encrChanged(const QString &sel)
  266. {
  267. wepEnabled(sel.indexOf("WEP") == 0);
  268. }
  269. void NetworkConfig::wepEnabled(bool enabled)
  270. {
  271. wep0Edit->setEnabled(enabled);
  272. wep1Edit->setEnabled(enabled);
  273. wep2Edit->setEnabled(enabled);
  274. wep3Edit->setEnabled(enabled);
  275. wep0Radio->setEnabled(enabled);
  276. wep1Radio->setEnabled(enabled);
  277. wep2Radio->setEnabled(enabled);
  278. wep3Radio->setEnabled(enabled);
  279. }
  280. void NetworkConfig::writeWepKey(int network_id, QLineEdit *edit, int id)
  281. {
  282. char buf[10];
  283. bool hex;
  284. const char *txt, *pos;
  285. size_t len;
  286. if (!edit->isEnabled() || edit->text().isEmpty())
  287. return;
  288. /*
  289. * Assume hex key if only hex characters are present and length matches
  290. * with 40, 104, or 128-bit key
  291. */
  292. txt = edit->text().toAscii().constData();
  293. if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
  294. return;
  295. len = strlen(txt);
  296. if (len == 0)
  297. return;
  298. pos = txt;
  299. hex = true;
  300. while (*pos) {
  301. if (!((*pos >= '0' && *pos <= '9') ||
  302. (*pos >= 'a' && *pos <= 'f') ||
  303. (*pos >= 'A' && *pos <= 'F'))) {
  304. hex = false;
  305. break;
  306. }
  307. pos++;
  308. }
  309. if (hex && len != 10 && len != 26 && len != 32)
  310. hex = false;
  311. snprintf(buf, sizeof(buf), "wep_key%d", id);
  312. setNetworkParam(network_id, buf, txt, !hex);
  313. }
  314. static int key_value_isset(const char *reply, size_t reply_len)
  315. {
  316. return reply_len > 0 && (reply_len < 4 || memcmp(reply, "FAIL", 4) != 0);
  317. }
  318. void NetworkConfig::paramsFromConfig(int network_id)
  319. {
  320. int i, res;
  321. edit_network_id = network_id;
  322. getEapCapa();
  323. char reply[1024], cmd[256], *pos;
  324. size_t reply_len;
  325. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ssid", network_id);
  326. reply_len = sizeof(reply) - 1;
  327. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  328. reply_len >= 2 && reply[0] == '"') {
  329. reply[reply_len] = '\0';
  330. pos = strchr(reply + 1, '"');
  331. if (pos)
  332. *pos = '\0';
  333. ssidEdit->setText(reply + 1);
  334. }
  335. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d proto", network_id);
  336. reply_len = sizeof(reply) - 1;
  337. int wpa = 0;
  338. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  339. reply[reply_len] = '\0';
  340. if (strstr(reply, "RSN") || strstr(reply, "WPA2"))
  341. wpa = 2;
  342. else if (strstr(reply, "WPA"))
  343. wpa = 1;
  344. }
  345. int auth = AUTH_NONE, encr = 0;
  346. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d key_mgmt", network_id);
  347. reply_len = sizeof(reply) - 1;
  348. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  349. reply[reply_len] = '\0';
  350. if (strstr(reply, "WPA-EAP"))
  351. auth = wpa & 2 ? AUTH_WPA2_EAP : AUTH_WPA_EAP;
  352. else if (strstr(reply, "WPA-PSK"))
  353. auth = wpa & 2 ? AUTH_WPA2_PSK : AUTH_WPA_PSK;
  354. else if (strstr(reply, "IEEE8021X")) {
  355. auth = AUTH_IEEE8021X;
  356. encr = 1;
  357. }
  358. }
  359. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d pairwise", network_id);
  360. reply_len = sizeof(reply) - 1;
  361. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
  362. reply[reply_len] = '\0';
  363. if (strstr(reply, "CCMP") && auth != AUTH_NONE)
  364. encr = 1;
  365. else if (strstr(reply, "TKIP"))
  366. encr = 0;
  367. else if (strstr(reply, "WEP"))
  368. encr = 1;
  369. else
  370. encr = 0;
  371. }
  372. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d psk", network_id);
  373. reply_len = sizeof(reply) - 1;
  374. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  375. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  376. reply[reply_len] = '\0';
  377. pos = strchr(reply + 1, '"');
  378. if (pos)
  379. *pos = '\0';
  380. pskEdit->setText(reply + 1);
  381. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  382. pskEdit->setText(WPA_GUI_KEY_DATA);
  383. }
  384. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d identity", network_id);
  385. reply_len = sizeof(reply) - 1;
  386. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  387. reply_len >= 2 && reply[0] == '"') {
  388. reply[reply_len] = '\0';
  389. pos = strchr(reply + 1, '"');
  390. if (pos)
  391. *pos = '\0';
  392. identityEdit->setText(reply + 1);
  393. }
  394. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d password", network_id);
  395. reply_len = sizeof(reply) - 1;
  396. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  397. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  398. reply[reply_len] = '\0';
  399. pos = strchr(reply + 1, '"');
  400. if (pos)
  401. *pos = '\0';
  402. passwordEdit->setText(reply + 1);
  403. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  404. passwordEdit->setText(WPA_GUI_KEY_DATA);
  405. }
  406. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ca_cert", network_id);
  407. reply_len = sizeof(reply) - 1;
  408. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  409. reply_len >= 2 && reply[0] == '"') {
  410. reply[reply_len] = '\0';
  411. pos = strchr(reply + 1, '"');
  412. if (pos)
  413. *pos = '\0';
  414. cacertEdit->setText(reply + 1);
  415. }
  416. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d eap", network_id);
  417. reply_len = sizeof(reply) - 1;
  418. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  419. reply_len >= 1) {
  420. reply[reply_len] = '\0';
  421. for (i = 0; i < eapSelect->count(); i++) {
  422. if (eapSelect->itemText(i).compare(reply) == 0) {
  423. eapSelect->setCurrentIndex(i);
  424. break;
  425. }
  426. }
  427. }
  428. for (i = 0; i < 4; i++) {
  429. QLineEdit *wepEdit;
  430. switch (i) {
  431. default:
  432. case 0:
  433. wepEdit = wep0Edit;
  434. break;
  435. case 1:
  436. wepEdit = wep1Edit;
  437. break;
  438. case 2:
  439. wepEdit = wep2Edit;
  440. break;
  441. case 3:
  442. wepEdit = wep3Edit;
  443. break;
  444. }
  445. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_key%d",
  446. network_id, i);
  447. reply_len = sizeof(reply) - 1;
  448. res = wpagui->ctrlRequest(cmd, reply, &reply_len);
  449. if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
  450. reply[reply_len] = '\0';
  451. pos = strchr(reply + 1, '"');
  452. if (pos)
  453. *pos = '\0';
  454. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  455. encr = 1;
  456. wepEdit->setText(reply + 1);
  457. } else if (res >= 0 && key_value_isset(reply, reply_len)) {
  458. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  459. encr = 1;
  460. wepEdit->setText(WPA_GUI_KEY_DATA);
  461. }
  462. }
  463. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_tx_keyidx", network_id);
  464. reply_len = sizeof(reply) - 1;
  465. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
  466. {
  467. reply[reply_len] = '\0';
  468. switch (atoi(reply)) {
  469. case 0:
  470. wep0Radio->setChecked(true);
  471. break;
  472. case 1:
  473. wep1Radio->setChecked(true);
  474. break;
  475. case 2:
  476. wep2Radio->setChecked(true);
  477. break;
  478. case 3:
  479. wep3Radio->setChecked(true);
  480. break;
  481. }
  482. }
  483. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d id_str", network_id);
  484. reply_len = sizeof(reply) - 1;
  485. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
  486. reply_len >= 2 && reply[0] == '"') {
  487. reply[reply_len] = '\0';
  488. pos = strchr(reply + 1, '"');
  489. if (pos)
  490. *pos = '\0';
  491. idstrEdit->setText(reply + 1);
  492. }
  493. snprintf(cmd, sizeof(cmd), "GET_NETWORK %d priority", network_id);
  494. reply_len = sizeof(reply) - 1;
  495. if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
  496. {
  497. reply[reply_len] = '\0';
  498. prioritySpinBox->setValue(atoi(reply));
  499. }
  500. authSelect->setCurrentIndex(auth);
  501. authChanged(auth);
  502. encrSelect->setCurrentIndex(encr);
  503. if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
  504. wepEnabled(encr == 1);
  505. removeButton->setEnabled(true);
  506. addButton->setText("Save");
  507. }
  508. void NetworkConfig::removeNetwork()
  509. {
  510. char reply[10], cmd[256];
  511. size_t reply_len;
  512. if (QMessageBox::information(this, "wpa_gui",
  513. "This will permanently remove the "
  514. "network\n"
  515. "from the configuration. Do you really "
  516. "want\n"
  517. "to remove this network?", "Yes", "No")
  518. != 0)
  519. return;
  520. snprintf(cmd, sizeof(cmd), "REMOVE_NETWORK %d", edit_network_id);
  521. reply_len = sizeof(reply);
  522. wpagui->ctrlRequest(cmd, reply, &reply_len);
  523. if (strncmp(reply, "OK", 2) != 0) {
  524. QMessageBox::warning(this, "wpa_gui",
  525. "Failed to remove network from "
  526. "wpa_supplicant\n"
  527. "configuration.");
  528. } else {
  529. wpagui->triggerUpdate();
  530. wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
  531. }
  532. close();
  533. }
  534. void NetworkConfig::newNetwork()
  535. {
  536. new_network = true;
  537. getEapCapa();
  538. }
  539. void NetworkConfig::getEapCapa()
  540. {
  541. char reply[256];
  542. size_t reply_len;
  543. if (wpagui == NULL)
  544. return;
  545. reply_len = sizeof(reply) - 1;
  546. if (wpagui->ctrlRequest("GET_CAPABILITY eap", reply, &reply_len) < 0)
  547. return;
  548. reply[reply_len] = '\0';
  549. QString res(reply);
  550. QStringList types = res.split(QChar(' '));
  551. eapSelect->insertItems(-1, types);
  552. }