comparison src/dbusbind.c @ 109126:aec1143e8d85

Convert (most) functions in src to standard C. * src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 04 Jul 2010 00:50:25 -0700
parents d418516def73
children 8cfee7d2955f
comparison
equal deleted inserted replaced
109125:12b02558bf51 109126:aec1143e8d85
161 hours, when optimzation is enabled. So we have transferred it into 161 hours, when optimzation is enabled. So we have transferred it into
162 a function. */ 162 a function. */
163 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one 163 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one
164 of the predefined D-Bus type symbols. */ 164 of the predefined D-Bus type symbols. */
165 static int 165 static int
166 xd_symbol_to_dbus_type (object) 166 xd_symbol_to_dbus_type (Lisp_Object object)
167 Lisp_Object object;
168 { 167 {
169 return 168 return
170 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE 169 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE
171 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN 170 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN
172 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 171 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16
219 cannot be detected in basic type objects, when they are preceded by 218 cannot be detected in basic type objects, when they are preceded by
220 a type symbol. PARENT_TYPE is the DBusType of a container this 219 a type symbol. PARENT_TYPE is the DBusType of a container this
221 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the 220 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the
222 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ 221 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */
223 static void 222 static void
224 xd_signature (signature, dtype, parent_type, object) 223 xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lisp_Object object)
225 char *signature;
226 unsigned int dtype, parent_type;
227 Lisp_Object object;
228 { 224 {
229 unsigned int subtype; 225 unsigned int subtype;
230 Lisp_Object elt; 226 Lisp_Object elt;
231 char x[DBUS_MAXIMUM_SIGNATURE_LENGTH]; 227 char x[DBUS_MAXIMUM_SIGNATURE_LENGTH];
232 228
391 DTYPE must be a valid DBusType. It is used to convert Lisp 387 DTYPE must be a valid DBusType. It is used to convert Lisp
392 objects, being arguments of `dbus-call-method' or 388 objects, being arguments of `dbus-call-method' or
393 `dbus-send-signal', into corresponding C values appended as 389 `dbus-send-signal', into corresponding C values appended as
394 arguments to a D-Bus message. */ 390 arguments to a D-Bus message. */
395 static void 391 static void
396 xd_append_arg (dtype, object, iter) 392 xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter)
397 unsigned int dtype;
398 Lisp_Object object;
399 DBusMessageIter *iter;
400 { 393 {
401 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; 394 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
402 DBusMessageIter subiter; 395 DBusMessageIter subiter;
403 396
404 if (XD_BASIC_DBUS_TYPE (dtype)) 397 if (XD_BASIC_DBUS_TYPE (dtype))
602 /* Retrieve C value from a DBusMessageIter structure ITER, and return 595 /* Retrieve C value from a DBusMessageIter structure ITER, and return
603 a converted Lisp object. The type DTYPE of the argument of the 596 a converted Lisp object. The type DTYPE of the argument of the
604 D-Bus message must be a valid DBusType. Compound D-Bus types 597 D-Bus message must be a valid DBusType. Compound D-Bus types
605 result always in a Lisp list. */ 598 result always in a Lisp list. */
606 static Lisp_Object 599 static Lisp_Object
607 xd_retrieve_arg (dtype, iter) 600 xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter)
608 unsigned int dtype;
609 DBusMessageIter *iter;
610 { 601 {
611 602
612 switch (dtype) 603 switch (dtype)
613 { 604 {
614 case DBUS_TYPE_BYTE: 605 case DBUS_TYPE_BYTE:
723 } 714 }
724 715
725 /* Initialize D-Bus connection. BUS is a Lisp symbol, either :system 716 /* Initialize D-Bus connection. BUS is a Lisp symbol, either :system
726 or :session. It tells which D-Bus to be initialized. */ 717 or :session. It tells which D-Bus to be initialized. */
727 static DBusConnection * 718 static DBusConnection *
728 xd_initialize (bus) 719 xd_initialize (Lisp_Object bus)
729 Lisp_Object bus;
730 { 720 {
731 DBusConnection *connection; 721 DBusConnection *connection;
732 DBusError derror; 722 DBusError derror;
733 723
734 /* Parameter check. */ 724 /* Parameter check. */
764 754
765 755
766 /* Add connection file descriptor to input_wait_mask, in order to 756 /* Add connection file descriptor to input_wait_mask, in order to
767 let select() detect, whether a new message has been arrived. */ 757 let select() detect, whether a new message has been arrived. */
768 dbus_bool_t 758 dbus_bool_t
769 xd_add_watch (watch, data) 759 xd_add_watch (DBusWatch *watch, void *data)
770 DBusWatch *watch;
771 void *data;
772 { 760 {
773 /* We check only for incoming data. */ 761 /* We check only for incoming data. */
774 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 762 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
775 { 763 {
776 #if HAVE_DBUS_WATCH_GET_UNIX_FD 764 #if HAVE_DBUS_WATCH_GET_UNIX_FD
795 } 783 }
796 784
797 /* Remove connection file descriptor from input_wait_mask. DATA is 785 /* Remove connection file descriptor from input_wait_mask. DATA is
798 the used bus, either QCdbus_system_bus or QCdbus_session_bus. */ 786 the used bus, either QCdbus_system_bus or QCdbus_session_bus. */
799 void 787 void
800 xd_remove_watch (watch, data) 788 xd_remove_watch (DBusWatch *watch, void *data)
801 DBusWatch *watch;
802 void *data;
803 { 789 {
804 /* We check only for incoming data. */ 790 /* We check only for incoming data. */
805 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 791 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
806 { 792 {
807 #if HAVE_DBUS_WATCH_GET_UNIX_FD 793 #if HAVE_DBUS_WATCH_GET_UNIX_FD
1567 } 1553 }
1568 1554
1569 /* Check, whether there is pending input in the message queue of the 1555 /* Check, whether there is pending input in the message queue of the
1570 D-Bus BUS. BUS is a Lisp symbol, either :system or :session. */ 1556 D-Bus BUS. BUS is a Lisp symbol, either :system or :session. */
1571 int 1557 int
1572 xd_get_dispatch_status (bus) 1558 xd_get_dispatch_status (Lisp_Object bus)
1573 Lisp_Object bus;
1574 { 1559 {
1575 DBusConnection *connection; 1560 DBusConnection *connection;
1576 1561
1577 /* Open a connection to the bus. */ 1562 /* Open a connection to the bus. */
1578 connection = xd_initialize (bus); 1563 connection = xd_initialize (bus);
1587 ? TRUE : FALSE; 1572 ? TRUE : FALSE;
1588 } 1573 }
1589 1574
1590 /* Check for queued incoming messages from the system and session buses. */ 1575 /* Check for queued incoming messages from the system and session buses. */
1591 int 1576 int
1592 xd_pending_messages () 1577 xd_pending_messages (void)
1593 { 1578 {
1594 1579
1595 /* Vdbus_registered_objects_table will be initialized as hash table 1580 /* Vdbus_registered_objects_table will be initialized as hash table
1596 in dbus.el. When this package isn't loaded yet, it doesn't make 1581 in dbus.el. When this package isn't loaded yet, it doesn't make
1597 sense to handle D-Bus messages. */ 1582 sense to handle D-Bus messages. */
1604 } 1589 }
1605 1590
1606 /* Read queued incoming message of the D-Bus BUS. BUS is a Lisp 1591 /* Read queued incoming message of the D-Bus BUS. BUS is a Lisp
1607 symbol, either :system or :session. */ 1592 symbol, either :system or :session. */
1608 static Lisp_Object 1593 static Lisp_Object
1609 xd_read_message (bus) 1594 xd_read_message (Lisp_Object bus)
1610 Lisp_Object bus;
1611 { 1595 {
1612 Lisp_Object args, key, value; 1596 Lisp_Object args, key, value;
1613 struct gcpro gcpro1; 1597 struct gcpro gcpro1;
1614 struct input_event event; 1598 struct input_event event;
1615 DBusConnection *connection; 1599 DBusConnection *connection;
1762 RETURN_UNGCPRO (Qnil); 1746 RETURN_UNGCPRO (Qnil);
1763 } 1747 }
1764 1748
1765 /* Read queued incoming messages from the system and session buses. */ 1749 /* Read queued incoming messages from the system and session buses. */
1766 void 1750 void
1767 xd_read_queued_messages () 1751 xd_read_queued_messages (void)
1768 { 1752 {
1769 1753
1770 /* Vdbus_registered_objects_table will be initialized as hash table 1754 /* Vdbus_registered_objects_table will be initialized as hash table
1771 in dbus.el. When this package isn't loaded yet, it doesn't make 1755 in dbus.el. When this package isn't loaded yet, it doesn't make
1772 sense to handle D-Bus messages. Furthermore, we ignore all Lisp 1756 sense to handle D-Bus messages. Furthermore, we ignore all Lisp
1988 return list2 (key, list3 (service, path, handler)); 1972 return list2 (key, list3 (service, path, handler));
1989 } 1973 }
1990 1974
1991 1975
1992 void 1976 void
1993 syms_of_dbusbind () 1977 syms_of_dbusbind (void)
1994 { 1978 {
1995 1979
1996 Qdbus_init_bus = intern_c_string ("dbus-init-bus"); 1980 Qdbus_init_bus = intern_c_string ("dbus-init-bus");
1997 staticpro (&Qdbus_init_bus); 1981 staticpro (&Qdbus_init_bus);
1998 defsubr (&Sdbus_init_bus); 1982 defsubr (&Sdbus_init_bus);