|
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: Native UI controller. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <bautils.h> |
|
20 #include <e32std.h> |
|
21 #include <e32property.h> |
|
22 #include <coemain.h> |
|
23 #include <avkon.rsg> |
|
24 #include <ecom/ecom.h> |
|
25 #include <ecom/implementationproxy.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <centralrepository.h> |
|
28 #include <activeidle2domainpskeys.h> |
|
29 #include <aipspropertyobserver.h> |
|
30 #include <eikstart.h> |
|
31 #include <AknLayout2ScalableDef.h> |
|
32 #include <avkondomainpskeys.h> |
|
33 #include <AknDlgShut.h> |
|
34 |
|
35 // User includes |
|
36 #include "nativeuicontroller.h" |
|
37 #include "ainativeui.hrh" |
|
38 #include "application.h" |
|
39 #include "appui.h" |
|
40 #include "aiutility.h" |
|
41 #include "aistrparser.h" |
|
42 #include "aidevicestatuscontentmodel.h" |
|
43 #include "aipropertyextension.h" |
|
44 #include "aistatuspanel.h" |
|
45 #include "ainativerenderer.h" |
|
46 #include "aititlepanerenderer.h" |
|
47 #include "ainavipanerenderer.h" |
|
48 #include "aidialogrenderer.h" |
|
49 #include "aisoftkeyrenderer.h" |
|
50 #include "ainotifierrenderer.h" |
|
51 #include "aitoolbarrenderer.h" |
|
52 #include "ainativeuiplugins.h" |
|
53 #include "activeidle2domaincrkeys.h" |
|
54 #include "aistatuspanetouchui.h" |
|
55 #include "ainativeuistrings.h" // string literals |
|
56 #include "aistrcnv.h" |
|
57 #include <aiscutplugindomaincrkeys.h> |
|
58 |
|
59 using namespace AiNativeUiController; |
|
60 |
|
61 // Constants |
|
62 _LIT( KResourceDrive, "Z:" ); |
|
63 _LIT( KResourceFile, "ainativeui.rsc" ); |
|
64 _LIT( KSettingsDummyData, "" ); |
|
65 _LIT( KSettingsIdSeparator, "/" ); |
|
66 _LIT( KSettings, "Settings" ); |
|
67 |
|
68 const TInt KOneSecondInMicroS = 1000*1000; |
|
69 const TInt KAI2CrKeyIncrementBy2 = 2; |
|
70 |
|
71 #define KResourcePath KDC_APP_RESOURCE_DIR |
|
72 |
|
73 const TImplementationProxy KImplementationTable[] = |
|
74 { |
|
75 IMPLEMENTATION_PROXY_ENTRY(KImplementationUidNativeUiController, CNativeUiController::NewL) |
|
76 }; |
|
77 |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CNativeUiController::NewL() |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 CNativeUiController* CNativeUiController::NewL() |
|
84 { |
|
85 CNativeUiController* self = new (ELeave) CNativeUiController; |
|
86 |
|
87 CleanupStack::PushL( self ); |
|
88 |
|
89 // Set Native UI Controller object to TLS for access in static |
|
90 // CNativeUiController::NewApplication |
|
91 User::LeaveIfError( Dll::SetTls( self ) ); |
|
92 CleanupStack::Pop( self ); |
|
93 |
|
94 return self; |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CNativeUiController::Exit() |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CNativeUiController::Exit() |
|
102 { |
|
103 if ( iExitTimer ) |
|
104 { |
|
105 iExitTimer->Cancel(); |
|
106 |
|
107 iExitTimer->Start( 0, KOneSecondInMicroS, |
|
108 TCallBack( ExitTimerCallBack, this ) ); |
|
109 } |
|
110 |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CNativeUiController::ExitTimerCallBack() |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CNativeUiController::ExitTimerCallBack( TAny *aSelf ) |
|
118 { |
|
119 CNativeUiController* self = |
|
120 static_cast<CNativeUiController*>( aSelf ); |
|
121 |
|
122 if ( self ) |
|
123 { |
|
124 self->iExitTimer->Cancel(); |
|
125 self->PrepareToExit(); |
|
126 self->iAppUi->Exit(); |
|
127 } |
|
128 |
|
129 return KErrNone; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // CNativeUiController::~CNativeUiController() |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 CNativeUiController::~CNativeUiController() |
|
137 { |
|
138 iPlugins.Close(); |
|
139 |
|
140 delete iExitTimer; |
|
141 |
|
142 PrepareToExit(); |
|
143 |
|
144 // Reset TLS pointer to this set in NewL |
|
145 Dll::SetTls( NULL ); |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CNativeUiController::PrepareToExit() |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CNativeUiController::PrepareToExit() |
|
153 { |
|
154 iRenderers.ResetAndDestroy(); |
|
155 |
|
156 delete iStatusPanel; |
|
157 iStatusPanel = NULL; |
|
158 |
|
159 Release( iIdleStatusObserver ); |
|
160 iIdleStatusObserver = NULL; |
|
161 |
|
162 Release( iKeylockStatusObserver ); |
|
163 iKeylockStatusObserver = NULL; |
|
164 |
|
165 Release( iExtHsPluginConfChange ); |
|
166 iExtHsPluginConfChange = NULL; |
|
167 |
|
168 //If we are not the |
|
169 if( !iRunningAsMain && iResourceOffset > 0 ) |
|
170 { |
|
171 iCoeEnv->DeleteResourceFile( iResourceOffset ); |
|
172 iResourceOffset = KErrNotFound; |
|
173 } |
|
174 } |
|
175 |
|
176 // ---------------------------------------------------------------------------- |
|
177 // CNativeUiController::CNativeUiController() |
|
178 // ---------------------------------------------------------------------------- |
|
179 // |
|
180 CNativeUiController::CNativeUiController() |
|
181 : iResourceOffset( KErrNotFound ) |
|
182 { |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CNativeUiController::AddRendererL() |
|
187 // ---------------------------------------------------------------------------- |
|
188 // |
|
189 void CNativeUiController::AddRendererL( CAiNativeRenderer* aRenderer ) |
|
190 { |
|
191 User::LeaveIfError( iRenderers.Append( aRenderer ) ); |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // CNativeUiController::RemoveRenderer() |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 TBool CNativeUiController::RemoveRenderer( CAiNativeRenderer *aRenderer, |
|
199 TBool aDelete ) |
|
200 { |
|
201 for ( TInt i = 0; i < iRenderers.Count(); i++ ) |
|
202 { |
|
203 if ( aRenderer == iRenderers[i] ) |
|
204 { |
|
205 if ( aDelete ) |
|
206 { |
|
207 delete aRenderer; |
|
208 } |
|
209 iRenderers.Remove(i); |
|
210 |
|
211 return ETrue; |
|
212 } |
|
213 } |
|
214 |
|
215 return EFalse; |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // CNativeUiController::ExitTimerCallBack() |
|
220 // ---------------------------------------------------------------------------- |
|
221 // |
|
222 void CNativeUiController::DeleteToolbarRenderer() |
|
223 { |
|
224 if ( iToolbarRenderer ) |
|
225 { |
|
226 RemoveRenderer( iToolbarRenderer ); |
|
227 delete iToolbarRenderer; |
|
228 iToolbarRenderer = NULL; |
|
229 } |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CNativeUiController::RecreateToolbarRendererL() |
|
234 // ---------------------------------------------------------------------------- |
|
235 // |
|
236 TBool CNativeUiController::RecreateToolbarRendererL() |
|
237 { |
|
238 TBool created( EFalse ); |
|
239 // Remove the old renderer... |
|
240 DeleteToolbarRenderer(); |
|
241 |
|
242 CAknToolbar* toolbar( iAvkonAppUi->CurrentFixedToolbar() ); |
|
243 // ...and create the new if there is an existing toolbar that |
|
244 // we can use |
|
245 if ( toolbar ) |
|
246 { |
|
247 iToolbarRenderer = CAiToolbarRenderer::NewL( *iFwEventHandler, *toolbar); |
|
248 AddRendererL( iToolbarRenderer ); |
|
249 created = ETrue; |
|
250 } |
|
251 |
|
252 return created; |
|
253 } |
|
254 |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // CNativeUiController::DoPublish() |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 template<class T> |
|
261 TInt CNativeUiController::DoPublish( MAiPropertyExtension& aPlugin, |
|
262 TInt aContent, T& aData, TInt aIndex ) |
|
263 { |
|
264 const TAiPublisherInfo* info( NULL ); |
|
265 |
|
266 TRAP_IGNORE( info = aPlugin.PublisherInfoL() ); |
|
267 |
|
268 if ( !info || info->iNamespace != KNativeUiNamespace ) |
|
269 { |
|
270 return KErrNotSupported; |
|
271 } |
|
272 |
|
273 const TInt count( iRenderers.Count() ); |
|
274 TInt err( KErrNone ); |
|
275 |
|
276 for( TInt i( 0 ); i < count; i++ ) |
|
277 { |
|
278 err = iRenderers[i]->Publish( aPlugin, aContent, aData, aIndex ); |
|
279 |
|
280 if( err == KErrNone ) |
|
281 { |
|
282 //data published |
|
283 return KErrNone; |
|
284 } |
|
285 |
|
286 if( err != KErrNotFound ) |
|
287 { |
|
288 return err; |
|
289 } |
|
290 } |
|
291 |
|
292 return err; |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // CNativeUiController::HandleIdleStateEvent() |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 TInt CNativeUiController::HandleIdleStateEvent( TAny* aPtr ) |
|
300 { |
|
301 CNativeUiController* self = |
|
302 reinterpret_cast< CNativeUiController* >( aPtr ); |
|
303 |
|
304 if( self ) |
|
305 { |
|
306 TInt idleState = EPSAiBackground; |
|
307 self->iIdleStatusObserver->Get( idleState ); |
|
308 |
|
309 const TInt count = self->iRenderers.Count(); |
|
310 |
|
311 if( idleState == EPSAiForeground ) |
|
312 { |
|
313 for( TInt i( 0 ); i < count; i++ ) |
|
314 { |
|
315 TRAP_IGNORE( self->iRenderers[i]->FocusObtainedL() ); |
|
316 } |
|
317 } |
|
318 else |
|
319 { |
|
320 for( TInt j( 0 ); j < count; j++ ) |
|
321 { |
|
322 TRAP_IGNORE( self->iRenderers[j]->FocusLostL() ); |
|
323 } |
|
324 } |
|
325 } |
|
326 |
|
327 return KErrNone; |
|
328 } |
|
329 |
|
330 // ---------------------------------------------------------------------------- |
|
331 // CNativeUiController::HandleKeylockStateEvent() |
|
332 // ---------------------------------------------------------------------------- |
|
333 // |
|
334 TInt CNativeUiController::HandleKeylockStateEvent( TAny* aPtr ) |
|
335 { |
|
336 CNativeUiController* self = |
|
337 reinterpret_cast< CNativeUiController* >( aPtr ); |
|
338 |
|
339 if( self ) |
|
340 { |
|
341 TInt keylockState = EKeyguardNotActive; |
|
342 self->iKeylockStatusObserver->Get( keylockState ); |
|
343 |
|
344 const TInt count = self->iRenderers.Count(); |
|
345 |
|
346 if( keylockState != EKeyguardNotActive ) |
|
347 { |
|
348 TRAP_IGNORE( |
|
349 // Run dialog shutter to shut any open dialogs |
|
350 AknDialogShutter::ShutDialogsL( |
|
351 *static_cast< CEikonEnv* >( CCoeEnv::Static() ) ); |
|
352 |
|
353 TKeyEvent key; |
|
354 key.iCode = 0; |
|
355 key.iModifiers = 0; |
|
356 key.iScanCode = EStdKeyNo; |
|
357 CCoeEnv::Static()->SimulateKeyEventL( key, EEventKey ); |
|
358 ); |
|
359 |
|
360 for( TInt i( 0 ); i < count; i++ ) |
|
361 { |
|
362 TRAP_IGNORE( self->iRenderers[i]->KeylockEnabledL() ); |
|
363 } |
|
364 } |
|
365 else |
|
366 { |
|
367 for( TInt i( 0 ); i < count; i++ ) |
|
368 { |
|
369 TRAP_IGNORE( self->iRenderers[i]->KeylockDisabledL() ); |
|
370 } |
|
371 } |
|
372 } |
|
373 |
|
374 return KErrNone; |
|
375 } |
|
376 |
|
377 // ---------------------------------------------------------------------------- |
|
378 // CNativeUiController::HandlePluginConfChange() |
|
379 // ---------------------------------------------------------------------------- |
|
380 // |
|
381 TInt CNativeUiController::HandlePluginConfChange( TAny* aPtr ) |
|
382 { |
|
383 CNativeUiController* self = |
|
384 reinterpret_cast< CNativeUiController* >( aPtr ); |
|
385 |
|
386 TInt value( 0 ); |
|
387 |
|
388 RProperty::Get( KPSUidAiInformation, |
|
389 KActiveIdleExtHS_PluginConfChange, value ); |
|
390 |
|
391 if( self && value ) |
|
392 { |
|
393 self->iAppUi->ExtHSThemeChanged(); |
|
394 } |
|
395 |
|
396 return KErrNone; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CNativeUiController::LoadUIDefinitionL() |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 void CNativeUiController::LoadUIDefinitionL() |
|
404 { |
|
405 if ( iUiLoaded ) |
|
406 { |
|
407 TInt count( iRenderers.Count() ); |
|
408 |
|
409 for( TInt i( 0 ); i < count; i++ ) |
|
410 { |
|
411 iRenderers[i]->LoadUIDefinitionL(); |
|
412 } |
|
413 return; |
|
414 } |
|
415 |
|
416 if ( !iExitTimer ) |
|
417 { |
|
418 iExitTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
419 } |
|
420 |
|
421 // This method is called upon startup. We'll need to: |
|
422 iRenderers.ResetAndDestroy(); |
|
423 |
|
424 if( !iStatusPanel ) |
|
425 { |
|
426 // 2) Initialize status pane for publishing in general |
|
427 iStatusPanel = CAiStatusPanel::NewL(); |
|
428 } |
|
429 |
|
430 // 3) Create renderers that handle publishing to title pane... |
|
431 AddRendererL( CAiTitlePaneRenderer::NewLC( *iStatusPanel ) ); |
|
432 CleanupStack::Pop();//CAiTitlePaneRenderer |
|
433 |
|
434 // ...navi pane... |
|
435 AddRendererL( CAiNaviPaneRenderer::NewLC( *iStatusPanel ) ); |
|
436 CleanupStack::Pop();//CAiNaviPaneRenderer |
|
437 |
|
438 // ...dialogs and. |
|
439 AddRendererL( CAiDialogRenderer::NewLC() ); |
|
440 CleanupStack::Pop();//CAiDialogRenderer |
|
441 |
|
442 AddRendererL( CAiNotifierRenderer::NewLC() ); |
|
443 CleanupStack::Pop();//CAiNotifierRenderer |
|
444 |
|
445 // ...touch ui. |
|
446 AddRendererL( CAiStatusPaneTouchUi::NewLC( *iStatusPanel, *iFwEventHandler ) ); |
|
447 CleanupStack::Pop();//CAiStatusPaneTouchUi |
|
448 |
|
449 if( iRunningAsMain ) |
|
450 { |
|
451 AddRendererL( CAiSoftKeyRenderer::NewLC() ); |
|
452 CleanupStack::Pop();//CAiSoftKeyRenderer |
|
453 |
|
454 // Toolbar shown only when we are not the main ui controller |
|
455 DeleteToolbarRenderer(); |
|
456 |
|
457 TRAP_IGNORE( |
|
458 iAppUi->StartL(); ) |
|
459 } |
|
460 |
|
461 // We need to load the resource file here if we are not main controller. |
|
462 // If we are the main controller the loading is done in appui |
|
463 // Also the toolbar renderer is loaded here. |
|
464 else |
|
465 { |
|
466 //Load resources file for resource publishing |
|
467 TFullName resourceFile( KResourceDrive ); |
|
468 resourceFile.Append( KResourcePath ); |
|
469 resourceFile.Append( KResourceFile ); |
|
470 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resourceFile ); |
|
471 if( iCoeEnv && iResourceOffset == KErrNotFound ) |
|
472 { |
|
473 iResourceOffset = iCoeEnv->AddResourceFileL( resourceFile ); |
|
474 } |
|
475 // Create the toolbar renderer |
|
476 RecreateToolbarRendererL(); |
|
477 } |
|
478 |
|
479 // 4) Add an observer that informs us about the focus transition changes |
|
480 if( !iIdleStatusObserver ) |
|
481 { |
|
482 iIdleStatusObserver = AiUtility::CreatePSPropertyObserverL( |
|
483 TCallBack( HandleIdleStateEvent, this ), |
|
484 KPSUidAiInformation, |
|
485 KActiveIdleState ); |
|
486 } |
|
487 if( !iKeylockStatusObserver ) |
|
488 { |
|
489 iKeylockStatusObserver = AiUtility::CreatePSPropertyObserverL( |
|
490 TCallBack( HandleKeylockStateEvent, this ), |
|
491 KPSUidAvkonDomain, |
|
492 KAknKeyguardStatus ); |
|
493 } |
|
494 if( !iExtHsPluginConfChange ) |
|
495 { |
|
496 iExtHsPluginConfChange = AiUtility::CreatePSPropertyObserverL( |
|
497 TCallBack( HandlePluginConfChange, this ), |
|
498 KPSUidAiInformation, |
|
499 KActiveIdleExtHS_PluginConfChange ); |
|
500 } |
|
501 |
|
502 iUiLoaded = ETrue; |
|
503 } |
|
504 |
|
505 // ---------------------------------------------------------------------------- |
|
506 // CNativeUiController::GetPluginsL() |
|
507 // ---------------------------------------------------------------------------- |
|
508 // |
|
509 void CNativeUiController::GetPluginsL( RAiPublisherInfoArray& aPlugins ) |
|
510 { |
|
511 iPlugins.Reset(); |
|
512 |
|
513 if( iRunningAsMain ) |
|
514 { |
|
515 TAiPublisherInfo shortcutPublisherInfo; |
|
516 shortcutPublisherInfo.iUid = KShortcutPluginUid; |
|
517 shortcutPublisherInfo.iName.Copy( KShortcutPluginName ); |
|
518 shortcutPublisherInfo.iNamespace.Copy( KNativeUiNamespace ); |
|
519 |
|
520 User::LeaveIfError( iPlugins.Append( shortcutPublisherInfo ) ); |
|
521 |
|
522 TAiPublisherInfo deviceStatusPublisherInfo; |
|
523 deviceStatusPublisherInfo.iUid = KDeviceStatusPluginUid; |
|
524 deviceStatusPublisherInfo.iName.Copy( KDeviceStatusPluginName ); |
|
525 deviceStatusPublisherInfo.iNamespace.Copy( KNativeUiNamespace ); |
|
526 |
|
527 User::LeaveIfError( iPlugins.Append( deviceStatusPublisherInfo ) ); |
|
528 |
|
529 TAiPublisherInfo profilePublisherInfo; |
|
530 profilePublisherInfo.iUid = KProfilePluginUid; |
|
531 profilePublisherInfo.iName.Copy( KProfilePluginName ); |
|
532 profilePublisherInfo.iNamespace.Copy( KNativeUiNamespace ); |
|
533 |
|
534 User::LeaveIfError( iPlugins.Append( profilePublisherInfo ) ); |
|
535 |
|
536 // Copy iPlugins to aPlugins |
|
537 aPlugins.ReserveL( aPlugins.Count() + iPlugins.Count() ); |
|
538 |
|
539 for( TInt i = 0; i < iPlugins.Count(); ++i ) |
|
540 { |
|
541 aPlugins.Append( iPlugins[i] ); |
|
542 } |
|
543 } |
|
544 } |
|
545 |
|
546 // ---------------------------------------------------------------------------- |
|
547 // CNativeUiController::GetSettingsL() |
|
548 // ---------------------------------------------------------------------------- |
|
549 // |
|
550 void CNativeUiController::GetSettingsL( const TAiPublisherInfo& aPubInfo, |
|
551 RAiSettingsItemArray& aSettings ) |
|
552 { |
|
553 if ( aPubInfo.iNamespace != KNativeUiNamespace ) |
|
554 { |
|
555 return; |
|
556 } |
|
557 |
|
558 if( iRunningAsMain && aPubInfo.iUid == KShortcutPluginUid ) |
|
559 { |
|
560 RProperty::Set( KPSUidAiInformation, KActiveIdleExtHS_PluginConfChange, 0 ); |
|
561 |
|
562 MAiPluginSettings* settings = AiUtility::CreatePluginSettingsL(); |
|
563 CleanupDeletePushL( settings ); |
|
564 |
|
565 MAiPluginSettingsItem& item = settings->AiPluginSettingsItem(); |
|
566 item.SetPublisherId( aPubInfo.iUid ); |
|
567 |
|
568 HBufC* appBuf; |
|
569 appBuf = HBufC::NewLC( RProperty::KMaxPropertySize ); |
|
570 TPtr appPtr = appBuf->Des(); |
|
571 RProperty::Get( KPSUidAiInformation, KActiveIdleExtHS_LSKLocked, appPtr ); |
|
572 if( appPtr.Length() > 0 ) |
|
573 { |
|
574 item.SetKey( KNativeUiKeyIdLockedLSK ); |
|
575 item.SetValueL( appPtr, EFalse ); |
|
576 } |
|
577 else |
|
578 { |
|
579 item.SetKey( KNativeUiKeyIdLSK ); |
|
580 item.SetValueL( KAiLocalAppAppShell, EFalse ); |
|
581 } |
|
582 |
|
583 // Append settings into array. |
|
584 // This can not fail because space has been reserved. |
|
585 aSettings.Append( settings ); |
|
586 |
|
587 CleanupStack::PopAndDestroy( appBuf ); |
|
588 appBuf = NULL; |
|
589 |
|
590 CleanupStack::Pop( settings ); |
|
591 |
|
592 settings = AiUtility::CreatePluginSettingsL(); |
|
593 CleanupDeletePushL( settings ); |
|
594 |
|
595 MAiPluginSettingsItem& item2 = settings->AiPluginSettingsItem(); |
|
596 item2.SetPublisherId( aPubInfo.iUid ); |
|
597 |
|
598 HBufC* app2Buf; |
|
599 app2Buf = HBufC::NewLC( RProperty::KMaxPropertySize ); |
|
600 TPtr app2Ptr = app2Buf->Des(); |
|
601 RProperty::Get( KPSUidAiInformation, KActiveIdleExtHS_RSKLocked, app2Ptr ); |
|
602 if( app2Ptr.Length() > 0 ) |
|
603 { |
|
604 item2.SetKey( KNativeUiKeyIdLockedRSK ); |
|
605 item2.SetValueL( app2Ptr, EFalse ); |
|
606 } |
|
607 else |
|
608 { |
|
609 item2.SetKey( KNativeUiKeyIdRSK ); |
|
610 item2.SetValueL( KAiLocalAppContacts, EFalse ); |
|
611 } |
|
612 |
|
613 // Append settings into array. |
|
614 // This can not fail because space has been reserved. |
|
615 aSettings.Append( settings ); |
|
616 |
|
617 CleanupStack::PopAndDestroy( app2Buf ); |
|
618 app2Buf = NULL; |
|
619 |
|
620 // In case there are settings in the cenrep the settings |
|
621 // here are overwritten by them |
|
622 GetSettingsFromCRL( aPubInfo, aSettings ); |
|
623 CleanupStack::Pop( settings ); |
|
624 } |
|
625 } |
|
626 |
|
627 // ---------------------------------------------------------------------------- |
|
628 // CNativeUiController::GetSettingsFromCRL() |
|
629 // ---------------------------------------------------------------------------- |
|
630 // |
|
631 void CNativeUiController::GetSettingsFromCRL( const TAiPublisherInfo& aPubInfo, |
|
632 RAiSettingsItemArray &aPluginSettings ) |
|
633 { |
|
634 if ( aPubInfo.iNamespace != KNativeUiNamespace ) |
|
635 { |
|
636 return; |
|
637 } |
|
638 |
|
639 /* |
|
640 * The settings are stored in the cenrep starting from 0x1000. |
|
641 * 0x1000 is the name of the plugin which this setting belongs to (for example Settings/Shortcut) |
|
642 * 0x1001 is the id of the setting (for example 1) |
|
643 * 0x1002 is the value of the setting (for example localapp:0x012345678) |
|
644 * |
|
645 * So three keys per setting. |
|
646 */ |
|
647 |
|
648 TUint32 crKey = KAIPluginSettingsKeyRangeStart; |
|
649 |
|
650 TBool moreSettings = ETrue; |
|
651 |
|
652 HBufC* pluginId = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); |
|
653 HBufC* settingValue = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); |
|
654 HBufC* settingKey = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); |
|
655 |
|
656 TPtr pluginIdPtr = pluginId->Des(); |
|
657 TPtr settingValuePtr = settingValue->Des(); |
|
658 TPtr settingKeyPtr = settingKey->Des(); |
|
659 |
|
660 TInt32 settingId = 0; |
|
661 |
|
662 TInt err = KErrNone; |
|
663 TBool settingFound = EFalse; |
|
664 |
|
665 CRepository *settingsRepository = CRepository::NewLC( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
666 |
|
667 while ( moreSettings ) |
|
668 { |
|
669 settingFound = EFalse; |
|
670 |
|
671 pluginIdPtr.Zero(); |
|
672 settingValuePtr.Zero(); |
|
673 settingKeyPtr.Zero(); |
|
674 //Get the name of plugin with the Settings/ prefix |
|
675 err = settingsRepository->Get(crKey++, pluginIdPtr); |
|
676 |
|
677 // remove the Settings/ prefix if it is located at the start of the string |
|
678 if ( pluginIdPtr.FindC(KSettings) == 0 ) |
|
679 { |
|
680 |
|
681 pluginIdPtr.Delete(0, |
|
682 KSettingsIdSeparator().Length() + |
|
683 KSettings().Length()); |
|
684 } |
|
685 |
|
686 // does the setting belong to this plugin |
|
687 if ( err == KErrNone && pluginIdPtr == aPubInfo.iName ) |
|
688 { |
|
689 // Get the settings id |
|
690 err = settingsRepository->Get(crKey++, settingKeyPtr); |
|
691 if ( err == KErrNone ) |
|
692 { |
|
693 err = AiUtility::ParseInt(settingId,settingKeyPtr); |
|
694 } |
|
695 if ( err == KErrNone ) |
|
696 { |
|
697 // Get the actual value of the setting |
|
698 err = settingsRepository->Get(crKey++, settingValuePtr); |
|
699 |
|
700 // Ignore possible placeholder data in cenrep |
|
701 if ( err == KErrNone && settingValuePtr.Compare( KSettingsDummyData ) != 0 ) |
|
702 { |
|
703 // Try to find an existing setting for this |
|
704 for ( TInt j = 0; j < aPluginSettings.Count(); j++ ) |
|
705 { |
|
706 MAiPluginSettings *setting = aPluginSettings[j]; |
|
707 MAiPluginSettingsItem& item = setting->AiPluginSettingsItem(); |
|
708 |
|
709 // Existing setting found => replace it |
|
710 if ( item.Key() == settingId && item.PublisherId() == aPubInfo.iUid ) |
|
711 { |
|
712 item.SetValueL( settingValuePtr, EFalse ); |
|
713 settingFound = ETrue; |
|
714 break; |
|
715 } |
|
716 } |
|
717 // Existing setting not found => append new one ONLY if we |
|
718 // are dealing with the icon overrides |
|
719 if ( !settingFound && ( settingId & KScutFlagBitIconOverride ) ) |
|
720 { |
|
721 MAiPluginSettings* settings = AiUtility::CreatePluginSettingsL(); |
|
722 CleanupDeletePushL( settings ); |
|
723 MAiPluginSettingsItem& item = settings->AiPluginSettingsItem(); |
|
724 |
|
725 item.SetPublisherId( aPubInfo.iUid ); |
|
726 item.SetKey( settingId ); |
|
727 item.SetValueL( settingValuePtr, EFalse ); |
|
728 aPluginSettings.Append( settings ); |
|
729 |
|
730 CleanupStack::Pop( settings ); |
|
731 } |
|
732 } |
|
733 } |
|
734 } |
|
735 // name of the plugin not found => no more settings |
|
736 else if (err != KErrNone ) |
|
737 { |
|
738 moreSettings = EFalse; |
|
739 |
|
740 } |
|
741 // not the correct setting for this plugin |
|
742 else |
|
743 { |
|
744 crKey += KAI2CrKeyIncrementBy2; |
|
745 } |
|
746 } |
|
747 |
|
748 CleanupStack::PopAndDestroy(settingsRepository); |
|
749 CleanupStack::PopAndDestroy(settingKey); |
|
750 CleanupStack::PopAndDestroy(settingValue); |
|
751 CleanupStack::PopAndDestroy(pluginId); |
|
752 } |
|
753 |
|
754 // ---------------------------------------------------------------------------- |
|
755 // CNativeUiController::ActivateUI() |
|
756 // ---------------------------------------------------------------------------- |
|
757 // |
|
758 void CNativeUiController::ActivateUI() |
|
759 { |
|
760 if( iAppUi ) |
|
761 { |
|
762 TRAP_IGNORE( iAppUi->StartL() ); |
|
763 } |
|
764 } |
|
765 |
|
766 // ---------------------------------------------------------------------------- |
|
767 // CNativeUiController::GetContentObserver() |
|
768 // ---------------------------------------------------------------------------- |
|
769 // |
|
770 MAiContentObserver& CNativeUiController::GetContentObserver() |
|
771 { |
|
772 return *this; |
|
773 } |
|
774 |
|
775 // ---------------------------------------------------------------------------- |
|
776 // CNativeUiController::SetEventHandler() |
|
777 // ---------------------------------------------------------------------------- |
|
778 // |
|
779 void CNativeUiController::SetEventHandler( MAiFwEventHandler& aEventHandler ) |
|
780 { |
|
781 iFwEventHandler = &aEventHandler; |
|
782 } |
|
783 |
|
784 // ---------------------------------------------------------------------------- |
|
785 // CNativeUiController::FwEventHandler() |
|
786 // ---------------------------------------------------------------------------- |
|
787 // |
|
788 MAiFwEventHandler* CNativeUiController::FwEventHandler() |
|
789 { |
|
790 return iFwEventHandler; |
|
791 } |
|
792 |
|
793 // ---------------------------------------------------------------------------- |
|
794 // CNativeUiController::RemovePluginFromUI() |
|
795 // ---------------------------------------------------------------------------- |
|
796 // |
|
797 void CNativeUiController::RemovePluginFromUI( |
|
798 MAiPropertyExtension& /*aPlugin*/ ) |
|
799 { |
|
800 } |
|
801 |
|
802 // ---------------------------------------------------------------------------- |
|
803 // CNativeUiController::MainInterface() |
|
804 // ---------------------------------------------------------------------------- |
|
805 // |
|
806 MAiMainUiController* CNativeUiController::MainInterface() |
|
807 { |
|
808 return this; |
|
809 } |
|
810 |
|
811 // ---------------------------------------------------------------------------- |
|
812 // CNativeUiController::SecondaryInterface() |
|
813 // ---------------------------------------------------------------------------- |
|
814 // |
|
815 MAiSecondaryUiController* CNativeUiController::SecondaryInterface() |
|
816 { |
|
817 return this; |
|
818 } |
|
819 |
|
820 // ---------------------------------------------------------------------------- |
|
821 // CNativeUiController::RunApplicationL() |
|
822 // ---------------------------------------------------------------------------- |
|
823 // |
|
824 void CNativeUiController::RunApplicationL() |
|
825 { |
|
826 VariateToMainUiController(); |
|
827 |
|
828 User::LeaveIfError( |
|
829 EikStart::RunApplication( &CNativeUiController::NewApplication ) ); |
|
830 } |
|
831 |
|
832 // ---------------------------------------------------------------------------- |
|
833 // CNativeUiController::CoeEnv() |
|
834 // ---------------------------------------------------------------------------- |
|
835 // |
|
836 CCoeEnv& CNativeUiController::CoeEnv() |
|
837 { |
|
838 return *CCoeEnv::Static(); |
|
839 } |
|
840 |
|
841 // ---------------------------------------------------------------------------- |
|
842 // CNativeUiController::SetUiFrameworkObserver() |
|
843 // ---------------------------------------------------------------------------- |
|
844 // |
|
845 void CNativeUiController::SetUiFrameworkObserver( |
|
846 MAiUiFrameworkObserver& aObserver ) |
|
847 { |
|
848 iUiFrameworkObserver = &aObserver; |
|
849 } |
|
850 |
|
851 // ---------------------------------------------------------------------------- |
|
852 // CNativeUiController::IsMenuOpen() |
|
853 // ---------------------------------------------------------------------------- |
|
854 // |
|
855 TBool CNativeUiController::IsMenuOpen() |
|
856 { |
|
857 return CoeEnv().AppUi()->IsDisplayingMenuOrDialog(); |
|
858 } |
|
859 |
|
860 // ---------------------------------------------------------------------------- |
|
861 // CNativeUiController::SetCoeEnv() |
|
862 // ---------------------------------------------------------------------------- |
|
863 // |
|
864 void CNativeUiController::SetCoeEnv( CCoeEnv& aCoeEnv ) |
|
865 { |
|
866 iCoeEnv = &aCoeEnv; |
|
867 } |
|
868 |
|
869 // ---------------------------------------------------------------------------- |
|
870 // CNativeUiController::UiFrameworkObserver() |
|
871 // ---------------------------------------------------------------------------- |
|
872 // |
|
873 MAiUiFrameworkObserver* CNativeUiController::UiFrameworkObserver() |
|
874 { |
|
875 return iUiFrameworkObserver; |
|
876 } |
|
877 |
|
878 // ---------------------------------------------------------------------------- |
|
879 // CNativeUiController::HandleResourceChange() |
|
880 // ---------------------------------------------------------------------------- |
|
881 // |
|
882 void CNativeUiController::HandleResourceChange( TInt /*aType*/ ) |
|
883 { |
|
884 } |
|
885 |
|
886 // ---------------------------------------------------------------------------- |
|
887 // CNativeUiController::HandleForegroundEvent() |
|
888 // ---------------------------------------------------------------------------- |
|
889 // |
|
890 void CNativeUiController::HandleForegroundEvent( TBool /*aForeground*/ ) |
|
891 { |
|
892 } |
|
893 |
|
894 // ---------------------------------------------------------------------------- |
|
895 // CNativeUiController::StartTransaction() |
|
896 // ---------------------------------------------------------------------------- |
|
897 // |
|
898 TInt CNativeUiController::StartTransaction( TInt /*aTxId*/ ) |
|
899 { |
|
900 return KErrNone; |
|
901 } |
|
902 |
|
903 // ---------------------------------------------------------------------------- |
|
904 // CNativeUiController::Commit() |
|
905 // ---------------------------------------------------------------------------- |
|
906 // |
|
907 TInt CNativeUiController::Commit( TInt /*aTxId*/ ) |
|
908 { |
|
909 TInt result( KErrNone ); |
|
910 const TInt count( iRenderers.Count() ); |
|
911 |
|
912 for( TInt i( 0 ); i < count; i++ ) |
|
913 { |
|
914 TRAP( result, iRenderers[i]->TransactionCommittedL() ); |
|
915 } |
|
916 |
|
917 return result; |
|
918 } |
|
919 |
|
920 // ---------------------------------------------------------------------------- |
|
921 // CNativeUiController::CancelTransaction() |
|
922 // ---------------------------------------------------------------------------- |
|
923 // |
|
924 TInt CNativeUiController::CancelTransaction( TInt /*aTxId*/ ) |
|
925 { |
|
926 return KErrNone; |
|
927 } |
|
928 |
|
929 // ---------------------------------------------------------------------------- |
|
930 // CNativeUiController::CanPublish() |
|
931 // ---------------------------------------------------------------------------- |
|
932 // |
|
933 TBool CNativeUiController::CanPublish( MAiPropertyExtension& aPlugin, |
|
934 TInt /*aContent*/, TInt /*aIndex*/ ) |
|
935 { |
|
936 const TAiPublisherInfo* info( NULL ); |
|
937 |
|
938 TRAP_IGNORE( info = aPlugin.PublisherInfoL() ); |
|
939 |
|
940 if ( !info || info->iNamespace != KNativeUiNamespace ) |
|
941 { |
|
942 return EFalse; |
|
943 } |
|
944 |
|
945 for( TInt i = 0; i < iPlugins.Count(); i++ ) |
|
946 { |
|
947 if ( iPlugins[i] == *info ) |
|
948 { |
|
949 return ETrue; |
|
950 } |
|
951 } |
|
952 |
|
953 return EFalse; |
|
954 } |
|
955 |
|
956 // ---------------------------------------------------------------------------- |
|
957 // CNativeUiController::Publish() |
|
958 // ---------------------------------------------------------------------------- |
|
959 // |
|
960 TInt CNativeUiController::Publish( MAiPropertyExtension& aPlugin, |
|
961 TInt aContent, TInt aResource, TInt aIndex ) |
|
962 { |
|
963 TInt err = DoPublish( aPlugin, aContent, aResource, aIndex ); |
|
964 return err; |
|
965 } |
|
966 |
|
967 // ---------------------------------------------------------------------------- |
|
968 // CNativeUiController::Publish() |
|
969 // ---------------------------------------------------------------------------- |
|
970 // |
|
971 TInt CNativeUiController::Publish( MAiPropertyExtension& aPlugin, |
|
972 TInt aContent, const TDesC16& aText, TInt aIndex ) |
|
973 { |
|
974 TInt err = DoPublish( aPlugin, aContent, aText, aIndex ); |
|
975 return err; |
|
976 } |
|
977 |
|
978 // ---------------------------------------------------------------------------- |
|
979 // CNativeUiController::Publish() |
|
980 // ---------------------------------------------------------------------------- |
|
981 // |
|
982 TInt CNativeUiController::Publish( MAiPropertyExtension& aPlugin, |
|
983 TInt aContent, const TDesC8& aBuf, TInt aIndex ) |
|
984 { |
|
985 TInt err = DoPublish( aPlugin, aContent, aBuf, aIndex ); |
|
986 return err; |
|
987 } |
|
988 |
|
989 // ---------------------------------------------------------------------------- |
|
990 // CNativeUiController::Publish() |
|
991 // ---------------------------------------------------------------------------- |
|
992 // |
|
993 TInt CNativeUiController::Publish( MAiPropertyExtension& aPlugin, |
|
994 TInt aContent, RFile& aFile, TInt aIndex ) |
|
995 { |
|
996 TInt err = DoPublish( aPlugin, aContent, aFile, aIndex ); |
|
997 return err; |
|
998 } |
|
999 |
|
1000 // ---------------------------------------------------------------------------- |
|
1001 // CNativeUiController::Clean() |
|
1002 // ---------------------------------------------------------------------------- |
|
1003 // |
|
1004 TInt CNativeUiController::Clean( MAiPropertyExtension& aPlugin, |
|
1005 TInt aContent, TInt /*aIndex*/ ) |
|
1006 { |
|
1007 const TInt count( iRenderers.Count() ); |
|
1008 |
|
1009 for( TInt i( 0 ); i < count; i++ ) |
|
1010 { |
|
1011 iRenderers[i]->Clean( aPlugin, aContent ); |
|
1012 } |
|
1013 |
|
1014 return KErrNone; |
|
1015 } |
|
1016 |
|
1017 // ---------------------------------------------------------------------------- |
|
1018 // CNativeUiController::Extension() |
|
1019 // ---------------------------------------------------------------------------- |
|
1020 // |
|
1021 TAny* CNativeUiController::Extension( TUid /*aUid*/ ) |
|
1022 { |
|
1023 return NULL; |
|
1024 } |
|
1025 |
|
1026 // ---------------------------------------------------------------------------- |
|
1027 // CNativeUiController::RequiresSubscription() |
|
1028 // ---------------------------------------------------------------------------- |
|
1029 // |
|
1030 TBool CNativeUiController::RequiresSubscription( |
|
1031 const TAiPublisherInfo& aPublisherInfo ) const |
|
1032 { |
|
1033 if ( aPublisherInfo.iNamespace == KNativeUiNamespace ) |
|
1034 { |
|
1035 // Targeted to this content renderer |
|
1036 return ETrue; |
|
1037 } |
|
1038 |
|
1039 return EFalse; |
|
1040 } |
|
1041 |
|
1042 // ---------------------------------------------------------------------------- |
|
1043 // CNativeUiController::NewApplication() |
|
1044 // ---------------------------------------------------------------------------- |
|
1045 // |
|
1046 CApaApplication* CNativeUiController::NewApplication() |
|
1047 { |
|
1048 CNativeUiController* self = |
|
1049 static_cast< CNativeUiController* >( Dll::Tls() ); |
|
1050 |
|
1051 return CApplication::New( self ); |
|
1052 } |
|
1053 |
|
1054 // ---------------------------------------------------------------------------- |
|
1055 // CNativeUiController::VariateToMainUiController() |
|
1056 // ---------------------------------------------------------------------------- |
|
1057 // |
|
1058 void CNativeUiController::VariateToMainUiController() |
|
1059 { |
|
1060 iRunningAsMain = ETrue; |
|
1061 } |
|
1062 |
|
1063 // ======== GLOBAL FUNCTIONS ======== |
|
1064 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
1065 { |
|
1066 aTableCount = sizeof( KImplementationTable ) / sizeof( TImplementationProxy ); |
|
1067 return KImplementationTable; |
|
1068 } |
|
1069 |
|
1070 // End of File. |