|
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: Screensaver GifAnimation plug-in API file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <IHLImageFactory.h> // IHLImageFactory |
|
23 |
|
24 #include "GifAnimationPlugin.h" |
|
25 #include "NPNExtensions.h" |
|
26 #include "GifAnimationUtils.h" |
|
27 |
|
28 // ======== Ecom interface functions implementation ======== |
|
29 |
|
30 NPError GifAnimationPluginNewp( NPMIMEType /*pluginType*/, |
|
31 NPP instance, |
|
32 uint16 /*mode*/, |
|
33 CDesCArray* /*argn*/, |
|
34 CDesCArray* /*argv*/, |
|
35 NPSavedData* /*saved*/ ) |
|
36 { |
|
37 DBG_TRACE_FN_BEGIN; |
|
38 CGifAnimationPlugin* lGifAnimationPlugin=NULL; |
|
39 TRAPD(err,lGifAnimationPlugin=CGifAnimationPlugin::NewL( instance ) ); |
|
40 |
|
41 if ( err == KErrNoMemory ) |
|
42 { |
|
43 DBG_TRACE_FN_END; |
|
44 return NPERR_OUT_OF_MEMORY_ERROR; |
|
45 } |
|
46 if ( err != KErrNone ) |
|
47 { |
|
48 DBG_TRACE_FN_END; |
|
49 return NPERR_MODULE_LOAD_FAILED_ERROR; |
|
50 } |
|
51 instance->pdata = (void *) lGifAnimationPlugin; |
|
52 DBG_TRACE_FN_END; |
|
53 return NPERR_NO_ERROR; |
|
54 } |
|
55 |
|
56 NPError GifAnimationPluginDestroy( NPP instance, NPSavedData** /*save*/ ) |
|
57 { |
|
58 DBG_TRACE_FN_BEGIN; |
|
59 CGifAnimationPlugin* lGifAnimationPlugin = |
|
60 ( CGifAnimationPlugin * )instance->pdata; |
|
61 if ( lGifAnimationPlugin ) |
|
62 { |
|
63 TRAPD( err, lGifAnimationPlugin->PrepareToExitL() ); |
|
64 if ( err != KErrNone ) |
|
65 { |
|
66 DBG_TRACE( |
|
67 "GifAnimationPluginDestroy Error when PrepareToExitL()" ); |
|
68 } |
|
69 /**Ignoring the error*/ |
|
70 delete lGifAnimationPlugin; |
|
71 lGifAnimationPlugin = NULL; |
|
72 } |
|
73 DBG_TRACE_FN_END; |
|
74 return NPERR_NO_ERROR; |
|
75 } |
|
76 |
|
77 NPError GifAnimationPluginSetWindow( NPP instance, NPWindow *window ) |
|
78 { |
|
79 DBG_TRACE_FN_BEGIN; |
|
80 CGifAnimationPlugin* lGifAnimationPlugin = |
|
81 (CGifAnimationPlugin *) instance->pdata; |
|
82 TUint lWidth = window->width; |
|
83 TUint lHeight = window->height; |
|
84 TRAPD( err, |
|
85 lGifAnimationPlugin->SetWindowL( window, |
|
86 TRect( TSize( lWidth, lHeight ) ) ) ); |
|
87 |
|
88 if ( err == KErrNoMemory ) |
|
89 { |
|
90 DBG_TRACE_FN_END; |
|
91 return NPERR_OUT_OF_MEMORY_ERROR; |
|
92 } |
|
93 if ( err != KErrNone ) |
|
94 { |
|
95 DBG_TRACE_FN_END; |
|
96 return NPERR_GENERIC_ERROR; |
|
97 } |
|
98 DBG_TRACE_FN_END; |
|
99 return NPERR_NO_ERROR; |
|
100 } |
|
101 |
|
102 NPError GifAnimationPluginNewStream( NPP /*instance*/, |
|
103 NPMIMEType /*type*/, |
|
104 NPStream* /*stream*/, |
|
105 NPBool /*seekable*/, |
|
106 uint16* stype ) |
|
107 { |
|
108 DBG_TRACE_FN_BEGIN; |
|
109 *stype = NP_ASFILEONLY; |
|
110 DBG_TRACE_FN_END; |
|
111 return NPERR_NO_ERROR; |
|
112 } |
|
113 |
|
114 NPError GifAnimationPluginDestroyStream( NPP /*instance*/, |
|
115 NPStream* /*stream*/, |
|
116 NPReason /*reason*/ ) |
|
117 { |
|
118 DBG_TRACE_FN_BEGIN; |
|
119 // |
|
120 DBG_TRACE_FN_END; |
|
121 return NPERR_NO_ERROR; |
|
122 } |
|
123 |
|
124 void GifAnimationPluginAsFile( NPP instance, |
|
125 NPStream* /*stream*/, |
|
126 const TDesC& fname ) |
|
127 { |
|
128 DBG_TRACE_FN_BEGIN; |
|
129 CGifAnimationPlugin* lGifAnimationPlugin = |
|
130 ( CGifAnimationPlugin* )instance->pdata; |
|
131 TRAP_IGNORE( lGifAnimationPlugin->Control()->LoadImageL( fname ) ); |
|
132 DBG_TRACE_FN_END; |
|
133 } |
|
134 |
|
135 int32 GifAnimationPluginWriteReady( NPP /*instance*/, NPStream* /*stream*/ ) |
|
136 { |
|
137 DBG_TRACE_FN_BEGIN; |
|
138 // |
|
139 DBG_TRACE_FN_END; |
|
140 return 65536; |
|
141 } |
|
142 |
|
143 int32 GifAnimationPluginWrite( NPP /*instance*/, |
|
144 NPStream* /*stream*/, |
|
145 int32 /*offset*/, |
|
146 int32 len, |
|
147 void* /*buffer*/ ) |
|
148 { |
|
149 DBG_TRACE_FN_BEGIN; |
|
150 // |
|
151 DBG_TRACE_FN_END; |
|
152 return len; |
|
153 } |
|
154 |
|
155 int16 GifAnimationPluginEvent( NPP /*instance*/, void* /*event*/ ) |
|
156 { |
|
157 DBG_TRACE_FN_BEGIN; |
|
158 // |
|
159 DBG_TRACE_FN_END; |
|
160 return 0; |
|
161 } |
|
162 |
|
163 |
|
164 NPError GifAnimationPluginGetValue( NPP instance, |
|
165 NPPVariable variable, |
|
166 void* ret_value ) |
|
167 { |
|
168 DBG_TRACE_FN_BEGIN; |
|
169 if ( variable == NPPCheckFileIsValid ) |
|
170 { |
|
171 NPCheckFile* checkFile = (NPCheckFile*)ret_value; |
|
172 TRAPD( err, |
|
173 CGifAnimationPluginControl::CheckFileIsValidL( |
|
174 checkFile->fileName->Des() ) ); |
|
175 |
|
176 checkFile->fileValidityCheckError = err; |
|
177 DBG_TRACE_FN_END; |
|
178 return NPERR_NO_ERROR; |
|
179 } |
|
180 |
|
181 if ( variable == NPPScreenSaverGetLastError ) |
|
182 { |
|
183 DBG_TRACE( "GetLastError" ); |
|
184 TInt* retValue = (TInt*)ret_value; |
|
185 CGifAnimationPlugin* lGifAnimationPlugin = |
|
186 ( CGifAnimationPlugin* )instance->pdata; |
|
187 *retValue = lGifAnimationPlugin->Control()->GetLastError(); |
|
188 DBG_TRACE_FN_END; |
|
189 return NPERR_NO_ERROR; |
|
190 } |
|
191 |
|
192 // new command, panic |
|
193 _LIT( KErrGetMsg, |
|
194 "CGifAnimationPluginDllApi::GifAnimationPluginGetValue" ); |
|
195 User::Panic( KErrGetMsg, KErrNotSupported ); |
|
196 return NPERR_GENERIC_ERROR; |
|
197 } |
|
198 |
|
199 NPError GifAnimationPluginSetValue( NPP instance, |
|
200 NPNVariable variable, |
|
201 void* value ) |
|
202 { |
|
203 DBG_TRACE_FN_BEGIN; |
|
204 CGifAnimationPlugin* lGifAnimationPlugin = |
|
205 ( CGifAnimationPlugin* )instance->pdata; |
|
206 |
|
207 if ( variable == NPNScreenSaverAnimationEvent ) |
|
208 { |
|
209 NPAnimationEvent* event = (NPAnimationEvent*)value; |
|
210 switch ( *event ) |
|
211 { |
|
212 case NPStartAnimation: |
|
213 DBG_TRACE( "StartAnimationL" ); |
|
214 TRAPD( errStart, |
|
215 lGifAnimationPlugin->Control()->StartAnimationL() ); |
|
216 if ( errStart != KErrNone ) |
|
217 { |
|
218 DBG_TRACE( "StartAnimation failed!" ); |
|
219 return NPERR_GENERIC_ERROR; |
|
220 } |
|
221 return NPERR_NO_ERROR; |
|
222 case NPEndAnimation: |
|
223 DBG_TRACE( "StopAnimation" ); |
|
224 TRAPD( errEnd, |
|
225 lGifAnimationPlugin->Control()->StopAnimation() ); |
|
226 if (errEnd != KErrNone) |
|
227 { |
|
228 DBG_TRACE( "StopAnimation failed!" ); |
|
229 return NPERR_GENERIC_ERROR; |
|
230 } |
|
231 DBG_TRACE_FN_END; |
|
232 return NPERR_NO_ERROR; |
|
233 default: |
|
234 // new command, panic |
|
235 _LIT( KErrSet1Msg, |
|
236 "CGifAnimationPluginDllApi::GifAnimationPluginSetValue1" ); |
|
237 User::Panic( KErrSet1Msg, KErrNotSupported ); |
|
238 return NPERR_GENERIC_ERROR; |
|
239 } |
|
240 } |
|
241 |
|
242 if ( variable == NPScreenSaverMode ) |
|
243 { |
|
244 // we do not need the event |
|
245 DBG_TRACE_FN_END; |
|
246 return NPERR_NO_ERROR; |
|
247 } |
|
248 |
|
249 if ( variable == NPNInteractionMode ) |
|
250 { |
|
251 // we do not need the event |
|
252 DBG_TRACE_FN_END; |
|
253 return NPERR_NO_ERROR; |
|
254 } |
|
255 |
|
256 // new command, panic |
|
257 _LIT( KErrSet2Msg, |
|
258 "CGifAnimationPluginDllApi::GifAnimationPluginSetValue2" ); |
|
259 User::Panic( KErrSet2Msg, KErrNotSupported ); |
|
260 return NPERR_GENERIC_ERROR; |
|
261 } |
|
262 |
|
263 void GifAnimationPluginURLNotify( NPP /*instance*/, |
|
264 const TDesC& /*url*/, |
|
265 NPReason /*reason*/, |
|
266 void* /*notifyData*/ ) |
|
267 { |
|
268 DBG_TRACE_FN_BEGIN; |
|
269 // |
|
270 DBG_TRACE_FN_END; |
|
271 } |
|
272 |
|
273 void GifAnimationPluginPrint( NPP /*instance*/, NPPrint* /*platformPrint*/ ) |
|
274 { |
|
275 DBG_TRACE_FN_BEGIN; |
|
276 // |
|
277 DBG_TRACE_FN_END; |
|
278 } |