widgettools/wrtwidgetpreinstaller/src/installwidgets.pl
branchRCL_3
changeset 34 60c10715f092
parent 33 04b7640f6fb5
child 36 a3ff8024e841
equal deleted inserted replaced
33:04b7640f6fb5 34:60c10715f092
    19 use File::Spec::Functions;
    19 use File::Spec::Functions;
    20 use Getopt::Long;
    20 use Getopt::Long;
    21 use Pod::Usage;
    21 use Pod::Usage;
    22 
    22 
    23 # Version of the script - just use the date
    23 # Version of the script - just use the date
    24 $main::VERSION = '12-July-2010';
    24 $main::VERSION = '02-August-2010';
    25 
    25 
    26 # New getopt::long provides this - but old version doesn't?
    26 # New getopt::long provides this - but old version doesn't?
    27 sub version
    27 sub version
    28   {
    28   {
    29   print sprintf("$0: $main::VERSION\n$^X: %vd\nos: $^O", $^V);
    29   print sprintf("$0: $main::VERSION\n$^X: %vd\nos: $^O", $^V);
   103 use constant EXTERNAL_UID_LOWER_CWRT => 0x2000DDC0; # Lower UID bound for CWRT widgets installed to removable cards
   103 use constant EXTERNAL_UID_LOWER_CWRT => 0x2000DDC0; # Lower UID bound for CWRT widgets installed to removable cards
   104 use constant WIDGET_UI_UID => 0x10282822;   # UID of the widget app
   104 use constant WIDGET_UI_UID => 0x10282822;   # UID of the widget app
   105 use constant CWRT_WIDGET_UI_UID => 0x200267C0;    # UID of the cwrt widget app
   105 use constant CWRT_WIDGET_UI_UID => 0x200267C0;    # UID of the cwrt widget app
   106 use constant SWIDGET_UI_UID => 0x102829A0;	# UID of the securewidget app
   106 use constant SWIDGET_UI_UID => 0x102829A0;	# UID of the securewidget app
   107 use constant CWRT_WIDGET_UI_NON_NOKIA_UID => 0x200267D6;    # UID of the cwrt widget app
   107 use constant CWRT_WIDGET_UI_NON_NOKIA_UID => 0x200267D6;    # UID of the cwrt widget app
       
   108 use constant JIL_NS => 'http://www.jil.org/ns/widgets1.2';
   108 
   109 
   109 # Folder paths
   110 # Folder paths
   110 use constant DESTINATION => 'private/10003a3f/import/apps/NonNative/Resource';
   111 use constant DESTINATION => 'private/10003a3f/import/apps/NonNative/Resource';
   111 use constant ROM_DEST => 'epoc32/release/winscw/udeb/Z/';
   112 use constant ROM_DEST => 'epoc32/release/winscw/udeb/Z/';
   112 use constant DRIVE_DEST => 'epoc32/winscw/%s';
   113 use constant DRIVE_DEST => 'epoc32/winscw/%s';
   411   print "Installing files for drive $drive\n" if $self->{'args'}->{'verbose'};
   412   print "Installing files for drive $drive\n" if $self->{'args'}->{'verbose'};
   412 
   413 
   413   # Unregister any existing widgets as otherwise when the registry is rewritten their icons will appear in the emulator but they won't work
   414   # Unregister any existing widgets as otherwise when the registry is rewritten their icons will appear in the emulator but they won't work
   414   $self->unregisterWidgets($drive);
   415   $self->unregisterWidgets($drive);
   415 
   416 
   416   print "\n			INSTALLING FILES FOR DRIVE $drive				\n"; 
   417   print "\n     INSTALLING FILES FOR DRIVE $drive       \n";
   417   # Process each widget in turn
   418   # Process each widget in turn
   418   my ( @installedProps );
   419   my ( @installedProps );
   419   my ( @installedCWRTProps );
   420   my ( @installedCWRTProps );
   420   foreach my $filename ( @$fileList )
   421   foreach my $filename ( @$fileList )
   421     {
   422     {
   444     
   445     
   445     my ( $root, $extracted, $size ) = $self->getFiles($tempdir);
   446     my ( $root, $extracted, $size ) = $self->getFiles($tempdir);
   446     die "No files extracted from $filename" if !@$extracted;
   447     die "No files extracted from $filename" if !@$extracted;
   447     
   448     
   448     if ($self->{'operator'}{lc $filename})
   449     if ($self->{'operator'}{lc $filename})
   449 		{
   450     {
   450     	print "\n NON NOKIA WGT \n";
   451       print "\nNON NOKIA WGT \n";
   451     	$non_nokia_widget = 1;
   452       $non_nokia_widget = 1;
   452     }
   453     }
   453     else
   454     else
   454     {
   455     {
   455     	print "\n NOKIA WGT \n";
   456       print "\nNOKIA WGT \n";
   456     	$non_nokia_widget = 0;
   457       $non_nokia_widget = 0;
   457     }
   458     }
   458     
   459     
   459     
   460     
   460     if (($filename =~ /.wgz/ )&& (my $plist = catfile($tempdir, $root, 'Info.plist')))
   461     if (($filename =~ /.wgz/ )&& (my $plist = catfile($tempdir, $root, 'Info.plist')))
   461       {
   462       {
   465           # Parse the XML file into a hash
   466           # Parse the XML file into a hash
   466               $widgetdata = parsePList($plist);
   467               $widgetdata = parsePList($plist);
   467       }
   468       }
   468     elsif (($filename =~ /.wgt/ ) && ( my $confxml = catfile($tempdir, $root, 'config.xml')))
   469     elsif (($filename =~ /.wgt/ ) && ( my $confxml = catfile($tempdir, $root, 'config.xml')))
   469       {
   470       {
   470         print (" W3C widget \n"); 
   471         print ("W3C widget \n");
   471       
   472 
   472           # Parse the XML file into a hash
   473           # Parse the XML file into a hash
   473             $widgetdata = parseConfXml($confxml,$self->{'args'}->{'l10n'});
   474             $widgetdata = parseConfXml($confxml,$self->{'args'}->{'l10n'});
   474             $w3c_widget = 1;
   475             $w3c_widget = 1;
   475       }
   476       }
   476     else
   477     else
   658     
   659     
   659     # Create the MBM file icon - in case of sharedlibrary, create only if NOKIA:widget is true
   660     # Create the MBM file icon - in case of sharedlibrary, create only if NOKIA:widget is true
   660     my $mbm;
   661     my $mbm;
   661     
   662     
   662     print("\nIs shared library - $isSharedLibrary \nIs sharedlib widget - $isSharedWidget \nIs Secure WGZ - $self->{'secure'}{lc $filename}\n");
   663     print("\nIs shared library - $isSharedLibrary \nIs sharedlib widget - $isSharedWidget \nIs Secure WGZ - $self->{'secure'}{lc $filename}\n");
   663     
   664 
   664 		if( ((!$isSharedLibrary) || ($isSharedLibrary && $isSharedWidget)) && (!$self->{'secure'}{lc $filename}))
   665     if( ((!$isSharedLibrary) || ($isSharedLibrary && $isSharedIcon)) && (!$self->{'secure'}{lc $filename}))
   665     {
   666     {
   666     	  print "Creating mbm !!!\n";
   667     	  print "Creating mbm !!!\n";
   667         die "ERROR: Can't find PNG2MBM command in PATH." if !(my $cmd = findCmd('png2mbm.exe'));
   668         die "ERROR: Can't find PNG2MBM command in PATH." if !(my $cmd = findCmd('png2mbm.exe'));
   668         $mbm = $self->regFileName($drive, sprintf("[%08x].mbm", $widgetdata->{'Uid'}));
   669         $mbm = $self->regFileName($drive, sprintf("[%08x].mbm", $widgetdata->{'Uid'}));
   669         print "Generating: $mbm\n";
   670         print "Generating: $mbm\n";
   724     }
   725     }
   725 
   726 
   726     # Copy the MBM file into the widget install directory
   727     # Copy the MBM file into the widget install directory
   727     # because native installation does and uses it after
   728     # because native installation does and uses it after
   728     # installation to manage UID consistency.
   729     # installation to manage UID consistency.
   729     if( (!$isSharedLibrary) || ($isSharedLibrary && $isSharedWidget))
   730     if( (!$isSharedLibrary) || ($isSharedLibrary && $isSharedIcon))
   730     {
   731     {
   731         my $mbmName = sprintf("[%08x].mbm", $widgetdata->{'Uid'});
   732         my $mbmName = sprintf("[%08x].mbm", $widgetdata->{'Uid'});
   732         my $destFile;
   733         my $destFile;
   733         if($w3c_widget)
   734         if($w3c_widget)
   734         {
   735         {
   807   # Generate the registry and IBY file
   808   # Generate the registry and IBY file
   808   $self->addToRomList($drive, $self->makeRegistry($drive, \@installedProps, 0));
   809   $self->addToRomList($drive, $self->makeRegistry($drive, \@installedProps, 0));
   809   $self->addToRomList($drive, $self->makeRegistry($drive, \@installedCWRTProps, 1));
   810   $self->addToRomList($drive, $self->makeRegistry($drive, \@installedCWRTProps, 1));
   810     
   811     
   811 
   812 
   812   print "\n\n %%%%%          WIDGET PRE-INSTALLATION completed for Drive $drive          %%%%% \n\n";
   813   print "\n\n%%%%%          WIDGET PRE-INSTALLATION completed for Drive $drive          %%%%% \n\n";
   813   }
   814   }
   814 
   815 
   815 sub un7zipWidget
   816 sub un7zipWidget
   816   {
   817   {
   817   my ( $self, $filename, $tempdir ) = @_;
   818   my ( $self, $filename, $tempdir ) = @_;
  1338     {
  1339     {
  1339     my ($p, $el, %atts) = @_;
  1340     my ($p, $el, %atts) = @_;
  1340     
  1341     
  1341     if($el eq "widget")
  1342     if($el eq "widget")
  1342         {
  1343         {
       
  1344          my $jilFeature = JIL_NS;
       
  1345          if( lc($atts{"xmlns:JIL"})=~ m/$jilFeature/i || lc($atts{"xmlns:jil"})=~ m/$jilFeature/i)
       
  1346          {
       
  1347            $plisthash->{'WidgetPackagingFormat'} = "jil";
       
  1348          }
  1343          if ( $atts{"id"} )
  1349          if ( $atts{"id"} )
  1344              {
  1350              {
  1345             $plisthash->{'BundleIdentifier'} = $atts{"id"};
  1351             $plisthash->{'BundleIdentifier'} = $atts{"id"};
  1346             $attributeMap = $attributeMap.WIDGET_ID.KEY_VALUE_SEPERATOR.$atts{"id"}.KEY_VALUE_PAIR_SEPERATOR;
  1352             $attributeMap = $attributeMap.WIDGET_ID.KEY_VALUE_SEPERATOR.$atts{"id"}.KEY_VALUE_PAIR_SEPERATOR;
  1347             
  1353             
  1415               if ($atts{"value"})
  1421               if ($atts{"value"})
  1416               {
  1422               {
  1417                   $attributeMap = $attributeMap.$featureParamMap.KEY_ATTR_SEPERATOR."value".KEY_VALUE_SEPERATOR.$atts{"value"}.KEY_VALUE_PAIR_SEPERATOR;
  1423                   $attributeMap = $attributeMap.$featureParamMap.KEY_ATTR_SEPERATOR."value".KEY_VALUE_SEPERATOR.$atts{"value"}.KEY_VALUE_PAIR_SEPERATOR;
  1418               }
  1424               }
  1419           }
  1425           }
  1420        elsif ($el eq "access" || $el eq "jil:access")
  1426        elsif ($el eq "access" || $el eq "jil:access" || $el eq "JIL:access")
  1421           {
  1427           {
  1422               $accessMap = WIDGET_ACCESS . $accessCount;
  1428               $accessMap = WIDGET_ACCESS . $accessCount;
  1423               $attributeMap = $attributeMap.$accessMap.KEY_VALUE_SEPERATOR.KEY_VALUE_PAIR_SEPERATOR;
  1429               $attributeMap = $attributeMap.$accessMap.KEY_VALUE_SEPERATOR.KEY_VALUE_PAIR_SEPERATOR;
  1424            
  1430            
  1425               if ( $atts{"network"} )
  1431               if ( $atts{"network"} )
  1584     my $registry = fixFilename(catfile($self->destLocation($drive), WIDGET_REGISTRY));
  1590     my $registry = fixFilename(catfile($self->destLocation($drive), WIDGET_REGISTRY));
  1585   # If the WRT registry already exists, remove apparc registry info for those widgets
  1591   # If the WRT registry already exists, remove apparc registry info for those widgets
  1586   # This should avoid problems with unregistered widget icons in the emulator?
  1592   # This should avoid problems with unregistered widget icons in the emulator?
  1587     if (-e $registry)
  1593     if (-e $registry)
  1588     {
  1594     {
  1589         print("\n			UNREGISTERING WGZ WIDGETS       \n");
  1595         print("\n     UNREGISTERING WGZ WIDGETS       \n");
  1590         
  1596 
  1591       my $ref = XMLin($registry, 'forcearray' => [ 'entry' ], 'keyattr' => { 'prop' => 'content' } );
  1597       my $ref = XMLin($registry, 'forcearray' => [ 'entry' ], 'keyattr' => { 'prop' => 'content' } );
  1592     foreach my $entry ( @{ $ref->{entry} } )
  1598     foreach my $entry ( @{ $ref->{entry} } )
  1593       {
  1599       {
  1594       my $uid = $entry->{prop}->{Uid}->{val}->{content};
  1600       my $uid = $entry->{prop}->{Uid}->{val}->{content};
  1595 
  1601 
  1611 
  1617 
  1612   # If the CWRT registry already exists, remove apparc registry info for those widgets
  1618   # If the CWRT registry already exists, remove apparc registry info for those widgets
  1613   # This should avoid problems with unregistered widget icons in the emulator?
  1619   # This should avoid problems with unregistered widget icons in the emulator?
  1614   if (-e $registry)
  1620   if (-e $registry)
  1615     {
  1621     {
  1616         print("\n			UNREGISTERING WGT WIDGETS       \n");
  1622         print("\n     UNREGISTERING WGT WIDGETS       \n");
  1617         
  1623 
  1618           my $ref = XMLin($registry, 'forcearray' => [ 'entry' ], 'keyattr' => { 'prop' => 'content' } );
  1624           my $ref = XMLin($registry, 'forcearray' => [ 'entry' ], 'keyattr' => { 'prop' => 'content' } );
  1619         foreach my $entry ( @{ $ref->{entry} } )
  1625         foreach my $entry ( @{ $ref->{entry} } )
  1620       {
  1626       {
  1621           my $uid = $entry->{prop}->{Uid}->{val}->{content};
  1627           my $uid = $entry->{prop}->{Uid}->{val}->{content};
  1622     
  1628     
  1626           my ( $reg, $loc ) = ( catfile($dest, sprintf("%08x_reg.rsc", $uid)), catfile($dest, sprintf("%08x_loc.rsc", $uid)) );
  1632           my ( $reg, $loc ) = ( catfile($dest, sprintf("%08x_reg.rsc", $uid)), catfile($dest, sprintf("%08x_loc.rsc", $uid)) );
  1627           unlink $mbm, $reg, $loc;
  1633           unlink $mbm, $reg, $loc;
  1628        
  1634        
  1629           # We also have to delete the widget directory otherwise it'll be re-registered
  1635           # We also have to delete the widget directory otherwise it'll be re-registered
  1630           my $id = $entry->{prop}->{BundleIdentifier}->{val}->{content};
  1636           my $id = $entry->{prop}->{BundleIdentifier}->{val}->{content};
  1631           print " Unregistering $id ";
  1637           print "Unregistering $id\n";
  1632           my $basepath = $entry->{prop}->{BasePath}->{val}->{content};
  1638           my $basepath = $entry->{prop}->{BasePath}->{val}->{content};
  1633           $w3c_widget = 1;
  1639           $w3c_widget = 1;
  1634           my $sharedLib = "lib";          #BasePath will have lib only if the widget is shared Library
  1640           my $sharedLib = "lib";          #BasePath will have lib only if the widget is shared Library
  1635           
  1641           
  1636           if($basepath =~ m/$sharedLib/)
  1642           if($basepath =~ m/$sharedLib/)
  1643           	$non_nokia_widget = 1;	
  1649           	$non_nokia_widget = 1;	
  1644           }
  1650           }
  1645            #sharedFolderName TBD
  1651            #sharedFolderName TBD
  1646           my $dir = $self->installDir($drive, $id);
  1652           my $dir = $self->installDir($drive, $id);
  1647           rmtree $dir;
  1653           rmtree $dir;
  1648                 
  1654 
  1649           print("BasePath:$basepath \nIs Non-Nokia? $non_nokia_widget		Is SharedLibrary? $isSharedLibrary \nDirectory:$dir \n");
  1655           $dir =~ s/widgets_21D_4C7/data/;
  1650     
       
  1651             $dir =~ s/widgets_21D_4C7/data/;
       
  1652           rmtree $dir;
  1656           rmtree $dir;
  1653         }
  1657         }
  1654     }
  1658     }
  1655     #delete CWRT webapp DB if exists
  1659     #delete CWRT webapp DB if exists
  1656     my $cwrtdbPath = catfile($self->destLocation($drive), CWRT_WEBAPP_REGISTRY);
  1660     my $cwrtdbPath = catfile($self->destLocation($drive), CWRT_WEBAPP_REGISTRY);
  1789     	 print $fh "<prop>$key<val>$data->{$key}<type>$type</type></val></prop>\n" if defined $data->{$key};
  1793     	 print $fh "<prop>$key<val>$data->{$key}<type>$type</type></val></prop>\n" if defined $data->{$key};
  1790     	}
  1794     	}
  1791     }
  1795     }
  1792     }
  1796     }
  1793   print $fh "</entry>\n";
  1797   print $fh "</entry>\n";
  1794   print "\n Is a w3c widget? -- $w3c\n";
       
  1795   if( $w3c )
  1798   if( $w3c )
  1796     {
  1799     {
  1797   my $dbPath = fixFilename(catfile($self->destLocation('C'), CWRT_WEBAPP_REGISTRY));
  1800   my $dbPath = fixFilename(catfile($self->destLocation('C'), CWRT_WEBAPP_REGISTRY));
  1798     mkpath dirname($dbPath);
  1801     mkpath dirname($dbPath);
  1799     die "ERROR: Can't find CWRTWebAppRegistry.exe in PATH" if !(my $cmd = findCmd('CWRTWebAppRegistry.exe'));
  1802     die "ERROR: Can't find CWRTWebAppRegistry.exe in PATH" if !(my $cmd = findCmd('CWRTWebAppRegistry.exe'));
  1800     my $regCmd;
  1803     my $regCmd;
  1801     
  1804     
  1802     if($encodeddata->{'AttributeList'})
  1805     if($encodeddata->{'AttributeList'})
  1803     {
  1806     {
  1804         print "\n AttributeList argument sent to DB\n";
  1807         print "\nAttributeList argument sent to DB\n";
  1805         $regCmd = "$cmd $dbPath $encodeddata->{'BundleIdentifier'} $encodeddata->{'Uid'} $encodeddata->{'BundleDisplayName'} $encodeddata->{'BasePath'} $encodeddata->{'DBIconPath'} $encodeddata->{'WidgetPackagingFormat'} $encodeddata->{'MainHTML'} $encodeddata->{'AttributeList'}";
  1808         $regCmd = "$cmd $dbPath $encodeddata->{'BundleIdentifier'} $encodeddata->{'Uid'} $encodeddata->{'BundleDisplayName'} $encodeddata->{'BasePath'} $encodeddata->{'DBIconPath'} $encodeddata->{'WidgetPackagingFormat'} $encodeddata->{'MainHTML'} $encodeddata->{'AttributeList'}";
  1806     }
  1809     }
  1807     else
  1810     else
  1808    {
  1811    {
  1809         print "\n AttributeList argument not sent to DB\n";
  1812         print "\nAttributeList argument not sent to DB\n";
  1810         $regCmd = "$cmd $dbPath $encodeddata->{'BundleIdentifier'} $encodeddata->{'Uid'} $encodeddata->{'BundleDisplayName'} $encodeddata->{'BasePath'} $encodeddata->{'DBIconPath'} $encodeddata->{'WidgetPackagingFormat'} $encodeddata->{'MainHTML'}";
  1813         $regCmd = "$cmd $dbPath $encodeddata->{'BundleIdentifier'} $encodeddata->{'Uid'} $encodeddata->{'BundleDisplayName'} $encodeddata->{'BasePath'} $encodeddata->{'DBIconPath'} $encodeddata->{'WidgetPackagingFormat'} $encodeddata->{'MainHTML'}";
  1811     }
  1814     }
  1812     print "\n regCmd : $regCmd \n\n";
  1815     print "\n regCmd : $regCmd \n\n";
  1813     system($regCmd);
  1816     system($regCmd);
  1814     }
  1817     }