]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-contact-blocking-dialog.c
Merge branch 'gnome-3-8'
[empathy.git] / libempathy-gtk / empathy-contact-blocking-dialog.c
1 /*
2  * empathy-contact-blocking-dialog.c
3  *
4  * EmpathyContactBlockingDialog
5  *
6  * Copyright (C) 2011 Collabora Ltd.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
23  */
24
25 #include "config.h"
26 #include "empathy-contact-blocking-dialog.h"
27
28 #include <glib/gi18n-lib.h>
29 #include <tp-account-widgets/tpaw-builder.h>
30
31 #include "empathy-account-chooser.h"
32 #include "empathy-ui-utils.h"
33 #include "empathy-utils.h"
34
35 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
36 #include "empathy-debug.h"
37
38 #define GET_PRIVATE(o) (EMPATHY_CONTACT_BLOCKING_DIALOG (o)->priv)
39 #define DECLARE_CALLBACK(func) \
40   static void func (GObject *, GAsyncResult *, gpointer);
41
42 G_DEFINE_TYPE (EmpathyContactBlockingDialog, empathy_contact_blocking_dialog,
43     GTK_TYPE_DIALOG);
44
45 struct _EmpathyContactBlockingDialogPrivate
46 {
47   guint block_account_changed;
48
49   GtkListStore *blocked_contacts;
50   GtkListStore *completion_contacts;
51   GtkTreeSelection *selection;
52
53   GtkWidget *account_chooser;
54   GtkWidget *add_button;
55   GtkWidget *add_contact_entry;
56   GtkWidget *info_bar;
57   GtkWidget *info_bar_label;
58   GtkWidget *remove_button;
59
60   TpConnection *current_conn;
61 };
62
63 enum /* blocked-contacts columns */
64 {
65   COL_BLOCKED_IDENTIFIER,
66   COL_BLOCKED_CONTACT,
67   N_BLOCKED_COLUMNS
68 };
69
70 enum /* completion_contacts columns */
71 {
72   COL_COMPLETION_IDENTIFIER,
73   COL_COMPLETION_TEXT,
74   N_COMPLETION_COLUMNS
75 };
76
77 static const char *
78 get_pretty_conn_name (TpConnection *conn)
79 {
80   return tp_proxy_get_object_path (conn) + strlen (TP_CONN_OBJECT_PATH_BASE);
81 }
82
83 static void
84 contact_blocking_dialog_filter_account_chooser (TpAccount *account,
85     EmpathyAccountChooserFilterResultCallback callback,
86     gpointer callback_data,
87     gpointer user_data)
88 {
89   TpConnection *conn = tp_account_get_connection (account);
90   gboolean enable;
91
92   enable =
93     conn != NULL &&
94     tp_proxy_has_interface_by_id (conn,
95       TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING);
96
97   callback (enable, callback_data);
98 }
99
100 static void contact_blocking_dialog_account_changed (GtkWidget *,
101     EmpathyContactBlockingDialog *);
102
103 static void
104 contact_blocking_dialog_refilter_account_chooser (
105     EmpathyContactBlockingDialog *self)
106 {
107   EmpathyAccountChooser *chooser =
108     EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
109   TpConnection *conn;
110   gboolean enabled;
111
112   DEBUG ("Refiltering account chooser");
113
114   /* set the filter to refilter the account chooser */
115   self->priv->block_account_changed++;
116   empathy_account_chooser_set_filter (chooser,
117       contact_blocking_dialog_filter_account_chooser, self);
118   self->priv->block_account_changed--;
119
120   conn = empathy_account_chooser_get_connection (chooser);
121   enabled = (empathy_account_chooser_get_account (chooser) != NULL &&
122              conn != NULL &&
123              tp_proxy_has_interface_by_id (conn,
124                TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING));
125
126   if (!enabled)
127     DEBUG ("No account selected");
128
129   gtk_widget_set_sensitive (self->priv->add_button, enabled);
130   gtk_widget_set_sensitive (self->priv->add_contact_entry, enabled);
131
132   contact_blocking_dialog_account_changed (self->priv->account_chooser, self);
133 }
134
135 static void
136 contact_blocking_dialog_add_blocked (
137     EmpathyContactBlockingDialog *self,
138     GPtrArray *blocked)
139 {
140   EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
141   guint i;
142
143   if (blocked == NULL)
144     return;
145
146   for (i = 0; i < blocked->len; i++)
147     {
148       TpContact *contact = g_ptr_array_index (blocked, i);
149
150       gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1,
151           COL_BLOCKED_IDENTIFIER, tp_contact_get_identifier (contact),
152           COL_BLOCKED_CONTACT, contact,
153           -1);
154     }
155 }
156
157 static void
158 blocked_contacts_changed_cb (TpConnection *conn,
159     GPtrArray *added,
160     GPtrArray *removed,
161     EmpathyContactBlockingDialog *self)
162 {
163   GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts);
164   GtkTreeIter iter;
165   gboolean valid;
166
167   DEBUG ("blocked contacts changed on %s: %u added, %u removed",
168       get_pretty_conn_name (conn), added->len, removed->len);
169
170   /* add contacts */
171   contact_blocking_dialog_add_blocked (self, added);
172
173   /* remove contacts */
174   valid = gtk_tree_model_get_iter_first (model, &iter);
175   while (valid)
176     {
177       TpContact *contact;
178
179       gtk_tree_model_get (model, &iter,
180           COL_BLOCKED_CONTACT, &contact,
181           -1);
182
183       if (tp_g_ptr_array_contains (removed, contact))
184         valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter);
185       else
186         valid = gtk_tree_model_iter_next (model, &iter);
187
188       g_object_unref (contact);
189     }
190 }
191
192 static void
193 contact_blocking_dialog_connection_status_changed (TpAccount *account,
194     guint old_status,
195     guint new_status,
196     guint reason,
197     const char *dbus_reason,
198     GHashTable *details,
199     EmpathyContactBlockingDialog *self)
200 {
201   TpConnection *conn = tp_account_get_connection (account);
202
203   switch (new_status)
204     {
205       case TP_CONNECTION_STATUS_DISCONNECTED:
206         DEBUG ("Connection %s invalidated", get_pretty_conn_name (conn));
207
208         contact_blocking_dialog_refilter_account_chooser (self);
209         break;
210
211       case TP_CONNECTION_STATUS_CONNECTING:
212         break;
213
214       case TP_CONNECTION_STATUS_CONNECTED:
215         DEBUG ("Connection %s reconnected", get_pretty_conn_name (conn));
216
217         contact_blocking_dialog_refilter_account_chooser (self);
218     }
219 }
220
221 static void
222 contact_blocking_dialog_am_prepared (GObject *am,
223     GAsyncResult *result,
224     gpointer user_data)
225 {
226   EmpathyContactBlockingDialog *self = user_data;
227   GList *accounts, *ptr;
228   GError *error = NULL;
229
230   if (!tp_proxy_prepare_finish (am, result, &error))
231     {
232       g_critical ("Could not prepare Account Manager: %s", error->message);
233       g_error_free (error);
234       return;
235     }
236
237   accounts = tp_account_manager_dup_valid_accounts (TP_ACCOUNT_MANAGER (am));
238
239   for (ptr = accounts; ptr != NULL; ptr = ptr->next)
240     {
241       TpAccount *account = ptr->data;
242
243       tp_g_signal_connect_object (account, "status-changed",
244           G_CALLBACK (contact_blocking_dialog_connection_status_changed),
245           self, 0);
246
247       contact_blocking_dialog_refilter_account_chooser (self);
248     }
249
250   g_list_free_full (accounts, g_object_unref);
251 }
252
253 static void
254 contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self,
255     const GError *error)
256 {
257   const char *msg = NULL;
258
259   if (error->domain == TP_ERROR)
260     {
261       if (error->code == TP_ERROR_INVALID_HANDLE)
262         msg = _("Unknown or invalid identifier");
263       else if (error->code == TP_ERROR_NOT_AVAILABLE)
264         msg = _("Contact blocking temporarily unavailable");
265       else if (error->code == TP_ERROR_NOT_CAPABLE)
266         msg = _("Contact blocking unavailable");
267       else if (error->code == TP_ERROR_PERMISSION_DENIED)
268         msg = _("Permission Denied");
269     }
270
271   if (msg == NULL)
272     msg = _("Could not block contact");
273
274   gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg);
275   gtk_widget_show (self->priv->info_bar);
276 }
277
278 static void
279 block_cb (GObject *source,
280     GAsyncResult *result,
281     gpointer user_data)
282 {
283   EmpathyContactBlockingDialog *self = user_data;
284   GError *error = NULL;
285
286   if (!tp_contact_block_finish (TP_CONTACT (source), result,
287         &error))
288     {
289       DEBUG ("Error blocking contacts: %s", error->message);
290
291       contact_blocking_dialog_set_error (
292           EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
293
294       g_error_free (error);
295       return;
296     }
297
298   DEBUG ("Contact blocked");
299 }
300
301 static void
302 block_contact_got_contact (GObject *source,
303     GAsyncResult *result,
304     gpointer user_data)
305 {
306   EmpathyContactBlockingDialog *self;
307   TpConnection *conn =  TP_CONNECTION (source);
308   TpWeakRef *wr = user_data;
309   TpContact *contact;
310   GError *error = NULL;
311
312   self = tp_weak_ref_dup_object (wr);
313   if (self == NULL)
314     goto finally;
315
316   contact = tp_connection_dup_contact_by_id_finish (conn, result, &error);
317   if (contact == NULL)
318     {
319       DEBUG ("Error getting contact on %s: %s",
320           get_pretty_conn_name (conn), error->message);
321
322       contact_blocking_dialog_set_error (
323           EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
324
325       g_error_free (error);
326       goto finally;
327     }
328
329   tp_contact_block_async (contact, FALSE, block_cb, self);
330   g_object_unref (contact);
331
332 finally:
333   g_clear_object (&self);
334   tp_weak_ref_destroy (wr);
335 }
336
337 static void
338 contact_blocking_dialog_add_contact (GtkWidget *widget,
339     EmpathyContactBlockingDialog *self)
340 {
341   TpConnection *conn = empathy_account_chooser_get_connection (
342       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
343   const char *identifier;
344
345   identifier = gtk_entry_get_text (
346       GTK_ENTRY (self->priv->add_contact_entry));
347
348   DEBUG ("Looking up handle for '%s' on %s",
349       identifier, get_pretty_conn_name (conn));
350
351   tp_connection_dup_contact_by_id_async (conn, identifier,
352       0, NULL, block_contact_got_contact,
353       tp_weak_ref_new (self, NULL, NULL));
354
355   gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
356   gtk_widget_hide (self->priv->info_bar);
357 }
358
359 static void
360 unblock_cb (GObject *source,
361     GAsyncResult *result,
362     gpointer user_data)
363 {
364   EmpathyContactBlockingDialog *self = user_data;
365   GError *error = NULL;
366
367   if (!tp_connection_unblock_contacts_finish (TP_CONNECTION (source), result,
368         &error))
369     {
370       DEBUG ("Error unblocking contacts: %s", error->message);
371
372       contact_blocking_dialog_set_error (
373           EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
374
375       g_error_free (error);
376       return;
377     }
378
379   DEBUG ("Contacts unblocked");
380 }
381
382 static void
383 contact_blocking_dialog_remove_contacts (GtkWidget *button,
384     EmpathyContactBlockingDialog *self)
385 {
386   TpConnection *conn = empathy_account_chooser_get_connection (
387       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
388   GtkTreeModel *model;
389   GList *rows, *ptr;
390   GPtrArray *contacts;
391
392   rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model);
393
394   contacts = g_ptr_array_new_with_free_func (g_object_unref);
395
396   for (ptr = rows; ptr != NULL; ptr = ptr->next)
397     {
398       GtkTreePath *path = ptr->data;
399       GtkTreeIter iter;
400       TpContact *contact;
401
402       if (!gtk_tree_model_get_iter (model, &iter, path))
403         continue;
404
405       gtk_tree_model_get (model, &iter,
406           COL_BLOCKED_CONTACT, &contact,
407           -1);
408
409       g_ptr_array_add (contacts, contact);
410
411       gtk_tree_path_free (path);
412     }
413
414   g_list_free (rows);
415
416   if (contacts->len > 0)
417     {
418       DEBUG ("Unblocking %u contacts", contacts->len);
419
420       tp_connection_unblock_contacts_async (conn, contacts->len,
421           (TpContact * const *) contacts->pdata, unblock_cb, self);
422     }
423
424   g_ptr_array_unref (contacts);
425 }
426
427 static void
428 contact_blocking_dialog_account_changed (GtkWidget *account_chooser,
429     EmpathyContactBlockingDialog *self)
430 {
431   TpConnection *conn = empathy_account_chooser_get_connection (
432       EMPATHY_ACCOUNT_CHOOSER (account_chooser));
433   GPtrArray *blocked;
434   GPtrArray *members;
435   guint i;
436
437   if (self->priv->block_account_changed > 0)
438     return;
439
440   if (conn == self->priv->current_conn)
441     return;
442
443   /* clear the lists of contacts */
444   gtk_list_store_clear (self->priv->blocked_contacts);
445   gtk_list_store_clear (self->priv->completion_contacts);
446
447   if (self->priv->current_conn != NULL)
448     {
449       g_signal_handlers_disconnect_by_func (self->priv->current_conn,
450           blocked_contacts_changed_cb, self);
451
452       g_clear_object (&self->priv->current_conn);
453     }
454
455   if (conn == NULL)
456     return;
457
458   DEBUG ("Account changed: %s", get_pretty_conn_name (conn));
459
460   self->priv->current_conn = g_object_ref (conn);
461
462   tp_g_signal_connect_object (conn, "blocked-contacts-changed",
463       G_CALLBACK (blocked_contacts_changed_cb), self, 0);
464
465   blocked = tp_connection_get_blocked_contacts (conn);
466
467   DEBUG ("%u contacts blocked on %s",
468       blocked != NULL ? blocked->len : 0, get_pretty_conn_name (conn));
469
470   contact_blocking_dialog_add_blocked (self, blocked);
471
472   DEBUG ("Loading contacts");
473
474   members = tp_connection_dup_contact_list (conn);
475
476   for (i = 0; i < members->len; i++)
477     {
478       TpContact *contact = g_ptr_array_index (members, i);
479       gchar *tmpstr;
480
481       tmpstr = g_strdup_printf ("%s (%s)",
482           tp_contact_get_alias (contact),
483           tp_contact_get_identifier (contact));
484
485       gtk_list_store_insert_with_values (self->priv->completion_contacts,
486           NULL, -1,
487           COL_COMPLETION_IDENTIFIER, tp_contact_get_identifier (contact),
488           COL_COMPLETION_TEXT, tmpstr,
489           -1);
490
491       g_free (tmpstr);
492     }
493
494   g_ptr_array_unref (members);
495 }
496
497 static void
498 contact_blocking_dialog_view_selection_changed (GtkTreeSelection *selection,
499     EmpathyContactBlockingDialog *self)
500 {
501   GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL);
502
503   /* update the sensitivity of the remove button */
504   gtk_widget_set_sensitive (self->priv->remove_button, rows != NULL);
505
506   g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
507   g_list_free (rows);
508 }
509
510 static gboolean
511 contact_selector_dialog_match_func (GtkEntryCompletion *completion,
512     const gchar *key,
513     GtkTreeIter *iter,
514     gpointer user_data)
515 {
516   GtkTreeModel *model;
517   gchar *str, *lower;
518   gboolean v = FALSE;
519
520   model = gtk_entry_completion_get_model (completion);
521   if (model == NULL || iter == NULL)
522     return FALSE;
523
524   gtk_tree_model_get (model, iter, COL_COMPLETION_TEXT, &str, -1);
525   lower = g_utf8_strdown (str, -1);
526   if (strstr (lower, key))
527     {
528       DEBUG ("Key %s is matching name **%s**", key, str);
529       v = TRUE;
530       goto out;
531     }
532   g_free (str);
533   g_free (lower);
534
535   gtk_tree_model_get (model, iter, COL_COMPLETION_IDENTIFIER, &str, -1);
536   lower = g_utf8_strdown (str, -1);
537   if (strstr (lower, key))
538     {
539       DEBUG ("Key %s is matching ID **%s**", key, str);
540       v = TRUE;
541       goto out;
542     }
543
544 out:
545   g_free (str);
546   g_free (lower);
547
548   return v;
549 }
550
551 static gboolean
552 contact_selector_dialog_match_selected_cb (GtkEntryCompletion *widget,
553     GtkTreeModel *model,
554     GtkTreeIter *iter,
555     EmpathyContactBlockingDialog *self)
556 {
557   gchar *id;
558
559   if (iter == NULL || model == NULL)
560     return FALSE;
561
562   gtk_tree_model_get (model, iter, COL_COMPLETION_IDENTIFIER, &id, -1);
563   gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), id);
564
565   DEBUG ("Got selected match **%s**", id);
566
567   g_free (id);
568
569   return TRUE;
570 }
571
572 static void
573 contact_blocking_dialog_dispose (GObject *self)
574 {
575   EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
576
577   g_clear_object (&priv->current_conn);
578
579   G_OBJECT_CLASS (empathy_contact_blocking_dialog_parent_class)->dispose (self);
580 }
581
582 static void
583 empathy_contact_blocking_dialog_class_init (
584     EmpathyContactBlockingDialogClass *klass)
585 {
586   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
587
588   gobject_class->dispose = contact_blocking_dialog_dispose;
589
590   g_type_class_add_private (gobject_class,
591       sizeof (EmpathyContactBlockingDialogPrivate));
592 }
593
594 static void
595 empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
596 {
597   GtkBuilder *gui;
598   char *filename;
599   GtkWidget *contents;
600   GtkWidget *account_hbox, *blocked_contacts_view, *blocked_contacts_sw,
601       *remove_toolbar;
602   GtkEntryCompletion *completion;
603   TpAccountManager *am;
604   GtkStyleContext *context;
605   TpSimpleClientFactory *factory;
606
607   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
608       EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
609       EmpathyContactBlockingDialogPrivate);
610
611   gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts"));
612   gtk_dialog_add_button (GTK_DIALOG (self),
613       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
614
615   filename = empathy_file_lookup ("empathy-contact-blocking-dialog.ui",
616       "libempathy-gtk");
617
618   gui = tpaw_builder_get_file (filename,
619       "contents", &contents,
620       "account-hbox", &account_hbox,
621       "add-button", &self->priv->add_button,
622       "add-contact-entry", &self->priv->add_contact_entry,
623       "blocked-contacts", &self->priv->blocked_contacts,
624       "blocked-contacts-sw", &blocked_contacts_sw,
625       "blocked-contacts-view", &blocked_contacts_view,
626       "remove-button", &self->priv->remove_button,
627       "remove-toolbar", &remove_toolbar,
628       NULL);
629
630   tpaw_builder_connect (gui, self,
631       "add-button", "clicked", contact_blocking_dialog_add_contact,
632       "add-contact-entry", "activate", contact_blocking_dialog_add_contact,
633       "remove-button", "clicked", contact_blocking_dialog_remove_contacts,
634       NULL);
635
636   /* join the remove toolbar to the treeview */
637   context = gtk_widget_get_style_context (blocked_contacts_sw);
638   gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
639   context = gtk_widget_get_style_context (remove_toolbar);
640   gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
641
642   /* add the contents to the dialog */
643   gtk_container_add (
644       GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
645       contents);
646   gtk_widget_show (contents);
647
648   /* set up the tree selection */
649   self->priv->selection = gtk_tree_view_get_selection (
650       GTK_TREE_VIEW (blocked_contacts_view));
651   gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_MULTIPLE);
652   g_signal_connect (self->priv->selection, "changed",
653       G_CALLBACK (contact_blocking_dialog_view_selection_changed), self);
654
655   /* build the contact entry */
656   self->priv->completion_contacts = gtk_list_store_new (N_COMPLETION_COLUMNS,
657       G_TYPE_STRING, /* id */
658       G_TYPE_STRING, /* text */
659       TP_TYPE_CONTACT); /* contact */
660
661   completion = gtk_entry_completion_new ();
662   gtk_entry_completion_set_model (completion,
663       GTK_TREE_MODEL (self->priv->completion_contacts));
664   gtk_entry_completion_set_text_column (completion, COL_COMPLETION_TEXT);
665   gtk_entry_completion_set_match_func (completion,
666       contact_selector_dialog_match_func,
667       NULL, NULL);
668   g_signal_connect (completion, "match-selected",
669         G_CALLBACK (contact_selector_dialog_match_selected_cb),
670         self);
671   gtk_entry_set_completion (GTK_ENTRY (self->priv->add_contact_entry),
672       completion);
673   g_object_unref (completion);
674   g_object_unref (self->priv->completion_contacts);
675
676   /* add the account chooser */
677   self->priv->account_chooser = empathy_account_chooser_new ();
678   contact_blocking_dialog_refilter_account_chooser (self);
679   g_signal_connect (self->priv->account_chooser, "changed",
680       G_CALLBACK (contact_blocking_dialog_account_changed), self);
681
682   gtk_box_pack_start (GTK_BOX (account_hbox), self->priv->account_chooser,
683       TRUE, TRUE, 0);
684   gtk_widget_show (self->priv->account_chooser);
685
686   /* add an error warning info bar */
687   self->priv->info_bar = gtk_info_bar_new ();
688   gtk_box_pack_start (GTK_BOX (contents), self->priv->info_bar, FALSE, TRUE, 0);
689   gtk_info_bar_set_message_type (GTK_INFO_BAR (self->priv->info_bar),
690       GTK_MESSAGE_ERROR);
691
692   self->priv->info_bar_label = gtk_label_new ("");
693   gtk_container_add (GTK_CONTAINER (
694         gtk_info_bar_get_content_area (GTK_INFO_BAR (self->priv->info_bar))),
695       self->priv->info_bar_label);
696   gtk_widget_show (self->priv->info_bar_label);
697
698   /* prepare the account manager */
699   am = tp_account_manager_dup ();
700
701   factory = tp_proxy_get_factory (am);
702   tp_simple_client_factory_add_connection_features_varargs (factory,
703       TP_CONNECTION_FEATURE_CONTACT_BLOCKING, NULL);
704
705   tp_proxy_prepare_async (am, NULL, contact_blocking_dialog_am_prepared, self);
706   g_object_unref (am);
707
708   g_free (filename);
709   g_object_unref (gui);
710 }
711
712 GtkWidget *
713 empathy_contact_blocking_dialog_new (GtkWindow *parent)
714 {
715   GtkWidget *self = g_object_new (EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
716       NULL);
717
718   if (parent != NULL)
719     {
720       gtk_window_set_transient_for (GTK_WINDOW (self), parent);
721     }
722
723   return self;
724 }