|
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 getting favicons for the favourites list |
|
110 * @param aFavItems a list of favourites items |
|
111 */ |
|
112 void StartGetFaviconsL( CFavouritesItemList* aFavItems ); |
|
113 |
|
114 /** |
|
115 * Appends the icon to the icon array |
|
116 * @param aItem the favourites item which is being checked for favicons |
|
117 * @return Index of favicon array in iIconArray |
|
118 */ |
|
119 TInt GetFaviconArrayIndex( const CFavouritesItem& aItem ); |
|
120 |
|
121 /** |
|
122 * Updates the handle to icon array |
|
123 * @param aIconArray an array of icons |
|
124 */ |
|
125 |
|
126 void UpdateIconArray(CArrayPtr<CGulIcon>* aIconArray); |
|
127 |
|
128 protected: // New functions |
|
129 |
|
130 /** |
|
131 * Gets the favicon for a given url from the Favicon Engine |
|
132 * @param aUrl a url to check if there is an associated favicon |
|
133 */ |
|
134 void GetFaviconL(); |
|
135 |
|
136 /** |
|
137 * Rescales a favicon to fit into the list box graphic pane |
|
138 * and stores the result in iIconArray |
|
139 */ |
|
140 void RescaleFaviconL(); |
|
141 |
|
142 /** |
|
143 * Appends the icon to the icon array |
|
144 * @return Leave code |
|
145 */ |
|
146 TInt AppendToIconArray(); |
|
147 |
|
148 |
|
149 private: // New functions |
|
150 |
|
151 void ConstructL( CArrayPtr<CGulIcon>* aIconArray ); |
|
152 |
|
153 // Structures |
|
154 struct TFaviconIndex |
|
155 { |
|
156 TInt iFavouritesItemIndex; |
|
157 TInt iIndex; |
|
158 }; |
|
159 |
|
160 // Members |
|
161 MApiProvider& iApiProvider; // NOT owned |
|
162 MBrowserFaviconObserver& iObserver; // NOT owned |
|
163 |
|
164 CArrayPtr<CGulIcon>* iIconArray; // NOT owned |
|
165 CArrayFixFlat<TFaviconIndex>* iFaviconArrayIndices; // owned |
|
166 |
|
167 CFavouritesItemList* iFavItems; // NOT owned |
|
168 TSize iFaviconSize; |
|
169 |
|
170 CGulIcon* iFavicon; // NOT owned |
|
171 HBufC* iUrl; // owned |
|
172 |
|
173 // Counters |
|
174 TInt iFavItemsCurrentIndex; // position in the favourites item list |
|
175 TInt iFaviconsFound; // counter for number of favicon which have been found |
|
176 |
|
177 TBool iWasLastItemFavicon; |
|
178 CBrowserFaviconScaler* iBmpScaler; // owned |
|
179 TBool iHasMask; |
|
180 }; |
|
181 |
|
182 |
|
183 |
|
184 #endif // __BROWSERFAVICONHANDLER_H |