* Changed CtdlRoomAccess() calling syntax in order to return both
authorArt Cancro <ajc@citadel.org>
Tue, 1 Feb 2005 03:33:23 +0000 (03:33 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 1 Feb 2005 03:33:23 +0000 (03:33 +0000)
  the access bits and the current view
* All "list rooms" commands now return the view for each room.

citadel/ChangeLog
citadel/citserver.c
citadel/msgbase.c
citadel/room_ops.c
citadel/room_ops.h
citadel/serv_calendar.c
citadel/serv_imap.c
citadel/techdoc/protocol.txt

index 13b0d9df450fd7415e812affb8263fcb15cd9b00..ca1410b5bdd986851309b71601f7668faf2d0f2f 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 630.9  2005/02/01 03:33:22  ajc
+ * Changed CtdlRoomAccess() calling syntax in order to return both
+   the access bits and the current view
+ * All "list rooms" commands now return the view for each room.
+
  Revision 630.8  2005/01/27 22:05:21  ajc
  * Renamed the "Extended message ID" field to "Exclusive message ID"
    (nothing changes except documentation and internal variable names)
@@ -6330,4 +6335,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 967e863bd1e6a1ed316552c5b986a6d07efbde83..10fc7be9205f25a8ccceef8494cfc87d2ed9ce17 100644 (file)
@@ -637,13 +637,15 @@ void GenerateRoomDisplay(char *real_room,
                        struct CitContext *viewed,
                        struct CitContext *viewer) {
 
+       int ra;
+
        strcpy(real_room, viewed->room.QRname);
        if (viewed->room.QRflags & QR_MAILBOX) {
                strcpy(real_room, &real_room[11]);
        }
        if (viewed->room.QRflags & QR_PRIVATE) {
-               if ( (CtdlRoomAccess(&viewed->room, &viewer->user)
-                  & UA_KNOWN) == 0) {
+               CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
+               if ( (ra & UA_KNOWN) == 0) {
                        strcpy(real_room, "<private room>");
                }
        }
index 98dbafc2714bd5275acc4754d20c546036254e6d..301ab1ee208c31a59aae9572888ef49a06874b30 100644 (file)
@@ -2981,7 +2981,7 @@ void cmd_move(char *args)
        }
 
        getuser(&CC->user, CC->curr_user);
-       ra = CtdlRoomAccess(&qtemp, &CC->user);
+       CtdlRoomAccess(&qtemp, &CC->user, &ra, NULL);
 
        /* Check for permission to perform this operation.
         * Remember: "CC->room" is source, "qtemp" is target.
index 6a946041e5e06a1942b9dc76c7395afbcc246c15..1b00fe4859352340cf4c9125b93efe8f98e3e353 100644 (file)
@@ -49,14 +49,17 @@ struct floor *floorcache[MAXFLOORS];
 /*
  * Generic routine for determining user access to rooms
  */
-int CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf)
+void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
+               int *result, int *view)
 {
        int retval = 0;
        struct visit vbuf;
 
        /* for internal programs, always do everything */
        if (((CC->internal_pgm)) && (roombuf->QRflags & QR_INUSE)) {
-               return (UA_KNOWN | UA_GOTOALLOWED);
+               retval = (UA_KNOWN | UA_GOTOALLOWED);
+               vbuf.v_view = 0;
+               goto SKIP_EVERYTHING;
        }
 
        /* Locate any applicable user/room relationships */
@@ -157,7 +160,11 @@ NEWMSG:    /* By the way, we also check for the presence of new messages */
        if (roombuf->QRflags2 & QR2_SYSTEM) {
                retval = retval & ~UA_KNOWN;
        }
-       return (retval);
+
+SKIP_EVERYTHING:
+       /* Now give the caller the information it wants. */
+       if (result != NULL) *result = retval;
+       if (view != NULL) *view = vbuf.v_view;
 }
 
 /*
@@ -500,7 +507,7 @@ int is_noneditable(struct ctdlroom *qrbuf)
 /*
  * Back-back-end for all room listing commands
  */
-void list_roomname(struct ctdlroom *qrbuf, int ra)
+void list_roomname(struct ctdlroom *qrbuf, int ra, int view)
 {
        char truncated_roomname[ROOMNAMELEN];
 
@@ -517,12 +524,13 @@ void list_roomname(struct ctdlroom *qrbuf, int ra)
        }
 
        /* ...and now the other parameters */
-       cprintf("|%u|%d|%d|%d|%d|\n",
+       cprintf("|%u|%d|%d|%d|%d|%d|\n",
                qrbuf->QRflags,
                (int) qrbuf->QRfloor,
                (int) qrbuf->QRorder,
                (int) qrbuf->QRflags2,
-               ra
+               ra,
+               view
        );
 }
 
@@ -534,14 +542,15 @@ void cmd_lrms_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
        int ra;
+       int view;
 
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if ((( ra & (UA_KNOWN | UA_ZAPPED)))
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lrms(char *argbuf)
@@ -571,14 +580,15 @@ void cmd_lkra_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
        int ra;
+       int view;
 
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if ((( ra & (UA_KNOWN)))
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lkra(char *argbuf)
@@ -605,15 +615,16 @@ void cmd_lprm_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
        int ra;
+       int view;
 
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if (   ((qrbuf->QRflags & QR_PRIVATE) == 0)
                && ((qrbuf->QRflags & QR_MAILBOX) == 0)
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lprm(char *argbuf)
@@ -637,15 +648,16 @@ void cmd_lkrn_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
        int ra;
+       int view;
 
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if ((ra & UA_KNOWN)
            && (ra & UA_HASNEWMSGS)
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lkrn(char *argbuf)
@@ -675,15 +687,16 @@ void cmd_lkro_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
        int ra;
+       int view;
 
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if ((ra & UA_KNOWN)
            && ((ra & UA_HASNEWMSGS) == 0)
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lkro(char *argbuf)
@@ -712,16 +725,17 @@ void cmd_lkro(char *argbuf)
 void cmd_lzrm_backend(struct ctdlroom *qrbuf, void *data)
 {
        int FloorBeingSearched = (-1);
-
        int ra;
+       int view;
+
        FloorBeingSearched = *(int *)data;
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
 
        if ((ra & UA_GOTOALLOWED)
            && (ra & UA_ZAPPED)
            && ((qrbuf->QRfloor == (FloorBeingSearched))
                || ((FloorBeingSearched) < 0)))
-               list_roomname(qrbuf, ra);
+               list_roomname(qrbuf, ra, view);
 }
 
 void cmd_lzrm(char *argbuf)
@@ -926,7 +940,7 @@ void cmd_goto(char *gargs)
                }
 
                /* See if there is an existing user/room relationship */
-               ra = CtdlRoomAccess(&QRscratch, &CC->user);
+               CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL);
 
                /* normal clients have to pass through security */
                if (ra & UA_GOTOALLOWED) {
@@ -972,6 +986,7 @@ void cmd_whok(void)
 {
        struct ctdluser temp;
        struct cdbdata *cdbus;
+       int ra;
 
        getuser(&CC->user, CC->curr_user);
 
@@ -997,8 +1012,9 @@ void cmd_whok(void)
                memcpy(&temp, cdbus->ptr, sizeof temp);
                cdb_free(cdbus);
 
+               CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
                if ((CC->room.QRflags & QR_INUSE)
-                   && (CtdlRoomAccess(&CC->room, &temp) & UA_KNOWN)
+                   && (ra & UA_KNOWN)
                    )
                        cprintf("%s\n", temp.fullname);
        }
index 724fa0782c4cdcc400ad91424dad75586d0b1fdf..549459c60c5514e30b96decc0d229a7bfb34b7f6 100644 (file)
@@ -52,9 +52,10 @@ void ForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
 void assoc_file_name(char *buf, size_t n,
                     struct ctdlroom *qrbuf, const char *prefix);
 void delete_room(struct ctdlroom *qrbuf);
-void list_roomname(struct ctdlroom *qrbuf, int ra);
+void list_roomname(struct ctdlroom *qrbuf, int ra, int view);
 int is_noneditable(struct ctdlroom *qrbuf);
-int CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf);
+void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
+               int *result, int *view);
 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
 
 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
index 08e090a9bb8079665e279c79e4ef61386f66f161..2e4eb50840b27d5d090cbfb605aa0de98381f3bf 100644 (file)
@@ -1733,7 +1733,6 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
  */
 int ical_obj_beforesave(struct CtdlMessage *msg)
 {
-       char roomname[ROOMNAMELEN];
        char *p;
        int a;
        struct icalmessagemod imm;
index 65682eb3621833f6ba703b46efd099547af77b1f..aabf7ba17e3a399a9ef1532663a4cda900018898 100644 (file)
@@ -527,7 +527,7 @@ void imap_select(int num_parms, char *parms[])
        /* If the room exists, check security/access */
        if (c == 0) {
                /* See if there is an existing user/room relationship */
-               ra = CtdlRoomAccess(&QRscratch, &CC->user);
+               CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL);
 
                /* normal clients have to pass through security */
                if (ra & UA_KNOWN) {
@@ -719,7 +719,7 @@ void imap_lsub_listroom(struct ctdlroom *qrbuf, void *data)
        pattern = (char *) data;
 
        /* Only list rooms to which the user has access!! */
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, NULL);
        if (ra & UA_KNOWN) {
                imap_mailboxname(buf, sizeof buf, qrbuf);
                if (imap_mailbox_matches_pattern(pattern, buf)) {
@@ -769,7 +769,7 @@ void imap_list_listroom(struct ctdlroom *qrbuf, void *data)
        pattern = (char *) data;
 
        /* Only list rooms to which the user has access!! */
-       ra = CtdlRoomAccess(qrbuf, &CC->user);
+       CtdlRoomAccess(qrbuf, &CC->user, &ra, NULL);
        if ((ra & UA_KNOWN)
            || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
                imap_mailboxname(buf, sizeof buf, qrbuf);
@@ -899,7 +899,7 @@ int imap_grabroom(char *returned_roomname, char *foldername)
        /* If the room exists, check security/access */
        if (c == 0) {
                /* See if there is an existing user/room relationship */
-               ra = CtdlRoomAccess(&QRscratch, &CC->user);
+               CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL);
 
                /* normal clients have to pass through security */
                if (ra & UA_KNOWN) {
index d6b73d0e206a2f3d61bb19d90ab6997252a0ced9..dee0278d45478760eeffd3c8dc03ee2708053382 100644 (file)
@@ -279,7 +279,8 @@ room access controls:
                                         * if the user calls it up by name */
 #define UA_HASNEWMSGS           8      /* Unread messages exist in room */
 #define UA_ZAPPED              16      /* Zapped from known rooms list */
+  
+ The sixth field is the user's current view for the room. (See VIEW command)
  
  
  LKRO   (List Known Rooms with Old [no new] messages)