[network-manager-applet/bg/secret-timeout-bgo767321: 2/4] applet: remember the reason for secret request cancellation
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/bg/secret-timeout-bgo767321: 2/4] applet: remember the reason for secret request cancellation
- Date: Mon, 20 Jun 2016 15:16:36 +0000 (UTC)
commit c29de20dda7ce4e51f871da89846c6e3fdedaa0b
Author: Beniamino Galvani <bgalvani redhat com>
Date: Mon Jun 20 15:15:01 2016 +0200
applet: remember the reason for secret request cancellation
Implement CancelGetSecretsWithReason() to obtain a reason for the
cancelation and remember store it in the request. It will be used in
the next commit to notify the auth-dialog about the expiration of the
request.
src/applet-agent.c | 24 +++++++++++++++++++-----
src/applet-vpn-request.c | 1 +
src/applet.c | 11 ++++++++++-
src/applet.h | 5 +++++
4 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/src/applet-agent.c b/src/applet-agent.c
index a9a8f5c..bd9fcda 100644
--- a/src/applet-agent.c
+++ b/src/applet-agent.c
@@ -28,6 +28,7 @@
#include "applet-agent.h"
#include "utils.h"
+#include "nm-dbus-interface.h"
#define KEYRING_UUID_TAG "connection-uuid"
#define KEYRING_SN_TAG "setting-name"
@@ -488,9 +489,10 @@ get_secrets (NMSecretAgentOld *agent,
/*******************************************************/
static void
-cancel_get_secrets (NMSecretAgentOld *agent,
- const char *connection_path,
- const char *setting_name)
+cancel_get_secrets_with_reason (NMSecretAgentOld *agent,
+ const char *connection_path,
+ const char *setting_name,
+ NMSecretAgentCancelReason reason)
{
AppletAgentPrivate *priv = APPLET_AGENT_GET_PRIVATE (agent);
GHashTableIter iter;
@@ -515,13 +517,24 @@ cancel_get_secrets (NMSecretAgentOld *agent,
r->get_callback (NM_SECRET_AGENT_OLD (r->agent), r->connection, NULL, error,
r->callback_data);
g_hash_table_iter_remove (&iter);
- g_signal_emit (r->agent, signals[CANCEL_SECRETS], 0, GUINT_TO_POINTER (r->id));
+ g_signal_emit (r->agent, signals[CANCEL_SECRETS], 0, GUINT_TO_POINTER (r->id),
GUINT_TO_POINTER (reason));
}
}
g_error_free (error);
}
+static void
+cancel_get_secrets (NMSecretAgentOld *agent,
+ const char *connection_path,
+ const char *setting_name)
+{
+ cancel_get_secrets_with_reason (agent,
+ connection_path,
+ setting_name,
+ NM_SECRET_AGENT_CANCEL_REASON_UNKNOWN);
+}
+
/*******************************************************/
static void
@@ -834,6 +847,7 @@ applet_agent_class_init (AppletAgentClass *agent_class)
object_class->dispose = dispose;
parent_class->get_secrets = get_secrets;
parent_class->cancel_get_secrets = cancel_get_secrets;
+ parent_class->cancel_get_secrets_with_reason = cancel_get_secrets_with_reason;
parent_class->save_secrets = save_secrets;
parent_class->delete_secrets = delete_secrets;
@@ -853,6 +867,6 @@ applet_agent_class_init (AppletAgentClass *agent_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (AppletAgentClass, cancel_secrets),
NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
}
diff --git a/src/applet-vpn-request.c b/src/applet-vpn-request.c
index db66bb5..69f72a7 100644
--- a/src/applet-vpn-request.c
+++ b/src/applet-vpn-request.c
@@ -73,6 +73,7 @@ typedef struct {
int num_newlines;
GIOChannel *channel;
guint channel_eventid;
+ NMSecretAgentCancelReason cancel_reason;
} AppletVpnRequestPrivate;
/****************************************************************/
diff --git a/src/applet.c b/src/applet.c
index 08be772..8d54243 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2767,6 +2767,14 @@ applet_secrets_request_free (SecretsRequest *req)
g_free (req);
}
+void
+applet_secrets_request_cancel (SecretsRequest *req, NMSecretAgentCancelReason reason)
+{
+ req->canceled = TRUE;
+ req->cancel_reason = reason;
+ applet_secrets_request_free (req);
+}
+
static void
get_existing_secrets_cb (NMSecretAgentOld *agent,
NMConnection *connection,
@@ -2883,6 +2891,7 @@ error:
static void
applet_agent_cancel_secrets_cb (AppletAgent *agent,
gpointer request_id,
+ NMSecretAgentCancelReason reason,
gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
@@ -2895,7 +2904,7 @@ applet_agent_cancel_secrets_cb (AppletAgent *agent,
if (req->reqid == request_id) {
/* cancel and free this password request */
- applet_secrets_request_free (req);
+ applet_secrets_request_cancel (req, reason);
break;
}
}
diff --git a/src/applet.h b/src/applet.h
index a308f20..b3c79ca 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -27,6 +27,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#include <nm-dbus-interface.h>
+
#include <net/ethernet.h>
#include <libnotify/notify.h>
@@ -164,6 +166,8 @@ struct _SecretsRequest {
NMApplet *applet;
AppletAgentSecretsCallback callback;
gpointer callback_data;
+ gboolean canceled;
+ NMSecretAgentCancelReason cancel_reason;
NMConnection *connection;
@@ -180,6 +184,7 @@ void applet_secrets_request_complete_setting (SecretsRequest *req,
const char *setting_name,
GError *error);
void applet_secrets_request_free (SecretsRequest *req);
+void applet_secrets_request_cancel (SecretsRequest *req, NMSecretAgentCancelReason reason);
struct NMADeviceClass {
gboolean (*new_auto_connection) (NMDevice *device,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]