Libksieve

legacy/vacationscriptextractor.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #include "vacationscriptextractor.h"
8 
9 using namespace KSieveUi::Legacy;
10 KSieveUi::Legacy::VacationDataExtractor::VacationDataExtractor()
11  : KSieve::ScriptBuilder()
12 {
13  qCDebug(LIBKSIEVE_LOG);
14 }
15 
16 KSieveUi::Legacy::VacationDataExtractor::~VacationDataExtractor()
17 {
18 }
19 
20 void KSieveUi::Legacy::VacationDataExtractor::commandStart(const QString &identifier, int lineNumber)
21 {
22  Q_UNUSED(lineNumber)
23  qCDebug(LIBKSIEVE_LOG) << "( \"" << identifier << "\" )";
24  if (identifier != QLatin1String("vacation")) {
25  return;
26  }
27  reset();
28  mContext = VacationCommand;
29 }
30 
31 void KSieveUi::Legacy::VacationDataExtractor::commandEnd(int lineNumber)
32 {
33  Q_UNUSED(lineNumber)
34  qCDebug(LIBKSIEVE_LOG);
35  if (mContext != None && mContext != VacationEnd) {
36  mContext = VacationEnd;
37  } else {
38  mContext = None;
39  }
40 }
41 
42 void KSieveUi::Legacy::VacationDataExtractor::error(const KSieve::Error &e)
43 {
44  qCDebug(LIBKSIEVE_LOG) << e.asString() << "@" << e.line() << "," << e.column();
45 }
46 
47 void KSieveUi::Legacy::VacationDataExtractor::finished()
48 {
49 }
50 
51 void KSieveUi::Legacy::VacationDataExtractor::taggedArgument(const QString &tag)
52 {
53  qCDebug(LIBKSIEVE_LOG) << "( \"" << tag << "\" )";
54  if (mContext != VacationCommand) {
55  return;
56  }
57  if (tag == QLatin1String("days")) {
58  mContext = Days;
59  } else if (tag == QLatin1String("addresses")) {
60  mContext = Addresses;
61  } else if (tag == QLatin1String("subject")) {
62  mContext = Subject;
63  }
64 }
65 
66 void KSieveUi::Legacy::VacationDataExtractor::stringArgument(const QString &string, bool, const QString &)
67 {
68  qCDebug(LIBKSIEVE_LOG) << "( \"" << string << "\" )";
69  if (mContext == Addresses) {
70  mAliases.push_back(string);
71  mContext = VacationCommand;
72  } else if (mContext == Subject) {
73  mSubject = string;
74  mContext = VacationCommand;
75  } else if (mContext == VacationCommand) {
76  mMessageText = string;
77  mContext = VacationCommand;
78  }
79 }
80 
81 void KSieveUi::Legacy::VacationDataExtractor::numberArgument(unsigned long number, char)
82 {
83  qCDebug(LIBKSIEVE_LOG) << "( \"" << number << "\" )";
84  if (mContext != Days) {
85  return;
86  }
87  if (number > INT_MAX) {
88  mNotificationInterval = INT_MAX;
89  } else {
90  mNotificationInterval = number;
91  }
92  mContext = VacationCommand;
93 }
94 
95 void KSieveUi::Legacy::VacationDataExtractor::stringListArgumentStart()
96 {
97 }
98 
99 void KSieveUi::Legacy::VacationDataExtractor::stringListEntry(const QString &string, bool, const QString &)
100 {
101  qCDebug(LIBKSIEVE_LOG) << "( \"" << string << "\" )";
102  if (mContext != Addresses) {
103  return;
104  }
105  mAliases.push_back(string);
106 }
107 
108 void KSieveUi::Legacy::VacationDataExtractor::stringListArgumentEnd()
109 {
110  qCDebug(LIBKSIEVE_LOG);
111  if (mContext != Addresses) {
112  return;
113  }
114  mContext = VacationCommand;
115 }
116 
117 void KSieveUi::Legacy::VacationDataExtractor::reset()
118 {
119  qCDebug(LIBKSIEVE_LOG);
120  mContext = None;
121  mNotificationInterval = 0;
122  mAliases.clear();
123  mMessageText.clear();
124 }
Subject
void push_back(QChar ch)
KGuiItem reset()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.