# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1261034974 -7200 # Node ID 1bad536211fdf69c29e04c0e55a7f4ecae1821a8 Revision: 200949 Kit: 200951 diff -r 000000000000 -r 1bad536211fd dtdinstaller/bin/convert_file.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dtdinstaller/bin/convert_file.pm Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,399 @@ +# +# Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +package Convert_file; + +# Hash of file meta information (name etc.). +my %file_meta_info; + +# List of logical name entries. +my @entries = (); + +sub convert_file { + my $file_to_process = shift; + + %file_meta_info = (); + @entries = (); + + # Convert LOC file to DTD... + if ($file_to_process =~ /\.loc$/) { + (my $file_to_write = $file_to_process) =~ s/\.loc$/.dtd/; + (my $file_log = $file_to_process) =~ s/\.loc$/.log/; + &read_loc_file($file_to_process); + &write_dtd_file($file_to_process, $file_to_write, $file_log); + } + # Convert DTD file to LOC... + elsif ($file_to_process =~ /\.dtd$/) { + (my $file_to_write = $file_to_process) =~ s/\.dtd$/.loc/; + (my $file_log = $file_to_process) =~ s/\.dtd$/.log/; + &read_dtd_file($file_to_process); + &write_loc_file($file_to_process, $file_to_write, $file_log); + } + else { + print "Unknown file format.\n"; + } +} + +# This subroutine reads DTD file into a data structure. Reading is done line +# by line. +# Adding extra complexity to this subroutine is the fact that ENTITY tag can +# either be declared before attribute definitions or after them. +sub read_dtd_file { + my $file_to_process = shift; + + open(FILE, $file_to_process) + or die "Can't open `$file_to_process' for reading: $!"; + + my %entry; + my $attribute_read = "FALSE"; + my $entity_read = "FALSE"; + + while (my $line = ) { + # NCR notation is used in DTD files. This is removed since it's not + # used in LOC files. + #&remove_NCR_notation(\$line); + chomp($line); + + SWITCH: { + # Extract file meta data. + # Matches eg. "> + if ($line =~ /\s*( ""> + if ($line =~ /\s* attributes -> entity + if ($attribute_read eq "TRUE" && $entity_read eq "TRUE") { + my %temp = %entry; + %entry = (); + push @entries, \%temp; + $attribute_read = "FALSE"; + $entity_read = "TRUE"; + + (my $loc_name, my $translation) = + $line =~ /\s* entity + elsif ($attribute_read eq "TRUE" && $entity_read eq "FALSE") { + (my $loc_name, my $translation) = + $line =~ /\s*.layout "" + if ($line =~ /\s*.[^\.]*(.layout|.description|.recycled|.release|.grammar|.term|.refers|.islocalizable|.item_type|.action_before|.action_after|.variables|.parents)\s*".[^"]*/) { + (my $item_name, my $content) = + $line =~ /\s*.[^\.]*.(.[^\s]*)\s*"(.[^"]*)/; + + $item_name =~ s/parents/Parents/; + $item_name =~ s/variables/Variables/; + + $entry{$item_name} = $content; + last SWITCH; + } + # Matches attribute tag. + if ($line =~ /\s*.[^\.]*.attributes/) { + # Case: entity -> attributes -> attributes + if ($entity_read eq "TRUE" && $attribute_read eq "TRUE") { + my %temp = %entry; + %entry = (); + push @entries, \%temp; + $entity_read = "FALSE"; + } + $attribute_read = "TRUE"; + + last SWITCH; + } + } + } + + # Include last entry also to results. This happens if file ends with an + # entry where attributes are defined after ENTITY. + if ($attribute_read eq "TRUE" && $entity_read eq "TRUE") { + my %temp = %entry; + %entry = (); + push @entries, \%temp; + } + + close FILE; +} + +# This subroutine reads LOC file into a data structure. Reading is done line +# by line. +sub read_loc_file { + my $file_to_process = shift; + + chmod ($file_to_process, 0777); # Make sure that file can be read, before trying to open it + + open(FILE, $file_to_process) + or die "Can't open `$file_to_process' for reading: $!"; + + my %entry; + + while (my $line = ) { + # NCR notation is used in DTD files. Not allowed characters are + # converted to NCR. + #&add_NCR_notation(\$line); + chomp($line); + + # Each line with #define defines a logical name/translation pair. This + # is saved to the data structure. + if ($line =~ /\s*#define\s*.[^\s]*\s*".[^"]*/) { + (my $item_name, my $content) = + $line =~ /\s*#define\s*(.[^\s]*)\s*"(.*)"$/; + + $entry{'logical_name'} = $item_name; + $entry{'translation'} = $content; + my %temp = %entry; + %entry = (); + push @entries, \%temp; + } + } + + close FILE; +} + +# This subroutine writes the data into a LOC file. +sub write_loc_file { + my $file_to_process = shift; + my $file_to_write = shift; + my $file_log = shift; + + open(my $file_handle, ">$file_to_write") + or die "Can't open `$file_to_write' for writing: $!"; + + open(my $log_file_handle, ">$file_log") + or die "Can't open `$file_log' for writing: $!"; + + my $tstamp = localtime(time); + + print $log_file_handle "Log created $tstamp:\n" . + "Errors and warnings for conversion of " . + "$file_to_process to $file_to_write\n\n"; + + # Write file header info. Mostly static text. + &write_loc_header($file_handle); + + print $file_handle "\n"; + + # This array defines the order in which attributes are written to a LOC + # file. + my @fields = ("item_type", "action_before", "action_after", "grammar", + "refers", "Parents", "Variables"); + + for my $i (0 .. $#entries) { + # Analyze entry for correctness and report possible errors. + &print_dtd_errors_and_warnings(\%{$entries[$i]}, $log_file_handle); + + # Seach for attributes and write them to output if found. + for my $y (0 .. $#fields) { + if (exists($entries[$i]{$fields[$y]})) { + print $file_handle + "//d: [$fields[$y]] : \"$entries[$i]{$fields[$y]}\"\n"; + } + } + + print $file_handle "//d: $entries[$i]{'description'}\n"; + print $file_handle "//l: $entries[$i]{'layout'}\n"; + print $file_handle "//r: $entries[$i]{'release'}\n"; + + print $file_handle "#define $entries[$i]{'logical_name'}" . + " \"$entries[$i]{'translation'}\"\n\n"; + } + + close $file_handle; + close $log_file_handle; +} + +sub print_dtd_errors_and_warnings { + my $entry_ref = shift; + my $log_file_handle = shift; + + # Either description or item_type and action_before should be defined. + if (!exists($entry_ref->{'description'}) && + !(exists($entry_ref->{'item_type'}) && + exists($entry_ref->{'action_before'}))) + { + print $log_file_handle "ERROR: $entry_ref->{'logical_name'} " . + "does not have any description data!\n"; + } + if (!exists($entry_ref->{'layout'})) { + print $log_file_handle "ERROR: $entry_ref->{'logical_name'} " . + "missing layout definition!\n"; + } + if (!exists($entry_ref->{'release'})) { + print $log_file_handle "ERROR: $entry_ref->{'logical_name'} " . + "missing release information!\n"; + } + if (!exists($entry_ref->{'Parents'})) { + print $log_file_handle "ERROR: $entry_ref->{'logical_name'} " . + "missing parent reference!\n"; + } + # Grammar should be defined if translation is a single word. + if (!($entry_ref->{'translation'} =~ /\s/) && + !exists($entry_ref->{'grammar'})) { + print $log_file_handle "\tWARNING: $entry_ref->{'logical_name'} " . + "is a single word, but no grammar data is " . + "given!\n"; + } + # Variables should be defined if translation contains variables. + if ($entry_ref->{'translation'} =~ /\%/ && + !exists($entry_ref->{'Variables'})) { + print $log_file_handle "\tWARNING: $entry_ref->{'logical_name'} " . + "has a variable or parameter, but no variable " . + "data is given!\n"; + } +} + +# This subroutine writes the data into a DTD file. Only ENTITY definitions are +# written i.e. no attribute definitions. +sub write_dtd_file { + my $file_to_process = shift; + my $file_to_write = shift; + my $file_log = shift; + + open(my $file_handle, ">$file_to_write") + or die "Can't open `$file_to_write' for writing: $!"; + + open(my $log_file_handle, ">$file_log") + or die "Can't open `$file_log' for writing: $!"; + + my $tstamp = localtime(time); + + print $log_file_handle "Log created $tstamp:\n" . + "Errors and warnings for conversion of " . + "$file_to_process to $file_to_write\n\n"; + + # Write file header info. Mostly static text. + my $file_name = ""; + if ($file_to_process =~ /\//) { + ($file_name) = $file_to_process =~ /\/(.[^\/]*)$/; + } + else { + $file_name = $file_to_process; + } + &write_dtd_header($file_handle, $file_name); + + for my $i (0 .. $#entries) { + print $log_file_handle "Found $entries[$i]{'logical_name'}\n"; + + $entries[$i]{'translation'} =~ s/\\"/"/g; + + print $file_handle "\n"; + } + + close $file_handle; + close $log_file_handle; +} + +sub write_loc_header { + my $file_handle = shift; + print $file_handle < + +EOT +} + +# Subroutine to add NCR notation to string. +sub add_NCR_notation { + my $string = shift; + # Replace characters with NCR notation. 'eh' is used to denote &# character + # sequence. If this is not used then &# sequence would be also replaced with + # NCR. + $$string =~ s/'/eh39;/g; + $$string =~ s/\%/eh37;/g; + $$string =~ s/>/eh62;/g; + $$string =~ s//g; + $$string =~ s/</ '/epoc32/tools'; +use lib LIBPATH; + +use Cwd; +use Getopt::Long; +use Convert_file; # for .dtd to .loc file conversion +use File::Copy; +use File::Find; # for finding +use File::Path; # mkpath +use File::Basename; # fileparse + +if ( $#ARGV < 1) + { + print <\\loc + -s: optional, for widgets only, default are xuikon and hsps + -o: optional, default is \\epoc32\\release\\winscw\\udeb\\z\\private\\200159c0\\install + -a: optional, default is build other possible are what and clean + -f: optional, for widgets only, themeinstaller is always run for xuikon, even switch loc file don\'t exist + -d: optional, for debugging purposes (e.g. temporary folders aren't deleted) + +Example how to run for dtd files only: + dtd_installer.pl -n matrixmenudata -o \\epoc32\\data\\z\\private\\200113DD\\content +Example how to run for one widget: + dtd_installer.pl -n view -t type widget +Example how to run for all widgets: + dtd_installer.pl -n all_widgets -t type widget -d yes + +USAGE + exit -1; + } + +my ($dtd_name, $dtd_type, $dtd_location, $sub_folder_name, $output_location, $action_type, $force_create, $debug, $what_output_file); +my (@all_dirs, @find_files, @files_to_convert); +my @sub_folders=("xuikon","hsps"); +my @layers=("\\epoc32\\include\\domain\\osextensions\\loc", "\\epoc32\\include\\domain\\middleware\\loc", "\\epoc32\\include\\domain\\applications\\loc", "\\epoc32\\include\\platform\\loc", "\\epoc32\\include\\platform\\mw\\loc", "\\epoc32\\include\\platform\\app\\loc"); +my $themeinstaller_tool = "\\epoc32\\tools\\themeinstaller\\themeinstaller.bat"; +my $themeinstaller_property_file = "\\epoc32\\tools\\themeinstaller\\data\\widgetinstaller.prop"; + +# Set this to 1 if you need to debug the script +# $debug = 1; + +GetOptions( + 'n=s' => \$dtd_name, + 't=s' => \$dtd_type, + 'l=s' => \$dtd_location, + 's=s' => \$sub_folder_name, + 'o=s' => \$output_location, + 'a=s' => \$action_type, + 'd=s' => \$debug, + 'f=s' => \$force_create ); + +check_options(); + +if (($action_type eq "what") && (-e $what_output_file)) { + open( WHAT, $what_output_file) or die $!; + while( ){ + print ; + } + close WHAT; + exit; +} elsif (($action_type eq "clean") && (-e $what_output_file)) { + unlink $what_output_file; +} + +if ($dtd_type eq "widget") { + if ((lc $dtd_name) eq "all_widgets") { + # read all widget names from given directory + opendir(SDIR, $dtd_location) or die("ERROR: dtd_installer.pl, can not open $dtd_location\n"); + @all_dirs = grep !/^\.\.?$/, readdir SDIR; + closedir(SDIR); + if (!@all_dirs) { + warn"ERROR: dtd_installer.pl, couldn't find any widgets:\n"; + die; + } + foreach my $temp_dtd_name (@all_dirs) { + $dtd_name = $temp_dtd_name; + my $dir = "${dtd_location}\\${dtd_name}"; + if (-d $dir) { # Calling process_widget sub routine for every directory + process_widget(); + } + } + } else { # Only one widget processed + process_widget(); + } +} else { + # Run only .loc to .dtd conversion for non widgets + process_dtd($output_location, $dtd_name); +} + +sub process_widget +{ + + foreach my $sub_f (@sub_folders) { + my @lang_dirs; + if ($debug) { print "Current subfolder:\n $sub_f\n"; } + ${sub_folder_name} = $sub_f; + if ($debug) { print "Processing widget:\n${dtd_location}\\${dtd_name}\n"; } + + my $current_time = time; + my $full_dtd_input_path = "${dtd_location}\\${dtd_name}\\${sub_folder_name}"; + my $full_dtd_output_path = "${output_location}\\${dtd_name}\\${sub_folder_name}"; + my $temp_path = "${dtd_location}\\${dtd_name}\\temp"; + my $temp_loc_path = "${dtd_location}\\${dtd_name}\\${sub_folder_name}\\temp"; + my $temp_dtd_path = "${temp_path}\\$current_time"; + my $temp_loc_files_path = "${temp_loc_path}\\$current_time"; + my $no_success = 1; + my $count = 0; + + while ($no_success) { # make sure that temporary directory isn't already in the use + undef $no_success; + $current_time = time; + $temp_dtd_path = "${temp_path}\\$current_time"; + mkpath $temp_dtd_path or $no_success=1; + sleep 1; + $count++; + if ($count > 100 ) { warn: "ERROR: dtd_installer.pl, couldn't create temp directory $temp_dtd_path !!!\nDtd_installer\.pl script stopped\n"; die;} + } + $count = 0; + $no_success = 1; + while ($no_success) { # make sure that temporary directory isn't already in the use + undef $no_success; + $current_time = time; + $temp_loc_files_path = "${temp_loc_path}\\$current_time"; + mkpath $temp_loc_files_path or $no_success=1; + sleep 1; + $count++; + if ($count > 100 ) { warn: "ERROR: dtd_installer.pl, couldn't create temp directory $temp_loc_files_path!!!\nDtd_installer\.pl script stopped\n"; die;} + } + + if ($debug) { print "Full dtd input path:\n$full_dtd_input_path\n"; } + if ($debug) { print "Full dtd output path:\n$full_dtd_output_path\n"; } + opendir(SDIR, $full_dtd_input_path) or die("ERROR: dtd_installer.pl, can not open $full_dtd_input_path\n"); + @lang_dirs = grep !/^\.\.?$/, readdir SDIR; + closedir(SDIR); + + + if (${sub_folder_name} eq "xuikon") { # Copy engineering english files always to 00 folder + copy_files($full_dtd_input_path,"${temp_loc_files_path}\\00"); + } else{ #hsps folder + copy_files($full_dtd_input_path,"${full_dtd_output_path}\\00"); + } + + + foreach my $lang_id (@lang_dirs) { # generate localized .dtd files + + my $dtd_temp = "${full_dtd_input_path}\\${lang_id}"; + if ((-f $dtd_temp) && ($lang_id =~ /.dtd/i) ) { # running loc to dtd for all .dtd files + if ($debug) { print "Dtd file found:\n$dtd_temp\n"; } + + if (${sub_folder_name} eq "xuikon") { # generate xuikon .dtd files to temp path + if ($debug) { print "Widget type DTD, xuikon subfolder\n"; } + process_dtd($temp_loc_files_path, $lang_id); + } else{ #hsps folder + if ($debug) { print "Widget type DTD, hsps subfolder\n"; } + process_dtd($full_dtd_output_path, $lang_id); + } + } elsif ((${sub_folder_name} eq "xuikon") && ($force_create ne "") && (-d $dtd_temp)) { + copy_files($dtd_temp,"${temp_loc_files_path}\\${lang_id}"); + } + } + + if (${sub_folder_name} eq "xuikon") { # generate localized files + if (!(-f $themeinstaller_tool)) { die("ERROR: dtd_installer.pl, can not find themeinstaller: $themeinstaller_tool\n"); } + if (!(-f $themeinstaller_property_file)) { die("ERROR: dtd_installer.pl, can not find themeinstaller property file: $themeinstaller_property_file\n"); } + + if (-d $temp_loc_files_path) { + opendir(SDIR, $temp_loc_files_path) or die("ERROR: dtd_installer.pl, can not open $temp_loc_files_path\n"); + @lang_dirs = grep !/^\.\.?$/, readdir SDIR; + closedir(SDIR); + + foreach my $lang_id (@lang_dirs) { + my $lang_dir = "$temp_loc_files_path\\$lang_id"; + if ($debug) { print"Language directory:\n$lang_dir\n"; } + if (-d $lang_dir) { # Running themeinstaller for all language folders in temp path + my $temp_dir = "$temp_dtd_path\\$lang_id"; + copy_files($full_dtd_input_path, "$temp_dir"); + my $lang_temp_dir = "$full_dtd_input_path\\$lang_id"; + if (-d $lang_temp_dir) { + copy_files("$lang_temp_dir", "$temp_dir"); + } + copy_files("$temp_loc_files_path\\$lang_id", "$temp_dir"); + if (($action_type eq "build") || ($debug)) { + print ("Calling themeinstaller: \n$themeinstaller_tool $temp_dtd_path\\${lang_id}\\${dtd_name}.dat $temp_dtd_path\\${lang_id} -prop:${themeinstaller_property_file}\n"); + system ("$themeinstaller_tool","$temp_dtd_path\\${lang_id}\\${dtd_name}.dat","$temp_dtd_path\\${lang_id}", "-prop:${themeinstaller_property_file}"); + } else { + system ("$themeinstaller_tool","$temp_dtd_path\\${lang_id}\\${dtd_name}.dat","$temp_dtd_path\\${lang_id}", "-prop:${themeinstaller_property_file}", ">$temp_dtd_path\\${lang_id}\\themeinstaller.log", "2>&1" ); + } + copy_files("$temp_dir", "$full_dtd_output_path\\$lang_id", "recursive"); + } + } + } + } + + if ($debug) { + print "Widget processed: ${dtd_name} \n"; + } else { + # Remove all temporary directories + if (-d $temp_dtd_path) { rmtree ($temp_dtd_path); } + if (-d $temp_loc_files_path) { rmtree ($temp_loc_files_path); } + rmdir $temp_path; + rmdir $temp_loc_path; + } + } +} + +sub process_dtd { + + my $output_path = shift; + my $switch_loc_name = shift; + $switch_loc_name =~ s/.dtd//i;; # remove the .dtd extension + my $input_path = $dtd_location; + my ($found, $loc_file); + if ($action_type eq "build") { print "Used switch loc file name:\n${switch_loc_name}\n"; } + if ($debug) { print "Used input path:\n${input_path}\n"; } + if ($debug) { print "Used output path:\n${output_path}\n"; } + + foreach (@layers) { + $input_path = $_; + if ($debug) { print("Used switch loc file path:\n${input_path}\n"); } + my $loc_file = "${input_path}\\${switch_loc_name}.loc"; + if (-e $loc_file) { + convert_locs_to_dtds($loc_file, $input_path, $output_path); + $found = "yes"; + } + } + if ($found ne "yes") { + warn "ERROR: dtd_installer.pl, no .loc file found:\n${switch_loc_name}.loc\n"; + } +} + +sub check_options { + + if ($dtd_name eq "") { + warn: "ERROR: dtd_installer.pl, no widget name given!!!\nDtd_installer\.pl script stopped\n"; + die; + } + + if ($dtd_type eq "") { + $dtd_type = "dtd"; + } + + if ($dtd_location eq "") { + if ($dtd_type eq "widget") { + $dtd_location = "\\epoc32\\data\\z\\resource\\homescreen"; + } + } else { + if ($dtd_type eq "dtd") { + undef @layers; + @layers[0]=${dtd_location}; + } + } + + if ($output_location eq "") { + $output_location = "\\epoc32\\release\\winscw\\udeb\\z\\private\\200159c0\\install"; + } + + if (${sub_folder_name} ne ""){ + undef @sub_folders; + @sub_folders[0]=${sub_folder_name}; + } + + if ($action_type eq "") { + $action_type = "build"; + } + + $dtd_location =~ s/\//\\/g; #Change / marks to \ + $output_location =~ s/\//\\/g; #Change / marks to \ + $what_output_file = $output_location; + $what_output_file =~ s/\\/_/g; #Change \ marks to _ + $what_output_file = "\\epoc32\\build\\dtd_installer\\" . $what_output_file . $dtd_name . ".txt"; + if ( !-d "/epoc32/build/dtd_installer") { mkdir("/epoc32/build/dtd_installer"); } + if ($debug) { print "Output what file: $what_output_file\n"; } +} + +# This subroutine moves files to/from temporary themeinstaller location. +sub copy_files { + my $in_path = shift; + my $out_path = shift; + my $recursive = shift; + if ($debug) { print "Copying from: $in_path\n"; } + if ($debug) { print "To: $out_path\n"; } + + if ($recursive) { + find( \&getFiles, $in_path ); + } else { + opendir(SDIR, $in_path) or die("ERROR: dtd_installer.pl, can not open $in_path\n"); + @find_files = grep !/^\.\.?$/, readdir SDIR; + closedir(SDIR); + } + + foreach my $file (@find_files) { + my $in_file = "${in_path}\\${file}"; + my $out_file= "${out_path}\\${file}"; + if ($recursive) { + $in_file = $file; + $file =~ /.*\\(.*)\\.*\\.*\\.*\\(.*)\\(.*)/i; + my $temp=$1; # lang code + my $temp2=$3; # file name + if ((lc $2) eq "sources") { + $out_file = "${out_path}\\$2\\$3"; + } else { + if (length($temp) > 4) { #skip extra files + next; + } + while (length($temp) < 4){ $temp = "0".$temp; } + $temp2 =~ s/\d{4}/$temp/g; # change .odt filename for correct lang + $out_file = "${out_path}\\$temp2"; + } + } + if ($debug) { print "Copying file from: $in_file\n"; } + if ($debug) { print "To: $out_file\n"; } + if (-f $in_file){ + if ($action_type eq "build") { + if ((!($out_file =~ /\\temp\\/i))) {write_what_file("$out_file")}; + xcopy($in_file,$out_file); + } elsif ($action_type eq "clean") { + if (!($out_file =~ /\\temp\\/i)) { + unlink $out_file; + my $temp_dir_path = $out_file; + $temp_dir_path =~ /(.*)\\.*/; + $temp_dir_path = $1; + rmdir $temp_dir_path; # Try to remove empty language directories + } else { + xcopy($in_file,$out_file); + } + } elsif ($action_type eq "what") { + if (!($out_file =~ /\\temp\\/i)) { + write_what_file("$out_file"); + print("$out_file\n"); + } else { + xcopy($in_file,$out_file); + } + } else { + warn ("ERROR: dtd_installer.pl, unknown action type"); + } + } else { + if ($debug) { print "Not file found: $in_file\n"; } + } + } +} + +# This subroutine converts LOC files to DTD files. Files that are +# listed in the switch_loc file are converted to DTD files. + +sub convert_locs_to_dtds { + my $switch_loc_file = shift; + my $in_path = shift; + my $out_path = shift; + + open(my $switch_loc_file_handle, "$switch_loc_file") + or die "Can't open `$switch_loc_file' for reading: $!"; + + # Read localised .loc file names from used input switch loc file + while (my $line = <$switch_loc_file_handle>) { + chomp($line); + if (($line =~ "include") && (!($line =~ /\.*/; + $line=$1; + $line =~ s/\//\\/g; #Change / marks to \ + if ($debug) { print"Adding localised file to conversion list:\n$line\n"; } + push @files_to_convert, $line; + } + } + + close $switch_loc_file_handle; + + # Process all the .loc files. + foreach (@files_to_convert) { + my $loc_file = "$in_path\\$_"; + my $out_file = "$out_path\\$_"; + $out_file =~ s/_\d{2,5}(.{4})$/$1/i; # remove the language code from the file name. + if ($debug) { print"Trying to convert file:\n$loc_file\n"; } + if ($debug) { print"To out file:\n$out_file\n"; } + if (-f $loc_file) { + if (($action_type eq "build") || ((${dtd_type} eq "widget") && (${sub_folder_name} eq "xuikon")) ) { +#old if ((!($out_file =~ /\\temp\\/i))) {write_what_file("$out_file")}; + xcopy($loc_file,$out_file); + Convert_file::convert_file($out_file); + if ((!($out_file =~ /\\temp\\/i))) { + my $convert_out_file = $out_file; + $convert_out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd + write_what_file("$convert_out_file"); + } + if (!($debug)) { unlink $out_file; } # Delete the copied .loc file + $out_file =~ s/\.loc/\.log/; # replace .loc with .log + if (!($debug)) { unlink $out_file; } # Delete the conversion .log file + } elsif ($action_type eq "clean") { + $out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd + unlink $out_file; # delete the output file + my $temp_dir_path = $out_file; + $temp_dir_path =~ /(.*)\\.*/; + $temp_dir_path = $1; + rmdir $temp_dir_path; # Try to remove empty language directories + } elsif (($action_type eq "what") && (!($out_file =~ /\\temp\\/i))) { + $out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd + print("$out_file\n"); + write_what_file("$out_file"); + } + } else { + warn "ERROR: dtd_installer.pl, no .loc file found: $loc_file\n"; + } + } +} + +# This subroutine is for file copying +sub xcopy +{ + my $source = shift; + my $dist = shift; + + # if distination file exist then clear read flag + if (-f $dist) + { + chmod ($dist , 0755); + } + else + { + my($n, $d, $ext) = fileparse($dist, '\..*'); + # check weather distination directory exist or not. If directory doesn't exist then create it. + -d $d || mkpath($d, 0, 0x755); + } + + # copy source to distination + copy($source,$dist); +} + +# read files from given path to filelist +sub getFiles { + my $file_name = $File::Find::name; + $file_name =~ s/\//\\/g; #Change / marks to \ + chomp $file_name; + next if ( -d $file_name ); # Skip directories + next if ((!($file_name =~ /o0000/i)) && (!($file_name =~ /\/sources\//i))); # Skip other then resource and source files + push @find_files, $file_name; +} + +sub write_what_file { + my $out = shift; + open( WHAT, ">>$what_output_file") or die $!; + print WHAT "$out\n"; + close WHAT; + +} diff -r 000000000000 -r 1bad536211fd dtdinstaller/config/export.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dtdinstaller/config/export.mk Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,31 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# dtdinstaller's actual configuration export makefile + +MAKEFILE = /sf/tools/homescreentools/dtdinstaller/config/export.mk +$(call push,MAKEFILE_STACK,$(MAKEFILE)) + +DTDINSTALLERFILES = $(MAKEFILEDIR)../bin/dtd_installer.pl /epoc32/tools/ \ + $(MAKEFILEDIR)../bin/convert_file.pm /epoc32/tools/ \ + $(MAKEFILEDIR)../bin/dtd.meta /epoc32/tools/makefile_templates/tools/ \ + $(MAKEFILEDIR)../bin/dtd.mk /epoc32/tools/makefile_templates/tools/ + +dtdinstaller_config :: dtdinstaller_config-dtdinstaller +dtdinstaller_config-dtdinstaller :: + +$(call addfiles, $(DTDINSTALLERFILES), dtdinstaller_config-dtdinstaller) + +$(call popout,MAKEFILE_STACK) \ No newline at end of file diff -r 000000000000 -r 1bad536211fd dtdinstaller/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dtdinstaller/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + + +PRJ_PLATFORMS +ARMV5 WINSCW + +PRJ_EXPORTS +../bin/convert_file.pm /epoc32/tools/convert_file.pm +../bin/dtd_installer.pl /epoc32/tools/dtd_installer.pl +../bin/dtd.meta /epoc32/tools/makefile_templates/tools/dtd.meta +../bin/dtd.mk /epoc32/tools/makefile_templates/tools/dtd.mk + +PRJ_MMPFILES +PRJ_TESTMMPFILES +PRJ_TESTEXPORTS diff -r 000000000000 -r 1bad536211fd dtdinstaller/makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dtdinstaller/makefile Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,8 @@ +# dtdinstaller level configuration makefile + +MAKEFILE = /sf/tools/homescreentools/dtdinstaller/makefile + +# Place the first target as the default target which is executed from this level +dtdinstaller_all :: dtdinstaller_config + +include include_template.mk \ No newline at end of file diff -r 000000000000 -r 1bad536211fd group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + + +PRJ_PLATFORMS +ARMV5 WINSCW + +PRJ_EXPORTS +#include "../dtdinstaller/group/bld.inf" +#include "../themeinstaller/group/bld.inf" +#include "../widgettools/group/bld.inf" + +PRJ_MMPFILES +PRJ_TESTMMPFILES +PRJ_TESTEXPORTS diff -r 000000000000 -r 1bad536211fd layers.sysdef.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layers.sysdef.xml Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,20 @@ + + +]> + + + + + + + + + + + + + + + + diff -r 000000000000 -r 1bad536211fd sysdef_1_4_0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_4_0.dtd Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 1bad536211fd themeinstaller/bin/themeinstaller.zip Binary file themeinstaller/bin/themeinstaller.zip has changed diff -r 000000000000 -r 1bad536211fd themeinstaller/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/themeinstaller/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + + +PRJ_PLATFORMS +ARMV5 WINSCW + +PRJ_EXPORTS +:zip ../bin/themeinstaller.zip /epoc32/tools/themeinstaller + +PRJ_MMPFILES +PRJ_TESTMMPFILES +PRJ_TESTEXPORTS diff -r 000000000000 -r 1bad536211fd widgettools/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgettools/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + +PRJ_EXPORTS +#include "../hspluginspreinstaller/group/bld.inf" +#include "../wrtwidgetpreinstaller/group/bld.inf" diff -r 000000000000 -r 1bad536211fd widgettools/hspluginspreinstaller/bin/hspluginpreinstaller_v_2_0.zip Binary file widgettools/hspluginspreinstaller/bin/hspluginpreinstaller_v_2_0.zip has changed diff -r 000000000000 -r 1bad536211fd widgettools/hspluginspreinstaller/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgettools/hspluginspreinstaller/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + + +PRJ_EXPORTS +:zip ../bin/hspluginpreinstaller_v_2_0.zip + diff -r 000000000000 -r 1bad536211fd widgettools/wrtwidgetpreinstaller/bin/widgetpreinstaller.zip Binary file widgettools/wrtwidgetpreinstaller/bin/widgetpreinstaller.zip has changed diff -r 000000000000 -r 1bad536211fd widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.confml Binary file widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.confml has changed diff -r 000000000000 -r 1bad536211fd widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.gcfml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.gcfml Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + [run-commands] + + + + + + diff -r 000000000000 -r 1bad536211fd widgettools/wrtwidgetpreinstaller/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgettools/wrtwidgetpreinstaller/group/bld.inf Thu Dec 17 09:29:34 2009 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the information for exporting the Theme +* Installer tool under the epoc tools +* +*/ + + +PRJ_EXPORTS +:zip ../bin/widgetpreinstaller.zip + +//../conf/availablewrtwidgets.confml APP_LAYER_CONFML(availablewrtwidgets.confml) +//../conf/availablewrtwidgets.gcfml APP_LAYER_GCFML(availablewrtwidgets.gcfml)