7#include "vacationpagewidget.h"
8#include "managescriptsjob/parseuserscriptjob.h"
9#include "vacationeditwidget.h"
10#include "vacationwarningwidget.h"
11#include <KSieveCore/MultiImapVacationManager>
12#include <KSieveCore/VacationCreateScriptJob>
13#include <KSieveCore/VacationUtils>
14#include <ksievecore/sieve-vacation.h>
16#include "kmanagesieve/sievejob.h"
18#include "libksieveui_debug.h"
19#include <KLocalizedString>
22#include <QStackedWidget>
25using namespace KSieveUi;
26VacationPageWidget::VacationPageWidget(
QWidget *parent)
30 lay->setContentsMargins({});
38 mainPage->setLayout(vbox);
39 mVacationWarningWidget =
new VacationWarningWidget(
this);
40 vbox->addWidget(mVacationWarningWidget);
42 mVacationEditWidget =
new VacationEditWidget(
this);
43 vbox->addWidget(mVacationEditWidget);
44 mStackWidget->addWidget(mainPage);
49 "Your server did not list \"vacation\" in "
50 "its list of supported Sieve extensions;"
51 "without it, KMail cannot install out-of-"
52 "office replies for you."
53 "Please contact your system administrator."));
54 QFont font = lab->font();
60 lab->setWordWrap(
true);
62 mStackWidget->addWidget(w);
64 mStackWidget->setCurrentIndex(Script);
67VacationPageWidget::~VacationPageWidget() =
default;
69bool VacationPageWidget::wasChanged()
const
71 return mVacationEditWidget->changed();
74void VacationPageWidget::setServerUrl(
const QUrl &url)
82 mVacationManager = vacationManager;
83 connect(mVacationManager, &KSieveCore::MultiImapVacationManager::scriptAvailable,
this, &VacationPageWidget::slotGetResult);
84 mVacationManager->checkVacation(mServerName, mUrl);
89 mVacationEditWidget->setSieveImapAccountSettings(account);
92void VacationPageWidget::setServerName(
const QString &serverName)
94 mServerName = serverName;
97void VacationPageWidget::slotGetResult(
const QString &serverName,
103 if (mServerName != serverName) {
106 qCDebug(LIBKSIEVEUI_LOG) << serverName << sieveCapabilities <<
Qt::endl << scriptName <<
"(" << active <<
")" <<
Qt::endl;
119 KSieveCore::VacationUtils::Vacation vacation = KSieveCore::VacationUtils::parseScript(script);
127 mVacationEditWidget->setActivateVacation(active && vacation.active);
128 mVacationEditWidget->setMessageText(vacation.messageText);
129 mVacationEditWidget->setSubject(vacation.subject);
130 mVacationEditWidget->setMailAction(vacation.mailAction, vacation.mailActionRecipient);
131 mVacationEditWidget->setNotificationInterval(vacation.notificationInterval);
132 mVacationEditWidget->setMailAliases(vacation.aliases);
133 mVacationEditWidget->setSendForSpam(vacation.sendForSpam);
134 mVacationEditWidget->setDomainName(vacation.reactOndomainName);
135 mVacationEditWidget->enableDomainAndSendForSpam(!KSieveCore::VacationSettings::allowOutOfOfficeUploadButNoSettings());
137 mVacationEditWidget->enableDates(mHasDateSupport);
138 if (mHasDateSupport) {
139 mVacationEditWidget->setStartDate(vacation.startDate);
140 mVacationEditWidget->setStartTime(vacation.startTime);
141 mVacationEditWidget->setEndDate(vacation.endDate);
142 mVacationEditWidget->setEndTime(vacation.endTime);
144 mVacationEditWidget->setChanged(
false);
147KSieveCore::VacationCreateScriptJob *VacationPageWidget::writeScript(
bool &errorFound)
149 if (mPageScript == Script) {
150 const bool active = mVacationEditWidget->activateVacation();
151 KSieveCore::VacationUtils::Vacation vacation;
153 vacation.aliases = mVacationEditWidget->mailAliases(ok);
158 vacation.valid =
true;
159 vacation.active = active;
160 vacation.messageText = mVacationEditWidget->messageText();
161 vacation.subject = mVacationEditWidget->subject();
162 vacation.mailAction = mVacationEditWidget->mailAction();
165 vacation.mailActionRecipient = mVacationEditWidget->mailActionRecipient(ok);
170 vacation.notificationInterval = mVacationEditWidget->notificationInterval();
171 vacation.sendForSpam = mVacationEditWidget->sendForSpam();
172 vacation.reactOndomainName = mVacationEditWidget->domainName();
173 if (mHasDateSupport) {
174 vacation.startDate = mVacationEditWidget->startDate();
175 vacation.startTime = mVacationEditWidget->startTime();
176 vacation.endDate = mVacationEditWidget->endDate();
177 vacation.endTime = mVacationEditWidget->endTime();
179 vacation.startDate =
QDate();
180 vacation.startTime =
QTime();
181 vacation.endDate =
QDate();
182 vacation.endTime =
QTime();
184 const QString script = KSieveCore::VacationUtils::composeScript(vacation);
185 auto createJob =
new KSieveCore::VacationCreateScriptJob;
186 createJob->setServerUrl(mUrl);
187 createJob->setServerName(mServerName);
188 createJob->setStatus(active, mWasActive);
189 createJob->setScript(script);
195void VacationPageWidget::setDefault()
198 mVacationEditWidget->setDefault();
202#include "moc_vacationpagewidget.cpp"
The MultiImapVacationManager class.
The SieveImapAccountSettings class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setBold(bool enable)
void setContentsMargins(const QMargins &margins)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
QString trimmed() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QTextStream & endl(QTextStream &stream)
QUrl adjusted(FormattingOptions options) const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setPath(const QString &path, ParsingMode mode)