• 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
filteractionsendfakedisposition.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 "filteractionsendfakedisposition.h"
21 
22 #include <messagecore/misc/mdnstateattribute.h>
23 
24 #include <KDE/KLocale>
25 
26 #include <QTextDocument>
27 
28 using namespace MailCommon;
29 
30 // if you change this list, also update
31 // the count in argsFromString
32 static const KMime::MDN::DispositionType mdns[] =
33 {
34  KMime::MDN::Displayed,
35  KMime::MDN::Deleted,
36  KMime::MDN::Dispatched,
37  KMime::MDN::Processed,
38  KMime::MDN::Denied,
39  KMime::MDN::Failed,
40 };
41 static const int numMDNs = sizeof( mdns ) / sizeof( *mdns );
42 
43 
44 FilterActionSendFakeDisposition::FilterActionSendFakeDisposition( QObject *parent )
45  : FilterActionWithStringList( QLatin1String("fake mdn"), i18n( "Send Fake MDN" ), parent )
46 {
47  // if you change this list, also update
48  // mdns above
49  mParameterList.append( QString() );
50  mParameterList.append( i18nc( "MDN type", "Ignore" ) );
51  mParameterList.append( i18nc( "MDN type", "Displayed" ) );
52  mParameterList.append( i18nc( "MDN type", "Deleted" ) );
53  mParameterList.append( i18nc( "MDN type", "Dispatched" ) );
54  mParameterList.append( i18nc( "MDN type", "Processed" ) );
55  mParameterList.append( i18nc( "MDN type", "Denied" ) );
56  mParameterList.append( i18nc( "MDN type", "Failed" ) );
57 
58  mParameter = mParameterList.at( 0 );
59 }
60 
61 FilterAction* FilterActionSendFakeDisposition::newAction()
62 {
63  return new FilterActionSendFakeDisposition;
64 }
65 
66 bool FilterActionSendFakeDisposition::isEmpty() const
67 {
68  return false;
69 }
70 
71 FilterAction::ReturnCode FilterActionSendFakeDisposition::process(ItemContext &context , bool) const
72 {
73  const int index = mParameterList.indexOf( mParameter );
74  if ( index < 1 )
75  return ErrorButGoOn;
76 
77  if ( index == 1 ) { // ignore
78  if ( context.item().hasAttribute<MessageCore::MDNStateAttribute>() ) {
79  context.item().attribute<MessageCore::MDNStateAttribute>()->setMDNState( MessageCore::MDNStateAttribute::MDNIgnore );
80  context.setNeedsFlagStore();
81  }
82  } else // send
83  sendMDN( context.item(), mdns[ index - 2 ] ); // skip first two entries: "" and "ignore"
84 
85  return GoOn;
86 }
87 
88 SearchRule::RequiredPart FilterActionSendFakeDisposition::requiredPart() const
89 {
90  return SearchRule::CompleteMessage;
91 }
92 
93 
94 void FilterActionSendFakeDisposition::argsFromString( const QString &argsStr )
95 {
96  if ( argsStr.length() == 1 ) {
97  if ( argsStr[ 0 ] == 'I' ) { // ignore
98  mParameter = mParameterList.at( 1 );
99  return;
100  }
101 
102  for ( int i = 0 ; i < numMDNs ; ++i ) {
103  if ( char( mdns[ i ] ) == argsStr[ 0 ] ) { // send
104  mParameter = mParameterList.at( i + 2 );
105  return;
106  }
107  }
108  }
109 
110  mParameter = mParameterList.at( 0 );
111 }
112 
113 QString FilterActionSendFakeDisposition::argsAsString() const
114 {
115  const int index = mParameterList.indexOf( mParameter );
116  if ( index < 1 )
117  return QString();
118 
119  return QString( QChar( index < 2 ? 'I' : char( mdns[ index - 2 ] ) ) );
120 }
121 
122 QString FilterActionSendFakeDisposition::displayString() const
123 {
124  return label() + QLatin1String( " \"" ) + mParameter + QLatin1String( "\"" );
125 }
126 
127 
128 #include "filteractionsendfakedisposition.moc"
MailCommon::FilterActionSendFakeDisposition::FilterActionSendFakeDisposition
FilterActionSendFakeDisposition(QObject *parent=0)
Definition: filteractionsendfakedisposition.cpp:44
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterActionSendFakeDisposition::displayString
QString displayString() const
Returns a translated string describing this filter for visualization purposes, e.g.
Definition: filteractionsendfakedisposition.cpp:122
MailCommon::FilterActionWithStringList
Abstract base class for filter actions with a fixed set of string parameters.
Definition: filteractionwithstringlist.h:49
MailCommon::FilterActionSendFakeDisposition::newAction
static FilterAction * newAction()
Definition: filteractionsendfakedisposition.cpp:61
numMDNs
static const int numMDNs
Definition: filteractionsendfakedisposition.cpp:41
QObject
MailCommon::SearchRule::CompleteMessage
Definition: searchpattern.h:107
MailCommon::FilterActionSendFakeDisposition::argsAsString
QString argsAsString() const
Return extra arguments as string.
Definition: filteractionsendfakedisposition.cpp:113
MailCommon::FilterAction
Abstract base class for mail filter actions.
Definition: filteraction.h:52
filteractionsendfakedisposition.h
MailCommon::FilterActionWithStringList::mParameterList
QStringList mParameterList
Definition: filteractionwithstringlist.h:85
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::FilterActionSendFakeDisposition::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractionsendfakedisposition.cpp:88
MailCommon::FilterActionSendFakeDisposition::argsFromString
void argsFromString(const QString &argsStr)
Read extra arguments from given string.
Definition: filteractionsendfakedisposition.cpp:94
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchpattern.h:104
MailCommon::FilterAction::label
QString label() const
Returns i18n'd label, ie.
Definition: filteraction.cpp:45
MailCommon::FilterActionWithString::mParameter
QString mParameter
Definition: filteractionwithstring.h:91
MailCommon::FilterAction::ReturnCode
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:60
mdns
static const KMime::MDN::DispositionType mdns[]
Definition: filteractionsendfakedisposition.cpp:32
MailCommon::ItemContext::item
Akonadi::Item & item()
Returns the item of the context.
Definition: itemcontext.cpp:30
context
const char * context
Definition: searchpatternedit.cpp:54
MailCommon::ItemContext::setNeedsFlagStore
void setNeedsFlagStore()
Marks that the item's flags has been changed and needs to be written back.
Definition: itemcontext.cpp:55
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
MailCommon::FilterActionSendFakeDisposition::isEmpty
bool isEmpty() const
Determines whether this action is valid.
Definition: filteractionsendfakedisposition.cpp:66
MailCommon::FilterActionSendFakeDisposition::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractionsendfakedisposition.cpp:71
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