Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / wpa / wpa_supplicant / wpa_gui-qt4 / userdatarequest.cpp
blob42fbdbc7b4e424389e9b533669a59a837d6d6608
1 /*
2 * wpa_gui - UserDataRequest class
3 * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
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
10 * license.
12 * See README and COPYING for more details.
15 #include "userdatarequest.h"
16 #include "wpagui.h"
17 #include "wpa_ctrl.h"
20 UserDataRequest::UserDataRequest(QWidget *parent, const char *, bool,
21 Qt::WFlags)
22 : QDialog(parent)
24 setupUi(this);
26 connect(buttonOk, SIGNAL(clicked()), this, SLOT(sendReply()));
27 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
28 connect(queryEdit, SIGNAL(returnPressed()), this, SLOT(sendReply()));
32 UserDataRequest::~UserDataRequest()
37 void UserDataRequest::languageChange()
39 retranslateUi(this);
43 int UserDataRequest::setParams(WpaGui *_wpagui, const char *reqMsg)
45 char *tmp, *pos, *pos2;
46 wpagui = _wpagui;
47 tmp = strdup(reqMsg);
48 if (tmp == NULL)
49 return -1;
50 pos = strchr(tmp, '-');
51 if (pos == NULL) {
52 free(tmp);
53 return -1;
55 *pos++ = '\0';
56 field = tmp;
57 pos2 = strchr(pos, ':');
58 if (pos2 == NULL) {
59 free(tmp);
60 return -1;
62 *pos2++ = '\0';
64 networkid = atoi(pos);
65 queryInfo->setText(pos2);
66 if (strcmp(tmp, "PASSWORD") == 0) {
67 queryField->setText("Password: ");
68 queryEdit->setEchoMode(QLineEdit::Password);
69 } else if (strcmp(tmp, "NEW_PASSWORD") == 0) {
70 queryField->setText("New password: ");
71 queryEdit->setEchoMode(QLineEdit::Password);
72 } else if (strcmp(tmp, "IDENTITY") == 0)
73 queryField->setText("Identity: ");
74 else if (strcmp(tmp, "PASSPHRASE") == 0) {
75 queryField->setText("Private key passphrase: ");
76 queryEdit->setEchoMode(QLineEdit::Password);
77 } else
78 queryField->setText(field + ":");
79 free(tmp);
81 return 0;
85 void UserDataRequest::sendReply()
87 char reply[10];
88 size_t reply_len = sizeof(reply);
90 if (wpagui == NULL) {
91 reject();
92 return;
95 QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
96 QString::number(networkid) + ':' +
97 queryEdit->text();
98 wpagui->ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
99 accept();