taskswitcher/teleportui/hgteleportappecom/src/hgteleportappecom.cpp
changeset 4 4d54b72983ae
parent 3 fb3763350a08
child 5 c743ef5928ba
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
     1 /*
       
     2  * ===========================================================================
       
     3  *  Name        : hgteleportappecom.cpp
       
     4  *  Part of     : Teleport
       
     5  *  Description : Teleport application ecom plugin
       
     6  *  Version     : %version:  sa1spcx1#8.1.2 %
       
     7  *
       
     8  *  Copyright © 2009 Nokia Corporation.
       
     9  *  This material, including documentation and any related 
       
    10  *  computer programs, is protected by copyright controlled by 
       
    11  *  Nokia Corporation. All rights are reserved. Copying, 
       
    12  *  including reproducing, storing, adapting or translating, any 
       
    13  *  or all of this material requires the prior written consent of 
       
    14  *  Nokia Corporation. This material also contains confidential 
       
    15  *  information which may not be disclosed to others without the 
       
    16  *  prior written consent of Nokia Corporation.
       
    17  * ===========================================================================
       
    18  */
       
    19  
       
    20 #include <e32property.h>
       
    21 #include <apgtask.h>
       
    22 #include <eikenv.h>
       
    23 
       
    24 #include "hgteleportappecomconst.hrh"
       
    25 #include "hgteleportappecom.h"
       
    26 
       
    27 #include "hgteleportappecomlogging.h"
       
    28 
       
    29 // AknCapServer UID, used for P&S category
       
    30 const TUid KTeleportStateCategory = { 0x10207218 };
       
    31 
       
    32 // Teleport UI, used as P&S key
       
    33 const TInt KTeleportStateKey = 0x20016BF0;
       
    34 
       
    35 // Values for Teleport launching P&S
       
    36 const TInt KTeleportBackgroundValue = 1;
       
    37 const TInt KTeleportForegroundValue = KTeleportBackgroundValue << 1;
       
    38 const TInt KTeleportShortAppKeyPressed = KTeleportForegroundValue << 1;
       
    39 const TInt KTeleportLongAppKeyPressed = KTeleportShortAppKeyPressed << 1;
       
    40 
       
    41 // Teleport application UID, for checking if teleport is running
       
    42 const TUid KTeleportAppUidValue = { 0x20016BF0 };
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CHgTeleportEcomPlugin::CHgTeleportEcomPlugin()
       
    46 // Default constructor for first phase construction.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CHgTeleportEcomPlugin::CHgTeleportEcomPlugin()
       
    50     {
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CHgTeleportEcomPlugin::NewL()
       
    55 // Standard NewL.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CHgTeleportEcomPlugin* CHgTeleportEcomPlugin::NewL()
       
    59     {
       
    60     CHgTeleportEcomPlugin* self = new ( ELeave ) CHgTeleportEcomPlugin;
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop( self );
       
    64     return self;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CHgTeleportEcomPlugin::ConstructL()
       
    69 // 2nd phase construction.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CHgTeleportEcomPlugin::ConstructL()
       
    73     {
       
    74     HGLOG_CONTEXT( CHgTeleportEcomPlugin::ConstructL, HGLOG_LOCAL );
       
    75     HGLOG_IN();
       
    76     
       
    77     DefineTeleportStateProperty();
       
    78     
       
    79     HGLOG_OUT();
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CHgTeleportEcomPlugin::~CHgTeleportEcomPlugin()
       
    84 // Destructor.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CHgTeleportEcomPlugin::~CHgTeleportEcomPlugin()
       
    88     {
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CHgTeleportEcomPlugin::Show
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CHgTeleportEcomPlugin::Show()
       
    96     {
       
    97     HGLOG_CONTEXT( CHgTeleportEcomPlugin::Show, HGLOG_LOCAL );
       
    98     HGLOG_IN();
       
    99     
       
   100     TInt value( 0 );
       
   101     RProperty::Get( KTeleportStateCategory, KTeleportStateKey, value );
       
   102     value &= ~KTeleportBackgroundValue;
       
   103     value |= KTeleportForegroundValue;
       
   104     SetTeleportStateProperty( value );  
       
   105     
       
   106     HGLOG_OUT();    
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CHgTeleportEcomPlugin::Dismiss
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CHgTeleportEcomPlugin::Dismiss()
       
   114     {
       
   115     HGLOG_CONTEXT( CHgTeleportEcomPlugin::Dismiss, HGLOG_LOCAL );
       
   116     HGLOG_IN();
       
   117     
       
   118     TInt value( 0 );
       
   119     RProperty::Get( KTeleportStateCategory, KTeleportStateKey, value );
       
   120     value &= ~KTeleportForegroundValue;
       
   121     value |= KTeleportBackgroundValue;
       
   122     SetTeleportStateProperty( value );  
       
   123     
       
   124     HGLOG_OUT();     
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CHgTeleportEcomPlugin::HandleLongAppKeyPress
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CHgTeleportEcomPlugin::HandleLongAppKeyPress()
       
   132     {
       
   133     HGLOG_CONTEXT( CHgTeleportEcomPlugin::Show, HGLOG_LOCAL );
       
   134     HGLOG_IN();
       
   135     
       
   136     TInt value( 0 );
       
   137     RProperty::Get( KTeleportStateCategory, KTeleportStateKey, value );
       
   138     value &= ~KTeleportShortAppKeyPressed;
       
   139     value |= KTeleportLongAppKeyPressed;
       
   140     SetTeleportStateProperty( value );    
       
   141     
       
   142     HGLOG_OUT();    
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CHgTeleportEcomPlugin::HandleShortAppKeyPress
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CHgTeleportEcomPlugin::HandleShortAppKeyPress()
       
   150     {
       
   151     HGLOG_CONTEXT( CHgTeleportEcomPlugin::Dismiss, HGLOG_LOCAL );
       
   152     HGLOG_IN();
       
   153     
       
   154     TInt value( 0 );
       
   155     RProperty::Get( KTeleportStateCategory, KTeleportStateKey, value );
       
   156     value &= ~KTeleportLongAppKeyPressed;
       
   157     value |= KTeleportShortAppKeyPressed;
       
   158     SetTeleportStateProperty( value ); 
       
   159     
       
   160     HGLOG_OUT();     
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CHgTeleportEcomPlugin::IsVisible
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 TBool CHgTeleportEcomPlugin::IsVisible()
       
   168     {
       
   169     HGLOG_CONTEXT( CHgTeleportEcomPlugin::IsVisible, HGLOG_LOCAL );
       
   170     HGLOG_IN();
       
   171     
       
   172     TInt value( 0 );
       
   173     RProperty::Get( KTeleportStateCategory, KTeleportStateKey, value );
       
   174     if ( value & KTeleportForegroundValue )
       
   175         {
       
   176         HGLOG_OUT();
       
   177         return ETrue;
       
   178         }
       
   179     HGLOG_OUT();
       
   180     return EFalse;
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CHgTeleportEcomPlugin::IsReady
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 TBool CHgTeleportEcomPlugin::IsReady()
       
   188     {
       
   189     HGLOG_CONTEXT( CHgTeleportEcomPlugin::IsReady, HGLOG_LOCAL );
       
   190     HGLOG_IN();
       
   191 
       
   192     TBool ret = EFalse;    
       
   193     CEikonEnv* eikonEnv = CEikonEnv::Static();
       
   194     
       
   195     if ( eikonEnv )
       
   196         {
       
   197         TApaTaskList taskList( eikonEnv->WsSession() );
       
   198         TApaTask task = taskList.FindApp( KTeleportAppUidValue ); 
       
   199     
       
   200         if ( task.Exists() )
       
   201             {
       
   202             ret = ETrue;
       
   203             }
       
   204         }
       
   205     
       
   206     HGLOG1_OUT( "IsReady returns: %d", ret );
       
   207     return ret;
       
   208     }
       
   209     
       
   210 // -----------------------------------------------------------------------------
       
   211 // CHgTeleportEcomPlugin::SetTeleportStateProperty
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 void CHgTeleportEcomPlugin::SetTeleportStateProperty( TInt aValue )
       
   215     {
       
   216     HGLOG_CONTEXT( CHgTeleportEcomPlugin::SetTeleportShowProperty, HGLOG_LOCAL );
       
   217     HGLOG_IN();
       
   218     
       
   219     if ( RProperty::Set( 
       
   220             KTeleportStateCategory, KTeleportStateKey, aValue ) != KErrNone )
       
   221         {
       
   222         DefineTeleportStateProperty();
       
   223         TInt error = 
       
   224             RProperty::Set( KTeleportStateCategory, KTeleportStateKey, aValue );
       
   225         if ( error != KErrNone )
       
   226             {
       
   227             HGLOG1( HGLOG_INFO, "RProperty::Set Error: %d", error ); 
       
   228             }        
       
   229         }
       
   230     
       
   231     HGLOG_OUT();    
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CHgTeleportEcomPlugin::DefineTeleportStateProperty
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 void CHgTeleportEcomPlugin::DefineTeleportStateProperty()
       
   239     {
       
   240     HGLOG_CONTEXT( CHgTeleportEcomPlugin::DefineTeleportShowProperty, HGLOG_LOCAL );
       
   241     HGLOG_IN();
       
   242     
       
   243     TInt error = RProperty::Define( 
       
   244             KTeleportStateCategory, KTeleportStateKey, RProperty::EInt );
       
   245     if ( error != KErrNone )
       
   246         {
       
   247         HGLOG1( HGLOG_INFO, "RProperty::Define Error: %d", error );
       
   248         }              
       
   249     
       
   250     HGLOG_OUT();
       
   251     }
       
   252 
       
   253 // End of file