mastermanager.h
1 //------------------------------------------------------------------------------
2 // mastermanager.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; 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 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #ifndef __MASTERMANAGER_H__
24 #define __MASTERMANAGER_H__
25 
26 #include "serverapi/masterclient.h"
27 #include "serverapi/message.h"
28 
29 class CustomServers;
30 class MasterClientSignalProxy;
31 
39 {
40  Q_OBJECT
41 
42  public:
43  MasterManager();
44  ~MasterManager();
45 
46  void addMaster(MasterClient *master);
47  QList<ServerPtr> allServers() const;
48  CustomServers *customServs() { return customServers; }
49 
50  int numMasters() const { return masters.size(); }
51 
52  const EnginePlugin *plugin() const { return NULL; }
53 
54  MasterClient *operator[](int index) { return masters[index]; }
55 
56  public slots:
57  void refreshStarts();
58 
59  signals:
64  void listUpdatedForMaster(MasterClient* pSender);
65  void masterMessage(MasterClient* pSender, const QString& title, const QString& content, bool isError);
66  void masterMessageImportant(MasterClient* pSender, const Message& objMessage);
67 
68  private:
69  CustomServers *customServers;
70  QList<MasterClient *> masters;
71  QSet<MasterClient *> mastersBeingRefreshed;
72 
73  QByteArray createServerListRequest() { return QByteArray(); }
74  Response readMasterResponse(const QByteArray &data);
75  void timeoutRefreshEx();
76 
77  private slots:
78  void masterListUpdated();
79 
80  void forwardMasterMessage(const QString& title, const QString& content, bool isError)
81  {
82  MasterClient* master = static_cast<MasterClient*>(sender());
83  emit masterMessage(master, title, content, isError);
84  }
85 
86  void forwardMasterMessageImportant(const Message &message)
87  {
88  MasterClient* master = static_cast<MasterClient*>(sender());
89  emit masterMessageImportant(master, message);
90  }
91 };
92 
93 #endif
const EnginePlugin * plugin() const
Definition: mastermanager.h:52
Message object used to pass messages throughout the Doomseeker's system.
Definition: message.h:62
void message(const QString &title, const QString &content, bool isError)
Manager class for a number of MasterClient instances.
Definition: mastermanager.h:38
void listUpdatedForMaster(MasterClient *pSender)
Emitted for every MasterClient that emits listUpdated() signal.
Abstract base for all MasterClients.
Definition: masterclient.h:49