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-debug.h>
45 #include <libempathy/empathy-tube-handler.h>
46 #include <libempathy/empathy-contact-factory.h>
48 #include <libempathy-gtk/empathy-chat.h>
49 #include <libempathy-gtk/empathy-images.h>
50 #include <libempathy-gtk/empathy-contact-dialogs.h>
52 #include "empathy-filter.h"
53 #include "empathy-chat-window.h"
54 #include "empathy-call-window.h"
56 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
57 EMPATHY_TYPE_FILTER, EmpathyFilterPriv))
59 #define DEBUG_DOMAIN "Filter"
61 struct _EmpathyFilterPriv {
69 static void empathy_filter_class_init (EmpathyFilterClass *klass);
70 static void empathy_filter_init (EmpathyFilter *filter);
72 G_DEFINE_TYPE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT);
79 typedef void (*FilterFunc) (EmpathyFilter *filter,
83 EmpathyFilterEvent public;
86 } EmpathyFilterEventExt;
89 filter_channel_hash (gconstpointer key)
91 TpProxy *channel = TP_PROXY (key);
93 return g_str_hash (channel->object_path);
97 filter_channel_equal (gconstpointer a,
100 TpProxy *channel_a = TP_PROXY (a);
101 TpProxy *channel_b = TP_PROXY (b);
103 return g_str_equal (channel_a->object_path, channel_b->object_path);
107 filter_event_free (EmpathyFilterEventExt *event)
109 g_free (event->public.icon_name);
110 g_free (event->public.message);
111 g_slice_free (EmpathyFilterEventExt, event);
115 filter_emit_event (EmpathyFilter *filter,
116 const gchar *icon_name,
117 const gchar *message,
121 EmpathyFilterPriv *priv = GET_PRIV (filter);
122 EmpathyFilterEventExt *event;
124 empathy_debug (DEBUG_DOMAIN, "Emit event, icon_name=%s message='%s'",
127 event = g_slice_new0 (EmpathyFilterEventExt);
129 event->user_data = user_data;
130 event->public.icon_name = g_strdup (icon_name);
131 event->public.message = g_strdup (message);
133 priv->events = g_slist_append (priv->events, event);
134 if (priv->events->data == event) {
135 g_object_notify (G_OBJECT (filter), "top-event");
140 empathy_filter_activate_event (EmpathyFilter *filter,
141 EmpathyFilterEvent *event)
143 EmpathyFilterPriv *priv = GET_PRIV (filter);
144 EmpathyFilterEventExt *event_ext;
148 g_return_if_fail (EMPATHY_IS_FILTER (filter));
149 g_return_if_fail (event != NULL);
151 if (!(l = g_slist_find (priv->events, event))) {
155 empathy_debug (DEBUG_DOMAIN, "Activating event");
157 is_top = (l == priv->events);
158 priv->events = g_slist_delete_link (priv->events, l);
160 g_object_notify (G_OBJECT (filter), "top-event");
163 event_ext = (EmpathyFilterEventExt*) event;
164 if (event_ext->func) {
165 event_ext->func (filter, event_ext->user_data);
168 filter_event_free (event_ext);
172 empathy_filter_get_top_event (EmpathyFilter *filter)
174 EmpathyFilterPriv *priv = GET_PRIV (filter);
176 g_return_val_if_fail (EMPATHY_IS_FILTER (filter), NULL);
178 return priv->events ? priv->events->data : NULL;
182 filter_chat_dispatch (EmpathyFilter *filter,
185 EmpathyTpChat *tp_chat = EMPATHY_TP_CHAT (user_data);
190 id = empathy_tp_chat_get_id (tp_chat);
191 account = empathy_tp_chat_get_account (tp_chat);
192 chat = empathy_chat_window_find_chat (account, id);
195 empathy_chat_set_tp_chat (chat, tp_chat);
197 chat = empathy_chat_new (tp_chat);
200 empathy_chat_window_present_chat (chat);
201 g_object_unref (tp_chat);
205 filter_chat_message_received_cb (EmpathyTpChat *tp_chat,
206 EmpathyMessage *message,
207 EmpathyFilter *filter)
209 EmpathyContact *sender;
212 g_signal_handlers_disconnect_by_func (tp_chat,
213 filter_chat_message_received_cb,
216 sender = empathy_message_get_sender (message);
217 msg = g_strdup_printf (_("New message from %s:\n%s"),
218 empathy_contact_get_name (sender),
219 empathy_message_get_body (message));
221 filter_emit_event (filter, EMPATHY_IMAGE_NEW_MESSAGE, msg,
222 filter_chat_dispatch, tp_chat);
228 filter_chat_handle_channel (EmpathyFilter *filter,
230 gboolean is_incoming)
232 EmpathyTpChat *tp_chat;
234 empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered: %p",
237 tp_chat = empathy_tp_chat_new (channel, FALSE);
239 filter_chat_dispatch (filter, tp_chat);
241 g_signal_connect (tp_chat, "message-received",
242 G_CALLBACK (filter_chat_message_received_cb),
249 filter_call_dispatch (EmpathyFilter *filter,
252 EmpathyTpCall *call = EMPATHY_TP_CALL (user_data);
254 empathy_call_window_new (call);
255 g_object_unref (call);
259 filter_call_contact_notify_cb (EmpathyTpCall *call,
261 EmpathyFilter *filter)
263 EmpathyContact *contact;
266 g_object_get (call, "contact", &contact, NULL);
271 empathy_contact_run_until_ready (contact,
272 EMPATHY_CONTACT_READY_NAME,
275 msg = g_strdup_printf (_("Incoming call from %s"),
276 empathy_contact_get_name (contact));
278 filter_emit_event (filter, EMPATHY_IMAGE_VOIP, msg,
279 filter_call_dispatch, call);
282 g_object_unref (contact);
286 filter_call_handle_channel (EmpathyFilter *filter,
288 gboolean is_incoming)
292 empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered: %p",
295 call = empathy_tp_call_new (channel);
297 filter_call_dispatch (filter, call);
299 g_signal_connect (call, "notify::contact",
300 G_CALLBACK (filter_call_contact_notify_cb),
307 filter_contact_list_subscribe (EmpathyFilter *filter,
310 EmpathyContact *contact = EMPATHY_CONTACT (user_data);
312 empathy_subscription_dialog_show (contact, NULL);
313 g_object_unref (contact);
317 filter_contact_list_local_pending_cb (EmpathyTpGroup *group,
318 EmpathyContact *contact,
319 EmpathyContact *actor,
322 EmpathyFilter *filter)
326 empathy_debug (DEBUG_DOMAIN, "New local pending contact");
328 empathy_contact_run_until_ready (contact,
329 EMPATHY_CONTACT_READY_NAME,
332 str = g_string_new (NULL);
333 g_string_printf (str, _("Subscription requested by %s"),
334 empathy_contact_get_name (contact));
335 if (!G_STR_EMPTY (message)) {
336 g_string_append_printf (str, _("\nMessage: %s"), message);
339 filter_emit_event (filter, GTK_STOCK_DIALOG_QUESTION, str->str,
340 filter_contact_list_subscribe,
341 g_object_ref (contact));
343 g_string_free (str, TRUE);
347 filter_contact_list_ready_cb (EmpathyTpGroup *group,
349 EmpathyFilter *filter)
353 if (tp_strdiff ("publish", empathy_tp_group_get_name (group))) {
354 g_object_unref (group);
358 empathy_debug (DEBUG_DOMAIN, "Publish contact list ready");
360 g_signal_connect (group, "local-pending",
361 G_CALLBACK (filter_contact_list_local_pending_cb),
364 pendings = empathy_tp_group_get_local_pendings (group);
365 for (l = pendings; l; l = l->next) {
366 EmpathyPendingInfo *info = l->data;
368 filter_contact_list_local_pending_cb (group, info->member,
369 info->actor, info->reason,
370 info->message, filter);
371 empathy_pending_info_free (info);
373 g_list_free (pendings);
377 filter_tubes_async_cb (TpProxy *channel,
383 empathy_debug (DEBUG_DOMAIN, "Error %s: %s",
384 user_data, error->message);
389 EmpathyContactFactory *factory;
390 EmpathyContact *initiator;
398 filter_tubes_dispatch (EmpathyFilter *filter,
401 static TpDBusDaemon *daemon = NULL;
402 FilterTubesData *data = user_data;
403 gchar *thandler_bus_name;
404 gchar *thandler_object_path;
405 gboolean activatable = FALSE;
406 gchar **names = NULL;
407 GError *error = NULL;
409 /* Build the bus-name and object-path where the handler for this tube
410 * is supposed to be. */
411 thandler_bus_name = empathy_tube_handler_build_bus_name (data->type,
413 thandler_object_path = empathy_tube_handler_build_object_path (data->type,
416 /* Check if that bus-name is activatable, if not that means the
417 * application needed to handle this tube isn't installed. */
419 daemon = tp_dbus_daemon_new (tp_get_bus ());
422 if (!tp_cli_dbus_daemon_run_list_activatable_names (daemon, -1,
425 empathy_debug (DEBUG_DOMAIN, "Error listing activatable names: %s",
427 g_clear_error (&error);
431 for (name = names; *name; name++) {
432 if (!tp_strdiff (*name, thandler_bus_name)) {
447 /* Create the proxy for the tube handler */
448 thandler = g_object_new (TP_TYPE_PROXY,
449 "dbus-connection", tp_get_bus (),
450 "bus-name", thandler_bus_name,
451 "object-path", thandler_object_path,
453 tp_proxy_add_interface_by_id (thandler, EMP_IFACE_QUARK_TUBE_HANDLER);
455 /* Give the tube to the handler */
456 g_object_get (data->channel,
457 "connection", &connection,
458 "object-path", &object_path,
459 "handle_type", &handle_type,
463 empathy_debug (DEBUG_DOMAIN, "Dispatching tube");
464 emp_cli_tube_handler_call_handle_tube (thandler, -1,
465 connection->bus_name,
466 connection->object_path,
467 object_path, handle_type,
469 filter_tubes_async_cb,
470 "handling tube", NULL,
473 g_object_unref (thandler);
474 g_object_unref (connection);
475 g_free (object_path);
480 /* Tell the user that the tube can't be handled */
481 str = g_strdup_printf (_("%s invited you to play %s but you don't "
482 "have it installed."),
483 empathy_contact_get_name (data->initiator),
485 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
487 GTK_BUTTONS_OK, str);
489 str = g_strdup_printf (_("%s Invitation"), data->service);
490 gtk_window_set_title (GTK_WINDOW (dialog), str);
493 g_signal_connect (dialog, "destroy",
494 G_CALLBACK (gtk_widget_destroy),
497 empathy_debug (DEBUG_DOMAIN, "Tube can't be handled, closing");
498 tp_cli_channel_type_tubes_call_close_tube (data->channel, -1,
504 g_free (thandler_bus_name);
505 g_free (thandler_object_path);
506 g_free (data->service);
507 g_object_unref (data->channel);
508 g_object_unref (data->initiator);
509 g_object_unref (data->factory);
510 g_slice_free (FilterTubesData, data);
514 filter_tubes_new_tube_cb (TpChannel *channel,
518 const gchar *service,
519 GHashTable *parameters,
524 EmpathyFilterPriv *priv = GET_PRIV (filter);
525 FilterTubesData *data;
530 /* Increase tube count */
531 number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
532 g_hash_table_replace (priv->tubes, g_object_ref (channel),
533 GUINT_TO_POINTER (++number));
534 empathy_debug (DEBUG_DOMAIN, "Increased tube count for channel %p: %d",
537 /* We dispatch only local pending tubes */
538 if (state != TP_TUBE_STATE_LOCAL_PENDING) {
542 account = empathy_channel_get_account (channel);
543 data = g_slice_new (FilterTubesData);
546 data->service = g_strdup (service);
547 data->channel = g_object_ref (channel);
548 data->factory = empathy_contact_factory_new ();
549 data->initiator = empathy_contact_factory_get_from_handle (data->factory,
553 empathy_contact_run_until_ready (data->initiator,
554 EMPATHY_CONTACT_READY_NAME, NULL);
556 msg = g_strdup_printf (_("%s is offering you a tube for application %s"),
557 empathy_contact_get_name (data->initiator),
560 filter_emit_event (EMPATHY_FILTER (filter), GTK_STOCK_DIALOG_QUESTION,
561 msg, filter_tubes_dispatch, data);
564 g_object_unref (account);
568 filter_tubes_list_tubes_cb (TpChannel *channel,
569 const GPtrArray *tubes,
577 empathy_debug (DEBUG_DOMAIN, "Error listing tubes: %s",
582 for (i = 0; i < tubes->len; i++) {
585 values = g_ptr_array_index (tubes, i);
586 filter_tubes_new_tube_cb (channel,
587 g_value_get_uint (g_value_array_get_nth (values, 0)),
588 g_value_get_uint (g_value_array_get_nth (values, 1)),
589 g_value_get_uint (g_value_array_get_nth (values, 2)),
590 g_value_get_string (g_value_array_get_nth (values, 3)),
591 g_value_get_boxed (g_value_array_get_nth (values, 4)),
592 g_value_get_uint (g_value_array_get_nth (values, 5)),
598 filter_tubes_channel_invalidated_cb (TpProxy *proxy,
602 EmpathyFilter *filter)
604 EmpathyFilterPriv *priv = GET_PRIV (filter);
606 empathy_debug (DEBUG_DOMAIN, "Channel %p invalidated: %s", proxy, message);
608 g_hash_table_remove (priv->tubes, proxy);
612 filter_tubes_tube_closed_cb (TpChannel *channel,
617 EmpathyFilterPriv *priv = GET_PRIV (filter);
620 number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
622 empathy_debug (DEBUG_DOMAIN, "Ended tube count for channel %p, "
623 "closing channel", channel);
624 tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);
626 else if (number > 1) {
627 empathy_debug (DEBUG_DOMAIN, "Decrease tube count for channel %p: %d",
629 g_hash_table_replace (priv->tubes, g_object_ref (channel),
630 GUINT_TO_POINTER (--number));
635 filter_tubes_handle_channel (EmpathyFilter *filter,
637 gboolean is_incoming)
639 EmpathyFilterPriv *priv = GET_PRIV (filter);
641 if (g_hash_table_lookup (priv->tubes, channel)) {
645 empathy_debug (DEBUG_DOMAIN, "Handling new channel");
647 g_hash_table_insert (priv->tubes, g_object_ref (channel),
648 GUINT_TO_POINTER (0));
650 g_signal_connect (channel, "invalidated",
651 G_CALLBACK (filter_tubes_channel_invalidated_cb),
654 tp_cli_channel_type_tubes_connect_to_tube_closed (channel,
655 filter_tubes_tube_closed_cb,
657 G_OBJECT (filter), NULL);
658 tp_cli_channel_type_tubes_connect_to_new_tube (channel,
659 filter_tubes_new_tube_cb,
661 G_OBJECT (filter), NULL);
662 tp_cli_channel_type_tubes_call_list_tubes (channel, -1,
663 filter_tubes_list_tubes_cb,
669 filter_contact_list_destroy_cb (EmpathyTpGroup *group,
670 EmpathyFilter *filter)
672 g_object_unref (group);
676 filter_contact_list_handle_channel (EmpathyFilter *filter,
678 gboolean is_incoming)
680 EmpathyTpGroup *group;
682 group = empathy_tp_group_new (channel);
683 g_signal_connect (group, "notify::ready",
684 G_CALLBACK (filter_contact_list_ready_cb),
686 g_signal_connect (group, "destroy",
687 G_CALLBACK (filter_contact_list_destroy_cb),
692 filter_connection_invalidated_cb (TpConnection *connection,
696 EmpathyFilter *filter)
698 EmpathyFilterPriv *priv = GET_PRIV (filter);
702 empathy_debug (DEBUG_DOMAIN, "connection invalidated: %s", message);
704 g_hash_table_iter_init (&iter, priv->accounts);
705 while (g_hash_table_iter_next (&iter, &key, &value)) {
706 if (value == connection) {
707 g_hash_table_remove (priv->accounts, key);
713 typedef void (*HandleChannelFunc) (EmpathyFilter *filter,
715 gboolean is_incoming);
718 filter_conection_new_channel_cb (TpConnection *connection,
719 const gchar *object_path,
720 const gchar *channel_type,
723 gboolean suppress_handler,
727 HandleChannelFunc func = NULL;
729 gpointer had_channels;
731 had_channels = g_object_get_data (G_OBJECT (connection), "had-channels");
732 if (had_channels == NULL) {
736 if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)) {
737 func = filter_chat_handle_channel;
740 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) {
741 func = filter_call_handle_channel;
744 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)) {
745 func = filter_contact_list_handle_channel;
747 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TUBES)) {
748 func = filter_tubes_handle_channel;
750 empathy_debug (DEBUG_DOMAIN, "Unknown channel type %s",
755 channel = tp_channel_new (connection, object_path, channel_type,
756 handle_type, handle, NULL);
757 tp_channel_run_until_ready (channel, NULL, NULL);
759 /* We abuse of suppress_handler, TRUE means OUTGOING */
760 func (EMPATHY_FILTER (filter), channel, suppress_handler);
762 g_object_unref (channel);
766 filter_connection_list_channels_cb (TpConnection *connection,
767 const GPtrArray *channels,
774 g_object_set_data (G_OBJECT (connection), "had-channels",
775 GUINT_TO_POINTER (1));
777 for (i = 0; i < channels->len; i++) {
780 values = g_ptr_array_index (channels, i);
781 filter_conection_new_channel_cb (connection,
782 g_value_get_boxed (g_value_array_get_nth (values, 0)),
783 g_value_get_string (g_value_array_get_nth (values, 1)),
784 g_value_get_uint (g_value_array_get_nth (values, 2)),
785 g_value_get_uint (g_value_array_get_nth (values, 3)),
786 TRUE, user_data, filter);
792 filter_connection_advertise_capabilities_cb (TpConnection *connection,
793 const GPtrArray *capabilities,
799 empathy_debug (DEBUG_DOMAIN, "Error advertising capabilities: %s",
806 filter_connection_ready_cb (TpConnection *connection,
808 EmpathyFilter *filter)
811 GPtrArray *capabilities;
814 const gchar *remove = NULL;
817 empathy_debug (DEBUG_DOMAIN, "Connection ready, accepting new channels");
819 tp_cli_connection_connect_to_new_channel (connection,
820 filter_conection_new_channel_cb,
822 G_OBJECT (filter), NULL);
823 tp_cli_connection_call_list_channels (connection, -1,
824 filter_connection_list_channels_cb,
829 /* Advertise VoIP capabilities */
830 capabilities = g_ptr_array_sized_new (1);
831 cap_type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING,
832 G_TYPE_UINT, G_TYPE_INVALID);
833 g_value_init (&cap, cap_type);
834 g_value_take_boxed (&cap, dbus_g_type_specialized_construct (cap_type));
835 dbus_g_type_struct_set (&cap,
836 0, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
837 1, TP_CHANNEL_MEDIA_CAPABILITY_AUDIO |
838 TP_CHANNEL_MEDIA_CAPABILITY_VIDEO |
839 TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_STUN |
840 TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P,
842 g_ptr_array_add (capabilities, g_value_get_boxed (&cap));
844 tp_cli_connection_interface_capabilities_call_advertise_capabilities (
846 capabilities, &remove,
847 filter_connection_advertise_capabilities_cb,
848 NULL, NULL, G_OBJECT (filter));
853 filter_update_account (EmpathyFilter *filter,
856 EmpathyFilterPriv *priv = GET_PRIV (filter);
857 TpConnection *connection;
860 connection = g_hash_table_lookup (priv->accounts, account);
865 connection = mission_control_get_tpconnection (priv->mc, account, NULL);
870 g_hash_table_insert (priv->accounts, g_object_ref (account), connection);
871 g_signal_connect (connection, "invalidated",
872 G_CALLBACK (filter_connection_invalidated_cb),
875 g_object_get (connection, "connection-ready", &ready, NULL);
877 filter_connection_ready_cb (connection, NULL, filter);
879 g_signal_connect (connection, "notify::connection-ready",
880 G_CALLBACK (filter_connection_ready_cb),
886 filter_status_changed_cb (MissionControl *mc,
887 TpConnectionStatus status,
889 TpConnectionStatusReason reason,
890 const gchar *unique_name,
891 EmpathyFilter *filter)
895 account = mc_account_lookup (unique_name);
896 filter_update_account (filter, account);
897 g_object_unref (account);
901 filter_finalize (GObject *object)
903 EmpathyFilterPriv *priv = GET_PRIV (object);
905 empathy_disconnect_account_status_changed (priv->token);
906 g_object_unref (priv->mc);
908 g_slist_foreach (priv->events, (GFunc) filter_event_free, NULL);
909 g_slist_free (priv->events);
911 g_hash_table_destroy (priv->accounts);
912 g_hash_table_destroy (priv->tubes);
916 filter_get_property (GObject *object,
921 EmpathyFilterPriv *priv = GET_PRIV (object);
925 g_value_set_pointer (value, priv->events ? priv->events->data : NULL);
928 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
934 empathy_filter_class_init (EmpathyFilterClass *klass)
936 GObjectClass *object_class = G_OBJECT_CLASS (klass);
938 object_class->finalize = filter_finalize;
939 object_class->get_property = filter_get_property;
941 g_object_class_install_property (object_class,
943 g_param_spec_pointer ("top-event",
945 "The first event in the events list",
948 g_type_class_add_private (object_class, sizeof (EmpathyFilterPriv));
952 empathy_filter_init (EmpathyFilter *filter)
954 EmpathyFilterPriv *priv = GET_PRIV (filter);
957 priv->tubes = g_hash_table_new_full (filter_channel_hash,
958 filter_channel_equal,
959 g_object_unref, NULL);
961 priv->mc = empathy_mission_control_new ();
962 priv->token = empathy_connect_to_account_status_changed (priv->mc,
963 G_CALLBACK (filter_status_changed_cb),
966 priv->accounts = g_hash_table_new_full (empathy_account_hash,
967 empathy_account_equal,
970 accounts = mc_accounts_list_by_enabled (TRUE);
971 for (l = accounts; l; l = l->next) {
972 filter_update_account (filter, l->data);
973 g_object_unref (l->data);
975 g_list_free (accounts);
979 empathy_filter_new (void)
981 static EmpathyFilter *filter = NULL;
984 filter = g_object_new (EMPATHY_TYPE_FILTER, NULL);
985 g_object_add_weak_pointer (G_OBJECT (filter), (gpointer) &filter);
987 g_object_ref (filter);