36 #include "wmeffectmanager.h" |
36 #include "wmeffectmanager.h" |
37 #include "wmwidgetdata.h" |
37 #include "wmwidgetdata.h" |
38 #include "wminstaller.h" |
38 #include "wminstaller.h" |
39 #include "wmlistbox.h" |
39 #include "wmlistbox.h" |
40 |
40 |
|
41 const TInt KExecuteCommandDelay( 50000 ); // 50ms |
|
42 const TInt KMaxCmdExecutionCount( 6 ); |
|
43 |
41 // --------------------------------------------------------- |
44 // --------------------------------------------------------- |
42 // CWmPlugin::NewL |
45 // CWmPlugin::NewL |
43 // --------------------------------------------------------- |
46 // --------------------------------------------------------- |
44 // |
47 // |
45 CWmPlugin* CWmPlugin::NewL() |
48 CWmPlugin* CWmPlugin::NewL() |
55 // CWmPlugin::~CWmPlugin |
58 // CWmPlugin::~CWmPlugin |
56 // --------------------------------------------------------- |
59 // --------------------------------------------------------- |
57 // |
60 // |
58 CWmPlugin::~CWmPlugin() |
61 CWmPlugin::~CWmPlugin() |
59 { |
62 { |
|
63 if ( iLauncher && iLauncher->IsActive() ) |
|
64 { |
|
65 iLauncher->Cancel(); |
|
66 } |
|
67 delete iLauncher; |
|
68 |
60 if ( iWmInstaller && |
69 if ( iWmInstaller && |
61 iWmInstaller->IsActive() ) |
70 iWmInstaller->IsActive() ) |
62 { |
71 { |
63 iWmInstaller->Cancel(); |
72 iWmInstaller->Cancel(); |
64 } |
73 } |
75 // --------------------------------------------------------- |
84 // --------------------------------------------------------- |
76 // |
85 // |
77 CWmPlugin::CWmPlugin() |
86 CWmPlugin::CWmPlugin() |
78 { |
87 { |
79 iPreviousViewUid.iViewUid = KNullUid; |
88 iPreviousViewUid.iViewUid = KNullUid; |
|
89 iExecutionCount = 0; |
80 } |
90 } |
81 |
91 |
82 // --------------------------------------------------------- |
92 // --------------------------------------------------------- |
83 // CWmPlugin::ConstructL |
93 // CWmPlugin::ConstructL |
84 // --------------------------------------------------------- |
94 // --------------------------------------------------------- |
104 CWmMainContainerView* mainView = |
114 CWmMainContainerView* mainView = |
105 CWmMainContainerView::NewL( *this ); |
115 CWmMainContainerView::NewL( *this ); |
106 CleanupStack::PushL( mainView ); |
116 CleanupStack::PushL( mainView ); |
107 iViewAppUi->AddViewL( mainView ); |
117 iViewAppUi->AddViewL( mainView ); |
108 CleanupStack::Pop( mainView ); |
118 CleanupStack::Pop( mainView ); |
|
119 |
|
120 // laucher for adding widgets. |
|
121 iLauncher = CPeriodic::NewL( CActive::EPriorityIdle ); |
109 } |
122 } |
110 |
123 |
111 // --------------------------------------------------------- |
124 // --------------------------------------------------------- |
112 // CWmPlugin::Activate |
125 // CWmPlugin::Activate |
113 // --------------------------------------------------------- |
126 // --------------------------------------------------------- |
244 if ( iEffectManager ) |
257 if ( iEffectManager ) |
245 { |
258 { |
246 iEffectManager->UiRendered(); |
259 iEffectManager->UiRendered(); |
247 } |
260 } |
248 |
261 |
249 TRAPD( err, ExecuteCommandL(); ); |
262 if ( !iEffectManager->IsEffectActive() ) |
250 if ( KErrNone != err ) |
263 { |
251 { |
264 // launch effect without delay |
252 delete iPostponedContent; |
265 iExecutionCount = KMaxCmdExecutionCount; |
253 iPostponedContent = NULL; |
266 iLauncher->Start( 0, 0, TCallBack( ExecuteCommand, this ) ); |
254 iPostponedCommand = ENone; |
267 } |
|
268 else |
|
269 { |
|
270 // maximum wait time is 300ms (6 x 50ms) |
|
271 if ( !iLauncher->IsActive() ) |
|
272 { |
|
273 iExecutionCount++; |
|
274 iLauncher->Start( |
|
275 KExecuteCommandDelay, |
|
276 KExecuteCommandDelay, |
|
277 TCallBack( ExecuteCommand, this ) ); |
|
278 } |
255 } |
279 } |
256 } |
280 } |
257 |
281 |
258 // --------------------------------------------------------- |
282 // --------------------------------------------------------- |
259 // CWmPlugin::ForwardNumericKeysToPhone |
283 // CWmPlugin::ForwardNumericKeysToPhone |
283 iPostponedContent = NULL; |
307 iPostponedContent = NULL; |
284 iPostponedContent = aContentInfo.CloneL(); |
308 iPostponedContent = aContentInfo.CloneL(); |
285 } |
309 } |
286 |
310 |
287 // --------------------------------------------------------- |
311 // --------------------------------------------------------- |
288 // CWmPlugin::ExecuteCommandL |
312 // CWmPlugin::ExecuteCommand |
289 // --------------------------------------------------------- |
313 // --------------------------------------------------------- |
290 // |
314 // |
291 void CWmPlugin::ExecuteCommandL() |
315 TInt CWmPlugin::ExecuteCommand( TAny* aSelf ) |
292 { |
316 { |
293 if ( iPostponedCommand == EAddToHomescreen ) |
317 CWmPlugin* plugin = static_cast<CWmPlugin*>( aSelf ); |
294 { |
318 plugin->DoExecuteCommand(); |
295 TInt err = ContentController().AddWidgetL( *iPostponedContent ); |
319 return 0; |
296 if ( err != KErrNone ) |
320 } |
297 ShowErrorNoteL( err ); |
321 |
298 } |
322 // --------------------------------------------------------- |
299 iPostponedCommand = ENone; |
323 // CWmPlugin::DoExecuteCommand |
300 delete iPostponedContent; |
324 // --------------------------------------------------------- |
301 iPostponedContent = NULL; |
325 // |
|
326 void CWmPlugin::DoExecuteCommand() |
|
327 { |
|
328 // prevent multiple events |
|
329 if ( iLauncher->IsActive() ) |
|
330 { |
|
331 iLauncher->Cancel(); |
|
332 } |
|
333 |
|
334 if ( !iEffectManager->IsEffectActive() || |
|
335 iExecutionCount == KMaxCmdExecutionCount ) |
|
336 { |
|
337 if ( iPostponedCommand == EAddToHomescreen ) |
|
338 { |
|
339 TRAP_IGNORE( |
|
340 TInt err( KErrNone ); |
|
341 err = ContentController().AddWidgetL( *iPostponedContent ); |
|
342 if ( KErrNone != err ) |
|
343 ShowErrorNoteL( err ); |
|
344 ); |
|
345 } |
|
346 iPostponedCommand = ENone; |
|
347 delete iPostponedContent; |
|
348 iPostponedContent = NULL; |
|
349 iExecutionCount = 0; // reset counter |
|
350 } |
|
351 else |
|
352 { |
|
353 iExecutionCount++; |
|
354 iLauncher->Start( |
|
355 KExecuteCommandDelay, |
|
356 KExecuteCommandDelay, |
|
357 TCallBack( ExecuteCommand, this ) ); |
|
358 } |
302 } |
359 } |
303 |
360 |
304 // --------------------------------------------------------- |
361 // --------------------------------------------------------- |
305 // CWmPlugin::ShowErrorNoteL |
362 // CWmPlugin::ShowErrorNoteL |
306 // --------------------------------------------------------- |
363 // --------------------------------------------------------- |