[PATCH]: wpa_gui-qt4: add save configuration file menu item

Kel Modderman kel at otaku42.de
Sun Jan 13 08:22:31 EST 2008


Allow configuration to be saved on demand. This is useful after
enabling/disabling all networks.

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
@@ -52,6 +52,7 @@
 		SLOT(enableAllNetworks()));
 	connect(fileDisableALLNetworksAction, SIGNAL(triggered()), this,
 		SLOT(disableAllNetworks()));
+	connect(fileSaveConfig, SIGNAL(triggered()), this, SLOT(saveConfig()));
 	connect(adapterSelect, SIGNAL(activated(const QString&)), this,
 		SLOT(selectAdapter(const QString&)));
 
@@ -806,6 +807,30 @@
 }
 
 
+void WpaGui::saveConfig()
+{
+	char buf[10];
+	size_t len;
+
+	len = sizeof(buf) - 1;
+	ctrlRequest("SAVE_CONFIG", buf, &len);
+
+	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");
+	else
+		QMessageBox::information(this, "Saved configuration",
+			                 "The current configuration was saved."
+					 "\n");
+}
+
+
 void WpaGui::selectAdapter( const QString & sel )
 {
 	if (openCtrlConnection(sel.toAscii().constData()) < 0)
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -53,6 +53,7 @@
 	virtual void addNetwork();
 	virtual void enableAllNetworks();
 	virtual void disableAllNetworks();
+	virtual void saveConfig();
 	virtual void selectAdapter(const QString &sel);
 	virtual void exitApp();
 
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.ui
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.ui
@@ -197,6 +197,7 @@
         <addaction name="fileEdit_networkAction" />
         <addaction name="fileEnableALLNetworksAction" />
         <addaction name="fileDisableALLNetworksAction" />
+        <addaction name="fileSaveConfig" />
         <addaction name="separator" />
         <addaction name="fileExitAction" />
       </widget>
@@ -329,6 +330,17 @@
         <string>&amp;Disable All Networks</string>
       </property>
     </action>
+    <action name="fileSaveConfig" >
+      <property name="name" stdset="0" >
+        <string>fileSaveConfig</string>
+      </property>
+      <property name="iconText" >
+        <string>Save Configuration</string>
+      </property>
+      <property name="text" >
+        <string>&amp;Save Configuration</string>
+      </property>
+    </action>
   </widget>
   <layoutdefault spacing="6" margin="11" />
   <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
---


More information about the HostAP mailing list