core: avoid using DBusGMethodInvocation in auth API
While porting to GDBus, use opaque pointers. This allows us to include either a DBusGMethodInvocation or a GDBusMethodInvocation in the 'context' pointer. Once fully ported to GDBus, we can safely change it back to make the context be a GDBusMethodInvocation.
This commit is contained in:

committed by
Aleksander Morgado

parent
1e79a2d292
commit
d47176a32c
@@ -55,20 +55,33 @@ static MMAuthRequest *
|
||||
real_create_request (MMAuthProvider *provider,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MMAuthProviderPolkitPrivate *priv = MM_AUTH_PROVIDER_POLKIT_GET_PRIVATE (provider);
|
||||
MMAuthRequest *auth_request;
|
||||
gchar *sender;
|
||||
|
||||
return (MMAuthRequest *) mm_auth_request_polkit_new (priv->authority,
|
||||
/* Ugly temporary hack... */
|
||||
if (G_IS_DBUS_METHOD_INVOCATION (context)) {
|
||||
sender = g_strdup (g_dbus_method_invocation_get_sender (context));
|
||||
} else {
|
||||
sender = dbus_g_method_get_sender (context);
|
||||
}
|
||||
|
||||
auth_request = (MMAuthRequest *)mm_auth_request_polkit_new (priv->authority,
|
||||
authorization,
|
||||
owner,
|
||||
context,
|
||||
sender,
|
||||
callback,
|
||||
callback_data,
|
||||
notify);
|
||||
g_free (sender);
|
||||
|
||||
return auth_request;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@@ -105,7 +105,7 @@ static MMAuthRequest *
|
||||
real_create_request (MMAuthProvider *provider,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify)
|
||||
@@ -165,7 +165,7 @@ MMAuthRequest *
|
||||
mm_auth_provider_request_auth (MMAuthProvider *self,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify,
|
||||
|
@@ -52,7 +52,7 @@ typedef struct {
|
||||
MMAuthRequest * (*create_request) (MMAuthProvider *provider,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify);
|
||||
@@ -64,7 +64,7 @@ GType mm_auth_provider_get_type (void);
|
||||
MMAuthRequest *mm_auth_provider_request_auth (MMAuthProvider *provider,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify,
|
||||
|
@@ -34,14 +34,14 @@ GObject *
|
||||
mm_auth_request_polkit_new (PolkitAuthority *authority,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
const gchar *sender,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
GObject *obj;
|
||||
MMAuthRequestPolkitPrivate *priv;
|
||||
char *sender;
|
||||
|
||||
g_return_val_if_fail (authorization != NULL, NULL);
|
||||
g_return_val_if_fail (owner != NULL, NULL);
|
||||
@@ -59,10 +59,7 @@ mm_auth_request_polkit_new (PolkitAuthority *authority,
|
||||
priv = MM_AUTH_REQUEST_POLKIT_GET_PRIVATE (obj);
|
||||
priv->authority = authority;
|
||||
priv->cancellable = g_cancellable_new ();
|
||||
|
||||
sender = dbus_g_method_get_sender (context);
|
||||
priv->subject = polkit_system_bus_name_new (sender);
|
||||
g_free (sender);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
@@ -42,7 +42,8 @@ GType mm_auth_request_polkit_get_type (void);
|
||||
GObject *mm_auth_request_polkit_new (PolkitAuthority *authority,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
const gchar *sender,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify);
|
||||
|
@@ -22,7 +22,7 @@ G_DEFINE_TYPE (MMAuthRequest, mm_auth_request, G_TYPE_OBJECT)
|
||||
typedef struct {
|
||||
GObject *owner;
|
||||
char *auth;
|
||||
DBusGMethodInvocation *context;
|
||||
gpointer context;
|
||||
MMAuthRequestCb callback;
|
||||
gpointer callback_data;
|
||||
|
||||
@@ -35,7 +35,7 @@ GObject *
|
||||
mm_auth_request_new (GType atype,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify)
|
||||
|
@@ -47,15 +47,18 @@ typedef struct {
|
||||
|
||||
GType mm_auth_request_get_type (void);
|
||||
|
||||
/* TODO: Change the context gpointer to be a GDBusMethodInvocation when
|
||||
* fully ported to GDBus, and remove all (MMAuthRequestCb) casts */
|
||||
|
||||
typedef void (*MMAuthRequestCb) (MMAuthRequest *req,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
gpointer user_data);
|
||||
|
||||
GObject *mm_auth_request_new (GType atype,
|
||||
const char *authorization,
|
||||
GObject *owner,
|
||||
DBusGMethodInvocation *context,
|
||||
gpointer context,
|
||||
MMAuthRequestCb callback,
|
||||
gpointer callback_data,
|
||||
GDestroyNotify notify);
|
||||
|
@@ -1023,7 +1023,7 @@ impl_manager_scan_devices (MMManager *manager,
|
||||
MM_AUTHORIZATION_MANAGER_CONTROL,
|
||||
G_OBJECT (manager),
|
||||
context,
|
||||
scan_devices_auth_cb,
|
||||
(MMAuthRequestCb)scan_devices_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
|
@@ -219,7 +219,7 @@ impl_modem_cdma_get_esn (MMModemCdma *self, DBusGMethodInvocation *context)
|
||||
if (!mm_modem_auth_request (MM_MODEM (self),
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
esn_auth_cb,
|
||||
(MMAuthRequestCb)esn_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
|
@@ -195,7 +195,7 @@ impl_modem_firmware_list (MMModemFirmware *modem, DBusGMethodInvocation *context
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_FIRMWARE,
|
||||
context,
|
||||
firmware_list_auth_cb,
|
||||
(MMAuthRequestCb)firmware_list_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -235,7 +235,7 @@ impl_modem_firmware_select (MMModemFirmware *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_FIRMWARE,
|
||||
context,
|
||||
firmware_select_auth_cb,
|
||||
(MMAuthRequestCb)firmware_select_auth_cb,
|
||||
info,
|
||||
firmware_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -277,7 +277,7 @@ impl_modem_firmware_install (MMModemFirmware *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_FIRMWARE,
|
||||
context,
|
||||
firmware_install_auth_cb,
|
||||
(MMAuthRequestCb)firmware_install_auth_cb,
|
||||
info,
|
||||
firmware_auth_info_destroy,
|
||||
&error)) {
|
||||
|
@@ -288,7 +288,7 @@ impl_gsm_modem_get_imei (MMModemGsmCard *modem, DBusGMethodInvocation *context)
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
imei_auth_cb,
|
||||
(MMAuthRequestCb)imei_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -325,7 +325,7 @@ impl_gsm_modem_get_imsi (MMModemGsmCard *modem, DBusGMethodInvocation *context)
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
imsi_auth_cb,
|
||||
(MMAuthRequestCb)imsi_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -362,7 +362,7 @@ impl_gsm_modem_get_spn (MMModemGsmCard *modem, DBusGMethodInvocation *context)
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
spn_auth_cb,
|
||||
(MMAuthRequestCb)spn_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -399,7 +399,7 @@ impl_gsm_modem_get_operator_id (MMModemGsmCard *modem, DBusGMethodInvocation *co
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
operator_id_auth_cb,
|
||||
(MMAuthRequestCb)operator_id_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -480,7 +480,7 @@ impl_gsm_modem_send_puk (MMModemGsmCard *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
send_puk_auth_cb,
|
||||
(MMAuthRequestCb)send_puk_auth_cb,
|
||||
info,
|
||||
send_pin_puk_info_destroy,
|
||||
&error)) {
|
||||
@@ -523,7 +523,7 @@ impl_gsm_modem_send_pin (MMModemGsmCard *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
send_pin_auth_cb,
|
||||
(MMAuthRequestCb)send_pin_auth_cb,
|
||||
info,
|
||||
send_pin_puk_info_destroy,
|
||||
&error)) {
|
||||
@@ -567,7 +567,7 @@ impl_gsm_modem_enable_pin (MMModemGsmCard *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
enable_pin_auth_cb,
|
||||
(MMAuthRequestCb)enable_pin_auth_cb,
|
||||
info,
|
||||
send_pin_puk_info_destroy,
|
||||
&error)) {
|
||||
@@ -611,7 +611,7 @@ impl_gsm_modem_change_pin (MMModemGsmCard *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
change_pin_auth_cb,
|
||||
(MMAuthRequestCb)change_pin_auth_cb,
|
||||
info,
|
||||
send_pin_puk_info_destroy,
|
||||
&error)) {
|
||||
|
@@ -452,7 +452,7 @@ impl_gsm_modem_scan (MMModemGsmNetwork *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
scan_auth_cb,
|
||||
(MMAuthRequestCb)scan_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
|
@@ -389,7 +389,7 @@ impl_gsm_modem_sms_delete (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_delete_auth_cb,
|
||||
(MMAuthRequestCb)sms_delete_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -435,7 +435,7 @@ impl_gsm_modem_sms_get (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_get_auth_cb,
|
||||
(MMAuthRequestCb)sms_get_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -501,7 +501,7 @@ impl_gsm_modem_sms_set_smsc (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_set_smsc_auth_cb,
|
||||
(MMAuthRequestCb)sms_set_smsc_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -539,7 +539,7 @@ impl_gsm_modem_sms_list (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_list_auth_cb,
|
||||
(MMAuthRequestCb)sms_list_auth_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
@@ -581,7 +581,7 @@ impl_gsm_modem_sms_save (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_save_auth_cb,
|
||||
(MMAuthRequestCb)sms_save_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -676,7 +676,7 @@ impl_gsm_modem_sms_send (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_send_auth_cb,
|
||||
(MMAuthRequestCb)sms_send_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -718,7 +718,7 @@ impl_gsm_modem_sms_send_from_storage (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_send_from_storage_auth_cb,
|
||||
(MMAuthRequestCb)sms_send_from_storage_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -764,7 +764,7 @@ impl_gsm_modem_sms_set_indication (MMModemGsmSms *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_SMS,
|
||||
context,
|
||||
sms_set_indication_auth_cb,
|
||||
(MMAuthRequestCb)sms_set_indication_auth_cb,
|
||||
info,
|
||||
sms_auth_info_destroy,
|
||||
&error)) {
|
||||
|
@@ -232,7 +232,7 @@ impl_modem_gsm_ussd_initiate (MMModemGsmUssd *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_USSD,
|
||||
context,
|
||||
ussd_initiate_auth_cb,
|
||||
(MMAuthRequestCb)ussd_initiate_auth_cb,
|
||||
info,
|
||||
ussd_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -282,7 +282,7 @@ impl_modem_gsm_ussd_respond (MMModemGsmUssd *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_USSD,
|
||||
context,
|
||||
ussd_respond_auth_cb,
|
||||
(MMAuthRequestCb)ussd_respond_auth_cb,
|
||||
info,
|
||||
ussd_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -323,7 +323,7 @@ impl_modem_gsm_ussd_cancel (MMModemGsmUssd *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_USSD,
|
||||
context,
|
||||
ussd_cancel_auth_cb,
|
||||
(MMAuthRequestCb)ussd_cancel_auth_cb,
|
||||
info,
|
||||
ussd_auth_info_destroy,
|
||||
&error)) {
|
||||
|
@@ -137,7 +137,7 @@ impl_modem_location_enable (MMModemLocation *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_LOCATION,
|
||||
context,
|
||||
loc_enable_auth_cb,
|
||||
(MMAuthRequestCb)loc_enable_auth_cb,
|
||||
info,
|
||||
loc_auth_info_destroy,
|
||||
&error)) {
|
||||
@@ -232,7 +232,7 @@ impl_modem_location_get_location (MMModemLocation *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_LOCATION,
|
||||
context,
|
||||
loc_get_auth_cb,
|
||||
(MMAuthRequestCb)loc_get_auth_cb,
|
||||
info,
|
||||
loc_auth_info_destroy,
|
||||
&error)) {
|
||||
|
@@ -491,7 +491,7 @@ impl_modem_reset (MMModem *modem, DBusGMethodInvocation *context)
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
reset_auth_cb,
|
||||
(MMAuthRequestCb)reset_auth_cb,
|
||||
NULL, NULL,
|
||||
&error)) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
@@ -544,7 +544,7 @@ impl_modem_factory_reset (MMModem *modem,
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
factory_reset_auth_cb,
|
||||
(MMAuthRequestCb)factory_reset_auth_cb,
|
||||
g_strdup (code),
|
||||
g_free,
|
||||
&error)) {
|
||||
|
Reference in New Issue
Block a user