65
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 the License "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: Header file for CBrowserFaviconHandler
|
|
15 |
*
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef __BROWSERFAVICONHANDLER_H
|
|
21 |
#define __BROWSERFAVICONHANDLER_H
|
|
22 |
|
|
23 |
// INCLUDE FILES
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <gulicon.h>
|
|
26 |
#include "BrowserFaviconScaler.h"
|
|
27 |
|
|
28 |
// CLASS DECLARATION
|
|
29 |
class MApiProvider;
|
|
30 |
class CFavouritesItemList;
|
|
31 |
class CFavouritesItem;
|
|
32 |
|
|
33 |
class MBrowserFaviconObserver
|
|
34 |
{
|
|
35 |
public:
|
|
36 |
virtual TInt DrawFavicons() = 0;
|
|
37 |
};
|
|
38 |
|
|
39 |
/**
|
|
40 |
* CBrowserFaviconHandler.
|
|
41 |
*
|
|
42 |
* @lib Browser.app
|
|
43 |
* @since Series 60 3.1
|
|
44 |
*/
|
|
45 |
class CBrowserFaviconHandler : public CActive,
|
|
46 |
public MBrowserFaviconScalerCallback
|
|
47 |
{
|
|
48 |
public: // Constructors
|
|
49 |
|
|
50 |
/**
|
|
51 |
* @param aApiProvider access to AppUi functions
|
|
52 |
* @param aIconArray an array of icons
|
|
53 |
* @param aObserver observer for drawing favicons
|
|
54 |
* @param aFaviconSize size in pixels of the favicons
|
|
55 |
*/
|
|
56 |
static CBrowserFaviconHandler* NewLC(
|
|
57 |
MApiProvider& aApiProvider,
|
|
58 |
CArrayPtr<CGulIcon>* aIconArray,
|
|
59 |
MBrowserFaviconObserver& aObserver,
|
|
60 |
TSize aFaviconSize );
|
|
61 |
|
|
62 |
/**
|
|
63 |
* @param aApiProvider access to AppUi functions
|
|
64 |
* @param aIconArray an array of icons
|
|
65 |
* @param aObserver observer for drawing favicons
|
|
66 |
* @param aFaviconSize size in pixels of the favicons
|
|
67 |
*/
|
|
68 |
static CBrowserFaviconHandler* NewL(
|
|
69 |
MApiProvider& aApiProvider,
|
|
70 |
CArrayPtr<CGulIcon>* aIconArray,
|
|
71 |
MBrowserFaviconObserver& aObserver,
|
|
72 |
TSize aFaviconSize );
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Destructor.
|
|
76 |
*/
|
|
77 |
~CBrowserFaviconHandler();
|
|
78 |
|
|
79 |
protected: // Constructor and destructor
|
|
80 |
|
|
81 |
/**
|
|
82 |
* @param aApiProvider access to AppUi functions
|
|
83 |
* @param aObserver observer for drawing favicons
|
|
84 |
* @param aFaviconSize size in pixels of the favicons
|
|
85 |
*/
|
|
86 |
CBrowserFaviconHandler( MApiProvider& aApiProvider,
|
|
87 |
MBrowserFaviconObserver& aObserver,
|
|
88 |
TSize aFaviconSize );
|
|
89 |
|
|
90 |
public: // from MBrowserFaviconScalerCallback
|
|
91 |
void ScalingCompletedL(CFbsBitmap* aResult, const TRect& aTargetRect);
|
|
92 |
|
|
93 |
public: // from CActive
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Cancel any outstanding requests
|
|
97 |
*/
|
|
98 |
void DoCancel();
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Handles object`s request completion event.
|
|
102 |
*/
|
|
103 |
void RunL();
|
|
104 |
|
|
105 |
public: // New functions
|
|
106 |
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Initiates decoding of favicons for the favourites list in browserengine.
|
|
110 |
* This will request icon database thread to start decoding requested icons in background.
|
|
111 |
* @param aFavItems a list of favourites items
|
|
112 |
*/
|
|
113 |
void RequestFavicons( CFavouritesItemList* aFavItems );
|
|
114 |
|
|
115 |
/**
|
|
116 |
* This is async fetch operation from engine. One icon at a time is fetched and asynchronously
|
|
117 |
* scaled. E.g. if there are 5 icons to be fetched, then this will cause the BitmapScaler to be
|
|
118 |
* Active for 5 times.
|
|
119 |
* overall fetching is Async
|
|
120 |
* @param aFavItems a list of favourites items
|
|
121 |
*/
|
|
122 |
void StartGetFaviconsL( CFavouritesItemList* aFavItems );
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Appends the icon to the icon array
|
|
126 |
* @param aItem the favourites item which is being checked for favicons
|
|
127 |
* @return Index of favicon array in iIconArray
|
|
128 |
*/
|
|
129 |
TInt GetFaviconArrayIndex( const CFavouritesItem& aItem );
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Updates the handle to icon array
|
|
133 |
* @param aIconArray an array of icons
|
|
134 |
*/
|
|
135 |
|
|
136 |
void UpdateIconArray(CArrayPtr<CGulIcon>* aIconArray);
|
|
137 |
|
|
138 |
protected: // New functions
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Gets the favicon for a given url from the Favicon Engine
|
|
142 |
* @param aUrl a url to check if there is an associated favicon
|
|
143 |
*/
|
|
144 |
void GetFaviconL();
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Rescales a favicon to fit into the list box graphic pane
|
|
148 |
* and stores the result in iIconArray
|
|
149 |
*/
|
|
150 |
void RescaleFaviconL();
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Appends the icon to the icon array
|
|
154 |
* @return Leave code
|
|
155 |
*/
|
|
156 |
TInt AppendToIconArray();
|
|
157 |
|
|
158 |
|
|
159 |
private: // New functions
|
|
160 |
|
|
161 |
void ConstructL( CArrayPtr<CGulIcon>* aIconArray );
|
|
162 |
|
|
163 |
// Structures
|
|
164 |
struct TFaviconIndex
|
|
165 |
{
|
|
166 |
TInt iFavouritesItemIndex;
|
|
167 |
TInt iIndex;
|
|
168 |
};
|
|
169 |
|
|
170 |
// Members
|
|
171 |
MApiProvider& iApiProvider; // NOT owned
|
|
172 |
MBrowserFaviconObserver& iObserver; // NOT owned
|
|
173 |
|
|
174 |
CArrayPtr<CGulIcon>* iIconArray; // NOT owned
|
|
175 |
CArrayFixFlat<TFaviconIndex>* iFaviconArrayIndices; // owned
|
|
176 |
|
|
177 |
CFavouritesItemList* iFavItems; // NOT owned
|
|
178 |
TSize iFaviconSize;
|
|
179 |
|
|
180 |
CGulIcon* iFavicon; // NOT owned
|
|
181 |
HBufC* iUrl; // owned
|
|
182 |
|
|
183 |
// Counters
|
|
184 |
TInt iFavItemsCurrentIndex; // position in the favourites item list
|
|
185 |
TInt iFaviconsFound; // counter for number of favicon which have been found
|
|
186 |
|
|
187 |
TBool iWasLastItemFavicon;
|
|
188 |
CBrowserFaviconScaler* iBmpScaler; // owned
|
|
189 |
TBool iHasMask;
|
|
190 |
};
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
#endif // __BROWSERFAVICONHANDLER_H
|