summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-08 02:17:50 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-08 02:17:50 +0100
commit18a2c56c9cac3a3f2b5ec8dcb88410bfa9f41c90 (patch)
tree75cc8bb44931d335f678e62ddef5d46eb16e35d5
parent78924b09d5cc79a8e2ee437877a8d23a2d522832 (diff)
downloadmsitools-18a2c56c9cac3a3f2b5ec8dcb88410bfa9f41c90.tar.gz
msitools-18a2c56c9cac3a3f2b5ec8dcb88410bfa9f41c90.tar.xz
msitools-18a2c56c9cac3a3f2b5ec8dcb88410bfa9f41c90.zip
Feature: fix db values with SampleFragment test
-rw-r--r--src/builder.vala45
-rw-r--r--src/msi.vala12
-rw-r--r--src/wix.vala11
3 files changed, 60 insertions, 8 deletions
diff --git a/src/builder.vala b/src/builder.vala
index 9f3ea1d..ef41d56 100644
--- a/src/builder.vala
+++ b/src/builder.vala
@@ -268,8 +268,49 @@ namespace Wixl {
}
- public override void visit_feature (WixFeature feature) throws GLib.Error {
- db.table_feature.add (feature.Id, 2, int.parse (feature.Level), 0);
+ enum FeatureDisplay {
+ HIDDEN = 0,
+ EXPAND,
+ COLLAPSE
+ }
+ WixFeature? feature_root;
+ int feature_display;
+
+ public override void visit_feature (WixFeature feature, VisitState state) throws GLib.Error {
+ if (state == VisitState.ENTER && feature_root == null) {
+ feature_display = 0;
+ feature_root = feature;
+ } else if (state == VisitState.LEAVE && feature_root == feature) {
+ feature_root = null;
+ }
+
+ if (state != VisitState.ENTER)
+ return;
+
+ int display = FeatureDisplay.COLLAPSE;
+ if (feature.Display != null) {
+ try {
+ display = enum_from_string (typeof (FeatureDisplay), feature.Display);
+ } catch (GLib.Error error) {
+ display = int.parse (feature.Display);
+ if (display != 0)
+ feature_display = display;
+ }
+ }
+
+ switch (display) {
+ case FeatureDisplay.COLLAPSE:
+ display = feature_display = (feature_display | 1) + 1;
+ break;
+ case FeatureDisplay.EXPAND:
+ display = feature_display = (feature_display + 1) | 1;
+ break;
+ }
+
+ string? parent = (feature.parent is WixFeature) ? feature.parent.Id : null;
+
+ db.table_feature.add (feature.Id, display, int.parse (feature.Level), 0, parent, feature.Title, feature.Description, feature.ConfigurableDirectory);
+
}
public override void visit_component_ref (WixComponentRef ref) throws GLib.Error {
diff --git a/src/msi.vala b/src/msi.vala
index 2b7fc28..eef4259 100644
--- a/src/msi.vala
+++ b/src/msi.vala
@@ -341,15 +341,19 @@ namespace Wixl {
static construct {
name = "Feature";
sql_create = "CREATE TABLE `Feature` (`Feature` CHAR(38) NOT NULL, `Feature_Parent` CHAR(38), `Title` CHAR(64) LOCALIZABLE, `Description` CHAR(255) LOCALIZABLE, `Display` INT, `Level` INT NOT NULL, `Directory_` CHAR(72), `Attributes` INT NOT NULL PRIMARY KEY `Feature`)";
- sql_insert = "INSERT INTO `Feature` (`Feature`, `Display`, `Level`, `Attributes`) VALUES (?, ?, ?, ?)";
+ sql_insert = "INSERT INTO `Feature` (`Feature`, `Display`, `Level`, `Attributes`, `Feature_Parent`, `Title`, `Description`, `Directory_`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
}
- public void add (string Feature, int Display, int Level, int Attributes) throws GLib.Error {
- var rec = new Libmsi.Record (4);
+ public void add (string Feature, int Display, int Level, int Attributes, string? Parent = null, string? Title = null, string? Description = null, string? ConfigurableDirectory = null) throws GLib.Error {
+ var rec = new Libmsi.Record (8);
if (!rec.set_string (1, Feature) ||
!rec.set_int (2, Display) ||
!rec.set_int (3, Level) ||
- !rec.set_int (4, Attributes))
+ !rec.set_int (4, Attributes) ||
+ (Parent != null && !rec.set_string (5, Parent)) ||
+ (Title != null && !rec.set_string (6, Title)) ||
+ (Description != null && !rec.set_string (7, Description)) ||
+ (ConfigurableDirectory != null && !rec.set_string (8, ConfigurableDirectory)))
throw new Wixl.Error.FAILED ("failed to add record");
records.append (rec);
diff --git a/src/wix.vala b/src/wix.vala
index 324d391..50a53ad 100644
--- a/src/wix.vala
+++ b/src/wix.vala
@@ -1,5 +1,11 @@
namespace Wixl {
+ public enum VisitState {
+ ENTER,
+ INFIX,
+ LEAVE
+ }
+
public abstract class WixElementVisitor: Object {
public abstract void visit_product (WixProduct product) throws GLib.Error;
public abstract void visit_icon (WixIcon icon) throws GLib.Error;
@@ -8,7 +14,7 @@ namespace Wixl {
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 void visit_feature (WixFeature feature) throws GLib.Error;
+ public abstract void visit_feature (WixFeature feature, VisitState state) 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 void visit_registry_value (WixRegistryValue reg) throws GLib.Error;
@@ -324,8 +330,9 @@ namespace Wixl {
public string ConfigurableDirectory { get; set; }
public override void accept (WixElementVisitor visitor) throws GLib.Error {
+ visitor.visit_feature (this, VisitState.ENTER);
base.accept (visitor);
- visitor.visit_feature (this);
+ visitor.visit_feature (this, VisitState.LEAVE);
}
}