From e2c959d61198c8fab378587a3b5e68c1296e2bb9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 26 Sep 2013 19:48:05 +0100 Subject: [PATCH 05/22] account: rename Valid to Usable Based on a patch by Jonny Lamb. --- src/mcd-account-connection.c | 2 +- src/mcd-account-manager.c | 87 ++++++----- src/mcd-account.c | 160 ++++++++++----------- src/mcd-account.h | 16 +-- tests/twisted/account-manager/account-basics.py | 19 ++- .../account-manager/backend-makes-changes.py | 4 +- .../account-manager/create-with-properties.py | 11 +- tests/twisted/account-manager/hidden.py | 24 ++-- tests/twisted/account-manager/make-valid.py | 2 +- tests/twisted/account-manager/param-types.py | 2 +- tests/twisted/account-manager/request-online.py | 6 +- .../account-storage/default-keyring-storage.py | 12 +- tests/twisted/account-storage/diverted-storage.py | 14 +- .../account-storage/libaccounts-sso-storage.py | 4 +- tests/twisted/mctest.py | 18 +-- util/mc-tool.c | 14 +- xml/Account_Manager_Interface_Hidden.xml | 34 ++--- 17 files changed, 215 insertions(+), 214 deletions(-) diff --git a/src/mcd-account-connection.c b/src/mcd-account-connection.c index 09b3a21..88ccc5c 100644 --- a/src/mcd-account-connection.c +++ b/src/mcd-account-connection.c @@ -68,7 +68,7 @@ _mcd_account_connection_begin (McdAccount *account, ctx = g_malloc (sizeof (McdAccountConnectionContext)); ctx->user_initiated = user_initiated; - /* If we get this far, the account should be valid, so getting the + /* If we get this far, the account should be usable, so getting the * parameters should succeed. */ ctx->params = _mcd_account_dup_parameters (account); diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index c326e19..7c34e67 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -213,10 +213,13 @@ altered_one_cb (GObject *storage, /* callbacks for the various stages in an backend-driven account creation */ static void -async_created_validity_cb (McdAccount *account, const GError *invalid_reason, gpointer data) +async_created_usability_cb (McdAccount *account, + const GError *unusable_reason, + gpointer data) { - DEBUG ("asynchronously created account %s is %svalid", - mcd_account_get_unique_name (account), (invalid_reason == NULL) ? "" : "in"); + DEBUG ("asynchronously created account %s is %susable", + mcd_account_get_unique_name (account), + (unusable_reason == NULL) ? "" : "un"); /* safely cached in the accounts hash by now */ g_object_unref (account); @@ -247,7 +250,7 @@ async_created_manager_cb (McdManager *cm, const GError *error, gpointer data) /* this triggers the final parameter check which results in dbus signals * * being fired and (potentially) the account going online automatically */ - mcd_account_check_validity (account, async_created_validity_cb, NULL); + mcd_account_check_usability (account, async_created_usability_cb, NULL); g_object_unref (cm); } @@ -551,8 +554,9 @@ list_connection_names_cb (const gchar * const *names, gsize n, } static void -on_account_validity_changed (McdAccount *account, gboolean valid, - McdAccountManager *account_manager) +on_account_usability_changed (McdAccount *account, + gboolean usable, + McdAccountManager *account_manager) { const gchar *object_path; @@ -560,14 +564,14 @@ on_account_validity_changed (McdAccount *account, gboolean valid, if (_mcd_account_is_hidden (account)) { - mc_svc_account_manager_interface_hidden_emit_hidden_account_validity_changed ( - account_manager, object_path, valid); + mc_svc_account_manager_interface_hidden_emit_hidden_account_usability_changed ( + account_manager, object_path, usable); } else { - tp_svc_account_manager_emit_account_validity_changed (account_manager, - object_path, - valid); + tp_svc_account_manager_emit_account_usability_changed (account_manager, + object_path, + usable); } } @@ -614,7 +618,7 @@ unref_account (gpointer data) DEBUG ("called for %s", mcd_account_get_unique_name (account)); - disconnect_signal (account, on_account_validity_changed); + disconnect_signal (account, on_account_usability_changed); disconnect_signal (account, on_account_removed); g_object_unref (account); @@ -645,8 +649,8 @@ add_account (McdAccountManager *account_manager, McdAccount *account, /* if we have to connect to any signals from the account object, this is * the place to do it */ - g_signal_connect (account, "validity-changed", - G_CALLBACK (on_account_validity_changed), + g_signal_connect (account, "usability-changed", + G_CALLBACK (on_account_usability_changed), account_manager); g_signal_connect (account, "removed", G_CALLBACK (on_account_removed), account_manager); @@ -657,11 +661,11 @@ add_account (McdAccountManager *account_manager, McdAccount *account, /* some reports indicate this doesn't always fire for async backend * * accounts: testing here hasn't shown this, but at least we will be * * able to tell if this happens from MC debug logs now: */ - DEBUG ("account %s validity: %d", name, mcd_account_is_valid (account)); - /* if the account is already valid, synthesize a signal indicating that + DEBUG ("account %s usability: %d", name, mcd_account_is_usable (account)); + /* if the account is already usable, synthesize a signal indicating that * it's been added */ - if (mcd_account_is_valid (account)) - on_account_validity_changed (account, TRUE, account_manager); + if (mcd_account_is_usable (account)) + on_account_usability_changed (account, TRUE, account_manager); } static void @@ -734,17 +738,17 @@ complete_account_creation_finish (McdAccount *account, } static void -complete_account_creation_check_validity_cb (McdAccount *account, - const GError *invalid_reason, +complete_account_creation_check_usability_cb (McdAccount *account, + const GError *unusable_reason, gpointer user_data) { McdCreateAccountData *cad = user_data; - if (invalid_reason != NULL) + if (unusable_reason != NULL) { cad->ok = FALSE; - g_set_error_literal (&cad->error, invalid_reason->domain, - invalid_reason->code, invalid_reason->message); + g_set_error_literal (&cad->error, unusable_reason->domain, + unusable_reason->code, unusable_reason->message); } complete_account_creation_finish (account, cad); @@ -775,7 +779,8 @@ complete_account_creation_set_cb (McdAccount *account, GPtrArray *not_yet, if (cad->ok) { add_account (account_manager, account, G_STRFUNC); - mcd_account_check_validity (account, complete_account_creation_check_validity_cb, cad); + mcd_account_check_usability (account, + complete_account_creation_check_usability_cb, cad); } else { @@ -936,7 +941,9 @@ account_manager_hidden_iface_init ( } static void -accounts_to_gvalue (GHashTable *accounts, gboolean valid, gboolean hidden, +accounts_to_gvalue (GHashTable *accounts, + gboolean usable, + gboolean hidden, GValue *value) { static GType ao_type = G_TYPE_INVALID; @@ -955,7 +962,7 @@ accounts_to_gvalue (GHashTable *accounts, gboolean valid, gboolean hidden, while (g_hash_table_iter_next (&iter, &k, (gpointer)&account)) { - if (mcd_account_is_valid (account) == valid && + if (mcd_account_is_usable (account) == usable && _mcd_account_is_hidden (account) == hidden) { g_ptr_array_add (account_array, @@ -968,8 +975,9 @@ accounts_to_gvalue (GHashTable *accounts, gboolean valid, gboolean hidden, } static void -get_valid_accounts (TpSvcDBusProperties *self, const gchar *name, - GValue *value) +get_usable_accounts (TpSvcDBusProperties *self, + const gchar *name, + GValue *value) { McdAccountManager *account_manager = MCD_ACCOUNT_MANAGER (self); McdAccountManagerPrivate *priv = account_manager->priv; @@ -979,8 +987,9 @@ get_valid_accounts (TpSvcDBusProperties *self, const gchar *name, } static void -get_invalid_accounts (TpSvcDBusProperties *self, const gchar *name, - GValue *value) +get_unusable_accounts (TpSvcDBusProperties *self, + const gchar *name, + GValue *value) { McdAccountManager *account_manager = MCD_ACCOUNT_MANAGER (self); McdAccountManagerPrivate *priv = account_manager->priv; @@ -1015,16 +1024,17 @@ get_supported_account_properties (TpSvcDBusProperties *svc, } static const McdDBusProp account_manager_properties[] = { - { "ValidAccounts", NULL, get_valid_accounts }, - { "InvalidAccounts", NULL, get_invalid_accounts }, + { "UsableAccounts", NULL, get_usable_accounts }, + { "UnusableAccounts", NULL, get_unusable_accounts }, { "Interfaces", NULL, mcd_dbus_get_interfaces }, { "SupportedAccountProperties", NULL, get_supported_account_properties }, { 0 }, }; static void -get_valid_hidden_accounts (TpSvcDBusProperties *self, const gchar *name, - GValue *value) +get_usable_hidden_accounts (TpSvcDBusProperties *self, + const gchar *name, + GValue *value) { McdAccountManager *account_manager = MCD_ACCOUNT_MANAGER (self); McdAccountManagerPrivate *priv = account_manager->priv; @@ -1033,8 +1043,9 @@ get_valid_hidden_accounts (TpSvcDBusProperties *self, const gchar *name, } static void -get_invalid_hidden_accounts (TpSvcDBusProperties *self, const gchar *name, - GValue *value) +get_unusable_hidden_accounts (TpSvcDBusProperties *self, + const gchar *name, + GValue *value) { McdAccountManager *account_manager = MCD_ACCOUNT_MANAGER (self); McdAccountManagerPrivate *priv = account_manager->priv; @@ -1043,8 +1054,8 @@ get_invalid_hidden_accounts (TpSvcDBusProperties *self, const gchar *name, } static const McdDBusProp account_manager_hidden_properties[] = { - { "ValidHiddenAccounts", NULL, get_valid_hidden_accounts }, - { "InvalidHiddenAccounts", NULL, get_invalid_hidden_accounts }, + { "UsableHiddenAccounts", NULL, get_usable_hidden_accounts }, + { "UnusableHiddenAccounts", NULL, get_unusable_hidden_accounts }, { 0 }, }; diff --git a/src/mcd-account.c b/src/mcd-account.c index f9e874e..8b5856b 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -159,10 +159,10 @@ struct _McdAccountPrivate (callback with user data) to be called when the account will be online */ - /* %NULL if the account is valid; a valid error for reporting over the - * D-Bus if the account is invalid. + /* %NULL if the account is usable; a valid error for reporting over the + * D-Bus if the account is unusable. */ - GError *invalid_reason; + GError *unusable_reason; gboolean connect_automatically; gboolean enabled; @@ -201,7 +201,7 @@ enum enum { - VALIDITY_CHANGED, + USABILITY_CHANGED, CONNECTION_PATH_CHANGED, LAST_SIGNAL }; @@ -336,17 +336,17 @@ mcd_account_loaded (McdAccount *account) if (account->priv->online_requests != NULL) { - /* if we have established that the account is not valid or is + /* if we have established that the account is not usable or is * disabled, cancel all requests */ - if (!mcd_account_is_valid (account) || !account->priv->enabled) + if (!mcd_account_is_usable (account) || !account->priv->enabled) { /* FIXME: pick better errors and put them in telepathy-spec? */ GError e = { TP_ERROR, TP_ERROR_NOT_AVAILABLE, - "account isn't Valid (not enough information to put it " + "account isn't Usable (not enough information to put it " "online)" }; GList *list; - if (mcd_account_is_valid (account)) + if (mcd_account_is_usable (account)) { e.message = "account isn't Enabled"; } @@ -458,22 +458,22 @@ mcd_account_get_parameter_of_known_type (McdAccount *account, typedef void (*CheckParametersCb) ( McdAccount *account, - const GError *invalid_reason, + const GError *unusable_reason, gpointer user_data); static void mcd_account_check_parameters (McdAccount *account, CheckParametersCb callback, gpointer user_data); static void manager_ready_check_params_cb (McdAccount *account, - const GError *invalid_reason, + const GError *unusable_reason, gpointer user_data) { McdAccountPrivate *priv = account->priv; - g_clear_error (&priv->invalid_reason); - if (invalid_reason != NULL) + g_clear_error (&priv->unusable_reason); + if (unusable_reason != NULL) { - priv->invalid_reason = g_error_copy (invalid_reason); + priv->unusable_reason = g_error_copy (unusable_reason); } mcd_account_loaded (account); @@ -555,7 +555,7 @@ account_external_password_storage_properties_changed_cb (TpProxy *cm, GObject *self) { McdAccount *account = MCD_ACCOUNT (self); - TpProtocol *protocol = tp_connection_manager_get_protocol_object ( + TpProtocol *protocol = tp_connection_manager_get_protocol ( TP_CONNECTION_MANAGER (cm), account->priv->protocol_name); GHashTable *params; @@ -594,7 +594,7 @@ static void on_manager_ready (McdManager *manager, const GError *error, if (tp_proxy_has_interface_by_id (cm, MC_IFACE_QUARK_CONNECTION_MANAGER_INTERFACE_ACCOUNT_STORAGE)) { - TpProtocol *protocol = tp_connection_manager_get_protocol_object ( + TpProtocol *protocol = tp_connection_manager_get_protocol ( cm, account->priv->protocol_name); GHashTable *params; @@ -706,7 +706,7 @@ mcd_account_delete (McdAccount *account, GHashTable *params; /* identify the account */ - protocol = tp_connection_manager_get_protocol_object (cm, + protocol = tp_connection_manager_get_protocol (cm, account->priv->protocol_name); params = _mcd_account_dup_parameters (account); @@ -828,7 +828,7 @@ mcd_account_request_presence_int (McdAccount *account, { GValue value = G_VALUE_INIT; - g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE); + g_value_init (&value, TP_STRUCT_TYPE_PRESENCE); g_value_take_boxed (&value, tp_value_array_build (3, G_TYPE_UINT, type, @@ -852,9 +852,9 @@ mcd_account_request_presence_int (McdAccount *account, return; } - if (!mcd_account_is_valid (account)) + if (!mcd_account_is_usable (account)) { - DEBUG ("%s not Valid", priv->unique_name); + DEBUG ("%s not Usable", priv->unique_name); return; } } @@ -1129,12 +1129,12 @@ get_icon (TpSvcDBusProperties *self, const gchar *name, GValue *value) } static void -get_valid (TpSvcDBusProperties *self, const gchar *name, GValue *value) +get_usable (TpSvcDBusProperties *self, const gchar *name, GValue *value) { McdAccount *account = MCD_ACCOUNT (self); g_value_init (value, G_TYPE_BOOLEAN); - g_value_set_boolean (value, mcd_account_is_valid (account)); + g_value_set_boolean (value, mcd_account_is_usable (account)); } static void @@ -1626,8 +1626,8 @@ get_parameters (TpSvcDBusProperties *self, const gchar *name, if (params == NULL) { - if (mcd_account_is_valid (account)) - g_warning ("%s is supposedly valid, but _dup_parameters() failed!", + if (mcd_account_is_usable (account)) + g_warning ("%s is supposedly usable, but _dup_parameters() failed!", mcd_account_get_unique_name (account)); params = tp_asv_new (NULL, NULL); @@ -1685,7 +1685,7 @@ set_automatic_presence (TpSvcDBusProperties *self, DEBUG ("called for %s", account_name); - if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_SIMPLE_PRESENCE)) + if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_PRESENCE)) { g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Unexpected type for AutomaticPresence: wanted (u,s,s), " @@ -1755,7 +1755,7 @@ get_automatic_presence (TpSvcDBusProperties *self, presence = priv->auto_presence_status; message = priv->auto_presence_message; - type = TP_STRUCT_TYPE_SIMPLE_PRESENCE; + type = TP_STRUCT_TYPE_PRESENCE; g_value_init (value, type); g_value_take_boxed (value, dbus_g_type_specialized_construct (type)); va = (GValueArray *) g_value_get_boxed (value); @@ -1903,7 +1903,7 @@ get_current_presence (TpSvcDBusProperties *self, const gchar *name, status = priv->curr_presence_status; message = priv->curr_presence_message; - type = TP_STRUCT_TYPE_SIMPLE_PRESENCE; + type = TP_STRUCT_TYPE_PRESENCE; g_value_init (value, type); g_value_take_boxed (value, dbus_g_type_specialized_construct (type)); va = (GValueArray *) g_value_get_boxed (value); @@ -1927,7 +1927,7 @@ set_requested_presence (TpSvcDBusProperties *self, DEBUG ("called for %s", priv->unique_name); - if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_SIMPLE_PRESENCE)) + if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_PRESENCE)) { g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Unexpected type for RequestedPresence: wanted (u,s,s), " @@ -1975,7 +1975,7 @@ get_requested_presence (TpSvcDBusProperties *self, presence = priv->req_presence_status; message = priv->req_presence_message; - type = TP_STRUCT_TYPE_SIMPLE_PRESENCE; + type = TP_STRUCT_TYPE_PRESENCE; g_value_init (value, type); g_value_take_boxed (value, dbus_g_type_specialized_construct (type)); va = (GValueArray *) g_value_get_boxed (value); @@ -2172,7 +2172,7 @@ static const McdDBusProp account_properties[] = { { "Interfaces", NULL, mcd_dbus_get_interfaces }, { "DisplayName", set_display_name, get_display_name }, { "Icon", set_icon, get_icon }, - { "Valid", NULL, get_valid }, + { "Usable", NULL, get_usable }, { "Enabled", set_enabled, get_enabled }, { "Nickname", set_nickname, get_nickname }, { "Service", set_service, get_service }, @@ -2362,7 +2362,7 @@ account_external_password_storage_forget_password ( } /* identify the account */ - protocol = tp_connection_manager_get_protocol_object (cm, + protocol = tp_connection_manager_get_protocol (cm, account->priv->protocol_name); params = _mcd_account_dup_parameters (account); @@ -2643,10 +2643,10 @@ out: static void set_parameters_maybe_autoconnect_cb (McdAccount *account, - const GError *invalid_reason, + const GError *unusable_reason, gpointer user_data G_GNUC_UNUSED) { - /* Strictly speaking this doesn't need to be called unless invalid_reason + /* Strictly speaking this doesn't need to be called unless unusable_reason * is NULL, but calling it in all cases gives us clearer debug output */ _mcd_account_maybe_autoconnect (account); } @@ -2686,8 +2686,8 @@ apply_parameter_updates (McdAccount *account, } } - mcd_account_check_validity (account, - set_parameters_maybe_autoconnect_cb, NULL); + mcd_account_check_usability (account, + set_parameters_maybe_autoconnect_cb, NULL); } static void @@ -3005,13 +3005,13 @@ account_reconnect (TpSvcAccount *service, /* if we can't, or don't want to, connect this method is a no-op */ if (!priv->enabled || - !mcd_account_is_valid (self) || + !mcd_account_is_usable (self) || priv->req_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE) { - DEBUG ("doing nothing (enabled=%c, valid=%c and " + DEBUG ("doing nothing (enabled=%c, usable=%c and " "combined presence=%i)", self->priv->enabled ? 'T' : 'F', - mcd_account_is_valid (self) ? 'T' : 'F', + mcd_account_is_usable (self) ? 'T' : 'F', self->priv->req_presence_type); tp_svc_account_return_from_reconnect (context); return; @@ -3327,7 +3327,7 @@ mcd_account_setup (McdAccount *account) priv->always_dispatch = mcd_storage_get_boolean (storage, name, MC_ACCOUNTS_KEY_ALWAYS_DISPATCH); - g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE); + g_value_init (&value, TP_STRUCT_TYPE_PRESENCE); g_free (priv->auto_presence_status); g_free (priv->auto_presence_message); @@ -3751,8 +3751,8 @@ mcd_account_class_init (McdAccountClass * klass) FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ - _mcd_account_signals[VALIDITY_CHANGED] = - g_signal_new ("validity-changed", + _mcd_account_signals[USABILITY_CHANGED] = + g_signal_new ("usability-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, 0, @@ -3814,7 +3814,7 @@ mcd_account_init (McdAccount *account) priv->changed_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free); - g_set_error (&priv->invalid_reason, TP_ERROR, TP_ERROR_NOT_YET, + g_set_error (&priv->unusable_reason, TP_ERROR, TP_ERROR_NOT_YET, "This account is not yet fully loaded"); } @@ -3843,20 +3843,20 @@ _mcd_account_get_storage (McdAccount *account) } /* - * mcd_account_is_valid: + * mcd_account_is_usable: * @account: the #McdAccount. * * Checks that the account is usable: * - Manager, protocol and TODO presets (if specified) must exist * - All required parameters for the protocol must be set * - * Returns: %TRUE if the account is valid, false otherwise. + * Returns: %TRUE if the account is usable, false otherwise. */ gboolean -mcd_account_is_valid (McdAccount *account) +mcd_account_is_usable (McdAccount *account) { McdAccountPrivate *priv = MCD_ACCOUNT_PRIV (account); - return priv->invalid_reason == NULL; + return priv->unusable_reason == NULL; } /** @@ -4026,7 +4026,7 @@ mcd_account_update_self_presence (McdAccount *account, if (!changed) return; - g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE); + g_value_init (&value, TP_STRUCT_TYPE_PRESENCE); g_value_take_boxed (&value, tp_value_array_build (3, G_TYPE_UINT, presence, @@ -4096,9 +4096,9 @@ mcd_account_would_like_to_connect (McdAccount *account) return FALSE; } - if (!mcd_account_is_valid (account)) + if (!mcd_account_is_usable (account)) { - DEBUG ("%s not Valid", priv->unique_name); + DEBUG ("%s not Usable", priv->unique_name); return FALSE; } @@ -4144,7 +4144,7 @@ mcd_account_get_protocol_name (McdAccount *account) * @account: an account * * Fetches the connection manager through which @account connects. If @account - * is not ready, or is invalid (perhaps because the connection manager is + * is not ready, or is unusable (perhaps because the connection manager is * missing), this may be %NULL. * * Returns: the connection manager through which @account connects, or %NULL. @@ -4644,66 +4644,66 @@ mcd_account_get_connection (McdAccount *account) typedef struct { - McdAccountCheckValidityCb callback; + McdAccountCheckUsabilityCb callback; gpointer user_data; -} CheckValidityData; +} CheckUsabilityData; static void -check_validity_check_parameters_cb (McdAccount *account, - const GError *invalid_reason, +check_usability_check_parameters_cb (McdAccount *account, + const GError *unusable_reason, gpointer user_data) { - CheckValidityData *data = (CheckValidityData *) user_data; + CheckUsabilityData *data = (CheckUsabilityData *) user_data; McdAccountPrivate *priv = account->priv; - gboolean now_valid = (invalid_reason == NULL); - gboolean was_valid = (priv->invalid_reason == NULL); + gboolean now_usable = (unusable_reason == NULL); + gboolean was_usable = (priv->unusable_reason == NULL); - g_clear_error (&priv->invalid_reason); - if (invalid_reason != NULL) + g_clear_error (&priv->unusable_reason); + if (unusable_reason != NULL) { - priv->invalid_reason = g_error_copy (invalid_reason); + priv->unusable_reason = g_error_copy (unusable_reason); } - if (was_valid != now_valid) + if (was_usable != now_usable) { GValue value = G_VALUE_INIT; - DEBUG ("Account validity changed (old: %d, new: %d)", - was_valid, now_valid); - g_signal_emit (account, _mcd_account_signals[VALIDITY_CHANGED], 0, - now_valid); + DEBUG ("Account usability changed (old: %d, new: %d)", + was_usable, now_usable); + g_signal_emit (account, _mcd_account_signals[USABILITY_CHANGED], 0, + now_usable); g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, now_valid); - mcd_account_changed_property (account, "Valid", &value); + g_value_set_boolean (&value, now_usable); + mcd_account_changed_property (account, "Usable", &value); - if (now_valid) + if (now_usable) { - /* Newly valid - try setting requested presence again. + /* Newly usable - try setting requested presence again. * This counts as user-initiated, because the user caused the - * account to become valid somehow. */ + * account to become usable somehow. */ mcd_account_rerequest_presence (account, TRUE); } } if (data->callback != NULL) - data->callback (account, invalid_reason, data->user_data); + data->callback (account, unusable_reason, data->user_data); - g_slice_free (CheckValidityData, data); + g_slice_free (CheckUsabilityData, data); } void -mcd_account_check_validity (McdAccount *account, - McdAccountCheckValidityCb callback, - gpointer user_data) +mcd_account_check_usability (McdAccount *account, + McdAccountCheckUsabilityCb callback, + gpointer user_data) { - CheckValidityData *data; + CheckUsabilityData *data; g_return_if_fail (MCD_IS_ACCOUNT (account)); - data = g_slice_new0 (CheckValidityData); + data = g_slice_new0 (CheckUsabilityData); data->callback = callback; data->user_data = user_data; - mcd_account_check_parameters (account, check_validity_check_parameters_cb, + mcd_account_check_parameters (account, check_usability_check_parameters_cb, data); } @@ -4766,11 +4766,11 @@ _mcd_account_online_request (McdAccount *account, return; } - if (priv->loaded && !mcd_account_is_valid (account)) + if (priv->loaded && !mcd_account_is_usable (account)) { /* FIXME: pick a better error and put it in telepathy-spec? */ GError e = { TP_ERROR, TP_ERROR_NOT_AVAILABLE, - "account isn't Valid (not enough information to put it online)" }; + "account isn't Usable (not enough information to put it online)" }; DEBUG ("%s: %s", priv->unique_name, e.message); callback (account, userdata, &e); @@ -5034,7 +5034,7 @@ mcd_account_self_contact_changed_cb (McdAccount *self, GParamSpec *unused_param_spec G_GNUC_UNUSED, TpConnection *tp_connection) { - static const TpContactFeature contact_features[] = { + GQuark contact_features[] = { TP_CONTACT_FEATURE_AVATAR_TOKEN, TP_CONTACT_FEATURE_AVATAR_DATA, TP_CONTACT_FEATURE_ALIAS, diff --git a/src/mcd-account.h b/src/mcd-account.h index 7843c27..a7489f7 100644 --- a/src/mcd-account.h +++ b/src/mcd-account.h @@ -90,14 +90,14 @@ void mcd_account_delete (McdAccount *account, McdAccountDeleteCb callback, const gchar *mcd_account_get_unique_name (McdAccount *account); const gchar *mcd_account_get_object_path (McdAccount *account); -gboolean mcd_account_is_valid (McdAccount *account); - -typedef void (*McdAccountCheckValidityCb) (McdAccount *account, - const GError *invalid_reason, - gpointer user_data); -void mcd_account_check_validity (McdAccount *account, - McdAccountCheckValidityCb callback, - gpointer user_data); +gboolean mcd_account_is_usable (McdAccount *account); + +typedef void (*McdAccountCheckUsabilityCb) (McdAccount *account, + const GError *unusable_reason, + gpointer user_data); +void mcd_account_check_usability (McdAccount *account, + McdAccountCheckUsabilityCb callback, + gpointer user_data); gboolean mcd_account_is_enabled (McdAccount *account); diff --git a/tests/twisted/account-manager/account-basics.py b/tests/twisted/account-manager/account-basics.py index 18b35cb..2744c1f 100644 --- a/tests/twisted/account-manager/account-basics.py +++ b/tests/twisted/account-manager/account-basics.py @@ -38,10 +38,8 @@ def test(q, bus, mc): properties = account_manager.GetAll(cs.AM, dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('ValidAccounts') == [], \ - properties.get('ValidAccounts') - assert properties.get('InvalidAccounts') == [], \ - properties.get('InvalidAccounts') + assertEquals([], properties.get('UsableAccounts')) + assertEquals([], properties.get('UnusableAccounts')) interfaces = properties.get('Interfaces') params = dbus.Dictionary({"account": "someguy@example.com", @@ -54,10 +52,10 @@ def test(q, bus, mc): properties = account_manager.GetAll(cs.AM, dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('ValidAccounts') == [account_path], properties - account_path = properties['ValidAccounts'][0] + assertEquals([account_path], properties.get('UsableAccounts')) + account_path = properties['UsableAccounts'][0] assert isinstance(account_path, dbus.ObjectPath), repr(account_path) - assert properties.get('InvalidAccounts') == [], properties + assertEquals([], properties.get('UnusableAccounts')) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) @@ -73,7 +71,7 @@ def test(q, bus, mc): assert properties.get('DisplayName') == 'fakeaccount', \ properties.get('DisplayName') assert properties.get('Icon') == '', properties.get('Icon') - assert properties.get('Valid') == True, properties.get('Valid') + assertEquals(True, properties.get('Usable')) assert properties.get('Enabled') == False, properties.get('Enabled') #assert properties.get('Nickname') == 'fakenick', properties.get('Nickname') assert properties.get('Parameters') == params, properties.get('Parameters') @@ -326,9 +324,8 @@ def test(q, bus, mc): properties = account_manager.GetAll(cs.AM, dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('ValidAccounts') == [], properties - assert properties.get('InvalidAccounts') == [], properties - + assertEquals([], properties.get('UsableAccounts')) + assertEquals([], properties.get('UnusableAccounts')) if __name__ == '__main__': exec_test(test, {}) diff --git a/tests/twisted/account-manager/backend-makes-changes.py b/tests/twisted/account-manager/backend-makes-changes.py index 30bb0ef..0d367f9 100644 --- a/tests/twisted/account-manager/backend-makes-changes.py +++ b/tests/twisted/account-manager/backend-makes-changes.py @@ -50,7 +50,7 @@ def test(q, bus, mc, fake_accounts_service=None, **kwargs): {'account': 0, 'password': cs.PARAM_SECRET}]), EventPattern('dbus-signal', path=cs.AM_PATH, - signal='AccountValidityChanged', + signal='AccountUsabilityChanged', args=[account_path, True]), ) account = Account(bus, account_path) @@ -64,7 +64,7 @@ def test(q, bus, mc, fake_accounts_service=None, **kwargs): path=account_path, signal='AccountPropertyChanged', interface=cs.ACCOUNT, - # Can't match on args because Valid: True sometimes gets into + # Can't match on args because Usable: True sometimes gets into # this AccountPropertyChanged signal. MC should stop merging # unrelated signals one day... predicate=(lambda e: diff --git a/tests/twisted/account-manager/create-with-properties.py b/tests/twisted/account-manager/create-with-properties.py index 6da44aa..75e8973 100644 --- a/tests/twisted/account-manager/create-with-properties.py +++ b/tests/twisted/account-manager/create-with-properties.py @@ -32,10 +32,8 @@ def test(q, bus, mc): call_async(q, account_manager.Properties, 'GetAll', cs.AM) properties, = q.expect('dbus-return', method='GetAll').value assert properties is not None - assert properties.get('ValidAccounts') == [], \ - properties.get('ValidAccounts') - assert properties.get('InvalidAccounts') == [], \ - properties.get('InvalidAccounts') + assertEquals([], properties.get('UsableAccounts')) + assertEquals([], properties.get('UnusableAccounts')) interfaces = properties.get('Interfaces') supported = properties.get('SupportedAccountProperties') @@ -92,7 +90,7 @@ def test(q, bus, mc): am_signal, ret, rc = q.expect_many( EventPattern('dbus-signal', path=cs.AM_PATH, - signal='AccountValidityChanged', interface=cs.AM), + signal='AccountUsabilityChanged', interface=cs.AM), EventPattern('dbus-return', method='CreateAccount'), EventPattern('dbus-method-call', method='RequestConnection'), ) @@ -117,8 +115,7 @@ def test(q, bus, mc): properties.get('ConnectAutomatically') assert properties.get('Enabled') == True, \ properties.get('Enabled') - assert properties.get('Valid') == True, \ - properties.get('Valid') + assertEquals(True, properties.get('Usable')) assert properties.get('Icon') == 'quake3arena', \ properties.get('Icon') assert properties.get('Nickname') == 'AnArKi', \ diff --git a/tests/twisted/account-manager/hidden.py b/tests/twisted/account-manager/hidden.py index 9e9351b..9a34e22 100644 --- a/tests/twisted/account-manager/hidden.py +++ b/tests/twisted/account-manager/hidden.py @@ -40,8 +40,8 @@ def test_unhidden_account(q, bus, mc): assert not account.Properties.Get(cs.ACCOUNT_IFACE_HIDDEN, 'Hidden') am_hidden_props = am.Properties.GetAll(cs.AM_IFACE_HIDDEN) - assertEquals([], am_hidden_props['ValidHiddenAccounts']) - assertEquals([], am_hidden_props['InvalidHiddenAccounts']) + assertEquals([], am_hidden_props['UsableHiddenAccounts']) + assertEquals([], am_hidden_props['UnusableHiddenAccounts']) def test_create_hidden_account(q, bus, mc): """ @@ -62,16 +62,16 @@ def test_create_hidden_account(q, bus, mc): q.forbid_events([ EventPattern('dbus-signal', path=cs.AM_PATH, - signal='AccountValidityChanged', interface=cs.AM), + signal='AccountUsabilityChanged', interface=cs.AM), ]) cm_name_ref, account = create_fakecm_account(q, bus, mc, params, properties) - valid_accounts = am.Properties.Get(cs.AM, 'ValidAccounts') - assertDoesNotContain(account.object_path, valid_accounts) + usable_accounts = am.Properties.Get(cs.AM, 'UsableAccounts') + assertDoesNotContain(account.object_path, usable_accounts) - valid_hidden_accounts = am.Properties.Get(cs.AM_IFACE_HIDDEN, - 'ValidHiddenAccounts') - assertContains(account.object_path, valid_hidden_accounts) + usable_hidden_accounts = am.Properties.Get(cs.AM_IFACE_HIDDEN, + 'UsableHiddenAccounts') + assertContains(account.object_path, usable_hidden_accounts) # Blow MC away, revive it, and check that the account is still hidden. tell_mc_to_die(q, bus) @@ -80,11 +80,11 @@ def test_create_hidden_account(q, bus, mc): assert account.Properties.Get(cs.ACCOUNT_IFACE_HIDDEN, 'Hidden') - assertDoesNotContain(account.object_path, properties['ValidAccounts']) + assertDoesNotContain(account.object_path, properties['UsableAccounts']) - valid_hidden_accounts = am.Properties.Get(cs.AM_IFACE_HIDDEN, - 'ValidHiddenAccounts') - assertContains(account.object_path, valid_hidden_accounts) + usable_hidden_accounts = am.Properties.Get(cs.AM_IFACE_HIDDEN, + 'UsableHiddenAccounts') + assertContains(account.object_path, usable_hidden_accounts) # Delete the account, and check that its removal is signalled only on # AM.I.Hidden, not on the main AM interface. diff --git a/tests/twisted/account-manager/make-valid.py b/tests/twisted/account-manager/make-valid.py index 33582c5..14abcee 100644 --- a/tests/twisted/account-manager/make-valid.py +++ b/tests/twisted/account-manager/make-valid.py @@ -17,7 +17,7 @@ # 02110-1301 USA import dbus -"""Feature test for accounts becoming valid. +"""Feature test for accounts becoming usable (formerly called "valid"). """ import os diff --git a/tests/twisted/account-manager/param-types.py b/tests/twisted/account-manager/param-types.py index 8dafd7f..ff5ec55 100644 --- a/tests/twisted/account-manager/param-types.py +++ b/tests/twisted/account-manager/param-types.py @@ -60,7 +60,7 @@ def test(q, bus, mc): am_signal, ret = q.expect_many( EventPattern('dbus-signal', path=cs.AM_PATH, - interface=cs.AM, signal='AccountValidityChanged'), + interface=cs.AM, signal='AccountUsabilityChanged'), EventPattern('dbus-return', method='CreateAccount'), ) account_path = ret.value[0] diff --git a/tests/twisted/account-manager/request-online.py b/tests/twisted/account-manager/request-online.py index 94a0b83..08d0248 100644 --- a/tests/twisted/account-manager/request-online.py +++ b/tests/twisted/account-manager/request-online.py @@ -52,10 +52,10 @@ def test(q, bus, mc): "password": "secrecy"}, signature='sv') (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) - # The account is initially valid but disabled, and hence offline + # The account is initially usable but disabled, and hence offline props = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE) assert not props['Enabled'] - assert props['Valid'] + assert props['Usable'] # The spec says it should be (Offline, "", "") but I don't think the # strings really matter. If anything, the second one should start out at # "offline". @@ -71,7 +71,7 @@ def test(q, bus, mc): props = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE) assert props['Enabled'] - assert props['Valid'] + assert props['Usable'] # Ditto above re. string fields. assertEquals(cs.PRESENCE_OFFLINE, props['CurrentPresence'][0]) diff --git a/tests/twisted/account-storage/default-keyring-storage.py b/tests/twisted/account-storage/default-keyring-storage.py index 2d3b2fc..bc41db6 100644 --- a/tests/twisted/account-storage/default-keyring-storage.py +++ b/tests/twisted/account-storage/default-keyring-storage.py @@ -67,10 +67,8 @@ def test(q, bus, mc): account_manager, properties, interfaces = connect_to_mc(q, bus, mc) - assert properties.get('ValidAccounts') == [], \ - properties.get('ValidAccounts') - assert properties.get('InvalidAccounts') == [], \ - properties.get('InvalidAccounts') + assertEquals([], properties.get('UsableAccounts')) + assertEquals([], properties.get('UnusableAccounts')) params = dbus.Dictionary({"account": "dontdivert@example.com", "password": "secrecy"}, signature='sv') @@ -82,10 +80,10 @@ def test(q, bus, mc): properties = account_manager.GetAll(cs.AM, dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('ValidAccounts') == [account_path], properties - account_path = properties['ValidAccounts'][0] + assertEquals([account_path], properties.get('UsableAccounts')) + account_path = properties['UsableAccounts'][0] assert isinstance(account_path, dbus.ObjectPath), repr(account_path) - assert properties.get('InvalidAccounts') == [], properties + assertEquals([], properties.get('UnusableAccounts')) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-storage/diverted-storage.py b/tests/twisted/account-storage/diverted-storage.py index 8692b09..c9fa379 100644 --- a/tests/twisted/account-storage/diverted-storage.py +++ b/tests/twisted/account-storage/diverted-storage.py @@ -25,7 +25,7 @@ import dbus import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ - call_async + call_async, assertEquals from mctest import ( exec_test, create_fakecm_account, get_fakecm_account, connect_to_mc, keyfile_read, read_account_keyfile, tell_mc_to_die, resuscitate_mc, @@ -46,10 +46,8 @@ def test(q, bus, mc): account_manager, properties, interfaces = connect_to_mc(q, bus, mc) - assert properties.get('ValidAccounts') == [], \ - properties.get('ValidAccounts') - assert properties.get('InvalidAccounts') == [], \ - properties.get('InvalidAccounts') + assertEquals([], properties.get('UsableAccounts')) + assertEquals([], properties.get('UnusableAccounts')) params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') @@ -61,10 +59,10 @@ def test(q, bus, mc): properties = account_manager.GetAll(cs.AM, dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('ValidAccounts') == [account_path], properties - account_path = properties['ValidAccounts'][0] + assertEquals([account_path], properties.get('UsableAccounts')) + account_path = properties['UsableAccounts'][0] assert isinstance(account_path, dbus.ObjectPath), repr(account_path) - assert properties.get('InvalidAccounts') == [], properties + assertEquals([], properties.get('UnusableAccounts')) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-storage/libaccounts-sso-storage.py b/tests/twisted/account-storage/libaccounts-sso-storage.py index a2e7b51..68637eb 100644 --- a/tests/twisted/account-storage/libaccounts-sso-storage.py +++ b/tests/twisted/account-storage/libaccounts-sso-storage.py @@ -66,10 +66,10 @@ def prepare_accounts_db(ctl_dir): def test(q, bus, mc): account_manager, properties, interfaces = connect_to_mc(q, bus, mc) - va = properties.get('ValidAccounts') + va = properties.get('UsableAccounts') assert va == [], va - ia = properties.get('InvalidAccounts') + ia = properties.get('UnusableAccounts') assert len(ia) == 1 account_path = ia[0] diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index 9bcd287..2b7809e 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -160,8 +160,8 @@ def exec_test_deferred (fun, params, protocol=None, timeout=None, am = AccountManager(bus) am_props = am.Properties.GetAll(cs.AM) - for a in (am_props.get('ValidAccounts', []) + - am_props.get('InvalidAccounts', [])): + for a in (am_props.get('UsableAccounts', []) + + am_props.get('UnusableAccounts', [])): account = Account(bus, a) try: @@ -1035,12 +1035,12 @@ def create_fakecm_account(q, bus, mc, params, properties={}, # expect a different signal. It annoys me that this has to be in here, but, # eh. if properties.get(cs.ACCOUNT_IFACE_HIDDEN + '.Hidden', False): - validity_changed_pattern = servicetest.EventPattern('dbus-signal', - path=cs.AM_PATH, signal='HiddenAccountValidityChanged', + usability_changed_pattern = servicetest.EventPattern('dbus-signal', + path=cs.AM_PATH, signal='HiddenAccountUsabilityChanged', interface=cs.AM_IFACE_HIDDEN) else: - validity_changed_pattern = servicetest.EventPattern('dbus-signal', - path=cs.AM_PATH, signal='AccountValidityChanged', interface=cs.AM) + usability_changed_pattern = servicetest.EventPattern('dbus-signal', + path=cs.AM_PATH, signal='AccountUsabilityChanged', interface=cs.AM) # The spec has no order guarantee here. # FIXME: MC ought to also introspect the CM and find out that the params @@ -1048,13 +1048,13 @@ def create_fakecm_account(q, bus, mc, params, properties={}, a_signal, am_signal, ret = q.expect_many( servicetest.EventPattern('dbus-signal', signal='AccountPropertyChanged', interface=cs.ACCOUNT, - predicate=(lambda e: 'Valid' in e.args[0])), - validity_changed_pattern, + predicate=(lambda e: 'Usable' in e.args[0])), + usability_changed_pattern, servicetest.EventPattern('dbus-return', method='CreateAccount'), ) account_path = ret.value[0] assert am_signal.args == [account_path, True], am_signal.args - assert a_signal.args[0]['Valid'] == True, a_signal.args + assert a_signal.args[0]['Usable'] == True, a_signal.args assert account_path is not None diff --git a/util/mc-tool.c b/util/mc-tool.c index 2f8d4b7..09a7174 100644 --- a/util/mc-tool.c +++ b/util/mc-tool.c @@ -468,7 +468,7 @@ getter_list_init(void) getter_list_add("DisplayName", GET_STRING, tp_account_get_display_name); getter_list_add("Icon", GET_STRING, tp_account_get_icon_name); - getter_list_add("Valid", GET_BOOLEAN, tp_account_is_valid); + getter_list_add("Usable", GET_BOOLEAN, tp_account_is_usable); getter_list_add("Enabled", GET_BOOLEAN, tp_account_is_enabled); getter_list_add("Nickname", GET_STRING, tp_account_get_nickname); getter_list_add("ConnectAutomatically", GET_BOOLEAN, @@ -518,16 +518,16 @@ compare_accounts (gconstpointer a, } static GList * -dup_valid_accounts_sorted (TpAccountManager *manager) +dup_usable_accounts_sorted (TpAccountManager *manager) { - return g_list_sort (tp_account_manager_dup_valid_accounts (manager), + return g_list_sort (tp_account_manager_dup_usable_accounts (manager), compare_accounts); } static gboolean command_list (TpAccountManager *manager) { - GList *accounts = dup_valid_accounts_sorted (manager); + GList *accounts = dup_usable_accounts_sorted (manager); if (accounts != NULL) { GList *ptr; @@ -550,7 +550,7 @@ command_summary (TpAccountManager *manager) GList *accounts, *l; guint longest_account = 0; - accounts = tp_account_manager_dup_valid_accounts (manager); + accounts = tp_account_manager_dup_usable_accounts (manager); if (accounts == NULL) { return FALSE; } @@ -731,7 +731,7 @@ command_show (TpAccount *account) show ("Display Name", tp_account_get_display_name (account)); show ("Normalized", tp_account_get_normalized_name (account)); show ("Enabled", tp_account_is_enabled (account) ? "enabled" : "disabled"); - show ("Valid", tp_account_is_valid (account) ? "" : "false"); + show ("Usable", tp_account_is_usable (account) ? "" : "false"); show ("Icon", tp_account_get_icon_name (account)); show ("Connects", tp_account_get_connect_automatically (account) @@ -825,7 +825,7 @@ command_dump (TpAccountManager *manager) { GList *accounts, *l; - accounts = tp_account_manager_dup_valid_accounts (manager); + accounts = tp_account_manager_dup_usable_accounts (manager); if (accounts == NULL) { return FALSE; } diff --git a/xml/Account_Manager_Interface_Hidden.xml b/xml/Account_Manager_Interface_Hidden.xml index 284eb64..0b52617 100644 --- a/xml/Account_Manager_Interface_Hidden.xml +++ b/xml/Account_Manager_Interface_Hidden.xml @@ -30,26 +30,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. first draft - + - A list of valid (complete, usable) Accounts intended exclusively for noninteractive applications. These accounts are not included in AccountManager.ValidAccounts. Change + namespace='imt1'>AccountManager.UsableAccounts. Change notification is via - HiddenAccountValidityChanged. + HiddenAccountUsabilityChanged. - + A list of incomplete or otherwise unusable Accounts intended exclusively for noninteractive applications. Change notification is via - HiddenAccountValidityChanged. + HiddenAccountUsabilityChanged. @@ -57,8 +57,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. tp:name-for-bindings="Hidden_Account_Removed"> The given account has been removed from - ValidHiddenAccounts or - InvalidHiddenAccounts. + UsableHiddenAccounts or + UnusableHiddenAccounts. @@ -68,15 +68,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + - The validity of the given account has changed. New magic - accounts are also indicated by this signal, as an account validity + The usability of the given account has changed. New magic + accounts are also indicated by this signal, as an account usability change (usually to True) on an account that did not previously exist. - This is effectively change notification for the valid and invalid + This is effectively change notification for the usable and unusable accounts lists. @@ -88,9 +88,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + - True if the account is now valid. + True if the account is now usable. -- 1.8.4.rc3