comparison src/ft.c @ 3621:e9f66d245253

[gaim-migrate @ 3742] Give a totsize of -1 if you want the filesize to be unknown upon asking. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 10 Oct 2002 05:57:07 +0000
parents a99f6f97a3f9
children 9682c0e022c6
comparison
equal deleted inserted replaced
3620:8856bb4b284e 3621:e9f66d245253
70 int totsize; 70 int totsize;
71 int bytessent; 71 int bytessent;
72 int bytesleft; 72 int bytesleft;
73 }; 73 };
74 74
75
76
75 static int ft_choose_file(gpointer a, struct file_transfer *xfer); 77 static int ft_choose_file(gpointer a, struct file_transfer *xfer);
76 static void ft_cancel(gpointer w, struct file_transfer *xfer); 78 static void ft_cancel(gpointer w, struct file_transfer *xfer);
77 static void ft_delete(struct file_transfer *xfer); 79 static void ft_delete(struct file_transfer *xfer);
78 static void ft_callback(gpointer data, gint source, GaimInputCondition condition); 80 static void ft_callback(gpointer data, gint source, GaimInputCondition condition);
79 static void ft_nextfile(struct file_transfer *xfer); 81 static void ft_nextfile(struct file_transfer *xfer);
98 int totfiles, const char *msg) 100 int totfiles, const char *msg)
99 { 101 {
100 struct file_transfer *xfer = ft_new(FILE_TRANSFER_TYPE_RECEIVE, gc, 102 struct file_transfer *xfer = ft_new(FILE_TRANSFER_TYPE_RECEIVE, gc,
101 who); 103 who);
102 char *buf; 104 char *buf;
105 char *sizebuf;
103 static const char *sizestr[4] = { "bytes", "KB", "MB", "GB" }; 106 static const char *sizestr[4] = { "bytes", "KB", "MB", "GB" };
104 float sizemag = (float)totsize; 107 float sizemag = (float)totsize;
105 int szindex = 0; 108 int szindex = 0;
106 109
107 xfer->initname = g_strdup(initname); 110 xfer->initname = g_strdup(initname);
113 while ((szindex < 4) && (sizemag > 1024)) { 116 while ((szindex < 4) && (sizemag > 1024)) {
114 sizemag /= 1024; 117 sizemag /= 1024;
115 szindex++; 118 szindex++;
116 } 119 }
117 120
118 if (xfer->totfiles == 1) 121 if (totsize == -1)
119 buf = g_strdup_printf(_("%s requests that %s accept a file: %s (%.3g %s)"), 122 sizebuf = g_strdup_printf(_("Unkown"));
120 who, xfer->gc->username, initname,
121 sizemag, sizestr[szindex]);
122 else 123 else
123 buf = g_strdup_printf(_("%s requests that %s accept %d files: %s (%.3g %s)"), 124 sizebuf = g_strdup_printf("%.3g %s", sizemag, sizestr[szindex]);
125
126 if (xfer->totfiles == 1) {
127 buf = g_strdup_printf(_("%s requests that %s accept a file: %s (%s)"),
128 who, xfer->gc->username, initname, sizebuf);
129 } else {
130 buf = g_strdup_printf(_("%s requests that %s accept %d files: %s (%s)"),
124 who, xfer->gc->username, xfer->totfiles, 131 who, xfer->gc->username, xfer->totfiles,
125 initname, sizemag, sizestr[szindex]); 132 initname, sizebuf);
133 }
134
135 g_free(sizebuf);
126 136
127 if (msg) { 137 if (msg) {
128 char *newmsg = g_strconcat(buf, ": ", msg, NULL); 138 char *newmsg = g_strconcat(buf, ": ", msg, NULL);
129 g_free(buf); 139 g_free(buf);
130 buf = newmsg; 140 buf = newmsg;