From 0ece30dc7c0e34b4c5911969b8fa99c33c6d023c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 30 Nov 2022 17:48:47 +0300 Subject: Telegram: update for TDLIB --- protocols/Telegram/Telegram.vcxproj | 2 + protocols/Telegram/Telegram.vcxproj.filters | 33 +- protocols/Telegram/src/main.cpp | 17 +- protocols/Telegram/src/stdafx.h | 6 +- protocols/Telegram/tdlib/build/tdactor.vcxproj | 164 - .../Telegram/tdlib/build/tdactor.vcxproj.filters | 105 - protocols/Telegram/tdlib/build/tdcore.vcxproj | 398 - .../Telegram/tdlib/build/tdcore.vcxproj.filters | 747 - protocols/Telegram/tdlib/build/tddb.vcxproj | 171 - .../Telegram/tdlib/build/tddb.vcxproj.filters | 44 - protocols/Telegram/tdlib/build/tdnet.vcxproj | 166 - .../Telegram/tdlib/build/tdnet.vcxproj.filters | 99 - protocols/Telegram/tdlib/build/tdsqlite.vcxproj | 132 - .../Telegram/tdlib/build/tdsqlite.vcxproj.filters | 27 - protocols/Telegram/tdlib/build/tdutils.vcxproj | 278 - .../Telegram/tdlib/build/tdutils.vcxproj.filters | 465 - protocols/Telegram/tdlib/td/.clang-format | 74 +- protocols/Telegram/tdlib/td/.gitattributes | 14 +- protocols/Telegram/tdlib/td/.gitignore | 1 + protocols/Telegram/tdlib/td/.ycm_extra_conf.py | 159 - protocols/Telegram/tdlib/td/CHANGELOG.md | 1447 +- .../tdlib/td/CMake/AddCXXCompilerFlag.cmake | 16 +- .../Telegram/tdlib/td/CMake/FindReadline.cmake | 8 +- .../tdlib/td/CMake/GeneratePkgConfig.cmake | 92 + .../tdlib/td/CMake/GetGitRevisionDescription.cmake | 127 + .../td/CMake/GetGitRevisionDescription.cmake.in | 43 + .../tdlib/td/CMake/PreventInSourceBuild.cmake | 14 + .../Telegram/tdlib/td/CMake/TdSetUpCompiler.cmake | 174 + protocols/Telegram/tdlib/td/CMake/iOS.cmake | 69 +- protocols/Telegram/tdlib/td/CMake/illumos.cmake | 10 + protocols/Telegram/tdlib/td/CMakeLists.txt | 733 +- protocols/Telegram/tdlib/td/README.md | 93 +- protocols/Telegram/tdlib/td/SplitSource.php | 368 + .../Telegram/tdlib/td/benchmark/CMakeLists.txt | 38 +- .../Telegram/tdlib/td/benchmark/bench_actor.cpp | 156 +- .../Telegram/tdlib/td/benchmark/bench_crypto.cpp | 392 +- protocols/Telegram/tdlib/td/benchmark/bench_db.cpp | 89 +- .../Telegram/tdlib/td/benchmark/bench_empty.cpp | 3 +- .../tdlib/td/benchmark/bench_handshake.cpp | 48 +- .../Telegram/tdlib/td/benchmark/bench_http.cpp | 59 +- .../tdlib/td/benchmark/bench_http_reader.cpp | 40 +- .../tdlib/td/benchmark/bench_http_server.cpp | 57 +- .../tdlib/td/benchmark/bench_http_server_cheat.cpp | 91 +- .../tdlib/td/benchmark/bench_http_server_fast.cpp | 85 +- .../Telegram/tdlib/td/benchmark/bench_log.cpp | 63 +- .../Telegram/tdlib/td/benchmark/bench_misc.cpp | 590 +- .../Telegram/tdlib/td/benchmark/bench_queue.cpp | 400 +- .../Telegram/tdlib/td/benchmark/bench_tddb.cpp | 87 +- .../Telegram/tdlib/td/benchmark/check_proxy.cpp | 193 + .../Telegram/tdlib/td/benchmark/check_tls.cpp | 336 + .../Telegram/tdlib/td/benchmark/hashmap_build.cpp | 545 + .../Telegram/tdlib/td/benchmark/hashset_memory.cpp | 193 + protocols/Telegram/tdlib/td/benchmark/rmdir.cpp | 13 +- protocols/Telegram/tdlib/td/benchmark/wget.cpp | 32 +- .../Telegram/tdlib/td/bitbucket-pipelines.yml | 2 +- protocols/Telegram/tdlib/td/build.html | 1141 + protocols/Telegram/tdlib/td/example/README.md | 315 + .../Telegram/tdlib/td/example/android/.gitignore | 3 + .../tdlib/td/example/android/AddIntDef.php | 51 + .../tdlib/td/example/android/CMakeLists.txt | 48 + .../Telegram/tdlib/td/example/android/Dockerfile | 26 + .../Telegram/tdlib/td/example/android/README.md | 24 + .../tdlib/td/example/android/build-openssl.sh | 78 + .../tdlib/td/example/android/build-tdlib.sh | 90 + .../tdlib/td/example/android/check-environment.sh | 50 + .../Telegram/tdlib/td/example/android/fetch-sdk.sh | 30 + .../Telegram/tdlib/td/example/cpp/CMakeLists.txt | 4 +- protocols/Telegram/tdlib/td/example/cpp/README.md | 4 +- .../Telegram/tdlib/td/example/cpp/td_example.cpp | 250 +- .../tdlib/td/example/cpp/tdjson_example.cpp | 36 +- .../Telegram/tdlib/td/example/csharp/README.md | 18 +- .../Telegram/tdlib/td/example/csharp/TdExample.cs | 98 +- .../tdlib/td/example/csharp/TdExample.csproj | 64 +- protocols/Telegram/tdlib/td/example/go/main.go | 26 - .../td/example/ios/Python-Apple-support.patch | 104 + protocols/Telegram/tdlib/td/example/ios/README.md | 31 +- .../Telegram/tdlib/td/example/ios/build-openssl.sh | 39 +- protocols/Telegram/tdlib/td/example/ios/build.sh | 116 +- .../example/ios/openssl-1.0.2n-darwin-arm64.patch | 12 + .../Telegram/tdlib/td/example/java/CMakeLists.txt | 68 +- protocols/Telegram/tdlib/td/example/java/README.md | 16 +- .../example/java/org/drinkless/tdlib/Client.java | 277 +- .../td/example/java/org/drinkless/tdlib/Log.java | 75 - .../java/org/drinkless/tdlib/example/Example.java | 372 +- .../Telegram/tdlib/td/example/java/td_jni.cpp | 128 +- .../Telegram/tdlib/td/example/python/README.md | 4 +- .../tdlib/td/example/python/tdjson_example.py | 164 +- protocols/Telegram/tdlib/td/example/ruby/Gemfile | 3 - .../Telegram/tdlib/td/example/ruby/Gemfile.lock | 17 - .../Telegram/tdlib/td/example/ruby/example.rb | 61 - .../Telegram/tdlib/td/example/swift/README.md | 6 +- .../Telegram/tdlib/td/example/swift/src/main.swift | 88 +- .../td/example/swift/src/td-Bridging-Header.h | 8 +- .../td/example/swift/td.xcodeproj/project.pbxproj | 16 +- protocols/Telegram/tdlib/td/example/uwp/README.md | 16 +- .../Telegram/tdlib/td/example/uwp/app/App.xaml.cs | 2 +- .../tdlib/td/example/uwp/app/MainPage.xaml.cs | 76 +- .../td/example/uwp/app/Properties/AssemblyInfo.cs | 4 +- .../Telegram/tdlib/td/example/uwp/app/TdApp.csproj | 2 +- protocols/Telegram/tdlib/td/example/uwp/build.ps1 | 45 +- .../tdlib/td/example/uwp/extension.vsixmanifest | 2 +- protocols/Telegram/tdlib/td/example/web/.gitignore | 5 + protocols/Telegram/tdlib/td/example/web/README.md | 29 + .../Telegram/tdlib/td/example/web/build-openssl.sh | 28 + .../Telegram/tdlib/td/example/web/build-tdlib.sh | 44 + .../Telegram/tdlib/td/example/web/build-tdweb.sh | 7 + .../Telegram/tdlib/td/example/web/copy-tdlib.sh | 7 + .../Telegram/tdlib/td/example/web/tdweb/README.md | 29 + .../tdlib/td/example/web/tdweb/package-lock.json | 7681 ++ .../tdlib/td/example/web/tdweb/package.json | 102 + .../tdlib/td/example/web/tdweb/src/index.js | 680 + .../tdlib/td/example/web/tdweb/src/logger.js | 47 + .../tdlib/td/example/web/tdweb/src/wasm-utils.js | 136 + .../tdlib/td/example/web/tdweb/src/worker.js | 1034 + .../tdlib/td/example/web/tdweb/webpack.config.js | 86 + protocols/Telegram/tdlib/td/format.ps1 | 2 +- protocols/Telegram/tdlib/td/format.sh | 3 +- protocols/Telegram/tdlib/td/gen_git_commit_h.ps1 | 6 +- protocols/Telegram/tdlib/td/gen_git_commit_h.sh | 13 +- protocols/Telegram/tdlib/td/memprof/memprof.cpp | 61 +- protocols/Telegram/tdlib/td/memprof/memprof.h | 2 +- .../Telegram/tdlib/td/memprof/memprof_stat.cpp | 166 + protocols/Telegram/tdlib/td/memprof/memprof_stat.h | 13 + protocols/Telegram/tdlib/td/post.js | 1 + protocols/Telegram/tdlib/td/sqlite/CMakeLists.txt | 44 +- .../Telegram/tdlib/td/sqlite/sqlite/sqlite3.c | 120020 +++++++++++------- .../Telegram/tdlib/td/sqlite/sqlite/sqlite3.h | 6597 +- .../Telegram/tdlib/td/sqlite/sqlite/sqlite3ext.h | 930 +- .../tdlib/td/sqlite/sqlite/sqlite3session.h | 757 +- protocols/Telegram/tdlib/td/src.ps1 | 2 +- protocols/Telegram/tdlib/td/src.sh | 2 +- .../Telegram/tdlib/td/td/generate/CMakeLists.txt | 121 +- .../td/generate/DotnetTlDocumentationGenerator.php | 37 +- .../generate/DoxygenTlDocumentationGenerator.php | 111 +- .../generate/JavadocTlDocumentationGenerator.php | 66 +- .../td/td/generate/TlDocumentationGenerator.php | 69 +- .../Telegram/tdlib/td/td/generate/generate_c.cpp | 4 +- .../tdlib/td/td/generate/generate_common.cpp | 7 +- .../tdlib/td/td/generate/generate_dotnet.cpp | 5 +- .../tdlib/td/td/generate/generate_java.cpp | 2 +- .../tdlib/td/td/generate/generate_json.cpp | 5 +- .../tdlib/td/td/generate/remove_documentation.cpp | 2 +- .../tdlib/td/td/generate/scheme/mtproto_api.tl | 25 +- .../tdlib/td/td/generate/scheme/mtproto_api.tlo | Bin 8276 -> 0 bytes .../tdlib/td/td/generate/scheme/secret_api.tl | 28 +- .../tdlib/td/td/generate/scheme/secret_api.tlo | Bin 14120 -> 0 bytes .../Telegram/tdlib/td/td/generate/scheme/td_api.tl | 6705 +- .../tdlib/td/td/generate/scheme/td_api.tlo | Bin 112840 -> 0 bytes .../tdlib/td/td/generate/scheme/telegram_api.tl | 1561 +- .../tdlib/td/td/generate/scheme/telegram_api.tlo | Bin 149276 -> 0 bytes .../tdlib/td/td/generate/scheme/update-tlo.sh | 6 - .../tdlib/td/td/generate/tl-parser/CMakeLists.txt | 25 + .../tdlib/td/td/generate/tl-parser/LICENSE | 339 + .../tdlib/td/td/generate/tl-parser/crc32.c | 345 + .../tdlib/td/td/generate/tl-parser/crc32.h | 37 + .../td/td/generate/tl-parser/portable_endian.h | 88 + .../td/td/generate/tl-parser/tl-parser-tree.h | 178 + .../tdlib/td/td/generate/tl-parser/tl-parser.c | 3078 + .../tdlib/td/td/generate/tl-parser/tl-parser.h | 223 + .../tdlib/td/td/generate/tl-parser/tl-tl.h | 55 + .../Telegram/tdlib/td/td/generate/tl-parser/tlc.c | 165 + .../tdlib/td/td/generate/tl-parser/wgetopt.c | 1274 + .../tdlib/td/td/generate/tl-parser/wgetopt.h | 193 + .../tdlib/td/td/generate/tl_json_converter.cpp | 153 +- .../tdlib/td/td/generate/tl_json_converter.h | 5 +- .../Telegram/tdlib/td/td/generate/tl_writer_c.h | 244 +- .../tdlib/td/td/generate/tl_writer_cpp.cpp | 97 +- .../Telegram/tdlib/td/td/generate/tl_writer_cpp.h | 15 +- .../tdlib/td/td/generate/tl_writer_dotnet.h | 190 +- .../Telegram/tdlib/td/td/generate/tl_writer_h.cpp | 102 +- .../Telegram/tdlib/td/td/generate/tl_writer_h.h | 19 +- .../tdlib/td/td/generate/tl_writer_hpp.cpp | 15 +- .../Telegram/tdlib/td/td/generate/tl_writer_hpp.h | 98 +- .../tdlib/td/td/generate/tl_writer_java.cpp | 53 +- .../Telegram/tdlib/td/td/generate/tl_writer_java.h | 117 +- .../tdlib/td/td/generate/tl_writer_jni_cpp.cpp | 59 +- .../tdlib/td/td/generate/tl_writer_jni_cpp.h | 80 +- .../tdlib/td/td/generate/tl_writer_jni_h.cpp | 20 +- .../tdlib/td/td/generate/tl_writer_jni_h.h | 41 +- .../Telegram/tdlib/td/td/generate/tl_writer_td.cpp | 52 +- .../Telegram/tdlib/td/td/generate/tl_writer_td.h | 5 +- .../Telegram/tdlib/td/td/mtproto/AuthData.cpp | 54 +- protocols/Telegram/tdlib/td/td/mtproto/AuthData.h | 69 +- protocols/Telegram/tdlib/td/td/mtproto/AuthKey.h | 72 +- .../tdlib/td/td/mtproto/ConnectionManager.cpp | 37 + .../tdlib/td/td/mtproto/ConnectionManager.h | 70 + .../Telegram/tdlib/td/td/mtproto/CryptoStorer.h | 127 +- .../Telegram/tdlib/td/td/mtproto/DhCallback.h | 29 + .../Telegram/tdlib/td/td/mtproto/DhHandshake.cpp | 232 + .../Telegram/tdlib/td/td/mtproto/DhHandshake.h | 124 + .../Telegram/tdlib/td/td/mtproto/Handshake.cpp | 269 +- protocols/Telegram/tdlib/td/td/mtproto/Handshake.h | 99 +- .../tdlib/td/td/mtproto/HandshakeActor.cpp | 52 +- .../Telegram/tdlib/td/td/mtproto/HandshakeActor.h | 64 +- .../tdlib/td/td/mtproto/HandshakeConnection.h | 36 +- .../Telegram/tdlib/td/td/mtproto/HttpTransport.cpp | 53 +- .../Telegram/tdlib/td/td/mtproto/HttpTransport.h | 37 +- .../tdlib/td/td/mtproto/IStreamTransport.cpp | 16 +- .../tdlib/td/td/mtproto/IStreamTransport.h | 14 +- protocols/Telegram/tdlib/td/td/mtproto/KDF.cpp | 107 + protocols/Telegram/tdlib/td/td/mtproto/KDF.h | 22 + .../Telegram/tdlib/td/td/mtproto/MtprotoQuery.h | 25 + .../Telegram/tdlib/td/td/mtproto/NoCryptoStorer.h | 33 +- .../Telegram/tdlib/td/td/mtproto/PacketInfo.h | 35 + .../Telegram/tdlib/td/td/mtproto/PacketStorer.h | 15 +- protocols/Telegram/tdlib/td/td/mtproto/Ping.cpp | 104 + protocols/Telegram/tdlib/td/td/mtproto/Ping.h | 25 + .../tdlib/td/td/mtproto/PingConnection.cpp | 201 + .../Telegram/tdlib/td/td/mtproto/PingConnection.h | 69 +- .../Telegram/tdlib/td/td/mtproto/ProxySecret.cpp | 53 + .../Telegram/tdlib/td/td/mtproto/ProxySecret.h | 69 + protocols/Telegram/tdlib/td/td/mtproto/RSA.cpp | 158 + protocols/Telegram/tdlib/td/td/mtproto/RSA.h | 49 + .../Telegram/tdlib/td/td/mtproto/RawConnection.cpp | 494 +- .../Telegram/tdlib/td/td/mtproto/RawConnection.h | 134 +- .../tdlib/td/td/mtproto/SessionConnection.cpp | 458 +- .../tdlib/td/td/mtproto/SessionConnection.h | 151 +- .../Telegram/tdlib/td/td/mtproto/TcpTransport.cpp | 138 +- .../Telegram/tdlib/td/td/mtproto/TcpTransport.h | 140 +- protocols/Telegram/tdlib/td/td/mtproto/TlsInit.cpp | 517 + protocols/Telegram/tdlib/td/td/mtproto/TlsInit.h | 50 + .../tdlib/td/td/mtproto/TlsReaderByteFlow.cpp | 40 + .../tdlib/td/td/mtproto/TlsReaderByteFlow.h | 20 + .../Telegram/tdlib/td/td/mtproto/Transport.cpp | 304 +- protocols/Telegram/tdlib/td/td/mtproto/Transport.h | 197 +- .../Telegram/tdlib/td/td/mtproto/TransportType.h | 27 + protocols/Telegram/tdlib/td/td/mtproto/crypto.cpp | 441 - protocols/Telegram/tdlib/td/td/mtproto/crypto.h | 160 - protocols/Telegram/tdlib/td/td/mtproto/utils.cpp | 16 +- protocols/Telegram/tdlib/td/td/mtproto/utils.h | 71 +- .../Telegram/tdlib/td/td/telegram/AccessRights.h | 6 +- .../Telegram/tdlib/td/td/telegram/Account.cpp | 605 + protocols/Telegram/tdlib/td/td/telegram/Account.h | 49 + .../tdlib/td/td/telegram/AffectedHistory.h | 33 + .../tdlib/td/td/telegram/AnimationsManager.cpp | 602 +- .../tdlib/td/td/telegram/AnimationsManager.h | 103 +- .../tdlib/td/td/telegram/AnimationsManager.hpp | 51 +- .../Telegram/tdlib/td/td/telegram/Application.cpp | 135 + .../Telegram/tdlib/td/td/telegram/Application.h | 28 + .../tdlib/td/td/telegram/AttachMenuManager.cpp | 1099 + .../tdlib/td/td/telegram/AttachMenuManager.h | 166 + .../tdlib/td/td/telegram/AudiosManager.cpp | 206 +- .../Telegram/tdlib/td/td/telegram/AudiosManager.h | 53 +- .../tdlib/td/td/telegram/AudiosManager.hpp | 133 +- .../Telegram/tdlib/td/td/telegram/AuthManager.cpp | 1222 +- .../Telegram/tdlib/td/td/telegram/AuthManager.h | 344 +- .../Telegram/tdlib/td/td/telegram/AuthManager.hpp | 168 +- .../tdlib/td/td/telegram/AutoDownloadSettings.cpp | 144 + .../tdlib/td/td/telegram/AutoDownloadSettings.h | 38 + .../Telegram/tdlib/td/td/telegram/BackgroundId.h | 70 + .../tdlib/td/td/telegram/BackgroundManager.cpp | 1273 + .../tdlib/td/td/telegram/BackgroundManager.h | 200 + .../tdlib/td/td/telegram/BackgroundType.cpp | 468 + .../Telegram/tdlib/td/td/telegram/BackgroundType.h | 134 + .../tdlib/td/td/telegram/BackgroundType.hpp | 84 + .../Telegram/tdlib/td/td/telegram/BotCommand.cpp | 226 + .../Telegram/tdlib/td/td/telegram/BotCommand.h | 100 + .../tdlib/td/td/telegram/BotCommandScope.cpp | 125 + .../tdlib/td/td/telegram/BotCommandScope.h | 43 + .../tdlib/td/td/telegram/BotMenuButton.cpp | 164 + .../Telegram/tdlib/td/td/telegram/BotMenuButton.h | 83 + .../Telegram/tdlib/td/td/telegram/CallActor.cpp | 696 +- .../Telegram/tdlib/td/td/telegram/CallActor.h | 127 +- .../tdlib/td/td/telegram/CallDiscardReason.cpp | 7 +- .../tdlib/td/td/telegram/CallDiscardReason.h | 13 +- protocols/Telegram/tdlib/td/td/telegram/CallId.h | 16 +- .../Telegram/tdlib/td/td/telegram/CallManager.cpp | 93 +- .../Telegram/tdlib/td/td/telegram/CallManager.h | 39 +- .../td/td/telegram/CallbackQueriesManager.cpp | 171 +- .../tdlib/td/td/telegram/CallbackQueriesManager.h | 39 +- protocols/Telegram/tdlib/td/td/telegram/ChainId.h | 57 + .../Telegram/tdlib/td/td/telegram/ChannelId.h | 31 +- .../td/td/telegram/ChannelParticipantFilter.cpp | 116 + .../td/td/telegram/ChannelParticipantFilter.h | 62 + .../Telegram/tdlib/td/td/telegram/ChannelType.h | 15 + protocols/Telegram/tdlib/td/td/telegram/ChatId.h | 30 +- .../tdlib/td/td/telegram/ChatReactions.cpp | 118 + .../Telegram/tdlib/td/td/telegram/ChatReactions.h | 83 + protocols/Telegram/tdlib/td/td/telegram/Client.cpp | 760 +- protocols/Telegram/tdlib/td/td/telegram/Client.h | 171 +- .../Telegram/tdlib/td/td/telegram/ClientActor.cpp | 32 +- .../Telegram/tdlib/td/td/telegram/ClientActor.h | 49 +- .../Telegram/tdlib/td/td/telegram/ClientDotNet.cpp | 150 +- .../Telegram/tdlib/td/td/telegram/ClientJson.cpp | 170 +- .../Telegram/tdlib/td/td/telegram/ClientJson.h | 27 +- .../tdlib/td/td/telegram/ConfigManager.cpp | 1836 +- .../Telegram/tdlib/td/td/telegram/ConfigManager.h | 134 +- .../Telegram/tdlib/td/td/telegram/ConfigShared.cpp | 126 - .../Telegram/tdlib/td/td/telegram/ConfigShared.h | 56 - .../tdlib/td/td/telegram/ConnectionState.cpp | 38 + .../tdlib/td/td/telegram/ConnectionState.h | 19 + .../Telegram/tdlib/td/td/telegram/Contact.cpp | 66 +- protocols/Telegram/tdlib/td/td/telegram/Contact.h | 90 +- .../tdlib/td/td/telegram/ContactsManager.cpp | 20182 ++- .../tdlib/td/td/telegram/ContactsManager.h | 1547 +- .../tdlib/td/td/telegram/CountryInfoManager.cpp | 543 + .../tdlib/td/td/telegram/CountryInfoManager.h | 87 + .../Telegram/tdlib/td/td/telegram/CustomEmojiId.h | 65 + .../tdlib/td/td/telegram/DelayDispatcher.cpp | 24 +- .../tdlib/td/td/telegram/DelayDispatcher.h | 13 +- .../Telegram/tdlib/td/td/telegram/Dependencies.cpp | 130 + .../Telegram/tdlib/td/td/telegram/Dependencies.h | 54 + .../tdlib/td/td/telegram/DeviceTokenManager.cpp | 270 +- .../tdlib/td/td/telegram/DeviceTokenManager.h | 69 +- .../Telegram/tdlib/td/td/telegram/DhCache.cpp | 21 +- protocols/Telegram/tdlib/td/td/telegram/DhCache.h | 14 +- protocols/Telegram/tdlib/td/td/telegram/DhConfig.h | 8 +- .../Telegram/tdlib/td/td/telegram/DialogAction.cpp | 530 + .../Telegram/tdlib/td/td/telegram/DialogAction.h | 101 + .../tdlib/td/td/telegram/DialogActionBar.cpp | 296 + .../tdlib/td/td/telegram/DialogActionBar.h | 118 + .../tdlib/td/td/telegram/DialogAdministrator.cpp | 26 + .../tdlib/td/td/telegram/DialogAdministrator.h | 89 + .../Telegram/tdlib/td/td/telegram/DialogDate.h | 73 + .../Telegram/tdlib/td/td/telegram/DialogDb.cpp | 381 +- protocols/Telegram/tdlib/td/td/telegram/DialogDb.h | 68 +- .../tdlib/td/td/telegram/DialogEventLog.cpp | 592 + .../Telegram/tdlib/td/td/telegram/DialogEventLog.h | 24 + .../Telegram/tdlib/td/td/telegram/DialogFilter.cpp | 480 + .../Telegram/tdlib/td/td/telegram/DialogFilter.h | 105 + .../Telegram/tdlib/td/td/telegram/DialogFilter.hpp | 84 + .../Telegram/tdlib/td/td/telegram/DialogFilterId.h | 73 + .../Telegram/tdlib/td/td/telegram/DialogId.cpp | 87 +- protocols/Telegram/tdlib/td/td/telegram/DialogId.h | 29 +- .../tdlib/td/td/telegram/DialogInviteLink.cpp | 132 + .../tdlib/td/td/telegram/DialogInviteLink.h | 161 + .../Telegram/tdlib/td/td/telegram/DialogListId.h | 138 + .../tdlib/td/td/telegram/DialogLocation.cpp | 63 + .../Telegram/tdlib/td/td/telegram/DialogLocation.h | 63 + .../td/td/telegram/DialogNotificationSettings.cpp | 102 + .../td/td/telegram/DialogNotificationSettings.h | 74 + .../td/td/telegram/DialogNotificationSettings.hpp | 89 + .../tdlib/td/td/telegram/DialogParticipant.cpp | 855 +- .../tdlib/td/td/telegram/DialogParticipant.h | 443 +- .../td/td/telegram/DialogParticipantFilter.cpp | 142 + .../tdlib/td/td/telegram/DialogParticipantFilter.h | 39 + .../Telegram/tdlib/td/td/telegram/DialogSource.cpp | 98 + .../Telegram/tdlib/td/td/telegram/DialogSource.h | 48 + .../Telegram/tdlib/td/td/telegram/Dimensions.cpp | 51 + .../Telegram/tdlib/td/td/telegram/Dimensions.h | 28 + .../Telegram/tdlib/td/td/telegram/Dimensions.hpp | 28 + .../Telegram/tdlib/td/td/telegram/Document.cpp | 113 + protocols/Telegram/tdlib/td/td/telegram/Document.h | 46 + .../Telegram/tdlib/td/td/telegram/Document.hpp | 107 + .../tdlib/td/td/telegram/DocumentsManager.cpp | 498 +- .../tdlib/td/td/telegram/DocumentsManager.h | 66 +- .../tdlib/td/td/telegram/DocumentsManager.hpp | 33 +- .../tdlib/td/td/telegram/DownloadManager.cpp | 840 + .../tdlib/td/td/telegram/DownloadManager.h | 112 + .../td/td/telegram/DownloadManagerCallback.cpp | 125 + .../tdlib/td/td/telegram/DownloadManagerCallback.h | 69 + .../Telegram/tdlib/td/td/telegram/DraftMessage.cpp | 95 + .../Telegram/tdlib/td/td/telegram/DraftMessage.h | 38 + .../Telegram/tdlib/td/td/telegram/DraftMessage.hpp | 31 + .../tdlib/td/td/telegram/EmailVerification.cpp | 53 + .../tdlib/td/td/telegram/EmailVerification.h | 37 + .../Telegram/tdlib/td/td/telegram/EmojiStatus.cpp | 330 + .../Telegram/tdlib/td/td/telegram/EmojiStatus.h | 110 + .../Telegram/tdlib/td/td/telegram/EncryptedFile.h | 91 + .../tdlib/td/td/telegram/FileReferenceManager.cpp | 475 + .../tdlib/td/td/telegram/FileReferenceManager.h | 196 + .../tdlib/td/td/telegram/FileReferenceManager.hpp | 139 + protocols/Telegram/tdlib/td/td/telegram/FolderId.h | 68 + .../Telegram/tdlib/td/td/telegram/ForumTopic.cpp | 52 + .../Telegram/tdlib/td/td/telegram/ForumTopic.h | 50 + .../tdlib/td/td/telegram/ForumTopicEditedData.cpp | 42 + .../tdlib/td/td/telegram/ForumTopicEditedData.h | 64 + .../tdlib/td/td/telegram/ForumTopicEditedData.hpp | 54 + .../tdlib/td/td/telegram/ForumTopicIcon.cpp | 43 + .../Telegram/tdlib/td/td/telegram/ForumTopicIcon.h | 45 + .../tdlib/td/td/telegram/ForumTopicIcon.hpp | 40 + .../tdlib/td/td/telegram/ForumTopicInfo.cpp | 70 + .../Telegram/tdlib/td/td/telegram/ForumTopicInfo.h | 77 + .../tdlib/td/td/telegram/ForumTopicManager.cpp | 358 + .../tdlib/td/td/telegram/ForumTopicManager.h | 81 + .../Telegram/tdlib/td/td/telegram/FullMessageId.h | 68 + protocols/Telegram/tdlib/td/td/telegram/Game.cpp | 100 +- protocols/Telegram/tdlib/td/td/telegram/Game.h | 30 +- protocols/Telegram/tdlib/td/td/telegram/Game.hpp | 5 +- .../Telegram/tdlib/td/td/telegram/GameManager.cpp | 319 + .../Telegram/tdlib/td/td/telegram/GameManager.h | 56 + .../tdlib/td/td/telegram/GitCommitHash.cpp.in | 15 + .../Telegram/tdlib/td/td/telegram/GitCommitHash.h | 13 + protocols/Telegram/tdlib/td/td/telegram/Global.cpp | 278 +- protocols/Telegram/tdlib/td/td/telegram/Global.h | 378 +- .../Telegram/tdlib/td/td/telegram/GroupCallId.h | 53 + .../tdlib/td/td/telegram/GroupCallManager.cpp | 4861 + .../tdlib/td/td/telegram/GroupCallManager.h | 427 + .../tdlib/td/td/telegram/GroupCallParticipant.cpp | 321 + .../tdlib/td/td/telegram/GroupCallParticipant.h | 112 + .../td/td/telegram/GroupCallParticipantOrder.cpp | 73 + .../td/td/telegram/GroupCallParticipantOrder.h | 64 + .../tdlib/td/td/telegram/GroupCallVideoPayload.cpp | 61 + .../tdlib/td/td/telegram/GroupCallVideoPayload.h | 40 + .../Telegram/tdlib/td/td/telegram/HashtagHints.cpp | 27 +- .../Telegram/tdlib/td/td/telegram/HashtagHints.h | 10 +- .../tdlib/td/td/telegram/InlineQueriesManager.cpp | 1811 +- .../tdlib/td/td/telegram/InlineQueriesManager.h | 89 +- .../tdlib/td/td/telegram/InputDialogId.cpp | 157 + .../Telegram/tdlib/td/td/telegram/InputDialogId.h | 82 + .../tdlib/td/td/telegram/InputGroupCallId.cpp | 23 + .../tdlib/td/td/telegram/InputGroupCallId.h | 72 + .../Telegram/tdlib/td/td/telegram/InputInvoice.cpp | 413 + .../Telegram/tdlib/td/td/telegram/InputInvoice.h | 133 + .../Telegram/tdlib/td/td/telegram/InputInvoice.hpp | 195 + .../tdlib/td/td/telegram/InputMessageText.cpp | 43 + .../tdlib/td/td/telegram/InputMessageText.h | 39 + .../tdlib/td/td/telegram/InputMessageText.hpp | 35 + .../Telegram/tdlib/td/td/telegram/JsonValue.cpp | 247 + .../Telegram/tdlib/td/td/telegram/JsonValue.h | 39 + .../tdlib/td/td/telegram/LabeledPricePart.h | 47 + .../tdlib/td/td/telegram/LanguagePackManager.cpp | 1920 + .../tdlib/td/td/telegram/LanguagePackManager.h | 201 + .../Telegram/tdlib/td/td/telegram/LinkManager.cpp | 1958 + .../Telegram/tdlib/td/td/telegram/LinkManager.h | 166 + .../Telegram/tdlib/td/td/telegram/Location.cpp | 138 +- protocols/Telegram/tdlib/td/td/telegram/Location.h | 124 +- protocols/Telegram/tdlib/td/td/telegram/Log.cpp | 49 +- protocols/Telegram/tdlib/td/td/telegram/Log.h | 12 +- .../Telegram/tdlib/td/td/telegram/LogDotNet.cpp | 14 +- .../Telegram/tdlib/td/td/telegram/Logging.cpp | 155 + protocols/Telegram/tdlib/td/td/telegram/Logging.h | 36 + .../tdlib/td/td/telegram/MessageContent.cpp | 6244 + .../Telegram/tdlib/td/td/telegram/MessageContent.h | 276 + .../tdlib/td/td/telegram/MessageContentType.cpp | 391 + .../tdlib/td/td/telegram/MessageContentType.h | 91 + .../tdlib/td/td/telegram/MessageCopyOptions.h | 57 + .../Telegram/tdlib/td/td/telegram/MessageDb.cpp | 1260 + .../Telegram/tdlib/td/td/telegram/MessageDb.h | 207 + .../tdlib/td/td/telegram/MessageEntity.cpp | 3883 +- .../Telegram/tdlib/td/td/telegram/MessageEntity.h | 178 +- .../tdlib/td/td/telegram/MessageEntity.hpp | 68 + .../tdlib/td/td/telegram/MessageExtendedMedia.cpp | 328 + .../tdlib/td/td/telegram/MessageExtendedMedia.h | 118 + .../tdlib/td/td/telegram/MessageExtendedMedia.hpp | 115 + .../Telegram/tdlib/td/td/telegram/MessageId.cpp | 165 + .../Telegram/tdlib/td/td/telegram/MessageId.h | 217 +- .../tdlib/td/td/telegram/MessageLinkInfo.h | 33 + .../tdlib/td/td/telegram/MessageReaction.cpp | 1017 + .../tdlib/td/td/telegram/MessageReaction.h | 240 + .../tdlib/td/td/telegram/MessageReaction.hpp | 124 + .../tdlib/td/td/telegram/MessageReplyHeader.cpp | 62 + .../tdlib/td/td/telegram/MessageReplyHeader.h | 29 + .../tdlib/td/td/telegram/MessageReplyInfo.cpp | 232 + .../tdlib/td/td/telegram/MessageReplyInfo.h | 74 + .../tdlib/td/td/telegram/MessageReplyInfo.hpp | 104 + .../tdlib/td/td/telegram/MessageSearchFilter.cpp | 148 + .../tdlib/td/td/telegram/MessageSearchFilter.h | 68 + .../tdlib/td/td/telegram/MessageSender.cpp | 169 + .../Telegram/tdlib/td/td/telegram/MessageSender.h | 44 + .../tdlib/td/td/telegram/MessageThreadDb.cpp | 343 + .../tdlib/td/td/telegram/MessageThreadDb.h | 98 + .../tdlib/td/td/telegram/MessageThreadInfo.h | 22 + .../Telegram/tdlib/td/td/telegram/MessageTtl.cpp | 27 + .../Telegram/tdlib/td/td/telegram/MessageTtl.h | 56 + .../Telegram/tdlib/td/td/telegram/MessagesDb.cpp | 1006 - .../Telegram/tdlib/td/td/telegram/MessagesDb.h | 169 - .../tdlib/td/td/telegram/MessagesManager.cpp | 54773 +++++--- .../tdlib/td/td/telegram/MessagesManager.h | 4094 +- .../Telegram/tdlib/td/td/telegram/MinChannel.h | 21 + .../Telegram/tdlib/td/td/telegram/MinChannel.hpp | 51 + .../tdlib/td/td/telegram/NewPasswordState.cpp | 58 + .../tdlib/td/td/telegram/NewPasswordState.h | 27 + .../Telegram/tdlib/td/td/telegram/Notification.h | 47 + .../tdlib/td/td/telegram/NotificationGroupId.h | 67 + .../tdlib/td/td/telegram/NotificationGroupKey.h | 43 + .../tdlib/td/td/telegram/NotificationGroupType.h | 69 + .../Telegram/tdlib/td/td/telegram/NotificationId.h | 72 + .../tdlib/td/td/telegram/NotificationManager.cpp | 4227 + .../tdlib/td/td/telegram/NotificationManager.h | 417 + .../td/td/telegram/NotificationSettingsManager.cpp | 1504 + .../td/td/telegram/NotificationSettingsManager.h | 217 + .../td/td/telegram/NotificationSettingsScope.cpp | 69 + .../td/td/telegram/NotificationSettingsScope.h | 29 + .../tdlib/td/td/telegram/NotificationSound.cpp | 313 + .../tdlib/td/td/telegram/NotificationSound.h | 67 + .../tdlib/td/td/telegram/NotificationSoundType.h | 15 + .../tdlib/td/td/telegram/NotificationType.cpp | 406 + .../tdlib/td/td/telegram/NotificationType.h | 67 + .../tdlib/td/td/telegram/OptionManager.cpp | 863 + .../Telegram/tdlib/td/td/telegram/OptionManager.h | 94 + .../Telegram/tdlib/td/td/telegram/OrderInfo.cpp | 190 + .../Telegram/tdlib/td/td/telegram/OrderInfo.h | 82 + .../Telegram/tdlib/td/td/telegram/OrderInfo.hpp | 87 + .../tdlib/td/td/telegram/PasswordManager.cpp | 790 +- .../tdlib/td/td/telegram/PasswordManager.h | 143 +- .../Telegram/tdlib/td/td/telegram/Payments.cpp | 660 +- protocols/Telegram/tdlib/td/td/telegram/Payments.h | 152 +- .../Telegram/tdlib/td/td/telegram/Payments.hpp | 134 - .../tdlib/td/td/telegram/PhoneNumberManager.cpp | 263 + .../tdlib/td/td/telegram/PhoneNumberManager.h | 76 + protocols/Telegram/tdlib/td/td/telegram/Photo.cpp | 672 +- protocols/Telegram/tdlib/td/td/telegram/Photo.h | 119 +- protocols/Telegram/tdlib/td/td/telegram/Photo.hpp | 99 +- .../Telegram/tdlib/td/td/telegram/PhotoFormat.h | 15 + .../Telegram/tdlib/td/td/telegram/PhotoSize.cpp | 447 + .../Telegram/tdlib/td/td/telegram/PhotoSize.h | 78 + .../Telegram/tdlib/td/td/telegram/PhotoSize.hpp | 60 + .../tdlib/td/td/telegram/PhotoSizeSource.cpp | 261 + .../tdlib/td/td/telegram/PhotoSizeSource.h | 272 + .../tdlib/td/td/telegram/PhotoSizeSource.hpp | 191 + protocols/Telegram/tdlib/td/td/telegram/PollId.h | 55 + protocols/Telegram/tdlib/td/td/telegram/PollId.hpp | 27 + .../Telegram/tdlib/td/td/telegram/PollManager.cpp | 1862 + .../Telegram/tdlib/td/td/telegram/PollManager.h | 254 + .../Telegram/tdlib/td/td/telegram/PollManager.hpp | 224 + .../Telegram/tdlib/td/td/telegram/Premium.cpp | 545 + protocols/Telegram/tdlib/td/td/telegram/Premium.h | 42 + .../tdlib/td/td/telegram/PremiumGiftOption.cpp | 109 + .../tdlib/td/td/telegram/PremiumGiftOption.h | 58 + .../tdlib/td/td/telegram/PremiumGiftOption.hpp | 77 + .../tdlib/td/td/telegram/PrivacyManager.cpp | 415 +- .../Telegram/tdlib/td/td/telegram/PrivacyManager.h | 91 +- .../Telegram/tdlib/td/td/telegram/PtsManager.h | 9 +- .../tdlib/td/td/telegram/PublicDialogType.h | 22 + .../tdlib/td/td/telegram/QueryCombiner.cpp | 109 + .../Telegram/tdlib/td/td/telegram/QueryCombiner.h | 51 + .../tdlib/td/td/telegram/RecentDialogList.cpp | 275 + .../tdlib/td/td/telegram/RecentDialogList.h | 59 + .../Telegram/tdlib/td/td/telegram/ReplyMarkup.cpp | 395 +- .../Telegram/tdlib/td/td/telegram/ReplyMarkup.h | 48 +- .../Telegram/tdlib/td/td/telegram/ReplyMarkup.hpp | 100 +- .../Telegram/tdlib/td/td/telegram/ReportReason.cpp | 109 + .../Telegram/tdlib/td/td/telegram/ReportReason.h | 61 + .../Telegram/tdlib/td/td/telegram/RequestActor.h | 160 + .../tdlib/td/td/telegram/RestrictionReason.cpp | 101 + .../tdlib/td/td/telegram/RestrictionReason.h | 70 + .../td/td/telegram/ScheduledServerMessageId.h | 65 + .../td/td/telegram/ScopeNotificationSettings.cpp | 74 + .../td/td/telegram/ScopeNotificationSettings.h | 55 + .../td/td/telegram/ScopeNotificationSettings.hpp | 71 + .../tdlib/td/td/telegram/SecretChatActor.cpp | 993 +- .../tdlib/td/td/telegram/SecretChatActor.h | 241 +- .../Telegram/tdlib/td/td/telegram/SecretChatDb.cpp | 2 +- .../Telegram/tdlib/td/td/telegram/SecretChatDb.h | 7 +- .../Telegram/tdlib/td/td/telegram/SecretChatId.h | 9 +- .../tdlib/td/td/telegram/SecretChatLayer.h | 21 + .../tdlib/td/td/telegram/SecretChatsManager.cpp | 346 +- .../tdlib/td/td/telegram/SecretChatsManager.h | 70 +- .../tdlib/td/td/telegram/SecretInputMedia.cpp | 40 + .../tdlib/td/td/telegram/SecretInputMedia.h | 13 +- .../tdlib/td/td/telegram/SecureManager.cpp | 1332 + .../Telegram/tdlib/td/td/telegram/SecureManager.h | 99 + .../tdlib/td/td/telegram/SecureStorage.cpp | 410 + .../Telegram/tdlib/td/td/telegram/SecureStorage.h | 195 + .../Telegram/tdlib/td/td/telegram/SecureValue.cpp | 1470 + .../Telegram/tdlib/td/td/telegram/SecureValue.h | 234 + .../Telegram/tdlib/td/td/telegram/SecureValue.hpp | 159 + .../tdlib/td/td/telegram/SendCodeHelper.cpp | 189 + .../Telegram/tdlib/td/td/telegram/SendCodeHelper.h | 98 + .../tdlib/td/td/telegram/SendCodeHelper.hpp | 55 + .../tdlib/td/td/telegram/SentEmailCode.cpp | 29 + .../Telegram/tdlib/td/td/telegram/SentEmailCode.h | 50 + .../tdlib/td/td/telegram/SequenceDispatcher.cpp | 243 +- .../tdlib/td/td/telegram/SequenceDispatcher.h | 48 +- .../tdlib/td/td/telegram/ServerMessageId.h | 43 + .../tdlib/td/td/telegram/SetWithPosition.h | 228 + .../tdlib/td/td/telegram/SpecialStickerSetType.cpp | 111 + .../tdlib/td/td/telegram/SpecialStickerSetType.h | 66 + .../td/td/telegram/SponsoredMessageManager.cpp | 370 + .../tdlib/td/td/telegram/SponsoredMessageManager.h | 70 + .../Telegram/tdlib/td/td/telegram/StateManager.cpp | 86 +- .../Telegram/tdlib/td/td/telegram/StateManager.h | 94 +- .../tdlib/td/td/telegram/StickerFormat.cpp | 181 + .../Telegram/tdlib/td/td/telegram/StickerFormat.h | 44 + .../Telegram/tdlib/td/td/telegram/StickerSetId.h | 55 + .../Telegram/tdlib/td/td/telegram/StickerSetId.hpp | 27 + .../Telegram/tdlib/td/td/telegram/StickerType.cpp | 66 + .../Telegram/tdlib/td/td/telegram/StickerType.h | 29 + .../tdlib/td/td/telegram/StickersManager.cpp | 9627 +- .../tdlib/td/td/telegram/StickersManager.h | 1043 +- .../tdlib/td/td/telegram/StickersManager.hpp | 530 +- .../tdlib/td/td/telegram/StorageManager.cpp | 265 +- .../Telegram/tdlib/td/td/telegram/StorageManager.h | 77 +- .../tdlib/td/td/telegram/SuggestedAction.cpp | 197 + .../tdlib/td/td/telegram/SuggestedAction.h | 79 + .../Telegram/tdlib/td/td/telegram/Support.cpp | 113 + protocols/Telegram/tdlib/td/td/telegram/Support.h | 24 + protocols/Telegram/tdlib/td/td/telegram/Td.cpp | 9730 +- protocols/Telegram/tdlib/td/td/telegram/Td.h | 1002 +- .../Telegram/tdlib/td/td/telegram/TdCallback.h | 8 +- protocols/Telegram/tdlib/td/td/telegram/TdDb.cpp | 419 +- protocols/Telegram/tdlib/td/td/telegram/TdDb.h | 104 +- .../Telegram/tdlib/td/td/telegram/TdParameters.h | 2 +- .../tdlib/td/td/telegram/TermsOfService.cpp | 121 + .../Telegram/tdlib/td/td/telegram/TermsOfService.h | 74 + .../Telegram/tdlib/td/td/telegram/ThemeManager.cpp | 441 + .../Telegram/tdlib/td/td/telegram/ThemeManager.h | 120 + .../tdlib/td/td/telegram/TopDialogCategory.cpp | 109 + .../tdlib/td/td/telegram/TopDialogCategory.h | 37 + .../tdlib/td/td/telegram/TopDialogManager.cpp | 592 +- .../tdlib/td/td/telegram/TopDialogManager.h | 109 +- .../tdlib/td/td/telegram/TranscriptionInfo.cpp | 207 + .../tdlib/td/td/telegram/TranscriptionInfo.h | 62 + .../tdlib/td/td/telegram/TranscriptionInfo.hpp | 31 + protocols/Telegram/tdlib/td/td/telegram/UniqueId.h | 2 +- .../tdlib/td/td/telegram/UpdatesManager.cpp | 3402 +- .../Telegram/tdlib/td/td/telegram/UpdatesManager.h | 562 +- protocols/Telegram/tdlib/td/td/telegram/UserId.h | 48 +- .../Telegram/tdlib/td/td/telegram/Usernames.cpp | 222 + .../Telegram/tdlib/td/td/telegram/Usernames.h | 142 + protocols/Telegram/tdlib/td/td/telegram/Venue.cpp | 126 + protocols/Telegram/tdlib/td/td/telegram/Venue.h | 92 + protocols/Telegram/tdlib/td/td/telegram/Version.h | 56 +- .../tdlib/td/td/telegram/VideoNotesManager.cpp | 301 +- .../tdlib/td/td/telegram/VideoNotesManager.h | 82 +- .../tdlib/td/td/telegram/VideoNotesManager.hpp | 92 +- .../tdlib/td/td/telegram/VideosManager.cpp | 179 +- .../Telegram/tdlib/td/td/telegram/VideosManager.h | 54 +- .../tdlib/td/td/telegram/VideosManager.hpp | 38 +- .../tdlib/td/td/telegram/VoiceNotesManager.cpp | 272 +- .../tdlib/td/td/telegram/VoiceNotesManager.h | 78 +- .../tdlib/td/td/telegram/VoiceNotesManager.hpp | 81 +- .../Telegram/tdlib/td/td/telegram/WebPageBlock.cpp | 2424 + .../Telegram/tdlib/td/td/telegram/WebPageBlock.h | 107 + .../Telegram/tdlib/td/td/telegram/WebPageId.h | 16 +- .../tdlib/td/td/telegram/WebPagesManager.cpp | 2542 +- .../tdlib/td/td/telegram/WebPagesManager.h | 190 +- protocols/Telegram/tdlib/td/td/telegram/cli.cpp | 6017 +- .../tdlib/td/td/telegram/files/FileBitmask.cpp | 172 + .../tdlib/td/td/telegram/files/FileBitmask.h | 41 + .../Telegram/tdlib/td/td/telegram/files/FileData.h | 60 + .../tdlib/td/td/telegram/files/FileData.hpp | 137 + .../Telegram/tdlib/td/td/telegram/files/FileDb.cpp | 192 +- .../Telegram/tdlib/td/td/telegram/files/FileDb.h | 54 +- .../Telegram/tdlib/td/td/telegram/files/FileDbId.h | 58 + .../tdlib/td/td/telegram/files/FileDownloader.cpp | 241 +- .../tdlib/td/td/telegram/files/FileDownloader.h | 51 +- .../td/td/telegram/files/FileEncryptionKey.cpp | 101 + .../tdlib/td/td/telegram/files/FileEncryptionKey.h | 104 + .../tdlib/td/td/telegram/files/FileFromBytes.cpp | 36 +- .../tdlib/td/td/telegram/files/FileFromBytes.h | 21 +- .../td/td/telegram/files/FileGcParameters.cpp | 42 +- .../tdlib/td/td/telegram/files/FileGcParameters.h | 23 +- .../tdlib/td/td/telegram/files/FileGcWorker.cpp | 167 +- .../tdlib/td/td/telegram/files/FileGcWorker.h | 28 +- .../td/td/telegram/files/FileGenerateManager.cpp | 358 +- .../td/td/telegram/files/FileGenerateManager.h | 33 +- .../td/td/telegram/files/FileHashUploader.cpp | 50 +- .../tdlib/td/td/telegram/files/FileHashUploader.h | 26 +- .../Telegram/tdlib/td/td/telegram/files/FileId.h | 9 +- .../Telegram/tdlib/td/td/telegram/files/FileId.hpp | 3 +- .../tdlib/td/td/telegram/files/FileLoadManager.cpp | 142 +- .../tdlib/td/td/telegram/files/FileLoadManager.h | 113 +- .../tdlib/td/td/telegram/files/FileLoader.cpp | 148 +- .../tdlib/td/td/telegram/files/FileLoader.h | 74 +- .../tdlib/td/td/telegram/files/FileLoaderActor.h | 12 +- .../tdlib/td/td/telegram/files/FileLoaderUtils.cpp | 287 +- .../tdlib/td/td/telegram/files/FileLoaderUtils.h | 48 +- .../tdlib/td/td/telegram/files/FileLocation.h | 997 +- .../tdlib/td/td/telegram/files/FileLocation.hpp | 433 + .../tdlib/td/td/telegram/files/FileManager.cpp | 2953 +- .../tdlib/td/td/telegram/files/FileManager.h | 398 +- .../tdlib/td/td/telegram/files/FileManager.hpp | 118 +- .../tdlib/td/td/telegram/files/FileSourceId.h | 59 + .../tdlib/td/td/telegram/files/FileSourceId.hpp | 28 + .../tdlib/td/td/telegram/files/FileStats.cpp | 165 +- .../tdlib/td/td/telegram/files/FileStats.h | 72 +- .../tdlib/td/td/telegram/files/FileStatsWorker.cpp | 117 +- .../tdlib/td/td/telegram/files/FileStatsWorker.h | 14 +- .../tdlib/td/td/telegram/files/FileType.cpp | 306 + .../Telegram/tdlib/td/td/telegram/files/FileType.h | 68 + .../tdlib/td/td/telegram/files/FileUploader.cpp | 143 +- .../tdlib/td/td/telegram/files/FileUploader.h | 50 +- .../tdlib/td/td/telegram/files/PartsManager.cpp | 360 +- .../tdlib/td/td/telegram/files/PartsManager.h | 71 +- .../tdlib/td/td/telegram/files/ResourceManager.cpp | 25 +- .../tdlib/td/td/telegram/files/ResourceManager.h | 27 +- .../tdlib/td/td/telegram/files/ResourceState.h | 16 +- .../tdlib/td/td/telegram/logevent/LogEvent.h | 222 +- .../td/td/telegram/logevent/LogEventHelper.cpp | 56 + .../tdlib/td/td/telegram/logevent/LogEventHelper.h | 57 + .../td/td/telegram/logevent/SecretChatEvent.h | 334 +- protocols/Telegram/tdlib/td/td/telegram/misc.cpp | 110 +- protocols/Telegram/tdlib/td/td/telegram/misc.h | 21 +- .../tdlib/td/td/telegram/net/AuthDataShared.cpp | 49 +- .../tdlib/td/td/telegram/net/AuthDataShared.h | 37 +- .../tdlib/td/td/telegram/net/ConnectionCreator.cpp | 1255 +- .../tdlib/td/td/telegram/net/ConnectionCreator.h | 275 +- .../tdlib/td/td/telegram/net/DcAuthManager.cpp | 134 +- .../tdlib/td/td/telegram/net/DcAuthManager.h | 35 +- protocols/Telegram/tdlib/td/td/telegram/net/DcId.h | 28 +- .../Telegram/tdlib/td/td/telegram/net/DcOptions.h | 155 +- .../tdlib/td/td/telegram/net/DcOptionsSet.cpp | 89 +- .../tdlib/td/td/telegram/net/DcOptionsSet.h | 29 +- .../tdlib/td/td/telegram/net/MtprotoHeader.cpp | 78 +- .../tdlib/td/td/telegram/net/MtprotoHeader.h | 82 +- .../Telegram/tdlib/td/td/telegram/net/NetActor.cpp | 8 +- .../Telegram/tdlib/td/td/telegram/net/NetActor.h | 15 +- .../Telegram/tdlib/td/td/telegram/net/NetQuery.cpp | 93 +- .../Telegram/tdlib/td/td/telegram/net/NetQuery.h | 210 +- .../tdlib/td/td/telegram/net/NetQueryCounter.cpp | 13 - .../tdlib/td/td/telegram/net/NetQueryCounter.h | 47 +- .../tdlib/td/td/telegram/net/NetQueryCreator.cpp | 76 +- .../tdlib/td/td/telegram/net/NetQueryCreator.h | 48 +- .../tdlib/td/td/telegram/net/NetQueryDelayer.cpp | 57 +- .../tdlib/td/td/telegram/net/NetQueryDelayer.h | 11 +- .../td/td/telegram/net/NetQueryDispatcher.cpp | 227 +- .../tdlib/td/td/telegram/net/NetQueryDispatcher.h | 34 +- .../tdlib/td/td/telegram/net/NetQueryStats.cpp | 56 + .../tdlib/td/td/telegram/net/NetQueryStats.h | 49 + .../tdlib/td/td/telegram/net/NetStatsManager.cpp | 78 +- .../tdlib/td/td/telegram/net/NetStatsManager.h | 56 +- .../Telegram/tdlib/td/td/telegram/net/NetType.h | 15 +- .../Telegram/tdlib/td/td/telegram/net/Proxy.cpp | 70 + .../Telegram/tdlib/td/td/telegram/net/Proxy.h | 163 + .../td/td/telegram/net/PublicRsaKeyShared.cpp | 126 +- .../tdlib/td/td/telegram/net/PublicRsaKeyShared.h | 28 +- .../td/td/telegram/net/PublicRsaKeyWatchdog.cpp | 58 +- .../td/td/telegram/net/PublicRsaKeyWatchdog.h | 17 +- .../Telegram/tdlib/td/td/telegram/net/Session.cpp | 972 +- .../Telegram/tdlib/td/td/telegram/net/Session.h | 172 +- .../tdlib/td/td/telegram/net/SessionMultiProxy.cpp | 74 +- .../tdlib/td/td/telegram/net/SessionMultiProxy.h | 28 +- .../tdlib/td/td/telegram/net/SessionProxy.cpp | 172 +- .../tdlib/td/td/telegram/net/SessionProxy.h | 37 +- .../tdlib/td/td/telegram/net/TempAuthKeyWatchdog.h | 45 +- .../Telegram/tdlib/td/td/telegram/td_c_client.cpp | 43 +- .../Telegram/tdlib/td/td/telegram/td_c_client.h | 22 +- .../tdlib/td/td/telegram/td_emscripten.cpp | 37 +- .../tdlib/td/td/telegram/td_json_client.cpp | 43 +- .../Telegram/tdlib/td/td/telegram/td_json_client.h | 128 +- protocols/Telegram/tdlib/td/td/telegram/td_log.cpp | 2 +- protocols/Telegram/tdlib/td/td/telegram/td_log.h | 20 +- protocols/Telegram/tdlib/td/td/tl/TlObject.h | 103 +- .../Telegram/tdlib/td/td/tl/tl_dotnet_object.h | 44 +- .../Telegram/tdlib/td/td/tl/tl_jni_object.cpp | 48 +- protocols/Telegram/tdlib/td/td/tl/tl_jni_object.h | 38 +- protocols/Telegram/tdlib/td/td/tl/tl_json.h | 139 +- .../Telegram/tdlib/td/td/tl/tl_object_parse.h | 70 +- .../Telegram/tdlib/td/td/tl/tl_object_store.h | 45 +- protocols/Telegram/tdlib/td/tdactor/CMakeLists.txt | 39 +- .../Telegram/tdlib/td/tdactor/example/example.cpp | 28 +- .../td/tdactor/td/actor/ConcurrentScheduler.cpp | 205 + .../td/tdactor/td/actor/ConcurrentScheduler.h | 116 + .../Telegram/tdlib/td/tdactor/td/actor/Condition.h | 47 - .../tdlib/td/tdactor/td/actor/MultiPromise.cpp | 25 +- .../tdlib/td/tdactor/td/actor/MultiPromise.h | 72 +- .../tdlib/td/tdactor/td/actor/MultiTimeout.cpp | 110 + .../tdlib/td/tdactor/td/actor/MultiTimeout.h | 81 + .../tdlib/td/tdactor/td/actor/PromiseFuture.h | 360 +- .../td/tdactor/td/actor/SchedulerLocalStorage.h | 15 +- .../tdlib/td/tdactor/td/actor/SignalSlot.h | 18 +- .../tdlib/td/tdactor/td/actor/SleepActor.h | 18 +- .../Telegram/tdlib/td/tdactor/td/actor/Timeout.cpp | 96 - .../Telegram/tdlib/td/tdactor/td/actor/Timeout.h | 83 +- .../Telegram/tdlib/td/tdactor/td/actor/actor.h | 3 +- .../tdlib/td/tdactor/td/actor/impl/Actor-decl.h | 20 +- .../tdlib/td/tdactor/td/actor/impl/Actor.h | 46 +- .../tdlib/td/tdactor/td/actor/impl/ActorId-decl.h | 72 +- .../tdlib/td/tdactor/td/actor/impl/ActorId.h | 69 +- .../td/tdactor/td/actor/impl/ActorInfo-decl.h | 35 +- .../tdlib/td/tdactor/td/actor/impl/ActorInfo.h | 65 +- .../tdactor/td/actor/impl/ConcurrentScheduler.cpp | 102 - .../td/tdactor/td/actor/impl/ConcurrentScheduler.h | 93 - .../tdlib/td/tdactor/td/actor/impl/Event.h | 70 +- .../td/tdactor/td/actor/impl/EventFull-decl.h | 6 +- .../tdlib/td/tdactor/td/actor/impl/EventFull.h | 4 +- .../td/tdactor/td/actor/impl/Scheduler-decl.h | 149 +- .../tdlib/td/tdactor/td/actor/impl/Scheduler.cpp | 250 +- .../tdlib/td/tdactor/td/actor/impl/Scheduler.h | 213 +- .../tdlib/td/tdactor/td/actor/impl2/ActorLocker.h | 117 - .../tdlib/td/tdactor/td/actor/impl2/ActorSignals.h | 84 - .../tdlib/td/tdactor/td/actor/impl2/ActorState.h | 166 - .../tdlib/td/tdactor/td/actor/impl2/Scheduler.cpp | 11 - .../tdlib/td/tdactor/td/actor/impl2/Scheduler.h | 1508 - .../tdlib/td/tdactor/td/actor/impl2/SchedulerId.h | 32 - .../Telegram/tdlib/td/tdactor/test/actors_bugs.cpp | 93 +- .../tdlib/td/tdactor/test/actors_impl2.cpp | 535 - .../Telegram/tdlib/td/tdactor/test/actors_main.cpp | 322 +- .../tdlib/td/tdactor/test/actors_simple.cpp | 428 +- .../tdlib/td/tdactor/test/actors_workers.cpp | 87 +- .../Telegram/tdlib/td/tdclientjson_export_list | 5 + protocols/Telegram/tdlib/td/tddb/CMakeLists.txt | 23 +- .../Telegram/tdlib/td/tddb/td/db/BinlogKeyValue.h | 110 +- protocols/Telegram/tdlib/td/tddb/td/db/DbKey.h | 28 +- .../tdlib/td/tddb/td/db/KeyValueSyncInterface.h | 17 +- protocols/Telegram/tdlib/td/tddb/td/db/Pmc.h | 27 - .../Telegram/tdlib/td/tddb/td/db/SeqKeyValue.h | 26 +- .../tdlib/td/tddb/td/db/SqliteConnectionSafe.cpp | 51 + .../tdlib/td/tddb/td/db/SqliteConnectionSafe.h | 48 +- .../Telegram/tdlib/td/tddb/td/db/SqliteDb.cpp | 215 +- protocols/Telegram/tdlib/td/tddb/td/db/SqliteDb.h | 47 +- .../tdlib/td/tddb/td/db/SqliteKeyValue.cpp | 124 + .../Telegram/tdlib/td/tddb/td/db/SqliteKeyValue.h | 184 +- .../tdlib/td/tddb/td/db/SqliteKeyValueAsync.cpp | 75 +- .../tdlib/td/tddb/td/db/SqliteKeyValueAsync.h | 22 +- .../tdlib/td/tddb/td/db/SqliteKeyValueSafe.h | 4 +- .../tdlib/td/tddb/td/db/SqliteStatement.cpp | 84 +- .../Telegram/tdlib/td/tddb/td/db/SqliteStatement.h | 32 +- protocols/Telegram/tdlib/td/tddb/td/db/TQueue.cpp | 558 + protocols/Telegram/tdlib/td/tddb/td/db/TQueue.h | 155 + .../Telegram/tdlib/td/tddb/td/db/TsSeqKeyValue.h | 25 +- .../Telegram/tdlib/td/tddb/td/db/binlog/Binlog.cpp | 304 +- .../Telegram/tdlib/td/tddb/td/db/binlog/Binlog.h | 54 +- .../tdlib/td/tddb/td/db/binlog/BinlogEvent.cpp | 56 +- .../tdlib/td/tddb/td/db/binlog/BinlogEvent.h | 74 +- .../tdlib/td/tddb/td/db/binlog/BinlogHelper.h | 47 +- .../tdlib/td/tddb/td/db/binlog/BinlogInterface.h | 42 +- .../td/tddb/td/db/binlog/ConcurrentBinlog.cpp | 53 +- .../tdlib/td/tddb/td/db/binlog/ConcurrentBinlog.h | 36 +- .../tdlib/td/tddb/td/db/binlog/binlog_dump.cpp | 138 +- .../td/db/binlog/detail/BinlogEventsBuffer.cpp | 6 +- .../tddb/td/db/binlog/detail/BinlogEventsBuffer.h | 8 +- .../td/db/binlog/detail/BinlogEventsProcessor.cpp | 23 +- .../td/db/binlog/detail/BinlogEventsProcessor.h | 15 +- .../tdlib/td/tddb/td/db/detail/RawSqliteDb.cpp | 39 +- .../tdlib/td/tddb/td/db/detail/RawSqliteDb.h | 45 +- protocols/Telegram/tdlib/td/tdnet/CMakeLists.txt | 54 +- .../Telegram/tdlib/td/tdnet/td/net/DarwinHttp.h | 21 + .../Telegram/tdlib/td/tdnet/td/net/DarwinHttp.mm | 68 + .../tdlib/td/tdnet/td/net/GetHostByNameActor.cpp | 220 +- .../tdlib/td/tdnet/td/net/GetHostByNameActor.h | 68 +- .../tdlib/td/tdnet/td/net/HttpChunkedByteFlow.cpp | 63 +- .../tdlib/td/tdnet/td/net/HttpChunkedByteFlow.h | 17 +- .../tdlib/td/tdnet/td/net/HttpConnectionBase.cpp | 127 +- .../tdlib/td/tdnet/td/net/HttpConnectionBase.h | 159 +- .../td/tdnet/td/net/HttpContentLengthByteFlow.cpp | 14 +- .../td/tdnet/td/net/HttpContentLengthByteFlow.h | 4 +- .../Telegram/tdlib/td/tdnet/td/net/HttpFile.cpp | 2 +- .../Telegram/tdlib/td/tdnet/td/net/HttpFile.h | 4 +- .../tdlib/td/tdnet/td/net/HttpHeaderCreator.h | 34 +- .../td/tdnet/td/net/HttpInboundConnection.cpp | 18 +- .../tdlib/td/tdnet/td/net/HttpInboundConnection.h | 19 +- .../td/tdnet/td/net/HttpOutboundConnection.cpp | 8 +- .../tdlib/td/tdnet/td/net/HttpOutboundConnection.h | 25 +- .../Telegram/tdlib/td/tdnet/td/net/HttpProxy.cpp | 110 + .../Telegram/tdlib/td/tdnet/td/net/HttpProxy.h | 28 + .../Telegram/tdlib/td/tdnet/td/net/HttpQuery.cpp | 38 +- .../Telegram/tdlib/td/tdnet/td/net/HttpQuery.h | 31 +- .../Telegram/tdlib/td/tdnet/td/net/HttpReader.cpp | 327 +- .../Telegram/tdlib/td/tdnet/td/net/HttpReader.h | 52 +- .../Telegram/tdlib/td/tdnet/td/net/NetStats.h | 15 +- .../Telegram/tdlib/td/tdnet/td/net/Socks5.cpp | 133 +- protocols/Telegram/tdlib/td/tdnet/td/net/Socks5.h | 44 +- .../Telegram/tdlib/td/tdnet/td/net/SslCtx.cpp | 312 + protocols/Telegram/tdlib/td/tdnet/td/net/SslCtx.h | 45 + protocols/Telegram/tdlib/td/tdnet/td/net/SslFd.cpp | 280 - protocols/Telegram/tdlib/td/tdnet/td/net/SslFd.h | 109 - .../Telegram/tdlib/td/tdnet/td/net/SslStream.cpp | 420 + .../Telegram/tdlib/td/tdnet/td/net/SslStream.h | 46 + .../Telegram/tdlib/td/tdnet/td/net/TcpListener.cpp | 26 +- .../Telegram/tdlib/td/tdnet/td/net/TcpListener.h | 14 +- .../tdlib/td/tdnet/td/net/TransparentProxy.cpp | 84 + .../tdlib/td/tdnet/td/net/TransparentProxy.h | 57 + protocols/Telegram/tdlib/td/tdnet/td/net/Wget.cpp | 96 +- protocols/Telegram/tdlib/td/tdnet/td/net/Wget.h | 35 +- protocols/Telegram/tdlib/td/tdtl/CMakeLists.txt | 4 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_config.cpp | 9 +- protocols/Telegram/tdlib/td/tdtl/td/tl/tl_config.h | 8 +- protocols/Telegram/tdlib/td/tdtl/td/tl/tl_core.cpp | 4 +- protocols/Telegram/tdlib/td/tdtl/td/tl/tl_core.h | 2 +- .../tdlib/td/tdtl/td/tl/tl_file_outputer.cpp | 4 +- .../tdlib/td/tdtl/td/tl/tl_file_outputer.h | 4 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_file_utils.cpp | 17 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_file_utils.h | 2 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_generate.cpp | 163 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_generate.h | 9 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_outputer.cpp | 4 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_outputer.h | 2 +- protocols/Telegram/tdlib/td/tdtl/td/tl/tl_simple.h | 72 +- .../tdlib/td/tdtl/td/tl/tl_simple_parser.h | 4 +- .../tdlib/td/tdtl/td/tl/tl_string_outputer.cpp | 17 +- .../tdlib/td/tdtl/td/tl/tl_string_outputer.h | 6 +- .../Telegram/tdlib/td/tdtl/td/tl/tl_writer.cpp | 16 +- protocols/Telegram/tdlib/td/tdtl/td/tl/tl_writer.h | 21 +- protocols/Telegram/tdlib/td/tdutils/CMakeLists.txt | 214 +- .../tdlib/td/tdutils/generate/CMakeLists.txt | 20 +- .../tdutils/generate/generate_mime_types_gperf.cpp | 22 +- .../tdlib/td/tdutils/generate/mime_types.txt | 28 +- .../tdlib/td/tdutils/td/utils/AesCtrByteFlow.h | 26 +- .../tdlib/td/tdutils/td/utils/AsyncFileLog.cpp | 160 + .../tdlib/td/tdutils/td/utils/AsyncFileLog.h | 51 + .../tdlib/td/tdutils/td/utils/AtomicRead.h | 89 + .../Telegram/tdlib/td/tdutils/td/utils/BigNum.cpp | 104 +- .../Telegram/tdlib/td/tdutils/td/utils/BigNum.h | 30 +- .../tdlib/td/tdutils/td/utils/BufferedFd.h | 62 +- .../tdlib/td/tdutils/td/utils/BufferedReader.h | 16 +- .../tdlib/td/tdutils/td/utils/BufferedUdp.cpp | 17 + .../tdlib/td/tdutils/td/utils/BufferedUdp.h | 177 + .../Telegram/tdlib/td/tdutils/td/utils/ByteFlow.h | 139 +- .../tdlib/td/tdutils/td/utils/CancellationToken.h | 71 + .../tdlib/td/tdutils/td/utils/ChainScheduler.h | 376 + .../tdlib/td/tdutils/td/utils/ChangesProcessor.h | 2 +- .../Telegram/tdlib/td/tdutils/td/utils/Closure.h | 84 +- .../tdlib/td/tdutils/td/utils/CombinedLog.h | 86 + .../td/tdutils/td/utils/ConcurrentHashTable.h | 322 + .../Telegram/tdlib/td/tdutils/td/utils/Container.h | 7 +- .../Telegram/tdlib/td/tdutils/td/utils/Context.h | 44 + .../Telegram/tdlib/td/tdutils/td/utils/DecTree.h | 216 + .../tdlib/td/tdutils/td/utils/Destructor.h | 52 + .../tdlib/td/tdutils/td/utils/Enumerator.h | 20 +- .../tdutils/td/utils/EpochBasedMemoryReclamation.h | 201 + .../tdlib/td/tdutils/td/utils/ExitGuard.cpp | 20 + .../Telegram/tdlib/td/tdutils/td/utils/ExitGuard.h | 30 + .../Telegram/tdlib/td/tdutils/td/utils/FileLog.cpp | 124 +- .../Telegram/tdlib/td/tdutils/td/utils/FileLog.h | 33 +- .../tdlib/td/tdutils/td/utils/FlatHashMap.h | 24 + .../tdlib/td/tdutils/td/utils/FlatHashMapChunks.h | 575 + .../tdlib/td/tdutils/td/utils/FlatHashSet.h | 24 + .../tdlib/td/tdutils/td/utils/FlatHashTable.cpp | 24 + .../tdlib/td/tdutils/td/utils/FlatHashTable.h | 551 + .../tdlib/td/tdutils/td/utils/FloodControlFast.h | 81 +- .../td/tdutils/td/utils/FloodControlGlobal.cpp | 32 + .../tdlib/td/tdutils/td/utils/FloodControlGlobal.h | 35 + .../tdlib/td/tdutils/td/utils/FloodControlStrict.h | 38 +- .../Telegram/tdlib/td/tdutils/td/utils/GitInfo.cpp | 20 - .../Telegram/tdlib/td/tdutils/td/utils/GitInfo.h | 19 - .../Telegram/tdlib/td/tdutils/td/utils/Gzip.cpp | 59 +- .../Telegram/tdlib/td/tdutils/td/utils/Gzip.h | 20 +- .../tdlib/td/tdutils/td/utils/GzipByteFlow.cpp | 83 +- .../tdlib/td/tdutils/td/utils/GzipByteFlow.h | 7 +- .../Telegram/tdlib/td/tdutils/td/utils/Hash.h | 70 + .../Telegram/tdlib/td/tdutils/td/utils/HashMap.h | 27 + .../Telegram/tdlib/td/tdutils/td/utils/HashSet.h | 27 + .../tdlib/td/tdutils/td/utils/HashTableUtils.h | 72 + .../tdlib/td/tdutils/td/utils/HazardPointers.h | 54 +- .../Telegram/tdlib/td/tdutils/td/utils/Heap.h | 67 +- .../Telegram/tdlib/td/tdutils/td/utils/Hints.cpp | 125 +- .../Telegram/tdlib/td/tdutils/td/utils/Hints.h | 21 +- .../Telegram/tdlib/td/tdutils/td/utils/HttpUrl.cpp | 134 +- .../Telegram/tdlib/td/tdutils/td/utils/HttpUrl.h | 43 +- .../tdlib/td/tdutils/td/utils/JsonBuilder.cpp | 100 +- .../tdlib/td/tdutils/td/utils/JsonBuilder.h | 230 +- .../Telegram/tdlib/td/tdutils/td/utils/List.h | 63 +- .../Telegram/tdlib/td/tdutils/td/utils/MapNode.h | 166 + .../Telegram/tdlib/td/tdutils/td/utils/MemoryLog.h | 60 +- .../tdlib/td/tdutils/td/utils/MimeType.cpp | 2 +- .../Telegram/tdlib/td/tdutils/td/utils/MimeType.h | 2 +- .../tdlib/td/tdutils/td/utils/MovableValue.h | 16 +- .../tdlib/td/tdutils/td/utils/MpmcQueue.cpp | 15 + .../Telegram/tdlib/td/tdutils/td/utils/MpmcQueue.h | 56 +- .../tdlib/td/tdutils/td/utils/MpmcWaiter.h | 281 +- .../tdlib/td/tdutils/td/utils/MpscLinkQueue.h | 13 +- .../tdlib/td/tdutils/td/utils/MpscPollableQueue.h | 65 +- .../Telegram/tdlib/td/tdutils/td/utils/Named.h | 2 +- .../Telegram/tdlib/td/tdutils/td/utils/NullLog.h | 19 + .../tdlib/td/tdutils/td/utils/ObjectPool.h | 14 +- .../Telegram/tdlib/td/tdutils/td/utils/Observer.h | 6 +- .../tdlib/td/tdutils/td/utils/OptionParser.cpp | 263 + .../tdlib/td/tdutils/td/utils/OptionParser.h | 81 + .../tdlib/td/tdutils/td/utils/OptionsParser.h | 150 - .../td/tdutils/td/utils/OrderedEventsProcessor.h | 16 +- .../Telegram/tdlib/td/tdutils/td/utils/Parser.h | 104 +- .../tdlib/td/tdutils/td/utils/PathView.cpp | 70 + .../Telegram/tdlib/td/tdutils/td/utils/PathView.h | 57 +- .../Telegram/tdlib/td/tdutils/td/utils/Promise.h | 373 + .../Telegram/tdlib/td/tdutils/td/utils/Random.cpp | 119 +- .../Telegram/tdlib/td/tdutils/td/utils/Random.h | 45 +- .../tdlib/td/tdutils/td/utils/ScopeGuard.h | 15 +- .../Telegram/tdlib/td/tdutils/td/utils/SetNode.h | 129 + .../tdlib/td/tdutils/td/utils/SharedObjectPool.h | 52 +- .../tdlib/td/tdutils/td/utils/SharedSlice.cpp | 17 + .../tdlib/td/tdutils/td/utils/SharedSlice.h | 382 + .../tdlib/td/tdutils/td/utils/Slice-decl.h | 49 +- .../Telegram/tdlib/td/tdutils/td/utils/Slice.cpp | 34 + .../Telegram/tdlib/td/tdutils/td/utils/Slice.h | 90 +- .../tdlib/td/tdutils/td/utils/SliceBuilder.h | 57 + .../Telegram/tdlib/td/tdutils/td/utils/Span.h | 158 + .../Telegram/tdlib/td/tdutils/td/utils/SpinLock.h | 8 +- .../tdlib/td/tdutils/td/utils/StackAllocator.cpp | 72 +- .../tdlib/td/tdutils/td/utils/StackAllocator.h | 79 +- .../Telegram/tdlib/td/tdutils/td/utils/Status.cpp | 40 +- .../Telegram/tdlib/td/tdutils/td/utils/Status.h | 253 +- .../tdlib/td/tdutils/td/utils/StealingQueue.h | 125 + .../Telegram/tdlib/td/tdutils/td/utils/Storer.h | 22 +- .../tdlib/td/tdutils/td/utils/StorerBase.h | 4 +- .../tdlib/td/tdutils/td/utils/StringBuilder.cpp | 151 +- .../tdlib/td/tdutils/td/utils/StringBuilder.h | 75 +- .../tdlib/td/tdutils/td/utils/ThreadLocalStorage.h | 55 + .../tdlib/td/tdutils/td/utils/ThreadSafeCounter.h | 132 + .../Telegram/tdlib/td/tdutils/td/utils/Time.cpp | 36 +- .../Telegram/tdlib/td/tdutils/td/utils/Time.h | 50 +- .../Telegram/tdlib/td/tdutils/td/utils/TimedStat.h | 36 +- .../Telegram/tdlib/td/tdutils/td/utils/Timer.cpp | 41 +- .../Telegram/tdlib/td/tdutils/td/utils/Timer.h | 19 +- .../tdlib/td/tdutils/td/utils/TlDowncastHelper.h | 29 + .../tdlib/td/tdutils/td/utils/TlStorerToString.h | 180 + .../Telegram/tdlib/td/tdutils/td/utils/TsCerr.cpp | 64 + .../Telegram/tdlib/td/tdutils/td/utils/TsCerr.h | 33 + .../tdlib/td/tdutils/td/utils/TsFileLog.cpp | 106 + .../Telegram/tdlib/td/tdutils/td/utils/TsFileLog.h | 23 + .../Telegram/tdlib/td/tdutils/td/utils/TsList.h | 214 + .../Telegram/tdlib/td/tdutils/td/utils/TsLog.cpp | 21 + .../Telegram/tdlib/td/tdutils/td/utils/TsLog.h | 55 + .../Telegram/tdlib/td/tdutils/td/utils/UInt.h | 91 + .../Telegram/tdlib/td/tdutils/td/utils/Variant.h | 28 +- .../tdlib/td/tdutils/td/utils/VectorQueue.h | 94 + .../tdlib/td/tdutils/td/utils/WaitFreeHashMap.h | 190 + .../tdlib/td/tdutils/td/utils/WaitFreeHashSet.h | 141 + .../tdlib/td/tdutils/td/utils/WaitFreeVector.h | 69 + .../Telegram/tdlib/td/tdutils/td/utils/algorithm.h | 217 + protocols/Telegram/tdlib/td/tdutils/td/utils/as.h | 81 + .../Telegram/tdlib/td/tdutils/td/utils/base64.cpp | 289 +- .../Telegram/tdlib/td/tdutils/td/utils/base64.h | 11 +- .../Telegram/tdlib/td/tdutils/td/utils/benchmark.h | 18 +- .../Telegram/tdlib/td/tdutils/td/utils/bits.h | 310 + .../Telegram/tdlib/td/tdutils/td/utils/buffer.cpp | 118 +- .../Telegram/tdlib/td/tdutils/td/utils/buffer.h | 206 +- .../Telegram/tdlib/td/tdutils/td/utils/check.cpp | 23 + .../Telegram/tdlib/td/tdutils/td/utils/check.h | 32 + .../Telegram/tdlib/td/tdutils/td/utils/common.h | 45 +- .../Telegram/tdlib/td/tdutils/td/utils/config.h | 5 + .../Telegram/tdlib/td/tdutils/td/utils/config.h.in | 5 + .../Telegram/tdlib/td/tdutils/td/utils/crypto.cpp | 1115 +- .../Telegram/tdlib/td/tdutils/td/utils/crypto.h | 143 +- .../Telegram/tdlib/td/tdutils/td/utils/emoji.cpp | 302 + .../Telegram/tdlib/td/tdutils/td/utils/emoji.h | 32 + .../tdlib/td/tdutils/td/utils/filesystem.cpp | 96 +- .../tdlib/td/tdutils/td/utils/filesystem.h | 22 +- .../tdlib/td/tdutils/td/utils/find_boundary.cpp | 8 +- .../tdlib/td/tdutils/td/utils/find_boundary.h | 2 +- .../tdlib/td/tdutils/td/utils/fixed_vector.h | 79 + .../Telegram/tdlib/td/tdutils/td/utils/format.h | 68 +- .../Telegram/tdlib/td/tdutils/td/utils/int_types.h | 22 +- .../Telegram/tdlib/td/tdutils/td/utils/invoke.h | 72 +- .../Telegram/tdlib/td/tdutils/td/utils/logging.cpp | 271 +- .../Telegram/tdlib/td/tdutils/td/utils/logging.h | 244 +- .../Telegram/tdlib/td/tdutils/td/utils/misc.cpp | 200 +- .../Telegram/tdlib/td/tdutils/td/utils/misc.h | 179 +- .../Telegram/tdlib/td/tdutils/td/utils/optional.h | 71 +- .../tdlib/td/tdutils/td/utils/overloaded.h | 4 +- .../tdlib/td/tdutils/td/utils/port/Clocks.cpp | 81 +- .../tdlib/td/tdutils/td/utils/port/Clocks.h | 19 +- .../tdlib/td/tdutils/td/utils/port/CxCli.h | 65 +- .../tdlib/td/tdutils/td/utils/port/EventFd.h | 2 +- .../tdlib/td/tdutils/td/utils/port/EventFdBase.h | 8 +- .../Telegram/tdlib/td/tdutils/td/utils/port/Fd.cpp | 1104 - .../Telegram/tdlib/td/tdutils/td/utils/port/Fd.h | 226 - .../tdlib/td/tdutils/td/utils/port/FileFd.cpp | 481 +- .../tdlib/td/tdutils/td/utils/port/FileFd.h | 50 +- .../tdlib/td/tdutils/td/utils/port/FromApp.h | 100 + .../tdlib/td/tdutils/td/utils/port/IPAddress.cpp | 473 +- .../tdlib/td/tdutils/td/utils/port/IPAddress.h | 52 +- .../tdlib/td/tdutils/td/utils/port/IoSlice.h | 42 + .../td/tdutils/td/utils/port/MemoryMapping.cpp | 109 + .../tdlib/td/tdutils/td/utils/port/MemoryMapping.h | 52 + .../tdlib/td/tdutils/td/utils/port/Mutex.h | 30 + .../Telegram/tdlib/td/tdutils/td/utils/port/Poll.h | 2 +- .../tdlib/td/tdutils/td/utils/port/PollBase.h | 11 +- .../tdlib/td/tdutils/td/utils/port/PollFlags.cpp | 71 + .../tdlib/td/tdutils/td/utils/port/PollFlags.h | 122 + .../tdlib/td/tdutils/td/utils/port/RwMutex.h | 10 +- .../td/tdutils/td/utils/port/ServerSocketFd.cpp | 384 +- .../td/tdutils/td/utils/port/ServerSocketFd.h | 35 +- .../tdlib/td/tdutils/td/utils/port/SocketFd.cpp | 683 +- .../tdlib/td/tdutils/td/utils/port/SocketFd.h | 53 +- .../tdlib/td/tdutils/td/utils/port/Stat.cpp | 142 +- .../Telegram/tdlib/td/tdutils/td/utils/port/Stat.h | 26 +- .../tdlib/td/tdutils/td/utils/port/StdStreams.cpp | 251 + .../tdlib/td/tdutils/td/utils/port/StdStreams.h | 49 + .../tdlib/td/tdutils/td/utils/port/UdpSocketFd.cpp | 873 + .../tdlib/td/tdutils/td/utils/port/UdpSocketFd.h | 93 + .../tdlib/td/tdutils/td/utils/port/config.h | 21 +- .../td/tdutils/td/utils/port/detail/Epoll.cpp | 82 +- .../tdlib/td/tdutils/td/utils/port/detail/Epoll.h | 30 +- .../td/tdutils/td/utils/port/detail/EventFdBsd.cpp | 45 +- .../td/tdutils/td/utils/port/detail/EventFdBsd.h | 26 +- .../tdutils/td/utils/port/detail/EventFdLinux.cpp | 94 +- .../td/tdutils/td/utils/port/detail/EventFdLinux.h | 29 +- .../td/utils/port/detail/EventFdWindows.cpp | 41 +- .../tdutils/td/utils/port/detail/EventFdWindows.h | 24 +- .../tdlib/td/tdutils/td/utils/port/detail/Iocp.cpp | 110 + .../tdlib/td/tdutils/td/utils/port/detail/Iocp.h | 71 + .../td/tdutils/td/utils/port/detail/KQueue.cpp | 115 +- .../tdlib/td/tdutils/td/utils/port/detail/KQueue.h | 38 +- .../td/tdutils/td/utils/port/detail/NativeFd.cpp | 261 + .../td/tdutils/td/utils/port/detail/NativeFd.h | 68 + .../tdlib/td/tdutils/td/utils/port/detail/Poll.cpp | 44 +- .../tdlib/td/tdutils/td/utils/port/detail/Poll.h | 24 +- .../td/tdutils/td/utils/port/detail/PollableFd.h | 230 + .../td/tdutils/td/utils/port/detail/Select.cpp | 49 +- .../tdlib/td/tdutils/td/utils/port/detail/Select.h | 27 +- .../tdutils/td/utils/port/detail/ThreadIdGuard.cpp | 34 +- .../tdutils/td/utils/port/detail/ThreadIdGuard.h | 2 +- .../tdutils/td/utils/port/detail/ThreadPthread.cpp | 217 + .../tdutils/td/utils/port/detail/ThreadPthread.h | 83 +- .../td/tdutils/td/utils/port/detail/ThreadStl.h | 99 +- .../tdutils/td/utils/port/detail/WineventPoll.cpp | 70 +- .../td/tdutils/td/utils/port/detail/WineventPoll.h | 28 +- .../td/tdutils/td/utils/port/detail/skip_eintr.h | 63 + .../tdlib/td/tdutils/td/utils/port/path.cpp | 304 +- .../Telegram/tdlib/td/tdutils/td/utils/port/path.h | 223 +- .../tdlib/td/tdutils/td/utils/port/platform.cpp | 25 + .../tdlib/td/tdutils/td/utils/port/platform.h | 29 +- .../tdlib/td/tdutils/td/utils/port/rlimit.cpp | 97 + .../tdlib/td/tdutils/td/utils/port/rlimit.h | 20 + .../tdlib/td/tdutils/td/utils/port/signals.cpp | 88 +- .../tdlib/td/tdutils/td/utils/port/signals.h | 6 +- .../tdlib/td/tdutils/td/utils/port/sleep.cpp | 2 +- .../tdlib/td/tdutils/td/utils/port/sleep.h | 2 +- .../tdlib/td/tdutils/td/utils/port/stacktrace.cpp | 139 + .../tdlib/td/tdutils/td/utils/port/stacktrace.h | 23 + .../tdlib/td/tdutils/td/utils/port/thread.h | 5 +- .../td/tdutils/td/utils/port/thread_local.cpp | 12 +- .../tdlib/td/tdutils/td/utils/port/thread_local.h | 18 +- .../tdlib/td/tdutils/td/utils/port/uname.cpp | 289 + .../tdlib/td/tdutils/td/utils/port/uname.h | 15 + .../tdlib/td/tdutils/td/utils/port/user.cpp | 57 + .../Telegram/tdlib/td/tdutils/td/utils/port/user.h | 16 + .../td/tdutils/td/utils/port/wstring_convert.cpp | 111 +- .../td/tdutils/td/utils/port/wstring_convert.h | 4 +- .../Telegram/tdlib/td/tdutils/td/utils/queue.h | 40 +- .../Telegram/tdlib/td/tdutils/td/utils/tests.cpp | 271 + .../Telegram/tdlib/td/tdutils/td/utils/tests.h | 258 +- .../tdlib/td/tdutils/td/utils/tl_helpers.h | 148 +- .../tdlib/td/tdutils/td/utils/tl_parsers.cpp | 38 +- .../tdlib/td/tdutils/td/utils/tl_parsers.h | 98 +- .../tdlib/td/tdutils/td/utils/tl_storers.h | 211 +- .../tdlib/td/tdutils/td/utils/translit.cpp | 115 + .../Telegram/tdlib/td/tdutils/td/utils/translit.h | 16 + .../tdlib/td/tdutils/td/utils/type_traits.h | 25 +- .../Telegram/tdlib/td/tdutils/td/utils/uint128.h | 293 + .../Telegram/tdlib/td/tdutils/td/utils/unicode.cpp | 1484 +- .../Telegram/tdlib/td/tdutils/td/utils/unicode.h | 9 +- .../tdlib/td/tdutils/td/utils/unique_ptr.h | 106 + .../Telegram/tdlib/td/tdutils/td/utils/utf8.cpp | 117 +- .../Telegram/tdlib/td/tdutils/td/utils/utf8.h | 48 +- .../tdlib/td/tdutils/test/ChainScheduler.cpp | 244 + .../tdlib/td/tdutils/test/ConcurrentHashMap.cpp | 252 + .../Telegram/tdlib/td/tdutils/test/Enumerator.cpp | 2 +- .../tdutils/test/EpochBasedMemoryReclamation.cpp | 68 + .../Telegram/tdlib/td/tdutils/test/HashSet.cpp | 438 + .../tdlib/td/tdutils/test/HazardPointers.cpp | 16 +- .../Telegram/tdlib/td/tdutils/test/HttpUrl.cpp | 54 + protocols/Telegram/tdlib/td/tdutils/test/List.cpp | 169 + .../Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp | 24 +- .../Telegram/tdlib/td/tdutils/test/MpmcWaiter.cpp | 60 +- .../tdlib/td/tdutils/test/MpscLinkQueue.cpp | 17 +- .../tdlib/td/tdutils/test/OptionParser.cpp | 82 + .../td/tdutils/test/OrderedEventsProcessor.cpp | 6 +- .../tdlib/td/tdutils/test/SharedObjectPool.cpp | 25 +- .../Telegram/tdlib/td/tdutils/test/SharedSlice.cpp | 91 + .../tdlib/td/tdutils/test/StealingQueue.cpp | 180 + .../tdlib/td/tdutils/test/WaitFreeHashMap.cpp | 95 + .../tdlib/td/tdutils/test/WaitFreeHashSet.cpp | 73 + .../tdlib/td/tdutils/test/WaitFreeVector.cpp | 69 + .../Telegram/tdlib/td/tdutils/test/bitmask.cpp | 249 + .../Telegram/tdlib/td/tdutils/test/buffer.cpp | 56 + .../Telegram/tdlib/td/tdutils/test/crypto.cpp | 333 +- protocols/Telegram/tdlib/td/tdutils/test/emoji.cpp | 128 + .../Telegram/tdlib/td/tdutils/test/filesystem.cpp | 68 +- protocols/Telegram/tdlib/td/tdutils/test/gzip.cpp | 188 +- .../tdlib/td/tdutils/test/hashset_benchmark.cpp | 647 + protocols/Telegram/tdlib/td/tdutils/test/heap.cpp | 47 +- protocols/Telegram/tdlib/td/tdutils/test/json.cpp | 34 +- protocols/Telegram/tdlib/td/tdutils/test/log.cpp | 187 + protocols/Telegram/tdlib/td/tdutils/test/misc.cpp | 1218 +- protocols/Telegram/tdlib/td/tdutils/test/port.cpp | 316 + protocols/Telegram/tdlib/td/tdutils/test/pq.cpp | 138 +- .../Telegram/tdlib/td/tdutils/test/variant.cpp | 24 +- protocols/Telegram/tdlib/td/test/CMakeLists.txt | 51 +- protocols/Telegram/tdlib/td/test/TestsRunner.cpp | 63 - protocols/Telegram/tdlib/td/test/TestsRunner.h | 19 - protocols/Telegram/tdlib/td/test/country_info.cpp | 87 + protocols/Telegram/tdlib/td/test/crypto.cpp | 279 + protocols/Telegram/tdlib/td/test/data.cpp | 442 +- protocols/Telegram/tdlib/td/test/data.h | 15 +- protocols/Telegram/tdlib/td/test/db.cpp | 512 +- protocols/Telegram/tdlib/td/test/fuzz_url.cpp | 4 +- protocols/Telegram/tdlib/td/test/http.cpp | 358 +- protocols/Telegram/tdlib/td/test/link.cpp | 983 + protocols/Telegram/tdlib/td/test/main.cpp | 56 +- .../Telegram/tdlib/td/test/message_entities.cpp | 1652 +- protocols/Telegram/tdlib/td/test/mtproto.cpp | 663 +- protocols/Telegram/tdlib/td/test/online.cpp | 632 + protocols/Telegram/tdlib/td/test/poll.cpp | 58 + protocols/Telegram/tdlib/td/test/secret.cpp | 376 +- .../Telegram/tdlib/td/test/secure_storage.cpp | 70 + .../Telegram/tdlib/td/test/set_with_position.cpp | 263 + .../Telegram/tdlib/td/test/string_cleaning.cpp | 103 +- protocols/Telegram/tdlib/td/test/tdclient.cpp | 1031 +- protocols/Telegram/tdlib/td/test/tests_runner.cpp | 18 - protocols/Telegram/tdlib/td/test/tests_runner.h | 18 - protocols/Telegram/tdlib/td/test/tqueue.cpp | 250 + protocols/Telegram/tdlib/tdactor.vcxproj | 67 + protocols/Telegram/tdlib/tdactor.vcxproj.filters | 105 + protocols/Telegram/tdlib/tdcore.vcxproj | 295 + protocols/Telegram/tdlib/tdcore.vcxproj.filters | 747 + protocols/Telegram/tdlib/tddb.vcxproj | 79 + protocols/Telegram/tdlib/tddb.vcxproj.filters | 44 + protocols/Telegram/tdlib/tdlib.vcxproj | 23 +- protocols/Telegram/tdlib/tdlib.vcxproj.filters | 26 +- protocols/Telegram/tdlib/tdnet.vcxproj | 77 + protocols/Telegram/tdlib/tdnet.vcxproj.filters | 99 + protocols/Telegram/tdlib/tdutils.vcxproj | 189 + protocols/Telegram/tdlib/tdutils.vcxproj.filters | 465 + 1187 files changed, 331248 insertions(+), 123309 deletions(-) delete mode 100644 protocols/Telegram/tdlib/build/tdactor.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tdactor.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/build/tdcore.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tdcore.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/build/tddb.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tddb.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/build/tdnet.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tdnet.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/build/tdsqlite.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tdsqlite.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/build/tdutils.vcxproj delete mode 100644 protocols/Telegram/tdlib/build/tdutils.vcxproj.filters delete mode 100644 protocols/Telegram/tdlib/td/.ycm_extra_conf.py create mode 100644 protocols/Telegram/tdlib/td/CMake/GeneratePkgConfig.cmake create mode 100644 protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake create mode 100644 protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake.in create mode 100644 protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake create mode 100644 protocols/Telegram/tdlib/td/CMake/TdSetUpCompiler.cmake create mode 100644 protocols/Telegram/tdlib/td/CMake/illumos.cmake create mode 100644 protocols/Telegram/tdlib/td/SplitSource.php create mode 100644 protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp create mode 100644 protocols/Telegram/tdlib/td/benchmark/check_tls.cpp create mode 100644 protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp create mode 100644 protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp create mode 100644 protocols/Telegram/tdlib/td/build.html create mode 100644 protocols/Telegram/tdlib/td/example/README.md create mode 100644 protocols/Telegram/tdlib/td/example/android/.gitignore create mode 100644 protocols/Telegram/tdlib/td/example/android/AddIntDef.php create mode 100644 protocols/Telegram/tdlib/td/example/android/CMakeLists.txt create mode 100644 protocols/Telegram/tdlib/td/example/android/Dockerfile create mode 100644 protocols/Telegram/tdlib/td/example/android/README.md create mode 100644 protocols/Telegram/tdlib/td/example/android/build-openssl.sh create mode 100644 protocols/Telegram/tdlib/td/example/android/build-tdlib.sh create mode 100644 protocols/Telegram/tdlib/td/example/android/check-environment.sh create mode 100644 protocols/Telegram/tdlib/td/example/android/fetch-sdk.sh delete mode 100644 protocols/Telegram/tdlib/td/example/go/main.go create mode 100644 protocols/Telegram/tdlib/td/example/ios/Python-Apple-support.patch create mode 100644 protocols/Telegram/tdlib/td/example/ios/openssl-1.0.2n-darwin-arm64.patch delete mode 100644 protocols/Telegram/tdlib/td/example/java/org/drinkless/tdlib/Log.java delete mode 100644 protocols/Telegram/tdlib/td/example/ruby/Gemfile delete mode 100644 protocols/Telegram/tdlib/td/example/ruby/Gemfile.lock delete mode 100644 protocols/Telegram/tdlib/td/example/ruby/example.rb create mode 100644 protocols/Telegram/tdlib/td/example/web/.gitignore create mode 100644 protocols/Telegram/tdlib/td/example/web/README.md create mode 100644 protocols/Telegram/tdlib/td/example/web/build-openssl.sh create mode 100644 protocols/Telegram/tdlib/td/example/web/build-tdlib.sh create mode 100644 protocols/Telegram/tdlib/td/example/web/build-tdweb.sh create mode 100644 protocols/Telegram/tdlib/td/example/web/copy-tdlib.sh create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/README.md create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/package-lock.json create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/package.json create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/index.js create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/logger.js create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/wasm-utils.js create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/worker.js create mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/webpack.config.js create mode 100644 protocols/Telegram/tdlib/td/memprof/memprof_stat.cpp create mode 100644 protocols/Telegram/tdlib/td/memprof/memprof_stat.h create mode 100644 protocols/Telegram/tdlib/td/post.js delete mode 100644 protocols/Telegram/tdlib/td/td/generate/scheme/mtproto_api.tlo delete mode 100644 protocols/Telegram/tdlib/td/td/generate/scheme/secret_api.tlo delete mode 100644 protocols/Telegram/tdlib/td/td/generate/scheme/td_api.tlo delete mode 100644 protocols/Telegram/tdlib/td/td/generate/scheme/telegram_api.tlo delete mode 100644 protocols/Telegram/tdlib/td/td/generate/scheme/update-tlo.sh create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/CMakeLists.txt create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/LICENSE create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/crc32.c create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/crc32.h create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/portable_endian.h create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/tl-parser-tree.h create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/tl-parser.c create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/tl-parser.h create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/tl-tl.h create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/tlc.c create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/wgetopt.c create mode 100644 protocols/Telegram/tdlib/td/td/generate/tl-parser/wgetopt.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/ConnectionManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/ConnectionManager.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/DhCallback.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/DhHandshake.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/DhHandshake.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/KDF.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/KDF.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/MtprotoQuery.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/PacketInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/Ping.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/Ping.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/PingConnection.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/ProxySecret.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/ProxySecret.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/RSA.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/RSA.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/TlsInit.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/TlsInit.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/TlsReaderByteFlow.cpp create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/TlsReaderByteFlow.h create mode 100644 protocols/Telegram/tdlib/td/td/mtproto/TransportType.h delete mode 100644 protocols/Telegram/tdlib/td/td/mtproto/crypto.cpp delete mode 100644 protocols/Telegram/tdlib/td/td/mtproto/crypto.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Account.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Account.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/AffectedHistory.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Application.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Application.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/AttachMenuManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/AttachMenuManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/AutoDownloadSettings.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/AutoDownloadSettings.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BackgroundType.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotCommand.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotCommand.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotCommandScope.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotCommandScope.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotMenuButton.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/BotMenuButton.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChainId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChannelParticipantFilter.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChannelParticipantFilter.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChannelType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChatReactions.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ChatReactions.h delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/ConfigShared.cpp delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/ConfigShared.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ConnectionState.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ConnectionState.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/CountryInfoManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/CountryInfoManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/CustomEmojiId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Dependencies.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Dependencies.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogAction.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogAction.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogActionBar.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogActionBar.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogAdministrator.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogAdministrator.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogDate.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogEventLog.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogEventLog.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogFilter.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogFilter.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogFilter.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogFilterId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogInviteLink.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogInviteLink.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogListId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogLocation.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogLocation.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogNotificationSettings.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogNotificationSettings.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogNotificationSettings.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogParticipantFilter.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogParticipantFilter.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogSource.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DialogSource.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Dimensions.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Dimensions.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Dimensions.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Document.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Document.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Document.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DownloadManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DownloadManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DownloadManagerCallback.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DownloadManagerCallback.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DraftMessage.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DraftMessage.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/DraftMessage.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/EmailVerification.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/EmailVerification.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/EmojiStatus.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/EmojiStatus.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/EncryptedFile.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/FileReferenceManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/FileReferenceManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/FileReferenceManager.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/FolderId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopic.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopic.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicEditedData.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicEditedData.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicEditedData.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicIcon.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicIcon.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicIcon.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicInfo.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ForumTopicManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/FullMessageId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GameManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GameManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GitCommitHash.cpp.in create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GitCommitHash.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallParticipant.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallParticipant.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallParticipantOrder.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallParticipantOrder.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallVideoPayload.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/GroupCallVideoPayload.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputDialogId.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputDialogId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputGroupCallId.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputGroupCallId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputInvoice.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputInvoice.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputInvoice.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputMessageText.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputMessageText.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/InputMessageText.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/JsonValue.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/JsonValue.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/LabeledPricePart.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/LanguagePackManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/LanguagePackManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/LinkManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/LinkManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Logging.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Logging.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageContent.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageContent.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageContentType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageContentType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageCopyOptions.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageDb.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageDb.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageEntity.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageExtendedMedia.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageExtendedMedia.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageExtendedMedia.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageId.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageLinkInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReaction.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReaction.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReaction.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReplyHeader.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReplyHeader.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReplyInfo.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReplyInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageReplyInfo.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageSearchFilter.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageSearchFilter.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageSender.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageSender.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageThreadDb.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageThreadDb.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageThreadInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageTtl.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessageTtl.h delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessagesDb.cpp delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/MessagesDb.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MinChannel.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/MinChannel.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NewPasswordState.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NewPasswordState.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Notification.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationGroupId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationGroupKey.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationGroupType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSettingsManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSettingsManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSettingsScope.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSettingsScope.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSound.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSound.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationSoundType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/NotificationType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/OptionManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/OptionManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/OrderInfo.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/OrderInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/OrderInfo.hpp delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/Payments.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhoneNumberManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhoneNumberManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoFormat.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSize.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSize.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSize.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSizeSource.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSizeSource.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PhotoSizeSource.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PollId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PollId.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PollManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PollManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PollManager.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Premium.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Premium.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PremiumGiftOption.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PremiumGiftOption.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PremiumGiftOption.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/PublicDialogType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/QueryCombiner.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/QueryCombiner.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/RecentDialogList.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/RecentDialogList.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ReportReason.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ReportReason.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/RequestActor.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/RestrictionReason.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/RestrictionReason.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ScheduledServerMessageId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ScopeNotificationSettings.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ScopeNotificationSettings.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ScopeNotificationSettings.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecretChatLayer.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecretInputMedia.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureStorage.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureStorage.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureValue.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureValue.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SecureValue.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SendCodeHelper.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SendCodeHelper.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SendCodeHelper.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SentEmailCode.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SentEmailCode.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ServerMessageId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SetWithPosition.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SpecialStickerSetType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SpecialStickerSetType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SponsoredMessageManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SponsoredMessageManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerFormat.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerFormat.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerSetId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerSetId.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/StickerType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SuggestedAction.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/SuggestedAction.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Support.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Support.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TermsOfService.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TermsOfService.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ThemeManager.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/ThemeManager.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TopDialogCategory.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TopDialogCategory.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TranscriptionInfo.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TranscriptionInfo.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/TranscriptionInfo.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Usernames.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Usernames.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Venue.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/Venue.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/WebPageBlock.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/WebPageBlock.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileBitmask.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileBitmask.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileData.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileData.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileDbId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileEncryptionKey.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileEncryptionKey.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileLocation.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileSourceId.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileSourceId.hpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileType.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/files/FileType.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/logevent/LogEventHelper.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/logevent/LogEventHelper.h delete mode 100644 protocols/Telegram/tdlib/td/td/telegram/net/NetQueryCounter.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/net/NetQueryStats.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/net/NetQueryStats.h create mode 100644 protocols/Telegram/tdlib/td/td/telegram/net/Proxy.cpp create mode 100644 protocols/Telegram/tdlib/td/td/telegram/net/Proxy.h create mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp create mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/Condition.h create mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp create mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ConcurrentScheduler.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ConcurrentScheduler.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/ActorLocker.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/ActorSignals.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/ActorState.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/Scheduler.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/Scheduler.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/td/actor/impl2/SchedulerId.h delete mode 100644 protocols/Telegram/tdlib/td/tdactor/test/actors_impl2.cpp delete mode 100644 protocols/Telegram/tdlib/td/tddb/td/db/Pmc.h create mode 100644 protocols/Telegram/tdlib/td/tddb/td/db/SqliteConnectionSafe.cpp create mode 100644 protocols/Telegram/tdlib/td/tddb/td/db/SqliteKeyValue.cpp create mode 100644 protocols/Telegram/tdlib/td/tddb/td/db/TQueue.cpp create mode 100644 protocols/Telegram/tdlib/td/tddb/td/db/TQueue.h create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/DarwinHttp.h create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/DarwinHttp.mm create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/HttpProxy.cpp create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/HttpProxy.h create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslCtx.cpp create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslCtx.h delete mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslFd.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslFd.h create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslStream.cpp create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/SslStream.h create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/TransparentProxy.cpp create mode 100644 protocols/Telegram/tdlib/td/tdnet/td/net/TransparentProxy.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/AsyncFileLog.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/AsyncFileLog.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/AtomicRead.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/BufferedUdp.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/BufferedUdp.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/CancellationToken.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ChainScheduler.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/CombinedLog.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ConcurrentHashTable.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Context.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/DecTree.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Destructor.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/EpochBasedMemoryReclamation.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ExitGuard.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ExitGuard.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FlatHashMap.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FlatHashMapChunks.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FlatHashSet.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FlatHashTable.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FlatHashTable.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FloodControlGlobal.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/FloodControlGlobal.h delete mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/GitInfo.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/GitInfo.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Hash.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/HashMap.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/HashSet.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/HashTableUtils.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/MapNode.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/MpmcQueue.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/NullLog.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/OptionParser.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/OptionParser.h delete mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/OptionsParser.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/PathView.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Promise.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/SetNode.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/SharedSlice.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/SharedSlice.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Slice.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/SliceBuilder.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/Span.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/StealingQueue.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ThreadLocalStorage.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/ThreadSafeCounter.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TlDowncastHelper.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TlStorerToString.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsCerr.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsCerr.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsFileLog.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsFileLog.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsList.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsLog.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/TsLog.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/UInt.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/VectorQueue.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/WaitFreeHashMap.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/WaitFreeHashSet.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/WaitFreeVector.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/algorithm.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/as.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/bits.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/check.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/check.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/emoji.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/emoji.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/fixed_vector.h delete mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/Fd.cpp delete mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/Fd.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/FromApp.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/IoSlice.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/MemoryMapping.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/MemoryMapping.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/Mutex.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/PollFlags.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/PollFlags.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/StdStreams.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/StdStreams.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/UdpSocketFd.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/UdpSocketFd.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/Iocp.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/Iocp.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/NativeFd.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/NativeFd.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/PollableFd.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/ThreadPthread.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/detail/skip_eintr.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/platform.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/rlimit.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/rlimit.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/stacktrace.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/stacktrace.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/uname.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/uname.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/user.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/port/user.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/tests.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/translit.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/translit.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/uint128.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/td/utils/unique_ptr.h create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/ChainScheduler.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/EpochBasedMemoryReclamation.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/HashSet.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/HttpUrl.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/List.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/OptionParser.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/SharedSlice.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/StealingQueue.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/WaitFreeHashMap.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/WaitFreeHashSet.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/WaitFreeVector.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/bitmask.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/buffer.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/emoji.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/hashset_benchmark.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/log.cpp create mode 100644 protocols/Telegram/tdlib/td/tdutils/test/port.cpp delete mode 100644 protocols/Telegram/tdlib/td/test/TestsRunner.cpp delete mode 100644 protocols/Telegram/tdlib/td/test/TestsRunner.h create mode 100644 protocols/Telegram/tdlib/td/test/country_info.cpp create mode 100644 protocols/Telegram/tdlib/td/test/crypto.cpp create mode 100644 protocols/Telegram/tdlib/td/test/link.cpp create mode 100644 protocols/Telegram/tdlib/td/test/online.cpp create mode 100644 protocols/Telegram/tdlib/td/test/poll.cpp create mode 100644 protocols/Telegram/tdlib/td/test/secure_storage.cpp create mode 100644 protocols/Telegram/tdlib/td/test/set_with_position.cpp delete mode 100644 protocols/Telegram/tdlib/td/test/tests_runner.cpp delete mode 100644 protocols/Telegram/tdlib/td/test/tests_runner.h create mode 100644 protocols/Telegram/tdlib/td/test/tqueue.cpp create mode 100644 protocols/Telegram/tdlib/tdactor.vcxproj create mode 100644 protocols/Telegram/tdlib/tdactor.vcxproj.filters create mode 100644 protocols/Telegram/tdlib/tdcore.vcxproj create mode 100644 protocols/Telegram/tdlib/tdcore.vcxproj.filters create mode 100644 protocols/Telegram/tdlib/tddb.vcxproj create mode 100644 protocols/Telegram/tdlib/tddb.vcxproj.filters create mode 100644 protocols/Telegram/tdlib/tdnet.vcxproj create mode 100644 protocols/Telegram/tdlib/tdnet.vcxproj.filters create mode 100644 protocols/Telegram/tdlib/tdutils.vcxproj create mode 100644 protocols/Telegram/tdlib/tdutils.vcxproj.filters (limited to 'protocols') diff --git a/protocols/Telegram/Telegram.vcxproj b/protocols/Telegram/Telegram.vcxproj index 47af72f50e..79d6b0d73f 100644 --- a/protocols/Telegram/Telegram.vcxproj +++ b/protocols/Telegram/Telegram.vcxproj @@ -26,6 +26,8 @@ + + Create diff --git a/protocols/Telegram/Telegram.vcxproj.filters b/protocols/Telegram/Telegram.vcxproj.filters index 83cffdb711..556fdc07cc 100644 --- a/protocols/Telegram/Telegram.vcxproj.filters +++ b/protocols/Telegram/Telegram.vcxproj.filters @@ -2,17 +2,42 @@ - + Header Files - + + Header Files + + + Header Files + + Source Files - + + Source Files + + Resource Files - + Resource Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + \ No newline at end of file diff --git a/protocols/Telegram/src/main.cpp b/protocols/Telegram/src/main.cpp index 3e25624f7f..0315936c3f 100644 --- a/protocols/Telegram/src/main.cpp +++ b/protocols/Telegram/src/main.cpp @@ -1,8 +1,11 @@ #include "stdafx.h" int hLangpack; +CMPlugin g_plugin; + +///////////////////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo = +static PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -14,14 +17,13 @@ PLUGININFOEX pluginInfo = UNICODE_AWARE, // {AE708252-0DF8-42BA-9EF9-9ACC038EEDA7} {0xae708252, 0xdf8, 0x42ba, {0x9e, 0xf9, 0x9a, 0xcc, 0x3, 0x8e, 0xed, 0xa7}} - }; -///////////////////////////////////////////////////////////////////////////////////////// - -CMPlugin g_plugin; - -extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; +CMPlugin::CMPlugin() : + ACCPROTOPLUGIN("Telegram", pluginInfo) +{ + SetUniqueId("Phone"); +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -31,7 +33,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); return 0; } diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h index 06f32c205d..f039dc6474 100644 --- a/protocols/Telegram/src/stdafx.h +++ b/protocols/Telegram/src/stdafx.h @@ -21,11 +21,7 @@ struct CMTProto; struct CMPlugin : public ACCPROTOPLUGIN { - CMPlugin() : - ACCPROTOPLUGIN("TELEGRAM") - { - SetUniqueId("Phone"); - } + CMPlugin(); }; #endif //_COMMON_H_ \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdactor.vcxproj b/protocols/Telegram/tdlib/build/tdactor.vcxproj deleted file mode 100644 index b25d56e2c8..0000000000 --- a/protocols/Telegram/tdlib/build/tdactor.vcxproj +++ /dev/null @@ -1,164 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {85F63934-02FE-332A-8703-059040B65512} - tdactor - - - - v141 - StaticLibrary - - - v141 - StaticLibrary - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td\tdactor;..\td\tdutils;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Level4 - Disabled - _DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - - - ..\td\tdactor;..\td\tdutils;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Level4 - Disabled - _DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - - - ..\td\tdactor;..\td\tdutils;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdactor;..\td\tdutils;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {D21C6A0F-BED1-3377-9659-7FC7D82EFC4F} - tdutils - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdactor.vcxproj.filters b/protocols/Telegram/tdlib/build/tdactor.vcxproj.filters deleted file mode 100644 index 830d9d15c0..0000000000 --- a/protocols/Telegram/tdlib/build/tdactor.vcxproj.filters +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - diff --git a/protocols/Telegram/tdlib/build/tdcore.vcxproj b/protocols/Telegram/tdlib/build/tdcore.vcxproj deleted file mode 100644 index 0500310881..0000000000 --- a/protocols/Telegram/tdlib/build/tdcore.vcxproj +++ /dev/null @@ -1,398 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {FC88FB5A-AAED-3F3E-9959-236444D8F644} - tdcore - - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td;..\td\td\generate\auto;..\..\..\..\include;..\td\tdactor;..\td\tdutils;..\td\tdnet;..\td\tddb;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - %(AdditionalOptions) /bigobj - - - - - ..\td;..\td\td\generate\auto;..\..\..\..\include;..\td\tdactor;..\td\tdutils;..\td\tdnet;..\td\tddb;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - %(AdditionalOptions) /bigobj - - - - - ..\td;..\td\td\generate\auto;..\..\..\..\include;..\td\tdactor;..\td\tdutils;..\td\tdnet;..\td\tddb;%(AdditionalIncludeDirectories) - %(AdditionalOptions) /bigobj - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - ..\td;..\td\td\generate\auto;..\..\..\..\include;..\td\tdactor;..\td\tdutils;..\td\tdnet;..\td\tddb;%(AdditionalIncludeDirectories) - %(AdditionalOptions) /bigobj - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {85F63934-02FE-332A-8703-059040B65512} - tdactor - - - {F525EE11-8820-3D8A-87A5-465D50A98A64} - tddb - - - {2246C3CF-7888-3102-984A-80214ADF418C} - tdnet - - - {4FA94C32-60A9-33CC-B822-9BB1BDDD34FD} - tdsqlite - - - {D21C6A0F-BED1-3377-9659-7FC7D82EFC4F} - tdutils - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdcore.vcxproj.filters b/protocols/Telegram/tdlib/build/tdcore.vcxproj.filters deleted file mode 100644 index 1e4dddda0e..0000000000 --- a/protocols/Telegram/tdlib/build/tdcore.vcxproj.filters +++ /dev/null @@ -1,747 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - diff --git a/protocols/Telegram/tdlib/build/tddb.vcxproj b/protocols/Telegram/tdlib/build/tddb.vcxproj deleted file mode 100644 index f7d21a06b5..0000000000 --- a/protocols/Telegram/tdlib/build/tddb.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F525EE11-8820-3D8A-87A5-465D50A98A64} - tddb - - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td\tddb;..\td\tdactor;..\td\tdutils;..\td\build\tdutils;..\td\sqlite;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - Disabled - - - - - ..\td\tddb;..\td\tdactor;..\td\tdutils;..\td\build\tdutils;..\td\sqlite;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - Disabled - - - - - ..\td\tddb;..\td\tdactor;..\td\tdutils;..\td\build\tdutils;..\td\sqlite;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tddb;..\td\tdactor;..\td\tdutils;..\td\build\tdutils;..\td\sqlite;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {85F63934-02FE-332A-8703-059040B65512} - tdactor - - - {4FA94C32-60A9-33CC-B822-9BB1BDDD34FD} - tdsqlite - - - {D21C6A0F-BED1-3377-9659-7FC7D82EFC4F} - tdutils - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tddb.vcxproj.filters b/protocols/Telegram/tdlib/build/tddb.vcxproj.filters deleted file mode 100644 index c1f569c828..0000000000 --- a/protocols/Telegram/tdlib/build/tddb.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdnet.vcxproj b/protocols/Telegram/tdlib/build/tdnet.vcxproj deleted file mode 100644 index 43626ae814..0000000000 --- a/protocols/Telegram/tdlib/build/tdnet.vcxproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2246C3CF-7888-3102-984A-80214ADF418C} - tdnet - - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td\tdnet;..\..\..\..\include;..\td\tdutils;..\td\tdactor;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdnet;..\..\..\..\include;..\td\tdutils;..\td\tdactor;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdnet;..\..\..\..\include;..\td\tdutils;..\td\tdactor;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdnet;..\..\..\..\include;..\td\tdutils;..\td\tdactor;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {85F63934-02FE-332A-8703-059040B65512} - tdactor - - - {D21C6A0F-BED1-3377-9659-7FC7D82EFC4F} - tdutils - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdnet.vcxproj.filters b/protocols/Telegram/tdlib/build/tdnet.vcxproj.filters deleted file mode 100644 index 8e762041c9..0000000000 --- a/protocols/Telegram/tdlib/build/tdnet.vcxproj.filters +++ /dev/null @@ -1,99 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - diff --git a/protocols/Telegram/tdlib/build/tdsqlite.vcxproj b/protocols/Telegram/tdlib/build/tdsqlite.vcxproj deleted file mode 100644 index 2a3c25f0a7..0000000000 --- a/protocols/Telegram/tdlib/build/tdsqlite.vcxproj +++ /dev/null @@ -1,132 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4FA94C32-60A9-33CC-B822-9BB1BDDD34FD} - tdsqlite - - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td\sqlite;..\..\..\..\include;%(AdditionalIncludeDirectories) - 4996 - - - Disabled - MultiThreadedDebugDLL - Level4 - _DEBUG;SQLITE_DEFAULT_MEMSTATUS=0;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_DECLTYPE;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_HAS_CODEC;SQLITE_TEMP_STORE=2;SQLITE_ENABLE_FTS5;SQLITE_DISABLE_LFS;%(PreprocessorDefinitions) - - - - - ..\td\sqlite;..\..\..\..\include;%(AdditionalIncludeDirectories) - 4996 - - - Disabled - MultiThreadedDebugDLL - Level4 - _DEBUG;SQLITE_DEFAULT_MEMSTATUS=0;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_DECLTYPE;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_HAS_CODEC;SQLITE_TEMP_STORE=2;SQLITE_ENABLE_FTS5;SQLITE_DISABLE_LFS;%(PreprocessorDefinitions) - - - - - ..\td\sqlite;..\..\..\..\include;%(AdditionalIncludeDirectories) - 4996 - Level4 - NDEBUG;SQLITE_DEFAULT_MEMSTATUS=0;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_DECLTYPE;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_HAS_CODEC;SQLITE_TEMP_STORE=2;SQLITE_ENABLE_FTS5;SQLITE_DISABLE_LFS;%(PreprocessorDefinitions) - - - - - ..\td\sqlite;..\..\..\..\include;%(AdditionalIncludeDirectories) - 4996 - Level4 - NDEBUG;SQLITE_DEFAULT_MEMSTATUS=0;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_DECLTYPE;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_HAS_CODEC;SQLITE_TEMP_STORE=2;SQLITE_ENABLE_FTS5;SQLITE_DISABLE_LFS;%(PreprocessorDefinitions) - - - - - - - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdsqlite.vcxproj.filters b/protocols/Telegram/tdlib/build/tdsqlite.vcxproj.filters deleted file mode 100644 index 1128706fb0..0000000000 --- a/protocols/Telegram/tdlib/build/tdsqlite.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - diff --git a/protocols/Telegram/tdlib/build/tdutils.vcxproj b/protocols/Telegram/tdlib/build/tdutils.vcxproj deleted file mode 100644 index d893543680..0000000000 --- a/protocols/Telegram/tdlib/build/tdutils.vcxproj +++ /dev/null @@ -1,278 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {D21C6A0F-BED1-3377-9659-7FC7D82EFC4F} - tdutils - - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - StaticLibrary - v141 - - - - - - - Create - - - - - - - - Create - - - - - <_ProjectFileVersion>10.0.20506.1 - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - - - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - - - - ..\td\tdutils;..\..\..\..\include;..\..\..\..\libs\zlib\src;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdutils;..\..\..\..\include;..\..\..\..\libs\zlib\src;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - Disabled - MultiThreadedDebugDLL - false - Level4 - _DEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdutils;..\..\..\..\include;..\..\..\..\libs\zlib\src;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - ..\td\tdutils;..\..\..\..\include;..\..\..\..\libs\zlib\src;%(AdditionalIncludeDirectories) - 4100;4127;4324;4505;4702 - false - Level4 - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/build/tdutils.vcxproj.filters b/protocols/Telegram/tdlib/build/tdutils.vcxproj.filters deleted file mode 100644 index e6f9fe816d..0000000000 --- a/protocols/Telegram/tdlib/build/tdutils.vcxproj.filters +++ /dev/null @@ -1,465 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - {0FD26E20-5E51-396B-B4E5-98068F96B37E} - - - {CC4593AA-1CC3-37C8-BDF9-C5986B1808BD} - - - diff --git a/protocols/Telegram/tdlib/td/.clang-format b/protocols/Telegram/tdlib/td/.clang-format index e169061bab..4e23f1d3a6 100644 --- a/protocols/Telegram/tdlib/td/.clang-format +++ b/protocols/Telegram/tdlib/td/.clang-format @@ -3,26 +3,35 @@ Language: Cpp # BasedOnStyle: Google AccessModifierOffset: -1 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None AlignEscapedNewlines: Left -AlignOperands: true +AlignOperands: Align AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: None # All -AllowShortIfStatementsOnASingleLine: false # true +AllowShortIfStatementsOnASingleLine: Never # WithoutElse +AllowShortLambdasOnASingleLine: Inline # All AllowShortLoopsOnASingleLine: false # true AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: true +AlwaysBreakTemplateDeclarations: Yes BinPackArguments: true BinPackParameters: true +BitFieldColonSpacing: Both BraceWrapping: + AfterCaseLabel: false AfterClass: false - AfterControlStatement: false + AfterControlStatement: Never AfterEnum: false AfterFunction: false AfterNamespace: false @@ -32,13 +41,17 @@ BraceWrapping: AfterExternBlock: false BeforeCatch: false BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: true BreakBeforeInheritanceComma: true # false +BreakInheritanceList: BeforeComma # BeforeColon BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: true # false BreakConstructorInitializers: BeforeComma # BeforeColon @@ -51,48 +64,85 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true +DeriveLineEnding: true DerivePointerAlignment: true DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true -# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +ForEachMacros: + - Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '.*' + Priority: 0 +IndentAccessModifiers: false +IndentCaseBlocks: false IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true IndentPPDirectives: None +IndentRequires: false IndentWidth: 2 IndentWrappedFunctionNames: false +# InsertTrailingCommas: None # JavaScriptQuotes: Leave # JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None +# ObjCBinPackProtocolList: Never # ObjCBlockIndentWidth: 2 +# ObjCBreakBeforeNestedBlockParam: true # ObjCSpaceAfterProperty: false -# ObjCSpaceBeforeProtocolList: false +# ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left +PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer ReflowComments: false # true -SortIncludes: false # disabled, because we need case insensitive sort +ShortNamespaceLines: 0 # 1 +SortIncludes: CaseInsensitive # CaseSensitive +# SortJavaStaticImport: Before SortUsingDeclarations: false # true SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 -SpacesInAngles: false +SpacesInAngles: Never +SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: 1 # -1 SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Auto TabWidth: 100 # 8 +UseCRLF: false UseTab: Never ... diff --git a/protocols/Telegram/tdlib/td/.gitattributes b/protocols/Telegram/tdlib/td/.gitattributes index ecb5de5494..06e5328a4f 100644 --- a/protocols/Telegram/tdlib/td/.gitattributes +++ b/protocols/Telegram/tdlib/td/.gitattributes @@ -5,32 +5,34 @@ *.h text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.c text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.tl text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.mm text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.txt text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.sh text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent eol=lf *.php text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.ps1 text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent eol=crlf *.yml text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent -*.py text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.cmake text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.md text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.in text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.html text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.java text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.py text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.js text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.patch text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.swift text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.pbxproj text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.cs text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.xaml text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.appxmanifest text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.vsixmanifest text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.json text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.csproj text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.sln text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.xml text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent -*.rb text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent -*.lock text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent -*.go text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent +*.config text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent sqlite/sqlite/* linguist-vendored -*.tlo binary - *.pfx binary *.png binary diff --git a/protocols/Telegram/tdlib/td/.gitignore b/protocols/Telegram/tdlib/td/.gitignore index 4b29dd985e..2572f22305 100644 --- a/protocols/Telegram/tdlib/td/.gitignore +++ b/protocols/Telegram/tdlib/td/.gitignore @@ -6,3 +6,4 @@ auto/ db_backup *.pyc docs/ +vcpkg/ diff --git a/protocols/Telegram/tdlib/td/.ycm_extra_conf.py b/protocols/Telegram/tdlib/td/.ycm_extra_conf.py deleted file mode 100644 index dd6050fea6..0000000000 --- a/protocols/Telegram/tdlib/td/.ycm_extra_conf.py +++ /dev/null @@ -1,159 +0,0 @@ -# This file is NOT licensed under the GPLv3, which is the license for the rest -# of YouCompleteMe. -# -# Here's the license text for this file: -# -# This is free and unencumbered software released into the public domain. -# -# Anyone is free to copy, modify, publish, use, compile, sell, or -# distribute this software, either in source code form or as a compiled -# binary, for any purpose, commercial or non-commercial, and by any -# means. -# -# In jurisdictions that recognize copyright laws, the author or authors -# of this software dedicate any and all copyright interest in the -# software to the public domain. We make this dedication for the benefit -# of the public at large and to the detriment of our heirs and -# successors. We intend this dedication to be an overt act of -# relinquishment in perpetuity of all present and future rights to this -# software under copyright law. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -# -# For more information, please refer to - -import os -import ycm_core - -# These are the compilation flags that will be used in case there's no -# compilation database set (by default, one is not set). -# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. -flags = [ -"-stdlib=libc++", -"-Wall", -"-Wextra", -"-Wno-unused-parameter", -"-Wno-deprecated-declarations", -"-std=c++14", -"-x", -"c++", -"-I", -".", -"-I", "tdutils", -"-I", "tdutils/generate", -"-I", "tdactor", -"-I", "tddb", -"-I", "tdnet", -"-I", "tdtl", -"-I", "td/generate", -"-I", "td/generate/auto", -"-I", "td", -"-isystem", -"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1", -"-isystem", -"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/include", -"-isystem", -"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" -] - - -# Set this to the absolute path to the folder (NOT the file!) containing the -# compile_commands.json file to use that instead of 'flags'. See here for -# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html -# -# You can get CMake to generate this file for you by adding: -# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) -# to your CMakeLists.txt file. -# -# Most projects will NOT need to set this to anything; you can just change the -# 'flags' list of compilation flags. Notice that YCM itself uses that approach. -compilation_database_folder = 'build' - -if os.path.exists( compilation_database_folder ): - database = ycm_core.CompilationDatabase( compilation_database_folder ) -else: - database = None - -SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] - -def DirectoryOfThisScript(): - return os.path.dirname( os.path.abspath( __file__ ) ) - - -def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): - if not working_directory: - return list( flags ) - new_flags = [] - make_next_absolute = False - path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] - for flag in flags: - new_flag = flag - - if make_next_absolute: - make_next_absolute = False - if not flag.startswith( '/' ): - new_flag = os.path.join( working_directory, flag ) - - for path_flag in path_flags: - if flag == path_flag: - make_next_absolute = True - break - - if flag.startswith( path_flag ): - path = flag[ len( path_flag ): ] - new_flag = path_flag + os.path.join( working_directory, path ) - break - - if new_flag: - new_flags.append( new_flag ) - return new_flags - - -def IsHeaderFile( filename ): - extension = os.path.splitext( filename )[ 1 ] - return extension in [ '.h', '.hxx', '.hpp', '.hh' ] - - -def GetCompilationInfoForFile( filename ): - # The compilation_commands.json file generated by CMake does not have entries - # for header files. So we do our best by asking the db for flags for a - # corresponding source file, if any. If one exists, the flags for that file - # should be good enough. - if IsHeaderFile( filename ): - basename = os.path.splitext( filename )[ 0 ] - for extension in SOURCE_EXTENSIONS: - replacement_file = basename + extension - if os.path.exists( replacement_file ): - compilation_info = database.GetCompilationInfoForFile( - replacement_file ) - if compilation_info.compiler_flags_: - return compilation_info - return None - return database.GetCompilationInfoForFile( filename ) - - -def FlagsForFile( filename, **kwargs ): - if database: - # Bear in mind that compilation_info.compiler_flags_ does NOT return a - # python list, but a "list-like" StringVec object - compilation_info = GetCompilationInfoForFile( filename ) - if not compilation_info: - return None - - final_flags = MakeRelativePathsInFlagsAbsolute( - compilation_info.compiler_flags_, - compilation_info.compiler_working_dir_ ) - else: - relative_to = DirectoryOfThisScript() - final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) - - return { - 'flags': final_flags, - 'do_cache': True - } diff --git a/protocols/Telegram/tdlib/td/CHANGELOG.md b/protocols/Telegram/tdlib/td/CHANGELOG.md index 77a14246e2..05c5269684 100644 --- a/protocols/Telegram/tdlib/td/CHANGELOG.md +++ b/protocols/Telegram/tdlib/td/CHANGELOG.md @@ -1,4 +1,1435 @@ -Changes in 1.2.0: +Changes in 1.8.0 (29 Dec 2021): + +* Changed the type of user, basic group and supergroup identifiers from `int32` to `int53`. +* Simplified chat list loading and removed the ability to misuse the method `getChats`: + - Renamed the method `getChats` to `loadChats`. + - Removed the parameters `offset_order` and `offset_chat_id` from the method `loadChats`. Chats are now always loaded + from the last known chat in the list. + - Changed the type of the result in the method `loadChats` to `ok`. If no chats were loaded, a 404 error is returned. + The order of chats in the list must be maintained using the updates `updateChatPosition`, `updateChatLastMessage`, + and `updateChatDraftMessage`. + - Added the convenience method `getChats`, which returns the requested number of chats from the beginning of a chat + list and can be used if the list of chats doesn't need to be maintained in a consistent state. +* Added the ability to hook TDLib log messages: + - Added the function `td_set_log_message_callback` to JSON interface. + - Added the function `set_log_message_callback` to the class `ClientManager`. + - Added the function `SetLogMessageCallback` to the UWP native wrapper through C++/CX. + - Deprecated the function `td_set_log_fatal_error_callback` in JSON interface in favor of + the function `td_set_log_message_callback`. + - Deprecated the function `Log::set_fatal_error_callback` in favor of + the function `ClientManager::set_log_message_callback`. +* Added support for sending messages on behalf of public channels owned by the user: + - Added the field `message_sender_id` to the class `chat`, containing the identifier of the currently selected + message sender. + - Added the update `updateChatMessageSender`. + - Added the method `getChatAvailableMessageSenders`, returning the list of available message senders for the chat. + - Added the method `setChatMessageSender`, changing the currently selected message sender. + - Added the field `need_another_sender` to the class `messageSendingStateFailed`. If it is true, an alert needs + to be shown to the user that the message will be re-sent on behalf of another sender. + - Replaced the method `deleteChatMessagesFromUser` with the method `deleteChatMessagesBySender`, expecting + a `MessageSender` instead of a user identifier. + - Replaced the update `updateUserChatAction` with the update `updateChatAction`, containing a `MessageSender` + instead of a user identifier as a source of the chat action. +* Added the ability to ban supergroups and channels in other supergroups and channels: + - Replaced the fields `user_id` with the fields `member_id` in the classes `chatMember` and + `chatEventMemberRestricted`. + - Replaced the parameters `user_id` with the parameters `member_id` in the methods `setChatMemberStatus` and + `getChatMember`. +* Improved support for animated emoji: + - Added the class `animatedEmoji`, containing information about an animated emoji. + - Added the class `messageAnimatedEmoji` to the types of message content. + - Added the method `clickAnimatedEmojiMessage` to be called when an animated emoji is clicked. + - Added the update `updateAnimatedEmojiMessageClicked`, received when a big animated sticker must be played. + - Added the class `chatActionWatchingAnimations` to the types of chat action. + - Added the method `getAnimatedEmoji`, returning an animated emoji corresponding to a given emoji. + - Added the writable option "disable_animated_emoji". + - Removed the option "animated_emoji_sticker_set_name". +* Added support for automatic message deletion in all chat types: + - Added the field `message_ttl` to the class `chat`. + - Added the update `updateChatMessageTtl`. + - Added the method `setChatMessageTtl`. + - Added the class `chatEventMessageTtlChanged`, representing change of the field `message_ttl` in the chat event log. + - Removed the field `ttl` from the class `secretChat` in favor of the field `message_ttl` in the class `chat`. + - Removed the method `sendChatSetTtlMessage` in favor of the method `setChatMessageTtl`. +* Improved names of the fields of the type `MessageSender`: + - Renamed the fields `sender` to `sender_id` in the classes `message` and `notificationTypeNewPushMessage`. + - Renamed the parameter `sender` to `sender_id` in the methods `searchChatMessages`, `addLocalMessage`, and + `toggleMessageSenderIsBlocked`. + - Renamed the field `recent_repliers` to `recent_replier_ids` in the class `messageReplyInfo`. + - Renamed the field `traveler` to `traveler_id` in the class `messageProximityAlertTriggered`. + - Renamed the field `watcher` to `watcher_id` in the class `messageProximityAlertTriggered`. +* The field `formatted_phone_number` in the class `phoneNumberInfo` now contains the character '-' at the places of + expected digits. +* Added the synchronous method `getPhoneNumberInfoSync` that can be used instead of the method `getPhoneNumberInfo` + to synchronously receive information about a phone number by its prefix. +* Replaced the field `user_id` in the class `chatEvent` with the field `member_id` of the type `MessageSender`. +* Improved support for bot payments: + - Allowed sending invoices as results of inline queries by allowing bots to use the class `inputMessageInvoice` as + the value of the field `input_message_content` in the classes `inputInlineQueryResultAnimation`, + `inputInlineQueryResultArticle`, `inputInlineQueryResultAudio`, `inputInlineQueryResultContact`, + `inputInlineQueryResultDocument`, `inputInlineQueryResultLocation`, `inputInlineQueryResultPhoto`, + `inputInlineQueryResultSticker`, `inputInlineQueryResultVenue`, `inputInlineQueryResultVideo`, and + `inputInlineQueryResultVoiceNote`. + - Allowed sending invoice messages to basic group, supergroup and channel chats. + - Allowed bots to send forwardable invoices by specifying an empty field `start_parameter` in + the class `inputMessageInvoice`. + - Added the field `invoice_chat_id` to the class `messagePaymentSuccessful`. + - Added the field `id` to the class `paymentForm`, containing a unique payment form identifier. + - Added the parameter `payment_form_id` to the method `sendPaymentForm`. + - Added the field `seller_bot_user_id` to the class `paymentForm`, containing the user identifier of the seller bot. + - Added the field `payments_provider_user_id` to the class `paymentForm`, containing the user identifier of + the payment provider bot. + - Added the fields `title`, `description`, `photo`, and `seller_bot_user_id` to the class `paymentReceipt`. + - Added the fields `max_tip_amount` and `suggested_tip_amounts` to the class `invoice`. + - Added the parameter `tip_amount` to the method `sendPaymentForm`. + - Added the field `tip_amount` to the class `paymentReceipt`. + - Renamed the class `inputCredentialsAndroidPay` to `inputCredentialsGooglePay`. + - Added the class `paymentFormTheme`, containing the desired colors for a payment form. + - Added the parameter `theme` to the method `getPaymentForm`. + - Removed the field `invoice_message_id` from the class `messagePaymentSuccessfulBot`. +* Added the method `deleteChat`, which can be used to completely delete a chat along with all messages. +* Removed the method `deleteSupergroup` in favor of the method `deleteChat`. +* Changed the type of the result in the method `getProxyLink` to the class `httpUrl` instead of the class `text`. +* Removed support for secret chat layers before 73. +* Added support for sponsored messages: + - Added the class `sponsoredMessage`. + - Added the method `getChatSponsoredMessage`. + - Added the ability to pass identifiers of sponsored messages to `viewMessages`. The method must be called when + the entire text of the sponsored message is shown on the screen (excluding the button). +* Added support for video chats: + - Added the class `groupCall`, representing a group call. + - Added the method `getGroupCall` for fetching information about a group call. + - Added the update `updateGroupCall`. + - Added the class `videoChat`, representing a video chat, i.e. group call bound to a chat. + - Added the field `video_chat` to the class `chat`. + - Added the update `updateChatVideoChat`. + - Added the classes `messageVideoChatScheduled`, `messageVideoChatStarted`, and `messageVideoChatEnded` to + the types of message content. + - Added the class `messageInviteVideoChatParticipants` to the types of message content. + - Added the field `can_manage_video_chats` to the class `chatMemberStatusAdministrator`. + - Added the class `groupCallId`. + - Added the method `createVideoChat` for video chat creation. + - Added the method `startScheduledGroupCall`. + - Added the method `toggleGroupCallEnabledStartNotification`. + - Added the method `joinGroupCall`. + - Added the method `leaveGroupCall`. + - Added the method `endGroupCall`. + - Added the method `toggleGroupCallIsMyVideoEnabled`. + - Added the method `toggleGroupCallIsMyVideoPaused`. + - Added the methods `startGroupCallScreenSharing`, `toggleGroupCallScreenSharingIsPaused`, + `endGroupCallScreenSharing` for managing screen sharing during group calls. + - Added the method `setGroupCallTitle`. + - Added the method `toggleGroupCallMuteNewParticipants`. + - Added the classes `groupCallVideoSourceGroup` and `groupCallParticipantVideoInfo`, describing available + video streams. + - Added the class `groupCallParticipant`. + - Added the update `updateGroupCallParticipant`. + - Added the method `loadGroupCallParticipants`. + - Added the method `toggleGroupCallParticipantIsHandRaised`. + - Added the method `setGroupCallParticipantIsSpeaking`. + - Added the methods `toggleGroupCallParticipantIsMuted` and `setGroupCallParticipantVolumeLevel` for managing + the volume level of group call participants. + - Added the method `inviteGroupCallParticipants`. + - Added the method `getGroupCallInviteLink` and `revokeGroupCallInviteLink` for managing group call invite links. + - Added the methods `startGroupCallRecording` and `endGroupCallRecording` for managing group call recordings. + - Added the method `getVideoChatAvailableParticipants`, returning the list of participants, on whose behalf + a video chat in the chat can be joined. + - Added the method `setVideoChatDefaultParticipant` for changing the default participant on whose behalf a video chat + will be joined. + - Added the class `GroupCallVideoQuality` and the method `getGroupCallStreamSegment` for downloading segments of + live streams. + - Added the class `groupCallRecentSpeaker`, representing a group call participant that was recently speaking. + - Added the field `video_chat_changes` to the class `chatEventLogFilters`. + - Added the class `chatEventVideoChatCreated`, representing a video chat being created in the chat event log. + - Added the class `chatEventVideoChatEnded`, representing a video chat being ended in the chat event log. + - Added the class `chatEventVideoChatMuteNewParticipantsToggled`, representing changes of + the setting `mute_new_participants` of a video chat in the chat event log. + - Added the class `chatEventVideoChatParticipantIsMutedToggled`, representing a video chat participant being muted or + unmuted in the chat event log. + - Added the class `chatEventVideoChatParticipantVolumeLevelChanged`, representing a video chat participant's + volume level being changed in the chat event log. +* Added "; pass null" documentation for all TDLib method parameters, for which null is an expected value. +* Added support for link processing: + - Added the method `getInternalLinkType`, which can parse internal links and return the exact link type and actions + to be done when the link is clicked. + - Added the classes `internalLinkTypeActiveSessions`, `internalLinkTypeAuthenticationCode`, + `internalLinkTypeBackground`, `internalLinkTypeBotStart`, `internalLinkTypeBotStartInGroup`, + `internalLinkTypeChangePhoneNumber`, `internalLinkTypeChatInvite`, `internalLinkTypeFilterSettings`, + `internalLinkTypeGame`, `internalLinkTypeLanguagePack`, `internalLinkTypeMessage`, `internalLinkTypeMessageDraft`, + `internalLinkTypePassportDataRequest`, `internalLinkTypePhoneNumberConfirmation`, `internalLinkTypeProxy`, + `internalLinkTypePublicChat`, `internalLinkTypeQrCodeAuthentication`, `internalLinkTypeSettings`, + `internalLinkTypeStickerSet`, `internalLinkTypeTheme`, `internalLinkTypeThemeSettings`, + `internalLinkTypeUnknownDeepLink`, `internalLinkTypeUnsupportedProxy`, and `internalLinkTypeVideoChat` to represent + different types of internal links. + - Added the method `getExternalLinkInfo`, which needs to be called if the clicked link wasn't recognized as + an internal link. + - Added the method `getExternalLink`, which needs to be called after the method `getExternalLinkInfo` if the user + confirms automatic authorization on the website. +* Added support for expiring chat invite links: + - Added the field `is_primary` to the class `chatInviteLink`. The primary invite link can't have a name, + expiration date, or usage limit. There is exactly one primary invite link for each administrator with + the can_invite_users right at any given time. + - Added the field `name` to the class `chatInviteLink`. + - Added the field `creator_user_id` to the class `chatInviteLink`. + - Added the field `date` to the class `chatInviteLink`, containing the link creation date. + - Added the field `edit_date` to the class `chatInviteLink`, containing the date the link was last edited. + - Added the fields `expiration_date` and `member_limit` to the class `chatInviteLink`, limiting link usage. + - Added the field `member_count` to the class `chatInviteLink`. + - Added the field `is_revoked` to the class `chatInviteLink`. + - Changed the type of the fields `invite_link` in the classes `basicGroupFullInfo` and `supergroupFullInfo` to + `chatInviteLink`. + - Added the field `description` to the class `chatInviteLinkInfo`, containing the description of the chat. + - Replaced the method `generateChatInviteLink` with the method `replacePrimaryChatInviteLink`. + - Added the method `createChatInviteLink` for creating new invite links. + - Added the method `editChatInviteLink` for editing non-primary invite links. + - Added the method `revokeChatInviteLink`. + - Added the method `deleteRevokedChatInviteLink`. + - Added the method `deleteAllRevokedChatInviteLink`. + - Added the method `getChatInviteLink`. + - Added the class `chatInviteLinks`, containing a list of chat invite links. + - Added the method `getChatInviteLinks`. + - Added the classes `chatInviteLinkCount` and `chatInviteLinkCounts`. + - Added the method `getChatInviteLinkCounts`, returning the number of invite links created by chat administrators. + - Added the classes `chatInviteLinkMember` and `chatInviteLinkMembers`. + - Added the method `getChatInviteLinkMembers`. + - Added the field `invite_link_changes` to the class `chatEventLogFilters`. + - Added the class `chatEventMemberJoinedByInviteLink`, representing a user joining the chat via invite link in + the chat event log. + - Added the class `chatEventInviteLinkEdited` to the types of chat event. + - Added the class `chatEventInviteLinkRevoked` to the types of chat event. + - Added the class `chatEventInviteLinkDeleted` to the types of chat event. + - Added the class `chatActionBarInviteMembers` to the types of chat action bar. +* Added support for chat invite links that create join requests: + - Added the class `messageChatJoinByRequest` to the types of message content. + - Added the class `pushMessageContentChatJoinByRequest` to the types of push message content. + - Added the field `pending_join_requests` to the class `chat`. + - Added the class `chatJoinRequestsInfo`, containing basic information about pending join requests for the chat. + - Added the update `updateChatPendingJoinRequests`. + - Added the fields `creates_join_request` to the classes `chatInviteLink` and `chatInviteLinkInfo`. + - Added the field `pending_join_request_count` to the class `chatInviteLink`. + - Added the class `chatJoinRequest`, describing a user that sent a join request. + - Added the class `chatJoinRequests`, containing a list of requests to join the chat. + - Added the method `getChatJoinRequests`. + - Added the method `processChatJoinRequest` for processing a request to join the chat. + - Added the method `processChatJoinRequests` for processing all requests to join the chat. + - Added the class `chatActionBarJoinRequest` to the types of chat action bar. + - Added the class `chatEventMemberJoinedByRequest`, representing a user approved to join the chat after + a join request in the chat event log. + - Added the update `updateNewChatJoinRequest` for bots. +* Added the ability to see viewers of outgoing messages in small group chats: + - Added the method `getMessageViewers`. + - Added the field `can_get_viewers` to the class `message`. +* Added the parameter `only_preview` to the method `forwardMessages`, which can be used to receive a preview of + forwarded messages. +* Added the method `getRecentlyOpenedChats`, returning the list of recently opened chats. +* Increased number of recently found chats that are stored to 50. +* Added the ability to get information about chat messages, which are split by days: + - Added the class `messageCalendarDay`, representing found messages, sent on a specific day. + - Added the class `messageCalendar`, representing found messages, split by days. + - Added the writable option "utc_time_offset", which contains a UTC time offset used for splitting messages by days. + The option is reset automatically on each TDLib instance launch, so it needs to be set manually only if + the time offset is changed during execution. + - Added the method `getChatMessageCalendar`, returning information about chat messages, which are split by days. +* Added the ability to get messages of the specified type in sparse positions for hyper-speed scrolling implementation: + - Added the class `messagePosition`, containing an identifier and send date of a message in + a specific chat history position. + - Added the class `messagePositions`, containing a list of message positions. + - Added the method `getChatSparseMessagePositions`. +* Added the field `can_manage_chat` to the class `chatMemberStatusAdministrator` to allow promoting chat administrators + without additional rights. +* Improved support for bot commands: + - Bot command entities in chats without bots are now automatically hidden. + - Added the class `botCommands`, representing a list of bot commands. + - Added the field `commands` to the class `userFullInfo`, containing the list of commands to be used in + the private chat with the bot. + - Added the fields `bot_commands` to the classes `basicGroupFullInfo` and `supergroupFullInfo`. + - Removed the class `botInfo`. + - Removed the fields `bot_info` from the classes `userFullInfo` and `chatMember`. + - Added the class `BotCommandScope`. + - Added the methods `setCommands`, `deleteCommands`, `getCommands` for bots. +* Added the read-only options "suggested_video_note_length", "suggested_video_note_video_bitrate", and + "suggested_video_note_audio_bitrate", containing suggested video note encoding parameters. +* Added the read-only option "channel_bot_user_id", containing the identifier of the bot which is shown in + outdated clients as the sender of messages sent on behalf of channels. +* Added the ability to fetch the actual value of the option "is_location_visible" using the method `getOption` in case + the value of the option was changed from another device. +* Added the field `minithumbnail` to the class `profilePhoto`, representing a profile photo minithumbnail. +* Added the field `minithumbnail` to the class `chatPhotoInfo`, representing a chat photo minithumbnail. +* Added support for sticker outlines: + - Added the field `outline` to the class `sticker`. + - Added the fields `thumbnail_outline` to the classes `stickerSet` and `stickerSetInfo`. + - Added the class `closedVectorPath`, representing a closed vector path. + - Added the class `VectorPathCommand`, representing one edge of a closed vector path. + - Added the class `point`, representing a point on a Cartesian plane. +* Added support for chats and messages with protected content: + - Added the field `has_protected_content` to the class `chat`. + - Added the update `updateChatHasProtectedContent`. + - Added the method `toggleChatHasProtectedContent`. + - Added the class `chatEventHasProtectedContentToggled`, representing a change of the setting `has_protected_content` + in the chat event log. + - Added the field `can_be_saved` to the class `message`. +* Added support for broadcast groups, i.e. supergroups without a limit on the number of members in which + only administrators can send messages: + - Added the field `is_broadcast_group` to the class `supergroup`. + - Added the method `toggleSupergroupIsBroadcastGroup`. Conversion of a supergroup to a broadcast group + can't be undone. + - Added the class `suggestedActionConvertToBroadcastGroup`, representing a suggestion to convert a supergroup to + a broadcast group. +* Improved chat reports: + - Added the parameter `text` to the method `reportChat`, allowing to add additional details to all + chat reporting reasons. + - Removed the field `text` from the class `chatReportReasonCustom`. + - Added the method `reportChatPhoto` for reporting chat photos. +* Added support for users and chats reported as fake: + - Added the field `is_fake` to the class `user`. + - Added the field `is_fake` to the class `supergroup`. + - Added the class `chatReportReasonFake` to the types of chat reporting reasons. +* Added the class `inlineKeyboardButtonTypeUser` to the types of inline keyboard buttons. +* Added the field `input_field_placeholder` to the classes `replyMarkupForceReply` and `replyMarkupShowKeyboard`. +* Added support for media timestamp entities in messages: + - Added the class `textEntityTypeMediaTimestamp` to the types of text entities. + - Added the field `has_timestamped_media` to the class `message`, describing whether media timestamp entities refer + to the message itself or to the replied message. + - Added the parameter `media_timestamp` to the method `getMessageLink` to support creating message links with + a given media timestamp. + - Added the field `can_get_media_timestamp_links` to the class `message`. + - Added the field `media_timestamp` to the class `messageLinkInfo` for handling of message links with + a specified media timestamp. +* Added the ability to change properties of active sessions: + - Added the field `can_accept_secret_chats` to the class `session`. + - Added the method `toggleSessionCanAcceptSecretChats`. + - Added the field `can_accept_calls` to the class `session`. + - Added the method `toggleSessionCanAcceptCalls`. + - Added the field `inactive_session_ttl_days` to the class `sessions`. + - Added the method `setInactiveSessionTtl`. +* Added new ways for phone number verification: + - Added the class `authenticationCodeTypeMissedCall`, describing an authentication code delivered by + a canceled phone call to the given number. The last digits of the phone number that calls are the code that + must be entered manually by the user. + - Added the field `allow_missed_call` to the class `phoneNumberAuthenticationSettings`. + - Added the read-only option "authentication_token", which can be received when logging out and contains + an authentication token to be used on subsequent authorizations. + - Added the field `authentication_tokens` to the class `phoneNumberAuthenticationSettings`. +* Added support for resetting the password from an active session: + - Added the class `ResetPasswordResult` and the method `resetPassword`. + - Added the method `cancelPasswordReset`, which can be used to cancel a pending password reset. + - Added the field `pending_reset_date` to the class `passwordState`. +* Added the ability to set a new 2-step verification password after recovering a lost password using + a recovery email address: + - Added the parameters `new_password` and `new_hint` to the methods `recoverAuthenticationPassword` and + `recoverPassword`. + - Added the method `checkAuthenticationPasswordRecoveryCode`. + - Added the method `checkPasswordRecoveryCode`. +* Added the class `chatActionChoosingSticker` to the types of chat action. +* Added the class `backgroundFillFreeformGradient` to the types of background fill. +* Added the field `is_inverted` to the class `backgroundTypePattern` for inverted patterns for dark themes. +* Added support for chat themes: + - Added the field `theme_name` to the class `chat`. + - Added the method `setChatTheme`. + - Added the update `updateChatTheme`, received when a theme was changed in a chat. + - Added the class `messageChatSetTheme` to the types of message content. + - Added the class `pushMessageContentChatSetTheme` to the types of push message content. + - Added the class `themeSettings`, representing basic theme settings. + - Added the class `chatTheme`, representing a chat theme. + - Added the update `updateChatThemes`, received when the list of available chat themes changes. +* Added the ability for regular users to create sticker sets: + - Allowed to use the methods `uploadStickerFile` and `createNewStickerSet` as regular users. + - Replaced the parameter `png_sticker` in the method `uploadStickerFile` with the parameter `sticker` of + the type `InputSticker`. + - Added the parameter `source` to the method `createNewStickerSet`. + - Added the method `getSuggestedStickerSetName`. + - Added the class `CheckStickerSetNameResult` and the method `checkStickerSetName` for checking a sticker set name + before creating a sticker set. +* Added support for importing chat history from an external source: + - Added the method `importMessages`. + - Added the method `getMessageImportConfirmationText`. + - Added the class `MessageFileType` and the method `getMessageFileType`, which can be used to check whether + the format of a file with exported message history is supported. + - Added the class `messageForwardOriginMessageImport` to the types of forwarded message origins for + imported messages. + - Added the parameter `for_import` to the method `createNewSupergroupChat`, which needs to be set to true whenever + the chat is created for a subsequent message history import. +* Added new types of suggested actions: + - Added the class `suggestedActionSetPassword`, suggesting the user to set a 2-step verification password to be able + to log in again before the specified number of days pass. + - Added the class `suggestedActionCheckPassword`, suggesting the user to check whether they still remember + their 2-step verification password. + - Added the class `suggestedActionViewChecksHint`, suggesting the user to see a hint about the meaning of + one and two check marks on sent messages. +* Added the method `getSuggestedFileName`, which returns a suggested name for saving a file in a given directory. +* Added the method `deleteAllCallMessages`. +* Added the method `deleteChatMessagesByDate`, which can be used to delete all messages between the specified dates in + a chat. +* Added the field `unread_message_count` to the class `messageThreadInfo`. +* Added the field `has_private_forwards` to the class `userFullInfo`. +* Added the field `description` to the class `userFullInfo`, containing description of the bot. +* Added the field `emoji` to the class `inputMessageSticker`, allowing to specify the emoji that was used to choose + the sent sticker. +* Added the method `banChatMember` that can be used to ban chat members instead of the method `setChatMemberStatus` and + allows to revoke messages from the banned user in basic groups. +* Allowed to use the method `setChatMemberStatus` for adding chat members. +* Removed the parameter `user_id` from the method `reportSupergroupSpam`. Messages from different senders can now + be reported simultaneously. +* Added the field `feedback_link` to the class `webPageInstantView`. +* Added the method `getApplicationDownloadLink`, returning the link for downloading official Telegram applications. +* Removed unusable search message filters `searchMessagesFilterCall` and `searchMessagesFilterMissedCall`. +* Removed the method `getChatStatisticsUrl`. +* Removed the method `getInviteText` in favor of the method `getApplicationDownloadLink`. +* Added the field `chat_type` to the update `updateNewInlineQuery` for bots. +* Added the update `updateChatMember` for bots. +* Improved the appearance of the [TDLib build instructions generator](https://tdlib.github.io/td/build.html). +* Added support for the illumos operating system. +* Added support for network access on real watchOS devices. +* Added support for OpenSSL 3.0. +* Improved the iOS/watchOS/tvOS build example to generate a universal XCFramework. +* Added support for ARM64 simulators in the iOS/watchOS/tvOS build example. +* Added the option `-release_only` to the build script for Universal Windows Platform, allowing to build + TDLib SDK for Universal Windows Platform in release-only mode. +* Rewritten the native .NET binding using the new `ClientManager` interface: + - Replaced the method `Client.send` with a static method that must be called exactly once in a dedicated thread. + The callbacks `ClientResultHandler` will be called in this thread for all clients. + - Removed the function `Client.Dispose()` from the C++/CLI native binding. The objects of the type `Client` + don't need to be explicitly disposed anymore. +* Rewritten the C binding using the new `ClientManager` interface: + - Renamed the fields `id` in the structs `TdRequest` and `TdResponse` to `request_id`. + - Added the field `client_id` to the struct `TdResponse`. + - Replaced the method `TdCClientCreate` with the method `TdCClientCreateId`. + - Replaced the parameter `instance` with the parameter `client_id` in the function `TdCClientSend`. + - Added the methods `TdCClientReceive` and `TdCClientExecute`. + - Removed the methods `TdCClientSendCommandSync`, `TdCClientDestroy`, and `TdCClientSetVerbosity`. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.7.0 (28 Nov 2020): + +* Added a new simplified JSON interface in which updates and responses to requests from all TDLib instances + are received in the same thread: + - The TDLib instance is identified by the unique `client_id` identifier, which is returned by the method + `td_create_client_id`. + - Use the method `td_send` to send a request to a specified client. The TDLib instance is created on the first + request sent to it. + - Use the method `td_receive` to receive updates and request responses from TDLib. The response will contain + the identifier of the client from which the event was received in the field "@client_id". + - Use the method `td_execute` to synchronously execute suitable TDLib methods. +* Added support for adding chats to more than one chat list: + - Added the class `chatPosition`, describing the position of the chat within a chat list. + - Replaced the fields `chat_list`, `order`, `is_sponsored` and `is_pinned` in the class `chat` with + the field `positions`, containing a list of the chat positions in various chat list. + - Replaced the field `order` with the field `positions` in the updates `updateChatLastMessage` and + `updateChatDraftMessage`. + - Added the update `updateChatPosition`. + - Removed the superfluous updates `updateChatChatList`, `updateChatIsSponsored`, `updateChatOrder` and + `updateChatIsPinned`. + - Added the parameter `chat_list` to the method `toggleChatIsPinned`. + - Added the class `chatLists`, containing a list of chat lists. + - Added the method `getChatListsToAddChat`, returning all chat lists to which a chat can be added. + - Added the method `addChatToList`, which can be used to add a chat to a chat list. + - Remove the method `setChatChatList`. +* Added support for chat filters: + - Added the new chat list type `chatListFilter`. + - Added the classes `chatFilterInfo` and `chatFilter`, describing a filter of user chats. + - Added the update `updateChatFilters`, which is sent when the list of chat filters is changed. + - Added the methods `createChatFilter`, `editChatFilter` and `deleteChatFilter` for managing chat filters. + - Added the method `reorderChatFilters` for changing the order of chat filters. + - Added the method `getChatFilter`, returning full information about a chat filter. + - Added the synchronous method `getChatFilterDefaultIconName`. + - Added the classes `recommendedChatFilter` and `recommendedChatFilters`. + - Added the method `getRecommendedChatFilters`, returning a list of recommended chat filters. +* Added support for messages sent on behalf of chats instead of users: + - Added the class `MessageSender`, representing a user or a chat which sent a message. + - Added the class `MessageSenders`, representing a list of message senders. + - Replaced the field `sender_user_id` with the field `sender` of the type `MessageSender` in the classes `message` + and `notificationTypeNewPushMessage`. + - Added the class `messageForwardOriginChat`, which describe a chat as the original sender of a message. + - Added the ability to search messages sent by a chat by replacing the parameter `sender_user_id` with + the parameter `sender` of the type `MessageSender` in the method `searchChatMessages`. + - Added the ability to specify a chat as a local message sender by replacing the parameter `sender_user_id` with + the parameter `sender` of the type `MessageSender` in the method `addLocalMessage`. +* Added support for video calls: + - Added the class `callServer`, describing a server for relaying call data. + - Added the classes `callServerTypeTelegramReflector` and `callServerTypeWebrtc`, representing different types of + supported call servers. + - Replaced the field `connections` with the field `servers` in the class `callStateReady`. + - Removed the class `callConnection`. + - Added the update `updateNewCallSignalingData`. + - Added the method `sendCallSignalingData`. + - Added the field `supports_video_calls` to the class `userFullInfo`. + - Added the field `is_video` to the class `messageCall`. + - Added the field `is_video` to the class `call`. + - Added the parameter `is_video` to the method `createCall`. + - Added the parameter `is_video` to the method `discardCall`. + - Added two new types of call problems `callProblemDistortedVideo` and `callProblemPixelatedVideo`. + - Added the field `library_versions` to the class `callProtocol`, which must be used to specify all supported + call library versions. +* Added support for multiple pinned messages and the ability to pin messages in private chats: + - Added the ability to pin messages in all private chats. + - Added the ability to pin mutiple messages in all chats. + - Added the field `is_pinned` to the class `message`. + - Added the update `updateMessageIsPinned`. + - Added the parameter `only_for_self` to the method `pinChatMessage`, allowing to pin messages in private chats for + one side only. + - Added the ability to find pinned messages in a chat using the filter `searchMessagesFilterPinned`. + - Added the parameter `message_id` to the method `unpinChatMessage`. + - Added the field `message` to the class `chatEventMessageUnpinned`. + - Added the method `unpinAllChatMessages`, which can be used to simultaneously unpin all pinned messages in a chat. + - Documented that notifications about new pinned messages are always silent in channels and private chats. + - The method `getChatPinnedMessage` now returns the newest pinned message in the chat. + - Removed the field `pinned_message_id` from the class `chat`. + - Removed the update `updateChatPinnedMessage`. +* Improved thumbnail representation and added support for animated MPEG4 thumbnails: + - Added the class `ThumbnailFormat`, representing the various supported thumbnail formats. + - Added the class `thumbnail`, containing information about a thumbnail. + - Changed the type of all thumbnail fields from `photoSize` to `thumbnail`. + - Added support for thumbnails in the format `thumbnailFormatMpeg4` for some animations and videos. + - Replaced the classes `inputInlineQueryResultAnimatedGif` and `inputInlineQueryResultAnimatedMpeg4` with + the generic class `inputInlineQueryResultAnimation`. + - Added support for animated thumbnails in the class `inputInlineQueryResultAnimation`. + - The class `photoSize` is now only used for JPEG images. +* Improved support for user profile photos and chat photos: + - Added the field `photo` to the class `userFullInfo`, containing full information about the user photo. + - Added the field `photo` to the class `basicGroupFullInfo`, containing full information about the group photo. + - Added the field `photo` to the class `supergroupFullInfo`, containing full information about the group photo. + - Renamed the class `chatPhoto` to `chatPhotoInfo`. + - Added the field `has_animation` to the classes `profilePhoto` and `chatPhotoInfo`, which is set to true for + animated chat photos. + - Added the classes `chatPhoto` and `chatPhotos`. + - Added minithumbnail support via the field `minithumbnail` in the class `chatPhoto`. + - Added the class `animatedChatPhoto`. + - Added animated chat photo support via the field `animation` in the class `chatPhoto`. + - Removed the classes `userProfilePhoto` and `userProfilePhotos`. + - Changed the type of the field `photo` in the class `messageChatChangePhoto` to `chatPhoto`. + - Changed the type of the fields `old_photo` and `new_photo` in the class `chatEventPhotoChanged` to `chatPhoto`. + - Changed the return type of the method `getUserProfilePhotos` to `chatPhotos`. + - Added the class `InputChatPhoto`, representing a chat or a profile photo to set. + - Changed the type of the parameter `photo` in the methods `setProfilePhoto` and `setChatPhoto` to + the `InputChatPhoto`. + - Added the ability to explicitly re-use previously set profile photos using the class `inputChatPhotoPrevious`. + - Added the ability to set animated chat photos using the class `inputChatPhotoAnimated`. +* Added support for message threads in supergroups and channel comments: + - Added the field `message_thread_id` to the class `message`. + - Added the class `messageThreadInfo`, containing information about a message thread. + - Added the class `messageReplyInfo`, containing information about replies to a message. + - Added the field `reply_info` to the class `messageInteractionInfo`, containing information about message replies. + - Added the field `can_get_message_thread` to the class `message`. + - Added the method `getMessageThread`, returning information about the message thread to which a message belongs. + - Added the method `getMessageThreadHistory`, returning messages belonging to a message thread. + - Added the parameter `message_thread_id` to the methods `sendMessage`, `sendMessageAlbum` and + `sendInlineQueryResultMessage` for sending messages within a thread. + - Added the parameter `message_thread_id` to the method `searchChatMessages` to search messages within a thread. + - Added the parameter `message_thread_id` to the method `viewMessages`. + - Added the parameter `message_thread_id` to the method `setChatDraftMessage`. + - Added the parameter `message_thread_id` to the method `sendChatAction` to send chat actions to a thread. + - Added the field `message_thread_id` to the update `updateUserChatAction`. +* Improved support for message albums: + - Added support for sending and receiving messages of the types `messageAudio` and `messageDocument` as albums. + - Added automatic grouping into audio or document albums in the method `forwardMessages` if all forwarded or + copied messages are of the same type. + - Removed the parameter `as_album` from the method `forwardMessages`. Forwarded message albums are now determined + automatically. +* Simplified usage of methods generating an HTTP link to a message: + - Added the class `messageLink`, representing an HTTP link to a message. + - Combined the methods `getPublicMessageLink` and `getMessageLink` into the method `getMessageLink`, which + now returns a public link to the message if possible and a private link otherwise. The combined method is + an offline method now. + - Added the parameter `for_comment` to the method `getMessageLink`, which allows to get a message link to the message + that opens it in a thread. + - Removed the class `publicMessageLink`. + - Added the field `for_comment` to the class `messageLinkInfo`. + - Added the separate method `getMessageEmbeddingCode`, returning an HTML code for embedding a message. +* Added the ability to block private messages sent via the @replies bot from chats: + - Added the field `is_blocked` to the class `chat`. + - Added the update `updateChatIsBlocked`. + - Added the method `blockMessageSenderFromReplies`. + - Replaced the methods `blockUser` and `unblockUser` with the method `toggleMessageSenderIsBlocked`. + - Replaced the method `getBlockedUsers` with the method `getBlockedMessageSenders`. +* Added support for incoming messages which are replies to messages in different chats: + - Added the field `reply_in_chat_id` to the class `message`. + - The method `getRepliedMessage` can now return the replied message in a different chat. +* Renamed the class `sendMessageOptions` to `messageSendOptions`. +* Added the new `tdapi` static library, which needs to be additionally linked in when static linking is used. +* Changed the type of the field `value` in the class `optionValueInteger` from `int32` to `int64`. +* Changed the type of the field `description` in the class `webPage` from `string` to `formattedText`. +* Improved Instant View support: + - Added the field `view_count` to the class `webPageInstantView`. + - Added the class `richTextAnchorLink`, containing a link to an anchor on the same page. + - Added the class `richTextReference`, containing a reference to a text on the same page. + - Removed the field `text` from the class `richTextAnchor`. + - Removed the field `url` which is no longer needed from the class `webPageInstantView`. +* Allowed the update `updateServiceNotification` to be sent before authorization is completed. +* Disallowed to pass messages in non-strictly increasing order to the method `forwardMessages`. +* Improved sending copies of messages: + - Added the class `messageCopyOptions` and the field `copy_options` to the class `inputMessageForwarded`. + - Removed the fields `send_copy` and `remove_caption` from the class `inputMessageForwarded`. + - Allowed to replace captions in copied messages using the fields `replace_caption` and `new_caption` in + the class `messageCopyOptions`. + - Allowed to specify `reply_to_message_id` when sending a copy of a message. + - Allowed to specify `reply_markup` when sending a copy of a message. +* Allowed passing multiple input language codes to `searchEmojis` by replacing the parameter `input_language_code` with + the parameter `input_language_codes`. +* Added support for public service announcements: + - Added the class `ChatSource` and the field `source` to the class `chatPosition`. + - Added the new type of chat source `chatSourcePublicServiceAnnouncement`. + - Added the field `public_service_announcement_type` to the class `messageForwardInfo`. +* Added support for previewing of private supergroups and channels by their invite link. + - The field `chat_id` in the class `chatInviteLinkInfo` is now non-zero for private supergroups and channels to which + the temporary read access is granted. + - Added the field `accessible_for` to the class `chatInviteLinkInfo`, containing the amount of time for which + read access to the chat will remain available. +* Improved methods for message search: + - Replaced the field `next_from_search_id` with a string field `next_offset` in the class `foundMessages`. + - Added the field `total_count` to the class `foundMessages`; can be -1 if the total count of matching messages is + unknown. + - Replaced the parameter `from_search_id` with the parameter `offset` in the method `searchSecretMessages`. + - Added the parameter `filter` to the method `searchMessages`. + - Added the parameters `min_date` and `max_date` to the method `searchMessages` to search messages sent only within + a particular timeframe. +* Added pkg-config file generation for all installed libraries. +* Added automatic operating system version detection. Use an empty field `system_version` in + the class `tdlibParameters` for the automatic detection. +* Increased maximum file size from 1500 MB to 2000 MB. +* Added support for human-friendly Markdown formatting: + - Added the synchronous method `parseMarkdown` for human-friendly parsing of text entities. + - Added the synchronous method `getMarkdownText` for replacing text entities with a human-friendly + Markdown formatting. + - Added the writable option "always_parse_markdown" which enables automatic parsing of text entities in + all `inputMessageText` objects. +* Added support for dice with random values in messages: + - Added the class `messageDice` to the types of message content; contains a dice. + - Added the class `DiceStickers`, containing animated stickers needed to show the dice. + - Added the class `inputMessageDice` to the types of new input message content; can be used to send a dice. + - Added the update `updateDiceEmojis`, containing information about supported dice emojis. +* Added support for chat statistics in channels and supergroups: + - Added the field `can_get_statistics` to the class `supergroupFullInfo`. + - Added the class `ChatStatistics`, which represents a supergroup or a channel statistics. + - Added the method `getChatStatistics` returning detailed statistics about a chat. + - Added the classes `chatStatisticsMessageInteractionInfo`, `chatStatisticsAdministratorActionsInfo`, + `chatStatisticsMessageSenderInfo` and `chatStatisticsInviterInfo` representing various parts of chat statistics. + - Added the class `statisticalValue` describing recent changes of a statistical value. + - Added the class `StatisticalGraph` describing a statistical graph. + - Added the method `getStatisticalGraph`, which can be used for loading asynchronous or zoomed in statistical graphs. + - Added the class `dateRange` representing a date range for which statistics are available. + - Removed the field `can_view_statistics` from the class `supergroupFullInfo` and marked + the method `getChatStatisticsUrl` as disabled and not working. +* Added support for detailed statistics about interactions with messages: + - Added the class `messageInteractionInfo`, containing information about message views, forwards and replies. + - Added the field `interaction_info` to the class `message`. + - Added the update `updateMessageInteractionInfo`. + - Added the field `can_get_statistics` to the class `message`. + - Added the class `messageStatistics`. + - Added the method `getMessageStatistics`. + - Added the method `getMessagePublicForwards`, returning all forwards of a message to public channels. + - Removed the now superfluous field `views` from the class `message`. + - Removed the now superfluous update `updateMessageViews`. +* Improved support for native polls: + - Added the field `explanation` to the class `pollTypeQuiz`. + - Added the fields `close_date` and `open_period` to the class `poll`. + - Added the fields `close_date` and `open_period` to the class `inputMessagePoll`; for bots only. + - Increased maximum poll question length to 300 characters for bots. +* Added support for anonymous administrators in supergroups: + - Added the field `is_anonymous` to the classes `chatMemberStatusCreator` and `chatMemberStatusAdministrator`. + - The field `author_signature` in the class `message` can now contain a custom title of the anonymous administrator + that sent the message. +* Added support for a new type of inline keyboard buttons, requiring user password entry: + - Added the class `inlineKeyboardButtonTypeCallbackWithPassword`, representing a button requiring password entry from + a user. + - Added the class `callbackQueryPayloadDataWithPassword`, representing new type of callback button payload, + which must be used for the buttons of the type `inlineKeyboardButtonTypeCallbackWithPassword`. +* Added support for making the location of the user public: + - Added the writable option "is_location_visible" to allow other users see location of the current user. + - Added the method `setLocation`, which should be called if `getOption("is_location_visible")` is true and location + changes by more than 1 kilometer. +* Improved Notification API: + - Added the field `sender_name` to the class `notificationTypeNewPushMessage`. + - Added the writable option "disable_sent_scheduled_message_notifications" for disabling notifications about + outgoing scheduled messages that were sent. + - Added the field `is_outgoing` to the class `notificationTypeNewPushMessage` for recognizing + outgoing scheduled messages that were sent. + - Added the fields `has_audios` and `has_documents` to the class `pushMessageContentMediaAlbum`. +* Added the field `date` to the class `draftMessage`. +* Added the update `updateStickerSet`, which is sent after a sticker set is changed. +* Added support for pagination in trending sticker sets: + - Added the parameters `offset` and `limit` to the method `getTrendingStickerSets`. + - Changed the field `sticker_sets` in the update `updateTrendingStickerSets` to contain only the prefix of + trending sticker sets. +* Messages that failed to send can now be found using the filter `searchMessagesFilterFailedToSend`. +* Added the ability to disable automatic server-side file type detection using the new field + `disable_content_type_detection` of the class `inputMessageDocument`. +* Improved chat action bar: + - Added the field `can_unarchive` to the classes `chatActionBarReportSpam` and `chatActionBarReportAddBlock`, + which is true whenever the chat was automatically archived. + - Added the field `distance` to the class `chatActionBarReportAddBlock`, + which denotes the distance between the users. +* Added support for actions suggested to the user by the server: + - Added the class `SuggestedAction`, representing possible actions suggested by the server. + - Added the update `updateSuggestedActions`. + - Added the method `hideSuggestedAction`, which can be used to dismiss a suggested action. +* Supported attaching stickers to animations: + - Added the field `has_stickers` to the class `animation`. + - Added the field `added_sticker_file_ids` to the class `inputMessageAnimation`. +* Added methods for phone number formatting: + - Added the class `countryInfo`, describing a country. + - Added the class `countries`, containing a list of countries. + - Added the method `getCountries`, returning a list of all existing countries. + - Added the class `phonenumberinfo` and the method `getPhoneNumberInfo`, which can be used to format a phone number + according to local rules. +* Improved location support: + - Added the field `horizontal_accuracy` to the class `location`. + - Added the field `heading` to the classes `messageLocation` and `inputMessageLocation` for live locations. + - Added the parameter `heading` to the methods `editMessageLiveLocation` and `editInlineMessageLiveLocation`. +* Added support for proximity alerts in live locations: + - Added the field `proximity_alert_radius` to the classes `messageLocation` and `inputMessageLocation`. + - Added the parameter `proximity_alert_radius` to the methods `editMessageLiveLocation` and + `editInlineMessageLiveLocation`. + - Added the new message content `messageProximityAlertTriggered`, received whenever a proximity alert is triggered. +* Added `CentOS 7` and `CentOS 8` operating systems to the + [TDLib build instructions generator](https://tdlib.github.io/td/build.html). +* Added the CMake configuration option TD_ENABLE_MULTI_PROCESSOR_COMPILATION, which can be used to enable parallel + build with MSVC. +* Added support for sending and receiving messages in secret chats with silent notifications. +* Added the field `progressive_sizes` to the class `photo` to allow partial progressive JPEG photo download. +* Added the field `redirect_stderr` to the class `logStreamFile` to allow explicit control over stderr redirection to + the log file. +* Added the read-only option "can_archive_and_mute_new_chats_from_unknown_users", which can be used to check, whether + the option "archive_and_mute_new_chats_from_unknown_users" can be changed. +* Added the writable option "archive_and_mute_new_chats_from_unknown_users", which can be used to automatically archive + and mute new chats from non-contacts. The option can be set only if the option + "can_archive_and_mute_new_chats_from_unknown_users" is true. +* Added the writable option "message_unload_delay", which can be used to change the minimum delay before messages are + unloaded from the memory. +* Added the writable option "disable_persistent_network_statistics", which can be used to disable persistent + network usage statistics, significantly reducing disk usage. +* Added the writable option "disable_time_adjustment_protection", which can be used to disable protection from + external time adjustment, significantly reducing disk usage. +* Added the writable option "ignore_default_disable_notification" to allow the application to manually specify the + `disable_notification` option each time when sending messages instead of following the default per-chat settings. +* Added the read-only option "telegram_service_notifications_chat_id", containing the identifier of + the Telegram service notifications chat. +* Added the read-only option "replies_bot_chat_id", containing the identifier of the @replies bot. +* Added the read-only option "group_anonymous_bot_user_id", containing the identifier of the bot which is shown as + the sender of anonymous group messages when viewed from an outdated client. +* Added the new venue provider value "gplaces" for Google Places. +* Added the parameter `return_deleted_file_statistics` to the method `optimizeStorage` to return information about + the files that were deleted instead of the ones that were not. +* Added the ability to search for supergroup members to mention by their name and username: + - Added the new filter `supergroupMembersFilterMention` for the method `getSupergroupMembers`. + - Added the new filter `chatMembersFilterMention` for the method `searchChatMembers`. +* Added support for highlighting bank card numbers: + - Added the new text entity `textEntityTypeBankCardNumber`. + - Added the classes `bankCardInfo` and `bankCardActionOpenUrl`, containing information about a bank card. + - Added the method `getBankCardInfo`, returning information about a bank card. +* Improved methods for managing sticker sets by bots: + - Added the method `setStickerSetThumbnail`. + - Added the ability to create new animated sticker sets and add new stickers to them by adding + the class `inputStickerAnimated`. + - Renamed the class `inputSticker` to `inputStickerStatic`. + - Renamed the field `png_sticker` to `sticker` in the class `inputStickerStatic`. +* Added the method `setCommands` for bots. +* Added the method `getCallbackQueryMessage` for bots. +* Added support for starting bots in private chats through `sendBotStartMessage`. +* Added the field `total_count` to the class `chats`. The field should have a precise value for the responses of + the methods `getChats`, `searchChats` and `getGroupsInCommon`. +* Added the update `updateAnimationSearchParameters`, containing information about animation search parameters. +* Documented that `getRepliedMessage` can be used to get a pinned message, a game message, or an invoice message for + messages of the types `messagePinMessage`, `messageGameScore`, and `messagePaymentSuccessful` respectively. +* Added guarantees that the field `member_count` in the class `supergroup` is known if the supergroup was received from + the methods `searchChatsNearby`, `getInactiveSupergroupChats`, `getSuitableDiscussionChats`, `getGroupsInCommon`, or + `getUserPrivacySettingRules`. +* Updated SQLCipher to 4.4.0. +* Updated dependencies in the prebuilt TDLib for Android: + - Updated SDK to SDK 30. + - Updated NDK to r21d, which dropped support for 32-bit ARM devices without Neon support. +* Updated recommended `emsdk` version for `tdweb` building to the 2.0.6. +* Removed the ability to change the update handler after client creation in native .NET binding, Java example and + prebuilt library for Android. +* Removed the ability to change the default exception handler after client creation in Java example and + prebuilt library for Android. +* Removed the ability to close Client using close() method in Java example and prebuilt library for Android. + Use the method TdApi.close() instead. +* Changed license of source code in prebuilt library for Android to Boost Software License, Version 1.0. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.6.0 (31 Jan 2020): + +* Added support for multiple chat lists. Currently, only two chat lists Main and Archive are supported: + - Added the class `ChatList`, which represents a chat list and could be `chatListMain` or `chatListArchive`. + - Added the field `chat_list` to the class `chat`, denoting the chat list to which the chat belongs. + - Added the parameter `chat_list` to the methods `getChats`, `searchMessages` and `setPinnedChats`. + - Added the field `chat_list` to the updates `updateUnreadMessageCount` and `updateUnreadChatCount`. + - Added the field `total_count` to the update `updateUnreadChatCount`, containing the total number of chats in + the list. + - Added the update `updateChatChatList`, which is sent after a chat is moved to or from a chat list. + - Added the method `setChatChatList`, which can be used to move a chat between chat lists. + - Added the option `pinned_archived_chat_count_max` for the maximum number of pinned chats in the Archive chat list. +* Added support for scheduled messages: + - Added the classes `messageSchedulingStateSendAtDate` and `messageSchedulingStateSendWhenOnline`, + representing the scheduling state of a message. + - Added the field `scheduling_state` to the class `message`, which allows to distinguish between scheduled and + ordinary messages. + - The update `updateNewMessage` can now contain a scheduled message and must be handled appropriately. + - The updates `updateMessageContent`, `updateDeleteMessages`, `updateMessageViews`, `updateMessageSendSucceeded`, + `updateMessageSendFailed`, and `updateMessageSendAcknowledged` can now contain identifiers of scheduled messages. + - Added the class `sendMessageOptions`, which contains options for sending messages, + including the scheduling state of the messages. + - Replaced the parameters `disable_notification` and `from_background` in the methods `sendMessage`, + `sendMessageAlbum`, `sendInlineQueryResultMessage`, and `forwardMessages` with the new field `options` of + the type `sendMessageOptions`. + - Added the method `editMessageSchedulingState`, which can be used to reschedule a message or send it immediately. + - Added the method `getChatScheduledMessages`, which returns all scheduled messages in a chat. + - Added the field `has_scheduled_messages` to the class `chat`. + - Added the update `updateChatHasScheduledMessages`, which is sent whenever the field `has_scheduled_messages` + changes in a chat. + - Added support for reminders in Saved Messages and notifications about other sent scheduled messages in + the [Notification API](https://core.telegram.org/tdlib/notification-api/). +* Added support for adding users without a known phone number to the list of contacts: + - Added the method `addContact` for adding or renaming contacts without a known phone number. + - Added the field `need_phone_number_privacy_exception` to the class `userFullInfo`, containing the default value for + the second parameter of the method `addContact`. + - Added the fields `is_contact` and `is_mutual_contact` to the class `user`. + - Removed the class `LinkState` and the fields `outgoing_link` and `incoming_link` from the class `user`. +* Improved support for the top chat action bar: + - Added the class `ChatActionBar`, representing all possible types of the action bar. + - Added the field `action_bar` to the class `chat`. + - Removed the legacy class `chatReportSpamState`. + - Removed the legacy methods `getChatReportSpamState` and `changeChatReportSpamState`. + - Added the update `updateChatActionBar`. + - Added the method `removeChatActionBar`, which allows to dismiss the action bar. + - Added the method `sharePhoneNumber`, allowing to share the phone number of the current user with a mutual contact. + - Added the new reason `chatReportReasonUnrelatedLocation` for reporting location-based groups unrelated to + their stated location. +* Improved support for text entities: + - Added the new types of text entities `textEntityTypeUnderline` and `textEntityTypeStrikethrough`. + - Added support for nested entities. Entities can be nested, but must not mutually intersect with each other. + Pre, Code and PreCode entities can't contain other entities. Bold, Italic, Underline and Strikethrough entities can + contain and be contained in all other entities. All other entities can't contain each other. + - Added the field `version` to the method `textParseModeMarkdown`. Versions 0 and 1 correspond to Bot API Markdown + parse mode, version 2 to Bot API MarkdownV2 parse mode with underline, strikethrough and nested entities support. + - The new entity types and nested entities are supported in secret chats also if its layer is at least 101. +* Added support for native non-anonymous, multiple answer, and quiz-style polls: + - Added support for quiz-style polls, which has exactly one correct answer option and can be answered only once. + - Added support for regular polls, which allows multiple answers. + - Added the classes `pollTypeRegular` and `pollTypeQuiz`, representing the possible types of a poll. + - Added the field `type` to the classes `poll` and `inputMessagePoll`. + - Added support for non-anonymous polls with visible votes by adding the field `is_anonymous` to the classes `poll` + and `inputMessagePoll`. + - Added the method `getPollVoters` returning users that voted for the specified option in a non-anonymous poll. + - Added the new reply markup keyboard button `keyboardButtonTypeRequestPoll`. + - Added the field `is_regular` to the class `pushMessageContentPoll`. + - Added the update `updatePollAnswer` for bots only. + - Added the field `is_closed` to the class `inputMessagePoll`, which can be used by bots to send a closed poll. +* Clarified in the documentation that file remote ID is guaranteed to be usable only if the corresponding file is + still accessible to the user and is known to TDLib. For example, if the file is from a message, then the message + must be not deleted and accessible to the user. If the file database is disabled, then the corresponding object with + the file must be preloaded by the client. +* Added support for administrator custom titles: + - Added the field `custom_title` to `chatMemberStatusCreator` and `chatMemberStatusAdministrator` classes. + - Added the classes `chatAdministrator` and `chatAdministrators`, containing user identifiers along with + their custom administrator title and owner status. + - Replaced the result type of the method `getChatAdministrators` with `chatAdministrators`. +* Improved Instant View support: + - Added the new web page block `pageBlockVoiceNote`. + - Changed value of invisible cells in `pageBlockTableCell` to null. + - Added the field `is_cached` to the class `richTextUrl`. +* Improved support for chat backgrounds: + - Added the classes `backgroundFillSolid` for solid color backgrounds and `backgroundFillGradient` for + gradient backgrounds. + - Added support for TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") background patterns + in addition to PNG patterns. Background pattern thumbnails are still always in PNG format. + - Replaced the field `color` in the class `backgroundTypePattern` with the field `fill` of type `BackgroundFill`. + - Replaced the class `backgroundTypeSolid` with the class `backgroundTypeFill`. +* Added support for discussion groups for channel chats: + - Added the field `linked_chat_id` to the class `supergroupFullInfo` containing the identifier of a discussion + supergroup for the channel, or a channel, for which the supergroup is the designated discussion supergroup. + - Added the field `has_linked_chat` to the class `supergroup`. + - Added the method `getSuitableDiscussionChats`, which returns a list of chats which can be assigned as + a discussion group for a channel by the current user. + - Added the method `setChatDiscussionGroup`, which can be used to add or remove a discussion group from a channel. + - Added the class `chatEventLinkedChatChanged` representing a change of the linked chat in the chat event log. +* Added support for slow mode in supergroups: + - Added the field `is_slow_mode_enabled` to the class `supergroup`. + - Added the field `slow_mode_delay` to the class `supergroupFullInfo`. + - Added the method `setChatSlowModeDelay`, which can be used to change the slow mode delay setting in a supergroup. + - Added the class `chatEventSlowModeDelayChanged` representing a change of the slow mode delay setting in + the chat event log. +* Improved privacy settings support: + - Added the classes `userPrivacySettingRuleAllowChatMembers` and `userPrivacySettingRuleRestrictChatMembers` + to include or exclude all group members in a privacy setting rule. + - Added the class `userPrivacySettingShowPhoneNumber` for managing the visibility of the user's phone number. + - Added the class `userPrivacySettingAllowFindingByPhoneNumber` for managing whether the user can be found by + their phone number. +* Added the method `checkCreatedPublicChatsLimit` for checking whether the maximum number of owned public chats + has been reached. +* Added support for transferring ownership of supergroup and channel chats: + - Added the method `transferChatOwnership`. + - Added the class `CanTransferOwnershipResult` and the method `canTransferOwnership` for checking + whether chat ownership can be transferred from the current session. +* Added support for location-based supergroups: + - Added the class `chatLocation`, which contains the location to which the supergroup is connected. + - Added the field `has_location` to the class `supergroup`. + - Added the field `location` to the class `supergroupFullInfo`. + - Added the ability to create location-based supergroups via the new field `location` in + the method `createNewSupergroupChat`. + - Added the method `setChatLocation`, which allows to change location of location-based supergroups. + - Added the field `can_set_location` to the class `supergroupFullInfo`. + - Added the class `PublicChatType`, which can be one of `publicChatTypeHasUsername` or + `publicChatTypeIsLocationBased`. + - Added the parameter `type` to the method `getCreatedPublicChats`, which allows to get location-based supergroups + owned by the user. + - Supported location-based supergroups as public chats where appropriate. + - Added the class `chatEventLocationChanged` representing a change of the location of a chat in the chat event log. +* Added support for searching chats and users nearby: + - Added the classes `chatNearby` and `chatsNearby`, containing information about chats along with + the distance to them. + - Added the method `searchChatsNearby`, which returns chats and users nearby. + - Added the update `updateUsersNearby`, which is sent 60 seconds after a successful `searchChatsNearby` request. +* Improved support for inline keyboard buttons of the type `inlineKeyboardButtonTypeLoginUrl`: + - Added the class `LoginUrlInfo` and the method `getLoginUrlInfo`, which allows to get information about + an inline button of the type `inlineKeyboardButtonTypeLoginUrl`. + - Added the method `getLoginUrl` for automatic authorization on the target website. +* Improved support for content restrictions: + - The field `restriction_reason` in the classes `user` and `channel` now contains only a human-readable description + why access must be restricted. It is non-empty if and only if access to the chat needs to be restricted. + - Added the field `restriction_reason` to the class `message`. It is non-empty if and only if access to the message + needs to be restricted. + - Added the writable option `ignore_platform_restrictions`, which can be set in non-store apps to ignore restrictions + specific to the currently used operating system. + - Added the writable option `ignore_sensitive_content_restrictions`, which can be set to show sensitive content on + all user devices. `getOption("ignore_sensitive_content_restrictions")` can be used to fetch the actual value of + the option, the option will not be immediately updated after a change from another device. + - Added the read-only option `can_ignore_sensitive_content_restrictions`, which can be used to check, whether + the option `ignore_sensitive_content_restrictions` can be changed. +* Added support for QR code authentication for already registered users: + - Added the authorization state `authorizationStateWaitOtherDeviceConfirmation`. + - Added the method `requestQrCodeAuthentication`, which can be used in the `authorizationStateWaitPhoneNumber` state + instead of the method `setAuthenticationPhoneNumber` to request QR code authentication. + - Added the method `confirmQrCodeAuthentication` for authentication confirmation from another device. +* Added the update `updateMessageLiveLocationViewed`, which is supposed to trigger an edit of the corresponding + live location. +* Added the parameter `input_language_code` to the method `searchEmojis`. +* Added the method `getInactiveSupergroupChats`, to be used when the user receives a CHANNELS_TOO_MUCH error after + reaching the limit on the number of joined supergroup and channel chats. +* Added the field `unique_id` to the class `remoteFile`, which can be used to identify the same file for + different users. +* Added the new category of top chat list `topChatCategoryForwardChats`. +* Added the read-only option `animated_emoji_sticker_set_name`, containing name of a sticker set with animated emojis. +* Added the read-only option `unix_time`, containing an estimation of the current Unix timestamp. + The option will not be updated automatically unless the difference between the previous estimation and + the locally available monotonic clocks changes significantly. +* Added the field `is_silent` to the class `notification`, so silent notifications can be shown with + the appropriate mark. +* Added the field `video_upload_bitrate` to the class `autoDownloadSettings`. +* Disallowed to call `setChatNotificationSettings` method on the chat with self, which never worked. +* Added support for `ton://` URLs in messages and inline keyboard buttons. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.5.0 (9 Sep 2019): + +* Changed authorization workflow: + - Added the state `authorizationStateWaitRegistration`, which will be received after `authorizationStateWaitCode` for + users who are not registered yet. + - Added the method `registerUser`, which must be used in the `authorizationStateWaitRegistration` state to finish + registration of the user. + - Removed the fields `is_registered` and `terms_of_service` from the class `authorizationStateWaitCode`. + - Removed the parameters `first_name` and `last_name` from the method `checkAuthenticationCode`. +* Added support for messages with an unknown sender (zero `sender_user_id`) in private chats, basic groups and + supergroups. Currently, the sender is unknown for posts in channels and for channel posts automatically forwarded to + the discussion group. +* Added support for the new permission system for non-administrator users in groups: + - Added the class `chatPermissions` containing all supported permissions, including new permissions `can_send_polls`, + `can_change_info`, `can_invite_users` and `can_pin_messages`. + - Added the field `permissions` to the class `chat`, describing actions that non-administrator chat members are + allowed to take in the chat. + - Added the update `updateChatPermissions`. + - Added the method `setChatPermissions` for changing chat permissions. + - Added the class `chatEventPermissionsChanged` representing a change of chat permissions in the chat event log. + - Replaced the fields `can_send_messages`, `can_send_media_messages`, `can_send_other_messages`, + `can_add_web_page_previews` in the class `chatMemberStatusRestricted` with the field `permissions` of + the type `chatPermissions`. + - Removed the field `everyone_is_administrator` from the `basicGroup` class in favor of the field `permissions` of + the class `chat`. + - Removed the field `anyone_can_invite` from the `supergroup` class in favor of the field `permissions` of + the class `chat`. + - Removed the method `toggleBasicGroupAdministrators` in favor of `setChatPermissions`. + - Removed the method `toggleSupergroupInvites` in favor of `setChatPermissions`. + - Renamed the field `anyone_can_invite` to `can_invite_users` in the class `chatEventInvitesToggled`. + - The permissions `can_send_other_messages` and `can_add_web_page_previews` now imply only `can_send_messages` + instead of `can_send_media_messages`. + - Allowed administrators in basic groups to use the method `generateChatInviteLink`. +* Added out of the box `OpenBSD` and `NetBSD` operating systems support. +* Added possibility to use `LibreSSL` >= 2.7.0 instead of `OpenSSL` to build TDLib. +* Added instructions for building TDLib on `Debian 10`, `OpenBSD` and `NetBSD` to + the [TDLib build instructions generator](https://tdlib.github.io/td/build.html). +* Added support for Backgrounds 2.0: + - Added the classes `BackgroundType`, `background`, `backgrounds` and `InputBackground`. + - Added the method `getBackground` returning the list of backgrounds installed by the user. + - Added the method `setBackground` for changing the background selected by the user. + - Added the update `updateSelectedBackground`, which is sent right after a successful initialization and whenever + the selected background changes. + - Added the method `removeBackground` for removing a background from the list of installed backgrounds. + - Added the method `resetBackgrounds` for restoring the default list of installed backgrounds. + - Added the method `searchBackground` returning a background by its name. + - Added the method `getBackgroundUrl` returning a persistent URL for a background. + - Removed the `getWallpapers` method. + - Removed the `wallpaper` and the `wallpapers` classes. + - The class `fileTypeWallpaper` can be used for remote file identifiers of both old wallpapers and new backgrounds. +* Added support for descriptions in basic groups: + - Added the field `description` to the class `basicGroupFullInfo`. + - Replaced the method `setSupergroupDescription` with `setChatDescription` which can be used for any chat type. +* Added support for emoji suggestions: + - Added the method `searchEmojis` for searching emojis by keywords. + - Added the method `getEmojiSuggestionsUrl`, which can be used to automatically log in to the translation platform + and suggest new emoji replacements. + - Renamed the class `stickerEmojis` to `emojis`. +* Changed type of the fields `old_photo` and `new_photo` in the class `chatEventPhotoChanged` from `chatPhoto` to + `photo`. +* Changed recommended size for `inputThumbnail` from 90x90 to 320x320. +* Combined all supported settings for phone number authentication: + - Added the class `phoneNumberAuthenticationSettings` which contains all the settings. + - Replaced the parameters `is_current_phone_number` and `allow_flash_call` in the methods + `setAuthenticationPhoneNumber`, `sendPhoneNumberConfirmationCode`, `sendPhoneNumberVerificationCode` and + `changePhoneNumber` with the parameter `settings` of the type `phoneNumberAuthenticationSettings`. + - Added support for automatic SMS code verification for official applications via the new field `allow_app_hash` in + the class `phoneNumberAuthenticationSettings`. +* Added support for auto-download settings presets. + - Added the classes `autoDownloadSettings` and `autoDownloadSettingsPresets`. + - Added the method `getAutoDownloadSettingsPresets` for getting the settings. + - Added the method `setAutoDownloadSettings`, which needs to be called whenever the user changes the settings. +* Added support for minithumbnails - thumbnail images of a very poor quality and low resolution: + - Added the class `minithumbnail`. + - Added the field `minithumbnail` to `animation`, `document`, `photo`, `video` and `videoNote` classes. + - Added the field `audio_cover_minithumbnail` to the class `audio`. +* Added support for resending messages which failed to send: + - Added the fields `error_code`, `error_message`, `can_retry` and `retry_after` to + the class `messageSendingStateFailed`. + - Added the method `resendMessages`. +* Added the field `is_animated` to the `sticker`, `stickerSet` and `stickerSetInfo` classes. + Animated stickers can be received anywhere where non-animated stickers can appear. +* Added the parameters `send_copy` and `remove_caption` to the `forwardMessages` method to allow forwarding of + messages without links to the originals. +* Added the fields `send_copy` and `remove_caption` to `inputMessageForwarded` method to allow forwarding of + a message without link to the original message. +* Added the method `getMessageLinkInfo` for getting information about a link to a message in a chat. +* Added the class `userPrivacySettingShowProfilePhoto` for managing visibility of the user's profile photo. +* Added the class `userPrivacySettingShowLinkInForwardedMessages` for managing whether a link to the user's account is + included with forwarded messages. +* Added the field `thumbnail` to the classes `stickerSet` and `stickerSetInfo`, containing a thumbnail for + the sticker set. +* Added the field `is_scam` to the classes `user` and `supergroup`. +* Added a new kind of inline keyboard button `inlineKeyboardButtonTypeLoginUrl`, which for the moment must be processed + in the same way as an `inlineKeyboardButtonTypeUrl`. +* Added the new class `supergroupMembersFilterContacts`, allowing to only search for contacts + in `getSupergroupMembers`. +* Added the new class `chatMembersFilterContacts`, allowing to only search for contacts in `searchChatMembers`. +* Added the class `chatEventPollStopped` representing the closing of a poll in a message in the chat event log. +* Added ability to specify the exact types of problems with a call in the method `sendCallRating` and + the new class `CallProblem`. +* Changes in [tdweb](https://github.com/tdlib/td/blob/master/example/web/): + - Supported non-zero `offset` and `limit` in `readFilePart`. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.4.0 (1 May 2019): + +* Added a [TDLib build instructions generator](https://tdlib.github.io/td/build.html), covering in details + TDLib building on the most popular operating systems. +* Added an example of TDLib building and usage from a browser. + See https://github.com/tdlib/td/blob/master/example/web/ for more details. +* Allowed to pass NULL pointer to `td_json_client_execute` instead of a previously created JSON client. + Now you can use synchronous TDLib methods through a JSON interface before creating a TDLib JSON client. +* Added support for media streaming by allowing to download any part of a file: + - Added the `offset` parameter to `downloadFile` which specifies the starting position + from which the file should be downloaded. + - Added the `limit` parameter to `downloadFile` which specifies how many bytes should be downloaded starting from + the `offset` position. + - Added the field `download_offset` to the class `localFile` which contains the current download offset. + - The field `downloaded_prefix_size` of the `localFile` class now contains the number of available bytes + from the position `download_offset` instead of from the beginning of the file. + - Added the method `getFileDownloadedPrefixSize` which can be used to get the number of locally available file bytes + from a given offset without actually changing the download offset. +* Added the parameter `synchronous` to `downloadFile` which causes the request to return the result only after + the download is completed. +* Added support for native polls in messages: + - Added `messagePoll` to the types of message content; contains a poll. + - Added the classes `poll` and `pollOption` describing a poll and a poll answer option respectively. + - Added `inputMessagePoll` to the types of new input message content; can be used to send a poll. + - Added the method `setPollAnswer` which can be used for voting in polls. + - Added the method `stopPoll` which can be used to stop polls. Use the `Message.can_be_edited` field to check whether + this method can be called on a message. + - Added the update `updatePoll` for bots only. Ordinary users receive poll updates through `updateMessageContent`. +* Added a Notification API. See article https://core.telegram.org/tdlib/notification-api for a detailed description. + - Added the class `pushReceiverId` which contains a globally unique identifier of the push notification subscription. + - Changed the return type of the method `registerDevice` to `pushReceiverId` to allow matching of push notifications + with TDLib instances. + - Removed the fields `disable_notification` and `contains_mention` from `updateNewMessage`. + - Renamed the class `deviceTokenGoogleCloudMessaging` to `deviceTokenFirebaseCloudMessaging`. + - Added the field `encrypt` to classes `deviceTokenApplePushVoIP` and `deviceTokenFirebaseCloudMessaging` + which allows to subscribe for end-to-end encrypted push notifications. + - Added the option `notification_group_count_max` which can be used to enable the Notification API and set + the maximum number of notification groups to be shown simultaneously. + - Added the option `notification_group_size_max` which can be used to set the maximum number of simultaneously shown + notifications in a group. + - Added the synchronous method `getPushReceiverId` for matching a push notification with a TDLib instance. + - Added the method `processPushNotification` for handling of push notifications. + - Removed the method `processDcUpdate` in favor of the general `processPushNotification` method. + - Added the update `updateNotificationGroup`, sent whenever a notification group changes. + - Added the update `updateNotification`, sent whenever a notification changes. + - Added the update `updateActiveNotifications` for syncing the list of active notifications on startup. + - Added the update `updateHavePendingNotifications` which can be used to improve lifetime handling of + the TDLib instance. + - Added the possibility to disable special handling of notifications about pinned messages via the new settings + `use_default_disable_pinned_message_notifications`, `disable_pinned_message_notifications` in + the class `chatNotificationSettings` and the new setting `disable_pinned_message_notifications` in + the class `scopeNotificationSettings`. + - Added the possibility to disable special handling of notifications about mentions and replies via the new settings + `use_default_disable_mention_notifications`, `disable_mention_notifications` in + the class `chatNotificationSettings` and the new setting `disable_mention_notifications` in + the class `scopeNotificationSettings`. + - Added the class `PushMessageContent` describing the content of a notification, received through + a push notification. + - Added the class `NotificationType` describing a type of a notification. + - Added the class `notification` containing information about a notification. + - Added the class `NotificationGroupType` describing a type of a notification group. + - Added the class `notificationGroup` describing a state of a notification group. + - Added the methods `removeNotification` and `removeNotificationGroup` for handling notifications removal + by the user. + - Added the separate notification scope `notificationSettingsScopeChannelChats` for channel chats. +* Added support for pinned notifications in basic groups and Saved Messages: + - Added the field `pinned_message_id` to the class `chat`. + - Removed the field `pinned_message_id` from the class `supergroupFullInfo` in favor of `chat.pinned_message_id`. + - Added the update `updateChatPinnedMessage`. + - The right `can_pin_messages` is now applicable to both basic groups and supergroups. + - Replaced the method `pinSupergroupMessage` with `pinChatMessage` which can be used for any chat type. + - Replaced the method `unpinSupergroupMessage` with `unpinChatMessage` which can be used for any chat type. +* Added new synchronous methods for managing TDLib internal logging. The old functions are deprecated and + will be removed in TDLib 2.0.0. + - Added the synchronous method `setLogStream` for changing the stream to which the TDLib internal log is written. + - Added the synchronous method `getLogStream` for getting information about the currently used log stream. + - Added the classes `logStreamDefault`, `logStreamFile` and `logStreamEmpty` describing different supported kinds of + log streams. + - Added the class `logVerbosityLevel` containing the verbosity level of the TDLib internal log. + - Added the class `logTags` containing a list of available TDLib internal log tags. + - Added the synchronous method `setLogVerbosityLevel` for changing verbosity level of logging. + - Added the synchronous method `getLogVerbosityLevel` for getting the current verbosity level of logging. + - Added the synchronous method `getLogTags` returning all currently supported log tags. + - Added the synchronous method `setLogTagVerbosityLevel` for changing the verbosity level of logging for + some specific part of the code. + - Added the synchronous method `getLogTagVerbosityLevel` for getting the current verbosity level for a specific part + of the code. + - Added the synchronous method `addLogMessage` for using the TDLib internal log by the application. +* Added support for Instant View 2.0: + - Replaced the field `has_instant_view` in class `webPage` with the `instant_view_version` field. + - Added the field `version` to the class `webPageInstantView`. + - Added the class `pageBlockCaption`. + - Changed the type of `caption` fields in `pageBlockAnimation`, `pageBlockAudio`, `pageBlockPhoto`, `pageBlockVideo`, + `pageBlockEmbedded`, `pageBlockEmbeddedPost`, `pageBlockCollage` and `pageBlockSlideshow` from + `RichText` to `pageBlockCaption`. + - Added the class `pageBlockListItem` and replaced the content of the `pageBlockList` class with a list of + `pageBlockListItem`. + - Added 6 new kinds of `RichText`: `richTextSubscript`, `richTextSuperscript`, `richTextMarked`, + `richTextPhoneNumber`, `richTextIcon` and `richTextAnchor`. + - Added new classes `pageBlockRelatedArticle`, `PageBlockHorizontalAlignment`, `PageBlockVerticalAlignment` and + `pageBlockTableCell`. + - Added new block types `pageBlockKicker`, `pageBlockRelatedArticles`, `pageBlockTable`, `pageBlockDetails` and + `pageBlockMap`. + - Added the flag `is_rtl` to the class `webPageInstantView`. + - Renamed the field `caption` in classes `pageBlockBlockQuote` and `pageBlockPullQuote` to `credit`. + - Dimensions in `pageBlockEmbedded` can now be unknown. + - Added the field `url` to `pageBlockPhoto` which contains a URL that needs to be opened when the photo is clicked. + - Added the field `url` to `webPageInstantView` which must be used for the correct handling of anchors. +* Added methods for confirmation of the 2-step verification recovery email address: + - Added the method `checkRecoveryEmailAddressCode` for checking the verification code. + - Added the method `resendRecoveryEmailAddressCode` for resending the verification code. + - Replaced the field `unconfirmed_recovery_email_address_pattern` in the class `passwordState` with + the `recovery_email_address_code_info` field containing full information about the code. + - The necessity of recovery email address confirmation in `setPassword` and `setRecoveryEmailAddress` methods + is now returned by the corresponding `passwordState` and not by the error `EMAIL_UNCONFIRMED`. +* Improved the `MessageForwardInfo` class and added support for hidden original senders: + - Removed the old `messageForwardedPost` and `messageForwardedFromUser` classes. + - Added the class `messageForwardInfo` which contains information about the origin of the message, original sending + date and identifies the place from which the message was forwarded the last time for messages forwarded to + Saved Messages. + - Added the classes `messageForwardOriginUser`, `messageForwardOriginHiddenUser` and `messageForwardOriginChannel` + which describe the exact origins of a message. +* Improved getting the list of user profile photos: + - Added the class `userProfilePhoto`, containing `id`, `added_date` and `sizes` of a profile photo. + - Changed the type of the field `photos` in `userProfilePhotos` to a list of `userProfilePhoto` instead of + a list of `photo`. `getUserProfilePhotos` now returns a date for each profile photo. + - Removed the field `id` from the class `photo` (this field was only needed in the result of `getUserProfilePhotos`). +* Added the possibility to get a Telegram Passport authorization form before asking the user for a password: + - Removed the parameter `password` from the method `getPassportAuthorizationForm`. + - Moved the fields `elements` and `errors` from the class `passportAuthorizationForm` to + the new class `passportElementsWithErrors`. + - Added the method `getPassportAuthorizationFormAvailableElements` that takes the user's password and + returns previously uploaded Telegram Passport elements and errors in them. +* Added the field `file_index` to the classes `passportElementErrorSourceFile` and + `passportElementErrorSourceTranslationFile`. +* Added the method `getCurrentState` returning all updates describing the current `TDLib` state. It can be used to + restore the correct state after connecting to a running TDLib instance. +* Added the class `updates` which contains a list of updates and is returned by the `getCurrentState` method. +* Added the update `updateChatOnlineMemberCount` which is automatically sent for open group chats if the number of + online members in a group changes. +* Added support for custom language packs downloaded from the server: + - Added the fields `base_language_pack_id`` to the class `languagePackInfo`. Strings from the base language pack + must be used for untranslated keys from the chosen language pack. + - Added the fields `plural_code`, `is_official`, `is_rtl`, `is_beta`, `is_installed`, `total_string_count`, + `translated_string_count`, `translation_url` to the class `languagePackInfo`. + - Added the method `addCustomServerLanguagePack` which adds a custom server language pack to the list of + installed language packs. + - Added the method `getLanguagePackInfo` which can be used for handling `https://t.me/setlanguage/...` links. + - Added the method `synchronizeLanguagePack` which can be used to fetch the latest versions of all strings from + a language pack. + The method doesn't need to be called explicitly for the current used/base language packs. + - The method `deleteLanguagePack` now also removes the language pack from the list of installed language packs. +* Added the method `getChatNotificationSettingsExceptions` which can be used to get chats with + non-default notification settings. +* Added the parameter `hide_via_bot` to `sendInlineQueryResultMessage` which can be used for + `getOption("animation_search_bot_username")`, `getOption("photo_search_bot_username")` and + `getOption("venue_search_bot_username")` bots to hide that the message was sent via the bot. +* Added the class `chatReportReasonChildAbuse` which can be used to report a chat for child abuse. +* Added the method `getMessageLocally` which returns a message only if it is available locally without + a network request. +* Added the method `writeGeneratedFilePart` which can be used to write a generated file if there is no direct access to + TDLib's file system. +* Added the method `readFilePart` which can be used to read a file from the TDLib file cache. +* Added the class `filePart` to represent the result of the new `readFilePart` method. +* Added the field `log_size` to the `storageStatisticsFast` class which contains the size of the TDLib internal log. + Previously the size was included into the value of the `database_size` field. +* Added the field `language_pack_database_size` to the `storageStatisticsFast` class which contains the size of the + language pack database. +* Added the field `is_support` to the class `user` which can be used to identify Telegram Support accounts. +* Added the class `HttpUrl` encapsulating an HTTP URL. +* Added the method `getMessageLink` which can be used to create a private link (which works only for members) to + a message in a supergroup or channel. +* Added support for channel statistics (coming soon): + - Added the field `can_view_statistics` to the `supergroupFullInfo` class. + - Added the method `getChatStatisticsUrl` which returns a URL with the chat statistics. +* Added support for server-side peer-to-peer calls privacy: + - Added the class `userPrivacySettingAllowPeerToPeerCalls` for managing privacy. + - Added the field `allow_p2p` to `callStateReady` class which must be used to determine whether + a peer-to-peer connection can be used. +* Added the option `ignore_background_updates` which allows to skip all updates received while the TDLib instance was + not running. The option does nothing if the database or secret chats are used. +* Added the read-only option `expect_blocking`, suggesting whether Telegram is blocked for the user. +* Added the read-only option `enabled_proxy_id`, containing the ID of the enabled proxy. +* Added the ability to identify password pending sessions (where the code was entered but not + the two-step verification password) via the flag `is_password_pending` in the `session` class. + TDLib guarantees that the sessions will be returned by the `getActiveSessions` method in the correct order. +* Added the classes `JsonValue` and `jsonObjectMember` which represent a JSON value and + a member of a JSON object respectively as TDLib API objects. +* Added the synchronous methods `getJsonValue` and `getJsonString` for simple conversion between + a JSON-encoded string and `JsonValue` TDLib API class. +* Added the methods `getApplicationConfig` and `saveApplicationLogEvent` to be used for testing purposes. +* Added the temporarily class `databaseStatistics` and the method `getDatabaseStatistics` for rough estimations of + database tables size in a human-readable format. +* Made the method `Client.Execute` static in .NET interface. +* Removed the `on_closed` callback virtual method from low-level C++ ClientActor interface. + Callback destructor can be used instead. +* Updated dependencies in the prebuilt TDLib for Android: + - Updated SDK to SDK 28 in which helper classes was moved from `android.support.` to `androidx.` package. + - Updated NDK to r19c, which dropped support for Android versions up to 4.0.4, so the minimum supported version is + Android 4.1. + - Updated OpenSSL to version 1.1.1. + - Added x86_64 libraries. +* Added out of the box `FreeBSD` support. +* Significantly improved TDLib compilation time and decreased compiler RAM usage: + - In native C++ interface `td_api::object_ptr` is now a simple homebrew const-propagating class instead of + `std::unique_ptr`. + - Added the script `SplitSource.php`, which can be used to split some source code files before building + the library to reduce maximum RAM usage per file at the expense of increased build time. +* The update `updateOption` with the `version` option is now guaranteed to come before all other updates. + It can now be used to dynamically discover available methods. +* Added the ability to delete incoming messages in private chats and revoke messages without a time limit: + - Added the parameter `revoke` to the method `deleteChatHistory`; use it to delete chat history for all chat members. + - Added the fields `can_be_deleted_only_for_self` and `can_be_deleted_for_all_users` to the class `chat` + which can be used to determine for whom the chat can be deleted through the `deleteChatHistory` method. + - The fields `Message.can_be_deleted_only_for_self` and `Message.can_be_deleted_for_all_users` can still be used + to determine for whom the message can be deleted through the `deleteMessages` method. +* Added support for server-generated notifications about newly registered contacts: + - Setting the option `disable_contact_registered_notifications` now affects all user sessions. + When the option is enabled, the client will still receive `messageContactRegistered` message in the private chat, + but there will be no notification about the message. + - `getOption("disable_contact_registered_notifications")` can be used to fetch the actual value of the option, + the option will not be updated automatically after a change from another device. +* Decreased the maximum allowed first name and last name length to 64, chat title length to 128, + matching the new server-side limits. +* Decreased the maximum allowed value of the `forward_limit` parameter of the `addChatMember` method from 300 to 100, + matching the new server-side limit. +* Added protection from opening two TDLib instances with the same database directory from one process. +* Added copying of notification settings of new secret chats from notification settings of + the corresponding private chat. +* Excluded the sponsored chat (when using sponsored proxies) from unread counters. +* Allowed to pass decreased local_size in `setFileGenerationProgress` to restart the generation from the beginning. +* Added a check for modification time of original file in `inputFileGenerated` whenever possible. + If the original file was changed, then TDLib will restart the generation. +* Added the destruction of MTProto keys on the server during log out. +* Added support for hexadecimal-encoded and decimal-encoded IPv4 proxy server addresses. +* Improved the behavior of `changeImportedContacts` which now also deletes contacts of users without Telegram accounts + from the server. +* Added the ability to call `getStorageStatistics` before authorization. +* Allowed to pass `limit` = -`offset` for negative offset in the `getChatHistory` method. +* Changed the recommended `inputThumbnail` size to be at most 320x320 instead of the previous 90x90. +* Disabled building by default of the native C interface. Use `cmake --build . --target tdc` to build it. +* Numerous optimizations and bug fixes: + - Network implementation for Windows was completely rewritten to allow a literally unlimited number of + simultaneously used TDLib instances. + - TDLib instances can now share working threads with each other. Only a limited number of threads will be created + even if there are thousands of TDLib instances in a single process. + - Removed the restriction on the size of update or response result in JSON interface. + - Fixed pinning of the 5th chat when there is a sponsored chat. + - Fixed IPv6 on Windows. + - Improved network connections balancing, aliveness checks and overall stability. + - Various autogenerated documentation fixes and improvements. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.3.0 (5 Sep 2018): + +* Added a review of existing TDLib based [frameworks](https://github.com/tdlib/td/blob/master/example/README.md) + in different programming languages. +* Added a [Getting started](https://core.telegram.org/tdlib/getting-started) guide describing the main TDLib concepts + and basic principles required for library usage. +* When a chat is opened, only those messages that have been viewed are marked as read. +* Improved the proxy settings API: + - A list of proxies is stored instead of just one proxy. + - New methods `addProxy`, `editProxy`, `enableProxy`, `disableProxy`, `removeProxy` and `getProxies` were added + instead of `setProxy` and `getProxy`. + - Added the method `pingProxy` which can be used to compute time needed to receive a response from a Telegram server + through a proxy or directly. + - Added support for MTProto proxy via class `proxyTypeMtproto`. + - Added support for HTTP proxy via class `proxyTypeHttp`. + - For each proxy last time it was used is remembered. + - Added the method `getProxyLink` which returns an HTTPS link that can be used to share a proxy with others. +* Improved the notification settings API. Scope notification settings are now properly synchronized between all devices + and chat notification settings can be reset to their default values: + - The `notificationSettings` class was split into `chatNotificationSettings` and `scopeNotificationSettings`. + - Only two notification settings scopes are left: `notificationSettingsScopePrivateChats` which is responsible for + default notification settings for private and secret chats and `notificationSettingsScopeGroupChats` for all other + chats. + - `updateNotificationSettings` was split into `updateChatNotificationSettings` and `updateScopeNotificationSettings`. + - `setNotificationSettings` was split into `setChatNotificationSettings` and `setScopeNotificationSettings`. + - `getNotificationSettings` was replaced with `getScopeNotificationSettings`. +* Added the field `filter` to the `searchChatMembers` method to support searching among administrators, bots, + restricted and banned members. +* Added the ability to use synchronous requests and `setAlarm` before the library is initialized. +* Added the ability to send requests that don't need authentication before the library is initialized. These requests + will be postponed and executed at the earliest opportunity. For example, `setNetworkType` can be used to disable the + network for TDLib before the library tries to use it; `addProxy` can be used to add a proxy before any network + activity; or `setOption("use_pfs")` can be used to guarantee that PFS is used for all requests. +* Added support for tg:// links in `inlineKeyboardButtonTypeUrl` and `textEntityTypeTextUrl`. +* Added the ability to call `deleteAccount` in the `authorizationStateWaitPassword` authorization state. +* Added the ability to call `checkAuthenticationCode` with an empty `first_name` for unregistered users to check the + code validity. +* Added the methods `editMessageMedia` and `editInlineMessageMedia` for editing media messages content. +* Renamed the class `shippingAddress` to `address`. +* Changed the return value of the `requestPasswordRecovery` method from `passwordRecoveryInfo` to + `emailAddressAuthenticationCodeInfo`. +* Added support for sponsored channels promoted by MTProto-proxies: + - Added the field `is_sponsored` to the `chat` class. + - Added `updateChatIsSponsored`, sent when this field changes. +* Added support for marking chats as unread: + - Added the field `is_marked_as_unread` to `chat`. + - Added the update `updateChatIsMarkedAsUnread`. + - Added the method `toggleChatIsMarkedAsUnread`. +* Added support for a default value of `disable_notification`, used when a message is sent to the chat: + - Added the field `default_disable_notification` to `chat` class. + - Added the update `updateChatDefaultDisableNotification`. + - Added the method `toggleChatDefaultDisableNotification`. +* Added the field `vcard` to the `contact` class. +* Added the field `type` to `venue`, which contains a provider-specific type of the venue, +* Added the update `updateUnreadChatCount`, enabled when the message database is used and sent when + the number of unread chats has changed. +* Added the method `addLocalMessage` for adding a local message to a chat. +* Added the method `getDeepLinkInfo`, which can return information about `tg://` links that are not supported by + the client. +* Added support for language packs: + - Added the writable option `language_pack_database_path` which can be used to specify a path to a database + for storing language pack strings, so that this database can be shared between different accounts. + If not specified, language pack strings will be stored only in memory. + Changes to the option are applied only on the next TDLib launch. + - Added the writable option `localization_target` for setting up a name for the current localization target + (currently supported: "android", "android_x", "ios", "macos" and "tdesktop"). + - Added the writable option `language_pack_id` for setting up an identifier of the currently used language pack from + the current localization target (a "language pack" represents the collection of strings that can be used to display + the interface of a particular application in a particular language). + - Added the class `LanguagePackStringValue` describing the possible values of a string from a language pack. + - Added the class `languagePackString` describing a string from a language pack. + - Added the class `languagePackStrings` containing a list of language pack strings. + - Added the class `languagePackInfo` containing information about a language pack from a localization target. + - Added the class `localizationTargetInfo` containing information about a localization target. + - Added the update `updateLanguagePackStrings` which is sent when some strings in a language pack have changed. + - Added the synchronous method `getLanguagePackString` which can be used to get a language pack string from + the local database. + - Added the method `getLocalizationTargetInfo` which returns information about the current localization target. + - Added the method `getLanguagePackStrings` which returns some or all strings from a language pack, possibly fetching + them from the server. + - Added the method `setCustomLanguagePack` for adding or editing a custom language pack. + - Added the method `editCustomLanguagePackInfo` for editing information about a custom language pack. + - Added the method `setCustomLanguagePackString` for adding, editing or deleting a string in a custom language pack. + - Added the method `deleteLanguagePack` for deleting a language pack from the database. + - Added the read-only option `suggested_language_pack_id` containing the identifier of the language pack, + suggested for the user by the server. +* Added support for Telegram Passport: + - Added two new message contents `messagePassportDataSent` for ordinary users and `messagePassportDataReceived` + for bots containing information about Telegram Passport data shared with a bot. + - Added the new file type `fileTypeSecure`. + - Added the class `datedFile` containing information about a file along with the date it was uploaded. + - Added the helper classes `date`, `personalDetails`, `identityDocument`, `inputIdentityDocument`, + `personalDocument`, `inputPersonalDocument`, `passportElements`. + - Added the class `PassportElementType` describing all supported types of Telegram Passport elements. + - Added the class `PassportElement` containing information about a Telegram Passport element. + - Added the class `InputPassportElement` containing information about a Telegram Passport element to save. + - Added the classes `passportElementError` and `PassportElementErrorSource` describing an error in + a Telegram Passport element. + - Added the field `has_passport_data` to the `passwordState` class. + - Added the methods `getPassportElement`, `getAllPassportElements`, `setPassportElement`, `deletePassportElement` + for managing Telegram Passport elements. + - Added the methods `getPassportAuthorizationForm` and `sendPassportAuthorizationForm` used for sharing + Telegram Passport data with a service via a bot. + - Added the methods `sendPhoneNumberVerificationCode`, `resendPhoneNumberVerificationCode` and + `checkPhoneNumberVerificationCode` for verification of a phone number used for Telegram Passport. + - Added the methods `sendEmailAddressVerificationCode`, `resendEmailAddressVerificationCode` and + `checkEmailAddressVerificationCode` for verification of an email address used for Telegram Passport. + - Added the method `getPreferredCountryLanguage` returning a most popular language in a country. + - Added the classes `inputPassportElementError` and `InputPassportElementErrorSource` for bots describing an error in + a Telegram Passport element. + - Added the method `setPassportElementErrors` for bots. + - Added the class `encryptedPassportElement` and `encryptedCredentials` for bots describing + an encrypted Telegram Passport element. +* Improved support for Telegram terms of service: + - Added the class `termsOfService`, containing information about the Telegram terms of service. + - Added the field `terms_of_service` to `authorizationStateWaitCode`. + - Added the update `updateTermsOfService` coming when new terms of service need to be accepted by the user. + - Added the method `acceptTermsOfService` for accepting terms of service. + - Removed the method `getTermsOfService`. +* Added the method `getMapThumbnailFile` which can be used to register and download a map thumbnail file. +* Added the methods `sendPhoneNumberConfirmationCode`, `resendPhoneNumberConfirmationCode` and + `checkPhoneNumberConfirmationCode` which can be used to prevent an account from being deleted. +* Added the convenience methods `joinChat` and `leaveChat` which can be used instead of `setChatMemberStatus` to manage + the current user's membership in a chat. +* Added the convenience method `getContacts` which can be used instead of `searchContacts` to get all contacts. +* Added the synchronous method `cleanFileName` which removes potentially dangerous characters from a file name. +* Added the method `getChatMessageCount` which can be used to get the number of shared media. +* Added the writable option `ignore_inline_thumbnails` which can be used to prevent file thumbnails sent + by the server along with messages from being saved on the disk. +* Added the writable option `prefer_ipv6` which can be used to prefer IPv6 connections over IPv4. +* Added the writable option `disable_top_chats` which can be used to disable support for top chats. +* Added the class `chatReportReasonCopyright` for reporting chats containing infringing content. +* Added the method `clearAllDraftMessages` which can be used to delete all cloud drafts. +* Added the read-only options `message_text_length_max` and `message_caption_length_max`. +* Added the read-only options `animation_search_bot_username`, `photo_search_bot_username` and + `venue_search_bot_username` containing usernames of bots which can be used in inline mode for animations, photos and + venues search respectively. +* Numerous optimizations and bug fixes: + - Fixed string encoding for .NET binding. + - Fixed building TDLib SDK for Universal Windows Platform for ARM with MSVC 2017. + - Fixed the Swift example project. + - Fixed the syntax error in the Python example. + - Sticker thumbnails can now have `webp` extensions if they are more likely to be in WEBP format. + +----------------------------------------------------------------------------------------------------------------------- + +Changes in 1.2.0 (20 Mar 2018): * Added support for native .NET bindings through `C++/CLI` and `C++/CX`. See [using in .NET projects](README.md#using-dotnet) for more details. @@ -19,7 +1450,7 @@ Changes in 1.2.0: * Added new message content type `messageWebsiteConnected`. * Added new text entity types `textEntityTypeCashtag` and `textEntityTypePhoneNumber`. * Added new update `updateUnreadMessageCount`, enabled when message database is used. -* Method `joinChatByInviteLink` now returns the joined `Chat`. +* Method `joinChatByInviteLink` now returns the joined `chat`. * Method `getWebPagePreview` now accepts `formattedText` instead of plain `string`. * Added field `phone_number` to `authenticationCodeInfo`, which contains a phone number that is being authenticated. * Added field `is_secret` to `messageAnimation`, `messagePhoto`, `messageVideo` and `messageVideoNote` classes, @@ -36,7 +1467,7 @@ Changes in 1.2.0: * Added method `searchInstalledStickerSets` to search by title and name for installed sticker sets. * Added methods for handling connected websites: `getConnectedWebsites`, `disconnectWebsite` and `disconnectAllWebsites`. -* Added method `getCountryCode`, which uses current user IP to identify their country. +* Added method `getCountryCode`, which uses current user IP address to identify their country. * Added option `t_me_url`. * Fixed `BlackBerry` spelling in `deviceTokenBlackBerryPush`. * Fixed return type of `getChatMessageByDate` method, which is `Message` and not `Messages`. @@ -45,13 +1476,13 @@ Changes in 1.2.0: ----------------------------------------------------------------------------------------------------------------------- -Changes in 1.1.1: +Changes in 1.1.1 (4 Feb 2018): * Fixed C JSON bindings compilation error. * Fixed locale-dependent JSON generation. ----------------------------------------------------------------------------------------------------------------------- -Changes in 1.1.0: +Changes in 1.1.0 (31 Jan 2018): * Methods `td::Log::set_file_path` and `td_set_log_file_path` now return whether they succeeded. * Added methods `td::Log::set_max_file_size` and `td_set_log_max_file_size` for restricting maximum TDLib log size. @@ -80,9 +1511,9 @@ Changes in 1.1.0: * Added parameter `as_album` to method `getPublicMessageLink` to enable getting public links for media albums. * Added field `html` to class `publicMessageLink`, containing HTML-code for message/message album embedding. * Added parameter `only_if_pending` to method `cancelDownloadFile` to allow keeping already started downloads. -* Methods `createPrivateChat`, `createBasciGroupChat`, `createSupergroupChat` and `createSecretChat` - can now be called without a prior call to `getUser`/`getBasicGroup`/`getSupergorup`/`getSecretChat`. -* Added parameter `force` to methods `createPrivateChat`, `createBasciGroupChat` and `createSupergroupChat` to allow +* Methods `createPrivateChat`, `createBasicGroupChat`, `createSupergroupChat` and `createSecretChat` + can now be called without a prior call to `getUser`/`getBasicGroup`/`getSupergroup`/`getSecretChat`. +* Added parameter `force` to methods `createPrivateChat`, `createBasicGroupChat` and `createSupergroupChat` to allow creating a chat without network requests. * Numerous optimizations and bug fixes. diff --git a/protocols/Telegram/tdlib/td/CMake/AddCXXCompilerFlag.cmake b/protocols/Telegram/tdlib/td/CMake/AddCXXCompilerFlag.cmake index b57fa4dd98..6fb615a1f7 100644 --- a/protocols/Telegram/tdlib/td/CMake/AddCXXCompilerFlag.cmake +++ b/protocols/Telegram/tdlib/td/CMake/AddCXXCompilerFlag.cmake @@ -12,7 +12,7 @@ # add_cxx_compiler_flag(-no-strict-aliasing RELEASE) # Requires CMake 2.6+ -if(__add_cxx_compiler_flag) +if (__add_cxx_compiler_flag) return() endif() set(__add_cxx_compiler_flag INCLUDED) @@ -29,22 +29,22 @@ endfunction(mangle_compiler_flag) function(add_cxx_compiler_flag FLAG) string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG}) - mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG) + mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG_NAME) if (DEFINED CMAKE_REQUIRED_FLAGS) set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") else() set(CMAKE_REQUIRED_FLAGS "${FLAG}") endif() - check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG}) + check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG_NAME}) if (DEFINED OLD_CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") else() unset(CMAKE_REQUIRED_FLAGS) endif() - if(${MANGLED_FLAG}) + if (${MANGLED_FLAG_NAME}) set(VARIANT ${ARGV1}) - if(ARGV1) + if (ARGV1) string(TOUPPER "_${VARIANT}" VARIANT) endif() set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) @@ -53,12 +53,12 @@ endfunction() function(add_required_cxx_compiler_flag FLAG) string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG}) - mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG) + mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG_NAME) set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") - check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG}) + check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG_NAME}) set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") - if (${MANGLED_FLAG}) + if (${MANGLED_FLAG_NAME}) set(VARIANT ${ARGV1}) if (ARGV1) string(TOUPPER "_${VARIANT}" VARIANT) diff --git a/protocols/Telegram/tdlib/td/CMake/FindReadline.cmake b/protocols/Telegram/tdlib/td/CMake/FindReadline.cmake index dab24bb19f..94b92ef558 100644 --- a/protocols/Telegram/tdlib/td/CMake/FindReadline.cmake +++ b/protocols/Telegram/tdlib/td/CMake/FindReadline.cmake @@ -1,10 +1,10 @@ if (APPLE) - find_path(READLINE_INCLUDE_DIR readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH) + find_path(READLINE_INCLUDE_DIR readline/readline.h /opt/homebrew/opt/readline/include /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH) endif() find_path(READLINE_INCLUDE_DIR readline/readline.h) if (APPLE) - find_library(READLINE_LIBRARY readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH) + find_library(READLINE_LIBRARY readline /opt/homebrew/opt/readline/lib /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH) endif() find_library(READLINE_LIBRARY readline) @@ -13,7 +13,7 @@ if (READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NOT GNU_READLINE_FOUND) set(CMAKE_REQUIRED_LIBRARIES "${READLINE_LIBRARY}") include(CheckCXXSourceCompiles) unset(GNU_READLINE_FOUND CACHE) - CHECK_CXX_SOURCE_COMPILES("#include \n#include \nint main() { rl_replace_line(\"\", 0); }" GNU_READLINE_FOUND) + check_cxx_source_compiles("#include \n#include \nint main() { rl_replace_line(\"\", 0); }" GNU_READLINE_FOUND) if (NOT GNU_READLINE_FOUND) unset(READLINE_INCLUDE_DIR CACHE) unset(READLINE_LIBRARY CACHE) @@ -21,5 +21,5 @@ if (READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NOT GNU_READLINE_FOUND) endif() include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY) +find_package_handle_standard_args(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY) mark_as_advanced(READLINE_INCLUDE_DIR READLINE_LIBRARY) diff --git a/protocols/Telegram/tdlib/td/CMake/GeneratePkgConfig.cmake b/protocols/Telegram/tdlib/td/CMake/GeneratePkgConfig.cmake new file mode 100644 index 0000000000..afbe06ac60 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/GeneratePkgConfig.cmake @@ -0,0 +1,92 @@ +function(get_relative_link OUTPUT PATH) + if (PATH MATCHES "^[$]<[$]:") + set(${OUTPUT} "" PARENT_SCOPE) + return() + endif() + string(REGEX REPLACE "^[$]<[$]>:(.*)>$" "\\1" PATH "${PATH}") + + get_filename_component(NAME "${PATH}" NAME_WE) + if (IS_ABSOLUTE ${PATH}) + get_filename_component(DIRECTORY_NAME "${PATH}" DIRECTORY) + if (WIN32) + set(${OUTPUT} "-l\"${DIRECTORY_NAME}/${NAME}\"" PARENT_SCOPE) + else() + get_filename_component(FULL_NAME "${PATH}" NAME) + set(${OUTPUT} "-L\"${DIRECTORY_NAME}\" -l:${FULL_NAME}" PARENT_SCOPE) + endif() + return() + endif() + + if (NOT WIN32 AND NAME MATCHES "^lib") + string(REGEX REPLACE "^lib" "-l" LINK "${NAME}") + elseif (NAME MATCHES "^-") + set(LINK "${NAME}") + else() + string(CONCAT LINK "-l" "${NAME}") + endif() + set(${OUTPUT} "${LINK}" PARENT_SCOPE) +endfunction() + +function(generate_pkgconfig TARGET DESCRIPTION) + # message("Generating pkg-config for ${TARGET}") + get_filename_component(PREFIX "${CMAKE_INSTALL_PREFIX}" REALPATH) + + get_target_property(LIST "${TARGET}" LINK_LIBRARIES) + set(REQS "") + set(LIBS "") + foreach (LIB ${LIST}) + if (TARGET "${LIB}") + set(HAS_REQS 1) + list(APPEND REQS "${LIB}") + else() + set(HAS_LIBS 1) + get_relative_link(LINK "${LIB}") + if (NOT LINK EQUAL "") + list(APPEND LIBS "${LINK}") + endif() + endif() + endforeach() + + if (HAS_REQS) + set(REQUIRES "") + foreach (REQ ${REQS}) + set(REQUIRES "${REQUIRES} ${REQ}") + endforeach() + set(REQUIRES "Requires.private:${REQUIRES}\n") + endif() + if (HAS_LIBS) + set(LIBRARIES "") + list(REVERSE LIBS) + list(REMOVE_DUPLICATES LIBS) + foreach (LIB ${LIBS}) + set(LIBRARIES " ${LIB}${LIBRARIES}") + endforeach() + set(LIBRARIES "Libs.private:${LIBRARIES}\n") + endif() + + if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(PKGCONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}") + else() + set(PKGCONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + endif() + + if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(PKGCONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}") + else() + set(PKGCONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}") + endif() + + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig") + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" CONTENT +"prefix=${PREFIX} + +Name: ${TARGET} +Description: ${DESCRIPTION} +Version: ${PROJECT_VERSION} + +CFlags: -I\"${PKGCONFIG_INCLUDEDIR}\" +Libs: -L\"${PKGCONFIG_LIBDIR}\" -l${TARGET} +${REQUIRES}${LIBRARIES}") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +endfunction() diff --git a/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake b/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000000..b565582098 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake @@ -0,0 +1,127 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( ) +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2020 Ryan Pavlik +# http://academic.cleardefinition.com +# +# Copyright 2009-2013, Iowa State University. +# Copyright 2013-2020, Ryan Pavlik +# Copyright 2013-2020, Contributors +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if (__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +# Function _git_find_closest_git_dir finds the next closest .git directory +# that is part of any directory in the path defined by _start_dir. +# The result is returned in the parent scope variable whose name is passed +# as variable _git_dir_var. If no .git directory can be found, the +# function returns an empty string via _git_dir_var. +# +# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and +# neither foo nor bar contain a file/directory .git. This wil return +# C:/bla/.git +# +function(_git_find_closest_git_dir _start_dir _git_dir_var) + set(cur_dir "${_start_dir}") + set(git_dir "${_start_dir}/.git") + while (NOT EXISTS "${git_dir}") + # .git dir not found, search parent directories + set(git_previous_parent "${cur_dir}") + get_filename_component(cur_dir "${cur_dir}" DIRECTORY) + if (cur_dir STREQUAL git_previous_parent) + # We have reached the root directory, we are not in git + set(${_git_dir_var} "" PARENT_SCOPE) + return() + endif() + set(git_dir "${cur_dir}/.git") + endwhile() + set(${_git_dir_var} "${git_dir}" PARENT_SCOPE) +endfunction() + +function(get_git_head_revision _refspecvar _hashvar) + _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) + + if (NOT GIT_DIR STREQUAL "") + file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${GIT_DIR}") + if (_relative_to_source_dir MATCHES "^[.][.]") + # We've gone above the CMake root dir. + set(GIT_DIR "") + endif() + endif() + if (GIT_DIR STREQUAL "") + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + + find_package(Git) + + # Check if the current source dir is a git submodule or a worktree. + # In both cases .git is a file instead of a directory. + # + if ((NOT IS_DIRECTORY ${GIT_DIR}) AND Git_FOUND) + # The following git command will return a non empty string that + # points to the super project working tree if the current + # source dir is inside a git submodule. + # Otherwise the command will return an empty string. + # + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --show-superproject-working-tree + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT out STREQUAL "") + # If out is non-empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule}) + string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + else() + # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree + file(READ ${GIT_DIR} worktree_ref) + # The .git directory contains a path to the worktree information directory + # inside the parent git repo of the worktree. + string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir ${worktree_ref}) + string(STRIP ${git_worktree_dir} git_worktree_dir) + _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) + set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") + endif() + else() + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + endif() + if (NOT EXISTS "${HEAD_SOURCE_FILE}") + return() + endif() + + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if (NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() diff --git a/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake.in b/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000000..bfc1e54c15 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,43 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright 2009-2012, Iowa State University +# Copyright 2011-2015, Contributors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# SPDX-License-Identifier: BSL-1.0 + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if (HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if (EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if (PACKED_REFS MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if (NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake b/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake new file mode 100644 index 0000000000..1815e82a25 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake @@ -0,0 +1,14 @@ +function(prevent_in_source_build) + get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) + get_filename_component(REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH) + + if (REAL_BINARY_DIR STREQUAL REAL_SOURCE_DIR) + message(" Out-of-source build must be used. Remove the files already") + message(" created by CMake and rerun CMake from a new directory:") + message(" rm -rf CMakeFiles CMakeCache.txt") + message(" mkdir build") + message(" cd build") + message(" cmake ..") + message(FATAL_ERROR "In-source build failed.") + endif() +endfunction() diff --git a/protocols/Telegram/tdlib/td/CMake/TdSetUpCompiler.cmake b/protocols/Telegram/tdlib/td/CMake/TdSetUpCompiler.cmake new file mode 100644 index 0000000000..536c5efb29 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/TdSetUpCompiler.cmake @@ -0,0 +1,174 @@ +# - Configures C++14 compiler, setting TDLib-specific compilation options. + +function(td_set_up_compiler) + set(CMAKE_EXPORT_COMPILE_COMMANDS 1 PARENT_SCOPE) + + set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE) + + include(illumos) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(GCC 1) + set(GCC 1 PARENT_SCOPE) + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CLANG 1) + set(CLANG 1 PARENT_SCOPE) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(INTEL 1) + set(INTEL 1 PARENT_SCOPE) + elseif (NOT MSVC) + message(FATAL_ERROR "Compiler isn't supported") + endif() + + include(CheckCXXCompilerFlag) + + if (GCC OR CLANG OR INTEL) + if (WIN32 AND INTEL) + set(STD14_FLAG /Qstd=c++14) + else() + set(STD14_FLAG -std=c++14) + endif() + check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD14) + if (NOT HAVE_STD14) + string(REPLACE "c++14" "c++1y" STD14_FLAG "${STD14_FLAG}") + check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD1Y) + set(HAVE_STD14 ${HAVE_STD1Y}) + endif() + elseif (MSVC) + set(HAVE_STD14 MSVC_VERSION>=1900) + endif() + + if (NOT HAVE_STD14) + message(FATAL_ERROR "No C++14 support in the compiler. Please upgrade the compiler.") + endif() + + if (MSVC) + if (CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") + string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + endif() + add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /GR- /W4 /wd4100 /wd4127 /wd4324 /wd4505 /wd4814 /wd4702 /bigobj") + elseif (CLANG OR GCC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG} -fno-omit-frame-pointer -fno-exceptions -fno-rtti") + if (APPLE) + set(TD_LINKER_FLAGS "-Wl,-dead_strip") + if (NOT CMAKE_BUILD_TYPE MATCHES "Deb") + set(TD_LINKER_FLAGS "${TD_LINKER_FLAGS},-x,-S") + endif() + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections") + if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(TD_LINKER_FLAGS "-Wl,-z,ignore") + elseif (EMSCRIPTEN) + set(TD_LINKER_FLAGS "-Wl,--gc-sections") + else() + set(TD_LINKER_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL") + endif() + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TD_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TD_LINKER_FLAGS}") + + if (WIN32 OR CYGWIN) + if (GCC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") + endif() + endif() + elseif (INTEL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG}") + endif() + + if (WIN32) + add_definitions(-DNTDDI_VERSION=0x06020000 -DWINVER=0x0602 -D_WIN32_WINNT=0x0602 -DPSAPI_VERSION=1 -DNOMINMAX -DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN) + endif() + if (CYGWIN) + add_definitions(-D_DEFAULT_SOURCE=1 -DFD_SETSIZE=4096) + endif() + + # _FILE_OFFSET_BITS is broken in Android NDK r15, r15b and r17 and doesn't work prior to Android 7.0 + add_definitions(-D_FILE_OFFSET_BITS=64) + + # _GNU_SOURCE might not be defined by g++ + add_definitions(-D_GNU_SOURCE) + + if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lsocket -lnsl") + if (ILLUMOS) + add_definitions(-DTD_ILLUMOS=1) + endif() + endif() + + include(AddCXXCompilerFlag) + if (NOT MSVC) + add_cxx_compiler_flag("-Wall") + add_cxx_compiler_flag("-Wextra") + add_cxx_compiler_flag("-Wimplicit-fallthrough=2") + add_cxx_compiler_flag("-Wpointer-arith") + add_cxx_compiler_flag("-Wcast-qual") + add_cxx_compiler_flag("-Wsign-compare") + add_cxx_compiler_flag("-Wduplicated-branches") + add_cxx_compiler_flag("-Wduplicated-cond") + add_cxx_compiler_flag("-Walloc-zero") + add_cxx_compiler_flag("-Wlogical-op") + add_cxx_compiler_flag("-Wno-tautological-compare") + add_cxx_compiler_flag("-Wpointer-arith") + add_cxx_compiler_flag("-Wvla") + add_cxx_compiler_flag("-Wnon-virtual-dtor") + add_cxx_compiler_flag("-Wno-unused-parameter") + add_cxx_compiler_flag("-Wconversion") + add_cxx_compiler_flag("-Wno-sign-conversion") + add_cxx_compiler_flag("-Wc++14-compat-pedantic") + add_cxx_compiler_flag("-Wdeprecated") + add_cxx_compiler_flag("-Wno-unused-command-line-argument") + add_cxx_compiler_flag("-Qunused-arguments") + add_cxx_compiler_flag("-Wodr") + add_cxx_compiler_flag("-flto-odr-type-merging") + + # add_cxx_compiler_flag("-Werror") + + # add_cxx_compiler_flag("-Wcast-align") + + #std::int32_t <-> int and off_t <-> std::size_t/std::int64_t + # add_cxx_compiler_flag("-Wuseless-cast") + + #external headers like openssl + # add_cxx_compiler_flag("-Wzero-as-null-pointer-constant") + endif() + + if (GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)) + add_cxx_compiler_flag("-Wno-maybe-uninitialized") # too many false positives + endif() + if (WIN32 AND GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)) + # warns about casts of function pointers returned by GetProcAddress + add_cxx_compiler_flag("-Wno-cast-function-type") + endif() + if (GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)) + # warns about a lot of "return std::move", which are not redundant for compilers without fix for DR 1579, i.e. GCC 4.9 or clang 3.8 + # see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 + add_cxx_compiler_flag("-Wno-redundant-move") + endif() + if (GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)) + add_cxx_compiler_flag("-Wno-stringop-overflow") # some false positives + endif() + if (CLANG AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)) + # https://stackoverflow.com/questions/26744556/warning-returning-a-captured-reference-from-a-lambda + add_cxx_compiler_flag("-Wno-return-stack-address") + endif() + + if (MINGW) + add_cxx_compiler_flag("-ftrack-macro-expansion=0") + endif() + + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" PARENT_SCOPE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" PARENT_SCOPE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE) +endfunction() diff --git a/protocols/Telegram/tdlib/td/CMake/iOS.cmake b/protocols/Telegram/tdlib/td/CMake/iOS.cmake index 9b395a0764..9351395422 100644 --- a/protocols/Telegram/tdlib/td/CMake/iOS.cmake +++ b/protocols/Telegram/tdlib/td/CMake/iOS.cmake @@ -9,12 +9,16 @@ # OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. # SIMULATOR - used to build for the Simulator platforms, which have an x86 arch. # +# IOS_ARCH = automatic(default) or "arch1;arch2" (e.q. "x86_64;arm64") +# By default this value will be automatically chosen based on the IOS_PLATFORM value above. +# If set manually, it will override the default and force to build those architectures only. +# # CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder -# By default this location is automatcially chosen based on the IOS_PLATFORM value above. +# By default this location is automatically chosen based on the IOS_PLATFORM value above. # If set manually, it will override the default location and force the user of a particular Developer Platform # # CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder -# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. +# By default this location is automatically chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. # In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. # If set manually, this will force the use of a specific SDK version @@ -48,9 +52,9 @@ endif (CMAKE_UNAME) # Force the compilers to gcc for iOS set (CMAKE_C_COMPILER /usr/bin/gcc) set (CMAKE_CXX_COMPILER /usr/bin/g++) -set(CMAKE_AR ar CACHE FILEPATH "" FORCE) -set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) -set(PKG_CONFIG_EXECUTABLE pkg-config CACHE FILEPATH "" FORCE) +set (CMAKE_AR ar CACHE FILEPATH "" FORCE) +set (CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) +set (PKG_CONFIG_EXECUTABLE pkg-config CACHE FILEPATH "" FORCE) # Setup iOS platform unless specified manually with IOS_PLATFORM if (NOT DEFINED IOS_PLATFORM) @@ -59,7 +63,7 @@ endif (NOT DEFINED IOS_PLATFORM) set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") # Check the platform selection and setup for developer root -if (${IOS_PLATFORM} STREQUAL "OS") +if (IOS_PLATFORM STREQUAL "OS") set (IOS_PLATFORM_LOCATION "iPhoneOS.platform") set (XCODE_IOS_PLATFORM iphoneos) @@ -67,7 +71,7 @@ if (${IOS_PLATFORM} STREQUAL "OS") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") set (APPLE_IOS True) -elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") +elseif (IOS_PLATFORM STREQUAL "SIMULATOR") set (SIMULATOR_FLAG true) set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") set (XCODE_IOS_PLATFORM iphonesimulator) @@ -76,7 +80,7 @@ elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") set (APPLE_IOS True) -elseif (${IOS_PLATFORM} STREQUAL "WATCHOS") +elseif (IOS_PLATFORM STREQUAL "WATCHOS") set (IOS_PLATFORM_LOCATION "WatchOS.platform") set (XCODE_IOS_PLATFORM watchos) @@ -84,7 +88,7 @@ elseif (${IOS_PLATFORM} STREQUAL "WATCHOS") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos") set (APPLE_WATCH True) -elseif (${IOS_PLATFORM} STREQUAL "WATCHSIMULATOR") +elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR") set (SIMULATOR_FLAG true) set (IOS_PLATFORM_LOCATION "WatchSimulator.platform") set (XCODE_IOS_PLATFORM watchsimulator) @@ -93,7 +97,7 @@ elseif (${IOS_PLATFORM} STREQUAL "WATCHSIMULATOR") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchsimulator") set (APPLE_WATCH True) -elseif (${IOS_PLATFORM} STREQUAL "TVOS") +elseif (IOS_PLATFORM STREQUAL "TVOS") set (IOS_PLATFORM_LOCATION "AppleTvOS.platform") set (XCODE_IOS_PLATFORM tvos) @@ -101,7 +105,7 @@ elseif (${IOS_PLATFORM} STREQUAL "TVOS") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-appletvos") set (APPLE_TV True) -elseif (${IOS_PLATFORM} STREQUAL "TVSIMULATOR") +elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR") set (SIMULATOR_FLAG true) set (IOS_PLATFORM_LOCATION "AppleTvSimulator.platform") set (XCODE_IOS_PLATFORM tvsimulator) @@ -110,7 +114,7 @@ elseif (${IOS_PLATFORM} STREQUAL "TVSIMULATOR") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-tvsimulator") set (APPLE_TV True) -else (${IOS_PLATFORM} STREQUAL "OS") +else (IOS_PLATFORM STREQUAL "OS") message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS, SIMULATOR, or WATCHOS.") endif () @@ -132,12 +136,9 @@ if (IOS_DEPLOYMENT_TARGET) endif() set (CMAKE_SHARED_LINKER_FLAGS_INIT "-fapplication-extension") -if (NOT SIMULATOR_FLAG) - set (BITCODE "-fembed-bitcode") -endif() -set (CMAKE_C_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE}") +set (CMAKE_C_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS}") # Hidden visibilty is required for cxx on iOS -set (CMAKE_CXX_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fvisibility-inlines-hidden") +set (CMAKE_CXX_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fvisibility-inlines-hidden") set (CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fapplication-extension -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") set (CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fapplication-extension -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") @@ -168,7 +169,7 @@ set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer" if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) if (EXISTS ${XCODE_POST_43_ROOT}) set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) - elseif(EXISTS ${XCODE_PRE_43_ROOT}) + elseif (EXISTS ${XCODE_PRE_43_ROOT}) set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) endif (EXISTS ${XCODE_POST_43_ROOT}) endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) @@ -191,23 +192,23 @@ set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the select # Set the sysroot default to the most recent SDK set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") -# set the architecture for iOS -if (IOS_PLATFORM STREQUAL "OS") - set (IOS_ARCH "armv7;armv7s;arm64") -elseif (IOS_PLATFORM STREQUAL "SIMULATOR") - set (IOS_ARCH "i386;x86_64") -elseif (IOS_PLATFORM STREQUAL "WATCHOS") - set (IOS_ARCH "armv7k") -elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR") - set (IOS_ARCH "i386") -elseif (IOS_PLATFORM STREQUAL "TVOS") - set (IOS_ARCH "arm64") -elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR") - set (IOS_ARCH "x86_64") -else() - message (WARNING "Unknown IOS_PLATFORM=<${IOS_PLATFORM}>") +# Set the architectures unless specified manually with IOS_ARCH +if (NOT DEFINED IOS_ARCH) + if (IOS_PLATFORM STREQUAL "OS") + set (IOS_ARCH "armv7;armv7s;arm64") + elseif (IOS_PLATFORM STREQUAL "SIMULATOR") + set (IOS_ARCH "i386;x86_64;arm64") + elseif (IOS_PLATFORM STREQUAL "WATCHOS") + set (IOS_ARCH "armv7k;arm64_32") + elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR") + set (IOS_ARCH "i386;x86_64;arm64") + elseif (IOS_PLATFORM STREQUAL "TVOS") + set (IOS_ARCH "arm64") + elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR") + set (IOS_ARCH "x86_64;arm64") + endif() endif() -message (STATUS ${IOS_ARCH}) +message (STATUS "The iOS architectures: ${IOS_ARCH}") set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS") diff --git a/protocols/Telegram/tdlib/td/CMake/illumos.cmake b/protocols/Telegram/tdlib/td/CMake/illumos.cmake new file mode 100644 index 0000000000..70583d1a82 --- /dev/null +++ b/protocols/Telegram/tdlib/td/CMake/illumos.cmake @@ -0,0 +1,10 @@ +if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") + # + # Determine if the host is running an illumos distribution: + # + execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (UNAME_O STREQUAL "illumos") + set(ILLUMOS 1) + endif() +endif() diff --git a/protocols/Telegram/tdlib/td/CMakeLists.txt b/protocols/Telegram/tdlib/td/CMakeLists.txt index 5e2a626021..8b683c20b7 100644 --- a/protocols/Telegram/tdlib/td/CMakeLists.txt +++ b/protocols/Telegram/tdlib/td/CMakeLists.txt @@ -1,21 +1,43 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) -project(TDLib VERSION 1.2.0 LANGUAGES CXX C) +if (POLICY CMP0065) + # do not export symbols from executables + # affects compiler checks in project(), so must be set before it + cmake_policy(SET CMP0065 NEW) +endif() + +project(TDLib VERSION 1.8.8 LANGUAGES CXX C) -# Prevent in-source build -get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) -get_filename_component(TD_REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH) +if (NOT DEFINED CMAKE_MODULE_PATH) + set(CMAKE_MODULE_PATH "") +endif() +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" "${CMAKE_MODULE_PATH}") -if (TD_REAL_BINARY_DIR STREQUAL TD_REAL_SOURCE_DIR) - message(" Out-of-source build should be used to build TDLib.") - message(" You need to remove the files already created by CMake and") - message(" rerun CMake from a new directory:") - message(" rm -rf CMakeFiles CMakeCache.txt") - message(" mkdir build") - message(" cd build") - message(" cmake ..") - message(FATAL_ERROR "In-source build failed.") +if (NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR "lib") +endif() +if (NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "bin") +endif() +if (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) + set(CMAKE_INSTALL_INCLUDEDIR "include") +endif() + +if (POLICY CMP0054) + # do not expand quoted arguments + cmake_policy(SET CMP0054 NEW) +endif() +if (POLICY CMP0060) + # link libraries by full path + cmake_policy(SET CMP0060 NEW) endif() +if (POLICY CMP0074) + # use environment variables to find libraries + cmake_policy(SET CMP0074 NEW) +endif() + +include(PreventInSourceBuild) +prevent_in_source_build() option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.") option(TD_ENABLE_DOTNET "Use \"ON\" to enable generation of C++/CLI or C++/CX TDLib API bindings.") @@ -24,15 +46,6 @@ if (TD_ENABLE_DOTNET AND (CMAKE_VERSION VERSION_LESS "3.1.0")) message(FATAL_ERROR "CMake 3.1.0 or higher is required. You are running version ${CMAKE_VERSION}.") endif() -if (NOT DEFINED CMAKE_MODULE_PATH) - set(CMAKE_MODULE_PATH "") -endif() -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" "${CMAKE_MODULE_PATH}") - -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - enable_testing() if (POLICY CMP0069) @@ -46,15 +59,15 @@ if (POLICY CMP0069) # set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) do not work? string(REPLACE ";" " " CXX_FLAGS_IPO "${CMAKE_CXX_COMPILE_OPTIONS_IPO}") message(STATUS "Use link time optimization CXX options: ${CXX_FLAGS_IPO}") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CXX_FLAGS_IPO}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_IPO}") string(REPLACE ";" " " C_FLAGS_IPO "${CMAKE_C_COMPILE_OPTIONS_IPO}") message(STATUS "Use link time optimization C options: ${C_FLAGS_IPO}") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${C_FLAGS_IPO}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS_IPO}") string(REPLACE ";" " " LINK_FLAGS_IPO "${CMAKE_CXX_LINK_OPTIONS_IPO}") message(STATUS "Use link time optimization linker options: ${LINK_FLAGS_IPO}") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LINK_FLAGS_IPO}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINK_FLAGS_IPO}") endif() endif() endif() @@ -67,14 +80,14 @@ if (CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) else() - message(STATUS "Could NOT find ccache") + message(STATUS "Could NOT find ccache (this is NOT an error)") endif() set(MEMPROF "" CACHE STRING "Use one of \"ON\", \"FAST\" or \"SAFE\" to enable memory profiling. \ -Works under Mac OS and Linux when compiled using glibc. \ +Works under macOS and Linux when compiled using glibc. \ In FAST mode stack is unwinded only using frame pointers, which may fail. \ In SAFE mode stack is unwinded using backtrace function from execinfo.h, which may be very slow. \ -By default both methods are used to achieve maximum speed and accuracy") +By default both methods are used to achieve the maximum speed and accuracy") if (EMSCRIPTEN) # use prebuilt zlib @@ -82,18 +95,23 @@ if (EMSCRIPTEN) set(ZLIB_LIBRARIES) set(ZLIB_INCLUDE_DIR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s ALLOW_MEMORY_GROWTH=1 -s USE_ZLIB=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS']\"") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s ALLOW_MEMORY_GROWTH=1 -s USE_ZLIB=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS']\"") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s MODULARIZE=1 \ + -s EXPORT_NAME=\"'createTdwebModule'\" -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s MODULARIZE=1 \ + -s EXPORT_NAME=\"'createTdwebModule'\" -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=1") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=1") if (ASMJS) set(TD_EMSCRIPTEN td_asmjs) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=0 -Wno-almost-asm") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s WASM=0 -Wno-almost-asm") else() set(TD_EMSCRIPTEN td_wasm) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s WASM=1") endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --post-js ${CMAKE_CURRENT_SOURCE_DIR}/post.js") endif() if (NOT OPENSSL_FOUND) @@ -103,38 +121,6 @@ if (OPENSSL_FOUND) message(STATUS "Found OpenSSL: ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}") endif() -if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) - set(GCC 1) -elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang) - set(CLANG 1) -elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Intel) - set(INTEL 1) -elseif (NOT MSVC) - message(FATAL_ERROR "Compiler isn't supported") -endif() - -include(CheckCXXCompilerFlag) - -if (GCC OR CLANG OR INTEL) - if (WIN32 AND INTEL) - SET(STD14_FLAG /Qstd=c++14) - else() - SET(STD14_FLAG -std=c++14) - endif() - CHECK_CXX_COMPILER_FLAG(${STD14_FLAG} HAVE_STD14) - if (NOT HAVE_STD14) - string(REPLACE "c++14" "c++1y" STD14_FLAG "${STD14_FLAG}") - CHECK_CXX_COMPILER_FLAG(${STD14_FLAG} HAVE_STD1Y) - set(HAVE_STD14 ${HAVE_STD1Y}) - endif() -elseif (MSVC) - set(HAVE_STD14 MSVC_VERSION>=1900) -endif() - -if (NOT HAVE_STD14) - message(FATAL_ERROR "No C++14 support in the compiler. Please upgrade the compiler.") -endif() - set(CMAKE_THREAD_PREFER_PTHREAD ON) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -143,86 +129,34 @@ if (THREADS_HAVE_PTHREAD_ARG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() +include(TdSetUpCompiler) +td_set_up_compiler() + if (MSVC) - if (CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") - string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - endif() - add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /W4 /wd4100 /wd4127 /wd4324 /wd4505 /wd4702") -elseif (CLANG OR GCC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG} -fno-omit-frame-pointer -fno-exceptions -fno-rtti") - if (APPLE) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip,-x,-S") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL") + option(TD_ENABLE_MULTI_PROCESSOR_COMPILATION "Use \"ON\" to enable multi-processor compilation.") + + if (TD_ENABLE_MULTI_PROCESSOR_COMPILATION) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() +endif() +if (CLANG OR GCC) if (MEMPROF) - CHECK_CXX_COMPILER_FLAG(-no-pie CXX_NO_PIE_FLAG) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-no-pie CXX_NO_PIE_FLAG) if (CXX_NO_PIE_FLAG) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") elseif (APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie") endif() endif() -elseif (INTEL) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG}") endif() -if (WIN32) - add_definitions(-DNTDDI_VERSION=0x06020000 -DWINVER=0x0602 -D_WIN32_WINNT=0x0602 -DNOMINMAX -DUNICODE -D_UNICODE) -endif() -if (CYGWIN) - add_definitions(-D_DEFAULT_SOURCE=1 -DFD_SETSIZE=4096) -endif() - -if (NOT ANDROID) # _FILE_OFFSET_BITS is broken in ndk r15 and r15b and doesn't work prior to Android 7.0 - add_definitions(-D_FILE_OFFSET_BITS=64) -endif() - -include(AddCXXCompilerFlag) -if (NOT MSVC) - add_cxx_compiler_flag("-Wall") - add_cxx_compiler_flag("-Wextra") - add_cxx_compiler_flag("-Wimplicit-fallthrough=2") - add_cxx_compiler_flag("-Wpointer-arith") - add_cxx_compiler_flag("-Wcast-qual") - add_cxx_compiler_flag("-Wsign-compare") - add_cxx_compiler_flag("-Wduplicated-branches") - add_cxx_compiler_flag("-Wduplicated-cond") - add_cxx_compiler_flag("-Walloc-zero") - add_cxx_compiler_flag("-Wlogical-op") - add_cxx_compiler_flag("-Wno-tautological-compare") - add_cxx_compiler_flag("-Wpointer-arith") - add_cxx_compiler_flag("-Wvla") - add_cxx_compiler_flag("-Wnon-virtual-dtor") - add_cxx_compiler_flag("-Wno-unused-parameter") - add_cxx_compiler_flag("-Wconversion") - add_cxx_compiler_flag("-Wno-sign-conversion") - add_cxx_compiler_flag("-Wc++14-compat-pedantic") - add_cxx_compiler_flag("-Qunused-arguments") - add_cxx_compiler_flag("-Wodr") - add_cxx_compiler_flag("-flto-odr-type-merging") - -# add_cxx_compiler_flag("-Werror") - -# add_cxx_compiler_flag("-Wcast-align") - -#std::int32_t <-> int and off_t <-> std::size_t/std::int64_t -# add_cxx_compiler_flag("-Wuseless-cast") - -#external headers like openssl -# add_cxx_compiler_flag("-Wzero-as-null-pointer-constant") -endif() - -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak") +include(GetGitRevisionDescription) +get_git_head_revision(TD_GIT_REFSPEC TD_GIT_COMMIT_HASH) +message(STATUS "Git state: ${TD_GIT_COMMIT_HASH}") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/td/telegram/GitCommitHash.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/td/telegram/GitCommitHash.cpp" @ONLY) add_subdirectory(tdtl) @@ -234,10 +168,10 @@ if (NOT CMAKE_CROSSCOMPILING) add_custom_target(prepare_cross_compiling DEPENDS tl_generate_common tdmime_auto tl_generate_json) if (TD_ENABLE_DOTNET) add_custom_target(remove_cpp_documentation - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND remove_documentation ${TL_TD_AUTO} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND remove_documentation ${TL_TD_API_AUTO_SOURCE} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h COMMENT "Remove C++ documentation from sources" - DEPENDS remove_documentation tl_generate_common generate_dotnet_api ${TL_TD_AUTO} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h + DEPENDS remove_documentation tl_generate_common generate_dotnet_api ${TL_TD_API_AUTO_SOURCE} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h ) add_dependencies(prepare_cross_compiling generate_dotnet_api remove_cpp_documentation) @@ -245,7 +179,7 @@ if (NOT CMAKE_CROSSCOMPILING) endif() if (NOT OPENSSL_FOUND) - message(WARNING "Not found OpenSSL: skip TDLib, tdactor, tdnet, tddb") + message(WARNING "Can't find OpenSSL: stop TDLib building") return() endif() @@ -253,7 +187,12 @@ if (NOT ZLIB_FOUND) find_package(ZLIB) endif() if (NOT ZLIB_FOUND) - message(WARNING "Not found zlib: skip TDLib, tdactor, tdnet, tddb") + message(WARNING "Can't find zlib: stop TDLib building") + return() +endif() + +if (NOT TDUTILS_MIME_TYPE) + message(WARNING "Option TDUTILS_MIME_TYPE must not be disabled: stop TDLib building") return() endif() @@ -274,84 +213,130 @@ endif() get_directory_property(HAS_PARENT PARENT_DIRECTORY) if (HAS_PARENT) - set(TL_TD_AUTO_INCLUDES ${TL_TD_AUTO_INCLUDES} PARENT_SCOPE) - set(TL_TD_API_TLO ${TL_TD_API_TLO} PARENT_SCOPE) - set(TL_TD_JSON_AUTO ${TL_TD_JSON_AUTO} PARENT_SCOPE) - set(TD_TEST_SOURCE ${TD_TEST_SOURCE} PARENT_SCOPE) + set(TL_TD_JSON_AUTO ${TL_TD_JSON_AUTO_SOURCE} PARENT_SCOPE) # used in tdbot + set(TD_TEST_SOURCE ${TD_TEST_SOURCE} PARENT_SCOPE) # used to build tests endif() #SOURCE SETS -set_source_files_properties(${TL_TD_AUTO} PROPERTIES GENERATED TRUE) -if (TD_ENABLE_JNI) - set(TL_JNI_OBJECT +set_source_files_properties(${TL_TD_API_AUTO_SOURCE} PROPERTIES GENERATED TRUE) +if (TD_ENABLE_JNI OR ANDROID) + set(TL_JNI_OBJECT_SOURCE td/tl/tl_jni_object.cpp td/tl/tl_jni_object.h ) else() - set(TL_JNI_OBJECT) + set(TL_JNI_OBJECT_SOURCE) endif() +set(TL_TD_API_SOURCE + ${TL_TD_API_AUTO_SOURCE} + ${TL_JNI_OBJECT_SOURCE} + td/tl/TlObject.h +) + +set_source_files_properties(${TL_TD_AUTO_SOURCE} PROPERTIES GENERATED TRUE) set(TL_TD_SCHEME_SOURCE - ${TL_TD_AUTO} - ${TL_JNI_OBJECT} + ${TL_TD_AUTO_SOURCE} td/tl/TlObject.h td/tl/tl_object_parse.h td/tl/tl_object_store.h ) -set_source_files_properties(${TL_TD_JSON_AUTO} PROPERTIES GENERATED TRUE) -set(TL_TD_JSON - ${TL_TD_JSON_AUTO} +set_source_files_properties(${TL_TD_JSON_AUTO_SOURCE} PROPERTIES GENERATED TRUE) +set(TL_TD_JSON_SOURCE + ${TL_TD_JSON_AUTO_SOURCE} td/tl/tl_json.h ) -set_source_files_properties(${TL_C_AUTO} PROPERTIES GENERATED TRUE) +set_source_files_properties(${TL_C_AUTO_SOURCE} PROPERTIES GENERATED TRUE) set(TL_C_SCHEME_SOURCE - ${TL_C_AUTO} + ${TL_C_AUTO_SOURCE} ) -set_source_files_properties(${TL_DOTNET_AUTO} PROPERTIES GENERATED TRUE) +set_source_files_properties(${TL_DOTNET_AUTO_SOURCE} PROPERTIES GENERATED TRUE) set(TL_DOTNET_SCHEME_SOURCE - ${TL_DOTNET_AUTO} + ${TL_DOTNET_AUTO_SOURCE} td/tl/tl_dotnet_object.h ) set(TDLIB_SOURCE td/mtproto/AuthData.cpp - td/mtproto/crypto.cpp + td/mtproto/ConnectionManager.cpp + td/mtproto/DhHandshake.cpp td/mtproto/Handshake.cpp td/mtproto/HandshakeActor.cpp td/mtproto/HttpTransport.cpp td/mtproto/IStreamTransport.cpp + td/mtproto/KDF.cpp + td/mtproto/Ping.cpp + td/mtproto/PingConnection.cpp + td/mtproto/ProxySecret.cpp td/mtproto/RawConnection.cpp + td/mtproto/RSA.cpp td/mtproto/SessionConnection.cpp td/mtproto/TcpTransport.cpp + td/mtproto/TlsInit.cpp + td/mtproto/TlsReaderByteFlow.cpp td/mtproto/Transport.cpp td/mtproto/utils.cpp + td/telegram/Account.cpp td/telegram/AnimationsManager.cpp + td/telegram/Application.cpp + td/telegram/AttachMenuManager.cpp td/telegram/AudiosManager.cpp td/telegram/AuthManager.cpp + td/telegram/AutoDownloadSettings.cpp + td/telegram/BackgroundManager.cpp + td/telegram/BackgroundType.cpp + td/telegram/BotCommand.cpp + td/telegram/BotCommandScope.cpp + td/telegram/BotMenuButton.cpp + td/telegram/BotMenuButton.h td/telegram/CallActor.cpp td/telegram/CallDiscardReason.cpp td/telegram/CallManager.cpp td/telegram/CallbackQueriesManager.cpp + td/telegram/ChannelParticipantFilter.cpp + td/telegram/ChatReactions.cpp td/telegram/ClientActor.cpp td/telegram/ConfigManager.cpp - td/telegram/ConfigShared.cpp + td/telegram/ConnectionState.cpp td/telegram/Contact.cpp td/telegram/ContactsManager.cpp + td/telegram/CountryInfoManager.cpp td/telegram/DelayDispatcher.cpp + td/telegram/Dependencies.cpp td/telegram/DeviceTokenManager.cpp td/telegram/DhCache.cpp + td/telegram/DialogAction.cpp + td/telegram/DialogActionBar.cpp + td/telegram/DialogAdministrator.cpp td/telegram/DialogDb.cpp + td/telegram/DialogEventLog.cpp + td/telegram/DialogFilter.cpp td/telegram/DialogId.cpp + td/telegram/DialogInviteLink.cpp + td/telegram/DialogLocation.cpp + td/telegram/DialogNotificationSettings.cpp td/telegram/DialogParticipant.cpp + td/telegram/DialogParticipantFilter.cpp + td/telegram/DialogSource.cpp + td/telegram/Dimensions.cpp + td/telegram/Document.cpp td/telegram/DocumentsManager.cpp + td/telegram/DownloadManager.cpp + td/telegram/DownloadManagerCallback.cpp + td/telegram/DraftMessage.cpp + td/telegram/EmailVerification.cpp + td/telegram/EmojiStatus.cpp + td/telegram/FileReferenceManager.cpp + td/telegram/files/FileBitmask.cpp td/telegram/files/FileDb.cpp td/telegram/files/FileDownloader.cpp + td/telegram/files/FileEncryptionKey.cpp td/telegram/files/FileFromBytes.cpp td/telegram/files/FileGcParameters.cpp td/telegram/files/FileGcWorker.cpp @@ -363,17 +348,48 @@ set(TDLIB_SOURCE td/telegram/files/FileManager.cpp td/telegram/files/FileStats.cpp td/telegram/files/FileStatsWorker.cpp + td/telegram/files/FileType.cpp td/telegram/files/FileUploader.cpp td/telegram/files/PartsManager.cpp td/telegram/files/ResourceManager.cpp + td/telegram/ForumTopic.cpp + td/telegram/ForumTopicEditedData.cpp + td/telegram/ForumTopicIcon.cpp + td/telegram/ForumTopicInfo.cpp + td/telegram/ForumTopicManager.cpp td/telegram/Game.cpp + td/telegram/GameManager.cpp td/telegram/Global.cpp + td/telegram/GroupCallManager.cpp + td/telegram/GroupCallParticipant.cpp + td/telegram/GroupCallParticipantOrder.cpp + td/telegram/GroupCallVideoPayload.cpp td/telegram/HashtagHints.cpp td/telegram/InlineQueriesManager.cpp + td/telegram/InputDialogId.cpp + td/telegram/InputGroupCallId.cpp + td/telegram/InputInvoice.cpp + td/telegram/InputMessageText.cpp + td/telegram/JsonValue.cpp + td/telegram/LanguagePackManager.cpp + td/telegram/LinkManager.cpp td/telegram/Location.cpp + td/telegram/logevent/LogEventHelper.cpp + td/telegram/Logging.cpp + td/telegram/MessageContent.cpp + td/telegram/MessageContentType.cpp + td/telegram/MessageDb.cpp td/telegram/MessageEntity.cpp - td/telegram/MessagesDb.cpp + td/telegram/MessageExtendedMedia.cpp + td/telegram/MessageId.cpp + td/telegram/MessageReaction.cpp + td/telegram/MessageReplyHeader.cpp + td/telegram/MessageReplyInfo.cpp + td/telegram/MessageSearchFilter.cpp + td/telegram/MessageSender.cpp td/telegram/MessagesManager.cpp + td/telegram/MessageThreadDb.cpp + td/telegram/MessageTtl.cpp td/telegram/misc.cpp td/telegram/net/AuthDataShared.cpp td/telegram/net/ConnectionCreator.cpp @@ -382,81 +398,174 @@ set(TDLIB_SOURCE td/telegram/net/MtprotoHeader.cpp td/telegram/net/NetActor.cpp td/telegram/net/NetQuery.cpp - td/telegram/net/NetQueryCounter.cpp td/telegram/net/NetQueryCreator.cpp td/telegram/net/NetQueryDelayer.cpp td/telegram/net/NetQueryDispatcher.cpp + td/telegram/net/NetQueryStats.cpp td/telegram/net/NetStatsManager.cpp + td/telegram/net/Proxy.cpp td/telegram/net/PublicRsaKeyShared.cpp td/telegram/net/PublicRsaKeyWatchdog.cpp td/telegram/net/Session.cpp td/telegram/net/SessionProxy.cpp td/telegram/net/SessionMultiProxy.cpp + td/telegram/NewPasswordState.cpp + td/telegram/NotificationManager.cpp + td/telegram/NotificationSettingsScope.cpp + td/telegram/NotificationSettingsManager.cpp + td/telegram/NotificationSound.cpp + td/telegram/NotificationType.cpp + td/telegram/OptionManager.cpp + td/telegram/OrderInfo.cpp td/telegram/Payments.cpp td/telegram/PasswordManager.cpp + td/telegram/PhoneNumberManager.cpp td/telegram/PrivacyManager.cpp td/telegram/Photo.cpp + td/telegram/PhotoSize.cpp + td/telegram/PhotoSizeSource.cpp + td/telegram/PollManager.cpp + td/telegram/Premium.cpp + td/telegram/PremiumGiftOption.cpp + td/telegram/QueryCombiner.cpp + td/telegram/RecentDialogList.cpp td/telegram/ReplyMarkup.cpp + td/telegram/ReportReason.cpp + td/telegram/RestrictionReason.cpp + td/telegram/ScopeNotificationSettings.cpp td/telegram/SecretChatActor.cpp td/telegram/SecretChatDb.cpp td/telegram/SecretChatsManager.cpp + td/telegram/SecretInputMedia.cpp + td/telegram/SecureManager.cpp + td/telegram/SecureStorage.cpp + td/telegram/SecureValue.cpp + td/telegram/SendCodeHelper.cpp + td/telegram/SentEmailCode.cpp td/telegram/SequenceDispatcher.cpp + td/telegram/SpecialStickerSetType.cpp + td/telegram/SponsoredMessageManager.cpp td/telegram/StateManager.cpp + td/telegram/StickerFormat.cpp td/telegram/StickersManager.cpp + td/telegram/StickerType.cpp td/telegram/StorageManager.cpp + td/telegram/SuggestedAction.cpp + td/telegram/Support.cpp td/telegram/Td.cpp td/telegram/TdDb.cpp + td/telegram/TermsOfService.cpp + td/telegram/ThemeManager.cpp + td/telegram/TopDialogCategory.cpp td/telegram/TopDialogManager.cpp + td/telegram/TranscriptionInfo.cpp td/telegram/UpdatesManager.cpp + td/telegram/Usernames.cpp + td/telegram/Venue.cpp td/telegram/VideoNotesManager.cpp td/telegram/VideosManager.cpp td/telegram/VoiceNotesManager.cpp + td/telegram/WebPageBlock.cpp td/telegram/WebPagesManager.cpp td/mtproto/AuthData.h td/mtproto/AuthKey.h - td/mtproto/crypto.h + td/mtproto/ConnectionManager.h td/mtproto/CryptoStorer.h + td/mtproto/DhCallback.h + td/mtproto/DhHandshake.h td/mtproto/Handshake.h td/mtproto/HandshakeActor.h td/mtproto/HandshakeConnection.h td/mtproto/HttpTransport.h td/mtproto/IStreamTransport.h + td/mtproto/KDF.h + td/mtproto/MtprotoQuery.h td/mtproto/NoCryptoStorer.h + td/mtproto/PacketInfo.h td/mtproto/PacketStorer.h + td/mtproto/Ping.h td/mtproto/PingConnection.h + td/mtproto/ProxySecret.h td/mtproto/RawConnection.h + td/mtproto/RSA.h td/mtproto/SessionConnection.h td/mtproto/TcpTransport.h + td/mtproto/TlsInit.h + td/mtproto/TlsReaderByteFlow.h td/mtproto/Transport.h + td/mtproto/TransportType.h td/mtproto/utils.h td/telegram/AccessRights.h + td/telegram/Account.h + td/telegram/AffectedHistory.h td/telegram/AnimationsManager.h + td/telegram/Application.h + td/telegram/AttachMenuManager.h td/telegram/AudiosManager.h td/telegram/AuthManager.h + td/telegram/AutoDownloadSettings.h + td/telegram/BackgroundId.h + td/telegram/BackgroundManager.h + td/telegram/BackgroundType.h + td/telegram/BotCommand.h + td/telegram/BotCommandScope.h td/telegram/CallActor.h td/telegram/CallDiscardReason.h td/telegram/CallId.h td/telegram/CallManager.h td/telegram/CallbackQueriesManager.h + td/telegram/ChainId.h td/telegram/ChannelId.h + td/telegram/ChannelParticipantFilter.h + td/telegram/ChannelType.h td/telegram/ChatId.h + td/telegram/ChatReactions.h td/telegram/ClientActor.h td/telegram/ConfigManager.h - td/telegram/ConfigShared.h + td/telegram/ConnectionState.h td/telegram/Contact.h td/telegram/ContactsManager.h + td/telegram/CountryInfoManager.h + td/telegram/CustomEmojiId.h td/telegram/DelayDispatcher.h + td/telegram/Dependencies.h td/telegram/DeviceTokenManager.h td/telegram/DhCache.h td/telegram/DhConfig.h + td/telegram/DialogAction.h + td/telegram/DialogActionBar.h + td/telegram/DialogAdministrator.h + td/telegram/DialogDate.h td/telegram/DialogDb.h + td/telegram/DialogEventLog.h + td/telegram/DialogFilter.h + td/telegram/DialogFilterId.h td/telegram/DialogId.h + td/telegram/DialogInviteLink.h + td/telegram/DialogListId.h + td/telegram/DialogLocation.h + td/telegram/DialogNotificationSettings.h td/telegram/DialogParticipant.h + td/telegram/DialogParticipantFilter.h + td/telegram/DialogSource.h + td/telegram/Dimensions.h + td/telegram/Document.h td/telegram/DocumentsManager.h + td/telegram/DownloadManager.h + td/telegram/DownloadManagerCallback.h + td/telegram/DraftMessage.h + td/telegram/EmailVerification.h + td/telegram/EmojiStatus.h + td/telegram/EncryptedFile.h + td/telegram/FileReferenceManager.h + td/telegram/files/FileBitmask.h + td/telegram/files/FileData.h td/telegram/files/FileDb.h + td/telegram/files/FileDbId.h td/telegram/files/FileDownloader.h + td/telegram/files/FileEncryptionKey.h td/telegram/files/FileFromBytes.h td/telegram/files/FileGcParameters.h td/telegram/files/FileGcWorker.h @@ -469,23 +578,63 @@ set(TDLIB_SOURCE td/telegram/files/FileLoadManager.h td/telegram/files/FileLocation.h td/telegram/files/FileManager.h + td/telegram/files/FileSourceId.h td/telegram/files/FileStats.h td/telegram/files/FileStatsWorker.h + td/telegram/files/FileType.h td/telegram/files/FileUploader.h td/telegram/files/PartsManager.h td/telegram/files/ResourceManager.h td/telegram/files/ResourceState.h + td/telegram/FolderId.h + td/telegram/ForumTopic.h + td/telegram/ForumTopicEditedData.h + td/telegram/ForumTopicIcon.h + td/telegram/ForumTopicInfo.h + td/telegram/ForumTopicManager.h + td/telegram/FullMessageId.h td/telegram/Game.h + td/telegram/GameManager.h + td/telegram/GitCommitHash.h td/telegram/Global.h + td/telegram/GroupCallId.h + td/telegram/GroupCallManager.h + td/telegram/GroupCallParticipant.h + td/telegram/GroupCallParticipantOrder.h + td/telegram/GroupCallVideoPayload.h td/telegram/HashtagHints.h td/telegram/InlineQueriesManager.h + td/telegram/InputDialogId.h + td/telegram/InputGroupCallId.h + td/telegram/InputInvoice.h + td/telegram/InputMessageText.h + td/telegram/JsonValue.h + td/telegram/LabeledPricePart.h + td/telegram/LanguagePackManager.h + td/telegram/LinkManager.h td/telegram/Location.h td/telegram/logevent/LogEvent.h + td/telegram/logevent/LogEventHelper.h td/telegram/logevent/SecretChatEvent.h + td/telegram/Logging.h + td/telegram/MessageContent.h + td/telegram/MessageContentType.h + td/telegram/MessageCopyOptions.h + td/telegram/MessageDb.h td/telegram/MessageEntity.h + td/telegram/MessageExtendedMedia.h td/telegram/MessageId.h - td/telegram/MessagesDb.h + td/telegram/MessageLinkInfo.h + td/telegram/MessageReaction.h + td/telegram/MessageReplyHeader.h + td/telegram/MessageReplyInfo.h + td/telegram/MessageSearchFilter.h + td/telegram/MessageSender.h td/telegram/MessagesManager.h + td/telegram/MessageThreadDb.h + td/telegram/MessageThreadInfo.h + td/telegram/MessageTtl.h + td/telegram/MinChannel.h td/telegram/misc.h td/telegram/net/AuthDataShared.h td/telegram/net/ConnectionCreator.h @@ -500,60 +649,145 @@ set(TDLIB_SOURCE td/telegram/net/NetQueryCreator.h td/telegram/net/NetQueryDelayer.h td/telegram/net/NetQueryDispatcher.h + td/telegram/net/NetQueryStats.h td/telegram/net/NetStatsManager.h td/telegram/net/NetType.h + td/telegram/net/Proxy.h td/telegram/net/PublicRsaKeyShared.h td/telegram/net/PublicRsaKeyWatchdog.h td/telegram/net/Session.h td/telegram/net/SessionProxy.h td/telegram/net/SessionMultiProxy.h td/telegram/net/TempAuthKeyWatchdog.h + td/telegram/NewPasswordState.h + td/telegram/Notification.h + td/telegram/NotificationGroupId.h + td/telegram/NotificationGroupKey.h + td/telegram/NotificationGroupType.h + td/telegram/NotificationId.h + td/telegram/NotificationManager.h + td/telegram/NotificationSettingsScope.h + td/telegram/NotificationSettingsManager.h + td/telegram/NotificationSound.h + td/telegram/NotificationSoundType.h + td/telegram/NotificationType.h + td/telegram/OptionManager.h + td/telegram/OrderInfo.h td/telegram/PasswordManager.h td/telegram/Payments.h + td/telegram/PhoneNumberManager.h td/telegram/Photo.h + td/telegram/PhotoFormat.h + td/telegram/PhotoSize.h + td/telegram/PhotoSizeSource.h + td/telegram/PollId.h + td/telegram/PollManager.h + td/telegram/Premium.h + td/telegram/PremiumGiftOption.h td/telegram/PrivacyManager.h td/telegram/PtsManager.h + td/telegram/PublicDialogType.h + td/telegram/QueryCombiner.h + td/telegram/RecentDialogList.h td/telegram/ReplyMarkup.h + td/telegram/ReportReason.h + td/telegram/RequestActor.h + td/telegram/RestrictionReason.h + td/telegram/ScheduledServerMessageId.h + td/telegram/ScopeNotificationSettings.h td/telegram/SecretChatActor.h td/telegram/SecretChatId.h td/telegram/SecretChatDb.h + td/telegram/SecretChatLayer.h td/telegram/SecretChatsManager.h td/telegram/SecretInputMedia.h + td/telegram/SecureManager.h + td/telegram/SecureStorage.h + td/telegram/SecureValue.h + td/telegram/SendCodeHelper.h + td/telegram/SentEmailCode.h td/telegram/SequenceDispatcher.h + td/telegram/ServerMessageId.h + td/telegram/SetWithPosition.h + td/telegram/SpecialStickerSetType.h + td/telegram/SponsoredMessageManager.h td/telegram/StateManager.h + td/telegram/StickerFormat.h + td/telegram/StickerSetId.h td/telegram/StickersManager.h + td/telegram/StickerType.h td/telegram/StorageManager.h + td/telegram/SuggestedAction.h + td/telegram/Support.h td/telegram/Td.h td/telegram/TdCallback.h td/telegram/TdDb.h td/telegram/TdParameters.h + td/telegram/TermsOfService.h + td/telegram/ThemeManager.h + td/telegram/TopDialogCategory.h td/telegram/TopDialogManager.h + td/telegram/TranscriptionInfo.h td/telegram/UniqueId.h td/telegram/UpdatesManager.h td/telegram/UserId.h + td/telegram/Usernames.h + td/telegram/Venue.h td/telegram/Version.h td/telegram/VideoNotesManager.h td/telegram/VideosManager.h td/telegram/VoiceNotesManager.h + td/telegram/WebPageBlock.h td/telegram/WebPageId.h td/telegram/WebPagesManager.h td/telegram/AnimationsManager.hpp td/telegram/AudiosManager.hpp td/telegram/AuthManager.hpp + td/telegram/BackgroundType.hpp + td/telegram/DialogNotificationSettings.hpp + td/telegram/DialogFilter.hpp + td/telegram/Dimensions.hpp + td/telegram/Document.hpp td/telegram/DocumentsManager.hpp + td/telegram/DraftMessage.hpp + td/telegram/FileReferenceManager.hpp + td/telegram/files/FileData.hpp td/telegram/files/FileId.hpp + td/telegram/files/FileLocation.hpp td/telegram/files/FileManager.hpp + td/telegram/files/FileSourceId.hpp + td/telegram/ForumTopicEditedData.hpp + td/telegram/ForumTopicIcon.hpp td/telegram/Game.hpp - td/telegram/Payments.hpp + td/telegram/InputInvoice.hpp + td/telegram/InputMessageText.hpp + td/telegram/MessageEntity.hpp + td/telegram/MessageExtendedMedia.hpp + td/telegram/MessageReaction.hpp + td/telegram/MessageReplyInfo.hpp + td/telegram/MinChannel.hpp + td/telegram/OrderInfo.hpp td/telegram/Photo.hpp + td/telegram/PhotoSize.hpp + td/telegram/PhotoSizeSource.hpp + td/telegram/PollId.hpp + td/telegram/PollManager.hpp + td/telegram/PremiumGiftOption.hpp td/telegram/ReplyMarkup.hpp + td/telegram/ScopeNotificationSettings.hpp + td/telegram/SecureValue.hpp + td/telegram/SendCodeHelper.hpp + td/telegram/StickerSetId.hpp td/telegram/StickersManager.hpp + td/telegram/TranscriptionInfo.hpp td/telegram/VideoNotesManager.hpp td/telegram/VideosManager.hpp td/telegram/VoiceNotesManager.hpp ${TL_TD_SCHEME_SOURCE} + + ${CMAKE_CURRENT_BINARY_DIR}/td/telegram/GitCommitHash.cpp ) set(MEMPROF_SOURCE @@ -561,20 +795,9 @@ set(MEMPROF_SOURCE memprof/memprof.h ) -#RULES - -file(MAKE_DIRECTORY auto) - -if (WIN32) - set(GIT_COMMIT_CMD powershell -ExecutionPolicy ByPass ./gen_git_commit_h.ps1) -else() - set(GIT_COMMIT_CMD ./gen_git_commit_h.sh) -endif() - -add_custom_target(git_commit ALL - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${GIT_COMMIT_CMD} - COMMENT "Generate git_commit.h" +set(MEMPROF_STAT_SOURCE + memprof/memprof_stat.cpp + memprof/memprof_stat.h ) #LIBRARIES @@ -589,25 +812,44 @@ if (MEMPROF) target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_SAFE=1) elseif (MEMPROF STREQUAL "FAST") target_compile_definitions(memprof PRIVATE -DUSE_MEMPROF_FAST=1) - elseif (NOT ${MEMPROF}) + elseif (NOT MEMPROF) message(FATAL_ERROR "Unsupported MEMPROF value \"${MEMPROF}\"") endif() endif() +add_library(memprof_stat EXCLUDE_FROM_ALL STATIC ${MEMPROF_STAT_SOURCE}) +target_include_directories(memprof_stat PUBLIC $) +target_link_libraries(memprof_stat PRIVATE tdutils) -# tdcore - mostly internal TDLib interface. One should use tdactor for interactions with it. -add_library(tdcore STATIC ${TDLIB_SOURCE}) -target_include_directories(tdcore PUBLIC $ $) -target_include_directories(tdcore SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR}) -target_link_libraries(tdcore PUBLIC tdactor tdutils tdnet tddb PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES}) + +add_library(tdapi ${TL_TD_API_SOURCE}) +target_include_directories(tdapi PUBLIC $ INTERFACE $) +target_link_libraries(tdapi PRIVATE tdutils) if (TD_ENABLE_JNI AND NOT ANDROID) # jni is available by default on Android if (NOT JNI_FOUND) find_package(JNI REQUIRED) endif() message(STATUS "Found JNI: ${JNI_INCLUDE_DIRS} ${JNI_LIBRARIES}") - target_include_directories(tdcore PUBLIC ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) - target_link_libraries(tdcore PUBLIC ${JAVA_JVM_LIBRARY}) + target_include_directories(tdapi PUBLIC ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) + target_link_libraries(tdapi PUBLIC ${JAVA_JVM_LIBRARY}) +endif() + +if (NOT CMAKE_CROSSCOMPILING) + add_dependencies(tdapi tl_generate_common) +endif() + +# tdcore - mostly internal TDLib interface. One should use tdactor for interactions with it. +add_library(tdcore STATIC ${TDLIB_SOURCE}) +target_include_directories(tdcore PUBLIC $ $) +target_include_directories(tdcore SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR}) +target_link_libraries(tdcore PUBLIC tdapi tdactor tdutils tdnet tddb PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES}) +if (WIN32) + if (MINGW) + target_link_libraries(tdcore PRIVATE ws2_32 mswsock crypt32) + else() + target_link_libraries(tdcore PRIVATE ws2_32 Mswsock Crypt32) + endif() endif() if (NOT CMAKE_CROSSCOMPILING) @@ -623,14 +865,8 @@ endif() add_library(tdclient td/telegram/Client.cpp td/telegram/Client.h td/telegram/Log.cpp td/telegram/Log.h) target_include_directories(tdclient PUBLIC $ - $ ) -target_link_libraries(tdclient PRIVATE tdcore) - -if (TD_ENABLE_JNI AND NOT ANDROID) # jni is available by default on Android - target_include_directories(tdclient PUBLIC ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) - target_link_libraries(tdclient PUBLIC ${JAVA_JVM_LIBRARY}) -endif() +target_link_libraries(tdclient PUBLIC tdapi PRIVATE tdcore) if (TD_ENABLE_DOTNET) add_library(tddotnet SHARED @@ -638,18 +874,17 @@ if (TD_ENABLE_DOTNET) td/telegram/LogDotNet.cpp ${TL_DOTNET_SCHEME_SOURCE} ) - set(VCPKG_APPLOCAL_LIBRARY_DEPS ON) set_target_properties(tddotnet PROPERTIES OUTPUT_NAME Telegram.Td) target_link_libraries(tddotnet PRIVATE tdclient tdutils) target_include_directories(tddotnet PUBLIC - $ + $ ) if (NOT CMAKE_CROSSCOMPILING) add_dependencies(tddotnet generate_dotnet_api) endif() target_compile_options(tddotnet PRIVATE "/doc") - if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") + if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set_target_properties(tddotnet PROPERTIES VS_WINRT_COMPONENT "true") target_compile_options(tddotnet PUBLIC "/ZW") else() @@ -659,19 +894,19 @@ if (TD_ENABLE_DOTNET) endif() # tdc - TDLib interface in pure c. -add_library(tdc STATIC ${TL_C_SCHEME_SOURCE} td/telegram/td_c_client.cpp td/telegram/td_c_client.h) +add_library(tdc STATIC EXCLUDE_FROM_ALL ${TL_C_SCHEME_SOURCE} td/telegram/td_c_client.cpp td/telegram/td_c_client.h) target_include_directories(tdc PUBLIC $ - $) + $) target_link_libraries(tdc PRIVATE tdclient tdutils) if (NOT CMAKE_CROSSCOMPILING) add_dependencies(tdc tl_generate_c) endif() -add_library(tdjson_private STATIC ${TL_TD_JSON} td/telegram/ClientJson.cpp td/telegram/ClientJson.h) +add_library(tdjson_private STATIC ${TL_TD_JSON_SOURCE} td/telegram/ClientJson.cpp td/telegram/ClientJson.h) target_include_directories(tdjson_private PUBLIC $ - $) + $) target_link_libraries(tdjson_private PUBLIC tdclient tdutils) if (NOT CMAKE_CROSSCOMPILING) add_dependencies(tdjson_private tl_generate_common tl_generate_json) @@ -702,48 +937,43 @@ target_include_directories(tdjson_static PUBLIC $ $) -set(BIGOBJ) -if (WIN32 OR CYGWIN) - if (MSVC) - set(BIGOBJ "/bigobj") - elseif (GCC) - set(BIGOBJ "-Wa,-mbig-obj") - endif() -endif() -if (BIGOBJ) - target_compile_options(tdc PUBLIC ${BIGOBJ}) - target_compile_options(tdcore PUBLIC ${BIGOBJ}) - target_compile_options(tdclient PUBLIC ${BIGOBJ}) - target_compile_options(tdjson PUBLIC ${BIGOBJ}) - target_compile_options(tdjson_static PUBLIC ${BIGOBJ}) - if (TD_ENABLE_DOTNET) - target_compile_options(tddotnet PUBLIC "/bigobj") - endif() -endif() - if (EMSCRIPTEN) set(TD_EMSCRIPTEN_SRC td/telegram/td_emscripten.cpp) add_executable(${TD_EMSCRIPTEN} ${TD_EMSCRIPTEN_SRC}) target_include_directories(${TD_EMSCRIPTEN} PUBLIC $) - target_link_libraries(${TD_EMSCRIPTEN} PRIVATE tdjson_static) + target_link_libraries(${TD_EMSCRIPTEN} PRIVATE tdjson_static tdactor) endif() #EXECUTABLES if (NOT CMAKE_CROSSCOMPILING) - add_executable(tg_cli td/telegram/cli.cpp ${TL_TD_JSON}) + add_executable(tg_cli td/telegram/cli.cpp ${TL_TD_JSON_SOURCE}) if (NOT READLINE_FOUND) find_package(Readline) endif() if (NOT READLINE_FOUND) - message(STATUS "Could NOT find Readline") + message(STATUS "Could NOT find Readline (this is NOT an error)") else() message(STATUS "Found Readline: ${READLINE_INCLUDE_DIR} ${READLINE_LIBRARY}") - target_link_libraries(tg_cli PRIVATE ${READLINE_LIBRARY}) - target_include_directories(tg_cli SYSTEM PRIVATE ${READLINE_INCLUDE_DIR}) - target_compile_definitions(tg_cli PRIVATE -DUSE_READLINE=1) + if (NOT USABLE_READLINE_FOUND) + set(CMAKE_REQUIRED_INCLUDES "${READLINE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_LIBRARIES "${READLINE_LIBRARY}") + include(CheckCXXSourceCompiles) + unset(USABLE_READLINE_FOUND CACHE) + check_cxx_source_compiles("#include \n#include \nint main() { rl_free(0); }" USABLE_READLINE_FOUND) + if (NOT USABLE_READLINE_FOUND) + message(STATUS "Found Readline is too old, ignore it (this is NOT an error)") + unset(READLINE_INCLUDE_DIR CACHE) + unset(READLINE_LIBRARY CACHE) + endif() + endif() + if (USABLE_READLINE_FOUND) + target_link_libraries(tg_cli PRIVATE ${READLINE_LIBRARY}) + target_include_directories(tg_cli SYSTEM PRIVATE ${READLINE_INCLUDE_DIR}) + target_compile_definitions(tg_cli PRIVATE -DUSE_READLINE=1) + endif() endif() - target_link_libraries(tg_cli PRIVATE memprof tdclient tdcore tdtl) + target_link_libraries(tg_cli PRIVATE memprof tdclient tdcore) add_dependencies(tg_cli tl_generate_json) endif() @@ -761,32 +991,65 @@ add_library(Td::TdStatic ALIAS TdStatic) add_library(Td::TdJson ALIAS TdJson) add_library(Td::TdJsonStatic ALIAS TdJsonStatic) -install(TARGETS tdjson TdJson tdjson_static TdJsonStatic tdjson_private tdclient tdcore TdStatic EXPORT TdTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include +install(TARGETS tdjson TdJson tdjson_static TdJsonStatic tdjson_private tdclient tdcore tdapi TdStatic EXPORT TdTargets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) +# generate pkg-config files +include(GeneratePkgConfig) + +generate_pkgconfig(tdutils "Telegram Library - Utils") +generate_pkgconfig(tdactor "Telegram Library - Actor") +generate_pkgconfig(tdnet "Telegram Library - Net") +generate_pkgconfig(tdsqlite "Telegram Library - SQLite") +generate_pkgconfig(tddb "Telegram Library - Database") +if (MEMPROF) + # generate_pkgconfig(memprof "memprof - simple library for memory usage profiling") +endif() +generate_pkgconfig(tdcore "Telegram Library - Core") +generate_pkgconfig(tdclient "Telegram Library - C++ Interface") +if (TD_ENABLE_DOTNET) + # generate_pkgconfig(tddotnet "Telegram Library - C# Interface") +endif() +# generate_pkgconfig(tdc "Telegram Library - C interface") +generate_pkgconfig(tdapi "Telegram Library - API") +generate_pkgconfig(tdjson_private "Telegram Library - JSON interface (private)") +generate_pkgconfig(tdjson "Telegram Library - JSON interface (shared)") +generate_pkgconfig(tdjson_static "Telegram Library - JSON interface (static)") + install(EXPORT TdTargets FILE TdTargets.cmake NAMESPACE Td:: - DESTINATION lib/cmake/Td + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Td" ) -install(FILES ${TD_JSON_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/td/telegram/tdjson_export.h DESTINATION include/td/telegram) -install(FILES td/telegram/Client.h td/telegram/Log.h DESTINATION include/td/telegram) -install(FILES td/tl/TlObject.h DESTINATION include/td/tl) -install(FILES ${TL_TD_AUTO_INCLUDES}/td/telegram/td_api.h ${TL_TD_AUTO_INCLUDES}/td/telegram/td_api.hpp DESTINATION include/td/telegram) +# Install tdjson/tdjson_static: +install(FILES ${TD_JSON_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/td/telegram/tdjson_export.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram") +# Install tdclient: +install(FILES td/telegram/Client.h td/telegram/Log.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram") +# Install tdapi: +install(FILES td/tl/TlObject.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/tl") +install(FILES "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.h" "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.hpp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram") if (TD_ENABLE_JNI) - install(FILES td/tl/tl_jni_object.h DESTINATION include/td/tl) + install(FILES td/tl/tl_jni_object.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/tl") +endif() +if (MSVC AND VCPKG_TOOLCHAIN) + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/" DESTINATION "${CMAKE_INSTALL_BINDIR}" FILES_MATCHING PATTERN "*.dll") endif() include(CMakePackageConfigHelpers) write_basic_package_version_file("TdConfigVersion.cmake" - VERSION ${TDLib_VERSION} + VERSION "${TDLib_VERSION}" COMPATIBILITY ExactVersion ) install(FILES "TdConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/TdConfigVersion.cmake" - DESTINATION lib/cmake/Td + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Td" ) + +# Add SOVERSION to shared libraries +set_property(TARGET tdclient PROPERTY SOVERSION "${TDLib_VERSION}") +set_property(TARGET tdapi PROPERTY SOVERSION "${TDLib_VERSION}") +set_property(TARGET tdjson PROPERTY SOVERSION "${TDLib_VERSION}") diff --git a/protocols/Telegram/tdlib/td/README.md b/protocols/Telegram/tdlib/td/README.md index 00e94cabff..ef82fb2e48 100644 --- a/protocols/Telegram/tdlib/td/README.md +++ b/protocols/Telegram/tdlib/td/README.md @@ -7,7 +7,6 @@ TDLib (Telegram Database library) is a cross-platform library for building [Tele - [Examples and documentation](#usage) - [Dependencies](#dependencies) - [Building](#building) -- [Installing dependencies](#installing-dependencies) - [Using in CMake C++ projects](#using-cxx) - [Using in Java projects](#using-java) - [Using in .NET projects](#using-dotnet) @@ -19,10 +18,10 @@ TDLib (Telegram Database library) is a cross-platform library for building [Tele `TDLib` has many advantages. Notably `TDLib` is: -* **Cross-platform**: `TDLib` can be used on Android, iOS, Windows, macOS, Linux, Windows Phone, WebAssembly, watchOS, tvOS, Tizen, Cygwin. It should also work on other *nix systems with or without minimal effort. +* **Cross-platform**: `TDLib` can be used on Android, iOS, Windows, macOS, Linux, FreeBSD, OpenBSD, NetBSD, illumos, Windows Phone, WebAssembly, watchOS, tvOS, Tizen, Cygwin. It should also work on other *nix systems with or without minimal effort. * **Multilanguage**: `TDLib` can be easily used with any programming language that is able to execute C functions. Additionally it already has native Java (using `JNI`) bindings and .NET (using `C++/CLI` and `C++/CX`) bindings. * **Easy to use**: `TDLib` takes care of all network implementation details, encryption and local data storage. -* **High-performance**: in the [Telegram Bot API](https://core.telegram.org/bots/api), each `TDLib` instance handles more than 19000 active bots simultaneously. +* **High-performance**: in the [Telegram Bot API](https://core.telegram.org/bots/api), each `TDLib` instance handles more than 24000 active bots simultaneously. * **Well-documented**: all `TDLib` API methods and public interfaces are fully documented. * **Consistent**: `TDLib` guarantees that all updates are delivered in the right order. * **Reliable**: `TDLib` remains stable on slow and unreliable Internet connections. @@ -31,7 +30,16 @@ TDLib (Telegram Database library) is a cross-platform library for building [Tele ## Examples and documentation -Take a look at our [examples](https://github.com/tdlib/td/tree/master/example) and [documentation](https://core.telegram.org/tdlib/docs/). +See our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts. + +Take a look at our [examples](https://github.com/tdlib/td/blob/master/example/README.md#tdlib-usage-and-build-examples). + +See a [TDLib build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib. + +See description of our [JSON](#using-json), [C++](#using-cxx), [Java](#using-java) and [.NET](#using-dotnet) interfaces. + +See the [td_api.tl](https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl) scheme or the automatically generated [HTML documentation](https://core.telegram.org/tdlib/docs/td__api_8h.html) +for a list of all available `TDLib` [methods](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html) and [classes](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_object.html). ## Dependencies @@ -43,13 +51,14 @@ Take a look at our [examples](https://github.com/tdlib/td/tree/master/example) a * gperf (build only) * CMake (3.0.2+, build only) * PHP (optional, for documentation generation) -* Doxygen (optional, for documentation generation) ## Building -Install all `TDLib` dependencies as described in [Installing dependencies](#installing-dependencies). -Then enter directory containing `TDLib` sources and compile them using CMake: +The simplest way to build `TDLib` is to use our [TDLib build instructions generator](https://tdlib.github.io/td/build.html). +You need only to choose your programming language and target operating system to receive complete build instructions. + +In general, you need to install all `TDLib` [dependencies](#dependencies), enter directory containing `TDLib` sources and compile them using CMake: ``` mkdir build @@ -58,53 +67,33 @@ cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . ``` - -### Installing dependencies - - -#### macOS -* Install the latest Xcode command line tools. -* Install other dependencies, for example, using [Homebrew](https://brew.sh): -``` -brew install gperf cmake openssl -``` -* Build `TDLib` with CMake as explained in [building](#building). You may need to manually specify path to the installed OpenSSL to CMake, e.g., -``` -cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ .. -``` - - -#### Windows -* Download and install [gperf](https://sourceforge.net/projects/gnuwin32/files/gperf/3.0.1/). Add the path to gperf.exe to the PATH environment variable. -* Install [vcpkg](https://github.com/Microsoft/vcpkg#quick-start). -* Run the following commands to install `TDLib` dependencies using vcpkg: -``` -C:\src\vcpkg> .\vcpkg.exe install openssl:x64-windows openssl:x86-windows zlib:x64-windows zlib:x86-windows -``` -* Build `TDLib` with CMake as explained in [building](#building), but instead of `cmake -DCMAKE_BUILD_TYPE=Release ..` use +To build `TDLib` on low memory devices you can run [SplitSource.php](https://github.com/tdlib/td/blob/master/SplitSource.php) script +before compiling main `TDLib` source code and compile only needed targets: ``` -cmake -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake .. +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +cmake --build . --target prepare_cross_compiling +cd .. +php SplitSource.php +cd build +cmake --build . --target tdjson +cmake --build . --target tdjson_static +cd .. +php SplitSource.php --undo ``` - -To build 64-bit `TDLib` using MSVC, you will need to additionally specify parameter `-A x64` to CMake. -To build `TDLib` in Release mode using MSVC, you will need to additionally specify parameter `--config Release` to the `cmake --build .` command. - - -#### Linux -* Install all dependencies using your package manager. +In our tests clang 6.0 with libc++ required less than 500 MB of RAM per file and GCC 4.9/6.3 used less than 1 GB of RAM per file. ## Using in CMake C++ projects -For C++ projects that use CMake, the best approach is to build `TDLib` as part of your project or to use a prebuilt installation. +For C++ projects that use CMake, the best approach is to build `TDLib` as part of your project or to install it system-wide. There are several libraries that you could use in your CMake project: * Td::TdJson, Td::TdJsonStatic — dynamic and static version of a JSON interface. This has a simple C interface, so it can be easily used with any programming language that is able to execute C functions. - See [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) and [td_log](https://core.telegram.org/tdlib/docs/td__log_8h.html) documentation for more information. + See [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) documentation for more information. * Td::TdStatic — static library with C++ interface for general usage. - See [Client](https://core.telegram.org/tdlib/docs/classtd_1_1_client.html) and [Log](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html) documentation for more information. -* Td::TdCoreStatic — static library with low-level C++ interface intended mostly for internal usage. - See [ClientActor](https://core.telegram.org/tdlib/docs/classtd_1_1_client_actor.html) and [Log](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html) documentation for more information. + See [ClientManager](https://core.telegram.org/tdlib/docs/classtd_1_1_client_manager.html) and [Client](https://core.telegram.org/tdlib/docs/classtd_1_1_client.html) documentation for more information. For example, part of your CMakeLists.txt may look like this: ``` @@ -114,10 +103,10 @@ target_link_libraries(YourTarget PRIVATE Td::TdStatic) Or you could install `TDLib` and then reference it in your CMakeLists.txt like this: ``` -find_package(Td 1.2.0 REQUIRED) +find_package(Td 1.8.8 REQUIRED) target_link_libraries(YourTarget PRIVATE Td::TdStatic) ``` -See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt). +See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/blob/master/example/cpp/CMakeLists.txt). ## Using in Java projects @@ -128,7 +117,7 @@ See [example/java](https://github.com/tdlib/td/tree/master/example/java) for exa ## Using in .NET projects `TDLib` provides native .NET interface through `C++/CLI` and `C++/CX`. To enable it, specify option `-DTD_ENABLE_DOTNET=ON` to CMake. -.NET Core doesn't support `C++/CLI`, so if .NET Core is used, then `TDLib` JSON interface should be used through P/Invoke instead. +.NET Core supports `C++/CLI` only since version 3.1 and only on Windows, so if older .NET Core is used or portability is needed, then `TDLib` JSON interface should be used through P/Invoke instead. See [example/csharp](https://github.com/tdlib/td/tree/master/example/csharp) for example of using `TDLib` from C# and detailed build and usage instructions. See [example/uwp](https://github.com/tdlib/td/tree/master/example/uwp) for example of using `TDLib` from C# UWP application and detailed build and usage instructions for Visual Studio Extension "TDLib for Universal Windows Platform". @@ -142,10 +131,14 @@ git checkout td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h ## Using from other programming languages `TDLib` provides efficient native C++, Java, and .NET interfaces. But for most use cases we suggest to use the JSON interface, which can be easily used with any programming language that is able to execute C functions. -See [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) and [td_log](https://core.telegram.org/tdlib/docs/td__log_8h.html) documentation for detailed JSON interface description, -scheme [td_api.tl](https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl) or autogenerated [HTML documentation](https://core.telegram.org/tdlib/docs/td__api_8h.html) for the list of all available `TDLib` methods and classes. +See [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) documentation for detailed JSON interface description, +the [td_api.tl](https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl) scheme or the automatically generated [HTML documentation](https://core.telegram.org/tdlib/docs/td__api_8h.html) for a list of +all available `TDLib` [methods](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html) and [classes](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_object.html). + +`TDLib` JSON interface adheres to semantic versioning and versions with the same major version number are binary and backward compatible, but the underlying `TDLib` API can be different for different minor and even patch versions. +If you need to support different `TDLib` versions, then you can use a value of the `version` option to find exact `TDLib` version to use appropriate API methods. -See [example/python/tdjson_example.py](https://github.com/tdlib/td/tree/master/example/python/tdjson_example.py) and [example/ruby/example.rb](https://github.com/tdlib/td/tree/master/example/ruby/example.rb) for an example of such usage. +See [example/python/tdjson_example.py](https://github.com/tdlib/td/blob/master/example/python/tdjson_example.py) for an example of such usage. ## License diff --git a/protocols/Telegram/tdlib/td/SplitSource.php b/protocols/Telegram/tdlib/td/SplitSource.php new file mode 100644 index 0000000000..49854cb716 --- /dev/null +++ b/protocols/Telegram/tdlib/td/SplitSource.php @@ -0,0 +1,368 @@ + 0) { + $depth += $add_depth; + } + if ($depth <= $target_depth) { + if ($add_depth > 0) { + $namespace_begin .= $line; + } else { + $namespace_end .= $line; + } + } + if ($add_depth < 0) { + $depth += $add_depth; + } + if ($is_static) { + $common .= $current; + } else { + $functions[] = $current; + } + $common .= $line; + $current = ''; + $is_static = false; + $in_define = false; + continue; + } + + if (strpos($line, '#undef') === 0 && !trim($current)) { + continue; + } + + if ($in_comment && strpos($line, '*/') === 0) { + $in_comment = false; + continue; + } + if (strpos($line, '/*') === 0) { + $in_comment = true; + } + if ($in_comment) { + continue; + } + + if ($depth !== $target_depth) { + $common .= $line; + continue; + } + + if (strpos($line, 'static ') === 0 && $depth === $target_depth) { + $is_static = true; + } + if (!trim($current) && strpos($line, '#define ') === 0) { + $is_static = true; + $in_define = true; + } + + $current .= $line; + if ((strpos($line, '}') === 0 || ($in_define && !trim($line)) || preg_match('/^[a-z].*;\s*$/i', $line)) && $depth === $target_depth) { + # block end + if ($is_static) { + $common .= $current; + } else { + $functions[] = $current; + } + $current = ''; + $is_static = false; + $in_define = false; + } + } + $current = trim($current); + if (!empty($current)) { + fwrite(STDERR, "ERROR: $current".PHP_EOL); + exit(); + } + + if (count($functions) < $chunks) { + fwrite(STDERR, "ERROR: file is too small to be split more".PHP_EOL); + return; + } + + $deps = array(); // all functions from the same subarray must be in the same file + $parents = array(); + foreach ($functions as $i => $f) { + if (preg_match_all('/(?J)create_handler<(?[A-Z][A-Za-z]*)>|'. + '(?[A-Z][A-Za-z]*) (final )?: public (Td::ResultHandler|Request)|'. + '(CREATE_REQUEST|CREATE_NO_ARGS_REQUEST)[(](?[A-Z][A-Za-z]*)|'. + '(?complete_pending_preauthentication_requests)|'. + '(?get_message_history_slice)|'. + '(Up|Down)load[a-zA-Z]*C(?allback)|(up|down)load_[a-z_]*_c(?allback)_|'. + '(?lazy_to_json)|'. + '(?LogEvent)[^sA]|'. + '(?parse)[(]|'. + '(?store)[(]/', $f, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $name = $match['name']; + if ($name === 'parse' || $name === 'store') { + if ($is_generated) { + continue; + } + $name = 'LogEvent'; + } + $deps[$name][] = $i; + } + } + $parents[$i] = $i; + } + + foreach ($deps as $func_ids) { + foreach ($func_ids as $func_id) { + disjoint_set_union($parents, $func_ids[0], $func_id); + } + } + $sets = array(); + $set_sizes = array(); + foreach ($functions as $i => $f) { + $parent = disjoint_set_find($parents, $i); + if (!isset($sets[$parent])) { + $sets[$parent] = ''; + $set_sizes[$parent] = 0; + } + $sets[$parent] .= $f; + $set_sizes[$parent] += preg_match('/Td::~?Td/', $f) ? 1000000 : strlen($f); + } + arsort($set_sizes); + + $files = array_fill(0, $chunks, ''); + $file_sizes = array_fill(0, $chunks, 0); + foreach ($set_sizes as $parent => $size) { + $file_id = array_search(min($file_sizes), $file_sizes); + $files[$file_id] .= $sets[$parent]; + $file_sizes[$file_id] += $size; + } + + foreach ($files as $n => $f) { + $new_content = $common.$namespace_begin.$f.$namespace_end; + + $std_methods = array(); + preg_match_all('/std::[a-z_0-9]*|td::unique(?!_)/', $new_content, $std_methods); + $std_methods = array_unique($std_methods[0]); + + $needed_std_headers = array(); + $type_headers = array( + 'std::move' => '', + 'std::vector' => '', + 'std::string' => '', + 'std::uint32_t' => '', + 'std::int32_t' => '', + 'std::int64_t' => '', + 'td::unique' => 'algorithm', + 'std::fill' => 'algorithm', + 'std::find' => 'algorithm', + 'std::max' => 'algorithm', + 'std::min' => 'algorithm', + 'std::remove' => 'algorithm', + 'std::reverse' => 'algorithm', + 'std::rotate' => 'algorithm', + 'std::sort' => 'algorithm', + 'std::abs' => 'cmath', + 'std::numeric_limits' => 'limits', + 'std::make_shared' => 'memory', + 'std::shared_ptr' => 'memory', + 'std::tie' => 'tuple', + 'std::tuple' => 'tuple', + 'std::decay_t' => 'type_traits', + 'std::is_same' => 'type_traits', + 'std::make_pair' => 'utility', + 'std::pair' => 'utility', + 'std::swap' => 'utility', + 'std::unordered_map' => 'unordered_map', + 'std::unordered_set' => 'unordered_set'); + foreach ($type_headers as $type => $header) { + if (in_array($type, $std_methods)) { + $std_methods = array_diff($std_methods, array($type)); + if ($header && !in_array($header, $needed_std_headers)) { + $needed_std_headers[] = $header; + } + } + } + + if (!$std_methods) { // know all needed std headers + $new_content = preg_replace_callback( + '/#include <([a-z_]*)>/', + function ($matches) use ($needed_std_headers) { + if (in_array($matches[1], $needed_std_headers)) { + return $matches[0]; + } + return ''; + }, + $new_content + ); + } + + if (!preg_match('/Td::~?Td/', $new_content)) { // destructor Td::~Td needs to see definitions of all forward-declared classes + $td_methods = array( + 'animations_manager[_(-][^.]|AnimationsManager[^;>]' => "AnimationsManager", + 'attach_menu_manager[_(-][^.]|AttachMenuManager[^;>]' => "AttachMenuManager", + 'audios_manager[_(-][^.]|AudiosManager' => "AudiosManager", + 'auth_manager[_(-][^.]|AuthManager' => 'AuthManager', + 'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager", + 'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager', + 'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager', + 'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager", + 'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager', + 'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', + 'forum_topic_manager[_(-][^.]|ForumTopicManager' => 'ForumTopicManager', + 'G[(][)]|Global[^A-Za-z]' => 'Global', + 'game_manager[_(-][^.]|GameManager' => 'GameManager', + 'group_call_manager[_(-][^.]|GroupCallManager' => 'GroupCallManager', + 'HashtagHints' => 'HashtagHints', + 'inline_queries_manager[_(-][^.]|InlineQueriesManager' => 'InlineQueriesManager', + 'language_pack_manager[_(-]|LanguagePackManager' => 'LanguagePackManager', + 'link_manager[_(-][^.]|LinkManager' => 'LinkManager', + 'LogeventIdWithGeneration|add_log_event|delete_log_event|get_erase_log_event_promise|parse_time|store_time' => 'logevent/LogEventHelper', + 'MessageCopyOptions' => 'MessageCopyOptions', + 'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager', + 'notification_manager[_(-][^.]|NotificationManager|notifications[)]' => 'NotificationManager', + 'notification_settings_manager[_(-][^.]|NotificationSettingsManager' => 'NotificationSettingsManager', + 'option_manager[_(-][^.]|OptionManager' => "OptionManager", + 'phone_number_manager[_(-][^.]|PhoneNumberManager' => "PhoneNumberManager", + 'poll_manager[_(-][^.]|PollManager' => "PollManager", + 'PublicDialogType|get_public_dialog_type' => 'PublicDialogType', + 'SecretChatActor' => 'SecretChatActor', + 'secret_chats_manager[_(-]|SecretChatsManager' => 'SecretChatsManager', + 'sponsored_message_manager[_(-][^.]|SponsoredMessageManager' => 'SponsoredMessageManager', + 'stickers_manager[_(-][^.]|StickersManager' => 'StickersManager', + '[>](td_db[(][)]|get_td_db_impl[(])|TdDb[^A-Za-z]' => 'TdDb', + 'theme_manager[_(-][^.]|ThemeManager' => "ThemeManager", + 'TopDialogCategory|get_top_dialog_category' => 'TopDialogCategory', + 'top_dialog_manager[_(-][^.]|TopDialogManager' => 'TopDialogManager', + 'updates_manager[_(-][^.]|UpdatesManager|get_difference[)]|updateSentMessage|dummyUpdate' => 'UpdatesManager', + 'WebPageId(Hash)?' => 'WebPageId', + 'web_pages_manager[_(-][^.]|WebPagesManager' => 'WebPagesManager'); + + foreach ($td_methods as $pattern => $header) { + if (strpos($cpp_name, $header) !== false) { + continue; + } + + $include_name = '#include "td/telegram/'.$header.'.h"'; + if (strpos($new_content, $include_name) !== false && preg_match('/'.$pattern.'/', str_replace($include_name, '', $new_content)) === 0) { + $new_content = str_replace($include_name, '', $new_content); + } + } + } else { + $new_content = preg_replace_callback( + '|#include "[a-z_A-Z/0-9.]*"|', + function ($matches) { + if (strpos($matches[0], "Manager") !== false || strpos($matches[0], "HashtagHints") !== false || strpos($matches[0], "Td.h") !== false) { + return $matches[0]; + } + return ''; + }, + $new_content + ); + } + + if (!file_exists($new_files[$n]) || file_get_contents($new_files[$n]) !== $new_content) { + echo "Writing file ".$new_files[$n].PHP_EOL; + file_put_contents($new_files[$n], $new_content); + } + } +} + +if (in_array('--help', $argv) || in_array('-h', $argv)) { + echo "Usage: php SplitSource.php [OPTION]...\n". + "Splits some source files to reduce a maximum amount of RAM needed for compiling a single file.\n". + " -u, --undo Undo all source code changes.\n". + " -h, --help Show this help.\n"; + exit(2); +} + +$undo = in_array('--undo', $argv) || in_array('-u', $argv); +$files = array('td/telegram/ContactsManager' => 20, + 'td/telegram/MessagesManager' => 50, + 'td/telegram/NotificationManager' => 10, + 'td/telegram/StickersManager' => 10, + 'td/telegram/Td' => 50, + 'td/generate/auto/td/telegram/td_api' => 10, + 'td/generate/auto/td/telegram/td_api_json' => 10, + 'td/generate/auto/td/telegram/telegram_api' => 10); + +foreach ($files as $file => $chunks) { + split_file($file, $chunks, $undo); +} diff --git a/protocols/Telegram/tdlib/td/benchmark/CMakeLists.txt b/protocols/Telegram/tdlib/td/benchmark/CMakeLists.txt index 90f294fbc9..53fbdede52 100644 --- a/protocols/Telegram/tdlib/td/benchmark/CMakeLists.txt +++ b/protocols/Telegram/tdlib/td/benchmark/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) +if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2")) + message(FATAL_ERROR "CMake >= 3.0.2 is required") +endif() if (NOT OPENSSL_FOUND) find_package(OpenSSL REQUIRED) @@ -7,7 +9,14 @@ endif() #TODO: all benchmarks in one file add_executable(bench_crypto bench_crypto.cpp) -target_link_libraries(bench_crypto PRIVATE tdcore tdutils ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES}) +target_link_libraries(bench_crypto PRIVATE tdutils ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES}) +if (WIN32) + if (MINGW) + target_link_libraries(bench_crypto PRIVATE ws2_32 mswsock crypt32) + else() + target_link_libraries(bench_crypto PRIVATE ws2_32 Mswsock Crypt32) + endif() +endif() target_include_directories(bench_crypto SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR}) add_executable(bench_actor bench_actor.cpp) @@ -40,6 +49,12 @@ target_link_libraries(bench_tddb PRIVATE tdcore tddb tdutils) add_executable(bench_misc bench_misc.cpp) target_link_libraries(bench_misc PRIVATE tdcore tdutils) +add_executable(check_proxy check_proxy.cpp) +target_link_libraries(check_proxy PRIVATE tdclient tdutils) + +add_executable(check_tls check_tls.cpp) +target_link_libraries(check_tls PRIVATE tdutils) + add_executable(rmdir rmdir.cpp) target_link_libraries(rmdir PRIVATE tdutils) @@ -57,3 +72,22 @@ if (NOT WIN32 AND NOT CYGWIN) add_executable(bench_queue bench_queue.cpp) target_link_libraries(bench_queue PRIVATE tdutils) endif() + +if (TD_TEST_FOLLY AND TD_WITH_ABSEIL) + find_package(ABSL QUIET) + find_package(folly QUIET) + find_package(gflags QUIET) + + if (ABSL_FOUND AND folly_FOUND) + add_executable(memory-hashset-memprof EXCLUDE_FROM_ALL hashset_memory.cpp) + target_compile_definitions(memory-hashset-memprof PRIVATE USE_MEMPROF=1) + target_link_libraries(memory-hashset-memprof PRIVATE tdutils memprof_stat Folly::folly absl::flat_hash_map absl::hash) + + add_executable(memory-hashset-os hashset_memory.cpp) + target_compile_definitions(memory-hashset-os PRIVATE USE_MEMPROF=0) + target_link_libraries(memory-hashset-os PRIVATE tdutils Folly::folly absl::flat_hash_map absl::hash) + + add_executable(hashmap-build hashmap_build.cpp) + target_link_libraries(hashmap-build PRIVATE tdutils Folly::folly absl::flat_hash_map absl::hash) + endif() +endif() diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp index a966d601cf..afe94ca3c1 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp @@ -1,47 +1,101 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/utils/benchmark.h" - #include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" #include "td/actor/PromiseFuture.h" +#include "td/utils/benchmark.h" +#include "td/utils/common.h" +#include "td/utils/crypto.h" #include "td/utils/logging.h" - -#include +#include "td/utils/Promise.h" +#include "td/utils/SliceBuilder.h" #if TD_MSVC #pragma comment(linker, "/STACK:16777216") #endif +struct TestActor final : public td::Actor { + static td::int32 actor_count_; + + void start_up() final { + actor_count_++; + stop(); + } + + void tear_down() final { + if (--actor_count_ == 0) { + td::Scheduler::instance()->finish(); + } + } +}; + +td::int32 TestActor::actor_count_; + +namespace td { +template <> +class ActorTraits { + public: + static constexpr bool need_context = false; + static constexpr bool need_start_up = true; +}; +} // namespace td + +class CreateActorBench final : public td::Benchmark { + td::ConcurrentScheduler scheduler_{0, 0}; + + void start_up() final { + scheduler_.start(); + } + + void tear_down() final { + scheduler_.finish(); + } + + public: + td::string get_description() const final { + return "CreateActor"; + } + + void run(int n) final { + for (int i = 0; i < n; i++) { + scheduler_.create_actor_unsafe(0, "TestActor").release(); + } + while (scheduler_.run_main(10)) { + // empty + } + } +}; + template -class RingBench : public td::Benchmark { +class RingBench final : public td::Benchmark { public: struct PassActor; private: - int actor_n_; - int thread_n_; - std::vector> actor_array_; - td::ConcurrentScheduler *scheduler_; + int actor_n_ = -1; + int thread_n_ = -1; + td::vector> actor_array_; + td::ConcurrentScheduler *scheduler_ = nullptr; public: - std::string get_description() const override { + td::string get_description() const final { static const char *types[] = {"later", "immediate", "raw", "tail", "lambda"}; static_assert(0 <= type && type < 5, ""); return PSTRING() << "Ring (send_" << types[type] << ") (threads_n = " << thread_n_ << ")"; } - struct PassActor : public td::Actor { - int id; + struct PassActor final : public td::Actor { + int id = -1; td::ActorId next_actor; int start_n = 0; void pass(int n) { - // LOG(INFO) << "pass: " << n; + // LOG(INFO) << "Pass: " << n; if (n == 0) { td::Scheduler::instance()->finish(); } else { @@ -56,24 +110,23 @@ class RingBench : public td::Benchmark { send_closure_later(next_actor, &PassActor::pass, n - 1); } else { // TODO: it is three times faster than send_event - // may be send event could be further optimized? - ::td::Scheduler::instance()->hack(static_cast>(next_actor), - td::Event::raw(static_cast(n - 1))); + // maybe send event could be further optimized? + next_actor.get_actor_unsafe()->raw_event(td::Event::raw(static_cast(n - 1)).data); } } else if (type == 4) { - send_lambda(next_actor, [=, ptr = next_actor.get_actor_unsafe()] { ptr->pass(n - 1); }); + send_lambda(next_actor, [n, ptr = next_actor.get_actor_unsafe()] { ptr->pass(n - 1); }); } } } - void raw_event(const td::Event::Raw &raw) override { + void raw_event(const td::Event::Raw &raw) final { pass(static_cast(raw.u32)); } - void start_up() override { + void start_up() final { yield(); } - void wakeup() override { + void wakeup() final { if (start_n != 0) { int n = start_n; start_n = 0; @@ -85,11 +138,10 @@ class RingBench : public td::Benchmark { RingBench(int actor_n, int thread_n) : actor_n_(actor_n), thread_n_(thread_n) { } - void start_up() override { - scheduler_ = new td::ConcurrentScheduler(); - scheduler_->init(thread_n_); + void start_up() final { + scheduler_ = new td::ConcurrentScheduler(thread_n_, 0); - actor_array_ = std::vector>(actor_n_); + actor_array_ = td::vector>(actor_n_); for (int i = 0; i < actor_n_; i++) { actor_array_[i] = scheduler_->create_actor_unsafe(thread_n_ ? i % thread_n_ : 0, "PassActor").release(); @@ -101,30 +153,30 @@ class RingBench : public td::Benchmark { scheduler_->start(); } - void run(int n) override { + void run(int n) final { // first actor is on main_thread - actor_array_[0].get_actor_unsafe()->start_n = std::max(n, 100); + actor_array_[0].get_actor_unsafe()->start_n = td::max(n, 100); while (scheduler_->run_main(10)) { // empty } } - void tear_down() override { + void tear_down() final { scheduler_->finish(); delete scheduler_; } }; template -class QueryBench : public td::Benchmark { +class QueryBench final : public td::Benchmark { public: - std::string get_description() const override { + td::string get_description() const final { static const char *types[] = {"callback", "immediate future", "delayed future", "dummy", "lambda", "lambda_future"}; static_assert(0 <= type && type < 6, ""); return PSTRING() << "QueryBench: " << types[type]; } - class ClientActor : public td::Actor { + class ClientActor final : public td::Actor { public: class Callback { public: @@ -136,7 +188,7 @@ class QueryBench : public td::Benchmark { virtual ~Callback() = default; virtual void on_result(int x) = 0; }; - explicit ClientActor(std::unique_ptr callback) : callback_(std::move(callback)) { + explicit ClientActor(td::unique_ptr callback) : callback_(std::move(callback)) { } void f(int x) { callback_->on_result(x * x); @@ -152,23 +204,23 @@ class QueryBench : public td::Benchmark { } private: - std::unique_ptr callback_; + td::unique_ptr callback_; }; - class ServerActor : public td::Actor { + class ServerActor final : public td::Actor { public: - class ClientCallback : public ClientActor::Callback { + class ClientCallback final : public ClientActor::Callback { public: explicit ClientCallback(td::ActorId server) : server_(server) { } - void on_result(int x) override { + void on_result(int x) final { send_closure(server_, &ServerActor::on_result, x); } private: td::ActorId server_; }; - void start_up() override { + void start_up() final { client_ = td::create_actor("Client", td::make_unique(actor_id(this))).release(); } @@ -177,7 +229,7 @@ class QueryBench : public td::Benchmark { wakeup(); } - void wakeup() override { + void wakeup() final { while (true) { if (n_ < 0) { td::Scheduler::instance()->finish(); @@ -206,10 +258,12 @@ class QueryBench : public td::Benchmark { } else if (type == 4) { int val = 0; send_lambda(client_, [&] { val = n_ * n_; }); + CHECK(val == n_ * n_); } else if (type == 5) { send_closure(client_, &ClientActor::f_promise, - td::PromiseCreator::lambda( - [id = actor_id(this), n = n_](td::Unit) { send_closure(id, &ServerActor::result, n * n); })); + td::PromiseCreator::lambda([actor_id = actor_id(this), n = n_](td::Unit) { + send_closure(actor_id, &ServerActor::result, n * n); + })); return; } } @@ -220,7 +274,7 @@ class QueryBench : public td::Benchmark { wakeup(); } - void raw_event(const td::Event::Raw &event) override { + void raw_event(const td::Event::Raw &event) final { int val = future_.move_as_ok(); CHECK(val == n_ * n_); wakeup(); @@ -232,22 +286,21 @@ class QueryBench : public td::Benchmark { private: td::ActorId client_; - int n_; + int n_ = 0; td::FutureActor future_; }; - void start_up() override { - scheduler_ = new td::ConcurrentScheduler(); - scheduler_->init(0); + void start_up() final { + scheduler_ = new td::ConcurrentScheduler(0, 0); server_ = scheduler_->create_actor_unsafe(0, "Server"); scheduler_->start(); } - void run(int n) override { + void run(int n) final { // first actor is on main_thread { - auto guard = scheduler_->get_current_guard(); + auto guard = scheduler_->get_main_guard(); send_closure(server_, &ServerActor::run, n); } while (scheduler_->run_main(10)) { @@ -255,19 +308,21 @@ class QueryBench : public td::Benchmark { } } - void tear_down() override { + void tear_down() final { server_.release(); scheduler_->finish(); delete scheduler_; } private: - td::ConcurrentScheduler *scheduler_; + td::ConcurrentScheduler *scheduler_ = nullptr; td::ActorOwn server_; }; int main() { - SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG)); + td::init_openssl_threads(); + + bench(CreateActorBench()); bench(RingBench<4>(504, 0)); bench(RingBench<3>(504, 0)); bench(RingBench<0>(504, 0)); @@ -286,5 +341,4 @@ int main() { bench(RingBench<0>(504, 2)); bench(RingBench<1>(504, 2)); bench(RingBench<2>(504, 2)); - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp index 44d309ef11..40d7602d2e 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp @@ -1,75 +1,374 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/utils/benchmark.h" +#include "td/utils/common.h" #include "td/utils/crypto.h" -#include "td/utils/int_types.h" -#include "td/utils/logging.h" #include "td/utils/port/thread.h" #include "td/utils/Random.h" #include "td/utils/Slice.h" +#include "td/utils/SliceBuilder.h" +#include "td/utils/UInt.h" +#include #include +#include #include #include #include #include +#include #include #include #include static constexpr int DATA_SIZE = 8 << 10; +static constexpr int SHORT_DATA_SIZE = 64; -class SHA1Bench : public td::Benchmark { +#if OPENSSL_VERSION_NUMBER <= 0x10100000L +class SHA1Bench final : public td::Benchmark { public: alignas(64) unsigned char data[DATA_SIZE]; - std::string get_description() const override { + std::string get_description() const final { return PSTRING() << "SHA1 OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; } - void start_up() override { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { unsigned char md[20]; SHA1(data, DATA_SIZE, md); } } }; +#endif + +class SHA1ShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + + std::string get_description() const final { + return PSTRING() << "SHA1 [" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + } + + void run(int n) final { + unsigned char md[20]; + for (int i = 0; i < n; i++) { + td::sha1(td::Slice(data, SHORT_DATA_SIZE), md); + } + } +}; + +class SHA256ShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + + std::string get_description() const final { + return PSTRING() << "SHA256 [" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + } + + void run(int n) final { + unsigned char md[32]; + for (int i = 0; i < n; i++) { + td::sha256(td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 32)); + } + } +}; + +class SHA512ShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + + std::string get_description() const final { + return PSTRING() << "SHA512 [" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + } + + void run(int n) final { + unsigned char md[64]; + for (int i = 0; i < n; i++) { + td::sha512(td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 64)); + } + } +}; -class AESBench : public td::Benchmark { +class HmacSha256ShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + + std::string get_description() const final { + return PSTRING() << "HMAC-SHA256 [" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + } + + void run(int n) final { + unsigned char md[32]; + for (int i = 0; i < n; i++) { + td::hmac_sha256(td::Slice(data, SHORT_DATA_SIZE), td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 32)); + } + } +}; + +class HmacSha512ShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + + std::string get_description() const final { + return PSTRING() << "HMAC-SHA512 [" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + } + + void run(int n) final { + unsigned char md[32]; + for (int i = 0; i < n; i++) { + td::hmac_sha256(td::Slice(data, SHORT_DATA_SIZE), td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 32)); + } + } +}; + +class AesEcbBench final : public td::Benchmark { public: alignas(64) unsigned char data[DATA_SIZE]; td::UInt256 key; td::UInt256 iv; - std::string get_description() const override { - return PSTRING() << "AES OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + std::string get_description() const final { + return PSTRING() << "AES ECB OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(key.raw, sizeof(key)); + td::Random::secure_bytes(iv.raw, sizeof(iv)); } - void start_up() override { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; + void run(int n) final { + td::AesState state; + state.init(td::as_slice(key), true); + td::MutableSlice data_slice(data, DATA_SIZE); + for (int i = 0; i <= n; i++) { + size_t step = 16; + for (size_t offset = 0; offset + step <= data_slice.size(); offset += step) { + state.encrypt(data_slice.ubegin() + offset, data_slice.ubegin() + offset, static_cast(step)); + } } + } +}; + +class AesIgeEncryptBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt256 iv; + + std::string get_description() const final { + return PSTRING() << "AES IGE OpenSSL encrypt [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } - void run(int n) override { + void run(int n) final { td::MutableSlice data_slice(data, DATA_SIZE); + td::AesIgeState state; + state.init(as_slice(key), as_slice(iv), true); for (int i = 0; i < n; i++) { - td::aes_ige_encrypt(key, &iv, data_slice, data_slice); + state.encrypt(data_slice, data_slice); + } + } +}; + +class AesIgeDecryptBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt256 iv; + + std::string get_description() const final { + return PSTRING() << "AES IGE OpenSSL decrypt [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(key.raw, sizeof(key)); + td::Random::secure_bytes(iv.raw, sizeof(iv)); + } + + void run(int n) final { + td::MutableSlice data_slice(data, DATA_SIZE); + td::AesIgeState state; + state.init(as_slice(key), as_slice(iv), false); + for (int i = 0; i < n; i++) { + state.decrypt(data_slice, data_slice); + } + } +}; + +class AesCtrBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt128 iv; + + std::string get_description() const final { + return PSTRING() << "AES CTR OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(key.raw, sizeof(key)); + td::Random::secure_bytes(iv.raw, sizeof(iv)); + } + + void run(int n) final { + td::MutableSlice data_slice(data, DATA_SIZE); + td::AesCtrState state; + state.init(as_slice(key), as_slice(iv)); + for (int i = 0; i < n; i++) { + state.encrypt(data_slice, data_slice); + } + } +}; + +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +class AesCtrOpenSSLBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt128 iv; + + std::string get_description() const final { + return PSTRING() << "AES CTR RAW OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(key.raw, sizeof(key)); + td::Random::secure_bytes(iv.raw, sizeof(iv)); + } + + void run(int n) final { + EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); + EVP_EncryptInit_ex(ctx, EVP_aes_256_ctr(), nullptr, key.raw, iv.raw); + + td::MutableSlice data_slice(data, DATA_SIZE); + td::AesCtrState state; + state.init(as_slice(key), as_slice(iv)); + for (int i = 0; i < n; i++) { + int len = 0; + EVP_EncryptUpdate(ctx, data_slice.ubegin(), &len, data_slice.ubegin(), DATA_SIZE); + CHECK(len == DATA_SIZE); + } + + EVP_CIPHER_CTX_free(ctx); + } +}; +#endif + +class AesCbcDecryptBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt128 iv; + + std::string get_description() const final { + return PSTRING() << "AES CBC Decrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(as_slice(key)); + td::Random::secure_bytes(as_slice(iv)); + } + + void run(int n) final { + td::MutableSlice data_slice(data, DATA_SIZE); + for (int i = 0; i < n; i++) { + td::aes_cbc_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice); + } + } +}; + +class AesCbcEncryptBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt128 iv; + + std::string get_description() const final { + return PSTRING() << "AES CBC Encrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(as_slice(key)); + td::Random::secure_bytes(as_slice(iv)); + } + + void run(int n) final { + td::MutableSlice data_slice(data, DATA_SIZE); + for (int i = 0; i < n; i++) { + td::aes_cbc_encrypt(as_slice(key), as_slice(iv), data_slice, data_slice); + } + } +}; + +template +class AesIgeShortBench final : public td::Benchmark { + public: + alignas(64) unsigned char data[SHORT_DATA_SIZE]; + td::UInt256 key; + td::UInt256 iv; + + std::string get_description() const final { + return PSTRING() << "AES IGE OpenSSL " << (use_state ? "EVP" : "C ") << "[" << SHORT_DATA_SIZE << "B]"; + } + + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); + td::Random::secure_bytes(as_slice(key)); + td::Random::secure_bytes(as_slice(iv)); + } + + void run(int n) final { + td::MutableSlice data_slice(data, SHORT_DATA_SIZE); + for (int i = 0; i < n; i++) { + if (use_state) { + td::AesIgeState ige; + ige.init(as_slice(key), as_slice(iv), false); + ige.decrypt(data_slice, data_slice); + } else { + td::aes_ige_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice); + } } } }; @@ -110,15 +409,15 @@ BENCH(TdRandFast, "td_rand_fast") { #if !TD_THREAD_UNSUPPORTED BENCH(SslRand, "ssl_rand_int32") { std::vector v; - std::atomic sum; + std::atomic sum{0}; for (int i = 0; i < 3; i++) { - v.push_back(td::thread([&] { + v.emplace_back([&sum, n] { td::int32 res = 0; for (int j = 0; j < n; j++) { res ^= td::Random::secure_int32(); } sum += res; - })); + }); } for (auto &x : v) { x.join(); @@ -147,22 +446,19 @@ BENCH(Pbkdf2, "pbkdf2") { td::pbkdf2_sha256(password, salt, n, key); } -class Crc32Bench : public td::Benchmark { +class Crc32Bench final : public td::Benchmark { public: alignas(64) unsigned char data[DATA_SIZE]; - std::string get_description() const override { + std::string get_description() const final { return PSTRING() << "Crc32 zlib [" << (DATA_SIZE >> 10) << "KB]"; } - void start_up() override { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); } - void run(int n) override { + void run(int n) final { td::uint64 res = 0; for (int i = 0; i < n; i++) { res += td::crc32(td::Slice(data, DATA_SIZE)); @@ -171,22 +467,19 @@ class Crc32Bench : public td::Benchmark { } }; -class Crc64Bench : public td::Benchmark { +class Crc64Bench final : public td::Benchmark { public: alignas(64) unsigned char data[DATA_SIZE]; - std::string get_description() const override { + std::string get_description() const final { return PSTRING() << "Crc64 Anton [" << (DATA_SIZE >> 10) << "KB]"; } - void start_up() override { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + void start_up() final { + std::fill(std::begin(data), std::end(data), static_cast(123)); } - void run(int n) override { + void run(int n) final { td::uint64 res = 0; for (int i = 0; i < n; i++) { res += td::crc64(td::Slice(data, DATA_SIZE)); @@ -196,6 +489,20 @@ class Crc64Bench : public td::Benchmark { }; int main() { + td::init_openssl_threads(); + td::bench(AesCtrBench()); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + td::bench(AesCtrOpenSSLBench()); +#endif + + td::bench(AesCbcDecryptBench()); + td::bench(AesCbcEncryptBench()); + td::bench(AesIgeShortBench()); + td::bench(AesIgeShortBench()); + td::bench(AesIgeEncryptBench()); + td::bench(AesIgeDecryptBench()); + td::bench(AesEcbBench()); + td::bench(Pbkdf2Bench()); td::bench(RandBench()); td::bench(CppRandBench()); @@ -205,9 +512,14 @@ int main() { td::bench(SslRandBench()); #endif td::bench(SslRandBufBench()); +#if OPENSSL_VERSION_NUMBER <= 0x10100000L td::bench(SHA1Bench()); - td::bench(AESBench()); +#endif + td::bench(SHA1ShortBench()); + td::bench(SHA256ShortBench()); + td::bench(SHA512ShortBench()); + td::bench(HmacSha256ShortBench()); + td::bench(HmacSha512ShortBench()); td::bench(Crc32Bench()); td::bench(Crc64Bench()); - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp index dc768e9d9d..822a915938 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp @@ -1,28 +1,35 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/actor/actor.h" - #include "td/db/binlog/Binlog.h" +#include "td/db/binlog/ConcurrentBinlog.h" #include "td/db/BinlogKeyValue.h" +#include "td/db/DbKey.h" #include "td/db/SeqKeyValue.h" +#include "td/db/SqliteConnectionSafe.h" #include "td/db/SqliteDb.h" #include "td/db/SqliteKeyValueAsync.h" +#include "td/db/SqliteKeyValueSafe.h" + +#include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" #include "td/utils/benchmark.h" +#include "td/utils/common.h" #include "td/utils/format.h" #include "td/utils/logging.h" +#include "td/utils/SliceBuilder.h" #include "td/utils/Status.h" #include "td/utils/StringBuilder.h" #include template -class TdKvBench : public td::Benchmark { - td::ConcurrentScheduler sched; +class TdKvBench final : public td::Benchmark { + td::ConcurrentScheduler sched{1, 0}; td::string name_; public: @@ -30,27 +37,27 @@ class TdKvBench : public td::Benchmark { name_ = std::move(name); } - td::string get_description() const override { + td::string get_description() const final { return name_; } - class Main : public td::Actor { + class Main final : public td::Actor { public: explicit Main(int n) : n_(n) { } private: - void loop() override { + void loop() final { KeyValueT::destroy("test_tddb").ignore(); - class Worker : public Actor { + class Worker final : public Actor { public: Worker(int n, td::string db_name) : n_(n) { kv_.init(db_name).ensure(); } private: - void loop() override { + void loop() final { for (int i = 0; i < n_; i++) { kv_.set(td::to_string(i % 10), td::to_string(i)); } @@ -64,12 +71,11 @@ class TdKvBench : public td::Benchmark { int n_; }; - void start_up_n(int n) override { - sched.init(1); + void start_up_n(int n) final { sched.create_actor_unsafe
(1, "Main", n).release(); } - void run(int n) override { + void run(int n) final { sched.start(); while (sched.run_main(10)) { // empty @@ -77,24 +83,23 @@ class TdKvBench : public td::Benchmark { sched.finish(); } - void tear_down() override { + void tear_down() final { } }; template -class SqliteKVBench : public td::Benchmark { +class SqliteKVBench final : public td::Benchmark { td::SqliteDb db; - td::string get_description() const override { + td::string get_description() const final { return PSTRING() << "SqliteKV " << td::tag("is_encrypted", is_encrypted); } - void start_up() override { + void start_up() final { td::string path = "testdb.sqlite"; td::SqliteDb::destroy(path).ignore(); if (is_encrypted) { - td::SqliteDb::change_key(path, td::DbKey::password("cucumber"), td::DbKey::empty()); - db = td::SqliteDb::open_with_key(path, td::DbKey::password("cucumber")).move_as_ok(); + db = td::SqliteDb::change_key(path, true, td::DbKey::password("cucumber"), td::DbKey::empty()).move_as_ok(); } else { - db = td::SqliteDb::open_with_key(path, td::DbKey::empty()).move_as_ok(); + db = td::SqliteDb::open_with_key(path, true, td::DbKey::empty()).move_as_ok(); } db.exec("PRAGMA encoding=\"UTF-8\"").ensure(); db.exec("PRAGMA synchronous=NORMAL").ensure(); @@ -103,7 +108,7 @@ class SqliteKVBench : public td::Benchmark { db.exec("DROP TABLE IF EXISTS KV").ensure(); db.exec("CREATE TABLE IF NOT EXISTS KV (k BLOB PRIMARY KEY, v BLOB)").ensure(); } - void run(int n) override { + void run(int n) final { auto stmt = db.get_statement("REPLACE INTO KV (k, v) VALUES(?1, ?2)").move_as_ok(); db.exec("BEGIN TRANSACTION").ensure(); for (int i = 0; i < n; i++) { @@ -135,17 +140,17 @@ static td::Status init_db(td::SqliteDb &db) { return td::Status::OK(); } -class SqliteKeyValueAsyncBench : public td::Benchmark { +class SqliteKeyValueAsyncBench final : public td::Benchmark { public: - td::string get_description() const override { + td::string get_description() const final { return "SqliteKeyValueAsync"; } - void start_up() override { + void start_up() final { do_start_up().ensure(); scheduler_->start(); } - void run(int n) override { - auto guard = scheduler_->get_current_guard(); + void run(int n) final { + auto guard = scheduler_->get_main_guard(); for (int i = 0; i < n; i++) { auto key = td::to_string(i % 10); @@ -153,10 +158,10 @@ class SqliteKeyValueAsyncBench : public td::Benchmark { sqlite_kv_async_->set(key, value, td::Auto()); } } - void tear_down() override { + void tear_down() final { scheduler_->run_main(0.1); { - auto guard = scheduler_->get_current_guard(); + auto guard = scheduler_->get_main_guard(); sqlite_kv_async_.reset(); sqlite_kv_safe_.reset(); sql_connection_->close_and_destroy(); @@ -167,21 +172,20 @@ class SqliteKeyValueAsyncBench : public td::Benchmark { } private: - std::unique_ptr scheduler_; + td::unique_ptr scheduler_; std::shared_ptr sql_connection_; std::shared_ptr sqlite_kv_safe_; - std::unique_ptr sqlite_kv_async_; + td::unique_ptr sqlite_kv_async_; td::Status do_start_up() { - scheduler_ = std::make_unique(); - scheduler_->init(1); + scheduler_ = td::make_unique(1, 0); - auto guard = scheduler_->get_current_guard(); + auto guard = scheduler_->get_main_guard(); td::string sql_db_name = "testdb.sqlite"; td::SqliteDb::destroy(sql_db_name).ignore(); - sql_connection_ = std::make_shared(sql_db_name); + sql_connection_ = std::make_shared(sql_db_name, td::DbKey::empty()); auto &db = sql_connection_->get(); TRY_STATUS(init_db(db)); @@ -192,31 +196,31 @@ class SqliteKeyValueAsyncBench : public td::Benchmark { } }; -class SeqKvBench : public td::Benchmark { - td::string get_description() const override { +class SeqKvBench final : public td::Benchmark { + td::string get_description() const final { return "SeqKvBench"; } td::SeqKeyValue kv; - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { - kv.set(td::to_string(i % 10), td::to_string(i)); + kv.set(PSLICE() << i % 10, PSLICE() << i); } } }; template -class BinlogKeyValueBench : public td::Benchmark { - td::string get_description() const override { +class BinlogKeyValueBench final : public td::Benchmark { + td::string get_description() const final { return PSTRING() << "BinlogKeyValue " << td::tag("is_encrypted", is_encrypted); } td::BinlogKeyValue kv; - void start_up() override { + void start_up() final { td::SqliteDb::destroy("test_binlog").ignore(); kv.init("test_binlog", is_encrypted ? td::DbKey::password("cucumber") : td::DbKey::empty()).ensure(); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { kv.set(td::to_string(i % 10), td::to_string(i)); } @@ -233,5 +237,4 @@ int main() { bench(TdKvBench>("BinlogKeyValue")); bench(TdKvBench>("BinlogKeyValue")); bench(SeqKvBench()); - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp index f6718152b4..ae2068c050 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp @@ -1,9 +1,8 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // int main() { - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp index 08d04f009c..f518fe03b0 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp @@ -1,15 +1,15 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/utils/benchmark.h" // for bench, do_not_optimize_away, etc - -#include "td/mtproto/crypto.h" +#include "td/mtproto/DhCallback.h" +#include "td/mtproto/DhHandshake.h" #include "td/utils/base64.h" -#include "td/utils/logging.h" +#include "td/utils/benchmark.h" +#include "td/utils/common.h" #include "td/utils/Slice.h" #include @@ -18,59 +18,55 @@ #include #endif -namespace td { - -static int32 g = 3; -static string prime_base64 = +static td::int32 g = 3; +static td::string prime_base64 = "xxyuucaxyQSObFIvcPE_c5gNQCOOPiHBSTTQN1Y9kw9IGYoKp8FAWCKUk9IlMPTb-jNvbgrJJROVQ67UTM58NyD9UfaUWHBaxozU_mtrE6vcl0ZRKW" "kyhFTxj6-MWV9kJHf-lrsqlB1bzR1KyMxJiAcI-ps3jjxPOpBgvuZ8-aSkppWBEFGQfhYnU7VrD2tBDbp02KhLKhSzFE4O8ShHVP0X7ZUNWWW0ud1G" "WC2xF40WnGvEZbDW_5yjko_vW5rk5Bj8Feg-vqD4f6n_Xu1wBQ3tKEn0e_lZ2VaFDOkphR8NgRX2NbEF7i5OFdBLJFS_b0-t8DSxBAMRnNjjuS_MW" "w"; -class HandshakeBench : public Benchmark { - std::string get_description() const override { +class HandshakeBench final : public td::Benchmark { + td::string get_description() const final { return "Handshake"; } - class FakeDhCallback : public DhCallback { + class FakeDhCallback final : public td::mtproto::DhCallback { public: - int is_good_prime(Slice prime_str) const override { + int is_good_prime(td::Slice prime_str) const final { auto it = cache.find(prime_str.str()); if (it == cache.end()) { return -1; } return it->second; } - void add_good_prime(Slice prime_str) const override { + void add_good_prime(td::Slice prime_str) const final { cache[prime_str.str()] = 1; } - void add_bad_prime(Slice prime_str) const override { + void add_bad_prime(td::Slice prime_str) const final { cache[prime_str.str()] = 0; } - mutable std::map cache; + mutable std::map cache; } dh_callback; - void run(int n) override { - DhHandshake a; - DhHandshake b; - auto prime = base64url_decode(prime_base64).move_as_ok(); + void run(int n) final { + td::mtproto::DhHandshake a; + td::mtproto::DhHandshake b; + auto prime = td::base64url_decode(prime_base64).move_as_ok(); + td::mtproto::DhHandshake::check_config(g, prime, &dh_callback).ensure(); for (int i = 0; i < n; i += 2) { a.set_config(g, prime); b.set_config(g, prime); b.set_g_a(a.get_g_b()); a.set_g_a(b.get_g_b()); - a.run_checks(&dh_callback).ensure(); - b.run_checks(&dh_callback).ensure(); + a.run_checks(true, &dh_callback).ensure(); + b.run_checks(true, &dh_callback).ensure(); auto a_key = a.gen_key(); auto b_key = b.gen_key(); CHECK(a_key.first == b_key.first); } } }; -} // namespace td int main() { - SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG)); - td::bench(td::HandshakeBench()); - return 0; + td::bench(HandshakeBench()); } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp index 6958a5b313..70fdb909c2 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp @@ -1,15 +1,18 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/actor/actor.h" - #include "td/net/HttpOutboundConnection.h" #include "td/net/HttpQuery.h" +#include "td/net/SslStream.h" + +#include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" #include "td/utils/buffer.h" +#include "td/utils/BufferedFd.h" #include "td/utils/logging.h" #include "td/utils/port/IPAddress.h" #include "td/utils/port/SocketFd.h" @@ -18,50 +21,52 @@ #include #include -namespace td { - std::atomic counter; -class HttpClient : public HttpOutboundConnection::Callback { - void start_up() override { - IPAddress addr; + +class HttpClient final : public td::HttpOutboundConnection::Callback { + void start_up() final { + td::IPAddress addr; addr.init_ipv4_port("127.0.0.1", 8082).ensure(); - auto fd = SocketFd::open(addr); - CHECK(fd.is_ok()) << fd.error(); - connection_ = - create_actor("Connect", fd.move_as_ok(), std::numeric_limits::max(), 0, 0, - ActorOwn(actor_id(this))); + auto fd = td::SocketFd::open(addr); + LOG_CHECK(fd.is_ok()) << fd.error(); + connection_ = td::create_actor( + "Connect", td::BufferedFd(fd.move_as_ok()), td::SslStream{}, std::numeric_limits::max(), + 0, 0, td::ActorOwn(actor_id(this))); yield(); cnt_ = 100000; counter++; } - void tear_down() override { + + void tear_down() final { if (--counter == 0) { - Scheduler::instance()->finish(); + td::Scheduler::instance()->finish(); } } - void loop() override { + + void loop() final { if (cnt_-- < 0) { return stop(); } - send_closure(connection_, &HttpOutboundConnection::write_next, BufferSlice("GET / HTTP/1.1\r\n\r\n")); - send_closure(connection_, &HttpOutboundConnection::write_ok); + send_closure(connection_, &td::HttpOutboundConnection::write_next, td::BufferSlice("GET / HTTP/1.1\r\n\r\n")); + send_closure(connection_, &td::HttpOutboundConnection::write_ok); LOG(INFO) << "SEND"; } - void handle(HttpQueryPtr result) override { + + void handle(td::unique_ptr result) final { loop(); } - void on_connection_error(Status error) override { + + void on_connection_error(td::Status error) final { LOG(ERROR) << "ERROR: " << error; } - ActorOwn connection_; - int cnt_; + td::ActorOwn connection_; + int cnt_ = 0; }; int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR)); - auto scheduler = make_unique(); - scheduler->init(0); + auto scheduler = td::make_unique(0, 0); scheduler->create_actor_unsafe(0, "Client1").release(); scheduler->create_actor_unsafe(0, "Client2").release(); scheduler->start(); @@ -69,10 +74,4 @@ int main() { // empty } scheduler->finish(); - return 0; -} -} // namespace td - -int main() { - return td::main(); } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp index 2afe2d73ff..403af06bec 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp @@ -1,5 +1,5 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,19 +9,20 @@ #include "td/utils/benchmark.h" #include "td/utils/buffer.h" +#include "td/utils/common.h" #include "td/utils/find_boundary.h" #include "td/utils/logging.h" static std::string http_query = "GET / HTTP/1.1\r\nConnection:keep-alive\r\nhost:127.0.0.1:8080\r\n\r\n"; static const size_t block_size = 2500; -class HttpReaderBench : public td::Benchmark { - std::string get_description() const override { +class HttpReaderBench final : public td::Benchmark { + std::string get_description() const final { return "HttpReaderBench"; } - void run(int n) override { - int cnt = static_cast(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast(block_size / http_query.size()); td::HttpQuery q; int parsed = 0; int sent = 0; @@ -45,27 +46,26 @@ class HttpReaderBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); http_reader_.init(&reader_, 10000, 0); } }; -class BufferBench : public td::Benchmark { - std::string get_description() const override { +class BufferBench final : public td::Benchmark { + std::string get_description() const final { return "BufferBench"; } - void run(int n) override { - int cnt = static_cast(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast(block_size / http_query.size()); for (int i = 0; i < n; i += cnt) { for (int j = 0; j < cnt; j++) { writer_.append(http_query); } reader_.sync_with_writer(); for (int j = 0; j < cnt; j++) { - reader_.cut_head(http_query.size()); + auto result = reader_.cut_head(http_query.size()); } } } @@ -73,19 +73,18 @@ class BufferBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); } }; -class FindBoundaryBench : public td::Benchmark { - std::string get_description() const override { +class FindBoundaryBench final : public td::Benchmark { + std::string get_description() const final { return "FindBoundaryBench"; } - void run(int n) override { - int cnt = static_cast(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast(block_size / http_query.size()); for (int i = 0; i < n; i += cnt) { for (int j = 0; j < cnt; j++) { writer_.append(http_query); @@ -95,7 +94,7 @@ class FindBoundaryBench : public td::Benchmark { size_t len = 0; find_boundary(reader_.clone(), "\r\n\r\n", len); CHECK(size_t(len) + 4 == http_query.size()); - reader_.cut_head(len + 2); + auto result = reader_.cut_head(len + 2); reader_.advance(2); } } @@ -104,8 +103,7 @@ class FindBoundaryBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); } }; diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp index c48e8b4a67..33cde9ef8c 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp @@ -1,31 +1,32 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/actor/actor.h" - #include "td/net/HttpHeaderCreator.h" #include "td/net/HttpInboundConnection.h" #include "td/net/HttpQuery.h" #include "td/net/TcpListener.h" +#include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" + #include "td/utils/buffer.h" +#include "td/utils/BufferedFd.h" #include "td/utils/logging.h" #include "td/utils/port/SocketFd.h" #include "td/utils/Slice.h" -namespace td { - static int cnt = 0; -class HelloWorld : public HttpInboundConnection::Callback { + +class HelloWorld final : public td::HttpInboundConnection::Callback { public: - void handle(HttpQueryPtr query, ActorOwn connection) override { + void handle(td::unique_ptr query, td::ActorOwn connection) final { // LOG(ERROR) << *query; - HttpHeaderCreator hc; - Slice content = "hello world"; - //auto content = BufferSlice("hello world"); + td::HttpHeaderCreator hc; + td::Slice content = "hello world"; + //auto content = td::BufferSlice("hello world"); hc.init_ok(); hc.set_keep_alive(); hc.set_content_size(content.size()); @@ -35,55 +36,49 @@ class HelloWorld : public HttpInboundConnection::Callback { auto res = hc.finish(content); LOG_IF(FATAL, res.is_error()) << res.error(); - send_closure(connection, &HttpInboundConnection::write_next, BufferSlice(res.ok())); - send_closure(connection.release(), &HttpInboundConnection::write_ok); + send_closure(connection, &td::HttpInboundConnection::write_next, td::BufferSlice(res.ok())); + send_closure(connection.release(), &td::HttpInboundConnection::write_ok); } - void hangup() override { + void hangup() final { LOG(ERROR) << "CLOSE " << cnt--; stop(); } }; const int N = 0; -class Server : public TcpListener::Callback { +class Server final : public td::TcpListener::Callback { public: - void start_up() override { - listener_ = create_actor("Listener", 8082, ActorOwn(actor_id(this))); + void start_up() final { + listener_ = + td::create_actor("Listener", 8082, td::ActorOwn(actor_id(this))); } - void accept(SocketFd fd) override { + void accept(td::SocketFd fd) final { LOG(ERROR) << "ACCEPT " << cnt++; pos_++; auto scheduler_id = pos_ % (N != 0 ? N : 1) + (N != 0); - create_actor_on_scheduler("HttpInboundConnection", scheduler_id, std::move(fd), 1024 * 1024, - 0, 0, - create_actor_on_scheduler("HelloWorld", scheduler_id)) + td::create_actor_on_scheduler( + "HttpInboundConnection", scheduler_id, td::BufferedFd(std::move(fd)), 1024 * 1024, 0, 0, + td::create_actor_on_scheduler("HelloWorld", scheduler_id)) .release(); } - void hangup() override { + void hangup() final { // may be it should be default?.. - LOG(ERROR) << "hangup.."; + LOG(ERROR) << "Hanging up.."; stop(); } private: - ActorOwn listener_; + td::ActorOwn listener_; int pos_{0}; }; int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR)); - auto scheduler = make_unique(); - scheduler->init(N); + auto scheduler = td::make_unique(N, 0); scheduler->create_actor_unsafe(0, "Server").release(); scheduler->start(); while (scheduler->run_main(10)) { // empty } scheduler->finish(); - return 0; -} -} // namespace td - -int main() { - return td::main(); } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp index da6fbbd713..8bbd768b40 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp @@ -1,49 +1,46 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/actor/actor.h" - #include "td/net/HttpHeaderCreator.h" -#include "td/net/HttpInboundConnection.h" #include "td/net/TcpListener.h" +#include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" + #include "td/utils/buffer.h" #include "td/utils/logging.h" -#include "td/utils/port/Fd.h" +#include "td/utils/port/detail/PollableFd.h" #include "td/utils/port/SocketFd.h" #include "td/utils/Slice.h" #include "td/utils/Status.h" #include -namespace td { - -// HttpInboundConnection header static int cnt = 0; -class HelloWorld : public Actor { + +class HelloWorld final : public td::Actor { public: - explicit HelloWorld(SocketFd socket_fd) : socket_fd_(std::move(socket_fd)) { + explicit HelloWorld(td::SocketFd socket_fd) : socket_fd_(std::move(socket_fd)) { } private: - SocketFd socket_fd_; + td::SocketFd socket_fd_; std::array read_buf; size_t read_new_lines{0}; - std::string hello_; - std::string write_buf_; + td::string hello_; + td::string write_buf_; size_t write_pos_{0}; - void start_up() override { - socket_fd_.get_fd().set_observer(this); - subscribe(socket_fd_.get_fd()); - HttpHeaderCreator hc; - Slice content = "hello world"; - //auto content = BufferSlice("hello world"); + void start_up() final { + td::Scheduler::subscribe(socket_fd_.get_poll_info().extract_pollable_fd(this)); + td::HttpHeaderCreator hc; + td::Slice content = "hello world"; + //auto content = td::BufferSlice("hello world"); hc.init_ok(); hc.set_keep_alive(); hc.set_content_size(content.size()); @@ -53,36 +50,37 @@ class HelloWorld : public Actor { hello_ = hc.finish(content).ok().str(); } - void loop() override { + void loop() final { auto status = do_loop(); if (status.is_error()) { - unsubscribe(socket_fd_.get_fd()); + td::Scheduler::unsubscribe(socket_fd_.get_poll_info().get_pollable_fd_ref()); stop(); LOG(ERROR) << "CLOSE: " << status; } } - Status do_loop() { + td::Status do_loop() { + sync_with_poll(socket_fd_); TRY_STATUS(read_loop()); TRY_STATUS(write_loop()); - if (can_close(socket_fd_)) { - return Status::Error("CLOSE"); + if (can_close_local(socket_fd_)) { + return td::Status::Error("CLOSE"); } - return Status::OK(); + return td::Status::OK(); } - Status write_loop() { - while (can_write(socket_fd_) && write_pos_ < write_buf_.size()) { - TRY_RESULT(written, socket_fd_.write(Slice(write_buf_).substr(write_pos_))); + td::Status write_loop() { + while (can_write_local(socket_fd_) && write_pos_ < write_buf_.size()) { + TRY_RESULT(written, socket_fd_.write(td::Slice(write_buf_).substr(write_pos_))); write_pos_ += written; if (write_pos_ == write_buf_.size()) { write_pos_ = 0; write_buf_.clear(); } } - return Status::OK(); + return td::Status::OK(); } - Status read_loop() { - while (can_read(socket_fd_)) { - TRY_RESULT(read_size, socket_fd_.read(MutableSlice(read_buf.data(), read_buf.size()))); + td::Status read_loop() { + while (can_read_local(socket_fd_)) { + TRY_RESULT(read_size, socket_fd_.read(td::MutableSlice(read_buf.data(), read_buf.size()))); for (size_t i = 0; i < read_size; i++) { if (read_buf[i] == '\n') { read_new_lines++; @@ -93,46 +91,41 @@ class HelloWorld : public Actor { } } } - return Status::OK(); + return td::Status::OK(); } }; + const int N = 0; -class Server : public TcpListener::Callback { +class Server final : public td::TcpListener::Callback { public: - void start_up() override { - listener_ = create_actor("Listener", 8082, ActorOwn(actor_id(this))); + void start_up() final { + listener_ = + td::create_actor("Listener", 8082, td::ActorOwn(actor_id(this))); } - void accept(SocketFd fd) override { + void accept(td::SocketFd fd) final { LOG(ERROR) << "ACCEPT " << cnt++; pos_++; auto scheduler_id = pos_ % (N != 0 ? N : 1) + (N != 0); - create_actor_on_scheduler("HttpInboundConnection", scheduler_id, std::move(fd)).release(); + td::create_actor_on_scheduler("HelloWorld", scheduler_id, std::move(fd)).release(); } - void hangup() override { + void hangup() final { // may be it should be default?.. - LOG(ERROR) << "hangup.."; + LOG(ERROR) << "Hanging up.."; stop(); } private: - ActorOwn listener_; + td::ActorOwn listener_; int pos_{0}; }; int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR)); - auto scheduler = make_unique(); - scheduler->init(N); + auto scheduler = td::make_unique(N, 0); scheduler->create_actor_unsafe(0, "Server").release(); scheduler->start(); while (scheduler->run_main(10)) { // empty } scheduler->finish(); - return 0; -} -} // namespace td - -int main() { - return td::main(); } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp index fbda47590b..4b140422f1 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp @@ -1,46 +1,48 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "td/actor/actor.h" - #include "td/net/HttpHeaderCreator.h" #include "td/net/HttpQuery.h" #include "td/net/HttpReader.h" #include "td/net/TcpListener.h" +#include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" + #include "td/utils/buffer.h" #include "td/utils/BufferedFd.h" #include "td/utils/logging.h" -#include "td/utils/port/Fd.h" +#include "td/utils/port/detail/PollableFd.h" #include "td/utils/port/SocketFd.h" #include "td/utils/Slice.h" #include "td/utils/Status.h" -namespace td { - -class HttpEchoConnection : public Actor { +class HttpEchoConnection final : public td::Actor { public: - explicit HttpEchoConnection(SocketFd fd) : fd_(std::move(fd)) { + explicit HttpEchoConnection(td::SocketFd fd) : fd_(std::move(fd)) { } private: - BufferedFd fd_; - HttpReader reader_; - HttpQuery query_; - void start_up() override { - fd_.get_fd().set_observer(this); - subscribe(fd_.get_fd()); + td::BufferedFd fd_; + td::HttpReader reader_; + td::HttpQuery query_; + void start_up() final { + td::Scheduler::subscribe(fd_.get_poll_info().extract_pollable_fd(this)); reader_.init(&fd_.input_buffer(), 1024 * 1024, 0); } + void tear_down() final { + td::Scheduler::unsubscribe_before_close(fd_.get_poll_info().get_pollable_fd_ref()); + fd_.close(); + } void handle_query() { - query_ = HttpQuery(); - HttpHeaderCreator hc; - Slice content = "hello world"; - //auto content = BufferSlice("hello world"); + query_ = td::HttpQuery(); + td::HttpHeaderCreator hc; + td::Slice content = "hello world"; + //auto content = td::BufferSlice("hello world"); hc.init_ok(); hc.set_keep_alive(); hc.set_content_size(content.size()); @@ -51,20 +53,19 @@ class HttpEchoConnection : public Actor { fd_.output_buffer().append(res.ok()); } - void loop() override { + void loop() final { + sync_with_poll(fd_); auto status = [&] { TRY_STATUS(loop_read()); TRY_STATUS(loop_write()); - return Status::OK(); + return td::Status::OK(); }(); - if (status.is_error() || can_close(fd_)) { + if (status.is_error() || can_close_local(fd_)) { stop(); } } - Status loop_read() { - if (can_read(fd_)) { - TRY_STATUS(fd_.flush_read()); - } + td::Status loop_read() { + TRY_STATUS(fd_.flush_read()); while (true) { TRY_RESULT(need, reader_.read_next(&query_)); if (need == 0) { @@ -73,49 +74,43 @@ class HttpEchoConnection : public Actor { break; } } - return Status::OK(); + return td::Status::OK(); } - Status loop_write() { + td::Status loop_write() { TRY_STATUS(fd_.flush_write()); - return Status::OK(); + return td::Status::OK(); } }; -const int N = 4; -class Server : public TcpListener::Callback { +const int N = 8; +class Server final : public td::TcpListener::Callback { public: - void start_up() override { - listener_ = create_actor("Listener", 8082, ActorOwn(actor_id(this))); + void start_up() final { + listener_ = + td::create_actor("Listener", 8082, td::ActorOwn(actor_id(this))); } - void accept(SocketFd fd) override { + void accept(td::SocketFd fd) final { pos_++; auto scheduler_id = pos_ % (N != 0 ? N : 1) + (N != 0); - create_actor_on_scheduler("HttpInboundConnection", scheduler_id, std::move(fd)).release(); + td::create_actor_on_scheduler("HttpEchoConnection", scheduler_id, std::move(fd)).release(); } - void hangup() override { - LOG(ERROR) << "hangup.."; + void hangup() final { + LOG(ERROR) << "Hanging up.."; stop(); } private: - ActorOwn listener_; + td::ActorOwn listener_; int pos_{0}; }; int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR)); - auto scheduler = make_unique(); - scheduler->init(N); + auto scheduler = td::make_unique(N, 0); scheduler->create_actor_unsafe(0, "Server").release(); scheduler->start(); while (scheduler->run_main(10)) { // empty } scheduler->finish(); - return 0; -} -} // namespace td - -int main() { - return td::main(); } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp index a57b1b9b42..8c2628b8a9 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp @@ -1,16 +1,16 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/utils/benchmark.h" +#include "td/utils/common.h" #include "td/utils/logging.h" #include #include #include -#include #include #include #include @@ -35,63 +35,63 @@ std::string create_tmp_file() { #endif } -class IostreamWriteBench : public td::Benchmark { +class IostreamWriteBench final : public td::Benchmark { protected: std::string file_name_; std::ofstream stream; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: - std::string get_description() const override { + std::string get_description() const final { return "ostream (to file, no buf, no flush)"; } - void start_up() override { + void start_up() final { file_name_ = create_tmp_file(); stream.open(file_name_.c_str()); CHECK(stream.is_open()); - // stream.rdbuf()->pubsetbuf(buffer, buffer_size); + // stream.rdbuf()->pubsetbuf(buffer, BUFFER_SIZE); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { stream << "This is just for test" << 987654321 << '\n'; } } - void tear_down() override { + void tear_down() final { stream.close(); unlink(file_name_.c_str()); } }; -class FILEWriteBench : public td::Benchmark { +class FILEWriteBench final : public td::Benchmark { protected: std::string file_name_; FILE *file; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: - std::string get_description() const override { + std::string get_description() const final { return "std::fprintf (to file, no buf, no flush)"; } - void start_up() override { + void start_up() final { file_name_ = create_tmp_file(); file = fopen(file_name_.c_str(), "w"); - // setvbuf(file, buffer, _IOFBF, buffer_size); + // setvbuf(file, buffer, _IOFBF, BUFFER_SIZE); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { std::fprintf(file, "This is just for test%d\n", 987654321); // std::fflush(file); } } - void tear_down() override { + void tear_down() final { std::fclose(file); unlink(file_name_.c_str()); } @@ -100,58 +100,56 @@ class FILEWriteBench : public td::Benchmark { #if TD_ANDROID #include #define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "XXX", __VA_ARGS__) -class ALogWriteBench : public td::Benchmark { +class ALogWriteBench final : public td::Benchmark { public: - std::string get_description() const override { + std::string get_description() const final { return "android_log"; } - void start_up() override { + void start_up() final { } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { ALOG("This is just for test%d\n", 987654321); } } - void tear_down() override { + void tear_down() final { } }; #endif -class LogWriteBench : public td::Benchmark { +class LogWriteBench final : public td::Benchmark { protected: std::string file_name_; std::ofstream stream; std::streambuf *old_buf; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: - std::string get_description() const override { + std::string get_description() const final { return "td_log (slow in debug mode)"; } - void start_up() override { + void start_up() final { file_name_ = create_tmp_file(); stream.open(file_name_.c_str()); CHECK(stream.is_open()); old_buf = std::cerr.rdbuf(stream.rdbuf()); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { LOG(DEBUG) << "This is just for test" << 987654321; } } - void tear_down() override { + void tear_down() final { stream.close(); unlink(file_name_.c_str()); std::cerr.rdbuf(old_buf); } }; -std::mutex mutex; - int main() { td::bench(LogWriteBench()); #if TD_ANDROID @@ -159,5 +157,4 @@ int main() { #endif td::bench(IostreamWriteBench()); td::bench(FILEWriteBench()); - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp index bfbcea438b..56a6117bb4 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp @@ -1,11 +1,15 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include "td/telegram/telegram_api.h" +#include "td/telegram/telegram_api.hpp" + #include "td/utils/benchmark.h" #include "td/utils/common.h" +#include "td/utils/format.h" #include "td/utils/logging.h" #include "td/utils/port/Clocks.h" #include "td/utils/port/EventFd.h" @@ -15,9 +19,9 @@ #include "td/utils/port/Stat.h" #include "td/utils/port/thread.h" #include "td/utils/Slice.h" - -#include "td/telegram/telegram_api.h" -#include "td/telegram/telegram_api.hpp" +#include "td/utils/SliceBuilder.h" +#include "td/utils/Status.h" +#include "td/utils/ThreadSafeCounter.h" #if !TD_WINDOWS #include @@ -28,37 +32,38 @@ #include #endif +#include +#include #include #include - -namespace td { +#include class F { - uint32 ∑ + td::uint32 ∑ public: - explicit F(uint32 &sum) : sum(sum) { + explicit F(td::uint32 &sum) : sum(sum) { } template void operator()(const T &x) const { - sum += static_cast(x.get_id()); + sum += static_cast(x.get_id()); } }; BENCH(Call, "TL Call") { - tl_object_ptr x = make_tl_object(); - uint32 res = 0; + td::tl_object_ptr x = td::make_tl_object(0); + td::uint32 res = 0; F f(res); for (int i = 0; i < n; i++) { downcast_call(*x, f); } - do_not_optimize_away(res); + td::do_not_optimize_away(res); } #if !TD_EVENTFD_UNSUPPORTED BENCH(EventFd, "EventFd") { - EventFd fd; + td::EventFd fd; fd.init(); for (int i = 0; i < n; i++) { fd.release(); @@ -75,15 +80,15 @@ BENCH(NewInt, "new int + delete") { res += reinterpret_cast(x); delete x; } - do_not_optimize_away(res); + td::do_not_optimize_away(res); } -BENCH(NewObj, "new struct then delete") { +BENCH(NewObj, "new struct, then delete") { struct A { - int32 a = 0; - int32 b = 0; - int32 c = 0; - int32 d = 0; + td::int32 a = 0; + td::int32 b = 0; + td::int32 c = 0; + td::int32 d = 0; }; std::uintptr_t res = 0; A **ptr = new A *[n]; @@ -95,57 +100,57 @@ BENCH(NewObj, "new struct then delete") { delete ptr[i]; } delete[] ptr; - do_not_optimize_away(res); + td::do_not_optimize_away(res); } #if !TD_THREAD_UNSUPPORTED -BENCH(ThreadNew, "new struct then delete in several threads") { - td::NewObjBench a, b; - thread ta([&] { a.run(n / 2); }); - thread tb([&] { b.run(n - n / 2); }); +BENCH(ThreadNew, "new struct, then delete in 2 threads") { + NewObjBench a; + NewObjBench b; + td::thread ta([&] { a.run(n / 2); }); + td::thread tb([&] { b.run(n - n / 2); }); ta.join(); tb.join(); } #endif - -// Too hard for android clang (?) +/* +// Too hard for clang (?) BENCH(Time, "Clocks::monotonic") { double res = 0; for (int i = 0; i < n; i++) { - res += Clocks::monotonic(); + res += td::Clocks::monotonic(); } - do_not_optimize_away(res); + td::do_not_optimize_away(res); } - +*/ #if !TD_WINDOWS -class PipeBench : public Benchmark { +class PipeBench final : public td::Benchmark { public: int p[2]; - PipeBench() { - pipe(p); - } - - string get_description() const override { + td::string get_description() const final { return "pipe write + read int32"; } - void start_up() override { - pipe(p); + void start_up() final { + int res = pipe(p); + CHECK(res == 0); } - void run(int n) override { + void run(int n) final { int res = 0; for (int i = 0; i < n; i++) { int val = 1; - write(p[1], &val, sizeof(val)); - read(p[0], &val, sizeof(val)); + auto write_len = write(p[1], &val, sizeof(val)); + CHECK(write_len == sizeof(val)); + auto read_len = read(p[0], &val, sizeof(val)); + CHECK(read_len == sizeof(val)); res += val; } - do_not_optimize_away(res); + td::do_not_optimize_away(res); } - void tear_down() override { + void tear_down() final { close(p[0]); close(p[1]); } @@ -153,42 +158,42 @@ class PipeBench : public Benchmark { #endif #if TD_LINUX || TD_ANDROID || TD_TIZEN -class SemBench : public Benchmark { +class SemBench final : public td::Benchmark { sem_t sem; public: - string get_description() const override { + td::string get_description() const final { return "sem post + wait"; } - void start_up() override { + void start_up() final { int err = sem_init(&sem, 0, 0); CHECK(err != -1); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { sem_post(&sem); sem_wait(&sem); } } - void tear_down() override { + void tear_down() final { sem_destroy(&sem); } }; #endif #if !TD_WINDOWS -class UtimeBench : public Benchmark { +class UtimeBench final : public td::Benchmark { public: - void start_up() override { - FileFd::open("test", FileFd::Flags::Create | FileFd::Flags::Write).move_as_ok().close(); + void start_up() final { + td::FileFd::open("test", td::FileFd::Create | td::FileFd::Write).move_as_ok().close(); } - string get_description() const override { + td::string get_description() const final { return "utime"; } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { int err = utime("test", nullptr); CHECK(err >= 0); @@ -203,73 +208,77 @@ class UtimeBench : public Benchmark { #endif BENCH(Pwrite, "pwrite") { - auto fd = FileFd::open("test", FileFd::Flags::Create | FileFd::Flags::Write).move_as_ok(); + auto fd = td::FileFd::open("test", td::FileFd::Create | td::FileFd::Write).move_as_ok(); for (int i = 0; i < n; i++) { fd.pwrite("a", 0).ok(); } fd.close(); } -class CreateFileBench : public Benchmark { - string get_description() const override { +class CreateFileBench final : public td::Benchmark { + td::string get_description() const final { return "create_file"; } - void start_up() override { - mkdir("A").ensure(); + void start_up() final { + td::mkdir("A").ensure(); } - void run(int n) override { + void run(int n) final { for (int i = 0; i < n; i++) { - FileFd::open("A/" + to_string(i), FileFd::Flags::Write | FileFd::Flags::Create).move_as_ok().close(); + td::FileFd::open(PSLICE() << "A/" << i, td::FileFd::Write | td::FileFd::Create).move_as_ok().close(); } } - void tear_down() override { - auto status = td::walk_path("A/", [&](CSlice path, bool is_dir) { - if (is_dir) { - rmdir(path).ignore(); - } else { - unlink(path).ignore(); + void tear_down() final { + td::walk_path("A/", [&](td::CSlice path, auto type) { + if (type == td::WalkPath::Type::ExitDir) { + td::rmdir(path).ignore(); + } else if (type == td::WalkPath::Type::NotDir) { + td::unlink(path).ignore(); } - }); + }).ignore(); } }; -class WalkPathBench : public Benchmark { - string get_description() const override { + +class WalkPathBench final : public td::Benchmark { + td::string get_description() const final { return "walk_path"; } - void start_up_n(int n) override { - mkdir("A").ensure(); + void start_up_n(int n) final { + td::mkdir("A").ensure(); for (int i = 0; i < n; i++) { - FileFd::open("A/" + to_string(i), FileFd::Flags::Write | FileFd::Flags::Create).move_as_ok().close(); + td::FileFd::open(PSLICE() << "A/" << i, td::FileFd::Write | td::FileFd::Create).move_as_ok().close(); } } - void run(int n) override { + void run(int n) final { int cnt = 0; - auto status = td::walk_path("A/", [&](CSlice path, bool is_dir) { - stat(path).ok(); + td::walk_path("A/", [&](td::CSlice path, auto type) { + if (type == td::WalkPath::Type::EnterDir) { + return; + } + td::stat(path).ok(); cnt++; - }); - } - void tear_down() override { - auto status = td::walk_path("A/", [&](CSlice path, bool is_dir) { - if (is_dir) { - rmdir(path).ignore(); - } else { - unlink(path).ignore(); + }).ignore(); + } + void tear_down() final { + td::walk_path("A/", [&](td::CSlice path, auto type) { + if (type == td::WalkPath::Type::ExitDir) { + td::rmdir(path).ignore(); + } else if (type == td::WalkPath::Type::NotDir) { + td::unlink(path).ignore(); } - }); + }).ignore(); } }; #if !TD_THREAD_UNSUPPORTED template -class AtomicReleaseIncBench : public Benchmark { - string get_description() const override { +class AtomicReleaseIncBench final : public td::Benchmark { + td::string get_description() const final { return PSTRING() << "AtomicReleaseInc" << ThreadN; } - static std::atomic a_; - void run(int n) override { - std::vector threads; + static std::atomic a_; + void run(int n) final { + td::vector threads; for (int i = 0; i < ThreadN; i++) { threads.emplace_back([&] { for (int i = 0; i < n / ThreadN; i++) { @@ -283,17 +292,17 @@ class AtomicReleaseIncBench : public Benchmark { } }; template -std::atomic AtomicReleaseIncBench::a_; +std::atomic AtomicReleaseIncBench::a_; template -class AtomicReleaseCasIncBench : public Benchmark { - string get_description() const override { +class AtomicReleaseCasIncBench final : public td::Benchmark { + td::string get_description() const final { return PSTRING() << "AtomicReleaseCasInc" << ThreadN; } - static std::atomic a_; - void run(int n) override { - std::vector threads; + static std::atomic a_; + void run(int n) final { + td::vector threads; for (int i = 0; i < ThreadN; i++) { threads.emplace_back([&] { for (int i = 0; i < n / ThreadN; i++) { @@ -309,16 +318,16 @@ class AtomicReleaseCasIncBench : public Benchmark { } }; template -std::atomic AtomicReleaseCasIncBench::a_; +std::atomic AtomicReleaseCasIncBench::a_; -template -class RwMutexReadBench : public Benchmark { - string get_description() const override { +template +class RwMutexReadBench final : public td::Benchmark { + td::string get_description() const final { return PSTRING() << "RwMutexRead" << ThreadN; } - RwMutex mutex_; - void run(int n) override { - std::vector threads; + td::RwMutex mutex_; + void run(int n) final { + td::vector threads; for (int i = 0; i < ThreadN; i++) { threads.emplace_back([&] { for (int i = 0; i < n / ThreadN; i++) { @@ -331,14 +340,15 @@ class RwMutexReadBench : public Benchmark { } } }; -template -class RwMutexWriteBench : public Benchmark { - string get_description() const override { + +template +class RwMutexWriteBench final : public td::Benchmark { + td::string get_description() const final { return PSTRING() << "RwMutexWrite" << ThreadN; } - RwMutex mutex_; - void run(int n) override { - std::vector threads; + td::RwMutex mutex_; + void run(int n) final { + td::vector threads; for (int i = 0; i < ThreadN; i++) { threads.emplace_back([&] { for (int i = 0; i < n / ThreadN; i++) { @@ -351,42 +361,366 @@ class RwMutexWriteBench : public Benchmark { } } }; + +class ThreadSafeCounterBench final : public td::Benchmark { + static td::ThreadSafeCounter counter_; + int thread_count_; + + td::string get_description() const final { + return PSTRING() << "ThreadSafeCounter" << thread_count_; + } + void run(int n) final { + counter_.clear(); + td::vector threads; + for (int i = 0; i < thread_count_; i++) { + threads.emplace_back([n] { + for (int i = 0; i < n; i++) { + counter_.add(1); + } + }); + } + for (auto &thread : threads) { + thread.join(); + } + CHECK(counter_.sum() == n * thread_count_); + } + + public: + explicit ThreadSafeCounterBench(int thread_count) : thread_count_(thread_count) { + } +}; +td::ThreadSafeCounter ThreadSafeCounterBench::counter_; + +template +class AtomicCounterBench final : public td::Benchmark { + static std::atomic counter_; + int thread_count_; + + td::string get_description() const final { + return PSTRING() << "AtomicCounter" << thread_count_; + } + void run(int n) final { + counter_.store(0); + td::vector threads; + for (int i = 0; i < thread_count_; i++) { + threads.emplace_back([n] { + for (int i = 0; i < n; i++) { + counter_.fetch_add(1, StrictOrder ? std::memory_order_seq_cst : std::memory_order_relaxed); + } + }); + } + for (auto &thread : threads) { + thread.join(); + } + CHECK(counter_.load() == n * thread_count_); + } + + public: + explicit AtomicCounterBench(int thread_count) : thread_count_(thread_count) { + } +}; +template +std::atomic AtomicCounterBench::counter_; + #endif -} // namespace td + +class IdDuplicateCheckerOld { + public: + static td::string get_description() { + return "Old"; + } + td::Status check(td::int64 message_id) { + if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS) { + auto oldest_message_id = *saved_message_ids_.begin(); + if (message_id < oldest_message_id) { + return td::Status::Error(2, PSLICE() << "Ignore very old message_id " + << td::tag("oldest message_id", oldest_message_id) + << td::tag("got message_id", message_id)); + } + } + if (saved_message_ids_.count(message_id) != 0) { + return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id)); + } + + saved_message_ids_.insert(message_id); + if (saved_message_ids_.size() > MAX_SAVED_MESSAGE_IDS) { + saved_message_ids_.erase(saved_message_ids_.begin()); + } + return td::Status::OK(); + } + + private: + static constexpr size_t MAX_SAVED_MESSAGE_IDS = 1000; + std::set saved_message_ids_; +}; + +template +class IdDuplicateCheckerNew { + public: + static td::string get_description() { + return PSTRING() << "New" << MAX_SAVED_MESSAGE_IDS; + } + td::Status check(td::int64 message_id) { + auto insert_result = saved_message_ids_.insert(message_id); + if (!insert_result.second) { + return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id)); + } + if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) { + auto begin_it = saved_message_ids_.begin(); + bool is_very_old = begin_it == insert_result.first; + saved_message_ids_.erase(begin_it); + if (is_very_old) { + return td::Status::Error(2, PSLICE() << "Ignore very old message_id " + << td::tag("oldest message_id", *saved_message_ids_.begin()) + << td::tag("got message_id", message_id)); + } + } + return td::Status::OK(); + } + + private: + std::set saved_message_ids_; +}; + +class IdDuplicateCheckerNewOther { + public: + static td::string get_description() { + return "NewOther"; + } + td::Status check(td::int64 message_id) { + if (!saved_message_ids_.insert(message_id).second) { + return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id)); + } + if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) { + auto begin_it = saved_message_ids_.begin(); + bool is_very_old = *begin_it == message_id; + saved_message_ids_.erase(begin_it); + if (is_very_old) { + return td::Status::Error(2, PSLICE() << "Ignore very old message_id " + << td::tag("oldest message_id", *saved_message_ids_.begin()) + << td::tag("got message_id", message_id)); + } + } + return td::Status::OK(); + } + + private: + static constexpr size_t MAX_SAVED_MESSAGE_IDS = 1000; + std::set saved_message_ids_; +}; + +class IdDuplicateCheckerNewSimple { + public: + static td::string get_description() { + return "NewSimple"; + } + td::Status check(td::int64 message_id) { + auto insert_result = saved_message_ids_.insert(message_id); + if (!insert_result.second) { + return td::Status::Error(1, "Ignore duplicated message_id"); + } + if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) { + auto begin_it = saved_message_ids_.begin(); + bool is_very_old = begin_it == insert_result.first; + saved_message_ids_.erase(begin_it); + if (is_very_old) { + return td::Status::Error(2, "Ignore very old message_id"); + } + } + return td::Status::OK(); + } + + private: + static constexpr size_t MAX_SAVED_MESSAGE_IDS = 1000; + std::set saved_message_ids_; +}; + +template +class IdDuplicateCheckerArray { + public: + static td::string get_description() { + return PSTRING() << "Array" << max_size; + } + td::Status check(td::int64 message_id) { + if (end_pos_ == 2 * max_size) { + std::copy_n(&saved_message_ids_[max_size], max_size, &saved_message_ids_[0]); + end_pos_ = max_size; + } + if (end_pos_ == 0 || message_id > saved_message_ids_[end_pos_ - 1]) { + // fast path + saved_message_ids_[end_pos_++] = message_id; + return td::Status::OK(); + } + if (end_pos_ >= max_size && message_id < saved_message_ids_[0]) { + return td::Status::Error(2, PSLICE() << "Ignore very old message_id " + << td::tag("oldest message_id", saved_message_ids_[0]) + << td::tag("got message_id", message_id)); + } + auto it = std::lower_bound(&saved_message_ids_[0], &saved_message_ids_[end_pos_], message_id); + if (*it == message_id) { + return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id)); + } + std::copy_backward(it, &saved_message_ids_[end_pos_], &saved_message_ids_[end_pos_ + 1]); + *it = message_id; + ++end_pos_; + return td::Status::OK(); + } + + private: + std::array saved_message_ids_; + std::size_t end_pos_ = 0; +}; + +template +class DuplicateCheckerBench final : public td::Benchmark { + td::string get_description() const final { + return PSTRING() << "DuplicateCheckerBench" << T::get_description(); + } + void run(int n) final { + T checker_; + for (int i = 0; i < n; i++) { + checker_.check(i).ensure(); + } + } +}; + +template +class DuplicateCheckerBenchRepeat final : public td::Benchmark { + td::string get_description() const final { + return PSTRING() << "DuplicateCheckerBenchRepeat" << T::get_description(); + } + void run(int n) final { + T checker_; + for (int i = 0; i < n; i++) { + auto iter = i >> 10; + auto pos = i - (iter << 10); + if (pos < 768) { + if (iter >= 3 && pos == 0) { + auto error = checker_.check((iter - 3) * 768 + pos); + CHECK(error.error().code() == 2); + } + checker_.check(iter * 768 + pos).ensure(); + } else { + checker_.check(iter * 768 + pos - 256).ensure_error(); + } + } + } +}; + +template +class DuplicateCheckerBenchRepeatOnly final : public td::Benchmark { + td::string get_description() const final { + return PSTRING() << "DuplicateCheckerBenchRepeatOnly" << T::get_description(); + } + void run(int n) final { + T checker_; + for (int i = 0; i < n; i++) { + auto result = checker_.check(i & 255); + CHECK(result.is_error() == (i >= 256)); + } + } +}; + +template +class DuplicateCheckerBenchReverse final : public td::Benchmark { + td::string get_description() const final { + return PSTRING() << "DuplicateCheckerBenchReverseAdd" << T::get_description(); + } + void run(int n) final { + T checker_; + for (int i = 0; i < n; i++) { + auto pos = i & 255; + checker_.check(i - pos + (255 - pos)).ensure(); + } + } +}; + +template +class DuplicateCheckerBenchEvenOdd final : public td::Benchmark { + td::string get_description() const final { + return PSTRING() << "DuplicateCheckerBenchEvenOdd" << T::get_description(); + } + void run(int n) final { + T checker_; + for (int i = 0; i < n; i++) { + auto pos = i & 255; + checker_.check(i - pos + (pos * 2) % 256 + (pos * 2) / 256).ensure(); + } + } +}; int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG)); + + td::bench(DuplicateCheckerBenchEvenOdd>()); + td::bench(DuplicateCheckerBenchEvenOdd>()); + td::bench(DuplicateCheckerBenchEvenOdd>()); + td::bench(DuplicateCheckerBenchEvenOdd>()); + + td::bench(DuplicateCheckerBenchReverse>()); + td::bench(DuplicateCheckerBenchReverse>()); + td::bench(DuplicateCheckerBenchReverse>()); + td::bench(DuplicateCheckerBenchReverse>()); + + td::bench(DuplicateCheckerBenchRepeatOnly>()); + td::bench(DuplicateCheckerBenchRepeatOnly>()); + td::bench(DuplicateCheckerBenchRepeatOnly>()); + td::bench(DuplicateCheckerBenchRepeatOnly>()); + + td::bench(DuplicateCheckerBenchRepeat()); + td::bench(DuplicateCheckerBenchRepeat>()); + td::bench(DuplicateCheckerBenchRepeat()); + td::bench(DuplicateCheckerBenchRepeat()); + td::bench(DuplicateCheckerBenchRepeat>()); + td::bench(DuplicateCheckerBenchRepeat>()); + td::bench(DuplicateCheckerBenchRepeat>()); + + td::bench(DuplicateCheckerBench()); + td::bench(DuplicateCheckerBench>()); + td::bench(DuplicateCheckerBench()); + td::bench(DuplicateCheckerBench()); + td::bench(DuplicateCheckerBench>()); + td::bench(DuplicateCheckerBench>()); + td::bench(DuplicateCheckerBench>()); + td::bench(DuplicateCheckerBench>()); + td::bench(DuplicateCheckerBench>()); + #if !TD_THREAD_UNSUPPORTED - td::bench(td::AtomicReleaseIncBench<1>()); - td::bench(td::AtomicReleaseIncBench<2>()); - td::bench(td::AtomicReleaseCasIncBench<1>()); - td::bench(td::AtomicReleaseCasIncBench<2>()); - td::bench(td::RwMutexWriteBench<1>()); - td::bench(td::RwMutexReadBench<1>()); - td::bench(td::RwMutexWriteBench<>()); - td::bench(td::RwMutexReadBench<>()); + for (int i = 1; i <= 16; i *= 2) { + td::bench(ThreadSafeCounterBench(i)); + td::bench(AtomicCounterBench(i)); + td::bench(AtomicCounterBench(i)); + } + + td::bench(AtomicReleaseIncBench<1>()); + td::bench(AtomicReleaseIncBench<2>()); + td::bench(AtomicReleaseCasIncBench<1>()); + td::bench(AtomicReleaseCasIncBench<2>()); + td::bench(RwMutexWriteBench<1>()); + td::bench(RwMutexReadBench<1>()); + td::bench(RwMutexWriteBench<2>()); + td::bench(RwMutexReadBench<2>()); #endif #if !TD_WINDOWS - td::bench(td::UtimeBench()); + td::bench(UtimeBench()); #endif - td::bench(td::WalkPathBench()); - td::bench(td::CreateFileBench()); - td::bench(td::PwriteBench()); + td::bench(WalkPathBench()); + td::bench(CreateFileBench()); + td::bench(PwriteBench()); - td::bench(td::CallBench()); + td::bench(CallBench()); #if !TD_THREAD_UNSUPPORTED - td::bench(td::ThreadNewBench()); + td::bench(ThreadNewBench()); #endif #if !TD_EVENTFD_UNSUPPORTED - td::bench(td::EventFdBench()); + td::bench(EventFdBench()); #endif - td::bench(td::NewObjBench()); - td::bench(td::NewIntBench()); + td::bench(NewObjBench()); + td::bench(NewIntBench()); #if !TD_WINDOWS - td::bench(td::PipeBench()); + td::bench(PipeBench()); #endif #if TD_LINUX || TD_ANDROID || TD_TIZEN - td::bench(td::SemBench()); + td::bench(SemBench()); #endif - return 0; } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp index 13288e6cd7..6f7cf20bc9 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp @@ -1,5 +1,5 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,47 +8,56 @@ #include "td/utils/common.h" #include "td/utils/logging.h" #include "td/utils/MpscPollableQueue.h" +#include "td/utils/port/sleep.h" +#include "td/utils/port/thread.h" #include "td/utils/queue.h" +#include "td/utils/Random.h" // TODO: check system calls // TODO: all return values must be checked #include -#include -#include -#include +#if TD_PORT_POSIX #include #include #include #include #include +#endif #if TD_LINUX #include #endif -using std::atomic; -using std::vector; - -using td::int32; -using td::uint32; - #define MODE std::memory_order_relaxed // void set_affinity(int mask) { -// int err, syscallres; -// pid_t pid = gettid(); -// syscallres = syscall(__NR_sched_setaffinity, pid, sizeof(mask), &mask); -// if (syscallres) { -// err = errno; -// perror("oppa"); -//} -//} - -// TODO: warnings and asserts. There should be no warnings or debug output in production. +// pid_t pid = gettid(); +// int syscallres = syscall(__NR_sched_setaffinity, pid, sizeof(mask), &mask); +// if (syscallres) { +// perror("Failed to set affinity"); +// } +// } + using qvalue_t = int; +class Backoff { + int cnt = 0; + + public: + bool next() { + cnt++; + if (cnt < 50) { + return true; + } else { + td::usleep_for(1); + return cnt < 500; + } + } +}; + +#if TD_PORT_POSIX // Just for testing, not production class PipeQueue { int input; @@ -57,18 +66,21 @@ class PipeQueue { public: void init() { int new_pipe[2]; - pipe(new_pipe); + int res = pipe(new_pipe); + CHECK(res == 0); output = new_pipe[0]; input = new_pipe[1]; } void put(qvalue_t value) { - write(input, &value, sizeof(value)); + auto len = write(input, &value, sizeof(value)); + CHECK(len == sizeof(value)); } qvalue_t get() { qvalue_t res; - read(output, &res, sizeof(res)); + auto len = read(output, &res, sizeof(res)); + CHECK(len == sizeof(res)); return res; } @@ -78,26 +90,8 @@ class PipeQueue { } }; -class Backoff { - int cnt; - - public: - Backoff() : cnt(0) { - } - - bool next() { - cnt++; - if (cnt < 50) { - return true; - } else { - sched_yield(); - return cnt < 500; - } - } -}; - class VarQueue { - atomic data; + std::atomic data{0}; public: void init() { @@ -179,6 +173,7 @@ class SemQueue { return get(); } }; +#endif #if TD_LINUX class EventfdQueue { @@ -193,11 +188,14 @@ class EventfdQueue { void put(qvalue_t value) { q.put(value); td::int64 x = 1; - write(fd, &x, sizeof(x)); + auto len = write(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); } qvalue_t get() { td::int64 x; - read(fd, &x, sizeof(x)); + auto len = read(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); + CHECK(x == 1); return q.get(); } void destroy() { @@ -212,17 +210,17 @@ const int queue_buf_size = 1 << 10; class BufferQueue { struct node { qvalue_t val; - char pad[64 - sizeof(atomic)]; + char pad[64 - sizeof(std::atomic)]; }; node q[queue_buf_size]; struct Position { - atomic i; - char pad[64 - sizeof(atomic)]; + std::atomic i{0}; + char pad[64 - sizeof(std::atomic)]; - uint32 local_read_i; - uint32 local_write_i; - char pad2[64 - sizeof(uint32) * 2]; + td::uint32 local_read_i; + td::uint32 local_write_i; + char pad2[64 - sizeof(td::uint32) * 2]; void init() { i = 0; @@ -318,8 +316,7 @@ class BufferQueue { return; } if (!update_writer()) { - std::fprintf(stderr, "put strong failed\n"); - std::exit(0); + LOG(FATAL) << "Put strong failed"; } put_unsafe(val); } @@ -336,7 +333,7 @@ class BufferQueue { #if TD_LINUX class BufferedFdQueue { int fd; - atomic wait_flag; + std::atomic wait_flag{0}; BufferQueue q; char pad[64]; @@ -351,7 +348,8 @@ class BufferedFdQueue { td::int64 x = 1; __sync_synchronize(); if (wait_flag.load(MODE)) { - write(fd, &x, sizeof(x)); + auto len = write(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); } } void put_noflush(qvalue_t value) { @@ -362,7 +360,8 @@ class BufferedFdQueue { td::int64 x = 1; __sync_synchronize(); if (wait_flag.load(MODE)) { - write(fd, &x, sizeof(x)); + auto len = write(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); } } void flush_reader() { @@ -393,7 +392,8 @@ class BufferedFdQueue { wait_flag.store(1, MODE); __sync_synchronize(); while (!(res = q.update_reader())) { - read(fd, &x, sizeof(x)); + auto len = read(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); __sync_synchronize(); } wait_flag.store(0, MODE); @@ -416,7 +416,8 @@ class BufferedFdQueue { wait_flag.store(1, MODE); __sync_synchronize(); while (!q.update_reader()) { - read(fd, &x, sizeof(x)); + auto len = read(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); __sync_synchronize(); } wait_flag.store(0, MODE); @@ -430,7 +431,7 @@ class BufferedFdQueue { class FdQueue { int fd; - atomic wait_flag; + std::atomic wait_flag{0}; VarQueue q; char pad[64]; @@ -445,12 +446,14 @@ class FdQueue { td::int64 x = 1; __sync_synchronize(); if (wait_flag.load(MODE)) { - write(fd, &x, sizeof(x)); + auto len = write(fd, &x, sizeof(x)); + CHECK(len == sizeof(x)); } } qvalue_t get() { // td::int64 x; - // read(fd, &x, sizeof(x)); + // auto len = read(fd, &x, sizeof(x)); + // CHECK(len == sizeof(x)); // return q.get(); Backoff backoff; @@ -466,14 +469,13 @@ class FdQueue { td::int64 x; wait_flag.store(1, MODE); __sync_synchronize(); - // std::fprintf(stderr, "!\n"); - // while (res == -1 && read(fd, &x, sizeof(x))) { - // res = q.try_get(); - //} + // while (res == -1 && read(fd, &x, sizeof(x)) == sizeof(x)) { + // res = q.try_get(); + // } do { __sync_synchronize(); res = q.try_get(); - } while (res == -1 && read(fd, &x, sizeof(x))); + } while (res == -1 && read(fd, &x, sizeof(x)) == sizeof(x)); q.acquire(); wait_flag.store(0, MODE); return res; @@ -485,6 +487,7 @@ class FdQueue { }; #endif +#if TD_PORT_POSIX class SemBackoffQueue { sem_t sem; VarQueue q; @@ -554,46 +557,40 @@ class SemCheatQueue { }; template -class QueueBenchmark2 : public td::Benchmark { +class QueueBenchmark2 final : public td::Benchmark { QueueT client, server; int connections_n, queries_n; int server_active_connections; int client_active_connections; - vector server_conn; - vector client_conn; + td::vector server_conn; + td::vector client_conn; + + td::string name; public: - explicit QueueBenchmark2(int connections_n = 1) : connections_n(connections_n) { + QueueBenchmark2(int connections_n, td::string name) : connections_n(connections_n), name(std::move(name)) { } - std::string get_description() const override { - return "QueueBenchmark2"; + td::string get_description() const final { + return name; } - void start_up() override { + void start_up() final { client.init(); server.init(); } - void tear_down() override { + void tear_down() final { client.destroy(); server.destroy(); } void server_process(qvalue_t value) { int no = value & 0x00FFFFFF; - int co = static_cast(static_cast(value) >> 24); - // std::fprintf(stderr, "-->%d %d\n", co, no); - if (co < 0 || co >= connections_n || no != server_conn[co]++) { - std::fprintf(stderr, "%d %d\n", co, no); - std::fprintf(stderr, "expected %d %lld\n", co, static_cast(server_conn[co] - 1)); - std::fprintf(stderr, "Server BUG\n"); - while (true) { - } - } - // std::fprintf(stderr, "no = %d/%d\n", no, queries_n); - // std::fprintf(stderr, "answer: %d %d\n", no, co); + auto co = static_cast(static_cast(value) >> 24); + CHECK(co >= 0 && co < connections_n); + CHECK(no == server_conn[co]++); client.writer_put(value); client.writer_flush(); @@ -603,15 +600,12 @@ class QueueBenchmark2 : public td::Benchmark { } void *server_run(void *) { - server_conn = vector(connections_n); + server_conn = td::vector(connections_n); server_active_connections = connections_n; while (server_active_connections > 0) { int cnt = server.reader_wait(); - if (cnt == 0) { - std::fprintf(stderr, "ERROR!\n"); - std::exit(0); - } + CHECK(cnt != 0); while (cnt-- > 0) { server_process(server.reader_get_unsafe()); server.reader_flush(); @@ -624,18 +618,10 @@ class QueueBenchmark2 : public td::Benchmark { void client_process(qvalue_t value) { int no = value & 0x00FFFFFF; - int co = static_cast(static_cast(value) >> 24); - // std::fprintf(stderr, "<--%d %d\n", co, no); - if (co < 0 || co >= connections_n || no != client_conn[co]++) { - std::fprintf(stderr, "%d %d\n", co, no); - std::fprintf(stderr, "expected %d %lld\n", co, static_cast(client_conn[co] - 1)); - std::fprintf(stderr, "BUG\n"); - while (true) { - } - std::exit(0); - } + auto co = static_cast(static_cast(value) >> 24); + CHECK(co >= 0 && co < connections_n); + CHECK(no == client_conn[co]++); if (no + 1 < queries_n) { - // std::fprintf(stderr, "query: %d %d\n", no + 1, co); server.writer_put(value + 1); server.writer_flush(); } else { @@ -644,12 +630,9 @@ class QueueBenchmark2 : public td::Benchmark { } void *client_run(void *) { - client_conn = vector(connections_n); + client_conn = td::vector(connections_n); client_active_connections = connections_n; - if (queries_n >= (1 << 24)) { - std::fprintf(stderr, "Too big queries_n\n"); - std::exit(0); - } + CHECK(queries_n < (1 << 24)); for (int i = 0; i < connections_n; i++) { server.writer_put(static_cast(i) << 24); @@ -658,10 +641,7 @@ class QueueBenchmark2 : public td::Benchmark { while (client_active_connections > 0) { int cnt = client.reader_wait(); - if (cnt == 0) { - std::fprintf(stderr, "ERROR!\n"); - std::exit(0); - } + CHECK(cnt != 0); while (cnt-- > 0) { client_process(client.reader_get_unsafe()); client.reader_flush(); @@ -681,7 +661,7 @@ class QueueBenchmark2 : public td::Benchmark { return static_cast(arg)->server_run(nullptr); } - void run(int n) override { + void run(int n) final { pthread_t client_thread_id; pthread_t server_thread_id; @@ -696,45 +676,40 @@ class QueueBenchmark2 : public td::Benchmark { }; template -class QueueBenchmark : public td::Benchmark { +class QueueBenchmark final : public td::Benchmark { QueueT client, server; const int connections_n; int queries_n; + td::string name; + public: - explicit QueueBenchmark(int connections_n = 1) : connections_n(connections_n) { + QueueBenchmark(int connections_n, td::string name) : connections_n(connections_n), name(std::move(name)) { } - std::string get_description() const override { - return "QueueBenchmark"; + td::string get_description() const final { + return name; } - void start_up() override { + void start_up() final { client.init(); server.init(); } - void tear_down() override { + void tear_down() final { client.destroy(); server.destroy(); } void *server_run(void *) { - vector conn(connections_n); + td::vector conn(connections_n); int active_connections = connections_n; while (active_connections > 0) { qvalue_t value = server.get(); int no = value & 0x00FFFFFF; - int co = static_cast(value >> 24); - // std::fprintf(stderr, "-->%d %d\n", co, no); - if (co < 0 || co >= connections_n || no != conn[co]++) { - std::fprintf(stderr, "%d %d\n", co, no); - std::fprintf(stderr, "expected %d %lld\n", co, static_cast(conn[co] - 1)); - std::fprintf(stderr, "Server BUG\n"); - while (true) { - } - } - // std::fprintf(stderr, "no = %d/%d\n", no, queries_n); + auto co = static_cast(value >> 24); + CHECK(co >= 0 && co < connections_n); + CHECK(no == conn[co]++); client.put(value); if (no + 1 >= queries_n) { active_connections--; @@ -744,11 +719,8 @@ class QueueBenchmark : public td::Benchmark { } void *client_run(void *) { - vector conn(connections_n); - if (queries_n >= (1 << 24)) { - std::fprintf(stderr, "Too big queries_n\n"); - std::exit(0); - } + td::vector conn(connections_n); + CHECK(queries_n < (1 << 24)); for (int i = 0; i < connections_n; i++) { server.put(static_cast(i) << 24); } @@ -756,16 +728,9 @@ class QueueBenchmark : public td::Benchmark { while (active_connections > 0) { qvalue_t value = client.get(); int no = value & 0x00FFFFFF; - int co = static_cast(value >> 24); - // std::fprintf(stderr, "<--%d %d\n", co, no); - if (co < 0 || co >= connections_n || no != conn[co]++) { - std::fprintf(stderr, "%d %d\n", co, no); - std::fprintf(stderr, "expected %d %lld\n", co, static_cast(conn[co] - 1)); - std::fprintf(stderr, "BUG\n"); - while (true) { - } - std::exit(0); - } + auto co = static_cast(value >> 24); + CHECK(co >= 0 && co < connections_n); + CHECK(no == conn[co]++); if (no + 1 < queries_n) { server.put(value + 1); } else { @@ -777,28 +742,18 @@ class QueueBenchmark : public td::Benchmark { } void *client_run2(void *) { - vector conn(connections_n); - if (queries_n >= (1 << 24)) { - std::fprintf(stderr, "Too big queries_n\n"); - std::exit(0); - } - for (int it = 0; it < queries_n; it++) { + td::vector conn(connections_n); + CHECK(queries_n < (1 << 24)); + for (int query = 0; query < queries_n; query++) { for (int i = 0; i < connections_n; i++) { - server.put((static_cast(i) << 24) + it); + server.put((static_cast(i) << 24) + query); } for (int i = 0; i < connections_n; i++) { qvalue_t value = client.get(); int no = value & 0x00FFFFFF; - int co = static_cast(value >> 24); - // std::fprintf(stderr, "<--%d %d\n", co, no); - if (co < 0 || co >= connections_n || no != conn[co]++) { - std::fprintf(stderr, "%d %d\n", co, no); - std::fprintf(stderr, "expected %d %lld\n", co, static_cast(conn[co] - 1)); - std::fprintf(stderr, "BUG\n"); - while (true) { - } - std::exit(0); - } + auto co = static_cast(value >> 24); + CHECK(co >= 0 && co < connections_n); + CHECK(no == conn[co]++); } } // system("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"); @@ -813,7 +768,7 @@ class QueueBenchmark : public td::Benchmark { return static_cast(arg)->server_run(nullptr); } - void run(int n) override { + void run(int n) final { pthread_t client_thread_id; pthread_t server_thread_id; @@ -828,8 +783,8 @@ class QueueBenchmark : public td::Benchmark { }; template -class RingBenchmark : public td::Benchmark { - enum { QN = 504 }; +class RingBenchmark final : public td::Benchmark { + static constexpr int QN = 504; struct Thread { int int_id; @@ -840,7 +795,6 @@ class RingBenchmark : public td::Benchmark { void *run() { qvalue_t value; - // std::fprintf(stderr, "start %d\n", int_id); do { int cnt = queue.reader_wait(); CHECK(cnt == 1); @@ -861,7 +815,7 @@ class RingBenchmark : public td::Benchmark { return static_cast(arg)->run(); } - void start_up() override { + void start_up() final { for (int i = 0; i < QN; i++) { q[i].int_id = i; q[i].queue.init(); @@ -869,18 +823,17 @@ class RingBenchmark : public td::Benchmark { } } - void tear_down() override { + void tear_down() final { for (int i = 0; i < QN; i++) { q[i].queue.destroy(); } } - void run(int n) override { + void run(int n) final { for (int i = 0; i < QN; i++) { pthread_create(&q[i].id, nullptr, run_gateway, &q[i]); } - std::fprintf(stderr, "run %d\n", n); if (n < 1000) { n = 1000; } @@ -892,52 +845,89 @@ class RingBenchmark : public td::Benchmark { } } }; +#endif + +/* +#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED +static void test_queue() { + td::vector threads; + static constexpr size_t THREAD_COUNT = 100; + td::vector> queues(THREAD_COUNT); + for (auto &q : queues) { + q.init(); + } + for (size_t i = 0; i < THREAD_COUNT; i++) { + threads.emplace_back([&q = queues[i]] { + while (true) { + auto got = q.reader_wait_nonblock(); + while (got-- > 0) { + q.reader_get_unsafe(); + } + q.reader_get_event_fd().wait(1000); + } + }); + } + + for (size_t iter = 0; iter < THREAD_COUNT; iter++) { + td::usleep_for(100); + for (int i = 0; i < 5; i++) { + queues[td::Random::fast(0, THREAD_COUNT - 1)].writer_put(1); + } + } + + for (size_t i = 0; i < THREAD_COUNT; i++) { + threads[i].join(); + } +} +#endif +*/ int main() { - SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG)); -#define BENCH_Q2(Q, N) \ - std::fprintf(stderr, "!%s %d:\t", #Q, N); \ - td::bench(QueueBenchmark2(N)); -#define BENCH_Q(Q, N) \ - std::fprintf(stderr, "%s %d:\t", #Q, N); \ - td::bench(QueueBenchmark(N)); - -#define BENCH_R(Q) \ - std::fprintf(stderr, "%s:\t", #Q); \ - td::bench(RingBenchmark()); +#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED + // test_queue(); +#endif + +#if TD_PORT_POSIX // TODO: yield makes it extremely slow. Yet some backoff may be necessary. - // BENCH_R(SemQueue); - // BENCH_R(td::PollQueue); + // td::bench(RingBenchmark()); + // td::bench(RingBenchmark>()); - BENCH_Q2(td::PollQueue, 1); - BENCH_Q2(td::MpscPollableQueue, 1); - BENCH_Q2(td::PollQueue, 100); - BENCH_Q2(td::MpscPollableQueue, 100); - BENCH_Q2(td::PollQueue, 10); - BENCH_Q2(td::MpscPollableQueue, 10); +#define BENCH_Q2(Q, N) td::bench(QueueBenchmark2>(N, #Q "(" #N ")")) - BENCH_Q(VarQueue, 1); - // BENCH_Q(FdQueue, 1); - // BENCH_Q(BufferedFdQueue, 1); - BENCH_Q(PipeQueue, 1); - BENCH_Q(SemCheatQueue, 1); - BENCH_Q(SemQueue, 1); +#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED + BENCH_Q2(td::InfBackoffQueue, 1); + BENCH_Q2(td::MpscPollableQueue, 1); + BENCH_Q2(td::PollQueue, 1); + + BENCH_Q2(td::InfBackoffQueue, 10); + BENCH_Q2(td::MpscPollableQueue, 10); + BENCH_Q2(td::PollQueue, 10); - // BENCH_Q2(td::PollQueue, 100); - // BENCH_Q2(td::PollQueue, 10); - // BENCH_Q2(td::PollQueue, 4); - // BENCH_Q2(td::InfBackoffQueue, 100); + BENCH_Q2(td::InfBackoffQueue, 100); + BENCH_Q2(td::MpscPollableQueue, 100); + BENCH_Q2(td::PollQueue, 100); - // BENCH_Q2(td::InfBackoffQueue, 1); - // BENCH_Q(SemCheatQueue, 1); + BENCH_Q2(td::PollQueue, 4); + BENCH_Q2(td::PollQueue, 10); + BENCH_Q2(td::PollQueue, 100); +#endif - // BENCH_Q(BufferedFdQueue, 100); - // BENCH_Q(BufferedFdQueue, 10); +#define BENCH_Q(Q, N) td::bench(QueueBenchmark(N, #Q "(" #N ")")) - // BENCH_Q(BufferQueue, 4); - // BENCH_Q(BufferQueue, 100); - // BENCH_Q(BufferQueue, 10); - // BENCH_Q(BufferQueue, 1); +#if TD_LINUX + BENCH_Q(BufferQueue, 1); + BENCH_Q(BufferedFdQueue, 1); + BENCH_Q(FdQueue, 1); +#endif + BENCH_Q(PipeQueue, 1); + BENCH_Q(SemCheatQueue, 1); + BENCH_Q(SemQueue, 1); + BENCH_Q(VarQueue, 1); - return 0; +#if TD_LINUX + BENCH_Q(BufferQueue, 4); + BENCH_Q(BufferQueue, 10); + BENCH_Q(BufferQueue, 100); +#endif +#endif } diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp index 91e957a501..c3298327e5 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp @@ -1,70 +1,78 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/DialogId.h" +#include "td/telegram/MessageDb.h" #include "td/telegram/MessageId.h" -#include "td/telegram/MessagesDb.h" +#include "td/telegram/NotificationId.h" +#include "td/telegram/ServerMessageId.h" #include "td/telegram/UserId.h" +#include "td/db/DbKey.h" +#include "td/db/SqliteConnectionSafe.h" +#include "td/db/SqliteDb.h" + +#include "td/actor/ConcurrentScheduler.h" + #include "td/utils/benchmark.h" #include "td/utils/buffer.h" #include "td/utils/common.h" #include "td/utils/logging.h" +#include "td/utils/Promise.h" #include "td/utils/Random.h" #include "td/utils/Status.h" #include -namespace td { - -static Status init_db(SqliteDb &db) { +static td::Status init_db(td::SqliteDb &db) { TRY_STATUS(db.exec("PRAGMA encoding=\"UTF-8\"")); TRY_STATUS(db.exec("PRAGMA synchronous=NORMAL")); TRY_STATUS(db.exec("PRAGMA journal_mode=WAL")); TRY_STATUS(db.exec("PRAGMA temp_store=MEMORY")); TRY_STATUS(db.exec("PRAGMA secure_delete=1")); - return Status::OK(); + return td::Status::OK(); } -class MessagesDbBench : public Benchmark { +class MessageDbBench final : public td::Benchmark { public: - string get_description() const override { - return "MessagesDb"; + td::string get_description() const final { + return "MessageDb"; } - void start_up() override { + void start_up() final { LOG(ERROR) << "START UP"; do_start_up().ensure(); scheduler_->start(); } - void run(int n) override { - auto guard = scheduler_->get_current_guard(); + void run(int n) final { + auto guard = scheduler_->get_main_guard(); for (int i = 0; i < n; i += 20) { - auto dialog_id = DialogId{UserId{Random::fast(1, 100)}}; - auto message_id_raw = Random::fast(1, 100000); + auto dialog_id = td::DialogId(td::UserId(static_cast(td::Random::fast(1, 100)))); + auto message_id_raw = td::Random::fast(1, 100000); for (int j = 0; j < 20; j++) { - auto message_id = MessageId{ServerMessageId{message_id_raw + j}}; - auto unique_message_id = ServerMessageId{i + 1}; - auto sender_user_id = UserId{Random::fast(1, 1000)}; + auto message_id = td::MessageId{td::ServerMessageId{message_id_raw + j}}; + auto unique_message_id = td::ServerMessageId{i + 1}; + auto sender_dialog_id = td::DialogId(td::UserId(static_cast(td::Random::fast(1, 1000)))); auto random_id = i + 1; auto ttl_expires_at = 0; - auto data = BufferSlice(Random::fast(100, 299)); + auto data = td::BufferSlice(td::Random::fast(100, 299)); // use async on same thread. - messages_db_async_->add_message({dialog_id, message_id}, unique_message_id, sender_user_id, random_id, - ttl_expires_at, 0, 0, "", std::move(data), Promise<>()); + message_db_async_->add_message({dialog_id, message_id}, unique_message_id, sender_dialog_id, random_id, + ttl_expires_at, 0, 0, "", td::NotificationId(), td::MessageId(), std::move(data), + td::Promise<>()); } } } - void tear_down() override { + void tear_down() final { scheduler_->run_main(0.1); { - auto guard = scheduler_->get_current_guard(); + auto guard = scheduler_->get_main_guard(); sql_connection_.reset(); - messages_db_sync_safe_.reset(); - messages_db_async_.reset(); + message_db_sync_safe_.reset(); + message_db_async_.reset(); } scheduler_->finish(); @@ -73,36 +81,33 @@ class MessagesDbBench : public Benchmark { } private: - std::unique_ptr scheduler_; - std::shared_ptr sql_connection_; - std::shared_ptr messages_db_sync_safe_; - std::shared_ptr messages_db_async_; + td::unique_ptr scheduler_; + std::shared_ptr sql_connection_; + std::shared_ptr message_db_sync_safe_; + std::shared_ptr message_db_async_; - Status do_start_up() { - scheduler_ = std::make_unique(); - scheduler_->init(1); + td::Status do_start_up() { + scheduler_ = td::make_unique(1, 0); - auto guard = scheduler_->get_current_guard(); + auto guard = scheduler_->get_main_guard(); - string sql_db_name = "testdb.sqlite"; - sql_connection_ = std::make_shared(sql_db_name); + td::string sql_db_name = "testdb.sqlite"; + sql_connection_ = std::make_shared(sql_db_name, td::DbKey::empty()); auto &db = sql_connection_->get(); TRY_STATUS(init_db(db)); db.exec("BEGIN TRANSACTION").ensure(); // version == 0 ==> db will be destroyed - TRY_STATUS(init_messages_db(db, 0)); + TRY_STATUS(init_message_db(db, 0)); db.exec("COMMIT TRANSACTION").ensure(); - messages_db_sync_safe_ = create_messages_db_sync(sql_connection_); - messages_db_async_ = create_messages_db_async(messages_db_sync_safe_, 0); - return Status::OK(); + message_db_sync_safe_ = td::create_message_db_sync(sql_connection_); + message_db_async_ = td::create_message_db_async(message_db_sync_safe_, 0); + return td::Status::OK(); } }; -} // namespace td int main() { SET_VERBOSITY_LEVEL(VERBOSITY_NAME(WARNING)); - bench(td::MessagesDbBench()); - return 0; + td::bench(MessageDbBench()); } diff --git a/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp b/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp new file mode 100644 index 0000000000..0a54c598c0 --- /dev/null +++ b/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp @@ -0,0 +1,193 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/telegram/Client.h" +#include "td/telegram/td_api.h" + +#include "td/utils/base64.h" +#include "td/utils/common.h" +#include "td/utils/filesystem.h" +#include "td/utils/logging.h" +#include "td/utils/misc.h" +#include "td/utils/TsCerr.h" + +#include +#include +#include +#include + +static void usage() { + td::TsCerr() << "Tests specified MTProto-proxies, outputs working proxies to stdout; exits with code 0 if a working " + "proxy was found.\n"; + td::TsCerr() << "Usage: check_proxy [options] server:port:secret [server2:port2:secret2 ...]\n"; + td::TsCerr() << "Options:\n"; + td::TsCerr() << " -v\tSet verbosity level to N\n"; + td::TsCerr() << " -h/--help\tDisplay this information\n"; + td::TsCerr() << " -d/--dc-id\tIdentifier of a datacenter to which try to connect (default is 2)\n"; + td::TsCerr() << " -l/--proxy-list\tName of a file with proxies to check; one proxy per line\n"; + td::TsCerr() << " -t/--timeout\tMaximum overall timeout for the request (default is 10 seconds)\n"; + std::exit(2); +} + +int main(int argc, char **argv) { + int new_verbosity_level = VERBOSITY_NAME(FATAL); + + td::vector>> requests; + + auto add_proxy = [&requests](td::string arg) { + if (arg.empty()) { + return; + } + + std::size_t offset = 0; + if (arg[0] == '[') { + auto end_ipv6_pos = arg.find(']'); + if (end_ipv6_pos == td::string::npos) { + td::TsCerr() << "Error: failed to find end of IPv6 address in \"" << arg << "\"\n"; + usage(); + } + offset = end_ipv6_pos; + } + if (std::count(arg.begin() + offset, arg.end(), ':') == 3) { + auto secret_domain_pos = arg.find(':', arg.find(':', offset) + 1) + 1; + auto domain_pos = arg.find(':', secret_domain_pos); + auto secret = arg.substr(secret_domain_pos, domain_pos - secret_domain_pos); + auto domain = arg.substr(domain_pos + 1); + auto r_decoded_secret = td::hex_decode(secret); + if (r_decoded_secret.is_error()) { + r_decoded_secret = td::base64url_decode(secret); + if (r_decoded_secret.is_error()) { + td::TsCerr() << "Error: failed to find proxy port and secret in \"" << arg << "\"\n"; + usage(); + } + } + arg = arg.substr(0, secret_domain_pos) + td::base64url_encode(r_decoded_secret.ok() + domain); + } + + auto secret_pos = arg.rfind(':'); + if (secret_pos == td::string::npos) { + td::TsCerr() << "Error: failed to find proxy port and secret in \"" << arg << "\"\n"; + usage(); + } + auto secret = arg.substr(secret_pos + 1); + auto port_pos = arg.substr(0, secret_pos).rfind(':'); + if (port_pos == td::string::npos) { + td::TsCerr() << "Error: failed to find proxy secret in \"" << arg << "\"\n"; + usage(); + } + auto r_port = td::to_integer_safe(arg.substr(port_pos + 1, secret_pos - port_pos - 1)); + if (r_port.is_error()) { + td::TsCerr() << "Error: failed to parse proxy port in \"" << arg << "\"\n"; + usage(); + } + auto port = r_port.move_as_ok(); + auto server = arg.substr(0, port_pos); + if (server[0] == '[' && server.back() == ']') { + server = server.substr(1, server.size() - 2); + } + + if (server.empty() || port <= 0 || port > 65536 || secret.empty()) { + td::TsCerr() << "Error: proxy address to check is in wrong format: \"" << arg << "\"\n"; + usage(); + } + + requests.emplace_back(arg, + td::td_api::make_object( + server, port, td::td_api::make_object(secret), -1, -1)); + }; + + td::int32 dc_id = 2; + double timeout = 10.0; + + for (int i = 1; i < argc; i++) { + td::string arg(argv[i]); + + auto get_next_arg = [&i, &arg, argc, argv](bool is_optional = false) { + CHECK(arg.size() >= 2); + if (arg.size() == 2 || arg[1] == '-') { + if (i + 1 < argc && argv[i + 1][0] != '-') { + return td::string(argv[++i]); + } + } else { + if (arg.size() > 2) { + return arg.substr(2); + } + } + if (!is_optional) { + td::TsCerr() << "Error: value is required after " << arg << "\n"; + usage(); + } + return td::string(); + }; + + if (td::begins_with(arg, "-v")) { + arg = get_next_arg(true); + int new_verbosity = 1; + while (arg[0] == 'v') { + new_verbosity++; + arg = arg.substr(1); + } + if (!arg.empty()) { + new_verbosity += td::to_integer(arg) - (new_verbosity == 1); + } + new_verbosity_level = VERBOSITY_NAME(FATAL) + new_verbosity; + } else if (td::begins_with(arg, "-t") || arg == "--timeout") { + timeout = td::to_double(get_next_arg()); + } else if (td::begins_with(arg, "-d") || arg == "--dc-id") { + dc_id = td::to_integer(get_next_arg()); + } else if (td::begins_with(arg, "-l") || arg == "--proxy-list") { + auto r_proxies = td::read_file_str(get_next_arg()); + if (r_proxies.is_error()) { + td::TsCerr() << "Error: wrong file name specified\n"; + usage(); + } + for (auto &proxy : td::full_split(r_proxies.ok(), '\n')) { + add_proxy(td::trim(proxy)); + } + } else if (arg[0] == '-') { + usage(); + } else { + add_proxy(arg); + } + } + + if (requests.empty()) { + td::TsCerr() << "Error: proxy address to check is not specified\n"; + usage(); + } + + SET_VERBOSITY_LEVEL(new_verbosity_level); + + td::ClientManager client_manager; + auto client_id = client_manager.create_client_id(); + for (size_t i = 0; i < requests.size(); i++) { + auto &request = requests[i].second; + request->dc_id_ = dc_id; + request->timeout_ = timeout; + client_manager.send(client_id, i + 1, std::move(request)); + } + size_t successful_requests = 0; + size_t failed_requests = 0; + + while (successful_requests + failed_requests != requests.size()) { + auto response = client_manager.receive(100.0); + CHECK(client_id == response.client_id); + if (1 <= response.request_id && response.request_id <= requests.size()) { + auto &proxy = requests[static_cast(response.request_id - 1)].first; + if (response.object->get_id() == td::td_api::error::ID) { + LOG(ERROR) << proxy << ": " << to_string(response.object); + failed_requests++; + } else { + std::cout << proxy << std::endl; + successful_requests++; + } + } + } + + if (successful_requests == 0) { + return 1; + } +} diff --git a/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp b/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp new file mode 100644 index 0000000000..f7fb1fecb7 --- /dev/null +++ b/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp @@ -0,0 +1,336 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/utils/BigNum.h" +#include "td/utils/common.h" +#include "td/utils/format.h" +#include "td/utils/logging.h" +#include "td/utils/misc.h" +#include "td/utils/port/detail/Iocp.h" +#include "td/utils/port/IPAddress.h" +#include "td/utils/port/sleep.h" +#include "td/utils/port/SocketFd.h" +#include "td/utils/port/thread.h" +#include "td/utils/Random.h" +#include "td/utils/Slice.h" +#include "td/utils/SliceBuilder.h" +#include "td/utils/Status.h" +#include "td/utils/Time.h" + +#include + +static td::BigNumContext context; + +static bool is_quadratic_residue(const td::BigNum &a) { + // 2^255 - 19 + td::BigNum mod = + td::BigNum::from_hex("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed").move_as_ok(); + // (mod - 1) / 2 = 2^254 - 10 + td::BigNum pow = + td::BigNum::from_hex("3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6").move_as_ok(); + + td::BigNum r; + td::BigNum::mod_exp(r, a, pow, mod, context); + td::BigNum one = td::BigNum::from_decimal("1").move_as_ok(); + td::BigNum::mod_add(r, r, one, mod, context); + + td::string result = r.to_decimal(); + CHECK(result == "0" || result == "1" || result == "2"); + return result == "2"; +} + +struct TlsInfo { + td::vector extension_list; + td::vector encrypted_application_data_length; +}; + +td::Result test_tls(const td::string &url) { + td::IPAddress address; + TRY_STATUS(address.init_host_port(url, 443)); + TRY_RESULT(socket, td::SocketFd::open(address)); + + td::string request; + + auto add_string = [&](td::Slice data) { + request.append(data.data(), data.size()); + }; + auto add_random = [&](size_t length) { + while (length-- > 0) { + request += static_cast(td::Random::secure_int32()); + } + }; + auto add_length = [&](size_t length) { + request += static_cast(length / 256); + request += static_cast(length % 256); + }; + auto add_key = [&] { + td::string key(32, '\0'); + td::BigNum mod = + td::BigNum::from_hex("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed").move_as_ok(); + while (true) { + td::Random::secure_bytes(key); + key[31] = static_cast(key[31] & 127); + td::BigNum x = td::BigNum::from_le_binary(key); + if (!is_quadratic_residue(x)) { + continue; + } + + td::BigNum y = x.clone(); + td::BigNum coef = td::BigNum::from_decimal("486662").move_as_ok(); + td::BigNum::mod_add(y, y, coef, mod, context); + td::BigNum::mod_mul(y, y, x, mod, context); + td::BigNum one = td::BigNum::from_decimal("1").move_as_ok(); + td::BigNum::mod_add(y, y, one, mod, context); + td::BigNum::mod_mul(y, y, x, mod, context); + // y = x^3 + 486662 * x^2 + x + if (is_quadratic_residue(y)) { + break; + } + } + request += key; + }; + + const size_t MAX_GREASE = 7; + char greases[MAX_GREASE]; + td::Random::secure_bytes(td::MutableSlice{greases, MAX_GREASE}); + for (auto &grease : greases) { + grease = static_cast((grease & 0xF0) + 0x0A); + } + for (size_t i = 1; i < MAX_GREASE; i += 2) { + if (greases[i] == greases[i - 1]) { + greases[i] = static_cast(0x10 ^ greases[i]); + } + } + auto add_grease = [&](size_t num) { + auto c = greases[num]; + request += c; + request += c; + }; + + add_string("\x16\x03\x01\x02\x00\x01\x00\x01\xfc\x03\x03"); + add_random(32); + add_string("\x20"); + add_random(32); + add_string("\x00\x20"); + add_grease(0); + add_string( + "\x13\x01\x13\x02\x13\x03\xc0\x2b\xc0\x2f\xc0\x2c\xc0\x30\xcc\xa9\xcc\xa8\xc0\x13\xc0\x14\x00\x9c\x00\x9d\x00" + "\x2f\x00\x35\x01\x00\x01\x93"); + add_grease(2); + add_string("\x00\x00\x00\x00"); + add_length(url.size() + 5); + add_length(url.size() + 3); + add_string("\x00"); + add_length(url.size()); + add_string(url); + add_string("\x00\x17\x00\x00\xff\x01\x00\x01\x00\x00\x0a\x00\x0a\x00\x08"); + add_grease(4); + add_string( + "\x00\x1d\x00\x17\x00\x18\x00\x0b\x00\x02\x01\x00\x00\x23\x00\x00\x00\x10\x00\x0e\x00\x0c\x02\x68\x32\x08\x68" + "\x74\x74\x70\x2f\x31\x2e\x31\x00\x05\x00\x05\x01\x00\x00\x00\x00\x00\x0d\x00\x12\x00\x10\x04\x03\x08\x04\x04" + "\x01\x05\x03\x08\x05\x05\x01\x08\x06\x06\x01\x00\x12\x00\x00\x00\x33\x00\x2b\x00\x29"); + add_grease(4); + add_string("\x00\x01\x00\x00\x1d\x00\x20"); + add_key(); + add_string("\x00\x2d\x00\x02\x01\x01\x00\x2b\x00\x0b\x0a"); + add_grease(6); + add_string("\x03\x04\x03\x03\x03\x02\x03\x01\x00\x1b\x00\x03\x02\x00\x02"); + add_grease(3); + add_string("\x00\x01\x00\x00\x15"); + auto padding = 515 - static_cast(request.size()); + CHECK(padding >= 0); + add_length(padding); + request.resize(517); + + // LOG(ERROR) << td::format::as_hex_dump<0>(td::Slice(request)); + + TRY_STATUS(socket.write(request)); + + TlsInfo info; + auto end_time = td::Time::now() + 3; + td::string result; + size_t pos = 0; + size_t server_hello_length = 0; + size_t encrypted_application_data_length_sum = 0; + while (td::Time::now() < end_time) { + static char buf[20000]; + TRY_RESULT(res, socket.read(td::MutableSlice{buf, sizeof(buf)})); + if (res > 0) { + auto read_length = [&]() -> size_t { + CHECK(result.size() >= 2 + pos); + pos += 2; + return static_cast(result[pos - 2]) * 256 + static_cast(result[pos - 1]); + }; + + result += td::Slice(buf, res).str(); + while (true) { +#define CHECK_LENGTH(length) \ + if (pos + (length) > result.size()) { \ + break; \ + } +#define EXPECT_STR(pos, str, error) \ + if (!begins_with(td::Slice(result).substr(pos), str)) { \ + return td::Status::Error(error); \ + } + + if (pos == 0) { + CHECK_LENGTH(3); + EXPECT_STR(0, "\x16\x03\x03", "Non-TLS response or TLS <= 1.1"); + pos += 3; + } + if (pos == 3) { + CHECK_LENGTH(2); + server_hello_length = read_length(); + if (server_hello_length <= 39) { + return td::Status::Error("Receive too short server hello"); + } + } + if (server_hello_length > 0) { + if (pos == 5) { + CHECK_LENGTH(server_hello_length); + + EXPECT_STR(5, "\x02\x00", "Non-TLS response 2"); + EXPECT_STR(9, "\x03\x03", "Non-TLS response 3"); + + auto random_id = td::Slice(result.c_str() + 11, 32); + if (random_id == + "\xcf\x21\xad\x74\xe5\x9a\x61\x11\xbe\x1d\x8c\x02\x1e\x65\xb8\x91\xc2\xa2\x11\x16\x7a\xbb\x8c\x5e\x07" + "\x9e\x09\xe2\xc8\xa8\x33\x9c") { + return td::Status::Error("TLS 1.3 servers returning HelloRetryRequest are not supprted"); + } + if (result[43] == '\x00') { + return td::Status::Error("TLS <= 1.2: empty session_id"); + } + EXPECT_STR(43, "\x20", "Non-TLS response 4"); + if (server_hello_length <= 75) { + return td::Status::Error("Receive too short server hello 2"); + } + EXPECT_STR(44, request.substr(44, 32), "TLS <= 1.2: expected mirrored session_id"); + EXPECT_STR(76, "\x13\x01\x00", "TLS <= 1.2: expected 0x1301 as a chosen cipher"); + pos += 74; + size_t extensions_length = read_length(); + if (extensions_length + 76 != server_hello_length) { + return td::Status::Error("Receive wrong extensions length"); + } + while (pos < 5 + server_hello_length - 4) { + info.extension_list.push_back(read_length()); + size_t extension_length = read_length(); + if (pos + extension_length > 5 + server_hello_length) { + return td::Status::Error("Receive wrong extension length"); + } + pos += extension_length; + } + if (pos != 5 + server_hello_length) { + return td::Status::Error("Receive wrong extensions list"); + } + } + if (pos == 5 + server_hello_length) { + CHECK_LENGTH(6); + EXPECT_STR(pos, "\x14\x03\x03\x00\x01\x01", "Expected dummy ChangeCipherSpec"); + pos += 6; + } + if (pos == 11 + server_hello_length + encrypted_application_data_length_sum) { + if (pos == result.size()) { + return info; + } + + CHECK_LENGTH(3); + EXPECT_STR(pos, "\x17\x03\x03", "Expected encrypted application data"); + pos += 3; + } + if (pos == 14 + server_hello_length + encrypted_application_data_length_sum) { + CHECK_LENGTH(2); + size_t encrypted_application_data_length = read_length(); + info.encrypted_application_data_length.push_back(encrypted_application_data_length); + if (encrypted_application_data_length == 0) { + return td::Status::Error("Receive empty encrypted application data"); + } + } + if (pos == 16 + server_hello_length + encrypted_application_data_length_sum) { + CHECK_LENGTH(info.encrypted_application_data_length.back()); + pos += info.encrypted_application_data_length.back(); + encrypted_application_data_length_sum += info.encrypted_application_data_length.back() + 5; + } + } + } + } else { + td::usleep_for(10000); + } + } + + // LOG(ERROR) << url << ":" << td::format::as_hex_dump<0>(td::Slice(result)); + return td::Status::Error("Failed to get response in 3 seconds"); +} + +int main(int argc, char *argv[]) { + SET_VERBOSITY_LEVEL(VERBOSITY_NAME(WARNING)); + +#if TD_PORT_WINDOWS + auto iocp = td::make_unique(); + iocp->init(); + auto iocp_thread = td::thread([&iocp] { iocp->loop(); }); + td::detail::Iocp::Guard iocp_guard(iocp.get()); +#endif + + td::vector urls; + for (int i = 1; i < argc; i++) { + urls.emplace_back(argv[i]); + } + for (auto &url : urls) { + const int MAX_TRIES = 100; + td::vector> length_count; + td::vector extension_list; + for (int i = 0; i < MAX_TRIES; i++) { + auto r_tls_info = test_tls(url); + if (r_tls_info.is_error()) { + LOG(ERROR) << url << ": " << r_tls_info.error(); + break; + } else { + auto tls_info = r_tls_info.move_as_ok(); + if (length_count.size() < tls_info.encrypted_application_data_length.size()) { + length_count.resize(tls_info.encrypted_application_data_length.size()); + } + for (size_t t = 0; t < tls_info.encrypted_application_data_length.size(); t++) { + length_count[t][tls_info.encrypted_application_data_length[t]]++; + } + if (i == 0) { + extension_list = tls_info.extension_list; + } else { + if (extension_list != tls_info.extension_list) { + LOG(ERROR) << url << ": TLS 1.3.0 extension list has changed from " << extension_list << " to " + << tls_info.extension_list; + break; + } + } + } + + if (i == MAX_TRIES - 1) { + if (extension_list != td::vector{51, 43} && extension_list != td::vector{43, 51}) { + LOG(ERROR) << url << ": TLS 1.3.0 unsupported extension list " << extension_list; + } else { + td::string length_distribution = "|"; + for (size_t t = 0; t < length_count.size(); t++) { + for (auto it : length_count[t]) { + length_distribution += PSTRING() + << it.first << " : " << static_cast(it.second * 100.0 / MAX_TRIES) << "%|"; + } + if (t + 1 != length_count.size()) { + length_distribution += " + |"; + } + } + LOG(ERROR) << url << ": TLS 1.3.0 with extensions " << extension_list << " and " + << (length_count.size() != 1 ? "unsupported " : "") + << "encrypted application data length distribution " << length_distribution; + } + } + } + } + +#if TD_PORT_WINDOWS + iocp->interrupt_loop(); + iocp_thread.join(); +#endif +} diff --git a/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp b/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp new file mode 100644 index 0000000000..f6e71b748a --- /dev/null +++ b/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp @@ -0,0 +1,545 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/utils/FlatHashMap.h" + +#ifdef SCOPE_EXIT +#undef SCOPE_EXIT +#endif + +#include +#include +#include +#include +#include + +#define test_map td::FlatHashMap +//#define test_map folly::F14FastMap +//#define test_map absl::flat_hash_map +//#define test_map std::map +//#define test_map std::unordered_map + +//#define CREATE_MAP(num) CREATE_MAP_IMPL(num) +#define CREATE_MAP(num) + +#define CREATE_MAP_IMPL(num) \ + int f_##num() { \ + test_map> m; \ + m.emplace(1, std::array{}); \ + int sum = 0; \ + for (auto &it : m) { \ + sum += it.first; \ + } \ + auto it = m.find(1); \ + sum += it->first; \ + m.erase(it); \ + return sum; \ + } \ + int x_##num = f_##num() + +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); +CREATE_MAP(__LINE__); + +int main() { +} diff --git a/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp b/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp new file mode 100644 index 0000000000..8f31b52114 --- /dev/null +++ b/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp @@ -0,0 +1,193 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#if USE_MEMPROF +#include "memprof/memprof_stat.h" +#endif + +#include "td/utils/common.h" +#include "td/utils/FlatHashMap.h" +#include "td/utils/FlatHashMapChunks.h" +#include "td/utils/FlatHashTable.h" +#include "td/utils/HashTableUtils.h" +#include "td/utils/logging.h" +#include "td/utils/MapNode.h" +#include "td/utils/misc.h" +#include "td/utils/port/Stat.h" +#include "td/utils/Slice.h" +#include "td/utils/StringBuilder.h" + +#ifdef SCOPE_EXIT +#undef SCOPE_EXIT +#endif + +#include +#include +#include +#include +#include +#include + +static int mem_stat_i = -1; +static int mem_stat_cur = 0; + +static bool use_memprof() { +#if USE_MEMPROF + return mem_stat_i < 0 && is_memprof_on(); +#else + return mem_stat_i < 0; +#endif +} + +static td::uint64 get_memory() { +#if USE_MEMPROF + if (use_memprof()) { + return get_used_memory_size(); + } +#endif + CHECK(!use_memprof()); + return td::mem_stat().ok().resident_size_; +} + +template +class Generator { + public: + T next() { + UNREACHABLE(); + } + static size_t dyn_size() { + UNREACHABLE(); + } +}; + +template +class IntGenerator { + public: + T next() { + return ++value; + } + static size_t dyn_size() { + return 0; + } + + private: + T value{}; +}; + +template <> +class Generator final : public IntGenerator {}; +template <> +class Generator final : public IntGenerator {}; + +template +class Generator> { + public: + td::unique_ptr next() { + return td::make_unique(); + } + static std::size_t dyn_size() { + return sizeof(T); + } +}; + +template +static void measure(td::StringBuilder &sb, td::Slice name, td::Slice key_name, td::Slice value_name) { + mem_stat_cur++; + if (mem_stat_i >= 0 && mem_stat_cur != mem_stat_i) { + return; + } + sb << name << "<" << key_name << "," << value_name << "> " << (use_memprof() ? "memprof" : "os") << "\n"; + std::size_t ideal_size = sizeof(KeyT) + sizeof(ValueT) + Generator::dyn_size(); + + sb << "\tempty:" << sizeof(T); + struct Stat { + int pi; + double min_ratio; + double max_ratio; + }; + td::vector stat; + stat.reserve(1024); + for (std::size_t size : {1000000u}) { + Generator key_generator; + Generator value_generator; + auto start_mem = get_memory(); + T ht; + auto ratio = [&] { + auto end_mem = get_memory(); + auto used_mem = end_mem - start_mem; + return static_cast(used_mem) / (static_cast(ideal_size) * static_cast(ht.size())); + }; + double min_ratio; + double max_ratio; + auto reset = [&] { + min_ratio = 1e100; + max_ratio = 0; + }; + auto update = [&] { + auto x = ratio(); + min_ratio = td::min(min_ratio, x); + max_ratio = td::max(max_ratio, x); + }; + reset(); + + int p = 10; + int pi = 1; + for (std::size_t i = 0; i < size; i++) { + ht.emplace(key_generator.next(), value_generator.next()); + update(); + if ((i + 1) % p == 0) { + stat.push_back(Stat{pi, min_ratio, max_ratio}); + reset(); + pi++; + p *= 10; + } + } + } + for (auto &s : stat) { + sb << " 10^" << s.pi << ":" << s.min_ratio << "->" << s.max_ratio; + } + sb << '\n'; +} + +template +using Bytes = std::array; + +template