diff --git a/td/telegram/Client.cpp b/td/telegram/Client.cpp index 8a171522..d6469328 100644 --- a/td/telegram/Client.cpp +++ b/td/telegram/Client.cpp @@ -269,7 +269,7 @@ Client::Client() : impl_(make_unique()) { init_openssl_threads(); } -void Client::send(Request request) { +void Client::send(Request &&request) { impl_->send(std::move(request)); } @@ -277,7 +277,7 @@ Client::Response Client::receive(double timeout) { return impl_->receive(timeout); } -Client::Response Client::execute(Request request) { +Client::Response Client::execute(Request &&request) { Response response; response.id = request.id; response.object = Td::static_request(std::move(request.function)); diff --git a/td/telegram/Client.h b/td/telegram/Client.h index 11e49371..ccd891b0 100644 --- a/td/telegram/Client.h +++ b/td/telegram/Client.h @@ -77,7 +77,7 @@ class Client final { * Sends request to TDLib. May be called from any thread. * \param[in] request Request to TDLib. */ - void send(Request request); + void send(Request &&request); /** * A response to a request, or an incoming update from TDLib. @@ -109,7 +109,7 @@ class Client final { * \param[in] request Request to the TDLib. * \return The request response. */ - static Response execute(Request request); + static Response execute(Request &&request); /** * Destroys the client and TDLib instance. diff --git a/td/telegram/LogDotNet.cpp b/td/telegram/LogDotNet.cpp index efe0ee81..26ec600b 100644 --- a/td/telegram/LogDotNet.cpp +++ b/td/telegram/LogDotNet.cpp @@ -17,8 +17,8 @@ using namespace CxCli; public ref class Log sealed { public: - static void SetFilePath(String^ filePath) { - ::td::Log::set_file_path(string_to_unmanaged(filePath)); + static bool SetFilePath(String^ filePath) { + return ::td::Log::set_file_path(string_to_unmanaged(filePath)); } static void SetMaxFileSize(std::int64_t maxFileSize) { diff --git a/tdutils/td/utils/port/CxCli.h b/tdutils/td/utils/port/CxCli.h index 3619387f..db9230ed 100644 --- a/tdutils/td/utils/port/CxCli.h +++ b/tdutils/td/utils/port/CxCli.h @@ -74,8 +74,11 @@ inline std::int64_t Increment(volatile std::int64_t &value) { return InterlockedIncrement64(&value); } -inline std::string string_to_unmanaged(String^ string) { - return td::from_wstring(string->Data(), string->Length()).ok(); +inline std::string string_to_unmanaged(String^ str) { + if (!str) { + return std::string(); + } + return td::from_wstring(str->Data(), str->Length()).ok(); } inline String^ string_from_unmanaged(const std::string &from) { @@ -117,8 +120,11 @@ inline std::int64_t Increment(std::int64_t %value) { return System::Threading::Interlocked::Increment(value); } -inline std::string string_to_unmanaged(String^ string) { - return msclr::interop::marshal_as(string); +inline std::string string_to_unmanaged(String^ str) { + if (!str) { + return std::string(); + } + return msclr::interop::marshal_as(str); } inline String^ string_from_unmanaged(const std::string &from) {