Libksieve

legacy/vacationscriptextractor.cpp
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "vacationscriptextractor.h"
19 
20 using namespace KSieveUi::Legacy;
21 KSieveUi::Legacy::VacationDataExtractor::VacationDataExtractor()
22  : KSieve::ScriptBuilder()
23  , mContext(None)
24  , mNotificationInterval(0)
25 {
26  qCDebug(LIBKSIEVE_LOG);
27 }
28 
29 KSieveUi::Legacy::VacationDataExtractor::~VacationDataExtractor()
30 {
31 }
32 
33 void KSieveUi::Legacy::VacationDataExtractor::commandStart(const QString &identifier, int lineNumber)
34 {
35  Q_UNUSED(lineNumber);
36  qCDebug(LIBKSIEVE_LOG) << "( \"" << identifier << "\" )";
37  if (identifier != QLatin1String("vacation")) {
38  return;
39  }
40  reset();
41  mContext = VacationCommand;
42 }
43 
44 void KSieveUi::Legacy::VacationDataExtractor::commandEnd(int lineNumber)
45 {
46  Q_UNUSED(lineNumber);
47  qCDebug(LIBKSIEVE_LOG);
48  if (mContext != None && mContext != VacationEnd) {
49  mContext = VacationEnd;
50  } else {
51  mContext = None;
52  }
53 }
54 
55 void KSieveUi::Legacy::VacationDataExtractor::error(const KSieve::Error &e)
56 {
57  qCDebug(LIBKSIEVE_LOG) << e.asString() << "@" << e.line() << "," << e.column();
58 }
59 
60 void KSieveUi::Legacy::VacationDataExtractor::finished()
61 {
62 }
63 
64 void KSieveUi::Legacy::VacationDataExtractor::taggedArgument(const QString &tag)
65 {
66  qCDebug(LIBKSIEVE_LOG) << "( \"" << tag << "\" )";
67  if (mContext != VacationCommand) {
68  return;
69  }
70  if (tag == QLatin1String("days")) {
71  mContext = Days;
72  } else if (tag == QLatin1String("addresses")) {
73  mContext = Addresses;
74  } else if (tag == QLatin1String("subject")) {
75  mContext = Subject;
76  }
77 }
78 
79 void KSieveUi::Legacy::VacationDataExtractor::stringArgument(const QString &string, bool, const QString &)
80 {
81  qCDebug(LIBKSIEVE_LOG) << "( \"" << string << "\" )";
82  if (mContext == Addresses) {
83  mAliases.push_back(string);
84  mContext = VacationCommand;
85  } else if (mContext == Subject) {
86  mSubject = string;
87  mContext = VacationCommand;
88  } else if (mContext == VacationCommand) {
89  mMessageText = string;
90  mContext = VacationCommand;
91  }
92 }
93 
94 void KSieveUi::Legacy::VacationDataExtractor::numberArgument(unsigned long number, char)
95 {
96  qCDebug(LIBKSIEVE_LOG) << "( \"" << number << "\" )";
97  if (mContext != Days) {
98  return;
99  }
100  if (number > INT_MAX) {
101  mNotificationInterval = INT_MAX;
102  } else {
103  mNotificationInterval = number;
104  }
105  mContext = VacationCommand;
106 }
107 
108 void KSieveUi::Legacy::VacationDataExtractor::stringListArgumentStart()
109 {
110 }
111 
112 void KSieveUi::Legacy::VacationDataExtractor::stringListEntry(const QString &string, bool, const QString &)
113 {
114  qCDebug(LIBKSIEVE_LOG) << "( \"" << string << "\" )";
115  if (mContext != Addresses) {
116  return;
117  }
118  mAliases.push_back(string);
119 }
120 
121 void KSieveUi::Legacy::VacationDataExtractor::stringListArgumentEnd()
122 {
123  qCDebug(LIBKSIEVE_LOG);
124  if (mContext != Addresses) {
125  return;
126  }
127  mContext = VacationCommand;
128 }
129 
130 void KSieveUi::Legacy::VacationDataExtractor::reset()
131 {
132  qCDebug(LIBKSIEVE_LOG);
133  mContext = None;
134  mNotificationInterval = 0;
135  mAliases.clear();
136  mMessageText.clear();
137 }
Subject
void push_back(QChar ch)
KGuiItem reset()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:09:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.