~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to iris/include/xmpp_xdata.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

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