|
1 /* |
|
2 * Copyright (c) 2005-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: Implementation for peninput client |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "peninputclientserver.h" |
|
21 #include "peninputclientimpl.h" |
|
22 #include "peninputcmd.h" |
|
23 #include "peninputsrvobserver.h" |
|
24 #include <apgtask.h> |
|
25 #include <w32std.h> |
|
26 #include <apacmdln.h> |
|
27 #include <apgcli.h> |
|
28 #include <s32mem.h> |
|
29 #include <coemain.h> |
|
30 #include <apgwgnam.h> |
|
31 #include "peninputclient.h" |
|
32 const TUint KDefaultMessageSlots = 4; |
|
33 |
|
34 const TInt KMaxSupportLanguages = 100; |
|
35 const TInt KMaxImeImplementations = 10; |
|
36 const TUid KSingletonClientId = |
|
37 { |
|
38 0x10281854 |
|
39 }; |
|
40 |
|
41 |
|
42 TUid GetAppUidByWndGroupIdL( RWsSession &aWs, TInt aWndGroupId ) |
|
43 { |
|
44 CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(aWs,aWndGroupId); |
|
45 TUid id = wg->AppUid(); |
|
46 CleanupStack::PopAndDestroy(wg); |
|
47 return id; |
|
48 } |
|
49 TUid AppUidFromWndGroupIdL(TInt aWndGrpId) |
|
50 { |
|
51 RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
52 //TInt wgId =ws.GetFocusWindowGroup(); |
|
53 CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(ws,aWndGrpId); |
|
54 |
|
55 TUid id = wg->AppUid(); |
|
56 CleanupStack::PopAndDestroy(wg); |
|
57 return id; |
|
58 |
|
59 } |
|
60 TUid AppUidFromWndGroupId(TInt aWndGrpId) |
|
61 { |
|
62 TUid id = {0x00000000}; |
|
63 TRAP_IGNORE(id = AppUidFromWndGroupIdL(aWndGrpId)); |
|
64 return id; |
|
65 } |
|
66 |
|
67 inline TUid GetFocusAppUid() |
|
68 { |
|
69 return AppUidFromWndGroupId(CCoeEnv::Static()->WsSession().GetFocusWindowGroup()); |
|
70 } |
|
71 TUid GetCurAppUid() |
|
72 { |
|
73 return AppUidFromWndGroupId(CCoeEnv::Static()->RootWin().Identifier()); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 CPeninputServerWaiter* CPeninputServerWaiter::NewL() |
|
79 { |
|
80 CPeninputServerWaiter* self = new(ELeave)CPeninputServerWaiter; |
|
81 CleanupStack::PushL(self); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop(self); |
|
84 return self; |
|
85 } |
|
86 void CPeninputServerWaiter::ConstructL() |
|
87 { |
|
88 iWaitScheduler = new(ELeave) CActiveSchedulerWait; |
|
89 } |
|
90 |
|
91 CPeninputServerWaiter::~CPeninputServerWaiter() |
|
92 { |
|
93 delete iWaitScheduler; |
|
94 } |
|
95 |
|
96 void CPeninputServerWaiter::Start() |
|
97 { |
|
98 iWaitScheduler->Start(); |
|
99 } |
|
100 |
|
101 void CPeninputServerWaiter::Stop(TInt aFlag) |
|
102 { |
|
103 //if(aFlag) |
|
104 iError = aFlag ? KErrNone : aFlag; |
|
105 |
|
106 iWaitScheduler->AsyncStop(); |
|
107 } |
|
108 |
|
109 |
|
110 |
|
111 // ======== MEMBER FUNCTIONS ======== |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // RPeninputServerImpl::NewL |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 RPeninputServerImpl* RPeninputServerImpl::NewL(TRequestStatus* aStatus) |
|
118 { |
|
119 //check for singleton existence |
|
120 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
121 CPenInputSingletonClient* client = |
|
122 static_cast<CPenInputSingletonClient*>(obj); |
|
123 if(client && client->IsValid()) |
|
124 { |
|
125 RPeninputServerImpl* server = client->GetSingletonServer(); |
|
126 TInt err = server->ServerReady() ? KErrNone : KErrLaunchingServer; |
|
127 User::RequestComplete(aStatus,err); |
|
128 return server; |
|
129 } |
|
130 |
|
131 RPeninputServerImpl* self = new(ELeave) RPeninputServerImpl(); |
|
132 CleanupStack::PushL(self); |
|
133 self->ConstructL(KSingletonClientId,aStatus); |
|
134 CleanupStack::Pop(self); |
|
135 return self; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // RPeninputServerImpl::RPeninputServerImpl |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 RPeninputServerImpl::RPeninputServerImpl() : iPosition(0,0),iSize(0,0) |
|
143 { |
|
144 iObserver = 0; |
|
145 iIsForegroundSession = EFalse; |
|
146 iServerExit = EFalse; |
|
147 iLaunchServer = EFalse; |
|
148 iCurPenUiType = -1; |
|
149 iWaitScheduler = NULL; |
|
150 iAppPrefferedUiMode = EPluginInputModeNone; |
|
151 iAutoOpenFlag = ETrue; |
|
152 iBackgroundCtrl = 0; |
|
153 iResourceChange = EFalse; |
|
154 iWaiterAo = NULL; |
|
155 iPendingRequest = NULL; |
|
156 iServerReady = EFalse; |
|
157 } |
|
158 |
|
159 void RPeninputServerImpl::ConstructL(const TUid& aUid, TRequestStatus* aStatus) |
|
160 { |
|
161 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(aUid); |
|
162 CPenInputSingletonClient* client; |
|
163 //__ASSERT_ALWAYS(obj == NULL, User::Leave(KErrAlreadyExists)); |
|
164 if(obj) |
|
165 { |
|
166 client = static_cast<CPenInputSingletonClient*>(obj); |
|
167 client->ReplaceServer(this); |
|
168 } |
|
169 else |
|
170 client = new (ELeave)CPenInputSingletonClient(aUid,this); |
|
171 //Note: The client is destroyed by the control environment automatically |
|
172 //User::LeaveIfError(DoConnectL()); |
|
173 TRAPD(err, DoConnectL(aStatus)); |
|
174 if(KErrNone != err) |
|
175 { |
|
176 client->SetInvalid(); |
|
177 User::LeaveIfError(err); |
|
178 } |
|
179 } |
|
180 |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // RPeninputServerImpl::DoConnectL |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 /*TInt RPeninputServerImpl::Connect() |
|
187 { |
|
188 //do nothing |
|
189 return KErrNone; |
|
190 } |
|
191 */ |
|
192 // --------------------------------------------------------------------------- |
|
193 // RPeninputServerImpl::Close |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void RPeninputServerImpl::Close() |
|
197 { |
|
198 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
199 CPenInputSingletonClient* client = |
|
200 static_cast<CPenInputSingletonClient*>(obj); |
|
201 if(client) |
|
202 { |
|
203 TInt ref = client->DecreaseRef(); |
|
204 if (ref <= 0) |
|
205 { |
|
206 // delete the CCoeStatic object of CPenInputSingletonClient when |
|
207 // Peninput server was closed. |
|
208 // Basiccaly, all CCoeStatic objects are deleted in CCoeEnv destructor. |
|
209 // However, it is necessary to delete the CCoeStatic object when |
|
210 // changing from avkon fep to other fep. |
|
211 delete client; |
|
212 } |
|
213 } |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // RPeninputServerImpl::DoConnectL |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 TInt RPeninputServerImpl::DoConnectL(TRequestStatus* aStatus) |
|
221 { |
|
222 iPendingRequest = aStatus; |
|
223 TInt error = KErrNone; |
|
224 /*************** Note ************************************************/ |
|
225 // Multi-thread case is not considered here! |
|
226 /*************** Note ************************************************/ |
|
227 |
|
228 // try to connect to the server |
|
229 error = CreateSession( KPeninputServerName, |
|
230 Version(), |
|
231 KDefaultMessageSlots,EIpcSession_Sharable); |
|
232 |
|
233 if( error == KErrNotFound || error == KErrServerTerminated ) |
|
234 { |
|
235 // server does not yet exist or it has terminated |
|
236 // try to create the server |
|
237 |
|
238 if(!aStatus) //sync call |
|
239 { |
|
240 error = StartThreadL(); |
|
241 if(KErrNone == error) |
|
242 { |
|
243 error = CreateSession( KPeninputServerName, |
|
244 Version(), |
|
245 KDefaultMessageSlots,EIpcSession_Sharable); |
|
246 AddObserver(); |
|
247 } |
|
248 |
|
249 } |
|
250 else |
|
251 { |
|
252 StartThreadAsyncL(); |
|
253 return KErrNone; |
|
254 } |
|
255 } |
|
256 else //server alreay there |
|
257 { |
|
258 if(aStatus) |
|
259 OnServerStarted(KErrNone); |
|
260 else |
|
261 AddObserver(); |
|
262 } |
|
263 return error; |
|
264 } |
|
265 |
|
266 void RPeninputServerImpl::AddObserver() |
|
267 { |
|
268 TThreadId srvThreadId; |
|
269 TIpcArgs arg; |
|
270 |
|
271 TPckg<TThreadId> msg(srvThreadId); |
|
272 arg.Set(KMsgSlot0,&msg); |
|
273 SendReceive(EPeninputRequestServerThreadId,arg); |
|
274 |
|
275 iServerExit = EFalse; |
|
276 if(iObserver) |
|
277 { |
|
278 iObserver->ReConstructL(srvThreadId); |
|
279 } |
|
280 else |
|
281 { |
|
282 iObserver = CPeninputServerObserver::NewL(this,srvThreadId); |
|
283 } |
|
284 } |
|
285 |
|
286 TBool RPeninputServerImpl::ServerReady() |
|
287 { |
|
288 return iServerReady; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // RPeninputServerImpl::Version |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 TVersion RPeninputServerImpl::Version(void) const |
|
296 { |
|
297 return( TVersion( KPeninputServerMajorVersionNumber, |
|
298 KPeninputServerMinorVersionNumber, |
|
299 KPeninputServerBuildVersionNumber ) ); |
|
300 } |
|
301 |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // RPeninputServerImpl::RequestMessageNotification |
|
305 // Register to require message notification |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 |
|
309 void RPeninputServerImpl::RequestMessageNotification( TRequestStatus& aStatus ) |
|
310 { |
|
311 TInt data=0; |
|
312 SendReceive( EPeninputServerRequestMessageNotification, TIpcArgs(data), aStatus ); |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // RPeninputServerImpl::CancelMessageNotification |
|
317 // Cancel message notification |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 void RPeninputServerImpl::CancelMessageNotification() |
|
321 { |
|
322 SendReceive( EPeninputServerCancelMessageNotification); |
|
323 } |
|
324 |
|
325 |
|
326 void RPeninputServerImpl::DimUiLayout(TBool aFlag) |
|
327 { |
|
328 TRAP_IGNORE(DimUiLayoutL(aFlag)); |
|
329 } |
|
330 |
|
331 void RPeninputServerImpl::DimUiLayoutL(TBool aFlag) |
|
332 { |
|
333 TInt priority = iPriority; |
|
334 |
|
335 TPckgC<TBool> msg(aFlag); |
|
336 TIpcArgs arg; |
|
337 arg.Set(KMsgSlot0,&msg); |
|
338 |
|
339 TPckgC<TInt> prioriryMsg(priority);//p |
|
340 arg.Set(KMsgSlot1,&prioriryMsg); |
|
341 |
|
342 TInt bmpHandle = -1; |
|
343 TPckg<TInt> handleMsg(bmpHandle); |
|
344 arg.Set(KMsgSlot2,&handleMsg); |
|
345 |
|
346 TRect extend; |
|
347 TPckg<TRect> posMsg(extend); |
|
348 arg.Set(KMsgSlot3,&posMsg); |
|
349 |
|
350 if (iInternalPopup) |
|
351 { |
|
352 SendReceive(EPeninputRequestInternalDimLayout,arg); |
|
353 } |
|
354 else |
|
355 { |
|
356 SendReceive(EPeninputRequestDimLayout,arg); |
|
357 } |
|
358 |
|
359 if(aFlag) |
|
360 { |
|
361 //show the background control |
|
362 if(!iBackgroundCtrl) |
|
363 { |
|
364 iBackgroundCtrl = CPenUiBackgroundWnd::NewL(CCoeEnv::Static()->RootWin(),bmpHandle); |
|
365 } |
|
366 if(iBackgroundCtrl) |
|
367 iBackgroundCtrl->Show(extend, iGlobalNotes, |
|
368 iInternalPopup,priority, iResourceChange); |
|
369 } |
|
370 else //undim the window |
|
371 { |
|
372 if(iBackgroundCtrl) |
|
373 iBackgroundCtrl->Hide(); |
|
374 } |
|
375 } |
|
376 // --------------------------------------------------------------------------- |
|
377 // RPeninputServerImpl::ActivateLayout |
|
378 // Activate/Deactivate a ui layout |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void RPeninputServerImpl::ActivateLayout(TBool aFlag) |
|
382 { |
|
383 if(iBackgroundCtrl && iBackgroundCtrl->IsVisible()) |
|
384 iBackgroundCtrl->Hide(); |
|
385 |
|
386 //inform UI activation handler |
|
387 for(TInt i = 0 ; i < iPenUiNotificationHandler.Count(); ++i) |
|
388 { |
|
389 if(iPenUiNotificationHandler[i].iType & iCurPenUiType) |
|
390 { |
|
391 if(aFlag) |
|
392 iPenUiNotificationHandler[i].iHandler->OnPeninputUiActivated(); |
|
393 else |
|
394 iPenUiNotificationHandler[i].iHandler->OnPeninputUiDeactivated(); |
|
395 } |
|
396 } |
|
397 |
|
398 if ( aFlag || ( !aFlag && IsVisible() ) ) |
|
399 { |
|
400 TPckgC<TBool> msg(aFlag); |
|
401 TIpcArgs arg; |
|
402 arg.Set(KMsgSlot0,&msg); |
|
403 |
|
404 TInt scrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode(); |
|
405 TPckgC<TInt> scrMsg(scrMode); |
|
406 arg.Set(KMsgSlot1,&scrMsg); |
|
407 SendReceive(EPeninputRequestActivateLayout,arg); |
|
408 } |
|
409 } |
|
410 |
|
411 void RPeninputServerImpl::ActivatePeninputInNotesL() |
|
412 { |
|
413 SendReceive(EPeninputRequestActivateLayoutInGlobalNotes); |
|
414 } |
|
415 // --------------------------------------------------------------------------- |
|
416 // RPeninputServerImpl::GetServerEventData |
|
417 // Retrieve server event data |
|
418 // --------------------------------------------------------------------------- |
|
419 // |
|
420 TInt RPeninputServerImpl::GetServerEventData(TDes& aBuf) |
|
421 { |
|
422 if(iServerExit) // ??? |
|
423 return -1; |
|
424 |
|
425 TIpcArgs arg; |
|
426 aBuf.Zero(); |
|
427 arg.Set(KMsgSlot0,aBuf.MaxLength()); |
|
428 arg.Set(KMsgSlot1,&aBuf); |
|
429 return SendReceive(EPeninputRequestGetServerEventData,arg); |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // RPeninputServerImpl::ServerEventDfataNum |
|
434 // Get the number of server event |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 TInt RPeninputServerImpl::ServerEventDataNum() |
|
438 { |
|
439 TInt num = -1; |
|
440 TPckg<TInt> msg(num); |
|
441 TIpcArgs arg; |
|
442 arg.Set(KMsgSlot0,&msg); |
|
443 TInt err = SendReceive(EPeninputRequestGetServerEventDataNumber,arg); |
|
444 if(err != KErrNone) |
|
445 num = err;//set the error code |
|
446 return num; |
|
447 |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 // RPeninputServerImpl::ResourceChanged |
|
452 // Tell server the client resource changed |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 void RPeninputServerImpl::ResourceChanged(TInt aType) |
|
456 { |
|
457 TIpcArgs arg; |
|
458 TPckgC<TInt> msg(aType); |
|
459 arg.Set(KMsgSlot0,&msg); |
|
460 |
|
461 SendReceive(EPeninputRequestResourceChanged,arg); |
|
462 } |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // RPeninputServerImpl::SetUiLayoutPos |
|
466 // Set ui layout position |
|
467 // --------------------------------------------------------------------------- |
|
468 // |
|
469 TInt RPeninputServerImpl::SetUiLayoutPos(const TPoint& aPos) |
|
470 { |
|
471 TPckgC<TPoint> msg(aPos); |
|
472 TIpcArgs arg; |
|
473 arg.Set(KMsgSlot0,&msg); |
|
474 return SendReceive(EPeninputRequestUiSetUiPos,arg); |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // RPeninputServerImpl::UiLayoutPos |
|
479 // get ui layout position |
|
480 // --------------------------------------------------------------------------- |
|
481 // |
|
482 void RPeninputServerImpl::GetUiLayoutPosAndSize() |
|
483 { |
|
484 TPckg<TPoint> msgPos(iPosition); |
|
485 TPckg<TSize> msgSize(iSize); |
|
486 |
|
487 TIpcArgs arg; |
|
488 arg.Set(KMsgSlot0,&msgPos); |
|
489 arg.Set(KMsgSlot1,&msgSize); |
|
490 SendReceive(EPeninputRequestUiGetUiPos,arg); |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------------------------- |
|
494 // RPeninputServer::UiLayoutPos |
|
495 // get ui layout position |
|
496 // --------------------------------------------------------------------------- |
|
497 // |
|
498 TPoint RPeninputServerImpl::UiLayoutPos() |
|
499 { |
|
500 GetUiLayoutPosAndSize(); |
|
501 return iPosition; |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // RPeninputServer::UiLayoutSize |
|
506 // get ui layout size |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 TSize RPeninputServerImpl::UiLayoutSize() |
|
510 { |
|
511 GetUiLayoutPosAndSize(); |
|
512 return iSize; |
|
513 } |
|
514 |
|
515 // --------------------------------------------------------------------------- |
|
516 // RPeninputServerImpl::SetUiLayoutId |
|
517 // Create a ui layout |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 TInt RPeninputServerImpl::SetUiLayoutId(TUid aId) |
|
521 { |
|
522 TInt uid = aId.iUid; |
|
523 |
|
524 TPckgC<TInt> msg(uid); |
|
525 TIpcArgs arg; |
|
526 arg.Set(KMsgSlot0,&msg); |
|
527 |
|
528 TPckg<TInt> type(iCurPenUiType); |
|
529 arg.Set(KMsgSlot2,&type); |
|
530 return SendReceive(EPeninputRequestSetUiLayoutId,arg); |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // RPeninputServerImpl::SetUiLayoutId |
|
535 // Create a ui layout |
|
536 // --------------------------------------------------------------------------- |
|
537 // |
|
538 TInt RPeninputServerImpl::SetUiLayoutId(TUid aId,const TDesC8& aData) |
|
539 { |
|
540 TInt uid = aId.iUid; |
|
541 |
|
542 TPckgC<TInt> idMsg(uid); |
|
543 TIpcArgs arg; |
|
544 arg.Set(KMsgSlot0,&idMsg); |
|
545 arg.Set(KMsgSlot1,&aData); |
|
546 |
|
547 TPckg<TInt> type(iCurPenUiType); |
|
548 arg.Set(KMsgSlot2,&type); |
|
549 |
|
550 return SendReceive(EPeninputRequestSetUiLayoutIdWithData,arg); |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 // RPeninputServerImpl::HandleCommand |
|
555 // Ask ui layout handle command |
|
556 // --------------------------------------------------------------------------- |
|
557 // |
|
558 TInt RPeninputServerImpl::HandleCommand(TInt aCmd,const TDesC8& aBuf) |
|
559 { |
|
560 TInt ret; |
|
561 return HandleCommand(aCmd,aBuf,ret); |
|
562 } |
|
563 |
|
564 // --------------------------------------------------------------------------- |
|
565 // RPeninputServerImpl::HandleCommand |
|
566 // Ask ui layout handle command |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 TInt RPeninputServerImpl::HandleCommand(TInt aCmd) |
|
570 { |
|
571 TInt ret; |
|
572 return HandleCommand(aCmd,KNullDesC8,ret); |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // RPeninputServerImpl::HandleCommand |
|
577 // Ask ui layout handle command |
|
578 // --------------------------------------------------------------------------- |
|
579 // |
|
580 TInt RPeninputServerImpl::HandleCommand(TInt aCmd,const TDesC8& aBuf, TInt &aResult) |
|
581 { |
|
582 //if(iSingletonServer != this) |
|
583 // return iSingletonServer->HandleCommand(aCmd,aBuf, aResult); |
|
584 |
|
585 if(!IsForegroundSession()) // not handle non-foregound session command |
|
586 return EFalse; |
|
587 |
|
588 TIpcArgs arg; |
|
589 TPckgC<TInt> cmdMsg(aCmd); |
|
590 arg.Set(KMsgSlot0,&cmdMsg); |
|
591 |
|
592 arg.Set(KMsgSlot1,&aBuf); |
|
593 |
|
594 TPckg<TInt> retMsg(aResult); |
|
595 arg.Set(KMsgSlot2,&retMsg); |
|
596 |
|
597 return SendReceive(EPeninputRequestHandleClientCommand,arg); |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // RPeninputServerImpl::IsVisible |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 TBool RPeninputServerImpl::IsVisible() |
|
605 { |
|
606 TBool bVisible; |
|
607 TIpcArgs arg; |
|
608 |
|
609 TPckg<TBool> msg(bVisible); |
|
610 arg.Set(KMsgSlot0,&msg); |
|
611 SendReceive(EPeninputRequestUiIsVisible,arg); |
|
612 |
|
613 return bVisible; |
|
614 } |
|
615 |
|
616 // --------------------------------------------------------------------------- |
|
617 // RPeninputServerImpl::IsVisible |
|
618 // --------------------------------------------------------------------------- |
|
619 // |
|
620 TBool RPeninputServerImpl::IsDimmed() |
|
621 { |
|
622 TBool bDimmed; |
|
623 TIpcArgs arg; |
|
624 |
|
625 TPckg<TBool> msg(bDimmed); |
|
626 arg.Set(KMsgSlot0,&msg); |
|
627 SendReceive(EPeninputRequestIsLayoutDimmed,arg); |
|
628 |
|
629 return bDimmed; |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // RPeninputServerImpl::IsDimmed |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 TInt RPeninputServerImpl::SupportInputMode() |
|
637 { |
|
638 TInt supportMode = 0; |
|
639 TIpcArgs arg; |
|
640 |
|
641 TPckg<TInt> msg(supportMode); |
|
642 arg.Set(KMsgSlot0,&msg); |
|
643 SendReceive(EPeninputRequestSupportInputMode,arg); |
|
644 |
|
645 return supportMode; |
|
646 } |
|
647 |
|
648 TInt RPeninputServerImpl::SetInputLanguage( TInt aLanguage ) |
|
649 { |
|
650 TIpcArgs arg; |
|
651 TPckgC<TInt> msg(aLanguage); |
|
652 arg.Set(KMsgSlot0,&msg); |
|
653 return SendReceive(EPeninputRequestSetInputLanguage, arg); |
|
654 } |
|
655 |
|
656 void RPeninputServerImpl::BackgroudDefaultOri( TInt aOri ) |
|
657 { |
|
658 TIpcArgs arg; |
|
659 TPckgC<TInt> msg(aOri); |
|
660 arg.Set(KMsgSlot0,&msg); |
|
661 |
|
662 SendReceive(EPeninputBackgroudDefaultOri,arg); |
|
663 } |
|
664 |
|
665 // --------------------------------------------------------------------------- |
|
666 // RPeninputServerImpl::SetAppBackgroundL |
|
667 // Set server running in background |
|
668 // --------------------------------------------------------------------------- |
|
669 // |
|
670 /*void RPeninputServerImpl::SetAppBackgroundL(RProcess& aServer) |
|
671 { |
|
672 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
673 commandLine->SetDocumentNameL(KNullDesC); |
|
674 commandLine->SetExecutableNameL(KPeninputServerExe); |
|
675 //if (aType == EBackgroundApplicationType ) |
|
676 commandLine->SetCommandL( EApaCommandBackground ); |
|
677 |
|
678 commandLine->SetProcessEnvironmentL(aServer); |
|
679 CleanupStack::PopAndDestroy(commandLine); |
|
680 |
|
681 } |
|
682 */ |
|
683 |
|
684 TInt RPeninputServerImpl::StartThreadAsyncL() |
|
685 { |
|
686 //ASSERT_DUBUG(!iWaiterAo) |
|
687 iWaiterAo = new CWaitingServerAo(this); |
|
688 |
|
689 |
|
690 TInt ret = KErrNone; |
|
691 |
|
692 RProcess server; |
|
693 User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC())); |
|
694 |
|
695 |
|
696 server.Rendezvous(iWaiterAo->RequestStatus()); |
|
697 server.Resume(); |
|
698 server.Close(); |
|
699 |
|
700 return ret; |
|
701 } |
|
702 |
|
703 |
|
704 // --------------------------------------------------------------------------- |
|
705 // RPeninputServerImpl::StartThread |
|
706 // Creates the server thread on WINS and server process on MARM. |
|
707 // Access to the thread/process creation is controlled with |
|
708 // a global mutex which allows only one client thread to do |
|
709 // the actual server creation in WINS. In MARM the creation of |
|
710 // new server exits with KErrAlreadyExits if another thread |
|
711 // already created it. |
|
712 // --------------------------------------------------------------------------- |
|
713 // |
|
714 TInt RPeninputServerImpl::StartThreadL() |
|
715 { |
|
716 TInt ret = KErrNone; |
|
717 |
|
718 RProcess server; |
|
719 User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC())); |
|
720 |
|
721 TRequestStatus status; |
|
722 server.Rendezvous(status); |
|
723 server.Resume(); |
|
724 server.Close(); |
|
725 |
|
726 User::WaitForRequest(status); |
|
727 if(ESignalServerReady != status.Int()) |
|
728 ret = KErrGeneral; |
|
729 else |
|
730 iServerReady = ETrue; |
|
731 return ret; |
|
732 } |
|
733 |
|
734 |
|
735 // --------------------------------------------------------------------------- |
|
736 // RPeninputServerImpl::AddPeninputServerObserverL |
|
737 // Add observer |
|
738 // --------------------------------------------------------------------------- |
|
739 // |
|
740 void RPeninputServerImpl::AddPeninputServerObserverL( |
|
741 MPeninputServerEventHandler* aHandler) |
|
742 { |
|
743 //can only set once |
|
744 iObserver->AddEventHandler(aHandler); |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // RPeninputServerImpl::RemovePeninputServerObserver |
|
749 // Remove observer |
|
750 // --------------------------------------------------------------------------- |
|
751 // |
|
752 void RPeninputServerImpl::RemovePeninputServerObserver() |
|
753 { |
|
754 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
755 if ( !obj ) |
|
756 { |
|
757 return; |
|
758 } |
|
759 delete iObserver; |
|
760 iObserver = NULL; |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // RPeninputServerImpl::RemovePeninputServerObserver |
|
765 // Remove observer |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 void RPeninputServerImpl::RemovePeninputServerObserver( |
|
769 MPeninputServerEventHandler* /*aHandler*/) |
|
770 { |
|
771 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
772 if ( !obj ) |
|
773 { |
|
774 return; |
|
775 } |
|
776 delete iObserver; |
|
777 iObserver = NULL; |
|
778 } |
|
779 |
|
780 // --------------------------------------------------------------------------- |
|
781 // RPeninputServerImpl::SetDisplayMode |
|
782 // Set the display mode |
|
783 // --------------------------------------------------------------------------- |
|
784 // |
|
785 void RPeninputServerImpl::SetDisplayMode(TDisplayMode aDisplayMode, |
|
786 TDisplayMode aMaskDisplayMode) |
|
787 { |
|
788 TPckgC<TDisplayMode> msg(aDisplayMode); |
|
789 TPckgC<TDisplayMode> msg2(aMaskDisplayMode); |
|
790 |
|
791 TIpcArgs arg; |
|
792 arg.Set(KMsgSlot0,&msg); |
|
793 arg.Set(KMsgSlot1,&msg2); |
|
794 |
|
795 SendReceive( EPeninputServerRequestSetDisplayMode, arg); |
|
796 } |
|
797 |
|
798 |
|
799 // --------------------------------------------------------------------------- |
|
800 // RPeninputServerImpl::ClearServerEvent |
|
801 // Set the display mode |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 void RPeninputServerImpl::ClearServerEvent() |
|
805 { |
|
806 |
|
807 if(iObserver->IsActive()) |
|
808 { |
|
809 TInt data=0; |
|
810 SendReceive(EPeninputServerClearServerEvent, TIpcArgs(data) ); |
|
811 } |
|
812 } |
|
813 |
|
814 // --------------------------------------------------------------------------- |
|
815 // RPeninputServerImpl::AfterUiNotification |
|
816 // Tell server Ui notification has been processed. |
|
817 // --------------------------------------------------------------------------- |
|
818 // |
|
819 /*void RPeninputServerImpl::Continue() |
|
820 { |
|
821 iSingletonServer->SendReceive(EPeninputRequestUiNotificationCompleted); |
|
822 } |
|
823 */ |
|
824 // --------------------------------------------------------------------------- |
|
825 // RPeninputServerImpl::SetDisplayMode |
|
826 // To disable specified layouts at a time. |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 void RPeninputServerImpl::SetDisabledLayout( TInt aLayouts ) |
|
830 { |
|
831 |
|
832 TIpcArgs arg; |
|
833 arg.Set(KMsgSlot0,aLayouts); |
|
834 |
|
835 SendReceive( EPeninputRequestDisableLayout, arg ); |
|
836 } |
|
837 |
|
838 // --------------------------------------------------------------------------- |
|
839 // RPeninputServerImpl::SetDisplayMode |
|
840 // To disable specified layouts at a time. |
|
841 // --------------------------------------------------------------------------- |
|
842 // |
|
843 TInt RPeninputServerImpl::DisabledLayout() |
|
844 { |
|
845 TInt layouts = 0; |
|
846 TIpcArgs arg; |
|
847 |
|
848 TPckg<TInt> msg(layouts); |
|
849 arg.Set(KMsgSlot0,&msg); |
|
850 |
|
851 SendReceive( EPeninputRequestGetDisableLayout, arg ); |
|
852 return layouts; |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // RPeninputServerImpl::GetImePluginIdListL |
|
857 // Get IME plugin list for a language |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 void RPeninputServerImpl::GetImePluginIdListL(TInt aLanguage, |
|
861 TInt aPluginMode, |
|
862 RArray<TInt>& aImplmentationIds) |
|
863 { |
|
864 TInt size = sizeof(TInt) * (KMaxImeImplementations + 1); |
|
865 HBufC8* buf = HBufC8::NewLC(size); |
|
866 TPtr8 bufPtr = buf->Des(); |
|
867 |
|
868 TIpcArgs args; |
|
869 args.Set(KMsgSlot0, aLanguage); |
|
870 args.Set(KMsgSlot1, aPluginMode); |
|
871 args.Set(KMsgSlot2, size); |
|
872 args.Set(KMsgSlot3, &bufPtr); |
|
873 aImplmentationIds.Reset(); |
|
874 TInt err = SendReceive(EPenInputRequestGetImePluginIdList,args); |
|
875 if( err == KErrNone ) |
|
876 { |
|
877 ReadIntArrayFromBufL(*buf, aImplmentationIds); |
|
878 } |
|
879 |
|
880 CleanupStack::PopAndDestroy(buf); |
|
881 } |
|
882 |
|
883 // --------------------------------------------------------------------------- |
|
884 // RPeninputServerImpl::PenSupportLanguagesL |
|
885 // Get pen supported langauge |
|
886 // --------------------------------------------------------------------------- |
|
887 // |
|
888 void RPeninputServerImpl::PenSupportLanguagesL(RArray<TInt>& aLanguageLists) |
|
889 { |
|
890 TInt size = sizeof(TInt) * (KMaxSupportLanguages + 1); |
|
891 HBufC8* buf = HBufC8::NewLC(size); |
|
892 TPtr8 bufPtr = buf->Des(); |
|
893 |
|
894 TIpcArgs args; |
|
895 args.Set(KMsgSlot0, size); |
|
896 args.Set(KMsgSlot1, &bufPtr); |
|
897 aLanguageLists.Reset(); |
|
898 TInt err = SendReceive(EPenInputRequestGetPenSupportLanguages,args); |
|
899 if( err == KErrNone ) |
|
900 { |
|
901 TRAP(err, ReadIntArrayFromBufL(*buf, aLanguageLists)); |
|
902 } |
|
903 |
|
904 CleanupStack::PopAndDestroy(buf); |
|
905 } |
|
906 |
|
907 // --------------------------------------------------------------------------- |
|
908 // RPeninputServerImpl::ReadIntArrayFromBufL |
|
909 // Read buffer |
|
910 // --------------------------------------------------------------------------- |
|
911 // |
|
912 void RPeninputServerImpl::ReadIntArrayFromBufL(const TDesC8& aBuf, RArray<TInt>& aResult) |
|
913 { |
|
914 RDesReadStream readStream; |
|
915 readStream.Open(aBuf); |
|
916 CleanupClosePushL(readStream); |
|
917 const TInt entryCount = readStream.ReadInt32L(); |
|
918 |
|
919 for(TInt i = 0; i < entryCount; ++i) |
|
920 { |
|
921 aResult.AppendL(readStream.ReadInt32L()); |
|
922 } |
|
923 |
|
924 CleanupStack::PopAndDestroy(&readStream); |
|
925 } |
|
926 |
|
927 // --------------------------------------------------------------------------- |
|
928 // RPeninputServerImpl::SetForeground |
|
929 // Set current session to be foreground application session |
|
930 // --------------------------------------------------------------------------- |
|
931 // |
|
932 TBool RPeninputServerImpl::SetForeground(TBool aMustConnectFlag) |
|
933 { |
|
934 // if(iIsForegroundSession) |
|
935 // return ETrue; |
|
936 |
|
937 TInt curAppId; |
|
938 TRAP_IGNORE( curAppId = GetAppUidByWndGroupIdL(CCoeEnv::Static()->WsSession(), |
|
939 CCoeEnv::Static()->RootWin().Identifier()).iUid); |
|
940 TIpcArgs arg; |
|
941 TPckgC<TInt> idData(curAppId); |
|
942 arg.Set(KMsgSlot0,&idData); |
|
943 |
|
944 TPckgC<TBool> flagMsg(aMustConnectFlag); |
|
945 arg.Set(KMsgSlot1,&flagMsg); |
|
946 |
|
947 TPckg<TInt> retMsg(iIsForegroundSession); |
|
948 arg.Set(KMsgSlot2,&retMsg); |
|
949 |
|
950 SendReceive(EPeninputRequestSetForeground,arg); |
|
951 return iIsForegroundSession; |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------------------------- |
|
955 // RPeninputServerImpl::LoseForeground |
|
956 // Indicates current client lost foreground |
|
957 // --------------------------------------------------------------------------- |
|
958 // |
|
959 void RPeninputServerImpl::LoseForeground() |
|
960 { |
|
961 iIsForegroundSession = EFalse; |
|
962 SendReceive(EPeninputRequestRelinquishForeground); |
|
963 } |
|
964 |
|
965 // --------------------------------------------------------------------------- |
|
966 // RPeninputServerImpl::IsForeground |
|
967 // Test whether this session is the forground application session |
|
968 // --------------------------------------------------------------------------- |
|
969 // |
|
970 TBool RPeninputServerImpl::IsForeground() |
|
971 { |
|
972 TBool bIsForeground; |
|
973 TIpcArgs arg; |
|
974 |
|
975 TPckg<TBool> msg(bIsForeground); |
|
976 arg.Set(KMsgSlot0,&msg); |
|
977 SendReceive(EPeninputRequestIsForeground,arg); |
|
978 //__ASSERT_DEBUG(bIsForeground == iIsForegroundSession,User::Leave(-1)); |
|
979 return bIsForeground; |
|
980 |
|
981 } |
|
982 |
|
983 /*void RPeninputServerImpl::DoAddPenUiActivationHandler() |
|
984 { |
|
985 TPckgC<TInt> msg(iPenUiNotificationHandler->RegisteredType()); |
|
986 TIpcArgs arg; |
|
987 arg.Set(KMsgSlot0,&msg); |
|
988 |
|
989 iSingletonServer->SendReceive(EPeninputRequestAddUiObserver,arg); |
|
990 |
|
991 } |
|
992 */ |
|
993 void RPeninputServerImpl::OnServerReady( TBool aFlag) |
|
994 { |
|
995 //iLaunchServer = EFalse; |
|
996 |
|
997 iWaitScheduler->Stop(aFlag);//AsyncStop(); |
|
998 //if(iPenUiNotificationHandler) |
|
999 // DoAddPenUiActivationHandler(); |
|
1000 } |
|
1001 // --------------------------------------------------------------------------- |
|
1002 // RPeninputServerImpl::AddPenUiActivationHandler |
|
1003 // Add an UI activate/deactivation handler |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // |
|
1006 TInt RPeninputServerImpl::AddPenUiActivationHandler( |
|
1007 MPenUiActivationHandler* aHandler,TInt aType) |
|
1008 { |
|
1009 iPenUiNotificationHandler.Append(TUiNotificationHandler(aHandler,aType)); |
|
1010 return KErrNone; |
|
1011 } |
|
1012 |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // RPeninputServerImpl::RemovePenUiActivationHandler |
|
1015 // Remove all UI activate/deactivation handler |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // |
|
1018 void RPeninputServerImpl::RemovePenUiActivationHandler() |
|
1019 { |
|
1020 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
1021 if ( !obj ) |
|
1022 { |
|
1023 return; |
|
1024 } |
|
1025 iPenUiNotificationHandler.Reset(); |
|
1026 } |
|
1027 |
|
1028 // --------------------------------------------------------------------------- |
|
1029 // RPeninputServerImpl::RemovePenUiActivationHandler |
|
1030 // Remove an UI activate/deactivation handler |
|
1031 // Deprecated API |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 void RPeninputServerImpl::RemovePenUiActivationHandler(MPenUiActivationHandler |
|
1035 *aHandler) |
|
1036 { |
|
1037 CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId); |
|
1038 if ( !obj ) |
|
1039 { |
|
1040 return; |
|
1041 } |
|
1042 for(TInt i = iPenUiNotificationHandler.Count() - 1; i >= 0 ; --i) |
|
1043 { |
|
1044 if(aHandler == iPenUiNotificationHandler[i].iHandler) |
|
1045 { |
|
1046 iPenUiNotificationHandler.Remove(i); |
|
1047 } |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 // --------------------------------------------------------------------------- |
|
1052 // RPeninputServerImpl::UpdateAppInfo |
|
1053 // Update current application information |
|
1054 // --------------------------------------------------------------------------- |
|
1055 // |
|
1056 void RPeninputServerImpl::UpdateAppInfo(const TDesC& aInfo, TPeninputAppInfo aType) |
|
1057 { |
|
1058 TPckgC<TPeninputAppInfo> typeMsg(aType); |
|
1059 TIpcArgs arg; |
|
1060 arg.Set(KMsgSlot0,&typeMsg); |
|
1061 arg.Set(KMsgSlot1,&aInfo); |
|
1062 SendReceive(EPeninputRequestUpdateAppInfo,arg); |
|
1063 } |
|
1064 |
|
1065 void RPeninputServerImpl::HandleServerExit() |
|
1066 { |
|
1067 iServerExit = ETrue; |
|
1068 } |
|
1069 |
|
1070 TBool RPeninputServerImpl::IsForegroundSession() |
|
1071 { |
|
1072 return iIsForegroundSession; |
|
1073 } |
|
1074 |
|
1075 void RPeninputServerImpl::FinalClose() |
|
1076 { |
|
1077 delete iBackgroundCtrl; |
|
1078 |
|
1079 delete iWaitScheduler; |
|
1080 iWaitScheduler = 0; |
|
1081 iPenUiNotificationHandler.Close(); |
|
1082 delete iObserver; |
|
1083 iObserver = NULL; |
|
1084 |
|
1085 if ( iWaiterAo ) |
|
1086 { |
|
1087 iWaiterAo->Cancel(); |
|
1088 delete iWaiterAo; |
|
1089 iWaiterAo = NULL; |
|
1090 } |
|
1091 |
|
1092 RSessionBase::Close(); |
|
1093 } |
|
1094 |
|
1095 |
|
1096 // --------------------------------------------------------------------------- |
|
1097 // RPeninputServerImpl::SetAutoOpen |
|
1098 // Enable/disable the auto-open feature |
|
1099 // --------------------------------------------------------------------------- |
|
1100 // |
|
1101 void RPeninputServerImpl::SetAutoOpen(TBool aFlag) |
|
1102 { |
|
1103 iAutoOpenFlag = aFlag; |
|
1104 } |
|
1105 |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // RPeninputServerImpl::AutoOpen |
|
1108 // get the the auto-open feature flag |
|
1109 // --------------------------------------------------------------------------- |
|
1110 // |
|
1111 TBool RPeninputServerImpl::AutoOpen() |
|
1112 { |
|
1113 return iAutoOpenFlag; |
|
1114 } |
|
1115 |
|
1116 |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // RPeninputServerImpl::SetPrefferredUiMode |
|
1119 // Set the app preferred pen ui mode. |
|
1120 // --------------------------------------------------------------------------- |
|
1121 // |
|
1122 void RPeninputServerImpl::SetPreferredUiMode(TPluginInputMode aMode) |
|
1123 { |
|
1124 iAppPrefferedUiMode = aMode; |
|
1125 } |
|
1126 |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // RPeninputServerImpl::PrefferredUiMode |
|
1129 // Get the app preferred pen ui mode. |
|
1130 // --------------------------------------------------------------------------- |
|
1131 // |
|
1132 TPluginInputMode RPeninputServerImpl::PreferredUiMode() |
|
1133 { |
|
1134 return iAppPrefferedUiMode; |
|
1135 } |
|
1136 |
|
1137 void RPeninputServerImpl::SetGlobalNotes(TBool aFlag) |
|
1138 { |
|
1139 iGlobalNotes = aFlag; |
|
1140 } |
|
1141 |
|
1142 void RPeninputServerImpl::SetInternalPopUp(TBool aFlag) |
|
1143 { |
|
1144 iInternalPopup = aFlag; |
|
1145 } |
|
1146 |
|
1147 void RPeninputServerImpl::SetEditorPriority(TInt aFlag) |
|
1148 { |
|
1149 iPriority = aFlag; |
|
1150 } |
|
1151 |
|
1152 void RPeninputServerImpl::ClearTouchUI() |
|
1153 { |
|
1154 if(iBackgroundCtrl) |
|
1155 { |
|
1156 iBackgroundCtrl->Hide(); |
|
1157 iBackgroundCtrl->MakeVisible(EFalse); |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 void RPeninputServerImpl::SetResourceChange(TBool aFlag) |
|
1162 { |
|
1163 iResourceChange = aFlag; |
|
1164 |
|
1165 |
|
1166 TBool bChange = aFlag; |
|
1167 TIpcArgs arg; |
|
1168 |
|
1169 TPckg<TBool> msg(bChange); |
|
1170 arg.Set(KMsgSlot0,&msg); |
|
1171 SendReceive(EPeninputRequestDimResChangeLayout,arg); |
|
1172 } |
|
1173 |
|
1174 //end of class RPeninputServerImpl |
|
1175 |
|
1176 |
|
1177 // Class CPeninputServerObserver |
|
1178 |
|
1179 CPeninputServerObserver* CPeninputServerObserver::NewL( |
|
1180 RPeninputServerImpl* aServer, |
|
1181 TThreadId aSrvThreadId) |
|
1182 { |
|
1183 CPeninputServerObserver* self = new(ELeave) CPeninputServerObserver(aServer, |
|
1184 aSrvThreadId); |
|
1185 CleanupStack::PushL(self); |
|
1186 self->ConstructL(); |
|
1187 CleanupStack::Pop(); |
|
1188 return self; |
|
1189 } |
|
1190 // --------------------------------------------------------------------------- |
|
1191 // CPeninputServerObserver::CPeninputServerObserver |
|
1192 // Constructor. Adds the active object to the active scheduler |
|
1193 // and issues a request for server notification. |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // |
|
1196 CPeninputServerObserver::CPeninputServerObserver( |
|
1197 RPeninputServerImpl* aPeninputServer, |
|
1198 TThreadId aSrvThreadId) |
|
1199 :CActive( EPriorityHigh ), |
|
1200 iPeninputServer( aPeninputServer ), |
|
1201 iSrvThreadId(aSrvThreadId), |
|
1202 iServerExit(EFalse) |
|
1203 { |
|
1204 __ASSERT_ALWAYS( !IsActive(), User::Panic( KPeninputServerName, |
|
1205 KErrObserverAlreadyActive ) ); |
|
1206 //__ASSERT_DEBUG(aHandler, User::Panic( KPeninputServerName, |
|
1207 // KErrObserverNoHandler )); |
|
1208 |
|
1209 AddEventHandler(this); //set own as the dummy handler |
|
1210 /*if(aPrevObserver) |
|
1211 { |
|
1212 iHandler = aPrevObserver->iHandler; |
|
1213 iUiActivationHandler = aPrevObserver->iUiActivationHandler; |
|
1214 }*/ |
|
1215 // issue asynchronous request and set this object active |
|
1216 CActiveScheduler::Add( this ); |
|
1217 } |
|
1218 |
|
1219 void CPeninputServerObserver::ConstructL() |
|
1220 { |
|
1221 if(iPeninputServer->Handle() > 0) //valid one |
|
1222 iPeninputServer->RequestMessageNotification(iStatus); |
|
1223 SetActive(); |
|
1224 } |
|
1225 |
|
1226 void CPeninputServerObserver::ReConstructL(TThreadId aId) |
|
1227 { |
|
1228 iSrvThreadId = aId; |
|
1229 if(IsActive()) |
|
1230 { |
|
1231 Cancel(); |
|
1232 } |
|
1233 ConstructL(); |
|
1234 } |
|
1235 // --------------------------------------------------------------------------- |
|
1236 // CPeninputServerObserver::~CPeninputServerObserver |
|
1237 // Destructor. Cancels any outstanding requests |
|
1238 // --------------------------------------------------------------------------- |
|
1239 // |
|
1240 CPeninputServerObserver::~CPeninputServerObserver() |
|
1241 { |
|
1242 Cancel(); |
|
1243 } |
|
1244 |
|
1245 // --------------------------------------------------------------------------- |
|
1246 // CPeninputServerObserver::DoCancel |
|
1247 // Cancels the notification requests |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // |
|
1250 void CPeninputServerObserver::DoCancel() |
|
1251 { |
|
1252 if(!iServerExit) |
|
1253 iPeninputServer->CancelMessageNotification(); |
|
1254 } |
|
1255 |
|
1256 |
|
1257 // --------------------------------------------------------------------------- |
|
1258 // CPeninputServerObserver::RunL |
|
1259 // --------------------------------------------------------------------------- |
|
1260 // |
|
1261 void CPeninputServerObserver::RunL() |
|
1262 { |
|
1263 |
|
1264 //iHandler is always there. No need to check it |
|
1265 TInt ret = EFalse; |
|
1266 |
|
1267 if(iStatus.Int() < 0) |
|
1268 { |
|
1269 //check server status |
|
1270 RThread srvThread; |
|
1271 TInt err = srvThread.Open(iSrvThreadId); |
|
1272 TInt exitReason = 0; |
|
1273 if(err == KErrNone) //thread is just closed |
|
1274 { |
|
1275 exitReason = srvThread.ExitReason(); |
|
1276 srvThread.Close(); |
|
1277 iPeninputServer->OnServerReady(-1000); |
|
1278 } |
|
1279 if(err != KErrNone || exitReason != 0) //server has exited |
|
1280 { |
|
1281 iServerExit = ETrue; |
|
1282 iPeninputServer->HandleServerExit(); |
|
1283 iHandler->HandleServerEventL(ESignalServerExit); |
|
1284 return; |
|
1285 } |
|
1286 } |
|
1287 |
|
1288 if(iStatus.Int() == ESignalServerReady) //server has started |
|
1289 { |
|
1290 iPeninputServer->OnServerReady(); |
|
1291 return; |
|
1292 } |
|
1293 //if there is also iUiActivationHandler, handle it first |
|
1294 if(iUiActivationHandler) |
|
1295 ret = iUiActivationHandler->HandleServerEventL(iStatus.Int()); |
|
1296 |
|
1297 if(!ret) |
|
1298 ret = iHandler->HandleServerEventL(iStatus.Int()); |
|
1299 // re-issue request if request |
|
1300 if(ret) |
|
1301 { |
|
1302 iPeninputServer->RequestMessageNotification(iStatus); |
|
1303 SetActive(); |
|
1304 } |
|
1305 } |
|
1306 |
|
1307 // --------------------------------------------------------------------------- |
|
1308 // CPeninputServerObserver::RunError |
|
1309 // --------------------------------------------------------------------------- |
|
1310 // |
|
1311 TInt CPeninputServerObserver::RunError(TInt /*aError*/) |
|
1312 { |
|
1313 // re-issue request |
|
1314 iPeninputServer->RequestMessageNotification(iStatus); |
|
1315 SetActive(); |
|
1316 |
|
1317 return KErrNone; |
|
1318 } |
|
1319 |
|
1320 void CPeninputServerObserver::AddEventHandler(MPeninputServerEventHandler* aHandler) |
|
1321 { |
|
1322 // if(iHandler) |
|
1323 // return; |
|
1324 iHandler = aHandler; |
|
1325 } |
|
1326 |
|
1327 void CPeninputServerObserver::AddUiActivationHandler(MPeninputServerEventHandler* aHandler) |
|
1328 { |
|
1329 iUiActivationHandler = aHandler; |
|
1330 } |
|
1331 |
|
1332 TBool CPeninputServerObserver::HandleServerEventL(TInt /*aEventId*/) |
|
1333 { |
|
1334 //consume all events |
|
1335 return ETrue; |
|
1336 } |
|
1337 |
|
1338 |
|
1339 TUiNotificationHandler::TUiNotificationHandler( |
|
1340 MPenUiActivationHandler* aHandler,TInt aType) |
|
1341 :iHandler(aHandler),iType(aType) |
|
1342 { |
|
1343 } |
|
1344 |
|
1345 //class CPenInputSingletonClient |
|
1346 CPenInputSingletonClient::CPenInputSingletonClient(const TUid& aUid, |
|
1347 RPeninputServerImpl* aServer) |
|
1348 : CCoeStatic(aUid,EApp), |
|
1349 iServer(aServer),iReferrence(1),iIsValid(ETrue) |
|
1350 { |
|
1351 } |
|
1352 |
|
1353 RPeninputServerImpl* CPenInputSingletonClient::GetSingletonServer() |
|
1354 { |
|
1355 RPeninputServerImpl* ret = 0; |
|
1356 if(iIsValid && iServer->Handle()) |
|
1357 { |
|
1358 ++iReferrence; |
|
1359 ret = iServer; |
|
1360 } |
|
1361 return ret; |
|
1362 } |
|
1363 |
|
1364 TInt CPenInputSingletonClient::DecreaseRef() |
|
1365 { |
|
1366 --iReferrence; |
|
1367 if( 0 == iReferrence && iIsValid) |
|
1368 { |
|
1369 iServer->FinalClose(); |
|
1370 delete iServer; |
|
1371 iServer = 0; |
|
1372 iIsValid = EFalse; |
|
1373 } |
|
1374 return iReferrence; |
|
1375 } |
|
1376 |
|
1377 TBool CPenInputSingletonClient::IsValid() |
|
1378 { |
|
1379 return iIsValid; |
|
1380 } |
|
1381 |
|
1382 void CPenInputSingletonClient::SetInvalid() |
|
1383 { |
|
1384 iIsValid = EFalse; |
|
1385 } |
|
1386 |
|
1387 void CPenInputSingletonClient::ReplaceServer(RPeninputServerImpl* aServer) |
|
1388 { |
|
1389 iServer = aServer; |
|
1390 iIsValid = ETrue; |
|
1391 iReferrence = 1; |
|
1392 } |
|
1393 |
|
1394 CPenInputSingletonClient::~CPenInputSingletonClient() |
|
1395 { |
|
1396 if ( iServer ) |
|
1397 { |
|
1398 iServer->FinalClose(); |
|
1399 delete iServer; |
|
1400 } |
|
1401 } |
|
1402 |
|
1403 //for class background wnd |
|
1404 |
|
1405 TBool IsGlobalNotesApp(TUid& aUid) |
|
1406 { |
|
1407 const TInt KAknCapServerUid = 0x10207218; |
|
1408 const TInt KAknNotifySrvUid = 0x10281EF2; |
|
1409 |
|
1410 if(aUid.iUid == KAknCapServerUid || aUid.iUid == KAknNotifySrvUid) |
|
1411 return ETrue; |
|
1412 return EFalse; |
|
1413 } |
|
1414 |
|
1415 |
|
1416 CPenUiBackgroundWnd* CPenUiBackgroundWnd::NewL(RWindowGroup& aWndGroup,TInt aBmpHandle) |
|
1417 { |
|
1418 CPenUiBackgroundWnd* self = new(ELeave) CPenUiBackgroundWnd(aWndGroup); |
|
1419 CleanupStack::PushL(self); |
|
1420 self->ConstructL(aBmpHandle); |
|
1421 CleanupStack::Pop(self); |
|
1422 return self; |
|
1423 } |
|
1424 |
|
1425 CPenUiBackgroundWnd::CPenUiBackgroundWnd(RWindowGroup& aWndGroup) |
|
1426 :iWndGroup(aWndGroup) |
|
1427 { |
|
1428 } |
|
1429 |
|
1430 CPenUiBackgroundWnd::~CPenUiBackgroundWnd() |
|
1431 { |
|
1432 delete iBitmap; |
|
1433 |
|
1434 // if (iBitmapCpoy) |
|
1435 { |
|
1436 // delete iBitmapCpoy; |
|
1437 // iBitmapCpoy = NULL; |
|
1438 } |
|
1439 } |
|
1440 |
|
1441 void CPenUiBackgroundWnd::CreateBitmapL(TInt aBmpHandle) |
|
1442 { |
|
1443 iBitmap = new (ELeave) CFbsBitmap; |
|
1444 TInt ret = iBitmap->Duplicate(aBmpHandle); |
|
1445 |
|
1446 if(KErrNone != ret) |
|
1447 { |
|
1448 delete iBitmap; |
|
1449 iBitmap = NULL; |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 void CPenUiBackgroundWnd::ConstructL(TInt aBmpHandle) |
|
1454 { |
|
1455 CreateWindowL(iWndGroup); |
|
1456 SetComponentsToInheritVisibility(); |
|
1457 |
|
1458 Window().SetRequiredDisplayMode( EColor16MA ); |
|
1459 MakeVisible( EFalse ); |
|
1460 CreateBitmapL(aBmpHandle); |
|
1461 TBool b = IsNonFocusing(); |
|
1462 SetFocusing(EFalse); |
|
1463 } |
|
1464 |
|
1465 void CPenUiBackgroundWnd::Show(const TRect& aExtend, TBool aGlobalNotes, |
|
1466 TBool aInternal, TInt aPriority, TBool aResource) |
|
1467 { |
|
1468 //Show the window will cause a focus group change in global notes showing case. |
|
1469 if (!iBitmap) |
|
1470 { |
|
1471 return; |
|
1472 } |
|
1473 TUid curApp = GetCurAppUid(); |
|
1474 TUid focusApp = GetFocusAppUid(); |
|
1475 //dim effect due to global notes will not done by background control |
|
1476 if(!aInternal || aGlobalNotes) |
|
1477 return; |
|
1478 |
|
1479 // if (iBitmapCpoy) |
|
1480 { |
|
1481 // delete iBitmapCpoy; |
|
1482 // iBitmapCpoy = NULL; |
|
1483 } |
|
1484 SetRect(aExtend); |
|
1485 TRAP_IGNORE(ActivateL()); |
|
1486 MakeVisible(ETrue); |
|
1487 if (!aResource) |
|
1488 { |
|
1489 RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
1490 TInt wgId =ws.GetFocusWindowGroup(); |
|
1491 TInt priority = ws.GetWindowGroupOrdinalPriority(wgId); |
|
1492 |
|
1493 iWndGroup.SetOrdinalPosition( 0, aPriority); |
|
1494 |
|
1495 Window().SetOrdinalPosition(0,aPriority); |
|
1496 |
|
1497 Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); |
|
1498 } |
|
1499 else |
|
1500 { |
|
1501 Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); |
|
1502 } |
|
1503 |
|
1504 Window().Invalidate(); |
|
1505 DrawNow(); |
|
1506 } |
|
1507 |
|
1508 void CPenUiBackgroundWnd::Draw(const TRect& aRect) const |
|
1509 { |
|
1510 CWindowGc& gc = SystemGc(); |
|
1511 |
|
1512 // if (iBitmapCpoy) |
|
1513 // gc.BitBlt(aRect.iTl,iBitmapCpoy,aRect); |
|
1514 if (iBitmap) |
|
1515 gc.BitBlt(aRect.iTl,iBitmap,aRect); |
|
1516 |
|
1517 } |
|
1518 |
|
1519 void CPenUiBackgroundWnd::Hide() |
|
1520 { |
|
1521 MakeVisible( EFalse ); |
|
1522 } |
|
1523 |
|
1524 |
|
1525 void RPeninputServerImpl::OnServerStarted(TInt aErr) |
|
1526 { |
|
1527 if(KErrNone == aErr) |
|
1528 { |
|
1529 iServerReady = ETrue; |
|
1530 } |
|
1531 |
|
1532 //create session |
|
1533 |
|
1534 TInt error = CreateSession( KPeninputServerName, |
|
1535 Version(), |
|
1536 KDefaultMessageSlots,EIpcSession_Sharable); |
|
1537 |
|
1538 if(KErrNone == error) |
|
1539 AddObserver(); |
|
1540 |
|
1541 User::RequestComplete(iPendingRequest, aErr); |
|
1542 } |
|
1543 |
|
1544 CWaitingServerAo::CWaitingServerAo(RPeninputServerImpl* aClient) |
|
1545 : CActive(CActive::EPriorityStandard), |
|
1546 iClient(aClient) |
|
1547 { |
|
1548 CActiveScheduler::Add(this); |
|
1549 SetActive(); |
|
1550 iStatus = KRequestPending; |
|
1551 } |
|
1552 |
|
1553 |
|
1554 void CWaitingServerAo::RunL() |
|
1555 { |
|
1556 TInt err = ESignalServerReady == iStatus.Int() ? KErrNone : KErrGeneral; |
|
1557 |
|
1558 iClient->OnServerStarted(err); |
|
1559 } |
|
1560 |
|
1561 void CWaitingServerAo::DoCancel() |
|
1562 { |
|
1563 } |
|
1564 TInt CWaitingServerAo::RunError(TInt /*aError*/) |
|
1565 { |
|
1566 return KErrNone; |
|
1567 } |
|
1568 |
|
1569 TRequestStatus& CWaitingServerAo::RequestStatus() |
|
1570 { |
|
1571 return iStatus; |
|
1572 } |
|
1573 // End of File |
|
1574 |