|
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: State Manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _AISTATEMANAGER_H |
|
20 #define _AISTATEMANAGER_H |
|
21 |
|
22 // System includes |
|
23 #include <e32base.h> |
|
24 #include <babitflags.h> |
|
25 |
|
26 // User includes |
|
27 #include <aifwdefs.h> |
|
28 #include "aistateobserver.h" |
|
29 |
|
30 // Forward declarations |
|
31 class CAiPluginFactory; |
|
32 class TAiFwPublisherInfo; |
|
33 class CHsContentPublisher; |
|
34 class THsPublisherInfo; |
|
35 |
|
36 /** |
|
37 * State Manager |
|
38 * |
|
39 * @ingroup group_aifw |
|
40 * @lib aifw.lib |
|
41 * @since S60 5.2 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CAiStateManager ) : public CBase, |
|
44 public MAiStateObserver |
|
45 { |
|
46 private: |
|
47 // Data types |
|
48 enum TState |
|
49 { |
|
50 ESuspended = 0, |
|
51 EAlive, |
|
52 }; |
|
53 |
|
54 enum TFlags |
|
55 { |
|
56 EIsForeground = 0, |
|
57 EIsLightsOn, |
|
58 EIsOnline, |
|
59 EShutdown |
|
60 }; |
|
61 |
|
62 public: |
|
63 // Constructors and destructor |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 */ |
|
68 static CAiStateManager* NewL( CAiPluginFactory& aFactory ); |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. Leaving on stack |
|
72 */ |
|
73 static CAiStateManager* NewLC( CAiPluginFactory& aFactory ); |
|
74 |
|
75 /** |
|
76 * Destructor |
|
77 */ |
|
78 ~CAiStateManager(); |
|
79 |
|
80 private: |
|
81 // private constructors |
|
82 |
|
83 /** |
|
84 * Leaving constructor |
|
85 */ |
|
86 void ConstructL(); |
|
87 |
|
88 /** |
|
89 * C++ default constructor |
|
90 */ |
|
91 CAiStateManager( CAiPluginFactory& aFactory ); |
|
92 |
|
93 private: |
|
94 // from MAiStateObserver |
|
95 |
|
96 /** |
|
97 * @see MAiStateObserver |
|
98 */ |
|
99 void NotifyStateChange( |
|
100 TAiFwState aReason ); |
|
101 |
|
102 /** |
|
103 * @see MAiStateObserver |
|
104 */ |
|
105 void NotifyLoadPlugin( const TAiFwPublisherInfo& aInfo ); |
|
106 |
|
107 /** |
|
108 * @see MAiStateObserver |
|
109 */ |
|
110 void NotifyDestroyPlugin( const TAiFwPublisherInfo& aInfo ); |
|
111 |
|
112 /** |
|
113 * @see MAiStateObserver |
|
114 */ |
|
115 void NotifyReloadPlugins(); |
|
116 |
|
117 |
|
118 /** |
|
119 * @see MAiStateObserver |
|
120 */ |
|
121 void NotifyReleasePlugins( const RArray<TUid>& aUidList ); |
|
122 |
|
123 public: |
|
124 // new functions |
|
125 |
|
126 /** |
|
127 * Runs plugin startup sequence |
|
128 * |
|
129 * @since S60 5.2 |
|
130 * @param aPlugin Plugin to start |
|
131 * @param aReason Start reason |
|
132 */ |
|
133 void StartPlugin( CHsContentPublisher& aPlugin, TInt aReason ); |
|
134 |
|
135 /** |
|
136 * Runs plugin shutdown sequence |
|
137 * |
|
138 * @since S60 5.2 |
|
139 * @param aPlugin Plugin to stop |
|
140 * @param aReason Stop reason |
|
141 */ |
|
142 void StopPlugin( CHsContentPublisher& aPlugin, TInt aReason ); |
|
143 |
|
144 private: |
|
145 // new functions |
|
146 |
|
147 /** |
|
148 * Evaluates next state |
|
149 * |
|
150 * @since S60 5.2 |
|
151 * @return Next state |
|
152 */ |
|
153 TState EvaluateNextState() const; |
|
154 |
|
155 /** |
|
156 * Process state change for all plugins |
|
157 * |
|
158 * @since S60 5.2 |
|
159 * @param aNextState Next state where plugins are driven |
|
160 */ |
|
161 void ProcessStateChange( TState aNextState ); |
|
162 |
|
163 /** |
|
164 * Process general theme state change for all plugins |
|
165 * |
|
166 * @since S60 5.2 |
|
167 */ |
|
168 void ProcessGeneralThemeChange(); |
|
169 |
|
170 /** |
|
171 * Process backup/restore state change for all plugins |
|
172 * |
|
173 * @since S60 5.2 |
|
174 * @param aStarted ETrue when backup started |
|
175 */ |
|
176 void ProcessBackupRestore( TBool aStarted ); |
|
177 |
|
178 /** |
|
179 * Process online / offline state change for all plugins |
|
180 * |
|
181 * @since S60 5.2 |
|
182 */ |
|
183 void ProcessOnlineStateChange(); |
|
184 |
|
185 private: |
|
186 // data |
|
187 |
|
188 /** Plugin Factory, Not owned */ |
|
189 CAiPluginFactory& iFactory; |
|
190 /** Current state */ |
|
191 TState iCurrentState; |
|
192 /** Flags */ |
|
193 TBitFlags32 iFlags; |
|
194 /** Halted flag */ |
|
195 TBool iHalt; |
|
196 /** List of plugins which should be reloaded */ |
|
197 RArray<THsPublisherInfo> iReloadPlugins; |
|
198 |
|
199 private: |
|
200 // friend classes |
|
201 |
|
202 #ifdef _AIFW_UNIT_TEST |
|
203 friend class UT_AiStateManager; |
|
204 #endif |
|
205 }; |
|
206 |
|
207 #endif // _AISTATEMANAGER_H |
|
208 |
|
209 // End of file |
|
210 |