jingle-filetransfer/filetransfer.c
changeset 134 8c98308c139d
parent 133 361d8577ebd1
child 135 06b7c6f1c05c
equal deleted inserted replaced
133:361d8577ebd1 134:8c98308c139d
    58 static void jingle_ft_init(void);
    58 static void jingle_ft_init(void);
    59 static void jingle_ft_uninit(void);
    59 static void jingle_ft_uninit(void);
    60 // Return must be free
    60 // Return must be free
    61 static gchar *_convert_size(guint64 size);
    61 static gchar *_convert_size(guint64 size);
    62 static int _next_index(void);
    62 static int _next_index(void);
    63 static void _free(gconstpointer data);
    63 static void _free(JingleFT *jft);
    64 
    64 
    65 const gchar *deps[] = { "jingle", NULL };
    65 const gchar *deps[] = { "jingle", NULL };
    66 
    66 
    67 static GSList *info_list = NULL;
    67 static GSList *info_list = NULL;
    68 static guint jft_cid = 0;
    68 static guint jft_cid = 0;
   399                    jftio->jft->desc?jftio->jft->desc:"",
   399                    jftio->jft->desc?jftio->jft->desc:"",
   400                    strstate[jftio->jft->state]);
   400                    strstate[jftio->jft->state]);
   401       g_free(strsize);
   401       g_free(strsize);
   402     }
   402     }
   403   } else if (!g_strcmp0(args[0], "flush")) {
   403   } else if (!g_strcmp0(args[0], "flush")) {
   404     GSList *el, *el2 = NULL;
   404     GSList *el, *el2 = info_list;
   405     int count = 0;
   405     int count = 0;
   406     for (el = info_list; el; el = el -> next) {
   406     el = info_list;
   407       JingleFTInfo *jftio = el->data;
   407     while (el) {
   408       if (jftio->jft->state == JINGLE_FT_ERROR ||
   408       JingleFTInfo *jftinf;
   409           jftio->jft->state == JINGLE_FT_REJECT ||
   409       jftinf = el->data;
   410           jftio->jft->state == JINGLE_FT_ENDING) {
   410       if (jftinf->jft->state == JINGLE_FT_ERROR ||
   411         g_slist_free_1(el2);
   411           jftinf->jft->state == JINGLE_FT_REJECT ||
       
   412           jftinf->jft->state == JINGLE_FT_ENDING) {
   412         count++;
   413         count++;
   413         _free(jftio->jft);
   414         _free(jftinf->jft);
   414         info_list = g_slist_remove(info_list, jftio);
   415         info_list = g_slist_delete_link(info_list, el);
   415         el2 = el;
   416         if (info_list == NULL)
       
   417           break;
       
   418         el = el2;
       
   419         continue;
   416       }
   420       }
       
   421       el2 = el;
       
   422       el = el->next;
   417     }
   423     }
   418     g_slist_free_1(el2);
       
   419     scr_LogPrint(LPRINT_LOGNORM, "JFT: %i files removed", count);
   424     scr_LogPrint(LPRINT_LOGNORM, "JFT: %i files removed", count);
   420   } else {
   425   } else {
   421     scr_LogPrint(LPRINT_LOGNORM, "/jft: %s is not a correct option.", args[1]);
   426     scr_LogPrint(LPRINT_LOGNORM, "/jft: %s is not a correct option.", args[1]);
   422   }
   427   }
   423   
   428   
   424   free_arg_lst(args);
   429   free_arg_lst(args);
   425 }
   430 }
   426 
   431 
   427 static void _free(gconstpointer data)
   432 static void _free(JingleFT *jft)
   428 {
   433 {
   429   JingleFT *jft = (JingleFT *)data;
       
   430   g_free(jft->hash);
   434   g_free(jft->hash);
   431   g_free(jft->name);
   435   g_free(jft->name);
   432   g_free(jft->desc);
   436   g_free(jft->desc);
   433   g_io_channel_unref(jft->outfile);
   437   g_io_channel_unref(jft->outfile);
   434   if (jft->dir == JINGLE_FT_INCOMING)
   438   if (jft->dir == JINGLE_FT_INCOMING)