Commit b8118efa authored by Laurent Montel's avatar Laurent Montel 😁

Port more actions

parent 7a3a6670
...@@ -124,9 +124,9 @@ void SieveAction::unknowTagValue(const QString &tagValue, QString &error) ...@@ -124,9 +124,9 @@ void SieveAction::unknowTagValue(const QString &tagValue, QString &error)
error += i18n("An unknown tag value \"%1\" was found during parsing action \"%2\".", tagValue, name()) + QLatin1Char('\n'); error += i18n("An unknown tag value \"%1\" was found during parsing action \"%2\".", tagValue, name()) + QLatin1Char('\n');
} }
void SieveAction::tooManyArgument(const QString &tagName, int index, int maxValue, QString &error) void SieveAction::tooManyArgument(const QStringRef &tagName, int index, int maxValue, QString &error)
{ {
error += i18n("Too many argument found for \"%1\", max value is %2, number of value found %3 for %4", name(), maxValue, index, tagName) + QLatin1Char('\n'); error += i18n("Too many argument found for \"%1\", max value is %2, number of value found %3 for %4", name(), maxValue, index, *tagName.string()) + QLatin1Char('\n');
} }
void SieveAction::serverDoesNotSupportFeatures(const QString &feature, QString &error) void SieveAction::serverDoesNotSupportFeatures(const QString &feature, QString &error)
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
void unknownTag(const QStringRef &tag, QString &error); void unknownTag(const QStringRef &tag, QString &error);
void unknowTagValue(const QString &tagValue, QString &error); void unknowTagValue(const QString &tagValue, QString &error);
void tooManyArgument(const QString &tagName, int index, int maxValue, QString &error); void tooManyArgument(const QStringRef &tagName, int index, int maxValue, QString &error);
void serverDoesNotSupportFeatures(const QString &feature, QString &error); void serverDoesNotSupportFeatures(const QString &feature, QString &error);
protected: protected:
......
...@@ -69,6 +69,34 @@ QWidget *SieveActionAddHeader::createParamWidget(QWidget *parent) const ...@@ -69,6 +69,34 @@ QWidget *SieveActionAddHeader::createParamWidget(QWidget *parent) const
bool SieveActionAddHeader::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionAddHeader::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
int index = 0;
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
SelectAddHeaderPositionCombobox *combo = w->findChild<SelectAddHeaderPositionCombobox *>(QStringLiteral("selectposition"));
combo->setCode(AutoCreateScriptUtil::tagValue(element.readElementText()), name(), error);
} else if (tagName == QLatin1String("str")) {
if (index == 0) {
QLineEdit *edit = w->findChild<QLineEdit *>(QStringLiteral("headeredit"));
edit->setText(element.readElementText());
} else if (index == 1) {
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("valueedit"));
value->setText(AutoCreateScriptUtil::quoteStr(element.readElementText()));
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionAddHeader::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionAddHeader::setParamWidgetValue unknown tag " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
int index = 0; int index = 0;
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
......
...@@ -70,6 +70,34 @@ QWidget *SieveActionConvert::createParamWidget(QWidget *parent) const ...@@ -70,6 +70,34 @@ QWidget *SieveActionConvert::createParamWidget(QWidget *parent) const
bool SieveActionConvert::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionConvert::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
int index = 0;
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
if (index == 0) {
SelectMimeTypeComboBox *fromMimeType = w->findChild<SelectMimeTypeComboBox *>(QStringLiteral("from"));
fromMimeType->setCode(element.readElementText(), name(), error);
} else if (index == 1) {
SelectMimeTypeComboBox *toMimeType = w->findChild<SelectMimeTypeComboBox *>(QStringLiteral("to"));
toMimeType->setCode(element.readElementText(), name(), error);
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionConvert::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("list")) {
SelectConvertParameterWidget *params = w->findChild<SelectConvertParameterWidget *>(QStringLiteral("params"));
params->setCode(AutoCreateScriptUtil::listValue(element), error);
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionConvert::setParamWidgetValue unknown tag " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
int index = 0; int index = 0;
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
......
...@@ -69,6 +69,41 @@ QWidget *SieveActionDeleteHeader::createParamWidget(QWidget *parent) const ...@@ -69,6 +69,41 @@ QWidget *SieveActionDeleteHeader::createParamWidget(QWidget *parent) const
bool SieveActionDeleteHeader::parseValue(QXmlStreamReader &element, QWidget *w, QString &error, bool isNegative) bool SieveActionDeleteHeader::parseValue(QXmlStreamReader &element, QWidget *w, QString &error, bool isNegative)
{ {
int index = 0;
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("test")) {
#ifdef FIXME_QDOMELEMENT
const QDomNode testNode = e.toElement();
const QString nameValue = e.attribute(QStringLiteral("name"), QString());
const bool isNegative = (nameValue == QLatin1String("not"));
return parseValue(element, w, error, isNegative);
#endif
} else if (tagName == QLatin1String("tag")) {
SelectMatchTypeComboBox *combo = w->findChild<SelectMatchTypeComboBox *>(QStringLiteral("matchtype"));
combo->setCode(AutoCreateScriptUtil::tagValueWithCondition(element.readElementText(), isNegative), name(), error);
} else if (tagName == QLatin1String("str")) {
if (index == 0) {
QLineEdit *edit = w->findChild<QLineEdit *>(QStringLiteral("headeredit"));
edit->setText(element.readElementText());
} else if (index == 1) {
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("valueedit"));
value->setText(element.readElementText());
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionAddHeader::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionAddHeader::setParamWidgetValue unknown tag " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
int index = 0; int index = 0;
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
......
...@@ -71,6 +71,39 @@ QWidget *SieveActionEnclose::createParamWidget(QWidget *parent) const ...@@ -71,6 +71,39 @@ QWidget *SieveActionEnclose::createParamWidget(QWidget *parent) const
bool SieveActionEnclose::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionEnclose::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("headers")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
QLineEdit *subject = w->findChild<QLineEdit *>(QStringLiteral("headers"));
subject->setText(strValue);
}
} else if (tagValue == QLatin1String("subject")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
QLineEdit *headers = w->findChild<QLineEdit *>(QStringLiteral("subject"));
headers->setText(strValue);
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEnclose::setParamWidgetValue unknown tag value:" << tagValue;
}
} else if (tagName == QLatin1String("str")) {
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("text"));
edit->setPlainText(element.readElementText());
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEnclose::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -52,6 +52,22 @@ QWidget *SieveActionEReject::createParamWidget(QWidget *parent) const ...@@ -52,6 +52,22 @@ QWidget *SieveActionEReject::createParamWidget(QWidget *parent) const
bool SieveActionEReject::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionEReject::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
const QString tagValue = element.readElementText();
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("rejectmessage"));
edit->setPlainText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEReject::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -64,6 +64,27 @@ QWidget *SieveActionExtractText::createParamWidget(QWidget *parent) const ...@@ -64,6 +64,27 @@ QWidget *SieveActionExtractText::createParamWidget(QWidget *parent) const
bool SieveActionExtractText::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionExtractText::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
//TODO ?
} else if (tagName == QLatin1String("num")) {
QSpinBox *numberOfCharacters = w->findChild<QSpinBox *>(QStringLiteral("numberOfCharacters"));
numberOfCharacters->setValue(element.readElementText().toInt());
} else if (tagName == QLatin1String("str")) {
QLineEdit *variableName = w->findChild<QLineEdit *>(QStringLiteral("variablename"));
variableName->setText(element.readElementText());
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionExtractText::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -61,6 +61,44 @@ QString SieveActionFileInto::code(QWidget *w) const ...@@ -61,6 +61,44 @@ QString SieveActionFileInto::code(QWidget *w) const
bool SieveActionFileInto::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionFileInto::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("copy")) {
if (mHasCopySupport) {
QCheckBox *copy = w->findChild<QCheckBox *>(QStringLiteral("copy"));
copy->setChecked(true);
} else {
error += i18n("Action \"fileinto\" has \"copy\" argument but current server does not support it") + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue has not copy support ";
}
} else if (tagValue == QLatin1String("create")) {
if (mHasMailBoxSupport) {
QCheckBox *create = w->findChild<QCheckBox *>(QStringLiteral("create"));
create->setChecked(true);
} else {
serverDoesNotSupportFeatures(QStringLiteral("create"), error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue server has not create support ";
}
} else {
serverDoesNotSupportFeatures(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue server has not flags support ";
}
} else if (tagName == QLatin1String("str")) {
const QString tagValue = element.readElementText();
KSieveUi::AbstractMoveImapFolderWidget *edit = w->findChild<KSieveUi::AbstractMoveImapFolderWidget *>(QStringLiteral("fileintolineedit"));
edit->setText(AutoCreateScriptUtil::protectSlash(tagValue));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionFileInto::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment