aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorMichael Albinus2010-01-03 20:27:17 +0100
committerMichael Albinus2010-01-03 20:27:17 +0100
commit777013f2bf9f548902c03ffbca0e98507d12ee64 (patch)
tree0fa475092e80faec2f5f90f54f530757099e80ea /src/dbusbind.c
parent798c9eb5600072c2558de7620ad69b06aee46de7 (diff)
downloademacs-777013f2bf9f548902c03ffbca0e98507d12ee64.tar.gz
emacs-777013f2bf9f548902c03ffbca0e98507d12ee64.zip
* dbusbind.c (xd_add_watch): Improve debug message.
(xd_remove_watch): Improve debug message. If DATA is the session bus, unset D-Bus session environment. (Fdbus_init_bus): Pass the bus as argument to dbus_connection_set_watch_functions. (Bug#5283)
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 7c0be49ab77..59702ed93c4 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -761,14 +761,14 @@ xd_add_watch (watch, data)
761 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 761 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
762 { 762 {
763#if HAVE_DBUS_WATCH_GET_UNIX_FD 763#if HAVE_DBUS_WATCH_GET_UNIX_FD
764 /* TODO: Reverse these on Win32, which prefers the opposite. */ 764 /* TODO: Reverse these on Win32, which prefers the opposite. */
765 int fd = dbus_watch_get_unix_fd(watch); 765 int fd = dbus_watch_get_unix_fd(watch);
766 if (fd == -1) 766 if (fd == -1)
767 fd = dbus_watch_get_socket(watch); 767 fd = dbus_watch_get_socket(watch);
768#else 768#else
769 int fd = dbus_watch_get_fd(watch); 769 int fd = dbus_watch_get_fd(watch);
770#endif 770#endif
771 XD_DEBUG_MESSAGE ("%d", fd); 771 XD_DEBUG_MESSAGE ("fd %d", fd);
772 772
773 if (fd == -1) 773 if (fd == -1)
774 return FALSE; 774 return FALSE;
@@ -781,7 +781,8 @@ xd_add_watch (watch, data)
781 return TRUE; 781 return TRUE;
782} 782}
783 783
784/* Remove connection file descriptor from input_wait_mask. */ 784/* Remove connection file descriptor from input_wait_mask. DATA is
785 the used bus, either QCdbus_system_bus or QCdbus_session_bus. */
785void 786void
786xd_remove_watch (watch, data) 787xd_remove_watch (watch, data)
787 DBusWatch *watch; 788 DBusWatch *watch;
@@ -791,18 +792,25 @@ xd_remove_watch (watch, data)
791 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 792 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
792 { 793 {
793#if HAVE_DBUS_WATCH_GET_UNIX_FD 794#if HAVE_DBUS_WATCH_GET_UNIX_FD
794 /* TODO: Reverse these on Win32, which prefers the opposite. */ 795 /* TODO: Reverse these on Win32, which prefers the opposite. */
795 int fd = dbus_watch_get_unix_fd(watch); 796 int fd = dbus_watch_get_unix_fd(watch);
796 if (fd == -1) 797 if (fd == -1)
797 fd = dbus_watch_get_socket(watch); 798 fd = dbus_watch_get_socket(watch);
798#else 799#else
799 int fd = dbus_watch_get_fd(watch); 800 int fd = dbus_watch_get_fd(watch);
800#endif 801#endif
801 XD_DEBUG_MESSAGE ("%d", fd); 802 XD_DEBUG_MESSAGE ("fd %d", fd);
802 803
803 if (fd == -1) 804 if (fd == -1)
804 return; 805 return;
805 806
807 /* Unset session environment. */
808 if ((data != NULL) && (EQ ((Lisp_Object) data, QCdbus_session_bus)))
809 {
810 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
811 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
812 }
813
806 /* Remove the file descriptor from input_wait_mask. */ 814 /* Remove the file descriptor from input_wait_mask. */
807 delete_keyboard_wait_descriptor (fd); 815 delete_keyboard_wait_descriptor (fd);
808 } 816 }
@@ -825,11 +833,12 @@ This is an internal function, it shall not be used outside dbus.el. */)
825 /* Open a connection to the bus. */ 833 /* Open a connection to the bus. */
826 connection = xd_initialize (bus); 834 connection = xd_initialize (bus);
827 835
828 /* Add the watch functions. */ 836 /* Add the watch functions. We pass also the bus as data, in order
837 to distinguish between the busses in xd_remove_watch. */
829 if (!dbus_connection_set_watch_functions (connection, 838 if (!dbus_connection_set_watch_functions (connection,
830 xd_add_watch, 839 xd_add_watch,
831 xd_remove_watch, 840 xd_remove_watch,
832 NULL, NULL, NULL)) 841 NULL, (void *) bus, NULL))
833 XD_SIGNAL1 (build_string ("Cannot add watch functions")); 842 XD_SIGNAL1 (build_string ("Cannot add watch functions"));
834 843
835 /* Return. */ 844 /* Return. */