csxhelp/src/csxhruntimeappwatcher.cpp
changeset 0 1f04cf54edd8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/csxhelp/src/csxhruntimeappwatcher.cpp	Tue Jan 26 15:15:23 2010 +0200
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCSXHRuntimeAppWatcher class definition
+*
+*/
+
+
+#include "csxhruntimeappwatcher.h"
+#include "csxhconstants.h"
+
+// ========================================================================
+// CCSXHRuntimeAppWatcher
+// ========================================================================
+//
+CCSXHRuntimeAppWatcher::CCSXHRuntimeAppWatcher()
+                         : CActive( CActive::EPriorityIdle )
+    {
+    }
+    
+CCSXHRuntimeAppWatcher::~CCSXHRuntimeAppWatcher()
+    {
+    if ( IsActive() )
+        Cancel();
+    iFileSession.Close();
+    }
+    
+CCSXHRuntimeAppWatcher* CCSXHRuntimeAppWatcher::NewL()
+    {
+    CCSXHRuntimeAppWatcher* self = new ( ELeave ) CCSXHRuntimeAppWatcher();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+void CCSXHRuntimeAppWatcher::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    User::LeaveIfError( iFileSession.Connect() );
+    }
+    
+void CCSXHRuntimeAppWatcher::RunL()
+    {
+    // iStatus equals to KErrNone means completion
+    //
+    if ( iStatus == KErrNone )
+        {
+        iObserver->RuntimeUpdateIndex();
+        Start();
+        }
+        
+    }
+    
+void CCSXHRuntimeAppWatcher::DoCancel()
+    {
+    iFileSession.NotifyChangeCancel( iStatus );
+    }
+    
+void CCSXHRuntimeAppWatcher::Start()
+    {
+    // Requests a notification of change to files or directories
+    // Addition or deletion of a directory entry, or changing or formatting a disk
+    //
+    TBuf<KMaxFileName> obsrvPath;
+    obsrvPath.Append( TChar('?') );
+    obsrvPath.Append( KInstallPath );
+    iFileSession.NotifyChange( ENotifyEntry, iStatus, obsrvPath );
+    
+    // starts
+    SetActive();
+    }
+    
+void CCSXHRuntimeAppWatcher::SetObserver( MInstallationObserver* aObserver )
+    {
+    iObserver = aObserver;
+    }