|
1 /* |
|
2 * Copyright (c) 2002 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 "CMIDToolkit.h" |
|
20 #include "javax_microedition_lcdui_CommandPeer.h" |
|
21 |
|
22 LOCAL_C void CreateCommandL |
|
23 ( |
|
24 CMIDToolkit* aToolkit, |
|
25 TInt* aHandle, |
|
26 const TDesC* aShortLabel, |
|
27 const TDesC* aLongLabel, |
|
28 jint aType, |
|
29 jint aPriority, |
|
30 jint aCommandID |
|
31 ) |
|
32 { |
|
33 MMIDCommand::TCommandType type = (MMIDCommand::TCommandType)aType; |
|
34 |
|
35 MMIDCommand* command = aToolkit->ComponentFactory()->CreateCommandL(*aShortLabel,*aLongLabel, type, aPriority, aCommandID); |
|
36 CleanupDisposePushL(command); |
|
37 *aHandle = aToolkit->RegisterComponentL(command, NULL); |
|
38 CleanupPopComponent(command); |
|
39 } |
|
40 |
|
41 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_CommandPeer__1create |
|
42 ( |
|
43 JNIEnv* aJni, |
|
44 jobject, |
|
45 jint aToolkit, |
|
46 jstring aShortLabel, |
|
47 jstring aLongLabel, |
|
48 jint aCommandType, |
|
49 jint aPriority, |
|
50 jint aCommandID |
|
51 ) |
|
52 { |
|
53 RJString shortLabel(*aJni,aShortLabel); |
|
54 RJString longLabel(*aJni,aLongLabel); |
|
55 |
|
56 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
57 const TDesC* pShortLabel = &shortLabel; |
|
58 const TDesC* pLongLabel = &longLabel; |
|
59 TInt handle = 0; |
|
60 |
|
61 TInt err = toolkit->ExecuteTrap(&CreateCommandL, toolkit, &handle, pShortLabel, pLongLabel, aCommandType, aPriority, aCommandID); |
|
62 if (err != KErrNone) |
|
63 { |
|
64 handle = err; |
|
65 } |
|
66 |
|
67 return handle; |
|
68 } |
|
69 |