author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 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: This class is used to post events to the java. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <jdebug.h> |
|
21 |
||
22 |
#include "cmmasnapshotevent.h" |
|
23 |
||
24 |
CMMASnapshotEvent::CMMASnapshotEvent(jobject aNotifyObject, |
|
25 |
jmethodID aHandleEventMethod, |
|
26 |
TInt aError, |
|
27 |
HBufC8* aImageBuffer, |
|
28 |
TDisposability aDisposable): |
|
29 |
CMMAEvent(aNotifyObject, |
|
30 |
aHandleEventMethod, |
|
31 |
aDisposable) |
|
32 |
{ |
|
33 |
iEventData = aError; |
|
34 |
iImageBuffer = aImageBuffer; |
|
35 |
} |
|
36 |
||
37 |
CMMASnapshotEvent::~CMMASnapshotEvent() |
|
38 |
{ |
|
39 |
// image buffer need to be deleted if |
|
40 |
// event server hasn't sent this event before |
|
41 |
// middlet is destroyed |
|
42 |
delete iImageBuffer; |
|
43 |
||
44 |
} |
|
45 |
||
46 |
void CMMASnapshotEvent::Dispatch(JNIEnv& aJni) |
|
47 |
{ |
|
48 |
DEBUG("MMA::CMMASnapshotEvent::Dispatch"); |
|
49 |
||
50 |
// create java byte array |
|
51 |
jbyteArray byteArray; |
|
52 |
||
53 |
if (iImageBuffer) |
|
54 |
{ |
|
55 |
byteArray = aJni.NewByteArray(iImageBuffer->Size()); |
|
56 |
if (byteArray) |
|
57 |
{ |
|
58 |
ArrayUtils::CopyToJava(aJni, |
|
59 |
*iImageBuffer, |
|
60 |
byteArray, |
|
61 |
0, |
|
62 |
iImageBuffer->Size()); |
|
63 |
} |
|
64 |
} |
|
65 |
else |
|
66 |
{ |
|
67 |
byteArray = aJni.NewByteArray(0); |
|
68 |
} |
|
69 |
||
70 |
if (!byteArray) |
|
71 |
{ |
|
72 |
delete iImageBuffer; |
|
73 |
iImageBuffer = NULL; // otherwise double delete in destructor |
|
74 |
DEBUG("MMA::CMMASnapshotEvent::Dispatch - Failed to create ByteArray"); |
|
75 |
return; |
|
76 |
} |
|
77 |
||
78 |
||
79 |
aJni.CallVoidMethod(iListenerObject, |
|
80 |
iHandleEventMethod, |
|
81 |
iEventData, |
|
82 |
byteArray); |
|
83 |
||
84 |
delete iImageBuffer; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
85 |
|
66 | 86 |
iImageBuffer = NULL; // otherwise double delete in destructor |
87 |
aJni.DeleteLocalRef(byteArray); |
|
88 |
||
89 |
} |
|
90 |
||
91 |
// END OF FILE |