static void
new_chatroom_dialog_select_last_account (GSettings             *gsettings,
                                         EmpathyAccountChooser *account_chooser)
{
	const gchar          *account_path;
	TpAccountManager      *manager;
	TpSimpleClientFactory *factory;
	TpAccount             *account;
	TpConnectionStatus    status;

	account_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT);
	DEBUG ("Selecting account path '%s'", account_path);

	manager =  tp_account_manager_dup ();
	factory = tp_proxy_get_factory (manager);
	account = tp_simple_client_factory_ensure_account (factory,
	                                                   account_path,
	                                                   NULL,
	                                                   NULL);

	if (account != NULL) {
		status = tp_account_get_connection_status (account, NULL);
		if (status == TP_CONNECTION_STATUS_CONNECTED) {
			empathy_account_chooser_set_account (account_chooser,
			                                     account);
		}
		g_object_unref (account);
	}
	g_object_unref (manager);
}
Ejemplo n.º 2
0
static void
empathy_account_chooser_init (EmpathyAccountChooser *self)
{
  TpSimpleClientFactory *factory;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
    EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserPriv);

  self->priv->set_active_item = FALSE;
  self->priv->account_manually_set = FALSE;
  self->priv->filter = NULL;
  self->priv->filter_data = NULL;

  self->priv->manager = tp_account_manager_dup ();

  tp_g_signal_connect_object (self->priv->manager, "account-validity-changed",
      G_CALLBACK (account_chooser_account_validity_changed_cb), self, 0);

  tp_g_signal_connect_object (self->priv->manager, "account-removed",
      G_CALLBACK (account_chooser_account_removed_cb), self, 0);

  /* Make sure we'll have the capabilities feature on TpAccount's connection */
  factory = tp_proxy_get_factory (self->priv->manager);

  tp_simple_client_factory_add_account_features_varargs (factory,
      TP_ACCOUNT_FEATURE_CONNECTION, NULL);
  tp_simple_client_factory_add_connection_features_varargs (factory,
      TP_CONNECTION_FEATURE_CAPABILITIES, NULL);
}
Ejemplo n.º 3
0
int
main (int argc,
      char **argv)
{
  TpAccountManager *manager;
  TpSimpleClientFactory *factory;
  TpBaseClient *approver;
  GError *error = NULL;

  gtk_init (&argc, &argv);
  tp_debug_set_flags (g_getenv ("LIBO_APPROVER_DEBUG"));

  manager = tp_account_manager_dup ();

    factory = tp_proxy_get_factory (manager);
    /* We want the target contact on channels to be available... */
    tp_simple_client_factory_add_channel_features_varargs (factory,
        TP_CHANNEL_FEATURE_CONTACTS,
        0);
    /* ...and for it to have its alias and avatar available */
    tp_simple_client_factory_add_contact_features_varargs (factory,
        TP_CONTACT_FEATURE_ALIAS,
        TP_CONTACT_FEATURE_AVATAR_DATA,
        TP_CONTACT_FEATURE_INVALID);

  approver = tp_simple_approver_new_with_am (manager, "LibreOfficeApprover",
      FALSE, add_dispatch_operation_cb, NULL, NULL);

  tp_base_client_take_approver_filter (approver, tp_asv_new (
        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
          TP_IFACE_CHANNEL_TYPE_DBUS_TUBE,
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
          TP_HANDLE_TYPE_CONTACT,
        TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING,
          LIBO_DTUBE_SERVICE,
        NULL));

  if (!tp_base_client_register (approver, &error))
    {
      g_warning ("Failed to register Approver: %s\n", error->message);
      g_error_free (error);
      goto out;
    }

  g_print ("Start approving\n");

  mainloop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (mainloop);
  /* TODO: time out after 5 seconds of inactivity? */

  if (mainloop != NULL)
    g_main_loop_unref (mainloop);

out:
  g_object_unref (manager);
  g_object_unref (approver);

  return 0;
}
Ejemplo n.º 4
0
void
ch_visitor_visit_connection_contact (ChVisitor    *self,
                                     TpConnection *connection,
                                     char         *contact_id)
{
    ch_visitor_incref (self);

    tp_simple_client_factory_ensure_contact_by_id_async (
        tp_proxy_get_factory (connection),
        connection,
        contact_id,
        ensure_contact_by_id_cb,
        self);
}
static void
connection_identified (TpStreamTubeChannel *self,
    GSocketConnection *conn,
    TpHandle handle,
    guint connection_id)
{
  TpStreamTubeConnection *tube_conn;

  tube_conn = _tp_stream_tube_connection_new (conn, self);

  g_hash_table_insert (self->priv->tube_connections,
      GUINT_TO_POINTER (connection_id), tube_conn);

  g_object_weak_ref (G_OBJECT (tube_conn), remote_connection_destroyed_cb,
      self);

  if (can_identify_contact (self))
    {
      TpConnection *connection;
      GArray *features;

      connection = tp_channel_get_connection (TP_CHANNEL (self));
      features = tp_simple_client_factory_dup_contact_features (
          tp_proxy_get_factory (connection), connection);

      /* Spec does not give the id with the handle */
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS
      /* Pass the ref on tube_conn to the function */
      tp_connection_get_contacts_by_handle (connection,
          1, &handle,
          features->len, (TpContactFeature *) features->data,
          _new_remote_connection_with_contact,
          tube_conn, g_object_unref, G_OBJECT (self));
       G_GNUC_END_IGNORE_DEPRECATIONS

      g_array_unref (features);
    }
  else
    {
      g_signal_emit (self, _signals[INCOMING], 0, tube_conn);

      g_object_unref (tube_conn);
    }
}
Ejemplo n.º 6
0
void
ch_visitor_visit_channel_target (ChVisitor *self,
                                 TpChannel *channel)
{
    TpConnection *connection = tp_channel_get_connection (channel);
    TpContact *contact = tp_channel_get_target_contact (channel);
    GPtrArray *contacts = g_ptr_array_new ();

    g_ptr_array_add (contacts, (gpointer) contact);
    ch_visitor_incref (self);
    tp_simple_client_factory_upgrade_contacts_async (
        tp_proxy_get_factory (connection),
        connection,
        contacts->len,
        (TpContact * const *) contacts->pdata,
        contacts_ready,
        self);

    g_ptr_array_free (contacts, TRUE);
}
Ejemplo n.º 7
0
void
ch_visitor_visit_channel_contacts (ChVisitor *self,
                                   TpChannel *channel)
{
    TpConnection *connection = tp_channel_get_connection (channel);
    GPtrArray *contacts = tp_channel_group_dup_members_contacts (channel);

    if (contacts->len > 0) {
        ch_visitor_incref (self);
        tp_simple_client_factory_upgrade_contacts_async (
            tp_proxy_get_factory (connection),
            connection,
            contacts->len,
            (TpContact * const *) contacts->pdata,
            contacts_ready,
            self);
    }

    g_ptr_array_free (contacts, TRUE);
}
static void
new_local_connection_identified (TpStreamTubeChannel *self,
    GSocketConnection *conn,
    guint connection_id)
{
  TpHandle initiator_handle;
  TpStreamTubeConnection *tube_conn;
  TpConnection *connection;
  GArray *features;

  tube_conn = _tp_stream_tube_connection_new (conn, self);

  g_hash_table_insert (self->priv->tube_connections,
      GUINT_TO_POINTER (connection_id), tube_conn);

  g_object_weak_ref (G_OBJECT (tube_conn), remote_connection_destroyed_cb,
      self);

  /* We are accepting a tube so the contact of the connection is the
   * initiator of the tube */
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  initiator_handle = tp_channel_get_initiator_handle (TP_CHANNEL (self));

  connection = tp_channel_get_connection (TP_CHANNEL (self));
  features = tp_simple_client_factory_dup_contact_features (
      tp_proxy_get_factory (connection), connection);

  /* Pass ownership of tube_conn to the function */
  tp_connection_get_contacts_by_handle (connection,
      1, &initiator_handle,
      features->len, (TpContactFeature *) features->data,
      new_local_connection_with_contact,
      tube_conn, g_object_unref, G_OBJECT (self));
  G_GNUC_END_IGNORE_DEPRECATIONS

  g_array_unref (features);
}
static void
empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
{
  GtkBuilder *gui;
  char *filename;
  GtkWidget *contents;
  GtkWidget *account_hbox, *blocked_contacts_view, *blocked_contacts_sw,
      *remove_toolbar;
  GtkEntryCompletion *completion;
  TpAccountManager *am;
  GtkStyleContext *context;
  TpSimpleClientFactory *factory;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
      EmpathyContactBlockingDialogPrivate);

  gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts"));
  gtk_dialog_add_button (GTK_DIALOG (self),
      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);

  filename = empathy_file_lookup ("empathy-contact-blocking-dialog.ui",
      "libempathy-gtk");

  gui = empathy_builder_get_file (filename,
      "contents", &contents,
      "account-hbox", &account_hbox,
      "add-button", &self->priv->add_button,
      "add-contact-entry", &self->priv->add_contact_entry,
      "blocked-contacts", &self->priv->blocked_contacts,
      "blocked-contacts-sw", &blocked_contacts_sw,
      "blocked-contacts-view", &blocked_contacts_view,
      "remove-button", &self->priv->remove_button,
      "remove-toolbar", &remove_toolbar,
      NULL);

  empathy_builder_connect (gui, self,
      "add-button", "clicked", contact_blocking_dialog_add_contact,
      "add-contact-entry", "activate", contact_blocking_dialog_add_contact,
      "remove-button", "clicked", contact_blocking_dialog_remove_contacts,
      NULL);

  /* join the remove toolbar to the treeview */
  context = gtk_widget_get_style_context (blocked_contacts_sw);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
  context = gtk_widget_get_style_context (remove_toolbar);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);

  /* add the contents to the dialog */
  gtk_container_add (
      GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
      contents);
  gtk_widget_show (contents);

  /* set up the tree selection */
  self->priv->selection = gtk_tree_view_get_selection (
      GTK_TREE_VIEW (blocked_contacts_view));
  gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_MULTIPLE);
  g_signal_connect (self->priv->selection, "changed",
      G_CALLBACK (contact_blocking_dialog_view_selection_changed), self);

  /* build the contact entry */
  self->priv->completion_contacts = gtk_list_store_new (N_COMPLETION_COLUMNS,
      G_TYPE_STRING, /* id */
      G_TYPE_STRING, /* text */
      TP_TYPE_CONTACT); /* contact */

  completion = gtk_entry_completion_new ();
  gtk_entry_completion_set_model (completion,
      GTK_TREE_MODEL (self->priv->completion_contacts));
  gtk_entry_completion_set_text_column (completion, COL_COMPLETION_TEXT);
  gtk_entry_completion_set_match_func (completion,
      contact_selector_dialog_match_func,
      NULL, NULL);
  g_signal_connect (completion, "match-selected",
        G_CALLBACK (contact_selector_dialog_match_selected_cb),
        self);
  gtk_entry_set_completion (GTK_ENTRY (self->priv->add_contact_entry),
      completion);
  g_object_unref (completion);
  g_object_unref (self->priv->completion_contacts);

  /* add the account chooser */
  self->priv->account_chooser = empathy_account_chooser_new ();
  contact_blocking_dialog_refilter_account_chooser (self);
  g_signal_connect (self->priv->account_chooser, "changed",
      G_CALLBACK (contact_blocking_dialog_account_changed), self);

  gtk_box_pack_start (GTK_BOX (account_hbox), self->priv->account_chooser,
      TRUE, TRUE, 0);
  gtk_widget_show (self->priv->account_chooser);

  /* add an error warning info bar */
  self->priv->info_bar = gtk_info_bar_new ();
  gtk_box_pack_start (GTK_BOX (contents), self->priv->info_bar, FALSE, TRUE, 0);
  gtk_info_bar_set_message_type (GTK_INFO_BAR (self->priv->info_bar),
      GTK_MESSAGE_ERROR);

  self->priv->info_bar_label = gtk_label_new ("");
  gtk_container_add (GTK_CONTAINER (
        gtk_info_bar_get_content_area (GTK_INFO_BAR (self->priv->info_bar))),
      self->priv->info_bar_label);
  gtk_widget_show (self->priv->info_bar_label);

  /* prepare the account manager */
  am = tp_account_manager_dup ();

  factory = tp_proxy_get_factory (am);
  tp_simple_client_factory_add_connection_features_varargs (factory,
      TP_CONNECTION_FEATURE_CONTACT_BLOCKING, NULL);

  tp_proxy_prepare_async (am, NULL, contact_blocking_dialog_am_prepared, self);
  g_object_unref (am);

  g_free (filename);
  g_object_unref (gui);
}