summaryrefslogtreecommitdiffstats
path: root/tools/wixl
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-15 15:20:21 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-15 20:05:56 +0100
commitd34198c2c034348329af4ce183cd5db74d4e53dd (patch)
tree61202ae6d1416863978d7b54f4b2135604f3ccd1 /tools/wixl
parente76a29489704dcea0d003dd52a3ee6d7ae6ad257 (diff)
downloadmsitools-d34198c2c034348329af4ce183cd5db74d4e53dd.tar.gz
msitools-d34198c2c034348329af4ce183cd5db74d4e53dd.tar.xz
msitools-d34198c2c034348329af4ce183cd5db74d4e53dd.zip
wixl: improve shortcut support
To support such construction: <DirectoryRef Id="DirMenu"> <Component Id="CShortcut" Guid="*"> <Shortcut Id="ApplicationStartMenuShortcut" Name="Remote viewer" Description="A SPICE/VNC client" Target="[INSTALLDIR]\bin\remote-viewer.exe" Icon="IcoVirtViewer"/> <RemoveFolder Id="MENUDIR" On="uninstall"/> <RegistryValue Root="HKCU" Key="Software\VirtViewer\remote-viewer-shortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/> </Component> </DirectoryRef>
Diffstat (limited to 'tools/wixl')
-rw-r--r--tools/wixl/builder.vala33
-rw-r--r--tools/wixl/msi.vala19
-rw-r--r--tools/wixl/wix.vala6
3 files changed, 44 insertions, 14 deletions
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala
index fd0ba59..813a8a1 100644
--- a/tools/wixl/builder.vala
+++ b/tools/wixl/builder.vala
@@ -200,8 +200,9 @@ namespace Wixl {
private void shortcut_target () throws GLib.Error {
var shortcuts = get_elements<WixShortcut> ();
-
foreach (var sc in shortcuts) {
+ if (sc.Target != null)
+ continue;
var component = sc.get_component ();
var feature = component.in_feature.first ().data;
MsiTableShortcut.set_target (sc.record, feature.Id);
@@ -446,13 +447,16 @@ namespace Wixl {
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;
+ var dir = resolve<WixDirectory> (comp.parent);
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;
+ void visit_key_element (WixKeyElement key, WixComponent? component = null) throws GLib.Error {
+ if (component == null)
+ component = key.parent as WixComponent;
+
+ return_if_fail (component != null);
if (component.key == null || parse_yesno (key.KeyPath))
component.key = key;
@@ -552,17 +556,30 @@ namespace Wixl {
}
public override void visit_shortcut (WixShortcut shortcut) throws GLib.Error {
- if (!parse_yesno (shortcut.Advertise))
- throw new Wixl.Error.FIXME ("unimplemented");
+ string? directory = shortcut.Directory;
+
+ if (!parse_yesno (shortcut.Advertise, true))
+ message ("unimplemented");
var component = shortcut.get_component ();
- var rec = db.table_shortcut.add (shortcut.Id, shortcut.Directory, shortcut.Name, component.Id);
+ if (directory == null && shortcut.parent is WixComponent) {
+ var dir = resolve<WixDirectory> (component.parent);
+ directory = dir.Id;
+ }
+
+ var rec = db.table_shortcut.add (shortcut.Id, directory, shortcut.Name, component.Id);
shortcut.record = rec;
if (shortcut.Icon != null)
- MsiTableShortcut.set_icon (rec, shortcut.Icon, int.parse (shortcut.IconIndex));
+ MsiTableShortcut.set_icon (rec, shortcut.Icon);
+ if (shortcut.IconIndex != null)
+ MsiTableShortcut.set_icon_index (rec, int.parse (shortcut.IconIndex));
if (shortcut.WorkingDirectory != null)
MsiTableShortcut.set_working_dir (rec, shortcut.WorkingDirectory);
+ if (shortcut.Target != null)
+ MsiTableShortcut.set_target (rec, shortcut.Target);
+ if (shortcut.Description != null)
+ MsiTableShortcut.set_description (rec, shortcut.Description);
}
public override void visit_sequence (WixSequence sequence) throws GLib.Error {
diff --git a/tools/wixl/msi.vala b/tools/wixl/msi.vala
index b0cf423..b847720 100644
--- a/tools/wixl/msi.vala
+++ b/tools/wixl/msi.vala
@@ -397,11 +397,11 @@ namespace Wixl {
static construct {
name = "Shortcut";
sql_create = "CREATE TABLE `Shortcut` (`Shortcut` CHAR(72) NOT NULL, `Directory_` CHAR(72) NOT NULL, `Name` CHAR(128) NOT NULL LOCALIZABLE, `Component_` CHAR(72) NOT NULL, `Target` CHAR(72) NOT NULL, `Arguments` CHAR(255), `Description` CHAR(255) LOCALIZABLE, `Hotkey` INT, `Icon_` CHAR(72), `IconIndex` INT, `ShowCmd` INT, `WkDir` CHAR(72), `DisplayResourceDLL` CHAR(255), `DisplayResourceId` INT, `DescriptionResourceDLL` CHAR(255), `DescriptionResourceId` INT PRIMARY KEY `Shortcut`)";
- sql_insert = "INSERT INTO `Shortcut` (`Shortcut`, `Directory_`, `Name`, `Component_`, `Target`, `Icon_`, `IconIndex`, `WkDir`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ sql_insert = "INSERT INTO `Shortcut` (`Shortcut`, `Directory_`, `Name`, `Component_`, `Target`, `Icon_`, `IconIndex`, `WkDir`, `Description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
}
public Libmsi.Record add (string Shortcut, string Directory, string Name, string Component) throws GLib.Error {
- var rec = new Libmsi.Record (8);
+ var rec = new Libmsi.Record (9);
if (!rec.set_string (1, Shortcut) ||
!rec.set_string (2, Directory) ||
@@ -419,9 +419,13 @@ namespace Wixl {
throw new Wixl.Error.FAILED ("failed to set record");
}
- public static void set_icon (Libmsi.Record rec, string Icon, int IconIndex) throws GLib.Error {
- if (!rec.set_string (6, Icon) ||
- !rec.set_int (7, IconIndex))
+ public static void set_icon (Libmsi.Record rec, string Icon) throws GLib.Error {
+ if (!rec.set_string (6, Icon))
+ throw new Wixl.Error.FAILED ("failed to set record");
+ }
+
+ public static void set_icon_index (Libmsi.Record rec, int IconIndex) throws GLib.Error {
+ if (!rec.set_int (7, IconIndex))
throw new Wixl.Error.FAILED ("failed to set record");
}
@@ -429,6 +433,11 @@ namespace Wixl {
if (!rec.set_string (8, WkDir))
throw new Wixl.Error.FAILED ("failed to set record");
}
+
+ public static void set_description (Libmsi.Record rec, string Description) throws GLib.Error {
+ if (!rec.set_string (9, Description))
+ throw new Wixl.Error.FAILED ("failed to set record");
+ }
}
class MsiTableRemoveFile: MsiTable {
diff --git a/tools/wixl/wix.vala b/tools/wixl/wix.vala
index bc4febd..91d58e7 100644
--- a/tools/wixl/wix.vala
+++ b/tools/wixl/wix.vala
@@ -310,6 +310,8 @@ namespace Wixl {
public string WorkingDirectory { get; set; }
public string Icon { get; set; }
public string Advertise { get; set; }
+ public string Description { get; set; }
+ public string Target { get; set; }
public Libmsi.Record record;
@@ -674,6 +676,7 @@ namespace Wixl {
add_child_types (child_types, {
typeof (WixCondition),
typeof (WixDirectory),
+ typeof (WixDirectoryRef),
typeof (WixFeature),
typeof (WixIcon),
typeof (WixInstallExecuteSequence),
@@ -727,7 +730,8 @@ namespace Wixl {
add_child_types (child_types, {
typeof (WixRemoveFolder),
typeof (WixRegistryValue),
- typeof (WixFile)
+ typeof (WixFile),
+ typeof (WixShortcut),
});
}