jingle/action-handlers.c
changeset 30 8c3a03e08fd8
parent 29 9215053e8fb0
child 31 02f5698ffa49
equal deleted inserted replaced
29:9215053e8fb0 30:8c3a03e08fd8
    39  */
    39  */
    40 
    40 
    41 void handle_session_initiate(LmMessage *m, JingleNode *jn)
    41 void handle_session_initiate(LmMessage *m, JingleNode *jn)
    42 {
    42 {
    43   GError *err = NULL;
    43   GError *err = NULL;
    44   gboolean is_session = FALSE;
    44   gboolean is_session = FALSE, support_both = FALSE;
    45   GSList *child = NULL;
    45   GSList *child = NULL;
    46   JingleContent *cn;
    46   JingleContent *cn;
       
    47   JingleAppFuncs *af;
       
    48   JingleTransportFuncs *tf;
    47 
    49 
    48   if (!check_contents(jn, &err)) {
    50   if (!check_contents(jn, &err)) {
    49     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
    51     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
    50                   err->message);
    52                   err->message);
    51     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
    53     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
    76   }
    78   }
    77 
    79 
    78   // the important from is one in the session-initiate
    80   // the important from is one in the session-initiate
    79   jn->from = lm_message_node_get_attribute(lm_message_get_node(m), "from");
    81   jn->from = lm_message_node_get_attribute(lm_message_get_node(m), "from");
    80   
    82   
       
    83   jingle_ack_iq(m);
    81   
    84   
    82   jingle_ack_iq(m);
       
    83 
       
    84   is_session = FALSE;  
       
    85   // Do we support any of this xmlns ?
       
    86   for (child = jn->content; child && !is_session; child = child->next) {
       
    87     if (jingle_get_appfuncs(get_xmlnsdesc(child)) != NULL)
       
    88       is_session = TRUE;
       
    89   }
       
    90   if (!is_session) { // None of the app is supported
       
    91     jingle_send_session_terminate(m, "unsupported-applications");
       
    92     return;
       
    93   }
       
    94 
       
    95   is_session = FALSE;  
       
    96   // Do we support any of this xmlns ?
       
    97   for (child = jn->content; child && !is_session; child = child->next) {
       
    98     if (jingle_get_transportfuncs(get_xmlnstrans(child)) != NULL)
       
    99       is_session = TRUE;
       
   100   }
       
   101   if (!is_session) { // None of the transport is supported
       
   102     jingle_send_session_terminate(m, "unsupported-transports");
       
   103     return;
       
   104   }
       
   105   
    85   
   106   // Next we ask parsing to the modules
       
   107   for (child = jn->content; child; child = child->next) {
    86   for (child = jn->content; child; child = child->next) {
   108     ((JingleContent*)(child->data))->description = jingle_get_appfuncs(get_xmlnsdesc(child))->check((JingleContent*)(child->data), NULL, NULL);
    87     cn = (JingleContent*)(child->data);
   109     ((JingleContent*)(child->data))->transport = jingle_get_appfuncs(get_xmlnstrans(child))->check((JingleContent*)(child->data), NULL, NULL);
    88     
       
    89     af = jingle_get_appfuncs(cn->xmlns_desc);
       
    90     tf = jingle_get_transportfuncs(cn->xmlns_trans);
       
    91     if (af == NULL && tf == NULL) continue;
       
    92     
       
    93     cn->description = af->check(cn, NULL, NULL);
       
    94     cn->transport = tf->check(cn, NULL, NULL);
   110   }
    95   }
   111 }
    96 }
   112 
    97 
   113 void handle_session_terminate(LmMessage *m, JingleNode *jn)
    98 void handle_session_terminate(LmMessage *m, JingleNode *jn)
   114 {
    99 {