javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp
changeset 23 98ccebc37403
parent 21 2a9601315dfc
child 25 9ac0a0a7da70
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
    40 using namespace java;
    40 using namespace java;
    41 using namespace Usif;
    41 using namespace Usif;
    42 
    42 
    43 IMPORT_C HBufC* CreateHBufCFromJavaStringLC(JNIEnv* aEnv, jstring aString);
    43 IMPORT_C HBufC* CreateHBufCFromJavaStringLC(JNIEnv* aEnv, jstring aString);
    44 
    44 
       
    45 // String to be used for icon filenames when icon is not present.
       
    46 _LIT(KNoIconFilename, "");
    45 
    47 
    46 /*
    48 /*
    47  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
    49  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
    48  * Method:    _sifNotifierEnabled
    50  * Method:    _sifNotifierEnabled
    49  * Signature: ()Z
    51  * Signature: ()Z
    59  * This method makes calls that may leave (the actual notifying).
    61  * This method makes calls that may leave (the actual notifying).
    60  */
    62  */
    61 void NotifyStartL(
    63 void NotifyStartL(
    62     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier,
    64     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier,
    63     jstring aGlobalComponentId, jstring aComponentName,
    65     jstring aGlobalComponentId, jstring aComponentName,
    64     jobjectArray aApplicationNames, jint aComponentSize,
    66     jobjectArray aApplicationNames, jobjectArray aApplicationIcons,
    65     jstring aComponentIconPath)
    67     jint aComponentSize, jstring aIconDir, jstring /*aComponentIcon*/)
    66 {
    68 {
    67     __UHEAP_MARK;
    69     __UHEAP_MARK;
    68     HBufC *globalComponentId = CreateHBufCFromJavaStringLC(aEnv, aGlobalComponentId);
    70     HBufC *globalComponentId = CreateHBufCFromJavaStringLC(aEnv, aGlobalComponentId);
    69     HBufC *componentName = CreateHBufCFromJavaStringLC(aEnv, aComponentName);
    71     HBufC *componentName = CreateHBufCFromJavaStringLC(aEnv, aComponentName);
    70     HBufC *componentIconPath = CreateHBufCFromJavaStringLC(aEnv, aComponentIconPath);
    72     HBufC *iconDir = NULL;
       
    73     if (NULL != aIconDir)
       
    74     {
       
    75         iconDir = CreateHBufCFromJavaStringLC(aEnv, aIconDir);
       
    76     }
    71 
    77 
    72     RPointerArray<HBufC> applicationNames;
    78     RPointerArray<HBufC> applicationNames;
    73     CleanupResetAndDestroyPushL(applicationNames);
    79     CleanupResetAndDestroyPushL(applicationNames);
    74     RPointerArray<HBufC> applicationIcons;
    80     RPointerArray<HBufC> applicationIcons;
    75     CleanupResetAndDestroyPushL(applicationIcons);
    81     CleanupResetAndDestroyPushL(applicationIcons);
    76 
    82 
    77     TInt appsCount = aEnv->GetArrayLength(aApplicationNames);
    83     TInt appsCount = aEnv->GetArrayLength(aApplicationNames);
    78     for (TInt i = 0; i < appsCount; i++)
    84     for (TInt i = 0; i < appsCount; i++)
    79     {
    85     {
    80         HBufC *appName = CreateHBufCFromJavaStringLC(
    86         HBufC *appName =
    81                              aEnv, (jstring)aEnv->GetObjectArrayElement(aApplicationNames, i));
    87             CreateHBufCFromJavaStringLC(
       
    88                 aEnv, (jstring)aEnv->GetObjectArrayElement(aApplicationNames, i));
    82         applicationNames.AppendL(appName);
    89         applicationNames.AppendL(appName);
    83         CleanupStack::Pop(appName);
    90         CleanupStack::Pop(appName);
    84     }
    91     }
    85 
    92     if (NULL != aApplicationIcons)
    86     CSifOperationStartData *startData = CSifOperationStartData::NewLC(
    93     {
    87                                             *globalComponentId, *componentName, applicationNames, applicationIcons,
    94         appsCount = aEnv->GetArrayLength(aApplicationIcons);
    88                                             aComponentSize, /*aIconPath=*/ *componentIconPath,
    95         for (TInt i = 0; i < appsCount; i++)
    89                                             /*aComponentIcon=*/ KNullDesC(), Usif::KSoftwareTypeJava);
    96         {
       
    97             jstring tmpAppIcon =
       
    98                 (jstring)aEnv->GetObjectArrayElement(aApplicationIcons, i);
       
    99             if (NULL != tmpAppIcon)
       
   100             {
       
   101                 HBufC *appIcon = CreateHBufCFromJavaStringLC(aEnv, tmpAppIcon);
       
   102                 applicationIcons.AppendL(appIcon);
       
   103                 CleanupStack::Pop(appIcon);
       
   104             }
       
   105             else
       
   106             {
       
   107                 // Add a string indicating that icon is not available
       
   108                 // for this application.
       
   109                 applicationIcons.AppendL(KNoIconFilename().AllocL());
       
   110             }
       
   111         }
       
   112     }
       
   113 
       
   114     CSifOperationStartData *startData =
       
   115         CSifOperationStartData::NewLC(
       
   116             *globalComponentId, *componentName, applicationNames, applicationIcons,
       
   117             aComponentSize, /*aIconPath=*/ (NULL != aIconDir? *iconDir: KNullDesC()),
       
   118             /*aComponentIcon=*/ KNullDesC(), Usif::KSoftwareTypeJava);
    90 
   119 
    91     User::LeaveIfError(aNotifier->PublishStart(*startData));
   120     User::LeaveIfError(aNotifier->PublishStart(*startData));
    92 
   121 
    93     CleanupStack::PopAndDestroy(startData);
   122     CleanupStack::PopAndDestroy(startData);
    94 
   123 
    95     CleanupStack::PopAndDestroy(&applicationIcons);
   124     CleanupStack::PopAndDestroy(&applicationIcons);
    96     CleanupStack::PopAndDestroy(&applicationNames);
   125     CleanupStack::PopAndDestroy(&applicationNames);
    97 
   126 
    98     CleanupStack::PopAndDestroy(componentIconPath);
   127     if (NULL != aIconDir)
       
   128     {
       
   129         CleanupStack::PopAndDestroy(iconDir);
       
   130     }
    99     CleanupStack::PopAndDestroy(componentName);
   131     CleanupStack::PopAndDestroy(componentName);
   100     CleanupStack::PopAndDestroy(globalComponentId);
   132     CleanupStack::PopAndDestroy(globalComponentId);
   101     __UHEAP_MARKEND;
   133     __UHEAP_MARKEND;
   102 }
   134 }
   103 
   135 
   106  * Method:    _notifyStart
   138  * Method:    _notifyStart
   107  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   139  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   108  */
   140  */
   109 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   141 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   110 (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId,
   142 (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId,
   111  jstring aComponentName, jobjectArray aApplicationNames, jint aComponentSize,
   143  jstring aComponentName, jobjectArray aApplicationNames,
   112  jstring aComponentIconPath)
   144  jobjectArray aApplicationIcons, jint aComponentSize,
       
   145  jstring aIconDir, jstring aComponentIcon)
   113 {
   146 {
   114     CPublishSifOperationInfo *pNotifier =
   147     CPublishSifOperationInfo *pNotifier =
   115         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   148         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   116     TRAPD(err, NotifyStartL(aEnv, pNotifier, aGlobalComponentId, aComponentName,
   149     TRAPD(err, NotifyStartL(aEnv, pNotifier, aGlobalComponentId, aComponentName,
   117                             aApplicationNames, aComponentSize,
   150                             aApplicationNames, aApplicationIcons,
   118                             aComponentIconPath));
   151                             aComponentSize, aIconDir, aComponentIcon));
   119     return err;
   152     return err;
   120 }
   153 }
   121 
   154 
   122 /**
   155 /**
   123  * See JNI method __1notifyEnd.
   156  * See JNI method __1notifyEnd.
   270  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   303  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   271  * Method:    _notifyStart
   304  * Method:    _notifyStart
   272  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   305  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   273  */
   306  */
   274 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   307 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   275 (JNIEnv *, jclass, jint, jstring, jstring, jobjectArray, jint, jstring)
   308 (JNIEnv *, jclass, jint, jstring, jstring, jobjectArray, jobjectArray, jint, jstring, jstring)
   276 {
   309 {
   277     LOG(EJavaInstaller, EInfo, "SifNotifier.notifyStart");
   310     LOG(EJavaInstaller, EInfo, "SifNotifier.notifyStart");
   278     return KErrNone;
   311     return KErrNone;
   279 }
   312 }
   280 
   313 
   284  * Signature: (ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;)I
   317  * Signature: (ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;)I
   285  */
   318  */
   286 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyEnd
   319 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyEnd
   287 (JNIEnv *, jclass, jint, jstring, jint aErrCategory, jint aErrCode, jstring, jstring)
   320 (JNIEnv *, jclass, jint, jstring, jint aErrCategory, jint aErrCode, jstring, jstring)
   288 {
   321 {
       
   322     (void)aErrCategory; // suppress compilation warning about unused argument
       
   323     (void)aErrCode; // suppress compilation warning about unused argument
   289     LOG2(EJavaInstaller, EInfo,
   324     LOG2(EJavaInstaller, EInfo,
   290          "SifNotifier.notifyEnd: errCategory=%d, errCode=%d",
   325          "SifNotifier.notifyEnd: errCategory=%d, errCode=%d",
   291          aErrCategory, aErrCode);
   326          aErrCategory, aErrCode);
   292     return KErrNone;
   327     return KErrNone;
   293 }
   328 }
   299  */
   334  */
   300 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyProgress
   335 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyProgress
   301 (JNIEnv *, jclass, jint, jstring,
   336 (JNIEnv *, jclass, jint, jstring,
   302  jint aOperation, jint aSubOperation, jint aCurrent, jint aTotal)
   337  jint aOperation, jint aSubOperation, jint aCurrent, jint aTotal)
   303 {
   338 {
       
   339     (void)aOperation; // suppress compilation warning about unused argument
       
   340     (void)aSubOperation; // suppress compilation warning about unused argument
       
   341     (void)aCurrent; // suppress compilation warning about unused argument
       
   342     (void)aTotal; // suppress compilation warning about unused argument
   304     LOG4(EJavaInstaller, EInfo,
   343     LOG4(EJavaInstaller, EInfo,
   305          "SifNotifier.notifyProgress: op=%d, subop=%d, current=%d, total=%d",
   344          "SifNotifier.notifyProgress: op=%d, subop=%d, current=%d, total=%d",
   306          aOperation, aSubOperation, aCurrent, aTotal);
   345          aOperation, aSubOperation, aCurrent, aTotal);
   307     return KErrNone;
   346     return KErrNone;
   308 }
   347 }