taskswitcher/contextengine/hgfswserver/engine/src/hgfshiddenapplist.cpp
changeset 4 4d54b72983ae
parent 3 fb3763350a08
child 5 c743ef5928ba
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : hgfshiddenapplist.cpp
       
     4 *  Part of     : Hg Teleport / Fast Swap module
       
     5 *  Description : Class that checks if chosen applications should be hidden
       
     6 *                from the task swap.
       
     7 *  Version     : %version: sa1spcx1#3 %
       
     8 *
       
     9 *  Copyright 2008 Nokia.  All rights reserved.
       
    10 *  This material, including documentation and any related computer
       
    11 *  programs, is protected by copyright controlled by Nokia.  All
       
    12 *  rights are reserved.  Copying, including reproducing, storing,
       
    13 *  adapting or translating, any or all of this material requires the
       
    14 *  prior written consent of Nokia.  This material also contains
       
    15 *  confidential information which may not be disclosed to others
       
    16 *  without the prior written consent of Nokia.
       
    17 * ============================================================================
       
    18 */
       
    19 
       
    20 // INCLUDES
       
    21 #include "hgfshiddenapplist.h"
       
    22 #include <apgwgnam.h>
       
    23 
       
    24 #include <eikenv.h>
       
    25 
       
    26 // the maximum size of array (25 32-bit UIDs equal 100 bytes)
       
    27 const TInt KMaxHiddenApps = 25;
       
    28 
       
    29 /**
       
    30  * Category id for the hidden application list.
       
    31  */
       
    32 const TUid KPSUidUikon = { 0x101F8773 };
       
    33 const TUint32 KUikAppHiddenList  = 0x00000010;
       
    34 
       
    35 /**
       
    36  * Apps that are always hidden, no matter what settings the system reports.
       
    37  */
       
    38 const TUint32 KHgFsAlwaysHiddenUidArray[] =
       
    39     {
       
    40     0x100056CF // screensaver
       
    41     };
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CHgFsHiddenAppList::NewL
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CHgFsHiddenAppList* CHgFsHiddenAppList::NewL(
       
    48         MHgFsHiddenAppListObserver& aObserver )
       
    49     {
       
    50     CHgFsHiddenAppList* self =
       
    51         new ( ELeave ) CHgFsHiddenAppList( aObserver );
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CHgFsHiddenAppList::NewLC
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CHgFsHiddenAppList* CHgFsHiddenAppList::NewLC(
       
    63         MHgFsHiddenAppListObserver& aObserver )
       
    64     {
       
    65     CHgFsHiddenAppList* self = CHgFsHiddenAppList::NewL( aObserver );
       
    66     CleanupStack::PushL( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CHgFsHiddenAppList::~CHgFsHiddenAppList
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CHgFsHiddenAppList::~CHgFsHiddenAppList()
       
    75     {
       
    76     Cancel();
       
    77 
       
    78     ResetArray();
       
    79     delete iHiddenAppList;
       
    80 
       
    81     iProperty.Close();
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CHgFsHiddenAppList::IsHiddenL
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TBool CHgFsHiddenAppList::IsHiddenL( TUid aAppUid,
       
    89                                      const RWsSession& aWsSession,
       
    90                                      TInt aWgId )
       
    91     {
       
    92     TBool ret = EFalse;
       
    93 
       
    94     CApaWindowGroupName* windowName =
       
    95                         CApaWindowGroupName::NewLC( aWsSession, aWgId );
       
    96 
       
    97     if ( windowName->Hidden() )
       
    98         {
       
    99         ret = ETrue;
       
   100         }
       
   101     else
       
   102         {
       
   103         for ( TInt i = 0, ie = iHiddenAppList->Count(); i != ie; ++i )
       
   104             {
       
   105             if ( aAppUid.iUid == iHiddenAppList->At( i ) )
       
   106                 {
       
   107                 ret = ETrue;
       
   108                 break;
       
   109                 }
       
   110             }
       
   111         if ( !ret )
       
   112             {
       
   113             for ( TInt i = 0,
       
   114                     arrCnt = sizeof( KHgFsAlwaysHiddenUidArray ) / sizeof( TUint32 );
       
   115                     i != arrCnt; ++i )
       
   116                 {
       
   117                 if ( KHgFsAlwaysHiddenUidArray[i] == aAppUid.iUid )
       
   118                     {
       
   119                     ret = ETrue;
       
   120                     break;
       
   121                     }
       
   122                 }
       
   123             }
       
   124         }
       
   125 
       
   126     CleanupStack::PopAndDestroy( windowName );
       
   127     return ret;
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CHgFsHiddenAppList::CHgFsHiddenAppList
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 CHgFsHiddenAppList::CHgFsHiddenAppList(
       
   135         MHgFsHiddenAppListObserver& aObserver )
       
   136             :CActive( CActive::EPriorityHigh ), iObserver( aObserver )
       
   137     {
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CHgFsHiddenAppList::ConstructL
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CHgFsHiddenAppList::ConstructL()
       
   145     {
       
   146     const TInt KMaxGranularity = 4;
       
   147     CActiveScheduler::Add( this );
       
   148 
       
   149     iHiddenAppList = new (ELeave) CArrayFixFlat<TInt>( KMaxGranularity );
       
   150     User::LeaveIfError( iProperty.Attach( KPSUidUikon, KUikAppHiddenList, EOwnerThread ) );
       
   151 
       
   152     // must not call RunL directly from here as things are not fully initialized yet
       
   153     TRequestStatus* status = &iStatus;
       
   154     User::RequestComplete( status, KErrNone );
       
   155     SetActive();
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CHgFsHiddenAppList::ResetArray
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CHgFsHiddenAppList::ResetArray()
       
   163     {
       
   164     if ( iHiddenAppList )
       
   165         {
       
   166         iHiddenAppList->Reset();
       
   167         }
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CHgFsHiddenAppList::UpdateListL
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CHgFsHiddenAppList::UpdateListL()
       
   175     {
       
   176     ResetArray();
       
   177 
       
   178     // hidden list array
       
   179     TBuf16 <2*KMaxHiddenApps> hiddenList;
       
   180     iProperty.Get( hiddenList );
       
   181 
       
   182     for ( TInt i = 0; i < hiddenList.Length(); i = i + 2 )
       
   183         {
       
   184         TUint32 uid = 0x00000000;
       
   185         uid = hiddenList[i];
       
   186         uid = uid << 16; // codescanner::magicnumbers
       
   187         uid |= hiddenList[i+1];
       
   188 
       
   189         if ( uid != 0 )
       
   190             {
       
   191             iHiddenAppList->AppendL( uid );
       
   192             }
       
   193         else
       
   194             {
       
   195             break;
       
   196             }
       
   197         }
       
   198 
       
   199     iObserver.HiddenAppListUpdated();
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CHgFsHiddenAppList::DoCancel
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CHgFsHiddenAppList::DoCancel()
       
   207     {
       
   208     iProperty.Cancel();
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CHgFsHiddenAppList::RunL
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CHgFsHiddenAppList::RunL()
       
   216     {
       
   217     if ( !IsActive() )
       
   218         {
       
   219         iProperty.Subscribe( iStatus );
       
   220         SetActive();
       
   221         }
       
   222     UpdateListL();
       
   223     }
       
   224 
       
   225 
       
   226 // end of file