ManaPlus
serverdialog.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
24 
25 #include "chatlogger.h"
26 #include "client.h"
27 #include "configuration.h"
28 #include "main.h"
29 #include "settings.h"
30 
31 #include "net/download.h"
32 
33 #include "fs/paths.h"
34 
35 #include "gui/widgets/checkbox.h"
37 #include "gui/widgets/desktop.h"
41 
42 #include "gui/widgets/button.h"
43 #include "gui/widgets/label.h"
44 #include "gui/widgets/layout.h"
46 #include "gui/widgets/scrollarea.h"
47 
48 #include "utils/delete2.h"
49 #include "utils/foreach.h"
50 #include "utils/langs.h"
51 
52 #include "debug.h"
53 
54 #ifdef WIN32
55 #undef ERROR
56 #endif // WIN32
57 
58 static const int MAX_SERVERLIST = 15;
59 
60 static std::string serverTypeToString(const ServerTypeT type)
61 {
62  switch (type)
63  {
65 #ifdef TMWA_SUPPORT
66  return "TmwAthena";
67 #else // TMWA_SUPPORT
68 
69  return "";
70 #endif // TMWA_SUPPORT
71 
73  return "eAthena";
74  case ServerType::EVOL2:
75  return "Evol2";
76  default:
78  return "";
79  }
80 }
81 
82 static uint16_t defaultPortForServerType(const ServerTypeT type)
83 {
84  switch (type)
85  {
86  default:
88  case ServerType::EVOL2:
89  return 6900;
92  return 6901;
93  }
94 }
95 
97  const std::string &dir) :
98  // TRANSLATORS: servers dialog name
99  Window(_("Choose Your Server"), Modal_false, nullptr, "server.xml"),
100  ActionListener(),
101  KeyListener(),
103  mMutex(),
104  mServers(ServerInfos()),
105  mDir(dir),
106  mDescription(new Label(this, std::string())),
107  // TRANSLATORS: servers dialog button
108  mQuitButton(new Button(this, _("Quit"), "quit", this)),
109  // TRANSLATORS: servers dialog button
110  mConnectButton(new Button(this, _("Connect"), "connect", this)),
111  // TRANSLATORS: servers dialog button
112  mAddEntryButton(new Button(this, _("Add"), "addEntry", this)),
113  // TRANSLATORS: servers dialog button
114  mEditEntryButton(new Button(this, _("Edit"), "editEntry", this)),
115  // TRANSLATORS: servers dialog button
116  mDeleteButton(new Button(this, _("Delete"), "remove", this)),
117  // TRANSLATORS: servers dialog button
118  mLoadButton(new Button(this, _("Load"), "load", this)),
119  // TRANSLATORS: servers dialog button
120  mInfoButton(new Button(this, _("Info"), "info", this)),
121  mServersListModel(new ServersListModel(&mServers, this)),
122  mServersList(CREATEWIDGETR(ServersListBox, this, mServersListModel)),
123  mDownload(nullptr),
124  mServerInfo(serverInfo),
125  mPersistentIPCheckBox(nullptr),
126  mDownloadProgress(-1.0F),
127  mDownloadStatus(ServerDialogDownloadStatus::UNKNOWN)
128 {
129  if (isSafeMode)
130  {
131  // TRANSLATORS: servers dialog name
132  setCaption(_("Choose Your Server *** SAFE MODE ***"));
133  }
134 
135  setWindowName("ServerDialog");
136 
137  setCloseButton(true);
138 
139  mPersistentIPCheckBox = new CheckBox(this,
140  // TRANSLATORS: servers dialog checkbox
141  _("Use same ip for game sub servers"),
142  config.getBoolValue("usePersistentIP"),
143  this, "persitent ip");
144 
146 
148 
149  ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
150  fromBool(getOptionBool("showbackground", false), Opaque),
151  "server_background.xml");
153 
155  usedScroll->setVerticalScrollAmount(0);
156 
157  place(0, 0, usedScroll, 8, 5).setPadding(3);
158  place(0, 5, mDescription, 8, 1);
159  place(0, 6, mPersistentIPCheckBox, 8, 1);
160  place(0, 7, mInfoButton, 1, 1);
161  place(1, 7, mAddEntryButton, 1, 1);
162  place(2, 7, mEditEntryButton, 1, 1);
163  place(3, 7, mLoadButton, 1, 1);
164  place(4, 7, mDeleteButton, 1, 1);
165  place(6, 7, mQuitButton, 1, 1);
166  place(7, 7, mConnectButton, 1, 1);
167 
168  // Make sure the list has enough height
169  getLayout().setRowHeight(0, 80);
170 
171  // Do this manually instead of calling reflowLayout so we can enforce a
172  // minimum width.
173  int width = 500;
174  int height = 350;
175 
176  getLayout().reflow(width, height);
177  setContentSize(width, height);
178 
179  setMinWidth(310);
180  setMinHeight(220);
182 
183  setResizable(true);
184  addKeyListener(this);
185 
186  loadWindowState();
187 }
188 
190 {
193 
195 
196  loadServers(true);
197 
198  mServersList->setSelected(0); // Do this after for the Delete button
199 
200  if (needUpdateServers())
202  else
203  logger->log("Skipping servers list update");
204 }
205 
207 {
208  if (mDownload != nullptr)
209  {
210  mDownload->cancel();
212  }
214 }
215 
217 {
219  return;
220 
221  const int index = mServersList->getSelected();
222  if (index < 0)
223  return;
224 
225  if (mDownload != nullptr)
226  mDownload->cancel();
227 
228  mQuitButton->setEnabled(false);
229  mConnectButton->setEnabled(false);
230  mLoadButton->setEnabled(false);
231 
232  ServerInfo server = mServers.at(index);
233  mServerInfo->hostname = server.hostname;
235  mServerInfo->port = server.port;
236  mServerInfo->type = server.type;
237  mServerInfo->name = server.name;
243  mServerInfo->save = true;
245  mServerInfo->freeType = server.freeType;
251  mServerInfo->docs = server.docs;
252  mServerInfo->serverUrl = server.serverUrl;
253 
257 
258  if (chatLogger != nullptr)
260 
262  -1);
263 
265  {
267  {
269  if (desktop != nullptr)
271  }
272  }
273 
274  config.setValue("usePersistentIP",
277 }
278 
280 {
281  const std::string &eventId = event.getId();
282  if (eventId == "connect")
283  {
285  }
286  else if (eventId == "quit")
287  {
288  close();
289  }
290  else if (eventId == "load")
291  {
293  }
294  else if (eventId == "addEntry")
295  {
297  }
298  else if (eventId == "editEntry")
299  {
300  const int index = mServersList->getSelected();
301  if (index >= 0)
302  {
304  this,
305  mServers.at(index),
306  index);
307  }
308  }
309  else if (eventId == "remove")
310  {
311  const int index = mServersList->getSelected();
312  if (index >= 0)
313  {
315  mServers.erase(mServers.begin() + index);
317  -1);
318  }
319  }
320  else if (eventId == "info")
321  {
322  const int index = mServersList->getSelected();
323  if (index >= 0)
324  {
325  if (serverInfoWindow != nullptr)
328  mServers.at(index));
329  }
330  }
331 }
332 
334 {
335  PRAGMA45(GCC diagnostic push)
336  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
337  switch (event.getActionId())
338  {
340  event.consume();
342  return;
343 
346  event.consume();
347  action(ActionEvent(nullptr,
349  return;
350 
353  return;
354 
356  {
357  const int index = mServersList->getSelected();
358  if (index >= 0)
359  {
361  mServers.erase(mServers.begin() + index);
363  -1);
364  }
365  return;
366  }
367 
369  {
370  const int index = mServersList->getSelected();
371  if (index >= 0)
372  {
373  CREATEWIDGET(EditServerDialog, this, mServers.at(index),
374  index);
375  }
376  return;
377  }
378 
379  default:
380  break;
381  }
382  PRAGMA45(GCC diagnostic pop)
383  if (!event.isConsumed())
384  mServersList->keyPressed(event);
385 }
386 
388 {
389  const int index = mServersList->getSelected();
390  if (index == -1)
391  {
392  mDeleteButton->setEnabled(false);
393  return;
394  }
395  mDeleteButton->setEnabled(true);
396 }
397 
399 {
400  if (event.getButton() == MouseButton::LEFT)
401  {
402  event.consume();
403  if (event.getClickCount() == 2 &&
404  event.getSource() == mServersList)
405  {
408  }
409  }
410 }
411 
413 {
414  BLOCK_START("ServerDialog::logic")
415  {
416  MutexLocker tempLock(&mMutex);
418  {
419  loadServers(true);
421  mDescription->setCaption(std::string());
422  logger->log("Servers list updated");
423  }
425  {
426  // TRANSLATORS: servers dialog label
427  mDescription->setCaption(strprintf(_("Downloading server list..."
428  "%2.2f%%"), static_cast<double>(mDownloadProgress * 100)));
429  }
431  {
432  // TRANSLATORS: servers dialog label
433  mDescription->setCaption(_("Waiting for server..."));
434  }
436  {
437  // TRANSLATORS: servers dialog label
438  mDescription->setCaption(_("Preparing download"));
439  }
441  {
442  // TRANSLATORS: servers dialog label
443  mDescription->setCaption(_("Error retreiving server list!"));
444  logger->log("Error: servers list updating error");
445  }
446  }
447 
448  Window::logic();
449  BLOCK_END("ServerDialog::logic")
450 }
451 
453 {
454  // Try to load the configuration value for the onlineServerList
455  std::string listFile = branding.getStringValue("onlineServerList");
456  std::string listFile2 = branding.getStringValue("onlineServerList2");
457 
458  // Fall back to manaplus.org when neither branding
459  // nor config set it
460  if (listFile.empty())
461  listFile = "http://manaplus.org/serverlist.xml";
462 
463  if (mDownload != nullptr)
464  {
465  mDownload->cancel();
467  }
468 
469  mDownload = new Net::Download(this, listFile,
470  &downloadUpdate, false, false, true);
472  branding.getStringValue("onlineServerFile")),
473  -1);
474  if (!listFile2.empty())
475  mDownload->addMirror(listFile2);
476  mDownload->start();
477 
478  config.setValue("serverslistupdate", getDateString());
479 }
480 
481 static void loadHostsGroup(XmlNodeConstPtr node,
482  ServerInfo &server)
483 {
484  HostsGroup group;
485  group.name = XML::langProperty(node,
486  "name",
487  // TRANSLATORS: unknown hosts group name
488  _("Unknown"));
489  for_each_xml_child_node(hostNode, node)
490  {
491  if (!xmlNameEqual(hostNode, "host") ||
492  !XmlHaveChildContent(hostNode))
493  {
494  continue;
495  }
496  const std::string host = XmlChildContent(hostNode);
497  if (host.empty())
498  continue;
499  if (!checkPath(host))
500  {
501  logger->log1("Warning: incorrect update server name");
502  continue;
503  }
504 
505  group.hosts.push_back(host);
506  }
507  if (!group.hosts.empty())
508  server.updateHosts.push_back(group);
509 }
510 
511 static void loadServerSourcesList(XmlNodeConstPtr node,
512  STD_VECTOR<ServerUrlInfo> &list)
513 {
514  for_each_xml_child_node(urlNode, node)
515  {
516  if (!xmlNameEqual(urlNode, "url") ||
517  !XmlHaveChildContent(urlNode))
518  {
519  continue;
520  }
521  const std::string name = XML::langProperty(urlNode,
522  "name",
523  "");
524  if (name.empty())
525  continue;
526  const std::string url = XmlChildContent(urlNode);
527  if (url.empty())
528  continue;
529  list.push_back(ServerUrlInfo(name, url));
530  }
531 }
532 
533 static void loadServerSources(XmlNodeConstPtr node,
534  ServerInfo &server)
535 {
536  for_each_xml_child_node(subNode, node)
537  {
538  if (xmlNameEqual(subNode, "free"))
539  {
540  loadServerSourcesList(subNode, server.freeSources);
541  }
542  else if (xmlNameEqual(subNode, "nonfree"))
543  {
544  loadServerSourcesList(subNode, server.nonFreeSources);
545  }
546  }
547 }
548 
549 void ServerDialog::loadServers(const bool addNew)
550 {
552  branding.getStringValue("onlineServerFile")),
555  XmlNodeConstPtr rootNode = doc.rootNode();
556 
557  if (rootNode == nullptr ||
558  !xmlNameEqual(rootNode, "serverlist"))
559  {
560  logger->log1("Error loading server list!");
561  return;
562  }
563 
564  const int ver = XML::getProperty(rootNode, "version", 0);
565  if (ver != 1)
566  {
567  logger->log("Error: unsupported online server list version: %d",
568  ver);
569  return;
570  }
571 
572  const std::string lang = getLangShort();
573  const std::string description2("description_" + lang);
574 
575  for_each_xml_child_node(serverNode, rootNode)
576  {
577  if (!xmlNameEqual(serverNode, "server"))
578  continue;
579 
580  const std::string type = XML::getProperty(
581  serverNode, "type", "unknown");
582  ServerInfo server;
583  server.type = ServerInfo::parseType(type);
584  const std::string licenseType = XML::getProperty(
585  serverNode, "licenseType", "notset");
586  server.freeType = ServerInfo::parseFreeType(licenseType);
587 
588  // Ignore unknown server types
589  if (server.type == ServerType::UNKNOWN)
590  {
591  logger->log("Ignoring server entry with unknown type: %s",
592  type.c_str());
593  continue;
594  }
595 
596  server.name = XML::getProperty(serverNode, "name", std::string());
597  std::string version = XML::getProperty(serverNode, "minimumVersion",
598  std::string());
599 
600  const bool meetsMinimumVersion = (compareStrI(version, SMALL_VERSION)
601  <= 0);
602 
603  // For display in the list
604  if (meetsMinimumVersion)
605  version.clear();
606  else if (version.empty())
607  {
608  // TRANSLATORS: servers dialog label
609  version = _("requires a newer version");
610  }
611  else
612  {
613  // TRANSLATORS: servers dialog label
614  version = strprintf(_("requires v%s"), version.c_str());
615  }
616 
617  const Font *const font = gui->getFont();
618 
619  for_each_xml_child_node(subNode, serverNode)
620  {
621  if (xmlNameEqual(subNode, "connection"))
622  {
623  server.hostname = XML::getProperty(subNode, "hostname", "");
624  server.althostname = XML::getProperty(
625  subNode, "althostname", "");
626  server.port = CAST_U16(
627  XML::getProperty(subNode, "port", 0));
628  server.packetVersion = XML::getProperty(subNode,
629  "packetVersion", 0);
630 
631  if (server.port == 0)
632  {
633  // If no port is given, use the default for the given type
634  server.port = defaultPortForServerType(server.type);
635  }
636  }
637  else if (XmlHaveChildContent(subNode))
638  {
639  if ((xmlNameEqual(subNode, "description")
640  && server.description.empty()) || (!lang.empty()
641  && xmlNameEqual(subNode, description2.c_str())))
642  {
643  server.description = XmlChildContent(subNode);
644  }
645  else if (xmlNameEqual(subNode, "registerurl"))
646  {
647  server.registerUrl = XmlChildContent(subNode);
648  }
649  else if (xmlNameEqual(subNode, "onlineListUrl"))
650  {
651  server.onlineListUrl = XmlChildContent(subNode);
652  }
653  else if (xmlNameEqual(subNode, "support"))
654  {
655  server.supportUrl = XmlChildContent(subNode);
656  }
657  else if (xmlNameEqual(subNode, "persistentIp"))
658  {
659  std::string text = XmlChildContent(subNode);
660  server.persistentIp = (text == "1" || text == "true");
661  }
662  else if (xmlNameEqual(subNode, "updateMirror"))
663  {
664  server.updateMirrors.push_back(XmlChildContent(subNode));
665  }
666  else if (xmlNameEqual(subNode, "site"))
667  {
668  server.serverUrl = XmlChildContent(subNode);
669  }
670  }
671  if (xmlNameEqual(subNode, "updates"))
672  {
673  loadHostsGroup(subNode, server);
674  }
675  else if (xmlNameEqual(subNode, "defaultUpdateHost"))
676  {
678  // TRANSLATORS: default hosts group name
679  subNode, "name", _("default"));
680  }
681  else if (xmlNameEqual(subNode, "sources"))
682  {
683  loadServerSources(subNode, server);
684  }
685  else if (xmlNameEqual(subNode, "docs"))
686  {
687  loadServerSourcesList(subNode, server.docs);
688  }
689  }
690 
691  server.version.first = font->getWidth(version);
692  server.version.second = version;
693 
694  MutexLocker tempLock(&mMutex);
695  // Add the server to the local list if it's not already present
696  bool found = false;
697  for (unsigned int i = 0, fsz = CAST_U32(
698  mServers.size()); i < fsz; i++)
699  {
700  if (mServers[i] == server)
701  {
702  // Use the name listed in the server list
703  mServers[i].name = server.name;
704  mServers[i].type = server.type;
705  mServers[i].freeType = server.freeType;
706  mServers[i].version = server.version;
707  mServers[i].description = server.description;
708  mServers[i].registerUrl = server.registerUrl;
709  mServers[i].onlineListUrl = server.onlineListUrl;
710  mServers[i].supportUrl = server.supportUrl;
711  mServers[i].serverUrl = server.serverUrl;
712  mServers[i].althostname = server.althostname;
713  mServers[i].persistentIp = server.persistentIp;
714  mServers[i].updateMirrors = server.updateMirrors;
715  mServers[i].defaultHostName = server.defaultHostName;
716  mServers[i].updateHosts = server.updateHosts;
717  mServers[i].packetVersion = server.packetVersion;
718  mServers[i].freeSources = server.freeSources;
719  mServers[i].nonFreeSources = server.nonFreeSources;
720  mServers[i].docs = server.docs;
721  mServersListModel->setVersionString(i, version);
722  found = true;
723  break;
724  }
725  }
726  if (!found && addNew)
727  mServers.push_back(server);
728  }
729  if (mServersList->getSelected() < 0)
731 }
732 
734 {
735  for (int i = 0; i < MAX_SERVERLIST; ++i)
736  {
737  const std::string index = toString(i);
738  const std::string nameKey("MostUsedServerDescName" + index);
739  const std::string descKey("MostUsedServerDescription" + index);
740  const std::string hostKey("MostUsedServerName" + index);
741  const std::string typeKey("MostUsedServerType" + index);
742  const std::string portKey("MostUsedServerPort" + index);
743  const std::string onlineListUrlKey
744  ("MostUsedServerOnlineList" + index);
745  const std::string persistentIpKey("persistentIp" + index);
746  const std::string packetVersionKey
747  ("MostUsedServerPacketVersion" + index);
748 
749  ServerInfo server;
750  server.name = config.getValue(nameKey, "");
751  server.description = config.getValue(descKey, "");
752  server.onlineListUrl = config.getValue(onlineListUrlKey, "");
753  server.hostname = config.getValue(hostKey, "");
754  server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
755  server.persistentIp = config.getValue(
756  persistentIpKey, 0) != 0 ? true : false;
757  server.packetVersion = config.getValue(packetVersionKey, 0);
758 
759  const int defaultPort = defaultPortForServerType(server.type);
760  server.port = CAST_U16(
761  config.getValue(portKey, defaultPort));
762 
763  // skip invalid server
764  if (!server.isValid())
765  continue;
766 
767  server.save = true;
768  mServers.push_back(server);
769  }
770 }
771 
772 void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
773  const int index)
774 {
775  // Make sure the current server is mentioned first
776  if (currentServer.isValid())
777  {
778  if (index >= 0 && CAST_SIZE(index) < mServers.size())
779  {
780  mServers[index] = currentServer;
781  }
782  else
783  {
784  FOR_EACH (ServerInfos::iterator, i, mServers)
785  {
786  if (*i == currentServer)
787  {
788  mServers.erase(i);
789  break;
790  }
791  }
792  mServers.insert(mServers.begin(), currentServer);
793  }
794  }
795 
796  int savedServerCount = 0;
797 
798  for (unsigned i = 0, fsz = CAST_U32(mServers.size());
799  i < fsz && savedServerCount < MAX_SERVERLIST; ++ i)
800  {
801  const ServerInfo &server = mServers.at(i);
802 
803  // Only save servers that were loaded from settings
804  if (!(server.save && server.isValid()))
805  continue;
806 
807  const std::string num = toString(savedServerCount);
808  const std::string nameKey("MostUsedServerDescName" + num);
809  const std::string descKey("MostUsedServerDescription" + num);
810  const std::string hostKey("MostUsedServerName" + num);
811  const std::string typeKey("MostUsedServerType" + num);
812  const std::string portKey("MostUsedServerPort" + num);
813  const std::string onlineListUrlKey
814  ("MostUsedServerOnlineList" + num);
815  const std::string persistentIpKey("persistentIp" + num);
816  const std::string packetVersionKey
817  ("MostUsedServerPacketVersion" + num);
818 
819  config.setValue(nameKey, server.name);
820  config.setValue(descKey, server.description);
821  config.setValue(onlineListUrlKey, server.onlineListUrl);
822  config.setValue(hostKey, server.hostname);
823  config.setValue(typeKey, serverTypeToString(server.type));
824  config.setValue(portKey, toString(server.port));
825  config.setValue(persistentIpKey, server.persistentIp);
826  config.setValue(packetVersionKey, server.packetVersion);
827  ++ savedServerCount;
828  }
829 
830  // Insert an invalid entry at the end to make the loading stop there
831  if (savedServerCount < MAX_SERVERLIST)
832  config.setValue("MostUsedServerName" + toString(savedServerCount), "");
833 }
834 
836  const DownloadStatusT status,
837  size_t total,
838  const size_t remaining)
839 {
840  if ((ptr == nullptr) || status == DownloadStatus::Cancelled)
841  return -1;
842 
843  ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
844  bool finished = false;
845 
846  if (sd->mDownload == nullptr)
847  return -1;
848 
849  if (status == DownloadStatus::Complete)
850  {
851  finished = true;
852  }
853  else if (CAST_S32(status) < 0)
854  {
855  logger->log("Error retreiving server list: %s\n",
856  sd->mDownload->getError());
858  }
859  else
860  {
861  float progress = static_cast<float>(remaining);
862  if (total != 0u)
863  progress /= static_cast<float>(total);
864 
865  if (progress != progress || progress < 0.0F)
866  progress = 0.0f;
867  else if (progress > 1.0F)
868  progress = 1.0F;
869 
870  MutexLocker lock1(&sd->mMutex);
872  sd->mDownloadProgress = progress;
873  }
874 
875  if (finished)
876  {
877  MutexLocker lock1(&sd->mMutex);
879  }
880 
881  return 0;
882 }
883 
884 void ServerDialog::updateServer(const ServerInfo &server, const int index)
885 {
886  saveCustomServers(server, index);
887 }
888 
890 {
891  if (mServers.empty() || config.getStringValue("serverslistupdate")
892  != getDateString())
893  {
894  return true;
895  }
896 
897  return false;
898 }
899 
901 {
902  if (mDownload != nullptr)
903  mDownload->cancel();
905  Window::close();
906 }
std::string serverUrl
Definition: serverinfo.h:50
#define CAST_U32
Definition: cast.h:30
Configuration branding
const bool UseVirtFs_false
Definition: usevirtfs.h:29
std::string defaultHostName
Definition: serverinfo.h:51
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setDefaultSize()
Definition: window.cpp:1193
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1379
std::string getStringValue(const std::string &key) const
void loadCustomServers()
#define _(s)
Definition: gettext.h:34
ServerDialogDownloadStatusT mDownloadStatus
Definition: serverdialog.h:147
void setSelected(const int selected)
Definition: listbox.cpp:398
int getWidth() const
Definition: widget.h:220
void log1(const char *const log_text)
Definition: logger.cpp:222
ServerTypeT type
Definition: serverinfo.h:41
void setVersionString(const int index, const std::string &version)
void addMirror(const std::string &str)
Definition: download.h:87
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1461
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
void setState(const StateT state)
Definition: client.h:65
const bool Visible_true
Definition: visible.h:29
static std::string serverTypeToString(const ServerTypeT type)
std::string hostname
Definition: serverinfo.h:44
void loadWindowState()
Definition: window.cpp:1082
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
void mouseClicked(MouseEvent &event)
static void loadServerSources(const xmlNodePtr node, ServerInfo &server)
std::vector< ServerUrlInfo > nonFreeSources
Definition: serverinfo.h:55
unsigned cancel
Definition: download.h:124
bool persistentIp
Definition: settings.h:150
MouseButtonT getButton() const
Definition: mouseevent.h:115
std::string pathJoin(std::string str1, const std::string &str2)
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
void setMinWidth(const int width)
Definition: window.cpp:586
void addSelectionListener(SelectionListener *const selectionListener)
Definition: listbox.cpp:434
Definition: window.h:98
ServerInfos mServers
Definition: serverdialog.h:129
#define BLOCK_START(name)
Definition: perfomance.h:78
Definition: button.h:94
Configuration config
bool checkPath(const std::string &path)
Definition: paths.cpp:106
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:171
static ServerTypeT parseType(const std::string &serverType)
Definition: serverinfo.h:196
StringVect hosts
Definition: hostsgroup.h:39
InputActionT getActionId() const
Definition: keyevent.h:126
#define BLOCK_END(name)
Definition: perfomance.h:79
Button * mLoadButton
Definition: serverdialog.h:137
Button * mConnectButton
Definition: serverdialog.h:133
std::string supportUrl
Definition: settings.h:119
Font * getFont() const
Definition: gui.h:159
const std::string & getActionEventId() const
Definition: widget.h:604
void setVerticalScrollAmount(const int vScroll)
Client * client
Definition: client.cpp:113
static void loadServerSourcesList(const xmlNodePtr node, std::vector< ServerUrlInfo > &list)
#define delete2(var)
Definition: delete2.h:24
ServerInfo * mServerInfo
Definition: serverdialog.h:144
void action(const ActionEvent &event)
Button * mInfoButton
Definition: serverdialog.h:138
std::string registerUrl
Definition: serverinfo.h:47
std::vector< std::string > updateMirrors
Definition: settings.h:127
bool persistentIp
Definition: serverinfo.h:61
ServerDialog(ServerInfo *const serverInfo, const std::string &dir)
int compareStrI(const std::string &a, const std::string &b)
Logger * logger
Definition: logger.cpp:95
void setFile(const std::string &filename, const int64_t adler32)
Definition: download.cpp:164
const std::string & mDir
Definition: serverdialog.h:130
VersionString version
Definition: serverinfo.h:58
virtual void close()
Definition: window.cpp:897
#define new
Definition: debug_new.h:147
void downloadServerList()
void setContentSize(int width, int height)
Definition: window.cpp:491
Settings settings
Definition: settings.cpp:31
#define CAST_U16
Definition: cast.h:28
bool getBoolValue(const std::string &key) const
#define CAST_S32
Definition: cast.h:29
std::vector< ServerInfo > ServerInfos
Definition: serverinfo.h:226
virtual void requestFocus()
Definition: widget.cpp:203
void keyPressed(KeyEvent &event)
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setCaption(const std::string &caption)
Definition: label.cpp:261
CheckBox * mPersistentIPCheckBox
Definition: serverdialog.h:145
const char * getError() const
Definition: download.cpp:213
Definition: label.h:87
std::string onlineListUrl
Definition: serverinfo.h:48
std::string name
Definition: hostsgroup.h:38
#define fromBool(val, name)
Definition: booldefines.h:48
#define SMALL_VERSION
Definition: main.h:43
std::vector< ServerUrlInfo > freeSources
Definition: serverinfo.h:54
std::vector< ServerUrlInfo > docs
Definition: serverinfo.h:56
std::string getDateString()
Button * mQuitButton
Definition: serverdialog.h:132
uint16_t port
Definition: serverinfo.h:57
ServerInfoWindow * serverInfoWindow
int getSelected() const
Definition: listbox.h:167
#define nullptr
Definition: localconsts.h:44
std::vector< HostsGroup > updateHosts
Definition: serverinfo.h:53
static const int MAX_SERVERLIST
std::string description
Definition: serverinfo.h:46
std::vector< std::string > updateMirrors
Definition: serverinfo.h:52
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
void setCloseButton(const bool flag)
Definition: window.cpp:744
static std::string savedPassword
Definition: logindialog.h:79
DownloadStatus ::T DownloadStatusT
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
ServerType ::T ServerTypeT
Definition: servertype.h:35
ServersListModel * mServersListModel
Definition: serverdialog.h:139
static void loadHostsGroup(const xmlNodePtr node, ServerInfo &server)
bool isConsumed() const
void valueChanged(const SelectionEvent &event)
bool start()
Definition: download.cpp:186
void setMinHeight(const int height)
Definition: window.cpp:599
void setEnabled(const bool enabled)
Definition: widget.h:351
std::string empty
Definition: podict.cpp:25
xmlNodePtr rootNode()
Definition: libxml.cpp:166
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59
virtual void scheduleDelete()
Definition: window.cpp:826
Layout & getLayout()
Definition: window.cpp:1360
static int downloadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
Label * mDescription
Definition: serverdialog.h:131
bool isSafeMode
Definition: client.cpp:118
std::string supportUrl
Definition: serverinfo.h:49
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:255
int packetVersion
Definition: serverinfo.h:59
std::string getValue(const std::string &key, const std::string &deflt) const
#define A_UNUSED
Definition: localconsts.h:171
void saveCustomServers(const ServerInfo &currentServer, const int index)
virtual void setVisible(Visible visible)
Definition: window.cpp:773
void loadServers(const bool addNew)
#define CREATEWIDGET(type,...)
Definition: createwidget.h:28
Button * mEditEntryButton
Definition: serverdialog.h:135
#define for_each_xml_child_node(var, parent)
Definition: libxml.h:160
Net::Download * mDownload
Definition: serverdialog.h:143
std::string getLangShort()
Definition: langs.cpp:101
std::string althostname
Definition: serverinfo.h:45
std::string name
Definition: serverinfo.h:43
bool save
Definition: serverinfo.h:60
StateT getState() const
Definition: client.h:68
void reloadWallpaper()
Definition: desktop.cpp:121
ListBox * mServersList
Definition: serverdialog.h:140
ServerFreeTypeT freeType
Definition: serverinfo.h:42
void connectToSelectedServer()
int getHeight() const
Definition: widget.h:239
void setResizable(const bool resize)
Definition: window.cpp:622
bool isValid() const
Definition: serverinfo.h:149
#define CAST_SIZE
Definition: cast.h:33
bool needUpdateServers() const
static uint16_t defaultPortForServerType(const ServerTypeT type)
void updateServer(const ServerInfo &server, const int index)
Button * mDeleteButton
Definition: serverdialog.h:136
void setServerName(const std::string &serverName)
Definition: chatlogger.cpp:176
int getClickCount() const
Definition: mouseevent.h:146
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
void log(const char *const log_text,...)
Definition: logger.cpp:243
float mDownloadProgress
Definition: serverdialog.h:146
const bool SkipError_true
Definition: skiperror.h:29
Desktop * desktop
Definition: desktop.cpp:48
void keyPressed(KeyEvent &event)
Definition: listbox.cpp:245
ChatLogger * chatLogger
Definition: chatlogger.cpp:43
void setCaption(const std::string &caption)
Definition: window.h:530
bool isSelected() const
Definition: checkbox.h:146
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
void setValue(const std::string &key, const std::string &value)
Button * mAddEntryButton
Definition: serverdialog.h:134
bool url(InputEvent &event)
Definition: commands.cpp:63
static ServerFreeTypeT parseFreeType(const std::string &serverFreeType)
Definition: serverinfo.h:213
void postInit()
Definition: window.cpp:248
static std::string savedPasswordKey
Definition: logindialog.h:78
void setWindowName(const std::string &name)
Definition: window.h:354
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)