QXmpp  Version:0.7.3
 All Classes Functions Variables Enumerations Enumerator Properties Groups
QXmppDataForm.h
1 /*
2  * Copyright (C) 2008-2012 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPDATAFORM_H
25 #define QXMPPDATAFORM_H
26 
27 #include <QPair>
28 #include <QSharedDataPointer>
29 #include <QString>
30 #include <QVariant>
31 #include <QXmlStreamWriter>
32 
33 #include "QXmppGlobal.h"
34 
35 class QDomElement;
36 class QXmppDataFormPrivate;
37 class QXmppDataFormFieldPrivate;
38 class QXmppDataFormMediaPrivate;
39 
43 
44 class QXMPP_EXPORT QXmppDataForm
45 {
46 public:
50 
51  class QXMPP_EXPORT Media
52  {
53  public:
54  Media();
55  Media(const QXmppDataForm::Media &other);
56  ~Media();
57 
58  QXmppDataForm::Media& operator=(const QXmppDataForm::Media &other);
59 
60  int height() const;
61  void setHeight(int height);
62 
63  int width() const;
64  void setWidth(int width);
65 
66  QList<QPair<QString, QString> > uris() const;
67  void setUris(const QList<QPair<QString, QString> > &uris);
68 
69  bool isNull() const;
70 
71  private:
72  QSharedDataPointer<QXmppDataFormMediaPrivate> d;
73  };
74 
78 
79  class QXMPP_EXPORT Field
80  {
81  public:
83  enum Type
84  {
85  BooleanField,
86  FixedField,
87  HiddenField,
88  JidMultiField,
89  JidSingleField,
90  ListMultiField,
91  ListSingleField,
92  TextMultiField,
93  TextPrivateField,
94  TextSingleField,
95  };
96 
97  Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
98  Field(const QXmppDataForm::Field &other);
99  ~Field();
100 
101  QXmppDataForm::Field& operator=(const QXmppDataForm::Field &other);
102 
103  QString description() const;
104  void setDescription(const QString &description);
105 
106  QString key() const;
107  void setKey(const QString &key);
108 
109  QString label() const;
110  void setLabel(const QString &label);
111 
112  Media media() const;
113  void setMedia(const Media &media);
114 
115  QList<QPair<QString, QString> > options() const;
116  void setOptions(const QList<QPair<QString, QString> > &options);
117 
118  bool isRequired() const;
119  void setRequired(bool required);
120 
121  QXmppDataForm::Field::Type type() const;
122  void setType(QXmppDataForm::Field::Type type);
123 
124  QVariant value() const;
125  void setValue(const QVariant &value);
126 
127  private:
128  QSharedDataPointer<QXmppDataFormFieldPrivate> d;
129  };
130 
132  enum Type
133  {
135  Form,
136 
137  Submit,
138 
139  Cancel,
140 
141  Result,
142 
143 
144  };
145 
147  QXmppDataForm(const QXmppDataForm &other);
148  ~QXmppDataForm();
149 
150  QXmppDataForm& operator=(const QXmppDataForm &other);
151 
152  QString instructions() const;
153  void setInstructions(const QString &instructions);
154 
155  QList<Field> fields() const;
156  QList<Field> &fields();
157  void setFields(const QList<QXmppDataForm::Field> &fields);
158 
159  QString title() const;
160  void setTitle(const QString &title);
161 
162  QXmppDataForm::Type type() const;
163  void setType(QXmppDataForm::Type type);
164 
165  bool isNull() const;
166 
168  void parse(const QDomElement &element);
169  void toXml(QXmlStreamWriter *writer) const;
171 
172 private:
173  QSharedDataPointer<QXmppDataFormPrivate> d;
174 };
175 
176 #endif