* Set the correct flags in the target room after an IMAP COPY command.
authorArt Cancro <ajc@citadel.org>
Thu, 2 Jun 2005 19:32:30 +0000 (19:32 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 2 Jun 2005 19:32:30 +0000 (19:32 +0000)
citadel/ChangeLog
citadel/imap_fetch.c
citadel/imap_misc.c
citadel/imap_store.c
citadel/msgbase.c
citadel/msgbase.h
citadel/user_ops.c

index 3c075a6498beaf2fdf2d20d15a0eff90808577d6..7d417c34f093506b65a101b5c1b713e28fb2cd46 100644 (file)
@@ -6764,4 +6764,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 c0d18b1cd56a01afb4935b2a3f6ce510874ef523..33028fc27eb1041ffea252f4c5bc0e27564f62b5 100644 (file)
@@ -681,7 +681,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
 
        /* Mark this message as "seen" *unless* this is a "peek" operation */
        if (is_peek == 0) {
-               CtdlSetSeen(msgnum, 1, ctdlsetseen_seen);
+               CtdlSetSeen(msgnum, 1, ctdlsetseen_seen, NULL, NULL);
        }
 }
 
index 59e5d8178381698563efe3cb39c15a9af98e2bfe..00c652f277dfd4a7d4c2acd9883956d384874ab2 100644 (file)
 int imap_do_copy(char *destination_folder) {
        int i;
        char roomname[ROOMNAMELEN];
+       struct ctdlroom qrbuf;
+
+       if (IMAP->num_msgs < 1) {
+               return(0);
+       }
 
        i = imap_grabroom(roomname, destination_folder, 0);
        if (i != 0) return(i);
 
-       if (IMAP->num_msgs > 0) {
-               for (i = 0; i < IMAP->num_msgs; ++i) {
-                       if (IMAP->flags[i] & IMAP_SELECTED) {
-                               CtdlCopyMsgToRoom(
-                                       IMAP->msgids[i],
-                                       roomname
-                               );
-                       }
+       for (i = 0; i < IMAP->num_msgs; ++i) {
+               if (IMAP->flags[i] & IMAP_SELECTED) {
+                       CtdlCopyMsgToRoom(IMAP->msgids[i], roomname);
+               }
+       }
+
+       /* Set the flags... */
+       i = getroom(&qrbuf, roomname);
+       if (i != 0) return(i);
+
+       for (i = 0; i < IMAP->num_msgs; ++i) {
+               if (IMAP->flags[i] & IMAP_SELECTED) {
+                       CtdlSetSeen(IMAP->msgids[i],
+                               ((IMAP->flags[i] & IMAP_SEEN) ? 1 : 0),
+                               ctdlsetseen_seen,
+                               NULL, &qrbuf
+                       );
+                       CtdlSetSeen(IMAP->msgids[i],
+                               ((IMAP->flags[i] & IMAP_ANSWERED) ? 1 : 0),
+                               ctdlsetseen_answered,
+                               NULL, &qrbuf
+                       );
                }
        }
 
@@ -81,6 +100,7 @@ int imap_do_copy(char *destination_folder) {
 }
 
 
+
 /*
  * This function is called by the main command loop.
  */
@@ -227,10 +247,12 @@ void imap_do_append_flags(long new_msgnum, char *new_message_flags) {
                extract_token(this_flag, flags, i, ' ', sizeof this_flag);
                if (this_flag[0] == '\\') strcpy(this_flag, &this_flag[1]);
                if (!strcasecmp(this_flag, "Seen")) {
-                       CtdlSetSeen(new_msgnum, 1, ctdlsetseen_seen);
+                       CtdlSetSeen(new_msgnum, 1, ctdlsetseen_seen,
+                               NULL, NULL);
                }
                if (!strcasecmp(this_flag, "Answered")) {
-                       CtdlSetSeen(new_msgnum, 1, ctdlsetseen_answered);
+                       CtdlSetSeen(new_msgnum, 1, ctdlsetseen_answered,
+                               NULL, NULL);
                }
        }
 }
@@ -325,7 +347,7 @@ void imap_append(int num_parms, char *parms[]) {
        IMAP->transmitted_message[literal_length] = 0;  /* reterminate it */
 
        lprintf(CTDL_DEBUG, "Converting message format\n");
-        msg = convert_internet_message(IMAP->transmitted_message);
+       msg = convert_internet_message(IMAP->transmitted_message);
        IMAP->transmitted_message = NULL;
        IMAP->transmitted_length = 0;
 
@@ -345,23 +367,23 @@ void imap_append(int num_parms, char *parms[]) {
        }
        usergoto(roomname, 0, 0, &msgs, &new);
 
-        /* If the user is locally authenticated, FORCE the From: header to
-         * show up as the real sender.  FIXME do we really want to do this?
+       /* If the user is locally authenticated, FORCE the From: header to
+        * show up as the real sender.  FIXME do we really want to do this?
         * Probably should make it site-definable or even room-definable.
         *
         * For now, we allow "forgeries" if the room is one of the user's
         * private mailboxes.
-         */
-        if (CC->logged_in) {
+        */
+       if (CC->logged_in) {
           if ( (CC->room.QRflags & QR_MAILBOX) == 0) {
-                if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']);
-                if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']);
-                if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']);
-                msg->cm_fields['A'] = strdup(CC->user.fullname);
-                msg->cm_fields['N'] = strdup(config.c_nodename);
-                msg->cm_fields['H'] = strdup(config.c_humannode);
+               if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']);
+               if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']);
+               if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']);
+               msg->cm_fields['A'] = strdup(CC->user.fullname);
+               msg->cm_fields['N'] = strdup(config.c_nodename);
+               msg->cm_fields['H'] = strdup(config.c_humannode);
            }
-        }
+       }
 
        /* 
         * Can we post here?
@@ -376,7 +398,7 @@ void imap_append(int num_parms, char *parms[]) {
        else {
                /* Yes ... go ahead and post! */
                if (msg != NULL) {
-                       new_msgnum = CtdlSubmitMsg(msg, NULL, "");
+                       new_msgnum = CtdlSubmitMsg(msg, NULL, "");
                }
                if (new_msgnum >= 0L) {
                        cprintf("%s OK APPEND completed\r\n", parms[0]);
index 1e65dae4c81c1db07743d7c6ee0ccf429efe9d57..b9fc5fdfe1144d51a6a52aeb3a0f713fbff3b235 100644 (file)
@@ -81,14 +81,16 @@ void imap_do_store_msg(int seq, char *oper, unsigned int bits_to_twiddle) {
 
        if (bits_to_twiddle & IMAP_SEEN) {
                CtdlSetSeen(IMAP->msgids[seq],
-                               ((IMAP->flags[seq] & IMAP_SEEN) ? 1 : 0),
-                               ctdlsetseen_seen
+                       ((IMAP->flags[seq] & IMAP_SEEN) ? 1 : 0),
+                       ctdlsetseen_seen,
+                       NULL, NULL
                );
        }
        if (bits_to_twiddle & IMAP_ANSWERED) {
                CtdlSetSeen(IMAP->msgids[seq],
-                               ((IMAP->flags[seq] & IMAP_ANSWERED) ? 1 : 0),
-                               ctdlsetseen_answered
+                       ((IMAP->flags[seq] & IMAP_ANSWERED) ? 1 : 0),
+                       ctdlsetseen_answered,
+                       NULL, NULL
                );
        }
 
index b8ac0567d877edaa409140c6ef69408f19a26404..e090cc8f498ea962f43b1a93b316690fc88d66fa 100644 (file)
@@ -306,7 +306,8 @@ void CtdlGetSeen(char *buf, int which_set) {
 /*
  * Manipulate the "seen msgs" string (or other message set strings)
  */
-void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) {
+void CtdlSetSeen(long target_msgnum, int target_setting, int which_set,
+               struct ctdluser *which_user, struct ctdlroom *which_room) {
        struct cdbdata *cdbfr;
        int i;
        int is_seen = 0;
@@ -326,7 +327,10 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) {
                target_msgnum, target_setting, which_set);
 
        /* Learn about the user and room in question */
-       CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
+       CtdlGetRelationship(&vbuf,
+               ((which_user != NULL) ? which_user : &CC->user),
+               ((which_room != NULL) ? which_room : &CC->room)
+       );
 
        /* Load the message list */
        cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
@@ -439,7 +443,10 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) {
 
        /* lprintf(CTDL_DEBUG, " after optimize: %s\n", vset); */
        free(msglist);
-       CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
+       CtdlSetRelationship(&vbuf,
+               ((which_user != NULL) ? which_user : &CC->user),
+               ((which_room != NULL) ? which_room : &CC->room)
+       );
 }
 
 
index 009f975c542fb855689e92e812a90612390c6c03..dd069ac5515c266b5f8aee7b65abb349e97c8435 100644 (file)
@@ -132,7 +132,8 @@ enum {
        ctdlsetseen_seen,
        ctdlsetseen_answered
 };
-void CtdlSetSeen(long target_msgnum, int target_setting, int which_set);
+void CtdlSetSeen(long target_msgnum, int target_setting, int which_set,
+               struct ctdluser *which_user, struct ctdlroom *which_room);
 void CtdlGetSeen(char *buf, int which_set);
 
 struct recptypes *validate_recipients(char *recipients);
index f375637e16d30342a25121a436faccf51717715c..a826165464ed801db2009d621777296c8db67e91 100644 (file)
@@ -1099,7 +1099,7 @@ void cmd_seen(char *argbuf) {
        target_msgnum = extract_long(argbuf, 0);
        target_setting = extract_int(argbuf, 1);
 
-       CtdlSetSeen(target_msgnum, target_setting, ctdlsetseen_seen);
+       CtdlSetSeen(target_msgnum, target_setting, ctdlsetseen_seen, NULL, NULL);
        cprintf("%d OK\n", CIT_OK);
 }