javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp
branchRCL_3
changeset 24 6c158198356e
parent 18 9ac0a0a7da70
equal deleted inserted replaced
23:e5618cc85d74 24:6c158198356e
    19 #include "com_nokia_mj_impl_installer_applicationregistrator_SifNotifier.h"
    19 #include "com_nokia_mj_impl_installer_applicationregistrator_SifNotifier.h"
    20 #include "javacommonutils.h"
    20 #include "javacommonutils.h"
    21 #include "javasymbianoslayer.h" // for CleanupResetAndDestroyPushL
    21 #include "javasymbianoslayer.h" // for CleanupResetAndDestroyPushL
    22 #include "logger.h"
    22 #include "logger.h"
    23 
    23 
    24 #if defined(SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK) && defined(RD_JAVA_USIF_NOTIFY_PROGRESS)
    24 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    25 
    25 
    26 #include <usif/sif/sifnotification.h>
    26 #include <usif/sif/sifnotification.h>
    27 #include <usif/usifcommon.h>
    27 #include <usif/usifcommon.h>
    28 
       
    29 // Helper macro for logging a TDesC.
       
    30 #define LOG_TDESC_L(compIdParam, logLevelParam, msgParam, tdescParam) \
       
    31     {                                                               \
       
    32         HBufC8* tdescBuf = HBufC8::NewLC(tdescParam.Length() + 1);  \
       
    33         TPtr8 tdescPtr(tdescBuf->Des());                            \
       
    34         tdescPtr.Append(tdescParam);                                \
       
    35         LOG1(compIdParam, logLevelParam, msgParam, tdescPtr.PtrZ());\
       
    36         CleanupStack::PopAndDestroy(tdescBuf);                      \
       
    37     }
       
    38 
    28 
    39 // NAMESPACE DECLARATION
    29 // NAMESPACE DECLARATION
    40 using namespace java;
    30 using namespace java;
    41 using namespace Usif;
    31 using namespace Usif;
    42 
    32 
    99             if (NULL != tmpAppIcon)
    89             if (NULL != tmpAppIcon)
   100             {
    90             {
   101                 HBufC *appIcon = CreateHBufCFromJavaStringLC(aEnv, tmpAppIcon);
    91                 HBufC *appIcon = CreateHBufCFromJavaStringLC(aEnv, tmpAppIcon);
   102                 applicationIcons.AppendL(appIcon);
    92                 applicationIcons.AppendL(appIcon);
   103                 CleanupStack::Pop(appIcon);
    93                 CleanupStack::Pop(appIcon);
       
    94                 aEnv->DeleteLocalRef(tmpAppIcon);
   104             }
    95             }
   105             else
    96             else
   106             {
    97             {
   107                 // Add a string indicating that icon is not available
    98                 // Add a string indicating that icon is not available
   108                 // for this application.
    99                 // for this application.
   159 void NotifyEndL(
   150 void NotifyEndL(
   160     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier,
   151     JNIEnv *aEnv, CPublishSifOperationInfo *aNotifier,
   161     jstring aGlobalComponentId, jint aErrCategory, jint aErrCode,
   152     jstring aGlobalComponentId, jint aErrCategory, jint aErrCode,
   162     jstring aErrMsg, jstring aErrMsgDetails)
   153     jstring aErrMsg, jstring aErrMsgDetails)
   163 {
   154 {
   164     __UHEAP_MARK;
   155     //__UHEAP_MARK;
   165     HBufC *globalComponentId = CreateHBufCFromJavaStringLC(aEnv, aGlobalComponentId);
   156     HBufC *globalComponentId = CreateHBufCFromJavaStringLC(aEnv, aGlobalComponentId);
   166     HBufC *errMsg = NULL;
   157     HBufC *errMsg = NULL;
   167     if (NULL != aErrMsg)
   158     if (NULL != aErrMsg)
   168     {
   159     {
   169         errMsg = CreateHBufCFromJavaStringLC(aEnv, aErrMsg);
   160         errMsg = CreateHBufCFromJavaStringLC(aEnv, aErrMsg);
   172     if (NULL != aErrMsgDetails)
   163     if (NULL != aErrMsgDetails)
   173     {
   164     {
   174         errMsgDetails = CreateHBufCFromJavaStringLC(aEnv, aErrMsgDetails);
   165         errMsgDetails = CreateHBufCFromJavaStringLC(aEnv, aErrMsgDetails);
   175     }
   166     }
   176 
   167 
   177     CSifOperationEndData *endData = CSifOperationEndData::NewLC(
   168     CSifOperationEndData *endData =
   178                                         *globalComponentId, (TErrorCategory)aErrCategory, aErrCode,
   169         CSifOperationEndData::NewLC(
   179                                         *errMsg, *errMsgDetails);
   170             *globalComponentId, (TErrorCategory)aErrCategory, aErrCode,
   180 
   171             (NULL != errMsg? *errMsg: KNullDesC()),
       
   172             (NULL != errMsgDetails? *errMsgDetails: KNullDesC()));
       
   173 
       
   174     // Do not use UHEAP macros around PublishCompletionL() because it
       
   175     // creates a timer object which gets deleted only when the notifier
       
   176     // object is deleted.
   181     aNotifier->PublishCompletionL(*endData);
   177     aNotifier->PublishCompletionL(*endData);
   182 
   178 
   183     CleanupStack::PopAndDestroy(endData);
   179     CleanupStack::PopAndDestroy(endData);
   184 
   180 
   185     if (NULL != aErrMsg)
   181     if (NULL != errMsgDetails)
       
   182     {
       
   183         CleanupStack::PopAndDestroy(errMsgDetails);
       
   184     }
       
   185     if (NULL != errMsg)
   186     {
   186     {
   187         CleanupStack::PopAndDestroy(errMsg);
   187         CleanupStack::PopAndDestroy(errMsg);
   188     }
   188     }
   189     if (NULL != aErrMsgDetails)
       
   190     {
       
   191         CleanupStack::PopAndDestroy(errMsgDetails);
       
   192     }
       
   193     CleanupStack::PopAndDestroy(globalComponentId);
   189     CleanupStack::PopAndDestroy(globalComponentId);
   194     __UHEAP_MARKEND;
   190     //__UHEAP_MARKEND;
   195 }
   191 }
   196 
   192 
   197 /*
   193 /*
   198  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   194  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   199  * Method:    _notifyEnd
   195  * Method:    _notifyEnd
   201  */
   197  */
   202 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyEnd
   198 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifNotifier__1notifyEnd
   203 (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId,
   199 (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId,
   204  jint aErrCategory, jint aErrCode, jstring aErrMsg, jstring aErrMsgDetails)
   200  jint aErrCategory, jint aErrCode, jstring aErrMsg, jstring aErrMsgDetails)
   205 {
   201 {
       
   202     CActiveScheduler* newScheduler = 0;
       
   203     if (0 == CActiveScheduler::Current())
       
   204     {
       
   205         // Create ActiveScheduler as it does not yet exist.
       
   206         newScheduler = new CActiveScheduler;
       
   207         CActiveScheduler::Install(newScheduler);
       
   208     }
       
   209 
   206     CPublishSifOperationInfo *pNotifier =
   210     CPublishSifOperationInfo *pNotifier =
   207         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   211         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   208     TRAPD(err, NotifyEndL(aEnv, pNotifier, aGlobalComponentId,
   212     TRAPD(err, NotifyEndL(aEnv, pNotifier, aGlobalComponentId,
   209                           aErrCategory, aErrCode, aErrMsg, aErrMsgDetails));
   213                           aErrCategory, aErrCode, aErrMsg, aErrMsgDetails));
       
   214 
       
   215     if (newScheduler)
       
   216     {
       
   217         delete newScheduler;
       
   218         newScheduler = 0;
       
   219     }
       
   220 
   210     return err;
   221     return err;
   211 }
   222 }
   212 
   223 
   213 /**
   224 /**
   214  * See JNI method __1notifyProgress.
   225  * See JNI method __1notifyProgress.
   284         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   295         reinterpret_cast<CPublishSifOperationInfo*>(aHandle<<2);
   285     delete pNotifier;
   296     delete pNotifier;
   286     return KErrNone;
   297     return KErrNone;
   287 }
   298 }
   288 
   299 
   289 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK && RD_JAVA_USIF_NOTIFY_PROGRESS
   300 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   290 
   301 
   291 /*
   302 /*
   292  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   303  * Class:     com_nokia_mj_impl_installer_applicationregistrator_SifNotifier
   293  * Method:    _sifNotifierEnabled
   304  * Method:    _sifNotifierEnabled
   294  * Signature: ()Z
   305  * Signature: ()Z
   368 {
   379 {
   369     LOG(EJavaInstaller, EInfo, "SifNotifier.destroy");
   380     LOG(EJavaInstaller, EInfo, "SifNotifier.destroy");
   370     return KErrNone;
   381     return KErrNone;
   371 }
   382 }
   372 
   383 
   373 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK && RD_JAVA_USIF_NOTIFY_PROGRESS
   384 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK