diff options
Diffstat (limited to 'src/fe-gtk/dccgui.c')
-rw-r--r-- | src/fe-gtk/dccgui.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 10ec8388..8c9dc8b4 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -88,7 +88,7 @@ struct my_dcc_send { struct session *sess; char *nick; - int maxcps; + gint64 maxcps; int passive; }; @@ -105,7 +105,7 @@ static short view_mode; /* 1=download 2=upload 3=both */ static void -proper_unit (DCC_SIZE size, char *buf, int buf_len) +proper_unit (guint64 size, char *buf, size_t buf_len) { gchar *formatted_str; GFormatSizeFlags format_flags = G_FORMAT_SIZE_DEFAULT; @@ -117,7 +117,7 @@ proper_unit (DCC_SIZE size, char *buf, int buf_len) format_flags = G_FORMAT_SIZE_IEC_UNITS; #endif - formatted_str = g_format_size_full ((guint64)size, format_flags); + formatted_str = g_format_size_full (size, format_flags); g_strlcpy (buf, formatted_str, buf_len); g_free (formatted_str); @@ -130,45 +130,45 @@ dcc_send_filereq_file (struct my_dcc_send *mdc, char *file) dcc_send (mdc->sess, mdc->nick, file, mdc->maxcps, mdc->passive); else { - free (mdc->nick); - free (mdc); + g_free (mdc->nick); + g_free (mdc); } } void fe_dcc_send_filereq (struct session *sess, char *nick, int maxcps, int passive) { - char tbuf[128]; - struct my_dcc_send *mdc; - - mdc = malloc (sizeof (*mdc)); + char* tbuf = g_strdup_printf (_("Send file to %s"), nick); + + struct my_dcc_send *mdc = g_new (struct my_dcc_send, 1); mdc->sess = sess; - mdc->nick = strdup (nick); + mdc->nick = g_strdup (nick); mdc->maxcps = maxcps; mdc->passive = passive; - snprintf (tbuf, sizeof tbuf, _("Send file to %s"), nick); gtkutil_file_req (tbuf, dcc_send_filereq_file, mdc, prefs.hex_dcc_dir, NULL, FRF_MULTIPLE|FRF_FILTERISINITIAL); + + g_free (tbuf); } static void dcc_prepare_row_chat (struct DCC *dcc, GtkListStore *store, GtkTreeIter *iter, gboolean update_only) { - static char pos[16], siz[16]; + static char pos[16], size[16]; char *date; date = ctime (&dcc->starttime); date[strlen (date) - 1] = 0; /* remove the \n */ proper_unit (dcc->pos, pos, sizeof (pos)); - proper_unit (dcc->size, siz, sizeof (siz)); + proper_unit (dcc->size, size, sizeof (size)); gtk_list_store_set (store, iter, CCOL_STATUS, _(dccstat[dcc->dccstat].name), CCOL_NICK, dcc->nick, CCOL_RECV, pos, - CCOL_SENT, siz, + CCOL_SENT, size, CCOL_START, date, CCOL_DCC, dcc, CCOL_COLOR, @@ -194,13 +194,12 @@ dcc_prepare_row_send (struct DCC *dcc, GtkListStore *store, GtkTreeIter *iter, per = (float) ((dcc->ack * 100.00) / dcc->size); proper_unit (dcc->size, size, sizeof (size)); proper_unit (dcc->pos, pos, sizeof (pos)); - snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); -/* proper_unit (dcc->ack, ack, sizeof (ack));*/ - snprintf (perc, sizeof (perc), "%.0f%%", per); + g_snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); + g_snprintf (perc, sizeof (perc), "%.0f%%", per); if (dcc->cps != 0) { to_go = (dcc->size - dcc->ack) / dcc->cps; - snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", + g_snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", to_go / 3600, (to_go / 60) % 60, to_go % 60); } else strcpy (eta, "--:--:--"); @@ -253,14 +252,14 @@ dcc_prepare_row_recv (struct DCC *dcc, GtkListStore *store, GtkTreeIter *iter, proper_unit (dcc->resumable, pos, sizeof (pos)); else proper_unit (dcc->pos, pos, sizeof (pos)); - snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); + g_snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); /* percentage recv'ed */ per = (float) ((dcc->pos * 100.00) / dcc->size); - snprintf (perc, sizeof (perc), "%.0f%%", per); + g_snprintf (perc, sizeof (perc), "%.0f%%", per); if (dcc->cps != 0) { to_go = (dcc->size - dcc->pos) / dcc->cps; - snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", + g_snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", to_go / 3600, (to_go / 60) % 60, to_go % 60); } else strcpy (eta, "--:--:--"); @@ -526,7 +525,7 @@ resume_clicked (GtkWidget * wid, gpointer none) fe_message (_("That file is not resumable."), FE_MSG_ERROR); break; case 1: - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _( "Cannot access file: %s\n" "%s.\n" "Resuming not possible."), dcc->destfile, @@ -607,7 +606,7 @@ browse_folder (char *dir) #else char buf[512]; - snprintf (buf, sizeof (buf), "file://%s", dir); + g_snprintf (buf, sizeof (buf), "file://%s", dir); fe_open_url (buf); #endif } @@ -640,7 +639,7 @@ dcc_details_populate (struct DCC *dcc) gtk_label_set_text (GTK_LABEL (dccfwin.file_label), dcc->file); /* address and port */ - snprintf (buf, sizeof (buf), "%s : %d", net_ip (dcc->addr), dcc->port); + g_snprintf (buf, sizeof (buf), "%s : %d", net_ip (dcc->addr), dcc->port); gtk_label_set_text (GTK_LABEL (dccfwin.address_label), buf); } @@ -738,7 +737,7 @@ dcc_detail_label (char *text, GtkWidget *box, int num) char buf[64]; label = gtk_label_new (NULL); - snprintf (buf, sizeof (buf), "<b>%s</b>", text); + g_snprintf (buf, sizeof (buf), "<b>%s</b>", text); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_table_attach (GTK_TABLE (box), label, 0, 1, 0 + num, 1 + num, GTK_FILL, GTK_FILL, 0, 0); |