aboutsummaryrefslogtreecommitdiff
path: root/lib/application-service/definitions/protocol.h
blob: 2aca7d669f6ae9c937e4366620b6735378904777 (plain)
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
30pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.N
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "converters.h"

#include <QtCore/QHash>
#include <QtCore/QJsonObject>
#include "converters.h"
#include <QtCore/QVector>

namespace QMatrixClient
{
    // Data structures

    /// Definition of valid values for a field.
    struct FieldType
    {
        /// A regular expression for validation of a field's value. This may be relatively
        /// coarse to verify the value as the application service providing this protocol
        /// may apply additional validation or filtering.
        QString regexp;
        /// An placeholder serving as a valid example of the field value.
        QString placeholder;
    };

    QJsonObject toJson(const FieldType& pod);

    template <> struct FromJsonObject<FieldType>
    {
        FieldType operator()(const QJsonObject& jo) const;
    };

    struct ProtocolInstance
    {
        /// A human-readable description for the protocol, such as the name.
        QString desc;
        /// An optional content URI representing the protocol. Overrides the one provided
        /// at the higher level Protocol object.
        QString icon;
        /// Preset values for ``fields`` the client may use to search by.
        QJsonObject fields;
        /// A unique identifier across all instances.
        QString networkId;
    };

    QJsonObject toJson(const ProtocolInstance& pod);

    template <> struct FromJsonObject<ProtocolInstance>
    {
        ProtocolInstance operator()(const QJsonObject& jo) const;
    };

    struct ThirdPartyProtocol
    {
        /// Fields which may be used to identify a third party user. These should be
        /// ordered to suggest the way that entities may be grouped, where higher
        /// groupings are ordered first. For example, the name of a network should be
        /// searched before the nickname of a user.
        QStringList userFields;
        /// Fields which may be used to identify a third party location. These should be
        /// ordered to suggest the way that entities may be grouped, where higher
        /// groupings are ordered first. For example, the name of a network should be
        /// searched before the name of a channel.
        QStringList locationFields;
        /// A content URI representing an icon for the third party protocol.
        QString icon;
        /// The type definitions for the fields defined in the ``user_fields`` and 
        /// ``location_fields``. Each entry in those arrays MUST have an entry here. The
        /// ``string`` key for this object is field name itself.
        /// 
        /// May be an empty object if no fields are defined.
        QHash<QString, FieldType> fieldTypes;
        /// A list of objects representing independent instances of configuration.
        /// For example, multiple networks on IRC if multiple are provided by the
        /// same application service.
        QVector<ProtocolInstance> instances;
    };

    QJsonObject toJson(const ThirdPartyProtocol& pod);

    template <> struct FromJsonObject<ThirdPartyProtocol>
    {
        ThirdPartyProtocol operator()(const QJsonObject& jo) const;
    };

} // namespace QMatrixClient