static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
{
gchar *text = NULL;
+ gchar *button1 = NULL;
+ gchar *button2 = NULL;
+ void *button1_cb = NULL;
+ void *button2_cb = NULL;
+
if (!pop3_msg_in_uidl_list(msginfo->account_server, msginfo->account_login,
msginfo->partial_recv))
return;
- if (msginfo->planned_download == 0) {
+ switch (msginfo->planned_download) {
+ case 0: /* unknown yet */
text = g_strdup_printf(_("This message has been partially "
- "retrieved;\n it is %s large."),
- to_human_readable(
- (off_t)(msginfo->total_size)));
-
- noticeview_set_text(noticeview, text);
- g_free(text);
- noticeview_set_button_text(noticeview, _("Mark for download"));
- noticeview_set_button_press_callback(noticeview,
- GTK_SIGNAL_FUNC(partial_recv_dload_clicked),
- (gpointer) msginfo);
- noticeview_set_2ndbutton_text(noticeview, _("Mark for deletion"));
- noticeview_set_2ndbutton_press_callback(noticeview,
- GTK_SIGNAL_FUNC(partial_recv_del_clicked),
- (gpointer) msginfo);
- noticeview_show(noticeview);
- } else if (msginfo->planned_download == 1) {
+ "retrieved;\nit is %s large."),
+ to_human_readable(
+ (off_t)(msginfo->total_size)));
+ button1 = _("Mark for download");
+ button2 = _("Mark for deletion");
+ button1_cb = partial_recv_dload_clicked;
+ button2_cb = partial_recv_del_clicked;
+ break;
+ case 1:
text = g_strdup_printf(_("This message has been partially "
- "retrieved and is planned for "
- "download;\n it is %s large."),
- to_human_readable(
- (off_t)(msginfo->total_size)));
-
- noticeview_set_text(noticeview, text);
- noticeview_set_button_text(noticeview, _("Mark for deletion"));
- noticeview_set_2ndbutton_text(noticeview, NULL);
- noticeview_set_button_press_callback(noticeview,
- GTK_SIGNAL_FUNC(partial_recv_del_clicked),
- (gpointer) msginfo);
- g_free(text);
- noticeview_show(noticeview);
- } else if (msginfo->planned_download == -1) {
+ "retrieved and is planned for "
+ "download;\nit is %s large."),
+ to_human_readable(
+ (off_t)(msginfo->total_size)));
+ button1 = _("Mark for deletion");
+ button1_cb = partial_recv_del_clicked;
+ break;
+ case -1:
text = g_strdup_printf(_("This message has been partially "
- "retrieved and is planned for "
- "deletion;\n it is %s large."),
- to_human_readable(
- (off_t)(msginfo->total_size)));
+ "retrieved and is planned for "
+ "deletion;\nit is %s large."),
+ to_human_readable(
+ (off_t)(msginfo->total_size)));
+ button1 = _("Mark for download");
+ button1_cb = partial_recv_dload_clicked;
+ break;
+ default:
+ return;
+ }
+
+ noticeview_set_text(noticeview, text);
+ g_free(text);
+ noticeview_set_button_text(noticeview, button1);
+ noticeview_set_button_press_callback(noticeview,
+ GTK_SIGNAL_FUNC(button1_cb), (gpointer) msginfo);
- noticeview_set_text(noticeview, text);
- noticeview_set_button_text(noticeview, _("Mark for download"));
+ if (button2 && button2_cb) {
+ noticeview_set_2ndbutton_text(noticeview, button2);
+ noticeview_set_2ndbutton_press_callback(noticeview,
+ GTK_SIGNAL_FUNC(button2_cb), (gpointer) msginfo);
+ } else {
noticeview_set_2ndbutton_text(noticeview, NULL);
- noticeview_set_button_press_callback(noticeview,
- GTK_SIGNAL_FUNC(partial_recv_dload_clicked),
- (gpointer) msginfo);
- g_free(text);
- noticeview_show(noticeview);
}
+
+ noticeview_show(noticeview);
}
static void partial_recv_dload_clicked(NoticeView *noticeview,
#define DOWNLOAD_MAIL 1
#define DELETE_MAIL 2
-static int pop3_mark_mail(const gchar *server, const gchar *login,
+static int pop3_uidl_mark_mail(const gchar *server, const gchar *login,
const gchar *muidl, const gchar *filename,
int download)
{
while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
if (start) {
start = FALSE;
- fprintf(fpnew, "SC-Marked-For-Download: %d\n", download);
+ fprintf(fpnew, "SC-Marked-For-Download: %d\n",
+ download);
printf("buf '%s'\n", buf);
- if(!strncmp(buf, "SC-Marked-For-Download:",
+ if(strlen(buf) > strlen("SC-Marked-For-Download: x\n")
+ && !strncmp(buf, "SC-Marked-For-Download:",
strlen("SC-Marked-For-Download:"))) {
- fprintf(fpnew, "%s", buf+strlen("SC-Marked-For-Download: x\n"));
+ fprintf(fpnew, "%s",
+ buf+strlen("SC-Marked-For-Download: x\n"));
continue;
}
}
int pop3_mark_for_delete(const gchar *server, const gchar *login,
const gchar *muidl, const gchar *filename)
{
- return pop3_mark_mail(server, login, muidl, filename, DELETE_MAIL);
+ return pop3_uidl_mark_mail(server, login, muidl, filename,
+ DELETE_MAIL);
}
int pop3_mark_for_download(const gchar *server, const gchar *login,
const gchar *muidl, const gchar *filename)
{
- return pop3_mark_mail(server, login, muidl, filename, DOWNLOAD_MAIL);
+ return pop3_uidl_mark_mail(server, login, muidl, filename,
+ DOWNLOAD_MAIL);
}
gint pop3_write_uidl_list(Pop3Session *session)