Changeset View
Changeset View
Standalone View
Standalone View
libksieve/ksieveui/vacation/vacationutils.cpp
Show All 18 Lines | |||||
#include "vacationscriptextractor.h" | #include "vacationscriptextractor.h" | ||||
#include "sieve-vacation.h" | #include "sieve-vacation.h" | ||||
#include <KPIMIdentities/IdentityManager> | #include <KPIMIdentities/IdentityManager> | ||||
#include <KPIMIdentities/Identity> | #include <KPIMIdentities/Identity> | ||||
#include <KLocalizedString> | #include <KLocalizedString> | ||||
#include <KLocale> | #include <KLocale> | ||||
#include <KGlobal> | #include <KGlobal> | ||||
#include <QDate> | #include <KDateTime> | ||||
using KMime::Types::AddrSpecList; | using KMime::Types::AddrSpecList; | ||||
static inline QString dotstuff( QString s ) { // krazy:exclude=passbyvalue | static inline QString dotstuff( QString s ) { // krazy:exclude=passbyvalue | ||||
if ( s.startsWith( QLatin1Char('.') ) ) | if ( s.startsWith( QLatin1Char('.') ) ) | ||||
return QLatin1Char('.') + s.replace( QLatin1String("\n."), QLatin1String("\n..") ); | return QLatin1Char('.') + s.replace( QLatin1String("\n."), QLatin1String("\n..") ); | ||||
else | else | ||||
return s.replace( QLatin1String("\n."), QLatin1String("\n..") ); | return s.replace( QLatin1String("\n."), QLatin1String("\n..") ); | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | if (!vacation.active && !vdx.ifComment().isEmpty()) { | ||||
vacation.valid = false; | vacation.valid = false; | ||||
return vacation; | return vacation; | ||||
} | } | ||||
} | } | ||||
vacation.sendForSpam = !sdx.found(); | vacation.sendForSpam = !sdx.found(); | ||||
vacation.excludeDomain = drdx.domainName(); | vacation.excludeDomain = drdx.domainName(); | ||||
vacation.startDate = dx.startDate(); | vacation.startDate = dx.startDate(); | ||||
vacation.startTime = dx.startTime(); | |||||
vacation.endDate = dx.endDate(); | vacation.endDate = dx.endDate(); | ||||
vacation.endTime = dx.endTime(); | |||||
return vacation; | return vacation; | ||||
} | } | ||||
QString composeOldScript( const QString & messageText, | QString composeOldScript( const QString & messageText, | ||||
const QString &subject, | const QString &subject, | ||||
int notificationInterval, | int notificationInterval, | ||||
const AddrSpecList & addrSpecs, | const AddrSpecList & addrSpecs, | ||||
bool sendForSpam, const QString & domain, | bool sendForSpam, const QString & domain, | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | QString composeOldScript( const QString & messageText, | ||||
return script; | return script; | ||||
} | } | ||||
QString KSieveUi::VacationUtils::composeScript(const Vacation &vacation) | QString KSieveUi::VacationUtils::composeScript(const Vacation &vacation) | ||||
{ | { | ||||
QStringList condition; | QStringList condition; | ||||
if (vacation.startDate.isValid()) { | if (vacation.startDate.isValid()) { | ||||
if (vacation.startTime.isValid()) { | |||||
KDateTime start(vacation.startDate, vacation.startTime); | |||||
condition.append(QString::fromLatin1("currentdate :value \"ge\" \"iso8601\" \"%1\"") | |||||
.arg(start.toString(KDateTime::ISODate))); | |||||
} else { | |||||
condition.append(QString::fromLatin1("currentdate :value \"ge\" \"date\" \"%1\"") | condition.append(QString::fromLatin1("currentdate :value \"ge\" \"date\" \"%1\"") | ||||
.arg(vacation.startDate.toString(Qt::ISODate))); | .arg(vacation.startDate.toString(Qt::ISODate))); | ||||
} | } | ||||
} | |||||
if (vacation.endDate.isValid()) { | if (vacation.endDate.isValid()) { | ||||
if (vacation.endTime.isValid()) { | |||||
KDateTime end(vacation.endDate, vacation.endTime); | |||||
condition.append(QString::fromLatin1("currentdate :value \"le\" \"iso8601\" \"%1\"") | |||||
.arg(end.toString(KDateTime::ISODate))); | |||||
} else { | |||||
condition.append(QString::fromLatin1("currentdate :value \"le\" \"date\" \"%1\"") | condition.append(QString::fromLatin1("currentdate :value \"le\" \"date\" \"%1\"") | ||||
.arg(vacation.endDate.toString(Qt::ISODate))); | .arg(vacation.endDate.toString(Qt::ISODate))); | ||||
} | } | ||||
} | |||||
if (!vacation.sendForSpam) { | if (!vacation.sendForSpam) { | ||||
condition.append(QString::fromLatin1("not header :contains \"X-Spam-Flag\" \"YES\"")); | condition.append(QString::fromLatin1("not header :contains \"X-Spam-Flag\" \"YES\"")); | ||||
} | } | ||||
if (!vacation.excludeDomain.isEmpty()) { | if (!vacation.excludeDomain.isEmpty()) { | ||||
condition.append(QString::fromLatin1("address :domain :contains \"from\" \"%1\"").arg( vacation.excludeDomain )); | condition.append(QString::fromLatin1("address :domain :contains \"from\" \"%1\"").arg( vacation.excludeDomain )); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |