00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // 00015 00016 00017 #ifndef __FILECHANGENOTIFIER_H__ 00018 #define __FILECHANGENOTIFIER_H__ 00019 00020 #include <e32base.h> 00021 #include <e32cons.h> 00022 #include <f32file.h> 00023 #include <f32notification.h> 00024 00025 /* 00026 * Demonstrates the various features of Enhanced File change notifier. 00027 * - User gets notified when there is a change in a File. 00028 * - User gets notified when there is a change in a Folder. 00029 * - User gets notified when there is a change in a Drive. 00030 */ 00031 class CChangeNotifier: public CActive 00032 { 00033 public: 00034 static CChangeNotifier* NewL(TInt aPriority = EPriorityStandard); 00035 virtual ~CChangeNotifier(); 00036 void RequestCharacter(); 00037 protected: 00038 void ConstructL(); 00039 00040 public: 00041 enum TFileOperations{ 00042 ECreateFile, 00043 EChangeFileContents, 00044 ERenameFile, 00045 EChangeFileAttributes , 00046 EDeleteFile, 00047 ECreateFolder, 00048 ERenameFolder, 00049 EDeleteFolder, 00050 EVolumeNameChange, 00051 EMultipleNotifications 00052 }; 00053 private: 00054 virtual void DoCancel(); 00055 virtual void RunL(); 00056 void PressAnyKey(); 00057 void NotifyChangeToFile(); // get notified when there is a change in the file. 00058 void NotifyChangeToFolder(); // get notified when there is a change in the folder. 00059 void CreateFile(); // get notified when a new file is created. 00060 void ChangeFileContents(); // get notified when the file contents are changed. 00061 void RenameFile(); // get notified when a file is renamed. 00062 void ChangeFileAttributes (); // get notified when the file attributes change. 00063 void DeleteFile(); // get notified when a file is deleted. 00064 void CreateFolder(); // get notified when a folder is created. 00065 void RenameFolder(); // get notified when a folder is renamed. 00066 void DeleteFolder(); // get notified when a folder is deleted. 00067 void DeleteFileandFolder(); // get notitified when a folder is deleted, file in the folder is also deleted. 00068 void VolumeNameChange(); // get notified when there is a volume name change. 00069 void MultipleNotifications(); // multiple notifications can be requested at once, completed notifications are filled in the buffer. 00070 void DoChanges(CChangeNotifier::TFileOperations operation); // Do file/folder changes. 00071 void ProcessMultipleChanges(const TFsNotification* aNotification); // Process the completion of multiple notifications requested by 'Multiple Notifications' use case. 00072 00073 private: 00074 CChangeNotifier(TInt aPriority = EPriorityStandard ); 00075 /* 00076 * These booleans are used to detect whether the file change operation was performed earlier or not. 00077 * Ex: If a folder is already created and the user tries to create it once again, it prints that the file is created. 00078 */ 00079 TBool iIsCreateFolder; // to verify whether a folder is created or not. 00080 TBool iIsRenameFolder; // to verify whether the rename operation on a folder is performed already. 00081 TBool iIsDeleteFolder; // to verify whether the delete folder operation is performed already. 00082 TBool iIsVolumeNameChange; // to verify whether the volume name change operation is done already. 00083 TBool iIsCreateFile; // to verify whether the file is created in the desired location already. 00084 TBool iIsRenameFile; // to verify whether the rename operation on the file is performed already. 00085 TBool iIsChangeFileAttributes ; // to verify whether the file attributed are changed already. 00086 TBool iIsDeleteFile; // to verify whether the file is deleted already. 00087 TBool iDeleteFileContinue; // this boolean is used when a folder with a file needs to be removed. it removes the file and then calls folder removal. 00088 TBool iIsMultipleNotifications; 00089 RFs iFs; 00090 TChar iDrive; // System drive 00091 TInt iDriveNumber; // drive number of U: drive 00092 TBool iOption; // This boolean is used to exit, if none of the Main menu options is chosen. 00093 TBool iOptionContinue; // it is used to continue with the Main menu, if none of the sub menu options is chosen. 00094 CConsoleBase* iConsole; 00095 CFsNotify* iNotify; // This is client which will be posting notification requests and will be notified after completion of these requests. 00096 TRequestStatus iReqStatus; 00097 }; 00098 #endif // __CHANGENOTIFIER_H__ 00099 00100