diff --git a/osrepodbmgr.Core/ChangeLog b/osrepodbmgr.Core/ChangeLog new file mode 100644 index 0000000..5d267e5 --- /dev/null +++ b/osrepodbmgr.Core/ChangeLog @@ -0,0 +1,20 @@ +2017-05-10 Natalia Portillo + + * Core.cs: + * DBOps.cs: + * SQLite.cs: + * DBCore.cs: + * Schema.cs: + * DicCore.cs: + * Context.cs: + * Settings.cs: + * Checksum.cs: + * DetectOS.cs: + * PlatformID.cs: + * PluginBase.cs: + * packages.config: + * DetectImageFormat.cs: + * osrepodbmgr.Core.csproj: + * Properties/AssemblyInfo.cs: + Refactor: Separate engine code from GUI. + diff --git a/osrepodbmgr/Checksum.cs b/osrepodbmgr.Core/Checksum.cs similarity index 99% rename from osrepodbmgr/Checksum.cs rename to osrepodbmgr.Core/Checksum.cs index 56dc5b3..cc71ebb 100644 --- a/osrepodbmgr/Checksum.cs +++ b/osrepodbmgr.Core/Checksum.cs @@ -35,7 +35,7 @@ using System.Threading; using DiscImageChef.Checksums; using Schemas; -namespace osrepodbmgr +namespace osrepodbmgr.Core { class Checksum { diff --git a/osrepodbmgr.Core/Context.cs b/osrepodbmgr.Core/Context.cs new file mode 100644 index 0000000..6926bef --- /dev/null +++ b/osrepodbmgr.Core/Context.cs @@ -0,0 +1,83 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// 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 System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using Schemas; + +namespace osrepodbmgr.Core +{ + public static class Context + { + public static List files; + public static Dictionary hashes; + 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 copyArchive; + public static string selectedFile; + public static OpticalDiscType workingDisc; + public static BlockMediaType workingDisk; + public static CICMMetadataType metadata; + + public delegate void UnarChangeStatusDelegate(); + public static event UnarChangeStatusDelegate UnarChangeStatus; + + public static void CheckUnar() + { + Core.Finished += CheckUnarFinished; + Core.Failed += CheckUnarFailed; + + Thread thdCheckUnar = new Thread(Core.CheckUnar); + thdCheckUnar.Start(); + } + + static void CheckUnarFinished() + { + unarUsable = true; + if(UnarChangeStatus != null) + UnarChangeStatus(); + Core.Finished -= CheckUnarFinished; + Core.Failed -= CheckUnarFailed; + } + + static void CheckUnarFailed(string text) + { + unarUsable = false; + if(UnarChangeStatus != null) + UnarChangeStatus(); + Core.Finished -= CheckUnarFinished; + Core.Failed -= CheckUnarFailed; + } + } +} diff --git a/osrepodbmgr/Core.cs b/osrepodbmgr.Core/Core.cs similarity index 87% rename from osrepodbmgr/Core.cs rename to osrepodbmgr.Core/Core.cs index ab30b7c..92a255e 100644 --- a/osrepodbmgr/Core.cs +++ b/osrepodbmgr.Core/Core.cs @@ -38,7 +38,7 @@ using Ionic.Zip; using Newtonsoft.Json; using Schemas; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public static partial class Core { @@ -70,10 +70,10 @@ namespace osrepodbmgr { string filesPath; - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && Directory.Exists(MainClass.tmpFolder)) - filesPath = MainClass.tmpFolder; + if(!string.IsNullOrEmpty(Context.tmpFolder) && Directory.Exists(Context.tmpFolder)) + filesPath = Context.tmpFolder; else - filesPath = MainClass.path; + filesPath = Context.path; if(string.IsNullOrEmpty(filesPath)) { @@ -89,8 +89,8 @@ namespace osrepodbmgr try { - MainClass.files = new List(Directory.EnumerateFiles(filesPath, "*", SearchOption.AllDirectories)); - MainClass.files.Sort(); + Context.files = new List(Directory.EnumerateFiles(filesPath, "*", SearchOption.AllDirectories)); + Context.files.Sort(); if(Finished != null) Finished(); } @@ -107,7 +107,7 @@ namespace osrepodbmgr { try { - MainClass.hashes = new Dictionary(); + Context.hashes = new Dictionary(); List alreadyMetadata = new List(); bool foundMetadata = false; @@ -137,7 +137,7 @@ namespace osrepodbmgr // End for metadata long counter = 1; - foreach(string file in MainClass.files) + foreach(string file in Context.files) { // An already known metadata file, skip it if(alreadyMetadata.Contains(file)) @@ -337,14 +337,14 @@ namespace osrepodbmgr string filesPath; FileInfo fi = new FileInfo(file); - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && Directory.Exists(MainClass.tmpFolder)) - filesPath = MainClass.tmpFolder; + if(!string.IsNullOrEmpty(Context.tmpFolder) && Directory.Exists(Context.tmpFolder)) + filesPath = Context.tmpFolder; else - filesPath = MainClass.path; + filesPath = Context.path; string relpath = file.Substring(filesPath.Length + 1); if(UpdateProgress != null) - UpdateProgress(string.Format("Hashing file {0} of {1}", counter, MainClass.files.Count), null, counter, MainClass.files.Count); + UpdateProgress(string.Format("Hashing file {0} of {1}", counter, Context.files.Count), null, counter, Context.files.Count); FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] dataBuffer = new byte[bufferSize]; @@ -389,60 +389,60 @@ namespace osrepodbmgr dbFile.Path = relpath; dbFile.Sha256 = hash; - MainClass.hashes.Add(relpath, dbFile); + Context.hashes.Add(relpath, dbFile); counter++; } if(foundMetadata) { - MainClass.metadata = new CICMMetadataType(); + Context.metadata = new CICMMetadataType(); if(architectures.Count > 0) - MainClass.metadata.Architectures = architectures.Distinct().ToArray(); + Context.metadata.Architectures = architectures.Distinct().ToArray(); if(authors.Count > 0) - MainClass.metadata.Author = authors.Distinct().ToArray(); + Context.metadata.Author = authors.Distinct().ToArray(); // TODO: Check for uniqueness if(barcodes.Count > 0) - MainClass.metadata.Barcodes = barcodes.ToArray(); + Context.metadata.Barcodes = barcodes.ToArray(); if(disks.Count > 0) - MainClass.metadata.BlockMedia = disks.ToArray(); + Context.metadata.BlockMedia = disks.ToArray(); if(categories.Count > 0) - MainClass.metadata.Categories = categories.Distinct().ToArray(); + Context.metadata.Categories = categories.Distinct().ToArray(); if(developers.Count > 0) - MainClass.metadata.Developer = developers.Distinct().ToArray(); + Context.metadata.Developer = developers.Distinct().ToArray(); if(keywords.Count > 0) - MainClass.metadata.Keywords = keywords.Distinct().ToArray(); + Context.metadata.Keywords = keywords.Distinct().ToArray(); if(languages.Count > 0) - MainClass.metadata.Languages = languages.Distinct().ToArray(); - MainClass.metadata.Name = metadataName; + Context.metadata.Languages = languages.Distinct().ToArray(); + Context.metadata.Name = metadataName; if(discs.Count > 0) - MainClass.metadata.OpticalDisc = discs.ToArray(); - MainClass.metadata.PartNumber = metadataPartNo; + Context.metadata.OpticalDisc = discs.ToArray(); + Context.metadata.PartNumber = metadataPartNo; if(performers.Count > 0) - MainClass.metadata.Performer = performers.Distinct().ToArray(); + Context.metadata.Performer = performers.Distinct().ToArray(); if(publishers.Count > 0) - MainClass.metadata.Publisher = publishers.Distinct().ToArray(); + Context.metadata.Publisher = publishers.Distinct().ToArray(); if(releaseDateSpecified) { - MainClass.metadata.ReleaseDate = releaseDate; - MainClass.metadata.ReleaseDateSpecified = true; + Context.metadata.ReleaseDate = releaseDate; + Context.metadata.ReleaseDateSpecified = true; } if(releaseTypeSpecified) { - MainClass.metadata.ReleaseType = releaseType; - MainClass.metadata.ReleaseTypeSpecified = true; + Context.metadata.ReleaseType = releaseType; + Context.metadata.ReleaseTypeSpecified = true; } - MainClass.metadata.SerialNumber = metadataSerial; + Context.metadata.SerialNumber = metadataSerial; if(subcategories.Count > 0) - MainClass.metadata.Subcategories = subcategories.Distinct().ToArray(); + Context.metadata.Subcategories = subcategories.Distinct().ToArray(); if(systems.Count > 0) - MainClass.metadata.Systems = systems.Distinct().ToArray(); - MainClass.metadata.Version = metadataVersion; + Context.metadata.Systems = systems.Distinct().ToArray(); + Context.metadata.Version = metadataVersion; foreach(string metadataFile in alreadyMetadata) - MainClass.files.Remove(metadataFile); + Context.files.Remove(metadataFile); } else - MainClass.metadata = null; + Context.metadata = null; if(Finished != null) Finished(); } @@ -460,10 +460,10 @@ namespace osrepodbmgr try { long counter = 0; - foreach(KeyValuePair kvp in MainClass.hashes) + foreach(KeyValuePair kvp in Context.hashes) { if(UpdateProgress != null) - UpdateProgress(null, "Checking files in database", counter, MainClass.hashes.Count); + UpdateProgress(null, "Checking files in database", counter, Context.hashes.Count); if(AddFile != null) AddFile(kvp.Key, kvp.Value.Sha256, dbCore.DBOps.ExistsFile(kvp.Value.Sha256)); @@ -472,7 +472,7 @@ namespace osrepodbmgr } if(UpdateProgress != null) - UpdateProgress(null, "Retrieving OSes from database", counter, MainClass.hashes.Count); + UpdateProgress(null, "Retrieving OSes from database", counter, Context.hashes.Count); List oses; dbCore.DBOps.GetAllOSes(out oses); @@ -488,10 +488,10 @@ namespace osrepodbmgr UpdateProgress(null, string.Format("Check OS id {0}", os.id), osCounter, osesArray.Length); counter = 0; - foreach(KeyValuePair kvp in MainClass.hashes) + foreach(KeyValuePair kvp in Context.hashes) { if(UpdateProgress2 != null) - UpdateProgress2(null, string.Format("Checking for file {0}", kvp.Value.Path), counter, MainClass.hashes.Count); + UpdateProgress2(null, string.Format("Checking for file {0}", kvp.Value.Path), counter, Context.hashes.Count); if(!dbCore.DBOps.ExistsFileInOS(kvp.Value.Sha256, os.id)) { @@ -594,10 +594,10 @@ namespace osrepodbmgr try { long counter = 0; - foreach(KeyValuePair kvp in MainClass.hashes) + foreach(KeyValuePair kvp in Context.hashes) { if(UpdateProgress != null) - UpdateProgress(null, "Adding files to database", counter, MainClass.hashes.Count); + UpdateProgress(null, "Adding files to database", counter, Context.hashes.Count); if(!dbCore.DBOps.ExistsFile(kvp.Value.Sha256)) dbCore.DBOps.AddFile(kvp.Value.Sha256); @@ -606,18 +606,18 @@ namespace osrepodbmgr } if(UpdateProgress != null) - UpdateProgress(null, "Adding OS information", counter, MainClass.hashes.Count); + UpdateProgress(null, "Adding OS information", counter, Context.hashes.Count); long osId; - dbCore.DBOps.AddOS(MainClass.dbInfo, out osId); + dbCore.DBOps.AddOS(Context.dbInfo, out osId); if(UpdateProgress != null) - UpdateProgress(null, "Creating OS table", counter, MainClass.hashes.Count); + UpdateProgress(null, "Creating OS table", counter, Context.hashes.Count); dbCore.DBOps.CreateTableForOS(osId); counter = 0; - foreach(KeyValuePair kvp in MainClass.hashes) + foreach(KeyValuePair kvp in Context.hashes) { if(UpdateProgress != null) - UpdateProgress(null, "Adding files to OS in database", counter, MainClass.hashes.Count); + UpdateProgress(null, "Adding files to OS in database", counter, Context.hashes.Count); dbCore.DBOps.AddFileToOS(kvp.Value, osId); @@ -711,21 +711,21 @@ namespace osrepodbmgr { try { - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.developer)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.developer)) { if(Failed != null) Failed("Developer cannot be empty"); return; } - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.product)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.product)) { if(Failed != null) Failed("Product cannot be empty"); return; } - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.version)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.version)) { if(Failed != null) Failed("Version cannot be empty"); @@ -737,84 +737,84 @@ namespace osrepodbmgr if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if developer folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.developer); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.developer); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if product folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.product); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.product); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if version folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.version); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.version); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.languages)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.languages)) { // Check if languages folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.languages); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.languages); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.architecture)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.architecture)) { // Check if architecture folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.architecture); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.architecture); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(MainClass.dbInfo.oem) + if(Context.dbInfo.oem) { // Check if oem folder exists destinationFolder = Path.Combine(destinationFolder, "oem"); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.machine)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.machine)) { // Check if architecture folder exists - destinationFolder = Path.Combine(destinationFolder, "for " + MainClass.dbInfo.machine); + destinationFolder = Path.Combine(destinationFolder, "for " + Context.dbInfo.machine); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } string destinationFile = ""; - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.format)) - destinationFile += "[" + MainClass.dbInfo.format + "]"; - if(MainClass.dbInfo.files) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.format)) + destinationFile += "[" + Context.dbInfo.format + "]"; + if(Context.dbInfo.files) { if(destinationFile != "") destinationFile += "_"; destinationFile += "files"; } - if(MainClass.dbInfo.netinstall) + if(Context.dbInfo.netinstall) { if(destinationFile != "") destinationFile += "_"; destinationFile += "netinstall"; } - if(MainClass.dbInfo.source) + if(Context.dbInfo.source) { if(destinationFile != "") destinationFile += "_"; destinationFile += "source"; } - if(MainClass.dbInfo.update) + if(Context.dbInfo.update) { if(destinationFile != "") destinationFile += "_"; destinationFile += "update"; } - if(MainClass.dbInfo.upgrade) + if(Context.dbInfo.upgrade) { if(destinationFile != "") destinationFile += "_"; destinationFile += "upgrade"; } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.description)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.description)) { if(destinationFile != "") destinationFile += "_"; - destinationFile += MainClass.dbInfo.description; + destinationFile += Context.dbInfo.description; } else if(destinationFile == "") { @@ -836,16 +836,16 @@ namespace osrepodbmgr string filesPath; - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && Directory.Exists(MainClass.tmpFolder)) - filesPath = MainClass.tmpFolder; + if(!string.IsNullOrEmpty(Context.tmpFolder) && Directory.Exists(Context.tmpFolder)) + filesPath = Context.tmpFolder; else - filesPath = MainClass.path; + filesPath = Context.path; int counter = 0; - foreach(string file in MainClass.files) + foreach(string file in Context.files) { if(UpdateProgress != null) - UpdateProgress("Choosing files...", file, counter, MainClass.files.Count); + UpdateProgress("Choosing files...", file, counter, Context.files.Count); FileInfo fi = new FileInfo(file); @@ -860,11 +860,11 @@ namespace osrepodbmgr counter++; } - if(MainClass.metadata != null) + if(Context.metadata != null) { MemoryStream xms = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType)); - xs.Serialize(xms, MainClass.metadata); + xs.Serialize(xms, Context.metadata); xms.Position = 0; ZipEntry zx = zf.AddEntry("metadata.xml", xms); @@ -880,7 +880,7 @@ namespace osrepodbmgr js.NullValueHandling = NullValueHandling.Ignore; MemoryStream jms = new MemoryStream(); StreamWriter sw = new StreamWriter(jms, Encoding.UTF8, 1048576, true); - js.Serialize(sw, MainClass.metadata, typeof(CICMMetadataType)); + js.Serialize(sw, Context.metadata, typeof(CICMMetadataType)); sw.Close(); jms.Position = 0; @@ -1040,14 +1040,14 @@ namespace osrepodbmgr public static void OpenArchive() { - if(!MainClass.unarUsable) + if(!Context.unarUsable) { if(Failed != null) Failed("The UnArchiver is not correctly installed"); return; } - if(!File.Exists(MainClass.path)) + if(!File.Exists(Context.path)) { if(Failed != null) Failed("Specified file cannot be found"); @@ -1067,7 +1067,7 @@ namespace osrepodbmgr lsarProcess.StartInfo.CreateNoWindow = true; lsarProcess.StartInfo.RedirectStandardOutput = true; lsarProcess.StartInfo.UseShellExecute = false; - lsarProcess.StartInfo.Arguments = string.Format("-j \"\"\"{0}\"\"\"", MainClass.path); + lsarProcess.StartInfo.Arguments = string.Format("-j \"\"\"{0}\"\"\"", Context.path); lsarProcess.Start(); string lsarOutput = lsarProcess.StandardOutput.ReadToEnd(); lsarProcess.WaitForExit(); @@ -1087,9 +1087,9 @@ namespace osrepodbmgr } } - MainClass.copyArchive = false; - MainClass.archiveFormat = format; - MainClass.noFilesInArchive = counter; + Context.copyArchive = false; + Context.archiveFormat = format; + Context.noFilesInArchive = counter; if(string.IsNullOrEmpty(format)) { @@ -1107,13 +1107,13 @@ namespace osrepodbmgr if(format == "Zip") { - ZipFile zf = ZipFile.Read(MainClass.path); + ZipFile zf = ZipFile.Read(Context.path); foreach(ZipEntry ze in zf) { // ZIP created with Mac OS X, need to be extracted with The UnArchiver to get correct ResourceFork structure if(ze.FileName.StartsWith("__MACOSX", StringComparison.CurrentCulture)) { - MainClass.copyArchive = true; + Context.copyArchive = true; break; } } @@ -1133,14 +1133,14 @@ namespace osrepodbmgr public static void ExtractArchive() { - if(!MainClass.unarUsable) + if(!Context.unarUsable) { if(Failed != null) Failed("The UnArchiver is not correctly installed"); return; } - if(!File.Exists(MainClass.path)) + if(!File.Exists(Context.path)) { if(Failed != null) Failed("Specified file cannot be found"); @@ -1170,28 +1170,28 @@ namespace osrepodbmgr try { - MainClass.unarProcess = new Process(); - MainClass.unarProcess.StartInfo.FileName = Settings.Current.UnArchiverPath; - MainClass.unarProcess.StartInfo.CreateNoWindow = true; - MainClass.unarProcess.StartInfo.RedirectStandardOutput = true; - MainClass.unarProcess.StartInfo.UseShellExecute = false; - MainClass.unarProcess.StartInfo.Arguments = string.Format("-o \"\"\"{0}\"\"\" -r -D -k hidden \"\"\"{1}\"\"\"", tmpFolder, MainClass.path); + Context.unarProcess = new Process(); + Context.unarProcess.StartInfo.FileName = Settings.Current.UnArchiverPath; + Context.unarProcess.StartInfo.CreateNoWindow = true; + Context.unarProcess.StartInfo.RedirectStandardOutput = true; + Context.unarProcess.StartInfo.UseShellExecute = false; + Context.unarProcess.StartInfo.Arguments = string.Format("-o \"\"\"{0}\"\"\" -r -D -k hidden \"\"\"{1}\"\"\"", tmpFolder, Context.path); long counter = 0; - MainClass.unarProcess.OutputDataReceived += (sender, e) => + Context.unarProcess.OutputDataReceived += (sender, e) => { counter++; if(UpdateProgress2 != null) - UpdateProgress2("", e.Data, counter, MainClass.noFilesInArchive); + UpdateProgress2("", e.Data, counter, Context.noFilesInArchive); }; - MainClass.unarProcess.Start(); - MainClass.unarProcess.BeginOutputReadLine(); - MainClass.unarProcess.WaitForExit(); - MainClass.unarProcess.Close(); + Context.unarProcess.Start(); + Context.unarProcess.BeginOutputReadLine(); + Context.unarProcess.WaitForExit(); + Context.unarProcess.Close(); if(Finished != null) Finished(); - MainClass.tmpFolder = tmpFolder; + Context.tmpFolder = tmpFolder; } catch(Exception ex) { @@ -1206,21 +1206,21 @@ namespace osrepodbmgr { try { - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.developer)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.developer)) { if(Failed != null) Failed("Developer cannot be empty"); return; } - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.product)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.product)) { if(Failed != null) Failed("Product cannot be empty"); return; } - if(string.IsNullOrWhiteSpace(MainClass.dbInfo.version)) + if(string.IsNullOrWhiteSpace(Context.dbInfo.version)) { if(Failed != null) Failed("Version cannot be empty"); @@ -1232,84 +1232,84 @@ namespace osrepodbmgr if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if developer folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.developer); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.developer); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if product folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.product); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.product); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); // Check if version folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.version); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.version); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.languages)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.languages)) { // Check if languages folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.languages); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.languages); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.architecture)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.architecture)) { // Check if architecture folder exists - destinationFolder = Path.Combine(destinationFolder, MainClass.dbInfo.architecture); + destinationFolder = Path.Combine(destinationFolder, Context.dbInfo.architecture); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(MainClass.dbInfo.oem) + if(Context.dbInfo.oem) { // Check if oem folder exists destinationFolder = Path.Combine(destinationFolder, "oem"); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.machine)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.machine)) { // Check if architecture folder exists - destinationFolder = Path.Combine(destinationFolder, "for " + MainClass.dbInfo.machine); + destinationFolder = Path.Combine(destinationFolder, "for " + Context.dbInfo.machine); if(!Directory.Exists(destinationFolder)) Directory.CreateDirectory(destinationFolder); } string destinationFile = ""; - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.format)) - destinationFile += "[" + MainClass.dbInfo.format + "]"; - if(MainClass.dbInfo.files) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.format)) + destinationFile += "[" + Context.dbInfo.format + "]"; + if(Context.dbInfo.files) { if(destinationFile != "") destinationFile += "_"; destinationFile += "files"; } - if(MainClass.dbInfo.netinstall) + if(Context.dbInfo.netinstall) { if(destinationFile != "") destinationFile += "_"; destinationFile += "netinstall"; } - if(MainClass.dbInfo.source) + if(Context.dbInfo.source) { if(destinationFile != "") destinationFile += "_"; destinationFile += "source"; } - if(MainClass.dbInfo.update) + if(Context.dbInfo.update) { if(destinationFile != "") destinationFile += "_"; destinationFile += "update"; } - if(MainClass.dbInfo.upgrade) + if(Context.dbInfo.upgrade) { if(destinationFile != "") destinationFile += "_"; destinationFile += "upgrade"; } - if(!string.IsNullOrWhiteSpace(MainClass.dbInfo.description)) + if(!string.IsNullOrWhiteSpace(Context.dbInfo.description)) { if(destinationFile != "") destinationFile += "_"; - destinationFile += MainClass.dbInfo.description; + destinationFile += Context.dbInfo.description; } else if(destinationFile == "") { @@ -1324,7 +1324,7 @@ namespace osrepodbmgr return; } - File.Copy(MainClass.path, destination); + File.Copy(Context.path, destination); } catch(Exception ex) { @@ -1341,9 +1341,9 @@ namespace osrepodbmgr { try { - if(Directory.Exists(MainClass.tmpFolder)) + if(Directory.Exists(Context.tmpFolder)) { - Directory.Delete(MainClass.tmpFolder, true); + Directory.Delete(Context.tmpFolder, true); if(Finished != null) Finished(); } diff --git a/osrepodbmgr/DBCore.cs b/osrepodbmgr.Core/DBCore.cs similarity index 98% rename from osrepodbmgr/DBCore.cs rename to osrepodbmgr.Core/DBCore.cs index 31cf145..f536714 100644 --- a/osrepodbmgr/DBCore.cs +++ b/osrepodbmgr.Core/DBCore.cs @@ -27,7 +27,7 @@ // using System.Data; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public abstract class DBCore { diff --git a/osrepodbmgr/DBOps.cs b/osrepodbmgr.Core/DBOps.cs similarity index 99% rename from osrepodbmgr/DBOps.cs rename to osrepodbmgr.Core/DBOps.cs index 4bef20e..10a015c 100644 --- a/osrepodbmgr/DBOps.cs +++ b/osrepodbmgr.Core/DBOps.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Data; using System.IO; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public struct DBEntry { diff --git a/osrepodbmgr/DetectImageFormat.cs b/osrepodbmgr.Core/DetectImageFormat.cs similarity index 99% rename from osrepodbmgr/DetectImageFormat.cs rename to osrepodbmgr.Core/DetectImageFormat.cs index 7494ae5..5dd80db 100644 --- a/osrepodbmgr/DetectImageFormat.cs +++ b/osrepodbmgr.Core/DetectImageFormat.cs @@ -33,7 +33,7 @@ using System; using DiscImageChef.Filters; using DiscImageChef.ImagePlugins; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public static class ImageFormat { diff --git a/osrepodbmgr/DetectOS.cs b/osrepodbmgr.Core/DetectOS.cs similarity index 100% rename from osrepodbmgr/DetectOS.cs rename to osrepodbmgr.Core/DetectOS.cs diff --git a/osrepodbmgr/DicCore.cs b/osrepodbmgr.Core/DicCore.cs similarity index 99% rename from osrepodbmgr/DicCore.cs rename to osrepodbmgr.Core/DicCore.cs index c8d8f2a..7884931 100644 --- a/osrepodbmgr/DicCore.cs +++ b/osrepodbmgr.Core/DicCore.cs @@ -36,13 +36,13 @@ using DiscImageChef.ImagePlugins; using DiscImageChef.PartPlugins; using Schemas; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public static partial class Core { public static void AddMedia() { - if(string.IsNullOrWhiteSpace(MainClass.selectedFile)) + if(string.IsNullOrWhiteSpace(Context.selectedFile)) { if(Failed != null) Failed("There is no file set"); @@ -51,12 +51,12 @@ namespace osrepodbmgr string filesPath; - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && Directory.Exists(MainClass.tmpFolder)) - filesPath = MainClass.tmpFolder; + if(!string.IsNullOrEmpty(Context.tmpFolder) && Directory.Exists(Context.tmpFolder)) + filesPath = Context.tmpFolder; else - filesPath = MainClass.path; + filesPath = Context.path; - string selectedFile = Path.Combine(filesPath, MainClass.selectedFile); + string selectedFile = Path.Combine(filesPath, Context.selectedFile); if(!File.Exists(selectedFile)) { @@ -681,7 +681,7 @@ namespace osrepodbmgr sidecar.OpticalDisc[0].DumpHardwareArray[0].Software.Version = _imageFormat.GetImageApplicationVersion(); } - MainClass.workingDisc = sidecar.OpticalDisc[0]; + Context.workingDisc = sidecar.OpticalDisc[0]; if(Finished != null) Finished(); return; @@ -905,7 +905,7 @@ namespace osrepodbmgr // TODO: Implement support for getting CHS if(UpdateProgress != null) UpdateProgress(null, "Finishing", maxProgress, maxProgress); - MainClass.workingDisk = sidecar.BlockMedia[0]; + Context.workingDisk = sidecar.BlockMedia[0]; if(Finished != null) Finished(); return; diff --git a/osrepodbmgr/PlatformID.cs b/osrepodbmgr.Core/PlatformID.cs similarity index 100% rename from osrepodbmgr/PlatformID.cs rename to osrepodbmgr.Core/PlatformID.cs diff --git a/osrepodbmgr/PluginBase.cs b/osrepodbmgr.Core/PluginBase.cs similarity index 99% rename from osrepodbmgr/PluginBase.cs rename to osrepodbmgr.Core/PluginBase.cs index 90bd8ca..2bc9967 100644 --- a/osrepodbmgr/PluginBase.cs +++ b/osrepodbmgr.Core/PluginBase.cs @@ -36,7 +36,7 @@ using DiscImageChef.Filesystems; using DiscImageChef.ImagePlugins; using DiscImageChef.PartPlugins; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public class PluginBase { diff --git a/osrepodbmgr.Core/Properties/AssemblyInfo.cs b/osrepodbmgr.Core/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bcca673 --- /dev/null +++ b/osrepodbmgr.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// 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. + +[assembly: AssemblyTitle("osrepodbmgr.Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Claunia.com")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("© Claunia.com")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/osrepodbmgr/SQLite.cs b/osrepodbmgr.Core/SQLite.cs similarity index 99% rename from osrepodbmgr/SQLite.cs rename to osrepodbmgr.Core/SQLite.cs index 86dc2c0..3e6ab32 100644 --- a/osrepodbmgr/SQLite.cs +++ b/osrepodbmgr.Core/SQLite.cs @@ -29,7 +29,7 @@ using System; using System.Data; using System.Data.SQLite; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public class SQLite : DBCore { diff --git a/osrepodbmgr/Schema.cs b/osrepodbmgr.Core/Schema.cs similarity index 99% rename from osrepodbmgr/Schema.cs rename to osrepodbmgr.Core/Schema.cs index ed4ebc2..3bcea9b 100644 --- a/osrepodbmgr/Schema.cs +++ b/osrepodbmgr.Core/Schema.cs @@ -25,7 +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. // -namespace osrepodbmgr +namespace osrepodbmgr.Core { public static class Schema { diff --git a/osrepodbmgr/Settings.cs b/osrepodbmgr.Core/Settings.cs similarity index 99% rename from osrepodbmgr/Settings.cs rename to osrepodbmgr.Core/Settings.cs index 891e9f5..3302069 100644 --- a/osrepodbmgr/Settings.cs +++ b/osrepodbmgr.Core/Settings.cs @@ -32,7 +32,7 @@ using System.Xml.Serialization; using Claunia.PropertyList; using Microsoft.Win32; -namespace osrepodbmgr +namespace osrepodbmgr.Core { public class SetSettings { diff --git a/osrepodbmgr.Core/osrepodbmgr.Core.csproj b/osrepodbmgr.Core/osrepodbmgr.Core.csproj new file mode 100644 index 0000000..4a2d612 --- /dev/null +++ b/osrepodbmgr.Core/osrepodbmgr.Core.csproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + {076D5C4D-9601-4164-B979-0DABACB56BB8} + Library + osrepodbmgr.Core + osrepodbmgr.Core + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + ..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll + + + ..\packages\plist-cil.1.15.0\lib\net40\plist-cil.dll + + + ..\packages\System.Data.SQLite.Core.1.0.105.0\lib\net45\System.Data.SQLite.dll + + + + + + + + + + + + + + + + + + + + + + + + + + {CC48B324-A532-4A45-87A6-6F91F7141E8D} + DiscImageChef.Checksums + + + {F2B84194-26EB-4227-B1C5-6602517E85AE} + DiscImageChef.CommonTypes + + + {0BEB3088-B634-4289-AE17-CDF2D25D00D5} + DiscImageChef.Decoders + + + {74032CBC-339B-42F3-AF6F-E96C261F3E6A} + DiscImageChef.DiscImages + + + {D7016DF2-5A5E-4524-B40D-BA2D59576688} + DiscImageChef.Filesystems + + + {D571B8EF-903D-4353-BDD5-B834F9F029EF} + DiscImageChef.Filters + + + {9F213318-5CB8-4066-A757-074489C9F818} + DiscImageChef.Metadata + + + {DA7AB65D-B5BA-4003-8893-A51BB071BA2F} + DiscImageChef.Partitions + + + + + \ No newline at end of file diff --git a/osrepodbmgr.Core/packages.config b/osrepodbmgr.Core/packages.config new file mode 100644 index 0000000..4225d80 --- /dev/null +++ b/osrepodbmgr.Core/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/osrepodbmgr.sln b/osrepodbmgr.sln index 1c7d3f0..b50f812 100644 --- a/osrepodbmgr.sln +++ b/osrepodbmgr.sln @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Decoders", "D EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Metadata", "DiscImageChef\DiscImageChef.Metadata\DiscImageChef.Metadata.csproj", "{9F213318-5CB8-4066-A757-074489C9F818}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osrepodbmgr.Core", "osrepodbmgr.Core\osrepodbmgr.Core.csproj", "{076D5C4D-9601-4164-B979-0DABACB56BB8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -79,6 +81,10 @@ Global {9F213318-5CB8-4066-A757-074489C9F818}.Debug|x86.Build.0 = Debug|Any CPU {9F213318-5CB8-4066-A757-074489C9F818}.Release|x86.ActiveCfg = Release|Any CPU {9F213318-5CB8-4066-A757-074489C9F818}.Release|x86.Build.0 = Release|Any CPU + {076D5C4D-9601-4164-B979-0DABACB56BB8}.Debug|x86.ActiveCfg = Debug|Any CPU + {076D5C4D-9601-4164-B979-0DABACB56BB8}.Debug|x86.Build.0 = Debug|Any CPU + {076D5C4D-9601-4164-B979-0DABACB56BB8}.Release|x86.ActiveCfg = Release|Any CPU + {076D5C4D-9601-4164-B979-0DABACB56BB8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/osrepodbmgr/ChangeLog b/osrepodbmgr/ChangeLog index 6d75147..494d2fc 100644 --- a/osrepodbmgr/ChangeLog +++ b/osrepodbmgr/ChangeLog @@ -1,3 +1,16 @@ +2017-05-10 Natalia Portillo + + * frmAdd.cs: + * Program.cs: + * frmHelp.cs: + * dlgMetadata.cs: + * frmSettings.cs: + * dlgFilesystem.cs: + * gtk-gui/frmAdd.cs: + * osrepodbmgr.csproj: + * gtk-gui/generated.cs: + Refactor: Separate engine code from GUI. + 2017-05-10 Natalia Portillo * frmAdd.cs: diff --git a/osrepodbmgr/Program.cs b/osrepodbmgr/Program.cs index 1f9bfac..3c8f3d5 100644 --- a/osrepodbmgr/Program.cs +++ b/osrepodbmgr/Program.cs @@ -25,68 +25,21 @@ // 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.Collections.Generic; -using System.Diagnostics; -using System.Threading; using Gtk; -using Schemas; +using osrepodbmgr.Core; namespace osrepodbmgr { static class MainClass { - public static List files; - public static Dictionary hashes; - public static string path; - public static DBEntry dbInfo; - public static bool unarUsable; - public delegate void UnarChangeStatusDelegate(); - public static event UnarChangeStatusDelegate UnarChangeStatus; - public static string tmpFolder; - public static long noFilesInArchive; - public static string archiveFormat; - public static Process unarProcess; - public static bool copyArchive; - public static string selectedFile; - public static OpticalDiscType workingDisc; - public static BlockMediaType workingDisk; - public static CICMMetadataType metadata; - public static void Main(string[] args) { - Settings.LoadSettings(); - CheckUnar(); + Core.Settings.LoadSettings(); + Context.CheckUnar(); Application.Init(); frmAdd win = new frmAdd(); win.Show(); Application.Run(); } - - public static void CheckUnar() - { - Core.Finished += CheckUnarFinished; - Core.Failed += CheckUnarFailed; - - Thread thdCheckUnar = new Thread(Core.CheckUnar); - thdCheckUnar.Start(); - } - - static void CheckUnarFinished() - { - unarUsable = true; - if(UnarChangeStatus != null) - UnarChangeStatus(); - Core.Finished -= CheckUnarFinished; - Core.Failed -= CheckUnarFailed; - } - - static void CheckUnarFailed(string text) - { - unarUsable = false; - if(UnarChangeStatus != null) - UnarChangeStatus(); - Core.Finished -= CheckUnarFinished; - Core.Failed -= CheckUnarFailed; - } } } diff --git a/osrepodbmgr/dlgFilesystem.cs b/osrepodbmgr/dlgFilesystem.cs index bfbbd08..dc4f12d 100644 --- a/osrepodbmgr/dlgFilesystem.cs +++ b/osrepodbmgr/dlgFilesystem.cs @@ -28,6 +28,7 @@ using System; using Gtk; using Schemas; + namespace osrepodbmgr { public partial class dlgFilesystem : Dialog diff --git a/osrepodbmgr/dlgMetadata.cs b/osrepodbmgr/dlgMetadata.cs index 91c717b..4880755 100644 --- a/osrepodbmgr/dlgMetadata.cs +++ b/osrepodbmgr/dlgMetadata.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Threading; using Gtk; +using osrepodbmgr.Core; using Schemas; namespace osrepodbmgr @@ -216,7 +217,7 @@ namespace osrepodbmgr void FillFilesCombos() { - foreach(KeyValuePair files in MainClass.hashes) + foreach(KeyValuePair files in Context.hashes) { lstFilesForDisc.AppendValues(files.Key); lstFilesForDisk.AppendValues(files.Key); @@ -227,7 +228,7 @@ namespace osrepodbmgr { // TODO: Check that files are not already added as disks lstFilesForDisc.Clear(); - foreach(KeyValuePair files in MainClass.hashes) + foreach(KeyValuePair files in Context.hashes) lstFilesForDisc.AppendValues(files.Key); } @@ -235,7 +236,7 @@ namespace osrepodbmgr { // TODO: Check that files are not already added as discs lstFilesForDisk.Clear(); - foreach(KeyValuePair files in MainClass.hashes) + foreach(KeyValuePair files in Context.hashes) lstFilesForDisk.AppendValues(files.Key); } @@ -704,7 +705,7 @@ namespace osrepodbmgr protected void OnBtnAddDiscClicked(object sender, EventArgs e) { - MainClass.selectedFile = cmbFilesForNewDisc.ActiveText; + Context.selectedFile = cmbFilesForNewDisc.ActiveText; notebook3.GetNthPage(0).Visible = false; notebook3.GetNthPage(1).Visible = false; notebook3.GetNthPage(2).Visible = false; @@ -719,15 +720,15 @@ namespace osrepodbmgr buttonOk.Visible = false; btnEditDisc.Visible = false; btnClearDiscs.Visible = false; - Core.Failed += OnDiscAddFailed; - Core.Finished += OnDiscAddFinished; - Core.UpdateProgress += UpdateDiscProgress1; - Core.UpdateProgress2 += UpdateDiscProgress2; - MainClass.workingDisc = null; + Core.Core.Failed += OnDiscAddFailed; + Core.Core.Finished += OnDiscAddFinished; + Core.Core.UpdateProgress += UpdateDiscProgress1; + Core.Core.UpdateProgress2 += UpdateDiscProgress2; + Context.workingDisc = null; btnStopAddDisc.Visible = true; btnAddDisc.Visible = false; btnRemoveDiscs.Visible = false; - thdDisc = new Thread(Core.AddMedia); + thdDisc = new Thread(Core.Core.AddMedia); thdDisc.Start(); } @@ -773,7 +774,7 @@ namespace osrepodbmgr dlgMsg.Run(); dlgMsg.Destroy(); } - MainClass.selectedFile = ""; + Context.selectedFile = ""; notebook3.GetNthPage(0).Visible = true; notebook3.GetNthPage(1).Visible = true; notebook3.GetNthPage(2).Visible = true; @@ -788,11 +789,11 @@ namespace osrepodbmgr buttonOk.Visible = true; btnEditDisc.Visible = true; btnClearDiscs.Visible = true; - Core.Failed -= OnDiscAddFailed; - Core.Finished -= OnDiscAddFinished; - Core.UpdateProgress -= UpdateDiscProgress1; - Core.UpdateProgress2 -= UpdateDiscProgress2; - MainClass.workingDisc = null; + Core.Core.Failed -= OnDiscAddFailed; + Core.Core.Finished -= OnDiscAddFinished; + Core.Core.UpdateProgress -= UpdateDiscProgress1; + Core.Core.UpdateProgress2 -= UpdateDiscProgress2; + Context.workingDisc = null; btnStopAddDisc.Visible = false; btnAddDisc.Visible = true; btnRemoveDiscs.Visible = true; @@ -804,12 +805,12 @@ namespace osrepodbmgr { Application.Invoke(delegate { - if(MainClass.workingDisc == null) + if(Context.workingDisc == null) return; - OpticalDiscType disc = MainClass.workingDisc; + OpticalDiscType disc = Context.workingDisc; - lstDiscs.AppendValues(MainClass.selectedFile, disc); + lstDiscs.AppendValues(Context.selectedFile, disc); List files = new List(); files.Add(disc.Image.Value); if(disc.ADIP != null) @@ -890,7 +891,7 @@ namespace osrepodbmgr while(cmbFilesForNewDisk.Model.IterNext(ref iter)); } - MainClass.selectedFile = ""; + Context.selectedFile = ""; notebook3.GetNthPage(0).Visible = true; notebook3.GetNthPage(1).Visible = true; notebook3.GetNthPage(2).Visible = true; @@ -905,11 +906,11 @@ namespace osrepodbmgr buttonOk.Visible = true; btnEditDisc.Visible = true; btnClearDiscs.Visible = true; - Core.Failed -= OnDiscAddFailed; - Core.Finished -= OnDiscAddFinished; - Core.UpdateProgress -= UpdateDiscProgress1; - Core.UpdateProgress2 -= UpdateDiscProgress2; - MainClass.workingDisc = null; + Core.Core.Failed -= OnDiscAddFailed; + Core.Core.Finished -= OnDiscAddFinished; + Core.Core.UpdateProgress -= UpdateDiscProgress1; + Core.Core.UpdateProgress2 -= UpdateDiscProgress2; + Context.workingDisc = null; btnStopAddDisc.Visible = false; btnAddDisc.Visible = true; btnRemoveDiscs.Visible = true; @@ -936,7 +937,7 @@ namespace osrepodbmgr protected void OnBtnAddDiskClicked(object sender, EventArgs e) { - MainClass.selectedFile = cmbFilesForNewDisk.ActiveText; + Context.selectedFile = cmbFilesForNewDisk.ActiveText; notebook3.GetNthPage(0).Visible = false; notebook3.GetNthPage(1).Visible = false; notebook3.GetNthPage(2).Visible = false; @@ -951,15 +952,15 @@ namespace osrepodbmgr buttonOk.Visible = false; btnEditDisk.Visible = false; btnClearDisks.Visible = false; - Core.Failed += OnDiskAddFailed; - Core.Finished += OnDiskAddFinished; - Core.UpdateProgress += UpdateDiskProgress1; - Core.UpdateProgress2 += UpdateDiskProgress2; - MainClass.workingDisk = null; + Core.Core.Failed += OnDiskAddFailed; + Core.Core.Finished += OnDiskAddFinished; + Core.Core.UpdateProgress += UpdateDiskProgress1; + Core.Core.UpdateProgress2 += UpdateDiskProgress2; + Context.workingDisk = null; btnStopAddDisk.Visible = true; btnAddDisk.Visible = false; btnRemoveDisk.Visible = false; - thdDisk = new Thread(Core.AddMedia); + thdDisk = new Thread(Core.Core.AddMedia); thdDisk.Start(); } @@ -1005,7 +1006,7 @@ namespace osrepodbmgr dlgMsg.Run(); dlgMsg.Destroy(); } - MainClass.selectedFile = ""; + Context.selectedFile = ""; notebook3.GetNthPage(0).Visible = true; notebook3.GetNthPage(1).Visible = true; notebook3.GetNthPage(2).Visible = true; @@ -1020,11 +1021,11 @@ namespace osrepodbmgr buttonOk.Visible = true; btnEditDisk.Visible = true; btnClearDisks.Visible = true; - Core.Failed -= OnDiskAddFailed; - Core.Finished -= OnDiskAddFinished; - Core.UpdateProgress -= UpdateDiskProgress1; - Core.UpdateProgress2 -= UpdateDiskProgress2; - MainClass.workingDisk = null; + Core.Core.Failed -= OnDiskAddFailed; + Core.Core.Finished -= OnDiskAddFinished; + Core.Core.UpdateProgress -= UpdateDiskProgress1; + Core.Core.UpdateProgress2 -= UpdateDiskProgress2; + Context.workingDisk = null; btnStopAddDisk.Visible = false; btnAddDisk.Visible = true; btnRemoveDisk.Visible = true; @@ -1036,10 +1037,10 @@ namespace osrepodbmgr { Application.Invoke(delegate { - if(MainClass.workingDisk == null) + if(Context.workingDisk == null) return; - BlockMediaType disk = MainClass.workingDisk; + BlockMediaType disk = Context.workingDisk; lstDisks.AppendValues(disk.Image.Value, disk); List files = new List(); @@ -1118,7 +1119,7 @@ namespace osrepodbmgr while(cmbFilesForNewDisk.Model.IterNext(ref iter)); } - MainClass.selectedFile = ""; + Context.selectedFile = ""; notebook3.GetNthPage(0).Visible = true; notebook3.GetNthPage(1).Visible = true; notebook3.GetNthPage(2).Visible = true; @@ -1133,11 +1134,11 @@ namespace osrepodbmgr buttonOk.Visible = true; btnEditDisk.Visible = true; btnClearDisks.Visible = true; - Core.Failed -= OnDiskAddFailed; - Core.Finished -= OnDiskAddFinished; - Core.UpdateProgress -= UpdateDiskProgress1; - Core.UpdateProgress2 -= UpdateDiskProgress2; - MainClass.workingDisk = null; + Core.Core.Failed -= OnDiskAddFailed; + Core.Core.Finished -= OnDiskAddFinished; + Core.Core.UpdateProgress -= UpdateDiskProgress1; + Core.Core.UpdateProgress2 -= UpdateDiskProgress2; + Context.workingDisk = null; btnStopAddDisk.Visible = false; btnAddDisk.Visible = true; btnRemoveDisk.Visible = true; diff --git a/osrepodbmgr/frmAdd.cs b/osrepodbmgr/frmAdd.cs index 7f8dc18..4b59a6b 100644 --- a/osrepodbmgr/frmAdd.cs +++ b/osrepodbmgr/frmAdd.cs @@ -33,6 +33,7 @@ using System.Xml.Serialization; using Gtk; using Newtonsoft.Json; using osrepodbmgr; +using osrepodbmgr.Core; using Schemas; public partial class frmAdd : Window @@ -56,8 +57,8 @@ public partial class frmAdd : Window Core.InitDB(); - MainClass.UnarChangeStatus += UnarChangeStatus; - MainClass.CheckUnar(); + Context.UnarChangeStatus += UnarChangeStatus; + Context.CheckUnar(); CellRendererText filenameCell = new CellRendererText(); CellRendererText hashCell = new CellRendererText(); @@ -133,7 +134,7 @@ public partial class frmAdd : Window { Application.Invoke(delegate { - btnArchive.Sensitive = MainClass.unarUsable; + btnArchive.Sensitive = Context.unarUsable; }); } @@ -183,7 +184,7 @@ public partial class frmAdd : Window }); thdFindFiles = new Thread(Core.FindFiles); - MainClass.path = dlgFolder.Filename; + Context.path = dlgFolder.Filename; Core.Failed += FindFilesFailed; Core.Finished += FindFilesFinished; btnStop.Visible = true; @@ -381,11 +382,11 @@ public partial class frmAdd : Window chkSource.Sensitive = true; btnMetadata.Visible = true; - if(MainClass.metadata != null) + if(Context.metadata != null) { - if(MainClass.metadata.Developer != null) + if(Context.metadata.Developer != null) { - foreach(string developer in MainClass.metadata.Developer) + foreach(string developer in Context.metadata.Developer) { if(!string.IsNullOrWhiteSpace(txtDeveloper.Text)) txtDeveloper.Text += ","; @@ -393,14 +394,14 @@ public partial class frmAdd : Window } } - if(!string.IsNullOrWhiteSpace(MainClass.metadata.Name)) - txtProduct.Text = MainClass.metadata.Name; - if(!string.IsNullOrWhiteSpace(MainClass.metadata.Version)) - txtVersion.Text = MainClass.metadata.Version; + if(!string.IsNullOrWhiteSpace(Context.metadata.Name)) + txtProduct.Text = Context.metadata.Name; + if(!string.IsNullOrWhiteSpace(Context.metadata.Version)) + txtVersion.Text = Context.metadata.Version; - if(MainClass.metadata.Languages != null) + if(Context.metadata.Languages != null) { - foreach(LanguagesTypeLanguage language in MainClass.metadata.Languages) + foreach(LanguagesTypeLanguage language in Context.metadata.Languages) { if(!string.IsNullOrWhiteSpace(txtLanguages.Text)) txtLanguages.Text += ","; @@ -408,9 +409,9 @@ public partial class frmAdd : Window } } - if(MainClass.metadata.Architectures != null) + if(Context.metadata.Architectures != null) { - foreach(ArchitecturesTypeArchitecture architecture in MainClass.metadata.Architectures) + foreach(ArchitecturesTypeArchitecture architecture in Context.metadata.Architectures) { if(!string.IsNullOrWhiteSpace(txtArchitecture.Text)) txtArchitecture.Text += ","; @@ -418,9 +419,9 @@ public partial class frmAdd : Window } } - if(MainClass.metadata.Systems != null) + if(Context.metadata.Systems != null) { - foreach(string machine in MainClass.metadata.Systems) + foreach(string machine in Context.metadata.Systems) { if(!string.IsNullOrWhiteSpace(txtMachine.Text)) txtMachine.Text += ","; @@ -469,9 +470,9 @@ public partial class frmAdd : Window { btnFolder.Visible = true; btnArchive.Visible = true; - MainClass.path = ""; - MainClass.files = null; - MainClass.hashes = null; + Context.path = ""; + Context.files = null; + Context.hashes = null; btnStop.Visible = false; btnAdd.Visible = false; btnPack.Visible = false; @@ -513,7 +514,7 @@ public partial class frmAdd : Window chkNetinstall.Active = false; chkSource.Active = false; - if(MainClass.tmpFolder != null) + if(Context.tmpFolder != null) { btnStop.Visible = false; prgProgress.Visible = true; @@ -536,7 +537,7 @@ public partial class frmAdd : Window } btnMetadata.Visible = false; - MainClass.metadata = null; + Context.metadata = null; } public void UpdateProgress(string text, string inner, long current, long maximum) @@ -611,13 +612,13 @@ public partial class frmAdd : Window thdOpenArchive = null; } - if(MainClass.unarProcess != null) + if(Context.unarProcess != null) { - MainClass.unarProcess.Kill(); - MainClass.unarProcess = null; + Context.unarProcess.Kill(); + Context.unarProcess = null; } - if(MainClass.tmpFolder != null) + if(Context.tmpFolder != null) { btnStop.Visible = false; prgProgress.Text = "Removing temporary files"; @@ -699,8 +700,8 @@ public partial class frmAdd : Window } Core.Failed -= RemoveTempFilesFailed; Core.Finished -= RemoveTempFilesFinished; - MainClass.path = null; - MainClass.tmpFolder = null; + Context.path = null; + Context.tmpFolder = null; RestoreUI(); }); } @@ -716,8 +717,8 @@ public partial class frmAdd : Window } Core.Failed -= RemoveTempFilesFailed; Core.Finished -= RemoveTempFilesFinished; - MainClass.path = null; - MainClass.tmpFolder = null; + Context.path = null; + Context.tmpFolder = null; RestoreUI(); }); } @@ -747,37 +748,37 @@ public partial class frmAdd : Window Core.Finished += AddFilesToDbFinished; Core.Failed += AddFilesToDbFailed; - MainClass.dbInfo.architecture = txtArchitecture.Text; - MainClass.dbInfo.description = txtDescription.Text; - MainClass.dbInfo.developer = txtDeveloper.Text; - MainClass.dbInfo.format = txtFormat.Text; - MainClass.dbInfo.languages = txtLanguages.Text; - MainClass.dbInfo.machine = txtMachine.Text; - MainClass.dbInfo.product = txtProduct.Text; - MainClass.dbInfo.version = txtVersion.Text; - MainClass.dbInfo.files = chkFiles.Active; - MainClass.dbInfo.netinstall = chkNetinstall.Active; - MainClass.dbInfo.oem = chkOem.Active; - MainClass.dbInfo.source = chkSource.Active; - MainClass.dbInfo.update = chkUpdate.Active; - MainClass.dbInfo.upgrade = chkUpgrade.Active; + Context.dbInfo.architecture = txtArchitecture.Text; + Context.dbInfo.description = txtDescription.Text; + Context.dbInfo.developer = txtDeveloper.Text; + Context.dbInfo.format = txtFormat.Text; + Context.dbInfo.languages = txtLanguages.Text; + Context.dbInfo.machine = txtMachine.Text; + Context.dbInfo.product = txtProduct.Text; + Context.dbInfo.version = txtVersion.Text; + Context.dbInfo.files = chkFiles.Active; + Context.dbInfo.netinstall = chkNetinstall.Active; + Context.dbInfo.oem = chkOem.Active; + Context.dbInfo.source = chkSource.Active; + Context.dbInfo.update = chkUpdate.Active; + Context.dbInfo.upgrade = chkUpgrade.Active; - if(MainClass.metadata != null) + if(Context.metadata != null) { MemoryStream ms = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType)); - xs.Serialize(ms, MainClass.metadata); - MainClass.dbInfo.xml = ms.ToArray(); + xs.Serialize(ms, Context.metadata); + Context.dbInfo.xml = ms.ToArray(); JsonSerializer js = new JsonSerializer(); ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms); - js.Serialize(sw, MainClass.metadata, typeof(CICMMetadataType)); - MainClass.dbInfo.json = ms.ToArray(); + js.Serialize(sw, Context.metadata, typeof(CICMMetadataType)); + Context.dbInfo.json = ms.ToArray(); } else { - MainClass.dbInfo.xml = null; - MainClass.dbInfo.json = null; + Context.dbInfo.xml = null; + Context.dbInfo.json = null; } thdAddFiles = new Thread(Core.AddFilesToDb); @@ -799,9 +800,9 @@ public partial class frmAdd : Window long counter = 0; fileView.Clear(); - foreach(KeyValuePair kvp in MainClass.hashes) + foreach(KeyValuePair kvp in Context.hashes) { - UpdateProgress(null, "Updating table", counter, MainClass.hashes.Count); + UpdateProgress(null, "Updating table", counter, Context.hashes.Count); fileView.AppendValues(kvp.Key, kvp.Value.Path, true, "green", "black"); counter++; } @@ -873,22 +874,22 @@ public partial class frmAdd : Window Core.FinishedWithText += PackFilesFinished; Core.Failed += PackFilesFailed; - MainClass.dbInfo.architecture = txtArchitecture.Text; - MainClass.dbInfo.description = txtDescription.Text; - MainClass.dbInfo.developer = txtDeveloper.Text; - MainClass.dbInfo.format = txtFormat.Text; - MainClass.dbInfo.languages = txtLanguages.Text; - MainClass.dbInfo.machine = txtMachine.Text; - MainClass.dbInfo.product = txtProduct.Text; - MainClass.dbInfo.version = txtVersion.Text; - MainClass.dbInfo.files = chkFiles.Active; - MainClass.dbInfo.netinstall = chkNetinstall.Active; - MainClass.dbInfo.oem = chkOem.Active; - MainClass.dbInfo.source = chkSource.Active; - MainClass.dbInfo.update = chkUpdate.Active; - MainClass.dbInfo.upgrade = chkUpgrade.Active; + Context.dbInfo.architecture = txtArchitecture.Text; + Context.dbInfo.description = txtDescription.Text; + Context.dbInfo.developer = txtDeveloper.Text; + Context.dbInfo.format = txtFormat.Text; + Context.dbInfo.languages = txtLanguages.Text; + Context.dbInfo.machine = txtMachine.Text; + Context.dbInfo.product = txtProduct.Text; + Context.dbInfo.version = txtVersion.Text; + Context.dbInfo.files = chkFiles.Active; + Context.dbInfo.netinstall = chkNetinstall.Active; + Context.dbInfo.oem = chkOem.Active; + Context.dbInfo.source = chkSource.Active; + Context.dbInfo.update = chkUpdate.Active; + Context.dbInfo.upgrade = chkUpgrade.Active; - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && MainClass.copyArchive) + if(!string.IsNullOrEmpty(Context.tmpFolder) && Context.copyArchive) { thdPulseProgress = new Thread(() => { @@ -985,7 +986,7 @@ public partial class frmAdd : Window protected void OnBtnArchiveClicked(object sender, EventArgs e) { - if(!MainClass.unarUsable) + if(!Context.unarUsable) { MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Cannot open archives without a working unar installation."); dlgMsg.Run(); @@ -1020,7 +1021,7 @@ public partial class frmAdd : Window }); thdOpenArchive = new Thread(Core.OpenArchive); - MainClass.path = dlgFolder.Filename; + Context.path = dlgFolder.Filename; Core.Failed += OpenArchiveFailed; Core.Finished += OpenArchiveFinished; btnStop.Visible = true; @@ -1114,7 +1115,7 @@ public partial class frmAdd : Window Core.Finished -= ExtractArchiveFinished; Core.UpdateProgress2 -= UpdateProgress2; thdExtractArchive = null; - if(MainClass.tmpFolder != null) + if(Context.tmpFolder != null) { btnStop.Visible = false; prgProgress.Text = "Removing temporary files"; @@ -1180,16 +1181,16 @@ public partial class frmAdd : Window protected void OnBtnMetadataClicked(object sender, EventArgs e) { dlgMetadata _dlgMetadata = new dlgMetadata(); - _dlgMetadata.Metadata = MainClass.metadata; + _dlgMetadata.Metadata = Context.metadata; _dlgMetadata.FillFields(); if(_dlgMetadata.Run() == (int)ResponseType.Ok) { - MainClass.metadata = _dlgMetadata.Metadata; + Context.metadata = _dlgMetadata.Metadata; if(string.IsNullOrWhiteSpace(txtDeveloper.Text)) { - foreach(string developer in MainClass.metadata.Developer) + foreach(string developer in Context.metadata.Developer) { if(!string.IsNullOrWhiteSpace(txtDeveloper.Text)) txtDeveloper.Text += ","; @@ -1199,21 +1200,21 @@ public partial class frmAdd : Window if(string.IsNullOrWhiteSpace(txtProduct.Text)) { - if(!string.IsNullOrWhiteSpace(MainClass.metadata.Name)) - txtProduct.Text = MainClass.metadata.Name; + if(!string.IsNullOrWhiteSpace(Context.metadata.Name)) + txtProduct.Text = Context.metadata.Name; } if(string.IsNullOrWhiteSpace(txtVersion.Text)) { - if(!string.IsNullOrWhiteSpace(MainClass.metadata.Version)) - txtVersion.Text = MainClass.metadata.Version; + if(!string.IsNullOrWhiteSpace(Context.metadata.Version)) + txtVersion.Text = Context.metadata.Version; } if(string.IsNullOrWhiteSpace(txtLanguages.Text)) { - if(MainClass.metadata.Languages != null) + if(Context.metadata.Languages != null) { - foreach(LanguagesTypeLanguage language in MainClass.metadata.Languages) + foreach(LanguagesTypeLanguage language in Context.metadata.Languages) { if(!string.IsNullOrWhiteSpace(txtLanguages.Text)) txtLanguages.Text += ","; @@ -1224,9 +1225,9 @@ public partial class frmAdd : Window if(string.IsNullOrWhiteSpace(txtArchitecture.Text)) { - if(MainClass.metadata.Architectures != null) + if(Context.metadata.Architectures != null) { - foreach(ArchitecturesTypeArchitecture architecture in MainClass.metadata.Architectures) + foreach(ArchitecturesTypeArchitecture architecture in Context.metadata.Architectures) { if(!string.IsNullOrWhiteSpace(txtArchitecture.Text)) txtArchitecture.Text += ","; @@ -1237,9 +1238,9 @@ public partial class frmAdd : Window if(string.IsNullOrWhiteSpace(txtMachine.Text)) { - if(MainClass.metadata.Systems != null) + if(Context.metadata.Systems != null) { - foreach(string machine in MainClass.metadata.Systems) + foreach(string machine in Context.metadata.Systems) { if(!string.IsNullOrWhiteSpace(txtMachine.Text)) txtMachine.Text += ","; @@ -1262,13 +1263,13 @@ public partial class frmAdd : Window string name = (string)fileView.GetValue(fileIter, 0); string filesPath; - if(!string.IsNullOrEmpty(MainClass.tmpFolder) && Directory.Exists(MainClass.tmpFolder)) - filesPath = MainClass.tmpFolder; + if(!string.IsNullOrEmpty(Context.tmpFolder) && Directory.Exists(Context.tmpFolder)) + filesPath = Context.tmpFolder; else - filesPath = MainClass.path; + filesPath = Context.path; - MainClass.hashes.Remove(name); - MainClass.files.Remove(System.IO.Path.Combine(filesPath, name)); + Context.hashes.Remove(name); + Context.files.Remove(System.IO.Path.Combine(filesPath, name)); fileView.Remove(ref fileIter); } } diff --git a/osrepodbmgr/frmHelp.cs b/osrepodbmgr/frmHelp.cs index d998972..daa0fa3 100644 --- a/osrepodbmgr/frmHelp.cs +++ b/osrepodbmgr/frmHelp.cs @@ -26,6 +26,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // using System; + namespace osrepodbmgr { public partial class frmHelp : Gtk.Window diff --git a/osrepodbmgr/frmSettings.cs b/osrepodbmgr/frmSettings.cs index 39e622f..3db8ac3 100644 --- a/osrepodbmgr/frmSettings.cs +++ b/osrepodbmgr/frmSettings.cs @@ -29,6 +29,7 @@ using System; using System.IO; using System.Threading; using Gtk; +using osrepodbmgr.Core; namespace osrepodbmgr { @@ -40,10 +41,10 @@ namespace osrepodbmgr base(WindowType.Toplevel) { Build(); - txtTmp.Text = osrepodbmgr.Settings.Current.TemporaryFolder; - txtUnar.Text = osrepodbmgr.Settings.Current.UnArchiverPath; - txtDatabase.Text = osrepodbmgr.Settings.Current.DatabasePath; - txtRepository.Text = osrepodbmgr.Settings.Current.RepositoryPath; + txtTmp.Text = Core.Settings.Current.TemporaryFolder; + txtUnar.Text = Core.Settings.Current.UnArchiverPath; + txtDatabase.Text = Core.Settings.Current.DatabasePath; + txtRepository.Text = Core.Settings.Current.RepositoryPath; if(!string.IsNullOrWhiteSpace(txtUnar.Text)) CheckUnar(); @@ -57,14 +58,14 @@ namespace osrepodbmgr protected void OnBtnApplyClicked(object sender, EventArgs e) { // TODO: Check sanity - osrepodbmgr.Settings.Current.TemporaryFolder = txtTmp.Text; - osrepodbmgr.Settings.Current.UnArchiverPath = txtUnar.Text; - osrepodbmgr.Settings.Current.DatabasePath = txtDatabase.Text; - osrepodbmgr.Settings.Current.RepositoryPath = txtRepository.Text; - osrepodbmgr.Settings.SaveSettings(); - Core.CloseDB(); - Core.InitDB(); - MainClass.CheckUnar(); + Core.Settings.Current.TemporaryFolder = txtTmp.Text; + Core.Settings.Current.UnArchiverPath = txtUnar.Text; + Core.Settings.Current.DatabasePath = txtDatabase.Text; + Core.Settings.Current.RepositoryPath = txtRepository.Text; + Core.Settings.SaveSettings(); + Core.Core.CloseDB(); + Core.Core.InitDB(); + Context.CheckUnar(); Destroy(); } @@ -121,7 +122,7 @@ namespace osrepodbmgr "Cancel", ResponseType.Cancel, "Choose", ResponseType.Accept); dlgFile.SelectMultiple = false; dlgFile.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); - dlgFile.SetFilename("osrepodbmgr.db"); + dlgFile.SetFilename("Core.db"); if(dlgFile.Run() == (int)ResponseType.Accept) { @@ -181,12 +182,12 @@ namespace osrepodbmgr void CheckUnar() { - Core.FinishedWithText += CheckUnarFinished; - Core.Failed += CheckUnarFailed; + Core.Core.FinishedWithText += CheckUnarFinished; + Core.Core.Failed += CheckUnarFailed; - oldUnarPath = osrepodbmgr.Settings.Current.UnArchiverPath; - osrepodbmgr.Settings.Current.UnArchiverPath = txtUnar.Text; - Thread thdCheckUnar = new Thread(Core.CheckUnar); + oldUnarPath = Core.Settings.Current.UnArchiverPath; + Core.Settings.Current.UnArchiverPath = txtUnar.Text; + Thread thdCheckUnar = new Thread(Core.Core.CheckUnar); thdCheckUnar.Start(); } @@ -194,12 +195,12 @@ namespace osrepodbmgr { Application.Invoke(delegate { - Core.FinishedWithText -= CheckUnarFinished; - Core.Failed -= CheckUnarFailed; + Core.Core.FinishedWithText -= CheckUnarFinished; + Core.Core.Failed -= CheckUnarFailed; lblUnarVersion.Text = text; lblUnarVersion.Visible = true; - osrepodbmgr.Settings.Current.UnArchiverPath = oldUnarPath; + Core.Settings.Current.UnArchiverPath = oldUnarPath; }); } @@ -207,14 +208,14 @@ namespace osrepodbmgr { Application.Invoke(delegate { - Core.FinishedWithText -= CheckUnarFinished; - Core.Failed -= CheckUnarFailed; + Core.Core.FinishedWithText -= CheckUnarFinished; + Core.Core.Failed -= CheckUnarFailed; if(string.IsNullOrWhiteSpace(oldUnarPath)) txtUnar.Text = ""; else txtUnar.Text = oldUnarPath; - osrepodbmgr.Settings.Current.UnArchiverPath = oldUnarPath; + Core.Settings.Current.UnArchiverPath = oldUnarPath; MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, text); dlgMsg.Run(); dlgMsg.Destroy(); diff --git a/osrepodbmgr/gtk-gui/frmAdd.cs b/osrepodbmgr/gtk-gui/frmAdd.cs index 16f132b..94e8a53 100644 --- a/osrepodbmgr/gtk-gui/frmAdd.cs +++ b/osrepodbmgr/gtk-gui/frmAdd.cs @@ -708,7 +708,7 @@ public partial class frmAdd w63.Expand = false; w63.Fill = false; this.Add(this.vbox1); - if ((this.Child != null)) + if((this.Child != null)) { this.Child.ShowAll(); } diff --git a/osrepodbmgr/gtk-gui/generated.cs b/osrepodbmgr/gtk-gui/generated.cs index 50283a9..f916e7a 100644 --- a/osrepodbmgr/gtk-gui/generated.cs +++ b/osrepodbmgr/gtk-gui/generated.cs @@ -8,7 +8,7 @@ namespace Stetic internal static void Initialize(Gtk.Widget iconRenderer) { - if ((Stetic.Gui.initialized == false)) + if((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; } @@ -20,7 +20,7 @@ namespace Stetic public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size) { Gdk.Pixbuf res = widget.RenderIcon(name, size, null); - if ((res != null)) + if((res != null)) { return res; } @@ -32,9 +32,9 @@ namespace Stetic { return Gtk.IconTheme.Default.LoadIcon(name, sz, 0); } - catch (System.Exception) + catch(System.Exception) { - if ((name != "gtk-missing-image")) + if((name != "gtk-missing-image")) { return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size); } diff --git a/osrepodbmgr/osrepodbmgr.csproj b/osrepodbmgr/osrepodbmgr.csproj index be3eaf8..460f4df 100644 --- a/osrepodbmgr/osrepodbmgr.csproj +++ b/osrepodbmgr/osrepodbmgr.csproj @@ -77,20 +77,8 @@ - - - - - - - - - - - - @@ -103,38 +91,14 @@ - - {CC48B324-A532-4A45-87A6-6F91F7141E8D} - DiscImageChef.Checksums - - - {74032CBC-339B-42F3-AF6F-E96C261F3E6A} - DiscImageChef.DiscImages - - - {D7016DF2-5A5E-4524-B40D-BA2D59576688} - DiscImageChef.Filesystems - - - {D571B8EF-903D-4353-BDD5-B834F9F029EF} - DiscImageChef.Filters - - - {DA7AB65D-B5BA-4003-8893-A51BB071BA2F} - DiscImageChef.Partitions - - - {F2B84194-26EB-4227-B1C5-6602517E85AE} - DiscImageChef.CommonTypes - - - {0BEB3088-B634-4289-AE17-CDF2D25D00D5} - DiscImageChef.Decoders - {9F213318-5CB8-4066-A757-074489C9F818} DiscImageChef.Metadata + + {076D5C4D-9601-4164-B979-0DABACB56BB8} + osrepodbmgr.Core +