static void uoa_get_account_password (TpAccount *tp_account, GSimpleAsyncResult *result) { AgAccountService *service; AgAuthData *auth_data; guint cred_id; SignonIdentity *identity; SignonAuthSession *session; GError *error = NULL; DEBUG ("Store password for %s in signond", tp_account_get_path_suffix (tp_account)); service = uoa_password_common (tp_account, result, &auth_data); if (service == NULL) return; cred_id = ag_auth_data_get_credentials_id (auth_data); if (cred_id == 0) { g_simple_async_result_set_error (result, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "AgAccount has no CredentialsId"); g_simple_async_result_complete_in_idle (result); goto out; } identity = signon_identity_new_from_db (cred_id); session = signon_identity_create_session (identity, ag_auth_data_get_method (auth_data), &error); g_object_unref (identity); if (session == NULL) { g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); goto out; } signon_auth_session_process_async (session, ag_auth_data_get_login_parameters (auth_data, NULL), ag_auth_data_get_mechanism (auth_data), NULL, uoa_session_process_cb, g_object_ref (result)); g_object_unref (session); out: ag_auth_data_unref (auth_data); g_object_unref (service); }
static void uoa_set_account_password (TpAccount *tp_account, const gchar *password, gboolean remember, GSimpleAsyncResult *result) { AgAccountService *service; AgAuthData *auth_data; guint cred_id; UoaChangePasswordData *data; SignonIdentity *identity; DEBUG ("Store password for %s in signond", tp_account_get_path_suffix (tp_account)); service = uoa_password_common (tp_account, result, &auth_data); if (service == NULL) return; data = uoa_change_password_data_new (service, password, remember, result); cred_id = ag_auth_data_get_credentials_id (auth_data); if (cred_id == 0) { SignonIdentityInfo *info; const GHashTable *params; const gchar *username; const gchar *acl_all[] = { "*", NULL }; /* This is the first time we store password for this account. * First check if we have an 'username' param as this is more accurate * in the tp-idle case. */ params = tp_account_get_parameters (tp_account); username = tp_asv_get_string (params, "username"); if (username == NULL) username = tp_asv_get_string (params, "account"); identity = signon_identity_new (); info = signon_identity_info_new (); signon_identity_info_set_username (info, username); signon_identity_info_set_secret (info, password, remember); signon_identity_info_set_access_control_list (info, acl_all); /* Give identity and data ownership to the callback */ signon_identity_store_credentials_with_info (identity, info, uoa_initial_identity_store_cb, data); signon_identity_info_free (info); } else { /* There is already a password stored, query info to update it. * Give identity and data ownership to the callback */ identity = signon_identity_new_from_db (cred_id); signon_identity_query_info (identity, uoa_identity_query_info_cb, data); } g_object_unref (service); ag_auth_data_unref (auth_data); }