summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-02-06 17:47:58 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-02-06 17:47:58 +0000
commit359a1ae278a9c33dd0bc41394912166ac2b5ecda (patch)
tree775c8f0fbc2217decfcdcfae057ae8b80bbdd2eb
parente0739058a22dae127e5410fd8ab4fb5dc2d49ad1 (diff)
parentb33adc647bf4e6dc75efba1abd74380d4bbb18d1 (diff)
downloadtelepathy-gabble-359a1ae278a9c33dd0bc41394912166ac2b5ecda.tar.gz
Merge branch 'master' into call1
Conflicts: src/Makefile.am For reasons I don't fully understand (presumably headers moving around a bit?) I had to add includes of <telepathy-glib/gtypes.h> or <telepathy-glib/interfaces.h> to: • src/call-content.c • src/private-tubes-factory.c • src/protocol.c • src/util.c But otherwise this has been an uneventful merge!
-rw-r--r--.gitignore3
-rw-r--r--Android.mk2
-rw-r--r--NEWS30
-rw-r--r--configure.ac1
-rw-r--r--gabble/capabilities-set.h2
-rw-r--r--gabble/connection.h2
-rw-r--r--gabble/error.h2
-rw-r--r--gabble/plugin.h2
-rw-r--r--lib/Makefile.am2
m---------lib/ext/wocky0
-rw-r--r--lib/loudmouth/Makefile.am75
-rw-r--r--lib/loudmouth/lm-connection.c209
-rw-r--r--lib/loudmouth/lm-connection.h67
-rw-r--r--lib/loudmouth/lm-message-handler.c56
-rw-r--r--lib/loudmouth/lm-message-handler.h64
-rw-r--r--lib/loudmouth/lm-message-node.c176
-rw-r--r--lib/loudmouth/lm-message-node.h62
-rw-r--r--lib/loudmouth/lm-message.c74
-rw-r--r--lib/loudmouth/lm-message.h88
-rw-r--r--lib/loudmouth/lm-types.h13
-rw-r--r--lib/loudmouth/loudmouth.h29
-rw-r--r--plugins/console.c6
-rw-r--r--plugins/console.h2
-rw-r--r--plugins/gateways.c4
-rw-r--r--plugins/gateways.h2
-rw-r--r--plugins/test.c3
-rw-r--r--plugins/test.h2
-rw-r--r--src/Makefile.am1
-rw-r--r--src/addressing-util.c2
-rw-r--r--src/auth-manager.c2
-rw-r--r--src/auth-manager.h2
-rw-r--r--src/bytestream-factory.c623
-rw-r--r--src/bytestream-factory.h12
-rw-r--r--src/bytestream-ibb.c148
-rw-r--r--src/bytestream-ibb.h9
-rw-r--r--src/bytestream-iface.h4
-rw-r--r--src/bytestream-muc.c53
-rw-r--r--src/bytestream-muc.h5
-rw-r--r--src/bytestream-multiple.c9
-rw-r--r--src/bytestream-multiple.h4
-rw-r--r--src/bytestream-socks5.c167
-rw-r--r--src/bytestream-socks5.h9
-rw-r--r--src/call-content.c1
-rw-r--r--src/call-muc-channel.c2
-rw-r--r--src/caps-hash.c3
-rw-r--r--src/caps-hash.h2
-rw-r--r--src/conn-addressing.c3
-rw-r--r--src/conn-aliasing.c97
-rw-r--r--src/conn-avatars.c46
-rw-r--r--src/conn-contact-info.c58
-rw-r--r--src/conn-location.c73
-rw-r--r--src/conn-mail-notif.c3
-rw-r--r--src/conn-olpc.c531
-rw-r--r--src/conn-olpc.h7
-rw-r--r--src/conn-power-saving.c3
-rw-r--r--src/conn-presence.c237
-rw-r--r--src/conn-util.c4
-rw-r--r--src/connection-manager.c2
-rw-r--r--src/connection.c356
-rw-r--r--src/connection.h30
-rw-r--r--src/debug.h7
-rw-r--r--src/disco.c101
-rw-r--r--src/disco.h4
-rw-r--r--src/error.c496
-rw-r--r--src/error.h73
-rw-r--r--src/ft-channel.c54
-rw-r--r--src/ft-manager.c36
-rw-r--r--src/ft-manager.h2
-rw-r--r--src/gabble.c7
-rw-r--r--src/im-channel.c5
-rw-r--r--src/im-factory.c58
-rw-r--r--src/jingle-content.c131
-rw-r--r--src/jingle-content.h23
-rw-r--r--src/jingle-factory.c13
-rw-r--r--src/jingle-media-rtp.c206
-rw-r--r--src/jingle-media-rtp.h1
-rw-r--r--src/jingle-session.c305
-rw-r--r--src/jingle-session.h14
-rw-r--r--src/jingle-share.c111
-rw-r--r--src/jingle-share.h1
-rw-r--r--src/jingle-transport-google.c58
-rw-r--r--src/jingle-transport-google.h1
-rw-r--r--src/jingle-transport-iceudp.c54
-rw-r--r--src/jingle-transport-iceudp.h1
-rw-r--r--src/jingle-transport-iface.c8
-rw-r--r--src/jingle-transport-iface.h10
-rw-r--r--src/jingle-transport-rawudp.c36
-rw-r--r--src/jingle-transport-rawudp.h1
-rw-r--r--src/legacy-caps.c2
-rw-r--r--src/media-factory.c1
-rw-r--r--src/message-util.c176
-rw-r--r--src/message-util.h9
-rw-r--r--src/muc-channel.c113
-rw-r--r--src/muc-channel.h1
-rw-r--r--src/muc-factory.c107
-rw-r--r--src/muc-factory.h3
-rw-r--r--src/plugin-loader.h2
-rw-r--r--src/presence-cache.c420
-rw-r--r--src/presence-cache.h6
-rw-r--r--src/presence.c23
-rw-r--r--src/presence.h2
-rw-r--r--src/private-tubes-factory.c87
-rw-r--r--src/private-tubes-factory.h5
-rw-r--r--src/protocol.c1
-rw-r--r--src/request-pipeline.c22
-rw-r--r--src/request-pipeline.h7
-rw-r--r--src/roomlist-manager.c1
-rw-r--r--src/roster.c37
-rw-r--r--src/search-channel.c252
-rw-r--r--src/search-manager.c8
-rw-r--r--src/server-sasl-channel.c4
-rw-r--r--src/server-sasl-channel.h2
-rw-r--r--src/server-tls-channel.c2
-rw-r--r--src/server-tls-manager.c4
-rw-r--r--src/server-tls-manager.h2
-rw-r--r--src/tube-dbus.c25
-rw-r--r--src/tube-iface.c14
-rw-r--r--src/tube-iface.h2
-rw-r--r--src/tube-stream.c82
-rw-r--r--src/tubes-channel.c160
-rw-r--r--src/tubes-channel.h11
-rw-r--r--src/util.c326
-rw-r--r--src/util.h67
-rw-r--r--src/vcard-manager.c249
-rw-r--r--src/vcard-manager.h10
-rw-r--r--tests/test-jid-decode.c2
-rw-r--r--tests/test-parse-message.c262
-rw-r--r--tests/twisted/Makefile.am2
-rw-r--r--tests/twisted/caps/broken-reply.py20
-rw-r--r--tests/twisted/connect/torture.py4
-rw-r--r--tests/twisted/presence/error.py71
-rw-r--r--tests/twisted/test-location.py4
-rw-r--r--tests/twisted/tubes/offer-muc-stream-tube.py2
-rw-r--r--tests/twisted/tubes/offer-no-caps.py2
-rw-r--r--tests/twisted/tubes/offer-private-stream-tube.py2
-rw-r--r--tests/twisted/tubes/tubetestutil.py16
136 files changed, 2995 insertions, 4940 deletions
diff --git a/.gitignore b/.gitignore
index 2ede58eb3..664c0825a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,9 +51,6 @@ core
/lib/gibber/gibber-signals-marshal.c
/lib/gibber/gibber-signals-marshal.h
/lib/gibber/gibber-signals-marshal.list
-lib/loudmouth/loudmouth-signals-marshal.c
-lib/loudmouth/loudmouth-signals-marshal.h
-lib/loudmouth/loudmouth-signals-marshal.list
/ltmain.sh
/m4/gtk-doc.m4
/m4/libtool.m4
diff --git a/Android.mk b/Android.mk
index 969f88506..0d98d0ee9 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,7 +7,6 @@ TELEPATHY_GABBLE_BUILT_SOURCES := \
gabble/telepathy-gabble-uninstalled.pc \
src/Android.mk \
lib/gibber/Android.mk \
- lib/loudmouth/Android.mk \
extensions/Android.mk
telepathy-gabble-configure-real:
@@ -37,5 +36,4 @@ CONFIGURE_TARGETS += telepathy-gabble-configure
#include all the subdirs...
-include $(TELEPATHY_GABBLE_TOP)/src/Android.mk
-include $(TELEPATHY_GABBLE_TOP)/lib/gibber/Android.mk
--include $(TELEPATHY_GABBLE_TOP)/lib/loudmouth/Android.mk
-include $(TELEPATHY_GABBLE_TOP)/extensions/Android.mk
diff --git a/NEWS b/NEWS
index 6810989f4..3ec5a16fb 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,35 @@ Go go go
Enhancements:
-* fd.o#41790 - Make file transfer support optional (andrunko)
+• fd.o#41790 - Make file transfer support optional (andrunko)
+
+• fd.o#44056 - telepathy-gabble-xmpp-console no longer mixes GIR and
+ pygtk. (Guillaume)
+
+• fd.o#33911 - The Loudmouth API compatibility layer has been removed.
+ It's possible this will cause regressions in weird edge cases but it
+ should make the code base more maintainable. (Jonny, Will)
+
+• fd.o#45491 - Error messages provided by the server in <presence
+ type='error'/> stanzas are now exposed via the SimplePresence API.
+ This makes it easier for users to distinguish contacts being offline
+ from contacts' servers being broken. (Will)
+
+API changes to Wocky snapshot:
+
+• fd.o#45400 - WockyPepService's API has changed a little bit.
+ wocky_pep_service_get_finish() has grown an extra out argument to give
+ the caller the <item/> element found, if any; similarly, the ::changed
+ signal has grown a similar extra argument. (Will)
+
+• fd.o#34975 - WockyPorter is now responsible for sending back error
+ replies for unhandled IQs, whereas previously this was up to Gabble.
+ Plugin authors shouldn't notice this change. (Will)
+
+• fd.o#27489 - including <wocky/wocky.h> now includes all public API
+ from Wocky, and including any other header directly is forbidden.
+ (This is similar to how GLib's headers are structured.) Out-of-tree
+ plugins will need to be updated. (Will)
telepathy-gabble 0.15.3 (2011-12-22)
====================================
diff --git a/configure.ac b/configure.ac
index e590706e0..90540b480 100644
--- a/configure.ac
+++ b/configure.ac
@@ -397,7 +397,6 @@ AC_OUTPUT( Makefile \
lib/Makefile \
lib/ext/Makefile \
lib/gibber/Makefile \
- lib/loudmouth/Makefile \
plugins/Makefile \
gabble/Makefile \
gabble/telepathy-gabble-uninstalled.pc \
diff --git a/gabble/capabilities-set.h b/gabble/capabilities-set.h
index 3f2152595..bc10c13fd 100644
--- a/gabble/capabilities-set.h
+++ b/gabble/capabilities-set.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include <wocky/wocky-node.h>
+#include <wocky/wocky.h>
G_BEGIN_DECLS
diff --git a/gabble/connection.h b/gabble/connection.h
index 1d7dccad9..5c7bf51e7 100644
--- a/gabble/connection.h
+++ b/gabble/connection.h
@@ -27,7 +27,7 @@
#include <gabble/capabilities-set.h>
#include <gabble/types.h>
-#include <wocky/wocky-xep-0115-capabilities.h>
+#include <wocky/wocky.h>
G_BEGIN_DECLS
diff --git a/gabble/error.h b/gabble/error.h
index 8563bf13b..cd5b4ee67 100644
--- a/gabble/error.h
+++ b/gabble/error.h
@@ -22,7 +22,7 @@
#include <glib.h>
-#include <wocky/wocky-xmpp-error.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/telepathy-glib.h>
G_BEGIN_DECLS
diff --git a/gabble/plugin.h b/gabble/plugin.h
index 6da99f136..7c3b4743f 100644
--- a/gabble/plugin.h
+++ b/gabble/plugin.h
@@ -26,7 +26,7 @@
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/presence-mixin.h>
-#include <wocky/wocky-session.h>
+#include <wocky/wocky.h>
#include <gabble/connection.h>
#include <gabble/sidecar.h>
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 620e572da..9755d06b8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1 +1 @@
-SUBDIRS=ext gibber loudmouth
+SUBDIRS=ext gibber
diff --git a/lib/ext/wocky b/lib/ext/wocky
-Subproject 8a1a8d94d40d731a8045d4fb2a67a65484a7983
+Subproject 17af336d3fe42109e9ab067c27bd9f20a915f9e
diff --git a/lib/loudmouth/Makefile.am b/lib/loudmouth/Makefile.am
deleted file mode 100644
index 63aed69f6..000000000
--- a/lib/loudmouth/Makefile.am
+++ /dev/null
@@ -1,75 +0,0 @@
-noinst_LTLIBRARIES = libloudmouth.la
-
-BUILT_SOURCES = \
- loudmouth-signals-marshal.list \
- loudmouth-signals-marshal.h \
- loudmouth-signals-marshal.c
-
-OUR_SOURCES = \
- loudmouth.h \
- lm-types.h \
- lm-message.c \
- lm-message.h \
- lm-message-node.c \
- lm-message-node.h \
- lm-message-handler.c \
- lm-message-handler.h \
- lm-connection.c \
- lm-connection.h
-
-libloudmouth_la_SOURCES = $(OUR_SOURCES) $(BUILT_SOURCES)
-libloudmouth_la_LIBADD = @WOCKY_LIBS@
-# filter out any -flags as we only need to include .a and .la files here:
-# this is necessary because:
-# @@ substitutions are filtered out by automake when constructing *_DEPENDENCIES
-# *_LIBADD contains the link flags, dynamic libs and static libs we want
-# *_DEPENDENCIES _MUST NOT_ contain the link flags and dynamic libs
-# *_DEPENDENCIES _SHOULD_ contain static libs so we rebuild when they change
-libloudmouth_la_DEPENDENCIES = \
- $(filter-out -%, $(libloudmouth_la_LIBADD))
-
-# Coding style checks
-check_c_sources = \
- $(OUR_SOURCES)
-
-include $(top_srcdir)/tools/check-coding-style.mk
-check-local: check-coding-style
-
-CLEANFILES=$(BUILT_SOURCES)
-dist-hook:
- $(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done)
-
-loudmouth-signals-marshal.list: $(OUR_SOURCES) Makefile.am
- $(AM_V_GEN)( cd $(srcdir) && \
- sed -n -e 's/.*_loudmouth_signals_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
- $(OUR_SOURCES) ) \
- | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp
- @if cmp -s $@.tmp $@; then \
- rm $@.tmp; \
- touch $@; \
- else \
- mv $@.tmp $@; \
- fi
-
-%-signals-marshal.h: %-signals-marshal.list Makefile.am
- $(AM_V_GEN)glib-genmarshal --header --prefix=_$(subst -,_,$*)_signals_marshal $< > $@
-
-%-signals-marshal.c: %-signals-marshal.list Makefile.am
- $(AM_V_GEN){ echo '#include "$*-signals-marshal.h"' && \
- glib-genmarshal --body --prefix=_$(subst -,_,$*)_signals_marshal $< ; \
- } > $@
-
-
-AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ @WOCKY_CFLAGS@
-
-AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ @WOCKY_LIBS@
-
-Android.mk: Makefile.am $(BUILT_SOURCES)
- androgenizer -:PROJECT telepathy-gabble -:STATIC loudmouth -:TAGS eng debug \
- -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
- -:SOURCES $(libloudmouth_la_SOURCES) \
- -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CFLAGS) \
- -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \
- -:LDFLAGS $(libloudmouth_la_LIBADD) \
- > $@
diff --git a/lib/loudmouth/lm-connection.c b/lib/loudmouth/lm-connection.c
deleted file mode 100644
index 8bde9b281..000000000
--- a/lib/loudmouth/lm-connection.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * lm-connection.c - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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 "lm-connection.h"
-#include "lm-message-handler.h"
-
-static gboolean
-stanza_cb (WockyPorter *self,
- WockyStanza *stanza,
- gpointer user_data)
-{
- LmMessageHandler *handler = (LmMessageHandler *) user_data;
- LmHandlerResult result;
-
- result = handler->function (handler, handler->connection, stanza,
- handler->user_data);
-
- if (result == LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS)
- return FALSE;
- else
- return TRUE;
-}
-
-typedef struct
-{
- LmMessageHandler *handler;
- LmMessageType type;
- LmHandlerPriority priority;
-} delayed_handler;
-
-void
-lm_connection_register_message_handler (LmConnection *connection,
- LmMessageHandler *handler,
- LmMessageType type,
- LmHandlerPriority priority)
-{
- if (connection->porter == NULL)
- {
- /* Loudmouth lets you register handlers before the connection is
- * connected. We can't do currently do that with Wocky so we store the
- * handler and will register it once lm_connection_set_porter is called.*/
- delayed_handler *delayed;
-
- delayed = g_slice_new (delayed_handler);
- delayed->handler = handler;
- delayed->type = type;
- delayed->priority = priority;
-
- connection->delayed_handlers = g_slist_prepend (
- connection->delayed_handlers, delayed);
- return;
- }
-
- /* Genuine Loudmouth lets you register the same handler once per message
- * type, but this compatibility shim only lets you register each
- * LmMessageHandler once. */
- g_assert (handler->handler_id == 0);
- g_assert (handler->connection == NULL);
-
- handler->connection = connection;
-
- handler->handler_id = wocky_porter_register_handler_from_anyone (
- connection->porter, type, WOCKY_STANZA_SUB_TYPE_NONE, priority, stanza_cb,
- handler, NULL);
-}
-
-void
-lm_connection_unregister_message_handler (LmConnection *connection,
- LmMessageHandler *handler,
- LmMessageType type)
-{
- if (handler->handler_id == 0)
- return;
-
- g_assert (handler->connection != NULL);
-
- wocky_porter_unregister_handler (handler->connection->porter,
- handler->handler_id);
-
- handler->handler_id = 0;
- handler->connection = NULL;
-}
-
-void
-lm_connection_unref (LmConnection *connection)
-{
- GSList *l;
-
- for (l = connection->delayed_handlers; l != NULL; l = g_slist_next (l))
- {
- delayed_handler *delayed = l->data;
-
- g_slice_free (delayed_handler, delayed);
- }
-
- g_slist_free (connection->delayed_handlers);
- connection->delayed_handlers = NULL;
-
- g_cancellable_cancel (connection->iq_reply_cancellable);
- g_object_unref (connection->iq_reply_cancellable);
- connection->iq_reply_cancellable = NULL;
-
- if (connection->porter != NULL)
- {
- g_object_unref (connection->porter);
- connection->porter = NULL;
- }
-
- g_free (connection);
-}
-
-static void
-iq_reply_cb (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
-{
- LmMessageHandler *handler = (LmMessageHandler *) user_data;
- WockyStanza *reply;
- GError *error = NULL;
-
- reply = wocky_porter_send_iq_finish (WOCKY_PORTER (source), res, &error);
- if (reply == NULL)
- {
- g_debug ("send_iq_async failed: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- handler->function (handler, handler->connection, reply,
- handler->user_data);
-
- g_object_unref (reply);
-
-out:
- lm_message_handler_unref (handler);
-}
-
-gboolean
-lm_connection_send_with_reply (LmConnection *connection,
- LmMessage *message,
- LmMessageHandler *handler,
- GError **error)
-{
- g_assert (connection != NULL);
- g_assert (connection->porter != NULL);
-
- handler->connection = connection;
- lm_message_handler_ref (handler);
-
- wocky_porter_send_iq_async (connection->porter, message,
- connection->iq_reply_cancellable, iq_reply_cb, handler);
-
- return TRUE;
-}
-
-LmConnection *
-lm_connection_new (void)
-{
- LmConnection *connection;
-
- connection = g_malloc (sizeof (LmConnection));
- connection->porter = NULL;
- connection->delayed_handlers = NULL;
- connection->iq_reply_cancellable = g_cancellable_new ();
-
- return connection;
-}
-
-void
-lm_connection_set_porter (LmConnection *connection,
- WockyPorter *porter)
-{
- GSList *l;
-
- g_assert (connection != NULL);
- g_assert (connection->porter == NULL);
- connection->porter = g_object_ref (porter);
-
- /* Now that we have a porter we can register the delayed handlers */
- for (l = connection->delayed_handlers; l != NULL; l = g_slist_next (l))
- {
- delayed_handler *delayed = l->data;
-
- lm_connection_register_message_handler (connection, delayed->handler,
- delayed->type, delayed->priority);
-
- g_slice_free (delayed_handler, delayed);
- }
-
- g_slist_free (connection->delayed_handlers);
- connection->delayed_handlers = NULL;
-}
diff --git a/lib/loudmouth/lm-connection.h b/lib/loudmouth/lm-connection.h
deleted file mode 100644
index 83100b6a8..000000000
--- a/lib/loudmouth/lm-connection.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * lm-connection.h - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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
- */
-
-#ifndef __LM_CONNECTION_H__
-#define __LM_CONNECTION_H__
-
-#include <wocky/wocky-stanza.h>
-#include <wocky/wocky-porter.h>
-
-#include "lm-types.h"
-#include "lm-message.h"
-#include "lm-message-handler.h"
-
-G_BEGIN_DECLS
-
-struct _LmConnection
-{
- WockyPorter *porter;
- GSList *delayed_handlers;
- GCancellable *iq_reply_cancellable;
-};
-
-typedef guint LmHandlerPriority;
-
-LmConnection * lm_connection_new (void);
-
-void lm_connection_register_message_handler (LmConnection *connection,
- LmMessageHandler *handler,
- LmMessageType type,
- LmHandlerPriority priority);
-
-void lm_connection_unregister_message_handler (LmConnection *connection,
- LmMessageHandler *handler,
- LmMessageType type);
-
-void lm_connection_unref (LmConnection *connection);
-
-gboolean lm_connection_send_with_reply (LmConnection *connection,
- LmMessage *message,
- LmMessageHandler *handler,
- GError **error);
-
-/* Fake API. This is not part of loudmouth */
-
-void lm_connection_set_porter (LmConnection *connection,
- WockyPorter *porter);
-
-G_END_DECLS
-
-#endif /* #ifndef __LM_CONNECTION_H__ */
diff --git a/lib/loudmouth/lm-message-handler.c b/lib/loudmouth/lm-message-handler.c
deleted file mode 100644
index f3c3988a7..000000000
--- a/lib/loudmouth/lm-message-handler.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * lm-message-handler.c - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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 "lm-message-handler.h"
-
-LmMessageHandler *
-lm_message_handler_new (LmHandleMessageFunction function,
- gpointer user_data,
- GDestroyNotify notify)
-{
- LmMessageHandler *handler = g_slice_new0 (LmMessageHandler);
- handler->function = function;
- handler->user_data = user_data;
- handler->notify = notify;
- handler->ref_count = 1;
-
- return handler;
-}
-
-void
-lm_message_handler_unref (LmMessageHandler *handler)
-{
- handler->ref_count--;
-
- if (handler->ref_count == 0)
- {
- if (handler->notify != NULL)
- handler->notify (handler->user_data);
- g_slice_free (LmMessageHandler, handler);
- }
-}
-
-LmMessageHandler *
-lm_message_handler_ref (LmMessageHandler *handler)
-{
- handler->ref_count++;
-
- return handler;
-}
diff --git a/lib/loudmouth/lm-message-handler.h b/lib/loudmouth/lm-message-handler.h
deleted file mode 100644
index 63feecc00..000000000
--- a/lib/loudmouth/lm-message-handler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * lm-message-handler.h - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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
- */
-
-#ifndef __LM_MESSAGE_HANDLER_H__
-#define __LM_MESSAGE_HANDLER_H__
-
-#include "lm-types.h"
-#include "lm-connection.h"
-#include "lm-message.h"
-
-G_BEGIN_DECLS
-
-typedef enum {
- LM_HANDLER_RESULT_REMOVE_MESSAGE,
- LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS
-} LmHandlerResult;
-
-typedef LmHandlerResult (*LmHandleMessageFunction) (LmMessageHandler *handler,
- LmConnection *connection,
- LmMessage *message,
- gpointer user_data);
-
-struct _LmMessageHandler
-{
- guint handler_id;
- LmConnection *connection;
- LmHandleMessageFunction function;
- gpointer user_data;
- GDestroyNotify notify;
- guint ref_count;
-};
-
-#define LM_HANDLER_PRIORITY_LAST WOCKY_PORTER_HANDLER_PRIORITY_MIN
-#define LM_HANDLER_PRIORITY_NORMAL WOCKY_PORTER_HANDLER_PRIORITY_NORMAL
-#define LM_HANDLER_PRIORITY_FIRST WOCKY_PORTER_HANDLER_PRIORITY_MAX
-
-LmMessageHandler * lm_message_handler_new (LmHandleMessageFunction function,
- gpointer user_data,
- GDestroyNotify notify);
-
-void lm_message_handler_unref (LmMessageHandler *handler);
-
-LmMessageHandler * lm_message_handler_ref (LmMessageHandler *handler);
-
-G_END_DECLS
-
-#endif /* #ifndef __LM_MESSAGE_HANDLER_H__ */
diff --git a/lib/loudmouth/lm-message-node.c b/lib/loudmouth/lm-message-node.c
deleted file mode 100644
index 8f5417cf9..000000000
--- a/lib/loudmouth/lm-message-node.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * lm-message-node.c - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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 "lm-message-node.h"
-
-#include <wocky/wocky-utils.h>
-
-static gboolean
-copy_attribute (const gchar *key,
- const gchar *value,
- const gchar *prefix,
- const gchar *ns,
- gpointer user_data)
-{
- WockyNode *copy = (WockyNode *) user_data;
-
- wocky_node_set_attribute_ns (copy, key, value, ns);
- return TRUE;
-}
-
-static WockyNode *
-copy_node (WockyNode *node)
-{
- WockyNode *copy;
- GSList *l;
-
- copy = wocky_node_new (node->name, wocky_node_get_ns (node));
- wocky_node_set_content (copy, node->content);
- wocky_node_set_language (copy, wocky_node_get_language (node));
-
- wocky_node_each_attribute (node, copy_attribute, copy);
-
- for (l = node->children; l != NULL; l = g_slist_next (l))
- {
- WockyNode *child = l->data;
-
- copy->children = g_slist_prepend (copy->children, copy_node (child));
- }
- copy->children = g_slist_reverse (copy->children);
-
- return copy;
-}
-
-LmMessageNode *
-lm_message_node_ref (LmMessageNode *node)
-{
- /* WockyNode is not ref counted. Return a copy of the node */
- return copy_node (node);
-}
-
-void
-lm_message_node_unref (LmMessageNode *node)
-{
- wocky_node_free (node);
-}
-
-void
-lm_message_node_set_attribute (LmMessageNode *node,
- const gchar *name,
- const gchar *value)
-{
- if (!wocky_strdiff (name, "xmlns"))
- node->ns = g_quark_from_string (value);
- else if (!wocky_strdiff (name, "xml:lang"))
- wocky_node_set_language (node, value);
- else
- wocky_node_set_attribute (node, name, value);
-}
-
-const gchar *
-lm_message_node_get_attribute (LmMessageNode *node,
- const gchar *name)
-{
- if (!wocky_strdiff (name, "xmlns"))
- return wocky_node_get_ns (node);
- else if (!wocky_strdiff (name, "xml:lang"))
- return wocky_node_get_language (node);
-
- return wocky_node_get_attribute (node, name);
-}
-
-void
-lm_message_node_set_attributes (LmMessageNode *node,
- const gchar *name,
- ...)
-{
- va_list args;
-
- g_return_if_fail (node != NULL);
-
- va_start (args, name);
- while (name != NULL)
- {
- const gchar *value;
- value = (const gchar *) va_arg (args, gchar *);
-
- lm_message_node_set_attribute (node, name, value);
-
- name = (const gchar *) va_arg (args, gchar *);
- }
- va_end (args);
-}
-
-LmMessageNode *
-lm_message_node_add_child (LmMessageNode *node,
- const gchar *name,
- const gchar *value)
-{
- return wocky_node_add_child_with_content (node, name, value);
-}
-
-LmMessageNode *
-lm_message_node_get_child (LmMessageNode *node,
- const gchar *child_name)
-{
- return wocky_node_get_child (node, child_name);
-}
-
-LmMessageNode *
-lm_message_node_find_child (LmMessageNode *node,
- const gchar *child_name)
-{
- WockyNode *found;
- GSList *l;
-
- found = wocky_node_get_child (node, child_name);
- if (found != NULL)
- return found;
-
- for (l = node->children; l != NULL; l = g_slist_next (l))
- {
- WockyNode *child = l->data;
-
- found = lm_message_node_find_child (child, child_name);
- if (found != NULL)
- return found;
- }
-
- return NULL;
-}
-
-const gchar *
-lm_message_node_get_value (LmMessageNode *node)
-{
- return node->content;
-}
-
-void
-lm_message_node_set_value (LmMessageNode *node,
- const gchar *value)
-{
- wocky_node_set_content (node, value);
-}
-
-gchar *
-lm_message_node_to_string (LmMessageNode *node)
-{
- return wocky_node_to_string (node);
-}
diff --git a/lib/loudmouth/lm-message-node.h b/lib/loudmouth/lm-message-node.h
deleted file mode 100644
index 1ea8b734d..000000000
--- a/lib/loudmouth/lm-message-node.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * lm-message-node.h - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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
- */
-
-#ifndef __LM_MESSAGE_NODE_H__
-#define __LM_MESSAGE_NODE_H__
-
-#include <wocky/wocky-node.h>
-
-G_BEGIN_DECLS
-
-typedef WockyNode LmMessageNode;
-
-LmMessageNode * lm_message_node_ref (LmMessageNode *node)
- G_GNUC_WARN_UNUSED_RESULT;
-void lm_message_node_unref (LmMessageNode *node);
-
-void lm_message_node_set_attribute (LmMessageNode *node,
- const gchar *name,
- const gchar *value);
-
-const gchar * lm_message_node_get_attribute (LmMessageNode *node,
- const gchar *name);
-
-void lm_message_node_set_attributes (LmMessageNode *node,
- const gchar *name,
- ...);
-
-LmMessageNode * lm_message_node_add_child (LmMessageNode *node,
- const gchar *name,
- const gchar *value);
-
-LmMessageNode * lm_message_node_get_child (LmMessageNode *node,
- const gchar *child_name);
-
-LmMessageNode * lm_message_node_find_child (LmMessageNode *node,
- const gchar *child_name);
-
-const gchar * lm_message_node_get_value (LmMessageNode *node);
-
-void lm_message_node_set_value (LmMessageNode *node,
- const gchar *value);
-
-gchar * lm_message_node_to_string (LmMessageNode *node);
-
-#endif /* #ifndef __LM_MESSAGE_NODE_H__ */
diff --git a/lib/loudmouth/lm-message.c b/lib/loudmouth/lm-message.c
deleted file mode 100644
index d6a0c7925..000000000
--- a/lib/loudmouth/lm-message.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * lm-message.c - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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 "lm-message.h"
-
-LmMessage *
-lm_message_new (const gchar *to,
- LmMessageType type)
-{
- return wocky_stanza_build (type, WOCKY_STANZA_SUB_TYPE_NONE,
- NULL, to, NULL);
-}
-
-LmMessage *
-lm_message_new_with_sub_type (const gchar *to,
- LmMessageType type,
- LmMessageSubType sub_type)
-{
- return wocky_stanza_build (type, sub_type,
- NULL, to, NULL);
-}
-
-LmMessage *
-lm_message_ref (LmMessage *message)
-{
- return g_object_ref (message);
-}
-
-void
-lm_message_unref (LmMessage *message)
-{
- g_object_unref (message);
-}
-
-LmMessageType
-lm_message_get_type (LmMessage *message)
-{
- WockyStanzaType type;
-
- wocky_stanza_get_type_info (message, &type, NULL);
- return type;
-}
-
-LmMessageSubType
-lm_message_get_sub_type (LmMessage *message)
-{
- WockyStanzaSubType sub_type;
-
- wocky_stanza_get_type_info (message, NULL, &sub_type);
- return sub_type;
-}
-
-LmMessageNode *
-lm_message_get_node (LmMessage *message)
-{
- return wocky_stanza_get_top_node (message);
-}
diff --git a/lib/loudmouth/lm-message.h b/lib/loudmouth/lm-message.h
deleted file mode 100644
index c1df07056..000000000
--- a/lib/loudmouth/lm-message.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * lm-message.h - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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
- */
-
-#ifndef __LM_MESSAGE_H__
-#define __LM_MESSAGE_H__
-
-#include <wocky/wocky-stanza.h>
-
-#include "lm-message-node.h"
-
-G_BEGIN_DECLS
-
-typedef WockyStanza LmMessage;
-
-typedef WockyStanzaType LmMessageType;
-
-#define LM_MESSAGE_TYPE_MESSAGE WOCKY_STANZA_TYPE_MESSAGE
-#define LM_MESSAGE_TYPE_PRESENCE WOCKY_STANZA_TYPE_PRESENCE
-#define LM_MESSAGE_TYPE_IQ WOCKY_STANZA_TYPE_IQ
-#define LM_MESSAGE_TYPE_STREAM WOCKY_STANZA_TYPE_STREAM
-#define LM_MESSAGE_TYPE_STREAM_ERROR WOCKY_STANZA_TYPE_STREAM_ERROR
-#define LM_MESSAGE_TYPE_STREAM_FEATURES WOCKY_STANZA_TYPE_STREAM_FEATURES
-#define LM_MESSAGE_TYPE_AUTH WOCKY_STANZA_TYPE_AUTH,
-#define LM_MESSAGE_TYPE_CHALLENGE WOCKY_STANZA_TYPE_CHALLENGE
-#define LM_MESSAGE_TYPE_RESPONSE WOCKY_STANZA_TYPE_RESPONSE
-#define LM_MESSAGE_TYPE_SUCCESS WOCKY_STANZA_TYPE_SUCCESS
-#define LM_MESSAGE_TYPE_FAILURE WOCKY_STANZA_TYPE_FAILURE
-/*
-#define LM_MESSAGE_TYPE_PROCEED
-#define LM_MESSAGE_TYPE_STARTTLS
-*/
-#define LM_MESSAGE_TYPE_UNKNOWN WOCKY_STANZA_TYPE_UNKNOWN
-
-typedef WockyStanzaSubType LmMessageSubType;
-
-#define LM_MESSAGE_SUB_TYPE_NOT_SET WOCKY_STANZA_SUB_TYPE_NONE
-#define LM_MESSAGE_SUB_TYPE_AVAILABLE WOCKY_STANZA_SUB_TYPE_AVAILABLE
-#define LM_MESSAGE_SUB_TYPE_NORMAL WOCKY_STANZA_SUB_TYPE_NORMAL
-#define LM_MESSAGE_SUB_TYPE_CHAT WOCKY_STANZA_SUB_TYPE_CHAT
-#define LM_MESSAGE_SUB_TYPE_GROUPCHAT WOCKY_STANZA_SUB_TYPE_GROUPCHAT
-#define LM_MESSAGE_SUB_TYPE_HEADLINE WOCKY_STANZA_SUB_TYPE_HEADLINE
-#define LM_MESSAGE_SUB_TYPE_UNAVAILABLE WOCKY_STANZA_SUB_TYPE_UNAVAILABLE
-#define LM_MESSAGE_SUB_TYPE_PROBE WOCKY_STANZA_SUB_TYPE_PROBE
-#define LM_MESSAGE_SUB_TYPE_SUBSCRIBE WOCKY_STANZA_SUB_TYPE_SUBSCRIBE
-#define LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE WOCKY_STANZA_SUB_TYPE_UNSUBSCRIBE
-#define LM_MESSAGE_SUB_TYPE_SUBSCRIBED WOCKY_STANZA_SUB_TYPE_SUBSCRIBED
-#define LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED WOCKY_STANZA_SUB_TYPE_UNSUBSCRIBED
-#define LM_MESSAGE_SUB_TYPE_GET WOCKY_STANZA_SUB_TYPE_GET
-#define LM_MESSAGE_SUB_TYPE_SET WOCKY_STANZA_SUB_TYPE_SET
-#define LM_MESSAGE_SUB_TYPE_RESULT WOCKY_STANZA_SUB_TYPE_RESULT
-#define LM_MESSAGE_SUB_TYPE_ERROR WOCKY_STANZA_SUB_TYPE_ERROR
-
-LmMessage * lm_message_new (const gchar *to,
- LmMessageType type);
-
-LmMessage * lm_message_new_with_sub_type (const gchar *to,
- LmMessageType type,
- LmMessageSubType sub_type);
-
-
-LmMessage * lm_message_ref (LmMessage *message);
-void lm_message_unref (LmMessage *message);
-
-LmMessageType lm_message_get_type (LmMessage *message);
-LmMessageSubType lm_message_get_sub_type (LmMessage *message);
-
-LmMessageNode * lm_message_get_node (LmMessage *message);
-
-G_END_DECLS
-
-#endif /* #ifndef __LM_MESSAGE_H__ */
diff --git a/lib/loudmouth/lm-types.h b/lib/loudmouth/lm-types.h
deleted file mode 100644
index 077ccbc33..000000000
--- a/lib/loudmouth/lm-types.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __LM_TYPES_H__
-#define __LM_TYPES_H__
-
-#include <wocky/wocky-porter.h>
-
-G_BEGIN_DECLS
-
-typedef struct _LmMessageHandler LmMessageHandler;
-typedef struct _LmConnection LmConnection;
-
-G_END_DECLS
-
-#endif /* #ifndef __LM_TYPES_H__ */
diff --git a/lib/loudmouth/loudmouth.h b/lib/loudmouth/loudmouth.h
deleted file mode 100644
index 3f3bf7e6c..000000000
--- a/lib/loudmouth/loudmouth.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * loudmouth.h - Loudmouth-Wocky compatibility layer
- * Copyright (C) 2009 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
- */
-
-#ifndef __LOUDMOUTH_H__
-#define __LOUDMOUTH_H__
-
-#include <loudmouth/lm-connection.h>
-#include <loudmouth/lm-message.h>
-#include <loudmouth/lm-message-handler.h>
-#include <loudmouth/lm-message-node.h>
-
-#endif /* #ifndef __LOUDMOUTH_H__ */
diff --git a/plugins/console.c b/plugins/console.c
index 13ca0eccf..87a450bd1 100644
--- a/plugins/console.c
+++ b/plugins/console.c
@@ -25,11 +25,7 @@
#include <telepathy-glib/telepathy-glib.h>
-#include <wocky/wocky-xmpp-error.h>
-#include <wocky/wocky-utils.h>
-#include <wocky/wocky-xmpp-reader.h>
-#include <wocky/wocky-xmpp-writer.h>
-#include <wocky/wocky-namespaces.h>
+#include <wocky/wocky.h>
#include "extensions/extensions.h"
diff --git a/plugins/console.h b/plugins/console.h
index a91b95337..9a3d5d619 100644
--- a/plugins/console.h
+++ b/plugins/console.h
@@ -20,7 +20,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <wocky/wocky-session.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/dbus-properties-mixin.h>
typedef struct _GabbleConsolePlugin GabbleConsolePlugin;
diff --git a/plugins/gateways.c b/plugins/gateways.c
index 88a32223f..be08e6228 100644
--- a/plugins/gateways.c
+++ b/plugins/gateways.c
@@ -25,9 +25,7 @@
#include <telepathy-glib/telepathy-glib.h>
-#include <wocky/wocky-namespaces.h>
-#include <wocky/wocky-xmpp-error.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include "extensions/extensions.h"
diff --git a/plugins/gateways.h b/plugins/gateways.h
index 766fa4bee..e4d734afe 100644
--- a/plugins/gateways.h
+++ b/plugins/gateways.h
@@ -20,7 +20,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <wocky/wocky-session.h>
+#include <wocky/wocky.h>
typedef struct _GabbleGatewayPlugin GabbleGatewayPlugin;
typedef struct _GabbleGatewayPluginClass GabbleGatewayPluginClass;
diff --git a/plugins/test.c b/plugins/test.c
index 05d784052..29c45a9e1 100644
--- a/plugins/test.c
+++ b/plugins/test.c
@@ -5,8 +5,7 @@
#include <telepathy-glib/telepathy-glib.h>
-#include <wocky/wocky-disco-identity.h>
-#include <wocky/wocky-data-form.h>
+#include <wocky/wocky.h>
#include "extensions/extensions.h"
diff --git a/plugins/test.h b/plugins/test.h
index 6fe0d1434..16a209c7e 100644
--- a/plugins/test.h
+++ b/plugins/test.h
@@ -1,7 +1,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <wocky/wocky-session.h>
+#include <wocky/wocky.h>
#include <gabble/gabble.h>
/* Plugin */
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d520828a..82308df62 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -212,7 +212,6 @@ enumtype_sources = \
libgabble_convenience_la_LIBADD = \
$(top_builddir)/extensions/libgabble-extensions.la \
$(top_builddir)/lib/gibber/libgibber.la \
- $(top_builddir)/lib/loudmouth/libloudmouth.la \
$(ALL_LIBS)
nodist_libgabble_convenience_la_SOURCES = \
diff --git a/src/addressing-util.c b/src/addressing-util.c
index 1ea089854..0f1b3ffcc 100644
--- a/src/addressing-util.c
+++ b/src/addressing-util.c
@@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include "connection.h"
#include "util.h"
diff --git a/src/auth-manager.c b/src/auth-manager.c
index 5089e9aed..57a8bbd62 100644
--- a/src/auth-manager.c
+++ b/src/auth-manager.c
@@ -24,7 +24,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_AUTH
diff --git a/src/auth-manager.h b/src/auth-manager.h
index 61a35a5f0..bdf7ebfe2 100644
--- a/src/auth-manager.h
+++ b/src/auth-manager.h
@@ -21,7 +21,7 @@
#define __AUTH_MANAGER_H__
#include <glib-object.h>
-#include <wocky/wocky-auth-registry.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/handle.h>
G_BEGIN_DECLS
diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index 2a2732269..725f06e9f 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -25,8 +25,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/interfaces.h>
#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
@@ -145,10 +144,10 @@ gabble_socks5_proxy_free (GabbleSocks5Proxy *proxy)
struct _GabbleBytestreamFactoryPrivate
{
GabbleConnection *conn;
- LmMessageHandler *iq_si_cb;
- LmMessageHandler *iq_ibb_cb;
- LmMessageHandler *iq_socks5_cb;
- LmMessageHandler *msg_data_cb;
+ guint iq_si_cb;
+ guint iq_ibb_cb;
+ guint iq_socks5_cb;
+ guint msg_data_cb;
/* SI-initiated bytestreams - data sent by normal messages, IQs used to
* open and close.
@@ -185,21 +184,25 @@ struct _GabbleBytestreamFactoryPrivate
#define GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE(obj) ((obj)->priv)
-static LmHandlerResult
-bytestream_factory_msg_data_cb (LmMessageHandler *handler,
- LmConnection *lmconn, LmMessage *message, gpointer user_data);
+static gboolean bytestream_factory_msg_data_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data);
-static LmHandlerResult
-bytestream_factory_iq_si_cb (LmMessageHandler *handler, LmConnection *lmconn,
- LmMessage *message, gpointer user_data);
+static gboolean bytestream_factory_iq_si_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data);
-static LmHandlerResult
-bytestream_factory_iq_ibb_cb (LmMessageHandler *handler, LmConnection *lmconn,
- LmMessage *message, gpointer user_data);
+static gboolean bytestream_factory_iq_ibb_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data);
-static LmHandlerResult
-bytestream_factory_iq_socks5_cb (LmMessageHandler *handler,
- LmConnection *lmconn, LmMessage *message, gpointer user_data);
+static gboolean handle_socks5_query_iq (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data);
static void query_proxies (GabbleBytestreamFactory *self,
guint nb_proxies_needed);
@@ -294,17 +297,17 @@ add_proxy_to_list (GabbleBytestreamFactory *self,
*list = g_slist_prepend (*list, proxy);
}
-static LmHandlerResult
+static void
socks5_proxy_query_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (obj);
GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
self);
- LmMessageNode *query, *streamhost;
+ WockyNode *query, *streamhost;
const gchar *from;
const gchar *jid, *host, *portstr;
gint64 port;
@@ -312,26 +315,26 @@ socks5_proxy_query_reply_cb (GabbleConnection *conn,
gboolean fallback = GPOINTER_TO_INT (user_data);
GSList *found = NULL;
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "from");
if (from == NULL)
goto fail;
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
goto fail;
- query = lm_message_node_get_child_with_namespace (
+ query = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "query", NS_BYTESTREAMS);
if (query == NULL)
goto fail;
- streamhost = lm_message_node_get_child (query, "streamhost");
+ streamhost = wocky_node_get_child (query, "streamhost");
if (streamhost == NULL)
goto fail;
- jid = lm_message_node_get_attribute (streamhost, "jid");
- host = lm_message_node_get_attribute (streamhost, "host");
- portstr = lm_message_node_get_attribute (streamhost, "port");
+ jid = wocky_node_get_attribute (streamhost, "jid");
+ host = wocky_node_get_attribute (streamhost, "host");
+ portstr = wocky_node_get_attribute (streamhost, "port");
if (jid == NULL || host == NULL || portstr == NULL)
goto fail;
@@ -345,7 +348,7 @@ socks5_proxy_query_reply_cb (GabbleConnection *conn,
add_proxy_to_list (self , proxy, fallback);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
fail:
if (fallback && from != NULL)
@@ -366,7 +369,6 @@ fail:
/* Try to get another proxy as this one failed */
query_proxies (self, 1);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -376,21 +378,21 @@ send_proxy_query (GabbleBytestreamFactory *self,
{
GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
self);
- LmMessage *query;
+ WockyStanza *query;
DEBUG ("send SOCKS5 query to %s", jid);
- query = lm_message_build (jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "get",
- '(', "query", "",
- '@', "xmlns", NS_BYTESTREAMS,
+ query = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_GET,
+ NULL, jid,
+ '(', "query",
+ ':', NS_BYTESTREAMS,
')', NULL);
_gabble_connection_send_with_reply (priv->conn, query,
socks5_proxy_query_reply_cb, G_OBJECT (self), GINT_TO_POINTER (fallback),
NULL);
- lm_message_unref (query);
+ g_object_unref (query);
}
static void
@@ -436,14 +438,15 @@ proxies_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *j,
const gchar *n,
- LmMessageNode *query_result,
+ WockyNode *query_result,
GError *error,
gpointer user_data)
{
GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
self);
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
GSList *new_list = NULL;
if (error != NULL)
@@ -452,15 +455,10 @@ proxies_disco_cb (GabbleDisco *disco,
return;
}
- for (i = node_iter (query_result); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, query_result, "item", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
- const gchar *jid;
-
- if (tp_strdiff (node->name, "item"))
- continue;
-
- jid = lm_message_node_get_attribute (node, "jid");
+ const gchar *jid = wocky_node_get_attribute (node, "jid");
if (jid == NULL)
continue;
@@ -571,6 +569,43 @@ randomize_g_slist (GSList *list)
}
static void
+porter_available_cb (
+ GabbleConnection *conn,
+ WockyPorter *porter,
+ gpointer user_data)
+{
+ GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
+ GabbleBytestreamFactoryPrivate *priv = self->priv;
+
+ priv->msg_data_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ bytestream_factory_msg_data_cb, self,
+ NULL);
+
+ priv->iq_si_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ bytestream_factory_iq_si_cb, self,
+ '(', "si", ':', NS_SI,
+ ')',
+ NULL);
+
+ priv->iq_ibb_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ bytestream_factory_iq_ibb_cb, self,
+ NULL);
+
+ priv->iq_socks5_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ handle_socks5_query_iq, self,
+ '(', "query", ':', NS_BYTESTREAMS, ')',
+ NULL);
+}
+
+static void
conn_status_changed_cb (GabbleConnection *conn,
TpConnectionStatus status,
TpConnectionStatusReason reason,
@@ -620,32 +655,14 @@ gabble_bytestream_factory_constructor (GType type,
self = GABBLE_BYTESTREAM_FACTORY (obj);
priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
- priv->msg_data_cb = lm_message_handler_new (bytestream_factory_msg_data_cb,
- self, NULL);
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->msg_data_cb, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_FIRST);
-
- priv->iq_si_cb = lm_message_handler_new (bytestream_factory_iq_si_cb, self,
- NULL);
- lm_connection_register_message_handler (priv->conn->lmconn, priv->iq_si_cb,
- LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
-
- priv->iq_ibb_cb = lm_message_handler_new (bytestream_factory_iq_ibb_cb, self,
- NULL);
- lm_connection_register_message_handler (priv->conn->lmconn, priv->iq_ibb_cb,
- LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
-
- priv->iq_socks5_cb = lm_message_handler_new (bytestream_factory_iq_socks5_cb,
- self, NULL);
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->iq_socks5_cb, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
-
/* Track SOCKS5 proxy available on the connection */
gabble_signal_connect_weak (priv->conn->disco, "item-found",
G_CALLBACK (disco_item_found_cb), G_OBJECT (self));
gabble_signal_connect_weak (priv->conn, "status-changed",
G_CALLBACK (conn_status_changed_cb), G_OBJECT (self));
+ tp_g_signal_connect_object (priv->conn, "porter-available",
+ G_CALLBACK (porter_available_cb), self, 0);
return obj;
}
@@ -664,21 +681,15 @@ gabble_bytestream_factory_dispose (GObject *object)
DEBUG ("dispose called");
priv->dispose_has_run = TRUE;
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->msg_data_cb, LM_MESSAGE_TYPE_MESSAGE);
- lm_message_handler_unref (priv->msg_data_cb);
-
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->iq_si_cb, LM_MESSAGE_TYPE_IQ);
- lm_message_handler_unref (priv->iq_si_cb);
-
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->iq_ibb_cb, LM_MESSAGE_TYPE_IQ);
- lm_message_handler_unref (priv->iq_ibb_cb);
+ if (priv->msg_data_cb != 0)
+ {
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->iq_socks5_cb, LM_MESSAGE_TYPE_IQ);
- lm_message_handler_unref (priv->iq_socks5_cb);
+ wocky_porter_unregister_handler (porter, priv->msg_data_cb);
+ wocky_porter_unregister_handler (porter, priv->iq_si_cb);
+ wocky_porter_unregister_handler (porter, priv->iq_ibb_cb);
+ wocky_porter_unregister_handler (porter, priv->iq_socks5_cb);
+ }
g_hash_table_unref (priv->ibb_bytestreams);
priv->ibb_bytestreams = NULL;
@@ -832,8 +843,8 @@ remove_bytestream (GabbleBytestreamFactory *self,
* message.
*/
static gboolean
-streaminit_parse_request (LmMessage *message,
- LmMessageNode *si,
+streaminit_parse_request (WockyStanza *message,
+ WockyNode *si,
const gchar **profile,
const gchar **from,
const gchar **stream_id,
@@ -842,13 +853,13 @@ streaminit_parse_request (LmMessage *message,
GSList **stream_methods,
gboolean *multiple)
{
- LmMessageNode *iq = wocky_stanza_get_top_node (message);
- LmMessageNode *feature, *x, *si_multiple;
- NodeIter i, j;
+ WockyNode *iq = wocky_stanza_get_top_node (message);
+ WockyNode *feature, *x, *si_multiple, *field;
+ WockyNodeIter i, j;
- *stream_init_id = lm_message_node_get_attribute (iq, "id");
+ *stream_init_id = wocky_node_get_attribute (iq, "id");
- *from = lm_message_node_get_attribute (iq, "from");
+ *from = wocky_node_get_attribute (iq, "from");
if (*from == NULL)
{
STANZA_DEBUG (message, "got a message without a from field");
@@ -857,18 +868,18 @@ streaminit_parse_request (LmMessage *message,
/* Parse <si> */
- *stream_id = lm_message_node_get_attribute (si, "id");
+ *stream_id = wocky_node_get_attribute (si, "id");
if (*stream_id == NULL)
{
STANZA_DEBUG (message, "got a SI request without a stream id field");
return FALSE;
}
- *mime_type = lm_message_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 "binary/octect-stream"
* which is presumably a typo for "application/octet-stream" */
- *profile = lm_message_node_get_attribute (si, "profile");
+ *profile = wocky_node_get_attribute (si, "profile");
if (*profile == NULL)
{
STANZA_DEBUG (message, "got a SI request without a profile field");
@@ -876,7 +887,7 @@ streaminit_parse_request (LmMessage *message,
}
/* Parse <feature> */
- feature = lm_message_node_get_child_with_namespace (si, "feature",
+ feature = wocky_node_get_child_ns (si, "feature",
NS_FEATURENEG);
if (feature == NULL)
{
@@ -884,23 +895,24 @@ streaminit_parse_request (LmMessage *message,
return FALSE;
}
- x = lm_message_node_get_child_with_namespace (feature, "x", NS_X_DATA);
+ x = wocky_node_get_child_ns (feature, "x", NS_X_DATA);
if (x == NULL)
{
STANZA_DEBUG (message, "got a SI request without a X data field");
return FALSE;
}
- for (i = node_iter (x); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, x, NULL, NULL);
+ while (wocky_node_iter_next (&i, &field))
{
- LmMessageNode *field = node_iter_data (i);
+ WockyNode *stream_method;
- if (tp_strdiff (lm_message_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 (lm_message_node_get_attribute (field, "type"),
+ if (tp_strdiff (wocky_node_get_attribute (field, "type"),
"list-single"))
{
STANZA_DEBUG (message, "SI request's stream-method field was "
@@ -910,17 +922,17 @@ streaminit_parse_request (LmMessage *message,
/* Get the stream methods offered */
*stream_methods = NULL;
- for (j = node_iter (field); j; j = node_iter_next (j))
+ wocky_node_iter_init (&j, field, NULL, NULL);
+ while (wocky_node_iter_next (&j, &stream_method))
{
- LmMessageNode *stream_method = node_iter_data (j);
- LmMessageNode *value;
+ WockyNode *value;
const gchar *stream_method_str;
- value = lm_message_node_get_child (stream_method, "value");
+ value = wocky_node_get_child (stream_method, "value");
if (value == NULL)
continue;
- stream_method_str = lm_message_node_get_value (value);
+ stream_method_str = value->content;
if (!tp_strdiff (stream_method_str, ""))
continue;
@@ -943,8 +955,7 @@ streaminit_parse_request (LmMessage *message,
return FALSE;
}
- si_multiple = lm_message_node_get_child_with_namespace (si, "si-multiple",
- NS_SI_MULTIPLE);
+ si_multiple = wocky_node_get_child_ns (si, "si-multiple", NS_SI_MULTIPLE);
if (si_multiple == NULL)
*multiple = FALSE;
else
@@ -965,38 +976,38 @@ streaminit_parse_request (LmMessage *message,
* The MIME type is not set - the receiving client will assume
* application/octet-stream unless the caller sets a MIME type explicitly.
*/
-LmMessage *
+WockyStanza *
gabble_bytestream_factory_make_stream_init_iq (const gchar *full_jid,
const gchar *stream_id,
const gchar *profile)
{
- return lm_message_build (full_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "si", "",
- '@', "xmlns", NS_SI,
+ return wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, full_jid,
+ '(', "si",
+ ':', NS_SI,
'@', "id", stream_id,
'@', "profile", profile,
- '(', "feature", "",
- '@', "xmlns", NS_FEATURENEG,
- '(', "x", "",
- '@', "xmlns", NS_X_DATA,
+ '(', "feature",
+ ':', NS_FEATURENEG,
+ '(', "x",
+ ':', NS_X_DATA,
'@', "type", "form",
- '(', "field", "",
+ '(', "field",
'@', "var", "stream-method",
'@', "type", "list-single",
- '(', "option", "",
- '(', "value", NS_BYTESTREAMS,
+ '(', "option",
+ '(', "value", '$', NS_BYTESTREAMS,
')',
')',
- '(', "option", "",
- '(', "value", NS_IBB,
+ '(', "option",
+ '(', "value", '$', NS_IBB,
')',
')',
')',
')',
')',
- '(', "si-multiple", "",
- '@', "xmlns", NS_SI_MULTIPLE,
+ '(', "si-multiple",
+ ':', NS_SI_MULTIPLE,
')',
')', NULL);
}
@@ -1033,8 +1044,8 @@ static GabbleBytestreamSocks5 *gabble_bytestream_factory_create_socks5 (
static void
si_tube_received (GabbleBytestreamFactory *self,
- LmMessage *msg,
- LmMessageNode *si,
+ WockyStanza *msg,
+ WockyNode *si,
GabbleBytestreamIface *bytestream,
TpHandle peer_handle,
TpHandle room_handle,
@@ -1048,14 +1059,14 @@ si_tube_received (GabbleBytestreamFactory *self,
* - a 1-1 tube extra bytestream offer
* - a muc tube extra bytestream offer
*/
- if (lm_message_node_get_child_with_namespace (si, "tube", NS_TUBES) != NULL)
+ if (wocky_node_get_child_ns (si, "tube", NS_TUBES) != NULL)
{
/* The SI request is a tube offer */
gabble_private_tubes_factory_handle_si_tube_request (
priv->conn->private_tubes_factory, bytestream, peer_handle,
stream_id, msg);
}
- else if (lm_message_node_get_child_with_namespace (si, "stream", NS_TUBES)
+ else if (wocky_node_get_child_ns (si, "stream", NS_TUBES)
!= NULL)
{
/* The SI request is an extra bytestream for a 1-1 tube */
@@ -1063,14 +1074,14 @@ si_tube_received (GabbleBytestreamFactory *self,
priv->conn->private_tubes_factory, bytestream, peer_handle,
stream_id, msg);
}
- else if (lm_message_node_get_child_with_namespace (si, "muc-stream",
+ else if (wocky_node_get_child_ns (si, "muc-stream",
NS_TUBES) != NULL)
{
/* The SI request is an extra bytestream for a muc tube */
if (room_handle == 0)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"<muc-stream> is only valid in a MUC context" };
gabble_bytestream_iface_close (bytestream, &e);
@@ -1083,7 +1094,7 @@ si_tube_received (GabbleBytestreamFactory *self,
}
else
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"Invalid tube SI request: expected <tube>, <stream> or "
"<muc-stream>" };
@@ -1096,15 +1107,15 @@ si_tube_received (GabbleBytestreamFactory *self,
/**
* bytestream_factory_iq_si_cb:
*
- * Called by loudmouth when we get an incoming <iq>. This handler is concerned
+ * Called by Wocky when we get an incoming <iq>. This handler is concerned
* with Stream Initiation requests (XEP-0095).
*
*/
-static LmHandlerResult
-bytestream_factory_iq_si_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *msg,
- gpointer user_data)
+static gboolean
+bytestream_factory_iq_si_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data)
{
GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
GabbleBytestreamFactoryPrivate *priv =
@@ -1113,7 +1124,7 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_ROOM);
- LmMessageNode *si;
+ WockyNode *si;
TpHandle peer_handle = 0, room_handle;
GabbleBytestreamIface *bytestream = NULL;
GSList *l;
@@ -1123,13 +1134,9 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
gchar *peer_resource = NULL;
gchar *self_jid = NULL;
- if (lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_SET)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-
- si = lm_message_node_get_child_with_namespace (
+ si = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
- if (si == NULL)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ g_return_val_if_fail (si != NULL, FALSE);
/* after this point, the message is for us, so in all cases we either handle
* it or send an error reply */
@@ -1137,8 +1144,8 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
if (!streaminit_parse_request (msg, si, &profile, &from, &stream_id,
&stream_init_id, &mime_type, &stream_methods, &multiple))
{
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "failed to parse SI request");
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, "failed to parse SI request");
goto out;
}
@@ -1166,7 +1173,7 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
peer_handle = tp_handle_ensure (contact_repo, from, NULL, NULL);
/* we are not in a muc so our own jid is the one in the 'to' attribute */
- self_jid = g_strdup (lm_message_node_get_attribute (
+ self_jid = g_strdup (wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "to"));
}
else
@@ -1191,8 +1198,8 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
if (peer_handle == 0)
{
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_JID_MALFORMED, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_JID_MALFORMED, NULL);
goto out;
}
@@ -1242,10 +1249,10 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
if (bytestream == NULL)
{
- DEBUG ("SI request doesn't contain any supported stream methods.");
+ GError error = { WOCKY_SI_ERROR, WOCKY_SI_ERROR_NO_VALID_STREAMS, "" };
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_SI_NO_VALID_STREAMS, NULL);
+ DEBUG ("SI request doesn't contain any supported stream methods.");
+ wocky_porter_send_iq_gerror (porter, msg, &error);
goto out;
}
@@ -1255,7 +1262,7 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
if (!gabble_bytestream_multiple_has_stream_method (
GABBLE_BYTESTREAM_MULTIPLE (bytestream)))
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_SI_NO_VALID_STREAMS, "" };
+ GError e = { WOCKY_SI_ERROR, WOCKY_SI_ERROR_NO_VALID_STREAMS, "" };
DEBUG ("No valid stream method in the multi bytestream. Closing");
gabble_bytestream_iface_close (bytestream, &e);
@@ -1281,7 +1288,7 @@ bytestream_factory_iq_si_cb (LmMessageHandler *handler,
#endif
else
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_SI_BAD_PROFILE, "" };
+ GError e = { WOCKY_SI_ERROR, WOCKY_SI_ERROR_BAD_PROFILE, "" };
DEBUG ("SI profile unsupported: %s", profile);
gabble_bytestream_iface_close (bytestream, &e);
@@ -1294,45 +1301,48 @@ out:
if (peer_handle != 0)
tp_handle_unref (contact_repo, peer_handle);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
static gboolean
handle_ibb_open_iq (GabbleBytestreamFactory *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleBytestreamFactoryPrivate *priv =
GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
GabbleBytestreamIBB *bytestream;
- LmMessageNode *open_node;
+ WockyNode *open_node;
ConstBytestreamIdentifier bsid = { NULL, NULL };
const gchar *tmp;
guint state;
+ WockyStanzaSubType sub_type;
- if (lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_SET)
+ wocky_stanza_get_type_info (msg, NULL, &sub_type);
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- open_node = lm_message_node_get_child_with_namespace (
+ open_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "open", NS_IBB);
if (open_node == NULL)
return FALSE;
- bsid.jid = lm_message_node_get_attribute (
+ bsid.jid = wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "from");
if (bsid.jid == NULL)
{
DEBUG ("got a message without a from field");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, NULL);
return TRUE;
}
- bsid.stream = lm_message_node_get_attribute (open_node, "sid");
+ bsid.stream = wocky_node_get_attribute (open_node, "sid");
if (bsid.stream == NULL)
{
DEBUG ("IBB open stanza doesn't contain stream id");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, NULL);
return TRUE;
}
@@ -1341,8 +1351,8 @@ handle_ibb_open_iq (GabbleBytestreamFactory *self,
{
/* We don't accept streams not previously announced using SI */
DEBUG ("unknown stream: <%s> from <%s>", bsid.stream, bsid.jid);
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, NULL);
return TRUE;
}
@@ -1352,12 +1362,12 @@ handle_ibb_open_iq (GabbleBytestreamFactory *self,
{
/* We don't accept streams not previously accepted using SI */
DEBUG ("unaccepted stream: <%s> from <%s>", bsid.stream, bsid.jid);
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, NULL);
return TRUE;
}
- tmp = lm_message_node_get_attribute (open_node, "block-size");
+ tmp = wocky_node_get_attribute (open_node, "block-size");
if (tmp != NULL)
{
guint block_size = strtoul (tmp, NULL, 10);
@@ -1369,45 +1379,48 @@ handle_ibb_open_iq (GabbleBytestreamFactory *self,
g_object_set (bytestream, "state", GABBLE_BYTESTREAM_STATE_OPEN,
NULL);
- _gabble_connection_acknowledge_set_iq (priv->conn, msg);
+ wocky_porter_acknowledge_iq (porter, msg, NULL);
return TRUE;
}
static gboolean
handle_ibb_close_iq (GabbleBytestreamFactory *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleBytestreamFactoryPrivate *priv =
GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
ConstBytestreamIdentifier bsid = { NULL, NULL };
GabbleBytestreamIBB *bytestream;
- LmMessageNode *close_node;
+ WockyNode *close_node;
+ WockyStanzaSubType sub_type;
- if (lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_SET)
+ wocky_stanza_get_type_info (msg, NULL, &sub_type);
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- close_node = lm_message_node_get_child_with_namespace (
+ close_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "close", NS_IBB);
if (close_node == NULL)
return FALSE;
- bsid.jid = lm_message_node_get_attribute (wocky_stanza_get_top_node (msg),
+ bsid.jid = wocky_node_get_attribute (wocky_stanza_get_top_node (msg),
"from");
if (bsid.jid == NULL)
{
DEBUG ("got a message without a from field");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB <close> has no 'from' attribute");
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, "IBB <close> has no 'from' attribute");
return TRUE;
}
- bsid.stream = lm_message_node_get_attribute (close_node, "sid");
+ bsid.stream = wocky_node_get_attribute (close_node, "sid");
if (bsid.stream == NULL)
{
DEBUG ("IBB close stanza doesn't contain stream id");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB <close> has no stream ID");
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, "IBB <close> has no stream ID");
return TRUE;
}
@@ -1415,8 +1428,8 @@ handle_ibb_close_iq (GabbleBytestreamFactory *self,
if (bytestream == NULL)
{
DEBUG ("unknown stream: <%s> from <%s>", bsid.stream, bsid.jid);
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_ITEM_NOT_FOUND, NULL);
+ wocky_porter_send_iq_error (porter, msg,
+ WOCKY_XMPP_ERROR_ITEM_NOT_FOUND, NULL);
}
else
{
@@ -1432,43 +1445,46 @@ handle_ibb_close_iq (GabbleBytestreamFactory *self,
* Return TRUE if we take responsibility for this message. */
static gboolean
handle_ibb_data (GabbleBytestreamFactory *self,
- LmMessage *msg,
+ WockyStanza *msg,
gboolean is_iq)
{
GabbleBytestreamFactoryPrivate *priv =
GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
GabbleBytestreamIBB *bytestream = NULL;
- LmMessageNode *data;
+ WockyNode *data;
ConstBytestreamIdentifier bsid = { NULL, NULL };
+ WockyStanzaSubType sub_type;
priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
- if (is_iq && lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_SET)
+ wocky_stanza_get_type_info (msg, NULL, &sub_type);
+ if (is_iq && sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return FALSE;
- data = lm_message_node_get_child_with_namespace (
+ data = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "data", NS_IBB);
if (data == NULL)
return FALSE;
- bsid.jid = lm_message_node_get_attribute (wocky_stanza_get_top_node (msg),
+ bsid.jid = wocky_node_get_attribute (wocky_stanza_get_top_node (msg),
"from");
if (bsid.jid == NULL)
{
DEBUG ("got a message without a from field");
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB <close> has no 'from' attribute");
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "IBB <close> has no 'from' attribute");
return TRUE;
}
- bsid.stream = lm_message_node_get_attribute (data, "sid");
+ bsid.stream = wocky_node_get_attribute (data, "sid");
if (bsid.stream == NULL)
{
DEBUG ("got a IBB message data without a stream id field");
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB <data> needs a stream ID");
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "IBB <data> needs a stream ID");
return TRUE;
}
@@ -1478,8 +1494,8 @@ handle_ibb_data (GabbleBytestreamFactory *self,
{
DEBUG ("unknown stream: <%s> from <%s>", bsid.stream, bsid.jid);
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB <data> has unknown stream ID");
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "IBB <data> has unknown stream ID");
return TRUE;
}
@@ -1491,24 +1507,24 @@ handle_ibb_data (GabbleBytestreamFactory *self,
static gboolean
handle_muc_data (GabbleBytestreamFactory *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleBytestreamFactoryPrivate *priv =
GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
GabbleBytestreamMuc *bytestream = NULL;
- LmMessageNode *data;
+ WockyNode *data;
ConstBytestreamIdentifier bsid = { NULL, NULL };
gchar *room_name;
const gchar *from;
priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
- data = lm_message_node_get_child_with_namespace (
+ data = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "data", NS_MUC_BYTESTREAM);
if (data == NULL)
return FALSE;
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "from");
if (from == NULL)
{
@@ -1516,7 +1532,7 @@ handle_muc_data (GabbleBytestreamFactory *self,
return TRUE;
}
- bsid.stream = lm_message_node_get_attribute (data, "sid");
+ bsid.stream = wocky_node_get_attribute (data, "sid");
if (bsid.stream == NULL)
{
DEBUG ("got a pseudo IBB muc message data without a stream id field");
@@ -1544,89 +1560,87 @@ handle_muc_data (GabbleBytestreamFactory *self,
/**
* bytestream_factory_iq_ibb_cb:
*
- * Called by loudmouth when we get an incoming <iq>.
+ * Called by Wocky when we get an incoming <iq>.
* This handler is concerned with IBB iq's.
*
*/
-static LmHandlerResult
-bytestream_factory_iq_ibb_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *msg,
- gpointer user_data)
+static gboolean
+bytestream_factory_iq_ibb_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data)
{
GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
if (handle_ibb_open_iq (self, msg))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (handle_ibb_close_iq (self, msg))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (handle_ibb_data (self, msg, TRUE))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
/**
* bytestream_factory_msg_data_cb
*
- * Called by loudmouth when we get an incoming <message>.
+ * Called by Wocky when we get an incoming <message>.
* This handler handles IBB data and pseudo IBB Muc data.
*/
-static LmHandlerResult
-bytestream_factory_msg_data_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *msg,
- gpointer user_data)
+static gboolean
+bytestream_factory_msg_data_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data)
{
GabbleBytestreamFactory *self = user_data;
if (handle_ibb_data (self, msg, FALSE))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (handle_muc_data (self, msg))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
static gboolean
-handle_socks5_query_iq (GabbleBytestreamFactory *self,
- LmMessage *msg)
+handle_socks5_query_iq (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data)
{
- GabbleBytestreamFactoryPrivate *priv =
- GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+ GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
+ GabbleBytestreamFactoryPrivate *priv = self->priv;
GabbleBytestreamSocks5 *bytestream;
- LmMessageNode *query_node;
+ WockyNode *query_node, *child_node;
ConstBytestreamIdentifier bsid = { NULL, NULL };
const gchar *tmp;
- NodeIter i;
-
- if (lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_SET)
- return FALSE;
+ WockyNodeIter i;
- query_node = lm_message_node_get_child_with_namespace (
+ query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "query", NS_BYTESTREAMS);
- if (query_node == NULL)
- return FALSE;
+ g_return_val_if_fail (query_node != NULL, FALSE);
- bsid.jid = lm_message_node_get_attribute (
+ bsid.jid = wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "from");
if (bsid.jid == NULL)
{
DEBUG ("got a message without a from field");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "SOCKS5 <query> has no 'from' attribute");
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "SOCKS5 <query> has no 'from' attribute");
return TRUE;
}
- bsid.stream = lm_message_node_get_attribute (query_node, "sid");
+ bsid.stream = wocky_node_get_attribute (query_node, "sid");
if (bsid.stream == NULL)
{
DEBUG ("SOCKS5 query stanza doesn't contain stream id");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "SOCKS5 <query> has no stream ID");
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "SOCKS5 <query> has no stream ID");
return TRUE;
}
@@ -1635,29 +1649,25 @@ handle_socks5_query_iq (GabbleBytestreamFactory *self,
{
/* We don't accept streams not previously announced using SI */
DEBUG ("unknown stream: <%s> from <%s>", bsid.stream, bsid.jid);
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_ITEM_NOT_FOUND,
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_ITEM_NOT_FOUND,
"SOCKS5 <query> has an unknown stream ID");
return TRUE;
}
- tmp = lm_message_node_get_attribute (query_node, "mode");
+ tmp = wocky_node_get_attribute (query_node, "mode");
/* If this attribute is missing, the default value of "tcp" MUST be assumed */
if (tmp != NULL && tp_strdiff (tmp, "tcp"))
{
DEBUG ("non-TCP SOCKS5 bytestreams are not supported");
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST,
+ wocky_porter_send_iq_error (porter, msg, WOCKY_XMPP_ERROR_BAD_REQUEST,
"SOCKS5 non-TCP bytestreams are not supported");
return TRUE;
}
- for (i = node_iter (query_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, query_node, "streamhost", NULL);
+ while (wocky_node_iter_next (&i, &child_node))
{
- LmMessageNode *child_node = node_iter_data (i);
-
- if (!tp_strdiff (child_node->name, "streamhost"))
- gabble_bytestream_socks5_add_streamhost (bytestream, child_node);
+ gabble_bytestream_socks5_add_streamhost (bytestream, child_node);
}
gabble_bytestream_socks5_connect_to_streamhost (bytestream, msg);
@@ -1665,27 +1675,6 @@ handle_socks5_query_iq (GabbleBytestreamFactory *self,
return TRUE;
}
-/**
- * bytestream_factory_iq_socks5_cb:
- *
- * Called by loudmouth when we get an incoming <iq>.
- * This handler is concerned with SOCKS5 iq's.
- *
- */
-static LmHandlerResult
-bytestream_factory_iq_socks5_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *msg,
- gpointer user_data)
-{
- GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
-
- if (handle_socks5_query_iq (self, msg))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-}
-
GabbleBytestreamFactory *
gabble_bytestream_factory_new (GabbleConnection *conn)
{
@@ -1897,8 +1886,8 @@ gabble_bytestream_factory_create_multiple (GabbleBytestreamFactory *self,
static GabbleBytestreamIface *
streaminit_get_multiple_bytestream (GabbleBytestreamFactory *self,
- LmMessage *reply_msg,
- LmMessageNode *si,
+ WockyStanza *reply_msg,
+ WockyNode *si,
const gchar *stream_id,
TpHandle peer_handle,
const gchar *peer_resource,
@@ -1906,12 +1895,13 @@ streaminit_get_multiple_bytestream (GabbleBytestreamFactory *self,
{
/* If the other client supports si-multiple we have directly a list of
* supported methods inside <value/> tags */
- LmMessageNode *si_multi;
+ WockyNode *si_multi;
const gchar *stream_method;
GabbleBytestreamMultiple *bytestream = NULL;
- NodeIter i;
+ WockyNode *value;
+ WockyNodeIter i;
- si_multi = lm_message_node_get_child_with_namespace (si, "si-multiple",
+ si_multi = wocky_node_get_child_ns (si, "si-multiple",
NS_SI_MULTIPLE);
if (si_multi == NULL)
return NULL;
@@ -1920,14 +1910,10 @@ streaminit_get_multiple_bytestream (GabbleBytestreamFactory *self,
stream_id, NULL, peer_resource, self_jid,
GABBLE_BYTESTREAM_STATE_INITIATING);
- for (i = node_iter (si_multi); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, si_multi, "value", NULL);
+ while (wocky_node_iter_next (&i, &value))
{
- LmMessageNode *value = node_iter_data (i);
-
- if (tp_strdiff (value->name, "value"))
- continue;
-
- stream_method = lm_message_node_get_value (value);
+ stream_method = value->content;
if (!stream_method_supported (stream_method))
{
DEBUG ("got a si-multiple reply with an unsupported "
@@ -1943,19 +1929,19 @@ streaminit_get_multiple_bytestream (GabbleBytestreamFactory *self,
static GabbleBytestreamIface *
streaminit_get_bytestream (GabbleBytestreamFactory *self,
- LmMessage *reply_msg,
- LmMessageNode *si,
+ WockyStanza *reply_msg,
+ WockyNode *si,
const gchar *stream_id,
TpHandle peer_handle,
const gchar *peer_resource,
const gchar *self_jid)
{
- LmMessageNode *feature, *x, *value;
+ WockyNode *feature, *x, *value, *field;
GabbleBytestreamIface *bytestream = NULL;
const gchar *stream_method;
- NodeIter i;
+ WockyNodeIter i;
- feature = lm_message_node_get_child_with_namespace (si, "feature",
+ feature = wocky_node_get_child_ns (si, "feature",
NS_FEATURENEG);
if (feature == NULL)
{
@@ -1963,23 +1949,22 @@ streaminit_get_bytestream (GabbleBytestreamFactory *self,
return NULL;
}
- x = lm_message_node_get_child_with_namespace (feature, "x", NS_X_DATA);
+ x = wocky_node_get_child_ns (feature, "x", NS_X_DATA);
if (x == NULL)
{
STANZA_DEBUG (reply_msg, "got a SI reply without a x field");
return NULL;
}
- for (i = node_iter (x); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, x, NULL, NULL);
+ while (wocky_node_iter_next (&i, &field))
{
- LmMessageNode *field = node_iter_data (i);
-
- if (tp_strdiff (lm_message_node_get_attribute (field, "var"),
+ if (tp_strdiff (wocky_node_get_attribute (field, "var"),
"stream-method"))
/* some future field, ignore it */
continue;
- value = lm_message_node_get_child (field, "value");
+ value = wocky_node_get_child (field, "value");
if (value == NULL)
{
STANZA_DEBUG (reply_msg, "SI reply's stream-method field "
@@ -1987,7 +1972,7 @@ streaminit_get_bytestream (GabbleBytestreamFactory *self,
return NULL;
}
- stream_method = lm_message_node_get_value (value);
+ stream_method = value->content;
bytestream = gabble_bytestream_factory_create_from_method (self,
stream_method, peer_handle, stream_id, NULL, peer_resource, self_jid,
GABBLE_BYTESTREAM_STATE_INITIATING);
@@ -2021,10 +2006,10 @@ negotiate_stream_object_destroy_notify_cb (gpointer _data,
}
/* Called when we receive the reply of a SI request */
-static LmHandlerResult
+static void
streaminit_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
@@ -2035,7 +2020,7 @@ streaminit_reply_cb (GabbleConnection *conn,
(struct _streaminit_reply_cb_data*) user_data;
GabbleBytestreamIface *bytestream = NULL;
gchar *peer_resource = NULL;
- LmMessageNode *si;
+ WockyNode *si;
const gchar *from;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
@@ -2058,7 +2043,7 @@ streaminit_reply_cb (GabbleConnection *conn,
goto END;
}
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
{
DEBUG ("stream %s declined", data->stream_id);
goto END;
@@ -2066,7 +2051,7 @@ streaminit_reply_cb (GabbleConnection *conn,
/* stream accepted */
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "from");
if (from == NULL)
{
@@ -2094,7 +2079,7 @@ streaminit_reply_cb (GabbleConnection *conn,
}
/* we are not in a muc so our own jid is the one in the 'to' attribute */
- self_jid = g_strdup (lm_message_node_get_attribute (
+ self_jid = g_strdup (wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "to"));
}
else
@@ -2114,7 +2099,7 @@ streaminit_reply_cb (GabbleConnection *conn,
g_object_get (muc, "self-jid", &self_jid, NULL);
}
- si = lm_message_node_get_child_with_namespace (
+ si = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "si", NS_SI);
if (si == NULL)
{
@@ -2167,8 +2152,6 @@ END:
g_free (self_jid);
g_free (data->stream_id);
g_slice_free (struct _streaminit_reply_cb_data, data);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
/*
@@ -2187,7 +2170,7 @@ END:
*/
gboolean
gabble_bytestream_factory_negotiate_stream (GabbleBytestreamFactory *self,
- LmMessage *msg,
+ WockyStanza *msg,
const gchar *stream_id,
GabbleBytestreamFactoryNegotiateReplyFunc func,
gpointer user_data,
@@ -2241,24 +2224,24 @@ gabble_bytestream_factory_negotiate_stream (GabbleBytestreamFactory *self,
* a SI request (XEP-0095).
*
*/
-LmMessage *
+WockyStanza *
gabble_bytestream_factory_make_accept_iq (const gchar *full_jid,
const gchar *stream_init_id,
const gchar *stream_method)
{
- return lm_message_build (full_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "result",
+ return wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_RESULT,
+ NULL, full_jid,
'@', "id", stream_init_id,
- '(', "si", "",
- '@', "xmlns", NS_SI,
- '(', "feature", "",
- '@', "xmlns", NS_FEATURENEG,
- '(', "x", "",
- '@', "xmlns", NS_X_DATA,
+ '(', "si",
+ ':', NS_SI,
+ '(', "feature",
+ ':', NS_FEATURENEG,
+ '(', "x",
+ ':', NS_X_DATA,
'@', "type", "submit",
- '(', "field", "",
+ '(', "field",
'@', "var", "stream-method",
- '(', "value", stream_method, ')',
+ '(', "value", '$', stream_method, ')',
')',
')',
')',
@@ -2276,29 +2259,29 @@ gabble_bytestream_factory_make_accept_iq (const gchar *full_jid,
* a si-multiple SI request.
*
*/
-LmMessage *
+WockyStanza *
gabble_bytestream_factory_make_multi_accept_iq (const gchar *full_jid,
const gchar *stream_init_id,
GList *stream_methods)
{
- LmMessage *msg;
- LmMessageNode *multi_node;
+ WockyStanza *msg;
+ WockyNode *multi_node;
GList *l;
- msg = lm_message_build (full_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "result",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_RESULT,
+ NULL, full_jid,
'@', "id", stream_init_id,
- '(', "si", "",
- '@', "xmlns", NS_SI,
- '(', "si-multiple", "",
- '@', "xmlns", NS_SI_MULTIPLE,
+ '(', "si",
+ ':', NS_SI,
+ '(', "si-multiple",
+ ':', NS_SI_MULTIPLE,
'*', &multi_node,
')',
')', NULL);
for (l = stream_methods; l != NULL; l = l->next)
{
- lm_message_node_add_child (multi_node, "value", l->data);
+ wocky_node_add_child_with_content (multi_node, "value", l->data);
}
return msg;
diff --git a/src/bytestream-factory.h b/src/bytestream-factory.h
index 4c84a33c2..7a86cd4f8 100644
--- a/src/bytestream-factory.h
+++ b/src/bytestream-factory.h
@@ -21,8 +21,6 @@
#define __BYTESTREAM_FACTORY_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
#include <telepathy-glib/base-connection.h>
#include "types.h"
#include "bytestream-iface.h"
@@ -73,7 +71,7 @@ typedef struct {
} GabbleSocks5Proxy;
typedef void (* GabbleBytestreamFactoryNegotiateReplyFunc) (
- GabbleBytestreamIface *bytestream, const gchar *stream_id, LmMessage *msg,
+ GabbleBytestreamIface *bytestream, const gchar *stream_id, WockyStanza *msg,
GObject *object, gpointer user_data);
GabbleBytestreamFactory *gabble_bytestream_factory_new (
@@ -89,18 +87,18 @@ GabbleBytestreamIface *gabble_bytestream_factory_create_from_method (
const gchar *peer_resource, const gchar *self_jid,
GabbleBytestreamState state);
-LmMessage *gabble_bytestream_factory_make_stream_init_iq (
+WockyStanza *gabble_bytestream_factory_make_stream_init_iq (
const gchar *full_jid, const gchar *stream_id, const gchar *profile);
-LmMessage *gabble_bytestream_factory_make_accept_iq (const gchar *full_jid,
+WockyStanza *gabble_bytestream_factory_make_accept_iq (const gchar *full_jid,
const gchar *stream_init_id, const gchar *stream_method);
-LmMessage *gabble_bytestream_factory_make_multi_accept_iq (
+WockyStanza *gabble_bytestream_factory_make_multi_accept_iq (
const gchar *full_jid, const gchar *stream_init_id,
GList *stream_methods);
gboolean gabble_bytestream_factory_negotiate_stream (
- GabbleBytestreamFactory *fac, LmMessage *msg, const gchar *stream_id,
+ GabbleBytestreamFactory *fac, WockyStanza *msg, const gchar *stream_id,
GabbleBytestreamFactoryNegotiateReplyFunc func,
gpointer user_data, GObject *object, GError **error);
diff --git a/src/bytestream-ibb.c b/src/bytestream-ibb.c
index faec02491..e4d66fceb 100644
--- a/src/bytestream-ibb.c
+++ b/src/bytestream-ibb.c
@@ -24,7 +24,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/interfaces.h>
#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
@@ -81,17 +80,17 @@ struct _GabbleBytestreamIBBPrivate
guint16 seq;
guint16 last_seq_recv;
- LmMessage *close_iq_to_ack;
+ WockyStanza *close_iq_to_ack;
/* We can't stop receving IBB data so if user wants to block the bytestream
* we buffer them until he unblocks it. */
gboolean read_blocked;
GString *read_buffer;
- /* list of reffed (LmMessage *) */
+ /* list of reffed (WockyStanza *) */
GSList *received_stanzas_not_acked;
- /* (LmMessage *) -> TRUE
- * We don't keep a ref on the LmMessage as we just use this table to track
+ /* (WockyStanza *) -> TRUE
+ * We don't keep a ref on the WockyStanza as we just use this table to track
* stanzas waiting for reply. The stanza is never used (and so deferenced). */
GHashTable *sent_stanzas_not_acked;
GString *write_buffer;
@@ -142,7 +141,7 @@ gabble_bytestream_ibb_dispose (GObject *object)
if (priv->close_iq_to_ack != NULL)
{
_gabble_connection_acknowledge_set_iq (priv->conn, priv->close_iq_to_ack);
- lm_message_unref (priv->close_iq_to_ack);
+ g_object_unref (priv->close_iq_to_ack);
priv->close_iq_to_ack = NULL;
}
@@ -375,22 +374,22 @@ static void
send_close_stanza (GabbleBytestreamIBB *self)
{
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
- LmMessage *msg;
+ WockyStanza *msg;
if (priv->close_iq_to_ack != NULL)
{
/* We received a close IQ and just need to ACK it */
_gabble_connection_acknowledge_set_iq (priv->conn, priv->close_iq_to_ack);
- lm_message_unref (priv->close_iq_to_ack);
+ g_object_unref (priv->close_iq_to_ack);
priv->close_iq_to_ack = NULL;
}
DEBUG ("send IBB close stanza");
- msg = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "close", "",
- '@', "xmlns", NS_IBB,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->peer_jid,
+ '(', "close",
+ ':', NS_IBB,
'@', "sid", priv->stream_id,
')', NULL);
@@ -399,17 +398,17 @@ send_close_stanza (GabbleBytestreamIBB *self)
_gabble_connection_send_with_reply (priv->conn, msg,
NULL, NULL, NULL, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static gboolean
send_data (GabbleBytestreamIBB *self, const gchar *str, guint len,
gboolean *result);
-static LmHandlerResult
+static void
iq_acked_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
@@ -451,8 +450,6 @@ iq_acked_cb (GabbleConnection *conn,
priv->write_buffer->len);
}
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -468,7 +465,7 @@ send_data (GabbleBytestreamIBB *self,
stanza_count = 0;
while (sent < len)
{
- LmMessage *iq;
+ WockyStanza *iq;
guint send_now, remaining;
gchar *seq, *encoded;
GError *error = NULL;
@@ -500,10 +497,11 @@ send_data (GabbleBytestreamIBB *self,
encoded = base64_encode (send_now, str + sent, FALSE);
seq = g_strdup_printf ("%u", priv->seq++);
- iq = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "data", encoded,
- '@', "xmlns", NS_IBB,
+ iq = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->peer_jid,
+ '(', "data",
+ '$', encoded,
+ ':', NS_IBB,
'@', "sid", priv->stream_id,
'@', "seq", seq,
')', NULL);
@@ -513,7 +511,7 @@ send_data (GabbleBytestreamIBB *self,
g_free (encoded);
g_free (seq);
- lm_message_unref (iq);
+ g_object_unref (iq);
if (!ret)
{
@@ -609,17 +607,17 @@ gabble_bytestream_ibb_send (GabbleBytestreamIface *iface,
void
gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self,
- LmMessage *msg,
+ WockyStanza *msg,
gboolean is_iq)
{
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
- LmMessageNode *data;
+ WockyNode *data;
GString *str;
TpHandle sender;
/* caller must have checked for this in order to know which bytestream to
* route this packet to */
- data = lm_message_node_get_child_with_namespace (
+ data = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "data", NS_IBB);
g_assert (data != NULL);
@@ -628,8 +626,9 @@ gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self,
DEBUG ("can't receive data through a not open bytestream (state: %d)",
priv->state);
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "IBB bytestream isn't open");
+ wocky_porter_send_iq_error (
+ wocky_session_get_porter (priv->conn->session), msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, "IBB bytestream isn't open");
return;
}
@@ -639,13 +638,14 @@ gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self,
/* FIXME: check sequence number */
- str = base64_decode (lm_message_node_get_value (data));
+ str = base64_decode (data->content);
if (str == NULL)
{
DEBUG ("base64 decoding failed");
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_BAD_REQUEST, "base64 decoding failed");
+ wocky_porter_send_iq_error (
+ wocky_session_get_porter (priv->conn->session), msg,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, "base64 decoding failed");
return;
}
@@ -662,8 +662,9 @@ gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self,
DEBUG ("Buffer is full. Closing the bytestream");
if (is_iq)
- _gabble_connection_send_iq_error (priv->conn, msg,
- XMPP_ERROR_NOT_ACCEPTABLE, "buffer is full");
+ wocky_porter_send_iq_error (
+ wocky_session_get_porter (priv->conn->session), msg,
+ WOCKY_XMPP_ERROR_NOT_ACCEPTABLE, "buffer is full");
gabble_bytestream_iface_close (GABBLE_BYTESTREAM_IFACE (self), NULL);
g_string_free (str, TRUE);
@@ -683,7 +684,7 @@ gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self,
if (is_iq)
{
priv->received_stanzas_not_acked = g_slist_prepend (
- priv->received_stanzas_not_acked, lm_message_ref (msg));
+ priv->received_stanzas_not_acked, g_object_ref (msg));
}
return;
@@ -710,8 +711,8 @@ gabble_bytestream_ibb_accept (GabbleBytestreamIface *iface,
{
GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (iface);
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
- LmMessage *msg;
- LmMessageNode *si;
+ WockyStanza *msg;
+ WockyNode *si;
if (priv->state != GABBLE_BYTESTREAM_STATE_LOCAL_PENDING)
{
@@ -721,7 +722,7 @@ gabble_bytestream_ibb_accept (GabbleBytestreamIface *iface,
msg = gabble_bytestream_factory_make_accept_iq (priv->peer_jid,
priv->stream_init_id, NS_IBB);
- si = lm_message_node_get_child_with_namespace (
+ si = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si != NULL);
@@ -738,7 +739,7 @@ gabble_bytestream_ibb_accept (GabbleBytestreamIface *iface,
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_ACCEPTED, NULL);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static void
@@ -746,30 +747,29 @@ gabble_bytestream_ibb_decline (GabbleBytestreamIBB *self,
GError *error)
{
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
- LmMessage *msg;
+ WockyStanza *msg;
g_return_if_fail (priv->state == GABBLE_BYTESTREAM_STATE_LOCAL_PENDING);
- msg = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "error",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
+ NULL, priv->peer_jid,
'@', "id", priv->stream_init_id,
NULL);
- if (error != NULL && error->domain == GABBLE_XMPP_ERROR)
+ if (error != NULL)
{
- gabble_xmpp_error_to_node (error->code,
- wocky_stanza_get_top_node (msg), error->message);
+ wocky_stanza_error_to_node (error, wocky_stanza_get_top_node (msg));
}
else
{
- gabble_xmpp_error_to_node (XMPP_ERROR_FORBIDDEN,
- wocky_stanza_get_top_node (msg),
- "Offer Declined");
+ GError fallback = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_FORBIDDEN,
+ "Offer Declined" };
+ wocky_stanza_error_to_node (&fallback, wocky_stanza_get_top_node (msg));
}
_gabble_connection_send (priv->conn, msg, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
}
@@ -785,6 +785,7 @@ gabble_bytestream_ibb_close (GabbleBytestreamIface *iface,
{
GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (iface);
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
GSList *l;
if (priv->state == GABBLE_BYTESTREAM_STATE_CLOSED)
@@ -795,16 +796,9 @@ gabble_bytestream_ibb_close (GabbleBytestreamIface *iface,
priv->received_stanzas_not_acked = g_slist_reverse (
priv->received_stanzas_not_acked);
- for (l = priv->received_stanzas_not_acked; l != NULL;
- l = g_slist_next (l))
- {
- LmMessage *iq = (LmMessage *) l->data;
-
- _gabble_connection_send_iq_error (priv->conn, iq,
- XMPP_ERROR_ITEM_NOT_FOUND, NULL);
-
- lm_message_unref (iq);
- }
+ for (l = priv->received_stanzas_not_acked; l != NULL; l = g_slist_next (l))
+ wocky_porter_send_iq_error (porter, l->data,
+ WOCKY_XMPP_ERROR_ITEM_NOT_FOUND, NULL);
g_slist_free (priv->received_stanzas_not_acked);
priv->received_stanzas_not_acked = NULL;
@@ -829,16 +823,17 @@ gabble_bytestream_ibb_close (GabbleBytestreamIface *iface,
}
}
-static LmHandlerResult
+static void
ibb_init_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (obj);
+ GError *error = NULL;
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_RESULT)
+ if (!wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
/* yeah, stream initiated */
DEBUG ("IBB stream initiated");
@@ -846,11 +841,10 @@ ibb_init_reply_cb (GabbleConnection *conn,
}
else
{
- DEBUG ("error during IBB initiation");
+ DEBUG ("error during IBB initiation: %s", error->message);
+ g_clear_error (&error);
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
/*
@@ -863,7 +857,7 @@ gabble_bytestream_ibb_initiate (GabbleBytestreamIface *iface)
{
GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (iface);
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
- LmMessage *msg;
+ WockyStanza *msg;
gchar *block_size;
if (priv->state != GABBLE_BYTESTREAM_STATE_INITIATING)
@@ -874,10 +868,10 @@ gabble_bytestream_ibb_initiate (GabbleBytestreamIface *iface)
}
block_size = g_strdup_printf ("%u", priv->block_size);
- msg = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "open", "",
- '@', "xmlns", NS_IBB,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->peer_jid,
+ '(', "open",
+ ':', NS_IBB,
'@', "sid", priv->stream_id,
'@', "block-size", block_size,
')', NULL);
@@ -888,11 +882,11 @@ gabble_bytestream_ibb_initiate (GabbleBytestreamIface *iface)
{
DEBUG ("Error when sending IBB init stanza");
- lm_message_unref (msg);
+ g_object_unref (msg);
return FALSE;
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return TRUE;
}
@@ -931,11 +925,11 @@ gabble_bytestream_ibb_block_reading (GabbleBytestreamIface *iface,
for (l = priv->received_stanzas_not_acked; l != NULL;
l = g_slist_next (l))
{
- LmMessage *iq = (LmMessage *) l->data;
+ WockyStanza *iq = (WockyStanza *) l->data;
_gabble_connection_acknowledge_set_iq (priv->conn, iq);
- lm_message_unref (iq);
+ g_object_unref (iq);
}
g_slist_free (priv->received_stanzas_not_acked);
@@ -945,13 +939,13 @@ gabble_bytestream_ibb_block_reading (GabbleBytestreamIface *iface,
void
gabble_bytestream_ibb_close_received (GabbleBytestreamIBB *self,
- LmMessage *iq)
+ WockyStanza *iq)
{
GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
DEBUG ("received IBB close stanza. Closing bytestream");
- priv->close_iq_to_ack = lm_message_ref (iq);
+ priv->close_iq_to_ack = g_object_ref (iq);
gabble_bytestream_ibb_close (GABBLE_BYTESTREAM_IFACE (self), NULL);
}
diff --git a/src/bytestream-ibb.h b/src/bytestream-ibb.h
index 5357fa635..fa1af3a2e 100644
--- a/src/bytestream-ibb.h
+++ b/src/bytestream-ibb.h
@@ -21,12 +21,9 @@
#define __GABBLE_BYTESTREAM_IBB_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
+#include <wocky/wocky.h>
#include <telepathy-glib/base-connection.h>
-#include "error.h"
-
G_BEGIN_DECLS
typedef struct _GabbleBytestreamIBB GabbleBytestreamIBB;
@@ -63,10 +60,10 @@ GType gabble_bytestream_ibb_get_type (void);
GabbleBytestreamIBBClass))
void gabble_bytestream_ibb_receive (GabbleBytestreamIBB *ibb,
- LmMessage *msg, gboolean is_iq);
+ WockyStanza *msg, gboolean is_iq);
void gabble_bytestream_ibb_close_received (GabbleBytestreamIBB *ibb,
- LmMessage *iq);
+ WockyStanza *iq);
G_END_DECLS
diff --git a/src/bytestream-iface.h b/src/bytestream-iface.h
index f8802b5b8..6a5323124 100644
--- a/src/bytestream-iface.h
+++ b/src/bytestream-iface.h
@@ -21,7 +21,7 @@
#define __GABBLE_BYTESTREAM_IFACE_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef enum
} GabbleBytestreamState;
typedef void (* GabbleBytestreamAugmentSiAcceptReply) (
- LmMessageNode *si, gpointer user_data);
+ WockyNode *si, gpointer user_data);
typedef struct _GabbleBytestreamIface GabbleBytestreamIface;
typedef struct _GabbleBytestreamIfaceClass GabbleBytestreamIfaceClass;
diff --git a/src/bytestream-muc.c b/src/bytestream-muc.c
index 7511a669a..4a803bc58 100644
--- a/src/bytestream-muc.c
+++ b/src/bytestream-muc.c
@@ -24,7 +24,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/interfaces.h>
#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
@@ -304,34 +303,24 @@ send_data_to (GabbleBytestreamMuc *self,
gchar *encoded;
guint send_now;
GError *error = NULL;
- LmMessage *msg;
- LmMessageNode *data = NULL;
+ WockyStanza *msg;
+ WockyNode *data = NULL;
- msg = lm_message_build (to, LM_MESSAGE_TYPE_MESSAGE,
- '(', "data", "",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, to,
+ '(', "data",
'*', &data,
- '@', "xmlns", NS_MUC_BYTESTREAM,
+ ':', NS_MUC_BYTESTREAM,
'@', "sid", priv->stream_id,
')',
- '(', "amp", "",
- '@', "xmlns", NS_AMP,
- '(', "rule", "",
- '@', "condition", "deliver-at",
- '@', "value", "stored",
- '@', "action", "error",
- ')',
- '(', "rule", "",
- '@', "condition", "match-resource",
- '@', "value", "exact",
- '@', "action", "error",
- ')',
- ')', NULL);
+ GABBLE_AMP_DO_NOT_STORE_SPEC,
+ NULL);
g_assert (data != NULL);
if (groupchat)
{
- lm_message_node_set_attribute (wocky_stanza_get_top_node (msg),
+ wocky_node_set_attribute (wocky_stanza_get_top_node (msg),
"type", "groupchat");
}
@@ -357,18 +346,18 @@ send_data_to (GabbleBytestreamMuc *self,
}
encoded = base64_encode (send_now, str + sent, FALSE);
- lm_message_node_set_value (data, encoded);
+ wocky_node_set_content (data, encoded);
switch (frag)
{
case FRAG_FIRST:
- lm_message_node_set_attribute (data, "frag", "first");
+ wocky_node_set_attribute (data, "frag", "first");
break;
case FRAG_MIDDLE:
- lm_message_node_set_attribute (data, "frag", "middle");
+ wocky_node_set_attribute (data, "frag", "middle");
break;
case FRAG_LAST:
- lm_message_node_set_attribute (data, "frag", "last");
+ wocky_node_set_attribute (data, "frag", "last");
break;
}
@@ -381,14 +370,14 @@ send_data_to (GabbleBytestreamMuc *self,
{
DEBUG ("error sending pseusdo IBB Muc stanza: %s", error->message);
g_error_free (error);
- lm_message_unref (msg);
+ g_object_unref (msg);
return FALSE;
}
sent += send_now;
stanza_count++;
- lm_message_unref (msg);
+ g_object_unref (msg);
}
DEBUG ("finished to send %d bytes (%d stanzas needed)", len, stanza_count);
@@ -414,13 +403,13 @@ gabble_bytestream_muc_send (GabbleBytestreamIface *iface,
void
gabble_bytestream_muc_receive (GabbleBytestreamMuc *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleBytestreamMucPrivate *priv = GABBLE_BYTESTREAM_MUC_GET_PRIVATE (self);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
const gchar *from;
- LmMessageNode *data;
+ WockyNode *data;
GString *str;
TpHandle sender;
GString *buffer;
@@ -430,7 +419,7 @@ gabble_bytestream_muc_receive (GabbleBytestreamMuc *self,
/* caller must have checked for this in order to know which bytestream to
* route this packet to */
- data = lm_message_node_get_child_with_namespace (
+ data = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "data", NS_MUC_BYTESTREAM);
g_assert (data != NULL);
@@ -441,7 +430,7 @@ gabble_bytestream_muc_receive (GabbleBytestreamMuc *self,
return;
}
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "from");
g_return_if_fail (from != NULL);
sender = tp_handle_lookup (contact_repo, from,
@@ -453,7 +442,7 @@ gabble_bytestream_muc_receive (GabbleBytestreamMuc *self,
return;
}
- frag_val = lm_message_node_get_attribute (data, "frag");
+ frag_val = wocky_node_get_attribute (data, "frag");
if (frag_val == NULL)
frag = FRAG_COMPLETE;
else if (!tp_strdiff (frag_val, "first"))
@@ -470,7 +459,7 @@ gabble_bytestream_muc_receive (GabbleBytestreamMuc *self,
return;
}
- str = base64_decode (lm_message_node_get_value (data));
+ str = base64_decode (data->content);
if (str == NULL)
{
DEBUG ("base64 decoding failed");
diff --git a/src/bytestream-muc.h b/src/bytestream-muc.h
index 8b882203c..06dcd2689 100644
--- a/src/bytestream-muc.h
+++ b/src/bytestream-muc.h
@@ -21,8 +21,7 @@
#define __GABBLE_BYTESTREAM_MUC_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
+#include <wocky/wocky.h>
#include <telepathy-glib/base-connection.h>
G_BEGIN_DECLS
@@ -61,7 +60,7 @@ GType gabble_bytestream_muc_get_type (void);
GabbleBytestreamMucClass))
void gabble_bytestream_muc_receive (GabbleBytestreamMuc *bytestream,
- LmMessage *msg);
+ WockyStanza *msg);
gboolean gabble_bytestream_muc_send_to (GabbleBytestreamMuc *bytestream,
TpHandle to, guint len, gchar *str);
diff --git a/src/bytestream-multiple.c b/src/bytestream-multiple.c
index 48e609710..07243e1f1 100644
--- a/src/bytestream-multiple.c
+++ b/src/bytestream-multiple.c
@@ -22,7 +22,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/interfaces.h>
#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
@@ -387,8 +386,8 @@ gabble_bytestream_multiple_accept (GabbleBytestreamIface *iface,
GabbleBytestreamMultiple *self = GABBLE_BYTESTREAM_MULTIPLE (iface);
GabbleBytestreamMultiplePrivate *priv =
GABBLE_BYTESTREAM_MULTIPLE_GET_PRIVATE (self);
- LmMessage *msg;
- LmMessageNode *si;
+ WockyStanza *msg;
+ WockyNode *si;
GList *all_methods;
gchar *current_method;
@@ -413,7 +412,7 @@ gabble_bytestream_multiple_accept (GabbleBytestreamIface *iface,
g_free (current_method);
g_list_free (all_methods);
- si = lm_message_node_get_child_with_namespace (
+ si = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si != NULL);
@@ -431,7 +430,7 @@ gabble_bytestream_multiple_accept (GabbleBytestreamIface *iface,
GABBLE_BYTESTREAM_STATE_ACCEPTED, NULL);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
diff --git a/src/bytestream-multiple.h b/src/bytestream-multiple.h
index 89da446d8..2b445438c 100644
--- a/src/bytestream-multiple.h
+++ b/src/bytestream-multiple.h
@@ -23,12 +23,8 @@
#include <stdlib.h>
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
-#include <telepathy-glib/base-connection.h>
#include "bytestream-iface.h"
-#include "error.h"
G_BEGIN_DECLS
diff --git a/src/bytestream-socks5.c b/src/bytestream-socks5.c
index 759b2573a..12bd7c509 100644
--- a/src/bytestream-socks5.c
+++ b/src/bytestream-socks5.c
@@ -178,7 +178,7 @@ struct _GabbleBytestreamSocks5Private
/* Connections to streamhosts are async, so we keep the IQ set message
* around */
- LmMessage *msg_for_acknowledge_connection;
+ WockyStanza *msg_for_acknowledge_connection;
Socks5State socks5_state;
GibberTransport *transport;
@@ -621,6 +621,7 @@ socks5_error (GabbleBytestreamSocks5 *self)
{
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
Socks5State previous_state;
stop_timer (self);
@@ -657,11 +658,12 @@ socks5_error (GabbleBytestreamSocks5 *self)
g_signal_emit_by_name (self, "connection-error");
g_assert (priv->msg_for_acknowledge_connection != NULL);
- _gabble_connection_send_iq_error (priv->conn,
- priv->msg_for_acknowledge_connection, XMPP_ERROR_ITEM_NOT_FOUND,
+ wocky_porter_send_iq_error (porter,
+ priv->msg_for_acknowledge_connection,
+ WOCKY_XMPP_ERROR_ITEM_NOT_FOUND,
"impossible to connect to any streamhost");
- lm_message_unref (priv->msg_for_acknowledge_connection);
+ g_object_unref (priv->msg_for_acknowledge_connection);
priv->msg_for_acknowledge_connection = NULL;
break;
@@ -734,7 +736,8 @@ target_got_connect_reply (GabbleBytestreamSocks5 *self)
{
GabbleBytestreamSocks5Private *priv = GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (
self);
- LmMessage *iq_result;
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
+ Streamhost *current_streamhost;
DEBUG ("Received CONNECT reply. Socks5 stream connected. "
"Bytestream is now open");
@@ -742,29 +745,17 @@ target_got_connect_reply (GabbleBytestreamSocks5 *self)
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_OPEN, NULL);
/* Acknowledge the connection */
- iq_result = lm_iq_message_make_result (
- priv->msg_for_acknowledge_connection);
- if (NULL != iq_result)
- {
- LmMessageNode *node;
- Streamhost *current_streamhost;
-
- node = lm_message_node_add_child (
- wocky_stanza_get_top_node (iq_result), "query", "");
- lm_message_node_set_attribute (node, "xmlns", NS_BYTESTREAMS);
-
- /* streamhost-used informs the other end of the streamhost we
- * decided to use. In case of a direct connetion this is useless
- * but if we are using an external proxy we need to know which
- * one was selected */
- node = lm_message_node_add_child (node, "streamhost-used", "");
- current_streamhost = priv->streamhosts->data;
- lm_message_node_set_attribute (node, "jid",
- current_streamhost->jid);
-
- _gabble_connection_send (priv->conn, iq_result, NULL);
- lm_message_unref (iq_result);
- }
+ current_streamhost = priv->streamhosts->data;
+ wocky_porter_acknowledge_iq (porter, priv->msg_for_acknowledge_connection,
+ '(', "query", ':', NS_BYTESTREAMS,
+ /* streamhost-used informs the other end of the streamhost we
+ * decided to use. In case of a direct connetion this is useless
+ * but if we are using an external proxy we need to know which
+ * one was selected */
+ '(', "streamhost-used",
+ '@', "jid", current_streamhost->jid,
+ ')',
+ ')', NULL);
if (priv->read_blocked)
{
@@ -774,10 +765,10 @@ target_got_connect_reply (GabbleBytestreamSocks5 *self)
}
}
-static LmHandlerResult
+static void
socks5_activation_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
@@ -785,7 +776,7 @@ socks5_activation_reply_cb (GabbleConnection *conn,
GabbleBytestreamSocks5Private *priv = GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (
self);
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
{
DEBUG ("Activation failed");
goto activation_failed;
@@ -805,11 +796,10 @@ socks5_activation_reply_cb (GabbleConnection *conn,
/* We can read data from the sock5 socket now */
gibber_transport_block_receiving (priv->transport, FALSE);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
activation_failed:
g_signal_emit_by_name (self, "connection-error");
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -817,17 +807,17 @@ initiator_got_connect_reply (GabbleBytestreamSocks5 *self)
{
GabbleBytestreamSocks5Private *priv = GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (
self);
- LmMessage *iq;
+ WockyStanza *iq;
DEBUG ("Got CONNECT reply. SOCKS5 negotiation with proxy is done. "
"Sending activation IQ");
- iq = lm_message_build (priv->proxy_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "query", "",
- '@', "xmlns", NS_BYTESTREAMS,
+ iq = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->proxy_jid,
+ '(', "query",
+ ':', NS_BYTESTREAMS,
'@', "sid", priv->stream_id,
- '(', "activate", priv->peer_jid, ')',
+ '(', "activate", '$', priv->peer_jid, ')',
')', NULL);
priv->socks5_state = SOCKS5_STATE_INITIATOR_ACTIVATION_SENT;
@@ -844,7 +834,7 @@ initiator_got_connect_reply (GabbleBytestreamSocks5 *self)
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
}
- lm_message_unref (iq);
+ g_object_unref (iq);
}
/* Process the received data and returns the number of bytes that have been
@@ -1257,7 +1247,7 @@ socks5_connect (GabbleBytestreamSocks5 *self)
*/
void
gabble_bytestream_socks5_add_streamhost (GabbleBytestreamSocks5 *self,
- LmMessageNode *streamhost_node)
+ WockyNode *streamhost_node)
{
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
@@ -1270,7 +1260,7 @@ gabble_bytestream_socks5_add_streamhost (GabbleBytestreamSocks5 *self,
g_return_if_fail (!tp_strdiff (streamhost_node->name, "streamhost"));
- zeroconf = lm_message_node_get_attribute (streamhost_node, "zeroconf");
+ zeroconf = wocky_node_get_attribute (streamhost_node, "zeroconf");
if (zeroconf != NULL)
{
/* TODO: add suppport for zeroconf */
@@ -1278,21 +1268,21 @@ gabble_bytestream_socks5_add_streamhost (GabbleBytestreamSocks5 *self,
return;
}
- jid = lm_message_node_get_attribute (streamhost_node, "jid");
+ jid = wocky_node_get_attribute (streamhost_node, "jid");
if (jid == NULL)
{
DEBUG ("streamhost doesn't contain a JID");
return;
}
- host = lm_message_node_get_attribute (streamhost_node, "host");
+ host = wocky_node_get_attribute (streamhost_node, "host");
if (host == NULL)
{
DEBUG ("streamhost doesn't contain a host");
return;
}
- portstr = lm_message_node_get_attribute (streamhost_node, "port");
+ portstr = wocky_node_get_attribute (streamhost_node, "port");
if (portstr == NULL)
{
DEBUG ("streamhost doesn't contain a port");
@@ -1327,13 +1317,13 @@ gabble_bytestream_socks5_add_streamhost (GabbleBytestreamSocks5 *self,
*/
void
gabble_bytestream_socks5_connect_to_streamhost (GabbleBytestreamSocks5 *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
- priv->msg_for_acknowledge_connection = lm_message_ref (msg);
+ priv->msg_for_acknowledge_connection = g_object_ref (msg);
socks5_connect (self);
}
@@ -1408,8 +1398,8 @@ gabble_bytestream_socks5_accept (GabbleBytestreamIface *iface,
GabbleBytestreamSocks5 *self = GABBLE_BYTESTREAM_SOCKS5 (iface);
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
- LmMessage *msg;
- LmMessageNode *si;
+ WockyStanza *msg;
+ WockyNode *si;
if (priv->bytestream_state != GABBLE_BYTESTREAM_STATE_LOCAL_PENDING)
{
@@ -1419,7 +1409,7 @@ gabble_bytestream_socks5_accept (GabbleBytestreamIface *iface,
msg = gabble_bytestream_factory_make_accept_iq (priv->peer_jid,
priv->stream_init_id, NS_BYTESTREAMS);
- si = lm_message_node_get_child_with_namespace (
+ si = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si != NULL);
@@ -1436,7 +1426,7 @@ gabble_bytestream_socks5_accept (GabbleBytestreamIface *iface,
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_ACCEPTED, NULL);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static void
@@ -1445,31 +1435,30 @@ gabble_bytestream_socks5_decline (GabbleBytestreamSocks5 *self,
{
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
- LmMessage *msg;
+ WockyStanza *msg;
g_return_if_fail (priv->bytestream_state ==
GABBLE_BYTESTREAM_STATE_LOCAL_PENDING);
- msg = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "error",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_ERROR,
+ NULL, priv->peer_jid,
'@', "id", priv->stream_init_id,
NULL);
- if (error != NULL && error->domain == GABBLE_XMPP_ERROR)
+ if (error != NULL)
{
- gabble_xmpp_error_to_node (error->code,
- wocky_stanza_get_top_node (msg), error->message);
+ wocky_stanza_error_to_node (error, wocky_stanza_get_top_node (msg));
}
else
{
- gabble_xmpp_error_to_node (XMPP_ERROR_FORBIDDEN,
- wocky_stanza_get_top_node (msg),
- "Offer Declined");
+ GError fallback = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_FORBIDDEN,
+ "Offer Declined" };
+ wocky_stanza_error_to_node (&fallback, wocky_stanza_get_top_node (msg));
}
_gabble_connection_send (priv->conn, msg, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
}
@@ -1553,10 +1542,10 @@ initiator_connected_to_proxy (GabbleBytestreamSocks5 *self)
proxy->port);
}
-static LmHandlerResult
+static void
socks5_init_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
@@ -1564,16 +1553,16 @@ socks5_init_reply_cb (GabbleConnection *conn,
GabbleBytestreamSocks5Private *priv =
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_RESULT)
+ if (!wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
{
- LmMessageNode *query, *streamhost = NULL;
+ WockyNode *query, *streamhost = NULL;
const gchar *jid;
- query = lm_message_node_get_child_with_namespace (
+ query = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "query", NS_BYTESTREAMS);
if (query != NULL)
- streamhost = lm_message_node_get_child (query, "streamhost-used");
+ streamhost = wocky_node_get_child (query, "streamhost-used");
if (streamhost == NULL)
{
@@ -1581,7 +1570,7 @@ socks5_init_reply_cb (GabbleConnection *conn,
goto socks5_init_error;
}
- jid = lm_message_node_get_attribute (streamhost, "jid");
+ jid = wocky_node_get_attribute (streamhost, "jid");
if (jid == NULL)
{
DEBUG ("no jid attribute in streamhost. Closing the bytestream");
@@ -1601,7 +1590,7 @@ socks5_init_reply_cb (GabbleConnection *conn,
priv->proxy_jid = g_strdup (jid);
initiator_connected_to_proxy (self);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
/* No proxy used */
@@ -1620,7 +1609,7 @@ socks5_init_reply_cb (GabbleConnection *conn,
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_OPEN, NULL);
/* We can read data from the sock5 socket now */
gibber_transport_block_receiving (priv->transport, FALSE);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
socks5_init_error:
@@ -1628,8 +1617,6 @@ socks5_init_error:
g_signal_emit_by_name (self, "connection-error");
g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
#ifdef G_OS_WIN32
@@ -1891,7 +1878,8 @@ gabble_bytestream_socks5_initiate (GabbleBytestreamIface *iface)
GABBLE_BYTESTREAM_SOCKS5_GET_PRIVATE (self);
gchar *port;
gint port_num;
- LmMessage *msg;
+ WockyStanza *msg;
+ WockyNode *query_node;
GSList *ips, *ip;
if (priv->bytestream_state != GABBLE_BYTESTREAM_STATE_INITIATING)
@@ -1923,23 +1911,20 @@ gabble_bytestream_socks5_initiate (GabbleBytestreamIface *iface)
port_num = gibber_listener_get_port (priv->listener);
port = g_strdup_printf ("%d", port_num);
- msg = lm_message_build (priv->peer_jid, LM_MESSAGE_TYPE_IQ,
- '@', "type", "set",
- '(', "query", "",
- '@', "xmlns", NS_BYTESTREAMS,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->peer_jid,
+ '(', "query",
+ ':', NS_BYTESTREAMS,
'@', "sid", priv->stream_id,
'@', "mode", "tcp",
+ '*', &query_node,
')', NULL);
for (ip = ips; ip != NULL; ip = g_slist_next (ip))
{
- LmMessageNode *node;
- NodeIter i = node_iter (wocky_stanza_get_top_node (msg));
+ WockyNode *node = wocky_node_add_child (query_node, "streamhost");
- node = lm_message_node_add_child (node_iter_data (i),
- "streamhost", "");
-
- lm_message_node_set_attributes (node,
+ wocky_node_set_attributes (node,
"jid", priv->self_full_jid,
"host", ip->data,
"port", port,
@@ -1960,17 +1945,13 @@ gabble_bytestream_socks5_initiate (GabbleBytestreamIface *iface)
for (l = proxies; l != NULL; l = g_slist_next (l))
{
- LmMessageNode *node;
+ WockyNode *node = wocky_node_add_child (query_node, "streamhost");
gchar *portstr;
GabbleSocks5Proxy *proxy = (GabbleSocks5Proxy *) l->data;
- NodeIter i = node_iter (wocky_stanza_get_top_node (msg));
-
- node = lm_message_node_add_child (node_iter_data (i),
- "streamhost", "");
portstr = g_strdup_printf ("%d", proxy->port);
- lm_message_node_set_attributes (node,
+ wocky_node_set_attributes (node,
"jid", proxy->jid,
"host", proxy->host,
"port", portstr,
@@ -1992,11 +1973,11 @@ gabble_bytestream_socks5_initiate (GabbleBytestreamIface *iface)
{
DEBUG ("Error when sending Socks5 init stanza");
- lm_message_unref (msg);
+ g_object_unref (msg);
return FALSE;
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return TRUE;
}
diff --git a/src/bytestream-socks5.h b/src/bytestream-socks5.h
index 27c2c8ef1..524812f32 100644
--- a/src/bytestream-socks5.h
+++ b/src/bytestream-socks5.h
@@ -23,12 +23,9 @@
#include <stdlib.h>
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
+#include <wocky/wocky.h>
#include <telepathy-glib/base-connection.h>
-#include "error.h"
-
G_BEGIN_DECLS
typedef struct _GabbleBytestreamSocks5 GabbleBytestreamSocks5;
@@ -65,10 +62,10 @@ GType gabble_bytestream_socks5_get_type (void);
GabbleBytestreamSocks5Class))
void gabble_bytestream_socks5_add_streamhost (GabbleBytestreamSocks5 *socks5,
- LmMessageNode *streamhost_node);
+ WockyNode *streamhost_node);
void gabble_bytestream_socks5_connect_to_streamhost (
- GabbleBytestreamSocks5 *socks5, LmMessage *msg);
+ GabbleBytestreamSocks5 *socks5, WockyStanza *msg);
G_END_DECLS
diff --git a/src/call-content.c b/src/call-content.c
index 0fbfb78fd..862d10457 100644
--- a/src/call-content.c
+++ b/src/call-content.c
@@ -26,6 +26,7 @@
#include <telepathy-glib/svc-properties-interface.h>
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/gtypes.h>
+#include <telepathy-glib/interfaces.h>
#include "call-member.h"
#include "call-content.h"
diff --git a/src/call-muc-channel.c b/src/call-muc-channel.c
index 100e540fb..5b516d721 100644
--- a/src/call-muc-channel.c
+++ b/src/call-muc-channel.c
@@ -26,7 +26,7 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/gtypes.h>
-#include <wocky/wocky-muc.h>
+#include <wocky/wocky.h>
#include "call-content.h"
#include "muc-channel.h"
diff --git a/src/caps-hash.c b/src/caps-hash.c
index bd143eecd..12d302ec3 100644
--- a/src/caps-hash.c
+++ b/src/caps-hash.c
@@ -29,8 +29,7 @@
#include <string.h>
-#include <wocky/wocky-disco-identity.h>
-#include <wocky/wocky-caps-hash.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
diff --git a/src/caps-hash.h b/src/caps-hash.h
index e931b95b1..b36ea03e9 100644
--- a/src/caps-hash.h
+++ b/src/caps-hash.h
@@ -21,8 +21,6 @@
#ifndef __CAPS_HASH_H__
#define __CAPS_HASH_H__
-#include <loudmouth/loudmouth.h>
-
#include "connection.h"
#include "gabble/caps-hash.h"
diff --git a/src/conn-addressing.c b/src/conn-addressing.c
index 465699494..6842ae008 100644
--- a/src/conn-addressing.c
+++ b/src/conn-addressing.c
@@ -21,6 +21,9 @@
#include <dbus/dbus-glib-lowlevel.h>
+#include <telepathy-glib/gtypes.h>
+#include <telepathy-glib/interfaces.h>
+
#include "extensions/extensions.h"
#include "addressing-util.h"
diff --git a/src/conn-aliasing.c b/src/conn-aliasing.c
index 12af005c5..f48758eaf 100644
--- a/src/conn-aliasing.c
+++ b/src/conn-aliasing.c
@@ -21,7 +21,7 @@
#include "config.h"
#include "conn-aliasing.h"
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/contacts-mixin.h>
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>
@@ -39,7 +39,7 @@
#include "vcard-manager.h"
static void gabble_conn_aliasing_pep_nick_reply_handler (
- GabbleConnection *conn, LmMessage *msg, TpHandle handle);
+ GabbleConnection *conn, WockyStanza *msg, TpHandle handle);
static GQuark gabble_conn_aliasing_pep_alias_quark (void);
static GabbleConnectionAliasSource _gabble_connection_get_cached_remote_alias (
@@ -172,7 +172,7 @@ static void
aliases_request_vcard_cb (GabbleVCardManager *manager,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *error,
gpointer user_data)
{
@@ -224,7 +224,7 @@ _cache_negatively (GabbleConnection *self,
/* Cache pep if successful */
static void
aliases_request_cache_pep (GabbleConnection *self,
- LmMessage *msg,
+ WockyStanza *msg,
TpHandle handle,
GError *error)
{
@@ -232,8 +232,9 @@ aliases_request_cache_pep (GabbleConnection *self,
{
DEBUG ("Error getting alias from PEP: %s", error->message);
_cache_negatively (self, handle);
+ return;
}
- else if (lm_message_get_sub_type (msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ else if (wocky_stanza_extract_errors (msg, NULL, NULL, NULL, NULL))
{
STANZA_DEBUG (msg, "Error getting alias from PEP");
_cache_negatively (self, handle);
@@ -248,7 +249,7 @@ aliases_request_cache_pep (GabbleConnection *self,
static void
aliases_request_basic_pep_cb (GabbleConnection *self,
- LmMessage *msg,
+ WockyStanza *msg,
gpointer user_data,
GError *error)
{
@@ -272,7 +273,7 @@ aliases_request_basic_pep_cb (GabbleConnection *self,
static void
aliases_request_pep_cb (GabbleConnection *self,
- LmMessage *msg,
+ WockyStanza *msg,
gpointer user_data,
GError *error)
{
@@ -333,7 +334,7 @@ typedef struct {
static void
pep_request_cb (
GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
gpointer user_data,
GError *error)
{
@@ -355,7 +356,8 @@ gabble_do_pep_request (GabbleConnection *self,
gpointer user_data)
{
TpBaseConnection *base = (TpBaseConnection *) self;
- LmMessage *msg;
+ const gchar *to;
+ WockyStanza *msg;
GabbleRequestPipelineItem *pep_request;
pep_request_ctx *ctx;
@@ -371,19 +373,19 @@ gabble_do_pep_request (GabbleConnection *self,
ctx->handle = handle;
tp_handle_ref (contact_handles, handle);
- msg = lm_message_build (tp_handle_inspect (contact_handles, handle),
- LM_MESSAGE_TYPE_IQ,
- '@', "type", "get",
- '(', "pubsub", "",
- '@', "xmlns", NS_PUBSUB,
- '(', "items", "",
+ to = tp_handle_inspect (contact_handles, handle);
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_GET,
+ NULL, to,
+ '(', "pubsub",
+ ':', NS_PUBSUB,
+ '(', "items",
'@', "node", NS_NICK,
')',
')',
NULL);
pep_request = gabble_request_pipeline_enqueue (self->req_pipeline,
msg, 0, pep_request_cb, ctx);
- lm_message_unref (msg);
+ g_object_unref (msg);
return pep_request;
}
@@ -478,34 +480,24 @@ gabble_connection_request_aliases (TpSvcConnectionInterfaceAliasing *iface,
aliases_request_free (request);
}
-static LmHandlerResult
+static void
nick_publish_msg_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
#ifdef ENABLE_DEBUG
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
- {
- LmMessageNode *error_node;
-
- error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (reply_msg), "error");
+ GError *error = NULL;
- if (error_node != NULL)
- {
- GabbleXmppError error = gabble_xmpp_error_from_node (error_node,
- NULL);
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
+ {
+ DEBUG ("can't publish nick using PEP: %s: %s",
+ wocky_xmpp_stanza_error_to_string (error), error->message);
- DEBUG ("can't publish nick using PEP: %s: %s",
- gabble_xmpp_error_string (error),
- gabble_xmpp_error_description (error));
- }
+ g_clear_error (&error);
}
#endif
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -576,7 +568,7 @@ set_one_alias (
if (conn->features & GABBLE_CONNECTION_FEATURES_PEP)
{
/* Publish nick using PEP */
- LmMessage *msg;
+ WockyStanza *msg;
WockyNode *item;
msg = wocky_pep_service_make_publish_stanza (conn->pep_nick, &item);
@@ -586,7 +578,7 @@ set_one_alias (
_gabble_connection_send_with_reply (conn, msg,
nick_publish_msg_reply_cb, NULL, NULL, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
if (alias == NULL)
@@ -667,7 +659,7 @@ gabble_conn_aliasing_pep_alias_quark (void)
static gboolean
_grab_nickname (GabbleConnection *self,
TpHandle handle,
- LmMessageNode *node)
+ WockyNode *node)
{
TpBaseConnection *base = (TpBaseConnection *) self;
TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
@@ -675,7 +667,7 @@ _grab_nickname (GabbleConnection *self,
GQuark quark = gabble_conn_aliasing_pep_alias_quark ();
const gchar *old, *nickname;
- node = lm_message_node_get_child_with_namespace (node, "nick", NS_NICK);
+ node = wocky_node_get_child_ns (node, "nick", NS_NICK);
if (NULL == node)
{
@@ -685,7 +677,7 @@ _grab_nickname (GabbleConnection *self,
return FALSE;
}
- nickname = lm_message_node_get_value (node);
+ nickname = node->content;
old = tp_handle_get_qdata (contact_handles, handle, quark);
if (tp_strdiff (old, nickname))
@@ -711,11 +703,11 @@ static void
pep_nick_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *node;
TpHandle handle;
const gchar *jid;
@@ -727,32 +719,30 @@ pep_nick_node_changed (WockyPepService *pep,
return;
}
- node = lm_message_node_find_child (wocky_stanza_get_top_node (stanza),
- "item");
- if (NULL == node)
+ if (NULL == item)
{
STANZA_DEBUG (stanza, "PEP event without item node, ignoring");
return;
}
- _grab_nickname (conn, handle, node);
+ _grab_nickname (conn, handle, item);
}
static void
gabble_conn_aliasing_pep_nick_reply_handler (GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
TpHandle handle)
{
- LmMessageNode *pubsub_node, *items_node;
+ WockyNode *pubsub_node, *items_node, *item_node;
gboolean found = FALSE;
- NodeIter i;
+ WockyNodeIter i;
- pubsub_node = lm_message_node_get_child_with_namespace (
+ pubsub_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "pubsub", NS_PUBSUB);
if (pubsub_node == NULL)
{
- pubsub_node = lm_message_node_get_child_with_namespace (
+ pubsub_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "pubsub", NS_PUBSUB "#event");
if (pubsub_node == NULL)
@@ -768,7 +758,7 @@ gabble_conn_aliasing_pep_nick_reply_handler (GabbleConnection *conn,
}
}
- items_node = lm_message_node_get_child (pubsub_node, "items");
+ items_node = wocky_node_get_child (pubsub_node, "items");
if (items_node == NULL)
{
STANZA_DEBUG (msg, "No items in PEP reply");
@@ -776,10 +766,9 @@ gabble_conn_aliasing_pep_nick_reply_handler (GabbleConnection *conn,
return;
}
- for (i = node_iter (items_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, items_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &item_node))
{
- LmMessageNode *item_node = node_iter_data (i);
-
if (_grab_nickname (conn, handle, item_node))
{
/* FIXME: does this do the right thing on servers which return
diff --git a/src/conn-avatars.c b/src/conn-avatars.c
index 1369e49be..3a12ce290 100644
--- a/src/conn-avatars.c
+++ b/src/conn-avatars.c
@@ -24,8 +24,6 @@
#include <string.h>
-#include <loudmouth/loudmouth.h>
-
#include <telepathy-glib/svc-connection.h>
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/contacts-mixin.h>
@@ -409,17 +407,17 @@ gabble_connection_get_known_avatar_tokens (TpSvcConnectionInterfaceAvatars *ifac
static gboolean
-parse_avatar (LmMessageNode *vcard,
+parse_avatar (WockyNode *vcard,
const gchar **mime_type,
GString **avatar,
GError **error)
{
- LmMessageNode *photo_node;
- LmMessageNode *type_node;
- LmMessageNode *binval_node;
+ WockyNode *photo_node;
+ WockyNode *type_node;
+ WockyNode *binval_node;
const gchar *binval_value;
- photo_node = lm_message_node_get_child (vcard, "PHOTO");
+ photo_node = wocky_node_get_child (vcard, "PHOTO");
if (NULL == photo_node)
{
@@ -428,18 +426,18 @@ parse_avatar (LmMessageNode *vcard,
return FALSE;
}
- type_node = lm_message_node_get_child (photo_node, "TYPE");
+ type_node = wocky_node_get_child (photo_node, "TYPE");
if (NULL != type_node)
{
- *mime_type = lm_message_node_get_value (type_node);
+ *mime_type = type_node->content;
}
else
{
*mime_type = "";
}
- binval_node = lm_message_node_get_child (photo_node, "BINVAL");
+ binval_node = wocky_node_get_child (photo_node, "BINVAL");
if (NULL == binval_node)
{
@@ -448,7 +446,7 @@ parse_avatar (LmMessageNode *vcard,
return FALSE;
}
- binval_value = lm_message_node_get_value (binval_node);
+ binval_value = binval_node->content;
if (NULL == binval_value)
{
@@ -473,7 +471,7 @@ static void
_request_avatar_cb (GabbleVCardManager *self,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *vcard_error,
gpointer user_data)
{
@@ -494,15 +492,15 @@ _request_avatar_cb (GabbleVCardManager *self,
GError tp_error = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
vcard_error->message };
- if (vcard_error->domain == GABBLE_XMPP_ERROR)
+ if (vcard_error->domain == WOCKY_XMPP_ERROR)
{
switch (vcard_error->code)
{
- case XMPP_ERROR_NOT_AUTHORIZED:
- case XMPP_ERROR_FORBIDDEN:
+ case WOCKY_XMPP_ERROR_NOT_AUTHORIZED:
+ case WOCKY_XMPP_ERROR_FORBIDDEN:
tp_error.code = TP_ERROR_PERMISSION_DENIED;
break;
- case XMPP_ERROR_ITEM_NOT_FOUND:
+ case WOCKY_XMPP_ERROR_ITEM_NOT_FOUND:
tp_error.code = TP_ERROR_DOES_NOT_EXIST;
break;
}
@@ -598,7 +596,7 @@ gabble_connection_request_avatar (TpSvcConnectionInterfaceAvatars *iface,
TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
TP_HANDLE_TYPE_CONTACT);
GError *err = NULL;
- LmMessageNode *vcard_node;
+ WockyNode *vcard_node;
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
@@ -625,7 +623,7 @@ gabble_connection_request_avatar (TpSvcConnectionInterfaceAvatars *iface,
static void
emit_avatar_retrieved (TpSvcConnectionInterfaceAvatars *iface,
TpHandle contact,
- LmMessageNode *vcard_node)
+ WockyNode *vcard_node)
{
const gchar *mime_type;
GString *avatar_str;
@@ -656,7 +654,7 @@ static void
request_avatars_cb (GabbleVCardManager *manager,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *vcard_error,
gpointer user_data)
{
@@ -697,7 +695,7 @@ gabble_connection_request_avatars (TpSvcConnectionInterfaceAvatars *iface,
for (i = 0; i < contacts->len; i++)
{
- LmMessageNode *vcard_node;
+ WockyNode *vcard_node;
TpHandle contact = g_array_index (contacts, TpHandle, i);
if (gabble_vcard_manager_get_cached (self->vcard_manager,
@@ -748,7 +746,7 @@ _set_avatar_ctx_free (struct _set_avatar_ctx *ctx)
static void
_set_avatar_cb2 (GabbleVCardManager *manager,
GabbleVCardManagerEditRequest *request,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *vcard_error,
gpointer user_data)
{
@@ -764,9 +762,9 @@ _set_avatar_cb2 (GabbleVCardManager *manager,
* too big. It's not clear what other XMPP errors make sense here, or how
* to map them.
*/
- if (vcard_error->domain == GABBLE_XMPP_ERROR)
- if (vcard_error->code == XMPP_ERROR_BAD_REQUEST ||
- vcard_error->code == XMPP_ERROR_NOT_ACCEPTABLE)
+ if (vcard_error->domain == WOCKY_XMPP_ERROR)
+ if (vcard_error->code == WOCKY_XMPP_ERROR_BAD_REQUEST ||
+ vcard_error->code == WOCKY_XMPP_ERROR_NOT_ACCEPTABLE)
tp_error.code = TP_ERROR_INVALID_ARGUMENT;
dbus_g_method_return_error (ctx->invocation, &tp_error);
diff --git a/src/conn-contact-info.c b/src/conn-contact-info.c
index 1cfac86cf..a78f172e4 100644
--- a/src/conn-contact-info.c
+++ b/src/conn-contact-info.c
@@ -252,17 +252,14 @@ _parse_vcard (WockyNode *vcard_node,
{
GPtrArray *contact_info = dbus_g_type_specialized_construct (
TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST);
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
- for (i = node_iter (vcard_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, vcard_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- WockyNode *node = node_iter_data (i);
- const VCardField *field;
-
- if (node->name == NULL || !tp_strdiff (node->name, ""))
- continue;
-
- field = g_hash_table_lookup (known_fields_xmpp, node->name);
+ const VCardField *field = g_hash_table_lookup (known_fields_xmpp,
+ node->name);
if (field == NULL)
{
@@ -294,7 +291,8 @@ _parse_vcard (WockyNode *vcard_node,
{
WockyNode *orgname = wocky_node_get_child (node,
"ORGNAME");
- NodeIter orgunit_iter;
+ WockyNodeIter orgunit_iter;
+ WockyNode *orgunit;
GPtrArray *field_values;
const gchar *value;
@@ -313,15 +311,9 @@ _parse_vcard (WockyNode *vcard_node,
g_ptr_array_add (field_values, (gpointer) value);
- for (orgunit_iter = node_iter (node);
- orgunit_iter != NULL;
- orgunit_iter = node_iter_next (orgunit_iter))
+ wocky_node_iter_init (&orgunit_iter, node, "ORGUNIT", NULL);
+ while (wocky_node_iter_next (&orgunit_iter, &orgunit))
{
- WockyNode *orgunit = node_iter_data (orgunit_iter);
-
- if (tp_strdiff (orgunit->name, "ORGUNIT"))
- continue;
-
value = orgunit->content;
if (value == NULL)
@@ -341,21 +333,15 @@ _parse_vcard (WockyNode *vcard_node,
case FIELD_LABEL:
{
- NodeIter line_iter;
+ WockyNodeIter line_iter;
+ WockyNode *line_node;
gchar *field_values[2] = { NULL, NULL };
GString *text = g_string_new ("");
- for (line_iter = node_iter (node);
- line_iter != NULL;
- line_iter = node_iter_next (line_iter))
+ wocky_node_iter_init (&line_iter, node, "LINE", NULL);
+ while (wocky_node_iter_next (&line_iter, &line_node))
{
- const gchar *line;
- WockyNode *line_node = node_iter_data (line_iter);
-
- if (tp_strdiff (line_node->name, "LINE"))
- continue;
-
- line = line_node->content;
+ const gchar *line = line_node->content;
if (line != NULL)
{
@@ -501,16 +487,16 @@ _return_from_request_contact_info (WockyNode *vcard_node,
GError tp_error = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
vcard_error->message };
- if (vcard_error->domain == GABBLE_XMPP_ERROR)
+ if (vcard_error->domain == WOCKY_XMPP_ERROR)
{
switch (vcard_error->code)
{
- case XMPP_ERROR_NOT_AUTHORIZED:
- case XMPP_ERROR_FORBIDDEN:
+ case WOCKY_XMPP_ERROR_NOT_AUTHORIZED:
+ case WOCKY_XMPP_ERROR_FORBIDDEN:
tp_error.code = TP_ERROR_PERMISSION_DENIED;
break;
- case XMPP_ERROR_ITEM_NOT_FOUND:
+ case WOCKY_XMPP_ERROR_ITEM_NOT_FOUND:
tp_error.code = TP_ERROR_DOES_NOT_EXIST;
break;
}
@@ -720,9 +706,9 @@ _set_contact_info_cb (GabbleVCardManager *vcard_manager,
GError tp_error = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
vcard_error->message };
- if (vcard_error->domain == GABBLE_XMPP_ERROR)
- if (vcard_error->code == XMPP_ERROR_BAD_REQUEST ||
- vcard_error->code == XMPP_ERROR_NOT_ACCEPTABLE)
+ if (vcard_error->domain == WOCKY_XMPP_ERROR)
+ if (vcard_error->code == WOCKY_XMPP_ERROR_BAD_REQUEST ||
+ vcard_error->code == WOCKY_XMPP_ERROR_NOT_ACCEPTABLE)
tp_error.code = TP_ERROR_INVALID_ARGUMENT;
dbus_g_method_return_error (context, &tp_error);
diff --git a/src/conn-location.c b/src/conn-location.c
index be3b62c0f..b9ac05474 100644
--- a/src/conn-location.c
+++ b/src/conn-location.c
@@ -10,6 +10,9 @@
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>
+#include <wocky/wocky.h>
+
+#include <gabble/gabble.h>
#include "debug.h"
#include "namespaces.h"
@@ -73,8 +76,10 @@ build_mapping_tables (void)
}
}
-static gboolean update_location_from_msg (GabbleConnection *conn,
- TpHandle contact, LmMessage *msg);
+static gboolean update_location_from_item (
+ GabbleConnection *conn,
+ TpHandle contact,
+ WockyNode *item_node);
/*
* get_cached_location:
@@ -164,10 +169,11 @@ request_location_reply_cb (GObject *source,
{
YetAnotherContextStruct *ctx = user_data;
WockyStanza *reply;
+ WockyNode *item_node;
GError *wocky_error = NULL, *tp_error = NULL;
reply = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
- &wocky_error);
+ &item_node, &wocky_error);
if (reply == NULL ||
wocky_stanza_extract_errors (reply, NULL, &wocky_error, NULL, NULL))
@@ -181,7 +187,7 @@ request_location_reply_cb (GObject *source,
{
GHashTable *location;
- if (update_location_from_msg (ctx->self, ctx->handle, reply))
+ if (update_location_from_item (ctx->self, ctx->handle, item_node))
{
location = get_cached_location (ctx->self, ctx->handle);
/* We just cached a location for this contact, so it should be
@@ -246,7 +252,7 @@ location_request_location (
static gboolean
add_to_geoloc_node (const gchar *tp_name,
GValue *value,
- LmMessageNode *geoloc,
+ WockyNode *geoloc,
GError **err)
{
LocationMapping *mapping;
@@ -263,7 +269,7 @@ add_to_geoloc_node (const gchar *tp_name,
return FALSE;
}
- lm_message_node_set_attribute (
+ wocky_node_set_attribute (
geoloc, "xml:lang", g_value_get_string (value));
return TRUE;
}
@@ -307,39 +313,37 @@ add_to_geoloc_node (const gchar *tp_name,
/* Keys and their type have been checked */
g_assert_not_reached ();
- lm_message_node_add_child (geoloc, mapping->xmpp_name, str);
+ wocky_node_add_child_with_content (geoloc, mapping->xmpp_name, str);
DEBUG ("\t - %s: %s", (gchar *) tp_name, str);
g_free (str);
return TRUE;
}
-static LmHandlerResult
+static void
set_location_sent_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
GError *error = NULL;
- error = gabble_message_get_xmpp_error (reply_msg);
- if (error == NULL)
+ if (!wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
dbus_g_method_return (context);
}
else
{
- GError tp_error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- error->message };
+ GError *tp_error = NULL;
DEBUG ("SetLocation failed: %s", error->message);
- dbus_g_method_return_error (context, &tp_error);
+ gabble_set_tp_error_from_wocky (error, &tp_error);
+ dbus_g_method_return_error (context, tp_error);
+ g_error_free (tp_error);
g_error_free (error);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -348,8 +352,8 @@ location_set_location (TpSvcConnectionInterfaceLocation *iface,
DBusGMethodInvocation *context)
{
GabbleConnection *conn = GABBLE_CONNECTION (iface);
- LmMessage *msg;
- LmMessageNode *geoloc;
+ WockyStanza *msg;
+ WockyNode *geoloc;
WockyNode *item;
GHashTableIter iter;
gpointer key, value;
@@ -398,7 +402,7 @@ location_set_location (TpSvcConnectionInterfaceLocation *iface,
}
out:
- lm_message_unref (msg);
+ g_object_unref (msg);
}
void
@@ -516,27 +520,31 @@ conn_location_properties_setter (GObject *object,
}
static gboolean
-update_location_from_msg (GabbleConnection *conn,
- TpHandle contact,
- LmMessage *msg)
+update_location_from_item (
+ GabbleConnection *conn,
+ TpHandle contact,
+ WockyNode *item_node)
{
- LmMessageNode *node;
+ WockyNode *node;
GHashTable *location = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_free, (GDestroyNotify) tp_g_value_slice_free);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
const gchar *from = tp_handle_inspect (contact_repo, contact);
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *subloc_node;
const gchar *lang;
- node = lm_message_node_find_child (wocky_stanza_get_top_node (msg),
- "geoloc");
+ if (item_node == NULL)
+ return FALSE;
+
+ node = wocky_node_get_child_ns (item_node, "geoloc", NS_GEOLOC);
if (node == NULL)
return FALSE;
DEBUG ("LocationsUpdate for %s:", from);
- lang = lm_message_node_get_attribute (node, "xml:lang");
+ lang = wocky_node_get_language (node);
if (lang != NULL)
{
g_hash_table_insert (location, g_strdup ("language"),
@@ -545,16 +553,16 @@ update_location_from_msg (GabbleConnection *conn,
build_mapping_tables ();
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &subloc_node))
{
- LmMessageNode *subloc_node = node_iter_data (i);
GValue *value = NULL;
gchar *xmpp_name;
const gchar *str;
LocationMapping *mapping;
xmpp_name = subloc_node->name;
- str = lm_message_node_get_value (subloc_node);
+ str = subloc_node->content;
if (str == NULL)
continue;
@@ -617,6 +625,7 @@ static void
location_pep_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item_node,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
@@ -637,7 +646,7 @@ location_pep_node_changed (WockyPepService *pep,
/* Ignore echoed pubsub notifications */
goto out;
- update_location_from_msg (conn, handle, stanza);
+ update_location_from_item (conn, handle, item_node);
out:
tp_handle_unref (contact_repo, handle);
diff --git a/src/conn-mail-notif.c b/src/conn-mail-notif.c
index 9263c5123..2fe12e41e 100644
--- a/src/conn-mail-notif.c
+++ b/src/conn-mail-notif.c
@@ -35,10 +35,11 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/svc-connection.h>
#include <telepathy-glib/util.h>
-#include <wocky/wocky-c2s-porter.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_MAIL_NOTIF
#include "connection.h"
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 58da3c313..243d2dff0 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -28,6 +28,8 @@
#define DEBUG_FLAG GABBLE_DEBUG_OLPC
+#include <gabble/error.h>
+
#include "debug.h"
#include "connection.h"
#include "muc-channel.h"
@@ -46,16 +48,48 @@
static gboolean
update_activities_properties (GabbleConnection *conn, const gchar *contact,
- LmMessage *msg);
+ WockyStanza *msg);
+
+/*
+ * This function performs a depth-first search on @node to find any element
+ * named @name in namespace @ns. This is usually not what you want because you
+ * don't want a depth-first search of the entire hierarchy: you know at what
+ * level of nesting you expect to find an element. Using this function rather
+ * than wocky_node_get_child_ns() a couple of times opens you up to accepting
+ * wildly misconstructed stanzas. Please think of the kittens.
+ */
+static WockyNode *
+search_for_child (
+ WockyNode *node,
+ const gchar *name,
+ const gchar *ns)
+{
+ WockyNode *found, *child;
+ WockyNodeIter i;
+
+ found = wocky_node_get_child_ns (node, name, ns);
+ if (found != NULL)
+ return found;
+
+ wocky_node_iter_init (&i, node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &child))
+ {
+ found = search_for_child (child, name, ns);
+ if (found != NULL)
+ return found;
+ }
+
+ return NULL;
+}
/* Returns TRUE if it actually contributed something, else FALSE.
*/
static gboolean
activity_info_contribute_properties (GabbleOlpcActivity *activity,
- LmMessageNode *parent,
+ WockyNode *parent,
gboolean only_public)
{
- LmMessageNode *props_node;
+ WockyNode *props_node;
if (activity->id == NULL || activity->properties == NULL)
return FALSE;
@@ -63,13 +97,14 @@ activity_info_contribute_properties (GabbleOlpcActivity *activity,
if (only_public && !gabble_olpc_activity_is_visible (activity))
return FALSE;
- props_node = lm_message_node_add_child (parent,
+ props_node = wocky_node_add_child_with_content (parent,
"properties", "");
- lm_message_node_set_attributes (props_node,
- "xmlns", NS_OLPC_ACTIVITY_PROPS,
+ wocky_node_set_attributes (props_node,
"room", gabble_olpc_activity_get_room (activity),
"activity", activity->id,
NULL);
+ props_node->ns = g_quark_from_string (NS_OLPC_ACTIVITY_PROPS);
+
lm_message_node_add_children_from_properties (props_node,
activity->properties, "property");
return TRUE;
@@ -150,87 +185,57 @@ inspect_room (TpBaseConnection *base,
* connected.
*/
static gboolean
-check_publish_reply_msg (LmMessage *reply_msg,
+check_publish_reply_msg (WockyStanza *reply_msg,
DBusGMethodInvocation *context)
{
- switch (lm_message_get_sub_type (reply_msg))
- {
- case LM_MESSAGE_SUB_TYPE_RESULT:
- return TRUE;
+ GError *error = NULL;
- default:
- {
- LmMessageNode *error_node;
- GError *error = NULL;
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
+ {
+ GError *tp_error = NULL;
- error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (reply_msg), "error");
- if (error_node != NULL)
- {
- GabbleXmppError xmpp_error = gabble_xmpp_error_from_node (
- error_node, NULL);
+ gabble_set_tp_error_from_wocky (error, &tp_error);
+ g_prefix_error (&tp_error, "Failed to publish to the PEP node: ");
+ DEBUG ("%s", tp_error->message);
- error = g_error_new (TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "Failed to publish to the PEP node: %s",
- gabble_xmpp_error_description (xmpp_error));
- }
- else
- {
- error = g_error_new (TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "Failed to publish to the PEP node");
- }
+ if (context != NULL)
+ dbus_g_method_return_error (context, tp_error);
- DEBUG ("%s", error->message);
- if (context != NULL)
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
+ g_error_free (tp_error);
+ g_error_free (error);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
}
-
- return FALSE;
}
static gboolean
-check_query_reply_msg (LmMessage *reply_msg,
+check_query_reply_msg (WockyStanza *reply_msg,
DBusGMethodInvocation *context)
{
- switch (lm_message_get_sub_type (reply_msg))
- {
- case LM_MESSAGE_SUB_TYPE_RESULT:
- return TRUE;
-
- default:
- {
- LmMessageNode *error_node;
- GError *error = NULL;
-
- error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (reply_msg), "error");
- if (error_node != NULL)
- {
- GabbleXmppError xmpp_error = gabble_xmpp_error_from_node (
- error_node, NULL);
+ GError *error = NULL;
- error = g_error_new (TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "Failed to query the PEP node: %s",
- gabble_xmpp_error_description (xmpp_error));
- }
- else
- {
- error = g_error_new (TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "Failed to query the PEP node");
- }
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
+ {
+ GError *tp_error = NULL;
- DEBUG ("%s", error->message);
+ gabble_set_tp_error_from_wocky (error, &tp_error);
+ g_prefix_error (&tp_error, "Failed to query the PEP node: ");
+ DEBUG ("%s", tp_error->message);
- if (context != NULL)
- dbus_g_method_return_error (context, error);
+ if (context != NULL)
+ dbus_g_method_return_error (context, tp_error);
- g_error_free (error);
- }
+ g_error_free (tp_error);
+ g_error_free (error);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
}
-
- return FALSE;
}
typedef struct
@@ -265,10 +270,11 @@ get_properties_reply_cb (GObject *source,
WockyStanza *reply_msg;
GError *error = NULL;
GHashTable *properties;
- LmMessageNode *node;
+ WockyNode *node;
+ /* FIXME: can we just pass &node in here to get the <properties/>? */
reply_msg = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
- &error);
+ NULL, &error);
if (reply_msg == NULL)
{
GError err = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
@@ -284,8 +290,8 @@ get_properties_reply_cb (GObject *source,
if (!check_query_reply_msg (reply_msg, ctx->context))
goto out;
- node = lm_message_node_find_child (
- wocky_stanza_get_top_node (reply_msg), "properties");
+ node = search_for_child (
+ wocky_stanza_get_top_node (reply_msg), "properties", NULL);
properties = lm_message_node_extract_properties (node, "property");
gabble_svc_olpc_buddy_info_return_from_get_properties (ctx->context,
@@ -331,21 +337,20 @@ olpc_buddy_info_get_properties (GabbleSvcOLPCBuddyInfo *iface,
}
/* context may be NULL. */
-static LmHandlerResult
+static void
set_properties_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
if (!check_publish_reply_msg (reply_msg, context))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
if (context != NULL)
gabble_svc_olpc_buddy_info_return_from_set_properties (context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
/* context may be NULL, in which case it will be NULL in the reply_cb. */
@@ -354,7 +359,7 @@ transmit_properties (GabbleConnection *conn,
GHashTable *properties,
DBusGMethodInvocation *context)
{
- LmMessage *msg;
+ WockyStanza *msg;
WockyNode *item, *props_node;
gabble_connection_ensure_capabilities (conn,
@@ -382,7 +387,7 @@ transmit_properties (GabbleConnection *conn,
dbus_g_method_return_error (context, &error);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static GQuark
@@ -469,12 +474,13 @@ static void
olpc_buddy_props_pep_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
GHashTable *properties;
- LmMessageNode *node;
+ WockyNode *node;
TpBaseConnection *base = (TpBaseConnection *) conn;
TpHandle handle;
const gchar *jid;
@@ -491,8 +497,8 @@ olpc_buddy_props_pep_node_changed (WockyPepService *pep,
/* Ignore echoed pubsub notifications */
goto out;
- node = lm_message_node_find_child (
- wocky_stanza_get_top_node (stanza), "properties");
+ node = search_for_child (
+ wocky_stanza_get_top_node (stanza), "properties", NULL);
properties = lm_message_node_extract_properties (node, "property");
gabble_svc_olpc_buddy_info_emit_properties_changed (conn, handle,
properties);
@@ -513,7 +519,7 @@ get_activity_properties_reply_cb (GObject *source,
GError *error = NULL;
reply_msg = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
- &error);
+ NULL, &error);
if (reply_msg == NULL)
{
DEBUG ("Failed to send activity properties request to server: %s",
@@ -522,7 +528,7 @@ get_activity_properties_reply_cb (GObject *source,
return;
}
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "from");
update_activities_properties (conn, from, reply_msg);
g_object_unref (reply_msg);
@@ -642,86 +648,85 @@ get_buddy_activities (GabbleConnection *conn,
static void
extract_activities (GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
TpHandle sender)
{
- LmMessageNode *activities_node;
+ WockyNode *activities_node;
TpHandleSet *activities_set, *old_activities;
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_ROOM);
- NodeIter i;
+ WockyNodeIter i;
- activities_node = lm_message_node_find_child (
- wocky_stanza_get_top_node (msg), "activities");
+ activities_node = search_for_child (
+ wocky_stanza_get_top_node (msg), "activities", NULL);
activities_set = tp_handle_set_new (room_repo);
- for (i = (activities_node != NULL ? node_iter (activities_node) : NULL);
- i;
- i = node_iter_next (i))
+ if (activities_node != NULL)
{
- const gchar *act_id;
- const gchar *room;
- LmMessageNode *node = node_iter_data (i);
- GabbleOlpcActivity *activity;
- TpHandle room_handle;
-
- if (tp_strdiff (node->name, "activity"))
- continue;
-
- act_id = lm_message_node_get_attribute (node, "type");
- if (act_id == NULL)
+ WockyNode *node;
+ wocky_node_iter_init (&i, activities_node, "activity", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- NODE_DEBUG (node, "No activity ID, skipping");
- continue;
- }
+ const gchar *act_id;
+ const gchar *room;
+ GabbleOlpcActivity *activity;
+ TpHandle room_handle;
- room = lm_message_node_get_attribute (node, "room");
- if (room == NULL)
- {
- NODE_DEBUG (node, "No room name, skipping");
- continue;
- }
-
- room_handle = tp_handle_ensure (room_repo, room, NULL, NULL);
- if (room_handle == 0)
- {
- DEBUG ("Invalid room name <%s>, skipping", room);
- continue;
- }
+ act_id = wocky_node_get_attribute (node, "type");
+ if (act_id == NULL)
+ {
+ NODE_DEBUG (node, "No activity ID, skipping");
+ continue;
+ }
- activity = g_hash_table_lookup (conn->olpc_activities_info,
- GUINT_TO_POINTER (room_handle));
+ room = wocky_node_get_attribute (node, "room");
+ if (room == NULL)
+ {
+ NODE_DEBUG (node, "No room name, skipping");
+ continue;
+ }
- if (activity == NULL)
- {
- activity = add_activity_info (conn, room_handle);
- g_assert (!tp_handle_set_is_member (activities_set, room_handle));
- }
- else
- {
- if (tp_handle_set_is_member (activities_set, room_handle))
+ room_handle = tp_handle_ensure (room_repo, room, NULL, NULL);
+ if (room_handle == 0)
{
- NODE_DEBUG (node, "Room advertised twice, skipping");
- tp_handle_unref (room_repo, room_handle);
+ DEBUG ("Invalid room name <%s>, skipping", room);
continue;
}
- g_object_ref (activity);
+ activity = g_hash_table_lookup (conn->olpc_activities_info,
+ GUINT_TO_POINTER (room_handle));
- DEBUG ("ref: %s (%d) refcount: %d\n",
- gabble_olpc_activity_get_room (activity),
- activity->room, G_OBJECT (activity)->ref_count);
- }
- /* pass ownership to the activities_set */
- tp_handle_set_add (activities_set, room_handle);
- tp_handle_unref (room_repo, room_handle);
+ if (activity == NULL)
+ {
+ activity = add_activity_info (conn, room_handle);
+ g_assert (!tp_handle_set_is_member (activities_set, room_handle));
+ }
+ else
+ {
+ if (tp_handle_set_is_member (activities_set, room_handle))
+ {
+ NODE_DEBUG (node, "Room advertised twice, skipping");
+ tp_handle_unref (room_repo, room_handle);
+ continue;
+ }
+
+ g_object_ref (activity);
+
+ DEBUG ("ref: %s (%d) refcount: %d\n",
+ gabble_olpc_activity_get_room (activity),
+ activity->room, G_OBJECT (activity)->ref_count);
+ }
+ /* pass ownership to the activities_set */
+ tp_handle_set_add (activities_set, room_handle);
+ tp_handle_unref (room_repo, room_handle);
- if (tp_strdiff (activity->id, act_id))
- {
- DEBUG ("Assigning new ID <%s> to room #%u <%s>", act_id, room_handle,
- room);
- g_object_set (activity, "id", act_id, NULL);
+ if (tp_strdiff (activity->id, act_id))
+ {
+ DEBUG ("Assigning new ID <%s> to room #%u <%s>", act_id, room_handle,
+ room);
+ g_object_set (activity, "id", act_id, NULL);
+ }
}
}
@@ -813,9 +818,10 @@ get_activities_reply_cb (GObject *source,
TpHandle from_handle;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) ctx->conn, TP_HANDLE_TYPE_CONTACT);
+ GError *stanza_error = NULL;
reply_msg = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
- &err);
+ NULL, &err);
if (reply_msg == NULL)
{
GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
@@ -828,7 +834,7 @@ get_activities_reply_cb (GObject *source,
goto out;
}
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "from");
if (from == NULL)
{
@@ -849,12 +855,15 @@ get_activities_reply_cb (GObject *source,
goto out;
}
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &stanza_error, NULL, NULL))
{
- GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "Error in pubsub reply: server error" };
+ GError *tp_error = NULL;
- dbus_g_method_return_error (ctx->context, &error);
+ gabble_set_tp_error_from_wocky (stanza_error, &tp_error);
+ g_prefix_error (&tp_error, "Error in pubsub reply: ");
+ dbus_g_method_return_error (ctx->context, tp_error);
+ g_clear_error (&tp_error);
+ g_clear_error (&stanza_error);
goto out;
}
@@ -916,7 +925,7 @@ upload_activities_pep (GabbleConnection *conn,
{
TpBaseConnection *base = (TpBaseConnection *) conn;
WockyNode *item, *activities;
- LmMessage *msg;
+ WockyStanza *msg;
TpHandleSet *my_activities = g_hash_table_lookup
(conn->olpc_pep_activities, GUINT_TO_POINTER (base->self_handle));
GError *e = NULL;
@@ -936,15 +945,15 @@ upload_activities_pep (GabbleConnection *conn,
{
GabbleOlpcActivity *activity = g_hash_table_lookup (
conn->olpc_activities_info, GUINT_TO_POINTER (iter.element));
- LmMessageNode *activity_node;
+ WockyNode *activity_node;
g_assert (activity != NULL);
if (!gabble_olpc_activity_is_visible (activity))
continue;
- activity_node = lm_message_node_add_child (activities,
+ activity_node = wocky_node_add_child_with_content (activities,
"activity", "");
- lm_message_node_set_attributes (activity_node,
+ wocky_node_set_attributes (activity_node,
"type", activity->id,
"room", gabble_olpc_activity_get_room (activity),
NULL);
@@ -961,26 +970,25 @@ upload_activities_pep (GabbleConnection *conn,
g_error_free (e);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return ret;
}
-static LmHandlerResult
+static void
set_activities_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
if (!check_publish_reply_msg (reply_msg, context))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
/* FIXME: emit ActivitiesChanged? */
gabble_svc_olpc_buddy_info_return_from_set_activities (context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -1169,6 +1177,7 @@ static void
olpc_activities_pep_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
@@ -1241,7 +1250,7 @@ add_activity_info_in_set (GabbleConnection *conn,
static GabbleOlpcActivity *
extract_current_activity (GabbleConnection *conn,
- LmMessageNode *node,
+ WockyNode *node,
const gchar *contact,
gboolean create_activity)
{
@@ -1259,13 +1268,13 @@ extract_current_activity (GabbleConnection *conn,
/* For some weird reasons, the PEP protocol use "type" for the activity ID.
* We can't change that without breaking compatibility but if there is no
* "type" attribute then we can use the "id" one. */
- id = lm_message_node_get_attribute (node, "type");
+ id = wocky_node_get_attribute (node, "type");
if (id == NULL)
{
- id = lm_message_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
}
- room = lm_message_node_get_attribute (node, "room");
+ room = wocky_node_get_attribute (node, "room");
if (room == NULL || room[0] == '\0')
return NULL;
@@ -1319,12 +1328,12 @@ get_current_activity_reply_cb (GObject *source,
pubsub_query_ctx *ctx = (pubsub_query_ctx *) user_data;
WockyStanza *reply_msg;
GError *error = NULL;
- LmMessageNode *node;
+ WockyNode *node;
const gchar *from;
GabbleOlpcActivity *activity;
reply_msg = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
- &error);
+ NULL, &error);
if (reply_msg == NULL)
{
GError err = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
@@ -1337,7 +1346,7 @@ get_current_activity_reply_cb (GObject *source,
goto out;
}
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
{
DEBUG ("Failed to query PEP node. No current activity");
@@ -1347,10 +1356,10 @@ get_current_activity_reply_cb (GObject *source,
goto out;
}
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (reply_msg), "from");
- node = lm_message_node_find_child (
- wocky_stanza_get_top_node (reply_msg), "activity");
+ node = search_for_child (
+ wocky_stanza_get_top_node (reply_msg), "activity", NULL);
activity = extract_current_activity (ctx->conn, node, from, TRUE);
if (activity == NULL)
{
@@ -1421,20 +1430,19 @@ olpc_buddy_info_get_current_activity (GabbleSvcOLPCBuddyInfo *iface,
g_object_unref (contact);
}
-static LmHandlerResult
+static void
set_current_activity_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
if (!check_publish_reply_msg (reply_msg, context))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
gabble_svc_olpc_buddy_info_return_from_set_current_activity (context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
/* Check if this activity is in our own activities list */
@@ -1472,7 +1480,7 @@ olpc_buddy_info_set_current_activity (GabbleSvcOLPCBuddyInfo *iface,
{
GabbleConnection *conn = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *) conn;
- LmMessage *msg;
+ WockyStanza *msg;
WockyNode *item, *publish;
const gchar *room = "";
@@ -1506,7 +1514,7 @@ olpc_buddy_info_set_current_activity (GabbleSvcOLPCBuddyInfo *iface,
publish = wocky_node_add_child_ns (item, "activity",
NS_OLPC_CURRENT_ACTIVITY);
- lm_message_node_set_attributes (publish,
+ wocky_node_set_attributes (publish,
"type", activity,
"room", room,
NULL);
@@ -1520,19 +1528,20 @@ olpc_buddy_info_set_current_activity (GabbleSvcOLPCBuddyInfo *iface,
dbus_g_method_return_error (context, &error);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static void
olpc_current_act_pep_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
TpBaseConnection *base = (TpBaseConnection *) conn;
- LmMessageNode *node;
+ WockyNode *node;
GabbleOlpcActivity *activity;
TpHandle handle;
const gchar *jid;
@@ -1549,8 +1558,8 @@ olpc_current_act_pep_node_changed (WockyPepService *pep,
/* Ignore echoed pubsub notifications */
goto out;
- node = lm_message_node_find_child (wocky_stanza_get_top_node (stanza),
- "activity");
+ node = search_for_child (wocky_stanza_get_top_node (stanza),
+ "activity", NULL);
activity = extract_current_activity (conn, node, jid, TRUE);
if (activity != NULL)
@@ -1572,22 +1581,21 @@ out:
tp_handle_unref (contact_repo, handle);
}
-static LmHandlerResult
+static void
add_activity_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
if (!check_publish_reply_msg (reply_msg, context))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
/* FIXME: emit ActivitiesChanged? */
gabble_svc_olpc_buddy_info_return_from_add_activity (context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -1659,8 +1667,8 @@ upload_activity_properties_pep (GabbleConnection *conn,
GError **error)
{
TpBaseConnection *base = (TpBaseConnection *) conn;
- LmMessageNode *publish, *item;
- LmMessage *msg;
+ WockyNode *publish, *item;
+ WockyStanza *msg;
GError *e = NULL;
gboolean ret;
TpHandleSet *my_activities = g_hash_table_lookup (conn->olpc_pep_activities,
@@ -1694,7 +1702,7 @@ upload_activity_properties_pep (GabbleConnection *conn,
g_error_free (e);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return ret;
}
@@ -1704,10 +1712,10 @@ typedef struct {
GabbleOlpcActivity *activity;
} set_properties_ctx;
-static LmHandlerResult
+static void
set_activity_properties_activities_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
@@ -1720,7 +1728,7 @@ set_activity_properties_activities_reply_cb (GabbleConnection *conn,
!check_publish_reply_msg (reply_msg, context->context))
{
g_slice_free (set_properties_ctx, context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
gabble_svc_olpc_activity_properties_emit_activity_properties_changed (
@@ -1730,13 +1738,13 @@ set_activity_properties_activities_reply_cb (GabbleConnection *conn,
context->context);
g_slice_free (set_properties_ctx, context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
-static LmHandlerResult
+static void
set_activity_properties_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
@@ -1749,7 +1757,7 @@ set_activity_properties_reply_cb (GabbleConnection *conn,
!check_publish_reply_msg (reply_msg, context->context))
{
g_slice_free (set_properties_ctx, context);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
if (context->visibility_changed)
@@ -1770,8 +1778,6 @@ set_activity_properties_reply_cb (GabbleConnection *conn,
set_activity_properties_activities_reply_cb (conn, NULL, NULL, NULL,
context);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -1787,29 +1793,29 @@ refresh_invitations (GabbleConnection *conn,
if (invitees != NULL && tp_handle_set_size (invitees) > 0)
{
- LmMessage *msg = lm_message_new (NULL, LM_MESSAGE_TYPE_MESSAGE);
TpIntSetIter iter = TP_INTSET_ITER_INIT (tp_handle_set_peek
(invitees));
- activity_info_contribute_properties (activity,
- wocky_stanza_get_top_node (msg), FALSE);
-
while (tp_intset_iter_next (&iter))
{
const gchar *to = tp_handle_inspect (contact_repo, iter.element);
+ WockyStanza *msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, to, NULL);
+
+ activity_info_contribute_properties (activity,
+ wocky_stanza_get_top_node (msg), FALSE);
- lm_message_node_set_attribute (
- wocky_stanza_get_top_node (msg), "to", to);
if (!_gabble_connection_send (conn, msg, error))
{
DEBUG ("Unable to re-send activity properties to invitee %s",
to);
- lm_message_unref (msg);
+ g_object_unref (msg);
return FALSE;
}
- }
- lm_message_unref (msg);
+ g_object_unref (msg);
+ }
}
return TRUE;
@@ -1823,7 +1829,7 @@ olpc_activity_properties_set_properties (GabbleSvcOLPCActivityProperties *iface,
{
GabbleConnection *conn = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *) conn;
- LmMessage *msg;
+ WockyStanza *msg;
const gchar *jid;
GHashTable *properties_copied;
GabbleOlpcActivity *activity;
@@ -1885,9 +1891,9 @@ olpc_activity_properties_set_properties (GabbleSvcOLPCActivityProperties *iface,
is_visible = gabble_olpc_activity_is_visible (activity);
- msg = lm_message_new (jid, LM_MESSAGE_TYPE_MESSAGE);
- lm_message_node_set_attribute (
- wocky_stanza_get_top_node (msg), "type", "groupchat");
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_GROUPCHAT,
+ NULL, jid, NULL);
activity_info_contribute_properties (activity,
wocky_stanza_get_top_node (msg), FALSE);
if (!_gabble_connection_send (conn, msg, NULL))
@@ -1895,11 +1901,11 @@ olpc_activity_properties_set_properties (GabbleSvcOLPCActivityProperties *iface,
GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
"Failed to send property change notification to chatroom" };
- lm_message_unref (msg);
+ g_object_unref (msg);
dbus_g_method_return_error (context, &error);
return;
}
- lm_message_unref (msg);
+ g_object_unref (msg);
if (!refresh_invitations (conn, muc_channel, activity, &err))
{
@@ -2054,7 +2060,7 @@ static void
update_activity_properties (GabbleConnection *conn,
const gchar *room,
const gchar *contact,
- LmMessageNode *properties_node)
+ WockyNode *properties_node)
{
GHashTable *new_properties, *old_properties;
gboolean new_infos = FALSE;
@@ -2124,25 +2130,22 @@ update_activity_properties (GabbleConnection *conn,
static gboolean
update_activities_properties (GabbleConnection *conn,
const gchar *contact,
- LmMessage *msg)
+ WockyStanza *msg)
{
const gchar *room;
- LmMessageNode *node;
- NodeIter i;
+ WockyNode *node;
+ WockyNodeIter i;
+ WockyNode *properties_node;
- node = lm_message_node_find_child (
- wocky_stanza_get_top_node (msg), "activities");
+ node = search_for_child (
+ wocky_stanza_get_top_node (msg), "activities", NULL);
if (node == NULL)
return FALSE;
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, node, "properties", NULL);
+ while (wocky_node_iter_next (&i, &properties_node))
{
- LmMessageNode *properties_node = node_iter_data (i);
-
- if (strcmp (properties_node->name, "properties") != 0)
- continue;
-
- room = lm_message_node_get_attribute (properties_node, "room");
+ room = wocky_node_get_attribute (properties_node, "room");
if (room == NULL)
continue;
@@ -2155,6 +2158,7 @@ static void
olpc_act_props_pep_node_changed (WockyPepService *pep,
WockyBareContact *contact,
WockyStanza *stanza,
+ WockyNode *item,
GabbleConnection *conn)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
@@ -2208,10 +2212,10 @@ connection_status_changed_cb (GabbleConnection *conn,
}
}
-static LmHandlerResult
+static void
pseudo_invite_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
@@ -2221,12 +2225,11 @@ pseudo_invite_reply_cb (GabbleConnection *conn,
"response to pseudo-invitation message");
STANZA_DEBUG (sent_msg, "The failed request was");
}
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
gboolean
conn_olpc_process_activity_properties_message (GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
const gchar *from)
{
TpBaseConnection *base = (TpBaseConnection *) conn;
@@ -2234,7 +2237,7 @@ conn_olpc_process_activity_properties_message (GabbleConnection *conn,
TP_HANDLE_TYPE_CONTACT);
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (base,
TP_HANDLE_TYPE_ROOM);
- LmMessageNode *node = lm_message_node_get_child_with_namespace (
+ WockyNode *node = search_for_child (
wocky_stanza_get_top_node (msg), "properties", NS_OLPC_ACTIVITY_PROPS);
const gchar *id;
TpHandle room_handle, contact_handle = 0;
@@ -2251,7 +2254,7 @@ conn_olpc_process_activity_properties_message (GabbleConnection *conn,
DEBUG ("Found <properties> node in <message>");
- id = lm_message_node_get_attribute (node, "activity");
+ id = wocky_node_get_attribute (node, "activity");
if (id == NULL)
{
NODE_DEBUG (node, "... activity ID missing - ignoring");
@@ -2281,7 +2284,7 @@ conn_olpc_process_activity_properties_message (GabbleConnection *conn,
return TRUE;
}
- room = lm_message_node_get_attribute (node, "room");
+ room = wocky_node_get_attribute (node, "room");
if (room == NULL)
{
NODE_DEBUG (node, "... room name missing - ignoring");
@@ -2461,10 +2464,10 @@ conn_olpc_process_activity_properties_message (GabbleConnection *conn,
return TRUE;
}
-static LmHandlerResult
+static void
closed_pep_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
@@ -2474,7 +2477,6 @@ closed_pep_reply_cb (GabbleConnection *conn,
"response to channel closure");
STANZA_DEBUG (sent_msg, "The failed request was");
}
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -2494,37 +2496,31 @@ revoke_invitations (GabbleConnection *conn,
if (invitees != NULL && tp_handle_set_size (invitees) > 0)
{
- LmMessage *msg = lm_message_new (NULL, LM_MESSAGE_TYPE_MESSAGE);
TpIntSetIter iter = TP_INTSET_ITER_INIT (tp_handle_set_peek
(invitees));
- LmMessageNode *uninvite_node;
-
- uninvite_node = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "uninvite", "");
- lm_message_node_set_attribute (uninvite_node, "xmlns",
- NS_OLPC_ACTIVITY_PROPS);
- lm_message_node_set_attribute (uninvite_node, "room",
- gabble_olpc_activity_get_room (activity));
- lm_message_node_set_attribute (uninvite_node, "id",
- activity->id);
DEBUG ("revoke invitations for activity %s", activity->id);
while (tp_intset_iter_next (&iter))
{
const gchar *to = tp_handle_inspect (contact_repo, iter.element);
+ WockyStanza *msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, to,
+ '(', "uninvite", ':', NS_OLPC_ACTIVITY_PROPS,
+ '@', "room", gabble_olpc_activity_get_room (activity),
+ '@', "id", activity->id,
+ ')', NULL);
- lm_message_node_set_attribute (
- wocky_stanza_get_top_node (msg), "to", to);
if (!_gabble_connection_send (conn, msg, error))
{
DEBUG ("Unable to send activity invitee revocation %s",
to);
- lm_message_unref (msg);
+ g_object_unref (msg);
return FALSE;
}
- }
- lm_message_unref (msg);
+ g_object_unref (msg);
+ }
}
return TRUE;
@@ -2532,33 +2528,33 @@ revoke_invitations (GabbleConnection *conn,
gboolean
conn_olpc_process_activity_uninvite_message (GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
const gchar *from)
{
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_ROOM);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *node;
+ WockyNode *node;
const gchar *id, *room;
TpHandle room_handle, from_handle;
TpHandleSet *rooms;
- node = lm_message_node_get_child_with_namespace (
+ node = search_for_child (
wocky_stanza_get_top_node (msg), "uninvite", NS_OLPC_ACTIVITY_PROPS);
/* if no <uninvite xmlns=...>, then not for us */
if (node == NULL)
return FALSE;
- id = lm_message_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL)
{
DEBUG ("no activity id. Skip");
return TRUE;
}
- room = lm_message_node_get_attribute (node, "room");
+ room = wocky_node_get_attribute (node, "room");
if (room == NULL)
{
DEBUG ("no room. Skip");
@@ -2684,7 +2680,7 @@ muc_channel_pre_invite_cb (GabbleMucChannel *chan,
GQuark quark = invitees_quark ();
TpHandleSet *invitees;
/* send them the properties */
- LmMessage *msg;
+ WockyStanza *msg;
TpHandle handle;
GError *error = NULL;
@@ -2692,7 +2688,10 @@ muc_channel_pre_invite_cb (GabbleMucChannel *chan,
contact_repo = tp_base_connection_get_handles
((TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
- msg = lm_message_new (jid, LM_MESSAGE_TYPE_MESSAGE);
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, jid,
+ NULL);
if (activity_info_contribute_properties (activity,
wocky_stanza_get_top_node (msg), FALSE))
@@ -2704,7 +2703,7 @@ muc_channel_pre_invite_cb (GabbleMucChannel *chan,
DEBUG ("Unable to send activity properties to invitee");
}
}
- lm_message_unref (msg);
+ g_object_unref (msg);
handle = tp_handle_ensure (contact_repo, jid, NULL, &error);
if (handle == 0)
diff --git a/src/conn-olpc.h b/src/conn-olpc.h
index 11958c40e..cef23cbbd 100644
--- a/src/conn-olpc.h
+++ b/src/conn-olpc.h
@@ -35,13 +35,10 @@ void conn_olpc_activity_properties_init (GabbleConnection *conn);
void conn_olpc_activity_properties_dispose (GabbleConnection *conn);
gboolean conn_olpc_process_activity_properties_message (GabbleConnection *conn,
- LmMessage *msg, const gchar *from);
+ WockyStanza *msg, const gchar *from);
gboolean conn_olpc_process_activity_uninvite_message (GabbleConnection *conn,
- LmMessage *msg, const gchar *from);
-
-LmHandlerResult conn_olpc_msg_cb (LmMessageHandler *handler,
- LmConnection *connection, LmMessage *message, gpointer user_data);
+ WockyStanza *msg, const gchar *from);
#endif /* __CONN_OLPC_H__ */
diff --git a/src/conn-power-saving.c b/src/conn-power-saving.c
index e1f25ad95..07b6a896b 100644
--- a/src/conn-power-saving.c
+++ b/src/conn-power-saving.c
@@ -26,8 +26,7 @@
#include "util.h"
#include "conn-util.h"
-#include <wocky/wocky-namespaces.h>
-#include <wocky/wocky-c2s-porter.h>
+#include <wocky/wocky.h>
enum
{
diff --git a/src/conn-presence.c b/src/conn-presence.c
index 55c75fe02..9dfd6b6b1 100644
--- a/src/conn-presence.c
+++ b/src/conn-presence.c
@@ -30,8 +30,7 @@
#include <telepathy-glib/util.h>
#include <telepathy-glib/interfaces.h>
-#include <wocky/wocky-c2s-porter.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_CONNECTION
@@ -58,7 +57,7 @@ typedef enum {
struct _GabbleConnectionPresencePrivate {
InvisibilityMethod invisibility_method;
- LmMessageHandler *iq_list_push_cb;
+ guint iq_list_push_id;
gchar *invisible_list_name;
/* Mapping between status "show" strings, and shared statuses */
@@ -123,22 +122,24 @@ static TpPresenceStatusSpec *gabble_statuses = NULL;
/* prototypes */
-static LmHandlerResult set_xep0186_invisible_cb (GabbleConnection *conn,
- LmMessage *sent_msg, LmMessage *reply_msg, GObject *obj,
+static void set_xep0186_invisible_cb (GabbleConnection *conn,
+ WockyStanza *sent_msg, WockyStanza *reply_msg, GObject *obj,
gpointer user_data);
-static LmHandlerResult activate_current_privacy_list_cb (
- GabbleConnection *conn, LmMessage *sent_msg, LmMessage *reply_msg,
+static void activate_current_privacy_list_cb (
+ GabbleConnection *conn, WockyStanza *sent_msg, WockyStanza *reply_msg,
GObject *obj, gpointer user_data);
static void setup_invisible_privacy_list_async (GabbleConnection *self,
GAsyncReadyCallback callback, gpointer user_data);
-static LmHandlerResult iq_privacy_list_push_cb (LmMessageHandler *handler,
- LmConnection *connection, LmMessage *message, gpointer user_data);
+static gboolean iq_privacy_list_push_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data);
-static LmHandlerResult verify_invisible_privacy_list_cb (
- GabbleConnection *conn, LmMessage *sent_msg, LmMessage *reply_msg,
+static void verify_invisible_privacy_list_cb (
+ GabbleConnection *conn, WockyStanza *sent_msg, WockyStanza *reply_msg,
GObject *obj, gpointer user_data);
static void toggle_presence_visibility_async (GabbleConnection *self,
@@ -512,7 +513,7 @@ set_xep0186_invisible (GabbleConnection *self,
g_object_unref (result);
}
}
- else if (!_gabble_connection_send_with_reply (self, (LmMessage *) iq,
+ else if (!_gabble_connection_send_with_reply (self, (WockyStanza *) iq,
set_xep0186_invisible_cb, NULL, result, &error))
{
g_simple_async_result_set_from_error (result, error);
@@ -525,21 +526,22 @@ set_xep0186_invisible (GabbleConnection *self,
g_object_unref (iq);
}
-static LmHandlerResult
+static void
set_xep0186_invisible_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
GError *error = NULL;
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
g_simple_async_result_set_error (result,
CONN_PRESENCE_ERROR, CONN_PRESENCE_ERROR_SET_INVISIBLE,
- "error setting XEP-0186 (in)visiblity");
+ "error setting XEP-0186 (in)visiblity: %s", error->message);
+ g_clear_error (&error);
}
else
{
@@ -561,8 +563,6 @@ set_xep0186_invisible_cb (GabbleConnection *conn,
g_simple_async_result_complete (result);
g_object_unref (result);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
@@ -577,7 +577,7 @@ activate_current_privacy_list (GabbleConnection *self,
gboolean invisible;
GabblePresence *presence = self->self_presence;
GError *error = NULL;
- LmMessageNode *active_node;
+ WockyNode *active_node;
g_assert (priv->privacy_statuses != NULL);
@@ -607,7 +607,7 @@ activate_current_privacy_list (GabbleConnection *self,
if (base->status == TP_CONNECTION_STATUS_CONNECTED && invisible)
{
if (!gabble_connection_send_presence (self,
- LM_MESSAGE_SUB_TYPE_UNAVAILABLE, NULL, NULL, &error))
+ WOCKY_STANZA_SUB_TYPE_UNAVAILABLE, NULL, NULL, &error))
goto ERROR;
}
/* If we're still connecting and there's no list to be set, we don't
@@ -625,7 +625,7 @@ activate_current_privacy_list (GabbleConnection *self,
goto OUT;
}
- _gabble_connection_send_with_reply (self, (LmMessage *) iq,
+ _gabble_connection_send_with_reply (self, (WockyStanza *) iq,
activate_current_privacy_list_cb, NULL, result, &error);
ERROR:
@@ -641,21 +641,22 @@ activate_current_privacy_list (GabbleConnection *self,
g_object_unref (iq);
}
-static LmHandlerResult
+static void
activate_current_privacy_list_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
GError *error = NULL;
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
g_simple_async_result_set_error (result,
CONN_PRESENCE_ERROR, CONN_PRESENCE_ERROR_SET_PRIVACY_LIST,
- "error setting requested privacy list");
+ "error setting requested privacy list: %s", error->message);
+ g_clear_error (&error);
}
else
{
@@ -674,8 +675,6 @@ activate_current_privacy_list_cb (GabbleConnection *conn,
g_simple_async_result_complete (result);
g_object_unref (result);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -696,29 +695,25 @@ disable_invisible_privacy_list (GabbleConnection *self)
}
}
-static LmHandlerResult
+static void
create_invisible_privacy_list_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GError *error = NULL;
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
- GError *error = gabble_message_get_xmpp_error (reply_msg);
-
g_simple_async_result_set_from_error (result, error);
-
g_free (error);
}
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -746,7 +741,7 @@ create_invisible_privacy_list_async (GabbleConnection *self,
DEBUG ("Creating '%s'", self->presence_priv->invisible_list_name);
- if (!_gabble_connection_send_with_reply (self, (LmMessage *) iq,
+ if (!_gabble_connection_send_with_reply (self, (WockyStanza *) iq,
create_invisible_privacy_list_reply_cb, NULL, result, &error))
{
g_simple_async_result_set_from_error (result, error);
@@ -925,53 +920,37 @@ iq_shared_status_changed_cb (WockyPorter *porter,
WockyNode *query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (stanza), "query",
NS_GOOGLE_SHARED_STATUS);
- WockyStanza *result;
if (store_shared_statuses (self, query_node))
emit_presences_changed_for_self (self);
- result = wocky_stanza_build_iq_result (stanza, NULL);
-
- wocky_porter_send (porter, result);
-
- g_object_unref (result);
+ wocky_porter_acknowledge_iq (porter, stanza, NULL);
return TRUE;
}
-static LmHandlerResult
-iq_privacy_list_push_cb (LmMessageHandler *handler,
- LmConnection *connection,
- LmMessage *message,
+static gboolean
+iq_privacy_list_push_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
gpointer user_data)
{
GabbleConnection *conn = GABBLE_CONNECTION (user_data);
- LmMessage *result;
- LmMessageNode *list_node, *iq;
+ WockyNode *list_node, *query_node, *iq;
const gchar *list_name;
- if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_SET)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-
- iq = lm_message_get_node (message);
- list_node = lm_message_node_find_child (iq, "list");
-
- if (!lm_message_node_get_child_with_namespace (iq, "query", NS_PRIVACY) ||
- !list_node)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ wocky_porter_acknowledge_iq (wocky_session_get_porter (conn->session),
+ message, NULL);
- result = lm_iq_message_make_result (message);
-
- wocky_porter_send (wocky_session_get_porter (conn->session), result);
-
- list_name = lm_message_node_get_attribute (list_node, "name");
+ iq = wocky_stanza_get_top_node (message);
+ query_node = wocky_node_get_first_child (iq);
+ list_node = wocky_node_get_child (query_node, "list");
+ list_name = wocky_node_get_attribute (list_node, "name");
if (g_strcmp0 (list_name, conn->presence_priv->invisible_list_name) == 0)
setup_invisible_privacy_list_async (conn, NULL, NULL);
- lm_message_unref (result);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
/**********************************************************************
@@ -1099,19 +1078,19 @@ get_shared_status_finish (GabbleConnection *self,
wocky_implement_finish_void (self, get_shared_status_async);
}
-static LmHandlerResult
+static void
get_existing_privacy_lists_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
WockyNode *query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "query", NS_PRIVACY);
- GError *error = gabble_message_get_xmpp_error (reply_msg);
+ GError *error = NULL;
- if (error != NULL)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
{
DEBUG ("Error getting privacy lists: %s", error->message);
@@ -1127,7 +1106,7 @@ get_existing_privacy_lists_cb (GabbleConnection *conn,
else
{
GabbleConnectionPresencePrivate *priv = conn->presence_priv;
- LmMessageNode *list_node;
+ WockyNode *list_node;
WockyNodeIter iter;
GabblePluginLoader *loader = gabble_plugin_loader_dup ();
@@ -1141,7 +1120,7 @@ get_existing_privacy_lists_cb (GabbleConnection *conn,
wocky_node_iter_init (&iter, query_node, "list", NULL);
while (wocky_node_iter_next (&iter, &list_node))
{
- const gchar *list_name = lm_message_node_get_attribute (list_node,
+ const gchar *list_name = wocky_node_get_attribute (list_node,
"name");
const gchar *status_name;
@@ -1162,8 +1141,6 @@ get_existing_privacy_lists_cb (GabbleConnection *conn,
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -1183,7 +1160,7 @@ get_existing_privacy_lists_async (GabbleConnection *self,
')',
NULL);
- if (!_gabble_connection_send_with_reply (self, (LmMessage *) iq,
+ if (!_gabble_connection_send_with_reply (self, (WockyStanza *) iq,
get_existing_privacy_lists_cb, NULL, result, &error))
{
g_simple_async_result_set_from_error (result, error);
@@ -1229,7 +1206,7 @@ setup_invisible_privacy_list_async (GabbleConnection *self,
')',
NULL);
- if (!_gabble_connection_send_with_reply (self, (LmMessage *) iq,
+ if (!_gabble_connection_send_with_reply (self, (WockyStanza *) iq,
verify_invisible_privacy_list_cb, NULL, result, &error))
{
g_simple_async_result_set_from_error (result, error);
@@ -1251,23 +1228,21 @@ setup_invisible_privacy_list_finish (GabbleConnection *self,
}
static gboolean
-is_valid_invisible_list (LmMessageNode *list_node)
+is_valid_invisible_list (WockyNode *list_node)
{
- LmMessageNode *top_node = NULL;
- NodeIter i;
+ WockyNode *top_node = NULL;
+ WockyNode *child;
+ WockyNodeIter i;
guint top_order = G_MAXUINT;
- for (i = node_iter (list_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, list_node, "item", NULL);
+ while (wocky_node_iter_next (&i, &child))
{
- LmMessageNode *child = node_iter_data (i);
const gchar *order_str;
guint order;
gchar *end;
- if (g_strcmp0 (lm_message_node_get_name (child), "item") != 0)
- continue;
-
- order_str = lm_message_node_get_attribute (child, "order");
+ order_str = wocky_node_get_attribute (child, "order");
if (order_str == NULL)
continue;
@@ -1286,9 +1261,9 @@ is_valid_invisible_list (LmMessageNode *list_node)
if (top_node != NULL)
{
- const gchar *value = lm_message_node_get_attribute (top_node, "value");
- const gchar *action = lm_message_node_get_attribute (top_node, "action");
- LmMessageNode *presence_out = lm_message_node_get_child (top_node,
+ const gchar *value = wocky_node_get_attribute (top_node, "value");
+ const gchar *action = wocky_node_get_attribute (top_node, "action");
+ WockyNode *presence_out = wocky_node_get_child (top_node,
"presence-out");
return (value == NULL && g_strcmp0 (action, "deny") == 0 &&
@@ -1298,22 +1273,27 @@ is_valid_invisible_list (LmMessageNode *list_node)
return FALSE;
}
-static LmHandlerResult
+static void
verify_invisible_privacy_list_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *obj,
gpointer user_data)
{
GabbleConnectionPresencePrivate *priv = conn->presence_priv;
- LmMessageNode *node = lm_message_node_find_child
- (wocky_stanza_get_top_node (reply_msg), "list");
- GError *error = gabble_message_get_xmpp_error (reply_msg);
+ WockyNode *query_node, *list_node = NULL;
+ GError *error = NULL;
+
+ query_node = wocky_node_get_child_ns (wocky_stanza_get_top_node (reply_msg),
+ "query", NS_PRIVACY);
+
+ if (query_node != NULL)
+ list_node = wocky_node_get_child (query_node, "list");
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_RESULT &&
- node != NULL)
+ if (!wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL) &&
+ list_node != NULL)
{
- if (!is_valid_invisible_list (node))
+ if (!is_valid_invisible_list (list_node))
{
g_free (priv->invisible_list_name);
priv->invisible_list_name = g_strdup ("invisible-gabble");
@@ -1331,29 +1311,22 @@ verify_invisible_privacy_list_cb (GabbleConnection *conn,
toggle_presence_visibility_async (conn,
toggle_initial_presence_visibility_cb, user_data);
}
-
- goto OUT;
}
- else if (error != NULL)
+ else if (error->code == WOCKY_XMPP_ERROR_ITEM_NOT_FOUND)
{
- if (error->code == XMPP_ERROR_ITEM_NOT_FOUND)
- {
- create_invisible_privacy_list_async (conn,
- create_invisible_privacy_list_cb, user_data);
- goto OUT;
- }
+ create_invisible_privacy_list_async (conn,
+ create_invisible_privacy_list_cb, user_data);
}
+ else
+ {
+ disable_invisible_privacy_list (conn);
- disable_invisible_privacy_list (conn);
-
- toggle_presence_visibility_async (conn,
- toggle_initial_presence_visibility_cb, user_data);
+ toggle_presence_visibility_async (conn,
+ toggle_initial_presence_visibility_cb, user_data);
+ }
- OUT:
if (error != NULL)
g_error_free (error);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -1373,14 +1346,17 @@ initial_presence_setup_cb (GObject *source_object,
g_error_free (error);
}
- if (priv->invisibility_method == INVISIBILITY_METHOD_PRIVACY)
+ if (priv->invisibility_method == INVISIBILITY_METHOD_PRIVACY &&
+ self->session != NULL)
{
- priv->iq_list_push_cb = lm_message_handler_new (iq_privacy_list_push_cb,
- self, NULL);
-
- lm_connection_register_message_handler (self->lmconn,
- priv->iq_list_push_cb, LM_MESSAGE_TYPE_IQ,
- LM_HANDLER_PRIORITY_NORMAL);
+ priv->iq_list_push_id = wocky_c2s_porter_register_handler_from_server (
+ WOCKY_C2S_PORTER (wocky_session_get_porter (self->session)),
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ WOCKY_PORTER_HANDLER_PRIORITY_NORMAL,
+ iq_privacy_list_push_cb, self,
+ '(', "query", ':', NS_PRIVACY,
+ '(', "list", ')',
+ ')', NULL);
}
g_simple_async_result_complete_in_idle (external_result);
@@ -1593,13 +1569,13 @@ conn_presence_signal_own_presence (GabbleConnection *self,
GabbleConnectionPresencePrivate *priv = self->presence_priv;
GabblePresence *presence = self->self_presence;
TpBaseConnection *base = (TpBaseConnection *) self;
- LmMessage *message = gabble_presence_as_message (presence, to);
+ WockyStanza *message = gabble_presence_as_message (presence, to);
gboolean ret;
if (presence->status == GABBLE_PRESENCE_HIDDEN && to == NULL)
{
if (priv->invisibility_method == INVISIBILITY_METHOD_PRESENCE_INVISIBLE)
- lm_message_node_set_attribute (lm_message_get_node (message),
+ wocky_node_set_attribute (wocky_stanza_get_top_node (message),
"type", "invisible");
/* FIXME: or if sending directed presence, should we add
* <show>away</show>? */
@@ -1609,7 +1585,7 @@ conn_presence_signal_own_presence (GabbleConnection *self,
ret = _gabble_connection_send (self, message, error);
- lm_message_unref (message);
+ g_object_unref (message);
/* FIXME: if sending broadcast presence, should we echo it to everyone we
* previously sent directed presence to? (Perhaps also GC them after a
@@ -2021,6 +1997,12 @@ conn_presence_dispose (GabbleConnection *self)
wocky_porter_unregister_handler (porter, priv->iq_shared_status_cb);
priv->iq_shared_status_cb = 0;
}
+
+ if (priv->iq_list_push_id != 0)
+ {
+ wocky_porter_unregister_handler (porter, priv->iq_list_push_id);
+ priv->iq_list_push_id = 0;
+ }
}
void
@@ -2036,9 +2018,6 @@ conn_presence_finalize (GabbleConnection *conn)
if (priv->shared_statuses != NULL)
g_hash_table_unref (priv->shared_statuses);
- if (priv->iq_list_push_cb != NULL)
- lm_message_handler_unref (priv->iq_list_push_cb);
-
g_slice_free (GabbleConnectionPresencePrivate, priv);
tp_presence_mixin_finalize ((GObject *) conn);
diff --git a/src/conn-util.c b/src/conn-util.c
index 5b3a3ddf6..98be2448e 100644
--- a/src/conn-util.c
+++ b/src/conn-util.c
@@ -19,12 +19,14 @@
#include "conn-util.h"
+#include <gabble/gabble.h>
+
#define DEBUG_FLAG GABBLE_DEBUG_CONNECTION
#include "debug.h"
#include "namespaces.h"
#include "util.h"
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
static void
conn_util_send_iq_cb (GObject *source_object,
diff --git a/src/connection-manager.c b/src/connection-manager.c
index 8267299d7..b2a0edb15 100644
--- a/src/connection-manager.c
+++ b/src/connection-manager.c
@@ -27,7 +27,7 @@
#include <dbus/dbus-glib.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/errors.h>
-#include <wocky/wocky-caps-cache.h>
+#include <wocky/wocky.h>
#include "connection.h"
#include "debug.h"
diff --git a/src/connection.c b/src/connection.c
index 4f396b9d0..25ae603b3 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -27,14 +27,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-#include <wocky/wocky-connector.h>
-#include <wocky/wocky-disco-identity.h>
-#include <wocky/wocky-tls-handler.h>
-#include <wocky/wocky-ping.h>
-#include <wocky/wocky-utils.h>
-#include <wocky/wocky-xmpp-error.h>
-#include <wocky/wocky-data-form.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/enums.h>
@@ -48,6 +41,7 @@
#define DEBUG_FLAG GABBLE_DEBUG_CONNECTION
+#include <gabble/error.h>
#include "bytestream-factory.h"
#include "gabble/capabilities.h"
#include "gabble/caps-channel-manager.h"
@@ -287,6 +281,15 @@ struct _GabbleConnectionPrivate
* to connected */
guint waiting_connected;
+ /* Used to cancel pending calls to _gabble_connection_send_with_reply(). It
+ * should not be necessary because by the time we get to cancelling this (in
+ * our dispose()) the porter should be long dead and have called back for all
+ * outstanding requests. However... call this paranoia, and a desire to
+ * delete the Loudmouth compatibility layer without spending any more hours
+ * untangling even more old code.
+ */
+ GCancellable *iq_reply_cancellable;
+
gboolean closing;
/* gobject housekeeping */
gboolean dispose_has_run;
@@ -532,7 +535,7 @@ gabble_connection_init (GabbleConnection *self)
}
self->priv = priv;
- self->lmconn = lm_connection_new ();
+ priv->iq_reply_cancellable = g_cancellable_new ();
priv->caps_serial = 1;
priv->last_activity_time = time (NULL);
@@ -1234,9 +1237,11 @@ gabble_connection_dispose (GObject *object)
tp_clear_object (&priv->connector);
tp_clear_object (&self->session);
- /* ownership of our porter was transferred to the LmConnection */
+ /* The porter was borrowed from the session. */
priv->porter = NULL;
- tp_clear_pointer (&self->lmconn, lm_connection_unref);
+ /* Cancel any outstanding _gabble_connection_send_with_reply() requests. */
+ g_cancellable_cancel (priv->iq_reply_cancellable);
+ tp_clear_object (&priv->iq_reply_cancellable);
g_hash_table_unref (priv->client_caps);
gabble_capability_set_free (priv->all_caps);
@@ -1398,14 +1403,14 @@ gabble_connection_get_session (GabbleConnection *connection)
/**
* _gabble_connection_send
*
- * Send an LmMessage and trap network errors appropriately.
+ * Send an WockyStanza and trap network errors appropriately.
*/
gboolean
-_gabble_connection_send (GabbleConnection *conn, LmMessage *msg, GError **error)
+_gabble_connection_send (GabbleConnection *conn, WockyStanza *msg, GError **error)
{
g_assert (GABBLE_IS_CONNECTION (conn));
- if (conn->lmconn == NULL || conn->priv->porter == NULL)
+ if (conn->priv->porter == NULL)
{
g_set_error_literal (error, TP_ERRORS, TP_ERROR_NETWORK_ERROR,
"connection is disconnected");
@@ -1432,44 +1437,13 @@ typedef struct {
GabbleConnectionMsgReplyFunc reply_func;
GabbleConnection *conn;
- LmMessage *sent_msg;
+ WockyStanza *sent_msg;
gpointer user_data;
GObject *object;
gboolean object_alive;
} GabbleMsgHandlerData;
-static LmHandlerResult
-message_send_reply_cb (LmMessageHandler *handler,
- LmConnection *connection,
- LmMessage *reply_msg,
- gpointer user_data)
-{
- GabbleMsgHandlerData *handler_data = user_data;
- LmMessageSubType sub_type;
-
- sub_type = lm_message_get_sub_type (reply_msg);
-
- /* Is it a reply to this message? If we're talking to another loudmouth,
- * they can send us messages which have the same ID as ones we send. :-O */
- if (sub_type != LM_MESSAGE_SUB_TYPE_RESULT &&
- sub_type != LM_MESSAGE_SUB_TYPE_ERROR)
- {
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
- }
-
- if (handler_data->object_alive && handler_data->reply_func != NULL)
- {
- return handler_data->reply_func (handler_data->conn,
- handler_data->sent_msg,
- reply_msg,
- handler_data->object,
- handler_data->user_data);
- }
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-}
-
static void
message_send_object_destroy_notify_cb (gpointer data,
GObject *where_the_object_was)
@@ -1481,11 +1455,9 @@ message_send_object_destroy_notify_cb (gpointer data,
}
static void
-message_send_handler_destroy_cb (gpointer data)
+msg_handler_data_free (GabbleMsgHandlerData *handler_data)
{
- GabbleMsgHandlerData *handler_data = data;
-
- lm_message_unref (handler_data->sent_msg);
+ g_object_unref (handler_data->sent_msg);
if (handler_data->object != NULL)
{
@@ -1497,40 +1469,71 @@ message_send_handler_destroy_cb (gpointer data)
g_slice_free (GabbleMsgHandlerData, handler_data);
}
+static void
+message_send_reply_cb (
+ GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GabbleMsgHandlerData *handler_data = user_data;
+
+ if (handler_data->object_alive && handler_data->reply_func != NULL)
+ {
+ WockyPorter *porter = WOCKY_PORTER (source);
+ GError *error = NULL;
+ WockyStanza *stanza = wocky_porter_send_iq_finish (porter, result, &error);
+
+ if (stanza != NULL)
+ {
+ handler_data->reply_func (handler_data->conn,
+ handler_data->sent_msg,
+ stanza,
+ handler_data->object,
+ handler_data->user_data);
+ g_object_unref (stanza);
+ }
+ else
+ {
+ DEBUG ("send_iq_async failed: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ msg_handler_data_free (handler_data);
+}
+
/**
* _gabble_connection_send_with_reply
*
- * Send a tracked LmMessage and trap network errors appropriately.
+ * Send a tracked WockyStanza and trap network errors appropriately.
*
* If object is non-NULL the handler will follow the lifetime of that object,
* which means that if the object is destroyed the callback will not be invoked.
*
- * if reply_func is NULL the reply will be ignored but connection_iq_unknown_cb
- * won't be called.
+ * if reply_func is NULL the reply will be ignored.
*/
gboolean
_gabble_connection_send_with_reply (GabbleConnection *conn,
- LmMessage *msg,
+ WockyStanza *msg,
GabbleConnectionMsgReplyFunc reply_func,
GObject *object,
gpointer user_data,
GError **error)
{
- LmMessageHandler *handler;
+ GabbleConnectionPrivate *priv;
GabbleMsgHandlerData *handler_data;
- gboolean ret;
- GError *lmerror = NULL;
g_assert (GABBLE_IS_CONNECTION (conn));
+ priv = conn->priv;
- if (conn->lmconn == NULL)
+ if (priv->porter == NULL)
{
g_set_error_literal (error, TP_ERRORS, TP_ERROR_NETWORK_ERROR,
"connection is disconnected");
return FALSE;
}
- lm_message_ref (msg);
+ g_object_ref (msg);
handler_data = g_slice_new (GabbleMsgHandlerData);
handler_data->reply_func = reply_func;
@@ -1547,34 +1550,17 @@ _gabble_connection_send_with_reply (GabbleConnection *conn,
handler_data);
}
- handler = lm_message_handler_new (message_send_reply_cb, handler_data,
- message_send_handler_destroy_cb);
-
- ret = lm_connection_send_with_reply (conn->lmconn, msg, handler, &lmerror);
- if (!ret)
- {
- DEBUG ("failed: %s", lmerror->message);
-
- if (error)
- {
- g_set_error (error, TP_ERRORS, TP_ERROR_NETWORK_ERROR,
- "message send failed: %s", lmerror->message);
- }
-
- g_error_free (lmerror);
- }
-
- lm_message_handler_unref (handler);
+ wocky_porter_send_iq_async (priv->porter, msg,
+ priv->iq_reply_cancellable, message_send_reply_cb, handler_data);
- return ret;
+ return TRUE;
}
static void connect_iq_callbacks (GabbleConnection *conn);
static gboolean iq_disco_cb (WockyPorter *, WockyStanza *, gpointer);
static gboolean iq_version_cb (WockyPorter *, WockyStanza *, gpointer);
-static gboolean iq_unknown_cb (WockyPorter *, WockyStanza *, gpointer);
static void connection_disco_cb (GabbleDisco *, GabbleDiscoRequest *,
- const gchar *, const gchar *, LmMessageNode *, GError *, gpointer);
+ const gchar *, const gchar *, WockyNode *, GError *, gpointer);
static void decrement_waiting_connected (GabbleConnection *connection);
static void connection_initial_presence_cb (GObject *, GAsyncResult *,
gpointer);
@@ -1723,12 +1709,11 @@ bare_jid_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *result,
+ WockyNode *result,
GError *disco_error,
gpointer user_data)
{
GabbleConnection *conn = user_data;
- NodeIter i;
if (disco_error != NULL)
{
@@ -1736,22 +1721,21 @@ bare_jid_disco_cb (GabbleDisco *disco,
}
else
{
- for (i = node_iter (result); i; i = node_iter_next (i))
+ WockyNodeIter i;
+ WockyNode *child;
+
+ wocky_node_iter_init (&i, result, "identity", NULL);
+ while (wocky_node_iter_next (&i, &child))
{
- LmMessageNode *child = node_iter_data (i);
+ const gchar *category = wocky_node_get_attribute (child,
+ "category");
+ const gchar *type = wocky_node_get_attribute (child, "type");
- if (!tp_strdiff (child->name, "identity"))
+ if (!tp_strdiff (category, "pubsub") &&
+ !tp_strdiff (type, "pep"))
{
- const gchar *category = lm_message_node_get_attribute (child,
- "category");
- const gchar *type = lm_message_node_get_attribute (child, "type");
-
- if (!tp_strdiff (category, "pubsub") &&
- !tp_strdiff (type, "pep"))
- {
- DEBUG ("Server advertises PEP support in our jid features");
- conn->features |= GABBLE_CONNECTION_FEATURES_PEP;
- }
+ DEBUG ("Server advertises PEP support in our jid features");
+ conn->features |= GABBLE_CONNECTION_FEATURES_PEP;
}
}
}
@@ -1886,7 +1870,6 @@ connector_connected (GabbleConnection *self,
g_signal_connect (priv->porter, "remote-error",
G_CALLBACK (remote_error_cb), self);
- lm_connection_set_porter (self->lmconn, priv->porter);
g_signal_emit (self, sig_id_porter_available, 0, priv->porter);
connect_iq_callbacks (self);
@@ -2079,12 +2062,6 @@ connect_iq_callbacks (GabbleConnection *conn)
WOCKY_PORTER_HANDLER_PRIORITY_NORMAL,
connection_iq_last_cb, conn,
'(', "query", ':', NS_LAST, ')', NULL);
-
- /* FIXME: the porter should do this for us. */
- wocky_porter_register_handler_from_anyone (priv->porter,
- WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_NONE,
- WOCKY_PORTER_HANDLER_PRIORITY_MIN,
- iq_unknown_cb, conn, NULL);
}
/**
@@ -2315,24 +2292,24 @@ connection_shut_down (TpBaseConnection *base)
void
gabble_connection_fill_in_caps (GabbleConnection *self,
- LmMessage *presence_message)
+ WockyStanza *presence_message)
{
GabblePresence *presence = self->self_presence;
- LmMessageNode *node = lm_message_get_node (presence_message);
+ WockyNode *node = wocky_stanza_get_top_node (presence_message);
gchar *caps_hash;
gboolean share_v1, voice_v1, video_v1;
GString *ext = g_string_new ("");
/* XEP-0115 version 1.5 uses a verification string in the 'ver' attribute */
caps_hash = caps_hash_compute_from_self_presence (self);
- node = lm_message_node_add_child (node, "c", NULL);
- lm_message_node_set_attributes (
+ node = wocky_node_add_child_with_content (node, "c", NULL);
+ wocky_node_set_attributes (
node,
- "xmlns", NS_CAPS,
"hash", "sha-1",
"node", NS_GABBLE_CAPS,
"ver", caps_hash,
NULL);
+ node->ns = g_quark_from_string (NS_CAPS);
/* Ensure this set of capabilities is in the cache. */
gabble_presence_cache_add_own_caps (self->presence_cache, caps_hash,
@@ -2359,7 +2336,7 @@ gabble_connection_fill_in_caps (GabbleConnection *self,
g_string_append (ext, " " BUNDLE_CAMERA_V1);
}
- lm_message_node_set_attribute (node, "ext", ext->str);
+ wocky_node_set_attribute (node, "ext", ext->str);
g_string_free (ext, TRUE);
g_free (caps_hash);
}
@@ -2371,7 +2348,7 @@ gabble_connection_send_capabilities (GabbleConnection *self,
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) self, TP_HANDLE_TYPE_CONTACT);
- LmMessage *message;
+ WockyStanza *message;
gboolean ret;
TpHandle handle;
@@ -2386,14 +2363,16 @@ gabble_connection_send_capabilities (GabbleConnection *self,
}
/* We deliberately don't include anything except the caps here */
- message = lm_message_new_with_sub_type (recipient, LM_MESSAGE_TYPE_PRESENCE,
- LM_MESSAGE_SUB_TYPE_AVAILABLE);
+ message = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_PRESENCE, WOCKY_STANZA_SUB_TYPE_AVAILABLE,
+ NULL, recipient,
+ NULL);
gabble_connection_fill_in_caps (self, message);
ret = _gabble_connection_send (self, message, error);
- lm_message_unref (message);
+ g_object_unref (message);
return ret;
}
@@ -2405,23 +2384,23 @@ gabble_connection_request_decloak (GabbleConnection *self,
GError **error)
{
GabblePresence *presence = self->self_presence;
- LmMessage *message = gabble_presence_as_message (presence, to);
- LmMessageNode *decloak;
+ WockyStanza *message = gabble_presence_as_message (presence, to);
+ WockyNode *decloak;
gboolean ret;
gabble_connection_fill_in_caps (self, message);
- decloak = lm_message_node_add_child (lm_message_get_node (message),
+ decloak = wocky_node_add_child_with_content (wocky_stanza_get_top_node (message),
"temppres", NULL);
- lm_message_node_set_attribute (decloak, "xmlns", NS_TEMPPRES);
+ decloak->ns = g_quark_from_string (NS_TEMPPRES);
if (reason != NULL && *reason != '\0')
{
- lm_message_node_set_attribute (decloak, "reason", reason);
+ wocky_node_set_attribute (decloak, "reason", reason);
}
ret = _gabble_connection_send (self, message, error);
- lm_message_unref (message);
+ g_object_unref (message);
return ret;
}
@@ -2520,87 +2499,37 @@ gabble_connection_refresh_capabilities (GabbleConnection *self,
*/
void
_gabble_connection_acknowledge_set_iq (GabbleConnection *conn,
- LmMessage *iq)
+ WockyStanza *iq)
{
- LmMessage *result;
-
- g_assert (LM_MESSAGE_TYPE_IQ == lm_message_get_type (iq));
- g_assert (LM_MESSAGE_SUB_TYPE_SET == lm_message_get_sub_type (iq));
-
- result = lm_iq_message_make_result (iq);
-
- if (NULL != result)
- {
- _gabble_connection_send (conn, result, NULL);
- lm_message_unref (result);
- }
-}
-
-/**
- * _gabble_connection_send_iq_error
- *
- * Function used to acknowledge an IQ stanza with an error.
- */
-void
-_gabble_connection_send_iq_error (GabbleConnection *conn,
- LmMessage *message,
- GabbleXmppError error,
- const gchar *errmsg)
-{
- const gchar *to, *id;
- LmMessage *msg;
- LmMessageNode *iq_node;
-
- iq_node = lm_message_get_node (message);
- to = lm_message_node_get_attribute (iq_node, "from");
- id = lm_message_node_get_attribute (iq_node, "id");
-
- if (id == NULL)
- {
- NODE_DEBUG (iq_node, "can't acknowledge IQ with no id");
- return;
- }
-
- msg = lm_message_new_with_sub_type (to, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_ERROR);
-
- lm_message_node_set_attribute (wocky_stanza_get_top_node (msg), "id", id);
-
- lm_message_node_steal_children (
- wocky_stanza_get_top_node (msg), iq_node);
-
- gabble_xmpp_error_to_node (error, wocky_stanza_get_top_node (msg), errmsg);
-
- _gabble_connection_send (conn, msg, NULL);
-
- lm_message_unref (msg);
+ wocky_porter_acknowledge_iq (wocky_session_get_porter (conn->session),
+ iq, NULL);
}
static void
add_feature_node (gpointer namespace,
gpointer result_query)
{
- LmMessageNode *feature_node;
+ WockyNode *feature_node;
- feature_node = lm_message_node_add_child (result_query, "feature",
+ feature_node = wocky_node_add_child_with_content (result_query, "feature",
NULL);
- lm_message_node_set_attribute (feature_node, "var", namespace);
+ wocky_node_set_attribute (feature_node, "var", namespace);
}
static void
add_identity_node (const GabbleDiscoIdentity *identity,
gpointer result_query)
{
- LmMessageNode *identity_node;
+ WockyNode *identity_node;
- identity_node = lm_message_node_add_child
+ identity_node = wocky_node_add_child_with_content
(result_query, "identity", NULL);
- lm_message_node_set_attribute (identity_node, "category", identity->category);
- lm_message_node_set_attribute (identity_node, "type", identity->type);
+ wocky_node_set_attribute (identity_node, "category", identity->category);
+ wocky_node_set_attribute (identity_node, "type", identity->type);
if (identity->lang)
- lm_message_node_set_attribute (identity_node, "lang", identity->lang);
+ wocky_node_set_attribute (identity_node, "lang", identity->lang);
if (identity->name)
- lm_message_node_set_attribute (identity_node, "name", identity->name);
+ wocky_node_set_attribute (identity_node, "name", identity->name);
}
/**
@@ -2722,8 +2651,8 @@ iq_disco_cb (WockyPorter *porter,
if (features == NULL && tp_strdiff (suffix, BUNDLE_PMUC_V1))
{
- _gabble_connection_send_iq_error (self, stanza,
- XMPP_ERROR_ITEM_NOT_FOUND, NULL);
+ wocky_porter_send_iq_error (porter, stanza,
+ WOCKY_XMPP_ERROR_ITEM_NOT_FOUND, NULL);
}
else
{
@@ -2764,37 +2693,6 @@ iq_version_cb (WockyPorter *porter, WockyStanza *stanza, gpointer user_data)
}
/**
- * iq_unknown_cb
- *
- * Called by Wocky when we get an incoming <iq>. This handler is
- * at a lower priority than the others, and should reply with an error
- * about unsupported get/set attempts.
- */
-static gboolean
-iq_unknown_cb (WockyPorter *porter,
- WockyStanza *stanza,
- gpointer user_data)
-{
- GabbleConnection *conn = GABBLE_CONNECTION (user_data);
- WockyStanzaSubType subtype;
-
- wocky_stanza_get_type_info (stanza, NULL, &subtype);
-
- switch (subtype)
- {
- case WOCKY_STANZA_SUB_TYPE_GET:
- case WOCKY_STANZA_SUB_TYPE_SET:
- _gabble_connection_send_iq_error (conn, stanza,
- XMPP_ERROR_SERVICE_UNAVAILABLE, NULL);
- return TRUE;
- default:
- break;
- }
-
- return FALSE;
-}
-
-/**
* set_status_to_connected
*
* Stage 4 of connecting, this function is called once all the events we were
@@ -2857,7 +2755,7 @@ connection_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *result,
+ WockyNode *result,
GError *disco_error,
gpointer user_data)
{
@@ -2881,19 +2779,19 @@ connection_disco_cb (GabbleDisco *disco,
}
else
{
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *child;
NODE_DEBUG (result, "got");
- for (i = node_iter (result); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, result, NULL, NULL);
+ while (wocky_node_iter_next (&i, &child))
{
- LmMessageNode *child = node_iter_data (i);
-
if (0 == strcmp (child->name, "identity"))
{
- const gchar *category = lm_message_node_get_attribute (child,
+ const gchar *category = wocky_node_get_attribute (child,
"category");
- const gchar *type = lm_message_node_get_attribute (child, "type");
+ const gchar *type = wocky_node_get_attribute (child, "type");
if (!tp_strdiff (category, "pubsub") &&
!tp_strdiff (type, "pep"))
@@ -2904,7 +2802,7 @@ connection_disco_cb (GabbleDisco *disco,
}
else if (0 == strcmp (child->name, "feature"))
{
- const gchar *var = lm_message_node_get_attribute (child, "var");
+ const gchar *var = wocky_node_get_attribute (child, "var");
if (var == NULL)
continue;
@@ -3811,29 +3709,29 @@ gabble_connection_ensure_capabilities (GabbleConnection *self,
gboolean
gabble_connection_send_presence (GabbleConnection *conn,
- LmMessageSubType sub_type,
+ WockyStanzaSubType sub_type,
const gchar *contact,
const gchar *status,
GError **error)
{
- LmMessage *message;
+ WockyStanza *message;
gboolean result;
- message = lm_message_new_with_sub_type (contact,
- LM_MESSAGE_TYPE_PRESENCE,
- sub_type);
+ message = wocky_stanza_build (WOCKY_STANZA_TYPE_PRESENCE, sub_type,
+ NULL, contact,
+ NULL);
- if (LM_MESSAGE_SUB_TYPE_SUBSCRIBE == sub_type)
+ if (WOCKY_STANZA_SUB_TYPE_SUBSCRIBE == sub_type)
lm_message_node_add_own_nick (
wocky_stanza_get_top_node (message), conn);
if (!tp_str_empty (status))
- lm_message_node_add_child (
+ wocky_node_add_child_with_content (
wocky_stanza_get_top_node (message), "status", status);
result = _gabble_connection_send (conn, message, error);
- lm_message_unref (message);
+ g_object_unref (message);
return result;
}
diff --git a/src/connection.h b/src/connection.h
index e8519d6f1..1c783e03f 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -25,19 +25,16 @@
#include <dbus/dbus-glib.h>
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/contacts-mixin.h>
#include <telepathy-glib/presence-mixin.h>
#include <telepathy-glib/dbus-properties-mixin.h>
#include <telepathy-glib/dbus.h>
-#include <wocky/wocky-session.h>
-#include <wocky/wocky-pep-service.h>
+#include <wocky/wocky.h>
#include "gabble/connection.h"
#include "gabble/capabilities.h"
-#include "error.h"
#ifdef ENABLE_FILE_TRANSFER
#include "ft-manager.h"
#endif
@@ -92,11 +89,12 @@ typedef struct _GabbleConnectionPrivate GabbleConnectionPrivate;
typedef struct _GabbleConnectionMailNotificationPrivate GabbleConnectionMailNotificationPrivate;
typedef struct _GabbleConnectionPresencePrivate GabbleConnectionPresencePrivate;
-typedef LmHandlerResult (*GabbleConnectionMsgReplyFunc) (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
- GObject *object,
- gpointer user_data);
+typedef void (*GabbleConnectionMsgReplyFunc) (
+ GabbleConnection *conn,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
+ GObject *object,
+ gpointer user_data);
typedef enum {
/* The JID could be a "global" JID, or a MUC room member. We'll assume
@@ -126,8 +124,6 @@ struct _GabbleConnection {
/* DBus daemon instance */
TpDBusDaemon *daemon;
- /* loudmouth connection */
- LmConnection *lmconn;
WockySession *session;
/* channel factories borrowed from TpBaseConnection's list */
@@ -214,15 +210,13 @@ WockyPorter *gabble_connection_dup_porter (GabbleConnection *conn);
gboolean _gabble_connection_set_properties_from_account (
GabbleConnection *conn, const gchar *account, GError **error);
-gboolean _gabble_connection_send (GabbleConnection *conn, LmMessage *msg,
+gboolean _gabble_connection_send (GabbleConnection *conn, WockyStanza *msg,
GError **error);
gboolean _gabble_connection_send_with_reply (GabbleConnection *conn,
- LmMessage *msg, GabbleConnectionMsgReplyFunc reply_func, GObject *object,
+ WockyStanza *msg, GabbleConnectionMsgReplyFunc reply_func, GObject *object,
gpointer user_data, GError **error);
void _gabble_connection_acknowledge_set_iq (GabbleConnection *conn,
- LmMessage *iq);
-void _gabble_connection_send_iq_error (GabbleConnection *conn,
- LmMessage *message, GabbleXmppError error, const gchar *errmsg);
+ WockyStanza *iq);
void gabble_connection_update_last_use (GabbleConnection *conn);
const char *_gabble_connection_find_conference_server (GabbleConnection *);
@@ -233,7 +227,7 @@ void gabble_connection_ensure_capabilities (GabbleConnection *self,
const GabbleCapabilitySet *ensured);
gboolean gabble_connection_send_presence (GabbleConnection *conn,
- LmMessageSubType sub_type, const gchar *contact, const gchar *status,
+ WockyStanzaSubType sub_type, const gchar *contact, const gchar *status,
GError **error);
gboolean gabble_connection_send_capabilities (GabbleConnection *self,
@@ -243,7 +237,7 @@ gboolean gabble_connection_request_decloak (GabbleConnection *self,
const gchar *to, const gchar *reason, GError **error);
void gabble_connection_fill_in_caps (GabbleConnection *self,
- LmMessage *presence_message);
+ WockyStanza *presence_message);
gboolean _gabble_connection_invisible_privacy_list_set_active (
GabbleConnection *self,
diff --git a/src/debug.h b/src/debug.h
index 07d64096f..83bf43247 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -4,8 +4,7 @@
#include "config.h"
#include <glib.h>
-#include <wocky/wocky-stanza.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
G_BEGIN_DECLS
@@ -85,7 +84,7 @@ G_END_DECLS
# define NODE_DEBUG(n, s) \
G_STMT_START { \
- gchar *debug_tmp = lm_message_node_to_string (n); \
+ gchar *debug_tmp = wocky_node_to_string (n); \
gabble_log (G_LOG_LEVEL_DEBUG, DEBUG_FLAG, "%s: %s:\n%s", G_STRFUNC, s, debug_tmp); \
g_free (debug_tmp); \
} G_STMT_END
@@ -110,7 +109,7 @@ STANZA_DEBUG (
static inline void
NODE_DEBUG (
- LmMessageNode *node,
+ WockyNode *node,
const gchar *format,
...)
{
diff --git a/src/disco.c b/src/disco.c
index cc3c3b6f8..6f142a4e1 100644
--- a/src/disco.c
+++ b/src/disco.c
@@ -382,35 +382,28 @@ disco_type_to_xmlns (GabbleDiscoType type)
return NULL;
}
-static LmHandlerResult
-request_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
- LmMessage *reply_msg, GObject *object, gpointer user_data)
+static void
+request_reply_cb (GabbleConnection *conn, WockyStanza *sent_msg,
+ WockyStanza *reply_msg, GObject *object, gpointer user_data)
{
GabbleDiscoRequest *request = (GabbleDiscoRequest *) user_data;
GabbleDisco *disco = GABBLE_DISCO (object);
GabbleDiscoPrivate *priv = disco->priv;
- LmMessageNode *query_node;
+ WockyNode *query_node;
GError *err = NULL;
g_assert (request);
if (!g_list_find (priv->requests, request))
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return;
- query_node = lm_message_node_get_child_with_namespace (
+ query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg),
"query", disco_type_to_xmlns (request->type));
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &err, NULL, NULL))
{
- err = gabble_message_get_xmpp_error (reply_msg);
-
- if (err == NULL)
- {
- err = g_error_new (GABBLE_DISCO_ERROR,
- GABBLE_DISCO_ERROR_UNKNOWN,
- "an unknown error occurred");
- }
+ /* pass */
}
else if (NULL == query_node)
{
@@ -424,8 +417,6 @@ request_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
if (err)
g_error_free (err);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -487,8 +478,8 @@ gabble_disco_request_with_timeout (GabbleDisco *self, GabbleDiscoType type,
{
GabbleDiscoPrivate *priv = self->priv;
GabbleDiscoRequest *request;
- LmMessage *msg;
- LmMessageNode *lm_node;
+ WockyStanza *msg;
+ WockyNode *lm_node;
request = g_slice_new0 (GabbleDiscoRequest);
request->disco = self;
@@ -507,30 +498,29 @@ gabble_disco_request_with_timeout (GabbleDisco *self, GabbleDiscoType type,
request, request->jid);
priv->requests = g_list_prepend (priv->requests, request);
- msg = lm_message_new_with_sub_type (jid, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_GET);
- lm_node = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "query", NULL);
-
- lm_message_node_set_attribute (lm_node, "xmlns", disco_type_to_xmlns (type));
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_GET,
+ NULL, jid,
+ '(', "query", ':', disco_type_to_xmlns (type),
+ '*', &lm_node,
+ ')', NULL);
if (node)
{
- lm_message_node_set_attribute (lm_node, "node", node);
+ wocky_node_set_attribute (lm_node, "node", node);
}
if (! _gabble_connection_send_with_reply (priv->connection, msg,
request_reply_cb, G_OBJECT(self), request, error))
{
delete_request (request);
- lm_message_unref (msg);
+ g_object_unref (msg);
return NULL;
}
else
{
request->timer_id =
g_timeout_add_seconds (timeout, timeout_request, request);
- lm_message_unref (msg);
+ g_object_unref (msg);
return request;
}
}
@@ -573,15 +563,15 @@ item_info_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *result,
+ WockyNode *result,
GError *error,
gpointer user_data)
{
- LmMessageNode *identity, *value_node;
+ WockyNode *identity, *value_node, *feature;
const char *category, *type, *var, *name, *value;
GHashTable *keys;
GabbleDiscoItem item;
- NodeIter i;
+ WockyNodeIter i;
GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) user_data;
@@ -593,19 +583,19 @@ item_info_cb (GabbleDisco *disco,
goto done;
}
- identity = lm_message_node_get_child (result, "identity");
+ identity = wocky_node_get_child (result, "identity");
if (NULL == identity)
goto done;
- name = lm_message_node_get_attribute (identity, "name");
+ name = wocky_node_get_attribute (identity, "name");
if (NULL == name)
goto done;
- category = lm_message_node_get_attribute (identity, "category");
+ category = wocky_node_get_attribute (identity, "category");
if (NULL == category)
goto done;
- type = lm_message_node_get_attribute (identity, "type");
+ type = wocky_node_get_attribute (identity, "type");
if (NULL == type)
goto done;
@@ -614,38 +604,34 @@ item_info_cb (GabbleDisco *disco,
keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- for (i = node_iter (result); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, result, NULL, NULL);
+ while (wocky_node_iter_next (&i, &feature))
{
- LmMessageNode *feature = node_iter_data (i);
-
if (0 == strcmp (feature->name, "feature"))
{
- var = lm_message_node_get_attribute (feature, "var");
+ var = wocky_node_get_attribute (feature, "var");
if (var)
g_hash_table_insert (keys, g_strdup (var), NULL);
}
else if (0 == strcmp (feature->name, "x"))
{
- if (lm_message_node_has_namespace (feature, NS_X_DATA, NULL))
+ if (wocky_node_has_ns (feature, NS_X_DATA))
{
- NodeIter j;
+ WockyNodeIter j;
+ WockyNode *field;
- for (j = node_iter (feature); j; j = node_iter_next (j))
+ wocky_node_iter_init (&j, feature, "field", NULL);
+ while (wocky_node_iter_next (&j, &field))
{
- LmMessageNode *field = node_iter_data (j);
-
- if (0 != strcmp (field->name, "field"))
- continue;
-
- var = lm_message_node_get_attribute (field, "var");
+ var = wocky_node_get_attribute (field, "var");
if (NULL == var)
continue;
- value_node = lm_message_node_get_child (field, "value");
+ value_node = wocky_node_get_child (field, "value");
if (NULL == value_node)
continue;
- value = lm_message_node_get_value (value_node);
+ value = value_node->content;
if (NULL == value)
continue;
@@ -723,14 +709,15 @@ disco_items_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *result,
+ WockyNode *result,
GError *error,
gpointer user_data)
{
const char *item_jid;
gpointer key, value;
GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) user_data;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *item;
pipeline->list_request = NULL;
@@ -740,14 +727,10 @@ disco_items_cb (GabbleDisco *disco,
goto out;
}
- for (i = node_iter (result); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, result, "item", NULL);
+ while (wocky_node_iter_next (&i, &item))
{
- LmMessageNode *item = node_iter_data (i);
-
- if (0 != strcmp (item->name, "item"))
- continue;
-
- item_jid = lm_message_node_get_attribute (item, "jid");
+ item_jid = wocky_node_get_attribute (item, "jid");
if (NULL != item_jid &&
!g_hash_table_lookup_extended (pipeline->remaining_items, item_jid,
diff --git a/src/disco.h b/src/disco.h
index cf937d19b..3a47f31a3 100644
--- a/src/disco.h
+++ b/src/disco.h
@@ -25,7 +25,7 @@
#define __GABBLE_DISCO_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
#include "types.h"
@@ -83,7 +83,7 @@ struct _GabbleDisco {
};
typedef void (*GabbleDiscoCb)(GabbleDisco *self, GabbleDiscoRequest *request,
- const gchar *jid, const gchar *node, LmMessageNode *query_result,
+ const gchar *jid, const gchar *node, WockyNode *query_result,
GError* error, gpointer user_data);
GabbleDisco *gabble_disco_new (GabbleConnection *);
diff --git a/src/error.c b/src/error.c
index 57774e7c9..e79ddef32 100644
--- a/src/error.c
+++ b/src/error.c
@@ -27,501 +27,7 @@
#include "namespaces.h"
#include "util.h"
-#include <wocky/wocky-auth-registry.h>
-#include <wocky/wocky-auth-registry-enumtypes.h>
-#include <wocky/wocky-connector.h>
-#include <wocky/wocky-connector-enumtypes.h>
-#include <wocky/wocky-tls.h>
-#include <wocky/wocky-tls-enumtypes.h>
-#include <wocky/wocky-xmpp-error.h>
-#include <wocky/wocky-xmpp-error-enumtypes.h>
-
-#define MAX_LEGACY_ERRORS 3
-
-typedef struct {
- const gchar *name;
- const gchar *description;
- const gchar *type;
- guint specialises;
- const gchar *namespace;
- const guint16 legacy_errors[MAX_LEGACY_ERRORS];
-} XmppErrorSpec;
-
-static const XmppErrorSpec xmpp_errors[NUM_XMPP_ERRORS] =
-{
- {
- "undefined-condition",
- "application-specific condition",
- NULL,
- 0,
- NS_XMPP_STANZAS,
- { 500, 0, },
- },
-
- {
- "redirect",
- "the recipient or server is redirecting requests for this information "
- "to another entity",
- "modify",
- 0,
- NS_XMPP_STANZAS,
- { 302, 0, },
- },
-
- {
- "gone",
- "the recipient or server can no longer be contacted at this address",
- "modify",
- 0,
- NS_XMPP_STANZAS,
- { 302, 0, },
- },
-
- {
- "bad-request",
- "the sender has sent XML that is malformed or that cannot be processed",
- "modify",
- 0,
- NS_XMPP_STANZAS,
- { 400, 0, },
- },
- {
- "unexpected-request",
- "the recipient or server understood the request but was not expecting "
- "it at this time",
- "wait",
- 0,
- NS_XMPP_STANZAS,
- { 400, 0, },
- },
- {
- "jid-malformed",
- "the sending entity has provided or communicated an XMPP address or "
- "aspect thereof (e.g., a resource identifier) that does not adhere "
- "to the syntax defined in Addressing Scheme (Section 3)",
- "modify",
- 0,
- NS_XMPP_STANZAS,
- { 400, 0, },
- },
-
- {
- "not-authorized",
- "the sender must provide proper credentials before being allowed to "
- "perform the action, or has provided improper credentials",
- "auth",
- 0,
- NS_XMPP_STANZAS,
- { 401, 0, },
- },
-
- {
- "payment-required",
- "the requesting entity is not authorized to access the requested "
- "service because payment is required",
- "auth",
- 0,
- NS_XMPP_STANZAS,
- { 402, 0, },
- },
-
- {
- "forbidden",
- "the requesting entity does not possess the required permissions to "
- "perform the action",
- "auth",
- 0,
- NS_XMPP_STANZAS,
- { 403, 0, },
- },
-
- {
- "item-not-found",
- "the addressed JID or item requested cannot be found",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 404, 0, },
- },
- {
- "recipient-unavailable",
- "the intended recipient is temporarily unavailable",
- "wait",
- 0,
- NS_XMPP_STANZAS,
- { 404, 0, },
- },
- {
- "remote-server-not-found",
- "a remote server or service specified as part or all of the JID of the "
- "intended recipient (or required to fulfill a request) could not be "
- "contacted within a reasonable amount of time",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 404, 0, },
- },
-
- {
- "not-allowed",
- "the recipient or server does not allow any entity to perform the action",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 405, 0, },
- },
-
- {
- "not-acceptable",
- "the recipient or server understands the request but is refusing to "
- "process it because it does not meet criteria defined by the recipient "
- "or server (e.g., a local policy regarding acceptable words in messages)",
- "modify",
- 0,
- NS_XMPP_STANZAS,
- { 406, 0, },
- },
-
- {
- "registration-required",
- "the requesting entity is not authorized to access the requested service "
- "because registration is required",
- "auth",
- 0,
- NS_XMPP_STANZAS,
- { 407, 0, },
- },
- {
- "subscription-required",
- "the requesting entity is not authorized to access the requested service "
- "because a subscription is required",
- "auth",
- 0,
- NS_XMPP_STANZAS,
- { 407, 0, },
- },
-
- {
- "remote-server-timeout",
- "a remote server or service specified as part or all of the JID of the "
- "intended recipient (or required to fulfill a request) could not be "
- "contacted within a reasonable amount of time",
- "wait",
- 0,
- NS_XMPP_STANZAS,
- { 408, 504, 0, },
- },
-
- {
- "conflict",
- "access cannot be granted because an existing resource or session exists "
- "with the same name or address",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 409, 0, },
- },
-
- {
- "internal-server-error",
- "the server could not process the stanza because of a misconfiguration "
- "or an otherwise-undefined internal server error",
- "wait",
- 0,
- NS_XMPP_STANZAS,
- { 500, 0, },
- },
- {
- "resource-constraint",
- "the server or recipient lacks the system resources necessary to service "
- "the request",
- "wait",
- 0,
- NS_XMPP_STANZAS,
- { 500, 0, },
- },
-
- {
- "feature-not-implemented",
- "the feature requested is not implemented by the recipient or server and "
- "therefore cannot be processed",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 501, 0, },
- },
-
- {
- "service-unavailable",
- "the server or recipient does not currently provide the requested "
- "service",
- "cancel",
- 0,
- NS_XMPP_STANZAS,
- { 502, 503, 510, },
- },
-
- {
- "out-of-order",
- "the request cannot occur at this point in the state machine",
- "cancel",
- XMPP_ERROR_UNEXPECTED_REQUEST,
- NS_JINGLE_ERRORS,
- { 0, },
- },
-
- {
- "unknown-session",
- "the 'sid' attribute specifies a session that is unknown to the "
- "recipient",
- "cancel",
- XMPP_ERROR_ITEM_NOT_FOUND,
- NS_JINGLE_ERRORS,
- { 0, },
- },
-
- {
- "tie-break",
- "The request is rejected because it was sent while the initiator was "
- "awaiting a reply on a similar request.",
- "cancel",
- XMPP_ERROR_CONFLICT,
- NS_JINGLE_ERRORS,
- { 0, },
- },
-
- {
- "unsupported-info",
- "The recipient does not support the informational payload of a "
- "session-info action.",
- "cancel",
- XMPP_ERROR_FEATURE_NOT_IMPLEMENTED,
- NS_JINGLE_ERRORS,
- { 0, },
- },
-
- {
- "no-valid-streams",
- "None of the available streams are acceptable.",
- "cancel",
- XMPP_ERROR_BAD_REQUEST,
- NS_SI,
- { 400, 0 },
- },
-
- {
- "bad-profile",
- "The profile is not understood or invalid.",
- "modify",
- XMPP_ERROR_BAD_REQUEST,
- NS_SI,
- { 400, 0 },
- },
-};
-
-
-GabbleXmppErrorType
-gabble_xmpp_error_type_to_enum (const gchar *error_type)
-{
- if (!tp_strdiff (error_type, "cancel"))
- return XMPP_ERROR_TYPE_CANCEL;
-
- if (!tp_strdiff (error_type, "continue"))
- return XMPP_ERROR_TYPE_CONTINUE;
-
- if (!tp_strdiff (error_type, "modify"))
- return XMPP_ERROR_TYPE_MODIFY;
-
- if (!tp_strdiff (error_type, "auth"))
- return XMPP_ERROR_TYPE_AUTH;
-
- if (!tp_strdiff (error_type, "wait"))
- return XMPP_ERROR_TYPE_WAIT;
-
- return XMPP_ERROR_TYPE_UNDEFINED;
-}
-
-
-GQuark
-gabble_xmpp_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("gabble-xmpp-error");
- return quark;
-}
-
-GabbleXmppError
-gabble_xmpp_error_from_node (LmMessageNode *error_node,
- GabbleXmppErrorType *type_out)
-{
- gint i, j;
- const gchar *error_code_str;
-
- g_return_val_if_fail (error_node != NULL, XMPP_ERROR_UNDEFINED_CONDITION);
-
- /* First, try to look it up the modern way */
- if (node_iter (error_node))
- {
- if (type_out != NULL)
- *type_out = gabble_xmpp_error_type_to_enum (
- lm_message_node_get_attribute (error_node, "type"));
-
- /* we loop backwards because the most specific errors are the larger
- * numbers; the >= 0 test is OK because i is signed */
- for (i = NUM_XMPP_ERRORS - 1; i >= 0; i--)
- {
- if (lm_message_node_get_child_with_namespace (error_node,
- xmpp_errors[i].name, xmpp_errors[i].namespace))
- {
- return i;
- }
- }
- }
-
- /* Ok, do it the legacy way */
- error_code_str = lm_message_node_get_attribute (error_node, "code");
- if (error_code_str)
- {
- gint error_code;
-
- error_code = atoi (error_code_str);
-
- /* skip UNDEFINED_CONDITION, we want code 500 to be translated
- * to INTERNAL_SERVER_ERROR */
- for (i = 1; i < NUM_XMPP_ERRORS; i++)
- {
- const XmppErrorSpec *spec = &xmpp_errors[i];
-
- for (j = 0; j < MAX_LEGACY_ERRORS; j++)
- {
- gint cur_code = spec->legacy_errors[j];
- if (cur_code == 0)
- break;
-
- if (cur_code == error_code)
- {
- if (type_out != NULL)
- *type_out = gabble_xmpp_error_type_to_enum (spec->type);
-
- return i;
- }
- }
- }
- }
-
- if (type_out != NULL)
- *type_out = XMPP_ERROR_TYPE_UNDEFINED;
-
- return XMPP_ERROR_UNDEFINED_CONDITION;
-}
-
-static GError *
-gabble_xmpp_error_to_g_error (GabbleXmppError error)
-{
- if (error >= NUM_XMPP_ERRORS)
- return g_error_new (GABBLE_XMPP_ERROR, XMPP_ERROR_UNDEFINED_CONDITION,
- "Unknown or invalid XMPP error");
-
- return g_error_new (GABBLE_XMPP_ERROR,
- error,
- "%s", xmpp_errors[error].description);
-}
-
-/*
- * See RFC 3920: 4.7 Stream Errors, 9.3 Stanza Errors.
- */
-LmMessageNode *
-gabble_xmpp_error_to_node (GabbleXmppError error,
- LmMessageNode *parent_node,
- const gchar *errmsg)
-{
- const XmppErrorSpec *spec, *extra;
- LmMessageNode *error_node, *node;
- gchar str[6];
-
- g_return_val_if_fail (error != XMPP_ERROR_UNDEFINED_CONDITION &&
- error < NUM_XMPP_ERRORS, NULL);
-
- if (xmpp_errors[error].specialises)
- {
- extra = &xmpp_errors[error];
- spec = &xmpp_errors[extra->specialises];
- }
- else
- {
- extra = NULL;
- spec = &xmpp_errors[error];
- }
-
- error_node = lm_message_node_add_child (parent_node, "error", NULL);
-
- sprintf (str, "%d", spec->legacy_errors[0]);
- lm_message_node_set_attribute (error_node, "code", str);
-
- if (spec->type)
- {
- lm_message_node_set_attribute (error_node, "type", spec->type);
- }
-
- node = lm_message_node_add_child (error_node, spec->name, NULL);
- lm_message_node_set_attribute (node, "xmlns", NS_XMPP_STANZAS);
-
- if (extra != NULL)
- {
- node = lm_message_node_add_child (error_node, extra->name, NULL);
- lm_message_node_set_attribute (node, "xmlns", extra->namespace);
- }
-
- if (NULL != errmsg)
- lm_message_node_add_child (error_node, "text", errmsg);
-
- return error_node;
-}
-
-const gchar *
-gabble_xmpp_error_string (GabbleXmppError error)
-{
- if (error < NUM_XMPP_ERRORS)
- return xmpp_errors[error].name;
- else
- return NULL;
-}
-
-const gchar *
-gabble_xmpp_error_description (GabbleXmppError error)
-{
- if (error < NUM_XMPP_ERRORS)
- return xmpp_errors[error].description;
- else
- return NULL;
-}
-
-GError *
-gabble_message_get_xmpp_error (LmMessage *msg)
-{
- g_return_val_if_fail (msg != NULL, NULL);
-
- if (lm_message_get_sub_type (msg) == LM_MESSAGE_SUB_TYPE_ERROR)
- {
- LmMessageNode *error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (msg), "error");
-
- if (error_node != NULL)
- {
- return gabble_xmpp_error_to_g_error
- (gabble_xmpp_error_from_node (error_node, NULL));
- }
- else
- {
- return g_error_new (GABBLE_XMPP_ERROR,
- XMPP_ERROR_UNDEFINED_CONDITION, "Unknown or invalid XMPP error");
- }
- }
-
- /* no error */
- return NULL;
-}
+#include <wocky/wocky.h>
static inline TpError
set_conn_reason (TpConnectionStatusReason *p,
diff --git a/src/error.h b/src/error.h
index 58c303d80..2d7d6c15f 100644
--- a/src/error.h
+++ b/src/error.h
@@ -23,77 +23,4 @@
#include <gabble/gabble.h>
-#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
-typedef enum {
- XMPP_ERROR_TYPE_UNDEFINED = 0,
- XMPP_ERROR_TYPE_CANCEL,
- XMPP_ERROR_TYPE_CONTINUE,
- XMPP_ERROR_TYPE_MODIFY,
- XMPP_ERROR_TYPE_AUTH,
- XMPP_ERROR_TYPE_WAIT,
-} GabbleXmppErrorType;
-
-typedef enum {
- XMPP_ERROR_UNDEFINED_CONDITION = 0, /* 500 */
- XMPP_ERROR_REDIRECT, /* 302 */
- XMPP_ERROR_GONE, /* 302 */
-
- XMPP_ERROR_BAD_REQUEST, /* 400 */
- XMPP_ERROR_UNEXPECTED_REQUEST, /* 400 */
- XMPP_ERROR_JID_MALFORMED, /* 400 */
-
- XMPP_ERROR_NOT_AUTHORIZED, /* 401 */
-
- XMPP_ERROR_PAYMENT_REQUIRED, /* 402 */
-
- XMPP_ERROR_FORBIDDEN, /* 403 */
-
- XMPP_ERROR_ITEM_NOT_FOUND, /* 404 */
- XMPP_ERROR_RECIPIENT_UNAVAILABLE, /* 404 */
- XMPP_ERROR_REMOTE_SERVER_NOT_FOUND, /* 404 */
-
- XMPP_ERROR_NOT_ALLOWED, /* 405 */
-
- XMPP_ERROR_NOT_ACCEPTABLE, /* 406 */
-
- XMPP_ERROR_REGISTRATION_REQUIRED, /* 407 */
- XMPP_ERROR_SUBSCRIPTION_REQUIRED, /* 407 */
-
- XMPP_ERROR_REMOTE_SERVER_TIMEOUT, /* 408, 504 */
-
- XMPP_ERROR_CONFLICT, /* 409 */
-
- XMPP_ERROR_INTERNAL_SERVER_ERROR, /* 500 */
- XMPP_ERROR_RESOURCE_CONSTRAINT, /* 500 */
-
- XMPP_ERROR_FEATURE_NOT_IMPLEMENTED, /* 501 */
-
- XMPP_ERROR_SERVICE_UNAVAILABLE, /* 502, 503, 510 */
-
- XMPP_ERROR_JINGLE_OUT_OF_ORDER,
- XMPP_ERROR_JINGLE_UNKNOWN_SESSION,
- XMPP_ERROR_JINGLE_TIE_BREAK,
- XMPP_ERROR_JINGLE_UNSUPPORTED_INFO,
-
- XMPP_ERROR_SI_NO_VALID_STREAMS,
- XMPP_ERROR_SI_BAD_PROFILE,
-
- NUM_XMPP_ERRORS,
-} GabbleXmppError;
-
-GQuark gabble_xmpp_error_quark (void);
-#define GABBLE_XMPP_ERROR (gabble_xmpp_error_quark ())
-
-GabbleXmppError gabble_xmpp_error_from_node (LmMessageNode *error_node,
- GabbleXmppErrorType *type_out);
-LmMessageNode *gabble_xmpp_error_to_node (GabbleXmppError error,
- LmMessageNode *parent_node, const gchar *errmsg);
-const gchar *gabble_xmpp_error_string (GabbleXmppError error);
-const gchar *gabble_xmpp_error_description (GabbleXmppError error);
-GError *gabble_message_get_xmpp_error (LmMessage *msg);
-
-GabbleXmppErrorType gabble_xmpp_error_type_to_enum (const gchar *error_type);
-
#endif /* __GABBLE_ERROR_H__ */
diff --git a/src/ft-channel.c b/src/ft-channel.c
index ecf6ff14d..5dec2be53 100644
--- a/src/ft-channel.c
+++ b/src/ft-channel.c
@@ -37,8 +37,6 @@
#define DEBUG_FLAG GABBLE_DEBUG_FT
#include "debug.h"
-#include <loudmouth/loudmouth.h>
-
#include <gibber/gibber-listener.h>
#include <gibber/gibber-transport.h>
#include <gibber/gibber-unix-transport.h> /* just for the feature-test */
@@ -1319,12 +1317,13 @@ set_gtalk_file_collection (
static void
bytestream_negotiate_cb (GabbleBytestreamIface *bytestream,
const gchar *stream_id,
- LmMessage *msg,
+ WockyStanza *msg,
GObject *object,
gpointer user_data)
{
GabbleFileTransferChannel *self = GABBLE_FILE_TRANSFER_CHANNEL (user_data);
- LmMessageNode *file;
+ WockyNode *si;
+ WockyNode *file = NULL;
if (bytestream == NULL)
{
@@ -1336,17 +1335,20 @@ bytestream_negotiate_cb (GabbleBytestreamIface *bytestream,
return;
}
- file = lm_message_node_find_child (wocky_stanza_get_top_node (msg), "file");
+ si = wocky_node_get_child_ns (wocky_stanza_get_top_node (msg), "si", NS_SI);
+ if (si != NULL)
+ file = wocky_node_get_child_ns (si, "file", NULL);
+
if (file != NULL)
{
- LmMessageNode *range;
+ WockyNode *range;
- range = lm_message_node_get_child_any_ns (file, "range");
+ range = wocky_node_get_child (file, "range");
if (range != NULL)
{
const gchar *offset_str;
- offset_str = lm_message_node_get_attribute (range, "offset");
+ offset_str = wocky_node_get_attribute (range, "offset");
if (offset_str != NULL)
{
self->priv->initial_offset = g_ascii_strtoull (offset_str, NULL,
@@ -1444,8 +1446,8 @@ offer_bytestream (GabbleFileTransferChannel *self, const gchar *jid,
const gchar *resource, GError **error)
{
gboolean result;
- LmMessage *msg;
- LmMessageNode *si_node, *file_node;
+ WockyStanza *msg;
+ WockyNode *si_node, *file_node;
gchar *stream_id, *size_str, *full_jid;
if (resource)
@@ -1465,15 +1467,15 @@ offer_bytestream (GabbleFileTransferChannel *self, const gchar *jid,
msg = gabble_bytestream_factory_make_stream_init_iq (full_jid,
stream_id, NS_FILE_TRANSFER);
- si_node = lm_message_node_get_child_with_namespace (
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si_node != NULL);
size_str = g_strdup_printf ("%" G_GUINT64_FORMAT, self->priv->size);
- file_node = lm_message_node_add_child (si_node, "file", NULL);
- lm_message_node_set_attributes (file_node,
- "xmlns", NS_FILE_TRANSFER,
+ file_node = wocky_node_add_child_with_content (si_node, "file", NULL);
+ file_node->ns = g_quark_from_string (NS_FILE_TRANSFER);
+ wocky_node_set_attributes (file_node,
"name", self->priv->filename,
"size", size_str,
"mime-type", self->priv->content_type,
@@ -1482,7 +1484,7 @@ offer_bytestream (GabbleFileTransferChannel *self, const gchar *jid,
add_metadata_forms (self, file_node);
if (self->priv->content_hash != NULL)
- lm_message_node_set_attribute (file_node, "hash", self->priv->content_hash);
+ wocky_node_set_attribute (file_node, "hash", self->priv->content_hash);
if (self->priv->date != 0)
{
@@ -1499,19 +1501,19 @@ offer_bytestream (GabbleFileTransferChannel *self, const gchar *jid,
strftime (date_str, sizeof (date_str), "%FT%H:%M:%SZ", tm);
#endif
- lm_message_node_set_attribute (file_node, "date", date_str);
+ wocky_node_set_attribute (file_node, "date", date_str);
}
- lm_message_node_add_child (file_node, "desc", self->priv->description);
+ wocky_node_add_child_with_content (file_node, "desc", self->priv->description);
/* we support resume */
- lm_message_node_add_child (file_node, "range", NULL);
+ wocky_node_add_child_with_content (file_node, "range", NULL);
result = gabble_bytestream_factory_negotiate_stream (
self->priv->connection->bytestream_factory, msg, stream_id,
bytestream_negotiate_cb, self, G_OBJECT (self), error);
- lm_message_unref (msg);
+ g_object_unref (msg);
g_free (stream_id);
g_free (size_str);
g_free (full_jid);
@@ -1859,24 +1861,24 @@ bytestream_data_received_cb (GabbleBytestreamIface *stream,
}
static void
-augment_si_reply (LmMessageNode *si,
+augment_si_reply (WockyNode *si,
gpointer user_data)
{
GabbleFileTransferChannel *self = GABBLE_FILE_TRANSFER_CHANNEL (user_data);
- LmMessageNode *file;
+ WockyNode *file;
- file = lm_message_node_add_child (si, "file", NULL);
- lm_message_node_set_attribute (file, "xmlns", NS_FILE_TRANSFER);
+ file = wocky_node_add_child_with_content (si, "file", NULL);
+ file->ns = g_quark_from_string (NS_FILE_TRANSFER);
if (self->priv->initial_offset != 0)
{
- LmMessageNode *range;
+ WockyNode *range;
gchar *offset_str;
- range = lm_message_node_add_child (file, "range", NULL);
+ range = wocky_node_add_child_with_content (file, "range", NULL);
offset_str = g_strdup_printf ("%" G_GUINT64_FORMAT,
self->priv->initial_offset);
- lm_message_node_set_attribute (range, "offset", offset_str);
+ wocky_node_set_attribute (range, "offset", offset_str);
/* Don't set "length" attribute as the default is the length of the file
* from offset to the end which is what we want when resuming a FT. */
diff --git a/src/ft-manager.c b/src/ft-manager.c
index 447813306..0bab5685a 100644
--- a/src/ft-manager.c
+++ b/src/ft-manager.c
@@ -34,13 +34,12 @@
#include "connection.h"
#include "ft-manager.h"
#include "ft-channel.h"
-#include "error.h"
#include "gabble-signals-marshal.h"
#include "namespaces.h"
#include "presence-cache.h"
#include "util.h"
-#include <wocky/wocky-data-form.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/channel-factory-iface.h>
@@ -666,9 +665,9 @@ gabble_ft_manager_type_foreach_channel_class (GType type,
g_hash_table_unref (table);
}
-static LmMessageNode *
+static WockyNode *
hyvaa_vappua (
- LmMessageNode *si_node,
+ WockyNode *si_node,
const gchar **filename,
const gchar **size_str,
GError **error)
@@ -676,17 +675,18 @@ hyvaa_vappua (
#define die_if_null(var, msg) \
if ((var) == NULL) \
{ \
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST, msg); \
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST, \
+ msg); \
return NULL; \
}
- LmMessageNode *file_node = lm_message_node_get_child_with_namespace (si_node,
+ WockyNode *file_node = wocky_node_get_child_ns (si_node,
"file", NS_FILE_TRANSFER);
die_if_null (file_node, "Invalid file transfer SI request: no <file>")
- die_if_null (*filename = lm_message_node_get_attribute (file_node, "name"),
+ die_if_null (*filename = wocky_node_get_attribute (file_node, "name"),
"Invalid file transfer SI request: missing file name")
- die_if_null (*size_str = lm_message_node_get_attribute (file_node, "size"),
+ die_if_null (*size_str = wocky_node_get_attribute (file_node, "size"),
"Invalid file transfer SI request: missing file size")
return file_node;
@@ -747,7 +747,7 @@ extract_service_name (WockyNode *file)
if (field == NULL)
{
- DEBUG ("ServiceName propery not present in data form; odd...");
+ DEBUG ("ServiceName property not present in data form; odd...");
goto out;
}
@@ -802,9 +802,9 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
GabbleBytestreamIface *bytestream,
TpHandle handle,
const gchar *stream_id,
- LmMessage *msg)
+ WockyStanza *msg)
{
- LmMessageNode *si_node, *file_node, *desc_node;
+ WockyNode *si_node, *file_node, *desc_node;
const gchar *filename, *size_str, *content_type, *content_hash, *description;
const gchar *date_str;
gchar *service_name;
@@ -816,7 +816,7 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
gboolean resume_supported;
GError *error = NULL;
- si_node = lm_message_node_get_child_with_namespace (
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si_node != NULL);
@@ -832,24 +832,24 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
size = g_ascii_strtoull (size_str, NULL, 0);
- content_type = lm_message_node_get_attribute (file_node, "mime-type");
+ content_type = wocky_node_get_attribute (file_node, "mime-type");
if (content_type == NULL)
content_type = "application/octet-stream";
/* The hash is always an MD5-sum, if present. */
- content_hash = lm_message_node_get_attribute (file_node, "hash");
+ content_hash = wocky_node_get_attribute (file_node, "hash");
if (content_hash != NULL)
content_hash_type = TP_FILE_HASH_TYPE_MD5;
else
content_hash_type = TP_FILE_HASH_TYPE_NONE;
- desc_node = lm_message_node_get_child (file_node, "desc");
+ desc_node = wocky_node_get_child (file_node, "desc");
if (desc_node != NULL)
- description = lm_message_node_get_value (desc_node);
+ description = desc_node->content;
else
description = NULL;
- date_str = lm_message_node_get_attribute (file_node, "date");
+ date_str = wocky_node_get_attribute (file_node, "date");
if (date_str != NULL)
{
GTimeVal val;
@@ -859,7 +859,7 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
date = val.tv_sec;
}
- resume_supported = (lm_message_node_get_child (file_node, "range") != NULL);
+ resume_supported = (wocky_node_get_child (file_node, "range") != NULL);
/* metadata */
service_name = extract_service_name (file_node);
diff --git a/src/ft-manager.h b/src/ft-manager.h
index c5fef4184..4b7e772c2 100644
--- a/src/ft-manager.h
+++ b/src/ft-manager.h
@@ -64,7 +64,7 @@ GabbleFtManager *gabble_ft_manager_new (GabbleConnection *connection);
void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
GabbleBytestreamIface *bytestream, TpHandle handle, const gchar *stream_id,
- LmMessage *msg);
+ WockyStanza *msg);
#ifdef G_OS_UNIX
/* Slight encapsulation violation: this function isn't portable, but we
diff --git a/src/gabble.c b/src/gabble.c
index fef4454e7..0d2fb6e29 100644
--- a/src/gabble.c
+++ b/src/gabble.c
@@ -32,7 +32,7 @@
#include <telepathy-glib/run.h>
#include <telepathy-glib/util.h>
#include <wocky/wocky.h>
-#include <wocky/wocky-debug.h>
+#include <wocky/wocky.h>
#include "debug.h"
#include "connection-manager.h"
@@ -161,7 +161,10 @@ gabble_main (int argc,
if (g_getenv ("WOCKY_DEBUG") == NULL)
{
redirect_wocky = TRUE;
- wocky_debug_set_flags (DEBUG_XMPP | DEBUG_AUTH | DEBUG_PORTER);
+ wocky_debug_set_flags ( WOCKY_DEBUG_XMPP
+ | WOCKY_DEBUG_AUTH
+ | WOCKY_DEBUG_PORTER
+ );
}
debug_sender = tp_debug_sender_dup ();
diff --git a/src/im-channel.c b/src/im-channel.c
index dba3aedba..d294c3a04 100644
--- a/src/im-channel.c
+++ b/src/im-channel.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <dbus/dbus-glib.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/enums.h>
#include <telepathy-glib/errors.h>
@@ -249,7 +248,7 @@ im_channel_send_gone (GabbleIMChannel *self)
if (chat_states_supported (self, FALSE))
gabble_message_util_send_chat_state (G_OBJECT (self),
GABBLE_CONNECTION (tp_base_channel_get_connection (base)),
- LM_MESSAGE_SUB_TYPE_CHAT, TP_CHANNEL_CHAT_STATE_GONE,
+ WOCKY_STANZA_SUB_TYPE_CHAT, TP_CHANNEL_CHAT_STATE_GONE,
priv->peer_jid, NULL);
priv->send_gone = FALSE;
@@ -650,7 +649,7 @@ gabble_im_channel_set_chat_state (TpSvcChannelInterfaceChatState *iface,
if (gabble_message_util_send_chat_state (G_OBJECT (self),
GABBLE_CONNECTION (base_conn),
- LM_MESSAGE_SUB_TYPE_CHAT, state, priv->peer_jid, &error))
+ WOCKY_STANZA_SUB_TYPE_CHAT, state, priv->peer_jid, &error))
{
priv->send_gone = TRUE;
diff --git a/src/im-factory.c b/src/im-factory.c
index 6932d2201..0459c2dc0 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -24,12 +24,11 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>
-#include <wocky/wocky-c2s-porter.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_IM
@@ -62,7 +61,7 @@ enum
struct _GabbleImFactoryPrivate
{
GabbleConnection *conn;
- LmMessageHandler *message_cb;
+ guint message_cb_id;
GHashTable *channels;
gulong status_changed_id;
@@ -79,8 +78,6 @@ gabble_im_factory_init (GabbleImFactory *self)
self->priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
- self->priv->message_cb = NULL;
-
self->priv->conn = NULL;
self->priv->dispose_has_run = FALSE;
}
@@ -200,13 +197,13 @@ static GabbleIMChannel *get_channel_for_incoming_message (
/**
* im_factory_message_cb:
*
- * Called by loudmouth when we get an incoming <message>.
+ * Called by Wocky when we get an incoming <message>.
*/
-static LmHandlerResult
-im_factory_message_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *message,
- gpointer user_data)
+static gboolean
+im_factory_message_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data)
{
GabbleImFactory *fac = GABBLE_IM_FACTORY (user_data);
const gchar *from, *body, *id;
@@ -220,11 +217,11 @@ im_factory_message_cb (LmMessageHandler *handler,
if (!gabble_message_util_parse_incoming_message (message, &from, &stamp,
&msgtype, &id, &body, &state, &send_error, &delivery_status))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (body == NULL && state == -1)
{
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
/* We don't want to open up a channel for the sole purpose of reporting a
@@ -242,7 +239,7 @@ im_factory_message_cb (LmMessageHandler *handler,
DEBUG ("ignoring message error or chat state notification from '%s': "
"no existing channel", from);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
if (send_error != GABBLE_TEXT_CHANNEL_SEND_NO_ERROR)
@@ -250,7 +247,7 @@ im_factory_message_cb (LmMessageHandler *handler,
if (body == NULL)
{
DEBUG ("ignoring error sending chat state to %s", from);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
DEBUG ("got error sending to %s, msgtype %u, body:\n%s",
@@ -268,7 +265,7 @@ im_factory_message_cb (LmMessageHandler *handler,
_gabble_im_channel_state_receive (chan, (TpChannelChatState) state);
}
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
/**
@@ -428,14 +425,14 @@ gabble_im_factory_close_all (GabbleImFactory *self)
self->priv->status_changed_id = 0;
}
- if (self->priv->message_cb != NULL)
+ if (self->priv->message_cb_id != 0)
{
- DEBUG ("removing callbacks");
- lm_connection_unregister_message_handler (self->priv->conn->lmconn,
- self->priv->message_cb, LM_MESSAGE_TYPE_MESSAGE);
- }
+ WockyPorter *porter = gabble_connection_dup_porter (self->priv->conn);
- tp_clear_pointer (&self->priv->message_cb, lm_message_handler_unref);
+ wocky_porter_unregister_handler (porter, self->priv->message_cb_id);
+ self->priv->message_cb_id = 0;
+ g_object_unref (porter);
+ }
}
@@ -447,17 +444,6 @@ connection_status_changed_cb (GabbleConnection *conn,
{
switch (status)
{
- case TP_CONNECTION_STATUS_CONNECTING:
- DEBUG ("adding callbacks");
- g_assert (self->priv->message_cb == NULL);
-
- self->priv->message_cb = lm_message_handler_new (im_factory_message_cb,
- self, NULL);
- lm_connection_register_message_handler (self->priv->conn->lmconn,
- self->priv->message_cb, LM_MESSAGE_TYPE_MESSAGE,
- LM_HANDLER_PRIORITY_LAST);
- break;
-
case TP_CONNECTION_STATUS_DISCONNECTED:
gabble_im_factory_close_all (self);
break;
@@ -526,6 +512,12 @@ porter_available_cb (
GabbleImFactory *self = GABBLE_IM_FACTORY (user_data);
gchar *stream_server;
+ DEBUG ("adding callbacks");
+ self->priv->message_cb_id = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MIN, im_factory_message_cb, self,
+ NULL);
+
g_object_get (conn, "stream-server", &stream_server, NULL);
if (!tp_strdiff (stream_server, "chat.facebook.com"))
diff --git a/src/jingle-content.c b/src/jingle-content.c
index 23f5ea0ac..1f37d3d6d 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -24,8 +24,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
#include "connection.h"
@@ -446,7 +444,8 @@ produce_senders (JingleContentSenders senders)
}
-#define SET_BAD_REQ(txt) g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST, txt)
+#define SET_BAD_REQ(txt) \
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST, txt)
static void
new_transport_candidates_cb (GabbleJingleTransportIface *trans,
@@ -468,10 +467,10 @@ transport_created (GabbleJingleContent *c)
static void
-parse_description (GabbleJingleContent *c, LmMessageNode *desc_node,
+parse_description (GabbleJingleContent *c, WockyNode *desc_node,
GError **error)
{
- void (*virtual_method)(GabbleJingleContent *, LmMessageNode *,
+ void (*virtual_method)(GabbleJingleContent *, WockyNode *,
GError **) = GABBLE_JINGLE_CONTENT_GET_CLASS (c)->parse_description;
g_assert (virtual_method != NULL);
@@ -483,13 +482,13 @@ send_gtalk4_transport_accept (gpointer user_data)
{
GabbleJingleContent *c = GABBLE_JINGLE_CONTENT (user_data);
GabbleJingleContentPrivate *priv = c->priv;
- LmMessageNode *sess_node, *tnode;
- LmMessage *msg = gabble_jingle_session_new_message (c->session,
+ WockyNode *sess_node, *tnode;
+ WockyStanza *msg = gabble_jingle_session_new_message (c->session,
JINGLE_ACTION_TRANSPORT_ACCEPT, &sess_node);
DEBUG ("Sending Gtalk4 'transport-accept' message to peer");
- tnode = lm_message_node_add_child (sess_node, "transport", NULL);
- lm_message_node_set_attribute (tnode, "xmlns", priv->transport_ns);
+ tnode = wocky_node_add_child_with_content (sess_node, "transport", NULL);
+ tnode->ns = g_quark_from_string (priv->transport_ns);
gabble_jingle_session_send (c->session, msg, NULL, NULL);
@@ -498,22 +497,22 @@ send_gtalk4_transport_accept (gpointer user_data)
void
gabble_jingle_content_parse_add (GabbleJingleContent *c,
- LmMessageNode *content_node, gboolean google_mode, GError **error)
+ WockyNode *content_node, gboolean google_mode, GError **error)
{
GabbleJingleContentPrivate *priv = c->priv;
const gchar *name, *creator, *senders, *disposition;
- LmMessageNode *trans_node, *desc_node;
+ WockyNode *trans_node, *desc_node;
GType transport_type = 0;
GabbleJingleTransportIface *trans = NULL;
JingleDialect dialect = gabble_jingle_session_get_dialect (c->session);
priv->created_by_us = FALSE;
- desc_node = lm_message_node_get_child_any_ns (content_node, "description");
- trans_node = lm_message_node_get_child_any_ns (content_node, "transport");
- creator = lm_message_node_get_attribute (content_node, "creator");
- name = lm_message_node_get_attribute (content_node, "name");
- senders = lm_message_node_get_attribute (content_node, "senders");
+ desc_node = wocky_node_get_child (content_node, "description");
+ trans_node = wocky_node_get_child (content_node, "transport");
+ creator = wocky_node_get_attribute (content_node, "creator");
+ name = wocky_node_get_attribute (content_node, "name");
+ senders = wocky_node_get_attribute (content_node, "senders");
g_assert (priv->transport_ns == NULL);
@@ -578,7 +577,7 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
/* if we didn't set it to google-p2p implicitly already, detect it */
if (transport_type == 0)
{
- const gchar *ns = lm_message_node_get_namespace (trans_node);
+ const gchar *ns = wocky_node_get_ns (trans_node);
transport_type = gabble_jingle_factory_lookup_transport (
c->conn->jingle_factory, ns);
@@ -607,7 +606,7 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
if (*error != NULL)
return;
- disposition = lm_message_node_get_attribute (content_node, "disposition");
+ disposition = wocky_node_get_attribute (content_node, "disposition");
if (disposition == NULL)
disposition = "session";
@@ -687,8 +686,8 @@ gabble_jingle_content_create_share_channel (GabbleJingleContent *self,
const gchar *name)
{
GabbleJingleContentPrivate *priv = self->priv;
- LmMessageNode *sess_node, *channel_node;
- LmMessage *msg = NULL;
+ WockyNode *sess_node, *channel_node;
+ WockyStanza *msg = NULL;
/* Send the info action before creating the channel, in case candidates need
to be sent on the signal emit. It doesn't matter if the channel already
@@ -697,9 +696,9 @@ gabble_jingle_content_create_share_channel (GabbleJingleContent *self,
JINGLE_ACTION_INFO, &sess_node);
DEBUG ("Sending 'info' message to peer : channel %s", name);
- channel_node = lm_message_node_add_child (sess_node, "channel", NULL);
- lm_message_node_set_attribute (channel_node, "xmlns", priv->content_ns);
- lm_message_node_set_attribute (channel_node, "name", name);
+ channel_node = wocky_node_add_child_with_content (sess_node, "channel", NULL);
+ channel_node->ns = g_quark_from_string (priv->content_ns);
+ wocky_node_set_attribute (channel_node, "name", name);
gabble_jingle_session_send (self->session, msg, NULL, NULL);
@@ -710,15 +709,15 @@ void
gabble_jingle_content_send_complete (GabbleJingleContent *self)
{
GabbleJingleContentPrivate *priv = self->priv;
- LmMessageNode *sess_node, *complete_node;
- LmMessage *msg = NULL;
+ WockyNode *sess_node, *complete_node;
+ WockyStanza *msg = NULL;
msg = gabble_jingle_session_new_message (self->session,
JINGLE_ACTION_INFO, &sess_node);
DEBUG ("Sending 'info' message to peer : complete");
- complete_node = lm_message_node_add_child (sess_node, "complete", NULL);
- lm_message_node_set_attribute (complete_node, "xmlns", priv->content_ns);
+ complete_node = wocky_node_add_child_with_content (sess_node, "complete", NULL);
+ complete_node->ns = g_quark_from_string (priv->content_ns);
gabble_jingle_session_send (self->session, msg, NULL, NULL);
@@ -726,19 +725,19 @@ gabble_jingle_content_send_complete (GabbleJingleContent *self)
void
gabble_jingle_content_parse_info (GabbleJingleContent *c,
- LmMessageNode *content_node, GError **error)
+ WockyNode *content_node, GError **error)
{
- LmMessageNode *channel_node;
- LmMessageNode *complete_node;
+ WockyNode *channel_node;
+ WockyNode *complete_node;
- channel_node = lm_message_node_get_child_any_ns (content_node, "channel");
- complete_node = lm_message_node_get_child_any_ns (content_node, "complete");
+ channel_node = wocky_node_get_child (content_node, "channel");
+ complete_node = wocky_node_get_child (content_node, "complete");
DEBUG ("parsing info message : %p - %p", channel_node, complete_node);
if (channel_node)
{
const gchar *name;
- name = lm_message_node_get_attribute (channel_node, "name");
+ name = wocky_node_get_attribute (channel_node, "name");
if (name != NULL)
new_share_channel (c, name);
}
@@ -751,17 +750,17 @@ gabble_jingle_content_parse_info (GabbleJingleContent *c,
void
gabble_jingle_content_parse_accept (GabbleJingleContent *c,
- LmMessageNode *content_node, gboolean google_mode, GError **error)
+ WockyNode *content_node, gboolean google_mode, GError **error)
{
GabbleJingleContentPrivate *priv = c->priv;
const gchar *senders;
- LmMessageNode *trans_node, *desc_node;
+ WockyNode *trans_node, *desc_node;
JingleDialect dialect = gabble_jingle_session_get_dialect (c->session);
JingleContentSenders newsenders;
- desc_node = lm_message_node_get_child_any_ns (content_node, "description");
- trans_node = lm_message_node_get_child_any_ns (content_node, "transport");
- senders = lm_message_node_get_attribute (content_node, "senders");
+ desc_node = wocky_node_get_child (content_node, "description");
+ trans_node = wocky_node_get_child (content_node, "transport");
+ senders = wocky_node_get_attribute (content_node, "senders");
if (GABBLE_IS_JINGLE_MEDIA_RTP (c) &&
JINGLE_IS_GOOGLE_DIALECT (dialect) && trans_node == NULL)
@@ -806,11 +805,11 @@ gabble_jingle_content_parse_accept (GabbleJingleContent *c,
void
gabble_jingle_content_parse_description_info (GabbleJingleContent *c,
- LmMessageNode *content_node, GError **error)
+ WockyNode *content_node, GError **error)
{
GabbleJingleContentPrivate *priv = c->priv;
- LmMessageNode *desc_node;
- desc_node = lm_message_node_get_child_any_ns (content_node, "description");
+ WockyNode *desc_node;
+ desc_node = wocky_node_get_child (content_node, "description");
if (desc_node == NULL)
{
SET_BAD_REQ ("invalid description-info action");
@@ -832,15 +831,15 @@ gabble_jingle_content_parse_description_info (GabbleJingleContent *c,
void
gabble_jingle_content_produce_node (GabbleJingleContent *c,
- LmMessageNode *parent,
+ WockyNode *parent,
gboolean include_description,
gboolean include_transport,
- LmMessageNode **trans_node_out)
+ WockyNode **trans_node_out)
{
GabbleJingleContentPrivate *priv = c->priv;
- LmMessageNode *content_node, *trans_node;
+ WockyNode *content_node, *trans_node;
JingleDialect dialect = gabble_jingle_session_get_dialect (c->session);
- void (*produce_desc)(GabbleJingleContent *, LmMessageNode *) =
+ void (*produce_desc)(GabbleJingleContent *, WockyNode *) =
GABBLE_JINGLE_CONTENT_GET_CLASS (c)->produce_description;
if ((dialect == JINGLE_DIALECT_GTALK3) ||
@@ -850,16 +849,16 @@ gabble_jingle_content_produce_node (GabbleJingleContent *c,
}
else
{
- content_node = lm_message_node_add_child (parent, "content", NULL);
- lm_message_node_set_attributes (content_node,
+ content_node = wocky_node_add_child_with_content (parent, "content", NULL);
+ wocky_node_set_attributes (content_node,
"name", priv->name,
"senders", produce_senders (priv->senders),
NULL);
if (gabble_jingle_content_creator_is_initiator (c))
- lm_message_node_set_attribute (content_node, "creator", "initiator");
+ wocky_node_set_attribute (content_node, "creator", "initiator");
else
- lm_message_node_set_attribute (content_node, "creator", "responder");
+ wocky_node_set_attribute (content_node, "creator", "responder");
}
if (include_description)
@@ -874,8 +873,8 @@ gabble_jingle_content_produce_node (GabbleJingleContent *c,
}
else
{
- trans_node = lm_message_node_add_child (content_node, "transport", NULL);
- lm_message_node_set_attribute (trans_node, "xmlns", priv->transport_ns);
+ trans_node = wocky_node_add_child_with_content (content_node, "transport", NULL);
+ trans_node->ns = g_quark_from_string (priv->transport_ns);
}
if (trans_node_out != NULL)
@@ -885,12 +884,12 @@ gabble_jingle_content_produce_node (GabbleJingleContent *c,
void
gabble_jingle_content_update_senders (GabbleJingleContent *c,
- LmMessageNode *content_node, GError **error)
+ WockyNode *content_node, GError **error)
{
GabbleJingleContentPrivate *priv = c->priv;
JingleContentSenders senders;
- senders = parse_senders (lm_message_node_get_attribute (content_node, "senders"));
+ senders = parse_senders (wocky_node_get_attribute (content_node, "senders"));
if (senders == JINGLE_CONTENT_SENDERS_NONE)
{
@@ -904,7 +903,7 @@ gabble_jingle_content_update_senders (GabbleJingleContent *c,
void
gabble_jingle_content_parse_transport_info (GabbleJingleContent *self,
- LmMessageNode *trans_node, GError **error)
+ WockyNode *trans_node, GError **error)
{
GabbleJingleContentPrivate *priv = self->priv;
@@ -971,8 +970,8 @@ static void
send_content_add_or_accept (GabbleJingleContent *self)
{
GabbleJingleContentPrivate *priv = self->priv;
- LmMessage *msg;
- LmMessageNode *sess_node, *transport_node;
+ WockyStanza *msg;
+ WockyNode *sess_node, *transport_node;
JingleAction action;
JingleContentState new_state = JINGLE_CONTENT_STATE_EMPTY;
@@ -1059,8 +1058,8 @@ gabble_jingle_content_maybe_send_description (GabbleJingleContent *self)
if (gabble_jingle_session_defines_action (self->session,
JINGLE_ACTION_DESCRIPTION_INFO))
{
- LmMessageNode *sess_node;
- LmMessage *msg = gabble_jingle_session_new_message (self->session,
+ WockyNode *sess_node;
+ WockyStanza *msg = gabble_jingle_session_new_message (self->session,
JINGLE_ACTION_DESCRIPTION_INFO, &sess_node);
gabble_jingle_content_produce_node (self, sess_node, TRUE, FALSE, NULL);
@@ -1085,7 +1084,7 @@ gabble_jingle_content_retransmit_candidates (GabbleJingleContent *self,
void
gabble_jingle_content_inject_candidates (GabbleJingleContent *self,
- LmMessageNode *transport_node)
+ WockyNode *transport_node)
{
gabble_jingle_transport_iface_inject_candidates (self->priv->transport,
transport_node);
@@ -1147,8 +1146,8 @@ gabble_jingle_content_change_direction (GabbleJingleContent *c,
JingleContentSenders senders)
{
GabbleJingleContentPrivate *priv = c->priv;
- LmMessage *msg;
- LmMessageNode *sess_node;
+ WockyStanza *msg;
+ WockyNode *sess_node;
JingleDialect dialect = gabble_jingle_session_get_dialect (c->session);
if (senders == priv->senders)
@@ -1178,7 +1177,7 @@ gabble_jingle_content_change_direction (GabbleJingleContent *c,
static void
_on_remove_reply (GObject *c_as_obj,
gboolean success,
- LmMessage *reply)
+ WockyStanza *reply)
{
GabbleJingleContent *c = GABBLE_JINGLE_CONTENT (c_as_obj);
GabbleJingleContentPrivate *priv = c->priv;
@@ -1199,8 +1198,8 @@ _content_remove (GabbleJingleContent *c,
JingleReason reason)
{
GabbleJingleContentPrivate *priv = c->priv;
- LmMessage *msg;
- LmMessageNode *sess_node;
+ WockyStanza *msg;
+ WockyNode *sess_node;
DEBUG ("called for %p (%s)", c, priv->name);
@@ -1225,9 +1224,9 @@ _content_remove (GabbleJingleContent *c,
if (reason != JINGLE_REASON_UNKNOWN)
{
- LmMessageNode *reason_node = lm_message_node_add_child (sess_node,
+ WockyNode *reason_node = wocky_node_add_child_with_content (sess_node,
"reason", NULL);
- lm_message_node_add_child (reason_node,
+ wocky_node_add_child_with_content (reason_node,
gabble_jingle_session_get_reason_name (reason), NULL);
}
diff --git a/src/jingle-content.h b/src/jingle-content.h
index d3a0d620b..a9720ec8b 100644
--- a/src/jingle-content.h
+++ b/src/jingle-content.h
@@ -21,7 +21,6 @@
#define __JINGLE_CONTENT_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
#include "jingle-factory.h"
#include "jingle-transport-iface.h"
@@ -82,9 +81,9 @@ GType gabble_jingle_content_get_type (void);
struct _GabbleJingleContentClass {
GObjectClass parent_class;
- void (*parse_description) (GabbleJingleContent *, LmMessageNode *,
+ void (*parse_description) (GabbleJingleContent *, WockyNode *,
GError **);
- void (*produce_description) (GabbleJingleContent *, LmMessageNode *);
+ void (*produce_description) (GabbleJingleContent *, WockyNode *);
void (*transport_created) (GabbleJingleContent *,
GabbleJingleTransportIface *);
JingleContentSenders (*get_default_senders) (GabbleJingleContent *);
@@ -101,23 +100,23 @@ struct _GabbleJingleContent {
};
void gabble_jingle_content_parse_add (GabbleJingleContent *c,
- LmMessageNode *content_node, gboolean google_mode, GError **error);
+ WockyNode *content_node, gboolean google_mode, GError **error);
void gabble_jingle_content_update_senders (GabbleJingleContent *c,
- LmMessageNode *content_node, GError **error);
+ WockyNode *content_node, GError **error);
void gabble_jingle_content_produce_node (GabbleJingleContent *c,
- LmMessageNode *parent,
+ WockyNode *parent,
gboolean include_description,
gboolean include_transport,
- LmMessageNode **trans_node_out);
+ WockyNode **trans_node_out);
void gabble_jingle_content_parse_accept (GabbleJingleContent *c,
- LmMessageNode *content_node, gboolean google_mode, GError **error);
+ WockyNode *content_node, gboolean google_mode, GError **error);
void gabble_jingle_content_parse_info (GabbleJingleContent *c,
- LmMessageNode *content_node, GError **error);
+ WockyNode *content_node, GError **error);
void gabble_jingle_content_parse_transport_info (GabbleJingleContent *self,
- LmMessageNode *trans_node, GError **error);
+ WockyNode *trans_node, GError **error);
void gabble_jingle_content_parse_description_info (GabbleJingleContent *self,
- LmMessageNode *trans_node, GError **error);
+ WockyNode *trans_node, GError **error);
guint gabble_jingle_content_create_share_channel (GabbleJingleContent *self,
const gchar *name);
void gabble_jingle_content_add_candidates (GabbleJingleContent *self, GList *li);
@@ -138,7 +137,7 @@ gboolean gabble_jingle_content_change_direction (GabbleJingleContent *c,
void gabble_jingle_content_retransmit_candidates (GabbleJingleContent *self,
gboolean all);
void gabble_jingle_content_inject_candidates (GabbleJingleContent *self,
- LmMessageNode *transport_node);
+ WockyNode *transport_node);
gboolean gabble_jingle_content_is_created_by_us (GabbleJingleContent *c);
gboolean gabble_jingle_content_creator_is_initiator (GabbleJingleContent *c);
diff --git a/src/jingle-factory.c b/src/jingle-factory.c
index 78c8c8c71..3dba1596a 100644
--- a/src/jingle-factory.c
+++ b/src/jingle-factory.c
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include <glib.h>
-#include <wocky/wocky-c2s-porter.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
@@ -720,8 +720,9 @@ ensure_session (GabbleJingleFactory *self,
}
else
{
- g_set_error (error, GABBLE_XMPP_ERROR,
- XMPP_ERROR_JINGLE_UNKNOWN_SESSION, "session %s is unknown", sid);
+ g_set_error (error, WOCKY_XMPP_ERROR,
+ WOCKY_JINGLE_ERROR_UNKNOWN_SESSION,
+ "session %s is unknown", sid);
return NULL;
}
}
@@ -776,11 +777,9 @@ jingle_cb (
REQUEST_ERROR:
g_assert (error != NULL);
-
DEBUG ("NAKing with error: %s", error->message);
- _gabble_connection_send_iq_error (priv->conn, msg, error->code,
- error->message);
-
+ wocky_porter_send_iq_gerror (wocky_session_get_porter (priv->conn->session),
+ msg, error);
g_error_free (error);
if (sess != NULL && new_session)
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 5b1a9775b..3c5fba2c7 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -29,8 +29,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
#include "connection.h"
@@ -281,9 +279,9 @@ gabble_jingle_media_rtp_set_property (GObject *object,
}
static void parse_description (GabbleJingleContent *content,
- LmMessageNode *desc_node, GError **error);
+ WockyNode *desc_node, GError **error);
static void produce_description (GabbleJingleContent *obj,
- LmMessageNode *content_node);
+ WockyNode *content_node);
static void transport_created (GabbleJingleContent *obj,
GabbleJingleTransportIface *transport);
@@ -354,16 +352,16 @@ static void transport_created (GabbleJingleContent *content,
static JingleMediaType
-extract_media_type (LmMessageNode *desc_node,
+extract_media_type (WockyNode *desc_node,
GError **error)
{
- if (lm_message_node_has_namespace (desc_node, NS_JINGLE_RTP, NULL))
+ if (wocky_node_has_ns (desc_node, NS_JINGLE_RTP))
{
- const gchar *type = lm_message_node_get_attribute (desc_node, "media");
+ const gchar *type = wocky_node_get_attribute (desc_node, "media");
if (type == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"missing required media type attribute");
return JINGLE_MEDIA_TYPE_NONE;
}
@@ -374,25 +372,21 @@ extract_media_type (LmMessageNode *desc_node,
if (!tp_strdiff (type, "video"))
return JINGLE_MEDIA_TYPE_VIDEO;
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"unknown media type %s", type);
return JINGLE_MEDIA_TYPE_NONE;
}
- if (lm_message_node_has_namespace (desc_node,
- NS_JINGLE_DESCRIPTION_AUDIO, NULL))
+ if (wocky_node_has_ns (desc_node, NS_JINGLE_DESCRIPTION_AUDIO))
return JINGLE_MEDIA_TYPE_AUDIO;
- if (lm_message_node_has_namespace (desc_node,
- NS_JINGLE_DESCRIPTION_VIDEO, NULL))
+ if (wocky_node_has_ns (desc_node, NS_JINGLE_DESCRIPTION_VIDEO))
return JINGLE_MEDIA_TYPE_VIDEO;
- if (lm_message_node_has_namespace (desc_node,
- NS_GOOGLE_SESSION_PHONE, NULL))
+ if (wocky_node_has_ns (desc_node, NS_GOOGLE_SESSION_PHONE))
return JINGLE_MEDIA_TYPE_AUDIO;
- if (lm_message_node_has_namespace (desc_node,
- NS_GOOGLE_SESSION_VIDEO, NULL))
+ if (wocky_node_has_ns (desc_node, NS_GOOGLE_SESSION_VIDEO))
return JINGLE_MEDIA_TYPE_VIDEO;
/* If we get here, namespace in use is not one of namespaces we signed up
@@ -413,21 +407,20 @@ content_has_cap (GabbleJingleContent *content, const gchar *cap)
}
static JingleFeedbackMessage *
-parse_rtcp_fb (GabbleJingleContent *content, LmMessageNode *node)
+parse_rtcp_fb (GabbleJingleContent *content, WockyNode *node)
{
- const gchar *pt_ns =
- lm_message_node_get_namespace (node);
+ const gchar *pt_ns = wocky_node_get_ns (node);
const gchar *type;
const gchar *subtype;
if (tp_strdiff (pt_ns, NS_JINGLE_RTCP_FB))
return NULL;
- type = lm_message_node_get_attribute (node, "type");
+ type = wocky_node_get_attribute (node, "type");
if (type == NULL)
return NULL;
- subtype = lm_message_node_get_attribute (node, "subtype");
+ subtype = wocky_node_get_attribute (node, "subtype");
/* This is optional, defaults to "" */
if (subtype == NULL)
@@ -441,10 +434,9 @@ parse_rtcp_fb (GabbleJingleContent *content, LmMessageNode *node)
* Returns G_MAXUINT on error
*/
static guint
-parse_rtcp_fb_trr_int (GabbleJingleContent *content, LmMessageNode *node)
+parse_rtcp_fb_trr_int (GabbleJingleContent *content, WockyNode *node)
{
- const gchar *pt_ns =
- lm_message_node_get_namespace (node);
+ const gchar *pt_ns = wocky_node_get_ns (node);
const gchar *txt;
guint trr_int;
gchar *endptr = NULL;
@@ -452,7 +444,7 @@ parse_rtcp_fb_trr_int (GabbleJingleContent *content, LmMessageNode *node)
if (tp_strdiff (pt_ns, NS_JINGLE_RTCP_FB))
return G_MAXUINT;
- txt = lm_message_node_get_attribute (node, "value");
+ txt = wocky_node_get_attribute (node, "value");
if (txt == NULL)
return G_MAXUINT;
@@ -472,7 +464,8 @@ parse_rtcp_fb_trr_int (GabbleJingleContent *content, LmMessageNode *node)
* otherwise.
*/
static JingleCodec *
-parse_payload_type (GabbleJingleContent *content, LmMessageNode *node)
+parse_payload_type (GabbleJingleContent *content,
+ WockyNode *node)
{
GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
GabbleJingleMediaRtpPrivate *priv = self->priv;
@@ -482,43 +475,43 @@ parse_payload_type (GabbleJingleContent *content, LmMessageNode *node)
const gchar *name;
guint clockrate = 0;
guint channels = 0;
- NodeIter i;
+ WockyNode *param;
+ WockyNodeIter i;
- txt = lm_message_node_get_attribute (node, "id");
+ txt = wocky_node_get_attribute (node, "id");
if (txt == NULL)
return NULL;
id = atoi (txt);
- name = lm_message_node_get_attribute (node, "name");
+ name = wocky_node_get_attribute (node, "name");
if (name == NULL)
name = "";
/* xep-0167 v0.22, gtalk libjingle 0.3/0.4 use "clockrate" */
- txt = lm_message_node_get_attribute (node, "clockrate");
+ txt = wocky_node_get_attribute (node, "clockrate");
/* older jingle rtp used "rate" ? */
if (txt == NULL)
- txt = lm_message_node_get_attribute (node, "rate");
+ txt = wocky_node_get_attribute (node, "rate");
if (txt != NULL)
clockrate = atoi (txt);
- txt = lm_message_node_get_attribute (node, "channels");
+ txt = wocky_node_get_attribute (node, "channels");
if (txt != NULL)
channels = atoi (txt);
p = jingle_media_rtp_codec_new (id, name, clockrate, channels, NULL);
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &param))
{
- LmMessageNode *param = node_iter_data (i);
-
- if (!tp_strdiff (lm_message_node_get_name (param), "parameter"))
+ if (!tp_strdiff (param->name, "parameter"))
{
const gchar *param_name, *param_value;
- param_name = lm_message_node_get_attribute (param, "name");
- param_value = lm_message_node_get_attribute (param, "value");
+ param_name = wocky_node_get_attribute (param, "name");
+ param_value = wocky_node_get_attribute (param, "value");
if (param_name == NULL || param_value == NULL)
continue;
@@ -526,7 +519,7 @@ parse_payload_type (GabbleJingleContent *content, LmMessageNode *node)
g_hash_table_insert (p->params, g_strdup (param_name),
g_strdup (param_value));
}
- else if (!tp_strdiff (lm_message_node_get_name (param), "rtcp-fb"))
+ else if (!tp_strdiff (param->name, "rtcp-fb"))
{
JingleFeedbackMessage *fb = parse_rtcp_fb (content, param);
@@ -536,7 +529,7 @@ parse_payload_type (GabbleJingleContent *content, LmMessageNode *node)
priv->has_rtcp_fb = TRUE;
}
}
- else if (!tp_strdiff (lm_message_node_get_name (param),
+ else if (!tp_strdiff (param->name,
"rtcp-fb-trr-int"))
{
guint trr_int = parse_rtcp_fb_trr_int (content, param);
@@ -556,14 +549,14 @@ parse_payload_type (GabbleJingleContent *content, LmMessageNode *node)
}
static JingleRtpHeaderExtension *
-parse_rtp_header_extension (LmMessageNode *node)
+parse_rtp_header_extension (WockyNode *node)
{
guint id;
JingleContentSenders senders;
const gchar *uri;
const char *txt;
- txt = lm_message_node_get_attribute (node, "id");
+ txt = wocky_node_get_attribute (node, "id");
if (txt == NULL)
return NULL;
@@ -573,7 +566,7 @@ parse_rtp_header_extension (LmMessageNode *node)
if ((id < 1 || id > 256) && (id < 4096 || id > 4351))
return NULL;
- txt = lm_message_node_get_attribute (node, "senders");
+ txt = wocky_node_get_attribute (node, "senders");
if (txt == NULL || !g_ascii_strcasecmp (txt, "both"))
senders = JINGLE_CONTENT_SENDERS_BOTH;
@@ -584,7 +577,7 @@ parse_rtp_header_extension (LmMessageNode *node)
else
return NULL;
- uri = lm_message_node_get_attribute (node, "uri");
+ uri = wocky_node_get_attribute (node, "uri");
if (uri == NULL)
return NULL;
@@ -676,8 +669,8 @@ update_remote_media_description (GabbleJingleMediaRtp *self,
new_c = l->data;
old_c = g_hash_table_lookup (rc, GUINT_TO_POINTER ((guint) new_c->id));
- if (!codec_update_coherent (old_c, new_c, GABBLE_XMPP_ERROR,
- XMPP_ERROR_BAD_REQUEST, &e))
+ if (!codec_update_coherent (old_c, new_c, WOCKY_XMPP_ERROR,
+ WOCKY_XMPP_ERROR_BAD_REQUEST, &e))
goto out;
}
@@ -715,7 +708,7 @@ out:
static void
parse_description (GabbleJingleContent *content,
- LmMessageNode *desc_node, GError **error)
+ WockyNode *desc_node, GError **error)
{
GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
GabbleJingleMediaRtpPrivate *priv = self->priv;
@@ -724,7 +717,8 @@ parse_description (GabbleJingleContent *content,
JingleCodec *p;
JingleDialect dialect = gabble_jingle_session_get_dialect (content->session);
gboolean video_session = FALSE;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
gboolean description_error = FALSE;
gboolean is_avpf = FALSE;
@@ -743,23 +737,20 @@ parse_description (GabbleJingleContent *content,
if (dialect == JINGLE_DIALECT_GTALK3)
{
const gchar *desc_ns =
- lm_message_node_get_namespace (desc_node);
+ wocky_node_get_ns (desc_node);
video_session = !tp_strdiff (desc_ns, NS_GOOGLE_SESSION_VIDEO);
}
md = jingle_media_description_new ();
- for (i = node_iter (desc_node); i && !description_error; i = node_iter_next (i))
+ wocky_node_iter_init (&i, desc_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &node) && !description_error)
{
- LmMessageNode *node = node_iter_data (i);
-
- if (!tp_strdiff (lm_message_node_get_name (node), "payload-type"))
+ if (!tp_strdiff (node->name, "payload-type"))
{
-
if (dialect == JINGLE_DIALECT_GTALK3)
{
- const gchar *pt_ns =
- lm_message_node_get_namespace (node);
+ const gchar *pt_ns = wocky_node_get_ns (node);
if (priv->media_type == JINGLE_MEDIA_TYPE_AUDIO)
{
@@ -788,10 +779,9 @@ parse_description (GabbleJingleContent *content,
is_avpf = TRUE;
}
}
- else if (!tp_strdiff (lm_message_node_get_name (node), "rtp-hdrext"))
+ else if (!tp_strdiff (node->name, "rtp-hdrext"))
{
- const gchar *pt_ns =
- lm_message_node_get_namespace (node);
+ const gchar *pt_ns = wocky_node_get_ns (node);
JingleRtpHeaderExtension *hdrext;
if (tp_strdiff (pt_ns, NS_JINGLE_RTP_HDREXT))
@@ -810,7 +800,7 @@ parse_description (GabbleJingleContent *content,
}
}
- else if (!tp_strdiff (lm_message_node_get_name (node), "rtcp-fb"))
+ else if (!tp_strdiff (node->name, "rtcp-fb"))
{
JingleFeedbackMessage *fb = parse_rtcp_fb (content, node);
@@ -825,8 +815,7 @@ parse_description (GabbleJingleContent *content,
priv->has_rtcp_fb = TRUE;
}
}
- else if (!tp_strdiff (lm_message_node_get_name (node),
- "rtcp-fb-trr-int"))
+ else if (!tp_strdiff (node->name, "rtcp-fb-trr-int"))
{
guint trr_int = parse_rtcp_fb_trr_int (content, node);
@@ -847,7 +836,7 @@ parse_description (GabbleJingleContent *content,
{
/* rollback these */
jingle_media_description_free (md);
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"invalid description");
return;
}
@@ -897,65 +886,64 @@ gtalk_case (const gchar *codec)
static void
_produce_extra_param (gpointer key, gpointer value, gpointer user_data)
{
- LmMessageNode *pt_node = user_data;
- LmMessageNode *param;
+ WockyNode *pt_node = user_data;
+ WockyNode *param;
gchar *param_name = key;
gchar *param_value = value;
- param = lm_message_node_add_child (pt_node, "parameter", NULL);
- lm_message_node_set_attribute (param, "name", param_name);
- lm_message_node_set_attribute (param, "value", param_value);
+ param = wocky_node_add_child_with_content (pt_node, "parameter", NULL);
+ wocky_node_set_attribute (param, "name", param_name);
+ wocky_node_set_attribute (param, "value", param_value);
}
static void
-produce_rtcp_fb_trr_int (LmMessageNode *node,
+produce_rtcp_fb_trr_int (WockyNode *node,
guint trr_int)
{
- LmMessageNode *trr_int_node;
+ WockyNode *trr_int_node;
gchar tmp[10];
if (trr_int == G_MAXUINT || trr_int == 0)
return;
- trr_int_node = lm_message_node_add_child (node, "rtcp-fb-trr-int", NULL);
-
- lm_message_node_set_attribute (trr_int_node, "xmlns", NS_JINGLE_RTCP_FB);
+ trr_int_node = wocky_node_add_child_ns (node, "rtcp-fb-trr-int",
+ NS_JINGLE_RTCP_FB);
snprintf (tmp, 9, "%d", trr_int);
- lm_message_node_set_attribute (trr_int_node, "value", tmp);
+ wocky_node_set_attribute (trr_int_node, "value", tmp);
}
static void
-produce_rtcp_fb (JingleFeedbackMessage *fb, LmMessageNode *node)
+produce_rtcp_fb (JingleFeedbackMessage *fb, WockyNode *node)
{
- LmMessageNode *fb_node;
+ WockyNode *fb_node;
- fb_node = lm_message_node_add_child (node, "rtcp-fb", NULL);
+ fb_node = wocky_node_add_child (node, "rtcp-fb");
- lm_message_node_set_attribute (fb_node, "xmlns", NS_JINGLE_RTCP_FB);
- lm_message_node_set_attribute (fb_node, "type", fb->type);
+ wocky_node_set_attribute (fb_node, "xmlns", NS_JINGLE_RTCP_FB);
+ wocky_node_set_attribute (fb_node, "type", fb->type);
if (fb->subtype != NULL && fb->subtype[0] != 0)
- lm_message_node_set_attribute (fb_node, "subtype", fb->subtype);
+ wocky_node_set_attribute (fb_node, "subtype", fb->subtype);
}
static void
produce_payload_type (GabbleJingleContent *content,
- LmMessageNode *desc_node,
+ WockyNode *desc_node,
JingleMediaType type,
JingleCodec *p,
JingleDialect dialect)
{
GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
GabbleJingleMediaRtpPrivate *priv = self->priv;
- LmMessageNode *pt_node;
+ WockyNode *pt_node;
gchar buf[16];
- pt_node = lm_message_node_add_child (desc_node, "payload-type", NULL);
+ pt_node = wocky_node_add_child_with_content (desc_node, "payload-type", NULL);
/* id: required */
sprintf (buf, "%d", p->id);
- lm_message_node_set_attribute (pt_node, "id", buf);
+ wocky_node_set_attribute (pt_node, "id", buf);
if (dialect == JINGLE_DIALECT_GTALK3)
{
@@ -967,8 +955,8 @@ produce_payload_type (GabbleJingleContent *content,
* doesn't matter, so just always set the namespace on audio
* payloads.
*/
- lm_message_node_set_attribute (pt_node, "xmlns",
- NS_GOOGLE_SESSION_PHONE);
+ pt_node->ns = g_quark_from_static_string (
+ NS_GOOGLE_SESSION_PHONE);
}
else
{
@@ -976,7 +964,7 @@ produce_payload_type (GabbleJingleContent *content,
* our initiate.. These are a recv parameters, to it doesn't matter
* for what we're sending, just for what we're getting.. 320x240
* seems a sane enough default */
- lm_message_node_set_attributes (pt_node,
+ wocky_node_set_attributes (pt_node,
"width", "320",
"height", "240",
"framerate", "30",
@@ -989,9 +977,9 @@ produce_payload_type (GabbleJingleContent *content,
if (*p->name != '\0')
{
if (JINGLE_IS_GOOGLE_DIALECT (dialect))
- lm_message_node_set_attribute (pt_node, "name", gtalk_case (p->name));
+ wocky_node_set_attribute (pt_node, "name", gtalk_case (p->name));
else
- lm_message_node_set_attribute (pt_node, "name", p->name);
+ wocky_node_set_attribute (pt_node, "name", p->name);
}
/* clock rate: optional */
@@ -1003,13 +991,13 @@ produce_payload_type (GabbleJingleContent *content,
attname = "rate";
sprintf (buf, "%u", p->clockrate);
- lm_message_node_set_attribute (pt_node, attname, buf);
+ wocky_node_set_attribute (pt_node, attname, buf);
}
if (p->channels != 0)
{
sprintf (buf, "%u", p->channels);
- lm_message_node_set_attribute (pt_node, "channels", buf);
+ wocky_node_set_attribute (pt_node, "channels", buf);
}
if (p->params != NULL)
@@ -1023,17 +1011,17 @@ produce_payload_type (GabbleJingleContent *content,
}
}
-static LmMessageNode *
+static WockyNode *
produce_description_node (JingleDialect dialect, JingleMediaType media_type,
- LmMessageNode *content_node)
+ WockyNode *content_node)
{
- LmMessageNode *desc_node;
+ WockyNode *desc_node;
const gchar *xmlns = NULL;
if (dialect == JINGLE_DIALECT_GTALK3)
return NULL;
- desc_node = lm_message_node_add_child (content_node, "description", NULL);
+ desc_node = wocky_node_add_child_with_content (content_node, "description", NULL);
switch (dialect)
{
@@ -1055,15 +1043,15 @@ produce_description_node (JingleDialect dialect, JingleMediaType media_type,
default:
xmlns = NS_JINGLE_RTP;
if (media_type == JINGLE_MEDIA_TYPE_AUDIO)
- lm_message_node_set_attribute (desc_node, "media", "audio");
+ wocky_node_set_attribute (desc_node, "media", "audio");
else if (media_type == JINGLE_MEDIA_TYPE_VIDEO)
- lm_message_node_set_attribute (desc_node, "media", "video");
+ wocky_node_set_attribute (desc_node, "media", "video");
else
g_assert_not_reached ();
break;
}
- lm_message_node_set_attribute (desc_node, "xmlns", xmlns);
+ desc_node->ns = g_quark_from_string (xmlns);
return desc_node;
}
@@ -1072,33 +1060,33 @@ static void
produce_hdrext (gpointer data, gpointer user_data)
{
JingleRtpHeaderExtension *hdrext = data;
- LmMessageNode *desc_node = user_data;
- LmMessageNode *hdrext_node;
+ WockyNode *desc_node = user_data;
+ WockyNode *hdrext_node;
gchar buf[16];
- hdrext_node = lm_message_node_add_child (desc_node, "rtp-hdrext", NULL);
+ hdrext_node = wocky_node_add_child (desc_node, "rtp-hdrext");
/* id: required */
sprintf (buf, "%d", hdrext->id);
- lm_message_node_set_attribute (hdrext_node, "id", buf);
- lm_message_node_set_attribute (hdrext_node, "uri", hdrext->uri);
+ wocky_node_set_attribute (hdrext_node, "id", buf);
+ wocky_node_set_attribute (hdrext_node, "uri", hdrext->uri);
if (hdrext->senders == JINGLE_CONTENT_SENDERS_INITIATOR)
- lm_message_node_set_attribute (hdrext_node, "senders", "initiator");
+ wocky_node_set_attribute (hdrext_node, "senders", "initiator");
else if (hdrext->senders == JINGLE_CONTENT_SENDERS_RESPONDER)
- lm_message_node_set_attribute (hdrext_node, "senders", "responder");
+ wocky_node_set_attribute (hdrext_node, "senders", "responder");
- lm_message_node_set_attribute (hdrext_node, "xmlns", NS_JINGLE_RTP_HDREXT);
+ wocky_node_set_attribute (hdrext_node, "xmlns", NS_JINGLE_RTP_HDREXT);
}
static void
-produce_description (GabbleJingleContent *content, LmMessageNode *content_node)
+produce_description (GabbleJingleContent *content, WockyNode *content_node)
{
GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
GabbleJingleMediaRtpPrivate *priv = self->priv;
GList *li;
JingleDialect dialect = gabble_jingle_session_get_dialect (content->session);
- LmMessageNode *desc_node;
+ WockyNode *desc_node;
if (content_has_cap (content, NS_JINGLE_RTCP_FB))
priv->has_rtcp_fb = TRUE;
diff --git a/src/jingle-media-rtp.h b/src/jingle-media-rtp.h
index 793ff2814..9bcb8f4d4 100644
--- a/src/jingle-media-rtp.h
+++ b/src/jingle-media-rtp.h
@@ -21,7 +21,6 @@
#define __JINGLE_MEDIA_RTP_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
#include "jingle-content.h"
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 42b6f6bf8..1560f3236 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -24,9 +24,8 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/handle-repo-dynamic.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
@@ -489,9 +488,9 @@ gabble_jingle_session_class_init (GabbleJingleSessionClass *cls)
}
typedef void (*HandlerFunc)(GabbleJingleSession *sess,
- LmMessageNode *node, GError **error);
+ WockyNode *node, GError **error);
typedef void (*ContentHandlerFunc)(GabbleJingleSession *sess,
- GabbleJingleContent *c, LmMessageNode *content_node, gpointer user_data,
+ GabbleJingleContent *c, WockyNode *content_node, gpointer user_data,
GError **error);
static gboolean
@@ -658,7 +657,7 @@ lookup_content (GabbleJingleSession *sess,
if (name == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"'name' attribute unset");
return FALSE;
}
@@ -704,7 +703,7 @@ lookup_content (GabbleJingleSession *sess,
}
else
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"'creator' attribute %s",
(creator == NULL ? "missing" : "invalid"));
return FALSE;
@@ -713,7 +712,7 @@ lookup_content (GabbleJingleSession *sess,
if (fail_if_missing && *c == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"Content '%s' (created by %s) does not exist", name, creator);
return FALSE;
}
@@ -723,25 +722,22 @@ lookup_content (GabbleJingleSession *sess,
static void
_foreach_content (GabbleJingleSession *sess,
- LmMessageNode *node,
+ WockyNode *node,
gboolean fail_if_missing,
ContentHandlerFunc func,
gpointer user_data,
GError **error)
{
GabbleJingleContent *c;
- NodeIter i;
+ WockyNode *content_node;
+ WockyNodeIter iter;
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&iter, node, "content", NULL);
+ while (wocky_node_iter_next (&iter, &content_node))
{
- LmMessageNode *content_node = node_iter_data (i);
-
- if (tp_strdiff (lm_message_node_get_name (content_node), "content"))
- continue;
-
if (!lookup_content (sess,
- lm_message_node_get_attribute (content_node, "name"),
- lm_message_node_get_attribute (content_node, "creator"),
+ wocky_node_get_attribute (content_node, "name"),
+ wocky_node_get_attribute (content_node, "creator"),
fail_if_missing, &c, error))
return;
@@ -763,8 +759,8 @@ struct idle_content_reject_ctx {
static gboolean
idle_content_reject (gpointer data)
{
- LmMessage *msg;
- LmMessageNode *sess_node, *node;
+ WockyStanza *msg;
+ WockyNode *sess_node, *node;
struct idle_content_reject_ctx *ctx = data;
msg = gabble_jingle_session_new_message (ctx->session,
@@ -772,8 +768,8 @@ idle_content_reject (gpointer data)
g_debug ("name = %s, intiiator = %s", ctx->name, ctx->creator);
- node = lm_message_node_add_child (sess_node, "content", NULL);
- lm_message_node_set_attributes (node,
+ node = wocky_node_add_child_with_content (sess_node, "content", NULL);
+ wocky_node_set_attributes (node,
"name", ctx->name, "creator", ctx->creator, NULL);
gabble_jingle_session_send (ctx->session, msg, NULL, NULL);
@@ -806,7 +802,7 @@ fire_idle_content_reject (GabbleJingleSession *sess, const gchar *name,
static GabbleJingleContent *
create_content (GabbleJingleSession *sess, GType content_type,
JingleMediaType type, const gchar *content_ns, const gchar *transport_ns,
- const gchar *name, LmMessageNode *content_node, GError **error)
+ const gchar *name, WockyNode *content_node, GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
GabbleJingleContent *c;
@@ -874,18 +870,18 @@ create_content (GabbleJingleSession *sess, GType content_type,
static void
_each_content_add (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
- const gchar *name = lm_message_node_get_attribute (content_node, "name");
- LmMessageNode *desc_node = lm_message_node_get_child_any_ns (content_node,
+ const gchar *name = wocky_node_get_attribute (content_node, "name");
+ WockyNode *desc_node = wocky_node_get_child (content_node,
"description");
GType content_type = 0;
const gchar *content_ns = NULL;
if (desc_node != NULL)
{
- content_ns = lm_message_node_get_namespace (desc_node);
+ content_ns = wocky_node_get_ns (desc_node);
DEBUG ("namespace: %s", content_ns);
content_type = gabble_jingle_factory_lookup_content_type (
priv->conn->jingle_factory, content_ns);
@@ -896,18 +892,18 @@ _each_content_add (GabbleJingleSession *sess, GabbleJingleContent *c,
/* if this is session-initiate, we should return error, otherwise,
* we should respond with content-reject */
if (priv->state < JINGLE_STATE_PENDING_INITIATED)
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"unsupported content type with ns %s", content_ns);
else
fire_idle_content_reject (sess, name,
- lm_message_node_get_attribute (content_node, "creator"));
+ wocky_node_get_attribute (content_node, "creator"));
return;
}
if (c != NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"content '%s' already exists", name);
return;
}
@@ -918,7 +914,7 @@ _each_content_add (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_content_remove (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
g_assert (c != NULL);
@@ -927,7 +923,7 @@ _each_content_remove (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_content_rejected (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
JingleReason reason = GPOINTER_TO_UINT (user_data);
g_assert (c != NULL);
@@ -939,7 +935,7 @@ _each_content_rejected (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_content_modify (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
g_assert (c != NULL);
@@ -951,7 +947,7 @@ _each_content_modify (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_content_replace (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
_each_content_remove (sess, c, content_node, NULL, error);
@@ -963,7 +959,7 @@ _each_content_replace (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_content_accept (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
JingleContentState state;
@@ -974,7 +970,7 @@ _each_content_accept (GabbleJingleSession *sess, GabbleJingleContent *c,
if (state != JINGLE_CONTENT_STATE_SENT)
{
#ifdef ENABLE_DEBUG
- const gchar *name = lm_message_node_get_attribute (content_node, "name");
+ const gchar *name = wocky_node_get_attribute (content_node, "name");
DEBUG ("ignoring content \"%s\"s acceptance for content not in SENT state", name);
#endif
return;
@@ -986,13 +982,13 @@ _each_content_accept (GabbleJingleSession *sess, GabbleJingleContent *c,
static void
_each_description_info (GabbleJingleSession *sess, GabbleJingleContent *c,
- LmMessageNode *content_node, gpointer user_data, GError **error)
+ WockyNode *content_node, gpointer user_data, GError **error)
{
gabble_jingle_content_parse_description_info (c, content_node, error);
}
static void
-on_session_initiate (GabbleJingleSession *sess, LmMessageNode *node,
+on_session_initiate (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1009,9 +1005,9 @@ on_session_initiate (GabbleJingleSession *sess, LmMessageNode *node,
if ((priv->dialect == JINGLE_DIALECT_GTALK3))
{
const gchar *content_ns = NULL;
- LmMessageNode *desc_node =
- lm_message_node_get_child_any_ns (node, "description");
- content_ns = lm_message_node_get_namespace (desc_node);
+ WockyNode *desc_node =
+ wocky_node_get_child (node, "description");
+ content_ns = wocky_node_get_ns (desc_node);
if (!tp_strdiff (content_ns, NS_GOOGLE_SESSION_VIDEO))
{
@@ -1059,38 +1055,38 @@ on_session_initiate (GabbleJingleSession *sess, LmMessageNode *node,
}
static void
-on_content_add (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_add (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, FALSE, _each_content_add, NULL, error);
}
static void
-on_content_modify (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_modify (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, TRUE, _each_content_modify, NULL, error);
}
static void
-on_content_remove (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_remove (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, TRUE, _each_content_remove, NULL, error);
}
static void
-on_content_replace (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_replace (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, TRUE, _each_content_replace, NULL, error);
}
static void
-on_content_reject (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_reject (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
- LmMessageNode *n = lm_message_node_get_child (node, "reason");
+ WockyNode *n = wocky_node_get_child (node, "reason");
JingleReason reason = JINGLE_REASON_UNKNOWN;
DEBUG (" ");
@@ -1106,14 +1102,14 @@ on_content_reject (GabbleJingleSession *sess, LmMessageNode *node,
}
static void
-on_content_accept (GabbleJingleSession *sess, LmMessageNode *node,
+on_content_accept (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, TRUE, _each_content_accept, NULL, error);
}
static void
-on_session_accept (GabbleJingleSession *sess, LmMessageNode *node,
+on_session_accept (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1201,7 +1197,7 @@ set_mute (GabbleJingleSession *sess,
if (G_OBJECT_TYPE (c) != GABBLE_TYPE_JINGLE_MEDIA_RTP)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"content '%s' isn't an RTP session", name);
return FALSE;
}
@@ -1226,14 +1222,14 @@ set_ringing (GabbleJingleSession *sess,
static gboolean
handle_payload (GabbleJingleSession *sess,
- LmMessageNode *payload,
+ WockyNode *payload,
gboolean *handled,
GError **error)
{
- const gchar *ns = lm_message_node_get_namespace (payload);
- const gchar *elt = lm_message_node_get_name (payload);
- const gchar *name = lm_message_node_get_attribute (payload, "name");
- const gchar *creator = lm_message_node_get_attribute (payload, "creator");
+ const gchar *ns = wocky_node_get_ns (payload);
+ const gchar *elt = payload->name;
+ const gchar *name = wocky_node_get_attribute (payload, "name");
+ const gchar *creator = wocky_node_get_attribute (payload, "creator");
if (tp_strdiff (ns, NS_JINGLE_RTP_INFO))
{
@@ -1275,8 +1271,8 @@ handle_payload (GabbleJingleSession *sess,
}
else
{
- g_set_error (error, GABBLE_XMPP_ERROR,
- XMPP_ERROR_JINGLE_UNSUPPORTED_INFO,
+ g_set_error (error, WOCKY_JINGLE_ERROR,
+ WOCKY_JINGLE_ERROR_UNSUPPORTED_INFO,
"<%s> is not known in namespace %s", elt, ns);
return FALSE;
}
@@ -1286,22 +1282,23 @@ handle_payload (GabbleJingleSession *sess,
static void
on_session_info (GabbleJingleSession *sess,
- LmMessageNode *node,
+ WockyNode *node,
GError **error)
{
gboolean understood_a_payload = FALSE;
gboolean hit_an_error = FALSE;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *n;
/* if this is a ping, just ack it. */
- if (node_iter (node) == NULL)
+ if (wocky_node_get_first_child (node) == NULL)
return;
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &n))
{
gboolean handled;
GError *e = NULL;
- LmMessageNode *n = node_iter_data (i);
if (handle_payload (sess, n, &handled, &e))
{
@@ -1326,16 +1323,16 @@ on_session_info (GabbleJingleSession *sess,
if (understood_a_payload)
g_signal_emit (sess, signals[REMOTE_STATE_CHANGED], 0);
else if (!hit_an_error)
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_JINGLE_UNSUPPORTED_INFO,
+ g_set_error (error, WOCKY_JINGLE_ERROR, WOCKY_JINGLE_ERROR_UNSUPPORTED_INFO,
"no recognized session-info payloads");
}
static void
-on_session_terminate (GabbleJingleSession *sess, LmMessageNode *node,
+on_session_terminate (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
gchar *text = NULL;
- LmMessageNode *n = lm_message_node_get_child (node, "reason");
+ WockyNode *n = wocky_node_get_child (node, "reason");
JingleReason jingle_reason = JINGLE_REASON_UNKNOWN;
if (n != NULL)
@@ -1351,7 +1348,7 @@ on_session_terminate (GabbleJingleSession *sess, LmMessageNode *node,
}
static void
-on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
+on_transport_info (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1364,7 +1361,7 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
if (priv->dialect == JINGLE_DIALECT_GTALK4)
{
- if (!tp_strdiff (lm_message_node_get_attribute (node, "type"),
+ if (!tp_strdiff (wocky_node_get_attribute (node, "type"),
"candidates"))
{
GList *contents = gabble_jingle_session_get_contents (sess);
@@ -1380,11 +1377,11 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
}
else
{
- node = lm_message_node_get_child_any_ns (node, "transport");
+ node = wocky_node_get_child (node, "transport");
if (node == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"transport-info stanza without a <transport/>");
return;
}
@@ -1413,12 +1410,12 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
WockyNode *transport_node;
if (lookup_content (sess,
- lm_message_node_get_attribute (content_node, "name"),
- lm_message_node_get_attribute (content_node, "creator"),
+ wocky_node_get_attribute (content_node, "name"),
+ wocky_node_get_attribute (content_node, "creator"),
TRUE /* fail_if_missing */, &c, &e))
{
/* we need transport child of content node */
- transport_node = lm_message_node_get_child_any_ns (
+ transport_node = wocky_node_get_child (
content_node, "transport");
gabble_jingle_content_parse_transport_info (c,
transport_node, &e);
@@ -1438,21 +1435,21 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
}
static void
-on_transport_accept (GabbleJingleSession *sess, LmMessageNode *node,
+on_transport_accept (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
DEBUG ("Ignoring 'transport-accept' action from peer");
}
static void
-on_description_info (GabbleJingleSession *sess, LmMessageNode *node,
+on_description_info (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
_foreach_content (sess, node, TRUE, _each_description_info, NULL, error);
}
static void
-on_info (GabbleJingleSession *sess, LmMessageNode *node,
+on_info (GabbleJingleSession *sess, WockyNode *node,
GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1493,7 +1490,7 @@ static HandlerFunc handlers[] = {
static void
jingle_state_machine_dance (GabbleJingleSession *sess,
JingleAction action,
- LmMessageNode *node,
+ WockyNode *node,
GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1506,15 +1503,15 @@ jingle_state_machine_dance (GabbleJingleSession *sess,
}
static JingleDialect
-detect_google_dialect (LmMessageNode *session_node)
+detect_google_dialect (WockyNode *session_node)
{
/* The GTALK3 dialect is the only one that supports video at this time */
- if (lm_message_node_get_child_with_namespace (session_node,
+ if (wocky_node_get_child_ns (session_node,
"description", NS_GOOGLE_SESSION_VIDEO) != NULL)
return JINGLE_DIALECT_GTALK3;
/* GTalk4 has a transport item, GTalk3 doesn't */
- if (lm_message_node_get_child_with_namespace (session_node,
+ if (wocky_node_get_child_ns (session_node,
"transport", NS_GOOGLE_TRANSPORT_P2P) == NULL)
return JINGLE_DIALECT_GTALK3;
@@ -1522,25 +1519,29 @@ detect_google_dialect (LmMessageNode *session_node)
}
const gchar *
-gabble_jingle_session_detect (LmMessage *message, JingleAction *action, JingleDialect *dialect)
+gabble_jingle_session_detect (
+ WockyStanza *stanza,
+ JingleAction *action,
+ JingleDialect *dialect)
{
const gchar *actxt, *sid;
- LmMessageNode *iq_node, *session_node;
+ WockyNode *iq_node, *session_node;
+ WockyStanzaSubType sub_type;
gboolean google_mode = FALSE;
/* all jingle actions are sets */
- if (LM_MESSAGE_SUB_TYPE_SET != lm_message_get_sub_type (message))
+ wocky_stanza_get_type_info (stanza, NULL, &sub_type);
+ if (sub_type != WOCKY_STANZA_SUB_TYPE_SET)
return NULL;
- iq_node = lm_message_get_node (message);
+ iq_node = wocky_stanza_get_top_node (stanza);
- if ((NULL == lm_message_node_get_attribute (iq_node, "from")) ||
- (NULL == lm_message_node_get_attribute (iq_node, "to")))
+ if ((NULL == wocky_stanza_get_from (stanza)) ||
+ (NULL == wocky_stanza_get_to (stanza)))
return NULL;
/* first, we try standard jingle */
- session_node = lm_message_node_get_child_with_namespace (iq_node,
- "jingle", NS_JINGLE032);
+ session_node = wocky_node_get_child_ns (iq_node, "jingle", NS_JINGLE032);
if (session_node != NULL)
{
@@ -1549,8 +1550,7 @@ gabble_jingle_session_detect (LmMessage *message, JingleAction *action, JingleDi
else
{
/* then, we try a bit older jingle version */
- session_node = lm_message_node_get_child_with_namespace (iq_node,
- "jingle", NS_JINGLE015);
+ session_node = wocky_node_get_child_ns (iq_node, "jingle", NS_JINGLE015);
if (session_node != NULL)
{
@@ -1559,7 +1559,7 @@ gabble_jingle_session_detect (LmMessage *message, JingleAction *action, JingleDi
else
{
/* next, we try googletalk */
- session_node = lm_message_node_get_child_with_namespace (iq_node,
+ session_node = wocky_node_get_child_ns (iq_node,
"session", NS_GOOGLE_SESSION);
if (session_node != NULL)
@@ -1576,13 +1576,13 @@ gabble_jingle_session_detect (LmMessage *message, JingleAction *action, JingleDi
if (google_mode)
{
- actxt = lm_message_node_get_attribute (session_node, "type");
- sid = lm_message_node_get_attribute (session_node, "id");
+ actxt = wocky_node_get_attribute (session_node, "type");
+ sid = wocky_node_get_attribute (session_node, "id");
}
else
{
- actxt = lm_message_node_get_attribute (session_node, "action");
- sid = lm_message_node_get_attribute (session_node, "sid");
+ actxt = wocky_node_get_attribute (session_node, "action");
+ sid = wocky_node_get_attribute (session_node, "sid");
}
*action = parse_action (actxt);
@@ -1591,20 +1591,23 @@ gabble_jingle_session_detect (LmMessage *message, JingleAction *action, JingleDi
}
gboolean
-gabble_jingle_session_parse (GabbleJingleSession *sess, JingleAction action, LmMessage *message, GError **error)
+gabble_jingle_session_parse (
+ GabbleJingleSession *sess,
+ JingleAction action,
+ WockyStanza *stanza,
+ GError **error)
{
GabbleJingleSessionPrivate *priv = sess->priv;
- LmMessageNode *iq_node, *session_node;
+ WockyNode *iq_node, *session_node;
const gchar *from, *action_name;
- iq_node = lm_message_get_node (message);
-
/* IQ from/to can come in handy */
- from = lm_message_node_get_attribute (iq_node, "from");
+ from = wocky_stanza_get_from (stanza);
+ iq_node = wocky_stanza_get_top_node (stanza);
if (action == JINGLE_ACTION_UNKNOWN)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"unknown session action");
return FALSE;
}
@@ -1616,16 +1619,16 @@ gabble_jingle_session_parse (GabbleJingleSession *sess, JingleAction action, LmM
switch (priv->dialect) {
case JINGLE_DIALECT_V032:
- session_node = lm_message_node_get_child_with_namespace (iq_node,
+ session_node = wocky_node_get_child_ns (iq_node,
"jingle", NS_JINGLE032);
break;
case JINGLE_DIALECT_V015:
- session_node = lm_message_node_get_child_with_namespace (iq_node,
+ session_node = wocky_node_get_child_ns (iq_node,
"jingle", NS_JINGLE015);
break;
case JINGLE_DIALECT_GTALK3:
case JINGLE_DIALECT_GTALK4:
- session_node = lm_message_node_get_child_with_namespace (iq_node,
+ session_node = wocky_node_get_child_ns (iq_node,
"session", NS_GOOGLE_SESSION);
break;
default:
@@ -1635,21 +1638,21 @@ gabble_jingle_session_parse (GabbleJingleSession *sess, JingleAction action, LmM
if (session_node == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"malformed jingle stanza");
return FALSE;
}
if (!gabble_jingle_session_defines_action (sess, action))
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"action '%s' unknown (using dialect %u)", action_name, priv->dialect);
return FALSE;
}
if (!action_is_allowed (action, priv->state))
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_JINGLE_OUT_OF_ORDER,
+ g_set_error (error, WOCKY_JINGLE_ERROR, WOCKY_JINGLE_ERROR_OUT_OF_ORDER,
"action '%s' not allowed in current state", action_name);
return FALSE;
}
@@ -1662,13 +1665,13 @@ gabble_jingle_session_parse (GabbleJingleSession *sess, JingleAction action, LmM
return TRUE;
}
-LmMessage *
+WockyStanza *
gabble_jingle_session_new_message (GabbleJingleSession *sess,
- JingleAction action, LmMessageNode **sess_node)
+ JingleAction action, WockyNode **sess_node)
{
GabbleJingleSessionPrivate *priv = sess->priv;
- LmMessage *msg;
- LmMessageNode *iq_node, *session_node;
+ WockyStanza *stanza;
+ WockyNode *session_node;
gchar *el = NULL, *ns = NULL;
gboolean gtalk_mode = FALSE;
@@ -1678,13 +1681,6 @@ gabble_jingle_session_new_message (GabbleJingleSession *sess,
(priv->state > JINGLE_STATE_PENDING_CREATED));
g_assert (GABBLE_IS_JINGLE_SESSION (sess));
- msg = lm_message_new_with_sub_type (
- priv->peer_jid,
- LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_SET);
-
- iq_node = lm_message_get_node (msg);
-
switch (priv->dialect)
{
case JINGLE_DIALECT_V032:
@@ -1705,9 +1701,14 @@ gabble_jingle_session_new_message (GabbleJingleSession *sess,
g_assert_not_reached ();
}
- session_node = lm_message_node_add_child (iq_node, el, NULL);
- lm_message_node_set_attributes (session_node,
- "xmlns", ns,
+ stanza = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->peer_jid,
+ '(', el, ':', ns,
+ '*', &session_node,
+ ')', NULL);
+
+ wocky_node_set_attributes (session_node,
"initiator", priv->initiator,
(gtalk_mode) ? "id" : "sid", priv->sid,
(gtalk_mode) ? "type" : "action",
@@ -1717,7 +1718,7 @@ gabble_jingle_session_new_message (GabbleJingleSession *sess,
if (sess_node != NULL)
*sess_node = session_node;
- return msg;
+ return stanza;
}
typedef void (*ContentMapperFunc) (GabbleJingleSession *sess,
@@ -1766,8 +1767,8 @@ static void
_fill_content (GabbleJingleSession *sess,
GabbleJingleContent *c, gpointer user_data)
{
- LmMessageNode *sess_node = user_data;
- LmMessageNode *transport_node;
+ WockyNode *sess_node = user_data;
+ WockyNode *transport_node;
JingleContentState state;
gabble_jingle_content_produce_node (c, sess_node, TRUE, TRUE,
@@ -1791,25 +1792,24 @@ _fill_content (GabbleJingleSession *sess,
}
}
-static LmHandlerResult
+static void
_process_reply (GabbleConnection *conn,
- LmMessage *sent,
- LmMessage *reply,
+ WockyStanza *sent,
+ WockyStanza *reply,
GObject *obj,
gpointer cb_)
{
JingleReplyHandler cb = cb_;
+ WockyStanzaSubType sub_type;
- cb (obj, (lm_message_get_sub_type (reply) == LM_MESSAGE_SUB_TYPE_RESULT),
- reply);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ wocky_stanza_get_type_info (reply, NULL, &sub_type);
+ cb (obj, sub_type == WOCKY_STANZA_SUB_TYPE_RESULT, reply);
}
/**
* gabble_jingle_session_send:
* @sess: a session
- * @msg: a stanza, of which this function will take ownership
+ * @stanza: (transfer full): a stanza, of which this function will take ownership
* @cb: callback for the IQ reply, or %NULL to ignore the reply
* @weak_object: an object to pass to @cb, or %NULL
*
@@ -1818,24 +1818,24 @@ _process_reply (GabbleConnection *conn,
*/
void
gabble_jingle_session_send (GabbleJingleSession *sess,
- LmMessage *msg,
+ WockyStanza *stanza,
JingleReplyHandler cb,
GObject *weak_object)
{
if (cb != NULL)
- _gabble_connection_send_with_reply (sess->priv->conn, msg,
+ _gabble_connection_send_with_reply (sess->priv->conn, stanza,
_process_reply, weak_object, cb, NULL);
else
- _gabble_connection_send_with_reply (sess->priv->conn, msg,
+ _gabble_connection_send_with_reply (sess->priv->conn, stanza,
NULL, NULL, NULL, NULL);
- lm_message_unref (msg);
+ g_object_unref (stanza);
}
static void
_on_initiate_reply (GObject *sess_as_obj,
gboolean success,
- LmMessage *reply)
+ WockyStanza *reply)
{
GabbleJingleSession *sess = GABBLE_JINGLE_SESSION (sess_as_obj);
GabbleJingleSessionPrivate *priv = sess->priv;
@@ -1863,7 +1863,7 @@ _on_initiate_reply (GObject *sess_as_obj,
static void
_on_accept_reply (GObject *sess_as_obj,
gboolean success,
- LmMessage *reply)
+ WockyStanza *reply)
{
GabbleJingleSession *sess = GABBLE_JINGLE_SESSION (sess_as_obj);
@@ -1885,8 +1885,8 @@ try_session_initiate_or_accept (GabbleJingleSession *sess)
GabbleJingleSessionPrivate *priv = sess->priv;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
- LmMessage *msg;
- LmMessageNode *sess_node;
+ WockyStanza *msg;
+ WockyNode *sess_node;
gboolean contents_ready = TRUE;
JingleAction action;
JingleState new_state;
@@ -1979,15 +1979,11 @@ try_session_initiate_or_accept (GabbleJingleSession *sess)
if (has_video || has_audio)
{
- sess_node = lm_message_node_add_child (sess_node, "description",
+ sess_node = wocky_node_add_child_with_content (sess_node, "description",
NULL);
- if (has_video)
- lm_message_node_set_attribute (sess_node, "xmlns",
- NS_GOOGLE_SESSION_VIDEO);
- else
- lm_message_node_set_attribute (sess_node, "xmlns",
- NS_GOOGLE_SESSION_PHONE);
+ sess_node->ns = g_quark_from_static_string (
+ has_video ? NS_GOOGLE_SESSION_VIDEO : NS_GOOGLE_SESSION_PHONE);
}
}
@@ -2086,19 +2082,19 @@ gabble_jingle_session_terminate (GabbleJingleSession *sess,
if (priv->state != JINGLE_STATE_PENDING_CREATED)
{
- LmMessageNode *session_node;
- LmMessage *msg = gabble_jingle_session_new_message (sess,
+ WockyNode *session_node;
+ WockyStanza *msg = gabble_jingle_session_new_message (sess,
JINGLE_ACTION_SESSION_TERMINATE, &session_node);
if (priv->dialect == JINGLE_DIALECT_V032 && reason_elt != NULL)
{
- LmMessageNode *r = lm_message_node_add_child (session_node, "reason",
+ WockyNode *r = wocky_node_add_child_with_content (session_node, "reason",
NULL);
- lm_message_node_add_child (r, reason_elt, NULL);
+ wocky_node_add_child_with_content (r, reason_elt, NULL);
if (!tp_str_empty (text))
- lm_message_node_add_child (r, "text", text);
+ wocky_node_add_child_with_content (r, "text", text);
}
gabble_jingle_session_send (sess, msg, NULL, NULL);
@@ -2316,8 +2312,8 @@ static void
gabble_jingle_session_send_rtp_info (GabbleJingleSession *sess,
const gchar *name)
{
- LmMessage *message;
- LmMessageNode *jingle, *notification;
+ WockyStanza *message;
+ WockyNode *jingle, *notification;
if (!gabble_jingle_session_defines_action (sess, JINGLE_ACTION_SESSION_INFO))
{
@@ -2328,9 +2324,8 @@ gabble_jingle_session_send_rtp_info (GabbleJingleSession *sess,
message = gabble_jingle_session_new_message (sess,
JINGLE_ACTION_SESSION_INFO, &jingle);
- notification = lm_message_node_add_child (jingle, name, NULL);
- lm_message_node_set_attributes (notification, "xmlns", NS_JINGLE_RTP_INFO,
- NULL);
+ notification = wocky_node_add_child_with_content (jingle, name, NULL);
+ notification->ns = g_quark_from_static_string (NS_JINGLE_RTP_INFO);
/* This is just informational, so ignoring the reply. */
gabble_jingle_session_send (sess, message, NULL, NULL);
diff --git a/src/jingle-session.h b/src/jingle-session.h
index 5c80b6c7a..44ba3b34d 100644
--- a/src/jingle-session.h
+++ b/src/jingle-session.h
@@ -21,7 +21,7 @@
#define __JINGLE_SESSION_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
#include "jingle-content.h"
#include "jingle-factory.h"
@@ -75,12 +75,12 @@ GabbleJingleSession *gabble_jingle_session_new (GabbleConnection *connection,
const gchar *jid,
gboolean local_hold);
-const gchar * gabble_jingle_session_detect (LmMessage *message,
+const gchar * gabble_jingle_session_detect (WockyStanza *stanza,
JingleAction *action, JingleDialect *dialect);
gboolean gabble_jingle_session_parse (GabbleJingleSession *sess,
- JingleAction action, LmMessage *message, GError **error);
-LmMessage *gabble_jingle_session_new_message (GabbleJingleSession *sess,
- JingleAction action, LmMessageNode **sess_node);
+ JingleAction action, WockyStanza *stanza, GError **error);
+WockyStanza *gabble_jingle_session_new_message (GabbleJingleSession *sess,
+ JingleAction action, WockyNode **sess_node);
void gabble_jingle_session_accept (GabbleJingleSession *sess);
gboolean gabble_jingle_session_terminate (GabbleJingleSession *sess,
@@ -112,9 +112,9 @@ gboolean gabble_jingle_session_peer_has_quirk (
const gchar *quirk);
typedef void (*JingleReplyHandler) (GObject *, gboolean success,
- LmMessage *reply);
+ WockyStanza *reply);
void gabble_jingle_session_send (GabbleJingleSession *sess,
- LmMessage *msg,
+ WockyStanza *stanza,
JingleReplyHandler cb,
GObject *weak_object);
diff --git a/src/jingle-share.c b/src/jingle-share.c
index f4935be95..56f74f4aa 100644
--- a/src/jingle-share.c
+++ b/src/jingle-share.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
#define DEBUG_FLAG GABBLE_DEBUG_SHARE
@@ -183,9 +182,9 @@ gabble_jingle_share_dispose (GObject *object)
static void parse_description (GabbleJingleContent *content,
- LmMessageNode *desc_node, GError **error);
+ WockyNode *desc_node, GError **error);
static void produce_description (GabbleJingleContent *obj,
- LmMessageNode *content_node);
+ WockyNode *content_node);
static void
@@ -291,14 +290,15 @@ gabble_jingle_share_class_init (GabbleJingleShareClass *cls)
static void
parse_description (GabbleJingleContent *content,
- LmMessageNode *desc_node, GError **error)
+ WockyNode *desc_node, GError **error)
{
GabbleJingleShare *self = GABBLE_JINGLE_SHARE (content);
GabbleJingleSharePrivate *priv = self->priv;
- NodeIter i;
- LmMessageNode *manifest_node = NULL;
- LmMessageNode *protocol_node = NULL;
- LmMessageNode *http_node = NULL;
+ WockyNodeIter i;
+ WockyNode *manifest_node = NULL;
+ WockyNode *protocol_node = NULL;
+ WockyNode *http_node = NULL;
+ WockyNode *node;
DEBUG ("parse description called");
@@ -308,52 +308,52 @@ parse_description (GabbleJingleContent *content,
return;
}
- manifest_node = lm_message_node_get_child (desc_node, "manifest");
+ manifest_node = wocky_node_get_child (desc_node, "manifest");
if (manifest_node == NULL)
{
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"description missing <manifest/> node");
return;
}
- protocol_node = lm_message_node_get_child (desc_node, "protocol");
+ protocol_node = wocky_node_get_child (desc_node, "protocol");
if (protocol_node != NULL)
- http_node = lm_message_node_get_child (protocol_node, "http");
+ http_node = wocky_node_get_child (protocol_node, "http");
free_manifest (self);
priv->manifest = g_slice_new0 (GabbleJingleShareManifest);
/* Build the manifest */
- for (i = node_iter (manifest_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, manifest_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
- LmMessageNode *name = NULL;
- LmMessageNode *image = NULL;
+ WockyNode *name = NULL;
+ WockyNode *image = NULL;
gboolean folder;
const gchar *size;
GabbleJingleShareManifestEntry *m = NULL;
- if (!tp_strdiff (lm_message_node_get_name (node), "folder"))
+ if (!tp_strdiff (node->name, "folder"))
folder = TRUE;
- else if (!tp_strdiff (lm_message_node_get_name (node), "file"))
+ else if (!tp_strdiff (node->name, "file"))
folder = FALSE;
else
continue;
- name = lm_message_node_get_child (node, "name");
+ name = wocky_node_get_child (node, "name");
if (name == NULL)
continue;
m = g_slice_new0 (GabbleJingleShareManifestEntry);
m->folder = folder;
- m->name = g_strdup (lm_message_node_get_value (name));
+ m->name = g_strdup (name->content);
- size = lm_message_node_get_attribute (node, "size");
+ size = wocky_node_get_attribute (node, "size");
if (size)
m->size = g_ascii_strtoull (size, NULL, 10);
- image = lm_message_node_get_child (node, "image");
+ image = wocky_node_get_child (node, "image");
if (image)
{
const gchar *width;
@@ -361,11 +361,11 @@ parse_description (GabbleJingleContent *content,
m->image = TRUE;
- width = lm_message_node_get_attribute (image, "width");
+ width = wocky_node_get_attribute (image, "width");
if (width)
m->image_width = g_ascii_strtoull (width, NULL, 10);
- height =lm_message_node_get_attribute (image, "height");
+ height =wocky_node_get_attribute (image, "height");
if (height)
m->image_height = g_ascii_strtoull (height, NULL, 10);
}
@@ -376,27 +376,22 @@ parse_description (GabbleJingleContent *content,
if (http_node != NULL)
{
/* clear the previously set values */
- for (i = node_iter (http_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, http_node, "url", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
- const gchar *name;
-
- if (tp_strdiff (lm_message_node_get_name (node), "url"))
- continue;
-
- name = lm_message_node_get_attribute (node, "name");
+ const gchar *name = wocky_node_get_attribute (node, "name");
if (name == NULL)
continue;
if (!tp_strdiff (name, "source-path"))
{
- const gchar *url = lm_message_node_get_value (node);
+ const gchar *url = node->content;
priv->manifest->source_url = g_strdup (url);
}
if (!tp_strdiff (name, "preview-path"))
{
- const gchar *url = lm_message_node_get_value (node);
+ const gchar *url = node->content;
priv->manifest->preview_url = g_strdup (url);
}
}
@@ -446,76 +441,76 @@ parse_description (GabbleJingleContent *content,
}
static void
-produce_description (GabbleJingleContent *content, LmMessageNode *content_node)
+produce_description (GabbleJingleContent *content, WockyNode *content_node)
{
GabbleJingleShare *self = GABBLE_JINGLE_SHARE (content);
GabbleJingleSharePrivate *priv = self->priv;
GList *i;
- LmMessageNode *desc_node;
- LmMessageNode *manifest_node;
- LmMessageNode *protocol_node;
- LmMessageNode *http_node;
- LmMessageNode *url_node;
+ WockyNode *desc_node;
+ WockyNode *manifest_node;
+ WockyNode *protocol_node;
+ WockyNode *http_node;
+ WockyNode *url_node;
DEBUG ("produce description called");
ensure_manifest (self);
- desc_node = lm_message_node_add_child (content_node, "description", NULL);
+ desc_node = wocky_node_add_child_with_content (content_node, "description", NULL);
- lm_message_node_set_attribute (desc_node, "xmlns", NS_GOOGLE_SESSION_SHARE);
+ desc_node->ns = g_quark_from_string (NS_GOOGLE_SESSION_SHARE);
- manifest_node = lm_message_node_add_child (desc_node, "manifest", NULL);
+ manifest_node = wocky_node_add_child_with_content (desc_node, "manifest", NULL);
for (i = priv->manifest->entries; i; i = i->next)
{
GabbleJingleShareManifestEntry *m = i->data;
- LmMessageNode *file_node;
- LmMessageNode *image_node;
+ WockyNode *file_node;
+ WockyNode *image_node;
gchar *size_str, *width_str, *height_str;
if (m->folder)
- file_node = lm_message_node_add_child (manifest_node, "folder", NULL);
+ file_node = wocky_node_add_child_with_content (manifest_node, "folder", NULL);
else
- file_node = lm_message_node_add_child (manifest_node, "file", NULL);
+ file_node = wocky_node_add_child_with_content (manifest_node, "file", NULL);
if (m->size > 0)
{
size_str = g_strdup_printf ("%" G_GUINT64_FORMAT, m->size);
- lm_message_node_set_attribute (file_node, "size", size_str);
+ wocky_node_set_attribute (file_node, "size", size_str);
g_free (size_str);
}
- lm_message_node_add_child (file_node, "name", m->name);
+ wocky_node_add_child_with_content (file_node, "name", m->name);
if (m->image &&
(m->image_width > 0 || m->image_height > 0))
{
- image_node = lm_message_node_add_child (file_node, "image", NULL);
+ image_node = wocky_node_add_child_with_content (file_node, "image", NULL);
if (m->image_width > 0)
{
width_str = g_strdup_printf ("%d", m->image_width);
- lm_message_node_set_attribute (image_node, "width", width_str);
+ wocky_node_set_attribute (image_node, "width", width_str);
g_free (width_str);
}
if (m->image_height > 0)
{
height_str = g_strdup_printf ("%d", m->image_height);
- lm_message_node_set_attribute (image_node, "height", height_str);
+ wocky_node_set_attribute (image_node, "height", height_str);
g_free (height_str);
}
}
}
- protocol_node = lm_message_node_add_child (desc_node, "protocol", NULL);
- http_node = lm_message_node_add_child (protocol_node, "http", NULL);
- url_node = lm_message_node_add_child (http_node, "url",
+ protocol_node = wocky_node_add_child_with_content (desc_node, "protocol", NULL);
+ http_node = wocky_node_add_child_with_content (protocol_node, "http", NULL);
+ url_node = wocky_node_add_child_with_content (http_node, "url",
priv->manifest->source_url);
- lm_message_node_set_attribute (url_node, "name", "source-path");
- url_node = lm_message_node_add_child (http_node, "url",
+ wocky_node_set_attribute (url_node, "name", "source-path");
+ url_node = wocky_node_add_child_with_content (http_node, "url",
priv->manifest->preview_url);
- lm_message_node_set_attribute (url_node, "name", "preview-path");
+ wocky_node_set_attribute (url_node, "name", "preview-path");
}
diff --git a/src/jingle-share.h b/src/jingle-share.h
index 5444743c0..1a4ac64d8 100644
--- a/src/jingle-share.h
+++ b/src/jingle-share.h
@@ -21,7 +21,6 @@
#define __JINGLE_SHARE_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
#include "jingle-content.h"
diff --git a/src/jingle-transport-google.c b/src/jingle-transport-google.c
index af9a8890e..e8e90bfa9 100644
--- a/src/jingle-transport-google.c
+++ b/src/jingle-transport-google.c
@@ -25,8 +25,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
#include "connection.h"
@@ -231,21 +229,19 @@ gabble_jingle_transport_google_class_init (GabbleJingleTransportGoogleClass *cls
}
-#define SET_BAD_REQ(txt) \
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST, txt)
-
static void
parse_candidates (GabbleJingleTransportIface *obj,
- LmMessageNode *transport_node, GError **error)
+ WockyNode *transport_node, GError **error)
{
GabbleJingleTransportGoogle *t = GABBLE_JINGLE_TRANSPORT_GOOGLE (obj);
GabbleJingleTransportGooglePrivate *priv = t->priv;
GList *candidates = NULL;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
- for (i = node_iter (transport_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, transport_node, "candidate", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
const gchar *name, *address, *user, *pass, *str;
guint port, net, gen, component;
int pref;
@@ -253,10 +249,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
JingleCandidateType ctype;
JingleCandidate *c;
- if (tp_strdiff (lm_message_node_get_name (node), "candidate"))
- continue;
-
- name = lm_message_node_get_attribute (node, "name");
+ name = wocky_node_get_attribute (node, "name");
if (name == NULL)
break;
@@ -269,16 +262,16 @@ parse_candidates (GabbleJingleTransportIface *obj,
component = GPOINTER_TO_INT (g_hash_table_lookup (priv->component_names,
name));
- address = lm_message_node_get_attribute (node, "address");
+ address = wocky_node_get_attribute (node, "address");
if (address == NULL)
break;
- str = lm_message_node_get_attribute (node, "port");
+ str = wocky_node_get_attribute (node, "port");
if (str == NULL)
break;
port = atoi (str);
- str = lm_message_node_get_attribute (node, "protocol");
+ str = wocky_node_get_attribute (node, "protocol");
if (str == NULL)
break;
@@ -310,13 +303,13 @@ parse_candidates (GabbleJingleTransportIface *obj,
break;
}
- str = lm_message_node_get_attribute (node, "preference");
+ str = wocky_node_get_attribute (node, "preference");
if (str == NULL)
break;
pref = g_ascii_strtod (str, NULL) * 65536;
- str = lm_message_node_get_attribute (node, "type");
+ str = wocky_node_get_attribute (node, "type");
if (str == NULL)
break;
@@ -339,25 +332,25 @@ parse_candidates (GabbleJingleTransportIface *obj,
break;
}
- user = lm_message_node_get_attribute (node, "username");
+ user = wocky_node_get_attribute (node, "username");
if (user == NULL)
break;
- pass = lm_message_node_get_attribute (node, "password");
+ pass = wocky_node_get_attribute (node, "password");
if (pass == NULL)
break;
- str = lm_message_node_get_attribute (node, "network");
+ str = wocky_node_get_attribute (node, "network");
if (str == NULL)
break;
net = atoi (str);
- str = lm_message_node_get_attribute (node, "generation");
+ str = wocky_node_get_attribute (node, "generation");
if (str == NULL)
break;
gen = atoi (str);
- str = lm_message_node_get_attribute (node, "component");
+ str = wocky_node_get_attribute (node, "component");
if (str != NULL)
component = atoi (str);
@@ -367,12 +360,13 @@ parse_candidates (GabbleJingleTransportIface *obj,
candidates = g_list_append (candidates, c);
}
- if (i != NULL)
+ if (wocky_node_iter_next (&i, NULL))
{
DEBUG ("not all nodes were processed, reporting error");
/* rollback these */
jingle_transport_free_candidates (candidates);
- SET_BAD_REQ ("invalid candidate");
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
+ "invalid candidate");
return;
}
@@ -391,8 +385,8 @@ transmit_candidates (GabbleJingleTransportGoogle *transport,
{
GabbleJingleTransportGooglePrivate *priv = transport->priv;
GList *li;
- LmMessage *msg;
- LmMessageNode *trans_node, *sess_node;
+ WockyStanza *msg;
+ WockyNode *trans_node, *sess_node;
if (candidates == NULL)
return;
@@ -407,7 +401,7 @@ transmit_candidates (GabbleJingleTransportGoogle *transport,
{
JingleCandidate *c = (JingleCandidate *) li->data;
gchar port_str[16], pref_str[16], comp_str[16], *type_str, *proto_str;
- LmMessageNode *cnode;
+ WockyNode *cnode;
sprintf (port_str, "%d", c->port);
sprintf (pref_str, "%lf", c->preference / 65536.0);
@@ -441,8 +435,8 @@ transmit_candidates (GabbleJingleTransportGoogle *transport,
g_assert_not_reached ();
}
- cnode = lm_message_node_add_child (trans_node, "candidate", NULL);
- lm_message_node_set_attributes (cnode,
+ cnode = wocky_node_add_child_with_content (trans_node, "candidate", NULL);
+ wocky_node_set_attributes (cnode,
"address", c->address,
"port", port_str,
"username", c->username,
@@ -455,12 +449,12 @@ transmit_candidates (GabbleJingleTransportGoogle *transport,
"generation", "0",
NULL);
- lm_message_node_set_attribute (cnode, "name", name);
+ wocky_node_set_attribute (cnode, "name", name);
}
_gabble_connection_send_with_reply (priv->content->conn, msg, NULL, NULL,
NULL, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
/* Groups @candidates into rtp and rtcp and sends each group in its own
diff --git a/src/jingle-transport-google.h b/src/jingle-transport-google.h
index 32c7ea76a..441509330 100644
--- a/src/jingle-transport-google.h
+++ b/src/jingle-transport-google.h
@@ -21,7 +21,6 @@
#define __JINGLE_TRANSPORT_GOOGLE_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
diff --git a/src/jingle-transport-iceudp.c b/src/jingle-transport-iceudp.c
index d676f3a83..13bf6468a 100644
--- a/src/jingle-transport-iceudp.c
+++ b/src/jingle-transport-iceudp.c
@@ -25,8 +25,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
#include "connection.h"
@@ -237,19 +235,20 @@ gabble_jingle_transport_iceudp_class_init (GabbleJingleTransportIceUdpClass *cls
static void
parse_candidates (GabbleJingleTransportIface *obj,
- LmMessageNode *transport_node, GError **error)
+ WockyNode *transport_node, GError **error)
{
GabbleJingleTransportIceUdp *t = GABBLE_JINGLE_TRANSPORT_ICEUDP (obj);
GabbleJingleTransportIceUdpPrivate *priv = t->priv;
gboolean node_contains_a_candidate = FALSE;
GList *candidates = NULL;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
DEBUG ("called");
- for (i = node_iter (transport_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, transport_node, "candidate", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
const gchar *id, *address, *user, *pass, *str;
guint port, net, gen, component = 1;
gdouble pref;
@@ -257,26 +256,23 @@ parse_candidates (GabbleJingleTransportIface *obj,
JingleCandidateType ctype;
JingleCandidate *c;
- if (tp_strdiff (lm_message_node_get_name (node), "candidate"))
- continue;
-
node_contains_a_candidate = TRUE;
- id = lm_message_node_get_attribute (node, "foundation");
+ id = wocky_node_get_attribute (node, "foundation");
if (id == NULL)
{
DEBUG ("candidate doesn't contain foundation");
continue;
}
- address = lm_message_node_get_attribute (node, "ip");
+ address = wocky_node_get_attribute (node, "ip");
if (address == NULL)
{
DEBUG ("candidate doesn't contain ip");
continue;
}
- str = lm_message_node_get_attribute (node, "port");
+ str = wocky_node_get_attribute (node, "port");
if (str == NULL)
{
DEBUG ("candidate doesn't contain port");
@@ -284,7 +280,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
}
port = atoi (str);
- str = lm_message_node_get_attribute (node, "protocol");
+ str = wocky_node_get_attribute (node, "protocol");
if (str == NULL)
{
DEBUG ("candidate doesn't contain protocol");
@@ -302,7 +298,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
continue;
}
- str = lm_message_node_get_attribute (node, "priority");
+ str = wocky_node_get_attribute (node, "priority");
if (str == NULL)
{
DEBUG ("candidate doesn't contain priority");
@@ -310,7 +306,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
}
pref = g_ascii_strtod (str, NULL);
- str = lm_message_node_get_attribute (node, "type");
+ str = wocky_node_get_attribute (node, "type");
if (str == NULL)
{
DEBUG ("candidate doesn't contain type");
@@ -339,21 +335,21 @@ parse_candidates (GabbleJingleTransportIface *obj,
continue;
}
- user = lm_message_node_get_attribute (transport_node, "ufrag");
+ user = wocky_node_get_attribute (transport_node, "ufrag");
if (user == NULL)
{
DEBUG ("transport doesn't contain ufrag");
continue;
}
- pass = lm_message_node_get_attribute (transport_node, "pwd");
+ pass = wocky_node_get_attribute (transport_node, "pwd");
if (pass == NULL)
{
DEBUG ("transport doesn't contain pwd");
continue;
}
- str = lm_message_node_get_attribute (node, "network");
+ str = wocky_node_get_attribute (node, "network");
if (str == NULL)
{
DEBUG ("candidate doesn't contain network");
@@ -361,7 +357,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
}
net = atoi (str);
- str = lm_message_node_get_attribute (node, "generation");
+ str = wocky_node_get_attribute (node, "generation");
if (str == NULL)
{
DEBUG ("candidate doesn't contain generation");
@@ -369,7 +365,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
}
gen = atoi (str);
- str = lm_message_node_get_attribute (node, "component");
+ str = wocky_node_get_attribute (node, "component");
if (str == NULL)
{
DEBUG ("candidate doesn't contain component");
@@ -401,7 +397,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
{
NODE_DEBUG (transport_node,
"couldn't parse any of the given candidates");
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"could not parse any of the given candidates");
}
else
@@ -422,7 +418,7 @@ parse_candidates (GabbleJingleTransportIface *obj,
static void
inject_candidates (GabbleJingleTransportIface *obj,
- LmMessageNode *transport_node)
+ WockyNode *transport_node)
{
GabbleJingleTransportIceUdp *self = GABBLE_JINGLE_TRANSPORT_ICEUDP (obj);
GabbleJingleTransportIceUdpPrivate *priv = self->priv;
@@ -434,7 +430,7 @@ inject_candidates (GabbleJingleTransportIface *obj,
JingleCandidate *c = (JingleCandidate *) priv->pending_candidates->data;
gchar port_str[16], pref_str[16], comp_str[16], id_str[16],
*type_str, *proto_str;
- LmMessageNode *cnode;
+ WockyNode *cnode;
if (username == NULL)
{
@@ -479,13 +475,13 @@ inject_candidates (GabbleJingleTransportIface *obj,
continue;
}
- lm_message_node_set_attributes (transport_node,
+ wocky_node_set_attributes (transport_node,
"ufrag", c->username,
"pwd", c->password,
NULL);
- cnode = lm_message_node_add_child (transport_node, "candidate", NULL);
- lm_message_node_set_attributes (cnode,
+ cnode = wocky_node_add_child_with_content (transport_node, "candidate", NULL);
+ wocky_node_set_attributes (cnode,
"ip", c->address,
"port", port_str,
"priority", pref_str,
@@ -512,8 +508,8 @@ send_candidates (GabbleJingleTransportIface *iface,
while (priv->pending_candidates != NULL)
{
- LmMessageNode *trans_node, *sess_node;
- LmMessage *msg;
+ WockyNode *trans_node, *sess_node;
+ WockyStanza *msg;
msg = gabble_jingle_session_new_message (priv->content->session,
JINGLE_ACTION_TRANSPORT_INFO, &sess_node);
@@ -524,7 +520,7 @@ send_candidates (GabbleJingleTransportIface *iface,
_gabble_connection_send_with_reply (priv->content->conn, msg, NULL, NULL,
NULL, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
DEBUG ("sent all pending candidates");
diff --git a/src/jingle-transport-iceudp.h b/src/jingle-transport-iceudp.h
index 8cfeacf84..7d9c77e66 100644
--- a/src/jingle-transport-iceudp.h
+++ b/src/jingle-transport-iceudp.h
@@ -21,7 +21,6 @@
#define __JINGLE_TRANSPORT_ICEUDP_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
diff --git a/src/jingle-transport-iface.c b/src/jingle-transport-iface.c
index c0ac8bf11..5e4e50eb0 100644
--- a/src/jingle-transport-iface.c
+++ b/src/jingle-transport-iface.c
@@ -41,10 +41,10 @@ gabble_jingle_transport_iface_new (GType type,
void
gabble_jingle_transport_iface_parse_candidates (GabbleJingleTransportIface *self,
- LmMessageNode *node, GError **error)
+ WockyNode *node, GError **error)
{
void (*virtual_method)(GabbleJingleTransportIface *,
- LmMessageNode *, GError **) =
+ WockyNode *, GError **) =
GABBLE_JINGLE_TRANSPORT_IFACE_GET_CLASS (self)->parse_candidates;
g_assert (virtual_method != NULL);
@@ -70,9 +70,9 @@ gabble_jingle_transport_iface_new_local_candidates (GabbleJingleTransportIface *
void
gabble_jingle_transport_iface_inject_candidates (
GabbleJingleTransportIface *self,
- LmMessageNode *transport_node)
+ WockyNode *transport_node)
{
- void (*virtual_method)(GabbleJingleTransportIface *, LmMessageNode *) =
+ void (*virtual_method)(GabbleJingleTransportIface *, WockyNode *) =
GABBLE_JINGLE_TRANSPORT_IFACE_GET_CLASS (self)->inject_candidates;
if (virtual_method != NULL)
diff --git a/src/jingle-transport-iface.h b/src/jingle-transport-iface.h
index 036ecc7a8..bc6253ad9 100644
--- a/src/jingle-transport-iface.h
+++ b/src/jingle-transport-iface.h
@@ -21,7 +21,7 @@
#define __GABBLE_JINGLE_TRANSPORT_IFACE_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
#include "jingle-factory.h"
#include "types.h"
@@ -42,11 +42,11 @@ struct _GabbleJingleTransportIfaceClass {
GTypeInterface parent;
void (*parse_candidates) (GabbleJingleTransportIface *,
- LmMessageNode *, GError **);
+ WockyNode *, GError **);
void (*new_local_candidates) (GabbleJingleTransportIface *, GList *);
void (*inject_candidates) (GabbleJingleTransportIface *,
- LmMessageNode *transport_node);
+ WockyNode *transport_node);
void (*send_candidates) (GabbleJingleTransportIface *, gboolean all);
gboolean (*can_accept) (GabbleJingleTransportIface *);
@@ -72,14 +72,14 @@ GType gabble_jingle_transport_iface_get_type (void);
GabbleJingleTransportIfaceClass))
void gabble_jingle_transport_iface_parse_candidates (GabbleJingleTransportIface *,
- LmMessageNode *, GError **);
+ WockyNode *, GError **);
void gabble_jingle_transport_iface_new_local_candidates (
GabbleJingleTransportIface *self,
GList *candidates);
void gabble_jingle_transport_iface_inject_candidates (
GabbleJingleTransportIface *self,
- LmMessageNode *transport_node);
+ WockyNode *transport_node);
void gabble_jingle_transport_iface_send_candidates (
GabbleJingleTransportIface *self,
gboolean all);
diff --git a/src/jingle-transport-rawudp.c b/src/jingle-transport-rawudp.c
index 3ba83c4f1..376c2ad15 100644
--- a/src/jingle-transport-rawudp.c
+++ b/src/jingle-transport-rawudp.c
@@ -25,8 +25,6 @@
#include <string.h>
#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
#include "connection.h"
@@ -217,12 +215,13 @@ gabble_jingle_transport_rawudp_class_init (GabbleJingleTransportRawUdpClass *cls
static void
parse_candidates (GabbleJingleTransportIface *obj,
- LmMessageNode *transport_node, GError **error)
+ WockyNode *transport_node, GError **error)
{
GabbleJingleTransportRawUdp *t = GABBLE_JINGLE_TRANSPORT_RAWUDP (obj);
GabbleJingleTransportRawUdpPrivate *priv = t->priv;
GList *candidates = NULL;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
DEBUG ("called");
@@ -232,17 +231,14 @@ parse_candidates (GabbleJingleTransportIface *obj,
return;
}
- for (i = node_iter (transport_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, transport_node, "candidate", NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
const gchar *id, *ip, *str;
guint port, gen, component = 1;
JingleCandidate *c;
- if (tp_strdiff (node->name, "candidate"))
- continue;
-
- str = lm_message_node_get_attribute (node, "component");
+ str = wocky_node_get_attribute (node, "component");
if (str != NULL)
component = atoi (str);
@@ -252,20 +248,20 @@ parse_candidates (GabbleJingleTransportIface *obj,
continue;
}
- id = lm_message_node_get_attribute (node, "id");
+ id = wocky_node_get_attribute (node, "id");
if (id == NULL)
break;
- ip = lm_message_node_get_attribute (node, "ip");
+ ip = wocky_node_get_attribute (node, "ip");
if (ip == NULL)
break;
- str = lm_message_node_get_attribute (node, "port");
+ str = wocky_node_get_attribute (node, "port");
if (str == NULL)
break;
port = atoi (str);
- str = lm_message_node_get_attribute (node, "generation");
+ str = wocky_node_get_attribute (node, "generation");
if (str == NULL)
break;
gen = atoi (str);
@@ -277,12 +273,12 @@ parse_candidates (GabbleJingleTransportIface *obj,
candidates = g_list_append (candidates, c);
}
- if (i != NULL)
+ if (wocky_node_iter_next (&i, NULL))
{
DEBUG ("not all nodes were processed, reporting error");
/* rollback these */
jingle_transport_free_candidates (candidates);
- g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"invalid candidate");
return;
}
@@ -294,14 +290,14 @@ parse_candidates (GabbleJingleTransportIface *obj,
static void
inject_candidates (GabbleJingleTransportIface *obj,
- LmMessageNode *transport_node)
+ WockyNode *transport_node)
{
GabbleJingleTransportRawUdp *self = GABBLE_JINGLE_TRANSPORT_RAWUDP (obj);
GabbleJingleTransportRawUdpPrivate *priv = self->priv;
JingleCandidate *c;
GList *li;
gchar port_str[16], comp_str[16];
- LmMessageNode *cnode;
+ WockyNode *cnode;
/* If we don't have the local candidates yet, we should've waited with
* the session initiation, or can_accept would have returned FALSE.
@@ -314,8 +310,8 @@ inject_candidates (GabbleJingleTransportIface *obj,
sprintf (port_str, "%d", c->port);
sprintf (comp_str, "%d", c->component);
- cnode = lm_message_node_add_child (transport_node, "candidate", NULL);
- lm_message_node_set_attributes (cnode,
+ cnode = wocky_node_add_child_with_content (transport_node, "candidate", NULL);
+ wocky_node_set_attributes (cnode,
"ip", c->address,
"port", port_str,
"generation", "0",
diff --git a/src/jingle-transport-rawudp.h b/src/jingle-transport-rawudp.h
index 5b8b61005..e638e8380 100644
--- a/src/jingle-transport-rawudp.h
+++ b/src/jingle-transport-rawudp.h
@@ -21,7 +21,6 @@
#define __JINGLE_TRANSPORT_RAWUDP_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include "types.h"
diff --git a/src/legacy-caps.c b/src/legacy-caps.c
index 538d18cdd..b8344063d 100644
--- a/src/legacy-caps.c
+++ b/src/legacy-caps.c
@@ -21,6 +21,8 @@
#include "config.h"
#include "legacy-caps.h"
+#include <telepathy-glib/interfaces.h>
+
#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
#include "debug.h"
#include "media-factory.h"
diff --git a/src/media-factory.c b/src/media-factory.c
index 8efd55597..eb4573e72 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -25,7 +25,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
diff --git a/src/message-util.c b/src/message-util.c
index c0f5a6938..ee9c1d028 100644
--- a/src/message-util.c
+++ b/src/message-util.c
@@ -27,8 +27,8 @@
#include <string.h>
#include <time.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/dbus.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_IM
#include "debug.h"
@@ -40,32 +40,30 @@ void
gabble_message_util_add_chat_state (WockyStanza *stanza,
TpChannelChatState state)
{
- LmMessageNode *node = NULL;
+ WockyNode *node = NULL;
WockyNode *n = wocky_stanza_get_top_node (stanza);
switch (state)
{
case TP_CHANNEL_CHAT_STATE_GONE:
- node = lm_message_node_add_child (n, "gone", NULL);
+ node = wocky_node_add_child_with_content (n, "gone", NULL);
break;
case TP_CHANNEL_CHAT_STATE_INACTIVE:
- node = lm_message_node_add_child (n, "inactive", NULL);
+ node = wocky_node_add_child_with_content (n, "inactive", NULL);
break;
case TP_CHANNEL_CHAT_STATE_ACTIVE:
- node = lm_message_node_add_child (n, "active", NULL);
+ node = wocky_node_add_child_with_content (n, "active", NULL);
break;
case TP_CHANNEL_CHAT_STATE_PAUSED:
- node = lm_message_node_add_child (n, "paused", NULL);
+ node = wocky_node_add_child_with_content (n, "paused", NULL);
break;
case TP_CHANNEL_CHAT_STATE_COMPOSING:
- node = lm_message_node_add_child (n, "composing", NULL);
+ node = wocky_node_add_child_with_content (n, "composing", NULL);
break;
}
if (node != NULL)
- {
- lm_message_node_set_attributes (node, "xmlns", NS_CHAT_STATES, NULL);
- }
+ node->ns = g_quark_from_static_string (NS_CHAT_STATES);
}
/**
@@ -85,7 +83,7 @@ gabble_message_util_add_chat_state (WockyStanza *stanza,
WockyStanza *
gabble_message_util_build_stanza (TpMessage *message,
GabbleConnection *conn,
- LmMessageSubType subtype,
+ WockyStanzaSubType subtype,
TpChannelChatState state,
const char *recipient,
gboolean send_nick,
@@ -142,22 +140,24 @@ gabble_message_util_build_stanza (TpMessage *message,
{
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION:
- subtype = LM_MESSAGE_SUB_TYPE_CHAT;
+ subtype = WOCKY_STANZA_SUB_TYPE_CHAT;
break;
case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE:
- subtype = LM_MESSAGE_SUB_TYPE_NORMAL;
+ subtype = WOCKY_STANZA_SUB_TYPE_NORMAL;
break;
}
}
- stanza = lm_message_new_with_sub_type (recipient, LM_MESSAGE_TYPE_MESSAGE,
- subtype);
- node = wocky_stanza_get_top_node (stanza);
/* Generate a UUID for the message */
id = gabble_generate_id ();
- lm_message_node_set_attribute (node, "id", id);
tp_message_set_string (message, 0, "message-token", id);
+ stanza = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, subtype,
+ NULL, recipient,
+ '@', "id", id,
+ '*', &node,
+ NULL);
+
if (send_nick)
lm_message_node_add_own_nick (node, conn);
@@ -165,12 +165,12 @@ gabble_message_util_build_stanza (TpMessage *message,
{
gchar *tmp;
tmp = g_strconcat ("/me ", text, NULL);
- lm_message_node_add_child (node, "body", tmp);
+ wocky_node_add_child_with_content (node, "body", tmp);
g_free (tmp);
}
else
{
- lm_message_node_add_child (node, "body", text);
+ wocky_node_add_child_with_content (node, "body", text);
}
gabble_message_util_add_chat_state (stanza, state);
@@ -199,19 +199,19 @@ gabble_message_util_build_stanza (TpMessage *message,
gboolean
gabble_message_util_send_chat_state (GObject *obj,
GabbleConnection *conn,
- LmMessageSubType subtype,
+ WockyStanzaSubType subtype,
TpChannelChatState state,
const char *recipient,
GError **error)
{
- LmMessage *msg = lm_message_new_with_sub_type (recipient,
- LM_MESSAGE_TYPE_MESSAGE, subtype);
+ WockyStanza *msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, subtype,
+ NULL, recipient, NULL);
gboolean result;
gabble_message_util_add_chat_state (msg, state);
result = _gabble_connection_send (conn, msg, error);
- lm_message_unref (msg);
+ g_object_unref (msg);
return result;
}
@@ -252,68 +252,66 @@ gabble_tp_send_error_from_wocky_xmpp_error (WockyXmppError err)
}
static TpChannelTextSendError
-_tp_send_error_from_error_node (LmMessageNode *error_node,
- TpDeliveryStatus *delivery_status)
+_tp_send_error_from_xmpp_error (
+ WockyXmppErrorType error_type,
+ GError *error,
+ TpDeliveryStatus *delivery_status)
{
- if (error_node != NULL)
- {
- GabbleXmppErrorType err_type = XMPP_ERROR_TYPE_UNDEFINED;
- GabbleXmppError err = gabble_xmpp_error_from_node (error_node, &err_type);
-
- DEBUG ("got xmpp error: %s (type=%u): %s", gabble_xmpp_error_string (err),
- err_type, gabble_xmpp_error_description (err));
+ /* The thing calling us should have got this back from
+ * wocky_stanza_extract_errors().
+ */
+ g_assert (error->domain == WOCKY_XMPP_ERROR);
- if (err_type == XMPP_ERROR_TYPE_WAIT)
- *delivery_status = TP_DELIVERY_STATUS_TEMPORARILY_FAILED;
- else
- *delivery_status = TP_DELIVERY_STATUS_PERMANENTLY_FAILED;
+ DEBUG ("got xmpp error: %s (type=%u): '%s'",
+ wocky_xmpp_stanza_error_to_string (error),
+ error_type, error->message);
- /* these are based on descriptions of errors, and some testing */
- switch (err)
- {
- /* Note: Google replies with <service-unavailable/> if you send a
- * message to someone you're not subscribed to. But
- * http://xmpp.org/rfcs/rfc3921.html#rules explicitly says that means
- * the user is offline and doesn't have offline storage. I think Google
- * should be returning <forbidden/> or <not-authorized/>. --wjt
- */
- case XMPP_ERROR_SERVICE_UNAVAILABLE:
- case XMPP_ERROR_RECIPIENT_UNAVAILABLE:
- return TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE;
-
- case XMPP_ERROR_ITEM_NOT_FOUND:
- case XMPP_ERROR_JID_MALFORMED:
- case XMPP_ERROR_REMOTE_SERVER_TIMEOUT:
- return TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT;
-
- case XMPP_ERROR_FORBIDDEN:
- case XMPP_ERROR_NOT_AUTHORIZED:
- return TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED;
-
- case XMPP_ERROR_RESOURCE_CONSTRAINT:
- return TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG;
-
- case XMPP_ERROR_FEATURE_NOT_IMPLEMENTED:
- return TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED;
-
- default:
- return TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
- }
- }
+ if (error_type == WOCKY_XMPP_ERROR_TYPE_WAIT)
+ *delivery_status = TP_DELIVERY_STATUS_TEMPORARILY_FAILED;
else
+ *delivery_status = TP_DELIVERY_STATUS_PERMANENTLY_FAILED;
+
+ /* these are based on descriptions of errors, and some testing */
+ switch (error->code)
{
+ /* Note: Google replies with <service-unavailable/> if you send a
+ * message to someone you're not subscribed to. But
+ * http://xmpp.org/rfcs/rfc3921.html#rules explicitly says that means
+ * the user is offline and doesn't have offline storage. I think Google
+ * should be returning <forbidden/> or <not-authorized/>. --wjt
+ */
+ case WOCKY_XMPP_ERROR_SERVICE_UNAVAILABLE:
+ case WOCKY_XMPP_ERROR_RECIPIENT_UNAVAILABLE:
+ return TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE;
+
+ case WOCKY_XMPP_ERROR_ITEM_NOT_FOUND:
+ case WOCKY_XMPP_ERROR_JID_MALFORMED:
+ case WOCKY_XMPP_ERROR_REMOTE_SERVER_TIMEOUT:
+ return TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT;
+
+ case WOCKY_XMPP_ERROR_FORBIDDEN:
+ case WOCKY_XMPP_ERROR_NOT_AUTHORIZED:
+ return TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED;
+
+ case WOCKY_XMPP_ERROR_RESOURCE_CONSTRAINT:
+ return TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG;
+
+ case WOCKY_XMPP_ERROR_FEATURE_NOT_IMPLEMENTED:
+ return TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED;
+
+ default:
return TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
}
}
static gint
-_tp_chat_state_from_message (LmMessage *message)
+_tp_chat_state_from_message (WockyStanza *message)
{
- LmMessageNode *node;
+ WockyNode *node;
#define MAP_TO(str, state) \
- node = lm_message_node_get_child_with_namespace ( \
+ node = wocky_node_get_child_ns ( \
wocky_stanza_get_top_node (message), str, \
NS_CHAT_STATES); \
if (node != NULL) \
@@ -355,7 +353,7 @@ _tp_chat_state_from_message (LmMessage *message)
* contained no body, chat state or send error; %FALSE otherwise.
*/
gboolean
-gabble_message_util_parse_incoming_message (LmMessage *message,
+gabble_message_util_parse_incoming_message (WockyStanza *message,
const gchar **from,
time_t *stamp,
TpChannelTextMessageType *msgtype,
@@ -366,26 +364,24 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
TpDeliveryStatus *delivery_status)
{
const gchar *type, *body;
- LmMessageNode *node;
+ WockyNode *node;
+ WockyXmppErrorType error_type;
+ GError *error = NULL;
*send_error = GABBLE_TEXT_CHANNEL_SEND_NO_ERROR;
*delivery_status = TP_DELIVERY_STATUS_UNKNOWN;
- if (lm_message_get_sub_type (message) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (message, &error_type, &error, NULL, NULL))
{
- LmMessageNode *error_node;
-
- error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (message), "error");
-
- *send_error = _tp_send_error_from_error_node (error_node,
+ *send_error = _tp_send_error_from_xmpp_error (error_type, error,
delivery_status);
+ g_clear_error (&error);
}
- *id = lm_message_node_get_attribute (wocky_stanza_get_top_node (message),
+ *id = wocky_node_get_attribute (wocky_stanza_get_top_node (message),
"id");
- *from = lm_message_node_get_attribute (wocky_stanza_get_top_node (message),
+ *from = wocky_node_get_attribute (wocky_stanza_get_top_node (message),
"from");
if (*from == NULL)
{
@@ -393,7 +389,7 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
return FALSE;
}
- type = lm_message_node_get_attribute (wocky_stanza_get_top_node (message),
+ type = wocky_node_get_attribute (wocky_stanza_get_top_node (message),
"type");
/*
@@ -402,7 +398,7 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
*/
*stamp = 0;
- node = lm_message_node_get_child_with_namespace (
+ node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (message), "x", NS_X_DELAY);
if (node != NULL)
{
@@ -412,7 +408,7 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
* in GMT. They're in the format yyyymmddThhmmss, so if we append 'Z'
* we'll get (one of the many valid syntaxes for) an ISO-8601 timestamp.
*/
- stamp_str = lm_message_node_get_attribute (node, "stamp");
+ stamp_str = wocky_node_get_attribute (node, "stamp");
if (stamp_str != NULL)
{
@@ -436,12 +432,12 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
/*
* Parse body if it exists.
*/
- node = lm_message_node_get_child (wocky_stanza_get_top_node (message),
+ node = wocky_node_get_child (wocky_stanza_get_top_node (message),
"body");
if (node)
{
- body = lm_message_node_get_value (node);
+ body = node->content;
}
else
{
@@ -459,7 +455,7 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
if (body != NULL)
{
- if (lm_message_node_get_child_with_namespace (
+ if (wocky_node_get_child_ns (
wocky_stanza_get_top_node (message),
"google-rbc-announcement", "google:metadata") != NULL)
{
@@ -468,10 +464,10 @@ gabble_message_util_parse_incoming_message (LmMessage *message,
}
if (type == NULL &&
- lm_message_node_get_child_with_namespace (
+ wocky_node_get_child_ns (
wocky_stanza_get_top_node (message),
"time", "google:timestamp") != NULL &&
- lm_message_node_get_child_with_namespace (
+ wocky_node_get_child_ns (
wocky_stanza_get_top_node (message),
"x", "jabber:x:delay") != NULL)
{
diff --git a/src/message-util.h b/src/message-util.h
index 8b63c7adb..80853c890 100644
--- a/src/message-util.h
+++ b/src/message-util.h
@@ -23,9 +23,8 @@
#include <telepathy-glib/message-mixin.h>
-#include <loudmouth/loudmouth.h>
#include <wocky/wocky.h>
-#include <wocky/wocky-xmpp-error.h>
+#include <wocky/wocky.h>
#include "connection.h"
@@ -35,18 +34,18 @@ void gabble_message_util_add_chat_state (WockyStanza *stanza,
TpChannelChatState state);
WockyStanza * gabble_message_util_build_stanza (TpMessage *message,
- GabbleConnection *conn, LmMessageSubType subtype,
+ GabbleConnection *conn, WockyStanzaSubType subtype,
TpChannelChatState state, const char *recipient, gboolean send_nick,
gchar **token, GError **error);
gboolean gabble_message_util_send_chat_state (GObject *obj,
- GabbleConnection *conn, LmMessageSubType subtype, TpChannelChatState state,
+ GabbleConnection *conn, WockyStanzaSubType subtype, TpChannelChatState state,
const char *recipient, GError **error);
#define GABBLE_TEXT_CHANNEL_SEND_NO_ERROR ((TpChannelTextSendError)-1)
-gboolean gabble_message_util_parse_incoming_message (LmMessage *message,
+gboolean gabble_message_util_parse_incoming_message (WockyStanza *message,
const gchar **from, time_t *stamp, TpChannelTextMessageType *msgtype,
const gchar **id, const gchar **body_ret, gint *state,
TpChannelTextSendError *send_error, TpDeliveryStatus *delivery_status);
diff --git a/src/muc-channel.c b/src/muc-channel.c
index b7425c7d2..2d413fe31 100644
--- a/src/muc-channel.c
+++ b/src/muc-channel.c
@@ -25,9 +25,7 @@
#include <stdio.h>
#include <string.h>
-#include <wocky/wocky-muc.h>
-#include <wocky/wocky-utils.h>
-#include <wocky/wocky-xmpp-error.h>
+#include <wocky/wocky.h>
#include <dbus/dbus-glib.h>
#include <telepathy-glib/dbus.h>
@@ -319,11 +317,11 @@ static void handle_errmsg (GObject *source,
static void _gabble_muc_channel_handle_subject (GabbleMucChannel *chan,
TpHandleType handle_type,
TpHandle sender, GDateTime *datetime, const gchar *subject,
- LmMessage *msg);
+ WockyStanza *msg);
static void _gabble_muc_channel_receive (GabbleMucChannel *chan,
TpChannelTextMessageType msg_type, TpHandleType handle_type,
TpHandle sender, GDateTime *datetime, const gchar *id, const gchar *text,
- LmMessage *msg, TpChannelTextSendError send_error,
+ WockyStanza *msg, TpChannelTextSendError send_error,
TpDeliveryStatus delivery_status);
static void
@@ -630,14 +628,15 @@ properties_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *query_result,
+ WockyNode *query_result,
GError *error,
gpointer user_data)
{
GabbleMucChannel *chan = user_data;
GabbleMucChannelPrivate *priv = chan->priv;
- LmMessageNode *lm_node;
- NodeIter i;
+ WockyNode *lm_node;
+ WockyNodeIter i;
+ WockyNode *child;
g_assert (GABBLE_IS_MUC_CHANNEL (chan));
@@ -652,14 +651,14 @@ properties_disco_cb (GabbleDisco *disco,
*/
/* ROOM_PROP_NAME */
- lm_node = lm_message_node_get_child (query_result, "identity");
+ lm_node = wocky_node_get_child (query_result, "identity");
if (lm_node)
{
const gchar *category, *type, *name;
- category = lm_message_node_get_attribute (lm_node, "category");
- type = lm_message_node_get_attribute (lm_node, "type");
- name = lm_message_node_get_attribute (lm_node, "name");
+ category = wocky_node_get_attribute (lm_node, "category");
+ type = wocky_node_get_attribute (lm_node, "type");
+ name = wocky_node_get_attribute (lm_node, "name");
if (!tp_strdiff (category, "conference") &&
!tp_strdiff (type, "text") &&
@@ -669,10 +668,10 @@ properties_disco_cb (GabbleDisco *disco,
}
}
- for (i = node_iter (query_result); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, query_result, NULL, NULL);
+ while (wocky_node_iter_next (&i, &child))
{
const gchar *config_property_name = NULL;
- LmMessageNode *child = node_iter_data (i);
GValue val = { 0, };
if (strcmp (child->name, "feature") == 0)
@@ -680,7 +679,7 @@ properties_disco_cb (GabbleDisco *disco,
config_property_name = map_feature (child, &val);
}
else if (strcmp (child->name, "x") == 0 &&
- lm_message_node_has_namespace (child, NS_X_DATA, NULL))
+ wocky_node_has_ns (child, NS_X_DATA))
{
config_property_name = handle_form (child, &val);
}
@@ -1745,11 +1744,6 @@ update_permissions (GabbleMucChannel *chan)
}
}
-
-
-/* ************************************************************************* */
-/* wocky MUC implementation */
-
/* connect to wocky-muc:SIG_PRESENCE_ERROR */
static void
handle_error (GObject *source,
@@ -2116,7 +2110,7 @@ handle_fill_presence (WockyMuc *muc,
conn->self_presence->status_message,
0);
- g_signal_emit (self, signals[PRE_PRESENCE], 0, (LmMessage *) stanza);
+ g_signal_emit (self, signals[PRE_PRESENCE], 0, (WockyStanza *) stanza);
}
/* connect to wocky-muc:SIG_NICK_CHANGE, which we will receive when the *
@@ -2179,7 +2173,7 @@ update_roster_presence (GabbleMucChannel *gmuc,
}
gabble_presence_parse_presence_message (conn->presence_cache,
- handle, member->from, (LmMessage *) member->presence_stanza);
+ handle, member->from, (WockyStanza *) member->presence_stanza);
tp_handle_set_add (members, handle);
g_hash_table_insert (omap,
@@ -2303,7 +2297,7 @@ handle_presence (GObject *source,
}
gabble_presence_parse_presence_message (conn->presence_cache,
- handle, who->from, (LmMessage *) who->presence_stanza);
+ handle, who->from, (WockyStanza *) who->presence_stanza);
/* add the member in quesion */
tp_handle_set_add (handles, handle);
@@ -2516,7 +2510,7 @@ _gabble_muc_channel_handle_subject (GabbleMucChannel *chan,
TpHandle sender,
GDateTime *datetime,
const gchar *subject,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleMucChannelPrivate *priv;
const gchar *actor;
@@ -2591,7 +2585,7 @@ _gabble_muc_channel_receive (GabbleMucChannel *chan,
GDateTime *datetime,
const gchar *id,
const gchar *text,
- LmMessage *msg,
+ WockyStanza *msg,
TpChannelTextSendError send_error,
TpDeliveryStatus error_status)
{
@@ -2836,7 +2830,7 @@ gabble_muc_channel_send (GObject *obj,
gchar *id = NULL;
stanza = gabble_message_util_build_stanza (message, gabble_conn,
- LM_MESSAGE_SUB_TYPE_GROUPCHAT, TP_CHANNEL_CHAT_STATE_ACTIVE,
+ WOCKY_STANZA_SUB_TYPE_GROUPCHAT, TP_CHANNEL_CHAT_STATE_ACTIVE,
priv->jid, FALSE, &id, &error);
if (stanza != NULL)
@@ -2867,30 +2861,30 @@ gabble_muc_channel_send_invite (GabbleMucChannel *self,
{
TpBaseChannel *base = TP_BASE_CHANNEL (self);
GabbleMucChannelPrivate *priv = self->priv;
- LmMessage *msg;
- LmMessageNode *x_node, *invite_node;
+ WockyStanza *msg;
+ WockyNode *invite_node;
gboolean result;
g_signal_emit (self, signals[PRE_INVITE], 0, jid);
- msg = lm_message_new (priv->jid, LM_MESSAGE_TYPE_MESSAGE);
-
- x_node = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "x", NULL);
- lm_message_node_set_attribute (x_node, "xmlns", NS_MUC_USER);
-
- invite_node = lm_message_node_add_child (x_node, "invite", NULL);
-
- lm_message_node_set_attribute (invite_node, "to", jid);
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, priv->jid,
+ '(', "x", ':', NS_MUC_USER,
+ '(', "invite",
+ '@', "to", jid,
+ '*', &invite_node,
+ ')',
+ ')', NULL);
if (message != NULL && *message != '\0')
{
- lm_message_node_add_child (invite_node, "reason", message);
+ wocky_node_add_child_with_content (invite_node, "reason", message);
}
if (continue_)
{
- lm_message_node_add_child (invite_node, "continue", NULL);
+ wocky_node_add_child_with_content (invite_node, "continue", NULL);
}
DEBUG ("sending MUC invitation for room %s to contact %s with reason "
@@ -2898,7 +2892,7 @@ gabble_muc_channel_send_invite (GabbleMucChannel *self,
result = _gabble_connection_send (
GABBLE_CONNECTION (tp_base_channel_get_connection (base)), msg, error);
- lm_message_unref (msg);
+ g_object_unref (msg);
return result;
}
@@ -2982,17 +2976,15 @@ gabble_muc_channel_add_member (GObject *obj,
return gabble_muc_channel_send_invite (self, jid, message, FALSE, error);
}
-static LmHandlerResult
-kick_request_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
- LmMessage *reply_msg, GObject *object,
+static void
+kick_request_reply_cb (GabbleConnection *conn, WockyStanza *sent_msg,
+ WockyStanza *reply_msg, GObject *object,
gpointer user_data)
{
- if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, NULL, NULL, NULL))
{
DEBUG ("Failed to kick user %s from room", (const char *) user_data);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -3005,8 +2997,8 @@ gabble_muc_channel_remove_member (GObject *obj,
TpBaseChannel *base = TP_BASE_CHANNEL (chan);
GabbleMucChannelPrivate *priv = chan->priv;
TpGroupMixin *group = TP_GROUP_MIXIN (chan);
- LmMessage *msg;
- LmMessageNode *query_node, *item_node;
+ WockyStanza *msg;
+ WockyNode *item_node;
const gchar *jid, *nick;
gboolean result;
@@ -3020,14 +3012,13 @@ gabble_muc_channel_remove_member (GObject *obj,
}
/* Otherwise, the user wants to kick someone. */
- msg = lm_message_new_with_sub_type (priv->jid, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_SET);
-
- query_node = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "query", NULL);
- lm_message_node_set_attribute (query_node, "xmlns", NS_MUC_ADMIN);
-
- item_node = lm_message_node_add_child (query_node, "item", NULL);
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, priv->jid,
+ '(', "query", ':', NS_MUC_ADMIN,
+ '(', "item",
+ '*', &item_node,
+ ')',
+ ')', NULL);
jid = tp_handle_inspect (TP_GROUP_MIXIN (obj)->handle_repo, handle);
@@ -3035,14 +3026,14 @@ gabble_muc_channel_remove_member (GObject *obj,
if (nick != NULL)
nick++;
- lm_message_node_set_attributes (item_node,
+ wocky_node_set_attributes (item_node,
"nick", nick,
"role", "none",
NULL);
if (*message != '\0')
{
- lm_message_node_add_child (item_node, "reason", message);
+ wocky_node_add_child_with_content (item_node, "reason", message);
}
DEBUG ("sending MUC kick request for contact %u (%s) to room %s with reason "
@@ -3052,7 +3043,7 @@ gabble_muc_channel_remove_member (GObject *obj,
GABBLE_CONNECTION (tp_base_channel_get_connection (base)),
msg, kick_request_reply_cb, obj, (gpointer) jid, error);
- lm_message_unref (msg);
+ g_object_unref (msg);
return result;
}
@@ -3255,7 +3246,7 @@ request_config_form_reply_cb (
while (wocky_node_iter_next (&j, &child))
{
const gchar *var, *type_str;
- LmMessageNode *field_node;
+ WockyNode *field_node;
ConfigFormMapping *f;
GValue *value = NULL;
@@ -3434,7 +3425,7 @@ gabble_muc_channel_set_chat_state (TpSvcChannelInterfaceChatState *iface,
if (error != NULL ||
!gabble_message_util_send_chat_state (G_OBJECT (self),
GABBLE_CONNECTION (tp_base_channel_get_connection (base)),
- LM_MESSAGE_SUB_TYPE_GROUPCHAT, state, priv->jid, &error))
+ WOCKY_STANZA_SUB_TYPE_GROUPCHAT, state, priv->jid, &error))
{
dbus_g_method_return_error (context, error);
g_error_free (error);
diff --git a/src/muc-channel.h b/src/muc-channel.h
index ca8ce2296..6662512a5 100644
--- a/src/muc-channel.h
+++ b/src/muc-channel.h
@@ -25,7 +25,6 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/base-channel.h>
#include <telepathy-glib/dbus-properties-mixin.h>
#include <telepathy-glib/group-mixin.h>
diff --git a/src/muc-factory.c b/src/muc-factory.c
index 58b5271e1..09338c319 100644
--- a/src/muc-factory.c
+++ b/src/muc-factory.c
@@ -24,8 +24,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
@@ -74,7 +73,7 @@ struct _GabbleMucFactoryPrivate
GabbleConnection *conn;
gulong status_changed_id;
- LmMessageHandler *message_cb;
+ guint message_cb_id;
/* GUINT_TO_POINTER(room_handle) => (GabbleMucChannel *) */
GHashTable *text_channels;
/* Tubes channels which will be considered ready when the corresponding
@@ -120,8 +119,6 @@ gabble_muc_factory_init (GabbleMucFactory *fac)
priv->queued_requests = g_hash_table_new_full (g_direct_hash,
g_direct_equal, NULL, NULL);
- priv->message_cb = NULL;
-
priv->conn = NULL;
priv->dispose_has_run = FALSE;
}
@@ -570,7 +567,7 @@ obsolete_invite_disco_cb (GabbleDisco *self,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *query_result,
+ WockyNode *query_result,
GError* error,
gpointer user_data)
{
@@ -580,7 +577,7 @@ obsolete_invite_disco_cb (GabbleDisco *self,
GabbleMucFactoryPrivate *priv = fac->priv;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *identity;
+ WockyNode *identity;
const char *category = NULL, *type = NULL;
g_hash_table_remove (priv->disco_requests, request);
@@ -592,11 +589,11 @@ obsolete_invite_disco_cb (GabbleDisco *self,
goto out;
}
- identity = lm_message_node_get_child (query_result, "identity");
+ identity = wocky_node_get_child (query_result, "identity");
if (identity != NULL)
{
- category = lm_message_node_get_attribute (identity, "category");
- type = lm_message_node_get_attribute (identity, "type");
+ category = wocky_node_get_attribute (identity, "category");
+ type = wocky_node_get_attribute (identity, "type");
}
if (tp_strdiff (category, "conference") ||
@@ -618,7 +615,7 @@ out:
static gboolean
process_muc_invite (GabbleMucFactory *fac,
- LmMessage *message,
+ WockyStanza *message,
const gchar *from,
TpChannelTextSendError send_error)
{
@@ -627,13 +624,13 @@ process_muc_invite (GabbleMucFactory *fac,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *x_node, *invite_node, *reason_node;
+ WockyNode *x_node, *invite_node, *reason_node;
const gchar *invite_from, *reason = NULL;
TpHandle inviter_handle;
gchar *room;
/* does it have a muc subnode? */
- x_node = lm_message_node_get_child_with_namespace (
+ x_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (message), "x",
NS_MUC_USER);
@@ -641,7 +638,7 @@ process_muc_invite (GabbleMucFactory *fac,
return FALSE;
/* and an invitation? */
- invite_node = lm_message_node_get_child (x_node, "invite");
+ invite_node = wocky_node_get_child (x_node, "invite");
if (invite_node == NULL)
return FALSE;
@@ -655,7 +652,7 @@ process_muc_invite (GabbleMucFactory *fac,
return TRUE;
}
- invite_from = lm_message_node_get_attribute (invite_node, "from");
+ invite_from = wocky_node_get_attribute (invite_node, "from");
if (invite_from == NULL)
{
STANZA_DEBUG (message, "got a MUC invitation message with no JID; "
@@ -674,10 +671,10 @@ process_muc_invite (GabbleMucFactory *fac,
return TRUE;
}
- reason_node = lm_message_node_get_child (invite_node, "reason");
+ reason_node = wocky_node_get_child (invite_node, "reason");
if (reason_node != NULL)
- reason = lm_message_node_get_value (reason_node);
+ reason = reason_node->content;
/* create the channel */
room = gabble_remove_resource (from);
@@ -691,7 +688,7 @@ process_muc_invite (GabbleMucFactory *fac,
static gboolean
process_obsolete_invite (GabbleMucFactory *fac,
- LmMessage *message,
+ WockyStanza *message,
const gchar *from,
const gchar *body,
TpChannelTextSendError send_error)
@@ -701,14 +698,14 @@ process_obsolete_invite (GabbleMucFactory *fac,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *x_node;
+ WockyNode *x_node;
const gchar *room;
TpHandle inviter_handle;
GabbleDiscoRequest *request;
struct DiscoInviteData *disco_udata;
/* check for obsolete invite method */
- x_node = lm_message_node_get_child_with_namespace (
+ x_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (message), "x", NS_X_CONFERENCE);
if (x_node == NULL)
return FALSE;
@@ -725,7 +722,7 @@ process_obsolete_invite (GabbleMucFactory *fac,
}
/* the room JID is in x */
- room = lm_message_node_get_attribute (x_node, "jid");
+ room = wocky_node_get_attribute (x_node, "jid");
if (room == NULL)
{
STANZA_DEBUG (message,
@@ -774,14 +771,14 @@ process_obsolete_invite (GabbleMucFactory *fac,
/**
* muc_factory_message_cb:
*
- * Called by loudmouth when we get an incoming <message>.
+ * Called by Wocky when we get an incoming <message>.
* We filter only groupchat and MUC messages, ignoring the rest.
*/
-static LmHandlerResult
-muc_factory_message_cb (LmMessageHandler *handler,
- LmConnection *connection,
- LmMessage *message,
- gpointer user_data)
+static gboolean
+muc_factory_message_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data)
{
GabbleMucFactory *fac = GABBLE_MUC_FACTORY (user_data);
GabbleMucFactoryPrivate *priv = fac->priv;
@@ -795,26 +792,26 @@ muc_factory_message_cb (LmMessageHandler *handler,
if (!gabble_message_util_parse_incoming_message (message, &from, &stamp,
&msgtype, &id, &body, &state, &send_error, &delivery_status))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (conn_olpc_process_activity_properties_message (priv->conn, message,
from))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (conn_olpc_process_activity_uninvite_message (priv->conn, message,
from))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (process_muc_invite (fac, message, from, send_error))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
if (process_obsolete_invite (fac, message, from, body, send_error))
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
/* we used to check if a room with the jid exists, instead at this *
* point we stop caring: actual MUC messages are handled internally *
* by the wocky muc implementation */
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
void
@@ -913,17 +910,30 @@ gabble_muc_factory_close_all (GabbleMucFactory *self)
g_hash_table_unref (tmp);
}
- if (priv->message_cb != NULL)
+ if (priv->message_cb_id != 0)
{
- DEBUG ("removing callbacks");
+ WockyPorter *porter = gabble_connection_dup_porter (priv->conn);
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->message_cb, LM_MESSAGE_TYPE_MESSAGE);
+ wocky_porter_unregister_handler (porter, priv->message_cb_id);
+ priv->message_cb_id = 0;
+ g_object_unref (porter);
}
-
- tp_clear_pointer (&priv->message_cb, lm_message_handler_unref);
}
+static void
+porter_available_cb (
+ GabbleConnection *conn,
+ WockyPorter *porter,
+ gpointer user_data)
+{
+ GabbleMucFactory *self = GABBLE_MUC_FACTORY (user_data);
+
+ self->priv->message_cb_id = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_NORMAL,
+ muc_factory_message_cb, self,
+ NULL);
+}
static void
connection_status_changed_cb (GabbleConnection *conn,
@@ -931,21 +941,8 @@ connection_status_changed_cb (GabbleConnection *conn,
guint reason,
GabbleMucFactory *self)
{
- GabbleMucFactoryPrivate *priv = self->priv;
-
switch (status)
{
- case TP_CONNECTION_STATUS_CONNECTING:
- DEBUG ("adding callbacks");
- g_assert (priv->message_cb == NULL);
-
- priv->message_cb = lm_message_handler_new (muc_factory_message_cb,
- self, NULL);
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->message_cb, LM_MESSAGE_TYPE_MESSAGE,
- LM_HANDLER_PRIORITY_NORMAL);
- break;
-
case TP_CONNECTION_STATUS_DISCONNECTED:
gabble_muc_factory_close_all (self);
break;
@@ -964,6 +961,8 @@ gabble_muc_factory_constructor (GType type, guint n_props,
priv->status_changed_id = g_signal_connect (priv->conn,
"status-changed", (GCallback) connection_status_changed_cb, obj);
+ tp_g_signal_connect_object (priv->conn,
+ "porter-available", (GCallback) porter_available_cb, obj, 0);
return obj;
}
@@ -1057,7 +1056,7 @@ gabble_muc_factory_handle_si_stream_request (GabbleMucFactory *self,
GabbleBytestreamIface *bytestream,
TpHandle room_handle,
const gchar *stream_id,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleMucFactoryPrivate *priv = self->priv;
TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
@@ -1073,7 +1072,7 @@ gabble_muc_factory_handle_si_stream_request (GabbleMucFactory *self,
if (tube == NULL)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"No tubes channel available for this MUC" };
DEBUG ("tubes channel doesn't exist for muc %d", room_handle);
diff --git a/src/muc-factory.h b/src/muc-factory.h
index 4d6b2dedf..3707043da 100644
--- a/src/muc-factory.h
+++ b/src/muc-factory.h
@@ -21,6 +21,7 @@
#define __MUC_FACTORY_H__
#include <glib-object.h>
+#include <wocky/wocky.h>
#include "bytestream-iface.h"
#include "types.h"
@@ -64,7 +65,7 @@ GabbleMucChannel *gabble_muc_factory_find_text_channel (GabbleMucFactory *self,
void gabble_muc_factory_handle_si_stream_request (GabbleMucFactory *self,
GabbleBytestreamIface *bytestream, TpHandle room_handle,
- const gchar *stream_id, LmMessage *msg);
+ const gchar *stream_id, WockyStanza *msg);
void gabble_muc_factory_broadcast_presence (GabbleMucFactory *self);
diff --git a/src/plugin-loader.h b/src/plugin-loader.h
index 9983d4b44..210042008 100644
--- a/src/plugin-loader.h
+++ b/src/plugin-loader.h
@@ -25,7 +25,7 @@
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/presence-mixin.h>
-#include <wocky/wocky-session.h>
+#include <wocky/wocky.h>
#include "gabble/sidecar.h"
diff --git a/src/presence-cache.c b/src/presence-cache.c
index 87b536864..6fe08f6fb 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -37,12 +37,7 @@
#include <dbus/dbus-glib.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/intset.h>
-#include <wocky/wocky-caps-cache.h>
-#include <wocky/wocky-caps-hash.h>
-#include <wocky/wocky-disco-identity.h>
-#include <wocky/wocky-utils.h>
-#include <wocky/wocky-namespaces.h>
-#include <wocky/wocky-data-form.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
@@ -95,8 +90,8 @@ struct _GabblePresenceCachePrivate
GabbleConnection *conn;
gulong status_changed_cb;
- LmMessageHandler *lm_message_cb;
- LmMessageHandler *lm_presence_cb;
+ guint message_cb;
+ guint presence_cb;
GHashTable *presence;
TpHandleSet *presence_handles;
@@ -364,10 +359,20 @@ static void gabble_presence_cache_get_property (GObject *object, guint
static GabblePresence *_cache_insert (GabblePresenceCache *cache,
TpHandle handle);
+static void gabble_presence_cache_porter_available_cb (
+ GabbleConnection *conn,
+ WockyPorter *porter,
+ gpointer user_data);
static void gabble_presence_cache_status_changed_cb (GabbleConnection *,
TpConnectionStatus, TpConnectionStatusReason, gpointer);
-static LmHandlerResult gabble_presence_cache_lm_message_cb (LmMessageHandler*,
- LmConnection*, LmMessage*, gpointer);
+static gboolean _parse_message_message (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data);
+static gboolean gabble_presence_cache_presence_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data);
static void
gabble_presence_cache_class_init (GabblePresenceCacheClass *klass)
@@ -562,6 +567,8 @@ gabble_presence_cache_constructor (GType type, guint n_props,
priv->status_changed_cb = g_signal_connect (priv->conn, "status-changed",
G_CALLBACK (gabble_presence_cache_status_changed_cb), obj);
+ tp_g_signal_connect_object (priv->conn, "porter-available",
+ G_CALLBACK (gabble_presence_cache_porter_available_cb), obj, 0);
return obj;
}
@@ -588,8 +595,8 @@ gabble_presence_cache_dispose (GObject *object)
tp_clear_pointer (&priv->decloak_requests, g_hash_table_unref);
tp_clear_pointer (&priv->decloak_handles, tp_handle_set_destroy);
- g_assert (priv->lm_message_cb == NULL);
- g_assert (priv->lm_presence_cb == NULL);
+ g_assert (priv->message_cb == 0);
+ g_assert (priv->presence_cb == 0);
g_signal_handler_disconnect (priv->conn, priv->status_changed_cb);
@@ -660,6 +667,27 @@ gabble_presence_cache_set_property (GObject *object,
}
static void
+gabble_presence_cache_porter_available_cb (
+ GabbleConnection *conn,
+ WockyPorter *porter,
+ gpointer user_data)
+{
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (user_data);
+ GabblePresenceCachePrivate *priv = cache->priv;
+
+ priv->message_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ _parse_message_message, cache,
+ NULL);
+ priv->presence_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_PRESENCE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MIN,
+ gabble_presence_cache_presence_cb, cache,
+ NULL);
+}
+
+static void
gabble_presence_cache_status_changed_cb (GabbleConnection *conn,
TpConnectionStatus status,
TpConnectionStatusReason reason,
@@ -673,25 +701,6 @@ gabble_presence_cache_status_changed_cb (GabbleConnection *conn,
switch (status)
{
case TP_CONNECTION_STATUS_CONNECTING:
- g_assert (priv->lm_message_cb == NULL);
- g_assert (priv->lm_presence_cb == NULL);
-
- /* these are separate despite having the same callback and user_data,
- * because the Wocky fake-Loudmouth compat layer only lets you register
- * each handler once */
- priv->lm_message_cb = lm_message_handler_new (
- gabble_presence_cache_lm_message_cb, cache, NULL);
- priv->lm_presence_cb = lm_message_handler_new (
- gabble_presence_cache_lm_message_cb, cache, NULL);
-
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->lm_presence_cb,
- LM_MESSAGE_TYPE_PRESENCE,
- LM_HANDLER_PRIORITY_LAST);
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->lm_message_cb,
- LM_MESSAGE_TYPE_MESSAGE,
- LM_HANDLER_PRIORITY_FIRST);
break;
case TP_CONNECTION_STATUS_CONNECTED:
@@ -702,16 +711,20 @@ gabble_presence_cache_status_changed_cb (GabbleConnection *conn,
break;
case TP_CONNECTION_STATUS_DISCONNECTED:
- if (priv->lm_message_cb != NULL)
- lm_connection_unregister_message_handler (conn->lmconn,
- priv->lm_message_cb, LM_MESSAGE_TYPE_MESSAGE);
+ if (conn->session != NULL)
+ {
+ WockyPorter *porter = wocky_session_get_porter (conn->session);
+
+ if (priv->message_cb != 0)
+ wocky_porter_unregister_handler (porter, priv->message_cb);
- if (priv->lm_presence_cb != NULL)
- lm_connection_unregister_message_handler (conn->lmconn,
- priv->lm_presence_cb, LM_MESSAGE_TYPE_PRESENCE);
+ if (priv->presence_cb != 0)
+ wocky_porter_unregister_handler (porter, priv->presence_cb);
+
+ priv->message_cb = 0;
+ priv->presence_cb = 0;
+ }
- tp_clear_pointer (&priv->lm_message_cb, lm_message_handler_unref);
- tp_clear_pointer (&priv->lm_presence_cb, lm_message_handler_unref);
break;
default:
@@ -720,22 +733,10 @@ gabble_presence_cache_status_changed_cb (GabbleConnection *conn,
}
static GabblePresenceId
-_presence_node_get_status (LmMessageNode *pres_node)
+_presence_node_get_status (WockyNode *pres_node)
{
- const gchar *presence_show;
- LmMessageNode *child_node = lm_message_node_get_child (pres_node, "show");
-
- if (!child_node)
- {
- /*
- NODE_DEBUG (pres_node,
- "<presence> without <show> received from server, "
- "setting presence to available");
- */
- return GABBLE_PRESENCE_AVAILABLE;
- }
-
- presence_show = lm_message_node_get_value (child_node);
+ const gchar *presence_show =
+ wocky_node_get_content_from_child (pres_node, "show");
if (!presence_show)
{
@@ -768,12 +769,12 @@ static void
_grab_nickname (GabblePresenceCache *cache,
TpHandle handle,
const gchar *from,
- LmMessageNode *node)
+ WockyNode *node)
{
const gchar *nickname;
GabblePresence *presence;
- node = lm_message_node_get_child_with_namespace (node, "nick", NS_NICK);
+ node = wocky_node_get_child_ns (node, "nick", NS_NICK);
if (NULL == node)
return;
@@ -783,7 +784,7 @@ _grab_nickname (GabblePresenceCache *cache,
if (NULL == presence)
return;
- nickname = lm_message_node_get_value (node);
+ nickname = node->content;
DEBUG ("got nickname \"%s\" for %s", nickname, from);
if (tp_strdiff (presence->nickname, nickname))
@@ -798,7 +799,7 @@ static void
self_vcard_request_cb (GabbleVCardManager *self,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *error,
gpointer user_data)
{
@@ -887,12 +888,12 @@ static void
_grab_avatar_sha1 (GabblePresenceCache *cache,
TpHandle handle,
const gchar *from,
- LmMessageNode *node)
+ WockyNode *node)
{
GabblePresenceCachePrivate *priv = cache->priv;
TpBaseConnection *base_conn = (TpBaseConnection *) priv->conn;
const gchar *sha1;
- LmMessageNode *x_node, *photo_node;
+ WockyNode *x_node, *photo_node;
GabblePresence *presence;
if (handle == base_conn->self_handle)
@@ -903,7 +904,7 @@ _grab_avatar_sha1 (GabblePresenceCache *cache,
if (NULL == presence)
return;
- x_node = lm_message_node_get_child_with_namespace (node, "x",
+ x_node = wocky_node_get_child_ns (node, "x",
NS_VCARD_TEMP_UPDATE);
if (NULL == x_node)
@@ -925,14 +926,14 @@ _grab_avatar_sha1 (GabblePresenceCache *cache,
return;
}
- photo_node = lm_message_node_get_child (x_node, "photo");
+ photo_node = wocky_node_get_child (x_node, "photo");
/* If there is no photo node, the resource supports XEP-0153, but has
* nothing in particular to say about the avatar. */
if (NULL == photo_node)
return;
- sha1 = lm_message_node_get_value (photo_node);
+ sha1 = photo_node->content;
/* "" means we know there is no avatar. NULL means we don't know what is the
* avatar. In this case, there is a <photo> node. */
@@ -960,30 +961,30 @@ _grab_avatar_sha1 (GabblePresenceCache *cache,
static GSList *
_parse_cap_bundles (
- LmMessageNode *lm_node,
+ WockyNode *lm_node,
const gchar **hash,
const gchar **ver)
{
const gchar *node, *ext;
GSList *uris = NULL;
- LmMessageNode *cap_node;
+ WockyNode *cap_node;
*hash = NULL;
*ver = NULL;
- cap_node = lm_message_node_get_child_with_namespace (lm_node, "c", NS_CAPS);
+ cap_node = wocky_node_get_child_ns (lm_node, "c", NS_CAPS);
if (NULL == cap_node)
return NULL;
- *hash = lm_message_node_get_attribute (cap_node, "hash");
+ *hash = wocky_node_get_attribute (cap_node, "hash");
- node = lm_message_node_get_attribute (cap_node, "node");
+ node = wocky_node_get_attribute (cap_node, "node");
if (NULL == node)
return NULL;
- *ver = lm_message_node_get_attribute (cap_node, "ver");
+ *ver = wocky_node_get_attribute (cap_node, "ver");
if (NULL != *ver)
uris = g_slist_prepend (uris, g_strdup_printf ("%s#%s", node, *ver));
@@ -993,7 +994,7 @@ _parse_cap_bundles (
if (NULL != *hash)
return uris;
- ext = lm_message_node_get_attribute (cap_node, "ext");
+ ext = wocky_node_get_attribute (cap_node, "ext");
if (NULL != ext)
{
@@ -1012,19 +1013,19 @@ _parse_cap_bundles (
static void
_parse_node (GabblePresence *presence,
- LmMessageNode *lm_node,
+ WockyNode *lm_node,
const gchar *resource,
guint serial)
{
- LmMessageNode *cap_node;
+ WockyNode *cap_node;
const gchar *node;
- cap_node = lm_message_node_get_child_with_namespace (lm_node, "c", NS_CAPS);
+ cap_node = wocky_node_get_child_ns (lm_node, "c", NS_CAPS);
if (NULL == cap_node)
return;
- node = lm_message_node_get_attribute (cap_node, "node");
+ node = wocky_node_get_attribute (cap_node, "node");
if (!tp_strdiff (node, "http://mail.google.com/xmpp/client/caps"))
{
@@ -1044,7 +1045,7 @@ static void _caps_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *query_result,
+ WockyNode *query_result,
GError *error,
gpointer user_data);
@@ -1200,7 +1201,7 @@ emit_capabilities_discovered (GabblePresenceCache *cache,
static guint
client_types_from_message (TpHandle handle,
- LmMessageNode *lm_node,
+ WockyNode *lm_node,
const gchar *resource)
{
WockyNode *identity, *query_result = (WockyNode *) lm_node;
@@ -1285,7 +1286,7 @@ _caps_disco_cb (GabbleDisco *disco,
GabbleDiscoRequest *request,
const gchar *jid,
const gchar *node,
- LmMessageNode *query_result,
+ WockyNode *query_result,
GError *error,
gpointer user_data)
{
@@ -1648,7 +1649,7 @@ _process_caps (GabblePresenceCache *cache,
GabblePresence *presence,
TpHandle handle,
const gchar *from,
- LmMessageNode *lm_node)
+ WockyNode *lm_node)
{
const gchar *resource;
GSList *uris, *i;
@@ -1710,18 +1711,71 @@ _process_caps (GabblePresenceCache *cache,
g_slist_free (uris);
}
-LmHandlerResult
-gabble_presence_parse_presence_message (GabblePresenceCache *cache,
- TpHandle handle,
- const gchar *from,
- LmMessage *message)
+static void
+presence_cache_check_for_decloak_request (
+ GabblePresenceCache *cache,
+ WockyStanza *stanza,
+ TpHandle handle,
+ const gchar *from)
{
GabblePresenceCachePrivate *priv = cache->priv;
+ WockyNode *presence_node = wocky_stanza_get_top_node (stanza);
+ WockyNode *child_node;
+
+ /* If we receive (directed or broadcast) presence of any sort from someone,
+ * it counts as a reply to any pending de-cloak request we might have been
+ * tracking */
+ g_hash_table_remove (priv->decloak_requests, GUINT_TO_POINTER (handle));
+
+ child_node = wocky_node_get_child_ns (presence_node, "temppres",
+ NS_TEMPPRES);
+
+ if (child_node != NULL)
+ {
+ gboolean decloak;
+ const gchar *reason;
+
+ /* this is a request to de-cloak, i.e. leak a minimal version of our
+ * presence to the peer */
+ g_object_get (priv->conn,
+ "decloak-automatically", &decloak,
+ NULL);
+
+ reason = wocky_node_get_attribute (child_node, "reason");
+
+ if (reason == NULL)
+ reason = "";
+
+ DEBUG ("Considering whether to decloak, reason='%s', conclusion=%d",
+ reason, decloak);
+
+ conn_decloak_emit_requested (priv->conn, handle, reason, decloak);
+
+ if (decloak)
+ gabble_connection_send_capabilities (priv->conn, from, NULL);
+ }
+
+}
+
+
+/* FIXME: in a cruel twist of fate, this is called by GabbleMucChannel!
+ * Presumably this is because the handler priority here is MIN, so WockyMuc
+ * steals the presence stanza before we can scrape our information out of it?
+ */
+gboolean
+gabble_presence_parse_presence_message (
+ GabblePresenceCache *cache,
+ TpHandle handle,
+ const gchar *from,
+ WockyStanza *message)
+{
+ GabblePresenceCachePrivate *priv = cache->priv;
+ const gchar *prio;
gint8 priority = 0;
const gchar *resource, *status_message = NULL;
gchar *my_full_jid;
- LmMessageNode *presence_node, *child_node;
- LmHandlerResult ret = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ WockyNode *presence_node;
+ WockyStanzaSubType sub_type;
GabblePresenceId presence_id;
GabblePresence *presence;
@@ -1733,7 +1787,7 @@ gabble_presence_parse_presence_message (GabblePresenceCache *cache,
if (!tp_strdiff (from, my_full_jid))
{
g_free (my_full_jid);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
g_free (my_full_jid);
@@ -1751,61 +1805,19 @@ gabble_presence_parse_presence_message (GabblePresenceCache *cache,
* presence around when it's unavailable. */
presence->keep_unavailable = FALSE;
- /* If we receive (directed or broadcast) presence of any sort from someone,
- * it counts as a reply to any pending de-cloak request we might have been
- * tracking */
- g_hash_table_remove (priv->decloak_requests, GUINT_TO_POINTER (handle));
-
- child_node = lm_message_node_get_child (presence_node, "status");
-
- if (child_node)
- status_message = lm_message_node_get_value (child_node);
-
- if (child_node)
- status_message = lm_message_node_get_value (child_node);
-
- child_node = lm_message_node_get_child (presence_node, "priority");
-
- if (child_node)
- {
- const gchar *prio = lm_message_node_get_value (child_node);
-
- if (prio != NULL)
- priority = CLAMP (atoi (prio), G_MININT8, G_MAXINT8);
- }
+ status_message = wocky_node_get_content_from_child (presence_node, "status");
+ prio = wocky_node_get_content_from_child (presence_node, "priority");
- child_node = wocky_node_get_child_ns (presence_node, "temppres",
- NS_TEMPPRES);
+ if (prio != NULL)
+ priority = CLAMP (atoi (prio), G_MININT8, G_MAXINT8);
- if (child_node != NULL)
- {
- gboolean decloak;
- const gchar *reason;
-
- /* this is a request to de-cloak, i.e. leak a minimal version of our
- * presence to the peer */
- g_object_get (priv->conn,
- "decloak-automatically", &decloak,
- NULL);
-
- reason = lm_message_node_get_attribute (child_node, "reason");
-
- if (reason == NULL)
- reason = "";
-
- DEBUG ("Considering whether to decloak, reason='%s', conclusion=%d",
- reason, decloak);
+ presence_cache_check_for_decloak_request (cache, message, handle, from);
- conn_decloak_emit_requested (priv->conn, handle, reason, decloak);
-
- if (decloak)
- gabble_connection_send_capabilities (priv->conn, from, NULL);
- }
-
- switch (lm_message_get_sub_type (message))
+ wocky_stanza_get_type_info (message, NULL, &sub_type);
+ switch (sub_type)
{
- case LM_MESSAGE_SUB_TYPE_NOT_SET:
- case LM_MESSAGE_SUB_TYPE_AVAILABLE:
+ case WOCKY_STANZA_SUB_TYPE_NONE:
+ case WOCKY_STANZA_SUB_TYPE_AVAILABLE:
presence_id = _presence_node_get_status (presence_node);
gabble_presence_cache_update (cache, handle, resource, presence_id,
status_message, priority);
@@ -1817,18 +1829,34 @@ gabble_presence_parse_presence_message (GabblePresenceCache *cache,
_grab_avatar_sha1 (cache, handle, from, presence_node);
_process_caps (cache, presence, handle, from, presence_node);
- ret = LM_HANDLER_RESULT_REMOVE_MESSAGE;
- break;
+ return TRUE;
+
+ case WOCKY_STANZA_SUB_TYPE_ERROR:
+ {
+ GError *error = NULL;
+ gboolean ret;
- case LM_MESSAGE_SUB_TYPE_ERROR:
NODE_DEBUG (presence_node, "Received error presence");
+
+ ret = wocky_stanza_extract_errors (message, NULL, &error, NULL, NULL);
+ g_assert (ret);
+
+ /* If there's a <status/> in this presence, it's our own echoed back at
+ * us. So we don't want to use that. Instead, we use the <error><text> if
+ * there is any, or the name of the error condition if not. */
+ if (tp_str_empty (error->message))
+ status_message = wocky_enum_to_nick (WOCKY_TYPE_XMPP_ERROR,
+ error->code);
+ else
+ status_message = error->message;
+
gabble_presence_cache_update (cache, handle, resource,
GABBLE_PRESENCE_ERROR, status_message, priority);
- ret = LM_HANDLER_RESULT_REMOVE_MESSAGE;
- break;
+ return TRUE;
+ }
- case LM_MESSAGE_SUB_TYPE_UNAVAILABLE:
+ case WOCKY_STANZA_SUB_TYPE_UNAVAILABLE:
if (gabble_roster_handle_sends_presence_to_us (priv->conn->roster,
handle))
presence_id = GABBLE_PRESENCE_OFFLINE;
@@ -1838,14 +1866,11 @@ gabble_presence_parse_presence_message (GabblePresenceCache *cache,
gabble_presence_cache_update (cache, handle, resource,
presence_id, status_message, priority);
- ret = LM_HANDLER_RESULT_REMOVE_MESSAGE;
- break;
+ return TRUE;
default:
- break;
+ return FALSE;
}
-
- return ret;
}
/* FIXME: this scrapes nicknames out of <messages>, and relies on im-channel.c
@@ -1858,24 +1883,45 @@ gabble_presence_parse_presence_message (GabblePresenceCache *cache,
* to go away when the channel closes, rather than relying on this
* spooky-action-at-a-distance.
*/
-static LmHandlerResult
-_parse_message_message (GabblePresenceCache *cache,
- TpHandle handle,
- const gchar *from,
- LmMessage *message)
+static gboolean
+_parse_message_message (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data)
{
- LmMessageNode *node;
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (user_data);
+ GabblePresenceCachePrivate *priv = cache->priv;
+ TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+ (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
+ const gchar *from = wocky_stanza_get_from (message);
+ TpHandle handle;
+ WockyStanzaSubType sub_type;
+ WockyNode *node;
GabblePresence *presence;
- switch (lm_message_get_sub_type (message))
+ if (NULL == from)
+ {
+ STANZA_DEBUG (message, "message without from attribute, ignoring");
+ return FALSE;
+ }
+
+ handle = tp_handle_ensure (contact_repo, from, NULL, NULL);
+ if (0 == handle)
+ {
+ STANZA_DEBUG (message, "ignoring message from malformed jid");
+ return FALSE;
+ }
+
+ wocky_stanza_get_type_info (message, NULL, &sub_type);
+ switch (sub_type)
{
- case LM_MESSAGE_SUB_TYPE_NOT_SET:
- case LM_MESSAGE_SUB_TYPE_NORMAL:
- case LM_MESSAGE_SUB_TYPE_CHAT:
- case LM_MESSAGE_SUB_TYPE_GROUPCHAT:
+ case WOCKY_STANZA_SUB_TYPE_NONE:
+ case WOCKY_STANZA_SUB_TYPE_NORMAL:
+ case WOCKY_STANZA_SUB_TYPE_CHAT:
+ case WOCKY_STANZA_SUB_TYPE_GROUPCHAT:
break;
default:
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
presence = gabble_presence_cache_get (cache, handle);
@@ -1886,72 +1932,46 @@ _parse_message_message (GabblePresenceCache *cache,
presence->keep_unavailable = TRUE;
}
- node = lm_message_get_node (message);
+ node = wocky_stanza_get_top_node (message);
_grab_nickname (cache, handle, from, node);
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
-/**
- * gabble_presence_cache_lm_message_cb:
- * @handler: #LmMessageHandler for this message
- * @connection: #LmConnection that originated the message
- * @message: the presence message
- * @user_data: callback data
+/*
+ * gabble_presence_cache_presence_cb:
*
- * Called by loudmouth when we get an incoming <presence>.
+ * Called by Wocky when we get an incoming <presence>.
*/
-static LmHandlerResult
-gabble_presence_cache_lm_message_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *message,
- gpointer user_data)
+static gboolean
+gabble_presence_cache_presence_cb (
+ WockyPorter *porter,
+ WockyStanza *message,
+ gpointer user_data)
{
GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (user_data);
GabblePresenceCachePrivate *priv = cache->priv;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
- const char *from;
- LmHandlerResult ret;
+ const char *from = wocky_stanza_get_from (message);
TpHandle handle;
- g_assert (lmconn == priv->conn->lmconn);
-
- from = lm_message_node_get_attribute (wocky_stanza_get_top_node (message),
- "from");
-
if (NULL == from)
{
STANZA_DEBUG (message, "message without from attribute, ignoring");
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return FALSE;
}
handle = tp_handle_ensure (contact_repo, from, NULL, NULL);
-
if (0 == handle)
{
STANZA_DEBUG (message, "ignoring message from malformed jid");
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
- }
-
- switch (lm_message_get_type (message))
- {
- case LM_MESSAGE_TYPE_PRESENCE:
- ret = gabble_presence_parse_presence_message (cache, handle,
- from, message);
- break;
- case LM_MESSAGE_TYPE_MESSAGE:
- ret = _parse_message_message (cache, handle, from, message);
- break;
- default:
- ret = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
- break;
+ return FALSE;
}
- tp_handle_unref (contact_repo, handle);
- return ret;
+ return gabble_presence_parse_presence_message (cache, handle, from, message);
}
diff --git a/src/presence-cache.h b/src/presence-cache.h
index 0e5283967..8c05e69fe 100644
--- a/src/presence-cache.h
+++ b/src/presence-cache.h
@@ -118,11 +118,11 @@ const GabbleCapabilityInfo *gabble_presence_cache_peek_own_caps (
void gabble_presence_cache_really_remove (GabblePresenceCache *cache,
TpHandle handle);
-LmHandlerResult
-gabble_presence_parse_presence_message (GabblePresenceCache *cache,
+gboolean gabble_presence_parse_presence_message (
+ GabblePresenceCache *cache,
TpHandle handle,
const gchar *from,
- LmMessage *message);
+ WockyStanza *message);
void gabble_presence_cache_contacts_added_to_olpc_view (
GabblePresenceCache *cache, TpHandleSet *handles);
diff --git a/src/presence.c b/src/presence.c
index 1ddaedf6f..704834ca2 100644
--- a/src/presence.c
+++ b/src/presence.c
@@ -23,8 +23,7 @@
#include <string.h>
#include <telepathy-glib/channel-manager.h>
-#include <wocky/wocky-utils.h>
-#include <wocky/wocky-xep-0115-capabilities.h>
+#include <wocky/wocky.h>
#include "gabble/capabilities.h"
#include "conn-presence.h"
@@ -644,34 +643,34 @@ gabble_presence_add_status_and_vcard (GabblePresence *presence,
}
}
-LmMessage *
+WockyStanza *
gabble_presence_as_message (GabblePresence *presence,
const gchar *to)
{
GabblePresencePrivate *priv = presence->priv;
- LmMessage *message;
- LmMessageSubType subtype;
+ WockyStanza *message;
+ WockyStanzaSubType subtype;
Resource *res = priv->resources->data; /* pick first resource */
g_assert (NULL != res);
if (presence->status == GABBLE_PRESENCE_OFFLINE)
- subtype = LM_MESSAGE_SUB_TYPE_UNAVAILABLE;
+ subtype = WOCKY_STANZA_SUB_TYPE_UNAVAILABLE;
else
- subtype = LM_MESSAGE_SUB_TYPE_AVAILABLE;
+ subtype = WOCKY_STANZA_SUB_TYPE_AVAILABLE;
- message = lm_message_new_with_sub_type (to, LM_MESSAGE_TYPE_PRESENCE,
- subtype);
+ message = wocky_stanza_build (WOCKY_STANZA_TYPE_PRESENCE, subtype,
+ NULL, to, NULL);
gabble_presence_add_status_and_vcard (presence, message);
if (res->priority)
{
gchar *priority = g_strdup_printf ("%d", res->priority);
- LmMessageNode *node;
+ WockyNode *node;
- node = lm_message_get_node (message);
- lm_message_node_add_child (node, "priority", priority);
+ node = wocky_stanza_get_top_node (message);
+ wocky_node_add_child_with_content (node, "priority", priority);
g_free (priority);
}
diff --git a/src/presence.h b/src/presence.h
index 50d6945a5..e2d51814b 100644
--- a/src/presence.h
+++ b/src/presence.h
@@ -115,7 +115,7 @@ gboolean gabble_presence_resource_has_caps (GabblePresence *presence,
const gchar *resource, GabbleCapabilitySetPredicate predicate,
gconstpointer user_data);
-LmMessage *gabble_presence_as_message (GabblePresence *presence,
+WockyStanza *gabble_presence_as_message (GabblePresence *presence,
const gchar *to);
void gabble_presence_add_status_and_vcard (GabblePresence *presence,
WockyStanza *stanza);
diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index 1bd97b7db..ea418f262 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -25,11 +25,11 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/exportable-channel.h>
#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/util.h>
#include "extensions/extensions.h"
@@ -55,8 +55,9 @@ static GabbleTubesChannel *new_tubes_channel (GabblePrivateTubesFactory *fac,
static void tubes_channel_closed_cb (GabbleTubesChannel *chan,
gpointer user_data);
-static LmHandlerResult private_tubes_factory_msg_tube_cb (
- LmMessageHandler *handler, LmConnection *lmconn, LmMessage *msg,
+static gboolean private_tubes_factory_msg_tube_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
gpointer user_data);
static void channel_manager_iface_init (gpointer, gpointer);
@@ -81,7 +82,8 @@ struct _GabblePrivateTubesFactoryPrivate
{
GabbleConnection *conn;
gulong status_changed_id;
- LmMessageHandler *msg_tube_cb;
+ guint msg_tube_cb;
+ guint msg_close_cb;
GHashTable *tubes_channels;
@@ -110,7 +112,6 @@ gabble_private_tubes_factory_init (GabblePrivateTubesFactory *self)
self->priv = priv;
- priv->msg_tube_cb = NULL;
priv->tubes_channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
@@ -122,6 +123,28 @@ gabble_private_tubes_factory_init (GabblePrivateTubesFactory *self)
static void gabble_private_tubes_factory_close_all (
GabblePrivateTubesFactory *fac);
+static void
+porter_available_cb (
+ GabbleConnection *connection,
+ WockyPorter *porter,
+ gpointer user_data)
+{
+ GabblePrivateTubesFactory *self = GABBLE_PRIVATE_TUBES_FACTORY (user_data);
+ GabblePrivateTubesFactoryPrivate *priv = self->priv;
+
+ priv->msg_tube_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ private_tubes_factory_msg_tube_cb, self,
+ '(', "tube", ':', NS_TUBES,
+ ')', NULL);
+ priv->msg_close_cb = wocky_porter_register_handler_from_anyone (porter,
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ WOCKY_PORTER_HANDLER_PRIORITY_MAX,
+ private_tubes_factory_msg_tube_cb, self,
+ '(', "close", ':', NS_TUBES,
+ ')', NULL);
+}
static void
connection_status_changed_cb (GabbleConnection *conn,
@@ -153,13 +176,10 @@ gabble_private_tubes_factory_constructor (GType type,
self = GABBLE_PRIVATE_TUBES_FACTORY (obj);
priv = GABBLE_PRIVATE_TUBES_FACTORY_GET_PRIVATE (self);
- priv->msg_tube_cb = lm_message_handler_new (
- private_tubes_factory_msg_tube_cb, self, NULL);
- lm_connection_register_message_handler (priv->conn->lmconn,
- priv->msg_tube_cb, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_FIRST);
-
self->priv->status_changed_id = g_signal_connect (self->priv->conn,
"status-changed", (GCallback) connection_status_changed_cb, obj);
+ tp_g_signal_connect_object (priv->conn, "porter-available",
+ (GCallback) porter_available_cb, obj, 0);
return obj;
}
@@ -363,11 +383,15 @@ gabble_private_tubes_factory_close_all (GabblePrivateTubesFactory *fac)
priv->status_changed_id = 0;
}
- if (priv->msg_tube_cb != NULL)
- lm_connection_unregister_message_handler (priv->conn->lmconn,
- priv->msg_tube_cb, LM_MESSAGE_TYPE_MESSAGE);
+ if (priv->msg_tube_cb != 0)
+ {
+ WockyPorter *porter = wocky_session_get_porter (priv->conn->session);
- tp_clear_pointer (&priv->msg_tube_cb, lm_message_handler_unref);
+ wocky_porter_unregister_handler (porter, priv->msg_tube_cb);
+ priv->msg_tube_cb = 0;
+ wocky_porter_unregister_handler (porter, priv->msg_close_cb);
+ priv->msg_close_cb = 0;
+ }
/* Use a temporary variable (the macro does this) because we don't want
* tubes_channel_closed_cb to remove the channel from the hash table a
@@ -668,7 +692,7 @@ gabble_private_tubes_factory_handle_si_tube_request (
GabbleBytestreamIface *bytestream,
TpHandle handle,
const gchar *stream_id,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabblePrivateTubesFactoryPrivate *priv =
GABBLE_PRIVATE_TUBES_FACTORY_GET_PRIVATE (self);
@@ -697,7 +721,7 @@ gabble_private_tubes_factory_handle_si_stream_request (
GabbleBytestreamIface *bytestream,
TpHandle handle,
const gchar *stream_id,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabblePrivateTubesFactoryPrivate *priv =
GABBLE_PRIVATE_TUBES_FACTORY_GET_PRIVATE (self);
@@ -711,7 +735,7 @@ gabble_private_tubes_factory_handle_si_stream_request (
chan = g_hash_table_lookup (priv->tubes_channels, GUINT_TO_POINTER (handle));
if (chan == NULL)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"No tubes channel available for this contact" };
DEBUG ("tubes channel with contact %d doesn't exist", handle);
@@ -722,43 +746,42 @@ gabble_private_tubes_factory_handle_si_stream_request (
gabble_tubes_channel_bytestream_offered (chan, bytestream, msg);
}
-static LmHandlerResult
-private_tubes_factory_msg_tube_cb (LmMessageHandler *handler,
- LmConnection *lmconn,
- LmMessage *msg,
- gpointer user_data)
+static gboolean
+private_tubes_factory_msg_tube_cb (
+ WockyPorter *porter,
+ WockyStanza *msg,
+ gpointer user_data)
{
GabblePrivateTubesFactory *self = GABBLE_PRIVATE_TUBES_FACTORY (user_data);
GabblePrivateTubesFactoryPrivate *priv =
GABBLE_PRIVATE_TUBES_FACTORY_GET_PRIVATE (self);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *tube_node, *close_node;
+ WockyNode *tube_node, *close_node;
GabbleTubesChannel *chan;
const gchar *from;
TpHandle handle;
- tube_node = lm_message_node_get_child_with_namespace (
+ tube_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "tube", NS_TUBES);
- close_node = lm_message_node_get_child_with_namespace (
+ close_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "close", NS_TUBES);
- if (tube_node == NULL && close_node == NULL)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ g_return_val_if_fail (tube_node != NULL || close_node != NULL, FALSE);
- from = lm_message_node_get_attribute (
+ from = wocky_node_get_attribute (
wocky_stanza_get_top_node (msg), "from");
if (from == NULL)
{
STANZA_DEBUG (msg, "got a message without a from field");
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return FALSE;
}
handle = tp_handle_lookup (contact_repo, from, NULL, NULL);
if (handle == 0)
{
DEBUG ("Invalid from field");
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return FALSE;
}
/* Tube offer */
@@ -776,13 +799,13 @@ private_tubes_factory_msg_tube_cb (LmMessageHandler *handler,
{
DEBUG ("Ignore tube close message as there is no tubes channel"
" to handle it");
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
}
gabble_tubes_channel_tube_msg (chan, msg);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return TRUE;
}
GabblePrivateTubesFactory *
diff --git a/src/private-tubes-factory.h b/src/private-tubes-factory.h
index f04f1ea4b..d9895199d 100644
--- a/src/private-tubes-factory.h
+++ b/src/private-tubes-factory.h
@@ -21,7 +21,6 @@
#define __PRIVATE_TUBES_FACTORY_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/base-connection.h>
#include "connection.h"
@@ -69,12 +68,12 @@ GabblePrivateTubesFactory * gabble_private_tubes_factory_new (
/* New 1-1 D-Bus tube requested by the remote contact */
void gabble_private_tubes_factory_handle_si_tube_request (
GabblePrivateTubesFactory *fac, GabbleBytestreamIface *bytestream,
- TpHandle handle, const gchar *stream_id, LmMessage *msg);
+ TpHandle handle, const gchar *stream_id, WockyStanza *msg);
/* New connection requested in a existing 1-1 stream tube */
void gabble_private_tubes_factory_handle_si_stream_request (
GabblePrivateTubesFactory *fac, GabbleBytestreamIface *bytestream,
- TpHandle handle, const gchar *stream_id, LmMessage *msg);
+ TpHandle handle, const gchar *stream_id, WockyStanza *msg);
G_END_DECLS
diff --git a/src/protocol.c b/src/protocol.c
index a6e343188..04b5e8506 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <telepathy-glib/base-connection-manager.h>
+#include <telepathy-glib/interfaces.h>
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-glib.h>
diff --git a/src/request-pipeline.c b/src/request-pipeline.c
index 3fdd64c72..1bbfe4aa4 100644
--- a/src/request-pipeline.c
+++ b/src/request-pipeline.c
@@ -44,7 +44,7 @@ G_DEFINE_TYPE (GabbleRequestPipeline, gabble_request_pipeline, G_TYPE_OBJECT);
struct _GabbleRequestPipelineItem
{
GabbleRequestPipeline *pipeline;
- LmMessage *message;
+ WockyStanza *message;
guint timer_id;
guint timeout;
gboolean in_flight;
@@ -193,7 +193,7 @@ delete_item (GabbleRequestPipelineItem *item)
if (item->timer_id)
g_source_remove (item->timer_id);
- tp_clear_pointer (&item->message, lm_message_unref);
+ tp_clear_pointer (&item->message, g_object_unref);
g_slice_free (GabbleRequestPipelineItem, item);
}
@@ -290,10 +290,10 @@ gabble_request_pipeline_finalize (GObject *object)
G_OBJECT_CLASS (gabble_request_pipeline_parent_class)->finalize (object);
}
-static LmHandlerResult
+static void
response_cb (GabbleConnection *conn,
- LmMessage *sent,
- LmMessage *reply,
+ WockyStanza *sent,
+ WockyStanza *reply,
GObject *object,
gpointer user_data)
{
@@ -307,7 +307,7 @@ response_cb (GabbleConnection *conn,
DEBUG ("got reply for request %p", item);
if (NULL == g_slist_find (priv->items_in_flight, item))
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ return;
g_assert (item->in_flight);
@@ -315,8 +315,8 @@ response_cb (GabbleConnection *conn,
if (!item->zombie)
{
- GError *error = gabble_message_get_xmpp_error (reply);
-
+ GError *error = NULL;
+ wocky_stanza_extract_errors (reply, NULL, &error, NULL, NULL);
item->callback (priv->connection, reply, item->user_data, error);
g_clear_error (&error);
}
@@ -328,8 +328,6 @@ response_cb (GabbleConnection *conn,
delete_item (item);
gabble_request_pipeline_go (pipeline);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -406,7 +404,7 @@ delayed_run_pipeline (gpointer user_data)
GabbleRequestPipelineItem *
gabble_request_pipeline_enqueue (GabbleRequestPipeline *pipeline,
- LmMessage *msg,
+ WockyStanza *msg,
guint timeout,
GabbleRequestPipelineCb callback,
gpointer user_data)
@@ -426,7 +424,7 @@ gabble_request_pipeline_enqueue (GabbleRequestPipeline *pipeline,
item->callback = callback;
item->user_data = user_data;
- lm_message_ref (msg);
+ g_object_ref (msg);
priv->pending_items = g_slist_append (priv->pending_items, item);
diff --git a/src/request-pipeline.h b/src/request-pipeline.h
index 5341c5289..2b094e765 100644
--- a/src/request-pipeline.h
+++ b/src/request-pipeline.h
@@ -22,8 +22,7 @@
#define __GABBLE_REQUEST_PIPELINE_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
+#include <wocky/wocky.h>
#include "types.h"
G_BEGIN_DECLS
@@ -32,7 +31,7 @@ typedef struct _GabbleRequestPipelinePrivate GabbleRequestPipelinePrivate;
typedef struct _GabbleRequestPipelineClass GabbleRequestPipelineClass;
typedef struct _GabbleRequestPipelineItem GabbleRequestPipelineItem;
typedef void (*GabbleRequestPipelineCb) (GabbleConnection *conn,
- LmMessage *msg, gpointer user_data, GError *error);
+ WockyStanza *msg, gpointer user_data, GError *error);
/**
* GabbleRequestPipelineError:
@@ -78,7 +77,7 @@ struct _GabbleRequestPipeline {
GabbleRequestPipeline *gabble_request_pipeline_new (GabbleConnection *conn);
GabbleRequestPipelineItem *gabble_request_pipeline_enqueue
- (GabbleRequestPipeline *pipeline, LmMessage *msg, guint timeout,
+ (GabbleRequestPipeline *pipeline, WockyStanza *msg, guint timeout,
GabbleRequestPipelineCb callback, gpointer user_data);
void gabble_request_pipeline_item_cancel (GabbleRequestPipelineItem *req);
diff --git a/src/roomlist-manager.c b/src/roomlist-manager.c
index e3cb09a4a..6f8d499ea 100644
--- a/src/roomlist-manager.c
+++ b/src/roomlist-manager.c
@@ -25,7 +25,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
diff --git a/src/roster.c b/src/roster.c
index fec216bdf..711ea01ad 100644
--- a/src/roster.c
+++ b/src/roster.c
@@ -28,10 +28,7 @@
#include <telepathy-glib/channel-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
-#include <wocky/wocky-c2s-porter.h>
-#include <wocky/wocky-namespaces.h>
-#include <wocky/wocky-node.h>
-#include <wocky/wocky-stanza.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_ROSTER
@@ -311,17 +308,13 @@ _parse_item_groups (WockyNode *item_node, TpBaseConnection *conn)
conn, TP_HANDLE_TYPE_GROUP);
TpHandleSet *groups = tp_handle_set_new (group_repo);
TpHandle handle;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *group_node;
- for (i = node_iter (item_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, item_node, "group", NULL);
+ while (wocky_node_iter_next (&i, &group_node))
{
- WockyNode *group_node = node_iter_data (i);
- const gchar *value;
-
- if (0 != strcmp (group_node->name, "group"))
- continue;
-
- value = group_node->content;
+ const gchar *value = group_node->content;
if (NULL == value)
continue;
@@ -1027,8 +1020,7 @@ is_google_roster_push (
/**
* validate_roster_item:
* @contact_repo: the handle repository for contacts
- * @item_node: a child of a <query xmlns='jabber:iq:roster'>, purporting to be
- * an <item>
+ * @item_node: an <item> child of a <query xmlns='jabber:iq:roster'>
* @jid_out: location at which to store the roster item's jid, borrowed from
* @item_node, if the item is valid.
*
@@ -1044,12 +1036,6 @@ validate_roster_item (
const gchar *jid;
TpHandle handle;
- if (strcmp (item_node->name, "item"))
- {
- NODE_DEBUG (item_node, "query sub-node is not item, skipping");
- return 0;
- }
-
jid = wocky_node_get_attribute (item_node, "jid");
if (!jid)
{
@@ -1103,17 +1089,18 @@ process_roster (
TpHandleSet *referenced_handles = tp_handle_set_new (contact_repo);
gboolean google_roster = is_google_roster_push (roster, query_node);
- NodeIter j;
+ WockyNodeIter j;
+ WockyNode *item_node;
if (google_roster)
blocking_changed = tp_handle_set_new (contact_repo);
else
blocking_changed = NULL;
- /* iterate every sub-node, which we expect to be <item>s */
- for (j = node_iter (query_node); j; j = node_iter_next (j))
+ /* iterate every <item> sub-node */
+ wocky_node_iter_init (&j, query_node, "item", NULL);
+ while (wocky_node_iter_next (&j, &item_node))
{
- WockyNode *item_node = node_iter_data (j);
const char *jid;
TpHandle handle;
GabbleRosterItem *item;
diff --git a/src/search-channel.c b/src/search-channel.c
index bc15fc4fd..afbb098ee 100644
--- a/src/search-channel.c
+++ b/src/search-channel.c
@@ -29,13 +29,12 @@
#include <telepathy-glib/svc-channel.h>
#include <telepathy-glib/util.h>
-#include <wocky/wocky-utils.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_SEARCH
+#include <gabble/error.h>
#include "connection.h"
#include "debug.h"
-#include "error.h"
#include "gabble-signals-marshal.h"
#include "namespaces.h"
#include "util.h"
@@ -206,21 +205,22 @@ supported_field_discovery_failed (GabbleSearchChannel *chan,
static GPtrArray *
parse_unextended_field_response (
GabbleSearchChannel *self,
- LmMessageNode *query_node,
+ WockyNode *query_node,
GError **error)
{
GPtrArray *search_keys = g_ptr_array_new ();
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *field;
- for (i = node_iter (query_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, query_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &field))
{
- LmMessageNode *field = node_iter_data (i);
gchar *tp_name;
if (!strcmp (field->name, "instructions"))
{
DEBUG ("server gave us some instructions: %s",
- lm_message_node_get_value (field));
+ field->content);
continue;
}
@@ -263,30 +263,31 @@ name_in_array (GPtrArray *array,
static GPtrArray *
parse_data_form (
GabbleSearchChannel *self,
- LmMessageNode *x_node,
+ WockyNode *x_node,
GError **error)
{
GPtrArray *search_keys = g_ptr_array_new ();
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *n;
- if (tp_strdiff (lm_message_node_get_attribute (x_node, "type"), "form"))
+ if (tp_strdiff (wocky_node_get_attribute (x_node, "type"), "form"))
{
g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
"server is broken: <x> not type='form'");
goto fail;
}
- for (i = node_iter (x_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, x_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &n))
{
- LmMessageNode *n = node_iter_data (i);
- const gchar *type = lm_message_node_get_attribute (n, "type");
- const gchar *var = lm_message_node_get_attribute (n, "var");
+ const gchar *type = wocky_node_get_attribute (n, "type");
+ const gchar *var = wocky_node_get_attribute (n, "var");
gchar *tp_name;
if (!strcmp (n->name, "title") ||
!strcmp (n->name, "instructions"))
{
- DEBUG ("ignoring <%s>: %s", n->name, lm_message_node_get_value (n));
+ DEBUG ("ignoring <%s>: %s", n->name, n->content);
continue;
}
@@ -301,9 +302,10 @@ parse_data_form (
if (!strcmp (var, "FORM_TYPE"))
{
- if (node_iter (n) == NULL ||
- strcmp (lm_message_node_get_value (node_iter_data (
- node_iter (n))), NS_SEARCH))
+ const gchar *form_type = wocky_node_get_content_from_child (n,
+ "value");
+
+ if (tp_strdiff (form_type, NS_SEARCH))
{
DEBUG ("<x> form does not have FORM_TYPE %s", NS_SEARCH);
g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
@@ -357,15 +359,15 @@ fail:
static void
parse_search_field_response (GabbleSearchChannel *chan,
- LmMessageNode *query_node)
+ WockyNode *query_node)
{
- LmMessageNode *x_node;
+ WockyNode *x_node;
GPtrArray *search_keys = NULL;
GError *e = NULL;
g_return_if_fail (query_node != NULL);
- x_node = lm_message_node_get_child_with_namespace (query_node, "x",
+ x_node = wocky_node_get_child_ns (query_node, "x",
NS_X_DATA);
if (x_node == NULL)
@@ -394,27 +396,23 @@ parse_search_field_response (GabbleSearchChannel *chan,
supported_fields_discovered (chan);
}
-static LmHandlerResult
+static void
query_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object);
- LmMessageNode *query_node;
+ WockyNode *query_node;
GError *err = NULL;
- query_node = lm_message_node_get_child_with_namespace (
+ query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "query", NS_SEARCH);
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &err, NULL, NULL))
{
- err = gabble_message_get_xmpp_error (reply_msg);
-
- if (err == NULL)
- err = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
- "%s gave us an error we don't understand", chan->priv->server);
+ /* pass */
}
else if (NULL == query_node)
{
@@ -432,8 +430,6 @@ query_reply_cb (GabbleConnection *conn,
supported_field_discovery_failed (chan, err);
g_error_free (err);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
@@ -441,15 +437,13 @@ request_search_fields (GabbleSearchChannel *chan)
{
TpBaseChannel *base = TP_BASE_CHANNEL (chan);
TpBaseConnection *base_conn = tp_base_channel_get_connection (base);
- LmMessage *msg;
- LmMessageNode *lm_node;
+ WockyStanza *msg;
GError *error = NULL;
- msg = lm_message_new_with_sub_type (chan->priv->server, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_GET);
- lm_node = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "query", NULL);
- lm_message_node_set_attribute (lm_node, "xmlns", NS_SEARCH);
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_GET,
+ NULL, chan->priv->server,
+ '(', "query", ':', NS_SEARCH,
+ ')', NULL);
if (! _gabble_connection_send_with_reply (GABBLE_CONNECTION (base_conn), msg,
query_reply_cb, (GObject *) chan, NULL, &error))
@@ -458,7 +452,7 @@ request_search_fields (GabbleSearchChannel *chan)
g_error_free (error);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
}
/* Search implementation */
@@ -642,11 +636,12 @@ add_search_result (GabbleSearchChannel *chan,
static void
parse_result_item (GabbleSearchChannel *chan,
- LmMessageNode *item)
+ WockyNode *item)
{
- const gchar *jid = lm_message_node_get_attribute (item, "jid");
+ const gchar *jid = wocky_node_get_attribute (item, "jid");
GHashTable *info;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *n;
if (jid == NULL)
{
@@ -657,10 +652,10 @@ parse_result_item (GabbleSearchChannel *chan,
info = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (info, "jid", (gchar *) jid);
- for (i = node_iter (item); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, item, NULL, NULL);
+ while (wocky_node_iter_next (&i, &n))
{
- LmMessageNode *n = node_iter_data (i);
- gchar *value = (gchar *) lm_message_node_get_value (n);
+ gchar *value = (gchar *) n->content;
g_hash_table_insert (info, n->name, value);
}
@@ -671,41 +666,33 @@ parse_result_item (GabbleSearchChannel *chan,
static void
parse_extended_result_item (GabbleSearchChannel *chan,
- LmMessageNode *item)
+ WockyNode *item)
{
- GHashTable *info;
- NodeIter i;
-
- info = g_hash_table_new (g_str_hash, g_str_equal);
+ GHashTable *info = g_hash_table_new (g_str_hash, g_str_equal);
+ WockyNodeIter i;
+ WockyNode *field;
- for (i = node_iter (item); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, item, "field", NULL);
+ while (wocky_node_iter_next (&i, &field))
{
- LmMessageNode *field = node_iter_data (i);
- LmMessageNode *value_node;
+ WockyNode *value_node;
const gchar *var, *value;
- if (tp_strdiff (field->name, "field"))
- {
- DEBUG ("found <%s/> in <item/> rather than <field/>, skipping",
- field->name);
- continue;
- }
-
- var = lm_message_node_get_attribute (field, "var");
+ var = wocky_node_get_attribute (field, "var");
if (var == NULL)
{
DEBUG ("Ignore <field/> without 'var' attribut");
continue;
}
- value_node = lm_message_node_get_child (field, "value");
+ value_node = wocky_node_get_child (field, "value");
if (value_node == NULL)
{
DEBUG ("Ignore <field/> without <value/> child");
continue;
}
- value = lm_message_node_get_value (value_node);
+ value = value_node->content;
g_hash_table_insert (info, (gchar *) var, (gchar *) value);
}
@@ -724,20 +711,16 @@ parse_extended_result_item (GabbleSearchChannel *chan,
static gboolean
parse_unextended_search_results (GabbleSearchChannel *chan,
- LmMessageNode *query_node,
+ WockyNode *query_node,
GError **error)
{
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *item;
- for (i = node_iter (query_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, query_node, "item", NULL);
+ while (wocky_node_iter_next (&i, &item))
{
- LmMessageNode *item = node_iter_data (i);
-
- if (!strcmp (item->name, "item"))
- parse_result_item (chan, item);
- else
- DEBUG ("found <%s/> in <query/> rather than <item/>, skipping",
- item->name);
+ parse_result_item (chan, item);
}
return TRUE;
@@ -745,13 +728,13 @@ parse_unextended_search_results (GabbleSearchChannel *chan,
static gboolean
parse_extended_search_results (GabbleSearchChannel *chan,
- LmMessageNode *query_node,
+ WockyNode *query_node,
GError **error)
{
- LmMessageNode *x;
- NodeIter i;
+ WockyNode *x, *item;
+ WockyNodeIter i;
- x = lm_message_node_get_child_with_namespace (query_node, "x", NS_X_DATA);
+ x = wocky_node_get_child_ns (query_node, "x", NS_X_DATA);
if (x == NULL)
{
g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
@@ -759,17 +742,16 @@ parse_extended_search_results (GabbleSearchChannel *chan,
return FALSE;
}
- for (i = node_iter (x); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, x, NULL, NULL);
+ while (wocky_node_iter_next (&i, &item))
{
- LmMessageNode *item = node_iter_data (i);
-
if (!tp_strdiff (item->name, "item"))
parse_extended_result_item (chan, item);
else if (!tp_strdiff (item->name, "reported"))
/* Ignore <reported> node */
continue;
else if (!tp_strdiff (item->name, "title"))
- DEBUG ("title: %s", lm_message_node_get_value (item));
+ DEBUG ("title: %s", item->content);
else
DEBUG ("found <%s/> in <x/> rather than <item/>, <title/> and "
"<reported/>, skipping", item->name);
@@ -780,7 +762,7 @@ parse_extended_search_results (GabbleSearchChannel *chan,
static gboolean
parse_search_results (GabbleSearchChannel *chan,
- LmMessageNode *query_node,
+ WockyNode *query_node,
GError **error)
{
if (chan->priv->xforms)
@@ -789,15 +771,16 @@ parse_search_results (GabbleSearchChannel *chan,
return parse_unextended_search_results (chan, query_node, error);
}
-static LmHandlerResult
+static void
search_reply_cb (GabbleConnection *conn,
- LmMessage *sent_msg,
- LmMessage *reply_msg,
+ WockyStanza *sent_msg,
+ WockyStanza *reply_msg,
GObject *object,
gpointer user_data)
{
GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object);
- LmMessageNode *query_node;
+ WockyNode *query_node;
+ GError *stanza_error = NULL;
GError *err = NULL;
DEBUG ("called");
@@ -806,43 +789,16 @@ search_reply_cb (GabbleConnection *conn,
{
DEBUG ("state is %s, not in progress; ignoring results",
states[chan->priv->state]);
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ return;
}
- query_node = lm_message_node_get_child_with_namespace (
+ query_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (reply_msg), "query", NS_SEARCH);
- if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ if (wocky_stanza_extract_errors (reply_msg, NULL, &stanza_error, NULL, NULL))
{
- err = gabble_message_get_xmpp_error (reply_msg);
-
- if (err == NULL)
- {
- err = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
- "%s gave us an error we don't understand", chan->priv->server);
- }
- else
- {
- err->domain = TP_ERRORS;
-
- switch (err->code)
- {
- case XMPP_ERROR_NOT_AUTHORIZED:
- case XMPP_ERROR_NOT_ACCEPTABLE:
- case XMPP_ERROR_FORBIDDEN:
- case XMPP_ERROR_NOT_ALLOWED:
- case XMPP_ERROR_REGISTRATION_REQUIRED:
- case XMPP_ERROR_SUBSCRIPTION_REQUIRED:
- err->code = TP_ERROR_PERMISSION_DENIED;
- break;
- /* FIXME: other error mappings go here. Maybe we need some kind of
- * generic GabbleXmppError -> TpError mapping.
- */
- default:
- err->code = TP_ERROR_NOT_AVAILABLE;
- }
- }
+ gabble_set_tp_error_from_wocky (stanza_error, &err);
+ g_clear_error (&stanza_error);
}
else if (NULL == query_node)
{
@@ -871,8 +827,6 @@ search_reply_cb (GabbleConnection *conn,
err);
g_error_free (err);
}
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
static gboolean
@@ -906,7 +860,7 @@ validate_terms (GabbleSearchChannel *chan,
static void
build_unextended_query (
GabbleSearchChannel *self,
- LmMessageNode *query,
+ WockyNode *query,
GHashTable *terms)
{
GHashTableIter iter;
@@ -920,32 +874,30 @@ build_unextended_query (
g_assert (xmpp_field != NULL);
- lm_message_node_add_child (query, xmpp_field, value);
+ wocky_node_add_child_with_content (query, xmpp_field, value);
}
}
static void
build_extended_query (GabbleSearchChannel *self,
- LmMessageNode *query,
+ WockyNode *query,
GHashTable *terms)
{
- LmMessageNode *x, *field;
+ WockyNode *x, *field;
GHashTableIter iter;
gpointer key, value;
- x = lm_message_node_add_child (query, "x", "");
- lm_message_node_set_attributes (x,
- "type", "submit",
- "xmlns", NS_X_DATA,
- NULL);
+ x = wocky_node_add_child_with_content (query, "x", "");
+ x->ns = g_quark_from_static_string (NS_X_DATA);
+ wocky_node_set_attribute (x, "type", "submit");
/* add FORM_TYPE */
- field = lm_message_node_add_child (x, "field", "");
- lm_message_node_set_attributes (field,
+ field = wocky_node_add_child_with_content (x, "field", "");
+ wocky_node_set_attributes (field,
"type", "hidden",
"var", "FORM_TYPE",
NULL);
- lm_message_node_add_child (field, "value", NS_SEARCH);
+ wocky_node_add_child_with_content (field, "value", NS_SEARCH);
/* Add search terms */
g_hash_table_iter_init (&iter, terms);
@@ -957,9 +909,9 @@ build_extended_query (GabbleSearchChannel *self,
g_assert (xmpp_field != NULL);
- field = lm_message_node_add_child (x, "field", "");
- lm_message_node_set_attribute (field, "var", xmpp_field);
- lm_message_node_add_child (field, "value", value);
+ field = wocky_node_add_child_with_content (x, "field", "");
+ wocky_node_set_attribute (field, "var", xmpp_field);
+ wocky_node_add_child_with_content (field, "value", value);
if (!tp_strdiff (tp_name, ""))
{
@@ -970,12 +922,12 @@ build_extended_query (GabbleSearchChannel *self,
{
xmpp_field = g_ptr_array_index (self->priv->boolean_keys, i);
- field = lm_message_node_add_child (x, "field", "");
- lm_message_node_set_attributes (field,
+ field = wocky_node_add_child_with_content (x, "field", "");
+ wocky_node_set_attributes (field,
"var", xmpp_field,
"type", "boolean",
NULL);
- lm_message_node_add_child (field, "value", "1");
+ wocky_node_add_child_with_content (field, "value", "1");
}
}
}
@@ -988,8 +940,8 @@ do_search (GabbleSearchChannel *chan,
{
TpBaseChannel *base = TP_BASE_CHANNEL (chan);
TpBaseConnection *base_conn = tp_base_channel_get_connection (base);
- LmMessage *msg;
- LmMessageNode *query;
+ WockyStanza *msg;
+ WockyNode *query;
gboolean ret;
DEBUG ("called");
@@ -997,11 +949,11 @@ do_search (GabbleSearchChannel *chan,
if (!validate_terms (chan, terms, error))
return FALSE;
- msg = lm_message_new_with_sub_type (chan->priv->server, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_SET);
- query = lm_message_node_add_child (
- wocky_stanza_get_top_node (msg), "query", NULL);
- lm_message_node_set_attribute (query, "xmlns", NS_SEARCH);
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, chan->priv->server,
+ '(', "query", ':', NS_SEARCH,
+ '*', &query,
+ ')', NULL);
if (chan->priv->xforms)
{
@@ -1026,7 +978,7 @@ do_search (GabbleSearchChannel *chan,
ret = FALSE;
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return ret;
}
diff --git a/src/search-manager.c b/src/search-manager.c
index 4c9ecf820..c78598fb1 100644
--- a/src/search-manager.c
+++ b/src/search-manager.c
@@ -25,7 +25,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_SEARCH
@@ -406,16 +406,16 @@ search_channel_ready_or_not_cb (GabbleSearchChannel *chan,
}
else
{
- if (domain == GABBLE_XMPP_ERROR)
+ if (domain == WOCKY_XMPP_ERROR)
{
domain = TP_ERRORS;
switch (code)
{
- case XMPP_ERROR_FORBIDDEN:
+ case WOCKY_XMPP_ERROR_FORBIDDEN:
code = TP_ERROR_PERMISSION_DENIED;
break;
- case XMPP_ERROR_JID_MALFORMED:
+ case WOCKY_XMPP_ERROR_JID_MALFORMED:
code = TP_ERROR_INVALID_ARGUMENT;
break;
default:
diff --git a/src/server-sasl-channel.c b/src/server-sasl-channel.c
index 671824462..961d6d491 100644
--- a/src/server-sasl-channel.c
+++ b/src/server-sasl-channel.c
@@ -34,8 +34,7 @@
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <dbus/dbus-glib.h>
-#include <wocky/wocky-auth-registry.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/channel-iface.h>
#include <telepathy-glib/dbus.h>
@@ -49,6 +48,7 @@
#define DEBUG_FLAG GABBLE_DEBUG_AUTH
+#include <gabble/error.h>
#include "connection.h"
#include "debug.h"
#include "namespaces.h"
diff --git a/src/server-sasl-channel.h b/src/server-sasl-channel.h
index f26fd47c7..69b469974 100644
--- a/src/server-sasl-channel.h
+++ b/src/server-sasl-channel.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
#include <telepathy-glib/base-channel.h>
-#include <wocky/wocky-auth-registry.h>
+#include <wocky/wocky.h>
#include "types.h"
diff --git a/src/server-tls-channel.c b/src/server-tls-channel.c
index e6f8267fc..859edb4d6 100644
--- a/src/server-tls-channel.c
+++ b/src/server-tls-channel.c
@@ -27,7 +27,7 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/channel-iface.h>
-#include <wocky/wocky-tls.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_TLS
#include "debug.h"
diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c
index 6f5f29aae..890a4d637 100644
--- a/src/server-tls-manager.c
+++ b/src/server-tls-manager.c
@@ -21,6 +21,8 @@
#include "config.h"
#include "server-tls-manager.h"
+#include <telepathy-glib/gtypes.h>
+
#define DEBUG_FLAG GABBLE_DEBUG_TLS
#include "debug.h"
#include "gabble/caps-channel-manager.h"
@@ -30,7 +32,7 @@
#include "extensions/extensions.h"
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
static void channel_manager_iface_init (gpointer, gpointer);
diff --git a/src/server-tls-manager.h b/src/server-tls-manager.h
index 529ff7543..e8f10af1b 100644
--- a/src/server-tls-manager.h
+++ b/src/server-tls-manager.h
@@ -22,7 +22,7 @@
#define __GABBLE_SERVER_TLS_MANAGER_H__
#include <glib-object.h>
-#include <wocky/wocky-tls-handler.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/enums.h>
diff --git a/src/tube-dbus.c b/src/tube-dbus.c
index 2726a5b9b..aa259acf6 100644
--- a/src/tube-dbus.c
+++ b/src/tube-dbus.c
@@ -26,8 +26,7 @@
#include <glib/gstdio.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <loudmouth/loudmouth.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/channel-iface.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/exportable-channel.h>
@@ -1193,7 +1192,7 @@ gabble_tube_dbus_class_init (GabbleTubeDBusClass *gabble_tube_dbus_class)
static void
bytestream_negotiate_cb (GabbleBytestreamIface *bytestream,
const gchar *stream_id,
- LmMessage *msg,
+ WockyStanza *msg,
GObject *object,
gpointer user_data)
{
@@ -1234,8 +1233,8 @@ gabble_tube_dbus_offer (GabbleTubeDBus *tube,
const gchar *jid, *resource;
gchar *full_jid;
GabblePresence *presence;
- LmMessageNode *tube_node, *si_node;
- LmMessage *msg;
+ WockyNode *tube_node, *si_node;
+ WockyStanza *msg;
gboolean result;
contact_repo = tp_base_connection_get_handles (
@@ -1266,12 +1265,12 @@ gabble_tube_dbus_offer (GabbleTubeDBus *tube,
full_jid = g_strdup_printf ("%s/%s", jid, resource);
msg = gabble_bytestream_factory_make_stream_init_iq (full_jid,
priv->stream_id, NS_TUBES);
- si_node = lm_message_node_get_child_with_namespace (
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si_node != NULL);
- tube_node = lm_message_node_add_child (si_node, "tube", NULL);
- lm_message_node_set_attribute (tube_node, "xmlns", NS_TUBES);
+ tube_node = wocky_node_add_child_with_content (si_node, "tube", NULL);
+ tube_node->ns = g_quark_from_string (NS_TUBES);
gabble_tube_iface_publish_in_node (GABBLE_TUBE_IFACE (tube),
(TpBaseConnection *) priv->conn, tube_node);
@@ -1283,7 +1282,7 @@ gabble_tube_dbus_offer (GabbleTubeDBus *tube,
/* We don't create the bytestream of private D-Bus tube yet.
* It will be when we'll receive the answer of the SI request */
- lm_message_unref (msg);
+ g_object_unref (msg);
g_free (full_jid);
if (!result)
@@ -1563,13 +1562,13 @@ gabble_tube_dbus_new (GabbleConnection *conn,
}
static void
-augment_si_accept_iq (LmMessageNode *si,
+augment_si_accept_iq (WockyNode *si,
gpointer user_data)
{
- LmMessageNode *tube_node;
+ WockyNode *tube_node;
- tube_node = lm_message_node_add_child (si, "tube", "");
- lm_message_node_set_attribute (tube_node, "xmlns", NS_TUBES);
+ tube_node = wocky_node_add_child_with_content (si, "tube", "");
+ tube_node->ns = g_quark_from_string (NS_TUBES);
}
/*
diff --git a/src/tube-iface.c b/src/tube-iface.c
index 31e2118ab..2563d16e8 100644
--- a/src/tube-iface.c
+++ b/src/tube-iface.c
@@ -171,9 +171,9 @@ gabble_tube_iface_get_type (void)
void
gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
TpBaseConnection *conn,
- LmMessageNode *node)
+ WockyNode *node)
{
- LmMessageNode *parameters_node;
+ WockyNode *parameters_node;
GHashTable *parameters;
TpTubeType type;
gchar *service, *id_str;
@@ -192,7 +192,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
id_str = g_strdup_printf ("%u", tube_id);
- lm_message_node_set_attributes (node,
+ wocky_node_set_attributes (node,
"service", service,
"id", id_str,
NULL);
@@ -210,14 +210,14 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
"dbus-name", &name,
NULL);
- lm_message_node_set_attributes (node,
+ wocky_node_set_attributes (node,
"type", "dbus",
"stream-id", stream_id,
"initiator", tp_handle_inspect (contact_repo, initiator_handle),
NULL);
if (name != NULL)
- lm_message_node_set_attribute (node, "dbus-name", name);
+ wocky_node_set_attribute (node, "dbus-name", name);
g_free (name);
g_free (stream_id);
@@ -225,7 +225,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
break;
case TP_TUBE_TYPE_STREAM:
{
- lm_message_node_set_attribute (node, "type", "stream");
+ wocky_node_set_attribute (node, "type", "stream");
}
break;
default:
@@ -234,7 +234,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
}
}
- parameters_node = lm_message_node_add_child (node, "parameters",
+ parameters_node = wocky_node_add_child_with_content (node, "parameters",
NULL);
lm_message_node_add_children_from_properties (parameters_node, parameters,
"parameter");
diff --git a/src/tube-iface.h b/src/tube-iface.h
index b7bee5bfb..311bf65bc 100644
--- a/src/tube-iface.h
+++ b/src/tube-iface.h
@@ -60,7 +60,7 @@ void gabble_tube_iface_add_bytestream (GabbleTubeIface *tube,
GabbleBytestreamIface *bytestream);
void gabble_tube_iface_publish_in_node (GabbleTubeIface *tube,
- TpBaseConnection *conn, LmMessageNode *node);
+ TpBaseConnection *conn, WockyNode *node);
G_END_DECLS
diff --git a/src/tube-stream.c b/src/tube-stream.c
index 6a2994e3b..e147fdc92 100644
--- a/src/tube-stream.c
+++ b/src/tube-stream.c
@@ -31,7 +31,6 @@
#endif
#include <glib/gstdio.h>
-#include <loudmouth/loudmouth.h>
#include <telepathy-glib/channel-iface.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/exportable-channel.h>
@@ -432,7 +431,7 @@ extra_bytestream_state_changed_cb (GabbleBytestreamIface *bytestream,
static void
extra_bytestream_negotiate_cb (GabbleBytestreamIface *bytestream,
const gchar *stream_id,
- LmMessage *msg,
+ WockyStanza *msg,
GObject *object,
gpointer user_data)
{
@@ -472,8 +471,8 @@ start_stream_initiation (GabbleTubeStream *self,
GError **error)
{
GabbleTubeStreamPrivate *priv;
- LmMessageNode *node, *si_node;
- LmMessage *msg;
+ WockyNode *node, *si_node;
+ WockyStanza *msg;
TpHandleRepoIface *contact_repo;
const gchar *jid;
gchar *full_jid, *stream_id, *id_str;
@@ -525,7 +524,7 @@ start_stream_initiation (GabbleTubeStream *self,
msg = gabble_bytestream_factory_make_stream_init_iq (full_jid,
stream_id, NS_TUBES);
- si_node = lm_message_node_get_child_with_namespace (
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_assert (si_node != NULL);
@@ -533,17 +532,15 @@ start_stream_initiation (GabbleTubeStream *self,
if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
{
- node = lm_message_node_add_child (si_node, "stream", NULL);
+ node = wocky_node_add_child_with_content (si_node, "stream", NULL);
}
else
{
- node = lm_message_node_add_child (si_node, "muc-stream", NULL);
+ node = wocky_node_add_child_with_content (si_node, "muc-stream", NULL);
}
- lm_message_node_set_attributes (node,
- "xmlns", NS_TUBES,
- "tube", id_str,
- NULL);
+ node->ns = g_quark_from_static_string (NS_TUBES);
+ wocky_node_set_attribute (node, "tube", id_str);
result = gabble_bytestream_factory_negotiate_stream (
priv->conn->bytestream_factory, msg, stream_id,
@@ -558,7 +555,7 @@ start_stream_initiation (GabbleTubeStream *self,
g_object_unref (transport);
}
- lm_message_unref (msg);
+ g_object_unref (msg);
g_free (stream_id);
g_free (full_jid);
g_free (id_str);
@@ -1893,7 +1890,7 @@ gabble_tube_stream_close (GabbleTubeIface *tube, gboolean closed_remotely)
if (!closed_remotely && priv->handle_type == TP_HANDLE_TYPE_CONTACT)
{
- LmMessage *msg;
+ WockyStanza *msg;
const gchar *jid;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
@@ -1903,43 +1900,33 @@ gabble_tube_stream_close (GabbleTubeIface *tube, gboolean closed_remotely)
id_str = g_strdup_printf ("%u", priv->id);
/* Send the close message */
- msg = lm_message_build (jid, LM_MESSAGE_TYPE_MESSAGE,
- '(', "close", "",
- '@', "xmlns", NS_TUBES,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE,
+ WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, jid,
+ '(', "close",
+ ':', NS_TUBES,
'@', "tube", id_str,
')',
- '(', "amp", "",
- '@', "xmlns", NS_AMP,
- '(', "rule", "",
- '@', "condition", "deliver-at",
- '@', "value", "stored",
- '@', "action", "error",
- ')',
- '(', "rule", "",
- '@', "condition", "match-resource",
- '@', "value", "exact",
- '@', "action", "error",
- ')',
- ')',
+ GABBLE_AMP_DO_NOT_STORE_SPEC,
NULL);
g_free (id_str);
_gabble_connection_send (priv->conn, msg, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
}
static void
-augment_si_accept_iq (LmMessageNode *si,
+augment_si_accept_iq (WockyNode *si,
gpointer user_data)
{
- LmMessageNode *tube_node;
+ WockyNode *tube_node;
- tube_node = lm_message_node_add_child (si, "tube", "");
- lm_message_node_set_attribute (tube_node, "xmlns", NS_TUBES);
+ tube_node = wocky_node_add_child_with_content (si, "tube", "");
+ tube_node->ns = g_quark_from_string (NS_TUBES);
}
/**
@@ -2225,8 +2212,8 @@ send_tube_offer (GabbleTubeStream *self,
GError **error)
{
GabbleTubeStreamPrivate *priv = GABBLE_TUBE_STREAM_GET_PRIVATE (self);
- LmMessageNode *tube_node = NULL;
- LmMessage *msg;
+ WockyNode *tube_node = NULL;
+ WockyStanza *msg;
TpHandleRepoIface *contact_repo;
const gchar *jid;
gboolean result;
@@ -2263,24 +2250,13 @@ send_tube_offer (GabbleTubeStream *self,
full_jid = g_strdup_printf ("%s/%s", jid, resource);
- msg = lm_message_build (full_jid, LM_MESSAGE_TYPE_MESSAGE,
- '(', "tube", "",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, full_jid,
+ '(', "tube",
'*', &tube_node,
- '@', "xmlns", NS_TUBES,
- ')',
- '(', "amp", "",
- '@', "xmlns", NS_AMP,
- '(', "rule", "",
- '@', "condition", "deliver-at",
- '@', "value", "stored",
- '@', "action", "error",
- ')',
- '(', "rule", "",
- '@', "condition", "match-resource",
- '@', "value", "exact",
- '@', "action", "error",
- ')',
+ ':', NS_TUBES,
')',
+ GABBLE_AMP_DO_NOT_STORE_SPEC,
NULL);
g_free (full_jid);
@@ -2295,7 +2271,7 @@ send_tube_offer (GabbleTubeStream *self,
priv->state = TP_TUBE_CHANNEL_STATE_REMOTE_PENDING;
}
- lm_message_unref (msg);
+ g_object_unref (msg);
return TRUE;
}
diff --git a/src/tubes-channel.c b/src/tubes-channel.c
index ffbe6134e..1afd4c213 100644
--- a/src/tubes-channel.c
+++ b/src/tubes-channel.c
@@ -120,7 +120,7 @@ struct _GabbleTubesChannelPrivate
static void update_tubes_presence (GabbleTubesChannel *self);
-static void pre_presence_cb (GabbleMucChannel *muc, LmMessage *msg,
+static void pre_presence_cb (GabbleMucChannel *muc, WockyStanza *msg,
GabbleTubesChannel *self);
static void
@@ -596,7 +596,7 @@ create_new_tube (GabbleTubesChannel *self,
static gboolean
extract_tube_information (GabbleTubesChannel *self,
- LmMessageNode *tube_node,
+ WockyNode *tube_node,
TpTubeType *type,
TpHandle *initiator_handle,
const gchar **service,
@@ -611,7 +611,7 @@ extract_tube_information (GabbleTubesChannel *self,
{
const gchar *_type;
- _type = lm_message_node_get_attribute (tube_node, "type");
+ _type = wocky_node_get_attribute (tube_node, "type");
if (!tp_strdiff (_type, "stream"))
{
@@ -632,7 +632,7 @@ extract_tube_information (GabbleTubesChannel *self,
{
const gchar *initiator;
- initiator = lm_message_node_get_attribute (tube_node, "initiator");
+ initiator = wocky_node_get_attribute (tube_node, "initiator");
if (initiator != NULL)
{
@@ -653,14 +653,14 @@ extract_tube_information (GabbleTubesChannel *self,
if (service != NULL)
{
- *service = lm_message_node_get_attribute (tube_node, "service");
+ *service = wocky_node_get_attribute (tube_node, "service");
}
if (parameters != NULL)
{
- LmMessageNode *node;
+ WockyNode *node;
- node = lm_message_node_get_child (tube_node, "parameters");
+ node = wocky_node_get_child (tube_node, "parameters");
*parameters = lm_message_node_extract_properties (node, "parameter");
}
@@ -670,7 +670,7 @@ extract_tube_information (GabbleTubesChannel *self,
gchar *endptr;
unsigned long tmp;
- str = lm_message_node_get_attribute (tube_node, "id");
+ str = wocky_node_get_attribute (tube_node, "id");
if (str == NULL)
{
DEBUG ("no tube id in SI request");
@@ -811,13 +811,14 @@ contact_left_muc (GabbleTubesChannel *self,
void
gabble_tubes_channel_presence_updated (GabbleTubesChannel *self,
TpHandle contact,
- LmMessageNode *pnode)
+ WockyNode *pnode)
{
GabbleTubesChannelPrivate *priv = self->priv;
- LmMessageNode *tubes_node;
+ WockyNode *tubes_node;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *tube_node;
const gchar *presence_type;
GHashTable *old_dbus_tubes;
struct _add_in_old_dbus_tubes_data add_data;
@@ -829,15 +830,14 @@ gabble_tubes_channel_presence_updated (GabbleTubesChannel *self,
/* We are interested by this presence only if it contains tube information
* or indicates someone left the muc */
- presence_type = lm_message_node_get_attribute (pnode, "type");
+ presence_type = wocky_node_get_attribute (pnode, "type");
if (!tp_strdiff (presence_type, "unavailable"))
{
contact_left_muc (self, contact);
return;
}
- tubes_node = lm_message_node_get_child_with_namespace (pnode,
- "tubes", NS_TUBES);
+ tubes_node = wocky_node_get_child_ns (pnode, "tubes", NS_TUBES);
if (tubes_node == NULL)
return;
@@ -849,15 +849,15 @@ gabble_tubes_channel_presence_updated (GabbleTubesChannel *self,
add_data.contact = contact;
g_hash_table_foreach (priv->tubes, add_in_old_dbus_tubes, &add_data);
- for (i = node_iter (tubes_node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, tubes_node, NULL, NULL);
+ while (wocky_node_iter_next (&i, &tube_node))
{
- LmMessageNode *tube_node = node_iter_data (i);
const gchar *stream_id;
GabbleTubeIface *tube;
guint tube_id;
TpTubeType type;
- stream_id = lm_message_node_get_attribute (tube_node, "stream-id");
+ stream_id = wocky_node_get_attribute (tube_node, "stream-id");
if (!extract_tube_information (self, tube_node, NULL,
NULL, NULL, NULL, &tube_id))
@@ -939,7 +939,7 @@ gabble_tubes_channel_presence_updated (GabbleTubesChannel *self,
/* Contact just joined the tube */
const gchar *new_name;
- new_name = lm_message_node_get_attribute (tube_node,
+ new_name = wocky_node_get_attribute (tube_node,
"dbus-name");
if (!new_name)
@@ -1085,7 +1085,7 @@ gabble_tubes_channel_list_tubes (TpSvcChannelTypeTubes *iface,
struct _i_hate_g_hash_table_foreach
{
GabbleTubesChannel *self;
- LmMessageNode *tubes_node;
+ WockyNode *tubes_node;
};
static void
@@ -1098,7 +1098,7 @@ publish_tubes_in_node (gpointer key,
(struct _i_hate_g_hash_table_foreach *) user_data;
GabbleTubesChannelPrivate *priv = data->self->priv;
TpTubeChannelState state;
- LmMessageNode *tube_node;
+ WockyNode *tube_node;
TpTubeType type;
TpHandle initiator;
@@ -1118,24 +1118,24 @@ publish_tubes_in_node (gpointer key,
/* We only announce stream tubes we initiated */
return;
- tube_node = lm_message_node_add_child (data->tubes_node, "tube", NULL);
+ tube_node = wocky_node_add_child_with_content (data->tubes_node, "tube", NULL);
gabble_tube_iface_publish_in_node (tube, (TpBaseConnection *) priv->conn,
tube_node);
}
static void
pre_presence_cb (GabbleMucChannel *muc,
- LmMessage *msg,
+ WockyStanza *msg,
GabbleTubesChannel *self)
{
GabbleTubesChannelPrivate *priv = self->priv;
struct _i_hate_g_hash_table_foreach data;
- LmMessageNode *node;
+ WockyNode *node;
/* Augment the muc presence with tubes information */
- node = lm_message_node_add_child (
+ node = wocky_node_add_child_with_content (
wocky_stanza_get_top_node (msg), "tubes", NULL);
- lm_message_node_set_attribute (node, "xmlns", NS_TUBES);
+ node->ns = g_quark_from_string (NS_TUBES);
data.self = self;
data.tubes_node = node;
@@ -1159,34 +1159,37 @@ update_tubes_presence (GabbleTubesChannel *self)
void
gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
GabbleBytestreamIface *bytestream,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleTubesChannelPrivate *priv = self->priv;
const gchar *service, *stream_id;
GHashTable *parameters;
TpTubeType type;
- LmMessageNode *si_node, *tube_node;
+ WockyNode *si_node, *tube_node;
guint tube_id;
GabbleTubeIface *tube;
+ WockyStanzaType stanza_type;
+ WockyStanzaSubType sub_type;
/* Caller is expected to have checked that we have a SI node with
* a stream ID, the TUBES profile and a <tube> element
*/
- g_return_if_fail (lm_message_get_type (msg) == LM_MESSAGE_TYPE_IQ);
- g_return_if_fail (lm_message_get_sub_type (msg) == LM_MESSAGE_SUB_TYPE_SET);
- si_node = lm_message_node_get_child_with_namespace (
+ wocky_stanza_get_type_info (msg, &stanza_type, &sub_type);
+ g_return_if_fail (stanza_type == WOCKY_STANZA_TYPE_IQ);
+ g_return_if_fail (sub_type == WOCKY_STANZA_SUB_TYPE_SET);
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_return_if_fail (si_node != NULL);
- stream_id = lm_message_node_get_attribute (si_node, "id");
+ stream_id = wocky_node_get_attribute (si_node, "id");
g_return_if_fail (stream_id != NULL);
- tube_node = lm_message_node_get_child_with_namespace (si_node, "tube",
+ tube_node = wocky_node_get_child_ns (si_node, "tube",
NS_TUBES);
g_return_if_fail (tube_node != NULL);
if (!extract_tube_information (self, tube_node, NULL, NULL,
NULL, NULL, &tube_id))
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"<tube> has no id attribute" };
NODE_DEBUG (tube_node, e.message);
@@ -1197,7 +1200,7 @@ gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
tube = g_hash_table_lookup (priv->tubes, GUINT_TO_POINTER (tube_id));
if (tube != NULL)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"tube ID already in use" };
NODE_DEBUG (tube_node, e.message);
@@ -1209,7 +1212,7 @@ gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
if (!extract_tube_information (self, tube_node, &type, NULL,
&service, &parameters, NULL))
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"can't extract <tube> information from SI request" };
NODE_DEBUG (tube_node, e.message);
@@ -1220,7 +1223,7 @@ gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
if (type != TP_TUBE_TYPE_DBUS)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_FORBIDDEN,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_FORBIDDEN,
"Only D-Bus tubes are allowed to be created using SI" };
DEBUG ("%s", e.message);
@@ -1245,41 +1248,44 @@ gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
void
gabble_tubes_channel_bytestream_offered (GabbleTubesChannel *self,
GabbleBytestreamIface *bytestream,
- LmMessage *msg)
+ WockyStanza *msg)
{
GabbleTubesChannelPrivate *priv = self->priv;
const gchar *stream_id, *tmp;
gchar *endptr;
- LmMessageNode *si_node, *stream_node;
+ WockyNode *si_node, *stream_node;
guint tube_id;
unsigned long tube_id_tmp;
GabbleTubeIface *tube;
+ WockyStanzaType stanza_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
*/
- g_return_if_fail (lm_message_get_type (msg) == LM_MESSAGE_TYPE_IQ);
- g_return_if_fail (lm_message_get_sub_type (msg) == LM_MESSAGE_SUB_TYPE_SET);
+ wocky_stanza_get_type_info (msg, &stanza_type, &sub_type);
+ g_return_if_fail (stanza_type == WOCKY_STANZA_TYPE_IQ);
+ g_return_if_fail (sub_type == WOCKY_STANZA_SUB_TYPE_SET);
- si_node = lm_message_node_get_child_with_namespace (
+ si_node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "si", NS_SI);
g_return_if_fail (si_node != NULL);
if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
- stream_node = lm_message_node_get_child_with_namespace (si_node,
+ stream_node = wocky_node_get_child_ns (si_node,
"stream", NS_TUBES);
else
- stream_node = lm_message_node_get_child_with_namespace (si_node,
+ stream_node = wocky_node_get_child_ns (si_node,
"muc-stream", NS_TUBES);
g_return_if_fail (stream_node != NULL);
- stream_id = lm_message_node_get_attribute (si_node, "id");
+ stream_id = wocky_node_get_attribute (si_node, "id");
g_return_if_fail (stream_id != NULL);
- tmp = lm_message_node_get_attribute (stream_node, "tube");
+ tmp = wocky_node_get_attribute (stream_node, "tube");
if (tmp == NULL)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"<stream> or <muc-stream> has no tube attribute" };
NODE_DEBUG (stream_node, e.message);
@@ -1289,7 +1295,7 @@ gabble_tubes_channel_bytestream_offered (GabbleTubesChannel *self,
tube_id_tmp = strtoul (tmp, &endptr, 10);
if (!endptr || *endptr || tube_id_tmp > G_MAXUINT32)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"<stream> or <muc-stream> tube attribute not numeric or > 2**32" };
DEBUG ("tube id is not numeric or > 2**32: %s", tmp);
@@ -1301,7 +1307,7 @@ gabble_tubes_channel_bytestream_offered (GabbleTubesChannel *self,
tube = g_hash_table_lookup (priv->tubes, GUINT_TO_POINTER (tube_id));
if (tube == NULL)
{
- GError e = { GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
"<stream> or <muc-stream> tube attribute points to a nonexistent "
"tube" };
@@ -1321,7 +1327,7 @@ send_tube_close_msg (GabbleTubesChannel *self,
guint tube_id)
{
GabbleTubesChannelPrivate *priv = self->priv;
- LmMessage *msg;
+ WockyStanza *msg;
const gchar *jid;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
@@ -1331,48 +1337,36 @@ send_tube_close_msg (GabbleTubesChannel *self,
id_str = g_strdup_printf ("%u", tube_id);
/* Send the close message */
- msg = lm_message_build (jid, LM_MESSAGE_TYPE_MESSAGE,
- '(', "close", "",
- '@', "xmlns", NS_TUBES,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ NULL, jid,
+ '(', "close",
+ ':', NS_TUBES,
'@', "tube", id_str,
')',
- '(', "amp", "",
- '@', "xmlns", NS_AMP,
- '(', "rule", "",
- '@', "condition", "deliver-at",
- '@', "value", "stored",
- '@', "action", "error",
- ')',
- '(', "rule", "",
- '@', "condition", "match-resource",
- '@', "value", "exact",
- '@', "action", "error",
- ')',
- ')',
+ GABBLE_AMP_DO_NOT_STORE_SPEC,
NULL);
g_free (id_str);
_gabble_connection_send (priv->conn, msg, NULL);
- lm_message_unref (msg);
+ g_object_unref (msg);
}
static void
tube_msg_offered (GabbleTubesChannel *self,
- LmMessage *msg)
+ WockyStanza *msg,
+ WockyNode *tube_node)
{
GabbleTubesChannelPrivate *priv = self->priv;
const gchar *service;
GHashTable *parameters;
TpTubeType type;
- LmMessageNode *tube_node;
guint tube_id;
GabbleTubeIface *tube;
+ WockyStanzaType stanza_type;
- g_return_if_fail (lm_message_get_type (msg) == LM_MESSAGE_TYPE_MESSAGE);
- tube_node = lm_message_node_get_child_with_namespace (
- wocky_stanza_get_top_node (msg), "tube", NS_TUBES);
- g_return_if_fail (tube_node != NULL);
+ wocky_stanza_get_type_info (msg, &stanza_type, NULL);
+ g_return_if_fail (stanza_type == WOCKY_STANZA_TYPE_MESSAGE);
if (!extract_tube_information (self, tube_node, NULL, NULL,
NULL, NULL, &tube_id))
@@ -1418,21 +1412,17 @@ tube_msg_offered (GabbleTubesChannel *self,
static void
tube_msg_close (GabbleTubesChannel *self,
- LmMessage *msg)
+ WockyStanza *msg,
+ WockyNode *close_node)
{
GabbleTubesChannelPrivate *priv = self->priv;
- LmMessageNode *close_node;
guint tube_id;
const gchar *tmp;
gchar *endptr;
GabbleTubeIface *tube;
TpTubeType type;
- close_node = lm_message_node_get_child_with_namespace (
- wocky_stanza_get_top_node (msg), "close", NS_TUBES);
- g_assert (close_node != NULL);
-
- tmp = lm_message_node_get_attribute (close_node, "tube");
+ tmp = wocky_node_get_attribute (close_node, "tube");
if (tmp == NULL)
{
DEBUG ("no tube id in close message");
@@ -1466,23 +1456,23 @@ tube_msg_close (GabbleTubesChannel *self,
void
gabble_tubes_channel_tube_msg (GabbleTubesChannel *self,
- LmMessage *msg)
+ WockyStanza *msg)
{
- LmMessageNode *node;
+ WockyNode *node;
- node = lm_message_node_get_child_with_namespace (
+ node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "tube", NS_TUBES);
if (node != NULL)
{
- tube_msg_offered (self, msg);
+ tube_msg_offered (self, msg, node);
return;
}
- node = lm_message_node_get_child_with_namespace (
+ node = wocky_node_get_child_ns (
wocky_stanza_get_top_node (msg), "close", NS_TUBES);
if (node != NULL)
{
- tube_msg_close (self, msg);
+ tube_msg_close (self, msg, node);
return;
}
}
diff --git a/src/tubes-channel.h b/src/tubes-channel.h
index 8f761f9c7..dbf7d5fd4 100644
--- a/src/tubes-channel.h
+++ b/src/tubes-channel.h
@@ -21,8 +21,7 @@
#define __GABBLE_TUBES_CHANNEL_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
-
+#include <wocky/wocky.h>
#include <telepathy-glib/base-connection.h>
#include <telepathy-glib/exportable-channel.h>
@@ -77,15 +76,15 @@ GabbleTubeIface *gabble_tubes_channel_tube_request (GabbleTubesChannel *self,
gboolean require_new);
void gabble_tubes_channel_presence_updated (GabbleTubesChannel *chan,
- TpHandle contact, LmMessageNode *presence);
+ TpHandle contact, WockyNode *presence);
void gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *chan,
- GabbleBytestreamIface *bytestream, LmMessage *msg);
+ GabbleBytestreamIface *bytestream, WockyStanza *msg);
void gabble_tubes_channel_bytestream_offered (GabbleTubesChannel *chan,
- GabbleBytestreamIface *bytestream, LmMessage *msg);
+ GabbleBytestreamIface *bytestream, WockyStanza *msg);
-void gabble_tubes_channel_tube_msg (GabbleTubesChannel *chan, LmMessage *msg);
+void gabble_tubes_channel_tube_msg (GabbleTubesChannel *chan, WockyStanza *msg);
void gabble_tubes_channel_close (GabbleTubesChannel *self);
diff --git a/src/util.c b/src/util.c
index 27a40e724..b20720bf4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -30,9 +30,10 @@
#include <gobject/gvaluecollector.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include <telepathy-glib/handle-repo-dynamic.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/gtypes.h>
#define DEBUG_FLAG GABBLE_DEBUG_JID
@@ -135,16 +136,16 @@ gabble_generate_id (void)
static void
-lm_message_node_add_nick (LmMessageNode *node, const gchar *nick)
+lm_message_node_add_nick (WockyNode *node, const gchar *nick)
{
- LmMessageNode *nick_node;
+ WockyNode *nick_node;
- nick_node = lm_message_node_add_child (node, "nick", nick);
- lm_message_node_set_attribute (nick_node, "xmlns", NS_NICK);
+ nick_node = wocky_node_add_child_with_content (node, "nick", nick);
+ nick_node->ns = g_quark_from_string (NS_NICK);
}
void
-lm_message_node_add_own_nick (LmMessageNode *node,
+lm_message_node_add_own_nick (WockyNode *node,
GabbleConnection *connection)
{
gchar *nick;
@@ -160,218 +161,6 @@ lm_message_node_add_own_nick (LmMessageNode *node,
g_free (nick);
}
-
-void
-lm_message_node_steal_children (LmMessageNode *snatcher,
- LmMessageNode *mum)
-{
- g_return_if_fail (snatcher->children == NULL);
-
- if (mum->children == NULL)
- return;
-
- snatcher->children = mum->children;
- mum->children = NULL;
-}
-
-/* variant of lm_message_node_get_child() which ignores node namespace
- * prefix */
-LmMessageNode *
-lm_message_node_get_child_any_ns (LmMessageNode *node, const gchar *name)
-{
- NodeIter i;
-
- for (i = node_iter (node); i; i = node_iter_next (i))
- {
- LmMessageNode *child = node_iter_data (i);
-
- if (!tp_strdiff (lm_message_node_get_name (child), name))
- return child;
- }
-
- return NULL;
-}
-
-const gchar *
-lm_message_node_get_namespace (LmMessageNode *node)
-{
- return wocky_node_get_ns (node);
-}
-
-const gchar *
-lm_message_node_get_name (LmMessageNode *node)
-{
- return node->name;
-}
-
-gboolean
-lm_message_node_has_namespace (LmMessageNode *node,
- const gchar *ns,
- const gchar *tag)
-{
- return (!tp_strdiff (lm_message_node_get_namespace (node), ns));
-}
-
-LmMessageNode *
-lm_message_node_get_child_with_namespace (LmMessageNode *node,
- const gchar *name,
- const gchar *ns)
-{
- LmMessageNode *found;
- NodeIter i;
-
- found = wocky_node_get_child_ns (node, name, ns);
- if (found != NULL)
- return found;
-
- for (i = node_iter (node); i; i = node_iter_next (i))
- {
- LmMessageNode *child = node_iter_data (i);
-
- found = lm_message_node_get_child_with_namespace (child, name, ns);
- if (found != NULL)
- return found;
- }
-
- return NULL;
-}
-
-/* note: these are only used internally for readability, not part of the API
- */
-enum {
- BUILD_END = '\0',
- BUILD_ATTRIBUTE = '@',
- BUILD_CHILD = '(',
- BUILD_CHILD_END = ')',
- BUILD_POINTER = '*',
-};
-
-/* lm_message_node_add_build_va
- *
- * Used to implement lm_message_build and lm_message_build_with_sub_type.
- */
-static void
-lm_message_node_add_build_va (LmMessageNode *node, guint spec, va_list ap)
-{
- GSList *stack = NULL;
- guint arg = spec;
-
- stack = g_slist_prepend (stack, node);
-
- while (arg != BUILD_END)
- {
- switch (arg)
- {
- case BUILD_ATTRIBUTE:
- {
- gchar *key = va_arg (ap, gchar *);
- gchar *value = va_arg (ap, gchar *);
-
- g_return_if_fail (key != NULL);
- g_return_if_fail (value != NULL);
- lm_message_node_set_attribute (stack->data, key, value);
- }
- break;
-
- case BUILD_CHILD:
- {
- gchar *name = va_arg (ap, gchar *);
- gchar *value = va_arg (ap, gchar *);
- LmMessageNode *child;
-
- g_return_if_fail (name != NULL);
- g_return_if_fail (value != NULL);
- child = lm_message_node_add_child (stack->data, name, value);
- stack = g_slist_prepend (stack, child);
- }
- break;
-
- case BUILD_CHILD_END:
- {
- GSList *tmp;
-
- tmp = stack;
- stack = stack->next;
- tmp->next = NULL;
- g_slist_free (tmp);
- }
- break;
-
- case BUILD_POINTER:
- {
- LmMessageNode **assign_to = va_arg (ap, LmMessageNode **);
-
- g_return_if_fail (assign_to != NULL);
- *assign_to = stack->data;
- }
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- /* Note that we pull out an int-sized value here, whereas our sentinel,
- * NULL, is pointer-sized. However, sizeof (void *) should always be >=
- * sizeof (uint), so this shouldn't cause a problem.
- */
- arg = va_arg (ap, guint);
- }
-
- g_slist_free (stack);
-}
-
-/**
- * lm_message_build:
- *
- * Build an LmMessage from a list of arguments employing an S-expression-like
- * notation. Example:
- *
- * lm_message_build ("bob@jabber.org", LM_MESSAGE_TYPE_IQ,
- * '(', 'query', 'lala',
- * '@', 'xmlns', 'http://jabber.org/protocol/foo',
- * ')',
- * NULL);
- *
- * --> <iq to="bob@jabber.org">
- * <query xmlns="http://jabber.org/protocol/foo">lala</query>
- * </iq>
- */
-G_GNUC_NULL_TERMINATED
-LmMessage *
-lm_message_build (const gchar *to, LmMessageType type, guint spec, ...)
-{
- LmMessage *msg;
- va_list ap;
-
- msg = lm_message_new (to, type);
- va_start (ap, spec);
- lm_message_node_add_build_va (
- wocky_stanza_get_top_node (msg), spec, ap);
- va_end (ap);
- return msg;
-}
-
-/**
- * lm_message_build_with_sub_type:
- *
- * As lm_message_build (), but creates a message with an LmMessageSubType.
- */
-G_GNUC_NULL_TERMINATED
-LmMessage *
-lm_message_build_with_sub_type (const gchar *to, LmMessageType type,
- LmMessageSubType sub_type, guint spec, ...)
-{
- LmMessage *msg;
- va_list ap;
-
- msg = lm_message_new_with_sub_type (to, type, sub_type);
- va_start (ap, spec);
- lm_message_node_add_build_va (
- wocky_stanza_get_top_node (msg), spec, ap);
- va_end (ap);
- return msg;
-}
-
/**
* gabble_get_room_handle_from_jid:
* @room_repo: The %TP_HANDLE_TYPE_ROOM handle repository
@@ -588,11 +377,12 @@ OUT:
*
*/
GHashTable *
-lm_message_node_extract_properties (LmMessageNode *node,
+lm_message_node_extract_properties (WockyNode *node,
const gchar *prop)
{
GHashTable *properties;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *child;
properties = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) tp_g_value_slice_free);
@@ -600,26 +390,15 @@ lm_message_node_extract_properties (LmMessageNode *node,
if (node == NULL)
return properties;
- for (i = node_iter (node); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, node, prop, NULL);
+ while (wocky_node_iter_next (&i, &child))
{
- LmMessageNode *child = node_iter_data (i);
- const gchar *name;
- const gchar *type;
- const gchar *value;
+ const gchar *name = wocky_node_get_attribute (child, "name");
+ const gchar *type = wocky_node_get_attribute (child, "type");
+ const gchar *value = child->content;
GValue *gvalue;
- if (0 != strcmp (child->name, prop))
- continue;
-
- name = lm_message_node_get_attribute (child, "name");
-
- if (!name)
- continue;
-
- type = lm_message_node_get_attribute (child, "type");
- value = lm_message_node_get_value (child);
-
- if (type == NULL || value == NULL)
+ if (name == NULL || type == NULL || value == NULL)
continue;
if (0 == strcmp (type, "bytes"))
@@ -690,7 +469,7 @@ lm_message_node_extract_properties (LmMessageNode *node,
struct _set_child_from_property_data
{
- LmMessageNode *node;
+ WockyNode *node;
const gchar *prop;
};
@@ -702,7 +481,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;
- LmMessageNode *child;
+ WockyNode *child;
const char *type = NULL;
if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
@@ -733,11 +512,11 @@ set_child_from_property (gpointer key,
return;
}
- child = lm_message_node_add_child (data->node, data->prop, "");
+ child = wocky_node_add_child_with_content (data->node, data->prop, "");
if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
{
- lm_message_node_set_value (child,
+ wocky_node_set_content (child,
g_value_get_string (gvalue));
}
else if (G_VALUE_TYPE (gvalue) == DBUS_TYPE_G_UCHAR_ARRAY)
@@ -748,7 +527,7 @@ set_child_from_property (gpointer key,
type = "bytes";
arr = g_value_get_boxed (gvalue);
str = base64_encode (arr->len, arr->data, FALSE);
- lm_message_node_set_value (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -757,7 +536,7 @@ set_child_from_property (gpointer key,
gchar *str;
str = g_strdup_printf ("%d", g_value_get_int (gvalue));
- lm_message_node_set_value (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -766,7 +545,7 @@ set_child_from_property (gpointer key,
gchar *str;
str = g_strdup_printf ("%u", g_value_get_uint (gvalue));
- lm_message_node_set_value (child, str);
+ wocky_node_set_content (child, str);
g_free (str);
}
@@ -775,7 +554,7 @@ set_child_from_property (gpointer key,
/* we output as "0" or "1" despite the canonical representation for
* xs:boolean being "false" or "true", for compatibility with older
* Gabble versions (OLPC Trial-3) */
- lm_message_node_set_value (child,
+ wocky_node_set_content (child,
g_value_get_boolean (gvalue) ? "1" : "0");
}
else
@@ -783,8 +562,8 @@ set_child_from_property (gpointer key,
g_assert_not_reached ();
}
- lm_message_node_set_attribute (child, "name", key);
- lm_message_node_set_attribute (child, "type", type);
+ wocky_node_set_attribute (child, "name", key);
+ wocky_node_set_attribute (child, "type", type);
}
/**
@@ -806,7 +585,7 @@ set_child_from_property (gpointer key,
*
*/
void
-lm_message_node_add_children_from_properties (LmMessageNode *node,
+lm_message_node_add_children_from_properties (WockyNode *node,
GHashTable *properties,
const gchar *prop)
{
@@ -818,44 +597,6 @@ lm_message_node_add_children_from_properties (LmMessageNode *node,
g_hash_table_foreach (properties, set_child_from_property, &data);
}
-/**
- * lm_iq_message_make_result:
- * @iq_message: A LmMessage containing an IQ stanza to acknowledge
- *
- * Creates a result IQ stanza to acknowledge @iq_message.
- *
- * Returns: A newly-created LmMessage containing the result IQ stanza.
- */
-LmMessage *
-lm_iq_message_make_result (LmMessage *iq_message)
-{
- LmMessage *result;
- LmMessageNode *iq, *result_iq;
- const gchar *from_jid, *id;
-
- g_assert (lm_message_get_type (iq_message) == LM_MESSAGE_TYPE_IQ);
- g_assert (lm_message_get_sub_type (iq_message) == LM_MESSAGE_SUB_TYPE_GET ||
- lm_message_get_sub_type (iq_message) == LM_MESSAGE_SUB_TYPE_SET);
-
- iq = lm_message_get_node (iq_message);
- id = lm_message_node_get_attribute (iq, "id");
-
- if (id == NULL)
- {
- NODE_DEBUG (iq, "can't acknowledge IQ with no id");
- return NULL;
- }
-
- from_jid = lm_message_node_get_attribute (iq, "from");
-
- result = lm_message_new_with_sub_type (from_jid, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_RESULT);
- result_iq = lm_message_get_node (result);
- lm_message_node_set_attribute (result_iq, "id", id);
-
- return result;
-}
-
typedef struct {
GObject *instance;
GObject *user_data;
@@ -999,19 +740,6 @@ gabble_idle_add_weak (GSourceFunc function,
return ctx->source_id;
}
-typedef struct {
- gchar *key;
- gchar *value;
-} Attribute;
-
-const gchar *
-lm_message_node_get_attribute_with_namespace (LmMessageNode *node,
- const gchar *attribute,
- const gchar *ns)
-{
- return wocky_node_get_attribute_ns (node, attribute, ns);
-}
-
GPtrArray *
gabble_g_ptr_array_copy (GPtrArray *source)
{
diff --git a/src/util.h b/src/util.h
index 15f28519d..c86763f58 100644
--- a/src/util.h
+++ b/src/util.h
@@ -27,19 +27,13 @@
#include <glib.h>
#include <telepathy-glib/handle-repo.h>
#include <telepathy-glib/util.h>
-#include <loudmouth/loudmouth.h>
-#include <wocky/wocky-bare-contact.h>
+#include <wocky/wocky.h>
#include "jingle-factory.h"
#include "jingle-content.h"
#include "types.h"
-typedef GSList * NodeIter;
-#define node_iter(node) (node->children)
-#define node_iter_next(i) (g_slist_next (i))
-#define node_iter_data(i) ((LmMessageNode *) i->data)
-
/* Guarantees that the resulting hash is in lower-case */
gchar *sha1_hex (const gchar *bytes, guint len);
@@ -49,19 +43,8 @@ void sha1_bin (const gchar *bytes, guint len, guchar out[SHA1_HASH_SIZE]);
gchar *gabble_generate_id (void);
-void lm_message_node_add_own_nick (LmMessageNode *node,
+void lm_message_node_add_own_nick (WockyNode *node,
GabbleConnection *conn);
-void lm_message_node_steal_children (LmMessageNode *snatcher,
- LmMessageNode *mum);
-gboolean lm_message_node_has_namespace (LmMessageNode *node, const gchar *ns,
- const gchar *tag);
-LmMessageNode *lm_message_node_get_child_with_namespace (LmMessageNode *node,
- const gchar *name, const gchar *ns);
-G_GNUC_NULL_TERMINATED LmMessage *lm_message_build (const gchar *to,
- LmMessageType type, guint spec, ...);
-G_GNUC_NULL_TERMINATED LmMessage * lm_message_build_with_sub_type (
- const gchar *to, LmMessageType type, LmMessageSubType sub_type,
- guint spec, ...);
G_GNUC_WARN_UNUSED_RESULT
gchar *gabble_encode_jid (const gchar *node, const gchar *domain,
@@ -75,27 +58,16 @@ gchar *gabble_normalize_room (TpHandleRepoIface *repo, const gchar *jid,
TpHandle gabble_get_room_handle_from_jid (TpHandleRepoIface *room_repo,
const gchar *jid);
-GHashTable *lm_message_node_extract_properties (LmMessageNode *node,
+GHashTable *lm_message_node_extract_properties (WockyNode *node,
const gchar *prop);
void
-lm_message_node_add_children_from_properties (LmMessageNode *node,
+lm_message_node_add_children_from_properties (WockyNode *node,
GHashTable *properties, const gchar *prop);
-const gchar * lm_message_node_get_namespace (LmMessageNode *node);
-const gchar * lm_message_node_get_name (LmMessageNode *node);
-LmMessageNode * lm_message_node_get_child_any_ns (LmMessageNode *node,
- const gchar *name);
-
-LmMessage *
-lm_iq_message_make_result (LmMessage *iq_message);
void gabble_signal_connect_weak (gpointer instance, const gchar *detailed_signal,
GCallback c_handler, GObject *user_data);
guint gabble_idle_add_weak (GSourceFunc function, GObject *object);
-const gchar * lm_message_node_get_attribute_with_namespace (LmMessageNode *node,
- const gchar *attribute,
- const gchar *ns);
-
GPtrArray *gabble_g_ptr_array_copy (GPtrArray *source);
WockyBareContact * ensure_bare_contact_from_jid (GabbleConnection *conn,
@@ -138,4 +110,35 @@ GSimpleAsyncResult *gabble_simple_async_countdown_new (gpointer self,
void gabble_simple_async_countdown_inc (GSimpleAsyncResult *simple);
void gabble_simple_async_countdown_dec (GSimpleAsyncResult *simple);
+/* Boilerplate for telling servers which implement XEP-0079 not to store these
+ * messages for delivery later. Include it in your call to wocky_stanza_build()
+ * like so:
+ *
+ * wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ * NULL, jid,
+ * '(', "close",
+ * ':', NS_TUBES,
+ * '@', "tube", id_str,
+ * ')',
+ * GABBLE_AMP_DO_NOT_STORE_SPEC,
+ * NULL);
+ *
+ * Every 1000th user will win a Marshall amplifier!
+ */
+#define GABBLE_AMP_DO_NOT_STORE_SPEC \
+ '(', "amp", \
+ ':', NS_AMP, \
+ '(', "rule", \
+ '@', "condition", "deliver-at", \
+ '@', "value", "stored", \
+ '@', "action", "error", \
+ ')', \
+ '(', "rule", \
+ '@', "condition", "match-resource", \
+ '@', "value", "exact", \
+ '@', "action", "error", \
+ ')', \
+ ')'
+
+
#endif /* __GABBLE_UTIL_H__ */
diff --git a/src/vcard-manager.c b/src/vcard-manager.c
index 872e865e9..67466be01 100644
--- a/src/vcard-manager.c
+++ b/src/vcard-manager.c
@@ -26,6 +26,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/heap.h>
+#include <wocky/wocky.h>
#define DEBUG_FLAG GABBLE_DEBUG_VCARD
@@ -154,7 +155,7 @@ struct _GabbleVCardManagerPrivate
/* Patched vCard that we sent to the server to update, but haven't
* got confirmation yet. We don't want to store it in cache (visible
* to others) before we're sure the server accepts it. */
- LmMessageNode *patched_vcard;
+ WockyNode *patched_vcard;
};
struct _GabbleVCardManagerRequest
@@ -208,7 +209,7 @@ struct _GabbleVCardCacheEntry
guint suspended_timer_id;
/* VCard node for this entry (owned reference), or NULL if there's no node */
- LmMessageNode *vcard_node;
+ WockyNode *vcard_node;
/* If @vcard_node is not NULL, the time the message will expire */
time_t expires;
@@ -235,7 +236,7 @@ gabble_vcard_manager_cache_quark (void)
static void cache_entry_free (void *data);
static gint cache_entry_compare (gconstpointer a, gconstpointer b);
static void manager_patch_vcard (
- GabbleVCardManager *self, LmMessageNode *vcard_node);
+ GabbleVCardManager *self, WockyNode *vcard_node);
static void request_send (GabbleVCardManagerRequest *request,
guint timeout);
@@ -350,6 +351,42 @@ gabble_vcard_manager_set_property (GObject *object,
}
}
+static gboolean
+copy_attribute (const gchar *key,
+ const gchar *value,
+ const gchar *prefix,
+ const gchar *ns,
+ gpointer user_data)
+{
+ WockyNode *copy = (WockyNode *) user_data;
+
+ wocky_node_set_attribute_ns (copy, key, value, ns);
+ return TRUE;
+}
+
+static WockyNode *
+copy_node (WockyNode *node)
+{
+ WockyNode *copy;
+ GSList *l;
+
+ copy = wocky_node_new (node->name, wocky_node_get_ns (node));
+ wocky_node_set_content (copy, node->content);
+ wocky_node_set_language (copy, wocky_node_get_language (node));
+
+ wocky_node_each_attribute (node, copy_attribute, copy);
+
+ for (l = node->children; l != NULL; l = g_slist_next (l))
+ {
+ WockyNode *child = l->data;
+
+ copy->children = g_slist_prepend (copy->children, copy_node (child));
+ }
+ copy->children = g_slist_reverse (copy->children);
+
+ return copy;
+}
+
static void delete_request (GabbleVCardManagerRequest *request);
static void cancel_request (GabbleVCardManagerRequest *request);
static void cancel_all_edit_requests (GabbleVCardManager *manager);
@@ -382,7 +419,7 @@ cache_entry_free (gpointer data)
gabble_request_pipeline_item_cancel (entry->pipeline_item);
}
- tp_clear_pointer (&entry->vcard_node, lm_message_node_unref);
+ tp_clear_pointer (&entry->vcard_node, wocky_node_free);
tp_handle_unref (contact_repo, entry->handle);
@@ -503,13 +540,13 @@ gabble_vcard_manager_invalidate_cache (GabbleVCardManager *manager,
tp_heap_remove (priv->timed_cache, entry);
- tp_clear_pointer (&entry->vcard_node, lm_message_node_unref);
+ tp_clear_pointer (&entry->vcard_node, wocky_node_free);
cache_entry_attempt_to_free (entry);
}
static void complete_one_request (GabbleVCardManagerRequest *request,
- LmMessageNode *vcard_node, GError *error);
+ WockyNode *vcard_node, GError *error);
static void
cache_entry_complete_requests (GabbleVCardCacheEntry *entry, GError *error)
@@ -530,7 +567,7 @@ cache_entry_complete_requests (GabbleVCardCacheEntry *entry, GError *error)
static void
complete_one_request (GabbleVCardManagerRequest *request,
- LmMessageNode *vcard_node,
+ WockyNode *vcard_node,
GError *error)
{
if (request->callback)
@@ -609,26 +646,26 @@ gabble_vcard_manager_finalize (GObject *object)
}
gchar *
-vcard_get_avatar_sha1 (LmMessageNode *vcard)
+vcard_get_avatar_sha1 (WockyNode *vcard)
{
gchar *sha1;
const gchar *binval_value;
GString *avatar;
- LmMessageNode *node;
- LmMessageNode *binval;
+ WockyNode *node;
+ WockyNode *binval;
- node = lm_message_node_get_child (vcard, "PHOTO");
+ node = wocky_node_get_child (vcard, "PHOTO");
if (!node)
return g_strdup ("");
DEBUG ("Our vCard has a PHOTO %p", node);
- binval = lm_message_node_get_child (node, "BINVAL");
+ binval = wocky_node_get_child (node, "BINVAL");
if (!binval)
return g_strdup ("");
- binval_value = lm_message_node_get_value (binval);
+ binval_value = binval->content;
if (!binval_value)
return g_strdup ("");
@@ -655,7 +692,7 @@ static void
initial_request_cb (GabbleVCardManager *self,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *error,
gpointer user_data)
{
@@ -810,17 +847,17 @@ cancel_request (GabbleVCardManagerRequest *request)
}
static gchar *
-extract_nickname (LmMessageNode *vcard_node)
+extract_nickname (WockyNode *vcard_node)
{
- LmMessageNode *node;
+ WockyNode *node;
const gchar *nick;
- node = lm_message_node_get_child (vcard_node, "NICKNAME");
+ node = wocky_node_get_child (vcard_node, "NICKNAME");
if (node == NULL)
return NULL;
- nick = lm_message_node_get_value (node);
+ nick = node->content;
return g_strdup (nick);
}
@@ -829,7 +866,7 @@ static void
observe_vcard (GabbleConnection *conn,
GabbleVCardManager *manager,
TpHandle handle,
- LmMessageNode *vcard_node)
+ WockyNode *vcard_node)
{
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
@@ -841,11 +878,11 @@ observe_vcard (GabbleConnection *conn,
if (alias == NULL)
{
- LmMessageNode *fn_node = lm_message_node_get_child (vcard_node, "FN");
+ WockyNode *fn_node = wocky_node_get_child (vcard_node, "FN");
if (fn_node != NULL)
{
- const gchar *fn = lm_message_node_get_value (fn_node);
+ const gchar *fn = fn_node->content;
if (!tp_str_empty (fn))
{
@@ -893,7 +930,7 @@ observe_vcard (GabbleConnection *conn,
*/
static void
replace_reply_cb (GabbleConnection *conn,
- LmMessage *reply_msg,
+ WockyStanza *reply_msg,
gpointer user_data,
GError *error)
{
@@ -901,7 +938,7 @@ replace_reply_cb (GabbleConnection *conn,
GabbleVCardManagerPrivate *priv = self->priv;
TpBaseConnection *base = (TpBaseConnection *) conn;
GList *li;
- LmMessageNode *node = NULL;
+ WockyNode *node = NULL;
/* If we sent a SET request, it's dead now. */
priv->edit_pipeline_item = NULL;
@@ -911,7 +948,7 @@ replace_reply_cb (GabbleConnection *conn,
if (error)
{
/* We won't need our patched vcard after all */
- tp_clear_pointer (&priv->patched_vcard, lm_message_node_unref);
+ tp_clear_pointer (&priv->patched_vcard, wocky_node_free);
}
else
{
@@ -921,7 +958,7 @@ replace_reply_cb (GabbleConnection *conn,
g_assert (priv->patched_vcard != NULL);
/* Finally we may put the new vcard in the cache. */
- tp_clear_pointer (&entry->vcard_node, lm_message_node_unref);
+ tp_clear_pointer (&entry->vcard_node, wocky_node_free);
entry->vcard_node = priv->patched_vcard;
priv->patched_vcard = NULL;
@@ -974,21 +1011,19 @@ replace_reply_cb (GabbleConnection *conn,
* (NICKNAME, PHOTO and in future FN are the problematic ones). */
static gboolean
gabble_vcard_manager_replace_is_significant (GabbleVCardManagerEditInfo *info,
- LmMessageNode *old_vcard)
+ WockyNode *old_vcard)
{
gboolean seen = FALSE;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *node;
- for (i = node_iter (old_vcard); i != NULL; i = node_iter_next (i))
+ /* Find the first node matching the one we want to edit */
+ wocky_node_iter_init (&i, old_vcard, info->element_name, NULL);
+ while (wocky_node_iter_next (&i, &node))
{
- LmMessageNode *node = node_iter_data (i);
const gchar *value;
const gchar *new_value;
- /* skip over nodes that aren't the one we want to edit */
- if (tp_strdiff (info->element_name, node->name))
- continue;
-
/* if there are >= 2 copies of this field, we're going to reduce that
* to 1 */
if (seen)
@@ -996,7 +1031,7 @@ gabble_vcard_manager_replace_is_significant (GabbleVCardManagerEditInfo *info,
/* consider NULL and "" to be different representations for the
* same thing */
- value = lm_message_node_get_value (node);
+ value = node->content;
new_value = info->element_value;
if (value == NULL)
@@ -1024,11 +1059,11 @@ gabble_vcard_manager_replace_is_significant (GabbleVCardManagerEditInfo *info,
child_iter = child_iter->next)
{
GabbleVCardChild *child = child_iter->data;
- LmMessageNode *child_node = lm_message_node_get_child (node,
+ WockyNode *child_node = wocky_node_get_child (node,
child->key);
if (child_node == NULL ||
- tp_strdiff (lm_message_node_get_value (child_node),
+ tp_strdiff (child_node->content,
child->value))
{
return TRUE;
@@ -1048,17 +1083,17 @@ gabble_vcard_manager_replace_is_significant (GabbleVCardManagerEditInfo *info,
return !seen;
}
-static LmMessageNode *vcard_copy (LmMessageNode *parent, LmMessageNode *src,
+static WockyNode *vcard_copy (WockyNode *parent, WockyNode *src,
const gchar *exclude, gboolean *exclude_mattered);
-static LmMessage *
+static WockyStanza *
gabble_vcard_manager_edit_info_apply (GabbleVCardManagerEditInfo *info,
- LmMessageNode *old_vcard,
+ WockyNode *old_vcard,
GabbleVCardManager *vcard_manager)
{
- LmMessage *msg;
- LmMessageNode *vcard_node;
- LmMessageNode *node;
+ WockyStanza *msg;
+ WockyNode *vcard_node;
+ WockyNode *node;
GList *iter;
gboolean maybe_changed = FALSE;
GabbleConnection *conn = vcard_manager->priv->connection;
@@ -1087,7 +1122,7 @@ gabble_vcard_manager_edit_info_apply (GabbleVCardManagerEditInfo *info,
* */
gchar *alias;
- node = lm_message_node_get_child (old_vcard, info->element_name);
+ node = wocky_node_get_child (old_vcard, info->element_name);
/* If the user has set this field explicitly via SetContactInfo(),
* that takes precedence */
@@ -1132,28 +1167,28 @@ gabble_vcard_manager_edit_info_apply (GabbleVCardManagerEditInfo *info,
return NULL;
}
- msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
- LM_MESSAGE_SUB_TYPE_SET);
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET,
+ NULL, NULL, NULL);
if (info->edit_type == GABBLE_VCARD_EDIT_CLEAR)
{
/* start from a clean slate... */
- vcard_node = lm_message_node_add_child (
+ vcard_node = wocky_node_add_child_with_content (
wocky_stanza_get_top_node (msg), "vCard", "");
- lm_message_node_set_attribute (vcard_node, "xmlns", "vcard-temp");
+ vcard_node->ns = g_quark_from_string ("vcard-temp");
/* ... but as a special case, the photo gets copied in from the old
* vCard, because SetContactInfo doesn't touch photos */
- node = lm_message_node_get_child (old_vcard, "PHOTO");
+ node = wocky_node_get_child (old_vcard, "PHOTO");
if (node != NULL)
vcard_copy (vcard_node, node, NULL, NULL);
- /* Yes, we can do this: "LmMessageNode" is really a WockyNode */
+ /* Yes, we can do this: "WockyNode" is really a WockyNode */
if (wocky_node_equal (old_vcard, vcard_node))
{
/* nothing actually happened, forget it */
- lm_message_unref (msg);
+ g_object_unref (msg);
return NULL;
}
@@ -1179,21 +1214,21 @@ gabble_vcard_manager_edit_info_apply (GabbleVCardManagerEditInfo *info,
{
maybe_changed = TRUE;
- node = lm_message_node_add_child (vcard_node,
+ node = wocky_node_add_child_with_content (vcard_node,
info->element_name, info->element_value);
for (iter = info->children; iter != NULL; iter = iter->next)
{
GabbleVCardChild *child = iter->data;
- lm_message_node_add_child (node, child->key, child->value);
+ wocky_node_add_child_with_content (node, child->key, child->value);
}
}
if ((!maybe_changed) || wocky_node_equal (old_vcard, vcard_node))
{
/* nothing actually happened, forget it */
- lm_message_unref (msg);
+ g_object_unref (msg);
return NULL;
}
@@ -1204,24 +1239,25 @@ gabble_vcard_manager_edit_info_apply (GabbleVCardManagerEditInfo *info,
*
* Note that this function doesn't copy any attributes other than
* xmlns, because LM provides no way to iterate over attributes. Thanks, LM. */
-static LmMessageNode *
-vcard_copy (LmMessageNode *parent,
- LmMessageNode *src,
+static WockyNode *
+vcard_copy (WockyNode *parent,
+ WockyNode *src,
const gchar *exclude,
gboolean *exclude_mattered)
{
- LmMessageNode *new = lm_message_node_add_child (parent, src->name,
- lm_message_node_get_value (src));
+ WockyNode *new = wocky_node_add_child_with_content (parent, src->name,
+ src->content);
const gchar *xmlns;
- NodeIter i;
+ WockyNodeIter i;
+ WockyNode *child;
- xmlns = lm_message_node_get_attribute (src, "xmlns");
+ xmlns = wocky_node_get_ns (src);
if (xmlns != NULL)
- lm_message_node_set_attribute (new, "xmlns", xmlns);
+ new->ns = g_quark_from_string (xmlns);
- for (i = node_iter (src); i; i = node_iter_next (i))
+ wocky_node_iter_init (&i, src, NULL, NULL);
+ while (wocky_node_iter_next (&i, &child))
{
- LmMessageNode *child = node_iter_data (i);
if (tp_strdiff (child->name, exclude))
{
@@ -1239,10 +1275,10 @@ vcard_copy (LmMessageNode *parent,
static void
manager_patch_vcard (GabbleVCardManager *self,
- LmMessageNode *vcard_node)
+ WockyNode *vcard_node)
{
GabbleVCardManagerPrivate *priv = self->priv;
- LmMessage *msg = NULL;
+ WockyStanza *msg = NULL;
GList *li;
/* Bail out if we don't have outstanding edits to make, or if we already
@@ -1254,19 +1290,19 @@ manager_patch_vcard (GabbleVCardManager *self,
/* Apply any unsent edits to the patched vCard */
for (li = priv->edits; li != NULL; li = li->next)
{
- LmMessage *new_msg = gabble_vcard_manager_edit_info_apply (
+ WockyStanza *new_msg = gabble_vcard_manager_edit_info_apply (
li->data, vcard_node, self);
/* edit_info_apply returns NULL if nothing happened */
if (new_msg == NULL)
continue;
- tp_clear_pointer (&msg, lm_message_unref);
+ tp_clear_pointer (&msg, g_object_unref);
msg = new_msg;
/* gabble_vcard_manager_edit_info_apply always returns an IQ message
* with one vCard child */
- vcard_node = lm_message_node_get_child (
+ vcard_node = wocky_node_get_child (
wocky_stanza_get_top_node (msg), "vCard");
g_assert (vcard_node != NULL);
}
@@ -1282,13 +1318,13 @@ manager_patch_vcard (GabbleVCardManager *self,
/* We'll save the patched vcard, and if the server says
* we're ok, put it into the cache. But we want to leave the
* original vcard in the cache until that happens. */
- priv->patched_vcard = lm_message_node_ref (vcard_node);
+ priv->patched_vcard = copy_node (vcard_node);
priv->edit_pipeline_item = gabble_request_pipeline_enqueue (
priv->connection->req_pipeline, msg, default_request_timeout,
replace_reply_cb, self);
- lm_message_unref (msg);
+ g_object_unref (msg);
out:
/* We've applied those, forget about them */
@@ -1321,14 +1357,14 @@ suspended_request_timeout_cb (gpointer data)
static gboolean
is_item_not_found (const GError *error)
{
- return (error->domain == GABBLE_XMPP_ERROR &&
- error->code == XMPP_ERROR_ITEM_NOT_FOUND);
+ return (error->domain == WOCKY_XMPP_ERROR &&
+ error->code == WOCKY_XMPP_ERROR_ITEM_NOT_FOUND);
}
/* Called when a GET request in the pipeline has either succeeded or failed. */
static void
pipeline_reply_cb (GabbleConnection *conn,
- LmMessage *reply_msg,
+ WockyStanza *reply_msg,
gpointer user_data,
GError *error)
{
@@ -1339,7 +1375,7 @@ pipeline_reply_cb (GabbleConnection *conn,
TpBaseConnection *base = (TpBaseConnection *) conn;
TpHandleRepoIface *contact_repo =
tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT);
- LmMessageNode *vcard_node = NULL;
+ WockyNode *vcard_node = NULL;
DEBUG("called for entry %p", entry);
@@ -1358,33 +1394,32 @@ pipeline_reply_cb (GabbleConnection *conn,
{
/* First, handle the error "wait": suspend the request and replay it
* later */
- LmMessageNode *error_node = NULL;
- GabbleXmppError xmpp_error = XMPP_ERROR_UNDEFINED_CONDITION;
- GabbleXmppErrorType error_type = XMPP_ERROR_UNDEFINED_CONDITION;
+ WockyXmppErrorType error_type = WOCKY_XMPP_ERROR_TYPE_CANCEL;
+ GError *stanza_error = NULL;
- /* FIXME: add a helper in error.c to extract the type, error, and message
- * from an XMPP stanza.
- */
- if (reply_msg != NULL)
- error_node = lm_message_node_get_child (
- wocky_stanza_get_top_node (reply_msg), "error");
-
- if (error_node != NULL)
- xmpp_error = gabble_xmpp_error_from_node (error_node, &error_type);
-
- if (error_type == XMPP_ERROR_TYPE_WAIT)
+ if (reply_msg != NULL &&
+ wocky_stanza_extract_errors (reply_msg, &error_type, &stanza_error,
+ NULL, NULL))
{
- DEBUG ("Retrieving %u's vCard returned a temporary <%s/> error; "
- "trying againg in %u seconds", entry->handle,
- gabble_xmpp_error_string (xmpp_error), request_wait_delay);
+ if (error_type == WOCKY_XMPP_ERROR_TYPE_WAIT)
+ {
+ DEBUG ("%s", g_quark_to_string (stanza_error->domain));
+ DEBUG ("Retrieving %u's vCard returned a temporary <%s/> error; "
+ "trying againg in %u seconds", entry->handle,
+ wocky_xmpp_stanza_error_to_string (stanza_error),
+ request_wait_delay);
+
+ g_source_remove (request->timer_id);
+ request->timer_id = 0;
- g_source_remove (request->timer_id);
- request->timer_id = 0;
+ entry->suspended_timer_id = g_timeout_add_seconds (
+ request_wait_delay, suspended_request_timeout_cb, request);
- entry->suspended_timer_id = g_timeout_add_seconds (
- request_wait_delay, suspended_request_timeout_cb, request);
+ g_error_free (stanza_error);
+ return;
+ }
- return;
+ g_error_free (stanza_error);
}
/* If request for our own vCard failed, and we do have
@@ -1408,7 +1443,7 @@ pipeline_reply_cb (GabbleConnection *conn,
g_assert (reply_msg != NULL);
- vcard_node = lm_message_node_get_child (
+ vcard_node = wocky_node_get_child (
wocky_stanza_get_top_node (reply_msg), "vCard");
if (NULL == vcard_node)
@@ -1417,14 +1452,14 @@ pipeline_reply_cb (GabbleConnection *conn,
DEBUG ("successful lookup response contained no <vCard> node, "
"creating an empty one");
- vcard_node = lm_message_node_add_child (
+ vcard_node = wocky_node_add_child_with_content (
wocky_stanza_get_top_node (reply_msg), "vCard",
NULL);
- lm_message_node_set_attribute (vcard_node, "xmlns", NS_VCARD_TEMP);
+ vcard_node->ns = g_quark_from_string (NS_VCARD_TEMP);
}
/* Put the message in the cache */
- entry->vcard_node = lm_message_node_ref (vcard_node);
+ entry->vcard_node = copy_node (vcard_node);
entry->expires = time (NULL) + VCARD_CACHE_ENTRY_TTL;
tp_heap_add (priv->timed_cache, entry);
@@ -1483,7 +1518,7 @@ request_send (GabbleVCardManagerRequest *request, guint timeout)
else
{
const char *jid;
- LmMessage *msg;
+ WockyStanza *msg;
request->timer_id =
g_timeout_add_seconds (request->timeout, timeout_request, request);
@@ -1499,17 +1534,17 @@ request_send (GabbleVCardManagerRequest *request, guint timeout)
DEBUG ("Cache entry %p is not mine, @to = %s", entry, jid);
}
- msg = lm_message_build_with_sub_type (jid,
- LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET,
- '(', "vCard", "",
- '@', "xmlns", NS_VCARD_TEMP,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_GET,
+ NULL, jid,
+ '(', "vCard",
+ ':', NS_VCARD_TEMP,
')',
NULL);
entry->pipeline_item = gabble_request_pipeline_enqueue (
conn->req_pipeline, msg, timeout, pipeline_reply_cb, request);
- lm_message_unref (msg);
+ g_object_unref (msg);
DEBUG ("adding request to cache entry %p and queueing the <iq>", entry);
}
@@ -1695,7 +1730,7 @@ gabble_vcard_manager_cancel_request (GabbleVCardManager *self,
gboolean
gabble_vcard_manager_get_cached (GabbleVCardManager *self,
TpHandle handle,
- LmMessageNode **node)
+ WockyNode **node)
{
GabbleVCardManagerPrivate *priv = self->priv;
GabbleVCardCacheEntry *entry = g_hash_table_lookup (priv->cache,
diff --git a/src/vcard-manager.h b/src/vcard-manager.h
index 7c4cb44d9..8f877050a 100644
--- a/src/vcard-manager.h
+++ b/src/vcard-manager.h
@@ -23,7 +23,7 @@
#define __GABBLE_VCARD_MANAGER_H__
#include <glib-object.h>
-#include <loudmouth/loudmouth.h>
+#include <wocky/wocky.h>
#include "types.h"
@@ -90,7 +90,7 @@ typedef enum {
typedef void (*GabbleVCardManagerCb)(GabbleVCardManager *self,
GabbleVCardManagerRequest *request,
TpHandle handle,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *error,
gpointer user_data);
@@ -115,12 +115,12 @@ gboolean gabble_vcard_manager_has_cached_alias (GabbleVCardManager *manager,
gboolean gabble_vcard_manager_get_cached (GabbleVCardManager *,
TpHandle,
- LmMessageNode **);
+ WockyNode **);
void gabble_vcard_manager_invalidate_cache (GabbleVCardManager *, TpHandle);
typedef void (*GabbleVCardManagerEditCb)(GabbleVCardManager *self,
GabbleVCardManagerEditRequest *request,
- LmMessageNode *vcard,
+ WockyNode *vcard,
GError *error,
gpointer user_data);
@@ -133,7 +133,7 @@ GabbleVCardManagerEditRequest *gabble_vcard_manager_edit (GabbleVCardManager *,
void gabble_vcard_manager_remove_edit_request (GabbleVCardManagerEditRequest *);
-gchar *vcard_get_avatar_sha1 (LmMessageNode *vcard);
+gchar *vcard_get_avatar_sha1 (WockyNode *vcard);
GabbleVCardManagerEditInfo *gabble_vcard_manager_edit_info_new (
const gchar *element_name,
diff --git a/tests/test-jid-decode.c b/tests/test-jid-decode.c
index f7d8c45e9..b1c835fe1 100644
--- a/tests/test-jid-decode.c
+++ b/tests/test-jid-decode.c
@@ -3,7 +3,7 @@
#include <string.h>
-#include <wocky/wocky-utils.h>
+#include <wocky/wocky.h>
#include "src/util.h"
diff --git a/tests/test-parse-message.c b/tests/test-parse-message.c
index a0e8d033b..e73ec3dad 100644
--- a/tests/test-parse-message.c
+++ b/tests/test-parse-message.c
@@ -9,10 +9,10 @@
#include "src/message-util.h"
/* Test the most basic <message> possible. */
-static gboolean
+static void
test1 (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -23,32 +23,31 @@ test1 (void)
const gchar *body;
gint state;
- msg = lm_message_build (NULL, LM_MESSAGE_TYPE_MESSAGE,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ "foo@bar.com", NULL,
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "from", "foo@bar.com",
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "foo@bar.com"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
- g_assert (body == NULL);
- g_assert (state == -1);
- g_assert (send_error == GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "foo@bar.com");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
+ g_assert_cmpstr (body, ==, NULL);
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
+ g_object_unref (msg);
}
/* A <message> with a simple body. Parsed as a NOTICE because it doesn't have
* a 'type' attribute.
*/
-static gboolean
+static void
test2 (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -59,31 +58,30 @@ test2 (void)
const gchar *body;
gint state;
- msg = lm_message_build (NULL, LM_MESSAGE_TYPE_MESSAGE,
- '@', "from", "foo@bar.com",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ "foo@bar.com", NULL,
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '(', "body", "hello", ')',
+ '(', "body", '$', "hello", ')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "foo@bar.com"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
- g_assert (0 == strcmp (body, "hello"));
- g_assert (state == -1);
- g_assert (send_error == GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "foo@bar.com");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
+ g_assert_cmpstr (body, ==, "hello");
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
+ g_object_unref (msg);
}
/* Simple type="chat" message. */
-static gboolean
+static void
test3 (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -94,32 +92,30 @@ test3 (void)
const gchar *body;
gint state;
- msg = lm_message_build (NULL, LM_MESSAGE_TYPE_MESSAGE,
- '@', "from", "foo@bar.com",
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_CHAT,
+ "foo@bar.com", NULL,
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "type", "chat",
- '(', "body", "hello", ')',
+ '(', "body", '$', "hello", ')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "foo@bar.com"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL);
- g_assert (0 == strcmp (body, "hello"));
- g_assert (state == -1);
- g_assert (send_error == GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "foo@bar.com");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL);
+ g_assert_cmpstr (body, ==, "hello");
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
+ g_object_unref (msg);
}
/* A simple error. */
-static gboolean
+static void
test_error (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -130,35 +126,33 @@ test_error (void)
const gchar *body;
gint state;
- msg = lm_message_build_with_sub_type (NULL, LM_MESSAGE_TYPE_MESSAGE,
- LM_MESSAGE_SUB_TYPE_ERROR,
- '@', "from", "foo@bar.com",
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_ERROR,
+ "foo@bar.com", NULL,
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "type", "error",
- '(', "error", "oops", ')',
+ '(', "error", '$', "oops", ')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "foo@bar.com"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
- g_assert (body == NULL);
- g_assert (state == -1);
- g_assert (send_error == TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN);
- g_assert (delivery_status == TP_DELIVERY_STATUS_PERMANENTLY_FAILED);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "foo@bar.com");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
+ g_assert_cmpstr (body, ==, NULL);
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN);
+ g_assert_cmpuint (delivery_status, ==, TP_DELIVERY_STATUS_PERMANENTLY_FAILED);
+ g_object_unref (msg);
}
/* A more complicated error, described in XEP-0086 as a "simple error response".
*/
-static gboolean
+static void
test_another_error (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -170,44 +164,41 @@ test_another_error (void)
gint state;
const gchar *message = "Wherefore art thou, Romeo?";
- msg = lm_message_build_with_sub_type (NULL, LM_MESSAGE_TYPE_MESSAGE,
- LM_MESSAGE_SUB_TYPE_ERROR,
- '@', "to", "juliet@capulet.com/balcony",
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_ERROR,
+ "romeo@montague.net/garden", "juliet@capulet.com/balcony",
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "from", "romeo@montague.net/garden",
- '@', "type", "error",
- '(', "body", message, ')',
- '(', "error", "",
+ '(', "body", '$', message, ')',
+ '(', "error",
'@', "code", "404",
'@', "type", "cancel",
- '(', "item-not-found", "",
- '@', "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas",
+ '(', "item-not-found",
+ ':', "urn:ietf:params:xml:ns:xmpp-stanzas",
')',
')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "romeo@montague.net/garden"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
- g_assert (!tp_strdiff (body, message));
- g_assert (state == -1);
- g_assert (send_error == TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT);
- g_assert (delivery_status == TP_DELIVERY_STATUS_PERMANENTLY_FAILED);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "romeo@montague.net/garden");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
+ g_assert_cmpstr (body, ==, message);
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT);
+ g_assert_cmpuint (delivery_status, ==, TP_DELIVERY_STATUS_PERMANENTLY_FAILED);
+ g_object_unref (msg);
}
/* One million, seven hundred seventy-one thousand, five hundred sixty-one
* errors.
*/
-static gboolean
+static void
test_yet_another_error (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -220,41 +211,39 @@ test_yet_another_error (void)
const gchar *message = "Its trilling seems to have a tranquilizing effect on "
"the human nervous system.";
- msg = lm_message_build_with_sub_type (NULL, LM_MESSAGE_TYPE_MESSAGE,
- LM_MESSAGE_SUB_TYPE_ERROR,
- '@', "to", "spock@starfleet.us/Enterprise",
+ msg = wocky_stanza_build (
+ WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_ERROR,
+ "other@starfleet.us/Enterprise",
+ "spock@starfleet.us/Enterprise",
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "from", "other@starfleet.us/Enterprise",
- '@', "type", "error",
- '(', "body", message, ')',
- '(', "error", "",
+ '(', "body", '$', message, ')',
+ '(', "error",
'@', "code", "404",
'@', "type", "wait",
- '(', "recipient-unavailable", "",
- '@', "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas",
+ '(', "recipient-unavailable",
+ ':', "urn:ietf:params:xml:ns:xmpp-stanzas",
')',
')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "other@starfleet.us/Enterprise"));
- g_assert (stamp == 0);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
- g_assert (!tp_strdiff (body, message));
- g_assert (state == -1);
- g_assert (send_error == TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE);
- g_assert (delivery_status == TP_DELIVERY_STATUS_TEMPORARILY_FAILED);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "other@starfleet.us/Enterprise");
+ g_assert_cmpuint (stamp, ==, 0);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE);
+ g_assert_cmpstr (body, ==, message);
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE);
+ g_assert_cmpuint (delivery_status, ==, TP_DELIVERY_STATUS_TEMPORARILY_FAILED);
+ g_object_unref (msg);
}
-static gboolean
+static void
test_google_offline (void)
{
- LmMessage *msg;
+ WockyStanza *msg;
gboolean ret;
const gchar *from;
time_t stamp;
@@ -265,47 +254,48 @@ test_google_offline (void)
const gchar *body;
gint state;
- msg = lm_message_build (NULL, LM_MESSAGE_TYPE_MESSAGE,
+ msg = wocky_stanza_build (WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE,
+ "foo@bar.com", NULL,
'@', "id", "a867c060-bd3f-4ecc-a38f-3e306af48e4c",
- '@', "from", "foo@bar.com",
- '(', "body", "hello", ')',
- '(', "x", "",
- '@', "xmlns", "jabber:x:delay",
+ '(', "body", '$', "hello", ')',
+ '(', "x",
+ ':', "jabber:x:delay",
'@', "stamp", "20070927T13:24:14",
')',
- '(', "time", "",
- '@', "xmlns", "google:timestamp",
+ '(', "time",
+ ':', "google:timestamp",
'@', "ms", "1190899454656",
')',
NULL);
ret = gabble_message_util_parse_incoming_message (
msg, &from, &stamp, &type, &id, &body, &state, &send_error,
&delivery_status);
- g_assert (ret == TRUE);
- g_assert (0 == strcmp (id, "a867c060-bd3f-4ecc-a38f-3e306af48e4c"));
- g_assert (0 == strcmp (from, "foo@bar.com"));
- g_assert (stamp == 1190899454);
- g_assert (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL);
- g_assert (0 == strcmp (body, "hello"));
- g_assert (state == -1);
- g_assert (send_error == GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
- lm_message_unref (msg);
- return TRUE;
+ g_assert (ret);
+ g_assert_cmpstr (id, ==, "a867c060-bd3f-4ecc-a38f-3e306af48e4c");
+ g_assert_cmpstr (from, ==, "foo@bar.com");
+ g_assert_cmpuint (stamp, ==, 1190899454);
+ g_assert_cmpuint (type, ==, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL);
+ g_assert_cmpstr (body, ==, "hello");
+ g_assert_cmpuint (state, ==, -1);
+ g_assert_cmpuint (send_error, ==, GABBLE_TEXT_CHANNEL_SEND_NO_ERROR);
+ g_object_unref (msg);
}
int
-main (void)
+main (
+ int argc,
+ char *argv[])
{
g_type_init ();
+ g_test_init (&argc, &argv, NULL);
- g_assert (test1 ());
- g_assert (test2 ());
- g_assert (test3 ());
- g_assert (test_error ());
- g_assert (test_another_error ());
- g_assert (test_yet_another_error ());
- g_assert (test_google_offline ());
-
- return 0;
+ g_test_add_func ("/parse-message/1", test1);
+ g_test_add_func ("/parse-message/2", test2);
+ g_test_add_func ("/parse-message/3", test3);
+ g_test_add_func ("/parse-message/error", test_error);
+ g_test_add_func ("/parse-message/another-error", test_another_error);
+ g_test_add_func ("/parse-message/yet-another-error", test_yet_another_error);
+ g_test_add_func ("/parse-message/google-offline", test_google_offline);
+ return g_test_run ();
}
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ef2445a2c..900048f24 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -3,6 +3,7 @@ TWISTED_TESTS = \
avatar-requirements.py \
caps/advertise-contact-caps.py \
caps/advertise-legacy.py \
+ caps/broken-reply.py \
caps/caps-cache.py \
caps/caps-persistent-cache.py \
caps/compat-bundles.py \
@@ -63,6 +64,7 @@ TWISTED_TESTS = \
plugin-channel-managers.py \
power-save.py \
presence/decloak.py \
+ presence/error.py \
presence/initial-contact-presence.py \
presence/initial-presence.py \
presence/invisible_xep_0126.py \
diff --git a/tests/twisted/caps/broken-reply.py b/tests/twisted/caps/broken-reply.py
new file mode 100644
index 000000000..4cb63eed7
--- /dev/null
+++ b/tests/twisted/caps/broken-reply.py
@@ -0,0 +1,20 @@
+"""
+Tests that disco replies whose <query/> node is missing don't crash Gabble.
+"""
+
+from gabbletest import exec_test, sync_stream, make_result_iq
+import caps_helper
+
+def test(q, bus, conn, stream):
+ jid = 'crashy@cra.shy/hi'
+ caps = { 'node': 'oh:hi',
+ 'ver': "dere",
+ }
+ h = caps_helper.send_presence(q, conn, stream, jid, caps, initial=False)
+ request = caps_helper.expect_disco(q, jid, caps['node'], caps)
+ result = make_result_iq(stream, request, add_query_node=False)
+ stream.send(result)
+ sync_stream(q, stream)
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/connect/torture.py b/tests/twisted/connect/torture.py
index add5b7ce8..332b8a20d 100644
--- a/tests/twisted/connect/torture.py
+++ b/tests/twisted/connect/torture.py
@@ -6,6 +6,10 @@ could not be established, since the file descriptors were leaked too); it may
also be useful for profiling the connection process (and test framework).
"""
from gabbletest import exec_test
+import os
+
+if os.environ.get('REALLY_TORTURE', '') != 'yes':
+ raise SystemExit(77)
def test(q, bus, conn, stream):
pass
diff --git a/tests/twisted/presence/error.py b/tests/twisted/presence/error.py
new file mode 100644
index 000000000..53f3703bc
--- /dev/null
+++ b/tests/twisted/presence/error.py
@@ -0,0 +1,71 @@
+"""
+Tests that Gabble provides at least some useful information from error
+presences.
+"""
+
+from gabbletest import exec_test, make_presence, elem
+from servicetest import assertEquals
+import ns
+import constants as cs
+
+def test(q, bus, conn, stream):
+ jids = ['gregory@unreachable.example.com',
+ 'thehawk@unreachable.example.net',
+ ]
+ gregory, hawk = jids
+ gregory_handle, hawk_handle = conn.RequestHandles(cs.HT_CONTACT, jids)
+
+ event = q.expect('stream-iq', query_ns=ns.ROSTER)
+ event.stanza['type'] = 'result'
+ for jid in jids:
+ item = event.query.addElement('item')
+ item['jid'] = jid
+ item['subscription'] = 'both'
+
+ stream.send(event.stanza)
+ q.expect('dbus-signal', signal='PresencesChanged',
+ args=[{gregory_handle: (cs.PRESENCE_OFFLINE, 'offline', ''),
+ hawk_handle: (cs.PRESENCE_OFFLINE, 'offline', ''),
+ }
+ ])
+
+ # Our server can't resolve unreachable.example.com so it sends us an error
+ # presence for Gregory. (This is what Prosody actually does.)
+ presence = make_presence(gregory, type='error')
+ error_text = u'Connection failed: DNS resolution failed'
+ presence.addChild(
+ elem('error', type='cancel')(
+ elem(ns.STANZA, 'remote-server-not-found'),
+ elem(ns.STANZA, 'text')(
+ error_text
+ )
+ ))
+
+ stream.send(presence)
+
+ e = q.expect('dbus-signal', signal='PresencesChanged')
+ presences, = e.args
+ type_, status, message = presences[gregory_handle]
+ assertEquals(cs.PRESENCE_ERROR, type_)
+ assertEquals('error', status)
+ assertEquals(error_text, message)
+
+ # How about maybe the hawk's server is busted?
+ presence = make_presence(hawk, type='error')
+ presence.addChild(
+ elem('error', type='cancel')(
+ elem(ns.STANZA, 'internal-server-error'),
+ ))
+ stream.send(presence)
+
+ e = q.expect('dbus-signal', signal='PresencesChanged')
+ presences, = e.args
+ type_, status, message = presences[hawk_handle]
+ assertEquals(cs.PRESENCE_ERROR, type_)
+ assertEquals('error', status)
+ # FIXME: It might be less user-hostile to give some kind of readable
+ # description of the error in future.
+ assertEquals('internal-server-error', message)
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/test-location.py b/tests/twisted/test-location.py
index 71433ec04..cb1817321 100644
--- a/tests/twisted/test-location.py
+++ b/tests/twisted/test-location.py
@@ -275,8 +275,8 @@ def test(q, bus, conn, stream):
# Hey, while we weren't looking Bob moved abroad!
result = make_result_iq(stream, e.stanza)
result['from'] = 'bob@foo.com'
- query = result.firstChildElement()
- result.addChild(
+ pubsub_node = result.firstChildElement()
+ pubsub_node.addChild(
elem('items', node=ns.GEOLOC)(
elem('item', id='12345')(
elem(ns.GEOLOC, 'geoloc')(
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index 21bbcbd13..433d79c82 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -349,5 +349,7 @@ def test(q, bus, conn, stream, bytestream_cls,
EventPattern('dbus-signal', signal='Closed'),
EventPattern('dbus-signal', signal='ChannelClosed'))
+ t.cleanup()
+
if __name__ == '__main__':
t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/offer-no-caps.py b/tests/twisted/tubes/offer-no-caps.py
index b71b8b684..09532736a 100644
--- a/tests/twisted/tubes/offer-no-caps.py
+++ b/tests/twisted/tubes/offer-no-caps.py
@@ -105,5 +105,7 @@ def test(q, bus, conn, stream):
e = q.expect('dbus-error', method='Offer').error
assert e.get_dbus_name() == cs.NOT_AVAILABLE, e.get_dbus_name()
+ t.cleanup()
+
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/tubes/offer-private-stream-tube.py b/tests/twisted/tubes/offer-private-stream-tube.py
index 63e68146b..71f59be19 100644
--- a/tests/twisted/tubes/offer-private-stream-tube.py
+++ b/tests/twisted/tubes/offer-private-stream-tube.py
@@ -416,5 +416,7 @@ def test(q, bus, conn, stream, bytestream_cls,
assertEquals(conn_id, e.args[0])
assertEquals(cs.CONNECTION_LOST, e.args[1])
+ t.cleanup()
+
if __name__ == '__main__':
t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 3c1a7ca40..9aeb89ed6 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -6,6 +6,7 @@ import errno
import os
import socket
import sys
+import tempfile
import dbus
@@ -21,6 +22,16 @@ from twisted.internet.protocol import Factory, Protocol
from twisted.internet.error import CannotListenError
from twisted.internet import tcp
+_to_cleanup = []
+
+def cleanup():
+ for f in _to_cleanup:
+ try:
+ os.remove(f)
+ except OSError:
+ pass # worse things have happened
+ del _to_cleanup[:]
+
def check_tube_in_tubes(tube, tubes):
"""
Check that 'tube' is in 'tubes', which should be the return value of
@@ -279,13 +290,16 @@ def create_server(q, address_type, factory=None, block_reading=False,
if factory is None:
factory = EventProtocolFactory(q, block_reading)
if address_type == cs.SOCKET_ADDRESS_TYPE_UNIX:
- path = os.getcwd() + '/' + streamfile
+ # don't use os.getcwd() here because it can be quite long and
+ # can easily hit the AF_UNIX max path length.
+ path = tempfile.mkstemp(suffix=streamfile)[1]
try:
os.remove(path)
except OSError, e:
if e.errno != errno.ENOENT:
raise
reactor.listenUNIX(path, factory)
+ _to_cleanup.append(path)
return dbus.ByteArray(path)