|
1 /* |
|
2 * Copyright (c) 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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef WIDGETUIOBSERVER_H_ |
|
20 #define WIDGETUIOBSERVER_H_ |
|
21 |
|
22 // INCLUDES |
|
23 #include <BrCtlLayoutObserver.h> |
|
24 #include <BrCtlSoftkeysObserver.h> |
|
25 #include <BrCtlSpecialLoadObserver.h> |
|
26 #include <BrCtlDownloadObserver.h> |
|
27 #include <BrCtlWindowObserver.h> |
|
28 #include <BrCtlInterface.h> |
|
29 #include <DocumentHandler.h> |
|
30 #include <flogger.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CActiveApDb; |
|
34 class CWidgetUiWindow; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * |
|
40 * @lib WidgetUI.exe |
|
41 * @since 3.1 |
|
42 */ |
|
43 class CWidgetUiObserver : public CBase, |
|
44 public MBrCtlLayoutObserver, // not needed |
|
45 public MBrCtlSoftkeysObserver, // needed |
|
46 public MBrCtlLoadEventObserver, // needed |
|
47 public MBrCtlLinkResolver, // needed |
|
48 public MBrCtlDownloadObserver, // not needed |
|
49 public MBrCtlWindowObserver // needed |
|
50 { |
|
51 |
|
52 public: // Constructors and destructor |
|
53 |
|
54 /** |
|
55 * NewL |
|
56 * Two-phased constructor. |
|
57 * @since 3.1 |
|
58 * @param none |
|
59 * @return CWidgetUiObserver* |
|
60 */ |
|
61 static CWidgetUiObserver* NewL( CWidgetUiWindow& aWindow ); |
|
62 |
|
63 /** |
|
64 * ~CWidgetUiObserver |
|
65 * Destructor |
|
66 * @since 3.1 |
|
67 * @param none |
|
68 * @return none |
|
69 */ |
|
70 ~CWidgetUiObserver(); |
|
71 |
|
72 |
|
73 /** |
|
74 * UpdateBrowserVScrollBarL |
|
75 * Update the position of vertical scrollbar. |
|
76 * @since 3.1 |
|
77 * @param aDocumentHeight The total height of the markup page |
|
78 * @param aDisplayHeight The height of the display |
|
79 * @param aDisplayPosY The current Y position |
|
80 * @return void |
|
81 */ |
|
82 void UpdateBrowserVScrollBarL( TInt aDocumentHeight, |
|
83 TInt aDisplayHeight, |
|
84 TInt aDisplayPosY ); |
|
85 |
|
86 /** |
|
87 * UpdateBrowserHScrollBarL |
|
88 * Update the position of horizontal scrollbar. |
|
89 * @since 3.1 |
|
90 * @param aDocumentWidth The total width of the markup page |
|
91 * @param aDisplayWidth The width of the display |
|
92 * @param aDisplayPosX The current X position |
|
93 * @return void |
|
94 */ |
|
95 void UpdateBrowserHScrollBarL( TInt aDocumentWidth, |
|
96 TInt aDisplayWidth, |
|
97 TInt aDisplayPosX ); |
|
98 |
|
99 /** |
|
100 * NotifyLayoutChange |
|
101 * Inform the layout of the page: right to left or left to right. Useful when the application draws the scrollbar itself. |
|
102 * @since 3.1 |
|
103 * @param aNewLayout RTL or LTR |
|
104 * @return void |
|
105 */ |
|
106 void NotifyLayoutChange( TBrCtlLayout aNewLayout ); |
|
107 |
|
108 /** |
|
109 * UpdateTitleL |
|
110 * Update the title of the page in history view |
|
111 * @since 3.1 |
|
112 * @param aTitle Title of the page |
|
113 * @return void |
|
114 */ |
|
115 void UpdateTitleL( const TDesC& aTitle ); |
|
116 |
|
117 /** |
|
118 * UpdateSoftkeyL |
|
119 * WidgetUi Control requests to update a softkey |
|
120 * @since 3.1 |
|
121 * @param aKeySoftkey Update the left softkey or the right softkey |
|
122 * @param aLabel The label associated with the softkey update |
|
123 * @param aCommandId The command to use if the softkey is selected by the user |
|
124 * @param aBrCtlSoftkeyChangeReason The reason for the softkey change |
|
125 * @return void |
|
126 */ |
|
127 void UpdateSoftkeyL( TBrCtlKeySoftkey aKeySoftkey, |
|
128 const TDesC& aLabel, |
|
129 TUint32 aCommandId, |
|
130 TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason); |
|
131 |
|
132 /** |
|
133 * HandleBrowserLoadEventL |
|
134 * A load events notification |
|
135 * @since 3.1 |
|
136 * @param aLoadEvent The load event |
|
137 * @param aSize Size depends on the event |
|
138 * @param aTransactionId The transaction id of the transaction that had this event |
|
139 * @return void |
|
140 */ |
|
141 void HandleBrowserLoadEventL( TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, |
|
142 TUint aSize, TUint16 aTransactionId ); |
|
143 |
|
144 /** |
|
145 * ResolveEmbeddedLinkL |
|
146 * WidgetUi plug-in calls this method when embedded link is found. Used with ECapabilityClientResolveEmbeddedURL |
|
147 * @since 3.1 |
|
148 * @param aEmbeddedUrl The url of the embedded content |
|
149 * @param aCurrentUrl The url of the current page |
|
150 * @param aLoadContentType The expected type of the embedded content |
|
151 * @param aEmbeddedLinkContent a callback interface to return the embedded content |
|
152 * @return EFalse, WidgetUI will resolve the link |
|
153 */ |
|
154 TBool ResolveEmbeddedLinkL( const TDesC& aEmbeddedUrl, |
|
155 const TDesC& aCurrentUrl, |
|
156 TBrCtlLoadContentType aLoadContentType, |
|
157 MBrCtlLinkContent& aEmbeddedLinkContent ); |
|
158 |
|
159 /** |
|
160 * ResolveLinkL |
|
161 * WidgetUi plug-in calls this method when the user requests to load content via selecting a link, or any other way. Used with ECapabilityClientNotifyURL |
|
162 * @since 3.1 |
|
163 * @param aUrl The requested url |
|
164 * @param aCurrentUrl The url of the current page |
|
165 * @param aBrCtlLinkContent a callback interface to return the embedded content |
|
166 * @return EFalse, WidgetUi will resolve the link |
|
167 */ |
|
168 TBool ResolveLinkL( const TDesC& aUrl, const TDesC& aCurrentUrl, |
|
169 MBrCtlLinkContent& aBrCtlLinkContent ); |
|
170 |
|
171 /** |
|
172 * CancelAll |
|
173 * Cancel all outstanding resolving operations |
|
174 * @since 3.1 |
|
175 * @param none |
|
176 * @return void |
|
177 */ |
|
178 void CancelAll() ; |
|
179 |
|
180 /** |
|
181 * NewDownloadL |
|
182 * Inform the host application that a new download has started using the Download Manager |
|
183 * @since 3.1 |
|
184 * @param aTransactionID The ID of the transaction, it is unique as long as the transaction is on-going |
|
185 * @param aFileName The name of file in which the content is stored/ |
|
186 * @param aContentType The content type of the downloaded content |
|
187 * @param aUrl The Url of the request to be done in the new window |
|
188 * @return ETrue if the file is handled progressively, EFalse otherwise |
|
189 */ |
|
190 TBool NewDownloadL( TUint aTransactionID, |
|
191 const TDesC& aFileName, |
|
192 const TDesC& aContentType, |
|
193 const TDesC& aUrl ); |
|
194 |
|
195 /** |
|
196 * ResumeDownloadL |
|
197 * Inform the host application that a new download has started using the Download Manager |
|
198 * @since 3.1 |
|
199 * @param aTransactionID The ID of the transaction, it is unique as long as the transaction is on-going |
|
200 * @param aFileName The name of file in which the content is stored/ |
|
201 * @param aContentType The content type of the downloaded content |
|
202 * @param aUrl The Url of the request to be done in the new window |
|
203 * @return Return ETrue if the file is handled progressively, EFalse otherwise |
|
204 */ |
|
205 virtual void ResumeDownloadL( TUint /*aTransactionID*/, |
|
206 TUint /*aLength*/, |
|
207 const TDesC& /*aFileName*/, |
|
208 const TDesC& /*aContentType*/, |
|
209 const TDesC& /*aUrl*/ ) { } |
|
210 /** |
|
211 * HandleDownloadEventL |
|
212 * Inform the host application of a progress event related to a download |
|
213 * @since 3.1 |
|
214 * @param aTransactionID The ID of the transaction, it is unique as long as the transaction is on-going |
|
215 * @param aDownloadEvent The event to be reported |
|
216 * @param aValue The value depends on the event |
|
217 * @return void |
|
218 */ |
|
219 void HandleDownloadEventL( TUint aTransactionID, |
|
220 TBrCtlDownloadEvent aDownloadEvent, |
|
221 TUint aValue ); |
|
222 |
|
223 public: // From MBrCtlWindowObserver |
|
224 |
|
225 |
|
226 CBrCtlInterface* OpenWindowL(TDesC& aUrl, TDesC* aTargetName, TBool aUserInitiated, |
|
227 TAny* aReserved); |
|
228 |
|
229 /** |
|
230 * Find a window by target name |
|
231 * @since 3.0 |
|
232 * @param aTargetName name of the window to find |
|
233 * @return Return Value is the browser control associated with the window name |
|
234 */ |
|
235 CBrCtlInterface* FindWindowL( const TDesC& aTargetName ) const; |
|
236 |
|
237 /** |
|
238 * Handle window events such as close/focus etc |
|
239 * @since 3.0 |
|
240 * @param aTargetName name of the window to send the event to |
|
241 * @param aCommand Command to pass to the window |
|
242 * @return void |
|
243 */ |
|
244 void HandleWindowCommandL( const TDesC& aTargetName, TBrCtlWindowCommand aCommand ); |
|
245 |
|
246 private: |
|
247 |
|
248 /** |
|
249 * CWidgetUiObserver |
|
250 * Construtor |
|
251 * @since 3.1 |
|
252 * @param aWindowManager |
|
253 * @return none |
|
254 */ |
|
255 CWidgetUiObserver( CWidgetUiWindow& aWindow ); |
|
256 |
|
257 /** |
|
258 * ConstructL |
|
259 * EPOC default constructor. |
|
260 * By default Symbian 2nd phase constructor is private. |
|
261 * @since 3.1 |
|
262 * @param none |
|
263 * @return void |
|
264 */ |
|
265 void ConstructL(); |
|
266 |
|
267 /** |
|
268 * IsFileScheme |
|
269 * Find if the scheme is file:// |
|
270 * @since 3.1 |
|
271 * @param aFilename |
|
272 * @return TBool |
|
273 */ |
|
274 TBool IsFileScheme( const TDesC& aFileName ); |
|
275 |
|
276 /** |
|
277 * ReadFileL |
|
278 * Read the file |
|
279 * @since 3.1 |
|
280 * @param aFileName |
|
281 * @return HBufC* |
|
282 */ |
|
283 HBufC8* ReadFileL( const TDesC& aFileName); |
|
284 |
|
285 /** |
|
286 * RecognizeLC |
|
287 * Rcognize the mime type. |
|
288 * @since 3.1 |
|
289 * @param aFileName |
|
290 * @param aData |
|
291 * @return HBufC* |
|
292 */ |
|
293 HBufC* RecognizeLC( const TDesC& aFileName, const TDesC8& aData ); |
|
294 |
|
295 /** |
|
296 * TranslateURLToFilenameL |
|
297 * Translate the file name from a URL to a valid file name in the system.. |
|
298 * @since 3.1 |
|
299 * @param aFileName |
|
300 * @return TBool |
|
301 */ |
|
302 TBool TranslateURLToFilenameL( const TDesC& aFileName, const TDesC& aLanguageDir ); |
|
303 |
|
304 private: // data |
|
305 |
|
306 CWidgetUiWindow* iWindow; // not owned, not responsible for deleting |
|
307 #ifdef _DEBUG |
|
308 RFileLogger iFileLogger; |
|
309 TBool iCanLog; |
|
310 #endif |
|
311 // The loaded file's name. This is different from the URL. It does not contain the scheme. |
|
312 HBufC* iFileName; |
|
313 |
|
314 CDocumentHandler* iHandler; |
|
315 TBool iConnected; |
|
316 TFileName iAppPrivatePath; |
|
317 HBufC* iSoftkeyExitStr; |
|
318 HBufC* iLeftSoftkeyStr; |
|
319 //Active Object to collect bitmap |
|
320 CIdle* iCollectBitmapTimer; |
|
321 }; |
|
322 |
|
323 #endif // WIDGEUIOBSERVER_H |
|
324 |
|
325 // End of File |