javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java
changeset 50 023eef975703
parent 35 85266cc22c7f
child 87 1627c337e51e
equal deleted inserted replaced
49:35baca0e7a2e 50:023eef975703
     1 /*
     1 /*
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    58     {
    58     {
    59         return _getUsifMode();
    59         return _getUsifMode();
    60     }
    60     }
    61 
    61 
    62     /**
    62     /**
       
    63      * Returns SIF specific error category from given error id.
       
    64      */
       
    65     public static int getErrorCategory(int aErrorId)
       
    66     {
       
    67         return _getErrorCategory(aErrorId);
       
    68     }
       
    69 
       
    70     /**
    63      * Launches the application view. If launching application view
    71      * Launches the application view. If launching application view
    64      * fails this method does not throw exception but produces an
    72      * fails this method does not throw exception but produces an
    65      * error log entry.
    73      * error log entry.
    66      */
    74      */
    67     public static void launchAppView()
    75     public static void launchAppView()
   155         // negative Symbian error code if it fails.
   163         // negative Symbian error code if it fails.
   156         int ret = _startSession(aTransaction);
   164         int ret = _startSession(aTransaction);
   157         if (ret < 0)
   165         if (ret < 0)
   158         {
   166         {
   159             InstallerException.internalError(
   167             InstallerException.internalError(
   160                 "Creating session failed with code " + ret);
   168                 "Creating SIF session failed with code " + ret);
   161         }
   169         }
   162         //Log.log("SifRegistrator session started");
   170         //Log.log("SifRegistrator session started");
   163         iSessionHandle = ret;
   171         iSessionHandle = ret;
   164     }
   172     }
   165 
   173 
   174      * @see startSession
   182      * @see startSession
   175      * @see SuiteInfo
   183      * @see SuiteInfo
   176      */
   184      */
   177     public void registerSuite(SuiteInfo aSuiteInfo, boolean aIsUpdate)
   185     public void registerSuite(SuiteInfo aSuiteInfo, boolean aIsUpdate)
   178     {
   186     {
   179         if (0 == iSessionHandle)
   187         checkSession();
   180         {
       
   181             InstallerException.internalError("No valid SIF session.");
       
   182         }
       
   183         Log.log("SifRegistrator registering application suite " +
   188         Log.log("SifRegistrator registering application suite " +
   184                 aSuiteInfo.getGlobalId());
   189                 aSuiteInfo.getGlobalId());
   185 
   190 
   186         if (_getUsifMode() > 0)
   191         // Register suite as a component.
   187         {
   192         registerComponent(aSuiteInfo, aIsUpdate);
   188             // USIF Phase 2 registration.
   193         registerLocalizedComponentName(aSuiteInfo, -1);
   189             // Register suite as a component.
   194         // Register applications within the component.
   190             registerComponent(aSuiteInfo, aIsUpdate);
   195         Vector apps = aSuiteInfo.getApplications();
   191             registerLocalizedComponentName(aSuiteInfo, -1);
   196         for (int i = 0; i < apps.size(); i++)
   192             // Register applications within the component.
   197         {
   193             Vector apps = aSuiteInfo.getApplications();
   198             registerApplication(aSuiteInfo, i);
   194             for (int i = 0; i < apps.size(); i++)
       
   195             {
       
   196                 registerApplication(aSuiteInfo, i);
       
   197             }
       
   198         }
       
   199         else
       
   200         {
       
   201             // USIF Phase 1 registration.
       
   202             // Register each application in the suite.
       
   203             Vector apps = aSuiteInfo.getApplications();
       
   204             for (int i = 0; i < apps.size(); i++)
       
   205             {
       
   206                 registerComponent(aSuiteInfo, i, aIsUpdate);
       
   207                 registerLocalizedComponentName(aSuiteInfo, i);
       
   208             }
       
   209         }
   199         }
   210         registerLocalizedProperties(aSuiteInfo);
   200         registerLocalizedProperties(aSuiteInfo);
   211     }
   201     }
   212 
   202 
   213     /**
   203     /**
   219      * @see startSession
   209      * @see startSession
   220      * @see SuiteInfo
   210      * @see SuiteInfo
   221      */
   211      */
   222     public void unregisterSuite(SuiteInfo aSuiteInfo)
   212     public void unregisterSuite(SuiteInfo aSuiteInfo)
   223     {
   213     {
   224         if (0 == iSessionHandle)
   214         checkSession();
   225         {
       
   226             InstallerException.internalError("No valid SIF session.");
       
   227         }
       
   228         Log.log("SifRegistrator unregistering application suite " +
   215         Log.log("SifRegistrator unregistering application suite " +
   229                 aSuiteInfo.getGlobalId());
   216                 aSuiteInfo.getGlobalId());
   230 
   217 
   231         if (_getUsifMode() > 0)
   218         // Unregister suite as a component.
   232         {
   219         unregisterComponent(aSuiteInfo);
   233             // USIF Phase 2 unregistration.
       
   234             // Unregister suite as a component.
       
   235             unregisterComponent(aSuiteInfo);
       
   236         }
       
   237         else
       
   238         {
       
   239             // USIF Phase 1 unregistration.
       
   240             // Unregister each application in the suite.
       
   241             Vector apps = aSuiteInfo.getApplications();
       
   242             for (int i = 0; i < apps.size(); i++)
       
   243             {
       
   244                 unregisterComponent(aSuiteInfo, i);
       
   245             }
       
   246         }
       
   247     }
   220     }
   248 
   221 
   249     /**
   222     /**
   250      * Commits the registrations and unregistrations.
   223      * Commits the registrations and unregistrations.
   251      * Ends the current session if commit is successfull.
   224      * Ends the current session if commit is successfull.
   254      *
   227      *
   255      * @throws InstallerException if session cannot be committed
   228      * @throws InstallerException if session cannot be committed
   256      */
   229      */
   257     public void commitSession()
   230     public void commitSession()
   258     {
   231     {
   259         if (0 == iSessionHandle)
   232         checkSession();
   260         {
       
   261             InstallerException.internalError("No valid SIF session.");
       
   262         }
       
   263 
       
   264         int err = _commitSession(iSessionHandle);
   233         int err = _commitSession(iSessionHandle);
   265         if (err < 0)
   234         if (err < 0)
   266         {
   235         {
   267             InstallerException.internalError("Commiting session failed with code " + err);
   236             InstallerException.internalError("Commiting SIF session failed with code " + err);
   268         }
   237         }
   269         // Current session has been closed
   238         // Current session has been closed
   270         iSessionHandle = 0;
   239         iSessionHandle = 0;
   271         //Log.log("SifRegistrator session committed");
   240         //Log.log("SifRegistrator session committed");
   272     }
   241     }
   277      *
   246      *
   278      * @throws InstallerException if session cannot be rolled back.
   247      * @throws InstallerException if session cannot be rolled back.
   279      */
   248      */
   280     public void rollbackSession()
   249     public void rollbackSession()
   281     {
   250     {
   282         if (0 == iSessionHandle)
   251         checkSession();
   283         {
       
   284             InstallerException.internalError("No valid SIF session.");
       
   285         }
       
   286 
       
   287         int err = _rollbackSession(iSessionHandle);
   252         int err = _rollbackSession(iSessionHandle);
   288         // Session is closed always when rollback is called
   253         // Session is closed always when rollback is called
   289         iSessionHandle = 0;
   254         iSessionHandle = 0;
   290         if (err < 0)
   255         if (err < 0)
   291         {
   256         {
   292             InstallerException.internalError("Rolling back the session failed with code " + err);
   257             InstallerException.internalError("Rolling back SIF session failed with code " + err);
   293         }
   258         }
   294         //Log.log("SifRegistrator session rolled back");
   259         //Log.log("SifRegistrator session rolled back");
   295     }
   260     }
   296 
   261 
   297     /**
   262     /**
   303     {
   268     {
   304         if (0 == iSessionHandle)
   269         if (0 == iSessionHandle)
   305         {
   270         {
   306             return;
   271             return;
   307         }
   272         }
   308 
       
   309         _closeSession(iSessionHandle);
   273         _closeSession(iSessionHandle);
   310         // Current session has been closed
   274         // Current session has been closed
   311         iSessionHandle = 0;
   275         iSessionHandle = 0;
   312         //Log.log("SifRegistrator session closed");
   276         //Log.log("SifRegistrator session closed");
   313     }
   277     }
   320      * application with given global id cannot be found.
   284      * application with given global id cannot be found.
   321      * @throws InstallerException if an error occurs
   285      * @throws InstallerException if an error occurs
   322      */
   286      */
   323     public ComponentId getComponentId(String aGlobalId)
   287     public ComponentId getComponentId(String aGlobalId)
   324     {
   288     {
   325         if (0 == iSessionHandle)
   289         checkSession();
   326         {
       
   327             InstallerException.internalError("No valid SIF session.");
       
   328         }
       
   329 
       
   330         ComponentId result = new ComponentId();
   290         ComponentId result = new ComponentId();
   331         int ret = _getComponentId(iSessionHandle, aGlobalId, result);
   291         int ret = _getComponentId(iSessionHandle, aGlobalId, result);
   332         if (-1 == ret)
   292         if (-1 == ret)
   333         {
   293         {
   334             // Symbian error code KErrNotFound means that the
   294             // Symbian error code KErrNotFound means that the
   352      * application with given uid cannot be found.
   312      * application with given uid cannot be found.
   353      * @throws InstallerException if an error occurs
   313      * @throws InstallerException if an error occurs
   354      */
   314      */
   355     public ComponentId getComponentId(Uid aAppUid)
   315     public ComponentId getComponentId(Uid aAppUid)
   356     {
   316     {
   357         if (0 == iSessionHandle)
   317         checkSession();
   358         {
       
   359             InstallerException.internalError("No valid SIF session.");
       
   360         }
       
   361 
       
   362         ComponentId result = new ComponentId();
   318         ComponentId result = new ComponentId();
   363         int ret = _getComponentIdForApp(
   319         int ret = _getComponentIdForApp(
   364                       iSessionHandle, ((PlatformUid)aAppUid).getIntValue(), result);
   320                       iSessionHandle, ((PlatformUid)aAppUid).getIntValue(), result);
   365         if (-1 == ret)
   321         if (-1 == ret)
   366         {
   322         {
   382      *
   338      *
   383      * @param aGlobalId the global id for the application.
   339      * @param aGlobalId the global id for the application.
   384      */
   340      */
   385     public void logComponent(String aGlobalId)
   341     public void logComponent(String aGlobalId)
   386     {
   342     {
   387         if (0 == iSessionHandle)
   343         checkSession();
   388         {
       
   389             InstallerException.internalError("No valid SIF session.");
       
   390         }
       
   391 
       
   392         int ret = _logComponent(iSessionHandle, aGlobalId);
   344         int ret = _logComponent(iSessionHandle, aGlobalId);
   393         if (ret < -1)
   345         if (ret < -1)
   394         {
   346         {
   395             Log.logError("SifRegistrator logComponent failed with code " + ret);
   347             Log.logError("SifRegistrator logComponent for " + aGlobalId +
       
   348                          " failed with code " + ret);
   396         }
   349         }
   397     }
   350     }
   398 
   351 
   399     /*** ----------------------------- PACKAGE ---------------------------- */
   352     /*** ----------------------------- PACKAGE ---------------------------- */
   400     /*** ----------------------------- PRIVATE ---------------------------- */
   353     /*** ----------------------------- PRIVATE ---------------------------- */
   401 
   354 
   402     /**
   355     /**
   403      * Registers one Java application to S60 USIF as a component.
   356      * Checks if SifRegistrator session has been started.
   404      * Used with USIF Phase 1.
   357      * @throws InstallerException if SifRegistrator session has not been started
   405      *
   358      */
   406      * @param aSuiteInfo Information needed to register the application
   359     private void checkSession()
   407      * @param aIndex index of the application in the suite
   360     {
   408      * @param aIsUpdate true in case of an update, false in case of a new
   361         if (iSessionHandle == 0)
   409      * installation
   362         {
   410      * @throws InstallerException if registration cannot done or
   363             InstallerException.internalError("No valid SIF session.");
   411      *  startSession has not been called successfully
       
   412      * @see startSession
       
   413      * @see SuiteInfo
       
   414      */
       
   415     private void registerComponent(
       
   416         SuiteInfo aSuiteInfo, int aIndex, boolean aIsUpdate)
       
   417     {
       
   418         String globalId = aSuiteInfo.getGlobalId(aIndex);
       
   419         if (globalId == null)
       
   420         {
       
   421             Log.logWarning("SifRegistrator: Application with index " + aIndex +
       
   422                            " not found from " + aSuiteInfo.getGlobalId());
       
   423             return;
       
   424         }
       
   425         ApplicationInfo appInfo =
       
   426             (ApplicationInfo)aSuiteInfo.getApplications().elementAt(aIndex);
       
   427         String suiteName = aSuiteInfo.getName();
       
   428         String vendor = aSuiteInfo.getVendor();
       
   429         String version = aSuiteInfo.getVersion().toString();
       
   430         String name = appInfo.getName();
       
   431         int uid = ((PlatformUid)appInfo.getUid()).getIntValue();
       
   432         String[] componentFiles = getComponentFiles(aSuiteInfo);
       
   433         long componentSize = aSuiteInfo.getInitialSize();
       
   434         String attrValue = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Block-Uninstall");
       
   435         boolean isRemovable = !(attrValue != null && attrValue.equalsIgnoreCase("true"));
       
   436         boolean isDrmProtected = (aSuiteInfo.getContentInfo() == aSuiteInfo.CONTENT_INFO_DRM);
       
   437         boolean isOriginVerified = aSuiteInfo.isTrusted();
       
   438         String midletInfoUrl = aSuiteInfo.getAttributeValue("MIDlet-Info-URL");
       
   439         String midletDescription = aSuiteInfo.getAttributeValue("MIDlet-Description");
       
   440         String downloadUrl = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Download-URL");
       
   441         ComponentId componentId = new ComponentId();
       
   442         int err = _registerComponent(
       
   443                       iSessionHandle, uid,
       
   444                       getScrString(suiteName), getScrString(vendor),
       
   445                       getScrString(version), getScrString(name),
       
   446                       getScrString(globalId), componentFiles,
       
   447                       componentSize, isRemovable, isDrmProtected,
       
   448                       isOriginVerified, aIsUpdate, aSuiteInfo.getMediaId(),
       
   449                       getScrString(midletInfoUrl),
       
   450                       getScrString(midletDescription),
       
   451                       getScrString(downloadUrl),
       
   452                       componentId);
       
   453         if (err < 0)
       
   454         {
       
   455             InstallerException.internalError(
       
   456                 "Registering component " + globalId +
       
   457                 " failed with code " + err);
       
   458         }
       
   459         else
       
   460         {
       
   461             appInfo.setComponentId(componentId);
       
   462             Log.log("SifRegistrator registered component " + globalId +
       
   463                     " with id " + componentId.getId());
       
   464         }
       
   465     }
       
   466 
       
   467     /**
       
   468      * Unregisters one Java application from being S60 USIF component.
       
   469      * Used with USIF Phase 1.
       
   470      *
       
   471      * @param aSuiteInfo Information needed to unregister the application,
       
   472      * @param aIndex index of the application in the suite
       
   473      * @throws InstallerException if unregistration cannot done or
       
   474      *  startSession has not been called successfully
       
   475      * @see startSession
       
   476      * @see SuiteInfo
       
   477      */
       
   478     private void unregisterComponent(SuiteInfo aSuiteInfo, int aIndex)
       
   479     {
       
   480         String globalId = aSuiteInfo.getGlobalId(aIndex);
       
   481         if (globalId == null)
       
   482         {
       
   483             Log.logWarning("SifRegistrator: Application with index " + aIndex +
       
   484                            " not found from " + aSuiteInfo.getGlobalId());
       
   485             return;
       
   486         }
       
   487         ComponentId componentId = getComponentId(globalId);
       
   488         if (componentId == null)
       
   489         {
       
   490             Log.logWarning(
       
   491                 "SifRegistrator unregistration failed, application " +
       
   492                 globalId + " does not exist");
       
   493             return;
       
   494         }
       
   495         // Save component id to ApplicationInfo.
       
   496         ApplicationInfo appInfo =
       
   497             (ApplicationInfo)aSuiteInfo.getApplications().elementAt(aIndex);
       
   498         appInfo.setComponentId(componentId);
       
   499         // Unregister application.
       
   500         int err = _unregisterComponent(iSessionHandle, componentId.getId());
       
   501         if (err < 0)
       
   502         {
       
   503             InstallerException.internalError(
       
   504                 "Unregistering component " + globalId +
       
   505                 " failed with code " + err);
       
   506         }
       
   507         else
       
   508         {
       
   509             Log.log("SifRegistrator unregistered component " + globalId +
       
   510                     " with id " + componentId.getId());
       
   511         }
   364         }
   512     }
   365     }
   513 
   366 
   514     /**
   367     /**
   515      * Registers Java application suite to S60 USIF as a component.
   368      * Registers Java application suite to S60 USIF as a component.
   516      * Used with USIF Phase 2.
       
   517      *
   369      *
   518      * @param aSuiteInfo Suite information
   370      * @param aSuiteInfo Suite information
   519      * @param aIsUpdate true in case of an update, false in case of a new
   371      * @param aIsUpdate true in case of an update, false in case of a new
   520      * installation
   372      * installation
   521      * @throws InstallerException if registration cannot done or
   373      * @throws InstallerException if registration cannot done or
   527     {
   379     {
   528         String globalId = aSuiteInfo.getGlobalId();
   380         String globalId = aSuiteInfo.getGlobalId();
   529         String suiteName = aSuiteInfo.getName();
   381         String suiteName = aSuiteInfo.getName();
   530         String vendor = aSuiteInfo.getVendor();
   382         String vendor = aSuiteInfo.getVendor();
   531         String version = aSuiteInfo.getVersion().toString();
   383         String version = aSuiteInfo.getVersion().toString();
   532         String name = null; // Set name to null so that suite name will be used.
       
   533         int uid = ((PlatformUid)aSuiteInfo.getUid()).getIntValue();
   384         int uid = ((PlatformUid)aSuiteInfo.getUid()).getIntValue();
   534         String[] componentFiles = getComponentFiles(aSuiteInfo);
   385         String[] componentFiles = getComponentFiles(aSuiteInfo);
   535         long componentSize = aSuiteInfo.getInitialSize();
   386         long componentSize = aSuiteInfo.getInitialSize();
   536         String attrValue = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Block-Uninstall");
   387         String attrValue = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Block-Uninstall");
   537         boolean isRemovable = !(attrValue != null && attrValue.equalsIgnoreCase("true"));
   388         boolean isRemovable = !(attrValue != null && attrValue.equalsIgnoreCase("true"));
   538         boolean isDrmProtected = (aSuiteInfo.getContentInfo() == aSuiteInfo.CONTENT_INFO_DRM);
   389         boolean isDrmProtected = (aSuiteInfo.getContentInfo() == aSuiteInfo.CONTENT_INFO_DRM);
   539         boolean isOriginVerified = aSuiteInfo.isTrusted();
   390         boolean isOriginVerified = aSuiteInfo.isTrusted();
   540         String midletInfoUrl = aSuiteInfo.getAttributeValue("MIDlet-Info-URL");
   391         String midletInfoUrl = aSuiteInfo.getAttributeValue("MIDlet-Info-URL");
   541         String midletDescription = aSuiteInfo.getAttributeValue("MIDlet-Description");
   392         String midletDescription = aSuiteInfo.getAttributeValue("MIDlet-Description");
   542         String downloadUrl = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Download-URL");
   393         String downloadUrl = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Download-URL");
       
   394         String updateUrl = aSuiteInfo.getAttributeValue("Nokia-Update");
   543         ComponentId componentId = new ComponentId();
   395         ComponentId componentId = new ComponentId();
   544         int err = _registerComponent(
   396         int err = _registerComponent(
   545                       iSessionHandle, uid,
   397                       iSessionHandle, uid,
   546                       getScrString(suiteName), getScrString(vendor),
   398                       getScrString(suiteName), getScrString(vendor),
   547                       getScrString(version), getScrString(name),
   399                       getScrString(version), getScrString(globalId),
   548                       getScrString(globalId), componentFiles,
   400                       componentFiles, componentSize,
   549                       componentSize, isRemovable, isDrmProtected,
   401                       isRemovable, isDrmProtected,
   550                       isOriginVerified, aIsUpdate, aSuiteInfo.getMediaId(),
   402                       isOriginVerified, aIsUpdate,
       
   403                       aSuiteInfo.getMediaId(),
   551                       getScrString(midletInfoUrl),
   404                       getScrString(midletInfoUrl),
   552                       getScrString(midletDescription),
   405                       getScrString(midletDescription),
   553                       getScrString(downloadUrl),
   406                       getScrString(downloadUrl),
       
   407                       getScrString(updateUrl),
   554                       componentId);
   408                       componentId);
   555         if (err < 0)
   409         if (err < 0)
   556         {
   410         {
   557             InstallerException.internalError(
   411             InstallerException.internalError(
   558                 "Registering component " + globalId +
   412                 "Registering component " + globalId +
   566         }
   420         }
   567     }
   421     }
   568 
   422 
   569     /**
   423     /**
   570      * Unregisters Java application suite from being S60 USIF component.
   424      * Unregisters Java application suite from being S60 USIF component.
   571      * Used with USIF Phase 2.
       
   572      *
   425      *
   573      * @param aSuiteInfo suite information
   426      * @param aSuiteInfo suite information
   574      * @throws InstallerException if unregistration cannot done or
   427      * @throws InstallerException if unregistration cannot done or
   575      *  startSession has not been called successfully
   428      *  startSession has not been called successfully
   576      * @see startSession
   429      * @see startSession
   608      * Registers one Java application to S60 USIF as an S60 application.
   461      * Registers one Java application to S60 USIF as an S60 application.
   609      * The application is registered to component whose id is taken
   462      * The application is registered to component whose id is taken
   610      * from given SuiteInfo object. The SuiteInfo must already have
   463      * from given SuiteInfo object. The SuiteInfo must already have
   611      * been registered to USIF as a component with registerComponent()
   464      * been registered to USIF as a component with registerComponent()
   612      * method before this method is called.
   465      * method before this method is called.
   613      * Used with USIF Phase 2.
       
   614      *
   466      *
   615      * @param aSuiteInfo information needed to register the application
   467      * @param aSuiteInfo information needed to register the application
   616      * @param aIndex index of the application in the suite
   468      * @param aIndex index of the application in the suite
   617      * @throws InstallerException if registration cannot done or
   469      * @throws InstallerException if registration cannot done or
   618      *  startSession has not been called successfully
   470      *  startSession has not been called successfully
   795             InstallerException.internalError(
   647             InstallerException.internalError(
   796                 "Adding property " + attrName + " for component " + cid +
   648                 "Adding property " + attrName + " for component " + cid +
   797                 " failed with code " + err + " (" + nonlocalizedAttrValue + ")");
   649                 " failed with code " + err + " (" + nonlocalizedAttrValue + ")");
   798         }
   650         }
   799         LocalizedName[] localizedAttrValues =
   651         LocalizedName[] localizedAttrValues =
   800             getLocalizedNames(aSuite, attrName + "-");
   652             getLocalizedNames(aSuite, "Nokia-" + attrName + "-");
   801         for (int i = 0; i < localizedAttrValues.length; i++)
   653         for (int i = 0; i < localizedAttrValues.length; i++)
   802         {
   654         {
   803             err = _setLocalizedComponentProperty(
   655             err = _setLocalizedComponentProperty(
   804                       iSessionHandle, cid, getScrString(attrName),
   656                       iSessionHandle, cid, getScrString(attrName),
   805                       getScrString(localizedAttrValues[i].getName()),
   657                       getScrString(localizedAttrValues[i].getName()),
   814         }
   666         }
   815 
   667 
   816         // Register Domain-Category property.
   668         // Register Domain-Category property.
   817         String protectionDomainProperty = "Domain-Category";
   669         String protectionDomainProperty = "Domain-Category";
   818         String protectionDomainName = aSuite.getProtectionDomainName();
   670         String protectionDomainName = aSuite.getProtectionDomainName();
   819         if (protectionDomainName != null)
   671         err = _setLocalizedComponentProperty(
   820         {
   672             iSessionHandle, cid, protectionDomainProperty,
   821             err = _setLocalizedComponentProperty(
   673             getProtectionDomainPropertyValue(protectionDomainName),
   822                 iSessionHandle, cid, protectionDomainProperty,
   674             UNSPECIFIED_LOCALE);
   823                 getProtectionDomainPropertyValue(protectionDomainName),
   675         if (err < 0)
   824                 UNSPECIFIED_LOCALE);
   676         {
   825             if (err < 0)
   677             InstallerException.internalError(
   826             {
   678                 "Adding property " + protectionDomainProperty +
   827                 InstallerException.internalError(
   679                 " value " + protectionDomainName + " for component " +
   828                     "Adding property " + protectionDomainProperty +
   680                 cid + " failed with code " + err);
   829                     " value " + protectionDomainName + " for component " +
       
   830                     cid + " failed with code " + err);
       
   831             }
       
   832         }
       
   833         else
       
   834         {
       
   835             Log.logWarning(
       
   836                 "SifRegistrator.registerLocalizedProperties: " +
       
   837                 protectionDomainProperty + " not set");
       
   838         }
   681         }
   839     }
   682     }
   840 
   683 
   841     /**
   684     /**
   842      * Returns the "Domain-Category" property value which contains
   685      * Returns the "Domain-Category" property value which contains
   843      * the text id and text file name for the localized domain category
   686      * the text id and text file name for the localized domain category
   844      * text.
   687      * text. This method must never return null.
   845      */
   688      */
   846     private String getProtectionDomainPropertyValue(String aProtectionDomain)
   689     private String getProtectionDomainPropertyValue(String aProtectionDomain)
   847     {
   690     {
   848         String textId = null;
   691         String textId = "txt_java_inst_setlabel_cert_domain_val_untrusted_third_party";
   849         if (aProtectionDomain.equals("Manufacturer"))
   692         if (aProtectionDomain != null)
   850         {
   693         {
   851             textId = "txt_java_inst_setlabel_cert_domain_val_manufacturer";
   694             if (aProtectionDomain.equals("Manufacturer"))
   852         }
   695             {
   853         else if (aProtectionDomain.equals("Operator"))
   696                 textId = "txt_java_inst_setlabel_cert_domain_val_manufacturer";
   854         {
   697             }
   855             textId = "txt_java_inst_setlabel_cert_domain_val_operator";
   698             else if (aProtectionDomain.equals("Operator"))
   856         }
   699             {
   857         else if (aProtectionDomain.equals("IdentifiedThirdParty"))
   700                 textId = "txt_java_inst_setlabel_cert_domain_val_operator";
   858         {
   701             }
   859             textId = "txt_java_inst_setlabel_cert_domain_val_trusted_third_party";
   702             else if (aProtectionDomain.equals("IdentifiedThirdParty"))
   860         }
   703             {
   861         else if (aProtectionDomain.equals("UnidentifiedThirdParty"))
   704                 textId = "txt_java_inst_setlabel_cert_domain_val_trusted_third_party";
   862         {
   705             }
   863             textId = "txt_java_inst_setlabel_cert_domain_val_untrusted_third_party";
       
   864         }
   706         }
   865         return textId + ",javaapplicationinstaller";
   707         return textId + ",javaapplicationinstaller";
   866     }
   708     }
   867 
   709 
   868     /**
   710     /**
   892                     {
   734                     {
   893                         Log.logWarning(
   735                         Log.logWarning(
   894                             "SifRegistrator ignored unknown locale: " +
   736                             "SifRegistrator ignored unknown locale: " +
   895                             name + ": " + localizedName);
   737                             name + ": " + localizedName);
   896                     }
   738                     }
       
   739                     else if (localizedName.getName() == null ||
       
   740                              localizedName.getName().length() == 0)
       
   741                     {
       
   742                         Log.logWarning(
       
   743                             "SifRegistrator ignored empty localized text: " +
       
   744                             name + ": " + localizedName);
       
   745                     }
   897                     else
   746                     else
   898                     {
   747                     {
   899                         Log.log("SifRegistrator found localized text " +
   748                         Log.log("SifRegistrator found localized text " +
   900                                 name + ": " + localizedName);
   749                                 name + ": " + localizedName);
   901                         localizedNames.put(
   750                         localizedNames.put(
  1013      * @param aSessionHandle
   862      * @param aSessionHandle
  1014      * @param aUid
   863      * @param aUid
  1015      * @param aSuiteName
   864      * @param aSuiteName
  1016      * @param aVendor
   865      * @param aVendor
  1017      * @param aVersion
   866      * @param aVersion
  1018      * @param aName
       
  1019      * @param aGlobalId
   867      * @param aGlobalId
  1020      * @param aComponentFiles
   868      * @param aComponentFiles
  1021      * @param aComponentSize
   869      * @param aComponentSize
  1022      * @param aIsRemovable
   870      * @param aIsRemovable
  1023      * @param aIsDrmProtected
   871      * @param aIsDrmProtected
  1025      * @param aIsUpdate
   873      * @param aIsUpdate
  1026      * @param aMediaId
   874      * @param aMediaId
  1027      * @param aMidletInfoUrl
   875      * @param aMidletInfoUrl
  1028      * @param aMidletDescription
   876      * @param aMidletDescription
  1029      * @param aDownloadUrl
   877      * @param aDownloadUrl
       
   878      * @param aUpdateUrl
  1030      * @param aComponentId upon successful execution contains the
   879      * @param aComponentId upon successful execution contains the
  1031      * component id for the registered component
   880      * component id for the registered component
  1032      * @return 0 if registration succeeded or Symbian error code
   881      * @return 0 if registration succeeded or Symbian error code
  1033      */
   882      */
  1034     private static native int _registerComponent(
   883     private static native int _registerComponent(
  1035         int aSessionHandle, int aUid, String aSuiteName, String aVendor,
   884         int aSessionHandle, int aUid, String aSuiteName, String aVendor,
  1036         String aVersion, String aName, String aGlobalId,
   885         String aVersion, String aGlobalId,
  1037         String[] aComponentFiles, long aComponentSize,
   886         String[] aComponentFiles, long aComponentSize,
  1038         boolean aIsRemovable, boolean aIsDrmProtected,
   887         boolean aIsRemovable, boolean aIsDrmProtected,
  1039         boolean aIsOriginVerified, boolean aIsUpdate, int aMediaId,
   888         boolean aIsOriginVerified, boolean aIsUpdate, int aMediaId,
  1040         String aMidletInfoUrl, String aMidletDescription, String aDownloadUrl,
   889         String aMidletInfoUrl, String aMidletDescription,
       
   890         String aDownloadUrl, String aUpdateUrl,
  1041         ComponentId aComponentId);
   891         ComponentId aComponentId);
  1042 
   892 
  1043     /**
   893     /**
  1044      * Unregisters Java application from S60 USIF.
   894      * Unregisters Java application from S60 USIF.
  1045      *
   895      *
  1143      * Checks if USIF is enabled.
   993      * Checks if USIF is enabled.
  1144      *
   994      *
  1145      * @return 1 if application data should be registered to USIF, 0 otherwise
   995      * @return 1 if application data should be registered to USIF, 0 otherwise
  1146      */
   996      */
  1147     private static native int _getUsifMode();
   997     private static native int _getUsifMode();
       
   998 
       
   999     /**
       
  1000      * Returns SIF specific error category from given error id.
       
  1001      */
       
  1002     private static native int _getErrorCategory(int aErrorId);
  1148 }
  1003 }