jingle/action-handlers.c
changeset 44 4738d78edc05
parent 43 357e69106171
child 45 c007e112dd54
equal deleted inserted replaced
43:357e69106171 44:4738d78edc05
    21 
    21 
    22 #include <glib.h>
    22 #include <glib.h>
    23 
    23 
    24 #include <mcabber/logprint.h>
    24 #include <mcabber/logprint.h>
    25 #include <mcabber/xmpp_helper.h>
    25 #include <mcabber/xmpp_helper.h>
       
    26 #include <mcabber/events.h>
       
    27 #include <mcabber/hbuf.h>
    26 
    28 
    27 #include <jingle/jingle.h>
    29 #include <jingle/jingle.h>
    28 #include <jingle/check.h>
    30 #include <jingle/check.h>
    29 #include <jingle/sessions.h>
    31 #include <jingle/sessions.h>
    30 #include <jingle/register.h>
    32 #include <jingle/register.h>
   239 }
   241 }
   240 
   242 
   241 void handle_session_initiate(LmMessage *m, JingleNode *jn)
   243 void handle_session_initiate(LmMessage *m, JingleNode *jn)
   242 {
   244 {
   243   GError *err = NULL;
   245   GError *err = NULL;
   244   GSList *child = NULL;
       
   245   gboolean valid_disposition = FALSE;
   246   gboolean valid_disposition = FALSE;
   246   JingleContent *cn;
   247   JingleContent *cn;
       
   248   GString *sbuf;
       
   249   GSList *child = NULL;
   247   LmMessage *r;
   250   LmMessage *r;
   248   
   251   
   249   if (!check_contents(jn, &err)) {
   252   if (!check_contents(jn, &err)) {
   250     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
   253     scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
   251                   err->message);
   254                   err->message);
   279     return;
   282     return;
   280   }
   283   }
   281 
   284 
   282   jingle_ack_iq(m);
   285   jingle_ack_iq(m);
   283 
   286 
   284   // TODO: generate an event and wait for the user's choice
   287   // Wait that user accept the jingle
       
   288   sbuf = g_string_new("");
       
   289   g_string_printf(sbuf, "Received an invitation for a jingle session from <%s>", lm_message_get_from(m));
       
   290 
       
   291   scr_WriteIncomingMessage(jidtodisp(lm_message_get_from(m)), sbuf->str, 0, HBB_PREFIX_INFO, 0);
       
   292   scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str);
       
   293 
       
   294   {
       
   295     const char *id;
       
   296     char *desc = g_strdup_printf("<%s> invites you to do a jingle session", lm_message_get_from(m));
       
   297 
       
   298     id = evs_new(desc, NULL, 0, evscallback_jingle, jn, (GDestroyNotify)NULL);
       
   299     g_free(desc);
       
   300     if (id)
       
   301       g_string_printf(sbuf, "Please use /event %s accept|reject", id);
       
   302     else
       
   303       g_string_printf(sbuf, "Unable to create a new event!");
       
   304   }
   285 }
   305 }
   286 
   306 
   287 void handle_session_terminate(LmMessage *m, JingleNode *jn)
   307 void handle_session_terminate(LmMessage *m, JingleNode *jn)
   288 {
   308 {
   289   JingleSession *sess;
   309   JingleSession *sess;