forward port from 3.5 branch, related to bug 113730

svn path=/trunk/KDE/kdepim/; revision=486435
wilder-work
Andreas Gungl 21 years ago
parent 2ccc121753
commit abb7c0c030
  1. 7
      actionscheduler.cpp
  2. 11
      actionscheduler.h
  3. 10
      kmfilteraction.cpp

@ -815,4 +815,11 @@ bool ActionScheduler::isEnabled()
return sEnabled;
}
bool ActionScheduler::ignoreChanges( bool ignore )
{
bool oldValue = mIgnore;
mIgnore = ignore;
return oldValue;
}
#include "actionscheduler.moc"

@ -81,10 +81,10 @@ public:
of messages left to process is empty */
void setFilterList( QList<KMFilter*> filters );
/* Set the id of the account associated with this scheduler */
/** Set the id of the account associated with this scheduler */
void setAccountId( uint id ) { mAccountId = id; mAccount = true; }
/* Clear the id of the account associated with this scheduler */
/** Clear the id of the account associated with this scheduler */
void clearAccountId() { mAccountId = 0; mAccount = false; }
/** Queue a message for filtering */
@ -92,9 +92,16 @@ public:
void execFilters(const Q3PtrList<KMMsgBase> msgList);
void execFilters(KMMsgBase* msgBase);
void execFilters(quint32 serNum);
static QString debug();
static bool isEnabled();
/** Allow or deny manipulations on the message to be filtered.
This is needed when using pipe-through filters, because the
changes made by the filter have to be written back.
The old value before applying the new value is returned. */
bool ignoreChanges( bool ignore );
signals:
/** Emitted when filtering is completed */
void result(ReturnCode);

@ -1634,6 +1634,9 @@ class PipeJob : public KPIM::ThreadWeaver::Job
FILE *p;
QByteArray ba;
// backup the serial number in case the header gets lost
QString origSerNum = mMsg->headerField( "X-KMail-Filtered" );
p = popen(QFile::encodeName(mCmd), "r");
int len =100;
char buffer[100];
@ -1648,10 +1651,17 @@ class PipeJob : public KPIM::ThreadWeaver::Job
if ( !ba.isEmpty() ) {
KPIM::ThreadWeaver::debug (1, "PipeJob::run: %s", QString(ba).toLatin1() );
KMFolder *filterFolder = mMsg->parent();
ActionScheduler *handler = MessageProperty::filterHandler( mMsg->getMsgSerNum() );
mMsg->fromByteArray( ba );
if ( filterFolder ) {
if ( !origSerNum.isEmpty() )
mMsg->setHeaderField( "X-KMail-Filtered", origSerNum );
if ( filterFolder && handler ) {
bool oldStatus = handler->ignoreChanges( true );
filterFolder->take( filterFolder->find( mMsg ) );
filterFolder->addMsg( mMsg );
handler->ignoreChanges( oldStatus );
} else {
kdDebug(5006) << "Warning: Cannot refresh the message from the external filter." << endl;
}

Loading…
Cancel
Save