engine/src/ImageHandler.cpp
author teknolog
Sat, 13 Mar 2010 22:00:39 +0000
changeset 56 c5cd47bc11ef
parent 32 26a3f2dfba08
child 60 4d230e702aa3
permissions -rw-r--r--
Fix for bug 2152 plus minor fix for S1 UI
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
* Example code from OcrExample Copyright (c) 2006 Nokia Corporation.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include "ImageHandler.h"
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
    20
#include "debug.h"
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
// =============================================================================
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
// CImageHandler, a utility class for loading images.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
// =============================================================================
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
// ============================= MEMBER FUNCTIONS ===============================
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
// CImageHandler::CImageHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
// C++ constructor can NOT contain any code, that
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
// might leave.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
CImageHandler::CImageHandler( RFs& aFs )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
    : CActive(CActive::EPriorityStandard)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
    , iDecoder(NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
    , iScaler(NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
    , iFs(aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
    , iSize(0,0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
// CImageHandler::ConstructL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
// Symbian 2nd phase constructor can leave.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
void CImageHandler::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
    CActiveScheduler::Add(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
    iBitmap = new (ELeave) CFbsBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
// CImageHandler::NewLC
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
// Two-phased constructor.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
EXPORT_C CImageHandler* CImageHandler::NewL(RFs& aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
    CImageHandler* self = NewLC(aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
    CleanupStack::Pop();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
// CImageHandler::NewLC
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
// Two-phased constructor.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
EXPORT_C CImageHandler* CImageHandler::NewLC(RFs& aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
    CImageHandler* self = new (ELeave) CImageHandler(aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
    CleanupStack::PushL( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
    self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
// Destructor
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
EXPORT_C CImageHandler::~CImageHandler()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	// Cancel any outstanding request
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	Cancel();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	Deque();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
    delete iDecoder;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
    delete iScaler;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	delete iBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
    iCallbackQue.Close(); 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
// CImageHandler::LoadFileL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
// Loads a selected frame from a named file
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
void CImageHandler::LoadFileL(const TFileName& aFileName, TInt aSelectedFrame)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
    __ASSERT_ALWAYS(!IsActive(),User::Invariant());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
    if ( iDecoder )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
        delete iDecoder;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
        iDecoder = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
   
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
    iDecoder = CImageDecoder::FileNewL(iFs, aFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
    // Get image information
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
    iFrameInfo = iDecoder->FrameInfo(aSelectedFrame);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
    // Resize to fit.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
    TRect bitmap = iFrameInfo.iFrameCoordsInPixels;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
    // release possible previous image
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
    iBitmap->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
    iBitmap->Create(bitmap.Size(), EColor16M);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
    // Decode as bitmap.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
    iDecoder->Convert(&iStatus, *iBitmap, aSelectedFrame);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
    SetActive();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
EXPORT_C void CImageHandler::LoadFileAndScaleL(CFbsBitmap* aScaledBitmap, 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
								      const TFileName& aFileName,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
                                      const TSize &aSize,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
                                      MImageHandlerCallback& aCallback,
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   125
                                      TUint aHandle,
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
                                      TInt aSelectedFrame)
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   127
    {
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   128
    DP1("CImageHandler::LoadFileAndScaleL, iCallbackQueue.Count()=%d", iCallbackQue.Count());
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   129
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
    if(!IsActive())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
    	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
    	__ASSERT_ALWAYS(!IsActive(),User::Invariant());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
    	iSize = aSize;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
    	iScaledBitmap = aScaledBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
    	iScaledBitmap->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
    	iScaledBitmap->Create(aSize, EColor16M);
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   137
    	iCallback = &aCallback;
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   138
    	iHandle = aHandle;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
    	LoadFileL(aFileName, aSelectedFrame);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
    	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
    else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
    	{
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   143
    	for (int i=0;i<iCallbackQue.Count();i++)
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   144
    		{
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   145
    		if (iCallbackQue[i].iFileName.Compare(aFileName) == 0)
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   146
    			{
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   147
				User::Leave(KErrAlreadyExists);
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   148
    			}
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   149
    		}
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   150
    	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
    	TImageStruct imageStruct;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
    	imageStruct.iCallBack = &aCallback;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
    	imageStruct.iScaledImage = aScaledBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
    	imageStruct.iScaledSize = aSize;    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
    	imageStruct.iFileName = aFileName;
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   156
    	imageStruct.iHandle = aHandle;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
    	iCallbackQue.Append(imageStruct);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
    	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
EXPORT_C CFbsBitmap* CImageHandler::ScaledBitmap()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
	return iScaledBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
void CImageHandler::ScaleL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
    __ASSERT_ALWAYS(!IsActive(),User::Invariant());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
    if ( iScaler )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
        delete iScaler;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
    iScaler = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
    iScaler = CBitmapScaler::NewL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
    iScaler->Scale(&iStatus, *iBitmap, *iScaledBitmap, ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
    SetActive();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
// CImageHandler::FrameInfo
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
// Get the current frame information.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
const TFrameInfo& CImageHandler::FrameInfo() const
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
    return iFrameInfo;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
// CImageHandler::RunL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
// CActive::RunL() implementation. Called on image load success/failure.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
void CImageHandler::RunL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
    {
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   196
    DP1("CImageHandler::RunL(), iCallbackQueue.Count()=%d", iCallbackQue.Count());
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
    if ((! iStatus.Int()) && (iSize.iWidth != 0) && (iSize.iHeight != 0))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
        ScaleL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
        iSize.SetSize(0,0);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
    else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
        // Invoke callback.
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   205
        iCallback->ImageOperationCompleteL(iStatus.Int(), iHandle);        
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
        if(iCallbackQue.Count())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
        	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
        	TInt loaderror = KErrNotFound;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
        	while(loaderror != KErrNone && iCallbackQue.Count())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
        		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
        		TImageStruct imageStruct= iCallbackQue[0];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
        		iCallbackQue.Remove(0);
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 2
diff changeset
   213
        		TRAP(loaderror, LoadFileAndScaleL(imageStruct.iScaledImage, imageStruct.iFileName, imageStruct.iScaledSize, *imageStruct.iCallBack, imageStruct.iHandle));
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
        		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
        	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
// CImageHandler::DoCancel
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
// CActive::Cancel() implementation. Stops decoding.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
// -----------------------------------------------------------------------------
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
//
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
void CImageHandler::DoCancel()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
    if ( iDecoder )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
        iDecoder->Cancel();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
    if ( iScaler )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
        {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
        iScaler->Cancel();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
        }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238