Added support for reading, editing (basic) metadata, adding it

to the DB, and compress and copy it as XML and JSON to the
	archived file.
This commit is contained in:
2017-04-29 07:04:03 +01:00
parent ba4070cfb4
commit 9edd4bcba3
14 changed files with 5341 additions and 24 deletions

View File

@@ -1,3 +1,22 @@
2017-04-29 Natalia Portillo <claunia@claunia.com>
* Core.cs:
* DBOps.cs:
* Schema.cs:
* DicCore.cs:
* Program.cs:
* MainWindow.cs:
* dlgMetadata.cs:
* gtk-gui/gui.stetic:
* osrepodbmgr.csproj:
* gtk-gui/generated.cs:
* gtk-gui/MainWindow.cs:
* gtk-gui/osrepodbmgr.DicCore.cs:
* gtk-gui/osrepodbmgr.dlgMetadata.cs:
Added support for reading, editing (basic) metadata, adding
it to the DB, and compress and copy it as XML and JSON to
the archived file.
2017-04-24 Natalia Portillo <claunia@claunia.com>
* osrepodbmgr.csproj:

View File

@@ -29,13 +29,17 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using Ionic.Zip;
using Newtonsoft.Json;
using Schemas;
namespace osrepodbmgr
{
public static class Core
public static partial class Core
{
// Sets a 128Kbyte buffer
const long bufferSize = 131072;
@@ -103,9 +107,232 @@ namespace osrepodbmgr
try
{
MainClass.hashes = new Dictionary<string, DBFile>();
List<string> alreadyMetadata = new List<string>();
bool foundMetadata = false;
// For metadata
List<ArchitecturesTypeArchitecture> architectures = new List<ArchitecturesTypeArchitecture>();
List<BarcodeType> barcodes = new List<BarcodeType>();
List<BlockMediaType> disks = new List<BlockMediaType>();
List<string> categories = new List<string>();
List<string> keywords = new List<string>();
List<LanguagesTypeLanguage> languages = new List<LanguagesTypeLanguage>();
List<OpticalDiscType> discs = new List<OpticalDiscType>();
List<string> subcategories = new List<string>();
List<string> systems = new List<string>();
bool releaseDateSpecified = false;
DateTime releaseDate = DateTime.MinValue;
CICMMetadataTypeReleaseType releaseType = CICMMetadataTypeReleaseType.Retail;
bool releaseTypeSpecified = false;
List<string> authors = new List<string>();
List<string> developers = new List<string>();
List<string> performers = new List<string>();
List<string> publishers = new List<string>();
string metadataName = null;
string metadataPartNo = null;
string metadataSerial = null;
string metadataVersion = null;
// End for metadata
long counter = 1;
foreach(string file in MainClass.files)
{
// An already known metadata file, skip it
if(alreadyMetadata.Contains(file))
{
counter++;
continue;
}
if(Path.GetExtension(file).ToLowerInvariant() == ".xml")
{
FileStream xrs = new FileStream(file, FileMode.Open, FileAccess.Read);
XmlReader xr = XmlReader.Create(xrs);
XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType));
if(xs.CanDeserialize(xr))
{
CICMMetadataType thisMetadata = (CICMMetadataType)xs.Deserialize(xr);
if(thisMetadata.Architectures != null)
architectures.AddRange(thisMetadata.Architectures);
if(thisMetadata.Barcodes != null)
barcodes.AddRange(thisMetadata.Barcodes);
if(thisMetadata.BlockMedia != null)
disks.AddRange(thisMetadata.BlockMedia);
if(thisMetadata.Categories != null)
categories.AddRange(thisMetadata.Categories);
if(thisMetadata.Keywords != null)
keywords.AddRange(thisMetadata.Keywords);
if(thisMetadata.Languages != null)
languages.AddRange(thisMetadata.Languages);
if(thisMetadata.OpticalDisc != null)
discs.AddRange(thisMetadata.OpticalDisc);
if(thisMetadata.Subcategories != null)
subcategories.AddRange(thisMetadata.Subcategories);
if(thisMetadata.Systems != null)
systems.AddRange(thisMetadata.Systems);
if(thisMetadata.Author != null)
authors.AddRange(thisMetadata.Author);
if(thisMetadata.Developer != null)
developers.AddRange(thisMetadata.Developer);
if(thisMetadata.Performer != null)
performers.AddRange(thisMetadata.Performer);
if(thisMetadata.Publisher != null)
publishers.AddRange(thisMetadata.Publisher);
if(string.IsNullOrWhiteSpace(metadataName) && !string.IsNullOrWhiteSpace(thisMetadata.Name))
metadataName = thisMetadata.Name;
if(string.IsNullOrWhiteSpace(metadataPartNo) && !string.IsNullOrWhiteSpace(thisMetadata.PartNumber))
metadataPartNo = thisMetadata.PartNumber;
if(string.IsNullOrWhiteSpace(metadataSerial) && !string.IsNullOrWhiteSpace(thisMetadata.SerialNumber))
metadataSerial = thisMetadata.SerialNumber;
if(string.IsNullOrWhiteSpace(metadataVersion) && !string.IsNullOrWhiteSpace(thisMetadata.Version))
metadataVersion = thisMetadata.Version;
if(thisMetadata.ReleaseDateSpecified)
{
if(thisMetadata.ReleaseDate > releaseDate)
{
releaseDateSpecified = true;
releaseDate = thisMetadata.ReleaseDate;
}
}
if(thisMetadata.ReleaseTypeSpecified)
{
releaseTypeSpecified = true;
releaseType = thisMetadata.ReleaseType;
}
foundMetadata = true;
string metadataFileWithoutExtension = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
alreadyMetadata.Add(metadataFileWithoutExtension + ".xml");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xmL");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xMl");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xML");
alreadyMetadata.Add(metadataFileWithoutExtension + ".Xml");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XmL");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XMl");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XML");
alreadyMetadata.Add(metadataFileWithoutExtension + ".json");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSon");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".Json");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSon");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSON");
xr.Close();
xrs.Close();
continue;
}
xr.Close();
xrs.Close();
}
else if(Path.GetExtension(file).ToLowerInvariant() == ".json")
{
FileStream jrs = new FileStream(file, FileMode.Open, FileAccess.Read);
TextReader jr = new StreamReader(jrs);
JsonSerializer js = new JsonSerializer();
try
{
CICMMetadataType thisMetadata = (CICMMetadataType)js.Deserialize(jr, typeof(CICMMetadataType));
if(thisMetadata.Architectures != null)
architectures.AddRange(thisMetadata.Architectures);
if(thisMetadata.Barcodes != null)
barcodes.AddRange(thisMetadata.Barcodes);
if(thisMetadata.BlockMedia != null)
disks.AddRange(thisMetadata.BlockMedia);
if(thisMetadata.Categories != null)
categories.AddRange(thisMetadata.Categories);
if(thisMetadata.Keywords != null)
keywords.AddRange(thisMetadata.Keywords);
if(thisMetadata.Languages != null)
languages.AddRange(thisMetadata.Languages);
if(thisMetadata.OpticalDisc != null)
discs.AddRange(thisMetadata.OpticalDisc);
if(thisMetadata.Subcategories != null)
subcategories.AddRange(thisMetadata.Subcategories);
if(thisMetadata.Systems != null)
systems.AddRange(thisMetadata.Systems);
if(thisMetadata.Author != null)
authors.AddRange(thisMetadata.Author);
if(thisMetadata.Developer != null)
developers.AddRange(thisMetadata.Developer);
if(thisMetadata.Performer != null)
performers.AddRange(thisMetadata.Performer);
if(thisMetadata.Publisher != null)
publishers.AddRange(thisMetadata.Publisher);
if(string.IsNullOrWhiteSpace(metadataName) && !string.IsNullOrWhiteSpace(thisMetadata.Name))
metadataName = thisMetadata.Name;
if(string.IsNullOrWhiteSpace(metadataPartNo) && !string.IsNullOrWhiteSpace(thisMetadata.PartNumber))
metadataPartNo = thisMetadata.PartNumber;
if(string.IsNullOrWhiteSpace(metadataSerial) && !string.IsNullOrWhiteSpace(thisMetadata.SerialNumber))
metadataSerial = thisMetadata.SerialNumber;
if(string.IsNullOrWhiteSpace(metadataVersion) && !string.IsNullOrWhiteSpace(thisMetadata.Version))
metadataVersion = thisMetadata.Version;
if(thisMetadata.ReleaseDateSpecified)
{
if(thisMetadata.ReleaseDate > releaseDate)
{
releaseDateSpecified = true;
releaseDate = thisMetadata.ReleaseDate;
}
}
if(thisMetadata.ReleaseTypeSpecified)
{
releaseTypeSpecified = true;
releaseType = thisMetadata.ReleaseType;
}
foundMetadata = true;
string metadataFileWithoutExtension = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
alreadyMetadata.Add(metadataFileWithoutExtension + ".xml");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xmL");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xMl");
alreadyMetadata.Add(metadataFileWithoutExtension + ".xML");
alreadyMetadata.Add(metadataFileWithoutExtension + ".Xml");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XmL");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XMl");
alreadyMetadata.Add(metadataFileWithoutExtension + ".XML");
alreadyMetadata.Add(metadataFileWithoutExtension + ".json");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jsON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSon");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".jSON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".Json");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JsON");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSon");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSoN");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSOn");
alreadyMetadata.Add(metadataFileWithoutExtension + ".JSON");
jr.Close();
jrs.Close();
continue;
}
catch
{
jr.Close();
jrs.Close();
}
}
string filesPath;
FileInfo fi = new FileInfo(file);
@@ -113,7 +340,7 @@ namespace osrepodbmgr
filesPath = MainClass.tmpFolder;
else
filesPath = MainClass.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);
@@ -164,6 +391,57 @@ namespace osrepodbmgr
MainClass.hashes.Add(relpath, dbFile);
counter++;
}
if(foundMetadata)
{
MainClass.metadata = new CICMMetadataType();
if(architectures.Count > 0)
MainClass.metadata.Architectures = architectures.Distinct().ToArray();
if(authors.Count > 0)
MainClass.metadata.Author = authors.Distinct().ToArray();
// TODO: Check for uniqueness
if(barcodes.Count > 0)
MainClass.metadata.Barcodes = barcodes.ToArray();
if(disks.Count > 0)
MainClass.metadata.BlockMedia = disks.ToArray();
if(categories.Count > 0)
MainClass.metadata.Categories = categories.Distinct().ToArray();
if(developers.Count > 0)
MainClass.metadata.Developer = developers.Distinct().ToArray();
if(keywords.Count > 0)
MainClass.metadata.Keywords = keywords.Distinct().ToArray();
if(languages.Count > 0)
MainClass.metadata.Languages = languages.Distinct().ToArray();
MainClass.metadata.Name = metadataName;
if(discs.Count > 0)
MainClass.metadata.OpticalDisc = discs.ToArray();
MainClass.metadata.PartNumber = metadataPartNo;
if(performers.Count > 0)
MainClass.metadata.Performer = performers.Distinct().ToArray();
if(publishers.Count > 0)
MainClass.metadata.Publisher = publishers.Distinct().ToArray();
if(releaseDateSpecified)
{
MainClass.metadata.ReleaseDate = releaseDate;
MainClass.metadata.ReleaseDateSpecified = true;
}
if(releaseTypeSpecified)
{
MainClass.metadata.ReleaseType = releaseType;
MainClass.metadata.ReleaseTypeSpecified = true;
}
MainClass.metadata.SerialNumber = metadataSerial;
if(subcategories.Count > 0)
MainClass.metadata.Subcategories = subcategories.Distinct().ToArray();
if(systems.Count > 0)
MainClass.metadata.Systems = systems.Distinct().ToArray();
MainClass.metadata.Version = metadataVersion;
foreach(string metadataFile in alreadyMetadata)
MainClass.files.Remove(metadataFile);
}
else
MainClass.metadata = null;
if(Finished != null)
Finished();
}
@@ -579,15 +857,49 @@ namespace osrepodbmgr
ze.LastModified = fi.LastWriteTimeUtc;
ze.FileName = file.Substring(filesPath.Length + 1);
//fs.Close();
if(file == "metadata.json")
File.Copy(file, Path.Combine(destinationFolder, destinationFile) + ".json");
if(file == "metadata.xml")
File.Copy(file, Path.Combine(destinationFolder, destinationFile) + ".xml");
counter++;
}
if(MainClass.metadata != null)
{
MemoryStream xms = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType));
xs.Serialize(xms, MainClass.metadata);
xms.Position = 0;
ZipEntry zx = zf.AddEntry("metadata.xml", xms);
zx.AccessedTime = DateTime.UtcNow;
zx.Attributes = FileAttributes.Normal;
zx.CreationTime = zx.AccessedTime;
zx.EmitTimesInUnixFormatWhenSaving = true;
zx.LastModified = zx.AccessedTime;
zx.FileName = "metadata.xml";
JsonSerializer js = new JsonSerializer();
js.Formatting = Newtonsoft.Json.Formatting.Indented;
js.NullValueHandling = NullValueHandling.Ignore;
MemoryStream jms = new MemoryStream();
StreamWriter sw = new StreamWriter(jms, Encoding.UTF8, 1048576, true);
js.Serialize(sw, MainClass.metadata, typeof(CICMMetadataType));
sw.Close();
jms.Position = 0;
ZipEntry zj = zf.AddEntry("metadata.json", jms);
zj.AccessedTime = DateTime.UtcNow;
zj.Attributes = FileAttributes.Normal;
zj.CreationTime = zx.AccessedTime;
zj.EmitTimesInUnixFormatWhenSaving = true;
zj.LastModified = zx.AccessedTime;
zj.FileName = "metadata.json";
FileStream xfs = new FileStream(Path.Combine(destinationFolder, destinationFile + ".xml"), FileMode.CreateNew, FileAccess.Write);
xms.CopyTo(xfs);
xfs.Close();
FileStream jfs = new FileStream(Path.Combine(destinationFolder, destinationFile + ".json"), FileMode.CreateNew, FileAccess.Write);
jms.CopyTo(jfs);
jfs.Close();
}
zipCounter = 0;
zipCurrentEntryName = "";
zf.SaveProgress += Zf_SaveProgress;
@@ -875,7 +1187,7 @@ namespace osrepodbmgr
if(Finished != null)
Finished();
MainClass.tmpFolder = tmpFolder;
}
catch(Exception ex)

View File

@@ -49,6 +49,8 @@ namespace osrepodbmgr
public bool source;
public bool files;
public bool netinstall;
public byte[] xml;
public byte[] json;
}
public struct DBFile
@@ -106,6 +108,8 @@ namespace osrepodbmgr
fEntry.source = bool.Parse(dRow["source"].ToString());
fEntry.files = bool.Parse(dRow["files"].ToString());
fEntry.netinstall = bool.Parse(dRow["netinstall"].ToString());
fEntry.xml = (byte[])dRow["xml"];
fEntry.json = (byte[])dRow["json"];
entries.Add(fEntry);
}
@@ -130,6 +134,8 @@ namespace osrepodbmgr
IDbDataParameter param12 = dbcmd.CreateParameter();
IDbDataParameter param13 = dbcmd.CreateParameter();
IDbDataParameter param14 = dbcmd.CreateParameter();
IDbDataParameter param15 = dbcmd.CreateParameter();
IDbDataParameter param16 = dbcmd.CreateParameter();
param1.ParameterName = "@developer";
param2.ParameterName = "@product";
@@ -145,6 +151,8 @@ namespace osrepodbmgr
param12.ParameterName = "@source";
param13.ParameterName = "@files";
param14.ParameterName = "@netinstall";
param15.ParameterName = "@xml";
param16.ParameterName = "@json";
param1.DbType = DbType.String;
param2.DbType = DbType.String;
@@ -159,6 +167,8 @@ namespace osrepodbmgr
param12.DbType = DbType.Boolean;
param13.DbType = DbType.Boolean;
param14.DbType = DbType.Boolean;
param15.DbType = DbType.Object;
param16.DbType = DbType.Object;
param1.Value = entry.developer;
param2.Value = entry.product;
@@ -174,6 +184,8 @@ namespace osrepodbmgr
param12.Value = entry.source;
param13.Value = entry.files;
param14.Value = entry.netinstall;
param15.Value = entry.xml;
param16.Value = entry.json;
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
@@ -189,6 +201,8 @@ namespace osrepodbmgr
dbcmd.Parameters.Add(param12);
dbcmd.Parameters.Add(param13);
dbcmd.Parameters.Add(param14);
dbcmd.Parameters.Add(param15);
dbcmd.Parameters.Add(param16);
return dbcmd;
}
@@ -199,8 +213,8 @@ namespace osrepodbmgr
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
const string sql = "INSERT INTO oses (developer, product, version, languages, architecture, machine, format, description, oem, upgrade, `update`, source, files, netinstall)" +
" VALUES (@developer, @product, @version, @languages, @architecture, @machine, @format, @description, @oem, @upgrade, @update, @source, @files, @netinstall)";
const string sql = "INSERT INTO oses (developer, product, version, languages, architecture, machine, format, description, oem, upgrade, `update`, source, files, netinstall, xml, json)" +
" VALUES (@developer, @product, @version, @languages, @architecture, @machine, @format, @description, @oem, @upgrade, @update, @source, @files, @netinstall, @xml, @json)";
dbcmd.CommandText = sql;
@@ -338,7 +352,7 @@ namespace osrepodbmgr
dbcmd.Transaction = trans;
string sql = string.Format("DROP TABLE IF EXISTS `os_{0}`;\n\n" +
"CREATE TABLE IF NOT EXISTS `os_{0}` (\n"+
"CREATE TABLE IF NOT EXISTS `os_{0}` (\n" +
" `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
" `path` VARCHAR(8192) NOT NULL,\n" +
" `sha256` VARCHAR(64) NOT NULL,\n\n" +

46
osrepodbmgr/DicCore.cs Normal file
View File

@@ -0,0 +1,46 @@
//
// 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.
//
namespace osrepodbmgr
{
public static partial class Core
{
public static void AddDisc()
{
// TODO: Call DiscImageChef
if(Failed != null)
Failed("Not yet implemented");
}
public static void AddDisk()
{
// TODO: Call DiscImageChef
if(Failed != null)
Failed("Not yet implemented");
}
}
}

View File

@@ -27,9 +27,13 @@
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Xml.Serialization;
using Gtk;
using Newtonsoft.Json;
using osrepodbmgr;
using Schemas;
public partial class MainWindow : Window
{
@@ -363,6 +367,47 @@ public partial class MainWindow : Window
chkUpgrade.Sensitive = true;
chkNetinstall.Sensitive = true;
chkSource.Sensitive = true;
btnMetadata.Visible = true;
if(MainClass.metadata != null)
{
foreach(string developer in MainClass.metadata.Developer)
{
if(!string.IsNullOrWhiteSpace(txtDeveloper.Text))
txtDeveloper.Text += ",";
txtDeveloper.Text += developer;
}
if(!string.IsNullOrWhiteSpace(MainClass.metadata.Name))
txtProduct.Text = MainClass.metadata.Name;
if(!string.IsNullOrWhiteSpace(MainClass.metadata.Version))
txtVersion.Text = MainClass.metadata.Version;
foreach(LanguagesTypeLanguage language in MainClass.metadata.Languages)
{
if(!string.IsNullOrWhiteSpace(txtLanguages.Text))
txtLanguages.Text += ",";
txtLanguages.Text += language;
}
foreach(ArchitecturesTypeArchitecture architecture in MainClass.metadata.Architectures)
{
if(!string.IsNullOrWhiteSpace(txtArchitecture.Text))
txtArchitecture.Text += ",";
txtArchitecture.Text += architecture;
}
foreach(string machine in MainClass.metadata.Systems)
{
if(!string.IsNullOrWhiteSpace(txtMachine.Text))
txtMachine.Text += ",";
txtMachine.Text += machine;
}
btnMetadata.ModifyBg(StateType.Normal, new Gdk.Color(0, 127, 0));
}
else
btnMetadata.ModifyBg(StateType.Normal, new Gdk.Color(127, 0, 0));
});
}
@@ -461,6 +506,9 @@ public partial class MainWindow : Window
thdRemoveTemp = new Thread(Core.RemoveTempFolder);
thdRemoveTemp.Start();
}
btnMetadata.Visible = false;
MainClass.metadata = null;
}
public void UpdateProgress(string text, string inner, long current, long maximum)
@@ -683,6 +731,24 @@ public partial class MainWindow : Window
MainClass.dbInfo.update = chkUpdate.Active;
MainClass.dbInfo.upgrade = chkUpgrade.Active;
if(MainClass.metadata != null)
{
MemoryStream ms = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType));
xs.Serialize(ms, MainClass.metadata);
MainClass.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();
}
else
{
MainClass.dbInfo.xml = null;
MainClass.dbInfo.json = null;
}
thdAddFiles = new Thread(Core.AddFilesToDb);
thdAddFiles.Start();
}
@@ -1057,4 +1123,72 @@ public partial class MainWindow : Window
thdFindFiles.Start();
});
}
protected void OnBtnMetadataClicked(object sender, EventArgs e)
{
dlgMetadata _dlgMetadata = new dlgMetadata();
_dlgMetadata.Metadata = MainClass.metadata;
_dlgMetadata.FillFields();
if(_dlgMetadata.Run() == (int)ResponseType.Accept)
{
MainClass.metadata = _dlgMetadata.Metadata;
if(string.IsNullOrWhiteSpace(txtDeveloper.Text))
{
foreach(string developer in MainClass.metadata.Developer)
{
if(!string.IsNullOrWhiteSpace(txtDeveloper.Text))
txtDeveloper.Text += ",";
txtDeveloper.Text += developer;
}
}
if(string.IsNullOrWhiteSpace(txtProduct.Text))
{
if(!string.IsNullOrWhiteSpace(MainClass.metadata.Name))
txtProduct.Text = MainClass.metadata.Name;
}
if(string.IsNullOrWhiteSpace(txtVersion.Text))
{
if(!string.IsNullOrWhiteSpace(MainClass.metadata.Version))
txtVersion.Text = MainClass.metadata.Version;
}
if(string.IsNullOrWhiteSpace(txtLanguages.Text))
{
foreach(LanguagesTypeLanguage language in MainClass.metadata.Languages)
{
if(!string.IsNullOrWhiteSpace(txtLanguages.Text))
txtLanguages.Text += ",";
txtLanguages.Text += language;
}
}
if(string.IsNullOrWhiteSpace(txtArchitecture.Text))
{
foreach(ArchitecturesTypeArchitecture architecture in MainClass.metadata.Architectures)
{
if(!string.IsNullOrWhiteSpace(txtArchitecture.Text))
txtArchitecture.Text += ",";
txtArchitecture.Text += architecture;
}
}
if(string.IsNullOrWhiteSpace(txtMachine.Text))
{
foreach(string machine in MainClass.metadata.Systems)
{
if(!string.IsNullOrWhiteSpace(txtMachine.Text))
txtMachine.Text += ",";
txtMachine.Text += machine;
}
}
btnMetadata.ModifyBg(StateType.Normal, new Gdk.Color(0, 127, 0));
}
_dlgMetadata.Destroy();
}
}

View File

@@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Gtk;
using Schemas;
namespace osrepodbmgr
{
@@ -46,6 +47,10 @@ namespace osrepodbmgr
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)
{

View File

@@ -58,7 +58,9 @@ namespace osrepodbmgr
" `update` BOOLEAN NULL,\n" +
" `source` BOOLEAN NULL,\n" +
" `files` BOOLEAN NULL,\n" +
" `netinstall` BOOLEAN NULL);\n\n" +
" `netinstall` BOOLEAN NULL,\n" +
" `xml` BLOB NULL,\n" +
" `json` BLOB NULL);\n\n" +
"CREATE UNIQUE INDEX `oses_id_UNIQUE` ON `oses` (`id` ASC);\n\n" +
"CREATE INDEX `oses_developer_idx` ON `oses` (`developer` ASC);\n\n" +
"CREATE INDEX `oses_product_idx` ON `oses` (`product` ASC);\n\n" +

1228
osrepodbmgr/dlgMetadata.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -117,6 +117,8 @@ public partial class MainWindow
private global::Gtk.Button btnStop;
private global::Gtk.Button btnMetadata;
protected virtual void Build()
{
global::Stetic.Gui.Initialize(this);
@@ -670,17 +672,32 @@ public partial class MainWindow
w59.Position = 8;
w59.Expand = false;
w59.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild
this.btnMetadata = new global::Gtk.Button();
this.btnMetadata.CanFocus = true;
this.btnMetadata.Name = "btnMetadata";
this.btnMetadata.UseUnderline = true;
this.btnMetadata.Label = global::Mono.Unix.Catalog.GetString("Metadata");
global::Gtk.Image w60 = new global::Gtk.Image();
w60.Pixbuf = global::Stetic.IconLoader.LoadIcon(this, "gtk-properties", global::Gtk.IconSize.Menu);
this.btnMetadata.Image = w60;
this.hbox1.Add(this.btnMetadata);
global::Gtk.Box.BoxChild w61 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.btnMetadata]));
w61.PackType = ((global::Gtk.PackType)(1));
w61.Position = 9;
w61.Expand = false;
w61.Fill = false;
this.vbox1.Add(this.hbox1);
global::Gtk.Box.BoxChild w60 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
w60.Position = 12;
w60.Expand = false;
w60.Fill = false;
global::Gtk.Box.BoxChild w62 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
w62.Position = 12;
w62.Expand = false;
w62.Fill = false;
this.Add(this.vbox1);
if ((this.Child != null))
if((this.Child != null))
{
this.Child.ShowAll();
}
this.DefaultWidth = 771;
this.DefaultWidth = 778;
this.DefaultHeight = 544;
this.lblProgress.Hide();
this.prgProgress.Hide();
@@ -690,8 +707,10 @@ public partial class MainWindow
this.btnPack.Hide();
this.btnAdd.Hide();
this.btnStop.Hide();
this.btnMetadata.Hide();
this.Show();
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
this.btnMetadata.Clicked += new global::System.EventHandler(this.OnBtnMetadataClicked);
this.btnStop.Clicked += new global::System.EventHandler(this.OnBtnStopClicked);
this.btnFolder.Clicked += new global::System.EventHandler(this.OnBtnFolderClicked);
this.btnArchive.Clicked += new global::System.EventHandler(this.OnBtnArchiveClicked);

View File

@@ -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);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
namespace osrepodbmgr
{
public partial class DicCore
{
private void Build()
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -90,6 +90,9 @@
<Compile Include="..\CICMMetadata\dotnet\cicm.cs">
<Link>cicm.cs</Link>
</Compile>
<Compile Include="dlgMetadata.cs" />
<Compile Include="gtk-gui\osrepodbmgr.dlgMetadata.cs" />
<Compile Include="DicCore.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />