diff --git a/mail_menu.c b/mail_menu.c index 19bcc1d..8e6d8f2 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -1865,7 +1865,7 @@ void mail_scan(struct user_record *user) { s_JamBase *jb; s_JamBaseHeader jbh; s_JamLastRead jlr; - + struct msg_headers *msghs; char c; int i; int j; @@ -1882,30 +1882,48 @@ void mail_scan(struct user_record *user) { for (j=0;jmail_area_count;j++) { if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) { continue; - } - jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path); - if (!jb) { - dolog("Unable to open message base"); - continue; - } - if (JAM_ReadMBHeader(jb, &jbh) != 0) { - JAM_CloseMB(jb); - continue; - } - if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { - if (jbh.ActiveMsgs == 0) { - JAM_CloseMB(jb); - continue; - } - s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs); - } else { - if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) { - s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg); - } else { - JAM_CloseMB(jb); - continue; - } - } + } + jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path); + if (!jb) { + dolog("Unable to open message base"); + continue; + } + if (JAM_ReadMBHeader(jb, &jbh) != 0) { + JAM_CloseMB(jb); + continue; + } + if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { + if (jbh.ActiveMsgs == 0) { + JAM_CloseMB(jb); + continue; + } + if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { + msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); + if (msghs != NULL) { + s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count); + free_message_headers(msghs); + } + } else { + s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs); + } + } else { + if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) { + if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { + msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); + if (msghs != NULL) { + if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) { + s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_no - jlr.HighReadMsg); + } + free_message_headers(msghs); + } + } else { + s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg); + } + } else { + JAM_CloseMB(jb); + continue; + } + } JAM_CloseMB(jb); } }