--- a/CMakeLists.txt Tue May 25 00:40:38 2010 +0200
+++ b/CMakeLists.txt Tue May 25 05:52:04 2010 +0200
@@ -1,5 +1,4 @@
## Copyright 2010 Cornu Nicolas
-# This file is part of mcabber module writing howto examples.
#
# Examples are free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,59 +14,52 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.6)
-project(Notify)
+project(mcabber-jingle C)
set(PROJECT_VERSION "0.0.1")
## User settable options
+#option(USE_LIBNAME "Option Description")
+#if(USE_LIBNAME)
+#
+#else(USE_LIBNAME)
+#
+#endif(USE_LIBNAME)
## Check for build dependencies
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(GLIB REQUIRED glib-2.0)
-pkg_check_modules(GTK REQUIRED gtk+-2.0)
-pkg_check_modules(LM REQUIRED loudmouth-1.0)
+find_package(PkgConfig REQUIRED)
+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}
- ${GTK_LIBRARY_DIRS})
+ ${MCABBER_LIBRARY_DIRS})
## Target definitions
-add_library(jingle MODULE jingle.c)
+add_library(jingle MODULE jingle.c)
## Compiler setup
-#configure_file(config.h.in config.h)
-include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
+configure_file(config.h.in config.h)
+include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
${LM_INCLUDE_DIRS}
- ${MCABBER_INCLUDE_DIRS}
- ${GTK_INCLUDE_DIRS})
-target_link_libraries(jingle ${GLIB_LIBRARIES}
+ ${MCABBER_INCLUDE_DIRS})
+target_link_libraries(jingle ${GLIB_LIBRARIES}
${LM_LIBRARIES}
- ${MCABBER_LIBRARIES}
- ${GTK_LIBRARIES}
- )
-include_directories(${notify_SOURCE_DIR}
- ${notify_BINARY_DIR})
+ ${MCABBER_LIBRARIES})
+include_directories(${autoaway_SOURCE_DIR}
+ ${autoaway_BINARY_DIR})
set_target_properties(jingle PROPERTIES COMPILE_FLAGS "-Wall")
## Packaging information
-set(CPACK_PACKAGE_NAME libmcabber-jingle)
+set(CPACK_PACKAGE_NAME mcabber-jingle)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "alkino")
set(CPACK_PACKAGE_CONTACT "Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Some notification for Mcabber")
-#set(CPACK_RESOURCE_FILE_LICENSE ${notify_SOURCE_DIR}/COPYING)
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Base jingle functions")
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_GENERATOR DEB CACHE TEXT "Binary package generator, eg DEB, RPM, TGZ, NSIS...")
-set(CPACK_DEBIAN_PACKAGE_SECTION libs)
-find_program(DPKG_EXECUTABLE dpkg)
-if(DPKG_EXECUTABLE)
- execute_process(COMMAND ${DPKG_EXECUTABLE} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
-else()
- set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 CACHE TEXT "Architecture of package")
-endif()
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)
+install(TARGETS jingle DESTINATION lib/mcabber)
--- a/jingle.c Tue May 25 00:40:38 2010 +0200
+++ b/jingle.c Tue May 25 05:52:04 2010 +0200
@@ -1,7 +1,7 @@
/*
- * pep.c -- Common pep routines
+ * jingle.c -- Base jingle functions
*
- * Copyrigth (C) 2009 Myhailo Danylenko <isbear@ukrpost.net>
+ * 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
@@ -28,122 +28,129 @@
#include <mcabber/modules.h>
#include <mcabber/logprint.h>
-#define NS_JINGLE "urn:xmpp:jingle:1"
+#include "jingle.h"
+
+
+static void mcjingle_init (void);
+static void mcjingle_uninit(void);
+
struct info_iq {
const gchar *from, *to, *type, *id;
};
+
struct info_jingle {
const gchar *xmlns, *action, *initiator, *sid;
};
-static void mcjingle_init (void);
-static void mcjingle_uninit (void);
-
-void parse_iq (LmMessageNode *iq, struct info_iq *ii) {
- if(!strcmp(iq->name, "iq")) {
- ii->to = ii->from = ii->type = ii->id = NULL;
- return;
- }
- ii->from = lm_message_node_get_attribute (iq, "from");
- ii->to = lm_message_node_get_attribute (iq, "to");
- ii->type = lm_message_node_get_attribute (iq, "type");
- ii->id = lm_message_node_get_attribute (iq, "id");
-}
-void parse_jingle (LmMessageNode *jingle, struct info_jingle *ij) {
- if(!strcmp(ij->name, "jingle")) {
- ij->to = ij->from = ij->type = ij->id = NULL;
- return;
- }
+LmMessageHandler* jingle_iq_handler = NULL;
- ii->from = lm_message_node_get_attribute (iq, "from");
- ii->to = lm_message_node_get_attribute (iq, "to");
- ii->type = lm_message_node_get_attribute (iq, "type");
- ii->id = lm_message_node_get_attribute (iq, "id");
-}
-
-
-LmMessageHandler* lm = NULL;
module_info_t info_jingle = {
.branch = MCABBER_BRANCH,
.api = MCABBER_API_VERSION,
.version = MCABBER_VERSION,
- .description = "A module for jingle",
+ .description = "Main Jingle module\n"
+ " required for file transport, voip...\n",
.requires = NULL,
.init = mcjingle_init,
.uninit = mcjingle_uninit,
.next = NULL,
};
-LmHandlerResult gestionnaire_lm(LmMessageHandler *handler,
- LmConnection *connection, LmMessage *message,
- gpointer user_data)
+
+void parse_iq(LmMessageNode *iq, struct info_iq *ii)
+{
+ if (!strcmp(iq->name, "iq")) {
+ ii->to = ii->from = ii->type = ii->id = NULL;
+ return;
+ }
+
+ ii->from = lm_message_node_get_attribute(iq, "from");
+ ii->to = lm_message_node_get_attribute(iq, "to");
+ ii->type = lm_message_node_get_attribute(iq, "type");
+ ii->id = lm_message_node_get_attribute(iq, "id");
+}
+
+void parse_jingle(LmMessageNode *jingle, struct info_jingle *ij)
{
- LmMessageNode * test = lm_message_get_node(message)->children;
+ if (!strcmp(ij->name, "jingle")) {
+ ij->to = ij->from = ij->type = ij->id = NULL;
+ return;
+ }
+
+ ii->from = lm_message_node_get_attribute(iq, "from");
+ ii->to = lm_message_node_get_attribute(iq, "to");
+ ii->type = lm_message_node_get_attribute(iq, "type");
+ ii->id = lm_message_node_get_attribute(iq, "id");
+}
+
+LmHandlerResult jingle_iq_event_handler(LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessageNode *test = lm_message_get_node(message)->children;
struct info_iq ii;
parse_iq(lm_message_get_node(message), &ii);
- if(!strcmp(test->name, "jingle")) {
- if(!strcmp(lm_message_node_get_attribute(test, "xmlns"), NS_JINGLE)) {
- gchar* action = g_strdup(lm_message_node_get_attribute(test, "action"));
- gchar* initiator = g_strdup(lm_message_node_get_attribute(test, "initiator"));
- gchar* responder = g_strdup(lm_message_node_get_attribute(test, "responder"));
- gchar* sid = g_strdup(lm_message_node_get_attribute(test, "sid"));
- if(!strcmp(action, "content-accept")) {
- } else if (!strcmp(action, "content-add")) {
- } else if (!strcmp(action, "content-modify")) {
- } else if (!strcmp(action, "content-reject")) {
- } else if (!strcmp(action, "content-remove")) {
- } else if (!strcmp(action, "description-info")) {
- } else if (!strcmp(action, "security-info")) {
- } else if (!strcmp(action, "session-accept")) {
- } else if (!strcmp(action, "session-info")) {
- } else if (!strcmp(action, "session-initiate")) {
- LmMessageNode *child = NULL;
- gchar* disposition = NULL;
- for(child = test->children; child; child = child->next) {
- if(!strcmp((disposition = lm_message_node_get_attribute(child, "disposition")), "session"))
- break;
- if(!disposition) {
- disposition = g_strdup("session");
- break;
- }
- }
- if(strcmp(disposition, "session")) {
- //ERREUR
- }
-
- } else if (!strcmp(action, "session-terminate")) {
- } else if (!strcmp(action, "transport-accept")) {
- } else if (!strcmp(action, "transport-info")) {
- } else if (!strcmp(action, "transport-reject")) {
- } else if (!strcmp(action, "transport-replace")) {
- } else {
- { // action inconnue => réponse XEP 0166 : 7.2
-
-
- }
- }
- } else {
- scr_log_print(LPRINT_NORMAL, "jingle : Namespace inconnu (%s)", lm_message_node_get_attribute(test, "xmlns"));
- }
+
+ if (strcmp(test->name, "jingle") != 0) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
+ if (!strcmp(lm_message_node_get_attribute(test, "xmlns"), NS_JINGLE)) {
+ gchar* action = g_strdup(lm_message_node_get_attribute(test, "action"));
+ gchar* initiator = g_strdup(lm_message_node_get_attribute(test, "initiator"));
+ gchar* responder = g_strdup(lm_message_node_get_attribute(test, "responder"));
+ gchar* sid = g_strdup(lm_message_node_get_attribute(test, "sid"));
+ if (!strcmp(action, "content-accept")) {
+ } else if (!strcmp(action, "content-add")) {
+ } else if (!strcmp(action, "content-modify")) {
+ } else if (!strcmp(action, "content-reject")) {
+ } else if (!strcmp(action, "content-remove")) {
+ } else if (!strcmp(action, "description-info")) {
+ } else if (!strcmp(action, "security-info")) {
+ } else if (!strcmp(action, "session-accept")) {
+ } else if (!strcmp(action, "session-info")) {
+ } else if (!strcmp(action, "session-initiate")) {
+ LmMessageNode *child = NULL;
+ gchar* disposition = NULL;
+ for(child = test->children; child; child = child->next) {
+ if (!strcmp((disposition = lm_message_node_get_attribute(child, "disposition")), "session"))
+ break;
+ if (!disposition) {
+ disposition = g_strdup("session");
+ break;
+ }
+ }
+ if (strcmp(disposition, "session")) {
+ //ERREUR
+ }
+ } else if (!strcmp(action, "session-terminate")) {
+ } else if (!strcmp(action, "transport-accept")) {
+ } else if (!strcmp(action, "transport-info")) {
+ } else if (!strcmp(action, "transport-reject")) {
+ } else if (!strcmp(action, "transport-replace")) {
+ } else {
+ // action inconnue => réponse XEP 0166 : 7.2
+ }
+ } else {
+ scr_log_print(LPRINT_NORMAL, "jingle : Namespace inconnu (%s)", lm_message_node_get_attribute(test, "xmlns"));
+ }
+
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
-
-/* Initialization */
+
static void mcjingle_init(void)
{
- lm = lm_message_handler_new(gestionnaire_lm, NULL, NULL);
- lm_connection_register_message_handler (lconnection, lm, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
+ jingle_iq_handler = lm_message_handler_new(jingle_iq_event_handler, NULL, NULL);
+ lm_connection_register_message_handler(lconnection, jingle_iq_handler, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
}
-/* Uninitialization */
static void mcjingle_uninit(void)
{
- lm_connection_unregister_message_handler (lconnection, lm, LM_MESSAGE_TYPE_IQ);
- lm_message_handler_invalidate (lm);
- lm_message_handler_unref (lm);
+ lm_connection_unregister_message_handler(lconnection, jingle_iq_handler, LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_invalidate(lm);
+ lm_message_handler_unref(lm);
}
--- a/parse.c Tue May 25 00:40:38 2010 +0200
+++ b/parse.c Tue May 25 05:52:04 2010 +0200
@@ -3,12 +3,12 @@
#include "parse.h"
-int parse_jingle (LmMessageNode *node, struct info_jingle *ij)
+int parse_jingle(LmMessageNode *node, struct info_jingle *ij)
{
int nb_reason = 0;
LmMessageNode *child = NULL;
- if(!strcmp(ij->name, "jingle"))
+ if (!strcmp(ij->name, "jingle"))
return PARSE_ERROR_NAME;
ij->action = attrcpy(lm_message_node_get_attribute(node, "action"));
@@ -17,11 +17,11 @@
ij->sid = attrcpy(lm_message_node_get_attribute(node, "sid"));
// check required
- if(ij->action == NULL || ij->sid == NULL)
+ if (ij->action == NULL || ij->sid == NULL)
return PARSE_ERROR_REQUIRED;
// check restrictions
- if(!check_restriction(ij->action, {"content-accept", "content-add",
+ if (!check_restriction(ij->action, {"content-accept", "content-add",
"content-modify", "content-reject", "content-remove", "description-info",
"security-info", "session-accept", "session-info", "session-initiate",
"session-terminate", "transport-accept", "transport-info", "transport-reject",
@@ -29,12 +29,12 @@
return PARSE_ERROR_RESTRICTION;
// check childs
- for(child = node->children; child; child = child->next) {
- if(!strcmp(child->name, "reason"))
+ for (child = node->children; child; child = child->next) {
+ if (!strcmp(child->name, "reason"))
nb_reason++;
}
- if(reason > 1)
+ if (reason > 1)
return PARSE_ERROR_TOO_MANY_CHILDS;
return PARSE_OK;
@@ -52,7 +52,7 @@
int parse_content(LmMessageNode* node, struct info_content* ic)
{
- if(!strcmp(ic->name, "content"))
+ if (!strcmp(ic->name, "content"))
return PARSE_ERROR_NAME;
ic->creator = attrcpy(lm_message_node_get_attribute(node, "creator"));
@@ -61,17 +61,17 @@
ic->senders = attrcpy(lm_message_node_get_attribute(node, "senders"));
// Put default if none
- if(ic->disposition == NULL)
+ if (ic->disposition == NULL)
ic->disposition = attrcpy("session");
// check required
- if(ic->creator == NULL || ic->name == NULL)
+ if (ic->creator == NULL || ic->name == NULL)
return PARSE_ERROR_REQUIRED;
// check restrictions
- if(!check_restriction(ic->creator, {"initiator", "responder", NULL}))
+ if (!check_restriction(ic->creator, {"initiator", "responder", NULL}))
return PARSE_ERROR_RESTRICTION;
- if(!check_restriction(ic->senders, {"both", "initiator", "none", "responder", NULL}))
+ if (!check_restriction(ic->senders, {"both", "initiator", "none", "responder", NULL}))
ic->senders = NULL; // because it's optional
return PARSE_OK;
@@ -92,8 +92,8 @@
const char* value;
int found = 0;
value = values[0];
- while(value && !found) {
- if(!strcmp(name, value))
+ while (value && !found) {
+ if (!strcmp(name, value))
found = 1;
value++;
}
@@ -104,7 +104,7 @@
char* attrcpy(const char* attr)
{
char *tmp = NULL;
- if(attr != NULL) {
+ if (attr != NULL) {
tmp = (char*) malloc((strlen(attr)+1) * sizeof(char));
strcpy(tmp, attr);
}