jingle/action-handlers.c
changeset 41 9c3620daec8f
parent 40 cbc7a83fbdf5
child 42 526d61c145a7
equal deleted inserted replaced
40:cbc7a83fbdf5 41:9c3620daec8f
   258   JingleAppFuncs *appfuncs; 
   258   JingleAppFuncs *appfuncs; 
   259   JingleTransportFuncs *transfuncs;
   259   JingleTransportFuncs *transfuncs;
   260   gconstpointer description, transport;
   260   gconstpointer description, transport;
   261   const gchar *xmlns;
   261   const gchar *xmlns;
   262   JingleSession* sess;
   262   JingleSession* sess;
   263 
   263   JingleNode accept;
       
   264   LmMessage *r;
       
   265   
   264   if (!check_contents(jn, &err)) {
   266   if (!check_contents(jn, &err)) {
   265     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
   267     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
   266                   err->message);
   268                   err->message);
   267     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
   269     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
   268     return;
   270     return;
   294     return;
   296     return;
   295   }
   297   }
   296 
   298 
   297   jingle_ack_iq(m);
   299   jingle_ack_iq(m);
   298 
   300 
       
   301   accept.action = JINGLE_SESSION_ACCEPT;
       
   302   accept.initiator = jn->initiator;
       
   303   accept.creator = jn->creator;
       
   304   accept.responder = jn->responder;
       
   305   accept.sid = jn->sid;
       
   306   accept.content = NULL;
       
   307   
   299   sess = session_new(jn);
   308   sess = session_new(jn);
   300   
   309   
   301   for (child = jn->content; child; child = child->next) {
   310   for (child = jn->content; child; child = child->next) {
   302     cn = (JingleContent *)(child->data);
   311     cn = (JingleContent *)(child->data);
   303     
   312     
   313     if (description == NULL || err != NULL) continue;
   322     if (description == NULL || err != NULL) continue;
   314     transport = transfuncs->check(cn, &err);
   323     transport = transfuncs->check(cn, &err);
   315     if (transport == NULL || err != NULL) continue;
   324     if (transport == NULL || err != NULL) continue;
   316     
   325     
   317     session_add_content(sess, cn, ACTIVE);
   326     session_add_content(sess, cn, ACTIVE);
       
   327     accept.content = g_slist_append(accept.content, cn);
   318   }
   328   }
   319   
   329   
   320   if(g_slist_length(sess->content) == 0) {
   330   if(g_slist_length(sess->content) == 0) {
   321     jingle_send_session_terminate(jn, "unsupported-applications");
   331     jingle_send_session_terminate(jn, "unsupported-applications");
   322     session_delete(sess);
   332     session_delete(sess);
   323     return;
   333     return;
   324   }
   334   }
   325   
   335   
   326   // Send a session-accept
   336   // Send a session-accept
   327   
   337   if (g_slist_length(accept.content) != 0) {
       
   338     r = lm_message_from_jinglenode(&accept, lm_message_get_from(m));
       
   339     if (r) {
       
   340       lm_connection_send(lconnection, r, NULL);
       
   341       lm_message_unref(r);
       
   342     }
       
   343   }
       
   344 
   328 }
   345 }
   329 
   346 
   330 void handle_session_terminate(LmMessage *m, JingleNode *jn)
   347 void handle_session_terminate(LmMessage *m, JingleNode *jn)
   331 {
   348 {
   332   JingleSession *sess;
   349   JingleSession *sess;