|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Defines the reference Comms Configurator |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #if !defined(__C32START_H__) |
|
24 #define __C32START_H__ |
|
25 #include <c32root.h> |
|
26 #include "c32cmi.h" |
|
27 #include "c32startshared.h" |
|
28 #include <e32property.h> |
|
29 #include <domainmember.h> |
|
30 #include <comms-infras/commsdebugutility.h> |
|
31 /** Subsystem name, used for logging. |
|
32 */ |
|
33 __FLOG_STMT(_LIT8(KSubsys,"C32Start");) |
|
34 |
|
35 /** Component name, used for logging. |
|
36 */ |
|
37 __FLOG_STMT(_LIT8(KComponent,"Events");) |
|
38 |
|
39 /** Name of the application. |
|
40 */ |
|
41 _LIT(KC32StartName, "C32Start"); |
|
42 |
|
43 /** Name of the Rootserver executable. |
|
44 */ |
|
45 _LIT(KRootServerExe, "c32exe.exe"); |
|
46 |
|
47 /** Default priority of the Rootserver executeable and |
|
48 thus the priority Comms Process. |
|
49 */ |
|
50 const TProcessPriority KRootServerDefaultPriority=EPriorityHigh; |
|
51 |
|
52 class CCommsProcessStarter; |
|
53 class CBindingRef; |
|
54 |
|
55 /** Type of module. |
|
56 */ |
|
57 enum TModuleType { |
|
58 /** A module which can only be at the top end of a hierarchical binding. |
|
59 */ |
|
60 EServerModule, |
|
61 /** Standard Comms Provider Module. |
|
62 */ |
|
63 EProviderModule |
|
64 }; |
|
65 |
|
66 /** State of module. |
|
67 */ |
|
68 enum TModuleState { |
|
69 /** The module is not currently loaded. |
|
70 */ |
|
71 ENotLoaded, |
|
72 /** The module is currently being loaded by the Rootserver. |
|
73 */ |
|
74 ELoading, |
|
75 /** The module has been loaded and is running. |
|
76 */ |
|
77 ELoaded, |
|
78 /** The module could not be loaded by the Rootserver. |
|
79 */ |
|
80 ELoadFailed |
|
81 /** The module is being currently Unloaded by the root server |
|
82 */ |
|
83 ,EUnLoading |
|
84 }; |
|
85 |
|
86 /** State of a binding |
|
87 */ |
|
88 enum TBindingState { |
|
89 /** The binding is not currently active. |
|
90 */ |
|
91 ENotBound, |
|
92 /** The binding is being set up by the Rootserver. |
|
93 */ |
|
94 EBinding, |
|
95 /** The binding has been created and is active. |
|
96 */ |
|
97 EBound, |
|
98 /** The Rootserver was unable to set up the binding. |
|
99 */ |
|
100 EBindFailed |
|
101 /** Either 'end' module of the binding has failed to load, result being binding won't start |
|
102 */ |
|
103 ,EBindInComplete |
|
104 }; |
|
105 |
|
106 class CModuleRef : public CActive |
|
107 /** An instance of this object represents one module to be-, being- or which is |
|
108 loaded by the RootServer. The public inheritance of CActive |
|
109 */ |
|
110 { |
|
111 public: |
|
112 static CModuleRef* NewLC(RRootServ& aRootServer, CCommsProcessStarter& aCommsProcess, C32CmiData& aCModuleCMIData); |
|
113 ~CModuleRef(); |
|
114 const inline TCFGroupNameF& GroupName() const; |
|
115 TModuleState State() const { return iState; } |
|
116 const TCFModuleNameF& Name() const { return static_cast<const TCFModuleNameF&>(iParams.iParams.iName); } |
|
117 TUint32 ScaledStartupState() const { return iScaledStartupState; } |
|
118 TBool SystemCritical() const { return iSystemCritical; } |
|
119 TBool SystemCriticalAfterInit() const {return iSystemCriticalAfterInit;} |
|
120 |
|
121 void Load(); |
|
122 TBool Resurrect(); |
|
123 TBool operator==(const TCFModuleNameF& aModuleName) const; |
|
124 static TInt CompareScaledStartupState(const CModuleRef& aModule1, const CModuleRef& aModule2); |
|
125 |
|
126 inline HBufC8* GetIniData() const; |
|
127 inline TBool IsOnDemand() const; |
|
128 inline void SetRMessage(const RMessage2& aMessage); |
|
129 const RMessage2& Message() const { return iRMessage; } |
|
130 void MaybeCompleteMessage(TInt aReturnValue); |
|
131 void UnLoadCpm(const TCFModuleNameF& aModuleName,TRSUnLoadType aType); |
|
132 void CancelUnLoadCpm(const TCFModuleNameF& aModuleName); |
|
133 void CancelLoadCpm(const TCFModuleNameF& aModuleName); |
|
134 void UnBindCpm(); |
|
135 inline void IncrementBindings() { ++iNumBindings; } |
|
136 inline void IncrementCompletedBindings() { ++iCompletedBindings; } |
|
137 void UpdateCompletedBinding(TInt aReturnvalue); |
|
138 inline void SetHasBindings() { iHasBinding = ETrue; } |
|
139 |
|
140 protected: |
|
141 void DoCancel(); |
|
142 void RunL(); |
|
143 |
|
144 private: |
|
145 CModuleRef(RRootServ& aRootServer, CCommsProcessStarter& aCommsProcess); |
|
146 void ConstructL(C32CmiData& aCModuleCMIData); |
|
147 |
|
148 private: |
|
149 RPointerArray<CBindingRef> iBindings; |
|
150 TUint32 iScaledStartupState; |
|
151 TUint iNumBindings; |
|
152 RRootServ& iRootServer; |
|
153 CCommsProcessStarter& iCommsProcess; |
|
154 TModuleState iState; |
|
155 TModuleType iType; |
|
156 HBufC8* iIniData; |
|
157 TRSStartModuleParams iParams; |
|
158 TBool iSystemCritical; |
|
159 TBool iSystemCriticalAfterInit; |
|
160 TConfiguratorModuleParams iConfigParams; |
|
161 RMessage2 iRMessage; |
|
162 TUint iCompletedBindings; // when iNumBindings == iCompletedBindings, Message is completed |
|
163 TBool iHasBinding; |
|
164 }; |
|
165 |
|
166 class CBindingRef : public CActive |
|
167 /** An instance of this object represents one binding to be-, being- or which is |
|
168 bound by the RootServer. |
|
169 */ |
|
170 { |
|
171 public: |
|
172 CBindingRef(RRootServ& aRootServer, CCommsProcessStarter& aStartConfigProcess, |
|
173 const TRSBindingInfo& aBinding); |
|
174 ~CBindingRef(); |
|
175 inline void SetState(TBindingState aState); |
|
176 void UpdateCompletedBinding(TInt aReturnValue); |
|
177 const TCFSubModuleAddress& FromModule() const; |
|
178 const TCFSubModuleAddress& ToModule() const; |
|
179 TInt BindIfReady(); |
|
180 protected: |
|
181 void DoCancel(); |
|
182 void RunL(); |
|
183 |
|
184 private: |
|
185 CBindingRef(); |
|
186 void ConstructL(RRootServ& aRootServer, CCommsProcessStarter& aStartConfigProcess, |
|
187 TRSBindingInfo& aBinding); |
|
188 private: |
|
189 RRootServ& iRootServer; |
|
190 CCommsProcessStarter& iStartProcess; |
|
191 TBindingState iState; |
|
192 TRSBindingInfo iBindInfo; |
|
193 }; |
|
194 |
|
195 class CDeathWatcher : public CActive |
|
196 /** Observes the death publication and notifies the CommsProcessStarter |
|
197 */ |
|
198 { |
|
199 public: |
|
200 static CDeathWatcher* NewL(CCommsProcessStarter& aStartConfigProcess); |
|
201 ~CDeathWatcher(); |
|
202 protected: |
|
203 void DoCancel(); |
|
204 void RunL(); |
|
205 private: |
|
206 CDeathWatcher(CCommsProcessStarter& aStartConfigProcess); |
|
207 void Construct(); |
|
208 private: |
|
209 CCommsProcessStarter& iStartProcess; |
|
210 RProperty iDeathProperty; |
|
211 }; |
|
212 |
|
213 class CStartupStateObserver : public CDmDomain |
|
214 /** Observes the Generic Start-up Architecture state transitions, if the GSA is available. The |
|
215 need to cope with its absence prevents the more obvious approach of simply deriving |
|
216 CCommsProcessStarter from CDmDomain. |
|
217 */ |
|
218 { |
|
219 public: |
|
220 static CStartupStateObserver* NewL(CCommsProcessStarter& aStarter); |
|
221 ~CStartupStateObserver(); |
|
222 protected: |
|
223 void RunL(); |
|
224 private: |
|
225 CStartupStateObserver(CCommsProcessStarter& aStarter); |
|
226 private: |
|
227 CCommsProcessStarter& iStarter; |
|
228 }; |
|
229 |
|
230 class CRsConfiguratorServer; |
|
231 class CCommsProcessStarter : public CBase |
|
232 /** The main class orchestrating loading and binding of the Comms Provider |
|
233 Modules as specified by the .CMI files. |
|
234 */ |
|
235 { |
|
236 public: |
|
237 enum TModuleState { ELoadingModule, EListeningforDeath }; |
|
238 |
|
239 static CCommsProcessStarter* NewLC(RRootServ& aRootServer, RProperty& aProperty); |
|
240 ~CCommsProcessStarter(); |
|
241 void ReadConfigAndStartAllL(const TDesC& aCMISuppressions); |
|
242 CModuleRef* GetModule(const TCFModuleNameF& aModule ) const; |
|
243 void NotifyLoadCompletion(CModuleRef& aModule); |
|
244 void NotifyBindCompletion(CBindingRef& aBinding); |
|
245 void NotifySuddenDeath(TInt aDeathCount, TInt aDeathStatus); |
|
246 void NotifyStartupStateChange(); |
|
247 TBool ConfigurationComplete() const; |
|
248 TBool InTestMode() const |
|
249 { |
|
250 return iTestMode; |
|
251 } |
|
252 void PrintSummary(); |
|
253 void LoadOnDemandModule(CModuleRef& aModule); |
|
254 RPointerArray<CModuleRef>& GetModulesList() |
|
255 { |
|
256 return iModules; |
|
257 } |
|
258 RPointerArray<CBindingRef>& GetBindingList() |
|
259 { |
|
260 return iBindings; |
|
261 } |
|
262 protected: |
|
263 TInt UnloadedModuleIdx() const |
|
264 { |
|
265 return iUnloadedModuleIdx; |
|
266 } |
|
267 private: |
|
268 CCommsProcessStarter(RRootServ& aRootServer, RProperty& aProperty); |
|
269 TBool SplitInt(TPtrC8 &aDes, TInt& aValue) const; |
|
270 TBool SplitUint(TPtrC8 &aDes, TUint& aValue) const; |
|
271 void ContinueLoading(); |
|
272 void Shutdown(); |
|
273 |
|
274 private: |
|
275 TInt iUnloadedModuleIdx; |
|
276 TInt iModulesLoading; |
|
277 TInt iModulesLoaded; |
|
278 RRootServ& iRootServer; |
|
279 RPointerArray<CModuleRef> iModules; |
|
280 RPointerArray<CBindingRef> iBindings; |
|
281 CDeathWatcher* iDeathWatcher; |
|
282 TInt iDeathCount; |
|
283 RProperty& iConfigurationProperty; |
|
284 enum TPublicationLevel { EUnpublished = 0, EPublishedCore, EPublishedComplete }; |
|
285 TPublicationLevel iPublicationLevel; |
|
286 // Because of monitoring startup state changes we can come through twice in the "final" state, |
|
287 // but only want one summary dump (avoid deluging the user with apparent ambiguity) |
|
288 __FLOG_STMT(TBool iSummaryAlreadyPrinted; ) |
|
289 TUint iBindCount; |
|
290 #ifndef SYMBIAN_ZERO_COPY_NETWORKING |
|
291 TInt iInitMBufPoolSize; |
|
292 TInt iMaxMBufPoolSize; |
|
293 #endif |
|
294 TBool iTestMode; |
|
295 CStartupStateObserver* iStartupStateObserver; |
|
296 TBool iNeedToAckLastState; |
|
297 TUint32 iScaledStartupState; |
|
298 TBool iFinishedloading; |
|
299 CRsConfiguratorServer* iConfiguratorServer; |
|
300 }; |
|
301 #include "c32start.inl" |
|
302 #endif |