69 (
"http://download.manaplus.org/manaplus/updates/");
71 (
"http://download2.manaplus.org/manaplus/updates/");
73 (
"http://download.evolonline.org/manaplus/updates/");
75 (
"http://download3.manaplus.org/manaplus/updates/");
83 STD_VECTOR<UpdateFile> files;
85 XmlNodeConstPtrConst rootNode = doc.
rootNode();
87 if ((rootNode ==
nullptr) || !xmlNameEqual(rootNode,
"updates"))
95 const bool isMod = xmlNameEqual(fileNode,
"mod");
96 if (!xmlNameEqual(fileNode,
"update") && !isMod)
105 if (!file.
group.empty() && (!isMod || !loadMods))
109 fileNode,
"version",
"");
110 if (!version.empty())
116 fileNode,
"notVersion",
"");
117 if (!notVersion.empty())
128 files.push_back(file);
136 STD_VECTOR<UpdateFile> files;
137 std::ifstream fileHandler;
138 fileHandler.open(
fileName.c_str(), std::ios::in);
140 if (fileHandler.is_open())
142 while (fileHandler.good())
146 fileHandler.getline(name, 256,
' ');
147 fileHandler.getline(hash, 50);
150 thisFile.
name = name;
151 thisFile.
hash = hash;
152 thisFile.
type =
"data";
153 thisFile.
group.clear();
155 thisFile.
desc.clear();
158 files.push_back(thisFile);
171 const std::string &
restrict updatesDir,
172 const bool applyUpdates,
178 mDownloadProgress(0.0F),
180 mUpdatesDir(updatesDir),
181 mUpdatesDirReal(updatesDir),
182 mCurrentFile(
"news.txt"),
193 mLabel(
new Label(this,
_(
"Connecting..."))),
200 "updateprogressbar.xml",
"updateprogressbar_fill.xml")),
208 mUpdateIndexOffset(0),
209 mUpdateType(updateType),
210 mStoreInMemory(true),
211 mDownloadComplete(true),
213 mLoadUpdates(applyUpdates),
236 placer(0, 3,
mLabel, 5, 1);
249 if (mirrors.begin() != mirrors.end())
315 const std::string &eventId =
event.getId();
316 if (eventId ==
"cancel")
328 else if (eventId ==
"play")
383 std::string newsName =
mUpdatesDir +
"/local/help/news.txt";
385 bool firstLine(
true);
389 file.open(newsName.c_str(), std::ios::out);
391 const int maxNews = 50;
392 while (std::getline(ss, line,
'\n'))
398 const size_t i = line.find(
"##9 Latest client version: ##6");
403 file << line << std::endl;
410 file << line << std::endl;
460 line = strtok(
nullptr,
"\n");
464 "##6ManaPlus %s##0", line),
true);
471 const std::string
url =
"androidDownloadUrl";
472 const std::string text =
"androidDownloadUrl";
474 const std::string
url =
"windowsDownloadUrl";
475 const std::string text =
"windowsDownloadUrl";
478 const std::string
url =
"otherDownloadUrl";
479 const std::string text =
"otherDownloadUrl";
536 float progress =
static_cast<float>(dn) /
537 static_cast<float>(dt);
539 if (progress != progress)
564 size_t nmemb,
void *stream)
567 const size_t totalMem =
size * nmemb;
594 for (
int f = 2; f < 8; f ++)
620 FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mirrors)
664 logger->
log(
"Warning this server does not have a"
677 if (!file.
group.empty())
694 if (updateFiles.empty())
696 logger->
log(
"Warning this server does not have a"
703 const std::string fixPath = dir +
"/fix";
704 for (
unsigned int updateIndex = 0,
709 const UpdateFile &file = updateFiles[updateIndex];
710 if (!file.
group.empty())
727 if (updateFiles.empty())
733 const std::string fixPath = dir +
"/fix";
734 for (
unsigned int updateIndex = 0,
741 updateFiles[updateIndex].name);
748 std::string fixPath = dir +
"/fix";
753 for (
unsigned int updateIndex = 0,
758 const UpdateFile &file = updateFiles[updateIndex];
759 if (!file.
group.empty())
761 const std::string name = file.
name;
767 if (stat(
fileName.c_str(), &statbuf) == 0)
778 const std::string fixPath = dir +
"/fix";
779 const STD_VECTOR<UpdateFile> updateFiles =
loadXMLFile(
783 for (
unsigned int updateIndex = 0,
788 std::string name = updateFiles[updateIndex].name;
794 if (stat(file.c_str(), &statbuf) == 0)
801 const std::string &
restrict fixPath,
805 const std::string tmpPath =
pathJoin(path, file);
809 const std::string fixFile =
pathJoin(fixPath, file);
811 if (stat(fixFile.c_str(), &statbuf) == 0)
819 const std::string &
restrict fixPath,
823 const std::string fixFile =
pathJoin(fixPath, file);
825 if (stat(fixFile.c_str(), &statbuf) == 0)
920 logger->
log(
"Warning this server does not have a %s"
921 " file falling back to %s",
951 if (thisFile.
type ==
"music"
958 std::string checksum;
959 checksum = thisFile.
hash;
960 std::stringstream ss(checksum);
1027 std::string checksum;
1028 checksum = thisFile.
hash;
1029 std::stringstream ss(checksum);
1066 logger->
log(
"UpdaterWindow::logic unknown status: "
1074 const unsigned long hash)
1076 FILE *
const file = fopen(filePath.c_str(),
"rb");
1077 if (file ==
nullptr)
1082 return adler == hash;
1104 for (
size_t i = 0, sz = lines.size(); i < sz; ++i)
1110 const STD_VECTOR<UpdateFile> &updateFiles)
1114 std::set<std::string> modsList;
1117 const std::string fixPath = dir +
"/fix";
1118 for (
unsigned int updateIndex = 0,
1119 fsz =
CAST_U32(updateFiles.size());
1123 const UpdateFile &file = updateFiles[updateIndex];
1124 if (file.
group.empty())
1126 const std::set<std::string>::const_iterator
1127 it = modsList.find(file.
group);
1128 if (it != modsList.end())
1137 STD_VECTOR<UpdateFile> updateFiles2 =
loadXMLFile(
1141 for (
unsigned int updateIndex = 0,
1142 fsz =
CAST_U32(updateFiles2.size());
1146 const UpdateFile &file = updateFiles2[updateIndex];
1147 if (file.
group.empty())
1149 std::string name = file.
name;
1152 const std::set<std::string>::const_iterator
1153 it = modsList.find(file.
group);
1154 if (it != modsList.end())
1156 struct stat statbuf;
1159 if (stat(
fileName.c_str(), &statbuf) == 0)
1181 const std::string &name = *it;
1183 if (modIt == mods.end())
1185 const ModInfo *
const mod = (*modIt).second;
1189 if (!localDir.empty())
1206 const std::string &name = *it;
1208 if (modIt == mods.end())
1210 const ModInfo *
const mod = (*modIt).second;
1214 if (!localDir.empty())
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
const std::string & getCaption() const
void setCaption(const std::string &caption)
void setRowHeight(const int n, const int h)
void log(const char *const log_text,...)
void log1(const char *const log_text)
const std::string & getLocalDir() const
void setFile(const std::string &filename, const int64_t adler32)
static unsigned long fadler32(FILE *const file)
static unsigned long adlerBuffer(const char *const buffer, int size)
void addMirror(const std::string &str)
void setWriteFunction(WriteFunction write)
const char * getError() const
void setProgress(const float progress)
void setSmoothProgress(bool smoothProgress)
void setText(const std::string &str)
std::vector< std::string > updateMirrors
void addRow(const std::string &row, const bool atTop)
void setOpaque(Opaque opaque)
void setEnableKeys(const bool n)
void setEnableImages(const bool n)
void setEnableTabs(const bool n)
void setProcessVars(const bool n)
void setLinkHandler(LinkHandler *linkHandler)
unsigned int mUpdateIndex
std::string mUpdateServerPath
void setProgress(const float p)
static void loadLocalUpdates(const std::string &dir)
static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream)
ItemLinkHandler * mItemLinkHandler
std::vector< UpdateFile > mUpdateFiles
static bool validateFile(const std::string &filePath, const unsigned long hash)
static void removeUpdateFile(const std::string &path, const std::string &fixPath, const std::string &filerestrict)
static void loadMods(const std::string &dir, const std::vector< UpdateFile > &updateFiles)
UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, const bool applyUpdates, const UpdateTypeT updateType)
void action(const ActionEvent &event)
static void unloadManaPlusUpdates(const std::string &dir)
static unsigned long getFileHash(const std::string &filePath)
static void loadDirMods(const std::string &dir)
void loadFile(std::string file)
StaticBrowserBox * mBrowserBox
static void unloadUpdates(const std::string &dir)
static void unloadMods(const std::string &dir)
std::vector< UpdateFile > mTempUpdateFiles
std::string mNewLabelCaption
unsigned long mCurrentChecksum
void keyPressed(KeyEvent &event)
ProgressBar * mProgressBar
static int updateProgress(void *ptr, const DownloadStatusT status, size_t dt, const size_t dn)
void setLabel(const std::string &)
UpdateDownloadStatusT mDownloadStatus
static void loadManaPlusUpdates(const std::string &dir)
Net::Download * mDownload
std::string mUpdatesDirReal
unsigned int mUpdateIndexOffset
static void addUpdateFile(const std::string &path, const std::string &fixPath, const std::string &file, const Append append)
void setResizable(const bool resize)
ContainerPlacer getPlacer(const int x, const int y)
virtual void setVisible(Visible visible)
void setWindowName(const std::string &name)
void setMinHeight(const int height)
void setMinWidth(const int width)
virtual void scheduleDelete()
Configuration serverConfig
DownloadStatus ::T DownloadStatusT
#define FOR_EACH(type, iter, array)
#define for_each_xml_child_node(var, parent)
int mkdir_r(const char *const pathname)
Create a directory, making leading components first if necessary.
ModInfos::const_iterator ModInfoCIterator
std::map< std::string, ModInfo * > ModInfos
bool url(InputEvent &event)
std::string trim(std::string const &str)
std::string toString(T const &value)
converts any type to a string
bool loadTextFileLocal(const std::string &fileName, StringVect &lines)
const ModInfos & getAll()
bool mountZip(std::string newDir, const Append append)
bool unmountZip(std::string oldDir)
const char * loadFile(std::string filename, int &fileSize)
bool mountDir(std::string newDir, const Append append)
bool unmountDir(std::string oldDir)
int getProperty(const xmlNodePtr node, const char *const name, int def)
bool checkPath(const std::string &path)
#define BLOCK_START(name)
const bool SkipError_false
std::string & removeProtocol(std::string &url)
std::string strprintf(const char *const format,...)
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
void splitToStringSet(std::set< std::string > &tokens, const std::string &text, const char separator)
std::string pathJoin(std::string str1, const std::string &str2)
std::string urlJoin(std::string str1, const std::string &str2)
bool strStartWith(const std::string &str1, const std::string &str2)
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect
const std::string txtUpdateFile("resources2.txt")
const std::string updateServer5("http://download3.manaplus.org/manaplus/updates/")
UpdaterWindow * updaterWindow
const std::string xmlUpdateFile("resources.xml")
static std::vector< UpdateFile > loadTxtFile(const std::string &fileName)
const std::string updateServer4("http://download.evolonline.org/manaplus/updates/")
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
const std::string updateServer2("http://download.manaplus.org/manaplus/updates/")
const std::string updateServer3("http://download2.manaplus.org/manaplus/updates/")
UpdateType ::T UpdateTypeT
const bool UseVirtFs_false