static gboolean
chat_conversations_list_accounts_key_equal_func (gconstpointer a, gconstpointer b)
{
  TpAccount *account_a = TP_ACCOUNT (a);
  TpAccount *account_b = TP_ACCOUNT (b);
  const gchar *path_suffix_a;
  const gchar *path_suffix_b;

  path_suffix_a = tp_account_get_path_suffix (account_a);
  path_suffix_b = tp_account_get_path_suffix (account_b);

  return g_strcmp0 (path_suffix_a, path_suffix_b) == 0;
}
Example #2
0
static void
retry_account_cb (GtkWidget *dialog,
    TpAccount *account,
    const gchar *password,
    EmpathyAuthFactory *factory)
{
  DEBUG ("Try reconnecting to %s", tp_account_get_path_suffix (account));

  empathy_auth_factory_save_retry_password (factory, account, password);

  tp_account_reconnect_async (account, NULL, NULL);
}
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);
}
Example #4
0
static void
auth_factory_auth_passsword_failed (EmpathyAuthFactory *factory,
    TpAccount *account,
    const gchar *password,
    gpointer user_data)
{
  GtkWidget *dialog;

  DEBUG ("Authentication on %s failed, popup password dialog",
      tp_account_get_path_suffix (account));

  dialog = empathy_bad_password_dialog_new (account, password);

  tp_g_signal_connect_object (dialog, "retry",
      G_CALLBACK (retry_account_cb), factory, 0);

  gtk_widget_show (dialog);
}
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);
}
static void
handle_channels_cb (TpSimpleHandler *handler,
  TpAccount *account,
  TpConnection *connection,
  GList *channels,
  GList *request_satisfied,
  gint64 user_aciton_time,
  TpHandleChannelsContext *handler_context,
  gpointer user_data)
{
  TpChannel *channel = channels->data;
  gchar *path = g_build_filename (
    g_get_user_config_dir (),
    "phoenix",
    "auth",
    NULL);
  GFile *file = g_file_new_for_path (path);
  GFileIOStream *stream;
  GDataInputStream *input = NULL;
  char *password = NULL;
  char *line;

  if (g_list_length (channels) != 1)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "Can only handle one channel at a time" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  stream = g_file_open_readwrite (file, NULL, NULL);

  if (stream == NULL)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "No authenication data stored" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  input = g_data_input_stream_new (
    g_io_stream_get_input_stream (G_IO_STREAM (stream)));
  while ((line = g_data_input_stream_read_line_utf8 (input, NULL, NULL, NULL))
      != NULL)
    {
      gchar **r = g_strsplit (line, " ", 2);
      if (r[0] == NULL || r[1] == NULL)
        continue;

      if (!tp_strdiff (r[0], tp_account_get_path_suffix (account)))
        {
          password = g_strdup (r[1]);
          printf ("Found password: %s\n", password);
          g_strfreev(r);
          break;
        }
      g_strfreev(r);
    }
  g_object_unref (input);

  if (password == NULL)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "No authenication data stored for this account" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  tp_handle_channels_context_accept (handler_context);

  tp_cli_channel_interface_sasl_authentication_connect_to_sasl_status_changed
    (channel, sasl_status_changed_cb, NULL, NULL, NULL, NULL);
  provide_password (channel, password);

out:
  g_free (path);
  g_free (password);
}