javauis/nokiauiapi_qt/src/os.cpp
changeset 87 1627c337e51e
parent 78 71ad690e91f5
equal deleted inserted replaced
80:d6dafc5d983f 87:1627c337e51e
    12 #include <QWidget>
    12 #include <QWidget>
    13 #include <coecntrl.h>
    13 #include <coecntrl.h>
    14 #include <touchfeedback.h>
    14 #include <touchfeedback.h>
    15 #include <com_nokia_mj_impl_nokiauiapi_OS.h>
    15 #include <com_nokia_mj_impl_nokiauiapi_OS.h>
    16 #include "autorelease.h"
    16 #include "autorelease.h"
    17 #include "csoftnotification.h"
    17 #include "CSoftNotification.h"
    18 
    18 
    19 static CCoeControl* convertToSymbian(QWidget* window)
    19 static CCoeControl* convertToSymbian(QWidget* window)
    20     {
    20     {
    21     CCoeControl* control = 0;
    21     CCoeControl* control = 0;
    22     if (window && window->winId())
    22     if (window && window->winId())
   170 
   170 
   171 JNIEXPORT jint JNICALL
   171 JNIEXPORT jint JNICALL
   172 Java_com_nokia_mj_impl_nokiauiapi_OS_setText(JNIEnv* aJniEnv, jclass /*aPeer*/,
   172 Java_com_nokia_mj_impl_nokiauiapi_OS_setText(JNIEnv* aJniEnv, jclass /*aPeer*/,
   173         jint aSoftNotificationHandle, jstring aPrimaryText, jstring aSecondaryText)
   173         jint aSoftNotificationHandle, jstring aPrimaryText, jstring aSecondaryText)
   174     {
   174     {
       
   175     if (aPrimaryText == NULL || aSecondaryText == NULL)
       
   176         {
       
   177         // These arguments are checked already on Java side, no need to try
       
   178         // to recover from NULL strings.
       
   179         return KErrArgument;
       
   180         }
       
   181         
   175     CSoftNotification* softNotification =
   182     CSoftNotification* softNotification =
   176             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   183             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   177     // Convert from java string to Symbian descriptor
   184     // Convert from java string to Symbian descriptor
   178     HBufC* bufferPrimaryText = NULL;
   185     HBufC* bufferPrimaryText = NULL;
   179     if (aPrimaryText != NULL)
   186     bufferPrimaryText = JavaStringToSymbianString(aJniEnv, aPrimaryText);
   180         {
   187     if (bufferPrimaryText == NULL)
   181         bufferPrimaryText = JavaStringToSymbianString(aJniEnv, aPrimaryText);
   188         {
   182         if (bufferPrimaryText == NULL)
   189         return KErrNoMemory;
   183             {
       
   184             return KErrNoMemory;
       
   185             }
       
   186         }
   190         }
   187 
   191 
   188     HBufC* bufferSecondaryText = NULL;
   192     HBufC* bufferSecondaryText = NULL;
   189     if (aSecondaryText != NULL)
   193     bufferSecondaryText = JavaStringToSymbianString(aJniEnv,
   190         {
   194             aSecondaryText);
   191         bufferSecondaryText = JavaStringToSymbianString(aJniEnv,
   195     if (bufferSecondaryText == NULL)
   192                 aSecondaryText);
   196         {
   193         if (bufferSecondaryText == NULL)
   197         return KErrNoMemory;
   194             {
   198         }
   195             return KErrNoMemory;
   199 
   196             }
       
   197         }
       
   198     TRAPD(err,softNotification->SetTextL(*bufferPrimaryText, *bufferSecondaryText));
   200     TRAPD(err,softNotification->SetTextL(*bufferPrimaryText, *bufferSecondaryText));
   199     return err;
   201     return err;
   200     }
   202     }
   201 
   203 
   202 JNIEXPORT jint JNICALL
   204 JNIEXPORT jint JNICALL
   230 
   232 
   231 JNIEXPORT jint JNICALL
   233 JNIEXPORT jint JNICALL
   232 Java_com_nokia_mj_impl_nokiauiapi_OS_setImagePath(JNIEnv* aJniEnv,
   234 Java_com_nokia_mj_impl_nokiauiapi_OS_setImagePath(JNIEnv* aJniEnv,
   233         jclass /*aPeer*/, jint aSoftNotificationHandle, jstring aImagePath )
   235         jclass /*aPeer*/, jint aSoftNotificationHandle, jstring aImagePath )
   234     {
   236     {
       
   237     if (aImagePath == NULL)
       
   238         {
       
   239         return KErrArgument;
       
   240         }
       
   241         
   235     CSoftNotification* softNotification =
   242     CSoftNotification* softNotification =
   236     reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   243     reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   237     // Convert from java string to Symbian descriptor
   244     // Convert from java string to Symbian descriptor
   238     HBufC* bufferImagePath = NULL;
   245     HBufC* bufferImagePath = NULL;
   239     if (aImagePath != NULL)
   246     bufferImagePath = JavaStringToSymbianString(aJniEnv, aImagePath);
   240         {
   247     if (bufferImagePath == NULL)
   241         bufferImagePath = JavaStringToSymbianString(aJniEnv, aImagePath);
   248         {
   242         if (bufferImagePath == NULL)
   249         return KErrNoMemory;
   243             {
   250         }
   244             return KErrNoMemory;
   251 
   245             }
       
   246         }
       
   247     TRAPD(err,softNotification->SetImagePathL(*bufferImagePath));
   252     TRAPD(err,softNotification->SetImagePathL(*bufferImagePath));
   248     return err;
   253     return err;
   249     }
   254     }
   250 
   255 
   251 JNIEXPORT void JNICALL
   256 JNIEXPORT void JNICALL