[PATCH 6/14]: wpa_gui-qt4: connect new Remove pushbutton to signal/slot pair

Kel Modderman kel at otaku42.de
Tue Jan 29 02:14:32 EST 2008


Connect the new Remove pushbutton on Manage Networks tab to a signal/slot
pair.

Add removeNetwork() public function and removeListedNetwork() public slot
function.

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
@@ -60,6 +60,8 @@
 	connect(addNetworkButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
 	connect(editNetworkButton, SIGNAL(clicked()), this,
 		SLOT(editListedNetwork()));
+	connect(removeNetworkButton, SIGNAL(clicked()), this,
+		SLOT(removeListedNetwork()));
 
 	eh = NULL;
 	scanres = NULL;
@@ -818,6 +820,37 @@
 }
 
 
+void WpaGui::removeNetwork(const QString &sel)
+{
+	QString cmd(sel);
+	char reply[10];
+	size_t reply_len = sizeof(reply);
+	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);
+	triggerUpdate();
+}
+
+
+void WpaGui::removeListedNetwork()
+{
+	if (networkList->currentRow() < 0) {
+		QMessageBox::information(this, "Select A Network",
+					 "Select a network from the list to"
+					 " remove it.\n");
+		return;
+	}
+	QString sel(networkList->currentItem()->text());
+	removeNetwork(sel);
+}
+
+
 void WpaGui::enableAllNetworks()
 {
 	char reply[10];
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -33,6 +33,7 @@
 	virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
 	virtual void triggerUpdate();
 	virtual void editNetwork(const QString &sel);
+	virtual void removeNetwork(const QString &sel);
 
 public slots:
 	virtual void parse_argv();
@@ -52,6 +53,7 @@
 	virtual void selectNetwork(const QString &sel);
 	virtual void editSelectedNetwork();
 	virtual void editListedNetwork();
+	virtual void removeListedNetwork();
 	virtual void addNetwork();
 	virtual void enableAllNetworks();
 	virtual void disableAllNetworks();
---


More information about the HostAP mailing list