summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-04 15:59:58 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 16:38:26 +0100
commit596edcd3f05b4eaa0217779d15f3ba3de9cdec1e (patch)
tree8763d715338bb24830a3591cd8e33e1dd151daef /src
parentde14a8055181d00514192f3ed36672b02d5e73ee (diff)
downloadmsitools-596edcd3f05b4eaa0217779d15f3ba3de9cdec1e.tar.gz
msitools-596edcd3f05b4eaa0217779d15f3ba3de9cdec1e.tar.xz
msitools-596edcd3f05b4eaa0217779d15f3ba3de9cdec1e.zip
Component: set KeyPath
Diffstat (limited to 'src')
-rw-r--r--src/builder.vala28
-rw-r--r--src/msi.vala9
-rw-r--r--src/util.vala3
-rw-r--r--src/wix.vala20
4 files changed, 40 insertions, 20 deletions
diff --git a/src/builder.vala b/src/builder.vala
index 8fa6303..a021434 100644
--- a/src/builder.vala
+++ b/src/builder.vala
@@ -127,7 +127,8 @@ namespace Wixl {
public override void visit_component (WixComponent comp) throws GLib.Error {
if (comp.parent.get_type () == typeof (WixDirectory)) {
var parent = comp.parent as WixDirectory;
- db.table_component.add (comp.Id, add_braces (comp.Guid), parent.Id, 0);
+ db.table_component.add (comp.Id, add_braces (comp.Guid), parent.Id, 0,
+ comp.key != null ? comp.key.Id : null);
} else
warning ("unhandled parent type %s", comp.parent.name);
}
@@ -158,6 +159,15 @@ namespace Wixl {
db.table_remove_file.add (rm.Id, comp.Id, dir.Id, on);
}
+ void visit_key_element (WixKeyElement key) throws GLib.Error {
+ var component = key.parent as WixComponent;
+
+ if (!parse_yesno (key.KeyPath))
+ return;
+
+ component.key = key;
+ }
+
enum RegistryValueType {
STRING,
INTEGER,
@@ -179,11 +189,13 @@ namespace Wixl {
var value = reg.Value;
var t = enum_from_string (typeof (RegistryValueType), reg.Type);
var r = enum_from_string (typeof (RegistryRoot), reg.Root.down ());
- var id = generate_id ("reg", 4,
- comp.Id,
- reg.Root,
- reg.Key != null ? reg.Key.down () : null,
- reg.Name != null ? reg.Name.down () : null);
+ if (reg.Id == null) {
+ reg.Id = generate_id ("reg", 4,
+ comp.Id,
+ reg.Root,
+ reg.Key != null ? reg.Key.down () : null,
+ reg.Name != null ? reg.Name.down () : null);
+ }
switch (t) {
case RegistryValueType.STRING:
@@ -191,7 +203,9 @@ namespace Wixl {
break;
}
- db.table_registry.add (id, r, reg.Key, comp.Id);
+ db.table_registry.add (reg.Id, r, reg.Key, comp.Id);
+
+ visit_key_element (reg);
}
}
diff --git a/src/msi.vala b/src/msi.vala
index b1de96b..4f21bef 100644
--- a/src/msi.vala
+++ b/src/msi.vala
@@ -262,12 +262,13 @@ namespace Wixl {
name = "Component";
}
- public void add (string Component, string ComponentId, string Directory, int Attributes) throws GLib.Error {
- var rec = new Libmsi.Record (4);
+ public void add (string Component, string ComponentId, string Directory, int Attributes, string? KeyPath = null) throws GLib.Error {
+ var rec = new Libmsi.Record (5);
if (!rec.set_string (1, Component) ||
!rec.set_string (2, ComponentId) ||
!rec.set_string (3, Directory) ||
- !rec.set_int (4, Attributes))
+ !rec.set_int (4, Attributes) ||
+ !rec.set_string (5, KeyPath))
throw new Wixl.Error.FAILED ("failed to add record");
records.append (rec);
@@ -277,7 +278,7 @@ namespace Wixl {
var query = new Libmsi.Query (db, "CREATE TABLE `Component` (`Component` CHAR(72) NOT NULL, `ComponentId` CHAR(38), `Directory_` CHAR(72) NOT NULL, `Attributes` INT NOT NULL, `Condition` CHAR(255), `KeyPath` CHAR(72) PRIMARY KEY `Component`)");
query.execute (null);
- query = new Libmsi.Query (db, "INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`) VALUES (?, ?, ?, ?)");
+ query = new Libmsi.Query (db, "INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES (?, ?, ?, ?, ?)");
foreach (var r in records)
query.execute (r);
}
diff --git a/src/util.vala b/src/util.vala
index 9ad72e2..00ae957 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -85,4 +85,7 @@ namespace Wixl {
return str;
}
+ bool parse_yesno (string str) {
+ return (str[0] == 'Y' || str[0] == 'y');
+ }
} // Wixl
diff --git a/src/wix.vala b/src/wix.vala
index 066795c..aa6f0d4 100644
--- a/src/wix.vala
+++ b/src/wix.vala
@@ -114,8 +114,8 @@ namespace Wixl {
public string Description { get; set; }
public override void accept (WixElementVisitor visitor) throws GLib.Error {
- visitor.visit_package (this);
base.accept (visitor);
+ visitor.visit_package (this);
}
}
@@ -131,7 +131,11 @@ namespace Wixl {
}
}
- public class WixRegistryValue: WixElement {
+ public abstract class WixKeyElement: WixElement {
+ public string KeyPath { get; set; }
+ }
+
+ public class WixRegistryValue: WixKeyElement {
static construct {
name = "RegistryValue";
}
@@ -140,7 +144,6 @@ namespace Wixl {
public string Key { get; set; }
public string Type { get; set; }
public string Value { get; set; }
- public string KeyPath { get; set; }
public string Name { get; set; }
public override void accept (WixElementVisitor visitor) throws GLib.Error {
@@ -190,8 +193,8 @@ namespace Wixl {
}
public override void accept (WixElementVisitor visitor) throws GLib.Error {
- visitor.visit_feature (this);
base.accept (visitor);
+ visitor.visit_feature (this);
}
}
@@ -268,8 +271,8 @@ namespace Wixl {
}
public override void accept (WixElementVisitor visitor) throws GLib.Error {
- visitor.visit_product (this);
base.accept (visitor);
+ visitor.visit_product (this);
}
}
@@ -293,6 +296,7 @@ namespace Wixl {
}
public string Guid { get; set; }
+ public WixKeyElement? key;
public override void load (Xml.Node *node) throws Wixl.Error {
base.load (node);
@@ -322,9 +326,8 @@ namespace Wixl {
}
public override void accept (WixElementVisitor visitor) throws GLib.Error {
- visitor.visit_component (this);
-
base.accept (visitor);
+ visitor.visit_component (this);
}
}
@@ -363,9 +366,8 @@ namespace Wixl {
}
public override void accept (WixElementVisitor visitor) throws GLib.Error {
- visitor.visit_directory (this);
-
base.accept (visitor);
+ visitor.visit_directory (this);
}
}