* Various changes to allow "new messages" to work correctly with Mail
authorArt Cancro <ajc@citadel.org>
Fri, 18 Sep 1998 02:56:19 +0000 (02:56 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 18 Sep 1998 02:56:19 +0000 (02:56 +0000)
citadel/ChangeLog
citadel/room_ops.c
citadel/user_ops.c
citadel/user_ops.h

index 17217007efa1b5ea92542f3f2084e7cb4815113b..df720ad04702ba8599220595358d17cd0f0279b8 100644 (file)
@@ -1,3 +1,6 @@
+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.
index 23e1406ff359465770e5bb433b53d2915dcd0301..445aa2f61675390f186e9c86aae413db9cd824e9 100644 (file)
@@ -50,11 +50,20 @@ int is_known(struct quickroom *roombuf, int roomnum, struct usersupp *userbuf)
  */
 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
  */
@@ -495,9 +504,6 @@ void usergoto(int where, int display_result)
        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);
@@ -507,18 +513,7 @@ void usergoto(int where, int display_result)
        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;
index b73d1a793a8eaaffb5b78e7cad982a3e4c0d8893..bde6305cea89fd4a32dba8af2033e2ace48aa544 100644 (file)
@@ -244,7 +244,6 @@ void session_startup(void) {
        }
 
 
-
 /* 
  * misc things to be taken care of when a user is logged out
  */
@@ -585,6 +584,9 @@ void cmd_slrp(char *new_ptr)
 
        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);
@@ -1001,12 +1003,7 @@ void cmd_chek(void) {
        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;
@@ -1022,17 +1019,7 @@ void cmd_chek(void) {
 
 
        /* 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);
        }
@@ -1206,3 +1193,27 @@ void cmd_asup(char *cmdbuf) {
                }
        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);
+       }
index 681d34114106fcce8477ea3711d307223fac08ef..ac6ef7c8bc295cba6596fa38476de6f7c6ab502c 100644 (file)
@@ -33,3 +33,4 @@ void cmd_rbio (char *cmdbuf);
 void cmd_lbio (void);
 void cmd_agup (char *cmdbuf);
 void cmd_asup (char *cmdbuf);
+int NewMailCount(void);