62
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 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: Call object loading.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <akniconconfig.h>
|
|
22 |
#include <AknsUtils.h>
|
|
23 |
#include "BMCallObjectManager.h"
|
|
24 |
#include "BMUtils.h"
|
|
25 |
#include "BMCallObjectUtils.h"
|
|
26 |
#include "BMPanic.h"
|
|
27 |
#include "BMMediaReaderFactory.h"
|
|
28 |
#include "BMMediaReaderInterface.h"
|
|
29 |
#include "BMBubbleImageManager.h"
|
|
30 |
|
|
31 |
// CONSTANTS
|
|
32 |
|
|
33 |
// MACROS
|
|
34 |
|
|
35 |
// LOCAL CONSTANTS AND MACROS
|
|
36 |
const TInt KBMBubbleIdNone = -2;
|
|
37 |
const TInt KBMCallTextAlphaValue = 128;
|
|
38 |
|
|
39 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// CBubbleCallObjectManager::CBubbleCallObjectManager
|
|
43 |
// C++ default constructor can NOT contain any code, that
|
|
44 |
// might leave.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CBubbleCallObjectManager::CBubbleCallObjectManager(
|
|
48 |
CBubbleManager& aBubbleManager ) : iBubbleManager( aBubbleManager )
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
// CBubbleCallObjectManager::ConstructL
|
|
54 |
// Symbian 2nd phase constructor can leave.
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
void CBubbleCallObjectManager::ConstructL()
|
|
58 |
{
|
|
59 |
iIdleProcessor = CIdle::NewL( CActive::EPriorityIdle );
|
|
60 |
iLoadingState = EBMLoaderReady;
|
|
61 |
iBubbleId = KBMBubbleIdNone;
|
|
62 |
}
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CBubbleCallObjectManager::NewL
|
|
66 |
// Two-phased constructor.
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CBubbleCallObjectManager* CBubbleCallObjectManager::NewL(
|
|
70 |
CBubbleManager& aBubbleManager )
|
|
71 |
{
|
|
72 |
CBubbleCallObjectManager* self =
|
|
73 |
new( ELeave ) CBubbleCallObjectManager( aBubbleManager );
|
|
74 |
|
|
75 |
CleanupStack::PushL( self );
|
|
76 |
self->ConstructL( );
|
|
77 |
CleanupStack::Pop( self );
|
|
78 |
|
|
79 |
return self;
|
|
80 |
}
|
|
81 |
|
|
82 |
// Destructor
|
|
83 |
CBubbleCallObjectManager::~CBubbleCallObjectManager()
|
|
84 |
{
|
|
85 |
Reset();
|
|
86 |
|
|
87 |
if ( iIdleProcessor )
|
|
88 |
{
|
|
89 |
iIdleProcessor->Cancel();
|
|
90 |
delete iIdleProcessor;
|
|
91 |
}
|
|
92 |
|
|
93 |
delete iCallThemeImageIcon;
|
|
94 |
}
|
|
95 |
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
// CBubbleCallObjectManager::Reset
|
|
98 |
//
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CBubbleCallObjectManager::Reset()
|
|
102 |
{
|
|
103 |
iLoadingState = EBMLoaderReady;
|
|
104 |
iBubbleId = KBMBubbleIdNone;
|
|
105 |
delete iMediaReader;
|
|
106 |
iMediaReader = NULL;
|
|
107 |
delete iCallText;
|
|
108 |
iCallText = NULL;
|
|
109 |
delete iCallImage;
|
|
110 |
iCallImage = NULL;
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// CBubbleCallObjectManager::LoadImageFromFile
|
|
115 |
//
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
void CBubbleCallObjectManager::LoadImageFromFile(
|
|
119 |
const CBubbleManager::TBubbleId& aBubbleId,
|
|
120 |
const TDesC& aFileName,
|
|
121 |
const TImageLoadingParams& aParams )
|
|
122 |
{
|
|
123 |
if ( !aFileName.Length() )
|
|
124 |
{
|
|
125 |
return;
|
|
126 |
}
|
|
127 |
|
|
128 |
if ( iLoadingState == EBMSuspended )
|
|
129 |
{
|
|
130 |
delete iCallImage;
|
|
131 |
iCallImage = aFileName.Alloc();
|
|
132 |
iImageLoadParams = aParams;
|
|
133 |
iBubbleId = aBubbleId;
|
|
134 |
return; // wait for resume
|
|
135 |
}
|
|
136 |
|
|
137 |
// queueing not supported, keep the existing
|
|
138 |
if ( iLoadingState == EBMLoaderReady )
|
|
139 |
{
|
|
140 |
TRAPD( err, ReadFromFileL( aFileName,
|
|
141 |
aParams.iPreferredSize,
|
|
142 |
aParams.iTinyImageSize ) );
|
|
143 |
if ( err == KErrNone )
|
|
144 |
{
|
|
145 |
iLoadingState = EBMLoadingImage;
|
|
146 |
delete iCallImage;
|
|
147 |
iCallImage = aFileName.Alloc();
|
|
148 |
iImageLoadParams = aParams;
|
|
149 |
iBubbleId = aBubbleId;
|
|
150 |
}
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
// CBubbleCallObjectManager::ReadFromFileL
|
|
156 |
//
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
void CBubbleCallObjectManager::ReadFromFileL(
|
|
160 |
const TDesC& aFileName,
|
|
161 |
const TSize& aPreferredImageSize,
|
|
162 |
const TSize& aTinyImageSize )
|
|
163 |
{
|
|
164 |
delete iMediaReader;
|
|
165 |
iMediaReader = NULL;
|
|
166 |
iMediaReader = BubbleMediaReaderFactory::CreateReaderL( aFileName );
|
|
167 |
|
|
168 |
TSize sourceSize( iMediaReader->SourceSize() );
|
|
169 |
|
|
170 |
TReal scaleFactor( 0 );
|
|
171 |
TRect clipRect( 0, 0, 0, 0 );
|
|
172 |
TSize targetSize( 0, 0 );
|
|
173 |
|
|
174 |
// if the caller image (source size) is bigger than aPreferredImageSize (the whole caller-image area)
|
|
175 |
// then some down scaling is required.
|
|
176 |
if ( sourceSize.iHeight > aPreferredImageSize.iHeight && sourceSize.iWidth > aPreferredImageSize.iWidth )
|
|
177 |
{
|
|
178 |
targetSize = aPreferredImageSize;
|
|
179 |
|
|
180 |
BubbleCallObjectUtils::GetScaleFactorAndClipRect(
|
|
181 |
sourceSize,
|
|
182 |
aPreferredImageSize,
|
|
183 |
BubbleCallObjectUtils::EFillTarget,
|
|
184 |
scaleFactor,
|
|
185 |
clipRect );
|
|
186 |
}
|
|
187 |
else // no scaling. wide or tall images gets cropped from center if required.
|
|
188 |
{
|
|
189 |
targetSize = aPreferredImageSize;
|
|
190 |
scaleFactor = 1;
|
|
191 |
TInt x_offset = 0;
|
|
192 |
TInt y_offset = 0;
|
|
193 |
|
|
194 |
if ( sourceSize.iWidth > aPreferredImageSize.iWidth )
|
|
195 |
{
|
|
196 |
x_offset = ( sourceSize.iWidth - aPreferredImageSize.iWidth ) / 2;
|
|
197 |
}
|
|
198 |
if ( sourceSize.iHeight > aPreferredImageSize.iHeight )
|
|
199 |
{
|
|
200 |
y_offset = ( sourceSize.iHeight - aPreferredImageSize.iHeight ) / 2;
|
|
201 |
}
|
|
202 |
|
|
203 |
clipRect = sourceSize;
|
|
204 |
|
|
205 |
if ( x_offset > 0 || y_offset > 0 )
|
|
206 |
{
|
|
207 |
// clip from center of the source image
|
|
208 |
clipRect.Shrink( x_offset, y_offset );
|
|
209 |
}
|
|
210 |
}
|
|
211 |
|
|
212 |
iMediaReader->StartReadingL( targetSize,
|
|
213 |
scaleFactor,
|
|
214 |
clipRect,
|
|
215 |
this );
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
// CBubbleCallObjectManager::LoadImageFromText
|
|
220 |
//
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CBubbleCallObjectManager::LoadImageFromText(
|
|
224 |
const CBubbleManager::TBubbleId& aBubbleId,
|
|
225 |
const TDesC& aText,
|
|
226 |
const TImageLoadingParams& aParams )
|
|
227 |
{
|
|
228 |
if ( !aText.Length() )
|
|
229 |
{
|
|
230 |
return;
|
|
231 |
}
|
|
232 |
|
|
233 |
if ( iLoadingState == EBMSuspended )
|
|
234 |
{
|
|
235 |
delete iCallText;
|
|
236 |
iCallText = aText.Alloc();
|
|
237 |
iImageLoadParams = aParams;
|
|
238 |
iBubbleId = aBubbleId;
|
|
239 |
return; // wait for resume
|
|
240 |
}
|
|
241 |
|
|
242 |
// queueing not supported, keep the existing
|
|
243 |
if ( iLoadingState == EBMLoaderReady )
|
|
244 |
{
|
|
245 |
delete iCallText;
|
|
246 |
iCallText = aText.Alloc();
|
|
247 |
iBubbleId = aBubbleId;
|
|
248 |
iImageLoadParams = aParams;
|
|
249 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
250 |
iIdleProcessor->Cancel();
|
|
251 |
iIdleProcessor->Start( idleCallback );
|
|
252 |
iLoadingState = EBMLoadingText;
|
|
253 |
}
|
|
254 |
}
|
|
255 |
|
|
256 |
// ---------------------------------------------------------------------------
|
|
257 |
// CBubbleCallObjectManager::CancelCallObjectLoading
|
|
258 |
//
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
void CBubbleCallObjectManager::CancelCallObjectLoading(
|
|
262 |
const CBubbleManager::TBubbleId& aBubbleId )
|
|
263 |
{
|
|
264 |
if ( iLoadingState != EBMLoaderReady &&
|
|
265 |
iBubbleId == aBubbleId )
|
|
266 |
{
|
|
267 |
Reset();
|
|
268 |
iIdleProcessor->Cancel();
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
// CBubbleCallObjectManager::Suspend
|
|
274 |
//
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CBubbleCallObjectManager::Suspend()
|
|
278 |
{
|
|
279 |
if ( iLoadingState != EBMLoaderReady )
|
|
280 |
{
|
|
281 |
// Cancel image/text reading
|
|
282 |
delete iMediaReader;
|
|
283 |
iMediaReader = NULL;
|
|
284 |
iIdleProcessor->Cancel();
|
|
285 |
}
|
|
286 |
|
|
287 |
// Set suspended state
|
|
288 |
iLoadingState = EBMSuspended;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
// CBubbleCallObjectManager::Resume
|
|
293 |
//
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
TInt CBubbleCallObjectManager::Resume()
|
|
297 |
{
|
|
298 |
TInt err = KErrNone;
|
|
299 |
|
|
300 |
if ( iLoadingState == EBMSuspended )
|
|
301 |
{
|
|
302 |
TRAP( err, DoResumeL() );
|
|
303 |
}
|
|
304 |
|
|
305 |
return err;
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// CBubbleCallObjectManager::DoResumeL
|
|
310 |
//
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
void CBubbleCallObjectManager::DoResumeL()
|
|
314 |
{
|
|
315 |
if ( iCallImage )
|
|
316 |
{
|
|
317 |
CBubbleManager::TPhoneCallState callState =
|
|
318 |
iBubbleManager.CallState( iBubbleId );
|
|
319 |
|
|
320 |
if ( callState < CBubbleManager::EIncoming &&
|
|
321 |
iImageLoadParams.iThumbnailSize != TSize(0,0) )
|
|
322 |
{
|
|
323 |
// switch to incall image size
|
|
324 |
iImageLoadParams.iPreferredSize =
|
|
325 |
iImageLoadParams.iThumbnailSize;
|
|
326 |
iImageLoadParams.iThumbnailSize = TSize(0,0);
|
|
327 |
iImageLoadParams.iTinyImageSize = TSize(0,0);
|
|
328 |
}
|
|
329 |
|
|
330 |
ReadFromFileL( *iCallImage,
|
|
331 |
iImageLoadParams.iPreferredSize,
|
|
332 |
iImageLoadParams.iTinyImageSize );
|
|
333 |
|
|
334 |
iLoadingState = EBMLoadingImage;
|
|
335 |
delete iCallImage;
|
|
336 |
iCallImage = NULL;
|
|
337 |
}
|
|
338 |
else if ( iCallText )
|
|
339 |
{
|
|
340 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
341 |
iIdleProcessor->Cancel();
|
|
342 |
iIdleProcessor->Start( idleCallback );
|
|
343 |
iLoadingState = EBMLoadingText;
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
Reset();
|
|
348 |
}
|
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------------------------
|
|
352 |
// CBubbleCallObjectManager::LoadCallThemeImage
|
|
353 |
//
|
|
354 |
// ---------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
void CBubbleCallObjectManager::LoadCallThemeImage(
|
|
357 |
CBubbleImageManager& aImageManager,
|
|
358 |
const TSize& aSize )
|
|
359 |
{
|
|
360 |
delete iCallThemeImageIcon;
|
|
361 |
iCallThemeImageIcon = NULL;
|
|
362 |
|
|
363 |
TRAPD( err, AllocateCallThemeImageIconL( aImageManager ) );
|
|
364 |
if ( !err )
|
|
365 |
{
|
|
366 |
iCallThemeImageSize = aSize;
|
|
367 |
|
|
368 |
if ( iLoadingState == EBMLoaderReady )
|
|
369 |
{
|
|
370 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
371 |
iIdleProcessor->Cancel();
|
|
372 |
iIdleProcessor->Start( idleCallback );
|
|
373 |
iLoadingState = EBMInitializingIcon;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
// CBubbleCallObjectManager::AllocateCallThemeImageIconL
|
|
380 |
//
|
|
381 |
// ---------------------------------------------------------------------------
|
|
382 |
//
|
|
383 |
void CBubbleCallObjectManager::AllocateCallThemeImageIconL(
|
|
384 |
CBubbleImageManager& aImageManager )
|
|
385 |
{
|
|
386 |
CEikImage* themeImage = new( ELeave ) CEikImage;
|
|
387 |
CleanupStack::PushL( themeImage );
|
|
388 |
aImageManager.SetBitmapToImage( themeImage,
|
|
389 |
EQgn_graf_call_image_1,
|
|
390 |
EQgn_graf_call_image_1_mask );
|
|
391 |
|
|
392 |
if ( themeImage->Bitmap() )
|
|
393 |
{
|
|
394 |
iCallThemeImageIcon = CGulIcon::NewL(
|
|
395 |
const_cast<CFbsBitmap*> (themeImage->Bitmap()),
|
|
396 |
const_cast<CFbsBitmap*> (themeImage->Mask()));
|
|
397 |
}
|
|
398 |
themeImage->SetPictureOwnedExternally( ETrue );
|
|
399 |
CleanupStack::PopAndDestroy( themeImage );
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------------------------
|
|
403 |
// CBubbleCallObjectManager::ReleaseCallThemeImage
|
|
404 |
//
|
|
405 |
// ---------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
void CBubbleCallObjectManager::ReleaseCallThemeImage()
|
|
408 |
{
|
|
409 |
delete iCallThemeImageIcon;
|
|
410 |
iCallThemeImageIcon = NULL;
|
|
411 |
}
|
|
412 |
|
|
413 |
// ---------------------------------------------------------------------------
|
|
414 |
// CBubbleCallObjectManager::ResizeCallThemeImage
|
|
415 |
//
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
void CBubbleCallObjectManager::ResizeCallThemeImage( const TSize& aSize )
|
|
419 |
{
|
|
420 |
iCallThemeImageSize = aSize;
|
|
421 |
AknIconUtils::SetSize( iCallThemeImageIcon->Bitmap(),
|
|
422 |
iCallThemeImageSize,
|
|
423 |
EAspectRatioPreservedSlice );
|
|
424 |
}
|
|
425 |
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
// CBubbleCallObjectManager::CallThemeImageIcon
|
|
428 |
//
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
CGulIcon* CBubbleCallObjectManager::CallThemeImageIcon()
|
|
432 |
{
|
|
433 |
return iCallThemeImageIcon;
|
|
434 |
}
|
|
435 |
|
|
436 |
// ---------------------------------------------------------------------------
|
|
437 |
// CBubbleCallObjectManager::IdleProcessorCallback
|
|
438 |
//
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
//
|
|
441 |
TInt CBubbleCallObjectManager::IdleProcessorCallback( TAny* aThis )
|
|
442 |
{
|
|
443 |
__ASSERT_ALWAYS( aThis,
|
|
444 |
Panic( EBMPanicCallObjectManager ) );
|
|
445 |
|
|
446 |
CBubbleCallObjectManager* self =
|
|
447 |
static_cast<CBubbleCallObjectManager*>( aThis );
|
|
448 |
|
|
449 |
TLoadingState state = self->iLoadingState;
|
|
450 |
|
|
451 |
if ( state == EBMLoadingText )
|
|
452 |
{
|
|
453 |
TRAP_IGNORE( self->DoLoadImageInIdleL() );
|
|
454 |
}
|
|
455 |
else if ( state == EBMInitializingIcon )
|
|
456 |
{
|
|
457 |
self->DoInitializeIcons();
|
|
458 |
}
|
|
459 |
else if ( state == EBMDeleting )
|
|
460 |
{
|
|
461 |
self->DoDeleteReaderInIdle();
|
|
462 |
}
|
|
463 |
|
|
464 |
return KErrNone;
|
|
465 |
}
|
|
466 |
|
|
467 |
// ---------------------------------------------------------------------------
|
|
468 |
// CBubbleCallObjectManager::DoLoadImageInIdleL
|
|
469 |
//
|
|
470 |
// ---------------------------------------------------------------------------
|
|
471 |
//
|
|
472 |
void CBubbleCallObjectManager::DoLoadImageInIdleL()
|
|
473 |
{
|
|
474 |
if ( iLoadingState == EBMLoadingText && iCallText )
|
|
475 |
{
|
|
476 |
AknIconConfig::TPreferredDisplayMode mode;
|
|
477 |
AknIconConfig::PreferredDisplayMode( mode,
|
|
478 |
AknIconConfig::EImageTypeIcon);
|
|
479 |
|
|
480 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
481 |
TRgb skinColor;
|
|
482 |
User::LeaveIfError( AknsUtils::GetCachedColor(
|
|
483 |
skin,
|
|
484 |
skinColor,
|
|
485 |
KAknsIIDQsnTextColors,
|
|
486 |
EAknsCIQsnTextColorsCG51 ) );
|
|
487 |
|
|
488 |
CFbsBitmap* bitmap = NULL;
|
|
489 |
CFbsBitmap* mask = NULL;
|
|
490 |
|
|
491 |
BubbleCallObjectUtils::CreateImageBitmapsFromTextLC(
|
|
492 |
*iCallText,
|
|
493 |
iBubbleManager.Rect(),
|
|
494 |
iImageLoadParams.iPreferredSize,
|
|
495 |
skinColor, // text color
|
|
496 |
KBMCallTextAlphaValue, // semitransparent
|
|
497 |
mode.iBitmapMode,
|
|
498 |
bitmap,
|
|
499 |
mask );
|
|
500 |
CleanupStack::Pop(2); // bitmap, mask
|
|
501 |
|
|
502 |
iBubbleManager.StartChanges();
|
|
503 |
iBubbleManager.SetCallObjectImage( iBubbleId,
|
|
504 |
bitmap,
|
|
505 |
mask,
|
|
506 |
ETrue );
|
|
507 |
iBubbleManager.EndChanges();
|
|
508 |
|
|
509 |
delete iCallText;
|
|
510 |
iCallText = NULL;
|
|
511 |
}
|
|
512 |
|
|
513 |
iLoadingState = EBMLoaderReady;
|
|
514 |
iBubbleId = KBMBubbleIdNone;
|
|
515 |
}
|
|
516 |
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
// CBubbleCallObjectManager::DoDeleteReaderInIdle
|
|
519 |
//
|
|
520 |
// ---------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
void CBubbleCallObjectManager::DoDeleteReaderInIdle()
|
|
523 |
{
|
|
524 |
Reset();
|
|
525 |
}
|
|
526 |
|
|
527 |
// ---------------------------------------------------------------------------
|
|
528 |
// CBubbleCallObjectManager::DoInitializeIcons
|
|
529 |
//
|
|
530 |
// ---------------------------------------------------------------------------
|
|
531 |
//
|
|
532 |
void CBubbleCallObjectManager::DoInitializeIcons()
|
|
533 |
{
|
|
534 |
AknIconUtils::ExcludeFromCache( iCallThemeImageIcon->Bitmap() );
|
|
535 |
AknIconUtils::SetSize( iCallThemeImageIcon->Bitmap(),
|
|
536 |
iCallThemeImageSize,
|
|
537 |
EAspectRatioPreservedSlice );
|
|
538 |
iLoadingState = EBMLoaderReady;
|
|
539 |
}
|
|
540 |
|
|
541 |
// ---------------------------------------------------------------------------
|
|
542 |
// CBubbleCallObjectManager::FrameBufferDataChanged
|
|
543 |
//
|
|
544 |
// ---------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
void CBubbleCallObjectManager::FrameBufferDataChanged()
|
|
547 |
{
|
|
548 |
TRAPD( err, DoHandleFrameBufferDataL() );
|
|
549 |
|
|
550 |
if ( err != KErrNone )
|
|
551 |
{
|
|
552 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
553 |
iIdleProcessor->Cancel();
|
|
554 |
iIdleProcessor->Start( idleCallback );
|
|
555 |
iLoadingState = EBMDeleting;
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
// ---------------------------------------------------------------------------
|
|
560 |
// CBubbleCallObjectManager::SetCallObjectImageL
|
|
561 |
//
|
|
562 |
// ---------------------------------------------------------------------------
|
|
563 |
//
|
|
564 |
void CBubbleCallObjectManager::DoHandleFrameBufferDataL()
|
|
565 |
{
|
|
566 |
const CFbsBitmap* bitmap = iMediaReader->FrameBuffer();
|
|
567 |
const CFbsBitmap* mask = iMediaReader->Mask();
|
|
568 |
|
|
569 |
if ( bitmap )
|
|
570 |
{
|
|
571 |
CBubbleManager::TPhoneCallState callState =
|
|
572 |
iBubbleManager.CallState( iBubbleId );
|
|
573 |
|
|
574 |
// copy the current frame
|
|
575 |
CFbsBitmap* d_bitmap = new( ELeave ) CFbsBitmap;
|
|
576 |
CleanupStack::PushL( d_bitmap );
|
|
577 |
User::LeaveIfError( d_bitmap->Duplicate( bitmap->Handle() ) );
|
|
578 |
|
|
579 |
CFbsBitmap* d_mask = NULL;
|
|
580 |
if ( mask )
|
|
581 |
{
|
|
582 |
d_mask = new( ELeave ) CFbsBitmap;
|
|
583 |
CleanupStack::PushL( d_mask );
|
|
584 |
User::LeaveIfError( d_mask->Duplicate( mask->Handle() ) );
|
|
585 |
CleanupStack::Pop( d_mask );
|
|
586 |
}
|
|
587 |
CleanupStack::Pop( d_bitmap );
|
|
588 |
|
|
589 |
// assign the copy to call header.
|
|
590 |
if ( ( iLoadingState == EBMLoadingThumbnail ) &&
|
|
591 |
( callState > CBubbleManager::EActive ) )
|
|
592 |
{
|
|
593 |
// displaying fullscreen image, set as thumbnail
|
|
594 |
iBubbleManager.SetThumbnail( iBubbleId,
|
|
595 |
d_bitmap,
|
|
596 |
d_mask,
|
|
597 |
ETrue ); // Ownership transfer
|
|
598 |
}
|
|
599 |
else
|
|
600 |
{
|
|
601 |
iBubbleManager.StartChanges();
|
|
602 |
iBubbleManager.SetCallObjectImage( iBubbleId,
|
|
603 |
d_bitmap,
|
|
604 |
d_mask,
|
|
605 |
ETrue ); // Ownership transfer
|
|
606 |
iBubbleManager.EndChanges();
|
|
607 |
}
|
|
608 |
|
|
609 |
}
|
|
610 |
|
|
611 |
// Delete media reader
|
|
612 |
iBubbleId = KBMBubbleIdNone;
|
|
613 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
614 |
iIdleProcessor->Cancel();
|
|
615 |
iIdleProcessor->Start( idleCallback );
|
|
616 |
iLoadingState = EBMDeleting;
|
|
617 |
}
|
|
618 |
|
|
619 |
// ---------------------------------------------------------------------------
|
|
620 |
// CBubbleCallObjectManager::LoadThumbnailVersion
|
|
621 |
//
|
|
622 |
// ---------------------------------------------------------------------------
|
|
623 |
//
|
|
624 |
TBool CBubbleCallObjectManager::LoadThumbnailVersion()
|
|
625 |
{
|
|
626 |
TSize sourceSize( iMediaReader->SourceSize() );
|
|
627 |
TReal scaleFactor;
|
|
628 |
TRect clipRect;
|
|
629 |
TBool isTiny = BubbleCallObjectUtils::GetScaleFactorAndClipRect(
|
|
630 |
sourceSize,
|
|
631 |
iImageLoadParams.iThumbnailSize,
|
|
632 |
BubbleCallObjectUtils::EFillTarget,
|
|
633 |
scaleFactor,
|
|
634 |
clipRect );
|
|
635 |
|
|
636 |
if ( !isTiny )
|
|
637 |
{
|
|
638 |
// scale image to thumbnail version
|
|
639 |
iMediaReader->SetScaleAndClip( iImageLoadParams.iThumbnailSize,
|
|
640 |
scaleFactor,
|
|
641 |
clipRect );
|
|
642 |
return ETrue;
|
|
643 |
}
|
|
644 |
else
|
|
645 |
{
|
|
646 |
// image is smaller than thumnail size
|
|
647 |
return EFalse;
|
|
648 |
}
|
|
649 |
}
|
|
650 |
|
|
651 |
// ---------------------------------------------------------------------------
|
|
652 |
// CBubbleCallObjectManager::ReaderError
|
|
653 |
//
|
|
654 |
// ---------------------------------------------------------------------------
|
|
655 |
//
|
|
656 |
void CBubbleCallObjectManager::ReaderError( TInt /*aError*/ )
|
|
657 |
{
|
|
658 |
TCallBack idleCallback( IdleProcessorCallback, this );
|
|
659 |
iIdleProcessor->Cancel();
|
|
660 |
iIdleProcessor->Start( idleCallback );
|
|
661 |
iLoadingState = EBMDeleting;
|
|
662 |
}
|
|
663 |
|
|
664 |
// End of File
|