70 #endif // TMWA_SUPPORT 97 const std::string &dir) :
110 mConnectButton(
new Button(this,
_(
"Connect"),
"connect",
115 mEditEntryButton(
new Button(this,
_(
"Edit"),
"editEntry",
126 mServerInfo(serverInfo),
127 mPersistentIPCheckBox(
nullptr),
128 mDownloadProgress(-1.0F),
134 setCaption(
_(
"Choose Your Server *** SAFE MODE ***"));
140 setCaption(
_(
"Choose Your Server *** SOFTWARE RENDER MODE ***"));
150 _(
"Use same ip for game sub servers"),
152 this,
"persitent ip");
160 "server_background.xml");
212 logger->
log(
"Skipping servers list update");
290 const std::string &eventId =
event.getId();
291 if (eventId ==
"connect")
295 else if (eventId ==
"quit")
299 else if (eventId ==
"load")
303 else if (eventId ==
"addEntry")
307 else if (eventId ==
"editEntry")
318 else if (eventId ==
"remove")
329 else if (eventId ==
"info")
345 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
453 logger->
log(
"Error: servers list updating error");
469 if (listFile.empty())
470 listFile =
"http://manaplus.org/serverlist.xml";
483 if (!listFile2.empty())
500 if (!xmlNameEqual(hostNode,
"host") ||
501 !XmlHaveChildContent(hostNode))
505 const std::string host = XmlChildContent(hostNode);
510 logger->
log1(
"Warning: incorrect update server name");
514 group.
hosts.push_back(host);
516 if (!group.
hosts.empty())
521 STD_VECTOR<ServerUrlInfo> &list)
525 if (!xmlNameEqual(urlNode,
"url") ||
526 !XmlHaveChildContent(urlNode))
535 const std::string
url = XmlChildContent(urlNode);
547 if (xmlNameEqual(subNode,
"free"))
551 else if (xmlNameEqual(subNode,
"nonfree"))
564 XmlNodeConstPtr rootNode = doc.
rootNode();
566 if (rootNode ==
nullptr ||
567 !xmlNameEqual(rootNode,
"serverlist"))
576 logger->
log(
"Error: unsupported online server list version: %d",
582 const std::string description2(
"description_" + lang);
586 if (!xmlNameEqual(serverNode,
"server"))
590 serverNode,
"type",
"unknown");
594 serverNode,
"licenseType",
"notset");
600 logger->
log(
"Ignoring server entry with unknown type: %s",
613 if (meetsMinimumVersion)
615 else if (version.empty())
618 version =
_(
"requires a newer version");
623 version =
strprintf(
_(
"requires v%s"), version.c_str());
630 if (xmlNameEqual(subNode,
"connection"))
634 subNode,
"althostname",
"");
640 if (server.
port == 0)
646 else if (XmlHaveChildContent(subNode))
648 if ((xmlNameEqual(subNode,
"description")
650 && xmlNameEqual(subNode, description2.c_str())))
654 else if (xmlNameEqual(subNode,
"registerurl"))
658 else if (xmlNameEqual(subNode,
"onlineListUrl"))
662 else if (xmlNameEqual(subNode,
"support"))
666 else if (xmlNameEqual(subNode,
"persistentIp"))
668 std::string text = XmlChildContent(subNode);
671 else if (xmlNameEqual(subNode,
"updateMirror"))
675 else if (xmlNameEqual(subNode,
"site"))
677 server.
serverUrl = XmlChildContent(subNode);
680 if (xmlNameEqual(subNode,
"updates"))
684 else if (xmlNameEqual(subNode,
"defaultUpdateHost"))
688 subNode,
"name",
_(
"default"));
690 else if (xmlNameEqual(subNode,
"sources"))
694 else if (xmlNameEqual(subNode,
"docs"))
700 server.
version.first = font->getWidth(version);
706 for (
unsigned int i = 0, fsz =
CAST_U32(
735 if (!found && addNew)
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);
765 persistentIpKey, 0) != 0 ? true :
false;
795 if (*i == currentServer)
805 int savedServerCount = 0;
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);
840 if (savedServerCount < MAX_SERVERLIST)
847 const size_t remaining)
853 bool finished =
false;
864 logger->
log(
"Error retreiving server list: %s\n",
870 float progress =
static_cast<float>(remaining);
872 progress /=
static_cast<float>(total);
874 if (progress != progress || progress < 0.0F)
876 else if (progress > 1.0F)
const bool UseVirtFs_false
std::string defaultHostName
#define FOR_EACH(type, iter, array)
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
std::string getStringValue(const std::string &key) const
ServerDialogDownloadStatusT mDownloadStatus
void setSelected(const int selected)
void log1(const char *const log_text)
void setVersionString(const int index, const std::string &version)
void addMirror(const std::string &str)
bool getOptionBool(const std::string &name, const bool def) const
void setState(const StateT state)
static std::string serverTypeToString(const ServerTypeT type)
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
MouseButtonT getButton() const
std::string pathJoin(std::string str1, const std::string &str2)
void reflow(int &nW, int &nH)
void setMinWidth(const int width)
void addSelectionListener(SelectionListener *const selectionListener)
#define BLOCK_START(name)
bool checkPath(const std::string &path)
int getProperty(const xmlNodePtr node, const char *const name, int def)
static ServerTypeT parseType(const std::string &serverType)
InputActionT getActionId() const
int getIntValue(const std::string &key) const
static void loadServerSourcesList(const xmlNodePtr node, std::vector< ServerUrlInfo > &list)
void action(const ActionEvent &event)
std::vector< std::string > updateMirrors
ServerDialog(ServerInfo *const serverInfo, const std::string &dir)
int compareStrI(const std::string &a, const std::string &b)
void setFile(const std::string &filename, const int64_t adler32)
void downloadServerList()
void setContentSize(int width, int height)
bool getBoolValue(const std::string &key) const
std::vector< ServerInfo > ServerInfos
void keyPressed(KeyEvent &event)
std::string strprintf(const char *const format,...)
void setCaption(const std::string &caption)
CheckBox * mPersistentIPCheckBox
const char * getError() const
std::string onlineListUrl
#define fromBool(val, name)
std::vector< ServerUrlInfo > freeSources
std::vector< ServerUrlInfo > docs
std::string getDateString()
ServerInfoWindow * serverInfoWindow
std::vector< HostsGroup > updateHosts
static const int MAX_SERVERLIST
std::vector< std::string > updateMirrors
void setCloseButton(const bool flag)
static std::string savedPassword
DownloadStatus ::T DownloadStatusT
ServerType ::T ServerTypeT
ServersListModel * mServersListModel
static void loadHostsGroup(const xmlNodePtr node, ServerInfo &server)
void valueChanged(const SelectionEvent &event)
void setMinHeight(const int height)
LayoutCell & setPadding(int p)
virtual void scheduleDelete()
static int downloadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
std::string toString(T const &value)
converts any type to a string
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
std::string getValue(const std::string &key, const std::string &deflt) const
void saveCustomServers(const ServerInfo ¤tServer, const int index)
virtual void setVisible(Visible visible)
void loadServers(const bool addNew)
Button * mEditEntryButton
#define for_each_xml_child_node(var, parent)
Net::Download * mDownload
std::string getLangShort()
void connectToSelectedServer()
void setResizable(const bool resize)
bool needUpdateServers() const
static uint16_t defaultPortForServerType(const ServerTypeT type)
void updateServer(const ServerInfo &server, const int index)
void setServerName(const std::string &serverName)
int getClickCount() const
void log(const char *const log_text,...)
const bool SkipError_true
void keyPressed(KeyEvent &event)
void setCaption(const std::string &caption)
void setRowHeight(const int n, const int h)
void setValue(const std::string &key, const std::string &value)
bool url(InputEvent &event)
static ServerFreeTypeT parseFreeType(const std::string &serverFreeType)
static std::string savedPasswordKey
void setWindowName(const std::string &name)