diff options
23 files changed, 307 insertions, 801 deletions
diff --git a/configure.ac b/configure.ac index a5050f72e..0e0ac9bba 100644 --- a/configure.ac +++ b/configure.ac @@ -43,8 +43,8 @@ KEYRING_REQUIRED=2.26.0 GCR_REQUIRED=2.91.4 LIBCANBERRA_GTK_REQUIRED=0.25 LIBNOTIFY_REQUIRED=0.7.0 -TELEPATHY_FARSIGHT_REQUIRED=0.0.14 -TELEPATHY_GLIB_REQUIRED=0.16.0 +TELEPATHY_FARSIGHT_REQUIRED=0.0.18 +TELEPATHY_GLIB_REQUIRED=0.17.0 TELEPATHY_LOGGER=0.2.10 WEBKIT_REQUIRED=1.3.13 GOA_REQUIRED=3.3.0 diff --git a/data/Makefile.am b/data/Makefile.am index e6414a805..a08ed620d 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -19,11 +19,6 @@ convertdir = $(datarootdir)/GConf/gsettings convert_DATA = \ empathy.convert -streamingprefsdir = $(datadir)/empathy -streamingprefs_DATA = \ - codec-preferences \ - element-properties - servicefiledir = $(datadir)/dbus-1/services servicefile_in_files = \ org.freedesktop.Telepathy.Client.Empathy.Chat.service.in \ @@ -76,7 +71,6 @@ EXTRA_DIST = \ $(desktop_in_files) \ $(desktop_DATA) \ $(schemas_DATA) \ - $(streamingprefs_DATA) \ $(html_DATA) \ $(clientfile_DATA) \ $(servicefile_in_files) \ diff --git a/data/codec-preferences b/data/codec-preferences deleted file mode 100644 index fbd8ad55d..000000000 --- a/data/codec-preferences +++ /dev/null @@ -1,50 +0,0 @@ -# Favorite audio codecs - -[audio/SPEEX:8000] -clock-rate=8000 - -[audio/SPEEX:16000] -clock-rate=16000 - -[audio/AMR] - -[audio/G729] - -[audio/ILBC] - -# Disabled audio codecs - -[audio/DV] -id=-1 - -[audio/MPA] -id=-1 - -[audio/VORBIS] -id=-1 - -[audio/MP3] -id=-1 - - -# Favorite video codecs - -# We like freedom and the future (proof of concept VP8 payloading) -[video/X-VP8-GST] - -# but keep an eye on people living in the past -[video/H264] - -[video/H263] - -[video/THEORA] - -# Disable the ones we don't want -[video/JPEG] -id=-1 - -[video/DV] -id=-1 - -[video/MPV] -id=-1 diff --git a/data/element-properties b/data/element-properties deleted file mode 100644 index 68debc234..000000000 --- a/data/element-properties +++ /dev/null @@ -1,59 +0,0 @@ -# Put the desired properties in the style of -# -# [element name] -# prop1=val1 - -[gstrtpbin] -latency=100 - -[x264enc] -byte-stream=1 -bframes=0 -b-adapt=0 -cabac=0 -dct8x8=0 -bitrate=256 -# tuned for zero latency -tune=0x4 -profile=1 -speed-preset=3 -sliced-threads=false -aud=false - -[ffenc_h263] -rtp-payload-size=1 - -[theoraenc] -bitrate=256 - -[vp8enc] -bitrate=256000 -max-latency=1 -speed=2 -error-resilient=true - -# Work around bug in the re-timestamp slaving method in -# GStreamer (2 is skew) -[alsasrc] -slave-method=2 - -[osssrc] -slave-method=2 - -[oss4src] -slave-method=2 - -[sunaudiosrc] -slave-method=2 - -[rtph264pay] -config-interval=5 - -[rtppcmupay] -ptime-multiple=20000000 - -[rtppcmapay] -ptime-multiple=20000000 - -[gstrtpjitterbuffer] -do-lost=1 diff --git a/libempathy-gtk/empathy-contact-blocking-dialog.c b/libempathy-gtk/empathy-contact-blocking-dialog.c index b000e24d4..1ec60b0ac 100644 --- a/libempathy-gtk/empathy-contact-blocking-dialog.c +++ b/libempathy-gtk/empathy-contact-blocking-dialog.c @@ -47,9 +47,6 @@ G_DEFINE_TYPE (EmpathyContactBlockingDialog, empathy_contact_blocking_dialog, struct _EmpathyContactBlockingDialogPrivate { - /* a map of all active connections to their 'deny' channel */ - GHashTable *channels; /* reffed TpConnection* -> reffed TpChannel* */ - guint block_account_changed; GtkListStore *blocked_contacts; @@ -62,12 +59,14 @@ struct _EmpathyContactBlockingDialogPrivate GtkWidget *info_bar; GtkWidget *info_bar_label; GtkWidget *remove_button; + + TpConnection *current_conn; }; enum /* blocked-contacts columns */ { COL_BLOCKED_IDENTIFIER, - COL_BLOCKED_HANDLE, + COL_BLOCKED_CONTACT, N_BLOCKED_COLUMNS }; @@ -90,13 +89,13 @@ contact_blocking_dialog_filter_account_chooser (TpAccount *account, gpointer callback_data, gpointer user_data) { - EmpathyContactBlockingDialog *self = user_data; TpConnection *conn = tp_account_get_connection (account); gboolean enable; enable = conn != NULL && - g_hash_table_lookup (self->priv->channels, conn) != NULL; + tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING); callback (enable, callback_data); } @@ -124,7 +123,8 @@ contact_blocking_dialog_refilter_account_chooser ( conn = empathy_account_chooser_get_connection (chooser); enabled = (empathy_account_chooser_get_account (chooser) != NULL && conn != NULL && - g_hash_table_lookup (self->priv->channels, conn) != NULL); + tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)); if (!enabled) DEBUG ("No account selected"); @@ -135,56 +135,63 @@ contact_blocking_dialog_refilter_account_chooser ( contact_blocking_dialog_account_changed (self->priv->account_chooser, self); } -static void contact_blocking_dialog_inspected_handles (TpConnection *, - const char **, const GError *, gpointer, GObject *); - static void -contact_blocking_dialog_add_contacts_to_list ( +contact_blocking_dialog_add_blocked ( EmpathyContactBlockingDialog *self, - TpConnection *conn, - GArray *handles) -{ - if (handles->len > 0) - tp_cli_connection_call_inspect_handles (conn, -1, - TP_HANDLE_TYPE_CONTACT, handles, - contact_blocking_dialog_inspected_handles, - g_boxed_copy (DBUS_TYPE_G_UINT_ARRAY, handles), - (GDestroyNotify) g_array_unref, G_OBJECT (self)); -} - -static void -contact_blocking_dialog_inspected_handles (TpConnection *conn, - const char **identifiers, - const GError *in_error, - gpointer user_data, - GObject *self) + GPtrArray *blocked) { EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self); - GArray *handles = user_data; guint i; - if (in_error != NULL) + if (blocked == NULL) + return; + + for (i = 0; i < blocked->len; i++) { - DEBUG ("Failed to inspect handles: %s", in_error->message); - return; + TpContact *contact = g_ptr_array_index (blocked, i); + + gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1, + COL_BLOCKED_IDENTIFIER, tp_contact_get_identifier (contact), + COL_BLOCKED_CONTACT, contact, + -1); } +} + +static void +blocked_contacts_changed_cb (TpConnection *conn, + GPtrArray *added, + GPtrArray *removed, + EmpathyContactBlockingDialog *self) +{ + GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts); + GtkTreeIter iter; + gboolean valid; + + DEBUG ("blocked contacts changed on %s: %u added, %u removed", + get_pretty_conn_name (conn), added->len, removed->len); - DEBUG ("Adding %u identifiers", handles->len); + /* add contacts */ + contact_blocking_dialog_add_blocked (self, added); - for (i = 0; i < handles->len; i++) + /* remove contacts */ + valid = gtk_tree_model_get_iter_first (model, &iter); + while (valid) { - const char *identifier = identifiers[i]; - TpHandle handle = g_array_index (handles, TpHandle, i); + TpContact *contact; - gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1, - COL_BLOCKED_IDENTIFIER, identifier, - COL_BLOCKED_HANDLE, handle, + gtk_tree_model_get (model, &iter, + COL_BLOCKED_CONTACT, &contact, -1); + + if (tp_g_ptr_array_contains (removed, contact)) + valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter); + else + valid = gtk_tree_model_iter_next (model, &iter); + + g_object_unref (contact); } } -DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared); - static void contact_blocking_dialog_connection_status_changed (TpAccount *account, guint old_status, @@ -201,8 +208,6 @@ contact_blocking_dialog_connection_status_changed (TpAccount *account, case TP_CONNECTION_STATUS_DISCONNECTED: DEBUG ("Connection %s invalidated", get_pretty_conn_name (conn)); - /* remove the channel from the hash table */ - g_hash_table_remove (self->priv->channels, conn); contact_blocking_dialog_refilter_account_chooser (self); break; @@ -212,65 +217,10 @@ contact_blocking_dialog_connection_status_changed (TpAccount *account, case TP_CONNECTION_STATUS_CONNECTED: DEBUG ("Connection %s reconnected", get_pretty_conn_name (conn)); - tp_proxy_prepare_async (conn, NULL, - contact_blocking_dialog_connection_prepared, self); - } -} - -static void -contact_blocking_dialog_deny_channel_members_changed (TpChannel *channel, - const char *message, - GArray *added, - GArray *removed, - GArray *local_pending, - GArray *remote_pending, - TpHandle actor, - guint reason, - EmpathyContactBlockingDialog *self) -{ - TpConnection *conn = tp_channel_borrow_connection (channel); - GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts); - GtkTreeIter iter; - TpIntset *removed_set; - gboolean valid; - - /* we only care about changes to the selected connection */ - /* FIXME: can we compare proxy pointers directly? */ - if (tp_strdiff ( - tp_proxy_get_object_path (tp_channel_borrow_connection (channel)), - tp_proxy_get_object_path (empathy_account_chooser_get_connection ( - EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser))))) - return; - - DEBUG ("deny list changed on %s: %u added, %u removed", - get_pretty_conn_name (conn), added->len, removed->len); - - /* add contacts */ - contact_blocking_dialog_add_contacts_to_list (self, conn, added); - - /* remove contacts */ - removed_set = tp_intset_from_array (removed); - - valid = gtk_tree_model_get_iter_first (model, &iter); - while (valid) - { - TpHandle handle; - - gtk_tree_model_get (model, &iter, - COL_BLOCKED_HANDLE, &handle, - -1); - - if (tp_intset_is_member (removed_set, handle)) - valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter); - else - valid = gtk_tree_model_iter_next (model, &iter); + contact_blocking_dialog_refilter_account_chooser (self); } - - tp_intset_destroy (removed_set); } -DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared); - static void contact_blocking_dialog_am_prepared (GObject *am, GAsyncResult *result, @@ -292,166 +242,100 @@ contact_blocking_dialog_am_prepared (GObject *am, for (ptr = accounts; ptr != NULL; ptr = ptr->next) { TpAccount *account = ptr->data; - TpConnection *conn; tp_g_signal_connect_object (account, "status-changed", G_CALLBACK (contact_blocking_dialog_connection_status_changed), self, 0); - conn = tp_account_get_connection (TP_ACCOUNT (account)); - - if (conn != NULL) - { - tp_proxy_prepare_async (conn, NULL, - contact_blocking_dialog_connection_prepared, self); - } + contact_blocking_dialog_refilter_account_chooser (self); } g_list_free (accounts); } -static void contact_blocking_dialog_got_deny_channel (TpConnection *, - gboolean, const char *, GHashTable *, const GError *, gpointer, GObject *); - static void -contact_blocking_dialog_connection_prepared (GObject *conn, - GAsyncResult *result, - gpointer user_data) +contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self, + const GError *error) { - EmpathyContactBlockingDialog *self = user_data; - GHashTable *request; - GError *error = NULL; + const char *msg = NULL; - if (!tp_proxy_prepare_finish (conn, result, &error)) + if (error->domain == TP_ERRORS) { - DEBUG ("Failed to prepare connection %s: %s", - get_pretty_conn_name ((TpConnection *) conn), error->message); - g_error_free (error); - return; + if (error->code == TP_ERROR_INVALID_HANDLE) + msg = _("Unknown or invalid identifier"); + else if (error->code == TP_ERROR_NOT_AVAILABLE) + msg = _("Contact blocking temporarily unavailable"); + else if (error->code == TP_ERROR_NOT_CAPABLE) + msg = _("Contact blocking unavailable"); + else if (error->code == TP_ERROR_PERMISSION_DENIED) + msg = _("Permission Denied"); } - /* request the deny channel */ - request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, - G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, - - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, - G_TYPE_UINT, - TP_HANDLE_TYPE_LIST, - - TP_PROP_CHANNEL_TARGET_ID, - G_TYPE_STRING, - "deny", - - NULL); - - tp_cli_connection_interface_requests_call_ensure_channel ( - TP_CONNECTION (conn), -1, request, - contact_blocking_dialog_got_deny_channel, NULL, NULL, G_OBJECT (self)); + if (msg == NULL) + msg = _("Could not block contact"); - g_hash_table_destroy (request); + gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg); + gtk_widget_show (self->priv->info_bar); } -DECLARE_CALLBACK (contact_blocking_dialog_deny_channel_prepared); - static void -contact_blocking_dialog_got_deny_channel (TpConnection *conn, - gboolean yours, - const char *channel_path, - GHashTable *props, - const GError *in_error, - gpointer user_data, - GObject *self) +block_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) { - TpChannel *channel; + EmpathyContactBlockingDialog *self = user_data; GError *error = NULL; - const GQuark features[] = { - TP_CHANNEL_FEATURE_CORE, - TP_CHANNEL_FEATURE_GROUP, - 0 }; - - if (in_error != NULL) + if (!tp_contact_block_finish (TP_CONTACT (source), result, + &error)) { - DEBUG ("Failed to get 'deny' channel on %s: %s", - get_pretty_conn_name (conn), in_error->message); - return; - } + DEBUG ("Error blocking contacts: %s", error->message); - channel = tp_channel_new_from_properties (conn, channel_path, props, &error); + contact_blocking_dialog_set_error ( + EMPATHY_CONTACT_BLOCKING_DIALOG (self), error); - if (error != NULL) - { - DEBUG ("Failed to create channel proxy on %s: %s", - get_pretty_conn_name (conn), in_error->message); g_error_free (error); return; } - tp_proxy_prepare_async (channel, features, - contact_blocking_dialog_deny_channel_prepared, self); + DEBUG ("Contact blocked"); } static void -contact_blocking_dialog_deny_channel_prepared (GObject *channel, - GAsyncResult *result, - gpointer user_data) +block_contact_got_contact(TpConnection *conn, + guint n_contacts, + TpContact * const *contacts, + const gchar * const *requested_ids, + GHashTable *failed_id_errors, + const GError *error, + gpointer user_data, + GObject *weak_object) { - EmpathyContactBlockingDialog *self = user_data; - TpConnection *conn; - GError *error = NULL; - - if (!tp_proxy_prepare_finish (channel, result, &error)) - { - DEBUG ("Failed to prepare channel %s: %s", - tp_proxy_get_object_path (channel), error->message); - g_error_free (error); - return; - } - - conn = tp_channel_borrow_connection (TP_CHANNEL (channel)); + EmpathyContactBlockingDialog *self = + EMPATHY_CONTACT_BLOCKING_DIALOG (weak_object); + gchar *id = user_data; - DEBUG ("Channel %s prepared for connection %s", - tp_proxy_get_object_path (channel), get_pretty_conn_name (conn)); - - g_hash_table_insert (self->priv->channels, - g_object_ref (conn), channel); - contact_blocking_dialog_refilter_account_chooser (self); + if (error != NULL) + goto error; - tp_g_signal_connect_object (channel, "group-members-changed", - G_CALLBACK (contact_blocking_dialog_deny_channel_members_changed), - self, 0); -} + error = g_hash_table_lookup (failed_id_errors, id); + if (error != NULL) + goto error; -static void -contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self, - const GError *error) -{ - const char *msg = NULL; + tp_contact_block_async (contacts[0], FALSE, block_cb, self); + goto finally; - if (error->domain == TP_ERRORS) - { - if (error->code == TP_ERROR_INVALID_HANDLE) - msg = _("Unknown or invalid identifier"); - else if (error->code == TP_ERROR_NOT_AVAILABLE) - msg = _("Contact blocking temporarily unavailable"); - else if (error->code == TP_ERROR_NOT_CAPABLE) - msg = _("Contact blocking unavailable"); - else if (error->code == TP_ERROR_PERMISSION_DENIED) - msg = _("Permission Denied"); - } +error: + DEBUG ("Error getting contact on %s: %s", + get_pretty_conn_name (conn), error->message); - if (msg == NULL) - msg = _("Could not block contact"); + contact_blocking_dialog_set_error ( + EMPATHY_CONTACT_BLOCKING_DIALOG (self), error); - gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg); - gtk_widget_show (self->priv->info_bar); +finally: + g_free (id); } -static void contact_blocking_dialog_add_contact_got_handle (TpConnection *, - const GArray *, const GError *, gpointer, GObject *); - static void contact_blocking_dialog_add_contact (GtkWidget *widget, EmpathyContactBlockingDialog *self) @@ -466,136 +350,80 @@ contact_blocking_dialog_add_contact (GtkWidget *widget, DEBUG ("Looking up handle for '%s' on %s", identifiers[0], get_pretty_conn_name (conn)); - tp_cli_connection_call_request_handles (conn, -1, - TP_HANDLE_TYPE_CONTACT, identifiers, - contact_blocking_dialog_add_contact_got_handle, - NULL, NULL, G_OBJECT (self)); + 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_added_contact (TpChannel *, const GError *, - gpointer, GObject *); - -static void -contact_blocking_dialog_add_contact_got_handle (TpConnection *conn, - const GArray *handles, - const GError *in_error, - gpointer user_data, - GObject *self) +unblock_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) { - EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self); - TpChannel *channel = g_hash_table_lookup (priv->channels, conn); - - if (in_error != NULL) - { - DEBUG ("Error getting handle on %s: %s", - get_pretty_conn_name (conn), in_error->message); - - contact_blocking_dialog_set_error ( - EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error); - - return; - } - - g_return_if_fail (handles->len == 1); - - DEBUG ("Adding handle %u to deny channel on %s", - g_array_index (handles, TpHandle, 0), get_pretty_conn_name (conn)); - - tp_cli_channel_interface_group_call_add_members (channel, -1, - handles, "", - contact_blocking_dialog_added_contact, NULL, NULL, self); -} + EmpathyContactBlockingDialog *self = user_data; + GError *error = NULL; -static void -contact_blocking_dialog_added_contact (TpChannel *channel, - const GError *in_error, - gpointer user_data, - GObject *self) -{ - if (in_error != NULL) + if (!tp_connection_unblock_contacts_finish (TP_CONNECTION (source), result, + &error)) { - DEBUG ("Error adding contact to deny list %s: %s", - tp_proxy_get_object_path (channel), in_error->message); + DEBUG ("Error unblocking contacts: %s", error->message); contact_blocking_dialog_set_error ( - EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error); + EMPATHY_CONTACT_BLOCKING_DIALOG (self), error); + g_error_free (error); return; } - DEBUG ("Contact added to %s", tp_proxy_get_object_path (channel)); + DEBUG ("Contacts unblocked"); } static void -contact_blocking_dialog_removed_contacts (TpChannel *, - const GError *, gpointer, GObject *); - -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)); - TpChannel *channel = g_hash_table_lookup (self->priv->channels, conn); GtkTreeModel *model; GList *rows, *ptr; - GArray *handles = g_array_new (FALSE, FALSE, sizeof (TpHandle)); + 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; - TpHandle handle; + TpContact *contact; if (!gtk_tree_model_get_iter (model, &iter, path)) continue; gtk_tree_model_get (model, &iter, - COL_BLOCKED_HANDLE, &handle, + COL_BLOCKED_CONTACT, &contact, -1); - g_array_append_val (handles, handle); + g_ptr_array_add (contacts, contact); + gtk_tree_path_free (path); } g_list_free (rows); - if (handles->len > 0) + if (contacts->len > 0) { - DEBUG ("Removing %u handles", handles->len); - - tp_cli_channel_interface_group_call_remove_members (channel, -1, - handles, "", - contact_blocking_dialog_removed_contacts, - NULL, NULL, G_OBJECT (self)); - } + DEBUG ("Unblocking %u contacts", contacts->len); - g_array_unref (handles); -} - -static void -contact_blocking_dialog_removed_contacts (TpChannel *channel, - const GError *in_error, - gpointer user_data, - GObject *self) -{ - if (in_error != NULL) - { - DEBUG ("Error removing contacts from deny list: %s", in_error->message); - - contact_blocking_dialog_set_error ( - EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error); - - return; + tp_connection_unblock_contacts_async (conn, contacts->len, + (TpContact * const *) contacts->pdata, unblock_cb, self); } - DEBUG ("Contacts removed"); + g_ptr_array_unref (contacts); } static void @@ -604,8 +432,7 @@ contact_blocking_dialog_account_changed (GtkWidget *account_chooser, { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (account_chooser)); - TpChannel *channel; - GArray *blocked; + GPtrArray *blocked; EmpathyContactManager *contact_manager; EmpathyTpContactList *contact_list; GList *members, *ptr; @@ -613,29 +440,37 @@ contact_blocking_dialog_account_changed (GtkWidget *account_chooser, 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)); - /* load the deny list */ - channel = g_hash_table_lookup (self->priv->channels, conn); + self->priv->current_conn = g_object_ref (conn); - if (channel == NULL) - return; - - g_return_if_fail (TP_IS_CHANNEL (channel)); + tp_g_signal_connect_object (conn, "blocked-contacts-changed", + G_CALLBACK (blocked_contacts_changed_cb), self, 0); - blocked = tp_intset_to_array (tp_channel_group_get_members (channel)); + blocked = tp_connection_get_blocked_contacts (conn); - DEBUG ("%u contacts on blocked list", blocked->len); + DEBUG ("%u contacts blocked on %s", + blocked != NULL ? blocked->len : 0, get_pretty_conn_name (conn)); - contact_blocking_dialog_add_contacts_to_list (self, conn, blocked); - g_array_unref (blocked); + contact_blocking_dialog_add_blocked (self, blocked); /* load the completion list */ g_return_if_fail (empathy_contact_manager_initialized ()); @@ -750,7 +585,7 @@ contact_blocking_dialog_dispose (GObject *self) { EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self); - tp_clear_pointer (&priv->channels, g_hash_table_destroy); + g_clear_object (&priv->current_conn); G_OBJECT_CLASS (empathy_contact_blocking_dialog_parent_class)->dispose (self); } @@ -778,14 +613,12 @@ empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self) GtkEntryCompletion *completion; TpAccountManager *am; GtkStyleContext *context; + TpSimpleClientFactory *factory; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG, EmpathyContactBlockingDialogPrivate); - self->priv->channels = g_hash_table_new_full (NULL, NULL, - g_object_unref, g_object_unref); - gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts")); gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); @@ -833,8 +666,9 @@ empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self) /* build the contact entry */ self->priv->completion_contacts = gtk_list_store_new (N_COMPLETION_COLUMNS, G_TYPE_STRING, /* id */ - G_TYPE_UINT, /* handle */ - G_TYPE_STRING); /* text */ + 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)); @@ -874,6 +708,11 @@ empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self) /* 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); diff --git a/libempathy-gtk/empathy-contact-blocking-dialog.ui b/libempathy-gtk/empathy-contact-blocking-dialog.ui index 78dd1cd2d..25499ac70 100644 --- a/libempathy-gtk/empathy-contact-blocking-dialog.ui +++ b/libempathy-gtk/empathy-contact-blocking-dialog.ui @@ -6,8 +6,8 @@ <columns> <!-- column-name identifier --> <column type="gchararray"/> - <!-- column-name handle --> - <column type="guint"/> + <!-- column-name contact --> + <column type="TpContact"/> </columns> </object> <object class="GtkVBox" id="contents"> diff --git a/libempathy-gtk/empathy-contact-chooser.c b/libempathy-gtk/empathy-contact-chooser.c index 7a9e7344d..5ff17a432 100644 --- a/libempathy-gtk/empathy-contact-chooser.c +++ b/libempathy-gtk/empathy-contact-chooser.c @@ -211,7 +211,7 @@ get_contacts_cb (TpConnection *connection, TpAccount *account; TpfPersonaStore *store; FolksIndividual *individual; - TpfPersona *persona_new; + TpfPersona *persona; GeeSet *personas; if (self->priv->add_temp_ctx != ctx) @@ -227,9 +227,10 @@ get_contacts_cb (TpConnection *connection, personas = GEE_SET ( gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, g_direct_hash, g_direct_equal)); - persona_new = tpf_persona_new (contacts[0], store); - gee_collection_add (GEE_COLLECTION (personas), - tpf_persona_new (contacts[0], store)); + + persona = tpf_persona_new (contacts[0], store); + + gee_collection_add (GEE_COLLECTION (personas), persona); individual = folks_individual_new (personas); @@ -248,7 +249,7 @@ get_contacts_cb (TpConnection *connection, NULL, NULL)) empathy_individual_view_select_first (self->priv->view); - g_clear_object (&persona_new); + g_clear_object (&persona); g_clear_object (&personas); g_object_unref (store); } diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 29552cccc..0df8df7eb 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -30,8 +30,6 @@ #include <telepathy-glib/account-manager.h> -#include <libempathy/empathy-contact-manager.h> -#include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-tp-contact-factory.h> #include <libempathy/empathy-utils.h> @@ -67,22 +65,18 @@ subscription_dialog_response_cb (GtkDialog *dialog, gint response, GtkWidget *contact_widget) { - EmpathyContactManager *manager; EmpathyContact *contact; - manager = empathy_contact_manager_dup_singleton (); contact = empathy_contact_widget_get_contact (contact_widget); if (response == GTK_RESPONSE_YES) { - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), - contact, ""); + empathy_contact_add_to_contact_list (contact, ""); empathy_contact_set_alias (contact, empathy_contact_widget_get_alias (contact_widget)); } else if (response == GTK_RESPONSE_NO) { - empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager), - contact, ""); + empathy_contact_remove_from_contact_list (contact); } else if (response == GTK_RESPONSE_REJECT) { gboolean abusive; @@ -90,24 +84,22 @@ subscription_dialog_response_cb (GtkDialog *dialog, /* confirm the blocking */ if (empathy_block_contact_dialog_show (GTK_WINDOW (dialog), contact, NULL, &abusive)) { - empathy_contact_list_remove ( - EMPATHY_CONTACT_LIST (manager), - contact, ""); - empathy_contact_list_set_blocked ( - EMPATHY_CONTACT_LIST (manager), - contact, TRUE, abusive); + TpContact *tp_contact; + + empathy_contact_remove_from_contact_list (contact); + + tp_contact = empathy_contact_get_tp_contact (contact); + + tp_contact_block_async (tp_contact, abusive, NULL, NULL); } else { /* if they don't confirm, return back to the * first dialog */ - goto finally; + return; } } subscription_dialogs = g_list_remove (subscription_dialogs, dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); - -finally: - g_object_unref (manager); } void @@ -123,10 +115,7 @@ empathy_subscription_dialog_show (EmpathyContact *contact, GtkWidget *block_user_button; GList *l; gchar *filename; - EmpathyContactManager *manager; - EmpathyContactListFlags flags; - - manager = empathy_contact_manager_dup_singleton (); + TpConnection *conn; g_return_if_fail (EMPATHY_IS_CONTACT (contact)); @@ -188,17 +177,16 @@ empathy_subscription_dialog_show (EmpathyContact *contact, G_CALLBACK (subscription_dialog_response_cb), contact_widget); - flags = empathy_contact_manager_get_flags_for_connection (manager, - empathy_contact_get_connection (contact)); + conn = empathy_contact_get_connection (contact); - if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK) + if (tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) gtk_widget_show (block_user_button); if (parent) { gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); } - g_object_unref (manager); gtk_widget_show (dialog); } @@ -395,7 +383,6 @@ can_add_contact_to_account (TpAccount *account, gpointer callback_data, gpointer user_data) { - EmpathyContactManager *contact_manager; TpConnection *connection; gboolean result; @@ -405,10 +392,7 @@ can_add_contact_to_account (TpAccount *account, return; } - contact_manager = empathy_contact_manager_dup_singleton (); - result = empathy_contact_manager_get_flags_for_connection ( - contact_manager, connection) & EMPATHY_CONTACT_LIST_CAN_ADD; - g_object_unref (contact_manager); + result = tp_connection_get_can_change_contact_list (connection); callback (result, callback_data); } @@ -418,20 +402,16 @@ new_contact_response_cb (GtkDialog *dialog, gint response, GtkWidget *contact_widget) { - EmpathyContactManager *manager; EmpathyContact *contact; - manager = empathy_contact_manager_dup_singleton (); contact = empathy_contact_widget_get_contact (contact_widget); if (contact && response == GTK_RESPONSE_OK) { - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), - contact, ""); + empathy_contact_add_to_contact_list (contact, ""); } new_contact_dialog = NULL; gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (manager); } void @@ -517,15 +497,10 @@ empathy_block_contact_dialog_show (GtkWindow *parent, GdkPixbuf *avatar, gboolean *abusive) { - EmpathyContactManager *manager; - EmpathyContactListFlags flags; GtkWidget *dialog; GtkWidget *abusive_check = NULL; int res; - - manager = empathy_contact_manager_dup_singleton (); - flags = empathy_contact_manager_get_flags_for_connection (manager, - empathy_contact_get_connection (contact)); + TpConnection *conn; dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, @@ -549,8 +524,10 @@ empathy_block_contact_dialog_show (GtkWindow *parent, gtk_widget_show (image); } + conn = empathy_contact_get_connection (contact); + /* ask the user if they want to also report the contact as abusive */ - if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE) { + if (tp_connection_can_report_abusive (conn)) { GtkWidget *vbox; vbox = gtk_message_dialog_get_message_area ( @@ -574,7 +551,6 @@ empathy_block_contact_dialog_show (GtkWindow *parent, } gtk_widget_destroy (dialog); - g_object_unref (manager); return res == GTK_RESPONSE_REJECT; } diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 1d95baf8e..b1d20f8e5 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -2003,7 +2003,6 @@ static void contact_list_view_remove_activate_cb (GtkMenuItem *menuitem, EmpathyContactListView *view) { - EmpathyContactListViewPriv *priv = GET_PRIV (view); EmpathyContact *contact; contact = empathy_contact_list_view_dup_selected (view); @@ -2016,10 +2015,7 @@ contact_list_view_remove_activate_cb (GtkMenuItem *menuitem, text = g_strdup_printf (_("Do you really want to remove the contact '%s'?"), empathy_contact_get_alias (contact)); if (contact_list_view_remove_dialog_show (parent, _("Removing contact"), text)) { - EmpathyContactList *list; - - list = empathy_contact_list_store_get_list_iface (priv->store); - empathy_contact_list_remove (list, contact, ""); + empathy_contact_remove_from_contact_list (contact); } g_free (text); diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c index 07def6078..a6f5a209d 100644 --- a/libempathy-gtk/empathy-contact-menu.c +++ b/libempathy-gtk/empathy-contact-menu.c @@ -226,8 +226,8 @@ empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item, EmpathyContact *contact) { static guint block_signal = 0; - EmpathyContactManager *manager; gboolean blocked, abusive; + TpContact *tp_contact; if (block_signal > 0) return; @@ -252,10 +252,12 @@ empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item, return; } - manager = empathy_contact_manager_dup_singleton (); - empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager), - contact, blocked, abusive); - g_object_unref (manager); + tp_contact = empathy_contact_get_tp_contact (contact); + + if (blocked) + tp_contact_block_async (tp_contact, abusive, NULL, NULL); + else + tp_contact_unblock_async (tp_contact, NULL, NULL); /* update the toggle with the blocked status */ block_signal++; @@ -269,8 +271,7 @@ empathy_contact_block_menu_item_new (EmpathyContact *contact) GtkWidget *item; EmpathyContactManager *manager; TpConnection *connection; - EmpathyContactListFlags flags; - gboolean blocked; + TpContact *tp_contact; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); @@ -282,19 +283,16 @@ empathy_contact_block_menu_item_new (EmpathyContact *contact) connection = empathy_contact_get_connection (contact); - flags = empathy_contact_manager_get_flags_for_connection (manager, - connection); - - if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)) { + if (!tp_proxy_has_interface_by_id (connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) return NULL; - } item = gtk_check_menu_item_new_with_mnemonic (_("_Block Contact")); - blocked = empathy_contact_list_get_blocked ( - EMPATHY_CONTACT_LIST (manager), - contact); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), blocked); + tp_contact = empathy_contact_get_tp_contact (contact); + + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), + tp_contact_is_blocked (tp_contact)); g_signal_connect (item, "toggled", G_CALLBACK (empathy_contact_block_menu_item_toggled), diff --git a/libempathy-gtk/empathy-contact-search-dialog.c b/libempathy-gtk/empathy-contact-search-dialog.c index bfc42bbb0..1dfb942e2 100644 --- a/libempathy-gtk/empathy-contact-search-dialog.c +++ b/libempathy-gtk/empathy-contact-search-dialog.c @@ -28,8 +28,8 @@ #include <telepathy-glib/telepathy-glib.h> -#include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-tp-contact-factory.h> +#include <libempathy/empathy-utils.h> #include <libempathy-gtk/empathy-account-chooser.h> #include <libempathy-gtk/empathy-cell-renderer-text.h> @@ -142,7 +142,6 @@ on_get_contact_factory_get_from_id_cb (TpConnection *connection, gpointer user_data, GObject *object) { - EmpathyContactManager *manager = empathy_contact_manager_dup_singleton (); const gchar *message = user_data; if (error != NULL) @@ -151,8 +150,7 @@ on_get_contact_factory_get_from_id_cb (TpConnection *connection, return; } - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), contact, - message); + empathy_contact_add_to_contact_list (contact, message); } static void @@ -342,15 +340,11 @@ check_request_message_available (EmpathyContactSearchDialog *self, TpConnection *conn) { EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self); - EmpathyContactManager *manager = empathy_contact_manager_dup_singleton (); - EmpathyContactListFlags flags; - - flags = empathy_contact_manager_get_flags_for_connection (manager, conn); gtk_widget_set_visible (priv->message_window, - flags & EMPATHY_CONTACT_LIST_MESSAGE_ADD); + tp_connection_get_can_change_contact_list (conn)); gtk_widget_set_visible (priv->message_label, - flags & EMPATHY_CONTACT_LIST_MESSAGE_ADD); + tp_connection_get_can_change_contact_list (conn)); } static void diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c index e1bd6f11f..ed566329d 100644 --- a/libempathy-gtk/empathy-individual-dialogs.c +++ b/libempathy-gtk/empathy-individual-dialogs.c @@ -182,8 +182,6 @@ empathy_block_individual_dialog_show (GtkWindow *parent, GdkPixbuf *avatar, gboolean *abusive) { - EmpathyContactManager *contact_manager = - empathy_contact_manager_dup_singleton (); GtkWidget *dialog; GtkWidget *abusive_check = NULL; GeeSet *personas; @@ -214,9 +212,9 @@ empathy_block_individual_dialog_show (GtkWindow *parent, { TpfPersona *persona = gee_iterator_get (iter); TpContact *contact; - EmpathyContactListFlags flags; GString *s; char *str; + TpConnection *conn; if (!TPF_IS_PERSONA (persona)) goto while_finish; @@ -225,10 +223,10 @@ empathy_block_individual_dialog_show (GtkWindow *parent, if (contact == NULL) goto while_finish; - flags = empathy_contact_manager_get_flags_for_connection ( - contact_manager, tp_contact_get_connection (contact)); + conn = tp_contact_get_connection (contact); - if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK) + if (tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) { s = blocked_str; npersonas_blocked++; @@ -239,7 +237,7 @@ empathy_block_individual_dialog_show (GtkWindow *parent, npersonas_notblocked++; } - if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE) + if (tp_connection_can_report_abusive (conn)) can_report_abuse = TRUE; str = contact_pretty_name (contact); @@ -291,7 +289,6 @@ while_finish: gtk_widget_show (abusive_check); } - g_object_unref (contact_manager); g_string_free (text, TRUE); g_string_free (blocked_str, TRUE); g_string_free (notblocked_str, TRUE); diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c index f7529bf2e..edc5463c9 100644 --- a/libempathy/empathy-client-factory.c +++ b/libempathy/empathy-client-factory.c @@ -158,6 +158,15 @@ empathy_client_factory_dup_connection_features (TpSimpleClientFactory *factory, feature = TP_CONNECTION_FEATURE_BALANCE; g_array_append_val (features, feature); + feature = TP_CONNECTION_FEATURE_CONTACT_BLOCKING; + g_array_append_val (features, feature); + + /* Most empathy-* may allow user to add a contact to his contact list. We + * need this property to check if the connection allows it. It's cheap to + * prepare anyway as it will just call GetAll() on the ContactList iface. */ + feature = TP_CONNECTION_FEATURE_CONTACT_LIST_PROPERTIES; + g_array_append_val (features, feature); + return features; } diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 9e99ba46c..38d0a446a 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -236,27 +236,3 @@ empathy_contact_list_get_flags (EmpathyContactList *list) return 0; } } - -void -empathy_contact_list_set_blocked (EmpathyContactList *list, - EmpathyContact *contact, - gboolean blocked, - gboolean abusive) -{ - EmpathyContactListIface *iface = EMPATHY_CONTACT_LIST_GET_IFACE (list); - - if (iface->set_blocked != NULL) - iface->set_blocked (list, contact, blocked, abusive); -} - -gboolean -empathy_contact_list_get_blocked (EmpathyContactList *list, - EmpathyContact *contact) -{ - EmpathyContactListIface *iface = EMPATHY_CONTACT_LIST_GET_IFACE (list); - - if (iface->get_blocked != NULL) - return iface->get_blocked (list, contact); - else - return FALSE; -} diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 0e1d6a850..f1ed3e8ed 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -39,9 +39,7 @@ typedef enum { EMPATHY_CONTACT_LIST_CAN_REMOVE = 1 << 1, EMPATHY_CONTACT_LIST_CAN_ALIAS = 1 << 2, EMPATHY_CONTACT_LIST_CAN_GROUP = 1 << 3, - EMPATHY_CONTACT_LIST_CAN_BLOCK = 1 << 4, - EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE = 1 << 5, - EMPATHY_CONTACT_LIST_MESSAGE_ADD = 1 << 6, + EMPATHY_CONTACT_LIST_MESSAGE_ADD = 1 << 4, } EmpathyContactListFlags; typedef struct _EmpathyContactListIface EmpathyContactListIface; @@ -74,12 +72,6 @@ struct _EmpathyContactListIface { const gchar *group); EmpathyContactListFlags (*get_flags) (EmpathyContactList *list); - void (*set_blocked) (EmpathyContactList *list, - EmpathyContact *contact, - gboolean blocked, - gboolean abusive); - gboolean (*get_blocked) (EmpathyContactList *list, - EmpathyContact *contact); }; GType empathy_contact_list_get_type (void) G_GNUC_CONST; @@ -109,14 +101,6 @@ void empathy_contact_list_remove_group (EmpathyContactList *list, EmpathyContactListFlags empathy_contact_list_get_flags (EmpathyContactList *list); -void empathy_contact_list_set_blocked (EmpathyContactList *list, - EmpathyContact *contact, - gboolean blocked, - gboolean abusive); -gboolean empathy_contact_list_get_blocked (EmpathyContactList *list, - EmpathyContact *contact); - - G_END_DECLS #endif /* __EMPATHY_CONTACT_LIST_H__ */ diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 8db9a5a09..88012bf35 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -563,47 +563,6 @@ contact_manager_remove_group (EmpathyContactList *manager, } static void -contact_manager_set_blocked (EmpathyContactList *manager, - EmpathyContact *contact, - gboolean blocked, - gboolean abusive) -{ - EmpathyContactManagerPriv *priv = GET_PRIV (manager); - EmpathyContactList *list; - TpConnection *connection; - - g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager)); - - connection = empathy_contact_get_connection (contact); - list = g_hash_table_lookup (priv->lists, connection); - - if (list != NULL) { - empathy_contact_list_set_blocked (list, contact, - blocked, abusive); - } -} - -static gboolean -contact_manager_get_blocked (EmpathyContactList *manager, - EmpathyContact *contact) -{ - EmpathyContactManagerPriv *priv = GET_PRIV (manager); - EmpathyContactList *list; - TpConnection *connection; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE); - - connection = empathy_contact_get_connection (contact); - list = g_hash_table_lookup (priv->lists, connection); - - if (list != NULL) { - return empathy_contact_list_get_blocked (list, contact); - } else { - return FALSE; - } -} - -static void contact_manager_iface_init (EmpathyContactListIface *iface) { iface->add = contact_manager_add; @@ -616,8 +575,6 @@ contact_manager_iface_init (EmpathyContactListIface *iface) iface->remove_from_group = contact_manager_remove_from_group; iface->rename_group = contact_manager_rename_group; iface->remove_group = contact_manager_remove_group; - iface->set_blocked = contact_manager_set_blocked; - iface->get_blocked = contact_manager_get_blocked; } EmpathyContactListFlags diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 935afb556..572d49250 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -2071,3 +2071,53 @@ while_finish: return best_contact; } + +#define declare_contact_cb(name) \ +static void \ +contact_##name##_cb (GObject *source, \ + GAsyncResult *result, \ + gpointer user_data) \ +{ \ + TpContact *contact = (TpContact *) source; \ + GError *error = NULL; \ + \ + if (!tp_contact_##name##_finish (contact, result, &error)) \ + { \ + DEBUG ("Failed to ##name## on %s\n", \ + tp_contact_get_identifier (contact)); \ + g_error_free (error); \ + } \ +} + +declare_contact_cb(request_subscription) +declare_contact_cb(authorize_publication) +declare_contact_cb(unblock) + +void +empathy_contact_add_to_contact_list (EmpathyContact *self, + const gchar *message) +{ + EmpathyContactPriv *priv = GET_PRIV (self); + + g_return_if_fail (priv->tp_contact != NULL); + + tp_contact_request_subscription_async (priv->tp_contact, message, + contact_request_subscription_cb, NULL); + + tp_contact_authorize_publication_async (priv->tp_contact, + contact_authorize_publication_cb, NULL); + + tp_contact_unblock_async (priv->tp_contact, contact_unblock_cb, NULL); +} + +declare_contact_cb(remove) + +void +empathy_contact_remove_from_contact_list (EmpathyContact *self) +{ + EmpathyContactPriv *priv = GET_PRIV (self); + + g_return_if_fail (priv->tp_contact != NULL); + + tp_contact_remove_async (priv->tp_contact, contact_remove_cb, NULL); +} diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h index cb8f5a660..d90ea2ad4 100644 --- a/libempathy/empathy-contact.h +++ b/libempathy/empathy-contact.h @@ -138,6 +138,11 @@ EmpathyContact * empathy_contact_dup_best_for_action ( FolksIndividual *individual, EmpathyActionType action_type); +void empathy_contact_add_to_contact_list (EmpathyContact *self, + const gchar *message); + +void empathy_contact_remove_from_contact_list (EmpathyContact *self); + G_END_DECLS #endif /* __EMPATHY_CONTACT_H__ */ diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index 833a5692d..044610724 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -546,7 +546,6 @@ empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self, { TpfPersona *persona = gee_iterator_get (iter); TpConnection *conn; - EmpathyContactManager *manager; if (TPF_IS_PERSONA (persona)) { @@ -556,14 +555,10 @@ empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self, if (tp_contact != NULL) { conn = tp_contact_get_connection (tp_contact); - manager = empathy_contact_manager_dup_singleton (); - if (empathy_contact_manager_get_flags_for_connection ( - manager, conn) & - EMPATHY_CONTACT_LIST_CAN_BLOCK) + if (tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) retval = TRUE; - - g_object_unref (manager); } } g_clear_object (&persona); @@ -589,31 +584,26 @@ empathy_individual_manager_set_blocked (EmpathyIndividualManager *self, while (gee_iterator_next (iter)) { TpfPersona *persona = gee_iterator_get (iter); - EmpathyContact *contact; - EmpathyContactManager *manager; - EmpathyContactListFlags flags; if (TPF_IS_PERSONA (persona)) { TpContact *tp_contact; + TpConnection *conn; tp_contact = tpf_persona_get_contact (persona); - if (tp_contact != NULL) - { - contact = empathy_contact_dup_from_tp_contact (tp_contact); - empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); - manager = empathy_contact_manager_dup_singleton (); - flags = empathy_contact_manager_get_flags_for_connection (manager, - empathy_contact_get_connection (contact)); - - if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK) - empathy_contact_list_set_blocked ( - EMPATHY_CONTACT_LIST (manager), - contact, blocked, abusive); - - g_object_unref (manager); - g_object_unref (contact); - } + if (tp_contact == NULL) + continue; + + conn = tp_contact_get_connection (tp_contact); + + if (!tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) + continue; + + if (blocked) + tp_contact_block_async (tp_contact, abusive, NULL, NULL); + else + tp_contact_unblock_async (tp_contact, NULL, NULL); } g_clear_object (&persona); } diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 1cd2ba4ca..bf639e4ce 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -48,7 +48,6 @@ typedef struct { TpChannel *publish; TpChannel *subscribe; TpChannel *stored; - TpChannel *deny; /* contact handle (TpHandle) => reffed (EmpathyContact *) * * Union of: @@ -731,10 +730,6 @@ tp_contact_list_finalize (GObject *object) g_object_unref (priv->stored); } - if (priv->deny) { - g_object_unref (priv->deny); - } - if (priv->connection) { g_object_unref (priv->connection); } @@ -786,11 +781,6 @@ got_list_channel (EmpathyTpContactList *list, g_signal_connect (priv->subscribe, "group-members-changed", G_CALLBACK (tp_contact_list_subscribe_group_members_changed_cb), list); - } else if (!tp_strdiff (id, "deny")) { - if (priv->deny != NULL) - return; - DEBUG ("Got 'deny' channel"); - priv->deny = g_object_ref (channel); } } @@ -817,39 +807,6 @@ list_ensure_channel_cb (TpConnection *conn, } static void -list_get_contact_blocking_capabilities_cb (TpProxy *conn, - const GValue *value, - const GError *in_error, - gpointer user_data, - GObject *weak_object) -{ - EmpathyTpContactList *list = EMPATHY_TP_CONTACT_LIST (weak_object); - EmpathyTpContactListPriv *priv = GET_PRIV (list); - TpContactBlockingCapabilities caps; - - if (in_error != NULL) { - DEBUG ("Get(Blocking, ContactBlockingCapabilities) on %s failed: %s", - tp_proxy_get_object_path (conn), - in_error->message); - return; - } - - if (!G_VALUE_HOLDS_UINT (value)) { - DEBUG ("Get(Blocking, ContactBlockingCapabilities) on %s returned a %s, not a uint", - tp_proxy_get_object_path (conn), - G_VALUE_TYPE_NAME (value)); - return; - } - - caps = g_value_get_uint (value); - - if (caps & TP_CONTACT_BLOCKING_CAPABILITY_CAN_REPORT_ABUSIVE) { - DEBUG ("Connection can report abusive contacts"); - priv->flags |= EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE; - } -} - -static void iterate_on_channels (EmpathyTpContactList *list, const GPtrArray *channels) { @@ -957,25 +914,8 @@ conn_ready_cb (TpConnection *connection, tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); - /* Request the 'deny' list */ - tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "deny"); - tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, - G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); - g_hash_table_unref (request); - /* Find out if we support reporting abusive contacts -- - * this is done via the new Conn.I.ContactBlocking interface */ - if (tp_proxy_has_interface_by_id (priv->connection, - TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) { - DEBUG ("Have Conn.I.ContactBlocking"); - - tp_cli_dbus_properties_call_get (priv->connection, -1, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING, - "ContactBlockingCapabilities", - list_get_contact_blocking_capabilities_cb, - NULL, NULL, G_OBJECT (list)); - } out: g_object_unref (list); } @@ -1154,10 +1094,13 @@ tp_contact_list_add (EmpathyContactList *list, } } - if (priv->deny) { - tp_cli_channel_interface_group_call_remove_members ( - priv->deny, -1, &handles, message, - NULL, NULL, NULL, NULL); + /* We want to unblock the contact */ + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) { + TpContact *tp_contact = empathy_contact_get_tp_contact (contact); + + if (tp_contact != NULL) + tp_contact_unblock_async (tp_contact, NULL, NULL); } } @@ -1370,56 +1313,10 @@ tp_contact_list_get_flags (EmpathyContactList *list) } } - if (priv->deny != NULL) - flags |= EMPATHY_CONTACT_LIST_CAN_BLOCK; - return flags; } static void -tp_contact_list_set_blocked (EmpathyContactList *list, - EmpathyContact *contact, - gboolean blocked, - gboolean abusive) -{ - EmpathyTpContactListPriv *priv = GET_PRIV (list); - TpHandle handle = empathy_contact_get_handle (contact); - GArray handles = { (char *) &handle, 1 }; - - g_return_if_fail (TP_IS_CHANNEL (priv->deny)); - - if (blocked && abusive) { - /* we have to do this via the new interface */ - g_return_if_fail (priv->flags & - EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE); - - tp_cli_connection_interface_contact_blocking_call_block_contacts ( - priv->connection, -1, - &handles, TRUE, NULL, NULL, NULL, NULL); - } else if (blocked) { - tp_cli_channel_interface_group_call_add_members ( - priv->deny, -1, - &handles, NULL, NULL, NULL, NULL, NULL); - } else { - tp_cli_channel_interface_group_call_remove_members ( - priv->deny, -1, - &handles, NULL, NULL, NULL, NULL, NULL); - } -} - -static gboolean -tp_contact_list_get_blocked (EmpathyContactList *list, - EmpathyContact *contact) -{ - EmpathyTpContactListPriv *priv = GET_PRIV (list); - - g_return_val_if_fail (TP_IS_CHANNEL (priv->deny), FALSE); - - return tp_intset_is_member (tp_channel_group_get_members (priv->deny), - empathy_contact_get_handle (contact)); -} - -static void tp_contact_list_iface_init (EmpathyContactListIface *iface) { iface->add = tp_contact_list_add; @@ -1433,8 +1330,6 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface) iface->rename_group = tp_contact_list_rename_group; iface->remove_group = tp_contact_list_remove_group; iface->get_flags = tp_contact_list_get_flags; - iface->set_blocked = tp_contact_list_set_blocked; - iface->get_blocked = tp_contact_list_get_blocked; } void diff --git a/src/empathy-notifications-approver.c b/src/empathy-notifications-approver.c index c312a3be6..ac51459fb 100644 --- a/src/empathy-notifications-approver.c +++ b/src/empathy-notifications-approver.c @@ -27,7 +27,6 @@ #include <telepathy-yell/telepathy-yell.h> -#include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-tp-streamed-media.h> #include <libempathy-gtk/empathy-notify-manager.h> @@ -158,18 +157,12 @@ notification_decline_subscription_cb (NotifyNotification *notification, gchar *action, EmpathyNotificationsApprover *self) { - EmpathyContactManager *manager; - if (self->priv->event == NULL) return; - manager = empathy_contact_manager_dup_singleton (); - empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager), - self->priv->event->contact, ""); + empathy_contact_remove_from_contact_list (self->priv->event->contact); empathy_event_remove (self->priv->event); - - g_object_unref (manager); } static void @@ -177,18 +170,12 @@ notification_accept_subscription_cb (NotifyNotification *notification, gchar *action, EmpathyNotificationsApprover *self) { - EmpathyContactManager *manager; - if (self->priv->event == NULL) return; - manager = empathy_contact_manager_dup_singleton (); - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), - self->priv->event->contact, ""); + empathy_contact_add_to_contact_list (self->priv->event->contact, ""); empathy_event_remove (self->priv->event); - - g_object_unref (manager); } static void diff --git a/src/empathy-streamed-media-handler.c b/src/empathy-streamed-media-handler.c index 67527d8e4..a3c539773 100644 --- a/src/empathy-streamed-media-handler.c +++ b/src/empathy-streamed-media-handler.c @@ -708,27 +708,6 @@ empathy_streamed_media_handler_tf_channel_closed_cb (TfChannel *tfchannel, g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0); } -static GList * -empathy_streamed_media_handler_tf_channel_codec_config_cb (TfChannel *channel, - guint stream_id, FsMediaType media_type, guint direction, gpointer user_data) -{ - gchar *filename = empathy_file_lookup ("codec-preferences", "data"); - GList *codecs; - GError *error = NULL; - - codecs = fs_codec_list_from_keyfile (filename, &error); - g_free (filename); - - if (!codecs) - { - g_warning ("No codec-preferences file: %s", - error ? error->message : "No error message"); - } - g_clear_error (&error); - - return codecs; -} - static void empathy_streamed_media_handler_start_tpfs (EmpathyStreamedMediaHandler *self) { @@ -748,8 +727,6 @@ empathy_streamed_media_handler_start_tpfs (EmpathyStreamedMediaHandler *self) G_CALLBACK (empathy_streamed_media_handler_tf_channel_stream_created_cb), self); g_signal_connect (priv->tfchannel, "closed", G_CALLBACK (empathy_streamed_media_handler_tf_channel_closed_cb), self); - g_signal_connect (priv->tfchannel, "stream-get-codec-config", - G_CALLBACK (empathy_streamed_media_handler_tf_channel_codec_config_cb), self); g_object_unref (channel); } diff --git a/src/empathy-streamed-media-window.c b/src/empathy-streamed-media-window.c index c74910b6b..22ecbd282 100644 --- a/src/empathy-streamed-media-window.c +++ b/src/empathy-streamed-media-window.c @@ -35,6 +35,7 @@ #include <telepathy-glib/util.h> #include <gst/farsight/fs-element-added-notifier.h> +#include <gst/farsight/fs-utils.h> #include <libempathy/empathy-tp-contact-factory.h> #include <libempathy/empathy-utils.h> @@ -981,8 +982,6 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self) GtkWidget *arrow; GtkWidget *page; gchar *filename; - GKeyFile *keyfile; - GError *error = NULL; GtkWidget *scroll; filename = empathy_file_lookup ("empathy-streamed-media-window.ui", "src"); @@ -1084,21 +1083,6 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self) /* The call will be started as soon the pipeline is playing */ priv->start_call_when_playing = TRUE; - keyfile = g_key_file_new (); - filename = empathy_file_lookup ("element-properties", "data"); - if (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error)) - { - fs_element_added_notifier_set_properties_from_keyfile (priv->fsnotifier, - keyfile); - } - else - { - g_warning ("Could not load element-properties file: %s", error->message); - g_key_file_free (keyfile); - g_clear_error (&error); - } - g_free (filename); - priv->vbox = gtk_vbox_new (FALSE, 3); gtk_box_pack_start (GTK_BOX (priv->content_hbox), priv->vbox, FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING); @@ -1759,6 +1743,12 @@ empathy_streamed_media_window_conference_added_cb (EmpathyStreamedMediaHandler * { EmpathyStreamedMediaWindow *self = EMPATHY_STREAMED_MEDIA_WINDOW (user_data); EmpathyStreamedMediaWindowPriv *priv = GET_PRIV (self); + GKeyFile *keyfile; + + keyfile = fs_utils_get_default_element_properties (conference); + if (keyfile != NULL) + fs_element_added_notifier_set_properties_from_keyfile (priv->fsnotifier, + keyfile); gst_bin_add (GST_BIN (priv->pipeline), conference); |