diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-09-07 17:17:59 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-03-23 23:40:58 +0100 |
| commit | 5c6a6b8385df6b3f9cc640781eb76900e9364015 (patch) | |
| tree | 337f5031643aef10e6e8a56db9535dd50835fc53 /src/base/QXmppDataForm.cpp | |
| parent | 729b2dfa31c7585028599ca66644fa7270c217e9 (diff) | |
| download | qxmpp-5c6a6b8385df6b3f9cc640781eb76900e9364015.tar.gz | |
QXmppDataForm: Add FORM_TYPE search function
Diffstat (limited to 'src/base/QXmppDataForm.cpp')
| -rw-r--r-- | src/base/QXmppDataForm.cpp | 21 |
1 files changed, 21 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 |
