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 "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: ScreenSaverAnimPlugin provides an implementation of |
|
15 * MScreensaverPlugin for animation files. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_SCREENSAVERANIMPLUGIN_H |
|
22 #define C_SCREENSAVERANIMPLUGIN_H |
|
23 |
|
24 #include <gdi.h> |
|
25 #include <ScreensaverpluginIntDef.h> |
|
26 #include <coecntrl.h> |
|
27 #include <e32cmn.h> |
|
28 #include <screensaverplugin.h> |
|
29 #include <coecobs.h> |
|
30 #include <npupp.h> |
|
31 #include <ecom/implementationinformation.h> |
|
32 #include <cecombrowserplugininterface.h> |
|
33 #include <pluginadapterinterface.h> |
|
34 #include <flogger.h> |
|
35 |
|
36 |
|
37 class CEikonEnv; |
|
38 class CDRMHelper; |
|
39 class CScreensaverRepositoryWatcher; |
|
40 class CRepository; |
|
41 |
|
42 |
|
43 _LIT( KFileLoggingDir, "ScreenSaver" ); |
|
44 _LIT( KFileLog, "SaveLog.txt" ); |
|
45 _LIT( KEmptyString, "" ); |
|
46 |
|
47 #ifdef SCREENSAVER_LOG_ENABLED |
|
48 |
|
49 inline void PrintDebugMsg( const TDesC& aMsg ) |
|
50 { |
|
51 RDebug::Print( aMsg ); |
|
52 #if 0 |
|
53 RFileLogger::Write( KFileLoggingDir, |
|
54 KFileLog, EFileLoggingModeAppend, aMsg ); |
|
55 #endif |
|
56 } |
|
57 #else |
|
58 |
|
59 inline void PrintDebugMsg( const TDesC& /*aMsg*/ ) |
|
60 { |
|
61 } |
|
62 |
|
63 #endif |
|
64 |
|
65 /** |
|
66 * Encapsulates the Settings that are written into the central repository |
|
67 * @lib ScreenSaverAnimPlugin.lib |
|
68 * @since 3.1 |
|
69 */ |
|
70 class CScreenSaverAnimSettingObject : public CBase |
|
71 { |
|
72 |
|
73 public: |
|
74 CScreenSaverAnimSettingObject(); |
|
75 |
|
76 public: |
|
77 |
|
78 // Name of the file to be set as screensaver |
|
79 TFileName iFileName; |
|
80 |
|
81 // Animation Timeout |
|
82 TInt iAnimationTimeout; |
|
83 |
|
84 // Lights Timeout |
|
85 TInt iLightsTimeout; |
|
86 }; |
|
87 |
|
88 /** |
|
89 * Provides the Animated ScreenSaverPlugin functionality which implements |
|
90 * ScreenSaver Interface and gives a Netscape Browser Plugin Interface |
|
91 * to the format specific plugins like SVG, Flash, M3G etc. |
|
92 * @lib ScreenSaverAnimPlugin.lib |
|
93 * @since 3.1 |
|
94 */ |
|
95 |
|
96 class CScreenSaverAnimPlugin: public CScreensaverPluginInterfaceDefinition, |
|
97 public MPluginAdapter, |
|
98 public MCoeControlObserver |
|
99 { |
|
100 |
|
101 public: |
|
102 |
|
103 /** |
|
104 * Two-phased constructor. |
|
105 * @since 3.1 |
|
106 */ |
|
107 static CScreenSaverAnimPlugin* NewL(); |
|
108 |
|
109 /** |
|
110 * Destructor. |
|
111 */ |
|
112 virtual ~CScreenSaverAnimPlugin(); |
|
113 |
|
114 public: // Functions From CScreensaverPluginInterfaceDefinition |
|
115 |
|
116 /** |
|
117 * From MScreensaverPlugin, Method called by ScreenSaver Application |
|
118 * when an animation file is configured as a Screen Saver. |
|
119 * @param aHost Screen saver plugin host. |
|
120 * @since 3.1 |
|
121 */ |
|
122 virtual TInt InitializeL( MScreensaverPluginHost *aHost ); |
|
123 |
|
124 /** |
|
125 * From MScreensaverPlugin, Method called by ScreenSaver Application |
|
126 * when Screen Saver is activated. |
|
127 * @since 3.1 |
|
128 */ |
|
129 virtual TInt Draw( CWindowGc& aGc ); |
|
130 |
|
131 /** |
|
132 * From MScreensaverPlugin, Method called by ScreenSaver Application |
|
133 * before the InitializeL. |
|
134 * @since 3.1 |
|
135 */ |
|
136 virtual const TDesC16& Name() const; |
|
137 |
|
138 /** |
|
139 * From MScreensaverPlugin, Method called by ScreenSaver Application |
|
140 * to get the capabilities of Screensaver plugin. |
|
141 * @since 3.1 |
|
142 */ |
|
143 virtual TInt Capabilities(); |
|
144 |
|
145 /** |
|
146 * From MScreensaverPlugin, Method called by Psln Application |
|
147 * when the user selects Animated ScreenSaver |
|
148 * @since 3.1 |
|
149 */ |
|
150 virtual TInt PluginFunction( |
|
151 TScPluginCaps /*aFunction*/, |
|
152 TAny* /*aParam*/ ); |
|
153 |
|
154 /** |
|
155 * From MScreensaverPlugin, Method called by ScreenSaver Application |
|
156 * when there are Screen Saver events. |
|
157 * @since 3.1 |
|
158 */ |
|
159 virtual TInt HandleScreensaverEventL( |
|
160 TScreensaverEvent aEvent, |
|
161 TAny* aData ); |
|
162 |
|
163 public: // New Functions |
|
164 |
|
165 /** |
|
166 * Reads the animation settings from the central repository |
|
167 * @since 3.1 |
|
168 * @return System wide Error value |
|
169 */ |
|
170 TInt GetAnimSettings(); |
|
171 |
|
172 /** |
|
173 * Writes the animation settings to the central repository |
|
174 * @since 3.1 |
|
175 * @return System wide Error value |
|
176 */ |
|
177 TInt SetAnimSettings() const; |
|
178 |
|
179 /** |
|
180 * This method registers for expiry of drm content |
|
181 * @since 3.1 |
|
182 * @return System wide Error value |
|
183 */ |
|
184 TInt RegisterForDrmExpiry(); |
|
185 |
|
186 /** |
|
187 * This method unregisters for expiry of drm content |
|
188 * @since 3.1 |
|
189 * @return System wide Error value |
|
190 */ |
|
191 TInt UnregisterForDrmExpiry(); |
|
192 |
|
193 /** |
|
194 * This method reads and parses the central repository key |
|
195 * for drm expiry |
|
196 * @since 3.1 |
|
197 * @return System wide Error value |
|
198 */ |
|
199 TInt ReadDrmNotification( TDes8& aString ); |
|
200 |
|
201 /** |
|
202 * Called when there is a drm expiry notification |
|
203 * @since 3.1 |
|
204 */ |
|
205 void ProcessDrmNotificationL(); |
|
206 |
|
207 /** |
|
208 * This method pops the settings dialog |
|
209 * @since 3.1 |
|
210 */ |
|
211 void PopSettingsDialogL(); |
|
212 |
|
213 /** |
|
214 * This method checks whether the set file exists currently |
|
215 * if not, it updates the filename string |
|
216 * This also checks if the rights are valid if the content is drm |
|
217 * if not, it updates the filename with the empty file name |
|
218 * returns True, if the Filename is updated |
|
219 * False, otherwise |
|
220 * @since 3.1 |
|
221 */ |
|
222 TBool UpdateFileName(); |
|
223 |
|
224 /** |
|
225 * Called when HandleScreenSaverEventL is called with EDisplayChanged |
|
226 * Used to set the parent control for the animation plugins |
|
227 * returns KErrGeneral when SetWindow does not go through |
|
228 * @since 3.1 |
|
229 */ |
|
230 TInt SetWindow( CCoeControl* aParent ); |
|
231 |
|
232 /** |
|
233 * Called to set the filename for the animation plugins |
|
234 * @since 3.1 |
|
235 */ |
|
236 void AsFile(); |
|
237 |
|
238 /** |
|
239 * Called when there is a central repository settings change |
|
240 * @since 3.1 |
|
241 */ |
|
242 void HandleSettingsChange( TAny* aPtr ); |
|
243 |
|
244 /** |
|
245 * Called by the repository watcher when there is a central |
|
246 * repository settings change |
|
247 * @since 3.1 |
|
248 */ |
|
249 static TInt HandleRepositoryCallBack( TAny* aPtr ); |
|
250 |
|
251 /** |
|
252 * Called by the repository watcher when there is a |
|
253 * drm expiry notification |
|
254 * @since 3.1 |
|
255 */ |
|
256 static TInt HandleDrmNotification( TAny* aPtr ); |
|
257 |
|
258 /** |
|
259 * Sends an event to the plugins to check for the file's validity |
|
260 * repository settings change |
|
261 * returns KErrNone if the file is valid |
|
262 * @since 3.1 |
|
263 */ |
|
264 TInt CheckFileValidityL( const TDesC& aFileName ); |
|
265 |
|
266 /** |
|
267 * Parses the mime description and checks whether the given mime type |
|
268 * is present in the mime description |
|
269 * @since 3.1 |
|
270 * @param aMIMEDescription mime Description which has mimetype, |
|
271 * extension and description |
|
272 * @param aDataType mimetype to be searched |
|
273 * @return TBool ETrue if aDataType is present in aMIMEDescription |
|
274 * EFalse otherwise |
|
275 */ |
|
276 static TBool ParseMimeStringL( const TDesC& aMIMEDescription, |
|
277 const TDesC& aDataType ); |
|
278 |
|
279 /** |
|
280 * Given the mimetype searches and returns the browser plugin which |
|
281 * handles the given mimetype |
|
282 * @since 3.1 |
|
283 * @param aDataType |
|
284 * @return TUid uid of the plugin which handles the mimetype |
|
285 */ |
|
286 TUid FindAnimPluginL( const TDesC& aDataType ); |
|
287 |
|
288 |
|
289 public: // From MPluginAdapter |
|
290 |
|
291 /** |
|
292 * Gets the pointer to the minor version number of the plug-in version |
|
293 * number of the Browser Plug-in API. |
|
294 * @since 3.1 |
|
295 * @return Series 60 returns 1. Series 80 and |
|
296 * the Nokia 7710 smartphone return 101. |
|
297 */ |
|
298 virtual TUint16 GetVersion(); |
|
299 |
|
300 /** |
|
301 * Called when the plug-in has completed its creation. |
|
302 * This function is called from the constructL function of the plug-in. |
|
303 * @since 3.1 |
|
304 * @param aPluginControl A pointer to the plug-in control window |
|
305 */ |
|
306 virtual void PluginConstructedL( CCoeControl* aPluginControl ); |
|
307 |
|
308 /** |
|
309 * Called after the plug-in has been deleted. |
|
310 * This function is called from the destructor of the plug-in. |
|
311 * @since 3.1 |
|
312 */ |
|
313 virtual void PluginFinishedL(); |
|
314 |
|
315 #ifndef __SERIES60_30__ |
|
316 |
|
317 /** |
|
318 * Called by the plug-in to open a URL in the parent frame. |
|
319 * This function is not implemented in Series 60. |
|
320 * It is supported in Series 80 and in the Nokia 7710 smartphone. |
|
321 * @since 3.1 |
|
322 * @param aUrl Name of the URL to open |
|
323 */ |
|
324 virtual void OpenUrlL( const TDesC& aUrl ); |
|
325 |
|
326 /** |
|
327 * Called by the plug-in to open a URL in a named window or frame. |
|
328 * This function is not implemented in Series 60. |
|
329 * It is supported in Series 80 and in the Nokia 7710 smartphone. |
|
330 * @since 3.1 |
|
331 * @param aUrl Name of the URL to open |
|
332 * @param aNewTargetWindowName The name of the target window or frame |
|
333 */ |
|
334 virtual void OpenUrlInTargetWindowL( const TDesC& aUrl, |
|
335 const TDesC& aNewTargetWindowName ); |
|
336 |
|
337 /** |
|
338 * Specifies whether or not the frame has a previous navigation |
|
339 * history item. |
|
340 * This function is not implemented in Series 60. |
|
341 * It is supported in Series 80 and in the Nokia 7710 smartphone. |
|
342 * @since 3.1 |
|
343 * @return true if the frame has a previous navigation |
|
344 * history item false otherwise |
|
345 */ |
|
346 virtual TBool HasNavigationHistoryPrevious() const; |
|
347 |
|
348 /** |
|
349 * Informs the browser to load the next navigation history URL |
|
350 * in its parent frame. |
|
351 * This function is not implemented in Series 60. |
|
352 * It is supported in Series 80 and in the Nokia 7710 smartphone. |
|
353 * @since 3.1 |
|
354 */ |
|
355 virtual void LoadNavigationHistoryPreviousL(); |
|
356 |
|
357 /** |
|
358 * Returns whether the frame has a next navigation history item. |
|
359 * This function is not implemented in Series 60. |
|
360 * It is supported in Series 80 and in the Nokia 7710 smartphone. |
|
361 * @since 3.1 |
|
362 * @return Returns whether the frame has a next navigation history item. |
|
363 */ |
|
364 virtual TBool HasNavigationHistoryNext() const; |
|
365 |
|
366 /** |
|
367 * Informs the browser to load the next navigation history URL |
|
368 * in its parent frame. |
|
369 * This function is not implemented in Series 60. It is supported in |
|
370 * Series 80 and in the Nokia 7710 smartphone. |
|
371 * @since 3.1 |
|
372 */ |
|
373 virtual void LoadNavigationHistoryNextL(); |
|
374 |
|
375 #endif |
|
376 /** |
|
377 * Returns the window system level control object for the plug-in. |
|
378 * @since 3.1 |
|
379 * @return A pointer to the parent control window. |
|
380 */ |
|
381 virtual CCoeControl* GetParentControl(); |
|
382 |
|
383 /** |
|
384 * Returns the observer for the plug-in control. |
|
385 * @since 3.1 |
|
386 * @return Observer that the plug-in can use to send events |
|
387 * to the browser. |
|
388 */ |
|
389 virtual MCoeControlObserver* GetParentControlObserver(); |
|
390 |
|
391 /** |
|
392 * Sets the plug-in notifier allowing the plug-in to control |
|
393 * portions of the browser. |
|
394 * @since 3.1 |
|
395 * @param aNotifier Pointer to an interface that the browser can |
|
396 * use to send events to the plug-in. |
|
397 */ |
|
398 virtual void SetPluginNotifier( MPluginNotifier *aNotifier ); |
|
399 |
|
400 /** |
|
401 * Tells the plugin adapter if plugin content can accept user interaction. This function |
|
402 * is called from the plugin. |
|
403 * @since Series 60 3nd Edition |
|
404 * @param None |
|
405 * @return None |
|
406 */ |
|
407 virtual void SetContentInteractive( TBool /*aInteractive*/ ); |
|
408 |
|
409 public: //MCoeControlObserver |
|
410 /** |
|
411 * Handles an event from an observed control. |
|
412 * This function is called when a control for which this control |
|
413 * is the observer calls CCoeControl::ReportEventL(). It should be |
|
414 * implemented by the observer control, and should handle all events |
|
415 * sent by controls it observes. |
|
416 * @param aControl The control that sent the event. |
|
417 * @param aEventType The event type. |
|
418 */ |
|
419 virtual void HandleControlEventL( CCoeControl* aControl, |
|
420 TCoeEvent aEventType ); |
|
421 |
|
422 private: // New functions |
|
423 |
|
424 /** |
|
425 * Finds the mime type of the file, searches the corresponding |
|
426 * browser plugin which handles the mime type and starts the same. |
|
427 * @since 3.1 |
|
428 */ |
|
429 void FindAndStartPluginL( const TDesC& aFileName, |
|
430 TBool aCheckFileMode = EFalse ); |
|
431 |
|
432 /** |
|
433 * Makes use of ecom api to find out whether an implementation with uid |
|
434 * aImpUid is present which implements the interface aInterfaceUid. |
|
435 * @since 3.1 |
|
436 */ |
|
437 TBool CheckIfPluginPresentL( TUid aInterfaceUid, |
|
438 TUid aImpUid ); |
|
439 |
|
440 /** |
|
441 * Finds the mime type of the file, searches the corresponding |
|
442 * browser plugin which handles the mime type |
|
443 * @since 3.1 |
|
444 */ |
|
445 void FindPluginL( const TDesC& aFileName ); |
|
446 |
|
447 /** |
|
448 * Creates the format specific plugin |
|
449 * @since 3.1 |
|
450 */ |
|
451 void CreatePluginL( TBool aCheckFileMode = EFalse ); |
|
452 |
|
453 /** |
|
454 * Deletes the browser plugin. |
|
455 * @since 3.1 |
|
456 */ |
|
457 void DeletePlugin(); |
|
458 |
|
459 /** |
|
460 * Deletes and Sets the browser plugin members to NULL |
|
461 * @since 3.1 |
|
462 */ |
|
463 void SetPluginDeleted(); |
|
464 |
|
465 /** |
|
466 * Connects the central repository session |
|
467 * @since 3.1 |
|
468 */ |
|
469 void InitializeCenRepL(); |
|
470 |
|
471 /** |
|
472 * Registers for central repository key changes |
|
473 * @since 3.1 |
|
474 */ |
|
475 void NotifyCenrepChangeL(); |
|
476 |
|
477 /** |
|
478 * Cancels registration for central repository key changes |
|
479 * @since 3.1 |
|
480 */ |
|
481 void NotifyCenrepChangeCancel(); |
|
482 |
|
483 /** |
|
484 * Disconnects the central repository session |
|
485 * @since 3.1 |
|
486 */ |
|
487 void UnInitializeCenRep(); |
|
488 |
|
489 /** |
|
490 * Sends an animation end event to the plugins |
|
491 * @since 3.1 |
|
492 */ |
|
493 TInt SendEndEvent(); |
|
494 |
|
495 /** |
|
496 * Checks whether the given content id matches the content id of the |
|
497 * file name given |
|
498 * @return ETrue if the content id matches |
|
499 * EFalse if not |
|
500 * @since 3.1 |
|
501 */ |
|
502 TBool CheckContentIdL( const TDesC& aFileName, TDesC8& aContentUri ); |
|
503 |
|
504 private: |
|
505 |
|
506 /** |
|
507 * Default Constructor |
|
508 * @since 3.1 |
|
509 */ |
|
510 CScreenSaverAnimPlugin(); |
|
511 |
|
512 /** |
|
513 * 2nd phase constructor |
|
514 * @since 3.1 |
|
515 */ |
|
516 void ConstructL(); |
|
517 |
|
518 public: |
|
519 |
|
520 // Pointer to the screen saver host |
|
521 MScreensaverPluginHost* iScreenSaverHost; |
|
522 |
|
523 private: |
|
524 |
|
525 // Resource file offset |
|
526 TInt iResourceOffset; |
|
527 |
|
528 // Handle to the central repository session |
|
529 CRepository* iAnimPluginSession; |
|
530 |
|
531 // Handle to the central repository session |
|
532 CRepository* iDrmSession; |
|
533 |
|
534 // Environment pointer |
|
535 CEikonEnv* iEikEnv; |
|
536 |
|
537 // Format specific Netscape plugin UID |
|
538 TUid iPluginUID; |
|
539 |
|
540 // Netscape plugin functions. |
|
541 NPPluginFuncs* iPluginFuncs; |
|
542 |
|
543 // Netscape ECOM plugin interface. |
|
544 CEcomBrowserPluginInterface* iPluginInterface; |
|
545 |
|
546 // Netscape plugin instance. |
|
547 NPP iNPPinstance; |
|
548 |
|
549 // Plugin Type |
|
550 HBufC8* iPluginType; |
|
551 |
|
552 // Parent control given by the screen saver application |
|
553 CCoeControl* iParentControl; |
|
554 |
|
555 // Pointer to the Settings object |
|
556 CScreenSaverAnimSettingObject* iSettingObject; |
|
557 |
|
558 // Pointer to Drm Helper |
|
559 CDRMHelper* iDrmHelper; |
|
560 |
|
561 // Cenrep Watcher for settings change |
|
562 CScreensaverRepositoryWatcher* iScreensaverRepositoryWatcher; |
|
563 |
|
564 // Cenrep Watcher for drm expiry |
|
565 CScreensaverRepositoryWatcher* iDrmExpiryWatcher; |
|
566 |
|
567 // To save the error encountered by the plugin |
|
568 TInt iPluginError; |
|
569 |
|
570 // Screensaver plugin name |
|
571 HBufC* iScreensaverName; |
|
572 }; |
|
573 |
|
574 |
|
575 #endif // C_SCREENSAVERANIMPLUGIN_H |
|
576 // End Of file |
|