mirror of
https://github.com/claunia/apprepodbmgr.git
synced 2025-12-16 19:24:42 +00:00
Refactor
This commit is contained in:
@@ -37,29 +37,29 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
public delegate void UnarChangeStatusDelegate();
|
||||
|
||||
public static List<string> Files;
|
||||
public static List<string> Folders;
|
||||
public static List<string> Symlinks;
|
||||
public static List<string> Files;
|
||||
public static List<string> Folders;
|
||||
public static List<string> Symlinks;
|
||||
public static Dictionary<string, DbAppFile> Hashes;
|
||||
public static Dictionary<string, DbFolder> FoldersDict;
|
||||
public static Dictionary<string, string> SymlinksDict;
|
||||
public static string Path;
|
||||
public static DbEntry DbInfo;
|
||||
public static bool UnarUsable;
|
||||
public static string TmpFolder;
|
||||
public static long NoFilesInArchive;
|
||||
public static string ArchiveFormat;
|
||||
public static Process UnarProcess;
|
||||
public static bool UnzipWithUnAr;
|
||||
public static string SelectedFile;
|
||||
public static OpticalDiscType WorkingDisc;
|
||||
public static BlockMediaType WorkingDisk;
|
||||
public static CICMMetadataType Metadata;
|
||||
public static bool UserExtracting;
|
||||
public static bool UsableDotNetZip;
|
||||
public static string ClamdVersion;
|
||||
public static bool VirusTotalEnabled;
|
||||
public static event UnarChangeStatusDelegate UnarChangeStatus;
|
||||
public static Dictionary<string, DbFolder> FoldersDict;
|
||||
public static Dictionary<string, string> SymlinksDict;
|
||||
public static string Path;
|
||||
public static DbEntry DbInfo;
|
||||
public static bool UnarUsable;
|
||||
public static string TmpFolder;
|
||||
public static long NoFilesInArchive;
|
||||
public static string ArchiveFormat;
|
||||
public static Process UnarProcess;
|
||||
public static bool UnzipWithUnAr;
|
||||
public static string SelectedFile;
|
||||
public static OpticalDiscType WorkingDisc;
|
||||
public static BlockMediaType WorkingDisk;
|
||||
public static CICMMetadataType Metadata;
|
||||
public static bool UserExtracting;
|
||||
public static bool UsableDotNetZip;
|
||||
public static string ClamdVersion;
|
||||
public static bool VirusTotalEnabled;
|
||||
public static event UnarChangeStatusDelegate UnarChangeStatus;
|
||||
|
||||
public static void CheckUnar()
|
||||
{
|
||||
|
||||
@@ -889,10 +889,10 @@ namespace apprepodbmgr.Core
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
dbcmd.CommandText =
|
||||
$"DROP TABLE IF EXISTS `app_{id}_symlinks`;\n\n" +
|
||||
$"CREATE TABLE IF NOT EXISTS `app_{id}_symlinks` (\n" +
|
||||
" `path` VARCHAR(8192) PRIMARY KEY,\n" +
|
||||
" `target` VARCHAR(8192) NOT NULL);\n\n" +
|
||||
$"DROP TABLE IF EXISTS `app_{id}_symlinks`;\n\n" +
|
||||
$"CREATE TABLE IF NOT EXISTS `app_{id}_symlinks` (\n" +
|
||||
" `path` VARCHAR(8192) PRIMARY KEY,\n" +
|
||||
" `target` VARCHAR(8192) NOT NULL);\n\n" +
|
||||
$"CREATE UNIQUE INDEX `app_{id}_symlinks_path_UNIQUE` ON `app_{id}_symlinks` (`path` ASC);\n\n" +
|
||||
$"CREATE INDEX `app_{id}_symlinks_target_idx` ON `app_{id}_symlinks` (`target` ASC);";
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace apprepodbmgr.Core
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch { }
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
|
||||
// Check only RAW plugin
|
||||
if(imageFormat != null) return imageFormat;
|
||||
@@ -77,7 +77,7 @@ namespace apprepodbmgr.Core
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch { }
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
|
||||
// Still not recognized
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace DiscImageChef.Interop
|
||||
{
|
||||
#if __ANDROID__
|
||||
return PlatformID.Android;
|
||||
#else
|
||||
#else
|
||||
return PlatformID.Linux;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
@@ -50,4 +50,4 @@ using System.Runtime.CompilerServices;
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@@ -173,7 +173,7 @@ namespace apprepodbmgr.Core
|
||||
break;
|
||||
}
|
||||
|
||||
long totalSize = 0, currentSize = 0;
|
||||
long totalSize = 0, currentSize = 0;
|
||||
foreach(KeyValuePair<string, DbAppFile> file in Context.Hashes) totalSize += file.Value.Length;
|
||||
|
||||
#if DEBUG
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace apprepodbmgr.Core
|
||||
UpdateProgress?.Invoke(null, "Checking files in database", counter, Context.Hashes.Count);
|
||||
|
||||
AddFileForApp?.Invoke(kvp.Key, kvp.Value.Sha256, dbCore.DbOps.ExistsFile(kvp.Value.Sha256),
|
||||
kvp.Value.Crack);
|
||||
kvp.Value.Crack);
|
||||
|
||||
if(dbCore.DbOps.ExistsFile(kvp.Value.Sha256))
|
||||
{
|
||||
@@ -246,7 +246,8 @@ namespace apprepodbmgr.Core
|
||||
counter = 0;
|
||||
foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
|
||||
{
|
||||
UpdateProgress?.Invoke(null, "Adding files to application in database", counter, Context.Hashes.Count);
|
||||
UpdateProgress?.Invoke(null, "Adding files to application in database", counter,
|
||||
Context.Hashes.Count);
|
||||
|
||||
dbCore.DbOps.AddFileToApp(kvp.Value, Context.DbInfo.Id);
|
||||
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
public static partial class Workers
|
||||
{
|
||||
public delegate void AddAppDelegate(DbEntry os);
|
||||
|
||||
public delegate void AddFileDelegate(DbFile file);
|
||||
|
||||
public delegate void AddFileForAppDelegate(string filename, string hash, bool known, bool isCrack);
|
||||
|
||||
public delegate void AddFilesDelegate(List<DbFile> file);
|
||||
|
||||
public delegate void AddAppDelegate(DbEntry os);
|
||||
|
||||
public delegate void FailedDelegate(string text);
|
||||
|
||||
public delegate void FinishedWithoutErrorDelegate();
|
||||
@@ -57,8 +57,8 @@ namespace apprepodbmgr.Core
|
||||
public static event FailedDelegate Failed;
|
||||
public static event FinishedWithoutErrorDelegate Finished;
|
||||
public static event FinishedWithTextDelegate FinishedWithText;
|
||||
public static event AddFileForAppDelegate AddFileForApp;
|
||||
public static event AddAppDelegate AddApp;
|
||||
public static event AddFileForAppDelegate AddFileForApp;
|
||||
public static event AddAppDelegate AddApp;
|
||||
public static event AddFileDelegate AddFile;
|
||||
public static event AddFilesDelegate AddFiles;
|
||||
public static event ScanFinishedDelegate ScanFinished;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using apprepodbmgr.Core;
|
||||
using Eto;
|
||||
@@ -41,14 +42,14 @@ namespace apprepodbmgr.Eto.Desktop
|
||||
Context.CheckUnar();
|
||||
if(Settings.Current.UseAntivirus)
|
||||
{
|
||||
if(Settings.Current.UseClamd)
|
||||
Workers.InitClamd();
|
||||
if(Settings.Current.UseClamd) Workers.InitClamd();
|
||||
if(Settings.Current.UseVirusTotal)
|
||||
Context.VirusTotalEnabled = Workers.InitVirusTotal(Settings.Current.VirusTotalKey);
|
||||
}
|
||||
|
||||
Context.UsableDotNetZip = !Platform.Detect.IsMac && !Platform.Detect.IsIos;
|
||||
|
||||
new Application(Platform.Detect).Run(new frmMain());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
@@ -50,4 +50,4 @@ using System.Runtime.CompilerServices;
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@@ -25,8 +25,8 @@
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
@@ -50,4 +50,4 @@ using System.Runtime.CompilerServices;
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@@ -46,18 +46,19 @@ namespace apprepodbmgr.Eto
|
||||
{
|
||||
public delegate void OnAddedAppDelegate(DbEntry app);
|
||||
|
||||
ObservableCollection<FileEntry> fileView;
|
||||
int knownFiles;
|
||||
ObservableCollection<DBEntryForEto> appView;
|
||||
bool stopped;
|
||||
Thread thdAddFiles;
|
||||
Thread thdCheckFiles;
|
||||
Thread thdExtractArchive;
|
||||
Thread thdFindFiles;
|
||||
Thread thdHashFiles;
|
||||
Thread thdOpenArchive;
|
||||
Thread thdPackFiles;
|
||||
Thread thdRemoveTemp;
|
||||
|
||||
ObservableCollection<FileEntry> fileView;
|
||||
int knownFiles;
|
||||
bool stopped;
|
||||
Thread thdAddFiles;
|
||||
Thread thdCheckFiles;
|
||||
Thread thdExtractArchive;
|
||||
Thread thdFindFiles;
|
||||
Thread thdHashFiles;
|
||||
Thread thdOpenArchive;
|
||||
Thread thdPackFiles;
|
||||
Thread thdRemoveTemp;
|
||||
|
||||
public dlgAdd()
|
||||
{
|
||||
@@ -293,8 +294,8 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished += ChkFilesFinished;
|
||||
Workers.UpdateProgress += UpdateProgress;
|
||||
Workers.UpdateProgress2 += UpdateProgress2;
|
||||
Workers.AddFileForApp += AddFile;
|
||||
Workers.AddApp += AddApp;
|
||||
Workers.AddFileForApp += AddFile;
|
||||
Workers.AddApp += AddApp;
|
||||
thdCheckFiles.Start();
|
||||
});
|
||||
}
|
||||
@@ -312,8 +313,8 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished -= ChkFilesFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
thdCheckFiles?.Abort();
|
||||
thdHashFiles = null;
|
||||
fileView?.Clear();
|
||||
@@ -332,8 +333,8 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished -= ChkFilesFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
|
||||
thdCheckFiles?.Abort();
|
||||
|
||||
@@ -560,8 +561,8 @@ namespace apprepodbmgr.Eto
|
||||
{
|
||||
stopped = true;
|
||||
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.Failed -= AddFilesToDbFailed;
|
||||
Workers.Failed -= ChkFilesFailed;
|
||||
Workers.Failed -= ExtractArchiveFailed;
|
||||
|
||||
@@ -39,17 +39,17 @@ namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class frmMain : Form
|
||||
{
|
||||
int infectedFiles;
|
||||
ObservableCollection<DbFile> lstFiles;
|
||||
int infectedFiles;
|
||||
|
||||
ObservableCollection<DBEntryForEto> lstApps;
|
||||
ObservableCollection<DbFile> lstFiles;
|
||||
DbFile outIter;
|
||||
bool populatingFiles;
|
||||
bool scanningFiles;
|
||||
Thread thdCleanFiles;
|
||||
Thread thdCompressTo;
|
||||
Thread thdPopulateFiles;
|
||||
Thread thdPopulateApps;
|
||||
Thread thdPopulateFiles;
|
||||
Thread thdSaveAs;
|
||||
Thread thdScanFile;
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Failed += LoadAppsFailed;
|
||||
Workers.Finished += LoadAppsFinished;
|
||||
Workers.UpdateProgress += UpdateProgress;
|
||||
Workers.AddApp += AddApp;
|
||||
Workers.AddApp += AddApp;
|
||||
Workers.AddFile += AddFile;
|
||||
Workers.AddFiles += AddFiles;
|
||||
thdPopulateApps = new Thread(Workers.GetAllApps);
|
||||
@@ -242,22 +242,22 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Failed -= LoadAppsFailed;
|
||||
Workers.Finished -= LoadAppsFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.AddApp -= AddApp;
|
||||
if(thdPopulateApps != null)
|
||||
{
|
||||
thdPopulateApps.Abort();
|
||||
thdPopulateApps = null;
|
||||
}
|
||||
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
btnSave.Visible = true;
|
||||
btnHelp.Enabled = true;
|
||||
btnSettings.Enabled = true;
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
btnSave.Visible = true;
|
||||
btnHelp.Enabled = true;
|
||||
btnSettings.Enabled = true;
|
||||
lblAppStatus.Visible = true;
|
||||
lblAppStatus.Text = $"{lstApps.Count} applications";
|
||||
});
|
||||
@@ -326,7 +326,7 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
protected void OnBtnAddClicked(object sender, EventArgs e)
|
||||
{
|
||||
dlgAdd dlgAdd = new dlgAdd();
|
||||
dlgAdd dlgAdd = new dlgAdd();
|
||||
dlgAdd.OnAddedApp += app => { lstApps.Add(new DBEntryForEto(app)); };
|
||||
dlgAdd.ShowModal(this);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
protected void OnBtnStopClicked(object sender, EventArgs e)
|
||||
{
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.Failed -= CompressToFailed;
|
||||
Workers.Failed -= LoadAppsFailed;
|
||||
Workers.Failed -= SaveAsFailed;
|
||||
|
||||
Reference in New Issue
Block a user