| 1 |
# |
| 2 |
# This file is part of the LibreOffice project. |
| 3 |
# |
| 4 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
# |
| 8 |
# This file incorporates work covered by the following license notice: |
| 9 |
# |
| 10 |
# Licensed to the Apache Software Foundation (ASF) under one or more |
| 11 |
# contributor license agreements. See the NOTICE file distributed |
| 12 |
# with this work for additional information regarding copyright |
| 13 |
# ownership. The ASF licenses this file to you under the Apache |
| 14 |
# License, Version 2.0 (the "License"); you may not use this file |
| 15 |
# except in compliance with the License. You may obtain a copy of |
| 16 |
# the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 17 |
# |
| 18 |
|
| 19 |
package installer::windows::msishortcutproperty; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::exiter; |
| 25 |
use installer::files; |
| 26 |
use installer::globals; |
| 27 |
use installer::windows::idtglobal; |
| 28 |
|
| 29 |
############################################################## |
| 30 |
# Returning identifier for msishortcutproperty table. |
| 31 |
############################################################## |
| 32 |
|
| 33 |
sub get_msishortcutproperty_identifier |
| 34 |
{ |
| 35 |
my ($msishortcutproperty) = @_; |
| 36 |
|
| 37 |
my $identifier = $msishortcutproperty->{'gid'}; |
| 38 |
|
| 39 |
return $identifier; |
| 40 |
} |
| 41 |
|
| 42 |
############################################################## |
| 43 |
# Returning shortcut for msishortcutproperty table. |
| 44 |
############################################################## |
| 45 |
|
| 46 |
sub get_msishorcutproperty_shortcut |
| 47 |
{ |
| 48 |
my ($msishortcutproperty, $filesref) = @_; |
| 49 |
|
| 50 |
my $onefile; |
| 51 |
my $shortcut = ""; |
| 52 |
my $found = 0; |
| 53 |
my $msishortcutproperty_shortcutid = $msishortcutproperty->{'ShortcutID'}; |
| 54 |
|
| 55 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 56 |
{ |
| 57 |
$onefile = ${$filesref}[$i]; |
| 58 |
my $filegid = $onefile->{'gid'}; |
| 59 |
|
| 60 |
if ( $filegid eq $msishortcutproperty_shortcutid ) |
| 61 |
{ |
| 62 |
$found = 1; |
| 63 |
last; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
if (!($found)) |
| 68 |
{ |
| 69 |
installer::exiter::exit_program("ERROR: Did not find ShortcutID $msishortcutproperty_shortcutid in file collection for shortcut", "get_msishorcutproperty_shortcut"); |
| 70 |
} |
| 71 |
|
| 72 |
$shortcut = $onefile->{'gid'}; |
| 73 |
|
| 74 |
return $shortcut; |
| 75 |
} |
| 76 |
|
| 77 |
############################################################## |
| 78 |
# Returning the propertykey for msishortcutproperty table. |
| 79 |
############################################################## |
| 80 |
|
| 81 |
sub get_msishortcutproperty_propertykey |
| 82 |
{ |
| 83 |
my ($msishortcutproperty) = @_; |
| 84 |
|
| 85 |
my $propertykey = ""; |
| 86 |
if ( $msishortcutproperty->{'Key'} ) { $propertykey = $msishortcutproperty->{'Key'}; } |
| 87 |
|
| 88 |
return $propertykey; |
| 89 |
} |
| 90 |
|
| 91 |
################################################################ |
| 92 |
# Returning the propvariantvalue for msishortcutproperty table. |
| 93 |
################################################################ |
| 94 |
|
| 95 |
sub get_msishortcutproperty_propvariantvalue |
| 96 |
{ |
| 97 |
my ($msishortcutproperty) = @_; |
| 98 |
|
| 99 |
my $propvariantvalue = ""; |
| 100 |
if ( $msishortcutproperty->{'Value'} ) { $propvariantvalue = $msishortcutproperty->{'Value'}; } |
| 101 |
|
| 102 |
return $propvariantvalue; |
| 103 |
} |
| 104 |
|
| 105 |
################################################################### |
| 106 |
# Creating the file MsiShortcutProperty.idt dynamically |
| 107 |
# Content: |
| 108 |
# MsiShortcutProperty Shortcut_ PropertyKey PropVariantValue |
| 109 |
################################################################### |
| 110 |
|
| 111 |
sub create_msishortcutproperty_table |
| 112 |
{ |
| 113 |
my ($folderitempropertiesref, $folderitemsref, $basedir) = @_; |
| 114 |
|
| 115 |
my @msishortcutpropertytable = (); |
| 116 |
|
| 117 |
installer::windows::idtglobal::write_idt_header(\@msishortcutpropertytable, "msishortcutproperty"); |
| 118 |
|
| 119 |
# The entries defined in scp as FolderItemProperties |
| 120 |
|
| 121 |
for ( my $j = 0; $j <= $#{$folderitempropertiesref}; $j++ ) |
| 122 |
{ |
| 123 |
my $onelink = ${$folderitempropertiesref}[$j]; |
| 124 |
my %msishortcutproperty = (); |
| 125 |
|
| 126 |
$msishortcutproperty{'MsiShortcutProperty'} = get_msishortcutproperty_identifier($onelink); |
| 127 |
$msishortcutproperty{'Shortcut_'} = get_msishorcutproperty_shortcut($onelink, $folderitemsref); |
| 128 |
$msishortcutproperty{'PropertyKey'} = get_msishortcutproperty_propertykey($onelink); |
| 129 |
$msishortcutproperty{'PropVariantValue'} = get_msishortcutproperty_propvariantvalue($onelink); |
| 130 |
|
| 131 |
my $oneline = $msishortcutproperty{'MsiShortcutProperty'} . "\t" . $msishortcutproperty{'Shortcut_'} . "\t" |
| 132 |
. $msishortcutproperty{'PropertyKey'} . "\t" . $msishortcutproperty{'PropVariantValue'} . "\n"; |
| 133 |
|
| 134 |
push(@msishortcutpropertytable, $oneline); |
| 135 |
} |
| 136 |
|
| 137 |
# Saving the file |
| 138 |
|
| 139 |
my $msishortcutpropertytablename = $basedir . $installer::globals::separator . "MsiShorP.idt"; |
| 140 |
installer::files::save_file($msishortcutpropertytablename ,\@msishortcutpropertytable); |
| 141 |
my $infoline = "Created idt file: $msishortcutpropertytablename\n"; |
| 142 |
push(@installer::globals::logfileinfo, $infoline); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
1; |