From 4e57fb277a5d0d497e7b750618af9da61fc69d4d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 1 Feb 2005 03:33:23 +0000 Subject: [PATCH] * 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. --- citadel/ChangeLog | 6 +++- citadel/citserver.c | 6 ++-- citadel/msgbase.c | 2 +- citadel/room_ops.c | 58 +++++++++++++++++++++++------------- citadel/room_ops.h | 5 ++-- citadel/serv_calendar.c | 1 - citadel/serv_imap.c | 8 ++--- citadel/techdoc/protocol.txt | 3 +- 8 files changed, 56 insertions(+), 33 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 13b0d9df4..ca1410b5b 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index 967e863bd..10fc7be92 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -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, ""); } } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 98dbafc27..301ab1ee2 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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. diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 6a946041e..1b00fe485 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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); } diff --git a/citadel/room_ops.h b/citadel/room_ops.h index 724fa0782..549459c60 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -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); diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c index 08e090a9b..2e4eb5084 100644 --- a/citadel/serv_calendar.c +++ b/citadel/serv_calendar.c @@ -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; diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index 65682eb36..aabf7ba17 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -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) { diff --git a/citadel/techdoc/protocol.txt b/citadel/techdoc/protocol.txt index d6b73d0e2..dee0278d4 100644 --- a/citadel/techdoc/protocol.txt +++ b/citadel/techdoc/protocol.txt @@ -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) -- 2.39.2