aboutsummaryrefslogtreecommitdiff
path: root/src/serverdata.h
blob: 99351852902a99826dcf55dae04603de422c8b90 (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
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
#ifndef SERVERDATA_H
#define SERVERDATA_H

#include <QObject>
#include <QString>
#include <QStringList>

namespace server
{
Q_NAMESPACE

/// The base feature set that almost all servers are supposed to support.
enum class BASE_FEATURE_SET
{
  YELLOWTEXT,         ///< Yellow text in in-character messages.
                      ///< @since 2.1.0
  FLIPPING,           ///< The ability to mirror a character in-game.
                      ///< @since 2.1.0
  CUSTOMOBJECTIONS,   ///< Enables the use of a single custom objection named
                      ///< `custom`.
                      ///< @since 2.1.0
  FASTLOADING,        ///< Enables the use of "fast loading" instead of the legacy
                      ///< loading protocol.
                      ///< @since 2.1.0
  NOENCRYPTION,       ///< Disables "FantaCrypt" for the remainder of  the session.
                      ///< @since 2.1.0
  DESKMOD,            ///< Allows forcing the appearance or disappearance of the desk.
                      ///< @since 2.3 to 2.5
  EVIDENCE,           ///< Allows creating and presenting evidence.
                      ///< @since 2.3 to 2.5
  CCCC_IC_SUPPORT,    ///< The ability to pair up with another user's character,
                      ///< the ability to change one's displayed name
                      ///< in-character ("showname"), and the ability to perform
                      ///< "immediate" preanimations (ones that happen alongside
                      ///< text display).
                      ///< @since 2.6.0
  ARUP,               ///< Areas have more data about them than just their name (including
                      ///< their status, their "lockedness", and who is the Case Master in
                      ///< the area), and sets the client up to receive and send ARUP
                      ///< packets.
                      ///< @since 2.6.0
  CASING_ALERTS,      ///< The client gains a new window to announce cases with,
                      ///< and the settings to set itself up to receive case alerts
                      ///< based on casing preferences. No longer used.
                      ///< @since 2.6.0
  MODCALL_REASON,     ///< Enables entering a custom reason for calling
                      ///< moderators.
                      ///< @since 2.6.0
  LOOPING_SFX,        ///< Enables looping SFX extensions for the in-character
                      ///< command.
                      ///< @since 2.8.0
  ADDITIVE,           ///< Enables "additive" text that allows in-character messages to
                      ///< concatenate to the previous one sent by the same character.
                      ///< @since 2.8.0
  EFFECTS,            ///< Enables effect overlays.
                      ///< @since 2.8.0
  Y_OFFSET,           ///< Enables support for vertical offsets.
                      ///< @since 2.9.0
  EXPANDED_DESK_MODS, ///< Enables desk modifiers 2 through 5.
                      ///< @since 2.9.0
  AUTH_PACKET,        ///< Enables the use of the AUTH packet.
                      ///< @since 2.9.1
  PREZOOM,            ///< Preanim zoom.
  CUSTOM_BLIPS        ///< Allows the in-character messages to contain data about
                      ///< what blips to use for the character's current message.
};
Q_ENUM_NS(BASE_FEATURE_SET)

/**
 * @brief Arranges data about the server the client is connected to.
 */
class ServerData
{
public:
  /**
   * @brief Returns true if one of the standard features exists on the server.
   *
   * @details Internally, this calls get_feature(const QString &f_feature)
   * with the enum's value converted to string.
   *
   * @param f_feature The feature to check for.
   *
   * @return True if the feature exists on the server.
   */
  bool get_feature(const BASE_FEATURE_SET &f_feature) const;

  /**
   * @brief Returns true if the feature exists on the server.
   *
   * @param f_feature The feature to check for. Case insensitive.
   *
   * @return True if the feature exists on the server.
   */
  bool get_feature(const QString &f_feature) const;

  /**
   * @brief Sets the feature list, overwriting the existing one.
   *
   * @param f_feature_list The new feature list of the server.
   */
  void set_features(const QStringList &f_feature_list);

  /**
   * @brief Self-explanatory: gets the software the server is running on.
   *
   * @return As brief description.
   */
  QString get_server_software() const;

  /**
   * @brief Self-explanatory: setter for server software.
   *
   * @param f_software The new server software.
   */
  void set_server_software(const QString &f_software);

  /**
   * @brief Getter for the server's asset URL.
   *
   * @return As brief description.
   *
   * @see m_asset_url
   */
  QString get_asset_url() const;

  /**
   * @brief Attempts to set the new asset URL for the server.
   *
   * @details The function converts the sole parameter into UTF-8, then
   * attempts to percent decode it. The  URL is only set if all these steps
   * successfully happen.
   *
   * @param f_asset_url A QString that contains the URL.
   */
  void set_asset_url(const QString &f_asset_url);

private:
  /// The features available on the server. Determines what
  QStringList m_features;

  /// The software the server is running.
  QString m_server_software;

  /**
   * @brief A QString of an URL that defines the content repository
   *        send by the server.
   *
   * @details Introduced in Version 2.9.2.
   *        Addresses the issue of contenturl devlivery for WebAO
   *        without relying on someone adding the link manually.
   */
  QString m_asset_url;
};
} // namespace server

#endif // SERVERDATA_H