static void
am_prepare_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyConnectionAggregator *self = EMPATHY_CONNECTION_AGGREGATOR (user_data);
  GError *error = NULL;
  GList *accounts, *l;

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

  accounts = tp_account_manager_get_valid_accounts (self->priv->mgr);
  for (l = accounts; l != NULL; l = g_list_next (l))
    {
      TpAccount *account = l->data;

      add_account (self, account);
    }

  tp_g_signal_connect_object (self->priv->mgr, "account-validity-changed",
      G_CALLBACK (account_validity_changed_cb), self, 0);

  g_list_free (accounts);

out:
  g_object_unref (self);
}
static void
contact_blocking_dialog_am_prepared (GObject *am,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyContactBlockingDialog *self = user_data;
  GList *accounts, *ptr;
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (am, result, &error))
    {
      g_critical ("Could not prepare Account Manager: %s", error->message);
      g_error_free (error);
      return;
    }

  accounts = tp_account_manager_get_valid_accounts (TP_ACCOUNT_MANAGER (am));

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

      tp_g_signal_connect_object (account, "status-changed",
          G_CALLBACK (contact_blocking_dialog_connection_status_changed),
          self, 0);

      contact_blocking_dialog_refilter_account_chooser (self);
    }

  g_list_free (accounts);
}
Ejemplo n.º 3
0
static void
conn_ready (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GError *error = NULL;
  TpConnection *conn = TP_CONNECTION (source);

  if (!tp_proxy_prepare_finish (conn, result, &error))
    {
      g_warning ("%s", error->message);
      g_main_loop_quit (mainloop);
      g_clear_error (&error);
      return;
    }

  if (!tp_proxy_has_interface_by_id (conn,
        EXAMPLE_IFACE_QUARK_CONNECTION_INTERFACE_HATS))
    {
      g_warning ("Connection does not support Hats interface");
      g_main_loop_quit (mainloop);
      return;
    }

  /* Get contact object for someone else */
  tp_connection_dup_contact_by_id_async (conn, "other@server", 0, NULL,
      contact_ready_cb, NULL);
}
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_proxy_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);
    }
}
static void
proxy_prepared_cb (GObject      *object,
                   GAsyncResult *res,
                   gpointer      user_data)
{
  PrepareTpProxyData *data = user_data;

  data->ret = tp_proxy_prepare_finish (object, res, &data->error);
  g_main_loop_quit (data->loop);
}
Ejemplo n.º 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);
  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);
    }
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
static void
manager_prepared_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  TpWeakRef *wr = user_data;
  EmpathyAppPluginWidget *self = tp_weak_ref_dup_object (wr);
  TpAccountManager *manager = (TpAccountManager *) source;
  GList *accounts;
  GError *error = NULL;

  if (self == NULL)
    {
      tp_weak_ref_destroy (wr);
      return;
    }

  if (!tp_proxy_prepare_finish (manager, result, &error))
    {
      g_debug ("Error preparing Account Manager: %s", error->message);
      g_clear_error (&error);
      goto out;
    }

  accounts = tp_account_manager_dup_valid_accounts (manager);
  while (accounts != NULL)
    {
      TpAccount *account = accounts->data;
      const GValue *value;

      value = tp_account_get_storage_identifier (account);
      if (G_VALUE_HOLDS_UINT (value) &&
          g_value_get_uint (value) == self->priv->account->id)
        {
          GtkWidget *alig;

          alig = gtk_alignment_new (0.5, 0, 0, 0);
          self->priv->user_info = tpaw_user_info_new (account);
          gtk_container_add (GTK_CONTAINER (alig), self->priv->user_info);
          gtk_widget_show (self->priv->user_info);

          gtk_box_pack_start (GTK_BOX (self), alig, TRUE, TRUE, 0);
          gtk_widget_show (alig);
          break;
        }

      accounts = g_list_delete_link (accounts, accounts);
    }
  g_list_free_full (accounts, g_object_unref);

out:
  tp_weak_ref_destroy (wr);
  g_object_unref (self);
}
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_proxy_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
prepare_connection_cb(GObject* connection, GAsyncResult *res, gpointer user_data)
{
	UT_DEBUGMSG(("prepare_connection_cb()\n"));

	if (!tp_proxy_prepare_finish(connection, res, NULL))
	{
		UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
		return;
	}

	// proceed checking if this connection is usable
	validate_connection(reinterpret_cast<TpConnection*>(connection), user_data);
}
static void
connection_contact_info_prepared_cb (GObject *object,
    GAsyncResult *res,
    gpointer user_data)
{
  TpawUserInfo *self = user_data;

  if (!tp_proxy_prepare_finish (object, res, NULL))
    return;

  reload_contact_info (self);

  g_object_unref (self);
}
Ejemplo n.º 12
0
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 *self = user_data;
  GError *error = NULL;

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

  accounts = tp_account_manager_dup_valid_accounts (manager);

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

      account_chooser_account_add_foreach (account, self);

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

      /* We generally use the TpConnection from the account to filter it so,
       * just relying on the account status is not enough. In some case we the
       * status change can be notified while the TpConnection is still
       * preparing. */
      tp_g_signal_connect_object (account, "notify::connection",
          G_CALLBACK (account_connection_notify_cb),
          self, 0);
    }

  g_list_free_full (accounts, g_object_unref);

  if (self->priv->select_when_ready != NULL)
    {
      select_account (self, self->priv->select_when_ready);

      g_clear_object (&self->priv->select_when_ready);
    }

  self->priv->ready = TRUE;
  g_signal_emit (self, signals[READY], 0);
}
Ejemplo n.º 13
0
static void
account_manager_prepare_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GError *error = NULL;
  GtkWidget *window;

  tp_proxy_prepare_finish (source, result, &error);
  g_assert_no_error (error);

  window = empathy_log_window_show (NULL, NULL, FALSE, NULL);

  g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL);
}
Ejemplo n.º 14
0
gboolean
tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy,
    const GQuark *features,
    GError **error)
{
  GAsyncResult *result = NULL;
  gboolean r;

  tp_proxy_prepare_async (proxy, features, tp_tests_result_ready_cb, &result);

  tp_tests_run_until_result (&result);

  r =  tp_proxy_prepare_finish (proxy, result, error);
  g_object_unref (result);
  return r;
}
static void
account_prepared_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccount *account = TP_ACCOUNT (source_object);
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (account, result, &error))
    {
      g_print ("failed to prepare account: %s\n", error->message);
      g_clear_error (&error);
      getoutofhere ();
      return;
    }

  got_account (account);
}
static void
tls_certificate_prepared_cb (GObject *source,
                             GAsyncResult *result,
                             gpointer user_data)
{
    TpTLSCertificate *certificate = TP_TLS_CERTIFICATE (source);
    EmpathyServerTLSHandler *self = user_data;
    GError *error = NULL;
    EmpathyServerTLSHandlerPriv *priv = GET_PRIV (self);

    if (!tp_proxy_prepare_finish (certificate, result, &error))
    {
        g_simple_async_result_set_from_error (priv->async_init_res, error);
        g_error_free (error);
    }

    g_simple_async_result_complete_in_idle (priv->async_init_res);
    tp_clear_object (&priv->async_init_res);
}
static void
channel_prepared (GObject *proxy, GAsyncResult *prepare_res, gpointer user_data)
{
  GSimpleAsyncResult *res = user_data;
  TfCallChannel *self =
      TF_CALL_CHANNEL (g_async_result_get_source_object (G_ASYNC_RESULT (res)));
  GError *error = NULL;
  GPtrArray *contents;
  guint i;

  if (!tp_proxy_prepare_finish (proxy, prepare_res, &error))
    {
      g_warning ("Preparing the channel: %s",
          error->message);
      g_simple_async_result_take_error (res, error);
      goto out;
    }

  if (tp_call_channel_has_hardware_streaming (TP_CALL_CHANNEL (proxy)))
    {
      g_warning ("Hardware streaming property is TRUE, ignoring");

      g_simple_async_result_set_error (res, TP_ERROR, TP_ERROR_NOT_CAPABLE,
          "This channel does hardware streaming, not handled here");
      goto out;
    }

  contents = tp_call_channel_get_contents (TP_CALL_CHANNEL (proxy));

  self->contents = g_ptr_array_new_with_free_func (free_content);

  for (i = 0; i < contents->len; i++)
    if (!add_content (self, g_ptr_array_index (contents, i)))
      break;

  g_simple_async_result_set_op_res_gboolean (res, TRUE);

out:
  g_simple_async_result_complete (res);
  g_object_unref (res);
  g_object_unref (self);
}
Ejemplo n.º 18
0
static void
connection_ready (GObject      *source,
                  GAsyncResult *result,
                  gpointer      user_data)
{
    ChVisitor *self = (ChVisitor*) user_data;
    TpConnection *connection = TP_CONNECTION (source);
    GError *error = NULL;

    if (!tp_proxy_prepare_finish (source, result, &error)) {
        g_printerr ("error loading connection: %s\n", error->message);
    }

    // Run callback, 0 indicates failure reason
    if (self->visit_connection) {
        self->visit_connection (self, connection, 0);
    }

    ch_visitor_decref (self);
}
Ejemplo n.º 19
0
static void
account_prepare_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data);
  TpAccount *account = TP_ACCOUNT (source_object);
  GError *error = NULL;

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

      account = NULL;
    }

  empathy_accounts_show_accounts_ui (manager, account,
      G_CALLBACK (gtk_main_quit));
}
Ejemplo n.º 20
0
static void
_account_manager_ready_cb (TpAccountManager *am,
                           GAsyncResult     *res,
                           gpointer          userdata)
{
  TpConnectionPresenceType type = (TpConnectionPresenceType)GPOINTER_TO_INT (userdata);
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (TP_PROXY (am), res, &error))
  {
    g_warning (G_STRLOC ": Error preparing account manager: %s",
               error->message);
    g_error_free (error);
    return;
  }

  tp_account_manager_set_all_requested_presences (am,
                                                  type,
                                                  NULL,
                                                  NULL);
}
static void
conn_prepared_cb (GObject *conn,
		GAsyncResult *result,
		gpointer user_data)
{
	FilterCallbackData *data = user_data;
	GError             *myerr = NULL;
	TpCapabilities     *caps;

	if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
		data->callback (FALSE, data->user_data);
		g_slice_free (FilterCallbackData, data);
		return;
	}

	caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
	data->callback (tp_capabilities_supports_text_chatrooms (caps),
			data->user_data);

	g_slice_free (FilterCallbackData, data);
}
static void
account_manager_ready_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (user_data);
  EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  GFile *file = NULL;

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

  chatroom_manager_get_all (self);

  /* Set up file monitor */
  file = g_file_new_for_path (priv->file);

  priv->monitor = g_file_monitor (file, 0, NULL, &error);
  if (priv->monitor == NULL)
    {
      DEBUG ("Failed to create file monitor on %s: %s", priv->file,
          error->message);

      g_error_free (error);
      goto out;
    }

  g_signal_connect (priv->monitor, "changed", G_CALLBACK (file_changed_cb),
      self);

out:
  tp_clear_object (&file);
  g_object_unref (self);
}
Ejemplo n.º 23
0
static void
chat_conversations_list_account_manager_prepare (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  ChatConversationsList *self = CHAT_CONVERSATIONS_LIST (user_data);
  ChatConversationsListPrivate *priv = self->priv;
  GError *error;
  GList *accounts = NULL;
  GList *l;

  error = NULL;
  if (!tp_proxy_prepare_finish (source_object, res, &error))
    {
      g_warning ("Unable to prepare the account manager: %s", error->message);
      g_error_free (error);
      goto out;
    }

  accounts = tp_account_manager_dup_valid_accounts (priv->am);
  for (l = accounts; l != NULL; l = l->next)
    {
      TpAccount *account = TP_ACCOUNT (l->data);
      TpConnection *conn;
      const gchar *cm_name;

      cm_name = tp_account_get_cm_name (account);
      if (g_strcmp0 (cm_name, "idle") == 0)
        continue;

      conn = tp_account_get_connection (account);
      if (conn == NULL)
        continue;

      tp_proxy_prepare_async (conn, NULL, chat_conversations_list_connection_prepare, g_object_ref (self));
      g_hash_table_insert (priv->accounts, g_object_ref (account), NULL);
    }

 out:
  g_list_free_full (accounts, g_object_unref);
  g_object_unref (self);
}
static void
_account_manager_ready (TpAccountManager *am,
                        GAsyncResult     *res,
                        gpointer          user_data)
{
    AnerleyPresenceChooser *self = user_data;
    AnerleyPresenceChooserPrivate *priv = GET_PRIVATE (self);
    GError *error = NULL;

    if (!tp_proxy_prepare_finish (TP_PROXY (am), res, &error))
    {
        g_warning (G_STRLOC ": Error preparing account manager: %s",
                   error->message);
        g_error_free (error);
        return;
    }

    priv->presence = tp_account_manager_get_most_available_presence (priv->am,
                     NULL,
                     NULL);
    update_combox_index (self);
}
Ejemplo n.º 25
0
static void
am_prepared_cb (GObject *object,
                GAsyncResult *result,
                gpointer user_data)
{
  MnbPeoplePanel *self= user_data;
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);
  GList *accounts;
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (object, result, &error))
  {
    g_warning ("Error preparing the TpAccountManager: %s", error->message);
    g_clear_error (&error);
    return;
  }

  g_signal_connect (priv->am,
                    "account-validity-changed",
                    (GCallback)_account_validity_changed_cb,
                    self);
  g_signal_connect_swapped (priv->am,
                    "most-available-presence-changed",
                    (GCallback)_update_presence_message,
                    self);

  accounts = tp_account_manager_get_valid_accounts (priv->am);
  while (accounts != NULL)
  {
    tp_g_signal_connect_object (accounts->data, "status-changed",
                                G_CALLBACK (_account_status_changed_cb),
                                self, 0);
    accounts = g_list_delete_link (accounts, accounts);
  }

  _update_placeholder_state (self);
  _update_presence_chooser_state (self);
  _update_presence_message (self);
}
Ejemplo n.º 26
0
static void
channel_prepared_cb (
    GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  TpFileTransferChannel *channel = TP_FILE_TRANSFER_CHANNEL (source);
  CallbacksData *cb_data = user_data;
  EmpathyFTHandler *handler = cb_data->handler;
  EmpathyFTHandlerPriv *priv = handler->priv;
  GHashTable *properties;
  GError *error = NULL;

  if (!tp_proxy_prepare_finish (channel, result, &error))
    {
      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      cb_data->callback (handler, error, cb_data->user_data);
      g_clear_error (&error);
      callbacks_data_free (cb_data);
      return;
    }
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  properties = tp_channel_borrow_immutable_properties (TP_CHANNEL (channel));
  #pragma GCC diagnostic pop

  priv->content_hash = g_strdup (
      tp_asv_get_string (properties, "ContentHash"));

  priv->content_hash_type = tp_asv_get_uint32 (
      properties, "ContentHashType", NULL);

  priv->contact = g_object_ref (tp_channel_get_target_contact (TP_CHANNEL (channel)));

  cb_data->callback (handler, NULL, cb_data->user_data);
}
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_proxy_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);
}
Ejemplo n.º 28
0
static void
on_channel_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
    TpChannel *tp_chan = TP_CHANNEL (source_object);
    McdChannel *channel, **channel_ptr = user_data;
    McdChannelPrivate *priv;
    gboolean requested, valid;
    GError *error = NULL;

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

    channel = *channel_ptr;
    if (channel)
	g_object_remove_weak_pointer ((GObject *)channel,
				      (gpointer)channel_ptr);
    g_slice_free (McdChannel *, channel_ptr);
    if (error)
    {
        DEBUG ("got error: %s", error->message);
	return;
    }

    if (!channel) return;

    DEBUG ("channel %p is ready", channel);
    priv = channel->priv;
    requested = tp_asv_get_boolean
        (tp_channel_borrow_immutable_properties (tp_chan),
         TP_IFACE_CHANNEL ".Requested", &valid);
    if (valid)
        priv->outgoing = requested;
}
Ejemplo n.º 29
0
Archivo: msg.c Proyecto: keis/charlatan
static void
channel_ready (GObject      *source,
               GAsyncResult *result,
               gpointer      user_data)
{
    ChVisitor *visitor = (ChVisitor*) user_data;
    TpChannel *channel;
    const gchar *ident;
    TpMessage *message;

    GError *error = NULL;
    if (!tp_proxy_prepare_finish (source, result, &error)) {
        g_printerr ("error loading channel: %s\n", error->message);
        return;
    }

    channel = TP_CHANNEL (source);
    ident = tp_channel_get_identifier (channel);

    if (verbose > 0) {
        g_printerr ("channel ready \"%s\" (type %s)\n",
                    ident,
                    tp_channel_get_channel_type (channel));
    }

    GList *messages, *iter;
    if (TP_IS_TEXT_CHANNEL (channel)) {
        messages = tp_text_channel_dup_pending_messages (
             TP_TEXT_CHANNEL (channel));

        for (iter = messages; iter; iter = iter->next) {
            TpMessage *message = TP_MESSAGE (iter->data);
            message_cb (message);
        }

        if (acknowledge) {
            tp_text_channel_ack_messages_async (TP_TEXT_CHANNEL (channel),
                                                messages,
                                                ack_messages_cb,
                                                NULL);
        }

        g_list_free_full (messages, g_object_unref);

        if (send_message && !has_sent_message_to (ident)) {
            message = tp_client_message_new_text(0, msg_buffer);
            g_ptr_array_add (messages_sent, g_strdup (ident));
            ch_visitor_incref (visitor);
            tp_text_channel_send_message_async (TP_TEXT_CHANNEL (channel),
                                                message,
                                                0,
                                                send_message_cb,
                                                visitor);
        }
    } else {
        g_printerr ("error loading channel: %s is not a text channel\n",
                    tp_channel_get_identifier (channel));
    }

    ch_visitor_decref (visitor);
}
Ejemplo n.º 30
0
static void
chat_conversations_list_connection_prepare (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  ChatConversationsList *self = CHAT_CONVERSATIONS_LIST (user_data);
  ChatConversationsListPrivate *priv = self->priv;
  GError *error;
  GList *contacts = NULL;
  GPtrArray *contact_list = NULL;
  TpAccount *account;
  TpConnection *conn = TP_CONNECTION (source_object);
  TpContactListState state;
  guint i;

  error = NULL;
  if (!tp_proxy_prepare_finish (source_object, res, &error))
    {
      g_warning ("Unable to prepare the connection: %s", error->message);
      g_error_free (error);
      goto out;
    }

  state = tp_connection_get_contact_list_state (conn);
  if (state != TP_CONTACT_LIST_STATE_SUCCESS)
    {
      g_warning ("Value of connection:contact-list-state %p was %d", conn, state);
      goto out;
    }

  account = tp_connection_get_account (conn);
  contact_list = tp_connection_dup_contact_list (conn);
  for (i = 0; i < contact_list->len; i++)
    {
      ChatConversationsListGetFilteredEventsData *data;
      TpContact *contact;
      TplEntity *entity;

      contact = TP_CONTACT (g_ptr_array_index (contact_list, i));
      entity = tpl_entity_new_from_tp_contact (contact, TPL_ENTITY_CONTACT);
      if (tpl_log_manager_exists (priv->lm, account, entity, TPL_EVENT_MASK_TEXT))
        {
          g_message ("%s", tp_contact_get_alias (contact));
          contacts = g_list_prepend (contacts, g_object_ref (contact));

          data = chat_conversations_list_get_filtered_events_data_new (self, contact);
          tpl_log_manager_get_filtered_events_async (priv->lm,
                                                     account,
                                                     entity,
                                                     TPL_EVENT_MASK_TEXT,
                                                     1,
                                                     NULL,
                                                     NULL,
                                                     chat_conversations_list_get_filtered_events,
                                                     data);
        }

      g_object_unref (entity);
    }

  g_hash_table_insert (priv->accounts, g_object_ref (account), contacts);

 out:
  if (contact_list != NULL)
    g_ptr_array_unref (contact_list);
  g_object_unref (self);
}