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