/** * empathy_account_chooser_filter_supports_multichat: * @account: a #TpAccount * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result * @callback_data: data passed to the @callback * @user_data: user data or %NULL * * An #EmpathyAccountChooserFilterFunc that returns accounts that both * support multiuser text chat and are connected. * * Returns (via the callback) TRUE if @account both supports muc and is connected */ void empathy_account_chooser_filter_supports_chatrooms ( TpAccount *account, EmpathyAccountChooserFilterResultCallback callback, gpointer callback_data, gpointer user_data) { TpConnection *connection; FilterCallbackData *cb_data; GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; if (tp_account_get_connection_status (account, NULL) != TP_CONNECTION_STATUS_CONNECTED) { callback (FALSE, callback_data); return; } /* check if CM supports multiuser text chat */ connection = tp_account_get_connection (account); if (connection == NULL) { callback (FALSE, callback_data); return; } cb_data = g_slice_new0 (FilterCallbackData); cb_data->callback = callback; cb_data->user_data = callback_data; tp_proxy_prepare_async (connection, features, conn_prepared_cb, cb_data); }
int main (int argc, char **argv) { EmpathyClientFactory *factory; TpAccountManager *am; GMainLoop *loop; gtk_init (&argc, &argv); empathy_gtk_init (); /* The blocking dialog needs the contact list for the contacts completion * so we prepare it first. */ factory = empathy_client_factory_dup (); tp_simple_client_factory_add_connection_features_varargs ( TP_SIMPLE_CLIENT_FACTORY (factory), TP_CONNECTION_FEATURE_CONTACT_LIST, NULL); am = tp_account_manager_dup (); loop = g_main_loop_new (NULL, FALSE); tp_proxy_prepare_async (am, NULL, am_prepare_cb, loop); g_main_loop_run (loop); g_object_unref (am); return 0; }
static void anerley_presence_chooser_init (AnerleyPresenceChooser *self) { MxComboBox *combo = MX_COMBO_BOX (self); AnerleyPresenceChooserPrivate *priv = GET_PRIVATE (self); priv->am = tp_account_manager_dup (); g_signal_connect (priv->am, "most-available-presence-changed", G_CALLBACK (_account_manager_presence_changed), self); priv->combo_entries = g_array_sized_new (FALSE, TRUE, sizeof (ComboEntry), 7); /* add some entries */ _append_presence (combo, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); _append_presence (combo, TP_CONNECTION_PRESENCE_TYPE_BUSY); _append_presence (combo, TP_CONNECTION_PRESENCE_TYPE_AWAY); _append_presence (combo, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); /* FIXME: Hidden ? */ g_signal_connect (self, "notify::index", G_CALLBACK (_combo_index_changed), NULL); tp_proxy_prepare_async (TP_PROXY (priv->am), NULL, (GAsyncReadyCallback)_account_manager_ready, self); }
static void tf_call_channel_init_async (GAsyncInitable *initable, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { TfCallChannel *self = TF_CALL_CHANNEL (initable); GSimpleAsyncResult *res; if (cancellable != NULL) { g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, "TfCallChannel initialisation does not support cancellation"); return; } res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, tf_call_channel_init_async); tp_g_signal_connect_object (self->proxy, "content-added", G_CALLBACK (content_added), self, 0); tp_g_signal_connect_object (self->proxy, "content-removed", G_CALLBACK (content_removed), self, 0); tp_proxy_prepare_async (self->proxy, NULL, channel_prepared, res); }
static void empathy_app_plugin_widget_constructed (GObject *object) { EmpathyAppPluginWidget *self = EMPATHY_APP_PLUGIN_WIDGET (object); void (*chain_up) (GObject *) = ((GObjectClass *) empathy_app_plugin_widget_parent_class)->constructed; GtkWidget *top; TpAccountManager *manager; if (chain_up != NULL) chain_up (object); g_assert (AG_IS_ACCOUNT (self->priv->account)); /* Top bar */ top = create_top_bar (self); gtk_widget_show (top); gtk_box_pack_start (GTK_BOX (self), top, FALSE, FALSE, 0); /* Prepare tp's account manager to find the TpAccount corresponding to our * AgAccount */ manager = tp_account_manager_dup (); tp_proxy_prepare_async (manager, NULL, manager_prepared_cb, tp_weak_ref_new (self, NULL, NULL)); g_object_unref (manager); }
int main (int argc, char **argv) { TpAccount *account; gchar *path; if (argc < 2) { g_print ("usage: %s [account]\n", argv[0]); return 1; } g_type_init (); am = tp_yts_account_manager_dup (); path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE, argv[1]); account = tp_yts_account_manager_ensure_account (am, path, NULL); g_free (path); tp_proxy_prepare_async (account, NULL, account_prepared_cb, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_main_loop_unref (loop); g_object_unref (account); g_object_unref (am); return 0; }
static void connection_list_cb (GObject *source, GAsyncResult *result, gpointer user_data) { ChVisitor *self = (ChVisitor*) user_data; GError *error = NULL; GPtrArray *connections; if (!list_connections_finish (source, result, &connections, &error)) { g_printerr ("error listing connections: %s\n", error->message); ch_visitor_decref (self); return; } for (unsigned int i = 0; i < connections->len; i++) { TpConnection *connection = g_ptr_array_index (connections, i); ch_visitor_incref (self); tp_proxy_prepare_async (connection, NULL, connection_ready, user_data); tp_cli_connection_call_get_status (connection, -1, connection_status, user_data, NULL, NULL); } g_ptr_array_free (connections, TRUE); ch_visitor_decref (self); }
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); } }
static void empathy_connection_aggregator_init (EmpathyConnectionAggregator *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_CONNECTION_AGGREGATOR, EmpathyConnectionAggregatorPriv); self->priv->mgr = tp_account_manager_dup (); tp_proxy_prepare_async (self->priv->mgr, NULL, am_prepare_cb, g_object_ref (self)); }
static void changed_accounts (TpConnectionPresenceType type) { TpAccountManager *am; am = tp_account_manager_dup (); tp_proxy_prepare_async (TP_PROXY (am), NULL, (GAsyncReadyCallback)_account_manager_ready_cb, GINT_TO_POINTER (type)); g_object_unref (am); }
static void import_widget_add_accounts_to_model (EmpathyImportWidget *self) { TpAccountManager *manager; manager = tp_account_manager_dup (); tp_proxy_prepare_async (manager, NULL, account_manager_prepared_cb, self); g_object_unref (manager); }
static void account_chooser_constructed (GObject *object) { EmpathyAccountChooser *self = (EmpathyAccountChooser *) object; GtkListStore *store; GtkCellRenderer *renderer; GtkComboBox *combobox; if (G_OBJECT_CLASS (empathy_account_chooser_parent_class)->constructed) G_OBJECT_CLASS (empathy_account_chooser_parent_class)->constructed (object); /* Set up combo box with new store */ combobox = GTK_COMBO_BOX (self); gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox)); store = gtk_list_store_new (COL_ACCOUNT_COUNT, GDK_TYPE_PIXBUF, /* Image */ G_TYPE_STRING, /* Name */ G_TYPE_BOOLEAN, /* Enabled */ G_TYPE_UINT, /* Row type */ TP_TYPE_ACCOUNT); gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), account_cmp, self, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "pixbuf", COL_ACCOUNT_IMAGE, "sensitive", COL_ACCOUNT_ENABLED, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", COL_ACCOUNT_TEXT, "sensitive", COL_ACCOUNT_ENABLED, NULL); /* Populate accounts */ tp_proxy_prepare_async (self->priv->manager, NULL, account_manager_prepared_cb, self); g_object_unref (store); }
static void empathy_contact_manager_init (EmpathyContactManager *manager) { EmpathyContactManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv); TpDBusDaemon *bus; GError *error = NULL; manager->priv = priv; priv->lists = g_hash_table_new_full (empathy_proxy_hash, empathy_proxy_equal, (GDestroyNotify) g_object_unref, (GDestroyNotify) g_object_unref); priv->favourites = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_unref); priv->account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (priv->account_manager, NULL, account_manager_prepared_cb, manager); bus = tp_dbus_daemon_dup (&error); if (error == NULL) { priv->logger = g_object_new (TP_TYPE_PROXY, "bus-name", "org.freedesktop.Telepathy.Logger", "object-path", "/org/freedesktop/Telepathy/Logger", "dbus-daemon", bus, NULL); g_object_unref (bus); tp_proxy_add_interface_by_id (priv->logger, EMP_IFACE_QUARK_LOGGER); logger_favourite_contacts_setup (manager); priv->favourite_contacts_changed_signal = emp_cli_logger_connect_to_favourite_contacts_changed ( priv->logger, logger_favourite_contacts_changed_cb, NULL, NULL, G_OBJECT (manager), NULL); } else { DEBUG ("Failed to get telepathy-logger proxy: %s", error->message); g_clear_error (&error); } }
static gboolean migrate_logs (gpointer data) { TpAccountManager *account_manager; account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (account_manager, NULL, migration_account_manager_prepared_cb, NULL); g_object_unref (account_manager); return FALSE; }
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 app_activate (GApplication *app) { TpAccountManager *account_manager; empathy_gtk_init (); account_manager = tp_account_manager_dup (); /* Hold the application while preparing the AM */ g_application_hold (app); tp_proxy_prepare_async (account_manager, NULL, account_manager_ready_for_accounts_cb, app); g_object_unref (account_manager); }
static void list_connection_names_cb (const gchar * const *bus_names, gsize n, const gchar * const * cms, const gchar * const * protocols, const GError *error, gpointer user_data, GObject * /*unused*/) { UT_DEBUGMSG(("list_connection_names_cb()\n")); TelepathyAccountHandler* pHandler = reinterpret_cast<TelepathyAccountHandler*>(user_data); UT_return_if_fail(pHandler); if (error != NULL) { UT_DEBUGMSG(("List connectiones failed: %s", error->message)); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } TpDBusDaemon* dbus = tp_dbus_daemon_dup(NULL); UT_return_if_fail(dbus); UT_DEBUGMSG(("Got %d connections:\n", (int)n)); for (UT_uint32 i = 0; i < n; i++) { UT_DEBUGMSG(("%d: Bus name %s, connection manager %s, protocol %s\n", i+1, bus_names[i], cms[i], protocols[i])); TpConnection* connection = tp_connection_new (dbus, bus_names[i], NULL, NULL); UT_continue_if_fail(connection); TpCapabilities* caps = tp_connection_get_capabilities(connection); if (!caps) { GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; tp_proxy_prepare_async(connection, features, prepare_connection_cb, pHandler); } else { validate_connection(connection, pHandler); } } g_object_unref(dbus); }
static void chat_conversations_list_init (ChatConversationsList *self) { ChatConversationsListPrivate *priv; self->priv = chat_conversations_list_get_instance_private (self); priv = self->priv; priv->accounts = g_hash_table_new_full (g_direct_hash, chat_conversations_list_accounts_key_equal_func, g_object_unref, chat_conversations_list_accounts_value_destroy_func); priv->am = tp_account_manager_dup (); tp_proxy_prepare_async (priv->am, NULL, chat_conversations_list_account_manager_prepare, g_object_ref (self)); priv->lm = tpl_log_manager_dup_singleton (); }
int main (int argc, char *argv[]) { TpAccountManager *account_manager; GtkApplication *app; GObjectClass *app_class; gint retval; g_thread_init (NULL); empathy_init (); gtk_init (&argc, &argv); empathy_gtk_init (); g_set_application_name (_("Empathy Accounts")); /* Make empathy and empathy-accounts appear as the same app in gnome-shell */ gdk_set_program_class ("Empathy"); gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); app = gtk_application_new (EMPATHY_ACCOUNTS_DBUS_NAME, G_APPLICATION_HANDLES_COMMAND_LINE); app_class = G_OBJECT_GET_CLASS (app); G_APPLICATION_CLASS (app_class)->local_command_line = local_cmdline; account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (account_manager, NULL, account_manager_ready_for_accounts_cb, NULL); g_signal_connect (app, "command-line", G_CALLBACK (app_command_line_cb), NULL); retval = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (account_manager); g_object_unref (app); return retval; }
static void channel_cb (ChVisitor *visitor, TpChannel *channel) { const char *type = tp_channel_get_channel_type (channel); const char *ident = tp_channel_get_identifier (channel); char **userlist; // if this is a text channel probe it for pending messages if (!strcmp (type, TP_IFACE_CHANNEL_TYPE_TEXT)) { // filter to only include given channels if ((userlist = users)) { for (; *userlist; userlist += 1) { if (!strcmp (ident, *userlist)) { break; } } if (!*userlist) { return; } } if (list_messages) { ch_visitor_visit_channel_target (visitor, channel); return; } GQuark features[] = { TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES, 0}; ch_visitor_incref (visitor); tp_proxy_prepare_async (channel, features, channel_ready, visitor); } else { if (verbose > 0) { g_printerr ("ignored channel %s %s\n", ident, type); } } }
int main (int argc, char *argv[]) { TpAccountManager *mgr; gtk_init (&argc, &argv); empathy_gtk_init (); g_set_application_name (PACKAGE_NAME); gtk_window_set_default_icon_name ("empathy"); mgr = tp_account_manager_dup (); tp_proxy_prepare_async (mgr, NULL, account_manager_prepare_cb, NULL); gtk_main (); g_object_unref (mgr); return EXIT_SUCCESS; }
static gboolean prepare_tp_proxy (gpointer proxy, const GQuark *features, GMainLoop *loop, GError **error) { PrepareTpProxyData data = { NULL, }; data.loop = loop; tp_proxy_prepare_async (proxy, features, proxy_prepared_cb, &data); g_main_loop_run (data.loop); if (data.error != NULL) { g_propagate_error (error, data.error); g_clear_error (&data.error); } return data.ret; }
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); }
int main (int argc, char **argv) { TpYtsAccountManager *am; TpAccount *account; gchar *path; if (argc < 3 || !tp_dbus_check_valid_interface_name (argv[2], NULL)) { g_print ("usage: %s [account] [service name] [--persist]\n", argv[0]); return 1; } g_type_init (); if (argc == 4) persist = g_str_equal (argv[3], "--persist"); am = tp_yts_account_manager_dup (); path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE, argv[1]); account = tp_yts_account_manager_ensure_account (am, path, NULL); g_free (path); tp_proxy_prepare_async (account, NULL, account_prepared_cb, argv[2]); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_main_loop_unref (loop); g_object_unref (account); g_object_unref (am); return 0; }
/** * empathy_ft_handler_new_incoming: * @channel: the #TpFileTransferChannel proxy to the incoming channel * @callback: callback to be called when the handler has been created * @user_data: user data to be passed to @callback * * Triggers the creation of a new #EmpathyFTHandler for an incoming transfer. * Note that for the handler to be useful, you will have to set a destination * file with empathy_ft_handler_incoming_set_destination() after the handler * is ready. */ void empathy_ft_handler_new_incoming (TpFileTransferChannel *channel, EmpathyFTHandlerReadyCallback callback, gpointer user_data) { EmpathyFTHandler *handler; CallbacksData *data; EmpathyFTHandlerPriv *priv; GQuark features[] = { TP_CHANNEL_FEATURE_CONTACTS, 0 }; g_return_if_fail (TP_IS_FILE_TRANSFER_CHANNEL (channel)); handler = g_object_new (EMPATHY_TYPE_FT_HANDLER, "channel", channel, NULL); priv = handler->priv; data = g_slice_new0 (CallbacksData); data->callback = callback; data->user_data = user_data; data->handler = g_object_ref (handler); priv->total_bytes = tp_file_transfer_channel_get_size (channel); priv->transferred_bytes = tp_file_transfer_channel_get_transferred_bytes ( channel); priv->filename = g_strdup (tp_file_transfer_channel_get_filename (channel)); priv->content_type = g_strdup (tp_file_transfer_channel_get_mime_type ( channel)); priv->description = g_strdup (tp_file_transfer_channel_get_description ( channel)); tp_proxy_prepare_async (channel, features, channel_prepared_cb, data); }
static void cm_requested_connection (TpConnectionManager *manager, const gchar *bus_name, const gchar *object_path, const GError *error, gpointer user_data, GObject *weak_object) { TpSimpleClientFactory *factory; GError *e = NULL; TpConnection *conn; if (die_if (error, "RequestConnection()")) return; /* Because we don't have an AccountManager, we have to do more work here. */ factory = tp_simple_client_factory_new (NULL); conn = tp_simple_client_factory_ensure_connection (factory, object_path, NULL, &e); g_object_unref (factory); if (conn == NULL) { g_warning ("tp_connection_new(): %s", error->message); g_main_loop_quit (mainloop); return; } /* the connection hasn't had a chance to become invalid yet, so we can * assume that this signal connection will work */ tp_cli_connection_connect_to_status_changed (conn, conn_status_changed, NULL, NULL, NULL, NULL); tp_proxy_prepare_async (conn, NULL, conn_ready, NULL); tp_cli_connection_call_connect (conn, -1, NULL, NULL, NULL, NULL); }
static void _mcd_channel_setup (McdChannel *channel, McdChannelPrivate *priv) { McdChannel **channel_ptr; GHashTable *properties; channel_ptr = g_slice_alloc (sizeof (McdChannel *)); *channel_ptr = channel; g_object_add_weak_pointer ((GObject *)channel, (gpointer)channel_ptr); tp_proxy_prepare_async (priv->tp_chan, NULL, on_channel_ready, channel_ptr); g_signal_connect (priv->tp_chan, "invalidated", G_CALLBACK (proxy_destroyed), channel); properties = tp_channel_borrow_immutable_properties (priv->tp_chan); if (properties) { gboolean requested, valid = FALSE; requested = tp_asv_get_boolean (properties, TP_IFACE_CHANNEL ".Requested", &valid); if (valid) priv->outgoing = requested; } }
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); }
static void tls_handler_init_async (GAsyncInitable *initable, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GVariant *properties; const gchar *cert_object_path; const gchar *bus_name; GError *error = NULL; GQuark features[] = { TP_TLS_CERTIFICATE_FEATURE_CORE, 0 }; /* * Used when channel doesn't implement ReferenceIdentities. A GStrv * with [0] the hostname, and [1] a NULL terminator. */ gchar *default_identities[2]; EmpathyServerTLSHandler *self = EMPATHY_SERVER_TLS_HANDLER (initable); EmpathyServerTLSHandlerPriv *priv = GET_PRIV (self); g_assert (priv->channel != NULL); priv->async_init_res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, empathy_server_tls_handler_new_async); properties = tp_channel_dup_immutable_properties (priv->channel); g_variant_lookup (properties, TP_PROP_CHANNEL_TYPE_SERVER_TLS_CONNECTION_HOSTNAME, "s", &priv->hostname); DEBUG ("Received hostname: %s", priv->hostname); g_variant_lookup (properties, TP_PROP_CHANNEL_TYPE_SERVER_TLS_CONNECTION_REFERENCE_IDENTITIES, "^as", &priv->reference_identities); /* * If the channel doesn't implement the ReferenceIdentities parameter * then fallback to the hostname. */ if (priv->reference_identities == NULL) { default_identities[0] = (gchar *) priv->hostname; default_identities[1] = NULL; priv->reference_identities = g_strdupv (default_identities); } else { #ifdef ENABLE_DEBUG gchar *output = g_strjoinv (", ", (gchar **) priv->reference_identities); DEBUG ("Received reference identities: %s", output); g_free (output); #endif /* ENABLE_DEBUG */ } g_variant_lookup (properties, TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION ".ServerCertificate", "&o", &cert_object_path); bus_name = tp_proxy_get_bus_name (TP_PROXY (priv->channel)); DEBUG ("Creating an TpTLSCertificate for path %s, bus name %s", cert_object_path, bus_name); priv->certificate = tp_tls_certificate_new (TP_PROXY (priv->channel), cert_object_path, &error); g_variant_unref (properties); if (error != NULL) { DEBUG ("Unable to create the TpTLSCertificate: error %s", error->message); g_simple_async_result_set_from_error (priv->async_init_res, error); g_simple_async_result_complete_in_idle (priv->async_init_res); g_error_free (error); tp_clear_object (&priv->async_init_res); return; } tp_proxy_prepare_async (priv->certificate, features, tls_certificate_prepared_cb, self); }
static GObject * empathy_chatroom_manager_constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *obj; EmpathyChatroomManager *self; EmpathyChatroomManagerPriv *priv; GError *error = NULL; if (chatroom_manager_singleton != NULL) return g_object_ref (chatroom_manager_singleton); /* Parent constructor chain */ obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)-> constructor (type, n_props, props); self = EMPATHY_CHATROOM_MANAGER (obj); priv = GET_PRIV (self); priv->ready = FALSE; chatroom_manager_singleton = self; g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton); priv->account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (priv->account_manager, NULL, account_manager_ready_cb, g_object_ref (self)); if (priv->file == NULL) { /* Set the default file path */ gchar *dir; dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); priv->file = g_build_filename (dir, CHATROOMS_XML_FILENAME, NULL); g_free (dir); } /* Setup a room observer */ priv->observer = tp_simple_observer_new_with_am (priv->account_manager, TRUE, "Empathy.ChatroomManager", TRUE, observe_channels_cb, self, NULL); tp_base_client_take_observer_filter (priv->observer, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, NULL)); if (!tp_base_client_register (priv->observer, &error)) { g_critical ("Failed to register Observer: %s", error->message); g_error_free (error); } return obj; }