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