javauis/amms_qt/jni/src/modulebase.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     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 //#include <jutils.h>
       
    19 #include <logger.h>
       
    20 
       
    21 #include <mmafunctionserver.h>
       
    22 #include <cmmaplayer.h>
       
    23 
       
    24 // Generated JNI header.
       
    25 #include "com_nokia_amms_ModuleBase.h"
       
    26 
       
    27 #include "cammsmodule.h"
       
    28 #include "cammsglobalmanager.h"
       
    29 
       
    30 /**
       
    31  * Calls CAMMSModule::AddPlayerL method.
       
    32  * @param aModule Module instance.
       
    33  * @param aPlayer Player to add.
       
    34  */
       
    35 LOCAL_C void AddPlayerL(CAMMSModule* aModule, CMMAPlayer* aPlayer)
       
    36 {
       
    37     aModule->AddPlayerL(aPlayer);
       
    38 }
       
    39 
       
    40 /**
       
    41  * JNI function.
       
    42  */
       
    43 JNIEXPORT jint JNICALL Java_com_nokia_amms_ModuleBase__1addPlayer
       
    44 (JNIEnv* /*aJniEnv*/,
       
    45  jclass,
       
    46  jint aEventSourceHandle,
       
    47  jint aModuleHandle,
       
    48  jint aPlayerHandle)
       
    49 {
       
    50     MMAFunctionServer* eventSource =
       
    51         reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle);
       
    52 
       
    53     CAMMSModule* module =
       
    54         reinterpret_cast< CAMMSModule* >(aModuleHandle);
       
    55 
       
    56     CMMAPlayer* player =
       
    57         reinterpret_cast< CMMAPlayer *>(aPlayerHandle);
       
    58 
       
    59     // call CAMMSModule::AddPlayerL through local AddPlayerL function.
       
    60     return eventSource->ExecuteTrap(&AddPlayerL,
       
    61                                     module,
       
    62                                     player);
       
    63 }
       
    64 
       
    65 /**
       
    66  * Calls CAMMSModule::RemovePlayerL method.
       
    67  * @param aModule Module instance.
       
    68  * @param aPlayer Player to remove.
       
    69  * @return KErrNotFound if player does not exist in the module.
       
    70  */
       
    71 LOCAL_C TInt RemovePlayer(CAMMSModule* aModule, CMMAPlayer* aPlayer)
       
    72 {
       
    73     return aModule->RemovePlayer(aPlayer);
       
    74 }
       
    75 
       
    76 /**
       
    77  * JNI function.
       
    78  */
       
    79 JNIEXPORT jint JNICALL Java_com_nokia_amms_ModuleBase__1removePlayer
       
    80 (JNIEnv* /*aJniEnv*/,
       
    81  jclass,
       
    82  jint aEventSourceHandle,
       
    83  jint aModuleHandle,
       
    84  jint aPlayerHandle)
       
    85 {
       
    86     MMAFunctionServer* eventSource =
       
    87         reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle);
       
    88 
       
    89     CAMMSModule* module =
       
    90         reinterpret_cast< CAMMSModule *>(aModuleHandle);
       
    91 
       
    92     CMMAPlayer* player =
       
    93         reinterpret_cast< CMMAPlayer *>(aPlayerHandle);
       
    94 
       
    95     // call CAMMSModule::RemovePlayerL through local RemovePlayerL function.
       
    96     return eventSource->Execute(&RemovePlayer,
       
    97                                 module,
       
    98                                 player);
       
    99 }
       
   100 
       
   101 /**
       
   102  * JNI function.
       
   103  */
       
   104 JNIEXPORT void JNICALL Java_com_nokia_amms_ModuleBase__1dispose
       
   105 (JNIEnv*,
       
   106  jclass,
       
   107  jint aManagerHandle,
       
   108  jint aModuleHandle)
       
   109 {
       
   110     LOG1( EJavaAMMS, EInfo, "AMMS::ModuleBase.cpp::finalize %d", aModuleHandle);
       
   111 
       
   112     // Module to dispose
       
   113     CAMMSModule* module =
       
   114         reinterpret_cast< CAMMSModule* >(aModuleHandle);
       
   115 
       
   116     CAMMSGlobalManager* manager =
       
   117         reinterpret_cast< CAMMSGlobalManager* >(aManagerHandle);
       
   118 
       
   119     manager->DisposeModule(module);
       
   120 }
       
   121 //  End of File
       
   122 
       
   123 
       
   124