diff options
| author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-03 16:19:25 +0100 |
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-06 16:38:26 +0100 |
| commit | d43a0c5613c3c88a845fdf183ed403bd95072cf4 (patch) | |
| tree | ddc77f9bd60560ba52669e6a5b0a2d4db9e96a8b /src | |
| parent | fb85d5f7abc59813184cfaab508616312fdf8af7 (diff) | |
| download | msitools-d43a0c5613c3c88a845fdf183ed403bd95072cf4.tar.gz msitools-d43a0c5613c3c88a845fdf183ed403bd95072cf4.tar.xz msitools-d43a0c5613c3c88a845fdf183ed403bd95072cf4.zip | |
Populate RemoveFile table
Diffstat (limited to 'src')
| -rw-r--r-- | src/builder.vala | 15 | ||||
| -rw-r--r-- | src/msi.vala | 29 | ||||
| -rw-r--r-- | src/util.vala | 11 | ||||
| -rw-r--r-- | src/wix.vala | 33 |
4 files changed, 88 insertions, 0 deletions
diff --git a/src/builder.vala b/src/builder.vala index e4f9a0a..6544d61 100644 --- a/src/builder.vala +++ b/src/builder.vala @@ -75,6 +75,21 @@ namespace Wixl { } else warning ("unhandled parent type %s", @ref.parent.name); } + + enum RemoveFileInstallMode { + INSTALL = 1, + UNINSTALL, + BOTH + } + + public override void visit_remove_folder (WixRemoveFolder rm) throws GLib.Error { + var on = enum_from_string (typeof (RemoveFileInstallMode), rm.On); + var comp = rm.parent as WixComponent; + var dir = comp.parent as WixDirectory; + + db.table_remove_file.add (rm.Id, comp.Id, dir.Id, on); + } + } } // Wixl diff --git a/src/msi.vala b/src/msi.vala index 915c4b1..56f4206 100644 --- a/src/msi.vala +++ b/src/msi.vala @@ -363,6 +363,32 @@ namespace Wixl { } } + class MsiTableRemoveFile: MsiTable { + construct { + name = "RemoveFile"; + } + + public void add (string FileKey, string Component, string DirProperty, int InstallMode) throws GLib.Error { + var rec = new Libmsi.Record (4); + if (!rec.set_string (1, FileKey) || + !rec.set_string (2, Component) || + !rec.set_string (3, DirProperty) || + !rec.set_int (4, InstallMode)) + 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 `RemoveFile` (`FileKey` CHAR(72) NOT NULL, `Component_` CHAR(72) NOT NULL, `FileName` CHAR(255) LOCALIZABLE, `DirProperty` CHAR(72) NOT NULL, `InstallMode` INT NOT NULL PRIMARY KEY `FileKey`)"); + query.execute (null); + + query = new Libmsi.Query (db, "INSERT INTO `RemoveFile` (`FileKey`, `Component_`, `DirProperty`, `InstallMode`) VALUES (?, ?, ?, ?)"); + foreach (var r in records) + query.execute (r); + } + } + class MsiTableFeature: MsiTable { construct { name = "Feature"; @@ -458,6 +484,7 @@ namespace Wixl { public MsiTableComponent table_component; public MsiTableFeature table_feature; public MsiTableFeatureComponents table_feature_components; + public MsiTableRemoveFile table_remove_file; HashTable<string, MsiTable> tables; @@ -487,6 +514,7 @@ namespace Wixl { table_component = new MsiTableComponent (); table_feature = new MsiTableFeature (); table_feature_components = new MsiTableFeatureComponents (); + table_remove_file = new MsiTableRemoveFile (); foreach (var t in new MsiTable[] { new MsiTableAdminExecuteSequence (), @@ -503,6 +531,7 @@ namespace Wixl { table_component, table_feature, table_feature_components, + table_remove_file, new MsiTable_Validation () }) { tables.insert (t.name, t); diff --git a/src/util.vala b/src/util.vala index d9a12cc..0dfdd36 100644 --- a/src/util.vala +++ b/src/util.vala @@ -22,9 +22,20 @@ namespace Wixl { return (string) udn; } + + int enum_from_string (Type t, string str) throws GLib.Error { + var k = (EnumClass)t.class_ref (); + var v = k.get_value_by_nick (str); + + if (v == null) + throw new Wixl.Error.FAILED ("Can't convert string to enum"); + return v.value; + } + string add_braces (string str) { return "{" + str + "}"; } + long now () { var tv = TimeVal (); tv.get_current_time (); diff --git a/src/wix.vala b/src/wix.vala index 6711a58..97cc137 100644 --- a/src/wix.vala +++ b/src/wix.vala @@ -10,6 +10,7 @@ namespace Wixl { 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 void visit_remove_folder (WixRemoveFolder rm) throws GLib.Error; } public abstract class WixElement: Object { @@ -129,6 +130,18 @@ namespace Wixl { } } + public class WixRemoveFolder: WixElement { + static construct { + name = "RemoveFolder"; + } + + public string On { get; set; } + + public override void accept (WixElementVisitor visitor) throws GLib.Error { + visitor.visit_remove_folder (this); + } + } + public class WixFeature: WixElement { static construct { name = "Feature"; @@ -265,10 +278,30 @@ namespace Wixl { 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 "RemoveFolder": + var rm = new WixRemoveFolder (); + rm.load (child); + add_child (rm); + continue; + } + break; + } + debug ("unhandled node %s", child->name); + } } public override void accept (WixElementVisitor visitor) throws GLib.Error { visitor.visit_component (this); + + base.accept (visitor); } } |
