javaextensions/pim/jni/src/eventimpl.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EventImpl JNI wrapper.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 
       
    21 #include "com_nokia_mj_impl_pim_EventImpl.h"
       
    22 #include "pimbasemanager.h"
       
    23 #include "pimbaseitem.h"
       
    24 #include "pimbaserepeatrule.h"
       
    25 #include "pimcommon.h"
       
    26 #include "pimutils.h"
       
    27 #include "pimpanics.h"
       
    28 #include "logger.h"
       
    29 
       
    30 JNIEXPORT jint
       
    31 JNICALL Java_com_nokia_mj_impl_pim_EventImpl__1createNativePeer(
       
    32     JNIEnv* aJniEnv,
       
    33     jobject /*aPeer*/,
       
    34     jint aManagerHandle,
       
    35     jintArray aRepeatRuleHandle,
       
    36     jintArray aError)
       
    37 {
       
    38     JELOG2(EPim);
       
    39     pimbasemanager* pimManager = reinterpret_cast< pimbasemanager*>(aManagerHandle);
       
    40     pimbaseitem* eventItem;
       
    41     int error = 0;
       
    42     try
       
    43     {
       
    44         eventItem = pimbaseitem::getEventItemInstance(pimManager);
       
    45     }
       
    46     catch (int aErr)
       
    47     {
       
    48         error = aErr;
       
    49         SetJavaErrorCode(aJniEnv, aError, error);
       
    50         return 0;
       
    51     }
       
    52     SetJavaErrorCode(aJniEnv, aError, error);
       
    53     int eventItemHandle = reinterpret_cast<int>(eventItem);
       
    54 
       
    55     int repeatRuleHandle = eventItem->getRepeatHandle();
       
    56     aJniEnv->SetIntArrayRegion(aRepeatRuleHandle, 0, 1, &repeatRuleHandle);
       
    57 
       
    58     // Ownership of the item is transferred to the Java side peer object
       
    59     return eventItemHandle;
       
    60 }
       
    61 
       
    62 JNIEXPORT jboolean
       
    63 JNICALL Java_com_nokia_mj_impl_pim_EventImpl__1isRepeating(
       
    64     JNIEnv* /*aJniEnv*/,
       
    65     jobject /*aPeer*/,
       
    66     jint aEventHandle)
       
    67 {
       
    68     JELOG2(EPim);
       
    69     pimbaseitem* eventItem = reinterpret_cast< pimbaseitem*>(aEventHandle);
       
    70     bool isRepeating = eventItem->isItemRepeating();
       
    71     return isRepeating;
       
    72 }
       
    73 
       
    74 JNIEXPORT void
       
    75 JNICALL Java_com_nokia_mj_impl_pim_EventImpl__1setRepeating(
       
    76     JNIEnv* /*aJniEnv*/,
       
    77     jobject /*aPeer*/,
       
    78     jint aEventHandle,
       
    79     jboolean aSetRepeating)
       
    80 {
       
    81     JELOG2(EPim);
       
    82     pimbaseitem* eventItem = reinterpret_cast< pimbaseitem *>(aEventHandle);
       
    83     eventItem->setItemRepeating(aSetRepeating);
       
    84 }
       
    85 
       
    86 JNIEXPORT void
       
    87 JNICALL Java_com_nokia_mj_impl_pim_EventImpl__1clearRepeatRule(
       
    88     JNIEnv* /*aJniEnv*/,
       
    89     jobject /*aPeer*/,
       
    90     jint aRepeatRuleHandle)
       
    91 {
       
    92     JELOG2(EPim);
       
    93     pimbaserepeatrule* repeatRule = reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
    94     repeatRule->clear();
       
    95 }
       
    96 
       
    97 // End of File