aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2018-02-28 13:25:07 +0300
committerlevlam <levlam@telegram.org>2018-02-28 13:25:07 +0300
commit1ac97a6ba73b07e93bbce96c7a47d0ec1852569a (patch)
treed1c38eddc2a45351c3b112b80170c5feaba5b9fb
parent110f2c5b7bd367ad565c43c306c2f2b7ae3f835a (diff)
Various fixes.
GitOrigin-RevId: 80fa34e64e6824a0f96c38d2e8b0a32455267ea8
-rw-r--r--example/swift/src/main.swift16
-rw-r--r--td/generate/CMakeLists.txt2
-rw-r--r--td/generate/tl_writer_dotnet.h9
-rw-r--r--td/mtproto/TcpTransport.cpp2
-rw-r--r--td/mtproto/TcpTransport.h2
-rw-r--r--td/telegram/ClientDotNet.cpp2
-rw-r--r--td/telegram/InlineQueriesManager.cpp1
-rw-r--r--td/telegram/LogDotNet.cpp2
-rw-r--r--td/telegram/Td.cpp1
-rw-r--r--td/telegram/files/FileLoaderUtils.cpp6
-rw-r--r--td/telegram/net/DcOptionsSet.cpp1
-rw-r--r--td/tl/tl_dotnet_object.h4
12 files changed, 28 insertions, 20 deletions
diff --git a/example/swift/src/main.swift b/example/swift/src/main.swift
index 84ca2b963..10b075dc8 100644
--- a/example/swift/src/main.swift
+++ b/example/swift/src/main.swift
@@ -97,8 +97,8 @@ func myReadLine() -> String {
}
}
-func updateAuthorizationState(authState: Dictionary<String, Any>) {
- switch(authState["@type"] as! String) {
+func updateAuthorizationState(authorizationState: Dictionary<String, Any>) {
+ switch(authorizationState["@type"] as! String) {
case "authorizationStateWaitTdlibParameters":
client.queryAsync(query:[
"@type":"setTdlibParameters",
@@ -122,13 +122,13 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
case "authorizationStateWaitPhoneNumber":
print("Enter your phone: ")
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":
var first_name: String = ""
var last_name: 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 {
print("Enter your first name: ")
first_name = myReadLine()
@@ -137,12 +137,12 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
}
print("Enter (SMS) code: ")
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":
print("Enter password: ")
let password = myReadLine()
- client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthError)
+ client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthenticationError)
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") {
client.queryAsync(query:["@type":"getAuthorizationState"], f:updateAuthorizationState)
}
@@ -162,7 +162,7 @@ client.run {
let update = $0
print(update)
if update["@type"] as! String == "updateAuthorizationState" {
- updateAuthorizationState(authState: update["authorization_state"] as! Dictionary<String, Any>)
+ updateAuthorizationState(authorizationState: update["authorization_state"] as! Dictionary<String, Any>)
}
}
diff --git a/td/generate/CMakeLists.txt b/td/generate/CMakeLists.txt
index ffecae6e0..e9ab1582d 100644
--- a/td/generate/CMakeLists.txt
+++ b/td/generate/CMakeLists.txt
@@ -131,7 +131,7 @@ if (NOT CMAKE_CROSSCOMPILING)
install(FILES JavadocTlDocumentationGenerator.php TlDocumentationGenerator.php DESTINATION bin/td/generate)
install(FILES scheme/td_api.tlo scheme/td_api.tl DESTINATION bin/td/generate/scheme)
endif()
-
+
if (TD_ENABLE_DOTNET)
add_executable(td_generate_dotnet_api generate_dotnet.cpp tl_writer_dotnet.h)
target_link_libraries(td_generate_dotnet_api PRIVATE tdtl)
diff --git a/td/generate/tl_writer_dotnet.h b/td/generate/tl_writer_dotnet.h
index d46d17ed4..3d3bada24 100644
--- a/td/generate/tl_writer_dotnet.h
+++ b/td/generate/tl_writer_dotnet.h
@@ -9,6 +9,7 @@
#include "td/tl/tl_writer.h"
#include <cassert>
+#include <cstdint>
#include <sstream>
#include <string>
#include <vector>
@@ -362,7 +363,7 @@ class TlWriterDotNet : public TL_writer {
void gen_from_unmanaged(std::stringstream &ss, const tl_combinator *t) const {
auto native_class_name = gen_native_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_) {
ss << ";\n";
return;
@@ -422,7 +423,7 @@ class TlWriterDotNet : public TL_writer {
assert(result_type->children.empty());
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 "";
}
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 "";
}
- 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 "";
}
@@ -520,7 +521,7 @@ class TlWriterDotNet : public TL_writer {
<< " }\n"
<< " return td::td_api::move_object_as<td::td_api::" << native_class_name << ">(from->ToUnmanaged()->get_object_ptr());\n}\n";
} 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_) {
ss << ";\n";
return ss.str();
diff --git a/td/mtproto/TcpTransport.cpp b/td/mtproto/TcpTransport.cpp
index ed266cb50..e7613acab 100644
--- a/td/mtproto/TcpTransport.cpp
+++ b/td/mtproto/TcpTransport.cpp
@@ -6,7 +6,9 @@
//
#include "td/mtproto/TcpTransport.h"
+#include "td/utils/logging.h"
#include "td/utils/Random.h"
+#include "td/utils/Slice.h"
#include <algorithm>
diff --git a/td/mtproto/TcpTransport.h b/td/mtproto/TcpTransport.h
index e5e217cd9..d53048478 100644
--- a/td/mtproto/TcpTransport.h
+++ b/td/mtproto/TcpTransport.h
@@ -13,9 +13,7 @@
#include "td/utils/ByteFlow.h"
#include "td/utils/common.h"
#include "td/utils/crypto.h"
-#include "td/utils/logging.h"
#include "td/utils/port/Fd.h"
-#include "td/utils/Slice.h"
#include "td/utils/Status.h"
namespace td {
diff --git a/td/telegram/ClientDotNet.cpp b/td/telegram/ClientDotNet.cpp
index ef73203d2..02a7fc07e 100644
--- a/td/telegram/ClientDotNet.cpp
+++ b/td/telegram/ClientDotNet.cpp
@@ -10,6 +10,8 @@
#include "td/utils/port/CxCli.h"
+#include <cstdint>
+
namespace Telegram {
namespace Td {
diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp
index 674563b8f..03321d738 100644
--- a/td/telegram/InlineQueriesManager.cpp
+++ b/td/telegram/InlineQueriesManager.cpp
@@ -39,7 +39,6 @@
#include "td/utils/HttpUrl.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
-#include "td/utils/PathView.h"
#include "td/utils/Slice.h"
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
diff --git a/td/telegram/LogDotNet.cpp b/td/telegram/LogDotNet.cpp
index c267c8f24..efe0ee817 100644
--- a/td/telegram/LogDotNet.cpp
+++ b/td/telegram/LogDotNet.cpp
@@ -8,6 +8,8 @@
#include "td/utils/port/CxCli.h"
+#include <cstdint>
+
namespace Telegram {
namespace Td {
diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp
index bd8b1ab7e..54fafb367 100644
--- a/td/telegram/Td.cpp
+++ b/td/telegram/Td.cpp
@@ -72,6 +72,7 @@
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/path.h"
+#include "td/utils/Random.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/Timer.h"
diff --git a/td/telegram/files/FileLoaderUtils.cpp b/td/telegram/files/FileLoaderUtils.cpp
index bc9329592..1e89cb72e 100644
--- a/td/telegram/files/FileLoaderUtils.cpp
+++ b/td/telegram/files/FileLoaderUtils.cpp
@@ -20,6 +20,8 @@
#include "td/utils/Random.h"
#include "td/utils/StringBuilder.h"
+#include <tuple>
+
namespace td {
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) {
LOG(INFO) << "Create file in directory " << dir << " with suggested name " << name << " from temporary file "
<< 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) {
res = try_create_new_file(PSLICE_SAFE() << dir << suggested_name);
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<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) {
auto r_pair = try_open_file(PSLICE_SAFE() << dir << suggested_name);
if (r_pair.is_error()) {
diff --git a/td/telegram/net/DcOptionsSet.cpp b/td/telegram/net/DcOptionsSet.cpp
index 00785e285..4aefd3b7f 100644
--- a/td/telegram/net/DcOptionsSet.cpp
+++ b/td/telegram/net/DcOptionsSet.cpp
@@ -6,6 +6,7 @@
//
#include "td/telegram/net/DcOptionsSet.h"
+#include "td/utils/format.h"
#include "td/utils/logging.h"
#include <algorithm>
diff --git a/td/tl/tl_dotnet_object.h b/td/tl/tl_dotnet_object.h
index 424383cc7..2d4a7d674 100644
--- a/td/tl/tl_dotnet_object.h
+++ b/td/tl/tl_dotnet_object.h
@@ -41,7 +41,7 @@ public:
virtual NativeObject^ ToUnmanaged();
};
-//from unmanaged
+// from unmanaged
inline bool FromUnmanaged(bool val) {
return val;
}
@@ -71,7 +71,7 @@ inline auto CLRCALL BytesFromUnmanaged(const std::string &from) {
return res;
}
-template <class FromT>
+template <class FromT>
auto CLRCALL FromUnmanaged(std::vector<FromT> &vec) {
using ToT = decltype(FromUnmanaged(vec[0]));
Array<ToT>^ res = REF_NEW Vector<ToT>(td::narrow_cast<int>(vec.size()));