[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdepim
From: Volker Krause <vkrause () kde ! org>
Date: 2008-03-07 19:25:58
Message-ID: 1204917958.896321.13845.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 783307 by vkrause:
BUG: 158854
BUG: 158681
Merged revisions 783303 via svnmerge from
https://vkrause@svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim
........
r783303 | vkrause | 2008-03-07 20:15:37 +0100 (Fri, 07 Mar 2008) | 5 lines
Some mimelib voodoo to make attachment modification/deletion work with
all kinds of multipart sturctures.
Kolab issue 1770
........
_M . (directory)
M +44 -10 kmail/kmcommands.cpp
M +4 -0 kmail/kmcommands.h
M +0 -6 kmail/kmmessage.cpp
M +0 -3 kmail/kmmessage.h
** branches/KDE/3.5/kdepim #property svnmerge-integrated
- /branches/kdepim/enterprise/kdepim:1-767022,767033,767233-767554,767556,767558-76 \
7946,767948-769318,769320-769354,769356-771105,771107-771251,771253-772311,772313-7723 \
16,772318-775194,775196-775202,775204,775207-775211,775213-778001,778003-778004,778007 \
,778010-778011,778013-778029,778031-778727,778729-779448,779450-779482,779484-779505,779507-779852,779854-779994,782647-782963,782965-782968
+ /branches/kdepim/enterprise/kdepim:1-767022,767033,767233-767554,767556,767558-767 \
946,767948-769318,769320-769354,769356-771105,771107-771251,771253-772311,772313-77231 \
6,772318-775194,775196-775202,775204,775207-775211,775213-778001,778003-778004,778007, \
778010-778011,778013-778029,778031-778727,778729-779448,779450-779482,779484-779505,779507-779852,779854-779994,782647-782963,782965-782968,783303
--- branches/KDE/3.5/kdepim/kmail/kmcommands.cpp #783306:783307
@@ -3369,7 +3369,29 @@
deleteLater();
}
+DwBodyPart * AttachmentModifyCommand::findPart(KMMessage* msg, int index)
+{
+ int accu = 0;
+ return findPartInternal( msg->getTopLevelPart(), index, accu );
+}
+DwBodyPart * AttachmentModifyCommand::findPartInternal(DwEntity * root, int index, \
int & accu) +{
+ accu++;
+ if ( index < accu ) // should not happen
+ return 0;
+ DwBodyPart *current = dynamic_cast<DwBodyPart*>( root );
+ if ( index == accu )
+ return current;
+ DwBodyPart *rv = 0;
+ if ( root->Body().FirstBodyPart() )
+ rv = findPartInternal( root->Body().FirstBodyPart(), index, accu );
+ if ( !rv && current && current->Next() )
+ rv = findPartInternal( current->Next(), index, accu );
+ return rv;
+}
+
+
KMDeleteAttachmentCommand::KMDeleteAttachmentCommand(partNode * node, KMMessage * \
msg, QWidget * parent) : AttachmentModifyCommand( node, msg, parent )
{
@@ -3385,15 +3407,18 @@
{
KMMessage *msg = retrievedMessage();
KMMessagePart part;
- // -2 because partNode counts root and body of the message as well
- DwBodyPart *dwpart = msg->dwBodyPart( mPartIndex - 2 );
+ DwBodyPart *dwpart = findPart( msg, mPartIndex );
if ( !dwpart )
return Failed;
KMMessage::bodyPart( dwpart, &part, true );
if ( !part.isComplete() )
return Failed;
- msg->removeBodyPart( dwpart );
+ DwBody *parentNode = dynamic_cast<DwBody*>( dwpart->Parent() );
+ if ( !parentNode )
+ return Failed;
+ parentNode->RemoveBodyPart( dwpart );
+
// add dummy part to show that a attachment has been deleted
KMMessagePart dummyPart;
dummyPart.duplicate( part );
@@ -3409,7 +3434,9 @@
} else if ( cd.isEmpty() ) {
dummyPart.setContentDisposition( "attachment" );
}
- msg->addBodyPart( &dummyPart );
+ DwBodyPart* newDwPart = msg->createDWBodyPart( &dummyPart );
+ parentNode->AddBodyPart( newDwPart );
+ msg->getTopLevelPart()->Assemble();
KMMessage *newMsg = new KMMessage();
newMsg->fromDwString( msg->asDwString() );
@@ -3435,14 +3462,16 @@
{
KMMessage *msg = retrievedMessage();
KMMessagePart part;
- // -2 because partNode counts root and body of the message as well
- DwBodyPart *dwpart = msg->dwBodyPart( mPartIndex - 2 );
+ DwBodyPart *dwpart = findPart( msg, mPartIndex );
if ( !dwpart )
return Failed;
KMMessage::bodyPart( dwpart, &part, true );
if ( !part.isComplete() )
return Failed;
+ if( !dynamic_cast<DwBody*>( dwpart->Parent() ) )
+ return Failed;
+
mTempFile.file()->writeBlock( part.bodyDecodedBinary() );
mTempFile.file()->flush();
@@ -3472,16 +3501,21 @@
// build the new message
KMMessage *msg = retrievedMessage();
KMMessagePart part;
- // -2 because partNode counts root and body of the message as well
- DwBodyPart *dwpart = msg->dwBodyPart( mPartIndex - 2 );
+ DwBodyPart *dwpart = findPart( msg, mPartIndex );
KMMessage::bodyPart( dwpart, &part, true );
- msg->removeBodyPart( dwpart );
+ DwBody *parentNode = dynamic_cast<DwBody*>( dwpart->Parent() );
+ assert( parentNode );
+ parentNode->RemoveBodyPart( dwpart );
+
KMMessagePart att;
att.duplicate( part );
att.setBodyEncodedBinary( data );
- msg->addBodyPart( &att );
+ DwBodyPart* newDwPart = msg->createDWBodyPart( &att );
+ parentNode->AddBodyPart( newDwPart );
+ msg->getTopLevelPart()->Assemble();
+
KMMessage *newMsg = new KMMessage();
newMsg->fromDwString( msg->asDwString() );
newMsg->setStatus( msg->status() );
--- branches/KDE/3.5/kdepim/kmail/kmcommands.h #783306:783307
@@ -32,6 +32,8 @@
class KMMsgBase;
class KMReaderWin;
class partNode;
+class DwBodyPart;
+class DwEntity;
namespace KIO { class Job; }
namespace KMail {
class Composer;
@@ -1038,6 +1040,7 @@
protected:
void storeChangedMessage( KMMessage* msg );
+ DwBodyPart* findPart( KMMessage* msg, int index );
virtual Result doAttachmentModify() = 0;
protected:
@@ -1046,6 +1049,7 @@
private:
Result execute();
+ DwBodyPart* findPartInternal( DwEntity* root, int index, int &accu );
private slots:
void messageStoreResult( KMFolderImap* folder, bool success );
--- branches/KDE/3.5/kdepim/kmail/kmmessage.cpp #783306:783307
@@ -3126,12 +3126,6 @@
mMsg->Body().DeleteBodyParts();
}
-void KMMessage::removeBodyPart(DwBodyPart * dwPart)
-{
- mMsg->Body().RemoveBodyPart( dwPart );
- mNeedsAssembly = true;
-}
-
//-----------------------------------------------------------------------------
DwBodyPart* KMMessage::createDWBodyPart(const KMMessagePart* aPart)
{
--- branches/KDE/3.5/kdepim/kmail/kmmessage.h #783306:783307
@@ -627,9 +627,6 @@
/** Delete all body parts. */
void deleteBodyParts();
- /** Removes the given body part. */
- void removeBodyPart( DwBodyPart * dwPart );
-
/** Set "Status" and "X-Status" fields of the message from the
* internal message status. */
void setStatusFields();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic