|
1 /* |
|
2 * Copyright (c) 2006 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: Server session base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_ALFAPPSRVSESSIONBASE_H |
|
21 #define C_ALFAPPSRVSESSIONBASE_H |
|
22 |
|
23 #include <AknServerApp.h> |
|
24 #include <alf/alfappserver.h> |
|
25 #include <alf/alfred.hrh> |
|
26 #include <alf/alfextensionfactory.h> |
|
27 #include <alf/alfconstants.h> |
|
28 |
|
29 #include <uiacceltk/HuiEnv.h> |
|
30 |
|
31 class CAlfAppServer; |
|
32 class CAlfAppUi; |
|
33 class CCoeControl; |
|
34 class CAlfSrvSubSessionBase; |
|
35 class CHuiControlGroup; |
|
36 |
|
37 // For window server visibility notifications |
|
38 class MWindowVisibilityObserver |
|
39 { |
|
40 public: |
|
41 virtual void WindowFullyVisible() = 0; |
|
42 virtual void WindowPartiallyVisible() = 0; |
|
43 virtual void WindowNotVisible() = 0; |
|
44 virtual CCoeControl* CoeControl() = 0; |
|
45 }; |
|
46 |
|
47 NONSHARABLE_CLASS(CAlfClientMessage):public CBase |
|
48 { |
|
49 public: |
|
50 static CAlfClientMessage* NewLC(TInt aSubsessionIdentifier, const RMessage2& aMessage) |
|
51 { |
|
52 CAlfClientMessage* me = new (ELeave) CAlfClientMessage(); |
|
53 me->iSubSession = aSubsessionIdentifier; |
|
54 me->iMessage = aMessage; |
|
55 CleanupStack::PushL(me); |
|
56 return me; |
|
57 } |
|
58 |
|
59 ~CAlfClientMessage() |
|
60 { |
|
61 if (!iMessage.IsNull()) |
|
62 { |
|
63 iMessage.Complete(KErrCancel); |
|
64 } |
|
65 delete iInBuf; |
|
66 delete iOutBuf; |
|
67 delete iReplyPtr; |
|
68 } |
|
69 |
|
70 void CompleteMessageD(TInt aError) |
|
71 { |
|
72 if (aError == KErrNone) |
|
73 { |
|
74 aError = iMessage.Write(2,*iOutBuf); |
|
75 } |
|
76 iMessage.Complete(aError); |
|
77 delete this; |
|
78 } |
|
79 |
|
80 void SetClientParams(const TInt2& aParams) |
|
81 { |
|
82 iDecodedOp = aParams.iInt1; |
|
83 iClientId = aParams.iInt2; |
|
84 } |
|
85 |
|
86 static TBool Compare(const TInt* aValue, const CAlfClientMessage& aStruct) |
|
87 { |
|
88 return (*aValue == aStruct.iClientId); |
|
89 } |
|
90 |
|
91 TPtr8& ReplyBufAsTDes8() |
|
92 { |
|
93 __ASSERT_ALWAYS(iOutBuf, User::Invariant()); |
|
94 |
|
95 if (!iReplyPtr) |
|
96 { |
|
97 iReplyPtr = new (ELeave) TPtr8(iOutBuf->Des()); |
|
98 } |
|
99 return *iReplyPtr; |
|
100 } |
|
101 |
|
102 public: |
|
103 HBufC8* iInBuf; |
|
104 HBufC8* iOutBuf; |
|
105 TInt iSubSession; |
|
106 TBool iIsAsync; |
|
107 TInt iClientId; |
|
108 TInt iDecodedOp; |
|
109 RMessagePtr2 iMessage; |
|
110 TPtr8* iReplyPtr; |
|
111 }; |
|
112 |
|
113 /** |
|
114 * Session/service class in the server side. |
|
115 * |
|
116 * @since S60 v3.2 |
|
117 */ |
|
118 class CAlfAppSrvSessionBase : public CAknAppServiceBase, public MAlfInterfaceProvider |
|
119 { |
|
120 public: |
|
121 /** |
|
122 * Default constructor, stores pointer to server instance |
|
123 * |
|
124 * @param aServer Server which the client has connected. |
|
125 */ |
|
126 IMPORT_C CAlfAppSrvSessionBase(const CAlfAppServer* aServer); |
|
127 |
|
128 /** |
|
129 * Default constructor, fetches and stores pointer to server instance using ccoestatic |
|
130 */ |
|
131 IMPORT_C CAlfAppSrvSessionBase(); |
|
132 |
|
133 /** |
|
134 * Destructor, singals server to free resources specific for this client |
|
135 */ |
|
136 IMPORT_C ~CAlfAppSrvSessionBase(); |
|
137 |
|
138 // new methods |
|
139 |
|
140 /** |
|
141 * From CAlfAppSrvSessionBase |
|
142 * Called when a message is received from the client. |
|
143 * |
|
144 * @param aMessage Message parameters. |
|
145 */ |
|
146 virtual void DoHandleCommandL(const RMessage2& aMessage) = 0; |
|
147 |
|
148 /** |
|
149 * Gets the drawing area of the session |
|
150 * |
|
151 * @return TRect of the drawing area |
|
152 */ |
|
153 IMPORT_C virtual TRect ClientDrawingArea() const; |
|
154 |
|
155 /** |
|
156 * From CAlfAppSrvSessionBase |
|
157 * Client's window group received focus. |
|
158 * |
|
159 * @param aDoTransitionEffect Do fade in transision (RnD) |
|
160 */ |
|
161 IMPORT_C virtual void FocusGainedL( TBool aDoTransitionEffect ); |
|
162 |
|
163 /** |
|
164 * From CAlfAppSrvSessionBase |
|
165 * Client's window group lost focus. |
|
166 * |
|
167 * @param aDoTransitionEffect Do fade out transision (RnD) |
|
168 * @return Did transition? (RnD) |
|
169 */ |
|
170 IMPORT_C virtual TBool FocusLostL( TBool aDoTransitionEffect ); |
|
171 |
|
172 // have to create new extension mechanism as CApaAppServiceBase breaks the chain |
|
173 // by defining CBase's ExtensionInterface() as private |
|
174 IMPORT_C virtual void ExtensionInterfaceL(TUid aInterfaceId, TAny*& aImplementation); |
|
175 |
|
176 /** |
|
177 * Ecom implementation for specific factory has been removed |
|
178 * Close all subsessions referring to that |
|
179 */ |
|
180 IMPORT_C virtual void FactoryDestroyed(TInt aFactoryUid); |
|
181 |
|
182 /** |
|
183 * Returns the preferred window group position of the session. |
|
184 * |
|
185 * @return Preferred position. |
|
186 */ |
|
187 IMPORT_C virtual CAlfAppServer::TAlfWGPostion PreferredWindowGroupPosition() const; |
|
188 |
|
189 /** |
|
190 * Returns the preferred refresh mode of the session. |
|
191 * |
|
192 * @return Preferred refresh mode. |
|
193 */ |
|
194 IMPORT_C virtual THuiRefreshMode PreferredRefreshMode() const; |
|
195 |
|
196 // for convenience, to avoid CCoeStatic |
|
197 IMPORT_C CAlfAppServer* AlfServer(); |
|
198 IMPORT_C CAlfAppUi* AlfAppUi(); |
|
199 |
|
200 |
|
201 public: // from MAlfInterfaceProvider |
|
202 IMPORT_C TAny* GetInterfaceL(const THuiInterfaceSupport& aType, TInt aHandle); |
|
203 IMPORT_C TInt GetHandleFromInterface(const THuiInterfaceSupport& aType, TAny* aInterface); |
|
204 IMPORT_C CAlfLayoutManager* LayoutManager() const; |
|
205 IMPORT_C CHuiEnv* SharedHuiEnv() const; |
|
206 IMPORT_C TInt HandleCurrentCommanndAsynch(); |
|
207 IMPORT_C void CompleteCmd(TInt aCommadIdentifier, TInt aResult); |
|
208 IMPORT_C void AlfInterfaceProviderExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
209 |
|
210 |
|
211 public: // utilities |
|
212 |
|
213 /** |
|
214 * From CAlfAppSrvSessionBase |
|
215 * Returns the client's window group id. |
|
216 * |
|
217 * @return Wg ID. KErrNotFound if not set. |
|
218 */ |
|
219 TInt ClientWindowGroup() const; |
|
220 |
|
221 /** |
|
222 * Sets the window group ID. |
|
223 * Server uses this information to calculate its screen position in Symbian window tree |
|
224 * |
|
225 * @param aId Wg ID |
|
226 */ |
|
227 IMPORT_C void SetClientWindowGroupId(TInt aId); |
|
228 |
|
229 /** |
|
230 * Finds all the subsession which implement the interface. |
|
231 * |
|
232 * @param aArray Array which the function fills of subsession on return. |
|
233 * @param aType Type of the interface that we are looking for. |
|
234 */ |
|
235 void GetSubsessionsByTypeL( RPointerArray<CAlfSrvSubSessionBase>& aArray, const THuiInterfaceSupport& aType ); |
|
236 |
|
237 // Closes the subsession |
|
238 void CloseSubSession( const RMessage2& aMessage ); |
|
239 |
|
240 /** |
|
241 * Returns ETrue if this session owns specified subsession handle. |
|
242 * @param aHandle subsession handle to be checked. |
|
243 * @return ETrue if subsession exists, EFalse otherwise. |
|
244 */ |
|
245 TBool HasSession( TInt aSubSessionHandle ) const; |
|
246 |
|
247 // Returns subsession basd on the handle |
|
248 CAlfSrvSubSessionBase& SubSession( TInt aSubSessionHandle ); |
|
249 |
|
250 CAlfClientMessage* CreateNewMessageHolderL(const RMessage2& aMessage); |
|
251 |
|
252 void HandleEventL(TAny* aCtrlPtr, TAny* aVisualPtr, const THuiEvent& aEvent); |
|
253 |
|
254 void StartPointerHandling(); |
|
255 void FlushPointerHandling(); |
|
256 void TriggerPointerEvent(const RMessage2* aMessage); |
|
257 void CancelPointerEvents(); |
|
258 |
|
259 // Methods for sending general system events to clients |
|
260 void GetSystemEvents(const RMessage2* aMessage); |
|
261 void TriggerSystemEvent(TInt aEvent); |
|
262 void CancelSystemEvents(); |
|
263 |
|
264 // embedded apps support |
|
265 void SetParentWindowGroupId(TInt aParentId); |
|
266 TInt ParentWindowGroupId(); |
|
267 void ResetRootlayerTransformationsL(); |
|
268 |
|
269 /** |
|
270 * Sets session's max fps limiter to half, used if client's window does not have keyboard focus |
|
271 * @param aOnBackground use lowered max fps (ETrue/EFalse) |
|
272 */ |
|
273 virtual void SetBackgroundMaxFps( TBool /*aOnBackground*/ ) {}; //empty implementation for base class. |
|
274 |
|
275 |
|
276 //RnD |
|
277 void ActivateContainerLayoutL(TBool aActivate); |
|
278 |
|
279 protected: // new methods |
|
280 |
|
281 // must be called from derived class to complete the construction |
|
282 IMPORT_C void BaseConstructL(); |
|
283 |
|
284 protected: // internal utilities |
|
285 |
|
286 // Checks if the function is meant for subsession creation |
|
287 TBool IsSubSessionCreationFunction(const RMessage2& aMessage) const; |
|
288 |
|
289 // creates subsession |
|
290 CAlfSrvSubSessionBase* CreateSubSessionLC(const RMessage2& aMessage); |
|
291 |
|
292 protected: // from baseclasses |
|
293 |
|
294 IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError); |
|
295 IMPORT_C TInt CountResources(); |
|
296 IMPORT_C void Disconnect(const RMessage2& aMessage); |
|
297 /** ! CSession2 */ |
|
298 IMPORT_C TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
299 |
|
300 |
|
301 |
|
302 private: |
|
303 |
|
304 /** |
|
305 * From CAknAppServiceBase. |
|
306 * Called by the framework when a client requests a sevice. |
|
307 * |
|
308 * @param aMessage Client's message. |
|
309 */ |
|
310 IMPORT_C void ServiceL(const RMessage2& aMessage); |
|
311 |
|
312 TBool DoSubSessionCmdL(const RMessage2& aMessage); |
|
313 |
|
314 void CloseSubSession(TInt aHandle); |
|
315 |
|
316 private: // data |
|
317 |
|
318 CAlfAppServer* iHost; // stores pointer to server instance |
|
319 // (we could utilise CSession2::Server() for this functionality, but just for sake of simplicity) |
|
320 |
|
321 class TPrivateData; |
|
322 TPrivateData* iData; |
|
323 }; |
|
324 |
|
325 #endif // C_ALFAPPSRVSESSIONBASE_H |