dbus/tools run-with-tmp-session-bus.sh, NONE, 1.1 print-introspect.c, NONE, 1.1 Makefile.am, 1.11, 1.12 .cvsignore, 1.3, 1.4

Colin Walters walters at freedesktop.org
Thu Mar 17 09:48:31 PST 2005


Update of /cvs/dbus/dbus/tools
In directory gabe:/tmp/cvs-serv31306/tools

Modified Files:
	Makefile.am .cvsignore 
Added Files:
	run-with-tmp-session-bus.sh print-introspect.c 
Log Message:
2005-03-17  Colin Walters  <walters at verbum.org>

	* bus/print-introspect.c: Move to tools/.
	* bus/run-with-tmp-session-bus.sh: Ditto.
	
	* glib/Makefile.am (dbus-glib-bindings.h): Move
	generation to tools/Makefile.am.

	* test/glib/run-test.sh: Update to handle move
	of run-with-tmp-session-bus.sh.

	* test/glib/test-service-glib.c: Update to handle
	move of dbus-glib-bindings.h.

	* tools/print-introspect.c: Moved here
	from bus/, and ported to GLib bindings.

	* tools/run-with-tmp-session-bus.sh: Moved here
	from bus/.

	* tools/Makefile.am: Generate dbus-glib-bindings.h
	and dbus-bus-introspect.xml here.

	* tools/.cvsignore, glib/.cvsignore, bus/.cvsignore:
	Update.


--- NEW FILE: run-with-tmp-session-bus.sh ---
#! /bin/bash

SCRIPTNAME=$0
WRAPPED_SCRIPT=$1
shift

function die() 
{
    if ! test -z "$DBUS_SESSION_BUS_PID" ; then
        echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
        kill -9 $DBUS_SESSION_BUS_PID
    fi
    echo $SCRIPTNAME: $* >&2
    exit 1
}

if test -z "$DBUS_TOP_BUILDDIR" ; then
    die "Must set DBUS_TOP_BUILDDIR"
fi

## convenient to be able to ctrl+C without leaking the message bus process
trap 'die "Received SIGINT"' SIGINT

CONFIG_FILE=./run-with-tmp-session-bus.conf
SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2

## create a configuration file based on the standard session.conf
cat $DBUS_TOP_BUILDDIR/bus/session.conf |  \
    sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
    sed -e 's/<include.*$//g'                \
  > $CONFIG_FILE

echo "Created configuration file $CONFIG_FILE" >&2

export PATH=$DBUS_TOP_BUILDDIR/bus:$PATH
## the libtool script found by the path search should already do this, but
export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH

unset DBUS_SESSION_BUS_ADDRESS
unset DBUS_SESSION_BUS_PID

echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2

eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE`

if test -z "$DBUS_SESSION_BUS_PID" ; then
    die "Failed to launch message bus for introspection generation to run"
fi

echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2

# Execute wrapped script
echo "Running $WRAPPED_SCRIPT $@" >&2
$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed"

kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2

sleep 2

## be sure it really died 
kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true

exit 0

--- NEW FILE: print-introspect.c ---
/* -*- mode: C; c-file-style: "gnu" -*- */
/* gather-introspect.c  Dump introspection data from service to stdout
 *
 * Copyright (C) 2005  Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <dbus/dbus-glib.h>

static void
usage (char *name, int ecode)
{
  fprintf (stderr, "Usage: %s <service> <destination object path>\n", name);
  exit (ecode);
}

int
main (int argc, char *argv[])
{
  DBusGConnection *connection;
  DBusGProxy *proxy;
  DBusGPendingCall *call;
  GError *error;
  const char *service;
  const char *path;
  const char *introspect_data;
  
  if (argc != 3)
    usage (argv[0], 1);

  service = argv[1];
  path = argv[2];

  g_type_init ();

  error = NULL;
  connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  if (connection == NULL)
    {
      fprintf (stderr, "Failed to open connection to session bus: %s\n",
               error->message);
      g_clear_error (&error);
      exit (1);
    }

  proxy = dbus_g_proxy_new_for_name (connection,
				     service, path,
				     DBUS_INTERFACE_INTROSPECTABLE);
  call = dbus_g_proxy_begin_call (proxy, "Introspect", DBUS_TYPE_INVALID);
  if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_STRING,
			      &introspect_data, DBUS_TYPE_INVALID))
    {
      fprintf (stderr, "Failed to get introspection data: %s\n",
               error->message);
      g_clear_error (&error);
      exit (1);
    }
      
  printf ("%s", introspect_data);

  dbus_g_pending_call_unref (call);
  g_object_unref (proxy);

  exit (0);
}

Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/tools/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am	13 Feb 2005 17:16:25 -0000	1.11
+++ Makefile.am	17 Mar 2005 17:48:29 -0000	1.12
@@ -2,6 +2,15 @@
 
 if HAVE_GLIB
 GLIB_TOOLS=dbus-monitor
+
+libdbus_glib_HEADERS = dbus-glib-bindings.h
+libdbus_glibdir = $(includedir)/dbus-1.0/dbus
+
+dbus-glib-bindings.h: dbus-bus-introspect.xml $(top_builddir)/glib/dbus-binding-tool
+	$(top_builddir)/glib/dbus-binding-tool --ignore-unsupported --mode=glib-client --output=dbus-glib-bindings.h dbus-bus-introspect.xml # FIXME - remove --ignore-unsupported when we can do arrays
+
+BUILT_SOURCES = dbus-glib-bindings.h
+
 else
 GLIB_TOOLS=
 endif
@@ -12,6 +21,16 @@
 GTK_TOOLS=
 endif
 
+noinst_PROGRAMS = print-introspect
+
+print_introspect_SOURCES = print-introspect.c
+print_introspect_LDADD = $(top_builddir)/glib/libdbus-glib-1.la
+
+run-with-tmp-session-bus.sh: $(top_builddir)/bus/dbus-daemon dbus-launch
+
+dbus-bus-introspect.xml: $(srcdir)/run-with-tmp-session-bus.sh print-introspect $(top_builddir)/bus/dbus-daemon
+	DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./print-introspect org.freedesktop.DBus /org/freedesktop/DBus > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml
+
 bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus-cleanup-sockets $(GTK_TOOLS)
 
 dbus_send_SOURCES=				\
@@ -43,6 +62,6 @@
 dbus_viewer_LDADD= $(DBUS_GLIB_TOOL_LIBS) $(top_builddir)/glib/libdbus-gtool.la $(DBUS_GTK_THREADS_LIBS)
 
 man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 dbus-cleanup-sockets.1
-EXTRA_DIST = $(man_MANS)
+EXTRA_DIST = $(man_MANS) run-with-tmp-session-bus.sh
 
 

Index: .cvsignore
===================================================================
RCS file: /cvs/dbus/dbus/tools/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- .cvsignore	29 Mar 2004 12:50:45 -0000	1.3
+++ .cvsignore	17 Mar 2005 17:48:29 -0000	1.4
@@ -13,3 +13,7 @@
 *.gcov
 *.da
 dbus-viewer
+dbus-glib-bindings.h
+run-with-tmp-session-bus.conf
+print-introspect
+dbus-bus-introspect.xml



More information about the dbus-commit mailing list