changed CtdlSetSeen() API
authorArt Cancro <ajc@citadel.org>
Mon, 10 Oct 2005 02:38:29 +0000 (02:38 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Oct 2005 02:38:29 +0000 (02:38 +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 1182a8736a25e580c80df7a5e8fb11e576e4f109..8f9af96a0b2687fe1caee34ca52eba0f4e3cc5b5 100644 (file)
@@ -1,3 +1,6 @@
+Sun Oct  9 22:37:44 EDT 2005 Art Cancro <ajc@uncensored.citadel.org>
+ * CtdlSetSeen() now accepts a list of message numbers instead of just one.
+
 Sat Oct  8 18:40:50 EDT 2005 Art Cancro <ajc@uncensored.citadel.org>
 * Replaced the various "socket is broken" messages with the message
   "Client disconnected: ending session."  The previous messages were concerning
index b2506051fd1bc7695248b97257f2da3a3d002dc1..5dc32135983dc5c1cbfd05286834682b440ba788 100644 (file)
@@ -703,7 +703,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, NULL, NULL);
+               CtdlSetSeen(&msgnum, 1, 1, ctdlsetseen_seen, NULL, NULL);
        }
 }
 
index b670f3ad68623bd2fe821285928b76b72c838c2a..9ed132c4a360bb4b2e8a7262c9e8fe4d372bd91a 100644 (file)
@@ -101,12 +101,12 @@ int imap_do_copy(char *destination_folder) {
 
        for (i = 0; i < IMAP->num_msgs; ++i) {
                if (IMAP->flags[i] & IMAP_SELECTED) {
-                       CtdlSetSeen(IMAP->msgids[i],
+                       CtdlSetSeen(&IMAP->msgids[i], 1,
                                ((IMAP->flags[i] & IMAP_SEEN) ? 1 : 0),
                                ctdlsetseen_seen,
                                NULL, &qrbuf
                        );
-                       CtdlSetSeen(IMAP->msgids[i],
+                       CtdlSetSeen(&IMAP->msgids[i], 1,
                                ((IMAP->flags[i] & IMAP_ANSWERED) ? 1 : 0),
                                ctdlsetseen_answered,
                                NULL, &qrbuf
@@ -265,11 +265,11 @@ 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, 1, ctdlsetseen_seen,
                                NULL, NULL);
                }
                if (!strcasecmp(this_flag, "Answered")) {
-                       CtdlSetSeen(new_msgnum, 1, ctdlsetseen_answered,
+                       CtdlSetSeen(&new_msgnum, 1, 1, ctdlsetseen_answered,
                                NULL, NULL);
                }
        }
index 49784cc13dadd0092cb7f0180f917cf516b41d99..068681686ac2ffb7b31573546006e9776eb7d0d5 100644 (file)
@@ -80,14 +80,14 @@ void imap_do_store_msg(int seq, char *oper, unsigned int bits_to_twiddle) {
        }
 
        if (bits_to_twiddle & IMAP_SEEN) {
-               CtdlSetSeen(IMAP->msgids[seq],
+               CtdlSetSeen(&IMAP->msgids[seq], 1,
                        ((IMAP->flags[seq] & IMAP_SEEN) ? 1 : 0),
                        ctdlsetseen_seen,
                        NULL, NULL
                );
        }
        if (bits_to_twiddle & IMAP_ANSWERED) {
-               CtdlSetSeen(IMAP->msgids[seq],
+               CtdlSetSeen(&IMAP->msgids[seq], 1,
                        ((IMAP->flags[seq] & IMAP_ANSWERED) ? 1 : 0),
                        ctdlsetseen_answered,
                        NULL, NULL
index e1608b4cba898745fbc81e2c63377c3d328385cc..0913354329e9af4b203ae91c9102af42381af699 100644 (file)
@@ -348,10 +348,11 @@ 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_msgnums, int num_target_msgnums,
+               int target_setting, int which_set,
                struct ctdluser *which_user, struct ctdlroom *which_room) {
        struct cdbdata *cdbfr;
-       int i, j;
+       int i, j, k;
        int is_seen = 0;
        int was_seen = 0;
        long lo = (-1L);
@@ -368,8 +369,9 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set,
        char setstr[SIZ], lostr[SIZ], histr[SIZ];
        size_t tmp;
 
-       lprintf(CTDL_DEBUG, "CtdlSetSeen(%ld, %d, %d)\n",
-               target_msgnum, target_setting, which_set);
+       lprintf(CTDL_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %d, %d)\n",
+               num_target_msgnums, target_msgnums[0],
+               target_setting, which_set);
 
        /* Learn about the user and room in question */
        CtdlGetRelationship(&vbuf,
@@ -434,13 +436,13 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set,
        hi = (-1L);
 
        for (i=0; i<num_msgs; ++i) {
-               is_seen = 0;
 
-               if (msglist[i] == target_msgnum) {
-                       is_seen = target_setting;
-               }
-               else {
-                       is_seen = is_set[i];
+               is_seen = is_set[i];    /* Default to existing setting */
+
+               for (k=0; k<num_target_msgnums; ++k) {
+                       if (msglist[i] == target_msgnums[k]) {
+                               is_seen = target_setting;
+                       }
                }
 
                if (is_seen) {
@@ -1751,7 +1753,8 @@ void cmd_opna(char *cmdbuf)
 
        msgid = extract_long(cmdbuf, 0);
        extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
-       safestrncpy(CC->download_desired_section, desired_section, sizeof CC->download_desired_section);
+       safestrncpy(CC->download_desired_section, desired_section,
+               sizeof CC->download_desired_section);
        CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1);
 }                      
 
@@ -1776,7 +1779,8 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
        long highest_msg = 0L;
        struct CtdlMessage *msg = NULL;
 
-       /*lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom(roomname=%s, msgid=%ld, do_repl_check=%d)\n",
+       /*lprintf(CTDL_DEBUG,
+               "CtdlSaveMsgPointerInRoom(room=%s, msgid=%ld, repl=%d)\n",
                roomname, msgid, do_repl_check);*/
 
        strcpy(hold_rm, CC->room.QRname);
@@ -1799,7 +1803,9 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
                   ((roomname != NULL) ? roomname : CC->room.QRname) )
                   != 0) {
                        lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
-                       if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+                       if ( (msg != NULL) && (msg != supplied_msg) ) {
+                               CtdlFreeMessage(msg);
+                       }
                        return(ERROR + ROOM_NOT_FOUND);
                }
 
@@ -1811,7 +1817,9 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
           ((roomname != NULL) ? roomname : CC->room.QRname) )
           != 0) {
                lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
-               if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+               if ( (msg != NULL) && (msg != supplied_msg) ) {
+                       CtdlFreeMessage(msg);
+               }
                return(ERROR + ROOM_NOT_FOUND);
        }
 
@@ -1821,8 +1829,9 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
                num_msgs = 0;
        } else {
                msglist = malloc(cdbfr->len);
-               if (msglist == NULL)
+               if (msglist == NULL) {
                        lprintf(CTDL_ALERT, "ERROR malloc msglist!\n");
+               }
                num_msgs = cdbfr->len / sizeof(long);
                memcpy(msglist, cdbfr->ptr, cdbfr->len);
                cdb_free(cdbfr);
@@ -1837,7 +1846,9 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
                if (msglist[i] == msgid) {
                        lputroom(&CC->room);    /* unlock the room */
                        getroom(&CC->room, hold_rm);
-                       if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+                       if ( (msg != NULL) && (msg != supplied_msg) ) {
+                               CtdlFreeMessage(msg);
+                       }
                        free(msglist);
                        return(ERROR + ALREADY_EXISTS);
                }
@@ -1868,7 +1879,8 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
        /* If the message has an Exclusive ID, index that... */
        if (msg != NULL) {
                if (msg->cm_fields['E'] != NULL) {
-                       index_message_by_euid(msg->cm_fields['E'], &CC->room, msgid);
+                       index_message_by_euid(msg->cm_fields['E'],
+                                               &CC->room, msgid);
                }
        }
 
@@ -1881,7 +1893,9 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
        AdjRefCount(msgid, +1);
 
        /* Return success. */
-       if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+       if ( (msg != NULL) && (msg != supplied_msg) ) {
+               CtdlFreeMessage(msg);
+       }
        return (0);
 }
 
index c88e1ea0185f393f98e86904c70155c62a041121..ab01d27d92d9dcf0674fc117a040340fd5fba6b6 100644 (file)
@@ -133,7 +133,8 @@ enum {
        ctdlsetseen_seen,
        ctdlsetseen_answered
 };
-void CtdlSetSeen(long target_msgnum, int target_setting, int which_set,
+void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
+                int target_setting, int which_set,
                struct ctdluser *which_user, struct ctdlroom *which_room);
 void CtdlGetSeen(char *buf, int which_set);
 
index d5880127c1ef38229e692175a7eefbcdc42c4a72..7ccba3409c9548e513ab95402a7e092a3f74ec16 100644 (file)
@@ -1111,7 +1111,8 @@ void cmd_seen(char *argbuf) {
        target_msgnum = extract_long(argbuf, 0);
        target_setting = extract_int(argbuf, 1);
 
-       CtdlSetSeen(target_msgnum, target_setting, ctdlsetseen_seen, NULL, NULL);
+       CtdlSetSeen(&target_msgnum, 1, target_setting,
+                       ctdlsetseen_seen, NULL, NULL);
        cprintf("%d OK\n", CIT_OK);
 }