author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:00:00 +0300 | |
branch | RCL_3 |
changeset 93 | b01126ce0bec |
parent 88 | 3321d3e205b6 |
permissions | -rw-r--r-- |
83 | 1 |
/* |
2 |
* Copyright (c) 2009 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: |
|
15 |
* CWmWidgetData implementation. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <fbs.h> |
|
22 |
#include <bautils.h> |
|
23 |
#include <s32file.h> |
|
24 |
#include <hscontentinfo.h> |
|
25 |
#include <widgetregistryclient.h> // widgetreqistry |
|
26 |
#include <eikenv.h> |
|
27 |
#include <avkon.mbg> |
|
28 |
#include <avkon.rsg> |
|
29 |
#include <AknsDrawUtils.h> |
|
30 |
#include <AknBitmapAnimation.h> |
|
31 |
#include <barsread.h> |
|
32 |
#include <widgetmanagerview.rsg> |
|
33 |
||
34 |
#include "wmwidgetdata.h" |
|
35 |
#include "wmwidgetdataobserver.h" |
|
36 |
#include "wmpersistentwidgetorder.h" |
|
37 |
#include "wmresourceloader.h" |
|
38 |
#include "wmcommon.h" |
|
39 |
#include "wmimageconverter.h" |
|
40 |
||
41 |
// --------------------------------------------------------- |
|
42 |
// CWmWidgetData::NewL |
|
43 |
// --------------------------------------------------------- |
|
44 |
// |
|
45 |
CWmWidgetData* CWmWidgetData::NewL( |
|
46 |
const TSize& aLogoSize, |
|
47 |
CWmResourceLoader& aWmResourceLoader, |
|
48 |
CHsContentInfo* aHsContentInfo, |
|
49 |
RWidgetRegistryClientSession* aRegistryClientSession ) |
|
50 |
{ |
|
51 |
CWmWidgetData* self = CWmWidgetData::NewLC( |
|
52 |
aLogoSize, aWmResourceLoader, |
|
53 |
aHsContentInfo, aRegistryClientSession ); |
|
54 |
CleanupStack::Pop(); // self; |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
// --------------------------------------------------------- |
|
59 |
// CWmWidgetData::NewLC |
|
60 |
// --------------------------------------------------------- |
|
61 |
// |
|
62 |
CWmWidgetData* CWmWidgetData::NewLC( |
|
63 |
const TSize& aLogoSize, |
|
64 |
CWmResourceLoader& aWmResourceLoader, |
|
65 |
CHsContentInfo* aHsContentInfo, |
|
66 |
RWidgetRegistryClientSession* aRegistryClientSession ) |
|
67 |
{ |
|
68 |
CWmWidgetData* self = new ( ELeave ) CWmWidgetData( |
|
69 |
aLogoSize, aWmResourceLoader ); |
|
70 |
CleanupStack::PushL(self); |
|
71 |
self->ConstructL( aHsContentInfo, aRegistryClientSession ); |
|
72 |
return self; |
|
73 |
} |
|
74 |
||
75 |
// --------------------------------------------------------- |
|
76 |
// CWmWidgetData::CWmWidgetData |
|
77 |
// --------------------------------------------------------- |
|
78 |
// |
|
79 |
CWmWidgetData::CWmWidgetData( const TSize& aLogoSize, |
|
80 |
CWmResourceLoader& aWmResourceLoader ) |
|
81 |
: iWmResourceLoader( aWmResourceLoader ) |
|
82 |
{ |
|
83 |
iLogoImage = NULL; |
|
84 |
iLogoImageMask = NULL; |
|
85 |
iHsContentInfo = NULL; |
|
86 |
iWidgetType = CWmWidgetData::EUnknown; |
|
87 |
iWrtType = CWmWidgetData::EUnIdentified; |
|
88 |
iPublisherUid = KNullUid; |
|
89 |
iLogoSize = aLogoSize; |
|
90 |
iAnimationTimer = NULL; |
|
91 |
iAnimationIndex = 0; |
|
92 |
iAsyncUninstalling = EFalse; |
|
93 |
iMdcaPoint = NULL; |
|
94 |
} |
|
95 |
||
96 |
// --------------------------------------------------------- |
|
97 |
// CWmWidgetData::ConstructL |
|
98 |
// --------------------------------------------------------- |
|
99 |
// |
|
100 |
void CWmWidgetData::ConstructL( |
|
101 |
CHsContentInfo* aHsContentInfo, |
|
102 |
RWidgetRegistryClientSession* aRegistryClientSession ) |
|
103 |
{ |
|
104 |
// start decoding the icon |
|
105 |
iImageConverter = CWmImageConverter::NewL(); |
|
106 |
iAnimationTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
107 |
||
108 |
InitL( aHsContentInfo, aRegistryClientSession ); |
|
109 |
||
110 |
// start logo handling |
|
111 |
HandleIconString( HsContentInfo().IconPath() ); |
|
112 |
} |
|
113 |
||
114 |
// --------------------------------------------------------- |
|
115 |
// CWmWidgetData::InitL |
|
116 |
// --------------------------------------------------------- |
|
117 |
// |
|
118 |
void CWmWidgetData::InitL( |
|
119 |
CHsContentInfo* aHsContentInfo, |
|
120 |
RWidgetRegistryClientSession* aRegistryClientSession ) |
|
121 |
{ |
|
122 |
// analyse the widget type |
|
123 |
if ( aHsContentInfo->Type() == KContentTemplate ) |
|
124 |
{ |
|
125 |
iWidgetType = CWmWidgetData::ECps; // wrt widgets included in this gategory |
|
126 |
} |
|
127 |
else if ( aHsContentInfo->Type() == KContentWidget ) |
|
128 |
{ |
|
129 |
iWidgetType = CWmWidgetData::ENative; |
|
130 |
} |
|
131 |
||
132 |
// get publisher uid from widget registry |
|
133 |
FetchPublisherUidL( aHsContentInfo->PublisherId(), |
|
134 |
aRegistryClientSession ); |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
135 |
|
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
136 |
// delete the old list box item |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
137 |
delete iMdcaPoint; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
138 |
iMdcaPoint = NULL; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
139 |
|
83 | 140 |
// create iMdcaPoint for listbox |
141 |
_LIT( KFormatStr, "0\t%S"); |
|
142 |
iMdcaPoint = HBufC::NewL( |
|
143 |
aHsContentInfo->Name().Length() + KFormatStr().Length() ); |
|
144 |
iMdcaPoint->Des().Format( KFormatStr(), &aHsContentInfo->Name() ); |
|
145 |
||
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
146 |
// delete the old content info |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
147 |
delete iHsContentInfo; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
148 |
iHsContentInfo = NULL; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
149 |
|
83 | 150 |
// take ownership of the content info |
151 |
iHsContentInfo = aHsContentInfo; |
|
152 |
} |
|
153 |
||
154 |
// --------------------------------------------------------- |
|
155 |
// CWmWidgetData::~CWmWidgetData |
|
156 |
// --------------------------------------------------------- |
|
157 |
// |
|
158 |
CWmWidgetData::~CWmWidgetData() |
|
159 |
{ |
|
160 |
SetObserver( NULL ); |
|
161 |
DestroyAnimData(); |
|
162 |
delete iAnimationTimer; |
|
163 |
delete iLogoImage; |
|
164 |
delete iLogoImageMask; |
|
165 |
delete iImageConverter; |
|
166 |
delete iHsContentInfo; |
|
167 |
delete iMdcaPoint; |
|
168 |
} |
|
169 |
||
170 |
// --------------------------------------------------------- |
|
171 |
// CWmWidgetData::SetObserver |
|
172 |
// --------------------------------------------------------- |
|
173 |
// |
|
174 |
void CWmWidgetData::SetObserver( MWmWidgetDataObserver* aObserver ) |
|
175 |
{ |
|
176 |
iObserver = aObserver; |
|
177 |
} |
|
178 |
||
179 |
// --------------------------------------------------------- |
|
180 |
// CWmWidgetData::SetObserver |
|
181 |
// --------------------------------------------------------- |
|
182 |
// |
|
183 |
void CWmWidgetData::SetPersistentWidgetOrder( |
|
184 |
const CWmPersistentWidgetOrder* aPersistentWidgetOrder ) |
|
185 |
{ |
|
186 |
iPersistentWidgetOrder = aPersistentWidgetOrder; |
|
187 |
} |
|
188 |
||
189 |
// --------------------------------------------------------- |
|
190 |
// CWmWidgetData::EqualsTo |
|
191 |
// --------------------------------------------------------- |
|
192 |
// |
|
193 |
TBool CWmWidgetData::EqualsTo( CHsContentInfo& aContentInfo ) |
|
194 |
{ |
|
195 |
return ( |
|
196 |
HsContentInfo().Uid() == aContentInfo.Uid() && |
|
197 |
HsContentInfo().PublisherId() == aContentInfo.PublisherId() ); |
|
198 |
} |
|
199 |
||
200 |
// --------------------------------------------------------- |
|
201 |
// CWmWidgetData::CompareByName |
|
202 |
// --------------------------------------------------------- |
|
203 |
// |
|
204 |
TInt CWmWidgetData::CompareByName( |
|
205 |
const CWmWidgetData& aDataOne, const CWmWidgetData& aDataTwo ) |
|
206 |
{ |
|
207 |
// negate the result for ascending alphabetical order |
|
208 |
TInt result = aDataOne.Name().CompareC( aDataTwo.Name() ); |
|
209 |
return result; |
|
210 |
} |
|
211 |
||
212 |
// --------------------------------------------------------- |
|
213 |
// CWmWidgetData::CompareByPersistentWidgetOrder |
|
214 |
// --------------------------------------------------------- |
|
215 |
// |
|
216 |
TInt CWmWidgetData::CompareByPersistentWidgetOrder( |
|
217 |
const CWmWidgetData& aDataOne, const CWmWidgetData& aDataTwo ) |
|
218 |
{ |
|
219 |
TInt result; |
|
220 |
const CWmPersistentWidgetOrder* order = aDataOne.iPersistentWidgetOrder; |
|
221 |
if ( order && !order->IsEmpty() ) |
|
222 |
{ |
|
223 |
result = order->IndexOf( aDataOne ) - order->IndexOf( aDataTwo ); |
|
224 |
} |
|
225 |
else |
|
226 |
{ |
|
227 |
// fallback: if persistent widget order is not available |
|
228 |
// or it is empty (this is the case on first start, or if the persistent |
|
229 |
// file is corrupted or deleted) -> order widgets by name. |
|
230 |
result = CompareByName( aDataOne, aDataTwo ); |
|
231 |
} |
|
232 |
return result; |
|
233 |
} |
|
234 |
||
235 |
// --------------------------------------------------------- |
|
236 |
// CWmWidgetData::HandleIconString |
|
237 |
// --------------------------------------------------------- |
|
238 |
// |
|
239 |
void CWmWidgetData::HandleIconString( const TDesC& aIconStr ) |
|
240 |
{ |
|
241 |
HBufC* iconStr = NULL; |
|
242 |
if ( aIconStr.Length() == 0 && |
|
243 |
iPublisherUid != KNullUid ) |
|
244 |
{ |
|
245 |
// workaround for wrt widgets icon |
|
246 |
_LIT( KUidTag, "uid(0x%x)" ); |
|
247 |
const TInt KLength = 32; |
|
248 |
TBuf<KLength> uidBuf; |
|
249 |
uidBuf.Format( KUidTag, iPublisherUid.iUid ); |
|
250 |
iconStr = uidBuf.Alloc(); |
|
251 |
} |
|
252 |
else |
|
253 |
{ |
|
254 |
iconStr = aIconStr.Alloc(); |
|
255 |
} |
|
256 |
||
257 |
// nothing to do if no iconstr |
|
258 |
if ( !iconStr ){ return; } |
|
259 |
||
260 |
TSize size( iLogoSize ); |
|
261 |
if ( iLogoImage ) { size = iLogoImage->SizeInPixels(); } |
|
262 |
if ( size != iLogoSize && |
|
263 |
iLogoSize.iWidth > 0 && iLogoSize.iHeight > 0 ) |
|
264 |
{ |
|
265 |
size = iLogoSize; |
|
266 |
} |
|
267 |
||
268 |
iImageConverter->HandleIconString( |
|
269 |
size, |
|
270 |
*iconStr, |
|
271 |
iLogoImage, |
|
272 |
iLogoImageMask ); |
|
273 |
||
274 |
delete iconStr; |
|
275 |
iconStr = NULL; |
|
276 |
||
277 |
FireDataChanged(); // draw default icon |
|
278 |
} |
|
279 |
||
280 |
// --------------------------------------------------------- |
|
281 |
// CWmWidgetData::FireDataChanged |
|
282 |
// --------------------------------------------------------- |
|
283 |
// |
|
284 |
void CWmWidgetData::FireDataChanged() |
|
285 |
{ |
|
286 |
if ( iObserver ) |
|
287 |
{ |
|
288 |
iObserver->HandleWidgetDataChanged( this ); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
// ---------------------------------------------------- |
|
293 |
// CWmWidgetData::UidFromString |
|
294 |
// ---------------------------------------------------- |
|
295 |
// |
|
296 |
TUid CWmWidgetData::UidFromString( const TDesC8& aUidString ) const |
|
297 |
{ |
|
298 |
TUid uid( TUid::Null() ); |
|
299 |
const TInt KHexPrefixLength = 2; |
|
300 |
if ( aUidString.Length() > KHexPrefixLength ) |
|
301 |
{ |
|
302 |
TUint id = 0; |
|
303 |
TLex8 lex( aUidString.Mid( KHexPrefixLength ) ); |
|
304 |
if ( lex.Val( id, EHex ) == KErrNone ) |
|
305 |
{ |
|
306 |
uid.iUid = (TInt32)id; |
|
307 |
} |
|
308 |
} |
|
309 |
return uid; |
|
310 |
} |
|
311 |
||
312 |
// ---------------------------------------------------- |
|
313 |
// CWmWidgetData::PublisherUid |
|
314 |
// ---------------------------------------------------- |
|
315 |
// |
|
316 |
TUid CWmWidgetData::PublisherUid() |
|
317 |
{ |
|
318 |
return iPublisherUid; |
|
319 |
} |
|
320 |
||
321 |
// ---------------------------------------------------- |
|
322 |
// CWmWidgetData::FetchPublisherUidL |
|
323 |
// ---------------------------------------------------- |
|
324 |
// |
|
325 |
void CWmWidgetData::FetchPublisherUidL( |
|
326 |
const TDesC& aPublisherId, |
|
327 |
RWidgetRegistryClientSession* aRegistryClientSession ) |
|
328 |
{ |
|
329 |
if ( iPublisherUid == KNullUid && |
|
330 |
aPublisherId != KNullDesC && |
|
331 |
iWidgetType != CWmWidgetData::ENative && |
|
332 |
aRegistryClientSession ) |
|
333 |
{ |
|
334 |
TInt widgetUid = aRegistryClientSession->GetWidgetUidL( aPublisherId ); |
|
335 |
if ( widgetUid != 0 ) |
|
336 |
{ |
|
337 |
// WRT widget |
|
338 |
iPublisherUid = TUid::Uid( widgetUid ); |
|
339 |
||
340 |
// wrt widget type |
|
341 |
CWidgetPropertyValue* value( NULL ); |
|
342 |
value = aRegistryClientSession->GetWidgetPropertyValueL( |
|
343 |
iPublisherUid, ENokiaWidget ); |
|
344 |
if ( value && *value == 1 ) |
|
345 |
{ |
|
346 |
iWrtType = CWmWidgetData::EWgz; |
|
347 |
} |
|
348 |
else if ( value && *value == 2 ) |
|
349 |
{ |
|
350 |
iWrtType = CWmWidgetData::EWgt; |
|
351 |
} |
|
352 |
else |
|
353 |
{ |
|
354 |
iWrtType = CWmWidgetData::EUnIdentified; |
|
355 |
} |
|
356 |
||
357 |
delete value; |
|
358 |
value = NULL; |
|
359 |
||
360 |
} |
|
361 |
else |
|
362 |
{ |
|
363 |
iPublisherUid = KNullUid; |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
// --------------------------------------------------------- |
|
369 |
// CWmWidgetData::Description |
|
370 |
// --------------------------------------------------------- |
|
371 |
// |
|
372 |
const TDesC& CWmWidgetData::Name() const |
|
373 |
{ |
|
374 |
return ( iAsyncUninstalling ? |
|
375 |
iWmResourceLoader.Uninstalling() : |
|
376 |
iHsContentInfo->Name() ); |
|
377 |
} |
|
378 |
||
379 |
// --------------------------------------------------------- |
|
380 |
// CWmWidgetData::Description |
|
381 |
// --------------------------------------------------------- |
|
382 |
// |
|
383 |
const TDesC& CWmWidgetData::Description() const |
|
384 |
{ |
|
385 |
if ( iHsContentInfo->Description().Length() <= 0 && |
|
386 |
&iWmResourceLoader ) |
|
387 |
{ |
|
388 |
return ( ( iPublisherUid != KNullUid ) ? |
|
389 |
iWmResourceLoader.WrtDescription() : |
|
390 |
iWmResourceLoader.NoDescription() ); |
|
391 |
} |
|
392 |
return iHsContentInfo->Description(); |
|
393 |
} |
|
394 |
||
395 |
// --------------------------------------------------------- |
|
396 |
// CWmWidgetData::ReCreateLogo |
|
397 |
// --------------------------------------------------------- |
|
398 |
// |
|
399 |
void CWmWidgetData::UpdateLogo( const TSize& aSize, TBool aReCreateLogo ) |
|
400 |
{ |
|
401 |
iLogoSize = aSize; |
|
402 |
if ( aReCreateLogo ) |
|
403 |
{ |
|
404 |
delete iLogoImage; |
|
405 |
iLogoImage = NULL; |
|
406 |
delete iLogoImageMask; |
|
407 |
iLogoImageMask = NULL; |
|
408 |
HandleIconString( HsContentInfo().IconPath() ); |
|
409 |
} |
|
410 |
else |
|
411 |
{ |
|
412 |
iImageConverter->UpdateImageSize( |
|
413 |
iLogoSize, |
|
414 |
HsContentInfo().IconPath(), |
|
415 |
*iLogoImage, |
|
416 |
*iLogoImageMask ); |
|
417 |
} |
|
418 |
} |
|
419 |
||
420 |
// --------------------------------------------------------- |
|
421 |
// CWmWidgetData::ReplaceContentInfo |
|
422 |
// --------------------------------------------------------- |
|
423 |
// |
|
424 |
TBool CWmWidgetData::ReplaceContentInfo( |
|
425 |
CHsContentInfo* aHsContentInfo ) |
|
426 |
{ |
|
427 |
TBool sameAppearance = ( |
|
428 |
iHsContentInfo->Name() == aHsContentInfo->Name() && |
|
429 |
iHsContentInfo->Description() == aHsContentInfo->Description() && |
|
430 |
iHsContentInfo->CanBeAdded() == aHsContentInfo->CanBeAdded() ); |
|
431 |
TBool sameLogo = ( |
|
432 |
iHsContentInfo->IconPath() == aHsContentInfo->IconPath() ); |
|
433 |
||
434 |
// re-init the object, take care about leave. |
|
435 |
TRAPD( err, InitL( aHsContentInfo, NULL ); ); |
|
436 |
if ( KErrNone != err ) |
|
437 |
{ |
|
438 |
delete aHsContentInfo; |
|
439 |
aHsContentInfo = NULL; |
|
440 |
} |
|
441 |
||
442 |
if ( !sameAppearance ) |
|
443 |
{ |
|
444 |
// fire change event -> widget redrawn |
|
445 |
FireDataChanged(); |
|
446 |
} |
|
447 |
||
448 |
if ( !sameLogo ) |
|
449 |
{ |
|
450 |
// re-convert image |
|
451 |
// change event will be fired later when bitmap is ready |
|
452 |
UpdateLogo( iLogoSize, ETrue ); |
|
453 |
} |
|
454 |
||
455 |
return !( sameAppearance && sameLogo ); |
|
456 |
} |
|
457 |
||
458 |
// --------------------------------------------------------- |
|
459 |
// CWmWidgetData::VisualizeUninstall |
|
460 |
// --------------------------------------------------------- |
|
461 |
// |
|
462 |
void CWmWidgetData::VisualizeUninstallL() |
|
463 |
{ |
|
464 |
DestroyAnimData(); |
|
465 |
PrepairAnimL(); |
|
466 |
||
467 |
iAsyncUninstalling = ETrue; |
|
468 |
iAnimationIndex = 0; |
|
469 |
const TInt tickInterval = 400000; |
|
470 |
iAnimationTimer->Start( |
|
471 |
tickInterval,tickInterval,TCallBack(AnimationTick, this)); |
|
472 |
} |
|
473 |
||
474 |
// --------------------------------------------------------- |
|
475 |
// CWmWidgetData::PrepairAnimL |
|
476 |
// --------------------------------------------------------- |
|
477 |
// |
|
478 |
void CWmWidgetData::PrepairAnimL() |
|
479 |
{ |
|
480 |
TInt resourceId = R_QGN_GRAF_WAIT_BAR_ANIM; |
|
481 |
CAknBitmapAnimation* aknAnimation = CAknBitmapAnimation::NewL(); |
|
482 |
CleanupStack::PushL( aknAnimation ); |
|
483 |
aknAnimation->SetScaleModeForAnimationFrames(EAspectRatioNotPreserved); |
|
484 |
TAknsItemID iid; |
|
485 |
iid.Set(EAknsMajorAvkon, resourceId ); |
|
486 |
if ( !aknAnimation ->ConstructFromSkinL( iid ) ) |
|
487 |
{ |
|
488 |
TResourceReader readerForAnimation; |
|
489 |
CCoeEnv::Static()->CreateResourceReaderLC( readerForAnimation,resourceId ); |
|
490 |
aknAnimation->ConstructFromResourceL( readerForAnimation ); |
|
491 |
CleanupStack::PopAndDestroy(); |
|
492 |
} |
|
493 |
TInt endFrame = aknAnimation ->BitmapAnimData()->FrameArray().Count()-1; |
|
494 |
for ( TInt i=0; i<=endFrame; i++ ) |
|
495 |
{ |
|
496 |
aknAnimation ->BitmapAnimData()->FrameArray().At(i)->SetBitmapsOwnedExternally( ETrue ); |
|
497 |
CFbsBitmap* bitmap = aknAnimation ->BitmapAnimData()->FrameArray().At(i)->Bitmap(); |
|
498 |
CFbsBitmap* bitmapMask = aknAnimation ->BitmapAnimData()->FrameArray().At(i)->Mask(); |
|
499 |
if ( bitmap && bitmapMask ) |
|
500 |
{ |
|
501 |
iUninstallAnimIcons.AppendL( bitmap ); |
|
502 |
iUninstallAnimIcons.AppendL( bitmapMask ); |
|
503 |
} |
|
504 |
} |
|
505 |
CleanupStack::PopAndDestroy( aknAnimation ); |
|
506 |
} |
|
507 |
||
508 |
// --------------------------------------------------------- |
|
509 |
// CWmWidgetData::DestroyAnimData |
|
510 |
// --------------------------------------------------------- |
|
511 |
// |
|
512 |
void CWmWidgetData::DestroyAnimData() |
|
513 |
{ |
|
514 |
if ( iAnimationTimer && iAnimationTimer->IsActive() ) |
|
515 |
{ |
|
516 |
iAnimationTimer->Cancel(); |
|
517 |
} |
|
518 |
||
519 |
for( TInt i=0; i < iUninstallAnimIcons.Count(); i++ ) |
|
520 |
{ |
|
521 |
CFbsBitmap* bitmap = iUninstallAnimIcons[i]; |
|
522 |
delete bitmap; bitmap = NULL; |
|
523 |
} |
|
524 |
iUninstallAnimIcons.Close(); |
|
525 |
} |
|
526 |
||
527 |
// --------------------------------------------------------- |
|
528 |
// CWmWidgetData::AnimationTick |
|
529 |
// --------------------------------------------------------- |
|
530 |
// |
|
531 |
TInt CWmWidgetData::AnimationTick( TAny* aPtr ) |
|
532 |
{ |
|
533 |
CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr ); |
|
534 |
self->iAnimationIndex += 2; |
|
535 |
if ( self->iAnimationIndex >= self->iUninstallAnimIcons.Count() -1 ) |
|
536 |
{ |
|
537 |
self->iAnimationIndex = 0; // restart from beginging |
|
538 |
} |
|
539 |
self->FireDataChanged(); |
|
540 |
return 1; |
|
541 |
} |
|
542 |
||
543 |
// --------------------------------------------------------- |
|
544 |
// CWmWidgetData::AnimationBitmap |
|
545 |
// --------------------------------------------------------- |
|
546 |
// |
|
547 |
const CFbsBitmap* CWmWidgetData::AnimationBitmap( const TSize& aSize ) |
|
548 |
{ |
|
549 |
CFbsBitmap* bitmap = NULL; |
|
550 |
if ( iUninstallAnimIcons.Count() ) |
|
551 |
{ |
|
552 |
TInt index = iAnimationIndex; |
|
553 |
if ( index >= iUninstallAnimIcons.Count() - 1 ) |
|
554 |
{ |
|
555 |
index = 0; |
|
556 |
} |
|
557 |
bitmap = iUninstallAnimIcons[index]; |
|
558 |
if ( bitmap->SizeInPixels() != aSize ) |
|
559 |
{ |
|
560 |
AknIconUtils::SetSize( bitmap, aSize, |
|
561 |
EAspectRatioNotPreserved ); |
|
562 |
} |
|
563 |
} |
|
564 |
return bitmap; |
|
565 |
} |
|
566 |
||
567 |
// --------------------------------------------------------- |
|
568 |
// CWmWidgetData::AnimationMask |
|
569 |
// --------------------------------------------------------- |
|
570 |
// |
|
571 |
const CFbsBitmap* CWmWidgetData::AnimationMask( const TSize& aSize ) |
|
572 |
{ |
|
573 |
CFbsBitmap* mask = NULL; |
|
574 |
if ( iUninstallAnimIcons.Count() ) |
|
575 |
{ |
|
576 |
TInt index = iAnimationIndex+1; |
|
577 |
if ( index >= iUninstallAnimIcons.Count() ) |
|
578 |
{ |
|
579 |
index = 1; |
|
580 |
} |
|
581 |
mask = iUninstallAnimIcons[index]; |
|
582 |
if ( mask && mask->SizeInPixels() != aSize ) |
|
583 |
{ |
|
584 |
AknIconUtils::SetSize( mask, aSize, |
|
585 |
EAspectRatioNotPreserved ); |
|
586 |
} |
|
587 |
} |
|
588 |
return mask; |
|
589 |
} |
|
590 |
||
591 |
// --------------------------------------------------------- |
|
592 |
// CWmWidgetData::IsUninstalling |
|
593 |
// --------------------------------------------------------- |
|
594 |
// |
|
595 |
TBool CWmWidgetData::IsUninstalling() |
|
596 |
{ |
|
597 |
return iAsyncUninstalling; |
|
598 |
} |
|
599 |
||
600 |
// --------------------------------------------------------- |
|
601 |
// CWmWidgetData::MdcaPoint |
|
602 |
// --------------------------------------------------------- |
|
603 |
// |
|
604 |
const TDesC& CWmWidgetData::MdcaPoint() const |
|
605 |
{ |
|
606 |
if ( iMdcaPoint ) |
|
607 |
return *iMdcaPoint; |
|
608 |
else |
|
609 |
return KNullDesC; |
|
610 |
} |
|
611 |
||
612 |
// --------------------------------------------------------- |
|
613 |
// CWmWidgetData::StopUninstallAnimation |
|
614 |
// --------------------------------------------------------- |
|
615 |
// |
|
616 |
void CWmWidgetData::StopUninstallAnimation() |
|
617 |
{ |
|
618 |
iAsyncUninstalling = EFalse; |
|
619 |
DestroyAnimData(); |
|
620 |
FireDataChanged(); //redraw |
|
621 |
} |
|
622 |
||
623 |
// End of file |
|
624 |