jingle-ibb/ibb.c
changeset 126 059a6737f6a4
parent 124 7773e8147c29
child 127 02dde03e219b
equal deleted inserted replaced
125:3b640eb09fbd 126:059a6737f6a4
    44 static gboolean cmp(gconstpointer data1, gconstpointer data2);
    44 static gboolean cmp(gconstpointer data1, gconstpointer data2);
    45 static void tomessage(gconstpointer data, LmMessageNode *node);
    45 static void tomessage(gconstpointer data, LmMessageNode *node);
    46 static const gchar* xmlns(void);
    46 static const gchar* xmlns(void);
    47 static gconstpointer new(void);
    47 static gconstpointer new(void);
    48 static void send(session_content *sc, gconstpointer data, gchar *buf, gsize size);
    48 static void send(session_content *sc, gconstpointer data, gchar *buf, gsize size);
       
    49 static void init(session_content *sc, gconstpointer data);
    49 static void end(session_content *sc, gconstpointer data);
    50 static void end(session_content *sc, gconstpointer data);
    50 static void _send_internal(session_content *sc, const gchar *to, gchar *buf,
    51 static void _send_internal(session_content *sc, const gchar *to, gchar *buf,
    51                            gsize size, const gchar *sid, gint64 *seq);
    52                            gsize size, const gchar *sid, gint64 *seq);
    52 
    53 
    53 static void jingle_ibb_init(void);
    54 static void jingle_ibb_init(void);
    63   .check     = check,
    64   .check     = check,
    64   .tomessage = tomessage,
    65   .tomessage = tomessage,
    65   .cmp       = cmp,
    66   .cmp       = cmp,
    66   .new       = new,
    67   .new       = new,
    67   .send      = send,
    68   .send      = send,
       
    69   .init      = init,
    68   .end       = end
    70   .end       = end
    69 };
    71 };
    70 
    72 
    71 module_info_t  info_jingle_inbandbytestream = {
    73 module_info_t  info_jingle_inbandbytestream = {
    72   .branch          = MCABBER_BRANCH,
    74   .branch          = MCABBER_BRANCH,
   103     return NULL;
   105     return NULL;
   104   }
   106   }
   105   
   107   
   106   ibb->blocksize = g_ascii_strtoll(blocksize, NULL, 10);
   108   ibb->blocksize = g_ascii_strtoll(blocksize, NULL, 10);
   107 
   109 
   108   // the size attribute is a xs:short an therefore can be negative.
   110   // If block size is too big, we change it
   109   if (ibb->blocksize < 0 || ibb->blocksize > IBB_BLOCK_SIZE_MAX) {
   111   if (ibb->blocksize > IBB_BLOCK_SIZE_MAX) {
       
   112     ibb->blocksize = IBB_BLOCK_SIZE_MAX;
       
   113     return NULL;
       
   114   }
       
   115   ibb->blocksize = 2048;
       
   116   // the blocksize attribute is a xs:short an therefore can be negative.
       
   117   if (ibb->blocksize < 0) {
   110     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
   118     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
   111                 "block-size is negative");
   119                 "block-size is negative");
   112     g_free(ibb->sid);
   120     g_free(ibb->sid);
   113     g_free(ibb);
   121     g_free(ibb);
   114     return NULL;
   122     return NULL;
   308   
   316   
   309     g_free(buffer);
   317     g_free(buffer);
   310   }
   318   }
   311 }
   319 }
   312 
   320 
       
   321 static void init(session_content *sc, gconstpointer data)
       
   322 {
       
   323   JingleIBB *jibb = (JingleIBB*)data;
       
   324   JingleSession *sess = session_find_by_sid(sc->sid, sc->from);
       
   325   SessionContent *sc2 = session_find_sessioncontent(sess, sc->name);
       
   326   JingleIBB *jibb2 = (JingleIBB*)sc2->transport;
       
   327   
       
   328   jibb2->blocksize = (jibb->blocksize < jibb2->blocksize)?jibb->blocksize:jibb2->blocksize;
       
   329 }
       
   330 
   313 static void end(session_content *sc, gconstpointer data)
   331 static void end(session_content *sc, gconstpointer data)
   314 {
   332 {
   315   JingleIBB *jibb = (JingleIBB*)data;
   333   JingleIBB *jibb = (JingleIBB*)data;
   316   JingleSession *sess = session_find_by_sid(sc->sid, sc->from);
   334   JingleSession *sess = session_find_by_sid(sc->sid, sc->from);
   317   
   335