diff --git a/Clients/TgDownloaderDesktop/App.xaml.cs b/Clients/TgDownloaderDesktop/App.xaml.cs index f365df6..37ef2b1 100644 --- a/Clients/TgDownloaderDesktop/App.xaml.cs +++ b/Clients/TgDownloaderDesktop/App.xaml.cs @@ -66,8 +66,8 @@ public App() services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/Clients/TgDownloaderDesktop/Helpers/TgDesktopUtils.cs b/Clients/TgDownloaderDesktop/Helpers/TgDesktopUtils.cs index 1f8c032..66f5cdc 100644 --- a/Clients/TgDownloaderDesktop/Helpers/TgDesktopUtils.cs +++ b/Clients/TgDownloaderDesktop/Helpers/TgDesktopUtils.cs @@ -11,7 +11,6 @@ public static class TgDesktopUtils #region Public and private fields, properties, constructor public static TgClientHelper TgClient => TgClientHelper.Instance; - //public static TgClientViewModel TgClientVm { get; } = App.GetService(); public static string BaseDirectory = AppContext.BaseDirectory; public static string LocalFolder = ApplicationData.Current.LocalFolder.Path; public static string InstalledLocation = Package.Current.InstalledLocation.Path; @@ -27,7 +26,7 @@ public static class TgDesktopUtils // { // if (isUpdateLoad) // viewModel.IsLoad = true; - // TgClientViewModel.Exception.Clear(); + // TgConnectViewModel.Exception.Clear(); // action(); // } @@ -42,7 +41,7 @@ public static class TgDesktopUtils // } // catch (Exception ex) // { - // App.MainWindow.DispatcherQueue.TryEnqueue(() => { TgClientViewModel.Exception.Set(ex); }); + // App.MainWindow.DispatcherQueue.TryEnqueue(() => { TgConnectViewModel.Exception.Set(ex); }); // } // finally // { @@ -167,7 +166,7 @@ public static class TgDesktopUtils // { // if (isUpdateLoad) // viewModel.IsLoad = true; - // //TgClientViewModel.Exception.Clear(); + // //TgConnectViewModel.Exception.Clear(); // await action(); // } @@ -182,7 +181,7 @@ public static class TgDesktopUtils // } // catch (Exception ex) // { - // //App.MainWindow.DispatcherQueue.TryEnqueue(() => TgClientViewModel.Exception.Set(ex)); + // //App.MainWindow.DispatcherQueue.TryEnqueue(() => TgConnectViewModel.Exception.Set(ex)); // } // finally // { diff --git a/Clients/TgDownloaderDesktop/Helpers/TgResourceExtensions.cs b/Clients/TgDownloaderDesktop/Helpers/TgResourceExtensions.cs index 1c7c8ba..ec561a8 100644 --- a/Clients/TgDownloaderDesktop/Helpers/TgResourceExtensions.cs +++ b/Clients/TgDownloaderDesktop/Helpers/TgResourceExtensions.cs @@ -29,6 +29,9 @@ public static class TgResourceExtensions public static string ClientSettingsAreNotValid() => "ClientSettingsAreNotValid".GetLocalized(); public static string GetAppVersion() => "AppVersion".GetLocalized(); public static string GetCancelButton() => "CancelButton".GetLocalized(); + public static string GetClientEnterLoginCode() => "ClientEnterLoginCode".GetLocalized(); + public static string GetClientEnterPassword() => "ClientEnterPassword".GetLocalized(); + public static string GetClientFloodWait() => "ClientFloodWait".GetLocalized(); public static string GetClientIsConnected() => "ClientIsConnected".GetLocalized(); public static string GetClientIsDisconnected() => "ClientIsDisconnected".GetLocalized(); public static string GetClipboard() => "Clipboard".GetLocalized(); diff --git a/Clients/TgDownloaderDesktop/Services/PageService.cs b/Clients/TgDownloaderDesktop/Services/PageService.cs index 93aae6d..9a2bae8 100644 --- a/Clients/TgDownloaderDesktop/Services/PageService.cs +++ b/Clients/TgDownloaderDesktop/Services/PageService.cs @@ -11,7 +11,7 @@ public PageService() { Configure(); Configure(); - Configure(); + Configure(); Configure(); Configure(); Configure(); diff --git a/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw b/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw index 6b67b87..811ffd1 100644 --- a/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw +++ b/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw @@ -160,10 +160,10 @@ Default - + TgDownloader - Telegram Files Downloader - + License @@ -315,28 +315,31 @@ Delete - + GitHub community - + + Official website + + Official website (global version) - + Official website (russian version) - + Download - + User support - + Project support - + Docker images - + Install Requirements @@ -447,11 +450,11 @@ Ok - - Connect the client to TG server + + Connect to TG server - - Disconnect the client from TG server + + Disconnect from TG server Client requests data @@ -480,6 +483,9 @@ Verification code + + Login code + First name @@ -498,6 +504,15 @@ Client is disconnected + + Enter login code from the Telegram message + + + Enter the login password + + + Flood defense has kicked in, stand by + Connection state diff --git a/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw b/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw index 50f925f..180bbd5 100644 --- a/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw +++ b/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw @@ -219,10 +219,10 @@ Default - + TgDownloader - Загрузчик файлов Telegram - + Лицензия @@ -374,28 +374,31 @@ Удалить - + ГитХаб сообщество - + + Официальный вебсайт + + Официальный вебсайт (глобальная версия) - + Официальный вебсайт (русская версия) - + Скачать - + Поддержка пользователей - + Поддержка проекта - + Docker образы - + Требования к установке @@ -506,11 +509,11 @@ Ок - - Подключить клиент к серверу TG + + Подключиться к серверу TG - - Отключить клиент от сервера TG + + Отключиться от сервера TG Клиент запрашивает данные @@ -542,6 +545,9 @@ Проверочный код + + Код логина + Имя @@ -560,6 +566,15 @@ Клиент отключен + + Введите код входа в систему из сообщения Telegram + + + Введите пароль входа + + + Сработала защита от флуда, ожидайте + Состояние подключения diff --git a/Clients/TgDownloaderDesktop/Styles/Thickness.xaml b/Clients/TgDownloaderDesktop/Styles/Thickness.xaml index 19d0a9b..470664e 100644 --- a/Clients/TgDownloaderDesktop/Styles/Thickness.xaml +++ b/Clients/TgDownloaderDesktop/Styles/Thickness.xaml @@ -31,4 +31,6 @@ 0,0,10,0 + 0,0,10,5 + diff --git a/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj b/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj index efcea92..b223f0f 100644 --- a/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj +++ b/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj @@ -28,9 +28,6 @@ c:\TgDownloader-Releases\ 12ADC21F87DF252CACA6ACA3440704BA8FA91CEA - - - @@ -64,7 +61,7 @@ - + Designer diff --git a/Clients/TgDownloaderDesktop/Usings.cs b/Clients/TgDownloaderDesktop/Usings.cs index 7fd26fe..c7211fe 100644 --- a/Clients/TgDownloaderDesktop/Usings.cs +++ b/Clients/TgDownloaderDesktop/Usings.cs @@ -21,6 +21,7 @@ global using Microsoft.Xaml.Interactivity; global using System.Collections.ObjectModel; global using System.Collections.Specialized; +global using System.Data; global using System.Diagnostics.CodeAnalysis; global using System.Diagnostics; global using System.Reflection; @@ -42,6 +43,7 @@ global using TgDownloaderDesktop.ViewModels; global using TgDownloaderDesktop.Views; global using TgInfrastructure.Common; +global using TgInfrastructure.Enums; global using TgInfrastructure.Helpers; global using TgStorage.Domain.Apps; global using TgStorage.Domain.Contacts; diff --git a/Clients/TgDownloaderDesktop/ViewModels/TgClientViewModel.cs b/Clients/TgDownloaderDesktop/ViewModels/TgConnectViewModel.cs similarity index 83% rename from Clients/TgDownloaderDesktop/ViewModels/TgClientViewModel.cs rename to Clients/TgDownloaderDesktop/ViewModels/TgConnectViewModel.cs index eeaafd7..af69fe3 100644 --- a/Clients/TgDownloaderDesktop/ViewModels/TgClientViewModel.cs +++ b/Clients/TgDownloaderDesktop/ViewModels/TgConnectViewModel.cs @@ -1,12 +1,10 @@ // This is an independent project of an individual developer. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com -using TgInfrastructure.Enums; - namespace TgDownloaderDesktop.ViewModels; [DebuggerDisplay("{ToDebugString()}")] -public sealed partial class TgClientViewModel : TgPageViewModelBase +public sealed partial class TgConnectViewModel : TgPageViewModelBase { #region Public and private fields, properties, constructor @@ -65,7 +63,7 @@ public sealed partial class TgClientViewModel : TgPageViewModelBase public IRelayCommand AppDeleteCommand { get; } - public TgClientViewModel(ITgSettingsService settingsService) : base(settingsService) + public TgConnectViewModel(ITgSettingsService settingsService) : base(settingsService) { AppClearCoreAsync().GetAwaiter().GetResult(); // Commands @@ -95,21 +93,46 @@ public TgClientViewModel(ITgSettingsService settingsService) : base(settingsServ private async Task AfterClientConnectAsync() { ConnectionDt = TgDataFormatUtils.GetDtFormat(DateTime.Now); - ConnectionMsg = TgDesktopUtils.TgClient.Client is null || TgDesktopUtils.TgClient.Client.Disconnected - ? TgResourceExtensions.GetClientIsDisconnected() : TgResourceExtensions.GetClientIsConnected(); - if (TgDesktopUtils.TgClient.Client is not null) + var client = TgDesktopUtils.TgClient.Client; + // Check exceptions + if (Exception.Message.Contains("PHONE_CODE_INVALID", StringComparison.InvariantCultureIgnoreCase)) + { + ConnectionMsg = TgResourceExtensions.GetClientEnterLoginCode(); + } + else if (Exception.Message.Contains("PASSWORD_HASH_INVALID", StringComparison.InvariantCultureIgnoreCase)) + { + ConnectionMsg = TgResourceExtensions.GetClientEnterPassword(); + } + else if (Exception.Message.Contains("FLOOD_WAIT", StringComparison.InvariantCultureIgnoreCase)) + { + ConnectionMsg = TgResourceExtensions.GetClientFloodWait(); + } + else if (Exception.Message.Contains("PHONE_PASSWORD_FLOOD", StringComparison.InvariantCultureIgnoreCase)) + { + ConnectionMsg = TgResourceExtensions.GetClientFloodWait(); + } + else + { + ConnectionMsg = client is null || client.Disconnected + ? TgResourceExtensions.GetClientIsDisconnected() : TgResourceExtensions.GetClientIsConnected(); + VerificationCode = string.Empty; + Password = string.Empty; + } + if (client is not null) { - UserName = TgDesktopUtils.TgClient.Client.User?.MainUsername ?? string.Empty; - MtProxyUrl = TgDesktopUtils.TgClient.Client.MTProxyUrl; - MaxAutoReconnects = TgDesktopUtils.TgClient.Client.MaxAutoReconnects.ToString(); - FloodRetryThreshold = TgDesktopUtils.TgClient.Client.FloodRetryThreshold.ToString(); - PingInterval = TgDesktopUtils.TgClient.Client.PingInterval.ToString(); - MaxCodePwdAttempts = TgDesktopUtils.TgClient.Client.MaxCodePwdAttempts.ToString(); + UserName = client.User?.MainUsername ?? string.Empty; + MtProxyUrl = client.MTProxyUrl; + MaxAutoReconnects = client.MaxAutoReconnects.ToString(); + FloodRetryThreshold = client.FloodRetryThreshold.ToString(); + PingInterval = client.PingInterval.ToString(); + MaxCodePwdAttempts = client.MaxCodePwdAttempts.ToString(); } else { await ReloadUiAsync(isClearPassw: false); } + // Clear memory + client = null; } private string? ConfigClientDesktop(string what) @@ -167,14 +190,14 @@ private async Task ClientConnectCoreAsync(bool isRetry) } catch (Exception ex) { - Exception.Set(ex); - await TgDesktopUtils.FileLogAsync(ex); + Exception.Set(ex); + await TgDesktopUtils.FileLogAsync(ex); if (isRetry) return; - if (Exception.Message.Contains("or delete the file to start a new session")) - { - await TgDesktopUtils.DeleteFileStorageExistsAsync(SettingsService.AppSession); + if (Exception.Message.Contains("or delete the file to start a new session")) + { + await TgDesktopUtils.DeleteFileStorageExistsAsync(SettingsService.AppSession); await ClientConnectCoreAsync(isRetry: true); - } + } } } diff --git a/Clients/TgDownloaderDesktop/Views/ListDetailsPage.xaml b/Clients/TgDownloaderDesktop/Views/ListDetailsPage.xaml index ea4827d..d8290bb 100644 --- a/Clients/TgDownloaderDesktop/Views/ListDetailsPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/ListDetailsPage.xaml @@ -12,6 +12,7 @@ behaviors:NavigationViewHeaderBehavior.HeaderMode="Never" d:DataContext="{d:DesignInstance Type=viewmodels:ListDetailsViewModel}" mc:Ignorable="d"> + diff --git a/Clients/TgDownloaderDesktop/Views/ShellPage.xaml b/Clients/TgDownloaderDesktop/Views/ShellPage.xaml index 5465c0b..79d110b 100644 --- a/Clients/TgDownloaderDesktop/Views/ShellPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/ShellPage.xaml @@ -50,7 +50,7 @@ - + @@ -67,18 +67,18 @@ - - - - - - + + + + + + - - @@ -176,6 +188,7 @@ @@ -298,6 +311,7 @@ @@ -316,10 +330,11 @@ - + @@ -329,10 +344,10 @@ Margin="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" - Password="{x:Bind ViewModel.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> - + Password="{x:Bind ViewModel.VerificationCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> + + Password="{x:Bind ViewModel.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> (); + ViewModel = App.GetService(); InitializeComponent(); } diff --git a/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml b/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml index 80a28b9..ea07084 100644 --- a/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml @@ -10,6 +10,7 @@ xmlns:views="using:TgDownloaderDesktop.Views" d:DataContext="{d:DesignInstance Type=viewmodels:TgContactsViewModel}" mc:Ignorable="d"> + @@ -32,6 +33,7 @@ @@ -115,6 +117,7 @@ diff --git a/Clients/TgDownloaderDesktop/Views/TgFiltersPage.xaml b/Clients/TgDownloaderDesktop/Views/TgFiltersPage.xaml index bf38c9a..95e9e99 100644 --- a/Clients/TgDownloaderDesktop/Views/TgFiltersPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgFiltersPage.xaml @@ -10,6 +10,7 @@ xmlns:views="using:TgDownloaderDesktop.Views" d:DataContext="{d:DesignInstance Type=viewmodels:TgFiltersViewModel}" mc:Ignorable="d"> + @@ -32,6 +33,7 @@ @@ -115,6 +117,7 @@ diff --git a/Clients/TgDownloaderDesktop/Views/TgLoadDataPage.xaml b/Clients/TgDownloaderDesktop/Views/TgLoadDataPage.xaml index 4f9befe..eb1f538 100644 --- a/Clients/TgDownloaderDesktop/Views/TgLoadDataPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgLoadDataPage.xaml @@ -8,6 +8,7 @@ xmlns:viewmodels="using:TgDownloaderDesktop.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:TgLoadDataViewModel}" mc:Ignorable="d"> + diff --git a/Clients/TgDownloaderDesktop/Views/TgMainPage.xaml b/Clients/TgDownloaderDesktop/Views/TgMainPage.xaml index 413a561..22b6c79 100644 --- a/Clients/TgDownloaderDesktop/Views/TgMainPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgMainPage.xaml @@ -3,396 +3,459 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:helpers="using:TgDownloaderDesktop.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodels="using:TgDownloaderDesktop.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:TgMainViewModel}" mc:Ignorable="d"> + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + - - - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + diff --git a/Clients/TgDownloaderDesktop/Views/TgSettingsPage.xaml b/Clients/TgDownloaderDesktop/Views/TgSettingsPage.xaml index 4202d69..416a4a1 100644 --- a/Clients/TgDownloaderDesktop/Views/TgSettingsPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgSettingsPage.xaml @@ -19,6 +19,7 @@ @@ -62,6 +63,7 @@ @@ -121,6 +123,7 @@ diff --git a/Clients/TgDownloaderDesktop/Views/TgSourcesPage.xaml b/Clients/TgDownloaderDesktop/Views/TgSourcesPage.xaml index 46cbf3d..65fae17 100644 --- a/Clients/TgDownloaderDesktop/Views/TgSourcesPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgSourcesPage.xaml @@ -10,6 +10,7 @@ xmlns:views="using:TgDownloaderDesktop.Views" d:DataContext="{d:DesignInstance Type=viewmodels:TgSourcesViewModel}" mc:Ignorable="d"> + @@ -32,6 +33,7 @@ @@ -163,6 +165,7 @@ diff --git a/Clients/TgDownloaderDesktop/Views/TgStoriesPage.xaml b/Clients/TgDownloaderDesktop/Views/TgStoriesPage.xaml index 6d51066..2f02277 100644 --- a/Clients/TgDownloaderDesktop/Views/TgStoriesPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgStoriesPage.xaml @@ -10,6 +10,7 @@ xmlns:views="using:TgDownloaderDesktop.Views" d:DataContext="{d:DesignInstance Type=viewmodels:TgContactsViewModel}" mc:Ignorable="d"> + @@ -32,6 +33,7 @@ @@ -115,6 +117,7 @@ diff --git a/Core/TgDownloader/TgDownloader.csproj b/Core/TgDownloader/TgDownloader.csproj deleted file mode 100644 index a93ea1d..0000000 --- a/Core/TgDownloader/TgDownloader.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - net8.0 - enable - enable - 0.5.250.0 - AnyCPU;x64;x86 - - - none - - - none - - - none - - - - - - - - - - - diff --git a/Core/TgDownloader/Using.cs b/Core/TgDownloader/Using.cs deleted file mode 100644 index e355811..0000000 --- a/Core/TgDownloader/Using.cs +++ /dev/null @@ -1,3 +0,0 @@ -// This is an independent project of an individual developer. Dear PVS-Studio, please check it. -// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com -