Various fixes.
GitOrigin-RevId: 80fa34e64e6824a0f96c38d2e8b0a32455267ea8
This commit is contained in:
parent
110f2c5b7b
commit
1ac97a6ba7
@ -97,8 +97,8 @@ func myReadLine() -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAuthorizationState(authState: Dictionary<String, Any>) {
|
func updateAuthorizationState(authorizationState: Dictionary<String, Any>) {
|
||||||
switch(authState["@type"] as! String) {
|
switch(authorizationState["@type"] as! String) {
|
||||||
case "authorizationStateWaitTdlibParameters":
|
case "authorizationStateWaitTdlibParameters":
|
||||||
client.queryAsync(query:[
|
client.queryAsync(query:[
|
||||||
"@type":"setTdlibParameters",
|
"@type":"setTdlibParameters",
|
||||||
@ -122,13 +122,13 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
|
|||||||
case "authorizationStateWaitPhoneNumber":
|
case "authorizationStateWaitPhoneNumber":
|
||||||
print("Enter your phone: ")
|
print("Enter your phone: ")
|
||||||
let phone = myReadLine()
|
let phone = myReadLine()
|
||||||
client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthError)
|
client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthenticationError)
|
||||||
|
|
||||||
case "authorizationStateWaitCode":
|
case "authorizationStateWaitCode":
|
||||||
var first_name: String = ""
|
var first_name: String = ""
|
||||||
var last_name: String = ""
|
var last_name: String = ""
|
||||||
var code: String = ""
|
var code: String = ""
|
||||||
if let is_registered = authState["is_registered"] as? Bool, is_registered {
|
if let is_registered = authorizationState["is_registered"] as? Bool, is_registered {
|
||||||
} else {
|
} else {
|
||||||
print("Enter your first name: ")
|
print("Enter your first name: ")
|
||||||
first_name = myReadLine()
|
first_name = myReadLine()
|
||||||
@ -137,12 +137,12 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
|
|||||||
}
|
}
|
||||||
print("Enter (SMS) code: ")
|
print("Enter (SMS) code: ")
|
||||||
code = myReadLine()
|
code = myReadLine()
|
||||||
client.queryAsync(query:["@type":"checkAuthenticationCode", "code":code, "first_name":first_name, "last_name":last_name], f:checkAuthError)
|
client.queryAsync(query:["@type":"checkAuthenticationCode", "code":code, "first_name":first_name, "last_name":last_name], f:checkAuthenticationError)
|
||||||
|
|
||||||
case "authorizationStateWaitPassword":
|
case "authorizationStateWaitPassword":
|
||||||
print("Enter password: ")
|
print("Enter password: ")
|
||||||
let password = myReadLine()
|
let password = myReadLine()
|
||||||
client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthError)
|
client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthenticationError)
|
||||||
|
|
||||||
case "authorizationStateReady":
|
case "authorizationStateReady":
|
||||||
()
|
()
|
||||||
@ -152,7 +152,7 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkAuthError(error: Dictionary<String, Any>) {
|
func checkAuthenticationError(error: Dictionary<String, Any>) {
|
||||||
if (error["@type"] as! String == "error") {
|
if (error["@type"] as! String == "error") {
|
||||||
client.queryAsync(query:["@type":"getAuthorizationState"], f:updateAuthorizationState)
|
client.queryAsync(query:["@type":"getAuthorizationState"], f:updateAuthorizationState)
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ client.run {
|
|||||||
let update = $0
|
let update = $0
|
||||||
print(update)
|
print(update)
|
||||||
if update["@type"] as! String == "updateAuthorizationState" {
|
if update["@type"] as! String == "updateAuthorizationState" {
|
||||||
updateAuthorizationState(authState: update["authorization_state"] as! Dictionary<String, Any>)
|
updateAuthorizationState(authorizationState: update["authorization_state"] as! Dictionary<String, Any>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "td/tl/tl_writer.h"
|
#include "td/tl/tl_writer.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -362,7 +363,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
void gen_from_unmanaged(std::stringstream &ss, const tl_combinator *t) const {
|
void gen_from_unmanaged(std::stringstream &ss, const tl_combinator *t) const {
|
||||||
auto native_class_name = gen_native_class_name(t->name);
|
auto native_class_name = gen_native_class_name(t->name);
|
||||||
auto class_name = gen_class_name(t->name);
|
auto class_name = gen_class_name(t->name);
|
||||||
ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << "& from)";
|
ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << " &from)";
|
||||||
if (is_header_) {
|
if (is_header_) {
|
||||||
ss << ";\n";
|
ss << ";\n";
|
||||||
return;
|
return;
|
||||||
@ -422,7 +423,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
assert(result_type->children.empty());
|
assert(result_type->children.empty());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::string gen_constructor_id_store(int32_t id, int storer_type) const override {
|
std::string gen_constructor_id_store(std::int32_t id, int storer_type) const override {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::string gen_field_fetch(int field_num, const arg &a, std::vector<var_description> &vars, bool flat,
|
std::string gen_field_fetch(int field_num, const arg &a, std::vector<var_description> &vars, bool flat,
|
||||||
@ -454,7 +455,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string gen_get_id(const std::string &class_name, int32_t id, bool is_proxy) const override {
|
std::string gen_get_id(const std::string &class_name, std::int32_t id, bool is_proxy) const override {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,7 +521,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
<< " }\n"
|
<< " }\n"
|
||||||
<< " return td::td_api::move_object_as<td::td_api::" << native_class_name << ">(from->ToUnmanaged()->get_object_ptr());\n}\n";
|
<< " return td::td_api::move_object_as<td::td_api::" << native_class_name << ">(from->ToUnmanaged()->get_object_ptr());\n}\n";
|
||||||
} else {
|
} else {
|
||||||
ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << "& from)";
|
ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << " &from)";
|
||||||
if (is_header_) {
|
if (is_header_) {
|
||||||
ss << ";\n";
|
ss << ";\n";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
//
|
//
|
||||||
#include "td/mtproto/TcpTransport.h"
|
#include "td/mtproto/TcpTransport.h"
|
||||||
|
|
||||||
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
|
#include "td/utils/Slice.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@
|
|||||||
#include "td/utils/ByteFlow.h"
|
#include "td/utils/ByteFlow.h"
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/crypto.h"
|
#include "td/utils/crypto.h"
|
||||||
#include "td/utils/logging.h"
|
|
||||||
#include "td/utils/port/Fd.h"
|
#include "td/utils/port/Fd.h"
|
||||||
#include "td/utils/Slice.h"
|
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "td/utils/port/CxCli.h"
|
#include "td/utils/port/CxCli.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Telegram {
|
namespace Telegram {
|
||||||
namespace Td {
|
namespace Td {
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include "td/utils/HttpUrl.h"
|
#include "td/utils/HttpUrl.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/PathView.h"
|
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
#include "td/utils/tl_helpers.h"
|
#include "td/utils/tl_helpers.h"
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "td/utils/port/CxCli.h"
|
#include "td/utils/port/CxCli.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Telegram {
|
namespace Telegram {
|
||||||
namespace Td {
|
namespace Td {
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/PathView.h"
|
#include "td/utils/PathView.h"
|
||||||
#include "td/utils/port/path.h"
|
#include "td/utils/port/path.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"
|
||||||
#include "td/utils/Timer.h"
|
#include "td/utils/Timer.h"
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -104,7 +106,7 @@ bool for_suggested_file_name(CSlice name, bool use_pmc, bool use_random, F &&cal
|
|||||||
Result<string> create_from_temp(CSlice temp_path, CSlice dir, CSlice name) {
|
Result<string> create_from_temp(CSlice temp_path, CSlice dir, CSlice name) {
|
||||||
LOG(INFO) << "Create file in directory " << dir << " with suggested name " << name << " from temporary file "
|
LOG(INFO) << "Create file in directory " << dir << " with suggested name " << name << " from temporary file "
|
||||||
<< temp_path;
|
<< temp_path;
|
||||||
Result<std::pair<FileFd, string>> res = Status::Error();
|
Result<std::pair<FileFd, string>> res = Status::Error(500, "Can't find suitable file name");
|
||||||
for_suggested_file_name(name, true, true, [&](CSlice suggested_name) {
|
for_suggested_file_name(name, true, true, [&](CSlice suggested_name) {
|
||||||
res = try_create_new_file(PSLICE_SAFE() << dir << suggested_name);
|
res = try_create_new_file(PSLICE_SAFE() << dir << suggested_name);
|
||||||
return res.is_error();
|
return res.is_error();
|
||||||
@ -117,7 +119,7 @@ Result<string> create_from_temp(CSlice temp_path, CSlice dir, CSlice name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<string> search_file(CSlice dir, CSlice name, int64 expected_size) {
|
Result<string> search_file(CSlice dir, CSlice name, int64 expected_size) {
|
||||||
Result<std::string> res = Status::Error();
|
Result<std::string> res = Status::Error(500, "Can't find suitable file name");
|
||||||
for_suggested_file_name(name, false, false, [&](CSlice suggested_name) {
|
for_suggested_file_name(name, false, false, [&](CSlice suggested_name) {
|
||||||
auto r_pair = try_open_file(PSLICE_SAFE() << dir << suggested_name);
|
auto r_pair = try_open_file(PSLICE_SAFE() << dir << suggested_name);
|
||||||
if (r_pair.is_error()) {
|
if (r_pair.is_error()) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#include "td/telegram/net/DcOptionsSet.h"
|
#include "td/telegram/net/DcOptionsSet.h"
|
||||||
|
|
||||||
|
#include "td/utils/format.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
virtual NativeObject^ ToUnmanaged();
|
virtual NativeObject^ ToUnmanaged();
|
||||||
};
|
};
|
||||||
|
|
||||||
//from unmanaged
|
// from unmanaged
|
||||||
inline bool FromUnmanaged(bool val) {
|
inline bool FromUnmanaged(bool val) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user