javacommons/gcfbase/src.s60/nativeerror.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "s60commonutils.h"
       
    20 #include "com_nokia_mj_impl_gcf_utils_NativeError.h"
       
    21 #include <textresolver.h>
       
    22 
       
    23 using namespace java::util;
       
    24 
       
    25 
       
    26 // forward declaration
       
    27 CTextResolver* createTextResolverL();
       
    28 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_gcf_utils_NativeError__1getNativeErrorMessage
       
    29 (JNIEnv* aJni, jclass /* aPeer */, jint aError)
       
    30 {
       
    31     jstring result = NULL;
       
    32 
       
    33     CTextResolver* iTextResolver = NULL;
       
    34     TRAPD(err, createTextResolverL(); CleanupStack::PopAndDestroy());
       
    35     if (err < 0)
       
    36     {
       
    37         CleanupStack::PopAndDestroy(); // iTextResolver
       
    38         return result;
       
    39     }
       
    40 
       
    41     TPtrC errorMsg;
       
    42     errorMsg.Set(iTextResolver->ResolveErrorString(aError));
       
    43     result = S60CommonUtils::NativeToJavaString(*aJni, errorMsg);
       
    44     CleanupStack::PopAndDestroy(); // iTextResolver
       
    45 
       
    46     return result;
       
    47 }
       
    48 
       
    49 CTextResolver* createTextResolverL()
       
    50 {
       
    51     CTextResolver * iResolver = CTextResolver::NewLC();
       
    52     return iResolver;
       
    53 }
       
    54 
       
    55 
       
    56