idlehomescreen/hscontentcontrol/src/hscontentcontrolswilistener.cpp
branchRCL_3
changeset 30 b8fae6b8a148
equal deleted inserted replaced
16:9674c1a575e9 30:b8fae6b8a148
       
     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:   Class to listen SWI operations (install/uninstall/restore).
       
    15 *
       
    16 */
       
    17 #include <swi/swiutils.h>
       
    18 #include <sacls.h> // KSWIUidsCurrentlyBeingProcessed
       
    19 
       
    20 #include "hscontentcontrolswilistener.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CHsContentControlSwiListener::NewL()
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CHsContentControlSwiListener* CHsContentControlSwiListener::NewL( 
       
    29             MHsContentControlSwiObserver& aObs )
       
    30     {
       
    31     CHsContentControlSwiListener* self = 
       
    32                 new( ELeave ) CHsContentControlSwiListener( aObs );
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CHsContentControlSwiListener::~CHsContentControlSwiListener()
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CHsContentControlSwiListener::~CHsContentControlSwiListener()
       
    44     {
       
    45     Cancel();
       
    46     iSwInstallKey.Close();
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CHsContentControlSwiListener::DoCancel()
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 void CHsContentControlSwiListener::DoCancel()
       
    54     {
       
    55     if ( IsActive() )
       
    56         {
       
    57         iSwInstallKey.Cancel();
       
    58         }    
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CHsContentControlSwiListener::RunL()
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CHsContentControlSwiListener::RunL()
       
    66     {    
       
    67     RArray<TUid> uidList;
       
    68     
       
    69     // get list of uids being processed.
       
    70     if ( Swi::GetAllUids( uidList ) == KErrNone )
       
    71         {
       
    72         iObs.HandleSwiEvent( uidList );
       
    73         uidList.Reset();
       
    74         }
       
    75 
       
    76     // close array
       
    77     uidList.Close();
       
    78 
       
    79     // keep monitoring
       
    80     iSwInstallKey.Subscribe( iStatus );
       
    81     SetActive();
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CHsContentControlSwiListener::CHsContentControlSwiListener()
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CHsContentControlSwiListener::CHsContentControlSwiListener( 
       
    89     MHsContentControlSwiObserver& aObs )
       
    90     : CActive( CActive::EPriorityStandard ),
       
    91     iObs( aObs )
       
    92     {
       
    93     CActiveScheduler::Add( this );
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CHsContentControlSwiListener::ConstructL()
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CHsContentControlSwiListener::ConstructL()
       
   101     {
       
   102     if ( KErrNone == iSwInstallKey.Attach( 
       
   103         KUidSystemCategory, KSWIUidsCurrentlyBeingProcessed ) )
       
   104         {
       
   105         iSwInstallKey.Subscribe( iStatus );
       
   106         SetActive();
       
   107         }
       
   108     }
       
   109