javauis/mmapi_akn/volumekeys/inc/cmmaforeground.h
branchRCL_3
changeset 26 2455ef1f5bbc
parent 14 04becd199f91
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Class is used to find out from java is midlet foreground or not
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMAFOREGROUND_H
       
    20 #define CMMAFOREGROUND_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "mmmaeventposter.h"
       
    25 #include "cmmadeleterefevent.h"
       
    26 #include "cmmaforegroundevent.h"
       
    27 
       
    28 // xm-radio fix
       
    29 #include "CMIDToolkit.h"
       
    30 #include "lcdui.h"
       
    31 
       
    32 #include <coemain.h>
       
    33 #include <eikenv.h>
       
    34 
       
    35 //  CLASS DECLARATION
       
    36 /**
       
    37 *
       
    38 * Class is used to find out from java is midlet foreground or not
       
    39 */
       
    40 NONSHARABLE_CLASS(CMMAForeground) : public CBase, public MMIDEnvObserver, public MCoeForegroundObserver
       
    41 {
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Creates and returns a new instance of this class.
       
    46      * @param aEventPoster for posting event to java side
       
    47      * @param aForegroundListener java side foreground object
       
    48      * @param aJavaMethod java side method id
       
    49      * @return New instance from this class.
       
    50      */
       
    51     static CMMAForeground* NewL(MMMAEventPoster* aEventPoster,
       
    52     jobject aForegroundListener,
       
    53     jmethodID aJavaMethod,
       
    54     CMIDToolkit* aToolkit); // xm-radio fix
       
    55     /**
       
    56      * Destructor.
       
    57      */
       
    58     ~CMMAForeground();
       
    59 
       
    60 protected:
       
    61 
       
    62     /**
       
    63      * C++ constructor
       
    64      */
       
    65     CMMAForeground();
       
    66 
       
    67     /**
       
    68      * Second phase constructor
       
    69      * @param aEventPoster for posting event to java side
       
    70      * @param aForegroundListener java side foreground object
       
    71      * @param aJavaMethod java side method id
       
    72      */
       
    73     void ConstructL(MMMAEventPoster* aEventPoster,
       
    74                     jobject aForegroundListener,
       
    75                     jmethodID aJavaMethod,
       
    76                     CMIDToolkit* aToolkit); // xm-radio fix
       
    77 
       
    78 
       
    79 public: // New methods
       
    80 
       
    81 
       
    82     /**
       
    83      * Tells is midlet foreground or not
       
    84      * @return boolean
       
    85      */
       
    86     TBool IsForeground();
       
    87 
       
    88     /**
       
    89      * Sets member boolean iIsForeground
       
    90      */
       
    91     void SetForeground(TBool aIsForeground);
       
    92 
       
    93 public: // from MMIDEnvObserver
       
    94 
       
    95     void HandleSwitchOnL(TBool /*aSwitchOn*/);
       
    96 
       
    97     /**
       
    98      * Handles the case when the MIDlet is brought to the foreground.
       
    99      */
       
   100     void HandleForegroundL(TBool /*aForeground*/);
       
   101 
       
   102     /**
       
   103      * Handles a change to resources which are shared accross the environment.
       
   104      */
       
   105     void HandleResourceChangeL(TInt /*aType*/);
       
   106 
       
   107 public:
       
   108     /** Handles the application coming to the foreground. */
       
   109     void HandleGainingForeground();
       
   110 
       
   111     /** Handles the application going into the background. */
       
   112     void HandleLosingForeground();
       
   113 
       
   114 private: // Member data
       
   115 
       
   116     CActiveSchedulerWait* iActiveScheduler; // owned
       
   117     MMMAEventPoster* iEventPoster; // not owned
       
   118     CMMAForegroundEvent* iForegroundEvent; // owned
       
   119 
       
   120     //Event is used to destroy reference to associated java object,
       
   121     //when foreground is destroyed.
       
   122     CMMADeleteRefEvent* iDeleteRefEvent; // owned
       
   123 
       
   124     jobject iForegroundListener;
       
   125     jmethodID iJavaMethod;
       
   126 
       
   127     TBool iIsForeground;
       
   128     // xm-radio fix
       
   129     CMIDToolkit* iToolkit;
       
   130     MMIDEnv* iMidEnv;
       
   131 };
       
   132 
       
   133 #endif // CMMAFOREGROUND_H