javauis/nokiauiapi_qt/src/os.cpp
changeset 78 71ad690e91f5
parent 72 1f0034e370aa
child 87 1627c337e51e
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
    10  *******************************************************************************/
    10  *******************************************************************************/
    11 
    11 
    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_mid_ui_internal_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     {
    24         control = reinterpret_cast<CCoeControl*> (window->winId());
    24         control = reinterpret_cast<CCoeControl*> (window->winId());
    25         }
    25         }
    26     return control;
    26     return control;
    27     }
    27     }
    28 
    28 
    29 JNIEXPORT void JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1InstantFeedback(
    29 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1InstantFeedback(
    30         JNIEnv *, jclass, jint aStyle)
    30         JNIEnv *, jclass, jint aStyle)
    31     {
    31     {
    32     MTouchFeedback* feedback = MTouchFeedback::Instance();
    32     MTouchFeedback* feedback = MTouchFeedback::Instance();
    33     if (feedback)
    33     if (feedback)
    34         {
    34         {
    35         feedback->InstantFeedback(static_cast<TTouchLogicalFeedback> (aStyle));
    35         feedback->InstantFeedback(static_cast<TTouchLogicalFeedback> (aStyle));
    36         }
    36         }
    37     }
    37     }
    38 
    38 
    39 JNIEXPORT jboolean JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1TouchFeedbackSupported(
    39 JNIEXPORT jboolean JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1TouchFeedbackSupported(
    40         JNIEnv *, jclass)
    40         JNIEnv *, jclass)
    41     {
    41     {
    42     jboolean enabled = JNI_FALSE;
    42     jboolean enabled = JNI_FALSE;
    43     MTouchFeedback* feedback = MTouchFeedback::Instance();
    43     MTouchFeedback* feedback = MTouchFeedback::Instance();
    44     if (feedback)
    44     if (feedback)
    46         enabled = feedback->TouchFeedbackSupported() ? JNI_TRUE : JNI_FALSE;
    46         enabled = feedback->TouchFeedbackSupported() ? JNI_TRUE : JNI_FALSE;
    47         }
    47         }
    48     return enabled;
    48     return enabled;
    49     }
    49     }
    50 
    50 
    51 JNIEXPORT void JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1SetFeedbackArea(
    51 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1SetFeedbackArea(
    52         JNIEnv *, jclass, jint aControl, jint aAreaIndex, jint aX, jint aY,
    52         JNIEnv *, jclass, jint aControl, jint aAreaIndex, jint aX, jint aY,
    53         jint aWidth, jint aHeight, jint aStyle)
    53         jint aWidth, jint aHeight, jint aStyle)
    54     {
    54     {
    55     MTouchFeedback* feedback = MTouchFeedback::Instance();
    55     MTouchFeedback* feedback = MTouchFeedback::Instance();
    56     if (feedback)
    56     if (feedback)
    62                 feedbackRect, static_cast<TTouchLogicalFeedback> (aStyle),
    62                 feedbackRect, static_cast<TTouchLogicalFeedback> (aStyle),
    63                 ETouchEventStylusDown);
    63                 ETouchEventStylusDown);
    64         }
    64         }
    65     }
    65     }
    66 
    66 
    67 JNIEXPORT void JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1RemoveFeedbackArea(
    67 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1RemoveFeedbackArea(
    68         JNIEnv *, jclass, jint aControl, jint aAreaIndex)
    68         JNIEnv *, jclass, jint aControl, jint aAreaIndex)
    69     {
    69     {
    70     MTouchFeedback* feedback = MTouchFeedback::Instance();
    70     MTouchFeedback* feedback = MTouchFeedback::Instance();
    71     if (feedback)
    71     if (feedback)
    72         {
    72         {
    74                 reinterpret_cast<QWidget*> (aControl));
    74                 reinterpret_cast<QWidget*> (aControl));
    75         feedback->RemoveFeedbackArea(control, aAreaIndex);
    75         feedback->RemoveFeedbackArea(control, aAreaIndex);
    76         }
    76         }
    77     }
    77     }
    78 
    78 
    79 JNIEXPORT void JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1RemoveFeedbackForControl(
    79 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1RemoveFeedbackForControl(
    80         JNIEnv *, jclass, jint aControl)
    80         JNIEnv *, jclass, jint aControl)
    81     {
    81     {
    82     MTouchFeedback* feedback = MTouchFeedback::Instance();
    82     MTouchFeedback* feedback = MTouchFeedback::Instance();
    83     if (feedback)
    83     if (feedback)
    84         {
    84         {
    86                 reinterpret_cast<QWidget*> (aControl));
    86                 reinterpret_cast<QWidget*> (aControl));
    87         feedback->RemoveFeedbackForControl(control);
    87         feedback->RemoveFeedbackForControl(control);
    88         }
    88         }
    89     }
    89     }
    90 
    90 
    91 JNIEXPORT void JNICALL Java_com_nokia_mid_ui_internal_OS_MTouchFeedback_1MoveFeedbackAreaToFirstPriority(
    91 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_MTouchFeedback_1MoveFeedbackAreaToFirstPriority(
    92         JNIEnv *, jclass, jint aControl, jint aAreaIndex)
    92         JNIEnv *, jclass, jint aControl, jint aAreaIndex)
    93     {
    93     {
    94     MTouchFeedback* feedback = MTouchFeedback::Instance();
    94     MTouchFeedback* feedback = MTouchFeedback::Instance();
    95     if (feedback)
    95     if (feedback)
    96         {
    96         {
    99         feedback->MoveFeedbackAreaToFirstPriority(control,
    99         feedback->MoveFeedbackAreaToFirstPriority(control,
   100                 static_cast<TUint32> (aAreaIndex));
   100                 static_cast<TUint32> (aAreaIndex));
   101         }
   101         }
   102     }
   102     }
   103 
   103 
   104 JNIEXPORT jint JNICALL Java_com_nokia_mid_ui_internal_OS_createNativePeer(
   104 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_nokiauiapi_OS_createNativePeer(
   105         JNIEnv* aJniEnv, jclass /*aClazz*/, jint aMidletId,
   105         JNIEnv* aJniEnv, jclass /*aClazz*/, jint aMidletId,
   106         jint aNotificationId, jobject aPeer)
   106         jint aNotificationId, jobject aPeer)
   107     {
   107     {
   108     jobject peer = aJniEnv->NewWeakGlobalRef(aPeer);
   108     jobject peer = aJniEnv->NewWeakGlobalRef(aPeer);
   109     if (!peer)
   109     if (!peer)
   128     aJniEnv->DeleteLocalRef(clazz);
   128     aJniEnv->DeleteLocalRef(clazz);
   129     return reinterpret_cast<jint> (softNote);
   129     return reinterpret_cast<jint> (softNote);
   130     }
   130     }
   131 
   131 
   132 JNIEXPORT jint JNICALL
   132 JNIEXPORT jint JNICALL
   133 Java_com_nokia_mid_ui_internal_OS_getId(JNIEnv* /*aJniEnv*/,
   133 Java_com_nokia_mj_impl_nokiauiapi_OS_getId(JNIEnv* /*aJniEnv*/,
   134         jclass /*aPeer*/, jint aSoftNotificationHandle)
   134         jclass /*aPeer*/, jint aSoftNotificationHandle)
   135     {
   135     {
   136     CSoftNotification* softNotification =
   136     CSoftNotification* softNotification =
   137             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   137             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   138     return softNotification->Id();
   138     return softNotification->Id();
   167         
   167         
   168     return bufferText;
   168     return bufferText;
   169     }
   169     }
   170 
   170 
   171 JNIEXPORT jint JNICALL
   171 JNIEXPORT jint JNICALL
   172 Java_com_nokia_mid_ui_internal_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     CSoftNotification* softNotification =
   175     CSoftNotification* softNotification =
   176             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   176             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   177     // Convert from java string to Symbian descriptor
   177     // Convert from java string to Symbian descriptor
   198     TRAPD(err,softNotification->SetTextL(*bufferPrimaryText, *bufferSecondaryText));
   198     TRAPD(err,softNotification->SetTextL(*bufferPrimaryText, *bufferSecondaryText));
   199     return err;
   199     return err;
   200     }
   200     }
   201 
   201 
   202 JNIEXPORT jint JNICALL
   202 JNIEXPORT jint JNICALL
   203 Java_com_nokia_mid_ui_internal_OS_removeSoftNotification(JNIEnv* /*aJniEnv*/,
   203 Java_com_nokia_mj_impl_nokiauiapi_OS_removeSoftNotification(JNIEnv* /*aJniEnv*/,
   204         jclass /*aPeer*/, jint aSoftNotificationHandle)
   204         jclass /*aPeer*/, jint aSoftNotificationHandle)
   205     {
   205     {
   206     CSoftNotification* softNotification =
   206     CSoftNotification* softNotification =
   207             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   207             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   208     TRAPD(err,softNotification->RemoveSoftNotificationL());
   208     TRAPD(err,softNotification->RemoveSoftNotificationL());
   209     delete softNotification;
   209     delete softNotification;
   210     return err;
   210     return err;
   211     }
   211     }
   212 
   212 
   213 JNIEXPORT jint JNICALL
   213 JNIEXPORT jint JNICALL
   214 Java_com_nokia_mid_ui_internal_OS_showSoftNotification(JNIEnv* /*aJniEnv*/,
   214 Java_com_nokia_mj_impl_nokiauiapi_OS_showSoftNotification(JNIEnv* /*aJniEnv*/,
   215         jclass /*aPeer*/, jint aSoftNotificationHandle)
   215         jclass /*aPeer*/, jint aSoftNotificationHandle)
   216     {
   216     {
   217     CSoftNotification* softNotification =
   217     CSoftNotification* softNotification =
   218             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   218             reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   219     jboolean status(false);
   219     jboolean status(false);
   227         return KErrNone;
   227         return KErrNone;
   228         }
   228         }
   229     }
   229     }
   230 
   230 
   231 JNIEXPORT jint JNICALL
   231 JNIEXPORT jint JNICALL
   232 Java_com_nokia_mid_ui_internal_OS_setImagePath(JNIEnv* aJniEnv,
   232 Java_com_nokia_mj_impl_nokiauiapi_OS_setImagePath(JNIEnv* aJniEnv,
   233         jclass /*aPeer*/, jint aSoftNotificationHandle, jstring aImagePath )
   233         jclass /*aPeer*/, jint aSoftNotificationHandle, jstring aImagePath )
   234     {
   234     {
   235     CSoftNotification* softNotification =
   235     CSoftNotification* softNotification =
   236     reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   236     reinterpret_cast<CSoftNotification*> (aSoftNotificationHandle);
   237     // Convert from java string to Symbian descriptor
   237     // Convert from java string to Symbian descriptor
   247     TRAPD(err,softNotification->SetImagePathL(*bufferImagePath));
   247     TRAPD(err,softNotification->SetImagePathL(*bufferImagePath));
   248     return err;
   248     return err;
   249     }
   249     }
   250 
   250 
   251 JNIEXPORT void JNICALL
   251 JNIEXPORT void JNICALL
   252 Java_com_nokia_mid_ui_internal_OS_destroy(JNIEnv* /*aJniEnv*/,
   252 Java_com_nokia_mj_impl_nokiauiapi_OS_destroy(JNIEnv* /*aJniEnv*/,
   253         jclass /*clazz*/, jint aSoftNotificationHandle)
   253         jclass /*clazz*/, jint aSoftNotificationHandle)
   254     {
   254     {
   255     if (aSoftNotificationHandle > KErrNone)
   255     if (aSoftNotificationHandle > KErrNone)
   256         {
   256         {
   257         CSoftNotification
   257         CSoftNotification