diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-03 13:11:22 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-06 16:38:26 +0100 |
commit | 37d07cd2611fe2bdfacdf602061b221620eb5302 (patch) | |
tree | 267c5e22531a7bdeec144a13ea9a7cc0cd57e8a0 | |
parent | d4caf80554c05c9acc9e29ae8ab399b49fd0e06d (diff) | |
download | msitools-37d07cd2611fe2bdfacdf602061b221620eb5302.tar.gz msitools-37d07cd2611fe2bdfacdf602061b221620eb5302.tar.xz msitools-37d07cd2611fe2bdfacdf602061b221620eb5302.zip |
Populate Component table
-rw-r--r-- | src/builder.vala | 8 | ||||
-rw-r--r-- | src/msi.vala | 29 | ||||
-rw-r--r-- | src/wix.vala | 22 |
3 files changed, 59 insertions, 0 deletions
diff --git a/src/builder.vala b/src/builder.vala index 4a50c79..e98706b 100644 --- a/src/builder.vala +++ b/src/builder.vala @@ -55,6 +55,14 @@ namespace Wixl { } else warning ("unhandled parent type %s", dir.parent.name); } + + 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); + } else + warning ("unhandled parent type %s", comp.parent.name); + } } } // Wixl diff --git a/src/msi.vala b/src/msi.vala index 48c2a92..6333490 100644 --- a/src/msi.vala +++ b/src/msi.vala @@ -313,6 +313,32 @@ namespace Wixl { } } + class MsiTableComponent: MsiTable { + construct { + name = "Component"; + } + + public void add (string Component, string ComponentId, string Directory, int Attributes) throws GLib.Error { + var rec = new Libmsi.Record (4); + if (!rec.set_string (1, Component) || + !rec.set_string (2, ComponentId) || + !rec.set_string (3, Directory) || + !rec.set_int (4, Attributes)) + throw new Wixl.Error.FAILED ("failed to add record"); + + records.append (rec); + } + + public override void create (Libmsi.Database db) throws GLib.Error { + 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 (?, ?, ?, ?)"); + foreach (var r in records) + query.execute (r); + } + } + class MsiTable_Validation: MsiTable { construct { name = "_Validation"; @@ -379,6 +405,7 @@ namespace Wixl { public MsiTableIcon table_icon; public MsiTableMedia table_media; public MsiTableDirectory table_directory; + public MsiTableComponent table_component; HashTable<string, MsiTable> tables; @@ -405,6 +432,7 @@ namespace Wixl { table_icon = new MsiTableIcon (); table_media = new MsiTableMedia (); table_directory = new MsiTableDirectory (); + table_component = new MsiTableComponent (); foreach (var t in new MsiTable[] { new MsiTableAdminExecuteSequence (), @@ -418,6 +446,7 @@ namespace Wixl { table_media, table_property, table_icon, + table_component, new MsiTable_Validation () }) { tables.insert (t.name, t); diff --git a/src/wix.vala b/src/wix.vala index df17fdc..75c2119 100644 --- a/src/wix.vala +++ b/src/wix.vala @@ -7,6 +7,7 @@ namespace Wixl { public abstract void visit_property (WixProperty prop) throws GLib.Error; public abstract void visit_media (WixMedia media) throws GLib.Error; public abstract void visit_directory (WixDirectory dir) throws GLib.Error; + public abstract void visit_component (WixComponent comp) throws GLib.Error; } public abstract class WixElement: Object { @@ -220,6 +221,22 @@ namespace Wixl { } } + public class WixComponent: WixElement { + static construct { + name = "Component"; + } + + public string Guid { get; set; } + + public override void load (Xml.Node *node) throws Wixl.Error { + base.load (node); + } + + public override void accept (WixElementVisitor visitor) throws GLib.Error { + visitor.visit_component (this); + } + } + public class WixDirectory: WixElement { static construct { name = "Directory"; @@ -242,6 +259,11 @@ namespace Wixl { directory.load (child); add_child (directory); continue; + case "Component": + var component = new WixComponent (); + component.load (child); + add_child (component); + continue; } break; } |