clients: NMSecretAgentSimple API fixups

nm_secret_agent_simple_*() functions should take an
NMSecretAgentSimple, not an NMSecretAgent.

The type macros were incorrectly validating against
NM_TYPE_SECRET_AGENT rather than NM_TYPE_SECRET_AGENT_SIMPLE.
This commit is contained in:
Dan Winship
2014-11-20 11:55:54 -05:00
parent abcb3184b3
commit a1f746351a
6 changed files with 35 additions and 37 deletions

View File

@@ -147,7 +147,7 @@ do_agent_secret (NmCli *nmc, int argc, char **argv)
/* We keep running */
nmc->should_wait = TRUE;
nm_secret_agent_simple_enable (nmc->secret_agent);
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
g_signal_connect (nmc->secret_agent, "request-secrets", G_CALLBACK (secrets_requested), nmc);
g_print (_("nmcli successfully registered as a NetworkManager's secret agent.\n"));
} else {

View File

@@ -1770,8 +1770,8 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
NMRemoteConnection *connection = nm_active_connection_get_connection (active);
const gchar *path = nm_connection_get_path (NM_CONNECTION (connection));
nm_secret_agent_simple_set_connection_path (nmc->secret_agent, path);
nm_secret_agent_simple_enable (nmc->secret_agent);
nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
}
devices = nm_active_connection_get_devices (active);
@@ -2094,8 +2094,8 @@ nmc_activate_connection (NmCli *nmc,
if (connection) {
const gchar *path = nm_object_get_path (NM_OBJECT (connection));
nm_secret_agent_simple_set_connection_path (nmc->secret_agent, path);
nm_secret_agent_simple_enable (nmc->secret_agent);
nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
}
}

View File

@@ -1522,8 +1522,8 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
NMRemoteConnection *connection = nm_active_connection_get_connection (active);
const char *path = nm_connection_get_path (NM_CONNECTION (connection));
nm_secret_agent_simple_set_connection_path (nmc->secret_agent, path);
nm_secret_agent_simple_enable (nmc->secret_agent);
nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
}
g_object_ref (device);

View File

@@ -584,15 +584,15 @@ nm_secret_agent_simple_delete_secrets (NMSecretAgent *agent,
/**
* nm_secret_agent_simple_set_connection_path:
* @agent: the #NMSecretAgentSimple
* @self: the #NMSecretAgentSimple
* @path: the path of the connection the agent handle secrets for
*
* Sets the path for a new #NMSecretAgentSimple.
*/
void
nm_secret_agent_simple_set_connection_path (NMSecretAgent *agent, const char *path)
nm_secret_agent_simple_set_connection_path (NMSecretAgentSimple *self, const char *path)
{
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (agent);
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (self);
g_free (priv->path);
priv->path = g_strdup (path);
@@ -600,14 +600,14 @@ nm_secret_agent_simple_set_connection_path (NMSecretAgent *agent, const char *pa
/**
* nm_secret_agent_simple_enable:
* @agent: the #NMSecretAgentSimple
* @self: the #NMSecretAgentSimple
*
* Enables servicing the requests including the already queued ones.
*/
void
nm_secret_agent_simple_enable (NMSecretAgent *agent)
nm_secret_agent_simple_enable (NMSecretAgentSimple *self)
{
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (agent);
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (self);
GList *requests, *iter;
GError *error;
@@ -696,11 +696,7 @@ nm_secret_agent_simple_class_init (NMSecretAgentSimpleClass *klass)
NMSecretAgent *
nm_secret_agent_simple_new (const char *name)
{
NMSecretAgent *agent;
agent = g_initable_new (NM_TYPE_SECRET_AGENT_SIMPLE, NULL, NULL,
NM_SECRET_AGENT_IDENTIFIER, name,
NULL);
return agent;
return g_initable_new (NM_TYPE_SECRET_AGENT_SIMPLE, NULL, NULL,
NM_SECRET_AGENT_OLD_IDENTIFIER, name,
NULL);
}

View File

@@ -24,11 +24,11 @@
G_BEGIN_DECLS
#define NM_TYPE_SECRET_AGENT_SIMPLE (nm_secret_agent_simple_get_type ())
#define NM_SECRET_AGENT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentSimple))
#define NM_SECRET_AGENT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentSimpleClass))
#define NM_IS_SECRET_AGENT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT))
#define NM_IS_SECRET_AGENT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT))
#define NM_SECRET_AGENT_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentSimpleClass))
#define NM_SECRET_AGENT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT_SIMPLE, NMSecretAgentSimple))
#define NM_SECRET_AGENT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT_SIMPLE, NMSecretAgentSimpleClass))
#define NM_IS_SECRET_AGENT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT_SIMPLE))
#define NM_IS_SECRET_AGENT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT_SIMPLE))
#define NM_SECRET_AGENT_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT_SIMPLE, NMSecretAgentSimpleClass))
typedef struct {
NMSecretAgent parent;
@@ -47,13 +47,15 @@ typedef struct {
GType nm_secret_agent_simple_get_type (void);
NMSecretAgent *nm_secret_agent_simple_new (const char *name);
void nm_secret_agent_simple_response (NMSecretAgentSimple *self,
const char *request_id,
GPtrArray *secrets);
void nm_secret_agent_simple_set_connection_path (NMSecretAgent *agent,
const char *path);
void nm_secret_agent_simple_enable (NMSecretAgent *agent);
NMSecretAgent *nm_secret_agent_simple_new (const char *name);
void nm_secret_agent_simple_response (NMSecretAgentSimple *self,
const char *request_id,
GPtrArray *secrets);
void nm_secret_agent_simple_set_connection_path (NMSecretAgentSimple *self,
const char *path);
void nm_secret_agent_simple_enable (NMSecretAgentSimple *self);
G_END_DECLS

View File

@@ -148,9 +148,9 @@ activate_connection (NMConnection *connection,
agent = nm_secret_agent_simple_new ("nmtui");
if (agent) {
if (connection) {
nm_secret_agent_simple_set_connection_path (agent,
nm_object_get_path (NM_OBJECT (connection)));
nm_secret_agent_simple_enable (agent);
nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (agent),
nm_object_get_path (NM_OBJECT (connection)));
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent));
}
g_signal_connect (agent, "request-secrets", G_CALLBACK (secrets_requested), NULL);
}
@@ -194,8 +194,8 @@ activate_connection (NMConnection *connection,
if (connection) {
const gchar *path = nm_object_get_path (NM_OBJECT (connection));
nm_secret_agent_simple_set_connection_path (agent, path);
nm_secret_agent_simple_enable (agent);
nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (agent), path);
nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent));
}
}