diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-11 13:11:22 +0000 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-11 13:11:22 +0000 |
commit | 92236b5ccc020a1e1062fbf8305a1bd8d2afb932 (patch) | |
tree | b53508d522d164cd53f132743c00c3fe9d2f9ec5 /tools | |
parent | ffb2b1feee9bb01c821f6de64d6011c1bc6e01b1 (diff) |
Update tools from tp-glib 0.7.6
svn path=/trunk/; revision=915
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 24 | ||||
-rw-r--r-- | tools/doc-generator.xsl | 94 | ||||
-rw-r--r-- | tools/glib-client-gen.py | 48 | ||||
-rw-r--r-- | tools/glib-ginterface-gen.py | 2 | ||||
-rw-r--r-- | tools/gobject-foo.py | 81 | ||||
-rw-r--r-- | tools/ls-interfaces.xsl | 35 | ||||
-rw-r--r-- | tools/make-all-async.xsl | 43 | ||||
-rw-r--r-- | tools/spec-to-introspect.xsl | 51 | ||||
-rw-r--r-- | tools/telepathy-glib-env.in | 9 | ||||
-rw-r--r-- | tools/with-session-bus.sh | 73 |
10 files changed, 421 insertions, 39 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index 4bf514f16..bd1f4c002 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,3 +1,11 @@ +abs_top_builddir = @abs_top_builddir@ + +noinst_SCRIPTS = telepathy-glib-env + +telepathy-glib-env: telepathy-glib-env.in Makefile + sed -e 's![@]abs_top_builddir[@]!$(abs_top_builddir)!' $< > $@ + chmod +x $@ + EXTRA_DIST = \ c-constants-generator.xsl \ check-coding-style.mk \ @@ -15,8 +23,14 @@ EXTRA_DIST = \ glib-ginterface-gen.py \ glib-gtypes-generator.py \ glib-signals-marshal-gen.py \ + gobject-foo.py \ identity.xsl \ - libglibcodegen.py + libglibcodegen.py \ + ls-interfaces.xsl \ + make-all-async.xsl \ + spec-to-introspect.xsl \ + telepathy-glib-env.in \ + with-session-bus.sh CLEANFILES = libglibcodegen.pyc libglibcodegen.pyo $(noinst_SCRIPTS) @@ -31,11 +45,11 @@ glib-gtypes-generator.py: libglibcodegen.py glib-signals-marshal-gen.py: libglibcodegen.py touch $@ -TELEPATHY_GLIB_SRCDIR = $(top_srcdir)/../telepathy-glib -maintainer-update-from-telepathy-glib: +TELEPATHY_SPEC_SRCDIR = $(top_srcdir)/../telepathy-spec +maintainer-update-from-telepathy-spec: set -e && cd $(srcdir) && \ for x in $(EXTRA_DIST); do \ - if test -f $(TELEPATHY_GLIB_SRCDIR)/tools/$$x; then \ - cp $(TELEPATHY_GLIB_SRCDIR)/tools/$$x $$x; \ + if test -f $(TELEPATHY_SPEC_SRCDIR)/tools/$$x; then \ + cp $(TELEPATHY_SPEC_SRCDIR)/tools/$$x $$x; \ fi; \ done diff --git a/tools/doc-generator.xsl b/tools/doc-generator.xsl index 83b42dc55..8fd4dd3a4 100644 --- a/tools/doc-generator.xsl +++ b/tools/doc-generator.xsl @@ -2,7 +2,7 @@ The master copy of this stylesheet is in the Telepathy spec repository - please make any changes there. -Copyright (C) 2006, 2007 Collabora Limited +Copyright (C) 2006-2008 Collabora Limited This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -12,20 +12,27 @@ version 2.1 of the License, or (at your option) any later version. This library 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 -Library General Public License for more details. +Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - exclude-result-prefixes="tp"> + xmlns:html="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="tp html"> <!--Don't move the declaration of the HTML namespace up here - XMLNSs don't work ideally in the presence of two things that want to use the absence of a prefix, sadly. --> + <xsl:template match="html:*" mode="html"> + <xsl:copy> + <xsl:apply-templates mode="html"/> + </xsl:copy> + </xsl:template> + <xsl:template match="*" mode="identity"> <xsl:copy> <xsl:apply-templates mode="identity"/> @@ -33,7 +40,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </xsl:template> <xsl:template match="tp:docstring"> - <xsl:apply-templates select="node()" mode="identity"/> + <xsl:apply-templates select="text() | html:*" mode="html"/> + <xsl:apply-templates select="tp:rationale"/> + </xsl:template> + + <xsl:template match="tp:rationale"> + <div xmlns="http://www.w3.org/1999/xhtml" class="rationale"> + <xsl:apply-templates select="node()" mode="html"/> + </div> </xsl:template> <xsl:template match="tp:errors"> @@ -90,7 +104,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </xsl:template> <xsl:template match="/tp:spec/tp:license"> <div xmlns="http://www.w3.org/1999/xhtml" class="license"> - <xsl:apply-templates mode="identity"/> + <xsl:apply-templates mode="html"/> </div> </xsl:template> @@ -141,13 +155,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA <xsl:choose> <xsl:when test="tp:property"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Properties:</h2> + <h2 xmlns="http://www.w3.org/1999/xhtml">Telepathy Properties:</h2> + <p xmlns="http://www.w3.org/1999/xhtml">Accessed using the + <a href="#org.freedesktop.Telepathy.Properties">Telepathy + Properties</a> interface.</p> <dl xmlns="http://www.w3.org/1999/xhtml"> <xsl:apply-templates select="tp:property"/> </dl> </xsl:when> <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no properties.</p> + <p xmlns="http://www.w3.org/1999/xhtml">Interface has no Telepathy + properties.</p> + </xsl:otherwise> + </xsl:choose> + + <xsl:choose> + <xsl:when test="property"> + <h2 xmlns="http://www.w3.org/1999/xhtml">D-Bus core Properties:</h2> + <p xmlns="http://www.w3.org/1999/xhtml">Accessed using the + org.freedesktop.DBus.Properties interface.</p> + <dl xmlns="http://www.w3.org/1999/xhtml"> + <xsl:apply-templates select="property"/> + </dl> + </xsl:when> + <xsl:otherwise> + <p xmlns="http://www.w3.org/1999/xhtml">Interface has no D-Bus core + properties.</p> </xsl:otherwise> </xsl:choose> @@ -219,6 +252,36 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </dl> </xsl:template> + <xsl:template match="property"> + <dt xmlns="http://www.w3.org/1999/xhtml"> + <a name="{concat(../@name, '.', @name)}"> + <code><xsl:value-of select="@name"/></code> + </a> + <xsl:text> - </xsl:text> + <code><xsl:value-of select="@type"/></code> + <xsl:call-template name="parenthesized-tp-type"/> + <xsl:text>, </xsl:text> + <xsl:choose> + <xsl:when test="@access = 'read'"> + <xsl:text>read-only</xsl:text> + </xsl:when> + <xsl:when test="@access = 'write'"> + <xsl:text>write-only</xsl:text> + </xsl:when> + <xsl:when test="@access = 'readwrite'"> + <xsl:text>read/write</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>access: </xsl:text> + <code><xsl:value-of select="@access"/></code> + </xsl:otherwise> + </xsl:choose> + </dt> + <dd xmlns="http://www.w3.org/1999/xhtml"> + <xsl:apply-templates select="tp:docstring"/> + </dd> + </xsl:template> + <xsl:template match="tp:property"> <dt xmlns="http://www.w3.org/1999/xhtml"> <xsl:if test="@name"> @@ -626,13 +689,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA float: right; font-style: italic; } - .method { + .method, .signal, .property { margin-left: 1em; margin-right: 4em; } - .signal { - margin-left: 1em; - margin-right: 4em; + .rationale { + font-style: italic; + border-left: 0.25em solid #808080; + padding-left: 0.5em; } </style> @@ -650,19 +714,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA <h2>Interfaces</h2> <ul> - <xsl:for-each select="node/interface"> + <xsl:for-each select="//node/interface"> <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li> </xsl:for-each> </ul> - <xsl:apply-templates select="node"/> + <xsl:apply-templates select="//node"/> <xsl:apply-templates select="tp:generic-types"/> <xsl:apply-templates select="tp:errors"/> <h1>Index</h1> <h2>Index of interfaces</h2> <ul> - <xsl:for-each select="node/interface"> + <xsl:for-each select="//node/interface"> <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li> </xsl:for-each> </ul> diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py index 4ff78cd0b..fede212dc 100644 --- a/tools/glib-client-gen.py +++ b/tools/glib-client-gen.py @@ -46,6 +46,8 @@ class Generator(object): self.basename = basename self.group = opts.get('--group', None) self.iface_quark_prefix = opts.get('--iface-quark-prefix', None) + self.tp_proxy_api = tuple(map(int, + opts.get('--tp-proxy-api', '0').split('.'))) self.proxy_cls = opts.get('--subclass', 'TpProxy') + ' *' self.proxy_arg = opts.get('--subclass', 'void') + ' *' self.proxy_assert = opts.get('--subclass-assert', 'TP_IS_PROXY') @@ -142,7 +144,7 @@ class Generator(object): if args: self.b('static void') - self.b('%s (DBusGProxy *proxy,' % collect_name) + self.b('%s (DBusGProxy *proxy G_GNUC_UNUSED,' % collect_name) for arg in args: name, info, tp_type, elt = arg @@ -208,7 +210,7 @@ class Generator(object): self.b('static void') self.b('%s (TpProxy *tpproxy,' % invoke_name) - self.b(' GError *error,') + self.b(' GError *error G_GNUC_UNUSED,') self.b(' GValueArray *args,') self.b(' GCallback generic_callback,') self.b(' gpointer user_data,') @@ -721,6 +723,7 @@ class Generator(object): self.b(' 0,') self.b(' error, user_data, weak_object);') + self.b(' g_error_free (error);') self.b(' return NULL;') self.b(' }') self.b('') @@ -801,12 +804,12 @@ class Generator(object): member_lc) self.b('static void') - self.b('%s (TpProxy *self,' % reentrant_invoke) + self.b('%s (TpProxy *self G_GNUC_UNUSED,' % reentrant_invoke) self.b(' GError *error,') self.b(' GValueArray *args,') - self.b(' GCallback unused,') - self.b(' gpointer user_data,') - self.b(' GObject *unused2)') + self.b(' GCallback unused G_GNUC_UNUSED,') + self.b(' gpointer user_data G_GNUC_UNUSED,') + self.b(' GObject *unused2 G_GNUC_UNUSED)') self.b('{') self.b(' _%s_%s_run_state_%s *state = user_data;' % (self.prefix_lc, iface_lc, member_lc)) @@ -1026,17 +1029,23 @@ class Generator(object): signals = node.getElementsByTagName('signal') methods = node.getElementsByTagName('method') - self.b('static inline void') - self.b('%s_add_signals_for_%s (DBusGProxy *proxy)' - % (self.prefix_lc, name.lower())) - self.b('{') + if signals: + self.b('static inline void') + self.b('%s_add_signals_for_%s (DBusGProxy *proxy)' + % (self.prefix_lc, name.lower())) + self.b('{') - for signal in signals: - self.do_signal_add(signal) + if self.tp_proxy_api >= (0, 7, 6): + self.b(' if (!tp_proxy_dbus_g_proxy_claim_for_signal_adding ' + '(proxy))') + self.b(' return;') - self.b('}') - self.b('') - self.b('') + for signal in signals: + self.do_signal_add(signal) + + self.b('}') + self.b('') + self.b('') for signal in signals: self.do_signal(name, signal) @@ -1080,17 +1089,20 @@ class Generator(object): self.b(' * #TpProxy::interface-added.') self.b(' */') self.b('static void') - self.b('%s_%s_add_signals (TpProxy *self,' + self.b('%s_%s_add_signals (TpProxy *self G_GNUC_UNUSED,' % (self.prefix_lc, self.group)) self.b(' guint quark,') self.b(' DBusGProxy *proxy,') - self.b(' gpointer unused)') + self.b(' gpointer unused G_GNUC_UNUSED)') self.b('{') for node in nodes: iface = node.getElementsByTagName('interface')[0] self.iface_dbus = iface.getAttribute('name') + signals = node.getElementsByTagName('signal') + if not signals: + continue name = node.getAttribute('name').replace('/', '').lower() self.iface_uc = name.upper() self.b(' if (quark == %s)' % self.get_iface_quark()) @@ -1114,7 +1126,7 @@ def types_to_gtypes(types): if __name__ == '__main__': options, argv = gnu_getopt(sys.argv[1:], '', ['group=', 'subclass=', 'subclass-assert=', - 'iface-quark-prefix=']) + 'iface-quark-prefix=', 'tp-proxy-api=']) opts = {} diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py index 0c7c419e6..36f3242b0 100644 --- a/tools/glib-ginterface-gen.py +++ b/tools/glib-ginterface-gen.py @@ -204,7 +204,7 @@ class Generator(object): base_init_code.extend(self.do_signal(signal)) self.b('static inline void') - self.b('%s%s_base_init_once (gpointer klass)' + self.b('%s%s_base_init_once (gpointer klass G_GNUC_UNUSED)' % (self.prefix_, node_name_lc)) self.b('{') self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {' diff --git a/tools/gobject-foo.py b/tools/gobject-foo.py new file mode 100644 index 000000000..5921cab8a --- /dev/null +++ b/tools/gobject-foo.py @@ -0,0 +1,81 @@ +#!/usr/bin/python + +# gobject-foo.py: generate standard GObject type macros etc. +# +# The master copy of this program is in the telepathy-glib repository - +# please make any changes there. +# +# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +def gobject_header(head, tail, as_interface=False): + out = [] + o = out.append + + name = head + '_' + tail + MixedCase = name.replace('_', '') + lower_case = name.lower() + UPPER_CASE = name.upper() + + gtype = head.upper() + '_TYPE_' + tail.upper() + + o("typedef struct _%s %s;" % (MixedCase, MixedCase)) + o("typedef struct _%sClass %sClass;" % (MixedCase, MixedCase)) + o("typedef struct _%sPrivate %sPrivate;" % (MixedCase, MixedCase)) + o("") + o("GType %s_get_type (void);" % lower_case) + o("") + + o("#define %s \\" % gtype) + o(" (%s_get_type ())" % lower_case) + + o("#define %s(obj) \\" % UPPER_CASE) + o(" (G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, \\" % gtype) + o(" %s))" % MixedCase) + + if not as_interface: + o("#define %s_CLASS(klass) \\" % UPPER_CASE) + o(" (G_TYPE_CHECK_CLASS_CAST ((klass), %s, \\" % gtype) + o(" %sClass))" % MixedCase) + + o("#define %s_IS_%s(obj) \\" % (head.upper(), tail.upper())) + o(" (G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))" % gtype) + + if not as_interface: + o("#define %s_IS_%s_CLASS(klass) \\" % (head.upper(), tail.upper())) + o(" (G_TYPE_CHECK_CLASS_TYPE ((klass), %s))" % gtype) + + o("#define %s_GET_CLASS(obj) \\" % UPPER_CASE) + o(" (G_TYPE_INSTANCE_GET_CLASS ((obj), %s, \\" % gtype) + o(" %sClass))" % MixedCase) + + return out + +if __name__ == '__main__': + import sys + from getopt import gnu_getopt + + options, argv = gnu_getopt(sys.argv[1:], '', ['interface']) + + as_interface = False + + for opt, val in options: + if opt == '--interface': + as_interface = True + + head, tail = argv + + print '\n'.join(gobject_header(head, tail, as_interface=as_interface)) diff --git a/tools/ls-interfaces.xsl b/tools/ls-interfaces.xsl new file mode 100644 index 000000000..22c4ff5e8 --- /dev/null +++ b/tools/ls-interfaces.xsl @@ -0,0 +1,35 @@ +<!-- +Extract a space-separated list of interface classnames from the Telepathy spec. +The master copy of this stylesheet is in the Telepathy spec repository - +please make any changes there. + +Copyright (C) 2006, 2007 Collabora Limited + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> + +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="text" indent="no" encoding="ascii"/> + + <xsl:template match="text()"/> + + <xsl:template match="node"> + <xsl:value-of select="concat(' ', translate(@name, '/', ''), ' ')"/> + </xsl:template> + +</xsl:stylesheet> + +<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/make-all-async.xsl b/tools/make-all-async.xsl new file mode 100644 index 000000000..634ee3ca4 --- /dev/null +++ b/tools/make-all-async.xsl @@ -0,0 +1,43 @@ +<!-- Alter a D-Bus introspection XML file to add the DBus.GLib.Async annotation +to all methods. +The master copy of this stylesheet is in the telepathy-glib repository - +please make any changes there. + +Copyright (C) 2006, 2007 Collabora Limited + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml" indent="yes" encoding="ascii"/> + + <xsl:template match="method"> + <xsl:copy> + <xsl:apply-templates select="@*|node()"/> + <xsl:if test="not(annotation[name='org.freedesktop.DBus.GLib.Async'])"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + </xsl:if> + </xsl:copy> + </xsl:template> + + <xsl:template match="@*|node()"> + <xsl:copy> + <xsl:apply-templates select="@*|node()"/> + </xsl:copy> + </xsl:template> + +</xsl:stylesheet> + +<!-- vim:set sw=2 sts=2 et: --> diff --git a/tools/spec-to-introspect.xsl b/tools/spec-to-introspect.xsl new file mode 100644 index 000000000..980604ace --- /dev/null +++ b/tools/spec-to-introspect.xsl @@ -0,0 +1,51 @@ +<!-- Remove Telepathy extensions from a D-Bus interface, trying to leave only +DTD-compliant introspection XML. The output still needs to be subjected to the +following sed filter: +sed -e 's@xmlns:tp="http://telepathy\.freedesktop\.org/wiki/DbusSpec.extensions-v0"@@g' + +The master copy of this stylesheet is in the Telepathy spec repository - +please make any changes there. + +Copyright (C) 2006, 2007 Collabora Limited + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> + +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" + exclude-result-prefixes="tp"> + + <xsl:template match="*"> + <xsl:copy> + <xsl:for-each select="@*"> + <xsl:if test="not(starts-with(name(), 'tp:'))"> + <xsl:copy/> + </xsl:if> + </xsl:for-each> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + + <xsl:template match="tp:*"/> + <xsl:template match="text()"/> + + <xsl:output method="xml" indent="yes" encoding="UTF-8" + omit-xml-declaration="no" + doctype-system="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" + doctype-public="-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" /> + +</xsl:stylesheet> + +<!-- vim:set sw=2 sts=2 et: --> diff --git a/tools/telepathy-glib-env.in b/tools/telepathy-glib-env.in new file mode 100644 index 000000000..ddc47bfd8 --- /dev/null +++ b/tools/telepathy-glib-env.in @@ -0,0 +1,9 @@ +#!/bin/sh +abs_top_builddir="@abs_top_builddir@" +export abs_top_builddir +LD_LIBRARY_PATH="${abs_top_builddir}/telepathy-glib/.libs${LD_LIBRARY_PATH:+":${LD_LIBRARY_PATH}"}" +export LD_LIBRARY_PATH +G_DEBUG="fatal_criticals,fatal_warnings${G_DEBUG:+",${G_DEBUG}"}" +export G_DEBUG + +exec "$@" diff --git a/tools/with-session-bus.sh b/tools/with-session-bus.sh new file mode 100644 index 000000000..26d9f248a --- /dev/null +++ b/tools/with-session-bus.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# with-session-bus.sh - run a program with a temporary D-Bus session daemon +# +# The canonical location of this program is the telepathy-glib tools/ +# directory, please synchronize any changes with that copy. +# +# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. + +set -e + +me=with-session-bus + +dbus_daemon_args="--print-address=5 --print-pid=6 --fork" + +usage () +{ + echo "usage: $me [options] -- program [program_options]" >&2 + echo "Requires write access to the current directory." >&2 + exit 2 +} + +while test "z$1" != "z--"; do + case "$1" in + --session) + dbus_daemon_args="$dbus_daemon_args --session" + shift + ;; + --config-file=*) + # FIXME: assumes config file doesn't contain any special characters + dbus_daemon_args="$dbus_daemon_args $1" + shift + ;; + *) + usage + ;; + esac +done +shift +if test "z$1" = "z"; then usage; fi + +exec 5> $me-$$.address +exec 6> $me-$$.pid + +cleanup () +{ + pid=`head -n1 $me-$$.pid` + if test -n "$pid" ; then + echo "Killing temporary bus daemon: $pid" >&2 + kill -INT "$pid" + fi + rm -f $me-$$.address + rm -f $me-$$.pid +} + +trap cleanup INT HUP TERM +dbus-daemon $dbus_daemon_args + +{ echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2 +{ echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2 + +e=0 +DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`" +export DBUS_SESSION_BUS_ADDRESS +"$@" || e=$? + +trap - INT HUP TERM +cleanup + +exit $e |