--- a/dtdinstaller/bin/convert_file.pm Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,399 +0,0 @@
-#
-# 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 = <FILE>) {
- # 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. <FileName: "<name_of_dtd_file>">
- if ($line =~ /\s*(<FileName|<PartOf|<FileDescription|<FileVersion)\s*:\s*".[^"]*/) {
- (my $item_name, my $content) =
- $line =~ /\s*<(.[^\s]*)\s*:\s*"(.[^"]*)/;
- $file_meta_info{$item_name} = $content;
- last SWITCH;
- }
- # Matches ENTITY tag eg.
- # <!ENTITY <logical_name> "<engineering_english_string>">
- if ($line =~ /\s*<!ENTITY\s*.[^\s]*\s*".[^"]*/)
- {
- # Case entity -> 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\s*(.[^\s]*)\s*"(.[^"]*)/;
-
- $entry{'logical_name'} = $loc_name;
- $entry{'translation'} = $translation;
- }
- # Case attributes -> entity
- elsif ($attribute_read eq "TRUE" && $entity_read eq "FALSE") {
- (my $loc_name, my $translation) =
- $line =~ /\s*<!ENTITY\s*(.[^\s]*)\s*"(.[^"]*)/;
-
- $entry{'logical_name'} = $loc_name;
- $entry{'translation'} = $translation;
-
- my %temp = %entry;
- %entry = ();
- push @entries, \%temp;
- $attribute_read = "FALSE";
- $entity_read = "FALSE";
- }
- # Case: nothing has been read yet.
- elsif ($attribute_read eq "FALSE" && $entity_read eq "FALSE") {
- (my $loc_name, my $translation) =
- $line =~ /\s*<!ENTITY\s*(.[^\s]*)\s*"(.[^"]*)/;
-
- $entry{'logical_name'} = $loc_name;
- $entry{'translation'} = $translation;
- $entity_read = "TRUE";
- }
-
- last SWITCH;
- }
- # Matches attributes e.g.
- # <logical_name>.layout "<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 = <FILE>) {
- # 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 "<!ENTITY $entries[$i]{'logical_name'}" .
- " \"$entries[$i]{'translation'}\">\n";
- }
-
- close $file_handle;
- close $log_file_handle;
-}
-
-sub write_loc_header {
- my $file_handle = shift;
- print $file_handle <<EOT;
-CHARACTER_SET UTF8
-// This file is best viewed with a non-proportian font, such as Courier
-// Or copied into a spreadsheet application.
-/*
-* ============================================================================
-* Name : $file_meta_info{'FileName'}
-* Part Of : $file_meta_info{'PartOf'}
-* Version : $file_meta_info{'FileVersion'}
-*
-* Description : $file_meta_info{'FileDescription'}
-*
-* Copyright © 2005 Nokia Corporation. This material, including
-* documentation and any related computer programs, is protected by
-* copyright controlled by Nokia Corporation. All rights are reserved.
-* Copying, including reproducing, storing, adapting or translating, any
-* or all of this material requires the prior written consent of Nokia
-* Corporation. This material also contains confidential information
-* which may not be disclosed to others without the prior written consent
-* of Nokia Corporation.
-* ============================================================================
-*/
-EOT
-}
-
-sub write_dtd_header {
- my $file_handle = shift;
- my $file_to_process = shift;
-
- my $tstamp = localtime(time);
-
- print $file_handle <<EOT;
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-DTD file generated from $file_to_process
-$tstamp
-by LocDTDConverter
--->
-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/</eh60;/g;
- $$string =~ s/&/eh38;/g;
-
- $$string =~ s/eh(\d{2});/&#$1;/g;
-}
-
-# Subroutine to remove NCR notation from a string.
-sub remove_NCR_notation {
- my $string = shift;
-
- $$string =~ s/'/'/g;
- $$string =~ s/%\;/\%/g;
- $$string =~ s/&/&/g;
- $$string =~ s/>/>/g;
- $$string =~ s/</</g;
-}
-
-1;
--- a/dtdinstaller/bin/dtd.meta Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-# Meta information for widget file generation
-#
-# Copyright (c) 2008 Nokia Corporation. All rights reserved.
-#
-
-platform win32
-makefile gnumake
-techstream tools
--- a/dtdinstaller/bin/dtd.mk Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-#
-# 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:
-#
-
-# To ensure that EPOCROOT always ends with a forward slash
-TMPROOT:=$(subst \,/,$(EPOCROOT))
-EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
-
-ifndef SWITCH_LOC_FILE_NAME
-$(error switch loc file unknown)
-endif
-
-DTD_INSTALLER_TOOL := perl $(EPOCROOT)epoc32/tools/dtd_installer.pl
-
-ifdef SWITCH_LOC_FILE_PATH
-SWITCH_LOC_FILE_PATH := $(EPOCROOT)$(SWITCH_LOC_FILE_PATH)
-endif
-
-# default type is dtd (Theme installer is not called, only loc_to_dtd_converter.pl !)
-ifndef DTD_TYPE
- DTD_TYPE := dtd
-endif
-
-
-ifeq ($(DTD_TYPE),widget)
- ifndef DTD_PRIVATE_LOCATION
- DTD_PRIVATE_LOCATION := z/private/200159c0/install
- endif
- ifeq ($(PLATFORM),WINSCW)
- PRODUCTIZATION_LOCATION := $(EPOCROOT)epoc32/release/winscw/$(CFG)/$(DTD_PRIVATE_LOCATION)
- endif
- ifeq ($(PLATFORM),ARMV5)
- PRODUCTIZATION_LOCATION := $(EPOCROOT)epoc32/data/$(DTD_PRIVATE_LOCATION)
- endif
-else # Type is DTD by default
- ifndef DTD_PRIVATE_LOCATION
- DTD_PRIVATE_LOCATION := z/private/200113DD/content
- endif
- ifeq ($(PLATFORM),WINSCW)
- PRODUCTIZATION_LOCATION := $(EPOCROOT)epoc32/release/winscw/$(CFG)/$(DTD_PRIVATE_LOCATION)
- endif
- ifeq ($(PLATFORM),ARMV5)
- PRODUCTIZATION_LOCATION := $(EPOCROOT)epoc32/data/$(DTD_PRIVATE_LOCATION)
- endif
-endif
-
-ifndef DTD_OUTPUT_LOCATION
- DTD_OUTPUT_LOCATION := $(PRODUCTIZATION_LOCATION)
-else
- DTD_OUTPUT_LOCATION := $(EPOCROOT)$(DTD_OUTPUT_LOCATION)
-endif
-
-DTD_INSTALLER_TOOL := $(DTD_INSTALLER_TOOL) -o $(DTD_OUTPUT_LOCATION) -n $(SWITCH_LOC_FILE_NAME) -t $(DTD_TYPE)
-
-ifdef LOC_FOLDERS
- DTD_INSTALLER_TOOL := $(DTD_INSTALLER_TOOL) -f force
-endif
-
-ifdef DEBUG_MODE
- DTD_INSTALLER_TOOL := $(DTD_INSTALLER_TOOL) -d yes
-endif
-
-DTD_INSTALLER_TOOL_BUILD := $(DTD_INSTALLER_TOOL) -a build
-DTD_INSTALLER_TOOL_CLEAN := $(DTD_INSTALLER_TOOL) -a clean
-DTD_INSTALLER_TOOL_WHAT := $(DTD_INSTALLER_TOOL) -a what
-
-#OUTPUT_PATH
-
-# DTD tool will be invoked here
-DO_DTD_BUILD:
- $(DTD_INSTALLER_TOOL_BUILD)
-DO_DTD_CLEAN:
- $(DTD_INSTALLER_TOOL_CLEAN)
-DO_DTD_WHAT:
- $(DTD_INSTALLER_TOOL_WHAT)
-
-
-BLD SAVESPACE: DO_NOTHING
-CLEAN : DO_DTD_CLEAN
-RELEASABLES : DO_DTD_WHAT
-
-DO_NOTHING :
- @echo do nothing
-
-MAKMAKE :
-FREEZE : DO_NOTHING
-LIB : DO_NOTHING
-CLEANLIB : DO_NOTHING
-RESOURCE : DO_DTD_BUILD
-FINAL : DO_NOTHING
-
-FINAL FREEZE LIB CLEANLIB RESOURCE RELEASABLES CLEAN BLD SAVESPACE MAKMAKE :
-
-
-
--- a/dtdinstaller/bin/dtd_installer.pl Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,470 +0,0 @@
-#
-# 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: A tool that install widgets and dtd files.
-# Tool is mainly meant to be used via dtd.mk makefile template,
-# but can be run as such also.
-#
-
-use strict;
-
-#Tools path
-use constant LIBPATH => '/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 <<USAGE;
-Usage: dtd_installer.pl -n dtd_name [-t type][-l dtd_location] [-s sub_folder_name] [-o output_location] [-a action_type] [-f force_create] [-d debug]
- -n: widget or dtd (switch_loc) file name
- -t: optional, default type is dtd and other possibility is widget
- -l: optional, input path location,
- default for widget type is \\epoc32\\data\\z\\resource\\homescreen
- default for dtd is \\epoc32\\include\\domain\\<layer>\\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( <WHAT> ){
- 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 =~ /\<sc\//i)) && (!($line =~ /\<00\//i)) ){ # Read all lines that contains include, except sc and 00
- $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;
-
-}
--- a/dtdinstaller/config/export.mk Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#
-# 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
--- a/dtdinstaller/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-* 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
--- a/dtdinstaller/makefile Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-# 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
--- a/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
-* 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
--- a/layers.sysdef.xml Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
- <!ENTITY layer_real_source_path "sf/tools/homescreentools" >
-]>
-
-<SystemDefinition name="homescreentools" schema="1.4.0">
- <systemModel>
- <layer name="bldmefirst_layer">
- <module name="homescreentoolsdtd">
- <unit unitID="hsdo.dtdinstaller" mrp="" bldFile="&layer_real_source_path;/dtdinstaller/group" name="dtdinstaller" />
- </module>
- </layer>
- <layer name="tools_layer">
- <module name="homescreentools">
- <unit unitID="hsdo.themeinstaller" mrp="" bldFile="&layer_real_source_path;/themeinstaller/group" name="themeinstaller" />
- <unit unitID="hsdo.widgettools" mrp="" bldFile="&layer_real_source_path;/widgettools/group" name="widgettools" />
- </module>
- </layer>
- </systemModel>
-</SystemDefinition>
--- a/sysdef_1_4_0.dtd Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
- <!ELEMENT SystemDefinition (systemModel?, build?)>
- <!ATTLIST SystemDefinition
- name CDATA #REQUIRED
- schema CDATA #REQUIRED>
- <!ELEMENT systemModel (layer+)>
- <!ELEMENT layer (logicalset* | module*)*>
- <!ATTLIST layer
- name CDATA #REQUIRED
- levels CDATA #IMPLIED
- span CDATA #IMPLIED>
- <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalset name CDATA #REQUIRED>
- <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalsubset name CDATA #REQUIRED>
- <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
- <!ATTLIST module
- name CDATA #REQUIRED
- level CDATA #IMPLIED>
- <!ELEMENT component (unit* | package* | prebuilt*)*>
- <!ATTLIST component name CDATA #REQUIRED>
- <!ELEMENT unit EMPTY>
- <!ATTLIST unit
- unitID ID #REQUIRED
- name CDATA #REQUIRED
- mrp CDATA #REQUIRED
- filter CDATA #IMPLIED
- bldFile CDATA #REQUIRED
- priority CDATA #IMPLIED
- contract CDATA #IMPLIED>
- <!ELEMENT package EMPTY>
- <!ATTLIST package
- name CDATA #REQUIRED
- mrp CDATA #REQUIRED
- filter CDATA #IMPLIED
- contract CDATA #IMPLIED>
- <!ELEMENT prebuilt EMPTY>
- <!ATTLIST prebuilt
- name CDATA #REQUIRED
- version CDATA #REQUIRED
- late (Y|N) #IMPLIED
- filter CDATA #IMPLIED
- contract CDATA #IMPLIED>
- <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
- <!ELEMENT unitList (unitRef+)>
- <!ATTLIST unitList
- name ID #REQUIRED
- description CDATA #REQUIRED>
- <!ELEMENT unitRef EMPTY>
- <!ATTLIST unitRef unit IDREF #REQUIRED>
- <!ELEMENT targetList EMPTY>
- <!ATTLIST targetList
- name ID #REQUIRED
- description CDATA #REQUIRED
- target IDREFS #REQUIRED>
- <!ELEMENT target EMPTY>
- <!ATTLIST target
- name ID #REQUIRED
- abldTarget CDATA #REQUIRED
- description CDATA #REQUIRED>
- <!ELEMENT option EMPTY>
- <!ATTLIST option
- name ID #REQUIRED
- abldOption CDATA #REQUIRED
- description CDATA #REQUIRED
- enable (Y | N | y | n) #REQUIRED>
- <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
- <!ATTLIST configuration
- name ID #REQUIRED
- description CDATA #REQUIRED
- filter CDATA #REQUIRED>
- <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
- <!ELEMENT unitListRef EMPTY>
- <!ATTLIST unitListRef unitList IDREF #REQUIRED>
- <!ELEMENT layerRef EMPTY>
- <!ATTLIST layerRef layerName CDATA #REQUIRED>
- <!ELEMENT buildLayer EMPTY>
- <!ATTLIST buildLayer
- command CDATA #REQUIRED
- targetList IDREFS #IMPLIED
- unitParallel (Y | N | y | n) #REQUIRED
- targetParallel (Y | N | y | n) #IMPLIED>
- <!ELEMENT specialInstructions EMPTY>
- <!ATTLIST specialInstructions
- name CDATA #REQUIRED
- cwd CDATA #REQUIRED
- command CDATA #REQUIRED>
Binary file themeinstaller/bin/themeinstaller.zip has changed
--- a/themeinstaller/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-* 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
--- a/themeinstaller/source/META-INF/MANIFEST.MF Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.nokia.tools.themeinstaller.ui.ThemeInstaller
-
--- a/themeinstaller/source/ReadMe.txt Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-============================================================================
-Read me for ThemeInstaller Tool 24.03.2009
-============================================================================
-
-Product description:
-====================
-ThemeInstaller Tool (XML2ODT) converts the theme files into a binary form and installs these binary
-files into folders defined in the property file. By default these folders
-are the folders from where emulator/hardware loads the theme.
-
-Main features:
-==============
-- Single theme install
-- Multiple themes install
-- Localization support
-
-System requirements:
-====================
-
-Minimum:
-- Microsoft Windows XP Professional, Service Pack 2, Service Pack 3, or
- Microsoft Windows XP Home Edition, Service Pack 2, or any edition of
- Microsoft Windows Vista.
-- 512 MB of RAM.
-- 430 MB of free disk space.
-- 1.5-GHz processor.
-- Display supporting 16-bit colour at 1,280 x 1,024-pixel resolution.
-
-Recommended:
-- Microsoft Windows XP Professional, Service Pack 2, Service Pack 3, or
- Microsoft Windows XP Home Edition, Service Pack 2, or any edition of
- Microsoft Windows Vista.
-- 1 GB of RAM.
-- 430 MB of free disk space.
-- 2.8-GHz processor.
-- Display supporting 24-bit colour at 1,280 x 1,024-pixel resolution.
-- Sound card.
-
-
-How to Run Themeinstaller:
-====================================
-- There must not be spaces in the directory names of the path where ThemeInstaller
-is placed.
-- If you are using the version that has JRE bundled, use
-./jre1.5.0_12/jre-1_5_0_12-windows-i586-p.exe to install runtime environment.
-- After having JRE installed, edit the ThemeInstaller.bat file using a text editor
-and set the variable of JRE_BIN_DIR to point to the directory where the java executable
-is located at. E.g. before editing the line would look like:
-set JRE_BIN_DIR=".\jre1.5.0_12\bin"
-- After editing the same line could look like (depending on where the JRE has been
-installed): set JRE_BIN_DIR="C:\Program files\Java\jre1.5.0_12\bin"
-
-----------------------------------------------------------------------------
-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 the License "Symbian Foundation License v1.0"
-which accompanies this distribution, and is available
-at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
\ No newline at end of file
--- a/themeinstaller/source/build.xml Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
- <!-- ****************************** -->
- <!-- XML2ODT Convertor Build Script -->
- <!-- ****************************** -->
-
- <project name="build" default="all" basedir=".">
-
- <!-- Build properties -->
- <property name="src" location="${basedir}/src" />
- <property name="lib" location="${basedir}/lib" />
- <property name="build" location="${basedir}/bin" />
-
-
- <!-- Compilation classpath -->
- <path id="build.classpath">
- <pathelement path="${build}" />
- <fileset dir="${lib}/batik">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${lib}/icu">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${lib}/xerces">
- <include name="*.jar"/>
- </fileset><fileset dir="${lib}/xml-apis-ext">
- <include name="*.jar"/>
- </fileset>
-
- </path>
-
- <!-- Init the build -->
- <target name="init">
- <echo>The XML2ODT Tool Build is started............ </echo>
- <delete dir="${build}" failonerror="false"/>
- <delete dir="${build}/package" failonerror="false"/>
-
- <mkdir dir="${build}" />
- </target>
-
- <!-- Compile the component -->
- <target name="compile" depends="init">
- <javac destdir="${build}" debug="yes">
- <classpath refid="build.classpath" />
- <src path="${src}" />
- </javac>
- </target>
-
- <!-- Compile the tests -->
- <!--<target name="compiletests" depends="compile">
- <javac destdir="${build}" debug="yes">
- <classpath refid="build.classpath" />
- <src path="${unittests}" />
- <src path="${moduletests}" />
- </javac>
- </target>-->
-
- <target name="makeApp" depends="compile">
- <jar destfile="${build}/ThemeInstaller.jar"
- basedir="${build}"/>
- <mkdir dir="${build}/package/ThemeInstaller/data" />
- <mkdir dir="${build}/package/ThemeInstaller/lib" />
- <mkdir dir="${build}/package/ThemeInstaller/doc" />
- <mkdir dir="${build}/package/ThemeInstaller/scripts" />
- <copy todir="${build}/package/ThemeInstaller/data" >
- <fileset dir="${basedir}/data"/>
- </copy>
- <copy todir="${build}/package/ThemeInstaller/lib">
- <fileset dir="${basedir}/lib"/>
- </copy>
- <copy todir="${build}/package/ThemeInstaller/doc" >
- <fileset dir="${basedir}/doc"/>
-
- </copy>
- <copy todir="${build}/package/ThemeInstaller/scripts" >
- <fileset dir="${basedir}/scripts"/>
- </copy>
-
- <copy file="${basedir}/scripts/ThemeInstaller.bat" todir="${build}/package/ThemeInstaller"/>
- <copy file="${build}/ThemeInstaller.jar" todir="${build}/package/ThemeInstaller"/>
- <zip destfile="${basedir}/ThemeInstaller.zip" basedir="${build}/package"/>
-
- </target>
-
- <target name="all" depends="clean"/>
-
- <!-- Delete the directories -->
- <target name="clean" depends="makeApp">
- <delete dir="${build}" />
- </target>
-
-</project>
\ No newline at end of file
--- a/themeinstaller/source/data/ThemeInstaller.prop Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-# Theme Installer properties file
-
-# Media converter executable
-media_converter=lib/bmconverter/bmconv
-
-# Color setting for media conversion
-color_setting=/c16
-
-# Themes data cage folder, relative to the epocroot
-themes_datacage_rom=epoc32/release/winscw/udeb/z/private/10207254/themes/
-themes_datacage_user_disc=epoc32/winscw/c/private/10207254/themes/
-
-# ODT file extension format (e.g. .o0001)
-odt_file_ext_format=.o%04d
-
-# Destination folder for theme resource files
-odt_resources_folder=sources/
-
-# Destination folder for language specific resource files (e.g. l0001)
-odt_lang_resources_folder=l%04d/
-
-# Theme name space
-theme_name_space=http://www.series60.com/xml/xmluiml/1
-
-# Theme provider name
-theme_provider_name=Nokia
-
-# Character encoding of DTD files
-# Used when reading localised entities and composing DTD files
-# Default character encoding will be used if it is not specified
-dtd_encoding=UTF8
--- a/themeinstaller/source/data/widgetinstaller.prop Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-# Theme Installer properties file
-
-# Media converter executable
-media_converter=lib/bmconv
-
-# Color setting for media conversion
-color_setting=/c16
-
-# Themes data cage folder, relative to the epocroot
-# themes_datacage_rom=epoc32/winscw/z/private/10207254/themes/
-# themes_datacage_user_disc=epoc32/winscw/c/private/10207254/themes/
-# markmoil 12.Nov.2008 new paths for Xuikon widget installation
-themes_datacage_rom=/
-themes_datacage_user_disc=/
-
-# ODT file extension format (e.g. .o0001)
-odt_file_ext_format=.o%04d
-
-# Destination folder for theme resource files
-odt_resources_folder=sources/
-
-# Destination folder for language specific resource files (e.g. l0001)
-odt_lang_resources_folder=l%04d/
-
-# Theme name space
-theme_name_space=http://www.series60.com/xml/xmluiml/1
-
-# Theme provider name
-theme_provider_name=Nokia
-
-# Character encoding of DTD files
-# Used when reading localised entities and composing DTD files
-# Default character encoding will be used if it is not specified
-dtd_encoding=UTF8
--- a/themeinstaller/source/lib/batik/LICENSE Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
Binary file themeinstaller/source/lib/batik/batik-css.jar has changed
Binary file themeinstaller/source/lib/batik/batik-src-1.6.zip has changed
Binary file themeinstaller/source/lib/batik/batik-util.jar has changed
Binary file themeinstaller/source/lib/icu/icu4j_3_2.jar has changed
Binary file themeinstaller/source/lib/icu/icu4jsrc_3_2.jar has changed
--- a/themeinstaller/source/lib/icu/license.html Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-<html>
-
-<head>
-<title>ICU4J license - ICU4J 1.3.1 and later</title>
-</head>
-
-<body BGCOLOR="#ffffff">
-<h2>ICU4J license - ICU4J 1.3.1 and later</h2>
-
-<p>COPYRIGHT AND PERMISSION NOTICE</p>
-
-<p>
-Copyright (c) 1995-2001 International Business Machines Corporation and others
-</p>
-<p>
-All rights reserved.
-</p>
-<p>
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
-</p>
-<p>
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-</p>
-<p>
-Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
-</p>
-
-<hr>
-<small>
-All trademarks and registered trademarks mentioned herein are the property of their respective owners.
-</small>
-</body>
-</html>
--- a/themeinstaller/source/lib/xerces/LICENSE Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
Binary file themeinstaller/source/lib/xerces/Xerces-J-src.2.9.1.zip has changed
Binary file themeinstaller/source/lib/xerces/xercesImpl.jar has changed
--- a/themeinstaller/source/lib/xml-apis-ext/LICENSE Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
Binary file themeinstaller/source/lib/xml-apis-ext/xml-apis-ext.jar has changed
Binary file themeinstaller/source/lib/xml-apis-ext/xml-commons-external-1.3.04-src.zip has changed
--- a/themeinstaller/source/scripts/ThemeInstaller.bat Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-@rem
-@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-@rem All rights reserved.
-@rem This component and the accompanying materials are made available
-@rem under the terms of "Eclipse Public License v1.0"
-@rem which accompanies this distribution, and is available
-@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
-@rem
-@rem Initial Contributors:
-@rem Nokia Corporation - initial contribution.
-@rem
-@rem Contributors:
-@rem
-@rem Description:
-@rem
-
-@ECHO OFF
-
-REM Configuration
-setlocal
-set JRE_BIN_DIR=%JAVA_6_HOME%\bin
-
-REM Verify that the JAVA_6_HOME exists
-if not exist %JAVA_6_HOME%\bin\java.exe goto lookforsymseej6
-set JRE_BIN_DIR="%JAVA_6_HOME%\bin"
-goto jpathexists
-
-
-:lookforsymseej6
-REM Verify that symsee java6 exists
-if not exist "C:\APPS\j2sdk_1.6.0_02\jre\bin\java.exe" goto lookforjava_home
-set JRE_BIN_DIR="C:\APPS\j2sdk_1.6.0_02\jre\bin"
-goto jpathexists
-
-
-:lookforjava_home
-REM Verify that the JAVA_HOME exists
-if not exist %JAVA_HOME%\bin\java.exe goto assigndefaultjrepath
-set JRE_BIN_DIR="%JAVA_HOME%\bin"
-goto jpathexists
-
-
-:assigndefaultjrepath
-set JRE_BIN_DIR=%JAVA_HOME%\bin"
-
-:jpathexists
-set INSTALL_DIR="."
-
-REM Verify that the JRE executable exists
-if not exist %JRE_BIN_DIR%\java.exe goto jreexecutablenotfound
-
-REM Execute JAVAVersionChecker
-%JRE_BIN_DIR%\java.exe -classpath %INSTALL_DIR% JAVAVersionChecker %1 %2 %3 %4 %5 %6
-goto exitpoint
-
-:jreexecutablenotfound
-echo.
-echo ERROR: Java Runtime Environment Executable not found at %JRE_BIN_DIR%
-echo Configure the JRE location in ThemeInstallerMain.bat file and ThemeInstaller.bat.
-goto exitpoint
-
-:exitpoint
\ No newline at end of file
--- a/themeinstaller/source/scripts/ThemeInstaller.sh Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-#
-# Configuration
-#
-
-# Directory where JRE has java executable has been installed to
-JRE_BIN_DIR=/home/TransCrescent/rossi/jre1.5.0_12/bin
-# Directory where ThemeInstaller has been installed to
-TI_DIR=.
-
-#Launch ThemeInstaller
-
-PATH=$JRE_BIN_DIR/:$PATH
-java -Dfile.encoding=ISO8859_1 -classpath $TI_DIR/ThemeInstaller.jar:$TI_DIR/lib/batik-util.jar:$TI_DIR/lib/xml-apis-ext.jar:$TI_DIR/lib/batik-css.jar:$TI_DIR/lib/xercesImpl.jar com.nokia.tools.themeinstaller.ui.ThemeInstaller $1 $2 $3 $4 $5 $6
--- a/themeinstaller/source/scripts/ThemeInstallerMain.bat Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-@rem
-@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-@rem All rights reserved.
-@rem This component and the accompanying materials are made available
-@rem under the terms of "Eclipse Public License v1.0"
-@rem which accompanies this distribution, and is available
-@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
-@rem
-@rem Initial Contributors:
-@rem Nokia Corporation - initial contribution.
-@rem
-@rem Contributors:
-@rem
-@rem Description:
-@rem
-
-@ECHO OFF
-
-REM Configuration
-setlocal
-set JRE_BIN_DIR=%JAVA_6_HOME%\bin
-
-REM Verify that the JAVA_6_HOME exists
-if not exist %JAVA_6_HOME%\bin\java.exe goto lookforsymseej6
-set JRE_BIN_DIR="%JAVA_6_HOME%\bin"
-goto jpathexists
-
-
-:lookforsymseej6
-REM Verify that symsee java6 exists
-if not exist "C:\APPS\j2sdk_1.6.0_02\jre\bin\java.exe" goto lookforjava_home
-set JRE_BIN_DIR="C:\APPS\j2sdk_1.6.0_02\jre\bin"
-goto jpathexists
-
-
-:lookforjava_home
-REM Verify that the JAVA_HOME exists
-if not exist %JAVA_HOME%\bin\java.exe goto assigndefaultjrepath
-set JRE_BIN_DIR="%JAVA_HOME%\bin"
-goto jpathexists
-
-
-:assigndefaultjrepath
-set JRE_BIN_DIR=%JAVA_HOME%\bin"
-
-:jpathexists
-set INSTALL_DIR="."
-
-REM Verify that the JRE executable exists
-if not exist %JRE_BIN_DIR%\java.exe goto jreexecutablenotfound
-
-REM Verify that the theme installer exists
-if not exist %INSTALL_DIR%\ThemeInstaller.jar goto installernotfound
-
-REM Execute ThemeInstaller
-%JRE_BIN_DIR%\java -Dfile.encoding=ISO8859_1 -classpath %INSTALL_DIR%/ThemeInstaller.jar;%INSTALL_DIR%/lib//batik/batik-util.jar;%INSTALL_DIR%/lib/xml-apis-ext/xml-apis-ext.jar;%INSTALL_DIR%/lib/batik/batik-css.jar;%INSTALL_DIR%/lib/xerces/xercesImpl.jar;%INSTALL_DIR%/lib/icu/icu4j_3_2.jar com.nokia.tools.themeinstaller.ui.ThemeInstaller %1 %2 %3 %4 %5 %6
-goto exitpoint
-
-:jreexecutablenotfound
-echo.
-echo ERROR: Java Runtime Environment not found at %JRE_BIN_DIR%
-echo Configure the JRE location in ThemeInstallerMain.bat file and ThemeInstaller.bat.
-goto exitpoint
-
-:installernotfound
-echo.
-echo ERROR: ThemeInstaller.jar not found at %INSTALL_DIR%
-echo Configure the install location in ThemeInstallerMain.bat file and ThemeInstaller.bat.
-goto exitpoint
-
-:exitpoint
\ No newline at end of file
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSDOMProcessor.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,687 +0,0 @@
-/*
-* 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: CSSDOMProcessor applies given CSSRules to DOM Document.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.w3c.css.sac.LexicalUnit;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-/**
- * CSSDOMProcessor applies given CSSRules to DOM Document.
- */
-public class CSSDOMProcessor
- {
- /** The Constant STRING_PROPERTY. */
- public static final String STRING_PROPERTY = "styleproperty";
-
- /** The Constant STRING_PSEUDOCLASS. */
- public static final String STRING_PSEUDOCLASS = "pseudoclass";
-
- /** The Constant STRING_NAME. */
- public static final String STRING_NAME = "name";
-
- /** The Constant STRING_VALUE. */
- public static final String STRING_VALUE = "value";
-
- /** The Constant STRING_INHERIT. */
- public static final String STRING_INHERIT = "inherit";
-
- /** The Constant CHAR_COLON. */
- private static final char CHAR_COLON = ':';
-
- /** The Constant STRING_SEPARATOR. */
- private static final String STRING_SEPARATOR = "|";
-
- /** The Constant PSEUDO_TABLE. */
- private static final String[] UNSTYLABLE_ELEMENTS_TABLE = { "styleproperty" };
-
- /** The Element type resolver. */
- private static ElementTypeResolver iElementTypeResolver = new ElementTypeResolver();
-
- /** The Constant INHERITABLE_PROPERTIES. */
- public static final String[] INHERITABLE_PROPERTIES = { "visibility",
- "block-progression", "direction", "color", "font-family",
- "font-size", "font-weight", "font-style", "_s60-tab-style",
- "_s60-tab-color" };
-
- /** The Match Maker. */
- private CSSMatchMaker iCSSMatchMaker;
-
- /**
- * Instantiates a new CSSDOM processor.
- */
- public CSSDOMProcessor()
- {
- iCSSMatchMaker = new CSSMatchMaker();
- }
-
- /**
- * Sort rules.
- *
- * @param rules The rules to be sorted by priority
- */
- private static void sortRules( Vector rules )
- {
- Collections.sort( rules );
- }
-
- /**
- * Checks if is stylable element.
- *
- * @param aElement The element to be checked
- *
- * @return true, if is stylable element
- */
- private static boolean isStylableElement(Element aElement){
-
- for ( int i = 0; i < UNSTYLABLE_ELEMENTS_TABLE.length; i++ )
- {
- if ( UNSTYLABLE_ELEMENTS_TABLE[ i ].equals( aElement.getTagName() ))
- {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Apply style rule to DOM. Walks through the DOM tree elements and finds
- * those that match with the CSSRule Selector. If matching element is found,
- * Rule is applied to DOM Element.
- *
- * @param aDocument The DOM document to apply the rules
- * @param aRuleList List of CSS style rules
- */
- public void applyRulesToDom( Document aDocument,
- Vector aRuleList )
- {
- DocumentTraversal traversal = ( DocumentTraversal ) aDocument;
-
- NodeIterator iterator = traversal.createNodeIterator( aDocument
- .getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true );
-
- for ( Node node = iterator.nextNode(); node != null; node = iterator
- .nextNode() )
- {
- Element element = ( Element ) node;
- if ( isStylableElement(element) )
- {
- Vector rulesMatch = new Vector();
-
- for ( int i = 0; i < aRuleList.size(); i++ )
- {
-
- CSSRule rule = ( CSSRule ) aRuleList.get( i );
-
- if ( iCSSMatchMaker.match( rule, element ) )
- {
- rulesMatch.add( rule );
- }
- }
-
- sortRules( rulesMatch );
-
- for ( int j = 0; j < rulesMatch.size(); j++ )
- {
- CSSRule matchingRule = ( CSSRule ) rulesMatch.elementAt( j );
-// if(matchingRule.getSelector().toString().equals("box:edit")){
-// System.out.println("Party");
-// }
-
- applyRuleToElement( element, matchingRule );
- }
- }
- }
- applyInheritance( aDocument );
- }
-
-
- /**
- * Checks if given property is inheritable property.
- *
- * @param aProperty the a property
- *
- * @return true, if is inheritable property
- */
- public boolean isInheritableProperty( String aProperty )
- {
- for ( int i = 0; i < INHERITABLE_PROPERTIES.length; i++ )
- {
- if ( aProperty.equals( INHERITABLE_PROPERTIES[ i ] ) )
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if given element can inherit given property name.
- *
- * @param aElement the a element
- * @param aPropertyName the a value's name
- *
- * @return true, if element can inherit the property
- */
- public boolean canInherit( Element aElement, String aPropertyName )
- {
- return canInherit( aElement, aPropertyName, null );
- }
-
- /**
- * Checks if given element can inherit given property.
- *
- * If property value equals "inherit", the property
- * is interpreted as inherited.
- *
- * If property is inheritable and element can inherit
- * properties, the element can inherit the property.
- *
- * @param aElement the a element
- * @param aPropertyName the a property's name
- * @param aPropertyValue the a property's value
- *
- * @return true, if element can inherit the property
- */
- public boolean canInherit( Element aElement, String aPropertyName,
- String aPropertyValue )
- {
- if ( aPropertyValue != null && aPropertyValue.equals( STRING_INHERIT ) )
- {
- return true;
- }
-
- if ( !isInheritableProperty( aPropertyName ) )
- {
- return false;
- }
-
- if ( iElementTypeResolver.canInherit( aElement.getNodeName() ) )
- {
- return true;
- }
-
- return false;
- }
-
- /**
- * Apply inheritance for stylable nodes that can inherit properties from
- * parent elements.
- *
- * @param aDocument The DOM document to be modified
- */
- private void applyInheritance( Document aDocument )
- {
- DocumentTraversal traversal = ( DocumentTraversal ) aDocument;
-
- NodeIterator iterator = traversal.createNodeIterator( aDocument
- .getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true );
-
- for ( Node node = iterator.nextNode(); node != null; node = iterator
- .nextNode() )
- {
- Element element = ( Element ) node;
-// if(node.getLocalName().equals("box"))
-// System.out.println("Kill me!!!");
- if ( isStylableElement( element ) )
- {
- if ( iElementTypeResolver.canInherit( element.getNodeName() ) )
- {
- applyInheritance( element );
- }
- }
- }
- }
-
- /**
- * Apply inheritance for DOM Element. Checks if any of the elements parents
- * has properties that can be inherited in the given element. If such
- * property is found, new property to the element is added, unless there
- * already exists a property with the same name.
- *
- * @param aElement The element to be modified
- */
- private void applyInheritance( Element aElement )
- {
- for ( int i = 0; i < INHERITABLE_PROPERTIES.length; i++ )
- {
- String inheritableProperty = INHERITABLE_PROPERTIES[ i ];
- if ( iElementTypeResolver.canInherit( aElement.getNodeName() ) )
- {
- if ( !hasAttribute( aElement, inheritableProperty ) )
- {
- if ( hasParentElementWithAttribute( aElement,
- inheritableProperty ) )
- {
- if ( hasChildElementWithAttribute( aElement,
- STRING_PROPERTY, inheritableProperty ) == null )
- {
- addNewChildElement( aElement, STRING_PROPERTY,
- inheritableProperty,
- LexicalUnit.SAC_IDENT
- + STRING_SEPARATOR + STRING_INHERIT );
- }
- }
- }
- }
- }
- }
-
- /**
- * Checks for parent element with attribute name.
- *
- * @param aElement The element that's parents are checked
- * @param aAttributeName The name of the property
- *
- * @return true, aElement has parent node with given attribute name
- */
- private static boolean hasParentElementWithAttribute( Element aElement,
- String aAttributeName )
- {
- Node n = aElement.getParentNode();
- while ( n != null )
- {
- if ( n.getNodeType() == Node.ELEMENT_NODE )
- {
- if ( hasChildElementWithAttribute( ( Element ) n,
- STRING_PROPERTY, aAttributeName ) != null )
- {
- return true;
- }
- }
- n = n.getParentNode();
- }
- return false;
- }
-
- /**
- * Apply rule to DOM Element. Creates child elements for aElement with style
- * data. If the element already has matching child element, the value of it
- * is overwritten.
- *
- * @param aElement The DOM Element
- * @param aRule CSS style rule
- */
- private void applyRuleToElement( Element aElement, CSSRule aRule )
- {
- HashMap styleMap = aRule.getStyleMap();
-
- Iterator itKeys = styleMap.keySet().iterator();
- while ( itKeys.hasNext() )
- {
- String keyName = ( String ) itKeys.next();
-
- // Case 1 : Rule has pseudo selector, add or replace Element
- if ( aRule.isPseudo() )
- {
- String selectorString = aRule.getSelector().toString();
- String pseudoPart = selectorString.substring( selectorString
- .lastIndexOf( CHAR_COLON ) + 1 );
-
- Vector elementsAttributes = new Vector();
- elementsAttributes.add( new NameValuePair(STRING_NAME, keyName) );
- elementsAttributes.add( new NameValuePair(STRING_PSEUDOCLASS, pseudoPart) );
-
- Element e = hasChildElementWithAttributes( aElement,
- STRING_PROPERTY, elementsAttributes );
- if ( e != null && hasAttribute( e, STRING_NAME, keyName ) )
- {
-
- CSSStyleProperty property = ( CSSStyleProperty ) styleMap
- .get( keyName );
- Vector values = property.getValues();
-
- CSSPropertyValue propertyValue = ( CSSPropertyValue ) values
- .elementAt( 0 );
-
- // 1st value has name "value"
- e.setAttribute( STRING_VALUE, propertyValue
- .getValueTypeAndValue() );
-
- // if there are more values, their name is set to "value1,
- // value 2, ..."
- for ( int i = 1; i < values.size(); i++ )
- {
-
- propertyValue = ( CSSPropertyValue ) values
- .elementAt( i );
-
- e.setAttribute( STRING_VALUE + i, propertyValue
- .getValueTypeAndValue() );
- }
- }
- else
- {
-
- CSSStyleProperty property = ( CSSStyleProperty ) styleMap
- .get( keyName );
- Vector values = property.getValues();
-
- CSSPropertyValue propertyValue = ( CSSPropertyValue ) values
- .elementAt( 0 );
-
- Element newElement = addNewChildElement( aElement,
- STRING_PROPERTY, keyName, propertyValue
- .getValueTypeAndValue(), pseudoPart );
-
- // Rest of the values are set to element we just created
- for ( int i = 1; i < values.size(); i++ )
- {
- propertyValue = ( CSSPropertyValue ) values
- .elementAt( i );
- newElement.setAttribute( STRING_VALUE + i,
- propertyValue.getValueTypeAndValue() );
- }
- }
- }
- // Case 2 : Rule don't have pseudo selector, add or replace Element
- else
- {
- Vector elementsAttributes = new Vector();
- elementsAttributes.add( new NameValuePair(STRING_NAME, keyName) );
-
- Element e = hasChildElementWithAttributes( aElement,
- STRING_PROPERTY, elementsAttributes );
-
- if ( e != null && hasAttribute( e, STRING_NAME, keyName ) )
- {
- CSSStyleProperty property = ( CSSStyleProperty ) styleMap
- .get( keyName );
- Vector values = property.getValues();
-
- CSSPropertyValue propertyValue = ( CSSPropertyValue ) values
- .elementAt( 0 );
-
- // 1st value has name "value"
- e.setAttribute( STRING_VALUE, propertyValue
- .getValueTypeAndValue() );
-
- // if there are more values, their name is set to "value1,
- // value 2, ..."
- for ( int i = 1; i < values.size(); i++ )
- {
- propertyValue = ( CSSPropertyValue ) values
- .elementAt( i );
- e.setAttribute( STRING_VALUE + i, propertyValue
- .getValueTypeAndValue() );
- }
- }
- else
- {
-
- CSSStyleProperty property = ( CSSStyleProperty ) styleMap
- .get( keyName );
- Vector values = property.getValues();
-
- CSSPropertyValue propertyValue = ( CSSPropertyValue ) values
- .elementAt( 0 );
-
- Element newElement = addNewChildElement( aElement,
- STRING_PROPERTY, keyName, propertyValue
- .getValueTypeAndValue() );
-
- // Rest of the values are set to element we just created
- for ( int i = 1; i < values.size(); i++ )
- {
- propertyValue = ( CSSPropertyValue ) values
- .elementAt( i );
- newElement.setAttribute( STRING_VALUE + i,
- propertyValue.getValueTypeAndValue() );
- }
- }
- }
- }
- }
-
- /**
- * Checks if DOM Element has a attribute with given value.
- *
- * @param aElement The DOM element to check
- * @param aValue Attributes value
- *
- * @return true, if successful
- */
- private static boolean hasAttribute( Element aElement, String aValue )
- {
- return hasAttribute( aElement, null, aValue );
- }
-
-
- /**
- * Checks if DOM Element has a attribute with given name and value.
- * Attribute's name can be null, when only the attributes value is checked
- *
- * @param aElement The DOM element to check
- * @param aName Attributes name
- * @param aValue Attributes value
- *
- * @return true, if successful
- */
- private static boolean hasAttribute( Element aElement, String aName,
- String aValue )
- {
- if ( aElement == null )
- {
- return false;
- }
- if ( aElement.hasAttributes() )
- {
- NamedNodeMap nnm = aElement.getAttributes();
- for ( int i = 0; i < nnm.getLength(); i++ )
- {
- Node att = nnm.item( i );
- if ( aName != null )
- {
- if ( att.getNodeValue().equals( aValue )
- && att.getNodeName().equals( aName ) )
- {
- return true;
- }
- }
- else
- {
- if ( att.getNodeValue().equals( aValue ) )
- {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Checks for elements attributes.
- *
- * @param aElement The element to be checked
- * @param aAttributes Attributes in name-value pairs
- *
- * @return true, if element has attributes given in aAttributes
- */
- private static boolean hasAttributes( Element aElement, Vector aAttributes )
- {
- if ( aElement == null )
- {
- return false;
- }
-
- if ( aElement.hasAttributes() )
- {
-
- for ( int i = 0; i < aAttributes.size(); i++ )
- {
-
- NameValuePair nameValuePair = ( NameValuePair ) aAttributes
- .get( i );
-
- String name = nameValuePair.getName();
- String value = nameValuePair.getValue();
-
- if ( !hasAttribute( aElement, name, value ) )
- {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Checks for child element with attribute's name.
- *
- * @param aParent The parent element
- * @param aElementName The element tag name to be matched with child nodes
- * name
- * @param aName Attributes name to be matched
- *
- * @return Child element with attribute, null if none
- */
- private static Element hasChildElementWithAttribute( Element aParent,
- String aElementName, String aName )
- {
- for ( Node n = aParent.getFirstChild(); n != null; n = n
- .getNextSibling() )
- {
- if ( n.getNodeType() == Node.ELEMENT_NODE )
- {
- if ( hasAttribute( ( Element ) n, aName )
- && n.getNodeName().equals( aElementName ) )
- {
- return ( Element ) n;
- }
- }
- }
- return null;
- }
-
-
-
- /**
- * Checks for child element with attributes.
- *
- * @param aParent The parent element
- * @param aElementName The element tag name to be matched with child nodes
- * name
- * @param aNameValuePairs The Name-Value pairs for attributes that need to be
- * found
- *
- * @return Child element with attributes, null if none
- */
- private static Element hasChildElementWithAttributes( Element aParent,
- String aElementName, Vector aNameValuePairs )
- {
- for ( Node n = aParent.getFirstChild(); n != null; n = n
- .getNextSibling() )
- {
- if ( n.getNodeType() == Node.ELEMENT_NODE )
- {
- if ( n.getNodeName().equals( aElementName )
- && hasAttributes( ( Element ) n, aNameValuePairs ) )
- {
- return ( Element ) n;
- }
- }
- }
- return null;
- }
-
- /**
- * Adds the new node to DOM.
- *
- * @param aParent The parent of the new node
- * @param aElementName Element name for new DOM node
- * @param aKeyName Attribute name for new DOM node
- * @param aKeyValue Attribute value for new DOM node
- */
- private Element addNewChildElement( Element aParent,
- String aElementName, String aKeyName, String aKeyValue )
- {
- return addNewChildElement( aParent, aElementName, aKeyName, aKeyValue, null );
- }
-
- /**
- * Adds the new node to DOM.
- *
- * @param aParent The parent of the new node
- * @param aElementName Element name for new DOM node
- * @param aKeyName Attribute name for new DOM node
- * @param aKeyValue Attribute value for new DOM node
- * @param aPseudo Pseudo attribute value for the DOM node
- */
- private Element addNewChildElement( Element aParent, String aElementName,
- String aKeyName, String aKeyValue, String aPseudo )
- {
- Document document = aParent.getOwnerDocument();
-
- String namespaceUri = aParent.getNamespaceURI();
-
- Element newElement = document.createElementNS( namespaceUri,
- aElementName );
-
- if ( aPseudo != null )
- {
- newElement.setAttribute( STRING_PSEUDOCLASS, aPseudo );
- }
- newElement.setAttribute( STRING_NAME, aKeyName );
- newElement.setAttribute( STRING_VALUE, aKeyValue );
-
- aParent.appendChild( newElement );
- return newElement;
- }
-
-
- /**
- * Class for temporarily store Node's attribute name and value.
- */
- private class NameValuePair
- {
- private String iName;
-
- private String iValue;
-
- NameValuePair( String aName, String aValue )
- {
- iName = aName;
- iValue = aValue;
- }
-
- public String getName()
- {
- return iName;
- }
-
- public String getValue()
- {
- return iValue;
- }
-
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSHandler.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,588 +0,0 @@
-/*
-* 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: This class gets notified during the CSS file parsing
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.awt.Color;
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Vector;
-
-import org.w3c.css.sac.CSSException;
-import org.w3c.css.sac.DocumentHandler;
-import org.w3c.css.sac.InputSource;
-import org.w3c.css.sac.LexicalUnit;
-import org.w3c.css.sac.Parser;
-import org.w3c.css.sac.SACMediaList;
-import org.w3c.css.sac.SelectorList;
-import org.w3c.css.sac.helpers.ParserFactory;
-import org.w3c.dom.Document;
-
-import com.nokia.tools.themeinstaller.logger.LogWriter;
-
-/**
- * The Class CSSHandler. Informs application of basic parsing events. This
- * should be registered with CSS Parser with setDocumentHandler method.
- *
- * Handler gets notified during the CSS parsing:
- * 1. startSelector(), when new selector is noticed
- * 2. property(), when new property is noticed
- * 3. lexicalValue() is used to calculate the values of the parsed property
- *
- * If you are using CSS import with paths relative to main CSS, you need to
- * set the path of main CSS using setImportDirectory( String aImportDirectory )
- */
-
-public class CSSHandler implements DocumentHandler
- {
-
- /** The style map for style property. */
- private HashMap iStyleMap;
-
- /** List of parsed rules. */
- private Vector iRuleList;
-
- /** The DOM document. */
- private Document iDocument;
-
- /** Color resolver for resolving colors in string form */
- private ColorResolver iColorResolver;
-
- /** The main CSS directory for finding imported CSS File's relative path. */
- private String iImportDirectory;
-
- /** The Constant FUNCTION_HSL. */
- public static final String FUNCTION_HSL = "hsl";
-
- /** The Constant COMMA. */
- public static final String COMMA = ",";
-
- /** The Constant CHAR_APOSTROPHE. */
- private static final char CHAR_APOSTROPHE = '"';
-
- /** The Constant CHAR_SPACE. */
- private static final char CHAR_SPACE = ' ';
-
- /** The Constant CHAR_COLON. */
- private static final char CHAR_COLON = ':';
-
- /** The Constant SEPARATOR. */
- public static final String SEPARATOR = "|";
-
- /** The Constant FORWARD_SLASH. */
- public static final String FORWARD_SLASH = "/";
-
- /** The Constant BACKWARD_SLASH. */
- public static final String BACKWARD_SLASH = "\\";
-
- /** The CSS to DOM Processor for applying changes to DOM. */
- private CSSDOMProcessor iCSSDOMProcessor;
-
- /**
- * Instantiates a new CSS handler.
- */
- public CSSHandler()
- {
- super();
- iCSSDOMProcessor = new CSSDOMProcessor();
- iStyleMap = new HashMap();
- iRuleList = new Vector();
- iColorResolver = new ColorResolver();
- }
-
- /**
- * Instantiates a new CSS handler. This one is used for handling imported
- * CSS files
- *
- * @param aHandler The handler to retrieve previous rule list and DOM document
- * from
- */
- private CSSHandler( CSSHandler aHandler )
- {
- super();
- iCSSDOMProcessor = new CSSDOMProcessor();
- iStyleMap = new HashMap();
-
- iRuleList = aHandler.iRuleList;
- iDocument = aHandler.iDocument;
- iColorResolver = new ColorResolver();
- }
-
- /**
- * Sets the document.
- *
- * @param aDocument The new document
- */
- public void setDocument( Document aDocument )
- {
- iDocument = aDocument;
- }
-
- /**
- * Gets the document.
- *
- * @return the document
- */
- public Document getDocument()
- {
- return iDocument;
- }
-
- /**
- * Sets the directory of main CSS.
- *
- * @param aImportDirectory The directory of main CSS
- */
- public void setImportDirectory( String aImportDirectory )
- {
- iImportDirectory = aImportDirectory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#startDocument(org.w3c.css.sac.InputSource)
- */
- public void startDocument( InputSource arg0 ) throws CSSException
- {
- iRuleList = new Vector();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#startSelector(org.w3c.css.sac.SelectorList)
- */
- public void startSelector( SelectorList aSelectorList ) throws CSSException
- {
- iStyleMap = new HashMap();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#endSelector(org.w3c.css.sac.SelectorList)
- */
- public void endSelector( SelectorList aSelectors ) throws CSSException
- {
- if ( iStyleMap.size() != 0 )
- {
- for ( int i = 0; i < aSelectors.getLength(); i++ )
- {
-// System.out.println("CSSHandler Selectors --> "+aSelectors.item(i));
- CSSRule rule = new CSSRule( aSelectors.item( i ), iStyleMap );
- iRuleList.add( rule );
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#property(java.lang.String,
- * org.w3c.css.sac.LexicalUnit, boolean)
- */
- public void property( String aName, LexicalUnit aLexicalUnit,
- boolean aImportant ) throws CSSException
- {
- Vector propertyValues = new Vector();
- lexicalValue( aLexicalUnit, propertyValues );
- iStyleMap.put( aName, new CSSStyleProperty( propertyValues, aImportant ) );
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#endDocument(org.w3c.css.sac.InputSource)
- */
- public void endDocument( InputSource aInputSource ) throws CSSException
- {
- if ( iDocument == null )
- {
- throw new IllegalStateException( "CSSHandler has null DOM Document" );
- }
-
- iCSSDOMProcessor.applyRulesToDom( iDocument, iRuleList );
- }
-
-
- /**
- * Finds out the property values and adds them into a Vector
- * aPropertyValues. Property types that are taken into account are
- * from Symbian side: ...\Xuikon\Dom\src\xndompropertyvalue.cpp
- *
- * @param aLexicalUnit Value
- * @param aPropertyValues Vector for Property values
- */
- public void lexicalValue( LexicalUnit aLexicalUnit,
- Vector aPropertyValues )
- {
- while ( aLexicalUnit != null )
- {
- switch ( aLexicalUnit.getLexicalUnitType() )
- {
- case LexicalUnit.SAC_OPERATOR_COMMA:
- break;
- // Allowed cases for integer value
- case LexicalUnit.SAC_INTEGER:
- aPropertyValues
- .add( new CSSPropertyValue(
- LexicalUnit.SAC_INTEGER, Integer
- .toString( aLexicalUnit
- .getIntegerValue() ) ) );
- break;
- // Allowed cases for real value
- // Fallthrough
- case LexicalUnit.SAC_REAL:
- case LexicalUnit.SAC_DIMENSION:
- case LexicalUnit.SAC_EM:
- case LexicalUnit.SAC_EX:
- case LexicalUnit.SAC_INCH:
- case LexicalUnit.SAC_PIXEL:
- case LexicalUnit.SAC_CENTIMETER:
- case LexicalUnit.SAC_MILLIMETER:
- case LexicalUnit.SAC_POINT:
- case LexicalUnit.SAC_PICA:
- case LexicalUnit.SAC_PERCENTAGE:
- case LexicalUnit.SAC_DEGREE:
- case LexicalUnit.SAC_GRADIAN:
- case LexicalUnit.SAC_RADIAN:
- case LexicalUnit.SAC_MILLISECOND:
- case LexicalUnit.SAC_SECOND:
- case LexicalUnit.SAC_HERTZ:
- case LexicalUnit.SAC_KILOHERTZ:
- aPropertyValues.add( new CSSPropertyValue( aLexicalUnit
- .getLexicalUnitType(), Float.toString( aLexicalUnit
- .getFloatValue() ) ) );
- break;
- // RGB Values
- case LexicalUnit.SAC_RGBCOLOR:
- //Using StringBuffer to store values of RGB property
- //in order to handle values (R,G and B) as one value
- StringBuffer sb = new StringBuffer();
- colorValue( aLexicalUnit.getParameters(), sb );
- aPropertyValues.add( new CSSPropertyValue( aLexicalUnit
- .getLexicalUnitType(), sb.toString() ) );
- break;
- // Allowed cases for string values
- // Fallthrough
- case LexicalUnit.SAC_URI:
- case LexicalUnit.SAC_IDENT:
- case LexicalUnit.SAC_STRING_VALUE:
- case LexicalUnit.SAC_ATTR:
- // Color value as string
- if ( iColorResolver.get( aLexicalUnit.getStringValue() ) != null )
- {
- Color color = ( Color ) iColorResolver.get( aLexicalUnit
- .getStringValue() );
- aPropertyValues.add( new CSSPropertyValue(
- LexicalUnit.SAC_RGBCOLOR,
- LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getRed() + COMMA
- + LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getGreen() + COMMA
- + LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getBlue() ) );
- }
- // Space
- else if ( aLexicalUnit.getStringValue()
- .indexOf( CHAR_SPACE ) != -1 )
- {
- aPropertyValues.add( new CSSPropertyValue( aLexicalUnit
- .getLexicalUnitType(), CHAR_APOSTROPHE
- + aLexicalUnit.getStringValue()
- + CHAR_APOSTROPHE ) );
- }
- // Text
- else
- {
- aPropertyValues.add( new CSSPropertyValue( aLexicalUnit
- .getLexicalUnitType(), aLexicalUnit
- .getStringValue() ) );
- }
- break;
- // In case value is set as "inherit" already in CSS -file
- // This sets it to DOM as Ident value that is "inherit"
- case LexicalUnit.SAC_INHERIT:
- aPropertyValues.add( new CSSPropertyValue(
- LexicalUnit.SAC_IDENT,
- CSSDOMProcessor.STRING_INHERIT ) );
- break;
- case LexicalUnit.SAC_FUNCTION:
- String functionName = aLexicalUnit.getFunctionName();
- if ( functionName.equals( FUNCTION_HSL ) )
- {
- Color color = colorFromHsl( aLexicalUnit
- .getParameters() );
- aPropertyValues.add( new CSSPropertyValue(
- LexicalUnit.SAC_RGBCOLOR,
- LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getRed() + COMMA
- + LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getGreen() + COMMA
- + LexicalUnit.SAC_INTEGER + SEPARATOR
- + color.getBlue() ) );
-
- }
- else
- {
- throw new IllegalStateException(
- "Unknown CSS Function : " + functionName );
- }
- break;
- default:
- break;
- }
- aLexicalUnit = aLexicalUnit.getNextLexicalUnit();
- }
- }
-
- /**
- * Parses HSL Function using ColorResolver.
- *
- * @param aLexicalUnit Parameters containing color values
- *
- * @return the color
- */
- private Color colorFromHsl( LexicalUnit aLexicalUnit )
- {
- float h = 0;
- float s = 0;
- float l = 0;
- try
- {
- h = ( float ) aLexicalUnit.getIntegerValue();
- aLexicalUnit = aLexicalUnit.getNextLexicalUnit()
- .getNextLexicalUnit();
- s = aLexicalUnit.getFloatValue();
- aLexicalUnit = aLexicalUnit.getNextLexicalUnit()
- .getNextLexicalUnit();
- l = aLexicalUnit.getFloatValue();
- }
- catch ( RuntimeException e )
- {
- throw new IllegalStateException( "Illegal HSL Color values" );
- }
- if ( aLexicalUnit.getNextLexicalUnit() != null )
- {
- throw new IllegalStateException( "Too many parameters in HSL color" );
- }
- return iColorResolver.hslToRgb( h, s, l );
- }
-
- /**
- * Finds out the property values for RGB color and adds them into a
- * StringBuffer aProperty.
- *
- * @param aLexicalUnit Parameters containing color values
- * @param aProperty StringBuffer for storing property information
- */
- public void colorValue( LexicalUnit aLexicalUnit, StringBuffer aProperty )
- {
- while ( aLexicalUnit != null )
- {
- switch ( aLexicalUnit.getLexicalUnitType() )
- {
- // Operator ","
- case LexicalUnit.SAC_OPERATOR_COMMA:
- aProperty.append( COMMA );
- break;
- case LexicalUnit.SAC_INTEGER:
- aProperty.append( aLexicalUnit.getLexicalUnitType() );
- aProperty.append( SEPARATOR );
- aProperty.append( aLexicalUnit.getIntegerValue() );
- break;
- case LexicalUnit.SAC_PERCENTAGE:
- aProperty.append( LexicalUnit.SAC_INTEGER );
- aProperty.append( SEPARATOR );
- aProperty.append( iColorResolver
- .getColorValueFromPercentage( aLexicalUnit
- .getFloatValue() ) );
- break;
- default:
- break;
- }
- aLexicalUnit = aLexicalUnit.getNextLexicalUnit();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#startFontFace ()
- */
- public void startFontFace() throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#startPage(java.lang.String,
- * java.lang.String)
- */
- public void startPage( String arg0, String arg1 ) throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#endFontFace ()
- */
- public void endFontFace() throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#endPage(java.lang.String,
- * java.lang.String)
- */
- public void endPage( String arg0, String arg1 ) throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#comment (java.lang.String)
- */
- public void comment( String arg0 ) throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#endMedia (org.w3c.css.sac.SACMediaList)
- */
- public void endMedia( SACMediaList arg0 ) throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#ignorableAtRule (java.lang.String)
- */
- public void ignorableAtRule( String arg0 ) throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#importStyle (java.lang.String,
- * org.w3c.css.sac.SACMediaList, java.lang.String)
- */
- public void importStyle( String aCSSFileName, SACMediaList aMedia,
- String aNameSpaceUri ) throws CSSException
- {
- try
- {
- CSSHandler handler = new CSSHandler( this );
- ParserFactory factory = new ParserFactory();
-
- Parser parser = factory.makeParser();
- parser.setDocumentHandler( handler );
- Reader r = null;
-
- File cssImport = new File( aCSSFileName );
- if ( isAbsolutePath( aCSSFileName ) && cssImport.exists() )
- {
- // The imported CSS file is given with absolute path
- r = new FileReader( aCSSFileName );
- LogWriter.getInstance().logInfo(
- "Imported CSS : " + cssImport.getAbsolutePath() );
- }
- else if ( !isAbsolutePath( aCSSFileName )
- && iImportDirectory != null )
- {
- // If the given imported CSS File is not found,
- // try to locate it using path relative to main CSS
- File relativeCSS = new File( iImportDirectory + File.separator
- + aCSSFileName );
- r = new FileReader( relativeCSS );
- LogWriter.getInstance().logInfo(
- "Imported CSS : " + relativeCSS.getAbsolutePath() );
- }
- else
- {
- throw new IllegalStateException(
- "Can't resolve imported CSS File: " + aCSSFileName );
- }
-
- InputSource is = new InputSource( r );
- parser.parseStyleSheet( is );
- }
- catch ( Exception e )
- {
- throw new CSSException( e.getMessage() );
- }
- }
-
- /**
- * Checks if path is absolute path.
- * Path is absolute if it starts with '/', '\'
- * or is of form [drive]:[path]
- * @param aFilePath the a file path
- *
- * @return true, if is absolute path
- */
- private boolean isAbsolutePath( String aFilePath )
- {
- if ( aFilePath.startsWith( FORWARD_SLASH ) )
- {
- return true;
- }
- if ( aFilePath.startsWith( BACKWARD_SLASH ) )
- {
- return true;
- }
- if ( aFilePath.length() > 1 && aFilePath.charAt( 1 ) == CHAR_COLON )
- {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#namespaceDeclaration(java.lang.String,
- * java.lang.String)
- */
- public void namespaceDeclaration( String arg0, String arg1 )
- throws CSSException
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.css.sac.DocumentHandler#startMedia(org.w3c.css.sac.SACMediaList)
- */
- public void startMedia( SACMediaList arg0 ) throws CSSException
- {
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSMatchMaker.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +0,0 @@
-/*
-* 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: Compares W3C DOM Elements and CSS Selectors
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.w3c.css.sac.AttributeCondition;
-import org.w3c.css.sac.CSSException;
-import org.w3c.css.sac.CombinatorCondition;
-import org.w3c.css.sac.Condition;
-import org.w3c.css.sac.ConditionalSelector;
-import org.w3c.css.sac.DescendantSelector;
-import org.w3c.css.sac.ElementSelector;
-import org.w3c.css.sac.Selector;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * The Class CSSMatchMaker compares W3C DOM Elements and CSS Selectors. Match
- * method returns true if CSS Selector has style rules for the given DOM Element
- */
-public class CSSMatchMaker
- {
-
- /** The Constant STRING_CLASS. */
- private static final String STRING_CLASS = "class";
-
- /** The Constant STRING_ID. */
- private static final String STRING_ID = "id";
-
- /** The Constant STRING_SPACE. */
- private static final String STRING_SPACE = " ";
-
- /** The pseudo class resolver. */
- private PseudoClassResolver iPseudoClassResolver;
-
- /**
- * Instantiates a new CSS Match Maker.
- */
- public CSSMatchMaker()
- {
- iPseudoClassResolver = new PseudoClassResolver();
- }
-
- /**
- * Compares if CSS rule with it's selector has style instructions for given
- * DOM Element.
- *
- * @param aElement W3C DOM Element
- * @param aRule The style rule
- *
- * @return true, if CSS Selector matches DOM Element
- */
- public boolean match( CSSRule aRule, Element aElement ){
- aRule.resetSpecificity();
- return match( aRule.getSelector(), aRule.getSpecificity(), aElement );
-
- }
-
- /**
- * Compares if CSS rule's selector has style instructions for given DOM
- * Element.
- *
- * @param aSelector the a selector
- * @param aSpecificity CSSRules specificity table to be updated during the
- * comparison
- * @param aElement the a element
- *
- * @return true, if given selector match DOM Element
- */
- private boolean match( Selector aSelector, CSSSpecificity aSpecificity, Element aElement )
- {
- switch ( aSelector.getSelectorType() )
- {
- case Selector.SAC_ELEMENT_NODE_SELECTOR:
- {
- ElementSelector eSelector = ( ElementSelector ) aSelector;
- String name = eSelector.getLocalName();
-// if("box".equals(aElement.getLocalName())&& "box".equals(name) ){
-// System.out.println("!!!");
-// }
- if ( name == null || name.equals( aElement.getLocalName() ) )
- {
- aSpecificity.incElement();
- return true;
- }
- return false;
- }
-
- case Selector.SAC_CONDITIONAL_SELECTOR:
- {
- ConditionalSelector cSelector = ( ConditionalSelector ) aSelector;
- if ( !match( cSelector.getSimpleSelector(), aSpecificity,
- aElement ) )
- {
- return false;
- }
- return matchCondition( cSelector.getCondition(), aSpecificity,
- aElement );
- }
-
- case Selector.SAC_CHILD_SELECTOR:
- {
- DescendantSelector dSelector = ( DescendantSelector ) aSelector;
- if ( !match( dSelector.getSimpleSelector(), aSpecificity,
- aElement ) )
- {
- return false;
- }
- return match( dSelector.getAncestorSelector(), aSpecificity,
- ( Element ) aElement.getParentNode() );
- }
- case Selector.SAC_DESCENDANT_SELECTOR:
- {
- DescendantSelector dSelector = ( DescendantSelector ) aSelector;
- if ( !match( dSelector.getSimpleSelector(), aSpecificity,
- aElement ) )
- {
- return false;
- }
-
- Node ancestor = aElement;
- while ( ( ancestor = ancestor.getParentNode() ) != null )
- {
- if ( ancestor.getNodeType() == Node.ELEMENT_NODE )
- {
- if ( match( dSelector.getAncestorSelector(),
- aSpecificity, ( Element ) ancestor ) )
- {
- return true;
- }
- }
- }
- return false;
- }
- case Selector.SAC_ANY_NODE_SELECTOR:
- case Selector.SAC_DIRECT_ADJACENT_SELECTOR:
- case Selector.SAC_CDATA_SECTION_NODE_SELECTOR:
- case Selector.SAC_COMMENT_NODE_SELECTOR:
- case Selector.SAC_NEGATIVE_SELECTOR:
- case Selector.SAC_PROCESSING_INSTRUCTION_NODE_SELECTOR:
- case Selector.SAC_PSEUDO_ELEMENT_SELECTOR:
- case Selector.SAC_ROOT_NODE_SELECTOR:
- case Selector.SAC_TEXT_NODE_SELECTOR:
- {
- throw new CSSException( "Selector : "
- + aSelector.getSelectorType() + " not supported" );
- }
- default:
- throw new CSSException( "Unknown selector : "
- + aSelector.getSelectorType() );
- }
- }
-
- /**
- * For Conditional Selectors, it is also necessary to check if selectors
- * conditions match with the DOM Element.
- *
- * @param aCondition The condition of the conditional selector
- * @param aElement The DOM element
- * @param aSpecificity CSSRules specificity table to be updated during the
- * comparison
- *
- * @return true, if given Condition match DOM Element
- */
- private boolean matchCondition( Condition aCondition,
- CSSSpecificity aSpecificity, Element aElement )
- {
- switch ( aCondition.getConditionType() )
- {
- case Condition.SAC_ID_CONDITION:
- {
- AttributeCondition idCondition = ( AttributeCondition ) aCondition;
- String idAttribute = aElement.getAttribute( STRING_ID );
-
- String[] idTexts = idAttribute.split( STRING_SPACE );
-
- for ( int i = 0; i < idTexts.length; i++ )
- {
- String idText = idTexts[ i ];
- if ( idAttribute != null
- && idText.equals( idCondition.getValue() ) )
- {
- aSpecificity.incID();
- return true;
- }
- }
- return false;
- }
-
- case Condition.SAC_CLASS_CONDITION:
- {
- AttributeCondition classCondition = ( AttributeCondition ) aCondition;
- String classAttribute = aElement.getAttribute( STRING_CLASS );
-
- String[] classTexts = classAttribute.split( STRING_SPACE );
-
- for ( int i = 0; i < classTexts.length; i++ )
- {
- String classText = classTexts[ i ];
- if ( classAttribute != null
- && classText.equals( classCondition.getValue() ) )
- {
- aSpecificity.incAttribute();
- return true;
- }
- }
- return false;
- }
-
- case Condition.SAC_AND_CONDITION:
- {
- CombinatorCondition combCondition = ( CombinatorCondition ) aCondition;
- return matchCondition( combCondition.getFirstCondition(),
- aSpecificity, aElement )
- && matchCondition( combCondition.getSecondCondition(),
- aSpecificity, aElement );
- }
-
- case Condition.SAC_PSEUDO_CLASS_CONDITION:
- {
- Collection pseudoTypes = iPseudoClassResolver
- .getPseudoTypes();
-
- for ( Iterator it = pseudoTypes.iterator(); it
- .hasNext(); )
- {
- if ( it.next()
- .equals( aCondition.toString().substring( 1 ) ) )
- {
- aSpecificity.incAttribute();
- return true;
- }
- }
- return false;
- }
- case Condition.SAC_ATTRIBUTE_CONDITION:
- case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
- case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION:
- case Condition.SAC_OR_CONDITION:
- case Condition.SAC_NEGATIVE_CONDITION:
- case Condition.SAC_POSITIONAL_CONDITION:
- case Condition.SAC_LANG_CONDITION:
- case Condition.SAC_ONLY_CHILD_CONDITION:
- case Condition.SAC_ONLY_TYPE_CONDITION:
- case Condition.SAC_CONTENT_CONDITION:
- {
- throw new CSSException( "condition : "
- + aCondition.getConditionType() + " not supported" );
- }
- default:
- throw new CSSException( "Unknown condition : "
- + aCondition.getConditionType() );
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSParser.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
-* 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: This class parses CSS file to DOM document
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.w3c.css.sac.InputSource;
-import org.w3c.css.sac.Parser;
-import org.w3c.css.sac.helpers.ParserFactory;
-import org.w3c.dom.Document;
-
-import com.nokia.tools.themeinstaller.logger.LogWriter;
-import com.nokia.tools.themeinstaller.odtconverter.ParseOperation;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.odtconverter.ODTException;
-
-/**
- * CSSParser parses the CSS File and uses CSSHandler to apply the
- * parsed style rules to DOM Document.
- */
-public class CSSParser extends ParseOperation implements Runnable
- {
-
- /** The Constant CSS_PARSER_SYSTEM_VALUE. */
- private static final String CSS_PARSER_SYSTEM_VALUE = "org.w3c.css.sac.parser";
-
- /** The Constant CSS_PARSER_SYSTEM_KEY. */
- private static final String CSS_PARSER_SYSTEM_KEY = "org.apache.batik.css.parser.Parser";
-
- /** CSS file name */
- private String iFileName;
-
- /** The CSS handler. */
- private CSSHandler iCSSHandler;
-
- /** The CSS parser. */
- private Parser iParser;
-
- /**
- * Instantiates a new CSS parser.
- *
- * @param aFileName The CSS file name
- */
- public CSSParser( String aFileName )
- {
- iFileName = aFileName;
- ParserFactory factory = new ParserFactory();
- iCSSHandler = new CSSHandler();
-
- // Store the value-key pair of the used parser in the System
- // environment(JVM)
- System.setProperty( CSS_PARSER_SYSTEM_VALUE, CSS_PARSER_SYSTEM_KEY );
- try
- {
- iParser = factory.makeParser();
- }
- catch ( Exception e )
- {
- throw new IllegalStateException( "Could not load CSS parser" );
- }
- }
-
- public void setDocument( Document aDocument )
- {
- iDOMDocument = aDocument;
- }
-
- /**
- * Run the CSS parse operation.
- */
- public void run()
- {
- int error = IParseOperationListener.OPERATION_SUCCESSFUL;
- String reason = "";
-
- try
- {
- iCSSHandler.setDocument( iDOMDocument );
-
- File mainCSS = new File( iFileName );
- Reader r = new FileReader( mainCSS );
- // Tell CSS handler the directory for relative import paths,
- // that is, the path of the Main CSS file
- iCSSHandler.setImportDirectory( mainCSS.getParent() );
- InputSource is = new InputSource( r );
- iParser.setDocumentHandler( iCSSHandler );
- LogWriter.getInstance().logInfo(
- this.getClass().getSimpleName() + ": Parsing CSS "
- + iFileName );
- iParser.parseStyleSheet( is );
- iDOMDocument = iCSSHandler.getDocument();
- }
- catch ( Exception e )
- {
- reason = e.getMessage();
- error = IParseOperationListener.CSS_PARSER_ERROR;
- }
-
- super.operationCompleted( error, reason );
- }
-
- /**
- * Starts CSS parsing in a new thread.
- */
- public void parse() throws IOException, ODTException
- {
- Thread thread = new Thread( this );
- thread.start();
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSPropertyValue.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
-* 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: CSS Style property value
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-/**
- * Contains property's value and value type
- */
-public class CSSPropertyValue
- {
-
- /** The Constant STRING_SEPARATOR. */
- private static final String STRING_SEPARATOR = "|";
-
- /** The value as string. */
- private String iValue;
-
- /** The value type. */
- private short iValueType;
-
- /**
- * Instantiates a new CSS property value.
- *
- * @param aValue the a value
- * @param aValueType the a value type
- */
- public CSSPropertyValue( short aValueType, String aValue )
- {
- iValue = aValue;
- iValueType = aValueType;
- }
-
- /**
- * Gets the value.
- *
- * @return the value
- */
- public String getValue()
- {
- return iValue;
- }
-
- /**
- * Gets the value type.
- *
- * @return the value type
- */
- public short getValueType()
- {
- return iValueType;
- }
-
- /**
- * Gets the value type as string.
- *
- * @return the value type as string
- */
- public String getValueTypeAsString()
- {
- return String.valueOf( iValueType );
- }
-
- /**
- * Gets the value type and value.
- *
- * @return the value type and value
- */
- public String getValueTypeAndValue()
- {
- return iValueType + STRING_SEPARATOR + iValue;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSRule.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/*
-* 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: Single CSS style rule
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.HashMap;
-
-import org.w3c.css.sac.Selector;
-
-/**
- * CSSRule contains one style rule parsed from CSS StyleSheet
- */
-public class CSSRule implements Comparable
- {
-
- /** The selector. */
- private Selector iSelector;
-
- /** Style data for Selector */
- private HashMap iStyleMap;
-
- /** Is Rule pseudo rule */
- private boolean iPseudo;
-
- /** The specificity of the rule. */
- private CSSSpecificity iSpecificity;
-
- /**
- * Instantiates a new CSS rule.
- *
- * @param aSelector Selector parsed from CSS file
- * @param aStyleMap Style data for Selector
- */
- public CSSRule( Selector aSelector, HashMap aStyleMap )
- {
- iSelector = aSelector;
- iStyleMap = aStyleMap;
- iSpecificity = new CSSSpecificity();
-
- if ( CSSSelectorParser.isPseudo( iSelector ) )
- {
- iPseudo = true;
- }
- else
- {
- iPseudo = false;
- }
-
- }
-
- /**
- * Gets the selector.
- *
- * @return the selector
- */
- public Selector getSelector()
- {
- return iSelector;
- }
-
- /**
- * Checks if rule has pseudo condition.
- *
- * @return true, if is pseudo
- */
- public boolean isPseudo()
- {
- return iPseudo;
- }
-
- /**
- * Gets the specificity.
- *
- * @return the specificity
- */
- public CSSSpecificity getSpecificity()
- {
- return iSpecificity;
- }
-
- /**
- * Reset specificity.
- */
- public void resetSpecificity()
- {
- iSpecificity.reset();
- }
-
- /**
- * Sets the specificity.
- *
- * @param aSpecificity the new specificity
- */
- public void setSpecificity( CSSSpecificity aSpecificity )
- {
- iSpecificity = aSpecificity;
- }
-
- /**
- * Gets the style map.
- *
- * @return the style map
- */
- public HashMap getStyleMap()
- {
- return iStyleMap;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object aRule )
- {
- return iSpecificity.compare( ( ( CSSRule ) aRule ).getSpecificity() );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSSelectorParser.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
-* 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: Parses SAC selector to find out its selector type
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import org.w3c.css.sac.CSSException;
-import org.w3c.css.sac.CombinatorCondition;
-import org.w3c.css.sac.Condition;
-import org.w3c.css.sac.ConditionalSelector;
-import org.w3c.css.sac.DescendantSelector;
-import org.w3c.css.sac.Selector;
-
-/**
- * Parses SAC Selector in order to find out if selector has pseudo condition.
-
- * For example selector "element.class:pseudo" is recognized as Conditional
- * Selector and the Selector's condition is ".class:pseudo" is recognized as
- * SAC_AND_CONDITION.
- *
- * After SAC_AND_CONDITION is parsed to two different conditions : ".class" and
- * ":pseudo", it is possible to tell that the original selector is Pseudo
- * Selector
- *
- */
-public class CSSSelectorParser
- {
-
- /**
- * Checks if Selector is pseudo selector.
- *
- * @param aSelector The selector
- *
- * @return true, if is pseudo selector
- */
- public static boolean isPseudo( Selector aSelector )
- {
- switch ( aSelector.getSelectorType() )
- {
- case Selector.SAC_ELEMENT_NODE_SELECTOR:
- {
- return false;
- }
- case Selector.SAC_CONDITIONAL_SELECTOR:
- {
- ConditionalSelector cSelector = ( ConditionalSelector ) aSelector;
- return isPseudoCondition( cSelector.getCondition() );
- }
- case Selector.SAC_CHILD_SELECTOR:
- {
- DescendantSelector dSelector = ( DescendantSelector ) aSelector;
- return isPseudo( dSelector.getSimpleSelector() );
- }
- case Selector.SAC_DESCENDANT_SELECTOR:
- {
- DescendantSelector dSelector = ( DescendantSelector ) aSelector;
- return isPseudo( dSelector.getSimpleSelector() );
- }
- case Selector.SAC_ANY_NODE_SELECTOR:
- case Selector.SAC_DIRECT_ADJACENT_SELECTOR:
- case Selector.SAC_CDATA_SECTION_NODE_SELECTOR:
- case Selector.SAC_COMMENT_NODE_SELECTOR:
- case Selector.SAC_NEGATIVE_SELECTOR:
- case Selector.SAC_PROCESSING_INSTRUCTION_NODE_SELECTOR:
- case Selector.SAC_PSEUDO_ELEMENT_SELECTOR:
- case Selector.SAC_ROOT_NODE_SELECTOR:
- case Selector.SAC_TEXT_NODE_SELECTOR:
- {
- throw new CSSException( "Selector : "
- + aSelector.getSelectorType() + " not supported" );
- }
- default:
- throw new CSSException( "Unknown selector : "
- + aSelector.getSelectorType() );
- }
- }
-
- /**
- * Checks if SAC Condition is pseudo condition.
- *
- * @param aCondition The condition
- *
- * @return true, if is pseudo condition
- */
- private static boolean isPseudoCondition( Condition aCondition )
- {
- switch ( aCondition.getConditionType() )
- {
- case Condition.SAC_ID_CONDITION:
- {
- return false;
- }
- case Condition.SAC_CLASS_CONDITION:
- {
- return false;
- }
- case Condition.SAC_AND_CONDITION:
- {
- CombinatorCondition combCondition = ( CombinatorCondition ) aCondition;
- return isPseudoCondition( combCondition.getFirstCondition() )
- || isPseudoCondition( combCondition
- .getSecondCondition() );
- }
- case Condition.SAC_PSEUDO_CLASS_CONDITION:
- {
- return true;
- }
- case Condition.SAC_ATTRIBUTE_CONDITION:
- case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
- case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION:
- case Condition.SAC_OR_CONDITION:
- case Condition.SAC_NEGATIVE_CONDITION:
- case Condition.SAC_POSITIONAL_CONDITION:
- case Condition.SAC_LANG_CONDITION:
- case Condition.SAC_ONLY_CHILD_CONDITION:
- case Condition.SAC_ONLY_TYPE_CONDITION:
- case Condition.SAC_CONTENT_CONDITION:
- {
- throw new CSSException( "condition : "
- + aCondition.getConditionType() + " not supported" );
-
- }
- default:
- throw new CSSException( "Unknown condition : "
- + aCondition.getConditionType() );
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSSpecificity.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
-* 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: Stores the information for Style rules priority
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-/**
- * The Class CSSSpecificity stores the information for Style rules priority
- */
-public class CSSSpecificity
- {
- final public static int ID = 0;
- final public static int ATTRIBUTE = 1;
- final public static int ELEMENT = 2;
-
- /** Table for counting specificity occurrences. */
- private int[] iSpecificity = { 0, 0, 0 };
-
- /**
- * Increase id count.
- */
- public void incID()
- {
- ++iSpecificity[ ID ];
- }
-
- /**
- * Increase attribute count.
- */
- public void incAttribute()
- {
- ++iSpecificity[ ATTRIBUTE ];
- }
-
- /**
- * Increase element count.
- */
- public void incElement()
- {
- ++iSpecificity[ ELEMENT ];
- }
-
- /**
- * Gets the specificity table.
- *
- * @return the specificity
- */
- public int[] getSpecificity()
- {
- return iSpecificity;
- }
-
- /**
- * Reset the table.
- */
- public void reset()
- {
- iSpecificity[ ID ] = 0;
- iSpecificity[ ATTRIBUTE ] = 0;
- iSpecificity[ ELEMENT ] = 0;
- }
-
- /**
- * Compare for another specificity.
- *
- * Order for priorities (3 has the highest priority): 1. element 2. .class
- * 3. #id
- *
- * @param aSpecificity Specificity to be compared
- *
- * @return 0 if this is equal, -1 if this is less, +1 if this is greater.
- */
- public int compare( CSSSpecificity aSpecificity )
- {
- int difference;
-
- difference = iSpecificity[ ID ] - aSpecificity.iSpecificity[ ID ];
- if ( difference != 0 )
- {
- if ( difference < 0 )
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
-
- difference = iSpecificity[ ATTRIBUTE ]
- - aSpecificity.iSpecificity[ ATTRIBUTE ];
- if ( difference != 0 )
- {
- if ( difference < 0 )
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
-
- difference = iSpecificity[ ELEMENT ]
- - aSpecificity.iSpecificity[ ELEMENT ];
- if ( difference != 0 )
- {
- if ( difference < 0 )
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
-
- return 0;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/CSSStyleProperty.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* 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: CSS Style property
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.Vector;
-
-/**
- * Contains information for style value.
- */
-public class CSSStyleProperty
- {
-
- /** Property values. */
- private Vector iValues;
-
- /** Information whether Style property is categorized as important. */
- private boolean iImportant;
-
- /**
- * Instantiates a new CSS style property.
- *
- * @param aValues property values
- * @param aImportant Is property important
- */
- public CSSStyleProperty( Vector aValues, boolean aImportant )
- {
- iValues = aValues;
- iImportant = aImportant;
- }
-
- /**
- * Gets the values.
- *
- * @return the values
- */
- public Vector getValues()
- {
- return iValues;
- }
-
- /**
- * Checks if property is important.
- *
- * @return true, if is important
- */
- public boolean isImportant()
- {
- return iImportant;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/ColorResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,358 +0,0 @@
-/*
-* 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: Color resolver for resolving colors set as strings.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.awt.Color;
-import java.util.Hashtable;
-
-/**
- * Color resolver for resolving colors set as strings. Corresponding
- * functionality is implemented in Xuikon CSS Parser (cssconstants.h and
- * CCSSLexicalUnit).
- *
- * Color resolver also includes HSL to RGB converting.
- *
- */
-public class ColorResolver extends Hashtable
- {
-
- // Default serial version UID
- private static final long serialVersionUID = 1L;
- private static final int RGB_MAX_VALUE = 255;
- private static final int PERCENTAGE_MAX_VALUE = 100;
-
- public ColorResolver()
- {
- // HTML4 color keywords
- put( "maroon", new Color( 128, 0, 0 ) );
- put( "red", new Color( 255, 0, 0 ) );
- put( "orange", new Color( 255, 165, 0 ) );
- put( "yellow", new Color( 255, 255, 0 ) );
- put( "olive", new Color( 128, 128, 0 ) );
- put( "purple", new Color( 128, 0, 128 ) );
- put( "fuchsia", new Color( 255, 0, 255 ) );
- put( "white", new Color( 255, 255, 255 ) );
- put( "lime", new Color( 0, 255, 0 ) );
- put( "green", new Color( 0, 128, 0 ) );
- put( "navy", new Color( 0, 0, 128 ) );
- put( "blue", new Color( 0, 0, 255 ) );
- put( "aqua", new Color( 0, 255, 255 ) );
- put( "teal", new Color( 0, 128, 128 ) );
- put( "black", new Color( 0, 0, 0 ) );
- put( "silver", new Color( 192, 192, 192 ) );
- put( "gray", new Color( 128, 128, 128 ) );
-
- // Transparent
- put( "transparent", new Color( 0, 0, 0, 0 ) );
-
- // SVG 1.0 COLOR KEYWORDS
- // (excl. the ones defined in the HTML4 colors set)
- put( "aliceblue", new Color( 240, 248, 255 ) );
- put( "antiquewhite", new Color( 250, 235, 215 ) );
- put( "aquamarine", new Color( 127, 255, 212 ) );
- put( "azure", new Color( 240, 255, 255 ) );
- put( "beige", new Color( 245, 245, 220 ) );
- put( "bisque", new Color( 255, 228, 196 ) );
- put( "blanchedalmond", new Color( 255, 235, 205 ) );
- put( "blueviolet", new Color( 138, 43, 226 ) );
- put( "brown", new Color( 165, 42, 42 ) );
- put( "burlywood", new Color( 222, 184, 135 ) );
- put( "cadetblue", new Color( 95, 158, 160 ) );
- put( "chartreuse", new Color( 127, 255, 0 ) );
- put( "chocolate", new Color( 210, 105, 30 ) );
- put( "coral", new Color( 255, 127, 80 ) );
- put( "cornflowerblue", new Color( 100, 149, 237 ) );
- put( "cornsilk", new Color( 255, 248, 220 ) );
- put( "crimson", new Color( 220, 20, 60 ) );
- put( "cyan", new Color( 0, 255, 255 ) );
- put( "darkblue", new Color( 0, 0, 139 ) );
- put( "darkcyan", new Color( 0, 139, 139 ) );
- put( "darkgoldenrod", new Color( 184, 134, 11 ) );
- put( "darkgray", new Color( 169, 169, 169 ) );
- put( "darkgrey", new Color( 169, 169, 169 ) );
- put( "darkgreen", new Color( 0, 100, 0 ) );
- put( "darkkhaki", new Color( 189, 183, 107 ) );
- put( "darkmagenta", new Color( 139, 0, 139 ) );
- put( "darkolivegreen", new Color( 85, 107, 47 ) );
- put( "darkorange", new Color( 255, 140, 0 ) );
- put( "darkorchid", new Color( 153, 50, 204 ) );
- put( "darkred", new Color( 139, 0, 0 ) );
- put( "darksalmon", new Color( 233, 150, 122 ) );
- put( "darkseagreen", new Color( 143, 188, 143 ) );
- put( "darkslateblue", new Color( 72, 61, 139 ) );
- put( "darkslategray", new Color( 47, 79, 79 ) );
- put( "darkslategrey", new Color( 47, 79, 79 ) );
- put( "darkturquoise", new Color( 0, 206, 209 ) );
- put( "darkviolet", new Color( 148, 0, 211 ) );
- put( "deeppink", new Color( 255, 20, 147 ) );
- put( "deepskyblue", new Color( 0, 191, 255 ) );
- put( "dimgray", new Color( 105, 105, 105 ) );
- put( "dimgrey", new Color( 105, 105, 105 ) );
- put( "dodgerblue", new Color( 30, 144, 255 ) );
- put( "firebrick", new Color( 178, 34, 34 ) );
- put( "floralwhite", new Color( 255, 250, 240 ) );
- put( "forestgreen", new Color( 34, 139, 34 ) );
- put( "fuchsia", new Color( 255, 0, 255 ) );
- put( "gainsboro", new Color( 220, 220, 220 ) );
- put( "ghostwhite", new Color( 248, 248, 255 ) );
- put( "gold", new Color( 255, 215, 0 ) );
- put( "goldenrod", new Color( 218, 165, 32 ) );
- put( "greenyellow", new Color( 173, 255, 47 ) );
- put( "grey", new Color( 240, 255, 240 ) );
- put( "honeydew", new Color( 240, 255, 240 ) );
- put( "hotpink", new Color( 255, 105, 180 ) );
- put( "indianred", new Color( 205, 92, 92 ) );
- put( "indigo", new Color( 75, 0, 130 ) );
- put( "ivory", new Color( 255, 255, 240 ) );
- put( "khaki", new Color( 240, 230, 140 ) );
- put( "lavender", new Color( 230, 230, 250 ) );
- put( "lavenderblush", new Color( 255, 240, 245 ) );
- put( "lawngreen", new Color( 124, 252, 0 ) );
- put( "lemonchiffon", new Color( 255, 250, 205 ) );
- put( "lightblue", new Color( 173, 216, 230 ) );
- put( "lightcoral", new Color( 240, 128, 128 ) );
- put( "lightcyan", new Color( 224, 255, 255 ) );
- put( "lightgoldenrodyellow", new Color( 250, 250, 210 ) );
- put( "lightgray", new Color( 211, 211, 211 ) );
- put( "lightgrey", new Color( 211, 211, 211 ) );
- put( "lightgreen", new Color( 144, 238, 144 ) );
- put( "lightpink", new Color( 255, 182, 193 ) );
- put( "lightsalmon", new Color( 255, 160, 122 ) );
- put( "lightseagreen", new Color( 32, 178, 170 ) );
- put( "lightskyblue", new Color( 135, 206, 250 ) );
- put( "lightslategray", new Color( 119, 136, 153 ) );
- put( "lightslategrey", new Color( 119, 136, 153 ) );
- put( "lightsteelblue", new Color( 176, 196, 222 ) );
- put( "lightyellow", new Color( 255, 255, 224 ) );
- put( "limegreen", new Color( 50, 205, 50 ) );
- put( "linen", new Color( 250, 240, 230 ) );
- put( "magenta", new Color( 255, 0, 255 ) );
- put( "mediumaquamarine", new Color( 102, 205, 170 ) );
- put( "mediumblue", new Color( 0, 0, 205 ) );
- put( "mediumorchid", new Color( 186, 85, 211 ) );
- put( "mediumpurple", new Color( 147, 112, 219 ) );
- put( "mediumseagreen", new Color( 60, 179, 113 ) );
- put( "mediumslateblue", new Color( 123, 104, 238 ) );
- put( "mediumspringgreen", new Color( 0, 250, 154 ) );
- put( "mediumturquoise", new Color( 72, 209, 204 ) );
- put( "mediumvioletred", new Color( 199, 21, 133 ) );
- put( "midnightblue", new Color( 25, 25, 112 ) );
- put( "mintcream", new Color( 245, 255, 250 ) );
- put( "mistyrose", new Color( 255, 228, 225 ) );
- put( "moccasin", new Color( 255, 228, 181 ) );
- put( "navajowhite", new Color( 255, 222, 173 ) );
- put( "oldlace", new Color( 253, 245, 230 ) );
- put( "olivedrab", new Color( 107, 142, 35 ) );
- put( "orangered", new Color( 255, 69, 0 ) );
- put( "orchid", new Color( 218, 112, 214 ) );
- put( "palegoldenrod", new Color( 238, 232, 170 ) );
- put( "palegreen", new Color( 152, 251, 152 ) );
- put( "paleturquoise", new Color( 175, 238, 238 ) );
- put( "palevioletred", new Color( 219, 112, 147 ) );
- put( "papayawhip", new Color( 255, 239, 213 ) );
- put( "peachpuff", new Color( 255, 218, 185 ) );
- put( "peru", new Color( 205, 133, 63 ) );
- put( "pink", new Color( 255, 192, 203 ) );
- put( "plum", new Color( 221, 160, 221 ) );
- put( "powderblue", new Color( 176, 224, 230 ) );
- put( "rosybrown", new Color( 188, 143, 143 ) );
- put( "royalblue", new Color( 65, 105, 225 ) );
- put( "saddlebrown", new Color( 139, 69, 19 ) );
- put( "salmon", new Color( 250, 128, 114 ) );
- put( "sandybrown", new Color( 244, 164, 96 ) );
- put( "seagreen", new Color( 46, 139, 87 ) );
- put( "seashell", new Color( 255, 245, 238 ) );
- put( "sienna", new Color( 160, 82, 45 ) );
- put( "skyblue", new Color( 135, 206, 235 ) );
- put( "slateblue", new Color( 106, 90, 205 ) );
- put( "slategray", new Color( 112, 128, 144 ) );
- put( "slategrey", new Color( 112, 128, 144 ) );
- put( "snow", new Color( 255, 250, 250 ) );
- put( "springgreen", new Color( 0, 255, 127 ) );
- put( "steelblue", new Color( 70, 130, 180 ) );
- put( "tan", new Color( 210, 180, 140 ) );
- put( "thistle", new Color( 216, 191, 216 ) );
- put( "tomato", new Color( 255, 99, 71 ) );
- put( "turquoise", new Color( 64, 224, 208 ) );
- put( "violet", new Color( 238, 130, 238 ) );
- put( "wheat", new Color( 245, 222, 179 ) );
- put( "whitesmoke", new Color( 245, 245, 245 ) );
- put( "yellowgreen", new Color( 154, 205, 50 ) );
- }
-
- /**
- * Gets the color value from percentage.
- *
- * For example:
- * 100% -> 255
- * 50% -> 128
- * 0% -> 0
- *
- * @param aPercentage the a percentage
- *
- * @return the color value from percentage
- */
- public int getColorValueFromPercentage( float aPercentage )
- {
- if ( aPercentage < 0 || PERCENTAGE_MAX_VALUE < aPercentage )
- {
- throw new IllegalStateException( "Color percentage out of range" );
- }
- float value = RGB_MAX_VALUE * ( ( aPercentage ) / PERCENTAGE_MAX_VALUE );
- return ( int ) ( value + 0.5f );
- }
-
- /**
- * Translate color from HSL to RGB.
- *
- * The algorithm is taken from
- * CSS3 Color Module:
- * http://www.w3.org/TR/css3-color/:
- *
- * @param aHue Hue
- * @param aSaturation Saturation
- * @param aLightness Lightness
- *
- * @return the color
- */
- public Color hslToRgb( float aHue, float aSaturation, float aLightness )
- {
-
- /*
- In these algorithms, all
- three values (H, S and L) have been normalized to fractions 0..1:
-
- HOW TO RETURN hsl.to.rgb(h, s, l):
- SELECT:
- l<=0.5: PUT l*(s+1) IN m2
- ELSE: PUT l+s-l*s IN m2
- PUT l*2-m2 IN m1
- PUT hue.to.rgb(m1, m2, h+1/3) IN r
- PUT hue.to.rgb(m1, m2, h ) IN g
- PUT hue.to.rgb(m1, m2, h-1/3) IN b
- RETURN (r, g, b)
-
- HOW TO RETURN hue.to.rgb(m1, m2, h):
- IF h<0: PUT h+1 IN h
- IF h>1: PUT h-1 IN h
- IF h*6<1: RETURN m1+(m2-m1)*h*6
- IF h*2<1: RETURN m2
- IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6
- RETURN m1
-
-
- */
-
- float h = aHue;
- h /= 360;
-
- if ( aSaturation < 0 || 100 < aSaturation
- || aLightness < 0 || 100 < aLightness )
- {
- throw new IllegalStateException( "HSL value out of range" );
- }
-
- float s = aSaturation;
- s /= 100;
-
- float l = aLightness;
- l /= 100;
-
- float[] color = { 0, 0, 0 };
-
- // If Saturation is zero, return gray with correct lightness
- if ( aSaturation == 0 )
- {
- int e = ( int ) ( RGB_MAX_VALUE * l + 0.5f );
- return new Color( e, e, e );
- }
-
- // HOW TO RETURN hsl.to.rgb(h, s, l):
- // SELECT:
- // l<=0.5: PUT l*(s+1) IN m2
- // ELSE: PUT l+s-l*s IN m2
- float m2 = 0;
-
- if ( l < 0.5 )
- {
- m2 = l * ( 1.0f + s );
- }
-
- if ( l >= 0.5 )
- {
- m2 = l + s - l * s;
- }
-
- // temp1 = 2.0*L - temp2
- // PUT l*2-m2 IN m1
- float m1 = 2.0f * l - m2;
-
- // PUT hue.to.rgb(m1, m2, h+1/3) IN r
- // PUT hue.to.rgb(m1, m2, h ) IN g
- // PUT hue.to.rgb(m1, m2, h-1/3) IN b
- float tempRGB[] = { h + 1.0f / 3.0f, h, h - 1.0f / 3.0f };
-
- for ( int i = 0; i < 3; i++ )
- {
- // HOW TO RETURN hue.to.rgb(m1, m2, h):
- // IF h<0: PUT h+1 IN h
- if ( tempRGB[ i ] < 0 )
- {
- tempRGB[ i ] = tempRGB[ i ] + 1.0f;
- }
- // IF h>1: PUT h-1 IN h
- if ( tempRGB[ i ] > 1 )
- {
- tempRGB[ i ] = tempRGB[ i ] - 1.0f;
- }
-
- // HOW TO RETURN hue.to.rgb(m1, m2, h):
- // IF h*6<1: RETURN m1+(m2-m1)*h*6
- if ( 6.0f * tempRGB[ i ] < 1.0f )
- {
- color[ i ] = m1 + ( m2 - m1 ) * 6.0f * tempRGB[ i ];
- }
- // HOW TO RETURN hue.to.rgb(m1, m2, h):
- // IF h*2<1: RETURN m2
- else if ( 2.0f * tempRGB[ i ] < 1.0f )
- {
- color[ i ] = m2;
- }
- // HOW TO RETURN hue.to.rgb(m1, m2, h):
- // IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6
- else if ( 3.0f * tempRGB[ i ] < 2.0f )
- {
- color[ i ] = m1 + ( m2 - m1 )
- * ( ( 2.0f / 3.0f ) - tempRGB[ i ] ) * 6.0f;
- }
- // HOW TO RETURN hue.to.rgb(m1, m2, h):
- // ELSE RETURN m1
- else
- {
- color[ i ] = m1;
- }
- }
-
- // Scale color back from [0..1] to [0..255]
- return new Color( ( int ) ( 255f * color[ 0 ] + 0.5f ),
- ( int ) ( 255f * color[ 1 ] + 0.5f ),
- ( int ) ( 255f * color[ 2 ] + 0.5f ) );
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/ElementTypeResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
-* 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: ElementTypeResolver for Different element types
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.Hashtable;
-
-/**
- * Resolves different element types by element name.
- *
- * Constants copied from Symbian side files:
- * ..\EComElement\XnDomVisitor\src\xndomvisitor.cpp
- * and
- * ..\EComElement\XnDomVisitor\inc\xnliteral.h
- *
- */
-public class ElementTypeResolver
- {
- public static final String STRING_NONE = "none";
- public static final String STRING_UNSPECIFIED = "unspecified";
- public static final String KProperty = "property";
-
- //Ui
- public static final String KXmluiml = "xmluiml";
- public static final String KInclude = "include";
- public static final String KViews = "views";
- public static final String KView = "view";
- public static final String KPanes = "panes";
- public static final String KStatusPane = "statuspane";
- public static final String KMainPane = "mainpane";
- public static final String KControlPane = "controlpane";
- public static final String KDialogs = "dialogs";
- public static final String KDialog = "dialog";
- public static final String KNote = "note";
-
- //Header
- public static final String KUiDefinition = "uidefinition";
- public static final String KApplication = "application";
- public static final String KDesc = "desc";
-
- //Control
- public static final String KButton = "button";
- public static final String KGrid = "grid";
- public static final String KListItem = "listitem";
- public static final String KDataGrid = "datagrid";
- public static final String KGridCellTemplate = "gridcelltemplate";
- public static final String KList = "list";
- public static final String KDataList = "datalist";
- public static final String KListRowTemplate = "listrowtemplate";
- public static final String KMenuBar = "menubar";
- public static final String KMenu = "menu";
- public static final String KMenuItem = "menuitem";
- public static final String KText = "text";
- public static final String KImage = "image";
- public static final String KEditor = "editor";
- public static final String KMarquee = "marquee";
- public static final String KNewsticker = "newsticker";
- public static final String KTooltip = "tooltip";
-
- //XHTML
- public static final String KObject = "object";
- public static final String KParam = "param";
-
- //Box
- public static final String KBox = "box";
-
- //Interaction
- public static final String KAction = "action";
- public static final String KTrigger = "trigger";
- public static final String KEvent = "event";
-
- public static final String VIEW_ELEMENT = "viewElement";
- public static final String COMMON_ELEMENT = "commonElement";
- public static final String TEXT_ELEMENT = "textElement";
- public static final String GRID_AND_DATAGRID_ELEMENT = "gridAndDataGridelement";
- public static final String GRID_AND_LIST_ELEMENT = "gridAndListElement";
-
- private Hashtable iElementTypeTable;
-
- /**
- * Instantiates a new element type resolver.
- */
- public ElementTypeResolver()
- {
- iElementTypeTable = new Hashtable();
- iElementTypeTable.put( KXmluiml, STRING_UNSPECIFIED );
- iElementTypeTable.put( KProperty, STRING_UNSPECIFIED );
- iElementTypeTable.put( KXmluiml, STRING_UNSPECIFIED );
- iElementTypeTable.put( KInclude, STRING_UNSPECIFIED );
- iElementTypeTable.put( KViews, STRING_UNSPECIFIED );
- iElementTypeTable.put( KView, VIEW_ELEMENT );
- iElementTypeTable.put( KPanes, COMMON_ELEMENT );
- iElementTypeTable.put( KStatusPane, COMMON_ELEMENT );
- iElementTypeTable.put( KMainPane, COMMON_ELEMENT );
- iElementTypeTable.put( KControlPane, COMMON_ELEMENT );
- iElementTypeTable.put( KDialogs, COMMON_ELEMENT );
- iElementTypeTable.put( KDialog, COMMON_ELEMENT );
- iElementTypeTable.put( KNote, TEXT_ELEMENT );
- iElementTypeTable.put( KUiDefinition, STRING_UNSPECIFIED );
- iElementTypeTable.put( KApplication, STRING_UNSPECIFIED );
- iElementTypeTable.put( KDesc, STRING_UNSPECIFIED );
- iElementTypeTable.put( KButton, TEXT_ELEMENT );
- iElementTypeTable.put( KGrid, GRID_AND_DATAGRID_ELEMENT );
- iElementTypeTable.put( KListItem, TEXT_ELEMENT );
- iElementTypeTable.put( KDataGrid, GRID_AND_DATAGRID_ELEMENT );
- iElementTypeTable.put( KGridCellTemplate, COMMON_ELEMENT );
- iElementTypeTable.put( KList, GRID_AND_LIST_ELEMENT );
- iElementTypeTable.put( KDataList, GRID_AND_LIST_ELEMENT );
- iElementTypeTable.put( KListRowTemplate, COMMON_ELEMENT );
- iElementTypeTable.put( KMenuBar, STRING_UNSPECIFIED );
- iElementTypeTable.put( KMenu, STRING_UNSPECIFIED );
- iElementTypeTable.put( KMenuItem, STRING_UNSPECIFIED );
- iElementTypeTable.put( KText, TEXT_ELEMENT );
- iElementTypeTable.put( KImage, COMMON_ELEMENT );
- iElementTypeTable.put( KEditor, TEXT_ELEMENT );
- iElementTypeTable.put( KMarquee, TEXT_ELEMENT );
- iElementTypeTable.put( KNewsticker, TEXT_ELEMENT );
- iElementTypeTable.put( KObject, STRING_UNSPECIFIED );
- iElementTypeTable.put( KParam, STRING_UNSPECIFIED );
- iElementTypeTable.put( KTooltip, TEXT_ELEMENT );
- iElementTypeTable.put( KBox, COMMON_ELEMENT );
- iElementTypeTable.put( KAction, STRING_UNSPECIFIED );
- iElementTypeTable.put( KTrigger, STRING_UNSPECIFIED );
- iElementTypeTable.put( KEvent, STRING_UNSPECIFIED );
- }
-
- /**
- * Gets the elements type.
- *
- * @param aKey Elements name
- *
- * @return The elements type
- */
- public String getValue( String aKey )
- {
- if ( iElementTypeTable.containsKey( aKey ) )
- {
- return ( String ) iElementTypeTable.get( aKey );
- }
- return STRING_NONE;
- }
-
- /**
- * Resolves if element can have inherited properties.
- *
- * @param aKey Elements name
- *
- * @return true, Element with given name can inherit properties
- */
- public boolean canInherit( String aKey )
- {
- if ( !iElementTypeTable.containsKey( aKey ) )
- {
- return false;
- }
- if ( iElementTypeTable.get( aKey ).equals( STRING_UNSPECIFIED ) )
- {
- return false;
- }
- return true;
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/PseudoClassResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
-* 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: Pseudo class resolver for CSS Style properties
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.cssparser;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-/**
- * Resolves pseudo class values by keys.
- */
-public class PseudoClassResolver
- {
-
- // Pseudo class keys
- public static final int UNKNOWN = -1;
- public static final int NONE = 0;
- public static final int FOCUS = 1;
- public static final int PASSIVE_FOCUS = 2;
- public static final int ACTIVE = 3;
- public static final int HOLD = 4;
- public static final int ENABLED = 5;
- public static final int DISABLED = 6;
- public static final int HOVER = 7;
- public static final int LINK = 8;
- public static final int VISITED = 9;
- public static final int EDIT = 10;
-
- // Pseudo class values
- private static final String NONE_VALUE = "none";
- private static final String FOCUS_VALUE = "focus";
- private static final String PASSIVE_FOCUS_VALUE = "passivefocus";
- private static final String ACTIVE_VALUE = "active";
- private static final String HOLD_VALUE = "hold";
- private static final String ENABLED_VALUE = "enabled";
- private static final String DISABLED_VALUE = "disabled";
- private static final String HOVER_VALUE = "hover";
- private static final String LINK_VALUE = "link";
- private static final String VISITED_VALUE = "visited";
- private static final String EDIT_VALUE = "edit";
-
- private Hashtable iPseudoClassTable;
-
- /**
- * Constructor.
- */
- public PseudoClassResolver()
- {
- iPseudoClassTable = new Hashtable();
- iPseudoClassTable.put( new Integer( NONE ), NONE_VALUE );
- iPseudoClassTable.put( new Integer( FOCUS ), FOCUS_VALUE );
- iPseudoClassTable.put( new Integer( PASSIVE_FOCUS ), PASSIVE_FOCUS_VALUE );
- iPseudoClassTable.put( new Integer( ACTIVE ), ACTIVE_VALUE );
- iPseudoClassTable.put( new Integer( HOLD ), HOLD_VALUE );
- iPseudoClassTable.put( new Integer( ENABLED ), ENABLED_VALUE );
- iPseudoClassTable.put( new Integer( DISABLED ), DISABLED_VALUE );
- iPseudoClassTable.put( new Integer( HOVER ), HOVER_VALUE );
- iPseudoClassTable.put( new Integer( LINK ), LINK_VALUE );
- iPseudoClassTable.put( new Integer( VISITED ), VISITED_VALUE );
- iPseudoClassTable.put( new Integer( EDIT ), EDIT_VALUE );
- }
-
- /**
- * Get pseudo class value by its key.
- * @param aClassKey Pseudo class key, for example, FOCUS
- * @return Pseudo class value, for example, "focus". Returns null if
- * the value can not be resolved.
- */
- public String getValue( Integer aClassKey )
- {
- return ( String ) iPseudoClassTable.get( aClassKey );
- }
-
- /**
- * Get pseudo class key by its value.
- * @param aClassValue Pseudo class value, for example, "focus"
- * @return Pseudo class key, for example, FOCUS. Returns UNKNOWN if the
- * value can not be resolved.
- */
- public int getKey( String aClassValue )
- {
- int result = UNKNOWN;
-
- Enumeration keys = iPseudoClassTable.keys();
- while ( keys.hasMoreElements() )
- {
- int key = ( ( Integer ) keys.nextElement() ).intValue();
- if ( aClassValue.equals( getValue( new Integer( key ) ) ) )
- {
- result = key;
- break;
- }
- }
-
- return result;
- }
-
- /**
- * Gets the table of pseudo class values.
- *
- * @return The table
- */
- public Collection getPseudoTypes()
- {
- return iPseudoClassTable.values();
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/DefinitionRepository.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/*
- * 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: Definition Repository implementation
- *
- */
-
-package com.nokia.tools.themeinstaller.defrep;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Observer;
-
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-import com.nokia.tools.themeinstaller.odtconverter.ThemeStatusResolver;
-import com.nokia.tools.themeinstaller.defrep.operations.CopyOperation;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperation;
-import com.nokia.tools.themeinstaller.defrep.operations.StoreOperation;
-
-/**
- * Definition repository class.
- */
-public class DefinitionRepository implements IDefinitionRepository {
-
- // CONSTANTS
- // Property keys
- private static final String THEMES_ROOT_ROM = "themes_datacage_rom";
- private static final String THEMES_ROOT_USER_DISC = "themes_datacage_user_disc";
- private static final String ODT_FILE_EXT_FORMAT = "odt_file_ext_format";
- private static final String ODT_RESOURCES_FOLDER = "odt_resources_folder";
- private static final String ODT_LANG_RESOURCES_FOLDER = "odt_lang_resources_folder";
-
- // Singleton instance
- private static DefinitionRepository sInstance = null;
-
- /**
- * Definition repository private constructor.
- */
- private DefinitionRepository() {
- }
-
- /**
- * Get a Definition Repository instance (singleton).
- *
- * @return Definition Repository instance
- */
- public static DefinitionRepository getInstance() {
- if (sInstance == null) {
- sInstance = new DefinitionRepository();
- }
-
- return sInstance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.nokia.tools.odtconverter.defrep.IDefinitionRepository#copy(java.lang
- * .String, java.util.Observer)
- */
- public void copy(File aSource, File aDestination, boolean aAppend,
- Observer aListener) {
- CopyOperation operation = new CopyOperation(aSource, aDestination,
- aAppend);
- operation.addObserver(aListener);
- performOperation(operation);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.nokia.tools.odtconverter.defrep.IDefinitionRepository#store(java.
- * lang.String, java.io.InputStream, java.util.Observer)
- */
- public void store(File aDestination, InputStream aStream, Observer aListener) {
- StoreOperation operation = new StoreOperation(aDestination, aStream);
- operation.addObserver(aListener);
- performOperation(operation);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.nokia.tools.odtconverter.defrep.IDefinitionRepository#storeODT(java
- * .io.File, com.nokia.tools.odtconverter.ODTDocument, java.util.Observer)
- */
- public void storeODT(File aDestination, ODTHeader aHeader,
- InputStream aStream, Observer aListener) throws IOException {
- File destination = new File(createODTPath(aDestination, aHeader));
- store(destination, aStream, aListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.nokia.tools.odtconverter.defrep.IDefinitionRepository#copyResource
- * (java.io.File, java.io.File, com.nokia.tools.odtconverter.ODTHeader,
- * java.util.Observer)
- */
- public void copyResource(File aSource, File aDestination,
- ODTHeader aHeader, Observer aListener) throws IOException {
- ConverterProperties properties = ConverterProperties.getInstance();
- StringBuffer odtPath = combineDirectory(aDestination, aHeader,
- properties);
-
- // Get the language to resolve the destination directory
- Integer language = (Integer) aHeader.get(ODTHeader.Language);
- if (language != null) {
- // Location for language specific resources
- String template = properties.getProperty(ODT_LANG_RESOURCES_FOLDER);
-
- Integer[] formatArguments = { language };
- odtPath.append(String.format(template, formatArguments));
- } else {
- // Location for language independent resources
- odtPath.append(properties.get(ODT_RESOURCES_FOLDER));
- }
-
- odtPath.append(aSource.getName());
- File destFile = new File(odtPath.toString());
- copy(aSource, destFile, false, aListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.nokia.tools.odtconverter.defrep.IDefinitionRepository#createODTPath
- * (java.lang.String, com.nokia.tools.odtconverter.ODTHeader,
- * com.nokia.tools.odtconverter.ConverterProperties)
- */
- public String createODTPath(File aDestination, ODTHeader aHeader) {
- // Get themes installation directory from the properties
- ConverterProperties properties = ConverterProperties.getInstance();
-
- StringBuffer odtPath = combineDirectory(aDestination, aHeader,
- properties);
-
- // Append ODT file name
- odtPath.append(aHeader.get(ODTHeader.ThemeShortName));
-
- // Append extension according to the language
- String format = properties.getProperty(ODT_FILE_EXT_FORMAT);
- Integer[] formatArguments = { (Integer) aHeader.get(ODTHeader.Language) };
- odtPath.append(String.format(format, formatArguments));
-
- return odtPath.toString();
- }
-
- /**
- * Combine the installation directory structure. According to the Xuikon,
- * the destination directory for locked themes is ROM location. Other themes
- * are stored to the user disk. Rest of the path is determined by theme
- * details: Application UID, Provider UID, Theme UID and Theme Version.
- *
- * @param aDestination
- * destination root directory, usually the epoc root
- * @param aHeader
- * ODT file header
- * @param aProperties
- * converter properties instance
- * @return complete destination path name for the installed theme
- */
- private StringBuffer combineDirectory(File aDestination, ODTHeader aHeader,
- ConverterProperties aProperties) {
- StringBuffer odtPath = new StringBuffer();
- odtPath.append(aDestination.getPath());
-
- // Add file separator only if the destination directory does not
- // already end with the separator
- if (!aDestination.getPath().endsWith(File.separator)) {
- odtPath.append(File.separator);
- }
-
- // if EXnThemeStatusLicenceeDefault flag is set,
- // theme is installed to ROM (z:\) otherwise to user disc (c:\)
- if ((((Integer) aHeader.get(ODTHeader.Flags)).intValue() & ThemeStatusResolver.E_XN_THEME_STATUS_LICENCEE_DEFAULT) != 0) {
- odtPath.append(aProperties.getProperty(THEMES_ROOT_ROM));
- } else {
- odtPath.append(aProperties.getProperty(THEMES_ROOT_USER_DISC));
- }
-
- //Bypass adding appuid etc, if we don't have these properties
- if (aHeader.get(ODTHeader.ApplicationUID) != null && aHeader.get(ODTHeader.ProviderUID)!= null
- && aHeader.get(ODTHeader.ThemeUID) != null && aHeader.get(ODTHeader.ThemeVersion) != null){
- // Append Application UID
- odtPath.append(((Long) aHeader.get(ODTHeader.ApplicationUID))
- .longValue());
-
- odtPath.append(File.separator);
-
- // Append Provider UID
- odtPath.append(((Long) aHeader.get(ODTHeader.ProviderUID))
- .longValue());
- odtPath.append(File.separator);
-
- // Append Theme UID
- odtPath
- .append(((Long) aHeader.get(ODTHeader.ThemeUID))
- .longValue());
- odtPath.append(File.separator);
-
- // Append Theme version
- odtPath.append(aHeader.get(ODTHeader.ThemeVersion));
- odtPath.append(File.separator);
- }
- return odtPath;
- }
-
- /**
- * Start a file operation in a new thread.
- *
- * @param aOperation
- * The operation to start.
- */
- private void performOperation(FileOperation aOperation) {
- Thread thread = new Thread(aOperation);
- thread.start();
- }
-
-}
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/IDefinitionRepository.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
-* 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: Interface to the Definition Repository
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Observer;
-
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-
-
-/**
- * Interface to the Defition Repository.
- */
-public interface IDefinitionRepository
- {
- /**
- * Copy a file.
- * @param aSource Source file
- * @param aDestination Destination file
- * @param aAppend Append to the destination file if it exists
- * @param aListener File operation listener to inform operation completion
- */
- public void copy( File aSource,
- File aDestination,
- boolean aAppend,
- Observer aListener );
-
- /**
- * Store a file to the file system.
- *
- * @param aDestination Destination file
- * @param aStream Source stream
- * @param aListener File operation listener to inform operation completion
- */
- public void store( File aDestination,
- InputStream aStream,
- Observer aListener );
-
- /**
- * Store an ODT Document to the file system.
- *
- * @param aDestination Destination root folder for the ODT file. Normally,
- * the epocroot is specified.
- * @param aHeader ODT header
- * @param aStream Input stream containing the ODT file contents
- * @param aListener File operation listener
- * @throws IOException if required properties can not be read from the
- * property file.
- */
- public void storeODT( File aDestination,
- ODTHeader aHeader,
- InputStream aStream,
- Observer aListener ) throws IOException;
-
- /**
- * Copies resource to destination folder
- *
- * @param aSource Source file
- * @param aDestination Root of destination folder
- * @param aHeader ODT header
- * @throws IOException if required properties can not be read, or
- * some other IO exception during copy operation
- */
- public void copyResource( File aSource,
- File aDestination,
- ODTHeader aHeader,
- Observer aListener ) throws IOException;
-
- /**
- * Create a path and file name of an ODT file.
- *
- * @param aDestination Root destination
- * @param aHeader ODT header
- * @return Path to the ODT file
- */
- public String createODTPath( File aDestination, ODTHeader aHeader );
-
- }
-
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/operations/CopyOperation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
-* 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: File operation for copying the installable files
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep.operations;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * Operation for copying files.
- */
-public class CopyOperation extends FileOperation
- {
-
- // Destination file
- private File iDestination;
-
- // Append flag
- private boolean iAppend;
-
- /**
- * Create a copy operation
- *
- * @param aSource Source file name
- * @param aDestination Destination file name
- * @param aAppend Append to the destination file if it exists
- */
- public CopyOperation( File aSource, File aDestination, boolean aAppend )
- {
- iFile = aSource;
- iDestination = aDestination;
- iAppend = aAppend;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- int error = FileOperationEvent.UNKNOWN_ERROR;
-
- // Perform the copy operation
- try
- {
- FileOperationUtils.copyFile( iFile, iDestination, iAppend );
- error = FileOperationEvent.OPERATION_SUCCESSFUL;
- }
- catch( FileNotFoundException fnfe )
- {
- error = FileOperationEvent.FILE_NOT_FOUND_ERROR;
- }
- catch( IOException ioe )
- {
- error = FileOperationEvent.IO_ERROR;
- }
-
- // Report results to the operation listeners
- super.finished( iDestination, error );
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/operations/FileOperation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
-* 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: Base class for file operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep.operations;
-
-import java.io.File;
-import java.util.Observable;
-import java.util.Observer;
-
-public abstract class FileOperation extends Observable implements Runnable
- {
-
- // File related to the operation
- protected File iFile;
-
- // Listener of the operation
- protected Observer iListener;
-
- /**
- * Called when the operation is finished. Sets the observable object as
- * changed and notifies its observers.
- *
- * @param aFile The file under operation
- * @param aErrorCode Error code
- */
- protected void finished( File aFile, int aErrorCode )
- {
- FileOperationEvent event = new FileOperationEvent( aFile,
- aErrorCode );
- super.setChanged();
- super.notifyObservers( event );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/operations/FileOperationEvent.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
-* 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: An event for informing about file operation completion
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep.operations;
-
-import java.io.File;
-
-public class FileOperationEvent
- {
-
- // CONSTANTS
- public static final int OPERATION_SUCCESSFUL = 0;
- public static final int FILE_NOT_FOUND_ERROR = -1;
- public static final int IO_ERROR = -2;
- public static final int UNKNOWN_ERROR = -3;
-
- // The file related to the operation
- private File iFile;
-
- // Destination file of the operation (in Symbian OS filesystem)
- private String iDestPath;
-
- // Error code of the finished operation
- private int iErrorCode;
-
- /**
- * File operation event constructor.
- *
- * @param aFileName File related to the event
- * @param aErrorCode Error code of the completed operation
- */
- public FileOperationEvent( File aFile, int aErrorCode )
- {
- iFile = aFile;
- iErrorCode = aErrorCode;
- iDestPath = FileOperationUtils.parseSymbianFSPath( iFile );
- }
-
- /**
- * Get the file.
- * @return The file
- */
- public File getFile()
- {
- return iFile;
- }
-
- /**
- * Get the error code.
- * @return The error code
- */
- public int getErrorCode()
- {
- return iErrorCode;
- }
-
- /**
- * Get the destination path in Symbian OS file system.
- * @return the iDestPath Destination path
- */
- public String getDestPath()
- {
- return iDestPath;
- }
-
- /**
- * Get the full destination path in PC file system.
- * @return the iFile's path
- */
- public String getFullDestPath()
- {
- return iFile.getPath();
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/operations/FileOperationUtils.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
-* 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: Utils for file operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep.operations;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-
-/**
- * Utils for file operations.
- */
-public class FileOperationUtils
- {
-
- // CONSTANTS
- private static final int READ_BUFFER_SIZE = 1024;
- private static final String REGEXP_PREFIX = "\\";
- private static final char EPOC_DRIVE_SEP = ':';
- private static final String EPOC_PATH_SEP = "\\";
- private static final char EPOC_DRIVE_LETTER_FIRST_U = 'A';
- private static final char EPOC_DRIVE_LETTER_LAST_U = 'Z';
- private static final char EPOC_DRIVE_LETTER_FIRST_L = 'a';
- private static final char EPOC_DRIVE_LETTER_LAST_L = 'z';
- private static final String EPOC32_DIR = "epoc32";
-
- /**
- * Copy a file to an another location.
- *
- * @param aSource Source file
- * @param aDestination Destination file
- * @param aAppend If true, the source file contents will be appended to the end of
- * the destination file. Otherwise, the original file will be overwritten.
- * @throws FileNotFoundException Thrown if the file can not be found
- * @throws IOException Thrown if IOException occurs, open streams are also closed
- */
- public static void copyFile( File aSource, File aDestination, boolean aAppend )
- throws FileNotFoundException, IOException
- {
- // Overwrite the existing file, if any
- if( aDestination.exists() && !aAppend )
- {
- aDestination.delete();
- }
-
- // Create the required directory structure for the destination file
- // (ignore return value)
- createDirs( aDestination );
-
- // Open streams for input and output
- FileInputStream input = new FileInputStream( aSource );
- FileOutputStream output = new FileOutputStream( aDestination, aAppend );
-
- // Create buffer for the data transfer
- byte[] buffer = new byte[ READ_BUFFER_SIZE ];
- int i = 0;
-
- try
- {
- // Read data to the buffer and write it to the output stream until
- // the whole file is processed
- while( ( i = input.read( buffer ) ) != -1 )
- {
- output.write( buffer, 0, i );
- }
- }
- finally
- {
- if( input != null )
- {
- input.close();
- }
- if( output != null )
- {
- output.close();
- }
- }
- }
-
- /**
- * Create the whole directory structure for the file
- *
- * @param aFile File object to be placed at the end of the tree
- * @return true, if new directories were created
- */
- public static boolean createDirs( File aFile )
- {
- // Extract the parent directory
- String parent = aFile.getParent();
-
- // Create the whole directory structure
- File dir = new File( parent );
- return dir.mkdirs();
- }
-
- /**
- * Parse Symbian OS file system format path of a Winscw environment path.
- * This method will search for a directory of which name is one character
- * long and from a to z.
- * @param aFile The file to process
- * @return Path and file name in Symbian OS file system. Returns null if
- * the file name can not be parsed.
- */
- public static String parseSymbianFSPath( File aFile )
- {
- String result = null;
- String path = aFile.getPath();
-
- File file = aFile.getParentFile();
-
- // Go through all parent directories of the file
- while( file != null )
- {
- // Find a directory of which name is 1 character long
- String name = file.getName();
- if( name.length() == 1 )
- {
- // Check that the directory name is an character
- // from A to Z or a to z
- char c = name.charAt( 0 );
- if( ( c >= EPOC_DRIVE_LETTER_FIRST_U &&
- c <= EPOC_DRIVE_LETTER_LAST_U ) ||
- ( c >= EPOC_DRIVE_LETTER_FIRST_L &&
- c <= EPOC_DRIVE_LETTER_LAST_L ) )
- {
- result = name;
- }
- }
- // Stop if already reached to the epoc32 directory
- else if( EPOC32_DIR.equalsIgnoreCase( name ) )
- {
- break;
- }
-
- file = file.getParentFile();
- }
-
- if( result != null )
- {
- String pattern = File.separatorChar + result + File.separatorChar;
-
- // Find the start of the actual path
- int pathStart = path.indexOf( pattern ) + pattern.length();
-
- // Combine the Symbian OS format path of the drive letter,
- // path separator and rest of the path
- result = result +
- EPOC_DRIVE_SEP +
- EPOC_PATH_SEP +
- path.substring( pathStart );
-
- // Replace path separators with Epoc ones
- pattern = REGEXP_PREFIX + File.separator;
- String replacement = REGEXP_PREFIX + EPOC_PATH_SEP;
- result = result.replaceAll( pattern, replacement );
- }
-
- return result;
- }
-
- /**
- * Parse Symbian OS file system format path of a Winscw environment path.
- * @param aFile The file name to process
- * @return Path and file name in Symbian OS file system. Returns null if
- * the file name can not be parsed.
- */
- public static String parseSymbianFSPath( String aFile )
- {
- File f = new File( aFile );
- return parseSymbianFSPath( f );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/defrep/operations/StoreOperation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
-* 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: File operation for storing an ODT file to the file system
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.defrep.operations;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Operation for storing data to the file system.
- */
-public class StoreOperation extends FileOperation
- {
-
- // CONSTANTS
- private static final int READ_BUFFER_SIZE = 1024;
-
- // Input stream for data input
- private InputStream iStream;
-
- /**
- * Create a store operation
- *
- * @param aDestination Destination file
- * @param aStream Input stream containing the data
- */
- public StoreOperation( File aDestination, InputStream aStream )
- {
- iFile = aDestination;
- iStream = aStream;
- }
-
- public void run()
- {
- int error = FileOperationEvent.UNKNOWN_ERROR;
-
- try
- {
- doStoreOperation();
- error = FileOperationEvent.OPERATION_SUCCESSFUL;
- }
- catch ( IOException ioe )
- {
- error = FileOperationEvent.IO_ERROR;
- }
-
- super.finished( iFile, error );
- }
-
- private void doStoreOperation()
- throws IOException
- {
- // Overwrite the existing file, if any
- if( iFile.exists() )
- {
- iFile.delete();
- }
-
- // Create the required directory structure for the destination file
- // (ignore return value)
- FileOperationUtils.createDirs( iFile );
-
- FileOutputStream output = null;
-
- try
- {
- output = new FileOutputStream( iFile );
-
- // Create a buffer for the data transfer
- byte[] buffer = new byte[ READ_BUFFER_SIZE ];
- int i = 0;
-
- // Read data to the buffer and write it to the output stream until
- // the whole stream is processed
- while( ( i = iStream.read( buffer ) ) != -1 )
- {
- output.write( buffer, 0, i );
- }
- }
- finally
- {
- if( output != null )
- {
- output.close();
- }
- }
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/IInstallationListener.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-* 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: This class is interface for ODT installation
- *
-*/
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-public interface IInstallationListener
- {
-
- // CONSTANTS
- // Installation states
- public static final int STATE_PARSED = 1;
- public static final int STATE_WRITED = 2;
- public static final int NO_ERROR = 0;
- public static final int ERROR = -1;
-
- /**
- * Called when installation has progressed
- * @param aEvent Progress event
- */
- public void installationProgress( ProgressEvent aEvent );
-
- /**
- * Called when installation is finished
- * @param aEvent Progress event
- */
- public void installationCompleted( ProgressEvent aEvent );
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/IResourceInstaller.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
-* 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: Interface for resource installer
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.IOException;
-import java.util.Vector;
-
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-import com.nokia.tools.themeinstaller.odtconverter.ODTResource;
-
-/**
- * Interface for resource installer.
- */
-public interface IResourceInstaller
- {
-
- /**
- * Install a list of resource files. Copies resource files and creates
- * a list of ODT Resources.
- * @param aResources List of resource files to install
- * @param aHeader ODT Header for determining the install location. The
- * header is not altered
- * @return List of created ODT Resources
- * @throws IOException if resource file copying fails
- */
- public Vector installResources(
- Vector aResources,
- ODTHeader aHeader ) throws IOException;
-
-
- /**
- * Install a resource file. Copies the resource file and creates
- * an ODT Resource.
- * @param aResource The resource file to install
- * @param aHeader ODT Header for determining the install location. The
- * header is not altered
- * @return Created ODT Resource
- * @throws IOException if resource file can not be copied
- */
- public ODTResource installResource( ThemeResource aResource,
- ODTHeader aHeader ) throws IOException;
-
- /**
- * Puts ODT file itself as a resource
- * @param aHeader ODT Header of the ODT to add as resource. The header
- * itself is not altered
- * @param aNameSpace Theme name space
- * @return new ODTResource object
- */
- public ODTResource createODTResource( ODTHeader aHeader,
- String aNameSpace );
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/IThemeManifest.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-/*
-* 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: Interface for theme manifest
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.util.Vector;
-
-/**
- * Interface for theme manifest.
- */
-public interface IThemeManifest
- {
-
- /**
- * Get application uid.
- * @return the application uid
- */
- public Long getApplicationUid();
-
- /**
- * Get provider uid.
- * @return the provider uid
- */
- public Long getProviderUid();
-
- /**
- * Get theme uid.
- * @return the theme uid
- */
- public Long getThemeUid();
-
- /**
- * Get provider name.
- * @return the provider name
- */
- public String getProviderName();
-
- /**
- * Get theme full name (not localized).
- * @return the theme full name
- */
- public String getThemeFullName();
-
- /**
- * Get theme short name.
- * @return the theme short name
- */
- public String getThemeShortName();
-
- /**
- * Get theme version.
- * @return the theme version
- */
- public String getThemeVersion();
-
- /**
- * Get horizontal screen size.
- * @return the screen size x value
- */
- public Integer getScreenSizeX();
-
- /**
- * Get vertical screen size.
- * @return the screen size y value
- */
- public Integer getScreenSizeY();
-
- /**
- * Get theme status. Theme status flags are a bit mask created from
- * theme status. See Xuikon for more information.
- * @return the flags
- */
- public Integer getThemeStatus();
-
- /**
- * Get theme XML file name.
- * @return the XML file name
- */
- public String getXMLFile();
-
- /**
- * Get theme CSS file name.
- * @return the CSS file name
- */
- public String getCSSFile();
-
- /**
- * Get theme DTD file name.
- * @return the DTD file name
- */
- public String getDTDFile();
-
- /**
- * Get all resources.
- * @return the list of resource files
- */
- public Vector getResources();
-
- /**
- * Get all language specific data.
- * @return the list of languages
- */
- public Vector getLanguages();
-
- /**
- * Get all manifest files of a multi theme manifest.
- * @return the list of manifest files
- */
- public Vector getManifestFiles();
-
- /**
- * Get the data directory that contains the theme files.
- * @return the data directory
- */
- public String getDataDir();
-
- /**
- * Get the name space of the theme.
- * @return the theme name space
- */
- public String getNameSpace();
-
- /**
- * Set application uid.
- * @param aApplicationUid the application uid
- */
- public void setApplicationUid( Long aApplicationUid );
-
- /**
- * Set provider uid.
- * @param aProviderUid the provider uid
- */
- public void setProviderUid( Long aProviderUid );
-
- /**
- * Set theme uid.
- * @param aThemeUid the theme uid
- */
- public void setThemeUid( Long aThemeUid );
-
- /**
- * Set provider name.
- * @param aProviderName the provider name
- */
- public void setProviderName( String aProviderName );
-
- /**
- * Set theme full name (not localized).
- * @param aThemeFullName the theme full name
- */
- public void setThemeFullName( String aThemeFullName );
-
- /**
- * Set theme short name.
- * @param aThemeShortName the theme short name
- */
- public void setThemeShortName( String aThemeShortName );
-
- /**
- * Set theme version.
- * @param the theme version
- */
- public void setThemeVersion( String aThemeVersion );
-
- /**
- * Set horizontal screen size.
- * @param aScreenSizeX the screen size x value
- */
- public void setScreenSizeX( Integer aScreenSizeX );
-
- /**
- * Set vertical screen size.
- * @param aScreenSizeY the screen size y value
- */
- public void setScreenSizeY( Integer aScreenSizeY );
-
- /**
- * Set theme status. Theme status flags are a bit mask created
- * from theme status. See Xuikon for more information.
- * @param aFlags the flags
- */
- public void setThemeStatus( Integer aThemeStatus );
-
- /**
- * Set theme XML file name.
- * @param aXMLFile the XML file name
- */
- public void setXMLFile( String aXMLFile );
-
- /**
- * Set theme CSS file name.
- * @param aCSSFile the CSS file name
- */
- public void setCSSFile( String aCSSFile );
-
- /**
- * Set theme DTD file name.
- * @param aDTDFile the DTD file name
- */
- public void setDTDFile( String aDTDFile );
-
- /**
- * Add a resource.
- * @param the resource to add
- */
- public void addResource( ThemeResource aResource );
-
- /**
- * Add a language.
- * @param the language to add
- */
- public void addLanguage( LanguageSpecificData aLanguage );
-
- /**
- * Add a manifest file of a multi theme manifest.
- * @param the manifest file name to add
- */
- public void addManifestFile( String aFileDAT );
-
- /**
- * Set the data directory that contains the theme files.
- * @param aDataDir the data directory
- */
- public void setDataDir( String aDataDir );
-
- /**
- * Set the name space of the theme.
- * @param aNameSpace the theme name space
- */
- public void setNameSpace( String aNameSpace );
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/InstallationList.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
-* 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: Installation list for monitoring language variants under install.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.util.Vector;
-
-/**
- * Installation list for monitoring language variants under install.
- */
-public class InstallationList
- {
-
- // CONSTANTS
- private static final int NOT_FOUND = -1;
- private static final String EXT_PREFIX = ".o";
-
- // Languages under install
- private Vector iLanguages;
-
- /**
- * Constructor.
- */
- public InstallationList()
- {
- iLanguages = new Vector();
- }
-
- /**
- * Add a language under install.
- * @param aLanguage language id
- */
- public void addInstall( Integer aLanguage )
- {
- iLanguages.add( aLanguage );
- }
-
- /**
- * Remove a language from list when the installation has completed.
- * @param aODTFileName path and file name of the installed ODT.
- * @return true if a language was removed from the list
- */
- public boolean removeInstall( String aODTFileName )
- {
- // No localized as default
- int languageId = NOT_FOUND;
- int extIndex = NOT_FOUND;
- if( aODTFileName != null )
- {
- extIndex = aODTFileName.lastIndexOf( EXT_PREFIX );
- }
- if( extIndex >= 0 )
- {
- String language = aODTFileName.substring( extIndex + EXT_PREFIX.length() );
- if( language != null &&
- !language.equals( "" ) )
- {
- languageId = Integer.valueOf( language ).intValue();
- }
- }
-
- return removeInstall( languageId );
- }
-
- /**
- * Remove a language from list when the installation has completed.
- * @param aLanguage language id
- * @return true if a language was removed from the list
- */
- public boolean removeInstall( int aLanguage )
- {
- boolean result = false;
- int index = findLanguage( aLanguage );
- if( index >= 0 )
- {
- iLanguages.remove( index );
- result = true;
- }
-
- return result;
- }
-
- /**
- * Check if there are ongoing installations in the list.
- * @return true if there are installtions in the list
- */
- public boolean installsExist()
- {
- if( iLanguages.size() > 0 )
- {
- return true;
- }
- return false;
- }
-
- /**
- * Find a language from the list.
- * @param aLanguage language id
- * @return index of the language in the list
- */
- private int findLanguage( int aLanguage )
- {
- int count = iLanguages.size();
- for( int i = 0; i < count; i++ )
- {
- Integer integer = ( Integer ) iLanguages.elementAt( i );
- if( integer.intValue() == aLanguage )
- {
- return i;
- }
- }
-
- return NOT_FOUND;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/InstallationManager.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,430 +0,0 @@
-/*
-* 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: Starting point for theme install procedure.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Vector;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
-
-import com.nokia.tools.themeinstaller.defrep.DefinitionRepository;
-import com.nokia.tools.themeinstaller.defrep.IDefinitionRepository;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperation;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperationEvent;
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.odtconverter.ODTDocument;
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-import com.nokia.tools.themeinstaller.odtconverter.ODTInputStream;
-import com.sun.org.apache.xpath.internal.XPathAPI;
-
-/**
- * Installation Manager class is the starting point for the theme installation
- * procedure.
- */
-public class InstallationManager implements Observer, IInstallationListener
- {
-
- protected static final String MANIFEST_SUFFIX = ".dat";
-
- // Theme manifest file
- private File iManifest;
-
- // Destination root directory
- private File iDestinationDir;
-
- // Definition repository for file operations
- private IDefinitionRepository iDefRep;
-
- // Data directory containing the theme to install
- private String iDataDir;
-
- // Installation observer
- private IInstallationListener iListener;
-
- // Resource installer
- private IResourceInstaller iResourceInstaller;
-
- // Installation list of ongoing installations
- private InstallationList iList;
-
- // Lock for asynchronous operations.
- private Lock iLock;
-
- // Lock for multi theme installs
- private Lock iMultiThemeLock;
-
- // Localisation settings
- private File iLocSettings;
-
- //DTD may contain some errors such as missing semicolon. Set
- //this to true if these are to be fixed. Currently passed via
- //argument.
- private static boolean fixDTD = false;
-
- /**
- * Default constructor
- * @param aParams Installation parameters
- * @param aListener Installation observer
- * @throws IOException if Resource Installer can not be created
- */
- public InstallationManager( InstallationParameters aParams,
- IInstallationListener aListener )
- throws IOException
- {
- // Properties must be initialized before using them
- ConverterProperties.initialize( aParams.getPropFile() );
-
- iManifest = aParams.getManifest();
- iLocSettings = aParams.getLocSettings();
- iDestinationDir = aParams.getDestinationDir();
- iListener = aListener;
-
- // Create destination directory structure
- if( !iDestinationDir.exists() )
- {
- iDestinationDir.mkdirs();
- }
-
- iDefRep = DefinitionRepository.getInstance();
-
- if( iManifest.getParent() == null )
- {
- iDataDir = ManifestFactory.CURRENT_DIR + File.separatorChar;
- }
- else
- {
- iDataDir = iManifest.getParent() + File.separatorChar;
- }
-
- iResourceInstaller =
- new ResourceInstaller( iDefRep, iDestinationDir, iDataDir);
- iList = new InstallationList();
- iLock = new Lock();
- iMultiThemeLock = new Lock();
- }
-
-
- public static boolean isFixDTD() {
- return fixDTD;
- }
-
-
- public static void setFixDTD(boolean fixDTD) {
- InstallationManager.fixDTD = fixDTD;
- }
-
-
- /**
- * Starts the actual installation
- * Progress will be informed via listener
- * @throws IOException If files cannot be found, or new files cannot be written
- * @throws IllegalArgumentException If there exists syntax errors in manifest file
- */
- public void startInstallation() throws IOException
- {
- // Source parameter is a directory
- if( iManifest.isDirectory() )
- {
- Enumeration manifests = searchManifests( iManifest ).elements();
- if( manifests.hasMoreElements() )
- {
- // Install all found themes
- installMultiTheme( manifests );
- }
- else
- {
- // No themes found
- throw new IllegalArgumentException(
- "Manifest files not found from: " + iManifest.getPath() );
- }
- }
- // Source parameter is a file
- else
- {
- // Parse the manifest
- ManifestFactory factory = new ManifestFactory( iLocSettings );
- IThemeManifest manifest = factory.createManifest( iManifest );
-
- // Install sub themes of a multi theme manifest, if any
- Enumeration manifests = manifest.getManifestFiles().elements();
- if( manifests.hasMoreElements() )
- {
- installMultiTheme( manifests );
- }
- // Install a normal theme
- else
- {
- installTheme( manifest, iLocSettings );
- }
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
- */
- public void update( Observable aObservable, Object aEvent )
- {
- // Language install event
- if( aObservable instanceof LanguageInstaller )
- {
- // Notify that the parsing operation has completed and
- // the install of next language variant will start
- iLock.unLock();
-
- LanguageInstallEvent event = ( LanguageInstallEvent )aEvent;
- ODTHeader header = event.getODTDocument().getODTHeader();
- ProgressEvent pe = new ProgressEvent();
- pe.setState( IInstallationListener.STATE_PARSED );
- pe.setName( ( String )header.get( ODTHeader.ThemeShortName ) );
- pe.setLanguage( (
- ( Integer )header.get( ODTHeader.Language ) ).intValue() );
- pe.setError( event.getErrorCode(), event.getReason() );
-
- iListener.installationProgress( pe );
- if( event.getErrorCode() ==
- IParseOperationListener.OPERATION_SUCCESSFUL )
- {
- InputStream in = null;
- try
- {
- // Store the ODT file
- ODTDocument document = event.getODTDocument();
- in = new ODTInputStream( document );
-
-// Source s = new DOMSource(document.getDOMDocument());
-//
-// Result r = new StreamResult(new File("C://output.xml"));
-//
-// Transformer t = TransformerFactory.newInstance().newTransformer();
-//
-// t.transform(s, r);
-
- iDefRep.storeODT( iDestinationDir,
- document.getODTHeader(),
- in,
- this );
- }
- catch ( Exception e )
- {
- pe.setError( IInstallationListener.ERROR, e.toString() );
- iListener.installationCompleted( pe );
- }
- finally
- {
- if( in != null )
- {
- try
- {
- in.close();
- }
- catch ( IOException e )
- {
- // Ignore error
- }
- }
- }
- }
- else
- {
- pe.setError( event.getErrorCode(), event.getReason() );
- iListener.installationCompleted( pe );
- }
- }
- // File operation event
- else if( aObservable instanceof FileOperation )
- {
- FileOperationEvent event = ( FileOperationEvent )aEvent;
- ProgressEvent pe = new ProgressEvent();
- pe.setState( IInstallationListener.STATE_WRITED );
- pe.setFileName( event.getFullDestPath() );
- pe.setError( event.getErrorCode(), null );
-
- if( event.getErrorCode() == FileOperationEvent.OPERATION_SUCCESSFUL )
- {
- pe.setFileName( event.getFullDestPath() );
- iListener.installationProgress( pe );
- }
- else
- {
- pe.setError( event.getErrorCode(), null );
- iListener.installationCompleted( pe );
- }
-
- iList.removeInstall( event.getDestPath() );
- if( !iList.installsExist() )
- {
- pe.setError( event.getErrorCode(), null );
- iListener.installationCompleted( pe );
- }
- }
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IInstallationListener#installationProgress(com.nokia.tools.themeinstaller.installationmanager.ProgressEvent)
- */
- public void installationProgress( ProgressEvent aEvent )
- {
- // Pass the event
- iListener.installationProgress( aEvent );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IInstallationListener#installationCompleted(com.nokia.tools.themeinstaller.installationmanager.ProgressEvent)
- */
- public void installationCompleted( ProgressEvent aEvent )
- {
- // Pass the event and release the multi theme install lock
- iListener.installationCompleted( aEvent );
- iMultiThemeLock.unLock();
- }
-
- /**
- * Install a normal theme
- * @param aManifest Manifest file
- * @throws IOException if resource files can not be installed
- */
- private void installTheme( IThemeManifest aManifest, File aLocSettings )
- throws IOException
- {
- // Create unlocalized header for copying language independent resources
- ODTHeader unlocalizedHeader =
- LanguageInstaller.createHeader( aManifest, null );
- Vector resources = aManifest.getResources();
- Vector odtResources =
- iResourceInstaller.installResources( resources, unlocalizedHeader );
-
- // Get all languages
- Enumeration languages =
- aManifest.getLanguages().elements();
-
- // Install each language variant
- while( languages.hasMoreElements() )
- {
- LanguageSpecificData language =
- ( LanguageSpecificData )languages.nextElement();
- LanguageInstaller installer = new LanguageInstaller(
- this, aManifest, language, aLocSettings, iResourceInstaller );
-
- // Add language id to the log
- iList.addInstall( language.getLanguageId() );
-
- // Add language independent resources
- installer.addResources( odtResources );
-
- try
- {
- // Start the installation process
- installer.install();
-
- // Wait for the parsing process to complete
- iLock.lock();
- }
- catch( Exception e )
- {
- // In error cases, cancel the installation
- ProgressEvent pe = new ProgressEvent();
- pe.setName( aManifest.getThemeShortName() );
- pe.setLanguage( language.getLanguageId().intValue() );
- pe.setError( IInstallationListener.ERROR, e.toString() );
- iListener.installationCompleted( pe );
- }
- }
- }
-
- /**
- * Install sub themes of a multi theme manifest.
- * @param aManifests List of manifests
- */
- private void installMultiTheme( Enumeration aManifests )
- {
- while( aManifests.hasMoreElements() )
- {
- File f = ( File )aManifests.nextElement();
- try
- {
- // Create installation parameters for the new
- // Installation Manager instance
- InstallationParameters params = new InstallationParameters(
- f, iDestinationDir );
- params.setLocSettings( iLocSettings );
-
- // Create a new installation manager
- InstallationManager i = new InstallationManager( params, this );
- i.startInstallation();
-
- // Install only a theme at a time
- iMultiThemeLock.lock();
- }
- catch ( Exception e )
- {
- // In error cases, cancel the installation
- ProgressEvent pe = new ProgressEvent();
- pe.setFileName( f.getPath() );
- pe.setError( IInstallationListener.ERROR,
- "Sub theme installation failed: " + e.toString() );
- iListener.installationCompleted( pe );
- }
- }
-
- }
-
- private Vector searchManifests( File aLocation )
- {
- // Create a FilenameFilter class for searching manifest (.dat) files
- FilenameFilter filter = new FilenameFilter()
- {
- public boolean accept( File aDir, String aName )
- {
- if( aName.endsWith( MANIFEST_SUFFIX ) )
- {
- return true;
- }
- return false;
- }
- };
-
- // List all manifest files in the directory and add them to
- // the result vector
- File[] files = aLocation.listFiles( filter );
- Vector v = new Vector();
- for( int i = 0; i < files.length; i++ )
- {
- v.add( files[ i ] );
- }
-
- return v;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/InstallationParameters.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
-* 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: Installation parameters for starting the Installation Manager
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-
-/**
- * Installation parameters for starting the Installation Manager.
- */
-public class InstallationParameters
- {
-
- // Manifest file
- private File iManifest;
-
- // Destination directory
- private File iDestinationDir;
-
- // Localisation settings
- private File iLocSettings;
-
- // External properties file
- private File iPropFile;
-
- /**
- * Constructor.
- * @param aManifest Manifest file
- * @param aDestinationDir Destination directory
- */
- public InstallationParameters( File aManifest, File aDestinationDir )
- {
- iManifest = aManifest;
- iDestinationDir = aDestinationDir;
-
- // Verify that theme manifest exists
- if( !aManifest.exists() )
- {
- throw new IllegalArgumentException(
- "Manifest file not found: " + aManifest.getPath() );
- }
-
- // Verify that destination directory is not an existing file
- if( aDestinationDir.isFile() )
- {
- throw new IllegalArgumentException( "Invalid destination directory: " +
- aDestinationDir.getPath() );
- }
- }
-
- /**
- * Get the manifest file.
- * @return the manifest file
- */
- public File getManifest()
- {
- return iManifest;
- }
-
- /**
- * Get the destination directory.
- * @return the destination directory
- */
- public File getDestinationDir()
- {
- return iDestinationDir;
- }
-
- /**
- * Get the localisation settings file.
- * @return the localisation settings file
- */
- public File getLocSettings()
- {
- return iLocSettings;
- }
-
- /**
- * Get the properties file.
- * @return the properties file
- */
- public File getPropFile()
- {
- return iPropFile;
- }
-
- /**
- * Set the localisation settings file.
- * @param aLocSettings the localisation settings file to set
- */
- public void setLocSettings( File aLocSettings )
- {
- iLocSettings = aLocSettings;
-
- // Verify that localisation settings are found
- if( aLocSettings != null &&
- ( !aLocSettings.exists() || !aLocSettings.isFile() ) )
- {
- throw new IllegalArgumentException(
- "Localisation settings file not found: " +
- aLocSettings.getPath() );
- }
- }
-
- /**
- * Set the properties file.
- * @param aPropFile the properties file to set
- */
- public void setPropFile( File aPropFile )
- {
- iPropFile = aPropFile;
-
- // Verify that properties file is found
- if( aPropFile != null &&
- ( !aPropFile.exists() || !aPropFile.isFile() ) )
- {
- throw new IllegalArgumentException(
- "Properties file not found: " +
- aPropFile.getPath() );
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/LanguageInstallEvent.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
-* 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: An event for informing about language install completion
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import com.nokia.tools.themeinstaller.odtconverter.ODTDocument;
-
-/**
- * An event for informing about language install completion.
- */
-public class LanguageInstallEvent
- {
-
- // ODTDocument related to the event
- private ODTDocument iODTDocument;
-
- // Error code of the finished operation
- private int iErrorCode;
-
- // Error reason
- private String iReason;
-
- /**
- * Language install event constructor.
- * @param aODTDocument ODT Document to the event
- * @param aErrorCode Error code of the completed operation
- * @param aReason Error reason
- */
- public LanguageInstallEvent( ODTDocument aODTDocument,
- int aErrorCode,
- String aReason )
- {
- iODTDocument = aODTDocument;
- iErrorCode = aErrorCode;
- iReason = aReason;
- }
-
- /**
- * Get the file.
- * @return The file
- */
- public ODTDocument getODTDocument()
- {
- return iODTDocument;
- }
-
- /**
- * Get the error code.
- * @return The error code
- */
- public int getErrorCode()
- {
- return iErrorCode;
- }
-
- /**
- * Get the error reason.
- * @return The error code
- */
- public String getReason()
- {
- return iReason;
- }
- }
-
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/LanguageInstaller.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-/*
-* 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: Uses ODTConverter for parsing the source files.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Vector;
-
-import com.nokia.tools.themeinstaller.localisation.Localisation;
-import com.nokia.tools.themeinstaller.localisation.LocalisationStore;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.odtconverter.ODTConverter;
-import com.nokia.tools.themeinstaller.odtconverter.ODTDocument;
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-import com.nokia.tools.themeinstaller.odtconverter.ODTResource;
-
-/**
- * Language Installer uses the ODTConverter for parsing the source files of
- * a language variant.
- */
-public class LanguageInstaller
- extends Observable implements IParseOperationListener
- {
-
- // ODT Document
- private ODTDocument iODTDocument;
-
- // ODT Converter
- private ODTConverter iConverter;
-
- // Theme manifest
- private IThemeManifest iManifest;
-
- // Language variant
- private LanguageSpecificData iLanguage;
-
- // Resource files
- private Vector iResources;
-
- // Resource installer
- private IResourceInstaller iResourceInstaller;
-
- // Localisation settings file
- private File iLocSettings;
-
- /**
- * Constructor.
- * @param aListener Listener for the parsing operation conversion
- * @param aManifest Theme manifest
- * @param aLanguage Language variant to to install
- * @param
- */
- public LanguageInstaller( Observer aListener,
- IThemeManifest aManifest,
- LanguageSpecificData aLanguage,
- File aLocSettings,
- IResourceInstaller aResourceInstaller )
- {
- iODTDocument = new ODTDocument();
- iConverter = new ODTConverter();
- iConverter.addListener( this );
- iManifest = aManifest;
- iLanguage = aLanguage;
- iLocSettings = aLocSettings;
- iResources = new Vector();
- iResourceInstaller = aResourceInstaller;
- addObserver( aListener );
- }
-
- /**
- * Add ODT Resources. This method can be used i.e. for adding language
- * independent ODT Resources.
- * @param aODTResources a list of resources to add
- */
- public void addResources( Vector aResources )
- {
- iResources.addAll( aResources );
- }
-
- /**
- * Start the installation process of the language.
- * @throws IOException if parse operation fails
- */
- public void install() throws IOException
- {
- ODTHeader header = createHeader( iManifest, iLanguage );
- iODTDocument.setODTHeader( header );
-
- // Install and add language specific resources
- Vector langResources = iLanguage.getResources();
- Vector odtLangResources = iResourceInstaller
- .installResources( langResources, header );
- odtLangResources.addAll( iResources );
-
- // Add ODT file as resource
- ODTResource langODTResource = iResourceInstaller
- .createODTResource( header, iManifest.getNameSpace() );
- odtLangResources.add( langODTResource );
- iODTDocument.setODTResources( odtLangResources );
-
- String dataDir = iManifest.getDataDir();
- String dtdName = null;
- File dtdFile = null;
-
- // Determine the DTD file to use
- if( iLanguage.getDTDFile() != null )
- {
- // Language specific DTD
- dtdName = iLanguage.getDTDFile();
- }
- else if( iManifest.getDTDFile() != null )
- {
- // Language independent DTD
- dtdName = iManifest.getDTDFile();
- }
-
- // Check if enhanced localisation support is enabled
- if( iLocSettings != null && dtdName != null )
- {
- // Use enhanced localisation: Find and compose the DTD file
- LocalisationStore ls = LocalisationStore.getInstance( iLocSettings );
- Localisation l = ls.getLocalisation(
- iManifest.getApplicationUid().longValue(),
- iManifest.getProviderUid().longValue(),
- iManifest.getThemeUid().longValue() );
- dtdFile = l.composeDTD( dtdName, iLanguage.getLanguageId().intValue() );
- }
- else if( dtdName != null )
- {
- // Use the standard localisation
- dtdFile = new File( dataDir + dtdName );
- }
-
- // Add XML to the converter
- if( dtdFile != null )
- {
- // External DTD file found
- iConverter.addXML( dataDir + iManifest.getXMLFile(),
- dtdFile.getPath() );
- }
- else
- {
- // Do not use external DTD
- iConverter.addXML( dataDir + iManifest.getXMLFile() );
- }
-
- // Add CSS to the converter, if available
- if( iLanguage.getCSSFile() != null )
- {
- // Use language specific CSS
- iConverter.addCSS( dataDir + iLanguage.getCSSFile() );
- }
- else if( iManifest.getCSSFile() != null )
- {
- // Use theme specific CSS
- iConverter.addCSS( dataDir + iManifest.getCSSFile() );
- }
-
- // Start the installation process
- try
- {
- iConverter.parse();
- }
- catch ( Exception e )
- {
- throw new IllegalArgumentException( "Failed to read resource files" );
- }
- }
-
- /**
- * Creates ODTHeader from manifest data
- * @param aManifest Theme manifest
- * @param aLanguage Language. If language is null, no language
- * specific data is processed.
- * @return new ODT Header
- */
- public static ODTHeader createHeader( IThemeManifest aManifest,
- LanguageSpecificData aLanguage )
- {
- ODTHeader header = new ODTHeader();
- if(null!=aManifest.getApplicationUid())
- header.put( ODTHeader.ApplicationUID, aManifest.getApplicationUid() );
-
- if(null!=aManifest.getProviderUid())
- header.put( ODTHeader.ProviderUID, aManifest.getProviderUid() );
-
- if(null!=aManifest.getThemeUid())
- header.put( ODTHeader.ThemeUID, aManifest.getThemeUid() );
-
- if(null!=aManifest.getProviderName())
- header.put( ODTHeader.ProviderName, aManifest.getProviderName() );
-
- if(null!=aManifest.getThemeFullName())
- header.put( ODTHeader.ThemeFullName, aManifest.getThemeFullName() );
-
- if(null!=aManifest.getThemeShortName())
- header.put( ODTHeader.ThemeShortName, aManifest.getThemeShortName() );
-
- if(null!=aManifest.getThemeVersion())
- header.put( ODTHeader.ThemeVersion, aManifest.getThemeVersion() );
-
- if(null!=aManifest.getScreenSizeX())
- header.put( ODTHeader.ScreenSizeX, aManifest.getScreenSizeX() );
-
- if(null!=aManifest.getScreenSizeY())
- header.put( ODTHeader.ScreenSizeY, aManifest.getScreenSizeY() );
-
- if(null!=aManifest.getThemeStatus())
- header.put( ODTHeader.Flags, aManifest.getThemeStatus() );
-
- // Set language specific data to the header
- if( aLanguage != null )
- {
- // Mandatory fields
- header.put( ODTHeader.Language, aLanguage.getLanguageId() );
-
- // Optional fields
- String locFullName = aLanguage.getThemeFullName();
- if( locFullName != null )
- {
- header.put( ODTHeader.ThemeFullName, locFullName );
- }
- }
-
- return header;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.odtconverter.IParseOperationListener#OperationCompleted(int, java.lang.String)
- */
- public void parseOperationCompleted( int aErr, String aReason )
- {
- iODTDocument.setDOMDocument( iConverter.getDOMDocument() );
- super.setChanged();
- super.notifyObservers(
- new LanguageInstallEvent( iODTDocument, aErr, aReason ) );
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/LanguageSpecificData.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
-* 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: Contains language specific data of each language.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.util.Vector;
-
-/**
- * Contains all the language specific data.
- */
-public class LanguageSpecificData
- {
-
- // Language id according to TLanguage enumeration in e32const.h
- private Integer iLanguageId;
-
- // DTD file name of the language
- private String iFileDTD;
-
- // CSS file name of the language
- private String iFileCSS;
-
- // Localized theme full name
- private String iThemeFullName;
-
- // Language specific resource files
- private Vector iResources;
-
- /**
- * Constructor.
- * @param aLanguageId Id number of the language
- * @param aFileDTD DTD file name
- * @param aFileCSS CSS file name
- * @param aThemeFullName Localized theme full name
- * @param aResources List of language specific resource files
- */
- public LanguageSpecificData( Integer aLanguageId,
- String aFileDTD,
- String aFileCSS,
- String aThemeFullName,
- Vector aResources )
- {
- iLanguageId = aLanguageId;
- iFileDTD = aFileDTD;
- iFileCSS = aFileCSS;
- iThemeFullName = aThemeFullName;
- iResources = aResources;
- if( iResources == null )
- {
- iResources = new Vector();
- }
- }
-
- /**
- * Get language id according to TLanguage enumeration in e32const.h.
- * @return Language id
- */
- public Integer getLanguageId()
- {
- return iLanguageId;
- }
-
- /**
- * Get DTD file name of the language.
- * @return File name of the DTD file
- */
- public String getDTDFile()
- {
- return iFileDTD;
- }
-
- /**
- * Get CSS file name of the language.
- * @return File name of the CSS file
- */
- public String getCSSFile()
- {
- return iFileCSS;
- }
-
- /**
- * Get localized theme full name.
- * @return Localized theme full name
- */
- public String getThemeFullName()
- {
- return iThemeFullName;
- }
-
- /**
- * Get language specific resource files
- * @return the resource file list
- */
- public Vector getResources()
- {
- return iResources;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/Lock.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
-* 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: Helper class for waiting asynchronous operations.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-/**
- * Helper class for waiting asynchronous operations.
- */
-public class Lock
- {
-
- private boolean iNotify = false;
-
- /*
- * Calls wait() if unLock() hasn't been called.
- * Causes thread to wait until unLock() is called.
- */
- synchronized public void lock()
- {
- if( !iNotify )
- {
- try
- {
- wait();
- }
- catch ( InterruptedException e )
- {
- //ignore
- }
- }
- iNotify = false;
- }
-
- /*
- * Called when asynchronous operation is ready.
- * Wakes up a thread that is waiting on this object's monitor.
- */
- synchronized public void unLock()
- {
- iNotify = true;
- notify();
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/ManifestFactory.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,593 +0,0 @@
-/*
- * 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: Uses XML parser to read the manifest and created objects that
- * represent the manifest.
- *
- */
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.nokia.tools.themeinstaller.localisation.DTDReader;
-import com.nokia.tools.themeinstaller.localisation.Localisation;
-import com.nokia.tools.themeinstaller.localisation.LocalisationStore;
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.odtconverter.MimeTypeResolver;
-import com.nokia.tools.themeinstaller.odtconverter.ThemeStatusResolver;
-import com.nokia.tools.themeinstaller.xmlparser.XMLParser;
-
-/**
- * Uses XML parser to read the manifest and created objects that represent the
- * manifest.
- */
-public class ManifestFactory implements IParseOperationListener {
-
- // CONSTANTS
- // Manifest root node names
- private static final String MULTI_THEME = "datfiles";
-
- // Manifest element names
- private static final String APP_UID_ELEMENT = "AppUid";
- private static final String PROVIDER_UID_ELEMENT = "Provideruid";
- private static final String THEME_UID_ELEMENT = "ThemeUid";
- private static final String THEME_STATUS_ELEMENT = "ThemeStatus";
- private static final String THEME_FULL_NAME_ELEMENT = "ThemeFullName";
- private static final String THEME_SHORT_NAME_ELEMENT = "ThemeShortName";
- private static final String THEME_VERSION_ELEMENT = "ThemeVersion";
- private static final String FILE_XML_ELEMENT = "FileXML";
- private static final String FILE_CSS_ELEMENT = "FileCSS";
- private static final String FILE_DTD_ELEMENT = "FileDTD";
- private static final String FILE_DAT_ELEMENT = "FileDAT";
- private static final String FILE_RESOURCE_ELEMENT = "FileResource";
- private static final String CACHE_VALUE_MEMORY = "CacheMemory";
- private static final String LOCKING_ELEMENT = "Locking";
- private static final String LOCKED_VALUE = "Locked";
- private static final String CACHE_TYPE_ELEMENT = "CacheType";
- private static final String CACHE_VALUE_NONE = "CacheNone";
- private static final String CACHE_VALUE_FILE = "CacheFile";
-
- // Language element names
- private static final String LANGUAGE_SPECIFIC_ELEMENT = "LanguageSpecific";
- private static final int LANGUAGE_INDEPENDENT = 0;
- private static final int LANG_NOT_SET = -1;
-
- // Integer conversion radix
- private static final int RADIX = 16;
-
- // Screen size
- private static final int SCREEN_SIZE_X = 0;
- private static final int SCREEN_SIZE_Y = 0;
-
- // Resource file cache type
- public static int CACHE_TYPE_CACHE_NONE = 0;
- public static int CACHE_TYPE_CACHE_FILE = 1;
- public static int CACHE_TYPE_CACHE_MEMORY = 2;
-
- // Locking policy flag-definition from native, bit-masked.
- public static final int E_XN_UNLOCKED = 0x0000; // 0b0000000000000000,
- public static final int E_XN_LOCKED = 0x0001; // 0b0000000000000001,
-
- public static final String CURRENT_DIR = ".";
-
- // Property keys
- private static final String THEME_PROVIDER_KEY = "theme_provider_name";
- private static final String NAME_SPACE_KEY = "theme_name_space";
-
- // Lock for monitoring parse operation completions
- private Lock iLock;
-
- // Mime type resolver
- private MimeTypeResolver iMimeTypeResolver;
-
- // Converter properties
- private ConverterProperties iProperties;
-
- // Localisation settings
- private File iLocSettings;
-
- /**
- * Constructor.
- *
- * @param aLocSettings
- * Localisation settings
- * @throws IOException
- * if converter properties can not be read
- */
- public ManifestFactory(File aLocSettings) throws IOException {
- iLock = new Lock();
- iMimeTypeResolver = new MimeTypeResolver();
- iProperties = ConverterProperties.getInstance();
- iLocSettings = aLocSettings;
- }
-
- /**
- * Parse a manifest and create the manifest object.
- *
- * @param aFile
- * Manifest file
- * @return Manifest instance
- * @throws IOException
- * if the manifest can not be read
- */
- public IThemeManifest createManifest(File aFile) throws IOException {
- // Read the manifest to the DOM document
- Document document = readManifest(aFile);
- IThemeManifest manifest = new ThemeManifest();
-
- // Set data directory that contains the data files of the theme
- if (aFile.getParent() == null) {
- manifest.setDataDir(CURRENT_DIR + File.separatorChar);
- } else {
- manifest.setDataDir(aFile.getParent() + File.separatorChar);
- }
-
- // Parse manifest contents
- String rootNodeName = document.getFirstChild().getNodeName();
- if (rootNodeName == MULTI_THEME) {
- // Multi theme manifest
- parseMultiThemeManifest(document, manifest);
- } else {
- // Single theme manifest
- parseManifest(document, manifest);
- parseLanguageSpecificData(document, manifest);
- parseResources(document, manifest, LANGUAGE_INDEPENDENT);
- }
-
- return manifest;
- }
-
- /*
- * (non-Javadoc)
- *
- * @seecom.nokia.tools.themeinstaller.odtconverter.IParseOperationListener#
- * parseOperationCompleted(int, java.lang.String)
- */
- public void parseOperationCompleted(int aErr, String aReason) {
- iLock.unLock();
- if (aErr != 0) {
- throw new IllegalArgumentException(
- "Theme manifest parsing failed: " + aErr + ", " + aReason);
- }
- }
-
- /**
- * Parse the manifest file.
- *
- * @param aManifest
- * Manifest file
- * @return DOM Document of the manifest
- */
- private Document readManifest(File aManifest) {
- // Parse the manifest
- XMLParser parser = new XMLParser(aManifest.getPath());
- parser.addListener(this);
-
- try {
- parser.parse();
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Theme manifest parsing failed: " + e.getMessage());
- }
-
- // Wait for the operation completion
- iLock.lock();
-
- // Return the document that was formed
- return parser.getDOMDocument();
- }
-
- /**
- * Parses a multi theme manifest from DOM to the manifest instance.
- *
- * @param aDocument
- * DOM Document containing the manifest data (source)
- * @param aManifest
- * Theme manifest (destination)
- */
- private void parseMultiThemeManifest(Document aDocument,
- IThemeManifest aManifest) {
- // Add DAT file names
- NodeList nodes = aDocument.getElementsByTagName(FILE_DAT_ELEMENT);
- Node node = null;
- for (int i = 0; i < nodes.getLength(); i++) {
- node = nodes.item(i);
- aManifest.addManifestFile(aManifest.getDataDir()
- + node.getTextContent());
- }
- }
-
- /**
- * Parses a manifest from DOM to the manifest instance.
- *
- * @param aDocument
- * DOM Document containing the manifest data (source)
- * @param aManifest
- * Theme manifest (destination)
- */
- private void parseManifest(Document aDocument, IThemeManifest aManifest) {
- // Set application uid
- NodeList nodes = aDocument.getElementsByTagName(APP_UID_ELEMENT);
- Node node = checkOneNode(nodes, APP_UID_ELEMENT);
- if (node != null)
- aManifest.setApplicationUid(Long.valueOf(node.getTextContent(),
- RADIX));
-
- // Set provider uid
- nodes = aDocument.getElementsByTagName(PROVIDER_UID_ELEMENT);
- node = checkOneNode(nodes, PROVIDER_UID_ELEMENT);
- if (node != null)
- aManifest
- .setProviderUid(Long.valueOf(node.getTextContent(), RADIX));
-
- // Set theme uid
- nodes = aDocument.getElementsByTagName(THEME_UID_ELEMENT);
- node = checkOneNode(nodes, THEME_UID_ELEMENT);
- if (node != null)
- aManifest.setThemeUid(Long.valueOf(node.getTextContent(), RADIX));
-
- // Set name space
- aManifest.setNameSpace(iProperties.getProperty(NAME_SPACE_KEY));
-
- // Set theme provider name
- aManifest.setProviderName(iProperties.getProperty(THEME_PROVIDER_KEY));
-
- // Set default theme full name before localization
- nodes = aDocument.getElementsByTagName(THEME_FULL_NAME_ELEMENT);
- if (nodes.getLength() > 0) {
- // Get first theme name that is found (for a default name).
- // The used name is specified in the language specific data.
- aManifest.setThemeFullName(nodes.item(0).getTextContent());
- }
- // else
- // {
- // throw new IllegalArgumentException(
- // "Syntax error in manifest file: theme full name not found" );
- // }
-
- // Set theme short name
- nodes = aDocument.getElementsByTagName(THEME_SHORT_NAME_ELEMENT);
- node = checkOneNode(nodes, THEME_SHORT_NAME_ELEMENT);
- if (node != null)
- aManifest.setThemeShortName(node.getTextContent());
-
- // Set theme version
- nodes = aDocument.getElementsByTagName(THEME_VERSION_ELEMENT);
- node = checkOneNode(nodes, THEME_VERSION_ELEMENT);
- if (node != null)
- aManifest.setThemeVersion(node.getTextContent());
-
- // Screen size, not used in Xuikon at the moment
- aManifest.setScreenSizeX(new Integer(SCREEN_SIZE_X));
- aManifest.setScreenSizeY(new Integer(SCREEN_SIZE_Y));
-
- // Resolve theme status
- nodes = aDocument.getElementsByTagName(THEME_STATUS_ELEMENT);
- int flags = ThemeStatusResolver.E_XN_THEME_STATUS_NONE;
- for (int i = 0; i < nodes.getLength(); i++) {
- node = nodes.item(i);
- flags |= ThemeStatusResolver.getValue(node.getTextContent())
- .intValue();
- if (node.getTextContent().equals(
- ThemeStatusResolver.THEME_STATUS_LICENCEE_RESTORABLE)) {
- // This theme is restored when licensee default theme is
- // restored.
- // When using this flag, the ThemeStatusLicenceeDefault-flag
- // must be activated.
- flags |= ThemeStatusResolver.E_XN_THEME_STATUS_LICENCEE_DEFAULT;
- }
- }
- aManifest.setThemeStatus(new Integer(flags));
-
- // Set XML file name
- NodeList files = aDocument.getElementsByTagName(FILE_XML_ELEMENT);
- node = checkOneNode(files, FILE_XML_ELEMENT);
- if (node != null)
- aManifest.setXMLFile(node.getTextContent());
-
- // Set CSS file name
- files = aDocument.getElementsByTagName(FILE_CSS_ELEMENT);
- node = checkMaxOneLanguageIndependentNode(files);
- if (node != null) {
- aManifest.setCSSFile(node.getTextContent());
- }
-
- // Set DTD file name
- files = aDocument.getElementsByTagName(FILE_DTD_ELEMENT);
- node = checkMaxOneLanguageIndependentNode(files);
- if (node != null) {
- aManifest.setDTDFile(node.getTextContent());
- }
- }
-
- /**
- * Parses language specific data in the manifest.
- *
- * @param aDocument
- * DOM Document containing the manifest data (source)
- * @param aManifest
- * Theme manifest (destination)
- * @throws IOException
- * if the manifest can not be parsed
- */
- private void parseLanguageSpecificData(Document aDocument,
- IThemeManifest aManifest) throws IOException {
- // Get languages
- NodeList languages = aDocument
- .getElementsByTagName(LANGUAGE_SPECIFIC_ELEMENT);
-
- Node langSpecificNode = null;
- NamedNodeMap langAttr = null;
- NodeList langSpecificChildren = null;
- Node langSpecificChild = null;
-
- NodeList resources = aDocument
- .getElementsByTagName(FILE_RESOURCE_ELEMENT);
- Vector langResources = null;
-
- // Process all languages
- for (int i = 0; i < languages.getLength(); i++) {
- // Language specific data
- int langId = LANG_NOT_SET;
- String extDtd = null;
- String extCss = null;
- String themeFullName = null;
-
- // Take a LanguageSpecific node
- langSpecificNode = languages.item(i);
-
- // There should be only one language for each LanguageSpecific node
- langAttr = langSpecificNode.getAttributes();
- if (langAttr.getLength() == 1) {
- String langStr = langAttr.item(0).getNodeValue();
- langId = Integer.valueOf(langStr).intValue();
- }
-
- langSpecificChildren = langSpecificNode.getChildNodes();
-
- // Read language specific elements
- String nodeName = null;
-
- for (int j = 0; j < langSpecificChildren.getLength(); j++) {
- langSpecificChild = langSpecificChildren.item(j);
- nodeName = langSpecificChild.getNodeName();
-
- // Language specific DTD file name
- if (FILE_DTD_ELEMENT.equals(nodeName)) {
- extDtd = langSpecificChild.getTextContent();
- }
- // Language specific CSS
- else if (FILE_CSS_ELEMENT.equals(nodeName)) {
- extCss = langSpecificChild.getTextContent();
- }
- // Localized theme full name
- else if (THEME_FULL_NAME_ELEMENT.equals(nodeName)) {
- themeFullName = langSpecificChild.getTextContent();
- }
- }
-
- // Parse language specific resources
- langResources = parseResources(aManifest, resources, langId);
-
- // Verify that mandatory fields language id and DTD file were set
- if (langId == LANG_NOT_SET || extDtd == null) {
- throw new IllegalArgumentException(
- "Syntax error in language specifications of the manifest");
- }
-
- // Find the DTD file for reading the localised theme full name
- File dtd = null;
- if (iLocSettings != null) {
- // Use enhanced localisation: Find the DTD file
- LocalisationStore ls = LocalisationStore
- .getInstance(iLocSettings);
- Localisation l = ls.getLocalisation(aManifest
- .getApplicationUid().longValue(), aManifest
- .getProviderUid().longValue(), aManifest.getThemeUid()
- .longValue());
- dtd = l.findDTD(extDtd);
- } else {
- dtd = new File(aManifest.getDataDir() + extDtd);
- }
-
- // Resolve localised theme full name, if specified
- themeFullName = DTDReader.readEntity(dtd, themeFullName);
-
- // Create new language specific data and add it to the languages
- // list
- LanguageSpecificData language = new LanguageSpecificData(
- new Integer(langId), extDtd, extCss, themeFullName,
- langResources);
- aManifest.addLanguage(language);
- }
-
- // Unlocalized variant (causes the .o0000 file to be generated)
- LanguageSpecificData language = new LanguageSpecificData(new Integer(
- LANGUAGE_INDEPENDENT), null, null, null, null);
- aManifest.addLanguage(language);
- }
-
- /**
- * Parses resource data in the manifest.
- *
- * @param aDocument
- * DOM Document containing the manifest data (source)
- * @param aManifest
- * Theme manifest (destination)
- * @param aLanguageId
- * Id of the language of which resources will be parsed. On 0,
- * only language independent resources are parsed.
- */
- private void parseResources(Document aDocument, IThemeManifest aManifest,
- int aLanguageId) {
- // Do the parsing operation
- NodeList resourceList = aDocument
- .getElementsByTagName(FILE_RESOURCE_ELEMENT);
- Vector resources = parseResources(aManifest, resourceList, aLanguageId);
-
- // Add resources to the manifest
- Enumeration e = resources.elements();
- while (e.hasMoreElements()) {
- aManifest.addResource((ThemeResource) e.nextElement());
- }
- }
-
- /**
- * Parses resource files defined in the manifest. Resources must be parsed
- * after the rest of the manifest is parsed. Theme status is used here for
- * determining locking policies.
- *
- * @param aManifest
- * Theme manifest
- * @param aNodeList
- * Node list to parse
- * @param aLanguageId
- * Id of the language of which resources will be parsed. On 0,
- * only language independent resources are parsed.
- */
- private Vector parseResources(IThemeManifest aManifest, NodeList aNodeList,
- int aLanguageId) {
- Vector result = new Vector();
- Node node = null;
-
- // Browse through all resources in the list
- int count = aNodeList.getLength();
- for (int i = 0; i < count; i++) {
- node = aNodeList.item(i);
- String filename = node.getTextContent();
- NamedNodeMap attributes = node.getAttributes();
-
- int cacheType = CACHE_TYPE_CACHE_NONE;
- int lockingPolicy = E_XN_UNLOCKED;
-
- // Set cache type
- Node cacheTypeNode = attributes.getNamedItem(CACHE_TYPE_ELEMENT);
- if ((cacheTypeNode == null)
- || cacheTypeNode.getTextContent().equals(CACHE_VALUE_NONE)) {
- cacheType = CACHE_TYPE_CACHE_NONE;
- } else if (cacheTypeNode.getTextContent().equals(CACHE_VALUE_FILE)) {
- cacheType = CACHE_TYPE_CACHE_FILE;
- } else if (cacheTypeNode.getTextContent()
- .equals(CACHE_VALUE_MEMORY)) {
- cacheType = CACHE_TYPE_CACHE_MEMORY;
- } else {
- throw new IllegalArgumentException(
- "Syntax error in the manifest, can not resolve resource cache type");
- }
-
- // Set locking policy
- Node locking = attributes.getNamedItem(LOCKING_ELEMENT);
- if (locking != null
- && locking.getTextContent().equals(LOCKED_VALUE)) {
- lockingPolicy = E_XN_LOCKED;
- }
-
- // If EXnThemeStatusLicenceeDefault flag is set, locking policy is
- // E_XN_LOCKED
- if ((aManifest.getThemeStatus().intValue() & ThemeStatusResolver.E_XN_THEME_STATUS_LICENCEE_DEFAULT) != 0) {
- lockingPolicy = E_XN_LOCKED;
- }
-
- // Resolve mime type
- String mime = iMimeTypeResolver.getMimeType(filename);
-
- // Resolve resource type
- int resourceType = iMimeTypeResolver.getResourceType(filename);
-
- // Verify language id
- Node parent = node.getParentNode();
- NamedNodeMap attr = parent.getAttributes();
-
- // Language specific resources
- if (attr.getLength() == 1
- && aLanguageId == Integer.valueOf(
- attr.item(0).getNodeValue()).intValue()) {
- ThemeResource resource = new ThemeResource(filename, cacheType,
- lockingPolicy, aManifest.getNameSpace(), resourceType,
- mime);
- result.add(resource);
- }
- // Language independent resources
- else if (aLanguageId == LANGUAGE_INDEPENDENT
- && !LANGUAGE_SPECIFIC_ELEMENT.equals(parent.getNodeName())) {
- ThemeResource resource = new ThemeResource(filename, cacheType,
- lockingPolicy, aManifest.getNameSpace(), resourceType,
- mime);
- result.add(resource);
- }
- }
-
- return result;
- }
-
- /**
- * Checks that there exists just one node in the list
- *
- * @param aNodeList
- * Node list to be checked
- * @return Only one existing node
- * @throws IllegalArgumentException
- * If there is more or less than one node in list
- */
- private Node checkOneNode(NodeList aNodeList, String tagName) {
-
- if (aNodeList.getLength() > 1) {
- throw new IllegalArgumentException(
- "Syntax error in manifest file, more child nodes than expected");
- }
- return aNodeList.item(0);
- }
-
- /**
- * Checks that there exists max one node in the list and it is language
- * independent.
- *
- * @param aNodeList
- * Node list to be checked
- * @return The existing language independent node or null
- * @throws IllegalArgumentException
- * If there is more or less than one node in list
- */
- private Node checkMaxOneLanguageIndependentNode(NodeList aNodeList) {
- Node result = null;
- int count = 0;
- for (int i = 0; i < aNodeList.getLength(); i++) {
- // Verify language in-dependency
- Node node = aNodeList.item(i);
- Node parent = node.getParentNode();
- if (!LANGUAGE_SPECIFIC_ELEMENT.equals(parent.getNodeName())) {
- result = node;
- count++;
- }
- }
-
- if (count > 1) {
- throw new IllegalArgumentException(
- "Syntax error in manifest file, more language "
- + "independent child nodes than expected");
- }
-
- return result;
- }
-
-}
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/ProgressEvent.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
-* 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: Event for installation progress information.
- *
-*/
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-/**
- * Installation progress event for delivering information about parsed
- * resource files and installed ODT files.
- */
-public class ProgressEvent
- {
-
- // Installation iState
- private int iState;
-
- // Theme name
- private String iName;
-
- // Language id
- private int iLanguage;
-
- // Installed file
- private String iFileName;
-
- // Error code
- private int iError;
-
- // Message
- private String iMessage;
-
- /**
- * Constructor.
- */
- public ProgressEvent()
- {
- }
-
- /**
- * Get installation state.
- * @return the state
- */
- public int getState()
- {
- return iState;
- }
-
- /**
- * Get theme name.
- * @return the name
- */
- public String getName()
- {
- return iName;
- }
-
- /**
- * Get the language id under install.
- * @return the language
- */
- public int getLanguage()
- {
- return iLanguage;
- }
-
- /**
- * Get name of the installed ODT file, if any
- * @return the fileName
- */
- public String getFileName()
- {
- return iFileName;
- }
-
- /**
- * Get the error code
- * @return the error code
- */
- public int getError()
- {
- return iError;
- }
-
- /**
- * Get the error message
- * @return the message
- */
- public String getMessage()
- {
- return iMessage;
- }
-
- /**
- * Set theme name
- * @param aName the name to set
- */
- public void setName( String aName )
- {
- iName = aName;
- }
-
- /**
- * Set language variant
- * @param aLanguage the language to set
- */
- public void setLanguage( int aLanguage )
- {
- iLanguage = aLanguage;
- }
-
- /**
- * Set state
- * @param iError the error to set
- */
- public void setState( int aState )
- {
- iState = aState;
- }
-
- /**
- * Set name of the installed ODT file
- * @param aFileName the fileName to set
- */
- public void setFileName( String aFileName )
- {
- iFileName = aFileName;
- }
-
- /**
- * Set error code and message
- * @param aError the error to set
- * @param aMessage the message to set
- */
- public void setError( int aError, String aMessage )
- {
- iError = aError;
- iMessage = aMessage;
- }
-
- /**
- * Set the error message
- * @param aMessage the message to set
- */
- public void setMessage( String aMessage )
- {
- iMessage = aMessage;
- }
-
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/ResourceInstaller.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,329 +0,0 @@
-/*
-* 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: Class for installing theme resources
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Vector;
-
-import com.nokia.tools.themeinstaller.defrep.IDefinitionRepository;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperationEvent;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperationUtils;
-import com.nokia.tools.themeinstaller.mediaconverter.MediaConverter;
-import com.nokia.tools.themeinstaller.odtconverter.MimeTypeResolver;
-import com.nokia.tools.themeinstaller.odtconverter.ODTHeader;
-import com.nokia.tools.themeinstaller.odtconverter.ODTResource;
-import com.nokia.tools.themeinstaller.odtconverter.ThemeStatusResolver;
-
-/**
- * Class for installing theme resources.
- */
-public class ResourceInstaller implements IResourceInstaller
- {
-
- // CONSTANTS
- private static final String MBM_SUFFIX = "mbm";
- private static final char FILE_EXT_SEPARATOR = '.';
-
- // Definition repository for accessing the file storage services
- private IDefinitionRepository iDefRep;
-
- // File operation event for observing file operations
- private FileOperationEvent iEvent;
-
- // Destination root directory
- private File iDestinationDir;
-
- // Data directory
- private String iDataDir;
-
- // Media converter for converting resources
- private MediaConverter iMediaConverter;
-
- // Mime type resolver for resolving resource type
- private MimeTypeResolver iMimeResolver;
-
- // Observer for monitoring file operation completions
- private Observer iFileCopyObserver;
-
- // For storing temporary files.
- private Vector iTempFiles;
-
- // Lock for asynchronous operations.
- private Lock iLock;
-
- /**
- * Constructor.
- * @param aDefRep Definition Repository for accessing the file storage
- * @param aDestinationDir Destination root directory
- * @param aDataDir Data directory containing the theme sources
- * @param aNameSpace Theme name space
- * @throws IOException if Media Converter can not be created
- */
- public ResourceInstaller( IDefinitionRepository aDefRep,
- File aDestinationDir,
- String aDataDir ) throws IOException
- {
- iDefRep = aDefRep;
- iDestinationDir = aDestinationDir;
- iDataDir = aDataDir;
- iMediaConverter = new MediaConverter();
- iMimeResolver = new MimeTypeResolver();
- iTempFiles = new Vector();
- iLock = new Lock();
-
- // Create an observer for monitoring file copy operation completions
- iFileCopyObserver = new Observer()
- {
- public void update( Observable aFileOperation, Object aEvent )
- {
- // Store the event
- iEvent = ( FileOperationEvent ) aEvent;
- // Open the lock
- iLock.unLock();
- }
- };
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.odtconverter.installationmanager.IResourceInstaller#installResources(java.util.Vector, com.nokia.tools.odtconverter.ODTHeader)
- */
- public Vector installResources(
- Vector aResources,
- ODTHeader aHeader ) throws IOException
- {
- Vector result = new Vector();
- Enumeration resources = aResources.elements();
-
- // Process all resource files
- while ( resources.hasMoreElements() )
- {
- result.add( installResource( ( ThemeResource ) resources.nextElement(), aHeader ) );
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.odtconverter.installationmanager.IResourceInstaller#installResource(com.nokia.tools.odtconverter.installationmanager.ThemeResource, com.nokia.tools.odtconverter.ODTHeader)
- */
- public ODTResource installResource( ThemeResource aResource,
- ODTHeader aHeader ) throws IOException
- {
- // Create the ODT resource
- ODTResource res = createResource( iDataDir, aResource );
-
- // Copy file to correct location
- File f = new File(
- iDataDir + ( String )res.get( ODTResource.TempFileName ) );
- iDefRep.copyResource(
- f,
- iDestinationDir,
- aHeader,
- iFileCopyObserver );
- // Wait for file copying
- iLock.lock();
-
- if ( iEvent.getErrorCode() == FileOperationEvent.OPERATION_SUCCESSFUL )
- {
- deleteTemporaryFile( iEvent.getFile().getName() );
- }
- else
- {
- throw new IOException( "Resource file copying failed: "
- + f.getPath() );
- }
-
- // Set the actual resource location (in Symbian file system) to resource
- res.put( ODTResource.FileName, iEvent.getDestPath() );
- return res;
- }
-
- /**
- * Delete temporary file.
- *
- * @param aFileName The file name
- *
- * @throws IOException Signals that an I/O exception has occurred.
- */
- private void deleteTemporaryFile( String aFileName ) throws IOException
- {
- Enumeration fileObjects = iTempFiles.elements();
-
- while ( fileObjects.hasMoreElements() )
- {
- File temp = ( File ) fileObjects.nextElement();
- if ( temp.getName().equals( aFileName ) )
- {
- if ( !temp.delete() )
- {
- throw new IOException( "Temporary file deletion failed: "
- + aFileName );
- }
- else
- {
- iTempFiles.remove( temp );
- deleteTemporaryFile( aFileName );
- }
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see com.nokia.tools.odtconverter.installationmanager.IResourceInstaller#createODTResource(com.nokia.tools.odtconverter.ODTHeader)
- */
- public ODTResource createODTResource( ODTHeader aHeader, String aNameSpace )
- {
- ODTResource res = new ODTResource();
- String odtPath = null;
-
- // Create ODT file path
- odtPath = iDefRep.createODTPath( iDestinationDir, aHeader );
-
- // Convert the path to Symbian OS file system format
- odtPath = FileOperationUtils.parseSymbianFSPath( odtPath );
-
- res.put( ODTResource.FileName, odtPath );
- res.put( ODTResource.CacheType,
- new Integer( ManifestFactory.CACHE_TYPE_CACHE_FILE ) );
-
- // If EXnThemeStatusLicenceeDefault flag is set,
- // locking policy is E_XN_LOCKED
- int flags = ( ( Integer )aHeader.get( ODTHeader.Flags ) ).intValue();
- if ( ( flags & ThemeStatusResolver.E_XN_THEME_STATUS_LICENCEE_DEFAULT ) != 0 )
- {
- res.put( ODTResource.LockingPolicy,
- new Integer( ManifestFactory.E_XN_LOCKED ) );
- }
- else
- {
- res.put( ODTResource.LockingPolicy,
- new Integer( ManifestFactory.E_XN_UNLOCKED ) );
- }
-
- // ODT file's mime type is "unknown"
- res.put( ODTResource.MimeType, MimeTypeResolver.UNKNOWN_MIME_TYPE );
- res.put( ODTResource.NameSpace, aNameSpace );
- res.put( ODTResource.ResourceID, aHeader
- .get( ODTHeader.ThemeShortName ) );
- res.put( ODTResource.ResourceType, new Integer(
- MimeTypeResolver.E_RESOURCEODT ) );
- return res;
- }
-
-
- /**
- * Creates ODT resource from given node
- * @param aItem DOM Node to be added
- * @param aDataDirectory Resource directory
- * @return new ODTResource object
- * @throws IOException if media file can not be converter
- */
- private ODTResource createResource( String aDataDirectory,
- ThemeResource aItem ) throws IOException
- {
- ODTResource res = new ODTResource();
-
- String tempFileName = null;
- String filename = aItem.getFileName();
- int cacheType = aItem.getCacheType();
-
- // Determine the need for media conversion
- if( cacheType == ManifestFactory.CACHE_TYPE_CACHE_FILE ||
- cacheType == ManifestFactory.CACHE_TYPE_CACHE_MEMORY )
- {
- // Convert the media file
- tempFileName = convertMedia( aDataDirectory + filename );
- }
- else
- {
- // No media conversion
- tempFileName = filename;
- }
-
- // Remove directories and separators from the file name
- int fileNameIndex = tempFileName.lastIndexOf( File.separatorChar );
- if( fileNameIndex > -1 )
- {
- tempFileName = tempFileName.substring( fileNameIndex + 1 );
- }
-
- // Update resource type after media conversion
- aItem.setResourceType( iMimeResolver.getResourceType( tempFileName ) );
- aItem.setMimeType( iMimeResolver.getMimeType( tempFileName ) );
-
- // Set temporary file name that is not externalized. It is required
- // only for copying the resource file in a case that media conversion
- // has changed the file name and extension.
- res.put( ODTResource.TempFileName, tempFileName );
-
- // Set properties that are externalized. The file name is set after the
- // resource file is copied to the correct location.
- res.put( ODTResource.CacheType, new Integer(cacheType ));
- res.put( ODTResource.ResourceID, filename );
- res.put( ODTResource.LockingPolicy, new Integer(aItem.getLockingPolicy() ));
- res.put( ODTResource.NameSpace, aItem.getNameSpace() );
- res.put( ODTResource.MimeType, aItem.getMimeType() );
- res.put( ODTResource.ResourceType, new Integer(aItem.getResourceType() ));
- return res;
- }
-
- /**
- * Uses MediaConverter to converts media to MBM
- * @param aFilename File to convert
- * @return Filename of converted resource
- * @throws IOException File conversion fails
- */
- private String convertMedia( String aFilename ) throws IOException
- {
- ArrayList files = new ArrayList();
- files.add( aFilename );
- int dotPosition = aFilename.lastIndexOf( FILE_EXT_SEPARATOR ) + 1;
- String destinationImage =
- aFilename.substring( 0, dotPosition ) + MBM_SUFFIX;
-
- if ( dotPosition == 0 )
- {
- destinationImage = aFilename + FILE_EXT_SEPARATOR + MBM_SUFFIX;
- }
-
- String filePrefix = destinationImage.substring( 0,
- destinationImage.lastIndexOf( FILE_EXT_SEPARATOR ) );
- File destFile = new File( destinationImage );
- int index = 1;
-
- // create unique name to not overwrite any existing files
- while( destFile.exists() )
- {
- destinationImage =
- filePrefix + index++ + FILE_EXT_SEPARATOR + MBM_SUFFIX;
- destFile = new File( destinationImage );
- }
-
- iMediaConverter.convertMedia( files, destinationImage );
- iTempFiles.add( destFile );
- return destinationImage;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/ThemeManifest.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,361 +0,0 @@
-/*
-* 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: Class representing the theme manifest
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-import java.io.File;
-import java.util.Vector;
-
-/**
- * Class representing the theme manifest.
- */
-/**
- * @author vivahanu
- *
- */
-public class ThemeManifest implements IThemeManifest
- {
-
- // Data directory
- private String iDataDir;
-
- // Resource list
- private Vector iResources;
-
- // List of language specific data
- private Vector iLanguages;
-
- // List of manifest files
- private Vector iManifestFiles;
-
- // Theme properties
- private Long iApplicationUid;
- private Long iProviderUid;
- private Long iThemeUid;
- private String iProviderName;
- private String iThemeFullName;
- private String iThemeShortName;
- private String iThemeVersion;
- private Integer iScreenSizeX;
- private Integer iScreenSizeY;
- private String iXMLFile;
- private String iCSSFile;
- private String iDTDFile;
- private Integer iThemeStatus;
- private String iNameSpace;
-
- /**
- * Constructor.
- */
- public ThemeManifest()
- {
- iResources = new Vector();
- iLanguages = new Vector();
- iManifestFiles = new Vector();
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getApplicationUid()
- */
- public Long getApplicationUid()
- {
- return iApplicationUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getProviderUid()
- */
- public Long getProviderUid()
- {
- return iProviderUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getThemeUid()
- */
- public Long getThemeUid()
- {
- return iThemeUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getProviderName()
- */
- public String getProviderName()
- {
- return iProviderName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getThemeFullName()
- */
- public String getThemeFullName()
- {
- return iThemeFullName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getThemeShortName()
- */
- public String getThemeShortName()
- {
- return iThemeShortName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getThemeVersion()
- */
- public String getThemeVersion()
- {
- return iThemeVersion;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getScreenSizeX()
- */
- public Integer getScreenSizeX()
- {
- return iScreenSizeX;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getScreenSizeY()
- */
- public Integer getScreenSizeY()
- {
- return iScreenSizeY;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getThemeStatus()
- */
- public Integer getThemeStatus()
- {
- return iThemeStatus;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getXMLFile()
- */
- public String getXMLFile()
- {
- return iXMLFile;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getCSSFile()
- */
- public String getCSSFile()
- {
- return iCSSFile;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getDTDFile()
- */
- public String getDTDFile()
- {
- return iDTDFile;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getResources()
- */
- public Vector getResources()
- {
- return iResources;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getLanguages()
- */
- public Vector getLanguages()
- {
- return iLanguages;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getManifestFiles()
- */
- public Vector getManifestFiles()
- {
- return iManifestFiles;
- }
-
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getDataDir()
- */
- public String getDataDir()
- {
- return iDataDir;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#getNameSpace()
- */
- public String getNameSpace()
- {
- return iNameSpace;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#addLanguage(com.nokia.tools.themeinstaller.installationmanager.LanguageSpecificData)
- */
- public void addLanguage( LanguageSpecificData aLanguage )
- {
- iLanguages.add( aLanguage );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#addManifestFile(java.lang.String)
- */
- public void addManifestFile( String aFileDAT )
- {
- iManifestFiles.add( new File( aFileDAT ) );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#addResource(com.nokia.tools.themeinstaller.installationmanager.ThemeResource)
- */
- public void addResource( ThemeResource aResource )
- {
- iResources.add( aResource );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setApplicationUid(java.lang.Long)
- */
- public void setApplicationUid( Long aApplicationUid )
- {
- iApplicationUid = aApplicationUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setCSSFile(java.lang.String)
- */
- public void setCSSFile( String aFile )
- {
- iCSSFile = aFile;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setDTDFile(java.lang.String)
- */
- public void setDTDFile( String aFile )
- {
- iDTDFile = aFile;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setDataDir(java.lang.String)
- */
- public void setDataDir( String aDataDir )
- {
- iDataDir = aDataDir;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setThemeStatus(java.lang.Integer)
- */
- public void setThemeStatus( Integer aThemeStatus )
- {
- iThemeStatus = aThemeStatus;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setNameSpace(java.lang.String)
- */
- public void setNameSpace( String aNameSpace )
- {
- iNameSpace = aNameSpace;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setProviderName(java.lang.String)
- */
- public void setProviderName( String aProviderName )
- {
- iProviderName = aProviderName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setProviderUid(java.lang.Long)
- */
- public void setProviderUid( Long aProviderUid )
- {
- iProviderUid = aProviderUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setScreenSizeX(java.lang.Integer)
- */
- public void setScreenSizeX( Integer aScreenSizeX )
- {
- iScreenSizeX = aScreenSizeX;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setScreenSizeY(java.lang.Integer)
- */
- public void setScreenSizeY( Integer aScreenSizeY )
- {
- iScreenSizeY = aScreenSizeY;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setThemeFullName(java.lang.String)
- */
- public void setThemeFullName( String aThemeFullName )
- {
- iThemeFullName = aThemeFullName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setThemeShortName(java.lang.String)
- */
- public void setThemeShortName( String aThemeShortName )
- {
- iThemeShortName = aThemeShortName;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setThemeUid(java.lang.Long)
- */
- public void setThemeUid( Long aThemeUid )
- {
- iThemeUid = aThemeUid;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setThemeVersion(java.lang.String)
- */
- public void setThemeVersion( String aThemeVersion )
- {
- iThemeVersion = aThemeVersion;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.installationmanager.IThemeManifest#setXMLFile(java.lang.String)
- */
- public void setXMLFile( String aFile )
- {
- iXMLFile = aFile;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/ThemeResource.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
-* 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: Class representing resource data in theme manifest
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.installationmanager;
-
-/**
- * Class representing resource data in theme manifest.
- */
-public class ThemeResource
- {
-
- // File name
- private String iFileName;
-
- // Cache type
- private int iCacheType;
-
- // Locking policy
- private int iLockingPolicy;
-
- // Name space
- private String iNameSpace;
-
- // Resource type
- private int iResourceType;
-
- // Mime type
- private String iMimeType;
-
- /**
- * Constructs a new theme resource.
- * @param aFileName Name of the resource file
- * @param aCacheType Resource cache type
- * @param aLockingPolicy Resource locking policy
- * @param aNameSpace Name space
- * @param aResourceType Resource type
- * @param aMimeType Mime type
- */
- public ThemeResource( String aFileName,
- int aCacheType,
- int aLockingPolicy,
- String aNameSpace,
- int aResourceType,
- String aMimeType )
- {
- iFileName = aFileName;
- iCacheType = aCacheType;
- iLockingPolicy = aLockingPolicy;
- iNameSpace = aNameSpace;
- iResourceType = aResourceType;
- iMimeType = aMimeType;
- }
-
- /**
- * Get resource file name.
- * @return the file name
- */
- public String getFileName()
- {
- return iFileName;
- }
-
- /**
- * Get resource cache type.
- * @return the cache type
- */
- public int getCacheType()
- {
- return iCacheType;
- }
-
- /**
- * Get locking policy.
- * @return the locking policy
- */
- public int getLockingPolicy()
- {
- return iLockingPolicy;
- }
-
- /**
- * Get name space.
- * @return the name space
- */
- public String getNameSpace()
- {
- return iNameSpace;
- }
-
- /**
- * Get resource type.
- * @return the resource type
- */
- public int getResourceType()
- {
- return iResourceType;
- }
-
- /**
- * Get resource mime type.
- * @return the resource mime type
- */
- public String getMimeType()
- {
- return iMimeType;
- }
-
- /**
- * Set resource type.
- * @param aResourceType new resource type
- */
- public void setResourceType( int aResourceType )
- {
- iResourceType = aResourceType;
- }
-
- /**
- * Set mime type.
- * @param aResourceType new mime type
- */
- public void setMimeType( String aMimeType )
- {
- iMimeType = aMimeType;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/DTDComposer.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
-* 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: Composes one dtd file from dtd entities
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-
-/**
- * Composes one dtd file from multiple entities.
- */
-public class DTDComposer
- {
-
- /** The Regular expression for entity. */
- private static final String FORMAT = "<!ENTITY %s \"%s\">";
-
- /** Line separator */
- private static final String CARRIAGE_RETURN =
- System.getProperty( "line.separator" );
-
- /** Property key for character encoding of DTD files */
- private static final String ENCODING_KEY = "dtd_encoding";
-
-
- /**
- * Returns dtd entity in right format for file writing.
- *
- * @param aEntity the entity
- * @param aLocString the localisable entity value
- *
- * @return Formatted entity
- */
- public static String formatEntity( String aEntity, String aLocString )
- {
- String[] formatArguments = { aEntity, aLocString };
- return String.format( FORMAT, formatArguments );
- }
-
- /**
- * Write entities to dtd file.
- *
- * @param aDestination Destination file
- * @param aEntities Entity - value pairs in hashtable
- * @param aAppend Append to the original file if it exists
- *
- * @return The dtd file
- *
- * @throws IOException Signals that an I/O exception has occurred.
- */
- public static File writeEntitiesToDtd( File aDestination,
- Hashtable aEntities,
- boolean aAppend )
- throws IOException
- {
-
- // Read the assumed character encoding of DTD files
- String encoding =
- ConverterProperties.getInstance().getProperty( ENCODING_KEY );
-
- BufferedWriter out = null;
- if( encoding != null )
- {
- // Use specified encoding
- out = new BufferedWriter( new OutputStreamWriter(
- new FileOutputStream( aDestination, aAppend ), encoding ) );
- }
- else
- {
- // Use default encoding
- out = new BufferedWriter( new OutputStreamWriter(
- new FileOutputStream( aDestination, aAppend ) ) );
- }
-
- try
- {
- Set entries = aEntities.keySet();
- Iterator it = entries.iterator();
-
- while ( it.hasNext() )
- {
- String entity = ( String ) it.next();
- String locString = ( String ) aEntities.get( entity );
-
- out.write( formatEntity( entity, locString ) + CARRIAGE_RETURN );
- }
- }
- finally
- {
- if ( out != null )
- {
- out.close();
- }
- }
-
- return aDestination;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/DTDReader.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-/*
-* 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: Read entities from dtd files
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.nokia.tools.themeinstaller.logger.LogWriter;
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-
-/**
- * Reads entities from dtd files.
- */
-public class DTDReader
- {
-
- /** The Regular expression for entity. */
- private static final String ENTITY_REGEX = "<!ENTITY(\\s*)%s(.*)>";
-
- /** The Regular expression for entity's value. */
- private static final String VALUE_REGEX = "(\")(.*)(\")";
-
- /** Line separator */
- private static final String LINE_SEPARATOR =
- System.getProperty( "line.separator" );
-
- /** Property key for character encoding of DTD files */
- private static final String ENCODING_KEY = "dtd_encoding";
-
- /**
- * Read DTD Entities. Reads a set of DTD files and searches
- * for localised string defined in a entity named aLocString.
- * If there are more than one instances found, the one that
- * is found first is returned.
- *
- * @param aDtdFiles DTD files containing entities
- * @param aLocString Entity's localisation string
- *
- * @return Localised string
- *
- * @throws IOException Signals that an I/O exception has occurred.
- */
- public static String readFiles( Vector aDtdFiles, String aLocString )
- throws IOException
- {
- String tempResult = null;
- Vector results = new Vector();
- for ( int i = 0; i < aDtdFiles.size(); i++ )
- {
- tempResult = readEntity( ( File ) aDtdFiles.get( i ), aLocString );
-
- if ( tempResult != null )
- {
- results.add( tempResult );
- }
- }
- if ( results.isEmpty() )
- {
- return null;
- }
- else
- {
- return ( String ) results.firstElement();
- }
-
- }
-
- /**
- * Read localized entity from the dtd.
- *
- * @param aDTD DTD file containing the localization
- * @param aLocString Localization string
- * @return Localized entity
- * @throws IOException if FileInputStream can not be opened
- */
- public static String readEntity( File aDTD, String aLocString )
- throws IOException
- {
- StringBuffer strbuf = new StringBuffer();
-
- // Read the assumed character encoding of DTD files
- String encoding =
- ConverterProperties.getInstance().getProperty( ENCODING_KEY );
-
- BufferedReader rdr = null;
- if( encoding != null )
- {
- // Use specified encoding
- rdr = new BufferedReader( new InputStreamReader(
- new FileInputStream( aDTD ), encoding ) );
- }
- else
- {
- // Use default encoding
- LogWriter.getInstance().logWarning( "DTDReader: Character " +
- "encoding of DTD files is not specified in the " +
- "properties file, using system default encoding." );
-
- rdr = new BufferedReader( new InputStreamReader(
- new FileInputStream( aDTD ) ) );
- }
-
- // Add all lines from the DTD file to the buffer
- for ( String line = rdr.readLine(); line != null; line = rdr.readLine() )
- {
- strbuf.append( line + LINE_SEPARATOR );
- }
-
- String[] formatArguments = { aLocString };
- String regex = String.format( ENTITY_REGEX, formatArguments );
-
- // Search for an entity containing the aLocString
- String result = findString( regex, strbuf.toString() );
-
- if ( result != null )
- {
- // Search for the entity's value
- result = findString( VALUE_REGEX, result );
-
- // Remove "-marks from the value
- result = result.replaceAll( "\"", "" );
- }
-
- return result;
- }
-
- /**
- * Find a substring. Also verifies that exactly one match is found.
- *
- * @param aRegex Regular expression for matching
- * @param aSearchString String for searching
- * @return Found string
- */
- private static String findString( String aRegex, String aSearchString )
- {
- String result = null;
- Pattern pattern = Pattern.compile( aRegex );
- Matcher matcher = pattern.matcher( aSearchString );
- int count = 0;
- while ( matcher.find() )
- {
- result = matcher.group();
- count++;
- }
-
- if ( count > 1 )
- {
- throw new IllegalArgumentException( "DTD parsing: "
- + "found more than one localized value for the "
- + "entity" );
- }
-
- return result;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/FileSearch.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/*
-* 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: Searches files from given directories
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Searches files that's name matches the regular expression.
- * Search operations can be executed in one or multiple directories
- * and also including subfolders in the search can activated.
- *
- * There are two versions for searching: recursive and non-recursive.
- * Recursive version is used when flooding the search to subfolders
- */
-public class FileSearch
- {
- private static Vector iFiles;
-
-
- /**
- * Find files in directories.
- *
- * @param aRootDirs The root directories where the search is initiated
- * @param aFileNameExpression The file name expression
- * @param aIncludeSubfolders Include subfolders in the search or not
- * @param aAllowSameName Allow same filenames
- *
- * @return Found files in a vector
- */
- public static Vector findFiles( Vector aRootDirs,
- String aFileNameExpression, boolean aIncludeSubfolders,
- boolean aAllowSame )
- {
- Vector allFiles = new Vector();
- Vector fileFromOneSearch = new Vector();
-
- for ( int i = 0; i < aRootDirs.size(); i++ )
- {
- fileFromOneSearch = findFiles( ( String ) aRootDirs.elementAt( i ),
- aFileNameExpression, aIncludeSubfolders, aAllowSame );
-
- for ( int j = 0; j < fileFromOneSearch.size(); j++ )
- {
- if ( aAllowSame && !allFiles.contains( fileFromOneSearch.get( j ) ) )
- {
- allFiles.add( fileFromOneSearch.get( j ) );
- }
- if ( !aAllowSame
- && !hasSameName( allFiles, ( File ) fileFromOneSearch.get( j ) ) )
- {
- allFiles.add( fileFromOneSearch.get( j ) );
-
- }
- }
- }
-
- return allFiles;
- }
-
- /**
- * Find files in directories.
- *
- * @param aRootDirs The root directories where the search is initiated
- * @param aFileNameExpression The file name expression
- * @param aIncludeSubfolders Include subfolders in the search or not
- *
- * @return Found files in a vector
- */
- public static Vector findFiles( Vector aRootDirs,
- String aFileNameExpression, boolean aIncludeSubfolders )
- {
- return findFiles( aRootDirs, aFileNameExpression, aIncludeSubfolders,
- true );
- }
-
- /**
- * Find one file in directories. Returns the first one found.
- *
- * @param aRootDirs The root directories where the search is initiated
- * @param aFileNameExpression The file name expression
- * @param aIncludeSubfolders Include sub folders in the search or not
- *
- * @return Found file
- */
- public static File findFile( Vector aRootDirs,
- String aFileNameExpression, boolean aIncludeSubfolders )
- {
- Vector results = findFiles( aRootDirs, aFileNameExpression, aIncludeSubfolders,
- true );
-
- if( results.size() == 0 )
- {
- throw new IllegalArgumentException( "Localisation: File Search: " +
- "File not found: " + aFileNameExpression );
- }
-
- return ( File ) results.elementAt( 0 );
- }
-
- /**
- * Find files in directory.
- *
- * @param aRootDir The root directory where the search is initiated
- * @param aFileNameExpression The file name expression
- * @param aIncludeSubfolders Include subfolders in the search or not
- * @param aAllowSameName Allow same filenames
- *
- * @return Found files in a vector
- */
- public static Vector findFiles( String aRootDir,
- String aFileNameExpression, boolean aIncludeSubfolders,
- boolean aAllowSameName )
- {
-
- iFiles = new Vector();
- // If subfolders included, use recursive version
- if ( aIncludeSubfolders )
- {
- findFilesInSubfolder( new File( aRootDir ), aFileNameExpression,
- aAllowSameName );
- }
- // If no subfolders included, use non-recursive version
- if ( !aIncludeSubfolders )
- {
- findFilesInFolder( new File( aRootDir ), aFileNameExpression,
- aAllowSameName );
- }
-
- return iFiles;
-
- }
-
- /**
- * Find files in directory.
- *
- * @param aRootDir The root directory where the search is initiated
- * @param aFileNameExpression The file name expression
- * @param aIncludeSubfolders Include subfolders in the search or not
- *
- * @return Found files in a vector
- */
- public static Vector findFiles( String aRootDir,
- String aFileNameExpression, boolean aIncludeSubfolders )
- {
- return findFiles( aRootDir, aFileNameExpression, aIncludeSubfolders, true );
- }
-
- /**
- * Find files in folder. Non-recursive version
- *
- * @param dir Directory to search in
- * @param aFileNameExpression The file name expression
- * @param aAllowSameName Allow same filename
- */
- private static void findFilesInFolder( File dir,
- final String aFileNameExpression, boolean aAllowSameName )
- {
- // Condition that file must fulfill
- FileFilter fileFilter = new FileFilter()
- {
- public boolean accept( File file )
- {
- return ( !file.isDirectory() && match( aFileNameExpression,
- file.getName() ) );
- }
- };
-
- // Files that match the condition
- File[] files = dir.listFiles( fileFilter );
-
- for ( int i = 0; i < files.length; i++ )
- {
- if ( aAllowSameName )
- {
- iFiles.add( files[ i ] );
- }
- if ( !aAllowSameName && !hasSameName( iFiles, files[ i ] ) )
- {
- iFiles.add( files[ i ] );
- }
- }
-
- }
-
- /**
- * Find files in folder and it's subfolder. Recursive version
- *
- * @param dir Root directory to start search
- * @param aFileNameExpression the a file name expression
- * @param aAllowSameName Allow same filenames
- */
- private static void findFilesInSubfolder( File dir,
- final String aFileNameExpression, boolean aAllowSameName )
- {
-
- // Flood the search to subdirectories:
- if ( dir.isDirectory() )
- {
-
- File[] files = dir.listFiles();
-
- for ( int i = 0; i < files.length; i++ )
- {
- findFilesInSubfolder( files[ i ], aFileNameExpression,
- aAllowSameName );
- }
- }
- // If not directory, add files that match conditions
- else
- {
- if ( match( aFileNameExpression, dir.getName() ) )
- {
- if ( aAllowSameName )
- {
- iFiles.add( dir );
- }
- if ( !aAllowSameName && !hasSameName( iFiles, dir ) )
- {
- iFiles.add( dir );
- }
-
- }
- }
- }
-
- /**
- * Match regular expression with string.
- *
- * @param patternStr Regular expression for match
- * @param input String to compare the regular expression
- *
- * @return true, if input matches the regular expression
- */
- private static boolean match( String patternStr, CharSequence input )
- {
- Pattern pattern = Pattern.compile( patternStr );
- Matcher matcher = pattern.matcher( input );
- if ( matcher.matches() )
- {
- return true;
- }
- return false;
- }
-
- /**
- * Checks if vector already has file with same name.
- *
- * @param aFiles Files to check
- * @param aFile Reference file
- *
- * @return true, if vector already has file with same name
- */
- private static boolean hasSameName( Vector aFiles, File aFile )
- {
- for ( int i = 0; i < aFiles.size(); i++ )
- {
- if ( ( ( File ) aFiles.get( i ) ).getName()
- .equals( aFile.getName() ) )
- {
- return true;
- }
- }
- return false;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/ILocalisation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
-* 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: Interface for localisation enhancements
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Interface for localisation enhancements.
- */
-public interface ILocalisation
- {
-
- /**
- * Get localisation settings of the theme.
- * @return Localisation settings
- */
- public Settings getSettings();
-
- /**
- * Find and compose a DTD file according to the provided localisation
- * settings. The temp-DTD file is deleted in the JVM exit.
- * @param aFileName Main dtd file name
- * @param aLanguage Language id of the language install
- * @return The composed DTD-file containing the main DTD file and
- * the extra entities from other DTD-files.
- * @throws IOException if reading/writing from/to DTD files fail.
- */
- public File composeDTD( String aFileName, int aLanguage ) throws IOException;
-
- /**
- * Find a DTD file according to the provided localisation settings.
- * @param aFileName DTD file name
- * @return The DTD file
- * @throws IOException if reading DTD files fail.
- */
- public File findDTD( String aFileName ) throws IOException;
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/IncludeSetting.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
-* 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: Contains one include settings for theme localisation.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.util.Vector;
-
-/**
- * Contains one include settings for theme localisation.
- */
-public class IncludeSetting
- {
-
- // File to include from
- private String iFile;
-
- // Include all entities
- private boolean iIncludeAll;
-
- // Search tree
- private Vector iSearchTree;
-
- // Entities to include
- private Vector iEntities;
-
-
-
- /**
- * Constructor.
- */
- public IncludeSetting()
- {
- iSearchTree = new Vector();
- iEntities = new Vector();
- }
-
- /**
- * Get the file to include from.
- * @return the file
- */
- public String getFile()
- {
- return iFile;
- }
-
- /**
- * Get the search tree.
- * @return the search tree
- */
- public Vector getSearchTree()
- {
- return iSearchTree;
- }
-
- /**
- * Get the entities to include.
- * @return the entities to include
- */
- public Vector getEntities()
- {
- return iEntities;
- }
-
- /**
- * Is include all entities flag set.
- * @return true if all entities in the file should be included
- */
- public boolean isIncludeAll()
- {
- return iIncludeAll;
- }
-
- /**
- * Add an entity to include.
- * @param aEntity the entity to include
- */
- public void addEntity( String aEntity )
- {
- iEntities.add( aEntity );
- }
-
- /**
- * Add a search directory for the file.
- * @param aDir Search directory
- */
- public void addSearchTree( Vector aSearchTree )
- {
- iSearchTree.addAll( aSearchTree );
- }
-
- /**
- * Set the file to include from.
- * @param aFile the search pattern for the file
- */
- public void setFile( String aFile )
- {
- iFile = aFile;
- }
-
- /**
- * Set include all entities flag.
- * @param aIncludeAll true if all entities in the file should be included
- */
- public void setIncludeAll( boolean aIncludeAll )
- {
- iIncludeAll = aIncludeAll;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/Localisation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
-* 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: This class is responsible for providing the enhanced
- * localisation services.
- *
-*/
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Vector;
-
-import com.nokia.tools.themeinstaller.defrep.DefinitionRepository;
-import com.nokia.tools.themeinstaller.defrep.operations.FileOperationEvent;
-import com.nokia.tools.themeinstaller.installationmanager.Lock;
-
-/**
- * This class is responsible for providing the enhanced localisation services.
- */
-public class Localisation implements ILocalisation
- {
-
- // The filename for temporary dtd file.
- private static String COMPOSED_DTD_FILE = "composed";
-
- // The extension for dtd file's filename.
- private static String DTD_FILE_EXTENSION = ".dtd";
-
- // Localisation settings of the theme
- private Settings iSettings;
-
- // File operation observer for copy operations
- private Observer iCopyObserver;
-
- // Lock for waiting the copy operation completion
- private Lock iCopyLock;
-
- // Stored file operation event
- private FileOperationEvent iCopyEvent;
-
- // Definition Repository
- private DefinitionRepository iDefRep;
-
- /**
- * Constructor.
- * @param aSettings Localisation settings of a theme
- */
- public Localisation( Settings aSettings )
- {
- iSettings = aSettings;
- iDefRep = DefinitionRepository.getInstance();
- iCopyLock = new Lock();
- iCopyObserver = new Observer()
- {
- public void update( Observable aFileOperation, Object aEvent )
- {
- // Store the event
- iCopyEvent = ( FileOperationEvent ) aEvent;
- // Open the lock
- iCopyLock.unLock();
- }
- };
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.localisation.ILocalisation#getSettings()
- */
- public Settings getSettings()
- {
- return iSettings;
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.localisation.ILocalisation#findDTD()
- */
- public File composeDTD( String aFileName, int aLanguage ) throws IOException
- {
- // Create a temp dtd file
- File composed = File.createTempFile(
- COMPOSED_DTD_FILE, DTD_FILE_EXTENSION );
- composed.deleteOnExit();
-
- // Copy the main dtd contents to the temp dtd
- copyDTDContents( findDTD( aFileName ), composed, false );
-
- // Loc settings: include settings
- Enumeration includes = iSettings.getIncludes().elements();
- IncludeSetting incl = null;
- Enumeration inclEntities = null;
- File inclFile = null;
-
- // Variables for localisation reading/writing
- String entity = null;
- String locString = null;
- String filename = null;
- Hashtable entities = new Hashtable();
- Integer[] formatArgs = { new Integer( aLanguage ) };
-
- // Process all include element
- while( includes.hasMoreElements() )
- {
- incl = ( IncludeSetting )includes.nextElement();
-
- filename = String.format( incl.getFile(), formatArgs );
-
- // Find the DTD to include from
- inclFile = FileSearch.findFile( incl.getSearchTree(), filename, true );
-
- // Include entities to the composed dtd file
- if( incl.isIncludeAll() )
- {
- // Append the whole dtd to include to the composed one
- copyDTDContents( inclFile, composed, true );
- }
- else
- {
- // Read the entities to include
- inclEntities = incl.getEntities().elements();
- while( inclEntities.hasMoreElements() )
- {
- entity = ( String )inclEntities.nextElement();
- locString = DTDReader.readEntity( inclFile, entity );
- entities.put( entity, locString );
- }
- }
- }
-
- // Create and return a temporary DTD file being composed
- return DTDComposer.writeEntitiesToDtd( composed, entities, true );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.localisation.ILocalisation#findDTD(java.lang.String)
- */
- public File findDTD( String aFileName ) throws IOException
- {
- // Use the file search to find the dtd file
- Vector searchTree = iSettings.getSearchTree();
- return FileSearch.findFile( searchTree, aFileName, true );
- }
-
- /**
- * Uses Definition Repository to copy DTD file contents to another DTD file.
- * The method is synchronous and waits for the operation completion.
- * @param aSource Source file
- * @param aDestination Destination file
- * @param aAppend Append to the destination file if it already exists
- * @throws IOException if reading/writing from/to a DTD file fails
- */
- private void copyDTDContents( File aSource, File aDestination, boolean aAppend )
- throws IOException
- {
- iDefRep.copy( aSource, aDestination, aAppend, iCopyObserver );
- iCopyLock.lock();
-
- if( iCopyEvent.getErrorCode() != FileOperationEvent.OPERATION_SUCCESSFUL )
- {
- throw new IOException( "Localisation: DTD contents copy failed: " +
- iCopyEvent.getErrorCode() + ", File: " +
- iCopyEvent.getFile().getPath() );
- }
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/LocalisationStore.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,391 +0,0 @@
-/*
-* 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: Parses the localisation settings file and creates Localisation
- * instances for each theme under install.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.io.File;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.nokia.tools.themeinstaller.installationmanager.Lock;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.xmlparser.XMLParser;
-
-/**
- * Parses the localisation settings file and creates Localisation
- * instances for each theme under install.
- */
-public class LocalisationStore
- {
-
- // CONSTANTS
- // Localisation settings element names
- private static final String THEME_ELEMENT = "theme";
-
- // Theme element attributes
- private static final String APP_UID_ATTR = "appuid";
- private static final String PROVIDER_UID_ATTR = "provideruid";
- private static final String THEME_UID_ATTR = "themeuid";
-
- // DTD elements
- private static final String MAIN_DTD_ELEMENT = "maindtd";
- private static final String SEARCH_TREE_ELEMENT = "searchtree";
- private static final String DIR_ELEMENT = "dir";
- private static final String DTD_INCLUDE_ELEMENT = "dtdinclude";
- private static final String ENTITY_ELEMENT = "entity";
-
- // DTD include element attributes
- private static final String FILE_ATTR = "file";
- private static final String ALL_ATTR = "all";
- private static final String TRUE = "true";
-
- // Radix for uid number conversion
- private static final int RADIX = 16;
-
- // Localisation store
- private Vector iLocalisations;
-
- // Lock for waiting the parse operation completion
- private Lock iLock;
-
- // Parsed localisation setting files
- private Vector iParsedFileNames;
-
- // Singleton instance
- private static LocalisationStore sInstance = null;
-
- /**
- * Constructor.
- * @param aFileName Localisation settings file
- */
- private LocalisationStore( File aFile )
- {
- iLock = new Lock();
- iLocalisations = new Vector();
- iParsedFileNames = new Vector();
- }
-
- /**
- * Get a LocalisationStore instance (singleton).
- * @param aFileName Localisation settings file name
- * @return LocalisationStore instance
- */
- public static LocalisationStore getInstance( File aFile )
- {
- if( sInstance == null )
- {
- sInstance = new LocalisationStore( aFile );
- }
- if( !sInstance.alreadyParsed( aFile ) )
- {
- Document d = sInstance.parseSettings( aFile );
- sInstance.createLocalisations( d );
- }
-
- return sInstance;
- }
-
- /**
- * Get Localisation instance for a theme. If the localisation
- * can not be found, null is returned.
- * @param aApplicationUid Theme application uid
- * @param aProviderUid Theme provider uid
- * @param aThemeUid Theme uid
- * @return Localisation instance containing the localisation information
- * for the theme
- * @throws IllegalArgumentException if the localisation can not be found
- */
- public Localisation getLocalisation( long aApplicationUid,
- long aProviderUid,
- long aThemeUid )
- {
- Localisation l = findLocalisation(
- aApplicationUid, aProviderUid, aThemeUid );
- if( l == null )
- {
- throw new IllegalArgumentException(
- "Can't find localisation information with Uid's : ApplicationUid: "
- + aApplicationUid + ", ProviderUid: "
- + aProviderUid + ", ThemeUid: " + aThemeUid );
- }
-
- return l;
- }
-
- /**
- * Find the Localisation instance from the internal list.
- * @param aApplicationUid Theme application uid
- * @param aProviderUid Theme provider uid
- * @param aThemeUid Theme uid
- * @return Localisation instance containing the localisation information
- * for the theme. If the localisation can not be found, null is returned
- */
- private Localisation findLocalisation( long aApplicationUid,
- long aProviderUid,
- long aThemeUid )
- {
- // Seek through all localisation instances to find the right one
- Enumeration e = iLocalisations.elements();
- Localisation l = null;
- while( e.hasMoreElements() )
- {
- l = ( Localisation )e.nextElement();
- Settings s = l.getSettings();
- if( aApplicationUid == s.getAppUid() &&
- aProviderUid == s.getProviderUid() &&
- aThemeUid == s.getThemeUid() )
- {
- return l;
- }
- }
- return null;
- }
-
- /**
- * Check if the settings file has already been parsed.
- * @param aSettings Localisation settings
- * @return true if the localisation settings file has already been parsed
- */
- private boolean alreadyParsed( File aSettings )
- {
- Enumeration e = iParsedFileNames.elements();
- while( e.hasMoreElements() )
- {
- String s = ( String )e.nextElement();
- if( s.equals( aSettings.getPath() ) )
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Create localisation instances for the store.
- * @param aDocument DOM Document containing the settings
- */
- private void createLocalisations( Document aDocument )
- {
- // Set application uid
- NodeList nodes = aDocument.getElementsByTagName( THEME_ELEMENT );
- for( int i = 0; i < nodes.getLength(); i++ )
- {
- Settings settings = new Settings();
- Node theme = nodes.item( i );
- NamedNodeMap list = theme.getAttributes();
-
- // Read application, provider and theme uids from
- // the element attributes
- for ( int j = 0; j < list.getLength(); j++ )
- {
- Node attr = list.item( j );
-
- if ( attr.getNodeType() == Node.ATTRIBUTE_NODE )
- {
- String name = attr.getNodeName();
- String value = attr.getNodeValue();
-
- if( APP_UID_ATTR.equals( name ) )
- {
- settings.setAppUid( Long.valueOf(
- value, RADIX ).longValue() );
- }
- else if( PROVIDER_UID_ATTR.equals( name ) )
- {
- settings.setProviderUid( Long.valueOf(
- value, RADIX ).longValue() );
- }
- else if( THEME_UID_ATTR.equals( name ) )
- {
- settings.setThemeUid( Long.valueOf(
- value, RADIX ).longValue() );
- }
- }
- }
-
- // Process settings of a theme
- Node element = theme.getFirstChild();
- while( element != null )
- {
- String elementName = element.getNodeName();
-
- // Process a main dtd element
- if( MAIN_DTD_ELEMENT.equals( elementName ) )
- {
- // Search tree
- Node maindtdChild = element.getFirstChild();
- while( maindtdChild != null )
- {
- if( SEARCH_TREE_ELEMENT.equals(
- maindtdChild.getNodeName() ) )
- {
- settings.addSearchTree( parseSearchTree( maindtdChild ) );
- }
- maindtdChild = maindtdChild.getNextSibling();
- }
- }
- // Process a dtd include element
- else if( DTD_INCLUDE_ELEMENT.equals( elementName ) )
- {
- IncludeSetting incl = new IncludeSetting();
-
- // Attributes: file, all
- NamedNodeMap inclAttr = element.getAttributes();
- for ( int j = 0; j < inclAttr.getLength(); j++ )
- {
- Node attr = inclAttr.item( j );
-
- if ( attr.getNodeType() == Node.ATTRIBUTE_NODE )
- {
- String name = attr.getNodeName();
- String value = attr.getNodeValue();
-
- if( FILE_ATTR.equals( name ) )
- {
- // Set file attribute
- incl.setFile( value );
- }
- else if( ALL_ATTR.equals( name ) )
- {
- // Set all attribute
- incl.setIncludeAll( TRUE.equals( value ) );
- }
- }
- }
-
- Node inclNode = element.getFirstChild();
- while( inclNode != null )
- {
- // Search tree
- if( SEARCH_TREE_ELEMENT.equals( inclNode.getNodeName() ) )
- {
- // Add all directories to the search tree
- incl.addSearchTree( parseSearchTree( inclNode ) );
- }
- // Entities
- else if( ENTITY_ELEMENT.equals( inclNode.getNodeName() ) )
- {
- // Add all entity elements
- incl.addEntity( inclNode.getTextContent() );
- }
-
- inclNode = inclNode.getNextSibling();
- }
-
- settings.addInclude( incl );
- }
- element = element.getNextSibling();
- }
-
- // Check if localisation for the theme already exists
- Localisation l = findLocalisation( settings.getAppUid(),
- settings.getProviderUid(), settings.getThemeUid() );
-
- if( l == null )
- {
- // Add a new localisation to the store
- iLocalisations.add( new Localisation( settings ) );
- }
- else
- {
- throw new IllegalArgumentException( "Localisation Store: " +
- "Localisation settings already exists for theme: " +
- "appuid: " + settings.getAppUid() +
- ", provideruid: " + settings.getProviderUid() +
- ", themeuid: " + settings.getThemeUid() );
- }
- }
- }
-
- /**
- * Read localisation settings file to a DOM Document.
- * @param aSettings Localisation settings file
- * @return DOM Document containing the settings data
- */
- private Document parseSettings( File aSettings )
- {
- // Create a parse operation listener
- IParseOperationListener listener = new IParseOperationListener()
- {
- public void parseOperationCompleted( int aErr, String aReason )
- {
- iLock.unLock();
- if ( aErr != 0 )
- {
- throw new IllegalArgumentException(
- "Localisation settings parsing failed: "
- + aErr + ", " + aReason );
- }
- }
- };
-
- // Parse the settings file
- XMLParser parser = new XMLParser( aSettings.getPath() );
- parser.addListener( listener );
-
- try
- {
- parser.parse();
- }
- catch ( Exception e )
- {
- throw new IllegalArgumentException(
- "Localisation settings parsing failed: "
- + e.getMessage() );
- }
-
- // Wait for the operation completion
- iLock.lock();
-
- iParsedFileNames.add( aSettings.getPath() );
-
- // Return the document that was formed
- return parser.getDOMDocument();
- }
-
- /**
- * Parse a search tree of child nodes.
- * @param aParent Search tree node of which child nodes define the
- * search directories
- * @return List of directory names as strings
- */
- private Vector parseSearchTree( Node aParent )
- {
- Vector result = new Vector();
-
- Node dir = aParent.getFirstChild();
- while( dir != null )
- {
- if( DIR_ELEMENT.equals( dir.getNodeName() ) )
- {
- result.add( dir.getTextContent() );
- }
- dir = dir.getNextSibling();
- }
-
- return result;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/localisation/Settings.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
-* 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: Contains the localisation settings that were defined in the
- * localisation settings file.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.localisation;
-
-import java.util.Vector;
-
-/**
- * Contains the localisation settings that were defined in the localisation
- * settings file. One instance contains settings for one theme.
- */
-public class Settings
- {
-
- // Theme application uid
- private long iAppUid;
-
- // Theme provider uid
- private long iProviderUid;
-
- // Theme uid
- private long iThemeUid;
-
- // Main DTD file search tree
- private Vector iSearchTree;
-
- // Include settings
- private Vector iIncludeSettings;
-
- /**
- * Constructor.
- */
- public Settings()
- {
- iSearchTree = new Vector();
- iIncludeSettings = new Vector();
- }
-
- /**
- * Get application uid.
- * @return the application uid
- */
- public long getAppUid()
- {
- return iAppUid;
- }
-
- /**
- * Get provider uid.
- * @return the provider uid
- */
- public long getProviderUid()
- {
- return iProviderUid;
- }
-
- /**
- * Get theme uid.
- * @return the theme uid
- */
- public long getThemeUid()
- {
- return iThemeUid;
- }
-
- /**
- * Get the search tree of the main DTD file.
- * @return Search tree
- */
- public Vector getSearchTree()
- {
- return iSearchTree;
- }
-
- /**
- * Get all include settings of a theme.
- * @return List of include settings
- */
- public Vector getIncludes()
- {
- return iIncludeSettings;
- }
-
- /**
- * Set application uid.
- * @param aAppUid the application uid to set
- */
- public void setAppUid( long aAppUid )
- {
- iAppUid = aAppUid;
- }
-
- /**
- * Set provider uid.
- * @param aProviderUid the provider uid to set
- */
- public void setProviderUid( long aProviderUid )
- {
- iProviderUid = aProviderUid;
- }
-
- /**
- * Set theme uid.
- * @param aThemeUid the theme uid to set
- */
- public void setThemeUid( long aThemeUid )
- {
- iThemeUid = aThemeUid;
- }
-
- /**
- * Add main DTD search tree.
- * @param aSearchTree Search tree
- */
- public void addSearchTree( Vector aSearchTree )
- {
- iSearchTree.addAll( aSearchTree );
- }
-
- /**
- * Add include settings of the theme.
- * @param aInclude Include settings
- */
- public void addInclude( IncludeSetting aInclude )
- {
- iIncludeSettings.add( aInclude );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/logger/LogFormatter.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
-* 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: String formatter for log files
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.logger;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-/**
- * Formats logging string to human readable form.
- */
-public class LogFormatter extends Formatter
- {
- // Format for date and time.
- private final static String DATE_FORMAT = "dd/MM/yyyy HH:mm:ss";
-
- /* (non-Javadoc)
- * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
- */
- public String format( LogRecord aRec )
- {
- return ( dateToString( DATE_FORMAT, aRec.getMillis() ) + " " + aRec.getLevel() + " "
- + formatMessage( aRec ) + "\n" );
- }
-
- /* (non-Javadoc)
- * @see java.util.logging.Formatter#getHead(java.util.logging.Handler)
- */
- public String getHead( Handler aHandler )
- {
- return "";
- }
-
- /* (non-Javadoc)
- * @see java.util.logging.Formatter#getTail(java.util.logging.Handler)
- */
- public String getTail( Handler aHandler )
- {
- return "";
- }
-
- /**
- * Formats date and time to string based on expression aFormat.
- *
- * @param aFormat expression for date and time
- *
- * @return Date and time in formatted string
- */
- public static String dateToString( String aFormat, long aDateMillis )
- {
- SimpleDateFormat sdf = new SimpleDateFormat( aFormat );
- String dateString = sdf.format( new Date( aDateMillis ) ).toString();
- return dateString;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/logger/LogWriter.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,327 +0,0 @@
-/*
-* 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: Writer for logging
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Class for writing logs to file or console.
- * This LogWriter is a singleton version of using logging
- * so that there is no need to instantiate Logger in
- * every class that uses logs.
- *
- * NOTE: User of this class has to make sure that closeInstance() is
- * called when logger is no longer used. If this is not called,
- * the used file resources are not closed.
- */
-public class LogWriter
- {
- // The logger used in writing.
- private static Logger iLogger = Logger.getLogger( LogWriter.class.getName() );
-
- // Singleton instance
- private static LogWriter sInstance = null;
-
- // Filename for log writing
- private static String sLogFileName = null;
-
- // Log file constants
- private final static String LOG_FILENAME = "ThemeInstaller";
- private final static String UNDERLINE_CHARACTER = "_";
- private final static String LOG_FILENAME_EXTENSION = ".log";
-
- // Date format for log filename
- private final static String DATE_FORMAT = "yyyyMMdd_HHmmssSS";
-
- /**
- * Instantiates a new log writer for console.
- *
- * @param aLevel The level
- */
- private LogWriter( Level aLevel )
- {
- iLogger.setLevel( aLevel );
- // If level == OFF, no need to continue the instantiating
- if ( aLevel == Level.OFF )
- {
- return;
- }
- // Disabling parent handlers so that the console handler remains as only
- // handler
- iLogger.setUseParentHandlers( false );
- ConsoleHandler consoleHandler = new ConsoleHandler();
- consoleHandler.setFormatter( new LogFormatter() );
- iLogger.addHandler( consoleHandler );
- }
-
- /**
- * Instantiates a new log writer for file.
- *
- * @param aDir The directory for log files
- * @param aLevel The level
- */
- private LogWriter( File aDir, Level aLevel )
- {
- try
- {
- iLogger.setLevel( aLevel );
- // If level == OFF, no need to continue the instantiating
- if ( aLevel == Level.OFF )
- {
- return;
- }
- // Disabling parent handlers so that the file handler remains as only
- // handler
- iLogger.setUseParentHandlers( false );
-
- String filename = validateDir( aDir );
-
- FileHandler fileHandler = new FileHandler( filename );
- fileHandler.setFormatter( new LogFormatter() );
- iLogger.addHandler( fileHandler );
- }
- catch ( IOException e )
- {
- iLogger.log( Level.SEVERE, "Unable to create logging file.", e );
- }
- }
-
- /**
- * Gets the level.
- *
- * @return The level
- */
- public Level getLevel()
- {
- return iLogger.getLevel();
- }
-
- /**
- * Close file.
- */
- private static void closeFile()
- {
- if ( iLogger.getHandlers().length > 0
- // LogWriter has maximum of 1 handler
- && iLogger.getHandlers()[ 0 ] instanceof FileHandler )
- {
- iLogger.getHandlers()[ 0 ].close();
- }
- }
-
- /**
- * Validate that directory for logging exists.
- *
- * @param aDir The directory
- *
- * @return Log file name
- */
- private String validateDir( File aDir )
- {
- if ( aDir.isFile() )
- {
- throw new IllegalArgumentException( "Invalid log file path. Not a directory: " + aDir );
- }
-
- // Create directory structure
- if ( !aDir.exists() )
- {
- aDir.mkdirs();
- }
-
- return aDir + File.separator + LOG_FILENAME + UNDERLINE_CHARACTER
- + LogFormatter.dateToString( DATE_FORMAT, System.currentTimeMillis() )
- + LOG_FILENAME_EXTENSION;
- }
-
- /**
- * Sets the level for logging.
- *
- * @param level The logging level in scale from 0 to 7
- */
- public void setLevel( int aLevel )
- {
- if ( aLevel < 0 || 7 < aLevel )
- {
- throw new IllegalStateException(
- "Trying to set invalid logging level" );
- }
- switch ( aLevel )
- {
- case 0:
- iLogger.setLevel( Level.ALL );
- break;
- case 1:
- iLogger.setLevel( Level.FINEST );
- break;
- case 2:
- iLogger.setLevel( Level.FINER );
- break;
- case 3:
- iLogger.setLevel( Level.FINE );
- break;
- case 4:
- iLogger.setLevel( Level.CONFIG );
- break;
- case 5:
- iLogger.setLevel( Level.INFO );
- break;
- case 6:
- iLogger.setLevel( Level.WARNING );
- break;
- case 7:
- iLogger.setLevel( Level.SEVERE );
- break;
- default:
- break;
- }
- }
-
- /**
- * Check if logger is in console mode.
- *
- * @return true, if Logger is writing on console
- */
- public boolean inConsoleMode()
- {
- if ( iLogger.getHandlers().length > 0
- // LogWriter has maximum of 1 handler
- && iLogger.getHandlers()[ 0 ] instanceof ConsoleHandler )
- {
- return true;
- }
- return false;
- }
-
- /**
- * Log severe.
- *
- * @param aMessage The message for logging
- */
- public void logSevere( String aMessage )
- {
- iLogger.log( Level.SEVERE, aMessage );
- }
-
- /**
- * Log warning.
- *
- * @param aMessage The message for logging
- */
- public void logWarning( String aMessage )
- {
- iLogger.log( Level.WARNING, aMessage );
- }
-
- /**
- * Log info.
- *
- * @param aMessage The message for logging
- */
- public void logInfo( String aMessage )
- {
- iLogger.log( Level.INFO, aMessage );
- }
-
- /**
- * Log message.
- *
- * @param aMessage The message for logging
- */
- public void logConfig( String aMessage )
- {
- iLogger.log( Level.CONFIG, aMessage );
- }
-
- /**
- * Log fine.
- *
- * @param aMessage The message for logging
- */
- public void logFine( String aMessage )
- {
- iLogger.log( Level.FINE, aMessage );
- }
-
- /**
- * Closes singleton resources and removes the singleton instance
- */
- public static synchronized void closeInstance()
- {
- closeFile();
- sInstance = null;
- }
-
- /**
- * Gets the single instance of LogWriter.
- * Note that initialize method has to be called
- * before this.
- *
- * @return Single instance of LogWriter
- */
- public static synchronized LogWriter getInstance()
- {
- if ( sInstance == null )
- {
- // Initialize method not called yet
- sInstance = new LogWriter( Level.OFF );
- }
- return sInstance;
- }
-
- /**
- * Initialize new instance of LogWriter.
- * Note that the default logging level is Level.ALL.
- *
- * @param aDir The directory for writing log
- *
- * @throws IOException Signals that an I/O exception has occurred.
- */
- public static void initialize( File aDir ) throws IOException
- {
- // Already initialized if:
- // sInstance is not null AND
- // sLogFileName equals with aLogFile
-
- if ( sInstance != null &&
- ( sLogFileName != null && aDir != null && sLogFileName.equals( aDir.getPath() ) ||
- ( sLogFileName == null && aDir == null ) ) )
- {
- return;
- }
-
- // Create a new instance
- // If no log file given, the log is written in console
- if ( aDir == null )
- {
- sInstance = new LogWriter( Level.ALL );
- sLogFileName = null;
- }
- else
- {
- sInstance = new LogWriter( aDir, Level.ALL );
- sLogFileName = aDir.getPath();
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/mediaconverter/MediaConverter.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,378 +0,0 @@
-/*
-* 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: This class is used for converting media files
- *
-*/
-
-package com.nokia.tools.themeinstaller.mediaconverter;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.imageio.IIOImage;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageReader;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageInputStream;
-import javax.imageio.stream.ImageOutputStream;
-
-import com.nokia.tools.themeinstaller.odtconverter.ConverterProperties;
-
-/**
- * Base class for different MediaConverters
- * Media converters are used for e.g. converting jpg to mbm
- * @author jutarhon
- *
- */
-public class MediaConverter
- {
- protected static final String MEDIA_CONVERTER_APPLICATION= "media_converter";
- private static final String WINDOWS_EXCUTABLE_EXTENSION = "exe";
- private static final String LINUX_OS_NAME = "linux";
- private static final String OPERATING_SYSTEM_PROPERTY = "os.name";
- protected static final char SPACE = ' ';
- protected static final char DOT = '.';
- private static final String BMP = "bmp";
- private static final String COLOR_SETTING = "color_setting";
- protected static String DEFAULT_SUCCESS_LINE = "Success.";
-
- protected ConverterProperties iProperties;
- private Process iProcess;
-
- protected String iExtraParameters = null;
-
- /**
- * Default constructor.
- * @throws IOException If loading properties fails
- */
- public MediaConverter() throws IOException
- {
- iProperties = new ConverterProperties();
- }
-
- /**
- * Returns possible set extra parameters for running converter application
- * or null if not set
- * @return the iExtraParameters
- */
- public String getExtraParameters()
- {
- return iExtraParameters;
- }
-
- /**
- * Sets extra parameters for running converter application
- * Set null for unsetting
- * @param aExtraParameters Extra parameters to set
- */
- public void setExtraParameters( String aExtraParameters )
- {
- iExtraParameters = aExtraParameters;
- }
-
- /**
- * Returns command line parameters for specified filenames
- * including the actual executable
- * example: bmconv.exe target.mbm source.jpg
- * @param aFilenames List of filenames to added to command line
- * @param aTargetFile Filename for target bitmap
- * @return Executable parameters
- */
- protected String getExecParameters( List aFilenames, String aTargetFile )
- {
- StringBuffer sb = new StringBuffer();
-
- // Get the execution location
- URL resource =
- getClass().getProtectionDomain().getCodeSource().getLocation();
- File bin = new File( resource.getPath() );
-
- // Find the bmconv from the installation directory
- sb.append( bin.getParent() + File.separatorChar );
-
- // Windows uses bmconv.exe and Linux bmconv
- if ( System.getProperty( OPERATING_SYSTEM_PROPERTY ).equalsIgnoreCase(
- LINUX_OS_NAME ) )
- {
- sb.append( iProperties.getProperty( MEDIA_CONVERTER_APPLICATION ) );
- }
- else
- {
- sb.append( iProperties.getProperty( MEDIA_CONVERTER_APPLICATION )
- + DOT + WINDOWS_EXCUTABLE_EXTENSION );
- }
-
- sb.append( SPACE );
- if( iExtraParameters != null )
- {
- sb.append( iExtraParameters );
- sb.append( SPACE );
- }
- sb.append( aTargetFile );
- sb.append( SPACE );
- for ( Iterator iterator = aFilenames.iterator(); iterator.hasNext(); )
- {
- sb.append( iProperties.getProperty( COLOR_SETTING ) );
- sb.append( iterator.next() );
- if( iterator.hasNext() )
- {
- sb.append( SPACE );
- }
- }
- return sb.toString();
- }
- /**
- * Getter for environment variables in form "key=value"
- * To be overwritten in derived class if environment variables are needed
- * @return String array of "key=value" pairs.
- */
- protected String[] getEnvironmentVariables()
- {
- return null;
- }
-
- /**
- * Returns success line that is excepted in output
- * @return Success line
- */
- protected String getSuccesIndicationLine()
- {
- return DEFAULT_SUCCESS_LINE;
- }
-
- /**
- * Cancels the executing conversion operation
- */
- public void cancelConversion()
- {
- if( iProcess != null )
- {
- iProcess.destroy();
- }
- }
-
- /**
- * Converts one ore more files to target file
- * @param aFilenames Files to be converted
- * @param aTargetFile Target file
- * @throws IOException If IO error occurs or tool fails conversion
- */
- public void convertMedia( List aFilenames,
- String aTargetFile ) throws IOException
- {
- ArrayList newFiles = new ArrayList();
-
- checkMedias( aFilenames, newFiles );
- Runtime rt = Runtime.getRuntime();
- iProcess = rt.exec( getExecParameters( aFilenames, aTargetFile ),
- getEnvironmentVariables() );
- try
- {
- iProcess.waitFor();
- }
- catch ( InterruptedException e )
- {
- throw new IOException( "Conversion interrupted" );
- }
-
- if( iProcess.exitValue() != 0 )
- {
- InputStream input = null;
- BufferedReader in = null;
- StringBuffer sb = null;
- try
- {
- // reading the error logs
- input = iProcess.getErrorStream();
- in = new BufferedReader( new InputStreamReader( input ) );
- sb = new StringBuffer();
- String line = null;
- while ( ( line = in.readLine() ) != null )
- {
- sb.append( line );
- sb.append( '\n' );
- }
- }
- finally
- {
- if( input != null )
- {
- input.close();
- }
- if( in != null )
- {
- in.close();
- }
- }
-
- deleteTemporaryFiles( newFiles );
- throw new IOException( "Conversion failed with error code: " +
- iProcess.exitValue() +
- "\nError log: " + sb.toString() );
- }
- // read the output logs, and check that there is success indication (in case that tool does not
- // support sending error code)
- boolean success = false;
- String line = null;
- String lastLine = null;
- InputStream input = null;
- BufferedReader in = null;
- try
- {
- input = iProcess.getInputStream();
- in = new BufferedReader( new InputStreamReader( input ) );
- while ( ( line = in.readLine() ) != null )
- {
- if( line.equals( getSuccesIndicationLine() ) )
- {
- success = true;
- break;
- }
- lastLine = line;
- }
- }
- finally
- {
- if( input != null )
- {
- input.close();
- }
- if( in != null )
- {
- in.close();
- }
- }
- iProcess = null;
- // Delete temporary files
- deleteTemporaryFiles( newFiles );
- // did not found success line
- if( !success )
- {
- throw new IOException( "Running media converter failed: " + lastLine );
- }
- }
-
- /**
- * Delete temporary files
- * @param newFiles List of temporary files
- * @throws IOException If file deletion fails
- */
- protected void deleteTemporaryFiles( List aNewFiles ) throws IOException
- {
- for ( Iterator iterator = aNewFiles.iterator(); iterator.hasNext(); )
- {
- String filename = ( String ) iterator.next();
- File file = new File( filename );
- if( !file.delete() )
- {
- throw new IOException( "Temporary file deletion failed: " + filename );
- }
- }
- }
-
- /**
- * Checks that input medias does not contain illegal files and converts
- * other image formats to BMP
- * @param aFilenames List of files to be added in MBM file
- * @param aNewFiles List of created temporary files
- * @throws IOException thrown if some of encoders are missing, or some error in image reading/writing
- */
- protected void checkMedias( List aFilenames,
- List aNewFiles ) throws IOException
- {
- // load BMP writer
- Iterator writers = ImageIO.getImageWritersByFormatName( BMP );
- if( !writers.hasNext() )
- {
- throw new IOException( "BMP encoder not found" );
- }
- ImageWriter bmpWriter = ( ImageWriter ) writers.next();
-
- ArrayList newNames = new ArrayList();
- // Go through all files and check if there is something else than BMP
- for ( Iterator iterator = aFilenames.iterator();
- iterator.hasNext(); )
- {
- String imageName = ( String ) iterator.next();
- ImageInputStream input = ImageIO.createImageInputStream(
- new File( imageName ) );
-
- String destinationImage = null;
- try
- {
- Iterator readers = ImageIO.getImageReaders( input );
- if( !readers.hasNext() )
- {
- throw new IOException( "Unknown file" );
- }
- ImageReader ir = ( ImageReader ) readers.next();
- //Convert file if it is not BMP
- destinationImage = imageName;
- if( !ir.getFormatName().equalsIgnoreCase( BMP ) )
- {
- // read original image
- ir.setInput( input );
- IIOImage image = ir.readAll( 0, null );
- destinationImage = imageName.substring(
- 0, imageName.lastIndexOf( DOT ) + 1 ) + BMP;
- File destFile = new File( destinationImage );
- int index = 1;
- // create unique name to not overwrite any existing files
- while( destFile.exists() )
- {
- destinationImage = imageName.substring( 0,
- imageName.lastIndexOf( DOT ) )
- + index++ + DOT + BMP;
- destFile = new File( destinationImage );
- }
- // Write image back in BMP format
- ImageOutputStream output =
- ImageIO.createImageOutputStream( destFile );
- try
- {
- bmpWriter.setOutput( output );
- bmpWriter.write( image );
- }
- finally
- {
- if( output != null )
- {
- output.close();
- }
- }
- aNewFiles.add( destinationImage );
- }
- }
- finally
- {
- if( input != null )
- {
- input.close();
- }
- }
-
- newNames.add( destinationImage );
- }
- // change new names to list
- aFilenames.clear();
- aFilenames.addAll( newNames );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ConverterProperties.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
-* 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 com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-
-/**
- * Properties for ODT to XML converter
- * @author jutarhon
- */
-public class ConverterProperties extends Properties
- {
- /**
- * Default serial version UID
- */
- private static final long serialVersionUID = 1L;
- private static final String PROPERTY_FILE =
- "data" + File.separatorChar + "ThemeInstaller.prop";
- private static ConverterProperties sInstance = null;
- private static String sPropFileName = null;
-
- /**
- * Default constructor, loads the properties from default place
- * @throws IOException If default file is not found or some other IO error occurs
- */
- public ConverterProperties() throws IOException
- {
- // Get the execution location
- URL resource =
- getClass().getProtectionDomain().getCodeSource().getLocation();
- File bin = new File( resource.getPath() );
-
- // Load properties from the Theme Installation directory
- loadProperties( new File(
- bin.getParent() + File.separatorChar + PROPERTY_FILE ) );
- }
-
- /**
- * Constructor with specified properties file
- * @param aFile File to read
- * @throws IOException If given file is not found or some other IO error occurs
- */
- public ConverterProperties( File aFile ) throws IOException
- {
- loadProperties( aFile );
- }
-
- /**
- * Constructor with default values
- * @param aDefaults Default properties values
- * @throws IOException If default file is not found or some other IO error occurs
- */
- public ConverterProperties( Properties aDefaults ) throws IOException
- {
- super( aDefaults );
- loadProperties( new File( PROPERTY_FILE ) );
- }
-
- /**
- * Loads the properties from file
- * @param aFile File to read
- * @throws IOException If given file is not found or some other IO error occurs
- */
- protected void loadProperties( File aFile ) throws IOException
- {
- FileInputStream file = null;
- try
- {
- file = new FileInputStream( aFile );
- load( file );
- }
- finally
- {
- if( file != null )
- {
- file.close();
- }
- }
- }
-
- /**
- * Singleton method for getting the ConverterProperties instance. Note that
- * the initialize method must be called before this one.
- * @return ConverterProperties instance
- * @throws IllegalStateException if this method has been called before
- * initialize has been called.
- */
- public static ConverterProperties getInstance()
- {
- if( sInstance == null )
- {
- throw new IllegalStateException( "Converter Properties: " +
- "Initialize must be called before the properties " +
- "can be used" );
- }
-
- return sInstance;
- }
-
- /**
- * Initialize method for constructing and reading the properties. The
- * properties are re-initialized only if the given property file differs
- * from the one used in the previous initialization.
- * @param aPropFile Properties file
- * @throws IOException If required properties can not be read from the
- * property file.
- */
- public static void initialize( File aPropFile )
- throws IOException
- {
- // Already initialized if:
- // sInstance is not null AND
- // sPropFileName equals with aPropFile
- if( sInstance != null &&
- ( sPropFileName != null && aPropFile != null && sPropFileName.equals( aPropFile.getPath() ) ||
- ( sPropFileName == null && aPropFile == null ) ) )
- {
- return;
- }
-
- // Create a new instance
- if( aPropFile == null )
- {
- sInstance = new ConverterProperties();
- sPropFileName = null;
- }
- else
- {
- sInstance = new ConverterProperties( aPropFile );
- sPropFileName = aPropFile.getPath();
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/DOMExternalizer.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,718 +0,0 @@
-/*
-* 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: Externalizes a DOM Document to a byte array.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.awt.Color;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.nokia.tools.themeinstaller.cssparser.CSSDOMProcessor;
-import com.nokia.tools.themeinstaller.cssparser.CSSHandler;
-import com.nokia.tools.themeinstaller.cssparser.PseudoClassResolver;
-
-/**
- * Externalizes DOM Document to a byte array.
- */
-public class DOMExternalizer
- {
-
- // CONSTANTS
- // Text elements according to CXnDomVisitor::KXnElementVisitorTable and
- // CXnODTParser
- private static final String TEXT_ELEMENT = "text";
- private static final String DESC_ELEMENT = "desc";
- private static final String MARQUEE_ELEMENT = "marquee";
- private static final String OBJECT_ELEMENT = "object";
- private static final String NEWSTICKER_ELEMENT = "newsticker";
-
- // Attribute name if node is refnode
- private static final String REF_NODE = "ref";
-
- // List types
- private static final int UNKNOWN = -1;
- private static final int NODE = 0;
- private static final int ATTRIBUTE = 1;
- private static final int PROPERTY = 2;
-
- // The Constant COLOR_TABLE_SIZE
- private static final int COLOR_TABLE_SIZE = 3;
-
- // Pseudo class resolver
- private PseudoClassResolver iPseudoResolver;
-
- // The value type resolver
- private ValueTypeResolver iValueTypeResolver;
-
- // String pool
- private StringPool iStringPool;
-
- // DOM Document
- private Document iDocument;
-
- // Byte output stream for delivering the externalized data
- private ByteArrayOutputStream iBaos;
-
- // Data output stream for writing to the baos
- private ODTDataOutputStream iODTDos;
-
- // Node id and counter
- private int iCurrentNodeId = 0;
-
- /** CSSDOMProsessor for checking property's inheritance value. */
- private CSSDOMProcessor iCSSDOMProsessor;
-
- /**
- * Constructor.
- * @param aDocument DOM Document to externalize
- */
- public DOMExternalizer( Document aDocument )
- {
- iPseudoResolver = new PseudoClassResolver();
- iValueTypeResolver = new ValueTypeResolver();
- iCSSDOMProsessor = new CSSDOMProcessor();
- iStringPool = new StringPool();
- iDocument = aDocument;
- iBaos = new ByteArrayOutputStream();
- iODTDos = new ODTDataOutputStream( iBaos );
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#finalize()
- */
- protected void finalize() throws Throwable
- {
- iODTDos.close();
- iBaos.close();
- }
-
- /**
- * Externalizes the DOM document and string pool to a byte array.
- * @return Byte array containing the document
- * @throws IOException if writing to a stream fails
- * @throws ODTException
- */
- public byte[] getByteArray() throws IOException, ODTException
- {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- byte[] resultArray = null;
-
- try
- {
- // Externalize the DOM
- doExternalize();
-
- // Externalize the string pool
- result.write( iStringPool.toByteArray() );
-
- // Write the dom contents to the result baos
- result.write( iBaos.toByteArray() );
-
- resultArray = result.toByteArray();
- }
- finally
- {
- if( result != null )
- {
- result.close();
- }
- }
-
- return resultArray;
- }
-
- /**
- * Do the externalization process.
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with property value externalization
- */
- private void doExternalize() throws IOException, ODTException
- {
- Node rootElement = iDocument.getDocumentElement();
-
- if( rootElement != null )
- {
- // Root node exists
- iODTDos.writeBoolean( true );
- externalizeNode( ( Node )rootElement, true );
- }
- else
- {
- // No root node
- iODTDos.writeBoolean( false );
- }
- }
-
- /**
- * Externalizes a node in the DOM tree.
- * @param aNode Node to externalize
- * @param aRootNode true, if this is the root node of the tree
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with property value externalization
- */
- private void externalizeNode( Node aNode, boolean aRootNode )
- throws IOException, ODTException
- {
- // Write name
- String name = aNode.getNodeName();
- int nameRef = iStringPool.addString( name );
- iODTDos.writeInt16( nameRef );
-
- // Write name space
- String ns = aNode.getNamespaceURI();
- int nsRef = iStringPool.addString( ns );
- iODTDos.writeInt16( nsRef );
-
- // Check and write refnode boolean
- iODTDos.writeBoolean( checkRefNode( aNode ) );
-
- boolean textNodeFound = false;
-
- // Write parsed character data
- StringBuffer pcData = new StringBuffer();
- if( TEXT_ELEMENT.equals( name ) ||
- DESC_ELEMENT.equals( name ) ||
- MARQUEE_ELEMENT.equals( name ) ||
- OBJECT_ELEMENT.equals( name ) ||
- NEWSTICKER_ELEMENT.equals( name ) )
- {
- NodeList list = aNode.getChildNodes();
-
- for( int i = 0; i < list.getLength() ; i++ )
- {
- Node nod = list.item( i );
- if( nod.getNodeType() == Node.TEXT_NODE )
- {
- textNodeFound = true;
- String textNodeValue = nod.getNodeValue();
-
- pcData.append( textNodeValue );
- }
- }
- }
-
- // Write data length and the data
- iODTDos.writeBoolean( textNodeFound );
- if( textNodeFound )
- {
- // Write text length
- iODTDos.writeInt16( pcData.length() );
-
- // Write text node value
- iODTDos.writeString8( pcData.toString() );
- }
- // Update the counter and write node id
- iODTDos.writeInt32( iCurrentNodeId++ );
-
- // Externalize the child list
- externalizeNodeList( aNode );
-
- // Externalize the attribute list
- externalizeAttributeList( aNode );
-
- // Externalize the property list
- externalizePropertyList( aNode );
- }
-
- /**
- * Checks if node is refnode.
- * Node is refnode if some of node's attributes name is "ref".
- * @param aNode Node containing the attributes
- * @return boolean true if node is refnode, otherwise false
- */
- private boolean checkRefNode( Node aNode )
- {
- boolean refNode = false;
- NamedNodeMap list = aNode.getAttributes();
- for ( int i = 0; i < list.getLength(); i++ )
- {
- Node node = list.item( i );
- if ( nodeType( node ) == ATTRIBUTE )
- {
- if( node.getNodeName().equals( REF_NODE ) )
- {
- refNode = true;
- }
- }
- }
- return refNode;
- }
-
- /**
- * Externalizes attributes of a node.
- * @param aNode Node containing the attributes
- * @throws IOException if writing to a stream fails
- * @throws ODTException
- */
- private void externalizeAttributeNode( Node aNode )
- throws IOException, ODTException
- {
- // Write name
- String name = aNode.getNodeName();
- int nameRef = iStringPool.addString( name );
- iODTDos.writeInt16( nameRef );
-
- // Write value
- String value = aNode.getNodeValue();
- int valueRef = iStringPool.addString( value );
- iODTDos.writeInt16( valueRef );
- }
-
- /**
- * Externalizes a property node.
- *
- * @param aNode Node containing the properties
- * @param aParentNode Node's parent node
- *
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with property
- * value externalization
- */
- private void externalizePropertyNode( Node aParentNode, Node aNode )
- throws IOException, ODTException
- {
- // Get property node attributes: property name, values and pseudo class
- NamedNodeMap list = aNode.getAttributes();
-
- // Property value list
- boolean isInherited = externalizePropertyValueList( aParentNode, list );
-
- iODTDos.writeBoolean( isInherited );
-
- // Resolve pseudo class
- int pseudoClass = PseudoClassResolver.NONE;
-
- int count = list.getLength();
- for( int i = 0; i < count; i++ )
- {
- // Browse through all attributes of the style property element and
- // seek for a pseudo class
- Node item = list.item( i );
- if( item.getNodeName().equals( CSSDOMProcessor.STRING_PSEUDOCLASS ) )
- {
- pseudoClass = iPseudoResolver.getKey( item.getNodeValue() );
- if( pseudoClass == UNKNOWN )
- {
- throw new ODTException( "Error externalizing ODT/styles: " +
- "unknown pseudo class" );
- }
- break;
- }
- }
-
- // Pseudo class -> int8
- iODTDos.writeByte( pseudoClass );
- }
-
- /**
- * Externalize a list of nodes.
- * @param aParentNode Parent node
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with property value externalization
- */
- private void externalizeNodeList( Node aParentNode ) throws IOException, ODTException
- {
- // Write list type
- iODTDos.writeByte( NODE );
-
- NodeList list = aParentNode.getChildNodes();
-
- // Count element nodes
- int count = countNodes( list );
-
- // Write element node count
- iODTDos.writeInt32( count );
-
- for ( int i = 0; i < list.getLength(); i++ )
- {
- Node node = list.item( i );
-
- if ( nodeType( node ) == NODE )
- {
- externalizeNode( node, false );
- }
- }
- }
-
- /**
- * Externalize a list of attributes.
- * @param aParentNode Node containing the attributes.
- * @throws IOException if writing to a stream fails
- * @throws ODTException
- */
- private void externalizeAttributeList( Node aParentNode )
- throws IOException, ODTException
- {
- // Write list type
- iODTDos.writeByte( ATTRIBUTE );
-
- NamedNodeMap list = aParentNode.getAttributes();
-
- // Count element nodes
- int count = countAttributes( list );
-
- // Write element node count
- iODTDos.writeInt32( count );
-
- for ( int i = 0; i < list.getLength(); i++ )
- {
- Node node = list.item( i );
-
- if ( nodeType( node ) == ATTRIBUTE )
- {
- externalizeAttributeNode( node );
- }
- }
- }
-
- /**
- * Externalize a list of properties.
- * @param aParentNode Node containing the properties
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with property value externalization
- */
- private void externalizePropertyList( Node aParentNode ) throws IOException, ODTException
- {
- // Write list type
- iODTDos.writeByte( PROPERTY );
-
- NodeList list = aParentNode.getChildNodes();
-
- // Count element nodes
- int count = countProperties( list );
-
- // Write element node count
- iODTDos.writeInt32( count );
-
- for ( int i = 0; i < list.getLength(); i++ )
- {
- Node node = list.item( i );
-
- if ( nodeType( node ) == PROPERTY )
- {
- externalizePropertyNode( aParentNode, node );
- }
- }
- }
-
- /**
- * Parses a Color from string.
- *
- * @param aColor Color values in String made by CSSHandler
- *
- * @return The color
- *
- * @throws ODTException the ODT exception
- */
- private Color parseColorFromString( String aColor ) throws ODTException
- {
- String sx[] = aColor.split( CSSHandler.COMMA );
- int ix[] = new int[ sx.length ];
-
- // LexicalUnit.SAC_RGBCOLOR knows color values with format
- // rgb(0, 0, 0) and #000. That is, with three parameters
- if ( sx.length != COLOR_TABLE_SIZE )
- {
- throw new ODTException( "Error in DOM/style data externalization: "
- + "RGB Values: parameter amount" );
- }
-
- for ( int i = 0; i < sx.length; i++ )
- {
- if ( sx[ i ].contains( CSSHandler.SEPARATOR ) )
- {
- // Check if single color's value is integer
- Short valueType = iValueTypeResolver.getValue( Short
- .valueOf( sx[ i ].substring( 0, sx[ i ]
- .indexOf( CSSHandler.SEPARATOR ) ) ) );
-
- if ( valueType.intValue() != ValueTypeResolver.E_NUMBER )
- {
- throw new ODTException(
- "Error in DOM/style data externalization: "
- + "RGB Values: R, G or B not interger" );
- }
- String redGreenBlue = sx[ i ].substring( sx[ i ]
- .indexOf( CSSHandler.SEPARATOR ) + 1, sx[ i ]
- .length() );
- Integer rgbValue = Integer.valueOf( redGreenBlue );
- ix[ i ] = rgbValue.intValue();
- }
- else
- {
- throw new ODTException(
- "Error in DOM/style data externalization: "
- + "RGB Values: can't resolve value type" );
- }
- }
- return new Color( ix[ 0 ], ix[ 1 ], ix[ 2 ] );
- }
-
- /**
- * Parses the Value Type from Value.
- *
- * @param aAttrValue The attribute value
- *
- * @return Parsed value as a string
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ODTException
- */
- private String parseAttrValue( String aAttrValue, PropertyValue aPropValue )
- throws IOException, ODTException
- {
- if ( aAttrValue.length() > 0 )
- {
- if ( aAttrValue.contains( "|" ) )
- {
- String type = aAttrValue
- .substring( 0, aAttrValue.indexOf( '|' ) );
- String value = aAttrValue.substring(
- aAttrValue.indexOf( '|' ) + 1, aAttrValue.length() );
-
- Short lexicalUnit = Short.valueOf( type );
- Short primitiveValueType =
- iValueTypeResolver.getValue( lexicalUnit );
-
- switch ( primitiveValueType.intValue() )
- {
- case ValueTypeResolver.E_NUMBER:
- double doubleValueInteger = Double.valueOf( value ).doubleValue();
- aPropValue.setRealValue( doubleValueInteger,
- primitiveValueType.shortValue() );
- break;
- case ValueTypeResolver.E_UNIT_VALUE:
- case ValueTypeResolver.E_PERCENTAGE:
- case ValueTypeResolver.E_EMS:
- case ValueTypeResolver.E_EXS:
- case ValueTypeResolver.E_PX:
- case ValueTypeResolver.E_CM:
- case ValueTypeResolver.E_MM:
- case ValueTypeResolver.E_IN:
- case ValueTypeResolver.E_PT:
- case ValueTypeResolver.E_PC:
- case ValueTypeResolver.E_DEG:
- case ValueTypeResolver.E_RAD:
- case ValueTypeResolver.E_GRAD:
- case ValueTypeResolver.E_MS:
- case ValueTypeResolver.E_S:
- case ValueTypeResolver.E_HZ:
- case ValueTypeResolver.E_KHZ:
- double doubleValuePercentage = Double.valueOf( value ).doubleValue();
- aPropValue.setRealValue( doubleValuePercentage,
- primitiveValueType.shortValue() );
- break;
- case ValueTypeResolver.E_IDENT:
- case ValueTypeResolver.E_STRING:
- case ValueTypeResolver.E_URI:
- case ValueTypeResolver.E_ATTR:
- aPropValue.setString( new String( value ),
- primitiveValueType.shortValue() );
- break;
- case ValueTypeResolver.E_RGB_COLOR:
- Color color = parseColorFromString(value);
- aPropValue.setRgbValue( color );
- break;
- default:
- break;
- }
-
- return value;
- }
- return aAttrValue;
- }
- return aAttrValue;
- }
-
- /**
- * Externalize a list of property values.
- *
- * @param aNode the a node
- * @param aAttrList the a attr list
- *
- * @return true, if property is inherited
- *
- * @throws IOException if data output stream can not be written
- * @throws ODTException if there is an error with externalizing property values
- */
- private boolean externalizePropertyValueList( Node aNode, NamedNodeMap aAttrList )
- throws IOException, ODTException
- {
- PropertyValueList valueList = new PropertyValueList( iStringPool );
-
- boolean isInherited = false;
- String name = null;
- String value = null;
-
- for ( int i = 0; i < aAttrList.getLength(); i++ )
- {
- Node node = aAttrList.item( i );
-
- if ( nodeType( node ) == ATTRIBUTE &&
- !node.getNodeName().equals( CSSDOMProcessor.STRING_PSEUDOCLASS ) )
- {
- String attrName = node.getNodeName();
- String attrValue = node.getNodeValue();
-
- if( attrName.equals( CSSDOMProcessor.STRING_NAME ) &&
- name == null )
- {
- name = attrValue;
- }
- else if( attrName.startsWith( CSSDOMProcessor.STRING_VALUE ) )
- {
- value = attrValue;
-
- // Checking if property is inherited.
- // This emulates the behavior of the Symbian side implementation
- // where this is true in following cases:
- // 1. Value equals "inherited"
- // 2. Property is inheritable and the element can inherit properties
- //
- // This means that also some properties that aren't actually
- // inherited, are also set with value isIherited == "true"
- isInherited = iCSSDOMProsessor.canInherit( (Element) aNode, name, value );
-
- PropertyValue propValue = valueList.newItem();
- parseAttrValue( value, propValue );
- }
- else
- {
- throw new ODTException( "Error in DOM/style data externalization: " +
- "Property values" );
- }
- }
- }
-
- if( name != null &&
- value != null )
- {
- // Write property name
- int nameRef = iStringPool.addString( name );
- iODTDos.writeInt16( nameRef );
-
- // Externalize the property value list to the stream
- valueList.externalize( iODTDos );
- }
- else
- {
- throw new ODTException( "Error in DOM/style data externalization: " +
- "Property values" );
- }
- return isInherited;
- }
-
- /**
- * Count element nodes in a node list.
- * @param aList Node list
- * @param aNodeType Node type to count
- * @return Count of found nodes
- */
- private static int countNodes( NodeList aList )
- {
- int count = 0;
- for( int i = 0; i < aList.getLength(); i++ )
- {
- // Exclude elements that are style properties
- if( nodeType( aList.item( i ) ) == NODE )
- {
- count++;
- }
- }
-
- return count;
- }
-
- /**
- * Count attributes in a named node map.
- * @param aList Node map
- * @param aNodeType Node type to count
- * @return Count of found nodes
- */
- private static int countAttributes( NamedNodeMap aList )
- {
- int count = 0;
- for( int i = 0; i < aList.getLength(); i++ )
- {
- if( nodeType( aList.item( i ) ) == ATTRIBUTE )
- {
- count++;
- }
- }
-
- return count;
- }
-
- /**
- * Count properties in a node list.
- * @param aList Node list
- * @param aNodeType Node type to count
- * @return Count of found nodes
- */
- private static int countProperties( NodeList aList )
- {
- int count = 0;
- for( int i = 0; i < aList.getLength(); i++ )
- {
- // Include only elements that are style properties
- if( nodeType( aList.item( i ) ) == PROPERTY )
- {
- count++;
- }
- }
-
- return count;
- }
-
- /**
- * Resolve node type. Possible types: NODE, ATTRIBUTE or PROPERTY
- * @param aItem Node to resolve
- * @return Type of the node. If the type can not be determined, UNKNOWN is returned
- */
- private static int nodeType( Node aItem )
- {
- int type = UNKNOWN;
-
- // Element that is not a style property element
- if( aItem.getNodeType() == Node.ELEMENT_NODE &&
- !aItem.getNodeName().equals( CSSDOMProcessor.STRING_PROPERTY ) )
- {
- type = NODE;
- }
- // Attribute nodes
- else if( aItem.getNodeType() == Node.ATTRIBUTE_NODE )
- {
- type = ATTRIBUTE;
- }
- // Style property element
- else if( aItem.getNodeType() == Node.ELEMENT_NODE &&
- aItem.getNodeName().equals( CSSDOMProcessor.STRING_PROPERTY ) )
- {
- type = PROPERTY;
- }
-
- return type;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/IParseOperationListener.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
-* 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: Listener for parsing operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-/**
- * Observer interface for parse operation completions.
- */
-public interface IParseOperationListener
- {
- // CONSTANTS
- public static final int OPERATION_SUCCESSFUL = 0;
- public static final int SYNTAX_ERROR = -1;
- public static final int SAX_PARSE_ERROR = -2;
- public static final int IO_ERROR = -3;
- public static final int CSS_PARSER_ERROR = -4;
- public static final int EXCEPTION = -5;
-
- /**
- * Is called when parse operation is completed.
- * @param aErr error code
- * @param aReason completion reason
- */
- public void parseOperationCompleted( int aErr, String aReason );
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/MimeTypeResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,265 +0,0 @@
-/*
-* 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: Gets the mime- and resource type using file's name extension
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.util.Hashtable;
-
-/**
- * Resolves the MimeType and Resource type of the resource to match the file
- * name used in the Symbian side. This class is following the behavior of the
- * Symbian class XnInstallationHandler.cpp in ...Xuikon\UIManager\src\
- *
- * In Symbian, MimeType is TDataType that has TBuf8 and TUid. The constructor
- * taking a descriptor of TDataType is as follows:
- *
- * If descriptor begins with "x-epoc/x-app", identifying data as a native
- * Symbian type, then the associated UID is set to the UID value which is
- * expected to follow the characters "x-epoc/x-app". If no sensible UID can be
- * extracted from the characters following: "x-epoc/x-app", then the associated
- * UID is set to KNullUid.
- *
- * Else Uid is set to KNullDesc and the descriptor is the descriptor given in
- * parameter.
- *
- * In ...Xuikon\UIManager\src\XnInstallationHandler.cpp
- * (ImportCompatibleResourcesL) MimeType is constructed using the Descriptor
- * that is parsed using file's name extension. Descriptors beginning with
- * "x-epoc/x-app" aren't used so TUid part is not implemented. Some of the types
- * are left empty in XnInstallationHandler.cpp. This represented as
- * EMPTY_MIME_TYPE
- *
- * Resource types are defined in Symbian side class XnResource.h
- *
- */
-public class MimeTypeResolver
- {
- private static Hashtable iResourceTypeAndMimeType;
-
- public static final int E_RESOURCE_NONE = 0;
- public static final int E_RESOURCERLB = 1;
- public static final int E_RESOURCEODT = 2;
- public static final int E_RESOURCEDTD = 3;
- public static final int E_RESOURCEXML = 4;
- public static final int E_RESOURCECSS = 5;
- public static final int E_RESOURCEDAT = 6;
- public static final int E_RESOURCERES = 7;
- public static final int E_RESOURCEFBS = 8;
- public static final int E_RESOURCEMBM = 9;
- public static final int E_RESOURCEMIF = 10;
- public static final int E_RESOURCEBMP = 11;
- public static final int E_RESOURCEJPG = 12;
- public static final int E_RESOURCEJPEG = 13;
- public static final int E_RESOURCEPNG = 14;
- public static final int E_RESOURCEGIF = 15;
- public static final int E_RESOURCEAAC = 16;
- public static final int E_RESOURCEWAV = 17;
- public static final int E_RESOURCEMID = 18;
- public static final int E_RESOURCEMP3 = 19;
- public static final int E_RESOURCEM3G = 20;
- public static final int E_RESOURCESVG = 21;
- public static final int E_RESOURCESWF = 22;
- public static final int E_RESOURCEMIME = 23;
- public static final int E_RESOURCETXT = 24;
-
- public static final String KRLB_FILE_EXTENSION = ".r";
- public static final String KODT_FILE_EXTENSION = ".o";
- public static final String KDTD_FILE_EXTENSION = ".dtd";
- public static final String KXML_FILE_EXTENSION = ".xml";
- public static final String KCSS_FILE_EXTENSION = ".css";
- public static final String KDAT_FILE_EXTENSION = ".dat";
- public static final String KFBS_FILE_EXTENSION = ".fbs";
- public static final String KMBM_FILE_EXTENSION = ".mbm";
- public static final String KMIF_FILE_EXTENSION = ".mif";
- public static final String KBMP_FILE_EXTENSION = ".bmp";
- public static final String KJPG_FILE_EXTENSION = ".jpg";
- public static final String KJPEG_FILE_EXTENSION = ".jpeg";
- public static final String KPNG_FILE_EXTENSION = ".png";
- public static final String KGIF_FILE_EXTENSION = ".gif";
- public static final String KAAC_FILE_EXTENSION = ".aac";
- public static final String KWAV_FILE_EXTENSION = ".wav";
- public static final String KMID_FILE_EXTENSION = ".mid";
- public static final String KMP3_FILE_EXTENSION = ".mp3";
- public static final String KM3G_FILE_EXTENSION = ".m3g";
- public static final String KSVG_FILE_EXTENSION = ".svg";
- public static final String KSWF_FILE_EXTENSION = ".swf";
- public static final String KTXT_FILE_EXTENSION = ".txt";
-
- public static final String KAPAAPPTYPEDES = "x-epoc/x-app";
-
- public static final String TXT_MIME_TYPE = "text/xml";
- public static final String MBM_MIME_TYPE = "image/x-epoc-mbm";
- public static final String EMPTY_MIME_TYPE = "";
- public static final String EMPTY_FILE_EXTENSION = "";
- public static final String WAV_MIME_TYPE = "audio/x-wav";
- public static final String MIDI_MIME_TYPE = "audio/midi";
- public static final String UNKNOWN_MIME_TYPE = "unknown";
-
- public static final String NAME_EXTENSION_SEPARATOR = ".";
-
- /**
- * Instantiates a new mimetype resolver.
- */
- public MimeTypeResolver()
- {
- iResourceTypeAndMimeType = new Hashtable();
- iResourceTypeAndMimeType.put( KRLB_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCERLB ) );
- iResourceTypeAndMimeType.put( KODT_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEODT ) );
- iResourceTypeAndMimeType.put( KDTD_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEDTD ) );
- iResourceTypeAndMimeType.put( KXML_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEXML ) );
- iResourceTypeAndMimeType.put( KCSS_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCECSS ) );
- iResourceTypeAndMimeType.put( KDAT_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEDAT ) );
- iResourceTypeAndMimeType.put( KFBS_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEFBS ) );
- iResourceTypeAndMimeType.put( KMBM_FILE_EXTENSION, new ResourceTypeAndMimeType( MBM_MIME_TYPE, E_RESOURCEMBM ) );
- iResourceTypeAndMimeType.put( KMIF_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEMIF ) );
- iResourceTypeAndMimeType.put( KBMP_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEBMP ) );
- iResourceTypeAndMimeType.put( KJPG_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEJPG ) );
- iResourceTypeAndMimeType.put( KJPEG_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEJPEG ) );
- iResourceTypeAndMimeType.put( KPNG_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEPNG ) );
- iResourceTypeAndMimeType.put( KGIF_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEGIF ) );
- iResourceTypeAndMimeType.put( KAAC_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCEAAC ) );
- iResourceTypeAndMimeType.put( KWAV_FILE_EXTENSION, new ResourceTypeAndMimeType( WAV_MIME_TYPE, E_RESOURCEWAV ) );
- iResourceTypeAndMimeType.put( KMID_FILE_EXTENSION, new ResourceTypeAndMimeType( MIDI_MIME_TYPE, E_RESOURCEMID ) );
- iResourceTypeAndMimeType.put( KMP3_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEMP3 ) );
- iResourceTypeAndMimeType.put( KM3G_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCEM3G ) );
- iResourceTypeAndMimeType.put( KSVG_FILE_EXTENSION, new ResourceTypeAndMimeType( UNKNOWN_MIME_TYPE, E_RESOURCESVG ) );
- iResourceTypeAndMimeType.put( KSWF_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCESWF ) );
- iResourceTypeAndMimeType.put( KTXT_FILE_EXTENSION, new ResourceTypeAndMimeType( EMPTY_MIME_TYPE, E_RESOURCETXT ) );
- }
-
- /**
- * Gets the MimeType.
- *
- * @param aFileName The file name
- *
- * @return The MimeType
- */
- public String getMimeType( String aFileName )
- {
- return getMimeTypeValue( getFileExtension( aFileName ) );
- }
-
- /**
- * Gets the resource type.
- *
- * @param aFileName The file name
- *
- * @return The Resource type
- */
- public int getResourceType( String aFileName )
- {
- return getResourceTypeValue( getFileExtension( aFileName ) );
- }
-
- /**
- * Gets the mimetype value.
- *
- * @param aKey The hashtable key is filen name extension
- *
- * @return The mimetype value
- */
- private String getMimeTypeValue( String aKey )
- {
- if ( iResourceTypeAndMimeType.containsKey( aKey ) )
- {
- ResourceTypeAndMimeType rtamt = ( ResourceTypeAndMimeType ) iResourceTypeAndMimeType.get( aKey );
- return rtamt.getMimeType();
- }
- return EMPTY_MIME_TYPE;
- }
-
- /**
- * Gets the resource type value.
- *
- * @param aKey The hashtable key is file name extension
- *
- * @return The resource type value
- */
- private int getResourceTypeValue( String aKey )
- {
- if ( iResourceTypeAndMimeType.containsKey( aKey ) )
- {
- ResourceTypeAndMimeType rtamt = ( ResourceTypeAndMimeType ) iResourceTypeAndMimeType.get( aKey );
- return rtamt.getResourceType();
- }
- return E_RESOURCE_NONE;
- }
-
- /**
- * Gets the file extension.
- *
- * @param aFileName The file name
- *
- * @return The file extension
- */
- private String getFileExtension( String aFileName )
- {
- String fileExtension = "";
- if ( aFileName.contains( NAME_EXTENSION_SEPARATOR ) )
- {
- fileExtension = aFileName.substring(
- aFileName.lastIndexOf( NAME_EXTENSION_SEPARATOR ),
- aFileName.length() ).toLowerCase();
- return fileExtension;
- }
- return EMPTY_FILE_EXTENSION;
- }
-
- /**
- * Inner class for containing mimetype - resource type pairs.
- */
- private static class ResourceTypeAndMimeType
- {
- private String iMimeType;
- private int iResourceType;
-
- /**
- * Instantiates a new resource type and mime type pair.
- *
- * @param aMimeType The mime type
- * @param aResourceType The resource type
- */
- public ResourceTypeAndMimeType( String aMimeType, int aResourceType )
- {
- iMimeType = aMimeType;
- iResourceType = aResourceType;
- }
-
- /**
- * Gets the mimetype.
- *
- * @return The mimetype
- */
- public String getMimeType()
- {
- return iMimeType;
- }
-
- /**
- * Gets the resource type.
- *
- * @return The resource type
- */
- public int getResourceType()
- {
- return iResourceType;
- }
-
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTConverter.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
-* 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: Interface class for parse operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.IOException;
-
-import org.w3c.dom.Document;
-
-import com.nokia.tools.themeinstaller.cssparser.CSSParser;
-import com.nokia.tools.themeinstaller.xmlparser.XMLParser;
-
-/**
- * Interface class for parse operations
- */
-public class ODTConverter extends ParseOperation
- {
-
- /** ParserComposite */
- private ParserComposite iParserComposite;
-
- /** Listener for parse operations */
- IParseOperationListener iListener;
-
- /**
- * Constructor
- */
- public ODTConverter()
- {
- iParserComposite = new ParserComposite();
- }
-
- /**
- * Adds the listener.
- *
- * @param aListener listener for parse operations
- */
- public void addListener( IParseOperationListener aListener )
- {
- iParserComposite.addListener( aListener );
- }
-
- /**
- * Creates XMLParser and adds it to ParserComposite
- * @param aFileName
- */
- public void addXML( String aFileName )
- {
- XMLParser xmlConv = new XMLParser( aFileName );
- iParserComposite.addOperation( xmlConv );
- }
-
- /**
- * Creates XMLParser and adds it to ParserComposite. By using this method,
- * the XML parser will ignore DTD definition in DOCTYPE. The specified
- * external DTD file is used instead.
- * @param aFileName File name of the XML
- * @param aExtDTD File name of the external DTD
- */
- public void addXML( String aFileName, String aExtDTD )
- {
- XMLParser xmlConv = new XMLParser( aFileName, aExtDTD );
- iParserComposite.addOperation( xmlConv );
- }
-
- /**
- * Creates CSSParser and adds it to ParserComposite
- * @param aFileName
- */
- public void addCSS( String aFileName )
- {
- CSSParser cssConv = new CSSParser( aFileName );
- iParserComposite.addOperation( cssConv );
- }
-
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.odtconverter.ParseOperation#parse()
- */
- public void parse( ) throws IOException, ODTException
- {
- iParserComposite.parse( );
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.odtconverter.ParseOperation#getDOMDocument()
- */
- public Document getDOMDocument()
- {
- return iParserComposite.getDOMDocument();
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTDataOutputStream.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,250 +0,0 @@
-/*
-* 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: Implements ODTDataOutputStream
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import com.ibm.icu.text.UnicodeCompressor;
-
-/**
- * Implements ODTDataOutputStream. Helper class for writing strings
- * and numeric values to stream so that native implementation reads
- * them properly.
- *
- */
-public class ODTDataOutputStream extends DataOutputStream
- {
-
- public ODTDataOutputStream( OutputStream aStream )
- {
- super( aStream );
- }
-
- /**
- * Write unsigned 32-bit integer.
- * Using long as Java's Integer value is restricted to
- * range -2^31 ... 2^31-1
- * @param aValue the value as long
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- public void writeUnsignedInt32( long aValue ) throws IOException, ODTException
- {
- // Using range of unsigned integer
- // Values bigger than 2^32-1 are not allowed
- if ( aValue < 0 || aValue > 0xFFFFFFFFL )
- {
- throw new ODTException(
- "ODTDataOutputStream writeUnsignedInt32s failed, value out of range" );
- }
-
- byte[] bArray = new byte[ 4 ];
- bArray[ 3 ] = ( byte ) ( ( aValue & 0xFF000000L ) >> 24 );
- bArray[ 2 ] = ( byte ) ( ( aValue & 0x00FF0000L ) >> 16 );
- bArray[ 1 ] = ( byte ) ( ( aValue & 0x0000FF00L ) >> 8 );
- bArray[ 0 ] = ( byte ) ( aValue & 0x000000FFL );
-
- int len = bArray.length;
- super.write( bArray, 0, len );
- }
-
- /**
- * Writes int to stream for native Int32
- * @param aValue
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- public void writeInt32( int aValue ) throws ODTException, IOException
- {
- byte[] bArray = new byte[4]; // we want 32 bit integer
- ByteBuffer buf = ByteBuffer.wrap( bArray );
- // byte order in native is LITTLE_ENDIAN
- buf.order( ByteOrder.LITTLE_ENDIAN );
- buf.putInt( aValue );
-
- if( buf.hasArray() )
- {
- bArray = buf.array();
- }
- else
- {
- throw new ODTException( "ODTDataOutputStream writeInt32 failed" );
- }
-
- int len = bArray.length;
- super.write( bArray, 0, len );
- }
-
- /**
- * Writes int to stream for native Int16
- * @param aValue
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- public void writeInt16( int aValue ) throws ODTException, IOException
- {
- Integer value = new Integer( aValue );
- byte[] bArray = new byte[2]; // we want 16 bit integer
- ByteBuffer buf = ByteBuffer.wrap( bArray );
- // byte order in native is LITTLE_ENDIAN
- buf.order( ByteOrder.LITTLE_ENDIAN );
- buf.putShort( value.shortValue() );
-
- if( buf.hasArray() )
- {
- bArray = buf.array();
- }
- else
- {
- throw new ODTException( "ODTDataOutputStream writeInt16 failed" );
- }
-
- int len = bArray.length;
- super.write( bArray, 0, len );
- }
-
- /**
- * Writes double to stream for native TReal64
- * @param aValue
- * @throws ODTException
- * @throws IOException
- */
- public void writeTReal64( double aValue ) throws ODTException, IOException
- {
- byte[] bArray = new byte[8]; // we want 64 bit TReal
- ByteBuffer buf = ByteBuffer.wrap( bArray );
- buf.order( ByteOrder.LITTLE_ENDIAN );
- buf.putDouble( aValue );
-
- if( buf.hasArray() )
- {
- bArray = buf.array();
- }
- else
- {
- throw new ODTException( "ODTDataOutputStream writeTReal64 failed" );
- }
-
- int len = bArray.length;
- super.write( bArray, 0, len );
- }
-
- /**
- * Writes string to stream for native HBufC8
- *
- * See Symbian common sources for more information:
- *
- * src\common\generic\syslibs\store\USTRM\US_FUNC.CPP
- * ExternalizeL(const TDesC8& aDes8,RWriteStream& aStream)
- *
- * src\common\generic\syslibs\store\INC\U32STD.INL
- * TDesHeader::TDesHeader(const TDesC8& aDes8)
- *
- * @param aS String to write
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- public void writeString8( String aS ) throws ODTException, IOException
- {
- byte[] ba = aS.getBytes();
- int len = ba.length;
-
- writeCardinality( len, true );
-
- super.write( ba, 0, len );
- }
-
- /**
- * Writes string to stream for native HBufC16.
- *
- * See Symbian common sources for more information:
- *
- * src\common\generic\syslibs\store\USTRM\US_FUNC.CPP
- * ExternalizeL(const TDesC16& aDes16,RWriteStream& aStream)
- *
- * src\common\generic\syslibs\store\INC\U32STD.INL
- * TDesHeader::TDesHeader(const TDesC16& aDes16)
- *
- * @param aS String to write
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- public void writeString16( String aS ) throws ODTException, IOException
- {
- // Take length of the String for calculating the cardinality
- // The cardinality is calculated of the original length of the string
- // (before compress) because the original length is again valid when
- // the string is uncompressed in the Symbian side.
- int clen = aS.length();
-
- // Using UnicodeCopressor to compress string. The Unicode Compression
- // is also used in Unicode builds of Symbian.
- byte[] ba = UnicodeCompressor.compress( aS );
- int len = ba.length;
-
- writeCardinality( clen, false );
-
- super.write( ba, 0, len );
- }
-
- /**
- * Calculates HBufC8 and HBufC16 string length for native stream.
- *
- * See Symbian common sources for more information:
- *
- * src\common\generic\syslibs\store\USTRM\US_UTL.CPP
- * TCardinality::ExternalizeL(RWriteStream& aStream)
- *
- * src\common\generic\syslibs\store\INC\U32STD.INL
- * TDesHeader::TDesHeader(const TDesC16& aDes16)
- * TDesHeader::TDesHeader(const TDesC8& aDes8)
- *
- * @param aLenght string length
- * @param a8bit set true for 8-bit descriptors, this adds one to the count
- * @throws IOException if writing to a stream fails
- * @throws ODTException if data conversion fails
- */
- private void writeCardinality( int aLenght, boolean a8bit ) throws IOException, ODTException
- {
- int count = aLenght * 2;
-
- if( a8bit )
- {
- count = count + 1;
- }
-
- if( count <= ( Byte.MAX_VALUE ) )
- {
- super.writeByte( count << 1 );
- }
- else if( count <= ( 65535 >>> 2 ) )
- {
- writeInt16( ( count << 2 ) + 1 );
- }
- else
- {
- writeInt32( ( count << 3 ) + 3 );
- }
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTDocument.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
-* 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: This class contains DOM document, ODT header
- * and ODT resources.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.util.Vector;
-import org.w3c.dom.Document;
-
-/**
- * This class contains DOM document, ODT header and ODT resources.
- */
-public class ODTDocument
- {
-
- /** ODTHeader */
- protected ODTHeader iODTHeader;
-
- /** Vector for ODTResources */
- protected Vector iODTResources = new Vector();
-
- /** DOMDocument */
- protected Document iDOMDocument;
-
-
- /**
- * Setter for ODTHeader
- * @param aODTHeader
- */
- public void setODTHeader( ODTHeader aODTHeader )
- {
- iODTHeader = aODTHeader;
- }
-
- /**
- * Getter for ODTHeader
- */
- public ODTHeader getODTHeader()
- {
- return iODTHeader;
- }
-
- /**
- * Setter for ODTResources
- * @param aODTResources
- */
- public void setODTResources( Vector aODTResources )
- {
- iODTResources = aODTResources;
- }
-
- /**
- * Getter for ODTResources
- */
- public Vector getODTResources()
- {
- return iODTResources;
- }
-
- /**
- * Setter for DOMDocument
- * @param aDOMDocument
- */
- public void setDOMDocument( Document aDOMDocument )
- {
- iDOMDocument = aDOMDocument;
- }
-
- /**
- * Getter for DOMDocument
- */
- public Document getDOMDocument()
- {
- return iDOMDocument;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTException.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
-* 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: Exception for ODT parsing operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-/**
- * The Class ODTException.
- */
-public class ODTException extends Exception
- {
-
- // Default serial version UID
- private static final long serialVersionUID = 1L;
-
- /**
- * Instantiates a new ODT exception.
- *
- * @param aMessage the message
- */
- public ODTException( String aMessage )
- {
- super( aMessage );
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTHeader.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
-* 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: This class contains meta information about the theme.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Hashtable;
-
-/**
- * This class contains meta information about the theme.
- */
-public class ODTHeader extends Hashtable
- {
- // Default serial version UID
- private static final long serialVersionUID = 1L;
-
- // Header fields
- public static final String ApplicationUID = "ApplicationUID";
- public static final String ProviderUID = "ProviderUID";
- public static final String ThemeUID = "ThemeUID";
- public static final String ProviderName = "ProviderName";
- public static final String ThemeFullName = "ThemeFullName";
- public static final String ThemeShortName = "ThemeShortName";
- public static final String ThemeVersion = "ThemeVersion";
- public static final String ScreenSizeX = "ScreenSizeX";
- public static final String ScreenSizeY = "ScreenSizeY";
- public static final String Language = "Language";
- public static final String Flags = "Flags";
-
- /**
- * Gets binary representation of ODTHeader
- * @return binary representation of ODTHeader
- * @throws IOException if stream I/O fails
- * @throws ODTException if header externalization fails
- */
- public byte[] getBinaryODTHeader() throws IOException, ODTException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ODTDataOutputStream dos = new ODTDataOutputStream( baos );
-
- byte[] binaryODTHeader = null;
-
- try
- {
- // Externalize header contents to the byte stream
- if(null!=get(ApplicationUID))
- dos.writeUnsignedInt32( ( ( Long )get( ApplicationUID ) ).longValue() );
- if(null!=get(ProviderUID))
- dos.writeUnsignedInt32( ( ( Long )get( ProviderUID ) ).longValue() );
- if(null!=get(ThemeUID))
- dos.writeUnsignedInt32( ( ( Long )get( ThemeUID ) ).longValue() );
- if(null!=get(ProviderName))
- dos.writeString16( ( String )get( ProviderName ) );
- if(null!=get(ThemeFullName))
- dos.writeString16( ( String )get( ThemeFullName ) );
- if(null!=get(ThemeShortName))
- dos.writeString16( ( String )get( ThemeShortName ) );
- if(null!=get(ThemeVersion))
-
- dos.writeString16( ( String )get( ThemeVersion ) );
-
- dos.writeInt32( ( ( Integer )get( ScreenSizeX ) ).intValue() );
- dos.writeInt32( ( ( Integer )get( ScreenSizeY ) ).intValue() );
- dos.writeInt32( ( ( Integer )get( Language ) ).intValue() );
- dos.writeInt32( ( ( Integer )get( Flags ) ).intValue() );
- binaryODTHeader = baos.toByteArray();
- }
- catch( Exception e )
- {
- throw new ODTException( e.getMessage() );
- }
- finally
- {
- // Close the streams
- if( dos != null )
- {
- dos.close();
- }
- if( baos != null )
- {
- baos.close();
- }
- }
-
- return binaryODTHeader;
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTInputStream.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
-* 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: Implements ODTInputStream
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-
-/**
- * Implements ODTInputStream
- */
-public class ODTInputStream extends InputStream
- {
-
- /** ODTDocument */
- ODTDocument iODTDocument;
-
- /** ByteArrayOutputStream for binary representations */
- ByteArrayOutputStream iBaos;
-
- /** ODTDataOutputStream for writing data to stream */
- ODTDataOutputStream iODTDos;
-
- /** byte array for read */
- byte[] iByteArray = null;
-
- /** index for reading byte array */
- int iIndex = 0;
-
- /* Literal delimiter is used in separation of theme header and
- other data in ODT-streaming. */
- private static final char DELIM = '#';
-
- // Symbian CDirectFileStore needs these
- private static final int WRITE_ONCE_FILE_STORE_UID = 268435511;
- private static final int UNKNOWN_MEDIA_UID = 73066445;
-
- /**
- * Constructor
- * @param aODTDocument
- * @throws ODTException
- */
- public ODTInputStream( ODTDocument aODTDocument ) throws ODTException
- {
- iODTDocument = aODTDocument;
- iBaos = new ByteArrayOutputStream();
- iODTDos = new ODTDataOutputStream( iBaos );
- getBinaryRepresentations();
- }
-
- /**
- * gets binary representations of ODTHeader, ODTResources and DOMDocument
- * @throws ODTException
- */
- private void getBinaryRepresentations() throws ODTException
- {
- // first write stuff needed by Symbian CDirectFileStore, then
- // get and write ODT material
- try
- {
- // write first uid
- iODTDos.writeInt32( WRITE_ONCE_FILE_STORE_UID );
-
- // write two 0, for keeping stream valid in native side
- iODTDos.writeInt( 0 );
- iODTDos.writeInt( 0 );
-
- // write second uid
- iODTDos.writeInt32( UNKNOWN_MEDIA_UID );
-
- // write index where ODT header starts
- iODTDos.writeInt32( 20 );
-
- // get and write ODT header
- iBaos.write( iODTDocument.getODTHeader().getBinaryODTHeader() );
-
- // write delimiter
- iODTDos.writeInt16( DELIM );
-
- // write resource count
- int resCount = iODTDocument.getODTResources().size();
- iODTDos.writeInt32( resCount );
-
- // get and write ODTResources
- for ( Enumeration resources = iODTDocument.getODTResources()
- .elements(); resources.hasMoreElements(); )
- {
- ODTResource odtResource = ( ODTResource ) resources
- .nextElement();
- iBaos.write( odtResource.getBinaryODTResource() );
- }
-
- // get and write DOMDocument
- DOMExternalizer domExt =
- new DOMExternalizer( iODTDocument.getDOMDocument() );
- iBaos.write( domExt.getByteArray() );
- }
- catch( IOException e )
- {
- throw new ODTException( e.getMessage() );
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.InputStream#close()
- */
- public void close() throws IOException
- {
- iODTDos.close();
- iBaos.close();
- }
-
- /* (non-Javadoc)
- * @see java.io.InputStream#read()
- */
- public int read() throws IOException
- {
- if( iByteArray == null )
- {
- iByteArray = iBaos.toByteArray();
- }
- if( iIndex >= iByteArray.length )
- {
- iByteArray = null;
- return -1;
- }
-
- byte b = iByteArray[iIndex++];
- // because 0xff byte is -1, which is used as end of stream value,
- // we must return 0xff int which is 255.
- if( b == (byte)0xff )
- {
- return 0xff;
- }
- return b;
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ODTResource.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
-* 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: This class contains data about theme resource.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Hashtable;
-
-/**
- * This class contains data about theme resource.
- */
-public class ODTResource extends Hashtable
- {
- // Default serial version UID
- private static final long serialVersionUID = 1L;
-
- // ODT Resource properties, externalized
- public static final String LockingPolicy = "LockingPolicy";
- public static final String CacheType = "CacheType";
- public static final String ResourceType = "ResourceType";
- public static final String ResourceID = "ResourceID";
- public static final String NameSpace = "NameSpace";
- public static final String FileName = "FileName";
- public static final String MimeType = "MimeType";
-
- // Size and offset are hard-coded because they are not used in Xuikon
- private static final int SIZE = 0;
- private static final int OFFSET = 0;
-
- // Name of the temporary file, not externalized
- public static final String TempFileName = "TempFileName";
-
-
- /**
- * Gets binary representation of one ODTResource
- * @return binary representation of one ODTResource
- * @throws IOException
- * @throws ODTException
- */
- public byte[] getBinaryODTResource() throws IOException, ODTException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ODTDataOutputStream dos = new ODTDataOutputStream( baos );
-
- byte[] binaryODTResource = null;
-
- try
- {
- // Write properties of the resource to the byte stream
- dos.writeInt32( ( ( Integer ) get( LockingPolicy ) ).intValue() );
- dos.writeInt32( ( ( Integer ) get( CacheType ) ).intValue() );
- dos.writeInt32( ( ( Integer ) get( ResourceType ) ).intValue() );
- dos.writeString16( ( String ) get( ResourceID ) );
- dos.writeString16( ( String ) get( NameSpace ) );
- dos.writeString16( ( String ) get( FileName ) );
- dos.writeString8( ( String ) get( MimeType ) );
- dos.writeInt32( SIZE );
- dos.writeInt32( OFFSET );
-
- binaryODTResource = baos.toByteArray();
- }
- catch ( Exception e )
- {
- throw new ODTException( e.getMessage() );
- }
- finally
- {
- // Close the streams
- if( dos != null )
- {
- dos.close();
- }
- if( baos != null )
- {
- baos.close();
- }
- }
-
- return binaryODTResource;
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ParseOperation.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
-* 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: Class for parsing operations
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.w3c.dom.Document;
-
-/**
- * This class provides a skeletal implementation of parsing operation
- */
-public abstract class ParseOperation
- {
-
- /** Listener for parsing operations */
- IParseOperationListener iListener;
-
- /** All listeners */
- Vector iListeners = new Vector();
-
- /** DOM document */
- protected Document iDOMDocument;
-
- /**
- * Parses file to DOM Document.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ODTException the ODT exception
- */
- public abstract void parse( )
- throws IOException, ODTException;
-
- /**
- * Getter for DOM document
- * @return DOM document
- */
- public Document getDOMDocument()
- {
- return iDOMDocument;
- }
-
- /**
- * Adds the listener.
- * @param aListener IParseOperationListener
- */
- public void addListener( IParseOperationListener aListener )
- {
- iListeners.addElement( aListener );
- }
-
- /**
- * Calls OperationCompleted for all listeners
- * @param aErr
- * @param aReason
- */
- public void operationCompleted( int aErr, String aReason )
- {
- for ( Enumeration e = iListeners.elements(); e.hasMoreElements(); )
- {
- IParseOperationListener listener = ( IParseOperationListener ) e
- .nextElement();
- listener.parseOperationCompleted( aErr, aReason );
- }
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ParserComposite.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
-* 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: This class stores parser components
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.IOException;
-import java.util.Vector;
-
-/**
- * This class stores parser components and calls components parse method.
- */
-public class ParserComposite extends ParseOperation
- implements IParseOperationListener
- {
-
- /** Vector for parsing operations */
- Vector iParseOperations = new Vector();
-
- /** Vector element index */
- private int iIndex = 0;
-
- /**
- * Instantiates a new ParserComposite.
- */
- public ParserComposite()
- {
- }
-
- /**
- * Adds parsers to ParserComposite.
- *
- * @param ParseOperation
- */
- public void addOperation( ParseOperation aParseOperation )
- {
- iParseOperations.addElement( aParseOperation );
- aParseOperation.addListener( this );
- }
-
- /**
- * If parse operation was successful, calls next until all available files
- * are parsed
- */
- public void parseOperationCompleted( int aErr, String aReason )
- {
- ParseOperation oper;
- if( aErr == OPERATION_SUCCESSFUL )
- {
- // get DOM document from previous parse operation
- oper = ( ParseOperation )iParseOperations.elementAt( iIndex++ );
- iDOMDocument = oper.getDOMDocument();
-
- if( iIndex < iParseOperations.size() )
- {
- oper =
- ( ParseOperation )iParseOperations.elementAt( iIndex );
- try
- {
- oper.iDOMDocument = iDOMDocument;
- oper.parse( );
- }
- catch ( IOException e )
- {
- operationCompleted( SYNTAX_ERROR, e.getMessage() );
- }
- catch ( ODTException e )
- {
- operationCompleted( SYNTAX_ERROR, e.getMessage() );
- }
- }
- else
- {
- operationCompleted( OPERATION_SUCCESSFUL, null );
- }
- }
- else
- {
- operationCompleted( aErr, aReason );
- }
- }
-
- /* (non-Javadoc)
- * @see com.nokia.tools.themeinstaller.odtconverter.ParseOperation#parse()
- */
- public void parse( )
- throws IOException, ODTException
- {
- iIndex = 0;
-
- if( !iParseOperations.isEmpty() )
- {
- ParseOperation oper =
- ( ParseOperation )iParseOperations.elementAt( iIndex );
- oper.parse( );
- }
- else
- {
- return;
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/PropertyValue.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
-* 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: Single property value for property value list.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.awt.Color;
-import java.io.IOException;
-
-/**
- * Property value stores style related data before it is externalized
- * to a binary format.
- */
-public class PropertyValue
- {
-
- // CONSTANTS
- // Ident types
- public static final String STRING_AUTO = "auto";
- public static final String STRING_NONE = "none";
- public static final String STRING_INHERIT = "inherit";
-
- public static final int E_NOT_SET = 0;
- public static final int E_AUTO = 1;
- public static final int E_NONE = 2;
- public static final int E_INHERIT = 3;
-
- // Property value type
- private Short iValueType;
-
- // Flag to identify ident
- private int iIdentType;
-
- // Rgb color value
- private Color iRgbValue;
-
- // Real value
- private double iRealValue;
-
- // String pool index to a string value
- private int iStringRef;
-
- // Reference to the String Pool
- private StringPool iStringPool;
-
- /**
- * Constructor.
- * @param aStringPool Reference to the String Pool
- */
- public PropertyValue( StringPool aStringPool )
- {
- iStringPool = aStringPool;
- }
-
- /**
- * Set rgb value.
- * @param aRgbValue the value to set
- * @param aValueType primitive value type
- * @throws ODTException
- * @throws ODTException if primitive value type is not a rgb color type
- */
- public void setRgbValue( Color aRgbValue )
- throws ODTException
- {
- iRgbValue = aRgbValue;
- iValueType = new Short( ValueTypeResolver.E_RGB_COLOR );
- }
-
- /**
- * Set real value.
- * @param aRealValue the value to set
- * @param aValueType primitive value type
- * @throws ODTException if primitive value type is not a real value type
- */
- public void setRealValue( double aRealValue, short aValueType )
- throws ODTException
- {
- // Verify the value type
- switch( aValueType )
- {
- case ValueTypeResolver.E_NUMBER:
- case ValueTypeResolver.E_PERCENTAGE:
- case ValueTypeResolver.E_EMS:
- case ValueTypeResolver.E_EXS:
- case ValueTypeResolver.E_PX:
- case ValueTypeResolver.E_CM:
- case ValueTypeResolver.E_MM:
- case ValueTypeResolver.E_IN:
- case ValueTypeResolver.E_PT:
- case ValueTypeResolver.E_PC:
- case ValueTypeResolver.E_DEG:
- case ValueTypeResolver.E_RAD:
- case ValueTypeResolver.E_GRAD:
- case ValueTypeResolver.E_MS:
- case ValueTypeResolver.E_S:
- case ValueTypeResolver.E_HZ:
- case ValueTypeResolver.E_KHZ:
- case ValueTypeResolver.E_UNIT_VALUE:
- break;
-
- default:
- throw new ODTException(
- "Property value type is not compatible with real: "
- + aValueType );
- }
-
- iRealValue = aRealValue;
- iValueType = new Short( aValueType );
- }
-
- /**
- * Set string value.
- * @param aString the string to set
- * @param aValueType primitive value type
- * @throws ODTException if primitive value type is not a string type
- */
- public void setString( String aString, short aValueType )
- throws ODTException
- {
- // Verify the value type
- switch( aValueType )
- {
- case ValueTypeResolver.E_STRING:
- case ValueTypeResolver.E_IDENT:
- case ValueTypeResolver.E_URI:
- case ValueTypeResolver.E_ATTR:
- case ValueTypeResolver.E_UNKNOWN:
- break;
-
- default:
- throw new ODTException(
- "Property value type is not compatible with string: "
- + aValueType );
- }
-
- // Add string to the pool
- iStringRef = iStringPool.addString( aString );
-
- // Resolve ident type
- if ( aString.equals( STRING_AUTO ) )
- {
- iIdentType = E_AUTO;
- }
- else if ( aString.equals( STRING_INHERIT ) )
- {
- iIdentType = E_INHERIT;
- }
- else if ( aString.equals( STRING_NONE ) )
- {
- iIdentType = E_NONE;
- }
- else
- {
- iIdentType = E_NOT_SET;
- }
- iValueType = new Short( aValueType );
- }
-
- /**
- * Externalize the property value to a stream.
- * @param aStream stream to use for externalization
- * @throws IOException if writing to a stream fails
- * @throws ODTException if value type can not be resolved
- */
- public void externalize( ODTDataOutputStream aStream )
- throws IOException, ODTException
- {
- // Write property value type - int8
- aStream.writeByte( iValueType.byteValue() );
-
- // Write property value data - real/int16/rgb
- switch( iValueType.intValue() )
- {
- // Real value
- case ValueTypeResolver.E_NUMBER:
- case ValueTypeResolver.E_PERCENTAGE:
- case ValueTypeResolver.E_EMS:
- case ValueTypeResolver.E_EXS:
- case ValueTypeResolver.E_PX:
- case ValueTypeResolver.E_CM:
- case ValueTypeResolver.E_MM:
- case ValueTypeResolver.E_IN:
- case ValueTypeResolver.E_PT:
- case ValueTypeResolver.E_PC:
- case ValueTypeResolver.E_DEG:
- case ValueTypeResolver.E_RAD:
- case ValueTypeResolver.E_GRAD:
- case ValueTypeResolver.E_MS:
- case ValueTypeResolver.E_S:
- case ValueTypeResolver.E_HZ:
- case ValueTypeResolver.E_KHZ:
- case ValueTypeResolver.E_UNIT_VALUE:
- aStream.writeTReal64( iRealValue );
- break;
-
- // String value and ident type
- case ValueTypeResolver.E_STRING:
- case ValueTypeResolver.E_IDENT:
- case ValueTypeResolver.E_URI:
- case ValueTypeResolver.E_ATTR:
- case ValueTypeResolver.E_UNKNOWN:
- aStream.writeInt16( iStringRef );
- aStream.writeByte( iIdentType );
- break;
-
- // Rgb value
- case ValueTypeResolver.E_RGB_COLOR:
- aStream.writeByte( iRgbValue.getRed() );
- aStream.writeByte( iRgbValue.getGreen() );
- aStream.writeByte( iRgbValue.getBlue() );
- break;
- default:
- throw new ODTException( "Property value can not be resolved: "
- + iValueType );
- }
-
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/PropertyValueList.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
-* 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: Property value list for style property values.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public class PropertyValueList
- {
-
- // CONSTANTS
- private static int PROPERTY_VALUE_LIST_TYPE = 3;
-
- // Property item list
- private Vector iList;
-
- // Reference to the String Pool
- private StringPool iStringPool;
-
- /**
- * Constructor.
- */
- public PropertyValueList( StringPool aStringPool )
- {
- iStringPool = aStringPool;
- iList = new Vector();
- }
-
- /**
- * Create a new item and add it to the list.
- * @param aItem The new item
- */
- public PropertyValue newItem()
- {
- PropertyValue propVal = new PropertyValue( iStringPool );
- iList.add( propVal );
- return propVal;
- }
-
- /**
- * Remove an item from the list.
- * @param aItem Item to remove
- * @return true if the item was removed, otherwise false is returned
- */
- public boolean removeItem( PropertyValue aItem )
- {
- return iList.remove( aItem );
- }
-
- /**
- * Externalize the list to the stream.
- * @param aStream Target stream
- * @throws IOException if writing to a stream fails
- * @throws ODTException if writing to a stream fails
- */
- public void externalize( ODTDataOutputStream aStream )
- throws ODTException, IOException
- {
- // Write list type - int8
- aStream.writeByte( PROPERTY_VALUE_LIST_TYPE );
-
- // Write item count - int32
- aStream.writeInt32( iList.size() );
-
- Enumeration elements = iList.elements();
-
- // Write all property values
- while( elements.hasMoreElements() )
- {
- PropertyValue propVal = ( PropertyValue ) elements.nextElement();
- propVal.externalize( aStream );
- }
- }
-
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/StringPool.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
-* 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: String pool for DOM Externalizer.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Vector;
-
-/**
- * String pool is a set of strings where a string is only listed once.
- */
-public class StringPool
- {
-
- // The pool for storing the strings
- private Vector iStringPool;
-
- /**
- * Constructor.
- */
- public StringPool()
- {
- iStringPool = new Vector();
- }
-
- /**
- * Add a string to the pool. Each string is added only once.
- * @param aString String to add
- * @return Index in the pool
- */
- public int addString( String aString )
- {
- if( aString == null )
- {
- aString = "";
- }
- if( !iStringPool.contains( aString ) )
- {
- iStringPool.addElement( aString );
- }
- return iStringPool.lastIndexOf( aString );
- }
-
- /**
- * Get a string from the pool.
- * @param aIndex Index number of the string
- * @return The requested string
- */
- public String getString( int aIndex )
- {
- return ( String ) iStringPool.elementAt( aIndex );
- }
-
-
- /**
- * Get string pool contents in a byte array.
- * @return String pool contents in a byte array
- * @throws IOException if writing to a stream fails
- * @throws ODTException if writing to a stream fails
- */
- public byte[] toByteArray() throws IOException, ODTException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ODTDataOutputStream dos = new ODTDataOutputStream( baos );
- int count = iStringPool.size();
- byte[] result = null;
-
- try
- {
- // Write string count and each string to the stream
- dos.writeInt16( count );
- for( int i = 0; i < count; i++ )
- {
- String string = ( String ) iStringPool.elementAt( i );
- dos.writeInt16( string.length() );
- dos.writeString8( string );
- }
-
- result = baos.toByteArray();
- }
- finally
- {
- if( dos != null )
- {
- dos.close();
- }
- if( baos != null )
- {
- baos.close();
- }
- }
-
- return result;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ThemeStatusResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
-* 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: Theme status flag-definition resolver
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.util.Hashtable;
-
-/**
- * Resolver for theme status flag-definition.
- * Theme status flag-definitions are taken from Xuikon XnThemeManagement.h
- */
-public class ThemeStatusResolver
- {
- // Theme status flag-definitions. Theme status flags are bit-masked.
-
- // Theme has no specific status. This is a common case.
- // 0b0000000000000000
- public static final int E_XN_THEME_STATUS_NONE = 0x0000;
-
- // EXnThemeStatusLicenceeDefault.
- // This theme is licencee default. It is located on ROM (Z-drive)
- // 0b0000000000000010
- public static final int E_XN_THEME_STATUS_LICENCEE_DEFAULT = 0x0002;
-
- // EXnThemeStatusOperatorDefault. This theme is set as operator default.
- // 0b0000000000000100
- public static final int E_XN_THEME_STATUS_OPERATOR_DEFAULT = 0x0004;
-
- // EXnThemeStatusUserDefault. This theme has set as user default.
- // 0b0000000000001000
- public static final int E_XN_THEME_STATUS_USER_DEFAULT = 0x0008;
-
- // EXnThemeStatusMakeActive. Activates the theme after installation.
- // 0b0000000000010000
- public static final int E_XN_THEME_STATUS_MAKE_ACTIVE = 0x0010;
-
- // EXnThemeStatusLicenceeRestorable. This theme is restored when licensee
- // default theme is restored. When using this flag, the
- // ThemeStatusLicenceeDefault-flag is also automatically activated.
- // It is located on ROM (Z-drive)
- // 0b00000000001000000
- public static final int E_XN_THEME_STATUS_LICENCEE_RESTORABLE = 0x0040;
-
- // EXnThemeStatusLocked.
- // 0b00000000010000000
- public static final int E_XN_THEME_STATUS_LOCKED = 0x0080;
-
- // Theme status keys
- public static final String THEME_STATUS_NONE = "ThemeStatusNone";
- public static final String THEME_STATUS_LOCKED = "ThemeStatusLocked";
- public static final String THEME_STATUS_MAKE_ACTIVE = "ThemeStatusMakeActive";
- public static final String THEME_STATUS_LICENCEE_DEFAULT = "ThemeStatusLicenceeDefault";
- public static final String THEME_STATUS_LICENCEE_RESTORABLE = "ThemeStatusLicenceeRestorable";
- public static final String THEME_STATUS_OPERATOR_DEFAULT = "ThemeStatusOperatorDefault";
- public static final String THEME_STATUS_USER_DEFAULT = "ThemeStatusUserDefault";
-
- private static Hashtable iThemeStatusResolver;
- static
- {
- iThemeStatusResolver = new Hashtable();
-
- iThemeStatusResolver.put( THEME_STATUS_NONE, new Integer(
- E_XN_THEME_STATUS_NONE ) );
- iThemeStatusResolver.put( THEME_STATUS_LICENCEE_DEFAULT, new Integer(
- E_XN_THEME_STATUS_LICENCEE_DEFAULT ) );
- iThemeStatusResolver.put( THEME_STATUS_OPERATOR_DEFAULT, new Integer(
- E_XN_THEME_STATUS_OPERATOR_DEFAULT ) );
- iThemeStatusResolver.put( THEME_STATUS_USER_DEFAULT, new Integer(
- E_XN_THEME_STATUS_USER_DEFAULT ) );
- iThemeStatusResolver.put( THEME_STATUS_MAKE_ACTIVE, new Integer(
- E_XN_THEME_STATUS_MAKE_ACTIVE ) );
- iThemeStatusResolver.put( THEME_STATUS_LICENCEE_RESTORABLE,
- new Integer( E_XN_THEME_STATUS_LICENCEE_RESTORABLE ) );
- iThemeStatusResolver.put( THEME_STATUS_LOCKED, new Integer(
- E_XN_THEME_STATUS_LOCKED ) );
- }
-
- private ThemeStatusResolver()
- {
- }
-
- /**
- * Gets the flag definition of the theme status.
- *
- * @param aKey theme status
- *
- * @return the The flag definition of the theme status
- * @throws IllegalArgumentException if the key is not mapped to any
- * value in iThemeStatusResolver
- */
- public static Integer getValue( String aKey ) throws IllegalArgumentException
- {
- if( !iThemeStatusResolver.containsKey( aKey ) )
- {
- throw new IllegalArgumentException( "Invalid theme status" );
- }
-
- return ( Integer ) iThemeStatusResolver.get( aKey );
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/odtconverter/ValueTypeResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
-* 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: Primitive value type resolver for CSS Style properties
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.odtconverter;
-
-import java.util.Hashtable;
-
-import org.w3c.css.sac.LexicalUnit;
-
-/**
- * Resolves primitive value types by keys.
- * Property types that are taken into account are
- * from Symbian side: ...\epoc32\include\middleware\xndompropertyvalue.h
- */
-public class ValueTypeResolver
- {
-
- // CONSTANTS
- // Primitive Value Types
- public static final short E_UNKNOWN = 0;
- public static final short E_NUMBER = 1;
- public static final short E_PERCENTAGE = 2;
- public static final short E_EMS = 3;
- public static final short E_EXS = 4;
- public static final short E_PX = 5;
- public static final short E_CM = 6;
- public static final short E_MM = 7;
- public static final short E_IN = 8;
- public static final short E_PT = 9;
- public static final short E_PC = 10;
- public static final short E_DEG = 11;
- public static final short E_RAD = 12;
- public static final short E_GRAD = 13;
- public static final short E_MS = 14;
- public static final short E_S = 15;
- public static final short E_HZ = 16;
- public static final short E_KHZ = 17;
- public static final short E_STRING = 19;
- public static final short E_URI = 20;
- public static final short E_IDENT = 21;
- public static final short E_ATTR = 22;
- public static final short E_RGB_COLOR = 25;
- public static final short E_RGBA_COLOR = 26;
- public static final short E_UNIT_VALUE = 28;
-
- // Ident Types
- public static final short E_NOT_SET = 0;
- public static final short E_AUTO = 1;
- public static final short E_NONE = 2;
- public static final short E_INHERIT = 3;
-
- private Hashtable iValueTypeResolver;
-
- /**
- * Instantiates a new value type resolver.
- */
- public ValueTypeResolver()
- {
- iValueTypeResolver = new Hashtable();
-
- //Real Value Types
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_INTEGER ), new Short( E_NUMBER ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_REAL ), new Short( E_NUMBER ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_PERCENTAGE ), new Short( E_PERCENTAGE ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_EM ), new Short( E_EMS ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_EX ), new Short( E_EXS ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_PIXEL ), new Short( E_PX ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_CENTIMETER ), new Short( E_CM ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_MILLIMETER ), new Short( E_MM ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_INCH ), new Short( E_IN ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_POINT ), new Short( E_PT ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_PICA ), new Short( E_PC ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_DEGREE ), new Short( E_DEG ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_RADIAN ), new Short( E_RAD ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_GRADIAN ), new Short( E_GRAD ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_MILLISECOND ), new Short( E_MS ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_SECOND ), new Short( E_S ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_HERTZ ), new Short( E_HZ ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_KILOHERTZ ), new Short( E_KHZ ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_DIMENSION ), new Short( E_UNIT_VALUE ));
-
- //String Value Types
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_STRING_VALUE ), new Short( E_STRING ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_IDENT ), new Short( E_IDENT ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_URI ), new Short( E_URI ));
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_ATTR ), new Short( E_ATTR ));
-
- //Color value Types
- iValueTypeResolver.put( new Short( LexicalUnit.SAC_RGBCOLOR ), new Short( E_RGB_COLOR ));
-
- }
-
- /**
- * Gets the value of the Symbian specific code for value type.
- *
- * @param aKey The key for Lexical Unit
- *
- * @return the The value of the Symbian specific code
- */
- public Short getValue( Short aKey )
- {
- if ( iValueTypeResolver.containsKey( aKey ) )
- {
- return ( Short ) iValueTypeResolver.get( aKey );
- }
- else
- throw new IllegalStateException(
- "Invalid value type while resolving CSS : " + aKey );
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/ui/ThemeInstaller.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/*
-* 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: Standalone UI
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.ui;
-
-import java.io.File;
-import java.io.IOException;
-import com.nokia.tools.themeinstaller.installationmanager.IInstallationListener;
-import com.nokia.tools.themeinstaller.installationmanager.InstallationManager;
-import com.nokia.tools.themeinstaller.installationmanager.InstallationParameters;
-import com.nokia.tools.themeinstaller.installationmanager.Lock;
-import com.nokia.tools.themeinstaller.installationmanager.ProgressEvent;
-import com.nokia.tools.themeinstaller.logger.LogWriter;
-
-public class ThemeInstaller
- {
-
- // CONSTANTS
- // Error message prefix
- private final static String ERROR_PREFIX = "*** ERROR: ";
-
- // Usage instructions
- private final static String USAGE =
- "\nUSAGE: ThemeInstaller manifest_file [destination_dir] [-option_1] [-option_n]\n" +
- "\nOptions:" +
- "\n -loc:<loc_settings_filename.xml> Enable localisation enhancements" +
- "\n -prop:<properties_filename.prop> Use external properties file instead of the default one" +
- "\n -log:<path> Path for log file" +
- "\n -log If no path given, the log is printed to console\n";
- //"\n -fixDTD Use if tool should attempt to fix errors in dtd\n";
-
-
- // Command line options
- private final static String OPTION_PREFIX = "-";
- private final static String LOC_OPTION = "loc:";
- private final static String PROP_OPTION = "prop:";
- private final static String LOG_PATH_OPTION = "log:";
- private final static String LOG_PATH_OPTION_NO_PATH = "log";
- private final static String FIX_INVALID_DTD_PARAMS = "fixDTD";
-
- // Lock object for waiting the install to complete
- private Lock iLock;
-
- // Manifest file
- protected String iManifest;
-
- // Destination directory
- protected String iDestination;
-
- // Localisation settings file
- protected String iLocSettings;
-
- // External properties file
- protected String iPropertiesFile;
-
- // Logging directory
- protected String iLogDir;
-
- /**
- * Application entry point
- * @param aArgs application arguments
- */
- public static void main( String[] aArgs )
- {
- ThemeInstaller instance = new ThemeInstaller();
- instance.install( aArgs );
- }
-
- /**
- * Constructor.
- */
- protected ThemeInstaller()
- {
- iLock = new Lock();
- }
-
- /**
- * Starts the installation process. Parses the arguments before
- * staring the installation.
- * @param aArgs Application arguments
- */
- protected void install( String[] aArgs )
- {
- try
- {
- parseArgs( aArgs );
- }
- catch( IllegalArgumentException iae )
- {
- //System.out.println( ERROR_PREFIX + iae.getMessage() );
- System.out.println("ThemeInstaller version 2.0.0");
- System.out.println("Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved");
- System.out.println("");
- System.out.println( USAGE );
- return;
- }
- catch ( IOException e )
- {
- System.out.println( ERROR_PREFIX + e.getMessage() );
- }
-
- try
- {
- doInstall();
- }
- catch ( Exception e )
- {
- String error = ERROR_PREFIX + "Installation failed: "
- + e.getMessage();
- if ( !LogWriter.getInstance().inConsoleMode() )
- {
- System.out.println( error );
- }
- LogWriter.getInstance().logSevere( error );
- }
- finally
- {
- LogWriter.closeInstance();
- }
- }
-
- /**
- * Execute the installation
- * @param aManifest theme manifest file name
- * @param aDestination destination directory
- * @throws Exception if installation fails
- */
- protected void doInstall() throws Exception
- {
- InstallationParameters params = new InstallationParameters(
- new File( iManifest ), new File( iDestination ) );
-
- LogWriter.getInstance().logInfo( "Starting Installer" );
- LogWriter.getInstance().logInfo( "Manifest file : " + iManifest );
- LogWriter.getInstance().logInfo( "Destination directory : " + iDestination );
-
- if( iLocSettings != null )
- {
- params.setLocSettings( new File( iLocSettings ) );
- LogWriter.getInstance().logInfo( "Settings file : " + params.getLocSettings().getPath() );
- }
- if( iPropertiesFile != null )
- {
- params.setPropFile( new File ( iPropertiesFile ) );
- LogWriter.getInstance().logInfo( "Properties file : " + params.getPropFile().getPath() );
- }
-
- IInstallationListener listener = new IInstallationListener()
- {
- public void installationCompleted( ProgressEvent aEvent )
- {
- if( aEvent.getError() == IInstallationListener.NO_ERROR )
- {
- if ( !LogWriter.getInstance().inConsoleMode() )
- {
- System.out.println( "Installation done." );
- }
- LogWriter.getInstance().logInfo( "Installation done" );
- }
- else
- {
- String error = ERROR_PREFIX
- + "Installation failed, error: "
- + aEvent.getError() + ", "
- + aEvent.getMessage();
- if ( !LogWriter.getInstance().inConsoleMode() )
- {
- System.out.println( error );
- }
- LogWriter.getInstance().logSevere( error );
- }
-
- // release lock
- iLock.unLock();
- }
-
- public void installationProgress( ProgressEvent aEvent )
- {
- if( aEvent.getState() == IInstallationListener.STATE_PARSED )
- {
- String message = "Resource files parsing done,";
- if( aEvent.getError() != IInstallationListener.NO_ERROR ) {
- message += " error: " + aEvent.getError() + ",";
- }
- message += " theme: "
- + aEvent.getName() + ", language: "
- + aEvent.getLanguage();
-
-
- if ( !LogWriter.getInstance().inConsoleMode() )
- {
- System.out.println( message );
- }
- LogWriter.getInstance().logInfo( message );
- }
- else if ( aEvent.getState() == IInstallationListener.STATE_WRITED )
- {
- String message = "Installed ODT: "
- + aEvent.getFileName();
- if ( !LogWriter.getInstance().inConsoleMode() )
- {
- System.out.println( message );
- }
- LogWriter.getInstance().logInfo( message );
- }
- }
- };
-
- InstallationManager i = new InstallationManager( params, listener );
- i.startInstallation();
-
- // wait for finalization
- iLock.lock();
- }
-
- /**
- * Parse command line arguments.
- * @param aArgs Command line arguments
- * @throws IllegalArgumentException if mandatory command line parameters
- * are not defined
- * @throws IOException Signals that an I/O exception has occurred.
- */
- protected void parseArgs( String[] aArgs ) throws IllegalArgumentException,
- IOException
- {
- // Print usage information if mandatory arguments were not specified
- if( aArgs.length == 0 )
- {
- throw new IllegalArgumentException( "No command line arguments" );
- }
-
- // Resolve manifest file name and destination directory
- iManifest = aArgs[ 0 ];
- if( aArgs.length > 1 &&
- !aArgs[ 1 ].startsWith( OPTION_PREFIX ) )
- {
- iDestination = aArgs[ 1 ];
- }
- else
- {
- // If no destination directory is specified, use the current dir
- iDestination = System.getProperty( "user.dir" );
- }
-
- // Parse the options
- for( int i = 1; i < aArgs.length; i++ )
- {
- //fix DTD
- String opt = OPTION_PREFIX + FIX_INVALID_DTD_PARAMS;
- if ( aArgs[ i ].toLowerCase().startsWith( opt.toLowerCase() )) {
- InstallationManager.setFixDTD(true);
- }
-
- // Localisation settings
- opt = OPTION_PREFIX + LOC_OPTION;
- if( aArgs[ i ].startsWith( opt ) )
- {
- iLocSettings = aArgs[ i ].substring( opt.length() );
- if( iLocSettings.length() == 0 )
- {
- throw new IllegalArgumentException( "No localisation settings file defined with the option" );
- }
- }
- // External properties file
- opt = OPTION_PREFIX + PROP_OPTION;
- if( aArgs[ i ].startsWith( opt ) )
- {
- iPropertiesFile = aArgs[ i ].substring( opt.length() );
- if( iPropertiesFile.length() == 0 )
- {
- throw new IllegalArgumentException( "No external properties file name defined with the option" );
- }
- }
- // Logging without path (option "-log")
- opt = OPTION_PREFIX + LOG_PATH_OPTION_NO_PATH;
- if ( aArgs[ i ].equals( opt ) )
- {
- // No logging file defined
- LogWriter.initialize( null );
- }
- // Logging with path or with option "-log:"
- opt = OPTION_PREFIX + LOG_PATH_OPTION;
- if ( aArgs[ i ].startsWith( opt ) )
- {
- iLogDir = aArgs[ i ].substring( opt.length() );
- if ( iLogDir.length() == 0 )
- {
- // No logging file defined
- LogWriter.initialize( null );
- }
- else
- {
- LogWriter.initialize( new File( iLogDir ) );
- }
- }
- }
- }
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/xmlparser/DTDEntityResolver.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
-* 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: Entity Resolver for using external DTD files in XML parsing.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.xmlparser;
-
-import java.io.IOException;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * DTD Entity Resolver is for using external DTD files in XML parsing.
- * The resolveEntity method returns null if the provided system id does
- * not end with the ".dtd".
- */
-public class DTDEntityResolver implements EntityResolver
- {
-
- // CONSTANTS
- // DTD file extension
- private static final String DTD_FILE_EXT = ".dtd";
-
- // File name of the external DTD
- private String iFileName;
-
- /**
- * Constructor.
- * @param aFileName file name of the DTD file
- */
- public DTDEntityResolver( String aFileName )
- {
- iFileName = aFileName;
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity( String aPublicId, String aSystemId )
- throws SAXException, IOException
- {
- DTDInputSource is = null;
-
- // For DTD files, provide input source containing the external DTD for
- // the XML parser
- if( aSystemId.endsWith( DTD_FILE_EXT ) )
- {
- is = new DTDInputSource( iFileName );
- }
-
- return is;
- }
-
- }
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/xmlparser/DTDInputSource.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
-* 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: File Reader for DTD Files. Filters out UTF-8 and 16 byte order
- * marks.
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.xmlparser;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Arrays;
-
-import org.xml.sax.InputSource;
-
-import com.nokia.tools.themeinstaller.installationmanager.InstallationManager;
-
-/**
- * File Reader for DTD Files. Filters out UTF-8 and 16 byte order marks. Byte
- * order marks need to be filtered because FileReader can not tolerate BOMs.
- */
-public class DTDInputSource extends InputSource {
-
- // CONSTANTS
- private final static int BUFFER_LENGTH = 3;
- private final static byte[] BOM_UTF8 = { (byte) 0xEF, (byte) 0xBB,
- (byte) 0xBF };
- private final static byte[] BOM_UTF16_BIG = { (byte) 0xFE, (byte) 0xFF };
- private final static byte[] BOM_UTF16_LIT = { (byte) 0xFF, (byte) 0xFE };
-
- // DTD File name
- private String iFileName;
-
- /**
- * Constructor.
- *
- * @param aFileName
- * DTD file name
- * @throws FileNotFoundException
- * if the file can not be found
- */
- public DTDInputSource(String aFileName) throws FileNotFoundException {
- super( new FileReader( aFileName ) );
- try {
- preprocess(aFileName);
- } catch (IOException e) {
- e.printStackTrace();
- }
- iFileName = aFileName;
- }
-
- /**
- * XML-DTD files should not contain invalid entity references. For example,
- * %N; is valid while %N is not. This method will validate and correct such
- * instances. Note: This was introduced because of a defect found in loc to
- * dtd converter tool. Once loc-dtd tool works fine, this step will not be
- * required.
- *
- * @param fileName
- * the dtd file that needs correction.
- * @throws IOException
- */
- private void preprocess(String fileName) throws IOException {
-
-
- /**
- * We won't use this parameter as of now. If required, use
- * boolean fixDTD = InstallationManager.isFixDTD();
- * We may remove this if we find no use in future.
- */
- boolean fixDTD = true;
- if (!fixDTD) {
- this.setCharacterStream(new FileReader(fileName));
- return;
- }
- long fileLen = (new File(fileName)).length();
- byte[] fileContents = new byte[(int) fileLen];
- FileInputStream fis = new FileInputStream(fileName);
- fis.read(fileContents);
- fis.close();
-
- String fileContentsString = new String(fileContents);
- fileContentsString = fileContentsString.replace("(%N)", "(%N;)");
- fileContentsString = fileContentsString.replace("(%U)", " (%U;)");
- fileContentsString = fileContentsString.replace("%0U;", "%U;");
- fileContentsString = fileContentsString.replace("%U(", "%U;(");
- fileContentsString = fileContentsString.replace("%0U(", "%U;(");
- fileContentsString = fileContentsString.replace("%U%N;", "%U;%N;");
- fileContentsString = fileContentsString.replace("%U%N", "%U;%N;");
-
- setByteStream(new ByteArrayInputStream(fileContentsString.getBytes()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.InputSource#getCharacterStream()
- */
- public Reader getCharacterStream() {
- // Get the reader from the base class
- Reader reader = super.getCharacterStream();
-
- // Read the beginning of the file to get the BOM
- byte[] buffer = new byte[BUFFER_LENGTH];
- try {
- // Read 3 bytes
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = (byte) reader.read();
- }
-
- int skip = 0;
-
- // UTF-8 byte order mark (length 3 bytes)
- if (Arrays.equals(BOM_UTF8, buffer)) {
- skip = BOM_UTF8.length;
- }
- // UTF-16 byte order mark (length 2 bytes)
- else {
- byte[] compareBuffer = new byte[BOM_UTF16_BIG.length];
- System.arraycopy(buffer, 0, compareBuffer, 0,
- compareBuffer.length);
-
- // Big and little endian
- if (Arrays.equals(BOM_UTF16_BIG, compareBuffer)
- || Arrays.equals(BOM_UTF16_LIT, compareBuffer)) {
- skip = BOM_UTF16_BIG.length;
- }
- }
-
- // Reset not supported, a new reader must be created
- FileReader fr = new FileReader(iFileName);
- fr.skip(skip);
-
- // Close the old reader
- reader.close();
-
- // Set the new reader back to the super class
- super.setCharacterStream(fr);
- } catch (Exception e) {
- // Ignore errors, original (unfiltered) stream will be returned
- }
-
- return super.getCharacterStream();
- }
-
-}
--- a/themeinstaller/source/src/com/nokia/tools/themeinstaller/xmlparser/XMLParser.java Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
-* 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: Parses XML file to DOM Document
- *
-*/
-
-
-package com.nokia.tools.themeinstaller.xmlparser;
-
-import java.io.IOException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import com.nokia.tools.themeinstaller.logger.LogWriter;
-import com.nokia.tools.themeinstaller.odtconverter.IParseOperationListener;
-import com.nokia.tools.themeinstaller.odtconverter.ParseOperation;
-
-/**
- * Parses XML File to DOM Document.
- */
-public class XMLParser extends ParseOperation implements Runnable
- {
-
- // CONSTANTS
- // Document Builder Factory and Parser configuration
- private static final String DBF_KEY =
- "javax.xml.parsers.DocumentBuilderFactory";
- private static final String DBF_VALUE =
- "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
- private static final String PARSER_CONFIG_KEY =
- "org.apache.xerces.xni.parser.XMLParserConfiguration";
- private static final String PARSER_CONFIG_VALUE =
- "org.apache.xerces.parsers.XIncludeAwareParserConfiguration";
-
- /** The Document Builder. */
- private DocumentBuilder iDocumentBuilder;
-
- /** XML file name */
- private String iFileName;
-
- /**
- * Static block.
- */
- static
- {
- // Configure the Document Builder Factory
- System.setProperty( DBF_KEY, DBF_VALUE );
-
- // Configure the XML Parser Configuration
- System.setProperty( PARSER_CONFIG_KEY, PARSER_CONFIG_VALUE );
- }
-
- /**
- * Instantiates a new XML parser without an external DTD file.
- *
- * @param aFileName the XML file name
- */
- public XMLParser( String aFileName )
- {
- this( aFileName, null );
- }
-
- /**
- * Instantiates a new XML parser. External DTD file can be used instead of
- * the one defined in the DOCTYPE.
- *
- * @param aFileName the XML file name
- * @param aExtDTD the DTD file name. If an external DTD is not specified,
- * Expand Entity References feature is disabled. This causes the
- * localisation to be left untouched.
- */
- public XMLParser( String aFileName, String aExtDTD )
- {
- super();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware( true );
-
- try
- {
- if( aExtDTD == null )
- {
- // Disable expanding of entity references to leave localisation
- // untouched
- dbf.setExpandEntityReferences( false );
-
- // Disable the loading of external DTD file because expanding
- // entity references (the localisation) is disabled anyway
- dbf.setFeature(
- "http://apache.org/xml/features/nonvalidating/load-external-dtd",
- false );
- }
-
- // Enable XIncludes in XML parsing
- dbf.setXIncludeAware( true );
-
- // Disable the adding of XInclude parsing related attributes:
- // xml:base and xml:lang
- dbf.setFeature(
- "http://apache.org/xml/features/xinclude/fixup-base-uris",
- false );
- dbf.setFeature(
- "http://apache.org/xml/features/xinclude/fixup-language",
- false );
-
- // Instantiate the Document Builder for parsing
- iDocumentBuilder = dbf.newDocumentBuilder();
-
- if( aExtDTD != null )
- {
- // Use entity resolver for using an external DTD file
- iDocumentBuilder.setEntityResolver(
- new DTDEntityResolver( aExtDTD ) );
- }
- }
- catch ( ParserConfigurationException e )
- {
- throw new IllegalStateException( "Could not load XML parser: " + e.toString() );
- }
-
- iFileName = aFileName;
- }
-
- /**
- * Run the XML parse operation.
- */
- public void run()
- {
- // Messages for operation listener
- int error = IParseOperationListener.OPERATION_SUCCESSFUL;
- String reason = null;
- try
- {
- // Actual parsing
- LogWriter.getInstance().logInfo(
- this.getClass().getSimpleName() + ": Parsing " + iFileName );
- iDOMDocument = iDocumentBuilder.parse( iFileName );
- }
- catch ( SAXException e )
- {
- reason = e.getMessage();
- error = IParseOperationListener.SAX_PARSE_ERROR;
- }
- catch ( IOException e )
- {
- reason = e.getMessage();
- error = IParseOperationListener.IO_ERROR;
- }
-
- super.operationCompleted( error, reason );
- }
-
- /**
- * Starts XML parsing in a new thread.
- */
- public void parse()
- {
- Thread thread = new Thread( this );
- thread.start();
- }
- }
--- a/widgettools/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/*
-* 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"
Binary file widgettools/hspluginspreinstaller/bin/hspluginpreinstaller_v_2_0.zip has changed
--- a/widgettools/hspluginspreinstaller/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-/*
-* 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
-
Binary file widgettools/wrtwidgetpreinstaller/bin/widgetpreinstaller.zip has changed
Binary file widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.confml has changed
--- a/widgettools/wrtwidgetpreinstaller/conf/availablewrtwidgets.gcfml Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<file xmlns="http://www.s60.com/xml/genconfml/1" name="widget_config.ini" target="epoc32\tools\rom\">
- <setting ref="WrtWidgetsC/WrtWidgetC"/>
- <setting ref="WrtWidgetsC/DriveC"/>
- <setting ref="WrtWidgetsC/CommandsExtension"/>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict">
- <xsl:output method="text" encoding="UTF-16"/>
- <xsl:template match="configuration/data">
- <xsl:value-of select="WrtWidgetsC/DriveC"/><xsl:text>
</xsl:text>
- <xsl:for-each select="WrtWidgetsC/WrtWidgetC">
- <xsl:if test="PreInstalled = 1">
- <xsl:value-of select="path" /><xsl:text> </xsl:text><xsl:value-of select="homescreen"/> <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
- <xsl:text>
</xsl:text>[run-commands]<xsl:text>
</xsl:text>
- <xsl:for-each select="WrtWidgetsC/CommandsExtension">
- <xsl:value-of select="CommandExt" /><xsl:text>
</xsl:text>
- </xsl:for-each>
- </xsl:template>
- </xsl:stylesheet>
-</file>
--- a/widgettools/wrtwidgetpreinstaller/group/bld.inf Tue Jan 26 13:19:36 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
-* 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)