summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--Makefile.am2
-rw-r--r--README2
-rw-r--r--configure.ac58
-rw-r--r--lib/gibber/Makefile.am4
-rw-r--r--lib/gibber/gibber-bytestream-ibb.c140
-rw-r--r--lib/gibber/gibber-bytestream-ibb.h2
-rw-r--r--lib/gibber/gibber-bytestream-iface.h4
-rw-r--r--lib/gibber/gibber-bytestream-oob.c136
-rw-r--r--lib/gibber/gibber-debug.c4
-rw-r--r--lib/gibber/gibber-debug.h4
-rw-r--r--lib/gibber/gibber-file-transfer.c14
-rw-r--r--lib/gibber/gibber-file-transfer.h12
-rw-r--r--lib/gibber/gibber-iq-helper.c58
-rw-r--r--lib/gibber/gibber-iq-helper.h16
-rw-r--r--lib/gibber/gibber-muc-connection.c8
-rw-r--r--lib/gibber/gibber-muc-connection.h4
-rw-r--r--lib/gibber/gibber-oob-file-transfer.c138
-rw-r--r--lib/gibber/gibber-oob-file-transfer.h4
-rw-r--r--lib/gibber/gibber-xmpp-connection.c10
-rw-r--r--lib/gibber/gibber-xmpp-connection.h4
-rw-r--r--lib/gibber/gibber-xmpp-error.c36
-rw-r--r--lib/gibber/gibber-xmpp-error.h10
-rw-r--r--lib/gibber/gibber-xmpp-node.c24
-rw-r--r--lib/gibber/gibber-xmpp-node.h59
-rw-r--r--lib/gibber/gibber-xmpp-reader.c4
-rw-r--r--lib/gibber/gibber-xmpp-stanza.c26
-rw-r--r--lib/gibber/gibber-xmpp-stanza.h90
-rw-r--r--lib/gibber/gibber-xmpp-writer.h2
-rw-r--r--lib/gibber/tests/Makefile.am105
-rw-r--r--lib/gibber/tests/check-gibber-iq-helper.c274
-rw-r--r--lib/gibber/tests/check-gibber-listener.c68
-rw-r--r--lib/gibber/tests/check-gibber-r-multicast-causal-transport.c127
-rw-r--r--lib/gibber/tests/check-gibber-r-multicast-packet.c81
-rw-r--r--lib/gibber/tests/check-gibber-r-multicast-sender.c121
-rw-r--r--lib/gibber/tests/check-gibber-unix-transport.c55
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-connection-listener.c37
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-connection.c43
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-error.c105
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-node.c146
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-reader.c80
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-stanza.c168
-rw-r--r--lib/gibber/tests/check-gibber.h19
-rw-r--r--lib/gibber/tests/check-helpers.c63
-rw-r--r--lib/gibber/tests/check-helpers.h43
-rw-r--r--lib/gibber/tests/check-main.c55
-rw-r--r--lib/gibber/tests/test-xmpp-connection.c16
-rw-r--r--plugins/Makefile.am32
-rw-r--r--plugins/test.c68
-rw-r--r--plugins/test.h32
-rw-r--r--salut/Makefile.am10
-rw-r--r--salut/plugin.h118
-rw-r--r--salut/protocol.h (renamed from src/protocol.h)24
-rw-r--r--salut/telepathy-salut-uninstalled.pc.in14
-rw-r--r--salut/telepathy-salut.pc.in14
-rw-r--r--src/Makefile.am29
-rw-r--r--src/debug.c1
-rw-r--r--src/debug.h3
-rw-r--r--src/plugin-loader.c273
-rw-r--r--src/plugin-loader.h71
-rw-r--r--src/plugin.c75
-rw-r--r--src/protocol.c97
-rw-r--r--src/salut-avahi-contact-manager.c14
-rw-r--r--src/salut-avahi-contact.c5
-rw-r--r--src/salut-avahi-discovery-client.c45
-rw-r--r--src/salut-avahi-discovery-client.h3
-rw-r--r--src/salut-avahi-self.c13
-rw-r--r--src/salut-caps-hash.c40
-rw-r--r--src/salut-caps-hash.h4
-rw-r--r--src/salut-connection-manager.c14
-rw-r--r--src/salut-connection.c66
-rw-r--r--src/salut-connection.h6
-rw-r--r--src/salut-contact-channel.c27
-rw-r--r--src/salut-disco.c104
-rw-r--r--src/salut-disco.h5
-rw-r--r--src/salut-discovery-client.c10
-rw-r--r--src/salut-file-transfer-channel.c147
-rw-r--r--src/salut-file-transfer-channel.h4
-rw-r--r--src/salut-ft-manager.c36
-rw-r--r--src/salut-im-channel.c66
-rw-r--r--src/salut-im-channel.h6
-rw-r--r--src/salut-im-manager.c30
-rw-r--r--src/salut-muc-channel.c68
-rw-r--r--src/salut-muc-manager.c26
-rw-r--r--src/salut-muc-manager.h2
-rw-r--r--src/salut-olpc-activity.c50
-rw-r--r--src/salut-olpc-activity.h2
-rw-r--r--src/salut-presence-cache.c2
-rw-r--r--src/salut-roomlist-channel.c8
-rw-r--r--src/salut-self.c2
-rw-r--r--src/salut-self.h4
-rw-r--r--src/salut-si-bytestream-manager.c178
-rw-r--r--src/salut-si-bytestream-manager.h4
-rw-r--r--src/salut-tubes-channel.c171
-rw-r--r--src/salut-tubes-channel.h8
-rw-r--r--src/salut-tubes-manager.c50
-rw-r--r--src/salut-util.c42
-rw-r--r--src/salut-util.h6
-rw-r--r--src/salut-xmpp-connection-manager.c12
-rw-r--r--src/salut-xmpp-connection-manager.h6
-rw-r--r--src/salut.c11
-rw-r--r--src/telepathy-salut-uninstalled.pc.in12
-rw-r--r--src/telepathy-salut.pc.in12
-rw-r--r--src/text-helper.c58
-rw-r--r--src/text-helper.h8
-rw-r--r--src/tube-dbus.c15
-rw-r--r--src/tube-stream.c59
-rw-r--r--src/tube-stream.h2
-rw-r--r--src/write-mgr-file.c6
-rw-r--r--tests/Makefile.am68
-rw-r--r--tests/check-helpers.c63
-rw-r--r--tests/check-helpers.h43
-rw-r--r--tests/check-main.c40
-rw-r--r--tests/check-node-properties.c188
-rw-r--r--tests/check-salut.h6
-rw-r--r--tests/twisted/avahi/file-transfer/file_transfer_helper.py246
-rw-r--r--tests/twisted/avahi/file-transfer/test-ichat-send-file-declined.py10
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-and-send-file.py4
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py8
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-transfering.py3
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-and-xmpp-disconnect.py3
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-cancelled-immediately.py9
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-decline.py13
-rw-r--r--tests/twisted/avahi/file-transfer/test-receive-file-not-found.py11
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-and-cancel-immediately.py9
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-declined.py10
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-ipv6.py13
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-item-not-found.py11
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-provide-immediately.py13
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py4
-rw-r--r--tests/twisted/avahi/file-transfer/test-send-file-wait-to-provide.py18
-rw-r--r--tests/twisted/avahi/test-caps-file-transfer.py24
-rw-r--r--tests/twisted/avahi/test-caps-tubes.py6
-rw-r--r--tests/twisted/constants.py66
-rw-r--r--tests/twisted/saluttest.py1
135 files changed, 3033 insertions, 2676 deletions
diff --git a/.gitignore b/.gitignore
index 43195e47..04eb8450 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,7 @@ ChangeSet
*.pyo
*#
+.\#*
.cvsignore
Thumbs.db
autom4te.cache
@@ -130,6 +131,9 @@ tools/libglibcodegen.pyc
src/telepathy-salut
src/write-mgr-file
+src/telepathy-salut-uninstalled.pc
+src/telepathy-salut.pc
+
/telepathy-salut-*/
/telepathy-salut-*.tar.gz
/telepathy-salut-*.tar.gz.asc
@@ -137,9 +141,13 @@ tests/test-r-multicast-packet
tests/test-r-sender
tests/test-r-transport-io
tests/telepathy-salut-debug
+tests/check-node-properties
lib/gibber/tests/check-main
lib/gibber/tests/outputs
lib/gibber/tests/sasl-test.db
lib/gibber/tests/test-xmpp-connection
lib/gibber/tests/test-r-multicast-transport-io
+
+salut/telepathy-salut.pc
+salut/telepathy-salut-uninstalled.pc
diff --git a/Makefile.am b/Makefile.am
index e4278cdf..ba099d87 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = tools extensions lib src data m4 tests docs
+SUBDIRS = tools extensions lib src data m4 tests docs plugins salut
DISTCHECK_CONFIGURE_FLAGS = --disable-debug --enable-gtk-doc
diff --git a/README b/README
index 2666f2f8..081accc1 100644
--- a/README
+++ b/README
@@ -30,8 +30,6 @@ At build time, it also requires:
pkg-config <http://ftp.gnome.org/pub/GNOME/sources/pkg-config/>
libxslt, xsltproc <http://xmlsoft.org/XSLT/>
Python <http://www.python.org/>
-and optionally makes use of:
- Check <http://check.sourceforge.net/>
See configure.ac for full details, including versions required.
diff --git a/configure.ac b/configure.ac
index 0ddfa53c..bd9a5379 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,7 @@ dnl GTK docs
GTK_DOC_CHECK
dnl Check for Glib
-PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16, gobject-2.0 >= 2.16, gthread-2.0 >= 2.4])
+PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.24, gobject-2.0 >= 2.16, gthread-2.0 >= 2.4])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
@@ -179,7 +179,7 @@ AC_SUBST(LIBXML2_CFLAGS)
AC_SUBST(LIBXML2_LIBS)
dnl Check for telepathy-glib
-PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib >= 0.11.16])
+PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib >= 0.13.12])
AC_SUBST(TELEPATHY_GLIB_CFLAGS)
AC_SUBST(TELEPATHY_GLIB_LIBS)
@@ -204,13 +204,51 @@ else
AC_MSG_WARN([libuuid not found, falling back to generating random IDs])
fi
-# Checks for the 'check' unit testing library
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
- [ HAVE_CHECK=yes ],
- [ HAVE_CHECK=no ] )
-AM_CONDITIONAL(HAVE_CHECK, test "x$HAVE_CHECK" = "xyes")
+dnl plugins
+AC_ARG_ENABLE(plugins,
+ AC_HELP_STRING([--disable-plugins],
+ [disable plugin loader]),
+ [enable_plugins=$enableval], [enable_plugins=yes])
+
+if test x$enable_plugins = xyes; then
+ AC_DEFINE(ENABLE_PLUGINS, [], [Enable plugins])
+ PKG_CHECK_MODULES(GMODULE, [gmodule-2.0])
+
+ AC_ARG_ENABLE(plugin-api,
+ AC_HELP_STRING([--enable-plugin-api],
+ [install headers for third-party plugins (experimental)]),
+ [
+ enable_plugin_api=$enableval
+ wocky_install_headers_dir="${includedir}/telepathy-salut-0"
+ ],
+ [enable_plugin_api=no])
+fi
+
+AC_SUBST(GMODULE_CFLAGS)
+AC_SUBST(GMODULE_LIBS)
+
+AM_CONDITIONAL(ENABLE_PLUGINS, test x$enable_plugins = xyes)
+AC_SUBST(ENABLE_PLUGINS)
+
+AM_CONDITIONAL(ENABLE_PLUGIN_API, test x$enable_plugin_api = xyes)
+# We have to run Wocky's configure *before* looking for it with
+# PKG_CHECK_MODULES so wocky-uninstalled.pc has been generated
+
+# We tell Wocky to install its headers alongside gabble's so that an actual
+# separate Wocky installation won't clash with them. This is a bit of a hack.
+# AX_CONFIG_DIR doesn't make it very easy to pass extra arguments to the
+# submodule's configure.
+
+prev_ac_configure_args=$ac_configure_args
+ac_configure_args="$ac_configure_args --with-installed-headers=${wocky_install_headers_dir}"
+
+prev_top_build_prefix=$ac_top_build_prefix
AX_CONFIG_DIR([lib/ext/wocky])
+ac_top_build_prefix=$prev_top_build_prefix
+
+ac_configure_args=$prev_ac_configure_args
+
PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+"$PKG_CONFIG_PATH:"}${ac_abs_top_builddir}/lib/ext/wocky/wocky"
export PKG_CONFIG_PATH
PKG_CHECK_MODULES([WOCKY], [wocky >= 0.0.0])
@@ -227,6 +265,8 @@ AC_OUTPUT( Makefile \
lib/gibber/tests/Makefile \
lib/gibber/tests/inputs/Makefile \
src/Makefile \
+ src/telepathy-salut-uninstalled.pc \
+ src/telepathy-salut.pc \
m4/Makefile \
data/Makefile \
extensions/Makefile \
@@ -234,4 +274,8 @@ AC_OUTPUT( Makefile \
tests/Makefile \
tests/twisted/Makefile \
tests/twisted/tools/Makefile \
+ plugins/Makefile \
+ salut/Makefile \
+ salut/telepathy-salut-uninstalled.pc \
+ salut/telepathy-salut.pc
)
diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am
index c2cd533b..4b6ce8f4 100644
--- a/lib/gibber/Makefile.am
+++ b/lib/gibber/Makefile.am
@@ -26,12 +26,8 @@ HANDWRITTEN_SOURCES = \
gibber-bytestream-direct.c \
gibber-debug.c \
gibber-debug.h \
- gibber-xmpp-node.c \
- gibber-xmpp-node.h \
gibber-xmpp-reader.c \
gibber-xmpp-reader.h \
- gibber-xmpp-stanza.c \
- gibber-xmpp-stanza.h \
gibber-xmpp-writer.c \
gibber-xmpp-writer.h \
gibber-transport.c \
diff --git a/lib/gibber/gibber-bytestream-ibb.c b/lib/gibber/gibber-bytestream-ibb.c
index a50e4702..d2f521af 100644
--- a/lib/gibber/gibber-bytestream-ibb.c
+++ b/lib/gibber/gibber-bytestream-ibb.c
@@ -28,7 +28,7 @@
#include "gibber-xmpp-connection.h"
#include "gibber-muc-connection.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#include "gibber-namespaces.h"
#include "gibber-xmpp-error.h"
@@ -93,13 +93,13 @@ gibber_bytestream_ibb_init (GibberBytestreamIBB *self)
static void
xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
GibberBytestreamIBB *self = (GibberBytestreamIBB *) user_data;
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberXmppNode *data;
+ WockyNode *data;
GString *str;
guchar *decoded;
gsize len;
@@ -125,7 +125,7 @@ xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
return;
}
- from = gibber_xmpp_node_get_attribute (node, "from");
+ from = wocky_node_get_attribute (node, "from");
if (from == NULL)
{
DEBUG ("got a message without a from field, ignoring");
@@ -341,7 +341,7 @@ gibber_bytestream_ibb_send (GibberBytestreamIface *bytestream,
{
GibberBytestreamIBB *self = GIBBER_BYTESTREAM_IBB (bytestream);
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
gchar *seq, *encoded;
gboolean ret;
@@ -356,29 +356,29 @@ gibber_bytestream_ibb_send (GibberBytestreamIface *bytestream,
encoded = g_base64_encode ((const guchar *) str, len);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_MESSAGE,
- GIBBER_STANZA_SUB_TYPE_NONE,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_NONE,
priv->self_id, priv->peer_id,
- GIBBER_NODE, "data",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
- GIBBER_NODE_ATTRIBUTE, "sid", priv->stream_id,
- GIBBER_NODE_ATTRIBUTE, "seq", seq,
- GIBBER_NODE_TEXT, encoded,
- GIBBER_NODE_END,
- GIBBER_NODE, "amp",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_AMP,
- GIBBER_NODE, "rule",
- GIBBER_NODE_ATTRIBUTE, "condition", "deliver-at",
- GIBBER_NODE_ATTRIBUTE, "value", "stored",
- GIBBER_NODE_ATTRIBUTE, "action", "error",
- GIBBER_NODE_END,
- GIBBER_NODE, "rule",
- GIBBER_NODE_ATTRIBUTE, "condition", "match-resource",
- GIBBER_NODE_ATTRIBUTE, "value", "exact",
- GIBBER_NODE_ATTRIBUTE, "action", "error",
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "data",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
+ WOCKY_NODE_ATTRIBUTE, "sid", priv->stream_id,
+ WOCKY_NODE_ATTRIBUTE, "seq", seq,
+ WOCKY_NODE_TEXT, encoded,
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "amp",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_AMP,
+ WOCKY_NODE_START, "rule",
+ WOCKY_NODE_ATTRIBUTE, "condition", "deliver-at",
+ WOCKY_NODE_ATTRIBUTE, "value", "stored",
+ WOCKY_NODE_ATTRIBUTE, "action", "error",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "rule",
+ WOCKY_NODE_ATTRIBUTE, "condition", "match-resource",
+ WOCKY_NODE_ATTRIBUTE, "value", "exact",
+ WOCKY_NODE_ATTRIBUTE, "action", "error",
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
DEBUG ("send %d bytes", len);
ret = gibber_xmpp_connection_send (priv->xmpp_connection, stanza, NULL);
@@ -390,31 +390,31 @@ gibber_bytestream_ibb_send (GibberBytestreamIface *bytestream,
return ret;
}
-static GibberXmppStanza *
+static WockyStanza *
create_si_accept_iq (GibberBytestreamIBB *self)
{
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
- return gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_RESULT,
+ return wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_RESULT,
priv->self_id, priv->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", priv->stream_init_id,
- GIBBER_NODE, "si",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_SI,
- GIBBER_NODE, "feature",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
- GIBBER_NODE, "x",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
- GIBBER_NODE_ATTRIBUTE, "type", "submit",
- GIBBER_NODE, "field",
- GIBBER_NODE_ATTRIBUTE, "var", "stream-method",
- GIBBER_NODE, "value",
- GIBBER_NODE_TEXT, GIBBER_XMPP_NS_IBB,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", priv->stream_init_id,
+ WOCKY_NODE_START, "si",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_SI,
+ WOCKY_NODE_START, "feature",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
+ WOCKY_NODE_START, "x",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
+ WOCKY_NODE_ATTRIBUTE, "type", "submit",
+ WOCKY_NODE_START, "field",
+ WOCKY_NODE_ATTRIBUTE, "var", "stream-method",
+ WOCKY_NODE_START, "value",
+ WOCKY_NODE_TEXT, GIBBER_XMPP_NS_IBB,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END, NULL);
}
/*
@@ -429,9 +429,9 @@ gibber_bytestream_ibb_accept (GibberBytestreamIface *bytestream,
{
GibberBytestreamIBB *self = GIBBER_BYTESTREAM_IBB (bytestream);
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
- GibberXmppNode *si;
+ WockyNode *si;
if (priv->state != GIBBER_BYTESTREAM_STATE_LOCAL_PENDING)
{
@@ -442,7 +442,7 @@ gibber_bytestream_ibb_accept (GibberBytestreamIface *bytestream,
stanza = create_si_accept_iq (self);
node = wocky_stanza_get_top_node (stanza);
- si = gibber_xmpp_node_get_child_ns (node, "si", GIBBER_XMPP_NS_SI);
+ si = wocky_node_get_child_ns (node, "si", GIBBER_XMPP_NS_SI);
g_assert (si != NULL);
if (func != NULL)
@@ -462,16 +462,16 @@ gibber_bytestream_ibb_decline (GibberBytestreamIBB *self,
GError *error)
{
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
g_return_if_fail (priv->state == GIBBER_BYTESTREAM_STATE_LOCAL_PENDING);
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
priv->self_id, priv->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", priv->stream_init_id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", priv->stream_init_id,
+ NULL);
node = wocky_stanza_get_top_node (stanza);
if (error != NULL && error->domain == GIBBER_XMPP_ERROR)
@@ -515,17 +515,17 @@ gibber_bytestream_ibb_close (GibberBytestreamIface *bytestream,
else if (priv->xmpp_connection != NULL)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
DEBUG ("send IBB close stanza");
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
priv->self_id, priv->peer_id,
- GIBBER_NODE, "close",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
- GIBBER_NODE_ATTRIBUTE, "sid", priv->stream_id,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "close",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
+ WOCKY_NODE_ATTRIBUTE, "sid", priv->stream_id,
+ WOCKY_NODE_END, NULL);
gibber_xmpp_connection_send (priv->xmpp_connection, stanza, NULL);
@@ -571,7 +571,7 @@ gibber_bytestream_ibb_initiate (GibberBytestreamIface *bytestream)
{
GibberBytestreamIBB *self = GIBBER_BYTESTREAM_IBB (bytestream);
GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
- GibberXmppStanza *msg;
+ WockyStanza *msg;
GError *error = NULL;
if (priv->state != GIBBER_BYTESTREAM_STATE_INITIATING)
@@ -593,14 +593,14 @@ gibber_bytestream_ibb_initiate (GibberBytestreamIface *bytestream)
return FALSE;
}
- msg = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_SET,
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
priv->self_id, priv->peer_id,
- GIBBER_NODE, "open",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
- GIBBER_NODE_ATTRIBUTE, "sid", priv->stream_id,
- GIBBER_NODE_ATTRIBUTE, "block-size", "4096",
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "open",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_IBB,
+ WOCKY_NODE_ATTRIBUTE, "sid", priv->stream_id,
+ WOCKY_NODE_ATTRIBUTE, "block-size", "4096",
+ WOCKY_NODE_END, NULL);
/* XXX should send using _with_reply (ibb_init_reply_cb) */
if (!gibber_xmpp_connection_send (priv->xmpp_connection, msg, &error))
diff --git a/lib/gibber/gibber-bytestream-ibb.h b/lib/gibber/gibber-bytestream-ibb.h
index f8c75559..507562c1 100644
--- a/lib/gibber/gibber-bytestream-ibb.h
+++ b/lib/gibber/gibber-bytestream-ibb.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
#include "gibber-bytestream-iface.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
diff --git a/lib/gibber/gibber-bytestream-iface.h b/lib/gibber/gibber-bytestream-iface.h
index 88a66df2..5f17ba70 100644
--- a/lib/gibber/gibber-bytestream-iface.h
+++ b/lib/gibber/gibber-bytestream-iface.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
@@ -44,7 +44,7 @@ typedef enum
} GibberBytestreamState;
typedef void (* GibberBytestreamAugmentSiAcceptReply) (
- GibberXmppNode *si, gpointer user_data);
+ WockyNode *si, gpointer user_data);
typedef struct _GibberBytestreamIface GibberBytestreamIface;
typedef struct _GibberBytestreamIfaceClass GibberBytestreamIfaceClass;
diff --git a/lib/gibber/gibber-bytestream-oob.c b/lib/gibber/gibber-bytestream-oob.c
index ccd50bd8..51c887cd 100644
--- a/lib/gibber/gibber-bytestream-oob.c
+++ b/lib/gibber/gibber-bytestream-oob.c
@@ -31,7 +31,7 @@
#include "gibber-sockets.h"
#include "gibber-bytestream-iface.h"
#include "gibber-xmpp-connection.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#include "gibber-namespaces.h"
#include "gibber-linklocal-transport.h"
#include "gibber-xmpp-error.h"
@@ -113,16 +113,16 @@ gibber_bytestream_oob_init (GibberBytestreamOOB *self)
priv->dispose_has_run = FALSE;
}
-static GibberXmppStanza *
+static WockyStanza *
make_iq_oob_sucess_response (const gchar *from,
const gchar *to,
const gchar *id)
{
- return gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_RESULT,
+ return wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_RESULT,
from, to,
- GIBBER_NODE_ATTRIBUTE, "id", id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", id,
+ NULL);
}
static void
@@ -309,37 +309,37 @@ out:
static gboolean
parse_oob_init_iq (GibberBytestreamOOB *self,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- GibberXmppNode *query_node, *url_node;
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyNode *query_node, *url_node;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
const gchar *stream_id, *url;
WockyNode *node = wocky_stanza_get_top_node (stanza);
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ ||
- sub_type != GIBBER_STANZA_SUB_TYPE_SET)
+ if (type != WOCKY_STANZA_TYPE_IQ ||
+ sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- query_node = gibber_xmpp_node_get_child_ns (node, "query",
+ query_node = wocky_node_get_child_ns (node, "query",
GIBBER_XMPP_NS_IQ_OOB);
if (query_node == NULL)
return FALSE;
- stream_id = gibber_xmpp_node_get_attribute (query_node, "sid");
+ stream_id = wocky_node_get_attribute (query_node, "sid");
if (stream_id == NULL || strcmp (stream_id, priv->stream_id) != 0)
return FALSE;
- url_node = gibber_xmpp_node_get_child (query_node, "url");
+ url_node = wocky_node_get_child (query_node, "url");
if (url_node == NULL)
return FALSE;
url = url_node->content;
priv->recipient = TRUE;
- priv->stream_open_id = g_strdup (gibber_xmpp_node_get_attribute (
+ priv->stream_open_id = g_strdup (wocky_node_get_attribute (
node, "id"));
connect_to_url (self, url);
@@ -349,11 +349,11 @@ parse_oob_init_iq (GibberBytestreamOOB *self,
static gboolean
parse_oob_iq_result (GibberBytestreamOOB *self,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
const gchar *id;
WockyNode *node = wocky_stanza_get_top_node (stanza);
@@ -361,14 +361,14 @@ parse_oob_iq_result (GibberBytestreamOOB *self,
/* Only the sender have to wait for the IQ reply */
return FALSE;
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ ||
- sub_type != GIBBER_STANZA_SUB_TYPE_RESULT)
+ if (type != WOCKY_STANZA_TYPE_IQ ||
+ sub_type != WOCKY_STANZA_SUB_TYPE_RESULT)
return FALSE;
/* FIXME: we should check if it's the right sender */
- id = gibber_xmpp_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL || strcmp (id, priv->stream_open_id) != 0)
return FALSE;
@@ -380,7 +380,7 @@ parse_oob_iq_result (GibberBytestreamOOB *self,
static void
xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
GibberBytestreamOOB *self = (GibberBytestreamOOB *) user_data;
@@ -388,7 +388,7 @@ xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
const gchar *from;
/* discard invalid stanza */
- from = gibber_xmpp_node_get_attribute (node, "from");
+ from = wocky_node_get_attribute (node, "from");
if (from == NULL)
{
DEBUG ("got a message without a from field");
@@ -714,31 +714,31 @@ gibber_bytestream_oob_send (GibberBytestreamIface *bytestream,
return TRUE;
}
-static GibberXmppStanza *
+static WockyStanza *
create_si_accept_iq (GibberBytestreamOOB *self)
{
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- return gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_RESULT,
+ return wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_RESULT,
priv->self_id, priv->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", priv->stream_init_id,
- GIBBER_NODE, "si",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_SI,
- GIBBER_NODE, "feature",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
- GIBBER_NODE, "x",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
- GIBBER_NODE_ATTRIBUTE, "type", "submit",
- GIBBER_NODE, "field",
- GIBBER_NODE_ATTRIBUTE, "var", "stream-method",
- GIBBER_NODE, "value",
- GIBBER_NODE_TEXT, GIBBER_XMPP_NS_IQ_OOB,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", priv->stream_init_id,
+ WOCKY_NODE_START, "si",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_SI,
+ WOCKY_NODE_START, "feature",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
+ WOCKY_NODE_START, "x",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
+ WOCKY_NODE_ATTRIBUTE, "type", "submit",
+ WOCKY_NODE_START, "field",
+ WOCKY_NODE_ATTRIBUTE, "var", "stream-method",
+ WOCKY_NODE_START, "value",
+ WOCKY_NODE_TEXT, GIBBER_XMPP_NS_IQ_OOB,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END, NULL);
}
/*
@@ -753,9 +753,9 @@ gibber_bytestream_oob_accept (GibberBytestreamIface *bytestream,
{
GibberBytestreamOOB *self = GIBBER_BYTESTREAM_OOB (bytestream);
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
- GibberXmppNode *si;
+ WockyNode *si;
if (priv->state != GIBBER_BYTESTREAM_STATE_LOCAL_PENDING)
{
@@ -766,7 +766,7 @@ gibber_bytestream_oob_accept (GibberBytestreamIface *bytestream,
stanza = create_si_accept_iq (self);
node = wocky_stanza_get_top_node (stanza);
- si = gibber_xmpp_node_get_child_ns (node, "si", GIBBER_XMPP_NS_SI);
+ si = wocky_node_get_child_ns (node, "si", GIBBER_XMPP_NS_SI);
g_assert (si != NULL);
if (func != NULL)
@@ -794,7 +794,7 @@ bytestream_closed (GibberBytestreamOOB *self)
if (priv->xmpp_connection->stream_flags ==
GIBBER_XMPP_CONNECTION_STREAM_FULLY_OPEN)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
/* As described in the XEP, we send result IQ when we have
* finished to use the OOB */
@@ -833,16 +833,16 @@ gibber_bytestream_oob_decline (GibberBytestreamOOB *self,
GError *error)
{
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
g_return_if_fail (priv->state == GIBBER_BYTESTREAM_STATE_LOCAL_PENDING);
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
priv->self_id, priv->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", priv->stream_init_id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", priv->stream_init_id,
+ NULL);
node = wocky_stanza_get_top_node (stanza);
if (error != NULL && error->domain == GIBBER_XMPP_ERROR)
@@ -903,22 +903,22 @@ gibber_bytestream_oob_close (GibberBytestreamIface *bytestream,
TRUE);
}
-static GibberXmppStanza *
+static WockyStanza *
make_oob_init_iq (const gchar *from,
const gchar *to,
const gchar *stream_id,
const gchar *url)
{
- return gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_SET,
+ return wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
from, to,
- GIBBER_NODE, "query",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_IQ_OOB,
- GIBBER_NODE_ATTRIBUTE, "sid", stream_id,
- GIBBER_NODE, "url",
- GIBBER_NODE_TEXT, url,
- GIBBER_NODE_END,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "query",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_IQ_OOB,
+ WOCKY_NODE_ATTRIBUTE, "sid", stream_id,
+ WOCKY_NODE_START, "url",
+ WOCKY_NODE_TEXT, url,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END, NULL);
}
static void
@@ -953,7 +953,7 @@ gibber_bytestream_oob_initiate (GibberBytestreamIface *bytestream)
{
GibberBytestreamOOB *self = GIBBER_BYTESTREAM_OOB (bytestream);
GibberBytestreamOOBPrivate *priv = GIBBER_BYTESTREAM_OOB_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
GError *error = NULL;
const gchar *id;
@@ -990,12 +990,12 @@ gibber_bytestream_oob_initiate (GibberBytestreamIface *bytestream)
g_free (url);
node = wocky_stanza_get_top_node (stanza);
- id = gibber_xmpp_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL)
{
priv->stream_open_id = gibber_xmpp_connection_new_id (
priv->xmpp_connection);
- gibber_xmpp_node_set_attribute (node, "id",
+ wocky_node_set_attribute (node, "id",
priv->stream_open_id);
}
else
diff --git a/lib/gibber/gibber-debug.c b/lib/gibber/gibber-debug.c
index e7ce58cd..47cc8742 100644
--- a/lib/gibber/gibber-debug.c
+++ b/lib/gibber/gibber-debug.c
@@ -70,7 +70,7 @@ void gibber_debug (DebugFlags flag,
void
gibber_debug_stanza (DebugFlags flag,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
const gchar *format,
...)
{
@@ -87,7 +87,7 @@ gibber_debug_stanza (DebugFlags flag,
msg = g_strdup_vprintf (format, args);
va_end (args);
- node_str = gibber_xmpp_node_to_string (node);
+ node_str = wocky_node_to_string (node);
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s\n%s", msg, node_str);
diff --git a/lib/gibber/gibber-debug.h b/lib/gibber/gibber-debug.h
index 9cd9f1be..aeef49af 100644
--- a/lib/gibber/gibber-debug.h
+++ b/lib/gibber/gibber-debug.h
@@ -6,7 +6,7 @@
#include <glib.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
@@ -34,7 +34,7 @@ void gibber_debug_set_flags (DebugFlags flags);
gboolean gibber_debug_flag_is_set (DebugFlags flag);
void gibber_debug (DebugFlags flag, const gchar *format, ...)
G_GNUC_PRINTF (2, 3);
-void gibber_debug_stanza (DebugFlags flag, GibberXmppStanza *stanza,
+void gibber_debug_stanza (DebugFlags flag, WockyStanza *stanza,
const gchar *format, ...)
G_GNUC_PRINTF (3, 4);
diff --git a/lib/gibber/gibber-file-transfer.c b/lib/gibber/gibber-file-transfer.c
index 5fd49a57..7f8d2843 100644
--- a/lib/gibber/gibber-file-transfer.c
+++ b/lib/gibber/gibber-file-transfer.c
@@ -138,7 +138,7 @@ generate_id (void)
}
static void received_stanza_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza, gpointer user_data);
+ WockyStanza *stanza, gpointer user_data);
static void
gibber_file_transfer_set_property (GObject *object,
@@ -331,20 +331,20 @@ gibber_file_transfer_finalize (GObject *object)
static void
received_stanza_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
GibberFileTransfer *self = user_data;
const gchar *id;
- id = gibber_xmpp_node_get_attribute (wocky_stanza_get_top_node (stanza),
+ id = wocky_node_get_attribute (wocky_stanza_get_top_node (stanza),
"id");
if (id != NULL && strcmp (id, self->id) == 0)
GIBBER_FILE_TRANSFER_GET_CLASS (self)->received_stanza (self, stanza);
}
gboolean
-gibber_file_transfer_is_file_offer (GibberXmppStanza *stanza)
+gibber_file_transfer_is_file_offer (WockyStanza *stanza)
{
/* FIXME put the known backends in a list and stop when the first one
* can handle the stanza */
@@ -353,7 +353,7 @@ gibber_file_transfer_is_file_offer (GibberXmppStanza *stanza)
GibberFileTransfer *
gibber_file_transfer_new_from_stanza_with_from (
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GibberXmppConnection *connection,
const gchar *from,
GError **error)
@@ -373,7 +373,7 @@ gibber_file_transfer_new_from_stanza_with_from (
}
GibberFileTransfer *
-gibber_file_transfer_new_from_stanza (GibberXmppStanza *stanza,
+gibber_file_transfer_new_from_stanza (WockyStanza *stanza,
GibberXmppConnection *connection,
GError **error)
{
@@ -455,7 +455,7 @@ gibber_file_transfer_get_size (GibberFileTransfer *self)
gboolean
gibber_file_transfer_send_stanza (GibberFileTransfer *self,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GError **error)
{
if (self->priv->connection->transport == NULL ||
diff --git a/lib/gibber/gibber-file-transfer.h b/lib/gibber/gibber-file-transfer.h
index 65d985b9..a1e8bfe3 100644
--- a/lib/gibber/gibber-file-transfer.h
+++ b/lib/gibber/gibber-file-transfer.h
@@ -22,7 +22,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#include "gibber-xmpp-connection.h"
G_BEGIN_DECLS
@@ -59,7 +59,7 @@ struct _GibberFileTransferClass
void (*cancel) (GibberFileTransfer *ft,
guint error_code);
void (*received_stanza) (GibberFileTransfer *ft,
- GibberXmppStanza *stanza);
+ WockyStanza *stanza);
};
typedef struct _GibberFileTransferPrivate GibberFileTransferPrivate;
@@ -103,13 +103,13 @@ GType gibber_file_transfer_get_type (void);
GibberFileTransferClass))
-gboolean gibber_file_transfer_is_file_offer (GibberXmppStanza *stanza);
+gboolean gibber_file_transfer_is_file_offer (WockyStanza *stanza);
GibberFileTransfer *gibber_file_transfer_new_from_stanza (
- GibberXmppStanza *stanza, GibberXmppConnection *connection,
+ WockyStanza *stanza, GibberXmppConnection *connection,
GError **error);
GibberFileTransfer *gibber_file_transfer_new_from_stanza_with_from (
- GibberXmppStanza *stanza, GibberXmppConnection *connection,
+ WockyStanza *stanza, GibberXmppConnection *connection,
const gchar *from, GError **error);
void gibber_file_transfer_offer (GibberFileTransfer *self);
@@ -121,7 +121,7 @@ void gibber_file_transfer_cancel (GibberFileTransfer *self, guint error_code);
/* FIXME move to a private header if gibber becomes a public library */
gboolean gibber_file_transfer_send_stanza (GibberFileTransfer *self,
- GibberXmppStanza *stanza, GError **error);
+ WockyStanza *stanza, GError **error);
void gibber_file_transfer_emit_error (GibberFileTransfer *self, GError *error);
diff --git a/lib/gibber/gibber-iq-helper.c b/lib/gibber/gibber-iq-helper.c
index f96c74f8..24532255 100644
--- a/lib/gibber/gibber-iq-helper.c
+++ b/lib/gibber/gibber-iq-helper.c
@@ -28,7 +28,7 @@
#include "gibber-xmpp-reader.h"
#include "gibber-xmpp-writer.h"
#include "gibber-transport.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_DEFINE_TYPE (GibberIqHelper, gibber_iq_helper, G_TYPE_OBJECT);
@@ -58,7 +58,7 @@ typedef struct
GibberIqHelper *self;
gchar *id;
GibberIqHelperStanzaReplyFunc reply_func;
- GibberXmppStanza *sent_stanza;
+ WockyStanza *sent_stanza;
GObject *object;
gpointer user_data;
} ReplyHandlerData;
@@ -94,7 +94,7 @@ gibber_iq_helper_init (GibberIqHelper *self)
static void
xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
@@ -103,7 +103,7 @@ xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
const gchar *id;
ReplyHandlerData *data;
- id = gibber_xmpp_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL)
return;
@@ -116,9 +116,9 @@ xmpp_connection_received_stanza_cb (GibberXmppConnection *conn,
return;
/* Its subtype have to be "result" or "error" */
- if (strcmp (gibber_xmpp_node_get_attribute (node, "type"), "result")
+ if (strcmp (wocky_node_get_attribute (node, "type"), "result")
!= 0 &&
- strcmp (gibber_xmpp_node_get_attribute (node, "type"), "error")
+ strcmp (wocky_node_get_attribute (node, "type"), "error")
!= 0)
return;
@@ -287,7 +287,7 @@ reply_handler_object_destroy_notify_cb (gpointer _data,
/*
* gibber_iq_send_with_reply
*
- * Send a GibberXmppStanza and call reply_func when we receive
+ * Send a WockyStanza and call reply_func when we receive
* its reply.
*
* If object is non-NULL the handler will follow the lifetime of that object,
@@ -295,7 +295,7 @@ reply_handler_object_destroy_notify_cb (gpointer _data,
*/
gboolean
gibber_iq_helper_send_with_reply (GibberIqHelper *self,
- GibberXmppStanza *iq,
+ WockyStanza *iq,
GibberIqHelperStanzaReplyFunc reply_func,
GObject *object,
gpointer user_data,
@@ -314,11 +314,11 @@ gibber_iq_helper_send_with_reply (GibberIqHelper *self,
priv = GIBBER_IQ_HELPER_GET_PRIVATE (self);
- tmp = gibber_xmpp_node_get_attribute (node, "id");
+ tmp = wocky_node_get_attribute (node, "id");
if (tmp == NULL)
{
id = gibber_xmpp_connection_new_id (priv->xmpp_connection);
- gibber_xmpp_node_set_attribute (node, "id", id);
+ wocky_node_set_attribute (node, "id", id);
}
else
{
@@ -351,49 +351,49 @@ gibber_iq_helper_send_with_reply (GibberIqHelper *self,
return TRUE;
}
-static GibberXmppStanza *
-new_reply (GibberXmppStanza *iq,
- GibberStanzaSubType sub_type)
+static WockyStanza *
+new_reply (WockyStanza *iq,
+ WockyStanzaSubType sub_type)
{
- GibberXmppStanza *reply;
+ WockyStanza *reply;
WockyNode *node = wocky_stanza_get_top_node (iq);
const gchar *id;
const gchar *iq_from, *iq_to;
- g_return_val_if_fail (sub_type == GIBBER_STANZA_SUB_TYPE_RESULT ||
- sub_type == GIBBER_STANZA_SUB_TYPE_ERROR, NULL);
+ g_return_val_if_fail (sub_type == WOCKY_STANZA_SUB_TYPE_RESULT ||
+ sub_type == WOCKY_STANZA_SUB_TYPE_ERROR, NULL);
g_return_val_if_fail (strcmp (node->name, "iq") == 0, NULL);
- id = gibber_xmpp_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
g_return_val_if_fail (id != NULL, NULL);
- iq_from = gibber_xmpp_node_get_attribute (node, "from");
- iq_to = gibber_xmpp_node_get_attribute (node, "to");
+ iq_from = wocky_node_get_attribute (node, "from");
+ iq_to = wocky_node_get_attribute (node, "to");
- reply = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
+ reply = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
sub_type,
iq_to, iq_from,
- GIBBER_NODE_ATTRIBUTE, "id", id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", id,
+ NULL);
return reply;
}
-GibberXmppStanza *
-gibber_iq_helper_new_result_reply (GibberXmppStanza *iq)
+WockyStanza *
+gibber_iq_helper_new_result_reply (WockyStanza *iq)
{
- return new_reply (iq, GIBBER_STANZA_SUB_TYPE_RESULT);
+ return new_reply (iq, WOCKY_STANZA_SUB_TYPE_RESULT);
}
-GibberXmppStanza *
-gibber_iq_helper_new_error_reply (GibberXmppStanza *iq,
+WockyStanza *
+gibber_iq_helper_new_error_reply (WockyStanza *iq,
GibberXmppError error,
const gchar *errmsg)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
- stanza = new_reply (iq, GIBBER_STANZA_SUB_TYPE_ERROR);
+ stanza = new_reply (iq, WOCKY_STANZA_SUB_TYPE_ERROR);
node = wocky_stanza_get_top_node (stanza);
gibber_xmpp_error_to_node (error, node, errmsg);
diff --git a/lib/gibber/gibber-iq-helper.h b/lib/gibber/gibber-iq-helper.h
index dc3648c1..3336d976 100644
--- a/lib/gibber/gibber-iq-helper.h
+++ b/lib/gibber/gibber-iq-helper.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#include "gibber-xmpp-connection.h"
#include "gibber-xmpp-error.h"
@@ -62,8 +62,8 @@ GType gibber_iq_helper_get_type (void);
GibberIqHelperClass))
typedef void (*GibberIqHelperStanzaReplyFunc) (GibberIqHelper *helper,
- GibberXmppStanza *sent_stanza,
- GibberXmppStanza *reply_stanza,
+ WockyStanza *sent_stanza,
+ WockyStanza *reply_stanza,
GObject *object,
gpointer user_data);
@@ -72,14 +72,14 @@ gibber_iq_helper_new (GibberXmppConnection *xmpp_connection);
gboolean
gibber_iq_helper_send_with_reply (GibberIqHelper *helper,
- GibberXmppStanza *iq, GibberIqHelperStanzaReplyFunc reply_func,
+ WockyStanza *iq, GibberIqHelperStanzaReplyFunc reply_func,
GObject *object, gpointer user_data, GError **error);
-GibberXmppStanza *
-gibber_iq_helper_new_result_reply (GibberXmppStanza *iq);
+WockyStanza *
+gibber_iq_helper_new_result_reply (WockyStanza *iq);
-GibberXmppStanza *
-gibber_iq_helper_new_error_reply (GibberXmppStanza *iq, GibberXmppError error,
+WockyStanza *
+gibber_iq_helper_new_error_reply (WockyStanza *iq, GibberXmppError error,
const gchar *errmsg);
G_END_DECLS
diff --git a/lib/gibber/gibber-muc-connection.c b/lib/gibber/gibber-muc-connection.c
index 7b7efdf9..94ba8c3d 100644
--- a/lib/gibber/gibber-muc-connection.c
+++ b/lib/gibber/gibber-muc-connection.c
@@ -43,7 +43,7 @@
#include "gibber-debug.h"
static void _reader_received_stanza_cb (GibberXmppReader *reader,
- GibberXmppStanza *stanza, gpointer user_data);
+ WockyStanza *stanza, gpointer user_data);
static void _connection_received_data (GibberTransport *transport,
GibberBuffer *buffer, gpointer user_data);
@@ -147,7 +147,7 @@ gibber_muc_connection_class_init (
0,
NULL, NULL,
_gibber_signals_marshal_VOID__STRING_OBJECT,
- G_TYPE_NONE, 2, G_TYPE_STRING, GIBBER_TYPE_XMPP_STANZA);
+ G_TYPE_NONE, 2, G_TYPE_STRING, WOCKY_TYPE_STANZA);
/* UINT: 16 bit stream id
* POINTER: guint8 * data buffer
* ULONG: data buffer size
@@ -631,7 +631,7 @@ gibber_muc_connection_get_parameters (GibberMucConnection *connection)
}
static void
-_reader_received_stanza_cb (GibberXmppReader *reader, GibberXmppStanza *stanza,
+_reader_received_stanza_cb (GibberXmppReader *reader, WockyStanza *stanza,
gpointer user_data)
{
GibberMucConnection *self = GIBBER_MUC_CONNECTION (user_data);
@@ -680,7 +680,7 @@ _connection_received_data (GibberTransport *transport, GibberBuffer *buffer,
gboolean
gibber_muc_connection_send (GibberMucConnection *connection,
- GibberXmppStanza *stanza, GError **error)
+ WockyStanza *stanza, GError **error)
{
GibberMucConnectionPrivate *priv =
GIBBER_MUC_CONNECTION_GET_PRIVATE (connection);
diff --git a/lib/gibber/gibber-muc-connection.h b/lib/gibber/gibber-muc-connection.h
index 981efa18..0f724c84 100644
--- a/lib/gibber/gibber-muc-connection.h
+++ b/lib/gibber/gibber-muc-connection.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include "gibber-r-multicast-transport.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
@@ -101,7 +101,7 @@ const GHashTable * gibber_muc_connection_get_parameters (
GType gibber_muc_connection_get_type (void);
gboolean gibber_muc_connection_send (GibberMucConnection *connection,
- GibberXmppStanza *stanza, GError **error);
+ WockyStanza *stanza, GError **error);
gboolean
gibber_muc_connection_send_raw (GibberMucConnection *connection,
diff --git a/lib/gibber/gibber-oob-file-transfer.c b/lib/gibber/gibber-oob-file-transfer.c
index 0dba39ec..b811f8b9 100644
--- a/lib/gibber/gibber-oob-file-transfer.c
+++ b/lib/gibber/gibber-oob-file-transfer.c
@@ -26,7 +26,7 @@
#include <libsoup/soup-server.h>
#include <libsoup/soup-message.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#include "gibber-oob-file-transfer.h"
#include "gibber-fd-transport.h"
#include "gibber-namespaces.h"
@@ -86,7 +86,7 @@ static void gibber_oob_file_transfer_receive (GibberFileTransfer *ft,
static void gibber_oob_file_transfer_cancel (GibberFileTransfer *ft,
guint error_code);
static void gibber_oob_file_transfer_received_stanza (GibberFileTransfer *ft,
- GibberXmppStanza *stanza);
+ WockyStanza *stanza);
static void
gibber_oob_file_transfer_class_init (
@@ -135,27 +135,27 @@ gibber_oob_file_transfer_finalize (GObject *object)
}
gboolean
-gibber_oob_file_transfer_is_file_offer (GibberXmppStanza *stanza)
+gibber_oob_file_transfer_is_file_offer (WockyStanza *stanza)
{
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
- GibberXmppNode *query;
- GibberXmppNode *url;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
+ WockyNode *query;
+ WockyNode *url;
const gchar *url_content;
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ ||
- sub_type != GIBBER_STANZA_SUB_TYPE_SET)
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
+ if (type != WOCKY_STANZA_TYPE_IQ ||
+ sub_type != WOCKY_STANZA_SUB_TYPE_SET)
{
return FALSE;
}
- query = gibber_xmpp_node_get_child (wocky_stanza_get_top_node (stanza),
+ query = wocky_node_get_child (wocky_stanza_get_top_node (stanza),
"query");
if (query == NULL)
return FALSE;
- url = gibber_xmpp_node_get_child (query, "url");
+ url = wocky_node_get_child (query, "url");
if (url == NULL)
return FALSE;
@@ -176,16 +176,16 @@ gibber_oob_file_transfer_is_file_offer (GibberXmppStanza *stanza)
GibberFileTransfer *
gibber_oob_file_transfer_new_from_stanza_with_from (
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GibberXmppConnection *connection,
const gchar *peer_id,
GError **error)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
GibberOobFileTransfer *self;
- GibberXmppNode *query;
- GibberXmppNode *url_node;
- GibberXmppNode *desc_node;
+ WockyNode *query;
+ WockyNode *url_node;
+ WockyNode *desc_node;
const gchar *self_id;
const gchar *type;
const gchar *id;
@@ -203,7 +203,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- self_id = gibber_xmpp_node_get_attribute (node, "to");
+ self_id = wocky_node_get_attribute (node, "to");
if (peer_id == NULL)
{
@@ -219,7 +219,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- type = gibber_xmpp_node_get_attribute (node, "type");
+ type = wocky_node_get_attribute (node, "type");
if (type == NULL || strcmp (type, "set") != 0)
{
@@ -228,7 +228,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- id = gibber_xmpp_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL)
{
@@ -237,7 +237,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- query = gibber_xmpp_node_get_child (node, "query");
+ query = wocky_node_get_child (node, "query");
if (query == NULL)
{
@@ -246,7 +246,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- url_node = gibber_xmpp_node_get_child (query, "url");
+ url_node = wocky_node_get_child (query, "url");
if (url_node == NULL)
{
@@ -262,7 +262,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
return NULL;
}
- ft_type = gibber_xmpp_node_get_attribute (url_node, "type");
+ ft_type = wocky_node_get_attribute (url_node, "type");
if (ft_type != NULL && gibber_strdiff (ft_type, "file"))
{
@@ -286,13 +286,13 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
filename++; /* move after the last "/" */
filename = g_uri_unescape_string (filename, NULL);
- desc_node = gibber_xmpp_node_get_child (query, "desc");
+ desc_node = wocky_node_get_child (query, "desc");
if (desc_node != NULL)
{
description = desc_node->content;
}
- content_type = gibber_xmpp_node_get_attribute (url_node, "mimeType");
+ content_type = wocky_node_get_attribute (url_node, "mimeType");
if (content_type == NULL)
{
content_type = "application/octet-stream";
@@ -309,7 +309,7 @@ gibber_oob_file_transfer_new_from_stanza_with_from (
"content-type", content_type,
NULL);
- size = gibber_xmpp_node_get_attribute (url_node, "size");
+ size = wocky_node_get_attribute (url_node, "size");
if (size != NULL)
gibber_file_transfer_set_size (GIBBER_FILE_TRANSFER (self),
g_ascii_strtoull (size, NULL, 0));
@@ -369,7 +369,7 @@ http_client_finished_chunks_cb (SoupSession *session,
gpointer user_data)
{
GibberOobFileTransfer *self = user_data;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
GError *error = NULL;
guint64 size;
@@ -413,12 +413,12 @@ http_client_finished_chunks_cb (SoupSession *session,
return;
}
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_RESULT,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_RESULT,
GIBBER_FILE_TRANSFER (self)->self_id,
GIBBER_FILE_TRANSFER (self)->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
+ NULL);
if (!gibber_file_transfer_send_stanza (GIBBER_FILE_TRANSFER (self), stanza,
&error))
@@ -466,7 +466,7 @@ gibber_oob_file_transfer_receive (GibberFileTransfer *ft,
http_client_finished_chunks_cb, self);
}
-static GibberXmppStanza *
+static WockyStanza *
create_transfer_offer (GibberOobFileTransfer *self,
GError **error)
{
@@ -478,11 +478,11 @@ create_transfer_offer (GibberOobFileTransfer *self,
socklen_t name_addr_len = sizeof (name_addr);
gchar *host_escaped;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
- GibberXmppNode *query_node;
- GibberXmppNode *url_node;
- GibberXmppNode *desc_node;
+ WockyNode *query_node;
+ WockyNode *url_node;
+ WockyNode *desc_node;
gchar *filename_escaped;
gchar *url;
@@ -525,23 +525,23 @@ create_transfer_offer (GibberOobFileTransfer *self,
served_name = g_strdup_printf ("/%s/%s", GIBBER_FILE_TRANSFER (self)->id,
GIBBER_FILE_TRANSFER (self)->filename);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
GIBBER_FILE_TRANSFER (self)->self_id,
GIBBER_FILE_TRANSFER (self)->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
+ NULL);
node = wocky_stanza_get_top_node (stanza);
- query_node = gibber_xmpp_node_add_child_ns (node, "query",
+ query_node = wocky_node_add_child_ns (node, "query",
GIBBER_XMPP_NS_IQ_OOB);
- url_node = gibber_xmpp_node_add_child_with_content (query_node, "url", url);
- gibber_xmpp_node_set_attribute (url_node, "type", "file");
- gibber_xmpp_node_set_attribute (url_node, "mimeType",
+ url_node = wocky_node_add_child_with_content (query_node, "url", url);
+ wocky_node_set_attribute (url_node, "type", "file");
+ wocky_node_set_attribute (url_node, "mimeType",
GIBBER_FILE_TRANSFER (self)->content_type);
- desc_node = gibber_xmpp_node_add_child_with_content (query_node, "desc",
+ desc_node = wocky_node_add_child_with_content (query_node, "desc",
GIBBER_FILE_TRANSFER (self)->description);
size = gibber_file_transfer_get_size (GIBBER_FILE_TRANSFER (self));
@@ -551,7 +551,7 @@ create_transfer_offer (GibberOobFileTransfer *self,
{
gchar *size_str = g_strdup_printf ("%" G_GUINT64_FORMAT,
size);
- gibber_xmpp_node_set_attribute (url_node, "size", size_str);
+ wocky_node_set_attribute (url_node, "size", size_str);
g_free (size_str);
}
@@ -721,7 +721,7 @@ static void
gibber_oob_file_transfer_offer (GibberFileTransfer *ft)
{
GibberOobFileTransfer *self = GIBBER_OOB_FILE_TRANSFER (ft);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
GError *error = NULL;
/* start the server if not running */
@@ -827,11 +827,11 @@ gibber_oob_file_transfer_cancel (GibberFileTransfer *ft,
guint error_code)
{
GibberOobFileTransfer *self = GIBBER_OOB_FILE_TRANSFER (ft);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
- GibberXmppNode *query;
- GibberXmppNode *error_node;
- GibberXmppNode *error_desc;
+ WockyNode *query;
+ WockyNode *error_node;
+ WockyNode *error_desc;
gchar *code_string;
if (self->priv->cancelled)
@@ -843,33 +843,33 @@ gibber_oob_file_transfer_cancel (GibberFileTransfer *ft,
* sender cancelled the transfer. */
return;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_ERROR,
GIBBER_FILE_TRANSFER (self)->self_id,
GIBBER_FILE_TRANSFER (self)->peer_id,
- GIBBER_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", GIBBER_FILE_TRANSFER (self)->id,
+ NULL);
node = wocky_stanza_get_top_node (stanza);
- query = gibber_xmpp_node_add_child_ns (node, "query",
+ query = wocky_node_add_child_ns (node, "query",
GIBBER_XMPP_NS_IQ_OOB);
- gibber_xmpp_node_add_child_with_content (query, "url", self->priv->url);
+ wocky_node_add_child_with_content (query, "url", self->priv->url);
- error_node = gibber_xmpp_node_add_child (node, "error");
+ error_node = wocky_node_add_child (node, "error");
code_string = g_strdup_printf ("%d", error_code);
switch (error_code)
{
case HTTP_STATUS_CODE_NOT_FOUND:
- gibber_xmpp_node_set_attribute (error_node, "code", code_string);
- gibber_xmpp_node_set_attribute (error_node, "type", "cancel");
- error_desc = gibber_xmpp_node_add_child_ns (error_node,
+ wocky_node_set_attribute (error_node, "code", code_string);
+ wocky_node_set_attribute (error_node, "type", "cancel");
+ error_desc = wocky_node_add_child_ns (error_node,
"item-not-found", GIBBER_XMPP_NS_STANZAS);
break;
case HTTP_STATUS_CODE_NOT_ACCEPTABLE:
- gibber_xmpp_node_set_attribute (error_node, "code", code_string);
- gibber_xmpp_node_set_attribute (error_node, "type", "modify");
- error_desc = gibber_xmpp_node_add_child_ns (error_node,
+ wocky_node_set_attribute (error_node, "code", code_string);
+ wocky_node_set_attribute (error_node, "type", "modify");
+ error_desc = wocky_node_add_child_ns (error_node,
"not-acceptable", GIBBER_XMPP_NS_STANZAS);
break;
default:
@@ -885,17 +885,17 @@ gibber_oob_file_transfer_cancel (GibberFileTransfer *ft,
static void
gibber_oob_file_transfer_received_stanza (GibberFileTransfer *ft,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
GibberOobFileTransfer *self = GIBBER_OOB_FILE_TRANSFER (ft);
WockyNode *node = wocky_stanza_get_top_node (stanza);
const gchar *type;
- GibberXmppNode *error_node;
+ WockyNode *error_node;
if (strcmp (node->name, "iq") != 0)
return;
- type = gibber_xmpp_node_get_attribute (node, "type");
+ type = wocky_node_get_attribute (node, "type");
if (type == NULL)
return;
@@ -905,7 +905,7 @@ gibber_oob_file_transfer_received_stanza (GibberFileTransfer *ft,
return;
}
- error_node = gibber_xmpp_node_get_child (node, "error");
+ error_node = wocky_node_get_child (node, "error");
if (error_node != NULL)
{
GError *error = NULL;
@@ -914,10 +914,10 @@ gibber_oob_file_transfer_received_stanza (GibberFileTransfer *ft,
self->priv->cancelled = TRUE;
/* FIXME copy the error handling code from gabble */
- error_code_str = gibber_xmpp_node_get_attribute (error_node, "code");
+ error_code_str = wocky_node_get_attribute (error_node, "code");
if (error_code_str == NULL)
/* iChat uses the 'type' attribute to transmit the error code */
- error_code_str = gibber_xmpp_node_get_attribute (error_node, "type");
+ error_code_str = wocky_node_get_attribute (error_node, "type");
if (error_code_str != NULL && g_ascii_strtoll (error_code_str, NULL,
10) == HTTP_STATUS_CODE_NOT_ACCEPTABLE)
diff --git a/lib/gibber/gibber-oob-file-transfer.h b/lib/gibber/gibber-oob-file-transfer.h
index b8ec34ad..85f1decc 100644
--- a/lib/gibber/gibber-oob-file-transfer.h
+++ b/lib/gibber/gibber-oob-file-transfer.h
@@ -60,10 +60,10 @@ GType gibber_oob_file_transfer_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), GIBBER_TYPE_OOB_FILE_TRANSFER, GibberOobFileTransferClass))
-gboolean gibber_oob_file_transfer_is_file_offer (GibberXmppStanza *stanza);
+gboolean gibber_oob_file_transfer_is_file_offer (WockyStanza *stanza);
GibberFileTransfer *gibber_oob_file_transfer_new_from_stanza_with_from (
- GibberXmppStanza *stanza, GibberXmppConnection *connection,
+ WockyStanza *stanza, GibberXmppConnection *connection,
const gchar *from, GError **error);
G_END_DECLS
diff --git a/lib/gibber/gibber-xmpp-connection.c b/lib/gibber/gibber-xmpp-connection.c
index 50733f6b..e4e567b4 100644
--- a/lib/gibber/gibber-xmpp-connection.c
+++ b/lib/gibber/gibber-xmpp-connection.c
@@ -30,7 +30,7 @@
#include "gibber-xmpp-reader.h"
#include "gibber-xmpp-writer.h"
#include "gibber-transport.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#define XMPP_STREAM_NAMESPACE "http://etherx.jabber.org/streams"
@@ -59,7 +59,7 @@ static void _reader_stream_closed_cb (GibberXmppReader *reader,
gpointer user_data);
static void _reader_received_stanza_cb (GibberXmppReader *reader,
- GibberXmppStanza *stanza, gpointer user_data);
+ WockyStanza *stanza, gpointer user_data);
/* private structure */
typedef struct _GibberXmppConnectionPrivate GibberXmppConnectionPrivate;
@@ -148,7 +148,7 @@ gibber_xmpp_connection_class_init (
0,
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GIBBER_TYPE_XMPP_STANZA);
+ G_TYPE_NONE, 1, WOCKY_TYPE_STANZA);
signals[PARSE_ERROR] = g_signal_new ("parse-error",
G_OBJECT_CLASS_TYPE(gibber_xmpp_connection_class),
@@ -297,7 +297,7 @@ gibber_xmpp_connection_disengage (GibberXmppConnection *connection)
gboolean
gibber_xmpp_connection_send (GibberXmppConnection *connection,
- GibberXmppStanza *stanza, GError **error)
+ WockyStanza *stanza, GError **error)
{
GibberXmppConnectionPrivate *priv =
GIBBER_XMPP_CONNECTION_GET_PRIVATE (connection);
@@ -369,7 +369,7 @@ _reader_stream_closed_cb (GibberXmppReader *reader, gpointer user_data)
}
static void
-_reader_received_stanza_cb (GibberXmppReader *reader, GibberXmppStanza *stanza,
+_reader_received_stanza_cb (GibberXmppReader *reader, WockyStanza *stanza,
gpointer user_data)
{
GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (user_data);
diff --git a/lib/gibber/gibber-xmpp-connection.h b/lib/gibber/gibber-xmpp-connection.h
index 6239b19d..821e3327 100644
--- a/lib/gibber/gibber-xmpp-connection.h
+++ b/lib/gibber/gibber-xmpp-connection.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include "gibber-transport.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
@@ -90,7 +90,7 @@ void gibber_xmpp_connection_engage (GibberXmppConnection *connection,
void gibber_xmpp_connection_disengage (GibberXmppConnection *connection);
gboolean gibber_xmpp_connection_send (GibberXmppConnection *connection,
- GibberXmppStanza *stanza, GError **error);
+ WockyStanza *stanza, GError **error);
gchar * gibber_xmpp_connection_new_id (GibberXmppConnection *connection);
diff --git a/lib/gibber/gibber-xmpp-error.c b/lib/gibber/gibber-xmpp-error.c
index a42df987..1d03238d 100644
--- a/lib/gibber/gibber-xmpp-error.c
+++ b/lib/gibber/gibber-xmpp-error.c
@@ -317,7 +317,7 @@ gibber_xmpp_error_quark (void)
}
GibberXmppError
-gibber_xmpp_error_from_node (GibberXmppNode *error_node)
+gibber_xmpp_error_from_node (WockyNode *error_node)
{
gint i, j;
const gchar *error_code_str;
@@ -331,7 +331,7 @@ gibber_xmpp_error_from_node (GibberXmppNode *error_node)
* numbers; the >= 0 test is OK because i is signed */
for (i = NUM_XMPP_ERRORS - 1; i >= 0; i--)
{
- if (gibber_xmpp_node_get_child_ns (error_node, xmpp_errors[i].name,
+ if (wocky_node_get_child_ns (error_node, xmpp_errors[i].name,
xmpp_errors[i].namespace))
{
return i;
@@ -340,7 +340,7 @@ gibber_xmpp_error_from_node (GibberXmppNode *error_node)
}
/* Ok, do it the legacy way */
- error_code_str = gibber_xmpp_node_get_attribute (error_node, "code");
+ error_code_str = wocky_node_get_attribute (error_node, "code");
if (error_code_str)
{
gint error_code;
@@ -382,13 +382,13 @@ gibber_xmpp_error_to_g_error (GibberXmppError error)
/*
* See RFC 3920: 4.7 Stream Errors, 9.3 Stanza Errors.
*/
-GibberXmppNode *
+WockyNode *
gibber_xmpp_error_to_node (GibberXmppError error,
- GibberXmppNode *parent_node,
+ WockyNode *parent_node,
const gchar *errmsg)
{
const XmppErrorSpec *spec, *extra;
- GibberXmppNode *error_node, *node;
+ WockyNode *error_node, *node;
gchar str[6];
g_return_val_if_fail (error != XMPP_ERROR_UNDEFINED_CONDITION &&
@@ -405,29 +405,29 @@ gibber_xmpp_error_to_node (GibberXmppError error,
spec = &xmpp_errors[error];
}
- error_node = gibber_xmpp_node_add_child (parent_node, "error");
+ error_node = wocky_node_add_child (parent_node, "error");
sprintf (str, "%d", spec->legacy_errors[0]);
- gibber_xmpp_node_set_attribute (error_node, "code", str);
+ wocky_node_set_attribute (error_node, "code", str);
if (spec->type)
{
- gibber_xmpp_node_set_attribute (error_node, "type", spec->type);
+ wocky_node_set_attribute (error_node, "type", spec->type);
}
- node = gibber_xmpp_node_add_child_ns (error_node, spec->name,
+ node = wocky_node_add_child_ns (error_node, spec->name,
GIBBER_XMPP_NS_STANZAS);
if (extra != NULL)
{
- node = gibber_xmpp_node_add_child_ns (error_node, extra->name,
+ node = wocky_node_add_child_ns (error_node, extra->name,
extra->namespace);
}
if (NULL != errmsg)
{
- node = gibber_xmpp_node_add_child (error_node, "text");
- gibber_xmpp_node_set_content (node, errmsg);
+ node = wocky_node_add_child (error_node, "text");
+ wocky_node_set_content (node, errmsg);
}
return error_node;
@@ -452,16 +452,16 @@ gibber_xmpp_error_description (GibberXmppError error)
}
GError *
-gibber_message_get_xmpp_error (GibberXmppStanza *msg)
+gibber_message_get_xmpp_error (WockyStanza *msg)
{
- GibberStanzaSubType sub_type;
+ WockyStanzaSubType sub_type;
g_return_val_if_fail (msg != NULL, NULL);
- gibber_xmpp_stanza_get_type_info (msg, NULL, &sub_type);
+ wocky_stanza_get_type_info (msg, NULL, &sub_type);
- if (sub_type == GIBBER_STANZA_SUB_TYPE_ERROR)
+ if (sub_type == WOCKY_STANZA_SUB_TYPE_ERROR)
{
- GibberXmppNode *error_node = gibber_xmpp_node_get_child (
+ WockyNode *error_node = wocky_node_get_child (
wocky_stanza_get_top_node (msg), "error");
if (error_node != NULL)
diff --git a/lib/gibber/gibber-xmpp-error.h b/lib/gibber/gibber-xmpp-error.h
index 605300e3..8e7a540a 100644
--- a/lib/gibber/gibber-xmpp-error.h
+++ b/lib/gibber/gibber-xmpp-error.h
@@ -22,7 +22,7 @@
#define __GIBBER_XMPP_ERROR_H__
#include <glib.h>
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
typedef enum {
XMPP_ERROR_UNDEFINED_CONDITION = 0, /* 500 */
@@ -76,11 +76,11 @@ typedef enum {
GQuark gibber_xmpp_error_quark (void);
#define GIBBER_XMPP_ERROR (gibber_xmpp_error_quark ())
-GibberXmppError gibber_xmpp_error_from_node (GibberXmppNode *error_node);
-GibberXmppNode *gibber_xmpp_error_to_node (GibberXmppError error,
- GibberXmppNode *parent_node, const gchar *errmsg);
+GibberXmppError gibber_xmpp_error_from_node (WockyNode *error_node);
+WockyNode *gibber_xmpp_error_to_node (GibberXmppError error,
+ WockyNode *parent_node, const gchar *errmsg);
const gchar *gibber_xmpp_error_string (GibberXmppError error);
const gchar *gibber_xmpp_error_description (GibberXmppError error);
-GError *gibber_message_get_xmpp_error (GibberXmppStanza *msg);
+GError *gibber_message_get_xmpp_error (WockyStanza *msg);
#endif /* __GIBBER_XMPP_ERROR_H__ */
diff --git a/lib/gibber/gibber-xmpp-node.c b/lib/gibber/gibber-xmpp-node.c
deleted file mode 100644
index 852e8a30..00000000
--- a/lib/gibber/gibber-xmpp-node.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * gibber-xmpp-node.c - Code for Gibber xmpp nodes
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * 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
- */
-
-#include <glib.h>
-#include <string.h>
-
-#include "gibber-xmpp-node.h"
diff --git a/lib/gibber/gibber-xmpp-node.h b/lib/gibber/gibber-xmpp-node.h
deleted file mode 100644
index 7d2a9f91..00000000
--- a/lib/gibber/gibber-xmpp-node.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * gibber-xmpp-node.h - Header for Gibber xmpp nodes
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * 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
- */
-
-#ifndef __GIBBER_XMPP_NODE_H__
-#define __GIBBER_XMPP_NODE_H__
-
-#include <glib.h>
-#include <wocky/wocky-node.h>
-
-G_BEGIN_DECLS
-
-typedef WockyNode GibberXmppNode;
-
-#define gibber_xmpp_node_each_child wocky_node_each_child
-#define gibber_xmpp_node_get_attribute wocky_node_get_attribute
-#define gibber_xmpp_node_get_attribute_ns wocky_node_get_attribute_ns
-#define gibber_xmpp_node_set_attribute wocky_node_set_attribute
-#define gibber_xmpp_node_set_attribute_ns wocky_node_set_attribute_ns
-#define gibber_xmpp_node_set_attribute_n wocky_node_set_attribute_n
-#define gibber_xmpp_node_set_attribute_n_ns wocky_node_set_attribute_n_ns
-#define gibber_xmpp_node_get_child wocky_node_get_child
-#define gibber_xmpp_node_get_child_ns wocky_node_get_child_ns
-#define gibber_xmpp_node_add_child wocky_node_add_child
-#define gibber_xmpp_node_add_child_ns wocky_node_add_child_ns
-#define gibber_xmpp_node_add_child_with_content wocky_node_add_child_with_content
-#define gibber_xmpp_node_add_child_with_content_ns wocky_node_add_child_with_content_ns
-
-#define gibber_xmpp_node_get_ns wocky_node_get_ns
-#define gibber_xmpp_node_get_language wocky_node_get_language
-#define gibber_xmpp_node_set_language wocky_node_set_language
-#define gibber_xmpp_node_set_language_n wocky_node_set_language_n
-#define gibber_xmpp_node_set_content wocky_node_set_content
-#define gibber_xmpp_node_append_content wocky_node_append_content
-#define gibber_xmpp_node_append_content_n wocky_node_append_content_n
-#define gibber_xmpp_node_to_string wocky_node_to_string
-
-#define gibber_xmpp_node_new_ns wocky_node_new
-#define gibber_xmpp_node_free wocky_node_free
-
-G_END_DECLS
-
-#endif /* #ifndef __GIBBER_XMPP_NODE_H__*/
diff --git a/lib/gibber/gibber-xmpp-reader.c b/lib/gibber/gibber-xmpp-reader.c
index a21dd017..7b265136 100644
--- a/lib/gibber/gibber-xmpp-reader.c
+++ b/lib/gibber/gibber-xmpp-reader.c
@@ -22,7 +22,7 @@
#include "gibber-signals-marshal.h"
-#include "gibber-xmpp-stanza.h"
+#include <wocky/wocky-stanza.h>
#define XMPP_STREAM_NAMESPACE "http://etherx.jabber.org/streams"
@@ -75,7 +75,7 @@ gibber_xmpp_reader_class_init (GibberXmppReaderClass *gibber_xmpp_reader_class)
0,
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GIBBER_TYPE_XMPP_STANZA);
+ G_TYPE_NONE, 1, WOCKY_TYPE_STANZA);
signals[STREAM_OPENED] = g_signal_new ("stream-opened",
G_OBJECT_CLASS_TYPE(gibber_xmpp_reader_class),
diff --git a/lib/gibber/gibber-xmpp-stanza.c b/lib/gibber/gibber-xmpp-stanza.c
deleted file mode 100644
index 0cbf02aa..00000000
--- a/lib/gibber/gibber-xmpp-stanza.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * gibber-xmpp-stanza.c - Source for GibberXmppStanza
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * 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
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gibber-xmpp-stanza.h"
diff --git a/lib/gibber/gibber-xmpp-stanza.h b/lib/gibber/gibber-xmpp-stanza.h
deleted file mode 100644
index 65cb9cd6..00000000
--- a/lib/gibber/gibber-xmpp-stanza.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * gibber-xmpp-stanza.h - Header for GibberXmppStanza
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * 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
- */
-
-#ifndef __GIBBER_XMPP_STANZA_H__
-#define __GIBBER_XMPP_STANZA_H__
-
-#include <glib-object.h>
-#include "gibber-xmpp-node.h"
-#include <wocky/wocky-stanza.h>
-
-G_BEGIN_DECLS
-
-typedef WockyStanza GibberXmppStanza;
-typedef WockyStanzaClass GibberXmppStanzaClass;
-
-#define GIBBER_TYPE_XMPP_STANZA WOCKY_TYPE_STANZA
-#define GIBBER_XMPP_STANZA(obj) (WOCKY_STANZA (obj))
-#define GIBBER_XMPP_STANZA_CLASS(klass) (WOCKY_STANZA_CLASS (klass))
-#define GIBBER_IS_XMPP_STANZA(obj) (WOCKY_IS_STANZA (obj))
-#define GIBBER_IS_XMPP_STANZA_CLASS(klass) (WOCKY_IS_STANZA_CLASS (klass))
-#define GIBBER_XMPP_STANZA_GET_CLASS(obj) (WOCKY_STANZA_GET_CLASS (obj))
-
-#define GIBBER_STANZA_TYPE_NONE WOCKY_STANZA_TYPE_NONE
-#define GIBBER_STANZA_TYPE_MESSAGE WOCKY_STANZA_TYPE_MESSAGE
-#define GIBBER_STANZA_TYPE_PRESENCE WOCKY_STANZA_TYPE_PRESENCE
-#define GIBBER_STANZA_TYPE_IQ WOCKY_STANZA_TYPE_IQ
-#define GIBBER_STANZA_TYPE_STREAM WOCKY_STANZA_TYPE_STREAM
-#define GIBBER_STANZA_TYPE_STREAM_FEATURES WOCKY_STANZA_TYPE_STREAM_FEATURES
-#define GIBBER_STANZA_TYPE_AUTH WOCKY_STANZA_TYPE_AUTH
-#define GIBBER_STANZA_TYPE_CHALLENGE WOCKY_STANZA_TYPE_CHALLENGE
-#define GIBBER_STANZA_TYPE_RESPONSE WOCKY_STANZA_TYPE_RESPONSE
-#define GIBBER_STANZA_TYPE_SUCCESS WOCKY_STANZA_TYPE_SUCCESS
-#define GIBBER_STANZA_TYPE_FAILURE WOCKY_STANZA_TYPE_FAILURE
-#define GIBBER_STANZA_TYPE_STREAM_ERROR WOCKY_STANZA_TYPE_STREAM_ERROR
-#define GIBBER_STANZA_TYPE_UNKNOWN WOCKY_STANZA_TYPE_UNKNOWN
-#define NUM_GIBBER_STANZA_TYPE NUM_WOCKY_STANZA_TYPE
-typedef WockyStanzaType GibberStanzaType;
-
-#define GIBBER_STANZA_SUB_TYPE_NONE WOCKY_STANZA_SUB_TYPE_NONE
-#define GIBBER_STANZA_SUB_TYPE_AVAILABLE WOCKY_STANZA_SUB_TYPE_AVAILABLE
-#define GIBBER_STANZA_SUB_TYPE_NORMAL WOCKY_STANZA_SUB_TYPE_NORMAL
-#define GIBBER_STANZA_SUB_TYPE_CHAT WOCKY_STANZA_SUB_TYPE_CHAT
-#define GIBBER_STANZA_SUB_TYPE_GROUPCHAT WOCKY_STANZA_SUB_TYPE_GROUPCHAT
-#define GIBBER_STANZA_SUB_TYPE_HEADLINE WOCKY_STANZA_SUB_TYPE_HEADLINE
-#define GIBBER_STANZA_SUB_TYPE_UNAVAILABLE WOCKY_STANZA_SUB_TYPE_UNAVAILABLE
-#define GIBBER_STANZA_SUB_TYPE_PROBE WOCKY_STANZA_SUB_TYPE_PROBE
-#define GIBBER_STANZA_SUB_TYPE_SUBSCRIBE WOCKY_STANZA_SUB_TYPE_SUBSCRIBE
-#define GIBBER_STANZA_SUB_TYPE_UNSUBSCRIBE WOCKY_STANZA_SUB_TYPE_UNSUBSCRIBE
-#define GIBBER_STANZA_SUB_TYPE_SUBSCRIBED WOCKY_STANZA_SUB_TYPE_SUBSCRIBED
-#define GIBBER_STANZA_SUB_TYPE_UNSUBSCRIBED WOCKY_STANZA_SUB_TYPE_UNSUBSCRIBED
-#define GIBBER_STANZA_SUB_TYPE_GET WOCKY_STANZA_SUB_TYPE_GET
-#define GIBBER_STANZA_SUB_TYPE_SET WOCKY_STANZA_SUB_TYPE_SET
-#define GIBBER_STANZA_SUB_TYPE_RESULT WOCKY_STANZA_SUB_TYPE_RESULT
-#define GIBBER_STANZA_SUB_TYPE_ERROR WOCKY_STANZA_SUB_TYPE_ERROR
-#define GIBBER_STANZA_SUB_TYPE_UNKNOWN WOCKY_STANZA_SUB_TYPE_UNKNOWN
-#define NUM_GIBBER_STANZA_SUB_TYPE NUM_WOCKY_STANZA_SUB_TYPE
-typedef WockyStanzaSubType GibberStanzaSubType;
-
-#define GIBBER_NODE WOCKY_NODE_START
-#define GIBBER_NODE_TEXT WOCKY_NODE_TEXT
-#define GIBBER_NODE_END WOCKY_NODE_END
-#define GIBBER_NODE_ATTRIBUTE WOCKY_NODE_ATTRIBUTE
-#define GIBBER_NODE_XMLNS WOCKY_NODE_XMLNS
-#define GIBBER_NODE_ASSIGN_TO WOCKY_NODE_ASSIGN_TO
-#define GIBBER_STANZA_END NULL
-
-#define gibber_xmpp_stanza_new_ns wocky_stanza_new
-#define gibber_xmpp_stanza_build wocky_stanza_build
-#define gibber_xmpp_stanza_get_type_info wocky_stanza_get_type_info
-
-G_END_DECLS
-
-#endif /* #ifndef __GIBBER_XMPP_STANZA_H__*/
diff --git a/lib/gibber/gibber-xmpp-writer.h b/lib/gibber/gibber-xmpp-writer.h
index ac6d529b..5a0247b4 100644
--- a/lib/gibber/gibber-xmpp-writer.h
+++ b/lib/gibber/gibber-xmpp-writer.h
@@ -55,7 +55,7 @@ gibber_xmpp_writer_stream_open (GibberXmppWriter *writer,
static inline gboolean
gibber_xmpp_writer_write_stanza (GibberXmppWriter *writer,
- GibberXmppStanza *stanza, const guint8 **data, gsize *length,
+ WockyStanza *stanza, const guint8 **data, gsize *length,
GError **error)
{
/* can't fail */
diff --git a/lib/gibber/tests/Makefile.am b/lib/gibber/tests/Makefile.am
index 97d7a3e3..2c241565 100644
--- a/lib/gibber/tests/Makefile.am
+++ b/lib/gibber/tests/Makefile.am
@@ -4,6 +4,31 @@ include $(top_srcdir)/rules/check.mak
SUPPRESSIONS=valgrind.supp dlopen.supp
+AM_CFLAGS = $(ERROR_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ @WOCKY_CFLAGS@ \
+ @DBUS_CFLAGS@ \
+ -I $(top_srcdir) -I $(top_builddir) \
+ -I $(top_srcdir)/lib -I $(top_builddir)/lib
+
+AM_LDFLAGS = @GLIB_LIBS@ \
+ $(top_builddir)/lib/gibber/libgibber.la
+
+clean-local:
+ -rm -rf outputs
+
+SUBDIRS = inputs
+
+EXTRA_DIST = \
+ test-transport.h \
+ test-transport.c
+
+$(check_SCRIPTS): always-run
+ chmod +x $(srcdir)/$@
+
+.PHONY: always-run
+
+# ------------------------------------------------------------------------------
+# Test programs
+
# Teach it how to make libgibber.la
$(top_builddir)/lib/gibber/libgibber.la:
${MAKE} -C $(top_builddir)/lib/gibber libgibber.la
@@ -13,13 +38,14 @@ $(top_builddir)/lib/gibber/libgibber.la:
TESTS = \
run-xmpp-connection-test.sh
-check_PROGRAMS = \
+noinst_PROGRAMS = \
test-xmpp-connection \
test-r-multicast-transport-io
check_SCRIPTS = run-xmpp-connection-test.sh
-EXTRA_DIST = simplemeshtest.py mesh.py $(check_SCRIPTS)
+EXTRA_DIST += \
+ simplemeshtest.py mesh.py $(check_SCRIPTS)
test_xmpp_connection_SOURCES = \
test-xmpp-connection.c \
@@ -27,7 +53,6 @@ test_xmpp_connection_SOURCES = \
test-transport.h
test_xmpp_connection_LDADD = \
- $(top_builddir)/lib/gibber/libgibber.la \
$(AM_LDFLAGS)
test_xmpp_connection_CFLAGS = \
@@ -45,66 +70,32 @@ test_r_multicast_transport_io_LDADD = \
test_r_multicast_transport_io_CFLAGS = \
$(AM_CFLAGS)
+# ------------------------------------------------------------------------------
+# Checks
-if HAVE_CHECK
-check_PROGRAMS += check-main
-TESTS += check-main
-check_main_SOURCES = \
- check-main.c \
- check-helpers.c \
- check-helpers.h \
- check-gibber.h \
- check-gibber-xmpp-node.c \
- check-gibber-xmpp-reader.c \
- check-gibber-r-multicast-causal-transport.c \
- test-transport.c \
- test-transport.h \
- check-gibber-xmpp-connection.c \
- check-gibber-r-multicast-packet.c \
- check-gibber-r-multicast-sender.c \
- check-gibber-xmpp-stanza.c \
- check-gibber-iq-helper.c \
- check-gibber-listener.c \
- check-gibber-xmpp-connection-listener.c \
- check-gibber-xmpp-error.c \
- check-gibber-unix-transport.c
-
-check_main_LDADD = \
- @CHECK_LIBS@ \
- $(top_builddir)/lib/gibber/libgibber.la \
- $(AM_LDFLAGS)
-
-check_main_CFLAGS = \
- @CHECK_CFLAGS@ \
- $(AM_CFLAGS)
-
-endif
-
-AM_CFLAGS = $(ERROR_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ @WOCKY_CFLAGS@ \
- @DBUS_CFLAGS@ \
- -I $(top_srcdir) -I $(top_builddir) \
- -I $(top_srcdir)/lib -I $(top_builddir)/lib
-
-AM_LDFLAGS = @GLIB_LIBS@
+check_PROGRAMS = \
+ check-gibber-xmpp-reader \
+ check-gibber-r-multicast-causal-transport \
+ check-gibber-xmpp-connection \
+ check-gibber-r-multicast-packet \
+ check-gibber-r-multicast-sender \
+ check-gibber-iq-helper \
+ check-gibber-listener \
+ check-gibber-xmpp-connection-listener \
+ check-gibber-xmpp-error \
+ check-gibber-unix-transport
+
+test: ${TEST_PROGS}
+ gtester -k --verbose $(check_PROGRAMS)
+
+# ------------------------------------------------------------------------------
+# Code Style
# Coding style checks
check_c_sources = \
$(test_xmpp_connection_SOURCES) \
$(test_r_multicast_transport_io_SOURCES)
-if HAVE_CHECK
- check_c_sources += $(check_main_SOURCES)
-endif
-
include $(top_srcdir)/tools/check-coding-style.mk
-check-local: check-coding-style
-
-clean-local:
- -rm -rf outputs
-
-SUBDIRS = inputs
-$(check_SCRIPTS): always-run
- chmod +x $(srcdir)/$@
-
-.PHONY: always-run
+check-local: check-coding-style test
diff --git a/lib/gibber/tests/check-gibber-iq-helper.c b/lib/gibber/tests/check-gibber-iq-helper.c
index 345f1d28..20bbdc8d 100644
--- a/lib/gibber/tests/check-gibber-iq-helper.c
+++ b/lib/gibber/tests/check-gibber-iq-helper.c
@@ -24,18 +24,14 @@
#include <string.h>
#include <dbus/dbus-glib.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-iq-helper.h>
#include <gibber/gibber-xmpp-error.h>
#include <gibber/gibber-namespaces.h>
-#include <check.h>
-#include "check-helpers.h"
-#include "check-gibber.h"
-
#include "test-transport.h"
-gboolean received_reply = FALSE;
+static gboolean received_reply = FALSE;
static gboolean
send_hook (GibberTransport *transport,
@@ -63,20 +59,20 @@ create_xmpp_connection (void)
return xmpp_connection;
}
-START_TEST (test_iq_helper_new)
+static void
+test_iq_helper_new (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- fail_unless (iq_helper != NULL);
+ g_assert (iq_helper != NULL);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
static void
reply_func (GibberIqHelper *helper,
- GibberXmppStanza *sent_stanza,
- GibberXmppStanza *reply_stanza,
+ WockyStanza *sent_stanza,
+ WockyStanza *reply_stanza,
GObject *object,
gpointer user_data)
{
@@ -86,8 +82,8 @@ reply_func (GibberIqHelper *helper,
static void
send_stanza_and_reply (GibberXmppConnection *xmpp_connection,
GibberIqHelper *iq_helper,
- GibberXmppStanza *stanza,
- GibberXmppStanza *reply)
+ WockyStanza *stanza,
+ WockyStanza *reply)
{
gboolean result;
@@ -95,13 +91,13 @@ send_stanza_and_reply (GibberXmppConnection *xmpp_connection,
{
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
NULL, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
}
if (reply != NULL)
{
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
}
while (g_main_context_iteration (NULL, FALSE))
@@ -109,238 +105,236 @@ send_stanza_and_reply (GibberXmppConnection *xmpp_connection,
}
-START_TEST (test_send_with_reply)
+static void
+test_send_with_reply (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_NODE_ATTRIBUTE, "id", "69",
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", "69",
+ NULL);
/* Reply of the stanza */
- reply = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_RESULT,
+ reply = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_RESULT,
"to", "from",
- GIBBER_NODE_ATTRIBUTE, "id", "69",
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", "69",
+ NULL);
send_stanza_and_reply (xmpp_connection, iq_helper, stanza, reply);
- fail_unless (received_reply);
+ g_assert (received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_send_without_reply)
+static void
+test_send_without_reply (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_NODE_ATTRIBUTE, "id", "69",
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", "69",
+ NULL);
send_stanza_and_reply (xmpp_connection, iq_helper, stanza, NULL);
- fail_unless (!received_reply);
+ g_assert (!received_reply);
g_object_unref (stanza);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_send_with_bad_reply_type)
+static void
+test_send_with_bad_reply_type (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_NODE_ATTRIBUTE, "id", "69",
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", "69",
+ NULL);
/* Reply can't be of sub type "get" */
- reply = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_GET,
+ reply = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_GET,
"to", "from",
- GIBBER_NODE_ATTRIBUTE, "id", "69",
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", "69",
+ NULL);
send_stanza_and_reply (xmpp_connection, iq_helper, stanza, reply);
- fail_unless (!received_reply);
+ g_assert (!received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_send_without_id)
+static void
+test_send_without_id (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
gboolean result;
const gchar *id;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
NULL, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
/* gibber_iq_helper_send_with_reply generated an id */
- id = gibber_xmpp_node_get_attribute (wocky_stanza_get_top_node (stanza),
+ id = wocky_node_get_attribute (wocky_stanza_get_top_node (stanza),
"id");
- reply = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_RESULT,
+ reply = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_RESULT,
"to", "from",
- GIBBER_NODE_ATTRIBUTE, "id", id,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", id,
+ NULL);
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
while (g_main_context_iteration (NULL, FALSE))
;
- fail_unless (received_reply);
+ g_assert (received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_new_result_reply)
+static void
+test_new_result_reply (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
gboolean result;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
NULL, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
reply = gibber_iq_helper_new_result_reply (stanza);
- fail_unless (reply != NULL);
- fail_unless (strcmp (wocky_stanza_get_top_node (reply)->name, "iq") == 0);
- fail_unless (strcmp (
- gibber_xmpp_node_get_attribute (wocky_stanza_get_top_node (reply),
- "type"),
- "result") == 0);
+ g_assert (reply != NULL);
+ g_assert_cmpstr (wocky_stanza_get_top_node (reply)->name, ==, "iq");
+ g_assert_cmpstr (
+ wocky_node_get_attribute (wocky_stanza_get_top_node (reply), "type"),
+ ==, "result");
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
while (g_main_context_iteration (NULL, FALSE))
;
- fail_unless (received_reply);
+ g_assert (received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_new_error_reply)
+static void
+test_new_error_reply (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
- GibberXmppNode *error_node, *node;
+ WockyStanza *stanza, *reply;
+ WockyNode *error_node, *node;
gboolean result;
received_reply = FALSE;
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
NULL, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
reply = gibber_iq_helper_new_error_reply (stanza,
XMPP_ERROR_BAD_REQUEST, "test");
- fail_unless (reply != NULL);
- fail_unless (strcmp (wocky_stanza_get_top_node (reply)->name, "iq") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_attribute (
- wocky_stanza_get_top_node (reply), "type"),
- "error") == 0);
+ g_assert (reply != NULL);
+ g_assert_cmpstr (wocky_stanza_get_top_node (reply)->name, ==, "iq");
+ g_assert_cmpstr (
+ wocky_node_get_attribute (wocky_stanza_get_top_node (reply), "type"),
+ ==, "error");
- error_node = gibber_xmpp_node_get_child (wocky_stanza_get_top_node (reply),
+ error_node = wocky_node_get_child (wocky_stanza_get_top_node (reply),
"error");
- fail_if (error_node == NULL);
- fail_if (strcmp (gibber_xmpp_node_get_attribute (error_node, "code"),
- "400") != 0);
- fail_if (strcmp (gibber_xmpp_node_get_attribute (error_node, "type"),
- "modify") != 0);
+ g_assert (error_node != NULL);
+ g_assert_cmpstr (wocky_node_get_attribute (error_node, "code"), ==, "400");
+ g_assert_cmpstr (wocky_node_get_attribute (error_node, "type"), ==, "modify");
- node = gibber_xmpp_node_get_child_ns (error_node, "bad-request",
+ node = wocky_node_get_child_ns (error_node, "bad-request",
GIBBER_XMPP_NS_STANZAS);
- fail_if (node == NULL);
+ g_assert (node != NULL);
- node = gibber_xmpp_node_get_child (error_node, "text");
- fail_if (node == NULL);
- fail_if (strcmp (node->content, "test") != 0);
+ node = wocky_node_get_child (error_node, "text");
+ g_assert (node != NULL);
+ g_assert_cmpstr (node->content, ==, "test");
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
while (g_main_context_iteration (NULL, FALSE))
;
- fail_unless (received_reply);
+ g_assert (received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_send_with_object_living)
+static void
+test_send_with_object_living (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
gboolean result;
GObject *object;
@@ -349,24 +343,24 @@ START_TEST (test_send_with_object_living)
/* We don't care about the TestTransport, we just need a GObject */
object = g_object_new (TEST_TYPE_TRANSPORT, NULL);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
object, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
reply = gibber_iq_helper_new_result_reply (stanza);
- fail_unless (reply != NULL);
+ g_assert (reply != NULL);
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
while (g_main_context_iteration (NULL, FALSE))
;
- fail_unless (received_reply);
+ g_assert (received_reply);
g_object_unref (stanza);
g_object_unref (reply);
@@ -374,13 +368,13 @@ START_TEST (test_send_with_object_living)
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-START_TEST (test_send_with_object_destroyed)
+static void
+test_send_with_object_destroyed (void)
{
GibberXmppConnection *xmpp_connection = create_xmpp_connection ();
GibberIqHelper *iq_helper = gibber_iq_helper_new (xmpp_connection);
- GibberXmppStanza *stanza, *reply;
+ WockyStanza *stanza, *reply;
gboolean result;
GObject *object;
@@ -389,49 +383,57 @@ START_TEST (test_send_with_object_destroyed)
/* We don't care about the TestTransport, we just need a GObject */
object = g_object_new (TEST_TYPE_TRANSPORT, NULL);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
result = gibber_iq_helper_send_with_reply (iq_helper, stanza, reply_func,
object, NULL, NULL);
- fail_unless (result);
+ g_assert (result);
g_object_unref (object);
reply = gibber_iq_helper_new_result_reply (stanza);
- fail_unless (reply != NULL);
+ g_assert (reply != NULL);
result = gibber_xmpp_connection_send (xmpp_connection, reply, NULL);
- fail_unless (result);
+ g_assert (result);
while (g_main_context_iteration (NULL, FALSE))
;
/* Object was destroyed before we send the reply so we don't receive
* the reply */
- fail_unless (!received_reply);
+ g_assert (!received_reply);
g_object_unref (stanza);
g_object_unref (reply);
g_object_unref (xmpp_connection);
g_object_unref (iq_helper);
}
-END_TEST
-TCase *
-make_gibber_iq_helper_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("IQ helper");
- tcase_add_test (tc, test_iq_helper_new);
- tcase_add_test (tc, test_send_with_reply);
- tcase_add_test (tc, test_send_without_reply);
- tcase_add_test (tc, test_send_with_bad_reply_type);
- tcase_add_test (tc, test_send_without_id);
- tcase_add_test (tc, test_new_result_reply);
- tcase_add_test (tc, test_new_error_reply);
- tcase_add_test (tc, test_send_with_object_living);
- tcase_add_test (tc, test_send_with_object_destroyed);
-
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/iq-helper/new", test_iq_helper_new);
+ g_test_add_func ("/gibber/iq-helper/send-with-reply", test_send_with_reply);
+ g_test_add_func ("/gibber/iq-helper/send-without-reply",
+ test_send_without_reply);
+ g_test_add_func ("/gibber/iq-helper/send-with-bad-reply-type",
+ test_send_with_bad_reply_type);
+ g_test_add_func ("/gibber/iq-helper/send-without-id", test_send_without_id);
+ g_test_add_func ("/gibber/iq-helper/new-result-reply", test_new_result_reply);
+ g_test_add_func ("/gibber/iq-helper/new-error-reply", test_new_error_reply);
+ g_test_add_func ("/gibber/iq-helper/send-with-object-living",
+ test_send_with_object_living);
+ g_test_add_func ("/gibber/iq-helper/send-with-object-destroyed",
+ test_send_with_object_destroyed);
+
+ return g_test_run ();
}
+
+#include "test-transport.c"
diff --git a/lib/gibber/tests/check-gibber-listener.c b/lib/gibber/tests/check-gibber-listener.c
index 4a1bce06..15550b65 100644
--- a/lib/gibber/tests/check-gibber-listener.c
+++ b/lib/gibber/tests/check-gibber-listener.c
@@ -34,9 +34,6 @@
#include <gibber/gibber-unix-transport.h>
#include <gibber/gibber-listener.h>
-#include <check.h>
-#include "check-gibber.h"
-
gboolean got_connection;
gboolean signalled;
@@ -77,7 +74,8 @@ connect_to_port (int port, GMainLoop *loop)
return GIBBER_TRANSPORT (transport);
}
-START_TEST (test_unix_listen)
+static void
+test_unix_listen (void)
{
GibberListener *listener_unix;
GibberUnixTransport *unix_transport;
@@ -87,34 +85,35 @@ START_TEST (test_unix_listen)
gchar *path = "/tmp/check-gibber-listener-socket";
ret = unlink (path);
- fail_if (ret == -1 && errno != ENOENT);
+ g_assert (!(ret == -1 && errno != ENOENT));
mainloop = g_main_loop_new (NULL, FALSE);
listener_unix = gibber_listener_new ();
- fail_if (listener_unix == NULL);
+ g_assert (listener_unix != NULL);
g_signal_connect (listener_unix, "new-connection",
G_CALLBACK (new_connection_cb), mainloop);
ret = gibber_listener_listen_socket (listener_unix, path, FALSE, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
unix_transport = gibber_unix_transport_new ();
ret = gibber_unix_transport_connect (unix_transport, path, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
if (!signalled)
g_main_loop_run (mainloop);
- fail_if (!got_connection, "Failed to connect");
+ g_assert (got_connection && "Failed to connect");
g_object_unref (listener_unix);
g_object_unref (unix_transport);
g_main_loop_unref (mainloop);
-} END_TEST
+}
-START_TEST (test_tcp_listen)
+static void
+test_tcp_listen (void)
{
GibberListener *listener;
GibberListener *listener_without_port;
@@ -128,13 +127,13 @@ START_TEST (test_tcp_listen)
/* tcp socket tests without a specified port */
listener_without_port = gibber_listener_new ();
- fail_if (listener_without_port == NULL);
+ g_assert (listener_without_port != NULL);
g_signal_connect (listener_without_port, "new-connection",
G_CALLBACK (new_connection_cb), mainloop);
ret = gibber_listener_listen_tcp (listener_without_port, 0, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
port = gibber_listener_get_port (listener_without_port);
signalled = FALSE;
@@ -142,14 +141,14 @@ START_TEST (test_tcp_listen)
if (!signalled)
g_main_loop_run (mainloop);
- fail_if (!got_connection, "Failed to connect");
+ g_assert (got_connection);
g_object_unref (listener_without_port);
g_object_unref (transport);
/* tcp socket tests with a specified port */
listener = gibber_listener_new ();
- fail_if (listener == NULL);
+ g_assert (listener != NULL);
g_signal_connect (listener, "new-connection", G_CALLBACK (new_connection_cb),
mainloop);
@@ -159,20 +158,20 @@ START_TEST (test_tcp_listen)
if (gibber_listener_listen_tcp (listener, port, &error))
break;
- fail_if (!g_error_matches (error, GIBBER_LISTENER_ERROR,
- GIBBER_LISTENER_ERROR_ADDRESS_IN_USE));
+ g_assert_error (error, GIBBER_LISTENER_ERROR,
+ GIBBER_LISTENER_ERROR_ADDRESS_IN_USE);
g_error_free (error);
error = NULL;
}
- fail_if (port >= 5400);
- fail_if (port != gibber_listener_get_port (listener));
+ g_assert (port < 5400);
+ g_assert (port == gibber_listener_get_port (listener));
/* try a second listener on the same port */
listener2 = gibber_listener_new ();
- fail_if (listener2 == NULL);
- fail_if (gibber_listener_listen_tcp (listener2, port, &error));
- fail_if (!g_error_matches (error, GIBBER_LISTENER_ERROR,
- GIBBER_LISTENER_ERROR_ADDRESS_IN_USE));
+ g_assert (listener2 != NULL);
+ g_assert (!gibber_listener_listen_tcp (listener2, port, &error));
+ g_assert_error (error, GIBBER_LISTENER_ERROR,
+ GIBBER_LISTENER_ERROR_ADDRESS_IN_USE);
g_object_unref (listener2);
g_error_free (error);
error = NULL;
@@ -182,7 +181,7 @@ START_TEST (test_tcp_listen)
if (!signalled)
g_main_loop_run (mainloop);
- fail_if (!got_connection, "Failed to connect");
+ g_assert (got_connection);
g_object_unref (listener);
g_object_unref (transport);
@@ -194,18 +193,23 @@ START_TEST (test_tcp_listen)
if (!signalled)
g_main_loop_run (mainloop);
- fail_if (got_connection, "Connected while listening should have stopped");
+ /* Connected while listening should have stopped */
+ g_assert (!got_connection);
g_object_unref (transport);
g_main_loop_unref (mainloop);
-} END_TEST
+}
-TCase *
-make_gibber_listener_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("GibberListener");
- tcase_add_test (tc, test_tcp_listen);
- tcase_add_test (tc, test_unix_listen);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/listener/tcp-listen", test_tcp_listen);
+ g_test_add_func ("/gibber/listener/unix-listen", test_unix_listen);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-r-multicast-causal-transport.c b/lib/gibber/tests/check-gibber-r-multicast-causal-transport.c
index 8dc92782..0d9f7427 100644
--- a/lib/gibber/tests/check-gibber-r-multicast-causal-transport.c
+++ b/lib/gibber/tests/check-gibber-r-multicast-causal-transport.c
@@ -24,9 +24,6 @@
#include <gibber/gibber-r-multicast-causal-transport.h>
#include <gibber/gibber-r-multicast-packet.h>
#include "test-transport.h"
-#include "check-gibber.h"
-
-#include <check.h>
/* Numer of polls we expect the id generation to do */
#define ID_GENERATION_EXPECTED_POLLS 3
@@ -45,7 +42,7 @@ create_rmulticast_transport (TestTransport **testtransport,
GibberRMulticastCausalTransport *rmctransport;
t = test_transport_new (test_send_hook, user_data);
- fail_unless (t != NULL);
+ g_assert (t != NULL);
GIBBER_TRANSPORT (t)->max_packet_size = 150;
rmctransport = gibber_r_multicast_causal_transport_new
@@ -66,9 +63,9 @@ static void
rmulticast_connect (GibberRMulticastCausalTransport *transport)
{
- fail_unless (transport != NULL);
+ g_assert (transport != NULL);
- fail_unless (gibber_r_multicast_causal_transport_connect (transport,
+ g_assert (gibber_r_multicast_causal_transport_connect (transport,
FALSE, NULL));
}
@@ -99,7 +96,7 @@ depends_send_hook (GibberTransport *transport,
guint i, n;
packet = gibber_r_multicast_packet_parse (data, length, NULL);
- fail_unless (packet != NULL);
+ g_assert (packet != NULL);
if (packet->type == PACKET_TYPE_WHOIS_REQUEST)
{
@@ -121,7 +118,7 @@ depends_send_hook (GibberTransport *transport,
goto out;
}
- fail_unless (senders[i].name != NULL);
+ g_assert (senders[i].name != NULL);
reply = gibber_r_multicast_packet_new (PACKET_TYPE_WHOIS_REPLY,
senders[i].sender_id, transport->max_packet_size);
@@ -139,7 +136,7 @@ depends_send_hook (GibberTransport *transport,
goto out;
}
- fail_unless (packet->depends->len > 0);
+ g_assert (packet->depends->len > 0);
for (n = 0; n < packet->depends->len; n++)
{
@@ -150,18 +147,18 @@ depends_send_hook (GibberTransport *transport,
GibberRMulticastPacketSenderInfo *, n);
if (senders[i].sender_id == sender_info->sender_id)
{
- fail_unless (senders[i].seen == FALSE);
- fail_unless (senders[i].packet_id + 1 == sender_info->packet_id);
+ g_assert (senders[i].seen == FALSE);
+ g_assert (senders[i].packet_id + 1 == sender_info->packet_id);
senders[i].seen = TRUE;
break;
}
}
- fail_unless (senders[i].name != NULL);
+ g_assert (senders[i].name != NULL);
}
for (i = 0; senders[i].name != NULL ; i++)
{
- fail_unless (senders[i].seen, "Not all senders in depends");
+ g_assert (senders[i].seen && "Not all senders in depends");
}
g_main_loop_quit (loop);
@@ -177,7 +174,7 @@ depends_send_test_data (gpointer data)
GIBBER_R_MULTICAST_CAUSAL_TRANSPORT (data);
guint8 testdata[] = { 1, 2, 3 };
- fail_unless (gibber_transport_send (GIBBER_TRANSPORT (t), testdata,
+ g_assert (gibber_transport_send (GIBBER_TRANSPORT (t), testdata,
3, NULL));
return FALSE;
@@ -221,7 +218,8 @@ depends_connected (GibberTransport *transport,
g_timeout_add (300, depends_send_test_data, rmctransport);
}
-START_TEST (test_depends)
+static void
+test_depends (void)
{
GibberRMulticastCausalTransport *rmctransport;
TestTransport *testtransport;
@@ -242,12 +240,11 @@ START_TEST (test_depends)
for (i = 0 ; senders[i].name != NULL; i++)
{
- fail_unless (senders[i].seen);
+ g_assert (senders[i].seen);
}
g_object_unref (rmctransport);
}
-END_TEST
/* test fragmentation testing */
@@ -266,7 +263,7 @@ fragmentation_send_hook (GibberTransport *transport,
guint8 *payload;
packet = gibber_r_multicast_packet_parse (data, length, NULL);
- fail_unless (packet != NULL);
+ g_assert (packet != NULL);
if (packet->type != PACKET_TYPE_DATA)
{
@@ -276,24 +273,24 @@ fragmentation_send_hook (GibberTransport *transport,
payload = gibber_r_multicast_packet_get_payload (packet, &size);
if (bytes == 0)
- fail_unless
+ g_assert
(packet->data.data.flags == GIBBER_R_MULTICAST_DATA_PACKET_START);
else if (bytes + size < TEST_DATA_SIZE)
- fail_unless (packet->data.data.flags == 0);
+ g_assert (packet->data.data.flags == 0);
bytes += size;
- fail_unless (bytes <= TEST_DATA_SIZE);
+ g_assert (bytes <= TEST_DATA_SIZE);
/* check our bytes */
for (i = 0; i < size; i++)
{
- fail_unless (payload[i] == next_byte);
+ g_assert (payload[i] == next_byte);
next_byte++;
}
if (bytes == TEST_DATA_SIZE)
{
- fail_unless
+ g_assert
(packet->data.data.flags == GIBBER_R_MULTICAST_DATA_PACKET_END);
g_object_unref (packet);
g_main_loop_quit (loop);
@@ -319,11 +316,12 @@ fragmentation_connected (GibberTransport *transport,
testdata[i] = (guint8) (i & 0xff);
}
- fail_unless (gibber_transport_send (GIBBER_TRANSPORT (rmctransport),
+ g_assert (gibber_transport_send (GIBBER_TRANSPORT (rmctransport),
(guint8 *) testdata, TEST_DATA_SIZE, NULL));
}
-START_TEST (test_fragmentation)
+static void
+test_fragmentation (void)
{
GibberRMulticastCausalTransport *rmctransport;
@@ -342,7 +340,6 @@ START_TEST (test_fragmentation)
g_object_unref (rmctransport);
}
-END_TEST
/* test unique id */
@@ -358,7 +355,7 @@ unique_id_send_hook (GibberTransport *transport,
packet = gibber_r_multicast_packet_parse (data, length, NULL);
- fail_unless (packet != NULL);
+ g_assert (packet != NULL);
if (*test_id == 0)
{
@@ -368,9 +365,9 @@ unique_id_send_hook (GibberTransport *transport,
gsize psize;
/* First packet must be a whois request to see if the id is taken */
- fail_unless (packet->type == PACKET_TYPE_WHOIS_REQUEST);
+ g_assert (packet->type == PACKET_TYPE_WHOIS_REQUEST);
/* Sender must be 0 as it couldn't choose a id just yet */
- fail_unless (packet->sender == 0);
+ g_assert (packet->sender == 0);
*test_id = packet->data.whois_request.sender_id;
@@ -385,11 +382,11 @@ unique_id_send_hook (GibberTransport *transport,
}
else
{
- fail_unless (*test_id != packet->sender);
+ g_assert (*test_id != packet->sender);
switch (packet->type)
{
case PACKET_TYPE_WHOIS_REQUEST:
- fail_unless (*test_id != packet->data.whois_request.sender_id);
+ g_assert (*test_id != packet->data.whois_request.sender_id);
break;
case PACKET_TYPE_WHOIS_REPLY:
/* transport sends a unsolicited whois reply after choosing a
@@ -397,7 +394,9 @@ unique_id_send_hook (GibberTransport *transport,
g_main_loop_quit (loop);
break;
default:
- fail ("Unexpected packet type: %x", packet->type);
+ g_warning ("Unexpected packet type: %x", packet->type);
+ g_assert_not_reached ();
+ break;
}
}
@@ -405,7 +404,8 @@ unique_id_send_hook (GibberTransport *transport,
return TRUE;
}
-START_TEST (test_unique_id)
+static void
+test_unique_id (void)
{
/* Test if the multicast transport correctly handles the case that it gets a
* WHOIS_REPLY on one of it's WHOIS_REQUESTS when it's determining a unique
@@ -426,7 +426,6 @@ START_TEST (test_unique_id)
g_object_unref (rmctransport);
}
-END_TEST
/* test id generation conflict */
typedef struct {
@@ -446,14 +445,14 @@ id_generation_conflict_send_hook (GibberTransport *transport,
unique_id_conflict_test_t *test = (unique_id_conflict_test_t *) user_data;
packet = gibber_r_multicast_packet_parse (data, length, NULL);
- fail_unless (packet != NULL);
+ g_assert (packet != NULL);
if (test->id == 0)
{
/* First packet must be a whois request to see if the id is taken */
- fail_unless (packet->type == PACKET_TYPE_WHOIS_REQUEST);
+ g_assert (packet->type == PACKET_TYPE_WHOIS_REQUEST);
/* Sender must be 0 as it couldn't choose a id just yet */
- fail_unless (packet->sender == 0);
+ g_assert (packet->sender == 0);
test->id = packet->data.whois_request.sender_id;
}
@@ -465,7 +464,7 @@ id_generation_conflict_send_hook (GibberTransport *transport,
if (test->count < test->wait)
{
- fail_unless (test->id == packet->data.whois_request.sender_id);
+ g_assert (test->id == packet->data.whois_request.sender_id);
}
else if (test->count == test->wait)
{
@@ -474,7 +473,7 @@ id_generation_conflict_send_hook (GibberTransport *transport,
guint8 *pdata;
gsize psize;
- fail_unless (test->id == packet->data.whois_request.sender_id);
+ g_assert (test->id == packet->data.whois_request.sender_id);
reply = gibber_r_multicast_packet_new (PACKET_TYPE_WHOIS_REQUEST,
0, transport->max_packet_size);
@@ -487,7 +486,7 @@ id_generation_conflict_send_hook (GibberTransport *transport,
}
else if (test->count > test->wait)
{
- fail_unless (test->id != packet->data.whois_request.sender_id);
+ g_assert (test->id != packet->data.whois_request.sender_id);
}
break;
@@ -495,21 +494,24 @@ id_generation_conflict_send_hook (GibberTransport *transport,
case PACKET_TYPE_WHOIS_REPLY:
/* transport sends a unsolicited whois reply after choosing a
* identifier */
- fail_unless (packet->sender != test->id);
- fail_unless (test->count ==
+ g_assert (packet->sender != test->id);
+ g_assert_cmpuint (test->count, ==,
ID_GENERATION_EXPECTED_POLLS + test->wait);
g_main_loop_quit (loop);
break;
default:
- fail ("Unexpected packet type: %x", packet->type);
+ g_warning ("Unexpected packet type: %x", packet->type);
+ g_assert_not_reached ();
+ break;
}
g_object_unref (packet);
return TRUE;
}
-START_TEST (test_id_generation_conflict)
+static void
+test_id_generation_conflict (gint _i)
{
/* Test if the multicast transport correctly handles the case that it sees
* another WHOIS_REQUEST on one of its WHOIS_REQUESTS when it's determining
@@ -533,18 +535,33 @@ START_TEST (test_id_generation_conflict)
g_object_unref (rmtransport);
}
-END_TEST
+static void
+test_id_generation_conflict_loop (void)
+{
+ gint i;
+ for (i = 0; i < ID_GENERATION_EXPECTED_POLLS; ++i)
+ test_id_generation_conflict (i);
+}
-TCase *
-make_gibber_r_multicast_causal_transport_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("Gibber R Multicast Causal transport");
- tcase_add_test (tc, test_unique_id);
- tcase_add_loop_test (tc, test_id_generation_conflict, 0,
- ID_GENERATION_EXPECTED_POLLS);
- tcase_add_test (tc, test_fragmentation);
- tcase_add_test (tc, test_depends);
-
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/r-multicast-casual-transport/unique-id",
+ test_unique_id);
+ g_test_add_func (
+ "/gibber/r-multicast-casual-transport/id-generation-conflict",
+ test_id_generation_conflict_loop);
+ g_test_add_func ("/gibber/r-multicast-casual-transport/fragmentation",
+ test_fragmentation);
+ g_test_add_func ("/gibber/r-multicast-casual-transport/depends",
+ test_depends);
+
+ return g_test_run ();
}
+
+#include "test-transport.c"
diff --git a/lib/gibber/tests/check-gibber-r-multicast-packet.c b/lib/gibber/tests/check-gibber-r-multicast-packet.c
index 52bfef41..5d5fcfd8 100644
--- a/lib/gibber/tests/check-gibber-r-multicast-packet.c
+++ b/lib/gibber/tests/check-gibber-r-multicast-packet.c
@@ -3,11 +3,8 @@
#include <gibber/gibber-r-multicast-packet.h>
-#include <check.h>
-#include "check-gibber.h"
-
#define COMPARE(x) G_STMT_START { \
- fail_unless (a->x == b->x); \
+ g_assert (a->x == b->x); \
} G_STMT_END
typedef struct {
@@ -24,7 +21,8 @@ typedef struct {
#define NUMBER_OF_DIFF_TESTS 15
-START_TEST (test_r_multicast_packet_diff)
+static void
+test_r_multicast_packet_diff (gint _i)
{
diff_testcase cases[NUMBER_OF_DIFF_TESTS] =
{ { 0, 0, 0 },
@@ -47,11 +45,19 @@ START_TEST (test_r_multicast_packet_diff)
diff_testcase *c = cases + _i;
gint32 result = gibber_r_multicast_packet_diff (c->a, c->b);
- fail_unless (c->result == result);
+ g_assert (c->result == result);
+}
+
+static void
+test_r_multicast_packet_diff_loop (void)
+{
+ gint i;
+ for (i = 0; i < NUMBER_OF_DIFF_TESTS; ++i)
+ test_r_multicast_packet_diff (i);
}
-END_TEST
-START_TEST (test_data_packet)
+static void
+test_data_packet (void)
{
GibberRMulticastPacket *a;
GibberRMulticastPacket *b;
@@ -87,7 +93,7 @@ START_TEST (test_data_packet)
data = gibber_r_multicast_packet_get_raw_data (a, &len);
b = gibber_r_multicast_packet_parse (data, len, NULL);
- fail_unless (b != NULL);
+ g_assert (b != NULL);
COMPARE (type);
COMPARE (version);
@@ -96,7 +102,7 @@ START_TEST (test_data_packet)
COMPARE (packet_id);
COMPARE (data.data.stream_id);
- fail_unless (a->sender == b->sender);
+ g_assert (a->sender == b->sender);
for (n = 0 ; n < b->depends->len; n++)
{
@@ -106,32 +112,33 @@ START_TEST (test_data_packet)
GibberRMulticastPacketSenderInfo *, n);
if (senders[i].sender_id == s->sender_id)
{
- fail_unless (senders[i].packet_id == s->packet_id);
- fail_unless (senders[i].seen == FALSE);
+ g_assert (senders[i].packet_id == s->packet_id);
+ g_assert (senders[i].seen == FALSE);
senders[i].seen = TRUE;
break;
}
}
- fail_unless (senders[i].sender_id != 0);
+ g_assert (senders[i].sender_id != 0);
}
for (i = 0; senders[i].sender_id != 0 ; i++)
{
- fail_unless (senders[i].seen == TRUE);
+ g_assert (senders[i].seen == TRUE);
}
pdata = gibber_r_multicast_packet_get_payload (b, &plen);
- fail_unless (plen == strlen (payload));
+ g_assert (plen == strlen (payload));
- fail_unless (memcmp (payload, pdata, plen) == 0);
+ g_assert (memcmp (payload, pdata, plen) == 0);
g_object_unref (a);
g_object_unref (b);
-} END_TEST
+}
-START_TEST (test_attempt_join_packet)
+static void
+test_attempt_join_packet (void)
{
GibberRMulticastPacket *a;
GibberRMulticastPacket *b;
@@ -166,14 +173,14 @@ START_TEST (test_attempt_join_packet)
b = gibber_r_multicast_packet_parse (data, len, NULL);
- fail_unless (b != NULL);
+ g_assert (b != NULL);
COMPARE (type);
COMPARE (version);
COMPARE (packet_id);
COMPARE (data.attempt_join.senders->len);
- fail_unless (a->sender == b->sender);
+ g_assert (a->sender == b->sender);
for (n = 0; n < b->depends->len; n++)
{
@@ -183,24 +190,24 @@ START_TEST (test_attempt_join_packet)
GibberRMulticastPacketSenderInfo *, n);
if (senders[i].sender_id == s->sender_id)
{
- fail_unless (senders[i].packet_id == s->packet_id);
- fail_unless (senders[i].seen == FALSE);
+ g_assert (senders[i].packet_id == s->packet_id);
+ g_assert (senders[i].seen == FALSE);
senders[i].seen = TRUE;
break;
}
}
- fail_unless (senders[i].sender_id != 0);
+ g_assert (senders[i].sender_id != 0);
}
for (i = 0; senders[i].sender_id != 0; i++)
{
- fail_unless (senders[i].seen == TRUE);
+ g_assert (senders[i].seen == TRUE);
}
for (i = 0; new_senders[i].sender_id != 0; i++)
{
- fail_unless (new_senders[i].sender_id ==
+ g_assert (new_senders[i].sender_id ==
g_array_index (b->data.attempt_join.senders, guint32, i));
new_senders[i].seen = TRUE;
break;
@@ -208,21 +215,25 @@ START_TEST (test_attempt_join_packet)
for (i = 0; new_senders[i].sender_id != 0; i++)
{
- fail_unless (senders[i].seen == TRUE);
+ g_assert (senders[i].seen == TRUE);
}
g_object_unref (a);
g_object_unref (b);
}
-END_TEST
-TCase *
-make_gibber_r_multicast_packet_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("RMulticast Packet");
- tcase_add_test (tc, test_data_packet);
- tcase_add_test (tc, test_attempt_join_packet);
- tcase_add_loop_test (tc, test_r_multicast_packet_diff, 0,
- NUMBER_OF_DIFF_TESTS);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/r-multicast-packet/data-packet", test_data_packet);
+ g_test_add_func ("/gibber/r-multicast-packet/attempt-join-packet",
+ test_attempt_join_packet);
+ g_test_add_func ("/gibber/r-multicast-packet/diff",
+ test_r_multicast_packet_diff_loop);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-r-multicast-sender.c b/lib/gibber/tests/check-gibber-r-multicast-sender.c
index b0a4c903..7eb41943 100644
--- a/lib/gibber/tests/check-gibber-r-multicast-sender.c
+++ b/lib/gibber/tests/check-gibber-r-multicast-sender.c
@@ -1,12 +1,29 @@
+/*
+ * check-gibber-r-multicast-sender.c
+ * Copyright (C) 2007 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
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <gibber/gibber-r-multicast-sender.h>
-#include <check.h>
-#include "check-gibber.h"
-
#define SENDER 4321
#define SENDER_NAME "testsender"
@@ -98,13 +115,13 @@ data_received_cb (GibberRMulticastSender *sender, guint8 stream_id,
for (i = 0 ; lines[i] != NULL && *lines[i] != '\0'; i++) {
guint32 v = atoi (lines[i]);
- fail_unless (v == expected);
- fail_unless ((v % G_MAXUINT8) - i == stream_id);
+ g_assert (v == expected);
+ g_assert ((v % G_MAXUINT8) - i == stream_id);
expected++;
}
/* serial % 3 is send out in a single packet the other two together.
* So expected can't be % 3 == 2 here */
- fail_if (expected % 3 == 2);
+ g_assert_cmpuint (expected % 3, !=, 2);
if (expected == serial_offset + NR_PACKETS
|| expected == serial_offset + NR_PACKETS + EXTRA_SEEN) {
@@ -121,7 +138,7 @@ repair_request_cb (GibberRMulticastSender *sender, guint id, gpointer data)
{
GibberRMulticastPacket *p;
- fail_unless (gibber_r_multicast_packet_diff (serial_offset, id) >= 0
+ g_assert (gibber_r_multicast_packet_diff (serial_offset, id) >= 0
|| gibber_r_multicast_packet_diff (id,
serial_offset + NR_PACKETS + EXTRA_SEEN) < 0);
@@ -135,8 +152,8 @@ repair_message_cb (GibberRMulticastSender *sender,
GibberRMulticastPacket *packet, gpointer user_data)
{
- fail_unless (packet->type == PACKET_TYPE_DATA);
- fail_unless (packet->packet_id == REPAIR_PACKET + serial_offset);
+ g_assert (packet->type == PACKET_TYPE_DATA);
+ g_assert (packet->packet_id == REPAIR_PACKET + serial_offset);
g_main_loop_quit ((GMainLoop *) user_data);
}
@@ -168,7 +185,8 @@ add_packet (gpointer data)
#define NUMBER_OF_TESTS 3
-START_TEST (test_sender)
+static void
+test_sender (gint _i)
{
GibberRMulticastSender *s;
GibberRMulticastSenderGroup *group;
@@ -227,7 +245,15 @@ START_TEST (test_sender)
g_main_loop_run (loop);
gibber_r_multicast_sender_group_free (group);
-} END_TEST
+}
+
+static void
+test_sender_loop (void)
+{
+ gint i;
+ for (i = 0; i < NUMBER_OF_TESTS; ++i)
+ test_sender (i);
+}
/* Holding test */
guint32 idle_timer = 0;
@@ -297,12 +323,12 @@ h_idle_next_step (gpointer user_data)
case START_DATA:
case FAIL:
case EXPECT:
- fail ("Should not be reached");
+ g_assert_not_reached ();
break;
case HOLD:
s = g_hash_table_find (d->group->senders,
h_find_sender, e->expected_node);
- fail_unless (s != NULL);
+ g_assert (s != NULL);
d->test_step++;
gibber_r_multicast_sender_hold_data (s, e->hold_id);
h_next_test_step (d);
@@ -310,7 +336,7 @@ h_idle_next_step (gpointer user_data)
case UNHOLD:
s = g_hash_table_find (d->group->senders,
h_find_sender, e->expected_node);
- fail_unless (s != NULL);
+ g_assert (s != NULL);
d->test_step++;
gibber_r_multicast_sender_release_data (s);
h_next_test_step (d);
@@ -336,7 +362,7 @@ h_next_test_step (h_data_t *d)
case UNHOLD_IMMEDIATE:
s = g_hash_table_find (d->group->senders,
h_find_sender, e->expected_node);
- fail_unless (s != NULL);
+ g_assert (s != NULL);
d->test_step++;
gibber_r_multicast_sender_release_data (s);
h_next_test_step (d);
@@ -344,7 +370,7 @@ h_next_test_step (h_data_t *d)
case START_DATA:
s = g_hash_table_find (d->group->senders,
h_find_sender, e->expected_node);
- fail_unless (s != NULL);
+ g_assert (s != NULL);
d->test_step++;
gibber_r_multicast_sender_set_data_start (s, e->hold_id);
h_next_test_step (d);
@@ -352,7 +378,7 @@ h_next_test_step (h_data_t *d)
case FAIL:
s = g_hash_table_find (d->group->senders,
h_find_sender, e->expected_node);
- fail_unless (s != NULL);
+ g_assert (s != NULL);
d->test_step++;
gibber_r_multicast_sender_set_failed (s);
h_next_test_step (d);
@@ -373,11 +399,11 @@ h_received_data_cb (GibberRMulticastSender *sender, guint16 stream_id,
{
h_data_t *d = (h_data_t *) user_data;
- fail_unless (d->expectation[d->test_step].type == EXPECT);
- fail_unless (d->expectation[d->test_step].packet_type == PACKET_TYPE_DATA);
- fail_unless (
- strcmp (d->expectation[d->test_step].expected_node, sender->name) == 0);
- fail_unless (d->expectation[d->test_step].data_stream_id == stream_id);
+ g_assert (d->expectation[d->test_step].type == EXPECT);
+ g_assert (d->expectation[d->test_step].packet_type == PACKET_TYPE_DATA);
+ g_assert_cmpstr (d->expectation[d->test_step].expected_node, ==,
+ sender->name);
+ g_assert (d->expectation[d->test_step].data_stream_id == stream_id);
d->test_step++;
h_next_test_step (d);
@@ -389,10 +415,10 @@ h_received_control_packet_cb (GibberRMulticastSender *sender,
{
h_data_t *d = (h_data_t *) user_data;
- fail_unless (d->expectation[d->test_step].type == EXPECT);
- fail_unless (d->expectation[d->test_step].packet_type == packet->type);
- fail_unless (
- strcmp (d->expectation[d->test_step].expected_node, sender->name) == 0);
+ g_assert (d->expectation[d->test_step].type == EXPECT);
+ g_assert (d->expectation[d->test_step].packet_type == packet->type);
+ g_assert_cmpstr (d->expectation[d->test_step].expected_node, ==,
+ sender->name);
d->test_step++;
h_next_test_step (d);
@@ -565,7 +591,9 @@ add_h_sender (guint32 sender, gchar *name, GibberRMulticastSenderGroup *group,
G_CALLBACK (h_received_control_packet_cb), data);
}
-START_TEST (test_holding) {
+static void
+test_holding (gint _i)
+{
GibberRMulticastSenderGroup *group;
guint32 sender_offset = 0xf00;
/* control packets aren't hold back, thus we get them interleaved at first
@@ -599,7 +627,7 @@ START_TEST (test_holding) {
s0 = g_hash_table_find (group->senders, h_find_sender,
test->setup[i].name);
- fail_unless (s0 != NULL);
+ g_assert (s0 != NULL);
p = gibber_r_multicast_packet_new (test->setup[i].packet_type, s0->id,
1500);
@@ -609,13 +637,13 @@ START_TEST (test_holding) {
{
s1 = g_hash_table_find (group->senders, h_find_sender,
test->setup[i].depend_node);
- fail_unless (s1 != NULL);
- fail_unless (gibber_r_multicast_packet_add_sender_info (p, s1->id,
+ g_assert (s1 != NULL);
+ g_assert (gibber_r_multicast_packet_add_sender_info (p, s1->id,
test->setup[i].depend_packet_id, NULL));
}
if (test->setup[i].packet_type == PACKET_TYPE_DATA)
{
- fail_unless (test->setup[i].data != NULL);
+ g_assert (test->setup[i].data != NULL);
gibber_r_multicast_packet_set_data_info (p,
test->setup[i].data_stream_id,
@@ -637,16 +665,29 @@ START_TEST (test_holding) {
}
while (data.expectation[data.test_step].type != DONE);
- fail_unless (idle_timer == 0);
+ g_assert (idle_timer == 0);
+}
-} END_TEST
+static void
+test_holding_loop (void)
+{
+ gint i;
+ for (i = 0; i < NUMBER_OF_H_TESTS; ++i)
+ test_holding (i);
+}
-TCase *
-make_gibber_r_multicast_sender_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("RMulticast Sender");
- tcase_set_timeout (tc, 20);
- tcase_add_loop_test (tc, test_sender, 0, NUMBER_OF_TESTS);
- tcase_add_loop_test (tc, test_holding, 0, NUMBER_OF_H_TESTS );
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ /* Kill this process after 20 seconds */
+ alarm (20);
+
+ g_test_add_func ("/gibber/r-multicast-sender/sender", test_sender_loop);
+ g_test_add_func ("/gibber/r-multicast-sender/holding", test_holding_loop);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-unix-transport.c b/lib/gibber/tests/check-gibber-unix-transport.c
index 6a048fef..c3cfbed8 100644
--- a/lib/gibber/tests/check-gibber-unix-transport.c
+++ b/lib/gibber/tests/check-gibber-unix-transport.c
@@ -34,9 +34,6 @@
#include <gibber/gibber-unix-transport.h>
#include <gibber/gibber-listener.h>
-#include <check.h>
-#include "check-gibber.h"
-
gboolean got_connection;
gboolean received_credentials;
GibberUnixTransport *unix_transport;
@@ -107,7 +104,8 @@ new_connection_cb (GibberListener *listener,
g_main_loop_quit (loop);
}
-START_TEST (test_send_credentials)
+static void
+test_send_credentials (void)
{
GibberListener *listener_unix;
int ret;
@@ -116,33 +114,34 @@ START_TEST (test_send_credentials)
gchar *path = "/tmp/check-gibber-unix-transport-socket";
ret = unlink (path);
- fail_if (ret == -1 && errno != ENOENT);
+ g_assert (!(ret == -1 && errno != ENOENT));
got_connection = FALSE;
mainloop = g_main_loop_new (NULL, FALSE);
listener_unix = gibber_listener_new ();
- fail_if (listener_unix == NULL);
+ g_assert (listener_unix != NULL);
g_signal_connect (listener_unix, "new-connection",
G_CALLBACK (new_connection_cb), mainloop);
ret = gibber_listener_listen_socket (listener_unix, path, FALSE, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
unix_transport = gibber_unix_transport_new ();
ret = gibber_unix_transport_connect (unix_transport, path, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
if (!got_connection)
g_main_loop_run (mainloop);
- fail_if (!got_connection, "Failed to connect");
+ /* "Failed to connect" */
+ g_assert (got_connection);
g_object_unref (listener_unix);
g_object_unref (unix_transport);
g_main_loop_unref (mainloop);
-} END_TEST
+}
static void
get_credentials_cb (GibberUnixTransport *transport,
@@ -184,7 +183,8 @@ receive_new_connection_cb (GibberListener *listener,
g_assert (ok == gibber_unix_transport_supports_credentials ());
}
-START_TEST (test_receive_credentials)
+static void
+test_receive_credentials (void)
{
GibberListener *listener_unix;
int ret;
@@ -193,41 +193,50 @@ START_TEST (test_receive_credentials)
gchar *path = "/tmp/check-gibber-unix-transport-socket";
ret = unlink (path);
- fail_if (ret == -1 && errno != ENOENT);
+ g_assert (!(ret == -1 && errno != ENOENT));
received_credentials = FALSE;
mainloop = g_main_loop_new (NULL, FALSE);
listener_unix = gibber_listener_new ();
- fail_if (listener_unix == NULL);
+ g_assert (listener_unix != NULL);
g_signal_connect (listener_unix, "new-connection",
G_CALLBACK (receive_new_connection_cb), mainloop);
ret = gibber_listener_listen_socket (listener_unix, path, FALSE, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
unix_transport = gibber_unix_transport_new ();
ret = gibber_unix_transport_connect (unix_transport, path, &error);
- fail_if (ret != TRUE);
+ g_assert (ret == TRUE);
#if defined(__linux__)
if (!received_credentials)
g_main_loop_run (mainloop);
- fail_if (!received_credentials, "Failed to receive credentials");
+ /* Failed to receive credentials */
+ g_assert (received_credentials);
#endif
g_object_unref (listener_unix);
g_object_unref (unix_transport);
g_main_loop_unref (mainloop);
-} END_TEST
+}
-TCase *
-make_gibber_unix_transport_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("GibberUnixTransport");
- tcase_add_test (tc, test_send_credentials);
- tcase_add_test (tc, test_receive_credentials);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ alarm (20);
+
+ g_test_add_func ("/gibber/unix-transport/send-credentials",
+ test_send_credentials);
+ g_test_add_func ("/gibber/unix-transport/receive-credentials",
+ test_receive_credentials);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-xmpp-connection-listener.c b/lib/gibber/tests/check-gibber-xmpp-connection-listener.c
index 8dd19314..96bdb17f 100644
--- a/lib/gibber/tests/check-gibber-xmpp-connection-listener.c
+++ b/lib/gibber/tests/check-gibber-xmpp-connection-listener.c
@@ -33,9 +33,6 @@
#include <gibber/gibber-xmpp-connection.h>
#include <gibber/gibber-xmpp-connection-listener.h>
-#include <check.h>
-#include "check-gibber.h"
-
gboolean got_connection;
static void
@@ -69,7 +66,8 @@ connect_to_port (int port)
return result;
}
-START_TEST (test_listen)
+static void
+test_listen (void)
{
GibberXmppConnectionListener *listener;
int port;
@@ -78,7 +76,7 @@ START_TEST (test_listen)
got_connection = FALSE;
listener = gibber_xmpp_connection_listener_new ();
- fail_if (listener == NULL);
+ g_assert (listener != NULL);
g_signal_connect (listener, "new-connection", G_CALLBACK (new_connection_cb),
NULL);
@@ -89,32 +87,37 @@ START_TEST (test_listen)
if (gibber_xmpp_connection_listener_listen (listener, port, &error))
break;
- fail_if (!g_error_matches (error, GIBBER_LISTENER_ERROR,
- GIBBER_LISTENER_ERROR_ADDRESS_IN_USE));
+ g_assert_error (error, GIBBER_LISTENER_ERROR,
+ GIBBER_LISTENER_ERROR_ADDRESS_IN_USE);
g_error_free (error);
error = NULL;
}
- fail_if (port >= 5400);
+ g_assert (port < 5400);
result = connect_to_port (port);
- fail_if (result == FALSE);
+ g_assert (result != FALSE);
while (g_main_context_iteration (NULL, FALSE))
;
- fail_if (got_connection == FALSE);
+ g_assert (got_connection);
g_object_unref (listener);
/* listener is destroyed, connection should be refused now */
got_connection = FALSE;
result = connect_to_port (port);
- fail_if (result == TRUE);
-} END_TEST
+ g_assert (result != TRUE);
+}
-TCase *
-make_gibber_xmpp_connection_listener_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("GibberXmppConnectionListener");
- tcase_add_test (tc, test_listen);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/xmpp-connection-listener/listen",
+ test_listen);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-xmpp-connection.c b/lib/gibber/tests/check-gibber-xmpp-connection.c
index de9dd1da..03412579 100644
--- a/lib/gibber/tests/check-gibber-xmpp-connection.c
+++ b/lib/gibber/tests/check-gibber-xmpp-connection.c
@@ -5,9 +5,6 @@
#include <gibber/gibber-xmpp-connection.h>
#include <gibber/gibber-transport.h>
#include "test-transport.h"
-#include "check-gibber.h"
-
-#include <check.h>
struct _FileChunker {
gchar *contents;
@@ -51,7 +48,8 @@ file_chunker_get_chunk (FileChunker *fc,
}
-START_TEST (test_instantiation)
+static void
+test_instantiation (void)
{
GibberXmppConnection *connection;
TestTransport *transport;
@@ -59,13 +57,12 @@ START_TEST (test_instantiation)
transport = test_transport_new (NULL, NULL);
connection = gibber_xmpp_connection_new (GIBBER_TRANSPORT(transport));
- fail_if (connection == NULL);
+ g_assert (connection != NULL);
connection = gibber_xmpp_connection_new (NULL);
- fail_if (connection == NULL);
+ g_assert (connection != NULL);
}
-END_TEST
static void
parse_error_cb (GibberXmppConnection *connection, gpointer user_data)
@@ -74,7 +71,8 @@ parse_error_cb (GibberXmppConnection *connection, gpointer user_data)
*parse_error_found = TRUE;
}
-START_TEST (test_simple_message)
+static void
+test_simple_message (void)
{
GibberXmppConnection *connection;
TestTransport *transport;
@@ -96,7 +94,7 @@ START_TEST (test_simple_message)
}
fc = file_chunker_new (file, 10);
- fail_if (fc == NULL);
+ g_assert (fc != NULL);
transport = test_transport_new (NULL, NULL);
connection = gibber_xmpp_connection_new (GIBBER_TRANSPORT(transport));
@@ -110,17 +108,28 @@ START_TEST (test_simple_message)
test_transport_write (transport, (guint8 *) chunk, chunk_length);
}
- fail_if (parse_error_found);
+ g_assert (!parse_error_found);
g_free (file);
file_chunker_destroy (fc);
-} END_TEST
+}
-TCase *
-make_gibber_xmpp_connection_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("XMPP Connection");
- tcase_add_test (tc, test_instantiation);
- tcase_add_test (tc, test_simple_message);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ /* Kill tests in 20 seconds */
+ alarm (20);
+
+ g_test_add_func ("/gibber/xmpp-connection/instantiation",
+ test_instantiation);
+ g_test_add_func ("/gibber/xmpp-connection/simple-message",
+ test_simple_message);
+
+ return g_test_run ();
}
+
+#include "test-transport.c"
diff --git a/lib/gibber/tests/check-gibber-xmpp-error.c b/lib/gibber/tests/check-gibber-xmpp-error.c
index b7e4ba26..926b2720 100644
--- a/lib/gibber/tests/check-gibber-xmpp-error.c
+++ b/lib/gibber/tests/check-gibber-xmpp-error.c
@@ -28,35 +28,32 @@
#define DEBUG_FLAG DEBUG_XMPP
#include <gibber/gibber-debug.h>
-#include <check.h>
-#include "check-gibber.h"
-
static void
test_xmpp_error_to_node_with_bad_request (void)
{
- GibberXmppStanza *stanza;
- GibberXmppNode *node;
+ WockyStanza *stanza;
+ WockyNode *node;
const gchar *code;
const gchar *type;
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
node = gibber_xmpp_error_to_node (XMPP_ERROR_BAD_REQUEST,
wocky_stanza_get_top_node (stanza), NULL);
- fail_if (node == NULL);
- fail_if (strcmp (node->name, "error") != 0);
+ g_assert (node != NULL);
+ g_assert_cmpstr (node->name, ==, "error");
- code = gibber_xmpp_node_get_attribute (node, "code");
- fail_if (code == NULL || strcmp (code, "400") != 0);
+ code = wocky_node_get_attribute (node, "code");
+ g_assert (!(code == NULL || strcmp (code, "400") != 0));
- type = gibber_xmpp_node_get_attribute (node, "type");
- fail_if (type == NULL || strcmp (type, "modify") != 0);
+ type = wocky_node_get_attribute (node, "type");
+ g_assert (!(type == NULL || strcmp (type, "modify") != 0));
- fail_if (gibber_xmpp_node_get_child_ns (node, "bad-request",
- "urn:ietf:params:xml:ns:xmpp-stanzas") == NULL);
+ g_assert (wocky_node_get_child_ns (node, "bad-request",
+ "urn:ietf:params:xml:ns:xmpp-stanzas") != NULL);
g_object_unref (stanza);
}
@@ -64,77 +61,85 @@ test_xmpp_error_to_node_with_bad_request (void)
static void
test_xmpp_error_to_node_with_si_bad_profile (void)
{
- GibberXmppStanza *stanza;
- GibberXmppNode *node;
+ WockyStanza *stanza;
+ WockyNode *node;
const gchar *code;
const gchar *type;
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
node = gibber_xmpp_error_to_node (XMPP_ERROR_SI_BAD_PROFILE,
wocky_stanza_get_top_node (stanza), NULL);
- fail_if (node == NULL);
- fail_if (strcmp (node->name, "error") != 0);
+ g_assert (node != NULL);
+ g_assert_cmpstr (node->name, ==, "error");
- code = gibber_xmpp_node_get_attribute (node, "code");
- fail_if (code == NULL || strcmp (code, "400") != 0);
+ code = wocky_node_get_attribute (node, "code");
+ g_assert (!(code == NULL || strcmp (code, "400") != 0));
- type = gibber_xmpp_node_get_attribute (node, "type");
- fail_if (type == NULL || strcmp (type, "modify") != 0);
+ type = wocky_node_get_attribute (node, "type");
+ g_assert (!(type == NULL || strcmp (type, "modify") != 0));
- fail_if (gibber_xmpp_node_get_child_ns (node, "bad-request",
- "urn:ietf:params:xml:ns:xmpp-stanzas") == NULL);
+ g_assert (wocky_node_get_child_ns (node, "bad-request",
+ "urn:ietf:params:xml:ns:xmpp-stanzas") != NULL);
- fail_if (gibber_xmpp_node_get_child_ns (node, "bad-profile",
- "http://jabber.org/protocol/si") == NULL);
+ g_assert (wocky_node_get_child_ns (node, "bad-profile",
+ "http://jabber.org/protocol/si") != NULL);
g_object_unref (stanza);
}
-START_TEST (test_xmpp_error_to_node)
+static void
+test_xmpp_error_to_node (void)
{
test_xmpp_error_to_node_with_bad_request ();
test_xmpp_error_to_node_with_si_bad_profile ();
-} END_TEST
+}
-START_TEST (test_message_get_xmpp_error)
+static void
+test_message_get_xmpp_error (void)
{
GibberXmppError xmpp_error;
for (xmpp_error = 1; xmpp_error < NUM_XMPP_ERRORS; xmpp_error++)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
GError *error = NULL;
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_ERROR,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
"from", "to",
- GIBBER_STANZA_END);
+ NULL);
gibber_xmpp_error_to_node (xmpp_error,
wocky_stanza_get_top_node (stanza), NULL);
error = gibber_message_get_xmpp_error (stanza);
- fail_if (error == NULL);
+ g_assert (error != NULL);
- fail_if (error->domain != GIBBER_XMPP_ERROR);
- fail_if (error->code != (gint) xmpp_error);
- fail_if (strcmp (error->message, gibber_xmpp_error_description (
- xmpp_error)) != 0);
+ g_assert (error->domain == GIBBER_XMPP_ERROR);
+ g_assert (error->code == (gint) xmpp_error);
+ g_assert_cmpstr (error->message, ==,
+ gibber_xmpp_error_description (xmpp_error));
g_object_unref (stanza);
g_error_free (error);
}
-} END_TEST
+}
-TCase *
-make_gibber_xmpp_error_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("XMPP Error");
- tcase_add_test (tc, test_xmpp_error_to_node);
- tcase_add_test (tc, test_message_get_xmpp_error);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/xmpp-error/to-node",
+ test_xmpp_error_to_node);
+ g_test_add_func ("/gibber/xmpp-error/message-get-xmpp-error",
+ test_message_get_xmpp_error);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-xmpp-node.c b/lib/gibber/tests/check-gibber-xmpp-node.c
deleted file mode 100644
index e7663ff8..00000000
--- a/lib/gibber/tests/check-gibber-xmpp-node.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <gibber/gibber-xmpp-node.h>
-
-#include <check.h>
-#include "check-helpers.h"
-#include "check-gibber.h"
-
-START_TEST (test_instantiation)
-{
- GibberXmppNode *node;
- node = gibber_xmpp_node_new_ns ("test", "http://example.com/badgers/");
- fail_unless (node != NULL);
-
- gibber_xmpp_node_free (node);
-}
-END_TEST
-
-START_TEST (test_language)
-{
- GibberXmppNode *node;
- const gchar *lang;
-
- node = gibber_xmpp_node_new_ns ("test", "http://example.com/badgers/");
- lang = gibber_xmpp_node_get_language (node);
- fail_unless (lang == NULL);
-
- gibber_xmpp_node_set_language (node, "en");
- lang = gibber_xmpp_node_get_language (node);
- fail_unless (strcmp (lang, "en") == 0);
-
- gibber_xmpp_node_set_language (node, NULL);
- lang = gibber_xmpp_node_get_language (node);
- fail_unless (lang == NULL);
-
- gibber_xmpp_node_set_language_n (node, "en-US", 2);
- lang = gibber_xmpp_node_get_language (node);
- fail_unless (strcmp (lang, "en") == 0);
-
- gibber_xmpp_node_set_language_n (node, NULL, 2);
- lang = gibber_xmpp_node_get_language (node);
- fail_unless (lang == NULL);
-
- gibber_xmpp_node_free (node);
-}
-END_TEST
-
-START_TEST (test_namespace)
-{
- GibberXmppNode *node;
- const gchar *ns;
-
- node = gibber_xmpp_node_new_ns ("test", "foo");
- ns = gibber_xmpp_node_get_ns (node);
- fail_unless (strcmp (ns, "foo") == 0);
- gibber_xmpp_node_free (node);
-}
-END_TEST
-
-
-START_TEST (test_attribute)
-{
- GibberXmppNode *node;
- const gchar *attribute;
-
- node = gibber_xmpp_node_new_ns ("test", "about:blank");
-
- attribute = gibber_xmpp_node_get_attribute (node, "foo");
- fail_unless (attribute == NULL);
-
- attribute = gibber_xmpp_node_get_attribute (node, NULL);
- fail_unless (attribute == NULL);
-
- attribute = gibber_xmpp_node_get_attribute_ns (node, "foo", "bar");
- fail_unless (attribute == NULL);
-
- gibber_xmpp_node_set_attribute (node, "foo", "baz");
-
- attribute = gibber_xmpp_node_get_attribute (node, "foo");
- fail_unless (strcmp ( attribute, "baz") == 0);
-
- attribute = gibber_xmpp_node_get_attribute_ns (node, "foo", "bar");
- fail_unless (attribute == NULL);
-
- gibber_xmpp_node_set_attribute_ns (node, "foobar", "barbaz", "bar");
-
- attribute = gibber_xmpp_node_get_attribute (node, "foobar");
- fail_unless (strcmp (attribute, "barbaz") == 0);
-
- attribute = gibber_xmpp_node_get_attribute_ns (node, "foobar", "bar");
- fail_unless (strcmp (attribute, "barbaz") == 0);
-
- attribute = gibber_xmpp_node_get_attribute_ns (node, "barfoo", "bar");
- fail_unless (attribute == NULL);
-
- gibber_xmpp_node_free (node);
-}
-END_TEST
-
-START_TEST (test_child)
-{
- GibberXmppNode *node, *child;
-
- node = gibber_xmpp_node_new_ns ("test", "about:blank");
-
- child = gibber_xmpp_node_get_child (node, "foo");
- fail_unless (child == NULL);
-
- gibber_xmpp_node_add_child (node, "foo");
- child = gibber_xmpp_node_get_child (node, "foo");
- fail_if (child == NULL);
- fail_unless (strcmp (child->name, "foo") == 0);
-
- child = gibber_xmpp_node_get_child_ns (node, "foo", "bar");
- fail_unless (child == NULL);
-
- gibber_xmpp_node_add_child_ns (node, "foobar", "bar");
- child = gibber_xmpp_node_get_child_ns (node, "foobar", "foo");
- fail_unless (child == NULL);
- child = gibber_xmpp_node_get_child_ns (node, "foobar", "bar");
- fail_if (child == NULL);
- fail_unless (strcmp (child->name, "foobar") == 0);
-
- gibber_xmpp_node_add_child_with_content (node, "foo2", "blah");
- child = gibber_xmpp_node_get_child (node, "foo2");
- fail_if (child->content == NULL);
- fail_unless (strcmp (child->content, "blah") == 0);
-
- gibber_xmpp_node_free (node);
-}
-END_TEST
-
-
-TCase *
-make_gibber_xmpp_node_tcase (void)
-{
- TCase *tc = tcase_create ("XMPP Node");
- tcase_add_test (tc, test_instantiation);
- tcase_add_test (tc, test_language);
- tcase_add_test (tc, test_namespace);
- tcase_add_test (tc, test_attribute);
- tcase_add_test (tc, test_child);
- return tc;
-}
diff --git a/lib/gibber/tests/check-gibber-xmpp-reader.c b/lib/gibber/tests/check-gibber-xmpp-reader.c
index 43b60d1b..42bf9930 100644
--- a/lib/gibber/tests/check-gibber-xmpp-reader.c
+++ b/lib/gibber/tests/check-gibber-xmpp-reader.c
@@ -3,28 +3,24 @@
#include <string.h>
#include <gibber/gibber-xmpp-reader.h>
-#include <gibber/gibber-xmpp-stanza.h>
-
-#include <check.h>
-
-#include "check-gibber.h"
+#include <wocky/wocky-stanza.h>
typedef struct _ReceivedStanzaEvent ReceivedStanzaEvent;
struct _ReceivedStanzaEvent {
GibberXmppReader *reader;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
};
static void received_stanza_cb (GibberXmppReader *reader,
- GibberXmppStanza *stanza, gpointer user_data)
+ WockyStanza *stanza, gpointer user_data)
{
GQueue *events_queue = (GQueue *) user_data;
ReceivedStanzaEvent *event;
- fail_if (reader == NULL);
- fail_if (stanza == NULL);
- fail_if (events_queue == NULL);
+ g_assert (reader != NULL);
+ g_assert (stanza != NULL);
+ g_assert (events_queue != NULL);
g_object_ref (stanza);
@@ -36,19 +32,20 @@ static void received_stanza_cb (GibberXmppReader *reader,
}
-START_TEST (test_instantiation)
+static void
+test_instantiation (void)
{
GibberXmppReader *reader;
reader = gibber_xmpp_reader_new_no_stream ();
- fail_if (reader == NULL);
+ g_assert (reader != NULL);
g_object_unref (reader);
}
-END_TEST
-START_TEST (test_simple_message)
+static void
+test_simple_message (void)
{
GibberXmppReader *reader;
- GibberXmppNode *node;
+ WockyNode *node;
gchar *data;
gsize length;
gboolean valid;
@@ -73,41 +70,39 @@ START_TEST (test_simple_message)
file = g_strdup_printf ("%s/inputs/simple-message.input", srcdir);
}
- fail_unless (g_file_get_contents (file, &data, &length, NULL));
+ g_assert (g_file_get_contents (file, &data, &length, NULL));
g_free (file);
valid = gibber_xmpp_reader_push (reader, (guint8 *) data, length, NULL);
- fail_unless (valid);
+ g_assert (valid);
- fail_unless (g_queue_get_length (received_stanzas) == 2);
+ g_assert (g_queue_get_length (received_stanzas) == 2);
event = g_queue_pop_head (received_stanzas);
- fail_unless (event->reader == reader);
+ g_assert (event->reader == reader);
node = wocky_stanza_get_top_node (event->stanza);
- fail_if (node == NULL);
- fail_unless (strcmp (node->name, "message") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_language (node), "en") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_attribute (node, "to"),
- "juliet@example.com") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_attribute (node, "id"),
- "0") == 0);
+ g_assert (node != NULL);
+ g_assert_cmpstr (node->name, ==, "message");
+ g_assert_cmpstr (wocky_node_get_language (node), ==, "en");
+ g_assert_cmpstr (wocky_node_get_attribute (node, "to"), ==,
+ "juliet@example.com");
+ g_assert_cmpstr (wocky_node_get_attribute (node, "id"), ==, "0");
g_object_unref (event->stanza);
g_free (event);
event = g_queue_pop_head (received_stanzas);
- fail_unless (event->reader == reader);
+ g_assert (event->reader == reader);
node = wocky_stanza_get_top_node (event->stanza);
- fail_unless (strcmp (node->name, "message") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_language (node), "en") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_attribute (node, "to"),
- "juliet@example.com") == 0);
- fail_unless (strcmp (gibber_xmpp_node_get_attribute (node, "id"),
- "1") == 0);
+ g_assert_cmpstr (node->name, ==, "message");
+ g_assert_cmpstr (wocky_node_get_language (node), ==, "en");
+ g_assert_cmpstr (wocky_node_get_attribute (node, "to"), ==,
+ "juliet@example.com");
+ g_assert_cmpstr (wocky_node_get_attribute (node, "id"), ==, "1");
g_free (data);
g_queue_free (received_stanzas);
@@ -115,13 +110,18 @@ START_TEST (test_simple_message)
g_free (event);
g_object_unref (reader);
}
-END_TEST
-TCase *
-make_gibber_xmpp_reader_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("XMPP Reader");
- tcase_add_test (tc, test_instantiation);
- tcase_add_test (tc, test_simple_message);
- return tc;
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add_func ("/gibber/xmpp-reader/instantiation",
+ test_instantiation);
+ g_test_add_func ("/gibber/xmpp-reader/simple-message",
+ test_simple_message);
+
+ return g_test_run ();
}
diff --git a/lib/gibber/tests/check-gibber-xmpp-stanza.c b/lib/gibber/tests/check-gibber-xmpp-stanza.c
deleted file mode 100644
index dae2ab2f..00000000
--- a/lib/gibber/tests/check-gibber-xmpp-stanza.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * check-gibber-xmpp-stanza.c - Test for gibber-xmpp-stanza functions
- * Copyright (C) 2007 Collabora Ltd.
- * @author Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gibber/gibber-xmpp-stanza.h>
-
-#define DEBUG_FLAG DEBUG_XMPP
-#include <gibber/gibber-debug.h>
-
-#include <wocky/wocky-namespaces.h>
-
-#include <check.h>
-#include "check-gibber.h"
-
-START_TEST (test_build_with_html_message)
-{
- GibberXmppStanza *stanza;
- const gchar *body = "Telepathy rocks!",
- *xhtml_ns = "http://www.w3.org/1999/xhtml";
- GibberXmppNode *node;
- const gchar *value;
-
- g_type_init ();
-#ifdef ENABLE_DEBUG
- gibber_debug_set_flags_from_env ();
-#endif
-
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_MESSAGE, GIBBER_STANZA_SUB_TYPE_NONE,
- "alice@collabora.co.uk", "bob@collabora.co.uk",
- GIBBER_NODE, "html",
- GIBBER_NODE_XMLNS, xhtml_ns,
- GIBBER_NODE, "body",
- GIBBER_NODE_ATTRIBUTE, "textcolor", "red",
- GIBBER_NODE_TEXT, body,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
-
- DEBUG_STANZA (stanza, "check");
-
- fail_if (stanza == NULL);
- /* <message> */
- node = wocky_stanza_get_top_node (stanza);
- fail_if (node == NULL);
- fail_unless (strcmp (node->name, "message") == 0);
- value = gibber_xmpp_node_get_attribute (node, "type");
- fail_unless (value == NULL);
- value = gibber_xmpp_node_get_attribute (node, "from");
- fail_unless (strcmp (value, "alice@collabora.co.uk") == 0);
- value = gibber_xmpp_node_get_attribute (node, "to");
- fail_unless (strcmp (value, "bob@collabora.co.uk") == 0);
-
- /* <html> */
- node = gibber_xmpp_node_get_child_ns (node, "html", xhtml_ns);
- fail_if (node == NULL);
-
- /* <body> */
- node = gibber_xmpp_node_get_child (node, "body");
- fail_if (node == NULL);
- value = gibber_xmpp_node_get_attribute (node, "textcolor");
- fail_unless (strcmp (value, "red") == 0);
- fail_unless (strcmp (node->content, body) == 0);
-
- g_object_unref (stanza);
-} END_TEST
-
-START_TEST (test_get_type_info_with_simple_message)
-{
- GibberXmppStanza *stanza;
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
-
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_MESSAGE, GIBBER_STANZA_SUB_TYPE_NONE,
- "alice@collabora.co.uk", "bob@collabora.co.uk",
- GIBBER_STANZA_END);
- fail_if (stanza == NULL);
-
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- fail_if (type != GIBBER_STANZA_TYPE_MESSAGE);
- fail_if (sub_type != GIBBER_STANZA_SUB_TYPE_NONE);
-
- g_object_unref (stanza);
-} END_TEST
-
-START_TEST (test_get_type_info_with_iq_set)
-{
- GibberXmppStanza *stanza;
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
-
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_SET,
- "alice@collabora.co.uk", "bob@collabora.co.uk",
- GIBBER_STANZA_END);
- fail_if (stanza == NULL);
-
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- fail_if (type != GIBBER_STANZA_TYPE_IQ);
- fail_if (sub_type != GIBBER_STANZA_SUB_TYPE_SET);
-
- g_object_unref (stanza);
-} END_TEST
-
-START_TEST (test_get_type_info_with_unknown_type)
-{
- GibberXmppStanza *stanza;
- GibberStanzaType type;
-
- stanza = gibber_xmpp_stanza_new_ns ("goat", WOCKY_XMPP_NS_JABBER_CLIENT);
- fail_if (stanza == NULL);
-
- gibber_xmpp_stanza_get_type_info (stanza, &type, NULL);
- fail_if (type != GIBBER_STANZA_TYPE_UNKNOWN);
-
- g_object_unref (stanza);
-} END_TEST
-
-START_TEST (test_get_type_info_with_unknown_sub_type)
-{
- GibberXmppStanza *stanza;
- GibberStanzaSubType sub_type;
-
- stanza = gibber_xmpp_stanza_new_ns ("iq", WOCKY_XMPP_NS_JABBER_CLIENT);
- fail_if (stanza == NULL);
- gibber_xmpp_node_set_attribute (wocky_stanza_get_top_node (stanza),
- "type", "goat");
-
- gibber_xmpp_stanza_get_type_info (stanza, NULL, &sub_type);
- fail_if (sub_type != GIBBER_STANZA_SUB_TYPE_UNKNOWN);
-
- g_object_unref (stanza);
-} END_TEST
-
-
-TCase *
-make_gibber_xmpp_stanza_tcase (void)
-{
- TCase *tc = tcase_create ("XMPP Stanza");
- tcase_add_test (tc, test_build_with_html_message);
- tcase_add_test (tc, test_get_type_info_with_simple_message);
- tcase_add_test (tc, test_get_type_info_with_iq_set);
- tcase_add_test (tc, test_get_type_info_with_unknown_type);
- tcase_add_test (tc, test_get_type_info_with_unknown_sub_type);
- return tc;
-}
diff --git a/lib/gibber/tests/check-gibber.h b/lib/gibber/tests/check-gibber.h
deleted file mode 100644
index d98d3d08..00000000
--- a/lib/gibber/tests/check-gibber.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __CHECK_GIBBER_H__
-#define __CHECK_GIBBER_H__
-
-#include <check.h>
-
-TCase *make_gibber_xmpp_node_tcase (void);
-TCase *make_gibber_xmpp_reader_tcase (void);
-TCase *make_gibber_xmpp_connection_tcase (void);
-TCase *make_gibber_r_multicast_packet_tcase (void);
-TCase *make_gibber_r_multicast_causal_transport_tcase (void);
-TCase *make_gibber_r_multicast_sender_tcase (void);
-TCase *make_gibber_xmpp_stanza_tcase (void);
-TCase *make_gibber_iq_helper_tcase (void);
-TCase *make_gibber_listener_tcase (void);
-TCase *make_gibber_xmpp_connection_listener_tcase (void);
-TCase *make_gibber_xmpp_error_tcase (void);
-TCase *make_gibber_unix_transport_tcase (void);
-
-#endif /* #ifndef __CHECK_GIBBER_H__ */
diff --git a/lib/gibber/tests/check-helpers.c b/lib/gibber/tests/check-helpers.c
deleted file mode 100644
index 86ef1154..00000000
--- a/lib/gibber/tests/check-helpers.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * check-helpers.c - Source for some check helpers
- * Copyright (C) 2007 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
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "check-helpers.h"
-
-static gboolean expecting_critical = FALSE;
-static gboolean received_critical = FALSE;
-
-static void
-check_helper_log_critical_func (const gchar *log_damain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
-{
-
- if (!expecting_critical)
- {
- fail ("Unexpected critical message: %s\n", message);
- }
-
- g_assert (log_level & G_LOG_LEVEL_CRITICAL);
-
- received_critical = TRUE;
-}
-
-gboolean
-got_critical (void)
-{
- return received_critical;
-}
-
-void
-expect_critical (gboolean expected)
-{
- expecting_critical = expected;
- received_critical = FALSE;
-}
-
-void
-check_helpers_init (void)
-{
- g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL,
- check_helper_log_critical_func, NULL);
-}
diff --git a/lib/gibber/tests/check-helpers.h b/lib/gibber/tests/check-helpers.h
deleted file mode 100644
index b71b3b65..00000000
--- a/lib/gibber/tests/check-helpers.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * check-helpers.c - Source for some check helpers
- * Copyright (C) 2007 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
- */
-#ifndef __CHECK_HELPERS_H__
-#define __CHECK_HELPERS_H__
-
-#include <glib.h>
-#include <check.h>
-
-void
-check_helpers_init (void);
-
-void
-expect_critical (gboolean expected);
-
-gboolean
-got_critical (void);
-
-#define fail_unless_critical(expr, ...) \
-G_STMT_START { \
- expect_critical (TRUE); \
- expr; \
- _fail_unless (got_critical (), __FILE__, __LINE__, \
- "Expected g_critical, got none", ## __VA_ARGS__, NULL); \
- expect_critical (FALSE); \
-} G_STMT_END;
-
-#endif /* #ifndef __CHECK_HELPERS_H__ */
diff --git a/lib/gibber/tests/check-main.c b/lib/gibber/tests/check-main.c
deleted file mode 100644
index 075e250a..00000000
--- a/lib/gibber/tests/check-main.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <glib-object.h>
-
-#include <wocky/wocky.h>
-
-#include <check.h>
-
-#include "check-gibber.h"
-#include "check-helpers.h"
-
-#include "config.h"
-
-static Suite *
-make_gibber_suite (void)
-{
- Suite *s = suite_create ("Gibber");
-
- suite_add_tcase (s, make_gibber_xmpp_node_tcase ());
- suite_add_tcase (s, make_gibber_xmpp_reader_tcase ());
- suite_add_tcase (s, make_gibber_xmpp_connection_tcase ());
- suite_add_tcase (s, make_gibber_r_multicast_packet_tcase ());
- suite_add_tcase (s, make_gibber_r_multicast_sender_tcase ());
- suite_add_tcase (s, make_gibber_r_multicast_causal_transport_tcase ());
- suite_add_tcase (s, make_gibber_xmpp_stanza_tcase ());
- suite_add_tcase (s, make_gibber_iq_helper_tcase ());
- suite_add_tcase (s, make_gibber_listener_tcase ());
- suite_add_tcase (s, make_gibber_xmpp_connection_listener_tcase ());
- suite_add_tcase (s, make_gibber_xmpp_error_tcase ());
- suite_add_tcase (s, make_gibber_unix_transport_tcase ());
-
- return s;
-}
-
-int
-main (void)
-{
- int number_failed = 0;
- Suite *s;
- SRunner *sr;
-
- check_helpers_init ();
- g_type_init ();
- wocky_init ();
-
- s = make_gibber_suite ();
- sr = srunner_create (s);
- srunner_run_all (sr, CK_NORMAL);
- number_failed += srunner_ntests_failed (sr);
- srunner_free (sr);
-
- wocky_deinit ();
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
diff --git a/lib/gibber/tests/test-xmpp-connection.c b/lib/gibber/tests/test-xmpp-connection.c
index b957f718..6bb627bc 100644
--- a/lib/gibber/tests/test-xmpp-connection.c
+++ b/lib/gibber/tests/test-xmpp-connection.c
@@ -58,34 +58,34 @@ print_attribute (const gchar *key, const gchar *value, const gchar *pref,
return TRUE;
}
-static void print_node (GibberXmppNode *node, gint ident);
+static void print_node (WockyNode *node, gint ident);
static gboolean
-print_child (GibberXmppNode *node, gpointer user_data)
+print_child (WockyNode *node, gpointer user_data)
{
print_node (node, GPOINTER_TO_INT(user_data));
return TRUE;
}
static void
-print_node (GibberXmppNode *node, gint ident)
+print_node (WockyNode *node, gint ident)
{
fprintf (treefile, "%*s`-+-- Name: %s (ns: %s)\n", ident - 1, " ",
- node->name, gibber_xmpp_node_get_ns (node));
+ node->name, wocky_node_get_ns (node));
wocky_node_each_attribute (node, print_attribute,
GINT_TO_POINTER(ident));
if (node->content)
fprintf (treefile, "%*s |-- Content: %s\n", ident, " ", node->content);
- if (gibber_xmpp_node_get_language (node))
+ if (wocky_node_get_language (node))
fprintf (treefile, "%*s |-- Language: %s\n", ident, " ",
- gibber_xmpp_node_get_language (node));
+ wocky_node_get_language (node));
- gibber_xmpp_node_each_child (node, print_child, GINT_TO_POINTER (ident + 2));
+ wocky_node_each_child (node, print_child, GINT_TO_POINTER (ident + 2));
}
static void
-received_stanza (GibberXmppConnection *connection, GibberXmppStanza *stanza,
+received_stanza (GibberXmppConnection *connection, WockyStanza *stanza,
gpointer user_data)
{
fprintf (treefile, "-|\n");
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
new file mode 100644
index 00000000..4120d82c
--- /dev/null
+++ b/plugins/Makefile.am
@@ -0,0 +1,32 @@
+plugindir = $(libdir)/telepathy/salut-0
+
+# testing-only plugins
+noinst_LTLIBRARIES = \
+ test.la
+
+installable_plugins =
+ $(NULL)
+
+if ENABLE_PLUGINS
+plugin_LTLIBRARIES = $(installable_plugins)
+else
+# we still compile the plugin (just to make sure it compiles!) but we don't
+# install it
+noinst_LTLIBRARIES += $(installable_plugins)
+endif
+
+AM_LDFLAGS = -module -avoid-version -shared
+
+test_la_SOURCES = \
+ test.c \
+ test.h
+
+# because test.la is not installed, libtool will want to compile it as static
+# despite -shared (a convenience library), unless we also use -rpath
+test_la_LDFLAGS = $(AM_LDFLAGS) -rpath $(plugindir)
+
+AM_CFLAGS = $(ERROR_CFLAGS) \
+ -I $(top_srcdir) -I $(top_builddir) \
+ @GLIB_CFLAGS@ @TELEPATHY_GLIB_CFLAGS@ \
+ -I $(top_srcdir)/salut -I $(top_builddir)/salut \
+ -I $(top_srcdir)/plugins
diff --git a/plugins/test.c b/plugins/test.c
new file mode 100644
index 00000000..7271d9ba
--- /dev/null
+++ b/plugins/test.c
@@ -0,0 +1,68 @@
+#include "config.h"
+
+#include "test.h"
+
+#include <salut/plugin.h>
+
+#define DEBUG(msg, ...) \
+ g_debug ("%s: " msg, G_STRFUNC, ##__VA_ARGS__)
+
+static void plugin_iface_init (
+ gpointer g_iface,
+ gpointer data);
+
+G_DEFINE_TYPE_WITH_CODE (TestPlugin, test_plugin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (SALUT_TYPE_PLUGIN, plugin_iface_init);
+ )
+
+static void
+test_plugin_init (TestPlugin *object)
+{
+ DEBUG ("%p", object);
+}
+
+static void
+test_plugin_class_init (TestPluginClass *klass)
+{
+}
+
+static void
+initialize (SalutPlugin *plugin,
+ TpBaseConnectionManager *connection_manager)
+{
+ DEBUG ("%p on connection manager %p", plugin, connection_manager);
+
+ /* If you wanted to add another protocol you could do it here by
+ * creating the protocol object and then calling
+ * tp_base_connection_manager_add_protocol(). */
+}
+
+static GPtrArray *
+create_channel_managers (SalutPlugin *plugin,
+ TpBaseConnection *connection)
+{
+ DEBUG ("%p on connection %p", plugin, connection);
+
+ return NULL;
+}
+
+static void
+plugin_iface_init (
+ gpointer g_iface,
+ gpointer data G_GNUC_UNUSED)
+{
+ SalutPluginInterface *iface = g_iface;
+
+ iface->api_version = SALUT_PLUGIN_CURRENT_VERSION;
+ iface->name = "Salut test plugin";
+ iface->version = PACKAGE_VERSION;
+
+ iface->initialize = initialize;
+ iface->create_channel_managers = create_channel_managers;
+}
+
+SalutPlugin *
+salut_plugin_create ()
+{
+ return g_object_new (test_plugin_get_type (), NULL);
+}
diff --git a/plugins/test.h b/plugins/test.h
new file mode 100644
index 00000000..13e11e4c
--- /dev/null
+++ b/plugins/test.h
@@ -0,0 +1,32 @@
+#include <glib-object.h>
+
+typedef struct _TestPluginClass TestPluginClass;
+typedef struct _TestPlugin TestPlugin;
+
+struct _TestPluginClass
+{
+ GObjectClass parent;
+};
+
+struct _TestPlugin
+{
+ GObject parent;
+};
+
+GType test_plugin_get_type (void);
+
+#define TEST_TYPE_PLUGIN \
+ (test_plugin_get_type ())
+#define TEST_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_PLUGIN, TestPlugin))
+#define TEST_PLUGIN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), TEST_TYPE_PLUGIN, \
+ TestPluginClass))
+#define TEST_IS_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), TEST_TYPE_PLUGIN))
+#define TEST_IS_PLUGIN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), TEST_TYPE_PLUGIN))
+#define TEST_PLUGIN_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_PLUGIN, \
+ TestPluginClass))
+
diff --git a/salut/Makefile.am b/salut/Makefile.am
new file mode 100644
index 00000000..ca46c477
--- /dev/null
+++ b/salut/Makefile.am
@@ -0,0 +1,10 @@
+if ENABLE_PLUGIN_API
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = telepathy-salut.pc
+
+salutincludedir = $(includedir)/telepathy-salut-0/salut
+salutinclude_HEADERS = \
+ plugin.h \
+ protocol.h
+
+endif
diff --git a/salut/plugin.h b/salut/plugin.h
new file mode 100644
index 00000000..975446c6
--- /dev/null
+++ b/salut/plugin.h
@@ -0,0 +1,118 @@
+/*
+ * plugin.h — plugin API for telepathy-salut plugins
+ * Copyright © 2009-2011 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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
+ */
+
+#ifndef SALUT_PLUGINS_PLUGIN_H
+#define SALUT_PLUGINS_PLUGIN_H
+
+#include <glib-object.h>
+
+#include <telepathy-glib/base-connection-manager.h>
+#include <telepathy-glib/base-connection.h>
+
+G_BEGIN_DECLS
+
+#define SALUT_TYPE_PLUGIN (salut_plugin_get_type ())
+#define SALUT_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), SALUT_TYPE_PLUGIN, SalutPlugin))
+#define SALUT_IS_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SALUT_TYPE_PLUGIN))
+#define SALUT_PLUGIN_GET_INTERFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SALUT_TYPE_PLUGIN, \
+ SalutPluginInterface))
+
+typedef struct _SalutPlugin SalutPlugin;
+typedef struct _SalutPluginInterface SalutPluginInterface;
+
+/* The caller of this function takes ownership of the returned
+ * GPtrArray and the channel managers inside the array. This has the
+ * same semantics as TpBaseConnectionCreateChannelManagersImpl. */
+typedef GPtrArray * (*SalutPluginCreateChannelManagersImpl) (
+ SalutPlugin *plugin,
+ TpBaseConnection *connection);
+
+typedef void (*SalutPluginInitializeImpl) (
+ SalutPlugin *plugin,
+ TpBaseConnectionManager *connection_manager);
+
+#define SALUT_PLUGIN_CURRENT_VERSION 1
+
+struct _SalutPluginInterface
+{
+ GTypeInterface parent;
+
+ /**
+ * The version of the SalutPluginInterface struct design. The
+ * current version is at %SALUT_PLUGIN_CURRENT_VERSION.
+ */
+ guint api_version;
+
+ /**
+ * An arbitrary human-readable name identifying this plugin.
+ */
+ const gchar *name;
+
+ /**
+ * The plugin's version, conventionally a "."-separated sequence of
+ * numbers.
+ */
+ const gchar *version;
+
+ /**
+ * An implementation of salut_plugin_initialize().
+ */
+ SalutPluginInitializeImpl initialize;
+
+ /**
+ * An implementation of salut_plugin_create_channel_managers().
+ */
+ SalutPluginCreateChannelManagersImpl create_channel_managers;
+
+ GCallback _padding[7];
+};
+
+GType salut_plugin_get_type (void);
+
+const gchar * salut_plugin_get_name (
+ SalutPlugin *plugin);
+const gchar * salut_plugin_get_version (
+ SalutPlugin *plugin);
+
+void salut_plugin_initialize (
+ SalutPlugin *plugin,
+ TpBaseConnectionManager *connection_manager);
+
+GPtrArray * salut_plugin_create_channel_managers (
+ SalutPlugin *plugin,
+ TpBaseConnection *connection);
+
+/**
+ * salut_plugin_create:
+ *
+ * Prototype for the plugin entry point.
+ *
+ * Returns: a new instance of this plugin, which must not be %NULL.
+ */
+SalutPlugin * salut_plugin_create (void);
+
+typedef SalutPlugin * (*SalutPluginCreateImpl) (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/protocol.h b/salut/protocol.h
index 186bb241..83d0a715 100644
--- a/src/protocol.h
+++ b/salut/protocol.h
@@ -62,7 +62,29 @@ GType salut_protocol_get_type (void);
SALUT_TYPE_PROTOCOL, \
SalutProtocolClass))
-TpBaseProtocol *salut_protocol_new (GType backend_type);
+#define SALUT_PROTOCOL_LOCAL_XMPP_NAME "local-xmpp"
+#define SALUT_PROTOCOL_LOCAL_XMPP_ENGLISH_NAME "Link-local XMPP"
+#define SALUT_PROTOCOL_LOCAL_XMPP_ICON_NAME "Link-local XMPP"
+
+/**
+ * salut_protocol_new:
+ * @backend_type: the #GType of the discovery client to use, or
+ * %G_TYPE_NONE for the avahi backend.
+ * @dnssd_name: The DNS-SD name to use (only used in avahi backend),
+ * or %NULL for the default avahi DNS-SD name.
+ * @protocol_name: Name of the protocol.
+ * @english_name: English name of the protocol.
+ * @icon_name: Icon name of the protocol.
+ *
+ * <!-- -->
+ *
+ * Returns: a new #TpBaseProtocol oject for the supplied arguments
+ */
+TpBaseProtocol *salut_protocol_new (GType backend_type,
+ const gchar *dnssd_name,
+ const gchar *protocol_name,
+ const gchar *english_name,
+ const gchar *icon_name);
G_END_DECLS
diff --git a/salut/telepathy-salut-uninstalled.pc.in b/salut/telepathy-salut-uninstalled.pc.in
new file mode 100644
index 00000000..92cbc46c
--- /dev/null
+++ b/salut/telepathy-salut-uninstalled.pc.in
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+abs_top_srcdir=@abs_top_srcdir@
+abs_top_builddir=@abs_top_builddir@
+libdir=@libdir@
+
+plugindir=${libdir}/telepathy/salut-0
+
+Name: Telepathy-Salut (uninstalled)
+Description: XMPP backend for the Telepathy framework (uninstalled)
+Version: @VERSION@
+Requires: pkg-config >= 0.21
+Requires.private: glib-2.0 >= 2.16, gobject-2.0 >= 2.16, telepathy-glib >= 0.13.12
+Cflags: -I${abs_top_srcdir} -I${abs_top_srcdir}/lib/ext/wocky
diff --git a/salut/telepathy-salut.pc.in b/salut/telepathy-salut.pc.in
new file mode 100644
index 00000000..9e63245c
--- /dev/null
+++ b/salut/telepathy-salut.pc.in
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+libexecdir=@libexecdir@
+
+plugindir=${libdir}/telepathy/salut-0
+
+Name: Telepathy-Salut
+Description: XMPP backend for the Telepathy framework
+Version: @VERSION@
+Requires: pkg-config >= 0.21
+Requires.private: glib-2.0 >= 2.16, gobject-2.0 >= 2.16, telepathy-glib >= 0.13.12
+Cflags: -I${includedir}/telepathy-salut-0
diff --git a/src/Makefile.am b/src/Makefile.am
index cc55da0e..56387ef3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,13 @@ CLEANFILES = $(BUILT_SOURCES)
dist-hook:
$(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done)
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = telepathy-salut.pc
+
+EXTRA_DIST = \
+ telepathy-salut.pc.in \
+ telepathy-salut-uninstalled.pc.in
+
libexec_PROGRAMS=telepathy-salut
noinst_PROGRAMS = write-mgr-file
@@ -84,7 +91,11 @@ CORE_SOURCES = \
debug.c \
debug.h \
protocol.c \
- protocol.h
+ $(top_srcdir)/salut/protocol.h \
+ plugin-loader.c \
+ plugin-loader.h \
+ $(top_srcdir)/salut/plugin.h \
+ plugin.c
AVAHI_BACKEND_SOURCES = \
salut-avahi-discovery-client.h \
@@ -125,15 +136,10 @@ SHA1_SOURCES = \
sha1/sha1-util.c
libsalut_convenience_la_SOURCES = $(CORE_SOURCES) $(BUILT_SOURCES) \
- $(SHA1_SOURCES)
-
-libsalut_backend_avahi_la_SOURCES = $(AVAHI_BACKEND_SOURCES)
-
-libsalut_backend_dummy_la_SOURCES = $(DUMMY_BACKEND_SOURCES)
+ $(SHA1_SOURCES) $(AVAHI_BACKEND_SOURCES) $(DUMMY_BACKEND_SOURCES)
write_mgr_file_SOURCES = write-mgr-file.c
write_mgr_file_LDADD = libsalut-convenience.la \
- libsalut-backend-avahi.la \
$(top_builddir)/lib/gibber/libgibber.la \
$(top_builddir)/extensions/libsalut-extensions.la \
-ltelepathy-glib
@@ -153,23 +159,23 @@ check-local: check-coding-style
# TELEPATHY_GLIB_LIBS is only here so compiling against a static lib succeeds
telepathy_salut_LDADD = libsalut-convenience.la \
- libsalut-backend-avahi.la \
$(top_builddir)/lib/gibber/libgibber.la \
$(top_builddir)/extensions/libsalut-extensions.la \
-ltelepathy-glib
-noinst_LTLIBRARIES = libsalut-convenience.la \
- libsalut-backend-avahi.la \
- libsalut-backend-dummy.la
+noinst_LTLIBRARIES = libsalut-convenience.la
AM_CFLAGS = \
-I $(top_srcdir) -I $(top_builddir) \
-I $(top_srcdir)/lib -I $(top_builddir)/lib \
+ -I $(top_srcdir)/salut \
-DG_LOG_DOMAIN=\"salut\" \
+ -DPLUGIN_DIR=\"$(libdir)/telepathy/salut-0\" \
$(ERROR_CFLAGS) \
$(GCOV_CFLAGS) \
@LIBXML2_CFLAGS@ \
@GLIB_CFLAGS@ \
+ @GMODULE_CFLAGS@ \
@WOCKY_CFLAGS@ \
@DBUS_CFLAGS@ \
@AVAHI_CFLAGS@ \
@@ -180,6 +186,7 @@ AM_LDFLAGS = \
$(GCOV_LIBS) \
@LIBXML2_LIBS@ \
@GLIB_LIBS@ \
+ @GMODULE_LIBS@ \
@WOCKY_LIBS@ \
@DBUS_LIBS@ \
@AVAHI_LIBS@ \
diff --git a/src/debug.c b/src/debug.c
index 9227dc45..fc2841cb 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -38,6 +38,7 @@ GDebugKey keys[] = {
{ "discovery", DEBUG_DISCO },
{ "olpc-activity", DEBUG_OLPC_ACTIVITY },
{ "ft", DEBUG_FT },
+ { "plugin", DEBUG_PLUGIN },
{ "all", ~0 },
{ 0, },
};
diff --git a/src/debug.h b/src/debug.h
index cc28fcc5..75f4ce37 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -6,7 +6,7 @@
#include <glib.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#ifdef ENABLE_DEBUG
@@ -33,6 +33,7 @@ typedef enum
DEBUG_DISCOVERY = 1 << 18,
DEBUG_OLPC_ACTIVITY = 1 << 19,
DEBUG_FT = 1 << 20,
+ DEBUG_PLUGIN = 1 << 21,
} DebugFlags;
void debug_set_flags_from_env (void);
diff --git a/src/plugin-loader.c b/src/plugin-loader.c
new file mode 100644
index 00000000..59ef2e27
--- /dev/null
+++ b/src/plugin-loader.c
@@ -0,0 +1,273 @@
+/*
+ * plugin-loader.c — plugin support for telepathy-salut
+ * Copyright © 2009-2011 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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
+ */
+
+#include "config.h"
+
+#include "plugin-loader.h"
+
+#include <glib.h>
+
+#ifdef ENABLE_PLUGINS
+# include <gmodule.h>
+#endif
+
+#include <telepathy-glib/util.h>
+
+#define DEBUG_FLAG DEBUG_PLUGIN
+#include "debug.h"
+#include "salut/plugin.h"
+
+G_DEFINE_TYPE(SalutPluginLoader,
+ salut_plugin_loader,
+ G_TYPE_OBJECT)
+
+struct _SalutPluginLoaderPrivate
+{
+ GPtrArray *plugins;
+};
+
+#ifdef ENABLE_PLUGINS
+static void
+plugin_loader_try_to_load (
+ SalutPluginLoader *self,
+ const gchar *path)
+{
+ GModule *m = g_module_open (path, G_MODULE_BIND_LOCAL);
+ gpointer func;
+ SalutPluginCreateImpl create;
+ SalutPlugin *plugin;
+
+ if (m == NULL)
+ {
+ const gchar *e = g_module_error ();
+
+ /* the errors often seem to be prefixed by the filename */
+ if (g_str_has_prefix (e, path))
+ DEBUG ("%s", e);
+ else
+ DEBUG ("%s: %s", path, e);
+
+ return;
+ }
+
+ if (!g_module_symbol (m, "salut_plugin_create", &func))
+ {
+ DEBUG ("%s", g_module_error ());
+ g_module_close (m);
+ return;
+ }
+
+ /* We're about to try to instantiate an object. This installs the
+ * class with the type system, so we should ensure that this
+ * plug-in is never accidentally unloaded.
+ */
+ g_module_make_resident (m);
+
+ /* Here goes nothing... */
+ create = func;
+ plugin = create ();
+
+ if (plugin == NULL)
+ {
+ g_warning ("salut_plugin_create () failed for %s", path);
+ }
+ else
+ {
+ const gchar *version = salut_plugin_get_version (plugin);
+
+ if (version == NULL)
+ version = "(unspecified)";
+
+ DEBUG ("loaded '%s' version %s (%s)",
+ salut_plugin_get_name (plugin), version, path);
+
+ g_ptr_array_add (self->priv->plugins, plugin);
+ }
+}
+
+static void
+salut_plugin_loader_probe (SalutPluginLoader *self)
+{
+ GError *error = NULL;
+ const gchar *directory_name = g_getenv ("SALUT_PLUGIN_DIR");
+ GDir *d;
+ const gchar *file;
+
+ if (!g_module_supported ())
+ {
+ DEBUG ("modules aren't supported on this platform.");
+ return;
+ }
+
+ if (directory_name == NULL)
+ directory_name = PLUGIN_DIR;
+
+ DEBUG ("probing %s", directory_name);
+ d = g_dir_open (directory_name, 0, &error);
+
+ if (d == NULL)
+ {
+ DEBUG ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ while ((file = g_dir_read_name (d)) != NULL)
+ {
+ gchar *path;
+
+ if (!g_str_has_suffix (file, G_MODULE_SUFFIX))
+ continue;
+
+ path = g_build_filename (directory_name, file, NULL);
+ plugin_loader_try_to_load (self, path);
+ g_free (path);
+ }
+
+ g_dir_close (d);
+}
+#endif
+
+static void
+salut_plugin_loader_init (SalutPluginLoader *self)
+{
+ SalutPluginLoaderPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ SALUT_TYPE_PLUGIN_LOADER, SalutPluginLoaderPrivate);
+
+ self->priv = priv;
+ priv->plugins = g_ptr_array_new_with_free_func (g_object_unref);
+}
+
+static GObject *
+salut_plugin_loader_constructor (
+ GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ static gpointer singleton = NULL;
+
+ if (singleton == NULL)
+ {
+ singleton = G_OBJECT_CLASS (salut_plugin_loader_parent_class)->
+ constructor (type, n_props, props);
+ g_object_add_weak_pointer (G_OBJECT (singleton), &singleton);
+
+ return singleton;
+ }
+ else
+ {
+ return g_object_ref (singleton);
+ }
+}
+
+static void
+salut_plugin_loader_constructed (GObject *object)
+{
+ SalutPluginLoader *self = SALUT_PLUGIN_LOADER (object);
+ void (*chain_up) (GObject *) =
+ G_OBJECT_CLASS (salut_plugin_loader_parent_class)->constructed;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+#ifdef ENABLE_PLUGINS
+ salut_plugin_loader_probe (self);
+#else
+ DEBUG ("built without plugin support, not actually loading anything");
+ (void) self; /* silence unused variable warning. */
+#endif
+}
+
+static void
+salut_plugin_loader_finalize (GObject *object)
+{
+ SalutPluginLoader *self = SALUT_PLUGIN_LOADER (object);
+ void (*chain_up) (GObject *) =
+ G_OBJECT_CLASS (salut_plugin_loader_parent_class)->finalize;
+
+ tp_clear_pointer (&self->priv->plugins, g_ptr_array_unref);
+
+ if (chain_up != NULL)
+ chain_up (object);
+}
+
+static void
+salut_plugin_loader_class_init (SalutPluginLoaderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (SalutPluginLoaderPrivate));
+
+ object_class->constructor = salut_plugin_loader_constructor;
+ object_class->constructed = salut_plugin_loader_constructed;
+ object_class->finalize = salut_plugin_loader_finalize;
+}
+
+SalutPluginLoader *
+salut_plugin_loader_dup ()
+{
+ return g_object_new (SALUT_TYPE_PLUGIN_LOADER, NULL);
+}
+
+void
+salut_plugin_loader_initialize (SalutPluginLoader *self,
+ TpBaseConnectionManager *connection_manager)
+{
+ guint i;
+
+ for (i = 0; i < self->priv->plugins->len; i++)
+ {
+ SalutPlugin *plugin = g_ptr_array_index (self->priv->plugins, i);
+
+ salut_plugin_initialize (plugin, connection_manager);
+ }
+}
+
+static void
+copy_to_other_array (gpointer data,
+ gpointer user_data)
+{
+ g_ptr_array_add (user_data, data);
+}
+
+GPtrArray *
+salut_plugin_loader_create_channel_managers (
+ SalutPluginLoader *self,
+ TpBaseConnection *connection)
+{
+ GPtrArray *out = g_ptr_array_new ();
+ guint i;
+
+ for (i = 0; i < self->priv->plugins->len; i++)
+ {
+ SalutPlugin *plugin = g_ptr_array_index (self->priv->plugins, i);
+ GPtrArray *managers;
+
+ managers = salut_plugin_create_channel_managers (plugin, connection);
+
+ if (managers == NULL)
+ continue;
+
+ g_ptr_array_foreach (managers, copy_to_other_array, out);
+ g_ptr_array_free (managers, TRUE);
+ }
+
+ return out;
+}
diff --git a/src/plugin-loader.h b/src/plugin-loader.h
new file mode 100644
index 00000000..1e3eefa7
--- /dev/null
+++ b/src/plugin-loader.h
@@ -0,0 +1,71 @@
+/*
+ * plugin-loader.h — plugin support for telepathy-salut
+ * Copyright © 2009-2011 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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
+ */
+#ifndef __PLUGIN_LOADER_H__
+#define __PLUGIN_LOADER_H__
+
+#include <glib-object.h>
+
+#include <telepathy-glib/base-connection-manager.h>
+#include <telepathy-glib/base-connection.h>
+
+typedef struct _SalutPluginLoader SalutPluginLoader;
+typedef struct _SalutPluginLoaderClass SalutPluginLoaderClass;
+typedef struct _SalutPluginLoaderPrivate SalutPluginLoaderPrivate;
+
+struct _SalutPluginLoaderClass {
+ GObjectClass parent_class;
+};
+
+struct _SalutPluginLoader {
+ GObject parent;
+
+ SalutPluginLoaderPrivate *priv;
+};
+
+GType salut_plugin_loader_get_type (void);
+
+/* TYPE MACROS */
+#define SALUT_TYPE_PLUGIN_LOADER \
+ (salut_plugin_loader_get_type ())
+#define SALUT_PLUGIN_LOADER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_PLUGIN_LOADER, \
+ SalutPluginLoader))
+#define SALUT_PLUGIN_LOADER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_PLUGIN_LOADER, \
+ SalutPluginLoaderClass))
+#define SALUT_IS_PLUGIN_LOADER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_PLUGIN_LOADER))
+#define SALUT_IS_PLUGIN_LOADER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_PLUGIN_LOADER))
+#define SALUT_PLUGIN_LOADER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_PLUGIN_LOADER, \
+ SalutPluginLoaderClass))
+
+SalutPluginLoader * salut_plugin_loader_dup (void);
+
+void salut_plugin_loader_initialize (
+ SalutPluginLoader *self,
+ TpBaseConnectionManager *connection_manager);
+
+GPtrArray * salut_plugin_loader_create_channel_managers (
+ SalutPluginLoader *self,
+ TpBaseConnection *connection);
+
+#endif /* #ifndef __PLUGIN_LOADER_H__ */
diff --git a/src/plugin.c b/src/plugin.c
new file mode 100644
index 00000000..370be53a
--- /dev/null
+++ b/src/plugin.c
@@ -0,0 +1,75 @@
+/*
+ * plugin.c — API for telepathy-salut plugins
+ * Copyright © 2009-2011 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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
+ */
+
+#include "salut/plugin.h"
+
+#include <telepathy-glib/util.h>
+
+#define DEBUG_FLAG DEBUG_PLUGINS
+#include "debug.h"
+
+G_DEFINE_INTERFACE (SalutPlugin, salut_plugin, G_TYPE_OBJECT)
+
+static void
+salut_plugin_default_init (SalutPluginInterface *iface)
+{
+}
+
+const gchar *
+salut_plugin_get_name (SalutPlugin *plugin)
+{
+ SalutPluginInterface *iface = SALUT_PLUGIN_GET_INTERFACE (plugin);
+
+ return iface->name;
+}
+
+const gchar *
+salut_plugin_get_version (SalutPlugin *plugin)
+{
+ SalutPluginInterface *iface = SALUT_PLUGIN_GET_INTERFACE (plugin);
+
+ return iface->version;
+}
+
+void
+salut_plugin_initialize (SalutPlugin *plugin,
+ TpBaseConnectionManager *connection_manager)
+{
+ SalutPluginInterface *iface = SALUT_PLUGIN_GET_INTERFACE (plugin);
+ SalutPluginInitializeImpl func = iface->initialize;
+
+ if (func != NULL)
+ func (plugin, connection_manager);
+}
+
+GPtrArray *
+salut_plugin_create_channel_managers (SalutPlugin *plugin,
+ TpBaseConnection *connection)
+{
+ SalutPluginInterface *iface = SALUT_PLUGIN_GET_INTERFACE (plugin);
+ SalutPluginCreateChannelManagersImpl func = iface->create_channel_managers;
+ GPtrArray *out = NULL;
+
+ if (func != NULL)
+ out = func (plugin, connection);
+
+ return out;
+}
+
diff --git a/src/protocol.c b/src/protocol.c
index 3120fce3..0d27a8e7 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -31,10 +31,8 @@
#include "salut-muc-manager.h"
#include "salut-roomlist-manager.h"
#include "salut-tubes-manager.h"
+#include "salut-avahi-discovery-client.h"
-#define PROTOCOL_NAME "local-xmpp"
-#define ICON_NAME "im-" PROTOCOL_NAME
-#define ENGLISH_NAME "Link-local XMPP"
/* there is no appropriate vCard field for this protocol */
#define VCARD_FIELD_NAME ""
@@ -44,11 +42,17 @@ G_DEFINE_TYPE (SalutProtocol,
enum {
PROP_BACKEND = 1,
+ PROP_DNSSD_NAME,
+ PROP_ENGLISH_NAME,
+ PROP_ICON_NAME
};
struct _SalutProtocolPrivate
{
GType backend_type;
+ gchar *english_name;
+ gchar *icon_name;
+ gchar *dnssd_name;
};
static const TpCMParamSpec salut_params[] = {
@@ -88,7 +92,9 @@ new_connection (TpBaseProtocol *protocol,
guint i;
obj = g_object_new (SALUT_TYPE_CONNECTION,
- "protocol", PROTOCOL_NAME,
+ "protocol", tp_base_protocol_get_name (protocol),
+ /* deliberately set :dnssd-name before backend-type */
+ "dnssd-name", self->priv->dnssd_name,
"backend-type", self->priv->backend_type,
NULL);
@@ -138,6 +144,8 @@ get_connection_details (TpBaseProtocol *self,
gchar **english_name,
gchar **vcard_field)
{
+ SalutProtocolPrivate *priv = SALUT_PROTOCOL (self)->priv;
+
if (connection_interfaces != NULL)
{
*connection_interfaces = g_strdupv (
@@ -160,7 +168,7 @@ get_connection_details (TpBaseProtocol *self,
if (icon_name != NULL)
{
- *icon_name = g_strdup (ICON_NAME);
+ *icon_name = g_strdup (priv->icon_name);
}
if (vcard_field != NULL)
@@ -170,7 +178,7 @@ get_connection_details (TpBaseProtocol *self,
if (english_name != NULL)
{
- *english_name = g_strdup (ENGLISH_NAME);
+ *english_name = g_strdup (priv->english_name);
}
}
@@ -188,6 +196,18 @@ salut_protocol_get_property (GObject *object,
g_value_set_gtype (value, self->priv->backend_type);
break;
+ case PROP_DNSSD_NAME:
+ g_value_set_string (value, self->priv->dnssd_name);
+ break;
+
+ case PROP_ENGLISH_NAME:
+ g_value_set_string (value, self->priv->english_name);
+ break;
+
+ case PROP_ICON_NAME:
+ g_value_set_string (value, self->priv->icon_name);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -205,7 +225,26 @@ salut_protocol_set_property (GObject *object,
switch (property_id)
{
case PROP_BACKEND:
- self->priv->backend_type = g_value_get_gtype (value);
+ {
+ GType type = g_value_get_gtype (value);
+
+ if (type == G_TYPE_NONE)
+ type = SALUT_TYPE_AVAHI_DISCOVERY_CLIENT;
+
+ self->priv->backend_type = type;
+ }
+ break;
+
+ case PROP_DNSSD_NAME:
+ self->priv->dnssd_name = g_value_dup_string (value);
+ break;
+
+ case PROP_ENGLISH_NAME:
+ self->priv->english_name = g_value_dup_string (value);
+ break;
+
+ case PROP_ICON_NAME:
+ self->priv->icon_name = g_value_dup_string (value);
break;
default:
@@ -215,6 +254,20 @@ salut_protocol_set_property (GObject *object,
}
static void
+salut_protocol_finalize (GObject *object)
+{
+ SalutProtocol *self = SALUT_PROTOCOL (object);
+
+ tp_clear_pointer (&self->priv->english_name, g_free);
+ tp_clear_pointer (&self->priv->icon_name, g_free);
+ tp_clear_pointer (&self->priv->dnssd_name, g_free);
+
+ if (G_OBJECT_CLASS (salut_protocol_parent_class)->finalize)
+ G_OBJECT_CLASS (salut_protocol_parent_class)->finalize (object);
+}
+
+
+static void
salut_protocol_class_init (SalutProtocolClass *klass)
{
TpBaseProtocolClass *base_class = (TpBaseProtocolClass *) klass;
@@ -232,19 +285,45 @@ salut_protocol_class_init (SalutProtocolClass *klass)
object_class->get_property = salut_protocol_get_property;
object_class->set_property = salut_protocol_set_property;
+ object_class->finalize = salut_protocol_finalize;
param_spec = g_param_spec_gtype ("backend-type", "backend type",
"a G_TYPE_GTYPE of the backend to use", G_TYPE_NONE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_BACKEND,
param_spec);
+
+ param_spec = g_param_spec_string ("dnssd-name", "DNS-SD name",
+ "The DNS-SD name of the protocol", "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_DNSSD_NAME,
+ param_spec);
+
+ param_spec = g_param_spec_string ("english-name", "English name",
+ "The English name of the protocol", "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_ENGLISH_NAME,
+ param_spec);
+
+ param_spec = g_param_spec_string ("icon-name", "Icon name",
+ "The icon name of the protocol", "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_ICON_NAME,
+ param_spec);
}
TpBaseProtocol *
-salut_protocol_new (GType backend_type)
+salut_protocol_new (GType backend_type,
+ const gchar *dnssd_name,
+ const gchar *protocol_name,
+ const gchar *english_name,
+ const gchar *icon_name)
{
return g_object_new (SALUT_TYPE_PROTOCOL,
- "name", PROTOCOL_NAME,
+ "name", protocol_name,
+ "dnssd-name", dnssd_name,
+ "english-name", english_name,
"backend-type", backend_type,
+ "icon-name", icon_name,
NULL);
}
diff --git a/src/salut-avahi-contact-manager.c b/src/salut-avahi-contact-manager.c
index 6b11835d..14c856d5 100644
--- a/src/salut-avahi-contact-manager.c
+++ b/src/salut-avahi-contact-manager.c
@@ -108,7 +108,6 @@ salut_avahi_contact_manager_init (SalutAvahiContactManager *self)
self->priv = priv;
- priv->presence_browser = ga_service_browser_new (SALUT_DNSSD_PRESENCE);
priv->discovery_client = NULL;
}
@@ -259,6 +258,18 @@ salut_avahi_contact_manager_close_all (SalutContactManager *mgr)
}
static void
+salut_avahi_contact_manager_constructed (GObject *object)
+{
+ SalutAvahiContactManager *self = SALUT_AVAHI_CONTACT_MANAGER (object);
+ SalutAvahiContactManagerPrivate *priv =
+ SALUT_AVAHI_CONTACT_MANAGER_GET_PRIVATE (self);
+ const gchar *dnssd_name = salut_avahi_discovery_client_get_dnssd_name (
+ priv->discovery_client);
+
+ priv->presence_browser = ga_service_browser_new ((gchar *) dnssd_name);
+}
+
+static void
salut_avahi_contact_manager_class_init (
SalutAvahiContactManagerClass *salut_avahi_contact_manager_class) {
GObjectClass *object_class = G_OBJECT_CLASS (salut_avahi_contact_manager_class);
@@ -271,6 +282,7 @@ salut_avahi_contact_manager_class_init (
object_class->get_property = salut_avahi_contact_manager_get_property;
object_class->set_property = salut_avahi_contact_manager_set_property;
+ object_class->constructed = salut_avahi_contact_manager_constructed;
contact_manager_class->start = salut_avahi_contact_manager_start;
contact_manager_class->create_contact =
diff --git a/src/salut-avahi-contact.c b/src/salut-avahi-contact.c
index 99df846a..81dfa6a9 100644
--- a/src/salut-avahi-contact.c
+++ b/src/salut-avahi-contact.c
@@ -322,6 +322,7 @@ salut_avahi_contact_retrieve_avatar (SalutContact *contact)
SalutAvahiContactPrivate *priv = self->priv;
gchar *name;
GError *error = NULL;
+ const gchar *dnssd_name;
if (priv->record_browser != NULL)
{
@@ -335,7 +336,9 @@ salut_avahi_contact_retrieve_avatar (SalutContact *contact)
return;
}
- name = g_strdup_printf ("%s." SALUT_DNSSD_PRESENCE ".local", contact->name);
+ dnssd_name = salut_avahi_discovery_client_get_dnssd_name (
+ priv->discovery_client);
+ name = g_strdup_printf ("%s.%s.local", contact->name, dnssd_name);
priv->record_browser = ga_record_browser_new (name, 0xA);
g_free (name);
diff --git a/src/salut-avahi-discovery-client.c b/src/salut-avahi-discovery-client.c
index 1130131f..b9076360 100644
--- a/src/salut-avahi-discovery-client.c
+++ b/src/salut-avahi-discovery-client.c
@@ -44,6 +44,7 @@
#include "salut-avahi-olpc-activity-manager.h"
#endif
+#include "salut-presence.h"
#include "salut-signals-marshal.h"
static void
@@ -67,6 +68,7 @@ static guint signals[LAST_SIGNAL] = {0};
enum
{
PROP_STATE = 1,
+ PROP_DNSSD_NAME,
LAST_PROPERTY
};
@@ -76,6 +78,8 @@ struct _SalutAvahiDiscoveryClientPrivate
{
SalutDiscoveryClientState state;
+ gchar *dnssd_name;
+
gboolean dispose_has_run;
};
@@ -135,6 +139,8 @@ salut_avahi_discovery_client_dispose (GObject *object)
self->avahi_client = NULL;
}
+ tp_clear_pointer (&priv->dnssd_name, g_free);
+
G_OBJECT_CLASS (salut_avahi_discovery_client_parent_class)->dispose (object);
}
@@ -153,6 +159,30 @@ salut_avahi_discovery_client_get_property (GObject *object,
case PROP_STATE:
g_value_set_uint (value, priv->state);
break;
+ case PROP_DNSSD_NAME:
+ g_value_set_string (value, priv->dnssd_name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+salut_avahi_discovery_client_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ SalutAvahiDiscoveryClient *self = SALUT_AVAHI_DISCOVERY_CLIENT (object);
+ SalutAvahiDiscoveryClientPrivate *priv =
+ SALUT_AVAHI_DISCOVERY_CLIENT_GET_PRIVATE (self);
+
+ switch (property_id)
+ {
+ case PROP_DNSSD_NAME:
+ priv->dnssd_name = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -172,9 +202,12 @@ salut_avahi_discovery_client_class_init (
object_class->dispose = salut_avahi_discovery_client_dispose;
object_class->get_property = salut_avahi_discovery_client_get_property;
+ object_class->set_property = salut_avahi_discovery_client_set_property;
g_object_class_override_property (object_class, PROP_STATE,
"state");
+ g_object_class_override_property (object_class, PROP_DNSSD_NAME,
+ "dnssd-name");
signals[STATE_CHANGED] =
g_signal_new ("state-changed",
@@ -324,6 +357,18 @@ salut_avahi_discovery_client_get_host_name_fqdn (SalutDiscoveryClient *clt)
SALUT_AVAHI_DISCOVERY_CLIENT (clt)->avahi_client->avahi_client);
}
+const gchar *
+salut_avahi_discovery_client_get_dnssd_name (SalutAvahiDiscoveryClient *clt)
+{
+ SalutAvahiDiscoveryClientPrivate *priv =
+ SALUT_AVAHI_DISCOVERY_CLIENT_GET_PRIVATE (clt);
+
+ if (priv->dnssd_name != NULL)
+ return priv->dnssd_name;
+ else
+ return SALUT_DNSSD_PRESENCE;
+}
+
static void
discovery_client_init (gpointer g_iface,
gpointer iface_data)
diff --git a/src/salut-avahi-discovery-client.h b/src/salut-avahi-discovery-client.h
index 861f4d01..7d7c3121 100644
--- a/src/salut-avahi-discovery-client.h
+++ b/src/salut-avahi-discovery-client.h
@@ -47,6 +47,9 @@ struct _SalutAvahiDiscoveryClient {
GType salut_avahi_discovery_client_get_type (void);
+const gchar * salut_avahi_discovery_client_get_dnssd_name (
+ SalutAvahiDiscoveryClient *self);
+
/* TYPE MACROS */
#define SALUT_TYPE_AVAHI_DISCOVERY_CLIENT \
(salut_avahi_discovery_client_get_type ())
diff --git a/src/salut-avahi-self.c b/src/salut-avahi-self.c
index c37e8dfb..7ab6ca55 100644
--- a/src/salut-avahi-self.c
+++ b/src/salut-avahi-self.c
@@ -215,6 +215,7 @@ salut_avahi_self_announce (SalutSelf *_self,
SalutAvahiSelf *self = SALUT_AVAHI_SELF (_self);
SalutAvahiSelfPrivate *priv = self->priv;
AvahiStringList *txt_record = NULL;
+ const char *dnssd_name;
priv->presence_group = ga_entry_group_new ();
@@ -234,8 +235,11 @@ salut_avahi_self_announce (SalutSelf *_self,
txt_record = create_txt_record (self, port);
+ dnssd_name = salut_avahi_discovery_client_get_dnssd_name (
+ priv->discovery_client);
+
priv->presence = ga_entry_group_add_service_strlist (priv->presence_group,
- _self->name, SALUT_DNSSD_PRESENCE, port, error, txt_record);
+ _self->name, dnssd_name, port, error, txt_record);
if (priv->presence == NULL)
goto error;
@@ -309,7 +313,12 @@ salut_avahi_self_publish_avatar (SalutAvahiSelf *self,
gchar *name;
gboolean ret;
gboolean is_new = FALSE;
- name = g_strdup_printf ("%s." SALUT_DNSSD_PRESENCE ".local", _self->name);
+ const gchar *dnssd_name;
+
+ dnssd_name = salut_avahi_discovery_client_get_dnssd_name (
+ priv->discovery_client);
+
+ name = g_strdup_printf ("%s.%s.local", _self->name, dnssd_name);
if (priv->avatar_group == NULL)
{
diff --git a/src/salut-caps-hash.c b/src/salut-caps-hash.c
index 8cb3a764..620f9e9e 100644
--- a/src/salut-caps-hash.c
+++ b/src/salut-caps-hash.c
@@ -220,7 +220,7 @@ caps_hash_compute (
* helper function for _parse_dataform_field
*/
static gboolean
-_parse_dataform_field_form_type (GibberXmppNode *value_node, gpointer user_data)
+_parse_dataform_field_form_type (WockyNode *value_node, gpointer user_data)
{
DataformFieldParsingContext *dataform_field_context =
(DataformFieldParsingContext *) user_data;
@@ -245,7 +245,7 @@ _parse_dataform_field_form_type (GibberXmppNode *value_node, gpointer user_data)
* helper function for _parse_caps_item
*/
static gboolean
-_parse_dataform_field_values (GibberXmppNode *value_node, gpointer user_data)
+_parse_dataform_field_values (WockyNode *value_node, gpointer user_data)
{
DataformFieldParsingContext *dataform_field_context =
(DataformFieldParsingContext *) user_data;
@@ -265,7 +265,7 @@ _parse_dataform_field_values (GibberXmppNode *value_node, gpointer user_data)
* helper function for _parse_caps_item
*/
static gboolean
-_parse_dataform_field (GibberXmppNode *field_node, gpointer user_data)
+_parse_dataform_field (WockyNode *field_node, gpointer user_data)
{
DataformParsingContext *dataform_context =
(DataformParsingContext *) user_data;
@@ -274,7 +274,7 @@ _parse_dataform_field (GibberXmppNode *field_node, gpointer user_data)
if (tp_strdiff (field_node->name, "field"))
return TRUE;
- var = gibber_xmpp_node_get_attribute (field_node, "var");
+ var = wocky_node_get_attribute (field_node, "var");
if (NULL == var)
return TRUE;
@@ -286,7 +286,7 @@ _parse_dataform_field (GibberXmppNode *field_node, gpointer user_data)
dataform_field_context->dataform_context = dataform_context;
dataform_field_context->field = NULL;
- gibber_xmpp_node_each_child (field_node,
+ wocky_node_each_child (field_node,
_parse_dataform_field_form_type, dataform_field_context);
g_slice_free (DataformFieldParsingContext, dataform_field_context);
@@ -304,7 +304,7 @@ _parse_dataform_field (GibberXmppNode *field_node, gpointer user_data)
dataform_field_context->dataform_context = dataform_context;
dataform_field_context->field = field;
- gibber_xmpp_node_each_child (field_node,
+ wocky_node_each_child (field_node,
_parse_dataform_field_values, dataform_field_context);
g_slice_free (DataformFieldParsingContext, dataform_field_context);
@@ -321,7 +321,7 @@ _parse_dataform_field (GibberXmppNode *field_node, gpointer user_data)
* helper function for _parse_caps_item
*/
static DataForm *
-_parse_dataform (GibberXmppNode *node)
+_parse_dataform (WockyNode *node)
{
DataForm *form;
DataformParsingContext *dataform_context;
@@ -333,7 +333,7 @@ _parse_dataform (GibberXmppNode *node)
dataform_context = g_slice_new0 (DataformParsingContext);
dataform_context->form = form;
- gibber_xmpp_node_each_child (node, _parse_dataform_field, dataform_context);
+ wocky_node_each_child (node, _parse_dataform_field, dataform_context);
g_slice_free (DataformParsingContext, dataform_context);
@@ -345,12 +345,12 @@ _parse_dataform (GibberXmppNode *node)
}
/**
- * parse a XML child node from from a received GibberXmppStanza
+ * parse a XML child node from from a received WockyStanza
*
* helper function for caps_hash_compute_from_stanza
*/
static gboolean
-_parse_caps_item (GibberXmppNode *node, gpointer user_data)
+_parse_caps_item (WockyNode *node, gpointer user_data)
{
AllCapsData *caps_data = (AllCapsData *) user_data;
@@ -361,10 +361,10 @@ _parse_caps_item (GibberXmppNode *node, gpointer user_data)
const gchar *type;
const gchar *xmllang;
- category = gibber_xmpp_node_get_attribute (node, "category");
- name = gibber_xmpp_node_get_attribute (node, "name");
- type = gibber_xmpp_node_get_attribute (node, "type");
- xmllang = gibber_xmpp_node_get_attribute (node, "xml:lang");
+ category = wocky_node_get_attribute (node, "category");
+ name = wocky_node_get_attribute (node, "name");
+ type = wocky_node_get_attribute (node, "type");
+ xmllang = wocky_node_get_attribute (node, "xml:lang");
if (NULL == category)
return FALSE;
@@ -381,7 +381,7 @@ _parse_caps_item (GibberXmppNode *node, gpointer user_data)
else if (!tp_strdiff (node->name, "feature"))
{
const gchar *var;
- var = gibber_xmpp_node_get_attribute (node, "var");
+ var = wocky_node_get_attribute (node, "var");
if (NULL == var)
return FALSE;
@@ -393,8 +393,8 @@ _parse_caps_item (GibberXmppNode *node, gpointer user_data)
const gchar *xmlns;
const gchar *type;
- xmlns = gibber_xmpp_node_get_attribute (node, "xmlns");
- type = gibber_xmpp_node_get_attribute (node, "type");
+ xmlns = wocky_node_get_attribute (node, "xmlns");
+ type = wocky_node_get_attribute (node, "type");
if (tp_strdiff (xmlns, "jabber:x:data"))
return FALSE;
@@ -411,12 +411,12 @@ _parse_caps_item (GibberXmppNode *node, gpointer user_data)
/**
* Compute the hash as defined by the XEP-0115 from a received
- * GibberXmppStanza
+ * WockyStanza
*
* Returns: the hash. The called must free the returned hash with g_free().
*/
gchar *
-caps_hash_compute_from_stanza (GibberXmppNode *node)
+caps_hash_compute_from_stanza (WockyNode *node)
{
gchar *str;
AllCapsData *caps_data;
@@ -426,7 +426,7 @@ caps_hash_compute_from_stanza (GibberXmppNode *node)
caps_data->identities = g_ptr_array_new ();
caps_data->dataforms = g_ptr_array_new ();
- gibber_xmpp_node_each_child (node, _parse_caps_item, caps_data);
+ wocky_node_each_child (node, _parse_caps_item, caps_data);
str = caps_hash_compute (caps_data->features, caps_data->identities,
caps_data->dataforms);
diff --git a/src/salut-caps-hash.h b/src/salut-caps-hash.h
index 26be0230..1e2c3f8b 100644
--- a/src/salut-caps-hash.h
+++ b/src/salut-caps-hash.h
@@ -24,9 +24,9 @@
#include "salut-self.h"
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
-gchar *caps_hash_compute_from_stanza (GibberXmppNode *node);
+gchar *caps_hash_compute_from_stanza (WockyNode *node);
gchar *caps_hash_compute_from_self_presence (SalutSelf *self);
#endif /* __SALUT_CAPS_HASH_H__ */
diff --git a/src/salut-connection-manager.c b/src/salut-connection-manager.c
index afa3d47a..86434ddb 100644
--- a/src/salut-connection-manager.c
+++ b/src/salut-connection-manager.c
@@ -32,6 +32,7 @@
#include "protocol.h"
#include "salut-connection.h"
#include "debug.h"
+#include "plugin-loader.h"
/* properties */
enum
@@ -118,12 +119,23 @@ salut_connection_manager_constructed (GObject *object)
TpBaseConnectionManager *base = (TpBaseConnectionManager *) self;
void (*constructed) (GObject *) =
((GObjectClass *) salut_connection_manager_parent_class)->constructed;
+ SalutPluginLoader *loader;
if (constructed != NULL)
constructed (object);
- self->priv->protocol = salut_protocol_new (self->priv->backend_type);
+ self->priv->protocol = salut_protocol_new (self->priv->backend_type,
+ NULL,
+ SALUT_PROTOCOL_LOCAL_XMPP_NAME,
+ SALUT_PROTOCOL_LOCAL_XMPP_ENGLISH_NAME,
+ SALUT_PROTOCOL_LOCAL_XMPP_ICON_NAME);
tp_base_connection_manager_add_protocol (base, self->priv->protocol);
+
+ loader = salut_plugin_loader_dup ();
+
+ salut_plugin_loader_initialize (loader, base);
+
+ g_object_unref (loader);
}
static void
diff --git a/src/salut-connection.c b/src/salut-connection.c
index 9a305123..b5ba23d7 100644
--- a/src/salut-connection.c
+++ b/src/salut-connection.c
@@ -65,6 +65,8 @@
#include "salut-util.h"
#include "salut-xmpp-connection-manager.h"
+#include "plugin-loader.h"
+
#ifdef ENABLE_OLPC
#include "salut-olpc-activity-manager.h"
#endif
@@ -132,11 +134,11 @@ G_DEFINE_TYPE_WITH_CODE(SalutConnection,
#ifdef ENABLE_OLPC
static gboolean uninvite_stanza_filter (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
static void uninvite_stanza_callback (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
#endif
@@ -160,6 +162,7 @@ enum {
PROP_OLPC_ACTIVITY_MANAGER,
#endif
PROP_BACKEND,
+ PROP_DNSSD_NAME,
LAST_PROP
};
@@ -218,6 +221,9 @@ struct _SalutConnectionPrivate
/* Backend type: avahi or dummy */
GType backend_type;
+
+ /* DNS-SD name, used for the avahi backend */
+ gchar *dnssd_name;
};
typedef struct _ChannelRequest ChannelRequest;
@@ -428,6 +434,9 @@ salut_connection_get_property (GObject *object,
case PROP_BACKEND:
g_value_set_gtype (value, priv->backend_type);
break;
+ case PROP_DNSSD_NAME:
+ g_value_set_string (value, priv->dnssd_name);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -472,9 +481,13 @@ salut_connection_set_property (GObject *object,
priv->backend_type = g_value_get_gtype (value);
/* Create the backend object */
priv->discovery_client = g_object_new (priv->backend_type,
+ "dnssd-name", priv->dnssd_name,
NULL);
g_assert (priv->discovery_client != NULL);
break;
+ case PROP_DNSSD_NAME:
+ priv->dnssd_name = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -870,6 +883,11 @@ salut_connection_class_init (SalutConnectionClass *salut_connection_class)
g_object_class_install_property (object_class, PROP_BACKEND,
param_spec);
+ param_spec = g_param_spec_string ("dnssd-name", "DNS-SD name",
+ "The DNS-SD name of the protocol", "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_DNSSD_NAME,
+ param_spec);
}
void
@@ -965,6 +983,7 @@ salut_connection_finalize (GObject *object)
g_array_free (priv->olpc_key, TRUE);
g_free (priv->olpc_color);
#endif
+ g_free (priv->dnssd_name);
tp_contacts_mixin_finalize (G_OBJECT(self));
@@ -2999,10 +3018,10 @@ void
salut_connection_olpc_observe_invitation (SalutConnection *self,
TpHandle room,
TpHandle inviter_handle,
- GibberXmppNode *invite_node)
+ WockyNode *invite_node)
{
SalutConnectionPrivate *priv = self->priv;
- GibberXmppNode *props_node;
+ WockyNode *props_node;
GHashTable *properties;
const gchar *activity_id, *color = NULL, *activity_name = NULL,
*activity_type = NULL, *tags = NULL;
@@ -3011,7 +3030,7 @@ salut_connection_olpc_observe_invitation (SalutConnection *self,
SalutMucChannel *muc;
muc_ready_ctx *ctx;
- props_node = gibber_xmpp_node_get_child_ns (invite_node, "properties",
+ props_node = wocky_node_get_child_ns (invite_node, "properties",
GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS);
if (props_node == NULL)
@@ -3022,7 +3041,7 @@ salut_connection_olpc_observe_invitation (SalutConnection *self,
if (inviter == NULL)
return;
- properties = salut_gibber_xmpp_node_extract_properties (props_node,
+ properties = salut_wocky_node_extract_properties (props_node,
"property");
if (!extract_properties_from_hash (properties, &activity_id, &color,
@@ -3195,18 +3214,18 @@ _olpc_activity_manager_activity_modified_cb (SalutOlpcActivityManager *mgr,
gboolean
salut_connection_olpc_observe_muc_stanza (SalutConnection *self,
- TpHandle room, TpHandle sender, GibberXmppStanza *stanza)
+ TpHandle room, TpHandle sender, WockyStanza *stanza)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
SalutConnectionPrivate *priv = self->priv;
- GibberXmppNode *props_node;
+ WockyNode *props_node;
GHashTable *properties;
const gchar *activity_id, *color = NULL, *activity_name = NULL,
*activity_type = NULL, *tags = NULL;
gboolean is_private = FALSE;
SalutOlpcActivity *activity;
- props_node = gibber_xmpp_node_get_child_ns (node, "properties",
+ props_node = wocky_node_get_child_ns (node, "properties",
GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS);
if (props_node == NULL)
@@ -3221,7 +3240,7 @@ salut_connection_olpc_observe_muc_stanza (SalutConnection *self,
return FALSE;
}
- properties = salut_gibber_xmpp_node_extract_properties (props_node,
+ properties = salut_wocky_node_extract_properties (props_node,
"property");
if (!extract_properties_from_hash (properties, &activity_id, &color,
@@ -3238,7 +3257,7 @@ salut_connection_olpc_observe_muc_stanza (SalutConnection *self,
static gboolean
uninvite_stanza_filter (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza, SalutContact *contact,
+ GibberXmppConnection *conn, WockyStanza *stanza, SalutContact *contact,
gpointer user_data)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
@@ -3249,14 +3268,14 @@ uninvite_stanza_filter (SalutXmppConnectionManager *mgr,
static void
uninvite_stanza_callback (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza, SalutContact *contact,
+ GibberXmppConnection *conn, WockyStanza *stanza, SalutContact *contact,
gpointer user_data)
{
SalutConnection *self = SALUT_CONNECTION (user_data);
SalutConnectionPrivate *priv = self->priv;
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
(TpBaseConnection *) self, TP_HANDLE_TYPE_ROOM);
- GibberXmppNode *node;
+ WockyNode *node;
TpHandle room_handle;
const gchar *room, *activity_id;
SalutOlpcActivity *activity;
@@ -3266,7 +3285,7 @@ uninvite_stanza_callback (SalutXmppConnectionManager *mgr,
GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS);
g_assert (node != NULL);
- room = gibber_xmpp_node_get_attribute (node, "room");
+ room = wocky_node_get_attribute (node, "room");
if (room == NULL)
{
DEBUG ("No room attribute");
@@ -3280,7 +3299,7 @@ uninvite_stanza_callback (SalutXmppConnectionManager *mgr,
return;
}
- activity_id = gibber_xmpp_node_get_attribute (node, "id");
+ activity_id = wocky_node_get_attribute (node, "id");
if (activity_id == NULL)
{
DEBUG ("No id attribute");
@@ -3399,12 +3418,21 @@ muc_manager_new_channels_cb (TpChannelManager *channel_manager,
}
#endif
+static void
+add_to_array (gpointer data,
+ gpointer user_data)
+{
+ g_ptr_array_add (user_data, data);
+}
+
static GPtrArray *
salut_connection_create_channel_managers (TpBaseConnection *base)
{
SalutConnection *self = SALUT_CONNECTION (base);
SalutConnectionPrivate *priv = self->priv;
GPtrArray *managers = g_ptr_array_sized_new (1);
+ GPtrArray *tmp;
+ SalutPluginLoader *loader;
/* FIXME: The second and third arguments depend on create_channel_factories
* being called before this; should telepathy-glib guarantee that or
@@ -3441,6 +3469,14 @@ salut_connection_create_channel_managers (TpBaseConnection *base)
G_CALLBACK (muc_manager_new_channels_cb), self);
#endif
+ /* plugin channel managers */
+ loader = salut_plugin_loader_dup ();
+ tmp = salut_plugin_loader_create_channel_managers (loader, base);
+ g_object_unref (loader);
+
+ g_ptr_array_foreach (tmp, add_to_array, managers);
+ g_ptr_array_free (tmp, TRUE);
+
return managers;
}
diff --git a/src/salut-connection.h b/src/salut-connection.h
index 449197d0..eb530581 100644
--- a/src/salut-connection.h
+++ b/src/salut-connection.h
@@ -33,7 +33,7 @@
#include <telepathy-glib/presence-mixin.h>
#include <telepathy-glib/svc-connection.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
G_BEGIN_DECLS
@@ -94,11 +94,11 @@ typedef enum {
#ifdef ENABLE_OLPC
void
salut_connection_olpc_observe_invitation (SalutConnection *connection,
- TpHandle room, TpHandle invitor_handle, GibberXmppNode *invite_node);
+ TpHandle room, TpHandle invitor_handle, WockyNode *invite_node);
gboolean
salut_connection_olpc_observe_muc_stanza (SalutConnection *self, TpHandle room,
- TpHandle sender, GibberXmppStanza *stanza);
+ TpHandle sender, WockyStanza *stanza);
#endif
const gchar * const *salut_connection_get_implemented_interfaces (void);
diff --git a/src/salut-contact-channel.c b/src/salut-contact-channel.c
index 483096ff..e82053a7 100644
--- a/src/salut-contact-channel.c
+++ b/src/salut-contact-channel.c
@@ -98,7 +98,7 @@ salut_contact_channel_constructor (GType type, guint n_props,
GObjectConstructParam *props)
{
GObject *obj;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
SalutContactChannelPrivate *priv;
TpHandleRepoIface *handle_repo;
TpHandleRepoIface *contact_repo;
@@ -111,12 +111,11 @@ salut_contact_channel_constructor (GType type, guint n_props,
priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE (SALUT_CONTACT_CHANNEL (obj));
/* Connect to the bus */
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ base_conn = TP_BASE_CONNECTION (priv->conn);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
/* Ref our handle */
- base_conn = TP_BASE_CONNECTION(priv->conn);
-
handle_repo = tp_base_connection_get_handles (base_conn,
TP_HANDLE_TYPE_LIST);
contact_repo = tp_base_connection_get_handles (base_conn,
@@ -387,12 +386,6 @@ salut_contact_channel_finalize (GObject *object)
*
* Implements DBus method GetChannelType
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_contact_channel_get_channel_type (TpSvcChannel *iface,
@@ -408,12 +401,6 @@ salut_contact_channel_get_channel_type (TpSvcChannel *iface,
*
* Implements DBus method GetHandle
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_contact_channel_get_handle (TpSvcChannel *iface,
@@ -432,12 +419,6 @@ salut_contact_channel_get_handle (TpSvcChannel *iface,
*
* Implements DBus method GetInterfaces
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_contact_channel_get_interfaces (TpSvcChannel *iface,
diff --git a/src/salut-disco.c b/src/salut-disco.c
index d5e2767b..085bf9af 100644
--- a/src/salut-disco.c
+++ b/src/salut-disco.c
@@ -186,8 +186,8 @@ notify_delete_request (gpointer data, GObject *obj)
static void
request_reply_cb (GibberIqHelper *helper,
- GibberXmppStanza *sent_stanza,
- GibberXmppStanza *reply_stanza,
+ WockyStanza *sent_stanza,
+ WockyStanza *reply_stanza,
GObject *object,
gpointer user_data)
{
@@ -195,21 +195,21 @@ request_reply_cb (GibberIqHelper *helper,
SalutDisco *disco = SALUT_DISCO (object);
SalutDiscoPrivate *priv = disco->priv;
WockyNode *reply_node = wocky_stanza_get_top_node (reply_stanza);
- GibberXmppNode *query_node;
+ WockyNode *query_node;
GError *err = NULL;
- GibberStanzaSubType sub_type;
+ WockyStanzaSubType sub_type;
g_assert (request);
if (!g_list_find (priv->requests, request))
return;
- query_node = gibber_xmpp_node_get_child_ns (reply_node,
+ query_node = wocky_node_get_child_ns (reply_node,
"query", disco_type_to_xmlns (request->type));
- gibber_xmpp_stanza_get_type_info (reply_stanza, NULL, &sub_type);
+ wocky_stanza_get_type_info (reply_stanza, NULL, &sub_type);
- if (sub_type == GIBBER_STANZA_SUB_TYPE_ERROR)
+ if (sub_type == WOCKY_STANZA_SUB_TYPE_ERROR)
{
err = gibber_message_get_xmpp_error (reply_stanza);
@@ -242,7 +242,7 @@ send_disco_request (SalutDisco *self,
{
SalutDiscoPrivate *priv = self->priv;
TpBaseConnection *base_conn = TP_BASE_CONNECTION (priv->connection);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
TpHandleRepoIface *contact_repo;
const gchar *jid_from, *jid_to;
GError *error = NULL;
@@ -253,14 +253,14 @@ send_disco_request (SalutDisco *self,
jid_from = tp_handle_inspect (contact_repo, base_conn->self_handle);
jid_to = tp_handle_inspect (contact_repo, contact->handle);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
jid_from, jid_to,
- GIBBER_NODE, "query",
- GIBBER_NODE_XMLNS, disco_type_to_xmlns (request->type),
- GIBBER_NODE_ATTRIBUTE, "node", request->node,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "query",
+ WOCKY_NODE_XMLNS, disco_type_to_xmlns (request->type),
+ WOCKY_NODE_ATTRIBUTE, "node", request->node,
+ WOCKY_NODE_END,
+ NULL);
request->requested = TRUE;
@@ -401,16 +401,16 @@ salut_disco_set_property (GObject *object,
static gboolean
caps_req_stanza_filter (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
- GibberStanzaSubType sub_type;
- GibberXmppNode *query;
+ WockyStanzaSubType sub_type;
+ WockyNode *query;
- gibber_xmpp_stanza_get_type_info (stanza, NULL, &sub_type);
+ wocky_stanza_get_type_info (stanza, NULL, &sub_type);
- if (sub_type != GIBBER_STANZA_SUB_TYPE_GET)
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_GET)
return FALSE;
query = wocky_node_get_child_ns (wocky_stanza_get_top_node (stanza), "query",
@@ -429,26 +429,26 @@ send_item_not_found (GibberXmppConnection *conn,
const gchar *to,
const gchar *id)
{
- GibberXmppStanza *result;
+ WockyStanza *result;
/* Return <item-not-found>. It is possible that the remote contact
* requested an old version (old hash) of our capabilities. In the
* meantime, it will have gotten a new hash, and query the new hash
* anyway. */
- result = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_ERROR,
+ result = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_ERROR,
from, to,
- GIBBER_NODE, "query",
- GIBBER_NODE_XMLNS, NS_DISCO_INFO,
- GIBBER_NODE_ATTRIBUTE, "node", node,
- GIBBER_NODE, "error",
- GIBBER_NODE_ATTRIBUTE, "type", "cancel",
- GIBBER_NODE, "item-not-found",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_STANZAS,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "query",
+ WOCKY_NODE_XMLNS, NS_DISCO_INFO,
+ WOCKY_NODE_ATTRIBUTE, "node", node,
+ WOCKY_NODE_START, "error",
+ WOCKY_NODE_ATTRIBUTE, "type", "cancel",
+ WOCKY_NODE_START, "item-not-found",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_STANZAS,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
if (id != NULL)
wocky_node_set_attribute (wocky_stanza_get_top_node (result), "id", id);
@@ -476,20 +476,20 @@ add_feature_foreach (gpointer ns,
static void
caps_req_stanza_callback (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
SalutDisco *self = SALUT_DISCO (user_data);
SalutDiscoPrivate *priv = self->priv;
TpBaseConnection *base_conn = TP_BASE_CONNECTION (priv->connection);
- GibberXmppNode *iq, *result_iq, *query, *result_query;
+ WockyNode *iq, *result_iq, *query, *result_query;
const gchar *node;
const gchar *suffix;
TpHandleRepoIface *contact_repo;
const gchar *jid_from, *jid_to, *id;
SalutSelf *salut_self;
- GibberXmppStanza *result;
+ WockyStanza *result;
const GabbleCapabilitySet *caps;
contact_repo = tp_base_connection_get_handles (base_conn,
@@ -499,10 +499,10 @@ caps_req_stanza_callback (SalutXmppConnectionManager *mgr,
iq = wocky_stanza_get_top_node (stanza);
id = wocky_node_get_attribute (iq, "id");
- query = gibber_xmpp_node_get_child_ns (iq, "query", NS_DISCO_INFO);
+ query = wocky_node_get_child_ns (iq, "query", NS_DISCO_INFO);
g_assert (query != NULL);
- node = gibber_xmpp_node_get_attribute (query, "node");
+ node = wocky_node_get_attribute (query, "node");
if (node == NULL)
{
send_item_not_found (conn, "", jid_from, jid_to, id);
@@ -534,24 +534,24 @@ caps_req_stanza_callback (SalutXmppConnectionManager *mgr,
/* Every entity MUST have at least one identity (XEP-0030). Salut publishs
* one identity. If you change the identity here, you also need to change
* caps_hash_compute_from_self_presence(). */
- result = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_RESULT,
+ result = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_RESULT,
jid_from, jid_to,
- GIBBER_NODE, "query",
- GIBBER_NODE_XMLNS, NS_DISCO_INFO,
- GIBBER_NODE_ATTRIBUTE, "node", node,
- GIBBER_NODE, "identity",
- GIBBER_NODE_ATTRIBUTE, "category", "client",
- GIBBER_NODE_ATTRIBUTE, "name", PACKAGE_STRING,
+ WOCKY_NODE_START, "query",
+ WOCKY_NODE_XMLNS, NS_DISCO_INFO,
+ WOCKY_NODE_ATTRIBUTE, "node", node,
+ WOCKY_NODE_START, "identity",
+ WOCKY_NODE_ATTRIBUTE, "category", "client",
+ WOCKY_NODE_ATTRIBUTE, "name", PACKAGE_STRING,
/* FIXME: maybe we should add a connection property allowing to
* set the type attribute instead of hardcoding "pc". */
- GIBBER_NODE_ATTRIBUTE, "type", "pc",
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "type", "pc",
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
result_iq = wocky_stanza_get_top_node (result);
- result_query = gibber_xmpp_node_get_child_ns (result_iq, "query", NULL);
+ result_query = wocky_node_get_child_ns (result_iq, "query", NULL);
caps = salut_self_get_caps (salut_self);
gabble_capability_set_foreach (caps, add_feature_foreach, result_query);
diff --git a/src/salut-disco.h b/src/salut-disco.h
index e43f48cc..6016f0ca 100644
--- a/src/salut-disco.h
+++ b/src/salut-disco.h
@@ -25,8 +25,7 @@
#define __SALUT_DISCO_H__
#include <glib-object.h>
-#include <gibber/gibber-xmpp-stanza.h>
-#include <gibber/gibber-xmpp-node.h>
+#include <wocky/wocky-stanza.h>
#include "salut-contact.h"
#include "salut-connection.h"
@@ -86,7 +85,7 @@ struct _SalutDisco {
};
typedef void (*SalutDiscoCb)(SalutDisco *self, SalutDiscoRequest *request,
- SalutContact *contact, const gchar *node, GibberXmppNode *query_result,
+ SalutContact *contact, const gchar *node, WockyNode *query_result,
GError* error, gpointer user_data);
SalutDisco *salut_disco_new (SalutConnection *connection,
diff --git a/src/salut-discovery-client.c b/src/salut-discovery-client.c
index 159e7b18..181832d8 100644
--- a/src/salut-discovery-client.c
+++ b/src/salut-discovery-client.c
@@ -130,6 +130,16 @@ salut_discovery_client_base_init (gpointer klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_interface_install_property (klass, param_spec);
+ /* Defined here so we can g_object_set this property on the
+ * discovery client without needing to define it everywhere. Now
+ * classes which implement this interface just need to override
+ * the property to use it.. */
+ param_spec = g_param_spec_string (
+ "dnssd-name", "DNS-SD name",
+ "The DNS-SD name of the protocol", "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_interface_install_property (klass, param_spec);
+
initialized = TRUE;
}
}
diff --git a/src/salut-file-transfer-channel.c b/src/salut-file-transfer-channel.c
index 687f5e8b..e5f90116 100644
--- a/src/salut-file-transfer-channel.c
+++ b/src/salut-file-transfer-channel.c
@@ -41,7 +41,7 @@
#include "salut-im-manager.h"
#include "salut-contact.h"
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-file-transfer.h>
#include <gibber/gibber-oob-file-transfer.h>
#include <gibber/gibber-iq-helper.h>
@@ -104,6 +104,7 @@ enum
PROP_AVAILABLE_SOCKET_TYPES,
PROP_TRANSFERRED_BYTES,
PROP_INITIAL_OFFSET,
+ PROP_URI,
PROP_CONTACT,
PROP_CONNECTION,
@@ -140,6 +141,7 @@ struct _SalutFileTransferChannelPrivate {
guint64 transferred_bytes;
guint64 initial_offset;
guint64 date;
+ gchar *uri;
};
static void
@@ -285,32 +287,48 @@ salut_file_transfer_channel_get_property (GObject *object,
case PROP_DATE:
g_value_set_uint64 (value, self->priv->date);
break;
+ case PROP_URI:
+ g_value_set_string (value,
+ self->priv->uri != NULL ? self->priv->uri : "");
+ break;
case PROP_CHANNEL_DESTROYED:
g_value_set_boolean (value, self->priv->closed);
break;
case PROP_CHANNEL_PROPERTIES:
- g_value_take_boxed (value,
- tp_dbus_properties_mixin_make_properties_hash (object,
- TP_IFACE_CHANNEL, "ChannelType",
- TP_IFACE_CHANNEL, "Interfaces",
- TP_IFACE_CHANNEL, "TargetHandle",
- TP_IFACE_CHANNEL, "TargetID",
- TP_IFACE_CHANNEL, "TargetHandleType",
- TP_IFACE_CHANNEL, "Requested",
- TP_IFACE_CHANNEL, "InitiatorHandle",
- TP_IFACE_CHANNEL, "InitiatorID",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "State",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentType",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Filename",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Size",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentHashType",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentHash",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Description",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Date",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "AvailableSocketTypes",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "TransferredBytes",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "InitialOffset",
- NULL));
+ {
+ GHashTable *props;
+
+ props = tp_dbus_properties_mixin_make_properties_hash (object,
+ TP_IFACE_CHANNEL, "ChannelType",
+ TP_IFACE_CHANNEL, "Interfaces",
+ TP_IFACE_CHANNEL, "TargetHandle",
+ TP_IFACE_CHANNEL, "TargetID",
+ TP_IFACE_CHANNEL, "TargetHandleType",
+ TP_IFACE_CHANNEL, "Requested",
+ TP_IFACE_CHANNEL, "InitiatorHandle",
+ TP_IFACE_CHANNEL, "InitiatorID",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "State",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentType",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Filename",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Size",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentHashType",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "ContentHash",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Description",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "Date",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "AvailableSocketTypes",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "TransferredBytes",
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "InitialOffset",
+ NULL);
+
+ /* URI is immutable only for outgoing transfers */
+ if (self->priv->initiator == base_conn->self_handle)
+ {
+ tp_dbus_properties_mixin_fill_properties_hash (object, props,
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "URI", NULL);
+ }
+
+ g_value_take_boxed (value, props);
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -392,6 +410,10 @@ salut_file_transfer_channel_set_property (GObject *object,
case PROP_INITIAL_OFFSET:
self->priv->initial_offset = g_value_get_uint64 (value);
break;
+ case PROP_URI:
+ g_assert (self->priv->uri == NULL); /* construct only */
+ self->priv->uri = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -411,7 +433,7 @@ salut_file_transfer_channel_constructor (GType type,
{
GObject *obj;
SalutFileTransferChannel *self;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
TpBaseConnection *base_conn;
TpHandleRepoIface *contact_repo;
GArray *unix_access;
@@ -435,8 +457,8 @@ salut_file_transfer_channel_constructor (GType type,
base_conn->object_path, self);
/* Connect to the bus */
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, self->priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, self->priv->object_path, obj);
/* Initialise the available socket types hash table */
self->priv->available_socket_types = g_hash_table_new_full (g_direct_hash,
@@ -457,6 +479,10 @@ salut_file_transfer_channel_constructor (GType type,
tp_handle_inspect (contact_repo, self->priv->initiator),
self->priv->filename, self->priv->size);
+ if (self->priv->initiator != base_conn->self_handle)
+ /* Incoming transfer, URI has to be set by the handler */
+ g_assert (self->priv->uri == NULL);
+
return obj;
}
@@ -465,6 +491,55 @@ salut_file_transfer_channel_dispose (GObject *object);
static void
salut_file_transfer_channel_finalize (GObject *object);
+static gboolean
+file_transfer_channel_properties_setter (GObject *object,
+ GQuark interface,
+ GQuark name,
+ const GValue *value,
+ gpointer setter_data,
+ GError **error)
+{
+ SalutFileTransferChannel *self = (SalutFileTransferChannel *) object;
+ TpBaseConnection *base_conn = TP_BASE_CONNECTION (self->priv->connection);
+
+ g_return_val_if_fail (interface == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER,
+ FALSE);
+
+ /* There is only one property with write access. So TpDBusPropertiesMixin
+ * already checked this. */
+ g_assert (name == g_quark_from_static_string ("URI"));
+
+ /* TpDBusPropertiesMixin already checked this */
+ g_assert (G_VALUE_HOLDS_STRING (value));
+
+ if (self->priv->uri != NULL)
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "URI has already be set");
+ return FALSE;
+ }
+
+ if (self->priv->initiator == base_conn->self_handle)
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Channel is not an incoming transfer");
+ return FALSE;
+ }
+
+ if (self->priv->state != TP_FILE_TRANSFER_STATE_PENDING)
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "State is not pending; cannot set URI");
+ return FALSE;
+ }
+
+ self->priv->uri = g_value_dup_string (value);
+
+ tp_svc_channel_type_file_transfer_emit_uri_defined (self, self->priv->uri);
+
+ return TRUE;
+}
+
static void
salut_file_transfer_channel_class_init (
SalutFileTransferChannelClass *salut_file_transfer_channel_class)
@@ -497,6 +572,7 @@ salut_file_transfer_channel_class_init (
{ "TransferredBytes", "transferred-bytes", NULL },
{ "InitialOffset", "initial-offset", NULL },
{ "Date", "date", "date" },
+ { "URI", "uri", NULL },
{ NULL }
};
@@ -508,7 +584,7 @@ salut_file_transfer_channel_class_init (
},
{ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
tp_dbus_properties_mixin_getter_gobject_properties,
- tp_dbus_properties_mixin_setter_gobject_properties,
+ file_transfer_channel_properties_setter,
file_props
},
{ NULL }
@@ -744,6 +820,14 @@ salut_file_transfer_channel_class_init (
g_object_class_install_property (object_class, PROP_DATE,
param_spec);
+ param_spec = g_param_spec_string (
+ "uri", "URI",
+ "URI of the file being transferred",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_URI,
+ param_spec);
+
salut_file_transfer_channel_class->dbus_props_class.interfaces = \
prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
@@ -819,6 +903,7 @@ salut_file_transfer_channel_finalize (GObject *object)
g_free (self->priv->content_hash);
g_free (self->priv->description);
g_hash_table_destroy (self->priv->available_socket_types);
+ g_free (self->priv->uri);
G_OBJECT_CLASS (salut_file_transfer_channel_parent_class)->finalize (object);
}
@@ -1530,7 +1615,8 @@ salut_file_transfer_channel_new (SalutConnection *conn,
const gchar *content_hash,
const gchar *description,
guint64 date,
- guint64 initial_offset)
+ guint64 initial_offset,
+ const gchar *file_uri)
{
return g_object_new (SALUT_TYPE_FILE_TRANSFER_CHANNEL,
"connection", conn,
@@ -1547,6 +1633,7 @@ salut_file_transfer_channel_new (SalutConnection *conn,
"description", description,
"date", date,
"initial-offset", initial_offset,
+ "uri", file_uri,
NULL);
}
@@ -1556,7 +1643,7 @@ salut_file_transfer_channel_new_from_stanza (SalutConnection *connection,
TpHandle handle,
SalutXmppConnectionManager *xcm,
TpFileTransferState state,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GibberXmppConnection *conn)
{
GError *error = NULL;
@@ -1570,7 +1657,7 @@ salut_file_transfer_channel_new_from_stanza (SalutConnection *connection,
if (ft == NULL)
{
/* Reply with an error */
- GibberXmppStanza *reply;
+ WockyStanza *reply;
DEBUG ("%s", error->message);
reply = gibber_iq_helper_new_error_reply (stanza, XMPP_ERROR_BAD_REQUEST,
diff --git a/src/salut-file-transfer-channel.h b/src/salut-file-transfer-channel.h
index 7acfd49b..c172a169 100644
--- a/src/salut-file-transfer-channel.h
+++ b/src/salut-file-transfer-channel.h
@@ -80,12 +80,12 @@ SalutFileTransferChannel * salut_file_transfer_channel_new (
TpFileTransferState state, const gchar *content_type,
const gchar *filename, guint64 size, TpFileHashType hash_type,
const gchar *content_hash, const gchar *description, guint64 date,
- guint64 initial_offset);
+ guint64 initial_offset, const gchar *file_uri);
SalutFileTransferChannel * salut_file_transfer_channel_new_from_stanza (
SalutConnection *connection, SalutContact *contact,
TpHandle handle, SalutXmppConnectionManager *xcm,
- TpFileTransferState state, GibberXmppStanza *stanza,
+ TpFileTransferState state, WockyStanza *stanza,
GibberXmppConnection *conn);
G_END_DECLS
diff --git a/src/salut-ft-manager.c b/src/salut-ft-manager.c
index 64f7f5b4..10025f11 100644
--- a/src/salut-ft-manager.c
+++ b/src/salut-ft-manager.c
@@ -94,7 +94,7 @@ salut_ft_manager_init (SalutFtManager *obj)
static gboolean
message_stanza_filter (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -104,7 +104,7 @@ message_stanza_filter (SalutXmppConnectionManager *mgr,
static void
message_stanza_callback (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -296,6 +296,7 @@ salut_ft_manager_handle_request (TpChannelManager *manager,
TpHandle handle;
const gchar *content_type, *filename, *content_hash, *description;
guint64 size, date, initial_offset;
+ const gchar *file_uri;
TpFileHashType content_hash_type;
GError *error = NULL;
gboolean valid;
@@ -399,6 +400,9 @@ salut_ft_manager_handle_request (TpChannelManager *manager,
initial_offset = tp_asv_get_uint64 (request_properties,
TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".InitialOffset", NULL);
+ file_uri = tp_asv_get_string (request_properties,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_URI);
+
contact = salut_contact_manager_get_contact (priv->contact_manager, handle);
if (contact == NULL)
{
@@ -416,7 +420,8 @@ salut_ft_manager_handle_request (TpChannelManager *manager,
chan = salut_file_transfer_channel_new (priv->connection, contact,
handle, priv->xmpp_connection_manager, base_connection->self_handle,
TP_FILE_TRANSFER_STATE_PENDING, content_type, filename, size,
- content_hash_type, content_hash, description, date, initial_offset);
+ content_hash_type, content_hash, description, date, initial_offset,
+ file_uri);
g_object_unref (contact);
@@ -449,17 +454,20 @@ static const gchar * const file_transfer_channel_fixed_properties[] = {
static const gchar * const file_transfer_channel_allowed_properties[] =
{
- TP_IFACE_CHANNEL ".TargetHandle",
- TP_IFACE_CHANNEL ".TargetID",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentType",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Filename",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Size",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHashType",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHash",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Description",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Date",
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".InitialOffset",
- NULL
+ /* ContentHashType has to be first so we can easily skip it if needed (we
+ * currently don't as Salut doesn't support any hash mechanism) */
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE,
+ TP_PROP_CHANNEL_TARGET_HANDLE,
+ TP_PROP_CHANNEL_TARGET_ID,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DESCRIPTION,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_INITIAL_OFFSET,
+ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_URI,
+ NULL
};
static void
diff --git a/src/salut-im-channel.c b/src/salut-im-channel.c
index 2cdf0f2e..b48a5d05 100644
--- a/src/salut-im-channel.c
+++ b/src/salut-im-channel.c
@@ -37,7 +37,7 @@
#include <gibber/gibber-linklocal-transport.h>
#include <gibber/gibber-namespaces.h>
#include <gibber/gibber-xmpp-connection.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#define DEBUG_FLAG DEBUG_IM
#include "debug.h"
@@ -74,11 +74,11 @@ static const gchar *salut_im_channel_interfaces[] = {
};
static gboolean message_stanza_filter (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
static void message_stanza_callback (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
/* Channel state */
@@ -139,7 +139,7 @@ struct _SalutImChannelMessage {
guint type;
gchar *text;
gchar *token;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
};
static void
@@ -175,7 +175,7 @@ static SalutImChannelMessage *
salut_im_channel_message_new (guint type,
const gchar *text,
const gchar *token,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
SalutImChannelMessage *msg;
msg = g_new0 (SalutImChannelMessage, 1);
@@ -203,7 +203,7 @@ salut_im_channel_message_free (SalutImChannelMessage *message)
static gboolean
_send_message (SalutImChannel *self, guint type, const gchar *text,
- const gchar *token, GibberXmppStanza *stanza, GError **error);
+ const gchar *token, WockyStanza *stanza, GError **error);
static void
salut_im_channel_init (SalutImChannel *obj)
@@ -296,6 +296,10 @@ salut_im_channel_get_property (GObject *object,
TP_IFACE_CHANNEL, "InitiatorID",
TP_IFACE_CHANNEL, "Requested",
TP_IFACE_CHANNEL, "Interfaces",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessagePartSupportFlags",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "DeliveryReportingSupport",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "SupportedContentTypes",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessageTypes",
NULL));
break;
default:
@@ -365,7 +369,7 @@ salut_im_channel_constructor (GType type,
GObjectConstructParam *props)
{
GObject *obj;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
SalutImChannelPrivate *priv;
TpBaseConnection *base_conn;
TpHandleRepoIface *contact_repo;
@@ -408,8 +412,8 @@ salut_im_channel_constructor (GType type,
supported_content_types);
/* Connect to the bus */
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
g_signal_connect (priv->xmpp_connection_manager, "new-connection",
G_CALLBACK (xmpp_connection_manager_new_connection_cb), obj);
@@ -604,7 +608,7 @@ _sendout_message (SalutImChannel *self,
guint type,
const gchar *text,
const gchar *token,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self);
@@ -663,7 +667,7 @@ _error_flush_queue (SalutImChannel *self) {
void
salut_im_channel_received_stanza (SalutImChannel *self,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self);
TpBaseConnection *base_conn = (TpBaseConnection *) priv->connection;
@@ -695,7 +699,7 @@ salut_im_channel_received_stanza (SalutImChannel *self,
static gboolean
message_stanza_filter (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -711,7 +715,7 @@ message_stanza_filter (SalutXmppConnectionManager *mgr,
static void
message_stanza_callback (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -904,7 +908,7 @@ _send_message (SalutImChannel *self,
guint type,
const gchar *text,
const gchar *token,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GError **error)
{
SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self);
@@ -951,12 +955,12 @@ salut_im_channel_add_connection (SalutImChannel *chan,
}
gboolean
-salut_im_channel_is_text_message (GibberXmppStanza *stanza)
+salut_im_channel_is_text_message (WockyStanza *stanza)
{
- GibberStanzaType type;
+ WockyStanzaType type;
- gibber_xmpp_stanza_get_type_info (stanza, &type, NULL);
- if (type != GIBBER_STANZA_TYPE_MESSAGE)
+ wocky_stanza_get_type_info (stanza, &type, NULL);
+ if (type != WOCKY_STANZA_TYPE_MESSAGE)
return FALSE;
if (wocky_node_get_child_ns (wocky_stanza_get_top_node (stanza), "invite",
@@ -972,12 +976,6 @@ salut_im_channel_is_text_message (GibberXmppStanza *stanza)
*
* Implements DBus method Close
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_im_channel_close (TpSvcChannel *iface,
@@ -993,12 +991,6 @@ salut_im_channel_close (TpSvcChannel *iface,
*
* Implements DBus method GetChannelType
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_im_channel_get_channel_type (TpSvcChannel *iface,
@@ -1014,12 +1006,6 @@ salut_im_channel_get_channel_type (TpSvcChannel *iface,
*
* Implements DBus method GetHandle
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_im_channel_get_handle (TpSvcChannel *iface,
@@ -1038,12 +1024,6 @@ salut_im_channel_get_handle (TpSvcChannel *iface,
*
* Implements DBus method GetInterfaces
* on interface org.freedesktop.Telepathy.Channel
- *
- * @error: Used to return a pointer to a GError detailing any error
- * that occured, DBus will throw the error only if this
- * function returns false.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
*/
static void
salut_im_channel_get_interfaces (TpSvcChannel *iface,
@@ -1076,7 +1056,7 @@ _salut_im_channel_send (GObject *channel,
SalutImChannel *self = SALUT_IM_CHANNEL (channel);
SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self);
GError *error = NULL;
- GibberXmppStanza *stanza = NULL;
+ WockyStanza *stanza = NULL;
guint type;
gchar *text;
gchar *token;
diff --git a/src/salut-im-channel.h b/src/salut-im-channel.h
index 5d34d7a0..2d61ab25 100644
--- a/src/salut-im-channel.h
+++ b/src/salut-im-channel.h
@@ -21,7 +21,7 @@
#define __SALUT_IM_CHANNEL_H__
#include <glib-object.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-xmpp-connection.h>
#include <telepathy-glib/message-mixin.h>
@@ -64,10 +64,10 @@ void salut_im_channel_add_connection (SalutImChannel *chan,
GibberXmppConnection *conn);
void salut_im_channel_received_stanza (SalutImChannel *chan,
- GibberXmppStanza *stanza);
+ WockyStanza *stanza);
gboolean
-salut_im_channel_is_text_message (GibberXmppStanza *stanza);
+salut_im_channel_is_text_message (WockyStanza *stanza);
G_END_DECLS
diff --git a/src/salut-im-manager.c b/src/salut-im-manager.c
index 56fce930..cd310255 100644
--- a/src/salut-im-manager.c
+++ b/src/salut-im-manager.c
@@ -30,7 +30,7 @@
#include <gibber/gibber-linklocal-transport.h>
#include <gibber/gibber-xmpp-connection.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-namespaces.h>
#include <telepathy-glib/channel-manager.h>
@@ -74,7 +74,6 @@ struct _SalutImManagerPrivate
SalutConnection *connection;
SalutXmppConnectionManager *xmpp_connection_manager;
GHashTable *channels;
- GHashTable *pending_connections;
gulong status_changed_id;
gboolean dispose_has_run;
};
@@ -84,35 +83,18 @@ struct _SalutImManagerPrivate
SalutImManagerPrivate))
static void
-contact_list_destroy (gpointer data)
-{
- GList *list = (GList *) data;
- GList *t = list;
- while (t != NULL)
- {
- SalutContact *contact;
- contact= SALUT_CONTACT (t->data);
- g_object_unref (contact);
- t = g_list_next (t);
- }
- g_list_free (list);
-}
-
-static void
salut_im_manager_init (SalutImManager *obj)
{
SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE (obj);
/* allocate any data required by the object here */
priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
- priv->pending_connections = g_hash_table_new_full (g_direct_hash,
- g_direct_equal, g_object_unref, contact_list_destroy);
}
static gboolean
message_stanza_filter (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -138,7 +120,7 @@ message_stanza_filter (SalutXmppConnectionManager *mgr,
static void
message_stanza_callback (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -348,12 +330,6 @@ salut_im_manager_dispose (GObject *object)
salut_im_factory_close_all (self);
- if (priv->pending_connections)
- {
- g_hash_table_destroy (priv->pending_connections);
- priv->pending_connections = NULL;
- }
-
if (G_OBJECT_CLASS (salut_im_manager_parent_class)->dispose)
G_OBJECT_CLASS (salut_im_manager_parent_class)->dispose (object);
}
diff --git a/src/salut-muc-channel.c b/src/salut-muc-channel.c
index 0baa0b10..6f59a2b9 100644
--- a/src/salut-muc-channel.c
+++ b/src/salut-muc-channel.c
@@ -138,11 +138,11 @@ static gboolean salut_muc_channel_send_stanza (SalutMucChannel *self,
guint type,
const gchar *token,
const gchar *text,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GError **error);
static void salut_muc_channel_received_stanza (GibberMucConnection *conn,
const gchar *sender,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data);
static gboolean
salut_muc_channel_connect (SalutMucChannel *channel, GError **error);
@@ -232,6 +232,10 @@ salut_muc_channel_get_property (GObject *object,
TP_IFACE_CHANNEL, "InitiatorID",
TP_IFACE_CHANNEL, "Requested",
TP_IFACE_CHANNEL, "Interfaces",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessagePartSupportFlags",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "DeliveryReportingSupport",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "SupportedContentTypes",
+ TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessageTypes",
NULL));
break;
default:
@@ -369,7 +373,7 @@ salut_muc_channel_constructor (GType type, guint n_props,
GObjectConstructParam *props)
{
GObject *obj;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
SalutMucChannel *self;
SalutMucChannelPrivate *priv;
TpBaseConnection *base_conn;
@@ -428,8 +432,8 @@ salut_muc_channel_constructor (GType type, guint n_props,
g_object_unref (priv->muc_manager);
/* Connect to the bus */
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
contact_repo = tp_base_connection_get_handles (base_conn,
TP_HANDLE_TYPE_CONTACT);
@@ -465,12 +469,12 @@ static void salut_muc_channel_finalize (GObject *object);
static void
invitation_append_parameter (gpointer key, gpointer value, gpointer data)
{
- GibberXmppNode *node = (GibberXmppNode *) data;
- gibber_xmpp_node_add_child_with_content (node, (gchar *) key,
+ WockyNode *node = (WockyNode *) data;
+ wocky_node_add_child_with_content (node, (gchar *) key,
(gchar *) value);
}
-static GibberXmppStanza *
+static WockyStanza *
create_invitation (SalutMucChannel *self, TpHandle handle,
const gchar *message)
{
@@ -480,29 +484,29 @@ create_invitation (SalutMucChannel *self, TpHandle handle,
tp_base_connection_get_handles (base_connection, TP_HANDLE_TYPE_CONTACT);
TpHandleRepoIface *room_repo =
tp_base_connection_get_handles (base_connection, TP_HANDLE_TYPE_ROOM);
- GibberXmppStanza *msg;
- GibberXmppNode *invite_node;
+ WockyStanza *msg;
+ WockyNode *invite_node;
const gchar *name = tp_handle_inspect (contact_repo, handle);
- msg = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_MESSAGE,
- GIBBER_STANZA_SUB_TYPE_NORMAL,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_NORMAL,
self->connection->name, name,
- GIBBER_NODE, "body",
- GIBBER_NODE_TEXT, "You got a Clique chatroom invitation",
- GIBBER_NODE_END,
- GIBBER_NODE, "invite",
- GIBBER_NODE_ASSIGN_TO, &invite_node,
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_CLIQUE,
- GIBBER_NODE, "roomname",
- GIBBER_NODE_TEXT, tp_handle_inspect (room_repo, priv->handle),
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "body",
+ WOCKY_NODE_TEXT, "You got a Clique chatroom invitation",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "invite",
+ WOCKY_NODE_ASSIGN_TO, &invite_node,
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_CLIQUE,
+ WOCKY_NODE_START, "roomname",
+ WOCKY_NODE_TEXT, tp_handle_inspect (room_repo, priv->handle),
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
if (message != NULL && *message != '\0')
{
- gibber_xmpp_node_add_child_with_content (invite_node, "reason", message);
+ wocky_node_add_child_with_content (invite_node, "reason", message);
}
g_hash_table_foreach (
@@ -532,7 +536,7 @@ pending_connection_for_invite_data
{
SalutMucChannel *self;
SalutContact *contact;
- GibberXmppStanza *invite;
+ WockyStanza *invite;
};
static struct pending_connection_for_invite_data *
@@ -624,7 +628,7 @@ salut_muc_channel_send_invitation (SalutMucChannel *self,
GError **error)
{
SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self);
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
SalutContactManager *contact_manager = NULL;
SalutContact *contact;
SalutXmppConnectionManagerRequestConnectionResult request_result;
@@ -1091,7 +1095,7 @@ static gboolean
salut_muc_channel_send_stanza (SalutMucChannel *self, guint type,
const gchar *token,
const gchar *text,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
GError **error)
{
SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self);
@@ -1190,7 +1194,7 @@ salut_muc_channel_remove_members (SalutMucChannel *self,
static void
salut_muc_channel_received_stanza (GibberMucConnection *conn,
const gchar *sender,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
SalutMucChannel *self = SALUT_MUC_CHANNEL (user_data);
@@ -1203,9 +1207,9 @@ salut_muc_channel_received_stanza (GibberMucConnection *conn,
TpChannelTextMessageType msgtype;
TpHandle from_handle;
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberXmppNode *tubes_node;
+ WockyNode *tubes_node;
- to = gibber_xmpp_node_get_attribute (node, "to");
+ to = wocky_node_get_attribute (node, "to");
if (strcmp (to, priv->muc_name)) {
DEBUG("Stanza to another muc group, discarding");
return;
@@ -1226,7 +1230,7 @@ salut_muc_channel_received_stanza (GibberMucConnection *conn,
return;
#endif
- tubes_node = gibber_xmpp_node_get_child_ns (node, "tubes",
+ tubes_node = wocky_node_get_child_ns (node, "tubes",
GIBBER_TELEPATHY_NS_TUBES);
if (tubes_node != NULL)
{
@@ -1480,7 +1484,7 @@ salut_muc_channel_send (GObject *channel,
SalutMucChannel *self = SALUT_MUC_CHANNEL(channel);
SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self);
GError *error = NULL;
- GibberXmppStanza *stanza = NULL;
+ WockyStanza *stanza = NULL;
guint type;
gchar *text = NULL;
gchar *token = NULL;
diff --git a/src/salut-muc-manager.c b/src/salut-muc-manager.c
index 75b3d149..9f473295 100644
--- a/src/salut-muc-manager.c
+++ b/src/salut-muc-manager.c
@@ -51,12 +51,12 @@
static gboolean
invite_stanza_filter (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
static void
invite_stanza_callback (SalutXmppConnectionManager *mgr,
- GibberXmppConnection *conn, GibberXmppStanza *stanza,
+ GibberXmppConnection *conn, WockyStanza *stanza,
SalutContact *contact, gpointer user_data);
@@ -1025,14 +1025,14 @@ static void salut_muc_manager_iface_init (gpointer g_iface,
static gboolean
invite_stanza_filter (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
- GibberStanzaType type;
+ WockyStanzaType type;
- gibber_xmpp_stanza_get_type_info (stanza, &type, NULL);
- if (type != GIBBER_STANZA_TYPE_MESSAGE)
+ wocky_stanza_get_type_info (stanza, &type, NULL);
+ if (type != WOCKY_STANZA_TYPE_MESSAGE)
return FALSE;
return (wocky_node_get_child_ns (wocky_stanza_get_top_node (stanza),
@@ -1042,7 +1042,7 @@ invite_stanza_filter (SalutXmppConnectionManager *mgr,
static void
invite_stanza_callback (SalutXmppConnectionManager *mgr,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -1053,7 +1053,7 @@ invite_stanza_callback (SalutXmppConnectionManager *mgr,
tp_base_connection_get_handles (base_connection, TP_HANDLE_TYPE_ROOM);
TpHandleRepoIface *contact_repo =
tp_base_connection_get_handles (base_connection, TP_HANDLE_TYPE_CONTACT);
- GibberXmppNode *invite, *room_node, *reason_node;
+ WockyNode *invite, *room_node, *reason_node;
SalutMucChannel *chan;
const gchar *room = NULL;
const gchar *reason = NULL;
@@ -1070,7 +1070,7 @@ invite_stanza_callback (SalutXmppConnectionManager *mgr,
DEBUG("Got an invitation");
- room_node = gibber_xmpp_node_get_child (invite, "roomname");
+ room_node = wocky_node_get_child (invite, "roomname");
if (room_node == NULL)
{
DEBUG ("Invalid invitation, discarding");
@@ -1078,7 +1078,7 @@ invite_stanza_callback (SalutXmppConnectionManager *mgr,
}
room = room_node->content;
- reason_node = gibber_xmpp_node_get_child (invite, "reason");
+ reason_node = wocky_node_get_child (invite, "reason");
if (reason_node != NULL)
reason = reason_node->content;
@@ -1096,9 +1096,9 @@ invite_stanza_callback (SalutXmppConnectionManager *mgr,
params_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
for (p = params ; *p != NULL; p++)
{
- GibberXmppNode *param;
+ WockyNode *param;
- param = gibber_xmpp_node_get_child (invite, *p);
+ param = wocky_node_get_child (invite, *p);
if (param == NULL)
{
DEBUG("Invalid invitation, (missing parameter) discarding");
@@ -1183,7 +1183,7 @@ salut_muc_manager_handle_si_stream_request (SalutMucManager *self,
GibberBytestreamIface *bytestream,
TpHandle room_handle,
const gchar *stream_id,
- GibberXmppStanza *msg)
+ WockyStanza *msg)
{
SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE (self);
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
diff --git a/src/salut-muc-manager.h b/src/salut-muc-manager.h
index 6c880945..8054c2a4 100644
--- a/src/salut-muc-manager.h
+++ b/src/salut-muc-manager.h
@@ -73,7 +73,7 @@ salut_muc_manager_get_text_channel (SalutMucManager *muc_manager,
void salut_muc_manager_handle_si_stream_request (SalutMucManager *muc_manager,
GibberBytestreamIface *bytestream, TpHandle room_handle,
- const gchar *stream_id, GibberXmppStanza *msg);
+ const gchar *stream_id, WockyStanza *msg);
SalutTubesChannel * salut_muc_manager_ensure_tubes_channel (
SalutMucManager *muc_manager, TpHandle handle, TpHandle actor,
diff --git a/src/salut-olpc-activity.c b/src/salut-olpc-activity.c
index b7cc32e5..9084c137 100644
--- a/src/salut-olpc-activity.c
+++ b/src/salut-olpc-activity.c
@@ -23,7 +23,7 @@
#include <string.h>
#include <gibber/gibber-namespaces.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include "salut-olpc-activity.h"
#include "salut-muc-manager.h"
@@ -278,9 +278,9 @@ send_properties_change_msg (SalutOlpcActivity *self,
SalutOlpcActivityPrivate *priv = SALUT_OLPC_ACTIVITY_GET_PRIVATE (self);
GHashTable *properties;
GValue *activity_id_val;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *top_node;
- GibberXmppNode *properties_node;
+ WockyNode *properties_node;
gchar *muc_name;
GibberMucConnection *muc_connection;
gboolean result;
@@ -311,18 +311,18 @@ send_properties_change_msg (SalutOlpcActivity *self,
g_value_set_static_string (activity_id_val, self->id);
g_hash_table_insert (properties, "id", activity_id_val);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_MESSAGE,
- GIBBER_STANZA_SUB_TYPE_GROUPCHAT,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_GROUPCHAT,
self->connection->name, muc_name,
- GIBBER_NODE, "properties",
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "properties",
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS,
+ WOCKY_NODE_END, NULL);
top_node = wocky_stanza_get_top_node (stanza);
- properties_node = gibber_xmpp_node_get_child_ns (top_node, "properties",
+ properties_node = wocky_node_get_child_ns (top_node, "properties",
GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS);
- salut_gibber_xmpp_node_add_children_from_properties (properties_node,
+ salut_wocky_node_add_children_from_properties (properties_node,
properties, "property");
result = gibber_muc_connection_send (muc_connection, stanza, &err);
@@ -602,13 +602,13 @@ typedef struct
{
SalutOlpcActivity *self;
SalutContact *contact;
- GibberXmppStanza *msg;
+ WockyStanza *msg;
} pending_connection_for_uninvite_ctx;
static pending_connection_for_uninvite_ctx *
pending_connection_for_uninvite_ctx_new (SalutOlpcActivity *self,
SalutContact *contact,
- GibberXmppStanza *msg)
+ WockyStanza *msg)
{
pending_connection_for_uninvite_ctx *ctx;
@@ -682,7 +682,7 @@ void
salut_olpc_activity_revoke_invitations (SalutOlpcActivity *self)
{
SalutOlpcActivityPrivate *priv = SALUT_OLPC_ACTIVITY_GET_PRIVATE (self);
- GibberXmppStanza *msg;
+ WockyStanza *msg;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) self->connection, TP_HANDLE_TYPE_CONTACT);
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
@@ -696,15 +696,15 @@ salut_olpc_activity_revoke_invitations (SalutOlpcActivity *self)
if (tp_handle_set_size (priv->invited) <= 0)
return;
- msg = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_MESSAGE,
- GIBBER_STANZA_SUB_TYPE_NONE,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_NONE,
self->connection->name, NULL,
- GIBBER_NODE, "uninvite",
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS,
- GIBBER_NODE_ATTRIBUTE, "room", tp_handle_inspect (room_repo,
+ WOCKY_NODE_START, "uninvite",
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS,
+ WOCKY_NODE_ATTRIBUTE, "room", tp_handle_inspect (room_repo,
self->room),
- GIBBER_NODE_ATTRIBUTE, "id", self->id,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_ATTRIBUTE, "id", self->id,
+ WOCKY_NODE_END, NULL);
top_node = wocky_stanza_get_top_node (msg);
g_object_get (self->connection,
@@ -732,7 +732,7 @@ salut_olpc_activity_revoke_invitations (SalutOlpcActivity *self)
}
to = tp_handle_inspect (contact_repo, contact_handle);
- gibber_xmpp_node_set_attribute (top_node, "to", to);
+ wocky_node_set_attribute (top_node, "to", to);
request_result = salut_xmpp_connection_manager_request_connection (
xmpp_connection_manager, contact, &connection, NULL);
@@ -772,16 +772,16 @@ salut_olpc_activity_revoke_invitations (SalutOlpcActivity *self)
void
salut_olpc_activity_augment_invitation (SalutOlpcActivity *self,
TpHandle contact,
- GibberXmppNode *invite_node)
+ WockyNode *invite_node)
{
SalutOlpcActivityPrivate *priv = SALUT_OLPC_ACTIVITY_GET_PRIVATE (self);
- GibberXmppNode *properties_node;
+ WockyNode *properties_node;
GHashTable *properties;
GValue *activity_id_val;
properties = salut_olpc_activity_create_properties_table (self);
- properties_node = gibber_xmpp_node_add_child_ns (invite_node, "properties",
+ properties_node = wocky_node_add_child_ns (invite_node, "properties",
GIBBER_TELEPATHY_NS_OLPC_ACTIVITY_PROPS);
/* add the activity id */
@@ -790,7 +790,7 @@ salut_olpc_activity_augment_invitation (SalutOlpcActivity *self,
g_value_set_static_string (activity_id_val, self->id);
g_hash_table_insert (properties, "id", activity_id_val);
- salut_gibber_xmpp_node_add_children_from_properties (properties_node,
+ salut_wocky_node_add_children_from_properties (properties_node,
properties, "property");
tp_handle_set_add (priv->invited, contact);
diff --git a/src/salut-olpc-activity.h b/src/salut-olpc-activity.h
index faf69ea0..3cadf48f 100644
--- a/src/salut-olpc-activity.h
+++ b/src/salut-olpc-activity.h
@@ -90,7 +90,7 @@ GHashTable * salut_olpc_activity_create_properties_table (
SalutOlpcActivity *activity);
void salut_olpc_activity_augment_invitation (SalutOlpcActivity *activity,
- TpHandle contact, GibberXmppNode *invite_node);
+ TpHandle contact, WockyNode *invite_node);
gboolean salut_olpc_activity_remove_invited (SalutOlpcActivity *activity,
TpHandle contact);
diff --git a/src/salut-presence-cache.c b/src/salut-presence-cache.c
index 268bf8db..e50d62f5 100644
--- a/src/salut-presence-cache.c
+++ b/src/salut-presence-cache.c
@@ -331,7 +331,7 @@ _caps_disco_cb (SalutDisco *disco,
SalutDiscoRequest *request,
SalutContact *contact,
const gchar *node,
- GibberXmppNode *query_result,
+ WockyNode *query_result,
GError *error,
gpointer user_data)
{
diff --git a/src/salut-roomlist-channel.c b/src/salut-roomlist-channel.c
index d6cb0cf9..6d7b483f 100644
--- a/src/salut-roomlist-channel.c
+++ b/src/salut-roomlist-channel.c
@@ -106,14 +106,16 @@ salut_roomlist_channel_constructor (GType type,
{
GObject *obj;
SalutRoomlistChannelPrivate *priv;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
+ TpBaseConnection *base_conn;
obj = G_OBJECT_CLASS (salut_roomlist_channel_parent_class)->constructor (
type, n_props, props);
priv = SALUT_ROOMLIST_CHANNEL_GET_PRIVATE (SALUT_ROOMLIST_CHANNEL (obj));
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ base_conn = TP_BASE_CONNECTION (priv->connection);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
return obj;
}
diff --git a/src/salut-self.c b/src/salut-self.c
index c12e8116..b3a276d3 100644
--- a/src/salut-self.c
+++ b/src/salut-self.c
@@ -945,7 +945,7 @@ void
salut_self_olpc_augment_invitation (SalutSelf *self,
TpHandle room,
TpHandle contact,
- GibberXmppNode *invite_node)
+ WockyNode *invite_node)
{
SalutOlpcActivity *activity;
diff --git a/src/salut-self.h b/src/salut-self.h
index 4d2e1da0..6d52b07a 100644
--- a/src/salut-self.h
+++ b/src/salut-self.h
@@ -26,7 +26,7 @@
#include <telepathy-glib/handle-repo.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include "capabilities-set.h"
#include "salut-connection.h"
@@ -154,7 +154,7 @@ void salut_self_foreach_olpc_activity (SalutSelf *self,
SalutSelfOLPCActivityFunc foreach, gpointer user_data);
void salut_self_olpc_augment_invitation (SalutSelf *self,
- TpHandle room, TpHandle contact, GibberXmppNode *invite_node);
+ TpHandle room, TpHandle contact, WockyNode *invite_node);
#endif
const GabbleCapabilitySet *salut_self_get_caps (SalutSelf *self);
diff --git a/src/salut-si-bytestream-manager.c b/src/salut-si-bytestream-manager.c
index 9d46c2f2..cd359ed0 100644
--- a/src/salut-si-bytestream-manager.c
+++ b/src/salut-si-bytestream-manager.c
@@ -25,7 +25,7 @@
#include <gibber/gibber-bytestream-ibb.h>
#include <gibber/gibber-bytestream-oob.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-namespaces.h>
#include <gibber/gibber-xmpp-error.h>
#include <gibber/gibber-iq-helper.h>
@@ -80,27 +80,27 @@ salut_si_bytestream_manager_init (SalutSiBytestreamManager *self)
static gboolean
si_request_filter (SalutXmppConnectionManager *xcm,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ)
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
+ if (type != WOCKY_STANZA_TYPE_IQ)
return FALSE;
- if (sub_type != GIBBER_STANZA_SUB_TYPE_SET)
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- return (gibber_xmpp_node_get_child_ns (node, "si",
+ return (wocky_node_get_child_ns (node, "si",
GIBBER_XMPP_NS_SI) != NULL);
}
static gboolean
-streaminit_parse_request (GibberXmppStanza *stanza,
+streaminit_parse_request (WockyStanza *stanza,
const gchar **profile,
const gchar **from,
const gchar **stream_id,
@@ -108,14 +108,14 @@ streaminit_parse_request (GibberXmppStanza *stanza,
const gchar **mime_type,
GSList **stream_methods)
{
- GibberXmppNode *iq, *si, *feature, *x;
+ WockyNode *iq, *si, *feature, *x;
GSList *x_children, *field_children;
iq = wocky_stanza_get_top_node (stanza);
- *stream_init_id = gibber_xmpp_node_get_attribute (iq, "id");
+ *stream_init_id = wocky_node_get_attribute (iq, "id");
- *from = gibber_xmpp_node_get_attribute (iq, "from");
+ *from = wocky_node_get_attribute (iq, "from");
if (*from == NULL)
{
DEBUG ("got a message without a from field");
@@ -123,22 +123,22 @@ streaminit_parse_request (GibberXmppStanza *stanza,
}
/* Parse <si> */
- si = gibber_xmpp_node_get_child_ns (iq, "si", GIBBER_XMPP_NS_SI);
+ si = wocky_node_get_child_ns (iq, "si", GIBBER_XMPP_NS_SI);
if (si == NULL)
return FALSE;
- *stream_id = gibber_xmpp_node_get_attribute (si, "id");
+ *stream_id = wocky_node_get_attribute (si, "id");
if (*stream_id == NULL)
{
DEBUG ("got a SI request without a stream id field");
return FALSE;
}
- *mime_type = gibber_xmpp_node_get_attribute (si, "mime-type");
+ *mime_type = wocky_node_get_attribute (si, "mime-type");
/* if no mime_type is defined, XEP-0095 says to assume
* "application/octet-stream" */
- *profile = gibber_xmpp_node_get_attribute (si, "profile");
+ *profile = wocky_node_get_attribute (si, "profile");
if (*profile == NULL)
{
DEBUG ("got a SI request without a profile field");
@@ -146,7 +146,7 @@ streaminit_parse_request (GibberXmppStanza *stanza,
}
/* Parse <feature> */
- feature = gibber_xmpp_node_get_child_ns (si, "feature",
+ feature = wocky_node_get_child_ns (si, "feature",
GIBBER_XMPP_NS_FEATURENEG);
if (feature == NULL)
{
@@ -154,7 +154,7 @@ streaminit_parse_request (GibberXmppStanza *stanza,
return FALSE;
}
- x = gibber_xmpp_node_get_child_ns (feature, "x", GIBBER_XMPP_NS_DATA);
+ x = wocky_node_get_child_ns (feature, "x", GIBBER_XMPP_NS_DATA);
if (x == NULL)
{
DEBUG ("got a SI request without a X data field");
@@ -164,14 +164,14 @@ streaminit_parse_request (GibberXmppStanza *stanza,
for (x_children = x->children; x_children;
x_children = g_slist_next (x_children))
{
- GibberXmppNode *field = x_children->data;
+ WockyNode *field = x_children->data;
- if (tp_strdiff (gibber_xmpp_node_get_attribute (field, "var"),
+ if (tp_strdiff (wocky_node_get_attribute (field, "var"),
"stream-method"))
/* some future field, ignore it */
continue;
- if (tp_strdiff (gibber_xmpp_node_get_attribute (field, "type"),
+ if (tp_strdiff (wocky_node_get_attribute (field, "type"),
"list-single"))
{
DEBUG ( "SI request's stream-method field was "
@@ -184,12 +184,12 @@ streaminit_parse_request (GibberXmppStanza *stanza,
for (field_children = field->children; field_children;
field_children = g_slist_next (field_children))
{
- GibberXmppNode *stream_method, *value;
+ WockyNode *stream_method, *value;
const gchar *stream_method_str;
- stream_method = (GibberXmppNode *) field_children->data;
+ stream_method = (WockyNode *) field_children->data;
- value = gibber_xmpp_node_get_child (stream_method, "value");
+ value = wocky_node_get_child (stream_method, "value");
if (value == NULL)
continue;
@@ -292,7 +292,7 @@ choose_bytestream_method (SalutSiBytestreamManager *self,
static void
si_request_cb (SalutXmppConnectionManager *xcm,
GibberXmppConnection *connection,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -306,7 +306,7 @@ si_request_cb (SalutXmppConnectionManager *xcm,
TpHandle peer_handle;
GibberBytestreamIface *bytestream = NULL;
WockyNode *top_node = wocky_stanza_get_top_node (stanza);
- GibberXmppNode *si, *node;
+ WockyNode *si, *node;
const gchar *profile, *from, *stream_id, *stream_init_id, *mime_type;
GSList *stream_methods = NULL;
@@ -316,7 +316,7 @@ si_request_cb (SalutXmppConnectionManager *xcm,
if (!streaminit_parse_request (stanza, &profile, &from, &stream_id,
&stream_init_id, &mime_type, &stream_methods))
{
- GibberXmppStanza *reply;
+ WockyStanza *reply;
reply = gibber_iq_helper_new_error_reply (stanza, XMPP_ERROR_BAD_REQUEST,
"failed to parse SI request");
@@ -326,7 +326,7 @@ si_request_cb (SalutXmppConnectionManager *xcm,
return;
}
- si = gibber_xmpp_node_get_child_ns (top_node, "si", GIBBER_XMPP_NS_SI);
+ si = wocky_node_get_child_ns (top_node, "si", GIBBER_XMPP_NS_SI);
g_assert (si != NULL);
DEBUG ("received a SI request");
@@ -343,7 +343,7 @@ si_request_cb (SalutXmppConnectionManager *xcm,
if (bytestream == NULL)
{
- GibberXmppStanza *reply;
+ WockyStanza *reply;
DEBUG ("SI request doesn't contain any supported stream method.");
reply = gibber_iq_helper_new_error_reply (stanza,
@@ -381,14 +381,14 @@ si_request_cb (SalutXmppConnectionManager *xcm,
* We don't use SI for 1-1 tubes
*/
- if ((node = gibber_xmpp_node_get_child_ns (si, "muc-stream",
+ if ((node = wocky_node_get_child_ns (si, "muc-stream",
GIBBER_TELEPATHY_NS_TUBES)))
{
const gchar *muc;
TpHandle room_handle;
SalutMucManager *muc_mgr;
- muc = gibber_xmpp_node_get_attribute (node, "muc");
+ muc = wocky_node_get_attribute (node, "muc");
if (muc == NULL)
{
DEBUG ("muc-stream SI doesn't contain muc attribute");
@@ -605,45 +605,45 @@ salut_si_bytestream_manager_new (SalutConnection *conn,
* Create a SI request IQ as described in XEP-0095.
*
*/
-GibberXmppStanza *
+WockyStanza *
salut_si_bytestream_manager_make_stream_init_iq (const gchar *from,
const gchar *to,
const gchar *stream_id,
const gchar *profile)
{
- return gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_IQ, GIBBER_STANZA_SUB_TYPE_SET,
+ return wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
from, to,
- GIBBER_NODE, "si",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_SI,
- GIBBER_NODE_ATTRIBUTE, "id", stream_id,
- GIBBER_NODE_ATTRIBUTE, "profile", profile,
- GIBBER_NODE_ATTRIBUTE, "mime-type", "application/octet-stream",
- GIBBER_NODE, "feature",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
- GIBBER_NODE, "x",
- GIBBER_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
- GIBBER_NODE_ATTRIBUTE, "type", "form",
- GIBBER_NODE, "field",
- GIBBER_NODE_ATTRIBUTE, "var", "stream-method",
- GIBBER_NODE_ATTRIBUTE, "type", "list-single",
-
- GIBBER_NODE, "option",
- GIBBER_NODE, "value",
- GIBBER_NODE_TEXT, GIBBER_XMPP_NS_IQ_OOB,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
-
- GIBBER_NODE, "option",
- GIBBER_NODE, "value",
- GIBBER_NODE_TEXT, GIBBER_XMPP_NS_IBB,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
-
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "si",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_SI,
+ WOCKY_NODE_ATTRIBUTE, "id", stream_id,
+ WOCKY_NODE_ATTRIBUTE, "profile", profile,
+ WOCKY_NODE_ATTRIBUTE, "mime-type", "application/octet-stream",
+ WOCKY_NODE_START, "feature",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_FEATURENEG,
+ WOCKY_NODE_START, "x",
+ WOCKY_NODE_XMLNS, GIBBER_XMPP_NS_DATA,
+ WOCKY_NODE_ATTRIBUTE, "type", "form",
+ WOCKY_NODE_START, "field",
+ WOCKY_NODE_ATTRIBUTE, "var", "stream-method",
+ WOCKY_NODE_ATTRIBUTE, "type", "list-single",
+
+ WOCKY_NODE_START, "option",
+ WOCKY_NODE_START, "value",
+ WOCKY_NODE_TEXT, GIBBER_XMPP_NS_IQ_OOB,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+
+ WOCKY_NODE_START, "option",
+ WOCKY_NODE_START, "value",
+ WOCKY_NODE_TEXT, GIBBER_XMPP_NS_IBB,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END, NULL);
}
struct streaminit_reply_cb_data
@@ -654,7 +654,7 @@ struct streaminit_reply_cb_data
gpointer user_data;
gchar *iq_id;
SalutContact *contact;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
};
static struct streaminit_reply_cb_data *
@@ -681,26 +681,26 @@ streaminit_reply_cb_data_free (struct streaminit_reply_cb_data *data)
static gboolean
si_request_reply_filter (SalutXmppConnectionManager *manager,
GibberXmppConnection *connection,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
struct streaminit_reply_cb_data *data =
(struct streaminit_reply_cb_data *) user_data;
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
const gchar *iq_id;
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ)
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
+ if (type != WOCKY_STANZA_TYPE_IQ)
return FALSE;
- if (sub_type != GIBBER_STANZA_SUB_TYPE_RESULT &&
- sub_type != GIBBER_STANZA_SUB_TYPE_ERROR)
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_RESULT &&
+ sub_type != WOCKY_STANZA_SUB_TYPE_ERROR)
return FALSE;
- iq_id = gibber_xmpp_node_get_attribute (node, "id");
+ iq_id = wocky_node_get_attribute (node, "id");
return (!tp_strdiff (iq_id, data->iq_id));
}
@@ -745,7 +745,7 @@ check_bytestream_oob_peer_addr (GibberBytestreamOOB *bytestream,
static void
si_request_reply_cb (SalutXmppConnectionManager *manager,
GibberXmppConnection *connection,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -753,8 +753,8 @@ si_request_reply_cb (SalutXmppConnectionManager *manager,
(struct streaminit_reply_cb_data *) user_data;
SalutSiBytestreamManagerPrivate *priv =
SALUT_SI_BYTESTREAM_MANAGER_GET_PRIVATE (data->self);
- GibberStanzaSubType sub_type;
- GibberXmppNode *si, *feature, *x;
+ WockyStanzaSubType sub_type;
+ WockyNode *si, *feature, *x;
GibberBytestreamIface *bytestream = NULL;
const gchar *from, *stream_method, *stream_init_id;
GSList *x_children;
@@ -765,24 +765,24 @@ si_request_reply_cb (SalutXmppConnectionManager *manager,
DEBUG ("received SI request response");
- gibber_xmpp_stanza_get_type_info (stanza, NULL, &sub_type);
- if (sub_type != GIBBER_STANZA_SUB_TYPE_RESULT)
+ wocky_stanza_get_type_info (stanza, NULL, &sub_type);
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_RESULT)
{
DEBUG ("stream %s declined", data->stream_id);
goto END;
}
/* stream accepted */
- stream_init_id = gibber_xmpp_node_get_attribute (node, "id");
+ stream_init_id = wocky_node_get_attribute (node, "id");
- from = gibber_xmpp_node_get_attribute (node, "from");
+ from = wocky_node_get_attribute (node, "from");
if (from == NULL)
{
DEBUG ("got a message without a from field");
goto END;
}
- si = gibber_xmpp_node_get_child_ns (node, "si",
+ si = wocky_node_get_child_ns (node, "si",
GIBBER_XMPP_NS_SI);
if (si == NULL)
{
@@ -790,7 +790,7 @@ si_request_reply_cb (SalutXmppConnectionManager *manager,
goto END;
}
- feature = gibber_xmpp_node_get_child_ns (si, "feature",
+ feature = wocky_node_get_child_ns (si, "feature",
GIBBER_XMPP_NS_FEATURENEG);
if (feature == NULL)
{
@@ -798,7 +798,7 @@ si_request_reply_cb (SalutXmppConnectionManager *manager,
goto END;
}
- x = gibber_xmpp_node_get_child_ns (feature, "x", GIBBER_XMPP_NS_DATA);
+ x = wocky_node_get_child_ns (feature, "x", GIBBER_XMPP_NS_DATA);
if (x == NULL)
{
DEBUG ("got a SI reply without a x field");
@@ -808,14 +808,14 @@ si_request_reply_cb (SalutXmppConnectionManager *manager,
for (x_children = x->children; x_children;
x_children = g_slist_next (x_children))
{
- GibberXmppNode *value, *field = x_children->data;
+ WockyNode *value, *field = x_children->data;
- if (tp_strdiff (gibber_xmpp_node_get_attribute (field, "var"),
+ if (tp_strdiff (wocky_node_get_attribute (field, "var"),
"stream-method"))
/* some future field, ignore it */
continue;
- value = gibber_xmpp_node_get_child (field, "value");
+ value = wocky_node_get_child (field, "value");
if (value == NULL)
{
DEBUG ("SI reply's stream-method field "
@@ -907,7 +907,7 @@ send_si_request (SalutSiBytestreamManager *self,
WockyNode *node = wocky_stanza_get_top_node (data->stanza);
const gchar *iq_id;
- iq_id = gibber_xmpp_node_get_attribute (node, "id");
+ iq_id = wocky_node_get_attribute (node, "id");
if (iq_id != NULL)
{
data->iq_id = g_strdup (iq_id);
@@ -915,7 +915,7 @@ send_si_request (SalutSiBytestreamManager *self,
else
{
data->iq_id = gibber_xmpp_connection_new_id (connection);
- gibber_xmpp_node_set_attribute (node, "id", data->iq_id);
+ wocky_node_set_attribute (node, "id", data->iq_id);
}
/* Register a filter to catch the response of the SI request */
@@ -1003,7 +1003,7 @@ xmpp_connection_manager_connection_failed_cb (SalutXmppConnectionManager *mgr,
gboolean
salut_si_bytestream_manager_negotiate_stream (SalutSiBytestreamManager *self,
SalutContact *contact,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
const gchar *stream_id,
SalutSiBytestreamManagerNegotiateReplyFunc func,
gpointer user_data,
diff --git a/src/salut-si-bytestream-manager.h b/src/salut-si-bytestream-manager.h
index 8a42e7f4..bebdabff 100644
--- a/src/salut-si-bytestream-manager.h
+++ b/src/salut-si-bytestream-manager.h
@@ -69,13 +69,13 @@ SalutSiBytestreamManager *
salut_si_bytestream_manager_new (SalutConnection *connection,
const gchar *host_name_fqdn);
-GibberXmppStanza *
+WockyStanza *
salut_si_bytestream_manager_make_stream_init_iq (const gchar *from,
const gchar *to, const gchar *stream_id, const gchar *profile);
gboolean
salut_si_bytestream_manager_negotiate_stream (SalutSiBytestreamManager *self,
- SalutContact *contact, GibberXmppStanza *stanza, const gchar *stream_id,
+ SalutContact *contact, WockyStanza *stanza, const gchar *stream_id,
SalutSiBytestreamManagerNegotiateReplyFunc func, gpointer user_data,
GError **error);
diff --git a/src/salut-tubes-channel.c b/src/salut-tubes-channel.c
index bf247e99..d8367c80 100644
--- a/src/salut-tubes-channel.c
+++ b/src/salut-tubes-channel.c
@@ -38,7 +38,7 @@
#include <gibber/gibber-muc-connection.h>
#include <gibber/gibber-bytestream-muc.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-namespaces.h>
#include <gibber/gibber-xmpp-error.h>
#include <gibber/gibber-iq-helper.h>
@@ -176,12 +176,12 @@ static void muc_connection_lost_senders_cb (GibberMucConnection *conn,
static void muc_connection_new_senders_cb (GibberMucConnection *conn,
GArray *senders, gpointer user_data);
static gboolean extract_tube_information (SalutTubesChannel *self,
- GibberXmppNode *tube_node, TpTubeType *type, TpHandle *initiator_handle,
+ WockyNode *tube_node, TpTubeType *type, TpHandle *initiator_handle,
const gchar **service, GHashTable **parameters, guint *tube_id);
static SalutTubeIface * create_new_tube (SalutTubesChannel *self,
TpTubeType type, TpHandle initiator, gboolean offered,
const gchar *service, GHashTable *parameters, guint tube_id, guint portnum,
- GibberXmppStanza *iq_req);
+ WockyStanza *iq_req);
static void
salut_tubes_channel_init (SalutTubesChannel *self)
@@ -211,7 +211,8 @@ salut_tubes_channel_constructor (GType type,
GObject *obj;
SalutTubesChannel *self;
SalutTubesChannelPrivate *priv;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
+ TpBaseConnection *base_conn;
TpHandleRepoIface *handle_repo;
obj = G_OBJECT_CLASS (salut_tubes_channel_parent_class)->
@@ -220,9 +221,9 @@ salut_tubes_channel_constructor (GType type,
self = SALUT_TUBES_CHANNEL (obj);
priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
- g_assert (priv->conn != NULL);
+ base_conn = TP_BASE_CONNECTION (priv->conn);
handle_repo = tp_base_connection_get_handles (
- (TpBaseConnection *) priv->conn, priv->handle_type);
+ base_conn, priv->handle_type);
tp_handle_ref (handle_repo, priv->handle);
@@ -258,8 +259,8 @@ salut_tubes_channel_constructor (GType type,
}
/* Connect to the bus */
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
DEBUG ("Registering at '%s'", priv->object_path);
@@ -776,20 +777,20 @@ emit_d_bus_names_changed_foreach (gpointer key,
GPtrArray *
salut_tubes_channel_muc_message_received (SalutTubesChannel *self,
const gchar *sender,
- GibberXmppStanza *stanza)
+ WockyStanza *stanza)
{
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
TpHandle contact;
WockyNode *top_node = wocky_stanza_get_top_node (stanza);
- GibberXmppNode *tubes_node;
+ WockyNode *tubes_node;
GSList *l;
GHashTable *old_dbus_tubes;
struct _add_in_old_dbus_tubes_data add_data;
struct emit_d_bus_names_changed_foreach_data emit_data;
- GibberStanzaType stanza_type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType stanza_type;
+ WockyStanzaSubType sub_type;
GPtrArray *result = g_ptr_array_new ();
contact = tp_handle_lookup (contact_repo, sender, NULL, NULL);
@@ -799,12 +800,12 @@ salut_tubes_channel_muc_message_received (SalutTubesChannel *self,
/* We don't need to inspect our own tubes */
return result;
- gibber_xmpp_stanza_get_type_info (stanza, &stanza_type, &sub_type);
- if (stanza_type != GIBBER_STANZA_TYPE_MESSAGE
- || sub_type != GIBBER_STANZA_SUB_TYPE_GROUPCHAT)
+ wocky_stanza_get_type_info (stanza, &stanza_type, &sub_type);
+ if (stanza_type != WOCKY_STANZA_TYPE_MESSAGE
+ || sub_type != WOCKY_STANZA_SUB_TYPE_GROUPCHAT)
return result;
- tubes_node = gibber_xmpp_node_get_child_ns (top_node, "tubes",
+ tubes_node = wocky_node_get_child_ns (top_node, "tubes",
GIBBER_TELEPATHY_NS_TUBES);
g_assert (tubes_node != NULL);
@@ -817,13 +818,13 @@ salut_tubes_channel_muc_message_received (SalutTubesChannel *self,
for (l = tubes_node->children; l != NULL; l = l->next)
{
- GibberXmppNode *tube_node = (GibberXmppNode *) l->data;
+ WockyNode *tube_node = (WockyNode *) l->data;
const gchar *stream_id;
SalutTubeIface *tube;
guint tube_id;
TpTubeType type;
- stream_id = gibber_xmpp_node_get_attribute (tube_node, "stream-id");
+ stream_id = wocky_node_get_attribute (tube_node, "stream-id");
extract_tube_information (self, tube_node, NULL,
NULL, NULL, NULL, &tube_id);
@@ -898,7 +899,7 @@ salut_tubes_channel_muc_message_received (SalutTubesChannel *self,
/* Contact just joined the tube */
const gchar *new_name;
- new_name = gibber_xmpp_node_get_attribute (tube_node,
+ new_name = wocky_node_get_attribute (tube_node,
"dbus-name");
if (!new_name)
@@ -956,7 +957,7 @@ salut_tubes_channel_message_received (SalutTubesChannel *self,
GHashTable *parameters,
guint tube_id,
guint portnum,
- GibberXmppStanza *iq_req)
+ WockyStanza *iq_req)
{
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
SalutTubeIface *tube;
@@ -1303,7 +1304,7 @@ create_new_tube (SalutTubesChannel *self,
GHashTable *parameters,
guint tube_id,
guint portnum,
- GibberXmppStanza *iq_req)
+ WockyStanza *iq_req)
{
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
SalutTubeIface *tube;
@@ -1361,7 +1362,7 @@ create_new_tube (SalutTubesChannel *self,
/* tube_node is a MUC <message> */
static gboolean
extract_tube_information (SalutTubesChannel *self,
- GibberXmppNode *tube_node,
+ WockyNode *tube_node,
TpTubeType *type,
TpHandle *initiator_handle,
const gchar **service,
@@ -1376,7 +1377,7 @@ extract_tube_information (SalutTubesChannel *self,
{
const gchar *_type;
- _type = gibber_xmpp_node_get_attribute (tube_node, "type");
+ _type = wocky_node_get_attribute (tube_node, "type");
if (!tp_strdiff (_type, "stream"))
@@ -1398,7 +1399,7 @@ extract_tube_information (SalutTubesChannel *self,
{
const gchar *initiator;
- initiator = gibber_xmpp_node_get_attribute (tube_node, "initiator");
+ initiator = wocky_node_get_attribute (tube_node, "initiator");
if (initiator != NULL)
{
@@ -1419,15 +1420,15 @@ extract_tube_information (SalutTubesChannel *self,
if (service != NULL)
{
- *service = gibber_xmpp_node_get_attribute (tube_node, "service");
+ *service = wocky_node_get_attribute (tube_node, "service");
}
if (parameters != NULL)
{
- GibberXmppNode *node;
+ WockyNode *node;
- node = gibber_xmpp_node_get_child (tube_node, "parameters");
- *parameters = salut_gibber_xmpp_node_extract_properties (node,
+ node = wocky_node_get_child (tube_node, "parameters");
+ *parameters = salut_wocky_node_extract_properties (node,
"parameter");
}
@@ -1437,7 +1438,7 @@ extract_tube_information (SalutTubesChannel *self,
gchar *endptr;
long int tmp;
- str = gibber_xmpp_node_get_attribute (tube_node, "id");
+ str = wocky_node_get_attribute (tube_node, "id");
if (str == NULL)
{
DEBUG ("no tube id in SI request");
@@ -1458,11 +1459,11 @@ extract_tube_information (SalutTubesChannel *self,
static void
publish_tube_in_node (SalutTubesChannel *self,
- GibberXmppNode *node,
+ WockyNode *node,
SalutTubeIface *tube)
{
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
- GibberXmppNode *parameters_node;
+ WockyNode *parameters_node;
GHashTable *parameters;
TpTubeType type;
gchar *service, *id_str;
@@ -1481,8 +1482,8 @@ publish_tube_in_node (SalutTubesChannel *self,
id_str = g_strdup_printf ("%u", tube_id);
- gibber_xmpp_node_set_attribute (node, "service", service);
- gibber_xmpp_node_set_attribute (node, "id", id_str);
+ wocky_node_set_attribute (node, "service", service);
+ wocky_node_set_attribute (node, "id", id_str);
g_free (id_str);
@@ -1497,13 +1498,13 @@ publish_tube_in_node (SalutTubesChannel *self,
"stream-id", &stream_id,
NULL);
- gibber_xmpp_node_set_attribute (node, "type", "dbus");
- gibber_xmpp_node_set_attribute (node, "stream-id", stream_id);
- gibber_xmpp_node_set_attribute (node, "initiator",
+ wocky_node_set_attribute (node, "type", "dbus");
+ wocky_node_set_attribute (node, "stream-id", stream_id);
+ wocky_node_set_attribute (node, "initiator",
tp_handle_inspect (contact_repo, initiator_handle));
if (name != NULL)
- gibber_xmpp_node_set_attribute (node, "dbus-name", name);
+ wocky_node_set_attribute (node, "dbus-name", name);
g_free (name);
g_free (stream_id);
@@ -1511,14 +1512,14 @@ publish_tube_in_node (SalutTubesChannel *self,
}
break;
case TP_TUBE_TYPE_STREAM:
- gibber_xmpp_node_set_attribute (node, "type", "stream");
+ wocky_node_set_attribute (node, "type", "stream");
break;
default:
g_assert_not_reached ();
}
- parameters_node = gibber_xmpp_node_add_child (node, "parameters");
- salut_gibber_xmpp_node_add_children_from_properties (parameters_node,
+ parameters_node = wocky_node_add_child (node, "parameters");
+ salut_wocky_node_add_children_from_properties (parameters_node,
parameters, "parameter");
g_free (service);
@@ -1528,7 +1529,7 @@ publish_tube_in_node (SalutTubesChannel *self,
struct _i_hate_g_hash_table_foreach
{
SalutTubesChannel *self;
- GibberXmppNode *tubes_node;
+ WockyNode *tubes_node;
};
static void
@@ -1542,7 +1543,7 @@ publish_tubes_in_node (gpointer key,
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (
data->self);
TpTubeChannelState state;
- GibberXmppNode *tube_node;
+ WockyNode *tube_node;
TpTubeType type;
TpHandle initiator;
@@ -1562,7 +1563,7 @@ publish_tubes_in_node (gpointer key,
/* We only announce stream tubes we initiated */
return;
- tube_node = gibber_xmpp_node_add_child (data->tubes_node, "tube");
+ tube_node = wocky_node_add_child (data->tubes_node, "tube");
publish_tube_in_node (data->self, tube_node, tube);
}
@@ -1573,9 +1574,9 @@ update_tubes_info (SalutTubesChannel *self)
TpBaseConnection *conn = (TpBaseConnection *) priv->conn;
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
conn, TP_HANDLE_TYPE_ROOM);
- GibberXmppStanza *msg;
+ WockyStanza *msg;
WockyNode *msg_node;
- GibberXmppNode *node;
+ WockyNode *node;
const gchar *jid;
struct _i_hate_g_hash_table_foreach data;
GError *error = NULL;
@@ -1586,15 +1587,15 @@ update_tubes_info (SalutTubesChannel *self)
/* build the message */
jid = tp_handle_inspect (room_repo, priv->handle);
- msg = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_MESSAGE,
- GIBBER_STANZA_SUB_TYPE_GROUPCHAT,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_GROUPCHAT,
priv->conn->name, jid,
- GIBBER_NODE, "tubes",
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
- GIBBER_NODE_END, GIBBER_STANZA_END);
+ WOCKY_NODE_START, "tubes",
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
+ WOCKY_NODE_END, NULL);
msg_node = wocky_stanza_get_top_node (msg);
- node = gibber_xmpp_node_get_child_ns (msg_node, "tubes",
+ node = wocky_node_get_child_ns (msg_node, "tubes",
GIBBER_TELEPATHY_NS_TUBES);
data.self = self;
@@ -1939,16 +1940,16 @@ stream_tube_new_connection_cb (SalutTubeIface *tube,
static void
iq_reply_cb (GibberIqHelper *helper,
- GibberXmppStanza *sent_stanza,
- GibberXmppStanza *reply_stanza,
+ WockyStanza *sent_stanza,
+ WockyStanza *reply_stanza,
GObject *object,
gpointer user_data)
{
SalutTubeIface *tube = (SalutTubeIface *) user_data;
- GibberStanzaSubType sub_type;
+ WockyStanzaSubType sub_type;
- gibber_xmpp_stanza_get_type_info (reply_stanza, NULL, &sub_type);
- if (sub_type != GIBBER_STANZA_SUB_TYPE_RESULT)
+ wocky_stanza_get_type_info (reply_stanza, NULL, &sub_type);
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_RESULT)
{
DEBUG ("The contact has declined our tube offer");
salut_tube_iface_close (tube, TRUE);
@@ -1988,9 +1989,9 @@ send_channel_iq_tube (gpointer key,
salut_tube_iface_offer_needed (tube))
{
GError *error = NULL;
- GibberXmppNode *parameters_node;
+ WockyNode *parameters_node;
const char *tube_type_str;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *top_node;
const gchar *jid_from, *jid_to;
TpHandleRepoIface *contact_repo;
@@ -2028,24 +2029,24 @@ send_channel_iq_tube (gpointer key,
port_str = g_strdup_printf ("%d", port);
tube_id_str = g_strdup_printf ("%d", tube_id);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
jid_from, jid_to,
- GIBBER_NODE, "tube",
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
- GIBBER_NODE_ATTRIBUTE, "type", tube_type_str,
- GIBBER_NODE_ATTRIBUTE, "service", service,
- GIBBER_NODE_ATTRIBUTE, "id", tube_id_str,
- GIBBER_NODE, "transport",
- GIBBER_NODE_ATTRIBUTE, "port", port_str,
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "tube",
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
+ WOCKY_NODE_ATTRIBUTE, "type", tube_type_str,
+ WOCKY_NODE_ATTRIBUTE, "service", service,
+ WOCKY_NODE_ATTRIBUTE, "id", tube_id_str,
+ WOCKY_NODE_START, "transport",
+ WOCKY_NODE_ATTRIBUTE, "port", port_str,
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
top_node = wocky_stanza_get_top_node (stanza);
- parameters_node = gibber_xmpp_node_add_child (
- gibber_xmpp_node_get_child (top_node, "tube"), "parameters");
- salut_gibber_xmpp_node_add_children_from_properties (parameters_node,
+ parameters_node = wocky_node_add_child (
+ wocky_node_get_child (top_node, "tube"), "parameters");
+ salut_wocky_node_add_children_from_properties (parameters_node,
parameters, "parameter");
if (priv->iq_helper == NULL)
@@ -2696,42 +2697,42 @@ salut_tubes_channel_get_interfaces (TpSvcChannel *iface,
void
salut_tubes_channel_bytestream_offered (SalutTubesChannel *self,
GibberBytestreamIface *bytestream,
- GibberXmppStanza *msg)
+ WockyStanza *msg)
{
SalutTubesChannelPrivate *priv = SALUT_TUBES_CHANNEL_GET_PRIVATE (self);
WockyNode *node = wocky_stanza_get_top_node (msg);
const gchar *stream_id, *tmp;
gchar *endptr;
- GibberXmppNode *si_node, *stream_node;
+ WockyNode *si_node, *stream_node;
guint tube_id;
unsigned long tube_id_tmp;
SalutTubeIface *tube;
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
/* Caller is expected to have checked that we have a stream or muc-stream
* node with a stream ID and the TUBES profile
*/
- gibber_xmpp_stanza_get_type_info (msg, &type, &sub_type);
- g_return_if_fail (type == GIBBER_STANZA_TYPE_IQ);
- g_return_if_fail (sub_type == GIBBER_STANZA_SUB_TYPE_SET);
+ wocky_stanza_get_type_info (msg, &type, &sub_type);
+ g_return_if_fail (type == WOCKY_STANZA_TYPE_IQ);
+ g_return_if_fail (sub_type == WOCKY_STANZA_SUB_TYPE_SET);
- si_node = gibber_xmpp_node_get_child_ns (node, "si",
+ si_node = wocky_node_get_child_ns (node, "si",
GIBBER_XMPP_NS_SI);
g_return_if_fail (si_node != NULL);
if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
- stream_node = gibber_xmpp_node_get_child_ns (si_node,
+ stream_node = wocky_node_get_child_ns (si_node,
"stream", GIBBER_TELEPATHY_NS_TUBES);
else
- stream_node = gibber_xmpp_node_get_child_ns (si_node,
+ stream_node = wocky_node_get_child_ns (si_node,
"muc-stream", GIBBER_TELEPATHY_NS_TUBES);
g_return_if_fail (stream_node != NULL);
- stream_id = gibber_xmpp_node_get_attribute (si_node, "id");
+ stream_id = wocky_node_get_attribute (si_node, "id");
g_return_if_fail (stream_id != NULL);
- tmp = gibber_xmpp_node_get_attribute (stream_node, "tube");
+ tmp = wocky_node_get_attribute (stream_node, "tube");
if (tmp == NULL)
{
GError e = { GIBBER_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
diff --git a/src/salut-tubes-channel.h b/src/salut-tubes-channel.h
index 8c10fc17..791350c0 100644
--- a/src/salut-tubes-channel.h
+++ b/src/salut-tubes-channel.h
@@ -21,7 +21,7 @@
#define __SALUT_TUBES_CHANNEL_H__
#include <glib-object.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-xmpp-connection.h>
#include <gibber/gibber-bytestream-iface.h>
#include <gibber/gibber-iq-helper.h>
@@ -72,15 +72,15 @@ void salut_tubes_channel_foreach (SalutTubesChannel *self,
void salut_tubes_channel_close (SalutTubesChannel *channel);
void salut_tubes_channel_bytestream_offered (SalutTubesChannel *chanel,
- GibberBytestreamIface *bytestream, GibberXmppStanza *msg);
+ GibberBytestreamIface *bytestream, WockyStanza *msg);
GPtrArray * salut_tubes_channel_muc_message_received (
- SalutTubesChannel *channel, const gchar *sender, GibberXmppStanza *stanza);
+ SalutTubesChannel *channel, const gchar *sender, WockyStanza *stanza);
SalutTubeIface * salut_tubes_channel_message_received (SalutTubesChannel *self,
const gchar *service, TpTubeType tube_type, TpHandle initiator_handle,
GHashTable *parameters, guint tube_id, guint portnum,
- GibberXmppStanza *iq_req);
+ WockyStanza *iq_req);
void salut_tubes_channel_message_close_received (SalutTubesChannel *self,
TpHandle initiator_handle, guint tube_id);
diff --git a/src/salut-tubes-manager.c b/src/salut-tubes-manager.c
index 59ea25cb..6f478e33 100644
--- a/src/salut-tubes-manager.c
+++ b/src/salut-tubes-manager.c
@@ -117,24 +117,24 @@ salut_tubes_manager_init (SalutTubesManager *self)
static gboolean
iq_tube_request_filter (SalutXmppConnectionManager *xcm,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberStanzaType type;
- GibberStanzaSubType sub_type;
+ WockyStanzaType type;
+ WockyStanzaSubType sub_type;
- gibber_xmpp_stanza_get_type_info (stanza, &type, &sub_type);
- if (type != GIBBER_STANZA_TYPE_IQ)
+ wocky_stanza_get_type_info (stanza, &type, &sub_type);
+ if (type != WOCKY_STANZA_TYPE_IQ)
return FALSE;
- if (sub_type != GIBBER_STANZA_SUB_TYPE_SET)
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- return (gibber_xmpp_node_get_child_ns (node, "tube",
+ return (wocky_node_get_child_ns (node, "tube",
GIBBER_TELEPATHY_NS_TUBES) != NULL) ||
- (gibber_xmpp_node_get_child_ns (node, "close",
+ (wocky_node_get_child_ns (node, "close",
GIBBER_TELEPATHY_NS_TUBES) != NULL);
}
@@ -142,7 +142,7 @@ iq_tube_request_filter (SalutXmppConnectionManager *xcm,
* information from a 1-1 <iq> message */
static gboolean
extract_tube_information (TpHandleRepoIface *contact_repo,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gboolean *close_out,
TpTubeType *type,
TpHandle *initiator_handle,
@@ -152,8 +152,8 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
guint *portnum,
GError **error)
{
- GibberXmppNode *iq;
- GibberXmppNode *tube_node, *close_node, *node;
+ WockyNode *iq;
+ WockyNode *tube_node, *close_node, *node;
gboolean _close;
iq = wocky_stanza_get_top_node (stanza);
@@ -161,7 +161,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
if (initiator_handle != NULL)
{
const gchar *from;
- from = gibber_xmpp_node_get_attribute (iq, "from");
+ from = wocky_node_get_attribute (iq, "from");
if (from == NULL)
{
g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
@@ -179,9 +179,9 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
}
}
- tube_node = gibber_xmpp_node_get_child_ns (iq, "tube",
+ tube_node = wocky_node_get_child_ns (iq, "tube",
GIBBER_TELEPATHY_NS_TUBES);
- close_node = gibber_xmpp_node_get_child_ns (iq, "close",
+ close_node = wocky_node_get_child_ns (iq, "close",
GIBBER_TELEPATHY_NS_TUBES);
if (tube_node == NULL && close_node == NULL)
@@ -217,7 +217,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
gchar *endptr;
long int tmp;
- str = gibber_xmpp_node_get_attribute (node, "id");
+ str = wocky_node_get_attribute (node, "id");
if (str == NULL)
{
g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
@@ -243,7 +243,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
{
const gchar *tube_type;
- tube_type = gibber_xmpp_node_get_attribute (tube_node, "type");
+ tube_type = wocky_node_get_attribute (tube_node, "type");
if (!tp_strdiff (tube_type, "stream"))
*type = TP_TUBE_TYPE_STREAM;
else if (!tp_strdiff (tube_type, "dbus"))
@@ -258,26 +258,26 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
if (service != NULL)
{
- *service = gibber_xmpp_node_get_attribute (tube_node, "service");
+ *service = wocky_node_get_attribute (tube_node, "service");
}
if (parameters != NULL)
{
- GibberXmppNode *parameters_node;
+ WockyNode *parameters_node;
- parameters_node = gibber_xmpp_node_get_child (tube_node, "parameters");
- *parameters = salut_gibber_xmpp_node_extract_properties (parameters_node,
+ parameters_node = wocky_node_get_child (tube_node, "parameters");
+ *parameters = salut_wocky_node_extract_properties (parameters_node,
"parameter");
}
if (portnum != NULL)
{
- GibberXmppNode *transport_node;
+ WockyNode *transport_node;
const gchar *str;
gchar *endptr;
long int tmp;
- transport_node = gibber_xmpp_node_get_child (tube_node, "transport");
+ transport_node = wocky_node_get_child (tube_node, "transport");
if (transport_node == NULL)
{
g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
@@ -285,7 +285,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
return FALSE;
}
- str = gibber_xmpp_node_get_attribute (transport_node, "port");
+ str = wocky_node_get_attribute (transport_node, "port");
if (str == NULL)
{
g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
@@ -309,7 +309,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
static void
iq_tube_request_cb (SalutXmppConnectionManager *xcm,
GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact,
gpointer user_data)
{
@@ -337,7 +337,7 @@ iq_tube_request_cb (SalutXmppConnectionManager *xcm,
&initiator_handle, &service, &parameters, &tube_id, &portnum,
&error))
{
- GibberXmppStanza *reply;
+ WockyStanza *reply;
reply = gibber_iq_helper_new_error_reply (stanza, XMPP_ERROR_BAD_REQUEST,
error->message);
diff --git a/src/salut-util.c b/src/salut-util.c
index 173dcfe1..04c0e95d 100644
--- a/src/salut-util.c
+++ b/src/salut-util.c
@@ -38,7 +38,7 @@ struct _xmpp_node_extract_property_data
};
static gboolean
-xmpp_node_extract_property (GibberXmppNode *node,
+xmpp_node_extract_property (WockyNode *node,
gpointer user_data)
{
struct _xmpp_node_extract_property_data *data =
@@ -51,12 +51,12 @@ xmpp_node_extract_property (GibberXmppNode *node,
if (tp_strdiff (node->name, data->prop))
return TRUE;
- name = gibber_xmpp_node_get_attribute (node, "name");
+ name = wocky_node_get_attribute (node, "name");
if (!name)
return TRUE;
- type = gibber_xmpp_node_get_attribute (node, "type");
+ type = wocky_node_get_attribute (node, "type");
value = node->content;
if (type == NULL || value == NULL)
@@ -124,7 +124,7 @@ xmpp_node_extract_property (GibberXmppNode *node,
}
/**
- * salut_gibber_xmpp_node_extract_properties
+ * salut_wocky_node_extract_properties
*
* Map a XML node to a properties hash table
*
@@ -135,7 +135,7 @@ xmpp_node_extract_property (GibberXmppNode *node,
* <prop name="prop2" type="uint">7</prop>
* </node>
*
- * salut_gibber_xmpp_node_extract_properties (node, "prop");
+ * salut_wocky_node_extract_properties (node, "prop");
*
* --> { "prop1" : "prop1_value", "prop2" : 7 }
*
@@ -144,7 +144,7 @@ xmpp_node_extract_property (GibberXmppNode *node,
*
*/
GHashTable *
-salut_gibber_xmpp_node_extract_properties (GibberXmppNode *node,
+salut_wocky_node_extract_properties (WockyNode *node,
const gchar *prop)
{
GHashTable *properties;
@@ -159,14 +159,14 @@ salut_gibber_xmpp_node_extract_properties (GibberXmppNode *node,
data.prop = prop;
data.properties = properties;
- gibber_xmpp_node_each_child (node, xmpp_node_extract_property, &data);
+ wocky_node_each_child (node, xmpp_node_extract_property, &data);
return properties;
}
struct _set_child_from_property_data
{
- GibberXmppNode *node;
+ WockyNode *node;
const gchar *prop;
};
@@ -178,7 +178,7 @@ set_child_from_property (gpointer key,
GValue *gvalue = value;
struct _set_child_from_property_data *data =
(struct _set_child_from_property_data *) user_data;
- GibberXmppNode *child;
+ WockyNode *child;
const char *type = NULL;
if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
@@ -209,11 +209,11 @@ set_child_from_property (gpointer key,
return;
}
- child = gibber_xmpp_node_add_child (data->node, data->prop);
+ child = wocky_node_add_child (data->node, data->prop);
if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
{
- gibber_xmpp_node_set_content (child,
+ wocky_node_set_content (child,
g_value_get_string (gvalue));
}
else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT)
@@ -221,7 +221,7 @@ set_child_from_property (gpointer key,
gchar *str;
str = g_strdup_printf ("%d", g_value_get_int (gvalue));
- gibber_xmpp_node_set_content (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -230,7 +230,7 @@ set_child_from_property (gpointer key,
gchar *str;
str = g_strdup_printf ("%u", g_value_get_uint (gvalue));
- gibber_xmpp_node_set_content (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -242,7 +242,7 @@ set_child_from_property (gpointer key,
type = "bytes";
arr = g_value_get_boxed (gvalue);
str = g_base64_encode ((const guchar *) arr->data, arr->len);
- gibber_xmpp_node_set_content (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -252,22 +252,22 @@ set_child_from_property (gpointer key,
val = g_value_get_boolean (gvalue);
if (val)
- gibber_xmpp_node_set_content (child, "1");
+ wocky_node_set_content (child, "1");
else
- gibber_xmpp_node_set_content (child, "0");
+ wocky_node_set_content (child, "0");
}
else
{
g_assert_not_reached ();
}
- gibber_xmpp_node_set_attribute (child, "name", key);
- gibber_xmpp_node_set_attribute (child, "type", type);
+ wocky_node_set_attribute (child, "name", key);
+ wocky_node_set_attribute (child, "type", type);
}
/**
*
- * gibber_xmpp_node_set_children_from_properties
+ * wocky_node_set_children_from_properties
*
* Map a properties hash table to a XML node.
*
@@ -275,7 +275,7 @@ set_child_from_property (gpointer key,
*
* properties = { "prop1" : "prop1_value", "prop2" : 7 }
*
- * salut_gibber_xmpp_node_add_children_from_properties (node, properties,
+ * salut_wocky_node_add_children_from_properties (node, properties,
* "prop");
*
* --> <node>
@@ -285,7 +285,7 @@ set_child_from_property (gpointer key,
*
*/
void
-salut_gibber_xmpp_node_add_children_from_properties (GibberXmppNode *node,
+salut_wocky_node_add_children_from_properties (WockyNode *node,
GHashTable *properties,
const gchar *prop)
{
diff --git a/src/salut-util.h b/src/salut-util.h
index 9443c12c..17fca019 100644
--- a/src/salut-util.h
+++ b/src/salut-util.h
@@ -23,12 +23,12 @@
#include <glib.h>
#include <glib-object.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
/* Mapping a XMPP node with a GHashTable */
-GHashTable *salut_gibber_xmpp_node_extract_properties (GibberXmppNode *node,
+GHashTable *salut_wocky_node_extract_properties (WockyNode *node,
const gchar *prop);
-void salut_gibber_xmpp_node_add_children_from_properties (GibberXmppNode *node,
+void salut_wocky_node_add_children_from_properties (WockyNode *node,
GHashTable *properties, const gchar *prop);
gchar *salut_generate_id (void);
diff --git a/src/salut-xmpp-connection-manager.c b/src/salut-xmpp-connection-manager.c
index b288f240..8644a2fe 100644
--- a/src/salut-xmpp-connection-manager.c
+++ b/src/salut-xmpp-connection-manager.c
@@ -348,7 +348,7 @@ static void
apply_filters (SalutXmppConnectionManager *self,
GibberXmppConnection *conn,
GSList *list,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
SalutContact *contact)
{
GSList *l;
@@ -472,7 +472,7 @@ add_refcount_timeout (SalutXmppConnectionManager *self,
static void
connection_stanza_received_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer user_data)
{
SalutXmppConnectionManager *self = SALUT_XMPP_CONNECTION_MANAGER (user_data);
@@ -719,9 +719,9 @@ incoming_pending_connection_stream_opened_cb (GibberXmppConnection *conn,
if (!tp_strdiff (version, "1.0"))
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
/* Send empty stream features */
- stanza = gibber_xmpp_stanza_new_ns ("features", GIBBER_XMPP_NS_STREAM);
+ stanza = wocky_stanza_new ("features", GIBBER_XMPP_NS_STREAM);
gibber_xmpp_connection_send (conn, stanza, NULL);
g_object_unref (stanza);
}
@@ -771,7 +771,7 @@ incoming_pending_connection_stream_opened_cb (GibberXmppConnection *conn,
static void
incoming_pending_connection_stanza_received_cb (GibberXmppConnection *conn,
- GibberXmppStanza *stanza,
+ WockyStanza *stanza,
gpointer userdata)
{
SalutXmppConnectionManager *self = SALUT_XMPP_CONNECTION_MANAGER (userdata);
@@ -780,7 +780,7 @@ incoming_pending_connection_stanza_received_cb (GibberXmppConnection *conn,
/* If the identity wasn't clear from the stream opening we only wait to the
* very first message */
- from = gibber_xmpp_node_get_attribute (node, "from");
+ from = wocky_node_get_attribute (node, "from");
if (incoming_pending_connection_got_from (self, conn, from))
{
/* We can filter the stanza now */
diff --git a/src/salut-xmpp-connection-manager.h b/src/salut-xmpp-connection-manager.h
index 46dff35f..9c5b5787 100644
--- a/src/salut-xmpp-connection-manager.h
+++ b/src/salut-xmpp-connection-manager.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-xmpp-connection.h>
#include "salut-connection.h"
@@ -88,11 +88,11 @@ typedef enum
typedef gboolean (* SalutXmppConnectionManagerStanzaFilterFunc) (
SalutXmppConnectionManager *manager, GibberXmppConnection *conn,
- GibberXmppStanza *stanza, SalutContact *contact, gpointer user_data);
+ WockyStanza *stanza, SalutContact *contact, gpointer user_data);
typedef void (* SalutXmppConnectionManagerStanzaCallbackFunc) (
SalutXmppConnectionManager *mgr, GibberXmppConnection *conn,
- GibberXmppStanza *stanza, SalutContact *contact, gpointer user_data);
+ WockyStanza *stanza, SalutContact *contact, gpointer user_data);
SalutXmppConnectionManager * salut_xmpp_connection_manager_new (
SalutConnection *connection, SalutContactManager *contact_manager);
diff --git a/src/salut.c b/src/salut.c
index 726743d0..91f7285b 100644
--- a/src/salut.c
+++ b/src/salut.c
@@ -8,6 +8,7 @@
#include "salut-connection-manager.h"
#include "salut-avahi-discovery-client.h"
#include "debug.h"
+#include "plugin-loader.h"
static TpBaseConnectionManager *
salut_create_connection_manager (void)
@@ -22,6 +23,8 @@ int
main (int argc, char **argv)
{
GLogLevelFlags fatal_mask;
+ gint ret;
+ SalutPluginLoader *loader;
g_type_init ();
g_thread_init (NULL);
@@ -39,9 +42,15 @@ main (int argc, char **argv)
tp_debug_set_persistent (TRUE);
#endif
- return tp_run_connection_manager ("telepathy-salut", VERSION,
+ loader = salut_plugin_loader_dup ();
+
+ ret = tp_run_connection_manager ("telepathy-salut", VERSION,
salut_create_connection_manager,
argc, argv);
+
+ g_object_unref (loader);
+
+ return ret;
}
diff --git a/src/telepathy-salut-uninstalled.pc.in b/src/telepathy-salut-uninstalled.pc.in
new file mode 100644
index 00000000..b9be57dd
--- /dev/null
+++ b/src/telepathy-salut-uninstalled.pc.in
@@ -0,0 +1,12 @@
+prefix=
+exec_prefix=
+abs_top_srcdir=@abs_top_srcdir@
+abs_top_builddir=@abs_top_builddir@
+libdir=@libdir@
+
+salutpath=@abs_top_builddir@/src/telepathy-salut
+
+Name: Telepathy-Salut (uninstalled)
+Description: Local XMPP backend for the Telepathy framework (uninstalled)
+Version: @VERSION@
+Requires: pkg-config >= 0.21
diff --git a/src/telepathy-salut.pc.in b/src/telepathy-salut.pc.in
new file mode 100644
index 00000000..6b473976
--- /dev/null
+++ b/src/telepathy-salut.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+libexecdir=@libexecdir@
+
+salutpath=${libexecdir}/telepathy-salut
+
+Name: Telepathy-Salut
+Description: Local XMPP backend for the Telepathy framework
+Version: @VERSION@
+Requires: pkg-config >= 0.21
diff --git a/src/text-helper.c b/src/text-helper.c
index 5155d514..84376251 100644
--- a/src/text-helper.c
+++ b/src/text-helper.c
@@ -45,26 +45,26 @@
#include "salut-util.h"
static void
-add_text (GibberXmppStanza *stanza, const gchar *text)
+add_text (WockyStanza *stanza, const gchar *text)
{
WockyNode *node = wocky_stanza_get_top_node (stanza);
- GibberXmppNode *htmlnode;
+ WockyNode *htmlnode;
- gibber_xmpp_node_add_child_with_content (node, "body", text);
+ wocky_node_add_child_with_content (node, "body", text);
/* Add plain xhtml-im node */
- htmlnode = gibber_xmpp_node_add_child_ns (node, "html",
+ htmlnode = wocky_node_add_child_ns (node, "html",
GIBBER_XMPP_NS_XHTML_IM);
- gibber_xmpp_node_add_child_with_content_ns (htmlnode, "body", text,
+ wocky_node_add_child_with_content_ns (htmlnode, "body", text,
GIBBER_W3C_NS_XHTML);
}
-static GibberXmppStanza *
+static WockyStanza *
create_message_stanza (const gchar *from,
const gchar *to, TpChannelTextMessageType type, const gchar *text,
GError **error)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
if (type > TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE)
@@ -76,11 +76,11 @@ create_message_stanza (const gchar *from,
return NULL;
}
- stanza = gibber_xmpp_stanza_new_ns ("message", WOCKY_XMPP_NS_JABBER_CLIENT);
+ stanza = wocky_stanza_new ("message", WOCKY_XMPP_NS_JABBER_CLIENT);
node = wocky_stanza_get_top_node (stanza);
- gibber_xmpp_node_set_attribute (node, "from", from);
- gibber_xmpp_node_set_attribute (node, "to", to);
+ wocky_node_set_attribute (node, "from", from);
+ wocky_node_set_attribute (node, "to", to);
if (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION)
{
@@ -97,14 +97,14 @@ create_message_stanza (const gchar *from,
return stanza;
}
-GibberXmppStanza *
+WockyStanza *
text_helper_create_message (const gchar *from,
const gchar *to,
TpChannelTextMessageType type,
const gchar *text,
GError **error)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
stanza = create_message_stanza (from, to, type, text, error);
@@ -117,10 +117,10 @@ text_helper_create_message (const gchar *from,
{
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION:
- gibber_xmpp_node_set_attribute (node, "type", "chat");
+ wocky_node_set_attribute (node, "type", "chat");
break;
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE:
- gibber_xmpp_node_set_attribute (node, "type", "normal");
+ wocky_node_set_attribute (node, "type", "normal");
break;
default:
g_assert_not_reached ();
@@ -130,14 +130,14 @@ text_helper_create_message (const gchar *from,
return stanza;
}
-GibberXmppStanza *
+WockyStanza *
text_helper_create_message_groupchat (const gchar *from,
const gchar *to,
TpChannelTextMessageType type,
const gchar *text,
GError **error)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *node;
stanza = create_message_stanza (from, to, type, text, error);
@@ -150,10 +150,10 @@ text_helper_create_message_groupchat (const gchar *from,
{
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION:
- gibber_xmpp_node_set_attribute (node, "type", "groupchat");
+ wocky_node_set_attribute (node, "type", "groupchat");
break;
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE:
- gibber_xmpp_node_set_attribute (node, "type", "normal");
+ wocky_node_set_attribute (node, "type", "normal");
break;
default:
g_assert_not_reached ();
@@ -164,29 +164,29 @@ text_helper_create_message_groupchat (const gchar *from,
}
gboolean
-text_helper_parse_incoming_message (GibberXmppStanza *stanza,
+text_helper_parse_incoming_message (WockyStanza *stanza,
const gchar **from,
TpChannelTextMessageType *msgtype,
const gchar **body,
const gchar **body_offset)
{
const gchar *type;
- GibberXmppNode *node;
- GibberXmppNode *event;
+ WockyNode *node;
+ WockyNode *event;
WockyNode *top_node = wocky_stanza_get_top_node (stanza);
- *from = gibber_xmpp_node_get_attribute (top_node, "from");
- type = gibber_xmpp_node_get_attribute (top_node, "type");
+ *from = wocky_node_get_attribute (top_node, "from");
+ type = wocky_node_get_attribute (top_node, "type");
/* Work around iChats strange way of doing typing notification */
- event = gibber_xmpp_node_get_child_ns (top_node, "x",
+ event = wocky_node_get_child_ns (top_node, "x",
GIBBER_XMPP_NS_EVENT);
if (event != NULL)
{
/* If the event has a composing and an id child, this is a typing
* notification and it should be dropped */
- if (gibber_xmpp_node_get_child (event, "composing") != NULL &&
- gibber_xmpp_node_get_child (event, "id") != NULL)
+ if (wocky_node_get_child (event, "composing") != NULL &&
+ wocky_node_get_child (event, "id") != NULL)
{
return FALSE;
}
@@ -194,7 +194,7 @@ text_helper_parse_incoming_message (GibberXmppStanza *stanza,
/*
* Parse body if it exists.
*/
- node = gibber_xmpp_node_get_child (top_node, "body");
+ node = wocky_node_get_child (top_node, "body");
if (node)
{
@@ -317,7 +317,7 @@ text_helper_report_delivery_error (TpSvcChannel *self,
tp_message_set_handle (delivery_echo, 0, "message-sender",
TP_HANDLE_TYPE_CONTACT, base_conn->self_handle);
tp_message_set_uint32 (delivery_echo, 0, "message-type", type);
- tp_message_set_uint64 (delivery_echo, 0, "message-sent", (guint64)timestamp);
+ tp_message_set_int64 (delivery_echo, 0, "message-sent", (gint64)timestamp);
tp_message_set_string (delivery_echo, 1, "content-type", "text/plain");
tp_message_set_string (delivery_echo, 1, "content", text);
@@ -349,7 +349,7 @@ text_helper_create_received_message (TpBaseConnection *base_conn,
tp_message_set_uint32 (message, 0, "message-type", type);
tp_message_set_handle (message, 0, "message-sender",
TP_HANDLE_TYPE_CONTACT, sender_handle);
- tp_message_set_uint32 (message, 0, "message-received", timestamp);
+ tp_message_set_int64 (message, 0, "message-received", timestamp);
tp_message_set_string (message, 1, "content-type", "text/plain");
tp_message_set_string (message, 1, "content", text);
diff --git a/src/text-helper.h b/src/text-helper.h
index 0d900485..5d810c68 100644
--- a/src/text-helper.h
+++ b/src/text-helper.h
@@ -23,21 +23,21 @@
#include <telepathy-glib/enums.h>
#include <telepathy-glib/channel.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
/* Utility functions for the helper user */
gboolean
-text_helper_parse_incoming_message (GibberXmppStanza *stanza,
+text_helper_parse_incoming_message (WockyStanza *stanza,
const gchar **from, TpChannelTextMessageType *msgtype,
const gchar **body, const gchar **body_offset);
-GibberXmppStanza *
+WockyStanza *
text_helper_create_message (const gchar *from,
const gchar *to, TpChannelTextMessageType type,
const gchar *text, GError **error);
-GibberXmppStanza *
+WockyStanza *
text_helper_create_message_groupchat (const gchar *from, const gchar *to,
TpChannelTextMessageType type, const gchar *text, GError **error);
diff --git a/src/tube-dbus.c b/src/tube-dbus.c
index bab0e96e..3e7c8789 100644
--- a/src/tube-dbus.c
+++ b/src/tube-dbus.c
@@ -904,7 +904,8 @@ salut_tube_dbus_constructor (GType type,
GObject *obj;
SalutTubeDBus *self;
SalutTubeDBusPrivate *priv;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
+ TpBaseConnection *base_conn;
TpHandleRepoIface *contact_repo;
TpHandleRepoIface *handles_repo;
TpSocketAccessControl access_control;
@@ -915,18 +916,18 @@ salut_tube_dbus_constructor (GType type,
priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
- handles_repo = tp_base_connection_get_handles
- ((TpBaseConnection *) priv->conn, priv->handle_type);
+ base_conn = TP_BASE_CONNECTION (priv->conn);
+ handles_repo = tp_base_connection_get_handles (base_conn, priv->handle_type);
/* Ref the initiator handle */
g_assert (priv->conn != NULL);
g_assert (priv->initiator != 0);
- contact_repo = tp_base_connection_get_handles
- ((TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
+ contact_repo = tp_base_connection_get_handles (base_conn,
+ TP_HANDLE_TYPE_CONTACT);
tp_handle_ref (contact_repo, priv->initiator);
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
DEBUG ("Registering at '%s'", priv->object_path);
diff --git a/src/tube-stream.c b/src/tube-stream.c
index 971afbec..7660eb82 100644
--- a/src/tube-stream.c
+++ b/src/tube-stream.c
@@ -42,7 +42,7 @@
#include <telepathy-glib/svc-channel.h>
#include <telepathy-glib/svc-generic.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include <gibber/gibber-namespaces.h>
#include <gibber/gibber-bytestream-direct.h>
#include <gibber/gibber-bytestream-iface.h>
@@ -54,7 +54,7 @@
#include <gibber/gibber-tcp-transport.h>
#include <gibber/gibber-transport.h>
#include <gibber/gibber-unix-transport.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#define DEBUG_FLAG DEBUG_TUBES
@@ -166,7 +166,7 @@ struct _SalutTubeStreamPrivate
guint id;
guint port;
GibberXmppConnection *xmpp_connection;
- GibberXmppStanza *iq_req;
+ WockyStanza *iq_req;
gchar *object_path;
/* Bytestreams for MUC tubes (using stream initiation) or 1-1 tubes (using
@@ -531,8 +531,8 @@ start_stream_initiation (SalutTubeStream *self,
GError **error)
{
SalutTubeStreamPrivate *priv = SALUT_TUBE_STREAM_GET_PRIVATE (self);
- GibberXmppNode *node, *si_node;
- GibberXmppStanza *msg;
+ WockyNode *node, *si_node;
+ WockyStanza *msg;
WockyNode *msg_node;
TpHandleRepoIface *contact_repo;
const gchar *jid;
@@ -556,7 +556,7 @@ start_stream_initiation (SalutTubeStream *self,
stream_id, GIBBER_TELEPATHY_NS_TUBES);
msg_node = wocky_stanza_get_top_node (msg);
- si_node = gibber_xmpp_node_get_child_ns (msg_node, "si", GIBBER_XMPP_NS_SI);
+ si_node = wocky_node_get_child_ns (msg_node, "si", GIBBER_XMPP_NS_SI);
g_assert (si_node != NULL);
id_str = g_strdup_printf ("%u", priv->id);
@@ -564,12 +564,12 @@ start_stream_initiation (SalutTubeStream *self,
g_assert (priv->handle_type == TP_HANDLE_TYPE_ROOM);
/* FIXME: this needs standardizing */
- node = gibber_xmpp_node_add_child_ns (si_node, "muc-stream",
+ node = wocky_node_add_child_ns (si_node, "muc-stream",
GIBBER_TELEPATHY_NS_TUBES);
- gibber_xmpp_node_set_attribute (node, "muc", tp_handle_inspect (
+ wocky_node_set_attribute (node, "muc", tp_handle_inspect (
room_repo, priv->handle));
- gibber_xmpp_node_set_attribute (node, "tube", id_str);
+ wocky_node_set_attribute (node, "tube", id_str);
data = g_slice_new (struct _extra_bytestream_negotiate_cb_data);
data->self = self;
@@ -1463,7 +1463,8 @@ salut_tube_stream_constructor (GType type,
GObject *obj;
SalutTubeStreamPrivate *priv;
TpHandleRepoIface *contact_repo;
- DBusGConnection *bus;
+ TpDBusDaemon *bus;
+ TpBaseConnection *base_conn;
obj = G_OBJECT_CLASS (salut_tube_stream_parent_class)->
constructor (type, n_props, props);
@@ -1471,10 +1472,10 @@ salut_tube_stream_constructor (GType type,
priv = SALUT_TUBE_STREAM_GET_PRIVATE (SALUT_TUBE_STREAM (obj));
/* Ref the initiator handle */
- g_assert (priv->conn != NULL);
+ base_conn = TP_BASE_CONNECTION (priv->conn);
g_assert (priv->initiator != 0);
- contact_repo = tp_base_connection_get_handles
- ((TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
+ contact_repo = tp_base_connection_get_handles (base_conn,
+ TP_HANDLE_TYPE_CONTACT);
tp_handle_ref (contact_repo, priv->initiator);
if (priv->initiator == priv->self_handle)
@@ -1501,8 +1502,8 @@ salut_tube_stream_constructor (GType type,
g_assert (priv->xmpp_connection_manager == NULL);
}
- bus = tp_get_bus ();
- dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ bus = tp_base_connection_get_dbus_daemon (base_conn);
+ tp_dbus_daemon_register_object (bus, priv->object_path, obj);
DEBUG ("Registering at '%s'", priv->object_path);
@@ -1814,7 +1815,7 @@ salut_tube_stream_new (SalutConnection *conn,
GHashTable *parameters,
guint id,
guint portnum,
- GibberXmppStanza *iq_req)
+ WockyStanza *iq_req)
{
SalutTubeStream *obj;
char *object_path;
@@ -1890,7 +1891,7 @@ salut_tube_stream_accept (SalutTubeIface *tube,
{
SalutTubeStream *self = SALUT_TUBE_STREAM (tube);
SalutTubeStreamPrivate *priv = SALUT_TUBE_STREAM_GET_PRIVATE (self);
- GibberXmppStanza *reply;
+ WockyStanza *reply;
if (priv->state != TP_TUBE_CHANNEL_STATE_LOCAL_PENDING)
return TRUE;
@@ -2034,8 +2035,8 @@ salut_tube_stream_listen (SalutTubeIface *tube)
static void
iq_close_reply_cb (GibberIqHelper *helper,
- GibberXmppStanza *sent_stanza,
- GibberXmppStanza *reply_stanza,
+ WockyStanza *sent_stanza,
+ WockyStanza *reply_stanza,
GObject *object,
gpointer user_data)
{
@@ -2063,7 +2064,7 @@ salut_tube_stream_close (SalutTubeIface *tube, gboolean closed_remotely)
* contact */
if (!closed_remotely && priv->handle_type == TP_HANDLE_TYPE_CONTACT)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
const gchar *jid_from, *jid_to;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
@@ -2074,14 +2075,14 @@ salut_tube_stream_close (SalutTubeIface *tube, gboolean closed_remotely)
jid_from = tp_handle_inspect (contact_repo, priv->self_handle);
tube_id_str = g_strdup_printf ("%u", priv->id);
- stanza = gibber_xmpp_stanza_build (GIBBER_STANZA_TYPE_IQ,
- GIBBER_STANZA_SUB_TYPE_SET,
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ,
+ WOCKY_STANZA_SUB_TYPE_SET,
jid_from, jid_to,
- GIBBER_NODE, "close",
- GIBBER_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
- GIBBER_NODE_ATTRIBUTE, "id", tube_id_str,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "close",
+ WOCKY_NODE_XMLNS, GIBBER_TELEPATHY_NS_TUBES,
+ WOCKY_NODE_ATTRIBUTE, "id", tube_id_str,
+ WOCKY_NODE_END,
+ NULL);
ensure_iq_helper (self);
@@ -2117,10 +2118,10 @@ salut_tube_stream_close (SalutTubeIface *tube, gboolean closed_remotely)
}
static void
-augment_si_accept_iq (GibberXmppNode *si,
+augment_si_accept_iq (WockyNode *si,
gpointer user_data)
{
- gibber_xmpp_node_add_child_ns (si, "tube", GIBBER_TELEPATHY_NS_TUBES);
+ wocky_node_add_child_ns (si, "tube", GIBBER_TELEPATHY_NS_TUBES);
}
/**
diff --git a/src/tube-stream.h b/src/tube-stream.h
index 11dbc8b4..a6079e0b 100644
--- a/src/tube-stream.h
+++ b/src/tube-stream.h
@@ -70,7 +70,7 @@ SalutTubeStream *salut_tube_stream_new (SalutConnection *conn,
TpHandleType handle_type, TpHandle self_handle, TpHandle initiator,
gboolean offered, const gchar *service,
GHashTable *parameters, guint id, guint portnum,
- GibberXmppStanza *iq_req);
+ WockyStanza *iq_req);
gboolean salut_tube_stream_check_params (TpSocketAddressType address_type,
const GValue *address, TpSocketAccessControl access_control,
diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c
index e0ce1466..71adefeb 100644
--- a/src/write-mgr-file.c
+++ b/src/write-mgr-file.c
@@ -334,7 +334,11 @@ main (void)
g_type_init ();
dbus_g_type_specialized_init ();
- protocols = g_slist_prepend (protocols, salut_protocol_new (G_TYPE_INVALID));
+ protocols = g_slist_prepend (protocols, salut_protocol_new (G_TYPE_INVALID,
+ NULL,
+ SALUT_PROTOCOL_LOCAL_XMPP_NAME,
+ SALUT_PROTOCOL_LOCAL_XMPP_ENGLISH_NAME,
+ SALUT_PROTOCOL_LOCAL_XMPP_ICON_NAME));
s = mgr_file_contents (TP_CM_BUS_NAME_BASE "salut",
TP_CM_OBJECT_PATH_BASE "salut",
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9808cf6a..78a3ecef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,11 +4,12 @@ include $(top_srcdir)/rules/check.mak
SUPPRESSIONS=valgrind.supp dlopen.supp
-# Teach it how to make libgibber.la
-$(top_builddir)/lib/gibber/libgibber.la:
- ${MAKE} -C $(top_builddir)/lib/gibber libgibber.la
+SUBDIRS = twisted
-.PHONY: $(top_builddir)/lib/gibber/libgibber.la
+.PHONY: always-run test test-report
+
+# ------------------------------------------------------------------------------
+# telepathy-salut-debug
noinst_PROGRAMS = \
telepathy-salut-debug
@@ -18,33 +19,20 @@ telepathy_salut_debug_SOURCES = \
telepathy_salut_debug_LDADD = \
$(top_builddir)/src/libsalut-convenience.la \
- $(top_builddir)/src/libsalut-backend-dummy.la \
$(top_builddir)/lib/gibber/libgibber.la \
$(top_builddir)/extensions/libsalut-extensions.la \
-ltelepathy-glib
-if HAVE_CHECK
-check_PROGRAMS = check-main
-TESTS = check-main
-check_main_SOURCES = \
- check-main.c \
- check-helpers.c \
- check-helpers.h \
- check-node-properties.c \
- check-salut.h
-
-check_main_LDADD = \
- @CHECK_LIBS@ \
- $(top_builddir)/lib/gibber/libgibber.la \
- $(top_builddir)/src/libsalut-convenience.la \
- $(top_builddir)/src/libsalut-backend-avahi.la \
- $(AM_LDFLAGS)
+# Teach it how to make libgibber.la
+$(top_builddir)/lib/gibber/libgibber.la:
+ ${MAKE} -C $(top_builddir)/lib/gibber libgibber.la
-check_main_CFLAGS = \
- @CHECK_CFLAGS@ \
- $(AM_CFLAGS)
+.PHONY: $(top_builddir)/lib/gibber/libgibber.la
-endif
+# ------------------------------------------------------------------------------
+# TESTS
+
+check_PROGRAMS = check-node-properties
AM_CFLAGS = $(ERROR_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ @WOCKY_CFLAGS@ \
@DBUS_CFLAGS@ @TELEPATHY_GLIB_CFLAGS@ \
@@ -54,22 +42,28 @@ AM_CFLAGS = $(ERROR_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ @WOCKY_CFLAGS@ \
AM_LDFLAGS = @GLIB_LIBS@ @TELEPATHY_GLIB_LIBS@
+check_node_properties_LDADD = \
+ $(top_builddir)/lib/gibber/libgibber.la \
+ $(top_builddir)/src/libsalut-convenience.la \
+ $(top_builddir)/src/libsalut-backend-avahi.la \
+ $(AM_LDFLAGS)
+
+check_node_properties_CFLAGS = \
+ $(AM_CFLAGS)
+
+test: ${TEST_PROGS}
+ gtester -k --verbose $(check_PROGRAMS)
+
+# ------------------------------------------------------------------------------
+# CODING STYLE
+
# Coding style checks
check_c_sources = \
$(telepathy_salut_debug_SOURCES) \
$(test_xmpp_connection_SOURCES) \
- $(test_r_multicast_transport_io_SOURCES)
-
-if HAVE_CHECK
- check_c_sources += $(check_main_SOURCES)
-endif
+ $(test_r_multicast_transport_io_SOURCES) \
+ $(check_main_SOURCES)
include $(top_srcdir)/tools/check-coding-style.mk
-check-local: check-coding-style
-
-SUBDIRS = twisted
-
-$(check_SCRIPTS): always-run
- chmod +x $(srcdir)/$@
-.PHONY: always-run
+check-local: check-coding-style test
diff --git a/tests/check-helpers.c b/tests/check-helpers.c
deleted file mode 100644
index 86ef1154..00000000
--- a/tests/check-helpers.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * check-helpers.c - Source for some check helpers
- * Copyright (C) 2007 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
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "check-helpers.h"
-
-static gboolean expecting_critical = FALSE;
-static gboolean received_critical = FALSE;
-
-static void
-check_helper_log_critical_func (const gchar *log_damain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
-{
-
- if (!expecting_critical)
- {
- fail ("Unexpected critical message: %s\n", message);
- }
-
- g_assert (log_level & G_LOG_LEVEL_CRITICAL);
-
- received_critical = TRUE;
-}
-
-gboolean
-got_critical (void)
-{
- return received_critical;
-}
-
-void
-expect_critical (gboolean expected)
-{
- expecting_critical = expected;
- received_critical = FALSE;
-}
-
-void
-check_helpers_init (void)
-{
- g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL,
- check_helper_log_critical_func, NULL);
-}
diff --git a/tests/check-helpers.h b/tests/check-helpers.h
deleted file mode 100644
index b71b3b65..00000000
--- a/tests/check-helpers.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * check-helpers.c - Source for some check helpers
- * Copyright (C) 2007 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
- */
-#ifndef __CHECK_HELPERS_H__
-#define __CHECK_HELPERS_H__
-
-#include <glib.h>
-#include <check.h>
-
-void
-check_helpers_init (void);
-
-void
-expect_critical (gboolean expected);
-
-gboolean
-got_critical (void);
-
-#define fail_unless_critical(expr, ...) \
-G_STMT_START { \
- expect_critical (TRUE); \
- expr; \
- _fail_unless (got_critical (), __FILE__, __LINE__, \
- "Expected g_critical, got none", ## __VA_ARGS__, NULL); \
- expect_critical (FALSE); \
-} G_STMT_END;
-
-#endif /* #ifndef __CHECK_HELPERS_H__ */
diff --git a/tests/check-main.c b/tests/check-main.c
deleted file mode 100644
index 7d1a85f5..00000000
--- a/tests/check-main.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <glib-object.h>
-
-#include <check.h>
-
-#include "check-salut.h"
-#include "check-helpers.h"
-
-#include "config.h"
-
-static Suite *
-make_salut_suite (void)
-{
- Suite *s = suite_create ("Salut");
-
- suite_add_tcase (s, make_salut_gibber_xmpp_node_properties_tcase ());
-
- return s;
-}
-
-int
-main (void)
-{
- int number_failed = 0;
- Suite *s;
- SRunner *sr;
-
- check_helpers_init ();
- g_type_init ();
-
- s = make_salut_suite ();
- sr = srunner_create (s);
- srunner_run_all (sr, CK_NORMAL);
- number_failed += srunner_ntests_failed (sr);
- srunner_free (sr);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
diff --git a/tests/check-node-properties.c b/tests/check-node-properties.c
index ff592418..4cb53499 100644
--- a/tests/check-node-properties.c
+++ b/tests/check-node-properties.c
@@ -1,7 +1,7 @@
/*
* check-xmpp-node-properties.c - Test for
- * salut_gibber_xmpp_node_extract_properties and
- * salut_gibber_xmpp_node_add_children_from_properties
+ * salut_wocky_node_extract_properties and
+ * salut_wocky_node_add_children_from_properties
* Copyright (C) 2007 Collabora Ltd.
* @author Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
*
@@ -26,57 +26,54 @@
#include <string.h>
#include <dbus/dbus-glib.h>
-#include <gibber/gibber-xmpp-stanza.h>
+#include <wocky/wocky-stanza.h>
#include "salut-util.h"
-#include <check.h>
-#include "check-helpers.h"
-#include "check-salut.h"
-
-static GibberXmppStanza *
+static WockyStanza *
create_sample_stanza (void)
{
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
- stanza = gibber_xmpp_stanza_build (
- GIBBER_STANZA_TYPE_MESSAGE, GIBBER_STANZA_SUB_TYPE_NONE,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
"alice@collabora.co.uk", "bob@collabora.co.uk",
- GIBBER_NODE, "properties",
- GIBBER_NODE, "prop",
- GIBBER_NODE_ATTRIBUTE, "name", "prop1",
- GIBBER_NODE_ATTRIBUTE, "type", "str",
- GIBBER_NODE_TEXT, "prop1_value",
- GIBBER_NODE_END,
- GIBBER_NODE, "prop",
- GIBBER_NODE_ATTRIBUTE, "name", "prop2",
- GIBBER_NODE_ATTRIBUTE, "type", "int",
- GIBBER_NODE_TEXT, "-7",
- GIBBER_NODE_END,
- GIBBER_NODE, "prop",
- GIBBER_NODE_ATTRIBUTE, "name", "prop3",
- GIBBER_NODE_ATTRIBUTE, "type", "uint",
- GIBBER_NODE_TEXT, "10",
- GIBBER_NODE_END,
- GIBBER_NODE, "prop",
- GIBBER_NODE_ATTRIBUTE, "name", "prop4",
- GIBBER_NODE_ATTRIBUTE, "type", "bytes",
- GIBBER_NODE_TEXT, "YWJjZGU=",
- GIBBER_NODE_END,
- GIBBER_NODE, "prop",
- GIBBER_NODE_ATTRIBUTE, "name", "prop5",
- GIBBER_NODE_ATTRIBUTE, "type", "bool",
- GIBBER_NODE_TEXT, "1",
- GIBBER_NODE_END,
- GIBBER_NODE_END,
- GIBBER_STANZA_END);
+ WOCKY_NODE_START, "properties",
+ WOCKY_NODE_START, "prop",
+ WOCKY_NODE_ATTRIBUTE, "name", "prop1",
+ WOCKY_NODE_ATTRIBUTE, "type", "str",
+ WOCKY_NODE_TEXT, "prop1_value",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "prop",
+ WOCKY_NODE_ATTRIBUTE, "name", "prop2",
+ WOCKY_NODE_ATTRIBUTE, "type", "int",
+ WOCKY_NODE_TEXT, "-7",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "prop",
+ WOCKY_NODE_ATTRIBUTE, "name", "prop3",
+ WOCKY_NODE_ATTRIBUTE, "type", "uint",
+ WOCKY_NODE_TEXT, "10",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "prop",
+ WOCKY_NODE_ATTRIBUTE, "name", "prop4",
+ WOCKY_NODE_ATTRIBUTE, "type", "bytes",
+ WOCKY_NODE_TEXT, "YWJjZGU=",
+ WOCKY_NODE_END,
+ WOCKY_NODE_START, "prop",
+ WOCKY_NODE_ATTRIBUTE, "name", "prop5",
+ WOCKY_NODE_ATTRIBUTE, "type", "bool",
+ WOCKY_NODE_TEXT, "1",
+ WOCKY_NODE_END,
+ WOCKY_NODE_END,
+ NULL);
return stanza;
}
-START_TEST (test_extract_properties)
+static void
+test_extract_properties (void)
{
- GibberXmppStanza *stanza;
- GibberXmppNode *node;
+ WockyStanza *stanza;
+ WockyNode *node;
GHashTable *properties;
GValue *value;
const gchar *prop1_value;
@@ -86,59 +83,58 @@ START_TEST (test_extract_properties)
gboolean prop5_value;
stanza = create_sample_stanza ();
- node = gibber_xmpp_node_get_child (wocky_stanza_get_top_node (stanza),
+ node = wocky_node_get_child (wocky_stanza_get_top_node (stanza),
"properties");
- fail_unless (node != NULL);
- properties = salut_gibber_xmpp_node_extract_properties (node, "prop");
+ g_assert (node != NULL);
+ properties = salut_wocky_node_extract_properties (node, "prop");
- fail_unless (properties != NULL);
- fail_unless (g_hash_table_size (properties) == 5);
+ g_assert (properties != NULL);
+ g_assert_cmpuint (g_hash_table_size (properties), ==, 5);
/* prop1 */
value = g_hash_table_lookup (properties, "prop1");
- fail_unless (value != NULL);
- fail_unless (G_VALUE_TYPE (value) == G_TYPE_STRING);
+ g_assert (value != NULL);
+ g_assert (G_VALUE_TYPE (value) == G_TYPE_STRING);
prop1_value = g_value_get_string (value);
- fail_unless (prop1_value != NULL);
- fail_unless (strcmp (prop1_value, "prop1_value") == 0);
+ g_assert (prop1_value != NULL);
+ g_assert_cmpstr (prop1_value, ==, "prop1_value");
/* prop2 */
value = g_hash_table_lookup (properties, "prop2");
- fail_unless (value != NULL);
- fail_unless (G_VALUE_TYPE (value) == G_TYPE_INT);
+ g_assert (value != NULL);
+ g_assert (G_VALUE_TYPE (value) == G_TYPE_INT);
prop2_value = g_value_get_int (value);
- fail_unless (prop2_value == -7);
+ g_assert_cmpuint (prop2_value, ==, -7);
/* prop3 */
value = g_hash_table_lookup (properties, "prop3");
- fail_unless (value != NULL);
- fail_unless (G_VALUE_TYPE (value) == G_TYPE_UINT);
+ g_assert (value != NULL);
+ g_assert (G_VALUE_TYPE (value) == G_TYPE_UINT);
prop3_value = g_value_get_uint (value);
- fail_unless (prop3_value == 10);
+ g_assert_cmpuint (prop3_value, ==, 10);
/* prop4 */
value = g_hash_table_lookup (properties, "prop4");
- fail_unless (value != NULL);
- fail_unless (G_VALUE_TYPE (value) == DBUS_TYPE_G_UCHAR_ARRAY);
+ g_assert (value != NULL);
+ g_assert (G_VALUE_TYPE (value) == DBUS_TYPE_G_UCHAR_ARRAY);
prop4_value = g_value_get_boxed (value);
- fail_unless (g_array_index (prop4_value, gchar, 0) == 'a');
- fail_unless (g_array_index (prop4_value, gchar, 1) == 'b');
- fail_unless (g_array_index (prop4_value, gchar, 2) == 'c');
- fail_unless (g_array_index (prop4_value, gchar, 3) == 'd');
- fail_unless (g_array_index (prop4_value, gchar, 4) == 'e');
+ g_assert (g_array_index (prop4_value, gchar, 0) == 'a');
+ g_assert (g_array_index (prop4_value, gchar, 1) == 'b');
+ g_assert (g_array_index (prop4_value, gchar, 2) == 'c');
+ g_assert (g_array_index (prop4_value, gchar, 3) == 'd');
+ g_assert (g_array_index (prop4_value, gchar, 4) == 'e');
/* prop 5 */
value = g_hash_table_lookup (properties, "prop5");
- fail_unless (value != NULL);
- fail_unless (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN);
+ g_assert (value != NULL);
+ g_assert (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN);
prop5_value = g_value_get_boolean (value);
- fail_unless (prop5_value == TRUE);
+ g_assert (prop5_value == TRUE);
g_object_unref (stanza);
g_hash_table_destroy (properties);
}
-END_TEST
static void
test_g_value_slice_free (GValue *value)
@@ -187,55 +183,55 @@ create_sample_properties (void)
return properties;
}
-
-START_TEST (test_add_children_from_properties)
+static void
+test_add_children_from_properties (void)
{
GHashTable *properties;
- GibberXmppStanza *stanza;
+ WockyStanza *stanza;
WockyNode *top_node;
GSList *l;
properties = create_sample_properties ();
- stanza = gibber_xmpp_stanza_new_ns ("properties",
+ stanza = wocky_stanza_new ("properties",
"http://example.com/stoats");
top_node = wocky_stanza_get_top_node (stanza);
- salut_gibber_xmpp_node_add_children_from_properties (top_node,
+ salut_wocky_node_add_children_from_properties (top_node,
properties, "prop");
- fail_unless (g_slist_length (top_node->children) == 5);
+ g_assert_cmpuint (g_slist_length (top_node->children), ==, 5);
for (l = top_node->children; l != NULL; l = l->next)
{
- GibberXmppNode *node = (GibberXmppNode *) l->data;
+ WockyNode *node = (WockyNode *) l->data;
const gchar *name, *type;
- name = gibber_xmpp_node_get_attribute (node, "name");
- type = gibber_xmpp_node_get_attribute (node, "type");
+ name = wocky_node_get_attribute (node, "name");
+ type = wocky_node_get_attribute (node, "type");
if (strcmp (name, "prop1") == 0)
{
- fail_unless (strcmp (type, "str") == 0);
- fail_unless (strcmp (node->content, "prop1_value") == 0);
+ g_assert_cmpstr (type, ==, "str");
+ g_assert_cmpstr (node->content, ==, "prop1_value");
}
else if (strcmp (name, "prop2") == 0)
{
- fail_unless (strcmp (type, "int") == 0);
- fail_unless (strcmp (node->content, "-7") == 0);
+ g_assert_cmpstr (type, ==, "int");
+ g_assert_cmpstr (node->content, ==, "-7");
}
else if (strcmp (name, "prop3") == 0)
{
- fail_unless (strcmp (type, "uint") == 0);
- fail_unless (strcmp (node->content, "10") == 0);
+ g_assert_cmpstr (type, ==, "uint");
+ g_assert_cmpstr (node->content, ==, "10");
}
else if (strcmp (name, "prop4") == 0)
{
- fail_unless (strcmp (type, "bytes") == 0);
- fail_unless (strcmp (node->content, "YWJjZGU=") == 0);
+ g_assert_cmpstr (type, ==, "bytes");
+ g_assert_cmpstr (node->content, ==, "YWJjZGU=");
}
else if (strcmp (name, "prop5") == 0)
{
- fail_unless (strcmp (type, "bool") == 0);
- fail_unless (strcmp (node->content, "1") == 0);
+ g_assert_cmpstr (type, ==, "bool");
+ g_assert_cmpstr (node->content, ==, "1");
}
else
g_assert_not_reached ();
@@ -244,17 +240,21 @@ START_TEST (test_add_children_from_properties)
g_hash_table_destroy (properties);
g_object_unref (stanza);
}
-END_TEST
-TCase *
-make_salut_gibber_xmpp_node_properties_tcase (void)
+int
+main (int argc,
+ char **argv)
{
- TCase *tc = tcase_create ("XMPP Node");
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
/* to initiate D-Bus types */
dbus_g_bus_get (DBUS_BUS_STARTER, NULL);
- tcase_add_test (tc, test_extract_properties);
- tcase_add_test (tc, test_add_children_from_properties);
- return tc;
+ g_test_add_func ("/node-properties/extract-properties",
+ test_extract_properties);
+ g_test_add_func ("/node-properties/add-children-from-properties",
+ test_add_children_from_properties);
+
+ return g_test_run ();
}
diff --git a/tests/check-salut.h b/tests/check-salut.h
deleted file mode 100644
index b4af2a95..00000000
--- a/tests/check-salut.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CHECK_SALUT_H__
-#define __CHECK_SALUT_H__
-
-TCase *make_salut_gibber_xmpp_node_properties_tcase (void);
-
-#endif /* #ifndef __CHECK_SALUT_H__ */
diff --git a/tests/twisted/avahi/file-transfer/file_transfer_helper.py b/tests/twisted/avahi/file-transfer/file_transfer_helper.py
index c9dbbc11..3d066743 100644
--- a/tests/twisted/avahi/file-transfer/file_transfer_helper.py
+++ b/tests/twisted/avahi/file-transfer/file_transfer_helper.py
@@ -11,47 +11,13 @@ from avahitest import AvahiAnnouncer, AvahiListener, get_host_name
from saluttest import wait_for_contact_in_publish
from xmppstream import setup_stream_listener, connect_to_stream
-from servicetest import make_channel_proxy, EventPattern
+from servicetest import make_channel_proxy, EventPattern, assertEquals, call_async
+import constants as cs
from twisted.words.xish import domish, xpath
from dbus import PROPERTIES_IFACE
-CONNECTION_INTERFACE_REQUESTS = 'org.freedesktop.Telepathy.Connection.Interface.Requests'
-CHANNEL_INTERFACE ='org.freedesktop.Telepathy.Channel'
-CHANNEL_TYPE_FILE_TRANSFER = 'org.freedesktop.Telepathy.Channel.Type.FileTransfer'
-HT_CONTACT = 1
-HT_CONTACT_LIST = 3
-
-FT_STATE_NONE = 0
-FT_STATE_PENDING = 1
-FT_STATE_ACCEPTED = 2
-FT_STATE_OPEN = 3
-FT_STATE_COMPLETED = 4
-FT_STATE_CANCELLED = 5
-
-FT_STATE_CHANGE_REASON_NONE = 0
-FT_STATE_CHANGE_REASON_REQUESTED = 1
-FT_STATE_CHANGE_REASON_LOCAL_STOPPED = 2
-FT_STATE_CHANGE_REASON_REMOTE_STOPPED = 3
-FT_STATE_CHANGE_REASON_LOCAL_ERROR = 4
-FT_STATE_CHANGE_REASON_REMOTE_ERROR = 5
-
-FILE_HASH_TYPE_NONE = 0
-FILE_HASH_TYPE_MD5 = 1
-FILE_HASH_TYPE_SHA1 = 2
-FILE_HASH_TYPE_SHA256 = 3
-
-SOCKET_ADDRESS_TYPE_UNIX = 0
-SOCKET_ADDRESS_TYPE_ABSTRACT_UNIX = 1
-SOCKET_ADDRESS_TYPE_IPV4 = 2
-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
-
class File(object):
DEFAULT_DATA = "What a nice file"
DEFAULT_NAME = "The foo.txt"
@@ -60,7 +26,7 @@ class File(object):
def __init__(self, data=DEFAULT_DATA, name=DEFAULT_NAME,
content_type=DEFAULT_CONTENT_TYPE, description=DEFAULT_DESCRIPTION,
- hash_type=FILE_HASH_TYPE_MD5):
+ hash_type=cs.FILE_HASH_TYPE_MD5):
self.data = data
self.size = len(self.data)
self.name = name
@@ -71,8 +37,10 @@ class File(object):
self.compute_hash(hash_type)
+ self.uri = 'file:///tmp/%s' % self.name
+
def compute_hash(self, hash_type):
- assert hash_type == FILE_HASH_TYPE_MD5
+ assert hash_type == cs.FILE_HASH_TYPE_MD5
self.hash_type = hash_type
self.hash = hashlib.md5(self.data).hexdigest()
@@ -88,7 +56,7 @@ class FileTransferTest(object):
self.q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
self.self_handle = self.conn.GetSelfHandle()
- self.self_handle_name = self.conn.InspectHandles(HT_CONTACT, [self.self_handle])[0]
+ self.self_handle_name = self.conn.InspectHandles(cs.HT_CONTACT, [self.self_handle])[0]
def announce_contact(self, name=CONTACT_NAME):
basic_txt = { "txtvers": "1", "status": "avail" }
@@ -129,8 +97,8 @@ class ReceiveFileTest(FileTransferTest):
self._actions = [self.connect, self.announce_contact, self.wait_for_contact,
self.connect_to_salut, self.setup_http_server, self.send_ft_offer_iq,
- self.check_new_channel, self.create_ft_channel, self.accept_file,
- self.receive_file, self.close_channel]
+ self.check_new_channel, self.create_ft_channel, self.set_uri,
+ self.accept_file, self.receive_file, self.close_channel]
def _resolve_salut_presence(self):
AvahiListener(self.q).listen_for_service("_presence._tcp")
@@ -193,41 +161,65 @@ class ReceiveFileTest(FileTransferTest):
# check channel properties
# org.freedesktop.Telepathy.Channel D-Bus properties
- assert props[CHANNEL_INTERFACE + '.ChannelType'] == CHANNEL_TYPE_FILE_TRANSFER
- assert props[CHANNEL_INTERFACE + '.Interfaces'] == []
- assert props[CHANNEL_INTERFACE + '.TargetHandle'] == self.handle
- assert props[CHANNEL_INTERFACE + '.TargetID'] == self.contact_name
- assert props[CHANNEL_INTERFACE + '.TargetHandleType'] == HT_CONTACT
- assert props[CHANNEL_INTERFACE + '.Requested'] == False
- assert props[CHANNEL_INTERFACE + '.InitiatorHandle'] == self.handle
- assert props[CHANNEL_INTERFACE + '.InitiatorID'] == self.contact_name
+ assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER
+ assert props[cs.INTERFACES] == []
+ assert props[cs.TARGET_HANDLE] == self.handle
+ assert props[cs.TARGET_ID] == self.contact_name
+ assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT
+ assert props[cs.REQUESTED] == False
+ assert props[cs.INITIATOR_HANDLE] == self.handle
+ assert props[cs.INITIATOR_ID] == self.contact_name
# org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.State'] == FT_STATE_PENDING
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentType'] == self.file.content_type
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Filename'] == self.file.name
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Size'] == self.file.size
+ assert props[cs.FT_STATE] == cs.FT_STATE_PENDING
+ assert props[cs.FT_CONTENT_TYPE] == self.file.content_type
+ assert props[cs.FT_FILENAME] == self.file.name
+ assert props[cs.FT_SIZE] == self.file.size
# FT's protocol doesn't allow us the send the hash info
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentHashType'] == FILE_HASH_TYPE_NONE
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash'] == ''
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Description'] == self.file.description
+ assert props[cs.FT_CONTENT_HASH_TYPE] == cs.FILE_HASH_TYPE_NONE
+ assert props[cs.FT_CONTENT_HASH] == ''
+ assert props[cs.FT_DESCRIPTION] == self.file.description
# FT's protocol doesn't allow us the send the date info
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Date'] == 0
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.AvailableSocketTypes'] == \
- {SOCKET_ADDRESS_TYPE_UNIX: [SOCKET_ACCESS_CONTROL_LOCALHOST]}
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.TransferredBytes'] == 0
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset'] == 0
+ assert props[cs.FT_DATE] == 0
+ assert props[cs.FT_AVAILABLE_SOCKET_TYPES] == \
+ {cs.SOCKET_ADDRESS_TYPE_UNIX: [cs.SOCKET_ACCESS_CONTROL_LOCALHOST]}
+ assert props[cs.FT_TRANSFERRED_BYTES] == 0
+ assert props[cs.FT_INITIAL_OFFSET] == 0
self.ft_path = path
+ def set_uri(self):
+ ft_props = dbus.Interface(self.ft_channel, cs.PROPERTIES_IFACE)
+
+ # URI is not set yet
+ uri = ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'URI')
+ assertEquals('', uri)
+
+ # Setting URI
+ call_async(self.q, ft_props, 'Set',
+ cs.CHANNEL_TYPE_FILE_TRANSFER, 'URI', self.file.uri)
+
+ self.q.expect('dbus-signal', signal='URIDefined', args=[self.file.uri])
+
+ self.q.expect('dbus-return', method='Set')
+
+ # Check it has the right value now
+ uri = ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'URI')
+ assertEquals(self.file.uri, uri)
+
+ # We can't change it once it has been set
+ call_async(self.q, ft_props, 'Set',
+ cs.CHANNEL_TYPE_FILE_TRANSFER, 'URI', 'badger://snake')
+ self.q.expect('dbus-error', method='Set', name=cs.INVALID_ARGUMENT)
+
def accept_file(self):
- self.address = self.ft_channel.AcceptFile(SOCKET_ADDRESS_TYPE_UNIX,
- SOCKET_ACCESS_CONTROL_LOCALHOST, "", 5, byte_arrays=True)
+ self.address = self.ft_channel.AcceptFile(cs.SOCKET_ADDRESS_TYPE_UNIX,
+ cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "", 5, byte_arrays=True)
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_ACCEPTED
- assert reason == FT_STATE_CHANGE_REASON_REQUESTED
+ assert state == cs.FT_STATE_ACCEPTED
+ assert reason == cs.FT_STATE_CHANGE_REASON_REQUESTED
e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
offset = e.args[0]
@@ -236,8 +228,8 @@ class ReceiveFileTest(FileTransferTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_OPEN
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_OPEN
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
def _read_file_from_socket(self, s):
# Read the file from Salut's socket
@@ -257,8 +249,8 @@ class ReceiveFileTest(FileTransferTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_COMPLETED
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_COMPLETED
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
def receive_file(self):
# Connect to Salut's socket
@@ -282,65 +274,73 @@ class SendFileTest(FileTransferTest):
self.close_channel]
def check_ft_available(self):
- properties = self.conn.GetAll(
- CONNECTION_INTERFACE_REQUESTS,
+ properties = self.conn.GetAll(cs.CONN_IFACE_REQUESTS,
dbus_interface=PROPERTIES_IFACE)
- assert ({CHANNEL_INTERFACE + '.ChannelType': CHANNEL_TYPE_FILE_TRANSFER,
- CHANNEL_INTERFACE + '.TargetHandleType': HT_CONTACT},
- [CHANNEL_INTERFACE + '.TargetHandle',
- CHANNEL_INTERFACE + '.TargetID',
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentType',
- CHANNEL_TYPE_FILE_TRANSFER + '.Filename',
- CHANNEL_TYPE_FILE_TRANSFER + '.Size',
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentHashType',
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash',
- CHANNEL_TYPE_FILE_TRANSFER + '.Description',
- CHANNEL_TYPE_FILE_TRANSFER + '.Date',
- CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset'],
+ assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_FILE_TRANSFER,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT},
+ [cs.FT_CONTENT_HASH_TYPE,
+ cs.TARGET_HANDLE,
+ cs.TARGET_ID,
+ cs.FT_CONTENT_TYPE,
+ cs.FT_FILENAME,
+ cs.FT_SIZE,
+ cs.FT_CONTENT_HASH,
+ cs.FT_DESCRIPTION,
+ cs.FT_DATE,
+ cs.FT_INITIAL_OFFSET,
+ cs.FT_URI],
) in properties.get('RequestableChannelClasses'),\
properties['RequestableChannelClasses']
- def request_ft_channel(self):
- requests_iface = dbus.Interface(self.conn, CONNECTION_INTERFACE_REQUESTS)
-
- self.ft_path, props = requests_iface.CreateChannel({
- CHANNEL_INTERFACE + '.ChannelType': CHANNEL_TYPE_FILE_TRANSFER,
- CHANNEL_INTERFACE + '.TargetHandleType': HT_CONTACT,
- CHANNEL_INTERFACE + '.TargetHandle': self.handle,
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentType': self.file.content_type,
- CHANNEL_TYPE_FILE_TRANSFER + '.Filename': self.file.name,
- CHANNEL_TYPE_FILE_TRANSFER + '.Size': self.file.size,
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentHashType': self.file.hash_type,
- CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash': self.file.hash,
- CHANNEL_TYPE_FILE_TRANSFER + '.Description': self.file.description,
- CHANNEL_TYPE_FILE_TRANSFER + '.Date': self.file.date,
- CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset': 0,
- })
+ def request_ft_channel(self, uri=True):
+ requests_iface = dbus.Interface(self.conn, cs.CONN_IFACE_REQUESTS)
+
+ request = { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_FILE_TRANSFER,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: self.handle,
+
+ cs.FT_CONTENT_TYPE: self.file.content_type,
+ cs.FT_FILENAME: self.file.name,
+ cs.FT_SIZE: self.file.size,
+ cs.FT_CONTENT_HASH_TYPE: self.file.hash_type,
+ cs.FT_CONTENT_HASH:self.file.hash,
+ cs.FT_DESCRIPTION: self.file.description,
+ cs.FT_DATE: self.file.date,
+ cs.FT_INITIAL_OFFSET: 0 }
+
+ if uri:
+ request[cs.FT_URI] = self.file.uri
+
+ self.ft_path, props = requests_iface.CreateChannel(request)
# org.freedesktop.Telepathy.Channel D-Bus properties
- assert props[CHANNEL_INTERFACE + '.ChannelType'] == CHANNEL_TYPE_FILE_TRANSFER
- assert props[CHANNEL_INTERFACE + '.Interfaces'] == []
- assert props[CHANNEL_INTERFACE + '.TargetHandle'] == self.handle
- assert props[CHANNEL_INTERFACE + '.TargetID'] == self.contact_name
- assert props[CHANNEL_INTERFACE + '.TargetHandleType'] == HT_CONTACT
- assert props[CHANNEL_INTERFACE + '.Requested'] == True
- assert props[CHANNEL_INTERFACE + '.InitiatorHandle'] == self.self_handle
- assert props[CHANNEL_INTERFACE + '.InitiatorID'] == self.self_handle_name
+ assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER
+ assert props[cs.INTERFACES] == []
+ assert props[cs.TARGET_HANDLE] == self.handle
+ assert props[cs.TARGET_ID] == self.contact_name
+ assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT
+ assert props[cs.REQUESTED] == True
+ assert props[cs.INITIATOR_HANDLE] == self.self_handle
+ assert props[cs.INITIATOR_ID] == self.self_handle_name
# org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.State'] == FT_STATE_PENDING
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentType'] == self.file.content_type
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Filename'] == self.file.name
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Size'] == self.file.size
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentHashType'] == self.file.hash_type
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash'] == self.file.hash
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Description'] == self.file.description
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.Date'] == self.file.date
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.AvailableSocketTypes'] == \
- {SOCKET_ADDRESS_TYPE_UNIX: [SOCKET_ACCESS_CONTROL_LOCALHOST]}
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.TransferredBytes'] == 0
- assert props[CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset'] == 0
+ assert props[cs.FT_STATE] == cs.FT_STATE_PENDING
+ assert props[cs.FT_CONTENT_TYPE] == self.file.content_type
+ assert props[cs.FT_FILENAME] == self.file.name
+ assert props[cs.FT_SIZE] == self.file.size
+ assert props[cs.FT_CONTENT_HASH_TYPE] == self.file.hash_type
+ assert props[cs.FT_CONTENT_HASH] == self.file.hash
+ assert props[cs.FT_DESCRIPTION] == self.file.description
+ assert props[cs.FT_DATE] == self.file.date
+ assert props[cs.FT_AVAILABLE_SOCKET_TYPES] == \
+ {cs.SOCKET_ADDRESS_TYPE_UNIX: [cs.SOCKET_ACCESS_CONTROL_LOCALHOST]}
+ assert props[cs.FT_TRANSFERRED_BYTES] == 0
+ assert props[cs.FT_INITIAL_OFFSET] == 0
+ if uri:
+ assertEquals(self.file.uri, props[cs.FT_URI])
+ else:
+ assertEquals('', props[cs.FT_URI])
def got_send_iq(self):
conn_event, iq_event = self.q.expect_many(
@@ -370,8 +370,8 @@ class SendFileTest(FileTransferTest):
assert self.desc == self.file.description
def provide_file(self):
- self.address = self.ft_channel.ProvideFile(SOCKET_ADDRESS_TYPE_UNIX,
- SOCKET_ACCESS_CONTROL_LOCALHOST, "", byte_arrays=True)
+ self.address = self.ft_channel.ProvideFile(cs.SOCKET_ADDRESS_TYPE_UNIX,
+ cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "", byte_arrays=True)
def client_request_file(self):
# Connect HTTP client to the CM and request the file
@@ -410,5 +410,5 @@ class SendFileTest(FileTransferTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_COMPLETED
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_COMPLETED
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
diff --git a/tests/twisted/avahi/file-transfer/test-ichat-send-file-declined.py b/tests/twisted/avahi/file-transfer/test-ichat-send-file-declined.py
index 62e68f70..feb067e2 100644
--- a/tests/twisted/avahi/file-transfer/test-ichat-send-file-declined.py
+++ b/tests/twisted/avahi/file-transfer/test-ichat-send-file-declined.py
@@ -3,8 +3,8 @@ from xmppstream import IncomingXmppiChatStream, setup_stream_listener
from twisted.words.xish import domish
from avahitest import get_host_name, AvahiAnnouncer
-from file_transfer_helper import SendFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_REMOTE_STOPPED, CHANNEL_TYPE_FILE_TRANSFER
+from file_transfer_helper import SendFileTest
+import constants as cs
class IChatSendFileDeclined(SendFileTest):
CONTACT_NAME = 'test-ft'
@@ -32,10 +32,10 @@ class IChatSendFileDeclined(SendFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED, state
- assert reason == FT_STATE_CHANGE_REASON_REMOTE_STOPPED
+ assert state == cs.FT_STATE_CANCELLED, state
+ assert reason == cs.FT_STATE_CHANGE_REASON_REMOTE_STOPPED
- transferred = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
+ transferred = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
# no byte has been transferred as the file was declined
assert transferred == 0
diff --git a/tests/twisted/avahi/file-transfer/test-receive-and-send-file.py b/tests/twisted/avahi/file-transfer/test-receive-and-send-file.py
index 4bcdd843..1c6dd418 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-and-send-file.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-and-send-file.py
@@ -15,8 +15,8 @@ class ReceiveAndSendFileTest(ReceiveFileTest, SendFileTest):
self.connect_to_salut,
# receive file
self.setup_http_server, self.send_ft_offer_iq, self.check_new_channel,
- self.create_ft_channel, self.accept_file, self.receive_file,
- self.close_channel,
+ self.create_ft_channel, self.set_uri, self.accept_file,
+ self.receive_file, self.close_channel,
# now send a file. We'll reuse the same XMPP connection
self.request_ft_channel, self.create_ft_channel, self.got_send_iq,
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py b/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py
index ca6bf7d3..e3bb73db 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py
@@ -1,8 +1,8 @@
import dbus
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest, SOCKET_ADDRESS_TYPE_UNIX,\
- SOCKET_ACCESS_CONTROL_LOCALHOST
+from file_transfer_helper import ReceiveFileTest
+
import constants as cs
class ReceiveFileAndSenderDisconnectWhilePendingTest(ReceiveFileTest):
@@ -15,8 +15,8 @@ class ReceiveFileAndSenderDisconnectWhilePendingTest(ReceiveFileTest):
# We can't accept the transfer now
try:
- self.ft_channel.AcceptFile(SOCKET_ADDRESS_TYPE_UNIX,
- SOCKET_ACCESS_CONTROL_LOCALHOST, "", 0, byte_arrays=True)
+ self.ft_channel.AcceptFile(cs.SOCKET_ADDRESS_TYPE_UNIX,
+ cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "", 0, byte_arrays=True)
except dbus.DBusException, e:
assert e.get_dbus_name() == cs.NOT_AVAILABLE
else:
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-transfering.py b/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-transfering.py
index c88e5d43..fef5cf26 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-transfering.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-and-sender-disconnect-while-transfering.py
@@ -2,8 +2,7 @@ import dbus
import socket
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest, SOCKET_ADDRESS_TYPE_UNIX,\
- SOCKET_ACCESS_CONTROL_LOCALHOST
+from file_transfer_helper import ReceiveFileTest
class ReceiveFileAndSenderDisconnectWhileTransfering(ReceiveFileTest):
def accept_file(self):
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-and-xmpp-disconnect.py b/tests/twisted/avahi/file-transfer/test-receive-file-and-xmpp-disconnect.py
index 1f6bf2fb..63fa2dd3 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-and-xmpp-disconnect.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-and-xmpp-disconnect.py
@@ -3,8 +3,7 @@ import dbus
import socket
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest, SOCKET_ADDRESS_TYPE_UNIX,\
- SOCKET_ACCESS_CONTROL_LOCALHOST
+from file_transfer_helper import ReceiveFileTest
class ReceiveFileAndXmppDisconnectTest(ReceiveFileTest):
def accept_file(self):
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-cancelled-immediately.py b/tests/twisted/avahi/file-transfer/test-receive-file-cancelled-immediately.py
index 243800e4..fabf826e 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-cancelled-immediately.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-cancelled-immediately.py
@@ -1,8 +1,9 @@
import socket
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_REMOTE_STOPPED
+from file_transfer_helper import ReceiveFileTest
+
+import constants as cs
class ReceiveFileCancelledImmediatelyTest(ReceiveFileTest):
def accept_file(self):
@@ -20,8 +21,8 @@ class ReceiveFileCancelledImmediatelyTest(ReceiveFileTest):
# Salut can't connect to download the file
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED
- assert reason == FT_STATE_CHANGE_REASON_REMOTE_STOPPED
+ assert state == cs.FT_STATE_CANCELLED
+ assert reason == cs.FT_STATE_CHANGE_REASON_REMOTE_STOPPED
if __name__ == '__main__':
test = ReceiveFileCancelledImmediatelyTest()
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-decline.py b/tests/twisted/avahi/file-transfer/test-receive-file-decline.py
index cfd6dd4a..c2964235 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-decline.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-decline.py
@@ -1,8 +1,9 @@
from servicetest import make_channel_proxy
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_LOCAL_STOPPED
+from file_transfer_helper import ReceiveFileTest
+
+import constants as cs
class ReceiveFileDeclineTest(ReceiveFileTest):
def accept_file(self):
@@ -11,8 +12,8 @@ class ReceiveFileDeclineTest(ReceiveFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED
- assert reason == FT_STATE_CHANGE_REASON_LOCAL_STOPPED
+ assert state == cs.FT_STATE_CANCELLED
+ assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED
self.q.expect('dbus-signal', signal='Closed')
# Re send offer (this is a regression test as Salut used to crash at this
@@ -31,8 +32,8 @@ class ReceiveFileDeclineTest(ReceiveFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED
- assert reason == FT_STATE_CHANGE_REASON_LOCAL_STOPPED
+ assert state == cs.FT_STATE_CANCELLED
+ assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED
self.q.expect('dbus-signal', signal='Closed')
# stop test
diff --git a/tests/twisted/avahi/file-transfer/test-receive-file-not-found.py b/tests/twisted/avahi/file-transfer/test-receive-file-not-found.py
index 0dc5692e..f8b9cbb7 100644
--- a/tests/twisted/avahi/file-transfer/test-receive-file-not-found.py
+++ b/tests/twisted/avahi/file-transfer/test-receive-file-not-found.py
@@ -5,8 +5,9 @@ import urllib
from twisted.words.xish import xpath
from saluttest import exec_test
-from file_transfer_helper import ReceiveFileTest,FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_LOCAL_ERROR, CHANNEL_TYPE_FILE_TRANSFER
+from file_transfer_helper import ReceiveFileTest
+
+import constants as cs
class ReceiveFileNotFound(ReceiveFileTest):
def setup_http_server(self):
@@ -40,10 +41,10 @@ class ReceiveFileNotFound(ReceiveFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED
- assert reason == FT_STATE_CHANGE_REASON_LOCAL_ERROR
+ assert state == cs.FT_STATE_CANCELLED
+ assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_ERROR
- transferred = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
+ transferred = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
# no byte has been transferred as the transfer failed
assert transferred == 0
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-and-cancel-immediately.py b/tests/twisted/avahi/file-transfer/test-send-file-and-cancel-immediately.py
index c503c108..e2cb5da5 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-and-cancel-immediately.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-and-cancel-immediately.py
@@ -3,8 +3,9 @@ import httplib
import socket
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_LOCAL_STOPPED
+from file_transfer_helper import SendFileTest
+
+import constants as cs
class SendFileAndCancelImmediatelyTest(SendFileTest):
def provide_file(self):
@@ -15,8 +16,8 @@ class SendFileAndCancelImmediatelyTest(SendFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED
- assert reason == FT_STATE_CHANGE_REASON_LOCAL_STOPPED
+ assert state == cs.FT_STATE_CANCELLED
+ assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED
self.q.expect('dbus-signal', signal='Closed')
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-declined.py b/tests/twisted/avahi/file-transfer/test-send-file-declined.py
index 33221638..28e3157d 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-declined.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-declined.py
@@ -1,8 +1,8 @@
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_REMOTE_STOPPED, CHANNEL_TYPE_FILE_TRANSFER
+from file_transfer_helper import SendFileTest
from twisted.words.xish import domish
+import constants as cs
class SendFileDeclinedTest(SendFileTest):
def got_send_iq(self):
@@ -26,10 +26,10 @@ class SendFileDeclinedTest(SendFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED, state
- assert reason == FT_STATE_CHANGE_REASON_REMOTE_STOPPED
+ assert state == cs.FT_STATE_CANCELLED, state
+ assert reason == cs.FT_STATE_CHANGE_REASON_REMOTE_STOPPED
- transferred = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
+ transferred = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
# no byte has been transferred as the file was declined
assert transferred == 0
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-ipv6.py b/tests/twisted/avahi/file-transfer/test-send-file-ipv6.py
index cbba065f..d379b059 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-ipv6.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-ipv6.py
@@ -2,8 +2,9 @@ import avahi
from saluttest import exec_test
from avahitest import AvahiAnnouncer, get_host_name
from xmppstream import setup_stream_listener6
-from file_transfer_helper import SendFileTest, CHANNEL_TYPE_FILE_TRANSFER, FT_STATE_PENDING, \
- FT_STATE_CHANGE_REASON_NONE, FT_STATE_OPEN
+from file_transfer_helper import SendFileTest
+
+import constants as cs
print "FIXME: This is disabled because of a bug in Python's httplib. http://bugs.python.org/issue5111"
# exiting 77 causes automake to consider the test to have been skipped
@@ -25,8 +26,8 @@ class SendFileTransferIPv6(SendFileTest):
SendFileTest.provide_file(self)
# state is still Pending as remote didn't accept the transfer yet
- state = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'State')
- assert state == FT_STATE_PENDING
+ state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
+ assert state == cs.FT_STATE_PENDING
def client_request_file(self):
SendFileTest.client_request_file(self)
@@ -39,8 +40,8 @@ class SendFileTransferIPv6(SendFileTest):
# Channel is open. We can start to send the file
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_OPEN
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_OPEN
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
if __name__ == '__main__':
test = SendFileTransferIPv6()
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-item-not-found.py b/tests/twisted/avahi/file-transfer/test-send-file-item-not-found.py
index bcf8cbdc..fdbbb645 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-item-not-found.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-item-not-found.py
@@ -1,9 +1,10 @@
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, FT_STATE_CANCELLED, \
- FT_STATE_CHANGE_REASON_REMOTE_ERROR, CHANNEL_TYPE_FILE_TRANSFER
+from file_transfer_helper import SendFileTest
from twisted.words.xish import domish
+import constants as cs
+
class SendFileItemNotFound(SendFileTest):
def client_request_file(self):
# Receiver can't retrieve the file
@@ -24,10 +25,10 @@ class SendFileItemNotFound(SendFileTest):
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_CANCELLED, state
- assert reason == FT_STATE_CHANGE_REASON_REMOTE_ERROR
+ assert state == cs.FT_STATE_CANCELLED, state
+ assert reason == cs.FT_STATE_CHANGE_REASON_REMOTE_ERROR
- transferred = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
+ transferred = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
# no byte has been transferred as the transfer failed
assert transferred == 0
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-provide-immediately.py b/tests/twisted/avahi/file-transfer/test-send-file-provide-immediately.py
index a7891549..2b52ea6a 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-provide-immediately.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-provide-immediately.py
@@ -1,14 +1,15 @@
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, CHANNEL_TYPE_FILE_TRANSFER, FT_STATE_PENDING, \
- FT_STATE_CHANGE_REASON_NONE, FT_STATE_OPEN
+from file_transfer_helper import SendFileTest
+
+import constants as cs
class SendFileTransferProvideImmediately(SendFileTest):
def provide_file(self):
SendFileTest.provide_file(self)
# state is still Pending as remote didn't accept the transfer yet
- state = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'State')
- assert state == FT_STATE_PENDING
+ state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
+ assert state == cs.FT_STATE_PENDING
def client_request_file(self):
SendFileTest.client_request_file(self)
@@ -21,8 +22,8 @@ class SendFileTransferProvideImmediately(SendFileTest):
# Channel is open. We can start to send the file
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_OPEN
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_OPEN
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
if __name__ == '__main__':
test = SendFileTransferProvideImmediately()
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py b/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py
index cab907c2..d6871fdb 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py
@@ -1,7 +1,7 @@
import dbus
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, HT_CONTACT
+from file_transfer_helper import SendFileTest
from avahitest import get_host_name
import constants as cs
@@ -14,7 +14,7 @@ class SendFileTransferToUnknownContactTest(SendFileTest):
def my_request_ft_channel(self):
self.contact_name = '%s@%s' % (self.CONTACT_NAME, get_host_name())
- self.handle = self.conn.RequestHandles(HT_CONTACT, [self.contact_name])[0]
+ self.handle = self.conn.RequestHandles(cs.HT_CONTACT, [self.contact_name])[0]
try:
self.request_ft_channel()
diff --git a/tests/twisted/avahi/file-transfer/test-send-file-wait-to-provide.py b/tests/twisted/avahi/file-transfer/test-send-file-wait-to-provide.py
index 6ddc76c9..b7bf47da 100644
--- a/tests/twisted/avahi/file-transfer/test-send-file-wait-to-provide.py
+++ b/tests/twisted/avahi/file-transfer/test-send-file-wait-to-provide.py
@@ -1,7 +1,7 @@
from saluttest import exec_test
-from file_transfer_helper import SendFileTest, CHANNEL_TYPE_FILE_TRANSFER, \
- FT_STATE_PENDING, FT_STATE_ACCEPTED, FT_STATE_OPEN, FT_STATE_CHANGE_REASON_REQUESTED, \
- FT_STATE_CHANGE_REASON_NONE
+from file_transfer_helper import SendFileTest
+
+import constants as cs
class SendFileTransferWaitToProvideTest(SendFileTest):
def __init__(self):
@@ -13,16 +13,16 @@ class SendFileTransferWaitToProvideTest(SendFileTest):
def client_request_file(self):
# state is still Pending as remote didn't accept the transfer yet
- state = self.ft_props.Get(CHANNEL_TYPE_FILE_TRANSFER, 'State')
- assert state == FT_STATE_PENDING
+ state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
+ assert state == cs.FT_STATE_PENDING
SendFileTest.client_request_file(self)
# Remote accepted the transfer
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_ACCEPTED, state
- assert reason == FT_STATE_CHANGE_REASON_NONE
+ assert state == cs.FT_STATE_ACCEPTED, state
+ assert reason == cs.FT_STATE_CHANGE_REASON_NONE
def provide_file(self):
SendFileTest.provide_file(self)
@@ -35,8 +35,8 @@ class SendFileTransferWaitToProvideTest(SendFileTest):
# Channel is open. We can start to send the file
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
- assert state == FT_STATE_OPEN
- assert reason == FT_STATE_CHANGE_REASON_REQUESTED
+ assert state == cs.FT_STATE_OPEN
+ assert reason == cs.FT_STATE_CHANGE_REASON_REQUESTED
if __name__ == '__main__':
test = SendFileTransferWaitToProvideTest()
diff --git a/tests/twisted/avahi/test-caps-file-transfer.py b/tests/twisted/avahi/test-caps-file-transfer.py
index 87106159..70cf73a0 100644
--- a/tests/twisted/avahi/test-caps-file-transfer.py
+++ b/tests/twisted/avahi/test-caps-file-transfer.py
@@ -135,9 +135,9 @@ def test_ft_caps_from_contact(q, bus, conn, client):
caps = e.args[0][contact_handle]
assert ({CHANNEL_TYPE: CHANNEL_TYPE_FILE_TRANSFER,
TARGET_HANDLE_TYPE: HT_CONTACT},
- [TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
- FT_CONTENT_HASH_TYPE, FT_CONTENT_HASH, FT_DESCRIPTION,
- FT_DATE, FT_INITIAL_OFFSET]) in caps
+ [FT_CONTENT_HASH_TYPE, TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME,
+ FT_SIZE, FT_CONTENT_HASH, FT_DESCRIPTION,
+ FT_DATE, FT_INITIAL_OFFSET, FT_URI]) in caps
caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle]
assert caps == caps_get
@@ -196,9 +196,9 @@ def test_ft_caps_from_contact(q, bus, conn, client):
caps = e.args[0][contact_handle]
assert ({CHANNEL_TYPE: CHANNEL_TYPE_FILE_TRANSFER,
TARGET_HANDLE_TYPE: HT_CONTACT},
- [TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
- FT_CONTENT_HASH_TYPE, FT_CONTENT_HASH, FT_DESCRIPTION,
- FT_DATE, FT_INITIAL_OFFSET]) not in caps
+ [FT_CONTENT_HASH_TYPE, TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
+ FT_CONTENT_HASH, FT_DESCRIPTION,
+ FT_DATE, FT_INITIAL_OFFSET, FT_URI]) not in caps
caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle]
assert caps == caps_get
@@ -219,9 +219,9 @@ def test_ft_caps_from_contact(q, bus, conn, client):
caps = e.args[0][contact_handle]
assert ({CHANNEL_TYPE: CHANNEL_TYPE_FILE_TRANSFER,
TARGET_HANDLE_TYPE: HT_CONTACT},
- [TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
- FT_CONTENT_HASH_TYPE, FT_CONTENT_HASH, FT_DESCRIPTION,
- FT_DATE, FT_INITIAL_OFFSET]) in caps
+ [FT_CONTENT_HASH_TYPE, TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME,
+ FT_SIZE, FT_CONTENT_HASH, FT_DESCRIPTION,
+ FT_DATE, FT_INITIAL_OFFSET, FT_URI]) in caps
caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle]
assert caps == caps_get
@@ -240,9 +240,9 @@ def test(q, bus, conn):
caps = conn_caps_iface.GetContactCapabilities([self_handle])[self_handle]
assert ({CHANNEL_TYPE: CHANNEL_TYPE_FILE_TRANSFER,
TARGET_HANDLE_TYPE: HT_CONTACT},
- [TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
- FT_CONTENT_HASH_TYPE, FT_CONTENT_HASH, FT_DESCRIPTION,
- FT_DATE, FT_INITIAL_OFFSET]) in caps
+ [FT_CONTENT_HASH_TYPE, TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME,
+ FT_SIZE, FT_CONTENT_HASH, FT_DESCRIPTION,
+ FT_DATE, FT_INITIAL_OFFSET, FT_URI]) in caps
client = 'http://telepathy.freedesktop.org/fake-client'
test_ft_caps_from_contact(q, bus, conn, client)
diff --git a/tests/twisted/avahi/test-caps-tubes.py b/tests/twisted/avahi/test-caps-tubes.py
index ffc34388..10e1895a 100644
--- a/tests/twisted/avahi/test-caps-tubes.py
+++ b/tests/twisted/avahi/test-caps-tubes.py
@@ -67,9 +67,9 @@ ft_fixed_properties = dbus.Dictionary({
TARGET_HANDLE_TYPE: HT_CONTACT
})
ft_allowed_properties = dbus.Array([
- TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME, FT_SIZE,
- FT_CONTENT_HASH_TYPE, FT_CONTENT_HASH, FT_DESCRIPTION,
- FT_DATE, FT_INITIAL_OFFSET
+ FT_CONTENT_HASH_TYPE, TARGET_HANDLE, TARGET_ID, FT_CONTENT_TYPE, FT_FILENAME,
+ FT_SIZE, FT_CONTENT_HASH, FT_DESCRIPTION,
+ FT_DATE, FT_INITIAL_OFFSET, FT_URI
])
stream_tube_fixed_properties = dbus.Dictionary({
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 1ffa4d8e..588a020e 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -17,13 +17,14 @@ CHANNEL = "org.freedesktop.Telepathy.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.DRAFT"
+CHANNEL_IFACE_SASL_AUTH = CHANNEL + ".Interface.SASLAuthentication"
CHANNEL_IFACE_CONFERENCE = CHANNEL + '.Interface.Conference'
CHANNEL_TYPE_CALL = CHANNEL + ".Type.Call.DRAFT"
@@ -37,7 +38,7 @@ CHANNEL_TYPE_STREAMED_MEDIA = CHANNEL + ".Type.StreamedMedia"
CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer"
CHANNEL_TYPE_SERVER_AUTHENTICATION = \
- CHANNEL + ".Type.ServerAuthentication.DRAFT"
+ CHANNEL + ".Type.ServerAuthentication"
CHANNEL_TYPE_SERVER_TLS_CONNECTION = \
CHANNEL + ".Type.ServerTLSConnection"
@@ -60,7 +61,9 @@ INITIAL_VIDEO = CHANNEL_TYPE_STREAMED_MEDIA + '.InitialVideo'
IMMUTABLE_STREAMS = CHANNEL_TYPE_STREAMED_MEDIA + '.ImmutableStreams'
CALL_INITIAL_AUDIO = CHANNEL_TYPE_CALL + '.InitialAudio'
+CALL_INITIAL_AUDIO_NAME = CHANNEL_TYPE_CALL + '.InitialAudioName'
CALL_INITIAL_VIDEO = CHANNEL_TYPE_CALL + '.InitialVideo'
+CALL_INITIAL_VIDEO_NAME = CHANNEL_TYPE_CALL + '.InitialVideoName'
CALL_MUTABLE_CONTENTS = CHANNEL_TYPE_CALL + '.MutableContents'
CALL_CONTENT = 'org.freedesktop.Telepathy.Call.Content.DRAFT'
@@ -79,9 +82,13 @@ CALL_STREAM_ENDPOINT = 'org.freedesktop.Telepathy.Call.Stream.Endpoint.DRAFT'
CALL_MEDIA_TYPE_AUDIO = 0
CALL_MEDIA_TYPE_VIDEO = 1
-CALL_STREAM_TRANSPORT_RAW_UDP = 0
-CALL_STREAM_TRANSPORT_ICE = 1
-CALL_STREAM_TRANSPORT_GOOGLE = 2
+CALL_CONTENT_PACKETIZATION_RTP = 0
+CALL_CONTENT_PACKETIZATION_RAW = 1
+CALL_CONTENT_PACKETIZATION_MSN_WEBCAM = 2
+
+CALL_STREAM_TRANSPORT_RAW_UDP = 1
+CALL_STREAM_TRANSPORT_ICE = 2
+CALL_STREAM_TRANSPORT_GOOGLE = 3
CALL_STATE_UNKNOWN = 0
CALL_STATE_PENDING_INITIATOR = 1
@@ -93,8 +100,7 @@ CALL_MEMBER_FLAG_RINGING = 1
CALL_MEMBER_FLAG_HELD = 2
CALL_DISPOSITION_NONE = 0
-CALL_DISPOSITION_EARLY_MEDIA = 1
-CALL_DISPOSITION_INITIAL = 2
+CALL_DISPOSITION_INITIAL = 1
CALL_SENDING_STATE_NONE = 0
CALL_SENDING_STATE_PENDING_SEND = 1
@@ -123,9 +129,11 @@ CONN_IFACE_SIMPLE_PRESENCE = CONN + '.Interface.SimplePresence'
CONN_IFACE_REQUESTS = CONN + '.Interface.Requests'
CONN_IFACE_LOCATION = CONN + '.Interface.Location'
CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak'
-CONN_IFACE_MAIL_NOTIFICATION = CONN + '.Interface.MailNotification.DRAFT'
+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'
ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities'
@@ -151,6 +159,8 @@ NETWORK_ERROR = ERROR + '.NetworkError'
NOT_YET = ERROR + '.NotYet'
INVALID_HANDLE = ERROR + '.InvalidHandle'
CERT_UNTRUSTED = ERROR + '.Cert.Untrusted'
+SERVICE_BUSY = ERROR + '.ServiceBusy'
+SERVICE_CONFUSED = ERROR + '.ServiceConfused'
UNKNOWN_METHOD = 'org.freedesktop.DBus.Error.UnknownMethod'
@@ -253,6 +263,7 @@ FT_AVAILABLE_SOCKET_TYPES = CHANNEL_TYPE_FILE_TRANSFER + '.AvailableSocketTypes'
FT_TRANSFERRED_BYTES = CHANNEL_TYPE_FILE_TRANSFER + '.TransferredBytes'
FT_INITIAL_OFFSET = CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset'
FT_FILE_COLLECTION = CHANNEL_TYPE_FILE_TRANSFER + '.FUTURE.FileCollection'
+FT_URI = CHANNEL_TYPE_FILE_TRANSFER + '.URI'
GF_CAN_ADD = 1
GF_CAN_REMOVE = 2
@@ -346,10 +357,6 @@ CONTACT_INFO_FLAG_CAN_SET = 1
CONTACT_INFO_FLAG_PUSH = 2
CONTACT_INFO_FIELD_FLAG_PARAMETERS_MANDATORY = 1
-# Channel_Type_ServerAuthentication
-AUTH_TYPE_SASL = 0
-AUTH_TYPE_CAPTCHA = 1
-
# Channel_Interface_SaslAuthentication
SASL_STATUS_NOT_STARTED = 0
SASL_STATUS_IN_PROGRESS = 1
@@ -363,8 +370,14 @@ SASL_ABORT_REASON_INVALID_CHALLENGE = 0
SASL_ABORT_REASON_USER_ABORT = 1
AUTH_METHOD = CHANNEL_TYPE_SERVER_AUTHENTICATION + ".AuthenticationMethod"
-AUTH_INFO = CHANNEL_TYPE_SERVER_AUTHENTICATION + ".AuthenticationInformation"
SASL_AVAILABLE_MECHANISMS = CHANNEL_IFACE_SASL_AUTH + ".AvailableMechanisms"
+SASL_STATUS = CHANNEL_IFACE_SASL_AUTH + ".SASLStatus"
+SASL_ERROR = CHANNEL_IFACE_SASL_AUTH + ".SASLError"
+SASL_ERROR_DETAILS = CHANNEL_IFACE_SASL_AUTH + ".SASLErrorDetails"
+SASL_CONTEXT = CHANNEL_IFACE_SASL_AUTH + ".SASLContext"
+SASL_AUTHORIZATION_IDENTITY = CHANNEL_IFACE_SASL_AUTH + ".AuthorizationIdentity"
+SASL_DEFAULT_REALM = CHANNEL_IFACE_SASL_AUTH + ".DefaultRealm"
+SASL_DEFAULT_USERNAME = CHANNEL_IFACE_SASL_AUTH + ".DefaultUsername"
# Channel_Type_ServerTLSConnection
TLS_CERT_PATH = CHANNEL_TYPE_SERVER_TLS_CONNECTION + ".ServerCertificate"
@@ -383,6 +396,7 @@ MT_AUTO_REPLY = 3
MT_DELIVERY_REPORT = 4
PROTOCOL = 'org.freedesktop.Telepathy.Protocol'
+PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence'
PARAM_REQUIRED = 1
PARAM_REGISTER = 2
PARAM_HAS_DEFAULT = 4
@@ -398,3 +412,29 @@ TLS_CERT_STATE_REJECTED = 2
TLS_REJECT_REASON_UNKNOWN = 0
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'
+
+MSG_SENDING_FLAGS_REPORT_DELIVERY = 1
+MSG_SENDING_FLAGS_REPORT_READ = 2
+MSG_SENDING_FLAGS_REPORT_DELETED = 4
+
+DELIVERY_REPORTING_SUPPORT_FLAGS_RECEIVE_FAILURES = 1
+DELIVERY_REPORTING_SUPPORT_FLAGS_RECEIVE_SUCCESSES = 2
+DELIVERY_REPORTING_SUPPORT_FLAGS_RECEIVE_READ = 4
+DELIVERY_REPORTING_SUPPORT_FLAGS_RECEIVE_DELETED = 8
+
+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_PROVIDE = 8
diff --git a/tests/twisted/saluttest.py b/tests/twisted/saluttest.py
index 56253d2a..3205deb0 100644
--- a/tests/twisted/saluttest.py
+++ b/tests/twisted/saluttest.py
@@ -83,6 +83,7 @@ def exec_test_deferred (fun, params, protocol=None, timeout=None,
import traceback
traceback.print_exc()
error = e
+ queue.verbose = False
try:
if colourer: