Merge with develop

This commit is contained in:
kervala 2016-02-13 23:43:04 +01:00
commit 24081ab894
12 changed files with 83 additions and 126 deletions

View file

@ -118,6 +118,7 @@ public:
/// Returns program name or path passed as first parameter to parse() method /// Returns program name or path passed as first parameter to parse() method
std::string getProgramName() const { return _ProgramName; } std::string getProgramName() const { return _ProgramName; }
std::string getProgramPath() const { return _ProgramPath; } std::string getProgramPath() const { return _ProgramPath; }
std::string getStartupPath() const { return _StartupPath; }
/// Set or get description to display in help /// Set or get description to display in help
void setDescription(const std::string &description) { _Description = description; } void setDescription(const std::string &description) { _Description = description; }
@ -129,6 +130,7 @@ public:
protected: protected:
std::string _ProgramName; // filename of the program std::string _ProgramName; // filename of the program
std::string _ProgramPath; // full path of the program std::string _ProgramPath; // full path of the program
std::string _StartupPath; // initial startup path
std::string _Description; // description of the program std::string _Description; // description of the program
std::string _Version; // version of the program std::string _Version; // version of the program

View file

@ -264,6 +264,9 @@ bool CCmdArgs::parse(const std::vector<std::string> &argv)
_ProgramName = CFile::getFilename(argv.front()); _ProgramName = CFile::getFilename(argv.front());
_ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true); _ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true);
// current path
_StartupPath = CPath::standardizePath(CPath::getCurrentPath());
// set process name for logs // set process name for logs
CLog::setProcessName(_ProgramName); CLog::setProcessName(_ProgramName);

View file

@ -765,7 +765,12 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
CloseHandle( pi.hThread ); CloseHandle( pi.hThread );
} }
#elif defined(NL_OS_MAC) #else
#ifdef NL_OS_MAC
// special OS X case with bundles
if (toLower(programName).find(".app") != std::string::npos)
{
// we need to open bundles with "open" command // we need to open bundles with "open" command
std::string command = NLMISC::toString("open \"%s\"", programName.c_str()); std::string command = NLMISC::toString("open \"%s\"", programName.c_str());
@ -783,7 +788,10 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
{ {
nlwarning ("LAUNCH: Failed launched '%s' with arg '%s' return code %d", programName.c_str(), arguments.c_str(), res); nlwarning ("LAUNCH: Failed launched '%s' with arg '%s' return code %d", programName.c_str(), arguments.c_str(), res);
} }
#else
return false;
}
#endif
static bool firstLaunchProgram = true; static bool firstLaunchProgram = true;
if (firstLaunchProgram) if (firstLaunchProgram)
@ -1025,6 +1033,7 @@ std::string expandEnvironmentVariables(const std::string &s)
{ {
// value not found // value not found
found = false; found = false;
nlwarning("Environment variable '%s' not found, won't be replaced", name.c_str());
} }
} }

View file

@ -1789,18 +1789,18 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
if (appPath.empty()) if (appPath.empty())
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
wchar_t buffer[MAX_PATH]; char buffer[MAX_PATH];
#ifdef CSIDL_LOCAL_APPDATA #ifdef CSIDL_LOCAL_APPDATA
if (local) if (local)
{ {
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE); SHGetSpecialFolderPathA(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE);
} }
else else
#endif #endif
{ {
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, TRUE);
} }
appPath = CPath::standardizePath(ucstring((ucchar*)buffer).toUtf8()); appPath = CPath::standardizePath(buffer);
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
appPath = CPath::standardizePath(getenv("HOME")); appPath = CPath::standardizePath(getenv("HOME"));
appPath += "/Library/Application Support/"; appPath += "/Library/Application Support/";

View file

@ -303,7 +303,7 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t
fontsize="12" shadow="true" hardtext="uiOnChecking" /> fontsize="12" shadow="true" hardtext="uiOnChecking" />
<view type="text" id="state" posparent="check_win" posref="TL TL" w="584" x="8" y="-8" line_maxw="584" color="135 243 28 255" <view type="text" id="state" posparent="check_win" posref="TL TL" w="584" x="8" y="-8" line_maxw="584" color="135 243 28 255"
fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_first_sentence_letter_up"/> fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_normal"/>
<view type="text" id="progress" posref="BL TL" posparent="state" fontsize="12" y="-8" color="135 243 28 255" line_maxw="584" <view type="text" id="progress" posref="BL TL" posparent="state" fontsize="12" y="-8" color="135 243 28 255" line_maxw="584"
shadow="true" multi_line="true" multi_line_space="0" /> shadow="true" multi_line="true" multi_line_space="0" />
@ -419,7 +419,7 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t
<view type="text" id="progress" posref="TL TL" posparent="patch_win" fontsize="12" x="8" y="-8" color="135 243 28 255" shadow="true"/> <view type="text" id="progress" posref="TL TL" posparent="patch_win" fontsize="12" x="8" y="-8" color="135 243 28 255" shadow="true"/>
<view type="text" id="state" posparent="progress" posref="TR TL" w="520" x="4" y="0" line_maxw="520" color="135 243 28 255" <view type="text" id="state" posparent="progress" posref="TR TL" w="520" x="4" y="0" line_maxw="520" color="135 243 28 255"
fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_first_sentence_letter_up"/> fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_normal"/>
<link expr="eq(@UI:VARIABLES:SCREEN,4)" target="progress:active,state:active"/> <link expr="eq(@UI:VARIABLES:SCREEN,4)" target="progress:active,state:active"/>
<!-- Reboot --> <!-- Reboot -->
@ -572,7 +572,7 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t
<!-- check state --> <!-- check state -->
<instance template="server_box" id="check_win" posparent="placeholder" posref="TM TM" sizeref="w" h="88" x="0" y="0" /> <instance template="server_box" id="check_win" posparent="placeholder" posref="TM TM" sizeref="w" h="88" x="0" y="0" />
<view type="text" id="state" posparent="check_win" posref="TL TL" w="584" x="8" y="-8" line_maxw="584" color="135 243 28 255" <view type="text" id="state" posparent="check_win" posref="TL TL" w="584" x="8" y="-8" line_maxw="584" color="135 243 28 255"
fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_first_sentence_letter_up"/> fontsize="12" shadow="true" multi_line="true" multi_line_space="0" case_mode="%case_normal"/>
<view type="text" id="progress" posref="BL TL" posparent="state" fontsize="12" y="-8" color="135 243 28 255" line_maxw="584" <view type="text" id="progress" posref="BL TL" posparent="state" fontsize="12" y="-8" color="135 243 28 255" line_maxw="584"
shadow="true" multi_line="true" multi_line_space="0" /> shadow="true" multi_line="true" multi_line_space="0" />

View file

@ -160,8 +160,6 @@ IF(WITH_RYZOM_CLIENT)
${CURL_LIBRARIES} ${CURL_LIBRARIES}
) )
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
IF(NOT APPLE AND NOT WIN32) IF(NOT APPLE AND NOT WIN32)
TARGET_LINK_LIBRARIES(ryzom_client ${X11_LIBRARIES}) TARGET_LINK_LIBRARIES(ryzom_client ${X11_LIBRARIES})
ENDIF() ENDIF()

View file

@ -205,7 +205,7 @@ int main(int argc, char **argv)
LoginShardId = std::numeric_limits<uint32>::max(); LoginShardId = std::numeric_limits<uint32>::max();
// if client_default.cfg is not in current directory, use application default directory // if client_default.cfg is not in current directory, use application default directory
if (!CFile::isExists("client_default.cfg")) if (Args.haveArg("c") || !CFile::isExists("client_default.cfg"))
{ {
std::string currentPath = CPath::getApplicationDirectory("Ryzom"); std::string currentPath = CPath::getApplicationDirectory("Ryzom");

View file

@ -25,6 +25,7 @@
#include "nel/misc/config_file.h" #include "nel/misc/config_file.h"
#include "nel/misc/bit_mem_stream.h" #include "nel/misc/bit_mem_stream.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/cmd_args.h"
// Client. // Client.
#include "client_cfg.h" #include "client_cfg.h"
#include "entities.h" #include "entities.h"
@ -256,6 +257,8 @@ extern string Cookie;
extern string FSAddr; extern string FSAddr;
#endif #endif
extern NLMISC::CCmdArgs Args;
///////////// /////////////
// METHODS // // METHODS //
///////////// /////////////
@ -2202,19 +2205,21 @@ bool CClientConfig::getDefaultConfigLocation(std::string& p_name) const
#ifdef NL_OS_MAC #ifdef NL_OS_MAC
// on mac, client_default.cfg should be searched in .app/Contents/Resources/ // on mac, client_default.cfg should be searched in .app/Contents/Resources/
defaultConfigPath = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources/"); defaultConfigPath = getAppBundlePath() + "/Contents/Resources/";
#elif defined(NL_OS_UNIX)
// if RYZOM_ETC_PREFIX is defined, client_default.cfg might be over there
defaultConfigPath = CPath::standardizePath(getRyzomEtcPrefix());
#else #else
// some other prefix here :) // unders Windows or Linux, search client_default.cfg is same directory as executable
#endif // NL_OS_UNIX defaultConfigPath = Args.getProgramPath();
#endif
// look in the current working directory first // look in the current working directory first
if (CFile::isExists(defaultConfigFileName)) if (CFile::isExists(defaultConfigFileName))
p_name = defaultConfigFileName; p_name = defaultConfigFileName;
// if not in working directory, check using prefix path // look in startup directory
else if (CFile::isExists(Args.getStartupPath() + defaultConfigFileName))
p_name = Args.getStartupPath() + defaultConfigFileName;
// look in prefix path
else if (CFile::isExists(defaultConfigPath + defaultConfigFileName)) else if (CFile::isExists(defaultConfigPath + defaultConfigFileName))
p_name = defaultConfigPath + defaultConfigFileName; p_name = defaultConfigPath + defaultConfigFileName;

View file

@ -661,6 +661,9 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
// current directory has priority everywhere // current directory has priority everywhere
directoryPrefixes.push_back(CPath::standardizePath(CPath::getCurrentPath())); directoryPrefixes.push_back(CPath::standardizePath(CPath::getCurrentPath()));
// startup directory
directoryPrefixes.push_back(Args.getStartupPath());
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
// check in same directory as executable // check in same directory as executable
directoryPrefixes.push_back(Args.getProgramPath()); directoryPrefixes.push_back(Args.getProgramPath());

View file

@ -311,8 +311,7 @@ class CAHMilkoMenuDoResetInterface : public IActionHandler
virtual void execute (CCtrlBase * /* pCaller */, const string& Params) virtual void execute (CCtrlBase * /* pCaller */, const string& Params)
{ {
// get param // get param
string mode; string mode = getParam(Params, "mode");
fromString(getParam(Params, "mode"), mode);
// run procedure // run procedure
vector<string> v; vector<string> v;

View file

@ -2192,7 +2192,6 @@ void initDataScan()
pPM->startScanDataThread(); pPM->startScanDataThread();
NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_DATASCAN); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_DATASCAN);
NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(1); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(1);
} }
// *************************************************************************** // ***************************************************************************

View file

@ -892,6 +892,13 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
fprintf(fp, "start \"\" \"%s\" %%1 %%2 %%3\n", CPath::standardizeDosPath(RyzomFilename).c_str()); fprintf(fp, "start \"\" \"%s\" %%1 %%2 %%3\n", CPath::standardizeDosPath(RyzomFilename).c_str());
#else #else
// wait until client is not in memory
fprintf(fp, "until ! pgrep %s > /dev/null; do sleep 1; done\n", CFile::getFilename(RyzomFilename).c_str());
// be sure file is executable
fprintf(fp, "chmod +x \"%s\"\n", RyzomFilename.c_str());
// launch new client
fprintf(fp, "\"%s\" $1 $2 $3\n", RyzomFilename.c_str()); fprintf(fp, "\"%s\" $1 $2 $3\n", RyzomFilename.c_str());
#endif #endif
} }
@ -945,11 +952,7 @@ void CPatchManager::executeBatchFile()
arguments += " " + toString(LoginShardId); arguments += " " + toString(LoginShardId);
} }
if (launchProgram(batchFilename, arguments, false)) if (!launchProgram(batchFilename, arguments, false))
{
exit(0);
}
else
{ {
// error occurs during the launch // error occurs during the launch
string str = toString("Can't execute '%s': code=%d %s (error code 30)", batchFilename.c_str(), errno, strerror(errno)); string str = toString("Can't execute '%s': code=%d %s (error code 30)", batchFilename.c_str(), errno, strerror(errno));
@ -1015,12 +1018,12 @@ float CPatchManager::getCurrentFileProgress() const
// **************************************************************************** // ****************************************************************************
void CPatchManager::setRWAccess (const string &filename, bool bThrowException) void CPatchManager::setRWAccess (const string &filename, bool bThrowException)
{ {
ucstring s = CI18N::get("uiSetAttrib") + " " + filename; ucstring s = CI18N::get("uiSetAttrib") + " " + CFile::getFilename(filename);
setState(true, s); setState(true, s);
if (!NLMISC::CFile::setRWAccess(filename) && bThrowException) if (!NLMISC::CFile::setRWAccess(filename) && bThrowException)
{ {
s = CI18N::get("uiAttribErr") + " " + filename + " (" + toString(errno) + "," + strerror(errno) + ")"; s = CI18N::get("uiAttribErr") + " " + CFile::getFilename(filename) + " (" + toString(errno) + "," + strerror(errno) + ")";
setState(true, s); setState(true, s);
throw Exception (s.toString()); throw Exception (s.toString());
} }
@ -1029,7 +1032,7 @@ void CPatchManager::setRWAccess (const string &filename, bool bThrowException)
// **************************************************************************** // ****************************************************************************
string CPatchManager::deleteFile (const string &filename, bool bThrowException, bool bWarning) string CPatchManager::deleteFile (const string &filename, bool bThrowException, bool bWarning)
{ {
ucstring s = CI18N::get("uiDelFile") + " " + filename; ucstring s = CI18N::get("uiDelFile") + " " + CFile::getFilename(filename);
setState(true, s); setState(true, s);
if (!NLMISC::CFile::fileExists(filename)) if (!NLMISC::CFile::fileExists(filename))
@ -1041,7 +1044,7 @@ string CPatchManager::deleteFile (const string &filename, bool bThrowException,
if (!NLMISC::CFile::deleteFile(filename)) if (!NLMISC::CFile::deleteFile(filename))
{ {
s = CI18N::get("uiDelErr") + " " + filename + " (" + toString(errno) + "," + strerror(errno) + ")"; s = CI18N::get("uiDelErr") + " " + CFile::getFilename(filename) + " (" + toString(errno) + "," + strerror(errno) + ")";
if(bWarning) if(bWarning)
setState(true, s); setState(true, s);
if(bThrowException) if(bThrowException)
@ -1269,7 +1272,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
try try
{ {
#ifdef USE_CURL #ifdef USE_CURL
ucstring s = CI18N::get("uiDLWithCurl") + " " + dest; ucstring s = CI18N::get("uiDLWithCurl") + " " + CFile::getFilename(dest);
setState(true, s); setState(true, s);
// user agent = nel_launcher // user agent = nel_launcher
@ -1776,10 +1779,19 @@ int CPatchManager::downloadProgressFunc(void *foo, double t, double d, double ul
// **************************************************************************** // ****************************************************************************
int CPatchManager::validateProgress(void *foo, double t, double d, double /* ultotal */, double /* ulnow */) int CPatchManager::validateProgress(void *foo, double t, double d, double /* ultotal */, double /* ulnow */)
{ {
static std::vector<std::string> units;
if (units.empty())
{
units.push_back("B"); // there is no translation for byte unit...
units.push_back(CI18N::get("uiKb").toUtf8());
units.push_back(CI18N::get("uiMb").toUtf8());
}
CPatchManager *pPM = CPatchManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance();
double pour1 = t!=0.0?d*100.0/t:0.0; double pour1 = t!=0.0?d*100.0/t:0.0;
ucstring sTranslate = CI18N::get("uiLoginGetFile") + toString(" %s : %s / %s (%5.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(), ucstring sTranslate = CI18N::get("uiLoginGetFile") + ucstring::makeFromUtf8(toString(" %s : %s / %s (%5.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(),
NLMISC::bytesToHumanReadable((uint64)d).c_str(), NLMISC::bytesToHumanReadable((uint64)t).c_str(), pour1); NLMISC::bytesToHumanReadableUnits((uint64)d, units).c_str(), NLMISC::bytesToHumanReadableUnits((uint64)t, units).c_str(), pour1));
pPM->setState(false, sTranslate); pPM->setState(false, sTranslate);
if (foo) if (foo)
{ {
@ -2791,49 +2803,8 @@ void CPatchThread::xDeltaPatch(const string &patch, const string &src, const str
// Launching xdelta // Launching xdelta
/* /*
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process. // Start the child process.
string strCmdLine = "xdelta patch " + patch + " " + src + " " + out; string strCmdLine = "xdelta patch " + patch + " " + src + " " + out;
if( !CreateProcess( NULL, // No module name (use command line).
(char*)strCmdLine.c_str(), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
// error occurs during the launch
string str = toString("Can't execute '%s'", strCmdLine.c_str());
throw Exception (str);
}
// Wait for the process to terminate
DWORD dwTimeout = 1000 * 300; // 5 min = 300 s
DWORD nRetWait = WaitForSingleObject(pi.hProcess, dwTimeout);
if (nRetWait == WAIT_TIMEOUT)
{
string str = toString("Time Out After %d s", dwTimeout/1000);
throw Exception (str);
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
*/ */
} }
@ -3170,44 +3141,13 @@ bool CPatchManager::extract(const std::string& patchPath,
stopFun(); stopFun();
} }
#ifdef NL_OS_WINDOWS if (!launchProgram(updateBatchFilename, "", false))
// normal quit
// Launch the batch file
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE; // SW_SHOW
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
string strCmdLine;
strCmdLine = updateBatchFilename;
//onFileInstallFinished();
if( !CreateProcess( NULL, // No module name (use command line).
(LPSTR)strCmdLine.c_str(), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{ {
// error occurs during the launch // error occurs during the launch
string str = toString("Can't execute '%s': code=%d %s (error code 30)", updateBatchFilename.c_str(), errno, strerror(errno)); string str = toString("Can't execute '%s': code=%d %s (error code 30)", updateBatchFilename.c_str(), errno, strerror(errno));
throw Exception (str); throw Exception (str);
} }
#else
// TODO for Linux and Mac OS
#endif
return true; return true;
} }
@ -3497,4 +3437,3 @@ void CInstallThread::run()
pPM->reboot(); // do not reboot just run the extract .bat pPM->reboot(); // do not reboot just run the extract .bat
} }