|
1 /* |
|
2 * Copyright (c) 2003 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: SVGT Plugin Implementation header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __SVGTPLUGIN_H |
|
20 #define __SVGTPLUGIN_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <coecntrl.h> |
|
24 #include <coemain.h> |
|
25 #include <fbs.h> |
|
26 #include <barsread.h> |
|
27 |
|
28 #include <hwrmlight.h> |
|
29 //SVGT Engine interface |
|
30 #include <SVGRequestObserver.h> |
|
31 #include <SVGEngineInterfaceImpl.h> |
|
32 #include <SVGHyperlinkListener.h> |
|
33 #include "SVGListener.h" |
|
34 |
|
35 #include <npupp.h> |
|
36 #include <pluginadapterinterface.h> |
|
37 |
|
38 #include <cecombrowserplugininterface.h> |
|
39 |
|
40 #include "MRepositoryVolumeObserver.h" |
|
41 |
|
42 class CSvgtPlugin; |
|
43 class CSvgEngineInterfaceImpl; |
|
44 class CFbsBitmap; |
|
45 |
|
46 class CVolumeKeyListener; |
|
47 class CRepositoryVolumeListener; |
|
48 /****************************************** |
|
49 This class is specific to ECom Style Plugin. |
|
50 This is used for passing plugin specific initialization information to and from |
|
51 browser. |
|
52 *******************************************/ |
|
53 |
|
54 IMPORT_C NPError InitializeFuncs(NPPluginFuncs* aPpf); |
|
55 |
|
56 const TInt KSvgtPluginImplementationValue = 0x101F8823; //implementation id Svgt Ecom Plugin |
|
57 |
|
58 class CSvgtPluginEcomMain : public CEcomBrowserPluginInterface |
|
59 { |
|
60 public: // Functions from base classes |
|
61 static CSvgtPluginEcomMain* NewL(TAny* aInitParam); |
|
62 ~CSvgtPluginEcomMain(); |
|
63 NPNetscapeFuncs* Funcs() {return iNpf;} |
|
64 private: |
|
65 CSvgtPluginEcomMain(NPNetscapeFuncs* aNpf); |
|
66 void ConstructL(NPPluginFuncs* aPluginFuncs); |
|
67 NPNetscapeFuncs* iNpf; |
|
68 }; |
|
69 |
|
70 /**************************************** |
|
71 Class CSvgtPluginControl |
|
72 Class to Handle UI related actions |
|
73 ****************************************/ |
|
74 |
|
75 class CSvgtPluginControl : public CCoeControl, public MCoeControlObserver, |
|
76 public MPluginNotifier, public MHWRMLightObserver |
|
77 |
|
78 { |
|
79 public: |
|
80 ~CSvgtPluginControl(); |
|
81 void ConstructL(CSvgtPlugin *aPlugin, const CCoeControl *aParentControl); |
|
82 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
83 void FocusChanged(TDrawNow aDrawNow); |
|
84 private: // new - possible notifications |
|
85 #ifndef ER5 |
|
86 TCoeInputCapabilities InputCapabilities() const; |
|
87 #endif |
|
88 void ApplicationFocusChanged(TBool aInFocus); |
|
89 void SystemNotification(); |
|
90 void Draw(const TRect& aRect) const; |
|
91 TInt CountComponentControls() const; |
|
92 CCoeControl* ComponentControl(TInt aIndex) const; |
|
93 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
94 void SizeChanged(); |
|
95 void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); |
|
96 private: // in MPluginNottify in S60 |
|
97 TInt NotifyL(TNotificationType aCallType, void* aParam); |
|
98 public: //From MEikMenuObserver |
|
99 |
|
100 |
|
101 public: |
|
102 void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus); |
|
103 CHWRMLight* iLightObserver; |
|
104 void AsFile(const TDesC& fname,NPStream* stream); |
|
105 TBool IsAsFileCalled(); |
|
106 TDesC& GetFilename(); |
|
107 |
|
108 private: |
|
109 void UpdatePointer(TInt aShiftX =0 , TInt aShiftY=0); |
|
110 |
|
111 public: |
|
112 TSize iContentDimension; |
|
113 private: |
|
114 CSvgtPlugin *iPlugin; |
|
115 TInt iPointerDx, iPointerDy;// increment decrement |
|
116 TInt iPointerX, iPointerY;//actual Pointer position with respect to Document. |
|
117 TBool iAsFileCalled; |
|
118 TBuf<256> iFilename; |
|
119 TBool iShowCursor; |
|
120 TInt iXPosAtMouseDown; |
|
121 TInt iYPosAtMouseDown; |
|
122 TKeyEvent iPreviousScanCode; //Introduced to differentiate long keypress and short key press |
|
123 |
|
124 }; |
|
125 |
|
126 |
|
127 /******************************************************* |
|
128 Class CSvgtPlugin |
|
129 ********************************************************/ |
|
130 |
|
131 class CSvgtPlugin : public CBase, |
|
132 public MSvgRequestObserver, |
|
133 public MSvgHyperlinkListener, |
|
134 public MSvgViewPortListener |
|
135 , |
|
136 public MRepositoryVolumeObserver |
|
137 { |
|
138 struct ImageInfo |
|
139 { |
|
140 TBuf<256> iImageRefUri; |
|
141 TBool iImagePendingOps; |
|
142 }; |
|
143 |
|
144 public: |
|
145 static CSvgtPlugin* NewL(NPP anInstance); |
|
146 ~CSvgtPlugin(); |
|
147 void ConstructL(NPP anInstance); |
|
148 void PrepareToExitL(); |
|
149 CSvgtPluginControl* Control(); |
|
150 void GetSizeOfRenderBuffer(TSize& aSize); |
|
151 NPP Instance(); |
|
152 void SetWindowL(const NPWindow *aWindow,const TRect& aRect); |
|
153 /** |
|
154 * ResizeWindow This function set width & height to the browser |
|
155 * and tell brower to resize. |
|
156 * |
|
157 * @since S60 3.1 |
|
158 * @param TInt width that needed to be used. |
|
159 * @param TInt height that needed to be used. |
|
160 * @return void |
|
161 */ |
|
162 void ResizeWindow(TInt width, TInt height); |
|
163 |
|
164 /** |
|
165 * AdjustDimention |
|
166 * |
|
167 * @since S60 3.1 |
|
168 * @return ETrue if dimention needs to be changed. EFalse if dimention |
|
169 * remains the same. |
|
170 */ |
|
171 TBool AdjustDimention( TBool aWidthInPercentage, |
|
172 TBool aHeightInPercentage ); |
|
173 |
|
174 /** |
|
175 * This function retrieves attributes from HTML that is |
|
176 * passed in by browser engine. |
|
177 * |
|
178 * @since S60 3.1 |
|
179 * @param NPMIMEType |
|
180 * @param NPP |
|
181 * @param uint16 |
|
182 * @param DesC16Array* attribute names |
|
183 * @param CDesC16Array* attribute values |
|
184 * @param NPSavedData* |
|
185 * @return NPError |
|
186 */ |
|
187 NPError SvgPluginNew(NPMIMEType pluginType, NPP instance, uint16 mode, |
|
188 CDesC16Array* argn, CDesC16Array* argv, NPSavedData* saved); |
|
189 |
|
190 public: // implements MSvgRequestObserver |
|
191 |
|
192 void UpdateScreen(); |
|
193 |
|
194 TBool ScriptCall( const TDesC& aScript, |
|
195 CSvgElementImpl* aCallerElement ); |
|
196 |
|
197 TInt FetchImage( const TDesC& aUri, RFs& aSession, RFile& aFileHandle ); |
|
198 |
|
199 TInt FetchFont( const TDesC& aUri, RFs& aSession, RFile& aFileHandle ); |
|
200 |
|
201 void GetSmilFitValue(TDes& aSmilValue); |
|
202 |
|
203 void UpdatePresentation(const TInt32& aNoOfAnimation); |
|
204 // MHyperlinkListener interface methods |
|
205 TBool LinkEntered( const TDesC& aUri ); |
|
206 TBool LinkExited( const TDesC& aUri ); |
|
207 TBool LinkActivated( const TDesC& aUri ); |
|
208 TBool LinkActivatedWithShow(const TDesC& aUri,const TDesC& aShow); |
|
209 //MSvgViewPortListener method |
|
210 void GetViewPort(TInt getWidth, TInt getHeight,TBool isWidthInPer, TBool isHeightInPer, TInt &setWidth, TInt &setHeight); |
|
211 |
|
212 // From MRepositoryVolumeObserver |
|
213 void VolumeChanged(TInt aNewValue); |
|
214 |
|
215 TBool LoadSvgFile( const TDesC& aFilename ); |
|
216 |
|
217 private: |
|
218 |
|
219 void FetchImageL(const TDesC& aUri); |
|
220 public: |
|
221 CFbsBitmap * iRenderBuffer; |
|
222 TSize iControlSize; |
|
223 TBool iSetWindowCalled; |
|
224 TBool iStartCalled; |
|
225 CSvgEngineInterfaceImpl * iSvgModule; |
|
226 TInt iRenderWidth; |
|
227 TInt iRenderHeight; |
|
228 TInt iObjectWidth; |
|
229 TInt iObjectHeight; |
|
230 NPWindow iCurrentWindow; |
|
231 |
|
232 TBool iTotalNumerOfAnimation, iStaticContent; |
|
233 |
|
234 /*Image Rendering*/ |
|
235 RPointerArray<HBufC> iImageUrlInfoList; |
|
236 |
|
237 TInt iViewPortWidth; |
|
238 TInt iViewPortHeight; |
|
239 private: |
|
240 |
|
241 CVolumeKeyListener* iKeyListener; |
|
242 CRepositoryVolumeListener* iRepositoryListener; |
|
243 |
|
244 MPluginAdapter* iPluginAdapter; |
|
245 |
|
246 //Control of UI for SVGT Engine |
|
247 CCoeControl * iParentControl; |
|
248 CSvgtPluginControl * iControl; |
|
249 NPP iInstance; |
|
250 TBool iIsRenderBufferDefined; |
|
251 TInt iResourceFileIndex; |
|
252 TBool iExpectedDefaultSize; |
|
253 TBool iAdjusted; |
|
254 // Flag indicates whether object height is specified |
|
255 // as percentage value |
|
256 TBool iObjHeightInPercentage; |
|
257 // Flag indicates whether object width is specified |
|
258 // as percentage value |
|
259 TBool iObjWidthInPercentage; |
|
260 |
|
261 //While parsing are object width height are specified or not |
|
262 TBool iObjectWidthSpecified; |
|
263 TBool iObjectHeightSpecified; |
|
264 }; |
|
265 |
|
266 |
|
267 /********************************************************************************* |
|
268 |
|
269 Plugin API methods |
|
270 |
|
271 */ |
|
272 |
|
273 /** |
|
274 * Create a plugin. |
|
275 */ |
|
276 NPError SvgtPluginNewp(NPMIMEType pluginType, NPP instance, uint16 mode, CDesCArray* argn, CDesCArray* argv, NPSavedData* saved); |
|
277 |
|
278 /** |
|
279 * Destroy a plugin. |
|
280 */ |
|
281 NPError SvgtPluginDestroy(NPP instance, NPSavedData** save); |
|
282 |
|
283 /** |
|
284 * This is the parent window of a plugin. |
|
285 */ |
|
286 NPError SvgtPluginSetWindow(NPP instance, NPWindow* window); |
|
287 |
|
288 /** |
|
289 * A new data stream has been created for sending data to the plugin. |
|
290 */ |
|
291 NPError SvgtPluginNewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype); |
|
292 |
|
293 /** |
|
294 * A data stream has been terminated. |
|
295 */ |
|
296 NPError SvgtPluginDestroyStream(NPP instance, NPStream* stream, NPReason reason); |
|
297 |
|
298 /** |
|
299 * A data stream has been fully saved to a file. |
|
300 */ |
|
301 void SvgtPluginAsFile(NPP instance, NPStream* stream, const TDesC& fname); |
|
302 |
|
303 /** |
|
304 * Return the maximum number of bytes this plugin can accept from the stream. |
|
305 */ |
|
306 int32 SvgtPluginWriteReady(NPP instance, NPStream* stream); |
|
307 |
|
308 /** |
|
309 * Receive more data - return number of bytes processed. |
|
310 */ |
|
311 int32 SvgtPluginWrite(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer); |
|
312 |
|
313 /** |
|
314 * Generic hook to set values/attributes within the plugin. |
|
315 */ |
|
316 NPError SvgtPluginSetValue(NPP instance, NPNVariable variable, void *ret_value); |
|
317 |
|
318 /** |
|
319 * Generic hook to get values/attributes from the plugin. |
|
320 */ |
|
321 NPError SvgtPluginGetValue(NPP instance, NPNVariable variable, void* *ret_value); |
|
322 |
|
323 /** |
|
324 * Event |
|
325 */ |
|
326 int16 SvgtPluginEvent(NPP instance, void* event); |
|
327 |
|
328 |
|
329 void SvgtPluginURLNotify(NPP instance, const TDesC& url, NPReason reason, void* notifyData); |
|
330 |
|
331 void SvgtPluginPrint(NPP instance, NPPrint* platformPrint); |
|
332 |
|
333 #endif // __PLGPLUGIN_H |