static void provide_password (TpChannel *channel, const gchar *password) { GArray *array = g_array_sized_new (TRUE, FALSE, sizeof (gchar), strlen (password)); g_array_append_vals (array, password, strlen (password)); tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data ( channel, -1, "X-TELEPATHY-PASSWORD", array, password_provided_cb, NULL, NULL, NULL); g_array_unref (array); }
void empathy_server_sasl_handler_provide_password ( EmpathyServerSASLHandler *handler, const gchar *password, gboolean remember) { EmpathyServerSASLHandlerPriv *priv; GArray *array; gboolean may_save_response, may_save_response_valid; g_return_if_fail (EMPATHY_IS_SERVER_SASL_HANDLER (handler)); priv = handler->priv; array = g_array_sized_new (TRUE, FALSE, sizeof (gchar), strlen (password)); g_array_append_vals (array, password, strlen (password)); DEBUG ("Calling StartMechanismWithData with our password"); tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data ( priv->channel, -1, "X-TELEPATHY-PASSWORD", array, start_mechanism_with_data_cb, NULL, NULL, G_OBJECT (handler)); g_array_unref (array); DEBUG ("%sremembering the password", remember ? "" : "not "); /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean ( tp_channel_borrow_immutable_properties (priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if (!may_save_response_valid) { DEBUG ("MaySaveResponse unknown, assuming TRUE"); may_save_response = TRUE; } if (remember) { if (may_save_response) { g_free (priv->password); /* We'll save the password if we manage to connect */ priv->password = g_strdup (password); priv->save_password = TRUE; } else if (tp_proxy_has_interface_by_id (priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { DEBUG ("Channel implements Ch.I.CredentialsStorage"); } else { DEBUG ("Asked to remember password, but doing so is not permitted"); } } if (!may_save_response) { /* delete any password present, it shouldn't be there */ empathy_keyring_delete_account_password_async (priv->account, NULL, NULL); } /* Additionally, if we implement Ch.I.CredentialsStorage, inform that * whether we want to remember the password */ if (tp_proxy_has_interface_by_id (priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { emp_cli_channel_interface_credentials_storage_call_store_credentials ( TP_PROXY (priv->channel), -1, remember, NULL, NULL, NULL, NULL); } }
void hev_impathy_server_sasl_handler_provide_password( HevImpathyServerSASLHandler *self, const gchar *password, gboolean remember) { HevImpathyServerSASLHandlerPrivate * priv = NULL; GArray *array = NULL; gboolean may_save_response = FALSE, may_save_response_valid = FALSE; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_if_fail(HEV_IS_IMPATHY_SERVER_SASL_HANDLER(self)); priv = HEV_IMPATHY_SERVER_SASL_HANDLER_GET_PRIVATE(self); array = g_array_sized_new(TRUE, FALSE, sizeof(gchar), strlen(password)); g_array_append_vals(array, password, strlen(password)); tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data( priv->channel, -1, "X-TELEPATHY-PASSWORD", array, start_mechanism_with_data_handler, NULL, NULL, G_OBJECT(self)); g_array_unref(array); /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean( tp_channel_borrow_immutable_properties(priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if(!may_save_response_valid) { may_save_response = TRUE; } if(remember) { if(may_save_response) { g_free(priv->password); /* We'll save the password if we manage to connect */ priv->password = g_strdup(password); priv->save_password = TRUE; } #if 0 /* TODO */ else if(tp_proxy_has_interface_by_id(priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { } else { } #endif } if(!may_save_response) { /* delete any password present, it shouldn't be there */ hev_impathy_keyring_delete_account_password_async(priv->account, NULL, NULL); } #if 0 /* TODO */ /* Additionally, if we implement Ch.I.CredentialsStorage, inform that * whether we want to remember the password. */ if(tp_proxy_has_interface_by_id(priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { emp_cli_channel_interface_credentials_storage_call_store_credentials( TP_PROXY(priv->channel), -1, remember, NULL, NULL, NULL, NULL); } #endif }