mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
[Option][Non-stored] Custom API ID and hash
This commit is contained in:
committed by
Eric Kotato
parent
826a0b935e
commit
f09d824616
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "core/crash_reports.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "kotato/kotato_version.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
@@ -317,7 +318,7 @@ QString PlatformString() {
|
||||
void StartCatching() {
|
||||
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
||||
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
|
||||
ProcessAnnotations["ApiId"] = QString::number(ApiId).toUtf8().constData();
|
||||
ProcessAnnotations["ApiId"] = QString::number(::Kotato::JsonSettings::GetInt("api_id")).toUtf8().constData();
|
||||
ProcessAnnotations["Version"] = (cAlphaVersion()
|
||||
? u"%1 %2"_q.arg(cAlphaVersion()).arg(AppKotatoTestBranch)
|
||||
: (AppBetaVersion
|
||||
|
@@ -27,6 +27,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace Core {
|
||||
namespace {
|
||||
|
||||
constexpr auto kApiIdVarName = "KTGDESKTOP_API_ID"_cs;
|
||||
constexpr auto kApiHashVarName = "KTGDESKTOP_API_HASH"_cs;
|
||||
|
||||
uint64 InstallationTag = 0;
|
||||
|
||||
base::options::toggle OptionFreeType({
|
||||
@@ -395,6 +398,15 @@ int Launcher::exec() {
|
||||
|
||||
// Must be started before Sandbox is created.
|
||||
Platform::start();
|
||||
|
||||
if (::Kotato::JsonSettings::GetBool("api_use_env")
|
||||
&& qEnvironmentVariableIsSet(kApiIdVarName.utf8().constData())
|
||||
&& qEnvironmentVariableIsSet(kApiHashVarName.utf8().constData())) {
|
||||
::Kotato::JsonSettings::Set("api_id", qgetenv(kApiIdVarName.utf8().constData()).toInt());
|
||||
::Kotato::JsonSettings::Set("api_hash", QString::fromLatin1(qgetenv(kApiHashVarName.utf8().constData())));
|
||||
::Kotato::JsonSettings::Set("api_start_params", false);
|
||||
}
|
||||
|
||||
auto result = executeApplication();
|
||||
|
||||
DEBUG_LOG(("Kotatogram finished, result: %1").arg(result));
|
||||
@@ -529,6 +541,9 @@ void Launcher::processArguments() {
|
||||
{ "-workdir" , KeyFormat::OneValue },
|
||||
{ "--" , KeyFormat::OneValue },
|
||||
{ "-scale" , KeyFormat::OneValue },
|
||||
{ "-no-env-api" , KeyFormat::NoValues },
|
||||
{ "-api-id" , KeyFormat::OneValue },
|
||||
{ "-api-hash" , KeyFormat::OneValue },
|
||||
};
|
||||
auto parseResult = QMap<QByteArray, QStringList>();
|
||||
auto parsingKey = QByteArray();
|
||||
@@ -583,6 +598,15 @@ void Launcher::processArguments() {
|
||||
? kScaleAuto
|
||||
: value;
|
||||
}
|
||||
|
||||
::Kotato::JsonSettings::Set("api_use_env", !parseResult.contains("-no-env-api"));
|
||||
auto customApiId = parseResult.value("-api-id", {}).join(QString()).toInt();
|
||||
auto customApiHash = parseResult.value("-api-hash", {}).join(QString());
|
||||
if (customApiId > 0 && !customApiHash.isEmpty()) {
|
||||
::Kotato::JsonSettings::Set("api_id", customApiId);
|
||||
::Kotato::JsonSettings::Set("api_hash", customApiHash);
|
||||
::Kotato::JsonSettings::Set("api_start_params", true);
|
||||
}
|
||||
}
|
||||
|
||||
int Launcher::executeApplication() {
|
||||
|
Reference in New Issue
Block a user