~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/jabber/libiris/src/xmpp/xmpp-im/xmpp_xdata.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * xmpp_xdata.h - a class for jabber:x:data forms
 
3
 * Copyright (C) 2003-2004  Michail Pishchagin
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
 * 02110-1301  USA
 
19
 *
 
20
 */
 
21
 
 
22
#ifndef XMPPXDATA_H
 
23
#define XMPPXDATA_H
 
24
 
 
25
#include <QString>
 
26
#include <QMap>
 
27
#include <QList>
 
28
#include <QSharedDataPointer>
 
29
#include <QStringList>
 
30
#include <QSize>
 
31
#include <QHash>
 
32
 
 
33
class QDomElement;
 
34
class QDomDocument;
 
35
 
 
36
namespace XMPP {
 
37
 
 
38
        class XData
 
39
        {
 
40
        public:
 
41
                XData();
 
42
 
 
43
                QString title() const;
 
44
                void setTitle(const QString &);
 
45
 
 
46
                QString instructions() const;
 
47
                void setInstructions(const QString &);
 
48
 
 
49
                enum Type {
 
50
                        Data_Form,
 
51
                        Data_Result,
 
52
                        Data_Submit,
 
53
                        Data_Cancel
 
54
                };
 
55
 
 
56
                Type type() const;
 
57
                void setType(Type);
 
58
                QString registrarType() const;
 
59
 
 
60
                struct ReportField {
 
61
                        ReportField() { }
 
62
                        ReportField( QString _label, QString _name ) { label = _label; name = _name; }
 
63
                        QString label;
 
64
                        QString name;
 
65
                };
 
66
                const QList<ReportField> &report() const;
 
67
 
 
68
                typedef QMap<QString, QString> ReportItem;
 
69
                const QList<ReportItem> &reportItems() const;
 
70
 
 
71
                void fromXml(const QDomElement &);
 
72
                QDomElement toXml(QDomDocument *, bool submitForm = true) const;
 
73
                bool isValid() const;
 
74
 
 
75
        public:
 
76
                class Field {
 
77
                public:
 
78
                        Field();
 
79
                        ~Field();
 
80
 
 
81
                        QString desc() const;
 
82
                        void setDesc(const QString &);
 
83
 
 
84
                        struct Option {
 
85
                                QString label;
 
86
                                QString value;
 
87
                        };
 
88
 
 
89
                        struct MediaUri {
 
90
                                QString type;
 
91
                                QString uri;
 
92
                                QHash<QString,QString> params;
 
93
                        };
 
94
 
 
95
                        class MediaElement : public QList<MediaUri>
 
96
                        {
 
97
                        public:
 
98
                                void append(const QString &type, const QString &uri, QHash<QString,QString> params);
 
99
                                void setMediaSize(const QSize &size);
 
100
                                QSize mediaSize() const;
 
101
                                bool checkSupport(const QStringList &wildcards);
 
102
 
 
103
                        private:
 
104
                                QSize _size;
 
105
                        };
 
106
 
 
107
                        typedef QList<Option> OptionList;
 
108
                        OptionList options() const;
 
109
                        void setOptions(OptionList);
 
110
 
 
111
                        MediaElement mediaElement() const;
 
112
                        void setMediaElement(const MediaElement &);
 
113
 
 
114
                        bool required() const;
 
115
                        void setRequired(bool);
 
116
 
 
117
                        QString label() const;
 
118
                        void setLabel(const QString &);
 
119
 
 
120
                        QString var() const;
 
121
                        void setVar(const QString &);
 
122
 
 
123
                        // generic value variable, because every possible Type
 
124
                        // can be converted to QStringList. Field_Single will
 
125
                        // use just one string in QStringList. Field_Boolean will
 
126
                        // use just one string, and that string will equal 0 or 1.
 
127
                        // and so on...
 
128
                        QStringList value() const;
 
129
                        void setValue(const QStringList &);
 
130
 
 
131
                        enum Type {
 
132
                                Field_Boolean,
 
133
                                Field_Fixed,
 
134
                                Field_Hidden,
 
135
                                Field_JidMulti,
 
136
                                Field_JidSingle,
 
137
                                Field_ListMulti,
 
138
                                Field_ListSingle,
 
139
                                Field_TextMulti,
 
140
                                Field_TextPrivate,
 
141
                                Field_TextSingle
 
142
                        };
 
143
 
 
144
                        Type type() const;
 
145
                        void setType(Type);
 
146
 
 
147
                        bool isValid() const;
 
148
 
 
149
                        void fromXml(const QDomElement &);
 
150
                        QDomElement toXml(QDomDocument *, bool submitForm = true) const;
 
151
 
 
152
                private:
 
153
                        QString _desc, _label, _var;
 
154
                        QList<Option> _options;
 
155
                        MediaElement _mediaElement;
 
156
                        bool _required;
 
157
                        Type _type;
 
158
                        QStringList _value;
 
159
                };
 
160
 
 
161
                typedef QList<Field> FieldList;
 
162
 
 
163
                FieldList fields() const;
 
164
                void setFields(const FieldList &);
 
165
 
 
166
        private:
 
167
                class Private : public QSharedData {
 
168
                public:
 
169
                        QString title, instructions;
 
170
                        XData::Type type;
 
171
                        QString registrarType;
 
172
                        FieldList fields;
 
173
                        QList<ReportField> report;
 
174
                        QList<ReportItem>  reportItems;
 
175
                };
 
176
                QSharedDataPointer<Private> d;
 
177
        };
 
178
 
 
179
};
 
180
 
 
181
#endif