jingle/action-handlers.c
changeset 34 08715c230027
parent 32 72bbe33f151a
child 37 fce6bdc1ff46
equal deleted inserted replaced
33:92e92ce901e7 34:08715c230027
    35  * value of the <content/> element's 'disposition' attribute MUST be "session"
    35  * value of the <content/> element's 'disposition' attribute MUST be "session"
    36  * (if there are multiple <content/> elements then at least one MUST have a
    36  * (if there are multiple <content/> elements then at least one MUST have a
    37  * disposition of "session"); if this rule is violated, the responder MUST
    37  * disposition of "session"); if this rule is violated, the responder MUST
    38  * return a <bad-request/> error to the initiator.
    38  * return a <bad-request/> error to the initiator.
    39  */
    39  */
       
    40 
       
    41 void handle_content_add(LmMessage *m, JingleNode *jn)
       
    42 {
       
    43   GError *err = NULL;
       
    44   GSList *child = NULL;
       
    45   JingleContent *cn;
       
    46   JingleAppFuncs *appfuncs; 
       
    47   JingleTransportFuncs *transfuncs;
       
    48   gconstpointer description, transport;
       
    49   const gchar *xmlns;
       
    50 
       
    51   if (!check_contents(jn, &err)) {
       
    52     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
       
    53                   err->message);
       
    54     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
       
    55     return;
       
    56   }
       
    57 
       
    58   // it's better if there is at least one content elem */
       
    59   if (g_slist_length(jn->content) < 1) {
       
    60     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
       
    61     return;
       
    62   }
       
    63   
       
    64   // if a session with the same sid doesn't already exists
       
    65   if (session_find(jn) == NULL) {
       
    66     jingle_send_iq_error(m, "cancel", "unexpected-request", "out-of-order");
       
    67     return;
       
    68   }
       
    69 
       
    70   jingle_ack_iq(m);
       
    71 
       
    72   for (child = jn->content; child; child = child->next) {
       
    73     cn = (JingleContent *)(child->data);
       
    74     
       
    75     xmlns = lm_message_node_get_attribute(cn->description, "xmlns");
       
    76     appfuncs = jingle_get_appfuncs(xmlns);
       
    77     if (appfuncs == NULL) continue;
       
    78     
       
    79     xmlns = lm_message_node_get_attribute(cn->transport, "xmlns");
       
    80     transfuncs = jingle_get_transportfuncs(xmlns);
       
    81     if (appfuncs == NULL) continue;
       
    82     
       
    83     description = appfuncs->check(cn, &err);
       
    84     if (description == NULL || err != NULL) continue;
       
    85     transport = transfuncs->check(cn, &err);
       
    86     if (transport == NULL || err != NULL) continue;
       
    87   }
       
    88 }
       
    89 
    40 
    90 
    41 void handle_session_initiate(LmMessage *m, JingleNode *jn)
    91 void handle_session_initiate(LmMessage *m, JingleNode *jn)
    42 {
    92 {
    43   GError *err = NULL;
    93   GError *err = NULL;
    44   GSList *child = NULL;
    94   GSList *child = NULL;