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 \
mm-callback-info.c \
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.h \
mm-modem.c \
@@ -71,13 +76,12 @@ modem_manager_SOURCES = \
mm-plugin-base.c \
mm-plugin-base.h \
mm-properties-changed-signal.c \
mm-properties-changed-signal.h \
mm-auth-provider.h \
mm-auth-provider.c \
mm-auth-provider-factory.c
mm-properties-changed-signal.h
if WITH_POLKIT
modem_manager_SOURCES += \
mm-auth-request-polkit.c \
mm-auth-request-polkit.h \
mm-auth-provider-polkit.c \
mm-auth-provider-polkit.h
endif

View File

@@ -35,14 +35,6 @@ enum {
LAST_PROP
};
enum {
REQUEST_ADDED,
REQUEST_REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/*****************************************************************************/
GObject *
@@ -53,101 +45,19 @@ mm_auth_provider_new (void)
/*****************************************************************************/
struct MMAuthRequest {
guint32 refcount;
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 void
remove_requests (MMAuthProvider *self, GSList *remove)
{
static guint32 id = 1;
MMAuthProviderPrivate *priv = MM_AUTH_PROVIDER_GET_PRIVATE (self);
MMAuthRequest *req;
g_return_val_if_fail (authorization != NULL, NULL);
g_return_val_if_fail (callback != NULL, NULL);
req = g_malloc0 (sizeof (MMAuthRequest));
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);
while (remove) {
req = MM_AUTH_REQUEST (remove->data);
g_hash_table_remove (priv->requests, req);
remove = g_slist_remove (remove, 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
process_complete_requests (gpointer user_data)
{
@@ -163,92 +73,78 @@ process_complete_requests (gpointer user_data)
/* Call finished request's callbacks */
g_hash_table_iter_init (&iter, priv->requests);
while (g_hash_table_iter_next (&iter, NULL, &value)) {
req = (MMAuthRequest *) 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);
req = MM_AUTH_REQUEST (value);
if (mm_auth_request_get_authorization (req) != MM_AUTH_RESULT_UNKNOWN) {
mm_auth_request_complete (req);
remove = g_slist_prepend (remove, req);
}
}
/* And remove those requests from our pending request list */
while (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);
}
remove_requests (self, remove);
return FALSE;
}
void
mm_auth_provider_finish_request (MMAuthProvider *provider,
guint32 reqid,
MMAuthRequest *req,
MMAuthResult result)
{
MMAuthProviderPrivate *priv;
MMAuthRequest *req;
g_return_if_fail (provider != NULL);
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);
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);
req->result = result;
g_return_if_fail (g_hash_table_lookup (priv->requests, req) != NULL);
mm_auth_request_set_result (req, result);
if (priv->process_id == 0)
priv->process_id = g_idle_add (process_complete_requests, provider);
}
void
mm_auth_provider_cancel_request (MMAuthProvider *provider, guint32 reqid)
mm_auth_provider_cancel_request (MMAuthProvider *provider, MMAuthRequest *req)
{
MMAuthProviderPrivate *priv;
MMAuthRequest *req;
g_return_if_fail (provider != NULL);
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);
/* Let the caller clean up the request's callback data */
if (req->notify)
req->notify (req->callback_data);
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
/* We don't signal removal here as it's assumed the caller
* handles that itself instead of by the signal.
*/
g_hash_table_remove (priv->requests, GUINT_TO_POINTER (reqid));
g_return_if_fail (g_hash_table_lookup (priv->requests, req) != NULL);
g_hash_table_remove (priv->requests, req);
}
const char *
mm_auth_provider_get_authorization_for_id (MMAuthProvider *provider, guint32 reqid)
void
mm_auth_provider_cancel_for_owner (MMAuthProvider *self, GObject *owner)
{
MMAuthProviderPrivate *priv;
GHashTableIter iter;
MMAuthRequest *req;
gpointer value;
GSList *remove = NULL;
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);
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_AUTH_PROVIDER (self));
priv = MM_AUTH_PROVIDER_GET_PRIVATE (provider);
req = (MMAuthRequest *) g_hash_table_lookup (priv->requests, GUINT_TO_POINTER (reqid));
g_return_val_if_fail (req != NULL, NULL);
/* Find all requests from this owner */
priv = MM_AUTH_PROVIDER_GET_PRIVATE (self);
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)
{
/* This class provides null authentication; all requests pass */
mm_auth_provider_finish_request (provider,
mm_auth_request_get_id (req),
MM_AUTH_RESULT_AUTHORIZED);
mm_auth_provider_finish_request (provider, req, MM_AUTH_RESULT_AUTHORIZED);
return TRUE;
}
guint32
mm_auth_provider_request_auth (MMAuthProvider *provider,
static MMAuthRequest *
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,
GObject *instance,
GObject *owner,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify,
@@ -277,32 +182,29 @@ mm_auth_provider_request_auth (MMAuthProvider *provider,
MMAuthProviderPrivate *priv;
MMAuthRequest *req;
g_return_val_if_fail (provider != NULL, 0);
g_return_val_if_fail (MM_IS_AUTH_PROVIDER (provider), 0);
g_return_val_if_fail (self != NULL, 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 (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_hash_table_insert (priv->requests, GUINT_TO_POINTER (req->id), req);
g_signal_emit (provider, signals[REQUEST_ADDED], 0, instance, req->id);
if (!MM_AUTH_PROVIDER_GET_CLASS (provider)->request_auth (provider, req, error)) {
g_hash_table_insert (priv->requests, req, req);
if (!MM_AUTH_PROVIDER_GET_CLASS (self)->request_auth (self, req, error)) {
/* Error */
g_signal_emit (provider, signals[REQUEST_REMOVED], 0, instance, req->id);
/* 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;
g_hash_table_remove (priv->requests, req);
return NULL;
}
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,
g_direct_equal,
NULL,
(GDestroyNotify) mm_auth_request_unref);
(GDestroyNotify) g_object_unref);
}
static void
@@ -352,7 +254,7 @@ get_property (GObject *object,
}
static void
finalize (GObject *object)
dispose (GObject *object)
{
MMAuthProviderPrivate *priv = MM_AUTH_PROVIDER_GET_PRIVATE (object);
@@ -360,7 +262,7 @@ finalize (GObject *object)
g_source_remove (priv->process_id);
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
@@ -374,8 +276,9 @@ mm_auth_provider_class_init (MMAuthProviderClass *class)
/* Virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
object_class->dispose = dispose;
class->request_auth = real_request_auth;
class->create_request = real_create_request;
/* Properties */
g_object_class_install_property (object_class, PROP_NAME,
@@ -384,22 +287,5 @@ mm_auth_provider_class_init (MMAuthProviderClass *class)
"Provider name",
NULL_PROVIDER,
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 "mm-auth-request.h"
/* Authorizations */
#define MM_AUTHORIZATION_DEVICE "org.freedesktop.ModemManager.Device"
#define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts"
@@ -34,66 +36,47 @@
#define MM_AUTH_PROVIDER_NAME "name"
typedef enum MMAuthResult {
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 {
typedef struct {
GObject parent;
};
} MMAuthProvider;
struct _MMAuthProviderClass {
typedef struct {
GObjectClass parent;
gboolean (*request_auth) (MMAuthProvider *provider,
MMAuthRequest *req,
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);
guint32 mm_auth_provider_request_auth (MMAuthProvider *provider,
const char *authorization,
GObject *instance,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify,
GError **error);
MMAuthRequest *mm_auth_provider_request_auth (MMAuthProvider *provider,
const char *authorization,
GObject *owner,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify,
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 */
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 */
void mm_auth_provider_finish_request (MMAuthProvider *provider,
guint32 reqid,
MMAuthRequest *req,
MMAuthResult result);
void mm_auth_provider_cancel_request (MMAuthProvider *provider, guint32 reqid);
const char *mm_auth_provider_get_authorization_for_id (MMAuthProvider *provider,
guint32 reqid);
void mm_auth_provider_cancel_request (MMAuthProvider *provider, MMAuthRequest *req);
#endif /* MM_AUTH_PROVIDER_H */

View File

@@ -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);

View File

@@ -189,17 +189,14 @@ mm_modem_cdma_get_esn (MMModemCdma *self,
}
static void
esn_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
esn_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemCdma *self = MM_MODEM_CDMA (instance);
MMModemCdma *self = MM_MODEM_CDMA (owner);
DBusGMethodInvocation *context = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else

View File

@@ -202,17 +202,14 @@ mm_modem_gsm_card_change_pin (MMModemGsmCard *self,
/*****************************************************************************/
static void
imei_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
imei_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
DBusGMethodInvocation *context = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else
@@ -239,17 +236,14 @@ impl_gsm_modem_get_imei (MMModemGsmCard *modem, DBusGMethodInvocation *context)
/*****************************************************************************/
static void
imsi_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
imsi_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
DBusGMethodInvocation *context = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else
@@ -316,17 +310,14 @@ send_pin_puk_info_new (const char *puk,
/*****************************************************************************/
static void
send_puk_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
send_puk_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else
@@ -359,17 +350,14 @@ impl_gsm_modem_send_puk (MMModemGsmCard *modem,
/*****************************************************************************/
static void
send_pin_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
send_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else
@@ -401,17 +389,14 @@ impl_gsm_modem_send_pin (MMModemGsmCard *modem,
/*****************************************************************************/
static void
enable_pin_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
enable_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else
@@ -444,17 +429,14 @@ impl_gsm_modem_enable_pin (MMModemGsmCard *modem,
/*****************************************************************************/
static void
change_pin_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
change_pin_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmCard *self = MM_MODEM_GSM_CARD (instance);
MMModemGsmCard *self = MM_MODEM_GSM_CARD (owner);
SendPinPukInfo *info = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else

View File

@@ -398,17 +398,14 @@ impl_gsm_modem_register (MMModemGsmNetwork *modem,
}
static void
scan_auth_cb (GObject *instance,
guint32 reqid,
MMAuthResult result,
gpointer user_data)
scan_auth_cb (MMAuthRequest *req, GObject *owner, gpointer user_data)
{
MMModemGsmNetwork *self = MM_MODEM_GSM_NETWORK (instance);
MMModemGsmNetwork *self = MM_MODEM_GSM_NETWORK (owner);
DBusGMethodInvocation *context = user_data;
GError *error = NULL;
/* 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);
g_error_free (error);
} else

View File

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

View File

@@ -632,18 +632,17 @@ mm_modem_auth_request (MMModem *self,
gboolean
mm_modem_auth_finish (MMModem *self,
guint32 reqid,
MMAuthResult result,
MMAuthRequest *req,
GError **error)
{
gboolean success;
g_return_val_if_fail (self != NULL, 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);
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 (!success && error)

View File

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