core: simply authentication request objects

This commit is contained in:
Dan Williams
2010-02-27 10:29:34 -08:00
parent 20796148ce
commit 3b6a58145f
10 changed files with 160 additions and 402 deletions

View File

@@ -37,6 +37,11 @@ modem_manager_SOURCES = \
main.c \ main.c \
mm-callback-info.c \ mm-callback-info.c \
mm-callback-info.h \ mm-callback-info.h \
mm-auth-request.c \
mm-auth-request.h \
mm-auth-provider.h \
mm-auth-provider.c \
mm-auth-provider-factory.c \
mm-manager.c \ mm-manager.c \
mm-manager.h \ mm-manager.h \
mm-modem.c \ mm-modem.c \
@@ -71,13 +76,12 @@ modem_manager_SOURCES = \
mm-plugin-base.c \ mm-plugin-base.c \
mm-plugin-base.h \ mm-plugin-base.h \
mm-properties-changed-signal.c \ mm-properties-changed-signal.c \
mm-properties-changed-signal.h \ mm-properties-changed-signal.h
mm-auth-provider.h \
mm-auth-provider.c \
mm-auth-provider-factory.c
if WITH_POLKIT if WITH_POLKIT
modem_manager_SOURCES += \ modem_manager_SOURCES += \
mm-auth-request-polkit.c \
mm-auth-request-polkit.h \
mm-auth-provider-polkit.c \ mm-auth-provider-polkit.c \
mm-auth-provider-polkit.h mm-auth-provider-polkit.h
endif endif

View File

@@ -35,14 +35,6 @@ enum {
LAST_PROP LAST_PROP
}; };
enum {
REQUEST_ADDED,
REQUEST_REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/*****************************************************************************/ /*****************************************************************************/
GObject * GObject *
@@ -53,101 +45,19 @@ mm_auth_provider_new (void)
/*****************************************************************************/ /*****************************************************************************/
struct MMAuthRequest { static void
guint32 refcount; remove_requests (MMAuthProvider *self, GSList *remove)
guint32 id;
char *auth;
GObject *instance;
MMAuthResult result;
MMAuthRequestCb callback;
gpointer callback_data;
GDestroyNotify notify;
};
static MMAuthRequest *
mm_auth_request_new (const char *authorization,
GObject *instance,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify)
{ {
static guint32 id = 1; MMAuthProviderPrivate *priv = MM_AUTH_PROVIDER_GET_PRIVATE (self);
MMAuthRequest *req; MMAuthRequest *req;
g_return_val_if_fail (authorization != NULL, NULL); while (remove) {
g_return_val_if_fail (callback != NULL, NULL); req = MM_AUTH_REQUEST (remove->data);
g_hash_table_remove (priv->requests, req);
req = g_malloc0 (sizeof (MMAuthRequest)); remove = g_slist_remove (remove, req);
req->id = id++;
req->refcount = 1;
req->auth = g_strdup (authorization);
req->instance = instance;
req->callback = callback;
req->callback_data = callback_data;
req->notify = notify;
return req;
}
MMAuthRequest *
mm_auth_request_ref (MMAuthRequest *req)
{
g_return_val_if_fail (req != NULL, NULL);
g_return_val_if_fail (req->refcount > 0, NULL);
req->refcount++;
return req;
}
void
mm_auth_request_unref (MMAuthRequest *req)
{
g_return_if_fail (req != NULL);
g_return_if_fail (req->refcount > 0);
req->refcount--;
if (req->refcount == 0) {
g_free (req->auth);
memset (req, 0, sizeof (MMAuthRequest));
g_free (req);
} }
} }
guint32
mm_auth_request_get_id (MMAuthRequest *req)
{
g_return_val_if_fail (req != NULL, 0);
g_return_val_if_fail (req->refcount > 0, 0);
return req->id;
}
const char *
mm_auth_request_get_authorization (MMAuthRequest *req)
{
g_return_val_if_fail (req != NULL, 0);
g_return_val_if_fail (req->refcount > 0, 0);
return req->auth;
}
/*****************************************************************************/
MMAuthRequest *
mm_auth_provider_get_request (MMAuthProvider *provider, guint32 reqid)
{
MMAuthProviderPrivate *priv;
g_return_val_if_fail (provider != NULL, NULL);
g_return_val_if_fail (MM_IS_AUTH_PROVIDER (provider), NULL);
g_return_val_if_fail (reqid > 0, NULL);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
return (MMAuthRequest *) g_hash_table_lookup (priv->requests, GUINT_TO_POINTER (reqid));
}
static gboolean static gboolean
process_complete_requests (gpointer user_data) process_complete_requests (gpointer user_data)
{ {
@@ -163,92 +73,78 @@ process_complete_requests (gpointer user_data)
/* Call finished request's callbacks */ /* Call finished request's callbacks */
g_hash_table_iter_init (&iter, priv->requests); g_hash_table_iter_init (&iter, priv->requests);
while (g_hash_table_iter_next (&iter, NULL, &value)) { while (g_hash_table_iter_next (&iter, NULL, &value)) {
req = (MMAuthRequest *) value; req = MM_AUTH_REQUEST (value);
if (req->result != MM_AUTH_RESULT_UNKNOWN) {
req->callback (req->instance, req->id, req->result, req->callback_data);
/* Let the caller clean up the request's callback data */
if (req->notify)
req->notify (req->callback_data);
if (mm_auth_request_get_authorization (req) != MM_AUTH_RESULT_UNKNOWN) {
mm_auth_request_complete (req);
remove = g_slist_prepend (remove, req); remove = g_slist_prepend (remove, req);
} }
} }
/* And remove those requests from our pending request list */ /* And remove those requests from our pending request list */
while (remove) { remove_requests (self, remove);
req = (MMAuthRequest *) remove->data;
g_signal_emit (self, signals[REQUEST_REMOVED], 0, req->instance, req->id);
g_hash_table_remove (priv->requests, GUINT_TO_POINTER (req->id));
remove = g_slist_remove (remove, req);
}
return FALSE; return FALSE;
} }
void void
mm_auth_provider_finish_request (MMAuthProvider *provider, mm_auth_provider_finish_request (MMAuthProvider *provider,
guint32 reqid, MMAuthRequest *req,
MMAuthResult result) MMAuthResult result)
{ {
MMAuthProviderPrivate *priv; MMAuthProviderPrivate *priv;
MMAuthRequest *req;
g_return_if_fail (provider != NULL); g_return_if_fail (provider != NULL);
g_return_if_fail (MM_IS_AUTH_PROVIDER (provider)); g_return_if_fail (MM_IS_AUTH_PROVIDER (provider));
g_return_if_fail (reqid > 0); g_return_if_fail (req != NULL);
g_return_if_fail (result != MM_AUTH_RESULT_UNKNOWN); g_return_if_fail (result != MM_AUTH_RESULT_UNKNOWN);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider); priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
req = (MMAuthRequest *) g_hash_table_lookup (priv->requests, GUINT_TO_POINTER (reqid)); g_return_if_fail (g_hash_table_lookup (priv->requests, req) != NULL);
g_return_if_fail (req != NULL);
req->result = result;
mm_auth_request_set_result (req, result);
if (priv->process_id == 0) if (priv->process_id == 0)
priv->process_id = g_idle_add (process_complete_requests, provider); priv->process_id = g_idle_add (process_complete_requests, provider);
} }
void void
mm_auth_provider_cancel_request (MMAuthProvider *provider, guint32 reqid) mm_auth_provider_cancel_request (MMAuthProvider *provider, MMAuthRequest *req)
{ {
MMAuthProviderPrivate *priv; MMAuthProviderPrivate *priv;
MMAuthRequest *req;
g_return_if_fail (provider != NULL); g_return_if_fail (provider != NULL);
g_return_if_fail (MM_IS_AUTH_PROVIDER (provider)); g_return_if_fail (MM_IS_AUTH_PROVIDER (provider));
g_return_if_fail (reqid > 0);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
req = (MMAuthRequest *) g_hash_table_lookup (priv->requests, GUINT_TO_POINTER (reqid));
g_return_if_fail (req != NULL); g_return_if_fail (req != NULL);
/* Let the caller clean up the request's callback data */ priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
if (req->notify)
req->notify (req->callback_data);
/* We don't signal removal here as it's assumed the caller g_return_if_fail (g_hash_table_lookup (priv->requests, req) != NULL);
* handles that itself instead of by the signal. g_hash_table_remove (priv->requests, req);
*/
g_hash_table_remove (priv->requests, GUINT_TO_POINTER (reqid));
} }
const char * void
mm_auth_provider_get_authorization_for_id (MMAuthProvider *provider, guint32 reqid) mm_auth_provider_cancel_for_owner (MMAuthProvider *self, GObject *owner)
{ {
MMAuthProviderPrivate *priv; MMAuthProviderPrivate *priv;
GHashTableIter iter;
MMAuthRequest *req; MMAuthRequest *req;
gpointer value;
GSList *remove = NULL;
g_return_val_if_fail (provider != NULL, NULL); g_return_if_fail (self != NULL);
g_return_val_if_fail (MM_IS_AUTH_PROVIDER (provider), NULL); g_return_if_fail (MM_IS_AUTH_PROVIDER (self));
g_return_val_if_fail (reqid > 0, NULL);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider); /* Find all requests from this owner */
req = (MMAuthRequest *) g_hash_table_lookup (priv->requests, GUINT_TO_POINTER (reqid)); priv = MM_AUTH_PROVIDER_GET_PRIVATE (self);
g_return_val_if_fail (req != NULL, NULL); g_hash_table_iter_init (&iter, priv->requests);
while (g_hash_table_iter_next (&iter, NULL, &value)) {
req = MM_AUTH_REQUEST (value);
if (mm_auth_request_get_owner (req) == owner)
remove = g_slist_prepend (remove, req);
}
return mm_auth_request_get_authorization (req); /* And cancel/remove them */
remove_requests (self, remove);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -259,16 +155,25 @@ real_request_auth (MMAuthProvider *provider,
GError **error) GError **error)
{ {
/* This class provides null authentication; all requests pass */ /* This class provides null authentication; all requests pass */
mm_auth_provider_finish_request (provider, mm_auth_provider_finish_request (provider, req, MM_AUTH_RESULT_AUTHORIZED);
mm_auth_request_get_id (req),
MM_AUTH_RESULT_AUTHORIZED);
return TRUE; return TRUE;
} }
guint32 static MMAuthRequest *
mm_auth_provider_request_auth (MMAuthProvider *provider, real_create_request (MMAuthProvider *provider,
const char *authorization,
GObject *owner,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify)
{
return (MMAuthRequest *) mm_auth_request_new (authorization, owner, callback, callback_data, notify);
}
MMAuthRequest *
mm_auth_provider_request_auth (MMAuthProvider *self,
const char *authorization, const char *authorization,
GObject *instance, GObject *owner,
MMAuthRequestCb callback, MMAuthRequestCb callback,
gpointer callback_data, gpointer callback_data,
GDestroyNotify notify, GDestroyNotify notify,
@@ -277,32 +182,29 @@ mm_auth_provider_request_auth (MMAuthProvider *provider,
MMAuthProviderPrivate *priv; MMAuthProviderPrivate *priv;
MMAuthRequest *req; MMAuthRequest *req;
g_return_val_if_fail (provider != NULL, 0); g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (MM_IS_AUTH_PROVIDER (provider), 0); g_return_val_if_fail (MM_IS_AUTH_PROVIDER (self), 0);
g_return_val_if_fail (authorization != NULL, 0); g_return_val_if_fail (authorization != NULL, 0);
g_return_val_if_fail (callback != NULL, 0); g_return_val_if_fail (callback != NULL, 0);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider); priv = MM_AUTH_PROVIDER_GET_PRIVATE (self);
req = mm_auth_request_new (authorization, instance, callback, callback_data, notify); req = MM_AUTH_PROVIDER_GET_CLASS (self)->create_request (self,
authorization,
owner,
callback,
callback_data,
notify);
g_assert (req); g_assert (req);
g_hash_table_insert (priv->requests, GUINT_TO_POINTER (req->id), req); g_hash_table_insert (priv->requests, req, req);
g_signal_emit (provider, signals[REQUEST_ADDED], 0, instance, req->id); if (!MM_AUTH_PROVIDER_GET_CLASS (self)->request_auth (self, req, error)) {
if (!MM_AUTH_PROVIDER_GET_CLASS (provider)->request_auth (provider, req, error)) {
/* Error */ /* Error */
g_signal_emit (provider, signals[REQUEST_REMOVED], 0, instance, req->id); g_hash_table_remove (priv->requests, req);
return NULL;
/* Let the caller clean up the request's callback data */
if (req->notify)
req->notify (req->callback_data);
g_hash_table_remove (priv->requests, GUINT_TO_POINTER (req->id));
return 0;
} }
return req->id; return req;
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -315,7 +217,7 @@ mm_auth_provider_init (MMAuthProvider *self)
priv->requests = g_hash_table_new_full (g_direct_hash, priv->requests = g_hash_table_new_full (g_direct_hash,
g_direct_equal, g_direct_equal,
NULL, NULL,
(GDestroyNotify) mm_auth_request_unref); (GDestroyNotify) g_object_unref);
} }
static void static void
@@ -352,7 +254,7 @@ get_property (GObject *object,
} }
static void static void
finalize (GObject *object) dispose (GObject *object)
{ {
MMAuthProviderPrivate *priv = MM_AUTH_PROVIDER_GET_PRIVATE (object); MMAuthProviderPrivate *priv = MM_AUTH_PROVIDER_GET_PRIVATE (object);
@@ -360,7 +262,7 @@ finalize (GObject *object)
g_source_remove (priv->process_id); g_source_remove (priv->process_id);
g_hash_table_destroy (priv->requests); g_hash_table_destroy (priv->requests);
G_OBJECT_CLASS (mm_auth_provider_parent_class)->finalize (object); G_OBJECT_CLASS (mm_auth_provider_parent_class)->dispose (object);
} }
static void static void
@@ -374,8 +276,9 @@ mm_auth_provider_class_init (MMAuthProviderClass *class)
/* Virtual methods */ /* Virtual methods */
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->dispose = dispose;
class->request_auth = real_request_auth; class->request_auth = real_request_auth;
class->create_request = real_create_request;
/* Properties */ /* Properties */
g_object_class_install_property (object_class, PROP_NAME, g_object_class_install_property (object_class, PROP_NAME,
@@ -384,22 +287,5 @@ mm_auth_provider_class_init (MMAuthProviderClass *class)
"Provider name", "Provider name",
NULL_PROVIDER, NULL_PROVIDER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* Signals */
signals[REQUEST_ADDED] =
g_signal_new ("request-added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
mm_marshal_VOID__POINTER_UINT,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
signals[REQUEST_REMOVED] =
g_signal_new ("request-removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
mm_marshal_VOID__POINTER_UINT,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
} }

View File

@@ -18,6 +18,8 @@
#include <glib-object.h> #include <glib-object.h>
#include "mm-auth-request.h"
/* Authorizations */ /* Authorizations */
#define MM_AUTHORIZATION_DEVICE "org.freedesktop.ModemManager.Device" #define MM_AUTHORIZATION_DEVICE "org.freedesktop.ModemManager.Device"
#define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts" #define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts"
@@ -34,66 +36,47 @@
#define MM_AUTH_PROVIDER_NAME "name" #define MM_AUTH_PROVIDER_NAME "name"
typedef enum MMAuthResult { typedef struct {
MM_AUTH_RESULT_UNKNOWN = 0,
MM_AUTH_RESULT_INTERNAL_FAILURE,
MM_AUTH_RESULT_NOT_AUTHORIZED,
MM_AUTH_RESULT_CHALLENGE,
MM_AUTH_RESULT_AUTHORIZED
} MMAuthResult;
typedef struct MMAuthRequest MMAuthRequest;
typedef struct _MMAuthProvider MMAuthProvider;
typedef struct _MMAuthProviderClass MMAuthProviderClass;
typedef void (*MMAuthRequestCb) (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data);
struct _MMAuthProvider {
GObject parent; GObject parent;
}; } MMAuthProvider;
struct _MMAuthProviderClass { typedef struct {
GObjectClass parent; GObjectClass parent;
gboolean (*request_auth) (MMAuthProvider *provider, gboolean (*request_auth) (MMAuthProvider *provider,
MMAuthRequest *req, MMAuthRequest *req,
GError **error); GError **error);
};
MMAuthRequest * (*create_request) (MMAuthProvider *provider,
const char *authorization,
GObject *owner,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify);
} MMAuthProviderClass;
GType mm_auth_provider_get_type (void); GType mm_auth_provider_get_type (void);
guint32 mm_auth_provider_request_auth (MMAuthProvider *provider, MMAuthRequest *mm_auth_provider_request_auth (MMAuthProvider *provider,
const char *authorization, const char *authorization,
GObject *instance, GObject *owner,
MMAuthRequestCb callback, MMAuthRequestCb callback,
gpointer callback_data, gpointer callback_data,
GDestroyNotify notify, GDestroyNotify notify,
GError **error); GError **error);
void mm_auth_provider_cancel_for_owner (MMAuthProvider *provider,
GObject *owner);
/* To get an auth provider instance, implemented in mm-auth-provider-factory.c */ /* To get an auth provider instance, implemented in mm-auth-provider-factory.c */
MMAuthProvider *mm_auth_provider_get (void); MMAuthProvider *mm_auth_provider_get (void);
/* For subclasses only */
MMAuthRequest *mm_auth_provider_get_request (MMAuthProvider *provider, guint32 reqid);
MMAuthRequest *mm_auth_request_ref (MMAuthRequest *req);
void mm_auth_request_unref (MMAuthRequest *req);
guint32 mm_auth_request_get_id (MMAuthRequest *req);
const char * mm_auth_request_get_authorization (MMAuthRequest *req);
/* Normal API */
/* schedules the request's completion */ /* schedules the request's completion */
void mm_auth_provider_finish_request (MMAuthProvider *provider, void mm_auth_provider_finish_request (MMAuthProvider *provider,
guint32 reqid, MMAuthRequest *req,
MMAuthResult result); MMAuthResult result);
void mm_auth_provider_cancel_request (MMAuthProvider *provider, guint32 reqid); void mm_auth_provider_cancel_request (MMAuthProvider *provider, MMAuthRequest *req);
const char *mm_auth_provider_get_authorization_for_id (MMAuthProvider *provider,
guint32 reqid);
#endif /* MM_AUTH_PROVIDER_H */ #endif /* MM_AUTH_PROVIDER_H */

View File

@@ -45,9 +45,6 @@ typedef struct {
MMModemState state; MMModemState state;
MMAuthProvider *authp; MMAuthProvider *authp;
guint authp_added_id;
guint authp_removed_id;
GSList *auth_reqs;
GHashTable *ports; GHashTable *ports;
} MMModemBasePrivate; } MMModemBasePrivate;
@@ -240,67 +237,18 @@ modem_auth_request (MMModem *modem,
} }
static gboolean static gboolean
modem_auth_finish (MMModem *modem, modem_auth_finish (MMModem *modem, MMAuthRequest *req, GError **error)
guint32 reqid,
MMAuthResult result,
GError **error)
{ {
MMModemBase *self = MM_MODEM_BASE (modem); if (mm_auth_request_get_result (req) != MM_AUTH_RESULT_AUTHORIZED) {
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);
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_AUTHORIZATION_REQUIRED, g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_AUTHORIZATION_REQUIRED,
"This request requires the '%s' authorization", "This request requires the '%s' authorization",
auth ? auth : "(unknown)"); mm_auth_request_get_authorization (req));
return FALSE; return FALSE;
} }
return TRUE; 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 static void
@@ -309,12 +257,6 @@ mm_modem_base_init (MMModemBase *self)
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self); MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
priv->authp = mm_auth_provider_get (); 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); 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); MMModemBase *self = MM_MODEM_BASE (object);
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self); MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
GSList *iter;
g_signal_handler_disconnect (priv->authp, priv->authp_added_id); mm_auth_provider_cancel_for_owner (priv->authp, object);
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);
g_hash_table_destroy (priv->ports); g_hash_table_destroy (priv->ports);
g_free (priv->driver); g_free (priv->driver);

View File

@@ -189,17 +189,14 @@ mm_modem_cdma_get_esn (MMModemCdma *self,
} }
static void static void
esn_auth_cb (GObject *instance, esn_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemCdma *self = MM_MODEM_CDMA (instance); MMModemCdma *self = MM_MODEM_CDMA (owner);
DBusGMethodInvocation *context = user_data; DBusGMethodInvocation *context = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise get the ESN */ /* Return any authorization error, otherwise get the ESN */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error); g_error_free (error);
} else } else

View File

@@ -202,17 +202,14 @@ mm_modem_gsm_card_change_pin (MMModemGsmCard *self,
/*****************************************************************************/ /*****************************************************************************/
static void static void
imei_auth_cb (GObject *instance, imei_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
DBusGMethodInvocation *context = user_data; DBusGMethodInvocation *context = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise get the IMEI */ /* Return any authorization error, otherwise get the IMEI */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -239,17 +236,14 @@ impl_gsm_modem_get_imei (MMModemGsmCard *modem, DBusGMethodInvocation *context)
/*****************************************************************************/ /*****************************************************************************/
static void static void
imsi_auth_cb (GObject *instance, imsi_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
DBusGMethodInvocation *context = user_data; DBusGMethodInvocation *context = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise get the IMSI */ /* Return any authorization error, otherwise get the IMSI */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -316,17 +310,14 @@ send_pin_puk_info_new (const char *puk,
/*****************************************************************************/ /*****************************************************************************/
static void static void
send_puk_auth_cb (GObject *instance, send_puk_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data; SendPinPukInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise send the PUK */ /* Return any authorization error, otherwise send the PUK */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -359,17 +350,14 @@ impl_gsm_modem_send_puk (MMModemGsmCard *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
send_pin_auth_cb (GObject *instance, send_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data; SendPinPukInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise unlock the modem */ /* Return any authorization error, otherwise unlock the modem */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -401,17 +389,14 @@ impl_gsm_modem_send_pin (MMModemGsmCard *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
enable_pin_auth_cb (GObject *instance, enable_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data; SendPinPukInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise enable the PIN */ /* Return any authorization error, otherwise enable the PIN */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -444,17 +429,14 @@ impl_gsm_modem_enable_pin (MMModemGsmCard *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
change_pin_auth_cb (GObject *instance, change_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance); MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data; SendPinPukInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise change the PIN */ /* Return any authorization error, otherwise change the PIN */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else

View File

@@ -398,17 +398,14 @@ impl_gsm_modem_register (MMModemGsmNetwork *modem,
} }
static void static void
scan_auth_cb (GObject *instance, scan_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmNetwork *self = MM_MODEM_GSM_NETWORK (instance); MMModemGsmNetwork *self = MM_MODEM_GSM_NETWORK (owner);
DBusGMethodInvocation *context = user_data; DBusGMethodInvocation *context = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise get the IMEI */ /* Return any authorization error, otherwise get the IMEI */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error); g_error_free (error);
} else } else

View File

@@ -207,17 +207,14 @@ sms_auth_info_new (guint num1,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_delete_auth_cb (GObject *instance, sms_delete_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -249,17 +246,14 @@ impl_gsm_modem_sms_delete (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_get_auth_cb (GObject *instance, sms_get_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -315,17 +309,14 @@ impl_gsm_modem_sms_get_smsc (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_set_smsc_auth_cb (GObject *instance, sms_set_smsc_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -357,17 +348,14 @@ impl_gsm_modem_sms_set_smsc (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_list_auth_cb (GObject *instance, sms_list_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -398,17 +386,14 @@ impl_gsm_modem_sms_list (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_save_auth_cb (GObject *instance, sms_save_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -440,12 +425,9 @@ impl_gsm_modem_sms_save (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_send_auth_cb (GObject *instance, sms_send_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
GValue *value; GValue *value;
@@ -456,7 +438,7 @@ sms_send_auth_cb (GObject *instance,
guint class = 0; guint class = 0;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) if (!mm_modem_auth_finish (MM_MODEM (self), req, &error))
goto done; goto done;
value = (GValue *) g_hash_table_lookup (info->hash, "number"); value = (GValue *) g_hash_table_lookup (info->hash, "number");
@@ -520,17 +502,14 @@ impl_gsm_modem_sms_send (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_send_from_storage_auth_cb (GObject *instance, sms_send_from_storage_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else
@@ -562,17 +541,14 @@ impl_gsm_modem_sms_send_from_storage (MMModemGsmSms *modem,
/*****************************************************************************/ /*****************************************************************************/
static void static void
sms_set_indication_auth_cb (GObject *instance, sms_set_indication_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
guint32 reqid,
MMAuthResult result,
gpointer user_data)
{ {
MMModemGsmSms *self = MM_MODEM_GSM_SMS (instance); MMModemGsmSms *self = MM_MODEM_GSM_SMS (owner);
SmsAuthInfo *info = user_data; SmsAuthInfo *info = user_data;
GError *error = NULL; GError *error = NULL;
/* Return any authorization error, otherwise delete the SMS */ /* Return any authorization error, otherwise delete the SMS */
if (!mm_modem_auth_finish (MM_MODEM (self), reqid, result, &error)) { if (!mm_modem_auth_finish (MM_MODEM (self), req, &error)) {
dbus_g_method_return_error (info->context, error); dbus_g_method_return_error (info->context, error);
g_error_free (error); g_error_free (error);
} else } else

View File

@@ -632,18 +632,17 @@ mm_modem_auth_request (MMModem *self,
gboolean gboolean
mm_modem_auth_finish (MMModem *self, mm_modem_auth_finish (MMModem *self,
guint32 reqid, MMAuthRequest *req,
MMAuthResult result,
GError **error) GError **error)
{ {
gboolean success; gboolean success;
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (MM_IS_MODEM (self), FALSE); g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
g_return_val_if_fail (reqid > 0, FALSE); g_return_val_if_fail (req != NULL, FALSE);
g_return_val_if_fail (MM_MODEM_GET_INTERFACE (self)->auth_finish, FALSE); g_return_val_if_fail (MM_MODEM_GET_INTERFACE (self)->auth_finish, FALSE);
success = MM_MODEM_GET_INTERFACE (self)->auth_finish (self, reqid, result, error); success = MM_MODEM_GET_INTERFACE (self)->auth_finish (self, req, error);
/* If the request failed, the implementor *should* return an error */ /* If the request failed, the implementor *should* return an error */
if (!success && error) if (!success && error)

View File

@@ -168,8 +168,7 @@ struct _MMModem {
GError **error); GError **error);
gboolean (*auth_finish) (MMModem *self, gboolean (*auth_finish) (MMModem *self,
guint32 reqid, MMAuthRequest *req,
MMAuthResult result,
GError **error); GError **error);
/* Signals */ /* Signals */
@@ -245,8 +244,7 @@ gboolean mm_modem_auth_request (MMModem *self,
GError **error); GError **error);
gboolean mm_modem_auth_finish (MMModem *self, gboolean mm_modem_auth_finish (MMModem *self,
guint32 reqid, MMAuthRequest *req,
MMAuthResult result,
GError **error); GError **error);
#endif /* MM_MODEM_H */ #endif /* MM_MODEM_H */