[PATCH]: wpa_gui-qt4: add "Select any network" to network combobox

Kel Modderman kel
Tue Jan 8 22:27:00 PST 2008


This patch adds a "Select any network" item to the network combobox when more
than 1 network has been configured, to allow the "SELECT_NETWORK any"
ctrl_interface command to be used.

It also modifies the edit network function to add a new network if the
combobox is currently set to the "Select any network" item.

This is especially useful when update_config=1 is set in used configuration,
because when you use the network combobox to select a network, it has the side
effect of disabling all other network blocks without possibility of enabling
all of the configured networks without manually editing config file.

Signed-off-by: Kel Modderman <kel at otaku42.de>
---
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -490,6 +490,9 @@
 		start = end + 1;
 	}
 
+	if (networkSelect->count() > 1)
+		networkSelect->addItem("Select any network");
+
 	if (!selected && first_active >= 0)
 		networkSelect->setCurrentIndex(first_active);
 
@@ -716,13 +719,17 @@
 	char reply[10];
 	size_t reply_len = sizeof(reply);
 
-	int pos = cmd.indexOf(':');
-	if (pos < 0) {
-		printf("Invalid selectNetwork '%s'\n",
-		       cmd.toAscii().constData());
-		return;
+	if (cmd.startsWith("Select any")) {
+		cmd = "any";
+	} else {
+		int pos = cmd.indexOf(':');
+		if (pos < 0) {
+			printf("Invalid selectNetwork '%s'\n",
+			       cmd.toAscii().constData());
+			return;
+		}
+		cmd.truncate(pos);
 	}
-	cmd.truncate(pos);
 	cmd.prepend("SELECT_NETWORK ");
 	ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
 }
@@ -731,20 +738,29 @@
 void WpaGui::editNetwork()
 {
 	QString sel(networkSelect->currentText());
-	int pos = sel.indexOf(':');
-	if (pos < 0) {
-		printf("Invalid selectNetwork '%s'\n",
-		       sel.toAscii().constData());
-		return;
+	int id = -1;
+
+	if (!sel.startsWith("Select any")) {
+		int pos = sel.indexOf(':');
+		if (pos < 0) {
+			printf("Invalid selectNetwork '%s'\n",
+			       sel.toAscii().constData());
+			return;
+		}
+		sel.truncate(pos);
+		id = sel.toInt();
 	}
-	sel.truncate(pos);
 
 	NetworkConfig *nc = new NetworkConfig();
 	if (nc == NULL)
 		return;
 	nc->setWpaGui(this);
 
-	nc->paramsFromConfig(sel.toInt());
+	if (id >= 0)
+		nc->paramsFromConfig(id);
+	else
+		nc->newNetwork();
+
 	nc->show();
 	nc->exec();
 }
---



More information about the Hostap mailing list