[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim/kmail
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2009-08-05 11:30:27
Message-ID: 1249471827.458267.9988.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1007245 by tmcguire:

When deleting or editing attachments of encapsulated messages that are displayed in a \
seperate reader window, make sure the original message is modified, not our dummy \
copy.

kolab/issue3740
MERGE: e4, trunk, 4.3, mailreader (if it has the same problem)


 M  +20 -0     kmcommands.cpp  
 M  +3 -0      kmcommands.h  
 M  +6 -1      kmreadermainwin.cpp  
 M  +10 -2     kmreadermainwin.h  
 M  +55 -9     kmreaderwin.cpp  
 M  +32 -3     kmreaderwin.h  


--- branches/kdepim/enterprise/kdepim/kmail/kmcommands.cpp #1007244:1007245
@@ -3317,6 +3317,13 @@
 {
 }
 
+AttachmentModifyCommand::AttachmentModifyCommand( int nodeId, KMMessage *msg, \
QWidget *parent ) +  : KMCommand( parent, msg ),
+    mPartIndex( nodeId ),
+    mSernum( 0 )
+{
+}
+
 AttachmentModifyCommand::~ AttachmentModifyCommand()
 {
 }
@@ -3412,6 +3419,12 @@
   kdDebug(5006) << k_funcinfo << endl;
 }
 
+KMDeleteAttachmentCommand::KMDeleteAttachmentCommand( int nodeId, KMMessage *msg, \
QWidget *parent ) +  : AttachmentModifyCommand( nodeId, msg, parent )
+{
+  kdDebug(5006) << k_funcinfo << endl;
+}
+
 KMDeleteAttachmentCommand::~KMDeleteAttachmentCommand()
 {
   kdDebug(5006) << k_funcinfo << endl;
@@ -3468,6 +3481,13 @@
   mTempFile.setAutoDelete( true );
 }
 
+KMEditAttachmentCommand::KMEditAttachmentCommand( int nodeId, KMMessage *msg, \
QWidget *parent ) +  : AttachmentModifyCommand( nodeId, msg, parent )
+{
+  kdDebug(5006) << k_funcinfo << endl;
+  mTempFile.setAutoDelete( true );
+}
+
 KMEditAttachmentCommand::~ KMEditAttachmentCommand()
 {
 }
--- branches/kdepim/enterprise/kdepim/kmail/kmcommands.h #1007244:1007245
@@ -1036,6 +1036,7 @@
   Q_OBJECT
   public:
     AttachmentModifyCommand( partNode *node, KMMessage *msg, QWidget *parent );
+    AttachmentModifyCommand( int nodeId, KMMessage *msg, QWidget *parent );
     ~AttachmentModifyCommand();
 
   protected:
@@ -1064,6 +1065,7 @@
   Q_OBJECT
   public:
     KMDeleteAttachmentCommand( partNode *node, KMMessage *msg, QWidget *parent );
+    KMDeleteAttachmentCommand( int nodeId, KMMessage *msg, QWidget *parent );
     ~KMDeleteAttachmentCommand();
 
   protected:
@@ -1076,6 +1078,7 @@
   Q_OBJECT
   public:
     KMEditAttachmentCommand( partNode *node, KMMessage *msg, QWidget *parent );
+    KMEditAttachmentCommand( int nodeId, KMMessage *msg, QWidget *parent );
     ~KMEditAttachmentCommand();
 
   protected:
--- branches/kdepim/enterprise/kdepim/kmail/kmreadermainwin.cpp #1007244:1007245
@@ -140,10 +140,15 @@
 }
 
 //-----------------------------------------------------------------------------
-void KMReaderMainWin::showMsg( const QString & encoding, KMMessage *msg )
+void KMReaderMainWin::showMsg( const QString & encoding, KMMessage *msg,
+                               unsigned long serNumOfOriginalMessage, int \
nodeIdOffset )  {
   mReaderWin->setOverrideEncoding( encoding );
   mReaderWin->setMsg( msg, true );
+  if ( serNumOfOriginalMessage != 0 ) {
+    Q_ASSERT( nodeIdOffset != -1 );
+    mReaderWin->setOriginalMsg( serNumOfOriginalMessage, nodeIdOffset );
+  }
   mReaderWin->slotTouchMessage();
   setCaption( msg->subject() );
   mMsg = msg;
--- branches/kdepim/enterprise/kdepim/kmail/kmreadermainwin.h #1007244:1007245
@@ -36,8 +36,16 @@
 
   void setUseFixedFont( bool useFixedFont );
 
-  // take ownership of and show @param msg
-  void showMsg( const QString & encoding, KMMessage *msg );
+  /**
+   * take ownership of and show @param msg
+   *
+   * The last two paramters, serNumOfOriginalMessage and nodeIdOffset, are needed \
when @p msg +   * is derived from another message, e.g. the user views an \
encapsulated message in this window. +   * Then, the reader needs to know about that \
original message, so those to paramters are passed +   * onto setOriginalMsg() of \
KMReaderWin. +   */
+  void showMsg( const QString & encoding, KMMessage *msg,
+                unsigned long serNumOfOriginalMessage = 0, int nodeIdOffset = -1 );
 
   /**
    * Sets up action list for forward menu.
--- branches/kdepim/enterprise/kdepim/kmail/kmreaderwin.cpp #1007244:1007245
@@ -488,6 +488,8 @@
                          const char *aName,
                          int aFlags )
   : QWidget(aParent, aName, aFlags | Qt::WDestructiveClose),
+    mSerNumOfOriginalMessage( 0 ),
+    mNodeIdOffset( -1 ),
     mAttachmentStrategy( 0 ),
     mHeaderStrategy( 0 ),
     mHeaderStyle( 0 ),
@@ -1192,8 +1194,15 @@
 }
 
 //-----------------------------------------------------------------------------
-void KMReaderWin::setMsg(KMMessage* aMsg, bool force)
+void KMReaderWin::setOriginalMsg( unsigned long serNumOfOriginalMessage, int \
nodeIdOffset )  {
+  mSerNumOfOriginalMessage = serNumOfOriginalMessage;
+  mNodeIdOffset = nodeIdOffset;
+}
+
+//-----------------------------------------------------------------------------
+void KMReaderWin::setMsg( KMMessage* aMsg, bool force )
+{
   if (aMsg)
       kdDebug(5006) << "(" << aMsg->getMsgSerNum() << ", last " << mLastSerNum << ") \
                " << aMsg->subject() << " "
         << aMsg->fromStrip() << ", readyToShow " << (aMsg->readyToShow()) << endl;
@@ -2104,7 +2113,7 @@
 
 
 //-----------------------------------------------------------------------------
-void KMReaderWin::atmViewMsg(KMMessagePart* aMsgPart)
+void KMReaderWin::atmViewMsg( KMMessagePart* aMsgPart, int nodeId )
 {
   assert(aMsgPart!=0);
   KMMessage* msg = new KMMessage;
@@ -2116,7 +2125,7 @@
   msg->setUID(message()->UID());
   msg->setReadyToShow(true);
   KMReaderMainWin *win = new KMReaderMainWin();
-  win->showMsg( overrideEncoding(), msg );
+  win->showMsg( overrideEncoding(), msg, message()->getMsgSerNum(), nodeId );
   win->show();
 }
 
@@ -2249,7 +2258,7 @@
     if (pname.isEmpty()) pname="unnamed";
     // image Attachment is saved already
     if (kasciistricmp(msgPart.typeStr(), "message")==0) {
-      atmViewMsg(&msgPart);
+      atmViewMsg( &msgPart,id );
     } else if ((kasciistricmp(msgPart.typeStr(), "text")==0) &&
 	       (kasciistricmp(msgPart.subtypeStr(), "x-vcard")==0)) {
       setMsgPart( &msgPart, htmlMail(), name, pname );
@@ -2280,7 +2289,7 @@
   KMMessagePart& msgPart = node->msgPart();
   if (kasciistricmp(msgPart.typeStr(), "message")==0)
   {
-    atmViewMsg(&msgPart);
+    atmViewMsg( &msgPart, id );
     return;
   }
 
@@ -2660,6 +2669,30 @@
   return false;
 }
 
+void KMReaderWin::fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId )
+{
+  Q_ASSERT( msg && nodeId );
+
+  if ( mSerNumOfOriginalMessage != 0 ) {
+    KMFolder *folder = 0;
+    int index = -1;
+    KMMsgDict::instance()->getLocation( mSerNumOfOriginalMessage, &folder, &index );
+    if ( folder && index != -1 )
+      *msg = folder->getMsg( index );
+
+    if ( !( *msg ) ) {
+      kdWarning( 5006 ) << "Unable to find the original message, aborting attachment \
deletion!" << endl; +      return;
+    }
+
+    *nodeId = node->nodeId() + mNodeIdOffset;
+  }
+  else {
+    *nodeId = node->nodeId();
+    *msg = message();
+  }
+}
+
 void KMReaderWin::slotDeleteAttachment(partNode * node)
 {
   if ( KMessageBox::warningContinueCancel( this,
@@ -2668,8 +2701,14 @@
      != KMessageBox::Continue ) {
     return;
   }
-  KMDeleteAttachmentCommand* command = new KMDeleteAttachmentCommand( node, \
                message(), this );
-  command->start();
+
+  int nodeId = -1;
+  KMMessage *msg = 0;
+  fillCommandInfo( node, &msg, &nodeId );
+  if ( msg && nodeId != -1 ) {
+    KMDeleteAttachmentCommand* command = new KMDeleteAttachmentCommand( nodeId, msg, \
this ); +    command->start();
+  }
 }
 
 void KMReaderWin::slotEditAttachment(partNode * node)
@@ -2680,8 +2719,14 @@
         != KMessageBox::Continue ) {
     return;
   }
-  KMEditAttachmentCommand* command = new KMEditAttachmentCommand( node, message(), \
                this );
-  command->start();
+
+  int nodeId = -1;
+  KMMessage *msg = 0;
+  fillCommandInfo( node, &msg, &nodeId );
+  if ( msg && nodeId != -1 ) {
+    KMEditAttachmentCommand* command = new KMEditAttachmentCommand( nodeId, msg, \
this ); +    command->start();
+  }
 }
 
 KMail::CSSHelper* KMReaderWin::cssHelper()
@@ -2780,6 +2825,7 @@
       label = node->msgPart().name().stripWhiteSpace();
     if( label.isEmpty() )
       label = node->msgPart().fileName();
+    // FIXME: add deleted attachments to the blacklist!
     bool typeBlacklisted = node->msgPart().typeStr() == "multipart";
     if ( !typeBlacklisted && node->msgPart().typeStr() == "application" ) {
       typeBlacklisted = node->msgPart().subtypeStr() == "pgp-encrypted"
--- branches/kdepim/enterprise/kdepim/kmail/kmreaderwin.h #1007244:1007245
@@ -142,8 +142,19 @@
 
   /** Set the message that shall be shown. If msg is 0, an empty page is
       displayed. */
-  virtual void setMsg(KMMessage* msg, bool force = false);
+  virtual void setMsg( KMMessage* msg, bool force = false );
 
+  /**
+   * This should be called when setting a message that was constructed from another \
message, which +   * is the case when viewing encapsulated messages in the seperate \
reader window. +   * We need to know the serial number of the original message, and \
at which part index the encapsulated +   * message was at that original message, so \
that deleting and editing attachments can work on the +   * original message.
+   *
+   * @see slotDeleteAttachment, slotEditAttachment, fillCommandInfo
+   */
+  void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
+
   /** Instead of settings a message to be shown sets a message part
       to be shown */
   void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
@@ -213,8 +224,12 @@
   /** Enable the displaying of messages again after an URL was displayed */
   void enableMsgDisplay();
 
-  /** View message part of type message/RFC822 in extra viewer window. */
-  void atmViewMsg(KMMessagePart* msgPart);
+  /**
+   * View message part of type message/RFC822 in extra viewer window.
+   * @param msgPart the part to display
+   * @param nodeId the part index of the message part that is displayed
+   */
+  void atmViewMsg( KMMessagePart* msgPart, int nodeId );
 
   bool atBottom() const;
 
@@ -399,6 +414,15 @@
   void slotLevelQuote( int l );
   void slotTouchMessage();
 
+  /**
+   * Find the node ID and the message of the attachment that should be edited or \
deleted. +   * This is used when setOriginalMsg() was called before, in that case we \
want to operate +   * on the original message instead of our copy.
+   *
+   * @see setOriginalMsg
+   */
+  void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
+
   void slotDeleteAttachment( partNode* node );
   void slotEditAttachment( partNode* node );
 
@@ -501,6 +525,11 @@
   int mAtmCurrent;
   QString mAtmCurrentName;
   KMMessage *mMessage;
+
+  // See setOriginalMsg() for an explaination for those two.
+  unsigned long mSerNumOfOriginalMessage;
+  int mNodeIdOffset;
+
   // widgets:
   QSplitter * mSplitter;
   QHBox *mBox;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic