2 * Copyright (C) 2007-2008 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Xavier Claessens <xclaesse@gmail.com>
19 * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
25 #include <glib/gi18n.h>
27 #include <telepathy-glib/util.h>
29 #include <libempathy/empathy-dispatcher.h>
30 #include <libempathy/empathy-contact-factory.h>
31 #include <libempathy/empathy-contact-manager.h>
32 #include <libempathy/empathy-tp-chat.h>
33 #include <libempathy/empathy-tp-call.h>
34 #include <libempathy/empathy-utils.h>
35 #include <libempathy/empathy-call-factory.h>
37 #include <extensions/extensions.h>
39 #include <libempathy-gtk/empathy-images.h>
40 #include <libempathy-gtk/empathy-contact-dialogs.h>
41 #include <libempathy-gtk/empathy-ui-utils.h>
43 #include "empathy-event-manager.h"
44 #include "empathy-main-window.h"
45 #include "empathy-tube-dispatch.h"
47 #define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
48 #include <libempathy/empathy-debug.h>
50 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyEventManager)
53 EmpathyEventManager *manager;
54 EmpathyDispatchOperation *operation;
55 gulong approved_handler;
56 gulong claimed_handler;
57 gulong invalidated_handler;
58 /* Remove contact if applicable */
59 EmpathyContact *contact;
60 /* Tube dispatcher if applicable */
61 EmpathyTubeDispatch *tube_dispatch;
62 /* option signal handler */
64 /* optional accept widget */
66 } EventManagerApproval;
69 EmpathyDispatcher *dispatcher;
70 EmpathyContactManager *contact_manager;
72 /* Ongoing approvals */
75 /* voip ringing sound */
78 } EmpathyEventManagerPriv;
80 typedef struct _EventPriv EventPriv;
81 typedef void (*EventFunc) (EventPriv *event);
85 EmpathyEventManager *manager;
86 EventManagerApproval *approval;
99 static guint signals[LAST_SIGNAL];
101 G_DEFINE_TYPE (EmpathyEventManager, empathy_event_manager, G_TYPE_OBJECT);
103 static EmpathyEventManager * manager_singleton = NULL;
105 static EventManagerApproval *
106 event_manager_approval_new (EmpathyEventManager *manager,
107 EmpathyDispatchOperation *operation)
109 EventManagerApproval *result = g_slice_new0 (EventManagerApproval);
110 result->operation = g_object_ref (operation);
111 result->manager = manager;
117 event_manager_approval_free (EventManagerApproval *approval)
119 g_signal_handler_disconnect (approval->operation,
120 approval->approved_handler);
121 g_signal_handler_disconnect (approval->operation,
122 approval->claimed_handler);
123 g_signal_handler_disconnect (approval->operation,
124 approval->invalidated_handler);
125 g_object_unref (approval->operation);
127 if (approval->contact != NULL)
128 g_object_unref (approval->contact);
130 if (approval->tube_dispatch != NULL)
131 g_object_unref (approval->tube_dispatch);
133 if (approval->dialog != NULL)
135 gtk_widget_destroy (approval->dialog);
138 g_slice_free (EventManagerApproval, approval);
141 static void event_remove (EventPriv *event);
144 event_free (EventPriv *event)
146 g_free (event->public.icon_name);
147 g_free (event->public.header);
148 g_free (event->public.message);
150 if (event->public.contact)
152 g_object_unref (event->public.contact);
155 g_slice_free (EventPriv, event);
158 static void event_manager_ringing_finished_cb (ca_context *c, guint id,
159 int error_code, gpointer user_data);
162 event_manager_ringing_timeout_cb (gpointer data)
164 EmpathyEventManager *manager = EMPATHY_EVENT_MANAGER (data);
165 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
167 priv->voip_timeout = 0;
169 empathy_sound_play_full (empathy_main_window_get (),
170 EMPATHY_SOUND_PHONE_INCOMING, event_manager_ringing_finished_cb,
177 event_manager_ringing_idle_cb (gpointer data)
179 EmpathyEventManager *manager = EMPATHY_EVENT_MANAGER (data);
180 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
182 if (priv->ringing > 0)
183 priv->voip_timeout = g_timeout_add (500, event_manager_ringing_timeout_cb,
190 event_manager_ringing_finished_cb (ca_context *c, guint id, int error_code,
193 if (error_code == CA_ERROR_CANCELED)
196 g_idle_add (event_manager_ringing_idle_cb, user_data);
200 event_manager_start_ringing (EmpathyEventManager *manager)
202 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
206 if (priv->ringing == 1)
208 empathy_sound_play_full (empathy_main_window_get (),
209 EMPATHY_SOUND_PHONE_INCOMING, event_manager_ringing_finished_cb,
215 event_manager_stop_ringing (EmpathyEventManager *manager)
217 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
221 if (priv->ringing > 0)
224 empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING);
226 if (priv->voip_timeout != 0)
228 g_source_remove (priv->voip_timeout);
229 priv->voip_timeout = 0;
234 event_remove (EventPriv *event)
236 EmpathyEventManagerPriv *priv = GET_PRIV (event->manager);
238 DEBUG ("Removing event %p", event);
239 priv->events = g_slist_remove (priv->events, event);
240 g_signal_emit (event->manager, signals[EVENT_REMOVED], 0, event);
245 event_manager_add (EmpathyEventManager *manager, EmpathyContact *contact,
246 const gchar *icon_name, const gchar *header, const gchar *message,
247 EventManagerApproval *approval, EventFunc func, gpointer user_data)
249 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
252 event = g_slice_new0 (EventPriv);
253 event->public.contact = contact ? g_object_ref (contact) : NULL;
254 event->public.icon_name = g_strdup (icon_name);
255 event->public.header = g_strdup (header);
256 event->public.message = g_strdup (message);
257 event->inhibit = FALSE;
259 event->user_data = user_data;
260 event->manager = manager;
261 event->approval = approval;
263 DEBUG ("Adding event %p", event);
264 priv->events = g_slist_prepend (priv->events, event);
265 g_signal_emit (event->manager, signals[EVENT_ADDED], 0, event);
269 event_channel_process_func (EventPriv *event)
271 empathy_dispatch_operation_approve (event->approval->operation);
275 event_text_channel_process_func (EventPriv *event)
277 EmpathyTpChat *tp_chat;
279 if (event->approval->handler != 0)
281 tp_chat = EMPATHY_TP_CHAT
282 (empathy_dispatch_operation_get_channel_wrapper (event->approval->operation));
284 g_signal_handler_disconnect (tp_chat, event->approval->handler);
285 event->approval->handler = 0;
288 empathy_dispatch_operation_approve (event->approval->operation);
292 event_lookup_by_approval (EmpathyEventManager *manager,
293 EventManagerApproval *approval)
295 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
297 EventPriv *retval = NULL;
299 for (l = priv->events; l; l = l->next)
301 EventPriv *event = l->data;
303 if (event->approval == approval)
314 event_update (EmpathyEventManager *manager, EventPriv *event,
315 const char *icon_name, const char *header, const char *msg)
317 g_free (event->public.icon_name);
318 g_free (event->public.header);
319 g_free (event->public.message);
321 event->public.icon_name = g_strdup (icon_name);
322 event->public.header = g_strdup (header);
323 event->public.message = g_strdup (msg);
325 g_signal_emit (manager, signals[EVENT_UPDATED], 0, event);
328 event_manager_call_window_confirmation_dialog_response_cb (GtkDialog *dialog,
329 gint response, gpointer user_data)
331 EventManagerApproval *approval = user_data;
333 gtk_widget_destroy (approval->dialog);
334 approval->dialog = NULL;
336 if (response != GTK_RESPONSE_ACCEPT)
338 EmpathyTpCall *call =
340 empathy_dispatch_operation_get_channel_wrapper (
341 approval->operation));
344 if (empathy_dispatch_operation_claim (approval->operation))
345 empathy_tp_call_close (call);
346 g_object_unref (call);
351 EmpathyCallFactory *factory = empathy_call_factory_get ();
352 empathy_call_factory_claim_channel (factory, approval->operation);
357 event_channel_process_voip_func (EventPriv *event)
363 if (event->approval->dialog != NULL)
365 gtk_window_present (GTK_WINDOW (event->approval->dialog));
369 dialog = gtk_message_dialog_new (GTK_WINDOW (empathy_main_window_get()),
370 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
371 GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Incoming call"));
372 gtk_message_dialog_format_secondary_text (
373 GTK_MESSAGE_DIALOG (dialog),
374 _("%s is calling you, do you want to answer?"),
375 empathy_contact_get_name (event->approval->contact));
377 gtk_dialog_set_default_response (GTK_DIALOG (dialog),
380 button = gtk_dialog_add_button (GTK_DIALOG (dialog),
381 _("_Reject"), GTK_RESPONSE_REJECT);
382 image = gtk_image_new_from_icon_name (GTK_STOCK_CANCEL,
383 GTK_ICON_SIZE_BUTTON);
384 gtk_button_set_image (GTK_BUTTON (button), image);
386 button = gtk_dialog_add_button (GTK_DIALOG (dialog),
387 _("_Answer"), GTK_RESPONSE_ACCEPT);
389 image = gtk_image_new_from_icon_name (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON);
390 gtk_button_set_image (GTK_BUTTON (button), image);
392 g_signal_connect (dialog, "response",
393 G_CALLBACK (event_manager_call_window_confirmation_dialog_response_cb),
396 gtk_widget_show (dialog);
398 event->approval->dialog = dialog;
402 event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
403 EmpathyMessage *message, EventManagerApproval *approval)
405 EmpathyContact *sender;
411 /* try to update the event if it's referring to a chat which is already in the
413 event = event_lookup_by_approval (approval->manager, approval);
415 if (event != NULL && event->inhibit && approval->handler != 0)
417 g_signal_handler_disconnect (tp_chat, approval->handler);
418 approval->handler = 0;
422 sender = empathy_message_get_sender (message);
423 header = g_strdup_printf (_("New message from %s"),
424 empathy_contact_get_name (sender));
425 msg = empathy_message_get_body (message);
427 channel = empathy_tp_chat_get_channel (tp_chat);
430 event_update (approval->manager, event, EMPATHY_IMAGE_NEW_MESSAGE, header, msg);
432 event_manager_add (approval->manager, sender, EMPATHY_IMAGE_NEW_MESSAGE, header,
433 msg, approval, event_text_channel_process_func, NULL);
436 empathy_sound_play (empathy_main_window_get (),
437 EMPATHY_SOUND_CONVERSATION_NEW);
443 event_manager_approval_done (EventManagerApproval *approval)
445 EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
448 if (approval->operation != NULL)
452 channel_type = empathy_dispatch_operation_get_channel_type_id (
453 approval->operation);
454 if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
456 event_manager_stop_ringing (approval->manager);
460 priv->approvals = g_slist_remove (priv->approvals, approval);
462 for (l = priv->events; l; l = l->next)
464 EventPriv *event = l->data;
466 if (event->approval == approval)
468 event_remove (event);
473 event_manager_approval_free (approval);
477 event_manager_operation_approved_cb (EmpathyDispatchOperation *operation,
478 EventManagerApproval *approval)
480 event_manager_approval_done (approval);
484 event_manager_operation_claimed_cb (EmpathyDispatchOperation *operation,
485 EventManagerApproval *approval)
487 event_manager_approval_done (approval);
491 event_manager_operation_invalidated_cb (EmpathyDispatchOperation *operation,
492 guint domain, gint code, gchar *message,
493 EventManagerApproval *approval)
495 event_manager_approval_done (approval);
499 event_manager_media_channel_got_name_cb (EmpathyContact *contact,
500 const GError *error, gpointer user_data, GObject *object)
502 EventManagerApproval *approval = user_data;
507 /* FIXME just returning assuming the operation will be invalidated as
512 header = g_strdup_printf (_("Incoming call from %s"),
513 empathy_contact_get_name (contact));
515 event_manager_add (approval->manager,
516 approval->contact, EMPATHY_IMAGE_VOIP, msg,
517 approval, event_channel_process_voip_func, NULL);
520 event_manager_start_ringing (approval->manager);
526 event_manager_media_channel_got_contact (EventManagerApproval *approval)
528 empathy_contact_call_when_ready (approval->contact,
529 EMPATHY_CONTACT_READY_NAME, event_manager_media_channel_got_name_cb,
530 approval, NULL, G_OBJECT (approval->manager));
534 event_manager_media_channel_contact_changed_cb (EmpathyTpCall *call,
535 GParamSpec *param, EventManagerApproval *approval)
537 EmpathyContact *contact;
539 g_object_get (G_OBJECT (call), "contact", &contact, NULL);
544 approval->contact = contact;
545 event_manager_media_channel_got_contact (approval);
549 event_manager_tube_approved_cb (EventPriv *event)
551 empathy_tube_dispatch_handle (event->approval->tube_dispatch);
555 event_manager_add_tube_approval (EventManagerApproval *approval,
556 EmpathyTubeDispatchAbility ability)
558 const gchar *icon_name;
562 header = g_strdup_printf (_("%s is offering you an invitation"),
563 empathy_contact_get_name (approval->contact));
565 if (ability == EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE)
567 icon_name = GTK_STOCK_EXECUTE;
568 msg = _("An external application will be started to handle it.");
572 icon_name = GTK_STOCK_DIALOG_ERROR;
573 msg = _("You don't have the needed external "
574 "application to handle it.");
577 event_manager_add (approval->manager, approval->contact, icon_name, header,
578 msg, approval, event_manager_tube_approved_cb, approval);
581 /* FIXME better sound for incoming tubes ? */
582 empathy_sound_play (empathy_main_window_get (),
583 EMPATHY_SOUND_CONVERSATION_NEW);
589 event_manager_tube_dispatch_ability_cb (GObject *object,
590 GParamSpec *spec, gpointer user_data)
592 EventManagerApproval *approval = (EventManagerApproval *)user_data;
593 EmpathyTubeDispatchAbility dispatchability;
596 empathy_tube_dispatch_is_dispatchable (approval->tube_dispatch);
598 if (dispatchability != EMPATHY_TUBE_DISPATCHABILITY_UNKNOWN)
600 event_manager_add_tube_approval (approval, dispatchability);
601 g_signal_handler_disconnect (object, approval->handler);
602 approval->handler = 0;
607 event_manager_tube_got_contact_name_cb (EmpathyContact *contact,
608 const GError *error, gpointer user_data, GObject *object)
610 EventManagerApproval *approval = (EventManagerApproval *)user_data;
611 EmpathyTubeDispatchAbility dispatchability;
615 /* FIXME?, we assume that the operation gets invalidated as well (if it
620 dispatchability = empathy_tube_dispatch_is_dispatchable
621 (approval->tube_dispatch);
624 switch (dispatchability)
626 case EMPATHY_TUBE_DISPATCHABILITY_UNKNOWN:
627 approval->handler = g_signal_connect (approval->tube_dispatch,
628 "notify::dispatchability",
629 G_CALLBACK (event_manager_tube_dispatch_ability_cb), approval);
631 case EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE:
633 case EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE:
634 event_manager_add_tube_approval (approval, dispatchability);
640 event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
641 EmpathyDispatchOperation *operation, EmpathyEventManager *manager)
643 const gchar *channel_type;
644 EventManagerApproval *approval;
645 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
647 channel_type = empathy_dispatch_operation_get_channel_type (operation);
649 approval = event_manager_approval_new (manager, operation);
650 priv->approvals = g_slist_prepend (priv->approvals, approval);
652 approval->approved_handler = g_signal_connect (operation, "approved",
653 G_CALLBACK (event_manager_operation_approved_cb), approval);
655 approval->claimed_handler = g_signal_connect (operation, "claimed",
656 G_CALLBACK (event_manager_operation_claimed_cb), approval);
658 approval->invalidated_handler = g_signal_connect (operation, "invalidated",
659 G_CALLBACK (event_manager_operation_invalidated_cb), approval);
661 if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT))
663 EmpathyTpChat *tp_chat =
665 empathy_dispatch_operation_get_channel_wrapper (operation));
667 approval->handler = g_signal_connect (tp_chat, "message-received",
668 G_CALLBACK (event_manager_chat_message_received_cb), approval);
671 else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
673 EmpathyContact *contact;
674 EmpathyTpCall *call = EMPATHY_TP_CALL (
675 empathy_dispatch_operation_get_channel_wrapper (operation));
677 g_object_get (G_OBJECT (call), "contact", &contact, NULL);
681 g_signal_connect (call, "notify::contact",
682 G_CALLBACK (event_manager_media_channel_contact_changed_cb),
687 approval->contact = contact;
688 event_manager_media_channel_got_contact (approval);
692 else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
694 EmpathyContact *contact;
698 EmpathyContactFactory *factory;
699 TpChannel *channel = empathy_dispatch_operation_get_channel (operation);
701 factory = empathy_contact_factory_dup_singleton ();
702 handle = tp_channel_get_handle (channel, NULL);
703 account = empathy_channel_get_account (channel);
705 contact = empathy_contact_factory_get_from_handle (factory, account,
708 empathy_contact_run_until_ready (contact,
709 EMPATHY_CONTACT_READY_NAME, NULL);
711 header = g_strdup_printf (_("Incoming file transfer from %s"),
712 empathy_contact_get_name (contact));
714 event_manager_add (manager, contact, EMPATHY_IMAGE_DOCUMENT_SEND,
715 header, NULL, approval, event_channel_process_func, NULL);
717 /* FIXME better sound for incoming file transfers ?*/
718 empathy_sound_play (empathy_main_window_get (),
719 EMPATHY_SOUND_CONVERSATION_NEW);
721 g_object_unref (factory);
722 g_object_unref (account);
725 else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE) ||
726 !tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE))
728 EmpathyContact *contact;
730 TpHandleType handle_type;
732 EmpathyContactFactory *factory;
733 EmpathyTubeDispatch *tube_dispatch;
736 channel = empathy_dispatch_operation_get_channel (operation);
738 handle = tp_channel_get_handle (channel, &handle_type);
740 /* Only understand p2p tubes */
741 if (handle_type != TP_HANDLE_TYPE_CONTACT)
744 factory = empathy_contact_factory_dup_singleton ();
745 account = empathy_channel_get_account (channel);
747 contact = empathy_contact_factory_get_from_handle (factory, account,
750 tube_dispatch = empathy_tube_dispatch_new (operation);
752 approval->contact = contact;
753 approval->tube_dispatch = tube_dispatch;
755 empathy_contact_call_when_ready (contact,
756 EMPATHY_CONTACT_READY_NAME, event_manager_tube_got_contact_name_cb,
757 approval, NULL, G_OBJECT (manager));
759 g_object_unref (factory);
760 g_object_unref (account);
764 DEBUG ("Unknown channel type, ignoring..");
769 event_pending_subscribe_func (EventPriv *event)
771 empathy_subscription_dialog_show (event->public.contact, NULL);
772 event_remove (event);
776 event_manager_pendings_changed_cb (EmpathyContactList *list,
777 EmpathyContact *contact, EmpathyContact *actor,
778 guint reason, gchar *message, gboolean is_pending,
779 EmpathyEventManager *manager)
781 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
782 gchar *header, *event_msg;
788 for (l = priv->events; l; l = l->next)
790 EventPriv *event = l->data;
792 if (event->public.contact == contact &&
793 event->func == event_pending_subscribe_func)
795 event_remove (event);
803 empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_NAME, NULL);
805 header = g_strdup_printf (_("Subscription requested by %s"),
806 empathy_contact_get_name (contact));
808 if (!EMP_STR_EMPTY (message))
809 event_msg = g_strdup_printf (_("\nMessage: %s"), message);
813 event_manager_add (manager, contact, GTK_STOCK_DIALOG_QUESTION, header,
814 event_msg, NULL, event_pending_subscribe_func, NULL);
821 event_manager_constructor (GType type,
823 GObjectConstructParam *props)
827 if (manager_singleton) {
828 retval = g_object_ref (manager_singleton);
830 retval = G_OBJECT_CLASS (empathy_event_manager_parent_class)->constructor
831 (type, n_props, props);
833 manager_singleton = EMPATHY_EVENT_MANAGER (retval);
834 g_object_add_weak_pointer (retval, (gpointer *) &manager_singleton);
841 event_manager_finalize (GObject *object)
843 EmpathyEventManagerPriv *priv = GET_PRIV (object);
845 g_slist_foreach (priv->events, (GFunc) event_free, NULL);
846 g_slist_free (priv->events);
847 g_slist_foreach (priv->approvals, (GFunc) event_manager_approval_free, NULL);
848 g_slist_free (priv->approvals);
849 g_object_unref (priv->contact_manager);
850 g_object_unref (priv->dispatcher);
854 empathy_event_manager_class_init (EmpathyEventManagerClass *klass)
856 GObjectClass *object_class = G_OBJECT_CLASS (klass);
858 object_class->finalize = event_manager_finalize;
859 object_class->constructor = event_manager_constructor;
861 signals[EVENT_ADDED] =
862 g_signal_new ("event-added",
863 G_TYPE_FROM_CLASS (klass),
867 g_cclosure_marshal_VOID__POINTER,
871 signals[EVENT_REMOVED] =
872 g_signal_new ("event-removed",
873 G_TYPE_FROM_CLASS (klass),
877 g_cclosure_marshal_VOID__POINTER,
878 G_TYPE_NONE, 1, G_TYPE_POINTER);
880 signals[EVENT_UPDATED] =
881 g_signal_new ("event-updated",
882 G_TYPE_FROM_CLASS (klass),
886 g_cclosure_marshal_VOID__POINTER,
887 G_TYPE_NONE, 1, G_TYPE_POINTER);
890 g_type_class_add_private (object_class, sizeof (EmpathyEventManagerPriv));
894 empathy_event_manager_init (EmpathyEventManager *manager)
896 EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
897 EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv);
899 manager->priv = priv;
901 priv->dispatcher = empathy_dispatcher_dup_singleton ();
902 priv->contact_manager = empathy_contact_manager_dup_singleton ();
903 g_signal_connect (priv->dispatcher, "approve",
904 G_CALLBACK (event_manager_approve_channel_cb), manager);
905 g_signal_connect (priv->contact_manager, "pendings-changed",
906 G_CALLBACK (event_manager_pendings_changed_cb), manager);
909 EmpathyEventManager *
910 empathy_event_manager_dup_singleton (void)
912 return g_object_new (EMPATHY_TYPE_EVENT_MANAGER, NULL);
916 empathy_event_manager_get_events (EmpathyEventManager *manager)
918 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
920 g_return_val_if_fail (EMPATHY_IS_EVENT_MANAGER (manager), NULL);
926 empathy_event_manager_get_top_event (EmpathyEventManager *manager)
928 EmpathyEventManagerPriv *priv = GET_PRIV (manager);
930 g_return_val_if_fail (EMPATHY_IS_EVENT_MANAGER (manager), NULL);
932 return priv->events ? priv->events->data : NULL;
936 empathy_event_activate (EmpathyEvent *event_public)
938 EventPriv *event = (EventPriv*) event_public;
940 g_return_if_fail (event_public != NULL);
945 event_remove (event);
949 empathy_event_inhibit_updates (EmpathyEvent *event_public)
951 EventPriv *event = (EventPriv *) event_public;
953 g_return_if_fail (event_public != NULL);
955 event->inhibit = TRUE;