javauis/mmapi_qt/baseline/inc/mmafunctionserver.h
branchRCL_3
changeset 24 0fd27995241b
child 26 dc7c549001d5
equal deleted inserted replaced
20:f9bb0fca356a 24:0fd27995241b
       
     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 provides CJavaEventSource services
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMAEVENTSOURCE_H
       
    20 #define CMMAEVENTSOURCE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "mmmaeventposter.h"
       
    24 //#include <jutils.h>
       
    25 #include "functionserver.h"
       
    26 #include "legacyeventserverwrapper.h"
       
    27 #include <logger.h>
       
    28 // FORWARD DECLARATIONS
       
    29 class CApaWindowGroupName;
       
    30 class CMMAPlayer;
       
    31 class MMMAPlayerInstanceObserver;
       
    32 #ifdef RD_JAVA_VOLUME_CONTROL
       
    33 class CMMAGlobalVolume;
       
    34 #endif // RD_JAVA_VOLUME_CONTROL
       
    35 
       
    36 //  CLASS DECLARATION
       
    37 /**
       
    38 *   This class provides CJavaEventSource services.
       
    39 *
       
    40 *
       
    41 */
       
    42 
       
    43 class MMAFunctionServer : public java::util::FunctionServer,public LegacyEventServerWrapper,
       
    44         public MMMAEventPoster
       
    45 {
       
    46 public:
       
    47     /**
       
    48      * Default constructor.
       
    49      */
       
    50     MMAFunctionServer(JNIEnv& aJni, jobject aPeer);
       
    51 
       
    52     /**
       
    53      * Destructor.
       
    54      */
       
    55     ~MMAFunctionServer();
       
    56 
       
    57 public: // From CJavaEventSource, construction
       
    58     /**
       
    59      * Normal construction, Invoked from base class.
       
    60      * Method is defined in the base class.
       
    61      */
       
    62     void ConstructL(JNIEnv& aJni,
       
    63                     jobject aPeer
       
    64                     );
       
    65 
       
    66     /**
       
    67      * Server side construction.
       
    68      */
       
    69     void ConstructSvrL();
       
    70     static TInt NewL(JNIEnv& aJni, jobject aPeer);
       
    71     
       
    72 		void Dispose();
       
    73     
       
    74     TBool IsDisposed() const
       
    75     {
       
    76         return iDisposed;
       
    77     }    
       
    78 
       
    79 public: // new methods
       
    80     /**
       
    81      * Adds object to cleanup. Added objects are deleted when event source
       
    82      * is deleted.
       
    83      *
       
    84      * @param aEventSource Event source to use.
       
    85      * @param aHandle Java handle to CBase object
       
    86      */
       
    87     IMPORT_C static void StaticAddObjectFromHandleL(MMAFunctionServer* aEventSource,
       
    88             TInt aHandle);
       
    89 
       
    90     /**
       
    91      * Adds player object to cleanup. Added objects are deleted when event
       
    92      * source is deleted. An object added to the event source must be
       
    93      * deleted with DisposePlayer method.
       
    94      *
       
    95      * @param aEventSource Event source to use.
       
    96      * @param aHandle Java handle to CBase object
       
    97      */
       
    98     void AddPlayerL(CMMAPlayer* aPlayer);
       
    99 
       
   100     /**
       
   101      * Removes player from array and deletes it.
       
   102      *
       
   103      * @param aPlayer Player to be deleted.
       
   104      */
       
   105     void DisposePlayer(CMMAPlayer* aPlayer);
       
   106 
       
   107     /**
       
   108      * Sets player instance observer.
       
   109      * @param aObserver Will be informed when player is created or deleted.
       
   110      */
       
   111     IMPORT_C void SetPlayerInstanceObserver(MMMAPlayerInstanceObserver* aObserver);
       
   112 
       
   113     /**
       
   114      * Return reference to the array containing all players.
       
   115      * @return All players
       
   116      */
       
   117     IMPORT_C RPointerArray< CMMAPlayer >& Players();
       
   118 
       
   119     /**
       
   120      * Realeases resources.
       
   121      */
       
   122     void Release();
       
   123 
       
   124     /**
       
   125      * Returns player pointer for java player handle if the native player
       
   126      * peer exists. Otherwise returns null.
       
   127      * @param aPlayerHandle Java side player handle integer
       
   128      * @param CMMAPlayer* player pointer
       
   129      */
       
   130     CMMAPlayer* FindPlayer(TInt aPlayerHandle);
       
   131 
       
   132     /**
       
   133      * Sets MMA global volume handler
       
   134      * @param aGlobalVolume Global volume handler. The onwership is
       
   135      *        transferred to this class
       
   136      */
       
   137 #ifdef RD_JAVA_VOLUME_CONTROL
       
   138     void SetGlobalVolume(CMMAGlobalVolume* aGlobalVolume);
       
   139 #endif // RD_JAVA_VOLUME_CONTROL
       
   140 
       
   141 		 java::util::FunctionServer* getFunctionServer() const;
       
   142 		 
       
   143 		 JNIEnv* getValidJniEnv();
       
   144     	 jobject getPeer();
       
   145 private:
       
   146     /**
       
   147      * @see StaticAddObjectFromHandleL
       
   148      * @param aHandle Java handle to CBase object
       
   149      */
       
   150     void AddObjectFromHandleL(TInt aHandle);
       
   151 
       
   152 private: // from CJavaEventSource
       
   153     void FinalizeSvr();
       
   154 
       
   155 public: // MMMAEventPoster
       
   156     void PostEvent(CMMAEvent* aEvent, TInt aPriority);
       
   157 
       
   158 private:
       
   159     bool mVmAttached;
       
   160     java::util::FunctionServer* iServer;
       
   161 private:
       
   162     /**
       
   163      * Objects added with StaticAddObjectFromHandleL. Will be destroyed
       
   164      * in server finalization.
       
   165      */
       
   166     RPointerArray< CBase > iObjects;
       
   167 
       
   168     // Owned array of players.
       
   169     RPointerArray< CMMAPlayer > iPlayers;
       
   170 
       
   171     /**
       
   172      * MMA needs ui framework. Window group must be hidden from the
       
   173      * user.
       
   174      */
       
   175     CApaWindowGroupName*    iWgName;
       
   176 
       
   177     /**
       
   178      * Used to check if session was connected in the constructor.
       
   179      */
       
   180     TBool iFbsSessionConnected;
       
   181     TBool iDisposed;
       
   182 
       
   183     // Not owned. Will be informed if it is set.
       
   184     MMMAPlayerInstanceObserver* iInstanceObserver;
       
   185 
       
   186     JavaVM* iJavaVM;
       
   187 
       
   188     // Global volume handler. Owned
       
   189 #ifdef RD_JAVA_VOLUME_CONTROL
       
   190     CMMAGlobalVolume* iGlobalVolume;
       
   191 #endif // RD_JAVA_VOLUME_CONTROL
       
   192 };
       
   193 
       
   194 #endif // CMMAEVENTSOURCE_H