1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
174 TInt iReserved1; |
178 TInt iReserved1; |
175 TInt iReserved2; |
179 TInt iReserved2; |
176 TInt iReserved3; |
180 TInt iReserved3; |
177 }; |
181 }; |
178 |
182 |
179 /** |
183 #endif |
180 @internalTechnology |
|
181 |
184 |
182 Used to Kill the subthread either immediately or after a timeout. |
|
183 Used by the subthread on startup to prevent orphaning if no sessions are created to it. |
|
184 */ |
|
185 class CMMFSubThreadShutdown : public CTimer |
|
186 { |
|
187 enum {EMMFSubThreadShutdownDelay=1000000}; // 1s |
|
188 public: |
|
189 static CMMFSubThreadShutdown* NewL(); |
|
190 CMMFSubThreadShutdown(); |
|
191 void ConstructL(); |
|
192 void Start(); |
|
193 void ShutdownNow(); |
|
194 private: |
|
195 void RunL(); |
|
196 }; |
|
197 |
|
198 /** |
|
199 @internalTechnology |
|
200 |
|
201 Subthread server base class. |
|
202 Provides session counting and will kill the subthread immediately when the session count reaches zero. |
|
203 Starts the shutdown timer on construction to prevent orphaning if no sessions are created. |
|
204 */ |
|
205 class CMMFSubThreadServer : public CMmfIpcServer |
|
206 { |
|
207 public: |
|
208 virtual ~CMMFSubThreadServer(); |
|
209 virtual void SessionCreated(); |
|
210 virtual TInt RunError(TInt aError); |
|
211 virtual void ShutdownNow(); |
|
212 protected: |
|
213 virtual CMmfIpcSession* NewSessionL(const TVersion& aVersion) const = 0; |
|
214 CMMFSubThreadServer(TInt aPriority); |
|
215 void ConstructL(); |
|
216 private: |
|
217 CMMFSubThreadShutdown* iShutdownTimer; |
|
218 }; |
|
219 |
|
220 /** |
|
221 @internalTechnology |
|
222 |
|
223 Used to hold on to an RMessage so we can complete it asynchronously to send an event to the main thread. |
|
224 */ |
|
225 class CMMFSubThreadEventReceiver : public CBase |
|
226 { |
|
227 public: |
|
228 static CMMFSubThreadEventReceiver* NewL(const RMmfIpcMessage& aMessage); |
|
229 ~CMMFSubThreadEventReceiver(); |
|
230 void SendEvent(const TMMFEvent& aEvent); |
|
231 private: |
|
232 CMMFSubThreadEventReceiver(const RMmfIpcMessage& aMessage); |
|
233 private: |
|
234 RMmfIpcMessage iMessage; |
|
235 TBool iNeedToCompleteMessage; |
|
236 }; |
|
237 |
|
238 /** |
|
239 @internalTechnology |
|
240 |
|
241 Subthread session base class. |
|
242 Derived classes must implement the ServiceL() method. |
|
243 */ |
|
244 class CMMFSubThreadSession : public CMmfIpcSession, public MAsyncEventHandler |
|
245 { |
|
246 public: |
|
247 virtual ~CMMFSubThreadSession(); |
|
248 void CreateL(const CMmfIpcServer& aServer); |
|
249 virtual void ServiceL(const RMmfIpcMessage& aMessage) = 0; |
|
250 //from MAsyncEventHandler |
|
251 TInt SendEventToClient(const TMMFEvent& aEvent); |
|
252 protected: |
|
253 CMMFSubThreadSession() {}; |
|
254 TBool ReceiveEventsL(const RMmfIpcMessage& aMessage); |
|
255 TBool CancelReceiveEvents(); |
|
256 TBool ShutDown(); |
|
257 protected: |
|
258 CMMFSubThreadServer* iServer; |
|
259 private: |
|
260 CMMFSubThreadEventReceiver* iEventReceiver; |
|
261 RArray<TMMFEvent> iEvents; |
|
262 }; |
|
263 |
|
264 |
|
265 |
|
266 #endif |
|