|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CMCSFREESPACEOBSERVER_H |
|
19 #define CMCSFREESPACEOBSERVER_H |
|
20 |
|
21 #include <e32base.h> // For CActive, link against: euser.lib |
|
22 #include <f32file.h> |
|
23 |
|
24 /** |
|
25 * Interface for monitoring free space. |
|
26 * |
|
27 * @since S60 v5.0 |
|
28 */ |
|
29 class MMcsFreeSpaceObserver |
|
30 { |
|
31 public: |
|
32 /** |
|
33 * Handles free space threshold events. |
|
34 * It must be implemented in derived clesses. |
|
35 */ |
|
36 virtual void HandleFreeSpaceEventL() = 0; |
|
37 static const TInt64 EFreeDiskSpace = 40*1024; |
|
38 }; |
|
39 |
|
40 |
|
41 /** |
|
42 * Free space Observer Interface. |
|
43 * @lib mcsmenu.lib |
|
44 * @since S60 v5.0 |
|
45 */ |
|
46 NONSHARABLE_CLASS(CMcsFreeSpaceObserver) : public CActive |
|
47 { |
|
48 public: |
|
49 // Cancel and destroy |
|
50 ~CMcsFreeSpaceObserver(); |
|
51 |
|
52 // Two-phased constructor. |
|
53 static CMcsFreeSpaceObserver* NewL(MMcsFreeSpaceObserver& aCallback, |
|
54 TInt64 aFreeDiskSpace = MMcsFreeSpaceObserver::EFreeDiskSpace, |
|
55 TInt aDrive=EDriveC); |
|
56 |
|
57 // Two-phased constructor. |
|
58 static CMcsFreeSpaceObserver* NewLC(MMcsFreeSpaceObserver& aCallback, |
|
59 TInt64 aFreeDiskSpace = MMcsFreeSpaceObserver::EFreeDiskSpace, |
|
60 TInt aDrive = EDriveC); |
|
61 |
|
62 private: |
|
63 // C++ constructor |
|
64 CMcsFreeSpaceObserver(MMcsFreeSpaceObserver& aCallback, |
|
65 TInt64 aFreeDiskSpace, |
|
66 TInt aDrive); |
|
67 |
|
68 // Second-phase constructor |
|
69 void ConstructL(); |
|
70 |
|
71 private: |
|
72 // From CActive |
|
73 // Handle completion |
|
74 void RunL(); |
|
75 |
|
76 void DoCancel(); |
|
77 |
|
78 TInt RunError(TInt aError); |
|
79 |
|
80 private: |
|
81 /* |
|
82 * Observed drive. |
|
83 */ |
|
84 TInt iDrive; |
|
85 /* |
|
86 * Free space threshold (bytes). |
|
87 */ |
|
88 TInt64 iFreeDiskSpace; |
|
89 /* |
|
90 * A handle to a file server session. |
|
91 */ |
|
92 RFs iFs; |
|
93 /* |
|
94 * An object of a class implementing callback |
|
95 * function (HandleFreeSpaceEventL) |
|
96 * of MMcsFreeSpaceObserver interface. |
|
97 */ |
|
98 MMcsFreeSpaceObserver& iCallback; |
|
99 |
|
100 }; |
|
101 |
|
102 #endif // CMCSFREESPACEOBSERVER_H |