Create two subdirectories.
One will contain the main jingle module
and the other the file transfert app.
--- a/CMakeLists.txt Sun Jun 06 17:36:23 2010 +0200
+++ b/CMakeLists.txt Sun Jun 06 23:19:47 2010 +0200
@@ -30,24 +30,15 @@
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(LM REQUIRED loudmouth-1.0)
pkg_check_modules(MCABBER REQUIRED mcabber)
-link_directories(${GLIB_LIBRARY_DIRS}
- ${LM_LIBRARY_DIRS}
- ${MCABBER_LIBRARY_DIRS})
-
-## Target definitions
-add_library(jingle MODULE jingle.c check.c register.c)
+link_directories(${GLIB_LIBRARY_DIRS} ${MCABBER_LIBRARY_DIRS})
## Compiler setup
configure_file(config.h.in config.h)
-include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
- ${LM_INCLUDE_DIRS}
- ${MCABBER_INCLUDE_DIRS})
-target_link_libraries(jingle ${GLIB_LIBRARIES}
- ${LM_LIBRARIES}
- ${MCABBER_LIBRARIES})
-include_directories(${autoaway_SOURCE_DIR}
- ${autoaway_BINARY_DIR})
-set_target_properties(jingle PROPERTIES COMPILE_FLAGS "-Wall")
+include_directories(SYSTEM ${GLIB_INCLUDE_DIRS} ${MCABBER_INCLUDE_DIRS})
+
+## Target definitions
+add_subdirectory(jingle)
+add_subdirectory(jingle-filetransfert)
## Packaging information
set(CPACK_PACKAGE_NAME mcabber-jingle)
@@ -60,6 +51,3 @@
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so")
include(CPack)
-
-## Installation
-install(TARGETS jingle DESTINATION lib/mcabber)
--- a/action-handlers.c Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * action-handlers.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 <glib.h>
-
-#include "jingle.h"
-#include "check.h"
-
-void handle_session_initiate(LmMessage *m, JingleNode *jn, GError *err)
-{
- // do stuff here
-
-}
--- a/action-handlers.h Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#ifndef __JINGLE_ACTION_HANDLERS_H__
-#define __JINGLE_ACTION_HANDLERS_H__ 1
-
-#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
-
-void handle_session_initiate(LmMessage *m, LmMessageNode *j);
-
-#endif
--- a/check.c Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * check.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 <glib.h>
-#include <loudmouth/loudmouth.h>
-
-#include "check.h"
-#include "jingle.h"
-
-
-JingleContentNode *check_content(LmMessageNode *node, GError **err);
-gint index_in_array(const gchar *str, const gchar **array);
-
-
-
-const gchar *jingle_content_creator[] = {
- "initiator",
- "responder",
- NULL
-};
-
-const gchar *jingle_content_senders[] = {
- "both",
- "initiator",
- "none",
- "responder",
- NULL
-};
-
-
-/**
- * Populate a jingle_data struct from a <jingle> element.
- * Check if the element is in compliance with the XEP.
- */
-gboolean check_jingle(LmMessageNode *node, JingleNode *jn, GError **err)
-{
- //gint nb_reason = 0;
- LmMessageNode *child = NULL;
- const gchar *actionstr;
- JingleContentNode *cn;
-
- actionstr = lm_message_node_get_attribute(node, "action");
- jn->initiator = lm_message_node_get_attribute(node, "initiator");
- jn->responder = lm_message_node_get_attribute(node, "responder");
- jn->sid = lm_message_node_get_attribute(node, "sid");
-
- if (actionstr == NULL || jn->sid == NULL) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
- "an attribute of the jingle element is missing");
- return FALSE;
- }
-
- jn->action = jingle_action_from_str(actionstr);
- if (jn->action == JINGLE_UNKNOWN_ACTION) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
- "the action attribute is invalid");
- return FALSE;
- }
-
- /*for (child = node->children; child; child = child->next) {
- if (!g_strcmp0(child->name, "reason"))
- nb_reason++;
- }
-
- if (nb_reason > 1) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADELEM,
- "too many reason elements");
- return FALSE;
- }*/
-
- for (child = node->children; child; child = child->next) {
- if (!g_strcmp0(child->name, "content")) {
- cn = check_content(node, err);
- if(cn == NULL) {
- g_assert (*err != NULL);
- return FALSE;
- }
- jn->content = g_list_append(jn->content, cn);
- }
- }
-
- return TRUE;
-}
-
-JingleContentNode *check_content(LmMessageNode *node, GError **err)
-{
- JingleContentNode *cn = g_new0(JingleContentNode, 1);
- const gchar *creatorstr, *sendersstr;
- gint tmp, tmp2;
-
- creatorstr = lm_message_node_get_attribute(node, "action");
- cn->disposition = lm_message_node_get_attribute(node, "disposition");
- cn->name = lm_message_node_get_attribute(node, "name");
- sendersstr = lm_message_node_get_attribute(node, "senders");
-
- if (creatorstr == NULL || cn->name == NULL) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
- "an attribute of the content element is missing");
- g_free(cn);
- return NULL;
- }
-
- tmp = index_in_array(creatorstr, jingle_content_creator);
- tmp2 = index_in_array(sendersstr, jingle_content_senders);
- if (tmp < 0 || tmp2 < 0) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
- "the attribute creator or sender is invalid");
- g_free(cn);
- return NULL;
- }
- cn->creator = (JingleCreator)tmp;
- cn->senders = (JingleSenders)tmp2;
-
-
- cn->description = lm_message_node_get_child(node, "description");
- cn->transport = lm_message_node_get_child(node, "transport");
- if (cn->description == NULL || cn->transport == NULL) {
- g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
- "a child element of content is missing");
- g_free(cn);
- return NULL;
- }
-
- return cn;
-}
-
-gint index_in_array(const gchar *str, const gchar **array)
-{
- gint i;
- for (i = 0; array[i]; i++) {
- if (!g_strcmp0(array[i], str)) {
- return i;
- }
- }
- return -1;
-}
-
-GQuark jingle_check_error_quark()
-{
- return g_quark_from_string("JINGLE_CHECK_ERROR");
-}
--- a/check.h Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#ifndef __JINGLE_CHECK_H__
-#define __JINGLE_CHECK_H__ 1
-
-#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
-#include "jingle.h"
-
-#define JINGLE_CHECK_ERROR jingle_check_error_quark()
-
-
-typedef enum {
- JINGLE_CHECK_ERROR_MISSING, // an element or attribute is missing
- JINGLE_CHECK_ERROR_BADELEM, // an element is not where it is supposed to be
- JINGLE_CHECK_ERROR_BADVALUE // the value of an attribute is incorrect
-} JingleCheckError;
-
-
-int check_jingle(LmMessageNode* node, JingleNode *jd, GError **err);
-GQuark jingle_check_error_quark();
-
-#endif
--- a/config.h.in Sun Jun 06 17:36:23 2010 +0200
+++ b/config.h.in Sun Jun 06 23:19:47 2010 +0200
@@ -1,1 +1,2 @@
//#cmakedefine USE_LIBNAME
+#define PROJECT_VERSION "@PROJECT_VERSION@"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle-filetransfert/CMakeLists.txt Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,4 @@
+add_library(jingle-filetransfert MODULE filetransfert.c)
+set_target_properties(jingle-filetransfert PROPERTIES COMPILE_FLAGS "-Wall")
+include_directories(${CMAKE_SOURCE_DIR}/jingle)
+install(TARGETS jingle-filetransfert DESTINATION lib/mcabber)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle-filetransfert/filetransfert.c Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,55 @@
+/*
+ * filetransfert.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 <glib.h>
+
+#include <mcabber/modules.h>
+
+#include <jingle.h>
+
+
+static void jingleft_init(void);
+static void jingleft_uninit(void);
+
+
+const gchar *deps[] = { "jingle", NULL };
+
+module_info_t info_jingle_filetransfert = {
+ .branch = MCABBER_BRANCH,
+ .api = MCABBER_API_VERSION,
+ .version = MCABBER_VERSION,
+ .description = "Jingle File Transfert (XEP-0234)\n",
+ .requires = deps,
+ .init = jingleft_init,
+ .uninit = jingleft_uninit,
+ .next = NULL,
+};
+
+
+static void jingleft_init(void)
+{
+
+}
+
+static void jingleft_uninit(void)
+{
+
+}
--- a/jingle.c Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-/*
- * jingle.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 <glib.h>
-#include <loudmouth/loudmouth.h>
-
-#include <mcabber/xmpp.h>
-#include <mcabber/hooks.h>
-#include <mcabber/modules.h>
-#include <mcabber/logprint.h>
-#include <mcabber/xmpp_helper.h>
-#include <mcabber/xmpp_defines.h>
-
-#include "jingle.h"
-#include "check.h"
-#include "register.h"
-
-
-static void jingle_register_lm_handlers(void);
-static void jingle_unregister_lm_handlers(void);
-static guint jingle_connect_hh(const gchar *hname, hk_arg_t *args, gpointer ignore);
-static guint jingle_disconn_hh(const gchar *hname, hk_arg_t *args, gpointer ignore);
-static void jingle_init(void);
-static void jingle_uninit(void);
-
-
-static LmMessageHandler* jingle_iq_handler = NULL;
-static guint connect_hid = 0;
-static guint disconn_hid = 0;
-
-/**
- * Must be aligned with the values in JingleAction
- * for easy acces.
- */
-struct JingleActionList jingle_action_list[] = {
- { NULL, NULL }, // for JINGLE_UNKNOWN_ACTION
- { "content-accept", NULL },
- { "content-add", NULL },
- { "content-modify", NULL },
- { "content-reject", NULL },
- { "content-remove", NULL },
- { "description-info", NULL },
- { "security-info", NULL },
- { "session-accept", NULL },
- { "session-info", NULL },
- { "session-initiate", NULL },
- { "session-terminate", NULL },
- { "transport-accept", NULL },
- { "transport-info", NULL },
- { "transport-reject", NULL },
- { "transport-replace", NULL },
-};
-
-module_info_t info_jingle = {
- .branch = MCABBER_BRANCH,
- .api = MCABBER_API_VERSION,
- .version = MCABBER_VERSION,
- .description = "Main Jingle module,"
- " required for file transport, voip...\n",
- .requires = NULL,
- .init = jingle_init,
- .uninit = jingle_uninit,
- .next = NULL,
-};
-
-
-LmHandlerResult jingle_handle_iq(LmMessageHandler *handler,
- LmConnection *connection,
- LmMessage *message,
- gpointer user_data)
-{
- LmMessageSubType iqtype = lm_message_get_sub_type(message);
- if (iqtype != LM_MESSAGE_SUB_TYPE_SET)
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-
- JingleNode *jn = g_new0(JingleNode, 1);
- GError *error;
- LmMessageNode *root = lm_message_get_node(message)->children;
- LmMessageNode *node = lm_message_node_get_child(root, "jingle");
-
- if (!node) // no <jingle> element found
- return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-
- if (g_strcmp0(lm_message_node_get_attribute(node, "xmlns"), NS_JINGLE)) {
- scr_log_print(LPRINT_DEBUG, "jingle: Received a jingle IQ with an invalid namespace");
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
- }
-
- check_jingle(node, jn, &error);
- if (error != NULL) {
- if (error->code == JINGLE_CHECK_ERROR) {
- // request malformed, we reply with a bad-request
- jingle_send_iq_error(message, "cancel", "bad-request", NULL);
- }
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
- }
-
- scr_log_print(LPRINT_DEBUG, "jingle: Received a valid jingle IQ");
-
- if (jingle_action_list[jn->action].handler != NULL)
- jingle_action_list[jn->action].handler(message, jn, &error);
- else
- jingle_send_iq_error(message, "cancel", "feature-not-implemented",
- "unsupported-info");
-
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-}
-
-/**
- * According to the specifications:
- * "An entity that receives an IQ request of type "get" or "set" MUST
- * reply with an IQ response of type "result" or "error"."
- * For Jingle's IQ, we have to reply with an empty "result" IQ to acknowledge
- * receipt.
- */
-void jingle_ack_iq(LmMessage *m)
-{
- LmMessage *r;
-
- r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
- lm_connection_send(lconnection, r, NULL);
- lm_message_unref(r);
-}
-
-/**
- * Reply to a Jingle IQ with an error.
- */
-LmMessage *jingle_new_iq_error(LmMessage *m, const gchar *errtype,
- const gchar *cond, const gchar *jinglecond)
-{
- LmMessage *r;
- LmMessageNode *err, *tmpnode;
-
- r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_ERROR);
- err = lm_message_node_add_child(r->node, "error", NULL);
- lm_message_node_set_attribute(err, "type", errtype);
-
- // error condition as defined by RFC 3920bis section 8.3.3
- if (cond != NULL) {
- tmpnode = lm_message_node_add_child(err, cond, NULL);
- lm_message_node_set_attribute(tmpnode, "xmlns", NS_XMPP_STANZAS);
- }
-
- // jingle error condition as defined by XEP-0166 section 10
- if (jinglecond != NULL) {
- tmpnode = lm_message_node_add_child(err, jinglecond, NULL);
- lm_message_node_set_attribute(tmpnode, "xmlns", NS_JINGLE_ERRORS);
- }
-
- return r;
-}
-
-void jingle_send_iq_error(LmMessage *m, const gchar *errtype,
- const gchar *cond, const gchar *jinglecond)
-{
- LmMessage *r = jingle_new_iq_error(m, errtype, cond, jinglecond);
- if (r) {
- lm_connection_send(lconnection, r, NULL);
- lm_message_unref(r);
- }
-}
-
-/**
- * Find the jingle_action corresponding to a string
- */
-JingleAction jingle_action_from_str(const gchar* string)
-{
- guint i, actstrlen = sizeof(jingle_action_list)/sizeof(jingle_action_list[0]);
- for (i = 0; i < actstrlen; i++)
- if (!g_strcmp0(jingle_action_list[i].name, string))
- return (JingleAction) i;
-
- return JINGLE_UNKNOWN_ACTION;
-}
-
-static void jingle_unregister_lm_handlers(void)
-{
- if (lconnection) {
- lm_connection_unregister_message_handler(lconnection, jingle_iq_handler,
- LM_MESSAGE_TYPE_IQ);
- }
-}
-
-static void jingle_register_lm_handlers(void)
-{
- jingle_unregister_lm_handlers();
- if (lconnection) {
- lm_connection_register_message_handler(lconnection, jingle_iq_handler,
- LM_MESSAGE_TYPE_IQ,
- LM_HANDLER_PRIORITY_FIRST);
- }
-}
-
-static guint jingle_connect_hh(const gchar *hname, hk_arg_t *args, gpointer ignore)
-{
- jingle_register_lm_handlers();
- return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-}
-
-static guint jingle_disconn_hh(const gchar *hname, hk_arg_t *args, gpointer ignore)
-{
- jingle_unregister_lm_handlers();
- return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
-}
-
-static void jingle_init(void)
-{
- jingle_iq_handler = lm_message_handler_new(jingle_handle_iq, NULL, NULL);
- xmpp_add_feature(NS_JINGLE);
-
- connect_hid = hk_add_handler(jingle_connect_hh, HOOK_POST_CONNECT,
- G_PRIORITY_DEFAULT_IDLE, NULL);
- disconn_hid = hk_add_handler(jingle_disconn_hh, HOOK_PRE_DISCONNECT,
- G_PRIORITY_DEFAULT_IDLE, NULL);
- jingle_register_lm_handlers();
-}
-
-static void jingle_uninit(void)
-{
- xmpp_del_feature(NS_JINGLE);
-
- hk_del_handler(HOOK_POST_CONNECT, connect_hid);
- hk_del_handler(HOOK_PRE_DISCONNECT, disconn_hid);
- jingle_unregister_lm_handlers();
-
- lm_message_handler_invalidate(jingle_iq_handler);
- lm_message_handler_unref(jingle_iq_handler);
-}
--- a/jingle.h Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-#ifndef __JINGLE_H__
-#define __JINGLE_H__ 1
-
-#include <glib.h>
-#include <loudmouth/loudmouth.h>
-
-#define NS_JINGLE "urn:xmpp:jingle:1"
-#define NS_JINGLE_ERRORS "urn:xmpp:jingle:errors:1"
-
-
-typedef enum {
- JINGLE_UNKNOWN_ACTION,
- JINGLE_CONTENT_ACCEPT,
- JINGLE_CONTENT_ADD,
- JINGLE_CONTENT_MODIFY,
- JINGLE_CONTENT_REJECT,
- JINGLE_CONTENT_REMOVE,
- JINGLE_DESCRIPTION_INFO,
- JINGLE_SECURITY_INFO,
- JINGLE_SESSION_ACCEPT,
- JINGLE_SESSION_INFO,
- JINGLE_SESSION_INITIATE,
- JINGLE_SESSION_TERMINATE,
- JINGLE_TRANSPORT_ACCEPT,
- JINGLE_TRANSPORT_INFO,
- JINGLE_TRANSPORT_REJECT,
- JINGLE_TRANSPORT_REPLACE,
-} JingleAction;
-
-typedef enum {
- JINGLE_CREATOR_INITIATOR,
- JINGLE_CREATOR_RESPONDER,
-} JingleCreator;
-
-typedef enum {
- JINGLE_SENDERS_BOTH,
- JINGLE_SENDERS_INITIATOR,
- JINGLE_SENDERS_NONE,
- JINGLE_SENDERS_RESPONDER,
-} JingleSenders;
-
-typedef struct {
- /* action attribute */
- JingleAction action;
-
- /* full JID of the entity that has initiated the session flow.
- * may be different from the 'from' address on the IQ-set of the
- * session-initiate message.
- * recommended for session-initiate, not recommended otherwise. */
- const gchar *initiator;
-
- /* full JID of the entity that has replied to the initation.
- * can be different from the 'to' address on the IQ-set.
- * recommended for session-accept, not recommended otherwise. */
- const gchar *responder;
-
- /* Random session identifier generated by the initator. */
- const gchar *sid;
-
- /* Doubly-linked list of JingleContentNode. */
- GList *content;
-
-} JingleNode;
-
-typedef struct {
- /* which party originally generated the content type.
- * the defined values are "initiator" and "responder"
- * (where the default is "initiator"). required. */
- JingleCreator creator;
-
- /* how the content definition is to be interpreted by the recipient.
- * optional, the default value is "session". */
- const gchar *disposition; // optional, default=session
-
- /* A unique name or identifier for the content type
- * according to the creator. required.*/
- const gchar *name;
-
- /* which parties in the session will be generating content.
- * allowable values are both, initiator, none, responder.
- * default is both.
- * required for content-modify, optional otherwise */
- JingleSenders senders;
-
- /* each content element (must) contain one description
- * child element that specifies a desired application.
- * the content of this node is app specific. */
- LmMessageNode *description;
-
- /* each content element (must) contain one transport
- * child element that specifies a potential transport
- * method */
- LmMessageNode *transport;
-
-} JingleContentNode;
-
-struct JingleActionList {
- const gchar *name;
- void (*handler)(LmMessage *, JingleNode *, GError **);
-};
-
-
-LmMessage *jingle_new_iq_error(LmMessage *m, const gchar *errtype,
- const gchar *cond, const gchar *jinglecond);
-void jingle_send_iq_error(LmMessage *m, const gchar *errtype,
- const gchar *cond, const gchar *jinglecond);
-void jingle_ack_iq(LmMessage *m);
-JingleAction jingle_action_from_str(const gchar* string);
-
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/CMakeLists.txt Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,5 @@
+add_library(jingle MODULE jingle.c check.c register.c)
+set_target_properties(jingle PROPERTIES COMPILE_FLAGS "-Wall")
+include_directories(${LM_INCLUDE_DIRS})
+target_link_libraries(jingle ${LM_LIBRARIES})
+install(TARGETS jingle DESTINATION lib/mcabber)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/action-handlers.c Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,31 @@
+/*
+ * action-handlers.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 <glib.h>
+
+#include "jingle.h"
+#include "check.h"
+
+void handle_session_initiate(LmMessage *m, JingleNode *jn, GError *err)
+{
+ // do stuff here
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/action-handlers.h Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,10 @@
+#ifndef __JINGLE_ACTION_HANDLERS_H__
+#define __JINGLE_ACTION_HANDLERS_H__ 1
+
+#include <glib.h>
+#include <loudmouth/loudmouth.h>
+
+
+void handle_session_initiate(LmMessage *m, LmMessageNode *j);
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/check.c Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,159 @@
+/*
+ * check.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 <glib.h>
+#include <loudmouth/loudmouth.h>
+
+#include "check.h"
+#include "jingle.h"
+
+
+JingleContentNode *check_content(LmMessageNode *node, GError **err);
+gint index_in_array(const gchar *str, const gchar **array);
+
+
+
+const gchar *jingle_content_creator[] = {
+ "initiator",
+ "responder",
+ NULL
+};
+
+const gchar *jingle_content_senders[] = {
+ "both",
+ "initiator",
+ "none",
+ "responder",
+ NULL
+};
+
+
+/**
+ * Populate a jingle_data struct from a <jingle> element.
+ * Check if the element is in compliance with the XEP.
+ */
+gboolean check_jingle(LmMessageNode *node, JingleNode *jn, GError **err)
+{
+ //gint nb_reason = 0;
+ LmMessageNode *child = NULL;
+ const gchar *actionstr;
+ JingleContentNode *cn;
+
+ actionstr = lm_message_node_get_attribute(node, "action");
+ jn->initiator = lm_message_node_get_attribute(node, "initiator");
+ jn->responder = lm_message_node_get_attribute(node, "responder");
+ jn->sid = lm_message_node_get_attribute(node, "sid");
+
+ if (actionstr == NULL || jn->sid == NULL) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
+ "an attribute of the jingle element is missing");
+ return FALSE;
+ }
+
+ jn->action = jingle_action_from_str(actionstr);
+ if (jn->action == JINGLE_UNKNOWN_ACTION) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
+ "the action attribute is invalid");
+ return FALSE;
+ }
+
+ /*for (child = node->children; child; child = child->next) {
+ if (!g_strcmp0(child->name, "reason"))
+ nb_reason++;
+ }
+
+ if (nb_reason > 1) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADELEM,
+ "too many reason elements");
+ return FALSE;
+ }*/
+
+ for (child = node->children; child; child = child->next) {
+ if (!g_strcmp0(child->name, "content")) {
+ cn = check_content(node, err);
+ if(cn == NULL) {
+ g_assert (*err != NULL);
+ return FALSE;
+ }
+ jn->content = g_list_append(jn->content, cn);
+ }
+ }
+
+ return TRUE;
+}
+
+JingleContentNode *check_content(LmMessageNode *node, GError **err)
+{
+ JingleContentNode *cn = g_new0(JingleContentNode, 1);
+ const gchar *creatorstr, *sendersstr;
+ gint tmp, tmp2;
+
+ creatorstr = lm_message_node_get_attribute(node, "action");
+ cn->disposition = lm_message_node_get_attribute(node, "disposition");
+ cn->name = lm_message_node_get_attribute(node, "name");
+ sendersstr = lm_message_node_get_attribute(node, "senders");
+
+ if (creatorstr == NULL || cn->name == NULL) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
+ "an attribute of the content element is missing");
+ g_free(cn);
+ return NULL;
+ }
+
+ tmp = index_in_array(creatorstr, jingle_content_creator);
+ tmp2 = index_in_array(sendersstr, jingle_content_senders);
+ if (tmp < 0 || tmp2 < 0) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
+ "the attribute creator or sender is invalid");
+ g_free(cn);
+ return NULL;
+ }
+ cn->creator = (JingleCreator)tmp;
+ cn->senders = (JingleSenders)tmp2;
+
+
+ cn->description = lm_message_node_get_child(node, "description");
+ cn->transport = lm_message_node_get_child(node, "transport");
+ if (cn->description == NULL || cn->transport == NULL) {
+ g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
+ "a child element of content is missing");
+ g_free(cn);
+ return NULL;
+ }
+
+ return cn;
+}
+
+gint index_in_array(const gchar *str, const gchar **array)
+{
+ gint i;
+ for (i = 0; array[i]; i++) {
+ if (!g_strcmp0(array[i], str)) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+GQuark jingle_check_error_quark()
+{
+ return g_quark_from_string("JINGLE_CHECK_ERROR");
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/check.h Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,22 @@
+#ifndef __JINGLE_CHECK_H__
+#define __JINGLE_CHECK_H__ 1
+
+#include <glib.h>
+#include <loudmouth/loudmouth.h>
+
+#include "jingle.h"
+
+#define JINGLE_CHECK_ERROR jingle_check_error_quark()
+
+
+typedef enum {
+ JINGLE_CHECK_ERROR_MISSING, // an element or attribute is missing
+ JINGLE_CHECK_ERROR_BADELEM, // an element is not where it is supposed to be
+ JINGLE_CHECK_ERROR_BADVALUE // the value of an attribute is incorrect
+} JingleCheckError;
+
+
+int check_jingle(LmMessageNode* node, JingleNode *jd, GError **err);
+GQuark jingle_check_error_quark();
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/jingle.c Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,246 @@
+/*
+ * jingle.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 <glib.h>
+#include <loudmouth/loudmouth.h>
+
+#include <mcabber/xmpp.h>
+#include <mcabber/hooks.h>
+#include <mcabber/modules.h>
+#include <mcabber/logprint.h>
+#include <mcabber/xmpp_helper.h>
+#include <mcabber/xmpp_defines.h>
+
+#include "jingle.h"
+#include "check.h"
+#include "register.h"
+
+
+static void jingle_register_lm_handlers(void);
+static void jingle_unregister_lm_handlers(void);
+static guint jingle_connect_hh(const gchar *hname, hk_arg_t *args, gpointer ignore);
+static guint jingle_disconn_hh(const gchar *hname, hk_arg_t *args, gpointer ignore);
+static void jingle_init(void);
+static void jingle_uninit(void);
+
+
+static LmMessageHandler* jingle_iq_handler = NULL;
+static guint connect_hid = 0;
+static guint disconn_hid = 0;
+
+/**
+ * Must be aligned with the values in JingleAction
+ * for easy acces.
+ */
+struct JingleActionList jingle_action_list[] = {
+ { NULL, NULL }, // for JINGLE_UNKNOWN_ACTION
+ { "content-accept", NULL },
+ { "content-add", NULL },
+ { "content-modify", NULL },
+ { "content-reject", NULL },
+ { "content-remove", NULL },
+ { "description-info", NULL },
+ { "security-info", NULL },
+ { "session-accept", NULL },
+ { "session-info", NULL },
+ { "session-initiate", NULL },
+ { "session-terminate", NULL },
+ { "transport-accept", NULL },
+ { "transport-info", NULL },
+ { "transport-reject", NULL },
+ { "transport-replace", NULL },
+};
+
+module_info_t info_jingle = {
+ .branch = MCABBER_BRANCH,
+ .api = MCABBER_API_VERSION,
+ .version = MCABBER_VERSION,
+ .description = "Main Jingle module,"
+ " required for file transport, voip...\n",
+ .requires = NULL,
+ .init = jingle_init,
+ .uninit = jingle_uninit,
+ .next = NULL,
+};
+
+
+LmHandlerResult jingle_handle_iq(LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessageSubType iqtype = lm_message_get_sub_type(message);
+ if (iqtype != LM_MESSAGE_SUB_TYPE_SET)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ JingleNode *jn = g_new0(JingleNode, 1);
+ GError *error;
+ LmMessageNode *root = lm_message_get_node(message)->children;
+ LmMessageNode *node = lm_message_node_get_child(root, "jingle");
+
+ if (!node) // no <jingle> element found
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ if (g_strcmp0(lm_message_node_get_attribute(node, "xmlns"), NS_JINGLE)) {
+ scr_log_print(LPRINT_DEBUG, "jingle: Received a jingle IQ with an invalid namespace");
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ check_jingle(node, jn, &error);
+ if (error != NULL) {
+ if (error->code == JINGLE_CHECK_ERROR) {
+ // request malformed, we reply with a bad-request
+ jingle_send_iq_error(message, "cancel", "bad-request", NULL);
+ }
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ scr_log_print(LPRINT_DEBUG, "jingle: Received a valid jingle IQ");
+
+ if (jingle_action_list[jn->action].handler != NULL)
+ jingle_action_list[jn->action].handler(message, jn, &error);
+ else
+ jingle_send_iq_error(message, "cancel", "feature-not-implemented",
+ "unsupported-info");
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+/**
+ * According to the specifications:
+ * "An entity that receives an IQ request of type "get" or "set" MUST
+ * reply with an IQ response of type "result" or "error"."
+ * For Jingle's IQ, we have to reply with an empty "result" IQ to acknowledge
+ * receipt.
+ */
+void jingle_ack_iq(LmMessage *m)
+{
+ LmMessage *r;
+
+ r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
+ lm_connection_send(lconnection, r, NULL);
+ lm_message_unref(r);
+}
+
+/**
+ * Reply to a Jingle IQ with an error.
+ */
+LmMessage *jingle_new_iq_error(LmMessage *m, const gchar *errtype,
+ const gchar *cond, const gchar *jinglecond)
+{
+ LmMessage *r;
+ LmMessageNode *err, *tmpnode;
+
+ r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_ERROR);
+ err = lm_message_node_add_child(r->node, "error", NULL);
+ lm_message_node_set_attribute(err, "type", errtype);
+
+ // error condition as defined by RFC 3920bis section 8.3.3
+ if (cond != NULL) {
+ tmpnode = lm_message_node_add_child(err, cond, NULL);
+ lm_message_node_set_attribute(tmpnode, "xmlns", NS_XMPP_STANZAS);
+ }
+
+ // jingle error condition as defined by XEP-0166 section 10
+ if (jinglecond != NULL) {
+ tmpnode = lm_message_node_add_child(err, jinglecond, NULL);
+ lm_message_node_set_attribute(tmpnode, "xmlns", NS_JINGLE_ERRORS);
+ }
+
+ return r;
+}
+
+void jingle_send_iq_error(LmMessage *m, const gchar *errtype,
+ const gchar *cond, const gchar *jinglecond)
+{
+ LmMessage *r = jingle_new_iq_error(m, errtype, cond, jinglecond);
+ if (r) {
+ lm_connection_send(lconnection, r, NULL);
+ lm_message_unref(r);
+ }
+}
+
+/**
+ * Find the jingle_action corresponding to a string
+ */
+JingleAction jingle_action_from_str(const gchar* string)
+{
+ guint i, actstrlen = sizeof(jingle_action_list)/sizeof(jingle_action_list[0]);
+ for (i = 0; i < actstrlen; i++)
+ if (!g_strcmp0(jingle_action_list[i].name, string))
+ return (JingleAction) i;
+
+ return JINGLE_UNKNOWN_ACTION;
+}
+
+static void jingle_unregister_lm_handlers(void)
+{
+ if (lconnection) {
+ lm_connection_unregister_message_handler(lconnection, jingle_iq_handler,
+ LM_MESSAGE_TYPE_IQ);
+ }
+}
+
+static void jingle_register_lm_handlers(void)
+{
+ jingle_unregister_lm_handlers();
+ if (lconnection) {
+ lm_connection_register_message_handler(lconnection, jingle_iq_handler,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_FIRST);
+ }
+}
+
+static guint jingle_connect_hh(const gchar *hname, hk_arg_t *args, gpointer ignore)
+{
+ jingle_register_lm_handlers();
+ return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+static guint jingle_disconn_hh(const gchar *hname, hk_arg_t *args, gpointer ignore)
+{
+ jingle_unregister_lm_handlers();
+ return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+static void jingle_init(void)
+{
+ jingle_iq_handler = lm_message_handler_new(jingle_handle_iq, NULL, NULL);
+ xmpp_add_feature(NS_JINGLE);
+
+ connect_hid = hk_add_handler(jingle_connect_hh, HOOK_POST_CONNECT,
+ G_PRIORITY_DEFAULT_IDLE, NULL);
+ disconn_hid = hk_add_handler(jingle_disconn_hh, HOOK_PRE_DISCONNECT,
+ G_PRIORITY_DEFAULT_IDLE, NULL);
+ jingle_register_lm_handlers();
+}
+
+static void jingle_uninit(void)
+{
+ xmpp_del_feature(NS_JINGLE);
+
+ hk_del_handler(HOOK_POST_CONNECT, connect_hid);
+ hk_del_handler(HOOK_PRE_DISCONNECT, disconn_hid);
+ jingle_unregister_lm_handlers();
+
+ lm_message_handler_invalidate(jingle_iq_handler);
+ lm_message_handler_unref(jingle_iq_handler);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/jingle.h Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,110 @@
+#ifndef __JINGLE_H__
+#define __JINGLE_H__ 1
+
+#include <glib.h>
+#include <loudmouth/loudmouth.h>
+
+#define NS_JINGLE "urn:xmpp:jingle:1"
+#define NS_JINGLE_ERRORS "urn:xmpp:jingle:errors:1"
+
+
+typedef enum {
+ JINGLE_UNKNOWN_ACTION,
+ JINGLE_CONTENT_ACCEPT,
+ JINGLE_CONTENT_ADD,
+ JINGLE_CONTENT_MODIFY,
+ JINGLE_CONTENT_REJECT,
+ JINGLE_CONTENT_REMOVE,
+ JINGLE_DESCRIPTION_INFO,
+ JINGLE_SECURITY_INFO,
+ JINGLE_SESSION_ACCEPT,
+ JINGLE_SESSION_INFO,
+ JINGLE_SESSION_INITIATE,
+ JINGLE_SESSION_TERMINATE,
+ JINGLE_TRANSPORT_ACCEPT,
+ JINGLE_TRANSPORT_INFO,
+ JINGLE_TRANSPORT_REJECT,
+ JINGLE_TRANSPORT_REPLACE,
+} JingleAction;
+
+typedef enum {
+ JINGLE_CREATOR_INITIATOR,
+ JINGLE_CREATOR_RESPONDER,
+} JingleCreator;
+
+typedef enum {
+ JINGLE_SENDERS_BOTH,
+ JINGLE_SENDERS_INITIATOR,
+ JINGLE_SENDERS_NONE,
+ JINGLE_SENDERS_RESPONDER,
+} JingleSenders;
+
+typedef struct {
+ /* action attribute */
+ JingleAction action;
+
+ /* full JID of the entity that has initiated the session flow.
+ * may be different from the 'from' address on the IQ-set of the
+ * session-initiate message.
+ * recommended for session-initiate, not recommended otherwise. */
+ const gchar *initiator;
+
+ /* full JID of the entity that has replied to the initation.
+ * can be different from the 'to' address on the IQ-set.
+ * recommended for session-accept, not recommended otherwise. */
+ const gchar *responder;
+
+ /* Random session identifier generated by the initator. */
+ const gchar *sid;
+
+ /* Doubly-linked list of JingleContentNode. */
+ GList *content;
+
+} JingleNode;
+
+typedef struct {
+ /* which party originally generated the content type.
+ * the defined values are "initiator" and "responder"
+ * (where the default is "initiator"). required. */
+ JingleCreator creator;
+
+ /* how the content definition is to be interpreted by the recipient.
+ * optional, the default value is "session". */
+ const gchar *disposition; // optional, default=session
+
+ /* A unique name or identifier for the content type
+ * according to the creator. required.*/
+ const gchar *name;
+
+ /* which parties in the session will be generating content.
+ * allowable values are both, initiator, none, responder.
+ * default is both.
+ * required for content-modify, optional otherwise */
+ JingleSenders senders;
+
+ /* each content element (must) contain one description
+ * child element that specifies a desired application.
+ * the content of this node is app specific. */
+ LmMessageNode *description;
+
+ /* each content element (must) contain one transport
+ * child element that specifies a potential transport
+ * method */
+ LmMessageNode *transport;
+
+} JingleContentNode;
+
+struct JingleActionList {
+ const gchar *name;
+ void (*handler)(LmMessage *, JingleNode *, GError **);
+};
+
+
+LmMessage *jingle_new_iq_error(LmMessage *m, const gchar *errtype,
+ const gchar *cond, const gchar *jinglecond);
+void jingle_send_iq_error(LmMessage *m, const gchar *errtype,
+ const gchar *cond, const gchar *jinglecond);
+void jingle_ack_iq(LmMessage *m);
+JingleAction jingle_action_from_str(const gchar* string);
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/register.c Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,66 @@
+/*
+ * register.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 <glib.h>
+
+#include <mcabber/logprint.h>
+
+#include "jingle.h"
+
+GHashTable *hk_jingle_apps_handler_hash = NULL;
+GHashTable *hk_jingle_transports_handler_hash = NULL;
+
+gchar* jingle_register_apps(const gchar* namespace)
+{
+ gchar* hookname = NULL;
+
+ if (!hk_jingle_apps_handler_hash) {
+ hk_jingle_apps_handler_hash = g_hash_table_new_full(&g_str_hash, &g_str_equal, &g_free, &g_free);
+ if (!hk_jingle_apps_handler_hash) {
+ scr_log_print(LPRINT_LOGNORM, "Couldn't create hook hash table for jingle apps!");
+ return NULL;
+ }
+ }
+
+ hookname = g_strdup_printf("%s%s", "hook_jingle_apps_", namespace);
+
+ g_hash_table_insert(hk_jingle_apps_handler_hash, g_strdup(namespace), hookname);
+
+ return hookname;
+}
+
+gchar* jingle_register_transports(const gchar* namespace) {
+ gchar* hookname = NULL;
+
+ if (!hk_jingle_transports_handler_hash) {
+ hk_jingle_transports_handler_hash = g_hash_table_new_full(&g_str_hash, &g_str_equal, &g_free, &g_free);
+ if (!hk_jingle_transports_handler_hash) {
+ scr_log_print(LPRINT_LOGNORM, "Couldn't create hook hash table for jingle transports!");
+ return NULL;
+ }
+ }
+
+ hookname = g_strdup_printf("%s%s", "hook_jingle_transports_", namespace);
+
+ g_hash_table_insert(hk_jingle_transports_handler_hash, g_strdup(namespace), hookname);
+
+ return hookname;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jingle/register.h Sun Jun 06 23:19:47 2010 +0200
@@ -0,0 +1,7 @@
+#ifndef __JINGLE_REGISTER_H__
+#define __JINGLE_REGISTER_H__
+
+gchar* jingle_resigter_apps(const gchar* namespace);
+gchar* jingle_register_transports(const gchar* namespace);
+
+#endif
--- a/register.c Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * register.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 <glib.h>
-
-#include <mcabber/logprint.h>
-
-#include "jingle.h"
-
-GHashTable *hk_jingle_apps_handler_hash = NULL;
-GHashTable *hk_jingle_transports_handler_hash = NULL;
-
-gchar* jingle_register_apps(const gchar* namespace)
-{
- gchar* hookname = NULL;
-
- if (!hk_jingle_apps_handler_hash) {
- hk_jingle_apps_handler_hash = g_hash_table_new_full(&g_str_hash, &g_str_equal, &g_free, &g_free);
- if (!hk_jingle_apps_handler_hash) {
- scr_log_print(LPRINT_LOGNORM, "Couldn't create hook hash table for jingle apps!");
- return NULL;
- }
- }
-
- hookname = g_strdup_printf("%s%s", "hook_jingle_apps_", namespace);
-
- g_hash_table_insert(hk_jingle_apps_handler_hash, g_strdup(namespace), hookname);
-
- return hookname;
-}
-
-gchar* jingle_register_transports(const gchar* namespace) {
- gchar* hookname = NULL;
-
- if (!hk_jingle_transports_handler_hash) {
- hk_jingle_transports_handler_hash = g_hash_table_new_full(&g_str_hash, &g_str_equal, &g_free, &g_free);
- if (!hk_jingle_transports_handler_hash) {
- scr_log_print(LPRINT_LOGNORM, "Couldn't create hook hash table for jingle transports!");
- return NULL;
- }
- }
-
- hookname = g_strdup_printf("%s%s", "hook_jingle_transports_", namespace);
-
- g_hash_table_insert(hk_jingle_transports_handler_hash, g_strdup(namespace), hookname);
-
- return hookname;
-}
--- a/register.h Sun Jun 06 17:36:23 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#ifndef __JINGLE_REGISTER_H__
-#define __JINGLE_REGISTER_H__
-
-gchar* jingle_resigter_apps(const gchar* namespace);
-gchar* jingle_register_transports(const gchar* namespace);
-
-#endif