Automatically detect operating system version.
GitOrigin-RevId: d693799fdbfe4919da5a70c141709f2db93063d7
This commit is contained in:
parent
2172c71191
commit
0877d7f716
@ -291,7 +291,6 @@ class TdExample {
|
|||||||
parameters->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2";
|
parameters->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2";
|
||||||
parameters->system_language_code_ = "en";
|
parameters->system_language_code_ = "en";
|
||||||
parameters->device_model_ = "Desktop";
|
parameters->device_model_ = "Desktop";
|
||||||
parameters->system_version_ = "Unknown";
|
|
||||||
parameters->application_version_ = "1.0";
|
parameters->application_version_ = "1.0";
|
||||||
parameters->enable_storage_optimizer_ = true;
|
parameters->enable_storage_optimizer_ = true;
|
||||||
send_query(td_api::make_object<td_api::setTdlibParameters>(std::move(parameters)),
|
send_query(td_api::make_object<td_api::setTdlibParameters>(std::move(parameters)),
|
||||||
|
@ -80,7 +80,6 @@ namespace TdExample
|
|||||||
parameters.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
parameters.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
||||||
parameters.SystemLanguageCode = "en";
|
parameters.SystemLanguageCode = "en";
|
||||||
parameters.DeviceModel = "Desktop";
|
parameters.DeviceModel = "Desktop";
|
||||||
parameters.SystemVersion = "Unknown";
|
|
||||||
parameters.ApplicationVersion = "1.0";
|
parameters.ApplicationVersion = "1.0";
|
||||||
parameters.EnableStorageOptimizer = true;
|
parameters.EnableStorageOptimizer = true;
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ public final class Example {
|
|||||||
parameters.apiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
parameters.apiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
||||||
parameters.systemLanguageCode = "en";
|
parameters.systemLanguageCode = "en";
|
||||||
parameters.deviceModel = "Desktop";
|
parameters.deviceModel = "Desktop";
|
||||||
parameters.systemVersion = "Unknown";
|
|
||||||
parameters.applicationVersion = "1.0";
|
parameters.applicationVersion = "1.0";
|
||||||
parameters.enableStorageOptimizer = true;
|
parameters.enableStorageOptimizer = true;
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ while True:
|
|||||||
'api_hash': 'a3406de8d171bb422bb6ddf3bbd800e2',
|
'api_hash': 'a3406de8d171bb422bb6ddf3bbd800e2',
|
||||||
'system_language_code': 'en',
|
'system_language_code': 'en',
|
||||||
'device_model': 'Desktop',
|
'device_model': 'Desktop',
|
||||||
'system_version': 'Linux',
|
|
||||||
'application_version': '1.0',
|
'application_version': '1.0',
|
||||||
'enable_storage_optimizer': True}})
|
'enable_storage_optimizer': True}})
|
||||||
|
|
||||||
|
@ -117,7 +117,6 @@ func updateAuthorizationState(authorizationState: Dictionary<String, Any>) {
|
|||||||
"api_hash":"a3406de8d171bb422bb6ddf3bbd800e2",
|
"api_hash":"a3406de8d171bb422bb6ddf3bbd800e2",
|
||||||
"system_language_code":"en",
|
"system_language_code":"en",
|
||||||
"device_model":"Desktop",
|
"device_model":"Desktop",
|
||||||
"system_version":"Unknown",
|
|
||||||
"application_version":"1.0",
|
"application_version":"1.0",
|
||||||
"enable_storage_optimizer":true
|
"enable_storage_optimizer":true
|
||||||
]
|
]
|
||||||
|
@ -43,7 +43,6 @@ namespace TdApp
|
|||||||
parameters.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
parameters.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
|
||||||
parameters.SystemLanguageCode = "en";
|
parameters.SystemLanguageCode = "en";
|
||||||
parameters.DeviceModel = "Desktop";
|
parameters.DeviceModel = "Desktop";
|
||||||
parameters.SystemVersion = "Unknown";
|
|
||||||
parameters.ApplicationVersion = "1.0.0";
|
parameters.ApplicationVersion = "1.0.0";
|
||||||
_client.Send(new TdApi.SetTdlibParameters(parameters), null);
|
_client.Send(new TdApi.SetTdlibParameters(parameters), null);
|
||||||
_client.Send(new TdApi.CheckDatabaseEncryptionKey(), null);
|
_client.Send(new TdApi.CheckDatabaseEncryptionKey(), null);
|
||||||
|
@ -34,7 +34,7 @@ ok = Ok;
|
|||||||
//@api_hash Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org
|
//@api_hash Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org
|
||||||
//@system_language_code IETF language tag of the user's operating system language; must be non-empty
|
//@system_language_code IETF language tag of the user's operating system language; must be non-empty
|
||||||
//@device_model Model of the device the application is being run on; must be non-empty
|
//@device_model Model of the device the application is being run on; must be non-empty
|
||||||
//@system_version Version of the operating system the application is being run on; must be non-empty
|
//@system_version Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib
|
||||||
//@application_version Application version; must be non-empty
|
//@application_version Application version; must be non-empty
|
||||||
//@enable_storage_optimizer If set to true, old files will automatically be deleted
|
//@enable_storage_optimizer If set to true, old files will automatically be deleted
|
||||||
//@ignore_file_names If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name
|
//@ignore_file_names If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name
|
||||||
|
@ -118,6 +118,7 @@
|
|||||||
#include "td/utils/port/IPAddress.h"
|
#include "td/utils/port/IPAddress.h"
|
||||||
#include "td/utils/port/path.h"
|
#include "td/utils/port/path.h"
|
||||||
#include "td/utils/port/SocketFd.h"
|
#include "td/utils/port/SocketFd.h"
|
||||||
|
#include "td/utils/port/uname.h"
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
@ -4676,7 +4677,7 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
|
|||||||
return Status::Error(400, "Device model must be non-empty");
|
return Status::Error(400, "Device model must be non-empty");
|
||||||
}
|
}
|
||||||
if (options_.system_version.empty()) {
|
if (options_.system_version.empty()) {
|
||||||
return Status::Error(400, "System version must be non-empty");
|
options_.system_version = get_operating_system_version().str();
|
||||||
}
|
}
|
||||||
if (options_.application_version.empty()) {
|
if (options_.application_version.empty()) {
|
||||||
return Status::Error(400, "Application version must be non-empty");
|
return Status::Error(400, "Application version must be non-empty");
|
||||||
|
@ -407,7 +407,6 @@ class CliClient final : public Actor {
|
|||||||
parameters->api_hash_ = api_hash_;
|
parameters->api_hash_ = api_hash_;
|
||||||
parameters->system_language_code_ = "en";
|
parameters->system_language_code_ = "en";
|
||||||
parameters->device_model_ = "Desktop";
|
parameters->device_model_ = "Desktop";
|
||||||
parameters->system_version_ = "Unknown";
|
|
||||||
parameters->application_version_ = "1.0";
|
parameters->application_version_ = "1.0";
|
||||||
send_request(td_api::make_object<td_api::setTdlibParameters>(std::move(parameters)));
|
send_request(td_api::make_object<td_api::setTdlibParameters>(std::move(parameters)));
|
||||||
break;
|
break;
|
||||||
@ -4385,13 +4384,15 @@ void main(int argc, char **argv) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!res.ok().empty()) {
|
if (!res.ok().empty()) {
|
||||||
LOG(PLAIN) << "tg_cli: " << "Have unexpected non-option parameters";
|
LOG(PLAIN) << "tg_cli: "
|
||||||
|
<< "Have unexpected non-option parameters";
|
||||||
LOG(PLAIN) << options;
|
LOG(PLAIN) << options;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api_id == 0 || api_hash.empty()) {
|
if (api_id == 0 || api_hash.empty()) {
|
||||||
LOG(PLAIN) << "tg_cli: " << "You should provide some valid api_id and api_hash";
|
LOG(PLAIN) << "tg_cli: "
|
||||||
|
<< "You should provide some valid api_id and api_hash";
|
||||||
LOG(PLAIN) << options;
|
LOG(PLAIN) << options;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,15 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
Slice get_operating_system_name() {
|
Slice get_operating_system_version() {
|
||||||
static string result = []() -> string {
|
static string result = []() -> string {
|
||||||
#if TD_PORT_POSIX
|
#if TD_PORT_POSIX
|
||||||
#if TD_ANDROID
|
#if TD_ANDROID
|
||||||
char version[PROP_VALUE_MAX + 1];
|
char version[PROP_VALUE_MAX + 1];
|
||||||
int length = __system_property_get("ro.build.version.release", version);
|
int length = __system_property_get("ro.build.version.release", version);
|
||||||
return length <= 0 ? string("Android") : "Android " + string(version, length);
|
if (length > 0) {
|
||||||
|
return "Android " + string(version, length);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
utsname name;
|
utsname name;
|
||||||
int err = uname(&name);
|
int err = uname(&name);
|
||||||
@ -38,8 +40,8 @@ Slice get_operating_system_name() {
|
|||||||
return os_name;
|
return os_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(ERROR) << "Failed to identify OS name; use generic one";
|
|
||||||
#endif
|
#endif
|
||||||
|
LOG(ERROR) << "Failed to identify OS name; use generic one";
|
||||||
|
|
||||||
#if TD_DARWIN_IOS
|
#if TD_DARWIN_IOS
|
||||||
return "iOS";
|
return "iOS";
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
Slice get_operating_system_name();
|
Slice get_operating_system_version();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1103,10 +1103,9 @@ TEST(Misc, CancellationToken) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Misc, uname) {
|
TEST(Misc, uname) {
|
||||||
auto first_name = get_operating_system_name();
|
auto first_version = get_operating_system_version();
|
||||||
auto second_name = get_operating_system_name();
|
auto second_version = get_operating_system_version();
|
||||||
ASSERT_STREQ(first_name, second_name);
|
ASSERT_STREQ(first_version, second_version);
|
||||||
ASSERT_EQ(first_name.begin(), second_name.begin());
|
ASSERT_EQ(first_version.begin(), second_version.begin());
|
||||||
ASSERT_TRUE(!first_name.empty());
|
ASSERT_TRUE(!first_version.empty());
|
||||||
LOG(ERROR) << first_name;
|
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,6 @@ class DoAuthentication : public Task {
|
|||||||
parameters->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2";
|
parameters->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2";
|
||||||
parameters->system_language_code_ = "en";
|
parameters->system_language_code_ = "en";
|
||||||
parameters->device_model_ = "Desktop";
|
parameters->device_model_ = "Desktop";
|
||||||
parameters->system_version_ = "Unknown";
|
|
||||||
parameters->application_version_ = "tdclient-test";
|
parameters->application_version_ = "tdclient-test";
|
||||||
parameters->ignore_file_names_ = false;
|
parameters->ignore_file_names_ = false;
|
||||||
parameters->enable_storage_optimizer_ = true;
|
parameters->enable_storage_optimizer_ = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user