Improve personal Mail Scan

This commit is contained in:
Andrew Pamment 2018-02-23 14:27:36 +10:00
parent a3476238d4
commit 7ca1148ff8
3 changed files with 140 additions and 51 deletions

View File

@ -23,6 +23,18 @@ LINE: 277 NEW
OLDSTRING: (NONE)
NEWSTRING: "\r\nScan for new personal mail? (Y/N/S): "
LINE: 278 NEW
OLDSTRING: (NONE)
NEWSTRING: "\e[1;32mConference: \e[1;37m%d. %s\e[0m\r\n"
LINE: 279 NEW
OLDSTRING: (NONE)
NEWSTRING: "\e[1;32m Area: \e[1;37m%d. %s \e[1;33m(%d New Messages)\e[0m\r\n\r\n"
LINE: 280 NEW
OLDSTRING: (NONE)
NEWSTRING: "Read Now ? (Y / N): "
Changes from v0.8-alpha -> v0.9-alpha
--------------------------------------------------------------
LINE: 255 NEW

View File

@ -275,3 +275,6 @@ File exists!\r\n
\r\n\e[1;31mError executing archiver.\r\n\e[0m
\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m
\r\nScan for new personal mail? (Y/N/S):
\e[1;32mConference: \e[1;37m%d. %s\e[0m\r\n
\e[1;32m Area: \e[1;37m%d. %s \e[1;33m(%d New Messages)\e[0m\r\n\r\n
Read Now ? (Y / N):

View File

@ -1686,6 +1686,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
if (tolower(c) == 'r') {
JAM_CloseMB(jb);
free(jb);
jb = NULL;
if (user->sec_level < conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->write_sec_level) {
s_printf(get_string(113));
} else {
@ -1976,6 +1977,11 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
msg_line_count = 0;
}
if (jb != NULL) {
JAM_CloseMB(jb);
free(jb);
}
if (doquit == 2) {
return 1;
}
@ -2004,7 +2010,8 @@ int read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
jlr.LastReadMsg = 0;
jlr.HighReadMsg = 0;
all_unread = 1;
} else if (jlr.LastReadMsg == 0 && jlr.HighReadMsg == 0) {
}
if (jlr.LastReadMsg == 0 && jlr.HighReadMsg == 0) {
all_unread = 1;
}
JAM_CloseMB(jb);
@ -2013,10 +2020,15 @@ int read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
k = jlr.HighReadMsg;
for (i=0;i<msghs->msg_count;i++) {
if (msghs->msgs[i]->msg_h->MsgNum == k) {
i+=2;
break;
}
if (msghs->msgs[i]->msg_h->MsgNum > k) {
i++;
break;
}
}
i += 2;
} else {
i = 1;
}
@ -3001,6 +3013,9 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
int orig_conf;
int orig_area;
int res = 0;
char ch;
int unread_count;
int k;
if (personal) {
s_printf(get_string(276));
@ -3014,13 +3029,16 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
if (conf.mail_conferences[i]->sec_level > user->sec_level) {
continue;
}
if (oldscan) {
s_printf(get_string(140), i, conf.mail_conferences[i]->name);
lines+=2;
if (lines == 22) {
s_printf(get_string(6));
s_getc();
lines = 0;
}
}
for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) {
if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) {
continue;
@ -3061,6 +3079,14 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
lines = 0;
}
} else {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count);
s_printf(get_string(289));
ch = s_getchar();
s_printf("\r\n");
if (tolower(ch) == 'y') {
orig_conf = user->cur_mail_conf;
orig_area = user->cur_mail_area;
@ -3073,6 +3099,7 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
user->cur_mail_area = orig_area;
}
}
}
free_message_headers(msghs);
}
} else {
@ -3087,7 +3114,16 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
} else {
msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) {
if (msghs->msg_count > 0) {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count);
s_printf(get_string(289));
ch = s_getchar();
s_printf("\r\n");
if (tolower(ch) == 'y') {
orig_conf = user->cur_mail_conf;
orig_area = user->cur_mail_area;
@ -3099,19 +3135,31 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area;
}
}
free_message_headers(msghs);
}
}
}
} else {
if (jlr.HighReadMsg < jbh.ActiveMsgs) {
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) {
if (msghs->msg_count > 0) {
unread_count = 0;
for (k=msghs->msg_count-1;k>=0;k--) {
if (msghs->msgs[k]->msg_no <= jlr.HighReadMsg) {
break;
}
unread_count++;
}
if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) {
if (oldscan) {
s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_h->MsgNum - jlr.HighReadMsg);
s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
lines++;
if (lines == 22) {
s_printf(get_string(6));
@ -3119,6 +3167,14 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
lines = 0;
}
} else {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
s_printf(get_string(289));
ch = s_getchar();
s_printf("\r\n");
if (tolower(ch) == 'y') {
orig_conf = user->cur_mail_conf;
orig_area = user->cur_mail_area;
@ -3132,6 +3188,7 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
}
}
}
}
free_message_headers(msghs);
}
} else {
@ -3147,6 +3204,22 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) {
if (msghs->msg_count > 0) {
unread_count = 0;
for (k=msghs->msg_count-1;k>=0;k--) {
if (msghs->msgs[k]->msg_no <= jlr.HighReadMsg) {
break;
}
unread_count++;
}
s_printf("\e[2J\e[1;1H");
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
s_printf(get_string(279));
ch = s_getchar();
s_printf("\r\n");
if (tolower(ch) == 'y') {
orig_conf = user->cur_mail_conf;
orig_area = user->cur_mail_area;
@ -3158,6 +3231,7 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area;
}
}
free_message_headers(msghs);
}
}