34
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: XML UI Controller main class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <ecom/implementationproxy.h>
|
|
20 |
#include <AknQueryDialog.h>
|
|
21 |
#include <eikstart.h>
|
|
22 |
#include <apgtask.h>
|
|
23 |
#include <centralrepository.h>
|
|
24 |
#include <e32property.h>
|
|
25 |
|
|
26 |
// User includes
|
|
27 |
#include <activeidle2domainpskeys.h>
|
|
28 |
#include <activeidle2domaincrkeys.h>
|
|
29 |
#include <hscontentpublisher.h>
|
|
30 |
#include <hspublisherinfo.h>
|
|
31 |
#include <aisystemuids.hrh>
|
|
32 |
#include <ai3xmlui.rsg>
|
|
33 |
|
|
34 |
#include "xmluicontroller.h"
|
|
35 |
|
|
36 |
#include "xnuiengineappif.h"
|
|
37 |
#include "xnnodeappif.h"
|
|
38 |
#include "xnproperty.h"
|
|
39 |
#include "xntype.h"
|
|
40 |
#include "aistrcnv.h"
|
|
41 |
|
|
42 |
#include "application.h"
|
|
43 |
#include "appui.h"
|
|
44 |
#include "xmlnodeidgenerator.h"
|
|
45 |
#include "aixuikoneventhandler.h"
|
|
46 |
#include "aixmluiutils.h"
|
|
47 |
#include "aiutility.h"
|
|
48 |
#include "aipluginsettings.h"
|
|
49 |
#include "aixmluiconstants.h"
|
|
50 |
#include "aifweventhandler.h"
|
|
51 |
#include "debug.h"
|
|
52 |
#include "aiconsts.h"
|
|
53 |
#include "contentrenderer.h"
|
|
54 |
#include "xmluicontrollerpanic.h"
|
|
55 |
#include "contentpublisher.h"
|
|
56 |
#include "xnplugindefs.h"
|
|
57 |
#include "ainativeuiplugins.h"
|
|
58 |
|
|
59 |
// Constants
|
|
60 |
const TInt KOneSecondInMicroS = 1000*1000;
|
|
61 |
|
|
62 |
// Macros
|
|
63 |
#define IS_KNOWN_CONTENT_MODEL_ELEMENT( e ) \
|
|
64 |
( e == AiUiDef::xml::element::KImage || \
|
|
65 |
e == AiUiDef::xml::element::KText || \
|
|
66 |
e == AiUiDef::xml::element::KAnimation || \
|
|
67 |
e == AiUiDef::xml::element::KTextEditor || \
|
|
68 |
e == AiUiDef::xml::element::KTitle || \
|
|
69 |
e == AiUiDef::xml::element::KData )
|
|
70 |
|
|
71 |
using namespace AiXmlUiController;
|
|
72 |
|
|
73 |
// ======== LOCAL FUNCTIONS ========
|
|
74 |
// ----------------------------------------------------------------------------
|
|
75 |
// BuildModelL()
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
static void BuildModelL( CXnNodeAppIf* aParent, const TDesC8& aKey,
|
|
79 |
const TDesC8& aNs, RPointerArray< CXnNodeAppIf >& aModel )
|
|
80 |
{
|
|
81 |
if ( !aParent || aParent->Namespace() != aNs )
|
|
82 |
{
|
|
83 |
// No parent or traversed out from the namespace
|
|
84 |
return;
|
|
85 |
}
|
|
86 |
|
|
87 |
if ( aParent->Type()->Type() == XnPropertyNames::action::KProperty )
|
|
88 |
{
|
|
89 |
CXnProperty* prop(
|
|
90 |
aParent->GetPropertyL( XnPropertyNames::common::KClass ) );
|
|
91 |
|
|
92 |
if ( prop )
|
|
93 |
{
|
|
94 |
const TDesC8& value( prop->StringValue() );
|
|
95 |
|
|
96 |
if ( value.Find( aKey ) != KErrNotFound )
|
|
97 |
{
|
|
98 |
aModel.AppendL( aParent );
|
|
99 |
}
|
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
RPointerArray< CXnNodeAppIf > children( aParent->ChildrenL() );
|
|
104 |
CleanupClosePushL( children );
|
|
105 |
|
|
106 |
for ( TInt i = 0; i < children.Count(); i++ )
|
|
107 |
{
|
|
108 |
// Recurse children
|
|
109 |
BuildModelL( children[i], aKey, aNs, aModel );
|
|
110 |
}
|
|
111 |
|
|
112 |
CleanupStack::PopAndDestroy( &children );
|
|
113 |
}
|
|
114 |
|
|
115 |
// ----------------------------------------------------------------------------
|
|
116 |
// ResolveEventParameters()
|
|
117 |
// ----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
static void ResolveEventParameters( const TDesC8& aEventString,
|
|
120 |
TPtrC8& aParam1, TPtrC8& aParam2 )
|
|
121 |
{
|
|
122 |
TInt paramPos( aEventString.Locate( KEventParameterSeparator ) );
|
|
123 |
|
|
124 |
TLex8 lex( aEventString.Mid( ++paramPos ) );
|
|
125 |
|
|
126 |
aParam1.Set( lex.NextToken() ); // first ui element id
|
|
127 |
|
|
128 |
TInt commaPos( aParam1.LocateReverse( KComma ) );
|
|
129 |
|
|
130 |
if( commaPos != KErrNotFound )
|
|
131 |
{
|
|
132 |
// Strip comma
|
|
133 |
aParam1.Set( aParam1.Left( commaPos ) );
|
|
134 |
|
|
135 |
aParam2.Set( lex.NextToken() ); // second ui element id
|
|
136 |
|
|
137 |
TInt rightParenthesis( aParam2.LocateReverse( KRightParenthesis ) );
|
|
138 |
|
|
139 |
if( rightParenthesis != KErrNotFound )
|
|
140 |
{
|
|
141 |
aParam2.Set( aParam2.Left( rightParenthesis ) );
|
|
142 |
}
|
|
143 |
}
|
|
144 |
else
|
|
145 |
{
|
|
146 |
// Strip right parenthesis
|
|
147 |
aParam1.Set( aParam1.Left( aParam1.Length() -1 ) );
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
// ======== MEMBER FUNCTIONS ========
|
|
152 |
// ----------------------------------------------------------------------------
|
|
153 |
// CXmlUiController::CXmlUiController()
|
|
154 |
// ----------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
CXmlUiController::CXmlUiController()
|
|
157 |
{
|
|
158 |
}
|
|
159 |
|
|
160 |
// ----------------------------------------------------------------------------
|
|
161 |
// CXmlUiController::ConstructL()
|
|
162 |
// ----------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CXmlUiController::ConstructL()
|
|
165 |
{
|
|
166 |
iNodeIdGenerator = CXmlNodeIdGenerator::NewL();
|
|
167 |
|
|
168 |
iAISettingsRepository =
|
|
169 |
CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
|
|
170 |
|
|
171 |
// Indicate to wserv plugin if it launches logs on send key or not
|
|
172 |
RProperty::Set( KPSUidAiInformation, KActiveIdleActOnSendKey, ETrue );
|
|
173 |
}
|
|
174 |
|
|
175 |
// ----------------------------------------------------------------------------
|
|
176 |
// CXmlUiController::NewL()
|
|
177 |
// ----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
CXmlUiController* CXmlUiController::NewL()
|
|
180 |
{
|
|
181 |
CXmlUiController* self = new ( ELeave ) CXmlUiController;
|
|
182 |
|
|
183 |
CleanupStack::PushL( self );
|
|
184 |
self->ConstructL();
|
|
185 |
|
|
186 |
// Set XML UI Controller object to TLS for access in static
|
|
187 |
// CXmlUiController::NewApplication
|
|
188 |
User::LeaveIfError( Dll::SetTls( self ) );
|
|
189 |
|
|
190 |
CleanupStack::Pop( self );
|
|
191 |
|
|
192 |
return self;
|
|
193 |
}
|
|
194 |
|
|
195 |
// ----------------------------------------------------------------------------
|
|
196 |
// CXmlUiController::~CXmlUiController()
|
|
197 |
// ----------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
CXmlUiController::~CXmlUiController()
|
|
200 |
{
|
|
201 |
delete iNodeIdGenerator;
|
|
202 |
delete iExitTimer;
|
|
203 |
delete iAISettingsRepository;
|
|
204 |
delete iCPSpublisher;
|
|
205 |
|
|
206 |
// Reset TLS pointer to this set in NewL
|
|
207 |
Dll::SetTls( NULL );
|
|
208 |
}
|
|
209 |
|
|
210 |
// ----------------------------------------------------------------------------
|
|
211 |
// CXmlUiController::Exit()
|
|
212 |
// ----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CXmlUiController::Exit()
|
|
215 |
{
|
|
216 |
if( iExitTimer )
|
|
217 |
{
|
|
218 |
iExitTimer->Cancel();
|
|
219 |
|
|
220 |
iExitTimer->Start( 0, KOneSecondInMicroS,
|
|
221 |
TCallBack( ExitTimerCallBack, this ) );
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
// ----------------------------------------------------------------------------
|
|
226 |
// CXmlUiController::ExitTimerCallBack()
|
|
227 |
// ----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
TInt CXmlUiController::ExitTimerCallBack(TAny *aSelf)
|
|
230 |
{
|
|
231 |
CXmlUiController* self =
|
|
232 |
static_cast< CXmlUiController* >( aSelf );
|
|
233 |
|
|
234 |
if( self )
|
|
235 |
{
|
|
236 |
self->iExitTimer->Cancel();
|
|
237 |
|
|
238 |
self->iAppUi->Exit();
|
|
239 |
}
|
|
240 |
|
|
241 |
return KErrNone;
|
|
242 |
}
|
|
243 |
|
|
244 |
// ----------------------------------------------------------------------------
|
|
245 |
// CXmlUiController::SetObserver()
|
|
246 |
// ----------------------------------------------------------------------------
|
|
247 |
//
|
|
248 |
void CXmlUiController::SetObserver( MAiContentObserver& aObserver )
|
|
249 |
{
|
|
250 |
iObserver = &aObserver;
|
|
251 |
}
|
|
252 |
|
|
253 |
// ----------------------------------------------------------------------------
|
|
254 |
// CXmlUiController::SetAppUi()
|
|
255 |
// ----------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CXmlUiController::SetAppUi( CAppUi& aAppUi )
|
|
258 |
{
|
|
259 |
iAppUi = &aAppUi;
|
|
260 |
}
|
|
261 |
|
|
262 |
// ----------------------------------------------------------------------------
|
|
263 |
// CXmlUiController::AppUi()
|
|
264 |
// ----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
CAppUi* CXmlUiController::AppUi() const
|
|
267 |
{
|
|
268 |
return iAppUi;
|
|
269 |
}
|
|
270 |
|
|
271 |
// ----------------------------------------------------------------------------
|
|
272 |
// CXmlUiController::UiEngineL()
|
|
273 |
// ----------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
TXnUiEngineAppIf* CXmlUiController::UiEngineL() const
|
|
276 |
{
|
|
277 |
return iAppUi ? iAppUi->UiEngineL() : NULL;
|
|
278 |
}
|
|
279 |
|
|
280 |
// ----------------------------------------------------------------------------
|
|
281 |
// CXmlUiController::SettingsRepository()
|
|
282 |
// ----------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
CRepository& CXmlUiController::SettingsRepository() const
|
|
285 |
{
|
|
286 |
return *iAISettingsRepository;
|
|
287 |
}
|
|
288 |
|
|
289 |
// ----------------------------------------------------------------------------
|
|
290 |
// CXmlUiController::CreateXuikonEventHandlerL()
|
|
291 |
// ----------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
CAIXuikonEventHandler* CXmlUiController::CreateXuikonEventHandlerL(
|
|
294 |
CContentRenderer& aRenderer )
|
|
295 |
{
|
|
296 |
CAIXuikonEventHandler* eventHandler =
|
|
297 |
CAIXuikonEventHandler::NewL( *this, aRenderer );
|
|
298 |
|
|
299 |
eventHandler->SetFwEventHandler( iFwEventHandler );
|
|
300 |
eventHandler->SetUiEventHandler( this );
|
|
301 |
|
|
302 |
return eventHandler;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ----------------------------------------------------------------------------
|
|
306 |
// CXmlUiController::NotifyAppEnvReadyL()
|
|
307 |
// ----------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
void CXmlUiController::NotifyAppEnvReadyL()
|
|
310 |
{
|
|
311 |
iCPSpublisher = CContentPublisher::NewL( *this );
|
|
312 |
|
|
313 |
iExitTimer = CPeriodic::NewL( CActive::EPriorityStandard );
|
|
314 |
|
|
315 |
if( iFwEventHandler )
|
|
316 |
{
|
|
317 |
iFwEventHandler->AppEnvReadyL();
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
// ----------------------------------------------------------------------------
|
|
322 |
// CXmlUiController::LoadUIDefinition()
|
|
323 |
// ----------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CXmlUiController::LoadUIDefinitionL()
|
|
326 |
{
|
|
327 |
}
|
|
328 |
|
|
329 |
// ----------------------------------------------------------------------------
|
|
330 |
// CXmlUiController::PublisherInfoL()
|
|
331 |
// ----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CXmlUiController::PublisherInfoL( CXnNodeAppIf& aSource,
|
|
334 |
THsPublisherInfo& aInfo )
|
|
335 |
{
|
|
336 |
// Fetch uid from XML and convert it to TUid
|
|
337 |
const TDesC8* uid( PropertyValue( aSource,
|
|
338 |
AiUiDef::xml::property::KValue ) );
|
|
339 |
|
|
340 |
if ( !uid )
|
|
341 |
{
|
|
342 |
return;
|
|
343 |
}
|
|
344 |
|
|
345 |
_LIT8( KPrefix, "0x" );
|
|
346 |
|
|
347 |
const TInt pos( uid->FindF( KPrefix ) );
|
|
348 |
|
|
349 |
TInt32 uidValue( 0 );
|
|
350 |
|
|
351 |
if( pos != KErrNotFound )
|
|
352 |
{
|
|
353 |
TLex8 lex( uid->Mid( pos + KPrefix().Length() ) );
|
|
354 |
|
|
355 |
// Hex parsing needs unsigned int
|
|
356 |
TUint32 value( 0 );
|
|
357 |
TInt err( lex.Val( value, EHex ) );
|
|
358 |
|
|
359 |
if ( err == KErrNone )
|
|
360 |
{
|
|
361 |
uidValue = value;
|
|
362 |
}
|
|
363 |
}
|
|
364 |
|
|
365 |
// Fetch plug-in name from XML
|
|
366 |
HBufC* name( PropertyValueL( aSource, AiUiDef::xml::property::KName ) );
|
|
367 |
|
|
368 |
TUid pluginuid( TUid::Uid( uidValue ) );
|
|
369 |
|
|
370 |
aInfo = THsPublisherInfo( pluginuid, *name, aSource.Namespace() );
|
|
371 |
|
|
372 |
delete name;
|
|
373 |
name = NULL;
|
|
374 |
}
|
|
375 |
|
|
376 |
// ----------------------------------------------------------------------------
|
|
377 |
// CXmlUiController::GetSettingsL()
|
|
378 |
//
|
|
379 |
// ----------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
void CXmlUiController::GetSettingsL( const THsPublisherInfo& aPublisherInfo,
|
|
382 |
RAiSettingsItemArray& aSettings )
|
|
383 |
{
|
|
384 |
if ( aPublisherInfo.Namespace() == KNativeUiNamespace )
|
|
385 |
{
|
|
386 |
// This controller doesn't provide settings for native ui namespace
|
|
387 |
return;
|
|
388 |
}
|
|
389 |
|
|
390 |
const TDesC& classId(
|
|
391 |
iNodeIdGenerator->SettingsNodeIdL( aPublisherInfo ) );
|
|
392 |
|
|
393 |
TBuf< KHsPublisherNamespaceMaxLength > ns;
|
|
394 |
|
|
395 |
ns.Copy( aPublisherInfo.Namespace() );
|
|
396 |
|
|
397 |
// Find settings nodes
|
|
398 |
RPointerArray< CXnNodeAppIf > nodes(
|
|
399 |
UiEngineL()->FindNodeByClassL( classId, ns ) );
|
|
400 |
|
|
401 |
CleanupClosePushL( nodes );
|
|
402 |
|
|
403 |
// Reserve space for settings
|
|
404 |
aSettings.ReserveL( aSettings.Count() + nodes.Count() );
|
|
405 |
|
|
406 |
// Collect settings
|
|
407 |
TInt count( nodes.Count() );
|
|
408 |
|
|
409 |
for( TInt i = 0; i < count; ++i )
|
|
410 |
{
|
|
411 |
CXnNodeAppIf* node( nodes[i] );
|
|
412 |
|
|
413 |
const TDesC8* name(
|
|
414 |
PropertyValue( *node, AiUiDef::xml::property::KName ) );
|
|
415 |
|
|
416 |
HBufC* value(
|
|
417 |
PropertyValueL( *node, AiUiDef::xml::property::KValue ) );
|
|
418 |
|
|
419 |
CleanupStack::PushL( value );
|
|
420 |
|
|
421 |
if( name && value )
|
|
422 |
{
|
|
423 |
MAiPluginSettings* settings( AiUtility::CreatePluginSettingsL() );
|
|
424 |
CleanupDeletePushL( settings );
|
|
425 |
|
|
426 |
MAiPluginSettingsItem& item( settings->AiPluginSettingsItem() );
|
|
427 |
item.SetPublisherId( aPublisherInfo.Uid() );
|
|
428 |
|
|
429 |
TInt32 key( 0 );
|
|
430 |
|
|
431 |
User::LeaveIfError( AiUtility::ParseInt( key, *name ) );
|
|
432 |
|
|
433 |
item.SetKey( key );
|
|
434 |
item.SetValueL( *value, EFalse );
|
|
435 |
|
|
436 |
// Append settings into array.
|
|
437 |
// This can not fail because space has been reserved.
|
|
438 |
aSettings.Append( settings );
|
|
439 |
CleanupStack::Pop( settings );
|
|
440 |
}
|
|
441 |
|
|
442 |
CleanupStack::PopAndDestroy( value );
|
|
443 |
}
|
|
444 |
|
|
445 |
CleanupStack::PopAndDestroy( &nodes );
|
|
446 |
|
|
447 |
GetContentModelL( aPublisherInfo, aSettings );
|
|
448 |
}
|
|
449 |
|
|
450 |
// ----------------------------------------------------------------------------
|
|
451 |
// CXmlUiController::GetContentModelL()
|
|
452 |
// ----------------------------------------------------------------------------
|
|
453 |
//
|
|
454 |
void CXmlUiController::GetContentModelL( const THsPublisherInfo& aPublisherInfo,
|
|
455 |
RAiSettingsItemArray& aSettings )
|
|
456 |
{
|
|
457 |
if ( aPublisherInfo.Namespace() == KNativeUiNamespace )
|
|
458 |
{
|
|
459 |
// This controller doesn't provide content model for native ui namespace
|
|
460 |
return;
|
|
461 |
}
|
|
462 |
|
|
463 |
// Find the node for the publisher
|
|
464 |
RPointerArray<CXnNodeAppIf> list(
|
|
465 |
UiEngineL()->FindContentSourceNodesL( aPublisherInfo.Namespace() ) );
|
|
466 |
|
|
467 |
CleanupClosePushL( list );
|
|
468 |
|
|
469 |
CXnNodeAppIf* publisher( NULL );
|
|
470 |
|
|
471 |
if ( list.Count() > 0 )
|
|
472 |
{
|
|
473 |
publisher = list[0];
|
|
474 |
}
|
|
475 |
|
|
476 |
CleanupStack::PopAndDestroy( &list );
|
|
477 |
|
|
478 |
if( !publisher )
|
|
479 |
{
|
|
480 |
return;
|
|
481 |
}
|
|
482 |
|
|
483 |
// Find plugin node for the <contentsource> element
|
|
484 |
CXnNodeAppIf* parent( publisher->ParentL() );
|
|
485 |
|
|
486 |
if ( parent && parent->InternalDomNodeType() == XnPropertyNames::KWidget )
|
|
487 |
{
|
|
488 |
// Get <contentsource> element configurations
|
|
489 |
GetConfigurationsL(
|
|
490 |
*parent, aSettings, AiUiDef::xml::element::K16Plugin() );
|
|
491 |
|
|
492 |
RPointerArray< CXnNodeAppIf > model;
|
|
493 |
CleanupClosePushL( model );
|
|
494 |
|
|
495 |
HBufC8* key = HBufC8::NewLC( aPublisherInfo.Name().Length() + 1 );
|
|
496 |
|
|
497 |
_LIT( KSlash, "/" );
|
|
498 |
|
|
499 |
key->Des().Copy( aPublisherInfo.Name() );
|
|
500 |
key->Des().Append( KSlash );
|
|
501 |
|
|
502 |
BuildModelL( parent, *key, parent->Namespace(), model );
|
|
503 |
|
|
504 |
for ( TInt i = 0; i < model.Count(); i++ )
|
|
505 |
{
|
|
506 |
CXnNodeAppIf* parent( model[i]->ParentL() );
|
|
507 |
|
|
508 |
if ( parent )
|
|
509 |
{
|
|
510 |
const TDesC8& type( parent->Type()->Type() );
|
|
511 |
|
|
512 |
if ( IS_KNOWN_CONTENT_MODEL_ELEMENT( type ) )
|
|
513 |
{
|
|
514 |
// Content model found for the element, create content item
|
|
515 |
MAiPluginSettings* settings(
|
|
516 |
AiUtility::CreatePluginSettingsL() );
|
|
517 |
|
|
518 |
CleanupDeletePushL( settings );
|
|
519 |
|
|
520 |
MAiPluginContentItem& item(
|
|
521 |
settings->AiPluginContentItem() );
|
|
522 |
|
|
523 |
// Type of the element is needed in content model
|
|
524 |
HBufC* type16( NULL );
|
|
525 |
|
|
526 |
type16 = AiUtility::CopyToBufferL( type16, type );
|
|
527 |
|
|
528 |
CleanupStack::PushL( type16 );
|
|
529 |
|
|
530 |
item.SetTypeL( *type16 );
|
|
531 |
|
|
532 |
HBufC* name( PropertyValueL(
|
|
533 |
*model[i], AiUiDef::xml::property::KClass ) );
|
|
534 |
CleanupStack::PushL( name );
|
|
535 |
|
|
536 |
item.SetNameL( *name );
|
|
537 |
|
|
538 |
// Get content model configurations,
|
|
539 |
// i.e. <property> element's <configuration> siblings
|
|
540 |
GetConfigurationsL( *parent, aSettings, *name );
|
|
541 |
|
|
542 |
CleanupStack::PopAndDestroy( 2, type16 ); // name
|
|
543 |
|
|
544 |
aSettings.AppendL( settings );
|
|
545 |
CleanupStack::Pop( settings );
|
|
546 |
}
|
|
547 |
}
|
|
548 |
}
|
|
549 |
|
|
550 |
CleanupStack::PopAndDestroy( 2, &model ); // key
|
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
// ----------------------------------------------------------------------------
|
|
555 |
// CXmlUiController::GetConfigurationsL()
|
|
556 |
// ----------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void CXmlUiController::GetConfigurationsL( CXnNodeAppIf& aNode,
|
|
559 |
RAiSettingsItemArray& aSettings, const TDesC& aConfOwner )
|
|
560 |
{
|
|
561 |
// Find configuration nodes
|
|
562 |
RPointerArray< CXnNodeAppIf > nodes( aNode.ChildrenL() );
|
|
563 |
CleanupClosePushL( nodes );
|
|
564 |
|
|
565 |
// Collect settings
|
|
566 |
TInt count( nodes.Count() );
|
|
567 |
|
|
568 |
for( TInt i = 0; i < count; i++ )
|
|
569 |
{
|
|
570 |
CXnNodeAppIf* node( nodes[i] );
|
|
571 |
|
|
572 |
if( node->Type()->Type() == AiUiDef::xml::element::KConfiguration )
|
|
573 |
{
|
|
574 |
HBufC* name( PropertyValueL( *node, AiUiDef::xml::property::KName ) );
|
|
575 |
CleanupStack::PushL( name );
|
|
576 |
|
|
577 |
HBufC* value( PropertyValueL( *node, AiUiDef::xml::property::KValue ) );
|
|
578 |
CleanupStack::PushL( value );
|
|
579 |
|
|
580 |
MAiPluginSettings* settings = AiUtility::CreatePluginSettingsL();
|
|
581 |
CleanupDeletePushL( settings );
|
|
582 |
|
|
583 |
MAiPluginConfigurationItem& item( settings->AiPluginConfigurationItem() );
|
|
584 |
|
|
585 |
item.SetOwnerL( aConfOwner );
|
|
586 |
item.SetNameL( *name );
|
|
587 |
item.SetValueL( *value );
|
|
588 |
|
|
589 |
// Append settings into array.
|
|
590 |
aSettings.AppendL( settings );
|
|
591 |
|
|
592 |
CleanupStack::Pop( settings );
|
|
593 |
CleanupStack::PopAndDestroy( value );
|
|
594 |
CleanupStack::PopAndDestroy( name );
|
|
595 |
}
|
|
596 |
}
|
|
597 |
|
|
598 |
CleanupStack::PopAndDestroy( &nodes );
|
|
599 |
}
|
|
600 |
|
|
601 |
// ----------------------------------------------------------------------------
|
|
602 |
// CXmlUiController::ActivateUI()
|
|
603 |
// ----------------------------------------------------------------------------
|
|
604 |
//
|
|
605 |
void CXmlUiController::ActivateUI()
|
|
606 |
{
|
|
607 |
if ( iRunningAsMain && iAppUi )
|
|
608 |
{
|
|
609 |
iAppUi->ActivateUi();
|
|
610 |
}
|
|
611 |
}
|
|
612 |
|
|
613 |
// ----------------------------------------------------------------------------
|
|
614 |
// CXmlUiController::GetContentObserver()
|
|
615 |
// ----------------------------------------------------------------------------
|
|
616 |
//
|
|
617 |
MAiContentObserver& CXmlUiController::GetContentObserver()
|
|
618 |
{
|
|
619 |
return *iObserver;
|
|
620 |
}
|
|
621 |
|
|
622 |
// ----------------------------------------------------------------------------
|
|
623 |
// CXmlUiController::SetEventHandler()
|
|
624 |
// ----------------------------------------------------------------------------
|
|
625 |
//
|
|
626 |
void CXmlUiController::SetEventHandler( MAiFwEventHandler& aFwEventHandler )
|
|
627 |
{
|
|
628 |
iFwEventHandler = &aFwEventHandler;
|
|
629 |
}
|
|
630 |
|
|
631 |
// ----------------------------------------------------------------------------
|
|
632 |
// CXmlUiController::SetStateHandler()
|
|
633 |
// ----------------------------------------------------------------------------
|
|
634 |
//
|
|
635 |
void CXmlUiController::SetStateHandler( MAiFwStateHandler& aFwStateHandler )
|
|
636 |
{
|
|
637 |
iFwStateHandler = &aFwStateHandler;
|
|
638 |
}
|
|
639 |
|
|
640 |
// ----------------------------------------------------------------------------
|
|
641 |
// CXmlUiController::FwEventHandler()
|
|
642 |
// ----------------------------------------------------------------------------
|
|
643 |
//
|
|
644 |
MAiFwEventHandler* CXmlUiController::FwEventHandler() const
|
|
645 |
{
|
|
646 |
return iFwEventHandler;
|
|
647 |
}
|
|
648 |
|
|
649 |
// ----------------------------------------------------------------------------
|
|
650 |
// CXmlUiController::FwStateHandler()
|
|
651 |
// ----------------------------------------------------------------------------
|
|
652 |
//
|
|
653 |
MAiFwStateHandler* CXmlUiController::FwStateHandler() const
|
|
654 |
{
|
|
655 |
return iFwStateHandler;
|
|
656 |
}
|
|
657 |
|
|
658 |
// ----------------------------------------------------------------------------
|
|
659 |
// CXmlUiController::MainInterface()
|
|
660 |
// ----------------------------------------------------------------------------
|
|
661 |
//
|
|
662 |
MAiMainUiController* CXmlUiController::MainInterface()
|
|
663 |
{
|
|
664 |
return this;
|
|
665 |
}
|
|
666 |
|
|
667 |
// ----------------------------------------------------------------------------
|
|
668 |
// CXmlUiController::SecondaryInterface()
|
|
669 |
// ----------------------------------------------------------------------------
|
|
670 |
//
|
|
671 |
MAiSecondaryUiController* CXmlUiController::SecondaryInterface()
|
|
672 |
{
|
|
673 |
return NULL;
|
|
674 |
}
|
|
675 |
|
|
676 |
// ----------------------------------------------------------------------------
|
|
677 |
// CXmlUiController::RunApplicationL()
|
|
678 |
// ----------------------------------------------------------------------------
|
|
679 |
//
|
|
680 |
void CXmlUiController::RunApplicationL()
|
|
681 |
{
|
|
682 |
__PRINTS( "*** CXmlUiController::RunApplicationL" );
|
|
683 |
|
|
684 |
iRunningAsMain = ETrue;
|
|
685 |
|
|
686 |
User::LeaveIfError(
|
|
687 |
EikStart::RunApplication( &CXmlUiController::NewApplication ) );
|
|
688 |
}
|
|
689 |
|
|
690 |
// ----------------------------------------------------------------------------
|
|
691 |
// CXmlUiController::CoeEnv()
|
|
692 |
// ----------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
CCoeEnv& CXmlUiController::CoeEnv()
|
|
695 |
{
|
|
696 |
__ASSERT_ALWAYS( iAppUi, Panic(ECriticalPointerNull) );
|
|
697 |
return *iAppUi->CoeEnv();
|
|
698 |
}
|
|
699 |
|
|
700 |
// ----------------------------------------------------------------------------
|
|
701 |
// CXmlUiController::IsMenuOpen()
|
|
702 |
// ----------------------------------------------------------------------------
|
|
703 |
//
|
|
704 |
TBool CXmlUiController::IsMenuOpen()
|
|
705 |
{
|
|
706 |
return iAppUi->IsDisplayingMenuOrDialog();
|
|
707 |
}
|
|
708 |
|
|
709 |
// ----------------------------------------------------------------------------
|
|
710 |
// CXmlUiController::HandleUiEvent()
|
|
711 |
// ----------------------------------------------------------------------------
|
|
712 |
//
|
|
713 |
TBool CXmlUiController::HandleUiEvent( TAny* aEvent, const TDesC8& aParam )
|
|
714 |
{
|
|
715 |
CXnNodeAppIf* event( static_cast<CXnNodeAppIf*>( aEvent ) );
|
|
716 |
|
|
717 |
TBool retval( EFalse );
|
|
718 |
|
|
719 |
if( event )
|
|
720 |
{
|
|
721 |
TPtrC8 param1;
|
|
722 |
TPtrC8 param2;
|
|
723 |
const TDesC8& eventString(
|
|
724 |
aParam.Mid( AiUiDef::xml::event::KUiEventPrefix().Length() ) );
|
|
725 |
|
|
726 |
// Extract event name
|
|
727 |
TInt paramPos( eventString.Locate( KEventParameterSeparator ) );
|
|
728 |
|
|
729 |
const TDesC8& eventName( eventString.Left( Max( 0, paramPos ) ) );
|
|
730 |
|
|
731 |
if( eventName == AiUiDef::xml::event::KFocusGained )
|
|
732 |
{
|
|
733 |
// Resolve event parameters
|
|
734 |
ResolveEventParameters( eventString, param1, param2 );
|
|
735 |
|
|
736 |
TRAP_IGNORE( HandleFocusGainedL( param1, param2, *event ) );
|
|
737 |
|
|
738 |
retval = ETrue;
|
|
739 |
}
|
|
740 |
else if( eventName == AiUiDef::xml::event::KSetElementSizeToCPS )
|
|
741 |
{
|
|
742 |
// Resolve event parameters
|
|
743 |
ResolveEventParameters( eventString, param1, param2 );
|
|
744 |
|
|
745 |
TRAP_IGNORE( HandleSetElementSizeL( param1, *event ));
|
|
746 |
|
|
747 |
retval = ETrue;
|
|
748 |
}
|
|
749 |
}
|
|
750 |
|
|
751 |
return retval;
|
|
752 |
}
|
|
753 |
|
|
754 |
// ----------------------------------------------------------------------------
|
|
755 |
// CXmlUiController::HandleSetElementSizeL()
|
|
756 |
// ----------------------------------------------------------------------------
|
|
757 |
//
|
|
758 |
void CXmlUiController::HandleSetElementSizeL( const TDesC8& aElementName,
|
|
759 |
CXnNodeAppIf& aOrigin )
|
|
760 |
{
|
|
761 |
__UHEAP_MARK;
|
|
762 |
// Resolve ui elements
|
|
763 |
CXnNodeAppIf* element(
|
|
764 |
UiEngineL()->FindNodeByIdL( aElementName, aOrigin.Namespace() ) );
|
|
765 |
|
|
766 |
LeaveIfNull( element, KErrNotFound );
|
|
767 |
|
|
768 |
TRect rect( element->Rect() );
|
|
769 |
|
|
770 |
HBufC* elementName( NULL );
|
|
771 |
elementName = AiUtility::CopyToBufferL( elementName, aElementName );
|
|
772 |
CleanupStack::PushL( elementName );
|
|
773 |
|
|
774 |
iCPSpublisher->PublishSizeL( *elementName, rect.Width(), rect.Height() );
|
|
775 |
|
|
776 |
CleanupStack::PopAndDestroy( elementName );
|
|
777 |
|
|
778 |
__UHEAP_MARKEND;
|
|
779 |
}
|
|
780 |
|
|
781 |
// ----------------------------------------------------------------------------
|
|
782 |
// CXmlUiController::HandleFocusGainedL()
|
|
783 |
// ----------------------------------------------------------------------------
|
|
784 |
//
|
|
785 |
void CXmlUiController::HandleFocusGainedL( const TDesC8& aUiElement1,
|
|
786 |
const TDesC8& aUiElement2, CXnNodeAppIf& aOrigin )
|
|
787 |
{
|
|
788 |
// Resolve ui elements
|
|
789 |
CXnNodeAppIf* element1(
|
|
790 |
UiEngineL()->FindNodeByIdL( aUiElement1, aOrigin.Namespace() ) );
|
|
791 |
|
|
792 |
LeaveIfNull( element1, KErrNotFound );
|
|
793 |
|
|
794 |
CXnNodeAppIf* element2(
|
|
795 |
UiEngineL()->FindNodeByIdL( aUiElement2, aOrigin.Namespace() ) );
|
|
796 |
|
|
797 |
LeaveIfNull( element2, KErrNotFound );
|
|
798 |
|
|
799 |
// swap display properties between ui elements
|
|
800 |
CXnProperty* display1(
|
|
801 |
element1->GetPropertyL( XnPropertyNames::style::common::KDisplay ) );
|
|
802 |
|
|
803 |
LeaveIfNull( display1, KErrNotFound );
|
|
804 |
|
|
805 |
CXnProperty* display2(
|
|
806 |
element2->GetPropertyL( XnPropertyNames::style::common::KDisplay ) );
|
|
807 |
|
|
808 |
LeaveIfNull( display2, KErrNotFound );
|
|
809 |
|
|
810 |
display1 = display1->CloneL();
|
|
811 |
CleanupStack::PushL( display1 );
|
|
812 |
|
|
813 |
display2 = display2->CloneL();
|
|
814 |
CleanupStack::PushL( display2 );
|
|
815 |
|
|
816 |
element1->SetPropertyL( display2 );
|
|
817 |
CleanupStack::Pop( display2 );
|
|
818 |
|
|
819 |
element2->SetPropertyL( display1 );
|
|
820 |
CleanupStack::Pop( display1 );
|
|
821 |
}
|
|
822 |
|
|
823 |
// ----------------------------------------------------------------------------
|
|
824 |
// CXmlUiController::NewApplication()
|
|
825 |
// ----------------------------------------------------------------------------
|
|
826 |
//
|
|
827 |
CApaApplication* CXmlUiController::NewApplication()
|
|
828 |
{
|
|
829 |
__TICK( "CXmlUiController::NewApplication" );
|
|
830 |
__TIME_MARK( time );
|
|
831 |
|
|
832 |
CXmlUiController* self = static_cast< CXmlUiController* >( Dll::Tls() );
|
|
833 |
|
|
834 |
__ASSERT_ALWAYS( self, Panic( ECriticalPointerNull ) );
|
|
835 |
|
|
836 |
CApplication* app = CApplication::New( *self );
|
|
837 |
|
|
838 |
__TIME_ENDMARK( "CXmlUiController::NewApplication, done", time );
|
|
839 |
|
|
840 |
return app;
|
|
841 |
}
|
|
842 |
|
|
843 |
const TImplementationProxy KImplementationTable[] =
|
|
844 |
{
|
|
845 |
IMPLEMENTATION_PROXY_ENTRY(KImplementationUidXmlUiController, CXmlUiController::NewL)
|
|
846 |
};
|
|
847 |
|
|
848 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
|
849 |
{
|
|
850 |
aTableCount = sizeof(KImplementationTable) / sizeof(TImplementationProxy);
|
|
851 |
return KImplementationTable;
|
|
852 |
}
|
|
853 |
|