1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MEMSPYENGINESERVER_H |
|
19 #define MEMSPYENGINESERVER_H |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 |
|
24 // User includes |
|
25 #include <memspyengineclientinterface.h> |
|
26 #include <memspy/engine/memspydevicewideoperations.h> |
|
27 |
|
28 // Classes referenced |
|
29 class CMemSpyEngine; |
|
30 class CMemSpyDwOperationTracker; |
|
31 |
|
32 NONSHARABLE_CLASS( CShutdown ) : public CTimer |
|
33 { |
|
34 enum {KMyShutdownDelay=10 * 1000000}; // 10s |
|
35 public: |
|
36 inline CShutdown(); |
|
37 inline void ConstructL(); |
|
38 inline void Start(); |
|
39 private: |
|
40 void RunL(); |
|
41 }; |
|
42 |
|
43 NONSHARABLE_CLASS( CMemSpyEngineServer ) : public CServer2 |
|
44 { |
|
45 public: |
|
46 static CMemSpyEngineServer* NewL( CMemSpyEngine& aEngine ); |
|
47 ~CMemSpyEngineServer(); |
|
48 |
|
49 CMemSpyDwOperationTracker* CurrentOperationTracker() const { return iCurrentOperationTracker; } |
|
50 void SetCurrentOperationTracker(CMemSpyDwOperationTracker* aTracker) { iCurrentOperationTracker = aTracker; } |
|
51 |
|
52 CMemSpyEngine& Engine() { return iEngine; } |
|
53 |
|
54 void AddSession(TBool aCliRequest); |
|
55 void DropSession(TBool aCliRequest); |
|
56 |
|
57 private: |
|
58 CMemSpyEngineServer( CMemSpyEngine& aEngine ); |
|
59 void ConstructL(); |
|
60 |
|
61 protected: // From CServer2 |
|
62 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
63 |
|
64 private: |
|
65 CMemSpyEngine& iEngine; |
|
66 CMemSpyDwOperationTracker* iCurrentOperationTracker; |
|
67 |
|
68 TInt iSessionCount; |
|
69 TBool iCliConnected; |
|
70 |
|
71 CShutdown iShutdown; |
|
72 }; |
|
73 |
|
74 |
|
75 |
|
76 NONSHARABLE_CLASS( CMemSpyEngineSession ) : public CSession2 |
|
77 { |
|
78 public: |
|
79 static CMemSpyEngineSession* NewL( CMemSpyEngine& aEngine, const RMessage2& aMessage ); |
|
80 ~CMemSpyEngineSession(); |
|
81 |
|
82 void CreateL(); |
|
83 |
|
84 private: |
|
85 CMemSpyEngineSession( CMemSpyEngine& aEngine ); |
|
86 void ConstructL( const RMessage2& aMessage ); |
|
87 |
|
88 private: // From CSession2 |
|
89 void ServiceL( const RMessage2& aMessage ); |
|
90 |
|
91 private: // Internal methods |
|
92 void DoServiceL( const RMessage2& aMessage ); |
|
93 void DoAsyncServiceL( const RMessage2& aMessage ); |
|
94 void DoUiServiceL( const RMessage2& aMessage ); |
|
95 void DoCmdServiceL( const RMessage2& aMessage ); |
|
96 static TInt ValidateFunction( TInt aFunction, TBool aIncludesThreadId, TBool aIncludesThreadName ); |
|
97 void HandleThreadSpecificOpL( TInt aFunction, const TThreadId& aThreadId ); |
|
98 void HandleThreadSpecificOpL( TInt aFunction, const TDesC& aThreadName ); |
|
99 void HandleThreadAgnosticOpL( TInt aFunction, const RMessage2& aMessage ); |
|
100 void StartDeviceWideOperationL(CMemSpyDeviceWideOperations::TOperation aOperation, const RMessage2& aMessage); |
|
101 |
|
102 inline CMemSpyEngineServer& Server() const { return *static_cast<CMemSpyEngineServer*>(const_cast<CServer2*>(CSession2::Server())); } |
|
103 |
|
104 private: |
|
105 CMemSpyEngine& iEngine; |
|
106 HBufC* iClientThreadName; |
|
107 TUint32 iClientThreadId; |
|
108 TBool iIsCliRequest; |
|
109 }; |
|
110 |
|
111 /** |
|
112 * CMemSpyDwOperationTracker |
|
113 * Tracks device wide operation progress and calls iOperationMessage.Complete upon completion. |
|
114 */ |
|
115 NONSHARABLE_CLASS( CMemSpyDwOperationTracker ) : public MMemSpyDeviceWideOperationsObserver |
|
116 { |
|
117 public: |
|
118 static CMemSpyDwOperationTracker* NewL(CMemSpyDeviceWideOperations::TOperation aOperation, |
|
119 const RMessage2& aOperationMessage, |
|
120 CMemSpyEngineServer& aServer); |
|
121 ~CMemSpyDwOperationTracker(); |
|
122 |
|
123 void AddNotificationL(const RMessage2& aMessage); |
|
124 |
|
125 void Cancel(); |
|
126 |
|
127 public: // From MMemSpyDeviceWideOperationsObserver |
|
128 void HandleDeviceWideOperationEvent(TEvent aEvent, TInt aParam1, const TDesC& aParam2); |
|
129 |
|
130 private: |
|
131 CMemSpyDwOperationTracker(const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer); |
|
132 void ConstructL(CMemSpyDeviceWideOperations::TOperation aOperation); |
|
133 |
|
134 private: |
|
135 RMessage2 iOperationMessage; |
|
136 CMemSpyEngineServer& iServer; |
|
137 CArrayFixFlat<RMessage2>* iPendingNotifications; |
|
138 CMemSpyDeviceWideOperations* iOperation; |
|
139 TInt iProgress; |
|
140 }; |
|
141 |
|
142 |
|
143 #endif |
|