static void
account_manager_ready_for_accounts_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_clear_error (&error);
      return;
    }

  account_manager_prepared = TRUE;

  if (selected_account_name != NULL)
    {
      gchar *account_path;
      TpAccount *account = NULL;
      TpDBusDaemon *bus;

      /* create and prep the corresponding TpAccount so it's fully ready by the
       * time we try to select it in the accounts dialog */
      if (g_str_has_prefix (selected_account_name, TP_ACCOUNT_OBJECT_PATH_BASE))
        account_path = g_strdup (selected_account_name);
      else
        account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
            selected_account_name);

      bus = tp_dbus_daemon_dup (NULL);
      if ((account = tp_account_new (bus, account_path, &error)))
        {
          tp_proxy_prepare_async (account, NULL, account_prepare_cb, manager);
          g_object_unref (bus);
          return;
        }
      else
        {
          DEBUG ("Failed to find account with path %s: %s", account_path,
              error->message);
          g_clear_error (&error);

          maybe_show_accounts_ui (manager);
        }

      g_object_unref (bus);
      g_free (account_path);
    }
  else
    {
      maybe_show_accounts_ui (manager);
    }
}
Example #2
0
static void
account_manager_ready_for_accounts_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  GApplication *app = G_APPLICATION (user_data);

  if (!tp_proxy_prepare_finish (manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_clear_error (&error);
      goto out;
    }

  if (selected_account_name != NULL)
    {
      gchar *account_path;
      TpAccount *account;

      /* create and prep the corresponding TpAccount so it's fully ready by the
       * time we try to select it in the accounts dialog */
      if (g_str_has_prefix (selected_account_name, TP_ACCOUNT_OBJECT_PATH_BASE))
        account_path = g_strdup (selected_account_name);
      else
        account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
            selected_account_name);

      account = find_account (manager, account_path);

      if (account != NULL)
        {
          empathy_accounts_show_accounts_ui (manager, account, app);
          goto out;
        }
      else
        {
          DEBUG ("Failed to find account with path %s", account_path);

          g_clear_error (&error);

          maybe_show_accounts_ui (manager, app);
        }

      g_free (account_path);
    }
  else
    {
      maybe_show_accounts_ui (manager, app);
    }

out:
  g_application_release (app);
}
Example #3
0
static void
account_manager_ready_for_accounts_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  const gchar *account_id = (const gchar*) user_data;
  GError *error = NULL;

  if (!tp_account_manager_prepare_finish (manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_clear_error (&error);
      return;
    }

  if (account_id != NULL)
    {
      gchar *account_path;
      TpAccount *account = NULL;
      TpDBusDaemon *bus;

      /* create and prep the corresponding TpAccount so it's fully ready by the
       * time we try to select it in the accounts dialog */
      account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
          account_id);
      bus = tp_dbus_daemon_dup (NULL);
      if ((account = tp_account_new (bus, account_path, &error)))
        {
          tp_account_prepare_async (account, NULL, account_prepare_cb, manager);
          return;
        }
      else
        {
          DEBUG ("Failed to find account with path %s: %s", account_path,
              error->message);
          g_clear_error (&error);
        }

      g_object_unref (bus);
      g_free (account_path);
    }
  else
    {
      if (empathy_import_mc4_has_imported ())
        {
          maybe_show_accounts_ui (manager);
        }
      else
        {
          EmpathyConnectionManagers *cm_mgr =
            empathy_connection_managers_dup_singleton ();

          empathy_connection_managers_prepare_async (
            cm_mgr, cm_manager_prepared_cb, manager);
        }
    }
}
Example #4
0
static void
cm_manager_prepared_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  if (!empathy_connection_managers_prepare_finish (
      EMPATHY_CONNECTION_MANAGERS (source), result, NULL))
    {
      g_warning ("Failed to prepare connection managers singleton");
      gtk_main_quit ();
      return;
    }

  empathy_accounts_import (TP_ACCOUNT_MANAGER (user_data),
    EMPATHY_CONNECTION_MANAGERS (source));

  maybe_show_accounts_ui (TP_ACCOUNT_MANAGER (user_data));
}