emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100762: * dbusbind.c (xd_initialize)


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100762: * dbusbind.c (xd_initialize): Add new argument RAISE_ERROR, which
Date: Fri, 09 Jul 2010 11:05:47 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100762
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Fri 2010-07-09 11:05:47 +0200
message:
  * dbusbind.c (xd_initialize): Add new argument RAISE_ERROR, which
  allows to suppress errors when polling in Emacs' main loop.
  (Fdbus_init_bus, Fdbus_get_unique_name, Fdbus_call_method)
  (Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
  (Fdbus_method_error_internal, Fdbus_send_signal)
  (xd_get_dispatch_status, xd_read_message, Fdbus_register_signal)
  (Fdbus_register_method): Use it.  (Bug#6579)
modified:
  src/ChangeLog
  src/dbusbind.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-07-08 21:25:08 +0000
+++ b/src/ChangeLog     2010-07-09 09:05:47 +0000
@@ -1,3 +1,13 @@
+2010-07-09  Michael Albinus  <address@hidden>
+
+       * dbusbind.c (xd_initialize): Add new argument RAISE_ERROR, which
+       allows to suppress errors when polling in Emacs' main loop.
+       (Fdbus_init_bus, Fdbus_get_unique_name, Fdbus_call_method)
+       (Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
+       (Fdbus_method_error_internal, Fdbus_send_signal)
+       (xd_get_dispatch_status, xd_read_message, Fdbus_register_signal)
+       (Fdbus_register_method): Use it.  (Bug#6579)
+
 2010-07-08  Dan Nicolaescu  <address@hidden>
 
        * alloc.c: Convert DEFUNs to standard C.

=== modified file 'src/dbusbind.c'
--- a/src/dbusbind.c    2010-07-08 21:25:08 +0000
+++ b/src/dbusbind.c    2010-07-09 09:05:47 +0000
@@ -714,9 +714,11 @@
 }
 
 /* Initialize D-Bus connection.  BUS is a Lisp symbol, either :system
-   or :session.  It tells which D-Bus to be initialized.  */
+   or :session.  It tells which D-Bus to be initialized.  RAISE_ERROR
+   can be TRUE or FALSE, it controls whether an error is signalled in
+   case the connection cannot be initialized.  */
 static DBusConnection *
-xd_initialize (Lisp_Object bus)
+xd_initialize (Lisp_Object bus, int raise_error)
 {
   DBusConnection *connection;
   DBusError derror;
@@ -724,12 +726,18 @@
   /* Parameter check.  */
   CHECK_SYMBOL (bus);
   if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus)))
-    XD_SIGNAL2 (build_string ("Wrong bus name"), bus);
+    if (raise_error == TRUE)
+      XD_SIGNAL2 (build_string ("Wrong bus name"), bus);
+    else
+      return NULL;
 
   /* We do not want to have an autolaunch for the session bus.  */
   if (EQ (bus, QCdbus_session_bus)
       && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL)
-    XD_SIGNAL2 (build_string ("No connection to bus"), bus);
+    if (raise_error == TRUE)
+      XD_SIGNAL2 (build_string ("No connection to bus"), bus);
+    else
+      return NULL;
 
   /* Open a connection to the bus.  */
   dbus_error_init (&derror);
@@ -740,9 +748,12 @@
     connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
 
   if (dbus_error_is_set (&derror))
-    XD_ERROR (derror);
+    if (raise_error == TRUE)
+      XD_ERROR (derror);
+    else
+      connection = NULL;
 
-  if (connection == NULL)
+  if ((connection == NULL) && (raise_error == TRUE))
     XD_SIGNAL2 (build_string ("No connection to bus"), bus);
 
   /* Cleanup.  */
@@ -829,7 +840,7 @@
   CHECK_SYMBOL (bus);
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Add the watch functions.  We pass also the bus as data, in order
      to distinguish between the busses in xd_remove_watch.  */
@@ -855,7 +866,7 @@
   CHECK_SYMBOL (bus);
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Request the name.  */
   name = dbus_bus_get_unique_name (connection);
@@ -970,7 +981,7 @@
                    SDATA (method));
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Create the message.  */
   dmessage = dbus_message_new_method_call (SDATA (service),
@@ -1153,7 +1164,7 @@
                    SDATA (method));
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Create the message.  */
   dmessage = dbus_message_new_method_call (SDATA (service),
@@ -1268,7 +1279,7 @@
   XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA 
(service));
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Create the message.  */
   dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN);
@@ -1360,7 +1371,7 @@
   XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA 
(service));
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Create the message.  */
   dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
@@ -1483,7 +1494,7 @@
                    SDATA (signal));
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Create the message.  */
   dmessage = dbus_message_new_signal (SDATA (path),
@@ -1548,7 +1559,8 @@
   DBusConnection *connection;
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (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);
@@ -1592,7 +1604,7 @@
   const char *uname, *path, *interface, *member;
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Non blocking read of the next available message.  */
   dbus_connection_read_write (connection, 0);
@@ -1842,7 +1854,7 @@
   if (NILP (uname) || (SBYTES (uname) > 0))
     {
       /* Open a connection to the bus.  */
-      connection = xd_initialize (bus);
+      connection = xd_initialize (bus, TRUE);
 
       /* Create a rule to receive related signals.  */
       sprintf (rule,
@@ -1932,7 +1944,7 @@
      a segmentation fault.  */
 
   /* Open a connection to the bus.  */
-  connection = xd_initialize (bus);
+  connection = xd_initialize (bus, TRUE);
 
   /* Request the known name from the bus.  We can ignore the result,
      it is set to -1 if there is an error - kind of redundancy.  */


reply via email to

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