• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • filter
filteractionredirect.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  */
19 
20 #include "filteractionredirect.h"
21 
22 #include "kernel/mailkernel.h"
23 #include "util/mailutil.h"
24 
25 #include <messagecomposer/helper/messagefactory.h>
26 #include <messagecomposer/sender/messagesender.h>
27 #include <messagecore/helpers/messagehelpers.h>
28 
29 #include <KDE/KLocale>
30 
31 using namespace MailCommon;
32 
33 FilterAction* FilterActionRedirect::newAction()
34 {
35  return new FilterActionRedirect;
36 }
37 
38 FilterActionRedirect::FilterActionRedirect( QObject *parent )
39  : FilterActionWithAddress( QLatin1String("redirect"), i18n( "Redirect To" ), parent )
40 {
41 }
42 
43 FilterAction::ReturnCode FilterActionRedirect::process(ItemContext &context , bool) const
44 {
45  if ( mParameter.isEmpty() )
46  return ErrorButGoOn;
47 
48  KMime::Message::Ptr msg = MessageCore::Util::message( context.item() );
49 
50  MessageComposer::MessageFactory factory( msg, context.item().id() );
51  factory.setFolderIdentity( Util::folderIdentity( context.item() ) );
52  factory.setIdentityManager( KernelIf->identityManager() );
53 
54  KMime::Message::Ptr rmsg = factory.createRedirect( mParameter );
55  if ( !rmsg )
56  return ErrorButGoOn;
57 
58  sendMDN( context.item(), KMime::MDN::Dispatched );
59 
60  if ( !KernelIf->msgSender()->send( rmsg, MessageComposer::MessageSender::SendLater ) ) {
61  kDebug() << "FilterAction: could not redirect message (sending failed)";
62  return ErrorButGoOn; // error: couldn't send
63  }
64 
65  return GoOn;
66 }
67 
68 SearchRule::RequiredPart FilterActionRedirect::requiredPart() const
69 {
70  return SearchRule::CompleteMessage;
71 }
72 
73 QString FilterActionRedirect::sieveCode() const
74 {
75  const QString result = QString::fromLatin1("redirect \"%1\";").arg(mParameter);
76  return result;
77 }
78 
79 
80 #include "filteractionredirect.moc"
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterActionRedirect::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractionredirect.cpp:68
KernelIf
#define KernelIf
Definition: mailkernel.h:186
MailCommon::FilterActionRedirect::sieveCode
QString sieveCode() const
Definition: filteractionredirect.cpp:73
QObject
MailCommon::FilterActionRedirect::FilterActionRedirect
FilterActionRedirect(QObject *parent=0)
Definition: filteractionredirect.cpp:38
MailCommon::SearchRule::CompleteMessage
Definition: searchpattern.h:107
MailCommon::FilterAction
Abstract base class for mail filter actions.
Definition: filteraction.h:52
MailCommon::FilterAction::ErrorButGoOn
A non-critical error occurred.
Definition: filteraction.h:63
MailCommon::FilterAction::sendMDN
static void sendMDN(const Akonadi::Item &item, KMime::MDN::DispositionType d, const QList< KMime::MDN::DispositionModifier > &m=QList< KMime::MDN::DispositionModifier >())
Automates the sending of MDNs from filter actions.
Definition: filteraction.cpp:99
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchpattern.h:104
filteractionredirect.h
MailCommon::FilterActionWithString::mParameter
QString mParameter
Definition: filteractionwithstring.h:91
MailCommon::Util::folderIdentity
MAILCOMMON_EXPORT uint folderIdentity(const Akonadi::Item &item)
Returns the identity of the folder that contains the given Akonadi::Item.
Definition: mailutil.cpp:446
MailCommon::FilterAction::ReturnCode
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:60
MailCommon::ItemContext::item
Akonadi::Item & item()
Returns the item of the context.
Definition: itemcontext.cpp:30
mailkernel.h
MailCommon::FilterActionRedirect::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractionredirect.cpp:43
context
const char * context
Definition: searchpatternedit.cpp:54
MailCommon::FilterActionWithAddress
Abstract base class for filter actions with a mail address as parameter.
Definition: filteractionwithaddress.h:42
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
MailCommon::FilterActionRedirect::newAction
static FilterAction * newAction()
Definition: filteractionredirect.cpp:33
mailutil.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal