1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2010 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28package installer::windows::inifile; 29 30use installer::existence; 31use installer::files; 32use installer::globals; 33use installer::windows::idtglobal; 34 35#################################################### 36# Setting the profile for a special profileitem 37#################################################### 38 39sub get_profile_for_profileitem 40{ 41 my ($profileid, $filesref) = @_; 42 43 my $profile = installer::existence::get_specified_file($filesref, $profileid); 44 45 return $profile; 46} 47 48#################################################### 49# Checking whether profile is included in patch 50#################################################### 51 52sub profile_has_patch_flag 53{ 54 my ($profile) = @_; 55 56 my $in_patch = 0; 57 58 my $styles = ""; 59 if ( $profile->{'Styles'} ) { $styles = $profile->{'Styles'}; } 60 if ( $styles =~ /\bPATCH\b/ ) { $in_patch = 1; } 61 62 return $in_patch; 63} 64 65#################################################### 66# Checking whether profile is part of product 67#################################################### 68 69sub file_is_part_of_product 70{ 71 my ($profilegid, $filesref) = @_; 72 73 my $part_of_product = 0; 74 75 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 76 { 77 $onefile = ${$filesref}[$i]; 78 my $filegid = $onefile->{'gid'}; 79 80 if ( $filegid eq $profilegid ) 81 { 82 $part_of_product = 1; 83 last; 84 } 85 } 86 87 return $part_of_product; 88} 89 90########################################################################################################### 91# Creating the file IniFile.idt dynamically 92# Content: 93# IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_ 94########################################################################################################### 95 96sub create_inifile_table 97{ 98 my ($inifiletableentries, $filesref, $basedir) = @_; 99 100 my @inifiletable = (); 101 102 installer::windows::idtglobal::write_idt_header(\@inifiletable, "inifile"); 103 104 for ( my $i = 0; $i <= $#{$inifiletableentries}; $i++ ) 105 { 106 my $profileitem = ${$inifiletableentries}[$i]; 107 108 my $profileid = $profileitem->{'ProfileID'}; 109 110 # Is this profile part of the product? This is not sure, for example in patch process. 111 # If the profile is not part of the product, this ProfileItem must be ignored. 112 113 if ( ! file_is_part_of_product($profileid, $filesref) ) { next; } 114 115 my $profile = get_profile_for_profileitem($profileid, $filesref); 116 117 if (( $installer::globals::patch ) && ( ! profile_has_patch_flag($profile) )) { next; } 118 119 my %inifile = (); 120 121 $inifile{'IniFile'} = $profileitem->{'Inifiletablekey'}; 122 $inifile{'FileName'} = $profile->{'Name'}; 123 $inifile{'DirProperty'} = $profile->{'uniquedirname'}; 124 $inifile{'Section'} = $profileitem->{'Section'}; 125 $inifile{'Key'} = $profileitem->{'Key'}; 126 $inifile{'Value'} = $profileitem->{'Value'}; 127 $inifile{'Action'} = $profileitem->{'Inifiletableaction'}; 128 $inifile{'Component_'} = $profile->{'componentname'}; 129 130 my $oneline = $inifile{'IniFile'} . "\t" . $inifile{'FileName'} . "\t" . $inifile{'DirProperty'} . "\t" 131 . $inifile{'Section'} . "\t" . $inifile{'Key'} . "\t" . $inifile{'Value'} . "\t" 132 . $inifile{'Action'} . "\t" . $inifile{'Component_'} . "\n"; 133 134 push(@inifiletable, $oneline); 135 } 136 137 # Saving the file 138 139 my $inifiletablename = $basedir . $installer::globals::separator . "IniFile.idt"; 140 installer::files::save_file($inifiletablename ,\@inifiletable); 141 my $infoline = "Created idt file: $inifiletablename\n"; 142 push(@installer::globals::logfileinfo, $infoline); 143 144} 145 1461; 147