|
1 /* |
|
2 * Copyright (c) 2008-2008 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: This file contains classes of Peninput server client side. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef R_RPENINPUTSERVER_IMPL_H |
|
20 #define R_RPENINPUTSERVER_IMPL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32err.h> |
|
25 #include <coemain.h> |
|
26 #include "peninputcmdparam.h" |
|
27 #include "peninputsrveventhandler.h" |
|
28 #include <coecntrl.h> |
|
29 #include <AknFepGlobalEnums.h> |
|
30 |
|
31 class CPeninputServerObserver; |
|
32 class MPenUiActivationHandler; |
|
33 class CPenUiBackgroundWnd; |
|
34 |
|
35 NONSHARABLE_CLASS(CPeninputServerWaiter) : public CBase |
|
36 { |
|
37 public: |
|
38 static CPeninputServerWaiter* NewL(); |
|
39 void Start(); |
|
40 void Stop(TInt aFlag); |
|
41 TBool IsStarted() |
|
42 { |
|
43 return iWaitScheduler->IsStarted(); |
|
44 } |
|
45 TInt Error() |
|
46 { |
|
47 return iError; |
|
48 } |
|
49 ~CPeninputServerWaiter(); |
|
50 protected: |
|
51 private: |
|
52 //CPeninputServerWaiter(); |
|
53 void ConstructL(); |
|
54 TInt iError; |
|
55 CActiveSchedulerWait* iWaitScheduler; |
|
56 }; |
|
57 |
|
58 NONSHARABLE_CLASS(TUiNotificationHandler) |
|
59 { |
|
60 public: |
|
61 TUiNotificationHandler(MPenUiActivationHandler* aHandler,TInt aType); |
|
62 public: |
|
63 MPenUiActivationHandler* iHandler; |
|
64 TInt iType; |
|
65 }; |
|
66 |
|
67 |
|
68 class CWaitingServerAo; |
|
69 /** |
|
70 * Client side interface to PeninputSingletonServer. |
|
71 * |
|
72 * |
|
73 * @lib peninputclient.lib |
|
74 * @since S60 v4.0 |
|
75 */ |
|
76 NONSHARABLE_CLASS(RPeninputServerImpl) : public RSessionBase |
|
77 { |
|
78 public: |
|
79 |
|
80 static RPeninputServerImpl* NewL(TRequestStatus* aStatus = NULL); |
|
81 // Constructors and destructor |
|
82 |
|
83 |
|
84 /** |
|
85 * Makes a connection to the server. |
|
86 * |
|
87 * @since S60 v4.0 |
|
88 * @return KErrNone if connection was successful, otherwise one of the |
|
89 * general error codes. |
|
90 */ |
|
91 //TInt Connect(); |
|
92 |
|
93 /** |
|
94 * Returns the version information of the server. |
|
95 * |
|
96 * @since S60 v4.0 |
|
97 * @return TVersion object containing the version of the server. |
|
98 */ |
|
99 TVersion Version() const; |
|
100 |
|
101 |
|
102 /** |
|
103 * Closes the connection to the server. |
|
104 * |
|
105 * @since S60 v4.0 |
|
106 */ |
|
107 void Close(); |
|
108 |
|
109 /** |
|
110 * HandleCommandL, handle command from client |
|
111 * |
|
112 * @since S60 v4.0 |
|
113 * @param aCmd The commandid |
|
114 * @param aBuf Command data |
|
115 * @return The command handling result code.KErrNone if operation sucessfully. |
|
116 */ |
|
117 TInt HandleCommand(TInt aCmd,const TDesC8& aBuf); |
|
118 |
|
119 /** |
|
120 * HandleCommandL, handle command from client |
|
121 * |
|
122 * @since S60 v4.0 |
|
123 * @param aCmd The commandid |
|
124 * @return The command handling result code.KErrNone if operation sucessfully. |
|
125 */ |
|
126 TInt HandleCommand(TInt aCmd); |
|
127 /** |
|
128 * HandleCommandL, handle command from client |
|
129 * |
|
130 * @since S60 v4.0 |
|
131 * @param aCmd The commandid |
|
132 * @param aBuf Command data |
|
133 * @param aResult The result of layout handle |
|
134 * @return The command handling result code.KErrNone if operation sucessfully. |
|
135 */ |
|
136 TInt HandleCommand(TInt aCmd,const TDesC8& aBuf,TInt &aResult); |
|
137 |
|
138 /** |
|
139 * Get PENINPUT UI visibility |
|
140 * |
|
141 * @since S60 v4.0 |
|
142 * @return ETrue if PENINPUT is visible, EFalse otherwise |
|
143 */ |
|
144 TBool IsVisible(); |
|
145 |
|
146 /** |
|
147 * Get PENINPUT UI dim status |
|
148 * |
|
149 * @since S60 v4.0 |
|
150 * @return ETrue if PENINPUT is visible, EFalse otherwise |
|
151 */ |
|
152 TBool IsDimmed(); |
|
153 |
|
154 /** |
|
155 * Get the all support input mode |
|
156 * |
|
157 * @since S60 v4.0 |
|
158 * @return input mode |
|
159 */ |
|
160 TInt SupportInputMode(); |
|
161 |
|
162 /** |
|
163 * Set input language Id |
|
164 * |
|
165 * @since S60 v4.0 |
|
166 * @param aLanguage The input language Id |
|
167 * @return The operation result code.KErrNone if successfully. |
|
168 */ |
|
169 TInt SetInputLanguage( TInt aLanguage ); |
|
170 |
|
171 /** |
|
172 * Set UI layout id. It will create the UI by the Id |
|
173 * |
|
174 * @since S60 v4.0 |
|
175 * @param aId The layout Id |
|
176 * @return The operation result code.KErrNone if successfully. |
|
177 */ |
|
178 TInt SetUiLayoutId(TUid aId); |
|
179 |
|
180 /** |
|
181 * Set UI layout id |
|
182 * |
|
183 * @since S60 v4.0 |
|
184 * @param aId The layout Id |
|
185 * @param aData The data associated with the layout creation |
|
186 * @return The operation result code |
|
187 */ |
|
188 TInt SetUiLayoutId(TUid aId,const TDesC8& aData); |
|
189 |
|
190 /** |
|
191 * Set UI layout position |
|
192 * |
|
193 * @since S60 v4.0 |
|
194 * @param aPos The layout position |
|
195 * @return The operation result code. KErrNone if successfully. |
|
196 */ |
|
197 TInt SetUiLayoutPos(const TPoint& aPos); |
|
198 |
|
199 /** |
|
200 * get UI layout position |
|
201 * |
|
202 * @since S60 v4.0 |
|
203 * @return The layout position |
|
204 */ |
|
205 TPoint UiLayoutPos(); |
|
206 |
|
207 /** |
|
208 * get UI layout size |
|
209 * |
|
210 * @since S60 v4.0 |
|
211 * @return The layout size |
|
212 */ |
|
213 TSize UiLayoutSize(); |
|
214 |
|
215 /** |
|
216 * Called when resource changed, e.g, screen size changed. |
|
217 * To inform layout that resource change event. |
|
218 * |
|
219 * @since S60 v4.0 |
|
220 * @param aData The data associated with size change event |
|
221 */ |
|
222 void ResourceChanged(TInt aType); |
|
223 |
|
224 /** |
|
225 * Activate/Deactivate the layout |
|
226 * |
|
227 * @since S60 V4.0 |
|
228 * @param aFlag The activation flag. ETrue if activated |
|
229 */ |
|
230 void ActivateLayout(TBool aFlag); |
|
231 |
|
232 /** |
|
233 * Get server event data. |
|
234 * When server oberver got a event notification, it calls this to get data |
|
235 * |
|
236 * @since S60 V4.0 |
|
237 * @param aBuf buf to save the event data on return |
|
238 * @return result code. KErrNone if data got. If the length of aBuf is |
|
239 * smaller than server data, data is not copied, return value is the |
|
240 * required data length. KNullDesC is returned if no data in server side |
|
241 */ |
|
242 TInt GetServerEventData(TDes& aBuf); |
|
243 |
|
244 /** |
|
245 * Get current pended server event number |
|
246 * |
|
247 * @since S60 V4.0 |
|
248 * @return The current pended event number in server side |
|
249 */ |
|
250 TInt ServerEventDataNum(); |
|
251 |
|
252 /** |
|
253 * Add server observer. An observer will be notified when server has event |
|
254 * |
|
255 * @since S60 V4.0 |
|
256 * @param aObserver The server observer |
|
257 */ |
|
258 void AddPeninputServerObserverL( |
|
259 MPeninputServerEventHandler* aObserver); |
|
260 |
|
261 |
|
262 /** |
|
263 * Remove all pen input observer |
|
264 * |
|
265 * @since S60 V5.0 |
|
266 */ |
|
267 void RemovePeninputServerObserver(); |
|
268 |
|
269 /** |
|
270 * Remove pen input observer |
|
271 * |
|
272 * @since S60 V5.0 |
|
273 * @param aObserver The observer to be removed |
|
274 */ |
|
275 void RemovePeninputServerObserver(MPeninputServerEventHandler* aObserver); |
|
276 |
|
277 /* |
|
278 * Set display mode. This must be called before any UI layout created. |
|
279 * Otherwise, no change happends. |
|
280 * |
|
281 * @since S60 V4.0 |
|
282 * @param aMode The display mode |
|
283 * @param aMaskMode The display mode for mask device |
|
284 */ |
|
285 void SetDisplayMode(TDisplayMode aDisplayMode, |
|
286 TDisplayMode aMaskDisplayMode); |
|
287 /* |
|
288 * Clear server events, all pending events for current session is cleared. |
|
289 * It's used when current focus changed and previous server event is out of date. |
|
290 * |
|
291 * @since S60 V4.0 |
|
292 */ |
|
293 void ClearServerEvent(); |
|
294 |
|
295 /** |
|
296 * Return requried Ime plugin list |
|
297 * |
|
298 * @since S60 V4.0 |
|
299 * @param aLanguage The required supporting language |
|
300 * @param aPluginMode The required supporting mode |
|
301 * @param aImplmentationIds A reference to a client owned array |
|
302 * which will be filled with IME plugin implementation. |
|
303 */ |
|
304 void GetImePluginIdListL(TInt aLanguage, |
|
305 TInt aPluginMode, |
|
306 RArray<TInt>& aImplmentationIds); |
|
307 |
|
308 /** |
|
309 * Return all supporing touch input languages |
|
310 * |
|
311 * @since S60 V4.0 |
|
312 * @param aLanguageLists A reference to a client owned array |
|
313 * which will be filled with supporting languages. |
|
314 */ |
|
315 void PenSupportLanguagesL(RArray<TInt>& aLanguageLists); |
|
316 /** |
|
317 * Asynchronous request which must be issued by every client after |
|
318 * Connect(). When this request completes it is the clients responsibility |
|
319 * to react to the message. Only one |
|
320 * client can receive this notification. Client must call CancelMessageNotification() |
|
321 * before closing the session. |
|
322 * |
|
323 * @since S60 v4.0 |
|
324 *@param aStatus Message Id of the observing active object |
|
325 */ |
|
326 void RequestMessageNotification( TRequestStatus& aStatus ); |
|
327 |
|
328 /** |
|
329 * Cancels the asynchronous request issued by RequestMessageNotification(). |
|
330 * |
|
331 * @since S60 v4.0 |
|
332 */ |
|
333 void CancelMessageNotification(); |
|
334 |
|
335 /** |
|
336 * Set foreground application session. Only foreground app session |
|
337 * can change the pen input UI attribute. Such command from other session |
|
338 * will be discarded by server. |
|
339 * |
|
340 * @since S60 V4.0 |
|
341 * @param aMustConnectFlag If ETrue, the set will always success. If EFalse, |
|
342 * operation depends on whether current app is the foreground application. |
|
343 */ |
|
344 TBool SetForeground(TBool aMustConnectFlag); |
|
345 |
|
346 /** |
|
347 * Indicates current client lost foregound. |
|
348 * |
|
349 * @since S60 V5.0 |
|
350 */ |
|
351 void LoseForeground(); |
|
352 |
|
353 /** |
|
354 * Test whether this session is the forground application session |
|
355 * |
|
356 * @since S60 V4.0 |
|
357 * @return ETrue if current session is foreground application session. |
|
358 */ |
|
359 TBool IsForeground(); |
|
360 |
|
361 /** |
|
362 * Add pen input UI activation observer. Only one handler can be added. If |
|
363 * need to change the handler, the old handler must be first removed. |
|
364 * |
|
365 * @since S60 V4.0 |
|
366 * @param aHandler The callback handler when pen input UI activated/deactivated |
|
367 * @param aType The pen ui type to be handled. The available type is defined in |
|
368 * TPenInputUiType |
|
369 * @return KErrNone if sucessfully. |
|
370 */ |
|
371 TInt AddPenUiActivationHandler(MPenUiActivationHandler* aHandler, |
|
372 TInt aType); |
|
373 |
|
374 /** |
|
375 * Remove all pen input UI activation observer |
|
376 * |
|
377 * @since S60 V4.0 |
|
378 * |
|
379 */ |
|
380 void RemovePenUiActivationHandler(); |
|
381 |
|
382 /** |
|
383 * Remove a pen input UI activation observer |
|
384 * |
|
385 * @since S60 V5.0 |
|
386 */ |
|
387 |
|
388 void RemovePenUiActivationHandler(MPenUiActivationHandler *aHandler); |
|
389 |
|
390 |
|
391 void ActivatePeninputInNotesL(); |
|
392 void DimUiLayout(TBool aFlag); |
|
393 |
|
394 void BackgroudDefaultOri( TInt aOri ); |
|
395 |
|
396 /** |
|
397 * Inform server that client has handled the UI notification event |
|
398 * |
|
399 * @since S60 V4.0 |
|
400 */ |
|
401 void Continue(); |
|
402 |
|
403 /* |
|
404 * To disable specified layouts at a time. |
|
405 * |
|
406 * @since S60 V4.0 |
|
407 * @param aDisableLayout The disabled layouts.Can disable serveral layouts one time. |
|
408 */ |
|
409 void SetDisabledLayout( TInt aLayouts ); |
|
410 |
|
411 /* |
|
412 * To get disable specified layouts at a time. |
|
413 * |
|
414 * @since S60 V4.0 |
|
415 * @return The disabled layouts. |
|
416 */ |
|
417 TInt DisabledLayout(); |
|
418 |
|
419 /* |
|
420 * Update the application information. |
|
421 * |
|
422 * @since S60 V5.0 |
|
423 * @param aInfo The application information. |
|
424 * @param aType The information type |
|
425 */ |
|
426 void UpdateAppInfo(const TDesC& aInfo, TPeninputAppInfo aType); |
|
427 |
|
428 void HandleServerExit(); |
|
429 void OnServerReady(TBool aFlag = ETrue); |
|
430 TBool IsForegroundSession(); |
|
431 //void SetForegroundFlag(TBool aFlag); |
|
432 void FinalClose(); |
|
433 /* |
|
434 * Enable/disable the auto open feature. When auto open feature is on, Focus change event |
|
435 * will open the pen UI automatically. The feature is on by default. When disabled, |
|
436 * all editor in current app won't have the auto-open feature. |
|
437 * |
|
438 * @since S60 V5.0 |
|
439 * @param aFlag ETrue to enable the feature, EFalse to disable the feature. |
|
440 */ |
|
441 void SetAutoOpen(TBool aFlag); |
|
442 |
|
443 /* |
|
444 * Get the auto-open feature flag. |
|
445 * |
|
446 * @since S60 V5.0 |
|
447 * @return ETrue if auto-open feature is on, otherwise EFalse. |
|
448 */ |
|
449 TBool AutoOpen(); |
|
450 |
|
451 /* |
|
452 * Set the application prefferred input mode. Application can set this mode to |
|
453 * override the mode selected by Fep. |
|
454 * |
|
455 * @since S60 V5.0 |
|
456 */ |
|
457 void SetPreferredUiMode(TPluginInputMode aMode); |
|
458 |
|
459 /* |
|
460 * Get the application prefferred input mode. |
|
461 * |
|
462 * @since S60 V5.0 |
|
463 * @return The application preferred mode. EPluginInputModeNone if app does set it. |
|
464 */ |
|
465 TPluginInputMode PreferredUiMode(); |
|
466 |
|
467 void SetGlobalNotes(TBool aFlag); |
|
468 |
|
469 void SetInternalPopUp(TBool aFlag); |
|
470 void SetEditorPriority(TInt aFlag); |
|
471 |
|
472 void ClearTouchUI(); |
|
473 void SetResourceChange(TBool aFlag); |
|
474 |
|
475 /** |
|
476 * Starts the server thread |
|
477 * |
|
478 * @since S60 v4.0 |
|
479 *@return KErrNone if server was created successfully |
|
480 * KErrAlreadyExists if the server is already running |
|
481 * otherwise one of the system wide error codes |
|
482 */ |
|
483 TInt StartThreadL(); |
|
484 |
|
485 //TInt ConnectAsync(TRequestStatus& status); |
|
486 TInt StartThreadAsyncL(); |
|
487 void AddObserver(); |
|
488 TBool ServerReady(); |
|
489 void OnServerStarted(TInt); |
|
490 |
|
491 private: |
|
492 /** |
|
493 * Constructor |
|
494 * |
|
495 * @since S60 v4.0 |
|
496 */ |
|
497 RPeninputServerImpl(); |
|
498 |
|
499 void ConstructL(const TUid& aUid,TRequestStatus* aStatus); |
|
500 |
|
501 TInt DoConnectL(); |
|
502 TInt DoConnectL(TRequestStatus* aStatus); |
|
503 |
|
504 void GetUiLayoutPosAndSize(); |
|
505 |
|
506 void DimUiLayoutL(TBool aFlag); |
|
507 |
|
508 private: // New functions |
|
509 |
|
510 |
|
511 void ReadIntArrayFromBufL(const TDesC8& aBuf, RArray<TInt>& aResult); |
|
512 |
|
513 void DoAddPenUiActivationHandler(); |
|
514 private: // Data |
|
515 /** |
|
516 * server observer |
|
517 */ |
|
518 CPeninputServerObserver* iObserver; |
|
519 |
|
520 /** |
|
521 * Ui notification handler. |
|
522 */ |
|
523 //CPenUiNotificationHandler* iPenUiNotificationHandler; |
|
524 RArray<TUiNotificationHandler> iPenUiNotificationHandler; |
|
525 //TUiNotificationHandler* iPenUiNotificationHandler |
|
526 |
|
527 /** |
|
528 * The type which to be monitored by the client. |
|
529 */ |
|
530 //TInt iRegistedType; |
|
531 /** |
|
532 * Indicates whether current client is the foreground application. |
|
533 */ |
|
534 TBool iIsForegroundSession; |
|
535 /** |
|
536 * server active flag |
|
537 */ |
|
538 TBool iServerExit; |
|
539 |
|
540 TBool iLaunchServer; |
|
541 |
|
542 //CActiveSchedulerWait* iWaitScheduler; |
|
543 CPeninputServerWaiter * iWaitScheduler; |
|
544 |
|
545 TInt iCurPenUiType; |
|
546 |
|
547 CPenUiBackgroundWnd* iBackgroundCtrl; |
|
548 |
|
549 TBool iAutoOpenFlag; |
|
550 |
|
551 TPluginInputMode iAppPrefferedUiMode; |
|
552 |
|
553 TPoint iPosition; |
|
554 TSize iSize; |
|
555 TBool iGlobalNotes; |
|
556 TBool iInternalPopup; |
|
557 TInt iPriority; |
|
558 TBool iResourceChange; |
|
559 TBool iStartServerOver; |
|
560 CWaitingServerAo* iWaiterAo; |
|
561 TRequestStatus* iPendingRequest; |
|
562 TBool iServerReady; |
|
563 }; |
|
564 |
|
565 |
|
566 class CWaitingServerAo : public CActive |
|
567 { |
|
568 public: |
|
569 |
|
570 CWaitingServerAo(RPeninputServerImpl* aClient); |
|
571 |
|
572 /** |
|
573 * From CActive |
|
574 * will be called when stroke timer ends |
|
575 * |
|
576 * @since S60 v4.0 |
|
577 */ |
|
578 void RunL(); |
|
579 |
|
580 /** |
|
581 * From CActive |
|
582 * will be called if RunL leaves |
|
583 * |
|
584 * @since S60 v4.0 |
|
585 */ |
|
586 TInt RunError(TInt aError); |
|
587 |
|
588 /** |
|
589 * From CActive |
|
590 * will be called when stroke timer has been cancelled |
|
591 * |
|
592 * @since S60 v4.0 |
|
593 */ |
|
594 void DoCancel(); |
|
595 |
|
596 TRequestStatus& RequestStatus(); |
|
597 |
|
598 RPeninputServerImpl* iClient; |
|
599 }; |
|
600 |
|
601 |
|
602 NONSHARABLE_CLASS(CPenInputSingletonClient) : public CCoeStatic |
|
603 { |
|
604 public: |
|
605 //static CPenInputSingletonClient* NewL(RPeninputServer* aServer); |
|
606 //private: |
|
607 CPenInputSingletonClient(const TUid& aUid,RPeninputServerImpl* aServer); |
|
608 ~CPenInputSingletonClient(); |
|
609 //void ConstructL(); |
|
610 RPeninputServerImpl* GetSingletonServer(); |
|
611 |
|
612 TInt DecreaseRef() ; |
|
613 |
|
614 TBool IsValid(); |
|
615 void SetInvalid(); |
|
616 void ReplaceServer(RPeninputServerImpl* aServer); |
|
617 private: |
|
618 RPeninputServerImpl* iServer; |
|
619 TInt iReferrence; |
|
620 TBool iIsValid; |
|
621 }; |
|
622 |
|
623 |
|
624 NONSHARABLE_CLASS(CPenUiBackgroundWnd) : public CCoeControl |
|
625 { |
|
626 public: // Constructors and destructor |
|
627 /** |
|
628 * C++ default constructor. |
|
629 * @param aAppUi AppUi of Eikon server. |
|
630 */ |
|
631 static CPenUiBackgroundWnd* NewL(RWindowGroup& aWndGroup,TInt aBmpHandle); |
|
632 |
|
633 private: |
|
634 /** |
|
635 * C++ default constructor. |
|
636 * @param aAppUi AppUi of Eikon server. |
|
637 */ |
|
638 CPenUiBackgroundWnd(RWindowGroup& aWndGroup); |
|
639 /** |
|
640 * Two-phased constructor. |
|
641 */ |
|
642 void ConstructL(TInt aBmpHandle); |
|
643 public: |
|
644 /** |
|
645 * Destructor. |
|
646 */ |
|
647 ~CPenUiBackgroundWnd(); |
|
648 |
|
649 public: // New functions |
|
650 /** |
|
651 * Called from akncapserver appui to run fastswap. |
|
652 */ |
|
653 |
|
654 /** |
|
655 * Show pen UI with priority. |
|
656 */ |
|
657 void Show(const TRect& aRect, TBool aGlobalNotes, |
|
658 TBool aInternal, TInt aPriority, TBool aResource); |
|
659 |
|
660 /** |
|
661 * Called from akncapserver appui to close fastswap. |
|
662 */ |
|
663 void Hide(); |
|
664 |
|
665 public: // Functions from base classes. |
|
666 |
|
667 /** |
|
668 * From CCoeControl |
|
669 * Function where control's drawing is done. |
|
670 * |
|
671 * @param aRect Control's area. |
|
672 */ |
|
673 void Draw( const TRect &aRect ) const; |
|
674 protected: |
|
675 void CreateBitmapL(TInt aBmpHandle); |
|
676 private: // Data |
|
677 |
|
678 RWindowGroup& iWndGroup; |
|
679 CFbsBitmap * iBitmap; |
|
680 CFbsBitmap *iBitmapCpoy; |
|
681 TInt iBmpHandle; |
|
682 }; |
|
683 |
|
684 //end of class RPeninputServerImpl |
|
685 #endif //R_RPENINPUTSERVER_IMPL_H |
|
686 |
|
687 // End of File |