|
1 /* |
|
2 * Copyright (c) 2005 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: Class for managing different types of memory on a |
|
15 * very abstract level. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef DEVENCUI_MEMORYENTITY_H |
|
20 #define DEVENCUI_MEMORYENTITY_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <eikenv.h> |
|
24 |
|
25 #include "DevEnc.hrh" |
|
26 #include "DevEncUiMemInfoObserver.h" |
|
27 #include "DevEncDiskStatusObserver.h" |
|
28 |
|
29 class CDevEncSession; |
|
30 class CDevEncUiInfoObserver; |
|
31 |
|
32 class CDevEncUiMemoryEntity : public CBase, |
|
33 public MDiskStatusObserver |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * Constructs the CDevEncUiMemoryEntity using the NewLC method, popping |
|
38 * the constructed object from the CleanupStack before returning it. |
|
39 * |
|
40 * @return The newly constructed CDevEncUiMemoryEntity |
|
41 */ |
|
42 static CDevEncUiMemoryEntity* NewL( CEikonEnv* aEikonEnv, |
|
43 TDevEncUiMemoryType aType ); |
|
44 |
|
45 /** |
|
46 * Constructs the CDevEncUiMemoryEntity using the constructor and ConstructL |
|
47 * method, leaving the constructed object on the CleanupStack before returning it. |
|
48 * |
|
49 * @return The newly constructed CDevEncUiMemoryEntity |
|
50 */ |
|
51 static CDevEncUiMemoryEntity* NewLC( CEikonEnv* aEikonEnv, |
|
52 TDevEncUiMemoryType aType ); |
|
53 |
|
54 /** |
|
55 * Adds an observer to this object's list of observers. |
|
56 * @param aInfoObserver The observer to add |
|
57 * @leave Symbian error code |
|
58 */ |
|
59 void AddObserverL( MDevEncUiMemInfoObserver* aInfoObserver ); |
|
60 |
|
61 /** |
|
62 * Removes an observer from this object's list of observers. |
|
63 * Any errors are ignored. |
|
64 * @param aInfoObserver The observer to remove |
|
65 */ |
|
66 void RemoveObserver( MDevEncUiMemInfoObserver* aInfoObserver ); |
|
67 |
|
68 /** |
|
69 * Called periodically. Not intended for use by other classes. |
|
70 * @param aPtr Pointer to an instance of this class. |
|
71 */ |
|
72 static TInt ProgressTick( TAny* aPtr ); |
|
73 |
|
74 /** |
|
75 * Called periodically. Not intended for use by other classes. |
|
76 * @param aPtr Pointer to an instance of this class. |
|
77 */ |
|
78 static TInt PollTick( TAny* aPtr ); |
|
79 |
|
80 /** |
|
81 * Destructor. |
|
82 */ |
|
83 virtual ~CDevEncUiMemoryEntity(); |
|
84 |
|
85 /** |
|
86 * Starts the encryption of this memory. |
|
87 */ |
|
88 void StartEncryptionL(); |
|
89 |
|
90 /** |
|
91 * Starts the decryption of this memory. |
|
92 */ |
|
93 void StartDecryptionL(); |
|
94 |
|
95 void Cancel(); |
|
96 |
|
97 /** |
|
98 * Gets the state of this memory entity. |
|
99 * @return the current state |
|
100 */ |
|
101 TUint State() const; |
|
102 |
|
103 /** |
|
104 * Sends the current memory state information to all observers. |
|
105 * @return none |
|
106 */ |
|
107 virtual void UpdateMemoryInfo(); |
|
108 |
|
109 /* |
|
110 * From MDiskStatusObserver |
|
111 */ |
|
112 void DiskStatusChangedL( TInt aStatus ); |
|
113 |
|
114 private: |
|
115 // functions |
|
116 |
|
117 /** |
|
118 * C++ Constructor |
|
119 **/ |
|
120 CDevEncUiMemoryEntity( CEikonEnv* aEikonEnv, TDevEncUiMemoryType aType ); |
|
121 |
|
122 /** |
|
123 * Second-phase constructor |
|
124 **/ |
|
125 virtual void ConstructL(); |
|
126 |
|
127 /** |
|
128 * Sets the internal state and calls UpdateMemoryInfo() |
|
129 * @param aState the new state |
|
130 **/ |
|
131 virtual void SetState( TUint aState ); |
|
132 |
|
133 /** |
|
134 * Starts a timer to periodically update the memory state in the UI. |
|
135 * @param aInterval the polling interval |
|
136 **/ |
|
137 void StartPolling( TTimeIntervalMicroSeconds32 aInterval ); |
|
138 |
|
139 /** |
|
140 * Helper function, called by StartPolling. |
|
141 * Starts a timer to periodically update the memory state in the UI. |
|
142 * @param aInterval the polling interval |
|
143 **/ |
|
144 void DoStartPollingL( TTimeIntervalMicroSeconds32 aInterval ); |
|
145 |
|
146 /** |
|
147 * Fetches the encryption state and progress. Called periodically. |
|
148 **/ |
|
149 virtual void CheckProgress(); |
|
150 |
|
151 /** |
|
152 * Performs periodical processing of timeouts. Calls CheckProgress(). |
|
153 **/ |
|
154 virtual void DoProgressTick(); |
|
155 |
|
156 /** |
|
157 * Performs periodical processing of timeouts. |
|
158 * Checks if the encryption status has changed. |
|
159 **/ |
|
160 virtual void DoPollTickL(); |
|
161 |
|
162 void RestoreAutolockSettings(); |
|
163 |
|
164 // Data |
|
165 /** Not owned */ |
|
166 CEikonEnv* iEikEnv; |
|
167 |
|
168 /** Owned */ |
|
169 CDiskStatusObserver* iDiskStatusObserver; |
|
170 |
|
171 /** Owned */ |
|
172 CPeriodic* iPeriodic; |
|
173 |
|
174 /** Owned */ |
|
175 RArray<MDevEncUiMemInfoObserver*> iObservers; |
|
176 |
|
177 /** Owned */ |
|
178 CDevEncSession* iSession; |
|
179 |
|
180 TUint iState; |
|
181 TUint iPrevState; |
|
182 const TDevEncUiMemoryType iType; |
|
183 TInt iPercentDone; |
|
184 TInt iPrevPercentDone; |
|
185 }; |
|
186 |
|
187 #endif // DEVENCUI_MEMORYENTITY_H |