Improve new message scan

This commit is contained in:
Andrew Pamment 2017-10-13 13:03:06 +10:00
parent ce65048a98
commit 1ae8c26054
3 changed files with 49 additions and 23 deletions

View File

@ -184,7 +184,8 @@ Login Name:
\r\n-------------------------------------\r\n \r\n-------------------------------------\r\n
Is this Correct? (Y/N) Is this Correct? (Y/N)
\e[1;37mPress any key to continue...\e[0m \e[1;37mPress any key to continue...\e[0m
\e[24;1H\e[1;32mUp / Down \e[1;37mto Scroll, \e[1;32mLeft / Right \e[1;37mChange Message, \e[1;32mR \e[1;37mreply, \e[1;32mQ \e[1;37mquit\e[K\e[0m
\e[24;1H\e[1;32m / \e[1;37mto Scroll, \e[1;32m /  \e[1;37mChange Message, \e[1;32mR \e[1;37mReply, \e[1;32mQ \e[1;37mQuit\e[K\e[0m
\e[23;1H\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n \e[23;1H\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n \e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n \e[1;30m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
@ -232,3 +233,4 @@ File exists!\r\n
\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[1;31mNEW \e[0;32m \r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[1;31mNEW \e[0;32m
\r\nScan for new files? (Y/N) : \r\nScan for new files? (Y/N) :
\r\n\e[1;37mOrder by (\e[1;32mF\e[1;37m)ilename, (\e[1;32mU\e[1;37m)pload Date, (\e[1;32mP\e[1;37m)opularity : \e[0m \r\n\e[1;37mOrder by (\e[1;32mF\e[1;37m)ilename, (\e[1;32mU\e[1;37m)pload Date, (\e[1;32mP\e[1;37m)opularity : \e[0m
\e[24;1H\e[1;32m / \e[1;37mto Scroll, \e[1;32m /  \e[1;37mChange Message, \e[1;32mR \e[1;37mReply, \e[1;32mJ \e[1;37m Next Area \e[1;32mQ \e[1;37mQuit\e[K\e[0m

View File

@ -284,7 +284,7 @@ extern void msg_conf_sub_bases();
extern void msgbase_reset_pointers(int conference, int msgarea); extern void msgbase_reset_pointers(int conference, int msgarea);
extern void msgbase_reset_all_pointers(); extern void msgbase_reset_all_pointers();
extern void full_mail_scan(struct user_record *user); extern void full_mail_scan(struct user_record *user);
extern void read_new_msgs(struct user_record *user, struct msg_headers *msghs); extern int read_new_msgs(struct user_record *user, struct msg_headers *msghs);
extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage); extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage);
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage); extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage);

View File

@ -1417,7 +1417,7 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
void read_message(struct user_record *user, struct msg_headers *msghs, int mailno) { int read_message(struct user_record *user, struct msg_headers *msghs, int mailno, int newscan) {
s_JamBase *jb; s_JamBase *jb;
s_JamMsgHeader jmh; s_JamMsgHeader jmh;
s_JamSubPacket* jsp; s_JamSubPacket* jsp;
@ -1454,10 +1454,10 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
return; return 0;
} }
while (!doquit) { while (doquit == 0) {
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
jlr.UserCRC = JAM_Crc32(user->loginname, strlen(user->loginname)); jlr.UserCRC = JAM_Crc32(user->loginname, strlen(user->loginname));
@ -1489,7 +1489,9 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
body = (char *)malloc(msghs->msgs[mailno]->msg_h->TxtLen); body = (char *)malloc(msghs->msgs[mailno]->msg_h->TxtLen);
JAM_ReadMsgText(jb, msghs->msgs[mailno]->msg_h->TxtOffset, msghs->msgs[mailno]->msg_h->TxtLen, (char *)body); JAM_ReadMsgText(jb, msghs->msgs[mailno]->msg_h->TxtOffset, msghs->msgs[mailno]->msg_h->TxtLen, (char *)body);
if (!newscan) {
JAM_WriteLastRead(jb, user->id, &jlr); JAM_WriteLastRead(jb, user->id, &jlr);
}
z2 = msghs->msgs[mailno]->msg_h->TxtLen; z2 = msghs->msgs[mailno]->msg_h->TxtLen;
@ -1565,8 +1567,11 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
break; break;
} }
} }
if (newscan) {
s_printf(get_string(235));
} else {
s_printf(get_string(187)); s_printf(get_string(187));
}
s_printf(get_string(186)); s_printf(get_string(186));
c = s_getc(); c = s_getc();
@ -1574,6 +1579,8 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
should_break = 1; should_break = 1;
} else if (tolower(c) == 'q') { } else if (tolower(c) == 'q') {
should_break = 1; should_break = 1;
} else if (tolower(c) == 'j' && newscan == 1) {
should_break = 1;
} else if (c == '\e') { } else if (c == '\e') {
c = s_getc(); c = s_getc();
if (c == 91) { if (c == 91) {
@ -1666,7 +1673,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
free(msg_lines[i]); free(msg_lines[i]);
} }
free(msg_lines); free(msg_lines);
return; return 0;
} }
JAM_ClearMsgHeader( &jmh ); JAM_ClearMsgHeader( &jmh );
@ -1830,7 +1837,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
free(msg_lines[i]); free(msg_lines[i]);
} }
free(msg_lines); free(msg_lines);
return; return 0;
} }
} }
if (JAM_AddMessage(jb, &jmh, jsp, (char *)replybody, strlen(replybody))) { if (JAM_AddMessage(jb, &jmh, jsp, (char *)replybody, strlen(replybody))) {
@ -1872,7 +1879,9 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
if (subject != NULL) { if (subject != NULL) {
free(subject); free(subject);
} }
} else if (tolower(c) == 'j' && newscan == 1) {
free(body);
doquit = 2;
} else if (tolower(c) == 'q') { } else if (tolower(c) == 'q') {
free(body); free(body);
doquit = 1; doquit = 1;
@ -1897,22 +1906,29 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn
free(msg_lines); free(msg_lines);
msg_line_count = 0; msg_line_count = 0;
} }
if (doquit == 2) {
return 1;
} }
void read_new_msgs(struct user_record *user, struct msg_headers *msghs) { return 0;
}
int read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
s_JamBase *jb; s_JamBase *jb;
s_JamLastRead jlr; s_JamLastRead jlr;
int all_unread; int all_unread;
int i; int i;
int k; int k;
char buffer[7]; char buffer[7];
int res;
// list mail in message base // list mail in message base
if (msghs != NULL && msghs->msg_count > 0) { if (msghs != NULL && msghs->msg_count > 0) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
return; return 0;
} else { } else {
all_unread = 0; all_unread = 0;
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
@ -1936,10 +1952,11 @@ void read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
} }
if (i > 0 && i <= msghs->msg_count) { if (i > 0 && i <= msghs->msg_count) {
read_message(user, msghs, i - 1); return read_message(user, msghs, i - 1, 1);
} }
} }
} }
return 0;
} }
void read_mail(struct user_record *user) { void read_mail(struct user_record *user) {
@ -1990,7 +2007,7 @@ void read_mail(struct user_record *user) {
} }
if (i > 0 && i <= msghs->msg_count) { if (i > 0 && i <= msghs->msg_count) {
read_message(user, msghs, i - 1); read_message(user, msghs, i - 1, 0);
} }
} }
} }
@ -2474,7 +2491,7 @@ void list_messages(struct user_record *user) {
} }
} else if (c == 13) { } else if (c == 13) {
redraw = 1; redraw = 1;
read_message(user, msghs, i - 1); read_message(user, msghs, i - 1, 0);
free_message_headers(msghs); free_message_headers(msghs);
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
@ -2633,7 +2650,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
int lines = 0; int lines = 0;
int orig_conf; int orig_conf;
int orig_area; int orig_area;
int res = 0;
s_printf(get_string(139)); s_printf(get_string(139));
c = s_getc(); c = s_getc();
@ -2693,7 +2710,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
user->cur_mail_conf = i; user->cur_mail_conf = i;
user->cur_mail_area = j; user->cur_mail_area = j;
read_new_msgs(user, msghs); res = read_new_msgs(user, msghs);
user->cur_mail_conf = orig_conf; user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area; user->cur_mail_area = orig_area;
@ -2720,7 +2737,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
user->cur_mail_conf = i; user->cur_mail_conf = i;
user->cur_mail_area = j; user->cur_mail_area = j;
read_new_msgs(user, msghs); res = read_new_msgs(user, msghs);
user->cur_mail_conf = orig_conf; user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area; user->cur_mail_area = orig_area;
@ -2751,7 +2768,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
user->cur_mail_conf = i; user->cur_mail_conf = i;
user->cur_mail_area = j; user->cur_mail_area = j;
read_new_msgs(user, msghs); res = read_new_msgs(user, msghs);
user->cur_mail_conf = orig_conf; user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area; user->cur_mail_area = orig_area;
@ -2779,7 +2796,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
user->cur_mail_conf = i; user->cur_mail_conf = i;
user->cur_mail_area = j; user->cur_mail_area = j;
read_new_msgs(user, msghs); res = read_new_msgs(user, msghs);
user->cur_mail_conf = orig_conf; user->cur_mail_conf = orig_conf;
user->cur_mail_area = orig_area; user->cur_mail_area = orig_area;
@ -2794,8 +2811,15 @@ void do_mail_scan(struct user_record *user, int oldscan) {
} }
} }
JAM_CloseMB(jb); JAM_CloseMB(jb);
if (res) {
break;
} }
} }
if (res) {
break;
}
}
s_printf(get_string(6)); s_printf(get_string(6));
s_getc(); s_getc();
} }