javauis/amms_akn/jni/src/modulebase.cpp
branchRCL_3
changeset 19 04becd199f91
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javauis/amms_akn/jni/src/modulebase.cpp	Tue Apr 27 16:30:29 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <jutils.h>
+#include <jdebug.h>
+
+#include <cmmaeventsource.h>
+#include <cmmaplayer.h>
+
+// Generated JNI header.
+#include "com_nokia_amms_ModuleBase.h"
+
+#include "cammsmodule.h"
+#include "cammsglobalmanager.h"
+
+/**
+ * Calls CAMMSModule::AddPlayerL method.
+ * @param aModule Module instance.
+ * @param aPlayer Player to add.
+ */
+LOCAL_C void AddPlayerL(CAMMSModule* aModule, CMMAPlayer* aPlayer)
+{
+    aModule->AddPlayerL(aPlayer);
+}
+
+/**
+ * JNI function.
+ */
+JNIEXPORT jint JNICALL Java_com_nokia_amms_ModuleBase__1addPlayer
+(JNIEnv* /*aJniEnv*/,
+ jclass,
+ jint aEventSourceHandle,
+ jint aModuleHandle,
+ jint aPlayerHandle)
+{
+    CMMAEventSource* eventSource =
+        JavaUnhand< CMMAEventSource >(aEventSourceHandle);
+
+    CAMMSModule* module =
+        JavaUnhand< CAMMSModule >(aModuleHandle);
+
+    CMMAPlayer* player =
+        JavaUnhand< CMMAPlayer >(aPlayerHandle);
+
+    // call CAMMSModule::AddPlayerL through local AddPlayerL function.
+    return eventSource->ExecuteTrap(&AddPlayerL,
+                                    module,
+                                    player);
+}
+
+/**
+ * Calls CAMMSModule::RemovePlayerL method.
+ * @param aModule Module instance.
+ * @param aPlayer Player to remove.
+ * @return KErrNotFound if player does not exist in the module.
+ */
+LOCAL_C TInt RemovePlayer(CAMMSModule* aModule, CMMAPlayer* aPlayer)
+{
+    return aModule->RemovePlayer(aPlayer);
+}
+
+/**
+ * JNI function.
+ */
+JNIEXPORT jint JNICALL Java_com_nokia_amms_ModuleBase__1removePlayer
+(JNIEnv* /*aJniEnv*/,
+ jclass,
+ jint aEventSourceHandle,
+ jint aModuleHandle,
+ jint aPlayerHandle)
+{
+    CMMAEventSource* eventSource =
+        JavaUnhand< CMMAEventSource >(aEventSourceHandle);
+
+    CAMMSModule* module =
+        JavaUnhand< CAMMSModule >(aModuleHandle);
+
+    CMMAPlayer* player =
+        JavaUnhand< CMMAPlayer >(aPlayerHandle);
+
+    // call CAMMSModule::RemovePlayerL through local RemovePlayerL function.
+    return eventSource->Execute(&RemovePlayer,
+                                module,
+                                player);
+}
+
+/**
+ * JNI function.
+ */
+JNIEXPORT void JNICALL Java_com_nokia_amms_ModuleBase__1dispose
+(JNIEnv*,
+ jclass,
+ jint aManagerHandle,
+ jint aModuleHandle)
+{
+    DEBUG_INT("AMMS::ModuleBase.cpp::finalize %d", aModuleHandle);
+
+    // Module to dispose
+    CAMMSModule* module =
+        JavaUnhand< CAMMSModule >(aModuleHandle);
+
+    CAMMSGlobalManager* manager =
+        JavaUnhand< CAMMSGlobalManager >(aManagerHandle);
+
+    manager->DisposeModule(module);
+}
+//  End of File
+
+
+