]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-contact-blocking-dialog.c
Provide autocompletion of known contacts in the entry box
[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 <glib/gi18n.h>
26
27 #include <libempathy/empathy-utils.h>
28
29 #include <libempathy/empathy-contact-manager.h>
30 #include <libempathy/empathy-tp-contact-list.h>
31
32 #include <libempathy-gtk/empathy-account-chooser.h>
33 #include <libempathy-gtk/empathy-ui-utils.h>
34
35 #include "empathy-contact-blocking-dialog.h"
36
37 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
38 #include <libempathy/empathy-debug.h>
39
40 #define GET_PRIVATE(o) (EMPATHY_CONTACT_BLOCKING_DIALOG (o)->priv)
41 #define DECLARE_CALLBACK(func) \
42   static void func (GObject *, GAsyncResult *, gpointer);
43
44 G_DEFINE_TYPE (EmpathyContactBlockingDialog, empathy_contact_blocking_dialog,
45     GTK_TYPE_DIALOG);
46
47 struct _EmpathyContactBlockingDialogPrivate
48 {
49   GHashTable *channels; /* TpConnection* -> TpChannel* */
50   GtkListStore *blocked_contacts;
51   GtkListStore *completion_contacts;
52   GtkTreeSelection *selection;
53
54   GtkWidget *account_chooser;
55   GtkWidget *add_contact_entry;
56   GtkWidget *remove_button;
57 };
58
59 enum /* blocked-contacts columns */
60 {
61   COL_IDENTIFIER,
62   COL_HANDLE,
63   N_COLUMNS
64 };
65
66 static const char *
67 get_pretty_conn_name (TpConnection *conn)
68 {
69   return tp_proxy_get_object_path (conn) + strlen (TP_CONN_OBJECT_PATH_BASE);
70 }
71
72 static void
73 contact_blocking_dialog_filter_account_chooser (TpAccount *account,
74     EmpathyAccountChooserFilterResultCallback callback,
75     gpointer callback_data,
76     gpointer user_data)
77 {
78   EmpathyContactBlockingDialog *self = user_data;
79   TpConnection *conn = tp_account_get_connection (account);
80   gboolean enable;
81
82   enable =
83     conn != NULL &&
84     g_hash_table_lookup (self->priv->channels, conn) != NULL;
85
86   callback (enable, callback_data);
87 }
88
89 static void contact_blocking_dialog_inspected_handles (TpConnection *,
90     const char **, const GError *, gpointer, GObject *);
91
92 static void
93 contact_blocking_dialog_add_contacts_to_list (
94     EmpathyContactBlockingDialog *self,
95     TpConnection *conn,
96     GArray *handles)
97 {
98   if (handles->len > 0)
99     tp_cli_connection_call_inspect_handles (conn, -1,
100         TP_HANDLE_TYPE_CONTACT, handles,
101         contact_blocking_dialog_inspected_handles,
102         g_boxed_copy (DBUS_TYPE_G_UINT_ARRAY, handles),
103         (GDestroyNotify) g_array_unref, G_OBJECT (self));
104 }
105
106 static void
107 contact_blocking_dialog_inspected_handles (TpConnection *conn,
108     const char **identifiers,
109     const GError *in_error,
110     gpointer user_data,
111     GObject *self)
112 {
113   EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
114   GArray *handles = user_data;
115   guint i;
116
117   if (in_error != NULL)
118     {
119       DEBUG ("Failed to inspect handles: %s", in_error->message);
120       return;
121     }
122
123   DEBUG ("Adding %u identifiers", handles->len);
124
125   for (i = 0; i < handles->len; i++)
126     {
127       const char *identifier = identifiers[i];
128       TpHandle handle = g_array_index (handles, TpHandle, i);
129
130       gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1,
131           COL_IDENTIFIER, identifier,
132           COL_HANDLE, handle,
133           -1);
134     }
135 }
136
137 DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared);
138
139 static void
140 contact_blocking_dialog_connection_status_changed (TpAccount *account,
141     guint old_status,
142     guint new_status,
143     guint reason,
144     const char *dbus_reason,
145     GHashTable *details,
146     EmpathyContactBlockingDialog *self)
147 {
148   TpConnection *conn = tp_account_get_connection (account);
149
150   switch (new_status)
151     {
152       case TP_CONNECTION_STATUS_DISCONNECTED:
153         DEBUG ("Connection %s invalidated", get_pretty_conn_name (conn));
154
155         /* remove the channel from the hash table */
156         g_hash_table_remove (self->priv->channels, conn);
157
158         /* set the filter again to refilter the account list */
159         empathy_account_chooser_set_filter (
160             EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser),
161             contact_blocking_dialog_filter_account_chooser, self);
162         break;
163
164       case TP_CONNECTION_STATUS_CONNECTING:
165         break;
166
167       case TP_CONNECTION_STATUS_CONNECTED:
168         DEBUG ("Connection %s reconnected", get_pretty_conn_name (conn));
169
170         tp_proxy_prepare_async (conn, NULL,
171             contact_blocking_dialog_connection_prepared, self);
172     }
173 }
174
175 static void
176 contact_blocking_dialog_deny_channel_members_changed (TpChannel *channel,
177     const char *message,
178     GArray *added,
179     GArray *removed,
180     GArray *local_pending,
181     GArray *remote_pending,
182     TpHandle actor,
183     guint reason,
184     EmpathyContactBlockingDialog *self)
185 {
186   TpConnection *conn = tp_channel_borrow_connection (channel);
187   GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts);
188   GtkTreeIter iter;
189   TpIntset *removed_set;
190   gboolean valid;
191
192   /* we only care about changes to the selected connection */
193   /* FIXME: can we compare proxy pointers directly? */
194   if (tp_strdiff (
195         tp_proxy_get_object_path (tp_channel_borrow_connection (channel)),
196         tp_proxy_get_object_path (empathy_account_chooser_get_connection (
197             EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)))))
198     return;
199
200   DEBUG ("deny list changed: %u added, %u removed", added->len, removed->len);
201
202   /* add contacts */
203   contact_blocking_dialog_add_contacts_to_list (self, conn, added);
204
205   /* remove contacts */
206   removed_set = tp_intset_from_array (removed);
207
208   valid = gtk_tree_model_get_iter_first (model, &iter);
209   while (valid)
210     {
211       TpHandle handle;
212
213       gtk_tree_model_get (model, &iter,
214           COL_HANDLE, &handle,
215           -1);
216
217       if (tp_intset_is_member (removed_set, handle))
218         valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter);
219       else
220         valid = gtk_tree_model_iter_next (model, &iter);
221     }
222
223   tp_intset_destroy (removed_set);
224 }
225
226 DECLARE_CALLBACK (contact_blocking_dialog_account_prepared);
227
228 static void
229 contact_blocking_dialog_am_prepared (GObject *am,
230     GAsyncResult *result,
231     gpointer user_data)
232 {
233   EmpathyContactBlockingDialog *self = user_data;
234   GList *accounts, *ptr;
235   GError *error = NULL;
236
237   if (!tp_proxy_prepare_finish (am, result, &error))
238     {
239       g_critical ("Could not prepare Account Manager: %s", error->message);
240       g_error_free (error);
241       return;
242     }
243
244   accounts = tp_account_manager_get_valid_accounts (TP_ACCOUNT_MANAGER (am));
245
246   for (ptr = accounts; ptr != NULL; ptr = ptr->next)
247     {
248       TpAccount *account = ptr->data;
249
250       tp_proxy_prepare_async (account, NULL,
251           contact_blocking_dialog_account_prepared, self);
252     }
253
254   g_list_free (accounts);
255 }
256
257 static void
258 contact_blocking_dialog_account_prepared (GObject *account,
259     GAsyncResult *result,
260     gpointer user_data)
261 {
262   EmpathyContactBlockingDialog *self = user_data;
263   TpConnection *conn;
264   GError *error = NULL;
265
266   if (!tp_proxy_prepare_finish (account, result, &error))
267     {
268       DEBUG ("Could not prepare Account: %s", error->message);
269       g_error_free (error);
270       return;
271     }
272
273   g_signal_connect (account, "status-changed",
274       G_CALLBACK (contact_blocking_dialog_connection_status_changed), self);
275
276   conn = tp_account_get_connection (TP_ACCOUNT (account));
277
278   if (conn != NULL)
279     {
280       tp_proxy_prepare_async (conn, NULL,
281           contact_blocking_dialog_connection_prepared, self);
282     }
283 }
284
285 static void contact_blocking_dialog_got_deny_channel (TpConnection *,
286     gboolean, const char *, GHashTable *, const GError *, gpointer, GObject *);
287
288 static void
289 contact_blocking_dialog_connection_prepared (GObject *conn,
290     GAsyncResult *result,
291     gpointer user_data)
292 {
293   EmpathyContactBlockingDialog *self = user_data;
294   GHashTable *request;
295   GError *error = NULL;
296
297   if (!tp_proxy_prepare_finish (conn, result, &error))
298     {
299       DEBUG ("Failed to prepare connection: %s", error->message);
300       g_error_free (error);
301       return;
302     }
303
304   /* request the deny channel */
305   request = tp_asv_new (
306       TP_PROP_CHANNEL_CHANNEL_TYPE,
307       G_TYPE_STRING,
308       TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
309
310       TP_PROP_CHANNEL_TARGET_HANDLE_TYPE,
311       G_TYPE_UINT,
312       TP_HANDLE_TYPE_LIST,
313
314       TP_PROP_CHANNEL_TARGET_ID,
315       G_TYPE_STRING,
316       "deny",
317
318       NULL);
319
320   tp_cli_connection_interface_requests_call_ensure_channel (
321       TP_CONNECTION (conn), -1, request,
322       contact_blocking_dialog_got_deny_channel, NULL, NULL, G_OBJECT (self));
323
324   g_hash_table_destroy (request);
325 }
326
327 DECLARE_CALLBACK (contact_blocking_dialog_deny_channel_prepared);
328
329 static void
330 contact_blocking_dialog_got_deny_channel (TpConnection *conn,
331     gboolean yours,
332     const char *channel_path,
333     GHashTable *props,
334     const GError *in_error,
335     gpointer user_data,
336     GObject *self)
337 {
338   TpChannel *channel;
339   GError *error = NULL;
340
341   const GQuark features[] = {
342       TP_CHANNEL_FEATURE_CORE,
343       TP_CHANNEL_FEATURE_GROUP,
344       0 };
345
346   if (in_error != NULL)
347     {
348       DEBUG ("Failed to get 'deny' channel: %s", in_error->message);
349       return;
350     }
351
352   channel = tp_channel_new_from_properties (conn, channel_path, props, &error);
353
354   if (error != NULL)
355     {
356       DEBUG ("Failed to create channel proxy: %s", error->message);
357       g_error_free (error);
358       return;
359     }
360
361   tp_proxy_prepare_async (channel, features,
362       contact_blocking_dialog_deny_channel_prepared, self);
363 }
364
365 static void
366 contact_blocking_dialog_deny_channel_prepared (GObject *channel,
367     GAsyncResult *result,
368     gpointer user_data)
369 {
370   EmpathyContactBlockingDialog *self = user_data;
371   TpConnection *conn;
372   GError *error = NULL;
373
374   if (!tp_proxy_prepare_finish (channel, result, &error))
375     {
376       DEBUG ("Failed to prepare channel: %s", error->message);
377       g_error_free (error);
378       return;
379     }
380
381   conn = tp_channel_borrow_connection (TP_CHANNEL (channel));
382
383   DEBUG ("Channel prepared for connection %s", get_pretty_conn_name (conn));
384
385   g_hash_table_insert (self->priv->channels,
386       g_object_ref (conn), channel);
387
388   /* set the filter again to refilter the account list */
389   empathy_account_chooser_set_filter (
390       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser),
391       contact_blocking_dialog_filter_account_chooser, self);
392
393   g_signal_connect (channel, "group-members-changed",
394       G_CALLBACK (contact_blocking_dialog_deny_channel_members_changed), self);
395 }
396
397 static void contact_blocking_dialog_add_contact_got_handle (TpConnection *,
398     const GArray *, const GError *, gpointer, GObject *);
399
400 static void
401 contact_blocking_dialog_add_contact (GtkWidget *widget,
402     EmpathyContactBlockingDialog *self)
403 {
404   TpConnection *conn = empathy_account_chooser_get_connection (
405       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
406   const char *identifiers[2] = { NULL, };
407
408   identifiers[0] = gtk_entry_get_text (
409       GTK_ENTRY (self->priv->add_contact_entry));
410
411   DEBUG ("Looking up handle for '%s'", identifiers[0]);
412
413   tp_cli_connection_call_request_handles (conn, -1,
414       TP_HANDLE_TYPE_CONTACT, identifiers,
415       contact_blocking_dialog_add_contact_got_handle,
416       NULL, NULL, G_OBJECT (self));
417
418   gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
419 }
420
421 static void
422 contact_blocking_dialog_added_contact (TpChannel *, const GError *,
423     gpointer, GObject *);
424
425 static void
426 contact_blocking_dialog_add_contact_got_handle (TpConnection *conn,
427     const GArray *handles,
428     const GError *in_error,
429     gpointer user_data,
430     GObject *self)
431 {
432   EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
433   TpChannel *channel = g_hash_table_lookup (priv->channels, conn);
434
435   if (in_error != NULL)
436     {
437       DEBUG ("Error getting handle: %s", in_error->message);
438       /* FIXME: expose error to user */
439       return;
440     }
441
442   g_return_if_fail (handles->len == 1);
443
444   DEBUG ("Adding handle %u to deny channel",
445       g_array_index (handles, TpHandle, 0));
446
447   tp_cli_channel_interface_group_call_add_members (channel, -1,
448       handles, "",
449       contact_blocking_dialog_added_contact, NULL, NULL, self);
450 }
451
452 static void
453 contact_blocking_dialog_added_contact (TpChannel *channel,
454     const GError *in_error,
455     gpointer user_data,
456     GObject *self)
457 {
458   if (in_error != NULL)
459     {
460       DEBUG ("Error adding contact to deny list: %s", in_error->message);
461       /* FIXME: expose error to user */
462       return;
463     }
464
465   DEBUG ("Contact added");
466 }
467
468 static void
469 contact_blocking_dialog_removed_contacts (TpChannel *,
470     const GError *, gpointer, GObject *);
471
472 static void
473 contact_blocking_dialog_remove_contacts (GtkWidget *button,
474     EmpathyContactBlockingDialog *self)
475 {
476   TpConnection *conn = empathy_account_chooser_get_connection (
477       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
478   TpChannel *channel = g_hash_table_lookup (self->priv->channels, conn);
479   GtkTreeModel *model;
480   GList *rows, *ptr;
481   GArray *handles = g_array_new (FALSE, FALSE, sizeof (TpHandle));
482
483   rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model);
484
485   for (ptr = rows; ptr != NULL; ptr = ptr->next)
486     {
487       GtkTreePath *path = ptr->data;
488       GtkTreeIter iter;
489       TpHandle handle;
490
491       if (!gtk_tree_model_get_iter (model, &iter, path))
492         continue;
493
494       gtk_tree_model_get (model, &iter,
495           COL_HANDLE, &handle,
496           -1);
497
498       g_array_append_val (handles, handle);
499       gtk_tree_path_free (path);
500     }
501
502   g_list_free (rows);
503
504   if (handles->len > 0)
505     {
506       DEBUG ("Removing %u handles", handles->len);
507
508       tp_cli_channel_interface_group_call_remove_members (channel, -1,
509           handles, "",
510           contact_blocking_dialog_removed_contacts,
511           NULL, NULL, G_OBJECT (self));
512     }
513
514   g_array_unref (handles);
515 }
516
517 static void
518 contact_blocking_dialog_removed_contacts (TpChannel *channel,
519     const GError *in_error,
520     gpointer user_data,
521     GObject *self)
522 {
523   if (in_error != NULL)
524     {
525       DEBUG ("Error removing contacts from deny list: %s", in_error->message);
526       /* FIXME: expose error to user */
527       return;
528     }
529
530   DEBUG ("Contacts removed");
531 }
532
533 static void
534 contact_blocking_dialog_account_changed (GtkWidget *account_chooser,
535     EmpathyContactBlockingDialog *self)
536 {
537   TpConnection *conn = empathy_account_chooser_get_connection (
538       EMPATHY_ACCOUNT_CHOOSER (account_chooser));
539   TpChannel *channel;
540   GArray *blocked;
541   EmpathyContactManager *contact_manager;
542   EmpathyTpContactList *contact_list;
543   GList *members, *ptr;
544
545   if (conn == NULL)
546     return;
547
548   DEBUG ("Account changed: %s", get_pretty_conn_name (conn));
549
550   /* clear the lists of contacts */
551   gtk_list_store_clear (self->priv->blocked_contacts);
552   gtk_list_store_clear (self->priv->completion_contacts);
553
554   /* load the deny list */
555   channel = g_hash_table_lookup (self->priv->channels, conn);
556
557   g_return_if_fail (TP_IS_CHANNEL (channel));
558
559   blocked = tp_intset_to_array (tp_channel_group_get_members (channel));
560
561   DEBUG ("%u contacts on blocked list", blocked->len);
562
563   contact_blocking_dialog_add_contacts_to_list (self, conn, blocked);
564   g_array_unref (blocked);
565
566   /* load the completion list */
567   g_return_if_fail (empathy_contact_manager_initialized ());
568
569   DEBUG ("Loading contacts");
570
571   contact_manager = empathy_contact_manager_dup_singleton ();
572   contact_list = empathy_contact_manager_get_list (contact_manager, conn);
573   members = empathy_contact_list_get_members (
574       EMPATHY_CONTACT_LIST (contact_list));
575
576   for (ptr = members; ptr != NULL; ptr = ptr->next)
577     {
578       EmpathyContact *contact = ptr->data;
579
580       gtk_list_store_insert_with_values (self->priv->completion_contacts,
581           NULL, -1,
582           COL_IDENTIFIER, empathy_contact_get_id (contact),
583           -1);
584
585       g_object_unref (contact);
586     }
587
588   g_list_free (members);
589   g_object_unref (contact_manager);
590 }
591
592 static void
593 contact_blocking_dialog_view_selection_changed (GtkTreeSelection *selection,
594     EmpathyContactBlockingDialog *self)
595 {
596   GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL);
597
598   /* update the sensitivity of the remove button */
599   gtk_widget_set_sensitive (self->priv->remove_button, rows != NULL);
600
601   g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
602   g_list_free (rows);
603 }
604
605 static void
606 contact_blocking_dialog_dispose (GObject *self)
607 {
608   EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
609
610   tp_clear_pointer (&priv->channels, g_hash_table_destroy);
611
612   G_OBJECT_CLASS (empathy_contact_blocking_dialog_parent_class)->dispose (self);
613 }
614
615 static void
616 empathy_contact_blocking_dialog_class_init (
617     EmpathyContactBlockingDialogClass *klass)
618 {
619   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
620
621   gobject_class->dispose = contact_blocking_dialog_dispose;
622
623   g_type_class_add_private (gobject_class,
624       sizeof (EmpathyContactBlockingDialogPrivate));
625 }
626
627 static void
628 empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
629 {
630   GtkBuilder *gui;
631   char *filename;
632   GtkWidget *contents;
633   GtkWidget *account_hbox, *blocked_contacts_view;
634   GtkEntryCompletion *completion;
635   TpAccountManager *am;
636
637   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
638       EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
639       EmpathyContactBlockingDialogPrivate);
640
641   self->priv->channels = g_hash_table_new_full (NULL, NULL,
642       g_object_unref, g_object_unref);
643
644   gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts"));
645   gtk_dialog_add_button (GTK_DIALOG (self),
646       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
647
648   filename = empathy_file_lookup ("empathy-contact-blocking-dialog.ui",
649       "libempathy-gtk");
650
651   gui = empathy_builder_get_file (filename,
652       "contents", &contents,
653       "account-hbox", &account_hbox,
654       "add-contact-entry", &self->priv->add_contact_entry,
655       "blocked-contacts", &self->priv->blocked_contacts,
656       "blocked-contacts-view", &blocked_contacts_view,
657       "remove-button", &self->priv->remove_button,
658       NULL);
659
660   empathy_builder_connect (gui, self,
661       "add-button", "clicked", contact_blocking_dialog_add_contact,
662       "add-contact-entry", "activate", contact_blocking_dialog_add_contact,
663       "remove-button", "clicked", contact_blocking_dialog_remove_contacts,
664       NULL);
665
666   /* add the contents to the dialog */
667   gtk_container_add (
668       GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
669       contents);
670   gtk_widget_show (contents);
671
672   /* add the account chooser */
673   self->priv->account_chooser = empathy_account_chooser_new ();
674   empathy_account_chooser_set_filter (
675       EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser),
676       contact_blocking_dialog_filter_account_chooser, self);
677   g_signal_connect (self->priv->account_chooser, "changed",
678       G_CALLBACK (contact_blocking_dialog_account_changed), self);
679
680   gtk_box_pack_start (GTK_BOX (account_hbox), self->priv->account_chooser,
681       TRUE, TRUE, 0);
682   gtk_widget_show (self->priv->account_chooser);
683
684   /* set up the tree selection */
685   self->priv->selection = gtk_tree_view_get_selection (
686       GTK_TREE_VIEW (blocked_contacts_view));
687   gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_MULTIPLE);
688   g_signal_connect (self->priv->selection, "changed",
689       G_CALLBACK (contact_blocking_dialog_view_selection_changed), self);
690
691   /* build the contact entry */
692   self->priv->completion_contacts = gtk_list_store_new (1, G_TYPE_STRING);
693   completion = gtk_entry_completion_new ();
694   gtk_entry_completion_set_model (completion,
695       GTK_TREE_MODEL (self->priv->completion_contacts));
696   gtk_entry_completion_set_text_column (completion, COL_IDENTIFIER);
697   gtk_entry_set_completion (GTK_ENTRY (self->priv->add_contact_entry),
698       completion);
699   g_object_unref (completion);
700   g_object_unref (self->priv->completion_contacts);
701
702   /* prepare the account manager */
703   am = tp_account_manager_dup ();
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 }