• 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
filteraction.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
3  * Copyright (C) 2012 Andras Mantia <amantia@kde.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #include "filteraction.h"
22 
23 #include "../kernel/mailkernel.h"
24 #include "mdnadvicedialog.h"
25 #include "util/mailutil.h"
26 
27 #include <messagecomposer/helper/messagefactory.h>
28 #include <messagecomposer/sender/messagesender.h>
29 #include <messagecore/helpers/messagehelpers.h>
30 #include <messageviewer/settings/globalsettings.h>
31 
32 #include <KDE/KLocale>
33 
34 using namespace MailCommon;
35 
36 FilterAction::FilterAction( const QString &name, const QString &label, QObject *parent )
37  : QObject( parent ), mName( name ), mLabel( label )
38 {
39 }
40 
41 FilterAction::~FilterAction()
42 {
43 }
44 
45 QString FilterAction::label() const
46 {
47  return mLabel;
48 }
49 
50 QString FilterAction::name() const
51 {
52  return mName;
53 }
54 
55 bool FilterAction::isEmpty() const
56 {
57  return false;
58 }
59 
60 FilterAction* FilterAction::newAction()
61 {
62  return 0;
63 }
64 
65 QWidget* FilterAction::createParamWidget( QWidget *parent ) const
66 {
67  return new QWidget( parent );
68 }
69 
70 void FilterAction::applyParamWidgetValue( QWidget * )
71 {
72 }
73 
74 void FilterAction::setParamWidgetValue( QWidget * ) const
75 {
76 }
77 
78 void FilterAction::clearParamWidget( QWidget * ) const
79 {
80 }
81 
82 bool FilterAction::argsFromStringInteractive( const QString &argsStr, const QString & filterName )
83 {
84  Q_UNUSED( filterName );
85  argsFromString(argsStr);
86  return false;
87 }
88 
89 QString FilterAction::argsAsStringReal() const
90 {
91  return argsAsString();
92 }
93 
94 bool FilterAction::folderRemoved( const Akonadi::Collection&, const Akonadi::Collection& )
95 {
96  return false;
97 }
98 
99 void FilterAction::sendMDN( const Akonadi::Item &item, KMime::MDN::DispositionType type,
100  const QList<KMime::MDN::DispositionModifier> &modifiers )
101 {
102  const KMime::Message::Ptr msg = MessageCore::Util::message( item );
103  if ( !msg )
104  return;
105 
106 
107 
108  const QPair<bool, KMime::MDN::SendingMode> mdnSend = MDNAdviceHelper::instance()->checkAndSetMDNInfo( item, type, true );
109  if ( mdnSend.first ) {
110  const int quote = MessageViewer::GlobalSettings::self()->quoteMessage();
111  QString receiptTo = msg->headerByType("Disposition-Notification-To") ? msg->headerByType("Disposition-Notification-To")->asUnicodeString() : QString();
112  if ( receiptTo.isEmpty() )
113  return;
114  MessageComposer::MessageFactory factory( msg, Akonadi::Item().id() );
115  factory.setIdentityManager( KernelIf->identityManager() );
116  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
117 
118  const KMime::Message::Ptr mdn = factory.createMDN( KMime::MDN::AutomaticAction, type, mdnSend.second, quote, modifiers );
119  if ( mdn ) {
120  if ( !KernelIf->msgSender()->send( mdn, MessageComposer::MessageSender::SendLater ) ) {
121  kDebug() << "Sending failed.";
122  }
123  }
124  }
125 }
126 
127 QStringList FilterAction::sieveRequires() const
128 {
129  return QStringList();
130 }
131 
132 QString FilterAction::sieveCode() const
133 {
134  return i18n("### \"%1 not supported\"", name());
135 }
136 
137 #include "filteraction.moc"
MailCommon::FilterAction::argsAsStringReal
virtual QString argsAsStringReal() const
Definition: filteraction.cpp:89
MailCommon::FilterAction::FilterAction
FilterAction(const QString &name, const QString &label, QObject *parent=0)
Creates a new filter action.
Definition: filteraction.cpp:36
KernelIf
#define KernelIf
Definition: mailkernel.h:186
MailCommon::FilterAction::folderRemoved
virtual bool folderRemoved(const Akonadi::Collection &aFolder, const Akonadi::Collection &aNewFolder)
Called from the filter when a folder is removed.
Definition: filteraction.cpp:94
QWidget
MailCommon::FilterAction::argsAsString
virtual QString argsAsString() const =0
Return extra arguments as string.
QObject
MailCommon::FilterAction::sieveRequires
virtual QStringList sieveRequires() const
Definition: filteraction.cpp:127
MailCommon::FilterAction
Abstract base class for mail filter actions.
Definition: filteraction.h:52
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
mdnadvicedialog.h
MailCommon::FilterAction::argsFromStringInteractive
virtual bool argsFromStringInteractive(const QString &argsStr, const QString &filterName)
Read extra arguments from given string.
Definition: filteraction.cpp:82
MailCommon::MDNAdviceHelper::checkAndSetMDNInfo
QPair< bool, KMime::MDN::SendingMode > checkAndSetMDNInfo(const Akonadi::Item &item, KMime::MDN::DispositionType d, bool forceSend=false)
Checks the MDN headers to see if the user needs to be asked for any confirmations.
Definition: mdnadvicedialog.cpp:135
MailCommon::FilterAction::isEmpty
virtual bool isEmpty() const
Determines whether this action is valid.
Definition: filteraction.cpp:55
MailCommon::FilterAction::label
QString label() const
Returns i18n'd label, ie.
Definition: filteraction.cpp:45
MailCommon::FilterAction::name
QString name() const
Returns identifier name, ie.
Definition: filteraction.cpp:50
MailCommon::FilterAction::createParamWidget
virtual QWidget * createParamWidget(QWidget *parent) const
Creates a widget for setting the filter action parameter.
Definition: filteraction.cpp:65
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::newAction
static FilterAction * newAction()
Static function that creates a filter action of this type.
Definition: filteraction.cpp:60
MailCommon::FilterAction::clearParamWidget
virtual void clearParamWidget(QWidget *paramWidget) const
The filter action shall clear it's parameter widget's contents.
Definition: filteraction.cpp:78
MailCommon::FilterAction::~FilterAction
virtual ~FilterAction()
Destroys the filter action.
Definition: filteraction.cpp:41
MailCommon::FilterAction::argsFromString
virtual void argsFromString(const QString &argsStr)=0
Read extra arguments from given string.
MailCommon::FilterAction::setParamWidgetValue
virtual void setParamWidgetValue(QWidget *paramWidget) const
The filter action shall set it's widget's contents from it's parameter.
Definition: filteraction.cpp:74
MailCommon::MDNAdviceHelper::instance
static MDNAdviceHelper * instance()
Definition: mdnadvicedialog.h:36
mailutil.h
MailCommon::FilterAction::applyParamWidgetValue
virtual void applyParamWidgetValue(QWidget *paramWidget)
The filter action shall set it's parameter from the widget's contents.
Definition: filteraction.cpp:70
MailCommon::FilterAction::sieveCode
virtual QString sieveCode() const
Definition: filteraction.cpp:132
filteraction.h
QList
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