diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/base/QXmppDataForm.cpp | 21 | ||||
| -rw-r--r-- | src/base/QXmppDataForm.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/base/QXmppDataForm.cpp b/src/base/QXmppDataForm.cpp index 6c1ae804..b8bfa357 100644 --- a/src/base/QXmppDataForm.cpp +++ b/src/base/QXmppDataForm.cpp @@ -665,6 +665,27 @@ void QXmppDataForm::setType(QXmppDataForm::Type type) d->type = type; } +/// +/// Searches for a hidden field called 'FORM_TYPE' and returns its value. +/// +/// \returns The string value of the field or a null string if the field +/// couldn't be found. +/// +/// \since QXmpp 1.5 +/// +QString QXmppDataForm::formType() const +{ + const auto formTypeItr = std::find_if(d->fields.begin(), d->fields.end(), [](const QXmppDataForm::Field &field) { + return field.type() == QXmppDataForm::Field::HiddenField && + field.key() == QStringLiteral("FORM_TYPE"); + }); + + if (formTypeItr != d->fields.end()) { + return formTypeItr->value().toString(); + } + return {}; +} + /// Returns true if the form has an unknown type. bool QXmppDataForm::isNull() const diff --git a/src/base/QXmppDataForm.h b/src/base/QXmppDataForm.h index a731bb66..e84ce472 100644 --- a/src/base/QXmppDataForm.h +++ b/src/base/QXmppDataForm.h @@ -234,6 +234,8 @@ public: QXmppDataForm::Type type() const; void setType(QXmppDataForm::Type type); + QString formType() const; + bool isNull() const; /// \cond |
