diff -r f5050f1da672 -r 04becd199f91 javacommons/utils/inc.s60/javasymbianoslayer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javacommons/utils/inc.s60/javasymbianoslayer.h Tue Apr 27 16:30:29 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef JAVASYMBIANOSLAYER_H +#define JAVASYMBIANOSLAYER_H + +#include +#include + +#include "javaosheaders.h" +#include "javauid.h" + +typedef void*(* FuncPtr)(); + +typedef FuncPtr(*LookupFunc)(const char* methodname); + +struct FuncTable +{ + const char* mFuncName; + unsigned int mFuncAddr; +}; + +OS_IMPORT FuncPtr findMethod(const char* funcName, const FuncTable funcTable[], + int tableSize); + +OS_IMPORT HBufC* stringToDes(const char* str); + +OS_IMPORT wchar_t* desToWstring(TPtr16& aDes); + +/** + * This method is supported only in S60 environment. + * Converts integer to Uid object. + * @param aId Id to be converted. + * @param aOutUid Output parameter. + * @return filled Uid object. Return object is equal with "aOutUid" parameter. + * Id is converted to hexadecimal format. Length of the number is always + * 8 digits. See examples: + * 1234 => [00001234] + * 0x123456ab => [123456ab] + * 1289 => [00000509] + */ +OS_IMPORT java::util::Uid& TUidToUid(const TUid& aId,java::util::Uid& aOutUid); + +/** + * This method is supported only in S60 environment. + * Converts Uid class to int. Supported formats: + * [123456ab] + * 0x123456ab + * 123456ab + * This operation strips following characters from the beginning and end of the string: + * " ", "\n" and "\t". + * @param aUid Length of the actual number is assumed to be 8 digit. + * @param aOutId Output parameter. Uid object converted to int. + * @return KErrNone is conversion was done successfully. + * KErrArgument if conversion failed for following errors: + * - Length of the number is not 8 digits after stripping and removing angle brackets. + * - Conversion from wstring to TUint fails. + * - Converted number is bigger than 0xEFFFFFFF or less than 0. + */ +OS_IMPORT TInt uidToTUid(const java::util::Uid& aUid,TUid& aOutId); + +/** + * Convert wide string AppVersion representation to TAppVersion. + * + * @param aString uid as wide string. + * @return TAppVersion. + */ +OS_IMPORT TAppVersion wstringToAppVersion(const std::wstring& aVersionString); + +/** + * Convert wide string to HBufC. Ownership is moved to caller. + * + * @param aString wide string. + * @return wide string as HBufC. + */ +OS_IMPORT HBufC* wstringToBuf(const std::wstring& aString); + +template +class CleanupResetAndDestroy +{ +public: + inline static void PushL(T& aRef); +private: + static void ResetAndDestroy(TAny *aPtr); +}; +template +inline void CleanupResetAndDestroyPushL(T& aRef); + +template +inline void CleanupResetAndDestroy::PushL(T& aRef) +{ + CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); +} +template +void CleanupResetAndDestroy::ResetAndDestroy(TAny *aPtr) +{ + (STATIC_CAST(T*,aPtr))->ResetAndDestroy(); +} +template +inline void CleanupResetAndDestroyPushL(T& aRef) +{ + CleanupResetAndDestroy::PushL(aRef); +} + + +#endif // JAVASYMBIANOSLAYER_H