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