]> git.0d.be Git - empathy.git/blob - libempathy/empathy-chatroom-manager.c
Coding style: one declaration per line.
[empathy.git] / libempathy / empathy-chatroom-manager.c
1 /*
2  * Copyright (C) 2004-2007 Imendio AB
3  * Copyright (C) 2007-2009 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program 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  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  *          Martyn Russell <martyn@imendio.com>
22  */
23
24 #include "config.h"
25
26 #include <string.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29
30 #include <libxml/parser.h>
31 #include <libxml/tree.h>
32
33 #include "empathy-tp-chat.h"
34 #include "empathy-chatroom-manager.h"
35 #include "empathy-account-manager.h"
36 #include "empathy-utils.h"
37
38 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
39 #include "empathy-debug.h"
40
41 #define CHATROOMS_XML_FILENAME "chatrooms.xml"
42 #define CHATROOMS_DTD_FILENAME "empathy-chatroom-manager.dtd"
43 #define SAVE_TIMER 4
44
45 static EmpathyChatroomManager *chatroom_manager_singleton = NULL;
46
47 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroomManager)
48 typedef struct
49 {
50   GList *chatrooms;
51   gchar *file;
52   EmpathyAccountManager *account_manager;
53   /* source id of the autosave timer */
54   gint save_timer_id;
55 } EmpathyChatroomManagerPriv;
56
57 enum {
58   CHATROOM_ADDED,
59   CHATROOM_REMOVED,
60   LAST_SIGNAL
61 };
62
63 static guint signals[LAST_SIGNAL];
64
65 /* properties */
66 enum
67 {
68   PROP_FILE = 1,
69   LAST_PROPERTY
70 };
71
72 G_DEFINE_TYPE (EmpathyChatroomManager, empathy_chatroom_manager, G_TYPE_OBJECT);
73
74 /*
75  * API to save/load and parse the chatrooms file.
76  */
77
78 static gboolean
79 chatroom_manager_file_save (EmpathyChatroomManager *manager)
80 {
81         EmpathyChatroomManagerPriv *priv;
82         xmlDocPtr                  doc;
83         xmlNodePtr                 root;
84         GList                     *l;
85
86         priv = GET_PRIV (manager);
87
88         doc = xmlNewDoc ("1.0");
89         root = xmlNewNode (NULL, "chatrooms");
90         xmlDocSetRootElement (doc, root);
91
92         for (l = priv->chatrooms; l; l = l->next) {
93                 EmpathyChatroom *chatroom;
94                 xmlNodePtr       node;
95                 const gchar     *account_id;
96
97                 chatroom = l->data;
98
99                 if (!empathy_chatroom_is_favorite (chatroom)) {
100                         continue;
101                 }
102
103                 account_id = mc_account_get_unique_name (empathy_chatroom_get_account (chatroom));
104
105                 node = xmlNewChild (root, NULL, "chatroom", NULL);
106                 xmlNewTextChild (node, NULL, "name", empathy_chatroom_get_name (chatroom));
107                 xmlNewTextChild (node, NULL, "room", empathy_chatroom_get_room (chatroom));
108                 xmlNewTextChild (node, NULL, "account", account_id);
109                 xmlNewTextChild (node, NULL, "auto_connect",
110                         empathy_chatroom_get_auto_connect (chatroom) ? "yes" : "no");
111         }
112
113         /* Make sure the XML is indented properly */
114         xmlIndentTreeOutput = 1;
115
116         DEBUG ("Saving file:'%s'", priv->file);
117         xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);
118         xmlFreeDoc (doc);
119
120         xmlCleanupParser ();
121         xmlMemoryDump ();
122
123         return TRUE;
124 }
125
126 static gboolean
127 save_timeout (EmpathyChatroomManager *self)
128 {
129   EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
130
131   priv->save_timer_id = 0;
132   chatroom_manager_file_save (self);
133
134   return FALSE;
135 }
136
137 static void
138 reset_save_timeout (EmpathyChatroomManager *self)
139 {
140   EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
141
142   if (priv->save_timer_id > 0)
143     {
144       g_source_remove (priv->save_timer_id);
145     }
146
147   priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER,
148       (GSourceFunc) save_timeout, self);
149 }
150
151 static void
152 chatroom_changed_cb (EmpathyChatroom *chatroom,
153                      GParamSpec *spec,
154                      EmpathyChatroomManager *self)
155 {
156   reset_save_timeout (self);
157 }
158
159 static void
160 add_chatroom (EmpathyChatroomManager *self,
161               EmpathyChatroom *chatroom)
162 {
163   EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
164
165   priv->chatrooms = g_list_prepend (priv->chatrooms, g_object_ref (chatroom));
166
167   g_signal_connect (chatroom, "notify",
168       G_CALLBACK (chatroom_changed_cb), self);
169 }
170
171 static void
172 chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
173                                  xmlNodePtr             node)
174 {
175         EmpathyChatroomManagerPriv *priv;
176         EmpathyChatroom            *chatroom;
177         McAccount                 *account;
178         xmlNodePtr                 child;
179         gchar                     *str;
180         gchar                     *name;
181         gchar                     *room;
182         gchar                     *account_id;
183         gboolean                   auto_connect;
184
185         priv = GET_PRIV (manager);
186
187         /* default values. */
188         name = NULL;
189         room = NULL;
190         auto_connect = TRUE;
191         account_id = NULL;
192
193         for (child = node->children; child; child = child->next) {
194                 gchar *tag;
195
196                 if (xmlNodeIsText (child)) {
197                         continue;
198                 }
199
200                 tag = (gchar *) child->name;
201                 str = (gchar *) xmlNodeGetContent (child);
202
203                 if (strcmp (tag, "name") == 0) {
204                         name = g_strdup (str);
205                 }
206                 else if (strcmp (tag, "room") == 0) {
207                         room = g_strdup (str);
208                 }
209                 else if (strcmp (tag, "auto_connect") == 0) {
210                         if (strcmp (str, "yes") == 0) {
211                                 auto_connect = TRUE;
212                         } else {
213                                 auto_connect = FALSE;
214                         }
215                 }
216                 else if (strcmp (tag, "account") == 0) {
217                         account_id = g_strdup (str);
218                 }
219
220                 xmlFree (str);
221         }
222
223         account = mc_account_lookup (account_id);
224         if (!account) {
225                 g_free (name);
226                 g_free (room);
227                 g_free (account_id);
228                 return;
229         }
230
231         chatroom = empathy_chatroom_new_full (account, room, name, auto_connect);
232         empathy_chatroom_set_favorite (chatroom, TRUE);
233         add_chatroom (manager, chatroom);
234         g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);
235
236         g_object_unref (account);
237         g_free (name);
238         g_free (room);
239         g_free (account_id);
240 }
241
242 static gboolean
243 chatroom_manager_file_parse (EmpathyChatroomManager *manager,
244                              const gchar           *filename)
245 {
246         EmpathyChatroomManagerPriv *priv;
247         xmlParserCtxtPtr           ctxt;
248         xmlDocPtr                  doc;
249         xmlNodePtr                 chatrooms;
250         xmlNodePtr                 node;
251
252         priv = GET_PRIV (manager);
253
254         DEBUG ("Attempting to parse file:'%s'...", filename);
255
256         ctxt = xmlNewParserCtxt ();
257
258         /* Parse and validate the file. */
259         doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
260         if (!doc) {
261                 g_warning ("Failed to parse file:'%s'", filename);
262                 xmlFreeParserCtxt (ctxt);
263                 return FALSE;
264         }
265
266         if (!empathy_xml_validate (doc, CHATROOMS_DTD_FILENAME)) {
267                 g_warning ("Failed to validate file:'%s'", filename);
268                 xmlFreeDoc (doc);
269                 xmlFreeParserCtxt (ctxt);
270                 return FALSE;
271         }
272
273         /* The root node, chatrooms. */
274         chatrooms = xmlDocGetRootElement (doc);
275
276         for (node = chatrooms->children; node; node = node->next) {
277                 if (strcmp ((gchar *) node->name, "chatroom") == 0) {
278                         chatroom_manager_parse_chatroom (manager, node);
279                 }
280         }
281
282         DEBUG ("Parsed %d chatrooms", g_list_length (priv->chatrooms));
283
284         xmlFreeDoc (doc);
285         xmlFreeParserCtxt (ctxt);
286
287         return TRUE;
288 }
289
290 static gboolean
291 chatroom_manager_get_all (EmpathyChatroomManager *manager)
292 {
293         EmpathyChatroomManagerPriv *priv;
294
295         priv = GET_PRIV (manager);
296
297         /* read file in */
298         if (g_file_test (priv->file, G_FILE_TEST_EXISTS) &&
299             !chatroom_manager_file_parse (manager, priv->file)) {
300                 return FALSE;
301         }
302
303         return TRUE;
304 }
305
306 static void
307 empathy_chatroom_manager_get_property (GObject *object,
308                                        guint property_id,
309                                        GValue *value,
310                                        GParamSpec *pspec)
311 {
312   EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
313   EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
314
315   switch (property_id)
316     {
317       case PROP_FILE:
318         g_value_set_string (value, priv->file);
319         break;
320       default:
321         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
322         break;
323     }
324 }
325
326 static void
327 empathy_chatroom_manager_set_property (GObject *object,
328                                        guint property_id,
329                                        const GValue *value,
330                                        GParamSpec *pspec)
331 {
332   EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
333   EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
334
335   switch (property_id)
336     {
337       case PROP_FILE:
338         g_free (priv->file);
339         priv->file = g_value_dup_string (value);
340         break;
341       default:
342         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
343         break;
344     }
345 }
346
347 static void
348 chatroom_manager_finalize (GObject *object)
349 {
350   EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
351   EmpathyChatroomManagerPriv *priv;
352   GList *l;
353
354   priv = GET_PRIV (object);
355
356   g_object_unref (priv->account_manager);
357
358   if (priv->save_timer_id > 0)
359     {
360       /* have to save before destroy the object */
361       g_source_remove (priv->save_timer_id);
362       priv->save_timer_id = 0;
363       chatroom_manager_file_save (self);
364     }
365
366   for (l = priv->chatrooms; l != NULL; l = g_list_next (l))
367     {
368       EmpathyChatroom *chatroom = l->data;
369
370       g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb,
371           self);
372
373       g_object_unref (chatroom);
374     }
375
376   g_list_free (priv->chatrooms);
377   g_free (priv->file);
378
379   (G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->finalize) (object);
380 }
381
382 static GObject *
383 empathy_chatroom_manager_constructor (GType type,
384                                       guint n_props,
385                                       GObjectConstructParam *props)
386 {
387   GObject *obj;
388   EmpathyChatroomManager *self;
389   EmpathyChatroomManagerPriv *priv;
390
391   if (chatroom_manager_singleton != NULL)
392     return g_object_ref (chatroom_manager_singleton);
393
394   /* Parent constructor chain */
395   obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->
396         constructor (type, n_props, props);
397
398   self = EMPATHY_CHATROOM_MANAGER (obj);
399   priv = GET_PRIV (self);
400
401   chatroom_manager_singleton = self;
402   g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton);
403
404   priv->account_manager = empathy_account_manager_dup_singleton ();
405
406   if (priv->file == NULL)
407     {
408       /* Set the default file path */
409       gchar *dir;
410
411       dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
412       if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
413         g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
414
415       priv->file = g_build_filename (dir, CHATROOMS_XML_FILENAME, NULL);
416       g_free (dir);
417     }
418
419   chatroom_manager_get_all (self);
420   return obj;
421 }
422
423 static void
424 empathy_chatroom_manager_class_init (EmpathyChatroomManagerClass *klass)
425 {
426   GObjectClass *object_class = G_OBJECT_CLASS (klass);
427   GParamSpec *param_spec;
428
429   object_class->constructor = empathy_chatroom_manager_constructor;
430   object_class->get_property = empathy_chatroom_manager_get_property;
431   object_class->set_property = empathy_chatroom_manager_set_property;
432         object_class->finalize = chatroom_manager_finalize;
433
434   param_spec = g_param_spec_string (
435       "file",
436       "path of the favorite file",
437       "The path of the XML file containing user's favorites",
438       NULL,
439       G_PARAM_CONSTRUCT_ONLY |
440       G_PARAM_READWRITE |
441       G_PARAM_STATIC_NAME |
442       G_PARAM_STATIC_NICK |
443       G_PARAM_STATIC_BLURB);
444   g_object_class_install_property (object_class, PROP_FILE, param_spec);
445
446   signals[CHATROOM_ADDED] = g_signal_new ("chatroom-added",
447       G_TYPE_FROM_CLASS (klass),
448       G_SIGNAL_RUN_LAST,
449       0, NULL, NULL,
450       g_cclosure_marshal_VOID__OBJECT,
451       G_TYPE_NONE,
452       1, EMPATHY_TYPE_CHATROOM);
453
454   signals[CHATROOM_REMOVED] = g_signal_new ("chatroom-removed",
455       G_TYPE_FROM_CLASS (klass),
456       G_SIGNAL_RUN_LAST,
457       0, NULL, NULL,
458       g_cclosure_marshal_VOID__OBJECT,
459       G_TYPE_NONE,
460       1, EMPATHY_TYPE_CHATROOM);
461
462   g_type_class_add_private (object_class, sizeof (EmpathyChatroomManagerPriv));
463 }
464
465 static void
466 empathy_chatroom_manager_init (EmpathyChatroomManager *manager)
467 {
468   EmpathyChatroomManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
469       EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManagerPriv);
470
471   manager->priv = priv;
472 }
473
474 EmpathyChatroomManager *
475 empathy_chatroom_manager_dup_singleton (const gchar *file)
476 {
477   return EMPATHY_CHATROOM_MANAGER (g_object_new (EMPATHY_TYPE_CHATROOM_MANAGER,
478       "file", file, NULL));
479 }
480
481 gboolean
482 empathy_chatroom_manager_add (EmpathyChatroomManager *manager,
483                              EmpathyChatroom        *chatroom)
484 {
485   EmpathyChatroomManagerPriv *priv;
486
487   g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), FALSE);
488   g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE);
489
490   priv = GET_PRIV (manager);
491
492   /* don't add more than once */
493   if (!empathy_chatroom_manager_find (manager,
494       empathy_chatroom_get_account (chatroom),
495       empathy_chatroom_get_room (chatroom)))
496     {
497       add_chatroom (manager, chatroom);
498
499       if (empathy_chatroom_is_favorite (chatroom))
500         reset_save_timeout (manager);
501
502       g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);
503       return TRUE;
504     }
505
506   return FALSE;
507 }
508
509 static void
510 chatroom_manager_remove_link (EmpathyChatroomManager *manager,
511                               GList *l)
512 {
513   EmpathyChatroomManagerPriv *priv;
514   EmpathyChatroom *chatroom;
515
516   priv = GET_PRIV (manager);
517
518   chatroom = l->data;
519
520   if (empathy_chatroom_is_favorite (chatroom))
521     reset_save_timeout (manager);
522
523   g_signal_emit (manager, signals[CHATROOM_REMOVED], 0, chatroom);
524   g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb, manager);
525
526   priv->chatrooms = g_list_delete_link (priv->chatrooms, l);
527   g_object_unref (chatroom);
528 }
529
530 void
531 empathy_chatroom_manager_remove (EmpathyChatroomManager *manager,
532                                  EmpathyChatroom        *chatroom)
533 {
534   EmpathyChatroomManagerPriv *priv;
535   GList *l;
536
537   g_return_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager));
538   g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
539
540   priv = GET_PRIV (manager);
541
542   for (l = priv->chatrooms; l; l = l->next)
543     {
544       EmpathyChatroom *this_chatroom;
545
546       this_chatroom = l->data;
547
548       if (this_chatroom == chatroom ||
549           empathy_chatroom_equal (chatroom, this_chatroom))
550         {
551           chatroom_manager_remove_link (manager, l);
552           break;
553         }
554     }
555 }
556
557 EmpathyChatroom *
558 empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
559                                McAccount *account,
560                                const gchar *room)
561 {
562         EmpathyChatroomManagerPriv *priv;
563         GList                     *l;
564
565         g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), NULL);
566         g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
567         g_return_val_if_fail (room != NULL, NULL);
568
569         priv = GET_PRIV (manager);
570
571         for (l = priv->chatrooms; l; l = l->next) {
572                 EmpathyChatroom *chatroom;
573                 McAccount      *this_account;
574                 const gchar    *this_room;
575
576                 chatroom = l->data;
577                 this_account = empathy_chatroom_get_account (chatroom);
578                 this_room = empathy_chatroom_get_room (chatroom);
579
580                 if (this_account && this_room &&
581                     empathy_account_equal (account, this_account) &&
582                     strcmp (this_room, room) == 0) {
583                         return chatroom;
584                 }
585         }
586
587         return NULL;
588 }
589
590 GList *
591 empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
592                                        McAccount             *account)
593 {
594         EmpathyChatroomManagerPriv *priv;
595         GList                     *chatrooms, *l;
596
597         g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), NULL);
598
599         priv = GET_PRIV (manager);
600
601         if (!account) {
602                 return g_list_copy (priv->chatrooms);
603         }
604
605         chatrooms = NULL;
606         for (l = priv->chatrooms; l; l = l->next) {
607                 EmpathyChatroom *chatroom;
608
609                 chatroom = l->data;
610
611                 if (empathy_account_equal (account,
612                                           empathy_chatroom_get_account (chatroom))) {
613                         chatrooms = g_list_append (chatrooms, chatroom);
614                 }
615         }
616
617         return chatrooms;
618 }
619
620 guint
621 empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,
622                                    McAccount             *account)
623 {
624         EmpathyChatroomManagerPriv *priv;
625         GList                     *l;
626         guint                      count = 0;
627
628         g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), 0);
629
630         priv = GET_PRIV (manager);
631
632         if (!account) {
633                 return g_list_length (priv->chatrooms);
634         }
635
636         for (l = priv->chatrooms; l; l = l->next) {
637                 EmpathyChatroom *chatroom;
638
639                 chatroom = l->data;
640
641                 if (empathy_account_equal (account,
642                                            empathy_chatroom_get_account (chatroom))) {
643                         count++;
644                 }
645         }
646
647         return count;
648 }
649
650 static void
651 chatroom_manager_chat_destroyed_cb (EmpathyTpChat *chat,
652   gpointer manager)
653 {
654   EmpathyChatroomManagerPriv *priv = GET_PRIV (manager);
655   GList *l;
656
657   for (l = priv->chatrooms; l; l = l->next)
658     {
659       EmpathyChatroom *chatroom = l->data;
660
661       if (empathy_chatroom_get_tp_chat (chatroom) != chat)
662         continue;
663
664       empathy_chatroom_set_tp_chat (chatroom, NULL);
665
666       if (!empathy_chatroom_is_favorite (chatroom))
667         {
668           /* Remove the chatroom from the list, unless it's in the list of
669            * favourites..
670            * FIXME this policy should probably not be in libempathy */
671           chatroom_manager_remove_link (manager, l);
672         }
673
674       break;
675     }
676 }
677
678 static void
679 chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
680   EmpathyDispatchOperation *operation, gpointer manager)
681 {
682   EmpathyChatroomManagerPriv *priv = GET_PRIV (manager);
683   EmpathyChatroom *chatroom;
684   TpChannel *channel;
685   EmpathyTpChat *chat;
686   const gchar *roomname;
687   GQuark channel_type;
688   TpHandleType handle_type;
689   McAccount *account;
690   TpConnection *connection;
691
692   channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
693
694   /* Observe Text channels to rooms only */
695   if (channel_type != TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
696     return;
697
698   channel = empathy_dispatch_operation_get_channel (operation);
699   tp_channel_get_handle (channel, &handle_type);
700
701   if (handle_type != TP_HANDLE_TYPE_ROOM)
702     return;
703
704   chat = EMPATHY_TP_CHAT (
705     empathy_dispatch_operation_get_channel_wrapper (operation));
706   connection = empathy_tp_chat_get_connection (chat);
707   account = empathy_account_manager_get_account (priv->account_manager,
708       connection);
709
710   roomname = empathy_tp_chat_get_id (chat);
711
712   chatroom = empathy_chatroom_manager_find (manager, account, roomname);
713
714   if (chatroom == NULL)
715     {
716       chatroom = empathy_chatroom_new_full (account, roomname, roomname,
717         FALSE);
718       empathy_chatroom_set_tp_chat (chatroom, chat);
719       empathy_chatroom_manager_add (manager, chatroom);
720       g_object_unref (chatroom);
721     }
722   else
723     {
724         empathy_chatroom_set_tp_chat (chatroom, chat);
725     }
726
727   /* A TpChat is always destroyed as it only gets unreffed after the channel
728    * has been invalidated in the dispatcher..  */
729   g_signal_connect (chat, "destroy",
730     G_CALLBACK (chatroom_manager_chat_destroyed_cb),
731     manager);
732 }
733
734 void
735 empathy_chatroom_manager_observe (EmpathyChatroomManager *manager,
736   EmpathyDispatcher *dispatcher)
737 {
738   g_signal_connect (dispatcher, "observe",
739     G_CALLBACK (chatroom_manager_observe_channel_cb), manager);
740 }