/*
* wpa_gui - WpaGui class
- * Copyright (c) 2005-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2005-2011, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#ifdef CONFIG_NATIVE_WINDOWS
fileStopServiceAction = new QAction(this);
fileStopServiceAction->setObjectName("Stop Service");
- fileStopServiceAction->setIconText("Stop Service");
+ fileStopServiceAction->setIconText(tr("Stop Service"));
fileMenu->insertAction(actionWPS, fileStopServiceAction);
fileStartServiceAction = new QAction(this);
fileStartServiceAction->setObjectName("Start Service");
- fileStartServiceAction->setIconText("Start Service");
+ fileStartServiceAction->setIconText(tr("Start Service"));
fileMenu->insertAction(fileStopServiceAction, fileStartServiceAction);
connect(fileStartServiceAction, SIGNAL(triggered()), this,
SLOT(stopService()));
addInterfaceAction = new QAction(this);
- addInterfaceAction->setIconText("Add Interface");
+ addInterfaceAction->setIconText(tr("Add Interface"));
fileMenu->insertAction(fileStartServiceAction, addInterfaceAction);
connect(addInterfaceAction, SIGNAL(triggered()), this,
show();
connectedToService = false;
- textStatus->setText("connecting to wpa_supplicant");
+ textStatus->setText(tr("connecting to wpa_supplicant"));
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(ping()));
timer->setSingleShot(FALSE);
first = false;
if (QMessageBox::warning(
this, qAppName(),
- "wpa_supplicant service is not running.\n"
- "Do you want to start it?",
+ tr("wpa_supplicant service is not "
+ "running.\n"
+ "Do you want to start it?"),
QMessageBox::Yes | QMessageBox::No) ==
QMessageBox::Yes)
startService();
}
+QString WpaGui::wpaStateTranslate(char *state)
+{
+ if (!strcmp(state, "DISCONNECTED"))
+ return tr("Disconnected");
+ else if (!strcmp(state, "INACTIVE"))
+ return tr("Inactive");
+ else if (!strcmp(state, "SCANNING"))
+ return tr("Scanning");
+ else if (!strcmp(state, "AUTHENTICATING"))
+ return tr("Authenticating");
+ else if (!strcmp(state, "ASSOCIATING"))
+ return tr("Associating");
+ else if (!strcmp(state, "ASSOCIATED"))
+ return tr("Associated");
+ else if (!strcmp(state, "4WAY_HANDSHAKE"))
+ return tr("4-Way Handshake");
+ else if (!strcmp(state, "GROUP_HANDSHAKE"))
+ return tr("Group Handshake");
+ else if (!strcmp(state, "COMPLETED"))
+ return tr("Completed");
+ else
+ return tr("Unknown");
+}
+
+
void WpaGui::updateStatus()
{
char buf[2048], *start, *end, *pos;
len = sizeof(buf) - 1;
if (ctrl_conn == NULL || ctrlRequest("STATUS", buf, &len) < 0) {
- textStatus->setText("Could not get status from "
- "wpa_supplicant");
+ textStatus->setText(tr("Could not get status from "
+ "wpa_supplicant"));
textAuthentication->clear();
textEncryption->clear();
textSsid->clear();
first = false;
if (QMessageBox::information(
this, qAppName(),
- "No network interfaces in use.\n"
- "Would you like to add one?",
+ tr("No network interfaces in use.\n"
+ "Would you like to add one?"),
QMessageBox::Yes | QMessageBox::No) ==
QMessageBox::Yes)
addInterface();
textIpAddress->setText(pos);
} else if (strcmp(start, "wpa_state") == 0) {
status_updated = true;
- textStatus->setText(pos);
+ textStatus->setText(wpaStateTranslate(pos));
} else if (strcmp(start, "key_mgmt") == 0) {
auth_updated = true;
textAuthentication->setText(pos);
break;
*flags++ = '\0';
+ if (strstr(flags, "[DISABLED][P2P-PERSISTENT]")) {
+ if (last)
+ break;
+ start = end + 1;
+ continue;
+ }
+
QString network(id);
network.append(": ");
network.append(ssid);
}
if (networkSelect->count() > 1)
- networkSelect->addItem("Select any network");
+ networkSelect->addItem(tr("Select any network"));
if (!current && first_active >= 0)
networkSelect->setCurrentIndex(first_active);
void WpaGui::helpAbout()
{
QMessageBox::about(this, "wpa_gui for wpa_supplicant",
- "Copyright (c) 2003-2008,\n"
+ "Copyright (c) 2003-2011,\n"
"Jouni Malinen <j@w1.fi>\n"
"and contributors.\n"
"\n"
scanres->updateResults();
else if (str_match(pos, WPA_EVENT_DISCONNECTED))
showTrayMessage(QSystemTrayIcon::Information, 3,
- "Disconnected from network.");
+ tr("Disconnected from network."));
else if (str_match(pos, WPA_EVENT_CONNECTED)) {
showTrayMessage(QSystemTrayIcon::Information, 3,
- "Connection to network established.");
+ tr("Connection to network established."));
QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
stopWpsRun(true);
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PBC)) {
- wpsStatusText->setText("WPS AP in active PBC mode found");
+ wpsStatusText->setText(tr("WPS AP in active PBC mode found"));
if (textStatus->text() == "INACTIVE" ||
textStatus->text() == "DISCONNECTED")
wpaguiTab->setCurrentWidget(wpsTab);
- wpsInstructions->setText("Press the PBC button on the screen "
- "to start registration");
+ wpsInstructions->setText(tr("Press the PBC button on the "
+ "screen to start registration"));
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PIN)) {
- wpsStatusText->setText("WPS AP with recently selected "
- "registrar");
+ wpsStatusText->setText(tr("WPS AP with recently selected "
+ "registrar"));
+ if (textStatus->text() == "INACTIVE" ||
+ textStatus->text() == "DISCONNECTED")
+ wpaguiTab->setCurrentWidget(wpsTab);
+ } else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_AUTH)) {
+ showTrayMessage(QSystemTrayIcon::Information, 3,
+ "Wi-Fi Protected Setup (WPS) AP\n"
+ "indicating this client is authorized.");
+ wpsStatusText->setText("WPS AP indicating this client is "
+ "authorized");
if (textStatus->text() == "INACTIVE" ||
textStatus->text() == "DISCONNECTED")
wpaguiTab->setCurrentWidget(wpsTab);
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE)) {
- wpsStatusText->setText("WPS AP detected");
+ wpsStatusText->setText(tr("WPS AP detected"));
} else if (str_match(pos, WPS_EVENT_OVERLAP)) {
- wpsStatusText->setText("PBC mode overlap detected");
- wpsInstructions->setText("More than one AP is currently in "
- "active WPS PBC mode. Wait couple of "
- "minutes and try again");
+ wpsStatusText->setText(tr("PBC mode overlap detected"));
+ wpsInstructions->setText(tr("More than one AP is currently in "
+ "active WPS PBC mode. Wait couple "
+ "of minutes and try again"));
wpaguiTab->setCurrentWidget(wpsTab);
} else if (str_match(pos, WPS_EVENT_CRED_RECEIVED)) {
- wpsStatusText->setText("Network configuration received");
+ wpsStatusText->setText(tr("Network configuration received"));
wpaguiTab->setCurrentWidget(wpsTab);
} else if (str_match(pos, WPA_EVENT_EAP_METHOD)) {
if (strstr(pos, "(WSC)"))
- wpsStatusText->setText("Registration started");
+ wpsStatusText->setText(tr("Registration started"));
} else if (str_match(pos, WPS_EVENT_M2D)) {
- wpsStatusText->setText("Registrar does not yet know PIN");
+ wpsStatusText->setText(tr("Registrar does not yet know PIN"));
} else if (str_match(pos, WPS_EVENT_FAIL)) {
- wpsStatusText->setText("Registration failed");
+ wpsStatusText->setText(tr("Registration failed"));
} else if (str_match(pos, WPS_EVENT_SUCCESS)) {
- wpsStatusText->setText("Registration succeeded");
+ wpsStatusText->setText(tr("Registration succeeded"));
}
}
char reply[10];
size_t reply_len = sizeof(reply);
- if (cmd.startsWith("Select any")) {
+ if (cmd.contains(QRegExp("^\\d+:")))
+ cmd.truncate(cmd.indexOf(':'));
+ else
cmd = "any";
- } else {
- int pos = cmd.indexOf(':');
- if (pos < 0) {
- printf("Invalid selectNetwork '%s'\n",
- cmd.toAscii().constData());
- return;
- }
- cmd.truncate(pos);
- }
cmd.prepend("SELECT_NETWORK ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
triggerUpdate();
char reply[10];
size_t reply_len = sizeof(reply);
- if (!cmd.startsWith("all")) {
- int pos = cmd.indexOf(':');
- if (pos < 0) {
- printf("Invalid enableNetwork '%s'\n",
- cmd.toAscii().constData());
- return;
- }
- cmd.truncate(pos);
+ if (cmd.contains(QRegExp("^\\d+:")))
+ cmd.truncate(cmd.indexOf(':'));
+ else if (!cmd.startsWith("all")) {
+ printf("Invalid editNetwork '%s'\n",
+ cmd.toAscii().constData());
+ return;
}
cmd.prepend("ENABLE_NETWORK ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
char reply[10];
size_t reply_len = sizeof(reply);
- if (!cmd.startsWith("all")) {
- int pos = cmd.indexOf(':');
- if (pos < 0) {
- printf("Invalid disableNetwork '%s'\n",
- cmd.toAscii().constData());
- return;
- }
- cmd.truncate(pos);
+ if (cmd.contains(QRegExp("^\\d+:")))
+ cmd.truncate(cmd.indexOf(':'));
+ else if (!cmd.startsWith("all")) {
+ printf("Invalid editNetwork '%s'\n",
+ cmd.toAscii().constData());
+ return;
}
cmd.prepend("DISABLE_NETWORK ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
QString cmd(sel);
int id = -1;
- if (!cmd.startsWith("Select any")) {
- int pos = sel.indexOf(':');
- if (pos < 0) {
- printf("Invalid editNetwork '%s'\n",
- cmd.toAscii().constData());
- return;
- }
- cmd.truncate(pos);
+ if (cmd.contains(QRegExp("^\\d+:"))) {
+ cmd.truncate(cmd.indexOf(':'));
id = cmd.toInt();
}
void WpaGui::editSelectedNetwork()
{
if (networkSelect->count() < 1) {
- QMessageBox::information(this, "No Networks",
- "There are no networks to edit.\n");
+ QMessageBox::information(
+ this, tr("No Networks"),
+ tr("There are no networks to edit.\n"));
return;
}
QString sel(networkSelect->currentText());
void WpaGui::editListedNetwork()
{
if (networkList->currentRow() < 0) {
- QMessageBox::information(this, "Select A Network",
- "Select a network from the list to"
- " edit it.\n");
+ QMessageBox::information(this, tr("Select A Network"),
+ tr("Select a network from the list to"
+ " edit it.\n"));
return;
}
QString sel(networkList->currentItem()->text());
char reply[10];
size_t reply_len = sizeof(reply);
- if (cmd.startsWith("Select any"))
+ if (cmd.contains(QRegExp("^\\d+:")))
+ cmd.truncate(cmd.indexOf(':'));
+ else if (!cmd.startsWith("all")) {
+ printf("Invalid editNetwork '%s'\n",
+ cmd.toAscii().constData());
return;
-
- if (!cmd.startsWith("all")) {
- int pos = cmd.indexOf(':');
- if (pos < 0) {
- printf("Invalid removeNetwork '%s'\n",
- cmd.toAscii().constData());
- return;
- }
- cmd.truncate(pos);
}
cmd.prepend("REMOVE_NETWORK ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
void WpaGui::removeSelectedNetwork()
{
if (networkSelect->count() < 1) {
- QMessageBox::information(this, "No Networks",
- "There are no networks to remove.\n");
+ QMessageBox::information(this, tr("No Networks"),
+ tr("There are no networks to remove."
+ "\n"));
return;
}
QString sel(networkSelect->currentText());
void WpaGui::removeListedNetwork()
{
if (networkList->currentRow() < 0) {
- QMessageBox::information(this, "Select A Network",
- "Select a network from the list to"
- " remove it.\n");
+ QMessageBox::information(this, tr("Select A Network"),
+ tr("Select a network from the list "
+ "to remove it.\n"));
return;
}
QString sel(networkList->currentItem()->text());
buf[len] = '\0';
if (str_match(buf, "FAIL"))
- QMessageBox::warning(this, "Failed to save configuration",
- "The configuration could not be saved.\n"
- "\n"
- "The update_config=1 configuration option\n"
- "must be used for configuration saving to\n"
- "be permitted.\n");
+ QMessageBox::warning(
+ this, tr("Failed to save configuration"),
+ tr("The configuration could not be saved.\n"
+ "\n"
+ "The update_config=1 configuration option\n"
+ "must be used for configuration saving to\n"
+ "be permitted.\n"));
else
- QMessageBox::information(this, "Saved configuration",
- "The current configuration was saved."
- "\n");
+ QMessageBox::information(
+ this, tr("Saved configuration"),
+ tr("The current configuration was saved."
+ "\n"));
}
QApplication::setQuitOnLastWindowClosed(false);
tray_icon = new QSystemTrayIcon(this);
- tray_icon->setToolTip(qAppName() + " - wpa_supplicant user interface");
+ tray_icon->setToolTip(qAppName() + tr(" - wpa_supplicant user interface"));
if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
else
tray_menu = new QMenu(this);
- disconnectAction = new QAction("&Disconnect", this);
- reconnectAction = new QAction("Re&connect", this);
+ disconnectAction = new QAction(tr("&Disconnect"), this);
+ reconnectAction = new QAction(tr("Re&connect"), this);
connect(disconnectAction, SIGNAL(triggered()), this,
SLOT(disconnect()));
connect(reconnectAction, SIGNAL(triggered()), this,
tray_menu->addAction(reconnectAction);
tray_menu->addSeparator();
- eventAction = new QAction("&Event History", this);
- scanAction = new QAction("Scan &Results", this);
- statAction = new QAction("S&tatus", this);
+ eventAction = new QAction(tr("&Event History"), this);
+ scanAction = new QAction(tr("Scan &Results"), this);
+ statAction = new QAction(tr("S&tatus"), this);
connect(eventAction, SIGNAL(triggered()), this, SLOT(eventHistory()));
connect(scanAction, SIGNAL(triggered()), this, SLOT(scan()));
connect(statAction, SIGNAL(triggered()), this, SLOT(showTrayStatus()));
tray_menu->addAction(statAction);
tray_menu->addSeparator();
- showAction = new QAction("&Show Window", this);
- hideAction = new QAction("&Hide Window", this);
- quitAction = new QAction("&Quit", this);
+ showAction = new QAction(tr("&Show Window"), this);
+ hideAction = new QAction(tr("&Hide Window"), this);
+ quitAction = new QAction(tr("&Quit"), this);
connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
if (QSystemTrayIcon::supportsMessages()) {
hide();
showTrayMessage(QSystemTrayIcon::Information, 3,
- qAppName() + " will keep running in "
- "the system tray.");
+ qAppName() +
+ tr(" will keep running in "
+ "the system tray."));
} else {
- QMessageBox::information(this, qAppName() + " systray",
- "The program will keep "
- "running in the system "
- "tray.");
+ QMessageBox::information(this, qAppName() +
+ tr(" systray"),
+ tr("The program will keep "
+ "running in the system "
+ "tray."));
}
ackTrayIcon = true;
}
return;
wpsPinEdit->setEnabled(false);
- if (wpsStatusText->text().compare("WPS AP in active PBC mode found")) {
- wpsInstructions->setText("Press the push button on the AP to "
- "start the PBC mode.");
+ if (wpsStatusText->text().compare(tr("WPS AP in active PBC mode found"))) {
+ wpsInstructions->setText(tr("Press the push button on the AP to "
+ "start the PBC mode."));
} else {
- wpsInstructions->setText("If you have not yet done so, press "
+ wpsInstructions->setText(tr("If you have not yet done so, press "
"the push button on the AP to start "
- "the PBC mode.");
+ "the PBC mode."));
}
- wpsStatusText->setText("Waiting for Registrar");
+ wpsStatusText->setText(tr("Waiting for Registrar"));
wpsRunning = true;
}
wpsPinEdit->setText(reply);
wpsPinEdit->setEnabled(true);
- wpsInstructions->setText("Enter the generated PIN into the Registrar "
+ wpsInstructions->setText(tr("Enter the generated PIN into the Registrar "
"(either the internal one in the AP or an "
- "external one).");
- wpsStatusText->setText("Waiting for Registrar");
+ "external one)."));
+ wpsStatusText->setText(tr("Waiting for Registrar"));
wpsRunning = true;
}
bssFromScan = bssid;
wpsApPinEdit->setEnabled(!bssFromScan.isEmpty());
wpsApPinButton->setEnabled(wpsApPinEdit->text().length() == 8);
- wpsStatusText->setText("WPS AP selected from scan results");
- wpsInstructions->setText("If you want to use an AP device PIN, e.g., "
+ wpsStatusText->setText(tr("WPS AP selected from scan results"));
+ wpsInstructions->setText(tr("If you want to use an AP device PIN, e.g., "
"from a label in the device, enter the eight "
- "digit AP PIN and click Use AP PIN button.");
+ "digit AP PIN and click Use AP PIN button."));
}
if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) < 0)
return;
- wpsStatusText->setText("Waiting for AP/Enrollee");
+ wpsStatusText->setText(tr("Waiting for AP/Enrollee"));
wpsRunning = true;
}
void WpaGui::stopWpsRun(bool success)
{
if (wpsRunning)
- wpsStatusText->setText(success ? "Connected to the network" :
- "Stopped");
+ wpsStatusText->setText(success ? tr("Connected to the network") :
+ tr("Stopped"));
else
wpsStatusText->setText("");
wpsPinEdit->setEnabled(false);
ErrorMsg::ErrorMsg(QWidget *parent, DWORD last_err) :
QMessageBox(parent), err(last_err)
{
- setWindowTitle("wpa_gui error");
+ setWindowTitle(tr("wpa_gui error"));
setIcon(QMessageBox::Warning);
}
scm = OpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (!scm) {
- ErrorMsg(this).showMsg("OpenSCManager failed");
+ ErrorMsg(this).showMsg(tr("OpenSCManager failed"));
return;
}
svc = OpenService(scm, WPASVC_NAME, SERVICE_START);
if (!svc) {
- ErrorMsg(this).showMsg("OpenService failed");
+ ErrorMsg(this).showMsg(tr("OpenService failed"));
CloseServiceHandle(scm);
return;
}
if (!StartService(svc, 0, NULL)) {
- ErrorMsg(this).showMsg("Failed to start wpa_supplicant "
- "service");
+ ErrorMsg(this).showMsg(tr("Failed to start wpa_supplicant "
+ "service"));
}
CloseServiceHandle(svc);
scm = OpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (!scm) {
- ErrorMsg(this).showMsg("OpenSCManager failed");
+ ErrorMsg(this).showMsg(tr("OpenSCManager failed"));
return;
}
svc = OpenService(scm, WPASVC_NAME, SERVICE_STOP);
if (!svc) {
- ErrorMsg(this).showMsg("OpenService failed");
+ ErrorMsg(this).showMsg(tr("OpenService failed"));
CloseServiceHandle(scm);
return;
}
if (!ControlService(svc, SERVICE_CONTROL_STOP, &status)) {
- ErrorMsg(this).showMsg("Failed to stop wpa_supplicant "
- "service");
+ ErrorMsg(this).showMsg(tr("Failed to stop wpa_supplicant "
+ "service"));
}
CloseServiceHandle(svc);