From: Art Cancro Date: Wed, 20 Oct 1999 16:46:28 +0000 (+0000) Subject: * More code shuffle. Added some flags to CtdlSaveMessagePointerInRoom() and X-Git-Tag: v7.86~7491 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3c02f955388dc0d2307f09cd71004dd36b5fcef3 * More code shuffle. Added some flags to CtdlSaveMessagePointerInRoom() and enabled the MOVE command to also do a "copy" operation (actually just creates a second link and bumps the ref count). Implemented "opy" in the client. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 14e2a1cc4..ba2e7d2ac 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,10 @@ $Log$ +Revision 1.390 1999/10/20 16:46:27 ajc +* More code shuffle. Added some flags to CtdlSaveMessagePointerInRoom() and + enabled the MOVE command to also do a "copy" operation (actually just + creates a second link and bumps the ref count). Implemented "opy" in + the client. + Revision 1.389 1999/10/20 16:07:48 ajc * Wholist fixes for users who are in chat mode @@ -1331,4 +1337,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/messages.c b/citadel/messages.c index 3b0cc34d1..e8b1d208c 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -1065,7 +1065,7 @@ RMSGREAD: fflush(stdout); /* space key same as */ if (e==32) e='n'; /* del/move for aides only */ if ((!is_room_aide) &&((room_flags&QR_MAILBOX)==0)) { - if ((e=='d')||(e=='m')) e=0; + if ((e=='d')||(e=='m')||(e=='c')) e=0; } /* print only if available */ if ((e=='p')&&(strlen(printcmd)==0)) e=0; /* can't reply in public rms */ if ((e=='r')&&(is_mail!=1)) e=0; @@ -1075,12 +1075,13 @@ RMSGREAD: fflush(stdout); &&(e!='d')&&(e!='m')&&(e!='p') &&(e!='q')&&(e!='b')&&(e!='h') &&(e!='r')&&(e!='f')&&(e!='?') - &&(e!='u')); + &&(e!='u')&&(e!='c')); switch(e) { case 's': printf("Stop\r"); break; case 'a': printf("Again\r"); break; case 'd': printf("Delete\r"); break; case 'm': printf("Move\r"); break; + case 'c': printf("Copy\r"); break; case 'n': printf("Next\r"); break; case 'p': printf("Print\r"); break; case 'q': printf("Quote\r"); break; @@ -1108,6 +1109,7 @@ RMSGREAD: fflush(stdout); ||(room_flags&QR_MAILBOX)) { printf(" D Delete this message\n"); printf(" M Move message to another room\n"); + printf(" C Copy message to another room\n"); } if (strlen(printcmd)>0) printf(" P Print this message\n"); @@ -1137,11 +1139,14 @@ RMSGREAD: fflush(stdout); case 'a': goto RAGAIN; case 'b': a=a-(rdir*2); break; - case 'm': newprompt("Enter target room: ", + case 'm': + case 'c': + newprompt("Enter target room: ", targ,ROOMNAMELEN-1); if (strlen(targ)>0) { - sprintf(cmd,"MOVE %ld|%s", - msg_arr[a],targ); + sprintf(cmd,"MOVE %ld|%s|%d", + msg_arr[a],targ, + (e=='c' ? 1 : 0) ); serv_puts(cmd); serv_gets(cmd); printf("%s\n",&cmd[4]); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index ffe22b771..5ea0841e8 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1094,7 +1094,6 @@ void cmd_opna(char *cmdbuf) } - /* * Save a message pointer into a specified room * (Returns 0 for success, nonzero for failure) @@ -1106,12 +1105,22 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { int num_msgs; long *msglist; long highest_msg = 0L; + struct CtdlMessage *msg = NULL; lprintf(9, "CtdlSaveMsgPointerInRoom(%s, %ld, %d)\n", roomname, msgid, flags); + /* We may need to check to see if this message is real */ + if ( (flags & SM_VERIFY_GOODNESS) + || (flags & SM_DO_REPL_CHECK) + ) { + msg = CtdlFetchMessage(msgid); + if (msg == NULL) return(ERROR + ILLEGAL_VALUE); + } + if (lgetroom(&qrbuf, roomname) != 0) { lprintf(9, "No such room <%s>\n", roomname); + if (msg != NULL) CtdlFreeMessage(msg); return(ERROR + ROOM_NOT_FOUND); } @@ -1136,6 +1145,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { if (num_msgs > 0) for (i=0; iusersupp, CC->curr_user); if ((CC->usersupp.axlevel < 6) @@ -2050,30 +2062,19 @@ void cmd_move(char *args) return; } - /* Temporarily bump the reference count to avoid having the message - * deleted while it's in transit. - */ - AdjRefCount(num, 1); - - /* yank the message out of the current room... */ - foundit = CtdlDeleteMessages(CC->quickroom.QRname, num, NULL); - - if (foundit) { - /* put the message into the target room */ - if (err = CtdlSaveMsgPointerInRoom(targ, num, 0), (err !=0) ) { - cprintf("%d Could not save message %ld in %s.\n", - err, num, targ); - } - else { - cprintf("%d Message moved.\n", OK); - } - } - else { - cprintf("%d No such message.\n", ERROR); + err = CtdlSaveMsgPointerInRoom(targ, num, SM_VERIFY_GOODNESS); + if (err != 0) { + cprintf("%d Cannot store message in %s: error %d\n", + err, targ, err); + return; } - /* Fix the reference count. */ - AdjRefCount(num, (-1)); + /* Now delete the message from the source room, + * if this is a 'move' rather than a 'copy' operation. + */ + if (is_copy == 0) CtdlDeleteMessages(CC->quickroom.QRname, num, NULL); + + cprintf("%d Message %s.\n", OK, (is_copy ? "copied" : "moved") ); } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 511f440f9..61638893e 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -9,6 +9,12 @@ #define MSGS_LAST 4 #define MSGS_GT 5 +/* + * Flags which may be passed to CtdlSaveMsgPointerInRoom() + */ +#define SM_VERIFY_GOODNESS 1 /* Verify this is a real msg number */ +#define SM_DO_REPL_CHECK 2 /* Perform replication checks */ + struct ma_info { char prefix[256]; /* Prefix for a multipart/alternative */ diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index dcc7337cf..bd94c8527 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -740,9 +740,12 @@ which will tell the client whether the file needs to be read (see GOTO above). Delete a message from the current room. The one argument that should be passed to this command is the message number of the message to be deleted. The return value will be OK if the message was deleted, or an ERROR code. +If the delete is successful, the message's reference count is decremented, and +if the reference count reaches zero, the message is removed from the message +base. - MOVE (MOVE a message to a different room) + MOVE (MOVE or copy a message to a different room) Move a message to a different room. The two arguments that should be passed to this command are the message number of the message to be deleted, and the @@ -751,6 +754,13 @@ deleted from the current room and moved to the target room. An ERROR code usually means that either the user does not have permission to perform this operation, or that the target room does not exist. + In Citadel/UX 5.55 and above, a third argument may be specified: 0 or 1 to +designate whether the message should be moved (0) or copied (1) to the target +room. In the case of a "copy" operation, the message's reference count is +incremented, and a pointer to the message will exist in both the source *and* +target rooms. In the case of a "move" operation, the message pointer is +deleted from the source room and the reference count remains the same. + KILL (KILL current room)