|
1 /* |
|
2 * Copyright (c) 2005 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 <jutils.h> |
|
20 #include <logger.h> |
|
21 |
|
22 #include <mmafunctionserver.h> |
|
23 |
|
24 #include "com_nokia_amms_GlobalManagerImpl.h" |
|
25 #include "cammsglobalmanager.h" |
|
26 |
|
27 /** |
|
28 * Creates new CAMMSGlobalManager instance which is added to |
|
29 * MMAFunctionServer for cleanup. |
|
30 * @param aHandle will contain handle to created object. |
|
31 * @param aEventSource MMA event source instance. |
|
32 */ |
|
33 LOCAL_C void CreateManagerL(TInt* aHandle, |
|
34 MMAFunctionServer* aEventSource) |
|
35 { |
|
36 CAMMSGlobalManager* manager = CAMMSGlobalManager::NewLC(); |
|
37 |
|
38 // Make Java handle |
|
39 *aHandle = reinterpret_cast<TInt>(manager); |
|
40 |
|
41 MMAFunctionServer::StaticAddObjectFromHandleL(aEventSource, |
|
42 *aHandle); |
|
43 |
|
44 CleanupStack::Pop(manager); |
|
45 } |
|
46 |
|
47 /** |
|
48 * JNI function. |
|
49 */ |
|
50 JNIEXPORT jint JNICALL Java_com_nokia_amms_GlobalManagerImpl__1createGlobalManager |
|
51 (JNIEnv*, |
|
52 jclass, |
|
53 jint aEventSourceHandle) |
|
54 { |
|
55 LOG( EJavaAMMS, EInfo, "AMMS::GlobalManager.cpp::createGlobalManager +"); |
|
56 |
|
57 // Development time check. |
|
58 __ASSERT_DEBUG(aEventSourceHandle > 0, User::Invariant()); |
|
59 |
|
60 MMAFunctionServer* eventSource = |
|
61 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
62 |
|
63 // handle will be set in CreateManagerL function. |
|
64 TInt handle = KErrNotReady; |
|
65 |
|
66 // Call CreateManagerL. If it leaves handle will not be set |
|
67 TInt error = eventSource->ExecuteTrap(&CreateManagerL, |
|
68 &handle, |
|
69 eventSource); |
|
70 |
|
71 if (error != KErrNone) |
|
72 { |
|
73 // executed function leaved. Set error to be returned to java. |
|
74 handle = error; |
|
75 } |
|
76 |
|
77 LOG1( EJavaAMMS, EInfo, "AMMS::GlobalManager.cpp::createGlobalManager return %d", |
|
78 handle); |
|
79 |
|
80 return handle; |
|
81 } |
|
82 |
|
83 /** |
|
84 * Calls CAMMSGlobalManager::InitL method. |
|
85 * |
|
86 * @param aManager CAMMSGlobalManager instance. |
|
87 * @param aEventSource MMAFunctionServer instance. |
|
88 */ |
|
89 LOCAL_C void InitManagerL(CAMMSGlobalManager* aManager, |
|
90 MMAFunctionServer* aEventSource) |
|
91 { |
|
92 aManager->InitL(aEventSource->Players()); |
|
93 |
|
94 // Receive notifications when new players are created or deleted. |
|
95 aEventSource->SetPlayerInstanceObserver(aManager); |
|
96 } |
|
97 |
|
98 /** |
|
99 * JNI function. |
|
100 */ |
|
101 JNIEXPORT jint JNICALL Java_com_nokia_amms_GlobalManagerImpl__1init |
|
102 (JNIEnv*, |
|
103 jclass, |
|
104 jint aEventSourceHandle, |
|
105 jint aGlobalManagerHandle) |
|
106 { |
|
107 LOG( EJavaAMMS, EInfo, "AMMS::GlobalManager.cpp::init +"); |
|
108 |
|
109 // Development time check. |
|
110 __ASSERT_DEBUG(aEventSourceHandle > 0 && |
|
111 aGlobalManagerHandle > 0, User::Invariant()); |
|
112 |
|
113 MMAFunctionServer* eventSource = |
|
114 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
115 |
|
116 CAMMSGlobalManager* manager = |
|
117 reinterpret_cast< CAMMSGlobalManager* >(aGlobalManagerHandle); |
|
118 |
|
119 // Call InitManagerL. |
|
120 TInt error = eventSource->ExecuteTrap(&InitManagerL, |
|
121 manager, |
|
122 eventSource); |
|
123 |
|
124 ELOG1( EJavaAMMS, "AMMS::GlobalManager.cpp::init error code %d", error); |
|
125 return error; |
|
126 } |
|
127 |
|
128 /** |
|
129 * Calls CAMMSGlobalManager::CreateSoundSource3DL method. |
|
130 * @param aManager CAMMSGlobalManager instance. |
|
131 * @param aHandle will contain handle to created object. |
|
132 */ |
|
133 LOCAL_C void CreateSoundSource3DL(CAMMSGlobalManager* aManager, TInt* aHandle) |
|
134 { |
|
135 CAMMSModule* module = aManager->CreateSoundSource3DL(); |
|
136 |
|
137 // Make Java handle |
|
138 *aHandle = reinterpret_cast<TInt>(module); |
|
139 } |
|
140 |
|
141 /** |
|
142 * JNI function. |
|
143 */ |
|
144 JNIEXPORT jint JNICALL Java_com_nokia_amms_GlobalManagerImpl__1createSoundSource3D |
|
145 (JNIEnv*, |
|
146 jclass, |
|
147 jint aEventSourceHandle, |
|
148 jint aGlobalManagerHandle) |
|
149 { |
|
150 MMAFunctionServer* eventSource = |
|
151 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
152 |
|
153 CAMMSGlobalManager* manager = |
|
154 reinterpret_cast< CAMMSGlobalManager* >(aGlobalManagerHandle); |
|
155 |
|
156 // handle will be set in CreateSoundSource3DL function. |
|
157 TInt handle = KErrNotReady; |
|
158 |
|
159 // Call CreateSoundSource3DL. If it leaves handle will not be set |
|
160 TInt error = eventSource->ExecuteTrap(&CreateSoundSource3DL, |
|
161 manager, |
|
162 &handle); |
|
163 |
|
164 if (error != KErrNone) |
|
165 { |
|
166 // executed function leaved. Set error to be returned to java. |
|
167 handle = error; |
|
168 } |
|
169 ELOG1( EJavaAMMS, "AMMS::GlobalManager.cpp::createSoundSource3D return value %d", |
|
170 error); |
|
171 return handle; |
|
172 } |
|
173 |
|
174 /** |
|
175 * Calls CAMMSGlobalManager::CreateEffectModuleL method. |
|
176 * @param aManager CAMMSGlobalManager instance. |
|
177 * @param aHandle will contain handle to created object. |
|
178 */ |
|
179 LOCAL_C void CreateEffectModuleL(CAMMSGlobalManager* aManager, TInt* aHandle) |
|
180 { |
|
181 CAMMSModule* module = aManager->CreateEffectModuleL(); |
|
182 |
|
183 // Make Java handle |
|
184 *aHandle = reinterpret_cast<TInt>(module); |
|
185 } |
|
186 |
|
187 /** |
|
188 * JNI function. |
|
189 */ |
|
190 JNIEXPORT jint JNICALL Java_com_nokia_amms_GlobalManagerImpl__1createEffectModule |
|
191 (JNIEnv*, |
|
192 jclass, |
|
193 jint aEventSourceHandle, |
|
194 jint aGlobalManagerHandle) |
|
195 { |
|
196 MMAFunctionServer* eventSource = |
|
197 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
198 |
|
199 CAMMSGlobalManager* manager = |
|
200 reinterpret_cast< CAMMSGlobalManager* >(aGlobalManagerHandle); |
|
201 |
|
202 // handle will be set in CreateEffectModuleL function. |
|
203 TInt handle = KErrNotReady; |
|
204 |
|
205 // Call CreateEffectModuleL. If it leaves handle will not be set |
|
206 TInt error = eventSource->ExecuteTrap(&CreateEffectModuleL, |
|
207 manager, |
|
208 &handle); |
|
209 |
|
210 if (error != KErrNone) |
|
211 { |
|
212 // executed function leaved. Set error to be returned to java. |
|
213 handle = error; |
|
214 } |
|
215 ELOG1( EJavaAMMS, "AMMS::GlobalManager.cpp::createEffectModule return value %d", |
|
216 error); |
|
217 return handle; |
|
218 } |
|
219 |
|
220 /** |
|
221 * Calls CAMMSGlobalManager::Spectator method. |
|
222 * @param aManager CAMMSGlobalManager instance. |
|
223 * @param aHandle will contain handle to created object. |
|
224 */ |
|
225 LOCAL_C void CreateSpectatorL(CAMMSGlobalManager* aManager, TInt* aHandle) |
|
226 { |
|
227 CAMMSModule* spectator = aManager->Spectator(); |
|
228 |
|
229 // Make Java handle |
|
230 *aHandle = reinterpret_cast<TInt>(spectator); |
|
231 } |
|
232 |
|
233 /** |
|
234 * JNI function. |
|
235 */ |
|
236 JNIEXPORT jint JNICALL Java_com_nokia_amms_GlobalManagerImpl__1createSpectator |
|
237 (JNIEnv*, |
|
238 jclass, |
|
239 jint aEventSourceHandle, |
|
240 jint aGlobalManagerHandle) |
|
241 { |
|
242 LOG( EJavaAMMS, EInfo, "AMMS::GlobalManager.cpp::createSpectator +"); |
|
243 MMAFunctionServer* eventSource = |
|
244 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
245 |
|
246 CAMMSGlobalManager* manager = |
|
247 reinterpret_cast< CAMMSGlobalManager* >(aGlobalManagerHandle); |
|
248 |
|
249 // handle will be set in CreateSpectatorL function. |
|
250 TInt handle = KErrNotReady; |
|
251 |
|
252 // Call CreateSpectatorL. If it leaves handle will not be set |
|
253 TInt error = eventSource->ExecuteTrap(&CreateSpectatorL, |
|
254 manager, |
|
255 &handle); |
|
256 |
|
257 if (error != KErrNone) |
|
258 { |
|
259 // executed function leaved. Set error to be returned to java. |
|
260 handle = error; |
|
261 } |
|
262 LOG1( EJavaAMMS, EInfo, "AMMS::GlobalManager.cpp::createSpectator error code %d", handle); |
|
263 return handle; |
|
264 } |
|
265 |
|
266 // End of File |