static void contact_blocking_dialog_refilter_account_chooser ( EmpathyContactBlockingDialog *self) { EmpathyAccountChooser *chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser); TpConnection *conn; gboolean enabled; DEBUG ("Refiltering account chooser"); /* set the filter to refilter the account chooser */ self->priv->block_account_changed++; empathy_account_chooser_set_filter (chooser, contact_blocking_dialog_filter_account_chooser, self); self->priv->block_account_changed--; conn = empathy_account_chooser_get_connection (chooser); enabled = (empathy_account_chooser_get_account (chooser) != NULL && conn != NULL && tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)); if (!enabled) DEBUG ("No account selected"); gtk_widget_set_sensitive (self->priv->add_button, enabled); gtk_widget_set_sensitive (self->priv->add_contact_entry, enabled); contact_blocking_dialog_account_changed (self->priv->account_chooser, self); }
static void contact_widget_change_contact (EmpathyContactWidget *information) { EmpathyTpContactFactory *factory; TpConnection *connection; connection = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); if (!connection) return; factory = empathy_tp_contact_factory_dup_singleton (connection); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { const gchar *id; id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); if (!EMP_STR_EMPTY (id)) { empathy_tp_contact_factory_get_from_id (factory, id, contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } } else { empathy_tp_contact_factory_get_from_handle (factory, tp_connection_get_self_handle (connection), contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } g_object_unref (factory); }
static void new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; TpConnection *connection; const gchar *room; const gchar *server = NULL; gchar *room_name = NULL; room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server)); account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); connection = empathy_account_chooser_get_connection (account_chooser); if (!EMP_STR_EMPTY (server)) { room_name = g_strconcat (room, "@", server, NULL); } else { room_name = g_strdup (room); } DEBUG ("Requesting channel for '%s'", room_name); empathy_dispatcher_join_muc (connection, room_name, NULL, NULL); g_free (room_name); }
static void update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser, EmpathyAvatarChooser *avatar_chooser) { TpConnection *connection; connection = empathy_account_chooser_get_connection (account_chooser); g_object_set (avatar_chooser, "connection", connection, NULL); }
static void contact_blocking_dialog_remove_contacts (GtkWidget *button, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)); GtkTreeModel *model; GList *rows, *ptr; GPtrArray *contacts; rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model); contacts = g_ptr_array_new_with_free_func (g_object_unref); for (ptr = rows; ptr != NULL; ptr = ptr->next) { GtkTreePath *path = ptr->data; GtkTreeIter iter; TpContact *contact; if (!gtk_tree_model_get_iter (model, &iter, path)) continue; gtk_tree_model_get (model, &iter, COL_BLOCKED_CONTACT, &contact, -1); g_ptr_array_add (contacts, contact); gtk_tree_path_free (path); } g_list_free (rows); if (contacts->len > 0) { DEBUG ("Unblocking %u contacts", contacts->len); tp_connection_unblock_contacts_async (conn, contacts->len, (TpContact * const *) contacts->pdata, unblock_cb, self); } g_ptr_array_unref (contacts); }
static void contact_blocking_dialog_add_contact (GtkWidget *widget, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)); const char *identifiers[2] = { NULL, }; identifiers[0] = gtk_entry_get_text ( GTK_ENTRY (self->priv->add_contact_entry)); DEBUG ("Looking up handle for '%s' on %s", identifiers[0], get_pretty_conn_name (conn)); tp_connection_get_contacts_by_id (conn, 1, identifiers, 0, NULL, block_contact_got_contact, g_strdup (identifiers[0]), NULL, G_OBJECT (self)); gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), ""); gtk_widget_hide (self->priv->info_bar); }
static void contact_blocking_dialog_account_changed (GtkWidget *account_chooser, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (account_chooser)); GPtrArray *blocked; GPtrArray *members; guint i; if (self->priv->block_account_changed > 0) return; if (conn == self->priv->current_conn) return; /* clear the lists of contacts */ gtk_list_store_clear (self->priv->blocked_contacts); gtk_list_store_clear (self->priv->completion_contacts); if (self->priv->current_conn != NULL) { g_signal_handlers_disconnect_by_func (self->priv->current_conn, blocked_contacts_changed_cb, self); g_clear_object (&self->priv->current_conn); } if (conn == NULL) return; DEBUG ("Account changed: %s", get_pretty_conn_name (conn)); self->priv->current_conn = g_object_ref (conn); tp_g_signal_connect_object (conn, "blocked-contacts-changed", G_CALLBACK (blocked_contacts_changed_cb), self, 0); blocked = tp_connection_get_blocked_contacts (conn); DEBUG ("%u contacts blocked on %s", blocked != NULL ? blocked->len : 0, get_pretty_conn_name (conn)); contact_blocking_dialog_add_blocked (self, blocked); DEBUG ("Loading contacts"); members = tp_connection_dup_contact_list (conn); for (i = 0; i < members->len; i++) { TpContact *contact = g_ptr_array_index (members, i); gchar *tmpstr; tmpstr = g_strdup_printf ("%s (%s)", tp_contact_get_alias (contact), tp_contact_get_identifier (contact)); gtk_list_store_insert_with_values (self->priv->completion_contacts, NULL, -1, COL_COMPLETION_IDENTIFIER, tp_contact_get_identifier (contact), COL_COMPLETION_TEXT, tmpstr, -1); g_free (tmpstr); } g_ptr_array_unref (members); }
static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox, EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; gboolean listing = FALSE; gboolean expanded = FALSE; TpConnection *connection; TpCapabilities *caps; if (dialog->room_list) { g_object_unref (dialog->room_list); dialog->room_list = NULL; } gtk_spinner_stop (GTK_SPINNER (dialog->throbber)); gtk_widget_hide (dialog->throbber); new_chatroom_dialog_model_clear (dialog); if (dialog->account != NULL) { g_signal_handler_disconnect (dialog->account, dialog->status_changed_id); g_object_unref (dialog->account); } account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); dialog->account = empathy_account_chooser_dup_account (account_chooser); connection = empathy_account_chooser_get_connection (account_chooser); if (dialog->account == NULL) goto out; dialog->status_changed_id = g_signal_connect (dialog->account, "status-changed", G_CALLBACK (account_status_changed_cb), dialog); /* empathy_account_chooser_filter_supports_chatrooms ensures that the * account has a connection and CAPABILITIES has been prepared. */ g_assert (connection != NULL); g_assert (tp_proxy_is_prepared (connection, TP_CONNECTION_FEATURE_CAPABILITIES)); caps = tp_connection_get_capabilities (connection); if (tp_capabilities_supports_room_list (caps, NULL)) { /* Roomlist channels are supported */ dialog->room_list = empathy_tp_roomlist_new (dialog->account); } else { dialog->room_list = NULL; } if (dialog->room_list) { g_signal_connect (dialog->room_list, "destroy", G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog); g_signal_connect (dialog->room_list, "new-room", G_CALLBACK (new_chatroom_dialog_new_room_cb), dialog); g_signal_connect (dialog->room_list, "notify::is-listing", G_CALLBACK (new_chatroom_dialog_listing_cb), dialog); g_signal_connect (dialog->room_list, "error::start", G_CALLBACK (start_listing_error_cb), dialog); g_signal_connect (dialog->room_list, "error::stop", G_CALLBACK (stop_listing_error_cb), dialog); expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse)); if (expanded) { gtk_widget_hide (dialog->viewport_error); gtk_widget_set_sensitive (dialog->treeview, TRUE); new_chatroom_dialog_browse_start (dialog); } listing = empathy_tp_roomlist_is_listing (dialog->room_list); if (listing) { gtk_spinner_start (GTK_SPINNER (dialog->throbber)); gtk_widget_show (dialog->throbber); } } gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL); out: new_chatroom_dialog_update_widgets (dialog); }
static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox, EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; gboolean listing = FALSE; gboolean expanded = FALSE; TpConnection *connection; EmpathyDispatcher *dispatcher; GList *classes = NULL; if (dialog->room_list) { g_object_unref (dialog->room_list); dialog->room_list = NULL; } ephy_spinner_stop (EPHY_SPINNER (dialog->throbber)); new_chatroom_dialog_model_clear (dialog); if (dialog->account != NULL) { g_signal_handler_disconnect (dialog->account, dialog->status_changed_id); g_object_unref (dialog->account); } account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); dialog->account = empathy_account_chooser_dup_account (account_chooser); connection = empathy_account_chooser_get_connection (account_chooser); if (dialog->account == NULL) goto out; dialog->status_changed_id = g_signal_connect (dialog->account, "status-changed", G_CALLBACK (account_status_changed_cb), dialog); dispatcher = empathy_dispatcher_dup_singleton (); if (connection != NULL) { classes = empathy_dispatcher_find_requestable_channel_classes (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_ROOM_LIST, TP_HANDLE_TYPE_NONE, NULL); } if (classes != NULL) { /* Roomlist channels are supported */ dialog->room_list = empathy_tp_roomlist_new (dialog->account); g_list_free (classes); } else { dialog->room_list = NULL; } g_object_unref (dispatcher); if (dialog->room_list) { g_signal_connect (dialog->room_list, "destroy", G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog); g_signal_connect (dialog->room_list, "new-room", G_CALLBACK (new_chatroom_dialog_new_room_cb), dialog); g_signal_connect (dialog->room_list, "notify::is-listing", G_CALLBACK (new_chatroom_dialog_listing_cb), dialog); g_signal_connect (dialog->room_list, "error::start", G_CALLBACK (start_listing_error_cb), dialog); g_signal_connect (dialog->room_list, "error::stop", G_CALLBACK (stop_listing_error_cb), dialog); expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse)); if (expanded) { gtk_widget_hide (dialog->viewport_error); gtk_widget_set_sensitive (dialog->treeview, TRUE); new_chatroom_dialog_browse_start (dialog); } listing = empathy_tp_roomlist_is_listing (dialog->room_list); if (listing) { ephy_spinner_start (EPHY_SPINNER (dialog->throbber)); } } gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL); out: new_chatroom_dialog_update_widgets (dialog); }