$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 "<C>opy" in
+ the client.
+
Revision 1.389 1999/10/20 16:07:48 ajc
* Wholist fixes for users who are in chat mode
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
/* space key same as <N> */ 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;
&&(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;
||(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");
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]);
}
-
/*
* Save a message pointer into a specified room
* (Returns 0 for success, nonzero for failure)
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);
}
if (num_msgs > 0) for (i=0; i<num_msgs; ++i) {
if (msglist[i] == msgid) {
lputroom(&qrbuf); /* unlock the room */
+ if (msg != NULL) CtdlFreeMessage(msg);
return(ERROR + ALREADY_EXISTS);
}
}
/* Return success. */
lprintf(9, "CtdlSaveMsgPointerInRoom() succeeded\n");
+ if (msg != NULL) CtdlFreeMessage(msg);
return (0);
}
/*
- * move a message to another room
+ * move or copy a message to another room
*/
void cmd_move(char *args)
{
long num;
char targ[32];
struct quickroom qtemp;
- int foundit;
int err;
+ int is_copy = 0;
num = extract_long(args, 0);
extract(targ, args, 1);
+ is_copy = extract_int(args, 2);
getuser(&CC->usersupp, CC->curr_user);
if ((CC->usersupp.axlevel < 6)
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") );
}
#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 */
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
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)