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 override
83  {
84  return nullptr;
85  }
86 
91  QList<ServerPtr> readConfig();
92 
97  void refreshStarts() override {}
98 
106  QList<ServerPtr> setServers(const QList<CustomServerInfo> &serverDefs);
107 
108 protected:
109  QByteArray createServerListRequest() override
110  {
111  return QByteArray();
112  }
113  Response readMasterResponse(const QByteArray &data) override
114  {
115  Q_UNUSED(data);
116  return RESPONSE_BAD;
117  }
118 };
119 
120 #endif