homescreenpluginsrv/hspsmanager/inc/hspsfilechangelisteneremu.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  ChspsFileChangeListenerEmu listens to given file folder and notifies it observer
       
    15 *                if there is any file change. Observer is given as a parameter on 
       
    16 *                initialising the listener. Observer must implement MhspsEmuFileChangeObserver-interface.
       
    17 *                FileChangeListener is intended to be used by any object that wants listen Windows file system events
       
    18 *                like file drag/drop events.
       
    19 *                This listener works only in emulator environment.        
       
    20 *
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 #ifndef __CFILECHANGEEMU_H__
       
    26 #define __CFILECHANGEEMU_H__
       
    27 
       
    28 #include "hsps_builds_cfg.hrh"
       
    29 
       
    30 #ifdef _hsps_EMULATOR_SUPPORT_
       
    31 
       
    32 #include <e32base.h>
       
    33 #include <s32file.h>
       
    34 #include <badesca.h>
       
    35 
       
    36 #ifdef HSPS_LOG_ACTIVE
       
    37 class ChspsLogBus;
       
    38 #endif
       
    39 
       
    40 const TInt KFileSystemPollingTime = 5000000;
       
    41 const TInt KFilelistGranularity = 10; 
       
    42 
       
    43 enum TEmuNotifyType
       
    44 	{
       
    45 	/**
       
    46 	Any change
       
    47 	*/
       
    48 	EEmuNotifyAll=0x01,
       
    49 	};
       
    50 	
       
    51 enum TStateType
       
    52 	{
       
    53 	EEmuStateIdle,
       
    54 	EEmuStateRunning
       
    55 	};
       
    56 
       
    57 
       
    58 /** 
       
    59 * MhspsFileChangeObserver is interface definition to be implemented by change events observers.
       
    60 */
       
    61 class MhspsEmuFileChangeObserver
       
    62     {
       
    63     public:
       
    64         virtual void HandleEmuFileSystemChange() = 0;
       
    65     };
       
    66 
       
    67 /**
       
    68 *
       
    69 *
       
    70 *  @lib hspsThemeServer.exe 
       
    71 *  @since S60 3.1
       
    72 */
       
    73 class ChspsFileChangeListenerEmu 
       
    74 : public CTimer
       
    75     {
       
    76     public:  // Constructors and destructor
       
    77 
       
    78         /**
       
    79         * NewL
       
    80         * Two-phased constructor.
       
    81         */
       
    82         static ChspsFileChangeListenerEmu* NewL( RFs& aFs, 
       
    83             MhspsEmuFileChangeObserver& aObserver,
       
    84             TEmuNotifyType aNotifyType, 
       
    85             const TDesC& aPath);
       
    86         /**
       
    87         * ~ChspsFileChangeListenerEmu
       
    88         * Destructor.
       
    89         */
       
    90         virtual ~ChspsFileChangeListenerEmu();
       
    91 
       
    92     public:
       
    93 
       
    94         /**
       
    95         * Setup
       
    96         * Starts file change listener.
       
    97         * @since S60 3.1
       
    98         * @return void
       
    99         */
       
   100         void StartL();
       
   101         /**
       
   102         * Stop
       
   103         * Stops file change listener.
       
   104         * @since S60 3.1
       
   105         * @return void
       
   106         */
       
   107         void Stop();
       
   108 
       
   109         /**
       
   110         * Set log bus to be used.
       
   111         * @param aLogBus Log bus to be used.
       
   112         * @return void
       
   113         */
       
   114 #ifdef HSPS_LOG_ACTIVE
       
   115         void SetLogBus( ChspsLogBus* aLogBus );
       
   116 #endif        
       
   117 
       
   118     protected:  // Functions from base classes
       
   119 
       
   120         /**
       
   121         * From CActive Called when asynchronous request has completed
       
   122         * RunL
       
   123         * @since S60 3.1
       
   124         */
       
   125         void RunL();
       
   126 
       
   127         /**
       
   128         * From CActive Called when asynchronous request has failed
       
   129         * RunError
       
   130         * @since S60 3.1
       
   131         */
       
   132         TInt RunError( TInt aError );
       
   133         
       
   134         /**
       
   135         * From CActive, DoCancel.
       
   136         * Cancels any outstanding operation.
       
   137         */
       
   138         void DoCancel();
       
   139 
       
   140     private:
       
   141 
       
   142         /**
       
   143         * ConstructL
       
   144         * By default Symbian 2nd phase constructor is private.
       
   145         */
       
   146         void ConstructL( const TDesC& aFullPath );
       
   147 
       
   148         /**
       
   149         * ChspsFileChangeListenerEmu
       
   150         * C++ default constructor.
       
   151         */
       
   152         ChspsFileChangeListenerEmu( RFs& aFs, 
       
   153             MhspsEmuFileChangeObserver& aObserver,
       
   154             TEmuNotifyType aNotifyType);
       
   155         /**
       
   156         * 
       
   157         * InformObserver
       
   158         * Informs observer of file change
       
   159         * @since S60 3.1
       
   160         */
       
   161         void InformObserver();
       
   162         /**
       
   163         * 
       
   164         * RetrieveFileList
       
   165         * Retrieves current filelist from filesystem
       
   166         * @since S60 3.1
       
   167         * @param aFileList  Destination array for fetched filelist
       
   168         * @param aPath      Source path to read files from
       
   169         */
       
   170         void RetrieveFileListL(CDesCArraySeg& aFileList,const TDesC& aPath);
       
   171         /**
       
   172         * 
       
   173         * CompareFiles
       
   174         * Compares given filelist to filelist in memory
       
   175         * @since S60 3.1
       
   176         * @param    aFileList   Filelist to use comparing against filelist in memory
       
   177         */
       
   178         TBool CompareFilesL(CDesCArraySeg& aFileList);
       
   179         /**
       
   180         * 
       
   181         * StoreFileList
       
   182         * Stores filelist to memory
       
   183         * @since S60 3.1
       
   184         * @param    aFileList   filelist to store to memeory
       
   185         */
       
   186         void StoreFileListL(CDesCArraySeg& aFileList);
       
   187 
       
   188 
       
   189     private:    // Data
       
   190         // Reference to opened File System session
       
   191         RFs&                    iFs;
       
   192     
       
   193         // This object is called when RunL occurs
       
   194         MhspsEmuFileChangeObserver& iObserver;
       
   195 
       
   196         // Type of the notify
       
   197         TEmuNotifyType         iNotifyType;
       
   198 
       
   199         // Full path of folder from where notification is needed
       
   200         TFileName              iFullPath;
       
   201         
       
   202         // Last updated list of files in filesyste
       
   203         CDesCArraySeg          *iFileList;
       
   204         
       
   205         // stores the current state of the listener
       
   206         TStateType             iState;
       
   207 
       
   208 #ifdef HSPS_LOG_ACTIVE        
       
   209         // Log bus. Not owned.
       
   210         ChspsLogBus* iLogBus;
       
   211 #endif        
       
   212     };
       
   213 
       
   214 
       
   215 #endif //_hsps_EMULATOR_SUPPORT_
       
   216 
       
   217 #endif // __CFILECHANGEEMU_H__
       
   218 
       
   219 // End of File