diff options
| author | Michael Albinus | 2009-08-18 15:17:02 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-08-18 15:17:02 +0000 |
| commit | 058ed8610c6c4c64b9bebfb7ef9283ff022b5b76 (patch) | |
| tree | c919d99a3a5d2da25f5390dc36674e2264cba743 /src/dbusbind.c | |
| parent | ba6f7d8640de1f191bee882de5bc029883a901b5 (diff) | |
| download | emacs-058ed8610c6c4c64b9bebfb7ef9283ff022b5b76.tar.gz emacs-058ed8610c6c4c64b9bebfb7ef9283ff022b5b76.zip | |
* dbusbind.c (xd_add_watch, xd_remove_watch, Fdbus_init_bus): New
functions.
(xd_initialize): Revert change from 2009-08-16.
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 88 |
1 files changed, 82 insertions, 6 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 76b0da54205..33a070014f8 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | /* Subroutines. */ | 31 | /* Subroutines. */ |
| 32 | Lisp_Object Qdbus_init_bus; | ||
| 32 | Lisp_Object Qdbus_get_unique_name; | 33 | Lisp_Object Qdbus_get_unique_name; |
| 33 | Lisp_Object Qdbus_call_method; | 34 | Lisp_Object Qdbus_call_method; |
| 34 | Lisp_Object Qdbus_call_method_asynchronously; | 35 | Lisp_Object Qdbus_call_method_asynchronously; |
| @@ -698,7 +699,6 @@ xd_initialize (bus) | |||
| 698 | { | 699 | { |
| 699 | DBusConnection *connection; | 700 | DBusConnection *connection; |
| 700 | DBusError derror; | 701 | DBusError derror; |
| 701 | int fd; | ||
| 702 | 702 | ||
| 703 | /* Parameter check. */ | 703 | /* Parameter check. */ |
| 704 | CHECK_SYMBOL (bus); | 704 | CHECK_SYMBOL (bus); |
| @@ -719,11 +719,6 @@ xd_initialize (bus) | |||
| 719 | if (connection == NULL) | 719 | if (connection == NULL) |
| 720 | XD_SIGNAL2 (build_string ("No connection"), bus); | 720 | XD_SIGNAL2 (build_string ("No connection"), bus); |
| 721 | 721 | ||
| 722 | /* Add connection file descriptor to input_wait_mask, in order to | ||
| 723 | let select() detect, whether a new message has been arrived. */ | ||
| 724 | if (dbus_connection_get_unix_fd (connection, &fd)) | ||
| 725 | add_keyboard_wait_descriptor (fd); | ||
| 726 | |||
| 727 | /* Cleanup. */ | 722 | /* Cleanup. */ |
| 728 | dbus_error_free (&derror); | 723 | dbus_error_free (&derror); |
| 729 | 724 | ||
| @@ -731,6 +726,83 @@ xd_initialize (bus) | |||
| 731 | return connection; | 726 | return connection; |
| 732 | } | 727 | } |
| 733 | 728 | ||
| 729 | |||
| 730 | /* Add connection file descriptor to input_wait_mask, in order to | ||
| 731 | let select() detect, whether a new message has been arrived. */ | ||
| 732 | dbus_bool_t | ||
| 733 | xd_add_watch (watch, data) | ||
| 734 | DBusWatch *watch; | ||
| 735 | void *data; | ||
| 736 | { | ||
| 737 | /* We check only for incoming data. */ | ||
| 738 | if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) | ||
| 739 | { | ||
| 740 | /* TODO: Reverse these on Win32, which prefers the opposite. */ | ||
| 741 | int fd = dbus_watch_get_unix_fd(watch); | ||
| 742 | if (fd == -1) | ||
| 743 | fd = dbus_watch_get_socket(watch); | ||
| 744 | if (fd == -1) | ||
| 745 | return FALSE; | ||
| 746 | |||
| 747 | //printf ("xd_add_watch: %d\n", fd); | ||
| 748 | /* Add the file descriptor to input_wait_mask. */ | ||
| 749 | add_keyboard_wait_descriptor (fd); | ||
| 750 | } | ||
| 751 | |||
| 752 | /* Return. */ | ||
| 753 | return TRUE; | ||
| 754 | } | ||
| 755 | |||
| 756 | /* Remove connection file descriptor from input_wait_mask. */ | ||
| 757 | void | ||
| 758 | xd_remove_watch (watch, data) | ||
| 759 | DBusWatch *watch; | ||
| 760 | void *data; | ||
| 761 | { | ||
| 762 | /* We check only for incoming data. */ | ||
| 763 | if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) | ||
| 764 | { | ||
| 765 | /* TODO: Reverse these on Win32, which prefers the opposite. */ | ||
| 766 | int fd = dbus_watch_get_unix_fd(watch); | ||
| 767 | if (fd == -1) | ||
| 768 | fd = dbus_watch_get_socket(watch); | ||
| 769 | if (fd == -1) | ||
| 770 | return; | ||
| 771 | |||
| 772 | //printf ("xd_remove_watch: %d\n", fd); | ||
| 773 | /* Remove the file descriptor from input_wait_mask. */ | ||
| 774 | delete_keyboard_wait_descriptor (fd); | ||
| 775 | } | ||
| 776 | |||
| 777 | /* Return. */ | ||
| 778 | return; | ||
| 779 | } | ||
| 780 | |||
| 781 | DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, | ||
| 782 | doc: /* Initialize connection to D-Bus BUS. | ||
| 783 | This is an internal function, it shall not be used outside dbus.el. */) | ||
| 784 | (bus) | ||
| 785 | Lisp_Object bus; | ||
| 786 | { | ||
| 787 | DBusConnection *connection; | ||
| 788 | |||
| 789 | /* Check parameters. */ | ||
| 790 | CHECK_SYMBOL (bus); | ||
| 791 | |||
| 792 | /* Open a connection to the bus. */ | ||
| 793 | connection = xd_initialize (bus); | ||
| 794 | |||
| 795 | /* Add the watch functions. */ | ||
| 796 | if (!dbus_connection_set_watch_functions (connection, | ||
| 797 | xd_add_watch, | ||
| 798 | xd_remove_watch, | ||
| 799 | NULL, NULL, NULL)) | ||
| 800 | XD_SIGNAL1 (build_string ("Cannot add watch functions")); | ||
| 801 | |||
| 802 | /* Return. */ | ||
| 803 | return Qnil; | ||
| 804 | } | ||
| 805 | |||
| 734 | DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, | 806 | DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, |
| 735 | 1, 1, 0, | 807 | 1, 1, 0, |
| 736 | doc: /* Return the unique name of Emacs registered at D-Bus BUS. */) | 808 | doc: /* Return the unique name of Emacs registered at D-Bus BUS. */) |
| @@ -1865,6 +1937,10 @@ void | |||
| 1865 | syms_of_dbusbind () | 1937 | syms_of_dbusbind () |
| 1866 | { | 1938 | { |
| 1867 | 1939 | ||
| 1940 | Qdbus_init_bus = intern ("dbus-init-bus"); | ||
| 1941 | staticpro (&Qdbus_init_bus); | ||
| 1942 | defsubr (&Sdbus_init_bus); | ||
| 1943 | |||
| 1868 | Qdbus_get_unique_name = intern ("dbus-get-unique-name"); | 1944 | Qdbus_get_unique_name = intern ("dbus-get-unique-name"); |
| 1869 | staticpro (&Qdbus_get_unique_name); | 1945 | staticpro (&Qdbus_get_unique_name); |
| 1870 | defsubr (&Sdbus_get_unique_name); | 1946 | defsubr (&Sdbus_get_unique_name); |