summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/example/uwp/app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-11-30 17:48:47 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-11-30 17:48:47 +0300
commit0ece30dc7c0e34b4c5911969b8fa99c33c6d023c (patch)
tree671325d3fec09b999411e4e3ab84ef8259261818 /protocols/Telegram/tdlib/td/example/uwp/app
parent46c53ffc6809c67e4607e99951a2846c382b63b2 (diff)
Telegram: update for TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/example/uwp/app')
-rw-r--r--protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs2
-rw-r--r--protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs76
-rw-r--r--protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs4
-rw-r--r--protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj2
4 files changed, 52 insertions, 32 deletions
diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs
index 0ed0f96812..5bfc66a30f 100644
--- a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs
+++ b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs
index 9bdf5070ee..4c42e27676 100644
--- a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs
+++ b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -18,7 +18,7 @@ namespace TdApp
{
public System.Collections.ObjectModel.ObservableCollection<string> Items { get; set; }
- private static MyClientResultHandler _handler;
+ private MyClientResultHandler _handler;
public MainPage()
{
@@ -27,31 +27,25 @@ namespace TdApp
Items = new System.Collections.ObjectModel.ObservableCollection<string>();
_handler = new MyClientResultHandler(this);
+ Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0));
+ Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"), 1 << 27, false)));
+ Td.Client.SetLogMessageCallback(100, LogMessageCallback);
System.Threading.Tasks.Task.Run(() =>
{
- try
- {
- Td.Log.SetFilePath(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"));
- _client = Td.Client.Create(_handler);
- var parameters = new TdApi.TdlibParameters();
- parameters.DatabaseDirectory = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
- parameters.UseSecretChats = true;
- parameters.UseMessageDatabase = true;
- parameters.ApiId = 94575;
- parameters.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
- parameters.SystemLanguageCode = "en";
- parameters.DeviceModel = "en";
- parameters.SystemVersion = "en";
- parameters.ApplicationVersion = "1.0.0";
- _client.Send(new TdApi.SetTdlibParameters(parameters), null);
- _client.Send(new TdApi.CheckDatabaseEncryptionKey(), null);
- _client.Run();
- }
- catch (Exception ex)
- {
- Print(ex.ToString());
- }
+ Td.Client.Run();
});
+
+ _client = Td.Client.Create(_handler);
+ var request = new TdApi.SetTdlibParameters();
+ request.DatabaseDirectory = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
+ request.UseSecretChats = true;
+ request.UseMessageDatabase = true;
+ request.ApiId = 94575;
+ request.ApiHash = "a3406de8d171bb422bb6ddf3bbd800e2";
+ request.SystemLanguageCode = "en";
+ request.DeviceModel = "Desktop";
+ request.ApplicationVersion = "1.0.0";
+ _client.Send(request, null);
}
public void Print(String str)
@@ -62,7 +56,15 @@ namespace TdApp
});
}
- private static Td.Client _client;
+ private void LogMessageCallback(int verbosity_level, String str)
+ {
+ if (verbosity_level < 0) {
+ return;
+ }
+ Print(verbosity_level + ": " + str);
+ }
+
+ private Td.Client _client;
private void AcceptCommand(String command)
{
@@ -92,13 +94,25 @@ namespace TdApp
{
var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command);
- _client.Send(new TdApi.SetAuthenticationPhoneNumber(args[1], false, false), _handler);
+ _client.Send(new TdApi.SetAuthenticationPhoneNumber(args[1], null), _handler);
+ }
+ else if (command.StartsWith("sae"))
+ {
+ var args = command.Split(" ".ToCharArray(), 2);
+ AcceptCommand(command);
+ _client.Send(new TdApi.SetAuthenticationEmailAddress(args[1]), _handler);
+ }
+ else if (command.StartsWith("caec"))
+ {
+ var args = command.Split(" ".ToCharArray(), 2);
+ AcceptCommand(command);
+ _client.Send(new TdApi.CheckAuthenticationEmailCode(new TdApi.EmailAddressAuthenticationCode(args[1])), _handler);
}
else if (command.StartsWith("cac"))
{
var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command);
- _client.Send(new TdApi.CheckAuthenticationCode(args[1], String.Empty, String.Empty), _handler);
+ _client.Send(new TdApi.CheckAuthenticationCode(args[1]), _handler);
}
else if (command.StartsWith("cap"))
{
@@ -106,6 +120,12 @@ namespace TdApp
AcceptCommand(command);
_client.Send(new TdApi.CheckAuthenticationPassword(args[1]), _handler);
}
+ else if (command.StartsWith("alm"))
+ {
+ var args = command.Split(" ".ToCharArray(), 3);
+ AcceptCommand(command);
+ _client.Send(new TdApi.AddLogMessage(Int32.Parse(args[1]), args[2]), _handler);
+ }
else if (command.StartsWith("gco"))
{
var args = command.Split(" ".ToCharArray(), 2);
@@ -116,7 +136,7 @@ namespace TdApp
{
var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command);
- _client.Send(new TdApi.DownloadFile(Int32.Parse(args[1]), 1), _handler);
+ _client.Send(new TdApi.DownloadFile(Int32.Parse(args[1]), 1, 0, 0, false), _handler);
}
else if (command.StartsWith("bench"))
{
diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs b/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs
index 99e2b83bea..2e008d1a29 100644
--- a/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs
+++ b/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("App2")]
-[assembly: AssemblyCopyright("Copyright © 2015-2018")]
+[assembly: AssemblyCopyright("Copyright © 2015-2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -26,4 +26,4 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: ComVisible(false)] \ No newline at end of file
+[assembly: ComVisible(false)]
diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj b/protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj
index b3d1d944d1..2b0de8df3d 100644
--- a/protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj
+++ b/protocols/Telegram/tdlib/td/example/uwp/app/TdApp.csproj
@@ -88,7 +88,7 @@
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<ItemGroup>
- <!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
+ <!-- A reference to the entire .NET Framework and Windows SDK are automatically included -->
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>