aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppDataForm.h
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-03-16 18:26:18 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-03-16 18:26:18 +0000
commitba54275f1234de7975c62a67f89db11e086af6e2 (patch)
tree0ccc39b1665e187a9438d9a7e0069895292f3f26 /source/QXmppDataForm.h
parent7e8f3008472fe21322df95cbf0125bad821b62cd (diff)
downloadqxmpp-ba54275f1234de7975c62a67f89db11e086af6e2.tar.gz
add XEP-0004: Data Forms implementation
Diffstat (limited to 'source/QXmppDataForm.h')
-rw-r--r--source/QXmppDataForm.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/source/QXmppDataForm.h b/source/QXmppDataForm.h
new file mode 100644
index 00000000..91b8ca7a
--- /dev/null
+++ b/source/QXmppDataForm.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2010 Bolloré telecom
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#ifndef QXMPPDATAFORM_H
+#define QXMPPDATAFORM_H
+
+#include <QPair>
+#include <QString>
+#include <QVariant>
+#include <QXmlStreamWriter>
+
+class QDomElement;
+
+class QXmppDataForm
+{
+public:
+ class Field
+ {
+ public:
+ enum Type
+ {
+ BooleanField,
+ FixedField,
+ HiddenField,
+ JidMultiField,
+ JidSingleField,
+ ListMultiField,
+ ListSingleField,
+ TextMultiField,
+ TextPrivateField,
+ TextSingleField,
+ };
+
+ Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
+
+ QString description() const;
+ void setDescription(const QString &description);
+
+ QString id() const;
+ void setId(const QString &id);
+
+ QString label() const;
+ void setLabel(const QString &label);
+
+ QList<QPair<QString, QString> > options() const;
+ void setOptions(const QList<QPair<QString, QString> > &options);
+
+ bool isRequired() const;
+ void setRequired(bool required);
+
+ QXmppDataForm::Field::Type type() const;
+ void setType(QXmppDataForm::Field::Type type);
+
+ QVariant value() const;
+ void setValue(const QVariant &value);
+
+ private:
+ QString m_id;
+ QString m_description;
+ QString m_label;
+ QList<QPair<QString, QString> > m_options;
+ bool m_required;
+ QXmppDataForm::Field::Type m_type;
+ QVariant m_value;
+ };
+
+ enum Type
+ {
+ Form,
+ Submit,
+ Cancel,
+ Result,
+ };
+
+ QXmppDataForm(QXmppDataForm::Type type = QXmppDataForm::Form);
+
+ QString instructions() const;
+ void setInstructions(const QString &instructions);
+
+ QList<Field> fields() const;
+ QList<Field> &fields();
+ void setFields(const QList<QXmppDataForm::Field> &fields);
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ QXmppDataForm::Type type() const;
+ void setType(QXmppDataForm::Type type);
+
+ void parse(const QDomElement &element);
+ void toXml(QXmlStreamWriter *writer) const;
+
+private:
+ QString m_instructions;
+ QList<Field> m_fields;
+ QString m_title;
+ QXmppDataForm::Type m_type;
+};
+
+#endif