emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101648: * dbusbind.c (dbus_fd_cb, xd


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101648: * dbusbind.c (dbus_fd_cb, xd_get_dispatch_status)
Date: Mon, 27 Sep 2010 17:34:04 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101648
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Mon 2010-09-27 17:34:04 +0200
message:
  * dbusbind.c (dbus_fd_cb, xd_get_dispatch_status)
  (xd_pending_messages): Functions removed.
  (xd_read_queued_messages): Add parameters fd, *data, for_read in
  order to be compatible with add_read_fd.  Determine bus from data,
  and call xd_read_message just for this bus.
  (xd_add_watch): Use xd_read_queued_messages as callback function.
  Add data.
  
  * lisp.h (xd_pending_messages, xd_read_queued_messages): Remove.
modified:
  src/ChangeLog
  src/dbusbind.c
  src/lisp.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-09-27 15:03:58 +0000
+++ b/src/ChangeLog     2010-09-27 15:34:04 +0000
@@ -1,3 +1,15 @@
+2010-09-27  Michael Albinus  <address@hidden>
+
+       * dbusbind.c (dbus_fd_cb, xd_get_dispatch_status)
+       (xd_pending_messages): Functions removed.
+       (xd_read_queued_messages): Add parameters fd, *data, for_read in
+       order to be compatible with add_read_fd.  Determine bus from data,
+       and call xd_read_message just for this bus.
+       (xd_add_watch): Use xd_read_queued_messages as callback function.
+       Add data.
+
+       * lisp.h (xd_pending_messages, xd_read_queued_messages): Remove.
+
 2010-09-27  Lars Magne Ingebrigtsen  <address@hidden>
 
        * gnutls.c (gnutls_log_function): Added more debugging.

=== modified file 'src/dbusbind.c'
--- a/src/dbusbind.c    2010-09-26 16:20:01 +0000
+++ b/src/dbusbind.c    2010-09-27 15:34:04 +0000
@@ -800,16 +800,7 @@
   return connection;
 }
 
-/* Callback called when something is read to read ow write.  */
-
-static void
-dbus_fd_cb (int fd, void *data, int for_read)
-{
-  xd_read_queued_messages ();
-}
-
 /* Return the file descriptor for WATCH, -1 if not found.  */
-
 static int
 xd_find_watch_fd (DBusWatch *watch)
 {
@@ -824,9 +815,11 @@
   return fd;
 }
 
+/* Prototype.  */
+static void
+xd_read_queued_messages (int fd, void *data, int for_read);
 
 /* Start monitoring WATCH for possible I/O.  */
-
 static dbus_bool_t
 xd_add_watch (DBusWatch *watch, void *data)
 {
@@ -843,9 +836,9 @@
   if (dbus_watch_get_enabled (watch))
     {
       if (flags & DBUS_WATCH_WRITABLE)
-        add_write_fd (fd, dbus_fd_cb, NULL);
+        add_write_fd (fd, xd_read_queued_messages, data);
       if (flags & DBUS_WATCH_READABLE)
-        add_read_fd (fd, dbus_fd_cb, NULL);
+        add_read_fd (fd, xd_read_queued_messages, data);
     }
   return TRUE;
 }
@@ -853,7 +846,6 @@
 /* Stop monitoring WATCH for possible I/O.
    DATA is the used bus, either a string or QCdbus_system_bus or
    QCdbus_session_bus.  */
-
 static void
 xd_remove_watch (DBusWatch *watch, void *data)
 {
@@ -862,8 +854,8 @@
 
   XD_DEBUG_MESSAGE ("fd %d", fd);
 
-  if (fd == -1) return;
-
+  if (fd == -1)
+    return;
 
   /* Unset session environment.  */
   if (data != NULL && data == (void*) XHASH (QCdbus_session_bus))
@@ -879,7 +871,6 @@
 }
 
 /* Toggle monitoring WATCH for possible I/O.  */
-
 static void
 xd_toggle_watch (DBusWatch *watch, void *data)
 {
@@ -1613,54 +1604,9 @@
   return Qt;
 }
 
-/* Check, whether there is pending input in the message queue of the
-   D-Bus BUS.  BUS is either a Lisp symbol, :system or :session, or a
-   string denoting the bus address.  */
-int
-xd_get_dispatch_status (Lisp_Object bus)
-{
-  DBusConnection *connection;
-
-  /* Open a connection to the bus.  */
-  connection = xd_initialize (bus, FALSE);
-  if (connection == NULL) return FALSE;
-
-  /* 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 buses.  */
-int
-xd_pending_messages (void)
-{
-  Lisp_Object busp = Vdbus_registered_buses;
-
-  while (!NILP (busp))
-    {
-      /* We do not want to have an autolaunch for the session bus.  */
-      if (EQ ((CAR_SAFE (busp)), QCdbus_session_bus)
-         && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL)
-       continue;
-
-      if (xd_get_dispatch_status (CAR_SAFE (busp)))
-       return TRUE;
-
-      busp = CDR_SAFE (busp);
-    }
-
-  return FALSE;
-}
-
 /* Read one queued incoming message of the D-Bus BUS.
    BUS is either a Lisp symbol, :system or :session, or a string denoting
    the bus address.  */
-
 static void
 xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
 {
@@ -1814,7 +1760,6 @@
 /* Read queued incoming messages of the D-Bus BUS.
    BUS is either a Lisp symbol, :system or :session, or a string denoting
    the bus address.  */
-
 static Lisp_Object
 xd_read_message (Lisp_Object bus)
 {
@@ -1830,19 +1775,28 @@
   return Qnil;
 }
 
-/* Read queued incoming messages from all buses.  */
-void
-xd_read_queued_messages (void)
+/* Callback called when something is ready to read or write.  */
+static void
+xd_read_queued_messages (int fd, void *data, int for_read)
 {
   Lisp_Object busp = Vdbus_registered_buses;
-
+  Lisp_Object bus = Qnil;
+
+  /* Find bus related to fd.  */
+  if (data != NULL)
+    while (!NILP (busp))
+      {
+       if (data == (void*) XHASH (CAR_SAFE (busp)))
+         bus = CAR_SAFE (busp);
+       busp = CDR_SAFE (busp);
+      }
+
+  if (NILP(bus))
+    return;
+
+  /* We ignore all Lisp errors during the call.  */
   xd_in_read_queued_messages = 1;
-  while (!NILP (busp))
-    {
-      /* We ignore all Lisp errors during the call.  */
-      internal_catch (Qdbus_error, xd_read_message, CAR_SAFE (busp));
-      busp = CDR_SAFE (busp);
-    }
+  internal_catch (Qdbus_error, xd_read_message, bus);
   xd_in_read_queued_messages = 0;
 }
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2010-09-25 09:36:36 +0000
+++ b/src/lisp.h        2010-09-27 15:34:04 +0000
@@ -3593,8 +3593,6 @@
 
 #ifdef HAVE_DBUS
 /* Defined in dbusbind.c */
-int xd_pending_messages (void);
-void xd_read_queued_messages (void);
 void syms_of_dbusbind (void);
 #endif
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]