mirror of https://github.com/procxx/kepka.git
Allow any version to be used as a portable.
You need to place TelegramForcePortable folder near the application.
This commit is contained in:
parent
25cefc6eab
commit
36f72191ad
|
@ -399,25 +399,26 @@ bool CheckAlphaVersionDir() {
|
||||||
if (!MoveLegacyAlphaFolder()) {
|
if (!MoveLegacyAlphaFolder()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QFile alpha(cExeDir() + qsl("TelegramAlpha_data/tdata/alpha"));
|
QFile key(cExeDir() + qsl("TelegramAlpha_data/tdata/alpha"));
|
||||||
if (cAlphaVersion()) {
|
if (cAlphaVersion()) {
|
||||||
cForceWorkingDir(cExeDir() + qsl("TelegramAlpha_data/"));
|
cForceWorkingDir(cExeDir() + qsl("TelegramAlpha_data/"));
|
||||||
QDir().mkpath(cWorkingDir() + qstr("tdata"));
|
QDir().mkpath(cWorkingDir() + qstr("tdata"));
|
||||||
if (*AlphaPrivateKey) {
|
if (*AlphaPrivateKey) {
|
||||||
cSetAlphaPrivateKey(QByteArray(AlphaPrivateKey));
|
cSetAlphaPrivateKey(QByteArray(AlphaPrivateKey));
|
||||||
}
|
}
|
||||||
if (alpha.open(QIODevice::WriteOnly)) {
|
if (key.open(QIODevice::WriteOnly)) {
|
||||||
QDataStream dataStream(&alpha);
|
QDataStream dataStream(&key);
|
||||||
dataStream.setVersion(QDataStream::Qt_5_3);
|
dataStream.setVersion(QDataStream::Qt_5_3);
|
||||||
dataStream << quint64(cRealAlphaVersion()) << cAlphaPrivateKey();
|
dataStream << quint64(cRealAlphaVersion()) << cAlphaPrivateKey();
|
||||||
} else {
|
} else {
|
||||||
LOG(("FATAL: Could not open '%1' for writing private key!").arg(alpha.fileName()));
|
LOG(("FATAL: Could not open '%1' for writing private key!"
|
||||||
|
).arg(key.fileName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (alpha.exists()) {
|
} else if (key.exists()) {
|
||||||
cForceWorkingDir(cExeDir() + qsl("TelegramAlpha_data/"));
|
cForceWorkingDir(cExeDir() + qsl("TelegramAlpha_data/"));
|
||||||
if (alpha.open(QIODevice::ReadOnly)) {
|
if (key.open(QIODevice::ReadOnly)) {
|
||||||
QDataStream dataStream(&alpha);
|
QDataStream dataStream(&key);
|
||||||
dataStream.setVersion(QDataStream::Qt_5_3);
|
dataStream.setVersion(QDataStream::Qt_5_3);
|
||||||
|
|
||||||
quint64 v;
|
quint64 v;
|
||||||
|
@ -428,17 +429,27 @@ bool CheckAlphaVersionDir() {
|
||||||
cSetAlphaPrivateKey(k);
|
cSetAlphaPrivateKey(k);
|
||||||
cSetRealAlphaVersion(v);
|
cSetRealAlphaVersion(v);
|
||||||
} else {
|
} else {
|
||||||
LOG(("FATAL: '%1' is corrupted, reinstall private alpha!").arg(alpha.fileName()));
|
LOG(("FATAL: '%1' is corrupted, reinstall private alpha!").arg(key.fileName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG(("FATAL: could not open '%1' for reading private key!").arg(alpha.fileName()));
|
LOG(("FATAL: could not open '%1' for reading private key!").arg(key.fileName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckPortableVersionDir() {
|
||||||
|
if (CheckAlphaVersionDir()) {
|
||||||
|
return true;
|
||||||
|
} else if (QDir(cExeDir() + qsl("TelegramForcePortable")).exists()) {
|
||||||
|
cForceWorkingDir(cExeDir() + qsl("TelegramForcePortable/"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString InstallBetaVersionsSettingPath() {
|
QString InstallBetaVersionsSettingPath() {
|
||||||
return cWorkingDir() + qsl("tdata/devversion");
|
return cWorkingDir() + qsl("tdata/devversion");
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ inline bool IsTopCorner(ScreenCorner corner) {
|
||||||
|
|
||||||
namespace Sandbox {
|
namespace Sandbox {
|
||||||
|
|
||||||
bool CheckAlphaVersionDir();
|
bool CheckPortableVersionDir();
|
||||||
void WorkingDirReady();
|
void WorkingDirReady();
|
||||||
void WriteInstallBetaVersionsSetting();
|
void WriteInstallBetaVersionsSetting();
|
||||||
void WriteDebugModeSetting();
|
void WriteDebugModeSetting();
|
||||||
|
|
|
@ -322,7 +322,7 @@ bool DebugEnabled() {
|
||||||
void start(not_null<Core::Launcher*> launcher) {
|
void start(not_null<Core::Launcher*> launcher) {
|
||||||
Assert(LogsData == 0);
|
Assert(LogsData == 0);
|
||||||
|
|
||||||
if (!Sandbox::CheckAlphaVersionDir()) {
|
if (!Sandbox::CheckPortableVersionDir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue