Changeset View
Changeset View
Standalone View
Standalone View
libksieve/ksieveui/vacation/vacationscriptextractor.cpp
Show All 22 Lines | : KSieve::ScriptBuilder(), | ||||
mContext( None ), | mContext( None ), | ||||
mNotificationInterval( 0 ) | mNotificationInterval( 0 ) | ||||
, mActive(true) | , mActive(true) | ||||
, mInIfBlock(false) | , mInIfBlock(false) | ||||
, mBlockLevel(0) | , mBlockLevel(0) | ||||
, mLineStart(0) | , mLineStart(0) | ||||
, mLineEnd(0) | , mLineEnd(0) | ||||
{ | { | ||||
kDebug(); | |||||
} | } | ||||
VacationDataExtractor::~VacationDataExtractor() | VacationDataExtractor::~VacationDataExtractor() | ||||
{ | { | ||||
} | } | ||||
void VacationDataExtractor::commandStart( const QString & identifier, int lineNumber ) { | void VacationDataExtractor::commandStart( const QString & identifier, int lineNumber ) { | ||||
kDebug() << "( \"" << identifier <<"\" )"; | |||||
if (identifier == QLatin1String("if") && mContext == None) { | if (identifier == QLatin1String("if") && mContext == None) { | ||||
mContext = IfBlock; | mContext = IfBlock; | ||||
mLineStart = lineNumber; | mLineStart = lineNumber; | ||||
mInIfBlock = true; | mInIfBlock = true; | ||||
} | } | ||||
if ( identifier != QLatin1String("vacation") ) | if ( identifier != QLatin1String("vacation") ) | ||||
return; | return; | ||||
Show All 23 Lines | |||||
} | } | ||||
void VacationDataExtractor::testStart(const QString &test) | void VacationDataExtractor::testStart(const QString &test) | ||||
{ | { | ||||
if (mContext == IfBlock) { | if (mContext == IfBlock) { | ||||
if (test == QLatin1String("true") || test == QLatin1String("false")) { | if (test == QLatin1String("true") || test == QLatin1String("false")) { | ||||
mActive = (test == QLatin1String("true")); | mActive = (test == QLatin1String("true")); | ||||
mIfComment = QString(); | mIfComment = QString(); | ||||
kDebug() << "set active level to" << mActive; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
void VacationDataExtractor::hashComment(const QString &comment) | void VacationDataExtractor::hashComment(const QString &comment) | ||||
{ | { | ||||
if (mContext == IfBlock) { | if (mContext == IfBlock) { | ||||
mIfComment += comment; | mIfComment += comment; | ||||
Show All 15 Lines | void VacationDataExtractor::blockEnd(int lineNumber) | ||||
} else if (mInIfBlock && mBlockLevel == 0 && commandFound()) { | } else if (mInIfBlock && mBlockLevel == 0 && commandFound()) { | ||||
mLineEnd = lineNumber; | mLineEnd = lineNumber; | ||||
mInIfBlock = false; | mInIfBlock = false; | ||||
} | } | ||||
} | } | ||||
void VacationDataExtractor::taggedArgument( const QString & tag ) | void VacationDataExtractor::taggedArgument( const QString & tag ) | ||||
{ | { | ||||
kDebug() << "( \"" << tag <<"\" )"; | |||||
if ( mContext != VacationCommand ) | if ( mContext != VacationCommand ) | ||||
return; | return; | ||||
if ( tag == QLatin1String("days") ) | if ( tag == QLatin1String("days") ) | ||||
mContext = Days; | mContext = Days; | ||||
else if ( tag == QLatin1String("addresses") ) | else if ( tag == QLatin1String("addresses") ) | ||||
mContext = Addresses; | mContext = Addresses; | ||||
else if (tag == QLatin1String("subject")) { | else if (tag == QLatin1String("subject")) { | ||||
mContext = Subject; | mContext = Subject; | ||||
} | } | ||||
} | } | ||||
void VacationDataExtractor::stringArgument( const QString & string, bool, const QString & ) | void VacationDataExtractor::stringArgument( const QString & string, bool, const QString & ) | ||||
{ | { | ||||
kDebug() << "( \"" << string <<"\" )"; | |||||
if ( mContext == Addresses ) { | if ( mContext == Addresses ) { | ||||
mAliases.push_back( string ); | mAliases.push_back( string ); | ||||
mContext = VacationCommand; | mContext = VacationCommand; | ||||
} else if (mContext == Subject) { | } else if (mContext == Subject) { | ||||
mSubject = string; | mSubject = string; | ||||
mContext = VacationCommand; | mContext = VacationCommand; | ||||
} else if ( mContext == VacationCommand ) { | } else if ( mContext == VacationCommand ) { | ||||
mMessageText = string; | mMessageText = string; | ||||
mContext = VacationCommand; | mContext = VacationCommand; | ||||
} | } | ||||
} | } | ||||
void VacationDataExtractor::numberArgument( unsigned long number, char ) | void VacationDataExtractor::numberArgument( unsigned long number, char ) | ||||
{ | { | ||||
kDebug() << "( \"" << number <<"\" )"; | |||||
if ( mContext != Days ) | if ( mContext != Days ) | ||||
return; | return; | ||||
if ( number > INT_MAX ) | if ( number > INT_MAX ) | ||||
mNotificationInterval = INT_MAX; | mNotificationInterval = INT_MAX; | ||||
else | else | ||||
mNotificationInterval = number; | mNotificationInterval = number; | ||||
mContext = VacationCommand; | mContext = VacationCommand; | ||||
} | } | ||||
void VacationDataExtractor::stringListArgumentStart() | void VacationDataExtractor::stringListArgumentStart() | ||||
{ | { | ||||
} | } | ||||
void VacationDataExtractor::stringListEntry( const QString & string, bool, const QString & ) | void VacationDataExtractor::stringListEntry( const QString & string, bool, const QString & ) | ||||
{ | { | ||||
kDebug() << "( \"" << string <<"\" )"; | |||||
if ( mContext != Addresses ) | if ( mContext != Addresses ) | ||||
return; | return; | ||||
mAliases.push_back( string ); | mAliases.push_back( string ); | ||||
} | } | ||||
void VacationDataExtractor::stringListArgumentEnd() | void VacationDataExtractor::stringListArgumentEnd() | ||||
{ | { | ||||
kDebug(); | |||||
if ( mContext != Addresses ) | if ( mContext != Addresses ) | ||||
return; | return; | ||||
mContext = VacationCommand; | mContext = VacationCommand; | ||||
} | } | ||||
void VacationDataExtractor::reset() | void VacationDataExtractor::reset() | ||||
{ | { | ||||
kDebug(); | |||||
mContext = None; | mContext = None; | ||||
mNotificationInterval = 0; | mNotificationInterval = 0; | ||||
mAliases.clear(); | mAliases.clear(); | ||||
mMessageText.clear(); | mMessageText.clear(); | ||||
} | } | ||||
RequireExtractor::RequireExtractor() | RequireExtractor::RequireExtractor() | ||||
: KSieve::ScriptBuilder() | : KSieve::ScriptBuilder() | ||||
Show All 39 Lines | |||||
{ | { | ||||
mRequirements << string; | mRequirements << string; | ||||
} | } | ||||
void RequireExtractor::stringListEntry(const QString &string, bool, const QString &) | void RequireExtractor::stringListEntry(const QString &string, bool, const QString &) | ||||
{ | { | ||||
mRequirements << string; | mRequirements << string; | ||||
} | } | ||||
No newline at end of file | No newline at end of file |