[network-manager-openvpn/bg/secret-timeout-bgo767321] fixup! auth-dialog: notify user of request expiration



commit dfa9112b7b4d8f9fcd50ee2a9d7a6142b09480b0
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Thu Jul 7 14:35:35 2016 +0200

    fixup! auth-dialog: notify user of request expiration

 auth-dialog/Makefile.am               |    2 ++
 auth-dialog/main.c                    |   15 ++++++++++++---
 shared/nm-utils/nm-vpn-plugin-utils.c |    1 -
 shared/nm-utils/nm-vpn-plugin-utils.h |   17 +++++++++++++++++
 4 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am
index a687b2c..0b7a44a 100644
--- a/auth-dialog/Makefile.am
+++ b/auth-dialog/Makefile.am
@@ -15,6 +15,8 @@ nm_openvpn_auth_dialog_CPPFLAGS =                     \
 nm_openvpn_auth_dialog_SOURCES = \
        $(top_srcdir)/shared/utils.c \
        $(top_srcdir)/shared/utils.h \
+       $(top_srcdir)/shared/nm-utils/nm-vpn-plugin-utils.c \
+       $(top_srcdir)/shared/nm-utils/nm-vpn-plugin-utils.h \
        main.c
 
 nm_openvpn_auth_dialog_LDADD = \
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 0a2a529..61fd68c 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -31,9 +31,9 @@
 #include <gtk/gtk.h>
 
 #include <libsecret/secret.h>
-
 #include <nma-vpn-password-dialog.h>
 
+#include "nm-utils/nm-vpn-plugin-utils.h"
 #include "utils.h"
 
 #define KEYRING_UUID_TAG "connection-uuid"
@@ -204,6 +204,15 @@ eui_finish (const char *vpn_name,
 
 /*****************************************************************/
 
+/* nma_password_dialog_set_expired() is NMA 1.4 API and we don't want
+ * a hard dependency on it. If the symbol it's not available the dialog
+ * will remain displayed as before.
+ */
+_NM_SYMBOL_RUN_DYNAMIC_VOID(nma_vpn_password_dialog_set_expired_compat,
+                            "nma_vpn_password_dialog_set_expired",
+                            (NMAVpnPasswordDialog *dialog, const char *reason),
+                            (dialog, reason));
+
 static void
 std_no_secrets_required (void)
 {
@@ -223,9 +232,9 @@ stdin_ready_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
        if (g_io_channel_read_line (source, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
                if (g_str_has_prefix (line, "CANCEL")){
                        if (sscanf (line, "%*s %u %m[^\n]", &reason_code, &reason_str) == 2)
-                               nma_vpn_password_dialog_set_expired (dialog, reason_str);
+                               nma_vpn_password_dialog_set_expired_compat (dialog, reason_str);
                        else
-                               nma_vpn_password_dialog_set_expired (dialog, NULL);
+                               nma_vpn_password_dialog_set_expired_compat (dialog, NULL);
                        return FALSE;
                }
                g_free (line);
diff --git a/shared/nm-utils/nm-vpn-plugin-utils.c b/shared/nm-utils/nm-vpn-plugin-utils.c
index 772aa39..3441aa3 100644
--- a/shared/nm-utils/nm-vpn-plugin-utils.c
+++ b/shared/nm-utils/nm-vpn-plugin-utils.c
@@ -127,4 +127,3 @@ nm_vpn_plugin_utils_load_editor (const char *module_name,
        g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), NULL);
        return editor;
 }
-
diff --git a/shared/nm-utils/nm-vpn-plugin-utils.h b/shared/nm-utils/nm-vpn-plugin-utils.h
index f3928d1..3fd8321 100644
--- a/shared/nm-utils/nm-vpn-plugin-utils.h
+++ b/shared/nm-utils/nm-vpn-plugin-utils.h
@@ -23,6 +23,7 @@
 #define __NM_VPN_PLUGIN_UTILS_H__
 
 #include <NetworkManager.h>
+#include <dlfcn.h>
 
 typedef NMVpnEditor *(NMVpnPluginUtilsEditorFactory) (gpointer factory,
                                                       NMVpnEditorPlugin *editor_plugin,
@@ -38,5 +39,21 @@ NMVpnEditor *nm_vpn_plugin_utils_load_editor (const char *module_name,
                                               gpointer user_data,
                                               GError **error);
 
+#define _NM_SYMBOL_RUN_DYNAMIC_VOID(new_func, func_str, typed_args, args) \
+void new_func typed_args \
+{ \
+       void *dl_module; \
+       void (*func) typed_args; \
+       \
+       dl_module = dlopen (NULL, RTLD_LAZY | RTLD_LOCAL); \
+       if (!dl_module) \
+               return; \
+       func = dlsym (dl_module, func_str); \
+       if (func) \
+               func args; \
+       \
+       dlclose (dl_module); \
+}
+
 #endif /* __NM_VPN_PLUGIN_UTILS_H__ */
 


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