Revision: 7187
http://svn.sourceforge.net/mahogany/?rev=7187&view=rev
Author: vadz
Date: 2006-12-25 07:57:34 -0800 (Mon, 25 Dec 2006)
Log Message:
-----------
added a command to strip attachments from messages
Modified Paths:
--------------
trunk/M/CHANGES
trunk/M/doc/Manual.htex
trunk/M/include/gui/wxMenuDefs.h
trunk/M/src/gui/wxMenuDefs.cpp
trunk/M/src/gui/wxMsgCmdProc.cpp
Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES 2006-12-25 15:53:48 UTC (rev 7186)
+++ trunk/M/CHANGES 2006-12-25 15:57:34 UTC (rev 7187)
@@ -9,6 +9,7 @@
Release 0.68 '' September xx, 2006
---------------------------------------
+2006-12-25 VZ: Added "Remove attachments" command
2006-09-05 NB: Mahogany can now be compiled with wxWine
Release 0.67 'Constance' August 1, 2006
Modified: trunk/M/doc/Manual.htex
===================================================================
--- trunk/M/doc/Manual.htex 2006-12-25 15:53:48 UTC (rev 7186)
+++ trunk/M/doc/Manual.htex 2006-12-25 15:57:34 UTC (rev 7187)
@@ -31,7 +31,7 @@
\vfill{}
\title{{\LARGE \textsl{Mahogany User Manual}}\\
-{\Large Version 0.67 ``Constance''}}
+{\Large Version 0.68 ``Constance''}}
\vfill{}
@@ -65,6 +65,14 @@
All sections here except the first one present only historical interest, please
skip them unless you're updating from a very old version of Mahogany.
+\subsubsection{0.68 against 0.67}
+
+\begin{itemize}
+ \item A much faster DSPAM storage driver is used now.
+ \item Added ``Remove attachments'' command which can be used to strip the
+ unwanted attachments from a message in a local or IMAP folder.
+\end{itemize}
+
\subsubsection{0.67 against 0.66}
\begin{itemize}
Modified: trunk/M/include/gui/wxMenuDefs.h
===================================================================
--- trunk/M/include/gui/wxMenuDefs.h 2006-12-25 15:53:48 UTC (rev 7186)
+++ trunk/M/include/gui/wxMenuDefs.h 2006-12-25 15:57:34 UTC (rev 7187)
@@ -249,6 +249,7 @@
WXMENU_MSG_SPAM_UNMARK,
WXMENU_MSG_SPAM_CHECK,
WXMENU_MSG_SPAM_SUBMENU_END,
+ WXMENU_MSG_REMOVE_ATTACHMENTS,
WXMENU_MSG_SEP6,
WXMENU_MSG_SAVEADDRESSES,
Modified: trunk/M/src/gui/wxMenuDefs.cpp
===================================================================
--- trunk/M/src/gui/wxMenuDefs.cpp 2006-12-25 15:53:48 UTC (rev 7186)
+++ trunk/M/src/gui/wxMenuDefs.cpp 2006-12-25 15:57:34 UTC (rev 7187)
@@ -334,8 +334,7 @@
// msg
- // the available accelerators for this menu:
- // H
+ // the available accelerators for this menu: none!
{ WXMENU_MSG_OPEN, gettext_noop("&Open"), gettext_noop("View selected message in a separate window") , wxITEM_NORMAL },
{ WXMENU_MSG_EDIT, gettext_noop("&Edit in composer\tCtrl-E"), gettext_noop("Edit selected message in composer") , wxITEM_NORMAL },
@@ -443,6 +442,7 @@
{ WXMENU_MSG_SPAM_UNMARK, gettext_noop("Mark as &ham"), gettext_noop("Classify the message as non-spam"), wxITEM_NORMAL },
{ WXMENU_MSG_SPAM_CHECK, gettext_noop("Chec&k message...\tShift-Ctrl-K"), gettext_noop("Check if this message is spam"), wxITEM_NORMAL },
{ WXMENU_SUBMENU, wxEmptyString, wxEmptyString, wxITEM_NORMAL },
+ { WXMENU_MSG_REMOVE_ATTACHMENTS, gettext_noop("Remove attac&hments..."), gettext_noop("Remove the attachments from the selected message"), wxITEM_NORMAL },
{ WXMENU_SEPARATOR, wxEmptyString, wxEmptyString , wxITEM_NORMAL },
{ WXMENU_MSG_SAVEADDRESSES, gettext_noop("Extract &addresses..."), gettext_noop("Save all or some addresses of the message in an address book"), wxITEM_NORMAL },
Modified: trunk/M/src/gui/wxMsgCmdProc.cpp
===================================================================
--- trunk/M/src/gui/wxMsgCmdProc.cpp 2006-12-25 15:53:48 UTC (rev 7186)
+++ trunk/M/src/gui/wxMsgCmdProc.cpp 2006-12-25 15:57:34 UTC (rev 7187)
@@ -40,6 +40,7 @@
#include "gui/wxMenuDefs.h"
#include "HeaderInfo.h"
+#include "Sequence.h"
#include "TemplateDialog.h"
#include "MessageView.h"
@@ -53,6 +54,7 @@
#include "SpamFilter.h"
#include "MIMETreeDialog.h"
+#include "MFui.h"
#include "gui/wxDialogLayout.h"
@@ -205,6 +207,9 @@
/// Check whether the message is spam
void CheckIfSpam(const UIdArray& uids);
+ /// Remove attachments from the message
+ void RemoveAttachments(UIdType uid);
+
//@}
/// access the m_TicketsToDeleteList creating it if necessary
@@ -745,6 +750,10 @@
CheckIfSpam(messages);
break;
+ case WXMENU_MSG_REMOVE_ATTACHMENTS:
+ RemoveAttachments(messages[0]);
+ break;
+
default:
// try passing it to message view
if ( !m_msgView->DoMenuCommand(cmd) )
@@ -823,6 +832,135 @@
m_msgView->GetUId() == uid ? m_msgView : NULL);
}
+void MsgCmdProcImpl::RemoveAttachments(UIdType uid)
+{
+ // check that we can modify messages in this folder
+ Message_obj msg(GetMessage(uid));
+ if ( !msg )
+ {
+ wxLogError(_("Failed to access the message"));
+ return;
+ }
+
+ // this object shouldn't be DecRef()'d
+ MailFolder * const mf = msg->GetFolder();
+ CHECK_RET( mf, _T("message without folder?") );
+
+ // before doing anything else, ensure that we can write to the folder
+ if ( !CanCreateMessagesInFolder(mf->GetType()) )
+ {
+ wxLogError(_("Messages in the folder \"%s\" can't be modified, "
+ "please copy the message to a local or IMAP folder "
+ "before removing attachments from it."),
+ mf->GetName().c_str());
+ return;
+ }
+
+ if ( mf->IsReadOnly() )
+ {
+ wxLogError(_("Folder \"%s\" is read-only, please reopen it in "
+ "read-write mode."), mf->GetName().c_str());
+ return;
+ }
+
+
+ // ask the user which attachments should be removed
+ wxArrayString partsDescs;
+ wxArrayInt partsRemove;
+ const int count = msg->CountParts();
+ int i;
+ for ( i = 0; i < count; i++ )
+ {
+ const MimePart * const mimepart = msg->GetMimePart(i);
+ MimeType mimetype = mimepart->GetType();
+
+ String desc = mimepart->GetDescription();
+ if ( desc.empty() )
+ desc = mimepart->GetParam("name");
+ if ( desc.empty() )
+ desc = mimepart->GetFilename();
+ if ( desc.empty() )
+ desc.Printf(_("Unnamed %s #%d"), mimetype.GetFull().c_str(), i);
+
+ desc << " ("
+ << SizeInBytesToString(mimepart->GetSize(), SizeToString_Medium)
+ << ")";
+ partsDescs.push_back(desc);
+
+ // remove all attachments by default
+ if ( mimepart->IsAttachment() || mimetype.GetPrimary() != MimeType::TEXT )
+ partsRemove.push_back(i);
+ }
+
+ if ( partsDescs.empty() )
+ {
+ wxLogWarning(_("There are no attachments to remove in this message."));
+ return;
+ }
+
+ size_t numRemove = MDialog_GetSelections
+ (
+ _("Please check the attachments to be deleted.\n"
+ "\n"
+ "This operation cannot be undone, the selected "
+ "attachments will be permanently deleted,\n"
+ "please make sure to save them first if you need them!"),
+ String(M_TITLE_PREFIX) + _("Remove Attachments"),
+ partsDescs,
+ &partsRemove,
+ GetFrame(),
+ "RemoveAttachments"
+ );
+ if ( numRemove == 0 )
+ return; // cancelled by the user
+
+ // create a copy of the message without the attachments
+ SendMessage_obj msgCopy(SendMessage::CreateFromMsg
+ (
+ GetProfile(),
+ msg.Get(),
+ Prot_SMTP,
+ GetFrame(),
+ &partsRemove
+ ));
+
+ // and save it to the same folder: note that we don't use MailFolder::
+ // AppendMessage(Message) overload as this would modify the date header and
+ // we want to preserve it
+ String msgstr;
+ if ( !msgCopy->WriteToString(msgstr) || !mf->AppendMessage(msgstr) )
+ return;
+
+ // copy the flags of the original message
+ {
+ bool flagsOk = false;
+
+ HeaderInfoList_obj headers(HeaderInfoList::Create(mf));
+ const HeaderInfo * const hi = headers ? headers->GetEntryUId(uid) : NULL;
+ if ( hi )
+ {
+ const int flags = hi->GetStatus();
+
+ // the message we've just appended must be the last one
+ Sequence seq;
+ seq.Add(headers->Count());
+ flagsOk = mf->SetSequenceFlag(MailFolder::SEQ_MSGNO, seq, flags);
+ }
+
+ if ( !flagsOk )
+ wxLogWarning(_("Failed to preserve the message flags"));
+ }
+
+ // finally delete the old one
+ UIdArray uids;
+ uids.push_back(uid);
+ if ( !mf->DeleteMessages(&uids, MailFolder::DELETE_EXPUNGE) )
+ {
+ wxLogWarning(_("Failed to delete the original message after creating "
+ "the message copy without attachments."));
+ }
+}
+
void MsgCmdProcImpl::ReclassifyAsSpam(const UIdArray& uids, bool isSpam)
{
wxString msg = isSpam ? _("Reclassifiying as spam...")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.