static void
am_ready_cb (GObject      *source_object,
             GAsyncResult *result,
             gpointer      userdata)

{
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
  AnerleyFeed *feed;
  ClutterActor *stage;
  ClutterActor *scroll_view;
  ClutterActor *icon_view;
  ClutterModel *model;
  GError *error = NULL;

  if (!tp_account_manager_prepare_finish (account_manager, result, &error))
  {
    g_warning ("Failed to make account manager ready: %s", error->message);
    g_error_free (error);
    return;
  }

  feed = ANERLEY_FEED (anerley_aggregate_tp_feed_new ());
  model = CLUTTER_MODEL (anerley_feed_model_new (feed));
  stage = clutter_stage_get_default ();
  icon_view = anerley_tile_view_new (ANERLEY_FEED_MODEL (model));

  scroll_view = mx_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                               CLUTTER_ACTOR (scroll_view));
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view),
                               CLUTTER_ACTOR (icon_view));
  clutter_actor_set_size (CLUTTER_ACTOR (scroll_view), 640, 480);
  clutter_actor_show_all (stage);
}
Exemple #2
0
static void
account_manager_prepared_cb (GObject *source_object,
			     GAsyncResult *result,
			     gpointer user_data)
{
	GList *list, *l;
	TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
	EmpathyStatusIcon *icon = user_data;
	GError *error = NULL;

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

	list = tp_account_manager_get_valid_accounts (account_manager);
	for (l = list; l != NULL; l = l->next) {
		tp_g_signal_connect_object (l->data, "status-changed",
					     G_CALLBACK (status_icon_status_changed_cb),
					     icon, 0);
	}
	g_list_free (list);

	status_icon_presence_changed_cb (icon);
}
static void
account_manager_prepared_cb (GObject *source_object,
			     GAsyncResult *result,
			     gpointer user_data)
{
	GList *accounts, *l;
	TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
	EmpathyAccountChooser *chooser = user_data;
	EmpathyAccountChooserPriv *priv = GET_PRIV (chooser);
	GError *error = NULL;

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

	accounts = tp_account_manager_get_valid_accounts (manager);

	for (l = accounts; l != NULL; l = l->next) {
		TpAccount *account = l->data;

		account_chooser_account_add_foreach (account, chooser);

		tp_g_signal_connect_object (account, "status-changed",
					     G_CALLBACK (account_chooser_status_changed_cb),
					     chooser, 0);
	}

	g_list_free (accounts);

	priv->ready = TRUE;
	g_signal_emit (chooser, signals[READY], 0);
}
static void
account_manager_prepared_cb (GObject *source_object,
			     GAsyncResult *result,
			     gpointer user_data)
{
	TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
	EmpathyLogWindow *window = user_data;
	guint account_num;
	GList *accounts;
	GError *error = NULL;

	if (log_window == NULL)
		return;

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

	accounts = tp_account_manager_get_valid_accounts (account_manager);
	account_num = g_list_length (accounts);
	g_list_free (accounts);

	if (account_num > 1) {
		gtk_widget_show (window->vbox_chats);
		gtk_widget_show (window->account_chooser_chats);
	} else {
		gtk_widget_hide (window->vbox_chats);
		gtk_widget_hide (window->account_chooser_chats);
	}
}
static void
account_manager_prepared_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  EmpathyImportWidget *self = user_data;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GList *l;
  EmpathyImportWidgetPriv *priv = GET_PRIV (self);
  GError *error = NULL;

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

  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));

  for (l = priv->accounts; l; l = l->next)
    {
      GValue *value;
      EmpathyImportAccountData *data = l->data;
      gboolean import;
      GList *accounts;
      TpConnectionManager *cm = NULL;

      if (!empathy_import_protocol_is_supported (data->protocol, &cm))
        continue;

      data->connection_manager = g_strdup (
          tp_connection_manager_get_name (cm));

      value = g_hash_table_lookup (data->settings, "account");

      accounts = tp_account_manager_get_valid_accounts (manager);

      /* Only set the "Import" cell to be active if there isn't already an
       * account set up with the same account id. */
      import = !import_widget_account_id_in_list (accounts,
          g_value_get_string (value));

      g_list_free (accounts);

      gtk_list_store_append (GTK_LIST_STORE (model), &iter);

      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
          COL_IMPORT, import,
          COL_PROTOCOL, data->protocol,
          COL_NAME, g_value_get_string (value),
          COL_SOURCE, data->source,
          COL_ACCOUNT_DATA, data,
          -1);
    }
}
Exemple #6
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);
        }
    }
}
Exemple #7
0
static void
account_manager_chatroom_ready_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
  EmpathyChatroomManager *chatroom_manager = user_data;
  GList *accounts, *l;
  GError *error = NULL;

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

  accounts = tp_account_manager_get_valid_accounts (account_manager);

  for (l = accounts; l != NULL; l = g_list_next (l))
    {
      TpAccount *account = TP_ACCOUNT (l->data);
      TpConnection *conn;
      GList *chatrooms, *p;

      conn = tp_account_get_connection (account);

      chatrooms = empathy_chatroom_manager_get_chatrooms (
          chatroom_manager, account);

      for (p = chatrooms; p != NULL; p = p->next)
        {
          EmpathyChatroom *room = EMPATHY_CHATROOM (p->data);

          if (!empathy_chatroom_get_auto_connect (room))
            continue;

          if (conn == NULL)
            {
              g_signal_connect (G_OBJECT (account), "status-changed",
                  G_CALLBACK (account_status_changed_cb), room);
            }
          else
            {
              empathy_dispatcher_join_muc (conn,
                  empathy_chatroom_get_room (room), NULL, NULL);
            }
        }

      g_list_free (chatrooms);
    }

  g_list_free (accounts);
}
Exemple #8
0
static void
account_manager_ready_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  EmpathyIdle *idle;
  EmpathyConnectivity *connectivity;
  gboolean autoconnect = TRUE;

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

  /* Autoconnect */
  idle = empathy_idle_dup_singleton ();
  connectivity = empathy_connectivity_dup_singleton ();

  empathy_conf_get_bool (empathy_conf_get (),
      EMPATHY_PREFS_AUTOCONNECT, &autoconnect);
  if (autoconnect && !no_connect &&
      tp_connection_presence_type_cmp_availability
          (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
            <= 0)
      /* if current state is Offline, then put it online */
      empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);

  if (should_create_salut_account (manager)
      || !empathy_import_mc4_has_imported ())
    {
      EmpathyConnectionManagers *managers;
      managers = empathy_connection_managers_dup_singleton ();

      if (!check_connection_managers_ready (managers))
        {
          g_signal_connect (managers, "notify::ready",
            G_CALLBACK (connection_managers_ready_cb), NULL);
        }
    }
  else if (!start_hidden)
    {
      maybe_show_account_assistant ();
    }

  g_object_unref (idle);
  g_object_unref (connectivity);
}
static void
migration_account_manager_prepared_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *am = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  GList *accounts, *l;
  GSettings *gsettings;

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

  accounts = tp_account_manager_get_valid_accounts (am);

  for (l = accounts; l != NULL; l = l->next)
    {
      TpAccount *account = TP_ACCOUNT (l->data);
      gchar *dir, *cm;

      tp_account_parse_object_path (tp_proxy_get_object_path (account),
          &cm, NULL, NULL, NULL);

      if (tp_strdiff (cm, "butterfly"))
        {
          g_free (cm);
          continue;
        }

      dir = get_log_dir_for_account (account);
      DEBUG ("Migrating all logs from dir: %s", dir);

      migrate_log_files_in_dir (dir);

      g_free (cm);
      g_free (dir);
    }

  DEBUG ("Finished all migrating");

  gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
  g_settings_set_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED,
      TRUE);
  g_object_unref (gsettings);

  g_list_free (accounts);
}
static void
account_manager_prepared_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;

  if (!tp_account_manager_prepare_finish (account_manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_error_free (error);
      return;
    }
}
Exemple #11
0
static void
account_manager_ready_cb (GObject *source_object,
			  GAsyncResult *result,
			  gpointer user_data)
{
	EmpathyIdle *idle = user_data;
	TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
	EmpathyIdlePriv *priv;
	TpConnectionPresenceType state;
	gchar *status, *status_message;
	GList *accounts, *l;
	GError *error = NULL;

	/* In case we've been finalized before reading this callback */
	if (idle_singleton == NULL)
		return;

	priv = GET_PRIV (idle);
	priv->ready = TRUE;

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

	state = tp_account_manager_get_most_available_presence (priv->manager,
		&status, &status_message);

	idle_presence_changed_cb (account_manager, state, status,
		status_message, idle);

	accounts = tp_account_manager_get_valid_accounts (priv->manager);
	for (l = accounts; l != NULL; l = l->next) {
		empathy_signal_connect_weak (l->data, "status-changed",
					     G_CALLBACK (account_status_changed_cb),
					     G_OBJECT (idle));
	}
	g_list_free (accounts);

	g_free (status);
	g_free (status_message);
}
static void
account_manager_prepared_cb (GObject *source_object,
			     GAsyncResult *result,
			     gpointer user_data)
{
	GList *accounts, *j;
	TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
	EmpathyMainWindow *window = user_data;
	GError *error = NULL;

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

	accounts = tp_account_manager_get_valid_accounts (window->account_manager);
	for (j = accounts; j != NULL; j = j->next) {
		TpAccount *account = TP_ACCOUNT (j->data);
		gulong handler_id;

		handler_id = g_signal_connect (account, "status-changed",
				  G_CALLBACK (main_window_connection_changed_cb),
				  window);
		g_hash_table_insert (window->status_changed_handlers,
				     account, GUINT_TO_POINTER (handler_id));
	}

	g_signal_connect (manager, "account-validity-changed",
			  G_CALLBACK (main_window_account_validity_changed_cb),
			  window);

	main_window_update_status (window);

	/* Disable the "Previous Conversations" menu entry if there is no account */
	gtk_action_set_sensitive (window->view_history,
		g_list_length (accounts) > 0);

	g_list_free (accounts);
}
static void
account_manager_prepared_cb (GObject *source_object,
			     GAsyncResult *result,
			     gpointer user_data)
{
	GList *accounts, *l;
	EmpathyContactManager *manager = user_data;
	TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
	GError *error = NULL;

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

	accounts = tp_account_manager_get_valid_accounts (account_manager);

	for (l = accounts; l != NULL; l = l->next) {
		TpAccount *account = l->data;
		TpConnection *conn = tp_account_get_connection (account);

		if (conn != NULL) {
			contact_manager_status_changed_cb (account, 0, 0, 0,
							   NULL, NULL, manager);
		}

		tp_g_signal_connect_object (account, "status-changed",
		    G_CALLBACK (contact_manager_status_changed_cb),
		    manager, 0);
	}
	g_list_free (accounts);

	tp_g_signal_connect_object (account_manager, "account-validity-changed",
			     G_CALLBACK (contact_manager_validity_changed_cb),
			     manager, 0);
}
Exemple #14
0
static void
create_salut_account_am_ready_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
  EmpathyConnectionManagers *managers = user_data;
  EmpathyAccountSettings  *settings;
  TpConnectionManager *manager;
  const TpConnectionManagerProtocol *protocol;
  EBook      *book;
  EContact   *contact;
  gchar      *nickname = NULL;
  gchar      *first_name = NULL;
  gchar      *last_name = NULL;
  gchar      *email = NULL;
  gchar      *jid = NULL;
  GError     *error = NULL;

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

  if (!should_create_salut_account (account_manager))
    goto out;

  manager = empathy_connection_managers_get_cm (managers, "salut");
  if (manager == NULL)
    {
      DEBUG ("Salut not installed, not making a salut account");
      goto out;
    }

  protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
  if (protocol == NULL)
    {
      DEBUG ("Salut doesn't support local-xmpp!!");
      goto out;
    }

  DEBUG ("Trying to add a salut account...");

  /* Get self EContact from EDS */
  if (!e_book_get_self (&contact, &book, &error))
    {
      DEBUG ("Failed to get self econtact: %s",
          error ? error->message : "No error given");
      g_clear_error (&error);
      goto out;
    }

  settings = empathy_account_settings_new ("salut", "local-xmpp",
      _("People nearby"));

  nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
  first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
  last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME);
  email = e_contact_get (contact, E_CONTACT_EMAIL_1);
  jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1);

  if (!tp_strdiff (nickname, "nickname"))
    {
      g_free (nickname);
      nickname = NULL;
    }

  DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n"
     "last-name=%s\nemail=%s\njid=%s\n",
     nickname, first_name, last_name, email, jid);

  empathy_account_settings_set_string (settings,
      "nickname", nickname ? nickname : "");
  empathy_account_settings_set_string (settings,
      "first-name", first_name ? first_name : "");
  empathy_account_settings_set_string (settings,
      "last-name", last_name ? last_name : "");
  empathy_account_settings_set_string (settings, "email", email ? email : "");
  empathy_account_settings_set_string (settings, "jid", jid ? jid : "");

  empathy_account_settings_apply_async (settings,
      salut_account_created, NULL);

  g_free (nickname);
  g_free (first_name);
  g_free (last_name);
  g_free (email);
  g_free (jid);
  g_object_unref (settings);
  g_object_unref (contact);
  g_object_unref (book);

 out:
  g_object_unref (managers);
}