jingle-filetransfer/filetransfer.c
changeset 101 4235aa1a7664
parent 94 a49f78cada29
child 102 ec430b98c115
equal deleted inserted replaced
100:c033d2fc0f7d 101:4235aa1a7664
    44 
    44 
    45 
    45 
    46 gconstpointer jingle_ft_check(JingleContent *cn, GError **err);
    46 gconstpointer jingle_ft_check(JingleContent *cn, GError **err);
    47 void jingle_ft_tomessage(gconstpointer data, LmMessageNode *node);
    47 void jingle_ft_tomessage(gconstpointer data, LmMessageNode *node);
    48 gboolean jingle_ft_handle_data(gconstpointer data, const gchar *data2, guint len);
    48 gboolean jingle_ft_handle_data(gconstpointer data, const gchar *data2, guint len);
       
    49 void jingle_ft_start(gconstpointer data);
    49 static gboolean is_md5_hash(const gchar *hash);
    50 static gboolean is_md5_hash(const gchar *hash);
    50 static void jingle_ft_init(void);
    51 static void jingle_ft_init(void);
    51 static void jingle_ft_uninit(void);
    52 static void jingle_ft_uninit(void);
    52 
    53 
    53 const gchar *deps[] = { "jingle", NULL };
    54 const gchar *deps[] = { "jingle", NULL };
   305     lm_message_node_add_child(node2, "desc", jft->desc);
   306     lm_message_node_add_child(node2, "desc", jft->desc);
   306 
   307 
   307   //if (jft->data != 0)
   308   //if (jft->data != 0)
   308 }
   309 }
   309 
   310 
       
   311 void jingle_ft_send(gconstpointer data, gsize size)
       
   312 {
       
   313   JingleFT *jft = (JingleFT*)data;
       
   314   gchar *buf = g_new0(gchar, size);
       
   315   gsize read;
       
   316   GIOStatus status;
       
   317   int count = 0;
       
   318   
       
   319   do {
       
   320     count++;
       
   321     status = g_io_channel_read_chars(jft->outfile, buf, size, &read, NULL);
       
   322   while (status == GIO_STATUS_AGAIN && count < 10);
       
   323   
       
   324   if (status == GIO_STATUS_AGAIN) {
       
   325     // TODO: something better
       
   326     scr_LogPrint(LPRINT_LOGNORM, "Jingle File Transfer: file unavailable");
       
   327     return;
       
   328   }
       
   329   
       
   330   if (status == GIO_STATUS_ERROR) {
       
   331     scr_LogPrint(LPRINT_LOGNORM, "Jingle File Transfer: an error occured");
       
   332     return;
       
   333   }
       
   334   
       
   335   // Call a handle in jingle who will call the trans
       
   336   //jingle_handle_data
       
   337   
       
   338   if (status == GIO_STATUS_EOF) {
       
   339     scr_LogPrint(LPRINT_LOGNORM, "Jingle File Transfer: transfer finish (%s)", jft->name);
       
   340     // Call a function to say state is ended
       
   341     
       
   342   }
       
   343 }
       
   344 
       
   345 void jingle_ft_start(gconstpointer data, gsize size)
       
   346 {
       
   347   JingleFT *jft = (JingleFT*)data;
       
   348 
       
   349 
       
   350 }
       
   351 
   310 static void jingle_ft_init(void)
   352 static void jingle_ft_init(void)
   311 {
   353 {
   312   jingle_register_app(NS_JINGLE_APP_FT, &funcs, JINGLE_TRANSPORT_STREAMING);
   354   jingle_register_app(NS_JINGLE_APP_FT, &funcs, JINGLE_TRANSPORT_STREAMING);
   313   xmpp_add_feature(NS_JINGLE_APP_FT);
   355   xmpp_add_feature(NS_JINGLE_APP_FT);
   314   /*file_cid = compl_new_category();
   356   /*file_cid = compl_new_category();