+2004-07-08 [colin] 0.9.11cvs17.16
+
+ * src/noticeview.c
+ * src/noticeview.h
+ Add an optional second button
+ * src/messageview.c
+ * src/pop.c
+ * src/pop.h
+ Don't delete partially received mails after a certain
+ time; rather, let the user decide.
+
2004-07-08 [colin] 0.9.11cvs17.15
* src/common/smtp.h
( cvs diff -u -r 1.149.2.7 -r 1.149.2.8 src/inc.c; cvs diff -u -r 1.94.2.8 -r 1.94.2.9 src/messageview.c; cvs diff -u -r 1.56.2.4 -r 1.56.2.5 src/pop.c; cvs diff -u -r 1.17.2.3 -r 1.17.2.4 src/pop.h; cvs diff -u -r 1.150.2.4 -r 1.150.2.5 src/procmsg.c; ) > 0.9.11cvs17.13.patchset
( cvs diff -u -r 1.94.2.9 -r 1.94.2.11 src/messageview.c; cvs diff -u -r 1.11.2.2 -r 1.11.2.4 src/common/smtp.c; ) > 0.9.11cvs17.14.patchset
( cvs diff -u -r 1.6.2.1 -r 1.6.2.2 src/common/smtp.h; ) > 0.9.11cvs17.15.patchset
+( cvs diff -u -r 1.94.2.11 -r 1.94.2.12 src/messageview.c; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/noticeview.c; cvs diff -u -r 1.3.8.1 -r 1.3.8.2 src/noticeview.h; cvs diff -u -r 1.56.2.5 -r 1.56.2.6 src/pop.c; cvs diff -u -r 1.17.2.4 -r 1.17.2.5 src/pop.h; ) > 0.9.11cvs17.16.patchset
MICRO_VERSION=11
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=17.15
+EXTRA_VERSION=17.16
EXTRA_RELEASE=
if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
MsgInfo *msginfo);
static void partial_recv_dload_clicked (NoticeView *noticeview,
MsgInfo *msginfo);
+static void partial_recv_del_clicked (NoticeView *noticeview,
+ MsgInfo *msginfo);
static void save_as_cb (gpointer data,
guint action,
GtkWidget *widget);
static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
{
gchar *text = NULL;
- if (!msginfo->planned_download) {
+ if (!pop3_msg_in_uidl_list(msginfo->account_server, msginfo->account_login,
+ msginfo->partial_recv))
+ return;
+ if (msginfo->planned_download == 0) {
text = g_strdup_printf(_("This message has been partially "
- "retrieved; it is %s large."),
+ "retrieved;\n it is %s large."),
to_human_readable(
(off_t)(msginfo->total_size)));
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 {
+ } else if (msginfo->planned_download == 1) {
text = g_strdup_printf(_("This message has been partially "
"retrieved and is planned for "
- "download; it is %s large."),
+ "download;\n it is %s large."),
to_human_readable(
(off_t)(msginfo->total_size)));
noticeview_set_text(noticeview, text);
- noticeview_set_button_text(noticeview, NULL);
+ 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) {
+ 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)));
+
+ noticeview_set_text(noticeview, text);
+ noticeview_set_button_text(noticeview, _("Mark for download"));
+ 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);
}
g_free(file);
}
+static void partial_recv_del_clicked(NoticeView *noticeview,
+ MsgInfo *msginfo)
+{
+ MsgInfo *tmpmsginfo;
+ gchar *file;
+
+ file = procmsg_get_message_file_path(msginfo);
+ if (!file) {
+ g_warning("can't get message file path.\n");
+ return;
+ }
+
+ tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
+ tmpmsginfo->folder = msginfo->folder;
+ tmpmsginfo->msgnum = msginfo->msgnum;
+
+ if (pop3_mark_for_delete(tmpmsginfo->account_server,
+ tmpmsginfo->account_login,
+ tmpmsginfo->partial_recv, file) == 0) {
+ msginfo->planned_download = -1;
+ partial_recv_show(noticeview, msginfo);
+ }
+
+ procmsg_msginfo_free(tmpmsginfo);
+ g_free(file);
+}
+
static void select_account_cb(GtkWidget *w, gpointer data)
{
*(gint*)data = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(w)));
#include "noticeview.h"
static void noticeview_button_pressed (GtkButton *button, NoticeView *noticeview);
+static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview);
NoticeView *noticeview_create(MainWindow *mainwin)
{
GtkWidget *icon;
GtkWidget *text;
GtkWidget *widget;
+ GtkWidget *widget2;
debug_print("Creating notice view...\n");
noticeview = g_new0(NoticeView, 1);
(gpointer) noticeview);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
+ widget2 = gtk_button_new_with_label("");
+ g_signal_connect(G_OBJECT(widget2), "clicked",
+ G_CALLBACK(noticeview_2ndbutton_pressed),
+ (gpointer) noticeview);
+ gtk_box_pack_start(GTK_BOX(hbox), widget2, FALSE, FALSE, 4);
+
noticeview->vbox = vbox;
noticeview->hsep = hsep;
noticeview->hbox = hbox;
noticeview->icon = icon;
noticeview->text = text;
noticeview->button = widget;
+ noticeview->button2 = widget2;
noticeview->visible = TRUE;
}
}
+void noticeview_set_2ndbutton_text(NoticeView *noticeview, const char *text)
+{
+ g_return_if_fail(noticeview);
+
+ if (text != NULL) {
+ gtk_label_set_text
+ (GTK_LABEL(GTK_BIN(noticeview->button2)->child), text);
+ gtk_widget_show(noticeview->button2);
+ } else
+ gtk_widget_hide(noticeview->button2);
+}
+
+void noticeview_set_2ndbutton_press_callback(NoticeView *noticeview,
+ GtkSignalFunc callback,
+ gpointer *user_data)
+{
+ noticeview->press2 = (void (*) (NoticeView *, gpointer)) callback;
+ noticeview->user_data2 = user_data;
+}
+
+static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview)
+{
+ if (noticeview->press2) {
+ noticeview->press2(noticeview, noticeview->user_data2);
+ }
+}
+
void noticeview_set_icon(NoticeView *noticeview, StockPixmap icon)
{
GdkPixmap *pixmap;
GtkWidget *icon;
GtkWidget *text;
GtkWidget *button;
+ GtkWidget *button2;
GtkWidget *window;
gboolean visible;
gpointer user_data;
+ gpointer user_data2;
void (*press) (NoticeView *, gpointer user_data);
+ void (*press2) (NoticeView *, gpointer user_data);
};
NoticeView *noticeview_create (MainWindow *mainwin);
void noticeview_set_button_text
(NoticeView *noticeview,
const gchar *text);
+void noticeview_set_2ndbutton_text
+ (NoticeView *noticeview,
+ const gchar *text);
gboolean noticeview_is_visible (NoticeView *noticeview);
void noticeview_show (NoticeView *noticeview);
void noticeview_hide (NoticeView *noticeview);
(NoticeView *noticeview,
GtkSignalFunc callback,
gpointer *user_data);
+void noticeview_set_2ndbutton_press_callback
+ (NoticeView *noticeview,
+ GtkSignalFunc callback,
+ gpointer *user_data);
#endif /* NOTICEVIEW_H__ */
return;
}
+int pop3_msg_in_uidl_list(const gchar *server, const gchar *login,
+ const gchar *muidl)
+{
+ gchar *path;
+ FILE *fp;
+ gchar buf[POPBUFSIZE];
+ gchar uidl[POPBUFSIZE];
+ time_t recv_time;
+ time_t now;
+ gint partial_recv;
+
+ path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "uidl", G_DIR_SEPARATOR_S, server,
+ "-", login, NULL);
+ if ((fp = fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
+ g_free(path);
+ path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "uidl-", server,
+ "-", login, NULL);
+ if ((fp = fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
+ g_free(path);
+ return FALSE;
+ }
+ }
+ g_free(path);
+
+ now = time(NULL);
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ gchar tmp[POPBUFSIZE];
+ strretchomp(buf);
+ recv_time = RECV_TIME_NONE;
+ partial_recv = 0;
+
+ if (sscanf(buf, "%s\t%ld\t%s", uidl, &recv_time, &tmp) < 2) {
+ if (sscanf(buf, "%s", uidl) != 1)
+ continue;
+ else {
+ recv_time = now;
+ }
+ }
+ if (!strcmp(uidl, muidl)) {
+ fclose(fp);
+ return TRUE;
+ }
+ }
+
+ fclose(fp);
+ return FALSE;
+}
+
static gchar *pop3_get_filename_for_partial_mail(Pop3Session *session,
gchar *muidl)
{
return result;
}
-int pop3_mark_for_download(const gchar *server, const gchar *login,
- const gchar *muidl, const gchar *filename)
+#define DOWNLOAD_MAIL 1
+#define DELETE_MAIL 2
+static int pop3_mark_mail(const gchar *server, const gchar *login,
+ const gchar *muidl, const gchar *filename,
+ int download)
{
gchar *path;
gchar *pathnew;
time_t recv_time;
time_t now;
int len;
+ int start = TRUE;
gchar partial_recv[POPBUFSIZE];
-
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl", G_DIR_SEPARATOR_S, server,
"-", login, NULL);
uidl, recv_time, partial_recv);
} else {
fprintf(fpnew, "%s\t%ld\t%s\n",
- uidl, recv_time, filename);
+ uidl, recv_time,
+ download==DOWNLOAD_MAIL?filename:"0");
}
}
fclose(fpnew);
return -1;
}
- fprintf(fpnew, "SC-Marked-For-Download: 1\n");
while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
+ if (start) {
+ start = FALSE;
+ fprintf(fpnew, "SC-Marked-For-Download: %d\n", download);
+ printf("buf '%s'\n", buf);
+ if(!strncmp(buf, "SC-Marked-For-Download:",
+ strlen("SC-Marked-For-Download:"))) {
+ fprintf(fpnew, "%s", buf+strlen("SC-Marked-For-Download: x\n"));
+ continue;
+ }
+ }
fprintf(fpnew, "%s", buf);
}
fclose(fpnew);
return 0;
}
+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);
+}
+
+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);
+}
+
gint pop3_write_uidl_list(Pop3Session *session)
{
gchar *path;
if (ac->rmmail &&
msg->recv_time != RECV_TIME_NONE &&
msg->recv_time != RECV_TIME_KEEP &&
+ msg->partial_recv == 0 &&
session->current_time - msg->recv_time >=
ac->msg_leave_time * 24 * 60 * 60) {
- if (msg->partial_recv == 0) {
- log_message
- (_("POP3: Deleting expired message "
- "%d\n"), session->cur_msg);
- pop3_delete_send(session);
- return POP3_DELETE;
- } else if (session->current_time - msg->recv_time >=
- 5 * 24 * 60 * 60) {
- log_message
- (_("POP3: Deleting too big expired "
- "message %d\n"), session->cur_msg);
- pop3_delete_send(session);
- return POP3_DELETE;
- }
+ log_message
+ (_("POP3: Deleting expired message "
+ "%d\n"), session->cur_msg);
+ pop3_delete_send(session);
+ return POP3_DELETE;
}
if (size_limit_over) {
Session *pop3_session_new (PrefsAccount *account);
void pop3_get_uidl_table (PrefsAccount *account, Pop3Session *session);
gint pop3_write_uidl_list (Pop3Session *session);
+gint pop3_msg_in_uidl_list (const gchar *server,
+ const gchar *login,
+ const gchar *uidl);
int pop3_mark_for_download (const gchar *server,
const gchar *login,
const gchar *uidl,
const gchar *filename);
+int pop3_mark_for_delete (const gchar *server,
+ const gchar *login,
+ const gchar *uidl,
+ const gchar *filename);
#endif /* __POP_H__ */