customservers.h
1 //------------------------------------------------------------------------------
2 // customservers.h
3 //------------------------------------------------------------------------------
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 WITHOUT ANY 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 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __CUSTOMSERVERS_H_
24 #define __CUSTOMSERVERS_H_
25 
26 #include "serverapi/masterclient.h"
27 #include <QtContainerFwd>
28 
29 class IniSection;
30 
36 {
37  public:
38  QString engine;
39  QString host;
40  unsigned short port;
41  int engineIndex;
42  bool enabled;
43 
44  static CustomServerInfo fromServer(const Server *server);
45 
49  bool isSameServer(const CustomServerInfo &other) const;
50 };
51 
57 {
58  Q_OBJECT;
59 
60  public:
62 
72  static void decodeConfigEntries(const QString& str, QList<CustomServerInfo>& outCustomServerInfoList);
73 
77  bool hasSameServer(const Server *otherServer) const;
78 
79  static bool isServerPinned(const CustomServerInfo &serverInfo);
80  static void setServerPinned(const CustomServerInfo &serverInfo, bool pinned);
81 
82  const EnginePlugin *plugin() const { return NULL; }
83 
88  QList<ServerPtr> readConfig();
89 
94  void refreshStarts() {}
95 
103  QList<ServerPtr> setServers(const QList<CustomServerInfo>& serverDefs);
104 
105  protected:
106  QByteArray createServerListRequest() { return QByteArray(); }
107  Response readMasterResponse(const QByteArray &data) { return RESPONSE_BAD; }
108 };
109 
110 #endif
void refreshStarts()
Definition: customservers.h:94
A representation of a server for a given game.
Definition: server.h:93
bool isSameServer(const CustomServerInfo &other) const
QByteArray createServerListRequest()
Produce contents of server list request packet that is sent to the master server. ...
const EnginePlugin * plugin() const
Definition: customservers.h:82
INI section representation.
Definition: inisection.h:40
Response readMasterResponse(const QByteArray &data)
Called to read and analyze the response from the MasterServer.
Abstract base for all MasterClients.
Definition: masterclient.h:49