Blob Blame Raw
From 8fe656de630e851bc512bbd7e7a6c18c53aecb61 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Mon, 14 Apr 2008 12:56:43 +0100
Subject: [PATCH] Freeze error ABI at the ABI used in Fedora 8 and Ubuntu gutsy.

This avoids getting a different ABI depending on the version of libdbus
we're compiled against. fd.o #15430, Debian #476080.
---
 dbus/dbus-glib.h                    |   34 ++++++++++++++++-
 dbus/dbus-gobject.c                 |   72 ++++++++++++++++++++++++++++++++++-
 dbus/make-dbus-glib-error-enum.sh   |   25 +------------
 dbus/make-dbus-glib-error-switch.sh |   29 +-------------
 4 files changed, 106 insertions(+), 54 deletions(-)

diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
index b1084ba..c4049f3 100644
--- a/dbus/dbus-glib.h
+++ b/dbus/dbus-glib.h
@@ -60,7 +60,39 @@ GQuark dbus_g_error_quark (void);
 
 typedef enum
 {
-#include "dbus-glib-error-enum.h" 
+DBUS_GERROR_FAILED,
+DBUS_GERROR_NO_MEMORY,
+DBUS_GERROR_SERVICE_UNKNOWN,
+DBUS_GERROR_NAME_HAS_NO_OWNER,
+DBUS_GERROR_NO_REPLY,
+DBUS_GERROR_IO_ERROR,
+DBUS_GERROR_BAD_ADDRESS,
+DBUS_GERROR_NOT_SUPPORTED,
+DBUS_GERROR_LIMITS_EXCEEDED,
+DBUS_GERROR_ACCESS_DENIED,
+DBUS_GERROR_AUTH_FAILED,
+DBUS_GERROR_NO_SERVER,
+DBUS_GERROR_TIMEOUT,
+DBUS_GERROR_NO_NETWORK,
+DBUS_GERROR_ADDRESS_IN_USE,
+DBUS_GERROR_DISCONNECTED,
+DBUS_GERROR_INVALID_ARGS,
+DBUS_GERROR_FILE_NOT_FOUND,
+DBUS_GERROR_FILE_EXISTS,
+DBUS_GERROR_UNKNOWN_METHOD,
+DBUS_GERROR_TIMED_OUT,
+DBUS_GERROR_MATCH_RULE_NOT_FOUND,
+DBUS_GERROR_MATCH_RULE_INVALID,
+DBUS_GERROR_SPAWN_EXEC_FAILED,
+DBUS_GERROR_SPAWN_FORK_FAILED,
+DBUS_GERROR_SPAWN_CHILD_EXITED,
+DBUS_GERROR_SPAWN_CHILD_SIGNALED,
+DBUS_GERROR_SPAWN_FAILED,
+DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN,
+DBUS_GERROR_INVALID_SIGNATURE,
+DBUS_GERROR_INVALID_FILE_CONTENT,
+DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
+DBUS_GERROR_REMOTE_EXCEPTION
 } DBusGError;
 
 gboolean         dbus_g_error_has_name    (GError      *error,
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index dae2dac..6596309 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -1668,7 +1668,77 @@ export_signals (DBusGConnection *connection, const GList *info_list, GObject *ob
     }
 }
 
-#include "dbus-glib-error-switch.h"
+static gint
+dbus_error_to_gerror_code (const char *derr)
+{
+  if (0) ; 
+  else if (!strcmp (derr,  DBUS_ERROR_FAILED  )) 
+    return  DBUS_GERROR_FAILED ;
+  else if (!strcmp (derr,  DBUS_ERROR_NO_MEMORY  )) 
+    return  DBUS_GERROR_NO_MEMORY ;
+  else if (!strcmp (derr,  DBUS_ERROR_SERVICE_UNKNOWN  )) 
+    return  DBUS_GERROR_SERVICE_UNKNOWN ;
+  else if (!strcmp (derr,  DBUS_ERROR_NAME_HAS_NO_OWNER  )) 
+    return  DBUS_GERROR_NAME_HAS_NO_OWNER ;
+  else if (!strcmp (derr,  DBUS_ERROR_NO_REPLY  )) 
+    return  DBUS_GERROR_NO_REPLY ;
+  else if (!strcmp (derr,  DBUS_ERROR_IO_ERROR  )) 
+    return  DBUS_GERROR_IO_ERROR ;
+  else if (!strcmp (derr,  DBUS_ERROR_BAD_ADDRESS  )) 
+    return  DBUS_GERROR_BAD_ADDRESS ;
+  else if (!strcmp (derr,  DBUS_ERROR_NOT_SUPPORTED  )) 
+    return  DBUS_GERROR_NOT_SUPPORTED ;
+  else if (!strcmp (derr,  DBUS_ERROR_LIMITS_EXCEEDED  )) 
+    return  DBUS_GERROR_LIMITS_EXCEEDED ;
+  else if (!strcmp (derr,  DBUS_ERROR_ACCESS_DENIED  )) 
+    return  DBUS_GERROR_ACCESS_DENIED ;
+  else if (!strcmp (derr,  DBUS_ERROR_AUTH_FAILED  )) 
+    return  DBUS_GERROR_AUTH_FAILED ;
+  else if (!strcmp (derr,  DBUS_ERROR_NO_SERVER  )) 
+    return  DBUS_GERROR_NO_SERVER ;
+  else if (!strcmp (derr,  DBUS_ERROR_TIMEOUT  )) 
+    return  DBUS_GERROR_TIMEOUT ;
+  else if (!strcmp (derr,  DBUS_ERROR_NO_NETWORK  )) 
+    return  DBUS_GERROR_NO_NETWORK ;
+  else if (!strcmp (derr,  DBUS_ERROR_ADDRESS_IN_USE  )) 
+    return  DBUS_GERROR_ADDRESS_IN_USE ;
+  else if (!strcmp (derr,  DBUS_ERROR_DISCONNECTED  )) 
+    return  DBUS_GERROR_DISCONNECTED ;
+  else if (!strcmp (derr,  DBUS_ERROR_INVALID_ARGS  )) 
+    return  DBUS_GERROR_INVALID_ARGS ;
+  else if (!strcmp (derr,  DBUS_ERROR_FILE_NOT_FOUND  )) 
+    return  DBUS_GERROR_FILE_NOT_FOUND ;
+  else if (!strcmp (derr,  DBUS_ERROR_FILE_EXISTS  )) 
+    return  DBUS_GERROR_FILE_EXISTS ;
+  else if (!strcmp (derr,  DBUS_ERROR_UNKNOWN_METHOD  )) 
+    return  DBUS_GERROR_UNKNOWN_METHOD ;
+  else if (!strcmp (derr,  DBUS_ERROR_TIMED_OUT  )) 
+    return  DBUS_GERROR_TIMED_OUT ;
+  else if (!strcmp (derr,  DBUS_ERROR_MATCH_RULE_NOT_FOUND  )) 
+    return  DBUS_GERROR_MATCH_RULE_NOT_FOUND ;
+  else if (!strcmp (derr,  DBUS_ERROR_MATCH_RULE_INVALID  )) 
+    return  DBUS_GERROR_MATCH_RULE_INVALID ;
+  else if (!strcmp (derr,  DBUS_ERROR_SPAWN_EXEC_FAILED  )) 
+    return  DBUS_GERROR_SPAWN_EXEC_FAILED ;
+  else if (!strcmp (derr,  DBUS_ERROR_SPAWN_FORK_FAILED  )) 
+    return  DBUS_GERROR_SPAWN_FORK_FAILED ;
+  else if (!strcmp (derr,  DBUS_ERROR_SPAWN_CHILD_EXITED  )) 
+    return  DBUS_GERROR_SPAWN_CHILD_EXITED ;
+  else if (!strcmp (derr,  DBUS_ERROR_SPAWN_CHILD_SIGNALED  )) 
+    return  DBUS_GERROR_SPAWN_CHILD_SIGNALED ;
+  else if (!strcmp (derr,  DBUS_ERROR_SPAWN_FAILED  )) 
+    return  DBUS_GERROR_SPAWN_FAILED ;
+  else if (!strcmp (derr,  DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN  )) 
+    return  DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN ;
+  else if (!strcmp (derr,  DBUS_ERROR_INVALID_SIGNATURE  )) 
+    return  DBUS_GERROR_INVALID_SIGNATURE ;
+  else if (!strcmp (derr,  DBUS_ERROR_INVALID_FILE_CONTENT  )) 
+    return  DBUS_GERROR_INVALID_FILE_CONTENT ;
+  else if (!strcmp (derr,  DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN  )) 
+    return  DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN ;
+  else
+    return DBUS_GERROR_REMOTE_EXCEPTION;
+}
 
 /**
  * dbus_set_g_error:
diff --git a/dbus/make-dbus-glib-error-enum.sh b/dbus/make-dbus-glib-error-enum.sh
index 1646333..1d7929a 100755
--- a/dbus/make-dbus-glib-error-enum.sh
+++ b/dbus/make-dbus-glib-error-enum.sh
@@ -1,25 +1,2 @@
 #!/bin/sh
-
-SRC=$1
-DEST=$2
-
-die()
-{
-    echo $1 1>&2
-    /bin/rm $DEST.tmp
-    exit 1
-}
-
-cat $SRC | grep '#define DBUS_ERROR' | sed -e 's/#define //g' | \
-  sed -e 's/".*//g' | sed -e 's/DBUS_ERROR/DBUS_GERROR/g' | sed -e 's/ *$/,/g' > $DEST.tmp
-
-if test ! -s $DEST.tmp ; then
-    die "$DEST.tmp is empty, something went wrong, see any preceding error message"
-fi
-echo "DBUS_GERROR_REMOTE_EXCEPTION" >> $DEST.tmp
-
-echo "#ifndef DBUS_INSIDE_DBUS_GLIB_H" >> $DEST.tmp
-echo '#error "' "$DEST" 'may only be included by dbus-glib.h"' >> $DEST.tmp
-echo "#endif" >> $DEST.tmp
-
-mv $DEST.tmp $DEST || die "could not move $DEST.tmp to $DEST"
+echo "#error This header makes no sense - see bugs.freedesktop.org 15430" >$2
diff --git a/dbus/make-dbus-glib-error-switch.sh b/dbus/make-dbus-glib-error-switch.sh
index 602cf99..1d7929a 100755
--- a/dbus/make-dbus-glib-error-switch.sh
+++ b/dbus/make-dbus-glib-error-switch.sh
@@ -1,29 +1,2 @@
 #!/bin/sh
-
-SRC=$1
-DEST=$2
-
-die()
-{
-    echo $1 1>&2
-    /bin/rm $DEST.tmp
-    exit 1
-}
-
-echo 'static gint' > $DEST.tmp
-echo 'dbus_error_to_gerror_code (const char *derr)' >> $DEST.tmp
-echo '{' >> $DEST.tmp
-echo '  if (0) ; ' >> $DEST.tmp
-
-cat $SRC | grep '#define DBUS_ERROR' | sed -e 's/#define //g' | \
-  sed -e 's/".*//g' | \
-   (while read line; do \
-     echo '  else if (!strcmp (derr, ' "$line" ' )) '; \
-     echo '    return ' `echo $line | sed -e 's/DBUS_ERROR/DBUS_GERROR/g'` ';'; \
-    done; \
-   ) >> $DEST.tmp
-echo '  else' >> $DEST.tmp
-echo '    return DBUS_GERROR_REMOTE_EXCEPTION;' >> $DEST.tmp
-echo '}' >> $DEST.tmp
-
-mv $DEST.tmp $DEST || die "could not move $DEST.tmp to $DEST"
+echo "#error This header makes no sense - see bugs.freedesktop.org 15430" >$2
-- 
1.5.5