secret-agent: refactor call-id to be of an opaque pointer type instead of a void pointer

This gives some type safety.
This commit is contained in:
Thomas Haller 2015-08-24 19:20:55 +02:00
parent 8ed98a381b
commit 88e485bc1d
3 changed files with 34 additions and 30 deletions

View file

@ -396,7 +396,7 @@ struct _Request {
/* Current agent being asked for secrets */
NMSecretAgent *current;
gconstpointer current_call_id;
NMSecretAgentCallId current_call_id;
/* Stores the sorted list of NMSecretAgents which will be asked for secrets */
GSList *pending;
@ -770,7 +770,7 @@ connection_request_new_other (NMConnection *connection,
static void
get_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
NMSecretAgentCallId call_id,
GVariant *secrets,
GError *error,
gpointer user_data)
@ -1220,7 +1220,7 @@ nm_agent_manager_cancel_secrets (NMAgentManager *self,
static void
save_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
NMSecretAgentCallId call_id,
GVariant *secrets,
GError *error,
gpointer user_data)
@ -1315,10 +1315,10 @@ nm_agent_manager_save_secrets (NMAgentManager *self,
static void
delete_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
GVariant *secrets,
GError *error,
gpointer user_data)
NMSecretAgentCallId call_id,
GVariant *secrets,
GError *error,
gpointer user_data)
{
Request *req = user_data;

View file

@ -63,14 +63,16 @@ static guint signals[LAST_SIGNAL] = { 0 };
/*************************************************************/
typedef struct {
struct _NMSecretAgentCallId {
NMSecretAgent *agent;
GCancellable *cancellable;
char *path;
char *setting_name;
NMSecretAgentCallback callback;
gpointer callback_data;
} Request;
};
typedef struct _NMSecretAgentCallId Request;
static Request *
request_new (NMSecretAgent *agent,
@ -279,7 +281,7 @@ get_callback (GObject *proxy,
g_hash_table_remove (priv->requests, r);
}
gconstpointer
NMSecretAgentCallId
nm_secret_agent_get_secrets (NMSecretAgent *self,
NMConnection *connection,
const char *setting_name,
@ -337,7 +339,7 @@ cancel_done (GObject *proxy, GAsyncResult *result, gpointer user_data)
}
void
nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call)
nm_secret_agent_cancel_secrets (NMSecretAgent *self, NMSecretAgentCallId call)
{
NMSecretAgentPrivate *priv;
Request *r = (gpointer) call;
@ -378,7 +380,7 @@ agent_save_cb (GObject *proxy,
g_hash_table_remove (priv->requests, r);
}
gconstpointer
NMSecretAgentCallId
nm_secret_agent_save_secrets (NMSecretAgent *self,
NMConnection *connection,
NMSecretAgentCallback callback,
@ -426,7 +428,7 @@ agent_delete_cb (GObject *proxy,
g_hash_table_remove (priv->requests, r);
}
gconstpointer
NMSecretAgentCallId
nm_secret_agent_delete_secrets (NMSecretAgent *self,
NMConnection *connection,
NMSecretAgentCallback callback,

View file

@ -43,6 +43,8 @@ typedef struct {
void (*disconnected) (NMSecretAgent *self);
} NMSecretAgentClass;
typedef struct _NMSecretAgentCallId *NMSecretAgentCallId;
GType nm_secret_agent_get_type (void);
NMSecretAgent *nm_secret_agent_new (GDBusMethodInvocation *context,
@ -76,30 +78,30 @@ gboolean nm_secret_agent_has_permission (NMSecretAgent *agent,
const char *permission);
typedef void (*NMSecretAgentCallback) (NMSecretAgent *agent,
gconstpointer call,
NMSecretAgentCallId call_id,
GVariant *new_secrets, /* NULL for save & delete */
GError *error,
gpointer user_data);
gconstpointer nm_secret_agent_get_secrets (NMSecretAgent *agent,
NMConnection *connection,
const char *setting_name,
const char **hints,
NMSecretAgentGetSecretsFlags flags,
NMSecretAgentCallback callback,
gpointer callback_data);
NMSecretAgentCallId nm_secret_agent_get_secrets (NMSecretAgent *agent,
NMConnection *connection,
const char *setting_name,
const char **hints,
NMSecretAgentGetSecretsFlags flags,
NMSecretAgentCallback callback,
gpointer callback_data);
void nm_secret_agent_cancel_secrets (NMSecretAgent *agent,
gconstpointer call_id);
NMSecretAgentCallId call_id);
gconstpointer nm_secret_agent_save_secrets (NMSecretAgent *agent,
NMConnection *connection,
NMSecretAgentCallback callback,
gpointer callback_data);
NMSecretAgentCallId nm_secret_agent_save_secrets (NMSecretAgent *agent,
NMConnection *connection,
NMSecretAgentCallback callback,
gpointer callback_data);
gconstpointer nm_secret_agent_delete_secrets (NMSecretAgent *agent,
NMConnection *connection,
NMSecretAgentCallback callback,
gpointer callback_data);
NMSecretAgentCallId nm_secret_agent_delete_secrets (NMSecretAgent *agent,
NMConnection *connection,
NMSecretAgentCallback callback,
gpointer callback_data);
#endif /* __NETWORKMANAGER_SECRET_AGENT_H__ */