jingle.c
author Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
Tue, 25 May 2010 16:44:52 +0200
changeset 5 2155c65c7455
parent 3 46a9e1c8181f
child 6 a035ec60dc7f
permissions -rw-r--r--
Use gchar/g_strdump instead of char/strcpy. Add an empty config.h.in.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     1
/*
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
     2
 *  jingle.c -- Base jingle functions
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     3
 *
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
     4
 * Copyrigth (C) 2010    Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     5
 *
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     8
 * the Free Software Foundation; either version 2 of the License, or (at
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
     9
 * your option) any later version.
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    10
 *
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    14
 * General Public License for more details.
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    15
 *
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    17
 * along with this program; if not, write to the Free Software
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    19
 * USA
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    20
 */
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    21
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    22
#include <glib.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    23
#include <loudmouth/loudmouth.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    24
#include <string.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    25
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    26
#include <mcabber/xmpp.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    27
#include <mcabber/hooks.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    28
#include <mcabber/modules.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    29
#include <mcabber/logprint.h>
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    30
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    31
#include "jingle.h"
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    32
#include "parse.h"
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    33
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    34
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    35
static void mcjingle_init  (void);
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    36
static void mcjingle_uninit(void);
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    37
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    38
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    39
LmMessageHandler* jingle_iq_handler = NULL;
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    40
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    41
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    42
module_info_t info_jingle = {
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    43
	.branch          = MCABBER_BRANCH,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    44
	.api             = MCABBER_API_VERSION,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    45
	.version         = MCABBER_VERSION,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    46
	.description     = "Main Jingle module\n"
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    47
		" required for file transport, voip...\n",
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    48
	.requires        = NULL,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    49
	.init            = mcjingle_init,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    50
	.uninit          = mcjingle_uninit,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    51
	.next            = NULL,
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    52
};
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    53
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    54
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    55
LmHandlerResult jingle_iq_event_handler(LmMessageHandler *handler,
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    56
		LmConnection *connection,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    57
		LmMessage *message,
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    58
		gpointer user_data)
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    59
{
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    60
	LmMessageNode *test = lm_message_get_node(message)->children;
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    61
	struct info_iq ii;
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    62
	struct info_jingle ij;
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    63
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    64
	parse_iq(lm_message_get_node(message), &ii);
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    65
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    66
	if (parse_jingle(test, &ij) == PARSE_ERROR_NAME)
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    67
		return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    68
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    69
	if (strcmp(lm_message_node_get_attribute(test, "xmlns"), NS_JINGLE)) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    70
		scr_log_print(LPRINT_NORMAL, "jingle : Namespace inconnu (%s)", lm_message_node_get_attribute(test, "xmlns"));
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    71
		return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    72
	}
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    73
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    74
	if (!strcmp(ij.action, "content-accept")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    75
	} else if (!strcmp(ij.action, "content-add")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    76
	} else if (!strcmp(ij.action, "content-modify")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    77
	} else if (!strcmp(ij.action, "content-reject")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    78
	} else if (!strcmp(ij.action, "content-remove")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    79
	} else if (!strcmp(ij.action, "description-info")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    80
	} else if (!strcmp(ij.action, "security-info")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    81
	} else if (!strcmp(ij.action, "session-accept")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    82
	} else if (!strcmp(ij.action, "session-info")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    83
	} else if (!strcmp(ij.action, "session-initiate")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    84
	} else if (!strcmp(ij.action, "session-terminate")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    85
	} else if (!strcmp(ij.action, "transport-accept")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    86
	} else if (!strcmp(ij.action, "transport-info")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    87
	} else if (!strcmp(ij.action, "transport-reject")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    88
	} else if (!strcmp(ij.action, "transport-replace")) {
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    89
	}
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    90
}
2
a48121a74017 Clean up the code, fix the coding style and improve the CMakeLists
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 1
diff changeset
    91
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    92
static void mcjingle_init(void)
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    93
{
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    94
	jingle_iq_handler = lm_message_handler_new(jingle_iq_event_handler, NULL, NULL);
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
    95
	lm_connection_register_message_handler(lconnection, jingle_iq_handler, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    96
}
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    97
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    98
static void mcjingle_uninit(void)
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
    99
{
3
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
   100
	lm_connection_unregister_message_handler(lconnection, jingle_iq_handler, LM_MESSAGE_TYPE_IQ);
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
   101
	lm_message_handler_invalidate(jingle_iq_handler);
46a9e1c8181f Some changes
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents: 2
diff changeset
   102
	lm_message_handler_unref(jingle_iq_handler);
1
6a9a25d32364 Add the parser of node and the CMakeList.txt
Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
parents:
diff changeset
   103
}