Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv12518/src/mail

Modified Files:
        ASMailFolder.cpp MailFolderCmn.cpp 
Log Message:
finally got rid of bool parameter in MF::DeleteMessages(); added another parameter to 
DeleteOrTrashMessages() to allow not copy the messages to trash folder (useful when 
deleting messages as part of moving them)

Index: ASMailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/ASMailFolder.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -b -u -2 -r1.64 -r1.65
--- ASMailFolder.cpp    16 Jul 2002 20:21:43 -0000      1.64
+++ ASMailFolder.cpp    5 Sep 2002 23:45:16 -0000       1.65
@@ -299,11 +299,14 @@
 public:
    MT_DeleteOrTrashMessages(ASMailFolder *mf, UserData ud,
-                            const UIdArray *sequence)
+                            const UIdArray *sequence,
+                            int flags)
       : MailThreadSeq(mf, ud, sequence)
       {
+         m_Flags = flags;
       }
+
    virtual void WorkFunction(void)
       {
-         bool rc = m_MailFolder->DeleteOrTrashMessages(m_Seq);
+         bool rc = m_MailFolder->DeleteOrTrashMessages(m_Seq, m_Flags);
          SendEvent(ASMailFolder::ResultInt::Create
                    (
@@ -320,4 +323,7 @@
 #endif
       }
+
+private:
+   int m_Flags;
 };
 
@@ -327,12 +333,12 @@
    MT_DeleteMessages(ASMailFolder *mf, UserData ud,
                      const UIdArray *sequence,
-                     bool expunge)
+                     int flags)
       : MailThreadSeq(mf, ud, sequence)
       {
-         m_expunge = expunge;
+         m_Flags = flags;
       }
    virtual void WorkFunction(void)
       {
-         bool rc = m_MailFolder->DeleteMessages(m_Seq, m_expunge);
+         bool rc = m_MailFolder->DeleteMessages(m_Seq, m_Flags);
          SendEvent(ASMailFolder::ResultInt::Create
                    (
@@ -351,5 +357,5 @@
 
 protected:
-   bool   m_expunge;
+   int m_Flags;
 };
 
@@ -874,11 +880,14 @@
    /** Mark messages as deleted or move them to trash.
        @param messages pointer to an array holding the message numbers
+       @param flags combination of MailFolder::DELETE_XXX bit flags
        @return ResultInt boolean
    */
    virtual Ticket DeleteOrTrashMessages(const UIdArray *messages,
+                                        int flags,
                                         UserData ud)
       {
-         return (new MT_DeleteOrTrashMessages(this, ud, messages))->Start();
+         return (new MT_DeleteOrTrashMessages(this, ud, messages, flags))->Start();
       }
+
    /** Mark messages as deleted.
        @param messages pointer to an array holding the message numbers
@@ -886,8 +895,8 @@
    */
    virtual Ticket DeleteMessages(const UIdArray *messages,
-                                 bool expunge,
+                                 int flags,
                                  UserData ud)
       {
-         return (new MT_DeleteMessages(this, ud, messages, expunge))->Start();
+         return (new MT_DeleteMessages(this, ud, messages, flags))->Start();
       }
 

Index: MailFolderCmn.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCmn.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -b -u -2 -r1.104 -r1.105
--- MailFolderCmn.cpp   2 Sep 2002 10:44:42 -0000       1.104
+++ MailFolderCmn.cpp   5 Sep 2002 23:45:16 -0000       1.105
@@ -1484,27 +1484,36 @@
 
 bool
-MailFolderCmn::DeleteOrTrashMessages(const UIdArray *selections)
+MailFolderCmn::DeleteOrTrashMessages(const UIdArray *selections,
+                                     int flags)
 {
    CHECK( CanDeleteMessagesInFolder(GetType()), FALSE,
           "can't delete messages in this folder" );
 
-   // we can either "really delete" the messages (in fact, just mark them as
-   // deleted) or move them to trash which implies deleting and expunging them
-   bool reallyDelete = !READ_CONFIG(GetProfile(), MP_USE_TRASH_FOLDER);
-
-   // If we are the trash folder, we *really* delete
-   wxString trashFolderName = READ_CONFIG(GetProfile(), MP_TRASH_FOLDER);
-   if ( !reallyDelete && GetName() == trashFolderName )
-      reallyDelete = true;
+   // we can either delete the messages by moving them to the trash folder and
+   // expunging them from this one or by marking them deleted and leaving them
+   // in place
+   bool useTrash = READ_CONFIG_BOOL(GetProfile(), MP_USE_TRASH_FOLDER);
 
-   bool rc;
-   if ( reallyDelete )
+   wxString trashFolderName;
+   if ( useTrash )
    {
-      // delete without expunging
-      rc = DeleteMessages(selections, FALSE /* don't expunge */);
+      // however if we are the trash folder, we can't use it
+      trashFolderName = READ_CONFIG(GetProfile(), MP_TRASH_FOLDER);
+      if ( GetName() == trashFolderName )
+         useTrash = false;
    }
-   else // move to trash
+
+   bool rc;
+   if ( useTrash )
    {
-      rc = SaveMessages(selections, trashFolderName);
+      // skip moving the messages to trash if the caller disabled it: in this
+      // case we keep the same apparent behaviour as usual (i.e. unlike in the
+      // !useTrash case, no messages marked as deleted are left in the folder)
+      // but we don't copy the messages unnecessarily -- this is especially
+      // useful when moving the messages, as when we delete them after having
+      // successfully copied them elsewhere we really don't need to keep yet
+      // another copy in the trash
+      rc = flags & DELETE_NO_TRASH ? true
+                                   : SaveMessages(selections, trashFolderName);
       if ( rc )
       {
@@ -1518,4 +1527,10 @@
          rc = DeleteMessages(selections, TRUE /* expunge */);
       }
+
+   }
+   else // delete in place
+   {
+      // delete without expunging
+      rc = DeleteMessages(selections, FALSE /* don't expunge */);
    }
 
@@ -1524,5 +1539,5 @@
 
 bool
-MailFolderCmn::DeleteMessages(const UIdArray *selections, bool expunge)
+MailFolderCmn::DeleteMessages(const UIdArray *selections, int flags)
 {
    CHECK( selections, false,
@@ -1533,5 +1548,5 @@
 
    bool rc = SetSequenceFlag(SEQ_UID, seq, MailFolder::MSG_STAT_DELETED);
-   if ( rc && expunge )
+   if ( rc && (flags & DELETE_EXPUNGE) )
       ExpungeMessages();
 



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to