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 /** |
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 + |
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 /** |
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 * |