Update contrib.
1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMFSUBTHREADBASE_IMPL_H__
17 #define __MMFSUBTHREADBASE_IMPL_H__
21 #include <mmf/common/mmfpaniccodes.h>
22 #include <mmf/common/mmfcontroller.h>
23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
24 #include <mmf/common/mmfipcserver.h>
31 Used to Kill the subthread either immediately or after a timeout.
32 Used by the subthread on startup to prevent orphaning if no sessions are created to it.
34 class CMMFSubThreadShutdown : public CTimer
36 enum {EMMFSubThreadShutdownDelay=1000000}; // 1s
38 static CMMFSubThreadShutdown* NewL();
39 CMMFSubThreadShutdown();
50 Subthread server base class.
51 Provides session counting and will kill the subthread immediately when the session count reaches zero.
52 Starts the shutdown timer on construction to prevent orphaning if no sessions are created.
54 class CMMFSubThreadServer : public CMmfIpcServer
57 virtual ~CMMFSubThreadServer();
58 virtual void SessionCreated();
59 virtual TInt RunError(TInt aError);
60 virtual void ShutdownNow();
62 virtual CMmfIpcSession* NewSessionL(const TVersion& aVersion) const = 0;
63 CMMFSubThreadServer(TInt aPriority);
66 CMMFSubThreadShutdown* iShutdownTimer;
72 Used to hold on to an RMessage so we can complete it asynchronously to send an event to the main thread.
74 class CMMFSubThreadEventReceiver : public CBase
77 static CMMFSubThreadEventReceiver* NewL(const RMmfIpcMessage& aMessage);
78 ~CMMFSubThreadEventReceiver();
79 void SendEvent(const TMMFEvent& aEvent);
81 CMMFSubThreadEventReceiver(const RMmfIpcMessage& aMessage);
83 RMmfIpcMessage iMessage;
84 TBool iNeedToCompleteMessage;
90 Subthread session base class.
91 Derived classes must implement the ServiceL() method.
93 class CMMFSubThreadSession : public CMmfIpcSession, public MAsyncEventHandler
96 virtual ~CMMFSubThreadSession();
97 void CreateL(const CMmfIpcServer& aServer);
98 virtual void ServiceL(const RMmfIpcMessage& aMessage) = 0;
99 //from MAsyncEventHandler
100 TInt SendEventToClient(const TMMFEvent& aEvent);
102 CMMFSubThreadSession() {};
103 TBool ReceiveEventsL(const RMmfIpcMessage& aMessage);
104 TBool CancelReceiveEvents();
107 CMMFSubThreadServer* iServer;
109 CMMFSubThreadEventReceiver* iEventReceiver;
110 RArray<TMMFEvent> iEvents;