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", BUTTON_SKIN, this)),
109  // TRANSLATORS: servers dialog button
110  mConnectButton(new Button(this, _("Connect"), "connect",
111  BUTTON_SKIN, this)),
112  // TRANSLATORS: servers dialog button
113  mAddEntryButton(new Button(this, _("Add"), "addEntry", BUTTON_SKIN, this)),
114  // TRANSLATORS: servers dialog button
115  mEditEntryButton(new Button(this, _("Edit"), "editEntry",
116  BUTTON_SKIN, this)),
117  // TRANSLATORS: servers dialog button
118  mDeleteButton(new Button(this, _("Delete"), "remove", BUTTON_SKIN, this)),
119  // TRANSLATORS: servers dialog button
120  mLoadButton(new Button(this, _("Load"), "load", BUTTON_SKIN, this)),
121  // TRANSLATORS: servers dialog button
122  mInfoButton(new Button(this, _("Info"), "info", BUTTON_SKIN, this)),
123  mServersListModel(new ServersListModel(&mServers, this)),
124  mServersList(CREATEWIDGETR(ServersListBox, this, mServersListModel)),
125  mDownload(nullptr),
126  mServerInfo(serverInfo),
127  mPersistentIPCheckBox(nullptr),
128  mDownloadProgress(-1.0F),
129  mDownloadStatus(ServerDialogDownloadStatus::UNKNOWN)
130 {
131  if (isSafeMode)
132  {
133  // TRANSLATORS: servers dialog name
134  setCaption(_("Choose Your Server *** SAFE MODE ***"));
135  }
136 #ifdef USE_OPENGL
137  else if (config.getIntValue("opengl") == RENDER_SOFTWARE)
138  {
139  // TRANSLATORS: servers dialog name
140  setCaption(_("Choose Your Server *** SOFTWARE RENDER MODE ***"));
141  }
142 #endif // USE_OPENGL
143 
144  setWindowName("ServerDialog");
145 
146  setCloseButton(true);
147 
148  mPersistentIPCheckBox = new CheckBox(this,
149  // TRANSLATORS: servers dialog checkbox
150  _("Use same ip for game sub servers"),
151  config.getBoolValue("usePersistentIP"),
152  this, "persitent ip");
153 
155 
157 
158  ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
159  fromBool(getOptionBool("showbackground", false), Opaque),
160  "server_background.xml");
162 
164  usedScroll->setVerticalScrollAmount(0);
165 
166  place(0, 0, usedScroll, 8, 5).setPadding(3);
167  place(0, 5, mDescription, 8, 1);
168  place(0, 6, mPersistentIPCheckBox, 8, 1);
169  place(0, 7, mInfoButton, 1, 1);
170  place(1, 7, mAddEntryButton, 1, 1);
171  place(2, 7, mEditEntryButton, 1, 1);
172  place(3, 7, mLoadButton, 1, 1);
173  place(4, 7, mDeleteButton, 1, 1);
174  place(6, 7, mQuitButton, 1, 1);
175  place(7, 7, mConnectButton, 1, 1);
176 
177  // Make sure the list has enough height
178  getLayout().setRowHeight(0, 80);
179 
180  // Do this manually instead of calling reflowLayout so we can enforce a
181  // minimum width.
182  int width = 500;
183  int height = 350;
184 
185  getLayout().reflow(width, height);
186  setContentSize(width, height);
187 
188  setMinWidth(310);
189  setMinHeight(220);
191 
192  setResizable(true);
193  addKeyListener(this);
194 
195  loadWindowState();
196 }
197 
199 {
202 
204 
205  loadServers(true);
206 
207  mServersList->setSelected(0); // Do this after for the Delete button
208 
209  if (needUpdateServers())
211  else
212  logger->log("Skipping servers list update");
213 }
214 
216 {
217  if (mDownload != nullptr)
218  {
219  mDownload->cancel();
221  }
223 }
224 
226 {
228  return;
229 
230  const int index = mServersList->getSelected();
231  if (index < 0)
232  return;
233 
234  if (mDownload != nullptr)
235  mDownload->cancel();
236 
237  mQuitButton->setEnabled(false);
238  mConnectButton->setEnabled(false);
239  mLoadButton->setEnabled(false);
240 
241  ServerInfo server = mServers.at(index);
242  mServerInfo->hostname = server.hostname;
244  mServerInfo->port = server.port;
245  mServerInfo->type = server.type;
246  mServerInfo->name = server.name;
252  mServerInfo->save = true;
254  mServerInfo->freeType = server.freeType;
260  mServerInfo->docs = server.docs;
261  mServerInfo->serverUrl = server.serverUrl;
262 
266 
267  if (chatLogger != nullptr)
269 
271  -1);
272 
274  {
276  {
278  if (desktop != nullptr)
280  }
281  }
282 
283  config.setValue("usePersistentIP",
286 }
287 
289 {
290  const std::string &eventId = event.getId();
291  if (eventId == "connect")
292  {
294  }
295  else if (eventId == "quit")
296  {
297  close();
298  }
299  else if (eventId == "load")
300  {
302  }
303  else if (eventId == "addEntry")
304  {
306  }
307  else if (eventId == "editEntry")
308  {
309  const int index = mServersList->getSelected();
310  if (index >= 0)
311  {
313  this,
314  mServers.at(index),
315  index);
316  }
317  }
318  else if (eventId == "remove")
319  {
320  const int index = mServersList->getSelected();
321  if (index >= 0)
322  {
324  mServers.erase(mServers.begin() + index);
326  -1);
327  }
328  }
329  else if (eventId == "info")
330  {
331  const int index = mServersList->getSelected();
332  if (index >= 0)
333  {
334  if (serverInfoWindow != nullptr)
337  mServers.at(index));
338  }
339  }
340 }
341 
343 {
344  PRAGMA45(GCC diagnostic push)
345  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
346  switch (event.getActionId())
347  {
349  event.consume();
351  return;
352 
355  event.consume();
356  action(ActionEvent(nullptr,
358  return;
359 
362  return;
363 
365  {
366  const int index = mServersList->getSelected();
367  if (index >= 0)
368  {
370  mServers.erase(mServers.begin() + index);
372  -1);
373  }
374  return;
375  }
376 
378  {
379  const int index = mServersList->getSelected();
380  if (index >= 0)
381  {
382  CREATEWIDGET(EditServerDialog, this, mServers.at(index),
383  index);
384  }
385  return;
386  }
387 
388  default:
389  break;
390  }
391  PRAGMA45(GCC diagnostic pop)
392  if (!event.isConsumed())
393  mServersList->keyPressed(event);
394 }
395 
397 {
398  const int index = mServersList->getSelected();
399  if (index == -1)
400  {
401  mDeleteButton->setEnabled(false);
402  return;
403  }
404  mDeleteButton->setEnabled(true);
405 }
406 
408 {
409  if (event.getButton() == MouseButton::LEFT)
410  {
411  event.consume();
412  if (event.getClickCount() == 2 &&
413  event.getSource() == mServersList)
414  {
417  }
418  }
419 }
420 
422 {
423  BLOCK_START("ServerDialog::logic")
424  {
425  MutexLocker tempLock(&mMutex);
427  {
428  loadServers(true);
430  mDescription->setCaption(std::string());
431  logger->log("Servers list updated");
432  }
434  {
435  // TRANSLATORS: servers dialog label
436  mDescription->setCaption(strprintf(_("Downloading server list..."
437  "%2.2f%%"), static_cast<double>(mDownloadProgress * 100)));
438  }
440  {
441  // TRANSLATORS: servers dialog label
442  mDescription->setCaption(_("Waiting for server..."));
443  }
445  {
446  // TRANSLATORS: servers dialog label
447  mDescription->setCaption(_("Preparing download"));
448  }
450  {
451  // TRANSLATORS: servers dialog label
452  mDescription->setCaption(_("Error retreiving server list!"));
453  logger->log("Error: servers list updating error");
454  }
455  }
456 
457  Window::logic();
458  BLOCK_END("ServerDialog::logic")
459 }
460 
462 {
463  // Try to load the configuration value for the onlineServerList
464  std::string listFile = branding.getStringValue("onlineServerList");
465  std::string listFile2 = branding.getStringValue("onlineServerList2");
466 
467  // Fall back to manaplus.org when neither branding
468  // nor config set it
469  if (listFile.empty())
470  listFile = "http://manaplus.org/serverlist.xml";
471 
472  if (mDownload != nullptr)
473  {
474  mDownload->cancel();
476  }
477 
478  mDownload = new Net::Download(this, listFile,
479  &downloadUpdate, false, false, true);
481  branding.getStringValue("onlineServerFile")),
482  -1);
483  if (!listFile2.empty())
484  mDownload->addMirror(listFile2);
485  mDownload->start();
486 
487  config.setValue("serverslistupdate", getDateString());
488 }
489 
490 static void loadHostsGroup(XmlNodeConstPtr node,
491  ServerInfo &server)
492 {
493  HostsGroup group;
494  group.name = XML::langProperty(node,
495  "name",
496  // TRANSLATORS: unknown hosts group name
497  _("Unknown"));
498  for_each_xml_child_node(hostNode, node)
499  {
500  if (!xmlNameEqual(hostNode, "host") ||
501  !XmlHaveChildContent(hostNode))
502  {
503  continue;
504  }
505  const std::string host = XmlChildContent(hostNode);
506  if (host.empty())
507  continue;
508  if (!checkPath(host))
509  {
510  logger->log1("Warning: incorrect update server name");
511  continue;
512  }
513 
514  group.hosts.push_back(host);
515  }
516  if (!group.hosts.empty())
517  server.updateHosts.push_back(group);
518 }
519 
520 static void loadServerSourcesList(XmlNodeConstPtr node,
521  STD_VECTOR<ServerUrlInfo> &list)
522 {
523  for_each_xml_child_node(urlNode, node)
524  {
525  if (!xmlNameEqual(urlNode, "url") ||
526  !XmlHaveChildContent(urlNode))
527  {
528  continue;
529  }
530  const std::string name = XML::langProperty(urlNode,
531  "name",
532  "");
533  if (name.empty())
534  continue;
535  const std::string url = XmlChildContent(urlNode);
536  if (url.empty())
537  continue;
538  list.push_back(ServerUrlInfo(name, url));
539  }
540 }
541 
542 static void loadServerSources(XmlNodeConstPtr node,
543  ServerInfo &server)
544 {
545  for_each_xml_child_node(subNode, node)
546  {
547  if (xmlNameEqual(subNode, "free"))
548  {
549  loadServerSourcesList(subNode, server.freeSources);
550  }
551  else if (xmlNameEqual(subNode, "nonfree"))
552  {
553  loadServerSourcesList(subNode, server.nonFreeSources);
554  }
555  }
556 }
557 
558 void ServerDialog::loadServers(const bool addNew)
559 {
561  branding.getStringValue("onlineServerFile")),
564  XmlNodeConstPtr rootNode = doc.rootNode();
565 
566  if (rootNode == nullptr ||
567  !xmlNameEqual(rootNode, "serverlist"))
568  {
569  logger->log1("Error loading server list!");
570  return;
571  }
572 
573  const int ver = XML::getProperty(rootNode, "version", 0);
574  if (ver != 1)
575  {
576  logger->log("Error: unsupported online server list version: %d",
577  ver);
578  return;
579  }
580 
581  const std::string lang = getLangShort();
582  const std::string description2("description_" + lang);
583 
584  for_each_xml_child_node(serverNode, rootNode)
585  {
586  if (!xmlNameEqual(serverNode, "server"))
587  continue;
588 
589  const std::string type = XML::getProperty(
590  serverNode, "type", "unknown");
591  ServerInfo server;
592  server.type = ServerInfo::parseType(type);
593  const std::string licenseType = XML::getProperty(
594  serverNode, "licenseType", "notset");
595  server.freeType = ServerInfo::parseFreeType(licenseType);
596 
597  // Ignore unknown server types
598  if (server.type == ServerType::UNKNOWN)
599  {
600  logger->log("Ignoring server entry with unknown type: %s",
601  type.c_str());
602  continue;
603  }
604 
605  server.name = XML::getProperty(serverNode, "name", std::string());
606  std::string version = XML::getProperty(serverNode, "minimumVersion",
607  std::string());
608 
609  const bool meetsMinimumVersion = (compareStrI(version, SMALL_VERSION)
610  <= 0);
611 
612  // For display in the list
613  if (meetsMinimumVersion)
614  version.clear();
615  else if (version.empty())
616  {
617  // TRANSLATORS: servers dialog label
618  version = _("requires a newer version");
619  }
620  else
621  {
622  // TRANSLATORS: servers dialog label
623  version = strprintf(_("requires v%s"), version.c_str());
624  }
625 
626  const Font *const font = gui->getFont();
627 
628  for_each_xml_child_node(subNode, serverNode)
629  {
630  if (xmlNameEqual(subNode, "connection"))
631  {
632  server.hostname = XML::getProperty(subNode, "hostname", "");
633  server.althostname = XML::getProperty(
634  subNode, "althostname", "");
635  server.port = CAST_U16(
636  XML::getProperty(subNode, "port", 0));
637  server.packetVersion = XML::getProperty(subNode,
638  "packetVersion", 0);
639 
640  if (server.port == 0)
641  {
642  // If no port is given, use the default for the given type
643  server.port = defaultPortForServerType(server.type);
644  }
645  }
646  else if (XmlHaveChildContent(subNode))
647  {
648  if ((xmlNameEqual(subNode, "description")
649  && server.description.empty()) || (!lang.empty()
650  && xmlNameEqual(subNode, description2.c_str())))
651  {
652  server.description = XmlChildContent(subNode);
653  }
654  else if (xmlNameEqual(subNode, "registerurl"))
655  {
656  server.registerUrl = XmlChildContent(subNode);
657  }
658  else if (xmlNameEqual(subNode, "onlineListUrl"))
659  {
660  server.onlineListUrl = XmlChildContent(subNode);
661  }
662  else if (xmlNameEqual(subNode, "support"))
663  {
664  server.supportUrl = XmlChildContent(subNode);
665  }
666  else if (xmlNameEqual(subNode, "persistentIp"))
667  {
668  std::string text = XmlChildContent(subNode);
669  server.persistentIp = (text == "1" || text == "true");
670  }
671  else if (xmlNameEqual(subNode, "updateMirror"))
672  {
673  server.updateMirrors.push_back(XmlChildContent(subNode));
674  }
675  else if (xmlNameEqual(subNode, "site"))
676  {
677  server.serverUrl = XmlChildContent(subNode);
678  }
679  }
680  if (xmlNameEqual(subNode, "updates"))
681  {
682  loadHostsGroup(subNode, server);
683  }
684  else if (xmlNameEqual(subNode, "defaultUpdateHost"))
685  {
687  // TRANSLATORS: default hosts group name
688  subNode, "name", _("default"));
689  }
690  else if (xmlNameEqual(subNode, "sources"))
691  {
692  loadServerSources(subNode, server);
693  }
694  else if (xmlNameEqual(subNode, "docs"))
695  {
696  loadServerSourcesList(subNode, server.docs);
697  }
698  }
699 
700  server.version.first = font->getWidth(version);
701  server.version.second = version;
702 
703  MutexLocker tempLock(&mMutex);
704  // Add the server to the local list if it's not already present
705  bool found = false;
706  for (unsigned int i = 0, fsz = CAST_U32(
707  mServers.size()); i < fsz; i++)
708  {
709  if (mServers[i] == server)
710  {
711  // Use the name listed in the server list
712  mServers[i].name = server.name;
713  mServers[i].type = server.type;
714  mServers[i].freeType = server.freeType;
715  mServers[i].version = server.version;
716  mServers[i].description = server.description;
717  mServers[i].registerUrl = server.registerUrl;
718  mServers[i].onlineListUrl = server.onlineListUrl;
719  mServers[i].supportUrl = server.supportUrl;
720  mServers[i].serverUrl = server.serverUrl;
721  mServers[i].althostname = server.althostname;
722  mServers[i].persistentIp = server.persistentIp;
723  mServers[i].updateMirrors = server.updateMirrors;
724  mServers[i].defaultHostName = server.defaultHostName;
725  mServers[i].updateHosts = server.updateHosts;
726  mServers[i].packetVersion = server.packetVersion;
727  mServers[i].freeSources = server.freeSources;
728  mServers[i].nonFreeSources = server.nonFreeSources;
729  mServers[i].docs = server.docs;
730  mServersListModel->setVersionString(i, version);
731  found = true;
732  break;
733  }
734  }
735  if (!found && addNew)
736  mServers.push_back(server);
737  }
738  if (mServersList->getSelected() < 0)
740 }
741 
743 {
744  for (int i = 0; i < MAX_SERVERLIST; ++i)
745  {
746  const std::string index = toString(i);
747  const std::string nameKey("MostUsedServerDescName" + index);
748  const std::string descKey("MostUsedServerDescription" + index);
749  const std::string hostKey("MostUsedServerName" + index);
750  const std::string typeKey("MostUsedServerType" + index);
751  const std::string portKey("MostUsedServerPort" + index);
752  const std::string onlineListUrlKey
753  ("MostUsedServerOnlineList" + index);
754  const std::string persistentIpKey("persistentIp" + index);
755  const std::string packetVersionKey
756  ("MostUsedServerPacketVersion" + index);
757 
758  ServerInfo server;
759  server.name = config.getValue(nameKey, "");
760  server.description = config.getValue(descKey, "");
761  server.onlineListUrl = config.getValue(onlineListUrlKey, "");
762  server.hostname = config.getValue(hostKey, "");
763  server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
764  server.persistentIp = config.getValue(
765  persistentIpKey, 0) != 0 ? true : false;
766  server.packetVersion = config.getValue(packetVersionKey, 0);
767 
768  const int defaultPort = defaultPortForServerType(server.type);
769  server.port = CAST_U16(
770  config.getValue(portKey, defaultPort));
771 
772  // skip invalid server
773  if (!server.isValid())
774  continue;
775 
776  server.save = true;
777  mServers.push_back(server);
778  }
779 }
780 
781 void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
782  const int index)
783 {
784  // Make sure the current server is mentioned first
785  if (currentServer.isValid())
786  {
787  if (index >= 0 && CAST_SIZE(index) < mServers.size())
788  {
789  mServers[index] = currentServer;
790  }
791  else
792  {
793  FOR_EACH (ServerInfos::iterator, i, mServers)
794  {
795  if (*i == currentServer)
796  {
797  mServers.erase(i);
798  break;
799  }
800  }
801  mServers.insert(mServers.begin(), currentServer);
802  }
803  }
804 
805  int savedServerCount = 0;
806 
807  for (unsigned i = 0, fsz = CAST_U32(mServers.size());
808  i < fsz && savedServerCount < MAX_SERVERLIST; ++ i)
809  {
810  const ServerInfo &server = mServers.at(i);
811 
812  // Only save servers that were loaded from settings
813  if (!(server.save && server.isValid()))
814  continue;
815 
816  const std::string num = toString(savedServerCount);
817  const std::string nameKey("MostUsedServerDescName" + num);
818  const std::string descKey("MostUsedServerDescription" + num);
819  const std::string hostKey("MostUsedServerName" + num);
820  const std::string typeKey("MostUsedServerType" + num);
821  const std::string portKey("MostUsedServerPort" + num);
822  const std::string onlineListUrlKey
823  ("MostUsedServerOnlineList" + num);
824  const std::string persistentIpKey("persistentIp" + num);
825  const std::string packetVersionKey
826  ("MostUsedServerPacketVersion" + num);
827 
828  config.setValue(nameKey, server.name);
829  config.setValue(descKey, server.description);
830  config.setValue(onlineListUrlKey, server.onlineListUrl);
831  config.setValue(hostKey, server.hostname);
832  config.setValue(typeKey, serverTypeToString(server.type));
833  config.setValue(portKey, toString(server.port));
834  config.setValue(persistentIpKey, server.persistentIp);
835  config.setValue(packetVersionKey, server.packetVersion);
836  ++ savedServerCount;
837  }
838 
839  // Insert an invalid entry at the end to make the loading stop there
840  if (savedServerCount < MAX_SERVERLIST)
841  config.setValue("MostUsedServerName" + toString(savedServerCount), "");
842 }
843 
845  const DownloadStatusT status,
846  size_t total,
847  const size_t remaining)
848 {
849  if ((ptr == nullptr) || status == DownloadStatus::Cancelled)
850  return -1;
851 
852  ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
853  bool finished = false;
854 
855  if (sd->mDownload == nullptr)
856  return -1;
857 
858  if (status == DownloadStatus::Complete)
859  {
860  finished = true;
861  }
862  else if (CAST_S32(status) < 0)
863  {
864  logger->log("Error retreiving server list: %s\n",
865  sd->mDownload->getError());
867  }
868  else
869  {
870  float progress = static_cast<float>(remaining);
871  if (total != 0U)
872  progress /= static_cast<float>(total);
873 
874  if (progress != progress || progress < 0.0F)
875  progress = 0.0F;
876  else if (progress > 1.0F)
877  progress = 1.0F;
878 
879  MutexLocker lock1(&sd->mMutex);
881  sd->mDownloadProgress = progress;
882  }
883 
884  if (finished)
885  {
886  MutexLocker lock1(&sd->mMutex);
888  }
889 
890  return 0;
891 }
892 
893 void ServerDialog::updateServer(const ServerInfo &server, const int index)
894 {
895  saveCustomServers(server, index);
896 }
897 
899 {
900  if (mServers.empty() || config.getStringValue("serverslistupdate")
901  != getDateString())
902  {
903  return true;
904  }
905 
906  return false;
907 }
908 
910 {
911  if (mDownload != nullptr)
912  mDownload->cancel();
914  Window::close();
915 }
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:1197
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
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:233
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:1465
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:1086
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:126
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:590
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:96
Configuration config
bool checkPath(const std::string &path)
Definition: paths.cpp:119
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:173
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
int getIntValue(const std::string &key) const
const std::string & getActionEventId() const
Definition: widget.h:604
void setVerticalScrollAmount(const int vScroll)
Client * client
Definition: client.cpp:117
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:88
void setFile(const std::string &filename, const int64_t adler32)
Definition: download.cpp:165
const std::string & mDir
Definition: serverdialog.h:130
VersionString version
Definition: serverinfo.h:58
virtual void close()
Definition: window.cpp:901
#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)
const std::string BUTTON_SKIN
Definition: button.h:88
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:217
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:748
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:187
void setMinHeight(const int height)
Definition: window.cpp:603
void setEnabled(const bool enabled)
Definition: widget.h:351
std::string empty
Definition: podict.cpp:25
xmlNodePtr rootNode()
Definition: libxml.cpp:168
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59
virtual void scheduleDelete()
Definition: window.cpp:830
Layout & getLayout()
Definition: window.cpp:1364
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:122
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:257
int packetVersion
Definition: serverinfo.h:59
std::string getValue(const std::string &key, const std::string &deflt) const
#define A_UNUSED
Definition: localconsts.h:159
void saveCustomServers(const ServerInfo &currentServer, const int index)
virtual void setVisible(Visible visible)
Definition: window.cpp:777
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:626
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:264
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)