homescreenpluginsrv/hspsmanager/inc/hspsfilechangelistener.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  FileChangeListener 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 MhspsFileChangeObserver-interface.
       
    17 *                FileChangeListener is asynchronous object that deploys Symbian RFs client-side
       
    18 *                handle on File Manager. FileChangeListener is intended to be used by any object
       
    19 *                that wants listen Symbian file system events.
       
    20 *
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 #ifndef __ChspsFILECHANGELISTENER_H__
       
    26 #define __ChspsFILECHANGELISTENER_H__
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <s32file.h>
       
    30 
       
    31 #include "hsps_builds_cfg.hrh"
       
    32 #ifdef _hsps_EMULATOR_SUPPORT_
       
    33 #include "hspsfilechangelisteneremu.h"
       
    34 #endif
       
    35 
       
    36 #ifdef HSPS_LOG_ACTIVE
       
    37 class ChspsLogBus;
       
    38 #endif
       
    39 class RFs;
       
    40 
       
    41 enum TListenerType
       
    42 {
       
    43   TListenerNone,
       
    44   TImportDirListener,
       
    45   TRepositoryListener,
       
    46 };
       
    47 
       
    48 /** 
       
    49 * @ingroup group_hspsserver
       
    50 * MhspsFileChangeObserver is interface definition to be implemented by change events observers.
       
    51 */
       
    52 class MhspsFileChangeObserver
       
    53     {
       
    54     public:
       
    55         virtual void HandleFileSystemChange() = 0;
       
    56         virtual void HandleRepositoryChange() = 0;
       
    57     };
       
    58 
       
    59 
       
    60 /**
       
    61 *
       
    62 *  @ingroup group_hspsserver
       
    63 *  FileChangeListener listens to given file folder and notifies it observer
       
    64 *  if there is any file change. Observer is given as a parameter on 
       
    65 *  initialising the listener. Observer must implement MhspsFileChangeObserver-interface.
       
    66 *  FileChangeListener is asynchronous object that deploys Symbian RFs client-side
       
    67 *  handle on File Manager. FileChangeListener is intended to be used by any object
       
    68 *  that wants listen Symbian file system events
       
    69 *  @lib hspsThemeServer.exe 
       
    70 *  @since S60 5.0
       
    71 */
       
    72 class ChspsFileChangeListener 
       
    73 : public CActive
       
    74 #ifdef _hsps_EMULATOR_SUPPORT_
       
    75 ,public MhspsEmuFileChangeObserver
       
    76 #endif
       
    77     {
       
    78     public:  // Constructors and destructor
       
    79 
       
    80         /**
       
    81         * NewL
       
    82         * Two-phased constructor.
       
    83         */
       
    84         static ChspsFileChangeListener* NewL( RFs& aFs, 
       
    85             MhspsFileChangeObserver& aObserver,
       
    86             TNotifyType aNotifyType, 
       
    87             const TDesC& aPath,
       
    88             TListenerType aListenerType );
       
    89         /**
       
    90         * ~ChspsFileChangeListener
       
    91         * Destructor.
       
    92         */
       
    93         virtual ~ChspsFileChangeListener();
       
    94 
       
    95     public:
       
    96 
       
    97         /**
       
    98         * Setup
       
    99         * Sets up the file change listener.
       
   100         * @since S60 3.1
       
   101         * @return void
       
   102         */
       
   103         void Setup();
       
   104 #ifdef _hsps_EMULATOR_SUPPORT_
       
   105         /**
       
   106         * Setup
       
   107         * Sets up the file change listener.
       
   108         * @since S60 3.1
       
   109         * @return void
       
   110         */
       
   111         void HandleEmuFileSystemChange();
       
   112 #endif
       
   113 
       
   114         /**
       
   115         * Set log bus to be used.
       
   116         * @param aLogBus Log bus to be used.
       
   117         * @return void
       
   118         */
       
   119 #ifdef HSPS_LOG_ACTIVE
       
   120         void SetLogBus( ChspsLogBus* aLogBus );
       
   121 #endif
       
   122         
       
   123     protected:  // Functions from base classes
       
   124 
       
   125         /**
       
   126         * From CActive Called when asynchronous request has completed
       
   127         * RunL
       
   128         * @since S60 3.1
       
   129         */
       
   130         void RunL();
       
   131 
       
   132         /**
       
   133         * From CActive Called when asynchronous request has failed
       
   134         * RunError
       
   135         * @since S60 3.1
       
   136         */
       
   137         TInt RunError( TInt aError );
       
   138 
       
   139         /**
       
   140         * DoCancel
       
   141         * From CActive Called when asynchronous request was cancelled
       
   142         * @since S60 3.1
       
   143         */
       
   144         void DoCancel();
       
   145 
       
   146     private:
       
   147 
       
   148         /**
       
   149         * ConstructL
       
   150         * By default Symbian 2nd phase constructor is private.
       
   151         */
       
   152         void ConstructL( const TDesC& aFullPath );
       
   153 
       
   154         /**
       
   155         * ChspsFileChangeListener
       
   156         * C++ default constructor.
       
   157         */
       
   158         ChspsFileChangeListener( RFs& aFs, 
       
   159             MhspsFileChangeObserver& aObserver,
       
   160             TNotifyType aNotifyType,
       
   161             TListenerType aListenerType );
       
   162         /**
       
   163         * Informs observer
       
   164         * InformObserver
       
   165         * @since S60 3.1
       
   166         */
       
   167         void InformObserver();
       
   168 
       
   169     private:    // Data
       
   170 
       
   171         // Ref: Reference to opened File System session
       
   172         RFs&                iFs;
       
   173 
       
   174         // Ref: This object is called when RunL occurs
       
   175         MhspsFileChangeObserver& iObserver;
       
   176 
       
   177         // Type of the notify, entry or disk.
       
   178         TNotifyType         iNotifyType;
       
   179 
       
   180         // Full path of folder from where notification is needed
       
   181         TFileName           iFullPath;
       
   182         TListenerType iListenerType;
       
   183 
       
   184 #ifdef HSPS_LOG_ACTIVE        
       
   185         // Log bus. Not owned.
       
   186         ChspsLogBus* iLogBus;
       
   187 #endif        
       
   188 
       
   189 #ifdef _hsps_EMULATOR_SUPPORT_
       
   190         ChspsFileChangeListenerEmu* iFileChange;
       
   191 #endif
       
   192     };
       
   193 
       
   194 
       
   195 #endif // __ChspsFILECHANGELISTENER_H__
       
   196 
       
   197 // End of File