--- a/CMakeLists.txt Sun Jul 11 20:37:04 2010 +0200
+++ b/CMakeLists.txt Tue Jul 13 12:56:45 2010 +0200
@@ -39,6 +39,7 @@
## Target definitions
add_subdirectory(jingle)
add_subdirectory(jingle-filetransfer)
+add_subdirectory(jingle-ibb)
## Packaging information
set(CPACK_PACKAGE_NAME mcabber-jingle)
--- a/jingle-filetransfer/filetransfer.c Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle-filetransfer/filetransfer.c Tue Jul 13 12:56:45 2010 +0200
@@ -110,7 +110,7 @@
static void jingle_ft_init(void)
{
- jingle_register_app(NS_JINGLE_APP_FT, &funcs);
+ jingle_register_app(NS_JINGLE_APP_FT, &funcs, JINGLE_TRANS_TCP);
xmpp_add_feature(NS_JINGLE_APP_FT);
}
--- a/jingle-filetransfer/filetransfer.h Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle-filetransfer/filetransfer.h Tue Jul 13 12:56:45 2010 +0200
@@ -17,7 +17,6 @@
/* the size, in bytes, of the data to be sent */
gint64 size;
-
} JingleFT;
#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle-ibb/CMakeLists.txt Tue Jul 13 12:56:45 2010 +0200
@@ -0,0 +1,4 @@
+add_library(jingle-inbandbytestream MODULE ibb.c ibb.h)
+set_target_properties(jingle-inbandbytestream PROPERTIES COMPILE_FLAGS "-Wall")
+include_directories(${CMAKE_SOURCE_DIR})
+install(TARGETS jingle-inbandbytestream DESTINATION lib/mcabber)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle-ibb/ibb.c Tue Jul 13 12:56:45 2010 +0200
@@ -0,0 +1,97 @@
+/*
+ * filetransfer.c
+ *
+ * Copyrigth (C) 2010 Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 <glib.h>
+
+#include <mcabber/modules.h>
+#include <mcabber/utils.h>
+#include <mcabber/xmpp_helper.h>
+
+#include <jingle/jingle.h>
+#include <jingle/check.h>
+#include <jingle/register.h>
+
+#include "ibb.h"
+
+
+gconstpointer jingle_ibb_check(JingleContent *cn, GError **err);
+static void jingle_ibb_init(void);
+static void jingle_ibb_uninit(void);
+
+
+const gchar *deps[] = { "jingle", NULL };
+
+JingleTransportFuncs funcs = {jingle_ibb_check, NULL};
+
+module_info_t info_jingle_filetransfer = {
+ .branch = MCABBER_BRANCH,
+ .api = MCABBER_API_VERSION,
+ .version = PROJECT_VERSION,
+ .description = "Jingle In Band Bytestream (XEP-0261)\n",
+ .requires = deps,
+ .init = jingle_ibb_init,
+ .uninit = jingle_ibb_uninit,
+ .next = NULL,
+};
+
+
+gconstpointer jingle_ibb_check(JingleContent *cn, GError **err)
+{
+ JingleIBB *ibb = NULL;
+ LmMessageNode *node = cn->transport;
+ const gchar *blocksize;
+
+ blocksize = lm_message_node_get_attribute(node, "block-size");
+ ibb->sid = lm_message_node_get_attribute(node, "sid");
+
+ if (!ibb->sid || !blocksize) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
+ "an attribute of the transport element is missing");
+ g_free(ibb);
+ return NULL;
+ }
+
+ ibb->blocksize = g_ascii_strtoll(blocksize, NULL, 10);
+
+ // the size attribute is a xs:short an therefore can be negative.
+ if (ibb->blocksize < 0) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
+ "block-size is negative");
+ g_free(ibb);
+ return NULL;
+ }
+
+ return (gconstpointer) ibb;
+}
+
+static void jingle_ibb_init(void)
+{
+ jingle_register_transport(NS_JINGLE_TRANSPORT_IBB, &funcs, JINGLE_TRANS_IN_BAND, JINGLE_TRANS_TCP);
+ xmpp_add_feature(NS_JINGLE_TRANSPORT_IBB);
+}
+
+static void jingle_ibb_uninit(void)
+{
+ xmpp_del_feature(NS_JINGLE_TRANSPORT_IBB);
+ jingle_unregister_transport(NS_JINGLE_TRANSPORT_IBB);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle-ibb/ibb.h Tue Jul 13 12:56:45 2010 +0200
@@ -0,0 +1,15 @@
+#ifndef __JINGLEIBB_H__
+#define __JINGLEIBB_H__ 1
+
+#define NS_JINGLE_TRANSPORT_IBB "urn:xmpp:jingle:transports:ibb:1"
+
+typedef struct {
+ /* Size of the blocks */
+ int blocksize;
+
+ /* The identifiant of the transfer */
+ const gchar *sid;
+
+} JingleIBB;
+
+#endif
--- a/jingle/general-handlers.c Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle/general-handlers.c Tue Jul 13 12:56:45 2010 +0200
@@ -23,6 +23,7 @@
#include <mcabber/events.h>
#include <mcabber/logprint.h>
+#include <mcabber/xmpp_helper.h>
#include <jingle/jingle.h>
#include <jingle/general-handlers.h>
@@ -75,8 +76,7 @@
LmMessage *message, gpointer user_data)
{
GSList *child;
- LmMessageNode *node = lm_message_get_node(message);
- const gchar *id = lm_message_node_get_attribute(node, "id");
+ const gchar *id = lm_message_get_id(message);
ack_iq *ai;
for (child = ack_wait; child; child = child->next) {
ai = (ack_iq*)child->data;
--- a/jingle/register.c Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle/register.c Tue Jul 13 12:56:45 2010 +0200
@@ -30,11 +30,14 @@
typedef struct {
gchar *xmlns;
JingleAppFuncs *funcs;
+ JingleTransMethod method;
} AppHandlerEntry;
typedef struct {
gchar *xmlns;
JingleTransportFuncs *funcs;
+ JingleTransType type;
+ JingleTransMethod method;
} TransportHandlerEntry;
@@ -46,7 +49,8 @@
GSList *jingle_transport_handlers = NULL;
-void jingle_register_app(const gchar *xmlns, JingleAppFuncs *funcs)
+void jingle_register_app(const gchar *xmlns, JingleAppFuncs *funcs,
+ JingleTransMethod method)
{
if (!g_str_has_prefix(xmlns, NS_JINGLE_APP_PREFIX)) return;
@@ -54,11 +58,13 @@
h->xmlns = g_strdup(xmlns);
h->funcs = funcs;
-
+ h->method = method;
+
jingle_app_handlers = g_slist_append(jingle_app_handlers, h);
}
-void jingle_register_transport(const gchar *xmlns, JingleTransportFuncs *funcs)
+void jingle_register_transport(const gchar *xmlns, JingleTransportFuncs *funcs,
+ JingleTransType type, JingleTransMethod method)
{
if (!g_str_has_prefix(xmlns, NS_JINGLE_TRANSPORT_PREFIX)) return;
@@ -66,7 +72,9 @@
h->xmlns = g_strdup(xmlns);
h->funcs = funcs;
-
+ h->method = method;
+ h->type = type;
+
jingle_transport_handlers = g_slist_append(jingle_transport_handlers, h);
}
--- a/jingle/register.h Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle/register.h Tue Jul 13 12:56:45 2010 +0200
@@ -7,6 +7,15 @@
#define NS_JINGLE_APP_PREFIX "urn:xmpp:jingle:app:"
#define NS_JINGLE_TRANSPORT_PREFIX "urn:xmpp:jingle:transport:"
+typedef enum {
+ JINGLE_TRANS_IN_BAND,
+ JINGLE_TRANS_OUT_BAND,
+} JingleTransType;
+
+typedef enum {
+ JINGLE_TRANS_TCP,
+ JINGLE_TRANS_UDP,
+} JingleTransMethod;
typedef gconstpointer (*JingleAppCheck) (JingleContent *cn, GError **err);
typedef void (*JingleAppHandle) (JingleNode *jn, JingleContent *cn);
@@ -40,8 +49,10 @@
} JingleTransportFuncs;
-void jingle_register_app(const gchar *xmlns, JingleAppFuncs *funcs);
-void jingle_register_transport(const gchar *xmlns, JingleTransportFuncs *funcs);
+void jingle_register_app(const gchar *xmlns, JingleAppFuncs *funcs,
+ JingleTransMethod method);
+void jingle_register_transport(const gchar *xmlns, JingleTransportFuncs *funcs,
+ JingleTransType type, JingleTransMethod method);
JingleAppFuncs *jingle_get_appfuncs(const gchar *xmlns);
JingleTransportFuncs *jingle_get_transportfuncs(const gchar *xmlns);
void jingle_unregister_app(const gchar *xmlns);
--- a/jingle/send.c Sun Jul 11 20:37:04 2010 +0200
+++ b/jingle/send.c Tue Jul 13 12:56:45 2010 +0200
@@ -111,7 +111,8 @@
if (g_slist_length(accept.content) <= 0) return;
- accept.message = lm_message_from_jinglenode(&accept, lm_message_get_from(jn->message));
+ accept.message = lm_message_from_jinglenode(&accept,
+ lm_message_get_from(jn->message));
if (accept.message) {
elem->id = g_strdup(lm_message_get_id(accept.message));
elem->callback = NULL;