summaryrefslogtreecommitdiff
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2009-08-15 18:27:58 +0000
committerMichael Albinus <michael.albinus@gmx.de>2009-08-15 18:27:58 +0000
commitf573d5886c10d1312e77c6d7e8bee35b15840d85 (patch)
treea7beec794bc33c0a3d4fb34b4bdd3db615712e6e /src/dbusbind.c
parent17310faf6be67fd1ed79180d328783555d754f15 (diff)
* dbusbind.c (xd_get_dispatch_status, xd_pending_messages): New functions.
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 8100c75439..aa4efa7ca3 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1414,6 +1414,41 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
return Qt;
}
+/* Check, whether there is pending input in the message queue of the
+ D-Bus BUS. BUS is a Lisp symbol, either :system or :session. */
+int
+xd_get_dispatch_status (bus)
+ Lisp_Object bus;
+{
+ DBusConnection *connection;
+
+ /* Open a connection to the bus. */
+ connection = xd_initialize (bus);
+
+ /* Non blocking read of the next available message. */
+ dbus_connection_read_write (connection, 0);
+
+ /* Return. */
+ return
+ (dbus_connection_get_dispatch_status (connection)
+ == DBUS_DISPATCH_DATA_REMAINS)
+ ? TRUE : FALSE;
+}
+
+/* Check for queued incoming messages from the system and session buses. */
+int
+xd_pending_messages ()
+{
+
+ /* Vdbus_registered_functions_table will be initialized as hash
+ table in dbus.el. When this package isn't loaded yet, it doesn't
+ make sense to handle D-Bus messages. */
+ return (HASH_TABLE_P (Vdbus_registered_functions_table)
+ ? ((xd_get_dispatch_status (QCdbus_system_bus)
+ || (xd_get_dispatch_status (QCdbus_session_bus))))
+ : FALSE);
+}
+
/* Read queued incoming message of the D-Bus BUS. BUS is a Lisp
symbol, either :system or :session. */
static Lisp_Object