aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2009-08-20 12:54:57 +0000
committerMichael Albinus2009-08-20 12:54:57 +0000
commit3f56d3c665c4d63064832628d110f646781c6353 (patch)
tree2d73209a559a7233ae5755a629c22089da5b5f41 /src
parentfb641d684f106ce60b98181b38d5d167156287f3 (diff)
downloademacs-3f56d3c665c4d63064832628d110f646781c6353.tar.gz
emacs-3f56d3c665c4d63064832628d110f646781c6353.zip
* dbusbind.c (XD_WITH_DBUS_WATCH_GET_UNIX_FD): New macro.
(xd_add_watch, xd_remove_watch): Use it. Print debug messages. (xd_initialize, xd_pending_messages): Check, whether $DBUS_SESSION_BUS_ADDRESS is set.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/dbusbind.c39
2 files changed, 40 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e04d71b921d..a6fd2b35233 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12009-08-20 Michael Albinus <michael.albinus@gmx.de>
2
3 * dbusbind.c (XD_WITH_DBUS_WATCH_GET_UNIX_FD): New macro.
4 (xd_add_watch, xd_remove_watch): Use it. Print debug messages.
5 (xd_initialize, xd_pending_messages): Check, whether
6 $DBUS_SESSION_BUS_ADDRESS is set.
7
12009-08-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 82009-08-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 9
3 * nsfns.m (Fxw_color_values): Return 3-element list. Doc fix. 10 * nsfns.m (Fxw_color_values): Return 3-element list. Doc fix.
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 33a070014f8..38912e5f51b 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -71,6 +71,16 @@ int xd_in_read_queued_messages = 0;
71/* We use "xd_" and "XD_" as prefix for all internal symbols, because 71/* We use "xd_" and "XD_" as prefix for all internal symbols, because
72 we don't want to poison other namespaces with "dbus_". */ 72 we don't want to poison other namespaces with "dbus_". */
73 73
74/* Since D-Bus 1.1.1, dbus_watch_get_fd() was replaced by
75 dbus_watch_get_unix_fd and dbus_watch_get_socket. We must check
76 this. */
77#ifdef DBUS_VERSION
78#define XD_WITH_DBUS_WATCH_GET_UNIX_FD \
79 ((1 << 16) | (1 << 8) | (1)) <= DBUS_VERSION
80#else
81#define XD_WITH_DBUS_WATCH_GET_UNIX_FD 0
82#endif
83
74/* Raise a signal. If we are reading events, we cannot signal; we 84/* Raise a signal. If we are reading events, we cannot signal; we
75 throw to xd_read_queued_messages then. */ 85 throw to xd_read_queued_messages then. */
76#define XD_SIGNAL1(arg) \ 86#define XD_SIGNAL1(arg) \
@@ -702,9 +712,14 @@ xd_initialize (bus)
702 712
703 /* Parameter check. */ 713 /* Parameter check. */
704 CHECK_SYMBOL (bus); 714 CHECK_SYMBOL (bus);
705 if (!((EQ (bus, QCdbus_system_bus)) || (EQ (bus, QCdbus_session_bus)))) 715 if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus)))
706 XD_SIGNAL2 (build_string ("Wrong bus name"), bus); 716 XD_SIGNAL2 (build_string ("Wrong bus name"), bus);
707 717
718 /* We do not want to have an autolaunch for the session bus. */
719 if (EQ (bus, QCdbus_session_bus)
720 && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL)
721 XD_SIGNAL2 (build_string ("No connection to bus"), bus);
722
708 /* Open a connection to the bus. */ 723 /* Open a connection to the bus. */
709 dbus_error_init (&derror); 724 dbus_error_init (&derror);
710 725
@@ -717,7 +732,7 @@ xd_initialize (bus)
717 XD_ERROR (derror); 732 XD_ERROR (derror);
718 733
719 if (connection == NULL) 734 if (connection == NULL)
720 XD_SIGNAL2 (build_string ("No connection"), bus); 735 XD_SIGNAL2 (build_string ("No connection to bus"), bus);
721 736
722 /* Cleanup. */ 737 /* Cleanup. */
723 dbus_error_free (&derror); 738 dbus_error_free (&derror);
@@ -737,14 +752,19 @@ xd_add_watch (watch, data)
737 /* We check only for incoming data. */ 752 /* We check only for incoming data. */
738 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 753 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
739 { 754 {
755#if XD_WITH_DBUS_WATCH_GET_UNIX_FD
740 /* TODO: Reverse these on Win32, which prefers the opposite. */ 756 /* TODO: Reverse these on Win32, which prefers the opposite. */
741 int fd = dbus_watch_get_unix_fd(watch); 757 int fd = dbus_watch_get_unix_fd(watch);
742 if (fd == -1) 758 if (fd == -1)
743 fd = dbus_watch_get_socket(watch); 759 fd = dbus_watch_get_socket(watch);
760#else
761 int fd = dbus_watch_get_fd(watch);
762#endif
763 XD_DEBUG_MESSAGE ("%d", fd);
764
744 if (fd == -1) 765 if (fd == -1)
745 return FALSE; 766 return FALSE;
746 767
747 //printf ("xd_add_watch: %d\n", fd);
748 /* Add the file descriptor to input_wait_mask. */ 768 /* Add the file descriptor to input_wait_mask. */
749 add_keyboard_wait_descriptor (fd); 769 add_keyboard_wait_descriptor (fd);
750 } 770 }
@@ -762,14 +782,19 @@ xd_remove_watch (watch, data)
762 /* We check only for incoming data. */ 782 /* We check only for incoming data. */
763 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 783 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
764 { 784 {
785#if XD_WITH_DBUS_WATCH_GET_UNIX_FD
765 /* TODO: Reverse these on Win32, which prefers the opposite. */ 786 /* TODO: Reverse these on Win32, which prefers the opposite. */
766 int fd = dbus_watch_get_unix_fd(watch); 787 int fd = dbus_watch_get_unix_fd(watch);
767 if (fd == -1) 788 if (fd == -1)
768 fd = dbus_watch_get_socket(watch); 789 fd = dbus_watch_get_socket(watch);
790#else
791 int fd = dbus_watch_get_fd(watch);
792#endif
793 XD_DEBUG_MESSAGE ("%d", fd);
794
769 if (fd == -1) 795 if (fd == -1)
770 return; 796 return;
771 797
772 //printf ("xd_remove_watch: %d\n", fd);
773 /* Remove the file descriptor from input_wait_mask. */ 798 /* Remove the file descriptor from input_wait_mask. */
774 delete_keyboard_wait_descriptor (fd); 799 delete_keyboard_wait_descriptor (fd);
775 } 800 }
@@ -1541,8 +1566,10 @@ xd_pending_messages ()
1541 table in dbus.el. When this package isn't loaded yet, it doesn't 1566 table in dbus.el. When this package isn't loaded yet, it doesn't
1542 make sense to handle D-Bus messages. */ 1567 make sense to handle D-Bus messages. */
1543 return (HASH_TABLE_P (Vdbus_registered_functions_table) 1568 return (HASH_TABLE_P (Vdbus_registered_functions_table)
1544 ? ((xd_get_dispatch_status (QCdbus_system_bus) 1569 ? (xd_get_dispatch_status (QCdbus_system_bus)
1545 || (xd_get_dispatch_status (QCdbus_session_bus)))) 1570 || ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL)
1571 ? xd_get_dispatch_status (QCdbus_session_bus)
1572 : FALSE))
1546 : FALSE); 1573 : FALSE);
1547} 1574}
1548 1575