diff options
author | Dan Williams <dcbw@redhat.com> | 2010-02-27 10:29:34 -0800 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-02-27 10:29:34 -0800 |
commit | 3b6a58145ff29d28bc026d4cec59aec076a99aba (patch) | |
tree | ca9aa49c931cb7fb415a91490004b2fe786bbe76 /src/mm-modem-base.c | |
parent | 20796148cee8021766dacf519bd3953fe8d8416c (diff) |
core: simply authentication request objects
Diffstat (limited to 'src/mm-modem-base.c')
-rw-r--r-- | src/mm-modem-base.c | 72 |
1 files changed, 4 insertions, 68 deletions
diff --git a/src/mm-modem-base.c b/src/mm-modem-base.c index 83178874..84dc1888 100644 --- a/src/mm-modem-base.c +++ b/src/mm-modem-base.c @@ -45,9 +45,6 @@ typedef struct { MMModemState state; MMAuthProvider *authp; - guint authp_added_id; - guint authp_removed_id; - GSList *auth_reqs; GHashTable *ports; } MMModemBasePrivate; @@ -240,67 +237,18 @@ modem_auth_request (MMModem *modem, } static gboolean -modem_auth_finish (MMModem *modem, - guint32 reqid, - MMAuthResult result, - GError **error) +modem_auth_finish (MMModem *modem, MMAuthRequest *req, GError **error) { - MMModemBase *self = MM_MODEM_BASE (modem); - MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self); - - if (result != MM_AUTH_RESULT_AUTHORIZED) { - const char *auth; - - auth = mm_auth_provider_get_authorization_for_id (priv->authp, reqid); + if (mm_auth_request_get_result (req) != MM_AUTH_RESULT_AUTHORIZED) { g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_AUTHORIZATION_REQUIRED, "This request requires the '%s' authorization", - auth ? auth : "(unknown)"); + mm_auth_request_get_authorization (req)); return FALSE; } return TRUE; } -static void -authp_request_added (MMAuthProvider *provider, - gpointer parent, - guint32 reqid, - gpointer user_data) -{ - MMModemBase *self; - MMModemBasePrivate *priv; - - /* Make sure it's our auth request */ - if (parent != user_data) - return; - - self = MM_MODEM_BASE (user_data); - priv = MM_MODEM_BASE_GET_PRIVATE (self); - - /* Add this request to our table so we can cancel it when we die */ - priv->auth_reqs = g_slist_prepend (priv->auth_reqs, GUINT_TO_POINTER (reqid)); -} - -static void -authp_request_removed (MMAuthProvider *provider, - gpointer parent, - guint32 reqid, - gpointer user_data) -{ - MMModemBase *self; - MMModemBasePrivate *priv; - - /* Make sure it's our auth request */ - if (parent != user_data) - return; - - self = MM_MODEM_BASE (user_data); - priv = MM_MODEM_BASE_GET_PRIVATE (self); - - /* Request finished; remove cleanly */ - priv->auth_reqs = g_slist_remove (priv->auth_reqs, GUINT_TO_POINTER (reqid)); -} - /*****************************************************************************/ static void @@ -309,12 +257,6 @@ mm_modem_base_init (MMModemBase *self) MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self); priv->authp = mm_auth_provider_get (); - priv->authp_added_id = g_signal_connect (priv->authp, "request-added", - (GCallback) authp_request_added, - self); - priv->authp_removed_id = g_signal_connect (priv->authp, "request-removed", - (GCallback) authp_request_removed, - self); priv->ports = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); @@ -425,14 +367,8 @@ finalize (GObject *object) { MMModemBase *self = MM_MODEM_BASE (object); MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self); - GSList *iter; - - g_signal_handler_disconnect (priv->authp, priv->authp_added_id); - g_signal_handler_disconnect (priv->authp, priv->authp_removed_id); - for (iter = priv->auth_reqs; iter; iter = g_slist_next (iter)) - mm_auth_provider_cancel_request (priv->authp, GPOINTER_TO_UINT (iter->data)); - g_slist_free (priv->auth_reqs); + mm_auth_provider_cancel_for_owner (priv->authp, object); g_hash_table_destroy (priv->ports); g_free (priv->driver); |