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