summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-03-02 15:37:42 +0000
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-03-02 15:37:42 +0000
commite35953ceb721c30e7808edccf8a00ca9a185adc7 (patch)
tree10d6d2dd71b06fd49e17142315fe7f2700ff3a74 /lib
parente4bd1f21c86cbd949f70a911f6dc8dfd795e1baa (diff)
downloadtelepathy-salut-e35953ceb721c30e7808edccf8a00ca9a185adc7.tar.gz
gibber-xmpp-connection: removed
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/gibber/Makefile.am2
-rw-r--r--lib/gibber/gibber-bytestream-direct.c1
-rw-r--r--lib/gibber/gibber-bytestream-oob.c1
-rw-r--r--lib/gibber/gibber-file-transfer.h1
-rw-r--r--lib/gibber/gibber-xmpp-connection.c391
-rw-r--r--lib/gibber/gibber-xmpp-connection.h102
-rw-r--r--lib/gibber/tests/Makefile.am19
-rw-r--r--lib/gibber/tests/check-gibber-xmpp-connection.c135
-rw-r--r--lib/gibber/tests/test-xmpp-connection.c160
9 files changed, 2 insertions, 810 deletions
diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am
index 2b93f407..5206df16 100644
--- a/lib/gibber/Makefile.am
+++ b/lib/gibber/Makefile.am
@@ -10,8 +10,6 @@ BUILT_SOURCES = \
gibber-signals-marshal.c
HANDWRITTEN_SOURCES = \
- gibber-xmpp-connection.c \
- gibber-xmpp-connection.h \
gibber-muc-connection.c \
gibber-muc-connection.h \
gibber-bytestream-ibb.h \
diff --git a/lib/gibber/gibber-bytestream-direct.c b/lib/gibber/gibber-bytestream-direct.c
index adb90417..81c6ba6e 100644
--- a/lib/gibber/gibber-bytestream-direct.c
+++ b/lib/gibber/gibber-bytestream-direct.c
@@ -26,7 +26,6 @@
#include <glib.h>
#include "gibber-sockets.h"
-#include "gibber-xmpp-connection.h"
#include "gibber-linklocal-transport.h"
#include "gibber-util.h"
#include "gibber-xmpp-error.h"
diff --git a/lib/gibber/gibber-bytestream-oob.c b/lib/gibber/gibber-bytestream-oob.c
index f01c0a59..213bb504 100644
--- a/lib/gibber/gibber-bytestream-oob.c
+++ b/lib/gibber/gibber-bytestream-oob.c
@@ -34,7 +34,6 @@
#include "gibber-sockets.h"
#include "gibber-bytestream-iface.h"
-#include "gibber-xmpp-connection.h"
#include "gibber-namespaces.h"
#include "gibber-linklocal-transport.h"
#include "gibber-xmpp-error.h"
diff --git a/lib/gibber/gibber-file-transfer.h b/lib/gibber/gibber-file-transfer.h
index 411a2486..e86d4cba 100644
--- a/lib/gibber/gibber-file-transfer.h
+++ b/lib/gibber/gibber-file-transfer.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <wocky/wocky-stanza.h>
#include <wocky/wocky-porter.h>
-#include "gibber-xmpp-connection.h"
G_BEGIN_DECLS
diff --git a/lib/gibber/gibber-xmpp-connection.c b/lib/gibber/gibber-xmpp-connection.c
deleted file mode 100644
index e4e567b4..00000000
--- a/lib/gibber/gibber-xmpp-connection.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * gibber-xmpp-connection.c - Source for GibberXmppConnection
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gibber-xmpp-connection.h"
-#include "gibber-signals-marshal.h"
-
-#include "gibber-xmpp-reader.h"
-#include "gibber-xmpp-writer.h"
-#include "gibber-transport.h"
-#include <wocky/wocky-stanza.h>
-
-#define XMPP_STREAM_NAMESPACE "http://etherx.jabber.org/streams"
-
-static void _xmpp_connection_received_data (GibberTransport *transport,
- GibberBuffer *buffer, gpointer user_data);
-
-G_DEFINE_TYPE(GibberXmppConnection, gibber_xmpp_connection, G_TYPE_OBJECT)
-
-/* signal enum */
-enum
-{
- STREAM_OPENED,
- STREAM_CLOSED,
- PARSE_ERROR,
- RECEIVED_STANZA,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-static void _reader_stream_opened_cb (GibberXmppReader *reader,
- const gchar *to, const gchar *from, const gchar *version,
- gpointer user_data);
-
-static void _reader_stream_closed_cb (GibberXmppReader *reader,
- gpointer user_data);
-
-static void _reader_received_stanza_cb (GibberXmppReader *reader,
- WockyStanza *stanza, gpointer user_data);
-
-/* private structure */
-typedef struct _GibberXmppConnectionPrivate GibberXmppConnectionPrivate;
-
-struct _GibberXmppConnectionPrivate
-{
- GibberXmppReader *reader;
- GibberXmppWriter *writer;
- gboolean dispose_has_run;
- guint last_id;
-};
-
-#define GIBBER_XMPP_CONNECTION_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIBBER_TYPE_XMPP_CONNECTION, \
- GibberXmppConnectionPrivate))
-
-static GObject *
-gibber_xmpp_connection_constructor (GType type,
- guint n_props, GObjectConstructParam *props)
-{
- GObject *obj;
- GibberXmppConnectionPrivate *priv;
-
- obj = G_OBJECT_CLASS (gibber_xmpp_connection_parent_class)->
- constructor (type, n_props, props);
-
- priv = GIBBER_XMPP_CONNECTION_GET_PRIVATE (obj);
-
- priv->writer = gibber_xmpp_writer_new ();
- priv->reader = gibber_xmpp_reader_new ();
-
- g_signal_connect (priv->reader, "stream-opened",
- G_CALLBACK (_reader_stream_opened_cb), obj);
- g_signal_connect (priv->reader, "stream-closed",
- G_CALLBACK (_reader_stream_closed_cb), obj);
- g_signal_connect (priv->reader, "received-stanza",
- G_CALLBACK (_reader_received_stanza_cb), obj);
-
- return obj;
-}
-
-static void
-gibber_xmpp_connection_init (GibberXmppConnection *obj)
-{
- GibberXmppConnectionPrivate *priv = GIBBER_XMPP_CONNECTION_GET_PRIVATE (obj);
- obj->transport = NULL;
- priv->last_id = 0;
-}
-
-static void gibber_xmpp_connection_dispose (GObject *object);
-static void gibber_xmpp_connection_finalize (GObject *object);
-
-static void
-gibber_xmpp_connection_class_init (
- GibberXmppConnectionClass *gibber_xmpp_connection_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (gibber_xmpp_connection_class);
-
- g_type_class_add_private (gibber_xmpp_connection_class,
- sizeof (GibberXmppConnectionPrivate));
-
- object_class->dispose = gibber_xmpp_connection_dispose;
- object_class->finalize = gibber_xmpp_connection_finalize;
-
- object_class->constructor = gibber_xmpp_connection_constructor;
-
- signals[STREAM_OPENED] = g_signal_new ("stream-opened",
- G_OBJECT_CLASS_TYPE (gibber_xmpp_connection_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- _gibber_signals_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[STREAM_CLOSED] = g_signal_new ("stream-closed",
- G_OBJECT_CLASS_TYPE (gibber_xmpp_connection_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[RECEIVED_STANZA] = g_signal_new ("received-stanza",
- G_OBJECT_CLASS_TYPE (gibber_xmpp_connection_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, WOCKY_TYPE_STANZA);
-
- signals[PARSE_ERROR] = g_signal_new ("parse-error",
- G_OBJECT_CLASS_TYPE(gibber_xmpp_connection_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-void
-gibber_xmpp_connection_dispose (GObject *object)
-{
- GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (object);
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (self);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
- if (self->transport != NULL)
- {
- g_object_unref (self->transport);
- self->transport = NULL;
- }
-
- if (priv->reader != NULL)
- {
- g_object_unref (priv->reader);
- priv->reader = NULL;
- }
-
- if (priv->writer != NULL)
- {
- g_object_unref (priv->writer);
- priv->writer = NULL;
- }
-
- /* release any references held by the object here */
-
- if (G_OBJECT_CLASS (gibber_xmpp_connection_parent_class)->dispose)
- G_OBJECT_CLASS (gibber_xmpp_connection_parent_class)->dispose (object);
-}
-
-void
-gibber_xmpp_connection_finalize (GObject *object)
-{
- G_OBJECT_CLASS (gibber_xmpp_connection_parent_class)->finalize (object);
-}
-
-
-
-static GibberXmppConnection *
-new_connection (GibberTransport *transport, gboolean stream)
-{
- GibberXmppConnection * result;
-
- result = g_object_new (GIBBER_TYPE_XMPP_CONNECTION, NULL);
-
- if (transport != NULL)
- {
- gibber_xmpp_connection_engage (result, transport);
- }
-
- return result;
-}
-
-GibberXmppConnection *
-gibber_xmpp_connection_new (GibberTransport *transport)
-{
- return new_connection (transport, TRUE);
-}
-
-GibberXmppConnection *
-gibber_xmpp_connection_new_no_stream (GibberTransport *transport)
-{
- return new_connection (transport, FALSE);
-}
-
-void
-gibber_xmpp_connection_open (GibberXmppConnection *connection,
- const gchar *to, const gchar *from, const gchar *version)
-{
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (connection);
- const guint8 *data;
- gsize length;
-
- g_assert ((connection->stream_flags & GIBBER_XMPP_CONNECTION_STREAM_SENT)
- == 0);
-
- gibber_xmpp_writer_stream_open (priv->writer, to, from, version, &data,
- &length);
- connection->stream_flags |= GIBBER_XMPP_CONNECTION_STREAM_SENT;
- gibber_transport_send (connection->transport, data, length, NULL);
-}
-
-void
-gibber_xmpp_connection_restart (GibberXmppConnection *connection)
-{
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (connection);
-
- g_assert (connection->stream_flags
- & GIBBER_XMPP_CONNECTION_STREAM_FULLY_OPEN);
- gibber_xmpp_reader_reset (priv->reader);
- connection->stream_flags = 0;
-}
-
-void
-gibber_xmpp_connection_close (GibberXmppConnection *connection)
-{
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (connection);
- const guint8 *data;
- gsize length;
-
- connection->stream_flags |= GIBBER_XMPP_CONNECTION_CLOSE_SENT;
-
- gibber_xmpp_writer_stream_close (priv->writer, &data, &length);
- gibber_transport_send (connection->transport, data, length, NULL);
-}
-
-void
-gibber_xmpp_connection_engage (GibberXmppConnection *connection,
- GibberTransport *transport)
-{
- g_assert (connection->transport == NULL);
-
- connection->transport = g_object_ref (transport);
- gibber_transport_set_handler (transport, _xmpp_connection_received_data,
- connection);
-}
-
-void
-gibber_xmpp_connection_disengage (GibberXmppConnection *connection)
-{
- g_assert (connection->transport != NULL);
-
- gibber_transport_set_handler (connection->transport, NULL, NULL);
-
- g_object_unref (connection->transport);
- connection->transport = NULL;
-}
-
-gboolean
-gibber_xmpp_connection_send (GibberXmppConnection *connection,
- WockyStanza *stanza, GError **error)
-{
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (connection);
- WockyNode *node = wocky_stanza_get_top_node (stanza);
- const guint8 *data;
- gsize length;
- const gchar *id;
-
- id = wocky_node_get_attribute (node, "id");
- if (id == NULL)
- {
- gchar *tmp = gibber_xmpp_connection_new_id (connection);
- wocky_node_set_attribute (node, "id", tmp);
- g_free (tmp);
- }
-
- if (!gibber_xmpp_writer_write_stanza (priv->writer, stanza,
- &data, &length, error))
- {
- return FALSE;
- }
-
- return gibber_transport_send (connection->transport, data, length, error);
-}
-
-static void
-_xmpp_connection_received_data (GibberTransport *transport,
- GibberBuffer *buffer, gpointer user_data)
-{
- GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (user_data);
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (self);
- gboolean ret;
- GError *error = NULL;
-
- g_assert (buffer->length > 0);
-
- /* Ensure we're not disposed inside while running the reader is busy */
- g_object_ref (self);
- ret = gibber_xmpp_reader_push (priv->reader, buffer->data, buffer->length,
- &error);
-
- if (!ret)
- {
- g_signal_emit (self, signals[PARSE_ERROR], 0);
- }
- g_object_unref (self);
-}
-
-static void
-_reader_stream_opened_cb (GibberXmppReader *reader, const gchar *to,
- const gchar *from, const gchar *version, gpointer user_data)
-{
- GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (user_data);
-
- self->stream_flags |= GIBBER_XMPP_CONNECTION_STREAM_RECEIVED;
-
- g_signal_emit (self, signals[STREAM_OPENED], 0, to, from, version);
-}
-
-static void
-_reader_stream_closed_cb (GibberXmppReader *reader, gpointer user_data)
-{
- GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (user_data);
-
- self->stream_flags |= GIBBER_XMPP_CONNECTION_CLOSE_RECEIVED;
-
- g_signal_emit (self, signals[STREAM_CLOSED], 0);
-}
-
-static void
-_reader_received_stanza_cb (GibberXmppReader *reader, WockyStanza *stanza,
- gpointer user_data)
-{
- GibberXmppConnection *self = GIBBER_XMPP_CONNECTION (user_data);
- g_signal_emit (self, signals[RECEIVED_STANZA], 0, stanza);
-}
-
-gchar *
-gibber_xmpp_connection_new_id (GibberXmppConnection *self)
-{
- GibberXmppConnectionPrivate *priv =
- GIBBER_XMPP_CONNECTION_GET_PRIVATE (self);
- GTimeVal tv;
- glong val;
-
- g_get_current_time (&tv);
- val = (tv.tv_sec & tv.tv_usec) + priv->last_id++;
-
- return g_strdup_printf ("%ld%ld", val, tv.tv_usec);
-}
diff --git a/lib/gibber/gibber-xmpp-connection.h b/lib/gibber/gibber-xmpp-connection.h
deleted file mode 100644
index 821e3327..00000000
--- a/lib/gibber/gibber-xmpp-connection.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * gibber-xmpp-connection.h - Header for GibberXmppConnection
- * Copyright (C) 2006 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd@luon.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __GIBBER_XMPP_CONNECTION_H__
-#define __GIBBER_XMPP_CONNECTION_H__
-
-#include <glib-object.h>
-
-#include "gibber-transport.h"
-#include <wocky/wocky-stanza.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GibberXmppConnection GibberXmppConnection;
-typedef struct _GibberXmppConnectionClass GibberXmppConnectionClass;
-
-typedef enum
-{
- GIBBER_XMPP_CONNECTION_STREAM_SENT = 1 << 0,
- GIBBER_XMPP_CONNECTION_STREAM_RECEIVED = 1 << 1,
- GIBBER_XMPP_CONNECTION_STREAM_FULLY_OPEN =
- GIBBER_XMPP_CONNECTION_STREAM_SENT|GIBBER_XMPP_CONNECTION_STREAM_RECEIVED,
- GIBBER_XMPP_CONNECTION_CLOSE_SENT = 1 << 2,
- GIBBER_XMPP_CONNECTION_CLOSE_RECEIVED = 1 << 3,
- GIBBER_XMPP_CONNECTION_CLOSE_FULLY_CLOSED =
- GIBBER_XMPP_CONNECTION_STREAM_FULLY_OPEN|
- GIBBER_XMPP_CONNECTION_CLOSE_SENT|GIBBER_XMPP_CONNECTION_CLOSE_RECEIVED,
-} GibberXmppConnectionFlags;
-
-struct _GibberXmppConnectionClass {
- GObjectClass parent_class;
-};
-
-struct _GibberXmppConnection {
- GObject parent;
- GibberTransport *transport;
- guint8 stream_flags;
-};
-
-GType gibber_xmpp_connection_get_type (void);
-
-/* TYPE MACROS */
-#define GIBBER_TYPE_XMPP_CONNECTION \
- (gibber_xmpp_connection_get_type ())
-#define GIBBER_XMPP_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GIBBER_TYPE_XMPP_CONNECTION, \
- GibberXmppConnection))
-#define GIBBER_XMPP_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GIBBER_TYPE_XMPP_CONNECTION, \
- GibberXmppConnectionClass))
-#define GIBBER_IS_XMPP_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIBBER_TYPE_XMPP_CONNECTION))
-#define GIBBER_IS_XMPP_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GIBBER_TYPE_XMPP_CONNECTION))
-#define GIBBER_XMPP_CONNECTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), GIBBER_TYPE_XMPP_CONNECTION, \
- GibberXmppConnectionClass))
-
-GibberXmppConnection *gibber_xmpp_connection_new (GibberTransport *transport);
-
-void gibber_xmpp_connection_open (GibberXmppConnection *connection,
- const gchar *to, const gchar *from, const gchar *version);
-
-/* Prepare the connection for a reopen from the other side, for example after
- * successfull SASL authentication */
-void gibber_xmpp_connection_restart (GibberXmppConnection *connection);
-
-void gibber_xmpp_connection_close (GibberXmppConnection *connection);
-
-void gibber_xmpp_connection_engage (GibberXmppConnection *connection,
- GibberTransport *transport);
-
-void gibber_xmpp_connection_disengage (GibberXmppConnection *connection);
-
-gboolean gibber_xmpp_connection_send (GibberXmppConnection *connection,
- WockyStanza *stanza, GError **error);
-
-gchar * gibber_xmpp_connection_new_id (GibberXmppConnection *connection);
-
-GibberXmppConnection * gibber_xmpp_connection_new_no_stream (
- GibberTransport *transport);
-
-G_END_DECLS
-
-#endif /* #ifndef __GIBBER_XMPP_CONNECTION_H__*/
diff --git a/lib/gibber/tests/Makefile.am b/lib/gibber/tests/Makefile.am
index b7e460fc..03e3f6eb 100644
--- a/lib/gibber/tests/Makefile.am
+++ b/lib/gibber/tests/Makefile.am
@@ -35,29 +35,16 @@ $(top_builddir)/lib/gibber/libgibber.la:
.PHONY: $(top_builddir)/lib/gibber/libgibber.la
-TESTS = \
- run-xmpp-connection-test.sh
+TESTS =
noinst_PROGRAMS = \
- test-xmpp-connection \
test-r-multicast-transport-io
-check_SCRIPTS = run-xmpp-connection-test.sh
+check_SCRIPTS =
EXTRA_DIST += \
simplemeshtest.py mesh.py $(check_SCRIPTS)
-test_xmpp_connection_SOURCES = \
- test-xmpp-connection.c \
- test-transport.c \
- test-transport.h
-
-test_xmpp_connection_LDADD = \
- $(AM_LDFLAGS)
-
-test_xmpp_connection_CFLAGS = \
- $(AM_CFLAGS)
-
test_r_multicast_transport_io_SOURCES = \
test-r-multicast-transport-io.c \
test-transport.c \
@@ -76,7 +63,6 @@ test_r_multicast_transport_io_CFLAGS = \
check_PROGRAMS = \
check-gibber-xmpp-reader \
check-gibber-r-multicast-causal-transport \
- check-gibber-xmpp-connection \
check-gibber-r-multicast-packet \
check-gibber-r-multicast-sender \
check-gibber-listener \
@@ -91,7 +77,6 @@ test: ${TEST_PROGS}
# Coding style checks
check_c_sources = \
- $(test_xmpp_connection_SOURCES) \
$(test_r_multicast_transport_io_SOURCES)
include $(top_srcdir)/tools/check-coding-style.mk
diff --git a/lib/gibber/tests/check-gibber-xmpp-connection.c b/lib/gibber/tests/check-gibber-xmpp-connection.c
deleted file mode 100644
index 03412579..00000000
--- a/lib/gibber/tests/check-gibber-xmpp-connection.c
+++ /dev/null
@@ -1,135 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include <gibber/gibber-xmpp-connection.h>
-#include <gibber/gibber-transport.h>
-#include "test-transport.h"
-
-struct _FileChunker {
- gchar *contents;
- gsize length;
- gsize size;
- gsize offset;
-};
-typedef struct _FileChunker FileChunker;
-
-static void
-file_chunker_destroy (FileChunker *fc) {
- g_free (fc->contents);
- g_free (fc);
-}
-
-
-static FileChunker *
-file_chunker_new (const gchar *filename, gsize chunk_size) {
- FileChunker *fc;
- fc = g_new0 (FileChunker, 1);
-
- fc->size = chunk_size;
- if (!g_file_get_contents (filename, &fc->contents, &fc->length, NULL)) {
- file_chunker_destroy (fc);
- return NULL;
- }
- return fc;
-}
-
-static gboolean
-file_chunker_get_chunk (FileChunker *fc,
- gchar **chunk,
- gsize *chunk_size) {
- if (fc->offset < fc->length) {
- *chunk_size = MIN (fc->length - fc->offset, fc->size);
- *chunk = fc->contents + fc->offset;
- fc->offset += *chunk_size;
- return TRUE;
- }
- return FALSE;
-}
-
-
-static void
-test_instantiation (void)
-{
- GibberXmppConnection *connection;
- TestTransport *transport;
-
- transport = test_transport_new (NULL, NULL);
- connection = gibber_xmpp_connection_new (GIBBER_TRANSPORT(transport));
-
- g_assert (connection != NULL);
-
- connection = gibber_xmpp_connection_new (NULL);
-
- g_assert (connection != NULL);
-}
-
-static void
-parse_error_cb (GibberXmppConnection *connection, gpointer user_data)
-{
- gboolean *parse_error_found = user_data;
- *parse_error_found = TRUE;
-}
-
-static void
-test_simple_message (void)
-{
- GibberXmppConnection *connection;
- TestTransport *transport;
- gchar *chunk;
- gsize chunk_length;
- gboolean parse_error_found = FALSE;
- const gchar *srcdir;
- gchar *file;
- FileChunker *fc;
-
- srcdir = g_getenv ("srcdir");
- if (srcdir == NULL)
- {
- file = g_strdup ("inputs/simple-message.input");
- }
- else
- {
- file = g_strdup_printf ("%s/inputs/simple-message.input", srcdir);
- }
-
- fc = file_chunker_new (file, 10);
- g_assert (fc != NULL);
-
- transport = test_transport_new (NULL, NULL);
- connection = gibber_xmpp_connection_new (GIBBER_TRANSPORT(transport));
-
- g_signal_connect (connection, "parse-error",
- G_CALLBACK(parse_error_cb), &parse_error_found);
-
- while (!parse_error_found &&
- file_chunker_get_chunk (fc, &chunk, &chunk_length))
- {
- test_transport_write (transport, (guint8 *) chunk, chunk_length);
- }
-
- g_assert (!parse_error_found);
-
- g_free (file);
- file_chunker_destroy (fc);
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_type_init ();
-
- /* Kill tests in 20 seconds */
- alarm (20);
-
- g_test_add_func ("/gibber/xmpp-connection/instantiation",
- test_instantiation);
- g_test_add_func ("/gibber/xmpp-connection/simple-message",
- test_simple_message);
-
- return g_test_run ();
-}
-
-#include "test-transport.c"
diff --git a/lib/gibber/tests/test-xmpp-connection.c b/lib/gibber/tests/test-xmpp-connection.c
deleted file mode 100644
index 6bb627bc..00000000
--- a/lib/gibber/tests/test-xmpp-connection.c
+++ /dev/null
@@ -1,160 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include <gibber/gibber-xmpp-connection.h>
-#include <gibber/gibber-transport.h>
-#include <wocky/wocky.h>
-#include "test-transport.h"
-
-#define BUFSIZE 10
-
-FILE *treefile = NULL;
-FILE *xmlfile = NULL;
-gboolean parsing_failed = FALSE;
-
-static gboolean
-send_hook (GibberTransport *transport, const guint8 *data,
- gsize length, GError **error, gpointer user_data)
-{
- size_t written;
- /* Nothing for now */
- written = fwrite (data, 1, length, xmlfile);
- g_assert (written == length);
- return TRUE;
-}
-
-static void
-parse_error (GibberXmppConnection *connection, gpointer user_data)
-{
- fprintf (treefile, "PARSE ERROR\n");
- fprintf (stderr, "PARSING FAILED\n");
- parsing_failed = TRUE;
-}
-
-static void
-stream_opened (GibberXmppConnection *connection, const gchar *to,
- const gchar *from, const gchar *version, gpointer user_data)
-{
- fprintf (treefile, "STREAM OPENED to=%s from=%s version=%s\n", to, from,
- version);
-
- gibber_xmpp_connection_open (connection, to, from, version);
-}
-
-static void
-stream_closed (GibberXmppConnection *connection, gpointer user_data)
-{
- fprintf (treefile, "STREAM CLOSED\n");
- gibber_xmpp_connection_close (connection);
-}
-
-static gboolean
-print_attribute (const gchar *key, const gchar *value, const gchar *pref,
- const gchar *ns, gpointer user_data)
-{
- fprintf (treefile, "%*s |-- Attribute: %s -> %s (ns: %s)\n",
- GPOINTER_TO_INT (user_data), " ", key, value, ns);
- return TRUE;
-}
-
-static void print_node (WockyNode *node, gint ident);
-
-static gboolean
-print_child (WockyNode *node, gpointer user_data)
-{
- print_node (node, GPOINTER_TO_INT(user_data));
- return TRUE;
-}
-
-static void
-print_node (WockyNode *node, gint ident)
-{
- fprintf (treefile, "%*s`-+-- Name: %s (ns: %s)\n", ident - 1, " ",
- node->name, wocky_node_get_ns (node));
- wocky_node_each_attribute (node, print_attribute,
- GINT_TO_POINTER(ident));
-
- if (node->content)
- fprintf (treefile, "%*s |-- Content: %s\n", ident, " ", node->content);
- if (wocky_node_get_language (node))
- fprintf (treefile, "%*s |-- Language: %s\n", ident, " ",
- wocky_node_get_language (node));
-
- wocky_node_each_child (node, print_child, GINT_TO_POINTER (ident + 2));
-}
-
-static void
-received_stanza (GibberXmppConnection *connection, WockyStanza *stanza,
- gpointer user_data)
-{
- fprintf (treefile, "-|\n");
- print_node (wocky_stanza_get_top_node (stanza), 2);
- g_assert (gibber_xmpp_connection_send (connection, stanza, NULL));
-}
-
-int
-main (int argc, char **argv)
-{
- GibberXmppConnection *connection;
- TestTransport *transport;
- FILE *file;
- int ret = 0;
- guint8 buf[BUFSIZE];
-
-
- g_type_init ();
- wocky_init ();
-
- transport = test_transport_new (send_hook, NULL);
- connection = gibber_xmpp_connection_new (GIBBER_TRANSPORT(transport));
-
- g_signal_connect (connection, "parse-error",
- G_CALLBACK (parse_error), NULL);
- g_signal_connect (connection, "stream-opened",
- G_CALLBACK (stream_opened), NULL);
- g_signal_connect (connection, "stream-closed",
- G_CALLBACK (stream_closed), NULL);
- g_signal_connect (connection, "received-stanza",
- G_CALLBACK (received_stanza), NULL);
-
- g_assert (argc >= 2 && argc < 5);
-
- file = fopen (argv[1], "r");
- g_assert (file != NULL);
-
- if (argc >= 3)
- {
- treefile = fopen (argv[2], "w+");
- }
- else
- {
- treefile = stdout;
- }
- g_assert (treefile != NULL);
-
- if (argc >= 4)
- {
- xmlfile = fopen (argv[3], "w+");
- }
- else
- {
- xmlfile = stderr;
- }
- g_assert (xmlfile != NULL);
-
- while (!parsing_failed && (ret = fread (buf, 1, BUFSIZE, file)) > 0)
- {
- test_transport_write (transport, buf, ret);
- }
-
- while (g_main_context_iteration (NULL, FALSE))
- ;
-
-
- g_assert (parsing_failed || ret == 0);
- fclose (file);
-
- wocky_deinit ();
- return parsing_failed ? 1 : 0;
-}