diff options
80 files changed, 1196 insertions, 3491 deletions
@@ -45,13 +45,13 @@ Makefile.in *-bindings.[ch] *-gen.h -data/org.freedesktop.Telepathy.ConnectionManager.idle.service +data/im.telepathy.v1.ConnectionManager.idle.service extensions/_gen extensions/extensions.html -src/telepathy-idle -src/telepathy-idle.8 +src/telepathy-idle-1 +src/telepathy-idle-1.8 core cscope.out @@ -66,10 +66,10 @@ tests/*.log tests/*.trs tests/twisted/config.py -tests/twisted/idle-twisted-tests.list +tests/twisted/twisted-tests.list tests/twisted/tools/exec-with-log.sh tests/twisted/tools/idle-testing.log -tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.idle.service +tests/twisted/tools/im.telepathy.v1.ConnectionManager.idle.service tests/twisted/run-test.sh tests/twisted/test-suite.log tests/twisted/tools/tmp-session-bus.conf diff --git a/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch b/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch new file mode 100644 index 0000000..876dbc0 --- /dev/null +++ b/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch @@ -0,0 +1,70 @@ +From e09ea00091c776c58b0063af7aaa93275d7ea024 Mon Sep 17 00:00:00 2001 +From: Simon McVittie <simon.mcvittie@collabora.co.uk> +Date: Wed, 9 Apr 2014 19:18:28 +0100 +Subject: [PATCH] Adapt for GVariant-based tp_group_mixin_change_members + +This means we need GLib 2.40 for GVariantDict. Enable GLib 2.28 +deprecations, but not 2.30 because we still use GValueArray. +--- + configure.ac | 6 +++--- + src/idle-muc-channel.c | 20 +++++++++++--------- + 2 files changed, 14 insertions(+), 12 deletions(-) + +diff --git a/configure.ac b/configure.ac +index b378afb..1c79d50 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -86,11 +86,11 @@ fi + AC_HEADER_STDC([]) + AC_C_INLINE + +-AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_28, [Ignore post 2.28 deprecations]) +-AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_34, [Prevent post 2.34 APIs]) ++AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations]) ++AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_40, [Prevent post 2.40 APIs]) + + PKG_CHECK_MODULES([GLIB], +- [glib-2.0 >= 2.34.0, gobject-2.0 >= 2.34.0, gio-2.0 >= 2.34.0 ]) ++ [glib-2.0 >= 2.40, gobject-2.0 >= 2.40, gio-2.0 >= 2.40 ]) + + PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.51, dbus-glib-1 >= 0.51]) + +diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c +index 4fc2091..7ee6313 100644 +--- a/src/idle-muc-channel.c ++++ b/src/idle-muc-channel.c +@@ -196,20 +196,22 @@ change_members (GObject *obj, + TpHandle actor, + TpChannelGroupChangeReason reason) + { +- GHashTable *details; ++ GVariantDict details; + +- details = tp_asv_new ( +- "actor", G_TYPE_UINT, actor, +- "change-reason", G_TYPE_UINT, reason, +- NULL); ++ g_variant_dict_init (&details, NULL); ++ ++ g_variant_dict_insert_value (&details, "actor", ++ g_variant_new_uint32 (actor)); ++ g_variant_dict_insert_value (&details, "change-reason", ++ g_variant_new_uint32 (reason)); + + if (message != NULL) +- tp_asv_set_string (details, "message", message); ++ g_variant_dict_insert_value (&details, "message", ++ g_variant_new_string (message)); + + tp_group_mixin_change_members (obj, +- add, del, add_local_pending, add_remote_pending, details); +- +- g_hash_table_unref (details); ++ add, del, add_local_pending, add_remote_pending, ++ g_variant_dict_end (&details)); + } + + static void +-- +1.9.1 + diff --git a/Makefile.am b/Makefile.am index 9742752..48dc6fd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = tools extensions src data m4 tests +SUBDIRS = tools src data m4 tests check-twisted : all $(MAKE) -C tests/twisted check-twisted @@ -1,3 +1,38 @@ +telepathy-idle 0.99.12 (UNRELEASED) +=================================== + +... + +telepathy-idle 0.99.11 (2014-05-14) +=================================== + +The “electioneering” release. + +Dependencies: + +• telepathy-glib ≥ 0.99.11 + +• GLib ≥ 2.40 + +Enhancements: + +• GNOME-style installed-tests (configure with --enable-installed-tests) + +telepathy-idle 0.99.10 (2014-04-03) +=================================== + +Dependencies: + +• telepathy-glib ≥ 0.99.10 + +Incompatible changes: + +• Switch to Telepathy 1 D-Bus API + +Enhancements: + +• Add IRCCommand interface (fd.o #70434) + telepathy-idle 0.2.0 (2013-10-03) ================================= @@ -1,7 +1,7 @@ #!/bin/sh set -e -autoreconf -i -Wno-portability +autoreconf -i -Wno-portability -f # Honor NOCONFIGURE for compatibility with gnome-autogen.sh if test x"$NOCONFIGURE" = x; then diff --git a/configure.ac b/configure.ac index 02a5966..94e2871 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_PREREQ([2.60]) +AC_PREREQ([2.59]) # Making releases: # set the new version number: @@ -10,10 +10,11 @@ AC_PREREQ([2.60]) # set nano_version to 1 m4_define([idle_major_version], [0]) -m4_define([idle_minor_version], [2]) -m4_define([idle_micro_version], [0]) +m4_define([idle_minor_version], [99]) +m4_define([idle_micro_version], [11]) m4_define([idle_nano_version], [1]) + m4_define([idle_base_version], [idle_major_version.idle_minor_version.idle_micro_version]) m4_define([idle_version], @@ -25,18 +26,17 @@ AC_INIT([telepathy-idle], [idle_version], [https://bugs.freedesktop.org/enter_bug.cgi?product=Telepathy&component=idle]) AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_AUX_DIR([build-aux]) # Enable silent build rules by default, requires at least # Automake-1.11. Disable by either passing --disable-silent-rules to # configure or passing V=1 to make m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_INIT_AUTOMAKE([1.9 -Wno-portability subdir-objects]) +AM_INIT_AUTOMAKE([1.9 -Wno-portability]) AM_PROG_LIBTOOL AM_CONFIG_HEADER(config.h) -AC_PROG_MKDIR_P +AM_PROG_MKDIR_P dnl check for tools AC_PROG_CC @@ -79,51 +79,59 @@ AC_SUBST([ERROR_CFLAGS]) # these aren't really error flags but they serve a similar purpose for us - # making the toolchain stricter -AS_IF([test "x$enable_fatal_warnings" = xyes], - [TP_ADD_LINKER_FLAG([ERROR_LDFLAGS], [-Wl,--no-copy-dt-needed-entries])]) +if test "x$enable_fatal_warnings" = xyes; then + TP_ADD_LINKER_FLAG([ERROR_LDFLAGS], [-Wl,--no-copy-dt-needed-entries]) +fi AC_HEADER_STDC([]) AC_C_INLINE -AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_28, [Ignore post 2.28 deprecations]) -AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_32, [Prevent post 2.32 APIs]) +AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations]) +AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_40, [Prevent post 2.40 APIs]) PKG_CHECK_MODULES([GLIB], - [glib-2.0 >= 2.32.0, gobject-2.0 >= 2.32.0, gio-2.0 >= 2.32.0 ]) + [glib-2.0 >= 2.40, gobject-2.0 >= 2.40, gio-2.0 >= 2.40 ]) PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.51, dbus-glib-1 >= 0.51]) AC_DEFINE([TP_SEAL_ENABLE], [], [Prevent to use sealed variables]) AC_DEFINE([TP_DISABLE_SINGLE_INCLUDE], [], [Disable single header include]) -AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_0_24, [Ignore post 0.24 deprecations]) -AC_DEFINE(TP_VERSION_MAX_ALLOWED, TP_VERSION_0_24, [Prevent post 0.24 APIs]) -PKG_CHECK_MODULES([TELEPATHY], [telepathy-glib >= 0.23.0]) +AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_1_0, [Ignore post 1.0 deprecations]) +AC_DEFINE(TP_VERSION_MAX_ALLOWED, TP_VERSION_1_0, [Prevent post 1.0 APIs]) +PKG_CHECK_MODULES([TELEPATHY], [telepathy-glib-1 >= 0.99.11, telepathy-glib-1-dbus >= 0.99.11]) dnl Check for code generation tools XSLTPROC= AC_CHECK_PROGS([XSLTPROC], [xsltproc]) -AS_IF([test -z "$XSLTPROC"], - [AC_MSG_ERROR([xsltproc (from the libxslt source package) is required])]) +if test -z "$XSLTPROC"; then + AC_MSG_ERROR([xsltproc (from the libxslt source package) is required]) +fi AM_PATH_PYTHON([2.3]) dnl check for a version of python that can run the twisted tests AC_MSG_CHECKING([for Python with Twisted and IRC protocol support]) for TEST_PYTHON in python2.5 python2.6 python; do - AS_IF([$TEST_PYTHON -c "from sys import version_info; import dbus, dbus.mainloop.glib; raise SystemExit(version_info < (2, 5, 0, 'final', 0))" >/dev/null 2>&1], - [ - AS_IF([$TEST_PYTHON -c "import twisted.words.protocols.irc, twisted.internet.reactor" >/dev/null 2>&1], - [ - AM_CONDITIONAL([WANT_TWISTED_TESTS], [true]) + if $TEST_PYTHON -c "from sys import version_info; import dbus, dbus.mainloop.glib; raise SystemExit(version_info < (2, 5, 0, 'final', 0))" >/dev/null 2>&1; then + if $TEST_PYTHON -c "import twisted.words.protocols.irc, twisted.internet.reactor" >/dev/null 2>&1; then + AM_CONDITIONAL([WANT_TWISTED_TESTS], true) break - ], - [TEST_PYTHON=no]) - ]) + else + TEST_PYTHON=no + fi + fi done AC_MSG_RESULT([$TEST_PYTHON]) AC_SUBST(TEST_PYTHON) AM_CONDITIONAL([WANT_TWISTED_TESTS], test xno != x$TEST_PYTHON) +AC_ARG_ENABLE([installed-tests], + [AC_HELP_STRING([--enable-installed-tests], + [enable as-installed regression tests])], + [], + [enable_installed_tests=no]) +AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], + [test "x$enable_installed_tests" = xyes]) AS_AC_EXPAND(DATADIR, $datadir) DBUS_SERVICES_DIR="$DATADIR/dbus-1/services" @@ -134,7 +142,6 @@ AC_CHECK_FUNCS(strnlen) AC_OUTPUT( Makefile \ data/Makefile \ - extensions/Makefile \ m4/Makefile \ src/Makefile \ tests/Makefile \ diff --git a/data/Makefile.am b/data/Makefile.am index b949137..edb8f6d 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,12 +1,12 @@ # Telepathy manager file -managerdir = $(datadir)/telepathy/managers +managerdir = $(datadir)/telepathy-1/managers manager_DATA = idle.manager # Dbus service file BUILT_FILES = $(service_in_files:.service.in=.service) servicedir = $(DBUS_SERVICES_DIR) -service_in_files = org.freedesktop.Telepathy.ConnectionManager.idle.service.in +service_in_files = im.telepathy.v1.ConnectionManager.idle.service.in service_DATA = $(BUILT_FILES) CLEANFILES = $(BUILT_FILES) diff --git a/data/idle.manager b/data/idle.manager index 1b981ce..cdca318 100644 --- a/data/idle.manager +++ b/data/idle.manager @@ -1,7 +1,7 @@ [ConnectionManager] Name = idle -BusName = org.freedesktop.Telepathy.ConnectionManager.idle -ObjectPath = /org/freedesktop/Telepathy/ConnectionManager/idle +BusName = im.telepathy1.ConnectionManager.idle +ObjectPath = /im/telepathy1/ConnectionManager/idle [Protocol irc] param-account = s required diff --git a/data/im.telepathy.v1.ConnectionManager.idle.service.in b/data/im.telepathy.v1.ConnectionManager.idle.service.in new file mode 100644 index 0000000..52377fe --- /dev/null +++ b/data/im.telepathy.v1.ConnectionManager.idle.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=im.telepathy.v1.ConnectionManager.idle +Exec=@libexecdir@/telepathy-idle-1 diff --git a/data/org.freedesktop.Telepathy.ConnectionManager.idle.service.in b/data/org.freedesktop.Telepathy.ConnectionManager.idle.service.in deleted file mode 100644 index 4d80601..0000000 --- a/data/org.freedesktop.Telepathy.ConnectionManager.idle.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.freedesktop.Telepathy.ConnectionManager.idle -Exec=@libexecdir@/telepathy-idle diff --git a/extensions/Connection_Interface_IRC_Command1.xml b/extensions/Connection_Interface_IRC_Command1.xml deleted file mode 100644 index 1de5396..0000000 --- a/extensions/Connection_Interface_IRC_Command1.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<node name="/Connection_Interface_IRC_Command1" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <tp:copyright> Copyright (C) 2013 Collabora Limited </tp:copyright> - <tp:license xmlns="http://www.w3.org/1999/xhtml"> - <p>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.</p> - -<p>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.</p> - -<p>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 Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> - </tp:license> - <interface name="org.freedesktop.Telepathy.Connection.Interface.IRCCommand1" - tp:causes-havoc='not well-tested'> - <tp:requires interface="org.freedesktop.Telepathy.Connection"/> - <method name="Send" tp:name-for-bindings="Send"> - <arg direction="in" name="Command" type="s"> - <tp:docstring> - The command followed by its arguments. - </tp:docstring> - </arg> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Send an arbitrary IRC command to the server.</p> - <p>For example, an IRC client receiving <code>/bip blreset</code> from - the user might call this method with <code>BIP blreset</code> as - argument which will send <code>BIP blreset</code> to the server.</p> - <p>The command is supplied in UTF-8 (because strings on D-Bus are - always UTF-8). It is transcoded into the connection's configured - character set, if different, before sending to the server.</p> - </tp:docstring> - <tp:possible-errors> - <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> - <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/> - <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"> - <tp:docstring> - The connection manager MAY raise this error for commands that - have a more appropriate D-Bus API. - </tp:docstring> - </tp:error> - </tp:possible-errors> - </method> - <tp:docstring> - An interface to send arbitrary IRC commands to the server. - </tp:docstring> - </interface> -</node> -<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/extensions/Makefile.am b/extensions/Makefile.am deleted file mode 100644 index b4d67f8..0000000 --- a/extensions/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -tools_dir = $(top_srcdir)/tools - -EXTRA_DIST = \ - all.xml \ - Connection_Interface_IRC_Command1.xml \ - $(NULL) - -noinst_LTLIBRARIES = libidle-extensions.la - -libidle_extensions_la_SOURCES = \ - extensions.h - -nodist_libidle_extensions_la_SOURCES = \ - _gen/enums.h \ - _gen/interfaces.h \ - _gen/svc-gtk-doc.h \ - _gen/svc.h \ - _gen/svc.c - -BUILT_SOURCES = \ - _gen/all.xml \ - $(nodist_libidle_extensions_la_SOURCES) \ - extensions.html - -CLEANFILES = $(BUILT_SOURCES) - -AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@ @TELEPATHY_CFLAGS@ -AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @TELEPATHY_LIBS@ - -# Generated stuff - -DROP_NAMESPACE = sed -e 's@xmlns:tp="http://telepathy\.freedesktop\.org/wiki/DbusSpec.extensions-v0"@@g' -XSLTPROCFLAGS = --nonet --novalid - -_gen/all.xml: all.xml $(wildcard $(srcdir)/*.xml) - @$(MKDIR_P) _gen - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --xinclude $(tools_dir)/identity.xsl \ - $< > $@ - -extensions.html: _gen/all.xml $(tools_dir)/doc-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - $(tools_dir)/doc-generator.xsl \ - $< > $@ - -_gen/svc.h: _gen/svc.c -_gen/svc-gtk-doc.h: _gen/svc.c - -_gen/svc.c: _gen/all.xml \ - $(tools_dir)/glib-ginterface-gen.py - $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-ginterface-gen.py \ - --filename=_gen/svc --signal-marshal-prefix=_idle_ext \ - --include='<telepathy-glib/telepathy-glib.h>' \ - --not-implemented-func='tp_dbus_g_method_return_not_implemented' \ - --allow-unstable \ - $< Idle_Svc_ - -_gen/enums.h: _gen/all.xml $(tools_dir)/c-constants-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --stringparam mixed-case-prefix Idle \ - $(tools_dir)/c-constants-generator.xsl \ - $< > $@ - -_gen/interfaces.h: _gen/all.xml $(tools_dir)/c-interfaces-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --stringparam mixed-case-prefix Idle \ - $(tools_dir)/c-interfaces-generator.xsl \ - $< > $@ diff --git a/extensions/all.xml b/extensions/all.xml deleted file mode 100644 index 6b76837..0000000 --- a/extensions/all.xml +++ /dev/null @@ -1,32 +0,0 @@ -<tp:spec - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - xmlns:xi="http://www.w3.org/2001/XInclude"> - -<tp:title>Idle-specific extensions to the Telepathy interfaces</tp:title> - -<tp:copyright>Copyright (C) 2007 Collabora Limited</tp:copyright> - -<tp:license xmlns="http://www.w3.org/1999/xhtml"> -<p>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.</p> - -<p>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.</p> - -<p>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</p> -</tp:license> - -<xi:include href="Connection_Interface_IRC_Command1.xml"/> - -<tp:generic-types> - <tp:external-type name="Contact_Handle" type="u" - from="Telepathy specification"/> -</tp:generic-types> - -</tp:spec> diff --git a/extensions/extensions.h b/extensions/extensions.h deleted file mode 100644 index 839fc4e..0000000 --- a/extensions/extensions.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef _IDLE_EXTENSIONS_H -#define _IDLE_EXTENSIONS_H - -#include "extensions/_gen/svc.h" -#include "extensions/_gen/enums.h" -#include "extensions/_gen/interfaces.h" - -#endif /* _IDLE_EXTENSIONS_H */ - diff --git a/src/Makefile.am b/src/Makefile.am index 7ed3126..0ef56d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # correctly clean the generated source files CLEANFILES = $(BUILT_SOURCES) $(man_MANS) -libexec_PROGRAMS=telepathy-idle +libexec_PROGRAMS = telepathy-idle-1 libidle_convenience_la_SOURCES = \ idle-connection.c \ @@ -49,13 +49,10 @@ libidle_convenience_la_SOURCES = \ nodist_libidle_convenience_la_SOURCES = \ $(BUILT_SOURCES) -libidle_convenience_la_LIBADD = \ - $(top_builddir)/extensions/libidle-extensions.la - -telepathy_idle_SOURCES = \ +telepathy_idle_1_SOURCES = \ idle.c -telepathy_idle_LDADD = \ +telepathy_idle_1_LDADD = \ libidle-convenience.la \ $(ALL_LIBS) @@ -79,9 +76,9 @@ ALL_LIBS = \ @GLIB_LIBS@ \ @TELEPATHY_LIBS@ -man_MANS = telepathy-idle.8 +man_MANS = telepathy-idle-1.8 -EXTRA_DIST = telepathy-idle.8.in +EXTRA_DIST = telepathy-idle-1.8.in %.8: %.8.in Makefile $(AM_V_GEN)sed -e 's,[@]libexecdir[@],@libexecdir@,' < $< > $@ diff --git a/src/idle-connection.c b/src/idle-connection.c index 9ee8840..31dab9c 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -41,8 +41,6 @@ #include "idle-server-connection.h" #include "server-tls-manager.h" -#include "extensions/extensions.h" /* IRCCommand */ - #define DEFAULT_KEEPALIVE_INTERVAL 30 /* sec */ #define MISSED_KEEPALIVES_BEFORE_DISCONNECTING 3 @@ -58,21 +56,15 @@ static gboolean flush_queue_faster = FALSE; #define SERVER_CMD_NORMAL_PRIORITY G_MAXUINT/2 #define SERVER_CMD_MAX_PRIORITY G_MAXUINT -static void _free_alias_pair(gpointer data, gpointer user_data) -{ - g_boxed_free(TP_STRUCT_TYPE_ALIAS_PAIR, data); -} - static void _aliasing_iface_init(gpointer, gpointer); static void _renaming_iface_init(gpointer, gpointer); static void irc_command_iface_init(gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE(IdleConnection, idle_connection, TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING, _aliasing_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO, idle_contact_info_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_RENAMING, _renaming_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, tp_contacts_mixin_iface_init); - G_IMPLEMENT_INTERFACE(IDLE_TYPE_SVC_CONNECTION_INTERFACE_IRC_COMMAND1, irc_command_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1, _aliasing_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO1, idle_contact_info_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_RENAMING1, _renaming_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_IRC_COMMAND1, irc_command_iface_init); ); typedef struct _IdleOutputPendingMsg IdleOutputPendingMsg; @@ -191,8 +183,8 @@ struct _IdleConnectionPrivate { gboolean quitting; guint force_disconnect_id; - /* AliasChanged aggregation */ - GPtrArray *queued_aliases; + /* AliasChanged aggregation. TpHandle -> owned (gchar *) */ + GHashTable *queued_aliases; TpHandleSet *queued_aliases_owners; /* if idle_connection_dispose has already run once */ @@ -240,10 +232,6 @@ static void idle_connection_add_queue_timeout (IdleConnection *self); static void idle_connection_clear_queue_timeout (IdleConnection *self); static void _send_with_priority(IdleConnection *conn, const gchar *msg, guint priority); -static void conn_aliasing_fill_contact_attributes ( - GObject *obj, - const GArray *contacts, - GHashTable *attributes_hash); static void idle_connection_init(IdleConnection *obj) { IdleConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, IDLE_TYPE_CONNECTION, IdleConnectionPrivate); @@ -252,21 +240,41 @@ static void idle_connection_init(IdleConnection *obj) { priv->sconn_connected = FALSE; priv->msg_queue = g_queue_new(); priv->aliases = g_hash_table_new_full (NULL, NULL, NULL, g_free); - - tp_contacts_mixin_init ((GObject *) obj, G_STRUCT_OFFSET (IdleConnection, contacts)); - tp_base_connection_register_with_contacts_mixin ((TpBaseConnection *) obj); } static void idle_connection_constructed (GObject *object) { + void (*chain_up) (GObject *) = + G_OBJECT_CLASS (idle_connection_parent_class)->constructed; IdleConnection *self = IDLE_CONNECTION (object); + GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object); + GDBusInterfaceSkeleton *iface; + + chain_up (object); self->parser = g_object_new (IDLE_TYPE_PARSER, "connection", self, NULL); idle_contact_info_init (self); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_ALIASING, - conn_aliasing_fill_contact_attributes); + + iface = tp_svc_interface_skeleton_new (skel, + TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1); + g_dbus_object_skeleton_add_interface (skel, iface); + g_object_unref (iface); + + iface = tp_svc_interface_skeleton_new (skel, + TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO1); + g_dbus_object_skeleton_add_interface (skel, iface); + g_object_unref (iface); + + iface = tp_svc_interface_skeleton_new (skel, + TP_TYPE_SVC_CONNECTION_INTERFACE_IRC_COMMAND1); + g_dbus_object_skeleton_add_interface (skel, iface); + g_object_unref (iface); + + iface = tp_svc_interface_skeleton_new (skel, + TP_TYPE_SVC_CONNECTION_INTERFACE_RENAMING1); + g_dbus_object_skeleton_add_interface (skel, iface); + g_object_unref (iface); } static void idle_connection_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) { @@ -413,8 +421,7 @@ static void idle_connection_dispose (GObject *object) { if (priv->queued_aliases_owners) tp_handle_set_destroy(priv->queued_aliases_owners); - if (priv->queued_aliases) - g_ptr_array_free(priv->queued_aliases, TRUE); + g_clear_pointer (&priv->queued_aliases, g_hash_table_unref); g_object_unref(self->parser); @@ -444,17 +451,14 @@ static void idle_connection_finalize (GObject *object) { idle_output_pending_msg_free(msg); g_queue_free(priv->msg_queue); - tp_contacts_mixin_finalize (object); G_OBJECT_CLASS(idle_connection_parent_class)->finalize(object); } static const gchar * interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_ALIASING, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO, - TP_IFACE_CONNECTION_INTERFACE_RENAMING, - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, - TP_IFACE_CONNECTION_INTERFACE_CONTACTS, + TP_IFACE_CONNECTION_INTERFACE_ALIASING1, + TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1, + TP_IFACE_CONNECTION_INTERFACE_RENAMING1, NULL}; const gchar * const *idle_connection_get_implemented_interfaces (void) { @@ -462,20 +466,10 @@ const gchar * const *idle_connection_get_implemented_interfaces (void) { return interfaces_always_present; } -static GPtrArray * -get_interfaces_always_present (TpBaseConnection *base) -{ - GPtrArray *interfaces; - const gchar **iter; - - interfaces = TP_BASE_CONNECTION_CLASS ( - idle_connection_parent_class)->get_interfaces_always_present (base); - - for (iter = interfaces_always_present; *iter != NULL; iter++) - g_ptr_array_add (interfaces, (gchar *) *iter); - - return interfaces; -} +static void idle_connection_fill_contact_attributes (TpBaseConnection *base, + const gchar *dbus_interface, + TpHandle handle, + GVariantDict *attributes); static void idle_connection_class_init(IdleConnectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); @@ -498,7 +492,7 @@ static void idle_connection_class_init(IdleConnectionClass *klass) { parent_class->disconnected = _iface_disconnected; parent_class->shut_down = _iface_shut_down; parent_class->start_connecting = _iface_start_connecting; - parent_class->get_interfaces_always_present = get_interfaces_always_present; + parent_class->fill_contact_attributes = idle_connection_fill_contact_attributes; param_spec = g_param_spec_string("nickname", "IRC nickname", "The nickname to be visible to others in IRC.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property(object_class, PROP_NICKNAME, param_spec); @@ -533,7 +527,6 @@ static void idle_connection_class_init(IdleConnectionClass *klass) { param_spec = g_param_spec_boolean("password-prompt", "Password prompt", "Whether the connection should pop up a SASL channel if no password is given", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); g_object_class_install_property(object_class, PROP_PASSWORD_PROMPT, param_spec); - tp_contacts_mixin_class_init (object_class, G_STRUCT_OFFSET (IdleConnectionClass, contacts)); idle_contact_info_class_init(klass); /* This is a hack to make the test suite run in finite time. */ @@ -568,7 +561,7 @@ static GPtrArray *_iface_create_channel_managers(TpBaseConnection *base) { } static void _iface_create_handle_repos(TpBaseConnection *self, TpHandleRepoIface **repos) { - for (int i = 0; i < TP_NUM_HANDLE_TYPES; i++) + for (int i = 0; i < TP_NUM_ENTITY_TYPES; i++) repos[i] = NULL; idle_handle_repos_init(repos); @@ -652,7 +645,8 @@ static void _connection_disconnect_with_gerror(IdleConnection *conn, TpConnectio if (tp_base_connection_get_status (TP_BASE_CONNECTION (conn)) == TP_CONNECTION_STATUS_DISCONNECTED) { IDLE_DEBUG ("Already disconnected; refusing to report error %s", error->message); } else { - GHashTable *details = tp_asv_new(key, G_TYPE_STRING, error->message, NULL); + GVariant *details = g_variant_new_parsed ( + "{ '%s': <%s> }", key, error->message); g_assert(error->domain == TP_ERROR); @@ -660,7 +654,6 @@ static void _connection_disconnect_with_gerror(IdleConnection *conn, TpConnectio tp_error_get_dbus_name(error->code), details, reason); - g_hash_table_unref(details); } } @@ -1087,7 +1080,9 @@ static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessa tp_base_connection_set_self_handle(TP_BASE_CONNECTION(conn), new_handle); } - tp_svc_connection_interface_renaming_emit_renamed(conn, old_handle, new_handle); + tp_svc_connection_interface_renaming1_emit_renamed(conn, old_handle, new_handle, + tp_handle_inspect (tp_base_connection_get_handles ( + TP_BASE_CONNECTION (conn), TP_ENTITY_TYPE_CONTACT), new_handle)); idle_connection_emit_queued_aliases_changed(conn); @@ -1153,7 +1148,7 @@ static IdleParserHandlerResult _version_privmsg_handler(IdleParser *parser, Idle return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; handle = g_value_get_uint(g_value_array_get_nth(args, 0)); - nick = tp_handle_inspect(tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_HANDLE_TYPE_CONTACT), handle); + nick = tp_handle_inspect(tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_ENTITY_TYPE_CONTACT), handle); reply = g_strdup_printf("VERSION telepathy-idle %s Telepathy IM/VoIP Framework http://telepathy.freedesktop.org", VERSION); idle_ctcp_notice(nick, reply, conn); @@ -1269,24 +1264,21 @@ _queue_alias_changed(IdleConnection *conn, TpHandle handle, const gchar *alias) IdleConnectionPrivate *priv = conn->priv; if (!priv->queued_aliases_owners) { - TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_ENTITY_TYPE_CONTACT); priv->queued_aliases_owners = tp_handle_set_new(handles); } tp_handle_set_add(priv->queued_aliases_owners, handle); if (!priv->queued_aliases) - priv->queued_aliases = g_ptr_array_new(); + priv->queued_aliases = g_hash_table_new_full (NULL, NULL, NULL, g_free); - g_ptr_array_add(priv->queued_aliases, - tp_value_array_build (2, - G_TYPE_UINT, handle, - G_TYPE_STRING, alias, - G_TYPE_INVALID)); + g_hash_table_insert (priv->queued_aliases, GUINT_TO_POINTER (handle), + g_strdup (alias)); } void idle_connection_canon_nick_receive(IdleConnection *conn, TpHandle handle, const gchar *canon_nick) { - TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_ENTITY_TYPE_CONTACT); const gchar *old_alias = g_hash_table_lookup (conn->priv->aliases, GUINT_TO_POINTER (handle)); if (!old_alias) @@ -1306,20 +1298,15 @@ void idle_connection_emit_queued_aliases_changed(IdleConnection *conn) { if (!priv->queued_aliases) return; - tp_svc_connection_interface_aliasing_emit_aliases_changed(conn, priv->queued_aliases); + tp_svc_connection_interface_aliasing1_emit_aliases_changed(conn, priv->queued_aliases); - g_ptr_array_foreach(priv->queued_aliases, _free_alias_pair, NULL); - g_ptr_array_free(priv->queued_aliases, TRUE); + g_hash_table_unref (priv->queued_aliases); priv->queued_aliases = NULL; tp_handle_set_destroy(priv->queued_aliases_owners); priv->queued_aliases_owners = NULL; } -static void idle_connection_get_alias_flags(TpSvcConnectionInterfaceAliasing *iface, DBusGMethodInvocation *context) { - tp_svc_connection_interface_aliasing_return_from_get_alias_flags(context, 0); -} - static const gchar * gimme_an_alias (IdleConnection *self, TpHandleRepoIface *repo, @@ -1334,72 +1321,36 @@ gimme_an_alias (IdleConnection *self, return tp_handle_inspect (repo, handle); } -static void -conn_aliasing_fill_contact_attributes ( - GObject *obj, - const GArray *contacts, - GHashTable *attributes_hash) +static gboolean +conn_aliasing_fill_contact_attributes (IdleConnection *self, + const gchar *dbus_interface, + TpHandle handle, + GVariantDict *attributes) { - IdleConnection *self = IDLE_CONNECTION (obj); - TpHandleRepoIface *repo = tp_base_connection_get_handles ( - TP_BASE_CONNECTION (self), TP_HANDLE_TYPE_CONTACT); - guint i; - - for (i = 0; i < contacts->len; i++) + if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1)) { - TpHandle handle = g_array_index (contacts, TpHandle, i); + TpHandleRepoIface *repo = tp_base_connection_get_handles ( + TP_BASE_CONNECTION (self), TP_ENTITY_TYPE_CONTACT); const gchar *alias = gimme_an_alias (self, repo, handle); g_assert (alias != NULL); - - tp_contacts_mixin_set_contact_attribute (attributes_hash, - handle, TP_IFACE_CONNECTION_INTERFACE_ALIASING"/alias", - tp_g_value_slice_new_string (alias)); + g_variant_dict_insert_value (attributes, + TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, + g_variant_new_string (alias)); + return TRUE; } -} - -static void -idle_connection_get_aliases ( - TpSvcConnectionInterfaceAliasing *iface, - const GArray *handles, - DBusGMethodInvocation *context) -{ - IdleConnection *self = IDLE_CONNECTION (iface); - TpHandleRepoIface *repo = tp_base_connection_get_handles ( - TP_BASE_CONNECTION (iface), TP_HANDLE_TYPE_CONTACT); - GError *error = NULL; - GHashTable *aliases; - if (!tp_handles_are_valid (repo, handles, FALSE, &error)) - { - dbus_g_method_return_error(context, error); - g_error_free(error); - return; - } - - aliases = g_hash_table_new (NULL, NULL); - - for (guint i = 0; i < handles->len; i++) - { - TpHandle handle = g_array_index (handles, TpHandle, i); - - g_hash_table_insert (aliases, GUINT_TO_POINTER (handle), - (gpointer) gimme_an_alias (self, repo, handle)); - } - - tp_svc_connection_interface_aliasing_return_from_get_aliases (context, - aliases); - g_hash_table_unref (aliases); + return FALSE; } -static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing *iface, const GArray *handles, DBusGMethodInvocation *context) { +static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing1 *iface, const GArray *handles, GDBusMethodInvocation *context) { IdleConnection *self = IDLE_CONNECTION (iface); - TpHandleRepoIface *repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(iface), TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(iface), TP_ENTITY_TYPE_CONTACT); GError *error = NULL; const gchar **aliases; if (!tp_handles_are_valid(repo, handles, FALSE, &error)) { - dbus_g_method_return_error(context, error); + g_dbus_method_invocation_return_gerror(context, error); g_error_free(error); return; } @@ -1411,12 +1362,12 @@ static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing *if aliases[i] = gimme_an_alias (self, repo, handle); } - tp_svc_connection_interface_aliasing_return_from_request_aliases(context, aliases); + tp_svc_connection_interface_aliasing1_return_from_request_aliases(context, aliases); g_free(aliases); } -static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBusGMethodInvocation *context) { - TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(obj), TP_HANDLE_TYPE_CONTACT); +static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, GDBusMethodInvocation *context) { + TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(obj), TP_ENTITY_TYPE_CONTACT); TpHandle handle = tp_handle_ensure(handles, nick, NULL, NULL); gchar msg[IRC_MSG_MAXLEN + 1]; @@ -1424,7 +1375,7 @@ static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBu GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Invalid nickname requested"}; IDLE_DEBUG("failed to get handle for \"%s\"", nick); - dbus_g_method_return_error(context, &error); + g_dbus_method_invocation_return_gerror(context, &error); return FALSE; } @@ -1436,29 +1387,29 @@ static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBu } static void -idle_connection_request_rename (TpSvcConnectionInterfaceRenaming *iface, +idle_connection_request_rename (TpSvcConnectionInterfaceRenaming1 *iface, const gchar *nick, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { IdleConnection *conn = IDLE_CONNECTION(iface); if (_send_rename_request(conn, nick, context)) - tp_svc_connection_interface_renaming_return_from_request_rename(context); + tp_svc_connection_interface_renaming1_return_from_request_rename(context); } -static void idle_connection_set_aliases(TpSvcConnectionInterfaceAliasing *iface, GHashTable *aliases, DBusGMethodInvocation *context) { +static void idle_connection_set_aliases(TpSvcConnectionInterfaceAliasing1 *iface, GHashTable *aliases, GDBusMethodInvocation *context) { IdleConnection *conn = IDLE_CONNECTION(iface); const gchar *requested_alias = g_hash_table_lookup(aliases, GUINT_TO_POINTER(tp_base_connection_get_self_handle (TP_BASE_CONNECTION (conn)))); if ((g_hash_table_size(aliases) != 1) || !requested_alias) { GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "You can only set your own alias in IRC"}; - dbus_g_method_return_error(context, &error); + g_dbus_method_invocation_return_gerror(context, &error); return; } if (_send_rename_request(conn, requested_alias, context)) - tp_svc_connection_interface_aliasing_return_from_set_aliases(context); + tp_svc_connection_interface_aliasing1_return_from_set_aliases(context); } static gboolean idle_connection_hton(IdleConnection *obj, const gchar *input, gchar **output, GError **_error) { @@ -1557,26 +1508,47 @@ idle_connection_ntoh(IdleConnection *obj, const gchar *input) { } static void _aliasing_iface_init(gpointer g_iface, gpointer iface_data) { - TpSvcConnectionInterfaceAliasingClass *klass = (TpSvcConnectionInterfaceAliasingClass *) g_iface; + TpSvcConnectionInterfaceAliasing1Class *klass = (TpSvcConnectionInterfaceAliasing1Class *) g_iface; -#define IMPLEMENT(x) tp_svc_connection_interface_aliasing_implement_##x (\ +#define IMPLEMENT(x) tp_svc_connection_interface_aliasing1_implement_##x (\ klass, idle_connection_##x) - IMPLEMENT(get_alias_flags); - IMPLEMENT(get_aliases); IMPLEMENT(request_aliases); IMPLEMENT(set_aliases); #undef IMPLEMENT } static void _renaming_iface_init(gpointer g_iface, gpointer iface_data) { - TpSvcConnectionInterfaceRenamingClass *klass = g_iface; + TpSvcConnectionInterfaceRenaming1Class *klass = g_iface; -#define IMPLEMENT(x) tp_svc_connection_interface_renaming_implement_##x (\ +#define IMPLEMENT(x) tp_svc_connection_interface_renaming1_implement_##x (\ klass, idle_connection_##x) IMPLEMENT(request_rename); #undef IMPLEMENT } +static void +idle_connection_fill_contact_attributes (TpBaseConnection *base, + const gchar *dbus_interface, + TpHandle handle, + GVariantDict *attributes) +{ + IdleConnection *self = IDLE_CONNECTION (base); + + if (conn_aliasing_fill_contact_attributes (self, + dbus_interface, handle, attributes)) + return; + + /* We don't cache contact info, so we just never put /info into the + * attributes hash. This is spec-compliant: it says the attribute should be + * omitted if unknown. */ + if (!tp_strdiff (dbus_interface, + TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1)) + return; + + TP_BASE_CONNECTION_CLASS (idle_connection_parent_class)-> + fill_contact_attributes (base, dbus_interface, handle, attributes); +} + typedef struct { const gchar *command; @@ -1623,31 +1595,31 @@ check_irc_command (IdleConnection *self, } static void -idle_connection_irc_command_send (IdleSvcConnectionInterfaceIRCCommand1 *iface, +idle_connection_irc_command_send (TpSvcConnectionInterfaceIRCCommand1 *iface, const gchar *command, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { IdleConnection *self = IDLE_CONNECTION(iface); GError *error = NULL; if (!check_irc_command (self, command, &error)) { - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (context, error); g_error_free (error); return; } _send_with_priority (self, command, SERVER_CMD_NORMAL_PRIORITY); - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (context, NULL); } static void irc_command_iface_init(gpointer g_iface, gpointer iface_data) { - IdleSvcConnectionInterfaceIRCCommand1Class *klass = g_iface; + TpSvcConnectionInterfaceIRCCommand1Class *klass = g_iface; -#define IMPLEMENT(x) idle_svc_connection_interface_irc_command1_implement_##x (\ +#define IMPLEMENT(x) tp_svc_connection_interface_irc_command1_implement_##x (\ klass, idle_connection_irc_command_##x) IMPLEMENT(send); #undef IMPLEMENT diff --git a/src/idle-connection.h b/src/idle-connection.h index bd5f903..3b151ab 100644 --- a/src/idle-connection.h +++ b/src/idle-connection.h @@ -36,12 +36,10 @@ typedef struct _IdleConnectionPrivate IdleConnectionPrivate; struct _IdleConnectionClass { TpBaseConnectionClass parent_class; - TpContactsMixinClass contacts; }; struct _IdleConnection { TpBaseConnection parent; - TpContactsMixin contacts; IdleParser *parser; GQueue *contact_info_requests; IdleConnectionPrivate *priv; diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index 07cd9a9..cdafc99 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -37,7 +37,7 @@ struct _ContactInfoRequest { gboolean is_reg_nick; gboolean is_secure; GPtrArray *contact_info; - DBusGMethodInvocation *context; + GDBusMethodInvocation *context; }; /* @@ -96,7 +96,7 @@ static void _dequeue_request_contact_info(IdleConnection *conn) { _send_request_contact_info(conn, request); } -static void _queue_request_contact_info(IdleConnection *conn, guint handle, const gchar *nick, DBusGMethodInvocation *context) { +static void _queue_request_contact_info(IdleConnection *conn, guint handle, const gchar *nick, GDBusMethodInvocation *context) { ContactInfoRequest *request; request = g_slice_new0(ContactInfoRequest); @@ -118,22 +118,22 @@ static void _queue_request_contact_info(IdleConnection *conn, guint handle, cons static void _return_from_request_contact_info(IdleConnection *conn) { ContactInfoRequest *request = g_queue_peek_head(conn->contact_info_requests); - tp_svc_connection_interface_contact_info_return_from_request_contact_info(request->context, request->contact_info); - tp_svc_connection_interface_contact_info_emit_contact_info_changed(conn, request->handle, request->contact_info); + tp_svc_connection_interface_contact_info1_return_from_request_contact_info(request->context, request->contact_info); + tp_svc_connection_interface_contact_info1_emit_contact_info_changed(conn, request->handle, request->contact_info); _dequeue_request_contact_info(conn); } -static void idle_connection_request_contact_info(TpSvcConnectionInterfaceContactInfo *iface, guint contact, DBusGMethodInvocation *context) { +static void idle_connection_request_contact_info(TpSvcConnectionInterfaceContactInfo1 *iface, guint contact, GDBusMethodInvocation *context) { IdleConnection *self = IDLE_CONNECTION(iface); TpBaseConnection *base = TP_BASE_CONNECTION(self); - TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(base, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(base, TP_ENTITY_TYPE_CONTACT); const gchar *nick; GError *error = NULL; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED(base, context); if (!tp_handle_is_valid(contact_handles, contact, &error)) { - dbus_g_method_return_error(context, error); + g_dbus_method_invocation_return_gerror(context, error); g_error_free(error); return; } @@ -205,7 +205,7 @@ static IdleParserHandlerResult _end_of_whois_handler(IdleParser *parser, IdlePar static IdleParserHandlerResult _no_such_server_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); TpBaseConnection *base = TP_BASE_CONNECTION(conn); - TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(base, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(base, TP_ENTITY_TYPE_CONTACT); TpHandle handle; ContactInfoRequest *request; GValueArray *norm_args = g_value_array_copy(args); @@ -234,7 +234,7 @@ static IdleParserHandlerResult _no_such_server_handler(IdleParser *parser, IdleP goto cleanup; error = g_error_new(TP_ERROR, TP_ERROR_DOES_NOT_EXIST, "User '%s' unknown; they may have disconnected", server); - dbus_g_method_return_error(request->context, error); + g_dbus_method_invocation_return_gerror(request->context, error); g_error_free(error); _dequeue_request_contact_info(conn); @@ -268,7 +268,7 @@ static IdleParserHandlerResult _try_again_handler(IdleParser *parser, IdleParser msg = g_value_get_string(g_value_array_get_nth(args, 1)); error = g_error_new_literal(TP_ERROR, TP_ERROR_SERVICE_BUSY, msg); - dbus_g_method_return_error(request->context, error); + g_dbus_method_invocation_return_gerror(request->context, error); g_error_free(error); _dequeue_request_contact_info(conn); @@ -487,28 +487,12 @@ void idle_contact_info_class_init (IdleConnectionClass *klass) { }; tp_dbus_properties_mixin_implement_interface(object_class, - TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO1, idle_contact_info_properties_getter, NULL, props); } -static void -idle_contact_info_fill_contact_attributes ( - GObject *obj, - const GArray *contacts, - GHashTable *attributes_hash) -{ - /* We don't cache contact info, so we just never put /info into the - * attributes hash. This is spec-compliant: we don't implement - * GetContactInfo, and the spec says the attribute should be the same as the - * value returned by that method (or omitted if unknown). This function - * exists at all to make ContactInfo show up in ContactAttributeInterfaces - * (otherwise tp-glib might be justified in falling back to - * GetContactInfo(), which we know will fail). - */ -} - void idle_contact_info_init (IdleConnection *conn) { conn->contact_info_requests = g_queue_new(); @@ -526,16 +510,12 @@ void idle_contact_info_init (IdleConnection *conn) { idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_NOSUCHSERVER, _no_such_server_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_TRYAGAIN, _try_again_handler, conn); - - tp_contacts_mixin_add_contact_attributes_iface ((GObject *) conn, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO, - idle_contact_info_fill_contact_attributes); } void idle_contact_info_iface_init(gpointer g_iface, gpointer iface_data) { - TpSvcConnectionInterfaceContactInfoClass *klass = (TpSvcConnectionInterfaceContactInfoClass *) g_iface; + TpSvcConnectionInterfaceContactInfo1Class *klass = (TpSvcConnectionInterfaceContactInfo1Class *) g_iface; -#define IMPLEMENT(x) tp_svc_connection_interface_contact_info_implement_##x (\ +#define IMPLEMENT(x) tp_svc_connection_interface_contact_info1_implement_##x (\ klass, idle_connection_##x) IMPLEMENT(request_contact_info); #undef IMPLEMENT diff --git a/src/idle-handles.c b/src/idle-handles.c index 0996ba6..834b999 100644 --- a/src/idle-handles.c +++ b/src/idle-handles.c @@ -163,14 +163,14 @@ static gchar *_channel_normalize_func(TpHandleRepoIface *repo, const gchar *id, void idle_handle_repos_init(TpHandleRepoIface **handles) { g_assert(handles != NULL); - handles[TP_HANDLE_TYPE_CONTACT] = (TpHandleRepoIface *) g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, - "handle-type", TP_HANDLE_TYPE_CONTACT, + handles[TP_ENTITY_TYPE_CONTACT] = (TpHandleRepoIface *) g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, + "entity-type", TP_ENTITY_TYPE_CONTACT, "normalize-function", _nick_normalize_func, "default-normalize-context", NULL, NULL); - handles[TP_HANDLE_TYPE_ROOM] = (TpHandleRepoIface *) g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, - "handle-type", TP_HANDLE_TYPE_ROOM, + handles[TP_ENTITY_TYPE_ROOM] = (TpHandleRepoIface *) g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, + "entity-type", TP_ENTITY_TYPE_ROOM, "normalize-function", _channel_normalize_func, "default-normalize-context", NULL, NULL); diff --git a/src/idle-im-channel.c b/src/idle-im-channel.c index 1449a9c..40df806 100644 --- a/src/idle-im-channel.c +++ b/src/idle-im-channel.c @@ -38,9 +38,8 @@ static void idle_im_channel_send (GObject *obj, TpMessage *message, TpMessageSen static void idle_im_channel_finalize (GObject *object); G_DEFINE_TYPE_WITH_CODE(IdleIMChannel, idle_im_channel, TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_text_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_MESSAGES, tp_message_mixin_messages_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE, _destroyable_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE1, _destroyable_iface_init); ) /* private structure */ @@ -90,10 +89,10 @@ idle_im_channel_fill_properties ( tp_dbus_properties_mixin_fill_properties_hash ( G_OBJECT (chan), properties, - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessagePartSupportFlags", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "DeliveryReportingSupport", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "SupportedContentTypes", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessageTypes", + TP_IFACE_CHANNEL_TYPE_TEXT, "MessagePartSupportFlags", + TP_IFACE_CHANNEL_TYPE_TEXT, "DeliveryReportingSupport", + TP_IFACE_CHANNEL_TYPE_TEXT, "SupportedContentTypes", + TP_IFACE_CHANNEL_TYPE_TEXT, "MessageTypes", NULL); } @@ -116,7 +115,7 @@ idle_im_channel_class_init (IdleIMChannelClass *idle_im_channel_class) object_class->finalize = idle_im_channel_finalize; base_class->channel_type = TP_IFACE_CHANNEL_TYPE_TEXT; - base_class->target_handle_type = TP_HANDLE_TYPE_CONTACT; + base_class->target_entity_type = TP_ENTITY_TYPE_CONTACT; base_class->close = idle_im_channel_close; base_class->fill_immutable_properties = idle_im_channel_fill_properties; base_class->get_object_path_suffix = idle_im_channel_get_path_suffix; @@ -174,8 +173,7 @@ idle_im_channel_get_interfaces (TpBaseChannel *channel) TP_BASE_CHANNEL_CLASS (idle_im_channel_parent_class)->get_interfaces ( channel); - g_ptr_array_add (interfaces, TP_IFACE_CHANNEL_INTERFACE_MESSAGES); - g_ptr_array_add (interfaces, TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE); + g_ptr_array_add (interfaces, TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE1); return interfaces; } @@ -184,7 +182,7 @@ idle_im_channel_get_interfaces (TpBaseChannel *channel) * idle_im_channel_send * * Indirectly implements (via TpMessageMixin) D-Bus method Send on interface - * org.freedesktop.Telepathy.Channel.Type.Text and D-Bus method SendMessage on + * im.telepathy.v1.Channel.Type.Text and D-Bus method SendMessage on * Channel.Interface.Messages */ static void @@ -196,7 +194,7 @@ idle_im_channel_send ( TpBaseChannel *base = TP_BASE_CHANNEL (obj); TpBaseConnection *conn = tp_base_channel_get_connection (base); const gchar *recipient = tp_handle_inspect ( - tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT), + tp_base_connection_get_handles (conn, TP_ENTITY_TYPE_CONTACT), tp_base_channel_get_target_handle (base)); idle_text_send (obj, message, flags, recipient, IDLE_CONNECTION (conn)); @@ -204,8 +202,8 @@ idle_im_channel_send ( static void idle_im_channel_destroy ( - TpSvcChannelInterfaceDestroyable *iface, - DBusGMethodInvocation *context) + TpSvcChannelInterfaceDestroyable1 *iface, + GDBusMethodInvocation *context) { TpBaseChannel *chan = TP_BASE_CHANNEL (iface); GObject *obj = (GObject *) chan; @@ -216,7 +214,7 @@ idle_im_channel_destroy ( tp_message_mixin_clear (obj); tp_base_channel_destroyed (chan); - tp_svc_channel_interface_destroyable_return_from_destroy(context); + tp_svc_channel_interface_destroyable1_return_from_destroy(context); } static void @@ -224,7 +222,7 @@ _destroyable_iface_init ( gpointer klass, gpointer iface_data) { -#define IMPLEMENT(x) tp_svc_channel_interface_destroyable_implement_##x (\ +#define IMPLEMENT(x) tp_svc_channel_interface_destroyable1_implement_##x (\ klass, idle_im_channel_##x) IMPLEMENT (destroy); #undef IMPLEMENT diff --git a/src/idle-im-manager.c b/src/idle-im-manager.c index 914306b..4f5ed9f 100644 --- a/src/idle-im-manager.c +++ b/src/idle-im-manager.c @@ -48,7 +48,7 @@ enum { static const gchar * const im_channel_fixed_properties[] = { TP_IFACE_CHANNEL ".ChannelType", - TP_IFACE_CHANNEL ".TargetHandleType", + TP_IFACE_CHANNEL ".TargetEntityType", NULL }; @@ -73,15 +73,14 @@ static IdleParserHandlerResult _notice_privmsg_handler(IdleParser *parser, IdleP static void _im_manager_close_all(IdleIMManager *manager); static void connection_status_changed_cb (IdleConnection* conn, guint status, guint reason, IdleIMManager *self); -static void _im_manager_foreach(TpChannelManager *manager, TpExportableChannelFunc func, gpointer user_data); +static void _im_manager_foreach(TpChannelManager *manager, TpBaseChannelFunc func, gpointer user_data); static void _im_manager_type_foreach_class (GType type, TpChannelManagerTypeChannelClassFunc func, gpointer user_data); -//static TpChannelManagerRequestStatus _iface_request(TpChannelFactoryIface *iface, const gchar *chan_type, TpHandleType handle_type, guint handle, gpointer request, TpChannelIface **new_chan, GError **error); +//static TpChannelManagerRequestStatus _iface_request(TpChannelFactoryIface *iface, const gchar *chan_type, TpEntityType entity_type, guint handle, gpointer request, TpChannelIface **new_chan, GError **error); -static gboolean _im_manager_create_channel(TpChannelManager *manager, gpointer request_token, GHashTable *request_properties); -static gboolean _im_manager_request_channel(TpChannelManager *manager, gpointer request_token, GHashTable *request_properties); -static gboolean _im_manager_ensure_channel(TpChannelManager *manager, gpointer request_token, GHashTable *request_properties); -static gboolean _im_manager_requestotron (IdleIMManager *self, gpointer request_token, GHashTable *request_properties, gboolean require_new); +static gboolean _im_manager_create_channel(TpChannelManager *manager, TpChannelManagerRequest *request, GHashTable *request_properties); +static gboolean _im_manager_ensure_channel(TpChannelManager *manager, TpChannelManagerRequest *request, GHashTable *request_properties); +static gboolean _im_manager_requestotron (IdleIMManager *self, TpChannelManagerRequest *request, GHashTable *request_properties, gboolean require_new); static IdleIMChannel *_im_manager_new_channel (IdleIMManager *mgr, TpHandle handle, TpHandle initiator, gpointer request); static void _im_channel_closed_cb (IdleIMChannel *chan, gpointer user_data); @@ -228,7 +227,7 @@ static void connection_status_changed_cb (IdleConnection* conn, } struct _ForeachHelperData { - TpExportableChannelFunc func; + TpBaseChannelFunc func; gpointer user_data; }; @@ -237,7 +236,7 @@ static void _foreach_helper(gpointer key, gpointer value, gpointer user_data) { data->func(value, data->user_data); } -static void _im_manager_foreach(TpChannelManager *manager, TpExportableChannelFunc func, gpointer user_data) { +static void _im_manager_foreach(TpChannelManager *manager, TpBaseChannelFunc func, gpointer user_data) { IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE(manager); struct _ForeachHelperData data = {func, user_data}; @@ -265,7 +264,7 @@ static void _im_manager_type_foreach_class (GType type, g_hash_table_insert (table, (gpointer) im_channel_fixed_properties[0], value); value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT); + g_value_set_uint (value, TP_ENTITY_TYPE_CONTACT); g_hash_table_insert (table, (gpointer) im_channel_fixed_properties[1], value); func (type, table, im_channel_allowed_properties, user_data); @@ -276,60 +275,47 @@ static void _im_manager_type_foreach_class (GType type, static gboolean _im_manager_create_channel(TpChannelManager *manager, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties) { IdleIMManager *self = IDLE_IM_MANAGER (manager); - return _im_manager_requestotron (self, request_token, request_properties, + return _im_manager_requestotron (self, request, request_properties, TRUE); } - -static gboolean -_im_manager_request_channel(TpChannelManager *manager, - gpointer request_token, - GHashTable *request_properties) -{ - IdleIMManager *self = IDLE_IM_MANAGER (manager); - - return _im_manager_requestotron (self, request_token, request_properties, - FALSE); -} - - static gboolean _im_manager_ensure_channel(TpChannelManager *manager, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties) { IdleIMManager *self = IDLE_IM_MANAGER (manager); - return _im_manager_requestotron (self, request_token, request_properties, + return _im_manager_requestotron (self, request, request_properties, FALSE); } static gboolean _im_manager_requestotron (IdleIMManager *self, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties, gboolean require_new) { IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE (self); TpBaseConnection *base_conn = (TpBaseConnection *) priv->conn; TpHandleRepoIface *contact_repo = - tp_base_connection_get_handles (base_conn, TP_HANDLE_TYPE_CONTACT); + tp_base_connection_get_handles (base_conn, TP_ENTITY_TYPE_CONTACT); TpHandle handle; GError *error = NULL; - TpExportableChannel *channel; + TpBaseChannel *channel; if (tp_strdiff (tp_asv_get_string (request_properties, TP_IFACE_CHANNEL ".ChannelType"), TP_IFACE_CHANNEL_TYPE_TEXT)) return FALSE; if (tp_asv_get_uint32 (request_properties, - TP_IFACE_CHANNEL ".TargetHandleType", NULL) != TP_HANDLE_TYPE_CONTACT) + TP_IFACE_CHANNEL ".TargetEntityType", NULL) != TP_ENTITY_TYPE_CONTACT) return FALSE; handle = tp_asv_get_uint32 (request_properties, @@ -359,7 +345,7 @@ _im_manager_requestotron (IdleIMManager *self, if (channel == NULL) { - _im_manager_new_channel (self, handle, tp_base_connection_get_self_handle (base_conn), request_token); + _im_manager_new_channel (self, handle, tp_base_connection_get_self_handle (base_conn), request); return TRUE; } @@ -370,12 +356,12 @@ _im_manager_requestotron (IdleIMManager *self, goto error; } - tp_channel_manager_emit_request_already_satisfied (self, request_token, + tp_channel_manager_emit_request_already_satisfied (TP_CHANNEL_MANAGER (self), request, channel); return TRUE; error: - tp_channel_manager_emit_request_failed (self, request_token, + tp_channel_manager_emit_request_failed (TP_CHANNEL_MANAGER (self), request, error->domain, error->code, error->message); g_error_free (error); return TRUE; @@ -390,9 +376,6 @@ _im_channel_closed_cb (IdleIMChannel *chan, IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE (self); TpBaseChannel *base = TP_BASE_CHANNEL (chan); - tp_channel_manager_emit_channel_closed_for_object (self, - TP_EXPORTABLE_CHANNEL (chan)); - if (priv->channels) { TpHandle handle = tp_base_channel_get_target_handle (base); @@ -401,11 +384,15 @@ _im_channel_closed_cb (IdleIMChannel *chan, { IDLE_DEBUG ("removing channel with handle %u", handle); g_hash_table_remove (priv->channels, GUINT_TO_POINTER (handle)); + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self), + base); } else { IDLE_DEBUG ("reopening channel with handle %u due to pending messages", handle); - tp_channel_manager_emit_new_channel (self, - (TpExportableChannel *) chan, NULL); + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self), + base); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (self), + base, NULL); } } } @@ -420,7 +407,7 @@ _im_manager_new_channel (IdleIMManager *mgr, IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE (mgr); TpBaseConnection *base_connection = TP_BASE_CONNECTION (priv->conn); TpHandleRepoIface *handle_repo = - tp_base_connection_get_handles (base_connection, TP_HANDLE_TYPE_CONTACT); + tp_base_connection_get_handles (base_connection, TP_ENTITY_TYPE_CONTACT); IdleIMChannel *chan; const gchar *name; GSList *requests = NULL; @@ -443,8 +430,8 @@ _im_manager_new_channel (IdleIMManager *mgr, if (request != NULL) requests = g_slist_prepend (requests, request); - tp_channel_manager_emit_new_channel (mgr, TP_EXPORTABLE_CHANNEL (chan), - requests); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (mgr), + TP_BASE_CHANNEL (chan), requests); g_slist_free (requests); @@ -458,7 +445,6 @@ static void _im_manager_iface_init(gpointer g_iface, gpointer iface_data) { iface->foreach_channel = _im_manager_foreach; iface->type_foreach_channel_class = _im_manager_type_foreach_class; - iface->request_channel = _im_manager_request_channel; iface->create_channel = _im_manager_create_channel; iface->ensure_channel = _im_manager_ensure_channel; } diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index c335efa..7ee6313 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -46,15 +46,14 @@ static void idle_muc_channel_send (GObject *obj, TpMessage *message, TpMessageSe static void idle_muc_channel_close (TpBaseChannel *base); G_DEFINE_TYPE_WITH_CODE(IdleMUCChannel, idle_muc_channel, TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP, tp_group_mixin_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_PASSWORD, _password_iface_init); - G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_text_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_MESSAGES, tp_message_mixin_messages_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_ROOM, NULL); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_SUBJECT, subject_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_ROOM_CONFIG, + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP1, tp_group_mixin_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_PASSWORD1, _password_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_ROOM1, NULL); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_SUBJECT1, subject_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_ROOM_CONFIG1, tp_base_room_config_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE, destroyable_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE1, destroyable_iface_init); ) /* property enum */ @@ -121,13 +120,12 @@ typedef struct { } IRCChannelModeState; static const gchar *muc_channel_interfaces[] = { - TP_IFACE_CHANNEL_INTERFACE_PASSWORD, - TP_IFACE_CHANNEL_INTERFACE_GROUP, - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, - TP_IFACE_CHANNEL_INTERFACE_ROOM, - TP_IFACE_CHANNEL_INTERFACE_SUBJECT, - TP_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG, - TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE, + TP_IFACE_CHANNEL_INTERFACE_PASSWORD1, + TP_IFACE_CHANNEL_INTERFACE_GROUP1, + TP_IFACE_CHANNEL_INTERFACE_ROOM1, + TP_IFACE_CHANNEL_INTERFACE_SUBJECT1, + TP_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG1, + TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE1, NULL }; @@ -157,7 +155,7 @@ struct _IdleMUCChannelPrivate { guint password_flags; - DBusGMethodInvocation *passwd_ctx; + GDBusMethodInvocation *passwd_ctx; /* NAMEREPLY MembersChanged aggregation */ TpHandleSet *namereply_set; @@ -189,14 +187,42 @@ static void idle_muc_channel_dispose (GObject *object); static void idle_muc_channel_finalize (GObject *object); static void +change_members (GObject *obj, + const gchar *message, + const TpIntset *add, + const TpIntset *del, + const TpIntset *add_local_pending, + const TpIntset *add_remote_pending, + TpHandle actor, + TpChannelGroupChangeReason reason) +{ + GVariantDict details; + + g_variant_dict_init (&details, NULL); + + g_variant_dict_insert_value (&details, "actor", + g_variant_new_uint32 (actor)); + g_variant_dict_insert_value (&details, "change-reason", + g_variant_new_uint32 (reason)); + + if (message != NULL) + g_variant_dict_insert_value (&details, "message", + g_variant_new_string (message)); + + tp_group_mixin_change_members (obj, + add, del, add_local_pending, add_remote_pending, + g_variant_dict_end (&details)); +} + +static void idle_muc_channel_constructed (GObject *obj) { IdleMUCChannel *self = IDLE_MUC_CHANNEL (obj); TpBaseChannel *base = TP_BASE_CHANNEL (obj); IdleMUCChannelPrivate *priv = self->priv; TpBaseConnection *conn = tp_base_channel_get_connection (base); - TpHandleRepoIface *room_handles = tp_base_connection_get_handles(conn, TP_HANDLE_TYPE_ROOM); - TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(conn, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *room_handles = tp_base_connection_get_handles(conn, TP_ENTITY_TYPE_ROOM); + TpHandleRepoIface *contact_handles = tp_base_connection_get_handles(conn, TP_ENTITY_TYPE_CONTACT); TpChannelTextMessageType types[] = { TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, @@ -216,7 +242,6 @@ idle_muc_channel_constructed (GObject *obj) tp_base_channel_register (base); tp_group_mixin_init(obj, G_STRUCT_OFFSET(IdleMUCChannel, group), contact_handles, self_handle); - tp_group_mixin_change_flags(obj, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0); /* initialize message mixin */ tp_message_mixin_init (obj, G_STRUCT_OFFSET (IdleMUCChannel, message_mixin), @@ -234,7 +259,7 @@ idle_muc_channel_constructed (GObject *obj) g_assert (initiator == self_handle); remote = tp_intset_new_containing (initiator); - tp_group_mixin_change_members (obj, "", NULL, NULL, NULL, remote, + change_members (obj, "", NULL, NULL, NULL, remote, initiator, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); tp_intset_destroy (remote); } @@ -298,12 +323,12 @@ idle_muc_channel_fill_immutable_properties ( tp_dbus_properties_mixin_fill_properties_hash ( G_OBJECT (chan), properties, - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessagePartSupportFlags", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "DeliveryReportingSupport", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "SupportedContentTypes", - TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessageTypes", - TP_IFACE_CHANNEL_INTERFACE_ROOM, "RoomName", - TP_IFACE_CHANNEL_INTERFACE_ROOM, "Server", + TP_IFACE_CHANNEL_TYPE_TEXT, "MessagePartSupportFlags", + TP_IFACE_CHANNEL_TYPE_TEXT, "DeliveryReportingSupport", + TP_IFACE_CHANNEL_TYPE_TEXT, "SupportedContentTypes", + TP_IFACE_CHANNEL_TYPE_TEXT, "MessageTypes", + TP_IFACE_CHANNEL_INTERFACE_ROOM1, "RoomName", + TP_IFACE_CHANNEL_INTERFACE_ROOM1, "Server", NULL); } @@ -347,7 +372,7 @@ static void idle_muc_channel_class_init (IdleMUCChannelClass *idle_muc_channel_c object_class->finalize = idle_muc_channel_finalize; base_channel_class->channel_type = TP_IFACE_CHANNEL_TYPE_TEXT; - base_channel_class->target_handle_type = TP_HANDLE_TYPE_ROOM; + base_channel_class->target_entity_type = TP_ENTITY_TYPE_ROOM; base_channel_class->close = idle_muc_channel_close; base_channel_class->fill_immutable_properties = idle_muc_channel_fill_immutable_properties; @@ -404,11 +429,11 @@ static void idle_muc_channel_class_init (IdleMUCChannelClass *idle_muc_channel_c tp_base_room_config_register_class (base_channel_class); tp_dbus_properties_mixin_implement_interface (object_class, - TP_IFACE_QUARK_CHANNEL_INTERFACE_ROOM, + TP_IFACE_QUARK_CHANNEL_INTERFACE_ROOM1, tp_dbus_properties_mixin_getter_gobject_properties, NULL, room_props); tp_dbus_properties_mixin_implement_interface (object_class, - TP_IFACE_QUARK_CHANNEL_INTERFACE_SUBJECT, + TP_IFACE_QUARK_CHANNEL_INTERFACE_SUBJECT1, tp_dbus_properties_mixin_getter_gobject_properties, NULL, subject_props); } @@ -470,7 +495,7 @@ static void provide_password_reply(IdleMUCChannel *chan, gboolean success) { priv = chan->priv; if (priv->passwd_ctx != NULL) { - tp_svc_channel_interface_password_return_from_provide_password(priv->passwd_ctx, success); + tp_svc_channel_interface_password1_return_from_provide_password(priv->passwd_ctx, success); priv->passwd_ctx = NULL; } else { IDLE_DEBUG("don't have a ProvidePassword context to return with! (%s, aka %u)", @@ -542,7 +567,7 @@ idle_muc_channel_update_can_set_topic ( priv->can_set_topic = !!can_set_topic; tp_dbus_properties_mixin_emit_properties_changed (G_OBJECT (self), - TP_IFACE_CHANNEL_INTERFACE_SUBJECT, changed); + TP_IFACE_CHANNEL_INTERFACE_SUBJECT1, changed); } static void change_mode_state(IdleMUCChannel *obj, guint add, guint remove) { @@ -695,7 +720,7 @@ static void change_password_flags(IdleMUCChannel *obj, guint flag, gboolean stat if (add | remove) { IDLE_DEBUG("emitting PASSWORD_FLAGS_CHANGED with %u %u", add, remove); - tp_svc_channel_interface_password_emit_password_flags_changed((TpSvcChannelInterfacePassword *)(obj), add, remove); + tp_svc_channel_interface_password1_emit_password_flags_changed((TpSvcChannelInterfacePassword1 *)(obj), add, remove); } } @@ -742,7 +767,7 @@ void idle_muc_channel_join(IdleMUCChannel *chan, TpHandle joiner) { if (joiner == tp_base_connection_get_self_handle (base_conn)) { /* woot we managed to get into a channel, great */ change_state(chan, MUC_STATE_JOINED); - tp_group_mixin_change_members((GObject *)(chan), NULL, set, NULL, NULL, NULL, joiner, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); + change_members((GObject *)(chan), NULL, set, NULL, NULL, NULL, joiner, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); tp_group_mixin_change_flags((GObject *)(chan), TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_MESSAGE_DEPART, @@ -754,7 +779,7 @@ void idle_muc_channel_join(IdleMUCChannel *chan, TpHandle joiner) { /* according to IRC specs, PLUS channels do not support channel modes and alway have only +t set, so we work with that. */ change_mode_state(chan, MODE_FLAG_TOPIC_ONLY_SETTABLE_BY_OPS, 0); } else { - tp_group_mixin_change_members((GObject *)(chan), NULL, set, NULL, NULL, NULL, joiner, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); + change_members((GObject *)(chan), NULL, set, NULL, NULL, NULL, joiner, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); } IDLE_DEBUG("member joined with handle %u", joiner); @@ -768,7 +793,7 @@ static void _network_member_left(IdleMUCChannel *chan, TpHandle leaver, TpHandle TpIntset *set = tp_intset_new(); tp_intset_add(set, leaver); - tp_group_mixin_change_members((GObject *) chan, message, NULL, set, NULL, NULL, actor, reason); + change_members((GObject *) chan, message, NULL, set, NULL, NULL, actor, reason); if (leaver == tp_base_connection_get_self_handle (base_conn)) { change_state(chan, MUC_STATE_PARTED); @@ -802,7 +827,7 @@ void idle_muc_channel_invited(IdleMUCChannel *chan, TpHandle inviter) { tp_intset_add(add, inviter); tp_intset_add(local, tp_base_connection_get_self_handle (base_conn)); - tp_group_mixin_change_members((GObject *)(chan), NULL, add, NULL, local, NULL, inviter, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); + change_members((GObject *)(chan), NULL, add, NULL, local, NULL, inviter, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); tp_intset_destroy(add); tp_intset_destroy(local); @@ -814,7 +839,7 @@ void idle_muc_channel_namereply(IdleMUCChannel *chan, GValueArray *args) { TpBaseConnection *base_conn = tp_base_channel_get_connection (base); if (!priv->namereply_set) - priv->namereply_set = tp_handle_set_new(tp_base_connection_get_handles(base_conn, TP_HANDLE_TYPE_CONTACT)); + priv->namereply_set = tp_handle_set_new(tp_base_connection_get_handles(base_conn, TP_ENTITY_TYPE_CONTACT)); for (guint i = 1; (i + 1) < args->n_values; i += 2) { TpHandle handle = g_value_get_uint(g_value_array_get_nth(args, i)); @@ -861,7 +886,7 @@ void idle_muc_channel_namereply_end(IdleMUCChannel *chan) { idle_connection_emit_queued_aliases_changed(IDLE_CONNECTION (base_conn)); - tp_group_mixin_change_members((GObject *) chan, NULL, tp_handle_set_peek(priv->namereply_set), NULL, NULL, NULL, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); + change_members((GObject *) chan, NULL, tp_handle_set_peek(priv->namereply_set), NULL, NULL, NULL, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); tp_handle_set_destroy(priv->namereply_set); priv->namereply_set = NULL; @@ -884,7 +909,7 @@ void idle_muc_channel_mode(IdleMUCChannel *chan, GValueArray *args) { IdleMUCChannelPrivate *priv = chan->priv; TpBaseChannel *base = TP_BASE_CHANNEL (chan); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); - TpHandleRepoIface *handles = tp_base_connection_get_handles(base_conn, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *handles = tp_base_connection_get_handles(base_conn, TP_ENTITY_TYPE_CONTACT); tp_base_room_config_set_retrieved (priv->room_config); @@ -1054,7 +1079,7 @@ idle_muc_channel_topic_full ( TpBaseChannel *base = TP_BASE_CHANNEL (self); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); TpHandleRepoIface *handles = tp_base_connection_get_handles (base_conn, - TP_HANDLE_TYPE_CONTACT); + TP_ENTITY_TYPE_CONTACT); guint i = 0; static const gchar *changed[] = { NULL, NULL, NULL, NULL, NULL }; @@ -1085,7 +1110,7 @@ idle_muc_channel_topic_full ( priv->mode_state.topic_toucher_id = ""; tp_dbus_properties_mixin_emit_properties_changed (G_OBJECT (self), - TP_IFACE_CHANNEL_INTERFACE_SUBJECT, changed); + TP_IFACE_CHANNEL_INTERFACE_SUBJECT1, changed); } void @@ -1136,7 +1161,7 @@ void idle_muc_channel_rename(IdleMUCChannel *chan, TpHandle old_handle, TpHandle else goto cleanup; - tp_group_mixin_change_members((GObject *) chan, NULL, add, remove, local, remote, new_handle, TP_CHANNEL_GROUP_CHANGE_REASON_RENAMED); + change_members((GObject *) chan, NULL, add, remove, local, remote, new_handle, TP_CHANNEL_GROUP_CHANGE_REASON_RENAMED); cleanup: @@ -1178,7 +1203,7 @@ static gboolean send_invite_request(IdleMUCChannel *obj, TpHandle handle, GError priv = obj->priv; - nick = tp_handle_inspect(tp_base_connection_get_handles(base_conn, TP_HANDLE_TYPE_CONTACT), handle); + nick = tp_handle_inspect(tp_base_connection_get_handles(base_conn, TP_ENTITY_TYPE_CONTACT), handle); if ((nick == NULL) || (nick[0] == '\0')) { IDLE_DEBUG("invalid handle %u passed", handle); @@ -1206,7 +1231,7 @@ static gboolean send_kick_request(IdleMUCChannel *obj, TpHandle handle, const gc priv = obj->priv; - nick = tp_handle_inspect(tp_base_connection_get_handles(base_conn, TP_HANDLE_TYPE_CONTACT), handle); + nick = tp_handle_inspect(tp_base_connection_get_handles(base_conn, TP_ENTITY_TYPE_CONTACT), handle); if ((nick == NULL) || (nick[0] == '\0')) { IDLE_DEBUG("invalid handle %u passed", handle); @@ -1250,7 +1275,7 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, tp_intset_add(add_set, handle); - tp_group_mixin_change_members(gobj, message, NULL, NULL, NULL, add_set, handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); + change_members(gobj, message, NULL, NULL, NULL, add_set, handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); } } else { if (tp_handle_set_is_member(obj->group.members, handle) || tp_handle_set_is_member(obj->group.remote_pending, handle)) { @@ -1274,7 +1299,7 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, tp_intset_add(add_set, handle); - tp_group_mixin_change_members(gobj, NULL, NULL, NULL, NULL, add_set, self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); + change_members(gobj, NULL, NULL, NULL, NULL, add_set, self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); } } @@ -1346,8 +1371,8 @@ idle_muc_channel_close ( static void idle_muc_channel_destroy ( - TpSvcChannelInterfaceDestroyable *object, - DBusGMethodInvocation *context) + TpSvcChannelInterfaceDestroyable1 *object, + GDBusMethodInvocation *context) { TpBaseChannel *base = TP_BASE_CHANNEL (object); IdleMUCChannel *self = IDLE_MUC_CHANNEL (object); @@ -1362,11 +1387,11 @@ idle_muc_channel_destroy ( if (priv->state < MUC_STATE_JOINED) tp_base_channel_destroyed (base); - tp_svc_channel_interface_destroyable_return_from_destroy (context); + tp_svc_channel_interface_destroyable1_return_from_destroy (context); } -static void idle_muc_channel_get_password_flags (TpSvcChannelInterfacePassword *iface, DBusGMethodInvocation *context) { +static void idle_muc_channel_get_password_flags (TpSvcChannelInterfacePassword1 *iface, GDBusMethodInvocation *context) { IdleMUCChannel *obj = IDLE_MUC_CHANNEL(iface); IdleMUCChannelPrivate *priv; @@ -1375,11 +1400,11 @@ static void idle_muc_channel_get_password_flags (TpSvcChannelInterfacePassword * priv = obj->priv; - tp_svc_channel_interface_password_return_from_get_password_flags(context, priv->password_flags); + tp_svc_channel_interface_password1_return_from_get_password_flags(context, priv->password_flags); } -static void idle_muc_channel_provide_password (TpSvcChannelInterfacePassword *iface, const gchar * password, DBusGMethodInvocation *context) { +static void idle_muc_channel_provide_password (TpSvcChannelInterfacePassword1 *iface, const gchar * password, GDBusMethodInvocation *context) { IdleMUCChannel *obj = IDLE_MUC_CHANNEL(iface); IdleMUCChannelPrivate *priv; @@ -1393,7 +1418,7 @@ static void idle_muc_channel_provide_password (TpSvcChannelInterfacePassword *if "don't need a password now or authentication already " "in progress (%s)", priv->channel_name); IDLE_DEBUG ("%s", error->message); - dbus_g_method_return_error(context, error); + g_dbus_method_invocation_return_gerror(context, error); g_error_free(error); return; } @@ -1407,7 +1432,7 @@ static void idle_muc_channel_provide_password (TpSvcChannelInterfacePassword *if * idle_muc_channel_send * * Indirectly implements (via TpMessageMixin) D-Bus method Send on interface - * org.freedesktop.Telepathy.Channel.Type.Text and D-Bus method SendMessage on + * im.telepathy.v1.Channel.Type.Text and D-Bus method SendMessage on * Channel.Interface.Messages */ static void @@ -1431,9 +1456,9 @@ idle_muc_channel_send (GObject *obj, TpMessage *message, TpMessageSendingFlags f static void idle_muc_channel_set_subject ( - TpSvcChannelInterfaceSubject *iface, + TpSvcChannelInterfaceSubject1 *iface, const gchar *subject, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { IdleMUCChannel *self = IDLE_MUC_CHANNEL (iface); IdleMUCChannelPrivate *priv = self->priv; @@ -1443,14 +1468,14 @@ idle_muc_channel_set_subject ( GError *error = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Can't set subject: not in the room (state=%s)", ascii_muc_states[priv->state]); - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (context, error); g_clear_error (&error); } else if (!priv->can_set_topic) { GError error = { TP_ERROR, TP_ERROR_PERMISSION_DENIED, "The channel's +t and you're not an op" }; - dbus_g_method_return_error (context, &error); + g_dbus_method_invocation_return_gerror (context, &error); } else { @@ -1460,7 +1485,7 @@ idle_muc_channel_set_subject ( subject); send_command (self, cmd); /* FIXME: don't return till we get a reply */ - tp_svc_channel_interface_subject_return_from_set_subject (context); + tp_svc_channel_interface_subject1_return_from_set_subject (context); } } @@ -1511,9 +1536,9 @@ gboolean idle_muc_channel_is_typechar(gchar c) } static void _password_iface_init(gpointer g_iface, gpointer iface_data) { - TpSvcChannelInterfacePasswordClass *klass = (TpSvcChannelInterfacePasswordClass *)(g_iface); + TpSvcChannelInterfacePassword1Class *klass = (TpSvcChannelInterfacePassword1Class *)(g_iface); -#define IMPLEMENT(x) tp_svc_channel_interface_password_implement_##x (\ +#define IMPLEMENT(x) tp_svc_channel_interface_password1_implement_##x (\ klass, idle_muc_channel_##x) IMPLEMENT(get_password_flags); IMPLEMENT(provide_password); @@ -1525,10 +1550,10 @@ subject_iface_init ( gpointer g_iface, gpointer iface_data G_GNUC_UNUSED) { - TpSvcChannelInterfaceSubjectClass *klass = g_iface; + TpSvcChannelInterfaceSubject1Class *klass = g_iface; #define IMPLEMENT(x) \ - tp_svc_channel_interface_subject_implement_##x (klass, idle_muc_channel_##x) + tp_svc_channel_interface_subject1_implement_##x (klass, idle_muc_channel_##x) IMPLEMENT (set_subject); #undef IMPLEMENT } @@ -1538,10 +1563,10 @@ destroyable_iface_init ( gpointer g_iface, gpointer iface_data G_GNUC_UNUSED) { - TpSvcChannelInterfaceDestroyableClass *klass = g_iface; + TpSvcChannelInterfaceDestroyable1Class *klass = g_iface; #define IMPLEMENT(x) \ - tp_svc_channel_interface_destroyable_implement_##x (klass, idle_muc_channel_##x) + tp_svc_channel_interface_destroyable1_implement_##x (klass, idle_muc_channel_##x) IMPLEMENT (destroy); #undef IMPLEMENT } diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c index 28e4fc3..52ae67b 100644 --- a/src/idle-muc-manager.c +++ b/src/idle-muc-manager.c @@ -90,7 +90,7 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use static const gchar * const muc_channel_fixed_properties[] = { TP_PROP_CHANNEL_CHANNEL_TYPE, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, NULL }; @@ -101,15 +101,15 @@ static const gchar * const muc_channel_allowed_properties[] = { }; static const gchar * const muc_channel_allowed_room_properties[] = { - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, /* But it must be None */ - TP_PROP_CHANNEL_INTERFACE_ROOM_ROOM_NAME, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, /* But it must be None */ + TP_PROP_CHANNEL_INTERFACE_ROOM1_ROOM_NAME, NULL }; static const gchar * const muc_channel_all_allowed_properties[] = { TP_PROP_CHANNEL_TARGET_HANDLE, TP_PROP_CHANNEL_TARGET_ID, - TP_PROP_CHANNEL_INTERFACE_ROOM_ROOM_NAME, + TP_PROP_CHANNEL_INTERFACE_ROOM1_ROOM_NAME, }; static GObject* @@ -285,7 +285,7 @@ static IdleParserHandlerResult _invite_handler(IdleParser *parser, IdleParserMes if (!chan) { chan = _muc_manager_new_channel(manager, room_handle, inviter_handle, FALSE); - tp_channel_manager_emit_new_channel(TP_CHANNEL_MANAGER(user_data), (TpExportableChannel *) chan, NULL); + tp_channel_manager_emit_new_channel(TP_CHANNEL_MANAGER (user_data), (TpBaseChannel *) chan, NULL); idle_muc_channel_invited(chan, inviter_handle); } @@ -399,7 +399,7 @@ struct _ChannelRenameForeachData { TpHandle old_handle, new_handle; }; -static void _channel_rename_foreach(TpExportableChannel *channel, gpointer user_data) { +static void _channel_rename_foreach(TpBaseChannel *channel, gpointer user_data) { IdleMUCChannel *muc_chan = IDLE_MUC_CHANNEL(channel); ChannelRenameForeachData *data = user_data; @@ -415,7 +415,7 @@ static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessa if (old_handle == new_handle) return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; - tp_channel_manager_foreach_channel(mgr, _channel_rename_foreach, &data); + tp_channel_manager_foreach_channel (TP_CHANNEL_MANAGER (mgr), _channel_rename_foreach, &data); return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } @@ -485,7 +485,7 @@ struct _ChannelQuitForeachData { const gchar *message; }; -static void _channel_quit_foreach(TpExportableChannel *channel, gpointer user_data) { +static void _channel_quit_foreach(TpBaseChannel *channel, gpointer user_data) { IdleMUCChannel *muc_chan = IDLE_MUC_CHANNEL(channel); ChannelQuitForeachData *data = user_data; @@ -498,7 +498,7 @@ static IdleParserHandlerResult _quit_handler(IdleParser *parser, IdleParserMessa const gchar *message = (args->n_values == 2) ? g_value_get_string(g_value_array_get_nth(args, 1)) : NULL; ChannelQuitForeachData data = {leaver_handle, message}; - tp_channel_manager_foreach_channel(manager, _channel_quit_foreach, &data); + tp_channel_manager_foreach_channel (TP_CHANNEL_MANAGER (manager), _channel_quit_foreach, &data); return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } @@ -594,7 +594,7 @@ static void _muc_manager_add_handlers(IdleMUCManager *manager) static void _muc_manager_foreach_channel ( TpChannelManager *iface, - TpExportableChannelFunc func, + TpBaseChannelFunc func, gpointer user_data) { IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE (iface); @@ -610,7 +610,7 @@ _muc_manager_foreach_channel ( g_hash_table_iter_init (&iter, priv->channels); while (g_hash_table_iter_next (&iter, NULL, &v)) - func (TP_EXPORTABLE_CHANNEL (v), user_data); + func (TP_BASE_CHANNEL (v), user_data); } } @@ -626,7 +626,7 @@ _muc_manager_type_foreach_channel_class ( { handle_fixed = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_ROOM, NULL); room_name_fixed = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, @@ -682,24 +682,27 @@ static void _channel_closed_cb(IdleMUCChannel *chan, gpointer user_data) { * didn't finish before we killed the channel. */ for (GSList *l = reqs; l != NULL; l = l->next) { - tp_channel_manager_emit_request_failed(manager, l->data, TP_ERROR, + tp_channel_manager_emit_request_failed (TP_CHANNEL_MANAGER (manager), l->data, TP_ERROR, TP_ERROR_DISCONNECTED, "Unable to complete this channel request, we're disconnecting!"); } g_slist_free(reqs); - tp_channel_manager_emit_channel_closed_for_object (manager, - TP_EXPORTABLE_CHANNEL (chan)); - if (priv->channels) { TpHandle handle = tp_base_channel_get_target_handle (base); - if (tp_base_channel_is_destroyed (base)) + if (tp_base_channel_is_destroyed (base)) { g_hash_table_remove(priv->channels, GUINT_TO_POINTER(handle)); - else - tp_channel_manager_emit_new_channel (manager, TP_EXPORTABLE_CHANNEL (chan), + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (manager), + base); + } + else { + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (manager), + base); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (manager), base, NULL); + } } } @@ -713,7 +716,7 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use GSList *l; if (err == MUC_CHANNEL_JOIN_ERROR_NONE) { - tp_channel_manager_emit_new_channel(manager, (TpExportableChannel *) chan, reqs); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (manager), (TpBaseChannel *) chan, reqs); goto out; } @@ -741,7 +744,7 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use } for (l = reqs; l != NULL; l = l->next) { - tp_channel_manager_emit_request_failed(manager, l->data, TP_ERROR, err_code, err_msg); + tp_channel_manager_emit_request_failed (TP_CHANNEL_MANAGER (manager), l->data, TP_ERROR, err_code, err_msg); } if (priv->channels) @@ -754,16 +757,16 @@ out: static gboolean _muc_manager_request ( IdleMUCManager *self, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties, gboolean require_new) { IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE (self); TpBaseConnection *base_conn = (TpBaseConnection *) priv->conn; TpHandleRepoIface *room_repo = tp_base_connection_get_handles (base_conn, - TP_HANDLE_TYPE_ROOM); + TP_ENTITY_TYPE_ROOM); GError *error = NULL; - TpHandleType handle_type; + TpEntityType entity_type; TpHandle handle; const gchar *channel_type; IdleMUCChannel *channel; @@ -774,12 +777,12 @@ _muc_manager_request ( if (tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)) return FALSE; - handle_type = tp_asv_get_uint32 (request_properties, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL); + entity_type = tp_asv_get_uint32 (request_properties, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, NULL); - switch (handle_type) + switch (entity_type) { - case TP_HANDLE_TYPE_ROOM: + case TP_ENTITY_TYPE_ROOM: handle = tp_asv_get_uint32 (request_properties, TP_PROP_CHANNEL_TARGET_HANDLE, NULL); @@ -788,10 +791,10 @@ _muc_manager_request ( break; - case TP_HANDLE_TYPE_NONE: + case TP_ENTITY_TYPE_NONE: { const gchar *room_name = tp_asv_get_string (request_properties, - TP_PROP_CHANNEL_INTERFACE_ROOM_ROOM_NAME); + TP_PROP_CHANNEL_INTERFACE_ROOM1_ROOM_NAME); if (room_name == NULL) return FALSE; @@ -824,8 +827,9 @@ _muc_manager_request ( } else if (idle_muc_channel_is_ready (channel)) { - tp_channel_manager_emit_request_already_satisfied (self, - request_token, TP_EXPORTABLE_CHANNEL (channel)); + tp_channel_manager_emit_request_already_satisfied ( + TP_CHANNEL_MANAGER (self), + request, TP_BASE_CHANNEL (channel)); return TRUE; } } @@ -836,12 +840,12 @@ _muc_manager_request ( idle_muc_channel_join_attempt (channel); } - associate_request (self, channel, request_token); + associate_request (self, channel, request); return TRUE; error: - tp_channel_manager_emit_request_failed (self, request_token, + tp_channel_manager_emit_request_failed (TP_CHANNEL_MANAGER (self), request, error->domain, error->code, error->message); g_error_free (error); return TRUE; @@ -850,34 +854,23 @@ error: static gboolean _muc_manager_create_channel ( TpChannelManager *manager, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties) { IdleMUCManager *self = IDLE_MUC_MANAGER (manager); - return _muc_manager_request (self, request_token, request_properties, TRUE); -} - -static gboolean -_muc_manager_request_channel ( - TpChannelManager *manager, - gpointer request_token, - GHashTable *request_properties) -{ - IdleMUCManager *self = IDLE_MUC_MANAGER (manager); - - return _muc_manager_request (self, request_token, request_properties, FALSE); + return _muc_manager_request (self, request, request_properties, TRUE); } static gboolean _muc_manager_ensure_channel ( TpChannelManager *manager, - gpointer request_token, + TpChannelManagerRequest *request, GHashTable *request_properties) { IdleMUCManager *self = IDLE_MUC_MANAGER (manager); - return _muc_manager_request (self, request_token, request_properties, FALSE); + return _muc_manager_request (self, request, request_properties, FALSE); } static void @@ -889,7 +882,6 @@ _muc_manager_iface_init ( iface->foreach_channel = _muc_manager_foreach_channel; iface->type_foreach_channel_class = _muc_manager_type_foreach_channel_class; - iface->request_channel = _muc_manager_request_channel; iface->create_channel = _muc_manager_create_channel; iface->ensure_channel = _muc_manager_ensure_channel; } diff --git a/src/idle-parser.c b/src/idle-parser.c index 6f0885c..9b3c97b 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -374,8 +374,8 @@ static void _parse_and_forward_one(IdleParser *parser, gchar **tokens, IdleParse gboolean success = TRUE; gchar **iter = tokens; /* We keep a ref to each unique handle in a message so that we can unref them after calling all handlers */ - TpHandleSet *contact_reffed = tp_handle_set_new(tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_HANDLE_TYPE_CONTACT)); - TpHandleSet *room_reffed = tp_handle_set_new(tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_HANDLE_TYPE_ROOM)); + TpHandleSet *contact_reffed = tp_handle_set_new(tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_ENTITY_TYPE_CONTACT)); + TpHandleSet *room_reffed = tp_handle_set_new(tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_ENTITY_TYPE_ROOM)); IDLE_DEBUG("message code %u", code); @@ -482,8 +482,8 @@ static gboolean _parse_atom(IdleParser *parser, GValueArray *arr, char atom, con IdleParserPrivate *priv = IDLE_PARSER_GET_PRIVATE(parser); TpHandle handle; GValue val = {0}; - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_HANDLE_TYPE_CONTACT); - TpHandleRepoIface *room_repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_HANDLE_TYPE_ROOM); + TpHandleRepoIface *contact_repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_ENTITY_TYPE_CONTACT); + TpHandleRepoIface *room_repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->conn), TP_ENTITY_TYPE_ROOM); if (token[0] == ':') token++; diff --git a/src/idle-roomlist-channel.c b/src/idle-roomlist-channel.c index 9fa15d2..e69bd8d 100644 --- a/src/idle-roomlist-channel.c +++ b/src/idle-roomlist-channel.c @@ -41,7 +41,7 @@ static IdleParserHandlerResult _rpl_listend_handler (IdleParser *parser, IdlePar G_DEFINE_TYPE_WITH_CODE (IdleRoomlistChannel, idle_roomlist_channel, TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_ROOM_LIST, _roomlist_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_ROOM_LIST1, _roomlist_iface_init); ) /* private structure */ @@ -92,7 +92,7 @@ idle_roomlist_channel_constructed (GObject *obj) priv->rooms = g_ptr_array_new (); priv->handles = tp_handle_set_new(tp_base_connection_get_handles ( - TP_BASE_CONNECTION(priv->connection), TP_HANDLE_TYPE_ROOM)); + TP_BASE_CONNECTION(priv->connection), TP_ENTITY_TYPE_ROOM)); } static gchar * @@ -109,7 +109,7 @@ idle_roomlist_channel_get_roomlist_property ( GValue *value, gpointer getter_data) { - g_return_if_fail (iface == TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST); + g_return_if_fail (iface == TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST1); g_return_if_fail (name == g_quark_from_static_string ("Server")); g_return_if_fail (G_VALUE_HOLDS_STRING (value)); @@ -127,7 +127,7 @@ idle_roomlist_channel_fill_properties ( tp_dbus_properties_mixin_fill_properties_hash ( G_OBJECT (chan), properties, - TP_IFACE_CHANNEL_TYPE_ROOM_LIST, "Server", + TP_IFACE_CHANNEL_TYPE_ROOM_LIST1, "Server", NULL); } @@ -148,14 +148,14 @@ idle_roomlist_channel_class_init (IdleRoomlistChannelClass *idle_roomlist_channe object_class->dispose = idle_roomlist_channel_dispose; object_class->finalize = idle_roomlist_channel_finalize; - base_channel_class->channel_type = TP_IFACE_CHANNEL_TYPE_ROOM_LIST; - base_channel_class->target_handle_type = TP_HANDLE_TYPE_NONE; + base_channel_class->channel_type = TP_IFACE_CHANNEL_TYPE_ROOM_LIST1; + base_channel_class->target_entity_type = TP_ENTITY_TYPE_NONE; base_channel_class->close = idle_roomlist_channel_close; base_channel_class->fill_immutable_properties = idle_roomlist_channel_fill_properties; base_channel_class->get_object_path_suffix = idle_roomlist_channel_get_path_suffix; tp_dbus_properties_mixin_implement_interface (object_class, - TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST, + TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST1, idle_roomlist_channel_get_roomlist_property, NULL, roomlist_props); @@ -222,16 +222,16 @@ idle_roomlist_channel_close (TpBaseChannel *channel) * idle_roomlist_channel_get_listing_rooms * * Implements D-Bus method GetListingRooms - * on interface org.freedesktop.Telepathy.Channel.Type.RoomList + * on interface im.telepathy.v1.Channel.Type.RoomList */ static void -idle_roomlist_channel_get_listing_rooms (TpSvcChannelTypeRoomList *iface, - DBusGMethodInvocation *context) +idle_roomlist_channel_get_listing_rooms (TpSvcChannelTypeRoomList1 *iface, + GDBusMethodInvocation *context) { IdleRoomlistChannel *self = IDLE_ROOMLIST_CHANNEL (iface); IdleRoomlistChannelPrivate *priv = self->priv;; - tp_svc_channel_type_room_list_return_from_get_listing_rooms ( + tp_svc_channel_type_room_list1_return_from_get_listing_rooms ( context, priv->listing); } @@ -240,39 +240,39 @@ idle_roomlist_channel_get_listing_rooms (TpSvcChannelTypeRoomList *iface, * idle_roomlist_channel_list_rooms * * Implements D-Bus method ListRooms - * on interface org.freedesktop.Telepathy.Channel.Type.RoomList + * on interface im.telepathy.v1.Channel.Type.RoomList */ static void -idle_roomlist_channel_list_rooms (TpSvcChannelTypeRoomList *iface, - DBusGMethodInvocation *context) +idle_roomlist_channel_list_rooms (TpSvcChannelTypeRoomList1 *iface, + GDBusMethodInvocation *context) { IdleRoomlistChannel *self = IDLE_ROOMLIST_CHANNEL (iface); IdleRoomlistChannelPrivate *priv = self->priv; priv->listing = TRUE; - tp_svc_channel_type_room_list_emit_listing_rooms (iface, TRUE); + tp_svc_channel_type_room_list1_emit_listing_rooms (iface, TRUE); idle_connection_send(priv->connection, "LIST"); - tp_svc_channel_type_room_list_return_from_list_rooms (context); + tp_svc_channel_type_room_list1_return_from_list_rooms (context); } /** * idle_roomlist_channel_stop_listing * * Implements D-Bus method StopListing - * on interface org.freedesktop.Telepathy.Channel.Type.RoomList + * on interface im.telepathy.v1.Channel.Type.RoomList */ static void -idle_roomlist_channel_stop_listing (TpSvcChannelTypeRoomList *iface, - DBusGMethodInvocation *context) +idle_roomlist_channel_stop_listing (TpSvcChannelTypeRoomList1 *iface, + GDBusMethodInvocation *context) { IdleRoomlistChannel *self = IDLE_ROOMLIST_CHANNEL (iface); GError error = { TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Can't stop listing!" }; g_assert (IDLE_IS_ROOMLIST_CHANNEL (self)); - dbus_g_method_return_error (context, &error); + g_dbus_method_invocation_return_gerror (context, &error); /* priv->listing = FALSE; @@ -289,10 +289,9 @@ static void _roomlist_iface_init (gpointer g_iface, gpointer iface_data) { - TpSvcChannelTypeRoomListClass *klass = - (TpSvcChannelTypeRoomListClass *)(g_iface); + TpSvcChannelTypeRoomList1Class *klass = g_iface; -#define IMPLEMENT(x) tp_svc_channel_type_room_list_implement_##x (\ +#define IMPLEMENT(x) tp_svc_channel_type_room_list1_implement_##x (\ klass, idle_roomlist_channel_##x) IMPLEMENT (get_listing_rooms); IMPLEMENT (list_rooms); @@ -315,7 +314,7 @@ _rpl_list_handler (IdleParser *parser, TpHandle room_handle = g_value_get_uint (g_value_array_get_nth (args, 0)); TpHandleRepoIface *handl_repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(priv->connection), - TP_HANDLE_TYPE_ROOM); + TP_ENTITY_TYPE_ROOM); const gchar *room_name = tp_handle_inspect(handl_repo, room_handle); guint num_users = g_value_get_uint (g_value_array_get_nth (args, 1)); /* topic is optional */ @@ -363,8 +362,8 @@ emit_room_signal (IdleRoomlistChannel *self) if (priv->rooms->len == 0) return TRUE; - tp_svc_channel_type_room_list_emit_got_rooms ( - (TpSvcChannelTypeRoomList *) self, priv->rooms); + tp_svc_channel_type_room_list1_emit_got_rooms ( + (TpSvcChannelTypeRoomList1 *) self, priv->rooms); while (priv->rooms->len != 0) { @@ -387,8 +386,8 @@ _rpl_listend_handler (IdleParser *parser, emit_room_signal (self); priv->listing = FALSE; - tp_svc_channel_type_room_list_emit_listing_rooms ( - (TpSvcChannelTypeRoomList *) self, FALSE); + tp_svc_channel_type_room_list1_emit_listing_rooms ( + (TpSvcChannelTypeRoomList1 *) self, FALSE); /* g_source_remove (priv->timer_source_id); diff --git a/src/idle-roomlist-manager.c b/src/idle-roomlist-manager.c index 970529b..8070365 100644 --- a/src/idle-roomlist-manager.c +++ b/src/idle-roomlist-manager.c @@ -47,7 +47,7 @@ enum { static const gchar * const roomlist_channel_fixed_properties[] = { TP_IFACE_CHANNEL ".ChannelType", - TP_IFACE_CHANNEL ".TargetHandleType", + TP_IFACE_CHANNEL ".TargetEntityType", NULL }; @@ -66,14 +66,13 @@ struct _IdleRoomlistManagerPrivate static void _roomlist_manager_close_all (IdleRoomlistManager *self); static void connection_status_changed_cb (IdleConnection* conn, guint status, guint reason, IdleRoomlistManager *self); -static void _roomlist_manager_foreach (TpChannelManager *self, TpExportableChannelFunc func, gpointer user_data); +static void _roomlist_manager_foreach (TpChannelManager *self, TpBaseChannelFunc func, gpointer user_data); static void _roomlist_manager_foreach_class (TpChannelManager *self, TpChannelManagerChannelClassFunc func, gpointer user_data); -static gboolean _roomlist_manager_create_channel (TpChannelManager *self, gpointer request_token, GHashTable *request_properties); -static gboolean _roomlist_manager_request_channel (TpChannelManager *self, gpointer request_token, GHashTable *request_properties); -static gboolean _roomlist_manager_ensure_channel (TpChannelManager *self, gpointer request_token, GHashTable *request_properties); -static gboolean _roomlist_manager_requestotron (IdleRoomlistManager *self, gpointer request_token, GHashTable *request_properties, gboolean require_new); -static IdleRoomlistChannel *_roomlist_manager_new_channel (IdleRoomlistManager *self, gpointer request); +static gboolean _roomlist_manager_create_channel (TpChannelManager *self, TpChannelManagerRequest *request, GHashTable *request_properties); +static gboolean _roomlist_manager_ensure_channel (TpChannelManager *self, TpChannelManagerRequest *request, GHashTable *request_properties); +static gboolean _roomlist_manager_requestotron (IdleRoomlistManager *self, TpChannelManagerRequest *request, GHashTable *request_properties, gboolean require_new); +static IdleRoomlistChannel *_roomlist_manager_new_channel (IdleRoomlistManager *self, TpChannelManagerRequest *request); static void _roomlist_channel_closed_cb (IdleRoomlistChannel *chan, gpointer user_data); @@ -218,7 +217,7 @@ connection_status_changed_cb (IdleConnection* conn, static void _roomlist_manager_foreach (TpChannelManager *manager, - TpExportableChannelFunc func, + TpBaseChannelFunc func, gpointer user_data) { IdleRoomlistManager *self = IDLE_ROOMLIST_MANAGER (manager); @@ -230,7 +229,7 @@ _roomlist_manager_foreach (TpChannelManager *manager, return; } - func (TP_EXPORTABLE_CHANNEL (priv->channel), user_data); + func (TP_BASE_CHANNEL (priv->channel), user_data); } @@ -241,9 +240,9 @@ _roomlist_manager_foreach_class (TpChannelManager *self, { GHashTable *table = tp_asv_new ( roomlist_channel_fixed_properties[0], G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_ROOM_LIST, + TP_IFACE_CHANNEL_TYPE_ROOM_LIST1, roomlist_channel_fixed_properties[1], G_TYPE_UINT, - TP_HANDLE_TYPE_NONE, + TP_ENTITY_TYPE_NONE, NULL); func (self, table, roomlist_channel_allowed_properties, user_data); @@ -254,45 +253,32 @@ _roomlist_manager_foreach_class (TpChannelManager *self, static gboolean _roomlist_manager_create_channel (TpChannelManager *self, - gpointer request_token, - GHashTable *request_properties) + TpChannelManagerRequest *request, + GHashTable *request_properties) { IdleRoomlistManager *mgr = IDLE_ROOMLIST_MANAGER (self); - return _roomlist_manager_requestotron (mgr, request_token, request_properties, + return _roomlist_manager_requestotron (mgr, request, request_properties, TRUE); } - -static gboolean -_roomlist_manager_request_channel (TpChannelManager *self, - gpointer request_token, - GHashTable *request_properties) -{ - IdleRoomlistManager *mgr = IDLE_ROOMLIST_MANAGER (self); - - return _roomlist_manager_requestotron (mgr, request_token, - request_properties, FALSE); -} - - static gboolean _roomlist_manager_ensure_channel (TpChannelManager *self, - gpointer request_token, - GHashTable *request_properties) + TpChannelManagerRequest *request, + GHashTable *request_properties) { IdleRoomlistManager *mgr = IDLE_ROOMLIST_MANAGER (self); - return _roomlist_manager_requestotron (mgr, request_token, + return _roomlist_manager_requestotron (mgr, request, request_properties, FALSE); } static gboolean _roomlist_manager_requestotron (IdleRoomlistManager *self, - gpointer request_token, - GHashTable *request_properties, - gboolean require_new) + TpChannelManagerRequest *request, + GHashTable *request_properties, + gboolean require_new) { IdleRoomlistManagerPrivate *priv = self->priv; GError *error = NULL; @@ -300,11 +286,11 @@ _roomlist_manager_requestotron (IdleRoomlistManager *self, IDLE_DEBUG("requesting new room list channel"); if (tp_strdiff (tp_asv_get_string (request_properties, - TP_IFACE_CHANNEL ".ChannelType"), TP_IFACE_CHANNEL_TYPE_ROOM_LIST)) + TP_IFACE_CHANNEL ".ChannelType"), TP_IFACE_CHANNEL_TYPE_ROOM_LIST1)) return FALSE; if (tp_asv_get_uint32 (request_properties, - TP_IFACE_CHANNEL ".TargetHandleType", NULL) != 0) + TP_IFACE_CHANNEL ".TargetEntityType", NULL) != 0) return FALSE; /* Check if there are any other properties that we don't understand */ @@ -318,7 +304,7 @@ _roomlist_manager_requestotron (IdleRoomlistManager *self, if (priv->channel == NULL) { - _roomlist_manager_new_channel (self, request_token); + _roomlist_manager_new_channel (self, request); return TRUE; } @@ -329,12 +315,12 @@ _roomlist_manager_requestotron (IdleRoomlistManager *self, goto error; } - tp_channel_manager_emit_request_already_satisfied (self, request_token, - TP_EXPORTABLE_CHANNEL (priv->channel)); + tp_channel_manager_emit_request_already_satisfied (TP_CHANNEL_MANAGER (self), + request, TP_BASE_CHANNEL (priv->channel)); return TRUE; error: - tp_channel_manager_emit_request_failed (self, request_token, + tp_channel_manager_emit_request_failed (TP_CHANNEL_MANAGER (self), request, error->domain, error->code, error->message); g_error_free (error); return TRUE; @@ -348,21 +334,21 @@ _roomlist_channel_closed_cb (IdleRoomlistChannel *chan, IdleRoomlistManager *self = IDLE_ROOMLIST_MANAGER (user_data); IdleRoomlistManagerPrivate *priv = self->priv; - tp_channel_manager_emit_channel_closed_for_object (self, - TP_EXPORTABLE_CHANNEL (chan)); - if (priv->channel) { g_assert (priv->channel == chan); g_object_unref (priv->channel); priv->channel = NULL; } + + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self), + TP_BASE_CHANNEL (chan)); } static IdleRoomlistChannel * _roomlist_manager_new_channel (IdleRoomlistManager *self, - gpointer request) + TpChannelManagerRequest *request) { IdleRoomlistManagerPrivate *priv = self->priv; IdleRoomlistChannel *chan; @@ -379,8 +365,8 @@ _roomlist_manager_new_channel (IdleRoomlistManager *self, if (request != NULL) requests = g_slist_prepend (requests, request); - tp_channel_manager_emit_new_channel (self, TP_EXPORTABLE_CHANNEL (chan), - requests); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (self), + TP_BASE_CHANNEL (chan), requests); g_slist_free (requests); @@ -399,7 +385,6 @@ _roomlist_manager_iface_init (gpointer g_iface, iface->foreach_channel = _roomlist_manager_foreach; iface->foreach_channel_class = _roomlist_manager_foreach_class; - iface->request_channel = _roomlist_manager_request_channel; iface->create_channel = _roomlist_manager_create_channel; iface->ensure_channel = _roomlist_manager_ensure_channel; } diff --git a/src/idle-text.c b/src/idle-text.c index cce38c8..88d7682 100644 --- a/src/idle-text.c +++ b/src/idle-text.c @@ -151,10 +151,10 @@ idle_text_encode_and_split(TpChannelTextMessageType type, void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flags, const gchar *recipient, IdleConnection *conn) { GError *error = NULL; - const GHashTable *part; + GVariant *part; TpChannelTextMessageType type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL; gboolean result = TRUE; - const gchar *content_type, *text; + const gchar *content_type = NULL, *text = NULL; guint n_parts; GStrv messages; GStrv bodies; @@ -171,10 +171,10 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag g_return_if_fail (recipient != NULL); - part = tp_message_peek (message, 0); + part = tp_message_dup_part (message, 0); - if (tp_asv_lookup (part, "message-type") != NULL) - type = tp_asv_get_uint32 (part, "message-type", &result); + if (tp_vardict_has_key (part, "message-type")) + type = tp_vardict_get_uint32 (part, "message-type", &result); if (!result) INVALID_ARGUMENT ("message-type must be a 32-bit unsigned integer"); @@ -187,9 +187,11 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag if (n_parts != 2) INVALID_ARGUMENT ("message must contain exactly 1 part, not %u", (n_parts - 1)); - part = tp_message_peek (message, 1); - content_type = tp_asv_get_string (part, "content-type"); - text = tp_asv_get_string (part, "content"); + g_variant_unref (part); + + part = tp_message_dup_part (message, 1); + g_variant_lookup (part, "content-type", "&s", &content_type); + g_variant_lookup (part, "content", "&s", &text); if (tp_strdiff (content_type, "text/plain")) INVALID_ARGUMENT ("message must be text/plain"); @@ -201,6 +203,7 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag msg_len = idle_connection_get_max_message_length(conn); messages = idle_text_encode_and_split(type, recipient, text, msg_len, &bodies, &error); + g_variant_unref (part); if (messages == NULL) goto failed; diff --git a/src/protocol.c b/src/protocol.c index 8e5a2cc..49287ca 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -179,17 +179,6 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED, return nick_at_server; } -static GPtrArray * -get_interfaces_array (TpBaseProtocol *self) -{ - GPtrArray *interfaces; - - interfaces = TP_BASE_PROTOCOL_CLASS ( - idle_protocol_parent_class)->get_interfaces_array (self); - - return interfaces; -} - static void get_connection_details (TpBaseProtocol *self, GStrv *connection_interfaces, @@ -234,7 +223,7 @@ static GStrv dup_authentication_types (TpBaseProtocol *base) { const gchar * const types[] = { - TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1, NULL, }; @@ -250,7 +239,6 @@ idle_protocol_class_init (IdleProtocolClass *klass) base_class->new_connection = new_connection; base_class->normalize_contact = normalize_contact; base_class->identify_account = identify_account; - base_class->get_interfaces_array = get_interfaces_array; base_class->get_connection_details = get_connection_details; base_class->dup_authentication_types = dup_authentication_types; } diff --git a/src/room-config.c b/src/room-config.c index 30e413d..da00db9 100644 --- a/src/room-config.c +++ b/src/room-config.c @@ -22,6 +22,7 @@ #include "idle-muc-channel.h" #include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #define IDLE_DEBUG_FLAG IDLE_DEBUG_MUC #include "idle-debug.h" diff --git a/src/server-tls-channel.c b/src/server-tls-channel.c index aa2ef62..8f23e38 100644 --- a/src/server-tls-channel.c +++ b/src/server-tls-channel.c @@ -32,7 +32,7 @@ G_DEFINE_TYPE_WITH_CODE (IdleServerTLSChannel, idle_server_tls_channel, TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_SERVER_TLS_CONNECTION, + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, NULL)); static void idle_server_tls_channel_close (TpBaseChannel *base); @@ -190,8 +190,8 @@ idle_server_tls_channel_constructed (GObject *object) "object-path", cert_object_path, "certificate-chain-data", certificates, "certificate-type", "x509", - "dbus-daemon", - tp_base_connection_get_dbus_daemon ( + "dbus-connection", + tp_base_connection_get_dbus_connection ( tp_base_channel_get_connection (TP_BASE_CHANNEL (self))), NULL); self->priv->server_cert_path = cert_object_path; @@ -210,9 +210,9 @@ idle_server_tls_channel_fill_immutable_properties ( tp_dbus_properties_mixin_fill_properties_hash ( G_OBJECT (chan), properties, - TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION, "ServerCertificate", - TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION, "Hostname", - TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION, "ReferenceIdentities", + TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, "ServerCertificate", + TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, "Hostname", + TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, "ReferenceIdentities", NULL); } @@ -253,8 +253,8 @@ idle_server_tls_channel_class_init (IdleServerTLSChannelClass *klass) oclass->finalize = idle_server_tls_channel_finalize; oclass->constructed = idle_server_tls_channel_constructed; - base_class->channel_type = TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION; - base_class->target_handle_type = TP_HANDLE_TYPE_NONE; + base_class->channel_type = TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1; + base_class->target_entity_type = TP_ENTITY_TYPE_NONE; base_class->fill_immutable_properties = idle_server_tls_channel_fill_immutable_properties; base_class->get_object_path_suffix = @@ -287,7 +287,7 @@ idle_server_tls_channel_class_init (IdleServerTLSChannelClass *klass) g_object_class_install_property (oclass, PROP_CERTIFICATE, pspec); tp_dbus_properties_mixin_implement_interface (oclass, - TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_TLS_CONNECTION, + TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, tp_dbus_properties_mixin_getter_gobject_properties, NULL, server_tls_props); } diff --git a/src/server-tls-channel.h b/src/server-tls-channel.h index 47b8474..fc47380 100644 --- a/src/server-tls-channel.h +++ b/src/server-tls-channel.h @@ -25,8 +25,6 @@ #include <telepathy-glib/telepathy-glib.h> -#include <extensions/extensions.h> - #include "tls-certificate.h" G_BEGIN_DECLS diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c index b14cecd..314e8d8 100644 --- a/src/server-tls-manager.c +++ b/src/server-tls-manager.c @@ -29,8 +29,6 @@ #include "idle-connection.h" #include "server-tls-channel.h" -#include "extensions/extensions.h" - static void channel_manager_iface_init (gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE (IdleServerTLSManager, idle_server_tls_manager, @@ -183,8 +181,8 @@ server_tls_channel_closed_cb (IdleServerTLSChannel *channel, self->priv->completed_channels, l); } - tp_channel_manager_emit_channel_closed_for_object (self, - TP_EXPORTABLE_CHANNEL (channel)); + tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self), + TP_BASE_CHANNEL (channel)); g_object_unref (channel); } @@ -274,8 +272,8 @@ idle_server_tls_manager_verify_async (IdleServerTLSManager *self, G_CALLBACK (tls_certificate_rejected_cb), self); /* emit NewChannel on the ChannelManager iface */ - tp_channel_manager_emit_new_channel (self, - (TpExportableChannel *) self->priv->channel, NULL); + tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (self), + (TpBaseChannel *) self->priv->channel, NULL); } gboolean @@ -367,14 +365,14 @@ idle_server_tls_manager_class_init (IdleServerTLSManagerClass *klass) static void idle_server_tls_manager_foreach_channel (TpChannelManager *manager, - TpExportableChannelFunc func, + TpBaseChannelFunc func, gpointer user_data) { IdleServerTLSManager *self = IDLE_SERVER_TLS_MANAGER (manager); GList *l; if (self->priv->channel != NULL) - func (TP_EXPORTABLE_CHANNEL (self->priv->channel), user_data); + func (TP_BASE_CHANNEL (self->priv->channel), user_data); for (l = self->priv->completed_channels; l != NULL; l = l->next) { @@ -393,7 +391,6 @@ channel_manager_iface_init (gpointer g_iface, /* these channels are not requestable. */ iface->ensure_channel = NULL; iface->create_channel = NULL; - iface->request_channel = NULL; iface->foreach_channel_class = NULL; } diff --git a/src/server-tls-manager.h b/src/server-tls-manager.h index 9e33753..54a6625 100644 --- a/src/server-tls-manager.h +++ b/src/server-tls-manager.h @@ -24,8 +24,6 @@ #include <glib-object.h> #include <telepathy-glib/telepathy-glib.h> -#include "extensions/extensions.h" - G_BEGIN_DECLS typedef struct _IdleServerTLSManager IdleServerTLSManager; diff --git a/src/telepathy-idle.8.in b/src/telepathy-idle-1.8.in index 54b0c4f..ee889a1 100644 --- a/src/telepathy-idle.8.in +++ b/src/telepathy-idle-1.8.in @@ -1,12 +1,12 @@ -.TH TELEPATHY-IDLE "8" "October 2007" "Telepathy" "D-Bus services" +.TH TELEPATHY-IDLE-1 "8" "October 2007" "Telepathy" "D-Bus services" \" This man page was written by Simon McVittie for the Debian project, \" but may be used by others. \" Copyright © 2007 Collabora Ltd. <http://www.collabora.co.uk/> \" It may be distributed under the same terms as telepathy-idle itself. .SH NAME -telepathy-idle \- Telepathy connection manager for IRC +telepathy-idle-1 \- Telepathy connection manager for IRC .SH SYNOPSIS -\fB@libexecdir@/telepathy\-idle\fR +\fB@libexecdir@/telepathy\-idle\-1\fR .SH DESCRIPTION Idle implements the Telepathy D-Bus specification for Internet Relay Chat, allowing Telepathy clients like diff --git a/src/tls-certificate.c b/src/tls-certificate.c index 3d71be1..a0481ea 100644 --- a/src/tls-certificate.c +++ b/src/tls-certificate.c @@ -34,9 +34,7 @@ G_DEFINE_TYPE_WITH_CODE (IdleTLSCertificate, idle_tls_certificate, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_AUTHENTICATION_TLS_CERTIFICATE, - tls_certificate_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES, - tp_dbus_properties_mixin_iface_init);) + tls_certificate_iface_init)) struct _IdleTLSCertificatePrivate { gchar *object_path; @@ -47,7 +45,7 @@ struct _IdleTLSCertificatePrivate { GPtrArray *rejections; GPtrArray *cert_data; - TpDBusDaemon *daemon; + GDBusConnection *dbus_connection; gboolean dispose_has_run; }; @@ -60,7 +58,7 @@ enum { PROP_CERTIFICATE_CHAIN_DATA, /* not exported */ - PROP_DBUS_DAEMON, + PROP_DBUS_CONNECTION, NUM_PROPERTIES }; @@ -115,8 +113,8 @@ idle_tls_certificate_set_property (GObject *object, case PROP_CERTIFICATE_CHAIN_DATA: self->priv->cert_data = g_value_dup_boxed (value); break; - case PROP_DBUS_DAEMON: - self->priv->daemon = g_value_dup_object (value); + case PROP_DBUS_CONNECTION: + self->priv->dbus_connection = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, value); @@ -149,7 +147,7 @@ idle_tls_certificate_dispose (GObject *object) self->priv->dispose_has_run = TRUE; - tp_clear_object (&self->priv->daemon); + tp_clear_object (&self->priv->dbus_connection); G_OBJECT_CLASS (idle_tls_certificate_parent_class)->dispose (object); } @@ -165,7 +163,7 @@ idle_tls_certificate_constructed (GObject *object) chain_up (object); /* register the certificate on the bus */ - tp_dbus_daemon_register_object (self->priv->daemon, + tp_dbus_connection_register_object (self->priv->dbus_connection, self->priv->object_path, self); } @@ -187,14 +185,6 @@ idle_tls_certificate_class_init (IdleTLSCertificateClass *klass) { "CertificateChainData", "certificate-chain-data", NULL }, { NULL } }; - static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = { - { TP_IFACE_AUTHENTICATION_TLS_CERTIFICATE, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - object_props, - }, - { NULL } - }; GObjectClass *oclass = G_OBJECT_CLASS (klass); GParamSpec *pspec; @@ -242,21 +232,21 @@ idle_tls_certificate_class_init (IdleTLSCertificateClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (oclass, PROP_CERTIFICATE_CHAIN_DATA, pspec); - pspec = g_param_spec_object ("dbus-daemon", - "The DBus daemon connection", - "The connection to the DBus daemon owning the CM", - TP_TYPE_DBUS_DAEMON, + pspec = g_param_spec_object ("dbus-connection", "D-Bus connection", + "D-Bus connection", + G_TYPE_DBUS_CONNECTION, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_DBUS_DAEMON, pspec); + g_object_class_install_property (oclass, PROP_DBUS_CONNECTION, pspec); - klass->dbus_props_class.interfaces = prop_interfaces; - tp_dbus_properties_mixin_class_init (oclass, - G_STRUCT_OFFSET (IdleTLSCertificateClass, dbus_props_class)); + tp_dbus_properties_mixin_implement_interface (oclass, + TP_IFACE_QUARK_AUTHENTICATION_TLS_CERTIFICATE, + tp_dbus_properties_mixin_getter_gobject_properties, + NULL, object_props); } static void idle_tls_certificate_accept (TpSvcAuthenticationTLSCertificate *cert, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { IdleTLSCertificate *self = IDLE_TLS_CERTIFICATE (cert); @@ -272,7 +262,7 @@ idle_tls_certificate_accept (TpSvcAuthenticationTLSCertificate *cert, "doesn't make sense." }; - dbus_g_method_return_error (context, &error); + g_dbus_method_invocation_return_gerror (context, &error); return; } @@ -285,7 +275,7 @@ idle_tls_certificate_accept (TpSvcAuthenticationTLSCertificate *cert, static void idle_tls_certificate_reject (TpSvcAuthenticationTLSCertificate *cert, const GPtrArray *rejections, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { IdleTLSCertificate *self = IDLE_TLS_CERTIFICATE (cert); @@ -298,7 +288,7 @@ idle_tls_certificate_reject (TpSvcAuthenticationTLSCertificate *cert, GError error = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Calling Reject() with a zero-length rejection list." }; - dbus_g_method_return_error (context, &error); + g_dbus_method_invocation_return_gerror (context, &error); return; } @@ -311,7 +301,7 @@ idle_tls_certificate_reject (TpSvcAuthenticationTLSCertificate *cert, "doesn't make sense." }; - dbus_g_method_return_error (context, &error); + g_dbus_method_invocation_return_gerror (context, &error); return; } diff --git a/src/tls-certificate.h b/src/tls-certificate.h index 52ea684..e664204 100644 --- a/src/tls-certificate.h +++ b/src/tls-certificate.h @@ -33,8 +33,6 @@ typedef struct _IdleTLSCertificatePrivate IdleTLSCertificatePrivate; struct _IdleTLSCertificateClass { GObjectClass parent_class; - - TpDBusPropertiesMixinClass dbus_props_class; }; struct _IdleTLSCertificate { diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index ded35b5..a8a5469 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -53,41 +53,58 @@ check-twisted: $(BUILT_SOURCES) else \ idle_test_sleep=--sleep=$(CHECK_TWISTED_SLEEP); \ fi; \ - IDLE_TEST_UNINSTALLED=1 \ - IDLE_ABS_TOP_SRCDIR=@abs_top_srcdir@ \ - IDLE_ABS_TOP_BUILDDIR=@abs_top_builddir@ \ - IDLE_TEST_SLEEP=$$idle_test_sleep \ + CHECK_TWISTED_UNINSTALLED=1 \ + G_TEST_SRCDIR=@abs_srcdir@ \ + G_TEST_BUILDDIR=@abs_builddir@ \ + CHECK_TWISTED_SLEEP=$$idle_test_sleep \ ./run-test.sh "$(TWISTED_TESTS)" -idle-twisted-tests.list: Makefile +endif + +twisted-tests.list: Makefile $(AM_V_GEN)echo $(TWISTED_TESTS) > $@ -BUILT_SOURCES = \ +built_test_data = \ config.py \ - idle-twisted-tests.list \ + twisted-tests.list \ + $(NULL) + +built_test_scripts = \ run-test.sh \ $(NULL) -# We don't really use idletestsdir yet - we only support uninstalled testing -# so far - but I'm substituting it to keep the script more similar to Gabble's. -# ${pkglibexecdir}/tests is what GNOME's InstalledTests goal recommends. +BUILT_SOURCES = \ + $(built_test_data) \ + $(built_test_scripts) \ + $(NULL) + +if ENABLE_INSTALLED_TESTS +testsdir = ${datadir}/telepathy-idle-1-tests +twistedtestsdir = ${testsdir}/twisted +nobase_dist_twistedtests_DATA = $(dist_test_data) +twistedtests_DATA = $(built_test_data) +twistedtests_SCRIPTS = $(built_test_scripts) +endif + run-test.sh: run-test.sh.in Makefile $(AM_V_GEN)sed \ - -e 's![@]idletestsdir[@]!${pkglibexecdir}/tests!' \ + -e 's![@]twistedtestsdir[@]!${twistedtestsdir}!' \ -e 's![@]TEST_PYTHON[@]!$(TEST_PYTHON)!' \ < $< > $@.tmp && \ chmod +x $@.tmp && \ mv $@.tmp $@ -endif +dist_test_data = \ + $(TWISTED_TESTS) \ + constants.py \ + idletest.py \ + servicetest.py \ + $(NULL) EXTRA_DIST = \ - $(TWISTED_TESTS) \ - run-test.sh.in \ - servicetest.py \ - idletest.py \ - constants.py \ - $(NULL) + $(dist_test_data) \ + run-test.sh.in \ + $(NULL) CLEANFILES = \ $(BUILT_SOURCES) \ @@ -97,3 +114,19 @@ CLEANFILES = \ $(NULL) SUBDIRS = tools + +%.test: Makefile + @$(MKDIR_P) $(dir $*) + $(AM_V_GEN)( echo '[Test]'; \ + echo 'Exec=${twistedtestsdir}/run-test.sh $*.py'; \ + echo 'Type=session'; \ + echo 'Output=TAP' ) > $@.tmp + @mv $@.tmp $@ + +insttestdir = ${datadir}/installed-tests/telepathy-idle-1 + +if ENABLE_INSTALLED_TESTS +nobase_nodist_insttest_DATA = \ + $(patsubst %.py,%.test,$(TWISTED_TESTS)) \ + $(NULL) +endif diff --git a/tests/twisted/channels/join-muc-channel-bouncer.py b/tests/twisted/channels/join-muc-channel-bouncer.py index e9b145c..e135160 100644 --- a/tests/twisted/channels/join-muc-channel-bouncer.py +++ b/tests/twisted/channels/join-muc-channel-bouncer.py @@ -12,18 +12,16 @@ from constants import * def test_join_bouncer(q, conn, stream, room): stream.sendJoin(room) - new_channels = EventPattern('dbus-signal', signal='NewChannels') - event = q.expect_many(new_channels)[0] - q.forbid_events([new_channels]) - channel_details = event.args[0] - assertEquals(1, len(channel_details)) - path, props = channel_details[0] + new_channel = EventPattern('dbus-signal', signal='NewChannel') + event = q.expect_many(new_channel)[0] + q.forbid_events([new_channel]) + path, props = event.args assertEquals(HT_ROOM, props[TARGET_HANDLE_TYPE]) assertEquals(CHANNEL_TYPE_TEXT, props[CHANNEL_TYPE]) q.expect('dbus-signal', signal='MembersChanged') - q.unforbid_events([new_channels]) + q.unforbid_events([new_channel]) return path def test(q, bus, conn, stream): @@ -31,8 +29,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) CHANNEL_NAME = "#idletest" @@ -44,7 +42,7 @@ def test(q, bus, conn, stream): # We PART. chan = make_channel_proxy(conn, path, 'Channel') - chan.RemoveMembers([self_handle], "bye bye cruel world", + chan.RemoveMembers([self_handle], "bye bye cruel world", GC_REASON_NONE, dbus_interface=CHANNEL_IFACE_GROUP) q.expect('dbus-signal', signal='MembersChanged') diff --git a/tests/twisted/channels/join-muc-channel.py b/tests/twisted/channels/join-muc-channel.py index de3235a..7699bec 100644 --- a/tests/twisted/channels/join-muc-channel.py +++ b/tests/twisted/channels/join-muc-channel.py @@ -13,8 +13,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) call_async(q, conn.Requests, 'CreateChannel', { CHANNEL_TYPE: CHANNEL_TYPE_TEXT, @@ -25,12 +25,10 @@ def test(q, bus, conn, stream): event = q.expect('dbus-return', method='CreateChannel') obj_path = event.value[0] - pattern = EventPattern('dbus-signal', signal='NewChannels') + pattern = EventPattern('dbus-signal', signal='NewChannel') event = q.expect_many(pattern)[0] q.forbid_events([pattern]) - channel_details = event.args[0] - assert len(channel_details) == 1 - path, props = channel_details[0] + path, props = event.args assert path == obj_path assert props[TARGET_HANDLE_TYPE] == HT_ROOM assert props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT diff --git a/tests/twisted/channels/muc-channel-topic.py b/tests/twisted/channels/muc-channel-topic.py index 10ddf47..4cf9c8e 100644 --- a/tests/twisted/channels/muc-channel-topic.py +++ b/tests/twisted/channels/muc-channel-topic.py @@ -39,10 +39,10 @@ def expect_and_check_can_set(q, channel, can_set): if can_set: # FIXME: this shouldn't return until the server gets back to us with # RPL_TOPIC - channel.Subject2.SetSubject('what up') + channel.Subject1.SetSubject('what up') e = q.expect('stream-TOPIC', data=[room, 'what up']) else: - call_async(q, channel.Subject2, 'SetSubject', 'boo hoo') + call_async(q, channel.Subject1, 'SetSubject', 'boo hoo') q.expect('dbus-error', method='SetSubject', name=PERMISSION_DENIED) @@ -80,7 +80,7 @@ def test(q, bus, conn, stream): path = event.value[0] channel = wrap_channel(bus.get_object(conn.bus_name, path), 'Text', - ['Subject2']) + ['Subject1']) assertContains(CHANNEL_IFACE_SUBJECT, channel.Properties.Get(CHANNEL, 'Interfaces')) @@ -178,7 +178,7 @@ def test(q, bus, conn, stream): # And back to normal again ? test_can_set(q, stream, channel) - channel.Subject2.SetSubject('') + channel.Subject1.SetSubject('') # Verify that we send an empty final parameter ("clear the topic") as # opposed to no final parameter ("what is the topic"). q.expect('stream-TOPIC', data=[room, '']) diff --git a/tests/twisted/channels/muc-destroy.py b/tests/twisted/channels/muc-destroy.py index b4c742b..d29fa4a 100644 --- a/tests/twisted/channels/muc-destroy.py +++ b/tests/twisted/channels/muc-destroy.py @@ -17,7 +17,7 @@ def join(q, bus, conn): event = q.expect('dbus-return', method='CreateChannel') path, props = event.value return wrap_channel(bus.get_object(conn.bus_name, path), 'Text', - ['Destroyable', 'Messages']) + ['Destroyable1']) def test(q, bus, conn, stream): conn.Connect() @@ -30,7 +30,7 @@ def test(q, bus, conn, stream): q.expect('dbus-signal', signal='MessageReceived') # Without acking the message, destroy the channel. - call_async(q, chan.Destroyable, "Destroy") + call_async(q, chan.Destroyable1, "Destroy") q.expect_many( EventPattern('stream-PART'), EventPattern('dbus-signal', signal='Closed', path=chan.object_path), @@ -43,7 +43,7 @@ def test(q, bus, conn, stream): chan = join(q, bus, conn) # The message should be gone. - messages = chan.Properties.Get(cs.CHANNEL_IFACE_MESSAGES, 'PendingMessages') + messages = chan.Properties.Get(cs.CHANNEL_TYPE_TEXT, 'PendingMessages') assertLength(0, messages) diff --git a/tests/twisted/channels/requests-create.py b/tests/twisted/channels/requests-create.py index 957560e..e762507 100644 --- a/tests/twisted/channels/requests-create.py +++ b/tests/twisted/channels/requests-create.py @@ -17,14 +17,15 @@ def test(q, bus, conn, stream): props = conn.GetAll(cs.CONN, dbus_interface=cs.PROPERTIES_IFACE) - assertContains(cs.CONN_IFACE_REQUESTS, props['Interfaces']) - nick = 'foo' foo_handle = conn.get_contact_handle_sync(nick) properties = conn.GetAll(cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE) assert properties.get('Channels') == [], properties['Channels'] + + properties = conn.GetAll(cs.CONN, + dbus_interface=cs.PROPERTIES_IFACE) assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, }, @@ -41,7 +42,7 @@ def test(q, bus, conn, stream): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) assert len(ret.value) == 2 @@ -54,31 +55,26 @@ def test(q, bus, conn, stream): assert emitted_props[cs.INITIATOR_HANDLE] == props['SelfHandle'] assert emitted_props[cs.INITIATOR_ID] == stream.nick - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == ret.value[0] - assert new_sig.args[0][0][1] == ret.value[1] + assert new_sig.args[0] == ret.value[0] + assert new_sig.args[1] == ret.value[1] properties = conn.GetAll(cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE) - assert new_sig.args[0][0] in properties['Channels'], \ - (new_sig.args[0][0], properties['Channels']) + assertContains((new_sig.args[0], new_sig.args[1]), properties['Channels']) chan = make_channel_proxy(conn, path, 'Channel') stream.sendMessage('PRIVMSG', stream.nick, ":oh hai", prefix=nick) - q.expect('dbus-signal', signal='Received') + q.expect('dbus-signal', signal='MessageReceived') # Without acknowledging the message, we close the channel: chan.Close() # It should close and respawn! q.expect('dbus-signal', signal='ChannelClosed') - chans, = q.expect('dbus-signal', signal='NewChannels').args - assert len(chans) == 1 - new_props = chans[0][1] + e = q.expect('dbus-signal', signal='NewChannel') + _, new_props = e.args # It should look pretty similar... assert new_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT @@ -92,9 +88,10 @@ def test(q, bus, conn, stream): assert new_props[cs.INITIATOR_ID] == nick # ...and it's got some messages in it! - ms = chan.ListPendingMessages(False, dbus_interface=cs.CHANNEL_TYPE_TEXT) + ms = chan.Get(cs.CHANNEL_TYPE_TEXT, 'PendingMessages', + dbus_interface=cs.PROPERTIES_IFACE) assert len(ms) == 1 - assert ms[0][5] == 'oh hai' + assert ms[0][1]['content'] == 'oh hai' # Without acknowledging the message, we destroy the channel: assertContains(cs.CHANNEL_IFACE_DESTROYABLE, diff --git a/tests/twisted/channels/requests-muc.py b/tests/twisted/channels/requests-muc.py index 7286ab1..864c3f7 100644 --- a/tests/twisted/channels/requests-muc.py +++ b/tests/twisted/channels/requests-muc.py @@ -17,11 +17,11 @@ class DelayJoinServer(BaseIRCServer): return def build_request(conn, channel_name, use_room): - rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, + rccs = conn.Properties.Get(cs.CONN, 'RequestableChannelClasses') if use_room: - # We allow TargetHandleType in Room-flavoured requests, but it has to + # We allow TargetEntityType in Room-flavoured requests, but it has to # be None if specified. assertContains( ({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT }, @@ -52,7 +52,7 @@ def test(q, bus, conn, stream, use_room=False): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged') + q.expect('dbus-signal', signal='SelfContactChanged') q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) self_handle = conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE) @@ -77,7 +77,7 @@ def test(q, bus, conn, stream, use_room=False): EventPattern('dbus-return', method='CreateChannel'), EventPattern('dbus-return', method='EnsureChannel'), ) - nc = q.expect('dbus-signal', signal='NewChannels') + nc = q.expect('dbus-signal', signal='NewChannel') path, props = cc.value @@ -85,7 +85,6 @@ def test(q, bus, conn, stream, use_room=False): assertSameSets( [cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_PASSWORD, - cs.CHANNEL_IFACE_MESSAGES, cs.CHANNEL_IFACE_ROOM, cs.CHANNEL_IFACE_SUBJECT, cs.CHANNEL_IFACE_ROOM_CONFIG, @@ -105,9 +104,7 @@ def test(q, bus, conn, stream, use_room=False): assert ec_path == path assert ec_props == props - channels = nc.args[0] - assert len(channels) == 1 - nc_path, nc_props = channels[0] + nc_path, nc_props = nc.args assert nc_path == path assert nc_props == props @@ -134,9 +131,9 @@ def test(q, bus, conn, stream, use_room=False): q.forbid_events(patterns) chan.Close() q.expect('dbus-signal', signal='Closed', path=chan.object_path) - e = q.expect('dbus-signal', signal='NewChannels') + e = q.expect('dbus-signal', signal='NewChannel') - path, props = e.args[0][0] + path, props = e.args assertEquals(chan.object_path, path) # We requested the channel originally, but we didn't request it popping # back up. @@ -144,7 +141,7 @@ def test(q, bus, conn, stream, use_room=False): assert not props[cs.REQUESTED] # The unacknowledged message should still be there and be marked as rescued. - messages = chan.Properties.Get(cs.CHANNEL_IFACE_MESSAGES, 'PendingMessages') + messages = chan.Properties.Get(cs.CHANNEL_TYPE_TEXT, 'PendingMessages') assertLength(1, messages) assert messages[0][0]['rescued'], messages[0] @@ -158,7 +155,7 @@ def test(q, bus, conn, stream, use_room=False): sync_stream(q, stream) q.unforbid_events(patterns) - chan.RemoveMembers([self_handle], "bye bye cruel\r\nworld", + chan.RemoveMembers([self_handle], "bye bye cruel\r\nworld", cs.GC_REASON_NONE, dbus_interface=cs.CHANNEL_IFACE_GROUP) part_event = q.expect('stream-PART') diff --git a/tests/twisted/channels/room-list-channel.py b/tests/twisted/channels/room-list-channel.py index a62d59f..ac2e031 100644 --- a/tests/twisted/channels/room-list-channel.py +++ b/tests/twisted/channels/room-list-channel.py @@ -41,8 +41,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) call_async(q, conn, 'CreateChannel', { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_ROOM_LIST }, @@ -52,16 +52,13 @@ def test(q, bus, conn, stream): assertEquals(cs.CHANNEL_TYPE_ROOM_LIST, properties[cs.CHANNEL_TYPE]) def looks_like_a_room_list(event): - channels, = event.args - if len(channels) != 1: - return False - path, props = channels[0] + path, props = event.args return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_ROOM_LIST and \ props[cs.TARGET_HANDLE_TYPE] == cs.HT_NONE and \ props[cs.TARGET_ID] == '' - e = q.expect('dbus-signal', signal='NewChannels', + q.expect('dbus-signal', signal='NewChannel', predicate=looks_like_a_room_list) chan = bus.get_object(conn.bus_name, path) diff --git a/tests/twisted/channels/room-list-multiple.py b/tests/twisted/channels/room-list-multiple.py index 568f4b4..37e77fe 100644 --- a/tests/twisted/channels/room-list-multiple.py +++ b/tests/twisted/channels/room-list-multiple.py @@ -17,8 +17,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) # request a roomlist channel call_async(q, conn, 'CreateChannel', @@ -30,16 +30,13 @@ def test(q, bus, conn, stream): # verify that a new channel was created and signalled def looks_like_a_room_list(event): - channels, = event.args - if len(channels) != 1: - return False - path, props = channels[0] + path, props = event.args return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_ROOM_LIST and \ props[cs.TARGET_HANDLE_TYPE] == cs.HT_NONE and \ props[cs.TARGET_ID] == '' - e = q.expect('dbus-signal', signal='NewChannels', + q.expect('dbus-signal', signal='NewChannel', predicate=looks_like_a_room_list) # FIXME: this is pretty questionable. diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py index 8fa3ece..fcf020a 100644 --- a/tests/twisted/cm/protocol.py +++ b/tests/twisted/cm/protocol.py @@ -11,19 +11,12 @@ import constants as cs def test(q, bus, conn, server): cm = bus.get_object(cs.CM + '.idle', tp_path_prefix + '/ConnectionManager/idle') - cm_iface = dbus.Interface(cm, cs.CM) cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE) protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols')) assertEquals(set(['irc']), set(protocols.keys())) - protocol_names = unwrap(cm_iface.ListProtocols()) - assertEquals(set(['irc']), set(protocol_names)) - - cm_params = cm_iface.GetParameters('irc') local_props = protocols['irc'] - local_params = local_props[cs.PROTOCOL + '.Parameters'] - assertEquals(cm_params, local_params) proto = bus.get_object(cm.bus_name, cm.object_path + '/irc') proto_iface = dbus.Interface(proto, cs.PROTOCOL) @@ -41,7 +34,6 @@ def test(q, bus, conn, server): assertEquals('im-irc', proto_props['Icon']) assertContains(cs.CONN_IFACE_ALIASING, proto_props['ConnectionInterfaces']) - assertContains(cs.CONN_IFACE_REQUESTS, proto_props['ConnectionInterfaces']) assertEquals('robot101', unwrap(proto_iface.NormalizeContact('Robot101'))) diff --git a/tests/twisted/connect/connect-close-ssl.py b/tests/twisted/connect/connect-close-ssl.py index 6fecd50..6da3ab4 100644 --- a/tests/twisted/connect/connect-close-ssl.py +++ b/tests/twisted/connect/connect-close-ssl.py @@ -13,9 +13,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - e = q.expect('dbus-signal', signal='NewChannels') - channels = e.args[0] - path, props = channels[0] + e = q.expect('dbus-signal', signal='NewChannel') + path, props = e.args channel = wrap_channel(bus.get_object(conn.bus_name, path), cs.CHANNEL_TYPE_SERVER_TLS_CONNECTION) diff --git a/tests/twisted/connect/connect-reject-ssl.py b/tests/twisted/connect/connect-reject-ssl.py index 8028428..31058b0 100644 --- a/tests/twisted/connect/connect-reject-ssl.py +++ b/tests/twisted/connect/connect-reject-ssl.py @@ -13,13 +13,12 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - e = q.expect('dbus-signal', signal='NewChannels') - channels = e.args[0] - path, props = channels[0] + e = q.expect('dbus-signal', signal='NewChannel') + path, props = e.args cert = bus.get_object (conn.bus_name, props[cs.TLS_CERT_PATH]) cert.Reject([(cs.TLS_REJECT_REASON_UNTRUSTED, cs.CERT_UNTRUSTED, {})], - signature = 'a(usa{sv})') + signature = 'a(usa{sv})', dbus_interface=cs.AUTH_TLS_CERT) q.expect('dbus-signal', signal='StatusChanged', args=[2, 2]) return True diff --git a/tests/twisted/connect/connect-success-ssl.py b/tests/twisted/connect/connect-success-ssl.py index 33062c5..e9e0b5a 100644 --- a/tests/twisted/connect/connect-success-ssl.py +++ b/tests/twisted/connect/connect-success-ssl.py @@ -13,15 +13,14 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - e = q.expect('dbus-signal', signal='NewChannels') - channels = e.args[0] - path, props = channels[0] + e = q.expect('dbus-signal', signal='NewChannel') + path, props = e.args cert = bus.get_object (conn.bus_name, props[cs.TLS_CERT_PATH]) - cert.Accept() + cert.Accept(dbus_interface=cs.AUTH_TLS_CERT) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) call_async(q, conn, 'Disconnect') q.expect_many( diff --git a/tests/twisted/connect/connect-success.py b/tests/twisted/connect/connect-success.py index 3281764..f1715b4 100644 --- a/tests/twisted/connect/connect-success.py +++ b/tests/twisted/connect/connect-success.py @@ -11,8 +11,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) call_async(q, conn, 'Disconnect') q.expect_many( diff --git a/tests/twisted/connect/disconnect-during-cert-verification.py b/tests/twisted/connect/disconnect-during-cert-verification.py index 83fe004..0c742f2 100644 --- a/tests/twisted/connect/disconnect-during-cert-verification.py +++ b/tests/twisted/connect/disconnect-during-cert-verification.py @@ -8,11 +8,14 @@ from idletest import exec_test, SSLIRCServer from servicetest import EventPattern, sync_dbus def test(q, bus, conn, stream): + cm = bus.get_object(cs.CM + '.idle', + '/' + cs.CM.replace('.', '/') + '/idle') + conn.Connect() q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - e = q.expect('dbus-signal', signal='NewChannels') + q.expect('dbus-signal', signal='NewChannel') conn.Disconnect() q.expect_many( @@ -21,7 +24,7 @@ def test(q, bus, conn, stream): ) # Idle would now crash in an idle callback; so let's see if it's alive. - sync_dbus(bus, q, conn) + sync_dbus(bus, q, cm) if __name__ == '__main__': exec_test(test, {'use-ssl':dbus.Boolean(True)}, protocol=SSLIRCServer) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index e21bc13..8272a67 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -22,7 +22,7 @@ Some handy constants for other tests to share and enjoy. from dbus import PROPERTIES_IFACE, INTROSPECTABLE_IFACE -PREFIX = "org.freedesktop.Telepathy" +PREFIX = "im.telepathy.v1" PATH_PREFIX = '/' + PREFIX.replace('.', '/') tp_name_prefix = PREFIX @@ -33,51 +33,39 @@ CM = PREFIX + ".ConnectionManager" HT_NONE = 0 HT_CONTACT = 1 HT_ROOM = 2 -HT_LIST = 3 -HT_GROUP = 4 CHANNEL = PREFIX + ".Channel" -CHANNEL_IFACE_CALL_STATE = CHANNEL + ".Interface.CallState" -CHANNEL_IFACE_CHAT_STATE = CHANNEL + '.Interface.ChatState' -CHANNEL_IFACE_DESTROYABLE = CHANNEL + ".Interface.Destroyable" -CHANNEL_IFACE_DTMF = CHANNEL + ".Interface.DTMF" -CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group" -CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold" -CHANNEL_IFACE_MEDIA_SIGNALLING = CHANNEL + ".Interface.MediaSignalling" -CHANNEL_IFACE_MESSAGES = CHANNEL + ".Interface.Messages" -CHANNEL_IFACE_PASSWORD = CHANNEL + ".Interface.Password" -CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube" -CHANNEL_IFACE_SASL_AUTH = CHANNEL + ".Interface.SASLAuthentication" -CHANNEL_IFACE_CONFERENCE = CHANNEL + '.Interface.Conference' -CHANNEL_IFACE_ROOM = CHANNEL + '.Interface.Room2' +CHANNEL_IFACE_CHAT_STATE = CHANNEL + '.Interface.ChatState1' +CHANNEL_IFACE_DESTROYABLE = CHANNEL + ".Interface.Destroyable1" +CHANNEL_IFACE_DTMF = CHANNEL + ".Interface.DTMF1" +CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group1" +CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold1" +CHANNEL_IFACE_PASSWORD = CHANNEL + ".Interface.Password1" +CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube1" +CHANNEL_IFACE_SASL_AUTH = CHANNEL + ".Interface.SASLAuthentication1" +CHANNEL_IFACE_CONFERENCE = CHANNEL + '.Interface.Conference1' +CHANNEL_IFACE_ROOM = CHANNEL + '.Interface.Room1' CHANNEL_IFACE_ROOM_CONFIG = CHANNEL + '.Interface.RoomConfig1' -CHANNEL_IFACE_SUBJECT = CHANNEL + '.Interface.Subject2' -CHANNEL_IFACE_FILE_TRANSFER_METADATA = CHANNEL + '.Interface.FileTransfer.Metadata' -CHANNEL_IFACE_SMS = CHANNEL + '.Interface.SMS' +CHANNEL_IFACE_SUBJECT = CHANNEL + '.Interface.Subject1' +CHANNEL_IFACE_FILE_TRANSFER_METADATA = CHANNEL + '.Interface.FileTransfer.Metadata1' CHANNEL_TYPE_CALL = CHANNEL + ".Type.Call1" -CHANNEL_TYPE_CONTACT_LIST = CHANNEL + ".Type.ContactList" -CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch" +CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch1" CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text" -CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes" -CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube" -CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube" -CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text" -CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer" -CHANNEL_TYPE_ROOM_LIST = CHANNEL + ".Type.RoomList" +CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube1" +CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube1" +CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer1" +CHANNEL_TYPE_ROOM_LIST = CHANNEL + ".Type.RoomList1" CHANNEL_TYPE_SERVER_AUTHENTICATION = \ - CHANNEL + ".Type.ServerAuthentication" + CHANNEL + ".Type.ServerAuthentication1" CHANNEL_TYPE_SERVER_TLS_CONNECTION = \ - CHANNEL + ".Type.ServerTLSConnection" - -TP_AWKWARD_PROPERTIES = PREFIX + ".Properties" -PROPERTY_FLAG_READ = 1 -PROPERTY_FLAG_WRITE = 2 -PROPERTY_FLAGS_RW = PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE + CHANNEL + ".Type.ServerTLSConnection1" CHANNEL_TYPE = CHANNEL + '.ChannelType' -TARGET_HANDLE_TYPE = CHANNEL + '.TargetHandleType' +TARGET_ENTITY_TYPE = CHANNEL + '.TargetEntityType' +# let's leave this as a synonym to reduce tests' diff churn in CMs +TARGET_HANDLE_TYPE = CHANNEL + '.TargetEntityType' TARGET_HANDLE = CHANNEL + '.TargetHandle' TARGET_ID = CHANNEL + '.TargetID' REQUESTED = CHANNEL + '.Requested' @@ -102,7 +90,7 @@ CALL_MUTABLE_CONTENTS = CHANNEL_TYPE_CALL + '.MutableContents' CALL_CONTENT = PREFIX + '.Call1.Content' CALL_CONTENT_IFACE_MEDIA = CALL_CONTENT + '.Interface.Media' -CALL_CONTENT_IFACE_DTMF = CALL_CONTENT + '.Interface.DTMF' +CALL_CONTENT_IFACE_DTMF = CALL_CONTENT + '.Interface.DTMF1' CALL_CONTENT_MEDIA_DESCRIPTION = CALL_CONTENT + '.MediaDescription' @@ -197,27 +185,24 @@ CONTACT_LIST_STATE_FAILURE = 2 CONTACT_LIST_STATE_SUCCESS = 3 CONN = PREFIX + ".Connection" -CONN_IFACE_AVATARS = CONN + '.Interface.Avatars' -CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing' -CONN_IFACE_CAPS = CONN + '.Interface.Capabilities' -CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts' -CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities' -CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo" -CONN_IFACE_PRESENCE = CONN + '.Interface.Presence' -CONN_IFACE_RENAMING = CONN + '.Interface.Renaming' +CONN_IFACE_AVATARS = CONN + '.Interface.Avatars1' +CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing1' +CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities1' +CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo1" +CONN_IFACE_PRESENCE = CONN + '.Interface.Presence1' +CONN_IFACE_RENAMING = CONN + '.Interface.Renaming1' CONN_IFACE_SIDECARS1 = CONN + '.Interface.Sidecars1' -CONN_IFACE_SIMPLE_PRESENCE = CONN + '.Interface.SimplePresence' CONN_IFACE_REQUESTS = CONN + '.Interface.Requests' -CONN_IFACE_LOCATION = CONN + '.Interface.Location' +CONN_IFACE_LOCATION = CONN + '.Interface.Location1' CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak' -CONN_IFACE_MAIL_NOTIFICATION = CONN + '.Interface.MailNotification' -CONN_IFACE_CONTACT_LIST = CONN + '.Interface.ContactList' -CONN_IFACE_CONTACT_GROUPS = CONN + '.Interface.ContactGroups' -CONN_IFACE_CLIENT_TYPES = CONN + '.Interface.ClientTypes' -CONN_IFACE_POWER_SAVING = CONN + '.Interface.PowerSaving' -CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking' +CONN_IFACE_MAIL_NOTIFICATION = CONN + '.Interface.MailNotification1' +CONN_IFACE_CONTACT_LIST = CONN + '.Interface.ContactList1' +CONN_IFACE_CONTACT_GROUPS = CONN + '.Interface.ContactGroups1' +CONN_IFACE_CLIENT_TYPES = CONN + '.Interface.ClientTypes1' +CONN_IFACE_POWER_SAVING = CONN + '.Interface.PowerSaving1' +CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking1' CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1' -CONN_IFACE_SERVICE_POINT = CONN + '.Interface.ServicePoint' +CONN_IFACE_SERVICE_POINT = CONN + '.Interface.ServicePoint1' ATTR_ALIAS = CONN_IFACE_ALIASING + '/alias' ATTR_AVATAR_TOKEN = CONN_IFACE_AVATARS + '/token' @@ -227,7 +212,7 @@ ATTR_CONTACT_ID = CONN + '/contact-id' ATTR_CONTACT_INFO = CONN_IFACE_CONTACT_INFO + '/info' ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' ATTR_LOCATION = CONN_IFACE_LOCATION + '/location' -ATTR_PRESENCE = CONN_IFACE_SIMPLE_PRESENCE + '/presence' +ATTR_PRESENCE = CONN_IFACE_PRESENCE + '/presence' ATTR_PUBLISH = CONN_IFACE_CONTACT_LIST + '/publish' ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' @@ -307,17 +292,13 @@ SOCKET_ADDRESS_TYPE_IPV6 = 3 SOCKET_ACCESS_CONTROL_LOCALHOST = 0 SOCKET_ACCESS_CONTROL_PORT = 1 -SOCKET_ACCESS_CONTROL_NETMASK = 2 -SOCKET_ACCESS_CONTROL_CREDENTIALS = 3 +SOCKET_ACCESS_CONTROL_CREDENTIALS = 2 TUBE_STATE_LOCAL_PENDING = 0 TUBE_STATE_REMOTE_PENDING = 1 TUBE_STATE_OPEN = 2 TUBE_STATE_NOT_OFFERED = 3 -TUBE_TYPE_DBUS = 0 -TUBE_TYPE_STREAM = 1 - MEDIA_STREAM_DIRECTION_NONE = 0 MEDIA_STREAM_DIRECTION_SEND = 1 MEDIA_STREAM_DIRECTION_RECEIVE = 2 @@ -329,15 +310,6 @@ MEDIA_STREAM_PENDING_REMOTE_SEND = 2 MEDIA_STREAM_TYPE_AUDIO = 0 MEDIA_STREAM_TYPE_VIDEO = 1 -MEDIA_STREAM_STATE_DISCONNECTED = 0 -MEDIA_STREAM_STATE_CONNECTING = 1 -MEDIA_STREAM_STATE_CONNECTED = 2 - -MEDIA_STREAM_DIRECTION_NONE = 0 -MEDIA_STREAM_DIRECTION_SEND = 1 -MEDIA_STREAM_DIRECTION_RECEIVE = 2 -MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3 - FT_STATE_NONE = 0 FT_STATE_PENDING = 1 FT_STATE_ACCEPTED = 2 @@ -384,8 +356,7 @@ GF_MESSAGE_RESCIND = 128 GF_CHANNEL_SPECIFIC_HANDLES = 256 GF_ONLY_ONE_GROUP = 512 GF_HANDLE_OWNERS_NOT_AVAILABLE = 1024 -GF_PROPERTIES = 2048 -GF_MEMBERS_CHANGED_DETAILED = 4096 +GF_MESSAGE_DEPART = 2048 GC_REASON_NONE = 0 GC_REASON_OFFLINE = 1 @@ -517,9 +488,9 @@ class SendError(object): NOT_IMPLEMENTED = 5 PROTOCOL = PREFIX + '.Protocol' -PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence' -PROTOCOL_IFACE_ADDRESSING = PROTOCOL + '.Interface.Addressing' -PROTOCOL_IFACE_AVATARS = PROTOCOL + '.Interface.Avatars' +PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence1' +PROTOCOL_IFACE_ADDRESSING = PROTOCOL + '.Interface.Addressing1' +PROTOCOL_IFACE_AVATARS = PROTOCOL + '.Interface.Avatars1' PARAM_REQUIRED = 1 PARAM_REGISTER = 2 @@ -539,9 +510,9 @@ TLS_REJECT_REASON_UNTRUSTED = 1 # Channel.Interface.Messages -MESSAGE_PART_SUPPORT_FLAGS = CHANNEL_IFACE_MESSAGES + '.MessagePartSupportFlags' -DELIVERY_REPORTING_SUPPORT = CHANNEL_IFACE_MESSAGES + '.DeliveryReportingSupport' -SUPPORTED_CONTENT_TYPES = CHANNEL_IFACE_MESSAGES + '.SupportedContentTypes' +MESSAGE_PART_SUPPORT_FLAGS = CHANNEL_TYPE_TEXT + '.MessagePartSupportFlags' +DELIVERY_REPORTING_SUPPORT = CHANNEL_TYPE_TEXT + '.DeliveryReportingSupport' +SUPPORTED_CONTENT_TYPES = CHANNEL_TYPE_TEXT + '.SupportedContentTypes' MSG_SENDING_FLAGS_REPORT_DELIVERY = 1 MSG_SENDING_FLAGS_REPORT_READ = 2 @@ -560,15 +531,7 @@ DELIVERY_STATUS_ACCEPTED = 4 DELIVERY_STATUS_READ = 5 DELIVERY_STATUS_DELETED = 6 -MEDIA_STREAM_ERROR_UNKNOWN = 0 -MEDIA_STREAM_ERROR_EOS = 1 -MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED = 2 -MEDIA_STREAM_ERROR_CONNECTION_FAILED = 3 -MEDIA_STREAM_ERROR_NETWORK_ERROR = 4 -MEDIA_STREAM_ERROR_NO_CODECS = 5 -MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR = 6 -MEDIA_STREAM_ERROR_MEDIA_ERROR = 7 - +PASSWORD_FLAG_HINT = 4 PASSWORD_FLAG_PROVIDE = 8 # Channel.Interface.Room @@ -580,7 +543,7 @@ SUBJECT = CHANNEL_IFACE_ROOM + '.Subject' SUBJECT_PRESENT = 1 SUBJECT_CAN_SET = 2 -DEBUG_IFACE = PREFIX + '.Debug' +DEBUG_IFACE = PREFIX + '.Debug1' DEBUG_PATH = PATH_PREFIX + '/debug' SERVICE_POINT_TYPE_NONE = 0 @@ -595,14 +558,14 @@ HANDLER = PREFIX + '.Client.Handler' CLIENT_IFACE_REQUESTS = CLIENT + '.Interface.Requests' ACCOUNT = PREFIX + '.Account' -ACCOUNT_IFACE_AVATAR = ACCOUNT + '.Interface.Avatar' -ACCOUNT_IFACE_ADDRESSING = ACCOUNT + '.Interface.Addressing' -ACCOUNT_IFACE_HIDDEN = ACCOUNT + '.Interface.Hidden.DRAFT1' +ACCOUNT_IFACE_AVATAR = ACCOUNT + '.Interface.Avatar1' +ACCOUNT_IFACE_ADDRESSING = ACCOUNT + '.Interface.Addressing1' +ACCOUNT_IFACE_HIDDEN = ACCOUNT + '.Interface.Hidden1' ACCOUNT_IFACE_NOKIA_CONDITIONS = 'com.nokia.Account.Interface.Conditions' ACCOUNT_PATH_PREFIX = PATH_PREFIX + '/Account/' AM = PREFIX + '.AccountManager' -AM_IFACE_HIDDEN = AM + '.Interface.Hidden.DRAFT1' +AM_IFACE_HIDDEN = AM + '.Interface.Hidden1' AM_PATH = PATH_PREFIX + '/AccountManager' CR = PREFIX + '.ChannelRequest' @@ -610,17 +573,16 @@ CDO = PREFIX + '.ChannelDispatchOperation' CD = PREFIX + '.ChannelDispatcher' CD_IFACE_MESSAGES1 = PREFIX + '.ChannelDispatcher.Interface.Messages1' -CD_IFACE_OP_LIST = PREFIX + '.ChannelDispatcher.Interface.OperationList' +CD_IFACE_OP_LIST = PREFIX + '.ChannelDispatcher.Interface.OperationList1' CD_PATH = PATH_PREFIX + '/ChannelDispatcher' -CD_REDISPATCH = CD + '.Interface.Redispatch.DRAFT' - -MC = PREFIX + '.MissionControl5' -MC_PATH = PATH_PREFIX + '/MissionControl5' +MC = PREFIX + '.MissionControl6' +MC_PATH = PATH_PREFIX + '/MissionControl6' DTMF_CURRENTLY_SENDING_TONES = CHANNEL_IFACE_DTMF + '.CurrentlySendingTones' DTMF_INITIAL_TONES = CHANNEL_IFACE_DTMF + '.InitialTones' DTMF_DEFERRED_TONES = CHANNEL_IFACE_DTMF + '.DeferredTones' +TESTS = PREFIX + ".Tests" TESTDOT = PREFIX + ".Test." TESTSLASH = PATH_PREFIX + "/Test/" @@ -631,6 +593,8 @@ TEST_DBUS_ACCOUNT_SERVICE_IFACE = TEST_DBUS_ACCOUNT_SERVICE TEST_DBUS_ACCOUNT_PLUGIN_PATH = TESTSLASH + "DBusAccountPlugin" TEST_DBUS_ACCOUNT_PLUGIN_IFACE = TESTDOT + "DBusAccountPlugin" -# Channel.Interface.SMS -SMS_FLASH = CHANNEL_IFACE_SMS + '.Flash' -SMS_CHANNEL = CHANNEL_IFACE_SMS + '.SMSChannel' +class StorageRestrictionFlags(object): + CANNOT_SET_PARAMETERS = 1 + CANNOT_SET_ENABLED = 2 + CANNOT_SET_PRESENCE = 4 + CANNOT_SET_SERVICE = 8 diff --git a/tests/twisted/contacts.py b/tests/twisted/contacts.py index 8df602e..0c1d05a 100644 --- a/tests/twisted/contacts.py +++ b/tests/twisted/contacts.py @@ -11,17 +11,11 @@ def test(q, bus, conn, stream): q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) interfaces = conn.Properties.Get(cs.CONN, "Interfaces") - assertContains(cs.CONN_IFACE_CONTACTS, interfaces) - - attr_ifaces = conn.Properties.Get(cs.CONN_IFACE_CONTACTS, - "ContactAttributeInterfaces") - assertContains(cs.CONN_IFACE_ALIASING, attr_ifaces) - assertContains(cs.CONN_IFACE_CONTACT_INFO, attr_ifaces) brillana, miriam = conn.get_contact_handles_sync(["brillana", "miriam"]) # First up, check that contact-id is always present - attrs = conn.Contacts.GetContactAttributes([brillana], [], True) + attrs = conn.Contacts.GetContactAttributes([brillana], []) assertContains(brillana, attrs) brillana_attrs = attrs[brillana] assertContains(cs.CONN + "/contact-id", brillana_attrs) @@ -30,7 +24,7 @@ def test(q, bus, conn, stream): # Test grabbing some aliases! Neither contact is known to have any # particular capitalization so they should be lowercase. attrs = conn.Contacts.GetContactAttributes([brillana, miriam], - [cs.CONN_IFACE_ALIASING], True) + [cs.CONN_IFACE_ALIASING]) assertContains(cs.CONN_IFACE_ALIASING + "/alias", attrs[brillana]) assertEquals("brillana", attrs[brillana][cs.CONN_IFACE_ALIASING + "/alias"]) assertEquals("miriam", attrs[miriam][cs.CONN_IFACE_ALIASING + "/alias"]) @@ -42,9 +36,9 @@ def test(q, bus, conn, stream): # We don't actually care about the message; the important bit is that her # alias changes. - q.expect('dbus-signal', signal='AliasesChanged', args=[[(brillana, bRiL)]]) + q.expect('dbus-signal', signal='AliasesChanged', args=[{brillana: bRiL}]) attrs = conn.Contacts.GetContactAttributes([brillana], - [cs.CONN_IFACE_ALIASING], True) + [cs.CONN_IFACE_ALIASING]) assertEquals(bRiL, attrs[brillana][cs.CONN_IFACE_ALIASING + "/alias"]) if __name__ == '__main__': diff --git a/tests/twisted/idletest.py b/tests/twisted/idletest.py index d60e774..c85acfb 100644 --- a/tests/twisted/idletest.py +++ b/tests/twisted/idletest.py @@ -159,8 +159,9 @@ class SSLIRCServer(BaseIRCServer): def listen(self, port, factory): self.log ("SSLIRCServer listening...") - key_file = os.environ.get('IDLE_SSL_KEY', 'tools/idletest.key') - cert_file = os.environ.get('IDLE_SSL_CERT', 'tools/idletest.cert') + G_TEST_SRCDIR = os.environ.get('G_TEST_SRCDIR', '.') + key_file = G_TEST_SRCDIR + '/tools/idletest.key' + cert_file = G_TEST_SRCDIR + '/tools/idletest.cert' return reactor.listenSSL(port, factory, ssl.DefaultOpenSSLContextFactory(key_file, cert_file)) diff --git a/tests/twisted/messages/accept-invalid-nicks.py b/tests/twisted/messages/accept-invalid-nicks.py index bd1f14b..3cec54b 100644 --- a/tests/twisted/messages/accept-invalid-nicks.py +++ b/tests/twisted/messages/accept-invalid-nicks.py @@ -13,14 +13,14 @@ def test(q, bus, conn, stream): q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) stream.sendMessage('PRIVMSG', stream.nick, ':testing testing', prefix='-bip') - q.expect('dbus-signal', signal='Received') + q.expect('dbus-signal', signal='MessageReceived') # FIXME: we should be lenient and accept unicode nicks that we recieve # from remote servers, but twisted can't seem to send unicode text so I # don't seem to be able to test this :( #stream.sendMessage('PRIVMSG', stream.nick, ':testing testing', prefix=u'김정은') - #q.expect('dbus-signal', signal='Received') + #q.expect('dbus-signal', signal='MessageReceived') stream.sendMessage('PRIVMSG', stream.nick, ':testing testing', prefix='12foo') - q.expect('dbus-signal', signal='Received') + q.expect('dbus-signal', signal='MessageReceived') call_async(q, conn, 'Disconnect') return True diff --git a/tests/twisted/messages/contactinfo-request.py b/tests/twisted/messages/contactinfo-request.py index 44464ca..462b913 100644 --- a/tests/twisted/messages/contactinfo-request.py +++ b/tests/twisted/messages/contactinfo-request.py @@ -37,8 +37,8 @@ def test(q, bus, conn, stream): q.expect_many( EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), EventPattern('irc-connected')) - q.expect('dbus-signal', signal='SelfHandleChanged', - args=[1L]) + q.expect('dbus-signal', signal='SelfContactChanged', + args=[1L, 'test']) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) self_handle = conn.Get(CONN, 'SelfHandle', dbus_interface=PROPERTIES_IFACE) @@ -50,7 +50,7 @@ def test(q, bus, conn, stream): TARGET_ID: name }) q.expect('dbus-return', method='CreateChannel') - q.expect('dbus-signal', signal='NewChannels') + q.expect('dbus-signal', signal='NewChannel') contact_info = dbus.Interface(conn, CONN_IFACE_CONTACT_INFO) diff --git a/tests/twisted/messages/leading-space.py b/tests/twisted/messages/leading-space.py index e14a87f..080dd69 100644 --- a/tests/twisted/messages/leading-space.py +++ b/tests/twisted/messages/leading-space.py @@ -6,7 +6,7 @@ recently fixed """ from idletest import exec_test, BaseIRCServer -from servicetest import EventPattern, call_async +from servicetest import EventPattern, call_async, assertEquals from constants import * import dbus @@ -20,9 +20,9 @@ def test(q, bus, conn, stream): stream.sendMessage('PRIVMSG', stream.nick, ':%s' % MESSAGE_WITH_LEADING_SPACE, prefix='remoteuser') # If telepathy-idle parses this message correctly, it should emit a - # 'Received' signal - q.expect('dbus-signal', signal='Received', - predicate=lambda x: x.args[5]==MESSAGE_WITH_LEADING_SPACE) + # 'MessageReceived' signal + e = q.expect('dbus-signal', signal='MessageReceived') + assertEquals(MESSAGE_WITH_LEADING_SPACE, e.args[0][1]['content']) call_async(q, conn, 'Disconnect') return True diff --git a/tests/twisted/messages/long-message-split.py b/tests/twisted/messages/long-message-split.py index fc8ce87..99ae40f 100644 --- a/tests/twisted/messages/long-message-split.py +++ b/tests/twisted/messages/long-message-split.py @@ -46,19 +46,26 @@ def test(q, bus, conn, stream): text_chan = dbus.Interface(chan, CHANNEL_TYPE_TEXT) # send a whole bunch of messages in a row - call_async(q, text_chan, 'Send', 0, LONG_MESSAGE) + message = [ + {'message-type': MT_NORMAL }, + {'content-type': 'text/plain', + 'content': LONG_MESSAGE }] - # apparently we only emit one 'Sent' signal even if we split a message up + call_async(q, text_chan, 'SendMessage', message, 0) + + # apparently we only emit one 'MessageSent' signal even if we split a message up # and send it in multiple messages - q.expect('dbus-signal', signal='Sent') + q.expect('dbus-signal', signal='MessageSent') - part1 = q.expect('dbus-signal', signal='Received') - n = len(part1.args[5]) + part1 = q.expect('dbus-signal', signal='MessageReceived') + content1 = part1.args[0][1]['content'] + n = len(content1) assert n <= 512, "Message exceeds IRC maximum: %d" % n - part2 = q.expect('dbus-signal', signal='Received') - n = len(part2.args[5]) + part2 = q.expect('dbus-signal', signal='MessageReceived') + content2 = part2.args[0][1]['content'] + n = len(content2) assert n <= 512, "Message exceeds IRC maximum: %d" % n - received_msg = part1.args[5] + part2.args[5] + received_msg = content1 + content2 assert received_msg == LONG_MESSAGE, received_msg diff --git a/tests/twisted/messages/message-order.py b/tests/twisted/messages/message-order.py index d307e29..ea91021 100644 --- a/tests/twisted/messages/message-order.py +++ b/tests/twisted/messages/message-order.py @@ -29,7 +29,12 @@ def test(q, bus, conn, stream): # in the proper order NUM_MESSAGES = 4 for i in range(NUM_MESSAGES): - call_async(q, text_chan, 'Send', 0, str(i)) + message = [ + {'message-type': MT_NORMAL }, + {'content-type': 'text/plain', + 'content': str(i) }] + + call_async(q, text_chan, 'SendMessage', message, 0) for i in range(NUM_MESSAGES): message = q.expect('stream-PRIVMSG') diff --git a/tests/twisted/messages/messages-iface.py b/tests/twisted/messages/messages-iface.py index 5bbfbed..9d75691 100644 --- a/tests/twisted/messages/messages-iface.py +++ b/tests/twisted/messages/messages-iface.py @@ -8,33 +8,21 @@ import constants as cs import dbus def test_sending(q, bus, conn, stream, chan): - # Send a message using Text API text_chan = dbus.Interface(chan, cs.CHANNEL_TYPE_TEXT) - call_async (q, text_chan, 'Send', cs.MT_NORMAL, "Hi!") - - q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, signal='MessageSent'), - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Sent'), - EventPattern('dbus-return', method='Send')) - - # Send a message using Messages API - msg_iface = dbus.Interface(chan, cs.CHANNEL_IFACE_MESSAGES) - message = [ {'message-type': cs.MT_NORMAL }, {'content-type': 'text/plain', 'content': 'What\'s up?',}] - call_async(q, msg_iface, 'SendMessage', message, 0) + call_async(q, text_chan, 'SendMessage', message, 0) q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, signal='MessageSent'), - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Sent'), + EventPattern('dbus-signal', signal='MessageSent'), EventPattern('dbus-return', method='SendMessage')) def test_dbus_properties (chan): - props = chan.GetAll(cs.CHANNEL_IFACE_MESSAGES, + props = chan.GetAll(cs.CHANNEL_TYPE_TEXT, dbus_interface=cs.PROPERTIES_IFACE) assert props['SupportedContentTypes'] == ['text/plain'] @@ -45,8 +33,6 @@ def test_dbus_properties (chan): def check_message(conn, msg, content, message_type=cs.MT_NORMAL): header = msg[0] assertEquals('alice', header['message-sender-id']) - handle = header['message-sender'] - assertEquals('alice', conn.InspectHandles(cs.HT_CONTACT, [handle])[0]) mtype = header.get('message-type', cs.MT_NORMAL); assertEquals(message_type, mtype) @@ -70,17 +56,11 @@ def test(q, bus, conn, stream): q.expect('dbus-signal', signal='MembersChanged') chan = bus.get_object(conn.bus_name, ret.value[0]) - props = ret.value[1] - assertContains(cs.CHANNEL_IFACE_MESSAGES, props[cs.INTERFACES]) - test_sending(q, bus, conn, stream, chan) # Receive a message on the channel stream.sendMessage('PRIVMSG', '#test', ":pony!", prefix='alice') - _, e = q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'), - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, - signal='MessageReceived')) + e = q.expect('dbus-signal', signal='MessageReceived') check_message(conn, e.args[0], "pony!") @@ -89,10 +69,7 @@ def test(q, bus, conn, stream): # Receive an action message on the channel stream.sendMessage('PRIVMSG', '#test', ":\001ACTION has no pony :(\001", prefix='alice') - _, e = q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'), - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, - signal='MessageReceived')) + e = q.expect('dbus-signal', signal='MessageReceived') check_message(conn, e.args[0], "has no pony :(", message_type = cs.MT_ACTION) @@ -106,28 +83,20 @@ def test(q, bus, conn, stream): ret = q.expect('dbus-return', method='CreateChannel') chan = bus.get_object(conn.bus_name, ret.value[0]) - props = ret.value[1] - assertContains(cs.CHANNEL_IFACE_MESSAGES, props[cs.INTERFACES]) - test_sending(q, bus, conn, stream, chan) # Receive a private message from Alice stream.sendMessage('PRIVMSG', stream.nick, ":i want my pony!", prefix='alice') - _, e = q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'), - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, - signal='MessageReceived')) + e = q.expect('dbus-signal', signal='MessageReceived') check_message(conn, e.args[0], "i want my pony!") # Receive an action message in private stream.sendMessage('PRIVMSG', stream.nick, ":\001ACTION has no pony :(\001", prefix='alice') - _, e = q.expect_many( - EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'), - EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES, - signal='MessageReceived')) + + e = q.expect('dbus-signal', signal='MessageReceived') check_message(conn, e.args[0], "has no pony :(", message_type = cs.MT_ACTION) diff --git a/tests/twisted/messages/room-contact-mixup.py b/tests/twisted/messages/room-contact-mixup.py index e53b454..a4038df 100644 --- a/tests/twisted/messages/room-contact-mixup.py +++ b/tests/twisted/messages/room-contact-mixup.py @@ -40,7 +40,7 @@ def test(q, bus, conn, stream): stream.sendMessage('PRIVMSG', NICK, ':PRIVATE', prefix=REMOTEUSER) - event = q.expect('dbus-signal', signal='Received') + event = q.expect('dbus-signal', signal='MessageReceived') # this seems a bit fragile, but I'm not entirely sure how else to ensure # that the message is not delivered to the MUC channel assert event.path not in muc_path diff --git a/tests/twisted/run-test.sh.in b/tests/twisted/run-test.sh.in index 2d9f3ae..f2b4773 100644 --- a/tests/twisted/run-test.sh.in +++ b/tests/twisted/run-test.sh.in @@ -1,74 +1,151 @@ #!/bin/sh -if test "x$IDLE_TEST_UNINSTALLED" = x; then - script_fullname=`readlink -e "@idletestsdir@/twisted/run-test.sh"` +# This script assumes that it is run in a temporary directory where it can +# create and delete subdirectories for files, logs, etc., but other users +# cannot write (for instance, /tmp is unsuitable, but +# the directory created by `mktemp -d /tmp/test.XXXXXXXXXX` is fine). +# +# During "make check" or "make installcheck" it runs in +# ${top_builddir}/tests/twisted. +# +# During installed testing, the test environment must run it in a +# suitable location. + +set -e + +CHECK_TWISTED_CURDIR="`pwd`" +export CHECK_TWISTED_CURDIR + +if test "x$CHECK_TWISTED_UNINSTALLED" = x; then + script_fullname=`readlink -e "@twistedtestsdir@/run-test.sh"` if [ `readlink -e "$0"` != "$script_fullname" ] ; then - echo "This script is meant to be installed at $script_fullname" >&2 + echo "Bail out! This script is meant to be installed at $script_fullname" exit 1 fi - test_src="@idletestsdir@" - test_build="@idletestsdir@" - config_file="@idletestsdir@/twisted/tools/servicedir/tmp-session-bus.conf" + G_TEST_SRCDIR="@twistedtestsdir@" + export G_TEST_SRCDIR + G_TEST_BUILDDIR="@twistedtestsdir@" + export G_TEST_BUILDDIR - PYTHONPATH="@idletestsdir@/twisted" + PYTHONPATH="${G_TEST_SRCDIR}" export PYTHONPATH - - IDLE_TWISTED_PATH="@idletestsdir@/twisted" - export IDLE_TWISTED_PATH else - if test -z "$IDLE_ABS_TOP_SRCDIR"; then - echo "IDLE_ABS_TOP_SRCDIR must be set" >&2 + if ! test -d "$G_TEST_SRCDIR"; then + echo "Bail out! G_TEST_SRCDIR must be set and absolute" exit 1 fi - if test -z "$IDLE_ABS_TOP_BUILDDIR"; then - echo "IDLE_ABS_TOP_BUILDDIR must be set" >&2 + if ! test -d "$G_TEST_BUILDDIR"; then + echo "Bail out! G_TEST_BUILDDIR must be set and absolute" exit 1 fi - test_src="${IDLE_ABS_TOP_SRCDIR}/tests" - test_build="${IDLE_ABS_TOP_BUILDDIR}/tests" - config_file="${test_build}/twisted/tools/tmp-session-bus.conf" - - PYTHONPATH="${test_src}/twisted:${test_build}/twisted" + PYTHONPATH="${G_TEST_SRCDIR}:${G_TEST_BUILDDIR}" export PYTHONPATH - - IDLE_TWISTED_PATH="${test_src}/twisted" - export IDLE_TWISTED_PATH fi -IDLE_SSL_KEY=${IDLE_ABS_TOP_SRCDIR}/tests/twisted/tools/idletest.key -export IDLE_SSL_KEY -IDLE_SSL_CERT=${IDLE_ABS_TOP_SRCDIR}/tests/twisted/tools/idletest.cert -export IDLE_SSL_CERT +config_file="${G_TEST_BUILDDIR}/tools/tmp-session-bus.conf" + +IDLE_DEBUG=all +export IDLE_DEBUG + +G_MESSAGES_DEBUG=all +export G_MESSAGES_DEBUG + +XDG_CONFIG_DIRS="${G_TEST_SRCDIR}" +export XDG_CONFIG_DIRS + +# Turn off anti-flooding to hurry the tests up (without this, +# channels/join-muc-channel-bouncer.py will time out, and the rest +# will be really slow) +IDLE_HTFU=seriously +export IDLE_HTFU if [ -n "$1" ] ; then list="$1" else - list=$(cat "${test_build}"/twisted/idle-twisted-tests.list) + list=$(cat "${G_TEST_BUILDDIR}"/twisted-tests.list) fi -any_failed=0 +n=0 for i in $list ; do - echo "Testing $i ..." - sh "${test_src}/twisted/tools/with-session-bus.sh" \ - ${IDLE_TEST_SLEEP} \ + n=$(( $n + 1 )) +done + +echo "1..$n" + +i=0 +n_failed=0 +for t in $list ; do + i=$(( $i + 1 )) + echo "# Testing $i/$n: $t ..." + + tmp="${CHECK_TWISTED_CURDIR}/tmp-`echo $t | tr ./ __`" + rm -fr "$tmp" + mkdir "$tmp" + + CHECK_TWISTED_LOG_DIR="${tmp}" + export CHECK_TWISTED_LOG_DIR + XDG_CONFIG_HOME="${tmp}/config" + export XDG_CONFIG_HOME + XDG_DATA_HOME="${tmp}/localshare" + export XDG_DATA_HOME + XDG_DATA_DIRS="${tmp}/share:${G_TEST_SRCDIR}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + export XDG_DATA_DIRS + XDG_CACHE_HOME="${tmp}/cache" + export XDG_CACHE_HOME + XDG_CACHE_DIR="${tmp}/cache" + export XDG_CACHE_DIR + IDLE_LOGFILE="${tmp}/cm.log" + export IDLE_LOGFILE + + CHECK_TWISTED_VERBOSE=1 + export CHECK_TWISTED_VERBOSE + + e=0 + sh "${G_TEST_SRCDIR}/tools/with-session-bus.sh" \ + ${CHECK_TWISTED_SLEEP} \ --config-file="${config_file}" \ -- \ - @TEST_PYTHON@ -u "${test_src}/twisted/$i" - e=$? + @TEST_PYTHON@ -u "${G_TEST_SRCDIR}/$t" \ + > "$tmp"/test.log 2>&1 || e=$? case "$e" in (0) - echo "PASS: $i" + echo "ok $i - $t" + if test -z "$CHECK_TWISTED_KEEP_TEMP"; then + rm -fr "$tmp" + fi ;; (77) - echo "SKIP: $i" + echo "ok $i # SKIP $t" + ( + cd $tmp && for x in *.log; do + echo "# ===== log file: $x =====" + sed 's/^/# /' "$x" + done + echo "# ===== end of log files for $t =====" + ) + if test -z "$CHECK_TWISTED_KEEP_TEMP"; then + rm -fr "$tmp" + fi ;; (*) - any_failed=1 - echo "FAIL: $i ($e)" + n_failed=$(( $n_failed + 1 )) + echo "not ok $i - $t ($e)" + ( + cd $tmp && for x in *.log; do + echo "# ===== log file: $x =====" + sed 's/^/# /' "$x" + done + echo "# ===== end of log files for $t =====" + ) ;; esac done -exit $any_failed +if test $n_failed != 0; then + echo "# Tests run: $n; tests failed: $n_failed" + exit 1 +else + exit 0 +fi diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index fcba708..0902b55 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -1,6 +1,23 @@ +# Copyright (C) 2009 Nokia Corporation +# Copyright (C) 2009-2013 Collabora Ltd. +# +# 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 """ -Infrastructure code for testing connection managers. +Infrastructure code for testing Telepathy services. """ from twisted.internet import glib2reactor @@ -14,6 +31,7 @@ import pprint import unittest import dbus +import dbus.lowlevel from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) @@ -22,7 +40,7 @@ from twisted.internet import reactor import constants as cs tp_name_prefix = cs.PREFIX -tp_path_prefix = '/' + cs.PREFIX.replace('.', '/') +tp_path_prefix = cs.PATH_PREFIX class DictionarySupersetOf (object): """Utility class for expecting "a dictionary with at least these keys".""" @@ -179,7 +197,14 @@ class BaseEventQueue: t = time.time() while True: - event = self.wait([pattern.subqueue]) + try: + event = self.wait([pattern.subqueue]) + except TimeoutError: + self.log('timeout') + self.log('still expecting:') + self.log(' - %r' % pattern) + raise + self._check_forbidden(event) if pattern.match(event): @@ -291,6 +316,11 @@ class IteratingEventQueue(BaseEventQueue): def __init__(self, timeout=None): BaseEventQueue.__init__(self, timeout) + self._dbus_method_impls = [] + self._buses = [] + # a message filter which will claim we handled everything + self._dbus_dev_null = \ + lambda bus, message: dbus.lowlevel.HANDLER_RESULT_HANDLED def wait(self, queues=None): stop = [False] @@ -315,6 +345,127 @@ class IteratingEventQueue(BaseEventQueue): else: raise TimeoutError + def add_dbus_method_impl(self, cb, bus=None, **kwargs): + if bus is None: + bus = self._buses[0] + + self._dbus_method_impls.append( + (EventPattern('dbus-method-call', **kwargs), cb)) + + def dbus_emit(self, path, iface, name, *a, **k): + bus = k.pop('bus', self._buses[0]) + assert 'signature' in k, k + message = dbus.lowlevel.SignalMessage(path, iface, name) + message.append(*a, **k) + bus.send_message(message) + + def dbus_return(self, in_reply_to, *a, **k): + bus = k.pop('bus', self._buses[0]) + assert 'signature' in k, k + reply = dbus.lowlevel.MethodReturnMessage(in_reply_to) + reply.append(*a, **k) + bus.send_message(reply) + + def dbus_raise(self, in_reply_to, name, message=None, bus=None): + if bus is None: + bus = self._buses[0] + + reply = dbus.lowlevel.ErrorMessage(in_reply_to, name, message) + bus.send_message(reply) + + def attach_to_bus(self, bus): + if not self._buses: + # first-time setup + self._dbus_filter_bound_method = self._dbus_filter + + self._buses.append(bus) + + # Only subscribe to messages on the first bus connection (assumed to + # be the shared session bus connection used by the simulated connection + # manager and most of the test suite), not on subsequent bus + # connections (assumed to represent extra clients). + # + # When we receive a method call on the other bus connections, ignore + # it - the eavesdropping filter installed on the first bus connection + # will see it too. + # + # This is highly counter-intuitive, but it means our messages are in + # a guaranteed order (we don't have races between messages arriving on + # various connections). + if len(self._buses) > 1: + bus.add_message_filter(self._dbus_dev_null) + return + + try: + # for dbus > 1.5 + bus.add_match_string("eavesdrop=true,type='signal'") + except dbus.DBusException: + bus.add_match_string("type='signal'") + bus.add_match_string("type='method_call'") + else: + bus.add_match_string("eavesdrop=true,type='method_call'") + + bus.add_message_filter(self._dbus_filter_bound_method) + + bus.add_signal_receiver( + lambda *args, **kw: + self.append( + Event('dbus-signal', + path=unwrap(kw['path']), + signal=kw['member'], + args=map(unwrap, args), + interface=kw['interface'])), + None, + None, + None, + path_keyword='path', + member_keyword='member', + interface_keyword='interface', + byte_arrays=True, + ) + + def cleanup(self): + if self._buses: + self._buses[0].remove_message_filter(self._dbus_filter_bound_method) + for bus in self._buses[1:]: + bus.remove_message_filter(self._dbus_dev_null) + + self._buses = [] + self._dbus_method_impls = [] + + def _dbus_filter(self, bus, message): + if isinstance(message, dbus.lowlevel.MethodCallMessage): + + destination = message.get_destination() + sender = message.get_sender() + + if (destination == 'org.freedesktop.DBus' or + sender == self._buses[0].get_unique_name()): + # suppress reply and don't make an Event + return dbus.lowlevel.HANDLER_RESULT_HANDLED + + e = Event('dbus-method-call', message=message, + interface=message.get_interface(), path=message.get_path(), + raw_args=message.get_args_list(byte_arrays=True), + args=map(unwrap, message.get_args_list(byte_arrays=True)), + destination=str(destination), + method=message.get_member(), + sender=message.get_sender(), + handled=False) + + for pair in self._dbus_method_impls: + pattern, cb = pair + if pattern.match(e): + cb(e) + e.handled = True + break + + self.append(e) + + return dbus.lowlevel.HANDLER_RESULT_HANDLED + + return dbus.lowlevel.HANDLER_RESULT_NOT_YET_HANDLED + class TestEventQueue(BaseEventQueue): def __init__(self, events): BaseEventQueue.__init__(self) @@ -425,19 +576,33 @@ def call_async(test, proxy, method, *args, **kw): kw.update({'reply_handler': reply_func, 'error_handler': error_func}) method_proxy(*args, **kw) -def sync_dbus(bus, q, conn): - # Dummy D-Bus method call. We can't use DBus.Peer.Ping() because libdbus - # replies to that message immediately, rather than handing it up to - # dbus-glib and thence Gabble, which means that Ping()ing Gabble doesn't - # ensure that it's processed all D-Bus messages prior to our ping. - # - # This won't do the right thing unless the proxy has a unique name. - assert conn.object.bus_name.startswith(':') - root_object = bus.get_object(conn.object.bus_name, '/', introspect=False) - call_async(q, - dbus.Interface(root_object, cs.PREFIX + '.Tests'), - 'DummySyncDBus') - q.expect('dbus-error', method='DummySyncDBus') +def sync_dbus(bus, q, proxy): + # We need to use functionality that is actually implemented by tp-glib, + # because unimplemented and built-in functionality in GDBus can jump + # the queue. <https://bugzilla.gnome.org/show_bug.cgi?id=726259> + + if proxy.object_path == cs.AM_PATH: + call_async(q, dbus.Interface(proxy, cs.PROPERTIES_IFACE), + 'Get', cs.AM, 'Interfaces') + q.expect('dbus-return', method='Get') + elif proxy.object_path.startswith(cs.ACCOUNT_PATH_PREFIX): + call_async(q, dbus.Interface(proxy, cs.PROPERTIES_IFACE), + 'Get', cs.ACCOUNT, 'Enabled') + q.expect('dbus-return', method='Get') + elif proxy.object_path.startswith('/' + cs.CONN.replace('.', '/') + '/'): + # It could be a Connection or a Channel. Assume it's a Connection + # for now, that's what all the CM tests use in practice + call_async(q, dbus.Interface(proxy, cs.PROPERTIES_IFACE), + 'Get', cs.CONN, 'Status') + q.expect('dbus-return', method='Get') + elif proxy.object_path.startswith('/' + cs.CM.replace('.', '/') + '/'): + # It could be a ConnectionManager or a Protocol. Assume it's a + # ConnectionManager for now + call_async(q, dbus.Interface(proxy, cs.PROPERTIES_IFACE), + 'Get', cs.CM, 'Protocols') + q.expect('dbus-return', method='Get') + else: + raise AssertionError("don't know how to sync %s" % proxy.object_path) class ProxyWrapper: def __init__(self, object, default, others={}): @@ -464,7 +629,7 @@ class ConnWrapper(ProxyWrapper): return self.inspect_contacts_sync([handle])[0] def inspect_contacts_sync(self, handles): - h2asv = self.Contacts.GetContactAttributes(handles, [], True) + h2asv = self.Contacts.GetContactAttributes(handles, []) ret = [] for h in handles: ret.append(h2asv[h][cs.ATTR_CONTACT_ID]) @@ -478,26 +643,46 @@ class ConnWrapper(ProxyWrapper): def wrap_connection(conn): return ConnWrapper(conn, tp_name_prefix + '.Connection', - dict([ - (name, tp_name_prefix + '.Connection.Interface.' + name) - for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts', - 'SimplePresence', 'Requests']] + + dict( [('Peer', 'org.freedesktop.DBus.Peer'), + ('Contacts', cs.CONN), # backwards compat with Telepathy 0 + ('Aliasing', cs.CONN_IFACE_ALIASING), + ('Avatars', cs.CONN_IFACE_AVATARS), ('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS), ('ContactInfo', cs.CONN_IFACE_CONTACT_INFO), ('Location', cs.CONN_IFACE_LOCATION), - ('Future', tp_name_prefix + '.Connection.FUTURE'), + ('Presence', cs.CONN_IFACE_PRESENCE), + ('Requests', cs.CONN_IFACE_REQUESTS), ('MailNotification', cs.CONN_IFACE_MAIL_NOTIFICATION), ('ContactList', cs.CONN_IFACE_CONTACT_LIST), ('ContactGroups', cs.CONN_IFACE_CONTACT_GROUPS), + ('ContactBlocking', cs.CONN_IFACE_CONTACT_BLOCKING), ('PowerSaving', cs.CONN_IFACE_POWER_SAVING), ('Addressing', cs.CONN_IFACE_ADDRESSING), + ('ClientTypes', cs.CONN_IFACE_CLIENT_TYPES), + ('Renaming', cs.CONN_IFACE_RENAMING), + ('Sidecars1', cs.CONN_IFACE_SIDECARS1), ])) +class ChannelWrapper(ProxyWrapper): + def send_msg_sync(self, txt): + message = [ + { 'message-type': cs.MT_NORMAL, }, + { 'content-type': 'text/plain', + 'content': txt + }] + self.Text.SendMessage(message, 0) + def wrap_channel(chan, type_, extra=None): interfaces = { type_: tp_name_prefix + '.Channel.Type.' + type_, - 'Group': tp_name_prefix + '.Channel.Interface.Group', + 'Channel': cs.CHANNEL, + 'Group': cs.CHANNEL_IFACE_GROUP, + 'Hold': cs.CHANNEL_IFACE_HOLD, + 'RoomConfig1': cs.CHANNEL_IFACE_ROOM_CONFIG, + 'ChatState': cs.CHANNEL_IFACE_CHAT_STATE, + 'Destroyable': cs.CHANNEL_IFACE_DESTROYABLE, + 'Password': cs.CHANNEL_IFACE_PASSWORD, } if extra: @@ -505,11 +690,14 @@ def wrap_channel(chan, type_, extra=None): (name, tp_name_prefix + '.Channel.Interface.' + name) for name in extra])) - return ProxyWrapper(chan, tp_name_prefix + '.Channel', interfaces) + return ChannelWrapper(chan, tp_name_prefix + '.Channel', interfaces) def wrap_content(chan, extra=None): - interfaces = { } + interfaces = { + 'DTMF': cs.CALL_CONTENT_IFACE_DTMF, + 'Media': cs.CALL_CONTENT_IFACE_MEDIA, + } if extra: interfaces.update(dict([ diff --git a/tests/twisted/tools/Makefile.am b/tests/twisted/tools/Makefile.am index 35f8a91..d58c8f4 100644 --- a/tests/twisted/tools/Makefile.am +++ b/tests/twisted/tools/Makefile.am @@ -3,18 +3,23 @@ exec-with-log.sh: exec-with-log.sh.in -e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" $< > $@ chmod +x $@ +servicedir = $(DBUS_SERVICES_DIR) + %.conf: %.conf.in - sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ + @$(MKDIR_P) installed + sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \ + -e "s|[@]servicedir[@]|$(servicedir)|g" \ + $< > $@ # We don't use the full filename for the .in because > 99 character filenames # in tarballs are non-portable (and automake 1.8 doesn't let us build # non-archaic tarballs) -org.freedesktop.Telepathy.ConnectionManager.%.service: %.service.in +im.telepathy.v1.ConnectionManager.%.service: %.service.in sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ # D-Bus service file for testing service_in_files = idle.service.in -service_files = org.freedesktop.Telepathy.ConnectionManager.idle.service +service_files = im.telepathy.v1.ConnectionManager.idle.service # D-Bus config file for testing conf_in_files = tmp-session-bus.conf.in @@ -22,14 +27,37 @@ conf_files = $(conf_in_files:.conf.in=.conf) BUILT_SOURCES = $(service_files) $(conf_files) exec-with-log.sh +dist_test_scripts = \ + with-session-bus.sh \ + $(NULL) + +dist_test_data = \ + idletest.cert \ + idletest.key \ + $(NULL) + +built_test_data = \ + installed/tmp-session-bus.conf \ + $(NULL) + EXTRA_DIST = \ + $(dist_test_data) \ + $(dist_test_scripts) \ $(service_in_files) \ $(conf_in_files) \ + installed/tmp-session-bus.conf.in \ exec-with-log.sh.in \ - idletest.cert \ - idletest.key \ - with-session-bus.sh + $(NULL) CLEANFILES = \ $(BUILT_SOURCES) \ idle-testing.log + +if ENABLE_INSTALLED_TESTS +testsdir = ${datadir}/telepathy-idle-1-tests +twistedtestsdir = ${testsdir}/twisted +twistedtoolsdir = ${twistedtestsdir}/tools +dist_twistedtools_SCRIPTS = $(dist_test_scripts) +dist_twistedtools_DATA = $(dist_test_data) +twistedtools_DATA = $(built_test_data) +endif diff --git a/tests/twisted/tools/exec-with-log.sh.in b/tests/twisted/tools/exec-with-log.sh.in index 3538044..6cad211 100644 --- a/tests/twisted/tools/exec-with-log.sh.in +++ b/tests/twisted/tools/exec-with-log.sh.in @@ -2,11 +2,16 @@ cd "@abs_top_builddir@/tests/twisted/tools" -export IDLE_DEBUG=all IDLE_HTFU=seriously +if test -z "$CHECK_TWISTED_LOG_DIR"; then + echo "CHECK_TWISTED_LOG_DIR must be set" + exit 1 +fi + +export IDLE_DEBUG=all G_MESSAGES_DEBUG=all export G_MESSAGES_DEBUG ulimit -c unlimited -exec >> idle-testing.log 2>&1 +exec > "${CHECK_TWISTED_LOG_DIR}/idle-testing.log" 2>&1 if test -n "$IDLE_TEST_VALGRIND"; then export G_DEBUG=${G_DEBUG:+"${G_DEBUG},"}gc-friendly @@ -26,4 +31,4 @@ elif test -n "$IDLE_TEST_REFDBG"; then fi export G_DEBUG=fatal-warnings" ${G_DEBUG}" -exec @abs_top_builddir@/libtool --mode=execute $IDLE_WRAPPER @abs_top_builddir@/src/telepathy-idle +exec @abs_top_builddir@/libtool --mode=execute $IDLE_WRAPPER @abs_top_builddir@/src/telepathy-idle-1 diff --git a/tests/twisted/tools/idle.service.in b/tests/twisted/tools/idle.service.in index 467adef..d7c9596 100644 --- a/tests/twisted/tools/idle.service.in +++ b/tests/twisted/tools/idle.service.in @@ -1,3 +1,3 @@ [D-BUS Service] -Name=org.freedesktop.Telepathy.ConnectionManager.idle +Name=im.telepathy.v1.ConnectionManager.idle Exec=@abs_top_builddir@/tests/twisted/tools/exec-with-log.sh diff --git a/tests/twisted/tools/installed/tmp-session-bus.conf.in b/tests/twisted/tools/installed/tmp-session-bus.conf.in new file mode 100644 index 0000000..0984f16 --- /dev/null +++ b/tests/twisted/tools/installed/tmp-session-bus.conf.in @@ -0,0 +1,12 @@ +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <type>session</type> + <listen>unix:tmpdir=/tmp</listen> + <servicedir>@servicedir@</servicedir> + <policy context="default"> + <allow send_destination="*" eavesdrop="true"/> + <allow eavesdrop="true"/> + <allow own="*"/> + </policy> +</busconfig> diff --git a/tools/Makefile.am b/tools/Makefile.am index 7b4106d..8fdb87b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,14 +1,2 @@ EXTRA_DIST = \ - c-constants-generator.xsl \ - c-interfaces-generator.xsl \ - doc-generator.xsl \ - glib-ginterface-gen.py \ - identity.xsl \ - libglibcodegen.py \ - libtpcodegen.py \ make-release-mail.py - -CLEANFILES = libglibcodegen.pyc libglibcodegen.pyo - -glib-ginterface-gen.py: libglibcodegen.py libtpcodegen.py - touch $@ diff --git a/tools/c-constants-generator.xsl b/tools/c-constants-generator.xsl deleted file mode 100644 index 2838ee1..0000000 --- a/tools/c-constants-generator.xsl +++ /dev/null @@ -1,257 +0,0 @@ -<!-- Stylesheet to extract C enumerations from the Telepathy spec. -The master copy of this stylesheet is in telepathy-glib - 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 -Library 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 Street, 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:output method="text" indent="no" encoding="ascii"/> - - <xsl:param name="mixed-case-prefix" select="''"/> - - <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> - <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> - - <xsl:variable name="upper-case-prefix" select="concat(translate($mixed-case-prefix, $lower, $upper), '_')"/> - <xsl:variable name="lower-case-prefix" select="concat(translate($mixed-case-prefix, $upper, $lower), '_')"/> - - - <xsl:template match="tp:flags"> - <xsl:variable name="name"> - <xsl:choose> - <xsl:when test="@plural"> - <xsl:value-of select="@plural"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> -/** - * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: -<xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates> * -<xsl:if test="tp:docstring"> - * <![CDATA[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> - * -</xsl:if> * Bitfield/set of flags generated from the Telepathy specification. - */ -typedef enum { -<xsl:apply-templates> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; - -</xsl:template> - - <xsl:template match="text()" mode="flag-or-enumvalue-gtkdoc"/> - - <xsl:template match="tp:enumvalue" mode="flag-or-enumvalue-gtkdoc"> - <xsl:param name="value-prefix"/> - <xsl:text> * @</xsl:text> - <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: <![CDATA[</xsl:text> - <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text>]]> </xsl:text> - </xsl:template> - - <xsl:template match="tp:flag" mode="flag-or-enumvalue-gtkdoc"> - <xsl:param name="value-prefix"/> - <xsl:text> * @</xsl:text> - <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: <![CDATA[</xsl:text> - <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text>]]> </xsl:text> - </xsl:template> - - <xsl:template match="tp:enum"> - <xsl:variable name="name"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name-plural"> - <xsl:choose> - <xsl:when test="@plural"> - <xsl:value-of select="@plural"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/><xsl:text>s</xsl:text> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> -/** - * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: -<xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates> * -<xsl:if test="tp:docstring"> - * <![CDATA[[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> - * -</xsl:if> * Enumeration generated from the Telepathy specification. - */ -typedef enum { -<xsl:apply-templates> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; - -/** - * NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/>: - * - * 1 higher than the highest valid value of #<xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>. - */ -#define NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/> (<xsl:value-of select="tp:enumvalue[position() = last()]/@value"/>+1) - -</xsl:template> - - <xsl:template match="tp:flags/tp:flag"> - <xsl:param name="value-prefix"/> - <xsl:variable name="suffix"> - <xsl:choose> - <xsl:when test="@suffix"> - <xsl:value-of select="@suffix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> - - <xsl:if test="@name and @suffix and @name != @suffix"> - <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> -</xsl:message> - </xsl:if> - <xsl:text> </xsl:text><xsl:value-of select="$name"/> = <xsl:value-of select="@value"/>, -</xsl:template> - - <xsl:template match="tp:enum/tp:enumvalue"> - <xsl:param name="value-prefix"/> - <xsl:variable name="suffix"> - <xsl:choose> - <xsl:when test="@suffix"> - <xsl:value-of select="@suffix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> - - <xsl:if test="@name and @suffix and @name != @suffix"> - <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> -</xsl:message> - </xsl:if> - - <xsl:if test="preceding-sibling::tp:enumvalue and number(preceding-sibling::tp:enumvalue[1]/@value) > number(@value)"> - <xsl:message terminate="yes">Enum values must be in ascending numeric order, -but <xsl:value-of select="$name"/> is less than the previous value -</xsl:message> - </xsl:if> - - <xsl:text> </xsl:text><xsl:value-of select="$name"/> = <xsl:value-of select="@value"/>, -</xsl:template> - - <xsl:template match="tp:flag"> - <xsl:message terminate="yes">tp:flag found outside tp:flags -</xsl:message> - </xsl:template> - - <xsl:template match="tp:enumvalue"> - <xsl:message terminate="yes">tp:enumvalue found outside tp:enum -</xsl:message> - </xsl:template> - - <xsl:template match="text()"/> - - <xsl:template match="/tp:spec"> - <xsl:if test="$mixed-case-prefix = ''"> - <xsl:message terminate="yes"> - <xsl:text>mixed-case-prefix param must be set </xsl:text> - </xsl:message> - </xsl:if> - - <xsl:text>/* Generated from </xsl:text> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text>, version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - <xsl:text> </xsl:text> - <xsl:for-each select="tp:copyright"> - <xsl:value-of select="."/> - <xsl:text> </xsl:text> - </xsl:for-each> - <xsl:value-of select="tp:license"/> - <xsl:text> </xsl:text> - <xsl:value-of select="tp:docstring"/> - <xsl:text> */ - -#ifdef __cplusplus -extern "C" { -#endif - -</xsl:text> - <xsl:apply-templates/> - <xsl:text> - -#ifdef __cplusplus -} -#endif - -</xsl:text> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/c-interfaces-generator.xsl b/tools/c-interfaces-generator.xsl deleted file mode 100644 index 38cbd7e..0000000 --- a/tools/c-interfaces-generator.xsl +++ /dev/null @@ -1,84 +0,0 @@ -<!-- Stylesheet to extract C enumerations from the Telepathy spec. -The master copy of this stylesheet is in telepathy-glib - 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 -Library 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 Street, 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:param name="mixed-case-prefix" select="''"/> - - <xsl:variable name="PREFIX" - select="translate($mixed-case-prefix, $lower, $upper)"/> - <xsl:variable name="Prefix" select="$mixed-case-prefix"/> - <xsl:variable name="prefix" - select="translate($mixed-case-prefix, $upper, $lower)"/> - - <xsl:output method="text" indent="no" encoding="ascii"/> - - <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> - <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> - - <xsl:template match="interface"> - <xsl:text>/** * </xsl:text> - <xsl:value-of select="$PREFIX"/> - <xsl:text>_IFACE_</xsl:text> - <xsl:value-of select="translate(../@name, concat($lower, '/'), $upper)"/> - <xsl:text>: * * The interface name "</xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>" */ #define </xsl:text> - <xsl:value-of select="$PREFIX"/> - <xsl:text>_IFACE_</xsl:text> - <xsl:value-of select="translate(../@name, concat($lower, '/'), $upper)"/> - <xsl:text> \ "</xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>" </xsl:text> - </xsl:template> - - <xsl:template match="text()"/> - - <xsl:template match="/tp:spec"> - <xsl:if test="$mixed-case-prefix = ''"> - <xsl:message terminate="yes"> - <xsl:text>mixed-case-prefix param must be set </xsl:text> - </xsl:message> - </xsl:if> - - <xsl:text>/* Generated from: </xsl:text> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text> version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - <xsl:text> </xsl:text> - <xsl:for-each select="tp:copyright"> - <xsl:value-of select="."/> - <xsl:text> </xsl:text> - </xsl:for-each> - <xsl:text> </xsl:text> - <xsl:value-of select="tp:license"/> - <xsl:value-of select="tp:docstring"/> - <xsl:text> */ </xsl:text> - <xsl:apply-templates/> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/doc-generator.xsl b/tools/doc-generator.xsl deleted file mode 100644 index 83b42dc..0000000 --- a/tools/doc-generator.xsl +++ /dev/null @@ -1,689 +0,0 @@ -<!-- Generate HTML documentation from the Telepathy specification. -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 -Library 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 ---> - -<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"> - <!--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="*" mode="identity"> - <xsl:copy> - <xsl:apply-templates mode="identity"/> - </xsl:copy> - </xsl:template> - - <xsl:template match="tp:docstring"> - <xsl:apply-templates select="node()" mode="identity"/> - </xsl:template> - - <xsl:template match="tp:errors"> - <h1 xmlns="http://www.w3.org/1999/xhtml">Errors</h1> - <xsl:apply-templates/> - </xsl:template> - - <xsl:template match="tp:generic-types"> - <h1 xmlns="http://www.w3.org/1999/xhtml">Generic types</h1> - <xsl:call-template name="do-types"/> - </xsl:template> - - <xsl:template name="do-types"> - <xsl:if test="tp:simple-type"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Simple types</h2> - <xsl:apply-templates select="tp:simple-type"/> - </xsl:if> - - <xsl:if test="tp:enum"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Enumerated types:</h2> - <xsl:apply-templates select="tp:enum"/> - </xsl:if> - - <xsl:if test="tp:flags"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Sets of flags:</h2> - <xsl:apply-templates select="tp:flags"/> - </xsl:if> - - <xsl:if test="tp:struct"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Structure types</h2> - <xsl:apply-templates select="tp:struct"/> - </xsl:if> - - <xsl:if test="tp:mapping"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Mapping types</h2> - <xsl:apply-templates select="tp:mapping"/> - </xsl:if> - - <xsl:if test="tp:external-type"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Types defined elsewhere</h2> - <dl><xsl:apply-templates select="tp:external-type"/></dl> - </xsl:if> - </xsl:template> - - <xsl:template match="tp:error"> - <h2 xmlns="http://www.w3.org/1999/xhtml"><a name="{concat(../@namespace, '.', translate(@name, ' ', ''))}"></a><xsl:value-of select="concat(../@namespace, '.', translate(@name, ' ', ''))"/></h2> - <xsl:apply-templates select="tp:docstring"/> - </xsl:template> - - <xsl:template match="/tp:spec/tp:copyright"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates/> - </div> - </xsl:template> - <xsl:template match="/tp:spec/tp:license"> - <div xmlns="http://www.w3.org/1999/xhtml" class="license"> - <xsl:apply-templates mode="identity"/> - </div> - </xsl:template> - - <xsl:template match="tp:copyright"/> - <xsl:template match="tp:license"/> - - <xsl:template match="interface"> - <h1 xmlns="http://www.w3.org/1999/xhtml"><a name="{@name}"></a><xsl:value-of select="@name"/></h1> - - <xsl:if test="@tp:causes-havoc"> - <p xmlns="http://www.w3.org/1999/xhtml" class="causes-havoc"> - This interface is <xsl:value-of select="@tp:causes-havoc"/> - and is likely to cause havoc to your API/ABI if bindings are generated. - Don't include it in libraries that care about compatibility. - </p> - </xsl:if> - - <xsl:if test="tp:requires"> - <p>Implementations of this interface must also implement:</p> - <ul xmlns="http://www.w3.org/1999/xhtml"> - <xsl:for-each select="tp:requires"> - <li><code><a href="#{@interface}"><xsl:value-of select="@interface"/></a></code></li> - </xsl:for-each> - </ul> - </xsl:if> - - <xsl:apply-templates select="tp:docstring" /> - - <xsl:choose> - <xsl:when test="method"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Methods:</h2> - <xsl:apply-templates select="method"/> - </xsl:when> - <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no methods.</p> - </xsl:otherwise> - </xsl:choose> - - <xsl:choose> - <xsl:when test="signal"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Signals:</h2> - <xsl:apply-templates select="signal"/> - </xsl:when> - <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no signals.</p> - </xsl:otherwise> - </xsl:choose> - - <xsl:choose> - <xsl:when test="tp:property"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Properties:</h2> - <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> - </xsl:otherwise> - </xsl:choose> - - <xsl:call-template name="do-types"/> - - </xsl:template> - - <xsl:template match="tp:flags"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </h3> - <xsl:apply-templates select="tp:docstring" /> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:for-each select="tp:flag"> - <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt> - <xsl:choose> - <xsl:when test="tp:docstring"> - <dd xmlns="http://www.w3.org/1999/xhtml"><xsl:apply-templates select="tp:docstring" /></dd> - </xsl:when> - <xsl:otherwise> - <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </dl> - </xsl:template> - - <xsl:template match="tp:enum"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </h3> - <xsl:apply-templates select="tp:docstring" /> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:for-each select="tp:enumvalue"> - <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt> - <xsl:choose> - <xsl:when test="tp:docstring"> - <dd xmlns="http://www.w3.org/1999/xhtml"><xsl:apply-templates select="tp:docstring" /></dd> - </xsl:when> - <xsl:otherwise> - <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </dl> - </xsl:template> - - <xsl:template match="tp:property"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <xsl:if test="@name"> - <code><xsl:value-of select="@name"/></code> - - </xsl:if> - <code><xsl:value-of select="@type"/></code> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring"/> - </dd> - </xsl:template> - - <xsl:template match="tp:mapping"> - <div xmlns="http://www.w3.org/1999/xhtml" class="struct"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - a{ - <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:text>: </xsl:text> - <xsl:value-of select="@name"/> - <xsl:if test="position() != last()"> → </xsl:if> - </xsl:for-each> - } - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - <div> - <h4>Members</h4> - <dl> - <xsl:apply-templates select="tp:member" mode="members-in-docstring"/> - </dl> - </div> - </div> - </xsl:template> - - <xsl:template match="tp:docstring" mode="in-index"/> - - <xsl:template match="tp:simple-type | tp:enum | tp:flags | tp:external-type" - mode="in-index"> - - <xsl:value-of select="@type"/> - </xsl:template> - - <xsl:template match="tp:simple-type"> - <div xmlns="http://www.w3.org/1999/xhtml" class="simple-type"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - <xsl:value-of select="@type"/> - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - </div> - </xsl:template> - - <xsl:template match="tp:external-type"> - <div xmlns="http://www.w3.org/1999/xhtml" class="external-type"> - <dt> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - <xsl:value-of select="@type"/> - </dt> - <dd>Defined by: <xsl:value-of select="@from"/></dd> - </div> - </xsl:template> - - <xsl:template match="tp:struct" mode="in-index"> - - ( <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> ) - </xsl:template> - - <xsl:template match="tp:mapping" mode="in-index"> - - a{ <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()"> → </xsl:if> - </xsl:for-each> } - </xsl:template> - - <xsl:template match="tp:struct"> - <div xmlns="http://www.w3.org/1999/xhtml" class="struct"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - ( - <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:text>: </xsl:text> - <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - ) - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - <xsl:choose> - <xsl:when test="string(@array-name) != ''"> - <p>In bindings that need a separate name, arrays of - <xsl:value-of select="@name"/> should be called - <xsl:value-of select="@array-name"/>.</p> - </xsl:when> - <xsl:otherwise> - <p>Arrays of <xsl:value-of select="@name"/> don't generally - make sense.</p> - </xsl:otherwise> - </xsl:choose> - <div> - <h4>Members</h4> - <dl> - <xsl:apply-templates select="tp:member" mode="members-in-docstring"/> - </dl> - </div> - </div> - </xsl:template> - - <xsl:template match="method"> - <div xmlns="http://www.w3.org/1999/xhtml" class="method"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="{concat(../@name, concat('.', @name))}"> - <xsl:value-of select="@name"/> - </a> ( - <xsl:for-each xmlns="" select="arg[@direction='in']"> - <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - ) → - <xsl:choose> - <xsl:when test="arg[@direction='out']"> - <xsl:for-each xmlns="" select="arg[@direction='out']"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - </xsl:when> - <xsl:otherwise>nothing</xsl:otherwise> - </xsl:choose> - </h3> - <div xmlns="http://www.w3.org/1999/xhtml" class="docstring"> - <xsl:apply-templates select="tp:docstring" /> - </div> - - <xsl:if test="arg[@direction='in']"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Parameters</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg[@direction='in']" - mode="parameters-in-docstring"/> - </dl> - </div> - </xsl:if> - - <xsl:if test="arg[@direction='out']"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Returns</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg[@direction='out']" - mode="returns-in-docstring"/> - </dl> - </div> - </xsl:if> - - <xsl:if test="tp:possible-errors"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Possible errors</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:possible-errors/tp:error"/> - </dl> - </div> - </xsl:if> - - </div> - </xsl:template> - - <xsl:template name="parenthesized-tp-type"> - <xsl:if test="@tp:type"> - <xsl:variable name="tp-type" select="@tp:type"/> - <xsl:variable name="single-type"> - <xsl:choose> - <xsl:when test="contains($tp-type, '[]')"> - <xsl:value-of select="substring-before($tp-type, '[]')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$tp-type"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:choose> - <xsl:when test="//tp:simple-type[@name=$tp-type]" /> - <xsl:when test="//tp:simple-type[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:struct[concat(@name, '[]')=$tp-type][string(@array-name) != '']" /> - <xsl:when test="//tp:struct[@name=$tp-type]" /> - <xsl:when test="//tp:enum[@name=$tp-type]" /> - <xsl:when test="//tp:enum[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:flags[@name=$tp-type]" /> - <xsl:when test="//tp:flags[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:mapping[@name=$tp-type]" /> - <xsl:when test="//tp:external-type[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:external-type[@name=$tp-type]" /> - <xsl:otherwise> - <xsl:message terminate="yes"> - <xsl:text>ERR: Unable to find type '</xsl:text> - <xsl:value-of select="$tp-type"/> - <xsl:text>' </xsl:text> - </xsl:message> - </xsl:otherwise> - </xsl:choose> - (<a href="#type-{$single-type}"><xsl:value-of select="$tp-type"/></a>) - </xsl:if> - </xsl:template> - - <xsl:template match="tp:member" mode="members-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:choose> - <xsl:when test="tp:docstring"> - <xsl:apply-templates select="tp:docstring" /> - </xsl:when> - <xsl:otherwise> - <em>(undocumented)</em> - </xsl:otherwise> - </xsl:choose> - </dd> - </xsl:template> - - <xsl:template match="arg" mode="parameters-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring" /> - </dd> - </xsl:template> - - <xsl:template match="arg" mode="returns-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <xsl:if test="@name"> - <code><xsl:value-of select="@name"/></code> - - </xsl:if> - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring"/> - </dd> - </xsl:template> - - <xsl:template match="tp:possible-errors/tp:error"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="name" select="@name"/> - <xsl:choose> - <xsl:when test="tp:docstring"> - <xsl:apply-templates select="tp:docstring"/> - </xsl:when> - <xsl:when test="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring"> - <xsl:apply-templates select="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring"/> <em xmlns="http://www.w3.org/1999/xhtml">(generic description)</em> - </xsl:when> - <xsl:otherwise> - (Undocumented.) - </xsl:otherwise> - </xsl:choose> - </dd> - </xsl:template> - - <xsl:template match="signal"> - <div xmlns="http://www.w3.org/1999/xhtml" class="signal"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="{concat(../@name, concat('.', @name))}"> - <xsl:value-of select="@name"/> - </a> ( - <xsl:for-each xmlns="" select="arg"> - <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - )</h3> - <div xmlns="http://www.w3.org/1999/xhtml" class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - - <xsl:if test="arg"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Parameters</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg" mode="parameters-in-docstring"/> - </dl> - </div> - </xsl:if> - </div> - </xsl:template> - - <xsl:output method="xml" indent="no" encoding="ascii" - omit-xml-declaration="yes" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> - - <xsl:template match="/tp:spec"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text> version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - </title> - <style type="text/css"> - - body { - font-family: sans-serif; - margin: 2em; - height: 100%; - font-size: 1.2em; - } - h1 { - padding-top: 5px; - padding-bottom: 5px; - font-size: 1.6em; - background: #dadae2; - } - h2 { - font-size: 1.3em; - } - h3 { - font-size: 1.2em; - } - a:link, a:visited, a:link:hover, a:visited:hover { - font-weight: bold; - } - .topbox { - padding-top: 10px; - padding-left: 10px; - border-bottom: black solid 1px; - padding-bottom: 10px; - background: #dadae2; - font-size: 2em; - font-weight: bold; - color: #5c5c5c; - } - .topnavbox { - padding-left: 10px; - padding-top: 5px; - padding-bottom: 5px; - background: #abacba; - border-bottom: black solid 1px; - font-size: 1.2em; - } - .topnavbox a{ - color: black; - font-weight: normal; - } - .sidebar { - float: left; - /* width:9em; - border-right:#abacba solid 1px; - border-left: #abacba solid 1px; - height:100%; */ - border: #abacba solid 1px; - padding-left: 10px; - margin-left: 10px; - padding-right: 10px; - margin-right: 10px; - color: #5d5d5d; - background: #dadae2; - } - .sidebar a { - text-decoration: none; - border-bottom: #e29625 dotted 1px; - color: #e29625; - font-weight: normal; - } - .sidebar h1 { - font-size: 1.2em; - color: black; - } - .sidebar ul { - padding-left: 25px; - padding-bottom: 10px; - border-bottom: #abacba solid 1px; - } - .sidebar li { - padding-top: 2px; - padding-bottom: 2px; - } - .sidebar h2 { - font-style:italic; - font-size: 0.81em; - padding-left: 5px; - padding-right: 5px; - font-weight: normal; - } - .date { - font-size: 0.6em; - float: right; - font-style: italic; - } - .method { - margin-left: 1em; - margin-right: 4em; - } - .signal { - margin-left: 1em; - margin-right: 4em; - } - - </style> - </head> - <body> - <h1 class="topbox"> - <xsl:value-of select="tp:title" /> - </h1> - <xsl:if test="tp:version"> - <h2>Version <xsl:apply-templates select="tp:version"/></h2> - </xsl:if> - <xsl:apply-templates select="tp:copyright"/> - <xsl:apply-templates select="tp:license"/> - <xsl:apply-templates select="tp:docstring"/> - - <h2>Interfaces</h2> - <ul> - <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="tp:generic-types"/> - <xsl:apply-templates select="tp:errors"/> - - <h1>Index</h1> - <h2>Index of interfaces</h2> - <ul> - <xsl:for-each select="node/interface"> - <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li> - </xsl:for-each> - </ul> - <h2>Index of types</h2> - <ul> - <xsl:for-each select="//tp:simple-type | //tp:enum | //tp:flags | //tp:mapping | //tp:struct | //tp:external-type"> - <xsl:sort select="@name"/> - <li> - <code> - <a href="#type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </code> - <xsl:apply-templates mode="in-index" select="."/> - </li> - </xsl:for-each> - </ul> - </body> - </html> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et: --> diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py deleted file mode 100644 index 8fea5df..0000000 --- a/tools/glib-ginterface-gen.py +++ /dev/null @@ -1,840 +0,0 @@ -#!/usr/bin/python - -# glib-ginterface-gen.py: service-side interface generator -# -# Generate dbus-glib 0.x service GInterfaces from the Telepathy specification. -# The master copy of this program 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 - -import sys -import os.path -import xml.dom.minidom - -from libtpcodegen import file_set_contents -from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \ - NS_TP, dbus_gutils_wincaps_to_uscore - - -NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - -def get_emits_changed(node): - try: - return [ - annotation.getAttribute('value') - for annotation in node.getElementsByTagName('annotation') - if annotation.getAttribute('name') == 'org.freedesktop.DBus.Property.EmitsChangedSignal' - ][0] - except IndexError: - return None - -class Generator(object): - - def __init__(self, dom, prefix, basename, signal_marshal_prefix, - headers, end_headers, not_implemented_func, - allow_havoc): - self.dom = dom - self.__header = [] - self.__body = [] - self.__docs = [] - - assert prefix.endswith('_') - assert not signal_marshal_prefix.endswith('_') - - # The main_prefix, sub_prefix thing is to get: - # FOO_ -> (FOO_, _) - # FOO_SVC_ -> (FOO_, _SVC_) - # but - # FOO_BAR/ -> (FOO_BAR_, _) - # FOO_BAR/SVC_ -> (FOO_BAR_, _SVC_) - - if '/' in prefix: - main_prefix, sub_prefix = prefix.upper().split('/', 1) - prefix = prefix.replace('/', '_') - else: - main_prefix, sub_prefix = prefix.upper().split('_', 1) - - self.MAIN_PREFIX_ = main_prefix + '_' - self._SUB_PREFIX_ = '_' + sub_prefix - - self.Prefix_ = prefix - self.Prefix = prefix.replace('_', '') - self.prefix_ = prefix.lower() - self.PREFIX_ = prefix.upper() - - self.basename = basename - self.signal_marshal_prefix = signal_marshal_prefix - self.headers = headers - self.end_headers = end_headers - self.not_implemented_func = not_implemented_func - self.allow_havoc = allow_havoc - - def h(self, s): - if isinstance(s, unicode): - s = s.encode('utf-8') - self.__header.append(s) - - def b(self, s): - if isinstance(s, unicode): - s = s.encode('utf-8') - self.__body.append(s) - - def d(self, s): - if isinstance(s, unicode): - s = s.encode('utf-8') - self.__docs.append(s) - - def do_node(self, node): - node_name = node.getAttribute('name').replace('/', '') - node_name_mixed = self.node_name_mixed = node_name.replace('_', '') - node_name_lc = self.node_name_lc = node_name.lower() - node_name_uc = self.node_name_uc = node_name.upper() - - interfaces = node.getElementsByTagName('interface') - assert len(interfaces) == 1, interfaces - interface = interfaces[0] - self.iface_name = interface.getAttribute('name') - - tmp = interface.getAttribute('tp:implement-service') - if tmp == "no": - return - - tmp = interface.getAttribute('tp:causes-havoc') - if tmp and not self.allow_havoc: - raise AssertionError('%s is %s' % (self.iface_name, tmp)) - - iface_emits_changed = get_emits_changed(interface) - - self.b('static const DBusGObjectInfo _%s%s_object_info;' - % (self.prefix_, node_name_lc)) - self.b('') - - methods = interface.getElementsByTagName('method') - signals = interface.getElementsByTagName('signal') - properties = interface.getElementsByTagName('property') - # Don't put properties in dbus-glib glue - glue_properties = [] - - self.b('struct _%s%sClass {' % (self.Prefix, node_name_mixed)) - self.b(' GTypeInterface parent_class;') - for method in methods: - self.b(' %s %s;' % self.get_method_impl_names(method)) - self.b('};') - self.b('') - - if signals: - self.b('enum {') - for signal in signals: - self.b(' %s,' % self.get_signal_const_entry(signal)) - self.b(' N_%s_SIGNALS' % node_name_uc) - self.b('};') - self.b('static guint %s_signals[N_%s_SIGNALS] = {0};' - % (node_name_lc, node_name_uc)) - self.b('') - - self.b('static void %s%s_base_init (gpointer klass);' - % (self.prefix_, node_name_lc)) - self.b('') - - self.b('GType') - self.b('%s%s_get_type (void)' - % (self.prefix_, node_name_lc)) - self.b('{') - self.b(' static GType type = 0;') - self.b('') - self.b(' if (G_UNLIKELY (type == 0))') - self.b(' {') - self.b(' static const GTypeInfo info = {') - self.b(' sizeof (%s%sClass),' % (self.Prefix, node_name_mixed)) - self.b(' %s%s_base_init, /* base_init */' - % (self.prefix_, node_name_lc)) - self.b(' NULL, /* base_finalize */') - self.b(' NULL, /* class_init */') - self.b(' NULL, /* class_finalize */') - self.b(' NULL, /* class_data */') - self.b(' 0,') - self.b(' 0, /* n_preallocs */') - self.b(' NULL /* instance_init */') - self.b(' };') - self.b('') - self.b(' type = g_type_register_static (G_TYPE_INTERFACE,') - self.b(' "%s%s", &info, 0);' % (self.Prefix, node_name_mixed)) - self.b(' }') - self.b('') - self.b(' return type;') - self.b('}') - self.b('') - - self.d('/**') - self.d(' * %s%s:' % (self.Prefix, node_name_mixed)) - self.d(' *') - self.d(' * Dummy typedef representing any implementation of this ' - 'interface.') - self.d(' */') - - self.h('typedef struct _%s%s %s%s;' - % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed)) - self.h('') - - self.d('/**') - self.d(' * %s%sClass:' % (self.Prefix, node_name_mixed)) - self.d(' *') - self.d(' * The class of %s%s.' % (self.Prefix, node_name_mixed)) - - if methods: - self.d(' *') - self.d(' * In a full implementation of this interface (i.e. all') - self.d(' * methods implemented), the interface initialization') - self.d(' * function used in G_IMPLEMENT_INTERFACE() would') - self.d(' * typically look like this:') - self.d(' *') - self.d(' * <programlisting>') - self.d(' * static void') - self.d(' * implement_%s (gpointer klass,' % self.node_name_lc) - self.d(' * gpointer unused G_GNUC_UNUSED)') - self.d(' * {') - self.d(' * #define IMPLEMENT(x) %s%s_implement_##x (\\' - % (self.prefix_, self.node_name_lc)) - self.d(' * klass, my_object_##x)') - - for method in methods: - class_member_name = method.getAttribute('tp:name-for-bindings') - class_member_name = class_member_name.lower() - self.d(' * IMPLEMENT (%s);' % class_member_name) - - self.d(' * #undef IMPLEMENT') - self.d(' * }') - self.d(' * </programlisting>') - else: - self.d(' * This interface has no D-Bus methods, so an') - self.d(' * implementation can typically pass %NULL to') - self.d(' * G_IMPLEMENT_INTERFACE() as the interface') - self.d(' * initialization function.') - - self.d(' */') - self.d('') - - self.h('typedef struct _%s%sClass %s%sClass;' - % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed)) - self.h('') - self.h('GType %s%s_get_type (void);' - % (self.prefix_, node_name_lc)) - - gtype = self.current_gtype = \ - self.MAIN_PREFIX_ + 'TYPE' + self._SUB_PREFIX_ + node_name_uc - classname = self.Prefix + node_name_mixed - - self.h('#define %s \\\n (%s%s_get_type ())' - % (gtype, self.prefix_, node_name_lc)) - self.h('#define %s%s(obj) \\\n' - ' (G_TYPE_CHECK_INSTANCE_CAST((obj), %s, %s))' - % (self.PREFIX_, node_name_uc, gtype, classname)) - self.h('#define %sIS%s%s(obj) \\\n' - ' (G_TYPE_CHECK_INSTANCE_TYPE((obj), %s))' - % (self.MAIN_PREFIX_, self._SUB_PREFIX_, node_name_uc, gtype)) - self.h('#define %s%s_GET_CLASS(obj) \\\n' - ' (G_TYPE_INSTANCE_GET_INTERFACE((obj), %s, %sClass))' - % (self.PREFIX_, node_name_uc, gtype, classname)) - self.h('') - self.h('') - - base_init_code = [] - - for method in methods: - self.do_method(method) - - for signal in signals: - base_init_code.extend(self.do_signal(signal)) - - self.b('static inline void') - self.b('%s%s_base_init_once (gpointer klass G_GNUC_UNUSED)' - % (self.prefix_, node_name_lc)) - self.b('{') - - if properties: - self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {' - % (len(properties) + 1)) - - for m in properties: - access = m.getAttribute('access') - assert access in ('read', 'write', 'readwrite') - - if access == 'read': - flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_READ' - elif access == 'write': - flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE' - else: - flags = ('TP_DBUS_PROPERTIES_MIXIN_FLAG_READ | ' - 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE') - - prop_emits_changed = get_emits_changed(m) - - if prop_emits_changed is None: - prop_emits_changed = iface_emits_changed - - if prop_emits_changed == 'true': - flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_CHANGED' - elif prop_emits_changed == 'invalidates': - flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_INVALIDATED' - - self.b(' { 0, %s, "%s", 0, NULL, NULL }, /* %s */' - % (flags, m.getAttribute('type'), m.getAttribute('name'))) - - self.b(' { 0, 0, NULL, 0, NULL, NULL }') - self.b(' };') - self.b(' static TpDBusPropertiesMixinIfaceInfo interface =') - self.b(' { 0, properties, NULL, NULL };') - self.b('') - - - self.b(' dbus_g_object_type_install_info (%s%s_get_type (),' - % (self.prefix_, node_name_lc)) - self.b(' &_%s%s_object_info);' - % (self.prefix_, node_name_lc)) - self.b('') - - if properties: - self.b(' interface.dbus_interface = g_quark_from_static_string ' - '("%s");' % self.iface_name) - - for i, m in enumerate(properties): - self.b(' properties[%d].name = g_quark_from_static_string ("%s");' - % (i, m.getAttribute('name'))) - self.b(' properties[%d].type = %s;' - % (i, type_to_gtype(m.getAttribute('type'))[1])) - - self.b(' tp_svc_interface_set_dbus_properties_info (%s, &interface);' - % self.current_gtype) - - self.b('') - - for s in base_init_code: - self.b(s) - self.b('}') - - self.b('static void') - self.b('%s%s_base_init (gpointer klass)' - % (self.prefix_, node_name_lc)) - self.b('{') - self.b(' static gboolean initialized = FALSE;') - self.b('') - self.b(' if (!initialized)') - self.b(' {') - self.b(' initialized = TRUE;') - self.b(' %s%s_base_init_once (klass);' - % (self.prefix_, node_name_lc)) - self.b(' }') - # insert anything we need to do per implementation here - self.b('}') - - self.h('') - - self.b('static const DBusGMethodInfo _%s%s_methods[] = {' - % (self.prefix_, node_name_lc)) - - method_blob, offsets = self.get_method_glue(methods) - - for method, offset in zip(methods, offsets): - self.do_method_glue(method, offset) - - if len(methods) == 0: - # empty arrays are a gcc extension, so put in a dummy member - self.b(" { NULL, NULL, 0 }") - - self.b('};') - self.b('') - - self.b('static const DBusGObjectInfo _%s%s_object_info = {' - % (self.prefix_, node_name_lc)) - self.b(' 0,') # version - self.b(' _%s%s_methods,' % (self.prefix_, node_name_lc)) - self.b(' %d,' % len(methods)) - self.b('"' + method_blob.replace('\0', '\\0') + '",') - self.b('"' + self.get_signal_glue(signals).replace('\0', '\\0') + '",') - self.b('"' + - self.get_property_glue(glue_properties).replace('\0', '\\0') + - '",') - self.b('};') - self.b('') - - self.node_name_mixed = None - self.node_name_lc = None - self.node_name_uc = None - - def get_method_glue(self, methods): - info = [] - offsets = [] - - for method in methods: - offsets.append(len(''.join(info))) - - info.append(self.iface_name + '\0') - info.append(method.getAttribute('name') + '\0') - - info.append('A\0') # async - - counter = 0 - for arg in method.getElementsByTagName('arg'): - out = arg.getAttribute('direction') == 'out' - - name = arg.getAttribute('name') - if not name: - assert out - name = 'arg%u' % counter - counter += 1 - - info.append(name + '\0') - - if out: - info.append('O\0') - else: - info.append('I\0') - - if out: - info.append('F\0') # not const - info.append('N\0') # not error or return - info.append(arg.getAttribute('type') + '\0') - - info.append('\0') - - return ''.join(info) + '\0', offsets - - def do_method_glue(self, method, offset): - lc_name = method.getAttribute('tp:name-for-bindings') - if method.getAttribute('name') != lc_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) does ' - 'not match' % (method.getAttribute('name'), lc_name)) - lc_name = lc_name.lower() - - marshaller = 'g_cclosure_marshal_generic' - wrapper = self.prefix_ + self.node_name_lc + '_' + lc_name - - self.b(" { (GCallback) %s, %s, %d }," % (wrapper, marshaller, offset)) - - def get_signal_glue(self, signals): - info = [] - - for signal in signals: - info.append(self.iface_name) - info.append(signal.getAttribute('name')) - - return '\0'.join(info) + '\0\0' - - # the implementation can be the same - get_property_glue = get_signal_glue - - def get_method_impl_names(self, method): - dbus_method_name = method.getAttribute('name') - - class_member_name = method.getAttribute('tp:name-for-bindings') - if dbus_method_name != class_member_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_method_name, class_member_name)) - class_member_name = class_member_name.lower() - - stub_name = (self.prefix_ + self.node_name_lc + '_' + - class_member_name) - return (stub_name + '_impl', class_member_name + '_cb') - - def do_method(self, method): - assert self.node_name_mixed is not None - - in_class = [] - - # Examples refer to Thing.DoStuff (su) -> ii - - # DoStuff - dbus_method_name = method.getAttribute('name') - # do_stuff - class_member_name = method.getAttribute('tp:name-for-bindings') - if dbus_method_name != class_member_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_method_name, class_member_name)) - class_member_name = class_member_name.lower() - - # void tp_svc_thing_do_stuff (TpSvcThing *, const char *, guint, - # DBusGMethodInvocation *); - stub_name = (self.prefix_ + self.node_name_lc + '_' + - class_member_name) - # typedef void (*tp_svc_thing_do_stuff_impl) (TpSvcThing *, - # const char *, guint, DBusGMethodInvocation); - impl_name = stub_name + '_impl' - # void tp_svc_thing_return_from_do_stuff (DBusGMethodInvocation *, - # gint, gint); - ret_name = (self.prefix_ + self.node_name_lc + '_return_from_' + - class_member_name) - - # Gather arguments - in_args = [] - out_args = [] - for i in method.getElementsByTagName('arg'): - name = i.getAttribute('name') - direction = i.getAttribute('direction') or 'in' - dtype = i.getAttribute('type') - - assert direction in ('in', 'out') - - if name: - name = direction + '_' + name - elif direction == 'in': - name = direction + str(len(in_args)) - else: - name = direction + str(len(out_args)) - - ctype, gtype, marshaller, pointer = type_to_gtype(dtype) - - if pointer: - ctype = 'const ' + ctype - - struct = (ctype, name) - - if direction == 'in': - in_args.append(struct) - else: - out_args.append(struct) - - # Implementation type declaration (in header, docs separated) - self.d('/**') - self.d(' * %s:' % impl_name) - self.d(' * @self: The object implementing this interface') - for (ctype, name) in in_args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' * @context: Used to return values or throw an error') - self.d(' *') - self.d(' * The signature of an implementation of the D-Bus method') - self.d(' * %s on interface %s.' % (dbus_method_name, self.iface_name)) - self.d(' */') - - self.h('typedef void (*%s) (%s%s *self,' - % (impl_name, self.Prefix, self.node_name_mixed)) - for (ctype, name) in in_args: - self.h(' %s%s,' % (ctype, name)) - self.h(' DBusGMethodInvocation *context);') - - # Class member (in class definition) - in_class.append(' %s %s;' % (impl_name, class_member_name)) - - # Stub definition (in body only - it's static) - self.b('static void') - self.b('%s (%s%s *self,' - % (stub_name, self.Prefix, self.node_name_mixed)) - for (ctype, name) in in_args: - self.b(' %s%s,' % (ctype, name)) - self.b(' DBusGMethodInvocation *context)') - self.b('{') - self.b(' %s impl = (%s%s_GET_CLASS (self)->%s_cb);' - % (impl_name, self.PREFIX_, self.node_name_uc, class_member_name)) - self.b('') - self.b(' if (impl != NULL)') - tmp = ['self'] + [name for (ctype, name) in in_args] + ['context'] - self.b(' {') - self.b(' (impl) (%s);' % ',\n '.join(tmp)) - self.b(' }') - self.b(' else') - self.b(' {') - if self.not_implemented_func: - self.b(' %s (context);' % self.not_implemented_func) - else: - self.b(' GError e = { DBUS_GERROR, ') - self.b(' DBUS_GERROR_UNKNOWN_METHOD,') - self.b(' "Method not implemented" };') - self.b('') - self.b(' dbus_g_method_return_error (context, &e);') - self.b(' }') - self.b('}') - self.b('') - - # Implementation registration (in both header and body) - self.h('void %s%s_implement_%s (%s%sClass *klass, %s impl);' - % (self.prefix_, self.node_name_lc, class_member_name, - self.Prefix, self.node_name_mixed, impl_name)) - - self.d('/**') - self.d(' * %s%s_implement_%s:' - % (self.prefix_, self.node_name_lc, class_member_name)) - self.d(' * @klass: A class whose instances implement this interface') - self.d(' * @impl: A callback used to implement the %s D-Bus method' - % dbus_method_name) - self.d(' *') - self.d(' * Register an implementation for the %s method in the vtable' - % dbus_method_name) - self.d(' * of an implementation of this interface. To be called from') - self.d(' * the interface init function.') - self.d(' */') - - self.b('void') - self.b('%s%s_implement_%s (%s%sClass *klass, %s impl)' - % (self.prefix_, self.node_name_lc, class_member_name, - self.Prefix, self.node_name_mixed, impl_name)) - self.b('{') - self.b(' klass->%s_cb = impl;' % class_member_name) - self.b('}') - self.b('') - - # Return convenience function (static inline, in header) - self.d('/**') - self.d(' * %s:' % ret_name) - self.d(' * @context: The D-Bus method invocation context') - for (ctype, name) in out_args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * Return successfully by calling dbus_g_method_return().') - self.d(' * This inline function exists only to provide type-safety.') - self.d(' */') - self.d('') - - tmp = (['DBusGMethodInvocation *context'] + - [ctype + name for (ctype, name) in out_args]) - self.h('static inline') - self.h('/* this comment is to stop gtkdoc realising this is static */') - self.h(('void %s (' % ret_name) + (',\n '.join(tmp)) + ');') - self.h('static inline void') - self.h(('%s (' % ret_name) + (',\n '.join(tmp)) + ')') - self.h('{') - tmp = ['context'] + [name for (ctype, name) in out_args] - self.h(' dbus_g_method_return (' + ',\n '.join(tmp) + ');') - self.h('}') - self.h('') - - return in_class - - def get_signal_const_entry(self, signal): - assert self.node_name_uc is not None - return ('SIGNAL_%s_%s' - % (self.node_name_uc, signal.getAttribute('name'))) - - def do_signal(self, signal): - assert self.node_name_mixed is not None - - in_base_init = [] - - # for signal: Thing::StuffHappened (s, u) - # we want to emit: - # void tp_svc_thing_emit_stuff_happened (gpointer instance, - # const char *arg0, guint arg1); - - dbus_name = signal.getAttribute('name') - - ugly_name = signal.getAttribute('tp:name-for-bindings') - if dbus_name != ugly_name.replace('_', ''): - raise AssertionError('Signal %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_name, ugly_name)) - - stub_name = (self.prefix_ + self.node_name_lc + '_emit_' + - ugly_name.lower()) - - const_name = self.get_signal_const_entry(signal) - - # Gather arguments - args = [] - for i in signal.getElementsByTagName('arg'): - name = i.getAttribute('name') - dtype = i.getAttribute('type') - tp_type = i.getAttribute('tp:type') - - if name: - name = 'arg_' + name - else: - name = 'arg' + str(len(args)) - - ctype, gtype, marshaller, pointer = type_to_gtype(dtype) - - if pointer: - ctype = 'const ' + ctype - - struct = (ctype, name, gtype) - args.append(struct) - - tmp = (['gpointer instance'] + - [ctype + name for (ctype, name, gtype) in args]) - - self.h(('void %s (' % stub_name) + (',\n '.join(tmp)) + ');') - - # FIXME: emit docs - - self.d('/**') - self.d(' * %s:' % stub_name) - self.d(' * @instance: The object implementing this interface') - for (ctype, name, gtype) in args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * Type-safe wrapper around g_signal_emit to emit the') - self.d(' * %s signal on interface %s.' - % (dbus_name, self.iface_name)) - self.d(' */') - - self.b('void') - self.b(('%s (' % stub_name) + (',\n '.join(tmp)) + ')') - self.b('{') - self.b(' g_assert (instance != NULL);') - self.b(' g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, %s));' - % (self.current_gtype)) - tmp = (['instance', '%s_signals[%s]' % (self.node_name_lc, const_name), - '0'] + [name for (ctype, name, gtype) in args]) - self.b(' g_signal_emit (' + ',\n '.join(tmp) + ');') - self.b('}') - self.b('') - - signal_name = dbus_gutils_wincaps_to_uscore(dbus_name).replace('_', - '-') - - self.d('/**') - self.d(' * %s%s::%s:' - % (self.Prefix, self.node_name_mixed, signal_name)) - self.d(' * @self: an object') - for (ctype, name, gtype) in args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * The %s D-Bus signal is emitted whenever ' - 'this GObject signal is.' % dbus_name) - self.d(' */') - self.d('') - - in_base_init.append(' %s_signals[%s] =' - % (self.node_name_lc, const_name)) - in_base_init.append(' g_signal_new ("%s",' % signal_name) - in_base_init.append(' G_OBJECT_CLASS_TYPE (klass),') - in_base_init.append(' G_SIGNAL_RUN_LAST|G_SIGNAL_DETAILED,') - in_base_init.append(' 0,') - in_base_init.append(' NULL, NULL,') - in_base_init.append(' g_cclosure_marshal_generic,') - in_base_init.append(' G_TYPE_NONE,') - tmp = ['%d' % len(args)] + [gtype for (ctype, name, gtype) in args] - in_base_init.append(' %s);' % ',\n '.join(tmp)) - in_base_init.append('') - - return in_base_init - - def have_properties(self, nodes): - for node in nodes: - interface = node.getElementsByTagName('interface')[0] - if interface.getElementsByTagName('property'): - return True - return False - - def __call__(self): - nodes = self.dom.getElementsByTagName('node') - nodes.sort(cmp_by_name) - - self.h('#include <glib-object.h>') - self.h('#include <dbus/dbus-glib.h>') - - if self.have_properties(nodes): - self.h('#include <telepathy-glib/telepathy-glib.h>') - - self.h('') - self.h('G_BEGIN_DECLS') - self.h('') - - self.b('#include "%s.h"' % self.basename) - self.b('') - for header in self.headers: - self.b('#include %s' % header) - self.b('') - - for node in nodes: - self.do_node(node) - - self.h('') - self.h('G_END_DECLS') - - self.b('') - for header in self.end_headers: - self.b('#include %s' % header) - - self.h('') - self.b('') - file_set_contents(self.basename + '.h', '\n'.join(self.__header)) - file_set_contents(self.basename + '.c', '\n'.join(self.__body)) - file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs)) - -def cmdline_error(): - print """\ -usage: - gen-ginterface [OPTIONS] xmlfile Prefix_ -options: - --include='<header.h>' (may be repeated) - --include='"header.h"' (ditto) - --include-end='"header.h"' (ditto) - Include extra headers in the generated .c file - --signal-marshal-prefix='prefix' - Use the given prefix on generated signal marshallers (default is - prefix.lower()). - --filename='BASENAME' - Set the basename for the output files (default is prefix.lower() - + 'ginterfaces') - --not-implemented-func='symbol' - Set action when methods not implemented in the interface vtable are - called. symbol must have signature - void symbol (DBusGMethodInvocation *context) - and return some sort of "not implemented" error via - dbus_g_method_return_error (context, ...) -""" - sys.exit(1) - - -if __name__ == '__main__': - from getopt import gnu_getopt - - options, argv = gnu_getopt(sys.argv[1:], '', - ['filename=', 'signal-marshal-prefix=', - 'include=', 'include-end=', - 'allow-unstable', - 'not-implemented-func=']) - - try: - prefix = argv[1] - except IndexError: - cmdline_error() - - basename = prefix.lower() + 'ginterfaces' - signal_marshal_prefix = prefix.lower().rstrip('_') - headers = [] - end_headers = [] - not_implemented_func = '' - allow_havoc = False - - for option, value in options: - if option == '--filename': - basename = value - elif option == '--signal-marshal-prefix': - signal_marshal_prefix = value - elif option == '--include': - if value[0] not in '<"': - value = '"%s"' % value - headers.append(value) - elif option == '--include-end': - if value[0] not in '<"': - value = '"%s"' % value - end_headers.append(value) - elif option == '--not-implemented-func': - not_implemented_func = value - elif option == '--allow-unstable': - allow_havoc = True - - try: - dom = xml.dom.minidom.parse(argv[0]) - except IndexError: - cmdline_error() - - Generator(dom, prefix, basename, signal_marshal_prefix, headers, - end_headers, not_implemented_func, allow_havoc)() diff --git a/tools/identity.xsl b/tools/identity.xsl deleted file mode 100644 index 6630f84..0000000 --- a/tools/identity.xsl +++ /dev/null @@ -1,7 +0,0 @@ -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:template match="@*|node()"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> -</xsl:stylesheet> diff --git a/tools/libglibcodegen.py b/tools/libglibcodegen.py deleted file mode 100644 index 6a9d214..0000000 --- a/tools/libglibcodegen.py +++ /dev/null @@ -1,172 +0,0 @@ -"""Library code for GLib/D-Bus-related code generation. - -The master copy of this library is in the telepathy-glib repository - -please make any changes there. -""" - -# 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 -# 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 - - -from libtpcodegen import NS_TP, \ - Signature, \ - cmp_by_name, \ - escape_as_identifier, \ - get_by_path, \ - get_descendant_text, \ - get_docstring, \ - xml_escape, \ - get_deprecated - -def dbus_gutils_wincaps_to_uscore(s): - """Bug-for-bug compatible Python port of _dbus_gutils_wincaps_to_uscore - which gets sequences of capital letters wrong in the same way. - (e.g. in Telepathy, SendDTMF -> send_dt_mf) - """ - ret = '' - for c in s: - if c >= 'A' and c <= 'Z': - length = len(ret) - if length > 0 and (length < 2 or ret[length-2] != '_'): - ret += '_' - ret += c.lower() - else: - ret += c - return ret - - -def signal_to_marshal_type(signal): - """ - return a list of strings indicating the marshalling type for this signal. - """ - - mtype=[] - for i in signal.getElementsByTagName("arg"): - name =i.getAttribute("name") - type = i.getAttribute("type") - mtype.append(type_to_gtype(type)[2]) - - return mtype - - -_glib_marshallers = ['VOID', 'BOOLEAN', 'CHAR', 'UCHAR', 'INT', - 'STRING', 'UINT', 'LONG', 'ULONG', 'ENUM', 'FLAGS', 'FLOAT', - 'DOUBLE', 'STRING', 'PARAM', 'BOXED', 'POINTER', 'OBJECT', - 'UINT_POINTER'] - - -def signal_to_marshal_name(signal, prefix): - - mtype = signal_to_marshal_type(signal) - if len(mtype): - name = '_'.join(mtype) - else: - name = 'VOID' - - if name in _glib_marshallers: - return 'g_cclosure_marshal_VOID__' + name - else: - return prefix + '_marshal_VOID__' + name - - -def method_to_glue_marshal_name(method, prefix): - - mtype = [] - for i in method.getElementsByTagName("arg"): - if i.getAttribute("direction") != "out": - type = i.getAttribute("type") - mtype.append(type_to_gtype(type)[2]) - - mtype.append('POINTER') - - name = '_'.join(mtype) - - if name in _glib_marshallers: - return 'g_cclosure_marshal_VOID__' + name - else: - return prefix + '_marshal_VOID__' + name - - -def type_to_gtype(s): - if s == 'y': #byte - return ("guchar ", "G_TYPE_UCHAR","UCHAR", False) - elif s == 'b': #boolean - return ("gboolean ", "G_TYPE_BOOLEAN","BOOLEAN", False) - elif s == 'n': #int16 - return ("gint ", "G_TYPE_INT","INT", False) - elif s == 'q': #uint16 - return ("guint ", "G_TYPE_UINT","UINT", False) - elif s == 'i': #int32 - return ("gint ", "G_TYPE_INT","INT", False) - elif s == 'u': #uint32 - return ("guint ", "G_TYPE_UINT","UINT", False) - elif s == 'x': #int64 - return ("gint64 ", "G_TYPE_INT64","INT64", False) - elif s == 't': #uint64 - return ("guint64 ", "G_TYPE_UINT64","UINT64", False) - elif s == 'd': #double - return ("gdouble ", "G_TYPE_DOUBLE","DOUBLE", False) - elif s == 's': #string - return ("gchar *", "G_TYPE_STRING", "STRING", True) - elif s == 'g': #signature - FIXME - return ("gchar *", "DBUS_TYPE_G_SIGNATURE", "STRING", True) - elif s == 'o': #object path - return ("gchar *", "DBUS_TYPE_G_OBJECT_PATH", "BOXED", True) - elif s == 'v': #variant - return ("GValue *", "G_TYPE_VALUE", "BOXED", True) - elif s == 'as': #array of strings - return ("gchar **", "G_TYPE_STRV", "BOXED", True) - elif s == 'ay': #byte array - return ("GArray *", - "dbus_g_type_get_collection (\"GArray\", G_TYPE_UCHAR)", "BOXED", - True) - elif s == 'au': #uint array - return ("GArray *", "DBUS_TYPE_G_UINT_ARRAY", "BOXED", True) - elif s == 'ai': #int array - return ("GArray *", "DBUS_TYPE_G_INT_ARRAY", "BOXED", True) - elif s == 'ax': #int64 array - return ("GArray *", "DBUS_TYPE_G_INT64_ARRAY", "BOXED", True) - elif s == 'at': #uint64 array - return ("GArray *", "DBUS_TYPE_G_UINT64_ARRAY", "BOXED", True) - elif s == 'ad': #double array - return ("GArray *", "DBUS_TYPE_G_DOUBLE_ARRAY", "BOXED", True) - elif s == 'ab': #boolean array - return ("GArray *", "DBUS_TYPE_G_BOOLEAN_ARRAY", "BOXED", True) - elif s == 'ao': #object path array - return ("GPtrArray *", - 'dbus_g_type_get_collection ("GPtrArray",' - ' DBUS_TYPE_G_OBJECT_PATH)', - "BOXED", True) - elif s == 'a{ss}': #hash table of string to string - return ("GHashTable *", "DBUS_TYPE_G_STRING_STRING_HASHTABLE", "BOXED", False) - elif s[:2] == 'a{': #some arbitrary hash tables - if s[2] not in ('y', 'b', 'n', 'q', 'i', 'u', 's', 'o', 'g'): - raise Exception, "can't index a hashtable off non-basic type " + s - first = type_to_gtype(s[2]) - second = type_to_gtype(s[3:-1]) - return ("GHashTable *", "(dbus_g_type_get_map (\"GHashTable\", " + first[1] + ", " + second[1] + "))", "BOXED", False) - elif s[:2] in ('a(', 'aa'): # array of structs or arrays, recurse - gtype = type_to_gtype(s[1:])[1] - return ("GPtrArray *", "(dbus_g_type_get_collection (\"GPtrArray\", "+gtype+"))", "BOXED", True) - elif s[:1] == '(': #struct - gtype = "(dbus_g_type_get_struct (\"GValueArray\", " - for subsig in Signature(s[1:-1]): - gtype = gtype + type_to_gtype(subsig)[1] + ", " - gtype = gtype + "G_TYPE_INVALID))" - return ("GValueArray *", gtype, "BOXED", True) - - # we just don't know .. - raise Exception, "don't know the GType for " + s diff --git a/tools/libtpcodegen.py b/tools/libtpcodegen.py deleted file mode 100644 index 7e9eb9a..0000000 --- a/tools/libtpcodegen.py +++ /dev/null @@ -1,227 +0,0 @@ -"""Library code for language-independent D-Bus-related code generation. - -The master copy of this library is in the telepathy-glib repository - -please make any changes there. -""" - -# 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 -# 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 - -import os -from string import ascii_letters, digits - - -NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - -_ASCII_ALNUM = ascii_letters + digits - -def file_set_contents(filename, contents): - try: - os.remove(filename) - except OSError: - pass - try: - os.remove(filename + '.tmp') - except OSError: - pass - - open(filename + '.tmp', 'w').write(contents) - os.rename(filename + '.tmp', filename) - -def cmp_by_name(node1, node2): - return cmp(node1.getAttributeNode("name").nodeValue, - node2.getAttributeNode("name").nodeValue) - - -def escape_as_identifier(identifier): - """Escape the given string to be a valid D-Bus object path or service - name component, using a reversible encoding to ensure uniqueness. - - The reversible encoding is as follows: - - * The empty string becomes '_' - * Otherwise, each non-alphanumeric character is replaced by '_' plus - two lower-case hex digits; the same replacement is carried out on - the first character, if it's a digit - """ - # '' -> '_' - if not identifier: - return '_' - - # A bit of a fast path for strings which are already OK. - # We deliberately omit '_' because, for reversibility, that must also - # be escaped. - if (identifier.strip(_ASCII_ALNUM) == '' and - identifier[0] in ascii_letters): - return identifier - - # The first character may not be a digit - if identifier[0] not in ascii_letters: - ret = ['_%02x' % ord(identifier[0])] - else: - ret = [identifier[0]] - - # Subsequent characters may be digits or ASCII letters - for c in identifier[1:]: - if c in _ASCII_ALNUM: - ret.append(c) - else: - ret.append('_%02x' % ord(c)) - - return ''.join(ret) - - -def get_by_path(element, path): - branches = path.split('/') - branch = branches[0] - - # Is the current branch an attribute, if so, return the attribute value - if branch[0] == '@': - return element.getAttribute(branch[1:]) - - # Find matching children for the branch - children = [] - if branch == '..': - children.append(element.parentNode) - else: - for x in element.childNodes: - if x.localName == branch: - children.append(x) - - ret = [] - # If this is not the last path element, recursively gather results from - # children - if len(branches) > 1: - for x in children: - add = get_by_path(x, '/'.join(branches[1:])) - if isinstance(add, list): - ret += add - else: - return add - else: - ret = children - - return ret - - -def get_docstring(element): - docstring = None - for x in element.childNodes: - if x.namespaceURI == NS_TP and x.localName == 'docstring': - docstring = x - if docstring is not None: - docstring = docstring.toxml().replace('\n', ' ').strip() - if docstring.startswith('<tp:docstring>'): - docstring = docstring[14:].lstrip() - if docstring.endswith('</tp:docstring>'): - docstring = docstring[:-15].rstrip() - if docstring in ('<tp:docstring/>', ''): - docstring = '' - return docstring - -def get_deprecated(element): - text = [] - for x in element.childNodes: - if hasattr(x, 'data'): - text.append(x.data.replace('\n', ' ').strip()) - else: - # This caters for tp:dbus-ref elements, but little else. - if x.childNodes and hasattr(x.childNodes[0], 'data'): - text.append(x.childNodes[0].data.replace('\n', ' ').strip()) - return ' '.join(text) - -def get_descendant_text(element_or_elements): - if not element_or_elements: - return '' - if isinstance(element_or_elements, list): - return ''.join(map(get_descendant_text, element_or_elements)) - parts = [] - for x in element_or_elements.childNodes: - if x.nodeType == x.TEXT_NODE: - parts.append(x.nodeValue) - elif x.nodeType == x.ELEMENT_NODE: - parts.append(get_descendant_text(x)) - else: - pass - return ''.join(parts) - - -class _SignatureIter: - """Iterator over a D-Bus signature. Copied from dbus-python 0.71 so we - can run genginterface in a limited environment with only Python - (like Scratchbox). - """ - def __init__(self, string): - self.remaining = string - - def next(self): - if self.remaining == '': - raise StopIteration - - signature = self.remaining - block_depth = 0 - block_type = None - end = len(signature) - - for marker in range(0, end): - cur_sig = signature[marker] - - if cur_sig == 'a': - pass - elif cur_sig == '{' or cur_sig == '(': - if block_type == None: - block_type = cur_sig - - if block_type == cur_sig: - block_depth = block_depth + 1 - - elif cur_sig == '}': - if block_type == '{': - block_depth = block_depth - 1 - - if block_depth == 0: - end = marker - break - - elif cur_sig == ')': - if block_type == '(': - block_depth = block_depth - 1 - - if block_depth == 0: - end = marker - break - - else: - if block_depth == 0: - end = marker - break - - end = end + 1 - self.remaining = signature[end:] - return Signature(signature[0:end]) - - -class Signature(str): - """A string, iteration over which is by D-Bus single complete types - rather than characters. - """ - def __iter__(self): - return _SignatureIter(self) - - -def xml_escape(s): - s = s.replace('&', '&').replace("'", ''').replace('"', '"') - return s.replace('<', '<').replace('>', '>') diff --git a/tools/ls-interfaces.xsl b/tools/ls-interfaces.xsl deleted file mode 100644 index efb76b9..0000000 --- a/tools/ls-interfaces.xsl +++ /dev/null @@ -1,35 +0,0 @@ -<!-- -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 -Library 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 ---> - -<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 deleted file mode 100644 index 271bec5..0000000 --- a/tools/make-all-async.xsl +++ /dev/null @@ -1,43 +0,0 @@ -<!-- 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 -Library 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 ---> -<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/make-release-mail.py b/tools/make-release-mail.py index 5c42b47..b03ebd2 100644 --- a/tools/make-release-mail.py +++ b/tools/make-release-mail.py @@ -6,6 +6,15 @@ # to <telepathy@lists.freedesktop.org>. I hope that you enjoy your stay. import sys +import re + +def looks_like_a_header(line, package, version=None): + if version is None: + pattern = "^%s .* \(.*\)$" % package + else: + pattern = "^%s %s \(.*\)$" % (package, version) + + return re.match(pattern, line) is not None def extract_description(package, version, news_path): release_name = [] @@ -15,7 +24,7 @@ def extract_description(package, version, news_path): lines = (line for line in f.readlines()) for line in lines: # Find the 'telepathy-foo 0.1.2' header - if line.startswith("%s %s" % (package, version)): + if looks_like_a_header(line, package, version): break # Skip the ====== line, and the first blank line @@ -27,7 +36,7 @@ def extract_description(package, version, news_path): for line in lines: line = line.rstrip() # If we hit the next version header, we're done - if line.startswith(package): + if looks_like_a_header(line, package): break # Else, if we hit a blank line and we're still reading the release # name, we're done with the release name. diff --git a/tools/spec-to-introspect.xsl b/tools/spec-to-introspect.xsl deleted file mode 100644 index 3def766..0000000 --- a/tools/spec-to-introspect.xsl +++ /dev/null @@ -1,51 +0,0 @@ -<!-- 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 -Library 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 ---> - -<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.am b/tools/telepathy.am index 2b6c430..e6defea 100644 --- a/tools/telepathy.am +++ b/tools/telepathy.am @@ -50,7 +50,7 @@ maintainer-prepare-release: $(MAKE) all $(MAKE) distcheck $(MAKE) release-mail - git tag -s @PACKAGE@-@VERSION@ -m @PACKAGE@' '@VERSION@ + cd $(srcdir) && git tag -s @PACKAGE@-@VERSION@ -m @PACKAGE@' '@VERSION@ gpg --detach-sign --armor @PACKAGE@-@VERSION@.tar.gz release-mail: NEWS |