diff --git a/LibgenDesktop.Setup/Constants.cs b/LibgenDesktop.Setup/Constants.cs
index ec606ad..3e343c9 100644
--- a/LibgenDesktop.Setup/Constants.cs
+++ b/LibgenDesktop.Setup/Constants.cs
@@ -2,8 +2,8 @@
{
internal static class Constants
{
- public const string CURRENT_VERSION = "1.1.1";
- public const string TITLE_VERSION = "1.1.1";
+ public const string CURRENT_VERSION = "1.1.2";
+ public const string TITLE_VERSION = "1.1.2";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + TITLE_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
diff --git a/LibgenDesktop/Common/Constants.cs b/LibgenDesktop/Common/Constants.cs
index b1e1952..0d4143d 100644
--- a/LibgenDesktop/Common/Constants.cs
+++ b/LibgenDesktop/Common/Constants.cs
@@ -4,9 +4,9 @@ namespace LibgenDesktop.Common
{
internal static class Constants
{
- public const string CURRENT_VERSION = "1.1.1";
- public const string CURRENT_GITHUB_RELEASE_NAME = "1.1.1";
- public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2018, 5, 2);
+ public const string CURRENT_VERSION = "1.1.2";
+ public const string CURRENT_GITHUB_RELEASE_NAME = "1.1.2";
+ public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2018, 5, 21);
public const string CURRENT_DATABASE_VERSION = "1.0";
public const string APP_SETTINGS_FILE_NAME = "libgen.config";
@@ -56,6 +56,10 @@ internal static class Constants
public const int IMPORT_WINDOW_MIN_WIDTH = 530;
public const int IMPORT_WINDOW_MIN_HEIGHT = 400;
public const int CREATE_DATABASE_WINDOW_WIDTH = 500;
+ public const int LIBRARY_WINDOW_DEFAULT_WIDTH = 760;
+ public const int LIBRARY_WINDOW_DEFAULT_HEIGHT = 550;
+ public const int LIBRARY_WINDOW_MIN_WIDTH = 760;
+ public const int LIBRARY_WINDOW_MIN_HEIGHT = 550;
public const int SETTINGS_WINDOW_DEFAULT_WIDTH = 760;
public const int SETTINGS_WINDOW_DEFAULT_HEIGHT = 550;
public const int SETTINGS_WINDOW_MIN_WIDTH = 760;
diff --git a/LibgenDesktop/Infrastructure/RegisteredWindows.cs b/LibgenDesktop/Infrastructure/RegisteredWindows.cs
index 6609caa..bbf6524 100644
--- a/LibgenDesktop/Infrastructure/RegisteredWindows.cs
+++ b/LibgenDesktop/Infrastructure/RegisteredWindows.cs
@@ -19,6 +19,7 @@ internal enum WindowKey
SETTINGS_WINDOW,
SYNCHRONIZATION_WINDOW,
APPLICATION_UPDATE_WINDOW,
+ LIBRARY_WINDOW,
DATABASE_WINDOW,
ABOUT_WINDOW
}
@@ -49,6 +50,7 @@ static RegisteredWindows()
RegisterWindow(WindowKey.CREATE_DATABASE_WINDOW, typeof(CreateDatabaseWindow), typeof(CreateDatabaseWindowViewModel));
RegisterWindow(WindowKey.SETTINGS_WINDOW, typeof(SettingsWindow), typeof(SettingsWindowViewModel));
RegisterWindow(WindowKey.SYNCHRONIZATION_WINDOW, typeof(SynchronizationWindow), typeof(SynchronizationWindowViewModel));
+ RegisterWindow(WindowKey.LIBRARY_WINDOW, typeof(LibraryWindow), typeof(LibraryWindowViewModel));
RegisterWindow(WindowKey.APPLICATION_UPDATE_WINDOW, typeof(ApplicationUpdateWindow), typeof(ApplicationUpdateWindowViewModel));
RegisterWindow(WindowKey.DATABASE_WINDOW, typeof(DatabaseWindow), typeof(DatabaseWindowViewModel));
RegisterWindow(WindowKey.ABOUT_WINDOW, typeof(AboutWindow), typeof(AboutWindowViewModel));
diff --git a/LibgenDesktop/LibgenDesktop.csproj b/LibgenDesktop/LibgenDesktop.csproj
index 5765585..ee8468a 100644
--- a/LibgenDesktop/LibgenDesktop.csproj
+++ b/LibgenDesktop/LibgenDesktop.csproj
@@ -170,6 +170,7 @@
+
@@ -201,12 +202,15 @@
+
+
+
@@ -239,6 +243,7 @@
+
@@ -295,6 +300,9 @@
AboutWindow.xaml
+
+ LibraryWindow.xaml
+
DatabaseWindow.xaml
@@ -376,6 +384,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -408,6 +420,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
diff --git a/LibgenDesktop/Models/Database/LocalDatabase.cs b/LibgenDesktop/Models/Database/LocalDatabase.cs
index c90aef9..ce7d03f 100644
--- a/LibgenDesktop/Models/Database/LocalDatabase.cs
+++ b/LibgenDesktop/Models/Database/LocalDatabase.cs
@@ -133,6 +133,11 @@ public void CreateNonFictionTables()
ExecuteCommands(SqlScripts.CREATE_NON_FICTION_FTS_TABLE);
}
+ public void CreateNonFictionMd5HashIndex()
+ {
+ ExecuteCommands(SqlScripts.CREATE_NON_FICTION_MD5HASH_INDEX);
+ }
+
public void CreateNonFictionLastModifiedDateTimeIndex()
{
ExecuteCommands(SqlScripts.CREATE_NON_FICTION_LASTMODIFIEDDATETIME_INDEX);
@@ -174,6 +179,27 @@ public NonFictionBook GetNonFictionBookById(int id)
}
}
+ public NonFictionBook GetNonFictionBookByMd5Hash(string md5Hash)
+ {
+ using (SQLiteCommand command = connection.CreateCommand())
+ {
+ command.CommandText = SqlScripts.GET_NON_FICTION_BY_MD5HASH;
+ command.Parameters.AddWithValue("@Md5Hash", md5Hash);
+ using (SQLiteDataReader dataReader = command.ExecuteReader())
+ {
+ if (dataReader.Read())
+ {
+ NonFictionBook book = ReadNonFictionBook(dataReader);
+ return book;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ }
+
public int? GetNonFictionBookIdByLibgenId(int libgenId)
{
return GetIdByLibgenId(SqlScripts.GET_NON_FICTION_ID_BY_LIBGENID, libgenId);
diff --git a/LibgenDesktop/Models/Database/SqlScripts.cs b/LibgenDesktop/Models/Database/SqlScripts.cs
index 289074d..41a460a 100644
--- a/LibgenDesktop/Models/Database/SqlScripts.cs
+++ b/LibgenDesktop/Models/Database/SqlScripts.cs
@@ -82,6 +82,8 @@ internal static class SqlScripts
public const string GET_NON_FICTION_BY_ID = "SELECT * FROM non_fiction WHERE Id = @Id";
+ public const string GET_NON_FICTION_BY_MD5HASH = "SELECT * FROM non_fiction WHERE Md5Hash = @Md5Hash COLLATE NOCASE";
+
public const string GET_NON_FICTION_ID_BY_LIBGENID = "SELECT Id FROM non_fiction WHERE LibgenId=@LibgenId LIMIT 1";
public const string GET_LAST_MODIFIED_NON_FICTION =
@@ -162,6 +164,9 @@ internal static class SqlScripts
public const string NON_FICTION_INDEX_PREFIX = "IX_non_fiction_";
+ public const string CREATE_NON_FICTION_MD5HASH_INDEX = "CREATE UNIQUE INDEX " + NON_FICTION_INDEX_PREFIX +
+ "Md5Hash ON non_fiction (Md5Hash COLLATE NOCASE)";
+
public const string CREATE_NON_FICTION_LASTMODIFIEDDATETIME_INDEX = "CREATE INDEX " + NON_FICTION_INDEX_PREFIX +
"LastModifiedDateTime ON non_fiction (LastModifiedDateTime DESC)";
@@ -329,6 +334,8 @@ internal static class SqlScripts
public const string FICTION_INDEX_PREFIX = "IX_fiction_";
+ public const string CREATE_FICTION_MD5HASH_INDEX = "CREATE UNIQUE INDEX " + FICTION_INDEX_PREFIX + "Md5Hash ON fiction (Md5Hash COLLATE NOCASE)";
+
public const string CREATE_FICTION_LASTMODIFIEDDATETIME_INDEX = "CREATE INDEX " + FICTION_INDEX_PREFIX +
"LastModifiedDateTime ON fiction (LastModifiedDateTime DESC)";
@@ -399,6 +406,8 @@ internal static class SqlScripts
public const string SCIMAG_INDEX_PREFIX = "IX_scimag_";
+ public const string CREATE_SCIMAG_MD5HASH_INDEX = "CREATE UNIQUE INDEX " + SCIMAG_INDEX_PREFIX + "Md5Hash ON scimag (Md5Hash COLLATE NOCASE)";
+
public const string CREATE_SCIMAG_ADDEDDATETIME_INDEX = "CREATE INDEX " + SCIMAG_INDEX_PREFIX + "AddedDateTime ON scimag (AddedDateTime DESC)";
}
}
diff --git a/LibgenDesktop/Models/Localization/Language.cs b/LibgenDesktop/Models/Localization/Language.cs
index f663341..210f838 100644
--- a/LibgenDesktop/Models/Localization/Language.cs
+++ b/LibgenDesktop/Models/Localization/Language.cs
@@ -26,6 +26,7 @@ internal class Language
private SynchronizationLocalizator synchronization;
private DownloadManagerLocalizator downloadManager;
private ApplicationUpdateLocalizator applicationUpdate;
+ private LibraryWindowLocalizator library;
private DatabaseWindowLocalizator database;
private SettingsWindowLocalizator settings;
private AboutWindowLocalizator about;
@@ -127,6 +128,8 @@ public Language(List prioritizedTranslationList)
public ApplicationUpdateLocalizator ApplicationUpdate =>
applicationUpdate ?? (applicationUpdate = new ApplicationUpdateLocalizator(translations, Formatter));
+ public LibraryWindowLocalizator Library => library ?? (library = new LibraryWindowLocalizator(translations, Formatter));
+
public DatabaseWindowLocalizator Database => database ?? (database = new DatabaseWindowLocalizator(translations, Formatter));
public SettingsWindowLocalizator Settings => settings ?? (settings = new SettingsWindowLocalizator(translations, Formatter));
diff --git a/LibgenDesktop/Models/Localization/Localizators/LibraryWindowLocalizator.cs b/LibgenDesktop/Models/Localization/Localizators/LibraryWindowLocalizator.cs
new file mode 100644
index 0000000..2bb5f0e
--- /dev/null
+++ b/LibgenDesktop/Models/Localization/Localizators/LibraryWindowLocalizator.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+
+namespace LibgenDesktop.Models.Localization.Localizators
+{
+ internal class LibraryWindowLocalizator : Localizator
+ {
+ public LibraryWindowLocalizator(List prioritizedTranslationList, LanguageFormatter formatter)
+ : base(prioritizedTranslationList, formatter)
+ {
+ WindowTitle = Format(translation => translation?.WindowTitle);
+ Scan = Format(translation => translation?.Scan);
+ BrowseDirectoryDialogTitle = Format(translation => translation?.BrowseDirectoryDialogTitle);
+ CreatingIndexes = Format(translation => translation?.CreatingIndexes);
+ NotFound = Format(translation => translation?.NotFound);
+ }
+
+ public string WindowTitle { get; }
+ public string Scan { get; }
+ public string BrowseDirectoryDialogTitle { get; }
+ public string CreatingIndexes { get; }
+ public string NotFound { get; }
+
+ public string GetScanStartedString(string directory) => Format(translation => translation?.ScanStarted, new { directory });
+ public string GetScanCompleteString(int found, int notFound) => Format(translation => translation?.ScanComplete,
+ new { found = Formatter.ToFormattedString(found), notFound = Formatter.ToFormattedString(notFound) });
+
+ private string Format(Func field, object templateArguments = null)
+ {
+ return Format(translation => field(translation?.Library), templateArguments);
+ }
+ }
+}
diff --git a/LibgenDesktop/Models/Localization/Localizators/Localizator.cs b/LibgenDesktop/Models/Localization/Localizators/Localizator.cs
index f72ce4a..e2756bd 100644
--- a/LibgenDesktop/Models/Localization/Localizators/Localizator.cs
+++ b/LibgenDesktop/Models/Localization/Localizators/Localizator.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
namespace LibgenDesktop.Models.Localization.Localizators
diff --git a/LibgenDesktop/Models/Localization/Localizators/MainWindowLocalizator.cs b/LibgenDesktop/Models/Localization/Localizators/MainWindowLocalizator.cs
index 2638d0f..784a7c6 100644
--- a/LibgenDesktop/Models/Localization/Localizators/MainWindowLocalizator.cs
+++ b/LibgenDesktop/Models/Localization/Localizators/MainWindowLocalizator.cs
@@ -15,6 +15,7 @@ public MainWindowLocalizator(List prioritizedTranslationList, Langu
ToolbarUpdate = Format(translation => translation?.Update);
ToolbarImport = Format(translation => translation?.Import);
ToolbarSynchronize = Format(translation => translation?.Synchronize);
+ ToolbarLibrary = Format(translation => translation?.Library);
ToolbarDatabase = Format(translation => translation?.Database);
ToolbarSettings = Format(translation => translation?.Settings);
ToolbarAbout = Format(translation => translation?.About);
@@ -27,6 +28,7 @@ public MainWindowLocalizator(List prioritizedTranslationList, Langu
public string ToolbarUpdate { get; }
public string ToolbarImport { get; }
public string ToolbarSynchronize { get; }
+ public string ToolbarLibrary { get; }
public string ToolbarDatabase { get; }
public string ToolbarSettings { get; }
public string ToolbarAbout { get; }
diff --git a/LibgenDesktop/Models/Localization/Translation.cs b/LibgenDesktop/Models/Localization/Translation.cs
index 8768a3d..fa75097 100644
--- a/LibgenDesktop/Models/Localization/Translation.cs
+++ b/LibgenDesktop/Models/Localization/Translation.cs
@@ -36,6 +36,7 @@ internal class MainMenuTranslation
public string Update { get; set; }
public string Import { get; set; }
public string Synchronize { get; set; }
+ public string Library { get; set; }
public string Database { get; set; }
public string Settings { get; set; }
public string About { get; set; }
@@ -543,6 +544,17 @@ internal class SynchronizationTranslation
public SynchronizationLogMessagesTranslation LogMessages { get; set; }
}
+ internal class LibraryTranslation
+ {
+ public string WindowTitle { get; set; }
+ public string Scan { get; set; }
+ public string BrowseDirectoryDialogTitle { get; set; }
+ public string ScanStarted { get; set; }
+ public string CreatingIndexes { get; set; }
+ public string NotFound { get; set; }
+ public string ScanComplete { get; set; }
+ }
+
internal class DatabaseTranslation
{
public string WindowTitle { get; set; }
@@ -794,6 +806,7 @@ internal class ErrorWindowTranslation
public SynchronizationTranslation Synchronization { get; set; }
public DownloadManagerTranslation DownloadManager { get; set; }
public ApplicationUpdateTranslation ApplicationUpdate { get; set; }
+ public LibraryTranslation Library { get; set; }
public DatabaseTranslation Database { get; set; }
public SettingsTranslation Settings { get; set; }
public AboutTranslation About { get; set; }
diff --git a/LibgenDesktop/Models/MainModel.cs b/LibgenDesktop/Models/MainModel.cs
index ec0986e..54e7153 100644
--- a/LibgenDesktop/Models/MainModel.cs
+++ b/LibgenDesktop/Models/MainModel.cs
@@ -5,6 +5,7 @@
using System.Linq;
using System.Net;
using System.Net.Http;
+using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using LibgenDesktop.Common;
@@ -482,6 +483,28 @@ public Task DownloadFileAsync(string fileUrl, string destina
});
}
+ public Task ScanAsync(string scanDirectory, IProgress