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::idtglobal;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse Cwd;
27cdf0e10cSrcweiruse installer::converter;
28cdf0e10cSrcweiruse installer::existence;
29cdf0e10cSrcweiruse installer::exiter;
30cdf0e10cSrcweiruse installer::files;
31cdf0e10cSrcweiruse installer::globals;
32cdf0e10cSrcweiruse installer::pathanalyzer;
33cdf0e10cSrcweiruse installer::remover;
34cdf0e10cSrcweiruse installer::scriptitems;
35cdf0e10cSrcweiruse installer::systemactions;
36cdf0e10cSrcweiruse installer::windows::language;
37cdf0e10cSrcweir
38cdf0e10cSrcweir##############################################################
39cdf0e10cSrcweir# Shorten the gid for a feature.
40cdf0e10cSrcweir# Attention: Maximum length is 38
41cdf0e10cSrcweir##############################################################
42cdf0e10cSrcweir
43cdf0e10cSrcweirsub shorten_feature_gid
44cdf0e10cSrcweir{
45cdf0e10cSrcweir	my ($stringref) = @_;
46cdf0e10cSrcweir
47cdf0e10cSrcweir	$$stringref =~ s/gid_Module_/gm_/;
48cdf0e10cSrcweir	$$stringref =~ s/_Extension_/_ex_/;
49cdf0e10cSrcweir	$$stringref =~ s/_Root_/_r_/;
50cdf0e10cSrcweir	$$stringref =~ s/_Prg_/_p_/;
51cdf0e10cSrcweir	$$stringref =~ s/_Optional_/_o_/;
52cdf0e10cSrcweir	$$stringref =~ s/_Tools_/_tl_/;
53cdf0e10cSrcweir	$$stringref =~ s/_Wrt_Flt_/_w_f_/;
54cdf0e10cSrcweir	$$stringref =~ s/_Javafilter_/_jf_/;
55cdf0e10cSrcweir	$$stringref =~ s/_Productivity_/_pr_/;
564f647325SEike Rathke	$$stringref =~ s/_Replacement_/_rpl_/;
57cdf0e10cSrcweir}
58cdf0e10cSrcweir
591ba1fd99SAndre Fischer=head2 create_shortend_feature_gid ($feature_name)
601ba1fd99SAndre Fischer
611ba1fd99SAndre Fischer    This is a side effect free version of shorten_feature_gid.
621ba1fd99SAndre Fischer    The shortened feature name is returned instead of overwriting the given name.
631ba1fd99SAndre Fischer
641ba1fd99SAndre Fischer=cut
651ba1fd99SAndre Fischersub create_shortend_feature_gid ($)
661ba1fd99SAndre Fischer{
671ba1fd99SAndre Fischer    my ($feature_name) = @_;
681ba1fd99SAndre Fischer    shorten_feature_gid(\$feature_name);
691ba1fd99SAndre Fischer    return $feature_name;
701ba1fd99SAndre Fischer}
711ba1fd99SAndre Fischer
72cdf0e10cSrcweir############################################
73cdf0e10cSrcweir# Getting the next free number, that
74cdf0e10cSrcweir# can be added.
75cdf0e10cSrcweir# Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
76cdf0e10cSrcweir############################################
77cdf0e10cSrcweir
78cdf0e10cSrcweirsub get_next_free_number
79cdf0e10cSrcweir{
80cdf0e10cSrcweir	my ($name, $shortnamesref) = @_;
81cdf0e10cSrcweir
82cdf0e10cSrcweir	my $counter = 0;
83cdf0e10cSrcweir	my $dontsave = 0;
84cdf0e10cSrcweir	my $alreadyexists;
85cdf0e10cSrcweir	my ($newname, $shortname);
86cdf0e10cSrcweir
87cdf0e10cSrcweir	do
88cdf0e10cSrcweir	{
89cdf0e10cSrcweir		$alreadyexists = 0;
90cdf0e10cSrcweir		$counter++;
91cdf0e10cSrcweir		$newname = $name . $counter;
92cdf0e10cSrcweir
93cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$shortnamesref}; $i++ )
94cdf0e10cSrcweir		{
95cdf0e10cSrcweir			$shortname = ${$shortnamesref}[$i];
96cdf0e10cSrcweir
97cdf0e10cSrcweir			if ( uc($shortname) eq uc($newname) )	# case insensitive
98cdf0e10cSrcweir			{
99cdf0e10cSrcweir				$alreadyexists = 1;
100cdf0e10cSrcweir				last;
101cdf0e10cSrcweir			}
102cdf0e10cSrcweir		}
103cdf0e10cSrcweir	}
104cdf0e10cSrcweir	until (!($alreadyexists));
105cdf0e10cSrcweir
106cdf0e10cSrcweir	if (( $counter > 9 ) && ( length($name) > 6 )) { $dontsave = 1; }
107cdf0e10cSrcweir	if (( $counter > 99 ) && ( length($name) > 5 )) { $dontsave = 1; }
108cdf0e10cSrcweir
109cdf0e10cSrcweir	if (!($dontsave))
110cdf0e10cSrcweir	{
111cdf0e10cSrcweir		push(@{$shortnamesref}, $newname);	# adding the new shortname to the array of shortnames
112cdf0e10cSrcweir	}
113cdf0e10cSrcweir
114cdf0e10cSrcweir	return $counter
115cdf0e10cSrcweir}
116cdf0e10cSrcweir
117cdf0e10cSrcweir############################################
118cdf0e10cSrcweir# Getting the next free number, that
119cdf0e10cSrcweir# can be added.
120cdf0e10cSrcweir# Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
121cdf0e10cSrcweir############################################
122cdf0e10cSrcweir
123cdf0e10cSrcweirsub get_next_free_number_with_hash
124cdf0e10cSrcweir{
125cdf0e10cSrcweir	my ($name, $shortnamesref, $ext) = @_;
126cdf0e10cSrcweir
127cdf0e10cSrcweir	my $counter = 0;
128cdf0e10cSrcweir	my $dontsave = 0;
129cdf0e10cSrcweir	my $saved = 0;
130cdf0e10cSrcweir	my $alreadyexists;
131cdf0e10cSrcweir	my ($newname, $shortname);
132cdf0e10cSrcweir
133cdf0e10cSrcweir	do
134cdf0e10cSrcweir	{
135cdf0e10cSrcweir		$alreadyexists = 0;
136cdf0e10cSrcweir		$counter++;
137cdf0e10cSrcweir		$newname = $name . $counter;
138cdf0e10cSrcweir		$newname = uc($newname);	# case insensitive, always upper case
139cdf0e10cSrcweir		if ( exists($shortnamesref->{$newname}) ||
140cdf0e10cSrcweir		     exists($installer::globals::savedrev83mapping{$newname.$ext}) )
141cdf0e10cSrcweir		{
142cdf0e10cSrcweir			$alreadyexists = 1;
143cdf0e10cSrcweir		}
144cdf0e10cSrcweir	}
145cdf0e10cSrcweir	until (!($alreadyexists));
146cdf0e10cSrcweir
147cdf0e10cSrcweir	if (( $counter > 9 ) && ( length($name) > 6 )) { $dontsave = 1; }
148cdf0e10cSrcweir	if (( $counter > 99 ) && ( length($name) > 5 )) { $dontsave = 1; }
149cdf0e10cSrcweir
150cdf0e10cSrcweir	if (!($dontsave))
151cdf0e10cSrcweir	{
152cdf0e10cSrcweir		# push(@{$shortnamesref}, $newname);	# adding the new shortname to the array of shortnames
153cdf0e10cSrcweir		$shortnamesref->{$newname} = 1;	# adding the new shortname to the array of shortnames, always uppercase
154cdf0e10cSrcweir		$saved = 1;
155cdf0e10cSrcweir	}
156cdf0e10cSrcweir
157cdf0e10cSrcweir	return ( $counter, $saved )
158cdf0e10cSrcweir}
159cdf0e10cSrcweir
160cdf0e10cSrcweir#########################################
161cdf0e10cSrcweir# 8.3 for filenames and directories
162cdf0e10cSrcweir#########################################
163cdf0e10cSrcweir
164cdf0e10cSrcweirsub make_eight_three_conform
165cdf0e10cSrcweir{
166cdf0e10cSrcweir	my ($inputstring, $pattern, $shortnamesref) = @_;
167cdf0e10cSrcweir
168cdf0e10cSrcweir	# all shortnames are collected in $shortnamesref, because of uniqueness
169cdf0e10cSrcweir
170cdf0e10cSrcweir	my ($name, $namelength, $number);
171cdf0e10cSrcweir	my $conformstring = "";
172cdf0e10cSrcweir	my $changed = 0;
173cdf0e10cSrcweir
174cdf0e10cSrcweir	if (( $inputstring =~ /^\s*(.*?)\.(.*?)\s*$/ ) && ( $pattern eq "file" ))	# files with a dot
175cdf0e10cSrcweir	{
176cdf0e10cSrcweir		$name = $1;
177cdf0e10cSrcweir		my $extension = $2;
178cdf0e10cSrcweir
179cdf0e10cSrcweir		$namelength = length($name);
180cdf0e10cSrcweir		my $extensionlength = length($extension);
181cdf0e10cSrcweir
182cdf0e10cSrcweir		if ( $extensionlength > 3 )
183cdf0e10cSrcweir		{
184cdf0e10cSrcweir			# simply taking the first three letters
185cdf0e10cSrcweir			$extension = substr($extension, 0, 3);	# name, offset, length
186cdf0e10cSrcweir		}
187cdf0e10cSrcweir
188cdf0e10cSrcweir		# Attention: readme.html -> README~1.HTM
189cdf0e10cSrcweir
190cdf0e10cSrcweir		if (( $namelength > 8 ) || ( $extensionlength > 3 ))
191cdf0e10cSrcweir		{
192cdf0e10cSrcweir			# taking the first six letters
193cdf0e10cSrcweir			$name = substr($name, 0, 6);	# name, offset, length
194cdf0e10cSrcweir			$name =~ s/\s*$//; # removing ending whitespaces
195cdf0e10cSrcweir			$name = $name . "\~";
196cdf0e10cSrcweir			$number = get_next_free_number($name, $shortnamesref);
197cdf0e10cSrcweir
198cdf0e10cSrcweir			# if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
199cdf0e10cSrcweir
200cdf0e10cSrcweir			if ( $number > 9 )
201cdf0e10cSrcweir			{
202cdf0e10cSrcweir				$name = substr($name, 0, 5);	# name, offset, length
203cdf0e10cSrcweir				$name =~ s/\s*$//; # removing ending whitespaces
204cdf0e10cSrcweir				$name = $name . "\~";
205cdf0e10cSrcweir				$number = get_next_free_number($name, $shortnamesref);
206cdf0e10cSrcweir
207cdf0e10cSrcweir				if ( $number > 99 )
208cdf0e10cSrcweir				{
209cdf0e10cSrcweir					$name = substr($name, 0, 4);	# name, offset, length
210cdf0e10cSrcweir					$name =~ s/\s*$//; # removing ending whitespaces
211cdf0e10cSrcweir					$name = $name . "\~";
212cdf0e10cSrcweir					$number = get_next_free_number($name, $shortnamesref);
213cdf0e10cSrcweir				}
214cdf0e10cSrcweir			}
215cdf0e10cSrcweir
216cdf0e10cSrcweir			$name = $name . "$number";
217cdf0e10cSrcweir
218cdf0e10cSrcweir			$changed = 1;
219cdf0e10cSrcweir		}
220cdf0e10cSrcweir
221cdf0e10cSrcweir		$conformstring = $name . "\." . $extension;
222cdf0e10cSrcweir
223cdf0e10cSrcweir		if ( $changed ) { $conformstring= uc($conformstring); }
224cdf0e10cSrcweir	}
225cdf0e10cSrcweir	else 		# no dot in filename or directory (also used for shortcuts)
226cdf0e10cSrcweir	{
227cdf0e10cSrcweir		$name = $inputstring;
228cdf0e10cSrcweir		$namelength = length($name);
229cdf0e10cSrcweir
230cdf0e10cSrcweir		if ( $namelength > 8 )
231cdf0e10cSrcweir		{
232cdf0e10cSrcweir			# taking the first six letters
233cdf0e10cSrcweir			$name = substr($name, 0, 6);	# name, offset, length
234cdf0e10cSrcweir			$name =~ s/\s*$//; # removing ending whitespaces
235cdf0e10cSrcweir			$name = $name . "\~";
236cdf0e10cSrcweir			$number = get_next_free_number($name, $shortnamesref);
237cdf0e10cSrcweir
238cdf0e10cSrcweir			# if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
239cdf0e10cSrcweir
240cdf0e10cSrcweir			if ( $number > 9 )
241cdf0e10cSrcweir			{
242cdf0e10cSrcweir				$name = substr($name, 0, 5);	# name, offset, length
243cdf0e10cSrcweir				$name =~ s/\s*$//; # removing ending whitespaces
244cdf0e10cSrcweir				$name = $name . "\~";
245cdf0e10cSrcweir				$number = get_next_free_number($name, $shortnamesref);
246cdf0e10cSrcweir
247cdf0e10cSrcweir				if ( $number > 99 )
248cdf0e10cSrcweir				{
249cdf0e10cSrcweir					$name = substr($name, 0, 4);	# name, offset, length
250cdf0e10cSrcweir					$name =~ s/\s*$//; # removing ending whitespaces
251cdf0e10cSrcweir					$name = $name . "\~";
252cdf0e10cSrcweir					$number = get_next_free_number($name, $shortnamesref);
253cdf0e10cSrcweir				}
254cdf0e10cSrcweir			}
255cdf0e10cSrcweir
256cdf0e10cSrcweir			$name = $name . "$number";
257cdf0e10cSrcweir			$changed = 1;
258cdf0e10cSrcweir			if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; }	# in directories replacing "." with "_"
259cdf0e10cSrcweir		}
260cdf0e10cSrcweir
261cdf0e10cSrcweir		$conformstring = $name;
262cdf0e10cSrcweir
263cdf0e10cSrcweir		if ( $changed ) { $conformstring = uc($name); }
264cdf0e10cSrcweir	}
265cdf0e10cSrcweir
266cdf0e10cSrcweir	return $conformstring;
267cdf0e10cSrcweir}
268cdf0e10cSrcweir
269cdf0e10cSrcweir#########################################
270cdf0e10cSrcweir# 8.3 for filenames and directories
271cdf0e10cSrcweir# $shortnamesref is a hash in this case
272cdf0e10cSrcweir# -> performance reasons
273cdf0e10cSrcweir#########################################
274cdf0e10cSrcweir
275cdf0e10cSrcweirsub make_eight_three_conform_with_hash
276cdf0e10cSrcweir{
277cdf0e10cSrcweir	my ($inputstring, $pattern, $shortnamesref) = @_;
278cdf0e10cSrcweir
279cdf0e10cSrcweir	# all shortnames are collected in $shortnamesref, because of uniqueness (a hash!)
280cdf0e10cSrcweir
281cdf0e10cSrcweir	my ($name, $namelength, $number);
282cdf0e10cSrcweir	my $conformstring = "";
283cdf0e10cSrcweir	my $changed = 0;
284cdf0e10cSrcweir	my $saved;
285cdf0e10cSrcweir
286cdf0e10cSrcweir	# if (( $inputstring =~ /^\s*(.*?)\.(.*?)\s*$/ ) && ( $pattern eq "file" ))	# files with a dot
287cdf0e10cSrcweir	if (( $inputstring =~ /^\s*(.*)\.(.*?)\s*$/ ) && ( $pattern eq "file" ))	# files with a dot
288cdf0e10cSrcweir	{
289cdf0e10cSrcweir		# extension has to be non-greedy, but name is. This is important to find the last dot in the filename
290cdf0e10cSrcweir		$name = $1;
291cdf0e10cSrcweir		my $extension = $2;
292cdf0e10cSrcweir
293cdf0e10cSrcweir		if ( $name =~ /^\s*(.*?)\s*$/ ) { $name = $1; } # now the name is also non-greedy
294cdf0e10cSrcweir		$name =~ s/\.//g; # no dots in 8+3 conform filename
295cdf0e10cSrcweir
296cdf0e10cSrcweir		$namelength = length($name);
297cdf0e10cSrcweir		my $extensionlength = length($extension);
298cdf0e10cSrcweir
299cdf0e10cSrcweir		if ( $extensionlength > 3 )
300cdf0e10cSrcweir		{
301cdf0e10cSrcweir			# simply taking the first three letters
302cdf0e10cSrcweir			$extension = substr($extension, 0, 3);	# name, offset, length
303cdf0e10cSrcweir			$changed = 1;
304cdf0e10cSrcweir		}
305cdf0e10cSrcweir
306cdf0e10cSrcweir		# Attention: readme.html -> README~1.HTM
307cdf0e10cSrcweir
308cdf0e10cSrcweir		if (( $namelength > 8 ) || ( $extensionlength > 3 ))
309cdf0e10cSrcweir		{
310cdf0e10cSrcweir			# taking the first six letters, if filename is longer than 6 characters
311cdf0e10cSrcweir			if ( $namelength > 6 )
312cdf0e10cSrcweir			{
313cdf0e10cSrcweir				$name = substr($name, 0, 6);	# name, offset, length
314cdf0e10cSrcweir				$name =~ s/\s*$//; # removing ending whitespaces
315cdf0e10cSrcweir				$name = $name . "\~";
316cdf0e10cSrcweir				($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
317cdf0e10cSrcweir
318cdf0e10cSrcweir				# if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
319cdf0e10cSrcweir
320cdf0e10cSrcweir				if ( ! $saved )
321cdf0e10cSrcweir				{
322cdf0e10cSrcweir					$name = substr($name, 0, 5);	# name, offset, length
323cdf0e10cSrcweir					$name =~ s/\s*$//; # removing ending whitespaces
324cdf0e10cSrcweir					$name = $name . "\~";
325cdf0e10cSrcweir					($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
326cdf0e10cSrcweir
327cdf0e10cSrcweir					# if $number>99 the new name would be "abcde~100.xyz", which is 9+3, and therefore not allowed
328cdf0e10cSrcweir
329cdf0e10cSrcweir					if ( ! $saved )
330cdf0e10cSrcweir					{
331cdf0e10cSrcweir						$name = substr($name, 0, 4);	# name, offset, length
332cdf0e10cSrcweir						$name =~ s/\s*$//; # removing ending whitespaces
333cdf0e10cSrcweir						$name = $name . "\~";
334cdf0e10cSrcweir						($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
335cdf0e10cSrcweir
336cdf0e10cSrcweir						if ( ! $saved )
337cdf0e10cSrcweir						{
338cdf0e10cSrcweir							installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash");
339cdf0e10cSrcweir						}
340cdf0e10cSrcweir					}
341cdf0e10cSrcweir				}
342cdf0e10cSrcweir
343cdf0e10cSrcweir				$name = $name . "$number";
344cdf0e10cSrcweir				$changed = 1;
345cdf0e10cSrcweir			}
346cdf0e10cSrcweir		}
347cdf0e10cSrcweir
348cdf0e10cSrcweir		$conformstring = $name . "\." . $extension;
349cdf0e10cSrcweir
350cdf0e10cSrcweir		if ( $changed ) { $conformstring= uc($conformstring); }
351cdf0e10cSrcweir	}
352cdf0e10cSrcweir	else 		# no dot in filename or directory (also used for shortcuts)
353cdf0e10cSrcweir	{
354cdf0e10cSrcweir		$name = $inputstring;
355cdf0e10cSrcweir		$namelength = length($name);
356cdf0e10cSrcweir
357cdf0e10cSrcweir		if ( $namelength > 8 )
358cdf0e10cSrcweir		{
359cdf0e10cSrcweir			# taking the first six letters
360cdf0e10cSrcweir			$name = substr($name, 0, 6);	# name, offset, length
361cdf0e10cSrcweir			$name =~ s/\s*$//; # removing ending whitespaces
362cdf0e10cSrcweir			$name = $name . "\~";
363cdf0e10cSrcweir			( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
364cdf0e10cSrcweir
365cdf0e10cSrcweir			# if $number>9 the new name would be "abcdef~10", which is 9+0, and therefore not allowed
366cdf0e10cSrcweir
367cdf0e10cSrcweir			if ( ! $saved )
368cdf0e10cSrcweir			{
369cdf0e10cSrcweir				$name = substr($name, 0, 5);	# name, offset, length
370cdf0e10cSrcweir				$name =~ s/\s*$//; # removing ending whitespaces
371cdf0e10cSrcweir				$name = $name . "\~";
372cdf0e10cSrcweir				( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
373cdf0e10cSrcweir
374cdf0e10cSrcweir				# if $number>99 the new name would be "abcde~100", which is 9+0, and therefore not allowed
375cdf0e10cSrcweir
376cdf0e10cSrcweir				if ( ! $saved )
377cdf0e10cSrcweir				{
378cdf0e10cSrcweir					$name = substr($name, 0, 4);	# name, offset, length
379cdf0e10cSrcweir					$name =~ s/\s*$//; # removing ending whitespaces
380cdf0e10cSrcweir					$name = $name . "\~";
381cdf0e10cSrcweir					( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
382cdf0e10cSrcweir
383cdf0e10cSrcweir					if ( ! $saved ) { installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash"); }
384cdf0e10cSrcweir				}
385cdf0e10cSrcweir			}
386cdf0e10cSrcweir
387cdf0e10cSrcweir			$name = $name . "$number";
388cdf0e10cSrcweir			$changed = 1;
389cdf0e10cSrcweir			if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; }	# in directories replacing "." with "_"
390cdf0e10cSrcweir		}
391cdf0e10cSrcweir
392cdf0e10cSrcweir		$conformstring = $name;
393cdf0e10cSrcweir
394cdf0e10cSrcweir		if ( $changed ) { $conformstring = uc($name); }
395cdf0e10cSrcweir	}
396cdf0e10cSrcweir
397cdf0e10cSrcweir	return $conformstring;
398cdf0e10cSrcweir}
399cdf0e10cSrcweir
400cdf0e10cSrcweir#########################################
401cdf0e10cSrcweir# Writing the header for idt files
402cdf0e10cSrcweir#########################################
403cdf0e10cSrcweir
404cdf0e10cSrcweirsub write_idt_header
405cdf0e10cSrcweir{
406cdf0e10cSrcweir	my ($idtref, $definestring) = @_;
407cdf0e10cSrcweir
408cdf0e10cSrcweir	my $oneline;
409cdf0e10cSrcweir
410cdf0e10cSrcweir	if ( $definestring eq "file" )
411cdf0e10cSrcweir	{
412cdf0e10cSrcweir		$oneline = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n";
413cdf0e10cSrcweir		push(@{$idtref}, $oneline);
414cdf0e10cSrcweir		$oneline = "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n";
415cdf0e10cSrcweir		push(@{$idtref}, $oneline);
416cdf0e10cSrcweir		$oneline = "File\tFile\n";
417cdf0e10cSrcweir		push(@{$idtref}, $oneline);
418cdf0e10cSrcweir	}
419cdf0e10cSrcweir
420cdf0e10cSrcweir	if ( $definestring eq "filehash" )
421cdf0e10cSrcweir	{
422cdf0e10cSrcweir		$oneline = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n";
423cdf0e10cSrcweir		push(@{$idtref}, $oneline);
424cdf0e10cSrcweir		$oneline = "s72\ti2\ti4\ti4\ti4\ti4\n";
425cdf0e10cSrcweir		push(@{$idtref}, $oneline);
426cdf0e10cSrcweir		$oneline = "MsiFileHash\tFile_\n";
427cdf0e10cSrcweir		push(@{$idtref}, $oneline);
428cdf0e10cSrcweir	}
429cdf0e10cSrcweir
430cdf0e10cSrcweir	if ( $definestring eq "directory" )
431cdf0e10cSrcweir	{
432cdf0e10cSrcweir		$oneline = "Directory\tDirectory_Parent\tDefaultDir\n";
433cdf0e10cSrcweir		push(@{$idtref}, $oneline);
434cdf0e10cSrcweir		$oneline = "s72\tS72\tl255\n";
435cdf0e10cSrcweir		push(@{$idtref}, $oneline);
436cdf0e10cSrcweir		$oneline = "Directory\tDirectory\n";
437cdf0e10cSrcweir		push(@{$idtref}, $oneline);
438cdf0e10cSrcweir	}
439cdf0e10cSrcweir
440cdf0e10cSrcweir	if ( $definestring eq "component" )
441cdf0e10cSrcweir	{
442cdf0e10cSrcweir		$oneline = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n";
443cdf0e10cSrcweir		push(@{$idtref}, $oneline);
444cdf0e10cSrcweir		$oneline = "s72\tS38\ts72\ti2\tS255\tS72\n";
445cdf0e10cSrcweir		push(@{$idtref}, $oneline);
446cdf0e10cSrcweir		$oneline = "Component\tComponent\n";
447cdf0e10cSrcweir		push(@{$idtref}, $oneline);
448cdf0e10cSrcweir	}
449cdf0e10cSrcweir
450cdf0e10cSrcweir	if ( $definestring eq "feature" )
451cdf0e10cSrcweir	{
452cdf0e10cSrcweir		$oneline = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n";
453cdf0e10cSrcweir		push(@{$idtref}, $oneline);
454cdf0e10cSrcweir		$oneline = "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n";
455cdf0e10cSrcweir		push(@{$idtref}, $oneline);
456cdf0e10cSrcweir		$oneline = "WINDOWSENCODINGTEMPLATE\tFeature\tFeature\n";
457cdf0e10cSrcweir		push(@{$idtref}, $oneline);
458cdf0e10cSrcweir	}
459cdf0e10cSrcweir
460cdf0e10cSrcweir	if ( $definestring eq "featurecomponent" )
461cdf0e10cSrcweir	{
462cdf0e10cSrcweir		$oneline = "Feature_\tComponent_\n";
463cdf0e10cSrcweir		push(@{$idtref}, $oneline);
464cdf0e10cSrcweir		$oneline = "s38\ts72\n";
465cdf0e10cSrcweir		push(@{$idtref}, $oneline);
466cdf0e10cSrcweir		$oneline = "FeatureComponents\tFeature_\tComponent_\n";
467cdf0e10cSrcweir		push(@{$idtref}, $oneline);
468cdf0e10cSrcweir	}
469cdf0e10cSrcweir
470cdf0e10cSrcweir	if ( $definestring eq "media" )
471cdf0e10cSrcweir	{
472cdf0e10cSrcweir		$oneline = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n";
473cdf0e10cSrcweir		push(@{$idtref}, $oneline);
474cdf0e10cSrcweir		$oneline = "i2\ti2\tL64\tS255\tS32\tS72\n";
475cdf0e10cSrcweir		push(@{$idtref}, $oneline);
476cdf0e10cSrcweir		$oneline = "Media\tDiskId\n";
477cdf0e10cSrcweir		push(@{$idtref}, $oneline);
478cdf0e10cSrcweir	}
479cdf0e10cSrcweir
480cdf0e10cSrcweir	if ( $definestring eq "font" )
481cdf0e10cSrcweir	{
482cdf0e10cSrcweir		$oneline = "File_\tFontTitle\n";
483cdf0e10cSrcweir		push(@{$idtref}, $oneline);
484cdf0e10cSrcweir		$oneline = "s72\tS128\n";
485cdf0e10cSrcweir		push(@{$idtref}, $oneline);
486cdf0e10cSrcweir		$oneline = "Font\tFile_\n";
487cdf0e10cSrcweir		push(@{$idtref}, $oneline);
488cdf0e10cSrcweir	}
489cdf0e10cSrcweir
490cdf0e10cSrcweir	if ( $definestring eq "shortcut" )
491cdf0e10cSrcweir	{
492cdf0e10cSrcweir		$oneline = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n";
493cdf0e10cSrcweir		push(@{$idtref}, $oneline);
494cdf0e10cSrcweir		$oneline = "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n";
495cdf0e10cSrcweir		push(@{$idtref}, $oneline);
496cdf0e10cSrcweir		$oneline = "WINDOWSENCODINGTEMPLATE\tShortcut\tShortcut\n";
497cdf0e10cSrcweir		push(@{$idtref}, $oneline);
498cdf0e10cSrcweir	}
499cdf0e10cSrcweir
500cdf0e10cSrcweir	if ( $definestring eq "registry" )
501cdf0e10cSrcweir	{
502cdf0e10cSrcweir		$oneline = "Registry\tRoot\tKey\tName\tValue\tComponent_\n";
503cdf0e10cSrcweir		push(@{$idtref}, $oneline);
504cdf0e10cSrcweir		$oneline = "s72\ti2\tl255\tL255\tL0\ts72\n";
505cdf0e10cSrcweir		push(@{$idtref}, $oneline);
506cdf0e10cSrcweir		$oneline = "Registry\tRegistry\n";
507cdf0e10cSrcweir		push(@{$idtref}, $oneline);
508cdf0e10cSrcweir	}
509cdf0e10cSrcweir
510cdf0e10cSrcweir	if ( $definestring eq "reg64" )
511cdf0e10cSrcweir	{
512cdf0e10cSrcweir		$oneline = "Registry\tRoot\tKey\tName\tValue\tComponent_\n";
513cdf0e10cSrcweir		push(@{$idtref}, $oneline);
514cdf0e10cSrcweir		$oneline = "s72\ti2\tl255\tL255\tL0\ts72\n";
515cdf0e10cSrcweir		push(@{$idtref}, $oneline);
516cdf0e10cSrcweir		$oneline = "Reg64\tRegistry\n";
517cdf0e10cSrcweir		push(@{$idtref}, $oneline);
518cdf0e10cSrcweir	}
519cdf0e10cSrcweir
520cdf0e10cSrcweir	if ( $definestring eq "createfolder" )
521cdf0e10cSrcweir	{
522cdf0e10cSrcweir		$oneline = "Directory_\tComponent_\n";
523cdf0e10cSrcweir		push(@{$idtref}, $oneline);
524cdf0e10cSrcweir		$oneline = "s72\ts72\n";
525cdf0e10cSrcweir		push(@{$idtref}, $oneline);
526cdf0e10cSrcweir		$oneline = "CreateFolder\tDirectory_\tComponent_\n";
527cdf0e10cSrcweir		push(@{$idtref}, $oneline);
528cdf0e10cSrcweir	}
529cdf0e10cSrcweir
530cdf0e10cSrcweir	if ( $definestring eq "removefile" )
531cdf0e10cSrcweir	{
532cdf0e10cSrcweir		$oneline = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n";
533cdf0e10cSrcweir		push(@{$idtref}, $oneline);
534cdf0e10cSrcweir		$oneline = "s72\ts72\tL255\ts72\ti2\n";
535cdf0e10cSrcweir		push(@{$idtref}, $oneline);
536cdf0e10cSrcweir		$oneline = "RemoveFile\tFileKey\n";
537cdf0e10cSrcweir		push(@{$idtref}, $oneline);
538cdf0e10cSrcweir	}
539cdf0e10cSrcweir
540cdf0e10cSrcweir	if ( $definestring eq "upgrade" )
541cdf0e10cSrcweir	{
542cdf0e10cSrcweir		$oneline = "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n";
543cdf0e10cSrcweir		push(@{$idtref}, $oneline);
544cdf0e10cSrcweir		$oneline = "s38\tS20\tS20\tS255\ti4\tS255\ts72\n";
545cdf0e10cSrcweir		push(@{$idtref}, $oneline);
546cdf0e10cSrcweir		$oneline = "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n";
547cdf0e10cSrcweir		push(@{$idtref}, $oneline);
548cdf0e10cSrcweir	}
549cdf0e10cSrcweir
550cdf0e10cSrcweir	if ( $definestring eq "icon" )
551cdf0e10cSrcweir	{
552cdf0e10cSrcweir		$oneline = "Name\tData\n";
553cdf0e10cSrcweir		push(@{$idtref}, $oneline);
554cdf0e10cSrcweir		$oneline = "s72\tv0\n";
555cdf0e10cSrcweir		push(@{$idtref}, $oneline);
556cdf0e10cSrcweir		$oneline = "Icon\tName\n";
557cdf0e10cSrcweir		push(@{$idtref}, $oneline);
558cdf0e10cSrcweir	}
559cdf0e10cSrcweir
560cdf0e10cSrcweir	if ( $definestring eq "inifile" )
561cdf0e10cSrcweir	{
562cdf0e10cSrcweir		$oneline = "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n";
563cdf0e10cSrcweir		push(@{$idtref}, $oneline);
564cdf0e10cSrcweir		$oneline = "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n";
565cdf0e10cSrcweir		push(@{$idtref}, $oneline);
566cdf0e10cSrcweir		$oneline = "IniFile\tIniFile\n";
567cdf0e10cSrcweir		push(@{$idtref}, $oneline);
568cdf0e10cSrcweir	}
569cdf0e10cSrcweir
570cdf0e10cSrcweir	if ( $definestring eq "selfreg" )
571cdf0e10cSrcweir	{
572cdf0e10cSrcweir		$oneline = "File_\tCost\n";
573cdf0e10cSrcweir		push(@{$idtref}, $oneline);
574cdf0e10cSrcweir		$oneline = "s72\tI2\n";
575cdf0e10cSrcweir		push(@{$idtref}, $oneline);
576cdf0e10cSrcweir		$oneline = "SelfReg\tFile_\n";
577cdf0e10cSrcweir		push(@{$idtref}, $oneline);
578cdf0e10cSrcweir	}
579cdf0e10cSrcweir
580cdf0e10cSrcweir	if ( $definestring eq "msiassembly" )
581cdf0e10cSrcweir	{
582cdf0e10cSrcweir		$oneline = "Component_\tFeature_\tFile_Manifest\tFile_Application\tAttributes\n";
583cdf0e10cSrcweir		push(@{$idtref}, $oneline);
584cdf0e10cSrcweir		$oneline = "s72\ts38\tS72\tS72\tI2\n";
585cdf0e10cSrcweir		push(@{$idtref}, $oneline);
586cdf0e10cSrcweir		$oneline = "MsiAssembly\tComponent_\n";
587cdf0e10cSrcweir		push(@{$idtref}, $oneline);
588cdf0e10cSrcweir	}
589cdf0e10cSrcweir
590cdf0e10cSrcweir	if ( $definestring eq "msiassemblyname" )
591cdf0e10cSrcweir	{
592cdf0e10cSrcweir		$oneline = "Component_\tName\tValue\n";
593cdf0e10cSrcweir		push(@{$idtref}, $oneline);
594cdf0e10cSrcweir		$oneline = "s72\ts255\ts255\n";
595cdf0e10cSrcweir		push(@{$idtref}, $oneline);
596cdf0e10cSrcweir		$oneline = "MsiAssemblyName\tComponent_\tName\n";
597cdf0e10cSrcweir		push(@{$idtref}, $oneline);
598cdf0e10cSrcweir	}
599cdf0e10cSrcweir
600cdf0e10cSrcweir	if ( $definestring eq "appsearch" )
601cdf0e10cSrcweir	{
602cdf0e10cSrcweir		$oneline = "Property\tSignature_\n";
603cdf0e10cSrcweir		push(@{$idtref}, $oneline);
604cdf0e10cSrcweir		$oneline = "s72\ts72\n";
605cdf0e10cSrcweir		push(@{$idtref}, $oneline);
606cdf0e10cSrcweir		$oneline = "AppSearch\tProperty\tSignature_\n";
607cdf0e10cSrcweir		push(@{$idtref}, $oneline);
608cdf0e10cSrcweir	}
609cdf0e10cSrcweir
610cdf0e10cSrcweir	if ( $definestring eq "reglocat" )
611cdf0e10cSrcweir	{
612cdf0e10cSrcweir		$oneline = "Signature_\tRoot\tKey\tName\tType\n";
613cdf0e10cSrcweir		push(@{$idtref}, $oneline);
614cdf0e10cSrcweir		$oneline = "s72\ti2\ts255\tS255\tI2\n";
615cdf0e10cSrcweir		push(@{$idtref}, $oneline);
616cdf0e10cSrcweir		$oneline = "RegLocator\tSignature_\n";
617cdf0e10cSrcweir		push(@{$idtref}, $oneline);
618cdf0e10cSrcweir	}
619cdf0e10cSrcweir
620cdf0e10cSrcweir	if ( $definestring eq "signatur" )
621cdf0e10cSrcweir	{
622cdf0e10cSrcweir		$oneline = "Signature\tFileName\tMinVersion\tMaxVersion\tMinSize\tMaxSize\tMinDate\tMaxDate\tLanguages\n";
623cdf0e10cSrcweir		push(@{$idtref}, $oneline);
624cdf0e10cSrcweir		$oneline = "s72\ts255\tS20\tS20\tI4\tI4\tI4\tI4\tS255\n";
625cdf0e10cSrcweir		push(@{$idtref}, $oneline);
626cdf0e10cSrcweir		$oneline = "Signature\tSignature\n";
627cdf0e10cSrcweir		push(@{$idtref}, $oneline);
628cdf0e10cSrcweir	}
629cdf0e10cSrcweir
630cdf0e10cSrcweir}
631cdf0e10cSrcweir
632cdf0e10cSrcweir##############################################################
633cdf0e10cSrcweir# Returning the name of the rranslation file for a
634cdf0e10cSrcweir# given language.
635cdf0e10cSrcweir# Sample: "01" oder "en-US" -> "1033.txt"
636cdf0e10cSrcweir##############################################################
637cdf0e10cSrcweir
638cdf0e10cSrcweirsub get_languagefilename
639cdf0e10cSrcweir{
640cdf0e10cSrcweir	my ($idtfilename, $basedir) = @_;
641cdf0e10cSrcweir
642cdf0e10cSrcweir	# $idtfilename =~ s/\.idt/\.ulf/;
643cdf0e10cSrcweir	$idtfilename =~ s/\.idt/\.mlf/;
644cdf0e10cSrcweir
645cdf0e10cSrcweir	my $languagefilename = $basedir . $installer::globals::separator . $idtfilename;
646cdf0e10cSrcweir
647cdf0e10cSrcweir	return $languagefilename;
648cdf0e10cSrcweir}
649cdf0e10cSrcweir
650cdf0e10cSrcweir##############################################################
651cdf0e10cSrcweir# Returning the complete block in all languages
652cdf0e10cSrcweir# for a specified string
653cdf0e10cSrcweir##############################################################
654cdf0e10cSrcweir
655cdf0e10cSrcweirsub get_language_block_from_language_file
656cdf0e10cSrcweir{
657cdf0e10cSrcweir	my ($searchstring, $languagefile) = @_;
658cdf0e10cSrcweir
659cdf0e10cSrcweir	my @language_block = ();
660cdf0e10cSrcweir
661cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
662cdf0e10cSrcweir	{
663cdf0e10cSrcweir		if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
664cdf0e10cSrcweir		{
665cdf0e10cSrcweir			my $counter = $i;
666cdf0e10cSrcweir
667cdf0e10cSrcweir			push(@language_block, ${$languagefile}[$counter]);
668cdf0e10cSrcweir			$counter++;
669cdf0e10cSrcweir
670cdf0e10cSrcweir			while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
671cdf0e10cSrcweir			{
672cdf0e10cSrcweir				push(@language_block, ${$languagefile}[$counter]);
673cdf0e10cSrcweir				$counter++;
674cdf0e10cSrcweir			}
675cdf0e10cSrcweir
676cdf0e10cSrcweir			last;
677cdf0e10cSrcweir		}
678cdf0e10cSrcweir	}
679cdf0e10cSrcweir
680cdf0e10cSrcweir	return \@language_block;
681cdf0e10cSrcweir}
682cdf0e10cSrcweir
683cdf0e10cSrcweir##############################################################
684cdf0e10cSrcweir# Returning a specific language string from the block
685cdf0e10cSrcweir# of all translations
686cdf0e10cSrcweir##############################################################
687cdf0e10cSrcweir
688cdf0e10cSrcweirsub get_language_string_from_language_block
689cdf0e10cSrcweir{
690cdf0e10cSrcweir	my ($language_block, $language, $oldstring) = @_;
691cdf0e10cSrcweir
692cdf0e10cSrcweir	my $newstring = "";
693cdf0e10cSrcweir
694cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$language_block}; $i++ )
695cdf0e10cSrcweir	{
696cdf0e10cSrcweir		if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
697cdf0e10cSrcweir		{
698cdf0e10cSrcweir			$newstring = $1;
699cdf0e10cSrcweir			last;
700cdf0e10cSrcweir		}
701cdf0e10cSrcweir	}
702cdf0e10cSrcweir
703cdf0e10cSrcweir	if ( $newstring eq "" )
704cdf0e10cSrcweir	{
705cdf0e10cSrcweir		$language = "en-US"; 	# defaulting to english
706cdf0e10cSrcweir
707cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$language_block}; $i++ )
708cdf0e10cSrcweir		{
709cdf0e10cSrcweir			if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
710cdf0e10cSrcweir			{
711cdf0e10cSrcweir				$newstring = $1;
712cdf0e10cSrcweir				last;
713cdf0e10cSrcweir			}
714cdf0e10cSrcweir		}
715cdf0e10cSrcweir	}
716cdf0e10cSrcweir
717cdf0e10cSrcweir	return $newstring;
718cdf0e10cSrcweir}
719cdf0e10cSrcweir
720cdf0e10cSrcweir##############################################################
721cdf0e10cSrcweir# Returning a specific code from the block
722cdf0e10cSrcweir# of all codes. No defaulting to english!
723cdf0e10cSrcweir##############################################################
724cdf0e10cSrcweir
725cdf0e10cSrcweirsub get_code_from_code_block
726cdf0e10cSrcweir{
727cdf0e10cSrcweir	my ($codeblock, $language) = @_;
728cdf0e10cSrcweir
729cdf0e10cSrcweir	my $newstring = "";
730cdf0e10cSrcweir
731cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$codeblock}; $i++ )
732cdf0e10cSrcweir	{
733cdf0e10cSrcweir		if ( ${$codeblock}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
734cdf0e10cSrcweir		{
735cdf0e10cSrcweir			$newstring = $1;
736cdf0e10cSrcweir			last;
737cdf0e10cSrcweir		}
738cdf0e10cSrcweir	}
739cdf0e10cSrcweir
740cdf0e10cSrcweir	return $newstring;
741cdf0e10cSrcweir}
742cdf0e10cSrcweir
743cdf0e10cSrcweir##############################################################
744cdf0e10cSrcweir# Translating an idt file
745cdf0e10cSrcweir##############################################################
746cdf0e10cSrcweir
747cdf0e10cSrcweirsub translate_idtfile
748cdf0e10cSrcweir{
749cdf0e10cSrcweir	my ($idtfile, $languagefile, $onelanguage) = @_;
750cdf0e10cSrcweir
751cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$idtfile}; $i++ )
752cdf0e10cSrcweir	{
753cdf0e10cSrcweir		my @allstrings = ();
754cdf0e10cSrcweir
755cdf0e10cSrcweir		my $oneline = ${$idtfile}[$i];
756cdf0e10cSrcweir
757cdf0e10cSrcweir		while ( $oneline =~ /\b(OOO_\w+)\b/ )
758cdf0e10cSrcweir		{
759cdf0e10cSrcweir			my $replacestring = $1;
760cdf0e10cSrcweir			push(@allstrings, $replacestring);
761cdf0e10cSrcweir			$oneline =~ s/$replacestring//;
762cdf0e10cSrcweir		}
763cdf0e10cSrcweir
764cdf0e10cSrcweir		my $oldstring;
765cdf0e10cSrcweir
766cdf0e10cSrcweir		foreach $oldstring (@allstrings)
767cdf0e10cSrcweir		{
768cdf0e10cSrcweir			my $language_block = get_language_block_from_language_file($oldstring, $languagefile);
769cdf0e10cSrcweir			my $newstring = get_language_string_from_language_block($language_block, $onelanguage, $oldstring);
770cdf0e10cSrcweir
771cdf0e10cSrcweir			# if (!( $newstring eq "" )) { ${$idtfile}[$i] =~ s/$oldstring/$newstring/; }
772cdf0e10cSrcweir			${$idtfile}[$i] =~ s/$oldstring/$newstring/;	# always substitute, even if $newstring eq "" (there are empty strings for control.idt)
773cdf0e10cSrcweir		}
774cdf0e10cSrcweir	}
775cdf0e10cSrcweir}
776cdf0e10cSrcweir
777cdf0e10cSrcweir##############################################################
778cdf0e10cSrcweir# Copying all needed files to create a msi database
779cdf0e10cSrcweir# into one language specific directory
780cdf0e10cSrcweir##############################################################
781cdf0e10cSrcweir
782*04be0b07SAndre Fischersub prepare_language_idt_directory ($$$$$$$)
783cdf0e10cSrcweir{
784cdf0e10cSrcweir	my ($destinationdir, $newidtdir, $onelanguage, $filesref, $iconfilecollector, $binarytablefiles, $allvariables) = @_;
785cdf0e10cSrcweir
786cdf0e10cSrcweir	# Copying all idt-files from the source $installer::globals::idttemplatepath to the destination $destinationdir
787cdf0e10cSrcweir	# Copying all files in the subdirectory "Binary"
788cdf0e10cSrcweir	# Copying all files in the subdirectory "Icon"
789cdf0e10cSrcweir
790cdf0e10cSrcweir	my $infoline = "";
791cdf0e10cSrcweir
792cdf0e10cSrcweir	installer::systemactions::copy_directory($installer::globals::idttemplatepath, $destinationdir);
793cdf0e10cSrcweir
794cdf0e10cSrcweir	if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Binary")
795cdf0e10cSrcweir	{
796cdf0e10cSrcweir		installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Binary");
797*04be0b07SAndre Fischer		installer::systemactions::copy_directory(
798*04be0b07SAndre Fischer            $installer::globals::idttemplatepath . $installer::globals::separator . "Binary",
799*04be0b07SAndre Fischer            $destinationdir . $installer::globals::separator . "Binary");
800cdf0e10cSrcweir
801cdf0e10cSrcweir		if ((( $installer::globals::patch ) && ( $allvariables->{'WINDOWSPATCHBITMAPDIRECTORY'} )) || ( $allvariables->{'WINDOWSBITMAPDIRECTORY'} ))
802cdf0e10cSrcweir		{
803cdf0e10cSrcweir			my $bitmapdir = "";
804*04be0b07SAndre Fischer			if ( $allvariables->{'WINDOWSPATCHBITMAPDIRECTORY'} )
805*04be0b07SAndre Fischer            {
806*04be0b07SAndre Fischer                $bitmapdir = $allvariables->{'WINDOWSPATCHBITMAPDIRECTORY'};
807*04be0b07SAndre Fischer            }
808*04be0b07SAndre Fischer			if ( $allvariables->{'WINDOWSBITMAPDIRECTORY'} )
809*04be0b07SAndre Fischer            {
810*04be0b07SAndre Fischer                $bitmapdir = $allvariables->{'WINDOWSBITMAPDIRECTORY'};
811*04be0b07SAndre Fischer            }
812cdf0e10cSrcweir
813cdf0e10cSrcweir			my $newsourcedir = $installer::globals::unpackpath . $installer::globals::separator . $bitmapdir; # path setting in list file dependent from unpackpath !?
814b274bc22SAndre Fischer            $installer::logger::Lang->printf("\n");
815b274bc22SAndre Fischer            $installer::logger::Lang->printf(
816b274bc22SAndre Fischer                "Overwriting files in directory \"%s%sBinary\" with files from directory \"%s\".\n",
817b274bc22SAndre Fischer                $destinationdir,
818b274bc22SAndre Fischer                $installer::globals::separator,
819b274bc22SAndre Fischer                $newsourcedir);
820cdf0e10cSrcweir			if ( ! -d $newsourcedir )
821cdf0e10cSrcweir			{
822cdf0e10cSrcweir				my $currentdir = cwd();
823*04be0b07SAndre Fischer				installer::exiter::exit_program(
824*04be0b07SAndre Fischer                    "ERROR: Directory $newsourcedir does not exist! Current directory is: $currentdir",
825*04be0b07SAndre Fischer                    "prepare_language_idt_directory");
826cdf0e10cSrcweir			}
827*04be0b07SAndre Fischer			installer::systemactions::copy_directory(
828*04be0b07SAndre Fischer                $newsourcedir,
829*04be0b07SAndre Fischer                $destinationdir . $installer::globals::separator . "Binary");
830cdf0e10cSrcweir		}
831cdf0e10cSrcweir	}
832cdf0e10cSrcweir
833cdf0e10cSrcweir	installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Icon");
834cdf0e10cSrcweir
835cdf0e10cSrcweir	if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Icon")
836cdf0e10cSrcweir	{
837*04be0b07SAndre Fischer		installer::systemactions::copy_directory(
838*04be0b07SAndre Fischer            $installer::globals::idttemplatepath . $installer::globals::separator . "Icon",
839*04be0b07SAndre Fischer            $destinationdir . $installer::globals::separator . "Icon");
840cdf0e10cSrcweir	}
841cdf0e10cSrcweir
842cdf0e10cSrcweir	# Copying all files in $iconfilecollector, that describe icons of folderitems
843cdf0e10cSrcweir
844cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$iconfilecollector}; $i++ )
845cdf0e10cSrcweir	{
846cdf0e10cSrcweir		my $iconfilename = ${$iconfilecollector}[$i];
847cdf0e10cSrcweir		installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$iconfilename);
848*04be0b07SAndre Fischer		installer::systemactions::copy_one_file(
849*04be0b07SAndre Fischer            ${$iconfilecollector}[$i],
850*04be0b07SAndre Fischer            $destinationdir . $installer::globals::separator . "Icon" . $installer::globals::separator . $iconfilename);
851cdf0e10cSrcweir	}
852cdf0e10cSrcweir
853cdf0e10cSrcweir	# Copying all files in $binarytablefiles in the binary directory
854cdf0e10cSrcweir
855*04be0b07SAndre Fischer	foreach my $binaryfile (@$binarytablefiles)
856cdf0e10cSrcweir	{
857cdf0e10cSrcweir		my $binaryfilepath = $binaryfile->{'sourcepath'};
858cdf0e10cSrcweir		my $binaryfilename = $binaryfilepath;
859*04be0b07SAndre Fischer        $installer::logger::Lang->printf("copying binary file %s to %s\n",
860*04be0b07SAndre Fischer            $binaryfilepath,
861*04be0b07SAndre Fischer            $binaryfilename);
862cdf0e10cSrcweir		installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$binaryfilename);
863*04be0b07SAndre Fischer		installer::systemactions::copy_one_file(
864*04be0b07SAndre Fischer            $binaryfilepath,
865*04be0b07SAndre Fischer            $destinationdir . $installer::globals::separator . "Binary" . $installer::globals::separator . $binaryfilename);
866cdf0e10cSrcweir	}
867cdf0e10cSrcweir
868cdf0e10cSrcweir	# Copying all new created and language independent idt-files to the destination $destinationdir.
869cdf0e10cSrcweir	# Example: "File.idt"
870cdf0e10cSrcweir
871cdf0e10cSrcweir	installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, "idt");
872cdf0e10cSrcweir
873cdf0e10cSrcweir	# Copying all new created and language dependent idt-files to the destination $destinationdir.
874cdf0e10cSrcweir	# Example: "Feature.idt.01"
875cdf0e10cSrcweir
876cdf0e10cSrcweir	installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, $onelanguage);
877cdf0e10cSrcweir	installer::systemactions::rename_files_with_fileextension($destinationdir, $onelanguage);
878cdf0e10cSrcweir
879cdf0e10cSrcweir}
880cdf0e10cSrcweir
881cdf0e10cSrcweir##############################################################
882cdf0e10cSrcweir# Returning the source path of the rtf licensefile for
883cdf0e10cSrcweir# a specified language
884cdf0e10cSrcweir##############################################################
885cdf0e10cSrcweir
886cdf0e10cSrcweirsub get_rtflicensefilesource
887cdf0e10cSrcweir{
888cdf0e10cSrcweir	my ($language, $includepatharrayref) = @_;
889cdf0e10cSrcweir
890cdf0e10cSrcweir	my $licensefilename = "license_" . $language . ".rtf";
891cdf0e10cSrcweir
892cdf0e10cSrcweir	my $sourcefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $includepatharrayref, 1);
893cdf0e10cSrcweir
894cdf0e10cSrcweir	if ($$sourcefileref eq "") { installer::exiter::exit_program("ERROR: Could not find $licensefilename!", "get_rtflicensefilesource"); }
895cdf0e10cSrcweir
896b274bc22SAndre Fischer    $installer::logger::Lang->printf("Using licensefile: %s\n", $$sourcefileref);
897cdf0e10cSrcweir
898cdf0e10cSrcweir	return $$sourcefileref;
899cdf0e10cSrcweir}
900cdf0e10cSrcweir
901cdf0e10cSrcweir##############################################################
902cdf0e10cSrcweir# Returning the source path of the licensefile for
903cdf0e10cSrcweir# a specified language
904cdf0e10cSrcweir##############################################################
905cdf0e10cSrcweir
906cdf0e10cSrcweirsub get_licensefilesource
907cdf0e10cSrcweir{
908cdf0e10cSrcweir	my ($language, $filesref) = @_;
909cdf0e10cSrcweir
910cdf0e10cSrcweir	my $licensefilename = "license_" . $language . ".txt";
911cdf0e10cSrcweir	my $sourcepath = "";
912cdf0e10cSrcweir	my $foundlicensefile = 0;
913cdf0e10cSrcweir
914cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
915cdf0e10cSrcweir	{
916cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
917cdf0e10cSrcweir		my $filename = $onefile->{'Name'};
918cdf0e10cSrcweir
919cdf0e10cSrcweir		if ($filename eq $licensefilename)
920cdf0e10cSrcweir		{
921cdf0e10cSrcweir			$sourcepath = $onefile->{'sourcepath'};
922cdf0e10cSrcweir			$foundlicensefile = 1;
923cdf0e10cSrcweir			last;
924cdf0e10cSrcweir		}
925cdf0e10cSrcweir	}
926cdf0e10cSrcweir
927cdf0e10cSrcweir	if ( ! $foundlicensefile ) { installer::exiter::exit_program("ERROR: Did not find file $licensefilename in file collector!", "get_licensefilesource"); }
928cdf0e10cSrcweir
929cdf0e10cSrcweir	return $sourcepath;
930cdf0e10cSrcweir}
931cdf0e10cSrcweir
932cdf0e10cSrcweir##############################################################
933cdf0e10cSrcweir# A simple converter to create the license text
934cdf0e10cSrcweir# in rtf format
935cdf0e10cSrcweir##############################################################
936cdf0e10cSrcweir
937cdf0e10cSrcweirsub get_rtf_licensetext
938cdf0e10cSrcweir{
939cdf0e10cSrcweir	my ($licensefile) = @_;
940cdf0e10cSrcweir
941cdf0e10cSrcweir	# A very simple rtf converter
942cdf0e10cSrcweir
943cdf0e10cSrcweir	# The static header
944cdf0e10cSrcweir
945cdf0e10cSrcweir	my $rtf_licensetext = '{\rtf1\ansi\deff0';
946cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}';
947cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red128\green128\blue128;}';
948cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\stylesheet{\s1\snext1 Standard;}}';
949cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\info{\comment StarWriter}{\vern5690}}\deftab709';
950cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\*\pgdsctbl';
951cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '{\pgdsc0\pgdscuse195\pgwsxn11905\pghsxn16837\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}';
952cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '\paperh16837\paperw11905\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn11905\pghsxn16837\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc';
953cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '\pard\plain \s1';
954cdf0e10cSrcweir
955cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
956cdf0e10cSrcweir	{
957cdf0e10cSrcweir		my $oneline = ${$licensefile}[$i];
958cdf0e10cSrcweir		# if  ( $oneline =~ /^\s*$/ ) { $oneline = '\par'; }	# empty lines
959cdf0e10cSrcweir
960cdf0e10cSrcweir		if ( $i == 0 ) { $oneline =~ s/^\W*//; }
961cdf0e10cSrcweir
962cdf0e10cSrcweir		$oneline =~ s/\t/    /g;		# no tabs allowed, converting to four spaces
963cdf0e10cSrcweir		$oneline =~ s/\n$//g;			# no newline at line end
964cdf0e10cSrcweir
965cdf0e10cSrcweir#		$oneline =~ s/�/\\\'e4/g;			# converting "�"
966cdf0e10cSrcweir#		$oneline =~ s/�/\\\'f6/g;			# converting "�"
967cdf0e10cSrcweir#		$oneline =~ s/�/\\\'fc/g;			# converting "�"
968cdf0e10cSrcweir#		$oneline =~ s/�/\\\'df/g;			# converting "�"
969cdf0e10cSrcweir
970cdf0e10cSrcweir		# german replacements
971cdf0e10cSrcweir
972cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'c4/g;		# converting "�"
973cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'d6/g;		# converting "�"
974cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'dc/g;		# converting "�"
975cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'e4/g;		# converting "�"
976cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'f6/g;		# converting "�"
977cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'fc/g;		# converting "�"
978cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'df/g;		# converting "�"
979cdf0e10cSrcweir
980cdf0e10cSrcweir		# french replacements
981cdf0e10cSrcweir
982cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'c9/g;
983cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'c0/g;
984cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'ab/g;
985cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'bb/g;
986cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'e9/g;
987cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'e8/g;
988cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'e0/g;
989cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'f4/g;
990cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'e7/g;
991cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'ea/g;
992cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'ca/g;
993cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'fb/g;
994cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'f9/g;
995cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\'ee/g;
996cdf0e10cSrcweir
997cdf0e10cSrcweir		# quotation marks
998cdf0e10cSrcweir
999cdf0e10cSrcweir		$oneline =~ s/\�\�\�/\\\'84/g;
1000cdf0e10cSrcweir		$oneline =~ s/\�\�\�/\\ldblquote/g;
1001cdf0e10cSrcweir		$oneline =~ s/\�\�\�/\\rquote/g;
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir		$oneline =~ s/\�\�/\\\~/g;
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir		$oneline = '\par ' . $oneline;
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir		$rtf_licensetext = $rtf_licensetext .  $oneline;
1009cdf0e10cSrcweir	}
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir	# and the end
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir	$rtf_licensetext = $rtf_licensetext . '\par \par }';
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir	return $rtf_licensetext;
1016cdf0e10cSrcweir}
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir##############################################################
1019cdf0e10cSrcweir# A simple converter to create a license txt string from
1020cdf0e10cSrcweir# the rtf format
1021cdf0e10cSrcweir##############################################################
1022cdf0e10cSrcweir
1023cdf0e10cSrcweirsub make_string_licensetext
1024cdf0e10cSrcweir{
1025cdf0e10cSrcweir	my ($licensefile) = @_;
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir	my $rtf_licensetext = "";
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
1030cdf0e10cSrcweir	{
1031cdf0e10cSrcweir		my $oneline = ${$licensefile}[$i];
1032cdf0e10cSrcweir		$oneline =~ s/\s*$//g;		# no whitespace at line end
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir		$rtf_licensetext = $rtf_licensetext .  $oneline . " ";
1035cdf0e10cSrcweir	}
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir	return $rtf_licensetext;
1038cdf0e10cSrcweir}
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir##############################################################
1041cdf0e10cSrcweir# Setting the path, where the soffice.exe is installed, into
1042cdf0e10cSrcweir# the CustomAction table
1043cdf0e10cSrcweir##############################################################
1044cdf0e10cSrcweir
1045cdf0e10cSrcweirsub add_officedir_to_database
1046cdf0e10cSrcweir{
1047cdf0e10cSrcweir	my ($basedir, $allvariables) = @_;
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir	my $customactionfilename = $basedir . $installer::globals::separator . "CustomAc.idt";
1050cdf0e10cSrcweir
1051cdf0e10cSrcweir	my $customacfile = installer::files::read_file($customactionfilename);
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir	my $found = 0;
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir	# Updating the values
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir	if ( $installer::globals::officeinstalldirectoryset )
1058cdf0e10cSrcweir	{
1059cdf0e10cSrcweir		$found = 0;
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$customacfile}; $i++ )
1062cdf0e10cSrcweir		{
1063cdf0e10cSrcweir			if ( ${$customacfile}[$i] =~ /\bOFFICEDIRECTORYGID\b/ )
1064cdf0e10cSrcweir			{
1065cdf0e10cSrcweir				${$customacfile}[$i] =~ s/\bOFFICEDIRECTORYGID\b/$installer::globals::officeinstalldirectory/;
1066cdf0e10cSrcweir				$found = 1;
1067cdf0e10cSrcweir			}
1068cdf0e10cSrcweir		}
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir		if (( ! $found ) && ( ! $allvariables->{'IGNOREDIRECTORYLAYER'} ))
1071cdf0e10cSrcweir		{
1072cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: \"OFFICEDIRECTORYGID\" not found in \"$customactionfilename\" !", "add_officedir_to_database");
1073cdf0e10cSrcweir		}
1074cdf0e10cSrcweir	}
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir	# Saving the file
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir	installer::files::save_file($customactionfilename ,$customacfile);
1079cdf0e10cSrcweir	my $infoline = "Updated idt file: $customactionfilename\n";
1080b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir}
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir##############################################################
1085cdf0e10cSrcweir# Including the license text into the table control.idt
1086cdf0e10cSrcweir##############################################################
1087cdf0e10cSrcweir
1088cdf0e10cSrcweirsub add_licensefile_to_database
1089cdf0e10cSrcweir{
1090cdf0e10cSrcweir	my ($licensefile, $controltable) = @_;
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir	# Nine tabs before the license text and two tabs after it
1093cdf0e10cSrcweir	# The license text has to be included into the dialog
1094cdf0e10cSrcweir	# LicenseAgreement into the control Memo.
1095cdf0e10cSrcweir
1096cdf0e10cSrcweir	my $foundlicenseline = 0;
1097cdf0e10cSrcweir	my ($number, $line);
1098cdf0e10cSrcweir
1099cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$controltable}; $i++ )
1100cdf0e10cSrcweir	{
1101cdf0e10cSrcweir		$line = ${$controltable}[$i];
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir		if ( $line =~ /^\s*\bLicenseAgreement\b\t\bMemo\t/ )
1104cdf0e10cSrcweir		{
1105cdf0e10cSrcweir			$foundlicenseline = 1;
1106cdf0e10cSrcweir			$number = $i;
1107cdf0e10cSrcweir			last;
1108cdf0e10cSrcweir		}
1109cdf0e10cSrcweir	}
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir	if (!($foundlicenseline))
1112cdf0e10cSrcweir	{
1113cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Line for license file in Control.idt not found!", "add_licensefile_to_database");
1114cdf0e10cSrcweir	}
1115cdf0e10cSrcweir	else
1116cdf0e10cSrcweir	{
1117cdf0e10cSrcweir		my %control = ();
1118cdf0e10cSrcweir
1119cdf0e10cSrcweir		if ( $line =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1120cdf0e10cSrcweir		{
1121cdf0e10cSrcweir			$control{'Dialog_'} = $1;
1122cdf0e10cSrcweir			$control{'Control'} = $2;
1123cdf0e10cSrcweir			$control{'Type'} = $3;
1124cdf0e10cSrcweir			$control{'X'} = $4;
1125cdf0e10cSrcweir			$control{'Y'} = $5;
1126cdf0e10cSrcweir			$control{'Width'} = $6;
1127cdf0e10cSrcweir			$control{'Height'} = $7;
1128cdf0e10cSrcweir			$control{'Attributes'} = $8;
1129cdf0e10cSrcweir			$control{'Property'} = $9;
1130cdf0e10cSrcweir			$control{'Text'} = $10;
1131cdf0e10cSrcweir			$control{'Control_Next'} = $11;
1132cdf0e10cSrcweir			$control{'Help'} = $12;
1133cdf0e10cSrcweir		}
1134cdf0e10cSrcweir		else
1135cdf0e10cSrcweir		{
1136cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: Could not split line correctly!", "add_licensefile_to_database");
1137cdf0e10cSrcweir		}
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir		# my $licensetext = get_rtf_licensetext($licensefile);
1140cdf0e10cSrcweir		my $licensetext = make_string_licensetext($licensefile);
1141cdf0e10cSrcweir
1142cdf0e10cSrcweir		$control{'Text'} = $licensetext;
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir		my $newline = $control{'Dialog_'} . "\t" . $control{'Control'} . "\t" . $control{'Type'} . "\t" .
1145cdf0e10cSrcweir						$control{'X'} . "\t" . $control{'Y'} . "\t" . $control{'Width'} . "\t" .
1146cdf0e10cSrcweir						$control{'Height'} . "\t" . $control{'Attributes'} . "\t" . $control{'Property'} . "\t" .
1147cdf0e10cSrcweir						$control{'Text'} . "\t" . $control{'Control_Next'} . "\t" . $control{'Help'} . "\n";
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir		${$controltable}[$number] = $newline
1150cdf0e10cSrcweir	}
1151cdf0e10cSrcweir}
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir################################################################################################
1154cdf0e10cSrcweir# Including the checkboxes for the language selection dialog
1155cdf0e10cSrcweir# into the table control.idt . This is only relevant for
1156cdf0e10cSrcweir# multilingual installation sets.
1157cdf0e10cSrcweir#
1158cdf0e10cSrcweir# old:
1159cdf0e10cSrcweir# LanguageSelection	CheckBox1	CheckBox	22	60	15	24	3	IS1033		CheckBox2
1160cdf0e10cSrcweir# LanguageSelection	Text1	Text	40	60	70	15	65539		OOO_CONTROL_LANG_1033
1161cdf0e10cSrcweir# LanguageSelection	CheckBox2	CheckBox	22	90	15	24	3	IS1031		Next
1162cdf0e10cSrcweir# LanguageSelection	Text2	Text	40	90	70	15	65539		OOO_CONTROL_LANG_1031
1163cdf0e10cSrcweir# new:
1164cdf0e10cSrcweir# LanguageSelection	CheckBox1	CheckBox	22	60	15	24	3	IS1033	Text	CheckBox2
1165cdf0e10cSrcweir# LanguageSelection	CheckBox2	CheckBox	22	90	15	24	3	IS1031	Text	Next
1166cdf0e10cSrcweir################################################################################################
1167cdf0e10cSrcweir
1168cdf0e10cSrcweirsub add_language_checkboxes_to_database
1169cdf0e10cSrcweir{
1170cdf0e10cSrcweir	my ($controltable, $languagesarrayref) = @_;
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir	# for each language, two lines have to be inserted
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1175cdf0e10cSrcweir	{
1176cdf0e10cSrcweir		my $last = 0;
1177cdf0e10cSrcweir		if ( $i == $#{$languagesarrayref} ) { $last = 1; }		# special handling for the last
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir		my $onelanguage = ${$languagesarrayref}[$i];
1180cdf0e10cSrcweir		my $windowslanguage = installer::windows::language::get_windows_language($onelanguage);
1181cdf0e10cSrcweir
1182cdf0e10cSrcweir		# my $is_english = 0;
1183cdf0e10cSrcweir		# if ( $windowslanguage eq "1033" ) { $is_english = 1; }
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir		my $checkboxattribute = "3";
1186cdf0e10cSrcweir		# if ( $is_english ) { $checkboxattribute = "1"; }	# english is not deselectable
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir		my $count = $i + 1;
1189cdf0e10cSrcweir		my $nextcount = $i + 2;
1190cdf0e10cSrcweir		my $checkboxcount = "CheckBox" . $count;
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir		my $multiplier = 20;
1193cdf0e10cSrcweir		my $offset = 60;
1194cdf0e10cSrcweir		if ( $#{$languagesarrayref} > 7 )
1195cdf0e10cSrcweir		{
1196cdf0e10cSrcweir			$multiplier = 15;	# smaller differences for more than 7 languages
1197cdf0e10cSrcweir			$offset = 50;		# smaller offset for more than 7 languages
1198cdf0e10cSrcweir		}
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir		my $yvalue = $offset + $i * $multiplier;
1201cdf0e10cSrcweir
1202cdf0e10cSrcweir		my $property = "IS" . $windowslanguage;
1203cdf0e10cSrcweir	#	if ( ! exists($installer::globals::languageproperties{$property}) ) { installer::exiter::exit_program("ERROR: Could not find property \"$property\" in the list of language properties!", "add_language_checkboxes_to_database"); }
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir		my $controlnext = "";
1206cdf0e10cSrcweir		if ( $last ) { $controlnext = "Next"; }
1207cdf0e10cSrcweir		else { $controlnext = "CheckBox" . $nextcount; }
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir		my $stringname = "OOO_CONTROL_LANG_" . $windowslanguage;
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir		my $line1 = "LanguageSelection" . "\t" . $checkboxcount . "\t" . "CheckBox" . "\t" .
1212cdf0e10cSrcweir					"22" . "\t" . $yvalue . "\t" . "200" . "\t" . "15" . "\t" . $checkboxattribute . "\t" .
1213cdf0e10cSrcweir					$property . "\t" . $stringname . "\t" . $controlnext . "\t" . "\n";
1214cdf0e10cSrcweir
1215cdf0e10cSrcweir		push(@{$controltable}, $line1);
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir	#	my $textcount = "Text" . $count;
1218cdf0e10cSrcweir	#	my $stringname = "OOO_CONTROL_LANG_" . $windowslanguage;
1219cdf0e10cSrcweir	#
1220cdf0e10cSrcweir	#	$yvalue = $yvalue + 2;		# text 2 pixel lower than checkbox
1221cdf0e10cSrcweir	#
1222cdf0e10cSrcweir	#	my $line2 = "LanguageSelection" . "\t" . $textcount . "\t" . "Text" . "\t" .
1223cdf0e10cSrcweir	#				"40" . "\t" . $yvalue . "\t" . "70" . "\t" . "15" . "\t" . "65539" . "\t" .
1224cdf0e10cSrcweir	#				"\t" . $stringname . "\t" . "\t" . "\n";
1225cdf0e10cSrcweir	#
1226cdf0e10cSrcweir	#	push(@{$controltable}, $line2);
1227cdf0e10cSrcweir	}
1228cdf0e10cSrcweir}
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir###################################################################
1231cdf0e10cSrcweir# Determining the last position in a sequencetable
1232cdf0e10cSrcweir# into the tables CustomAc.idt and InstallE.idt.
1233cdf0e10cSrcweir###################################################################
1234cdf0e10cSrcweir
1235cdf0e10cSrcweirsub get_last_position_in_sequencetable
1236cdf0e10cSrcweir{
1237cdf0e10cSrcweir	my ($sequencetable) = @_;
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir	my $position = 0;
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1242cdf0e10cSrcweir	{
1243cdf0e10cSrcweir		my $line = ${$sequencetable}[$i];
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir		if ( $line =~ /^\s*\w+\t.*\t\s*(\d+)\s$/ )
1246cdf0e10cSrcweir		{
1247cdf0e10cSrcweir			my $newposition = $1;
1248cdf0e10cSrcweir			if ( $newposition > $position ) { $position = $newposition; }
1249cdf0e10cSrcweir		}
1250cdf0e10cSrcweir	}
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir	return $position;
1253cdf0e10cSrcweir}
1254cdf0e10cSrcweir
1255cdf0e10cSrcweir#########################################################################
1256cdf0e10cSrcweir# Determining the position of a specified Action in the sequencetable
1257cdf0e10cSrcweir#########################################################################
1258cdf0e10cSrcweir
1259cdf0e10cSrcweirsub get_position_in_sequencetable
1260cdf0e10cSrcweir{
1261cdf0e10cSrcweir	my ($action, $sequencetable) = @_;
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir	my $position = 0;
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir	$action =~ s/^\s*behind_//;
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1268cdf0e10cSrcweir	{
1269cdf0e10cSrcweir		my $line = ${$sequencetable}[$i];
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir		if ( $line =~ /^\s*(\w+)\t.*\t\s*(\d+)\s$/ )
1272cdf0e10cSrcweir		{
1273cdf0e10cSrcweir			my $compareaction = $1;
1274cdf0e10cSrcweir			$position = $2;
1275cdf0e10cSrcweir			if ( $compareaction eq $action ) { last; }
1276cdf0e10cSrcweir		}
1277cdf0e10cSrcweir	}
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir	return $position;
1280cdf0e10cSrcweir}
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir################################################################################################
1283cdf0e10cSrcweir# Including the CustomAction for the configuration
1284cdf0e10cSrcweir# into the tables CustomAc.idt and InstallE.idt.
1285cdf0e10cSrcweir#
1286cdf0e10cSrcweir# CustomAc.idt: ExecutePkgchk 82 pkgchk.exe -s
1287cdf0e10cSrcweir# InstallE.idt: ExecutePkgchk Not REMOVE="ALL" 3175
1288cdf0e10cSrcweir#
1289cdf0e10cSrcweir# CustomAc.idt: ExecuteQuickstart 82 install_quickstart.exe
1290cdf0e10cSrcweir# InstallE.idt: ExecuteQuickstart &gm_o_Quickstart=3 3200
1291cdf0e10cSrcweir#
1292cdf0e10cSrcweir# CustomAc.idt: ExecuteInstallRegsvrex 82 regsvrex.exe shlxthdl.dll
1293cdf0e10cSrcweir# InstallE.idt: ExecuteInstallRegsvrex Not REMOVE="ALL" 3225
1294cdf0e10cSrcweir#
1295cdf0e10cSrcweir# CustomAc.idt: ExecuteUninstallRegsvrex 82 regsvrex.exe /u shlxthdl.dll
1296cdf0e10cSrcweir# InstallE.idt: ExecuteUninstallRegsvrex REMOVE="ALL" 690
1297cdf0e10cSrcweir#
1298cdf0e10cSrcweir# CustomAc.idt: Regmsdocmsidll1 1 reg4msdocmsidll Reg4MsDocEntry
1299cdf0e10cSrcweir# InstallU.idt: Regmsdocmsidll1 Not REMOVE="ALL" 610
1300cdf0e10cSrcweir#
1301cdf0e10cSrcweir# CustomAc.idt: Regmsdocmsidll2 1 reg4msdocmsidll Reg4MsDocEntry
1302cdf0e10cSrcweir# InstallE.idt: Regmsdocmsidll2 Not REMOVE="ALL" 3160
1303cdf0e10cSrcweir################################################################################################
1304cdf0e10cSrcweir
1305cdf0e10cSrcweirsub set_custom_action
1306cdf0e10cSrcweir{
1307cdf0e10cSrcweir	my ($customactionidttable, $actionname, $actionflags, $exefilename, $actionparameter, $inbinarytable, $filesref, $customactionidttablename, $styles) = @_;
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir	my $included_customaction = 0;
1310cdf0e10cSrcweir	my $infoline = "";
1311cdf0e10cSrcweir	my $customaction_exefilename = $exefilename;
1312cdf0e10cSrcweir	my $uniquename = "";
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir    # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1315cdf0e10cSrcweir    if ( $styles =~ /\bNO_FILE\b/ )
1316cdf0e10cSrcweir    {
1317cdf0e10cSrcweir		my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1318cdf0e10cSrcweir		push(@{$customactionidttable}, $line);
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir        $infoline = "Added $actionname CustomAction into table $customactionidttablename (NO_FILE has been set)\n";
1321b274bc22SAndre Fischer        $installer::logger::Lang->print($infoline);
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir		$included_customaction = 1;
1324cdf0e10cSrcweir        return $included_customaction;
1325cdf0e10cSrcweir	}
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir	# is the $exefilename a library that is included into the binary table
1328cdf0e10cSrcweir
1329cdf0e10cSrcweir	if ( $inbinarytable ) { $customaction_exefilename =~ s/\.//; }	# this is the entry in the binary table ("abc.dll" -> "abcdll")
1330cdf0e10cSrcweir
1331cdf0e10cSrcweir	# is the $exefilename included into the product?
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir	my $contains_file = 0;
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir	# All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1336cdf0e10cSrcweir	# Both must be added together
1337cdf0e10cSrcweir	my $localfilesref = installer::converter::combine_arrays_from_references(\@installer::globals::binarytableonlyfiles, $filesref);
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1340cdf0e10cSrcweir	{
1341cdf0e10cSrcweir		my $onefile = ${$localfilesref}[$i];
1342cdf0e10cSrcweir		my $filename = "";
1343cdf0e10cSrcweir		if ( exists($onefile->{'Name'}) )
1344cdf0e10cSrcweir		{
1345cdf0e10cSrcweir			$filename = $onefile->{'Name'};
1346cdf0e10cSrcweir
1347cdf0e10cSrcweir			if ( $filename eq $exefilename )
1348cdf0e10cSrcweir			{
1349cdf0e10cSrcweir				$contains_file = 1;
1350cdf0e10cSrcweir				$uniquename = ${$localfilesref}[$i]->{'uniquename'};
1351cdf0e10cSrcweir				last;
1352cdf0e10cSrcweir			}
1353cdf0e10cSrcweir		}
1354cdf0e10cSrcweir		else
1355cdf0e10cSrcweir		{
1356cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: Did not find \"Name\" for file \"$onefile->{'uniquename'}\" ($onefile->{'gid'})!", "set_custom_action");
1357cdf0e10cSrcweir		}
1358cdf0e10cSrcweir	}
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir	if ( $contains_file )
1361cdf0e10cSrcweir	{
1362cdf0e10cSrcweir		# Now the CustomAction can be included into the CustomAc.idt
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir		if ( ! $inbinarytable ) { $customaction_exefilename = $uniquename; }	# the unique file name has to be added to the custom action table
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir		my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1367cdf0e10cSrcweir		push(@{$customactionidttable}, $line);
1368cdf0e10cSrcweir
1369cdf0e10cSrcweir		$included_customaction = 1;
1370cdf0e10cSrcweir	}
1371cdf0e10cSrcweir
1372cdf0e10cSrcweir	if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $customactionidttablename\n"; }
1373cdf0e10cSrcweir	else { $infoline = "Did not add $actionname CustomAction into table $customactionidttablename\n"; }
1374b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir	return $included_customaction;
1377cdf0e10cSrcweir}
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir####################################################################
1380cdf0e10cSrcweir# Adding a Custom Action to InstallExecuteTable or InstallUITable
1381cdf0e10cSrcweir####################################################################
1382cdf0e10cSrcweir
1383cdf0e10cSrcweirsub add_custom_action_to_install_table
1384cdf0e10cSrcweir{
1385cdf0e10cSrcweir	my ($installtable, $exefilename, $actionname, $actioncondition, $position, $filesref, $installtablename, $styles) = @_;
1386cdf0e10cSrcweir
1387cdf0e10cSrcweir	my $included_customaction = 0;
1388cdf0e10cSrcweir	my $feature = "";
1389cdf0e10cSrcweir	my $infoline = "";
1390cdf0e10cSrcweir
1391cdf0e10cSrcweir    # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1392cdf0e10cSrcweir    if ( $styles =~ /\bNO_FILE\b/ )
1393cdf0e10cSrcweir    {
1394cdf0e10cSrcweir		# then the InstallE.idt.idt or InstallU.idt.idt
1395cdf0e10cSrcweir		$actioncondition =~ s/FEATURETEMPLATE/$feature/g;	# only execute Custom Action, if feature of the file is installed
1396cdf0e10cSrcweir
1397cdf0e10cSrcweir		my $actionposition = 0;
1398cdf0e10cSrcweir
1399cdf0e10cSrcweir		if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1400cdf0e10cSrcweir		elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1401cdf0e10cSrcweir		else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1402cdf0e10cSrcweir
1403cdf0e10cSrcweir		my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1404cdf0e10cSrcweir		push(@{$installtable}, $line);
1405cdf0e10cSrcweir
1406cdf0e10cSrcweir        $infoline = "Added $actionname CustomAction into table $installtablename (NO_FILE has been set)\n";
1407b274bc22SAndre Fischer    	$installer::logger::Lang->print($infoline);
1408cdf0e10cSrcweir        return;
1409cdf0e10cSrcweir	}
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir	my $contains_file = 0;
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir	# All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1414cdf0e10cSrcweir	# Both must be added together
1415cdf0e10cSrcweir	my $localfilesref = installer::converter::combine_arrays_from_references(\@installer::globals::binarytableonlyfiles, $filesref);
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1418cdf0e10cSrcweir	{
1419cdf0e10cSrcweir		my $filename = ${$localfilesref}[$i]->{'Name'};
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir		if ( $filename eq $exefilename )
1422cdf0e10cSrcweir		{
1423cdf0e10cSrcweir			$contains_file = 1;
1424cdf0e10cSrcweir
1425cdf0e10cSrcweir			# Determining the feature of the file
1426cdf0e10cSrcweir
1427cdf0e10cSrcweir			if ( ${$localfilesref}[$i] ) { $feature = ${$localfilesref}[$i]->{'modules'}; }
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir			# If modules contains a list of modules, only taking the first one.
1430cdf0e10cSrcweir			if ( $feature =~ /^\s*(.*?)\,/ ) { $feature = $1; }
1431cdf0e10cSrcweir			# Attention: Maximum feature length is 38!
1432cdf0e10cSrcweir			shorten_feature_gid(\$feature);
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir			last;
1435cdf0e10cSrcweir		}
1436cdf0e10cSrcweir	}
1437cdf0e10cSrcweir
1438cdf0e10cSrcweir	if ( $contains_file )
1439cdf0e10cSrcweir	{
1440cdf0e10cSrcweir		# then the InstallE.idt.idt or InstallU.idt.idt
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir		$actioncondition =~ s/FEATURETEMPLATE/$feature/g;	# only execute Custom Action, if feature of the file is installed
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir#		my $actionposition = 0;
1445cdf0e10cSrcweir#		if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1446cdf0e10cSrcweir#		elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1447cdf0e10cSrcweir#		else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1448cdf0e10cSrcweir#		my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1449cdf0e10cSrcweir
1450cdf0e10cSrcweir		my $positiontemplate = "";
1451cdf0e10cSrcweir		if ( $position =~ /^\s*\d+\s*$/ ) { $positiontemplate = $position; }	# setting the position directly, number defined in scp2
1452cdf0e10cSrcweir		else { $positiontemplate = "POSITIONTEMPLATE_" . $position; }
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir		my $line = $actionname . "\t" . $actioncondition . "\t" . $positiontemplate . "\n";
1455cdf0e10cSrcweir		push(@{$installtable}, $line);
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir		$included_customaction = 1;
1458cdf0e10cSrcweir	}
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir	if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $installtablename\n"; }
1461cdf0e10cSrcweir	else { $infoline = "Did not add $actionname CustomAction into table $installtablename\n"; }
1462b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1463cdf0e10cSrcweir
1464cdf0e10cSrcweir}
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir##################################################################
1467cdf0e10cSrcweir# A line in the table ControlEvent connects a Control
1468cdf0e10cSrcweir# with a Custom Action
1469cdf0e10cSrcweir#################################################################
1470cdf0e10cSrcweir
1471cdf0e10cSrcweirsub connect_custom_action_to_control
1472cdf0e10cSrcweir{
1473cdf0e10cSrcweir	my ( $table, $tablename, $dialog, $control, $event, $argument, $condition, $ordering) = @_;
1474cdf0e10cSrcweir
1475cdf0e10cSrcweir	my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $argument. "\t" . $condition. "\t" . $ordering . "\n";
1476cdf0e10cSrcweir
1477cdf0e10cSrcweir	push(@{$table}, $line);
1478cdf0e10cSrcweir
1479cdf0e10cSrcweir	$line =~ s/\s*$//g;
1480cdf0e10cSrcweir
1481cdf0e10cSrcweir	$infoline = "Added line \"$line\" into table $tablename\n";
1482b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1483cdf0e10cSrcweir}
1484cdf0e10cSrcweir
1485cdf0e10cSrcweir##################################################################
1486cdf0e10cSrcweir# A line in the table ControlCondition connects a Control state
1487cdf0e10cSrcweir# with a condition
1488cdf0e10cSrcweir##################################################################
1489cdf0e10cSrcweir
1490cdf0e10cSrcweirsub connect_condition_to_control
1491cdf0e10cSrcweir{
1492cdf0e10cSrcweir	my ( $table, $tablename, $dialog, $control, $event, $condition) = @_;
1493cdf0e10cSrcweir
1494cdf0e10cSrcweir	my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $condition. "\n";
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir	push(@{$table}, $line);
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir	$line =~ s/\s*$//g;
1499cdf0e10cSrcweir
1500cdf0e10cSrcweir	$infoline = "Added line \"$line\" into table $tablename\n";
1501b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1502cdf0e10cSrcweir}
1503cdf0e10cSrcweir
1504cdf0e10cSrcweir##################################################################
1505cdf0e10cSrcweir# Searching for a sequencenumber in InstallUISequence table
1506cdf0e10cSrcweir# "ExecuteAction" must be the last action
1507cdf0e10cSrcweir##################################################################
1508cdf0e10cSrcweir
1509cdf0e10cSrcweirsub get_free_number_in_uisequence_table
1510cdf0e10cSrcweir{
1511cdf0e10cSrcweir	my ( $installuitable ) = @_;
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir	# determining the sequence of "ExecuteAction"
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir	my $executeactionnumber = 0;
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1518cdf0e10cSrcweir	{
1519cdf0e10cSrcweir		if ( ${$installuitable}[$i] =~ /^\s*(\w+)\t\w*\t(\d+)\s*$/ )
1520cdf0e10cSrcweir		{
1521cdf0e10cSrcweir			my $actionname = $1;
1522cdf0e10cSrcweir			my $actionnumber = $2;
1523cdf0e10cSrcweir
1524cdf0e10cSrcweir			if ( $actionname eq "ExecuteAction" )
1525cdf0e10cSrcweir			{
1526cdf0e10cSrcweir				$executeactionnumber = $actionnumber;
1527cdf0e10cSrcweir				last;
1528cdf0e10cSrcweir			}
1529cdf0e10cSrcweir		}
1530cdf0e10cSrcweir	}
1531cdf0e10cSrcweir
1532cdf0e10cSrcweir	if ( $executeactionnumber == 0 ) { installer::exiter::exit_program("ERROR: Did not find \"ExecuteAction\" in InstallUISequence table!", "get_free_number_in_uisequence_table"); }
1533cdf0e10cSrcweir
1534cdf0e10cSrcweir	# determining the sequence of the action before "ExecuteAction"
1535cdf0e10cSrcweir
1536cdf0e10cSrcweir	my $lastactionnumber = 0;
1537cdf0e10cSrcweir
1538cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1539cdf0e10cSrcweir	{
1540cdf0e10cSrcweir		if ( ${$installuitable}[$i] =~ /^\s*\w+\t\w*\t(\d+)\s*$/ )
1541cdf0e10cSrcweir		{
1542cdf0e10cSrcweir			my $actionnumber = $1;
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir			if (( $actionnumber > $lastactionnumber ) && ( $actionnumber != $executeactionnumber ))
1545cdf0e10cSrcweir			{
1546cdf0e10cSrcweir				$lastactionnumber = $actionnumber;
1547cdf0e10cSrcweir			}
1548cdf0e10cSrcweir		}
1549cdf0e10cSrcweir	}
1550cdf0e10cSrcweir
1551cdf0e10cSrcweir	# the new number can now be calculated
1552cdf0e10cSrcweir
1553cdf0e10cSrcweir	my $newnumber = 0;
1554cdf0e10cSrcweir
1555cdf0e10cSrcweir	if ((( $lastactionnumber + $executeactionnumber ) % 2 ) == 0 ) { $newnumber = ( $lastactionnumber + $executeactionnumber ) / 2; }
1556cdf0e10cSrcweir	else { $newnumber = ( $lastactionnumber + $executeactionnumber -1 ) / 2; }
1557cdf0e10cSrcweir
1558cdf0e10cSrcweir	return $newnumber;
1559cdf0e10cSrcweir}
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir##################################################################
1562cdf0e10cSrcweir# Searching for a specified string in the feature table
1563cdf0e10cSrcweir##################################################################
1564cdf0e10cSrcweir
1565cdf0e10cSrcweirsub get_feature_name
1566cdf0e10cSrcweir{
1567cdf0e10cSrcweir	my ( $string, $featuretable ) = @_;
1568cdf0e10cSrcweir
1569cdf0e10cSrcweir	my $featurename = "";
1570cdf0e10cSrcweir
1571cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$featuretable}; $i++ )
1572cdf0e10cSrcweir	{
1573cdf0e10cSrcweir		if ( ${$featuretable}[$i] =~ /^\s*(\w+$string)\t/ )
1574cdf0e10cSrcweir		{
1575cdf0e10cSrcweir			$featurename = $1;
1576cdf0e10cSrcweir			last;
1577cdf0e10cSrcweir		}
1578cdf0e10cSrcweir	}
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir	return $featurename;
1581cdf0e10cSrcweir}
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir######################################################################
1584cdf0e10cSrcweir# Returning the toplevel directory name of one specific file
1585cdf0e10cSrcweir######################################################################
1586cdf0e10cSrcweir
1587cdf0e10cSrcweirsub get_directory_name_from_file
1588cdf0e10cSrcweir{
1589cdf0e10cSrcweir	my ($onefile) = @_;
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir	my $destination = $onefile->{'destination'};
1592cdf0e10cSrcweir	my $name = $onefile->{'Name'};
1593cdf0e10cSrcweir
1594cdf0e10cSrcweir	$destination =~ s/\Q$name\E\s*$//;
1595cdf0e10cSrcweir	$destination =~ s/\Q$installer::globals::separator\E\s*$//;
1596cdf0e10cSrcweir
1597cdf0e10cSrcweir	my $path = "";
1598cdf0e10cSrcweir
1599cdf0e10cSrcweir	if ( $destination =~ /\Q$installer::globals::separator\E/ )
1600cdf0e10cSrcweir	{
1601cdf0e10cSrcweir		if ( $destination =~ /^\s*(\S.*\S\Q$installer::globals::separator\E)(\S.+\S?)/ )
1602cdf0e10cSrcweir		{
1603cdf0e10cSrcweir			$path = $2;
1604cdf0e10cSrcweir		}
1605cdf0e10cSrcweir	}
1606cdf0e10cSrcweir	else
1607cdf0e10cSrcweir	{
1608cdf0e10cSrcweir		$path = $destination;
1609cdf0e10cSrcweir	}
1610cdf0e10cSrcweir
1611cdf0e10cSrcweir	return $path;
1612cdf0e10cSrcweir}
1613cdf0e10cSrcweir
1614cdf0e10cSrcweir#############################################################
1615cdf0e10cSrcweir# Including the new subdir into the directory table
1616cdf0e10cSrcweir#############################################################
1617cdf0e10cSrcweir
1618cdf0e10cSrcweirsub include_subdirname_into_directory_table
1619cdf0e10cSrcweir{
1620cdf0e10cSrcweir	my ($dirname, $directorytable, $directorytablename, $onefile) = @_;
1621cdf0e10cSrcweir
1622cdf0e10cSrcweir	my $subdir = "";
1623cdf0e10cSrcweir	if ( $onefile->{'Subdir'} ) { $subdir = $onefile->{'Subdir'}; }
1624cdf0e10cSrcweir	if ( $subdir eq "" ) { installer::exiter::exit_program("ERROR: No \"Subdir\" defined for $onefile->{'Name'}", "include_subdirname_into_directory_table"); }
1625cdf0e10cSrcweir
1626cdf0e10cSrcweir	# program INSTALLLOCATION program -> subjava INSTALLLOCATION program:java
1627cdf0e10cSrcweir
1628cdf0e10cSrcweir	my $uniquename = "";
1629cdf0e10cSrcweir	my $parent = "";
1630cdf0e10cSrcweir	my $name = "";
1631cdf0e10cSrcweir
1632cdf0e10cSrcweir	my $includedline = 0;
1633cdf0e10cSrcweir
1634cdf0e10cSrcweir	my $newdir = "";
1635cdf0e10cSrcweir
1636cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directorytable}; $i++ )
1637cdf0e10cSrcweir	{
1638cdf0e10cSrcweir
1639cdf0e10cSrcweir		if ( ${$directorytable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\s*$/ )
1640cdf0e10cSrcweir		{
1641cdf0e10cSrcweir			$uniquename = $1;
1642cdf0e10cSrcweir			$parent = $2;
1643cdf0e10cSrcweir			$name = $3;
1644cdf0e10cSrcweir
1645cdf0e10cSrcweir			if ( $dirname eq $name )
1646cdf0e10cSrcweir			{
1647cdf0e10cSrcweir				my $newuniquename = "sub" . $subdir;
1648cdf0e10cSrcweir				$newdir = $newuniquename;
1649cdf0e10cSrcweir				# my $newparent = $parent;
1650cdf0e10cSrcweir				my $newparent = "INSTALLLOCATION";
1651cdf0e10cSrcweir				my $newname = $name . "\:" . $subdir;
1652cdf0e10cSrcweir				my $newline =
1653cdf0e10cSrcweir				$line = "$newuniquename\t$newparent\t$newname\n";
1654cdf0e10cSrcweir				push(@{$directorytable}, $line);
1655cdf0e10cSrcweir				installer::remover::remove_leading_and_ending_whitespaces(\$line);
1656cdf0e10cSrcweir				$infoline = "Added $line into directory table $directorytablename\n";
1657b274bc22SAndre Fischer				$installer::logger::Lang->print($infoline);
1658cdf0e10cSrcweir
1659cdf0e10cSrcweir				$includedline = 1;
1660cdf0e10cSrcweir				last;
1661cdf0e10cSrcweir			}
1662cdf0e10cSrcweir		}
1663cdf0e10cSrcweir	}
1664cdf0e10cSrcweir
1665cdf0e10cSrcweir	if ( ! $includedline ) { installer::exiter::exit_program("ERROR: Could not include new subdirectory into directory table for file $onefile->{'Name'}!", "include_subdirname_into_directory_table"); }
1666cdf0e10cSrcweir
1667cdf0e10cSrcweir	return $newdir;
1668cdf0e10cSrcweir}
1669cdf0e10cSrcweir
1670cdf0e10cSrcweir##################################################################
1671cdf0e10cSrcweir# Including the new sub directory into the component table
1672cdf0e10cSrcweir##################################################################
1673cdf0e10cSrcweir
1674cdf0e10cSrcweirsub include_subdir_into_componenttable
1675cdf0e10cSrcweir{
1676cdf0e10cSrcweir	my ($subdir, $onefile, $componenttable) = @_;
1677cdf0e10cSrcweir
1678cdf0e10cSrcweir	my $componentname = $onefile->{'componentname'};
1679cdf0e10cSrcweir
1680cdf0e10cSrcweir	my $changeddirectory = 0;
1681cdf0e10cSrcweir
1682cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$componenttable}; $i++ )
1683cdf0e10cSrcweir	{
1684cdf0e10cSrcweir		if ( ${$componenttable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1685cdf0e10cSrcweir		{
1686cdf0e10cSrcweir			my $localcomponentname = $1;
1687cdf0e10cSrcweir			my $directory = $3;
1688cdf0e10cSrcweir
1689cdf0e10cSrcweir			if ( $componentname eq $localcomponentname )
1690cdf0e10cSrcweir			{
1691cdf0e10cSrcweir				my $oldvalue = ${$componenttable}[$i];
1692cdf0e10cSrcweir				${$componenttable}[$i] =~ s/\b\Q$directory\E\b/$subdir/;
1693cdf0e10cSrcweir				my $newvalue = ${$componenttable}[$i];
1694cdf0e10cSrcweir
1695cdf0e10cSrcweir				installer::remover::remove_leading_and_ending_whitespaces(\$oldvalue);
1696cdf0e10cSrcweir				installer::remover::remove_leading_and_ending_whitespaces(\$newvalue);
1697cdf0e10cSrcweir				$infoline = "Change in Component table: From \"$oldvalue\" to \"$newvalue\"\n";
1698b274bc22SAndre Fischer				$installer::logger::Lang->print($infoline);
1699cdf0e10cSrcweir
1700cdf0e10cSrcweir				$changeddirectory = 1;
1701cdf0e10cSrcweir				last;
1702cdf0e10cSrcweir			}
1703cdf0e10cSrcweir		}
1704cdf0e10cSrcweir	}
1705cdf0e10cSrcweir
1706cdf0e10cSrcweir	if ( ! $changeddirectory ) { installer::exiter::exit_program("ERROR: Could not change directory for component: $onefile->{'Name'}!", "include_subdir_into_componenttable"); }
1707cdf0e10cSrcweir
1708cdf0e10cSrcweir}
1709cdf0e10cSrcweir
1710cdf0e10cSrcweir################################################################################################
1711cdf0e10cSrcweir# Including the content for the child installations
1712cdf0e10cSrcweir# into the tables:
1713cdf0e10cSrcweir# CustomAc.idt, InstallU.idt, Feature.idt
1714cdf0e10cSrcweir################################################################################################
1715cdf0e10cSrcweir
1716cdf0e10cSrcweirsub add_childprojects
1717cdf0e10cSrcweir{
1718cdf0e10cSrcweir	my ($languageidtdir, $filesref, $allvariables) = @_;
1719cdf0e10cSrcweir
1720cdf0e10cSrcweir	my $customactiontablename = $languageidtdir . $installer::globals::separator . "CustomAc.idt";
1721cdf0e10cSrcweir	my $customactiontable = installer::files::read_file($customactiontablename);
1722cdf0e10cSrcweir	my $installuitablename = $languageidtdir . $installer::globals::separator . "InstallU.idt";
1723cdf0e10cSrcweir	my $installuitable = installer::files::read_file($installuitablename);
1724cdf0e10cSrcweir	my $featuretablename = $languageidtdir . $installer::globals::separator . "Feature.idt";
1725cdf0e10cSrcweir	my $featuretable = installer::files::read_file($featuretablename);
1726cdf0e10cSrcweir	my $directorytablename = $languageidtdir . $installer::globals::separator . "Director.idt";
1727cdf0e10cSrcweir	my $directorytable = installer::files::read_file($directorytablename);
1728cdf0e10cSrcweir	my $componenttablename = $languageidtdir . $installer::globals::separator . "Componen.idt";
1729cdf0e10cSrcweir	my $componenttable = installer::files::read_file($componenttablename);
1730cdf0e10cSrcweir
1731cdf0e10cSrcweir	my $infoline = "";
1732cdf0e10cSrcweir	my $line = "";
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir	$installer::globals::javafile = installer::worker::return_first_item_with_special_flag($filesref ,"JAVAFILE");
1735cdf0e10cSrcweir	$installer::globals::urefile = installer::worker::return_first_item_with_special_flag($filesref ,"UREFILE");
1736cdf0e10cSrcweir
1737cdf0e10cSrcweir	if (( $installer::globals::javafile eq "" ) && ( $allvariables->{'JAVAPRODUCT'} )) { installer::exiter::exit_program("ERROR: No JAVAFILE found in files collector!", "add_childprojects"); }
1738cdf0e10cSrcweir	if (( $installer::globals::urefile eq "" ) && ( $allvariables->{'UREPRODUCT'} )) { installer::exiter::exit_program("ERROR: No UREFILE found in files collector!", "add_childprojects"); }
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir	# Content for Directory table
1741cdf0e10cSrcweir	# SystemFolder TARGETDIR .
1742cdf0e10cSrcweir
1743cdf0e10cSrcweir	my $contains_systemfolder = 0;
1744cdf0e10cSrcweir
1745cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directorytable}; $i++ )
1746cdf0e10cSrcweir	{
1747cdf0e10cSrcweir		if ( ${$directorytable}[$i] =~ /^\s*SystemFolder\t/ )
1748cdf0e10cSrcweir		{
1749cdf0e10cSrcweir			$contains_systemfolder = 1;
1750cdf0e10cSrcweir			last;
1751cdf0e10cSrcweir		}
1752cdf0e10cSrcweir	}
1753cdf0e10cSrcweir
1754cdf0e10cSrcweir	if ( ! $contains_systemfolder )
1755cdf0e10cSrcweir	{
1756cdf0e10cSrcweir		$line = "SystemFolder\tTARGETDIR\t\.\n";
1757cdf0e10cSrcweir		push(@{$directorytable}, $line);
1758cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1759cdf0e10cSrcweir		$infoline = "Added $line into table $directorytablename\n";
1760cdf0e10cSrcweir	}
1761cdf0e10cSrcweir	else
1762cdf0e10cSrcweir	{
1763cdf0e10cSrcweir		$infoline = "SystemFolder already exists in table $directorytablename\n";
1764cdf0e10cSrcweir	}
1765cdf0e10cSrcweir
1766b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
1767cdf0e10cSrcweir
1768cdf0e10cSrcweir	# Additional content for the directory table
1769cdf0e10cSrcweir	# subjava 	INSTALLLOCATION program:java
1770cdf0e10cSrcweir	# subure 	INSTALLLOCATION program:ure
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir	my $dirname = "";
1773cdf0e10cSrcweir	my $subjavadir = "";
1774cdf0e10cSrcweir	my $suburedir = "";
1775cdf0e10cSrcweir
1776cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
1777cdf0e10cSrcweir	{
1778cdf0e10cSrcweir		$dirname = get_directory_name_from_file($installer::globals::javafile);
1779cdf0e10cSrcweir		$subjavadir = include_subdirname_into_directory_table($dirname, $directorytable, $directorytablename, $installer::globals::javafile);
1780cdf0e10cSrcweir	}
1781cdf0e10cSrcweir
1782cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} )
1783cdf0e10cSrcweir	{
1784cdf0e10cSrcweir		$dirname = get_directory_name_from_file($installer::globals::urefile);
1785cdf0e10cSrcweir		$suburedir = include_subdirname_into_directory_table($dirname, $directorytable, $directorytablename, $installer::globals::urefile);
1786cdf0e10cSrcweir	}
1787cdf0e10cSrcweir
1788cdf0e10cSrcweir	# Content for the Component table
1789cdf0e10cSrcweir	# The Java and Ada components have new directories
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} ) { include_subdir_into_componenttable($subjavadir, $installer::globals::javafile, $componenttable); }
1792cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} ) { include_subdir_into_componenttable($suburedir, $installer::globals::urefile, $componenttable); }
1793cdf0e10cSrcweir
1794cdf0e10cSrcweir	# Content for CustomAction table
1795cdf0e10cSrcweir
1796cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
1797cdf0e10cSrcweir	{
1798cdf0e10cSrcweir		$line = "InstallJava\t98\tSystemFolder\t[SourceDir]$installer::globals::javafile->{'Subdir'}\\$installer::globals::javafile->{'Name'} \/qb REBOOT=Suppress SPONSORS=0 DISABLEAD=1\n";
1799cdf0e10cSrcweir		push(@{$customactiontable} ,$line);
1800cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1801cdf0e10cSrcweir		$infoline = "Added $line into table $customactiontablename\n";
1802b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1803cdf0e10cSrcweir	}
1804cdf0e10cSrcweir
1805cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} )
1806cdf0e10cSrcweir	{
1807cdf0e10cSrcweir		$line = "InstallUre\t98\tSystemFolder\t$installer::globals::urefile->{'Subdir'}\\$installer::globals::urefile->{'Name'} /S\n";
1808cdf0e10cSrcweir		push(@{$customactiontable} ,$line);
1809cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1810cdf0e10cSrcweir		$infoline = "Added $line into table $customactiontablename\n";
1811b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1812cdf0e10cSrcweir	}
1813cdf0e10cSrcweir
1814cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
1815cdf0e10cSrcweir	{
1816cdf0e10cSrcweir		$line = "MaintenanceJava\t82\t$installer::globals::javafile->{'uniquename'}\t\/qb REBOOT=Suppress SPONSORS=0 DISABLEAD=1\n";
1817cdf0e10cSrcweir		push(@{$customactiontable} ,$line);
1818cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1819cdf0e10cSrcweir		$infoline = "Added $line into table $customactiontablename\n";
1820b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1821cdf0e10cSrcweir	}
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} )
1824cdf0e10cSrcweir	{
1825cdf0e10cSrcweir		$line = "MaintenanceUre\t82\t$installer::globals::urefile->{'uniquename'}\t\/S\n";
1826cdf0e10cSrcweir		push(@{$customactiontable} ,$line);
1827cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1828cdf0e10cSrcweir		$infoline = "Added $line into table $customactiontablename\n";
1829b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1830cdf0e10cSrcweir	}
1831cdf0e10cSrcweir
1832cdf0e10cSrcweir	# Content for InstallUISequence table
1833cdf0e10cSrcweir	# InstallAdabas &gm_o_Adabas=3 825
1834cdf0e10cSrcweir	# InstallJava &gm_o_Java=3 827
1835cdf0e10cSrcweir
1836cdf0e10cSrcweir	my $number = "";
1837cdf0e10cSrcweir	my $featurename = "";
1838cdf0e10cSrcweir
1839cdf0e10cSrcweir	if ( $allvariables->{'ADAPRODUCT'} )
1840cdf0e10cSrcweir	{
1841cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable);
1842cdf0e10cSrcweir		$featurename = get_feature_name("_Adabas", $featuretable);
1843cdf0e10cSrcweir		$line = "InstallAdabas\t\&$featurename\=3 And Not Installed And Not PATCH\t$number\n";
1844cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1845cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1846cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1847b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1848cdf0e10cSrcweir	}
1849cdf0e10cSrcweir
1850cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
1851cdf0e10cSrcweir	{
1852cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable) + 2;
1853cdf0e10cSrcweir		$featurename = get_feature_name("_Java", $featuretable);
1854cdf0e10cSrcweir		if ( $featurename ) { $line = "InstallJava\t\&$featurename\=3 And Not Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; }
1855cdf0e10cSrcweir		else { $line = "InstallJava\tNot Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; } # feature belongs to root
1856cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1857cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1858cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1859b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1860cdf0e10cSrcweir	}
1861cdf0e10cSrcweir
1862cdf0e10cSrcweir	if ( $allvariables->{'ADAPRODUCT'} )
1863cdf0e10cSrcweir	{
1864cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable) + 4;
1865cdf0e10cSrcweir		$featurename = get_feature_name("_Adabas", $featuretable);
1866cdf0e10cSrcweir		$line = "MaintenanceAdabas\t\&$featurename\=3 And Installed And Not PATCH\t$number\n";
1867cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1868cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1869cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1870b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1871cdf0e10cSrcweir	}
1872cdf0e10cSrcweir
1873cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
1874cdf0e10cSrcweir	{
1875cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable) + 6;
1876cdf0e10cSrcweir		$featurename = get_feature_name("_Java", $featuretable);
1877cdf0e10cSrcweir		if ( $featurename ) { $line = "MaintenanceJava\t\&$featurename\=3 And Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; }
1878cdf0e10cSrcweir		else { $line = "MaintenanceJava\tInstalled And JAVAPATH\=\"\" And Not PATCH\t$number\n"; } # feature belongs to root
1879cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1880cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1881cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1882b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1883cdf0e10cSrcweir	}
1884cdf0e10cSrcweir
1885cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} )
1886cdf0e10cSrcweir	{
1887cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable) + 8;
1888cdf0e10cSrcweir		$featurename = get_feature_name("_Ure", $featuretable);
1889cdf0e10cSrcweir		if ( $featurename ) { $line = "InstallUre\t\&$featurename\=3 And Not Installed\t$number\n"; }
1890cdf0e10cSrcweir		else { $line = "InstallUre\tNot Installed\t$number\n"; } # feature belongs to root
1891cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1892cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1893cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1894b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1895cdf0e10cSrcweir	}
1896cdf0e10cSrcweir
1897cdf0e10cSrcweir	if ( $allvariables->{'UREPRODUCT'} )
1898cdf0e10cSrcweir	{
1899cdf0e10cSrcweir		$number = get_free_number_in_uisequence_table($installuitable) + 10;
1900cdf0e10cSrcweir		$featurename = get_feature_name("_Ure", $featuretable);
1901cdf0e10cSrcweir		if ( $featurename ) { $line = "MaintenanceUre\t\&$featurename\=3 And Installed\t$number\n"; }
1902cdf0e10cSrcweir		else { $line = "MaintenanceUre\tInstalled\t$number\n"; } # feature belongs to root
1903cdf0e10cSrcweir		push(@{$installuitable} ,$line);
1904cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$line);
1905cdf0e10cSrcweir		$infoline = "Added $line into table $installuitablename\n";
1906b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
1907cdf0e10cSrcweir	}
1908cdf0e10cSrcweir
1909cdf0e10cSrcweir	# Content for Feature table, better from scp (translation)
1910cdf0e10cSrcweir	# gm_o_java gm_optional Java 1.4.2 Description 2 200
1911cdf0e10cSrcweir
1912cdf0e10cSrcweir	installer::files::save_file($customactiontablename, $customactiontable);
1913cdf0e10cSrcweir	installer::files::save_file($installuitablename, $installuitable);
1914cdf0e10cSrcweir	installer::files::save_file($featuretablename, $featuretable);
1915cdf0e10cSrcweir	installer::files::save_file($directorytablename, $directorytable);
1916cdf0e10cSrcweir	installer::files::save_file($componenttablename, $componenttable);
1917cdf0e10cSrcweir}
1918cdf0e10cSrcweir
1919cdf0e10cSrcweir##################################################################
1920cdf0e10cSrcweir# Setting the encoding in all idt files. Replacing the
1921cdf0e10cSrcweir# variable WINDOWSENCODINGTEMPLATE
1922cdf0e10cSrcweir##################################################################
1923cdf0e10cSrcweir
1924cdf0e10cSrcweirsub setencoding
1925cdf0e10cSrcweir{
1926cdf0e10cSrcweir	my ( $languageidtdir, $onelanguage ) = @_;
1927cdf0e10cSrcweir
1928cdf0e10cSrcweir	my $encoding = installer::windows::language::get_windows_encoding($onelanguage);
1929cdf0e10cSrcweir
1930cdf0e10cSrcweir	# collecting all idt files in the directory $languageidtdir and substituting the string
1931cdf0e10cSrcweir
1932cdf0e10cSrcweir	my $idtfiles = installer::systemactions::find_file_with_file_extension("idt", $languageidtdir);
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$idtfiles}; $i++ )
1935cdf0e10cSrcweir	{
1936cdf0e10cSrcweir		my $onefilename = $languageidtdir . $installer::globals::separator . ${$idtfiles}[$i];
1937cdf0e10cSrcweir		my $onefile = installer::files::read_file($onefilename);
1938cdf0e10cSrcweir
1939cdf0e10cSrcweir		for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1940cdf0e10cSrcweir		{
1941cdf0e10cSrcweir			${$onefile}[$j] =~ s/WINDOWSENCODINGTEMPLATE/$encoding/g;
1942cdf0e10cSrcweir		}
1943cdf0e10cSrcweir
1944cdf0e10cSrcweir		installer::files::save_file($onefilename, $onefile);
1945cdf0e10cSrcweir	}
1946cdf0e10cSrcweir}
1947cdf0e10cSrcweir
1948cdf0e10cSrcweir##################################################################
1949cdf0e10cSrcweir# Setting the condition, that at least one module is selected.
1950cdf0e10cSrcweir# All modules with flag SHOW_MULTILINGUAL_ONLY were already
1951cdf0e10cSrcweir# collected. In table ControlE.idt, the string
1952cdf0e10cSrcweir# LANGUAGECONDITIONINSTALL needs to be replaced.
1953cdf0e10cSrcweir# Also for APPLICATIONCONDITIONINSTALL for the applications
1954cdf0e10cSrcweir# with flag APPLICATIONMODULE.
1955cdf0e10cSrcweir##################################################################
1956cdf0e10cSrcweir
1957cdf0e10cSrcweirsub set_multilanguageonly_condition
1958cdf0e10cSrcweir{
1959cdf0e10cSrcweir	my ( $languageidtdir ) = @_;
1960cdf0e10cSrcweir
1961cdf0e10cSrcweir	my $onefilename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
1962cdf0e10cSrcweir	my $onefile = installer::files::read_file($onefilename);
1963cdf0e10cSrcweir
1964cdf0e10cSrcweir	# Language modules
1965cdf0e10cSrcweir
1966cdf0e10cSrcweir	my $condition = "";
1967cdf0e10cSrcweir
1968cdf0e10cSrcweir	foreach my $module ( sort keys %installer::globals::multilingual_only_modules )
1969cdf0e10cSrcweir	{
1970cdf0e10cSrcweir		$condition = $condition . " &$module=3 Or";
1971cdf0e10cSrcweir	}
1972cdf0e10cSrcweir
1973cdf0e10cSrcweir	$condition =~ s/^\s*//;
1974cdf0e10cSrcweir	$condition =~ s/\s*Or\s*$//;	# removing the ending "Or"
1975cdf0e10cSrcweir
1976cdf0e10cSrcweir	if ( $condition eq "" ) { $condition = "1"; }
1977cdf0e10cSrcweir
1978cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1979cdf0e10cSrcweir	{
1980cdf0e10cSrcweir		${$onefile}[$j] =~ s/LANGUAGECONDITIONINSTALL/$condition/;
1981cdf0e10cSrcweir	}
1982cdf0e10cSrcweir
1983cdf0e10cSrcweir	# Application modules
1984cdf0e10cSrcweir
1985cdf0e10cSrcweir	$condition = "";
1986cdf0e10cSrcweir
1987cdf0e10cSrcweir	foreach my $module ( sort keys %installer::globals::application_modules )
1988cdf0e10cSrcweir	{
1989cdf0e10cSrcweir		$condition = $condition . " &$module=3 Or";
1990cdf0e10cSrcweir	}
1991cdf0e10cSrcweir
1992cdf0e10cSrcweir	$condition =~ s/^\s*//;
1993cdf0e10cSrcweir	$condition =~ s/\s*Or\s*$//;	# removing the ending "Or"
1994cdf0e10cSrcweir
1995cdf0e10cSrcweir	if ( $condition eq "" ) { $condition = "1"; }
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1998cdf0e10cSrcweir	{
1999cdf0e10cSrcweir		${$onefile}[$j] =~ s/APPLICATIONCONDITIONINSTALL/$condition/;
2000cdf0e10cSrcweir	}
2001cdf0e10cSrcweir
2002cdf0e10cSrcweir	installer::files::save_file($onefilename, $onefile);
2003cdf0e10cSrcweir}
2004cdf0e10cSrcweir
2005cdf0e10cSrcweir#############################################
2006cdf0e10cSrcweir# Putting array values into hash
2007cdf0e10cSrcweir#############################################
2008cdf0e10cSrcweir
2009cdf0e10cSrcweirsub fill_assignment_hash
2010cdf0e10cSrcweir{
2011cdf0e10cSrcweir	my ($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray) = @_;
2012cdf0e10cSrcweir
2013cdf0e10cSrcweir	my $max = $parameter - 1;
2014cdf0e10cSrcweir
2015cdf0e10cSrcweir	if ( $max != $#{$assignmentarray} )
2016cdf0e10cSrcweir	{
2017cdf0e10cSrcweir		my $definedparameter = $#{$assignmentarray} + 1;
2018cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Wrong parameter in scp. For table $tablename $parameter parameter are required ! You defined: $definedparameter", "fill_assignment_hash");
2019cdf0e10cSrcweir	}
2020cdf0e10cSrcweir
2021cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$assignmentarray}; $i++ )
2022cdf0e10cSrcweir	{
2023cdf0e10cSrcweir		my $counter = $i + 1;
2024cdf0e10cSrcweir		my $key = "parameter". $counter;
2025cdf0e10cSrcweir
2026cdf0e10cSrcweir		my $localvalue = ${$assignmentarray}[$i];
2027cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_quotationmarks(\$localvalue);
2028cdf0e10cSrcweir		$localvalue =~ s/\\\"/\"/g;
2029cdf0e10cSrcweir		$localvalue =~ s/\\\!/\!/g;
2030cdf0e10cSrcweir		$localvalue =~ s/\\\&/\&/g;
2031cdf0e10cSrcweir		$localvalue =~ s/\\\</\</g;
2032cdf0e10cSrcweir		$localvalue =~ s/\\\>/\>/g;
2033cdf0e10cSrcweir		$assignmenthashref->{$key} = $localvalue;
2034cdf0e10cSrcweir	}
2035cdf0e10cSrcweir}
2036cdf0e10cSrcweir
2037cdf0e10cSrcweir##########################################################################
2038cdf0e10cSrcweir# Checking the assignment of a Windows CustomAction and putting it
2039cdf0e10cSrcweir# into a hash
2040cdf0e10cSrcweir##########################################################################
2041cdf0e10cSrcweir
2042cdf0e10cSrcweirsub create_customaction_assignment_hash
2043cdf0e10cSrcweir{
2044cdf0e10cSrcweir	my ($gid, $name, $key, $assignmentarray) = @_;
2045cdf0e10cSrcweir
2046cdf0e10cSrcweir	my %assignment = ();
2047cdf0e10cSrcweir	my $assignmenthashref = \%assignment;
2048cdf0e10cSrcweir
2049cdf0e10cSrcweir	my $tablename = ${$assignmentarray}[0];
2050cdf0e10cSrcweir	installer::remover::remove_leading_and_ending_quotationmarks(\$tablename);
2051cdf0e10cSrcweir
2052cdf0e10cSrcweir	my $tablename_defined = 0;
2053cdf0e10cSrcweir	my $parameter = 0;
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir	if ( $tablename eq "InstallUISequence" )
2056cdf0e10cSrcweir	{
2057cdf0e10cSrcweir		$tablename_defined = 1;
2058cdf0e10cSrcweir		$parameter = 3;
2059cdf0e10cSrcweir		fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2060cdf0e10cSrcweir	}
2061cdf0e10cSrcweir
2062cdf0e10cSrcweir	if ( $tablename eq "InstallExecuteSequence" )
2063cdf0e10cSrcweir	{
2064cdf0e10cSrcweir		$tablename_defined = 1;
2065cdf0e10cSrcweir		$parameter = 3;
2066cdf0e10cSrcweir		fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2067cdf0e10cSrcweir	}
2068cdf0e10cSrcweir
2069cdf0e10cSrcweir	if ( $tablename eq "AdminExecuteSequence" )
2070cdf0e10cSrcweir	{
2071cdf0e10cSrcweir		$tablename_defined = 1;
2072cdf0e10cSrcweir		$parameter = 3;
2073cdf0e10cSrcweir		fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2074cdf0e10cSrcweir	}
2075cdf0e10cSrcweir
2076cdf0e10cSrcweir	if ( $tablename eq "ControlEvent" )
2077cdf0e10cSrcweir	{
2078cdf0e10cSrcweir		$tablename_defined = 1;
2079cdf0e10cSrcweir		$parameter = 7;
2080cdf0e10cSrcweir		fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2081cdf0e10cSrcweir	}
2082cdf0e10cSrcweir
2083cdf0e10cSrcweir	if ( $tablename eq "ControlCondition" )
2084cdf0e10cSrcweir	{
2085cdf0e10cSrcweir		$tablename_defined = 1;
2086cdf0e10cSrcweir		$parameter = 5;
2087cdf0e10cSrcweir		fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2088cdf0e10cSrcweir	}
2089cdf0e10cSrcweir
2090cdf0e10cSrcweir	if ( ! $tablename_defined )
2091cdf0e10cSrcweir	{
2092cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $tablename ! Currently supported: InstallUISequence, InstallExecuteSequence, ControlEvent, ControlCondition", "create_customaction_assignment_hash");
2093cdf0e10cSrcweir	}
2094cdf0e10cSrcweir
2095cdf0e10cSrcweir	return $assignmenthashref;
2096cdf0e10cSrcweir}
2097cdf0e10cSrcweir
2098cdf0e10cSrcweir##########################################################################
2099cdf0e10cSrcweir# Finding the position of a specified CustomAction.
2100cdf0e10cSrcweir# If the CustomAction is not found, the return value is "-1".
2101cdf0e10cSrcweir# If the CustomAction position is not defined yet,
2102cdf0e10cSrcweir# the return value is also "-1".
2103cdf0e10cSrcweir##########################################################################
2104cdf0e10cSrcweir
2105cdf0e10cSrcweirsub get_customaction_position
2106cdf0e10cSrcweir{
2107cdf0e10cSrcweir	my ($action, $sequencetable) = @_;
2108cdf0e10cSrcweir
2109cdf0e10cSrcweir	my $position = -1;
2110cdf0e10cSrcweir
2111cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2112cdf0e10cSrcweir	{
2113cdf0e10cSrcweir		my $line = ${$sequencetable}[$i];
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir		if ( $line =~ /^\s*([\w\.]+)\t.*\t\s*(\d+)\s$/ )	# matching only, if position is a number!
2116cdf0e10cSrcweir		{
2117cdf0e10cSrcweir			my $compareaction = $1;
2118cdf0e10cSrcweir			my $localposition = $2;
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir			if ( $compareaction eq $action )
2121cdf0e10cSrcweir			{
2122cdf0e10cSrcweir				$position = $localposition;
2123cdf0e10cSrcweir				last;
2124cdf0e10cSrcweir			}
2125cdf0e10cSrcweir		}
2126cdf0e10cSrcweir	}
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir	return $position;
2129cdf0e10cSrcweir}
2130cdf0e10cSrcweir
2131cdf0e10cSrcweir##########################################################################
2132cdf0e10cSrcweir# Setting the position of CustomActions in sequence tables.
2133cdf0e10cSrcweir# Replacing all occurences of "POSITIONTEMPLATE_"
2134cdf0e10cSrcweir##########################################################################
2135cdf0e10cSrcweir
2136cdf0e10cSrcweirsub set_positions_in_table
2137cdf0e10cSrcweir{
2138cdf0e10cSrcweir	my ( $sequencetable, $tablename ) = @_;
2139cdf0e10cSrcweir
2140b274bc22SAndre Fischer	$installer::logger::Lang->print("\n");
2141b274bc22SAndre Fischer	$installer::logger::Lang->printf("Setting positions in table \"%s\".\n", $tablename);
2142cdf0e10cSrcweir
2143cdf0e10cSrcweir	# Step 1: Resolving all occurences of "POSITIONTEMPLATE_end"
2144cdf0e10cSrcweir
2145cdf0e10cSrcweir	my $lastposition = get_last_position_in_sequencetable($sequencetable);
2146cdf0e10cSrcweir
2147cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2148cdf0e10cSrcweir	{
2149cdf0e10cSrcweir		if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*POSITIONTEMPLATE_end\s*$/ )
2150cdf0e10cSrcweir		{
2151cdf0e10cSrcweir			my $customaction = $1;
2152cdf0e10cSrcweir			$lastposition = $lastposition + 25;
2153cdf0e10cSrcweir			${$sequencetable}[$i] =~ s/POSITIONTEMPLATE_end/$lastposition/;
2154cdf0e10cSrcweir			$infoline = "Setting position \"$lastposition\" for custom action \"$customaction\".\n";
2155b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
2156cdf0e10cSrcweir		}
2157cdf0e10cSrcweir	}
2158cdf0e10cSrcweir
2159cdf0e10cSrcweir	# Step 2: Resolving all occurences of "POSITIONTEMPLATE_abc" or "POSITIONTEMPLATE_behind_abc"
2160cdf0e10cSrcweir	# where abc is the name of the reference Custom Action.
2161cdf0e10cSrcweir	# This has to be done, until there is no more occurence of POSITIONTEMPLATE (success)
2162cdf0e10cSrcweir	# or there is no replacement in one circle (failure).
2163cdf0e10cSrcweir
2164cdf0e10cSrcweir	my $template_exists = 0;
2165cdf0e10cSrcweir	my $template_replaced = 0;
2166cdf0e10cSrcweir	my $counter = 0;
2167cdf0e10cSrcweir
2168cdf0e10cSrcweir	do
2169cdf0e10cSrcweir	{
2170cdf0e10cSrcweir		$template_exists = 0;
2171cdf0e10cSrcweir		$template_replaced = 0;
2172cdf0e10cSrcweir		$counter++;
2173cdf0e10cSrcweir
2174cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2175cdf0e10cSrcweir		{
2176cdf0e10cSrcweir			if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
2177cdf0e10cSrcweir			{
2178cdf0e10cSrcweir				my $onename = $1;
2179cdf0e10cSrcweir				my $templatename = $2;
2180cdf0e10cSrcweir				my $positionname = $templatename;
2181cdf0e10cSrcweir				my $customaction = $templatename;
2182cdf0e10cSrcweir				$customaction =~ s/POSITIONTEMPLATE_//;
2183cdf0e10cSrcweir				$template_exists = 1;
2184cdf0e10cSrcweir
2185cdf0e10cSrcweir				# Trying to find the correct number.
2186cdf0e10cSrcweir				# This can fail, if the custom action has no number
2187cdf0e10cSrcweir
2188cdf0e10cSrcweir				my $setbehind = 0;
2189cdf0e10cSrcweir				if ( $customaction =~ /^\s*behind_(.*?)\s*$/ )
2190cdf0e10cSrcweir				{
2191cdf0e10cSrcweir					$customaction = $1;
2192cdf0e10cSrcweir					$setbehind = 1;
2193cdf0e10cSrcweir				}
2194cdf0e10cSrcweir
2195cdf0e10cSrcweir				my $position = get_customaction_position($customaction, $sequencetable);
2196cdf0e10cSrcweir
2197cdf0e10cSrcweir				if ( $position >= 0 )	# Found CustomAction and is has a position. Otherwise return value is "-1".
2198cdf0e10cSrcweir				{
2199cdf0e10cSrcweir					my $newposition = 0;
2200cdf0e10cSrcweir					if ( $setbehind ) { $newposition = $position + 2; }
2201cdf0e10cSrcweir					else { $newposition = $position - 2; }
2202cdf0e10cSrcweir					${$sequencetable}[$i] =~ s/$templatename/$newposition/;
2203cdf0e10cSrcweir					$template_replaced = 1;
2204cdf0e10cSrcweir					$infoline = "Setting position \"$newposition\" for custom action \"$onename\" (scp: \"$positionname\" at position $position).\n";
2205b274bc22SAndre Fischer					$installer::logger::Lang->print($infoline);
2206cdf0e10cSrcweir				}
2207cdf0e10cSrcweir				else
2208cdf0e10cSrcweir				{
2209cdf0e10cSrcweir					$infoline = "Could not assign position for custom action \"$onename\" yet (scp: \"$positionname\").\n";
2210b274bc22SAndre Fischer					$installer::logger::Lang->print($infoline);
2211cdf0e10cSrcweir				}
2212cdf0e10cSrcweir			}
2213cdf0e10cSrcweir		}
2214cdf0e10cSrcweir	} while (( $template_exists ) && ( $template_replaced ));
2215cdf0e10cSrcweir
2216cdf0e10cSrcweir	# An error occured, because templates still exist, but could not be replaced.
2217cdf0e10cSrcweir	# Reason:
2218cdf0e10cSrcweir	# 1. Wrong name of CustomAction in scp2 (typo?)
2219cdf0e10cSrcweir	# 2. Circular dependencies of CustomActions (A after B and B after A)
2220cdf0e10cSrcweir
2221cdf0e10cSrcweir	# Problem: It is allowed, that a CustomAction is defined in scp2 in a library that is
2222cdf0e10cSrcweir	# part of product ABC, but this CustomAction is not used in this product
2223cdf0e10cSrcweir	# and the reference CustomAction is not part of this product.
2224cdf0e10cSrcweir	# Therefore this cannot be an error, but only produce a warning. The assigned number
2225cdf0e10cSrcweir	# must be the last sequence number.
2226cdf0e10cSrcweir
2227cdf0e10cSrcweir	if (( $template_exists ) && ( ! $template_replaced ))
2228cdf0e10cSrcweir	{
2229cdf0e10cSrcweir		# Giving a precise error message, collecting all unresolved templates
2230cdf0e10cSrcweir		# my $templatestring = "";
2231cdf0e10cSrcweir
2232cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2233cdf0e10cSrcweir		{
2234cdf0e10cSrcweir			if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
2235cdf0e10cSrcweir			{
2236cdf0e10cSrcweir				my $customactionname = $1;
2237cdf0e10cSrcweir				my $fulltemplate = $2;
2238cdf0e10cSrcweir				my $template = $fulltemplate;
2239cdf0e10cSrcweir				$template =~ s/POSITIONTEMPLATE_//;
2240cdf0e10cSrcweir				# my $newstring = $customactionname . " (" . $template . ")";
2241cdf0e10cSrcweir				# $templatestring = $templatestring . $newstring . ", ";
2242cdf0e10cSrcweir				# Setting at the end!
2243cdf0e10cSrcweir				$lastposition = $lastposition + 25;
2244cdf0e10cSrcweir				${$sequencetable}[$i] =~ s/$fulltemplate/$lastposition/;
2245cdf0e10cSrcweir				$infoline = "WARNING: Setting position \"$lastposition\" for custom action \"$customactionname\". Could not find CustomAction \"$template\".\n";
2246b274bc22SAndre Fischer				$installer::logger::Lang->print($infoline);
2247cdf0e10cSrcweir			}
2248cdf0e10cSrcweir		}
2249cdf0e10cSrcweir		# $templatestring =~ s/,\s*$//;
2250cdf0e10cSrcweir
2251cdf0e10cSrcweir		# $infoline = "Error: Saving table \"$tablename\"\n";
2252b274bc22SAndre Fischer		# $installer::logger::Lang->print($infoline);
2253cdf0e10cSrcweir		# print $infoline;
2254cdf0e10cSrcweir		# installer::files::save_file($tablename, $sequencetable);
2255cdf0e10cSrcweir		# installer::exiter::exit_program("ERROR: Unresolved positions in CustomActions in scp2: $templatestring", "set_positions_in_table");
2256cdf0e10cSrcweir	}
2257cdf0e10cSrcweir}
2258cdf0e10cSrcweir
2259cdf0e10cSrcweir##########################################################################
2260cdf0e10cSrcweir# Setting the Windows custom actions into different tables
2261cdf0e10cSrcweir# CustomAc.idt, InstallE.idt, InstallU.idt, ControlE.idt, ControlC.idt
2262cdf0e10cSrcweir##########################################################################
2263cdf0e10cSrcweir
2264cdf0e10cSrcweirsub addcustomactions
2265cdf0e10cSrcweir{
2266cdf0e10cSrcweir	my ($languageidtdir, $customactions, $filesarray) = @_;
2267cdf0e10cSrcweir
2268b274bc22SAndre Fischer	$installer::logger::Lang->print("\n");
2269b274bc22SAndre Fischer	$installer::logger::Lang->add_timestamp("Performance Info: addcustomactions start\n");
2270cdf0e10cSrcweir
2271cdf0e10cSrcweir	my $customactionidttablename = $languageidtdir . $installer::globals::separator . "CustomAc.idt";
2272cdf0e10cSrcweir	my $customactionidttable = installer::files::read_file($customactionidttablename);
2273cdf0e10cSrcweir	my $installexecutetablename = $languageidtdir . $installer::globals::separator . "InstallE.idt";
2274cdf0e10cSrcweir	my $installexecutetable = installer::files::read_file($installexecutetablename);
2275cdf0e10cSrcweir	my $adminexecutetablename = $languageidtdir . $installer::globals::separator . "AdminExe.idt";
2276cdf0e10cSrcweir	my $adminexecutetable = installer::files::read_file($adminexecutetablename);
2277cdf0e10cSrcweir	my $installuitablename = $languageidtdir . $installer::globals::separator . "InstallU.idt";
2278cdf0e10cSrcweir	my $installuitable = installer::files::read_file($installuitablename);
2279cdf0e10cSrcweir	my $controleventtablename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
2280cdf0e10cSrcweir	my $controleventtable = installer::files::read_file($controleventtablename);
2281cdf0e10cSrcweir	my $controlconditiontablename = $languageidtdir . $installer::globals::separator . "ControlC.idt";
2282cdf0e10cSrcweir	my $controlconditiontable = installer::files::read_file($controlconditiontablename);
2283cdf0e10cSrcweir
2284cdf0e10cSrcweir	# Iterating over all Windows custom actions
2285cdf0e10cSrcweir
2286cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$customactions}; $i++ )
2287cdf0e10cSrcweir	{
2288cdf0e10cSrcweir		my $customaction = ${$customactions}[$i];
2289cdf0e10cSrcweir		my $name = $customaction->{'Name'};
2290cdf0e10cSrcweir		my $typ = $customaction->{'Typ'};
2291cdf0e10cSrcweir		my $source = $customaction->{'Source'};
2292cdf0e10cSrcweir		my $target = $customaction->{'Target'};
2293cdf0e10cSrcweir		my $inbinarytable = $customaction->{'Inbinarytable'};
2294cdf0e10cSrcweir		my $gid = $customaction->{'gid'};
2295cdf0e10cSrcweir
2296cdf0e10cSrcweir		my $styles = "";
2297cdf0e10cSrcweir		if ( $customaction->{'Styles'} ) { $styles = $customaction->{'Styles'}; }
2298cdf0e10cSrcweir
2299cdf0e10cSrcweir		my $added_customaction = set_custom_action($customactionidttable, $name, $typ, $source, $target, $inbinarytable, $filesarray, $customactionidttablename, $styles);
2300cdf0e10cSrcweir
2301cdf0e10cSrcweir		if ( $added_customaction )
2302cdf0e10cSrcweir		{
2303cdf0e10cSrcweir			# If the CustomAction was added into the CustomAc.idt, it can be connected to the installation.
2304cdf0e10cSrcweir			# There are currently two different ways for doing this:
2305cdf0e10cSrcweir			# 1. Using "add_custom_action_to_install_table", which adds the CustomAction to the install sequences,
2306cdf0e10cSrcweir			#    which are saved in InstallE.idt and InstallU.idt
2307cdf0e10cSrcweir			# 2. Using "connect_custom_action_to_control" and "connect_custom_action_to_control". The first method
2308cdf0e10cSrcweir			#    connects a CustomAction to a control in ControlE.idt. The second method sets a condition for a control,
2309cdf0e10cSrcweir			#    which might be influenced by the CustomAction. This happens in ControlC.idt.
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir			# Any Windows CustomAction can have a lot of different assignments.
2312cdf0e10cSrcweir
2313cdf0e10cSrcweir			for ( my $j = 1; $j <= 50; $j++ )
2314cdf0e10cSrcweir			{
2315cdf0e10cSrcweir				my $key = "Assignment" . $j;
2316cdf0e10cSrcweir				my $value = "";
2317cdf0e10cSrcweir				if ( $customaction->{$key} )
2318cdf0e10cSrcweir				{
2319cdf0e10cSrcweir					$value = $customaction->{$key};
2320cdf0e10cSrcweir
2321cdf0e10cSrcweir					# in a patch the Assignment can be overwritten by a PatchAssignment
2322cdf0e10cSrcweir					if ( $installer::globals::patch )
2323cdf0e10cSrcweir					{
2324cdf0e10cSrcweir						$patchkey = "PatchAssignment" . $j;
2325cdf0e10cSrcweir						if ( $customaction->{$patchkey} )
2326cdf0e10cSrcweir						{
2327cdf0e10cSrcweir							$value = $customaction->{$patchkey};
2328cdf0e10cSrcweir							$key = $patchkey;
2329cdf0e10cSrcweir						}
2330cdf0e10cSrcweir					}
2331cdf0e10cSrcweir
2332cdf0e10cSrcweir				}
2333cdf0e10cSrcweir				else { last; }
2334cdf0e10cSrcweir
2335cdf0e10cSrcweir				# $value is now a comma separated list
2336cdf0e10cSrcweir				if ( $value =~ /^\s*\(\s*(.*)\s*\);?\s*$/ ) { $value = $1; }
2337cdf0e10cSrcweir				my $assignmentarray = installer::converter::convert_stringlist_into_array(\$value, ",");
2338cdf0e10cSrcweir				my $assignment = create_customaction_assignment_hash($gid, $name, $key, $assignmentarray);
2339cdf0e10cSrcweir
2340cdf0e10cSrcweir				if ( $assignment->{'parameter1'} eq "InstallExecuteSequence" )
2341cdf0e10cSrcweir				{
2342cdf0e10cSrcweir					add_custom_action_to_install_table($installexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installexecutetablename, $styles);
2343cdf0e10cSrcweir				}
2344cdf0e10cSrcweir				elsif ( $assignment->{'parameter1'} eq "AdminExecuteSequence" )
2345cdf0e10cSrcweir				{
2346cdf0e10cSrcweir					add_custom_action_to_install_table($adminexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $adminexecutetablename, $styles);
2347cdf0e10cSrcweir				}
2348cdf0e10cSrcweir				elsif ( $assignment->{'parameter1'} eq "InstallUISequence" )
2349cdf0e10cSrcweir				{
2350cdf0e10cSrcweir					add_custom_action_to_install_table($installuitable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installuitablename, $styles);
2351cdf0e10cSrcweir				}
2352cdf0e10cSrcweir				elsif ( $assignment->{'parameter1'} eq "ControlEvent" )
2353cdf0e10cSrcweir				{
2354cdf0e10cSrcweir					connect_custom_action_to_control($controleventtable, $controleventtablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'}, $assignment->{'parameter6'}, $assignment->{'parameter7'});
2355cdf0e10cSrcweir				}
2356cdf0e10cSrcweir				elsif ( $assignment->{'parameter1'} eq "ControlCondition" )
2357cdf0e10cSrcweir				{
2358cdf0e10cSrcweir					connect_condition_to_control($controlconditiontable, $controlconditiontablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'});
2359cdf0e10cSrcweir				}
2360cdf0e10cSrcweir				else
2361cdf0e10cSrcweir				{
2362cdf0e10cSrcweir					installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $assignmenthashref->{'parameter1'} ! Currently supported: InstallUISequence, InstallESequence, ControlEvent, ControlCondition", "addcustomactions");
2363cdf0e10cSrcweir				}
2364cdf0e10cSrcweir			}
2365cdf0e10cSrcweir		}
2366cdf0e10cSrcweir	}
2367cdf0e10cSrcweir
2368cdf0e10cSrcweir	# Setting the positions in the tables
2369cdf0e10cSrcweir
2370cdf0e10cSrcweir	set_positions_in_table($installexecutetable, $installexecutetablename);
2371cdf0e10cSrcweir	set_positions_in_table($installuitable, $installuitablename);
2372cdf0e10cSrcweir	set_positions_in_table($adminexecutetable, $adminexecutetablename);
2373cdf0e10cSrcweir
2374cdf0e10cSrcweir	# Saving the files
2375cdf0e10cSrcweir
2376cdf0e10cSrcweir	installer::files::save_file($customactionidttablename, $customactionidttable);
2377cdf0e10cSrcweir	installer::files::save_file($installexecutetablename, $installexecutetable);
2378cdf0e10cSrcweir	installer::files::save_file($adminexecutetablename, $adminexecutetable);
2379cdf0e10cSrcweir	installer::files::save_file($installuitablename, $installuitable);
2380cdf0e10cSrcweir	installer::files::save_file($controleventtablename, $controleventtable);
2381cdf0e10cSrcweir	installer::files::save_file($controlconditiontablename, $controlconditiontable);
2382cdf0e10cSrcweir
2383cdf0e10cSrcweir	my $infoline = "Updated idt file: $customactionidttablename\n";
2384b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2385cdf0e10cSrcweir	$infoline = "Updated idt file: $installexecutetablename\n";
2386b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2387cdf0e10cSrcweir	$infoline = "Updated idt file: $adminexecutetablename\n";
2388b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2389cdf0e10cSrcweir	$infoline = "Updated idt file: $installuitablename\n";
2390b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2391cdf0e10cSrcweir	$infoline = "Updated idt file: $controleventtablename\n";
2392b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2393cdf0e10cSrcweir	$infoline = "Updated idt file: $controlconditiontablename\n";
2394b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2395cdf0e10cSrcweir
2396b274bc22SAndre Fischer	$installer::logger::Lang->print("\n");
2397b274bc22SAndre Fischer	$installer::logger::Lang->add_timestamp("Performance Info: addcustomactions end\n");
2398cdf0e10cSrcweir}
2399cdf0e10cSrcweir
2400cdf0e10cSrcweir##########################################################################
2401cdf0e10cSrcweir# Setting bidi attributes in idt tables
2402cdf0e10cSrcweir##########################################################################
2403cdf0e10cSrcweir
2404cdf0e10cSrcweirsub setbidiattributes
2405cdf0e10cSrcweir{
2406cdf0e10cSrcweir	my ($languageidtdir, $onelanguage) = @_;
2407cdf0e10cSrcweir
2408cdf0e10cSrcweir	# Editing the files Dialog.idt and Control.idt
2409cdf0e10cSrcweir
2410cdf0e10cSrcweir	my $dialogfilename = $languageidtdir . $installer::globals::separator . "Dialog.idt";
2411cdf0e10cSrcweir	my $controlfilename = $languageidtdir . $installer::globals::separator . "Control.idt";
2412cdf0e10cSrcweir
2413cdf0e10cSrcweir	my $dialogfile = installer::files::read_file($dialogfilename);
2414cdf0e10cSrcweir	my $controlfile = installer::files::read_file($controlfilename);
2415cdf0e10cSrcweir
2416cdf0e10cSrcweir	# Searching attributes in Dialog.idt and adding "896".
2417cdf0e10cSrcweir	# Attributes are in column 6 (from 10).
2418cdf0e10cSrcweir
2419cdf0e10cSrcweir	my $bidiattribute = 896;
2420cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dialogfile}; $i++ )
2421cdf0e10cSrcweir	{
2422cdf0e10cSrcweir		if ( $i < 3 ) { next; }
2423cdf0e10cSrcweir		if ( ${$dialogfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
2424cdf0e10cSrcweir		{
2425cdf0e10cSrcweir			my $one = $1;
2426cdf0e10cSrcweir			my $two = $2;
2427cdf0e10cSrcweir			my $three = $3;
2428cdf0e10cSrcweir			my $four = $4;
2429cdf0e10cSrcweir			my $five = $5;
2430cdf0e10cSrcweir			my $attribute = $6;
2431cdf0e10cSrcweir			my $seven = $7;
2432cdf0e10cSrcweir			my $eight = $8;
2433cdf0e10cSrcweir			$attribute = $attribute + $bidiattribute;
2434cdf0e10cSrcweir			${$dialogfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$attribute\t$seven\t$eight\n";
2435cdf0e10cSrcweir		}
2436cdf0e10cSrcweir	}
2437cdf0e10cSrcweir
2438cdf0e10cSrcweir	# Searching attributes in Control.idt and adding "224".
2439cdf0e10cSrcweir	# Attributes are in column 8 (from 12).
2440cdf0e10cSrcweir
2441cdf0e10cSrcweir	$bidiattribute = 224;
2442cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$controlfile}; $i++ )
2443cdf0e10cSrcweir	{
2444cdf0e10cSrcweir		if ( $i < 3 ) { next; }
2445cdf0e10cSrcweir		if ( ${$controlfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
2446cdf0e10cSrcweir		{
2447cdf0e10cSrcweir			my $one = $1;
2448cdf0e10cSrcweir			my $two = $2;
2449cdf0e10cSrcweir			my $three = $3;
2450cdf0e10cSrcweir			my $four = $4;
2451cdf0e10cSrcweir			my $five = $5;
2452cdf0e10cSrcweir			my $six = $6;
2453cdf0e10cSrcweir			my $seven = $7;
2454cdf0e10cSrcweir			my $attribute = $8;
2455cdf0e10cSrcweir			my $nine = $9;
2456cdf0e10cSrcweir			my $ten = $10;
2457cdf0e10cSrcweir			my $eleven = $11;
2458cdf0e10cSrcweir			my $twelve = $12;
2459cdf0e10cSrcweir			$attribute = $attribute + $bidiattribute;
2460cdf0e10cSrcweir			${$controlfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$six\t$seven\t$attribute\t$nine\t$ten\t$eleven\t$twelve\n";
2461cdf0e10cSrcweir		}
2462cdf0e10cSrcweir	}
2463cdf0e10cSrcweir
2464cdf0e10cSrcweir	# Saving the file
2465cdf0e10cSrcweir
2466cdf0e10cSrcweir	installer::files::save_file($dialogfilename, $dialogfile);
2467cdf0e10cSrcweir	$infoline = "Set bidi support in idt file \"$dialogfilename\" for language $onelanguage\n";
2468b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2469cdf0e10cSrcweir
2470cdf0e10cSrcweir	installer::files::save_file($controlfilename, $controlfile);
2471cdf0e10cSrcweir	$infoline = "Set bidi support in idt file \"$controlfilename\" for language $onelanguage\n";
2472b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
2473cdf0e10cSrcweir}
2474cdf0e10cSrcweir
2475cdf0e10cSrcweir1;
2476