# HG changeset patch # User Nicolas Cornu # Date 1282171419 -7200 # Node ID cb40539b88b7dcb1c6146fc05a71ce4d90de2f76 # Parent c72010633a860717785e1f33385445507b5626db Fix compilation warnings. Add documentation in the code. diff -r c72010633a86 -r cb40539b88b7 jingle-ibb/ibb.c --- a/jingle-ibb/ibb.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle-ibb/ibb.c Thu Aug 19 00:43:39 2010 +0200 @@ -391,7 +391,7 @@ jingle_register_transport(NS_JINGLE_TRANSPORT_IBB, &funcs, JINGLE_TRANSPORT_STREAMING, - JINGLE_TRANSPORT_LOW); + JINGLE_TRANSPORT_PRIO_LOW); xmpp_add_feature(NS_JINGLE_TRANSPORT_IBB); JingleIBBs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_ibb); } diff -r c72010633a86 -r cb40539b88b7 jingle-socks5/socks5.c --- a/jingle-socks5/socks5.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle-socks5/socks5.c Thu Aug 19 00:43:39 2010 +0200 @@ -37,7 +37,6 @@ #include "socks5.h" gconstpointer jingle_socks5_check(JingleContent *cn, GError **err); -gboolean jingle_socks5_cmp(gconstpointer data1, gconstpointer data2); void jingle_socks5_tomessage(gconstpointer data, LmMessageNode *node); gconstpointer jingle_socks5_new(void); void jingle_socks5_send(session_content *sc, gconstpointer data, gchar *buf, @@ -50,11 +49,10 @@ const gchar *deps[] = { "jingle", NULL }; static JingleTransportFuncs funcs = { - jingle_socks5_check, - jingle_socks5_tomessage, - jingle_socks5_cmp, - jingle_socks5_new, - jingle_socks5_send + .check = jingle_socks5_check, + .tomessage = jingle_socks5_tomessage, + .new = jingle_socks5_new, + .send = jingle_socks5_send }; module_info_t info_jingle_socks5bytestream = { @@ -185,7 +183,7 @@ { jingle_register_transport(NS_JINGLE_TRANSPORT_SOCKS5, &funcs, JINGLE_TRANSPORT_STREAMING, - JINGLE_TRANSPORT_HIGH); + JINGLE_TRANSPORT_PRIO_HIGH); xmpp_add_feature(NS_JINGLE_TRANSPORT_SOCKS5); } diff -r c72010633a86 -r cb40539b88b7 jingle/action-handlers.c --- a/jingle/action-handlers.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/action-handlers.c Thu Aug 19 00:43:39 2010 +0200 @@ -45,13 +45,11 @@ JingleContent *cn; gchar *sbuf; GSList *child = NULL; - LmMessage *r; gchar *disp; JingleSession *sess; const gchar *xmlns; JingleAppFuncs *appfuncs; JingleTransportFuncs *transfuncs; - gconstpointer description, transport; // Make sure the request come from an user in our roster disp = jidtodisp(lm_message_get_from(jn->message)); diff -r c72010633a86 -r cb40539b88b7 jingle/check.h --- a/jingle/check.h Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/check.h Thu Aug 19 00:43:39 2010 +0200 @@ -2,7 +2,6 @@ * @file check.h * @brief check.c header file * @author Nicolas Cornu - * @version 0.1 */ #ifndef __JINGLE_CHECK_H__ diff -r c72010633a86 -r cb40539b88b7 jingle/jingle.h --- a/jingle/jingle.h Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/jingle.h Thu Aug 19 00:43:39 2010 +0200 @@ -2,7 +2,6 @@ * @file jingle.h * @brief jingle.c header file * @author Nicolas Cornu - * @version 0.1 */ #ifndef __JINGLE_H__ @@ -53,7 +52,6 @@ } JingleSenders; /** - * @struct JingleNode * @brief Represent an incoming jingle IQ * * This struct is used to represent an incoming jingle IQ. @@ -105,7 +103,6 @@ } JingleNode; /** - * @struct JingleContent * @brief Struct used to represent a element of an incoming Jingle IQ */ typedef struct { @@ -157,8 +154,6 @@ } JingleContent; /** - * @struct JingleActionList - * * Represent a jingle action and the "handler" * (defined in action-handlers.c) for that action. */ diff -r c72010633a86 -r cb40539b88b7 jingle/register.c --- a/jingle/register.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/register.c Thu Aug 19 00:43:39 2010 +0200 @@ -114,7 +114,7 @@ AppHandlerEntry *app = jingle_find_app(appxmlns); GSList *entry; TransportHandlerEntry *thistransport, *besttransport = NULL; - JingleTransportPriority bestprio = JINGLE_TRANSPORT_NONE; + JingleTransportPriority bestprio = 0; JingleTransportType requestedtype; if (app == NULL) diff -r c72010633a86 -r cb40539b88b7 jingle/register.h --- a/jingle/register.h Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/register.h Thu Aug 19 00:43:39 2010 +0200 @@ -1,3 +1,9 @@ +/** + * @file register.h + * @brief register.c header file + * @author Nicolas Cornu + */ + #ifndef __JINGLE_REGISTER_H__ #define __JINGLE_REGISTER_H__ @@ -7,31 +13,39 @@ #define NS_JINGLE_TRANSPORT_PREFIX "urn:xmpp:jingle:transports:" +/** + * @brief A transport can be either of type "streaming" or "datagram" + */ typedef enum { - /* A datagram transport has one or more components with which to exchange + /** + * A datagram transport has one or more components with which to exchange * packets with UDP-like behavior. Packets might be of arbitrary length, * might be received out of order, and might not be received at all - * (i.e., the transport is lossy). */ + * (i.e., the transport is lossy). + */ JINGLE_TRANSPORT_STREAMING, - /* A streaming transport has one or more components with which to exchange + /** + * A streaming transport has one or more components with which to exchange * bidirectional bytestreams with TCP-like behavior. Bytes are received * reliably and in order, and applications MUST NOT rely on a stream being - * chunked in any specific way. */ + * chunked in any specific way. + */ JINGLE_TRANSPORT_DATAGRAM } JingleTransportType; /** + * @brief A way for transport modules to rank themselves. + * * We need to rank transports to determine which one to choose. - * With this system, In-Band Bytestreams could have a low priority, SOCKS5 - * Bytestream a normal priority, and some stream transport method that allow - * direct connection would have a high priority, since it would be the fastest. + * With this system, In-Band Bytestreams could have a low priority, + * SOCKS5 Bytestreams a normal priority.\n + * 0 will always be an invalid priority. */ typedef enum { - JINGLE_TRANSPORT_NONE, - JINGLE_TRANSPORT_LOW, - JINGLE_TRANSPORT_NORMAL, - JINGLE_TRANSPORT_HIGH + JINGLE_TRANSPORT_PRIO_LOW = 1, + JINGLE_TRANSPORT_PRIO_NORMAL, + JINGLE_TRANSPORT_PRIO_HIGH } JingleTransportPriority; typedef gconstpointer (*JingleAppCheck) (JingleContent *cn, GError **err); @@ -51,18 +65,31 @@ typedef void (*JingleTransportEnd) (session_content *sc, gconstpointer data); typedef gchar* (*JingleTransportInfo) (gconstpointer data); +/** + * @brief Struct containing functions provided by an app module. + */ typedef struct { - /* check if the description of a JingleContent is correct */ + /** + * @brief Check if the description node of a JingleContent is correct + */ JingleAppCheck check; - /* handle an incoming jingle message (session-info, description-info...). + /** + * @brief Handle an incoming jingle message (session-info, description-info...) + * * If the function could not handle the incoming data, the caller should - * reply to the incoming message with an error iq */ + * reply to the incoming message with an error iq. + */ JingleAppHandle handle; - /* Insert data from the gconstpointer to the node given as an argument */ + /** + * @brief Insert data from the gconstpointer to the node given as an argument + */ JingleAppToMessage tomessage; + /** + * @brief Handle incoming data + */ JingleAppHandleData handle_data; JingleAppStart start; @@ -70,24 +97,30 @@ JingleAppSend send; JingleAppStop stop; - + JingleAppInfo info; } JingleAppFuncs; typedef struct { + /** + * @brief Check if the transport node of a JingleContent is correct + */ JingleTransportCheck check; + /** + * @brief Insert data from the gconstpointer to the node given as an argument + */ JingleTransportToMessage tomessage; JingleTransportNew new; JingleTransportSend send; - + JingleTransportInit init; - + JingleTransportEnd end; - + JingleTransportInfo info; } JingleTransportFuncs; diff -r c72010633a86 -r cb40539b88b7 jingle/send.c --- a/jingle/send.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/send.c Thu Aug 19 00:43:39 2010 +0200 @@ -65,13 +65,11 @@ { LmMessageNode *node; const gchar *type, *cause; - GSList *child = NULL; JingleSession *sess = (JingleSession*)data; - SessionContent *sc; if (acktype == JINGLE_ACK_TIMEOUT) { // TODO: handle ack timeout... - scr_LogPrint(LPRINT_LOGNORM, "Jingle: session-accept %s: %s", type, cause); + scr_LogPrint(LPRINT_LOGNORM, "Jingle: did not receive the accept ack in time, aborting"); session_delete(sess); return; } @@ -86,6 +84,8 @@ type = lm_message_node_get_attribute(node, "type"); if(node->children != NULL) cause = node->children->name; + else + cause = "?"; scr_LogPrint(LPRINT_LOGNORM, "Jingle: session-accept %s: %s", type, cause); } // We delete the session, there was an error @@ -121,7 +121,7 @@ if (acktype == JINGLE_ACK_TIMEOUT) { // TODO: handle ack timeout... - scr_LogPrint(LPRINT_LOGNORM, "Jingle: did not receive the ack in time, aborting"); + scr_LogPrint(LPRINT_LOGNORM, "Jingle: did not receive the initiate ack in time, aborting"); session_delete(sess); return; } @@ -134,6 +134,8 @@ type = lm_message_node_get_attribute(node, "type"); if(node->children != NULL) cause = node->children->name; + else + cause = "?"; scr_LogPrint(LPRINT_LOGNORM, "Jingle: session-initiate %s: %s", type, cause); } // We delete the session, there was an error @@ -143,7 +145,6 @@ void jingle_send_session_initiate(JingleSession *js) { JingleAckHandle *ackhandle; - GSList *listentry; GError *err = NULL; gboolean status; diff -r c72010633a86 -r cb40539b88b7 jingle/sessions.c --- a/jingle/sessions.c Thu Aug 19 00:00:08 2010 +0200 +++ b/jingle/sessions.c Thu Aug 19 00:43:39 2010 +0200 @@ -26,6 +26,7 @@ #include #include #include +#include static GSList *sessions; @@ -191,11 +192,11 @@ return NULL; } -int session_remove_sessioncontent(JingleSession *sess, const gchar *name) +gint session_remove_sessioncontent(JingleSession *sess, const gchar *name) { SessionContent *sc; sc = session_find_sessioncontent(sess, name); - if(sc == NULL) return; + if(sc == NULL) return 0; if (sc->state == JINGLE_SESSION_STATE_ACTIVE) { // TODO: stop the transfer @@ -275,7 +276,7 @@ { LmMessage* m; LmMessageNode *jnode; - const gchar *actionstr, *recipient; + const gchar *recipient; recipient = (js->origin == JINGLE_SESSION_INCOMING) ? js->from : js->to; @@ -285,11 +286,8 @@ jnode = lm_message_node_add_child(m->node, "jingle", NULL); lm_message_node_set_attribute(jnode, "xmlns", NS_JINGLE); - - if (actionstr = jingle_action_list[action].name) - lm_message_node_set_attribute(jnode, "action", actionstr); - else - return NULL; + + lm_message_node_set_attribute(jnode, "action", jingle_action_list[action].name); if (js->sid) lm_message_node_set_attribute(jnode, "sid", js->sid); @@ -302,9 +300,6 @@ static void lm_insert_sessioncontent(gpointer data, gpointer userdata) { - const gchar *xmlns; - JingleTransportFuncs *tfunc; - JingleAppFuncs *afunc; SessionContent *content = (SessionContent*) data; LmMessageNode *jnode = (LmMessageNode*) userdata; LmMessageNode *node = lm_message_node_add_child(jnode, "content", NULL);