javauis/mmapi_qt/volumekeys/src/cmmaforeground.cpp
changeset 26 dc7c549001d5
parent 23 98ccebc37403
child 47 f40128debb5d
equal deleted inserted replaced
23:98ccebc37403 26:dc7c549001d5
    31 CMMAForeground* CMMAForeground::NewL(MMMAEventPoster* aEventPoster,
    31 CMMAForeground* CMMAForeground::NewL(MMMAEventPoster* aEventPoster,
    32                                      jobject aForegroundListener,
    32                                      jobject aForegroundListener,
    33                                      jmethodID aJavaMethod/* ,
    33                                      jmethodID aJavaMethod/* ,
    34                                      CMIDToolkit* aToolkit*/)
    34                                      CMIDToolkit* aToolkit*/)
    35 {
    35 {
    36     LOG( EJavaMMAPI, EInfo, "CMMAForeground::NewL + ");
    36     LOG(EJavaMMAPI, EInfo, "CMMAForeground::NewL + ");
    37     CMMAForeground* self = new(ELeave) CMMAForeground;
    37     CMMAForeground* self = new(ELeave) CMMAForeground;
    38 
    38 
    39     CleanupStack::PushL(self);
    39     CleanupStack::PushL(self);
    40     self->ConstructL(aEventPoster, aForegroundListener, aJavaMethod/*, aToolkit*/);
    40     self->ConstructL(aEventPoster, aForegroundListener, aJavaMethod/*, aToolkit*/);
    41     CleanupStack::Pop();
    41     CleanupStack::Pop();
    42 
    42 
    43     LOG( EJavaMMAPI, EInfo, "CMMAForeground::NewL - ");
    43     LOG(EJavaMMAPI, EInfo, "CMMAForeground::NewL - ");
    44     return self;
    44     return self;
    45 }
    45 }
    46 
    46 
    47 CMMAForeground::~CMMAForeground()
    47 CMMAForeground::~CMMAForeground()
    48 {
    48 {
    49     LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() + ");
    49     LOG(EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() + ");
    50    /* if (iMidEnv)
    50     /* if (iMidEnv)
    51     {
    51      {
    52         // unregister for getting the foreground change event
    52          // unregister for getting the foreground change event
    53         LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : iMidEnv RemoveObserver +");
    53          LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : iMidEnv RemoveObserver +");
    54         iMidEnv->RemoveObserver(*this);
    54          iMidEnv->RemoveObserver(*this);
    55         LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : iMidEnv RemoveObserver -");
    55          LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : iMidEnv RemoveObserver -");
    56     }
    56      }
    57 
    57 
    58     CEikonEnv* eikEnv = ((CEikonEnv*)CEikonEnv::Static());
    58      CEikonEnv* eikEnv = ((CEikonEnv*)CEikonEnv::Static());
    59 
    59 
    60     if (eikEnv)
    60      if (eikEnv)
    61     {
    61      {
    62         LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : eikEnv RemoveForegroundObserver +");
    62          LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : eikEnv RemoveForegroundObserver +");
    63         eikEnv->RemoveForegroundObserver(*this);
    63          eikEnv->RemoveForegroundObserver(*this);
    64         LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : eikEnv RemoveForegroundObserver -");
    64          LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() : eikEnv RemoveForegroundObserver -");
    65     }
    65      }
    66 */
    66     */
    67     if (iEventPoster && iDeleteRefEvent)
    67     if (iEventPoster && iDeleteRefEvent)
    68     {
    68     {
    69         iEventPoster->PostEvent(iDeleteRefEvent);
    69         iEventPoster->PostEvent(iDeleteRefEvent);
    70     }
    70     }
    71     else
    71     else
    72     {
    72     {
    73         delete iDeleteRefEvent;
    73         delete iDeleteRefEvent;
    74     }
    74     }
    75     delete iForegroundEvent;
    75     delete iForegroundEvent;
    76     delete iActiveScheduler;
    76     delete iActiveScheduler;
    77     LOG( EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() - ");
    77     LOG(EJavaMMAPI, EInfo, "CMMAForeground::~CMMAForeground() - ");
    78 }
    78 }
    79 
    79 
    80 CMMAForeground::CMMAForeground()
    80 CMMAForeground::CMMAForeground()
    81         : iIsForeground(ETrue) // Initialize IsForeground to true, we might have already missed the event (HandleForegroundL), events before observer registration
    81         : iIsForeground(ETrue) // Initialize IsForeground to true, we might have already missed the event (HandleForegroundL), events before observer registration
    82 {
    82 {
    85 void CMMAForeground::ConstructL(MMMAEventPoster* aEventPoster,
    85 void CMMAForeground::ConstructL(MMMAEventPoster* aEventPoster,
    86                                 jobject aForegroundListener,
    86                                 jobject aForegroundListener,
    87                                 jmethodID aJavaMethod /* ,
    87                                 jmethodID aJavaMethod /* ,
    88                                 CMIDToolkit* aToolkit*/) // xm-radio fix
    88                                 CMIDToolkit* aToolkit*/) // xm-radio fix
    89 {
    89 {
    90     LOG1( EJavaMMAPI, EInfo, "CMMAForeground::ConstructL + ISFOREGROUND = %d",iIsForeground);
    90     LOG1(EJavaMMAPI, EInfo, "CMMAForeground::ConstructL + ISFOREGROUND = %d",iIsForeground);
    91 
    91 
    92     iActiveScheduler = new(ELeave) CActiveSchedulerWait();
    92     iActiveScheduler = new(ELeave) CActiveSchedulerWait();
    93     iEventPoster = aEventPoster;
    93     iEventPoster = aEventPoster;
    94     iForegroundListener = aForegroundListener;
    94     iForegroundListener = aForegroundListener;
    95     iJavaMethod = aJavaMethod;
    95     iJavaMethod = aJavaMethod;
   125     {
   125     {
   126         DEBUG("CMMAForeground::ConstructL - eikAppUi->AddForegroundObserverL() + ");
   126         DEBUG("CMMAForeground::ConstructL - eikAppUi->AddForegroundObserverL() + ");
   127         eikEnv->AddForegroundObserverL(*this);
   127         eikEnv->AddForegroundObserverL(*this);
   128         DEBUG("CMMAForeground::ConstructL - eikAppUi->AddForegroundObserverL() - ");
   128         DEBUG("CMMAForeground::ConstructL - eikAppUi->AddForegroundObserverL() - ");
   129     }
   129     }
   130  */
   130      */
   131     LOG( EJavaMMAPI, EInfo, "CMMAForeground::ConstructL - ");
   131     LOG(EJavaMMAPI, EInfo, "CMMAForeground::ConstructL - ");
   132 }
   132 }
   133 
   133 
   134 TBool CMMAForeground::IsForeground()
   134 TBool CMMAForeground::IsForeground()
   135 {
   135 {
   136     LOG2( EJavaMMAPI, EInfo, "THREADID = %d : CMMAForeground::IsForeground : ISFOREGROUND = %d",RThread().Id().Id(),iIsForeground);
   136     LOG2(EJavaMMAPI, EInfo, "THREADID = %d : CMMAForeground::IsForeground : ISFOREGROUND = %d",RThread().Id().Id(),iIsForeground);
   137     return iIsForeground;
   137     return iIsForeground;
   138 }
   138 }
   139 
   139 
   140 void CMMAForeground::SetForeground(TBool aIsForeground)
   140 void CMMAForeground::SetForeground(TBool aIsForeground)
   141 {
   141 {
   142     iIsForeground = aIsForeground;
   142     iIsForeground = aIsForeground;
   143     LOG1( EJavaMMAPI, EInfo, "CMMAForeground::SetForeground - ISFOREGROUND = %d",iIsForeground);
   143     LOG1(EJavaMMAPI, EInfo, "CMMAForeground::SetForeground - ISFOREGROUND = %d",iIsForeground);
   144 }
   144 }
   145 
   145 
   146 // Implement MMIDEnvObserver
   146 // Implement MMIDEnvObserver
   147 /*
   147 /*
   148 void CMMAForeground::HandleSwitchOnL(TBool aSwitchOn)
   148 void CMMAForeground::HandleSwitchOnL(TBool aSwitchOn)
   151 }
   151 }
   152 */
   152 */
   153 /**
   153 /**
   154  * Handles the case when the MIDlet is brought to the foreground.
   154  * Handles the case when the MIDlet is brought to the foreground.
   155  */
   155  */
   156  /*
   156 /*
   157 void CMMAForeground::HandleForegroundL(TBool aForeground)
   157 void CMMAForeground::HandleForegroundL(TBool aForeground)
   158 {
   158 {
   159     LOG1( EJavaMMAPI, EInfo, "CMMAForeground::HandleForegroundL %d", aForeground);
   159    LOG1( EJavaMMAPI, EInfo, "CMMAForeground::HandleForegroundL %d", aForeground);
   160     iIsForeground = aForeground;
   160    iIsForeground = aForeground;
   161 }
   161 }
   162 */
   162 */
   163 /**
   163 /**
   164  * Handles a change to resources which are shared accross the environment.
   164  * Handles a change to resources which are shared accross the environment.
   165  */
   165  */