98 const std::string &dir) :
111 mConnectButton(
new Button(this,
_(
"Connect"),
"connect",
116 mEditEntryButton(
new Button(this,
_(
"Edit"),
"editEntry",
127 mServerInfo(serverInfo),
128 mPersistentIPCheckBox(
nullptr),
129 mDownloadProgress(-1.0F),
135 setCaption(
_(
"Choose Your Server *** SAFE MODE ***"));
141 setCaption(
_(
"Choose Your Server *** SOFTWARE RENDER MODE ***"));
151 _(
"Use same ip for game sub servers"),
153 this,
"persitent ip");
161 "server_background.xml");
213 logger->
log(
"Skipping servers list update");
291 const std::string &eventId =
event.getId();
292 if (eventId ==
"connect")
296 else if (eventId ==
"quit")
300 else if (eventId ==
"load")
304 else if (eventId ==
"addEntry")
308 else if (eventId ==
"editEntry")
319 else if (eventId ==
"remove")
330 else if (eventId ==
"info")
346 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
454 logger->
log(
"Error: servers list updating error");
470 if (listFile.empty())
471 listFile =
"http://manaplus.org/serverlist.xml";
484 if (!listFile2.empty())
501 if (!xmlNameEqual(hostNode,
"host") ||
502 !XmlHaveChildContent(hostNode))
506 const std::string host = XmlChildContent(hostNode);
511 logger->
log1(
"Warning: incorrect update server name");
515 group.
hosts.push_back(host);
517 if (!group.
hosts.empty())
522 STD_VECTOR<ServerUrlInfo> &list)
526 if (!xmlNameEqual(urlNode,
"url") ||
527 !XmlHaveChildContent(urlNode))
536 const std::string
url = XmlChildContent(urlNode);
548 if (xmlNameEqual(subNode,
"free"))
552 else if (xmlNameEqual(subNode,
"nonfree"))
565 XmlNodeConstPtr rootNode = doc.
rootNode();
567 if (rootNode ==
nullptr ||
568 !xmlNameEqual(rootNode,
"serverlist"))
577 logger->
log(
"Error: unsupported online server list version: %d",
583 const std::string description2(
"description_" + lang);
587 if (!xmlNameEqual(serverNode,
"server"))
591 serverNode,
"type",
"unknown");
595 serverNode,
"licenseType",
"notset");
601 logger->
log(
"Ignoring server entry with unknown type: %s",
614 if (meetsMinimumVersion)
616 else if (version.empty())
619 version =
_(
"requires a newer version");
624 version =
strprintf(
_(
"requires v%s"), version.c_str());
631 if (xmlNameEqual(subNode,
"connection"))
635 subNode,
"althostname",
"");
641 if (server.
port == 0)
647 else if (XmlHaveChildContent(subNode))
649 if ((xmlNameEqual(subNode,
"description")
651 && xmlNameEqual(subNode, description2.c_str())))
655 else if (xmlNameEqual(subNode,
"registerurl"))
659 else if (xmlNameEqual(subNode,
"onlineListUrl"))
663 else if (xmlNameEqual(subNode,
"support"))
667 else if (xmlNameEqual(subNode,
"persistentIp"))
669 std::string text = XmlChildContent(subNode);
672 else if (xmlNameEqual(subNode,
"updateMirror"))
676 else if (xmlNameEqual(subNode,
"site"))
678 server.
serverUrl = XmlChildContent(subNode);
681 if (xmlNameEqual(subNode,
"updates"))
685 else if (xmlNameEqual(subNode,
"defaultUpdateHost"))
689 subNode,
"name",
_(
"default"));
691 else if (xmlNameEqual(subNode,
"sources"))
695 else if (xmlNameEqual(subNode,
"docs"))
702 server.
version.second = version;
707 for (
unsigned int i = 0, fsz =
CAST_U32(
736 if (!found && addNew)
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);
766 persistentIpKey, 0) != 0 ? true :
false;
796 if (*i == currentServer)
806 int savedServerCount = 0;
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);
848 const size_t remaining)
854 bool finished =
false;
865 logger->
log(
"Error retreiving server list: %s\n",
871 float progress =
static_cast<float>(remaining);
873 progress /=
static_cast<float>(total);
875 if (progress != progress || progress < 0.0F)
877 else if (progress > 1.0F)
#define fromBool(val, name)
void setServerName(const std::string &serverName)
void setState(const StateT state)
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
Widget * getSource() const
int getWidth(const std::string &text) const
InputActionT getActionId() const
void setCaption(const std::string &caption)
LayoutCell & setPadding(int p)
void setRowHeight(const int n, const int h)
void reflow(int &nW, int &nH)
void keyPressed(KeyEvent &event)
void setSelected(const int selected)
void addSelectionListener(SelectionListener *const selectionListener)
void log(const char *const log_text,...)
void log1(const char *const log_text)
static std::string savedPasswordKey
static std::string savedPassword
MouseButtonT getButton() const
int getClickCount() const
void setFile(const std::string &filename, const int64_t adler32)
void addMirror(const std::string &str)
const char * getError() const
Net::Download * mDownload
void valueChanged(const SelectionEvent &event)
ServerDialogDownloadStatusT mDownloadStatus
void saveCustomServers(const ServerInfo ¤tServer, const int index)
CheckBox * mPersistentIPCheckBox
bool needUpdateServers() const
Button * mEditEntryButton
ServerDialog(ServerInfo *const serverInfo, const std::string &dir)
void updateServer(const ServerInfo &server, const int index)
void downloadServerList()
static int downloadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
void action(const ActionEvent &event)
void loadServers(const bool addNew)
void mouseClicked(MouseEvent &event)
void connectToSelectedServer()
void keyPressed(KeyEvent &event)
ServersListModel * mServersListModel
std::vector< std::string > updateMirrors
std::vector< ServerUrlInfo > nonFreeSources
std::vector< HostsGroup > updateHosts
static ServerFreeTypeT parseFreeType(const std::string &serverFreeType)
std::vector< ServerUrlInfo > docs
std::string onlineListUrl
static ServerTypeT parseType(const std::string &serverType)
std::string defaultHostName
std::vector< ServerUrlInfo > freeSources
void setVersionString(const int index, const std::string &version)
std::vector< std::string > updateMirrors
void setResizable(const bool resize)
virtual void setVisible(Visible visible)
bool getOptionBool(const std::string &name, const bool def) const
void setContentSize(int width, int height)
void setWindowName(const std::string &name)
void setCaption(const std::string &caption)
void setMinHeight(const int height)
void setMinWidth(const int width)
void setCloseButton(const bool flag)
virtual void scheduleDelete()
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
DownloadStatus ::T DownloadStatusT
#define FOR_EACH(type, iter, array)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
std::string getLangShort()
#define for_each_xml_child_node(var, parent)
bool url(InputEvent &event)
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)
int getProperty(const xmlNodePtr node, const char *const name, int def)
bool checkPath(const std::string &path)
#define BLOCK_START(name)
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
ServerInfoWindow * serverInfoWindow
ServerType ::T ServerTypeT
const bool SkipError_true
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()
const bool UseVirtFs_false