From 58f5bf41354155490a405fcd1276e2a1ce0828f4 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 15 Jan 2013 16:21:22 +0100 Subject: wixl: add support for registry key parent, name and value --- tools/wixl/builder.vala | 34 ++++++++++++++++++++++++++++------ tools/wixl/msi.vala | 10 ++++++---- tools/wixl/wix.vala | 14 ++++++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) (limited to 'tools/wixl') diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala index 813a8a1..f583d3a 100644 --- a/tools/wixl/builder.vala +++ b/tools/wixl/builder.vala @@ -479,27 +479,49 @@ namespace Wixl { } public override void visit_registry_value (WixRegistryValue reg) throws GLib.Error { - var comp = reg.parent as WixComponent; + WixComponent comp; + string reg_key = ""; + string reg_root = ""; + + if (reg.parent is WixRegistryKey) { + var regkey = reg.parent as WixRegistryKey; + comp = regkey.parent as WixComponent; + reg_key = regkey.Key + "\\" + reg.Key; + reg_root = regkey.Root; + } else if (reg.parent is WixComponent) { + comp = reg.parent as WixComponent; + reg_key = reg.Key; + } else { + warning ("unhandled parent kind"); + return; + } + + if (reg.Root != null) + reg_root = reg.Root; + var value = reg.Value; var t = enum_from_string (typeof (RegistryValueType), reg.Type); - var r = enum_from_string (typeof (RegistryRoot), reg.Root.down ()); + var r = enum_from_string (typeof (RegistryRoot), reg_root.down ()); if (reg.Id == null) { reg.Id = generate_id ("reg", 4, comp.Id, - reg.Root, - reg.Key != null ? reg.Key.down () : null, + reg_root, + reg_key, reg.Name != null ? reg.Name.down () : null); } switch (t) { + case RegistryValueType.INTEGER: + value = "#" + value; + break; case RegistryValueType.STRING: value = value[0] == '#' ? "#" + value : value; break; } - db.table_registry.add (reg.Id, r, reg.Key, comp.Id); + db.table_registry.add (reg.Id, r, reg_key, comp.Id, reg.Name, value); - visit_key_element (reg); + visit_key_element (reg, comp); } [Flags] diff --git a/tools/wixl/msi.vala b/tools/wixl/msi.vala index b847720..10bdccd 100644 --- a/tools/wixl/msi.vala +++ b/tools/wixl/msi.vala @@ -378,15 +378,17 @@ namespace Wixl { static construct { name = "Registry"; sql_create = "CREATE TABLE `Registry` (`Registry` CHAR(72) NOT NULL, `Root` INT NOT NULL, `Key` CHAR(255) NOT NULL LOCALIZABLE, `Name` CHAR(255) LOCALIZABLE, `Value` CHAR(0) LOCALIZABLE, `Component_` CHAR(72) NOT NULL PRIMARY KEY `Registry`)"; - sql_insert = "INSERT INTO `Registry` (`Registry`, `Root`, `Key`, `Component_`) VALUES (?, ?, ?, ?)"; + sql_insert = "INSERT INTO `Registry` (`Registry`, `Root`, `Key`, `Component_`, `Name`, `Value`) VALUES (?, ?, ?, ?, ?, ?)"; } - public void add (string Registry, int Root, string Key, string Component) throws GLib.Error { - var rec = new Libmsi.Record (4); + public void add (string Registry, int Root, string Key, string Component, string? Name, string? Value) throws GLib.Error { + var rec = new Libmsi.Record (6); if (!rec.set_string (1, Registry) || !rec.set_int (2, Root) || !rec.set_string (3, Key) || - !rec.set_string (4, Component)) + !rec.set_string (4, Component) || + (Name != null && !rec.set_string (5, Name)) || + (Value != null && !rec.set_string (6, Value))) throw new Wixl.Error.FAILED ("failed to add record"); records.append (rec); diff --git a/tools/wixl/wix.vala b/tools/wixl/wix.vala index 91d58e7..ce55d6f 100644 --- a/tools/wixl/wix.vala +++ b/tools/wixl/wix.vala @@ -723,6 +723,19 @@ namespace Wixl { } } + public class WixRegistryKey: WixElement { + static construct { + name = "RegistryKey"; + + add_child_types (child_types, { + typeof (WixRegistryValue), + }); + } + + public string Key { get; set; } + public string Root { get; set; } + } + public class WixComponent: WixElement { static construct { name = "Component"; @@ -732,6 +745,7 @@ namespace Wixl { typeof (WixRegistryValue), typeof (WixFile), typeof (WixShortcut), + typeof (WixRegistryKey), }); } -- cgit