|
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 #include "CMIDNotify.h" |
|
19 #include "CMIDToolkit.h" |
|
20 |
|
21 CMIDNotifyEvent::CMIDNotifyEvent(TJavaPeer aPeer) |
|
22 : CJavaEvent<CMIDToolkit>(EReusableEvent) |
|
23 , iPeer(aPeer) |
|
24 { |
|
25 } |
|
26 |
|
27 void CMIDNotifyEvent::SetResult(TInt aResult) |
|
28 { |
|
29 iResult=aResult; |
|
30 } |
|
31 |
|
32 void CMIDNotifyEvent::Dispose() |
|
33 { |
|
34 delete this; |
|
35 } |
|
36 |
|
37 void CMIDNotifyEvent::Dispatch(JNIEnv& aJni) |
|
38 { |
|
39 #ifdef _TRACE_ASYNC_ |
|
40 RDebug::Print(_L("CMIDNotifyEvent::Dispatch: result=%d"), iResult); |
|
41 #endif |
|
42 |
|
43 CMIDToolkit& toolkit = Object(); |
|
44 jobject sourceObject = aJni.NewLocalRef((jobject)iPeer); |
|
45 if (sourceObject) |
|
46 { |
|
47 jobject peerObject = aJni.NewLocalRef(toolkit.Peer()); |
|
48 if (peerObject) |
|
49 { |
|
50 #ifdef _TRACE_ASYNC_ |
|
51 RDebug::Print(_L("CMIDNotifyEvent::Dispatch: calling Toolkit.handleNotifyCallback(%x, %d)"), source, iResult); |
|
52 #endif |
|
53 aJni.CallVoidMethod( |
|
54 peerObject, |
|
55 toolkit.iHandleNotifyMethod, |
|
56 sourceObject, |
|
57 iResult |
|
58 ); |
|
59 aJni.DeleteLocalRef(peerObject); |
|
60 } |
|
61 aJni.DeleteLocalRef(sourceObject); |
|
62 } |
|
63 |
|
64 #if defined(_DEBUG) && defined(_TRACE_ASYNC_) |
|
65 if (aJni.IsSameObject(source, NULL)) |
|
66 { |
|
67 RDebug::Print(_L("CMIDNotifyEvent: source has been gc'd!")); |
|
68 } |
|
69 if (aJni.IsSameObject(toolkit.Peer(), NULL)) |
|
70 { |
|
71 RDebug::Print(_L("CMIDNotifyEvent: Toolkit has been gc'd!!!!")); |
|
72 } |
|
73 #endif |
|
74 } |
|
75 |
|
76 void CMIDNotifyEvent::Close(JNIEnv& aJni) |
|
77 { |
|
78 // |
|
79 // ASSERT( !IsQueued() ); |
|
80 // |
|
81 if (NULL != iPeer) |
|
82 { |
|
83 aJni.DeleteWeakGlobalRef((jweak)iPeer); |
|
84 iPeer = NULL; |
|
85 } |
|
86 } |