--- a/loudmouth/Makefile.am Sun Jun 22 22:38:28 2008 +0200
+++ b/loudmouth/Makefile.am Sun Jun 22 22:53:07 2008 +0200
@@ -53,10 +53,12 @@
lm-sock.c \
lm-socket.c \
lm-socket.h \
- asyncns.c \
- asyncns.h \
+ asyncns.c \
+ asyncns.h \
lm-sasl.c \
lm-sasl.h \
+ lm-xmpp-writer.c \
+ lm-xmpp-writer.h \
md5.c \
md5.h \
$(NULL)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/lm-xmpp-writer.c Sun Jun 22 22:53:07 2008 +0200
@@ -0,0 +1,93 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Imendio AB
+ *
+ * This program 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 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "lm-xmpp-writer.h"
+
+static void xmpp_writer_base_init (LmXmppWriterIface *iface);
+
+GType
+lm_xmpp_writer_get_type (void)
+{
+ static GType iface_type = 0;
+
+ if (!iface_type) {
+ static const GTypeInfo iface_info = {
+ sizeof (LmXmppWriterIface),
+ (GBaseInitFunc) xmpp_writer_base_init,
+ (GBaseFinalizeFunc) NULL,
+ };
+
+ iface_type = g_type_register_static (G_TYPE_INTERFACE,
+ "LmXmppWriterIface",
+ &iface_info,
+ 0);
+
+ g_type_interface_add_prerequisite (iface_type, G_TYPE_OBJECT);
+ }
+
+ return iface_type;
+}
+
+static void
+xmpp_writer_base_init (LmXmppWriterIface *iface)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ /* create interface signals here. */
+ initialized = TRUE;
+ }
+}
+
+void
+lm_xmpp_writer_send (LmXmppWriter *writer,
+ LmMessage *message)
+{
+ if (!LM_XMPP_WRITER_GET_IFACE(writer)->send) {
+ g_assert_not_reached ();
+ }
+
+ LM_XMPP_WRITER_GET_IFACE(writer)->send (writer, message);
+}
+
+void
+lm_xmpp_writer_send_text (LmXmppWriter *writer,
+ const gchar *buf,
+ gsize len)
+{
+ if (!LM_XMPP_WRITER_GET_IFACE(writer)->send_text) {
+ g_assert_not_reached ();
+ }
+
+ LM_XMPP_WRITER_GET_IFACE(writer)->send_text (writer, buf, len);
+}
+
+void
+lm_xmpp_writer_flush (LmXmppWriter *writer)
+{
+ if (!LM_XMPP_WRITER_GET_IFACE(writer)->flush) {
+ g_assert_not_reached ();
+ }
+
+ LM_XMPP_WRITER_GET_IFACE(writer)->flush (writer);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/lm-xmpp-writer.h Sun Jun 22 22:53:07 2008 +0200
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * This program 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 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_XMPP_WRITER_H__
+#define __LM_XMPP_WRITER_H__
+
+#include <glib-object.h>
+#include "lm-message.h"
+
+G_BEGIN_DECLS
+
+#define LM_TYPE_XMPP_WRITER (lm_xmpp_writer_get_type())
+#define LM_XMPP_WRITER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), LM_TYPE_XMPP_WRITER, LmXmppWriter))
+#define LM_IS_XMPP_WRITER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), LM_TYPE_XMPP_WRITER))
+#define LM_XMPP_WRITER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), LM_TYPE_XMPP_WRITER, LmXmppWriterIface))
+
+typedef struct _LmXmppWriter LmXmppWriter;
+typedef struct _LmXmppWriterIface LmXmppWriterIface;
+
+struct _LmXmppWriterIface {
+ GTypeInterface parent;
+
+ /* <vtable> */
+ void (*send) (LmXmppWriter *writer,
+ LmMessage *message);
+ void (*send_text) (LmXmppWriter *writer,
+ const gchar *buf,
+ gsize len);
+
+ /* Needed? */
+ void (*flush) (LmXmppWriter *writer);
+};
+
+GType lm_xmpp_writer_get_type (void);
+
+void lm_xmpp_writer_send (LmXmppWriter *writer,
+ LmMessage *message);
+void lm_xmpp_writer_send_text (LmXmppWriter *writer,
+ const gchar *buf,
+ gsize len);
+void lm_xmpp_writer_flush (LmXmppWriter *writer);
+
+G_END_DECLS
+
+#endif /* __LM_XMPP_WRITER_H__ */
+