author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:58:58 +0300 | |
branch | RCL_3 |
changeset 35 | 3321d3e205b6 |
parent 34 | 5456b4e8b3a8 |
permissions | -rw-r--r-- |
34 | 1 |
/* |
2 |
* Copyright (c) 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: Manages Ai3 personalization |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <StringLoader.h> |
|
20 |
#include <aknlistquerydialog.h> |
|
21 |
#include <aknnotewrappers.h> |
|
22 |
#include <utf.h> |
|
23 |
#include <AknsWallpaperUtils.h> |
|
24 |
#include <centralrepository.h> |
|
25 |
#include <AknSkinsInternalCRKeys.h> |
|
26 |
#include "../../../inc/ai3.hrh" |
|
27 |
||
28 |
#include <xnuiengine.rsg> |
|
29 |
#include <hscontentcontrolui.h> |
|
30 |
#include <hscontentcontrol.h> |
|
31 |
#include <activeidle2domaincrkeys.h> |
|
32 |
||
33 |
// User includes |
|
34 |
#include "xnuiengine.h" |
|
35 |
#include "xnproperty.h" |
|
36 |
#include "xnnode.h" |
|
37 |
#include "xntype.h" |
|
38 |
#include "xntext.h" |
|
39 |
#include "xnappuiadapter.h" |
|
40 |
||
41 |
#include "xndomnode.h" |
|
42 |
#include "xndomproperty.h" |
|
43 |
#include "xndompropertyvalue.h" |
|
44 |
#include "xndomlist.h" |
|
45 |
#include "xndomattribute.h" |
|
46 |
#include "hspssapi.h" |
|
47 |
#include "cpssapi.h" |
|
48 |
#include "xneditmode.h" |
|
49 |
#include "xndomdocument.h" |
|
50 |
#include "xnnodeimpl.h" |
|
51 |
#include "xnodt.h" |
|
52 |
#include "xnplugindefs.h" |
|
53 |
||
54 |
#include "xnviewmanager.h" |
|
55 |
#include "xnplugindata.h" |
|
56 |
#include "xnrootdata.h" |
|
57 |
#include "xnviewdata.h" |
|
58 |
#include "xnwallpaperview.h" |
|
59 |
#include "xnbackgroundmanager.h" |
|
60 |
#include "xnpopupcontroladapter.h" |
|
61 |
||
62 |
#include "xneditor.h" |
|
63 |
#include "xnpanic.h" |
|
64 |
||
65 |
#include "xnoomsyshandler.h" |
|
66 |
||
67 |
using namespace hspswrapper; |
|
68 |
using namespace cpswrapper; |
|
69 |
||
70 |
// LOCAL CONSTANTS AND MACROS |
|
71 |
_LIT8( KEventPluginUnInstalled, "PluginUninstalled" ); |
|
72 |
_LIT8( KEventRootConfActivated, "AppConfActivated" ); |
|
73 |
_LIT8( KEventPluginUpdated, "PluginUpdated" ); |
|
74 |
_LIT8( KEventPluginInstalled, "PluginInstalled" ); |
|
75 |
||
76 |
_LIT8( KEmptyWidgetUid, "0x2001F47F" ); |
|
77 |
_LIT8( KDownload, "Editor/DownloadCaption" ); |
|
78 |
||
79 |
_LIT8( KSingle, "single" ); |
|
80 |
_LIT8( KMulti, "multi" ); |
|
81 |
||
82 |
||
83 |
const TInt32 KMultiInstanceUnlimitedValue = -1; |
|
84 |
||
85 |
const TUid KDummyUid = { 0x0000000 }; |
|
86 |
||
87 |
const TUint32 KAICCPluginUIDKey = 0x00003010; |
|
88 |
const TInt32 KOpaQDataLen = 10; |
|
89 |
||
90 |
enum |
|
91 |
{ |
|
92 |
ECanBeAdded = 0x01, |
|
93 |
ECanBeRemoved |
|
94 |
}; |
|
95 |
||
96 |
const TInt KNotifyWidgetListChangedDelay( 1000000 ); //1sec |
|
97 |
const TInt KNotifyViewListChangedDelay( 1000000 ); //1sec |
|
98 |
||
99 |
// ====================== LOCAL FUNTION PROTOTYPES ============================ |
|
100 |
static void DeletePluginInfos( TAny* aObject ); |
|
101 |
static void DeleteItemMaps( TAny* aObject ); |
|
102 |
static void DeleteContentInfo( TAny* aObject ); |
|
103 |
||
104 |
static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo ); |
|
105 |
static void SetPropertyL( CXnNode& aNode, const TDesC8& aAttribute, |
|
106 |
const TDesC8& aValue ); |
|
107 |
static void ShowErrorNoteL( const TDesC& aMsg ); |
|
108 |
static CXnPluginData* DeterminePlugin( CXnViewManager& aViewManager, |
|
109 |
CXnNode* aPredicate = NULL ); |
|
110 |
static CXnPluginData* DeterminePlugin( |
|
111 |
RPointerArray< CXnPluginData >& aPlugins, |
|
112 |
const CHsContentInfo& aContentInfo ); |
|
113 |
||
114 |
// ============================ LOCAL FUNCTIONS =============================== |
|
115 |
||
116 |
// --------------------------------------------------------------------------- |
|
117 |
// DeletePluginInfos |
|
118 |
// --------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
static void DeletePluginInfos( TAny* aObject ) |
|
121 |
{ |
|
122 |
reinterpret_cast< |
|
123 |
RPointerArray< hspswrapper::CPluginInfo >* >( |
|
124 |
aObject )->ResetAndDestroy(); |
|
125 |
} |
|
126 |
||
127 |
// --------------------------------------------------------------------------- |
|
128 |
// DeleteItemMaps |
|
129 |
// --------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
static void DeleteItemMaps( TAny* aObject ) |
|
132 |
{ |
|
133 |
reinterpret_cast< |
|
134 |
RPointerArray< hspswrapper::CItemMap >* >( |
|
135 |
aObject )->ResetAndDestroy(); |
|
136 |
} |
|
137 |
||
138 |
// --------------------------------------------------------------------------- |
|
139 |
// DeleteContentInfo |
|
140 |
// --------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
static void DeleteContentInfo( TAny* aObject ) |
|
143 |
{ |
|
144 |
reinterpret_cast<RPointerArray< CHsContentInfo >* >( |
|
145 |
aObject )->ResetAndDestroy(); |
|
146 |
} |
|
147 |
||
148 |
// --------------------------------------------------------------------------- |
|
149 |
// ParseWidgetName |
|
150 |
// --------------------------------------------------------------------------- |
|
151 |
// |
|
152 |
static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo ) |
|
153 |
{ |
|
154 |
TPtrC retval( aContentInfo.Name() ); |
|
155 |
||
156 |
TInt pos( retval.Locate( ':' ) ); |
|
157 |
||
158 |
if ( pos != KErrNotFound ) |
|
159 |
{ |
|
160 |
retval.Set( retval.Right( retval.Length() - pos - 1 ) ); |
|
161 |
} |
|
162 |
||
163 |
return retval; |
|
164 |
} |
|
165 |
||
166 |
// --------------------------------------------------------------------------- |
|
167 |
// SetPropertyL |
|
168 |
// --------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
static void SetPropertyL( CXnNode& aNode, |
|
171 |
const TDesC8& aAttribute, const TDesC8& aValue ) |
|
172 |
{ |
|
173 |
CXnDomNode* node( aNode.DomNode() ); |
|
174 |
||
175 |
if ( node ) |
|
176 |
{ |
|
177 |
CXnDomStringPool* sp( node->StringPool() ); |
|
178 |
||
179 |
// create new property |
|
180 |
CXnDomPropertyValue* value = CXnDomPropertyValue::NewL( sp ); |
|
181 |
CleanupStack::PushL( value ); |
|
182 |
||
183 |
value->SetStringValueL( CXnDomPropertyValue::EString, aValue ); |
|
184 |
||
185 |
CXnProperty* prop = CXnProperty::NewL( aAttribute, value, *sp ); |
|
186 |
||
187 |
CleanupStack::Pop( value ); |
|
188 |
CleanupStack::PushL( prop ); |
|
189 |
||
190 |
aNode.SetPropertyL( prop ); |
|
191 |
||
192 |
CleanupStack::Pop( prop ); |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
// --------------------------------------------------------------------------- |
|
197 |
// ShowErrorNoteL |
|
198 |
// --------------------------------------------------------------------------- |
|
199 |
// |
|
200 |
static void ShowErrorNoteL( const TDesC& aMsg ) |
|
201 |
{ |
|
202 |
CAknErrorNote* note = new ( ELeave ) CAknErrorNote; |
|
203 |
CleanupStack::PushL( note ); |
|
204 |
||
205 |
note->ExecuteLD( aMsg ); |
|
206 |
||
207 |
CleanupStack::Pop( note ); |
|
208 |
} |
|
209 |
||
210 |
// --------------------------------------------------------------------------- |
|
211 |
// DeterminePlugin |
|
212 |
// Determinates target plugin where widget should be added |
|
213 |
// --------------------------------------------------------------------------- |
|
214 |
// |
|
215 |
CXnPluginData* DeterminePlugin( CXnViewManager& aViewManager, |
|
216 |
CXnNode* aPredicate ) |
|
217 |
{ |
|
218 |
CXnViewData& viewData( aViewManager.ActiveViewData() ); |
|
219 |
||
220 |
if ( aPredicate ) |
|
221 |
{ |
|
222 |
CXnPluginData* plugin( viewData.Plugin( aPredicate ) ); |
|
223 |
||
224 |
if ( plugin && !plugin->Occupied() ) |
|
225 |
{ |
|
226 |
return plugin; |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
RPointerArray< CXnNode >& nodes( aViewManager.PluginNodes() ); |
|
231 |
||
232 |
for ( TInt i = 0; i < nodes.Count(); i++ ) |
|
233 |
{ |
|
234 |
CXnNode* node( nodes[i] ); |
|
235 |
||
236 |
CXnPluginData* plugin( viewData.Plugin( node ) ); |
|
237 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
238 |
if ( plugin && !plugin->Occupied() && plugin->Editable() ) |
34 | 239 |
{ |
240 |
return plugin; |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
return NULL; |
|
245 |
} |
|
246 |
||
247 |
// --------------------------------------------------------------------------- |
|
248 |
// DeterminePlugin |
|
249 |
// Determines target plugin based widget info |
|
250 |
// --------------------------------------------------------------------------- |
|
251 |
// |
|
252 |
CXnPluginData* DeterminePlugin( RPointerArray< CXnPluginData >& aPlugins, |
|
253 |
const CHsContentInfo& aContentInfo ) |
|
254 |
{ |
|
255 |
for ( TInt i = 0; i < aPlugins.Count(); i++ ) |
|
256 |
{ |
|
257 |
CXnPluginData* plugin( aPlugins[i] ); |
|
258 |
||
259 |
if ( plugin->Occupied() && plugin->PluginId() == aContentInfo.PluginId() ) |
|
260 |
{ |
|
261 |
return plugin; |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
return NULL; |
|
266 |
} |
|
267 |
||
268 |
// ============================ MEMBER FUNCTIONS =============================== |
|
269 |
||
270 |
// --------------------------------------------------------------------------- |
|
271 |
// CXnEditor::NewL |
|
272 |
// --------------------------------------------------------------------------- |
|
273 |
// |
|
274 |
CXnEditor* CXnEditor::NewL( CXnViewManager& aViewManager, |
|
275 |
const TDesC8& aUid ) |
|
276 |
{ |
|
277 |
CXnEditor* self = CXnEditor::NewLC( aViewManager, aUid ); |
|
278 |
CleanupStack::Pop( self ); |
|
279 |
return self; |
|
280 |
} |
|
281 |
||
282 |
// --------------------------------------------------------------------------- |
|
283 |
// CXnEditor::NewLC |
|
284 |
// --------------------------------------------------------------------------- |
|
285 |
// |
|
286 |
CXnEditor* CXnEditor::NewLC( CXnViewManager& aViewManager, |
|
287 |
const TDesC8& aUid ) |
|
288 |
{ |
|
289 |
CXnEditor* self = new ( ELeave ) CXnEditor( aViewManager ); |
|
290 |
CleanupStack::PushL( self ); |
|
291 |
self->ConstructL( aUid ); |
|
292 |
return self; |
|
293 |
} |
|
294 |
||
295 |
// --------------------------------------------------------------------------- |
|
296 |
// CXnEditor::CXnEditor |
|
297 |
// --------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
CXnEditor::CXnEditor( CXnViewManager& aViewManager ) |
|
300 |
: iViewManager( aViewManager ), |
|
301 |
iWidgetsVisibilityState( ETrue ) |
|
302 |
{ |
|
303 |
iViewManager.AddObserver( *this ); |
|
304 |
} |
|
305 |
||
306 |
// --------------------------------------------------------------------------- |
|
307 |
// CXnEditor::ConstructL |
|
308 |
// --------------------------------------------------------------------------- |
|
309 |
// |
|
310 |
void CXnEditor::ConstructL( const TDesC8& aUid ) |
|
311 |
{ |
|
312 |
iCpsWrapper = CCpsWrapper::NewL( *this ); |
|
313 |
iHspsWrapper = CHspsWrapper::NewL( aUid, this ); |
|
314 |
iRepository= CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
315 |
iOomSysHandler = CXnOomSysHandler::NewL(); |
|
316 |
iNotifyWidgetListChanged = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
317 |
iNotifyViewListChanged = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
318 |
} |
|
319 |
||
320 |
// --------------------------------------------------------------------------- |
|
321 |
// CXnEditor::~CXnEditor |
|
322 |
// --------------------------------------------------------------------------- |
|
323 |
// |
|
324 |
CXnEditor::~CXnEditor() |
|
325 |
{ |
|
326 |
if ( iNotifyWidgetListChanged && |
|
327 |
iNotifyWidgetListChanged->IsActive() ) |
|
328 |
{ |
|
329 |
iNotifyWidgetListChanged->Cancel(); |
|
330 |
} |
|
331 |
delete iNotifyWidgetListChanged; |
|
332 |
||
333 |
if ( iNotifyViewListChanged && |
|
334 |
iNotifyViewListChanged->IsActive() ) |
|
335 |
{ |
|
336 |
iNotifyViewListChanged->Cancel(); |
|
337 |
} |
|
338 |
delete iNotifyViewListChanged; |
|
339 |
||
340 |
iViewManager.RemoveObserver( *this ); |
|
341 |
if( iPluginConfigurations.Count() ) |
|
342 |
{ |
|
343 |
iPluginConfigurations.ResetAndDestroy(); |
|
344 |
} |
|
345 |
delete iCpsWrapper; |
|
346 |
delete iHspsWrapper; |
|
347 |
delete iPublisherMap; |
|
348 |
delete iRepository; |
|
349 |
delete iOomSysHandler; |
|
350 |
} |
|
351 |
||
352 |
// ----------------------------------------------------------------------------- |
|
353 |
// CXnEditor::IsCurrentViewFull |
|
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// |
|
356 |
TBool CXnEditor::IsCurrentViewFull() |
|
357 |
{ |
|
358 |
return IsViewFull( iViewManager.ActiveViewData() ); |
|
359 |
} |
|
360 |
||
361 |
// ----------------------------------------------------------------------------- |
|
362 |
// CXnEditor::FilterPluginsL |
|
363 |
// ----------------------------------------------------------------------------- |
|
364 |
// |
|
365 |
void CXnEditor::FilterPluginsL( CHsContentInfoArray& aContentInfoArray, |
|
366 |
TBool aIgnoreViewFull ) |
|
367 |
{ |
|
368 |
RPointerArray< CHsContentInfo >& list( aContentInfoArray.Array() ); |
|
369 |
||
370 |
TBool viewFull = ( aIgnoreViewFull ? EFalse : IsCurrentViewFull() ); |
|
371 |
||
372 |
for ( TInt i = 0; i < list.Count(); i++ ) |
|
373 |
{ |
|
374 |
CHsContentInfo* info( list[i] ); |
|
375 |
||
376 |
info->SetCanBeAdded( EFalse ); |
|
377 |
info->SetCanBeRemoved( EFalse ); |
|
378 |
||
379 |
TInt result( 0 ); |
|
380 |
||
381 |
if ( info->Type() != KKeyTemplate() ) |
|
382 |
{ |
|
383 |
result = NonTemplateWidgetCanBeAddedRemovedL( *info ); |
|
384 |
} |
|
385 |
else |
|
386 |
{ |
|
387 |
result = TemplateWidgetCanBeAddedRemovedL( *info ); |
|
388 |
} |
|
389 |
||
390 |
if ( ( result & ECanBeAdded ) && !viewFull ) |
|
391 |
{ |
|
392 |
info->SetCanBeAdded( ETrue ); |
|
393 |
} |
|
394 |
||
395 |
if ( result & ECanBeRemoved ) |
|
396 |
{ |
|
397 |
info->SetCanBeRemoved( ETrue ); |
|
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
// --------------------------------------------------------------------------- |
|
403 |
// CXnEditor::TemplateWidgetCanBeAddedRemovedL |
|
404 |
// --------------------------------------------------------------------------- |
|
405 |
// |
|
406 |
TInt CXnEditor::TemplateWidgetCanBeAddedRemovedL( |
|
407 |
CHsContentInfo& aInfo ) |
|
408 |
{ |
|
409 |
TInt retval( 0 ); |
|
410 |
||
411 |
TInt widgetCount( 0 ); |
|
412 |
||
413 |
RPointerArray< CXnPluginData > plugins; |
|
414 |
CleanupClosePushL( plugins ); |
|
415 |
||
416 |
if ( aInfo.IsWrt() ) |
|
417 |
{ |
|
418 |
// Get plugins globally from all pages |
|
419 |
iViewManager.PluginDataL( plugins, ETrue ); |
|
420 |
} |
|
421 |
else |
|
422 |
{ |
|
423 |
// Get plugins from current page |
|
424 |
iViewManager.PluginDataL( plugins, EFalse ); |
|
425 |
} |
|
426 |
||
427 |
// Get widgets in current configuration |
|
428 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
429 |
{ |
|
430 |
CXnPluginData* plugin( plugins[i] ); |
|
431 |
||
432 |
if ( !plugin->Occupied() ) |
|
433 |
{ |
|
434 |
continue; |
|
435 |
} |
|
436 |
||
437 |
if ( plugin->PublisherName() == aInfo.PublisherId() ) |
|
438 |
{ |
|
439 |
widgetCount++; |
|
440 |
} |
|
441 |
} |
|
442 |
||
443 |
if ( widgetCount < aInfo.MaxWidgets() ) |
|
444 |
{ |
|
445 |
retval |= ECanBeAdded; |
|
446 |
} |
|
447 |
||
448 |
CleanupStack::PopAndDestroy( &plugins ); |
|
449 |
||
450 |
return retval; |
|
451 |
} |
|
452 |
||
453 |
// --------------------------------------------------------------------------- |
|
454 |
// CXnEditor::NonTemplateWidgetCanBeAddedRemovedL |
|
455 |
// |
|
456 |
// --------------------------------------------------------------------------- |
|
457 |
// |
|
458 |
TInt CXnEditor::NonTemplateWidgetCanBeAddedRemovedL( |
|
459 |
CHsContentInfo& aInfo ) |
|
460 |
{ |
|
461 |
TInt retval( 0 ); |
|
462 |
||
463 |
TInt widgetCount( 0 ); |
|
464 |
||
465 |
CXnViewData& activeView( iViewManager.ActiveViewData() ); |
|
466 |
||
467 |
RPointerArray< CXnPluginData >& plugins( activeView.PluginData() ); |
|
468 |
||
469 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
470 |
{ |
|
471 |
CXnPluginData* plugin( plugins[i] ); |
|
472 |
||
473 |
if ( !plugin->Occupied() ) |
|
474 |
{ |
|
475 |
continue; |
|
476 |
} |
|
477 |
||
478 |
if ( plugin->PluginUid().CompareF( aInfo.Uid() ) == 0 ) |
|
479 |
{ |
|
480 |
widgetCount++; |
|
481 |
} |
|
482 |
} |
|
483 |
||
484 |
if ( widgetCount < aInfo.MaxWidgets() || |
|
485 |
aInfo.MaxWidgets() == KMultiInstanceUnlimitedValue ) |
|
486 |
{ |
|
487 |
retval |= ECanBeAdded; |
|
488 |
} |
|
489 |
||
490 |
return retval; |
|
491 |
} |
|
492 |
||
493 |
||
494 |
// --------------------------------------------------------------------------- |
|
495 |
// CXnEditor::FilterViewListL |
|
496 |
// --------------------------------------------------------------------------- |
|
497 |
// |
|
498 |
void CXnEditor::FilterViewListL( CHsContentInfoArray& aContentInfoArray ) |
|
499 |
{ |
|
500 |
RPointerArray< CHsContentInfo >& list( aContentInfoArray.Array() ); |
|
501 |
||
502 |
TBool canBeAdded( EFalse ); |
|
503 |
CXnRootData& appData( iViewManager.ActiveAppData() ); |
|
504 |
if ( appData.PluginData().Count() < appData.MaxPages() ) |
|
505 |
{ |
|
506 |
canBeAdded = ETrue; |
|
507 |
} |
|
508 |
||
509 |
for ( TInt i = 0; i < list.Count(); i++ ) |
|
510 |
{ |
|
511 |
CHsContentInfo* info( list[i] ); |
|
512 |
info->SetCanBeAdded( canBeAdded ); |
|
513 |
} |
|
514 |
} |
|
515 |
||
516 |
// --------------------------------------------------------------------------- |
|
517 |
// CXnEditor::RemoveUnRegisteredWidgetL |
|
518 |
// --------------------------------------------------------------------------- |
|
519 |
// |
|
520 |
void CXnEditor::RemoveUnRegisteredWidgetL( const TDesC16& aPublisher ) |
|
521 |
{ |
|
522 |
RPointerArray< CXnPluginData > plugins; |
|
523 |
CleanupClosePushL( plugins ); |
|
524 |
||
525 |
iViewManager.PluginDataL( plugins, ETrue ); |
|
526 |
||
527 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
528 |
{ |
|
529 |
CXnPluginData* plugin( plugins[i] ); |
|
530 |
||
531 |
if( plugin->Occupied() && plugin->PublisherName() == aPublisher ) |
|
532 |
{ |
|
533 |
iViewManager.UnloadWidgetFromPluginL( *plugin ); |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
CleanupStack::PopAndDestroy( &plugins ); |
|
538 |
} |
|
539 |
||
540 |
// --------------------------------------------------------------------------- |
|
541 |
// CXnEditor::RemoveUnInstalledWidgetL |
|
542 |
// --------------------------------------------------------------------------- |
|
543 |
// |
|
544 |
void CXnEditor::RemoveUnInstalledWidgetL( const CHsContentInfo& aContentInfo ) |
|
545 |
{ |
|
546 |
RPointerArray< CXnPluginData > plugins; |
|
547 |
CleanupClosePushL( plugins ); |
|
548 |
||
549 |
iViewManager.PluginDataL( plugins, ETrue ); |
|
550 |
||
551 |
CXnPluginData* plugin( DeterminePlugin( plugins, aContentInfo ) ); |
|
552 |
||
553 |
if ( plugin ) |
|
554 |
{ |
|
555 |
iViewManager.UnloadWidgetFromPluginL( *plugin ); |
|
556 |
} |
|
557 |
||
558 |
CleanupStack::PopAndDestroy( &plugins ); |
|
559 |
} |
|
560 |
||
561 |
// --------------------------------------------------------------------------- |
|
562 |
// CXnEditor::ReplaceWidgetL |
|
563 |
// --------------------------------------------------------------------------- |
|
564 |
// |
|
565 |
void CXnEditor::ReplaceWidgetL( CHsContentInfo& aContentInfo ) |
|
566 |
{ |
|
567 |
RPointerArray< CXnPluginData > plugins; |
|
568 |
CleanupClosePushL( plugins ); |
|
569 |
||
570 |
iViewManager.PluginDataL( plugins, ETrue ); |
|
571 |
||
572 |
CXnPluginData* match = NULL; |
|
573 |
||
574 |
for( TInt i = 0; i < plugins.Count(); i++ ) |
|
575 |
{ |
|
576 |
CXnPluginData* plugin( plugins[i] ); |
|
577 |
||
578 |
if( plugin->PluginId() == aContentInfo.PluginId() ) |
|
579 |
{ |
|
580 |
if ( aContentInfo.Type() == KNullDesC8 ) |
|
581 |
{ |
|
582 |
aContentInfo.SetTypeL( plugin->Type() ); |
|
583 |
} |
|
584 |
||
585 |
if ( aContentInfo.PublisherId() == KNullDesC ) |
|
586 |
{ |
|
587 |
aContentInfo.SetPublisherIdL( plugin->PublisherName() ); |
|
588 |
} |
|
589 |
match = plugin; |
|
590 |
break; |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
if( match ) |
|
595 |
{ |
|
596 |
iViewManager.ReplaceWidgetToPluginL( aContentInfo, *match ); |
|
597 |
} |
|
598 |
||
599 |
CleanupStack::PopAndDestroy( &plugins ); |
|
600 |
} |
|
601 |
||
602 |
// --------------------------------------------------------------------------- |
|
603 |
// CXnEditor::IdFromCrep |
|
604 |
// --------------------------------------------------------------------------- |
|
605 |
// |
|
606 |
TInt CXnEditor::IdFromCrep (TDes8& aUid) const |
|
607 |
{ |
|
608 |
return iRepository->Get( KAICCPluginUIDKey, aUid ); |
|
609 |
} |
|
610 |
||
611 |
// --------------------------------------------------------------------------- |
|
612 |
// CXnEditor::AddWidgetL |
|
613 |
// --------------------------------------------------------------------------- |
|
614 |
// |
|
615 |
void CXnEditor::AddWidgetL() |
|
616 |
{ |
|
617 |
if ( !CXnOomSysHandler::HeapAvailable( VIEW_MIN_MEM ) ) |
|
618 |
{ |
|
619 |
OomSysHandler().HandlePotentialOomL(); |
|
620 |
return; |
|
621 |
} |
|
622 |
||
623 |
TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8(); |
|
624 |
||
625 |
MHsContentControlUi* ui( NULL ); |
|
626 |
if ( IdFromCrep ( oPaqDataStr ) == KErrNone ) |
|
627 |
{ |
|
628 |
ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); |
|
629 |
} |
|
630 |
if( ui ) |
|
631 |
{ |
|
632 |
CXnNode* popup( iViewManager.UiEngine().StylusPopupNode() ); |
|
633 |
if ( popup ) |
|
634 |
{ |
|
635 |
CXnPopupControlAdapter* control = |
|
636 |
static_cast< CXnPopupControlAdapter* >( |
|
637 |
popup->Control() ); |
|
638 |
||
639 |
if ( control ) |
|
640 |
{ |
|
641 |
control->HideMenuL(); |
|
642 |
} |
|
643 |
} |
|
644 |
ui->SetContentController( this ); |
|
645 |
ui->Activate(); |
|
646 |
||
647 |
return; |
|
648 |
} |
|
649 |
||
650 |
CXnPluginData* plugin( NULL ); |
|
651 |
||
652 |
if ( iTargetPlugin ) |
|
653 |
{ |
|
654 |
plugin = DeterminePlugin( iViewManager, iTargetPlugin ); |
|
655 |
} |
|
656 |
else |
|
657 |
{ |
|
658 |
plugin = DeterminePlugin( iViewManager ); |
|
659 |
} |
|
660 |
||
661 |
iTargetPlugin = NULL; |
|
662 |
||
663 |
CHsContentInfoArray* info = CHsContentInfoArray::NewL(); |
|
664 |
CleanupStack::PushL( info ); |
|
665 |
||
666 |
RPointerArray< CHsContentInfo >& widgets( info->Array() ); |
|
667 |
||
668 |
// get installed widgets and template configurations from HSPS |
|
669 |
HspsWidgetPluginsL( widgets ); |
|
670 |
||
671 |
// get installed widgets from HSPS (type: "template") |
|
672 |
CpsWidgetPluginsL( widgets ); |
|
673 |
||
674 |
// check whether the plugins can be added or removed |
|
675 |
FilterPluginsL( *info, ETrue ); |
|
676 |
||
677 |
CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( 8 ); |
|
678 |
CleanupStack::PushL( array ); |
|
679 |
||
680 |
for ( TInt i = 0; i < widgets.Count(); i++ ) |
|
681 |
{ |
|
682 |
CHsContentInfo* widget( widgets[i] ); |
|
683 |
||
684 |
if ( widget->CanBeAdded() ) |
|
685 |
{ |
|
686 |
TPtrC name( ParseWidgetName( *widget ) ); |
|
687 |
||
688 |
array->InsertIsqAllowDuplicatesL( name ); |
|
689 |
} |
|
690 |
} |
|
691 |
||
692 |
const TDesC8& ns( iViewManager.ViewNode()->Namespace() ); |
|
693 |
||
694 |
CXnNode* link( iViewManager.UiEngine().FindNodeByIdL( KDownload, ns ) ); |
|
695 |
||
696 |
if ( link ) |
|
697 |
{ |
|
698 |
CXnText* textIf( NULL ); |
|
699 |
||
700 |
XnComponentInterface::MakeInterfaceL( textIf, link->AppIfL() ); |
|
701 |
||
702 |
if ( textIf ) |
|
703 |
{ |
|
704 |
const TDesC* text( textIf->Text() ); |
|
705 |
||
706 |
if ( text ) |
|
707 |
{ |
|
708 |
// First item is always Download link |
|
709 |
array->InsertL( 0, *text ); |
|
710 |
} |
|
711 |
} |
|
712 |
} |
|
713 |
||
714 |
// Display dialog |
|
715 |
TInt selectedIndex( 0 ); |
|
716 |
||
717 |
CAknListQueryDialog* query = |
|
718 |
new ( ELeave ) CAknListQueryDialog( &selectedIndex ); |
|
719 |
||
720 |
query->PrepareLC( R_LISTQUERY_ADD_WIDGET ); |
|
721 |
||
722 |
query->SetItemTextArray( array ); |
|
723 |
query->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
724 |
||
725 |
// Save dialog pointer for later usage |
|
726 |
iQuery = query; |
|
727 |
||
728 |
TBool linkSelected( EFalse ); |
|
729 |
||
730 |
if ( query->RunLD() ) |
|
731 |
{ |
|
732 |
// Download link is always the first one, if it is defined |
|
733 |
if ( link && selectedIndex == 0 ) |
|
734 |
{ |
|
735 |
// Activate download link shortcut |
|
736 |
link->SetStateL( XnPropertyNames::style::common::KActive ); |
|
737 |
link->UnsetStateL( XnPropertyNames::style::common::KActive ); |
|
738 |
||
739 |
linkSelected = ETrue; |
|
740 |
} |
|
741 |
else |
|
742 |
{ |
|
743 |
if ( !plugin ) |
|
744 |
{ |
|
745 |
// No room for new widget, so error note. |
|
746 |
HBufC* msg = StringLoader::LoadLC( R_QTN_HS_ADD_WIDGET_FULL ); |
|
747 |
ShowErrorNoteL( *msg ); |
|
748 |
CleanupStack::PopAndDestroy( msg ); |
|
749 |
} |
|
750 |
} |
|
751 |
||
752 |
const TDesC& selectedName( ( *array )[selectedIndex] ); |
|
753 |
||
754 |
for ( TInt i = 0; plugin && !linkSelected && i < widgets.Count(); i++ ) |
|
755 |
{ |
|
756 |
CHsContentInfo* widget( widgets[i] ); |
|
757 |
||
758 |
TPtrC name( ParseWidgetName( *widget ) ); |
|
759 |
||
760 |
if ( selectedName == name ) |
|
761 |
{ |
|
762 |
TInt ret( iViewManager.LoadWidgetToPluginL( *widget, *plugin ) ); |
|
763 |
||
764 |
if ( ret == KErrNone ) |
|
765 |
{ |
|
766 |
CXnNode *node( plugin->Owner()->LayoutNode() ); |
|
767 |
||
768 |
// Analyse added widget |
|
769 |
TBool widgetOk( iViewManager.UiEngine().AnalyseAddedWidgetL( |
|
770 |
*node ) ); |
|
771 |
||
772 |
if ( !widgetOk ) |
|
773 |
{ |
|
774 |
iViewManager.UnloadWidgetFromPluginL( *plugin ); |
|
775 |
||
776 |
// Widget doesn't fit to UI |
|
777 |
HBufC* msg = StringLoader::LoadLC( |
|
778 |
R_QTN_HS_ADD_WIDGET_FULL ); |
|
779 |
||
780 |
ShowErrorNoteL( *msg ); |
|
781 |
||
782 |
CleanupStack::PopAndDestroy( msg ); |
|
783 |
} |
|
784 |
} |
|
785 |
||
786 |
break; |
|
787 |
} |
|
788 |
} |
|
789 |
} |
|
790 |
||
791 |
// Dialog ended and deleted by RunLD |
|
792 |
iQuery = NULL; |
|
793 |
||
794 |
CleanupStack::PopAndDestroy( 2, info ); // array |
|
795 |
} |
|
796 |
||
797 |
// --------------------------------------------------------------------------- |
|
798 |
// CXnEditor::RemoveWidgetL |
|
799 |
// --------------------------------------------------------------------------- |
|
800 |
// |
|
801 |
void CXnEditor::RemoveWidgetL( CXnNode* aNode ) |
|
802 |
{ |
|
803 |
if ( iTargetPlugin ) |
|
804 |
{ |
|
805 |
aNode = iTargetPlugin; |
|
806 |
} |
|
807 |
||
808 |
iTargetPlugin = NULL; |
|
809 |
||
810 |
if ( !aNode ) |
|
811 |
{ |
|
812 |
return; |
|
813 |
} |
|
814 |
||
815 |
CXnPluginData* plugin( iViewManager.ActiveViewData().Plugin( aNode ) ); |
|
816 |
||
817 |
if( plugin && plugin->Removable() ) |
|
818 |
{ |
|
819 |
TRAPD( err, err = iViewManager.UnloadWidgetFromPluginL( *plugin ) ); |
|
820 |
||
821 |
if ( err != KErrNone ) |
|
822 |
{ |
|
823 |
HBufC* msg = StringLoader::LoadLC( |
|
824 |
R_QTN_HS_OPERATION_FAILED_NO_DISK ); |
|
825 |
ShowErrorNoteL( *msg ); |
|
826 |
CleanupStack::PopAndDestroy( msg ); |
|
827 |
} |
|
828 |
} |
|
829 |
} |
|
830 |
||
831 |
// --------------------------------------------------------------------------- |
|
832 |
// CXnEditor::ReorderWidgetsL |
|
833 |
// --------------------------------------------------------------------------- |
|
834 |
// |
|
835 |
void CXnEditor::ReorderWidgetsL( RPointerArray< CXnNode >* aPluginArray ) |
|
836 |
{ |
|
837 |
if ( !aPluginArray ) |
|
838 |
{ |
|
839 |
return; |
|
840 |
} |
|
841 |
||
842 |
CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
843 |
||
844 |
const TDesC8& configurationId( viewData.ConfigurationId() ); |
|
845 |
||
846 |
CDesC8ArrayFlat* ids = new ( ELeave ) CDesC8ArrayFlat( 6 ); |
|
847 |
CleanupStack::PushL( ids ); |
|
848 |
||
849 |
for ( TInt i = 0; i < aPluginArray->Count(); i++ ) |
|
850 |
{ |
|
851 |
CXnPluginData* plugin( viewData.Plugin( ( *aPluginArray )[i] ) ); |
|
852 |
if ( plugin ) |
|
853 |
{ |
|
854 |
const TDesC8& id( plugin->PluginId() ); |
|
855 |
||
856 |
if ( id != KNullDesC8 ) |
|
857 |
{ |
|
858 |
ids->AppendL( id ); |
|
859 |
} |
|
860 |
} |
|
861 |
} |
|
862 |
||
863 |
iHspsWrapper->MovePluginsL( configurationId, *ids ); |
|
864 |
||
865 |
CleanupStack::PopAndDestroy( ids ); |
|
866 |
} |
|
867 |
||
868 |
// --------------------------------------------------------------------------- |
|
869 |
// CXnEditor::PublisherInfoL |
|
870 |
// --------------------------------------------------------------------------- |
|
871 |
// |
|
872 |
CPublisherInfo* CXnEditor::PublisherInfoL( const CHsContentInfo& aContentInfo ) |
|
873 |
{ |
|
874 |
if ( !iPublisherMap ) |
|
875 |
{ |
|
876 |
return NULL; |
|
877 |
} |
|
878 |
||
879 |
RPointerArray< CPublisherInfo >& publisherInfo( |
|
880 |
iPublisherMap->PublisherInfo() ); |
|
881 |
||
882 |
const TDesC& publisherId( aContentInfo.PublisherId() ); |
|
883 |
||
884 |
CPublisherInfo* info = NULL; |
|
885 |
||
886 |
for ( TInt i = 0; i < publisherInfo.Count(); i++ ) |
|
887 |
{ |
|
888 |
CPublisherInfo* temp = publisherInfo[i]; |
|
889 |
||
890 |
if ( temp->PublisherId() == publisherId ) |
|
891 |
{ |
|
892 |
info = temp; |
|
893 |
break; |
|
894 |
} |
|
895 |
} |
|
896 |
||
897 |
return info; |
|
898 |
} |
|
899 |
||
900 |
// --------------------------------------------------------------------------- |
|
901 |
// CXnEditor::CpsWidgetPluginsL |
|
902 |
// --------------------------------------------------------------------------- |
|
903 |
// |
|
904 |
void CXnEditor::CpsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
|
905 |
{ |
|
906 |
// Get publishers from CPS |
|
907 |
delete iPublisherMap; |
|
908 |
iPublisherMap = NULL; |
|
909 |
||
910 |
iPublisherMap = iCpsWrapper->GetTemplatedPublishersL(); |
|
911 |
||
912 |
RPointerArray< CPublisherInfo >& publisherInfo( iPublisherMap->PublisherInfo() ); |
|
913 |
||
914 |
// Find templates for the published data |
|
915 |
for ( TInt i = 0; i < publisherInfo.Count(); i++ ) |
|
916 |
{ |
|
917 |
CPublisherInfo* info( publisherInfo[i] ); |
|
918 |
||
919 |
for ( TInt j = 0; j < iPluginConfigurations.Count(); j++ ) |
|
920 |
{ |
|
921 |
if( iPluginConfigurations[j]->Name().Length() > 0 ) |
|
922 |
{ |
|
923 |
// 8 to 16bit conv |
|
924 |
HBufC* nameBuf = HBufC::NewLC( iPluginConfigurations[j]->Name().Length() ); |
|
925 |
nameBuf->Des().Copy( iPluginConfigurations[j]->Name() ); |
|
926 |
TBool matchingNames = ( nameBuf->Des() == info->TemplateType() ); |
|
927 |
CleanupStack::PopAndDestroy(); |
|
928 |
if ( matchingNames ) |
|
929 |
{ |
|
930 |
||
931 |
// Add published widget |
|
932 |
CHsContentInfo* contentInfo = CHsContentInfo::NewLC(); |
|
933 |
||
934 |
contentInfo->SetNameL( info->WidgetName() ); |
|
935 |
contentInfo->SetPublisherIdL( info->PublisherId() ); |
|
936 |
contentInfo->SetMaxWidgets( info->MaxWidgets() ); |
|
937 |
contentInfo->SetUidL( iPluginConfigurations[j]->Uid() ); |
|
938 |
contentInfo->SetTypeL( iPluginConfigurations[j]->Type() ); |
|
939 |
contentInfo->SetDescriptionL( info->Description() ); |
|
940 |
contentInfo->SetIconPathL( info->LogoIcon() ); |
|
941 |
contentInfo->SetIsWrt( info->ContentType() == KWRTTemplate() ); |
|
942 |
||
943 |
aWidgets.AppendL( contentInfo ); |
|
944 |
||
945 |
CleanupStack::Pop( contentInfo ); |
|
946 |
break; |
|
947 |
} |
|
948 |
} |
|
949 |
} |
|
950 |
} |
|
951 |
} |
|
952 |
||
953 |
||
954 |
// --------------------------------------------------------------------------- |
|
955 |
// CXnEditor::ToggleWidgetsVisibiltyL |
|
956 |
// --------------------------------------------------------------------------- |
|
957 |
// |
|
958 |
TBool CXnEditor::ToggleWidgetsVisibiltyL() |
|
959 |
{ |
|
960 |
RPointerArray< CXnPluginData >& plugins( |
|
961 |
iViewManager.ActiveViewData().PluginData() ); |
|
962 |
||
963 |
TBool useEmpty( iViewManager.ActiveViewData().UseEmptyWidget() ); |
|
964 |
||
965 |
TBool stateChanged( EFalse ); |
|
966 |
||
967 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
968 |
{ |
|
969 |
CXnPluginData* plugin( plugins[i] ); |
|
970 |
||
971 |
if( !plugin->Removable() ) |
|
972 |
{ |
|
973 |
// Don't touch to non-removable widget |
|
974 |
continue; |
|
975 |
} |
|
976 |
||
977 |
if ( iWidgetsVisibilityState ) |
|
978 |
{ |
|
979 |
// Currently visible, make invisible |
|
980 |
stateChanged = ETrue; |
|
981 |
||
982 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
983 |
XnPropertyNames::style::common::KVisibility, |
|
984 |
XnPropertyNames::style::common::visibility::KHidden ); |
|
985 |
} |
|
986 |
else |
|
987 |
{ |
|
988 |
// Currently invisible, make visible |
|
989 |
if ( plugin->Occupied() ) |
|
990 |
{ |
|
991 |
stateChanged = ETrue; |
|
992 |
||
993 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
994 |
XnPropertyNames::style::common::KVisibility, |
|
995 |
XnPropertyNames::style::common::visibility::KVisible ); |
|
996 |
} |
|
997 |
else if( useEmpty ) |
|
998 |
{ |
|
999 |
stateChanged = ETrue; |
|
1000 |
||
1001 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
1002 |
XnPropertyNames::style::common::KVisibility, |
|
1003 |
XnPropertyNames::style::common::visibility::KBlank ); |
|
1004 |
} |
|
1005 |
} |
|
1006 |
} |
|
1007 |
||
1008 |
if ( stateChanged ) |
|
1009 |
{ |
|
1010 |
// Update |
|
1011 |
iWidgetsVisibilityState = !iWidgetsVisibilityState; |
|
1012 |
} |
|
1013 |
||
1014 |
return iWidgetsVisibilityState; |
|
1015 |
} |
|
1016 |
||
1017 |
// --------------------------------------------------------------------------- |
|
1018 |
// CXnEditor::WidgetsVisible |
|
1019 |
// --------------------------------------------------------------------------- |
|
1020 |
// |
|
1021 |
TBool CXnEditor::WidgetsVisible() const |
|
1022 |
{ |
|
1023 |
return iWidgetsVisibilityState; |
|
1024 |
} |
|
1025 |
||
1026 |
// --------------------------------------------------------------------------- |
|
1027 |
// CXnEditor::SetTargetPlugin |
|
1028 |
// --------------------------------------------------------------------------- |
|
1029 |
// |
|
1030 |
void CXnEditor::SetTargetPlugin( CXnNode* aNode ) |
|
1031 |
{ |
|
1032 |
TBool editState( iViewManager.UiEngine().EditMode()->EditState() ); |
|
1033 |
||
1034 |
if ( editState ) |
|
1035 |
{ |
|
1036 |
iTargetPlugin = aNode; |
|
1037 |
} |
|
1038 |
} |
|
1039 |
||
1040 |
// ----------------------------------------------------------------------------- |
|
1041 |
// CXnEditor::NotifyViewActivatedL |
|
1042 |
// ----------------------------------------------------------------------------- |
|
1043 |
// |
|
1044 |
void CXnEditor::NotifyViewActivatedL( const CXnViewData& aViewData ) |
|
1045 |
{ |
|
1046 |
RPointerArray< CXnPluginData >& plugins( aViewData.PluginData() ); |
|
1047 |
||
1048 |
TBool emptyInUse( aViewData.UseEmptyWidget() ); |
|
1049 |
TBool editState( iViewManager.UiEngine().EditMode()->EditState() ); |
|
1050 |
||
1051 |
iWidgetsVisibilityState = EFalse; |
|
1052 |
||
1053 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
1054 |
{ |
|
1055 |
CXnPluginData* plugin( plugins[i] ); |
|
1056 |
||
1057 |
if ( plugin->Occupied() ) |
|
1058 |
{ |
|
1059 |
// At least one widget visible |
|
1060 |
iWidgetsVisibilityState = ETrue; |
|
1061 |
} |
|
1062 |
||
1063 |
if ( plugin->Occupied() || editState ) |
|
1064 |
{ |
|
1065 |
// Make widget visible |
|
1066 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
1067 |
XnPropertyNames::style::common::KVisibility, |
|
1068 |
XnPropertyNames::style::common::visibility::KVisible ); |
|
1069 |
} |
|
1070 |
else |
|
1071 |
{ |
|
1072 |
if ( emptyInUse ) |
|
1073 |
{ |
|
1074 |
// Make empty space blank |
|
1075 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
1076 |
XnPropertyNames::style::common::KVisibility, |
|
1077 |
XnPropertyNames::style::common::visibility::KBlank ); |
|
1078 |
} |
|
1079 |
else |
|
1080 |
{ |
|
1081 |
// Nothing in this plugin hide |
|
1082 |
SetPropertyL( *plugin->Owner()->LayoutNode(), |
|
1083 |
XnPropertyNames::style::common::KDisplay, |
|
1084 |
XnPropertyNames::style::common::display::KNone ); |
|
1085 |
} |
|
1086 |
} |
|
1087 |
} |
|
1088 |
} |
|
1089 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1090 |
// ----------------------------------------------------------------------------- |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1091 |
// CXnEditor::NotifyViewLoadedL |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1092 |
// ----------------------------------------------------------------------------- |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1093 |
// |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1094 |
void CXnEditor::NotifyViewLoadedL( const CXnViewData& /*aViewData*/ ) |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1095 |
{ |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1096 |
} |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1097 |
|
34 | 1098 |
// --------------------------------------------------------------------------- |
1099 |
// CXnEditor::NotifyConfigureWidgetL |
|
1100 |
// --------------------------------------------------------------------------- |
|
1101 |
// |
|
1102 |
void CXnEditor::NotifyConfigureWidgetL( const CHsContentInfo& aContentInfo, |
|
1103 |
CXnPluginData& aPluginData ) |
|
1104 |
{ |
|
1105 |
if ( aContentInfo.Type() != KKeyTemplate ) |
|
1106 |
{ |
|
1107 |
// Doesn't need configuration |
|
1108 |
return; |
|
1109 |
} |
|
1110 |
||
1111 |
const TDesC8& pluginId( aPluginData.PluginId() ); |
|
1112 |
||
1113 |
CHspsConfiguration* pluginConf( |
|
1114 |
iHspsWrapper->GetPluginConfigurationL( pluginId ) ); |
|
1115 |
||
1116 |
CleanupStack::PushL( pluginConf ); |
|
1117 |
||
1118 |
const CPublisherInfo* info = PublisherInfoL( aContentInfo ); |
|
1119 |
||
1120 |
__ASSERT_DEBUG( info != NULL, Panic( EXnInvalidPublisherInfo ) ); |
|
1121 |
if ( !info ) |
|
1122 |
{ |
|
1123 |
User::Leave( KErrBadHandle ); |
|
1124 |
} |
|
1125 |
RPointerArray< CItemMap > itemMapListIn; |
|
1126 |
CleanupStack::PushL( TCleanupItem( DeleteItemMaps, &itemMapListIn ) ); |
|
1127 |
RPointerArray< CItemMap >& settings = pluginConf->Settings(); |
|
1128 |
||
1129 |
HBufC8* publisherId = CnvUtfConverter::ConvertFromUnicodeToUtf8L( |
|
1130 |
info->PublisherId() ); |
|
1131 |
CleanupStack::PushL( publisherId ); |
|
1132 |
||
1133 |
CItemMap* itemMap( 0 ); |
|
1134 |
CPropertyMap* property( 0 ); |
|
1135 |
CPropertyMap* propertyIn( 0 ); |
|
1136 |
||
1137 |
for ( TInt i = 0; i < settings.Count(); ++i ) |
|
1138 |
{ |
|
1139 |
CItemMap* readItem = settings[i]; |
|
1140 |
itemMap = CItemMap::NewLC(); |
|
1141 |
itemMap->SetItemIdL( readItem->ItemId() ); |
|
1142 |
const TDesC8& itemName = readItem->ItemName(); |
|
1143 |
itemMap->SetItemNameL( itemName ); |
|
1144 |
||
1145 |
RPointerArray< CPropertyMap >& properties = readItem->Properties(); |
|
1146 |
for ( int j = 0; j < properties.Count(); ++j ) |
|
1147 |
{ |
|
1148 |
property = properties[j]; |
|
1149 |
propertyIn = CPropertyMap::NewLC(); |
|
1150 |
propertyIn->SetNameL( property->Name() ); |
|
1151 |
// Dispatching is based on item name |
|
1152 |
if ( itemName == KContentSource() ) |
|
1153 |
{ |
|
1154 |
propertyIn->SetValueL( *publisherId ); |
|
1155 |
} |
|
1156 |
else if ( itemName == KContentData() ) |
|
1157 |
{ |
|
1158 |
// If this default template with full configuration |
|
1159 |
TInt pos = property->Value().LocateReverse( KSepratorChar ); |
|
1160 |
if ( KErrNotFound != pos ) |
|
1161 |
{ |
|
1162 |
propertyIn->SetValueL( property->Value() ); |
|
1163 |
} |
|
1164 |
else |
|
1165 |
{ |
|
1166 |
HBufC8* contentData = HBufC8::NewLC( publisherId->Length() |
|
1167 |
+ KSeperator().Length() |
|
1168 |
+ property->Value().Length()); |
|
1169 |
contentData->Des().Copy( *publisherId ); |
|
1170 |
contentData->Des().Append( KSeperator ); |
|
1171 |
contentData->Des().Append( property->Value() ); |
|
1172 |
propertyIn->SetValueL( *contentData ); |
|
1173 |
CleanupStack::PopAndDestroy( contentData ); |
|
1174 |
} |
|
1175 |
} |
|
1176 |
else if ( itemName.Find( KPublisher ) != KErrNotFound ) |
|
1177 |
{ |
|
1178 |
propertyIn->SetValueL( *publisherId ); |
|
1179 |
} |
|
1180 |
else if ( !KPubTrigger().Compare( itemName ) ) |
|
1181 |
{ |
|
1182 |
HBufC8* triggerData = HBufC8::NewLC( |
|
1183 |
publisherId->Length() |
|
1184 |
+ KSeperator().Length() |
|
1185 |
+ KPublisher().Length() |
|
1186 |
+ KWidgetTriggerName().Length()); |
|
1187 |
triggerData->Des().Copy( *publisherId ); |
|
1188 |
triggerData->Des().Append( KSeperator ); |
|
1189 |
triggerData->Des().Append( KPublisher ); |
|
1190 |
triggerData->Des().Append( KWidgetTriggerName ); |
|
1191 |
||
1192 |
propertyIn->SetValueL( *triggerData ); |
|
1193 |
CleanupStack::PopAndDestroy( triggerData ); |
|
1194 |
} |
|
1195 |
else if ( !KTrigger().Compare( itemName ) ) |
|
1196 |
{ |
|
1197 |
// If this default template with full configuration |
|
1198 |
TInt pos = property->Value().LocateReverse( KSepratorChar ); |
|
1199 |
if ( KErrNotFound != pos ) |
|
1200 |
{ |
|
1201 |
propertyIn->SetValueL( property->Value() ); |
|
1202 |
} |
|
1203 |
else |
|
1204 |
{ |
|
1205 |
HBufC8* triggerData = HBufC8::NewLC( |
|
1206 |
publisherId->Length() |
|
1207 |
+ KSeperator().Length() |
|
1208 |
+ property->Value().Length() |
|
1209 |
+ KOpen().Length() |
|
1210 |
+ property->Value().Length() |
|
1211 |
+ KClose().Length() ); |
|
1212 |
triggerData->Des().Copy( *publisherId ); |
|
1213 |
triggerData->Des().Append( KSeperator ); |
|
1214 |
triggerData->Des().Append( property->Value() ); |
|
1215 |
triggerData->Des().Append( KOpen ); |
|
1216 |
triggerData->Des().Append( property->Value() ); |
|
1217 |
triggerData->Des().Append( KClose ); |
|
1218 |
propertyIn->SetValueL( *triggerData ); |
|
1219 |
CleanupStack::PopAndDestroy( triggerData ); |
|
1220 |
} |
|
1221 |
} |
|
1222 |
else |
|
1223 |
{ |
|
1224 |
// unrecognized items are not handled |
|
1225 |
} |
|
1226 |
itemMap->AddPropertyMapL( propertyIn ); |
|
1227 |
CleanupStack::Pop( propertyIn ); |
|
1228 |
} |
|
1229 |
itemMapListIn.AppendL( itemMap ); |
|
1230 |
CleanupStack::Pop( itemMap ); |
|
1231 |
} |
|
1232 |
iHspsWrapper->SetPluginSettingsL( pluginId, itemMapListIn ); |
|
1233 |
||
1234 |
CleanupStack::PopAndDestroy( publisherId ); |
|
1235 |
CleanupStack::PopAndDestroy( &itemMapListIn ); |
|
1236 |
CleanupStack::PopAndDestroy( pluginConf ); |
|
1237 |
} |
|
1238 |
||
1239 |
// --------------------------------------------------------------------------- |
|
1240 |
// CXnEditor::NotifyWidgetAdditionL |
|
1241 |
// --------------------------------------------------------------------------- |
|
1242 |
// |
|
1243 |
void CXnEditor::NotifyWidgetAdditionL( const CXnPluginData& aPluginData ) |
|
1244 |
{ |
|
1245 |
CXnNode* node( aPluginData.Owner()->LayoutNode() ); |
|
1246 |
||
1247 |
// At least one widget is visible |
|
1248 |
iWidgetsVisibilityState = ETrue; |
|
1249 |
||
1250 |
// Ensure the new widget is visible |
|
1251 |
SetPropertyL( *node, |
|
1252 |
XnPropertyNames::style::common::KVisibility, |
|
1253 |
XnPropertyNames::style::common::visibility::KVisible ); |
|
1254 |
||
1255 |
SetPropertyL( *node, |
|
1256 |
XnPropertyNames::style::common::KDisplay, |
|
1257 |
XnPropertyNames::style::common::display::KBlock ); |
|
1258 |
||
1259 |
node->SetDirtyL( XnDirtyLevel::ELayoutAndRenderSiblings ); |
|
1260 |
||
1261 |
NotifyWidgetListChanged(); |
|
1262 |
} |
|
1263 |
||
1264 |
// --------------------------------------------------------------------------- |
|
1265 |
// CXnEditor::NotifyWidgetRemovalL |
|
1266 |
// --------------------------------------------------------------------------- |
|
1267 |
// |
|
1268 |
void CXnEditor::NotifyWidgetRemovalL( const CXnPluginData& aPluginData ) |
|
1269 |
{ |
|
1270 |
CXnNode* node( aPluginData.Owner()->LayoutNode() ); |
|
1271 |
||
1272 |
CXnViewData& viewData( |
|
1273 |
static_cast< CXnViewData& >( *aPluginData.Parent() ) ); |
|
1274 |
||
1275 |
TBool emptyInUse( viewData.UseEmptyWidget() ); |
|
1276 |
||
1277 |
if ( emptyInUse ) |
|
1278 |
{ |
|
1279 |
if ( iViewManager.UiEngine().IsEditMode() ) |
|
1280 |
{ |
|
1281 |
// Ensure the plugin which was holding |
|
1282 |
// the removed widget is visible when edit mode is active |
|
1283 |
SetPropertyL( *node, |
|
1284 |
XnPropertyNames::style::common::KVisibility, |
|
1285 |
XnPropertyNames::style::common::visibility::KVisible ); |
|
1286 |
} |
|
1287 |
else |
|
1288 |
{ |
|
1289 |
// Ensure the plugin which was holding |
|
1290 |
// the removed widget is blank now |
|
1291 |
SetPropertyL( *node, |
|
1292 |
XnPropertyNames::style::common::KVisibility, |
|
1293 |
XnPropertyNames::style::common::visibility::KBlank ); |
|
1294 |
} |
|
1295 |
} |
|
1296 |
else |
|
1297 |
{ |
|
1298 |
// Ensure the plugin which was holding the removed widget is invisible |
|
1299 |
SetPropertyL( *node, |
|
1300 |
XnPropertyNames::style::common::KDisplay, |
|
1301 |
XnPropertyNames::style::common::display::KNone ); |
|
1302 |
||
1303 |
// Reodred layout tree by moving the plugin which was holding the |
|
1304 |
// removed widget as the last one in layout tree's plugin the list |
|
1305 |
CXnNode *parent( node->Parent() ); |
|
1306 |
||
1307 |
RPointerArray< CXnNode >& children( parent->Children() ); |
|
1308 |
||
1309 |
TInt nodeIndex( children.Find( node ) ); |
|
1310 |
||
1311 |
children.Remove( nodeIndex ); |
|
1312 |
children.Insert( node, children.Count() - 1 ); |
|
1313 |
} |
|
1314 |
||
1315 |
node->SetDirtyL( XnDirtyLevel::ERender ); |
|
1316 |
||
1317 |
iTargetPlugin = NULL; |
|
1318 |
||
1319 |
if ( aPluginData.Active() ) |
|
1320 |
{ |
|
1321 |
CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
1322 |
||
1323 |
RPointerArray< CXnPluginData >& plugins( viewData.PluginData() ); |
|
1324 |
||
1325 |
TBool occupied( EFalse ); |
|
1326 |
||
1327 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
1328 |
{ |
|
1329 |
if ( plugins[i]->Occupied() && plugins[i]->Removable() ) |
|
1330 |
{ |
|
1331 |
occupied = ETrue; |
|
1332 |
break; |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
1336 |
if ( !occupied ) |
|
1337 |
{ |
|
1338 |
// No more widgets in the active view |
|
1339 |
iWidgetsVisibilityState = EFalse; |
|
1340 |
} |
|
1341 |
} |
|
1342 |
||
1343 |
NotifyWidgetListChanged(); |
|
1344 |
} |
|
1345 |
||
1346 |
// --------------------------------------------------------------------------- |
|
1347 |
// CXnEditor::NotifyViewAdditionL |
|
1348 |
// --------------------------------------------------------------------------- |
|
1349 |
// |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1350 |
void CXnEditor::NotifyViewAdditionL( const CXnViewData& /*aViewData*/ ) |
34 | 1351 |
{ |
1352 |
NotifyViewListChanged(); |
|
1353 |
} |
|
1354 |
||
1355 |
// --------------------------------------------------------------------------- |
|
1356 |
// CXnEditor::NotifyViewRemovalL |
|
1357 |
// --------------------------------------------------------------------------- |
|
1358 |
// |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1359 |
void CXnEditor::NotifyViewRemovalL( const CXnViewData& /*aViewData*/ ) |
34 | 1360 |
{ |
1361 |
NotifyViewListChanged(); |
|
1362 |
} |
|
1363 |
||
1364 |
// --------------------------------------------------------------------------- |
|
1365 |
// CXnEditor::NotifyWidgetUnregisteredL |
|
1366 |
// --------------------------------------------------------------------------- |
|
1367 |
// |
|
1368 |
void CXnEditor::NotifyWidgetUnregisteredL( const TDesC& aPublisher ) |
|
1369 |
{ |
|
1370 |
ResetPluginsAndPublishers(); |
|
1371 |
RemoveUnRegisteredWidgetL( aPublisher ); |
|
1372 |
NotifyWidgetListChanged(); |
|
1373 |
} |
|
1374 |
||
1375 |
// --------------------------------------------------------------------------- |
|
1376 |
// CXnEditor::NotifyWidgetRegisteredL |
|
1377 |
// --------------------------------------------------------------------------- |
|
1378 |
// |
|
1379 |
void CXnEditor::NotifyWidgetRegisteredL() |
|
1380 |
{ |
|
1381 |
ResetPluginsAndPublishers(); |
|
1382 |
NotifyWidgetListChanged(); |
|
1383 |
} |
|
1384 |
||
1385 |
// --------------------------------------------------------------------------- |
|
1386 |
// CXnEditor::NotifyWidgetUpdatedL |
|
1387 |
// --------------------------------------------------------------------------- |
|
1388 |
// |
|
1389 |
void CXnEditor::NotifyWidgetUpdatedL() |
|
1390 |
{ |
|
1391 |
NotifyWidgetListChanged(); |
|
1392 |
} |
|
1393 |
||
1394 |
// --------------------------------------------------------------------------- |
|
1395 |
// CXnEditor::NotifyAllViewsLoadedL |
|
1396 |
// --------------------------------------------------------------------------- |
|
1397 |
// |
|
1398 |
void CXnEditor::NotifyAllViewsLoadedL() |
|
1399 |
{ |
|
1400 |
NotifyViewListChanged(); |
|
1401 |
NotifyWidgetListChanged(); |
|
1402 |
} |
|
1403 |
||
1404 |
// ----------------------------------------------------------------------------- |
|
1405 |
// CXnEditor::NotifyContainerActivatedL |
|
1406 |
// ----------------------------------------------------------------------------- |
|
1407 |
// |
|
1408 |
void CXnEditor::NotifyContainerActivatedL( const CXnViewData& /* aViewData */ ) |
|
1409 |
{ |
|
1410 |
if ( iViewManager.ActiveAppData().AllViewsLoaded() ) |
|
1411 |
{ |
|
1412 |
NotifyWidgetListChanged(); |
|
1413 |
} |
|
1414 |
} |
|
1415 |
||
1416 |
// --------------------------------------------------------------------------- |
|
1417 |
// CXnEditor::NotifyWidgetListChanged |
|
1418 |
// --------------------------------------------------------------------------- |
|
1419 |
// |
|
1420 |
void CXnEditor::NotifyWidgetListChanged() |
|
1421 |
{ |
|
1422 |
if ( iNotifyWidgetListChanged->IsActive() ) |
|
1423 |
{ |
|
1424 |
iNotifyWidgetListChanged->Cancel(); |
|
1425 |
} |
|
1426 |
// start waiting for widget list changes (wait time is 1sec). |
|
1427 |
// if no new changes, notify observers about changes. otherwise |
|
1428 |
// start waiting for new updates again. |
|
1429 |
iNotifyWidgetListChanged->Start( |
|
1430 |
KNotifyWidgetListChangedDelay, |
|
1431 |
KNotifyWidgetListChangedDelay, |
|
1432 |
TCallBack( WidgetListChangedCallBack, this ) ); |
|
1433 |
} |
|
1434 |
||
1435 |
// --------------------------------------------------------------------------- |
|
1436 |
// CXnEditor::WidgetListChangedCallBack |
|
1437 |
// --------------------------------------------------------------------------- |
|
1438 |
// |
|
1439 |
TInt CXnEditor::WidgetListChangedCallBack( TAny* aSelf ) |
|
1440 |
{ |
|
1441 |
CXnEditor* editor = static_cast<CXnEditor*>( aSelf ); |
|
1442 |
if ( editor && editor->iNotifyWidgetListChanged->IsActive() ) |
|
1443 |
{ |
|
1444 |
// prevent multiple events |
|
1445 |
editor->iNotifyWidgetListChanged->Cancel(); |
|
1446 |
editor->WidgetListChanged(); |
|
1447 |
} |
|
1448 |
return KErrNone; |
|
1449 |
} |
|
1450 |
||
1451 |
// --------------------------------------------------------------------------- |
|
1452 |
// CXnEditor::NotifyViewListChanged |
|
1453 |
// --------------------------------------------------------------------------- |
|
1454 |
// |
|
1455 |
void CXnEditor::NotifyViewListChanged() |
|
1456 |
{ |
|
1457 |
if ( iNotifyViewListChanged->IsActive() ) |
|
1458 |
{ |
|
1459 |
iNotifyViewListChanged->Cancel(); |
|
1460 |
} |
|
1461 |
// start waiting for widget list changes (wait time is 1sec). |
|
1462 |
// if no new changes, notify observer about changes. otherwise |
|
1463 |
// start waiting for new changes again. |
|
1464 |
iNotifyViewListChanged->Start( |
|
1465 |
KNotifyViewListChangedDelay, |
|
1466 |
KNotifyViewListChangedDelay, |
|
1467 |
TCallBack( ViewListChangedCallBack, this ) ); |
|
1468 |
||
1469 |
} |
|
1470 |
||
1471 |
// --------------------------------------------------------------------------- |
|
1472 |
// CXnEditor::ViewListChangedCallBack |
|
1473 |
// --------------------------------------------------------------------------- |
|
1474 |
// |
|
1475 |
TInt CXnEditor::ViewListChangedCallBack( TAny* aSelf ) |
|
1476 |
{ |
|
1477 |
CXnEditor* editor = static_cast<CXnEditor*>( aSelf ); |
|
1478 |
if ( editor && editor->iNotifyViewListChanged->IsActive() ) |
|
1479 |
{ |
|
1480 |
// prevent multiple events |
|
1481 |
editor->iNotifyViewListChanged->Cancel(); |
|
1482 |
editor->ViewListChanged(); |
|
1483 |
} |
|
1484 |
return KErrNone; |
|
1485 |
} |
|
1486 |
||
1487 |
// --------------------------------------------------------------------------- |
|
1488 |
// CXnEditor::NotifyViewDeactivatedL |
|
1489 |
// --------------------------------------------------------------------------- |
|
1490 |
// |
|
1491 |
void CXnEditor::NotifyViewDeactivatedL( const CXnViewData& /*aViewData*/) |
|
1492 |
{ |
|
1493 |
iTargetPlugin = NULL; |
|
1494 |
} |
|
1495 |
||
1496 |
// --------------------------------------------------------------------------- |
|
1497 |
// CXnEditor::SetWallpaperL |
|
1498 |
// --------------------------------------------------------------------------- |
|
1499 |
// |
|
1500 |
void CXnEditor::SetWallpaperL() |
|
1501 |
{ |
|
1502 |
// Display dialog |
|
1503 |
TInt selectedIndex( 0 ); |
|
1504 |
||
1505 |
CAknListQueryDialog* query = |
|
1506 |
new ( ELeave ) CAknListQueryDialog( &selectedIndex ); |
|
1507 |
CleanupStack::PushL( query ); |
|
1508 |
query->PrepareLC( R_LISTQUERY_CHANGE_WALLPAPER ); |
|
1509 |
||
1510 |
if ( query->RunLD() ) |
|
1511 |
{ |
|
1512 |
if ( selectedIndex == 0 ) |
|
1513 |
{ |
|
1514 |
// set wallpaper. No need to check return value. If successful, |
|
1515 |
// avkon calls SkinConfigurationChanged function |
|
1516 |
AknsWallpaperUtils::SetIdleWallpaper( |
|
1517 |
KNullDesC, |
|
1518 |
NULL ); |
|
1519 |
} |
|
1520 |
else if ( selectedIndex == 1 ) |
|
1521 |
{ |
|
1522 |
iViewManager.AppUiAdapter().ActivateLocalViewL( KWallpaperViewUid, KDummyUid, KSingle ); |
|
1523 |
} |
|
1524 |
else if ( selectedIndex == 2 ) |
|
1525 |
{ |
|
1526 |
iViewManager.AppUiAdapter().ActivateLocalViewL( KWallpaperViewUid, KDummyUid, KMulti ); |
|
1527 |
} |
|
1528 |
} |
|
1529 |
CleanupStack::Pop( query ); |
|
1530 |
} |
|
1531 |
||
1532 |
// ----------------------------------------------------------------------------- |
|
1533 |
// CXnEditor::HandleNotifyL |
|
1534 |
// Handles notifications from HSPS wrapper |
|
1535 |
// ----------------------------------------------------------------------------- |
|
1536 |
// |
|
1537 |
TInt CXnEditor::HandleNotifyL( |
|
1538 |
const TDesC8& aEvent, |
|
1539 |
const TDesC8& /*aAppConfUid*/, |
|
1540 |
const TDesC8& aPluginName, |
|
1541 |
const TDesC8& /*aOrigUid*/, |
|
1542 |
const TDesC8& aPluginUid, |
|
1543 |
const TDesC8& aPluginId ) |
|
1544 |
{ |
|
1545 |
if ( aEvent == KEventPluginUnInstalled ) |
|
1546 |
{ |
|
1547 |
ResetPluginsAndPublishers(); |
|
1548 |
||
1549 |
CHsContentInfo* info = CHsContentInfo::NewLC(); |
|
1550 |
||
1551 |
info->SetNameL( aPluginName ); |
|
1552 |
info->SetUidL( aPluginUid ); |
|
1553 |
info->SetPluginIdL( aPluginId ); |
|
1554 |
||
1555 |
RemoveUnInstalledWidgetL( *info ); |
|
1556 |
NotifyWidgetListChanged(); |
|
1557 |
||
1558 |
CleanupStack::PopAndDestroy( info ); |
|
1559 |
} |
|
1560 |
else if ( aEvent == KEventRootConfActivated ) |
|
1561 |
{ |
|
1562 |
iViewManager.AppUiAdapter().ReloadUiL(); |
|
1563 |
} |
|
1564 |
else if ( aEvent == KEventPluginInstalled ) |
|
1565 |
{ |
|
1566 |
ResetPluginsAndPublishers(); |
|
1567 |
||
1568 |
NotifyWidgetListChanged(); |
|
1569 |
} |
|
1570 |
else if ( aEvent == KEventPluginUpdated ) |
|
1571 |
{ |
|
1572 |
ResetPluginsAndPublishers(); |
|
1573 |
||
1574 |
// If the plugin is in use then reload the widget |
|
1575 |
if ( aPluginId.Length() > 0 ) |
|
1576 |
{ |
|
1577 |
CHsContentInfo* info = CHsContentInfo::NewLC(); |
|
1578 |
info->SetNameL( aPluginName ); |
|
1579 |
info->SetUidL( aPluginUid ); |
|
1580 |
info->SetPluginIdL( aPluginId ); |
|
1581 |
ReplaceWidgetL( *info ); |
|
1582 |
CleanupStack::PopAndDestroy( info ); |
|
1583 |
} |
|
1584 |
NotifyWidgetListChanged(); |
|
1585 |
} |
|
1586 |
||
1587 |
return KErrNone; |
|
1588 |
} |
|
1589 |
||
1590 |
// ----------------------------------------------------------------------------- |
|
1591 |
// CXnEditor::WidgetListChanged |
|
1592 |
// ----------------------------------------------------------------------------- |
|
1593 |
// |
|
1594 |
void CXnEditor::WidgetListChanged() |
|
1595 |
{ |
|
1596 |
TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8(); |
|
1597 |
||
1598 |
MHsContentControlUi* ui( NULL ); |
|
1599 |
if ( IdFromCrep ( oPaqDataStr ) == KErrNone ) |
|
1600 |
{ |
|
1601 |
ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); |
|
1602 |
} |
|
1603 |
if( ui ) |
|
1604 |
{ |
|
1605 |
ui->NotifyWidgetListChanged(); |
|
1606 |
} |
|
1607 |
MHsContentControl* srv( iViewManager.AppUiAdapter().HsContentControlSrv() ); |
|
1608 |
if ( srv ) |
|
1609 |
{ |
|
1610 |
srv->NotifyWidgetListChanged(); |
|
1611 |
} |
|
1612 |
} |
|
1613 |
||
1614 |
// ----------------------------------------------------------------------------- |
|
1615 |
// CXnEditor::ViewListChanged |
|
1616 |
// ----------------------------------------------------------------------------- |
|
1617 |
// |
|
1618 |
void CXnEditor::ViewListChanged() |
|
1619 |
{ |
|
1620 |
TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8(); |
|
1621 |
||
1622 |
MHsContentControlUi* ui( NULL ); |
|
1623 |
if ( IdFromCrep ( oPaqDataStr ) == KErrNone ) |
|
1624 |
{ |
|
1625 |
ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); |
|
1626 |
} |
|
1627 |
if( ui ) |
|
1628 |
{ |
|
1629 |
ui->NotifyViewListChanged(); |
|
1630 |
} |
|
1631 |
MHsContentControl* srv( iViewManager.AppUiAdapter().HsContentControlSrv() ); |
|
1632 |
if ( srv ) |
|
1633 |
{ |
|
1634 |
srv->NotifyViewListChanged(); |
|
1635 |
} |
|
1636 |
} |
|
1637 |
||
1638 |
// ----------------------------------------------------------------------------- |
|
1639 |
// CXnEditor::HspsWrapper |
|
1640 |
// ----------------------------------------------------------------------------- |
|
1641 |
// |
|
1642 |
CHspsWrapper& CXnEditor::HspsWrapper() const |
|
1643 |
{ |
|
1644 |
return *iHspsWrapper; |
|
1645 |
} |
|
1646 |
||
1647 |
// ----------------------------------------------------------------------------- |
|
1648 |
// CXnEditor::AppendPluginsL |
|
1649 |
// ----------------------------------------------------------------------------- |
|
1650 |
// |
|
1651 |
void CXnEditor::AppendPluginsL( |
|
1652 |
RPointerArray< hspswrapper::CPluginInfo > aPlugins, |
|
1653 |
RPointerArray< CHsContentInfo >& aWidgets ) |
|
1654 |
{ |
|
1655 |
// Append plugins to the content info array |
|
1656 |
for ( TInt i = 0; i < aPlugins.Count(); i++ ) |
|
1657 |
{ |
|
1658 |
||
1659 |
// Block the empty and template plugins from the list |
|
1660 |
if ( aPlugins[i]->Uid().CompareF( KEmptyWidgetUid ) == 0 |
|
1661 |
|| aPlugins[i]->Type() == KKeyTemplate ) |
|
1662 |
{ |
|
1663 |
continue; |
|
1664 |
} |
|
1665 |
||
1666 |
CHsContentInfo* contentInfo = CHsContentInfo::NewLC(); |
|
1667 |
contentInfo->SetNameL( aPlugins[i]->Name() ); |
|
1668 |
contentInfo->SetUidL( aPlugins[i]->Uid() ); |
|
1669 |
contentInfo->SetTypeL( aPlugins[i]->Type() ); |
|
1670 |
if ( aPlugins[i]->Type() == KKeyWidget |
|
1671 |
|| aPlugins[i]->Type() == KKeyTemplate ) |
|
1672 |
{ |
|
1673 |
contentInfo->SetMaxWidgets( aPlugins[i]->MultiInstance() ); |
|
1674 |
} |
|
1675 |
contentInfo->SetDescriptionL( aPlugins[i]->Description() ); |
|
1676 |
contentInfo->SetIconPathL( aPlugins[i]->LogoIcon() ); |
|
1677 |
||
1678 |
aWidgets.AppendL( contentInfo ); |
|
1679 |
CleanupStack::Pop( contentInfo ); |
|
1680 |
} |
|
1681 |
} |
|
1682 |
||
1683 |
// ----------------------------------------------------------------------------- |
|
1684 |
// CXnEditor::ResetPluginsAndPublishers |
|
1685 |
// ----------------------------------------------------------------------------- |
|
1686 |
// |
|
1687 |
void CXnEditor::ResetPluginsAndPublishers() |
|
1688 |
{ |
|
1689 |
// Force loading of widget/template plugin configurations |
|
1690 |
iPluginConfigurations.ResetAndDestroy(); |
|
1691 |
||
1692 |
// Forece reloading of CPS publishers |
|
1693 |
delete iPublisherMap; |
|
1694 |
iPublisherMap = NULL; |
|
1695 |
} |
|
1696 |
||
1697 |
// ----------------------------------------------------------------------------- |
|
1698 |
// CXnEditor::HspsApplicationPluginsL |
|
1699 |
// ----------------------------------------------------------------------------- |
|
1700 |
// |
|
1701 |
void CXnEditor::HspsApplicationPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
|
1702 |
{ |
|
1703 |
RPointerArray< hspswrapper::CPluginInfo > plugins; |
|
1704 |
CleanupStack::PushL( TCleanupItem( DeletePluginInfos, &plugins ) ); |
|
1705 |
||
1706 |
iHspsWrapper->GetAppConfigurationsL( plugins ); |
|
1707 |
||
1708 |
// Append plugins to the content info array |
|
1709 |
AppendPluginsL( plugins, aWidgets ); |
|
1710 |
||
1711 |
CleanupStack::PopAndDestroy( &plugins ); |
|
1712 |
} |
|
1713 |
||
1714 |
// ----------------------------------------------------------------------------- |
|
1715 |
// CXnEditor::HspsViewPluginsL |
|
1716 |
// ----------------------------------------------------------------------------- |
|
1717 |
// |
|
1718 |
void CXnEditor::HspsViewPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
|
1719 |
{ |
|
1720 |
RPointerArray< hspswrapper::CPluginInfo > plugins; |
|
1721 |
CleanupStack::PushL( TCleanupItem( DeletePluginInfos, &plugins ) ); |
|
1722 |
||
1723 |
iHspsWrapper->GetPluginsL( plugins, KPluginInterface, KView ); |
|
1724 |
||
1725 |
// Append plugins to the content info array |
|
1726 |
AppendPluginsL( plugins, aWidgets ); |
|
1727 |
||
1728 |
CleanupStack::PopAndDestroy( &plugins ); |
|
1729 |
} |
|
1730 |
||
1731 |
// ----------------------------------------------------------------------------- |
|
1732 |
// CXnEditor::HspsWidgetPluginsL |
|
1733 |
// ----------------------------------------------------------------------------- |
|
1734 |
// |
|
1735 |
void CXnEditor::HspsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
|
1736 |
{ |
|
1737 |
__ASSERT_DEBUG( aWidgets.Count() == 0, User::Leave( KErrGeneral ) ); |
|
1738 |
||
1739 |
// If widget/template plugins haven't been fetched yet |
|
1740 |
if( iPluginConfigurations.Count() == 0 ) |
|
1741 |
{ |
|
1742 |
// Fetch the plugins into the runtime cache |
|
1743 |
TRAPD( err, DoHspsWidgetPluginsL() ); |
|
1744 |
if( err ) |
|
1745 |
{ |
|
1746 |
ResetPluginsAndPublishers(); |
|
1747 |
User::LeaveIfError( err ); |
|
1748 |
} |
|
1749 |
} |
|
1750 |
||
1751 |
// Append plugins to the content info array |
|
1752 |
AppendPluginsL( iPluginConfigurations, aWidgets ); |
|
1753 |
} |
|
1754 |
||
1755 |
// ----------------------------------------------------------------------------- |
|
1756 |
// CXnEditor::DoHspsWidgetPluginsL |
|
1757 |
// ----------------------------------------------------------------------------- |
|
1758 |
// |
|
1759 |
void CXnEditor::DoHspsWidgetPluginsL() |
|
1760 |
{ |
|
1761 |
iHspsWrapper->GetPluginsL( iPluginConfigurations, KPluginInterface, KKeyWidget ); |
|
1762 |
iHspsWrapper->GetPluginsL( iPluginConfigurations, KPluginInterface, KKeyTemplate ); |
|
1763 |
} |
|
1764 |
||
1765 |
// ----------------------------------------------------------------------------- |
|
1766 |
// from MHsContentController |
|
1767 |
// ----------------------------------------------------------------------------- |
|
1768 |
// |
|
1769 |
TInt CXnEditor::WidgetListL( CHsContentInfoArray& aArray ) |
|
1770 |
{ |
|
1771 |
// append the list with native widget and template plugins from HSPS |
|
1772 |
HspsWidgetPluginsL( aArray.Array() ); |
|
1773 |
||
1774 |
// append the list with published template plugins from CPS |
|
1775 |
CpsWidgetPluginsL( aArray.Array() ); |
|
1776 |
||
1777 |
// check whether the plugins can be added or removed |
|
1778 |
FilterPluginsL( aArray, ETrue ); |
|
1779 |
||
1780 |
return KErrNone; |
|
1781 |
} |
|
1782 |
||
1783 |
// ----------------------------------------------------------------------------- |
|
1784 |
// from MHsContentController |
|
1785 |
// ----------------------------------------------------------------------------- |
|
1786 |
// |
|
1787 |
TInt CXnEditor::WidgetListL( CHsContentInfo& aInfo, CHsContentInfoArray& aArray ) |
|
1788 |
{ |
|
1789 |
TInt err( KErrNone ); |
|
1790 |
RPointerArray< CXnPluginData > widgets; |
|
1791 |
CleanupClosePushL( widgets ); |
|
1792 |
||
1793 |
if ( aInfo.Type() == KApplication ) |
|
1794 |
{ |
|
1795 |
if ( aInfo.Uid().CompareF( iViewManager.ActiveAppData().PluginUid() ) == 0 ) |
|
1796 |
{ |
|
1797 |
// Get widgets included in active application configuration |
|
1798 |
err = iViewManager.PluginDataL( KNullDesC8(), widgets ); |
|
1799 |
} |
|
1800 |
else |
|
1801 |
{ |
|
1802 |
// Invalid application configuration |
|
1803 |
err = KErrArgument; |
|
1804 |
} |
|
1805 |
} |
|
1806 |
else if ( aInfo.Type() == KView ) |
|
1807 |
{ |
|
1808 |
// Get widgets included in a view |
|
1809 |
err = iViewManager.PluginDataL( aInfo.PluginId(), widgets ); |
|
1810 |
} |
|
1811 |
else |
|
1812 |
{ |
|
1813 |
err = KErrArgument; |
|
1814 |
} |
|
1815 |
||
1816 |
if ( !err ) |
|
1817 |
{ |
|
1818 |
// Get installed widget content infos |
|
1819 |
RPointerArray< CHsContentInfo > array; |
|
1820 |
CleanupStack::PushL( TCleanupItem( DeleteContentInfo, &array ) ); |
|
1821 |
||
1822 |
// get installed widgets and template configurations from HSPS |
|
1823 |
HspsWidgetPluginsL( array ); |
|
1824 |
||
1825 |
// get published widgets |
|
1826 |
CpsWidgetPluginsL( array ); |
|
1827 |
||
1828 |
// Create content info for each found widget |
|
1829 |
for ( TInt i = 0; i < widgets.Count(); i++ ) |
|
1830 |
{ |
|
1831 |
CHsContentInfo* info = CreateContentInfoLC( *widgets[i], array ); |
|
1832 |
if ( info ) |
|
1833 |
{ |
|
1834 |
aArray.Array().AppendL( info ); |
|
1835 |
CleanupStack::Pop( info ); |
|
1836 |
} |
|
1837 |
} |
|
1838 |
CleanupStack::PopAndDestroy(); // array |
|
1839 |
} |
|
1840 |
||
1841 |
CleanupStack::PopAndDestroy(); // widgets |
|
1842 |
||
1843 |
return err; |
|
1844 |
} |
|
1845 |
||
1846 |
// ----------------------------------------------------------------------------- |
|
1847 |
// from MHsContentController |
|
1848 |
// ----------------------------------------------------------------------------- |
|
1849 |
// |
|
1850 |
TInt CXnEditor::ViewListL( CHsContentInfoArray& aArray ) |
|
1851 |
{ |
|
1852 |
RPointerArray< CHsContentInfo >& array( aArray.Array() ); |
|
1853 |
||
1854 |
||
1855 |
// get installed view configurations from HSPS |
|
1856 |
HspsViewPluginsL( array ); |
|
1857 |
||
1858 |
FilterViewListL( aArray ); |
|
1859 |
||
1860 |
return KErrNone; |
|
1861 |
} |
|
1862 |
||
1863 |
// ----------------------------------------------------------------------------- |
|
1864 |
// from MHsContentController |
|
1865 |
// ----------------------------------------------------------------------------- |
|
1866 |
// |
|
1867 |
TInt CXnEditor::ViewListL( CHsContentInfo& aInfo, CHsContentInfoArray& aArray ) |
|
1868 |
{ |
|
1869 |
TInt err( KErrNone ); |
|
1870 |
||
1871 |
if ( aInfo.Type() == KApplication ) |
|
1872 |
{ |
|
1873 |
if ( aInfo.Uid().CompareF( iViewManager.ActiveAppData().PluginUid() ) == 0 ) |
|
1874 |
{ |
|
1875 |
// Get list of views in active application configuration |
|
1876 |
CXnRootData& appData( iViewManager.ActiveAppData() ); |
|
1877 |
RPointerArray< CXnPluginData >& views( appData.PluginData() ); |
|
1878 |
||
1879 |
// Get installed view content infos |
|
1880 |
RPointerArray< CHsContentInfo > array; |
|
1881 |
CleanupStack::PushL( TCleanupItem( DeleteContentInfo, &array ) ); |
|
1882 |
HspsViewPluginsL( array ); |
|
1883 |
||
1884 |
// Create content info for each found view |
|
1885 |
for ( TInt i = 0; i < views.Count(); i++ ) |
|
1886 |
{ |
|
1887 |
CHsContentInfo* info = CreateContentInfoLC( *views[i], array ); |
|
1888 |
if ( info ) |
|
1889 |
{ |
|
1890 |
CXnViewData* view = static_cast < CXnViewData* >( views[ i ] ); |
|
1891 |
info->SetIsFull( IsViewFull( *view ) ); |
|
1892 |
aArray.Array().AppendL( info ); |
|
1893 |
CleanupStack::Pop( info ); |
|
1894 |
} |
|
1895 |
} |
|
1896 |
CleanupStack::PopAndDestroy(); // array |
|
1897 |
} |
|
1898 |
else |
|
1899 |
{ |
|
1900 |
// Invalid application configuration |
|
1901 |
err = KErrArgument; |
|
1902 |
} |
|
1903 |
} |
|
1904 |
else |
|
1905 |
{ |
|
1906 |
// Invalid argument |
|
1907 |
err = KErrArgument; |
|
1908 |
} |
|
1909 |
||
1910 |
return err; |
|
1911 |
} |
|
1912 |
||
1913 |
// ----------------------------------------------------------------------------- |
|
1914 |
// from MHsContentController |
|
1915 |
// ----------------------------------------------------------------------------- |
|
1916 |
// |
|
1917 |
TInt CXnEditor::AppListL( CHsContentInfoArray& aArray ) |
|
1918 |
{ |
|
1919 |
RPointerArray< CHsContentInfo >& array( aArray.Array() ); |
|
1920 |
||
1921 |
// get installed application configurations from HSPS |
|
1922 |
HspsApplicationPluginsL( array ); |
|
1923 |
||
1924 |
return KErrNone; |
|
1925 |
} |
|
1926 |
||
1927 |
// ----------------------------------------------------------------------------- |
|
1928 |
// from MHsContentController |
|
1929 |
// ----------------------------------------------------------------------------- |
|
1930 |
// |
|
1931 |
TInt CXnEditor::AddWidgetL( CHsContentInfo& aInfo ) |
|
1932 |
{ |
|
1933 |
TInt ret( KErrNone ); |
|
1934 |
||
1935 |
const TDesC8& type( aInfo.Type() ); |
|
1936 |
||
1937 |
if ( ( type != KKeyWidget && type != KKeyTemplate ) || |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1938 |
aInfo.Uid() == KNullDesC8 ) |
34 | 1939 |
{ |
1940 |
// malformed content info |
|
1941 |
return KErrArgument; |
|
1942 |
} |
|
1943 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1944 |
// the widget can not be added. Return proper error code |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1945 |
if ( IsCurrentViewFull() ) |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1946 |
{ |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1947 |
return KHsErrorViewFull; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1948 |
} |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1949 |
else if ( !aInfo.CanBeAdded() ) |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1950 |
{ |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1951 |
return KHsErrorMaxInstanceCountExceeded; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1952 |
} |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1953 |
|
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1954 |
|
34 | 1955 |
CXnPluginData* plugin( NULL ); |
1956 |
||
1957 |
if( iTargetPlugin ) |
|
1958 |
{ |
|
1959 |
plugin = DeterminePlugin( iViewManager, iTargetPlugin ); |
|
1960 |
} |
|
1961 |
else |
|
1962 |
{ |
|
1963 |
plugin = DeterminePlugin( iViewManager ); |
|
1964 |
} |
|
1965 |
||
1966 |
iTargetPlugin = NULL; |
|
1967 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1968 |
if ( !plugin ) |
34 | 1969 |
{ |
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1970 |
return KErrGeneral; |
34 | 1971 |
} |
1972 |
||
1973 |
ret = iViewManager.LoadWidgetToPluginL( aInfo, *plugin ); |
|
1974 |
||
1975 |
if( ret == KErrNone ) |
|
1976 |
{ |
|
1977 |
CXnNode* node( plugin->Owner()->LayoutNode() ); |
|
1978 |
TBool widgetOk( iViewManager.UiEngine().AnalyseAddedWidgetL( *node ) ); |
|
1979 |
||
1980 |
if( !widgetOk ) |
|
1981 |
{ |
|
1982 |
iViewManager.UnloadWidgetFromPluginL( *plugin ); |
|
1983 |
||
1984 |
ret = KHsErrorDoesNotFit; |
|
1985 |
} |
|
1986 |
} |
|
1987 |
||
1988 |
return ret; |
|
1989 |
} |
|
1990 |
||
1991 |
// ----------------------------------------------------------------------------- |
|
1992 |
// from MHsContentController |
|
1993 |
// ----------------------------------------------------------------------------- |
|
1994 |
// |
|
1995 |
TInt CXnEditor::RemoveWidgetL( CHsContentInfo& aInfo ) |
|
1996 |
{ |
|
1997 |
if ( !aInfo.CanBeRemoved() || aInfo.PluginId() == KNullDesC8 || |
|
1998 |
( aInfo.Type() != KKeyWidget && aInfo.Type() != KKeyTemplate ) ) |
|
1999 |
{ |
|
2000 |
return KErrArgument; |
|
2001 |
} |
|
2002 |
||
2003 |
TInt retval( KErrNotFound ); |
|
2004 |
||
2005 |
RPointerArray< CXnPluginData > plugins; |
|
2006 |
CleanupClosePushL( plugins ); |
|
2007 |
||
2008 |
// Search only from active view |
|
2009 |
iViewManager.PluginDataL( plugins ); |
|
2010 |
||
2011 |
CXnPluginData* plugin( DeterminePlugin( plugins, aInfo ) ); |
|
2012 |
||
2013 |
if ( plugin && plugin->Removable() ) |
|
2014 |
{ |
|
2015 |
retval = iViewManager.UnloadWidgetFromPluginL( *plugin ); |
|
2016 |
} |
|
2017 |
||
2018 |
CleanupStack::PopAndDestroy( &plugins ); |
|
2019 |
||
2020 |
return retval; |
|
2021 |
} |
|
2022 |
||
2023 |
// ----------------------------------------------------------------------------- |
|
2024 |
// from MHsContentController |
|
2025 |
// ----------------------------------------------------------------------------- |
|
2026 |
// |
|
2027 |
TInt CXnEditor::AddViewL( CHsContentInfo& aInfo ) |
|
2028 |
{ |
|
2029 |
if ( !aInfo.CanBeAdded() || aInfo.Uid() == KNullDesC8 || |
|
2030 |
aInfo.Type() != KView ) |
|
2031 |
{ |
|
2032 |
return KErrArgument; |
|
2033 |
} |
|
2034 |
||
2035 |
return iViewManager.AddViewL( aInfo ); |
|
2036 |
} |
|
2037 |
||
2038 |
// ----------------------------------------------------------------------------- |
|
2039 |
// from MHsContentController |
|
2040 |
// ----------------------------------------------------------------------------- |
|
2041 |
// |
|
2042 |
TInt CXnEditor::RemoveViewL( CHsContentInfo& aInfo ) |
|
2043 |
{ |
|
2044 |
if ( !aInfo.CanBeRemoved() || aInfo.PluginId() == KNullDesC8 || |
|
2045 |
aInfo.Type() != KView ) |
|
2046 |
{ |
|
2047 |
return KErrArgument; |
|
2048 |
} |
|
2049 |
||
2050 |
return iViewManager.RemoveViewL( aInfo ); |
|
2051 |
} |
|
2052 |
||
2053 |
// ----------------------------------------------------------------------------- |
|
2054 |
// from MHsContentController |
|
2055 |
// ----------------------------------------------------------------------------- |
|
2056 |
// |
|
2057 |
TInt CXnEditor::ActivateViewL( CHsContentInfo& aInfo ) |
|
2058 |
{ |
|
2059 |
if ( aInfo.Type() != KView ) |
|
2060 |
{ |
|
2061 |
return KErrArgument; |
|
2062 |
} |
|
2063 |
||
2064 |
return iViewManager.ActivateViewL( aInfo.PluginId() ); |
|
2065 |
} |
|
2066 |
||
2067 |
// ----------------------------------------------------------------------------- |
|
2068 |
// from MHsContentController |
|
2069 |
// ----------------------------------------------------------------------------- |
|
2070 |
// |
|
2071 |
TInt CXnEditor::ActivateAppL( CHsContentInfo& aInfo ) |
|
2072 |
{ |
|
2073 |
if ( aInfo.Type() != KApplication ) |
|
2074 |
{ |
|
2075 |
return KErrArgument; |
|
2076 |
} |
|
2077 |
||
2078 |
return iViewManager.ActivateAppL( aInfo.Uid() ); |
|
2079 |
} |
|
2080 |
||
2081 |
// ----------------------------------------------------------------------------- |
|
2082 |
// from MHsContentController |
|
2083 |
// ----------------------------------------------------------------------------- |
|
2084 |
// |
|
2085 |
TInt CXnEditor::ActiveViewL( CHsContentInfo& aInfo ) |
|
2086 |
{ |
|
2087 |
||
2088 |
TInt err( KErrNone ); |
|
2089 |
||
2090 |
CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
2091 |
||
2092 |
CHspsConfiguration* view( iHspsWrapper->GetPluginConfigurationL( viewData.PluginId() ) ); |
|
2093 |
CleanupStack::PushL( view ); |
|
2094 |
if ( view ) |
|
2095 |
{ |
|
2096 |
aInfo.SetNameL( view->PluginInfo().Name() ); |
|
2097 |
aInfo.SetPluginIdL( viewData.PluginId() ); |
|
2098 |
aInfo.SetUidL( view->PluginInfo().Uid() ); |
|
2099 |
aInfo.SetTypeL( view->PluginInfo().Type() ); |
|
2100 |
aInfo.SetDescriptionL( view->PluginInfo().Description() ); |
|
2101 |
aInfo.SetIconPathL( view->PluginInfo().LogoIcon() ); |
|
2102 |
aInfo.SetIsFull( IsViewFull( viewData ) ); |
|
2103 |
} |
|
2104 |
else |
|
2105 |
{ |
|
2106 |
err = KErrNotFound; |
|
2107 |
} |
|
2108 |
||
2109 |
CleanupStack::PopAndDestroy( view ); |
|
2110 |
||
2111 |
return err; |
|
2112 |
} |
|
2113 |
||
2114 |
// ----------------------------------------------------------------------------- |
|
2115 |
// from MHsContentController |
|
2116 |
// ----------------------------------------------------------------------------- |
|
2117 |
// |
|
2118 |
TInt CXnEditor::ActiveAppL( CHsContentInfo& aInfo ) |
|
2119 |
{ |
|
2120 |
||
2121 |
TInt err( KErrNone ); |
|
2122 |
CHspsConfiguration* app = iHspsWrapper->GetAppConfigurationL(); |
|
2123 |
CleanupStack::PushL( app ); |
|
2124 |
||
2125 |
if ( app->PluginInfo().Uid().Length() > 0 ) |
|
2126 |
{ |
|
2127 |
aInfo.SetNameL( app->PluginInfo().Name() ); |
|
2128 |
aInfo.SetUidL( app->PluginInfo().Uid() ); |
|
2129 |
aInfo.SetTypeL( app->PluginInfo().Type() ); |
|
2130 |
aInfo.SetDescriptionL( app->PluginInfo().Description() ); |
|
2131 |
aInfo.SetIconPathL( app->PluginInfo().LogoIcon() ); |
|
2132 |
||
2133 |
CXnRootData& appData( iViewManager.ActiveAppData() ); |
|
2134 |
if ( appData.PluginData().Count() < appData.MaxPages() ) |
|
2135 |
{ |
|
2136 |
aInfo.SetIsFull( EFalse ); |
|
2137 |
} |
|
2138 |
else |
|
2139 |
{ |
|
2140 |
aInfo.SetIsFull( ETrue ); |
|
2141 |
} |
|
2142 |
} |
|
2143 |
else |
|
2144 |
{ |
|
2145 |
err = KErrNotFound; |
|
2146 |
} |
|
2147 |
||
2148 |
CleanupStack::PopAndDestroy( app ); |
|
2149 |
return err; |
|
2150 |
} |
|
2151 |
||
2152 |
// ----------------------------------------------------------------------------- |
|
2153 |
// CXnEditor::CreateContentInfoLC |
|
2154 |
// ----------------------------------------------------------------------------- |
|
2155 |
// |
|
2156 |
CHsContentInfo* CXnEditor::CreateContentInfoLC( CXnPluginData& aPlugin, |
|
2157 |
RPointerArray< CHsContentInfo >& aInfos ) |
|
2158 |
{ |
|
2159 |
CHsContentInfo* contentInfo( NULL ); |
|
2160 |
if ( aPlugin.Occupied() ) |
|
2161 |
{ |
|
2162 |
for ( TInt i = 0; i < aInfos.Count() && !contentInfo; i++ ) |
|
2163 |
{ |
|
2164 |
CHsContentInfo* info = aInfos[i]; |
|
2165 |
if ( ( !aPlugin.PublisherName().Length() && |
|
2166 |
aPlugin.PluginUid().CompareF( info->Uid() ) == 0 ) || |
|
2167 |
( aPlugin.PublisherName().Length() && |
|
2168 |
aPlugin.PublisherName().CompareF( info->PublisherId() ) == 0 ) |
|
2169 |
) |
|
2170 |
{ |
|
2171 |
contentInfo = info->CloneL(); |
|
2172 |
CleanupStack::PushL( contentInfo ); |
|
2173 |
contentInfo->SetPluginIdL( aPlugin.PluginId() ); |
|
2174 |
contentInfo->SetCanBeRemoved( aPlugin.Removable() ); |
|
2175 |
} |
|
2176 |
} |
|
2177 |
} |
|
2178 |
return contentInfo; |
|
2179 |
} |
|
2180 |
||
2181 |
// ----------------------------------------------------------------------------- |
|
2182 |
// CXnEditor::IsViewFull |
|
2183 |
// ----------------------------------------------------------------------------- |
|
2184 |
// |
|
2185 |
TBool CXnEditor::IsViewFull( CXnViewData& aViewData ) |
|
2186 |
{ |
|
2187 |
TBool isFull( ETrue ); |
|
2188 |
||
2189 |
RPointerArray< CXnPluginData >& plugins( |
|
2190 |
aViewData.PluginData() ); |
|
2191 |
||
2192 |
for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
2193 |
{ |
|
2194 |
CXnPluginData* plugin = plugins[ i ]; |
|
2195 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
2196 |
if ( plugin && !plugin->Occupied() && plugin->Editable() ) |
34 | 2197 |
{ |
2198 |
isFull = EFalse; |
|
2199 |
break; |
|
2200 |
} |
|
2201 |
} |
|
2202 |
||
2203 |
return isFull; |
|
2204 |
} |
|
2205 |
||
2206 |
// ----------------------------------------------------------------------------- |
|
2207 |
// CXnBackgroundManager::OOMSysHandler |
|
2208 |
// ----------------------------------------------------------------------------- |
|
2209 |
// |
|
2210 |
CXnOomSysHandler& CXnEditor::OomSysHandler() const |
|
2211 |
{ |
|
2212 |
__ASSERT_DEBUG( iOomSysHandler , User::Panic( _L("xneditor"), 0 ) ); |
|
2213 |
||
2214 |
return *iOomSysHandler; |
|
2215 |
} |
|
2216 |
||
2217 |
// End of file |