hsappkeyhandler/src/hsappkeyplugin.cpp
changeset 115 3ab5c078b490
parent 109 e0aa398e6810
child 121 0b3699f6c654
equal deleted inserted replaced
109:e0aa398e6810 115:3ab5c078b490
    87 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
    88 // From CSysapKeyHandlerPlugin
    88 // From CSysapKeyHandlerPlugin
    89 // 
    89 // 
    90 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    91 //
    91 //
    92 TKeyResponse CHsAppKeyPlugin::HandleKeyEventL( const TKeyEvent&  aKeyEvent , 
    92 TKeyResponse CHsAppKeyPlugin::HandleKeyEventL(const TKeyEvent &aKeyEvent, 
    93                                               TEventCode  /*aType*/ 
    93                                               TEventCode /*aType*/)
    94                                             )
       
    95 {
    94 {
    96     TKeyResponse retVal(EKeyWasNotConsumed);
    95     TKeyResponse retVal(EKeyWasNotConsumed);
    97     if (aKeyEvent.iCode == EKeyApplication0) {
    96     if (aKeyEvent.iCode == EKeyApplication0) {
    98         if (iSecondEvent) {
    97         if (iSecondEvent) {
    99             if (aKeyEvent.iRepeats > 0)
    98             if (aKeyEvent.iRepeats > 0)
   100                 HandleLongPressL();
    99                 HandleLongPressL();
   101             else 
   100             else 
   102                 HandleShortPressL();
   101                 HandleShortPressL();
   103             retVal = EKeyWasConsumed;
   102             retVal = EKeyWasConsumed;
   104         }
   103         }
   105         iSecondEvent =!iSecondEvent; 
   104         iSecondEvent = !iSecondEvent; 
   106     }
   105     }
   107     return retVal;
   106     return retVal;
   108 }
   107 }
   109 
   108 
   110 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   134 // 
   133 // 
   135 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
   136 //
   135 //
   137 void CHsAppKeyPlugin::HandleShortPressL()
   136 void CHsAppKeyPlugin::HandleShortPressL()
   138 {   
   137 {   
   139     RApaLsSession apaLsSession;
   138     TInt value(0);
   140     CleanupClosePushL(apaLsSession);
   139     RProperty::Get(TsProperty::KCategory, TsProperty::KVisibilityKey, value);
   141     User::LeaveIfError(apaLsSession.Connect());
   140     if (value) {
   142     CAfActivityLauncher *activityEnabler = 
   141         // when Task Switcher dialog is visible, Appkey is used to dismiss it
   143         CAfActivityLauncher::NewLC(apaLsSession, 
   142     
   144                                    iEikEnv->WsSession());
   143         // @todo: remove notification through property when SharedDialog flag
   145     TInt state(0);
   144         // is implemented in Orbit.
   146     RProperty::Get(KHsCategoryUid, KHsCategoryStateKey, state);
   145         if (!mDialog) {
   147     if (state == EHomeScreenIdleState) {
   146             // dismiss dialog launched from HomeScreen
   148         activityEnabler->launchActivityL(KAppLibActivactionUri);
   147             User::LeaveIfError(RProperty::Set(TsProperty::KCategory, TsProperty::KDismissRequestKey, 1));
       
   148         } else {
       
   149             // dismiss dialog launched by this plugin
       
   150             delete mDialog;
       
   151             mDialog = 0;
       
   152         }
   149     } else {
   153     } else {
   150         activityEnabler->launchActivityL(KHsActivactionUri);
   154         // when there is no Task Switcher dialog, Appkey is used to switch between Applib and HomeScreen
   151     }    
   155         RApaLsSession apaLsSession;
   152     CleanupStack::PopAndDestroy(activityEnabler);
   156         CleanupClosePushL(apaLsSession);
   153     CleanupStack::PopAndDestroy(&apaLsSession);
   157         User::LeaveIfError(apaLsSession.Connect());
   154     delete mDialog;
   158         CAfActivityLauncher *activityEnabler = 
   155     mDialog =0;
   159             CAfActivityLauncher::NewLC(apaLsSession, 
       
   160                                        iEikEnv->WsSession());
       
   161         TInt state(0);
       
   162         RProperty::Get(KHsCategoryUid, KHsCategoryStateKey, state);
       
   163         if (state == EHomeScreenIdleState) {
       
   164             activityEnabler->launchActivityL(KAppLibActivactionUri);
       
   165         } else {
       
   166             activityEnabler->launchActivityL(KHsActivactionUri);
       
   167         }    
       
   168         CleanupStack::PopAndDestroy(activityEnabler);
       
   169         CleanupStack::PopAndDestroy(&apaLsSession);
       
   170     }
   156 }
   171 }
   157 
   172 
   158 // ---------------------------------------------------------------------------
   173 // ---------------------------------------------------------------------------
   159 // 
   174 // 
   160 // ---------------------------------------------------------------------------
   175 // ---------------------------------------------------------------------------
   164     if( !mDialog ) {
   179     if( !mDialog ) {
   165         TInt value( 0 );
   180         TInt value( 0 );
   166         RProperty::Get( TsProperty::KCategory, 
   181         RProperty::Get( TsProperty::KCategory, 
   167                     TsProperty::KVisibilityKey,
   182                     TsProperty::KVisibilityKey,
   168                     value );
   183                     value );
   169         if(!value){
   184         if(!value) {
   170             mDialog = CHbDeviceDialogSymbian::NewL();
   185             mDialog = CHbDeviceDialogSymbian::NewL();    
   171     
       
   172             CHbSymbianVariantMap* params = CHbSymbianVariantMap::NewL();
   186             CHbSymbianVariantMap* params = CHbSymbianVariantMap::NewL();
   173         if(KErrNone != mDialog->Show(KTsPluginName,*params,this)) {
   187             if(KErrNone != mDialog->Show(KTsPluginName,*params,this)) {
   174             delete mDialog;
   188                 delete mDialog;
   175             mDialog = 0;
   189                 mDialog = 0;
   176             }
   190             }
   177         delete params;
   191             delete params;
   178         }
   192         }
   179     }
   193     }
   180 }
   194 }
   181 //  End of File
   195 //  End of File
   182 
   196