/usr/include/jreen-qt5/jreen/dataform.h is in libjreen-qt5-dev 1.2.0-2fakesync1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | /****************************************************************************
**
** Jreen
**
** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru>
**
*****************************************************************************
**
** $JREEN_BEGIN_LICENSE$
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see http://www.gnu.org/licenses/.
** $JREEN_END_LICENSE$
**
****************************************************************************/
#ifndef JREEN_DATAFORM_H
#define JREEN_DATAFORM_H
#include "jid.h"
#include "stanzaextension.h"
#include <QStringList>
#include <QHash>
#include <QVariant>
namespace Jreen
{
// XEP-0004
// http://xmpp.org/extensions/xep-0004.html
class DataFormFieldPrivate;
class DataFormMediaPrivate;
class Stanza;
class JREEN_EXPORT DataFormMedia
{
Q_DECLARE_PRIVATE(DataFormMedia)
public:
typedef QSharedPointer<DataFormMedia> Ptr;
class UriPrivate;
class JREEN_EXPORT Uri
{
public:
Uri();
Uri(const QUrl &url, const QString &type);
Uri(const Uri &o);
Uri &operator =(const Uri &o);
~Uri();
bool operator==(const Uri &o) const;
QUrl url() const;
void setUrl(const QUrl &url);
QString type() const;
void setType(const QString &type);
private:
QSharedDataPointer<UriPrivate> d;
};
DataFormMedia();
~DataFormMedia();
void appendUri(const Uri &uri);
void appendUri(const QUrl &url, const QString &type);
void setUries(const QList<Uri> &uries);
QList<Uri> uries() const;
QSize size() const;
void setSize(const QSize &size);
int width() const;
void setWidth(int width);
int height() const;
void setHeight(int height);
private:
Q_DISABLE_COPY(DataFormMedia)
QScopedPointer<DataFormMediaPrivate> d_ptr;
};
class JREEN_EXPORT DataFormField
{
public:
enum Type
{
Invalid = -1,
Boolean, /**< The field enables an entity to gather or provide an either-or
* choice between two options. The default value is "false". */
Fixed, /**< The field is intended for data description (e.g., human-readable
* text such as "section" headers) rather than data gathering or
* provision. The <value/> child SHOULD NOT contain newlines
* (the \n and \r characters); instead an application SHOULD
* generate multiple fixed fields, each with one <value/> child. */
Hidden, /**< The field is not shown to the form-submitting entity, but
* instead is returned with the form. The form-submitting entity
* SHOULD NOT modify the value of a hidden field, but MAY do so
* if such behavior is defined for the "using protocol". */
JidMulti, /**< The field enables an entity to gather or provide multiple
* Jabber IDs. Each provided JID SHOULD be unique (as determined
* by comparison that includes application of the Nodeprep, Nameprep,
* and Resourceprep profiles of Stringprep as specified in XMPP Core),
* and duplicate JIDs MUST be ignored. */
JidSingle, /**< The field enables an entity to gather or provide a single
* Jabber ID. */
ListMulti, /**< The field enables an entity to gather or provide one or more
* options from among many. A form-submitting entity chooses one
* or more items from among the options presented by the form-processing
* entity and MUST NOT insert new options. The form-submitting entity
* MUST NOT modify the order of items as received from the form-processing
* entity, since the order of items MAY be significant. */
ListSingle, /**< The field enables an entity to gather or provide one option
* from among many. A form-submitting entity chooses one item
* from among the options presented by the form-processing entity
* and MUST NOT insert new options. */
TextMulti, /**< The field enables an entity to gather or provide multiple
* lines of text. */
TextPrivate, /**< The field enables an entity to gather or provide a single
* line or word of text, which shall be obscured in an interface
* (e.g., with multiple instances of the asterisk character). */
TextSingle, /**< The field enables an entity to gather or provide a single
* line or word of text, which may be shown in an interface.
* This field type is the default and MUST be assumed if a form-submitting
* entity receives a field type it does not understand. */
None
};
DataFormField(Type type = Invalid, const QString &var = QString(), const QString &label = QString());
DataFormField(const DataFormField &that);
DataFormField &operator =(const DataFormField &that);
~DataFormField();
Type type() const;
bool isRequired() const;
void setRequired(bool required);
QString var() const;
void setVar(const QString &var);
QString label() const;
void setLabel(const QString &label);
QString description() const;
void setDescription(const QString &desc);
DataFormMedia::Ptr media() const;
void setMedia(const DataFormMedia::Ptr &media);
void setValues(const QStringList &values);
QStringList values() const;
void setValue(const QString &value);
QString value() const;
template <typename T> T cast() const
{ return T(static_cast<DataFormField::Type>(T::StaticType) == type() ? *this : DataFormField()); }
protected:
QExplicitlySharedDataPointer<DataFormFieldPrivate> d_ptr;
friend class DataFormFieldPrivate;
};
class JREEN_EXPORT DataFormFieldBoolean : public DataFormField
{
public:
enum { StaticType = DataFormField::Boolean };
DataFormFieldBoolean(const QString &var, bool value = false, const QString &label = QString());
bool value() const;
void setValue(bool value);
protected:
DataFormFieldBoolean(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldFixed : public DataFormField
{
public:
enum { StaticType = DataFormField::Fixed };
DataFormFieldFixed(const QString &var, const QString &value = QString(), const QString &label = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldFixed(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldHidden : public DataFormField
{
public:
enum { StaticType = DataFormField::Hidden };
DataFormFieldHidden(const QString &var, const QString &value = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldHidden(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldJidMulti : public DataFormField
{
public:
enum { StaticType = DataFormField::JidMulti };
DataFormFieldJidMulti(const QString &var, const QList<JID> &values = QList<JID>(), const QString &label = QString());
QList<JID> values() const;
void setValues(const QList<JID> &values);
protected:
DataFormFieldJidMulti(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldJidSingle : public DataFormField
{
public:
enum { StaticType = DataFormField::JidSingle };
DataFormFieldJidSingle(const QString &var, const JID &value = JID(), const QString &label = QString());
JID value() const;
void setValue(const JID &value);
protected:
DataFormFieldJidSingle(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormOptionContainer : public DataFormField
{
public:
int optionsCount() const;
QString optionLabel(int index) const;
QString optionValue(int index) const;
void addOption(const QString &label, const QString &value);
void removeOption(int index);
protected:
DataFormOptionContainer(const DataFormField &that);
DataFormOptionContainer(Type type = Invalid, const QString &var = QString(), const QString &label = QString());
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldListMulti : public DataFormOptionContainer
{
public:
enum { StaticType = DataFormField::ListMulti };
DataFormFieldListMulti(const QString &var, const QStringList &values = QStringList(), const QString &label = QString());
bool isChecked(int index) const;
void setChecked(int index, bool checked);
protected:
DataFormFieldListMulti(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldListSingle : public DataFormOptionContainer
{
public:
enum { StaticType = DataFormField::ListSingle };
DataFormFieldListSingle(const QString &var, const QString &value = QString(), const QString &label = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldListSingle(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldTextMulti : public DataFormField
{
public:
enum { StaticType = DataFormField::TextMulti };
DataFormFieldTextMulti(const QString &var, const QString &value = QString(), const QString &label = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldTextMulti(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldTextPrivate : public DataFormField
{
public:
enum { StaticType = DataFormField::TextPrivate };
DataFormFieldTextPrivate(const QString &var, const QString &value = QString(), const QString &label = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldTextPrivate(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldTextSingle : public DataFormField
{
public:
enum { StaticType = DataFormField::TextSingle };
DataFormFieldTextSingle(const QString &var, const QString &value = QString(), const QString &label = QString());
QString value() const;
void setValue(const QString &value);
protected:
DataFormFieldTextSingle(const DataFormField &o);
friend class DataFormField;
};
class JREEN_EXPORT DataFormFieldNone : public DataFormField
{
public:
enum { StaticType = DataFormField::None };
DataFormFieldNone(const QString &var, const QStringList &values = QStringList(), const QString &label = QString());
QStringList values() const;
void setValues(const QStringList &values);
protected:
DataFormFieldNone(const DataFormField &o);
friend class DataFormField;
};
typedef QSharedPointer<DataFormField> DataFormFieldPointer;
typedef QList<DataFormField> DataFormFieldList;
typedef QHash<QString, DataFormField> DataFormFieldHash;
class DataFormFieldContainerPrivate;
class JREEN_EXPORT DataFormFieldContainer
{
Q_DECLARE_PRIVATE(DataFormFieldContainer)
Q_DISABLE_COPY(DataFormFieldContainer)
public:
int fieldsCount() const;
DataFormField field(int index) const;
DataFormField field(const QString &var) const;
DataFormField field(const QLatin1String &var) const;
void removeField(int index);
void appendField(const DataFormField &field);
void setFields(const QList<DataFormField> &fields);
protected:
DataFormFieldContainer();
DataFormFieldContainer(DataFormFieldContainerPrivate &d);
virtual ~DataFormFieldContainer();
QScopedPointer<DataFormFieldContainerPrivate> d_ptr;
};
class JREEN_EXPORT DataFormItem : public DataFormFieldContainer
{
public:
typedef QSharedPointer<DataFormItem> Ptr;
};
typedef QList<QSharedPointer<DataFormItem> > DataFormItemList;
class JREEN_EXPORT DataFormReported : public DataFormFieldContainer
{
public:
typedef QSharedPointer<DataFormReported> Ptr;
};
typedef QList<QSharedPointer<DataFormReported> > DataFormReportedList;
class DataFormPrivate;
class JREEN_EXPORT DataForm : public Payload, public DataFormFieldContainer
{
J_PAYLOAD(Jreen::DataForm)
Q_DECLARE_PRIVATE(DataForm)
public:
enum Type
{
Form, // The form-processing entity is asking the form-submitting entity to complete a form.
Submit, // The form-submitting entity is submitting data to the form-processing entity. The submission MAY include fields that were not provided in the empty form, but the form-processing entity MUST ignore any fields that it does not understand.
Cancel, // The form-submitting entity has cancelled submission of data to the form-processing entity.
Result, // The form-processing entity is returning data (e.g., search results) to the form-submitting entity, or the data is a generic data set.
Invalid
};
DataForm(Type type = Submit, const QString &title = QString());
DataForm(Type type, const QString &title, const QString &instructions);
virtual ~DataForm();
Type type() const;
void setType(Type type);
QString typeName() const;
void setTypeName(const QString &type);
QString title() const;
QString instructions() const;
QList<DataFormItem::Ptr> items() const;
DataFormReported::Ptr reported() const;
};
template <>
Q_INLINE_TEMPLATE DataFormOptionContainer DataFormField::cast() const
{
bool ok = type() == ListMulti || type() == ListSingle;
return DataFormOptionContainer(ok ? *this : DataFormField());
}
}
#endif // JREEN_DATAFORM_H
|