]> git.0d.be Git - empathy.git/blob - libempathy/empathy-utils.c
Add needed empathy.omf.in and set Milo Casagrande as maintainer. seriesid generated...
[empathy.git] / libempathy / empathy-utils.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2003-2007 Imendio AB
4  * Copyright (C) 2007-2008 Collabora Ltd.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  * Authors: Richard Hult <richard@imendio.com>
22  *          Martyn Russell <martyn@imendio.com>
23  *          Xavier Claessens <xclaesse@gmail.com>
24  */
25
26 #include "config.h"
27
28 #include <string.h>
29 #include <time.h>
30 #include <sys/types.h>
31 #include <regex.h>
32
33 #include <glib/gi18n.h>
34
35 #include <libxml/uri.h>
36 #include <telepathy-glib/connection.h>
37 #include <telepathy-glib/channel.h>
38 #include <telepathy-glib/dbus.h>
39
40 #include "empathy-debug.h"
41 #include "empathy-utils.h"
42 #include "empathy-contact-factory.h"
43 #include "empathy-contact-manager.h"
44 #include "empathy-tp-group.h"
45
46 #define DEBUG_DOMAIN "Utils"
47
48 static void regex_init (void);
49
50 gchar *
51 empathy_substring (const gchar *str,
52                   gint         start,
53                   gint         end)
54 {
55         return g_strndup (str + start, end - start);
56 }
57
58 /*
59  * Regular Expression code to match urls.
60  */
61 #define USERCHARS "-A-Za-z0-9"
62 #define PASSCHARS "-A-Za-z0-9,?;.:/!%$^*&~\"#'"
63 #define HOSTCHARS "-A-Za-z0-9_"
64 #define PATHCHARS "-A-Za-z0-9_$.+!*(),;:@&=?/~#%"
65 #define SCHEME    "(news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:)"
66 #define USER      "[" USERCHARS "]+(:["PASSCHARS "]+)?"
67 #define URLPATH   "/[" PATHCHARS "]*[^]'.}>) \t\r\n,\\\"]"
68
69 static regex_t dingus[EMPATHY_REGEX_ALL];
70
71 static void
72 regex_init (void)
73 {
74         static gboolean  inited = FALSE;
75         const gchar     *expression;
76         gint             i;
77
78         if (inited) {
79                 return;
80         }
81
82         for (i = 0; i < EMPATHY_REGEX_ALL; i++) {
83                 switch (i) {
84                 case EMPATHY_REGEX_AS_IS:
85                         expression =
86                                 SCHEME "//(" USER "@)?[" HOSTCHARS ".]+"
87                                 "(:[0-9]+)?(" URLPATH ")?";
88                         break;
89                 case EMPATHY_REGEX_BROWSER:
90                         expression =
91                                 "(www|ftp)[" HOSTCHARS "]*\\.[" HOSTCHARS ".]+"
92                                 "(:[0-9]+)?(" URLPATH ")?";
93                         break;
94                 case EMPATHY_REGEX_EMAIL:
95                         expression =
96                                 "(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9]"
97                                 "[a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+";
98                         break;
99                 case EMPATHY_REGEX_OTHER:
100                         expression =
101                                 "news:[-A-Z\\^_a-z{|}~!\"#$%&'()*+,./0-9;:=?`]+"
102                                 "@[" HOSTCHARS ".]+(:[0-9]+)?";
103                         break;
104                 default:
105                         /* Silence the compiler. */
106                         expression = NULL;
107                         continue;
108                 }
109
110                 memset (&dingus[i], 0, sizeof (regex_t));
111                 regcomp (&dingus[i], expression, REG_EXTENDED | REG_ICASE);
112         }
113
114         inited = TRUE;
115 }
116
117 gint
118 empathy_regex_match (EmpathyRegExType  type,
119                     const gchar     *msg,
120                     GArray          *start,
121                     GArray          *end)
122 {
123         regmatch_t matches[1];
124         gint       ret = 0;
125         gint       num_matches = 0;
126         gint       offset = 0;
127         gint       i;
128
129         g_return_val_if_fail (type >= 0 || type <= EMPATHY_REGEX_ALL, 0);
130
131         regex_init ();
132
133         while (!ret && type != EMPATHY_REGEX_ALL) {
134                 ret = regexec (&dingus[type], msg + offset, 1, matches, 0);
135                 if (ret == 0) {
136                         gint s;
137
138                         num_matches++;
139
140                         s = matches[0].rm_so + offset;
141                         offset = matches[0].rm_eo + offset;
142
143                         g_array_append_val (start, s);
144                         g_array_append_val (end, offset);
145                 }
146         }
147
148         if (type != EMPATHY_REGEX_ALL) {
149                 empathy_debug (DEBUG_DOMAIN,
150                               "Found %d matches for regex type:%d",
151                               num_matches, type);
152                 return num_matches;
153         }
154
155         /* If EMPATHY_REGEX_ALL then we run ALL regex's on the string. */
156         for (i = 0; i < EMPATHY_REGEX_ALL; i++, ret = 0) {
157                 while (!ret) {
158                         ret = regexec (&dingus[i], msg + offset, 1, matches, 0);
159                         if (ret == 0) {
160                                 gint s;
161
162                                 num_matches++;
163
164                                 s = matches[0].rm_so + offset;
165                                 offset = matches[0].rm_eo + offset;
166
167                                 g_array_append_val (start, s);
168                                 g_array_append_val (end, offset);
169                         }
170                 }
171         }
172
173         empathy_debug (DEBUG_DOMAIN,
174                       "Found %d matches for ALL regex types",
175                       num_matches);
176
177         return num_matches;
178 }
179
180 gint
181 empathy_strcasecmp (const gchar *s1,
182                    const gchar *s2)
183 {
184         return empathy_strncasecmp (s1, s2, -1);
185 }
186
187 gint
188 empathy_strncasecmp (const gchar *s1,
189                     const gchar *s2,
190                     gsize        n)
191 {
192         gchar *u1, *u2;
193         gint   ret_val;
194
195         u1 = g_utf8_casefold (s1, n);
196         u2 = g_utf8_casefold (s2, n);
197
198         ret_val = g_utf8_collate (u1, u2);
199         g_free (u1);
200         g_free (u2);
201
202         return ret_val;
203 }
204
205 gboolean
206 empathy_xml_validate (xmlDoc      *doc,
207                      const gchar *dtd_filename)
208 {
209         gchar        *path, *escaped;
210         xmlValidCtxt  cvp;
211         xmlDtd       *dtd;
212         gboolean      ret;
213
214         path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy",
215                                  dtd_filename, NULL);
216         if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
217                 g_free (path);
218                 path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL);
219         }
220         empathy_debug (DEBUG_DOMAIN, "Loading dtd file %s", path);
221
222         /* The list of valid chars is taken from libxml. */
223         escaped = xmlURIEscapeStr (path, ":@&=+$,/?;");
224         g_free (path);
225
226         memset (&cvp, 0, sizeof (cvp));
227         dtd = xmlParseDTD (NULL, escaped);
228         ret = xmlValidateDtd (&cvp, doc, dtd);
229
230         xmlFree (escaped);
231         xmlFreeDtd (dtd);
232
233         return ret;
234 }
235
236 xmlNodePtr
237 empathy_xml_node_get_child (xmlNodePtr   node, 
238                            const gchar *child_name)
239 {
240         xmlNodePtr l;
241
242         g_return_val_if_fail (node != NULL, NULL);
243         g_return_val_if_fail (child_name != NULL, NULL);
244
245         for (l = node->children; l; l = l->next) {
246                 if (l->name && strcmp (l->name, child_name) == 0) {
247                         return l;
248                 }
249         }
250
251         return NULL;
252 }
253
254 xmlChar *
255 empathy_xml_node_get_child_content (xmlNodePtr   node, 
256                                    const gchar *child_name)
257 {
258         xmlNodePtr l;
259
260         g_return_val_if_fail (node != NULL, NULL);
261         g_return_val_if_fail (child_name != NULL, NULL);
262
263         l = empathy_xml_node_get_child (node, child_name);
264         if (l) {
265                 return xmlNodeGetContent (l);
266         }
267                 
268         return NULL;
269 }
270
271 xmlNodePtr
272 empathy_xml_node_find_child_prop_value (xmlNodePtr   node, 
273                                        const gchar *prop_name,
274                                        const gchar *prop_value)
275 {
276         xmlNodePtr l;
277         xmlNodePtr found = NULL;
278
279         g_return_val_if_fail (node != NULL, NULL);
280         g_return_val_if_fail (prop_name != NULL, NULL);
281         g_return_val_if_fail (prop_value != NULL, NULL);
282
283         for (l = node->children; l && !found; l = l->next) {
284                 xmlChar *prop;
285
286                 if (!xmlHasProp (l, prop_name)) {
287                         continue;
288                 }
289
290                 prop = xmlGetProp (l, prop_name);
291                 if (prop && strcmp (prop, prop_value) == 0) {
292                         found = l;
293                 }
294                 
295                 xmlFree (prop);
296         }
297                 
298         return found;
299 }
300
301 guint
302 empathy_account_hash (gconstpointer key)
303 {
304         g_return_val_if_fail (MC_IS_ACCOUNT (key), 0);
305
306         return g_str_hash (mc_account_get_unique_name (MC_ACCOUNT (key)));
307 }
308
309 gboolean
310 empathy_account_equal (gconstpointer a,
311                        gconstpointer b)
312 {
313         const gchar *name_a;
314         const gchar *name_b;
315
316         g_return_val_if_fail (MC_IS_ACCOUNT (a), FALSE);
317         g_return_val_if_fail (MC_IS_ACCOUNT (b), FALSE);
318
319         name_a = mc_account_get_unique_name (MC_ACCOUNT (a));
320         name_b = mc_account_get_unique_name (MC_ACCOUNT (b));
321
322         return g_str_equal (name_a, name_b);
323 }
324
325 MissionControl *
326 empathy_mission_control_new (void)
327 {
328         static MissionControl *mc = NULL;
329
330         if (!mc) {
331                 mc = mission_control_new (tp_get_bus ());
332                 g_object_add_weak_pointer (G_OBJECT (mc), (gpointer) &mc);
333         } else {
334                 g_object_ref (mc);
335         }
336
337         return mc;
338 }
339
340 void
341 empathy_call_with_contact (EmpathyContact *contact)
342 {
343 #ifdef HAVE_VOIP
344         MissionControl        *mc;
345         McAccount             *account;
346         TpConnection          *connection;
347         gchar                 *object_path;
348         TpChannel             *channel;
349         EmpathyContactFactory *factory;
350         EmpathyTpGroup        *group;
351         EmpathyContact        *self_contact;
352         GError                *error = NULL;
353
354         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
355
356         mc = empathy_mission_control_new ();
357         account = empathy_contact_get_account (contact);
358         connection = mission_control_get_tpconnection (mc, account, NULL);
359         tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
360         g_object_unref (mc);
361
362         /* We abuse of suppress_handler, TRUE means OUTGOING. The channel
363          * will be catched in EmpathyFilter */
364         if (!tp_cli_connection_run_request_channel (connection, -1,
365                                                     TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
366                                                     TP_HANDLE_TYPE_NONE,
367                                                     0,
368                                                     TRUE,
369                                                     &object_path,
370                                                     &error,
371                                                     NULL)) {
372                 empathy_debug (DEBUG_DOMAIN, 
373                               "Couldn't request channel: %s",
374                               error ? error->message : "No error given");
375                 g_clear_error (&error);
376                 g_object_unref (connection);
377                 return;
378         }
379
380         channel = tp_channel_new (connection,
381                                   object_path, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
382                                   TP_HANDLE_TYPE_NONE, 0, NULL);
383
384         group = empathy_tp_group_new (channel);
385         empathy_run_until_ready (group);
386
387         factory = empathy_contact_factory_new ();
388         self_contact = empathy_contact_factory_get_user (factory, account);
389         empathy_contact_run_until_ready (self_contact,
390                                          EMPATHY_CONTACT_READY_HANDLE,
391                                          NULL);
392
393         empathy_tp_group_add_member (group, contact, "");
394         empathy_tp_group_add_member (group, self_contact, "");  
395
396         g_object_unref (factory);
397         g_object_unref (self_contact);
398         g_object_unref (group);
399         g_object_unref (connection);
400         g_object_unref (channel);
401         g_free (object_path);
402 #endif
403 }
404
405 void
406 empathy_call_with_contact_id (McAccount *account, const gchar *contact_id)
407 {
408 #ifdef HAVE_VOIP
409         EmpathyContactFactory *factory;
410         EmpathyContact        *contact;
411
412         factory = empathy_contact_factory_new ();
413         contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
414         empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
415
416         empathy_call_with_contact (contact);
417
418         g_object_unref (contact);
419         g_object_unref (factory);
420 #endif
421 }
422
423 void
424 empathy_chat_with_contact (EmpathyContact  *contact)
425 {
426         MissionControl        *mc;
427         McAccount             *account;
428         TpConnection          *connection;
429
430         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
431
432         mc = empathy_mission_control_new ();
433         account = empathy_contact_get_account (contact);
434         connection = mission_control_get_tpconnection (mc, account, NULL);
435         tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
436         g_object_unref (mc);
437
438         /* We abuse of suppress_handler, TRUE means OUTGOING. The channel
439          * will be catched in EmpathyFilter */
440         tp_cli_connection_call_request_channel (connection, -1,
441                                                 TP_IFACE_CHANNEL_TYPE_TEXT,
442                                                 TP_HANDLE_TYPE_CONTACT,
443                                                 empathy_contact_get_handle (contact),
444                                                 TRUE,
445                                                 NULL, NULL, NULL, NULL);
446         g_object_unref (connection);
447 }
448
449 void
450 empathy_chat_with_contact_id (McAccount *account, const gchar *contact_id)
451 {
452         EmpathyContactFactory *factory;
453         EmpathyContact        *contact;
454
455         factory = empathy_contact_factory_new ();
456         contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
457         empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
458
459         empathy_chat_with_contact (contact);
460
461         g_object_unref (contact);
462         g_object_unref (factory);
463 }
464
465 const gchar *
466 empathy_presence_get_default_message (McPresence presence)
467 {
468         switch (presence) {
469         case MC_PRESENCE_AVAILABLE:
470                 return _("Available");
471         case MC_PRESENCE_DO_NOT_DISTURB:
472                 return _("Busy");
473         case MC_PRESENCE_AWAY:
474         case MC_PRESENCE_EXTENDED_AWAY:
475                 return _("Away");
476         case MC_PRESENCE_HIDDEN:
477                 return _("Hidden");
478         case MC_PRESENCE_OFFLINE:
479         case MC_PRESENCE_UNSET:
480                 return _("Offline");
481         default:
482                 g_assert_not_reached ();
483         }
484
485         return NULL;
486 }
487
488 const gchar *
489 empathy_presence_to_str (McPresence presence)
490 {
491         switch (presence) {
492         case MC_PRESENCE_AVAILABLE:
493                 return "available";
494         case MC_PRESENCE_DO_NOT_DISTURB:
495                 return "busy";
496         case MC_PRESENCE_AWAY:
497                 return "away";
498         case MC_PRESENCE_EXTENDED_AWAY:
499                 return "ext_away";
500         case MC_PRESENCE_HIDDEN:
501                 return "hidden";
502         case MC_PRESENCE_OFFLINE:
503                 return "offline";
504         case MC_PRESENCE_UNSET:
505                 return "unset";
506         default:
507                 g_assert_not_reached ();
508         }
509
510         return NULL;
511 }
512
513 McPresence
514 empathy_presence_from_str (const gchar *str)
515 {
516         if (strcmp (str, "available") == 0) {
517                 return MC_PRESENCE_AVAILABLE;
518         } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
519                 return MC_PRESENCE_DO_NOT_DISTURB;
520         } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
521                 return MC_PRESENCE_AWAY;
522         } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) {
523                 return MC_PRESENCE_EXTENDED_AWAY;
524         } else if (strcmp (str, "hidden") == 0) {
525                 return MC_PRESENCE_HIDDEN;
526         } else if (strcmp (str, "offline") == 0) {
527                 return MC_PRESENCE_OFFLINE;
528         } else if (strcmp (str, "unset") == 0) {
529                 return MC_PRESENCE_UNSET;
530         }
531
532         return MC_PRESENCE_AVAILABLE;
533 }
534
535 gchar *
536 empathy_file_lookup (const gchar *filename, const gchar *subdir)
537 {
538         gchar *path;
539
540         if (!subdir) {
541                 subdir = ".";
542         }
543
544         path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), subdir, filename, NULL);
545         if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
546                 g_free (path);
547                 path = g_build_filename (DATADIR, "empathy", filename, NULL);
548         }
549
550         return path;
551 }
552
553 typedef struct {
554         EmpathyRunUntilReadyFunc  func;
555         gpointer                  user_data;
556         GObject                  *object;
557         GMainLoop                *loop;
558 } RunUntilReadyData;
559
560 static void
561 run_until_ready_cb (RunUntilReadyData *data)
562 {
563         if (!data->func || data->func (data->object, data->user_data)) {
564                 empathy_debug (DEBUG_DOMAIN, "Object %p is ready", data->object);
565                 g_main_loop_quit (data->loop);
566         }
567 }
568
569 static gboolean
570 object_is_ready (GObject *object,
571                  gpointer user_data)
572 {
573         gboolean ready;
574
575         g_object_get (object, "ready", &ready, NULL);
576
577         return ready;
578 }
579
580 void
581 empathy_run_until_ready_full (gpointer                  object,
582                               const gchar              *signal,
583                               EmpathyRunUntilReadyFunc  func,
584                               gpointer                  user_data,
585                               GMainLoop               **loop)
586 {
587         RunUntilReadyData  data;
588         gulong             signal_id;
589
590         g_return_if_fail (G_IS_OBJECT (object));
591         g_return_if_fail (signal != NULL);
592
593         if (func && func (object, user_data)) {
594                 return;
595         }
596
597         empathy_debug (DEBUG_DOMAIN, "Starting run until ready for object %p",
598                        object);
599
600         data.func = func;
601         data.user_data = user_data;
602         data.object = object;
603         data.loop = g_main_loop_new (NULL, FALSE);
604
605         signal_id = g_signal_connect_swapped (object, signal,
606                                               G_CALLBACK (run_until_ready_cb),
607                                               &data);
608         if (loop != NULL) {
609                 *loop = data.loop;
610         }
611
612         g_main_loop_run (data.loop);
613
614         if (loop != NULL) {
615                 *loop = NULL;
616         }
617
618         g_signal_handler_disconnect (object, signal_id);
619         g_main_loop_unref (data.loop);
620 }
621
622 void
623 empathy_run_until_ready (gpointer object)
624 {
625         empathy_run_until_ready_full (object, "notify::ready", object_is_ready,
626                                       NULL, NULL);
627 }
628
629 McAccount *
630 empathy_channel_get_account (TpChannel *channel)
631 {
632         TpConnection   *connection;
633         McAccount      *account;
634         MissionControl *mc;
635
636         g_object_get (channel, "connection", &connection, NULL);
637         mc = empathy_mission_control_new ();
638         account = mission_control_get_account_for_tpconnection (mc, connection, NULL);
639         g_object_unref (connection);
640         g_object_unref (mc);
641
642         return account;
643 }
644
645 typedef void (*AccountStatusChangedFunc) (MissionControl           *mc,
646                                           TpConnectionStatus        status,
647                                           McPresence                presence,
648                                           TpConnectionStatusReason  reason,
649                                           const gchar              *unique_name,
650                                           gpointer                  user_data);
651
652 typedef struct {
653         AccountStatusChangedFunc handler;
654         gpointer                 user_data;
655         GClosureNotify           free_func;
656         MissionControl          *mc;
657 } AccountStatusChangedData;
658
659 typedef struct {
660         TpConnectionStatus        status;
661         McPresence                presence;
662         TpConnectionStatusReason  reason;
663         gchar                    *unique_name;
664         AccountStatusChangedData *data;
665 } InvocationData;
666
667 static void
668 account_status_changed_data_free (gpointer ptr,
669                                   GClosure *closure)
670 {
671         AccountStatusChangedData *data = ptr;
672
673         if (data->free_func) {
674                 data->free_func (data->user_data, closure);
675         }
676         g_object_unref (data->mc);
677         g_slice_free (AccountStatusChangedData, data);
678 }
679
680 static gboolean
681 account_status_changed_invoke_callback (gpointer data)
682 {
683         InvocationData *invocation_data = data;
684
685         invocation_data->data->handler (invocation_data->data->mc,
686                                         invocation_data->status,
687                                         invocation_data->presence,
688                                         invocation_data->reason,
689                                         invocation_data->unique_name,
690                                         invocation_data->data->user_data);
691
692         g_free (invocation_data->unique_name);
693         g_slice_free (InvocationData, invocation_data);
694
695         return FALSE;
696 }
697
698 static void
699 account_status_changed_cb (MissionControl           *mc,
700                            TpConnectionStatus        status,
701                            McPresence                presence,
702                            TpConnectionStatusReason  reason,
703                            const gchar              *unique_name,
704                            AccountStatusChangedData *data)
705 {
706         InvocationData *invocation_data;
707
708         invocation_data = g_slice_new (InvocationData);
709         invocation_data->status = status;
710         invocation_data->presence = presence;
711         invocation_data->reason = reason;
712         invocation_data->unique_name = g_strdup (unique_name);
713         invocation_data->data = data;
714
715         g_idle_add_full (G_PRIORITY_HIGH,
716                          account_status_changed_invoke_callback,
717                          invocation_data, NULL);
718 }
719
720 gpointer
721 empathy_connect_to_account_status_changed (MissionControl *mc,
722                                            GCallback       handler,
723                                            gpointer        user_data,
724                                            GClosureNotify  free_func)
725 {
726         AccountStatusChangedData *data;
727
728         g_return_val_if_fail (IS_MISSIONCONTROL (mc), NULL);
729         g_return_val_if_fail (handler != NULL, NULL);
730         
731         data = g_slice_new (AccountStatusChangedData);
732         data->handler = (AccountStatusChangedFunc) handler;
733         data->user_data = user_data;
734         data->free_func = free_func;
735         data->mc = g_object_ref (mc);
736
737         dbus_g_proxy_connect_signal (DBUS_G_PROXY (mc), "AccountStatusChanged",
738                                      G_CALLBACK (account_status_changed_cb),
739                                      data, account_status_changed_data_free);
740
741         return data;
742 }
743
744 void
745 empathy_disconnect_account_status_changed (gpointer token)
746 {
747         AccountStatusChangedData *data = token;
748
749         dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (data->mc),
750                                         "AccountStatusChanged",
751                                         G_CALLBACK (account_status_changed_cb),
752                                         data);
753 }
754