From e1ec72eab6d00b3ba38e5932bc88920f103b6e4a Mon Sep 17 00:00:00 2001 From: aunsane Date: Fri, 27 Apr 2018 21:33:17 +0300 Subject: Telegram: initial commit - tdlib moved to telegram dir --- .../Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt | 23 +++ protocols/Telegram/tdlib/td/example/uwp/README.md | 28 ++++ .../Telegram/tdlib/td/example/uwp/SDKManifest.xml | 12 ++ .../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 0 -> 1430 bytes .../uwp/app/Assets/SplashScreen.scale-200.png | Bin 0 -> 7700 bytes .../uwp/app/Assets/Square150x150Logo.scale-200.png | Bin 0 -> 2937 bytes .../uwp/app/Assets/Square44x44Logo.scale-200.png | Bin 0 -> 1647 bytes ...are44x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 1255 bytes .../tdlib/td/example/uwp/app/Assets/StoreLogo.png | Bin 0 -> 1451 bytes .../uwp/app/Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 3204 bytes .../tdlib/td/example/uwp/app/MainPage.xaml | 29 ++++ .../tdlib/td/example/uwp/app/MainPage.xaml.cs | 171 +++++++++++++++++++++ .../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 0 -> 2456 bytes .../Telegram/tdlib/td/example/uwp/app/project.json | 19 +++ protocols/Telegram/tdlib/td/example/uwp/build.ps1 | 142 +++++++++++++++++ .../tdlib/td/example/uwp/extension.vsixmanifest | 17 ++ 25 files changed, 813 insertions(+) create mode 100644 protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt create mode 100644 protocols/Telegram/tdlib/td/example/uwp/README.md create mode 100644 protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml create mode 100644 protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/.gitignore create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/App.xaml create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Package.appxmanifest create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/Properties/Default.rd.xml create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/TdApp_TemporaryKey.pfx create mode 100644 protocols/Telegram/tdlib/td/example/uwp/app/project.json create mode 100644 protocols/Telegram/tdlib/td/example/uwp/build.ps1 create mode 100644 protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest (limited to 'protocols/Telegram/tdlib/td/example/uwp') diff --git a/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt b/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt new file mode 100644 index 0000000000..36b7cd93cd --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +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 new file mode 100644 index 0000000000..e7bb9b821b --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/README.md @@ -0,0 +1,28 @@ +# 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 [vcpkg](https://github.com/Microsoft/vcpkg#quick-start) or update it to the latest version using `vcpkg update` and following received instructions. +* Install `zlib` and `openssl` for all UWP architectures using `vcpkg`: +``` +C:\src\vcpkg> .\vcpkg.exe install openssl:arm-uwp openssl:x64-uwp openssl:x86-uwp zlib:arm-uwp zlib:x64-uwp zlib:x86-uwp +``` +* (Optional. For XML documentation generation.) Download [PHP](https://windows.php.net/download#php-7.2). Add the path to php.exe to the PATH environment variable. +* Download and install [gperf](https://sourceforge.net/projects/gnuwin32/files/gperf/3.0.1/). Add the path to gperf.exe to the PATH environment variable. +* 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: +``` +powershell -ExecutionPolicy ByPass .\build.ps1 -vcpkg_root C:\src\vcpkg +``` +If you need to restart the build from scratch, call `.\build.ps1 -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. + +Now `TDLib` can be freely used from any UWP project, built in Visual Studio. + +## 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 2017 and run. diff --git a/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml b/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml new file mode 100644 index 0000000000..d6896fcb65 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/SDKManifest.xml @@ -0,0 +1,12 @@ + + + + diff --git a/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml b/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml new file mode 100644 index 0000000000..b91d46fa3c --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/[Content_Types].xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore b/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore new file mode 100644 index 0000000000..37ab08165b --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/app/.gitignore @@ -0,0 +1,5 @@ +.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 new file mode 100644 index 0000000000..b4256fd441 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml @@ -0,0 +1,7 @@ + + diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs new file mode 100644 index 0000000000..0ed0f96812 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs @@ -0,0 +1,104 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// +// 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 new file mode 100644 index 0000000000..cb2a232da3 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/app/ApplicationInsights.config @@ -0,0 +1,3 @@ + + + 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 new file mode 100644 index 0000000000..735f57adb5 Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/LockScreenLogo.scale-200.png 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 new file mode 100644 index 0000000000..023e7f1fed Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/SplashScreen.scale-200.png 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 new file mode 100644 index 0000000000..af49fec1a5 Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square150x150Logo.scale-200.png 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 new file mode 100644 index 0000000000..ce342a2ec8 Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.scale-200.png 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 new file mode 100644 index 0000000000..f6c02ce97e Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png 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 new file mode 100644 index 0000000000..7385b56c0e Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/StoreLogo.png 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 new file mode 100644 index 0000000000..288995b397 Binary files /dev/null and b/protocols/Telegram/tdlib/td/example/uwp/app/Assets/Wide310x150Logo.scale-200.png differ diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml new file mode 100644 index 0000000000..cdff97d9f3 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + +