+Thu Sep 17 22:55:29 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Various changes to allow "new messages" to work correctly with Mail
+
Thu Sep 17 22:21:45 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* server.h, dynloader.c, citserver.c, user_ops.c: reduced the number
of hook types by inventing an EventType field to the Session hook.
*/
int has_newmsgs(struct quickroom *roombuf, int roomnum, struct usersupp *userbuf)
{
- if (roombuf->QRhighest > (userbuf->lastseen[roomnum]) )
- return(1);
- else return(0);
+ if (roomnum == 1) {
+ return ( (NewMailCount() > 0) ? 1 : 0 );
+ }
+ else {
+ if (roombuf->QRhighest > (userbuf->lastseen[roomnum]) ) {
+ return(1);
+ }
+ else {
+ return(0);
+ }
+ }
}
+
/*
* is_zapped() - returns nonzero if room is on forgotten rooms list
*/
int rmailflag;
int raideflag;
int newmailcount = 0;
- struct cdbdata *cdbmb;
- int num_mails;
- long *mailbox;
CC->curr_rm=where;
getroom(&CC->quickroom,CC->curr_rm);
lputuser(&CC->usersupp,CC->curr_user);
/* check for new mail */
- newmailcount = 0;
-
- cdbmb = cdb_fetch(CDB_MAILBOXES, &CC->usersupp.usernum, sizeof(long));
- if (cdbmb != NULL) {
- num_mails = cdbmb->len / sizeof(long);
- mailbox = (long *) cdbmb->ptr;
- if (num_mails > 0) for (a=0; a<num_mails; ++a) {
- if (mailbox[a] > (CC->usersupp.lastseen[1]))
- ++newmailcount;
- }
- cdb_free(cdbmb);
- }
+ newmailcount = NewMailCount();
/* set info to 1 if the user needs to read the room's info file */
if (CC->quickroom.QRinfo > CC->usersupp.lastseen[CC->curr_rm]) info = 1;
}
-
/*
* misc things to be taken care of when a user is logged out
*/
if (!strncasecmp(new_ptr,"highest",7)) {
newlr = CC->quickroom.QRhighest;
+/* FIX ... if the current room is 1 (Mail), newlr needs to be set to the
+ * number of the highest mail message
+ */
}
else {
newlr = atol(new_ptr);
int mail = 0;
int regis = 0;
int vali = 0;
- int a;
- struct cdbdata *cdbmb;
- long *mailbox;
- int num_mails;
-
if (!(CC->logged_in)) {
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
return;
/* check for mail */
- mail = 0;
- cdbmb = cdb_fetch(CDB_MAILBOXES, &CC->usersupp.usernum, sizeof(long));
- if (cdbmb != NULL) {
- num_mails = cdbmb->len / sizeof(long);
- mailbox = (long *) cdbmb->ptr;
- if (num_mails > 0) for (a=0; a<num_mails; ++a) {
- if (mailbox[a] > (CC->usersupp.lastseen[1])) ++mail;
- }
- cdb_free(cdbmb);
- }
-
+ mail = NewMailCount();
cprintf("%d %d|%d|%d\n",OK,mail,regis,vali);
}
}
cprintf("%d Ok\n", OK);
}
+
+
+/*
+ * Count the number of new mail messages the user has
+ */
+int NewMailCount() {
+ int num_newmsgs = 0;
+ struct cdbdata *cdbmb;
+ int num_mails;
+ long *mailbox;
+ int a;
+
+ cdbmb = cdb_fetch(CDB_MAILBOXES, &CC->usersupp.usernum, sizeof(long));
+ if (cdbmb != NULL) {
+ num_mails = cdbmb->len / sizeof(long);
+ mailbox = (long *) cdbmb->ptr;
+ if (num_mails > 0) for (a=0; a<num_mails; ++a) {
+ if (mailbox[a] > (CC->usersupp.lastseen[1]))
+ ++num_newmsgs;
+ }
+ cdb_free(cdbmb);
+ }
+ return(num_newmsgs);
+ }
void cmd_lbio (void);
void cmd_agup (char *cmdbuf);
void cmd_asup (char *cmdbuf);
+int NewMailCount(void);