QXmpp
Version:0.9.3
|
00001 /* 00002 * Copyright (C) 2008-2014 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * https://github.com/qxmpp-project/qxmpp 00009 * 00010 * This file is a part of QXmpp library. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 */ 00023 00024 #ifndef QXMPPDATAFORM_H 00025 #define QXMPPDATAFORM_H 00026 00027 #include <QPair> 00028 #include <QVariant> 00029 00030 #include "QXmppStanza.h" 00031 00032 class QXmppDataFormPrivate; 00033 class QXmppDataFormFieldPrivate; 00034 class QXmppDataFormMediaPrivate; 00035 00039 00040 class QXMPP_EXPORT QXmppDataForm 00041 { 00042 public: 00046 00047 class QXMPP_EXPORT Media 00048 { 00049 public: 00050 Media(); 00051 Media(const QXmppDataForm::Media &other); 00052 ~Media(); 00053 00054 QXmppDataForm::Media& operator=(const QXmppDataForm::Media &other); 00055 00056 int height() const; 00057 void setHeight(int height); 00058 00059 int width() const; 00060 void setWidth(int width); 00061 00062 QList<QPair<QString, QString> > uris() const; 00063 void setUris(const QList<QPair<QString, QString> > &uris); 00064 00065 bool isNull() const; 00066 00067 private: 00068 QSharedDataPointer<QXmppDataFormMediaPrivate> d; 00069 }; 00070 00074 00075 class QXMPP_EXPORT Field 00076 { 00077 public: 00079 enum Type 00080 { 00081 BooleanField, 00082 FixedField, 00083 HiddenField, 00084 JidMultiField, 00085 JidSingleField, 00086 ListMultiField, 00087 ListSingleField, 00088 TextMultiField, 00089 TextPrivateField, 00090 TextSingleField 00091 }; 00092 00093 Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField); 00094 Field(const QXmppDataForm::Field &other); 00095 ~Field(); 00096 00097 QXmppDataForm::Field& operator=(const QXmppDataForm::Field &other); 00098 00099 QString description() const; 00100 void setDescription(const QString &description); 00101 00102 QString key() const; 00103 void setKey(const QString &key); 00104 00105 QString label() const; 00106 void setLabel(const QString &label); 00107 00108 Media media() const; 00109 void setMedia(const Media &media); 00110 00111 QList<QPair<QString, QString> > options() const; 00112 void setOptions(const QList<QPair<QString, QString> > &options); 00113 00114 bool isRequired() const; 00115 void setRequired(bool required); 00116 00117 QXmppDataForm::Field::Type type() const; 00118 void setType(QXmppDataForm::Field::Type type); 00119 00120 QVariant value() const; 00121 void setValue(const QVariant &value); 00122 00123 private: 00124 QSharedDataPointer<QXmppDataFormFieldPrivate> d; 00125 }; 00126 00128 enum Type 00129 { 00130 None, 00131 Form, 00132 00133 Submit, 00134 00135 Cancel, 00136 00137 Result 00138 00139 00140 }; 00141 00142 QXmppDataForm(QXmppDataForm::Type type = QXmppDataForm::None); 00143 QXmppDataForm(const QXmppDataForm &other); 00144 ~QXmppDataForm(); 00145 00146 QXmppDataForm& operator=(const QXmppDataForm &other); 00147 00148 QString instructions() const; 00149 void setInstructions(const QString &instructions); 00150 00151 QList<Field> fields() const; 00152 QList<Field> &fields(); 00153 void setFields(const QList<QXmppDataForm::Field> &fields); 00154 00155 QString title() const; 00156 void setTitle(const QString &title); 00157 00158 QXmppDataForm::Type type() const; 00159 void setType(QXmppDataForm::Type type); 00160 00161 bool isNull() const; 00162 00164 void parse(const QDomElement &element); 00165 void toXml(QXmlStreamWriter *writer) const; 00167 00168 private: 00169 QSharedDataPointer<QXmppDataFormPrivate> d; 00170 }; 00171 00172 #endif