csxhelp/src/csxhruntimeappwatcher.cpp
branchRCL_3
changeset 18 cbffe13eac63
parent 0 1f04cf54edd8
equal deleted inserted replaced
17:12f60d9a73b3 18:cbffe13eac63
       
     1 /*
       
     2 * Copyright (c) 2006 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:  CCSXHRuntimeAppWatcher class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "csxhruntimeappwatcher.h"
       
    20 #include "csxhconstants.h"
       
    21 
       
    22 // ========================================================================
       
    23 // CCSXHRuntimeAppWatcher
       
    24 // ========================================================================
       
    25 //
       
    26 CCSXHRuntimeAppWatcher::CCSXHRuntimeAppWatcher()
       
    27                          : CActive( CActive::EPriorityIdle )
       
    28     {
       
    29     }
       
    30     
       
    31 CCSXHRuntimeAppWatcher::~CCSXHRuntimeAppWatcher()
       
    32     {
       
    33     if ( IsActive() )
       
    34         Cancel();
       
    35     iFileSession.Close();
       
    36     }
       
    37     
       
    38 CCSXHRuntimeAppWatcher* CCSXHRuntimeAppWatcher::NewL()
       
    39     {
       
    40     CCSXHRuntimeAppWatcher* self = new ( ELeave ) CCSXHRuntimeAppWatcher();
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46     
       
    47 void CCSXHRuntimeAppWatcher::ConstructL()
       
    48     {
       
    49     CActiveScheduler::Add( this );
       
    50     User::LeaveIfError( iFileSession.Connect() );
       
    51     }
       
    52     
       
    53 void CCSXHRuntimeAppWatcher::RunL()
       
    54     {
       
    55     // iStatus equals to KErrNone means completion
       
    56     //
       
    57     if ( iStatus == KErrNone )
       
    58         {
       
    59         iObserver->RuntimeUpdateIndex();
       
    60         Start();
       
    61         }
       
    62         
       
    63     }
       
    64     
       
    65 void CCSXHRuntimeAppWatcher::DoCancel()
       
    66     {
       
    67     iFileSession.NotifyChangeCancel( iStatus );
       
    68     }
       
    69     
       
    70 void CCSXHRuntimeAppWatcher::Start()
       
    71     {
       
    72     // Requests a notification of change to files or directories
       
    73     // Addition or deletion of a directory entry, or changing or formatting a disk
       
    74     //
       
    75     TBuf<KMaxFileName> obsrvPath;
       
    76     obsrvPath.Append( TChar('?') );
       
    77     obsrvPath.Append( KInstallPath );
       
    78     iFileSession.NotifyChange( ENotifyEntry, iStatus, obsrvPath );
       
    79     
       
    80     // starts
       
    81     SetActive();
       
    82     }
       
    83     
       
    84 void CCSXHRuntimeAppWatcher::SetObserver( MInstallationObserver* aObserver )
       
    85     {
       
    86     iObserver = aObserver;
       
    87     }