javauis/remconobserver_akn/inc/javaremconobserver.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008-2008 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:  Java RemCon Observer Active Object
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef JAVAREMCONOBSERVER_H
       
    20 #define JAVAREMCONOBSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <remconcoreapi.h>
       
    24 #include <remconcoreapitargetobserver.h>
       
    25 #include <e32msgqueue.h>
       
    26 
       
    27 enum TMethodType
       
    28 {
       
    29     EMethodNone = 0,
       
    30     EMethodMrccatoCommand = 1,
       
    31     EMethodMrccatoPlay = 2,
       
    32 };
       
    33 
       
    34 /**
       
    35  * Class is active object which should be created if some API wants use
       
    36  * RemCon API for receiving events
       
    37  *
       
    38  * Java RunTime needs to listen to various events like volume key press,
       
    39  * media key press and so on. For this purpose, various modules
       
    40  * in Java middleware register with CRemConCoreApiTarget to get events
       
    41  * to the observer MRemConCoreApiTargetObserver.
       
    42  * For this to happen, a target session has to be opened to RemCon,
       
    43  * which is done via CRemConInterfaceSelector::OpenTargetL(). At present,
       
    44  * whichever module wants it (say MMAPI, LCDUI etc) goes ahead and registers
       
    45  * by calling CRemConInterfaceSelector::OpenTargetL(). However when someother
       
    46  * module also calls the same, the OpenTargetL() returns KErrInUse as in
       
    47  * Java all modules are in one single process and one process can have
       
    48  * only one target session open to RemCon. This means that only one of the
       
    49  * required modules will get the events needed.
       
    50  *
       
    51  * Class provides common callback API for events from RemCon
       
    52  *
       
    53  *  @lib javaremconobserver
       
    54  *  @since S60 v3.2
       
    55  */
       
    56 class CJavaRemConObserver : public CActive
       
    57 {
       
    58 private:
       
    59     class TJavaRemConMessage
       
    60     {
       
    61     public:
       
    62         TRemConCoreApiPlaybackSpeed iSpeed;
       
    63         TRemConCoreApiButtonAction iButtonAct;
       
    64         TRemConCoreApiOperationId iOperationId;
       
    65         TInt iMethod;
       
    66     };
       
    67 
       
    68 public:
       
    69 
       
    70     /**
       
    71     * Constructor
       
    72     *
       
    73     * @since S60 v3.2
       
    74     * @param aObserver Set observer, not owned
       
    75     */
       
    76     IMPORT_C static CJavaRemConObserver* NewL(
       
    77         MRemConCoreApiTargetObserver& iObserver);
       
    78 
       
    79     CJavaRemConObserver(MRemConCoreApiTargetObserver& iObserver);
       
    80 
       
    81     ~CJavaRemConObserver();
       
    82 
       
    83     void AddPlayMessage(TRemConCoreApiPlaybackSpeed aSpeed,
       
    84                         TRemConCoreApiButtonAction aButtonAct);
       
    85 
       
    86     void AddCommandMessage(TRemConCoreApiOperationId aOperationId,
       
    87                            TRemConCoreApiButtonAction aButtonAct);
       
    88 
       
    89 protected:
       
    90     void ConstructL();
       
    91 
       
    92 private:
       
    93     void IssueRequest();
       
    94 
       
    95     // From CActive
       
    96     void RunL();
       
    97 
       
    98     void DoCancel();
       
    99 
       
   100 
       
   101 private:
       
   102 
       
   103     /**
       
   104     * Observer called in RunL
       
   105     */
       
   106     MRemConCoreApiTargetObserver& iObserver;
       
   107 
       
   108     /**
       
   109     * Message queue for storing events from RemCon
       
   110     */
       
   111     RMsgQueue<TJavaRemConMessage> iQueue;
       
   112 };
       
   113 
       
   114 #endif // JAVAREMCONOBSERVER_H