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
32cdf0e10cSrcweir#####################################################
33cdf0e10cSrcweir# Generating the component name from a registryitem
34cdf0e10cSrcweir#####################################################
35cdf0e10cSrcweir
36cdf0e10cSrcweirsub get_registry_component_name
37cdf0e10cSrcweir{
38cdf0e10cSrcweir	my ($registryref, $allvariables) = @_;
39cdf0e10cSrcweir
40cdf0e10cSrcweir	# In this function exists the rule to create components from registryitems
41cdf0e10cSrcweir	# Rule:
42cdf0e10cSrcweir	# The componentname can be directly taken from the ModuleID.
43cdf0e10cSrcweir	# All registryitems belonging to one module can get the same component.
44cdf0e10cSrcweir
45cdf0e10cSrcweir	my $componentname = "";
46cdf0e10cSrcweir	my $isrootmodule = 0;
47cdf0e10cSrcweir
48cdf0e10cSrcweir	if ( $registryref->{'ModuleID'} ) { $componentname = $registryref->{'ModuleID'}; }
49cdf0e10cSrcweir
50cdf0e10cSrcweir	$componentname =~ s/\\/\_/g;
51cdf0e10cSrcweir	$componentname =~ s/\//\_/g;
52cdf0e10cSrcweir	$componentname =~ s/\-/\_/g;
53cdf0e10cSrcweir	$componentname =~ s/\_\s*$//g;
54cdf0e10cSrcweir
55cdf0e10cSrcweir	$componentname = lc($componentname);	# componentnames always lowercase
56cdf0e10cSrcweir
57cdf0e10cSrcweir	if ( $componentname eq "gid_module_root" ) { $isrootmodule = 1; }
58cdf0e10cSrcweir
59cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
60cdf0e10cSrcweir
61cdf0e10cSrcweir	# identifying this component as registryitem component
62cdf0e10cSrcweir	$componentname = "registry_" . $componentname;
63cdf0e10cSrcweir
64cdf0e10cSrcweir	$componentname =~ s/gid_module_/g_m_/g;
65cdf0e10cSrcweir	$componentname =~ s/_optional_/_o_/g;
66cdf0e10cSrcweir	$componentname =~ s/_javafilter_/_jf_/g;
67cdf0e10cSrcweir
68cdf0e10cSrcweir	# This componentname must be more specific
69cdf0e10cSrcweir	my $addon = "_";
70cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTNAME'} ) { $addon = $addon . $allvariables->{'PRODUCTNAME'}; }
71cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTVERSION'} ) { $addon = $addon . $allvariables->{'PRODUCTVERSION'}; }
72cdf0e10cSrcweir	$addon = lc($addon);
73cdf0e10cSrcweir	$addon =~ s/ //g;
74cdf0e10cSrcweir	$addon =~ s/-//g;
75cdf0e10cSrcweir	$addon =~ s/\.//g;
76cdf0e10cSrcweir
77cdf0e10cSrcweir	my $styles = "";
78cdf0e10cSrcweir	if ( $registryref->{'Styles'} ) { $styles = $registryref->{'Styles'}; }
79cdf0e10cSrcweir
80cdf0e10cSrcweir	# Layer links must have unique Component GUID for all products. This is necessary, because only the
81cdf0e10cSrcweir	# uninstallation of the last product has to delete registry keys.
82cdf0e10cSrcweir	if ( $styles =~ /\bLAYER_REGISTRY\b/ )
83cdf0e10cSrcweir	{
84cdf0e10cSrcweir		$componentname = "g_m_root_registry_layer_ooo_reglayer";
85cdf0e10cSrcweir		# Styles USE_URELAYERVERSION, USE_OOOBASEVERSION
86cdf0e10cSrcweir		if ( $styles =~ /\bUSE_URELAYERVERSION\b/ ) { $addon = "_ure_" . $allvariables->{'URELAYERVERSION'}; }
87cdf0e10cSrcweir		if ( $styles =~ /\bUSE_OOOBASEVERSION\b/ ) { $addon = "_basis_" . $allvariables->{'OOOBASEVERSION'}; }
88cdf0e10cSrcweir		$addon =~ s/\.//g;
89cdf0e10cSrcweir	}
90cdf0e10cSrcweir
91cdf0e10cSrcweir	$componentname = $componentname . $addon;
92cdf0e10cSrcweir
93cdf0e10cSrcweir	if (( $styles =~ /\bLANGUAGEPACK\b/ ) && ( $installer::globals::languagepack )) { $componentname = $componentname . "_lang"; }
94cdf0e10cSrcweir	if ( $styles =~ /\bALWAYS_REQUIRED\b/ ) { $componentname = $componentname . "_forced"; }
95cdf0e10cSrcweir
96cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
97cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_in_this_database_ : resetted for each database
98cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_ : not resetted for each database
99cdf0e10cSrcweir	# Component strings must be unique for the complete product, because they are used for
100cdf0e10cSrcweir	# the creation of the globally unique identifier.
101cdf0e10cSrcweir
102cdf0e10cSrcweir	my $fullname = $componentname;  # This can be longer than 72
103cdf0e10cSrcweir
104cdf0e10cSrcweir	if (( exists($installer::globals::allregistrycomponents_{$fullname}) ) && ( ! exists($installer::globals::allregistrycomponents_in_this_database_{$fullname}) ))
105cdf0e10cSrcweir	{
106cdf0e10cSrcweir		# This is not allowed: One component cannot be installed with different packages.
107cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Windows registry component \"$fullname\" is already included into another package. This is not allowed.", "get_registry_component_name");
108cdf0e10cSrcweir	}
109cdf0e10cSrcweir
110cdf0e10cSrcweir	if ( exists($installer::globals::allregistrycomponents_{$fullname}) )
111cdf0e10cSrcweir	{
112cdf0e10cSrcweir		$componentname = $installer::globals::allregistrycomponents_{$fullname};
113cdf0e10cSrcweir	}
114cdf0e10cSrcweir	else
115cdf0e10cSrcweir	{
11619d58b3aSEike Rathke		if ( length($componentname) > 70 )
117cdf0e10cSrcweir		{
118cdf0e10cSrcweir			$componentname = generate_new_short_registrycomponentname($componentname); # This has to be unique for the complete product, not only one package
119cdf0e10cSrcweir		}
120cdf0e10cSrcweir
121cdf0e10cSrcweir		$installer::globals::allregistrycomponents_{$fullname} = $componentname;
122cdf0e10cSrcweir		$installer::globals::allregistrycomponents_in_this_database_{$fullname} = 1;
123cdf0e10cSrcweir	}
124cdf0e10cSrcweir
125cdf0e10cSrcweir	if ( $isrootmodule ) { $installer::globals::registryrootcomponent = $componentname; }
126cdf0e10cSrcweir
127cdf0e10cSrcweir	return $componentname;
128cdf0e10cSrcweir}
129cdf0e10cSrcweir
130cdf0e10cSrcweir#########################################################
131cdf0e10cSrcweir# Create a shorter version of a long component name,
132cdf0e10cSrcweir# because maximum length in msi database is 72.
133cdf0e10cSrcweir# Attention: In multi msi installation sets, the short
134cdf0e10cSrcweir# names have to be unique over all packages, because
135cdf0e10cSrcweir# this string is used to create the globally unique id
136cdf0e10cSrcweir# -> no resetting of
137cdf0e10cSrcweir# %installer::globals::allshortregistrycomponents
138cdf0e10cSrcweir# after a package was created.
139cdf0e10cSrcweir#########################################################
140cdf0e10cSrcweir
141cdf0e10cSrcweirsub generate_new_short_registrycomponentname
142cdf0e10cSrcweir{
143cdf0e10cSrcweir	my ($componentname) = @_;
14419d58b3aSEike Rathke
145cdf0e10cSrcweir	my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters
14619d58b3aSEike Rathke	my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits
14719d58b3aSEike Rathke	my $shortcomponentname = $startversion . "_" . $subid;
148cdf0e10cSrcweir
14919d58b3aSEike Rathke	if ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_registrycomponentname"); }
150cdf0e10cSrcweir
151cdf0e10cSrcweir	$installer::globals::allshortregistrycomponents{$shortcomponentname} = 1;
152cdf0e10cSrcweir
153cdf0e10cSrcweir	return $shortcomponentname;
154cdf0e10cSrcweir}
155cdf0e10cSrcweir
156cdf0e10cSrcweir##############################################################
157cdf0e10cSrcweir# Returning identifier for registry table.
158cdf0e10cSrcweir##############################################################
159cdf0e10cSrcweir
160cdf0e10cSrcweirsub get_registry_identifier
161cdf0e10cSrcweir{
162cdf0e10cSrcweir	my ($registry) = @_;
163cdf0e10cSrcweir
164cdf0e10cSrcweir	my $identifier = "";
165cdf0e10cSrcweir
166cdf0e10cSrcweir	if ( $registry->{'gid'} ) { $identifier = $registry->{'gid'}; }
167cdf0e10cSrcweir
168cdf0e10cSrcweir	$identifier = lc($identifier);	# always lower case
169cdf0e10cSrcweir
170cdf0e10cSrcweir	# Attention: Maximum length is 72
171cdf0e10cSrcweir
172cdf0e10cSrcweir	$identifier =~ s/gid_regitem_/g_r_/;
173cdf0e10cSrcweir	$identifier =~ s/_soffice_/_s_/;
174cdf0e10cSrcweir	$identifier =~ s/_clsid_/_c_/;
175cdf0e10cSrcweir	$identifier =~ s/_currentversion_/_cv_/;
176cdf0e10cSrcweir	$identifier =~ s/_microsoft_/_ms_/;
177cdf0e10cSrcweir	$identifier =~ s/_manufacturer_/_mf_/;
178cdf0e10cSrcweir	$identifier =~ s/_productname_/_pn_/;
179cdf0e10cSrcweir	$identifier =~ s/_productversion_/_pv_/;
180cdf0e10cSrcweir	$identifier =~ s/_staroffice_/_so_/;
181cdf0e10cSrcweir	$identifier =~ s/_software_/_sw_/;
182cdf0e10cSrcweir	$identifier =~ s/_capabilities_/_cap_/;
183cdf0e10cSrcweir	$identifier =~ s/_classpath_/_cp_/;
184cdf0e10cSrcweir	$identifier =~ s/_extension_/_ex_/;
185cdf0e10cSrcweir	$identifier =~ s/_fileassociations_/_fa_/;
186cdf0e10cSrcweir	$identifier =~ s/_propertysheethandlers_/_psh_/;
187cdf0e10cSrcweir	$identifier =~ s/__/_/g;
188cdf0e10cSrcweir
189cdf0e10cSrcweir	# Saving this in the registry collector
190cdf0e10cSrcweir
191cdf0e10cSrcweir	$registry->{'uniquename'} = $identifier;
192cdf0e10cSrcweir
193cdf0e10cSrcweir	return $identifier;
194cdf0e10cSrcweir}
195cdf0e10cSrcweir
196cdf0e10cSrcweir##################################################################
197cdf0e10cSrcweir# Returning root value for registry table.
198cdf0e10cSrcweir##################################################################
199cdf0e10cSrcweir
200cdf0e10cSrcweirsub get_registry_root
201cdf0e10cSrcweir{
202cdf0e10cSrcweir	my ($registry) = @_;
203cdf0e10cSrcweir
204cdf0e10cSrcweir	my $rootvalue = 0;	# Default: Parent is KKEY_CLASSES_ROOT
205cdf0e10cSrcweir	my $scproot = "";
206cdf0e10cSrcweir
207cdf0e10cSrcweir	if ( $registry->{'ParentID'} ) { $scproot = $registry->{'ParentID'}; }
208cdf0e10cSrcweir
209cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE" ) { $rootvalue = -1; }
210cdf0e10cSrcweir
211cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CLASSES_ROOT" ) { $rootvalue = 0; }
212cdf0e10cSrcweir
213cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CURRENT_USER_ONLY" ) { $rootvalue = 1; }
214cdf0e10cSrcweir
215cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE_ONLY" ) { $rootvalue = 2; }
216cdf0e10cSrcweir
217cdf0e10cSrcweir	return $rootvalue;
218cdf0e10cSrcweir}
219cdf0e10cSrcweir
220cdf0e10cSrcweir##############################################################
221cdf0e10cSrcweir# Returning key for registry table.
222cdf0e10cSrcweir##############################################################
223cdf0e10cSrcweir
224cdf0e10cSrcweirsub get_registry_key
225cdf0e10cSrcweir{
226cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
227cdf0e10cSrcweir
228cdf0e10cSrcweir	my $key = "";
229cdf0e10cSrcweir
230cdf0e10cSrcweir	if ( $registry->{'Subkey'} ) { $key = $registry->{'Subkey'}; }
231cdf0e10cSrcweir
232cdf0e10cSrcweir	if ( $key =~ /\%/ ) { $key = installer::worker::replace_variables_in_string($key, $allvariableshashref); }
233cdf0e10cSrcweir
234cdf0e10cSrcweir	return $key;
235cdf0e10cSrcweir}
236cdf0e10cSrcweir
237cdf0e10cSrcweir##############################################################
238cdf0e10cSrcweir# Returning name for registry table.
239cdf0e10cSrcweir##############################################################
240cdf0e10cSrcweir
241cdf0e10cSrcweirsub get_registry_name
242cdf0e10cSrcweir{
243cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
244cdf0e10cSrcweir
245cdf0e10cSrcweir	my $name = "";
246cdf0e10cSrcweir
247cdf0e10cSrcweir	if ( $registry->{'Name'} ) { $name = $registry->{'Name'}; }
248cdf0e10cSrcweir
249cdf0e10cSrcweir	if ( $name =~ /\%/ ) { $name = installer::worker::replace_variables_in_string($name, $allvariableshashref); }
250cdf0e10cSrcweir
251cdf0e10cSrcweir	return $name;
252cdf0e10cSrcweir}
253cdf0e10cSrcweir
254cdf0e10cSrcweir##############################################################
255cdf0e10cSrcweir# Returning value for registry table.
256cdf0e10cSrcweir##############################################################
257cdf0e10cSrcweir
258cdf0e10cSrcweirsub get_registry_value
259cdf0e10cSrcweir{
260cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
261cdf0e10cSrcweir
262cdf0e10cSrcweir	my $value = "";
263cdf0e10cSrcweir
264cdf0e10cSrcweir	if ( $registry->{'Value'} ) { $value = $registry->{'Value'}; }
265cdf0e10cSrcweir
266cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
267cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
268cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
269cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
270cdf0e10cSrcweir
271cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
272cdf0e10cSrcweir
273cdf0e10cSrcweir	return $value;
274cdf0e10cSrcweir}
275cdf0e10cSrcweir
276cdf0e10cSrcweir##############################################################
277cdf0e10cSrcweir# Returning 64 bit value for registry table.
278cdf0e10cSrcweir##############################################################
279cdf0e10cSrcweir
280cdf0e10cSrcweirsub get_registry_val64
281cdf0e10cSrcweir{
282cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
283cdf0e10cSrcweir
284cdf0e10cSrcweir	my $value = "";
285cdf0e10cSrcweir
286cdf0e10cSrcweir	if ( $registry->{'Val64'} ) { $value = $registry->{'Val64'}; }
287cdf0e10cSrcweir
288cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
289cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
290cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
291cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
292cdf0e10cSrcweir
293cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
294cdf0e10cSrcweir
295cdf0e10cSrcweir	return $value;
296cdf0e10cSrcweir}
297cdf0e10cSrcweir
298cdf0e10cSrcweir##############################################################
299cdf0e10cSrcweir# Returning component for registry table.
300cdf0e10cSrcweir##############################################################
301cdf0e10cSrcweir
302cdf0e10cSrcweirsub get_registry_component
303cdf0e10cSrcweir{
304cdf0e10cSrcweir	my ($registry, $allvariables) = @_;
305cdf0e10cSrcweir
306cdf0e10cSrcweir	# All registry items belonging to one module can
307cdf0e10cSrcweir	# be included into one component
308cdf0e10cSrcweir
309cdf0e10cSrcweir	my $componentname = get_registry_component_name($registry, $allvariables);
310cdf0e10cSrcweir
311cdf0e10cSrcweir	# saving componentname in the registryitem collector
312cdf0e10cSrcweir
313cdf0e10cSrcweir	$registry->{'componentname'} = $componentname;
314cdf0e10cSrcweir
315cdf0e10cSrcweir	return $componentname;
316cdf0e10cSrcweir}
317cdf0e10cSrcweir
318cdf0e10cSrcweir######################################################
319cdf0e10cSrcweir# Adding the content of
320cdf0e10cSrcweir# @installer::globals::userregistrycollector
321cdf0e10cSrcweir# to the registry table. The content was collected
322cdf0e10cSrcweir# in create_files_table() in file.pm.
323cdf0e10cSrcweir######################################################
324cdf0e10cSrcweir
325cdf0e10cSrcweirsub add_userregs_to_registry_table
326cdf0e10cSrcweir{
327cdf0e10cSrcweir	my ( $registrytable, $allvariables ) = @_;
328cdf0e10cSrcweir
329cdf0e10cSrcweir	for ( my $i = 0; $i <= $#installer::globals::userregistrycollector; $i++ )
330cdf0e10cSrcweir	{
331cdf0e10cSrcweir		my $onefile = $installer::globals::userregistrycollector[$i];
332cdf0e10cSrcweir
333cdf0e10cSrcweir		my $styles = "";
334cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
335cdf0e10cSrcweir
336cdf0e10cSrcweir		my %registry = ();
337cdf0e10cSrcweir
338cdf0e10cSrcweir		$registry{'Registry'} = $onefile->{'userregkeypath'};
339cdf0e10cSrcweir		$registry{'Root'} = "1";  # always HKCU
340cdf0e10cSrcweir		$registry{'Key'} = "Software\\$allvariables->{'MANUFACTURER'}\\$allvariables->{'PRODUCTNAME'} $allvariables->{'PRODUCTVERSION'}\\";
341cdf0e10cSrcweir		if ( $onefile->{'needs_user_registry_key'} ) { $registry{'Key'} = $registry{'Key'} . "StartMenu"; }
342cdf0e10cSrcweir		else { $registry{'Key'} = $registry{'Key'} . "ShellNew"; }
343cdf0e10cSrcweir		$registry{'Name'} = $onefile->{'Name'};
344cdf0e10cSrcweir		$registry{'Value'} = "1";
345cdf0e10cSrcweir		$registry{'Component_'} = $onefile->{'componentname'};
346cdf0e10cSrcweir
347cdf0e10cSrcweir		my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
348cdf0e10cSrcweir					. $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n";
349cdf0e10cSrcweir
350cdf0e10cSrcweir		push(@{$registrytable}, $oneline);
351cdf0e10cSrcweir	}
352cdf0e10cSrcweir}
353cdf0e10cSrcweir
354cdf0e10cSrcweir######################################################
355cdf0e10cSrcweir# Creating the file Registry.idt dynamically
356cdf0e10cSrcweir# Content:
357cdf0e10cSrcweir# Registry Root Key Name Value Component_
358cdf0e10cSrcweir######################################################
359cdf0e10cSrcweir
360cdf0e10cSrcweirsub create_registry_table
361cdf0e10cSrcweir{
362cdf0e10cSrcweir	my ($registryref, $allregistrycomponentsref, $basedir, $languagesarrayref, $allvariableshashref) = @_;
363cdf0e10cSrcweir
364cdf0e10cSrcweir	for ( my $m = 0; $m <= $#{$languagesarrayref}; $m++ )
365cdf0e10cSrcweir	{
366cdf0e10cSrcweir		my $onelanguage = ${$languagesarrayref}[$m];
367cdf0e10cSrcweir
368cdf0e10cSrcweir		my @registrytable = ();
369cdf0e10cSrcweir		my @reg64table = ();
370cdf0e10cSrcweir
371cdf0e10cSrcweir		installer::windows::idtglobal::write_idt_header(\@registrytable, "registry");
372cdf0e10cSrcweir		installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64");
373cdf0e10cSrcweir
374cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$registryref}; $i++ )
375cdf0e10cSrcweir		{
376cdf0e10cSrcweir			my $oneregistry = ${$registryref}[$i];
377cdf0e10cSrcweir
378cdf0e10cSrcweir			# Controlling the language!
379cdf0e10cSrcweir			# Only language independent folderitems or folderitems with the correct language
380cdf0e10cSrcweir			# will be included into the table
381cdf0e10cSrcweir
382cdf0e10cSrcweir			if (! (!(( $oneregistry->{'ismultilingual'} )) || ( $oneregistry->{'specificlanguage'} eq $onelanguage )) )  { next; }
383cdf0e10cSrcweir
384cdf0e10cSrcweir			my %registry = ();
385cdf0e10cSrcweir
386cdf0e10cSrcweir			$registry{'Registry'} = get_registry_identifier($oneregistry);
387cdf0e10cSrcweir			$registry{'Root'} = get_registry_root($oneregistry);
388cdf0e10cSrcweir			$registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref);
389cdf0e10cSrcweir			$registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref);
390cdf0e10cSrcweir			$registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref);
391cdf0e10cSrcweir			$registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref);
392cdf0e10cSrcweir			$registry{'Component_'} = get_registry_component($oneregistry, $allvariableshashref);
393cdf0e10cSrcweir
394cdf0e10cSrcweir			# Collecting all components
395cdf0e10cSrcweir			if (!(installer::existence::exists_in_array($registry{'Component_'}, $allregistrycomponentsref)))
396cdf0e10cSrcweir			{
397cdf0e10cSrcweir				push(@{$allregistrycomponentsref}, $registry{'Component_'});
398cdf0e10cSrcweir			}
399cdf0e10cSrcweir
400cdf0e10cSrcweir			# Collecting all components with DONT_DELETE style
401cdf0e10cSrcweir			my $style = "";
402cdf0e10cSrcweir			if ( $oneregistry->{'Styles'} ) { $style = $oneregistry->{'Styles'}; }
403cdf0e10cSrcweir			if ( $style =~ /\bDONT_DELETE\b/ ) { $installer::globals::dontdeletecomponents{$registry{'Component_'}} = 1; }
404cdf0e10cSrcweir
405cdf0e10cSrcweir			# Saving upgradekey to write this into setup.ini for minor upgrades
406cdf0e10cSrcweir			if ( $style =~ /\bUPGRADEKEY\b/ ) { $installer::globals::minorupgradekey = $registry{'Key'}; }
407cdf0e10cSrcweir
408cdf0e10cSrcweir			# Collecting all registry components with ALWAYS_REQUIRED style
409cdf0e10cSrcweir			if ( ! ( $style =~ /\bALWAYS_REQUIRED\b/ ))
410cdf0e10cSrcweir			{
411cdf0e10cSrcweir				# Setting a component condition for unforced registry components!
412cdf0e10cSrcweir				# Only write into registry, if WRITE_REGISTRY is set.
413cdf0e10cSrcweir				if ( $oneregistry->{'ComponentCondition'} ) { $oneregistry->{'ComponentCondition'} = "(" . $oneregistry->{'ComponentCondition'} . ") AND (WRITE_REGISTRY=1)"; }
414cdf0e10cSrcweir				else { $oneregistry->{'ComponentCondition'} = "WRITE_REGISTRY=1"; }
415cdf0e10cSrcweir			}
416cdf0e10cSrcweir
417cdf0e10cSrcweir			# Collecting all component conditions
418cdf0e10cSrcweir			if ( $oneregistry->{'ComponentCondition'} )
419cdf0e10cSrcweir			{
420cdf0e10cSrcweir				if ( ! exists($installer::globals::componentcondition{$registry{'Component_'}}))
421cdf0e10cSrcweir				{
422cdf0e10cSrcweir					$installer::globals::componentcondition{$registry{'Component_'}} = $oneregistry->{'ComponentCondition'};
423cdf0e10cSrcweir				}
424cdf0e10cSrcweir			}
425cdf0e10cSrcweir
426cdf0e10cSrcweir			my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
427cdf0e10cSrcweir						. $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n";
428cdf0e10cSrcweir
429cdf0e10cSrcweir			my $oneline64 = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
430cdf0e10cSrcweir						. $registry{'Name'} . "\t" . $registry{'Val64'} . "\t" . $registry{'Component_'} . "\n";
431cdf0e10cSrcweir
432cdf0e10cSrcweir			if ( ! ( $style =~ /\bX64_ONLY\b/ )) { push(@registrytable, $oneline); }	# standard registry table for 32 Bit
433cdf0e10cSrcweir			if (( $style =~ /\bX64\b/ ) || ( $style =~ /\bX64_ONLY\b/ )) { push(@reg64table , $oneline64); }
434cdf0e10cSrcweir		}
435cdf0e10cSrcweir
436cdf0e10cSrcweir		# If there are added user registry keys for files collected in
437cdf0e10cSrcweir		# @installer::globals::userregistrycollector (file.pm), then
438cdf0e10cSrcweir		# this registry keys have to be added now. This is necessary for
439cdf0e10cSrcweir		# files in PREDEFINED_OSSHELLNEWDIR, because their component
440cdf0e10cSrcweir		# needs as KeyPath a RegistryItem in HKCU.
441cdf0e10cSrcweir
442cdf0e10cSrcweir		if ( $installer::globals::addeduserregitrykeys ) { add_userregs_to_registry_table(\@registrytable, $allvariableshashref); }
443cdf0e10cSrcweir
444cdf0e10cSrcweir		# Saving the file
445cdf0e10cSrcweir
446cdf0e10cSrcweir		my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage;
447cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@registrytable);
448*b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
449cdf0e10cSrcweir
450cdf0e10cSrcweir		$registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage;
451cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@reg64table );
452*b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
453cdf0e10cSrcweir	}
454cdf0e10cSrcweir}
455cdf0e10cSrcweir
456cdf0e10cSrcweir1;
457