• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
3 **
4 ** If you want to add, delete, or rename functions or slots, use
5 ** Qt Designer to update this file, preserving your code.
6 **
7 ** You should not define a constructor or destructor in this file.
8 ** Instead, write your code in functions called init() and destroy().
9 ** These will automatically be called by the form's constructor and
10 ** destructor.
11 *****************************************************************************/
12 
13 #include <stdlib.h>
14 
setParams(WpaGui * _wpagui,const char * reqMsg)15 int UserDataRequest::setParams(WpaGui *_wpagui, const char *reqMsg)
16 {
17     char *tmp, *pos, *pos2;
18     wpagui = _wpagui;
19     tmp = strdup(reqMsg);
20     if (tmp == NULL)
21 	return -1;
22     pos = strchr(tmp, '-');
23     if (pos == NULL) {
24 	free(tmp);
25 	return -1;
26     }
27     *pos++ = '\0';
28     field = tmp;
29     pos2 = strchr(pos, ':');
30     if (pos2 == NULL) {
31 	free(tmp);
32 	return -1;
33     }
34     *pos2++ = '\0';
35 
36     networkid = atoi(pos);
37     queryInfo->setText(pos2);
38     if (strcmp(tmp, "PASSWORD") == 0) {
39 	queryField->setText("Password: ");
40 	queryEdit->setEchoMode(QLineEdit::Password);
41     } else if (strcmp(tmp, "NEW_PASSWORD") == 0) {
42 	queryField->setText("New password: ");
43  	queryEdit->setEchoMode(QLineEdit::Password);
44     } else if (strcmp(tmp, "IDENTITY") == 0)
45 	queryField->setText("Identity: ");
46     else if (strcmp(tmp, "PASSPHRASE") == 0) {
47 	queryField->setText("Private key passphrase: ");
48  	queryEdit->setEchoMode(QLineEdit::Password);
49     } else
50 	queryField->setText(field + ":");
51     free(tmp);
52 
53     return 0;
54 }
55 
56 
sendReply()57 void UserDataRequest::sendReply()
58 {
59     char reply[10];
60     size_t reply_len = sizeof(reply);
61 
62     if (wpagui == NULL) {
63 	reject();
64 	return;
65     }
66 
67     QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
68 		  QString::number(networkid) + ':' +
69 		  queryEdit->text();
70     wpagui->ctrlRequest(cmd.ascii(), reply, &reply_len);
71     accept();
72 }
73