jingle/sessions.c
changeset 33 92e92ce901e7
parent 32 72bbe33f151a
child 35 a0fd92a93af7
equal deleted inserted replaced
32:72bbe33f151a 33:92e92ce901e7
    22 #include <glib.h>
    22 #include <glib.h>
    23 
    23 
    24 
    24 
    25 #include <jingle/jingle.h>
    25 #include <jingle/jingle.h>
    26 #include <jingle/sessions.h>
    26 #include <jingle/sessions.h>
       
    27 #include <jingle/register.h>
    27 
    28 
    28 
    29 
    29 static GSList *sessions;
    30 static GSList *sessions;
    30 
    31 
    31 
    32 
    67   LmMessageNode *iq = lm_message_get_node(jn->message);
    68   LmMessageNode *iq = lm_message_get_node(jn->message);
    68   const gchar *from = lm_message_node_get_attribute(iq, "from");
    69   const gchar *from = lm_message_node_get_attribute(iq, "from");
    69   return session_find_by_sid(jn->sid, from);
    70   return session_find_by_sid(jn->sid, from);
    70 }
    71 }
    71 
    72 
       
    73 void session_add_content(JingleSession *sess, JingleContent *cn)
       
    74 {
       
    75   SessionContent *sc = g_new0(SessionContent, 1);
       
    76   const gchar *tmpchar = lm_message_node_get_attribute(cn->description,
       
    77                                                        "xmlns");
       
    78   sc->appfuncs = jingle_get_appfuncs(tmpchar);
       
    79   tmpchar = lm_message_node_get_attribute(cn->transport, "xmlns");
       
    80   sc->transfuncs = jingle_get_transportfuncs(tmpchar);
       
    81   // TODO errors
       
    82   sc->description = sc->appfuncs->check(cn, NULL);
       
    83   sc->transport = sc->appfuncs->check(cn, NULL);
       
    84 
       
    85   sess->content = g_slist_append(sess->content, sc);
       
    86 }
       
    87 
       
    88 SessionContent *session_find_sessioncontent(JingleSession *sess,
       
    89                                         gconstpointer desc, gconstpointer trans)
       
    90 {
       
    91   GSList *el;
       
    92   SessionContent *sc;
       
    93   for (el = sess->content; el; el = el->next) {
       
    94     sc = (SessionContent*) el->data;
       
    95     if (sc->appfuncs->cmp(sc->description, desc) == TRUE &&
       
    96         sc->transfuncs->cmp(sc->transport, trans) == TRUE)
       
    97       return sc;
       
    98   }
       
    99   return NULL;
       
   100 }
       
   101 
    72 /**
   102 /**
    73  * Remove a session from the linked list and free it.
   103  * Remove a session from the linked list and free it.
    74  */
   104  */
    75 void session_delete(JingleSession *sess)
   105 void session_delete(JingleSession *sess)
    76 {
   106 {