os/security/cryptoservices/certificateandkeymgmt/twtlscert/scripts/batchfiles/certstorePlugins
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/twtlscert/scripts/batchfiles/certstorePlugins Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,225 @@
1.4 +#!/usr/bin/perl -w
1.5 +
1.6 +# pluginScript.pl
1.7 +#
1.8 +# Controls the availability of cert store plugins on the emulator, for testing
1.9 +# purposes.
1.10 +
1.11 +$UsageMessage = <<"EOF";
1.12 +usage:
1.13 + pluginScript disable PLUGIN
1.14 + Disable the specified plugin by moving it to a backup location
1.15 + pluginScript disable_all
1.16 + Disable all plugins
1.17 + pluginScript enable PLUGIN
1.18 + Enable the specified plugin by copying the backup to its original location
1.19 + pluginScript list PLATFORM BUILD
1.20 + List the currently enabled plugins for the specified platform and build
1.21 + (default is winscw udeb)
1.22 +EOF
1.23 +
1.24 +@plugins = ('filecertstore.dll',
1.25 + 'tadditionalstores.dll',
1.26 + 'tadditionalstoressoftware.dll',
1.27 + 'wapcertstore.dll',
1.28 + 'swicertstoreplugin.dll',
1.29 + 'thwsimstores.dll',
1.30 + 'thwuiccstores.dll',
1.31 + 'thwwimstores.dll',
1.32 + 'tDeviceImmutablestores.dll',
1.33 + 'MIDP2CertStore.dll');
1.34 +
1.35 +@platforms = ('wins', 'winscw');
1.36 +
1.37 +@builds = ('udeb', 'urel');
1.38 +
1.39 +$EpocRoot = $ENV{'EPOCROOT'} . "epoc32";
1.40 +
1.41 +sub usage()
1.42 +{
1.43 + die $UsageMessage;
1.44 +}
1.45 +
1.46 +sub copyFile($$)
1.47 +{
1.48 + my ($from, $to) = @_;
1.49 + print "Copying $from -> $to\n";
1.50 + die "Can't copy: $!" unless system("cmd", "/c", "copy", $from, $to) == 0;
1.51 +}
1.52 +
1.53 +sub deleteFile($)
1.54 +{
1.55 + my ($file) = @_;
1.56 + print "Deleting $file\n";
1.57 + die "Can't delete '$file': $!" unless unlink $file;
1.58 +}
1.59 +
1.60 +sub ensureDir($)
1.61 +{
1.62 + my ($dir) = @_;
1.63 + if (! -d $dir)
1.64 + {
1.65 + print "Creating $dir\n";
1.66 + die "Can't create dir '$dir': $!" unless mkdir $dir;
1.67 + }
1.68 +}
1.69 +
1.70 +sub isSecure($)
1.71 +{
1.72 + my ($plugin) = @_;
1.73 + $plugin =~ s/\.dll/.rsc/i;
1.74 + return -f "$EpocRoot\\data\\z\\resource\\plugins\\$plugin"
1.75 +}
1.76 +
1.77 +sub pluginDir($$)
1.78 +{
1.79 + my ($plugin, $path) = @_;
1.80 +
1.81 + if (isSecure($plugin))
1.82 + {
1.83 + return "$path";
1.84 + }
1.85 + else
1.86 + {
1.87 + return "$path\\z\\system\\libs\\plugins";
1.88 + }
1.89 +}
1.90 +
1.91 +sub backupDir($$)
1.92 +{
1.93 + my ($plugin, $path) = @_;
1.94 +
1.95 + if (isSecure($plugin))
1.96 + {
1.97 + return "$path\\plugins_backup";
1.98 + }
1.99 + else
1.100 + {
1.101 + return "$path\\z\\system\\libs\\plugins_backup";
1.102 + }
1.103 +}
1.104 +
1.105 +sub disable($)
1.106 +{
1.107 + my ($plugin) = @_;
1.108 +
1.109 + for my $platform (@platforms)
1.110 + {
1.111 + for my $build (@builds)
1.112 + {
1.113 + my $path = "$EpocRoot\\release\\$platform\\$build";
1.114 +
1.115 + my $backupDir = backupDir($plugin, $path);
1.116 + my $pluginDir = pluginDir($plugin, $path);
1.117 + my $pluginFile = "$pluginDir\\$plugin";
1.118 + my $backupFile = "$backupDir\\$plugin";
1.119 +
1.120 + if (-f $pluginFile)
1.121 + {
1.122 + # Always copy, in case plugin has been rebuilt
1.123 + ensureDir($backupDir);
1.124 + copyFile($pluginFile, $backupDir);
1.125 +
1.126 + deleteFile($pluginFile);
1.127 + }
1.128 + }
1.129 + }
1.130 +}
1.131 +
1.132 +sub disableAll()
1.133 +{
1.134 + for my $plugin (@plugins)
1.135 + {
1.136 + disable($plugin)
1.137 + }
1.138 +}
1.139 +
1.140 +sub enable($)
1.141 +{
1.142 + my ($plugin) = @_;
1.143 +
1.144 + for my $platform (@platforms)
1.145 + {
1.146 + for my $build (@builds)
1.147 + {
1.148 + my $path = "$EpocRoot\\release\\$platform\\$build";
1.149 +
1.150 + my $backupDir = backupDir($plugin, $path);
1.151 + my $pluginDir = pluginDir($plugin, $path);
1.152 + my $pluginFile = "$pluginDir\\$plugin";
1.153 + my $backupFile = "$backupDir\\$plugin";
1.154 +
1.155 + if (! -f $pluginFile && -f $backupFile)
1.156 + {
1.157 + copyFile($backupFile, $pluginDir);
1.158 + }
1.159 + }
1.160 + }
1.161 +}
1.162 +
1.163 +sub list($$)
1.164 +{
1.165 + my ($platform, $build) = @_;
1.166 + my $path = "$EpocRoot\\release\\$platform\\$build";
1.167 +
1.168 + printf "%-32s %-12s %s\n", "Plugin:", "Type:", "Status:";
1.169 +
1.170 + for my $plugin (@plugins)
1.171 + {
1.172 + my $secure = isSecure($plugin);
1.173 + my $enabled = 0;
1.174 +
1.175 + if ($secure)
1.176 + {
1.177 + $enabled = -f "$path\\$plugin";
1.178 + }
1.179 + else
1.180 + {
1.181 + $enabled = -f "$path\\z\\system\\libs\\plugins\\$plugin";
1.182 + }
1.183 +
1.184 + my $secureMess = $secure ? 'secure' : 'old-style';
1.185 + my $enabledMess = $enabled ? 'enabled' : 'disabled';
1.186 +
1.187 + printf "%-32s %-12s %s\n", $plugin, $secureMess, $enabledMess;
1.188 + }
1.189 +}
1.190 +
1.191 +sub main(@)
1.192 +{
1.193 + my $action = shift || usage();
1.194 + if ($action eq 'backup_all')
1.195 + {
1.196 + backupAll();
1.197 + }
1.198 + elsif ($action eq 'disable')
1.199 + {
1.200 + my $plugin = shift || usage();
1.201 + usage() unless grep { $_ eq $plugin } @plugins;
1.202 + disable($plugin);
1.203 + }
1.204 + elsif ($action eq 'disable_all')
1.205 + {
1.206 + disableAll();
1.207 + }
1.208 + elsif ($action eq 'enable')
1.209 + {
1.210 + my $plugin = shift || usage();
1.211 + usage() unless grep { $_ eq $plugin } @plugins;
1.212 + enable($plugin);
1.213 + }
1.214 + elsif ($action eq 'list')
1.215 + {
1.216 + my $platform = shift || 'winscw';
1.217 + my $build = shift || 'udeb';
1.218 + usage() unless grep { $_ eq $platform } @platforms;
1.219 + usage() unless grep { $_ eq $build } @builds;
1.220 + list($platform, $build);
1.221 + }
1.222 + else
1.223 + {
1.224 + usage();
1.225 + }
1.226 +}
1.227 +
1.228 +main(@ARGV);