19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::windows::registry;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::files;
27cdf0e10cSrcweiruse installer::globals;
28cdf0e10cSrcweiruse installer::worker;
2919d58b3aSEike Rathkeuse installer::windows::msiglobal;
30cdf0e10cSrcweiruse installer::windows::idtglobal;
31cdf0e10cSrcweir
32*9f91b7e3SAndre Fischeruse strict;
33*9f91b7e3SAndre Fischer
34cdf0e10cSrcweir#####################################################
35cdf0e10cSrcweir# Generating the component name from a registryitem
36cdf0e10cSrcweir#####################################################
37cdf0e10cSrcweir
38cdf0e10cSrcweirsub get_registry_component_name
39cdf0e10cSrcweir{
40cdf0e10cSrcweir	my ($registryref, $allvariables) = @_;
41cdf0e10cSrcweir
42cdf0e10cSrcweir	# In this function exists the rule to create components from registryitems
43cdf0e10cSrcweir	# Rule:
44cdf0e10cSrcweir	# The componentname can be directly taken from the ModuleID.
45cdf0e10cSrcweir	# All registryitems belonging to one module can get the same component.
46cdf0e10cSrcweir
47cdf0e10cSrcweir	my $componentname = "";
48cdf0e10cSrcweir	my $isrootmodule = 0;
49cdf0e10cSrcweir
50cdf0e10cSrcweir	if ( $registryref->{'ModuleID'} ) { $componentname = $registryref->{'ModuleID'}; }
51cdf0e10cSrcweir
52cdf0e10cSrcweir	$componentname =~ s/\\/\_/g;
53cdf0e10cSrcweir	$componentname =~ s/\//\_/g;
54cdf0e10cSrcweir	$componentname =~ s/\-/\_/g;
55cdf0e10cSrcweir	$componentname =~ s/\_\s*$//g;
56cdf0e10cSrcweir
57cdf0e10cSrcweir	$componentname = lc($componentname);	# componentnames always lowercase
58cdf0e10cSrcweir
59cdf0e10cSrcweir	if ( $componentname eq "gid_module_root" ) { $isrootmodule = 1; }
60cdf0e10cSrcweir
61cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
62cdf0e10cSrcweir
63cdf0e10cSrcweir	# identifying this component as registryitem component
64cdf0e10cSrcweir	$componentname = "registry_" . $componentname;
65cdf0e10cSrcweir
66cdf0e10cSrcweir	$componentname =~ s/gid_module_/g_m_/g;
67cdf0e10cSrcweir	$componentname =~ s/_optional_/_o_/g;
68cdf0e10cSrcweir	$componentname =~ s/_javafilter_/_jf_/g;
69cdf0e10cSrcweir
70cdf0e10cSrcweir	# This componentname must be more specific
71cdf0e10cSrcweir	my $addon = "_";
72cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTNAME'} ) { $addon = $addon . $allvariables->{'PRODUCTNAME'}; }
73cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTVERSION'} ) { $addon = $addon . $allvariables->{'PRODUCTVERSION'}; }
74cdf0e10cSrcweir	$addon = lc($addon);
75cdf0e10cSrcweir	$addon =~ s/ //g;
76cdf0e10cSrcweir	$addon =~ s/-//g;
77cdf0e10cSrcweir	$addon =~ s/\.//g;
78cdf0e10cSrcweir
79cdf0e10cSrcweir	my $styles = "";
80cdf0e10cSrcweir	if ( $registryref->{'Styles'} ) { $styles = $registryref->{'Styles'}; }
81cdf0e10cSrcweir
82cdf0e10cSrcweir	$componentname = $componentname . $addon;
83cdf0e10cSrcweir
84cdf0e10cSrcweir	if (( $styles =~ /\bLANGUAGEPACK\b/ ) && ( $installer::globals::languagepack )) { $componentname = $componentname . "_lang"; }
85cdf0e10cSrcweir	if ( $styles =~ /\bALWAYS_REQUIRED\b/ ) { $componentname = $componentname . "_forced"; }
86cdf0e10cSrcweir
87cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
88cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_in_this_database_ : resetted for each database
89cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_ : not resetted for each database
90cdf0e10cSrcweir	# Component strings must be unique for the complete product, because they are used for
91cdf0e10cSrcweir	# the creation of the globally unique identifier.
92cdf0e10cSrcweir
93cdf0e10cSrcweir	my $fullname = $componentname;  # This can be longer than 72
94cdf0e10cSrcweir
95cdf0e10cSrcweir	if (( exists($installer::globals::allregistrycomponents_{$fullname}) ) && ( ! exists($installer::globals::allregistrycomponents_in_this_database_{$fullname}) ))
96cdf0e10cSrcweir	{
97cdf0e10cSrcweir		# This is not allowed: One component cannot be installed with different packages.
98cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Windows registry component \"$fullname\" is already included into another package. This is not allowed.", "get_registry_component_name");
99cdf0e10cSrcweir	}
100cdf0e10cSrcweir
101cdf0e10cSrcweir	if ( exists($installer::globals::allregistrycomponents_{$fullname}) )
102cdf0e10cSrcweir	{
103cdf0e10cSrcweir		$componentname = $installer::globals::allregistrycomponents_{$fullname};
104cdf0e10cSrcweir	}
105cdf0e10cSrcweir	else
106cdf0e10cSrcweir	{
10719d58b3aSEike Rathke		if ( length($componentname) > 70 )
108cdf0e10cSrcweir		{
109cdf0e10cSrcweir			$componentname = generate_new_short_registrycomponentname($componentname); # This has to be unique for the complete product, not only one package
110cdf0e10cSrcweir		}
111cdf0e10cSrcweir
112cdf0e10cSrcweir		$installer::globals::allregistrycomponents_{$fullname} = $componentname;
113cdf0e10cSrcweir		$installer::globals::allregistrycomponents_in_this_database_{$fullname} = 1;
114cdf0e10cSrcweir	}
115cdf0e10cSrcweir
116cdf0e10cSrcweir	if ( $isrootmodule ) { $installer::globals::registryrootcomponent = $componentname; }
117cdf0e10cSrcweir
118cdf0e10cSrcweir	return $componentname;
119cdf0e10cSrcweir}
120cdf0e10cSrcweir
121cdf0e10cSrcweir#########################################################
122cdf0e10cSrcweir# Create a shorter version of a long component name,
123cdf0e10cSrcweir# because maximum length in msi database is 72.
124cdf0e10cSrcweir# Attention: In multi msi installation sets, the short
125cdf0e10cSrcweir# names have to be unique over all packages, because
126cdf0e10cSrcweir# this string is used to create the globally unique id
127cdf0e10cSrcweir# -> no resetting of
128cdf0e10cSrcweir# %installer::globals::allshortregistrycomponents
129cdf0e10cSrcweir# after a package was created.
130cdf0e10cSrcweir#########################################################
131cdf0e10cSrcweir
132cdf0e10cSrcweirsub generate_new_short_registrycomponentname
133cdf0e10cSrcweir{
134cdf0e10cSrcweir	my ($componentname) = @_;
13519d58b3aSEike Rathke
136cdf0e10cSrcweir	my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters
13719d58b3aSEike Rathke	my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits
13819d58b3aSEike Rathke	my $shortcomponentname = $startversion . "_" . $subid;
139cdf0e10cSrcweir
14019d58b3aSEike Rathke	if ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_registrycomponentname"); }
141cdf0e10cSrcweir
142cdf0e10cSrcweir	$installer::globals::allshortregistrycomponents{$shortcomponentname} = 1;
143cdf0e10cSrcweir
144cdf0e10cSrcweir	return $shortcomponentname;
145cdf0e10cSrcweir}
146cdf0e10cSrcweir
147cdf0e10cSrcweir##############################################################
148cdf0e10cSrcweir# Returning identifier for registry table.
149cdf0e10cSrcweir##############################################################
150cdf0e10cSrcweir
151cdf0e10cSrcweirsub get_registry_identifier
152cdf0e10cSrcweir{
153cdf0e10cSrcweir	my ($registry) = @_;
154cdf0e10cSrcweir
155cdf0e10cSrcweir	my $identifier = "";
156cdf0e10cSrcweir
157cdf0e10cSrcweir	if ( $registry->{'gid'} ) { $identifier = $registry->{'gid'}; }
158cdf0e10cSrcweir
159cdf0e10cSrcweir	$identifier = lc($identifier);	# always lower case
160cdf0e10cSrcweir
161cdf0e10cSrcweir	# Attention: Maximum length is 72
162cdf0e10cSrcweir
163cdf0e10cSrcweir	$identifier =~ s/gid_regitem_/g_r_/;
164cdf0e10cSrcweir	$identifier =~ s/_soffice_/_s_/;
165cdf0e10cSrcweir	$identifier =~ s/_clsid_/_c_/;
166cdf0e10cSrcweir	$identifier =~ s/_currentversion_/_cv_/;
167cdf0e10cSrcweir	$identifier =~ s/_microsoft_/_ms_/;
168cdf0e10cSrcweir	$identifier =~ s/_manufacturer_/_mf_/;
169cdf0e10cSrcweir	$identifier =~ s/_productname_/_pn_/;
170cdf0e10cSrcweir	$identifier =~ s/_productversion_/_pv_/;
171cdf0e10cSrcweir	$identifier =~ s/_staroffice_/_so_/;
172cdf0e10cSrcweir	$identifier =~ s/_software_/_sw_/;
173cdf0e10cSrcweir	$identifier =~ s/_capabilities_/_cap_/;
174cdf0e10cSrcweir	$identifier =~ s/_classpath_/_cp_/;
175cdf0e10cSrcweir	$identifier =~ s/_extension_/_ex_/;
176cdf0e10cSrcweir	$identifier =~ s/_fileassociations_/_fa_/;
177cdf0e10cSrcweir	$identifier =~ s/_propertysheethandlers_/_psh_/;
178cdf0e10cSrcweir	$identifier =~ s/__/_/g;
179cdf0e10cSrcweir
180cdf0e10cSrcweir	# Saving this in the registry collector
181cdf0e10cSrcweir
182cdf0e10cSrcweir	$registry->{'uniquename'} = $identifier;
183cdf0e10cSrcweir
184cdf0e10cSrcweir	return $identifier;
185cdf0e10cSrcweir}
186cdf0e10cSrcweir
187cdf0e10cSrcweir##################################################################
188cdf0e10cSrcweir# Returning root value for registry table.
189cdf0e10cSrcweir##################################################################
190cdf0e10cSrcweir
191cdf0e10cSrcweirsub get_registry_root
192cdf0e10cSrcweir{
193cdf0e10cSrcweir	my ($registry) = @_;
194cdf0e10cSrcweir
195cdf0e10cSrcweir	my $rootvalue = 0;	# Default: Parent is KKEY_CLASSES_ROOT
196cdf0e10cSrcweir	my $scproot = "";
197cdf0e10cSrcweir
198cdf0e10cSrcweir	if ( $registry->{'ParentID'} ) { $scproot = $registry->{'ParentID'}; }
199cdf0e10cSrcweir
200cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE" ) { $rootvalue = -1; }
201cdf0e10cSrcweir
202cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CLASSES_ROOT" ) { $rootvalue = 0; }
203cdf0e10cSrcweir
204cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CURRENT_USER_ONLY" ) { $rootvalue = 1; }
205cdf0e10cSrcweir
206cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE_ONLY" ) { $rootvalue = 2; }
207cdf0e10cSrcweir
208cdf0e10cSrcweir	return $rootvalue;
209cdf0e10cSrcweir}
210cdf0e10cSrcweir
211cdf0e10cSrcweir##############################################################
212cdf0e10cSrcweir# Returning key for registry table.
213cdf0e10cSrcweir##############################################################
214cdf0e10cSrcweir
215cdf0e10cSrcweirsub get_registry_key
216cdf0e10cSrcweir{
217cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
218cdf0e10cSrcweir
219cdf0e10cSrcweir	my $key = "";
220cdf0e10cSrcweir
221cdf0e10cSrcweir	if ( $registry->{'Subkey'} ) { $key = $registry->{'Subkey'}; }
222cdf0e10cSrcweir
223cdf0e10cSrcweir	if ( $key =~ /\%/ ) { $key = installer::worker::replace_variables_in_string($key, $allvariableshashref); }
224cdf0e10cSrcweir
225cdf0e10cSrcweir	return $key;
226cdf0e10cSrcweir}
227cdf0e10cSrcweir
228cdf0e10cSrcweir##############################################################
229cdf0e10cSrcweir# Returning name for registry table.
230cdf0e10cSrcweir##############################################################
231cdf0e10cSrcweir
232cdf0e10cSrcweirsub get_registry_name
233cdf0e10cSrcweir{
234cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
235cdf0e10cSrcweir
236cdf0e10cSrcweir	my $name = "";
237cdf0e10cSrcweir
238cdf0e10cSrcweir	if ( $registry->{'Name'} ) { $name = $registry->{'Name'}; }
239cdf0e10cSrcweir
240cdf0e10cSrcweir	if ( $name =~ /\%/ ) { $name = installer::worker::replace_variables_in_string($name, $allvariableshashref); }
241cdf0e10cSrcweir
242cdf0e10cSrcweir	return $name;
243cdf0e10cSrcweir}
244cdf0e10cSrcweir
245cdf0e10cSrcweir##############################################################
246cdf0e10cSrcweir# Returning value for registry table.
247cdf0e10cSrcweir##############################################################
248cdf0e10cSrcweir
249cdf0e10cSrcweirsub get_registry_value
250cdf0e10cSrcweir{
251cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
252cdf0e10cSrcweir
253cdf0e10cSrcweir	my $value = "";
254cdf0e10cSrcweir
255cdf0e10cSrcweir	if ( $registry->{'Value'} ) { $value = $registry->{'Value'}; }
256cdf0e10cSrcweir
257cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
258cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
259cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
260cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
261cdf0e10cSrcweir
262cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
263cdf0e10cSrcweir
264cdf0e10cSrcweir	return $value;
265cdf0e10cSrcweir}
266cdf0e10cSrcweir
267cdf0e10cSrcweir##############################################################
268cdf0e10cSrcweir# Returning 64 bit value for registry table.
269cdf0e10cSrcweir##############################################################
270cdf0e10cSrcweir
271cdf0e10cSrcweirsub get_registry_val64
272cdf0e10cSrcweir{
273cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
274cdf0e10cSrcweir
275cdf0e10cSrcweir	my $value = "";
276cdf0e10cSrcweir
277cdf0e10cSrcweir	if ( $registry->{'Val64'} ) { $value = $registry->{'Val64'}; }
278cdf0e10cSrcweir
279cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
280cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
281cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
282cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
283cdf0e10cSrcweir
284cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
285cdf0e10cSrcweir
286cdf0e10cSrcweir	return $value;
287cdf0e10cSrcweir}
288cdf0e10cSrcweir
289cdf0e10cSrcweir
290cdf0e10cSrcweir######################################################
291cdf0e10cSrcweir# Adding the content of
292cdf0e10cSrcweir# @installer::globals::userregistrycollector
293cdf0e10cSrcweir# to the registry table. The content was collected
294cdf0e10cSrcweir# in create_files_table() in file.pm.
295cdf0e10cSrcweir######################################################
296cdf0e10cSrcweir
297cdf0e10cSrcweirsub add_userregs_to_registry_table
298cdf0e10cSrcweir{
299cdf0e10cSrcweir	my ( $registrytable, $allvariables ) = @_;
300cdf0e10cSrcweir
301cdf0e10cSrcweir	for ( my $i = 0; $i <= $#installer::globals::userregistrycollector; $i++ )
302cdf0e10cSrcweir	{
303cdf0e10cSrcweir		my $onefile = $installer::globals::userregistrycollector[$i];
304cdf0e10cSrcweir
305cdf0e10cSrcweir		my $styles = "";
306cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
307cdf0e10cSrcweir
308cdf0e10cSrcweir		my %registry = ();
309cdf0e10cSrcweir
310cdf0e10cSrcweir		$registry{'Registry'} = $onefile->{'userregkeypath'};
311cdf0e10cSrcweir		$registry{'Root'} = "1";  # always HKCU
312cdf0e10cSrcweir		$registry{'Key'} = "Software\\$allvariables->{'MANUFACTURER'}\\$allvariables->{'PRODUCTNAME'} $allvariables->{'PRODUCTVERSION'}\\";
313cdf0e10cSrcweir		if ( $onefile->{'needs_user_registry_key'} ) { $registry{'Key'} = $registry{'Key'} . "StartMenu"; }
314cdf0e10cSrcweir		else { $registry{'Key'} = $registry{'Key'} . "ShellNew"; }
315cdf0e10cSrcweir		$registry{'Name'} = $onefile->{'Name'};
316cdf0e10cSrcweir		$registry{'Value'} = "1";
317cdf0e10cSrcweir		$registry{'Component_'} = $onefile->{'componentname'};
318cdf0e10cSrcweir
319cdf0e10cSrcweir		my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
320cdf0e10cSrcweir					. $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n";
321cdf0e10cSrcweir
322cdf0e10cSrcweir		push(@{$registrytable}, $oneline);
323cdf0e10cSrcweir	}
324cdf0e10cSrcweir}
325cdf0e10cSrcweir
326cdf0e10cSrcweir######################################################
327cdf0e10cSrcweir# Creating the file Registry.idt dynamically
328cdf0e10cSrcweir# Content:
329cdf0e10cSrcweir# Registry Root Key Name Value Component_
330cdf0e10cSrcweir######################################################
331*9f91b7e3SAndre Fischersub prepare_registry_table ($$$)
332cdf0e10cSrcweir{
333*9f91b7e3SAndre Fischer	my ($registryref, $languagesarrayref, $allvariableshashref) = @_;
334cdf0e10cSrcweir
3351ba1fd99SAndre Fischer    my %table_data = ();
3361ba1fd99SAndre Fischer	foreach my $onelanguage (@$languagesarrayref)
337cdf0e10cSrcweir	{
3381ba1fd99SAndre Fischer        my $table_items = [];
3391ba1fd99SAndre Fischer		foreach my $oneregistry (@$registryref)
340cdf0e10cSrcweir		{
341cdf0e10cSrcweir			# Controlling the language!
342cdf0e10cSrcweir			# Only language independent folderitems or folderitems with the correct language
343cdf0e10cSrcweir			# will be included into the table
344cdf0e10cSrcweir
3451ba1fd99SAndre Fischer			next if $oneregistry->{'ismultilingual'}
3461ba1fd99SAndre Fischer                && $oneregistry->{'specificlanguage'} ne $onelanguage;
347cdf0e10cSrcweir
348cdf0e10cSrcweir			my %registry = ();
349cdf0e10cSrcweir
350cdf0e10cSrcweir			$registry{'Registry'} = get_registry_identifier($oneregistry);
351cdf0e10cSrcweir			$registry{'Root'} = get_registry_root($oneregistry);
352cdf0e10cSrcweir			$registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref);
353cdf0e10cSrcweir			$registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref);
354cdf0e10cSrcweir			$registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref);
355cdf0e10cSrcweir			$registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref);
3561ba1fd99SAndre Fischer            my $component_name = get_registry_component_name($oneregistry, $allvariableshashref);
3571ba1fd99SAndre Fischer            $oneregistry->{'componentname'} = $component_name;
3581ba1fd99SAndre Fischer			$registry{'Component_'} = $component_name;
359cdf0e10cSrcweir
360cdf0e10cSrcweir			# Collecting all components with DONT_DELETE style
3611ba1fd99SAndre Fischer			my $style = $oneregistry->{'Styles'} // "";
3621ba1fd99SAndre Fischer            $registry{'styles'} = $style;
3631ba1fd99SAndre Fischer
3641ba1fd99SAndre Fischer			if ( $style =~ /\bDONT_DELETE\b/ )
3651ba1fd99SAndre Fischer            {
3661ba1fd99SAndre Fischer                $installer::globals::dontdeletecomponents{$component_name} = 1;
3671ba1fd99SAndre Fischer            }
368cdf0e10cSrcweir
369cdf0e10cSrcweir			# Saving upgradekey to write this into setup.ini for minor upgrades
3701ba1fd99SAndre Fischer			if ( $style =~ /\bUPGRADEKEY\b/ )
3711ba1fd99SAndre Fischer            {
3721ba1fd99SAndre Fischer                $installer::globals::minorupgradekey = $registry{'Key'};
3731ba1fd99SAndre Fischer            }
374cdf0e10cSrcweir
375cdf0e10cSrcweir			# Collecting all registry components with ALWAYS_REQUIRED style
376cdf0e10cSrcweir			if ( ! ( $style =~ /\bALWAYS_REQUIRED\b/ ))
377cdf0e10cSrcweir			{
378cdf0e10cSrcweir				# Setting a component condition for unforced registry components!
379cdf0e10cSrcweir				# Only write into registry, if WRITE_REGISTRY is set.
380cdf0e10cSrcweir				if ( $oneregistry->{'ComponentCondition'} ) { $oneregistry->{'ComponentCondition'} = "(" . $oneregistry->{'ComponentCondition'} . ") AND (WRITE_REGISTRY=1)"; }
381cdf0e10cSrcweir				else { $oneregistry->{'ComponentCondition'} = "WRITE_REGISTRY=1"; }
382cdf0e10cSrcweir			}
383cdf0e10cSrcweir
384cdf0e10cSrcweir			# Collecting all component conditions
385cdf0e10cSrcweir			if ( $oneregistry->{'ComponentCondition'} )
386cdf0e10cSrcweir			{
387cdf0e10cSrcweir				if ( ! exists($installer::globals::componentcondition{$registry{'Component_'}}))
388cdf0e10cSrcweir				{
389cdf0e10cSrcweir					$installer::globals::componentcondition{$registry{'Component_'}} = $oneregistry->{'ComponentCondition'};
390cdf0e10cSrcweir				}
391cdf0e10cSrcweir			}
392cdf0e10cSrcweir
393*9f91b7e3SAndre Fischer            push @$table_items, \%registry;
394*9f91b7e3SAndre Fischer		}
395*9f91b7e3SAndre Fischer        $table_data{$onelanguage} = $table_items;
396*9f91b7e3SAndre Fischer    }
397*9f91b7e3SAndre Fischer
398*9f91b7e3SAndre Fischer    return \%table_data;
399*9f91b7e3SAndre Fischer}
400*9f91b7e3SAndre Fischer
401*9f91b7e3SAndre Fischer
402*9f91b7e3SAndre Fischer
403*9f91b7e3SAndre Fischer
404*9f91b7e3SAndre Fischersub collect_registry_components ($)
405*9f91b7e3SAndre Fischer{
406*9f91b7e3SAndre Fischer    my ($table_data) = @_;
407*9f91b7e3SAndre Fischer
408*9f91b7e3SAndre Fischer    my %components = ();
409*9f91b7e3SAndre Fischer    foreach my $language_data (values %$table_data)
410*9f91b7e3SAndre Fischer    {
411*9f91b7e3SAndre Fischer        foreach my $item (@$language_data)
412*9f91b7e3SAndre Fischer        {
413*9f91b7e3SAndre Fischer			$components{$item->{'Component_'}} = 1;
414*9f91b7e3SAndre Fischer        }
415*9f91b7e3SAndre Fischer    }
416*9f91b7e3SAndre Fischer    return keys %components;
417*9f91b7e3SAndre Fischer}
418*9f91b7e3SAndre Fischer
419*9f91b7e3SAndre Fischer
420*9f91b7e3SAndre Fischer
421*9f91b7e3SAndre Fischer
422*9f91b7e3SAndre Fischersub translate_component_names ($$$)
423*9f91b7e3SAndre Fischer{
424*9f91b7e3SAndre Fischer    my ($translation_map, $registry_items, $table_data) = @_;
425*9f91b7e3SAndre Fischer
426*9f91b7e3SAndre Fischer    my $replacement_count = 0;
427*9f91b7e3SAndre Fischer    foreach my $item (@$registry_items)
428*9f91b7e3SAndre Fischer    {
429*9f91b7e3SAndre Fischer        my $translated_name = $translation_map->{$item->{'componentname'}};
430*9f91b7e3SAndre Fischer        if (defined $translated_name)
431*9f91b7e3SAndre Fischer        {
432*9f91b7e3SAndre Fischer            $item->{'componentname'} = $translated_name;
433*9f91b7e3SAndre Fischer            ++$replacement_count;
434*9f91b7e3SAndre Fischer        }
435*9f91b7e3SAndre Fischer    }
436*9f91b7e3SAndre Fischer    $installer::logger::Lang->printf("replaced %d component names in registry items\n", $replacement_count);
437*9f91b7e3SAndre Fischer
438*9f91b7e3SAndre Fischer    $replacement_count = 0;
439*9f91b7e3SAndre Fischer    foreach my $language_data (values %$table_data)
440*9f91b7e3SAndre Fischer    {
441*9f91b7e3SAndre Fischer        foreach my $item (@$language_data)
442*9f91b7e3SAndre Fischer        {
443*9f91b7e3SAndre Fischer            my $translated_name = $translation_map->{$item->{'Component_'}};
444*9f91b7e3SAndre Fischer            if (defined $translated_name)
445*9f91b7e3SAndre Fischer            {
446*9f91b7e3SAndre Fischer                $item->{'Component_'} = $translated_name;
447*9f91b7e3SAndre Fischer                ++$replacement_count;
448*9f91b7e3SAndre Fischer            }
449*9f91b7e3SAndre Fischer        }
450*9f91b7e3SAndre Fischer    }
451*9f91b7e3SAndre Fischer    $installer::logger::Lang->printf("replaced %d component names in registry table\n", $replacement_count);
452*9f91b7e3SAndre Fischer}
453*9f91b7e3SAndre Fischer
454*9f91b7e3SAndre Fischer
455*9f91b7e3SAndre Fischer
456cdf0e10cSrcweir
457*9f91b7e3SAndre Fischersub create_registry_table_32 ($$$$)
458*9f91b7e3SAndre Fischer{
459*9f91b7e3SAndre Fischer	my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_;
460*9f91b7e3SAndre Fischer
461*9f91b7e3SAndre Fischer	foreach my $onelanguage (@$languagesarrayref)
462*9f91b7e3SAndre Fischer	{
463*9f91b7e3SAndre Fischer		my @registrytable = ();
464*9f91b7e3SAndre Fischer        installer::windows::idtglobal::write_idt_header(\@registrytable, "registry");
465cdf0e10cSrcweir
466*9f91b7e3SAndre Fischer		foreach my $item (@{$table_data->{$onelanguage}})
467*9f91b7e3SAndre Fischer		{
468*9f91b7e3SAndre Fischer			next if $item->{'styles'} =~ /\bX64_ONLY\b/;
469*9f91b7e3SAndre Fischer
470*9f91b7e3SAndre Fischer			my $oneline = join("\t",
471*9f91b7e3SAndre Fischer                $item->{'Registry'},
472*9f91b7e3SAndre Fischer                $item->{'Root'},
473*9f91b7e3SAndre Fischer                $item->{'Key'},
474*9f91b7e3SAndre Fischer                $item->{'Name'},
475*9f91b7e3SAndre Fischer                $item->{'Value'},
476*9f91b7e3SAndre Fischer                $item->{'Component_'})
477*9f91b7e3SAndre Fischer                . "\n";
478*9f91b7e3SAndre Fischer
479*9f91b7e3SAndre Fischer            push(@registrytable, $oneline);
480cdf0e10cSrcweir		}
481cdf0e10cSrcweir
482cdf0e10cSrcweir		# If there are added user registry keys for files collected in
483cdf0e10cSrcweir		# @installer::globals::userregistrycollector (file.pm), then
484cdf0e10cSrcweir		# this registry keys have to be added now. This is necessary for
485cdf0e10cSrcweir		# files in PREDEFINED_OSSHELLNEWDIR, because their component
486cdf0e10cSrcweir		# needs as KeyPath a RegistryItem in HKCU.
487cdf0e10cSrcweir
488*9f91b7e3SAndre Fischer		if ( $installer::globals::addeduserregitrykeys )
489*9f91b7e3SAndre Fischer        {
490*9f91b7e3SAndre Fischer            add_userregs_to_registry_table(\@registrytable, $allvariableshashref);
491*9f91b7e3SAndre Fischer        }
492cdf0e10cSrcweir
493*9f91b7e3SAndre Fischer		# Save the database file.
494cdf0e10cSrcweir		my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage;
495cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@registrytable);
496b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
497*9f91b7e3SAndre Fischer	}
498*9f91b7e3SAndre Fischer}
499*9f91b7e3SAndre Fischer
500cdf0e10cSrcweir
501*9f91b7e3SAndre Fischer
502*9f91b7e3SAndre Fischer
503*9f91b7e3SAndre Fischersub create_registry_table_64 ($$$$)
504*9f91b7e3SAndre Fischer{
505*9f91b7e3SAndre Fischer	my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_;
506*9f91b7e3SAndre Fischer
507*9f91b7e3SAndre Fischer	foreach my $onelanguage (@$languagesarrayref)
508*9f91b7e3SAndre Fischer	{
509*9f91b7e3SAndre Fischer        my @reg64table = ();
510*9f91b7e3SAndre Fischer		installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64");
511*9f91b7e3SAndre Fischer		foreach my $item (@{$table_data->{$onelanguage}})
512*9f91b7e3SAndre Fischer        {
513*9f91b7e3SAndre Fischer			next unless $item->{'styles'} =~ /\b(X64|X64_ONLY)\b/;
514*9f91b7e3SAndre Fischer
515*9f91b7e3SAndre Fischer            my $oneline64 = join("\t",
516*9f91b7e3SAndre Fischer                $item->{'Registry'},
517*9f91b7e3SAndre Fischer                $item->{'Root'},
518*9f91b7e3SAndre Fischer                $item->{'Key'},
519*9f91b7e3SAndre Fischer                $item->{'Name'},
520*9f91b7e3SAndre Fischer                $item->{'Val64'},
521*9f91b7e3SAndre Fischer                $item->{'Component_'})
522*9f91b7e3SAndre Fischer                . "\n";
523*9f91b7e3SAndre Fischer
524*9f91b7e3SAndre Fischer            push(@reg64table , $oneline64);
525*9f91b7e3SAndre Fischer        }
526*9f91b7e3SAndre Fischer
527*9f91b7e3SAndre Fischer        # Save the database file.
528*9f91b7e3SAndre Fischer		my $registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage;
529cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@reg64table );
530b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
531cdf0e10cSrcweir	}
532cdf0e10cSrcweir}
533cdf0e10cSrcweir
534cdf0e10cSrcweir1;
535