From c0b9663101092257873410d92e2c02219d109353 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 20 Nov 2013 17:10:40 -0500 Subject: Be consistent in the constness of arguments in storage virtual methods We usually don't pass const objects Bug: https://bugs.freedesktop.org/show_bug.cgi?id=27727 --- mission-control-plugins/account-storage.c | 48 +++++++-------- mission-control-plugins/account-storage.h | 97 +++++++++++++++---------------- src/mcd-account-manager-default.c | 12 ++-- src/mcd-storage.c | 4 +- tests/twisted/dbus-account-plugin.c | 22 +++---- tests/twisted/mcp-account-diversion.c | 16 ++--- 6 files changed, 98 insertions(+), 101 deletions(-) diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c index e30bb51e..288df077 100644 --- a/mission-control-plugins/account-storage.c +++ b/mission-control-plugins/account-storage.c @@ -133,16 +133,16 @@ default_delete_finish (McpAccountStorage *storage, } static gboolean -default_commit (const McpAccountStorage *storage, - const McpAccountManager *am, +default_commit (McpAccountStorage *storage, + McpAccountManager *am, const gchar *account) { return FALSE; } static gchar * -default_create (const McpAccountStorage *storage, - const McpAccountManager *am, +default_create (McpAccountStorage *storage, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, @@ -154,14 +154,14 @@ default_create (const McpAccountStorage *storage, } static void -default_ready (const McpAccountStorage *storage, - const McpAccountManager *am) +default_ready (McpAccountStorage *storage, + McpAccountManager *am) { /* do nothing */ } static void -default_get_identifier (const McpAccountStorage *storage, +default_get_identifier (McpAccountStorage *storage, const gchar *account, GValue *identifier) { @@ -170,14 +170,14 @@ default_get_identifier (const McpAccountStorage *storage, } static GHashTable * -default_get_additional_info (const McpAccountStorage *storage, +default_get_additional_info (McpAccountStorage *storage, const gchar *account) { return g_hash_table_new (g_str_hash, g_str_equal); } static TpStorageRestrictionFlags -default_get_restrictions (const McpAccountStorage *storage, +default_get_restrictions (McpAccountStorage *storage, const gchar *account) { return 0; @@ -417,7 +417,7 @@ mcp_account_storage_get_type (void) * Returns: the priority of this plugin **/ gint -mcp_account_storage_priority (const McpAccountStorage *storage) +mcp_account_storage_priority (McpAccountStorage *storage) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -657,8 +657,8 @@ mcp_account_storage_set_parameter (McpAccountStorage *storage, * be done. */ gchar * -mcp_account_storage_create (const McpAccountStorage *storage, - const McpAccountManager *am, +mcp_account_storage_create (McpAccountStorage *storage, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, @@ -774,8 +774,8 @@ mcp_account_storage_delete_finish (McpAccountStorage *storage, * obvious. */ gboolean -mcp_account_storage_commit (const McpAccountStorage *storage, - const McpAccountManager *am, +mcp_account_storage_commit (McpAccountStorage *storage, + McpAccountManager *am, const gchar *account) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -817,8 +817,8 @@ mcp_account_storage_commit (const McpAccountStorage *storage, * them. */ GList * -mcp_account_storage_list (const McpAccountStorage *storage, - const McpAccountManager *am) +mcp_account_storage_list (McpAccountStorage *storage, + McpAccountManager *am) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -851,8 +851,8 @@ mcp_account_storage_list (const McpAccountStorage *storage, * "deleted". */ void -mcp_account_storage_ready (const McpAccountStorage *storage, - const McpAccountManager *am) +mcp_account_storage_ready (McpAccountStorage *storage, + McpAccountManager *am) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -889,7 +889,7 @@ mcp_account_storage_ready (const McpAccountStorage *storage, * the account. */ void -mcp_account_storage_get_identifier (const McpAccountStorage *storage, +mcp_account_storage_get_identifier (McpAccountStorage *storage, const gchar *account, GValue *identifier) { @@ -932,7 +932,7 @@ mcp_account_storage_get_identifier (const McpAccountStorage *storage, * storage-specific information, which must not be %NULL */ GHashTable * -mcp_account_storage_get_additional_info (const McpAccountStorage *storage, +mcp_account_storage_get_additional_info (McpAccountStorage *storage, const gchar *account) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -968,7 +968,7 @@ mcp_account_storage_get_additional_info (const McpAccountStorage *storage, * account storage. */ TpStorageRestrictionFlags -mcp_account_storage_get_restrictions (const McpAccountStorage *storage, +mcp_account_storage_get_restrictions (McpAccountStorage *storage, const gchar *account) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -989,7 +989,7 @@ mcp_account_storage_get_restrictions (const McpAccountStorage *storage, * Returns: the plugin's name (for logging etc) */ const gchar * -mcp_account_storage_name (const McpAccountStorage *storage) +mcp_account_storage_name (McpAccountStorage *storage) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -1007,7 +1007,7 @@ mcp_account_storage_name (const McpAccountStorage *storage) * Returns: the plugin's description (for logging etc) */ const gchar * -mcp_account_storage_description (const McpAccountStorage *storage) +mcp_account_storage_description (McpAccountStorage *storage) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); @@ -1026,7 +1026,7 @@ mcp_account_storage_description (const McpAccountStorage *storage) * was provided in #McpAccountStorageIface.provider. */ const gchar * -mcp_account_storage_provider (const McpAccountStorage *storage) +mcp_account_storage_provider (McpAccountStorage *storage) { McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); diff --git a/mission-control-plugins/account-storage.h b/mission-control-plugins/account-storage.h index 1e4c5873..356642f6 100644 --- a/mission-control-plugins/account-storage.h +++ b/mission-control-plugins/account-storage.h @@ -63,38 +63,15 @@ struct _McpAccountStorage { }; GType mcp_account_storage_get_type (void); -/* Virtual method implementation signatures */ typedef gchar * (*McpAccountStorageCreate) ( - const McpAccountStorage *storage, - const McpAccountManager *am, + McpAccountStorage *storage, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, GError **error); -typedef gboolean (*McpAccountStorageDeleteFunc) ( - const McpAccountStorage *storage, - const McpAccountManager *am, - const gchar *account, - const gchar *key); -typedef GList * (*McpAccountStorageListFunc) ( - const McpAccountStorage *storage, - const McpAccountManager *am); -typedef gboolean (*McpAccountStorageCommitFunc) ( - const McpAccountStorage *storage, - const McpAccountManager *am, - const gchar *account); -typedef void (*McpAccountStorageReadyFunc) ( - const McpAccountStorage *storage, - const McpAccountManager *am); -typedef void (*McpAccountStorageGetIdentifierFunc) ( - const McpAccountStorage *storage, - const gchar *account, - GValue *identifier); -typedef GHashTable * (*McpAccountStorageGetAdditionalInfoFunc) ( - const McpAccountStorage *storage, - const gchar *account); typedef TpStorageRestrictionFlags (*McpAccountStorageGetRestrictionsFunc) ( - const McpAccountStorage *storage, + McpAccountStorage *storage, const gchar *account); struct _McpAccountStorageIface @@ -115,15 +92,34 @@ struct _McpAccountStorageIface gboolean (*delete_finish) (McpAccountStorage *storage, GAsyncResult *res, GError **error); - McpAccountStorageCommitFunc commit; - McpAccountStorageListFunc list; - McpAccountStorageReadyFunc ready; - McpAccountStorageGetIdentifierFunc get_identifier; - McpAccountStorageGetAdditionalInfoFunc get_additional_info; - McpAccountStorageGetRestrictionsFunc get_restrictions; - McpAccountStorageCreate create; - - /* Since 5.15.0 */ + + gboolean (*commit) (McpAccountStorage *storage, + McpAccountManager *am, + const gchar *account); + + GList * (*list) (McpAccountStorage *storage, + McpAccountManager *am); + + void (*ready) (McpAccountStorage *storage, + McpAccountManager *am); + + void (*get_identifier) (McpAccountStorage *storage, + const gchar *account, + GValue *identifier); + + GHashTable * (*get_additional_info) (McpAccountStorage *storage, + const gchar *account); + + TpStorageRestrictionFlags (*get_restrictions) (McpAccountStorage *storage, + const gchar *account); + + gchar * (*create) (McpAccountStorage *storage, + McpAccountManager *am, + const gchar *manager, + const gchar *protocol, + const gchar *identification, + GError **error); + GVariant *(*get_attribute) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, @@ -136,6 +132,7 @@ struct _McpAccountStorageIface const gchar *parameter, const GVariantType *type, McpParameterFlags *flags); + McpAccountStorageSetResult (*set_attribute) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, @@ -151,10 +148,10 @@ struct _McpAccountStorageIface }; /* virtual methods */ -gint mcp_account_storage_priority (const McpAccountStorage *storage); +gint mcp_account_storage_priority (McpAccountStorage *storage); -gchar * mcp_account_storage_create (const McpAccountStorage *storage, - const McpAccountManager *am, +gchar * mcp_account_storage_create (McpAccountStorage *storage, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, @@ -170,33 +167,33 @@ gboolean mcp_account_storage_delete_finish (McpAccountStorage *storage, GAsyncResult *result, GError **error); -void mcp_account_storage_ready (const McpAccountStorage *storage, - const McpAccountManager *am); +void mcp_account_storage_ready (McpAccountStorage *storage, + McpAccountManager *am); gboolean -mcp_account_storage_commit (const McpAccountStorage *storage, - const McpAccountManager *am, +mcp_account_storage_commit (McpAccountStorage *storage, + McpAccountManager *am, const gchar *account); -GList *mcp_account_storage_list (const McpAccountStorage *storage, - const McpAccountManager *am); +GList *mcp_account_storage_list (McpAccountStorage *storage, + McpAccountManager *am); -void mcp_account_storage_get_identifier (const McpAccountStorage *storage, +void mcp_account_storage_get_identifier (McpAccountStorage *storage, const gchar *account, GValue *identifier); GHashTable *mcp_account_storage_get_additional_info ( - const McpAccountStorage *storage, + McpAccountStorage *storage, const gchar *account); TpStorageRestrictionFlags mcp_account_storage_get_restrictions ( - const McpAccountStorage *storage, + McpAccountStorage *storage, const gchar *account); -const gchar *mcp_account_storage_name (const McpAccountStorage *storage); +const gchar *mcp_account_storage_name (McpAccountStorage *storage); -const gchar *mcp_account_storage_description (const McpAccountStorage *storage); -const gchar *mcp_account_storage_provider (const McpAccountStorage *storage); +const gchar *mcp_account_storage_description (McpAccountStorage *storage); +const gchar *mcp_account_storage_provider (McpAccountStorage *storage); GVariant *mcp_account_storage_get_attribute (McpAccountStorage *storage, McpAccountManager *am, diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c index efcb19f4..b79b6bba 100644 --- a/src/mcd-account-manager-default.c +++ b/src/mcd-account-manager-default.c @@ -326,8 +326,8 @@ get_parameter (McpAccountStorage *self, } static gchar * -_create (const McpAccountStorage *self, - const McpAccountManager *am, +_create (McpAccountStorage *self, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, @@ -520,8 +520,8 @@ am_default_commit_one (McdAccountManagerDefault *self, } static gboolean -_commit (const McpAccountStorage *self, - const McpAccountManager *am, +_commit (McpAccountStorage *self, + McpAccountManager *am, const gchar *account) { McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); @@ -819,8 +819,8 @@ am_default_load_directory (McdAccountManagerDefault *self, } static GList * -_list (const McpAccountStorage *self, - const McpAccountManager *am) +_list (McpAccountStorage *self, + McpAccountManager *am) { GList *rval = NULL; McdAccountManagerDefault *amd = MCD_ACCOUNT_MANAGER_DEFAULT (self); diff --git a/src/mcd-storage.c b/src/mcd-storage.c index cbca24e2..828d5a1b 100644 --- a/src/mcd-storage.c +++ b/src/mcd-storage.c @@ -409,8 +409,8 @@ identify_account_async (McpAccountManager *mcpa, static gint account_storage_cmp (gconstpointer a, gconstpointer b) { - gint pa = mcp_account_storage_priority (a); - gint pb = mcp_account_storage_priority (b); + gint pa = mcp_account_storage_priority ((McpAccountStorage *) a); + gint pb = mcp_account_storage_priority ((McpAccountStorage *) b); if (pa > pb) return -1; if (pa < pb) return 1; diff --git a/tests/twisted/dbus-account-plugin.c b/tests/twisted/dbus-account-plugin.c index 2e66179e..446a2ad7 100644 --- a/tests/twisted/dbus-account-plugin.c +++ b/tests/twisted/dbus-account-plugin.c @@ -748,8 +748,8 @@ parameters_changed_cb (GDBusConnection *bus, } static GList * -test_dbus_account_plugin_list (const McpAccountStorage *storage, - const McpAccountManager *am) +test_dbus_account_plugin_list (McpAccountStorage *storage, + McpAccountManager *am) { TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); GError *error = NULL; @@ -858,8 +858,8 @@ test_dbus_account_plugin_list (const McpAccountStorage *storage, } static void -test_dbus_account_plugin_ready (const McpAccountStorage *storage, - const McpAccountManager *am) +test_dbus_account_plugin_ready (McpAccountStorage *storage, + McpAccountManager *am) { TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); @@ -873,8 +873,8 @@ test_dbus_account_plugin_ready (const McpAccountStorage *storage, } static gchar * -test_dbus_account_plugin_create (const McpAccountStorage *storage, - const McpAccountManager *am, +test_dbus_account_plugin_create (McpAccountStorage *storage, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identifier, @@ -1286,8 +1286,8 @@ update_parameters_cb (GObject *source_object, } static gboolean -test_dbus_account_plugin_commit (const McpAccountStorage *storage, - const McpAccountManager *am, +test_dbus_account_plugin_commit (McpAccountStorage *storage, + McpAccountManager *am, const gchar *account_name) { TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); @@ -1436,7 +1436,7 @@ test_dbus_account_plugin_commit (const McpAccountStorage *storage, } static void -test_dbus_account_plugin_get_identifier (const McpAccountStorage *storage, +test_dbus_account_plugin_get_identifier (McpAccountStorage *storage, const gchar *account_name, GValue *identifier) { @@ -1455,7 +1455,7 @@ test_dbus_account_plugin_get_identifier (const McpAccountStorage *storage, } static GHashTable * -test_dbus_account_plugin_get_additional_info (const McpAccountStorage *storage, +test_dbus_account_plugin_get_additional_info (McpAccountStorage *storage, const gchar *account_name) { TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); @@ -1476,7 +1476,7 @@ test_dbus_account_plugin_get_additional_info (const McpAccountStorage *storage, } static guint -test_dbus_account_plugin_get_restrictions (const McpAccountStorage *storage, +test_dbus_account_plugin_get_restrictions (McpAccountStorage *storage, const gchar *account_name) { TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); diff --git a/tests/twisted/mcp-account-diversion.c b/tests/twisted/mcp-account-diversion.c index 02775b4c..466d3ee3 100644 --- a/tests/twisted/mcp-account-diversion.c +++ b/tests/twisted/mcp-account-diversion.c @@ -250,8 +250,8 @@ _get_parameter (McpAccountStorage *self, return ret; } -static gboolean _commit (const McpAccountStorage *self, - const McpAccountManager *am, +static gboolean _commit (McpAccountStorage *self, + McpAccountManager *am, const gchar *account_name); static void @@ -292,8 +292,8 @@ delete_finish (McpAccountStorage *storage, } static gboolean -_commit (const McpAccountStorage *self, - const McpAccountManager *am, +_commit (McpAccountStorage *self, + McpAccountManager *am, const gchar *account_name G_GNUC_UNUSED) { gsize n; @@ -321,8 +321,8 @@ _commit (const McpAccountStorage *self, } static GList * -_list (const McpAccountStorage *self, - const McpAccountManager *am) +_list (McpAccountStorage *self, + McpAccountManager *am) { gsize i; gsize n; @@ -348,8 +348,8 @@ _list (const McpAccountStorage *self, } static gchar * -create (const McpAccountStorage *self, - const McpAccountManager *am, +create (McpAccountStorage *self, + McpAccountManager *am, const gchar *manager, const gchar *protocol, const gchar *identification, -- cgit v1.2.1