javaextensions/pim/jni/src/repeatrule.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:  RepeatRule JNI wrapper.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 
       
    21 #include "javax_microedition_pim_RepeatRule.h"
       
    22 #include "pimbaserepeatrule.h"
       
    23 #include "pimcommon.h"
       
    24 #include "pimutils.h"
       
    25 #include "logger.h"
       
    26 
       
    27 JNIEXPORT jint
       
    28 JNICALL Java_javax_microedition_pim_RepeatRule__1createRepeatRule(
       
    29     JNIEnv* aJniEnv,
       
    30     jobject /*aPeer*/,
       
    31     jintArray aError)
       
    32 {
       
    33     JELOG2(EPim);
       
    34     pimbaserepeatrule* repeatRule = NULL;
       
    35     int error = 0;
       
    36     try
       
    37     {
       
    38         repeatRule = pimbaserepeatrule::getInstance();
       
    39     }
       
    40     catch (int aError)
       
    41     {
       
    42         error = aError;
       
    43     }
       
    44     SetJavaErrorCode(aJniEnv, aError, error);
       
    45 
       
    46     return reinterpret_cast<int>(repeatRule);
       
    47 }
       
    48 
       
    49 JNIEXPORT void
       
    50 JNICALL Java_javax_microedition_pim_RepeatRule__1dispose(
       
    51     JNIEnv* /*aJniEnv*/,
       
    52     jobject /*aPeer*/,
       
    53     jint aRepeatRuleHandle)
       
    54 {
       
    55     JELOG2(EPim);
       
    56     pimbaserepeatrule* repeatRule =
       
    57         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
    58     delete repeatRule;
       
    59 }
       
    60 
       
    61 JNIEXPORT jintArray
       
    62 JNICALL Java_javax_microedition_pim_RepeatRule__1dates(
       
    63     JNIEnv* aJniEnv,
       
    64     jobject /*aPeer*/,
       
    65     jint aRepeatRuleHandle,
       
    66     jlong aStartDate,
       
    67     jlong aSubsetBeginning,
       
    68     jlong aSubsetEnding)
       
    69 {
       
    70     JELOG2(EPim);
       
    71     pimbaserepeatrule* repeatRule =
       
    72         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
    73     jintArray repeatDatesIntArray = repeatRule->dates(
       
    74                                         aStartDate,
       
    75                                         aSubsetBeginning,
       
    76                                         aSubsetEnding,
       
    77                                         aJniEnv);
       
    78 
       
    79     return repeatDatesIntArray;
       
    80 }
       
    81 
       
    82 JNIEXPORT void
       
    83 JNICALL Java_javax_microedition_pim_RepeatRule__1addExceptDate(
       
    84     JNIEnv* /*aJniEnv*/,
       
    85     jobject /*aPeer*/,
       
    86     jint aRepeatRuleHandle,
       
    87     jlong aValue)
       
    88 {
       
    89     JELOG2(EPim);
       
    90     pimbaserepeatrule* repeatRule =
       
    91         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
    92 
       
    93     repeatRule->addExceptDate(aValue);
       
    94 }
       
    95 
       
    96 JNIEXPORT void
       
    97 JNICALL Java_javax_microedition_pim_RepeatRule__1removeExceptDate(
       
    98     JNIEnv* /*aJniEnv*/,
       
    99     jobject /*aPeer*/,
       
   100     jint aRepeatRuleHandle,
       
   101     jlong aValue)
       
   102 {
       
   103     JELOG2(EPim);
       
   104     pimbaserepeatrule* repeatRule =
       
   105         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   106 
       
   107     repeatRule->removeExceptDate(aValue);
       
   108 }
       
   109 
       
   110 JNIEXPORT jintArray
       
   111 JNICALL Java_javax_microedition_pim_RepeatRule__1getExceptDates(
       
   112     JNIEnv* aJniEnv,
       
   113     jobject /*aPeer*/,
       
   114     jint aRepeatRuleHandle)
       
   115 {
       
   116     JELOG2(EPim);
       
   117     pimbaserepeatrule* repeatRule =
       
   118         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   119 
       
   120     jintArray exceptDatesIntArray = repeatRule->getExceptDates(aJniEnv);
       
   121 
       
   122     return exceptDatesIntArray;
       
   123 }
       
   124 
       
   125 JNIEXPORT jint
       
   126 JNICALL Java_javax_microedition_pim_RepeatRule__1getInt(
       
   127     JNIEnv* aJniEnv,
       
   128     jobject /*aPeer*/,
       
   129     jint aRepeatRuleHandle,
       
   130     jint aField,
       
   131     jintArray aError)
       
   132 {
       
   133     JELOG2(EPim);
       
   134     pimbaserepeatrule* repeatRule =
       
   135         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   136 
       
   137     int retVal = 0;
       
   138     int error = 0;
       
   139     try
       
   140     {
       
   141         retVal = repeatRule->getRepeatInt(aField);
       
   142     }
       
   143     catch (int aError)
       
   144     {
       
   145         error = aError;
       
   146     }
       
   147     SetJavaErrorCode(aJniEnv, aError, error);
       
   148     return retVal;
       
   149 }
       
   150 
       
   151 JNIEXPORT void
       
   152 JNICALL Java_javax_microedition_pim_RepeatRule__1setInt(
       
   153     JNIEnv* aJniEnv,
       
   154     jobject /*aPeer*/,
       
   155     jint aRepeatRuleHandle,
       
   156     jint aField,
       
   157     jint aValue,
       
   158     jintArray aError)
       
   159 {
       
   160     JELOG2(EPim);
       
   161     pimbaserepeatrule* repeatRule =
       
   162         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   163     int error = 0;
       
   164     try
       
   165     {
       
   166         repeatRule->setRepeatInt(aField, aValue);
       
   167     }
       
   168     catch (int aError)
       
   169     {
       
   170         error = aError;
       
   171     }
       
   172 
       
   173     SetJavaErrorCode(aJniEnv, aError, error);
       
   174 }
       
   175 
       
   176 JNIEXPORT jlong
       
   177 JNICALL Java_javax_microedition_pim_RepeatRule__1getDate(
       
   178     JNIEnv* aJniEnv,
       
   179     jobject /*aPeer*/,
       
   180     jint aRepeatRuleHandle,
       
   181     jint aField,
       
   182     jintArray aError)
       
   183 {
       
   184     JELOG2(EPim);
       
   185     pimbaserepeatrule* repeatRule =
       
   186         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   187     jlong retVal = 0;
       
   188     int error = 0;
       
   189     try
       
   190     {
       
   191         retVal = repeatRule->getRepeatDate(aField);
       
   192     }
       
   193     catch (int aError)
       
   194     {
       
   195         error = aError;
       
   196     }
       
   197     SetJavaErrorCode(aJniEnv, aError, error);
       
   198     return retVal;
       
   199 }
       
   200 
       
   201 JNIEXPORT void
       
   202 JNICALL Java_javax_microedition_pim_RepeatRule__1setDate(
       
   203     JNIEnv* aJniEnv,
       
   204     jobject /*aPeer*/,
       
   205     jint aRepeatRuleHandle,
       
   206     jint aField,
       
   207     jlong aValue,
       
   208     jintArray aError)
       
   209 {
       
   210     JELOG2(EPim);
       
   211     pimbaserepeatrule* repeatRule =
       
   212         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   213     int error = 0;
       
   214     try
       
   215     {
       
   216         repeatRule->setDate(aField, aValue);
       
   217     }
       
   218     catch (int aError)
       
   219     {
       
   220         error = aError;
       
   221     }
       
   222     SetJavaErrorCode(aJniEnv, aError, error);
       
   223 }
       
   224 
       
   225 JNIEXPORT jintArray
       
   226 JNICALL Java_javax_microedition_pim_RepeatRule__1getFields(
       
   227     JNIEnv* aJniEnv,
       
   228     jobject /*aPeer*/,
       
   229     jint aRepeatRuleHandle)
       
   230 {
       
   231     JELOG2(EPim);
       
   232     pimbaserepeatrule* repeatRule =
       
   233         reinterpret_cast< pimbaserepeatrule*>(aRepeatRuleHandle);
       
   234 
       
   235     jintArray javaFields = repeatRule->getFields(aJniEnv);
       
   236 
       
   237     return javaFields;
       
   238 }
       
   239 
       
   240 // End of File