taskswitcherapp/taskswitcherappecom/src/tsappecom.cpp
changeset 35 f9ce957a272c
equal deleted inserted replaced
5:c743ef5928ba 35:f9ce957a272c
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Taskswitcher application ecom plugin
       
    15  *
       
    16 */
       
    17 
       
    18  
       
    19 #include <e32property.h>
       
    20 #include <apgtask.h>
       
    21 #include <eikenv.h>
       
    22 
       
    23 #include "tsappecomconst.hrh"
       
    24 #include "tsappecom.h"
       
    25 
       
    26 // AknCapServer UID, used for P&S category
       
    27 const TUid KTaskswitcherStateCategory = { 0x10207218 };
       
    28 
       
    29 // Taskswitcher UI, used as P&S key
       
    30 const TUint KTaskswitcherStateKey = 0x2002677D;
       
    31 
       
    32 // Values for Taskswitcher launching P&S
       
    33 const TInt KTaskswitcherBackgroundValue = 1;
       
    34 const TInt KTaskswitcherForegroundValue = KTaskswitcherBackgroundValue << 1;
       
    35 const TInt KTaskswitcherLongAppKeyPressed = KTaskswitcherForegroundValue << 1;
       
    36 
       
    37 // Taskswitcher application UID, for checking if taskswitcher is running
       
    38 const TUid KTaskswitcherAppUidValue = { 0x2002677D };
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CTsEcomPlugin::CTsEcomPlugin()
       
    42 // Default constructor for first phase construction.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CTsEcomPlugin::CTsEcomPlugin()
       
    46     {
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CTsEcomPlugin::NewL()
       
    51 // Standard NewL.
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CTsEcomPlugin* CTsEcomPlugin::NewL()
       
    55     {
       
    56     CTsEcomPlugin* self = new ( ELeave ) CTsEcomPlugin;
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CTsEcomPlugin::ConstructL()
       
    65 // 2nd phase construction.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CTsEcomPlugin::ConstructL()
       
    69     {    
       
    70     DefineTaskswitcherStateProperty();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CTsEcomPlugin::~CTsEcomPlugin()
       
    75 // Destructor.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CTsEcomPlugin::~CTsEcomPlugin()
       
    79     {
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CTsEcomPlugin::Show
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CTsEcomPlugin::Show()
       
    87     {
       
    88     TInt value( 0 );
       
    89     RProperty::Get( KTaskswitcherStateCategory, KTaskswitcherStateKey, value );
       
    90     value &= ~KTaskswitcherBackgroundValue;
       
    91     value |= KTaskswitcherForegroundValue;
       
    92     value |= KTaskswitcherLongAppKeyPressed;
       
    93     SetTaskswitcherStateProperty( value );  
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CTsEcomPlugin::Dismiss
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CTsEcomPlugin::Dismiss()
       
   101     {
       
   102     TInt value( 0 );
       
   103     RProperty::Get( KTaskswitcherStateCategory, KTaskswitcherStateKey, value );
       
   104     value &= ~KTaskswitcherForegroundValue;
       
   105     value |= KTaskswitcherBackgroundValue;
       
   106     SetTaskswitcherStateProperty( value );  
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CTsEcomPlugin::HandleLongAppKeyPress
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CTsEcomPlugin::HandleLongAppKeyPress()
       
   114     {
       
   115     TInt value( 0 );
       
   116     RProperty::Get( KTaskswitcherStateCategory, KTaskswitcherStateKey, value );
       
   117     value |= KTaskswitcherLongAppKeyPressed;
       
   118     SetTaskswitcherStateProperty( value );    
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CTsEcomPlugin::HandleShortAppKeyPress
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CTsEcomPlugin::HandleShortAppKeyPress()
       
   126     { 
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CTsEcomPlugin::IsVisible
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 TBool CTsEcomPlugin::IsVisible()
       
   134     {
       
   135     TInt value( 0 );
       
   136     RProperty::Get( KTaskswitcherStateCategory, KTaskswitcherStateKey, value );
       
   137     if ( value & KTaskswitcherForegroundValue )
       
   138         {
       
   139         return ETrue;
       
   140         }
       
   141     return EFalse;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CTsEcomPlugin::IsReady
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 TBool CTsEcomPlugin::IsReady()
       
   149     {
       
   150     TBool ret = EFalse;    
       
   151     CEikonEnv* eikonEnv = CEikonEnv::Static();
       
   152     
       
   153     if ( eikonEnv )
       
   154         {
       
   155         TApaTaskList taskList( eikonEnv->WsSession() );
       
   156         TApaTask task = taskList.FindApp( KTaskswitcherAppUidValue ); 
       
   157     
       
   158         if ( task.Exists() )
       
   159             {
       
   160             ret = ETrue;
       
   161             }
       
   162         }
       
   163     
       
   164     return ret;
       
   165     }
       
   166     
       
   167 // -----------------------------------------------------------------------------
       
   168 // CTsEcomPlugin::SetTaskswitcherStateProperty
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CTsEcomPlugin::SetTaskswitcherStateProperty( TInt aValue )
       
   172     {
       
   173     if ( RProperty::Set( 
       
   174             KTaskswitcherStateCategory, KTaskswitcherStateKey, aValue ) != KErrNone )
       
   175         {
       
   176         DefineTaskswitcherStateProperty();
       
   177         RProperty::Set( KTaskswitcherStateCategory, KTaskswitcherStateKey, aValue );      
       
   178         }
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CTsEcomPlugin::DefineTaskswitcherStateProperty
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CTsEcomPlugin::DefineTaskswitcherStateProperty()
       
   186     {
       
   187     RProperty::Define( 
       
   188         KTaskswitcherStateCategory, KTaskswitcherStateKey, RProperty::EInt );
       
   189             
       
   190     }
       
   191 
       
   192 // End of file