|
1 /* |
|
2 * Copyright (c) 2007-2009 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: This is disk space notifier for Metadata server.* |
|
15 */ |
|
16 |
|
17 #ifndef __MDSDISKSPACENOTIFIER_H__ |
|
18 #define __MDSDISKSPACENOTIFIER_H__ |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 /** |
|
25 * MMdSDiskSpaceNotifierObserver |
|
26 * Observer interface for a disk space notifier. |
|
27 */ |
|
28 class MMdSDiskSpaceNotifierObserver |
|
29 { |
|
30 public : |
|
31 enum TDiskSpaceDirection |
|
32 { |
|
33 /** Disk space is larger than threshold level */ |
|
34 EMore, |
|
35 |
|
36 /** Disk space is smaller than threshold level */ |
|
37 ELess |
|
38 }; |
|
39 |
|
40 /** |
|
41 * Called to notify the observer that disk space has crossed the specified threshold value. |
|
42 * |
|
43 * @param aCrossDirection threshold cross direction |
|
44 */ |
|
45 virtual void HandleDiskSpaceNotificationL(TDiskSpaceDirection aDiskSpaceDirection) = 0; |
|
46 |
|
47 /** |
|
48 * Called to if disk space notifier has an error situation. |
|
49 * |
|
50 * @param aError error code |
|
51 */ |
|
52 virtual void HandleDiskSpaceError(TInt aError) = 0; |
|
53 }; |
|
54 |
|
55 /** |
|
56 * CMSDiskSpaceNotifierAO. |
|
57 * A disk space notifier class |
|
58 */ |
|
59 class CMdSDiskSpaceNotifierAO : public CActive |
|
60 { |
|
61 public: |
|
62 enum TDiskSpaceNotifierState |
|
63 { |
|
64 ENormal, |
|
65 EIterate |
|
66 }; |
|
67 |
|
68 public : // Constructors and destructors |
|
69 /** |
|
70 * Constructs a disk space notifier implementation. |
|
71 * |
|
72 * @param aThreshold minimum free disk space threshold level in bytes |
|
73 * @param aFilename filename which defines monitored drive's number |
|
74 * @return metadata server implementation |
|
75 */ |
|
76 static CMdSDiskSpaceNotifierAO* NewL( |
|
77 MMdSDiskSpaceNotifierObserver& aObserver, |
|
78 TInt64 aThreshold, const TDesC& aFilename); |
|
79 |
|
80 /** |
|
81 * Constructs a disk space notifier implementation and leaves it |
|
82 * in the cleanup stack. |
|
83 * |
|
84 * @param aThreshold minimum free disk space threshold level in bytes |
|
85 * @param aFilename filename which defines monitored drive's number |
|
86 * @return metadata server implementation |
|
87 */ |
|
88 static CMdSDiskSpaceNotifierAO* NewLC( |
|
89 MMdSDiskSpaceNotifierObserver& aObserver, |
|
90 TInt64 aThreshold, const TDesC& aFilename); |
|
91 |
|
92 /** |
|
93 * Destructor. |
|
94 */ |
|
95 virtual ~CMdSDiskSpaceNotifierAO(); |
|
96 |
|
97 TBool DiskFull() const; |
|
98 |
|
99 protected: // Functions from base classes |
|
100 /** |
|
101 * From CActive |
|
102 * Callback function. |
|
103 * Invoked to handle responses from the server. |
|
104 */ |
|
105 void RunL(); |
|
106 |
|
107 /** |
|
108 * From CActive |
|
109 * Handles errors that occur during notifying the observer. |
|
110 */ |
|
111 TInt RunError(TInt aError); |
|
112 |
|
113 /** |
|
114 * From CActive |
|
115 * Cancels any outstanding operation. |
|
116 */ |
|
117 void DoCancel(); |
|
118 |
|
119 private: // Constructors and destructors |
|
120 |
|
121 /** |
|
122 * constructor |
|
123 */ |
|
124 CMdSDiskSpaceNotifierAO( |
|
125 MMdSDiskSpaceNotifierObserver& aObserver, |
|
126 TInt64 aThreshold, TDriveNumber aDrive); |
|
127 |
|
128 /** |
|
129 * 2nd phase constructor |
|
130 * @param aThreshold minimum free disk space threshold level in bytes |
|
131 * @param aDrive monitored drive's number |
|
132 */ |
|
133 void ConstructL(); |
|
134 |
|
135 private: // New methods |
|
136 |
|
137 void StartNotifier(); |
|
138 |
|
139 static TDriveNumber GetDriveNumberL( const TDesC& aFilename ); |
|
140 |
|
141 private: // Data |
|
142 |
|
143 MMdSDiskSpaceNotifierObserver& iObserver; |
|
144 |
|
145 RFs iFileServerSession; |
|
146 |
|
147 const TInt64 iThreshold; |
|
148 |
|
149 const TDriveNumber iDrive; |
|
150 |
|
151 TDiskSpaceNotifierState iState; |
|
152 |
|
153 TInt iIterationCount; |
|
154 |
|
155 TBool iDiskFull; |
|
156 }; |
|
157 |
|
158 #endif // __CMDSSERVER_H__ |
|
159 |
|
160 // End of File |