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