taskswitcher/contextengine/tsfswpreviewprovider/src/tspropertylistener.cpp
changeset 4 4d54b72983ae
child 15 ff572dfe6d86
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2008 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 
       
    10 #include "tspropertylistener.h"
       
    11 #include "previewproviderlogging.h"
       
    12 
       
    13 
       
    14 
       
    15 // --------------------------------------------------------------------------
       
    16 // CTsPropertyListener::~CTsPropertyListener
       
    17 // --------------------------------------------------------------------------
       
    18 //
       
    19 CTsPropertyListener::~CTsPropertyListener()
       
    20     {
       
    21     Cancel();
       
    22     iProperty.Close();
       
    23     }
       
    24 
       
    25 // --------------------------------------------------------------------------
       
    26 // CTsPropertyListener::CTsPropertyListener
       
    27 // --------------------------------------------------------------------------
       
    28 //
       
    29 CTsPropertyListener::CTsPropertyListener( MTsFastSwapPreviewObserver& aObs ) : 
       
    30     CActive( CActive::EPriorityHigh ), iObs( aObs )
       
    31     {
       
    32     }
       
    33 
       
    34 // --------------------------------------------------------------------------
       
    35 // CTsPropertyListener::NewL
       
    36 // --------------------------------------------------------------------------
       
    37 //
       
    38 CTsPropertyListener* CTsPropertyListener::NewL( MTsFastSwapPreviewObserver& aObs )
       
    39     {
       
    40     CTsPropertyListener* self = new ( ELeave ) CTsPropertyListener( aObs );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;    
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // CTsPropertyListener::RunL
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 void CTsPropertyListener::RunL()
       
    52     {
       
    53     // Resubscribe before processing new value to prevent missing updates
       
    54     Subscribe();
       
    55     
       
    56     // Read all properties to member variables
       
    57     ReadPropertiesL();
       
    58     
       
    59     // Do the callback
       
    60     switch( iOperation )
       
    61         {
       
    62         case EOperationUnregister:
       
    63             {
       
    64             iObs.HandleFswPpApplicationUnregistered( iWgId );
       
    65             break;            
       
    66             }        
       
    67         case EOperationBitmapUpdated:
       
    68             {
       
    69             iObs.HandleFswPpApplicationChange( iWgId, iFbsBitmapId );
       
    70             break;
       
    71             }
       
    72         default:
       
    73             break;
       
    74         }
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------
       
    78 // CTsPropertyListener::DoCancel
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 void CTsPropertyListener::DoCancel()
       
    82     {
       
    83     iProperty.Cancel();
       
    84     }
       
    85 
       
    86 // --------------------------------------------------------------------------
       
    87 // CTsPropertyListener::ReadProperties
       
    88 // --------------------------------------------------------------------------
       
    89 //
       
    90 void CTsPropertyListener::ReadPropertiesL()
       
    91     {
       
    92     // Read all properties
       
    93     User::LeaveIfError( iProperty.Get( KPSUidPreviewProvider, KPSKeyWgId, iWgId ) );
       
    94     User::LeaveIfError( iProperty.Get( KPSUidPreviewProvider, KPSKeyFbsBitmapId, iFbsBitmapId ) );
       
    95     TInt operation( 0 );
       
    96     User::LeaveIfError( iProperty.Get( KPSUidPreviewProvider, KPSKeyOperation, operation ) );
       
    97     iOperation = static_cast<TPreviewOperation>( operation );    
       
    98     }
       
    99 
       
   100 // --------------------------------------------------------------------------
       
   101 // CTsPropertyListener::DefinePropertyL
       
   102 // --------------------------------------------------------------------------
       
   103 //
       
   104 void CTsPropertyListener::DefinePropertyL( TInt aPSKey )
       
   105     {
       
   106     TInt err = RProperty::Define( KPSUidPreviewProvider, aPSKey, RProperty::EInt );
       
   107     // Don't mind the already exists error
       
   108     if ( err != KErrAlreadyExists && err != KErrPermissionDenied )
       
   109         {
       
   110         User::LeaveIfError( err );
       
   111         }    
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // CTsPropertyListener::Subscribe
       
   116 // --------------------------------------------------------------------------
       
   117 //
       
   118 void CTsPropertyListener::Subscribe()
       
   119     {
       
   120     iProperty.Subscribe( iStatus );
       
   121     SetActive();  
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // CTsPropertyListener::ConstructL
       
   126 // --------------------------------------------------------------------------
       
   127 //
       
   128 void CTsPropertyListener::ConstructL()
       
   129     {
       
   130     TSLOG_CONTEXT( ConstructL, TSLOG_LOCAL );
       
   131     TSLOG_IN();
       
   132     
       
   133     DefinePropertyL( KPSKeyWgId );
       
   134     DefinePropertyL( KPSKeyFbsBitmapId );
       
   135     DefinePropertyL( KPSKeyOperation );
       
   136     
       
   137     User::LeaveIfError( iProperty.Attach( KPSUidPreviewProvider, KPSKeyWgId ) );
       
   138     CActiveScheduler::Add( this );
       
   139     
       
   140     // initial subscription
       
   141     Subscribe();
       
   142     
       
   143     TSLOG_OUT();
       
   144     }
       
   145 
       
   146 // End of file
       
   147