javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp
changeset 76 4ad59aaee882
parent 48 e0d6e9bd3ca7
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
    21 #include "javasymbianoslayer.h" // for CleanupResetAndDestroyPushL
    21 #include "javasymbianoslayer.h" // for CleanupResetAndDestroyPushL
    22 #include "logger.h"
    22 #include "logger.h"
    23 
    23 
    24 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    24 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    25 
    25 
       
    26 #include <hb/hbcore/hbindicatorsymbian.h>
       
    27 #include <hb/hbcore/hbsymbianvariant.h>
       
    28 #include <sifuiinstallindicatordefinitions.h>
    26 #include <usif/sif/sifnotification.h>
    29 #include <usif/sif/sifnotification.h>
    27 #include <usif/usifcommon.h>
    30 #include <usif/usifcommon.h>
    28 
    31 
    29 // NAMESPACE DECLARATION
    32 // NAMESPACE DECLARATION
    30 using namespace java;
    33 using namespace java;
    49 /**
    52 /**
    50  * See JNI method __1notifyStart.
    53  * See JNI method __1notifyStart.
    51  * This method makes calls that may leave (the actual notifying).
    54  * This method makes calls that may leave (the actual notifying).
    52  */
    55  */
    53 void NotifyStartL(
    56 void NotifyStartL(
    54     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier,
    57     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier, jint aOperation,
    55     jstring aGlobalComponentId, jstring aComponentName,
    58     jstring aGlobalComponentId, jstring aComponentName,
    56     jobjectArray aApplicationNames, jobjectArray aApplicationIcons,
    59     jobjectArray aApplicationNames, jobjectArray aApplicationIcons,
    57     jint aComponentSize, jstring aIconDir, jstring /*aComponentIcon*/)
    60     jint aComponentSize, jstring aIconDir, jstring /*aComponentIcon*/)
    58 {
    61 {
    59     __UHEAP_MARK;
    62     __UHEAP_MARK;
   104 
   107 
   105     CSifOperationStartData *startData =
   108     CSifOperationStartData *startData =
   106         CSifOperationStartData::NewLC(
   109         CSifOperationStartData::NewLC(
   107             *globalComponentId, *componentName, applicationNames, applicationIcons,
   110             *globalComponentId, *componentName, applicationNames, applicationIcons,
   108             aComponentSize, /*aIconPath=*/ (NULL != aIconDir? *iconDir: KNullDesC()),
   111             aComponentSize, /*aIconPath=*/ (NULL != aIconDir? *iconDir: KNullDesC()),
   109             /*aComponentIcon=*/ KNullDesC(), Usif::KSoftwareTypeJava);
   112             /*aComponentIcon=*/ KNullDesC(), Usif::KSoftwareTypeJava,
       
   113             (TSifOperationPhase)aOperation);
   110 
   114 
   111     aNotifier->PublishStartL(*startData);
   115     aNotifier->PublishStartL(*startData);
   112 
   116 
   113     CleanupStack::PopAndDestroy(startData);
   117     CleanupStack::PopAndDestroy(startData);
   114 
   118 
   128  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   132  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   129  * Method:    _notifyStart
   133  * Method:    _notifyStart
   130  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   134  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   131  */
   135  */
   132 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   136 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   133 (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId,
   137 (JNIEnv *aEnv, jclass, jint aHandle, jint aOperation,
   134  jstring aComponentName, jobjectArray aApplicationNames,
   138  jstring aGlobalComponentId, jstring aComponentName,
   135  jobjectArray aApplicationIcons, jint aComponentSize,
   139  jobjectArray aApplicationNames, jobjectArray aApplicationIcons,
   136  jstring aIconDir, jstring aComponentIcon)
   140  jint aComponentSize, jstring aIconDir, jstring aComponentIcon)
   137 {
   141 {
   138     CPublishSifOperationInfo *pNotifier =
   142     CPublishSifOperationInfo *pNotifier =
   139         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   143         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   140     TRAPD(err, NotifyStartL(aEnv, pNotifier, aGlobalComponentId, aComponentName,
   144     TRAPD(err, NotifyStartL(aEnv, pNotifier, aOperation, aGlobalComponentId,
   141                             aApplicationNames, aApplicationIcons,
   145                             aComponentName, aApplicationNames,
   142                             aComponentSize, aIconDir, aComponentIcon));
   146                             aApplicationIcons, aComponentSize,
       
   147                             aIconDir, aComponentIcon));
   143     return err;
   148     return err;
   144 }
   149 }
   145 
   150 
   146 /**
   151 /**
   147  * See JNI method __1notifyEnd.
   152  * See JNI method __1notifyEnd.
   295         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   300         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   296     delete pNotifier;
   301     delete pNotifier;
   297     return KErrNone;
   302     return KErrNone;
   298 }
   303 }
   299 
   304 
       
   305 /*
       
   306  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   307  * Method:    _initIndicator
       
   308  * Signature: ()I
       
   309  */
       
   310 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1initIndicator
       
   311 (JNIEnv *, jclass)
       
   312 {
       
   313     CHbIndicatorSymbian *pIndicator = NULL;
       
   314     TRAPD(err, pIndicator = CHbIndicatorSymbian::NewL());
       
   315     if (KErrNone != err)
       
   316     {
       
   317         ELOG1(EJavaInstaller,
       
   318               "SifNotifier.initIndicator: Creating indicator failed, error %d",
       
   319               err);
       
   320         return err;
       
   321     }
       
   322     // Return handle to the object. Utilize the fact that in Symbian
       
   323     // all pointer addresses are MOD 4 so the last 2 bits are 0
       
   324     // and can be shifted out. This way the returned handle is
       
   325     // always positive whereas Symbian error codes are always negative.
       
   326     return reinterpret_cast<TUint>(pIndicator)>>2;
       
   327 }
       
   328 
       
   329 /**
       
   330  * See JNI method __1updateIndicator.
       
   331  * This method makes calls that may leave (the actual notifying).
       
   332  */
       
   333 void UpdateIndicatorL(
       
   334     JNIEnv *aEnv, CHbIndicatorSymbian *pIndicator, jstring aName, jint aPhase, jint aProgress)
       
   335 {
       
   336     HBufC *name = CreateHBufCFromJavaStringLC(aEnv, aName);
       
   337 
       
   338     CHbSymbianVariantMap *variantMap = CHbSymbianVariantMap::NewL();
       
   339     CleanupStack::PushL(variantMap);
       
   340     CHbSymbianVariant *variantName = CHbSymbianVariant::NewL(name, CHbSymbianVariant::EDes);
       
   341     variantMap->Add(KSifUiInstallIndicatorAppName, variantName);
       
   342     CHbSymbianVariant *variantPhase = CHbSymbianVariant::NewL(&aPhase, CHbSymbianVariant::EInt);
       
   343     variantMap->Add(KSifUiInstallIndicatorPhase, variantPhase);
       
   344     CHbSymbianVariant *variantProgress = CHbSymbianVariant::NewL(&aProgress, CHbSymbianVariant::EInt);
       
   345     variantMap->Add(KSifUiInstallIndicatorProgress, variantProgress);
       
   346 
       
   347     CHbSymbianVariant *variant = CHbSymbianVariant::NewL(variantMap, CHbSymbianVariant::EVariantMap);
       
   348     CleanupStack::PushL(variant);
       
   349 
       
   350     TInt err = KErrNone;
       
   351     if (!pIndicator->Activate(KSifUiInstallIndicatorType, variant))
       
   352     {
       
   353         err = pIndicator->Error();
       
   354         ELOG1(EJavaInstaller,
       
   355               "SifNotifier.updateIndicator: activating indicator failed, error %d",
       
   356               err);
       
   357         err = KErrGeneral;
       
   358     }
       
   359 
       
   360     CleanupStack::PopAndDestroy(variant);
       
   361     CleanupStack::PopAndDestroy(variantMap);
       
   362     CleanupStack::PopAndDestroy(name);
       
   363 }
       
   364 
       
   365 /*
       
   366  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   367  * Method:    _updateIndicator
       
   368  * Signature: ()I
       
   369  */
       
   370 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1updateIndicator
       
   371 (JNIEnv *aEnv, jclass, jint aHandle, jstring aName, jint aPhase, jint aProgress)
       
   372 {
       
   373     CHbIndicatorSymbian *pIndicator =
       
   374         reinterpret_cast<CHbIndicatorSymbian*>(aHandle<<2);
       
   375     TRAPD(err, UpdateIndicatorL(aEnv, pIndicator, aName, aPhase, aProgress));
       
   376     return err;
       
   377 }
       
   378 
       
   379 /*
       
   380  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   381  * Method:    _destroyIndicator
       
   382  * Signature: (II)I
       
   383  */
       
   384 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1destroyIndicator
       
   385 (JNIEnv *, jclass, jint aHandle, jint aState)
       
   386 {
       
   387     CHbIndicatorSymbian *pIndicator =
       
   388         reinterpret_cast<CHbIndicatorSymbian*>(aHandle<<2);
       
   389     TInt err = KErrNone;
       
   390     if (aState && !pIndicator->Deactivate(KSifUiInstallIndicatorType))
       
   391     {
       
   392         err = pIndicator->Error();
       
   393         ELOG1(EJavaInstaller,
       
   394               "SifNotifier.destroyIndicator: Deactivating indicator failed, error %d",
       
   395               err);
       
   396         err = KErrGeneral;
       
   397     }
       
   398     delete pIndicator;
       
   399     return err;
       
   400 }
       
   401 
   300 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   402 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   301 
   403 
   302 /*
   404 /*
   303  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   405  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   304  * Method:    _sifNotifierEnabled
   406  * Method:    _sifNotifierEnabled
   314  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   416  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   315  * Method:    _notifyStart
   417  * Method:    _notifyStart
   316  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   418  * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)I
   317  */
   419  */
   318 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   420 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyStart
   319 (JNIEnv *, jclass, jint, jstring, jstring, jobjectArray, jobjectArray, jint, jstring, jstring)
   421 (JNIEnv *, jclass, jint, jint, jstring, jstring, jobjectArray, jobjectArray, jint, jstring, jstring)
   320 {
   422 {
   321     LOG(EJavaInstaller, EInfo, "SifNotifier.notifyStart");
   423     LOG(EJavaInstaller, EInfo, "SifNotifier.notifyStart");
   322     return KErrNone;
   424     return KErrNone;
   323 }
   425 }
   324 
   426 
   379 {
   481 {
   380     LOG(EJavaInstaller, EInfo, "SifNotifier.destroy");
   482     LOG(EJavaInstaller, EInfo, "SifNotifier.destroy");
   381     return KErrNone;
   483     return KErrNone;
   382 }
   484 }
   383 
   485 
       
   486 /*
       
   487  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   488  * Method:    _initIndicator
       
   489  * Signature: ()I
       
   490  */
       
   491 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1initIndicator
       
   492 (JNIEnv *, jclass)
       
   493 {
       
   494     LOG(EJavaInstaller, EInfo, "SifNotifier.initIndicator");
       
   495     return 1; // return dummy object handle
       
   496 }
       
   497 
       
   498 /*
       
   499  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   500  * Method:    _updateIndicator
       
   501  * Signature: ()I
       
   502  */
       
   503 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1updateIndicator
       
   504 (JNIEnv *, jclass, jint, jstring, jint, jint)
       
   505 {
       
   506     LOG(EJavaInstaller, EInfo, "SifNotifier.updateIndicator");
       
   507     return KErrNone;
       
   508 }
       
   509 
       
   510 /*
       
   511  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
       
   512  * Method:    _destroyIndicator
       
   513  * Signature: (II)I
       
   514  */
       
   515 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1destroyIndicator
       
   516 (JNIEnv *, jclass, jint, jint)
       
   517 {
       
   518     LOG(EJavaInstaller, EInfo, "SifNotifier.destroyIndicator");
       
   519     return KErrNone;
       
   520 }
       
   521 
   384 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   522 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK