From 2a3f8c8771fd53bae3ca74602c5b733519cdfa9d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 Oct 2023 14:55:04 +0300 Subject: we don't need this --- protocols/Telegram/tdlib/td/example/README.md | 323 - .../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 | 51 - .../Telegram/tdlib/td/example/android/fetch-sdk.sh | 30 - protocols/Telegram/tdlib/td/example/cpp/.gitignore | 1 - .../Telegram/tdlib/td/example/cpp/CMakeLists.txt | 13 - protocols/Telegram/tdlib/td/example/cpp/README.md | 24 - .../Telegram/tdlib/td/example/cpp/td_example.cpp | 338 - .../tdlib/td/example/cpp/tdjson_example.cpp | 55 - .../Telegram/tdlib/td/example/csharp/.gitignore | 5 - .../Telegram/tdlib/td/example/csharp/README.md | 40 - .../Telegram/tdlib/td/example/csharp/TdExample.cs | 294 - .../tdlib/td/example/csharp/TdExample.csproj | 119 - .../td/example/ios/Python-Apple-support.patch | 105 - protocols/Telegram/tdlib/td/example/ios/README.md | 46 - .../Telegram/tdlib/td/example/ios/build-openssl.sh | 38 - protocols/Telegram/tdlib/td/example/ios/build.sh | 90 - .../example/ios/openssl-1.0.2n-darwin-arm64.patch | 12 - .../Telegram/tdlib/td/example/java/.gitignore | 5 - .../Telegram/tdlib/td/example/java/CMakeLists.txt | 124 - protocols/Telegram/tdlib/td/example/java/README.md | 43 - .../Telegram/tdlib/td/example/java/td_jni.cpp | 181 - .../Telegram/tdlib/td/example/python/README.md | 11 - .../tdlib/td/example/python/tdjson_example.py | 142 - .../Telegram/tdlib/td/example/swift/.gitignore | 3 - .../Telegram/tdlib/td/example/swift/README.md | 15 - .../Telegram/tdlib/td/example/swift/src/main.swift | 190 - .../td/example/swift/src/td-Bridging-Header.h | 9 - .../td/example/swift/td.xcodeproj/project.pbxproj | 312 - .../Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt | 23 - protocols/Telegram/tdlib/td/example/uwp/README.md | 33 - .../Telegram/tdlib/td/example/uwp/SDKManifest.xml | 12 - .../tdlib/td/example/uwp/Telegram.Td.UWP.nuspec | 16 - .../tdlib/td/example/uwp/Telegram.Td.UWP.targets | 21 - .../tdlib/td/example/uwp/[Content_Types].xml | 14 - .../Telegram/tdlib/td/example/uwp/app/.gitignore | 5 - .../Telegram/tdlib/td/example/uwp/app/App.xaml | 7 - .../Telegram/tdlib/td/example/uwp/app/App.xaml.cs | 104 - .../td/example/uwp/app/ApplicationInsights.config | 3 - .../uwp/app/Assets/LockScreenLogo.scale-200.png | Bin 1430 -> 0 bytes .../uwp/app/Assets/SplashScreen.scale-200.png | Bin 7700 -> 0 bytes .../uwp/app/Assets/Square150x150Logo.scale-200.png | Bin 2937 -> 0 bytes .../uwp/app/Assets/Square44x44Logo.scale-200.png | Bin 1647 -> 0 bytes ...are44x44Logo.targetsize-24_altform-unplated.png | Bin 1255 -> 0 bytes .../tdlib/td/example/uwp/app/Assets/StoreLogo.png | Bin 1451 -> 0 bytes .../uwp/app/Assets/Wide310x150Logo.scale-200.png | Bin 3204 -> 0 bytes .../tdlib/td/example/uwp/app/MainPage.xaml | 29 - .../tdlib/td/example/uwp/app/MainPage.xaml.cs | 186 - .../tdlib/td/example/uwp/app/Package.appxmanifest | 28 - .../td/example/uwp/app/Properties/AssemblyInfo.cs | 29 - .../td/example/uwp/app/Properties/Default.rd.xml | 31 - .../Telegram/tdlib/td/example/uwp/app/TdApp.csproj | 151 - .../td/example/uwp/app/TdApp_TemporaryKey.pfx | Bin 2456 -> 0 bytes .../Telegram/tdlib/td/example/uwp/app/project.json | 19 - protocols/Telegram/tdlib/td/example/uwp/build.ps1 | 174 - .../tdlib/td/example/uwp/extension.vsixmanifest | 17 - 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 - 76 files changed, 13756 deletions(-) delete mode 100644 protocols/Telegram/tdlib/td/example/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/android/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/android/AddIntDef.php delete mode 100644 protocols/Telegram/tdlib/td/example/android/CMakeLists.txt delete mode 100644 protocols/Telegram/tdlib/td/example/android/Dockerfile delete mode 100644 protocols/Telegram/tdlib/td/example/android/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/android/build-openssl.sh delete mode 100644 protocols/Telegram/tdlib/td/example/android/build-tdlib.sh delete mode 100644 protocols/Telegram/tdlib/td/example/android/check-environment.sh delete mode 100644 protocols/Telegram/tdlib/td/example/android/fetch-sdk.sh delete mode 100644 protocols/Telegram/tdlib/td/example/cpp/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/cpp/CMakeLists.txt delete mode 100644 protocols/Telegram/tdlib/td/example/cpp/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/cpp/td_example.cpp delete mode 100644 protocols/Telegram/tdlib/td/example/cpp/tdjson_example.cpp delete mode 100644 protocols/Telegram/tdlib/td/example/csharp/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/csharp/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/csharp/TdExample.cs delete mode 100644 protocols/Telegram/tdlib/td/example/csharp/TdExample.csproj delete mode 100644 protocols/Telegram/tdlib/td/example/ios/Python-Apple-support.patch delete mode 100644 protocols/Telegram/tdlib/td/example/ios/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/ios/build-openssl.sh delete mode 100644 protocols/Telegram/tdlib/td/example/ios/build.sh delete mode 100644 protocols/Telegram/tdlib/td/example/ios/openssl-1.0.2n-darwin-arm64.patch delete mode 100644 protocols/Telegram/tdlib/td/example/java/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/java/CMakeLists.txt delete mode 100644 protocols/Telegram/tdlib/td/example/java/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/java/td_jni.cpp delete mode 100644 protocols/Telegram/tdlib/td/example/python/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/python/tdjson_example.py delete mode 100644 protocols/Telegram/tdlib/td/example/swift/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/swift/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/swift/src/main.swift delete mode 100644 protocols/Telegram/tdlib/td/example/swift/src/td-Bridging-Header.h delete mode 100644 protocols/Telegram/tdlib/td/example/swift/td.xcodeproj/project.pbxproj delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/App.xaml delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Package.appxmanifest delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Properties/Default.rd.xml delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/TdApp_TemporaryKey.pfx delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/project.json delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/build.ps1 delete mode 100644 protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest delete mode 100644 protocols/Telegram/tdlib/td/example/web/.gitignore delete mode 100644 protocols/Telegram/tdlib/td/example/web/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/web/build-openssl.sh delete mode 100644 protocols/Telegram/tdlib/td/example/web/build-tdlib.sh delete mode 100644 protocols/Telegram/tdlib/td/example/web/build-tdweb.sh delete mode 100644 protocols/Telegram/tdlib/td/example/web/copy-tdlib.sh delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/README.md delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/package-lock.json delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/package.json delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/index.js delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/logger.js delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/wasm-utils.js delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/src/worker.js delete mode 100644 protocols/Telegram/tdlib/td/example/web/tdweb/webpack.config.js (limited to 'protocols/Telegram/tdlib/td/example') diff --git a/protocols/Telegram/tdlib/td/example/README.md b/protocols/Telegram/tdlib/td/example/README.md deleted file mode 100644 index ab11409218..0000000000 --- a/protocols/Telegram/tdlib/td/example/README.md +++ /dev/null @@ -1,323 +0,0 @@ -# TDLib usage and build examples - -This directory contains basic examples of TDLib usage from different programming languages and examples of library building for different platforms. -If you are looking for documentation of all available TDLib methods, 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). -Also, take a look at our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts. - -TDLib can be easily used from almost any programming language on any platform. See a [TDLib build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib. -Choose your preferred programming language to see examples of usage and a detailed description: - -- [Python](#python) -- [JavaScript](#javascript) -- [Go](#go) -- [Java](#java) -- [Kotlin](#kotlin) -- [C#](#csharp) -- [C++](#cxx) -- [Swift](#swift) -- [Objective-C](#objective-c) -- [Object Pascal](#object-pascal) -- [Dart](#dart) -- [Rust](#rust) -- [Erlang](#erlang) -- [PHP](#php) -- [Lua](#lua) -- [Ruby](#ruby) -- [Crystal](#crystal) -- [Haskell](#haskell) -- [Nim](#nim) -- [Clojure](#clojure) -- [Emacs Lisp](#emacslisp) -- [D](#d) -- [Elixir](#elixir) -- [Vala](#vala) -- [1С](#1s) -- [C](#c) -- [G](#g) -- [Other](#other) - - -## Using TDLib in Python projects - -TDLib can be used from Python through the [JSON](https://github.com/tdlib/td#using-json) interface. - -Convenient Python wrappers already exist for our JSON interface. - -If you use Python >= 3.6, take a look at [python-telegram](https://github.com/alexander-akhmetov/python-telegram). -The wrapper uses the full power of asyncio, has a good documentation and has several examples. It can be installed through pip or used in a Docker container. -You can also try a fork [python-telegram](https://github.com/iTeam-co/pytglib) of this library. - -If you want to use TDLib with asyncio and Python >= 3.9, take a look at [aiotdlib](https://github.com/pylakey/aiotdlib) or [Pytdbot](https://github.com/pytdbot/client). - -For older Python versions you can use [pytdlib](https://github.com/pytdlib/pytdlib). -This wrapper contains generator for TDLib API classes and basic interface for interaction with TDLib. - -You can also check out [example/python/tdjson_example.py](https://github.com/tdlib/td/blob/master/example/python/tdjson_example.py), -[tdlib-python](https://github.com/JunaidBabu/tdlib-python), or [Python Wrapper TDLib](https://github.com/alvhix/pywtdlib) for some basic examples of TDLib JSON interface integration with Python. - - -## Using TDLib in JavaScript projects - -TDLib can be compiled to WebAssembly or asm.js and used in a browser from JavaScript. See [tdweb](https://github.com/tdlib/td/tree/master/example/web) as a convenient wrapper for TDLib in a browser -and [telegram-react](https://github.com/evgeny-nadymov/telegram-react) as an example of a TDLib-based Telegram client. - -See also [Svelte-tdweb-starter](https://github.com/gennadypolakov/svelte-tdweb-starter) - Svelte wrapper for tdweb, and [Telegram-Photoframe](https://github.com/lukefx/telegram-photoframe) - a web application that displays your prefered group or channel as Photoframe. - -TDLib can be used from Node.js through the [JSON](https://github.com/tdlib/td#using-json) interface. - -Convenient Node.js wrappers already exist for our JSON interface. -For example, take a look at [Airgram](https://github.com/airgram/airgram) – modern TDLib framework for TypeScript/JavaScript, or -at [tdl](https://github.com/Bannerets/tdl), which provides a convenient, fully-asynchronous interface for interaction with TDLib and contains a bunch of examples. - -You can also see [TdNode](https://github.com/puppy0cam/TdNode), [tglib](https://github.com/nodegin/tglib), [node-tdlib](https://github.com/wfjsw/node-tdlib), [tdlnode](https://github.com/fonbah/tdlnode), -[Paper Plane](https://github.com/par6n/paper-plane), or [node-tlg](https://github.com/dilongfa/node-tlg) for other examples of TDLib JSON interface integration with Node.js. - -See also the source code of [DIBgram](https://github.com/DIBgram/DIBgram) - an unofficial Telegram web application which looks like Telegram Desktop. - -TDLib can be used also from NativeScript through the [JSON](https://github.com/tdlib/td#using-json) interface. -See [nativescript-tglib](https://github.com/arpit2438735/nativescript-tglib) as an example of a NativeScript library for building Telegram clients. - - -## Using TDLib in Go projects - -TDLib can be used from the Go programming language through the [JSON](https://github.com/tdlib/td#using-json) interface and Cgo, and can be linked either statically or dynamically. - -Convenient Go wrappers already exist for our JSON interface. -For example, take a look at [github.com/zelenin/go-tdlib](https://github.com/zelenin/go-tdlib) or [github.com/Arman92/go-tdlib](https://github.com/Arman92/go-tdlib), which provide a convenient TDLib client, a generator for TDLib API classes and contain many examples. - -You can also see [github.com/aliforever/go-tdlib](https://github.com/aliforever/go-tdlib) or [github.com/L11R/go-tdjson](https://github.com/L11R/go-tdjson) for another examples of TDLib JSON interface integration with Go. - - -## Using TDLib in Java projects - -TDLib can be used from the Java programming language through native [JNI](https://github.com/tdlib/td#using-java) binding. - -We provide a generator for JNI bridge methods and Java classes for all TDLib API methods and objects. -See [example/java](https://github.com/tdlib/td/tree/master/example/java) for an example of using TDLib from desktop Java along with detailed building and usage instructions. -To use TDLib to create Android Java applications, use our [prebuilt library for Android](https://core.telegram.org/tdlib/tdlib.zip). - - -## Using TDLib in Kotlin projects - -TDLib can be used from the Kotlin/JVM programming language through same way as in [Java](#java). - -You can also use [ktd](https://github.com/whyoleg/ktd) library with Kotlin-specific bindings. - -See also [td-ktx](https://github.com/tdlibx/td-ktx) - Kotlin coroutines wrapper for TDLib. - - -## Using TDLib in C# projects - -TDLib provides a native [.NET](https://github.com/tdlib/td#using-dotnet) interface through `C++/CLI` and `C++/CX`. -See [tdlib-netcore](https://github.com/dantmnf/tdlib-netcore) for a SWIG-like binding with automatically generated classes for TDLib API. -See [example/uwp](https://github.com/tdlib/td/tree/master/example/uwp) for an example of building TDLib SDK for the Universal Windows Platform and an example of its usage from C#. -See [example/csharp](https://github.com/tdlib/td/tree/master/example/csharp) for an example of building TDLib with `C++/CLI` support and an example of TDLib usage from C# on Windows. - -If you want to write a cross-platform C# application using .NET Core, see [tdsharp](https://github.com/egramtel/tdsharp). It uses our [JSON](https://github.com/tdlib/td#using-json) interface, -provides an asynchronous interface for interaction with TDLib, automatically generated classes for TDLib API and has some examples. - -You can also use [TDLibCore](https://github.com/ph09nix/TDLibCore) library. - -Also, see [Unigram](https://github.com/UnigramDev/Unigram), which is a full-featured client rewritten from scratch in C# using TDLib SDK for Universal Windows Platform in less than 2 months, -[egram.tel](https://github.com/egramtel/egram.tel) – a cross-platform Telegram client written in C#, .NET Core, ReactiveUI and Avalonia, or -[telewear](https://github.com/telewear/telewear) - a Telegram client for Samsung watches. - - -## Using TDLib in C++ projects - -TDLib has a simple and convenient C++11-interface for sending and receiving requests and can be statically linked to your application. - -See [example/cpp](https://github.com/tdlib/td/tree/master/example/cpp) for an example of TDLib usage from C++. -[td_example.cpp](https://github.com/tdlib/td/blob/master/example/cpp/td_example.cpp) contains an example of authorization, processing new incoming messages, getting a list of chats and sending a text message. - -See also the source code of [Fernschreiber](https://github.com/Wunderfitz/harbour-fernschreiber) and [Depecher](https://github.com/blacksailer/depecher) – Telegram apps for Sailfish OS, -[TELEports](https://gitlab.com/ubports/development/apps/teleports) – a Qt-client for Ubuntu Touch, [tdlib-purple](https://github.com/ars3niy/tdlib-purple) - Telegram plugin for Pidgin, -or [MeeGram](https://github.com/qtinsider/meegram2) - a Telegram client for Nokia N9, -[TDLib Native Sciter Extension](https://github.com/EricKotato/TDLibNSE) - a Sciter native extension for TDLib's JSON interface, all of which are based on TDLib. - - -## Using TDLib in Swift projects - -TDLib can be used from the Swift programming language through the [JSON](https://github.com/tdlib/td#using-json) interface and can be linked statically or dynamically. - -See [example/ios](https://github.com/tdlib/td/tree/master/example/ios) for an example of building TDLib for iOS, watchOS, tvOS, and macOS. - -See [TDLibKit](https://github.com/Swiftgram/TDLibKit), [tdlib-swift](https://github.com/modestman/tdlib-swift), or [TDLib-iOS](https://github.com/leoMehlig/TDLib-iOS), which provide convenient TDLib clients with automatically generated and fully-documented classes for all TDLib API methods and objects. - -See also the source code of [Moc](https://github.com/mock-foundation/moc) - a native and powerful macOS and iPadOS Telegram client, optimized for moderating large communities and personal use. - -See [example/swift](https://github.com/tdlib/td/tree/master/example/swift) for an example of a macOS Swift application. - - -## Using TDLib in Objective-C projects - -TDLib can be used from the Objective-C programming language through [JSON](https://github.com/tdlib/td#using-json) interface and can be linked statically or dynamically. - -See [example/ios](https://github.com/tdlib/td/tree/master/example/ios) for an example of building TDLib for iOS, watchOS, tvOS, and macOS. - - -## Using TDLib in Object Pascal projects with Delphi and Lazarus - -TDLib can be used from the Object Pascal programming language through the [JSON](https://github.com/tdlib/td#using-json). - -See [tdlib-delphi](https://github.com/dieletro/tdlib-delphi) for an example of TDLib usage from Delphi. - -See [tdlib-lazarus](https://github.com/dieletro/tdlib-lazarus) for an example of TDLib usage from Lazarus. - - -## Using TDLib in Dart projects - -TDLib can be used from the Dart programming language through the [JSON](https://github.com/tdlib/td#using-json) interface and a Dart Native Extension or Dart FFI. - -See [tdlib-dart](https://github.com/ivk1800/tdlib-dart), which provide convenient TDLib client with automatically generated and fully-documented classes for all TDLib API methods and objects. - -See also [dart_tdlib](https://github.com/periodicaidan/dart_tdlib), [flutter_libtdjson](https://github.com/up9cloud/flutter_libtdjson), [Dart wrapper for TDLib](https://github.com/tdlib/td/pull/708/commits/237060abd4c205768153180e9f814298d1aa9d49), or [tdlib_bindings](https://github.com/lesnitsky/tdlib_bindings) for an example of a TDLib Dart bindings through FFI. - -See [Telegram Client library](https://github.com/azkadev/telegram_client), [project.scarlet](https://github.com/aaugmentum/project.scarlet), [tdlib](https://github.com/i-Naji/tdlib), -[tdlib-dart](https://github.com/drewpayment/tdlib-dart), [FluGram](https://github.com/triedcatched/tdlib-dart), or [telegram-service](https://github.com/igorder-dev/telegram-service) for examples of using TDLib from Dart. - -See also [telegram-flutter](https://github.com/ivk1800/telegram-flutter) - Telegram client written in Dart, and [f-Telegram](https://github.com/evgfilim1/ftg) - Flutter Telegram client. - - -## Using TDLib in Rust projects - -TDLib can be used from the Rust programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [rust-tdlib](https://github.com/antonio-antuan/rust-tdlib), or [tdlib](https://github.com/paper-plane-developers/tdlib-rs), which provide convenient TDLib clients with automatically generated and fully-documented classes for all TDLib API methods and objects. - -See [rtdlib](https://github.com/fewensa/rtdlib), [tdlib-rs](https://github.com/d653/tdlib-rs), [tdlib-futures](https://github.com/yuri91/tdlib-futures), -[tdlib-sys](https://github.com/nuxeh/tdlib-sys), [tdjson-rs](https://github.com/mersinvald/tdjson-rs), [rust-tdlib](https://github.com/vhaoran/rust-tdlib), or [tdlib-json-sys](https://github.com/aykxt/tdlib-json-sys) for examples of TDLib Rust bindings. - -Also, see [Paper Plane](https://github.com/paper-plane-developers/paper-plane) – a Telegram client written in Rust and GTK. - - -## Using TDLib in Erlang projects - -TDLib can be used from the Erlang programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [erl-tdlib](https://github.com/lattenwald/erl-tdlib) for an example of TDLib Erlang bindings. - - -## Using TDLib in PHP projects - -If you use modern PHP >= 7.4, you can use TDLib via a PHP FFI extension. For example, take a look at [ffi-tdlib](https://github.com/aurimasniekis/php-ffi-tdlib), or [tdlib-php-ffi](https://github.com/thisismzm/tdlib-php-ffi) - FFI-based TDLib wrappers. - -See also [tdlib-schema](https://github.com/aurimasniekis/php-tdlib-schema) - a generator for TDLib API classes. - -For older PHP versions you can use TDLib by wrapping its functionality in a PHP extension. - -See [phptdlib](https://github.com/yaroslavche/phptdlib), [tdlib](https://github.com/aurimasniekis/php-ext-tdlib), or [PIF-TDPony](https://github.com/danog/pif-tdpony) -for examples of such extensions which provide access to TDLib from PHP. - -See [tdlib-bundle](https://github.com/yaroslavche/tdlib-bundle) – a Symfony bundle based on [phptdlib](https://github.com/yaroslavche/phptdlib). - - -## Using TDLib in Lua projects - -TDLib can be used from the Lua programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [luajit-tdlib](https://github.com/Rami-Sabbagh/luajit-tdlib), [tdlua](https://github.com/giuseppeM99/tdlua), or -[luajit-tdlib](https://github.com/Playermet/luajit-tdlib) for examples of TDLib Lua bindings and basic usage examples. - -See also [tdbot](https://github.com/vysheng/tdbot), which makes all TDLib features available from Lua scripts. - - -## Using TDLib in D projects - -TDLib can be used from the D programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [d-tdlib-service](https://github.com/Lord-Evil/d-tdlib-service) for an example of TDLib D bindings. - - -## Using TDLib in Ruby projects - -TDLib can be used from the Ruby programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [tdlib-ruby](https://github.com/southbridgeio/tdlib-ruby) for examples of Ruby bindings and a client for TDLib. - - -## Using TDLib in Crystal projects - -TDLib can be used from the Crystal programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [Proton](https://github.com/protoncr/proton) for examples of Crystal bindings with automatically generated types for all TDLib API methods and objects. - - -## Using TDLib in Haskell projects - -TDLib can be used from the Haskell programming language. - -See [haskell-tdlib](https://github.com/mejgun/haskell-tdlib) or [tdlib](https://github.com/poscat0x04/tdlib) for examples of such usage and Haskell wrappers for TDLib. -This library contains automatically generated Haskell types for all TDLib API methods and objects. - - -## Using TDLib in Nim projects - -TDLib can be used from the Nim programming language. - -See [telenim](https://github.com/Yardanico/telenim) for example of such usage and a Nim wrapper for TDLib. - - -## Using TDLib in Clojure projects - -TDLib can be used from the Clojure programming language through the [JSON](https://github.com/tdlib/td#using-json) interface. - -See [clojure-tdlib-json-wrapper](https://github.com/MityaSaray/clojure-tdlib-json) for an example of TDLib Clojure bindings. - - -## Using TDLib in Emacs Lisp projects - -TDLib can be used from the Emacs Lisp programming language. - -See [telega.el](https://github.com/zevlg/telega.el) for an example of a GNU Emacs Telegram client. - - -## Using TDLib in Elixir projects - -TDLib can be used from the Elixir programming language. - -See [Elixir TDLib](https://github.com/QuantLayer/elixir-tdlib) for an example of such usage and an Elixir client for TDLib. -The library contains automatically generated and fully-documented classes for all TDLib API methods and objects. - - -## Using TDLib in Vala projects - -TDLib can be used from the Vala programming language. - -See [TDLib Vala](https://github.com/AYMENJD/td-vala) for an example of such usage. - - -## Using TDLib from 1С:Enterprise - -TDLib can be used from the 1С programming language. - -See [TDLib bindings for 1С:Enterprise](https://github.com/Infactum/telegram-native) and [e1c.tAgents](https://github.com/fedbka/e1c.tAgents) for examples of such usage. - - -## Using TDLib in C projects - -TDLib can be used from the C programming language through the [JSON](https://github.com/tdlib/td#using-json) interface and can be linked statically or dynamically. - -See [easy-tg](https://github.com/Trumeet/easy-tg) for an example of such usage. - -You can also try to use our [C](https://github.com/tdlib/td/blob/master/td/telegram/td_c_client.h) client, which was used by the private TDLib-based version of [telegram-cli](https://github.com/vysheng/tg). - - -## Using TDLib from G projects - -TDLib can be used from the G graphical programming language in LabVIEW development environment. - -See [TDLib bindings for LabVIEW](https://github.com/IvanLisRus/Telegram-Client_TDLib) for examples of such usage. - - -## Using TDLib from other programming languages - -You can use TDLib from any other programming language using [tdbot](https://github.com/vysheng/tdbot) or [TDLib JSON CLI](https://github.com/oott123/tdlib-json-cli), -which provide a command line tool for interaction with TDLIb using the [JSON](https://github.com/tdlib/td#using-json) interface through stdin and stdout. -You can use this method to use TDLib, for example, from Brainfuck (unfortunately, we haven't seen examples of sending a Telegram message through TDLib on Brainfuck yet). - -Alternatively, you can use the TDLib [JSON](https://github.com/tdlib/td#using-json) interface directly from your programming language. - -Feel free to create an issue, if you have created a valuable TDLib binding or a TDLib client in some programming language and want it to be added to this list of examples. diff --git a/protocols/Telegram/tdlib/td/example/android/.gitignore b/protocols/Telegram/tdlib/td/example/android/.gitignore deleted file mode 100644 index 7547413bf5..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -SDK/ -tdlib/ -third-party/ diff --git a/protocols/Telegram/tdlib/td/example/android/AddIntDef.php b/protocols/Telegram/tdlib/td/example/android/AddIntDef.php deleted file mode 100644 index d4ae4a65bd..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/AddIntDef.php +++ /dev/null @@ -1,51 +0,0 @@ -)? extends Object [{]/', - function ($val) use ($children) { - $values = implode(','.PHP_EOL, $children[$val[1]]); - return $val[0].<< $.debug - COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded $.debug -o $) -else() - add_subdirectory(${TD_DIR} td) - - set(TD_API_JAVA_PACKAGE "org/drinkless/tdlib") - set(TD_API_JAVA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${TD_API_JAVA_PACKAGE}/TdApi.java") - set(TD_API_TLO_PATH "${TD_DIR}/td/generate/auto/tlo/td_api.tlo") - set(TD_API_TL_PATH "${TD_DIR}/td/generate/scheme/td_api.tl") - set(JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH "${TD_DIR}/td/generate/JavadocTlDocumentationGenerator.php") - set(GENERATE_JAVA_CMD td_generate_java_api TdApi ${TD_API_TLO_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${TD_API_JAVA_PACKAGE}) - if (PHP_EXECUTABLE) - set(GENERATE_JAVA_CMD ${GENERATE_JAVA_CMD} && - ${PHP_EXECUTABLE} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH} ${TD_API_TL_PATH} ${TD_API_JAVA_PATH} androidx.annotation.Nullable @Nullable && - ${PHP_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/AddIntDef.php ${TD_API_JAVA_PATH}) - endif() - - file(MAKE_DIRECTORY ${TD_API_JAVA_PACKAGE}) - add_custom_target(tl_generate_java - COMMAND ${GENERATE_JAVA_CMD} - COMMENT "Generate Java TL source files" - DEPENDS td_generate_java_api tl_generate_tlo ${TD_API_TLO_PATH} ${TD_API_TL_PATH} - ) -endif() diff --git a/protocols/Telegram/tdlib/td/example/android/Dockerfile b/protocols/Telegram/tdlib/td/example/android/Dockerfile deleted file mode 100644 index 310e8f7eb1..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM --platform=linux/amd64 ubuntu:22.04 as build - -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq default-jdk g++ git gperf make perl php-cli unzip wget && rm -rf /var/lib/apt/lists/* - -WORKDIR /home - -ARG ANDROID_NDK_VERSION=23.2.8568313 -COPY ./check-environment.sh ./fetch-sdk.sh ./ -RUN ./fetch-sdk.sh SDK "$ANDROID_NDK_VERSION" - -ARG OPENSSL_VERSION=OpenSSL_1_1_1t -COPY ./build-openssl.sh ./ -RUN ./build-openssl.sh SDK "$ANDROID_NDK_VERSION" openssl "$OPENSSL_VERSION" - -ADD "https://api.github.com/repos/tdlib/td/git/refs/heads/master" version.json -ARG COMMIT_HASH=master -RUN git clone https://github.com/tdlib/td.git && cd td && git checkout "$COMMIT_HASH" -RUN cd td && git merge-base --is-ancestor bcd89728c3b93b67448b93b4863dc5bd4e122a4c "$COMMIT_HASH" - -ARG ANDROID_STL=c++_static -RUN td/example/android/build-tdlib.sh SDK "$ANDROID_NDK_VERSION" openssl "$ANDROID_STL" && rm -rf td/example/android/build-* - - -FROM scratch - -COPY --from=build /home/td/example/android/tdlib/tdlib* / diff --git a/protocols/Telegram/tdlib/td/example/android/README.md b/protocols/Telegram/tdlib/td/example/android/README.md deleted file mode 100644 index 6fa34fb6d2..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# TDLib Android example - -This is an example of building `TDLib` for Android. -You need a Bash shell on Linux, macOS, or Windows with some common tools, a C++ compiler, JDK, PHP, perl, and gperf pre-installed. - -## Building TDLib for Android - -* Run the script `./check-environment.sh` to check that you have all required Unix tools and Java utilities. If the script exits with an error message, install the missing tool. -* Run the script `./fetch-sdk.sh` to download Android SDK to a local directory. -* Run the script `./build-openssl.sh` to download and build OpenSSL for Android. -* Run the script `./build-tdlib.sh` to build TDLib for Android. -* The built libraries are now located in the `tdlib/libs` directory, corresponding Java code is located in the `tdlib/java` directory, and standalone Java documentation can be found in the `tdlib/javadoc` directory. You can also use archives `tdlib/tdlib.zip` and `tdlib/tdlib-debug.zip`, which contain all aforementioned data. - -If you already have installed Android SDK and NDK, you can skip the second step and specify existing Android SDK root path and Android NDK version as the first and the second parameters to the subsequent scripts. Make sure that the SDK includes android-33 platform and CMake 3.22.1. - -If you already have prebuilt OpenSSL, you can skip the third step and specify path to the prebuild OpenSSL as the third parameter to the script `./build-tdlib.sh`. - -If you want to update TDLib to a newer version, you need to run only the script `./build-tdlib.sh`. - -You can specify different OpenSSL version as the fourth parameter to the script `./build-openssl.sh`. By default OpenSSL 1.1.1 is used because of much smaller binary footprint and better performance than newer OpenSSL versions. - -You can build TDLib against shared standard C++ library by specifying "c++_shared" as the fourth parameter to the script `./build-tdlib.sh`. This can reduce total application size if you have a lot of other C++ code and want it to use the same shared library. - -Alternatively, you can use Docker to build TDLib for Android. Use `docker build --output tdlib .` to build the latest TDLib commit from Github, or `docker build --build-arg COMMIT_HASH= --output tdlib .` to build specific commit. The output archives will be placed in the tdlib directory as specified. diff --git a/protocols/Telegram/tdlib/td/example/android/build-openssl.sh b/protocols/Telegram/tdlib/td/example/android/build-openssl.sh deleted file mode 100644 index e4b82e06be..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/build-openssl.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -ANDROID_SDK_ROOT=${1:-SDK} -ANDROID_NDK_VERSION=${2:-23.2.8568313} -OPENSSL_INSTALL_DIR=${3:-third-party/openssl} -OPENSSL_VERSION=${4:-OpenSSL_1_1_1t} # openssl-3.1.0 - -if [ ! -d "$ANDROID_SDK_ROOT" ] ; then - echo "Error: directory \"$ANDROID_SDK_ROOT\" doesn't exist. Run ./fetch-sdk.sh first, or provide a valid path to Android SDK." - exit 1 -fi - -if [ -e "$OPENSSL_INSTALL_DIR" ] ; then - echo "Error: file or directory \"$OPENSSL_INSTALL_DIR\" already exists. Delete it manually to proceed." - exit 1 -fi - -source ./check-environment.sh || exit 1 - -mkdir -p $OPENSSL_INSTALL_DIR || exit 1 - -ANDROID_SDK_ROOT="$(cd "$(dirname -- "$ANDROID_SDK_ROOT")" >/dev/null; pwd -P)/$(basename -- "$ANDROID_SDK_ROOT")" -OPENSSL_INSTALL_DIR="$(cd "$(dirname -- "$OPENSSL_INSTALL_DIR")" >/dev/null; pwd -P)/$(basename -- "$OPENSSL_INSTALL_DIR")" - -cd $(dirname $0) - -echo "Downloading OpenSSL sources..." -rm -f $OPENSSL_VERSION.tar.gz || exit 1 -$WGET https://github.com/openssl/openssl/archive/refs/tags/$OPENSSL_VERSION.tar.gz || exit 1 -rm -rf ./openssl-$OPENSSL_VERSION || exit 1 -tar xzf $OPENSSL_VERSION.tar.gz || exit 1 -rm $OPENSSL_VERSION.tar.gz || exit 1 -cd openssl-$OPENSSL_VERSION - -export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION # for OpenSSL 3.0 -export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT # for OpenSSL 1.1.1 -PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_ARCH/bin:$PATH - -if ! clang --help >/dev/null 2>&1 ; then - echo "Error: failed to run clang from Android NDK." - if [[ "$OS_NAME" == "linux" ]] ; then - echo "Prebuilt Android NDK binaries are linked against glibc, so glibc must be installed." - fi - exit 1 -fi - -ANDROID_API32=16 -ANDROID_API64=21 -if [[ ${ANDROID_NDK_VERSION%%.*} -ge 24 ]] ; then - ANDROID_API32=19 -fi - -for ABI in arm64-v8a armeabi-v7a x86_64 x86 ; do - if [[ $ABI == "x86" ]] ; then - ./Configure android-x86 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API32 || exit 1 - elif [[ $ABI == "x86_64" ]] ; then - ./Configure android-x86_64 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API64 || exit 1 - elif [[ $ABI == "armeabi-v7a" ]] ; then - ./Configure android-arm no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API32 -D__ARM_MAX_ARCH__=8 || exit 1 - elif [[ $ABI == "arm64-v8a" ]] ; then - ./Configure android-arm64 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API64 || exit 1 - fi - - sed -i.bak 's/-O3/-O3 -ffunction-sections -fdata-sections/g' Makefile || exit 1 - - make depend -s || exit 1 - make -j4 -s || exit 1 - - mkdir -p $OPENSSL_INSTALL_DIR/$ABI/lib/ || exit 1 - cp libcrypto.a libssl.a $OPENSSL_INSTALL_DIR/$ABI/lib/ || exit 1 - cp -r include $OPENSSL_INSTALL_DIR/$ABI/ || exit 1 - - make distclean || exit 1 -done - -cd .. - -rm -rf ./openssl-$OPENSSL_VERSION || exit 1 diff --git a/protocols/Telegram/tdlib/td/example/android/build-tdlib.sh b/protocols/Telegram/tdlib/td/example/android/build-tdlib.sh deleted file mode 100644 index 1ff9ae7af2..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/build-tdlib.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash - -ANDROID_SDK_ROOT=${1:-SDK} -ANDROID_NDK_VERSION=${2:-23.2.8568313} -OPENSSL_INSTALL_DIR=${3:-third-party/openssl} -ANDROID_STL=${4:-c++_static} - -if [ "$ANDROID_STL" != "c++_static" ] && [ "$ANDROID_STL" != "c++_shared" ] ; then - echo 'Error: ANDROID_STL must be either "c++_static" or "c++_shared".' - exit 1 -fi - -source ./check-environment.sh || exit 1 - -if [ ! -d "$ANDROID_SDK_ROOT" ] ; then - echo "Error: directory \"$ANDROID_SDK_ROOT\" doesn't exist. Run ./fetch-sdk.sh first, or provide a valid path to Android SDK." - exit 1 -fi - -if [ ! -d "$OPENSSL_INSTALL_DIR" ] ; then - echo "Error: directory \"$OPENSSL_INSTALL_DIR\" doesn't exists. Run ./build-openssl.sh first." - exit 1 -fi - -ANDROID_SDK_ROOT="$(cd "$(dirname -- "$ANDROID_SDK_ROOT")" >/dev/null; pwd -P)/$(basename -- "$ANDROID_SDK_ROOT")" -ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION" -OPENSSL_INSTALL_DIR="$(cd "$(dirname -- "$OPENSSL_INSTALL_DIR")" >/dev/null; pwd -P)/$(basename -- "$OPENSSL_INSTALL_DIR")" -PATH=$ANDROID_SDK_ROOT/cmake/3.22.1/bin:$PATH - -cd $(dirname $0) - -echo "Downloading annotation Java package..." -rm -f android.jar annotation-1.4.0.jar || exit 1 -$WGET https://maven.google.com/androidx/annotation/annotation/1.4.0/annotation-1.4.0.jar || exit 1 - -echo "Generating TDLib source files..." -mkdir -p build-native || exit 1 -cd build-native -cmake .. || exit 1 -cmake --build . --target prepare_cross_compiling || exit 1 -cmake --build . --target tl_generate_java || exit 1 -cd .. -php AddIntDef.php org/drinkless/tdlib/TdApi.java || exit 1 - -echo "Copying Java source files..." -rm -rf tdlib || exit 1 -mkdir -p tdlib/java/org/drinkless/tdlib || exit 1 -cp -p {../../example,tdlib}/java/org/drinkless/tdlib/Client.java || exit 1 -mv {,tdlib/java/}org/drinkless/tdlib/TdApi.java || exit 1 -rm -rf org || exit 1 - -echo "Generating Javadoc documentation..." -cp "$ANDROID_SDK_ROOT/platforms/android-33/android.jar" . || exit 1 -JAVADOC_SEPARATOR=$([ "$OS_NAME" == "win" ] && echo ";" || echo ":") -javadoc -d tdlib/javadoc -encoding UTF-8 -charset UTF-8 -classpath "android.jar${JAVADOC_SEPARATOR}annotation-1.4.0.jar" -quiet -sourcepath tdlib/java org.drinkless.tdlib || exit 1 -rm android.jar annotation-1.4.0.jar || exit 1 - -echo "Building TDLib..." -for ABI in arm64-v8a armeabi-v7a x86_64 x86 ; do - mkdir -p build-$ABI || exit 1 - cd build-$ABI - cmake -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake" -DOPENSSL_ROOT_DIR="$OPENSSL_INSTALL_DIR/$ABI" -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja -DANDROID_ABI=$ABI -DANDROID_STL=$ANDROID_STL -DANDROID_PLATFORM=android-16 .. || exit 1 - cmake --build . || exit 1 - cd .. - - mkdir -p tdlib/libs/$ABI/ || exit 1 - cp -p build-$ABI/libtd*.so* tdlib/libs/$ABI/ || exit 1 - if [[ "$ANDROID_STL" == "c++_shared" ]] ; then - if [[ "$ABI" == "arm64-v8a" ]] ; then - FULL_ABI="aarch64-linux-android" - elif [[ "$ABI" == "armeabi-v7a" ]] ; then - FULL_ABI="arm-linux-androideabi" - elif [[ "$ABI" == "x86_64" ]] ; then - FULL_ABI="x86_64-linux-android" - elif [[ "$ABI" == "x86" ]] ; then - FULL_ABI="i686-linux-android" - fi - cp "$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_ARCH/sysroot/usr/lib/$FULL_ABI/libc++_shared.so" tdlib/libs/$ABI/ || exit 1 - "$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_ARCH/bin/llvm-strip" tdlib/libs/$ABI/libc++_shared.so || exit 1 - fi -done - -echo "Compressing..." -rm -f tdlib.zip tdlib-debug.zip || exit 1 -jar -cMf tdlib-debug.zip tdlib || exit 1 -rm tdlib/libs/*/*.debug || exit 1 -jar -cMf tdlib.zip tdlib || exit 1 -mv tdlib.zip tdlib-debug.zip tdlib || exit 1 - -echo "Done." diff --git a/protocols/Telegram/tdlib/td/example/android/check-environment.sh b/protocols/Telegram/tdlib/td/example/android/check-environment.sh deleted file mode 100644 index 249df33987..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/check-environment.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -# The script checks that all needed tools are installed and sets OS_NAME, HOST_ARCH, and WGET variables - -if [[ "$OSTYPE" == "linux"* ]] ; then - OS_NAME="linux" - HOST_ARCH="linux-x86_64" -elif [[ "$OSTYPE" == "darwin"* ]] ; then - OS_NAME="mac" - HOST_ARCH="darwin-x86_64" -elif [[ "$OSTYPE" == "msys" ]] ; then - OS_NAME="win" - HOST_ARCH="windows-x86_64" -else - echo "Error: this script supports only Bash shell on Linux, macOS, or Windows." - exit 1 -fi - -if which wget >/dev/null 2>&1 ; then - WGET="wget -q" -elif which curl >/dev/null 2>&1 ; then - WGET="curl -sfLO" -else - echo "Error: this script requires either curl or wget tool installed." - exit 1 -fi - -for TOOL_NAME in gperf jar java javadoc make perl php sed tar yes unzip ; do - if ! which "$TOOL_NAME" >/dev/null 2>&1 ; then - echo "Error: this script requires $TOOL_NAME tool installed." - exit 1 - fi -done - -if [[ $(which make) = *" "* ]] ; then - echo "Error: OpenSSL expects that full path to make tool doesn't contain spaces. Move it to some other place." - exit 1 -fi - -if ! perl -MExtUtils::MakeMaker -MLocale::Maketext::Simple -MPod::Usage -e '' >/dev/null 2>&1 ; then - echo "Error: Perl installation is broken." - if [[ "$OSTYPE" == "msys" ]] ; then - echo "For Git Bash you need to manually copy ExtUtils, Locale and Pod modules to /usr/share/perl5/core_perl from any compatible Perl installation." - fi - exit 1 -fi - -if ! java --help >/dev/null 2>&1 ; then - echo "Error: Java installation is broken. Install JDK from https://www.oracle.com/java/technologies/downloads/." - exit 1 -fi diff --git a/protocols/Telegram/tdlib/td/example/android/fetch-sdk.sh b/protocols/Telegram/tdlib/td/example/android/fetch-sdk.sh deleted file mode 100644 index 61d93170a5..0000000000 --- a/protocols/Telegram/tdlib/td/example/android/fetch-sdk.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -ANDROID_SDK_ROOT=${1:-SDK} -ANDROID_NDK_VERSION=${2:-23.2.8568313} - -if [ -e "$ANDROID_SDK_ROOT" ] ; then - echo "Error: file or directory \"$ANDROID_SDK_ROOT\" already exists. Delete it manually to proceed." - exit 1 -fi - -source ./check-environment.sh || exit 1 - -SDKMANAGER="./sdkmanager" -if [[ "$OS_NAME" == "win" ]] ; then - SDKMANAGER="./sdkmanager.bat" -fi - -echo "Downloading SDK Manager..." -mkdir -p "$ANDROID_SDK_ROOT" || exit 1 -cd "$ANDROID_SDK_ROOT" || exit 1 -$WGET "https://dl.google.com/android/repository/commandlinetools-$OS_NAME-8512546_latest.zip" || exit 1 -mkdir -p cmdline-tools || exit 1 -unzip -qq "commandlinetools-$OS_NAME-8512546_latest.zip" -d cmdline-tools || exit 1 -rm "commandlinetools-$OS_NAME-8512546_latest.zip" || exit 1 -mv cmdline-tools/* cmdline-tools/latest/ || exit 1 - -echo "Installing required SDK tools..." -cd cmdline-tools/latest/bin/ || exit 1 -yes | $SDKMANAGER --licenses >/dev/null || exit 1 -$SDKMANAGER --install "ndk;$ANDROID_NDK_VERSION" "cmake;3.22.1" "build-tools;33.0.0" "platforms;android-33" > /dev/null || exit 1 diff --git a/protocols/Telegram/tdlib/td/example/cpp/.gitignore b/protocols/Telegram/tdlib/td/example/cpp/.gitignore deleted file mode 100644 index 336dc7d458..0000000000 --- a/protocols/Telegram/tdlib/td/example/cpp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -td/ diff --git a/protocols/Telegram/tdlib/td/example/cpp/CMakeLists.txt b/protocols/Telegram/tdlib/td/example/cpp/CMakeLists.txt deleted file mode 100644 index 19c4d11011..0000000000 --- a/protocols/Telegram/tdlib/td/example/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4 FATAL_ERROR) - -project(TdExample VERSION 1.0 LANGUAGES CXX) - -find_package(Td 1.8.14 REQUIRED) - -add_executable(tdjson_example tdjson_example.cpp) -target_link_libraries(tdjson_example PRIVATE Td::TdJson) -set_property(TARGET tdjson_example PROPERTY CXX_STANDARD 11) - -add_executable(td_example td_example.cpp) -target_link_libraries(td_example PRIVATE Td::TdStatic) -set_property(TARGET td_example PROPERTY CXX_STANDARD 14) diff --git a/protocols/Telegram/tdlib/td/example/cpp/README.md b/protocols/Telegram/tdlib/td/example/cpp/README.md deleted file mode 100644 index c8ee34d4fa..0000000000 --- a/protocols/Telegram/tdlib/td/example/cpp/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# TDLib C++ basic usage examples - -TDLib should be prebuilt and installed to local subdirectory `td/`: -``` -cd -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../example/cpp/td .. -cmake --build . --target install -``` -Also, see [building](https://github.com/tdlib/td#building) for additional details on TDLib building. - -After this you can build the examples: -``` -cd /example/cpp -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DTd_DIR=/example/cpp/td/lib/cmake/Td .. -cmake --build . -``` - -Documentation for all available classes and methods can be found at https://core.telegram.org/tdlib/docs. - -To run the examples you may need to manually copy needed shared libraries from `td/bin` to a directory containing built binaries. diff --git a/protocols/Telegram/tdlib/td/example/cpp/td_example.cpp b/protocols/Telegram/tdlib/td/example/cpp/td_example.cpp deleted file mode 100644 index b30afa8070..0000000000 --- a/protocols/Telegram/tdlib/td/example/cpp/td_example.cpp +++ /dev/null @@ -1,338 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// Simple single-threaded example of TDLib usage. -// Real world programs should use separate thread for the user input. -// Example includes user authentication, receiving updates, getting chat list and sending text messages. - -// overloaded -namespace detail { -template -struct overload; - -template -struct overload : public F { - explicit overload(F f) : F(f) { - } -}; -template -struct overload - : public overload - , public overload { - overload(F f, Fs... fs) : overload(f), overload(fs...) { - } - using overload::operator(); - using overload::operator(); -}; -} // namespace detail - -template -auto overloaded(F... f) { - return detail::overload(f...); -} - -namespace td_api = td::td_api; - -class TdExample { - public: - TdExample() { - td::ClientManager::execute(td_api::make_object(1)); - client_manager_ = std::make_unique(); - client_id_ = client_manager_->create_client_id(); - send_query(td_api::make_object("version"), {}); - } - - void loop() { - while (true) { - if (need_restart_) { - restart(); - } else if (!are_authorized_) { - process_response(client_manager_->receive(10)); - } else { - std::cout << "Enter action [q] quit [u] check for updates and request results [c] show chats [m " - "] send message [me] show self [l] logout: " - << std::endl; - std::string line; - std::getline(std::cin, line); - std::istringstream ss(line); - std::string action; - if (!(ss >> action)) { - continue; - } - if (action == "q") { - return; - } - if (action == "u") { - std::cout << "Checking for updates..." << std::endl; - while (true) { - auto response = client_manager_->receive(0); - if (response.object) { - process_response(std::move(response)); - } else { - break; - } - } - } else if (action == "close") { - std::cout << "Closing..." << std::endl; - send_query(td_api::make_object(), {}); - } else if (action == "me") { - send_query(td_api::make_object(), - [this](Object object) { std::cout << to_string(object) << std::endl; }); - } else if (action == "l") { - std::cout << "Logging out..." << std::endl; - send_query(td_api::make_object(), {}); - } else if (action == "m") { - std::int64_t chat_id; - ss >> chat_id; - ss.get(); - std::string text; - std::getline(ss, text); - - std::cout << "Sending message to chat " << chat_id << "..." << std::endl; - auto send_message = td_api::make_object(); - send_message->chat_id_ = chat_id; - auto message_content = td_api::make_object(); - message_content->text_ = td_api::make_object(); - message_content->text_->text_ = std::move(text); - send_message->input_message_content_ = std::move(message_content); - - send_query(std::move(send_message), {}); - } else if (action == "c") { - std::cout << "Loading chat list..." << std::endl; - send_query(td_api::make_object(nullptr, 20), [this](Object object) { - if (object->get_id() == td_api::error::ID) { - return; - } - auto chats = td::move_tl_object_as(object); - for (auto chat_id : chats->chat_ids_) { - std::cout << "[chat_id:" << chat_id << "] [title:" << chat_title_[chat_id] << "]" << std::endl; - } - }); - } - } - } - } - - private: - using Object = td_api::object_ptr; - std::unique_ptr client_manager_; - std::int32_t client_id_{0}; - - td_api::object_ptr authorization_state_; - bool are_authorized_{false}; - bool need_restart_{false}; - std::uint64_t current_query_id_{0}; - std::uint64_t authentication_query_id_{0}; - - std::map> handlers_; - - std::map> users_; - - std::map chat_title_; - - void restart() { - client_manager_.reset(); - *this = TdExample(); - } - - void send_query(td_api::object_ptr f, std::function handler) { - auto query_id = next_query_id(); - if (handler) { - handlers_.emplace(query_id, std::move(handler)); - } - client_manager_->send(client_id_, query_id, std::move(f)); - } - - void process_response(td::ClientManager::Response response) { - if (!response.object) { - return; - } - //std::cout << response.request_id << " " << to_string(response.object) << std::endl; - if (response.request_id == 0) { - return process_update(std::move(response.object)); - } - auto it = handlers_.find(response.request_id); - if (it != handlers_.end()) { - it->second(std::move(response.object)); - handlers_.erase(it); - } - } - - std::string get_user_name(std::int64_t user_id) const { - auto it = users_.find(user_id); - if (it == users_.end()) { - return "unknown user"; - } - return it->second->first_name_ + " " + it->second->last_name_; - } - - std::string get_chat_title(std::int64_t chat_id) const { - auto it = chat_title_.find(chat_id); - if (it == chat_title_.end()) { - return "unknown chat"; - } - return it->second; - } - - void process_update(td_api::object_ptr update) { - td_api::downcast_call( - *update, overloaded( - [this](td_api::updateAuthorizationState &update_authorization_state) { - authorization_state_ = std::move(update_authorization_state.authorization_state_); - on_authorization_state_update(); - }, - [this](td_api::updateNewChat &update_new_chat) { - chat_title_[update_new_chat.chat_->id_] = update_new_chat.chat_->title_; - }, - [this](td_api::updateChatTitle &update_chat_title) { - chat_title_[update_chat_title.chat_id_] = update_chat_title.title_; - }, - [this](td_api::updateUser &update_user) { - auto user_id = update_user.user_->id_; - users_[user_id] = std::move(update_user.user_); - }, - [this](td_api::updateNewMessage &update_new_message) { - auto chat_id = update_new_message.message_->chat_id_; - std::string sender_name; - td_api::downcast_call(*update_new_message.message_->sender_id_, - overloaded( - [this, &sender_name](td_api::messageSenderUser &user) { - sender_name = get_user_name(user.user_id_); - }, - [this, &sender_name](td_api::messageSenderChat &chat) { - sender_name = get_chat_title(chat.chat_id_); - })); - std::string text; - if (update_new_message.message_->content_->get_id() == td_api::messageText::ID) { - text = static_cast(*update_new_message.message_->content_).text_->text_; - } - std::cout << "Receive message: [chat_id:" << chat_id << "] [from:" << sender_name << "] [" - << text << "]" << std::endl; - }, - [](auto &update) {})); - } - - auto create_authentication_query_handler() { - return [this, id = authentication_query_id_](Object object) { - if (id == authentication_query_id_) { - check_authentication_error(std::move(object)); - } - }; - } - - void on_authorization_state_update() { - authentication_query_id_++; - td_api::downcast_call(*authorization_state_, - overloaded( - [this](td_api::authorizationStateReady &) { - are_authorized_ = true; - std::cout << "Authorization is completed" << std::endl; - }, - [this](td_api::authorizationStateLoggingOut &) { - are_authorized_ = false; - std::cout << "Logging out" << std::endl; - }, - [this](td_api::authorizationStateClosing &) { std::cout << "Closing" << std::endl; }, - [this](td_api::authorizationStateClosed &) { - are_authorized_ = false; - need_restart_ = true; - std::cout << "Terminated" << std::endl; - }, - [this](td_api::authorizationStateWaitPhoneNumber &) { - std::cout << "Enter phone number: " << std::flush; - std::string phone_number; - std::cin >> phone_number; - send_query( - td_api::make_object(phone_number, nullptr), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitEmailAddress &) { - std::cout << "Enter email address: " << std::flush; - std::string email_address; - std::cin >> email_address; - send_query(td_api::make_object(email_address), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitEmailCode &) { - std::cout << "Enter email authentication code: " << std::flush; - std::string code; - std::cin >> code; - send_query(td_api::make_object( - td_api::make_object(code)), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitCode &) { - std::cout << "Enter authentication code: " << std::flush; - std::string code; - std::cin >> code; - send_query(td_api::make_object(code), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitRegistration &) { - std::string first_name; - std::string last_name; - std::cout << "Enter your first name: " << std::flush; - std::cin >> first_name; - std::cout << "Enter your last name: " << std::flush; - std::cin >> last_name; - send_query(td_api::make_object(first_name, last_name), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitPassword &) { - std::cout << "Enter authentication password: " << std::flush; - std::string password; - std::getline(std::cin, password); - send_query(td_api::make_object(password), - create_authentication_query_handler()); - }, - [this](td_api::authorizationStateWaitOtherDeviceConfirmation &state) { - std::cout << "Confirm this login link on another device: " << state.link_ << std::endl; - }, - [this](td_api::authorizationStateWaitTdlibParameters &) { - auto request = td_api::make_object(); - request->database_directory_ = "tdlib"; - request->use_message_database_ = true; - request->use_secret_chats_ = true; - request->api_id_ = 94575; - request->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2"; - request->system_language_code_ = "en"; - request->device_model_ = "Desktop"; - request->application_version_ = "1.0"; - request->enable_storage_optimizer_ = true; - send_query(std::move(request), create_authentication_query_handler()); - })); - } - - void check_authentication_error(Object object) { - if (object->get_id() == td_api::error::ID) { - auto error = td::move_tl_object_as(object); - std::cout << "Error: " << to_string(error) << std::flush; - on_authorization_state_update(); - } - } - - std::uint64_t next_query_id() { - return ++current_query_id_; - } -}; - -int main() { - TdExample example; - example.loop(); -} diff --git a/protocols/Telegram/tdlib/td/example/cpp/tdjson_example.cpp b/protocols/Telegram/tdlib/td/example/cpp/tdjson_example.cpp deleted file mode 100644 index 29a9be04be..0000000000 --- a/protocols/Telegram/tdlib/td/example/cpp/tdjson_example.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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 -#include - -// Basic example of TDLib JSON interface usage. -// Native interface should be preferred instead in C++, so here is only an example of -// the main event cycle, which should be essentially the same for all languages. - -int main() { - // disable TDLib logging - td_execute("{\"@type\":\"setLogVerbosityLevel\", \"new_verbosity_level\":0}"); - - int client_id = td_create_client_id(); - // somehow share the client_id with other threads, which will be able to send requests via td_send - - // start the client by sending request to it - td_send(client_id, "{\"@type\":\"getOption\", \"name\":\"version\"}"); - - const bool test_incorrect_queries = false; - if (test_incorrect_queries) { - td_execute("{\"@type\":\"setLogVerbosityLevel\", \"new_verbosity_level\":1}"); - td_execute(""); - td_execute("test"); - td_execute("\"test\""); - td_execute("{\"@type\":\"test\", \"@extra\":1}"); - - td_send(client_id, "{\"@type\":\"getFileMimeType\"}"); - td_send(client_id, "{\"@type\":\"getFileMimeType\", \"@extra\":1}"); - td_send(client_id, "{\"@type\":\"getFileMimeType\", \"@extra\":null}"); - td_send(client_id, "{\"@type\":\"test\"}"); - td_send(client_id, "[]"); - td_send(client_id, "{\"@type\":\"test\", \"@extra\":1}"); - td_send(client_id, "{\"@type\":\"sendMessage\", \"chat_id\":true, \"@extra\":1}"); - td_send(client_id, "test"); - } - - const double WAIT_TIMEOUT = 10.0; // seconds - while (true) { - const char *result = td_receive(WAIT_TIMEOUT); - if (result != nullptr) { - // parse the result as a JSON object and process it as an incoming update or an answer to a previously sent request - - // if (result is UpdateAuthorizationState with authorizationStateClosed) { - // break; - // } - - std::cout << result << std::endl; - } - } -} diff --git a/protocols/Telegram/tdlib/td/example/csharp/.gitignore b/protocols/Telegram/tdlib/td/example/csharp/.gitignore deleted file mode 100644 index 5266ecccc9..0000000000 --- a/protocols/Telegram/tdlib/td/example/csharp/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.vs/ -bin/ -obj/ -project.lock.json -TdExample.csproj.user diff --git a/protocols/Telegram/tdlib/td/example/csharp/README.md b/protocols/Telegram/tdlib/td/example/csharp/README.md deleted file mode 100644 index efa0490ecc..0000000000 --- a/protocols/Telegram/tdlib/td/example/csharp/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# TDLib C# example - -This is an example of building TDLib with `C++/CLI` support and an example of TDLib usage from C#. - -## Building TDLib - -* Download and install Microsoft Visual Studio 2015 or later. -* Download and install [CMake](https://cmake.org/download/); choose "Add CMake to the system PATH" option while installing. -* Install `gperf`, `zlib`, and `openssl` using [vcpkg](https://github.com/Microsoft/vcpkg#quick-start): -``` -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -git checkout 1b1ae50e1a69f7c659bd7d731e80b358d21c86ad -.\bootstrap-vcpkg.bat -.\vcpkg.exe install gperf:x64-windows gperf:x86-windows openssl:x64-windows openssl:x86-windows zlib:x64-windows zlib:x86-windows -``` -* (Optional. For XML documentation generation.) Download [PHP](https://windows.php.net/download). Add the path to php.exe to the PATH environment variable. -* Build `TDLib` with CMake enabling `.NET` support and specifying correct path to `vcpkg` toolchain file: -``` -cd /example/csharp -mkdir build -cd build -cmake -A Win32 -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake ../../.. -cmake --build . --config Release -cmake --build . --config Debug -cd .. -mkdir build64 -cd build64 -cmake -A x64 -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake ../../.. -cmake --build . --config Release -cmake --build . --config Debug -``` - -## Example of usage - -After `TDLib` is built you can open and run TdExample project. -It contains a simple console C# application with implementation of authorization and message sending. -Just open it with Visual Studio 2015 or later and run. - -Also, see TdExample.csproj for example of including TDLib in C# project with all native shared library dependencies. diff --git a/protocols/Telegram/tdlib/td/example/csharp/TdExample.cs b/protocols/Telegram/tdlib/td/example/csharp/TdExample.cs deleted file mode 100644 index 3cb1949d6a..0000000000 --- a/protocols/Telegram/tdlib/td/example/csharp/TdExample.cs +++ /dev/null @@ -1,294 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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) -// - -using Td = Telegram.Td; -using TdApi = Telegram.Td.Api; - -using System; -using System.Threading; - -namespace TdExample -{ - /// - /// Example class for TDLib usage from C#. - /// - class Example - { - private static Td.Client _client = null; - private readonly static Td.ClientResultHandler _defaultHandler = new DefaultHandler(); - - private static TdApi.AuthorizationState _authorizationState = null; - private static volatile bool _haveAuthorization = false; - private static volatile bool _needQuit = false; - private static volatile bool _canQuit = false; - - private static volatile AutoResetEvent _gotAuthorization = new AutoResetEvent(false); - - private static readonly string _newLine = Environment.NewLine; - private static readonly string _commandsLine = "Enter command (gc - GetChat, me - GetMe, sm - SendMessage, lo - LogOut, r - Restart, q - Quit): "; - private static volatile string _currentPrompt = null; - - private static Td.Client CreateTdClient() - { - return Td.Client.Create(new UpdateHandler()); - } - - private static void Print(string str) - { - if (_currentPrompt != null) - { - Console.WriteLine(); - } - Console.WriteLine(str); - if (_currentPrompt != null) - { - Console.Write(_currentPrompt); - } - } - - private static string ReadLine(string str) - { - Console.Write(str); - _currentPrompt = str; - var result = Console.ReadLine(); - _currentPrompt = null; - return result; - } - - private static void OnAuthorizationStateUpdated(TdApi.AuthorizationState authorizationState) - { - if (authorizationState != null) - { - _authorizationState = authorizationState; - } - if (_authorizationState is TdApi.AuthorizationStateWaitTdlibParameters) - { - TdApi.SetTdlibParameters request = new TdApi.SetTdlibParameters(); - request.DatabaseDirectory = "tdlib"; - request.UseMessageDatabase = true; - request.UseSecretChats = true; - request.ApiId = 94575; - request.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2"; - request.SystemLanguageCode = "en"; - request.DeviceModel = "Desktop"; - request.ApplicationVersion = "1.0"; - request.EnableStorageOptimizer = true; - - _client.Send(request, new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitPhoneNumber) - { - string phoneNumber = ReadLine("Please enter phone number: "); - _client.Send(new TdApi.SetAuthenticationPhoneNumber(phoneNumber, null), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitEmailAddress) - { - string emailAddress = ReadLine("Please enter email address: "); - _client.Send(new TdApi.SetAuthenticationEmailAddress(emailAddress), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitEmailCode) - { - string code = ReadLine("Please enter email authentication code: "); - _client.Send(new TdApi.CheckAuthenticationEmailCode(new TdApi.EmailAddressAuthenticationCode(code)), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitOtherDeviceConfirmation state) - { - Console.WriteLine("Please confirm this login link on another device: " + state.Link); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitCode) - { - string code = ReadLine("Please enter authentication code: "); - _client.Send(new TdApi.CheckAuthenticationCode(code), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitRegistration) - { - string firstName = ReadLine("Please enter your first name: "); - string lastName = ReadLine("Please enter your last name: "); - _client.Send(new TdApi.RegisterUser(firstName, lastName), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateWaitPassword) - { - string password = ReadLine("Please enter password: "); - _client.Send(new TdApi.CheckAuthenticationPassword(password), new AuthorizationRequestHandler()); - } - else if (_authorizationState is TdApi.AuthorizationStateReady) - { - _haveAuthorization = true; - _gotAuthorization.Set(); - } - else if (_authorizationState is TdApi.AuthorizationStateLoggingOut) - { - _haveAuthorization = false; - Print("Logging out"); - } - else if (_authorizationState is TdApi.AuthorizationStateClosing) - { - _haveAuthorization = false; - Print("Closing"); - } - else if (_authorizationState is TdApi.AuthorizationStateClosed) - { - Print("Closed"); - if (!_needQuit) - { - _client = CreateTdClient(); // recreate _client after previous has closed - } else { - _canQuit = true; - } - } - else - { - Print("Unsupported authorization state:" + _newLine + _authorizationState); - } - } - - private static long GetChatId(string arg) - { - long chatId = 0; - try - { - chatId = Convert.ToInt64(arg); - } - catch (FormatException) - { - } - catch (OverflowException) - { - } - return chatId; - } - - private static void GetCommand() - { - string command = ReadLine(_commandsLine); - string[] commands = command.Split(new char[] { ' ' }, 2); - try - { - switch (commands[0]) - { - case "gc": - _client.Send(new TdApi.GetChat(GetChatId(commands[1])), _defaultHandler); - break; - case "me": - _client.Send(new TdApi.GetMe(), _defaultHandler); - break; - case "sm": - string[] args = commands[1].Split(new char[] { ' ' }, 2); - sendMessage(GetChatId(args[0]), args[1]); - break; - case "lo": - _haveAuthorization = false; - _client.Send(new TdApi.LogOut(), _defaultHandler); - break; - case "r": - _haveAuthorization = false; - _client.Send(new TdApi.Close(), _defaultHandler); - break; - case "q": - _needQuit = true; - _haveAuthorization = false; - _client.Send(new TdApi.Close(), _defaultHandler); - break; - default: - Print("Unsupported command: " + command); - break; - } - } - catch (IndexOutOfRangeException) - { - Print("Not enough arguments"); - } - } - - private static void sendMessage(long chatId, string message) - { - // initialize reply markup just for testing - TdApi.InlineKeyboardButton[] row = { new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl()) }; - TdApi.ReplyMarkup replyMarkup = new TdApi.ReplyMarkupInlineKeyboard(new TdApi.InlineKeyboardButton[][] { row, row, row }); - - TdApi.InputMessageContent content = new TdApi.InputMessageText(new TdApi.FormattedText(message, null), false, true); - _client.Send(new TdApi.SendMessage(chatId, 0, 0, null, replyMarkup, content), _defaultHandler); - } - - static void Main() - { - // disable TDLib log - Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0)); - if (Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, false))) is TdApi.Error) - { - throw new System.IO.IOException("Write access to the current directory is required"); - } - new Thread(() => - { - Thread.CurrentThread.IsBackground = true; - Td.Client.Run(); - }).Start(); - - // create Td.Client - _client = CreateTdClient(); - - // test Client.Execute - _defaultHandler.OnResult(Td.Client.Execute(new TdApi.GetTextEntities("@telegram /test_command https://telegram.org telegram.me @gif @test"))); - - // main loop - while (!_needQuit) - { - // await authorization - _gotAuthorization.Reset(); - _gotAuthorization.WaitOne(); - - _client.Send(new TdApi.LoadChats(null, 100), _defaultHandler); // preload main chat list - while (_haveAuthorization) - { - GetCommand(); - } - } - while (!_canQuit) { - Thread.Sleep(1); - } - } - - private class DefaultHandler : Td.ClientResultHandler - { - void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) - { - Print(@object.ToString()); - } - } - - private class UpdateHandler : Td.ClientResultHandler - { - void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) - { - if (@object is TdApi.UpdateAuthorizationState) - { - OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState); - } - else - { - // Print("Unsupported update: " + @object); - } - } - } - - private class AuthorizationRequestHandler : Td.ClientResultHandler - { - void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) - { - if (@object is TdApi.Error) - { - Print("Receive an error:" + _newLine + @object); - OnAuthorizationStateUpdated(null); // repeat last action - } - else - { - // result is already received through UpdateAuthorizationState, nothing to do - } - } - } - } -} diff --git a/protocols/Telegram/tdlib/td/example/csharp/TdExample.csproj b/protocols/Telegram/tdlib/td/example/csharp/TdExample.csproj deleted file mode 100644 index 6a511d8f74..0000000000 --- a/protocols/Telegram/tdlib/td/example/csharp/TdExample.csproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - Debug - x86 - {3F9A93EA-DC26-4F8B-ACE0-131B33B00CA7} - Exe - false - ConsoleApplication - v4.0 - Client - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - x86 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - x86 - - - TdExample - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - False - build\$(Configuration)\Telegram.Td.dll - build64\$(Configuration)\Telegram.Td.dll - - - - - - - - zlibd1.dll - PreserveNewest - - - - - zlib1.dll - PreserveNewest - - - - - zlibd1.dll - PreserveNewest - - - - - zlib1.dll - PreserveNewest - - - - - libcrypto-1_1.dll - PreserveNewest - - - libssl-1_1.dll - PreserveNewest - - - - - libcrypto-1_1-x64.dll - PreserveNewest - - - libssl-1_1-x64.dll - PreserveNewest - - - - - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/td/example/ios/Python-Apple-support.patch b/protocols/Telegram/tdlib/td/example/ios/Python-Apple-support.patch deleted file mode 100644 index 3650d008bc..0000000000 --- a/protocols/Telegram/tdlib/td/example/ios/Python-Apple-support.patch +++ /dev/null @@ -1,105 +0,0 @@ -diff --git a/Makefile b/Makefile -index 695be54..eda7b0d 100644 ---- a/Makefile -+++ b/Makefile -@@ -7,8 +7,11 @@ - # - watchOS - build everything for watchOS - # - OpenSSL-macOS - build OpenSSL for macOS - # - OpenSSL-iOS - build OpenSSL for iOS -+# - OpenSSL-iOS-simulator - build OpenSSL for iOS-simulator - # - OpenSSL-tvOS - build OpenSSL for tvOS -+# - OpenSSL-tvOS-simulator - build OpenSSL for tvOS-simulator - # - OpenSSL-watchOS - build OpenSSL for watchOS -+# - OpenSSL-watchOS-simulator - build OpenSSL for watchOS-simulator - # - BZip2-macOS - build BZip2 for macOS - # - BZip2-iOS - build BZip2 for iOS - # - BZip2-tvOS - build BZip2 for tvOS -@@ -30,37 +33,52 @@ PYTHON_VERSION=2.7.14 - PYTHON_VER=$(basename $(PYTHON_VERSION)) - - OPENSSL_VERSION_NUMBER=1.0.2 --OPENSSL_REVISION=n -+OPENSSL_REVISION=u - OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION) - - BZIP2_VERSION=1.0.6 - - # Supported OS --OS=macOS iOS tvOS watchOS -+OS=macOS iOS iOS-simulator tvOS tvOS-simulator watchOS watchOS-simulator - - # macOS targets --TARGETS-macOS=macosx.x86_64 -+TARGETS-macOS=macosx.arm64 macosx.x86_64 -+PYTHON_TARGETS-macOS=macOS - CFLAGS-macOS=-mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) - - # iOS targets --TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.i386 iphoneos.armv7 iphoneos.armv7s iphoneos.arm64 -+TARGETS-iOS=iphoneos.armv7 iphoneos.armv7s iphoneos.arm64 - CFLAGS-iOS=-mios-version-min=7.0 --CFLAGS-iphoneos.armv7=-fembed-bitcode --CFLAGS-iphoneos.armv7s=-fembed-bitcode --CFLAGS-iphoneos.arm64=-fembed-bitcode -+CFLAGS-iphoneos.armv7= -+CFLAGS-iphoneos.armv7s= -+CFLAGS-iphoneos.arm64= -+ -+# iOS-simulator targets -+TARGETS-iOS-simulator=iphonesimulator.x86_64 iphonesimulator.i386 iphonesimulator.arm64 -+CFLAGS-iOS-simulator=-mios-simulator-version-min=7.0 - - # tvOS targets --TARGETS-tvOS=appletvsimulator.x86_64 appletvos.arm64 -+TARGETS-tvOS=appletvos.arm64 - CFLAGS-tvOS=-mtvos-version-min=9.0 --CFLAGS-appletvos.arm64=-fembed-bitcode -+CFLAGS-appletvos.arm64= - PYTHON_CONFIGURE-tvOS=ac_cv_func_sigaltstack=no - -+# tvOS-simulator targets -+TARGETS-tvOS-simulator=appletvsimulator.x86_64 appletvsimulator.arm64 -+CFLAGS-tvOS-simulator=-mtvos-simulator-version-min=9.0 -+ - # watchOS targets --TARGETS-watchOS=watchsimulator.i386 watchos.armv7k -+TARGETS-watchOS=watchos.armv7k watchos.arm64_32 watchos.arm64 - CFLAGS-watchOS=-mwatchos-version-min=4.0 --CFLAGS-watchos.armv7k=-fembed-bitcode -+CFLAGS-watchos.armv7k= -+CFLAGS-watchos.arm64_32= -+CFLAGS-watchos.arm64= - PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack=no - -+# watchOS-simulator targets -+TARGETS-watchOS-simulator=watchsimulator.i386 watchsimulator.x86_64 watchsimulator.arm64 -+CFLAGS-watchOS-simulator=-mwatchos-simulator-version-min=4.0 -+ - # override machine types for arm64 - MACHINE_DETAILED-arm64=aarch64 - MACHINE_SIMPLE-arm64=arm -@@ -194,9 +212,11 @@ endif - - # Configure the build - ifeq ($2,macOS) -+ # Patch openssl-darwin-arm64 -+ cd $$(OPENSSL_DIR-$1) && git apply ../../../../openssl-1.0.2n-darwin-arm64.patch - cd $$(OPENSSL_DIR-$1) && \ - CC="$$(CC-$1)" MACOSX_DEPLOYMENT_TARGET=$$(MACOSX_DEPLOYMENT_TARGET) \ -- ./Configure darwin64-x86_64-cc --openssldir=$(PROJECT_DIR)/build/$2/openssl -+ ./Configure darwin64-$$(ARCH-$1)-cc --openssldir=$(PROJECT_DIR)/build/$2/openssl - else - cd $$(OPENSSL_DIR-$1) && \ - CC="$$(CC-$1)" \ -@@ -216,7 +235,10 @@ $$(OPENSSL_DIR-$1)/libssl.a $$(OPENSSL_DIR-$1)/libcrypto.a: $$(OPENSSL_DIR-$1)/M - CC="$$(CC-$1)" \ - CROSS_TOP="$$(dir $$(SDK_ROOT-$1)).." \ - CROSS_SDK="$$(notdir $$(SDK_ROOT-$1))" \ -- make all && make install -+ make build_libs && \ -+ mkdir -p "$(PROJECT_DIR)/build/$2/openssl/lib" && \ -+ cp libcrypto.a libssl.a "$(PROJECT_DIR)/build/$2/openssl/lib" -+ -cd $$(OPENSSL_DIR-$1) && make install_sw 2> /dev/null - - # Unpack BZip2 - $$(BZIP2_DIR-$1)/Makefile: downloads/bzip2-$(BZIP2_VERSION).tgz diff --git a/protocols/Telegram/tdlib/td/example/ios/README.md b/protocols/Telegram/tdlib/td/example/ios/README.md deleted file mode 100644 index e8a2f8d183..0000000000 --- a/protocols/Telegram/tdlib/td/example/ios/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Universal XCFramework build example - -Below are instructions for building TDLib for iOS, watchOS, tvOS, and also macOS. - -If you need only a macOS build for the current architecture, take a look at [TDLib build instructions generator](https://tdlib.github.io/td/build.html). - -For example of usage take a look at our [Swift example](https://github.com/tdlib/td/tree/master/example/swift). - -To compile `TDLib` you will need to: -* Install the latest Xcode via `xcode-select --install` or downloading it from [Xcode website](https://developer.apple.com/xcode/). - It is not enough to install only command line developer tools to build `TDLib` for iOS. Xcode >= 14.0 is required to build TDLib for watchOS. -* Install other build dependencies using [Homebrew](https://brew.sh): -``` -brew install gperf cmake coreutils -``` -* If you don't want to build `TDLib` for macOS first, you **must** pregenerate required source code files using `CMake` prepare_cross_compiling target: -``` -cd -mkdir native-build -cd native-build -cmake .. -cmake --build . --target prepare_cross_compiling -``` -* Build OpenSSL for iOS, watchOS, tvOS, and macOS: -``` -cd /example/ios -./build-openssl.sh -``` -Here we use scripts from [Python Apple support](https://github.com/beeware/Python-Apple-support), but any other OpenSSL build should work too. -[Python Apple support](https://github.com/beeware/Python-Apple-support) has known problems with spaces in the path to the current directory, so -you need to ensure that there are no spaces in the path. -Built OpenSSL libraries should be stored in the directory `third_party/openssl/`, because the next script will rely on this location. -* Build TDLib for iOS, watchOS, tvOS, and macOS: -``` -cd /example/ios -./build.sh -``` -This may take a while, because TDLib will be built about 16 times. -Resulting XCFramework will work on any architecture and even on a simulator. -We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains may work too. - -Built libraries and XCFramework will be stored in `tdjson` directory. - -Documentation for all available classes and methods can be found at https://core.telegram.org/tdlib/docs. - -If you receive an "error: SDK "appletvsimulator" cannot be located", you need to run the command "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" before running ./build.sh. diff --git a/protocols/Telegram/tdlib/td/example/ios/build-openssl.sh b/protocols/Telegram/tdlib/td/example/ios/build-openssl.sh deleted file mode 100644 index e31f565691..0000000000 --- a/protocols/Telegram/tdlib/td/example/ios/build-openssl.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -cd $(dirname $0) - -git clone https://github.com/beeware/Python-Apple-support -cd Python-Apple-support -git checkout 60b990128d5f1f04c336ff66594574515ab56604 || exit 1 -git reset --hard || exit 1 -git apply ../Python-Apple-support.patch || exit 1 -cd .. - -#TODO: change openssl version -platforms="macOS iOS watchOS tvOS" - -for platform in $platforms; -do - if [[ $platform = "macOS" ]]; then - simulators="0" - else - simulators="0 1" - fi - - for simulator in $simulators; - do - if [[ $simulator = "1" ]]; then - platform="${platform}-simulator" - fi - echo $platform - cd Python-Apple-support - #NB: -j will fail - make OpenSSL-$platform || exit 1 - cd .. - rm -rf third_party/openssl/$platform || exit 1 - mkdir -p third_party/openssl/$platform/lib || exit 1 - cp ./Python-Apple-support/build/$platform/libcrypto.a third_party/openssl/$platform/lib/ || exit 1 - cp ./Python-Apple-support/build/$platform/libssl.a third_party/openssl/$platform/lib/ || exit 1 - cp -r ./Python-Apple-support/build/$platform/openssl/include/ third_party/openssl/$platform/include || exit 1 - done -done diff --git a/protocols/Telegram/tdlib/td/example/ios/build.sh b/protocols/Telegram/tdlib/td/example/ios/build.sh deleted file mode 100644 index cd11907b2d..0000000000 --- a/protocols/Telegram/tdlib/td/example/ios/build.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -cd $(dirname $0) -td_path=$(grealpath ../..) - -rm -rf build -mkdir -p build -cd build - -set_cmake_options () { - # Set CMAKE options depending on platform passed $1 - openssl_path=$(grealpath ../third_party/openssl/$1) - echo "OpenSSL path = ${openssl_path}" - openssl_crypto_library="${openssl_path}/lib/libcrypto.a" - openssl_ssl_library="${openssl_path}/lib/libssl.a" - options="" - options="$options -DOPENSSL_FOUND=1" - options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_crypto_library}" - options="$options -DOPENSSL_SSL_LIBRARY=${openssl_ssl_library}" - options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include" - options="$options -DOPENSSL_LIBRARIES=${openssl_crypto_library};${openssl_ssl_library}" - options="$options -DCMAKE_BUILD_TYPE=Release" -} - -platforms="macOS iOS watchOS tvOS" -#platforms="watchOS" -for platform in $platforms; -do - echo "Platform = ${platform}" - if [[ $platform = "macOS" ]]; then - simulators="0" - else - simulators="0 1" - fi - - for simulator in $simulators; - do - if [[ $platform = "macOS" ]]; then - other_options="-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64'" - else - if [[ $platform = "watchOS" ]]; then - ios_platform="WATCH" - elif [[ $platform = "tvOS" ]]; then - ios_platform="TV" - else - ios_platform="" - fi - - if [[ $simulator = "1" ]]; then - platform="${platform}-simulator" - ios_platform="${ios_platform}SIMULATOR" - else - ios_platform="${ios_platform}OS" - fi - - echo "iOS platform = ${ios_platform}" - other_options="-DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake" - fi - - set_cmake_options $platform - build="build-${platform}" - install="install-${platform}" - rm -rf $build - mkdir -p $build - mkdir -p $install - cd $build - cmake $td_path $options $other_options -DCMAKE_INSTALL_PREFIX=../${install} - make -j3 install || exit - cd .. - install_name_tool -id @rpath/libtdjson.dylib ${install}/lib/libtdjson.dylib - mkdir -p ../tdjson/${platform}/include - rsync --recursive ${install}/include/ ../tdjson/${platform}/include/ - mkdir -p ../tdjson/${platform}/lib - cp ${install}/lib/libtdjson.dylib ../tdjson/${platform}/lib/ - done -done - -produced_dylibs=(install-*/lib/libtdjson.dylib) -xcodebuild_frameworks=() - -for dylib in "${produced_dylibs[@]}"; -do - xcodebuild_frameworks+=(-library $(grealpath "${dylib}")) -done - -# Make xcframework -xcodebuild -create-xcframework \ - "${xcodebuild_frameworks[@]}" \ - -output "libtdjson.xcframework" - -rsync --recursive libtdjson.xcframework ../tdjson/ diff --git a/protocols/Telegram/tdlib/td/example/ios/openssl-1.0.2n-darwin-arm64.patch b/protocols/Telegram/tdlib/td/example/ios/openssl-1.0.2n-darwin-arm64.patch deleted file mode 100644 index 5239d94c32..0000000000 --- a/protocols/Telegram/tdlib/td/example/ios/openssl-1.0.2n-darwin-arm64.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- Configure 2019-12-20 14:02:41.000000000 +0100 -+++ Configure 2020-11-22 16:23:13.000000000 +0100 -@@ -650,7 +650,9 @@ - "darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", - "debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", - "darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -+"darwin64-arm64-cc","cc:-arch arm64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch arm64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", - "debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -+"debug-darwin64-arm64-cc","cc:-arch arm64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch arm64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", - "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", - # iPhoneOS/iOS - "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:macOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", diff --git a/protocols/Telegram/tdlib/td/example/java/.gitignore b/protocols/Telegram/tdlib/td/example/java/.gitignore deleted file mode 100644 index 8f846b80d9..0000000000 --- a/protocols/Telegram/tdlib/td/example/java/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -**/*build/ -bin/ -docs/ -org/drinkless/tdlib/TdApi.java -td/ diff --git a/protocols/Telegram/tdlib/td/example/java/CMakeLists.txt b/protocols/Telegram/tdlib/td/example/java/CMakeLists.txt deleted file mode 100644 index 576eee2cfc..0000000000 --- a/protocols/Telegram/tdlib/td/example/java/CMakeLists.txt +++ /dev/null @@ -1,124 +0,0 @@ -cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) - -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(TdJavaExample VERSION 1.0 LANGUAGES CXX) - -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() - -find_package(Td REQUIRED) - -if (NOT JNI_FOUND) - find_package(JNI REQUIRED) -endif() -message(STATUS "Found JNI: ${JNI_INCLUDE_DIRS} ${JNI_LIBRARIES}") - -if (NOT Java_FOUND) - find_package(Java REQUIRED) -endif() -message(STATUS "Found Java: ${Java_JAVAC_EXECUTABLE} ${Java_JAVADOC_EXECUTABLE}") - -# Generating TdApi.java -find_program(PHP_EXECUTABLE php) -if ((CMAKE_SYSTEM_NAME MATCHES "FreeBSD") AND (CMAKE_SYSTEM_VERSION MATCHES "HBSD")) - set(PHP_EXECUTABLE "PHP_EXECUTABLE-NOTFOUND") -endif() - -set(TD_API_JAVA_PACKAGE "org/drinkless/tdlib") -set(TD_API_JAVA_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -set(TD_API_TLO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/scheme/td_api.tlo) -set(TD_API_TL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/scheme/td_api.tl) -set(JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/JavadocTlDocumentationGenerator.php) -set(GENERATE_JAVA_API_CMD ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td_generate_java_api TdApi ${TD_API_TLO_PATH} ${TD_API_JAVA_PATH} ${TD_API_JAVA_PACKAGE}) -if (PHP_EXECUTABLE) - set(GENERATE_JAVA_API_CMD ${GENERATE_JAVA_API_CMD} && ${PHP_EXECUTABLE} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH} ${TD_API_TL_PATH} ${TD_API_JAVA_PATH}/${TD_API_JAVA_PACKAGE}/TdApi.java) -endif() - -add_custom_target(td_generate_java_api - COMMAND ${GENERATE_JAVA_API_CMD} - COMMENT "Generating Java TDLib API source files" - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td_generate_java_api ${TD_API_TLO_PATH} ${TD_API_TL_PATH} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH} -) - -set(JAVA_SOURCE_PATH "${TD_API_JAVA_PATH}/${TD_API_JAVA_PACKAGE}") -get_filename_component(JAVA_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") -file(MAKE_DIRECTORY ${JAVA_OUTPUT_DIRECTORY}) -add_custom_target(build_java - COMMAND ${Java_JAVAC_EXECUTABLE} -encoding UTF-8 -d ${JAVA_OUTPUT_DIRECTORY} ${JAVA_SOURCE_PATH}/example/Example.java ${JAVA_SOURCE_PATH}/Client.java ${JAVA_SOURCE_PATH}/TdApi.java - COMMENT "Building Java code" - DEPENDS td_generate_java_api -) - -add_custom_target(generate_javadoc - COMMAND ${Java_JAVADOC_EXECUTABLE} -encoding UTF-8 -charset UTF-8 -d ${JAVA_OUTPUT_DIRECTORY}/../docs org.drinkless.tdlib - WORKING_DIRECTORY ${TD_API_JAVA_PATH} - COMMENT "Generating Javadoc documentation" - DEPENDS td_generate_java_api -) - -# Building shared library -add_library(tdjni SHARED - td_jni.cpp -) -target_include_directories(tdjni PRIVATE ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) -target_link_libraries(tdjni PRIVATE Td::TdStatic ${JAVA_JVM_LIBRARY}) -target_compile_definitions(tdjni PRIVATE PACKAGE_NAME="${TD_API_JAVA_PACKAGE}") - -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() - - target_compile_options(tdjni PRIVATE "${STD14_FLAG}") -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() - -add_dependencies(tdjni td_generate_java_api build_java generate_javadoc) - -install(TARGETS tdjni - LIBRARY DESTINATION bin - RUNTIME DESTINATION bin -) -if (MSVC AND VCPKG_TOOLCHAIN) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/" DESTINATION bin FILES_MATCHING PATTERN "*.dll" PATTERN "*.pdb") -endif() diff --git a/protocols/Telegram/tdlib/td/example/java/README.md b/protocols/Telegram/tdlib/td/example/java/README.md deleted file mode 100644 index bca3e7ad9c..0000000000 --- a/protocols/Telegram/tdlib/td/example/java/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# TDLib Java example - -To run this example, you will need installed JDK >= 1.6. -For Javadoc documentation generation PHP is needed. - -You can find complete build instructions for your operating system at https://tdlib.github.io/td/build.html?language=Java. - -In general, the build process looks as follows. - -TDLib should be prebuilt with JNI bindings and installed to local subdirectory `td/` as follows: -``` -cd -mkdir jnibuild -cd jnibuild -cmake -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX:PATH=../example/java/td .. -cmake --build . --target install -``` -If you want to compile TDLib for 32-bit/64-bit Java on Windows using MSVC, you will also need to add `-A Win32`/`-A x64` option to CMake. - -In Windows, use vcpkg toolchain file by adding parameter -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake - -After this you can compile the example source code: -``` -cd /example/java -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DTd_DIR=/example/java/td/lib/cmake/Td -DCMAKE_INSTALL_PREFIX:PATH=.. .. -cmake --build . --target install -``` - -Compiled TDLib shared library and Java example after that will be placed in bin/ and Javadoc documentation in `docs/`. - -After this you can run the Java example: -``` -cd /example/java/bin -java '-Djava.library.path=.' org/drinkless/tdlib/example/Example -``` - -If you receive "Could NOT find JNI ..." error from CMake, you need to specify to CMake path to the installed JDK, for example, "-DJAVA_HOME=/usr/lib/jvm/java-8-oracle/". - -If you receive java.lang.UnsatisfiedLinkError with "Can't find dependent libraries", you may also need to copy some dependent shared OpenSSL and zlib libraries to `bin/`. - -Make sure that you compiled the example for the same architecture as your JVM. diff --git a/protocols/Telegram/tdlib/td/example/java/td_jni.cpp b/protocols/Telegram/tdlib/td/example/java/td_jni.cpp deleted file mode 100644 index fb7554c747..0000000000 --- a/protocols/Telegram/tdlib/td/example/java/td_jni.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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 -#include - -#include - -#include -#include -#include -#include - -namespace td_jni { - -static td::td_api::object_ptr fetch_function(JNIEnv *env, jobject function) { - td::jni::reset_parse_error(); - auto result = td::td_api::Function::fetch(env, function); - if (td::jni::have_parse_error()) { - std::abort(); - } - return result; -} - -static td::ClientManager *get_manager() { - return td::ClientManager::get_manager_singleton(); -} - -static jint Client_createNativeClient(JNIEnv *env, jclass clazz) { - return static_cast(get_manager()->create_client_id()); -} - -static void Client_nativeClientSend(JNIEnv *env, jclass clazz, jint client_id, jlong id, jobject function) { - get_manager()->send(static_cast(client_id), static_cast(id), - fetch_function(env, function)); -} - -static jint Client_nativeClientReceive(JNIEnv *env, jclass clazz, jintArray client_ids, jlongArray ids, - jobjectArray events, jdouble timeout) { - jsize events_size = env->GetArrayLength(ids); // client_ids, ids and events must be of equal size - if (events_size == 0) { - return 0; - } - jsize result_size = 0; - - auto *manager = get_manager(); - auto response = manager->receive(timeout); - while (response.object) { - auto client_id = static_cast(response.client_id); - env->SetIntArrayRegion(client_ids, result_size, 1, &client_id); - - auto request_id = static_cast(response.request_id); - env->SetLongArrayRegion(ids, result_size, 1, &request_id); - - jobject object; - response.object->store(env, object); - env->SetObjectArrayElement(events, result_size, object); - env->DeleteLocalRef(object); - - result_size++; - if (result_size == events_size) { - break; - } - - response = manager->receive(0); - } - return result_size; -} - -static jobject Client_nativeClientExecute(JNIEnv *env, jclass clazz, jobject function) { - jobject result; - td::ClientManager::execute(fetch_function(env, function))->store(env, result); - return result; -} - -static jstring Object_toString(JNIEnv *env, jobject object) { - return td::jni::to_jstring(env, to_string(td::td_api::Object::fetch(env, object))); -} - -static jstring Function_toString(JNIEnv *env, jobject object) { - return td::jni::to_jstring(env, to_string(td::td_api::Function::fetch(env, object))); -} - -static constexpr jint JAVA_VERSION = JNI_VERSION_1_6; -static JavaVM *java_vm; -static jobject log_message_handler; - -static void on_log_message(int verbosity_level, const char *log_message) { - auto env = td::jni::get_jni_env(java_vm, JAVA_VERSION); - if (env == nullptr) { - return; - } - - jobject handler = env->NewLocalRef(log_message_handler); - if (!handler) { - return; - } - - jclass handler_class = env->GetObjectClass(handler); - if (handler_class) { - jmethodID on_log_message_method = env->GetMethodID(handler_class, "onLogMessage", "(ILjava/lang/String;)V"); - if (on_log_message_method) { - jstring log_message_str = td::jni::to_jstring(env.get(), log_message); - if (log_message_str) { - env->CallVoidMethod(handler, on_log_message_method, static_cast(verbosity_level), log_message_str); - env->DeleteLocalRef((jobject)log_message_str); - } - } - env->DeleteLocalRef((jobject)handler_class); - } - - env->DeleteLocalRef(handler); -} - -static void Client_nativeClientSetLogMessageHandler(JNIEnv *env, jclass clazz, jint max_verbosity_level, - jobject new_log_message_handler) { - if (log_message_handler) { - td::ClientManager::set_log_message_callback(0, nullptr); - jobject old_log_message_handler = log_message_handler; - log_message_handler = jobject(); - env->DeleteGlobalRef(old_log_message_handler); - } - - if (new_log_message_handler) { - log_message_handler = env->NewGlobalRef(new_log_message_handler); - if (!log_message_handler) { - // out of memory - return; - } - - td::ClientManager::set_log_message_callback(static_cast(max_verbosity_level), on_log_message); - } -} - -static jint register_native(JavaVM *vm) { - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JAVA_VERSION) != JNI_OK) { - return -1; - } - - java_vm = vm; - - auto register_method = [env](jclass clazz, std::string name, std::string signature, auto function_ptr) { - td::jni::register_native_method(env, clazz, std::move(name), std::move(signature), - reinterpret_cast(function_ptr)); - }; - - auto client_class = td::jni::get_jclass(env, PACKAGE_NAME "/Client"); - auto object_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Object"); - auto function_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Function"); - -#define TD_OBJECT "L" PACKAGE_NAME "/TdApi$Object;" -#define TD_FUNCTION "L" PACKAGE_NAME "/TdApi$Function;" - register_method(client_class, "createNativeClient", "()I", Client_createNativeClient); - register_method(client_class, "nativeClientSend", "(IJ" TD_FUNCTION ")V", Client_nativeClientSend); - register_method(client_class, "nativeClientReceive", "([I[J[" TD_OBJECT "D)I", Client_nativeClientReceive); - register_method(client_class, "nativeClientExecute", "(" TD_FUNCTION ")" TD_OBJECT, Client_nativeClientExecute); - register_method(client_class, "nativeClientSetLogMessageHandler", "(IL" PACKAGE_NAME "/Client$LogMessageHandler;)V", - Client_nativeClientSetLogMessageHandler); - - register_method(object_class, "toString", "()Ljava/lang/String;", Object_toString); - - register_method(function_class, "toString", "()Ljava/lang/String;", Function_toString); -#undef TD_FUNCTION -#undef TD_OBJECT - - td::jni::init_vars(env, PACKAGE_NAME); - td::td_api::set_package_name(PACKAGE_NAME); - - return JAVA_VERSION; -} - -} // namespace td_jni - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { - static jint jni_version = td_jni::register_native(vm); // call_once - return jni_version; -} diff --git a/protocols/Telegram/tdlib/td/example/python/README.md b/protocols/Telegram/tdlib/td/example/python/README.md deleted file mode 100644 index 0afb4a70b0..0000000000 --- a/protocols/Telegram/tdlib/td/example/python/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# TDLib Python example - -To run this example you need to [build](https://github.com/tdlib/td#building) TDLib and copy built tdjson shared library to this directory. - -After this you can run the example: -``` -python tdjson_example.py -``` - -Description of all available classes and methods can be found at [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) -and [td_api](https://core.telegram.org/tdlib/docs/td__api_8h.html) documentation. diff --git a/protocols/Telegram/tdlib/td/example/python/tdjson_example.py b/protocols/Telegram/tdlib/td/example/python/tdjson_example.py deleted file mode 100644 index 001eb38758..0000000000 --- a/protocols/Telegram/tdlib/td/example/python/tdjson_example.py +++ /dev/null @@ -1,142 +0,0 @@ -# -# Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com), -# Pellegrino Prevete (pellegrinoprevete@gmail.com) 2014-2023 -# -# 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) -# -from ctypes.util import find_library -from ctypes import * -import json -import sys - -# load shared library -tdjson_path = find_library('tdjson') or 'tdjson.dll' -if tdjson_path is None: - sys.exit("Can't find 'tdjson' library") -tdjson = CDLL(tdjson_path) - -# load TDLib functions from shared library -_td_create_client_id = tdjson.td_create_client_id -_td_create_client_id.restype = c_int -_td_create_client_id.argtypes = [] - -_td_receive = tdjson.td_receive -_td_receive.restype = c_char_p -_td_receive.argtypes = [c_double] - -_td_send = tdjson.td_send -_td_send.restype = None -_td_send.argtypes = [c_int, c_char_p] - -_td_execute = tdjson.td_execute -_td_execute.restype = c_char_p -_td_execute.argtypes = [c_char_p] - -log_message_callback_type = CFUNCTYPE(None, c_int, c_char_p) - -_td_set_log_message_callback = tdjson.td_set_log_message_callback -_td_set_log_message_callback.restype = None -_td_set_log_message_callback.argtypes = [c_int, log_message_callback_type] - -# initialize TDLib log with desired parameters -@log_message_callback_type -def on_log_message_callback(verbosity_level, message): - if verbosity_level == 0: - sys.exit('TDLib fatal error: %r' % message) - -def td_execute(query): - query = json.dumps(query).encode('utf-8') - result = _td_execute(query) - if result: - result = json.loads(result.decode('utf-8')) - return result - -_td_set_log_message_callback(2, on_log_message_callback) - -# setting TDLib log verbosity level to 1 (errors) -print(str(td_execute({'@type': 'setLogVerbosityLevel', 'new_verbosity_level': 1, '@extra': 1.01234})).encode('utf-8')) - - -# create client -client_id = _td_create_client_id() - -# simple wrappers for client usage -def td_send(query): - query = json.dumps(query).encode('utf-8') - _td_send(client_id, query) - -def td_receive(): - result = _td_receive(1.0) - if result: - result = json.loads(result.decode('utf-8')) - return result - -# another test for TDLib execute method -print(str(td_execute({'@type': 'getTextEntities', 'text': '@telegram /test_command https://telegram.org telegram.me', '@extra': ['5', 7.0, 'a']})).encode('utf-8')) - -# start the client by sending a request to it -td_send({'@type': 'getOption', 'name': 'version', '@extra': 1.01234}) - -# main events cycle -while True: - event = td_receive() - if event: - # process authorization states - if event['@type'] == 'updateAuthorizationState': - auth_state = event['authorization_state'] - - # if client is closed, we need to destroy it and create new client - if auth_state['@type'] == 'authorizationStateClosed': - break - - # set TDLib parameters - # you MUST obtain your own api_id and api_hash at https://my.telegram.org - # and use them in the setTdlibParameters call - if auth_state['@type'] == 'authorizationStateWaitTdlibParameters': - td_send({'@type': 'setTdlibParameters', - 'database_directory': 'tdlib', - 'use_message_database': True, - 'use_secret_chats': True, - 'api_id': 94575, - 'api_hash': 'a3406de8d171bb422bb6ddf3bbd800e2', - 'system_language_code': 'en', - 'device_model': 'Desktop', - 'application_version': '1.0', - 'enable_storage_optimizer': True}) - - # enter phone number to log in - if auth_state['@type'] == 'authorizationStateWaitPhoneNumber': - phone_number = input('Please enter your phone number: ') - td_send({'@type': 'setAuthenticationPhoneNumber', 'phone_number': phone_number}) - - # enter email address to log in - if auth_state['@type'] == 'authorizationStateWaitEmailAddress': - email_address = input('Please enter your email address: ') - td_send({'@type': 'setAuthenticationEmailAddress', 'email_address': email_address}) - - # wait for email authorization code - if auth_state['@type'] == 'authorizationStateWaitEmailCode': - code = input('Please enter the email authentication code you received: ') - td_send({'@type': 'checkAuthenticationEmailCode', - 'code': {'@type': 'emailAddressAuthenticationCode', 'code' : code}}) - - # wait for authorization code - if auth_state['@type'] == 'authorizationStateWaitCode': - code = input('Please enter the authentication code you received: ') - td_send({'@type': 'checkAuthenticationCode', 'code': code}) - - # wait for first and last name for new users - if auth_state['@type'] == 'authorizationStateWaitRegistration': - first_name = input('Please enter your first name: ') - last_name = input('Please enter your last name: ') - td_send({'@type': 'registerUser', 'first_name': first_name, 'last_name': last_name}) - - # wait for password if present - if auth_state['@type'] == 'authorizationStateWaitPassword': - password = input('Please enter your password: ') - td_send({'@type': 'checkAuthenticationPassword', 'password': password}) - - # handle an incoming update or an answer to a previously sent request - print(str(event).encode('utf-8')) - sys.stdout.flush() diff --git a/protocols/Telegram/tdlib/td/example/swift/.gitignore b/protocols/Telegram/tdlib/td/example/swift/.gitignore deleted file mode 100644 index 4737be5996..0000000000 --- a/protocols/Telegram/tdlib/td/example/swift/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -xcuserdata/ -*workspace/ -td/ diff --git a/protocols/Telegram/tdlib/td/example/swift/README.md b/protocols/Telegram/tdlib/td/example/swift/README.md deleted file mode 100644 index ab7d855006..0000000000 --- a/protocols/Telegram/tdlib/td/example/swift/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# TDLib swift macOS example - -TDLib should be prebuilt and installed to local subdirectory `td/`: -``` -cd -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../example/swift/td .. -cmake --build . --target install -``` - -After this you can open and build the example with the latest Xcode. - -Description of all available classes and methods can be found at [td_json_client](https://core.telegram.org/tdlib/docs/td__json__client_8h.html) -and [td_api](https://core.telegram.org/tdlib/docs/td__api_8h.html) documentation. diff --git a/protocols/Telegram/tdlib/td/example/swift/src/main.swift b/protocols/Telegram/tdlib/td/example/swift/src/main.swift deleted file mode 100644 index fde2b75321..0000000000 --- a/protocols/Telegram/tdlib/td/example/swift/src/main.swift +++ /dev/null @@ -1,190 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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) -// - -import Foundation - -// TDLib Client Swift binding -class TdClient { - var client_id = td_create_client_id() - let tdlibMainLoop = DispatchQueue(label: "TDLib") - let tdlibQueryQueue = DispatchQueue(label: "TDLibQuery") - var queryF = Dictionary)->()>() - var updateF: ((Dictionary)->())? - var queryId: Int64 = 0 - - func queryAsync(query: [String: Any], f: ((Dictionary)->())? = nil) { - tdlibQueryQueue.async { - var newQuery = query - - if f != nil { - let nextQueryId = self.queryId + 1 - newQuery["@extra"] = nextQueryId - self.queryF[nextQueryId] = f - self.queryId = nextQueryId - } - td_send(self.client_id, to_json(newQuery)) - } - } - - func querySync(query: [String: Any]) -> Dictionary { - let semaphore = DispatchSemaphore(value:0) - var result = Dictionary() - queryAsync(query: query) { - result = $0 - semaphore.signal() - } - semaphore.wait() - return result - } - - init() { - } - - deinit { - } - - func run(updateHandler: @escaping (Dictionary)->()) { - updateF = updateHandler - tdlibMainLoop.async { [weak self] in - while (true) { - if let s = self { - if let res = td_receive(10) { - let event = String(cString: res) - s.queryResultAsync(event) - } - } else { - break - } - } - } - } - - private func queryResultAsync(_ result: String) { - tdlibQueryQueue.async { - let json = try? JSONSerialization.jsonObject(with: result.data(using: .utf8)!, options:[]) - if let dictionary = json as? [String:Any] { - if let extra = dictionary["@extra"] as? Int64 { - let index = self.queryF.index(forKey: extra)! - self.queryF[index].value(dictionary) - self.queryF.remove(at: index) - } else { - self.updateF!(dictionary) - } - } - } - } -} - -func to_json(_ obj: Any) -> String { - do { - let obj = try JSONSerialization.data(withJSONObject: obj) - return String(data: obj, encoding: .utf8)! - } catch { - return "" - } -} - - -var client = TdClient() - -// start the client by sending request to it -client.queryAsync(query: ["@type":"getOption", "name":"version"]) - -func myReadLine() -> String { - while (true) { - if let line = readLine() { - return line - } - } -} - -func updateAuthorizationState(authorizationState: Dictionary) { - switch(authorizationState["@type"] as! String) { - case "authorizationStateWaitTdlibParameters": - client.queryAsync(query:[ - "@type":"setTdlibParameters", - "database_directory":"tdlib", - "use_message_database":true, - "use_secret_chats":true, - "api_id":94575, - "api_hash":"a3406de8d171bb422bb6ddf3bbd800e2", - "system_language_code":"en", - "device_model":"Desktop", - "application_version":"1.0", - "enable_storage_optimizer":true - ]); - - case "authorizationStateWaitPhoneNumber": - print("Enter your phone number: ") - let phone_number = myReadLine() - client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone_number], f:checkAuthenticationError) - - case "authorizationStateWaitEmailAddress": - print("Enter your email address: ") - let email_address = myReadLine() - client.queryAsync(query:["@type":"setAuthenticationEmailAddress", "email_address":email_address], f:checkAuthenticationError) - - case "authorizationStateWaitEmailCode": - var code: String = "" - print("Enter email code: ") - code = myReadLine() - client.queryAsync(query:["@type":"checkAuthenticationEmailCode", "code":["@type":"emailAddressAuthenticationCode", "code":code]], f:checkAuthenticationError) - - case "authorizationStateWaitCode": - var code: String = "" - print("Enter (SMS) code: ") - code = myReadLine() - client.queryAsync(query:["@type":"checkAuthenticationCode", "code":code], f:checkAuthenticationError) - - case "authorizationStateWaitRegistration": - var first_name: String = "" - var last_name: String = "" - print("Enter your first name: ") - first_name = myReadLine() - print("Enter your last name: ") - last_name = myReadLine() - client.queryAsync(query:["@type":"registerUser", "first_name":first_name, "last_name":last_name], f:checkAuthenticationError) - - case "authorizationStateWaitPassword": - print("Enter password: ") - let password = myReadLine() - client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthenticationError) - - case "authorizationStateReady": - () - - case "authorizationStateLoggingOut": - print("Logging out...") - - case "authorizationStateClosing": - print("Closing...") - - case "authorizationStateClosed": - print("Closed.") - - default: - assert(false, "TODO: Unexpected authorization state"); - } -} - -func checkAuthenticationError(error: Dictionary) { - if (error["@type"] as! String == "error") { - client.queryAsync(query:["@type":"getAuthorizationState"], f:updateAuthorizationState) - } -} - -client.run { - let update = $0 - print(update) - if update["@type"] as! String == "updateAuthorizationState" { - updateAuthorizationState(authorizationState: update["authorization_state"] as! Dictionary) - } -} - -while true { - sleep(1) -} diff --git a/protocols/Telegram/tdlib/td/example/swift/src/td-Bridging-Header.h b/protocols/Telegram/tdlib/td/example/swift/src/td-Bridging-Header.h deleted file mode 100644 index 06a2ba73d6..0000000000 --- a/protocols/Telegram/tdlib/td/example/swift/src/td-Bridging-Header.h +++ /dev/null @@ -1,9 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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/td_json_client.h" -#include "td/telegram/td_log.h" diff --git a/protocols/Telegram/tdlib/td/example/swift/td.xcodeproj/project.pbxproj b/protocols/Telegram/tdlib/td/example/swift/td.xcodeproj/project.pbxproj deleted file mode 100644 index e7a4bb9085..0000000000 --- a/protocols/Telegram/tdlib/td/example/swift/td.xcodeproj/project.pbxproj +++ /dev/null @@ -1,312 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1F65E3A92031C0F000F79763 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F65E3A82031C0F000F79763 /* main.swift */; }; - 425922F020C8353500F06B38 /* libtdjson.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F65E3A32031BF6A00F79763 /* libtdjson.dylib */; }; - 425922F120C844E700F06B38 /* libtdjson.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F65E3A32031BF6A00F79763 /* libtdjson.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 1FCE2CEF1EC5E1B50061661A /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 8; - dstPath = ""; - dstSubfolderSpec = 11; - files = ( - 425922F120C844E700F06B38 /* libtdjson.dylib in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1F65E3A32031BF6A00F79763 /* libtdjson.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtdjson.dylib; path = td/lib/libtdjson.dylib; sourceTree = ""; }; - 1F65E3A82031C0F000F79763 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = main.swift; path = src/main.swift; sourceTree = SOURCE_ROOT; }; - 1F65E3AA2031C14300F79763 /* td-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "td-Bridging-Header.h"; path = "src/td-Bridging-Header.h"; sourceTree = SOURCE_ROOT; }; - 1FCE2CF11EC5E1B50061661A /* td */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = td; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 1FCE2CEE1EC5E1B50061661A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 425922F020C8353500F06B38 /* libtdjson.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 1FCE2CE81EC5E1B50061661A = { - isa = PBXGroup; - children = ( - 1FCE2CF31EC5E1B50061661A /* src */, - 1FCE2CF21EC5E1B50061661A /* Products */, - 1FCE2CFB1EC5E1EE0061661A /* Frameworks */, - ); - sourceTree = ""; - }; - 1FCE2CF21EC5E1B50061661A /* Products */ = { - isa = PBXGroup; - children = ( - 1FCE2CF11EC5E1B50061661A /* td */, - ); - name = Products; - sourceTree = ""; - }; - 1FCE2CF31EC5E1B50061661A /* src */ = { - isa = PBXGroup; - children = ( - 1F65E3AA2031C14300F79763 /* td-Bridging-Header.h */, - 1F65E3A82031C0F000F79763 /* main.swift */, - ); - name = src; - path = td; - sourceTree = ""; - }; - 1FCE2CFB1EC5E1EE0061661A /* Frameworks */ = { - isa = PBXGroup; - children = ( - 1F65E3A32031BF6A00F79763 /* libtdjson.dylib */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 1FCE2CF01EC5E1B50061661A /* td */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1FCE2CF81EC5E1B50061661A /* Build configuration list for PBXNativeTarget "td" */; - buildPhases = ( - 1FCE2CED1EC5E1B50061661A /* Sources */, - 1FCE2CEE1EC5E1B50061661A /* Frameworks */, - 1FCE2CEF1EC5E1B50061661A /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = td; - productName = td; - productReference = 1FCE2CF11EC5E1B50061661A /* td */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 1FCE2CE91EC5E1B50061661A /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0920; - ORGANIZATIONNAME = "Arseny Smirnov "; - TargetAttributes = { - 1FCE2CF01EC5E1B50061661A = { - CreatedOnToolsVersion = 8.3.2; - LastSwiftMigration = 0920; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 1FCE2CEC1EC5E1B50061661A /* Build configuration list for PBXProject "td" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 1FCE2CE81EC5E1B50061661A; - productRefGroup = 1FCE2CF21EC5E1B50061661A /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 1FCE2CF01EC5E1B50061661A /* td */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 1FCE2CED1EC5E1B50061661A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1F65E3A92031C0F000F79763 /* main.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 1FCE2CF61EC5E1B50061661A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - }; - name = Debug; - }; - 1FCE2CF71EC5E1B50061661A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - }; - name = Release; - }; - 1FCE2CF91EC5E1B50061661A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/td/lib"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/td/lib", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "src/td-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; - USER_HEADER_SEARCH_PATHS = td/include/; - }; - name = Debug; - }; - 1FCE2CFA1EC5E1B50061661A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/td/lib"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/td/lib", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "src/td-Bridging-Header.h"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; - USER_HEADER_SEARCH_PATHS = td/include/; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1FCE2CEC1EC5E1B50061661A /* Build configuration list for PBXProject "td" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1FCE2CF61EC5E1B50061661A /* Debug */, - 1FCE2CF71EC5E1B50061661A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1FCE2CF81EC5E1B50061661A /* Build configuration list for PBXNativeTarget "td" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1FCE2CF91EC5E1B50061661A /* Debug */, - 1FCE2CFA1EC5E1B50061661A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 1FCE2CE91EC5E1B50061661A /* Project object */; -} diff --git a/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt b/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt deleted file mode 100644 index 36b7cd93cd..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -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, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/protocols/Telegram/tdlib/td/example/uwp/README.md b/protocols/Telegram/tdlib/td/example/uwp/README.md deleted file mode 100644 index 3faa890d51..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# TDLib Universal Windows Platform example - -This is an example of building TDLib SDK for Universal Windows Platform and an example of its usage from C#. - -## Building SDK - -* Download and install Microsoft Visual Studio 2015+ with Windows 10 SDK. We recommend to use the latest available versions of Microsoft Visual Studio and Windows 10 SDK. -* Download and install [CMake](https://cmake.org/download/). -* Install `zlib` and `openssl` for all UWP architectures and `gperf` for x86 using [vcpkg](https://github.com/Microsoft/vcpkg#quick-start): -``` -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -git checkout 1b1ae50e1a69f7c659bd7d731e80b358d21c86ad -.\bootstrap-vcpkg.bat -.\vcpkg.exe install gperf:x86-windows openssl:arm-uwp openssl:arm64-uwp openssl:x64-uwp openssl:x86-uwp zlib:arm-uwp zlib:arm64-uwp zlib:x64-uwp zlib:x86-uwp -``` -* (Optional. For XML documentation generation.) Download [PHP](https://windows.php.net/download). Add the path to php.exe to the PATH environment variable. -* Download and install [7-Zip](http://www.7-zip.org/download.html) archiver, which is used by the `build.ps1` script to create a Telegram.Td.UWP Visual Studio Extension. Add the path to 7z.exe to the PATH environment variable. - Alternatively `build.ps1` supports compressing using [WinRAR](https://en.wikipedia.org/wiki/WinRAR) with option `-compress winrar` and compressing using [zip](http://gnuwin32.sourceforge.net/packages/zip.htm) with `-compress zip`. -* Build `TDLib` using provided `build.ps1` script (TDLib should be built 6 times for multiple platforms in Debug and Release configurations, so it make take few hours). Pass path to vcpkg.exe as `-vcpkg-root` argument, for example: -``` -powershell -ExecutionPolicy ByPass .\build.ps1 -vcpkg_root C:\vcpkg -``` -If you need to restart the build from scratch, call `.\build.ps1 -vcpkg_root C:\vcpkg -mode clean` first. -* Install Visual Studio Extension "TDLib for Universal Windows Platform" located at `build-uwp\vsix\tdlib.vsix`, which was created on the previous step by `build.ps1` script. - -After this `TDLib` can be used from any UWP project, built in Visual Studio. - -Alternatively, you can build `TDLib` as a NuGet package, adding the option `-nupkg` to the `.\build.ps1` script invocation. The resulting package will be placed in the directory `build-uwp\nupkg`. - -## Example of usage - -The `app/` directory contains a simple example of a C# application for Universal Windows Platform. Just open it with Visual Studio 2015 or later and run. diff --git a/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml b/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml deleted file mode 100644 index d6896fcb65..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec deleted file mode 100644 index 039ec2adaf..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec +++ /dev/null @@ -1,16 +0,0 @@ - - - - Telegram.Td.UWP - 1.8.14 - TDLib for Universal Windows Platform - Telegram - Telegram - false - LICENSE_1_0.txt - https://core.telegram.org/tdlib - https://github.com/tdlib/td/blob/master/CHANGELOG.md - TDLib for Universal Windows Platform - © Telegram FZ-LLC. All rights reserved. - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets deleted file mode 100644 index 3ad7f3e95d..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets +++ /dev/null @@ -1,21 +0,0 @@ - - - - - x86 - $(Platform) - - -$(Platform) - - - - - Telegram.Td.dll - - - - - - - - \ No newline at end of file diff --git a/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml b/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml deleted file mode 100644 index b91d46fa3c..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore b/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore deleted file mode 100644 index 37ab08165b..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.vs/ -bin/ -obj/ -project.lock.json -TdApp.csproj.user diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml deleted file mode 100644 index b4256fd441..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs deleted file mode 100644 index faaa46cab0..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 -// -// 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) -// -using System; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -namespace TdApp -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( - Microsoft.ApplicationInsights.WindowsCollectors.Metadata | - Microsoft.ApplicationInsights.WindowsCollectors.Session); - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - -#if DEBUG - if (System.Diagnostics.Debugger.IsAttached) - { - this.DebugSettings.EnableFrameRateCounter = true; - } -#endif - - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } - } -} diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config b/protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config deleted file mode 100644 index cb2a232da3..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57adb5..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1fed..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1a5..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2ec8..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce97e..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png deleted file mode 100644 index 7385b56c0e..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b397..0000000000 Binary files a/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml deleted file mode 100644 index cdff97d9f3..0000000000 --- a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - -