[network-manager-applet/th/vpn-auth-dialog-bgo765329] applet: load VPN auth-dialog via NMVpnPluginInfo instead of manually loading keyfile



commit 20dc6d35207695de4b04f390322e897a4fe989bd
Author: Thomas Haller <thaller redhat com>
Date:   Wed Apr 20 16:41:47 2016 +0200

    applet: load VPN auth-dialog via NMVpnPluginInfo instead of manually loading keyfile

 src/applet-vpn-request.c |   59 ++++++++-------------------------------------
 1 files changed, 11 insertions(+), 48 deletions(-)
---
diff --git a/src/applet-vpn-request.c b/src/applet-vpn-request.c
index f83ef5a..c65069a 100644
--- a/src/applet-vpn-request.c
+++ b/src/applet-vpn-request.c
@@ -169,65 +169,28 @@ find_auth_dialog_binary (const char *service,
                          gboolean *out_hints_supported,
                          GError **error)
 {
-       GDir *dir;
        char *prog = NULL;
-       const char *f;
-       gboolean hints_supported = FALSE;
+       const char *auth_dialog;
+       GSList *plugins;
+       NMVpnPluginInfo *plugin;
 
-       dir = g_dir_open (VPN_NAME_FILES_DIR, 0, NULL);
-       if (!dir) {
-               g_set_error (error,
-                            NM_SECRET_AGENT_ERROR,
-                            NM_SECRET_AGENT_ERROR_FAILED,
-                            "Failed to open VPN plugin file configuration directory " VPN_NAME_FILES_DIR);
-               return NULL;
-       }
+       plugins = nm_vpn_plugin_info_list_load ();
+       plugin = nm_vpn_plugin_info_list_find_by_service (plugins, service);
 
-       while (prog == NULL && (f = g_dir_read_name (dir)) != NULL) {
-               char *path;
-               GKeyFile *keyfile;
+       auth_dialog = plugin ? nm_vpn_plugin_info_get_auth_dialog (plugin) : NULL;
 
-               if (!g_str_has_suffix (f, ".name"))
-                       continue;
-
-               path = g_strdup_printf ("%s/%s", VPN_NAME_FILES_DIR, f);
-
-               keyfile = g_key_file_new ();
-               if (g_key_file_load_from_file (keyfile, path, 0, NULL)) {
-                       char *thisservice;
-
-                       thisservice = g_key_file_get_string (keyfile, "VPN Connection", "service", NULL);
-                       if (g_strcmp0 (thisservice, service) == 0) {
-                               prog = g_key_file_get_string (keyfile, "GNOME", "auth-dialog", NULL);
-                               hints_supported = g_key_file_get_boolean (keyfile, "GNOME", "supports-hints", 
NULL);
-                       }
-                       g_free (thisservice);
-               }
-               g_key_file_free (keyfile);
-               g_free (path);
-       }
-       g_dir_close (dir);
-
-       if (prog == NULL) {
+       if (!auth_dialog) {
                g_set_error (error,
                             NM_SECRET_AGENT_ERROR,
                             NM_SECRET_AGENT_ERROR_FAILED,
                             "Could not find the authentication dialog for VPN connection type '%s'",
                             service);
-       } else if (!g_path_is_absolute (prog)) {
-               char *prog_basename;
-
-               /* Remove any path component, then reconstruct path to the auth
-                * dialog in LIBEXECDIR.
-                */
-               prog_basename = g_path_get_basename (prog);
-               g_free (prog);
-               prog = g_strdup_printf ("%s/%s", LIBEXECDIR, prog_basename);
-               g_free (prog_basename);
-
-               *out_hints_supported = hints_supported;
+       } else {
+               prog = g_strdup (auth_dialog);
+               *out_hints_supported = nm_vpn_plugin_info_supports_hints (plugin);
        }
 
+       g_slist_free_full (plugins, g_object_unref);
        return prog;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]