|
1 /* |
|
2 * Copyright (c) 2007 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 client for alfredserver.exe |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alfclient.h" |
|
21 #include "alf/alfconstants.h" |
|
22 #include "alfuids.h" |
|
23 #include "alflogger.h" |
|
24 #include "alfclientserver.h" |
|
25 #include "alf/alftexture.h" |
|
26 #include "alf/alfcontrol.h" |
|
27 #include <e32math.h> |
|
28 |
|
29 #include "uiacceltk/HuiUtil.h" |
|
30 |
|
31 const TInt KAlfClientDefaultBatchBufferSize = |
|
32 KAlfClientServerDefaultCommandBatchBufferSize; |
|
33 |
|
34 // ======== HELPER CLASSES ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CBatchBufferAutoFlusher |
|
38 // |
|
39 // This class is responsible of flushing the client side command buffer |
|
40 // when it gets time - hopefully as fast as possible after synchronous |
|
41 // commands. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 NONSHARABLE_CLASS( RAlfClient::CBatchBufferAutoFlusher ) : public CActive |
|
45 { |
|
46 public: |
|
47 CBatchBufferAutoFlusher( RAlfClient& aClient ); |
|
48 ~CBatchBufferAutoFlusher(); |
|
49 |
|
50 void StartAutoFlush(); |
|
51 protected: |
|
52 void RunL(); |
|
53 void DoCancel(); |
|
54 private: |
|
55 RAlfClient& iClient; |
|
56 }; |
|
57 |
|
58 RAlfClient::CBatchBufferAutoFlusher::CBatchBufferAutoFlusher( RAlfClient& aClient ) |
|
59 : CActive( EPriorityHigh+5), // Priority must be bigger than any received events from the server |
|
60 iClient( aClient ) |
|
61 { |
|
62 CActiveScheduler::Add( this ); |
|
63 } |
|
64 |
|
65 RAlfClient::CBatchBufferAutoFlusher::~CBatchBufferAutoFlusher() |
|
66 { |
|
67 Cancel(); |
|
68 } |
|
69 |
|
70 void RAlfClient::CBatchBufferAutoFlusher::StartAutoFlush() |
|
71 { |
|
72 if ( !IsActive() ) |
|
73 { |
|
74 iStatus = KRequestPending; |
|
75 SetActive(); |
|
76 |
|
77 TRequestStatus* status = &iStatus; |
|
78 User::RequestComplete( status, KErrNone ); |
|
79 } |
|
80 } |
|
81 |
|
82 void RAlfClient::CBatchBufferAutoFlusher::RunL() |
|
83 { |
|
84 iClient.FlushBatchBuffer(); |
|
85 } |
|
86 |
|
87 void RAlfClient::CBatchBufferAutoFlusher::DoCancel() |
|
88 { |
|
89 } |
|
90 |
|
91 // ======== MEMBER FUNCTIONS ======== |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // Constructor |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 RAlfClient::RAlfClient() |
|
98 : RAlfClientBase(KAlfServiceUid.iUid), |
|
99 iDefaultBatchBuffer(0), |
|
100 iExtendedBatchBuffer(0), |
|
101 iUsedBatchBuffer(0), |
|
102 iAutoFlusher(0), |
|
103 iAutoFlushMode( EAlfAutoFlushDeferred ), |
|
104 iUsedMaxBufferSize( KAlfBatchBufferSizeNoLimit ) |
|
105 { |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // "destructor" |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void RAlfClient::Disconnect() |
|
113 { |
|
114 if ( Handle() ) |
|
115 { |
|
116 FlushBatchBuffer(); |
|
117 } |
|
118 |
|
119 delete iExtendedBatchBuffer; |
|
120 iExtendedBatchBuffer = NULL; |
|
121 |
|
122 delete iDefaultBatchBuffer; |
|
123 iDefaultBatchBuffer = NULL; |
|
124 |
|
125 iUsedBatchBuffer = NULL; |
|
126 |
|
127 delete iAutoFlusher; |
|
128 iAutoFlusher = NULL; |
|
129 |
|
130 Close(); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // Sets refresh mode |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void RAlfClient::EnvSetRefreshMode( TAlfRefreshMode aMode ) |
|
138 { |
|
139 Send(EAlfEnvSetRefreshMode, TIpcArgs(aMode) ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // Sets frame rate |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void RAlfClient::EnvSetMaxFrameRate( TReal32 aFrameRate ) |
|
147 { |
|
148 TPckg<TReal32> frameRatePckg( aFrameRate ); |
|
149 SendReceive(EAlfEnvSetMaxFrameRate, TIpcArgs(&frameRatePckg) ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Shows control group in roster. |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 TInt RAlfClient::RosterShow( |
|
157 TInt aCntrlGroupHandle, |
|
158 TInt aWhere, |
|
159 TInt aDisplayHandle ) |
|
160 { |
|
161 // Need to flush. |
|
162 FlushBatchBuffer(); |
|
163 |
|
164 TInt err = SendReceive( |
|
165 EAlfRosterShow, |
|
166 TIpcArgs(aCntrlGroupHandle, aWhere, aDisplayHandle) ); |
|
167 if ( err != KErrNone ) |
|
168 { |
|
169 __ALFLOGSTRING1( "RAlfClient::RosterShow return error %d", err ) |
|
170 } |
|
171 return err; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // Hides the control group from the roster. |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt RAlfClient::RosterHide( TInt aCntrlGroupHandle, TInt aDisplayHandle ) |
|
179 { |
|
180 TInt err = SendReceive( |
|
181 EAlfRosterHide, |
|
182 TIpcArgs(aCntrlGroupHandle, aDisplayHandle) ); |
|
183 if ( err != KErrNone ) |
|
184 { |
|
185 __ALFLOGSTRING1( "RAlfClient::RosterHide return error %d", err ) |
|
186 } |
|
187 return err; |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 // -------------------------------------------------------------------------- |
|
193 // |
|
194 TInt RAlfClient::RosterShowVisual( TInt aVisualHandle, TInt aDisplayHandle ) |
|
195 { |
|
196 TInt err = SendReceive( |
|
197 EAlfRosterShowVisual, |
|
198 TIpcArgs(aVisualHandle, aDisplayHandle) ); |
|
199 if ( err != KErrNone ) |
|
200 { |
|
201 __ALFLOGSTRING1( "RAlfClient::RosterShowVisual return error %d", err ) |
|
202 } |
|
203 return err; |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 // -------------------------------------------------------------------------- |
|
209 // |
|
210 TInt RAlfClient::RosterHideVisual( TInt aVisualHandle, TInt aDisplayHandle ) |
|
211 { |
|
212 TInt err = SendReceive( |
|
213 EAlfRosterHideVisual, |
|
214 TIpcArgs(aVisualHandle, aDisplayHandle) ); |
|
215 if ( err != KErrNone ) |
|
216 { |
|
217 __ALFLOGSTRING1( "RAlfClient::RosterHideVisual return error %d", err ) |
|
218 } |
|
219 return err; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 // -------------------------------------------------------------------------- |
|
225 // |
|
226 TInt RAlfClient::RosterSetPointerEventObservers( |
|
227 TInt aFlags, TInt aCntrlHandle, TInt aDisplayHandle ) |
|
228 { |
|
229 TInt err = SendReceive( |
|
230 EAlfRosterSetPointerEventFlags, |
|
231 TIpcArgs(aFlags, aCntrlHandle, aDisplayHandle) ); |
|
232 if ( err != KErrNone ) |
|
233 { |
|
234 __ALFLOGSTRING1( "RAlfClient::RosterSetPointerEventObservers return error %d", err ) |
|
235 } |
|
236 return err; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 // -------------------------------------------------------------------------- |
|
242 // |
|
243 TInt RAlfClient::RosterAddPointerEventObserver( |
|
244 TAlfPointerEventFlags aObserver, TInt aCntrlHandle, TInt aDisplayHandle ) |
|
245 { |
|
246 TInt err = SendReceive( |
|
247 EAlfRosterAddPointerEventObserver, |
|
248 TIpcArgs(aObserver, aCntrlHandle, aDisplayHandle) ); |
|
249 if ( err != KErrNone ) |
|
250 { |
|
251 __ALFLOGSTRING1( "RAlfClient::RosterAddPointerEventObserver return error %d", err ) |
|
252 } |
|
253 return err; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 // -------------------------------------------------------------------------- |
|
259 // |
|
260 TInt RAlfClient::RosterRemovePointerEventObserver( |
|
261 TAlfPointerEventFlags aObserver, TInt aCntrlHandle, TInt aDisplayHandle ) |
|
262 { |
|
263 TInt err = SendReceive( |
|
264 EAlfRosterRemovePointerEventObserver, |
|
265 TIpcArgs(aObserver, aCntrlHandle, aDisplayHandle) ); |
|
266 if ( err != KErrNone ) |
|
267 { |
|
268 __ALFLOGSTRING1( "RAlfClient::RosterRemovePointerEventObserver return error %d", err ) |
|
269 } |
|
270 return err; |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 // -------------------------------------------------------------------------- |
|
276 // |
|
277 TInt RAlfClient::RosterMoveVisualToFront( TInt aVisualHandle, TInt aDisplayHandle ) |
|
278 { |
|
279 TInt err = SendReceive( |
|
280 EAlfRosterMoveVisualToFront, |
|
281 TIpcArgs(aVisualHandle, aDisplayHandle) ); |
|
282 if ( err != KErrNone ) |
|
283 { |
|
284 __ALFLOGSTRING1( "RAlfClient::RosterMoveVisualToFront return error %d", err ) |
|
285 } |
|
286 return err; |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // Asks server to update owner id. |
|
291 // -------------------------------------------------------------------------- |
|
292 // |
|
293 TInt RAlfClient::TextureUpdateOwnerId() |
|
294 { |
|
295 return SendReceive( EAlfTextureUpdateOwnerId, TIpcArgs() ); |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 // -------------------------------------------------------------------------- |
|
301 // |
|
302 TInt RAlfClient::TextureCreateAnimatedL(TInt aId, TAlfTextureFlags aFlags, TInt aManagerId, const TDesC& aFilename) |
|
303 { |
|
304 TInt flags = aFlags; |
|
305 flags &= ~EAlfTextureFlagSkinContent; // Skin content is handled in the client side |
|
306 |
|
307 TInt handle = 0; |
|
308 TPckg<TInt> handlePckg(handle); |
|
309 |
|
310 TAlfCreateTextureAnimatedParams params; |
|
311 params.iId = aId; |
|
312 params.iBitmapHandle = 0; |
|
313 params.iMaskBitmapHandle = 0; |
|
314 params.iFlags = flags; |
|
315 params.iManagerId = aManagerId; |
|
316 params.iFilename = aFilename; |
|
317 |
|
318 TPckg<TAlfCreateTextureAnimatedParams> paramsPckg(params); |
|
319 TInt err = SendReceive(EAlfTextureCreateAnimated, TIpcArgs(&handlePckg, ¶msPckg) ); |
|
320 |
|
321 if ( err != KErrNone ) |
|
322 { |
|
323 __ALFLOGSTRING1( "RAlfClient::TextureCreateAnimatedL leave error %d", err ) |
|
324 } |
|
325 |
|
326 User::LeaveIfError( err ); |
|
327 return handle; |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 // -------------------------------------------------------------------------- |
|
333 // |
|
334 TInt RAlfClient::TextureStartAnimation( TInt aId ) |
|
335 { |
|
336 TPckg<TInt> idPckg(aId); |
|
337 return SendReceive(EAlfTextureStartAnimation, TIpcArgs(aId) ); |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 // -------------------------------------------------------------------------- |
|
343 // |
|
344 TInt RAlfClient::TextureStopAnimation( TInt aId ) |
|
345 { |
|
346 TPckg<TInt> idPckg(aId); |
|
347 return SendReceive(EAlfTextureStopAnimation, TIpcArgs(aId) ); |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // Creates a texture. |
|
352 // --------------------------------------------------------------------------- |
|
353 // |
|
354 TInt RAlfClient::TextureCreateL(TInt aId, |
|
355 TInt aBitmapHandle, |
|
356 TInt aMaskBitmapHandle, |
|
357 TAlfTextureFlags aFlags, |
|
358 TInt aManagerId ) |
|
359 { |
|
360 TInt flags = aFlags; |
|
361 flags &= ~EAlfTextureFlagSkinContent; // Skin content is handled in the client side |
|
362 |
|
363 TInt handle = 0; |
|
364 TPckg<TInt> handlePckg(handle); |
|
365 |
|
366 TAlfCreateTextureParams params; |
|
367 params.iId = aId; |
|
368 params.iBitmapHandle = aBitmapHandle; |
|
369 params.iMaskBitmapHandle = aMaskBitmapHandle; |
|
370 params.iFlags = flags; |
|
371 params.iManagerId = aManagerId; |
|
372 |
|
373 TPckg<TAlfCreateTextureParams> paramsPckg(params); |
|
374 TInt err = SendReceive(EAlfTextureCreate, TIpcArgs(&handlePckg, ¶msPckg) ); |
|
375 |
|
376 if ( err != KErrNone ) |
|
377 { |
|
378 __ALFLOGSTRING1( "RAlfClient::TextureCreateL leave error %d", err ) |
|
379 } |
|
380 |
|
381 User::LeaveIfError( err ); |
|
382 return handle; |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------------------------- |
|
386 // Loads a texture. |
|
387 // --------------------------------------------------------------------------- |
|
388 // |
|
389 TInt RAlfClient::TextureLoadL(TInt aId, |
|
390 TInt aBitmapHandle, |
|
391 TInt aMaskBitmapHandle, |
|
392 TAlfTextureFlags aFlags, |
|
393 TInt aManagerId ) |
|
394 { |
|
395 TInt flags = aFlags; |
|
396 flags &= ~EAlfTextureFlagSkinContent; // Skin content is handled in the client side |
|
397 |
|
398 TInt handle = 0; |
|
399 TPckg<TInt> handlePckg(handle); |
|
400 |
|
401 TAlfLoadTextureParams params; |
|
402 params.iId = aId; |
|
403 params.iBitmapHandle = aBitmapHandle; |
|
404 params.iMaskBitmapHandle = aMaskBitmapHandle; |
|
405 params.iFlags = flags; |
|
406 params.iManagerId = aManagerId; |
|
407 |
|
408 TPckg<TAlfLoadTextureParams> paramsPckg(params); |
|
409 TInt err = SendReceive(EAlfTextureLoad, TIpcArgs(&handlePckg, ¶msPckg) ); |
|
410 |
|
411 if ( err != KErrNone ) |
|
412 { |
|
413 __ALFLOGSTRING1( "RAlfClient::TextureLoadL leave error %d", err ) |
|
414 } |
|
415 |
|
416 User::LeaveIfError( err ); |
|
417 return handle; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // Unloads a texture. |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 TInt RAlfClient::TextureUnload( TInt aId, TInt aManagerId ) |
|
425 { |
|
426 TInt err = SendReceive(EAlfTextureUnload, TIpcArgs(aId, aManagerId)); |
|
427 |
|
428 if ( err != KErrNone ) |
|
429 { |
|
430 __ALFLOGSTRING1( "RAlfClient::TextureUnload return error %d", err ) |
|
431 } |
|
432 |
|
433 return err; |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // Delete a texture. |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 TInt RAlfClient::TextureDelete( TInt aId, TInt aManagerId ) |
|
441 { |
|
442 TInt err = SendReceive(EAlfTextureDelete, TIpcArgs(aId, aManagerId)); |
|
443 |
|
444 if ( err != KErrNone ) |
|
445 { |
|
446 __ALFLOGSTRING1( "RAlfClient::TextureDelete return error %d", err ) |
|
447 } |
|
448 |
|
449 return err; |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // Release a texture. |
|
454 // --------------------------------------------------------------------------- |
|
455 // |
|
456 TInt RAlfClient::TextureRelease( TInt aId, TInt aManagerId ) |
|
457 { |
|
458 TInt err = SendReceive(EAlfTextureRelease, TIpcArgs(aId, aManagerId)); |
|
459 |
|
460 if ( err != KErrNone ) |
|
461 { |
|
462 __ALFLOGSTRING1( "RAlfClient::TextureRelease return error %d", err ) |
|
463 } |
|
464 |
|
465 return err; |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // Restore a texture. |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 TInt RAlfClient::TextureRestore( TInt aId, TInt aManagerId ) |
|
473 { |
|
474 TInt err = SendReceive(EAlfTextureRestore, TIpcArgs(aId, aManagerId)); |
|
475 |
|
476 if ( err != KErrNone ) |
|
477 { |
|
478 __ALFLOGSTRING1( "RAlfClient::TextureRestore return error %d", err ) |
|
479 } |
|
480 |
|
481 return err; |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------------------------- |
|
485 // Notifies a skin change for a texture. |
|
486 // --------------------------------------------------------------------------- |
|
487 // |
|
488 TInt RAlfClient::TextureNotifySkinChanged( TInt aId, TInt aManagerId ) |
|
489 { |
|
490 TInt err = SendReceive(EAlfTextureNotifySkinChanged, TIpcArgs(aId, aManagerId)); |
|
491 |
|
492 if ( err != KErrNone ) |
|
493 { |
|
494 __ALFLOGSTRING1( "RAlfClient::TextureNotifySkinChanged return error %d", err ) |
|
495 } |
|
496 |
|
497 return err; |
|
498 } |
|
499 |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // Blurs a texture. |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 TInt RAlfClient::TextureProcessorBlurL( const TInt aServerSideSrcHandle, |
|
506 TInt aServerSideDstHandle, |
|
507 TInt aManagerId, |
|
508 const TSize& aPreferredSize, |
|
509 TInt aFilterSize, |
|
510 TInt aFlag ) |
|
511 { |
|
512 TAlfBlurTextureParams params; |
|
513 params.iServerSideSrcHandle = aServerSideSrcHandle; |
|
514 params.iServerSideDstHandle = aServerSideDstHandle; |
|
515 params.iManagerId = aManagerId; |
|
516 params.iPreferredSize = aPreferredSize; |
|
517 params.iFilterSize = aFilterSize; |
|
518 params.iFlag = aFlag; |
|
519 |
|
520 TPckg<TAlfBlurTextureParams> paramsPckg(params); |
|
521 TInt err = SendReceive(EAlfTextureBlur, TIpcArgs(¶msPckg) ); |
|
522 |
|
523 if ( err != KErrNone ) |
|
524 { |
|
525 __ALFLOGSTRING1( "RAlfClient::TextureProcessorBlurL return error %d", err ) |
|
526 } |
|
527 |
|
528 return err; |
|
529 } |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // Checks texture content. |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 TInt RAlfClient::TextureHasContent( TBool& aHasContent, TInt aId, TInt aManagerId ) |
|
536 { |
|
537 TPckg<TBool> retValPckg(aHasContent); |
|
538 TInt err = SendReceive(EAlfTextureHasContent, TIpcArgs(&retValPckg, aId, aManagerId)); |
|
539 |
|
540 if ( err != KErrNone ) |
|
541 { |
|
542 __ALFLOGSTRING1( "RAlfClient::TextureHasContent return error %d", err ) |
|
543 } |
|
544 |
|
545 return err; |
|
546 } |
|
547 |
|
548 // --------------------------------------------------------------------------- |
|
549 // Sends texture information notification request to alfred server. |
|
550 // --------------------------------------------------------------------------- |
|
551 // |
|
552 void RAlfClient::TextureNotifyInfo( TRequestStatus& aStatus, TDes8& aDest ) |
|
553 { |
|
554 SendReceive( EAlfNotifyTextureInfo, TIpcArgs( &aDest ), aStatus ); |
|
555 } |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // Cancels texture information notification request. |
|
559 // --------------------------------------------------------------------------- |
|
560 // |
|
561 void RAlfClient::TextureCancelNotifyInfo() |
|
562 { |
|
563 SendReceive( EAlfCancelNotifyTextureInfo, TIpcArgs() ); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // Sets params for texture preferred size calculation. |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 TInt RAlfClient::TextureSetAutoSizeParams( TInt aId, TInt aManagerId, |
|
571 const TAlfTextureAutoSizeParams& aParams ) |
|
572 { |
|
573 TPckg<TAlfTextureAutoSizeParams> paramsPckg(aParams); |
|
574 |
|
575 TInt err = SendReceive(EAlfTextureSetAutoSizeParams, |
|
576 TIpcArgs(aId, aManagerId, ¶msPckg) ); |
|
577 |
|
578 if ( err != KErrNone ) |
|
579 { |
|
580 __ALFLOGSTRING1( "RAlfClient::TextureSetAutoSizeParams return error %d", err ) |
|
581 } |
|
582 |
|
583 return err; |
|
584 } |
|
585 |
|
586 //---------------------------------------------------------------------------- |
|
587 // Notify about visibility of an application this instance is running |
|
588 // --------------------------------------------------------------------------- |
|
589 // |
|
590 void RAlfClient::ApplicationIsForeground(TBool aIsPartiallyOrFullyForeground) |
|
591 { |
|
592 SendReceive(EAlfNotifyAppVisibility, TIpcArgs(aIsPartiallyOrFullyForeground)); |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 // Continue refresh |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 void RAlfClient::EnvContinueRefresh() |
|
600 { |
|
601 Send(EAlfEnvContinueRefresh, TIpcArgs() ); |
|
602 } |
|
603 |
|
604 // --------------------------------------------------------------------------- |
|
605 // Pause refresh |
|
606 // --------------------------------------------------------------------------- |
|
607 // |
|
608 void RAlfClient::EnvPauseRefresh() |
|
609 { |
|
610 Send(EAlfEnvPauseRefresh, TIpcArgs() ); |
|
611 } |
|
612 |
|
613 // --------------------------------------------------------------------------- |
|
614 // Refresh call back |
|
615 // --------------------------------------------------------------------------- |
|
616 // |
|
617 void RAlfClient::EnvRefreshCallBack() |
|
618 { |
|
619 Send(EAlfEnvRefreshCallBack, TIpcArgs() ); |
|
620 } |
|
621 |
|
622 // --------------------------------------------------------------------------- |
|
623 // Get renderer type. |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 TInt RAlfClient::EnvRenderer() const |
|
627 { |
|
628 TInt retVal = 0; |
|
629 TPckg<TInt> retValPckg(retVal); |
|
630 TInt err = SendReceive(EAlfEnvRenderer, TIpcArgs(&retValPckg)); |
|
631 |
|
632 if ( err != KErrNone ) |
|
633 { |
|
634 __ALFLOGSTRING1( "RAlfClient::Renderer return error %d", err ) |
|
635 } |
|
636 |
|
637 return retVal; |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 // Set idle treshold |
|
642 // --------------------------------------------------------------------------- |
|
643 // |
|
644 void RAlfClient::EnvSetIdleThreshold(TInt aMilliseconds) |
|
645 { |
|
646 TInt err = SendReceive(EAlfEnvSetIdleThreshold, TIpcArgs(aMilliseconds)); |
|
647 |
|
648 if ( err != KErrNone ) |
|
649 { |
|
650 __ALFLOGSTRING1( "RAlfClient::EnvSetIdleTreshold return error %d", err ) |
|
651 } |
|
652 |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 // -------------------------------------------------------------------------- |
|
658 // |
|
659 void RAlfClient::CancelPointerEvents() |
|
660 { |
|
661 SendReceive(EAlfCancelPtrEvents); |
|
662 } |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 // -------------------------------------------------------------------------- |
|
667 // |
|
668 void RAlfClient::RequestPointerEvents(TDes8& aEventAsDescriptor,TRequestStatus& aStatus) |
|
669 { |
|
670 SendReceive(EAlfGetPointerEvent, TIpcArgs(&aEventAsDescriptor), aStatus); |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 // -------------------------------------------------------------------------- |
|
676 // |
|
677 void RAlfClient::SetFullScreenDrawing(TBool aEnable) |
|
678 { |
|
679 Send(ESetFullScreenDrawing, TIpcArgs(aEnable)); |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------------------------- |
|
683 // |
|
684 // -------------------------------------------------------------------------- |
|
685 // |
|
686 TInt RAlfClient::LayoutMetricsTextStyleData(TInt& aFontCategory, TInt aTextStyle) |
|
687 { |
|
688 TPckg<TInt> retValPckg(aFontCategory); |
|
689 TInt err = SendReceive(EAlfLayoutMetricsTextStyleData, TIpcArgs(&retValPckg, aTextStyle)); |
|
690 return err; |
|
691 } |
|
692 |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 // -------------------------------------------------------------------------- |
|
696 // |
|
697 void RAlfClient::CancelSystemEvents() |
|
698 { |
|
699 SendReceive(EAlfCancelSystemEvents); |
|
700 } |
|
701 |
|
702 // --------------------------------------------------------------------------- |
|
703 // |
|
704 // -------------------------------------------------------------------------- |
|
705 // |
|
706 void RAlfClient::RequestSystemEvents(TDes8& aEventAsDescriptor,TRequestStatus& aStatus) |
|
707 { |
|
708 SendReceive(EAlfGetSystemEvent, TIpcArgs(&aEventAsDescriptor), aStatus); |
|
709 } |
|
710 |
|
711 void RAlfClient::SetWgParent(TInt aParentId) |
|
712 { |
|
713 Send(EAlfSetWgParent, TIpcArgs(aParentId)); |
|
714 } |
|
715 |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 // -------------------------------------------------------------------------- |
|
720 // |
|
721 TInt RAlfClient::RosterSetPointerDragTreshold( |
|
722 TInt aCntrlHandle, const TAlfXYMetric& aXYMetric, TInt aDisplayHandle ) |
|
723 { |
|
724 TAlfPointerEventDragTreshold params; |
|
725 params.iControlHandle = aCntrlHandle; |
|
726 params.iXYMetric = aXYMetric; |
|
727 params.iDisplayHandle = aDisplayHandle; |
|
728 |
|
729 TPckg<TAlfPointerEventDragTreshold> paramsPckg(params); |
|
730 TInt err = SendReceive(EAlfRosterSetPointerDragTreshold, TIpcArgs(¶msPckg) ); |
|
731 |
|
732 if ( err != KErrNone ) |
|
733 { |
|
734 __ALFLOGSTRING1( "RAlfClient::RosterSetPointerDragTreshold return error %d", err ) |
|
735 } |
|
736 return err; |
|
737 } |
|
738 |
|
739 // --------------------------------------------------------------------------- |
|
740 // |
|
741 // -------------------------------------------------------------------------- |
|
742 // |
|
743 TInt RAlfClient::RosterDisableLongTapEventsWhenDragging( |
|
744 TInt aCntrlHandle, TBool aDisable, TInt aDisplayHandle ) |
|
745 { |
|
746 |
|
747 TInt err = SendReceive(EAlfRosterDisableLongTapEventsWhenDragging, TIpcArgs(aCntrlHandle, aDisable, aDisplayHandle) ); |
|
748 |
|
749 if ( err != KErrNone ) |
|
750 { |
|
751 __ALFLOGSTRING1( "RAlfClient::RosterSetPointerDragTreshold return error %d", err ) |
|
752 } |
|
753 return err; |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // Send synchronous command |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void RAlfClient::SendCmd(TUint aCmd, TDes8& aBuf) |
|
761 { |
|
762 Send(aCmd, TIpcArgs(&aBuf)); |
|
763 } |
|
764 |
|
765 // --------------------------------------------------------------------------- |
|
766 // Send asynchronous command |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 void RAlfClient::SendAsyncCmd(TUint aCmd, TDes8& aBuf, TRequestStatus& aStatus) |
|
770 { |
|
771 SendReceive(aCmd, TIpcArgs(&aBuf), aStatus); |
|
772 } |
|
773 |
|
774 // --------------------------------------------------------------------------- |
|
775 // Send command |
|
776 // --------------------------------------------------------------------------- |
|
777 // |
|
778 TInt RAlfClient::SendSyncCmd(TUint aCmd, TDes8& aBuf) |
|
779 { |
|
780 return SendReceive(aCmd, TIpcArgs(&aBuf)); |
|
781 } |
|
782 |
|
783 // --------------------------------------------------------------------------- |
|
784 // Appends the command in the buffer. |
|
785 // On any error case, the caller is expected to call "synch with reply" instead. |
|
786 // --------------------------------------------------------------------------- |
|
787 // |
|
788 TInt RAlfClient::SendNoReply(TUint aOp, const TDesC8& aInputBuf, TInt aSubSessionHandle) |
|
789 { |
|
790 if ( iAutoFlushMode == EAlfAutoFlushInstant ) |
|
791 { |
|
792 // this will generate a function calls flush and "send with reply" |
|
793 return KErrGeneral; |
|
794 } |
|
795 |
|
796 // Make sure the default buffer is allocated |
|
797 if ( !iDefaultBatchBuffer ) |
|
798 { |
|
799 iDefaultBatchBuffer = HBufC8::New( KAlfClientDefaultBatchBufferSize ); |
|
800 if ( !iDefaultBatchBuffer ) |
|
801 { |
|
802 return KErrNoMemory; |
|
803 } |
|
804 |
|
805 // start adding commands on the default buffer |
|
806 iUsedBatchBuffer = iDefaultBatchBuffer; |
|
807 } |
|
808 |
|
809 TPtr8 prtToUsedBuffer = iUsedBatchBuffer->Des(); |
|
810 |
|
811 TInt3 param( aOp, aSubSessionHandle, aInputBuf.Length() ); |
|
812 TPckgC<TInt3> paramPckg( param ); |
|
813 |
|
814 // check max length |
|
815 const TInt paddedParamsPckgLength = AlfPaddedLength( paramPckg.Length() ); |
|
816 const TInt paddedInputBufLength = AlfPaddedLength( aInputBuf.Length() ); |
|
817 const TInt lengthNeededByTheCommand = |
|
818 paddedParamsPckgLength + paddedInputBufLength; |
|
819 |
|
820 // check if we can fit in the used buffer |
|
821 if ( lengthNeededByTheCommand > prtToUsedBuffer.MaxLength() - prtToUsedBuffer.Length() ) |
|
822 { |
|
823 // we cannot fit. Let's try to allocate more buffer: |
|
824 TInt allocError = AllocateExtendedBuffer( lengthNeededByTheCommand ); |
|
825 |
|
826 if ( allocError != KErrNone ) |
|
827 { |
|
828 if ( iAutoFlushMode != EAlfAutoFlushOnlyForced ) |
|
829 { |
|
830 FlushBatchBuffer(); |
|
831 } |
|
832 } |
|
833 } |
|
834 |
|
835 // the used buffer might have changed in the previous if-statement |
|
836 prtToUsedBuffer.Set( iUsedBatchBuffer->Des() ); |
|
837 |
|
838 // check if we can fit in the used buffer - again |
|
839 if ( lengthNeededByTheCommand > prtToUsedBuffer.MaxLength() - prtToUsedBuffer.Length() ) |
|
840 { |
|
841 // we still do not fit... |
|
842 return KErrOverflow; |
|
843 } |
|
844 |
|
845 prtToUsedBuffer.Append( paramPckg ); |
|
846 AppendPadding( |
|
847 prtToUsedBuffer, |
|
848 paddedParamsPckgLength - paramPckg.Length() ); |
|
849 prtToUsedBuffer.Append( aInputBuf ); |
|
850 AppendPadding( |
|
851 prtToUsedBuffer, |
|
852 paddedInputBufLength - aInputBuf.Length() ); |
|
853 |
|
854 __ASSERT_DEBUG( |
|
855 !( prtToUsedBuffer.Length() % KAlfClientServerRoundToBoundary ), |
|
856 USER_INVARIANT() ); |
|
857 |
|
858 if ( !iAutoFlusher && iAutoFlushMode == EAlfAutoFlushDeferred ) |
|
859 { |
|
860 iAutoFlusher = new CBatchBufferAutoFlusher(*this); |
|
861 if ( !iAutoFlusher ) |
|
862 { |
|
863 // if cannot allocate auto-flusher, flush now |
|
864 FlushBatchBuffer(); |
|
865 return KErrNone; |
|
866 } |
|
867 } |
|
868 |
|
869 if ( iAutoFlusher ) |
|
870 { |
|
871 iAutoFlusher->StartAutoFlush(); |
|
872 } |
|
873 return KErrNone; |
|
874 } |
|
875 |
|
876 // --------------------------------------------------------------------------- |
|
877 // Returns the flush mode |
|
878 // --------------------------------------------------------------------------- |
|
879 // |
|
880 TAlfAutoFlushMode RAlfClient::AutoFlushMode() const |
|
881 { |
|
882 return iAutoFlushMode; |
|
883 } |
|
884 |
|
885 // --------------------------------------------------------------------------- |
|
886 // Sets the flush mode |
|
887 // --------------------------------------------------------------------------- |
|
888 // |
|
889 void RAlfClient::SetAutoFlushMode( TAlfAutoFlushMode aAutoFlushMode ) |
|
890 { |
|
891 if ( iAutoFlushMode == aAutoFlushMode ) |
|
892 { |
|
893 // no action required |
|
894 return; |
|
895 } |
|
896 |
|
897 FlushBatchBuffer(); |
|
898 iAutoFlushMode = aAutoFlushMode; |
|
899 |
|
900 switch( iAutoFlushMode ) |
|
901 { |
|
902 case EAlfAutoFlushOnlyForced: |
|
903 delete iAutoFlusher; |
|
904 iAutoFlusher = NULL; |
|
905 break; |
|
906 |
|
907 case EAlfAutoFlushInstant: |
|
908 // these are not needed |
|
909 delete iDefaultBatchBuffer; |
|
910 iDefaultBatchBuffer = NULL; |
|
911 |
|
912 iUsedBatchBuffer = NULL; |
|
913 |
|
914 delete iAutoFlusher; |
|
915 iAutoFlusher = NULL; |
|
916 break; |
|
917 |
|
918 default: |
|
919 break; |
|
920 } |
|
921 |
|
922 __ALFLOGSTRING1( "RAlfClient::SetAutoFlushMode New flush mode %d", aAutoFlushMode ) |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // Flushes the command buffer |
|
927 // --------------------------------------------------------------------------- |
|
928 // |
|
929 TInt RAlfClient::FlushBatchBuffer() |
|
930 { |
|
931 TInt err = KErrNone; |
|
932 if ( iUsedBatchBuffer && iUsedBatchBuffer->Length() ) |
|
933 { |
|
934 TPtr8 ptr(iUsedBatchBuffer->Des()); |
|
935 err = SendSyncCmd( EAlfDoSubSessionBatchCmd, ptr ); |
|
936 |
|
937 // all the commands in the buffer are handled -> it can be emptied |
|
938 delete iExtendedBatchBuffer; |
|
939 iExtendedBatchBuffer = NULL; |
|
940 |
|
941 iDefaultBatchBuffer->Des().Zero(); |
|
942 |
|
943 iUsedBatchBuffer = iDefaultBatchBuffer; |
|
944 |
|
945 // the iDefaultBatchBuffer could be deleted here, but we might end up |
|
946 // fragmenting the memory |
|
947 } |
|
948 |
|
949 if ( iAutoFlusher ) |
|
950 { |
|
951 iAutoFlusher->Cancel(); |
|
952 } |
|
953 |
|
954 // the iAutoFlusher could be deleted here, but we might end up |
|
955 // fragmenting the memory |
|
956 |
|
957 return err; |
|
958 } |
|
959 |
|
960 // --------------------------------------------------------------------------- |
|
961 // Sets the flush buffer size |
|
962 // --------------------------------------------------------------------------- |
|
963 // |
|
964 void RAlfClient::SetMaxBatchBufferSize( TInt aBufferSize ) |
|
965 { |
|
966 FlushBatchBuffer(); |
|
967 |
|
968 if ( aBufferSize == KAlfBatchBufferSizeNoLimit ) |
|
969 { |
|
970 iUsedMaxBufferSize = KAlfBatchBufferSizeNoLimit; |
|
971 } |
|
972 else if ( aBufferSize == KAlfBatchBufferSizeLimitToSystemDefault ) |
|
973 { |
|
974 // KAlfClientDefaultBatchBufferSize will be used |
|
975 iUsedMaxBufferSize = KAlfClientDefaultBatchBufferSize; |
|
976 } |
|
977 else |
|
978 { |
|
979 // The buffer >= KAlfClientDefaultBatchBufferSize always |
|
980 iUsedMaxBufferSize = Max( aBufferSize, KAlfClientDefaultBatchBufferSize ); |
|
981 } |
|
982 } |
|
983 |
|
984 // --------------------------------------------------------------------------- |
|
985 // Tries to allocate the extended buffer |
|
986 // --------------------------------------------------------------------------- |
|
987 // |
|
988 TInt RAlfClient::AllocateExtendedBuffer( TInt aMoreSpaceNeeded ) |
|
989 { |
|
990 TPtr8 prtToUsedBuffer = iUsedBatchBuffer->Des(); |
|
991 |
|
992 // Note that max buffer size may be slightly larger than |
|
993 // iUsedMaxBufferSize, since when you create instance using |
|
994 // HBufC8::NewL( len ) its max size may be larger than len. |
|
995 if ( ( iUsedMaxBufferSize != KAlfBatchBufferSizeNoLimit ) && |
|
996 ( prtToUsedBuffer.MaxLength() >= iUsedMaxBufferSize ) ) |
|
997 { |
|
998 // Cannot make make buffer any bigger |
|
999 return KErrGeneral; |
|
1000 } |
|
1001 |
|
1002 // Go for twice the required size. |
|
1003 TInt newExtendedSize = |
|
1004 ( prtToUsedBuffer.Length() + aMoreSpaceNeeded ) * 2; |
|
1005 if ( iUsedMaxBufferSize != KAlfBatchBufferSizeNoLimit ) |
|
1006 { |
|
1007 // There is a max limit - we need to balace with it |
|
1008 newExtendedSize = Min( newExtendedSize, iUsedMaxBufferSize ); |
|
1009 } |
|
1010 |
|
1011 HBufC8* newBuffer = HBufC8::New( newExtendedSize ); |
|
1012 if ( !newBuffer ) |
|
1013 { |
|
1014 return KErrNoMemory; |
|
1015 } |
|
1016 |
|
1017 // Copy from the old one |
|
1018 TPtr8 newBufferPtr = newBuffer->Des(); |
|
1019 newBufferPtr.Copy( *iUsedBatchBuffer ); |
|
1020 |
|
1021 // Clear the old one |
|
1022 if ( iUsedBatchBuffer == iExtendedBatchBuffer ) |
|
1023 { |
|
1024 // delete old extended buffer |
|
1025 delete iExtendedBatchBuffer; |
|
1026 iExtendedBatchBuffer = NULL; |
|
1027 } |
|
1028 else |
|
1029 { |
|
1030 iDefaultBatchBuffer->Des().Zero(); |
|
1031 } |
|
1032 |
|
1033 // set the pointers point to the new buffer |
|
1034 iExtendedBatchBuffer = newBuffer; |
|
1035 iUsedBatchBuffer = iExtendedBatchBuffer; |
|
1036 |
|
1037 __ALFLOGSTRING1( "RAlfClient::AllocateExtendedBuffer New buffer size %d", newExtendedSize ) |
|
1038 |
|
1039 return KErrNone; |
|
1040 } |
|
1041 |
|
1042 // --------------------------------------------------------------------------- |
|
1043 // Appends padding to the command |
|
1044 // --------------------------------------------------------------------------- |
|
1045 // |
|
1046 inline void RAlfClient::AppendPadding( TDes8& aBuffer, TInt aAmount ) |
|
1047 { |
|
1048 if ( aAmount ) |
|
1049 { |
|
1050 // Modify length |
|
1051 TInt length = aBuffer.Length(); |
|
1052 aBuffer.SetLength( length + aAmount ); |
|
1053 |
|
1054 // Zero bytes used for padding |
|
1055 do |
|
1056 { |
|
1057 aAmount--; |
|
1058 aBuffer[ length ] = 0; |
|
1059 length++; |
|
1060 } |
|
1061 while ( aAmount ); |
|
1062 } |
|
1063 } |
|
1064 |
|
1065 // --------------------------------------------------------------------------- |
|
1066 // Post Qt buffer received from Qt port |
|
1067 // --------------------------------------------------------------------------- |
|
1068 // |
|
1069 |
|
1070 TInt RAlfClient::PostQtBuffer( TInt aWsWgId, TInt aWsClientId, TDes8& aCommandBuffer, |
|
1071 TAlfCommandBufferStatus aStatus ) |
|
1072 { |
|
1073 TAlfQtCommandBufferParams params; |
|
1074 params.iWsClientId = aWsClientId; |
|
1075 params.iPtr = (TAny*)aCommandBuffer.Ptr(); |
|
1076 params.iLength = aCommandBuffer.Length(); |
|
1077 params.iBufferStatus = aStatus; |
|
1078 params.iVisualHandle = 0; |
|
1079 params.iWsWgId = aWsWgId; |
|
1080 TPckg<TAlfQtCommandBufferParams> paramsPckg(params); |
|
1081 |
|
1082 TInt err = SendReceive( EAlfQtCommandBuffer, TIpcArgs(¶msPckg) ); |
|
1083 |
|
1084 if ( err != KErrNone ) |
|
1085 { |
|
1086 __ALFLOGSTRING1( "RAlfClient::PostQtBuffer return error %d", err ) |
|
1087 } |
|
1088 return err; |
|
1089 } |
|
1090 |
|
1091 // --------------------------------------------------------------------------- |
|
1092 // Returns the requested info about the batch buffer |
|
1093 // --------------------------------------------------------------------------- |
|
1094 // |
|
1095 TInt RAlfClient::GetBatchBufferInfo( TAlfBatchBufferInfoType aBufferInfoType ) const |
|
1096 { |
|
1097 switch ( aBufferInfoType ) |
|
1098 { |
|
1099 case EAlfBatchBufferInfoDefaultBufferSize: |
|
1100 return KAlfClientDefaultBatchBufferSize; |
|
1101 |
|
1102 case EAlfBatchBufferInfoMaxSize: |
|
1103 return iUsedMaxBufferSize == KAlfClientDefaultBatchBufferSize ? |
|
1104 KAlfBatchBufferSizeLimitToSystemDefault : iUsedMaxBufferSize; |
|
1105 |
|
1106 case EAlfBatchBufferInfoCurrentlyAllocated: |
|
1107 return iUsedBatchBuffer ? iUsedBatchBuffer->Des().MaxLength() : 0; |
|
1108 |
|
1109 case EAlfBatchBufferInfoCommandsAllocate: |
|
1110 return iUsedBatchBuffer ? iUsedBatchBuffer->Length() : 0; |
|
1111 |
|
1112 default: |
|
1113 return 0; |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 TInt RAlfClient::ClearTextureAnimation( TInt aId ) |
|
1118 { |
|
1119 TPckg<TInt> idPckg(aId); |
|
1120 return SendReceive(EAlfTextureCleanAnimation, TIpcArgs(aId) ); |
|
1121 } |
|
1122 // end of file |
|
1123 |