]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-contact-blocking-dialog.c
Updated Telugu translation
[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 #include "config.h"
25
26 #include <glib/gi18n-lib.h>
27
28 #include <libempathy/empathy-utils.h>
29
30 #include <libempathy-gtk/empathy-account-chooser.h>
31 #include <libempathy-gtk/empathy-ui-utils.h>
32
33 #include "empathy-contact-blocking-dialog.h"
34
35 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
36 #include <libempathy/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_get_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 (accounts);
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_ERRORS)
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 (TpConnection *conn,
303     guint n_contacts,
304     TpContact * const *contacts,
305     const gchar * const *requested_ids,
306     GHashTable *failed_id_errors,
307     const GError *error,
308     gpointer user_data,
309     GObject *weak_object)
310 {
311   EmpathyContactBlockingDialog *self =
312     EMPATHY_CONTACT_BLOCKING_DIALOG (weak_object);
313   gchar *id = user_data;
314
315   if (error != NULL)
316     goto error;
317
318   error = g_hash_table_lookup (failed_id_errors, id);
319   if (error != NULL)
320     goto error;
321
322   tp_contact_block_async (contacts[0], FALSE, block_cb, self);
323   goto finally;
324
325 error:
326   DEBUG ("Error getting contact on %s: %s",
327       get_pretty_conn_name (conn), error->message);
328
329   contact_blocking_dialog_set_error (
330       EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
331
332 finally:
333   g_free (id);
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 *identifiers[2] = { NULL, };
343
344   identifiers[0] = gtk_entry_get_text (
345       GTK_ENTRY (self->priv->add_contact_entry));
346
347   DEBUG ("Looking up handle for '%s' on %s",
348       identifiers[0], get_pretty_conn_name (conn));
349
350   tp_connection_get_contacts_by_id (conn, 1, identifiers,
351       0, NULL, block_contact_got_contact,
352       g_strdup (identifiers[0]), NULL, G_OBJECT (self));
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 }