Add a KeyFile option to the utilities.ini config file. This option takes a filename...
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 27 Jan 2009 21:23:27 +0000 (21:23 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 27 Jan 2009 21:23:27 +0000 (21:23 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7574 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/frm/plugins.cpp
pgadmin/include/frm/frmMain.h
plugins/utilities.ini

index 10847ea33252db6c60a0edcd47c8634ad7abdaa7..dd61bdf95f7c6ac882812dc4e69b0686cd89a377 100644 (file)
@@ -72,9 +72,13 @@ void frmMain::LoadPluginUtilities()
             // Add the previous app if required.\r
             if (!util->title.IsEmpty() && !util->command.IsEmpty())\r
             {\r
-                CreatePluginUtility(util);\r
-                ClearPluginUtility(util);\r
-                pluginUtilityCount++;\r
+                // We're only going to add this if the keyfile exists or isn't specified\r
+                if (util->keyfile.IsEmpty() || wxFileExists(util->keyfile))\r
+                {\r
+                    CreatePluginUtility(util);\r
+                    ClearPluginUtility(util);\r
+                    pluginUtilityCount++;\r
+                }\r
             }\r
 \r
             util->title = token.AfterFirst('=').Trim();\r
@@ -88,6 +92,10 @@ void frmMain::LoadPluginUtilities()
                if (token.Lower().StartsWith(wxT("description=")))\r
             util->description = token.AfterFirst('=').Trim();\r
 \r
+        // KeyFile\r
+               if (token.Lower().StartsWith(wxT("keyfile=")))\r
+            util->keyfile = token.AfterFirst('=').Trim();\r
+\r
         // Database\r
                if (token.Lower().StartsWith(wxT("database=")))\r
         {\r
@@ -122,9 +130,13 @@ void frmMain::LoadPluginUtilities()
        // Add the last app if required.\r
     if (!util->title.IsEmpty() && !util->command.IsEmpty())\r
     {\r
-        CreatePluginUtility(util);\r
-        ClearPluginUtility(util);\r
-        pluginUtilityCount++;\r
+        // We're only going to add this if the keyfile exists or isn't specified\r
+        if (util->keyfile.IsEmpty() || wxFileExists(util->keyfile))\r
+        {\r
+            CreatePluginUtility(util);\r
+            ClearPluginUtility(util);\r
+            pluginUtilityCount++;\r
+        }\r
     }\r
 \r
     if (util)\r
@@ -149,6 +161,7 @@ void frmMain::ClearPluginUtility(PluginUtility *util)
     util->title = wxEmptyString;\r
     util->command = wxEmptyString;\r
     util->description = wxEmptyString;\r
+    util->keyfile = wxEmptyString;\r
     util->database = false;\r
     util->applies_to.Clear();\r
     util->set_password = false;\r
index d19ebfa1acc55df45e6b992ec4a7e0a59d197377..ecdabece266c5aa41e8cf27ba854cf8abaf39a40 100644 (file)
@@ -52,6 +52,7 @@ typedef struct PluginUtility {
     wxString title;
     wxString command;
     wxString description;
+    wxString keyfile;
     bool database;
     wxArrayString applies_to;
     bool set_password;
index 2372ffb0ec1253dc91854deb1a4ab915e278e81b..77645becaa46ad051526cf01203577fe9db24072 100644 (file)
@@ -36,6 +36,9 @@
 ;\r
 ; Description - A description of the utility for use in tooltips etc.\r
 ;\r
+; KeyFile     - If specified, this file must exist for the plugin to be shown\r
+;               on the menus.\r
+;\r
 ; Database    - Set to 'Yes' to indicate that the command needs to be executed\r
 ;               where database connection is possible - ie. when the currently\r
 ;               selected object in the treeview is a database or child object.\r
@@ -63,6 +66,7 @@
 ;\r
 ; Title=PSQL Console\r
 ; Command=/usr/bin/xterm -e /usr/local/pgsql/bin/psql -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE\r
+; KeyFile=/usr/local/pgsql/bin/psql\r
 ; Description=Open a PSQL console to the current database.\r
 ; Database=Yes\r
 ; SetPassword=Yes\r
@@ -81,6 +85,7 @@
 ; Title=PSQL Console\r
 ; Command="C:\Program Files\PostgreSQL\8.3\bin\psql.exe" -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE\r
 ; Description=Open a PSQL console to the current database.\r
+; KeyFile=C:\Program Files\PostgreSQL\8.3\bin\psql.exe\r
 ; Database=Yes\r
 ; SetPassword=Yes\r
 ;\r
@@ -88,6 +93,7 @@
 ;\r
 ; Title=PSQL Console\r
 ; Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script with command "/usr/local/pgsql/bin/psql -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE && exit || sleep 5 && exit"' -e 'end tell' -e 'end ignoring'\r
+; KeyFile=/usr/local/pgsql/bin/psql\r
 ; Description=Open a PSQL console to the current database.\r
 ; Database=Yes\r
 ; SetPassword=Yes\r