1 /* |
|
2 * Copyright (c) 2005-2006 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: Header for CIRDiskSpaceSession |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_IRDISKSPACESESSION_H |
|
19 #define C_IRDISKSPACESESSION_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 class MIRDiskSpaceWatcherObserver; |
|
25 |
|
26 /** |
|
27 * Defines disk space observer. |
|
28 * |
|
29 * Observers defined disk and notifies observer if disk space drops below |
|
30 * certain level. |
|
31 */ |
|
32 NONSHARABLE_CLASS( CIRDiskSpaceSession ) : public CActive |
|
33 { |
|
34 |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Static constructor |
|
39 * |
|
40 * @param aDiskSpaceSessionObserver Observer who is interested if disk |
|
41 * space drops below certain level. |
|
42 * @param aDriveNumber drive to observe |
|
43 * @param aCriticalLevel critical disk space level in bytes. If disk |
|
44 * space falls below this observer is notified. |
|
45 */ |
|
46 static CIRDiskSpaceSession* NewL(MIRDiskSpaceWatcherObserver& |
|
47 aDiskSpaceSessionObserver, |
|
48 const TDriveNumber& aDriveNumber, |
|
49 const TInt64& aCriticalLevel, |
|
50 RFs& aFs ); |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 ~CIRDiskSpaceSession(); |
|
56 |
|
57 /** |
|
58 * Tells observed drive. |
|
59 * |
|
60 * @return Drive number which is been observed by this session. |
|
61 */ |
|
62 TDriveNumber DriveNumber(); |
|
63 |
|
64 /** |
|
65 * Sets observer count |
|
66 * |
|
67 * @param aObserverCount observer count |
|
68 */ |
|
69 void SetObserverCount( TInt aObserverCount ); |
|
70 |
|
71 /** |
|
72 * Returns observer count |
|
73 * |
|
74 * @return observer count |
|
75 */ |
|
76 TInt ObserverCount(); |
|
77 |
|
78 /** |
|
79 * IsBelowCriticalLevel Returns whether or disk defined by parameter |
|
80 * contains less than the critical level free disk space. |
|
81 * |
|
82 * @param aDriveNumber drive which space is checked |
|
83 * @return ETrue if there is less free disk space than the critical |
|
84 * level, otherwise EFalse. |
|
85 */ |
|
86 TBool IsBelowCriticalLevel( const TDriveNumber& aDriveNumber ) const; |
|
87 |
|
88 protected: |
|
89 |
|
90 // from base class CActive |
|
91 /** |
|
92 * From CActive |
|
93 * |
|
94 * @see CActive::DoCancel() |
|
95 */ |
|
96 void DoCancel(); |
|
97 |
|
98 /** |
|
99 * From CActive |
|
100 * |
|
101 * Invoked when the observed disk's free disk space has run |
|
102 * below the supplied critical level. |
|
103 * Notifies the observer and regenerates the request to RFs' |
|
104 * NotifyDiskSpace. |
|
105 * @see CActive::RunL() |
|
106 */ |
|
107 void RunL(); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * C++ default constructor. Sets references. |
|
113 * |
|
114 * @param aDiskSpaceSessionObserver Observer who is interested if disk |
|
115 * space drops below certain level. |
|
116 * @param aDriveNumber drive to observe |
|
117 * @param aCriticalLevel critical disk space level in bytes. If disk |
|
118 * space falls below this observer is notified. |
|
119 */ |
|
120 CIRDiskSpaceSession(MIRDiskSpaceWatcherObserver& |
|
121 aDiskSpaceSessionObserver, |
|
122 const TDriveNumber& aDriveNumber, |
|
123 const TInt64& aCriticalLevel, |
|
124 RFs& aFs ); |
|
125 |
|
126 /** |
|
127 * Second phase constructor |
|
128 */ |
|
129 void ConstructL(); |
|
130 |
|
131 private: |
|
132 |
|
133 /** |
|
134 * The observer to be notified when critical disk space limit is reached. |
|
135 */ |
|
136 MIRDiskSpaceWatcherObserver& iObserver; |
|
137 |
|
138 /** |
|
139 * Drive to be observed. |
|
140 */ |
|
141 const TDriveNumber iDriveNumber; |
|
142 |
|
143 /** |
|
144 * Critical disk space level. |
|
145 */ |
|
146 const TInt64 iCriticalLevel; |
|
147 |
|
148 /** |
|
149 * Handle to the file system. |
|
150 */ |
|
151 RFs& iFs; |
|
152 |
|
153 /** |
|
154 * Number of observers of this drive. When observer count drops to |
|
155 * zero drive observation can be stopped. |
|
156 */ |
|
157 TInt iObserverCount; |
|
158 |
|
159 }; |
|
160 |
|
161 |
|
162 #endif // C_IRDISKSPACESESSION_H |
|