• 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
filteractionremoveheader.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 "filteractionremoveheader.h"
21 
22 #include "pimcommon/widgets/minimumcombobox.h"
23 
24 #include <KDE/KLocale>
25 #include <KDE/KLineEdit>
26 
27 using namespace MailCommon;
28 
29 FilterAction* FilterActionRemoveHeader::newAction()
30 {
31  return new FilterActionRemoveHeader;
32 }
33 
34 FilterActionRemoveHeader::FilterActionRemoveHeader( QObject *parent )
35  : FilterActionWithStringList( QLatin1String("remove header"), i18n( "Remove Header" ), parent )
36 {
37  mParameterList << QLatin1String("")
38  << QLatin1String("Reply-To")
39  << QLatin1String("Delivered-To")
40  << QLatin1String("X-KDE-PR-Message")
41  << QLatin1String("X-KDE-PR-Package")
42  << QLatin1String("X-KDE-PR-Keywords");
43 
44  mParameter = mParameterList.at( 0 );
45 }
46 
47 QWidget* FilterActionRemoveHeader::createParamWidget( QWidget *parent ) const
48 {
49  PimCommon::MinimumComboBox *comboBox = new PimCommon::MinimumComboBox( parent );
50  comboBox->setEditable( true );
51  comboBox->setInsertPolicy( QComboBox::InsertAtBottom );
52  setParamWidgetValue( comboBox );
53 
54  connect( comboBox, SIGNAL(currentIndexChanged(int)),
55  this, SIGNAL(filterActionModified()) );
56  connect( comboBox->lineEdit(), SIGNAL(textChanged(QString)),
57  this, SIGNAL(filterActionModified()) );
58 
59  return comboBox;
60 }
61 
62 FilterAction::ReturnCode FilterActionRemoveHeader::process(ItemContext &context , bool) const
63 {
64  if ( mParameter.isEmpty() )
65  return ErrorButGoOn;
66 
67  KMime::Message::Ptr msg = context.item().payload<KMime::Message::Ptr>();
68  const QByteArray param(mParameter.toLatin1());
69  while ( msg->headerByType( param ) )
70  msg->removeHeader( param );
71 
72  msg->assemble();
73 
74  context.setNeedsPayloadStore();
75 
76  return GoOn;
77 }
78 
79 SearchRule::RequiredPart FilterActionRemoveHeader::requiredPart() const
80 {
81  return SearchRule::CompleteMessage;
82 }
83 
84 void FilterActionRemoveHeader::setParamWidgetValue( QWidget *paramWidget ) const
85 {
86  PimCommon::MinimumComboBox *comboBox = dynamic_cast<PimCommon::MinimumComboBox*>(paramWidget );
87  Q_ASSERT( comboBox );
88 
89  const int index = mParameterList.indexOf( mParameter );
90  comboBox->clear();
91  comboBox->addItems( mParameterList );
92  if ( index < 0 ) {
93  comboBox->addItem( mParameter );
94  comboBox->setCurrentIndex( comboBox->count() - 1 );
95  } else {
96  comboBox->setCurrentIndex( index );
97  }
98 }
99 
100 QStringList FilterActionRemoveHeader::sieveRequires() const
101 {
102  return QStringList() << QLatin1String("editheader");
103 }
104 
105 QString FilterActionRemoveHeader::sieveCode() const
106 {
107  return QString::fromLatin1("deleteheader \"%1\";").arg(mParameter);
108 }
109 
110 #include "filteractionremoveheader.moc"
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterActionWithStringList
Abstract base class for filter actions with a fixed set of string parameters.
Definition: filteractionwithstringlist.h:49
MailCommon::FilterActionRemoveHeader::sieveCode
QString sieveCode() const
Definition: filteractionremoveheader.cpp:105
QWidget
MailCommon::ItemContext::setNeedsPayloadStore
void setNeedsPayloadStore()
Marks that the item's payload has been changed and needs to be written back.
Definition: itemcontext.cpp:45
MailCommon::FilterActionRemoveHeader::setParamWidgetValue
void setParamWidgetValue(QWidget *paramWidget) const
The filter action shall set it's widget's contents from it's parameter.
Definition: filteractionremoveheader.cpp:84
QObject
MailCommon::SearchRule::CompleteMessage
Definition: searchpattern.h:107
MailCommon::FilterAction
Abstract base class for mail filter actions.
Definition: filteraction.h:52
MailCommon::FilterActionWithStringList::mParameterList
QStringList mParameterList
Definition: filteractionwithstringlist.h:85
MailCommon::FilterAction::ErrorButGoOn
A non-critical error occurred.
Definition: filteraction.h:63
MailCommon::FilterActionRemoveHeader::sieveRequires
QStringList sieveRequires() const
Definition: filteractionremoveheader.cpp:100
MailCommon::FilterActionRemoveHeader::FilterActionRemoveHeader
FilterActionRemoveHeader(QObject *parent=0)
Definition: filteractionremoveheader.cpp:34
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchpattern.h:104
MailCommon::FilterActionRemoveHeader::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractionremoveheader.cpp:79
MailCommon::FilterActionRemoveHeader::createParamWidget
QWidget * createParamWidget(QWidget *parent) const
Creates a widget for setting the filter action parameter.
Definition: filteractionremoveheader.cpp:47
MailCommon::FilterActionWithString::mParameter
QString mParameter
Definition: filteractionwithstring.h:91
MailCommon::FilterActionRemoveHeader::newAction
static FilterAction * newAction()
Definition: filteractionremoveheader.cpp:29
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
MailCommon::FilterAction::filterActionModified
void filterActionModified()
Called to notify that the current FilterAction has had some value modification.
filteractionremoveheader.h
context
const char * context
Definition: searchpatternedit.cpp:54
MailCommon::FilterActionRemoveHeader::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractionremoveheader.cpp:62
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
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