Patch: Elm ME+ 2.5 PLalpha54 -> Elm ME+ 2.5 PLalpha60 [11/13] (3/4)
From
Kari Hurtta@21:1/5 to
All on Thu Nov 24 20:32:01 2022
[continued from previous message]
! if (c >= 0 && c < sync_store_COUNT) {
! messages2[c]++;
!
! if (c >= 0 && c < sync_store_COUNT &&
! ! keep_this[c]) {
!
! if (isoff(storage->headers[j]->status, UNREAD)
! && (storage->headers[j]->exit_disposition == UNSET)) {
!
! marked_read_x[c]++;
! }
! }
! }
! }
! }
! }
}
+ for (c = 0; c < sync_store_COUNT; c++) {
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: class %s: %d messages (%d messages after class translation), %d marked read\n",
! sync_store_config[c].text,
! messages1[c],
! messages2[c],
! marked_read_x[c]));
!
! if (marked_read_x[c] &&
! 0 == keep_this[c]
! ) {
! answer = (always_store ?
! *def_ans_yes : *def_ans_no); /* default answer */
! if(l_ask_store && prompt_area) {
! int def = answer;
!
! struct string * message = NULL;
! againR:
! switch (c) {
!
! case sync_store_received:
!
!
! /* NOTICE: prompt_letter may return EOF */
! if (marked_read_x[c] == 1)
! answer = prompt_letter(0,"",def,
! PROMPT_yesno|PROMPT_cancel|
! PROMPT_redraw_mark|PROMPT_ctrlL,
! prompt_area,
! CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveMoveMessage,
! "Move read message to \"received\" folder? (%c/%c) "),
! *def_ans_yes, *def_ans_no);
! else
! answer = prompt_letter(0,"",def,
! PROMPT_yesno|PROMPT_cancel|
! PROMPT_redraw_mark|PROMPT_ctrlL,
! prompt_area,
! CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveMoveMessages,
! "Move read messages to \"received\" folder? (%c/%c) "),
! *def_ans_yes, *def_ans_no);
! break;
! case sync_store_dnsmail:
! if (!message)
! message = read_message_text(c,(marked_read_x[c] != 1));
! if (!message)
! break;
!
! if (keep_this[sync_store_received]) {
! answer = prompt_letter(0,"",def,
! PROMPT_yesno|PROMPT_cancel|
! PROMPT_redraw_mark|PROMPT_ctrlL,
! prompt_area,
! CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveMoveX,
! "Move %S to \"%s\" folder? (%c/%c) "),
! message,
! sync_store_config[c].text,
! *def_ans_yes, *def_ans_no);
! } else {
! answer = prompt_letter(0,"r",def,
! PROMPT_yesno|PROMPT_cancel|
! PROMPT_redraw_mark|PROMPT_ctrlL,
! prompt_area,
! CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveMoveXRec,
! "Move %S to \"%s\" or r)eceived folder? (%c/%c/r) "),
! message,
! sync_store_config[c].text,
! *def_ans_yes, *def_ans_no);
! }
!
! break;
!
! case sync_store_COUNT:
! break;
! }
!
! if (answer == ('L'&31) || answer == REDRAW_MARK) {
! menu_ClearScreen(page); /* Reset possible redraw flag */
!
! /* Call refresh routines of children */
! menu_redraw_children(page);
!
! if (menu_need_redraw(prompt_area))
! menu_ClearScreen(prompt_area); /* but clear redraw mark from prompt_area*/
!
! delay_redraw++; /* Can't trigger redraw yet... */ ! goto againR;
! }
! if (message)
! free_string(&message);
!
! if (TERMCH_interrupt_char == answer) {
! return_value = sync_mbox_cancel;
! goto cleanup;
! }
!
!
! if (answer == EOF) {
! return_value = sync_mbox_EOF;
! goto cleanup;
! }
!
! if (answer == *def_ans_no)
! need_keep_x[c] = 1;
!
! }
! DPRINT(Debug,4,(&Debug,
! "sync_mbox: move messages to %s folder? %c\n",
! sync_store_config[c].text,
! answer));
! if (answer == *def_ans_yes) {
! need_move_x[c] = 1;
! ask_unread = 1;
! } else if (answer == 'r') {
! need_move_x[c] = -1;
! ask_unread = 1;
! }
!
! } else {
! ask_unread = 1;
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: class %s: No messages marked to read (or disposition is set), or class keeps messages\n",
! sync_store_config[c].text
! ));
! }
! }
!
! sc = get_storage_count(mailbox);
! for (i = 0; i < sc; i++) {
! struct current_storage *storage = get_storage(mailbox,i);
! int j;
!
! int c1 = 0;
! int skipped = 0;
!
! if (!storage)
! continue;
!
! if (storage->headers) {
! for (j = 0; j < storage->message_count; j++) {
!
! if ((storage->headers[j] &&
! isoff(storage->headers[j]->status, UNREAD))
! && (storage->headers[j]->exit_disposition == UNSET)) {
!
! c = header_to_class(storage->headers[j]);
!
! if (c >= 0 && c < sync_store_COUNT &&
! keep_this[c] < 0) {
!
! c = sync_store_received;
}
! if (c >= 0 && c < sync_store_COUNT) {
! if (need_move_x[c] > 0) {
! storage->headers[j]->exit_disposition =
! sync_store_config[c].store;
!
! sync_store_list[c].have_store = 1;
!
! to_store++;
! c1++;
! } else if (need_move_x[c] < 0) {
! storage->headers[j]->exit_disposition =
! sync_store_config[sync_store_received].store;
! sync_store_list[sync_store_received].have_store = 1;
! to_store++;
! c1++;
! } else
! goto need_keep;
! } else {
! need_keep:
! storage->headers[j]->exit_disposition = KEEP;
! to_keep++;
! c1++;
! }
! } else {
! skipped ++;
! }
! }
! }
!
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: mailbox #%d: %d (read) messages marked to keep or store; %d other messages skipped\n",
! i,c1,skipped));
}
!
/* If we asked the user if read messages should be stored,
* and if the user wanted them kept instead, then certainly the
* user would want the unread messages kept as well.
*/
! if (ask_unread) {
! for (c = 0; c < sync_store_COUNT; c++) {
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: class %s: need %s unread messages\n",
! sync_store_config[c].text,
! need_keep_x[c] ? "keep" : "ask about"));
! }
! }
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: %s ask about unread messages\n",
! ask_unread ? "will" : "will not"));
!
! sc = get_storage_count(mailbox);
! for (i = 0; i < sc; i++) {
! struct current_storage *storage = get_storage(mailbox,i);
! int j;
! int c1 = 0;
! int skipped = 0;
!
! if (!storage)
! continue;
!
! if (storage->headers) {
! for (j = 0; j < storage->message_count; j++) {
! if ((storage->headers[j] &&
! ison(storage->headers[j]->status, UNREAD))
! && (storage->headers[j]->
! exit_disposition == UNSET)) {
! c = header_to_class(storage->headers[j]);
!
! if (c >= 0 && c < sync_store_COUNT &&
! keep_this[c] < 0) {
!
! c = sync_store_received;
! }
!
!
! if (c >= 0 && c < sync_store_COUNT &&
! need_keep_x[c]) {
storage->headers[j]->exit_disposition = KEEP;
to_keep++;
! c1++;
! } else if (!ask_unread) {
+ /* If we not ask about unread messages,
+ we keep them
+ */
+
+ storage->headers[j]->exit_disposition = KEEP;
+ to_keep++;
+ c1++;
+
+ } else {
+ skipped ++;
+ }
+ } else {
+ skipped ++;
+ }
+ }
+
}
!
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: mailbox #%d: %d (unread) messages marked to keep; %d other messages skipped\n",
! i,c1,skipped));
! }
!
!
! if (ask_unread) {
int marked_unread = 0;
+ int marked_unread_x[sync_store_COUNT];
+ int move_unread_x[sync_store_COUNT];
+
+ for (c = 0; c < sync_store_COUNT; c++) {
+ marked_unread_x[c] = 0;
+ move_unread_x[c] = 0;
+ }
/* Determine if unread messages are to be kept */
!
sc = get_storage_count(mailbox);
for (i = 0; i < sc; i++) {
struct current_storage *storage = get_storage(mailbox,i);
int j;
+
+ int skipped = 0;
+ int c1 = 0;
if (!storage)
continue;
!
! if (storage->headers) {
!
! for (j=0; j<storage->message_count; j++) {
if((storage->headers[j] &&
ison(storage->headers[j]->status, UNREAD))
&& (storage->headers[j]->
! exit_disposition == UNSET)) {
!
! c = header_to_class(storage->headers[j]);
!
! if (c >= 0 && c < sync_store_COUNT &&
! keep_this[c] < 0) {
!
! c = sync_store_received;
! }
!
!
! if (c >= 0 && c < sync_store_COUNT) {
! marked_unread_x[c] ++;
! }
!
!
marked_unread++;
! c1++;
! } else {
! skipped++;
! }
! }
! }
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: mailbox #%d: %d (unread) messages to consider; %d other messages skipped\n",
! i,c1,skipped));
! }
!
! if (marked_unread) {
! int class_count = 0;
! enum sync_store_class only_class = sync_store_COUNT;
!
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: %d unread messsages (and no disposition)\n",
! marked_unread));
!
! for (c = 0; c < sync_store_COUNT; c++) {
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: class %s: %d unread messsages (and no disposition)\n",
! sync_store_config[c].text,
! marked_unread_x[c]));
!
! if (marked_unread_x[c] > 0) {
! class_count ++;
! only_class = c;
! }
! }
!
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: %d classes with unread messsages (and no disposition)",
! class_count));
!
! if (1 == class_count && only_class >= 0 && only_class < sync_store_COUNT) {
! DPRINT(Debug,3,(&Debug,", only class %s",
! sync_store_config[only_class].text)); ! }
! DPRINT(Debug,3,(&Debug, "\n"));
!
!
answer = (always_keep ?
*def_ans_yes : *def_ans_no); /* default answer */
!
!
! if (l_ask_keep && prompt_area) {
int def = answer;
+
+ struct string * message = NULL;
againK:
/* NOTICE: prompt_letter may return EOF */
! if (1 == class_count && only_class >= 0 && only_class < sync_store_COUNT) {
! if (!message)
! message = unread_message_text(only_class,marked_unread_x[c] != 1);
! if (have_incoming) {
answer = prompt_letter(0,"",def,
PROMPT_yesno|PROMPT_cancel|
PROMPT_redraw_mark|PROMPT_ctrlL,
prompt_area,
CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveKeepX,
! "Keep %S in incoming mailbox? (%c/%c) "),
! message,
*def_ans_yes, *def_ans_no);
!
! } else if (current_mailbox_name) {
answer = prompt_letter(0,"",def,
PROMPT_yesno|PROMPT_cancel|
PROMPT_redraw_mark|PROMPT_ctrlL,
prompt_area,
! CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveKeepXName,
! "Keep %S in %S mailbox? (%c/%c) "),
! message,
current_mailbox_name,
*def_ans_yes, *def_ans_no);
! } else {
answer = prompt_letter(0,"",def,
PROMPT_yesno|PROMPT_cancel|
PROMPT_redraw_mark|PROMPT_ctrlL,
prompt_area,
CATGETS(elm_msg_cat, ElmSet,
! ElmLeaveKeepXCount,
! "Keep %S in mailbox (%d mailboxes)? (%c/%c) "),
! message,
mailbox_count,
*def_ans_yes, *def_ans_no);
! }
+ if (answer != ('L'&31) && answer != REDRAW_MARK && + TERMCH_interrupt_char != answer && answer != EOF) {
+
+ DPRINT(Debug,4,(&Debug,
+ "sync_mbox: keep %s unread messages? %c\n",
+ sync_store_config[only_class].text,
+ answer));
+ }
+
+ if (answer == *def_ans_no)
+ move_unread_x[only_class] = 1;
+ else if (answer == *def_ans_yes)
+ move_unread_x[only_class] = 0;
+
+ } else {
+
+ if (have_incoming) {
+ if (marked_unread == 1) {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet,
+ ElmLeaveKeepMessage,
+ "Keep unread message in incoming mailbox? (%c/%c) "),
+ *def_ans_yes, *def_ans_no);
+ } else {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet, ElmLeaveKeepMessages,
+ "Keep unread messages in incoming mailbox? (%c/%c) "),
+ *def_ans_yes, *def_ans_no);
+ }
+ } else if (current_mailbox_name) {
+ if (marked_unread == 1) {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet,
+ ElmLeaveKeepMessageName,
+ "Keep unread message in %S mailbox? (%c/%c) "),
+ current_mailbox_name,
+ *def_ans_yes, *def_ans_no);
+ } else {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet, ElmLeaveKeepMessagesName,
+ "Keep unread messages in %S mailbox? (%c/%c) "),
+ current_mailbox_name,
+ *def_ans_yes, *def_ans_no);
+
+ }
+
+ } else {
+ if (marked_unread == 1) {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet,
+ ElmLeaveKeepMessageCount,
+ "Keep unread message in mailbox (%d mailboxes)? (%c/%c) "),
+ mailbox_count,
+ *def_ans_yes, *def_ans_no);
+ } else {
+ answer = prompt_letter(0,"",def,
+ PROMPT_yesno|PROMPT_cancel|
+ PROMPT_redraw_mark|PROMPT_ctrlL,
+ prompt_area,
+ CATGETS(elm_msg_cat, ElmSet, ElmLeaveKeepMessagesCount,
+ "Keep unread messages in mailbox (%d mailboxes)? (%c/%c) "),
+ mailbox_count,
+ *def_ans_yes, *def_ans_no);
+ }
+ }
+
+ if (answer != ('L'&31) && answer != REDRAW_MARK && + TERMCH_interrupt_char != answer && answer != EOF) {
+ DPRINT(Debug,4,(&Debug,
+ "sync_mbox: keep unread messages? %c\n",
+ answer));
+ }
+
+ for (c = 0; c < sync_store_COUNT; c++) {
+ if (answer == *def_ans_no)
+ move_unread_x[c] = 1;
+ else if (answer == *def_ans_yes)
+ move_unread_x[c] = 0;
+ }
+ }
+
if (answer == ('L'&31) || answer == REDRAW_MARK) {
menu_ClearScreen(page); /* Reset possible redraw flag */
!
/* Call refresh routines of children */
menu_redraw_children(page);
if (menu_need_redraw(prompt_area))
menu_ClearScreen(prompt_area); /* but clear redraw mark from prompt_area*/
!
delay_redraw++; /* Can't trigger redraw yet... */ !
goto againK;
}
+ if (message)
+ free_string(&message);
+
+ if (TERMCH_interrupt_char == answer) {
+ return_value = sync_mbox_cancel;
+ goto cleanup;
+ }
+
+
if (answer == EOF) {
return_value = sync_mbox_EOF;
goto cleanup;
}
!
}
!
sc = get_storage_count(mailbox);
for (i = 0; i < sc; i++) {
struct current_storage *storage =
get_storage(mailbox,i);
!
! int c1 = 0;
! int skipped = 0;
!
if (!storage)
continue;
!
! if (storage->headers) {
! int j;
!
for (j = 0; j < storage->message_count; j++) {
! if ((storage->headers[j] &&
! ison(storage->headers[j]->status, UNREAD)) ! && (storage->headers[j]->
! exit_disposition == UNSET)) {
!
! c = header_to_class(storage->headers[j]);
!
! if (c >= 0 && c < sync_store_COUNT) {
! if (keep_this[c] < 0) {
! c = sync_store_received;
! }
! }
!
! if (c >= 0 && c < sync_store_COUNT &&
! move_unread_x[only_class]) {
!
! if (need_move_x[c] < 0) {
! storage->headers[j]->exit_disposition =
! sync_store_config[sync_store_received].store;
! } else {
! storage->headers[j]->exit_disposition =
! sync_store_config[c].store;
! }
!
! sync_store_list[c].have_store = 1;
to_store++;
! c1++;
} else {
storage->headers[j]->
exit_disposition = KEEP;
! to_keep++;
! c1++;
}
+ } else {
+ skipped ++;
}
}
!
! }
!
DPRINT(Debug,3,(&Debug,
! "sync_mbox: mailbox #%d: %d (unread) messages marked to keep or store; %d other messages skipped\n",
! i,c1,skipped));
!
}
} else {
DPRINT(Debug,3,(&Debug,
! "sync_mbox: No messages marked to unread (or disposition is set)\n"));
!
}
}
}
+
}
!
! sc = get_storage_count(mailbox);
! for (i = 0; i < sc; i++) {
! int c1 = 0;
! int handled = 0;
! struct current_storage *storage =
! get_storage(mailbox,i);
!
! if (!storage)
! continue;
!
! if (storage->headers) {
! int j;
!
! for (j = 0; j < storage->message_count; j++) {
!
! if (UNSET == storage->headers[j]->exit_disposition) {
! storage->headers[j]->exit_disposition = KEEP;
! to_keep++;
! c1++;
! } else {
! handled++;
! }
! }
! }
!
! DPRINT(Debug,3,(&Debug,
! "sync_mbox: mailbox #%d: %d unhandled messages marked to keep; %d other messages handled already\n",
! i,c1,handled));
! }
!
! DPRINT(Debug,3,(&Debug, "sync_mbox: Messages to store: %d\n", to_store));
! DPRINT(Debug,3,(&Debug, "sync_mbox: Messages to keep: %d (+ %d hide)\n",
to_keep, to_hide));
/* ================================================================ */ ***************
*** 1524,1530 ****
MoveCursor(LINES-1, 0);
Raw(OFF);
DPRINT(Debug,1,(&Debug,
! "Error: %d to delete + %d to store + %d to keep + %d to ignore != %d message cnt\n",
to_delete, to_store, to_keep, to_ignore,
get_message_count(mailbox)));
--- 2436,2442 ----
MoveCursor(LINES-1, 0);
Raw(OFF);
DPRINT(Debug,1,(&Debug,
! "sync_mbox: Error: %d to delete + %d to store + %d to keep + %d to ignore != %d message cnt\n",
to_delete, to_store, to_keep, to_ignore,
get_message_count(mailbox)));
***************
*** 1544,1550 ****
struct current_storage *storage = get_storage(mailbox,i);
int j;
! if(!resyncing && storage && storage->headers) {
for (j = 0; j < storage->message_count; j++) {
if (storage->headers[j] &&
ison(storage->headers[j]->status, NEW)) {
--- 2456,2462 ----
struct current_storage *storage = get_storage(mailbox,i);
int j;
! if (!resyncing && storage && storage->headers) {
for (j = 0; j < storage->message_count; j++) {
if (storage->headers[j] &&
ison(storage->headers[j]->status, NEW)) {
***************
*** 1576,1584 ****
num_chgd_status++;
}
! if(!to_delete && !to_store && !num_chgd_status && !resyncing) {
!