userdatarequest.cpp
Go to the documentation of this file.
00001 /*
00002  * wpa_gui - UserDataRequest class
00003  * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  *
00009  * Alternatively, this software may be distributed under the terms of BSD
00010  * license.
00011  *
00012  * See README and COPYING for more details.
00013  */
00014 
00015 #include "userdatarequest.h"
00016 #include "wpagui.h"
00017 #include "common/wpa_ctrl.h"
00018 
00019 
00020 UserDataRequest::UserDataRequest(QWidget *parent, const char *, bool,
00021                                  Qt::WFlags)
00022         : QDialog(parent)
00023 {
00024         setupUi(this);
00025 
00026         connect(buttonOk, SIGNAL(clicked()), this, SLOT(sendReply()));
00027         connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00028         connect(queryEdit, SIGNAL(returnPressed()), this, SLOT(sendReply()));
00029 }
00030 
00031 
00032 UserDataRequest::~UserDataRequest()
00033 {
00034 }
00035 
00036 
00037 void UserDataRequest::languageChange()
00038 {
00039         retranslateUi(this);
00040 }
00041 
00042 
00043 int UserDataRequest::setParams(WpaGui *_wpagui, const char *reqMsg)
00044 {
00045         char *tmp, *pos, *pos2;
00046         wpagui = _wpagui;
00047         tmp = strdup(reqMsg);
00048         if (tmp == NULL)
00049                 return -1;
00050         pos = strchr(tmp, '-');
00051         if (pos == NULL) {
00052                 free(tmp);
00053                 return -1;
00054         }
00055         *pos++ = '\0';
00056         field = tmp;
00057         pos2 = strchr(pos, ':');
00058         if (pos2 == NULL) {
00059                 free(tmp);
00060                 return -1;
00061         }
00062         *pos2++ = '\0';
00063 
00064         networkid = atoi(pos);
00065         queryInfo->setText(pos2);
00066         if (strcmp(tmp, "PASSWORD") == 0) {
00067                 queryField->setText(tr("Password: "));
00068                 queryEdit->setEchoMode(QLineEdit::Password);
00069         } else if (strcmp(tmp, "NEW_PASSWORD") == 0) {
00070                 queryField->setText(tr("New password: "));
00071                 queryEdit->setEchoMode(QLineEdit::Password);
00072         } else if (strcmp(tmp, "IDENTITY") == 0)
00073                 queryField->setText(tr("Identity: "));
00074         else if (strcmp(tmp, "PASSPHRASE") == 0) {
00075                 queryField->setText(tr("Private key passphrase: "));
00076                 queryEdit->setEchoMode(QLineEdit::Password);
00077         } else
00078                 queryField->setText(field + ":");
00079         free(tmp);
00080 
00081         return 0;
00082 }
00083 
00084 
00085 void UserDataRequest::sendReply()
00086 {
00087         char reply[10];
00088         size_t reply_len = sizeof(reply);
00089 
00090         if (wpagui == NULL) {
00091                 reject();
00092                 return;
00093         }
00094 
00095         QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
00096                 QString::number(networkid) + ':' +
00097                 queryEdit->text();
00098         wpagui->ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
00099         accept();
00100 }


wpa_supplicant_node
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Jan 2 2014 11:25:15