|
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 FILES |
|
20 #include "s60commonutils.h" |
|
21 #include "cstsapduevent.h" |
|
22 #include "logger.h" |
|
23 |
|
24 using namespace java::util; |
|
25 |
|
26 namespace java |
|
27 { |
|
28 namespace satsa |
|
29 { |
|
30 |
|
31 CSTSApduEvent::CSTSApduEvent(JNIEnv& aJni, jobject aNotifyObject, |
|
32 jmethodID aHandleEventMethod) : |
|
33 iJni(aJni), iListenerObject(aNotifyObject), iHandleEventMethod( |
|
34 aHandleEventMethod) |
|
35 { |
|
36 } |
|
37 |
|
38 CSTSApduEvent::~CSTSApduEvent() |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CSTSApduEvent::SetId |
|
44 // |
|
45 // (other items were commented in a header). |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 void CSTSApduEvent::SetId(TInt aId) |
|
49 { |
|
50 LOG(ESATSA, EInfo, "CSTSApduEvent::SetId"); |
|
51 iId = aId; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSTSApduEvent::SetErrorCode |
|
56 // |
|
57 // (other items were commented in a header). |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CSTSApduEvent::SetErrorCode(TInt aError) |
|
61 { |
|
62 LOG(ESATSA, EInfo, "CSTSApduEvent::SetErrorCode"); |
|
63 iError = aError; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSTSApduEvent::SetData |
|
68 // Sets member variable to point to the response data |
|
69 // (other items were commented in a header). |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CSTSApduEvent::SetData(HBufC8* aResponseData) |
|
73 { |
|
74 LOG(ESATSA, EInfo, "CSTSApduEvent::SetData"); |
|
75 iResponseData = aResponseData; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSTSApduEvent::Dispatch |
|
80 // from CJavaEvent. Copies response data to java side and calls java side method |
|
81 // with parameters set before. |
|
82 // (other items were commented in a header). |
|
83 // ----------------------------------------------------------------------------- |
|
84 void CSTSApduEvent::Dispatch(JNIEnv* aJni, jobject aPeer) |
|
85 { |
|
86 LOG(ESATSA, EInfo, "+ CSTSApduEvent::Dispatch"); |
|
87 |
|
88 // create java byte array |
|
89 jbyteArray byteArray; |
|
90 if (iResponseData) |
|
91 { |
|
92 LOG(ESATSA, EInfo, "CSTSApduEvent::Dispatch: Responsedata is ready"); |
|
93 byteArray = aJni->NewByteArray(iResponseData->Size()); |
|
94 if (byteArray) |
|
95 { |
|
96 LOG(ESATSA, EInfo, "CSTSApduEvent::Dispatch: create byteArray now"); |
|
97 S60CommonUtils::CopyToJava((*aJni), *iResponseData, byteArray, 0, |
|
98 iResponseData->Size()); |
|
99 } |
|
100 } |
|
101 else |
|
102 { |
|
103 LOG(ESATSA, EInfo, "CSTSApduEvent::Dispatch: responseData is NOT ready!"); |
|
104 byteArray = aJni->NewByteArray(0); |
|
105 } |
|
106 |
|
107 if (!byteArray) |
|
108 { |
|
109 ELOG(ESATSA, "STS::CSTSApduEvent::Dispatch - Failed to create ByteArray"); |
|
110 iError = KErrNoMemory; |
|
111 } |
|
112 LOG(ESATSA, EInfo, "call java side method with parameters"); |
|
113 // call java side method with parameters |
|
114 jclass sessionClass = aJni->FindClass( |
|
115 "com/nokia/mj/impl/satsa/APDUConnectionImpl"); |
|
116 jmethodID mOperationCompleteCallBack = aJni->GetMethodID(sessionClass, |
|
117 "operationComplete", "(II[B)V"); |
|
118 aJni->CallVoidMethod(aPeer, mOperationCompleteCallBack, iId, iError, |
|
119 byteArray); |
|
120 |
|
121 } |
|
122 |
|
123 } // namespace satsa |
|
124 } // namespace java |
|
125 // END OF FILE |