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