1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2008 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
26 #include <glib/gi18n.h>
28 #include <telepathy-glib/enums.h>
29 #include <telepathy-glib/channel.h>
30 #include <telepathy-glib/connection.h>
31 #include <telepathy-glib/util.h>
32 #include <telepathy-glib/dbus.h>
33 #include <telepathy-glib/proxy-subclass.h>
35 #include <libmissioncontrol/mission-control.h>
36 #include <libmissioncontrol/mc-account.h>
38 #include <extensions/extensions.h>
40 #include <libempathy/empathy-tp-chat.h>
41 #include <libempathy/empathy-tp-call.h>
42 #include <libempathy/empathy-tp-group.h>
43 #include <libempathy/empathy-utils.h>
44 #include <libempathy/empathy-tube-handler.h>
45 #include <libempathy/empathy-contact-factory.h>
47 #include <libempathy-gtk/empathy-chat.h>
48 #include <libempathy-gtk/empathy-images.h>
49 #include <libempathy-gtk/empathy-contact-dialogs.h>
51 #include "empathy-filter.h"
52 #include "empathy-chat-window.h"
53 #include "empathy-call-window.h"
55 #define DEBUG_FLAG EMPATHY_DEBUG_FILTER
56 #include <libempathy/empathy-debug.h>
58 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyFilter)
67 G_DEFINE_TYPE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT);
74 typedef void (*FilterFunc) (EmpathyFilter *filter,
78 EmpathyFilterEvent public;
81 } EmpathyFilterEventExt;
84 filter_channel_hash (gconstpointer key)
86 TpProxy *channel = TP_PROXY (key);
88 return g_str_hash (channel->object_path);
92 filter_channel_equal (gconstpointer a,
95 TpProxy *channel_a = TP_PROXY (a);
96 TpProxy *channel_b = TP_PROXY (b);
98 return g_str_equal (channel_a->object_path, channel_b->object_path);
102 filter_event_free (EmpathyFilterEventExt *event)
104 g_free (event->public.icon_name);
105 g_free (event->public.message);
106 g_slice_free (EmpathyFilterEventExt, event);
110 filter_emit_event (EmpathyFilter *filter,
111 const gchar *icon_name,
112 const gchar *message,
116 EmpathyFilterPriv *priv = GET_PRIV (filter);
117 EmpathyFilterEventExt *event;
119 DEBUG ("Emit event, icon_name=%s message='%s'", icon_name, message);
121 event = g_slice_new0 (EmpathyFilterEventExt);
123 event->user_data = user_data;
124 event->public.icon_name = g_strdup (icon_name);
125 event->public.message = g_strdup (message);
127 priv->events = g_slist_append (priv->events, event);
128 if (priv->events->data == event) {
129 g_object_notify (G_OBJECT (filter), "top-event");
134 empathy_filter_activate_event (EmpathyFilter *filter,
135 EmpathyFilterEvent *event)
137 EmpathyFilterPriv *priv = GET_PRIV (filter);
138 EmpathyFilterEventExt *event_ext;
142 g_return_if_fail (EMPATHY_IS_FILTER (filter));
143 g_return_if_fail (event != NULL);
145 if (!(l = g_slist_find (priv->events, event))) {
149 DEBUG ("Activating event");
151 is_top = (l == priv->events);
152 priv->events = g_slist_delete_link (priv->events, l);
154 g_object_notify (G_OBJECT (filter), "top-event");
157 event_ext = (EmpathyFilterEventExt*) event;
158 if (event_ext->func) {
159 event_ext->func (filter, event_ext->user_data);
162 filter_event_free (event_ext);
166 empathy_filter_get_top_event (EmpathyFilter *filter)
168 EmpathyFilterPriv *priv = GET_PRIV (filter);
170 g_return_val_if_fail (EMPATHY_IS_FILTER (filter), NULL);
172 return priv->events ? priv->events->data : NULL;
176 filter_chat_dispatch (EmpathyFilter *filter,
179 EmpathyTpChat *tp_chat = EMPATHY_TP_CHAT (user_data);
180 EmpathyChat *chat = NULL;
183 id = empathy_tp_chat_get_id (tp_chat);
185 EmpathyContact *contact;
187 contact = empathy_tp_chat_get_remote_contact (tp_chat);
189 id = empathy_contact_get_id (contact);
196 account = empathy_tp_chat_get_account (tp_chat);
197 chat = empathy_chat_window_find_chat (account, id);
201 empathy_chat_set_tp_chat (chat, tp_chat);
203 chat = empathy_chat_new (tp_chat);
206 empathy_chat_window_present_chat (chat);
207 g_object_unref (tp_chat);
211 filter_chat_message_received_cb (EmpathyTpChat *tp_chat,
212 EmpathyMessage *message,
213 EmpathyFilter *filter)
215 EmpathyContact *sender;
218 g_signal_handlers_disconnect_by_func (tp_chat,
219 filter_chat_message_received_cb,
222 sender = empathy_message_get_sender (message);
223 msg = g_strdup_printf (_("New message from %s:\n%s"),
224 empathy_contact_get_name (sender),
225 empathy_message_get_body (message));
227 filter_emit_event (filter, EMPATHY_IMAGE_NEW_MESSAGE, msg,
228 filter_chat_dispatch, tp_chat);
234 filter_chat_handle_channel (EmpathyFilter *filter,
236 gboolean is_incoming)
238 EmpathyTpChat *tp_chat;
240 DEBUG ("New text channel to be filtered: %p", channel);
242 tp_chat = empathy_tp_chat_new (channel, FALSE);
243 empathy_run_until_ready (tp_chat);
245 filter_chat_dispatch (filter, tp_chat);
247 g_signal_connect (tp_chat, "message-received",
248 G_CALLBACK (filter_chat_message_received_cb),
254 filter_call_dispatch (EmpathyFilter *filter,
257 EmpathyTpCall *call = EMPATHY_TP_CALL (user_data);
259 empathy_call_window_new (call);
260 g_object_unref (call);
264 filter_call_contact_notify_cb (EmpathyTpCall *call,
266 EmpathyFilter *filter)
268 EmpathyContact *contact;
271 g_object_get (call, "contact", &contact, NULL);
276 empathy_contact_run_until_ready (contact,
277 EMPATHY_CONTACT_READY_NAME,
280 msg = g_strdup_printf (_("Incoming call from %s"),
281 empathy_contact_get_name (contact));
283 filter_emit_event (filter, EMPATHY_IMAGE_VOIP, msg,
284 filter_call_dispatch, call);
287 g_object_unref (contact);
291 filter_call_handle_channel (EmpathyFilter *filter,
293 gboolean is_incoming)
297 DEBUG ("New media channel to be filtered: %p", channel);
299 call = empathy_tp_call_new (channel);
301 filter_call_dispatch (filter, call);
303 g_signal_connect (call, "notify::contact",
304 G_CALLBACK (filter_call_contact_notify_cb),
310 filter_contact_list_subscribe (EmpathyFilter *filter,
313 EmpathyContact *contact = EMPATHY_CONTACT (user_data);
315 empathy_subscription_dialog_show (contact, NULL);
316 g_object_unref (contact);
320 filter_contact_list_local_pending_cb (EmpathyTpGroup *group,
321 EmpathyContact *contact,
322 EmpathyContact *actor,
325 EmpathyFilter *filter)
329 DEBUG ("New local pending contact");
331 empathy_contact_run_until_ready (contact,
332 EMPATHY_CONTACT_READY_NAME,
335 str = g_string_new (NULL);
336 g_string_printf (str, _("Subscription requested by %s"),
337 empathy_contact_get_name (contact));
338 if (!G_STR_EMPTY (message)) {
339 g_string_append_printf (str, _("\nMessage: %s"), message);
342 filter_emit_event (filter, GTK_STOCK_DIALOG_QUESTION, str->str,
343 filter_contact_list_subscribe,
344 g_object_ref (contact));
346 g_string_free (str, TRUE);
350 filter_contact_list_ready_cb (EmpathyTpGroup *group,
352 EmpathyFilter *filter)
356 if (tp_strdiff ("publish", empathy_tp_group_get_name (group))) {
357 g_object_unref (group);
361 DEBUG ("Publish contact list ready");
363 g_signal_connect (group, "local-pending",
364 G_CALLBACK (filter_contact_list_local_pending_cb),
367 pendings = empathy_tp_group_get_local_pendings (group);
368 for (l = pendings; l; l = l->next) {
369 EmpathyPendingInfo *info = l->data;
371 filter_contact_list_local_pending_cb (group, info->member,
372 info->actor, info->reason,
373 info->message, filter);
374 empathy_pending_info_free (info);
376 g_list_free (pendings);
380 filter_tubes_async_cb (TpProxy *channel,
386 DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
391 EmpathyContactFactory *factory;
392 EmpathyContact *initiator;
397 gboolean activatable;
401 filter_tubes_dispatch (EmpathyFilter *filter,
404 FilterTubesData *data = user_data;
406 if (data->activatable) {
413 /* Create the proxy for the tube handler */
414 thandler = g_object_new (TP_TYPE_PROXY,
415 "dbus-connection", tp_get_bus (),
416 "bus-name", data->bus_name,
417 "object-path", data->object_path,
419 tp_proxy_add_interface_by_id (thandler, EMP_IFACE_QUARK_TUBE_HANDLER);
421 /* Give the tube to the handler */
422 g_object_get (data->channel,
423 "connection", &connection,
424 "object-path", &object_path,
425 "handle_type", &handle_type,
429 DEBUG ("Dispatching tube");
430 emp_cli_tube_handler_call_handle_tube (thandler, -1,
431 connection->bus_name,
432 connection->object_path,
433 object_path, handle_type,
435 filter_tubes_async_cb,
436 "handling tube", NULL,
439 g_object_unref (thandler);
440 g_object_unref (connection);
441 g_free (object_path);
446 /* Tell the user that the tube can't be handled */
447 str = g_strdup_printf (_("%s offered you an invitation, but "
448 "you don't have the needed external "
449 "application to handle it."),
450 empathy_contact_get_name (data->initiator));
452 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
454 GTK_BUTTONS_OK, str);
455 gtk_window_set_title (GTK_WINDOW (dialog),
456 _("Invitation Error"));
459 gtk_widget_show (dialog);
460 g_signal_connect (dialog, "response",
461 G_CALLBACK (gtk_widget_destroy),
464 DEBUG ("Tube can't be handled, closing");
465 tp_cli_channel_type_tubes_call_close_tube (data->channel, -1,
471 g_free (data->bus_name);
472 g_free (data->object_path);
473 g_object_unref (data->channel);
474 g_object_unref (data->initiator);
475 g_object_unref (data->factory);
476 g_slice_free (FilterTubesData, data);
480 filter_tubes_new_tube_cb (TpChannel *channel,
484 const gchar *service,
485 GHashTable *parameters,
490 EmpathyFilterPriv *priv = GET_PRIV (filter);
491 static TpDBusDaemon *daemon = NULL;
492 FilterTubesData *data;
497 gboolean running = FALSE;
498 const gchar *icon_name;
499 GError *error = NULL;
501 /* Increase tube count */
502 number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
503 g_hash_table_replace (priv->tubes, g_object_ref (channel),
504 GUINT_TO_POINTER (++number));
505 DEBUG ("Increased tube count for channel %p: %d", channel, number);
507 /* We dispatch only local pending tubes */
508 if (state != TP_TUBE_STATE_LOCAL_PENDING) {
513 daemon = tp_dbus_daemon_new (tp_get_bus ());
516 account = empathy_channel_get_account (channel);
517 data = g_slice_new (FilterTubesData);
518 data->activatable = FALSE;
520 data->channel = g_object_ref (channel);
521 data->factory = empathy_contact_factory_new ();
522 data->initiator = empathy_contact_factory_get_from_handle (data->factory,
525 data->bus_name = empathy_tube_handler_build_bus_name (type, service);
526 data->object_path = empathy_tube_handler_build_object_path (type, service);
527 g_object_unref (account);
529 /* Check if that bus-name has an owner, if it has one that means the
530 * app is already running and we can directly give the channel. */
531 tp_cli_dbus_daemon_run_name_has_owner (daemon, -1, data->bus_name,
532 &running, NULL, NULL);
534 DEBUG ("Tube handler running");
535 data->activatable = TRUE;
536 filter_tubes_dispatch (EMPATHY_FILTER (filter), data);
540 /* Check if that bus-name is activatable, if not that means the
541 * application needed to handle this tube isn't installed. */
542 if (!tp_cli_dbus_daemon_run_list_activatable_names (daemon, -1,
545 DEBUG ("Error listing activatable names: %s", error->message);
546 g_clear_error (&error);
550 for (name = names; *name; name++) {
551 if (!tp_strdiff (*name, data->bus_name)) {
552 data->activatable = TRUE;
559 empathy_contact_run_until_ready (data->initiator,
560 EMPATHY_CONTACT_READY_NAME, NULL);
562 if (data->activatable) {
563 icon_name = GTK_STOCK_EXECUTE;
564 msg = g_strdup_printf (_("%s is offering you an invitation. An external "
565 "application will be started to handle it."),
566 empathy_contact_get_name (data->initiator));
568 icon_name = GTK_STOCK_DIALOG_ERROR;
569 msg = g_strdup_printf (_("%s is offering you an invitation, but "
570 "you don't have the needed external "
571 "application to handle it."),
572 empathy_contact_get_name (data->initiator));
575 filter_emit_event (EMPATHY_FILTER (filter), icon_name, msg,
576 filter_tubes_dispatch, data);
582 filter_tubes_list_tubes_cb (TpChannel *channel,
583 const GPtrArray *tubes,
591 DEBUG ("Error listing tubes: %s", error->message);
595 for (i = 0; i < tubes->len; i++) {
598 values = g_ptr_array_index (tubes, i);
599 filter_tubes_new_tube_cb (channel,
600 g_value_get_uint (g_value_array_get_nth (values, 0)),
601 g_value_get_uint (g_value_array_get_nth (values, 1)),
602 g_value_get_uint (g_value_array_get_nth (values, 2)),
603 g_value_get_string (g_value_array_get_nth (values, 3)),
604 g_value_get_boxed (g_value_array_get_nth (values, 4)),
605 g_value_get_uint (g_value_array_get_nth (values, 5)),
611 filter_tubes_channel_invalidated_cb (TpProxy *proxy,
615 EmpathyFilter *filter)
617 EmpathyFilterPriv *priv = GET_PRIV (filter);
619 DEBUG ("Channel %p invalidated: %s", proxy, message);
621 g_hash_table_remove (priv->tubes, proxy);
625 filter_tubes_tube_closed_cb (TpChannel *channel,
630 EmpathyFilterPriv *priv = GET_PRIV (filter);
633 number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
635 DEBUG ("Ended tube count for channel %p, closing channel",
637 tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);
639 else if (number > 1) {
640 DEBUG ("Decrease tube count for channel %p: %d", channel, number);
641 g_hash_table_replace (priv->tubes, g_object_ref (channel),
642 GUINT_TO_POINTER (--number));
647 filter_tubes_handle_channel (EmpathyFilter *filter,
649 gboolean is_incoming)
651 EmpathyFilterPriv *priv = GET_PRIV (filter);
653 if (g_hash_table_lookup (priv->tubes, channel)) {
657 DEBUG ("Handling new channel");
659 g_hash_table_insert (priv->tubes, g_object_ref (channel),
660 GUINT_TO_POINTER (0));
662 g_signal_connect (channel, "invalidated",
663 G_CALLBACK (filter_tubes_channel_invalidated_cb),
666 tp_cli_channel_type_tubes_connect_to_tube_closed (channel,
667 filter_tubes_tube_closed_cb,
669 G_OBJECT (filter), NULL);
670 tp_cli_channel_type_tubes_connect_to_new_tube (channel,
671 filter_tubes_new_tube_cb,
673 G_OBJECT (filter), NULL);
674 tp_cli_channel_type_tubes_call_list_tubes (channel, -1,
675 filter_tubes_list_tubes_cb,
681 filter_contact_list_destroy_cb (EmpathyTpGroup *group,
682 EmpathyFilter *filter)
684 g_object_unref (group);
688 filter_contact_list_handle_channel (EmpathyFilter *filter,
690 gboolean is_incoming)
692 EmpathyTpGroup *group;
694 group = empathy_tp_group_new (channel);
695 g_signal_connect (group, "notify::ready",
696 G_CALLBACK (filter_contact_list_ready_cb),
698 g_signal_connect (group, "destroy",
699 G_CALLBACK (filter_contact_list_destroy_cb),
704 filter_connection_invalidated_cb (TpConnection *connection,
708 EmpathyFilter *filter)
710 EmpathyFilterPriv *priv = GET_PRIV (filter);
714 DEBUG ("connection invalidated: %s", message);
716 g_hash_table_iter_init (&iter, priv->accounts);
717 while (g_hash_table_iter_next (&iter, &key, &value)) {
718 if (value == connection) {
719 g_hash_table_remove (priv->accounts, key);
725 typedef void (*HandleChannelFunc) (EmpathyFilter *filter,
727 gboolean is_incoming);
730 filter_conection_new_channel_cb (TpConnection *connection,
731 const gchar *object_path,
732 const gchar *channel_type,
735 gboolean suppress_handler,
739 HandleChannelFunc func = NULL;
741 gpointer had_channels;
743 had_channels = g_object_get_data (G_OBJECT (connection), "had-channels");
744 if (had_channels == NULL) {
748 if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)) {
749 func = filter_chat_handle_channel;
751 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) {
752 func = filter_call_handle_channel;
754 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)) {
755 func = filter_contact_list_handle_channel;
757 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TUBES)) {
758 func = filter_tubes_handle_channel;
760 DEBUG ("Unknown channel type %s", channel_type);
764 channel = tp_channel_new (connection, object_path, channel_type,
765 handle_type, handle, NULL);
766 tp_channel_run_until_ready (channel, NULL, NULL);
768 /* We abuse of suppress_handler, TRUE means OUTGOING */
769 func (EMPATHY_FILTER (filter), channel, suppress_handler);
771 g_object_unref (channel);
775 filter_connection_list_channels_cb (TpConnection *connection,
776 const GPtrArray *channels,
784 DEBUG ("Error listing channels: %s", error->message);
788 g_object_set_data (G_OBJECT (connection), "had-channels",
789 GUINT_TO_POINTER (1));
791 for (i = 0; i < channels->len; i++) {
794 values = g_ptr_array_index (channels, i);
795 filter_conection_new_channel_cb (connection,
796 g_value_get_boxed (g_value_array_get_nth (values, 0)),
797 g_value_get_string (g_value_array_get_nth (values, 1)),
798 g_value_get_uint (g_value_array_get_nth (values, 2)),
799 g_value_get_uint (g_value_array_get_nth (values, 3)),
800 TRUE, user_data, filter);
805 filter_connection_advertise_capabilities_cb (TpConnection *connection,
806 const GPtrArray *capabilities,
812 DEBUG ("Error advertising capabilities: %s", error->message);
817 filter_connection_ready_cb (TpConnection *connection,
819 EmpathyFilter *filter)
821 GPtrArray *capabilities;
824 const gchar *remove = NULL;
826 DEBUG ("Connection ready, accepting new channels");
828 tp_cli_connection_connect_to_new_channel (connection,
829 filter_conection_new_channel_cb,
831 G_OBJECT (filter), NULL);
832 tp_cli_connection_call_list_channels (connection, -1,
833 filter_connection_list_channels_cb,
837 /* Advertise VoIP capabilities */
838 capabilities = g_ptr_array_sized_new (1);
839 cap_type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING,
840 G_TYPE_UINT, G_TYPE_INVALID);
841 g_value_init (&cap, cap_type);
842 g_value_take_boxed (&cap, dbus_g_type_specialized_construct (cap_type));
843 dbus_g_type_struct_set (&cap,
844 0, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
845 1, TP_CHANNEL_MEDIA_CAPABILITY_AUDIO |
846 TP_CHANNEL_MEDIA_CAPABILITY_VIDEO |
847 TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_STUN |
848 TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P,
850 g_ptr_array_add (capabilities, g_value_get_boxed (&cap));
852 tp_cli_connection_interface_capabilities_call_advertise_capabilities (
854 capabilities, &remove,
855 filter_connection_advertise_capabilities_cb,
856 NULL, NULL, G_OBJECT (filter));
860 filter_update_account (EmpathyFilter *filter,
863 EmpathyFilterPriv *priv = GET_PRIV (filter);
864 TpConnection *connection;
867 connection = g_hash_table_lookup (priv->accounts, account);
872 connection = mission_control_get_tpconnection (priv->mc, account, NULL);
877 g_hash_table_insert (priv->accounts, g_object_ref (account), connection);
878 g_signal_connect (connection, "invalidated",
879 G_CALLBACK (filter_connection_invalidated_cb),
882 g_object_get (connection, "connection-ready", &ready, NULL);
884 filter_connection_ready_cb (connection, NULL, filter);
886 g_signal_connect (connection, "notify::connection-ready",
887 G_CALLBACK (filter_connection_ready_cb),
893 filter_status_changed_cb (MissionControl *mc,
894 TpConnectionStatus status,
896 TpConnectionStatusReason reason,
897 const gchar *unique_name,
898 EmpathyFilter *filter)
902 account = mc_account_lookup (unique_name);
903 filter_update_account (filter, account);
904 g_object_unref (account);
908 filter_finalize (GObject *object)
910 EmpathyFilterPriv *priv = GET_PRIV (object);
912 empathy_disconnect_account_status_changed (priv->token);
913 g_object_unref (priv->mc);
915 g_slist_foreach (priv->events, (GFunc) filter_event_free, NULL);
916 g_slist_free (priv->events);
918 g_hash_table_destroy (priv->accounts);
919 g_hash_table_destroy (priv->tubes);
923 filter_get_property (GObject *object,
928 EmpathyFilterPriv *priv = GET_PRIV (object);
932 g_value_set_pointer (value, priv->events ? priv->events->data : NULL);
935 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
941 empathy_filter_class_init (EmpathyFilterClass *klass)
943 GObjectClass *object_class = G_OBJECT_CLASS (klass);
945 object_class->finalize = filter_finalize;
946 object_class->get_property = filter_get_property;
948 g_object_class_install_property (object_class,
950 g_param_spec_pointer ("top-event",
952 "The first event in the events list",
955 g_type_class_add_private (object_class, sizeof (EmpathyFilterPriv));
959 empathy_filter_init (EmpathyFilter *filter)
962 EmpathyFilterPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (filter,
963 EMPATHY_TYPE_FILTER, EmpathyFilterPriv);
966 priv->tubes = g_hash_table_new_full (filter_channel_hash,
967 filter_channel_equal,
968 g_object_unref, NULL);
970 priv->mc = empathy_mission_control_new ();
971 priv->token = empathy_connect_to_account_status_changed (priv->mc,
972 G_CALLBACK (filter_status_changed_cb),
975 priv->accounts = g_hash_table_new_full (empathy_account_hash,
976 empathy_account_equal,
979 accounts = mc_accounts_list_by_enabled (TRUE);
980 for (l = accounts; l; l = l->next) {
981 filter_update_account (filter, l->data);
982 g_object_unref (l->data);
984 g_list_free (accounts);
988 empathy_filter_new (void)
990 static EmpathyFilter *filter = NULL;
993 filter = g_object_new (EMPATHY_TYPE_FILTER, NULL);
994 g_object_add_weak_pointer (G_OBJECT (filter), (gpointer) &filter);
996 g_object_ref (filter);