From ee58ec23144196cf6635db93d7ae9154ae3af1e9 Mon Sep 17 00:00:00 2001 From: Michael Haeckel Date: Thu, 3 May 2001 07:21:45 +0000 Subject: [PATCH] =?UTF-8?q?Add=20"forward=20as=20attachment".=20Patch=20by?= =?UTF-8?q?=20Ingo=20Kl=C3=B6cker=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/kdenetwork/kmail/; revision=94903 --- kmcomposewin.cpp | 5 +++- kmheaders.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++-- kmheaders.h | 1 + kmmainwin.cpp | 12 +++++++++ kmmainwin.h | 3 ++- kmmainwin.rc | 3 ++- 6 files changed, 86 insertions(+), 5 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 7b0112729..0569b9575 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -1302,7 +1302,10 @@ void KMComposeWin::msgPartToItem(const KMMessagePart* msgPart, if (len > 9999) lenStr.sprintf("%uK", (len>>10)); else lenStr.sprintf("%u", len); - lvi->setText(0, msgPart->fileName()); + if (!msgPart->fileName().isEmpty()) + lvi->setText(0, msgPart->fileName()); + else + lvi->setText(0, msgPart->name()); lvi->setText(1, lenStr); lvi->setText(2, msgPart->contentTransferEncodingStr()); lvi->setText(3, msgPart->typeStr() + "/" + msgPart->subtypeStr()); diff --git a/kmheaders.cpp b/kmheaders.cpp index 2efd56b1b..025b37d81 100644 --- a/kmheaders.cpp +++ b/kmheaders.cpp @@ -1304,15 +1304,77 @@ void KMHeaders::forwardMsg () KMMessage *msg = currentMsg(); if (!msg) return; + QString id = msg->headerField( "X-KMail-Identity" ); + if (id.isEmpty() && mFolder->isMailingList()) + id = mFolder->mailingListIdentity(); kernel->kbp()->busy(); - win = new KMComposeWin(msg->createForward(), - msg->headerField( "X-KMail-Identity" )); + win = new KMComposeWin(msg->createForward(), id); win->setCharset(msg->codec()->name(), TRUE); win->show(); kernel->kbp()->idle(); } +//----------------------------------------------------------------------------- +void KMHeaders::forwardAttachedMsg () +{ + KMComposeWin *win; + KMMessageList* msgList = selectedMsgs(); + QString id; + + if (msgList->count() >= 2) { + // don't respect X-KMail-Identity headers because they might differ for + // the selected mails + if (mFolder->isMailingList()) + id = mFolder->mailingListIdentity(); + else + id = ""; + } + else if (msgList->count() == 1) { + KMMessage *msg = currentMsg(); + id = msg->headerField( "X-KMail-Identity" ); + if (id.isEmpty() && mFolder->isMailingList()) + id = mFolder->mailingListIdentity(); + } + + KMMessage *fwdMsg = new KMMessage; + + fwdMsg->initHeader(id); + fwdMsg->setAutomaticFields(true); + + kdDebug() << "Launching composer window\n" << endl; + kernel->kbp()->busy(); + win = new KMComposeWin(fwdMsg, id); + + kdDebug() << "Doing forward as attachment\n" << endl; + // iterate through all the messages to be forwarded + for (KMMsgBase *mb = msgList->first(); mb; mb = msgList->next()) { + int idx = mFolder->find(mb); + if (idx < 0) continue; + KMMessage *thisMsg = mFolder->getMsg(idx); + if (!thisMsg) continue; + // set the part + KMMessagePart *msgPart = new KMMessagePart; + msgPart->setTypeStr("message"); + msgPart->setSubtypeStr("rfc822"); + msgPart->setCharset(thisMsg->charset()); + msgPart->setName("forwarded message"); + msgPart->setCte(DwMime::kCte8bit); // is 8bit O.K.? + msgPart->setContentDescription(thisMsg->from()+": "+thisMsg->subject()); + // THIS HAS TO BE AFTER setCte()!!!! + msgPart->setBodyEncoded(QCString(thisMsg->asString())); + msgPart->setCharset(""); + + thisMsg->setStatus(KMMsgStatusForwarded); + + win->addAttach(msgPart); + } + + win->show(); + kernel->kbp()->idle(); +} + + //----------------------------------------------------------------------------- void KMHeaders::redirectMsg() { @@ -2445,6 +2507,7 @@ void KMHeaders::slotRMB() mOwner->replyAction->plug(menu); mOwner->replyAllAction->plug(menu); mOwner->forwardAction->plug(menu); + mOwner->forwardAttachedAction->plug(menu); mOwner->redirectAction->plug(menu); mOwner->bounceAction->plug(menu); } diff --git a/kmheaders.h b/kmheaders.h index b504fd430..d50a1eed0 100644 --- a/kmheaders.h +++ b/kmheaders.h @@ -98,6 +98,7 @@ public: virtual void undo(); virtual bool canUndo() const; virtual void forwardMsg(); + virtual void forwardAttachedMsg(); virtual void bounceMsg(); virtual void replyToMsg(QString selection=QString::null); virtual void noQuoteReplyToMsg(); diff --git a/kmmainwin.cpp b/kmmainwin.cpp index f5f0267bb..4d764ec9a 100644 --- a/kmmainwin.cpp +++ b/kmmainwin.cpp @@ -897,6 +897,13 @@ void KMMainWin::slotForwardMsg() } +//----------------------------------------------------------------------------- +void KMMainWin::slotForwardAttachedMsg() +{ + mHeaders->forwardAttachedMsg(); +} + + //----------------------------------------------------------------------------- void KMMainWin::slotRedirectMsg() { @@ -1510,6 +1517,7 @@ void KMMainWin::slotMsgPopup(const KURL &aUrl, const QPoint& aPoint) replyAction->plug(menu); replyAllAction->plug(menu); forwardAction->plug(menu); + forwardAttachedAction->plug(menu); redirectAction->plug(menu); bounceAction->plug(menu); } @@ -1661,6 +1669,9 @@ void KMMainWin::setupMenuBar() forwardAction = new KAction( i18n("&Forward..."), "mail_forward", Key_F, this, SLOT(slotForwardMsg()), actionCollection(), "forward" ); + forwardAttachedAction = new KAction( i18n("&Forward as attachment"), "mail_forward_attached", SHIFT+Key_F, this, + SLOT(slotForwardAttachedMsg()), actionCollection(), "forward_attached" ); + redirectAction = new KAction( i18n("R&edirect..."), Key_E, this, SLOT(slotRedirectMsg()), actionCollection(), "redirect" ); @@ -2014,6 +2025,7 @@ void KMMainWin::updateMessageMenu() copyActionMenu->setEnabled( mass_actions ); deleteAction->setEnabled( mass_actions ); forwardAction->setEnabled( mass_actions ); + forwardAttachedAction->setEnabled( mass_actions ); action( "apply_filters" )->setEnabled( mass_actions ); bool single_actions = count == 1; diff --git a/kmmainwin.h b/kmmainwin.h index 2e985a90f..0318eaa78 100644 --- a/kmmainwin.h +++ b/kmmainwin.h @@ -77,7 +77,7 @@ public: static void cleanup(); KAction *replyAction, *noQuoteReplyAction, *replyAllAction, *replyListAction, - *forwardAction, *redirectAction, + *forwardAction, *forwardAttachedAction, *redirectAction, *deleteAction, *saveAsAction, *bounceAction, *editAction, *printAction, *sendAgainAction; KActionMenu *filterMenu, *statusMenu, *moveActionMenu, *copyActionMenu; @@ -137,6 +137,7 @@ protected slots: void slotReplyAllToMsg(); void slotReplyListToMsg(); void slotForwardMsg(); + void slotForwardAttachedMsg(); void slotRedirectMsg(); void slotBounceMsg(); void slotMessageQueuedOrDrafted(); diff --git a/kmmainwin.rc b/kmmainwin.rc index 822931f8f..289f6aca7 100644 --- a/kmmainwin.rc +++ b/kmmainwin.rc @@ -1,4 +1,4 @@ - + &File @@ -56,6 +56,7 @@ +