summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-03 13:54:58 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 16:38:26 +0100
commitfb85d5f7abc59813184cfaab508616312fdf8af7 (patch)
tree06aea58261ece5886036fcd272bb962733b652d4 /src
parentace4b70a1519354b15e091d5d0a034b4457d4d7e (diff)
downloadmsitools-fb85d5f7abc59813184cfaab508616312fdf8af7.tar.gz
msitools-fb85d5f7abc59813184cfaab508616312fdf8af7.tar.xz
msitools-fb85d5f7abc59813184cfaab508616312fdf8af7.zip
Populate FeatureComponents table
Diffstat (limited to 'src')
-rw-r--r--src/builder.vala8
-rw-r--r--src/msi.vala27
-rw-r--r--src/wix.vala51
3 files changed, 69 insertions, 17 deletions
diff --git a/src/builder.vala b/src/builder.vala
index 66fb671..e4f9a0a 100644
--- a/src/builder.vala
+++ b/src/builder.vala
@@ -67,6 +67,14 @@ namespace Wixl {
public override void visit_feature (WixFeature feature) throws GLib.Error {
db.table_feature.add (feature.Id, 2, int.parse (feature.Level), 0);
}
+
+ public override void visit_component_ref (WixComponentRef ref) throws GLib.Error {
+ if (ref.parent is WixFeature) {
+ var parent = ref.parent as WixFeature;
+ db.table_feature_components.add (parent.Id, @ref.Id);
+ } else
+ warning ("unhandled parent type %s", @ref.parent.name);
+ }
}
} // Wixl
diff --git a/src/msi.vala b/src/msi.vala
index d8f9c8a..915c4b1 100644
--- a/src/msi.vala
+++ b/src/msi.vala
@@ -339,6 +339,30 @@ namespace Wixl {
}
}
+ class MsiTableFeatureComponents: MsiTable {
+ construct {
+ name = "FeatureComponents";
+ }
+
+ public void add (string Feature, string Component) throws GLib.Error {
+ var rec = new Libmsi.Record (2);
+ if (!rec.set_string (1, Feature) ||
+ !rec.set_string (2, Component))
+ 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 `FeatureComponents` (`Feature_` CHAR(38) NOT NULL, `Component_` CHAR(72) NOT NULL PRIMARY KEY `Feature_`, `Component_`)");
+ query.execute (null);
+
+ query = new Libmsi.Query (db, "INSERT INTO `FeatureComponents` (`Feature_`, `Component_`) VALUES (?, ?)");
+ foreach (var r in records)
+ query.execute (r);
+ }
+ }
+
class MsiTableFeature: MsiTable {
construct {
name = "Feature";
@@ -433,6 +457,7 @@ namespace Wixl {
public MsiTableDirectory table_directory;
public MsiTableComponent table_component;
public MsiTableFeature table_feature;
+ public MsiTableFeatureComponents table_feature_components;
HashTable<string, MsiTable> tables;
@@ -461,6 +486,7 @@ namespace Wixl {
table_directory = new MsiTableDirectory ();
table_component = new MsiTableComponent ();
table_feature = new MsiTableFeature ();
+ table_feature_components = new MsiTableFeatureComponents ();
foreach (var t in new MsiTable[] {
new MsiTableAdminExecuteSequence (),
@@ -476,6 +502,7 @@ namespace Wixl {
table_icon,
table_component,
table_feature,
+ table_feature_components,
new MsiTable_Validation ()
}) {
tables.insert (t.name, t);
diff --git a/src/wix.vala b/src/wix.vala
index 1e94fc8..6711a58 100644
--- a/src/wix.vala
+++ b/src/wix.vala
@@ -9,6 +9,7 @@ namespace Wixl {
public abstract void visit_directory (WixDirectory dir) throws GLib.Error;
public abstract void visit_component (WixComponent comp) throws GLib.Error;
public abstract void visit_feature (WixFeature feature) throws GLib.Error;
+ public abstract void visit_component_ref (WixComponentRef ref) throws GLib.Error;
}
public abstract class WixElement: Object {
@@ -110,23 +111,6 @@ namespace Wixl {
public string Comments { get; set; }
public string Description { get; set; }
- public override void load (Xml.Node *node) throws Wixl.Error {
- base.load (node);
-
- for (var child = node->children; child != null; child = child->next) {
- switch (child->type) {
- case Xml.ElementType.COMMENT_NODE:
- case Xml.ElementType.TEXT_NODE:
- continue;
- case Xml.ElementType.ELEMENT_NODE:
- switch (child->name) {
- }
- break;
- }
- debug ("unhandled node %s", child->name);
- }
- }
-
public override void accept (WixElementVisitor visitor) throws GLib.Error {
visitor.visit_package (this);
base.accept (visitor);
@@ -152,8 +136,41 @@ namespace Wixl {
public string Level { get; set; }
+ public override void load (Xml.Node *node) throws Wixl.Error {
+ base.load (node);
+
+ for (var child = node->children; child != null; child = child->next) {
+ switch (child->type) {
+ case Xml.ElementType.COMMENT_NODE:
+ case Xml.ElementType.TEXT_NODE:
+ continue;
+ case Xml.ElementType.ELEMENT_NODE:
+ switch (child->name) {
+ case "ComponentRef":
+ var ref = new WixComponentRef ();
+ ref.load (child);
+ add_child (@ref);
+ continue;
+ }
+ break;
+ }
+ debug ("unhandled node %s", child->name);
+ }
+ }
+
public override void accept (WixElementVisitor visitor) throws GLib.Error {
visitor.visit_feature (this);
+ base.accept (visitor);
+ }
+ }
+
+ public class WixComponentRef: WixElement {
+ static construct {
+ name = "ComponentRef";
+ }
+
+ public override void accept (WixElementVisitor visitor) throws GLib.Error {
+ visitor.visit_component_ref (this);
}
}