7 #include "vacationscriptextractor.h" 12 VacationDataExtractor::VacationDataExtractor()
15 qCDebug(LIBKSIEVE_LOG);
18 VacationDataExtractor::~VacationDataExtractor()
22 void VacationDataExtractor::commandStart(
const QString &identifier,
int lineNumber)
24 qCDebug(LIBKSIEVE_LOG) <<
"(\"" << identifier <<
"\")";
27 mLineStart = lineNumber;
31 if (commandFound() && (!mFoundInBlock || mBlockLevel > 0)) {
33 mMailAction = VacationUtils::Discard;
35 mMailAction = VacationUtils::Sendto;
36 mMailActionContext = RedirectCommand;
44 if (mContext != IfBlock) {
45 mLineStart = lineNumber;
49 mContext = VacationCommand;
50 mFoundInBlock = (mBlockLevel > 0);
53 void VacationDataExtractor::commandEnd(
int lineNumber)
55 qCDebug(LIBKSIEVE_LOG);
56 if (mContext != None && mContext != IfBlock && mContext != VacationEnd) {
57 mContext = VacationEnd;
58 mLineEnd = lineNumber;
60 mMailActionContext =
None;
63 void VacationDataExtractor::error(
const KSieve::Error &e)
65 qCDebug(LIBKSIEVE_LOG) << e.asString() <<
"@" << e.line() <<
"," << e.column();
68 void VacationDataExtractor::finished()
72 void VacationDataExtractor::testStart(
const QString &test)
74 if (mContext == IfBlock) {
82 void VacationDataExtractor::hashComment(
const QString &comment)
84 if (mContext == IfBlock) {
85 mIfComment += comment;
89 void VacationDataExtractor::blockStart(
int lineNumber)
95 void VacationDataExtractor::blockEnd(
int lineNumber)
98 if (mBlockLevel == 0 && !commandFound()) {
101 }
else if (mInIfBlock && mBlockLevel == 0 && commandFound()) {
102 mLineEnd = lineNumber;
107 void VacationDataExtractor::taggedArgument(
const QString &tag)
109 qCDebug(LIBKSIEVE_LOG) <<
"(\"" << tag <<
"\")";
110 if (mMailActionContext == RedirectCommand) {
112 mMailAction = VacationUtils::CopyTo;
115 if (mContext != VacationCommand) {
121 mContext = Addresses;
127 void VacationDataExtractor::stringArgument(
const QString &
string,
bool,
const QString &)
129 qCDebug(LIBKSIEVE_LOG) <<
"(\"" <<
string <<
"\")";
130 if (mContext == Addresses) {
131 mAliases.push_back(
string);
132 mContext = VacationCommand;
133 }
else if (mContext == Subject) {
135 mContext = VacationCommand;
136 }
else if (mContext == VacationCommand) {
137 mMessageText = string;
138 mContext = VacationCommand;
140 if (mMailActionContext == RedirectCommand) {
141 mMailActionRecipient = string;
145 void VacationDataExtractor::numberArgument(
unsigned long number,
char)
147 qCDebug(LIBKSIEVE_LOG) <<
"(\"" << number <<
"\")";
148 if (mContext != Days) {
151 if (number > INT_MAX) {
152 mNotificationInterval = INT_MAX;
154 mNotificationInterval = number;
156 mContext = VacationCommand;
159 void VacationDataExtractor::stringListArgumentStart()
163 void VacationDataExtractor::stringListEntry(
const QString &
string,
bool,
const QString &)
165 qCDebug(LIBKSIEVE_LOG) <<
"(\"" <<
string <<
"\")";
166 if (mContext != Addresses) {
172 void VacationDataExtractor::stringListArgumentEnd()
174 qCDebug(LIBKSIEVE_LOG);
175 if (mContext != Addresses) {
178 mContext = VacationCommand;
181 void VacationDataExtractor::reset()
183 qCDebug(LIBKSIEVE_LOG);
185 mMailAction = VacationUtils::Keep;
186 mMailActionRecipient =
QString();
187 mNotificationInterval = 0;
189 mMessageText.clear();
192 RequireExtractor::RequireExtractor()
200 RequireExtractor::~RequireExtractor()
204 void RequireExtractor::commandStart(
const QString &identifier,
int lineNumber)
206 if (identifier ==
QLatin1String(
"require") && mContext == None) {
207 mContext = RequireCommand;
208 mLineStart = lineNumber;
212 void RequireExtractor::commandEnd(
int lineNumber)
214 if (mContext == RequireCommand) {
216 mLineEnd = lineNumber;
220 void RequireExtractor::error(
const KSieve::Error &e)
222 qCDebug(LIBKSIEVE_LOG) << e.asString() <<
"@" << e.line() <<
"," << e.column();
225 void RequireExtractor::finished()
229 void RequireExtractor::stringArgument(
const QString &
string,
bool,
const QString &)
231 mRequirements << string;
234 void RequireExtractor::stringListEntry(
const QString &
string,
bool,
const QString &)
236 mRequirements << string;