javacommons/utils/inc.s60/s60commonutils.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19: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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef S60COMMONUTILS_H
       
    20 #define S60COMMONUTILS_H
       
    21 
       
    22 
       
    23 #include "jni.h"
       
    24 #include <e32def.h>
       
    25 #include <e32cmn.h>
       
    26 #include <wchar.h>
       
    27 #include "javaosheaders.h"
       
    28 
       
    29 namespace java
       
    30 {
       
    31 namespace util
       
    32 {
       
    33 
       
    34 class S60CommonUtils
       
    35 {
       
    36 public:
       
    37     OS_IMPORT static TInt CopyToNative(JNIEnv& aJni, jbyteArray aJavaBuffer, TInt aOffset, TInt aLength, TDes8& aNativeBuffer);
       
    38 
       
    39     OS_IMPORT static TInt CopyToJava(JNIEnv& aJni, const TDesC8& aNativeBuffer, jbyteArray aJavaBuffer, TInt aOffset, TInt aLength);
       
    40 
       
    41     OS_IMPORT static jobjectArray NativeToJavaStringArray(JNIEnv& aJni, const RPointerArray<HBufC>& aNativeArray);
       
    42 
       
    43 
       
    44     OS_IMPORT static TTime JavaTimeToTTime(jlong aJavaTime);
       
    45 
       
    46     OS_IMPORT static jlong TTimeToJavaTime(TTime aEpocTime);
       
    47 
       
    48     OS_IMPORT static jstring NativeToJavaString(JNIEnv& aJni, const TDesC16& aNativeString);
       
    49 
       
    50 
       
    51     OS_IMPORT static const TUint JavaUpperEpocTime = 14474675;
       
    52     OS_IMPORT static const TUint JavaLowerEpocTime = 254771200;
       
    53     OS_IMPORT static HBufC* wstringToDes(const wchar_t* cStr);
       
    54 
       
    55     /**
       
    56      * Create a new TDesC8 from TDesC16.
       
    57      * Transfer the owner ship to the caller
       
    58      * @param aSource: original descriptor
       
    59      * @param aDestination: newly created descriptor
       
    60      *
       
    61      * @return TInt (length of the newly created descriptor)
       
    62      */
       
    63     OS_IMPORT static TInt ConvertWiderToNarrowL(const TDesC& aSource,
       
    64             TDesC8*& aDestination);
       
    65     /**
       
    66      * Create a new TDesC8 from TDesC16 and leave it on the cleanup stack.
       
    67      * Transfer the owner ship to the caller
       
    68      * @param aSource: original descriptor
       
    69      * @param aDestination: newly created descriptor
       
    70      *
       
    71      * @return TInt (length of the newly created descriptor)
       
    72      */
       
    73     OS_IMPORT static TInt ConvertWiderToNarrowLC(const TDesC& aSource,
       
    74             TDesC8*& aDestination);
       
    75     /**
       
    76      * Create a new TDesC16 from TDesC8.
       
    77      * Transfer the owner ship to the caller
       
    78      * @param aSource: original descriptor
       
    79      * @param aDestination: newly created descriptor
       
    80      *
       
    81      * @return TInt (length of the newly created descriptor)
       
    82      */
       
    83     OS_IMPORT static TInt ConvertNarrowToWiderL(const TDesC8& aSource,
       
    84             TDesC*& aDestination);
       
    85     /**
       
    86      * Create a new TDesC16 from TDesC8 and leave it on the cleanup stack.
       
    87      * Transfer the owner ship to the caller
       
    88      * @param aSource: original descriptor
       
    89      * @param aDestination: newly created descriptor
       
    90      *
       
    91      * @return TInt (length of the newly created descriptor)
       
    92      */
       
    93     OS_IMPORT static TInt ConvertNarrowToWiderLC(const TDesC8& aSource,
       
    94             TDesC*& aDestination);
       
    95     /**
       
    96      * Create the copy of TDesC8 and leave it on cleanup stack.
       
    97      * Transfer the owner ship to the caller
       
    98      * @param aSource: original descriptor
       
    99      * @param aDestination: newly created descriptor
       
   100      *
       
   101      * @return TInt (length of the newly created descriptor)
       
   102      */
       
   103     OS_IMPORT static TInt CopyNarrowLC(const TDesC8& aSource,
       
   104                                        TDesC8*& aDestination);
       
   105     /**
       
   106      * Create the copy of TDesC8.
       
   107      * Transfer the owner ship to the caller
       
   108      * @param aSource: original descriptor
       
   109      * @param aDestination: newly created descriptor
       
   110      *
       
   111      * @return TInt (length of the newly created descriptor)
       
   112      */
       
   113     OS_IMPORT static TInt CopyNarrowL(const TDesC8& aSource,
       
   114                                       TDesC8*& aDestination);
       
   115     /**
       
   116      * Create the copy of TDesC16 and leave it on cleanup stack.
       
   117      * Transfer the owner ship to the caller
       
   118      * @param aSource: original descriptor
       
   119      * @param aDestination: newly created descriptor
       
   120      *
       
   121      * @return TInt (length of the newly created descriptor)
       
   122      */
       
   123     OS_IMPORT static TInt CopyWiderLC(const TDesC16& aSource,
       
   124                                       TDesC16*& aDestination);
       
   125     /**
       
   126      * Create the copy of TDesC16.
       
   127      * Transfer the owner ship to the caller
       
   128      * @param aSource: original descriptor
       
   129      * @param aDestination: newly created descriptor
       
   130      *
       
   131      * @return TInt (length of the newly created descriptor)
       
   132      */
       
   133     OS_IMPORT static TInt CopyWiderL(const TDesC16& aSource,
       
   134                                      TDesC16*& aDestination);
       
   135 
       
   136     /**
       
   137      * Searches for the most appropriate variant of the resource corresponding
       
   138      * to the device's language in use. The variant is searched on following
       
   139      * drives:
       
   140      * - on drive from where the calling dll is loaded (might be c: drive)
       
   141      * - on ROM drive (z:)
       
   142      *
       
   143      * @param aResourceFileName Path name of the resource file to be matched.
       
   144      *                          The path name is relative to 'resource/java' directory.
       
   145      *                          E.g. providing a path name 'lcdui.rsc' the
       
   146      *                          method would return either 'c:/resource/java/lcdui.rsc'
       
   147      *                          or 'z:/resource/java/lcdui.rsc'
       
   148      * @return                  The full name (including path) of the most appropriate
       
   149      *                          variant of the resource
       
   150      */
       
   151     OS_IMPORT static TFileName ResourceLanguageFileNameL(const TDesC& aResourceFileName);
       
   152 
       
   153 
       
   154     /**
       
   155      * Searches for the specified file from several drives
       
   156      * - on EDefaultSystem (usually C:)
       
   157      * - on ROM drive (Z:)
       
   158      *
       
   159      * @param aFileName The path name (with or without drive) of the file to be searched,
       
   160      *  for example '/resource/java/java_app.mif' or 'Z:/resource/java/version.txt'
       
   161      * @return The full name (including drive) of the first found version of the file.
       
   162      * @throws Leaves with KErrNotFound if file does not exist in any drive
       
   163      */
       
   164     OS_IMPORT static TFileName VerifiedFileNameL(const TDesC& aFileName);
       
   165 
       
   166 };
       
   167 
       
   168 
       
   169 } //end namespace util
       
   170 } //end namespace java
       
   171 
       
   172 #endif // S60COMMONUTILS_H