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