83
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
* widget manager plugin implementation
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <bautils.h>
|
|
21 |
#include <coemain.h>
|
|
22 |
#include <aknViewAppUi.h>
|
|
23 |
#include <eikappui.h>
|
|
24 |
#include <eikapp.h>
|
|
25 |
#include <e32property.h>
|
|
26 |
#include <e32base.h>
|
|
27 |
#include <activeidle2domainpskeys.h>
|
|
28 |
#include <widgetmanagerview.rsg>
|
|
29 |
|
|
30 |
#include "wmcommon.h"
|
|
31 |
#include "widgetmanager.hrh"
|
|
32 |
#include "wmmaincontainer.h"
|
|
33 |
#include "wmmaincontainerview.h"
|
|
34 |
#include "wmresourceloader.h"
|
|
35 |
#include "wmplugin.h"
|
|
36 |
#include "wmeffectmanager.h"
|
|
37 |
#include "wmwidgetdata.h"
|
|
38 |
#include "wminstaller.h"
|
|
39 |
#include "wmlistbox.h"
|
|
40 |
|
|
41 |
const TInt KExecuteCommandDelay( 50000 ); // 50ms
|
|
42 |
const TInt KMaxCmdExecutionCount( 6 );
|
|
43 |
|
|
44 |
// ---------------------------------------------------------
|
|
45 |
// CWmPlugin::NewL
|
|
46 |
// ---------------------------------------------------------
|
|
47 |
//
|
|
48 |
CWmPlugin* CWmPlugin::NewL()
|
|
49 |
{
|
|
50 |
CWmPlugin* self = new( ELeave ) CWmPlugin();
|
|
51 |
CleanupStack::PushL( self );
|
|
52 |
self->ConstructL();
|
|
53 |
CleanupStack::Pop(self);
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// CWmPlugin::~CWmPlugin
|
|
59 |
// ---------------------------------------------------------
|
|
60 |
//
|
|
61 |
CWmPlugin::~CWmPlugin()
|
|
62 |
{
|
|
63 |
if ( iLauncher && iLauncher->IsActive() )
|
|
64 |
{
|
|
65 |
iLauncher->Cancel();
|
|
66 |
}
|
|
67 |
delete iLauncher;
|
|
68 |
|
|
69 |
if ( iWmInstaller &&
|
|
70 |
iWmInstaller->IsActive() )
|
|
71 |
{
|
|
72 |
iWmInstaller->Cancel();
|
|
73 |
}
|
|
74 |
|
|
75 |
// delete members
|
|
76 |
delete iResourceLoader;
|
|
77 |
delete iEffectManager;
|
|
78 |
delete iPostponedContent;
|
|
79 |
delete iWmInstaller;
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------
|
|
83 |
// CWmPlugin::CWmPlugin
|
|
84 |
// ---------------------------------------------------------
|
|
85 |
//
|
|
86 |
CWmPlugin::CWmPlugin()
|
|
87 |
{
|
|
88 |
iPreviousViewUid.iViewUid = KNullUid;
|
|
89 |
iExecutionCount = 0;
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------
|
|
93 |
// CWmPlugin::ConstructL
|
|
94 |
// ---------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CWmPlugin::ConstructL()
|
|
97 |
{
|
|
98 |
iWmMainContainer = NULL;
|
|
99 |
iPostponedCommand = ENone;
|
|
100 |
|
|
101 |
// store static view app ui
|
|
102 |
CEikonEnv* eikonEnv = CEikonEnv::Static();
|
|
103 |
if ( !eikonEnv ) User::Leave( KErrUnknown );
|
|
104 |
iViewAppUi = (CAknViewAppUi*)eikonEnv->EikAppUi();
|
|
105 |
if ( !iViewAppUi ) User::Leave( KErrUnknown );
|
|
106 |
|
|
107 |
// create resource loader
|
|
108 |
iFs = &eikonEnv->FsSession();
|
|
109 |
iResourceLoader = CWmResourceLoader::NewL( *eikonEnv );
|
|
110 |
iEffectManager = CWmEffectManager::NewL( *eikonEnv );
|
|
111 |
iWmInstaller = CWmInstaller::NewL( *this );
|
|
112 |
|
|
113 |
// main view
|
|
114 |
CWmMainContainerView* mainView =
|
|
115 |
CWmMainContainerView::NewL( *this );
|
|
116 |
CleanupStack::PushL( mainView );
|
|
117 |
iViewAppUi->AddViewL( mainView );
|
|
118 |
CleanupStack::Pop( mainView );
|
|
119 |
|
|
120 |
// laucher for adding widgets.
|
|
121 |
iLauncher = CPeriodic::NewL( CActive::EPriorityUserInput + 1 );
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
// CWmPlugin::Activate
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CWmPlugin::Activate()
|
|
129 |
{
|
|
130 |
// prevents opening wm if adding widget is ongoing.
|
|
131 |
if ( !iLauncher->IsActive() )
|
|
132 |
{
|
|
133 |
CWmMainContainerView* view = static_cast<CWmMainContainerView*>(
|
|
134 |
iViewAppUi->View( TUid::Uid(EWmMainContainerViewId) ) );
|
|
135 |
if ( !IsActive() && view && iHsContentController )
|
|
136 |
{
|
|
137 |
// stop displaying menubar before starting fullscreen effects
|
|
138 |
CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar();
|
|
139 |
if ( menuBar && menuBar->IsDisplayed() )
|
|
140 |
{
|
|
141 |
menuBar->StopDisplayingMenuBar();
|
|
142 |
}
|
|
143 |
|
|
144 |
TRAP_IGNORE(
|
|
145 |
iEffectManager->BeginFullscreenEffectL(
|
|
146 |
KAppStartEffectStyle );
|
|
147 |
iViewAppUi->ActivateLocalViewL(
|
|
148 |
TUid::Uid( EWmMainContainerViewId ) );
|
|
149 |
);
|
|
150 |
}
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
// CWmPlugin::DeActivate
|
|
156 |
// ---------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CWmPlugin::DeActivate()
|
|
159 |
{
|
|
160 |
iPostponedCommand = ENone;
|
|
161 |
iPreviousViewUid.iViewUid = KNullUid;
|
|
162 |
CWmMainContainerView* view = static_cast<CWmMainContainerView*>(
|
|
163 |
iViewAppUi->View( TUid::Uid(EWmMainContainerViewId) ) );
|
|
164 |
if ( view ) { view->DoDeactivate(); }
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
// CWmPlugin::Views
|
|
169 |
// ---------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CWmPlugin::Views( RPointerArray<CAknView>& aViews )
|
|
172 |
{
|
|
173 |
// return view to be destroyed.
|
|
174 |
CAknView* view = iViewAppUi->View(
|
|
175 |
TUid::Uid(EWmMainContainerViewId) );
|
|
176 |
if ( view )
|
|
177 |
{
|
|
178 |
aViews.Append( view );
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------
|
|
183 |
// CWmPlugin::IsActive
|
|
184 |
// ---------------------------------------------------------
|
|
185 |
//
|
|
186 |
TBool CWmPlugin::IsActive()
|
|
187 |
{
|
|
188 |
TVwsViewId activeViewId(KNullUid,KNullUid);
|
|
189 |
if ( iViewAppUi->GetActiveViewId( activeViewId ) == KErrNone &&
|
|
190 |
activeViewId.iViewUid == TUid::Uid( EWmMainContainerViewId ) )
|
|
191 |
{
|
|
192 |
if ( iPreviousViewUid.iViewUid == KNullUid &&
|
|
193 |
iViewAppUi->GetDefaultViewId( iPreviousViewUid ) != KErrNone )
|
|
194 |
{
|
|
195 |
iPreviousViewUid.iAppUid = iViewAppUi->Application()->AppDllUid();
|
|
196 |
iPreviousViewUid.iViewUid = TUid::Uid( 1 );
|
|
197 |
}
|
|
198 |
return ETrue;
|
|
199 |
}
|
|
200 |
|
|
201 |
return( iPreviousViewUid.iViewUid != KNullUid );
|
|
202 |
}
|
|
203 |
|
|
204 |
// ---------------------------------------------------------
|
|
205 |
// CWmPlugin::CloseView
|
|
206 |
// ---------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CWmPlugin::CloseView()
|
|
209 |
{
|
|
210 |
if ( IsActive() )
|
|
211 |
{
|
|
212 |
iWmMainContainer->SetClosingDown( ETrue );
|
|
213 |
TRAPD( err,
|
|
214 |
iEffectManager->BeginFullscreenEffectL(
|
|
215 |
KAppExitEffectStyle );
|
|
216 |
iViewAppUi->ActivateLocalViewL(
|
|
217 |
iPreviousViewUid.iViewUid );
|
|
218 |
);
|
|
219 |
if ( KErrNone != err )
|
|
220 |
{
|
|
221 |
iWmMainContainer->SetClosingDown( EFalse );
|
|
222 |
}
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
// ---------------------------------------------------------
|
|
227 |
// CWmPlugin::MainViewActivated
|
|
228 |
// ---------------------------------------------------------
|
|
229 |
//
|
|
230 |
void CWmPlugin::MainViewActivated(
|
|
231 |
const TVwsViewId& /*aViewId*/,
|
|
232 |
CWmMainContainer* aWmMainContainer )
|
|
233 |
{
|
|
234 |
// previous view for Wm is always default view.
|
|
235 |
if ( iViewAppUi->GetDefaultViewId( iPreviousViewUid ) != KErrNone )
|
|
236 |
{
|
|
237 |
// use default if we got wrong viewid as previous view
|
|
238 |
iPreviousViewUid.iAppUid = iViewAppUi->Application()->AppDllUid();
|
|
239 |
iPreviousViewUid.iViewUid = TUid::Uid( 1 );
|
|
240 |
}
|
|
241 |
|
|
242 |
iWmMainContainer = aWmMainContainer;
|
|
243 |
iEffectManager->UiRendered();
|
|
244 |
iWmMainContainer->SetClosingDown( EFalse );
|
|
245 |
|
|
246 |
// Don't forward numeric keys to phone
|
|
247 |
ForwardNumericKeysToPhone( EFalse );
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
// CWmPlugin::MainViewDeactivated
|
|
252 |
// ---------------------------------------------------------
|
|
253 |
//
|
|
254 |
void CWmPlugin::MainViewDeactivated()
|
|
255 |
{
|
|
256 |
// Forward numeric keys to phone
|
|
257 |
ForwardNumericKeysToPhone( ETrue );
|
|
258 |
|
|
259 |
iPreviousViewUid.iViewUid = KNullUid;
|
|
260 |
iWmMainContainer = NULL;
|
|
261 |
if ( iEffectManager )
|
|
262 |
{
|
|
263 |
iEffectManager->UiRendered();
|
|
264 |
}
|
|
265 |
|
|
266 |
if ( !iEffectManager->IsEffectActive() )
|
|
267 |
{
|
|
268 |
// launch effect without delay
|
|
269 |
if ( !iLauncher->IsActive() )
|
|
270 |
{
|
|
271 |
iExecutionCount = KMaxCmdExecutionCount;
|
|
272 |
iLauncher->Start( 0, 0, TCallBack( ExecuteCommand, this ) );
|
|
273 |
}
|
|
274 |
}
|
|
275 |
else
|
|
276 |
{
|
|
277 |
// maximum wait time is 300ms (6 x 50ms)
|
|
278 |
if ( !iLauncher->IsActive() )
|
|
279 |
{
|
|
280 |
iExecutionCount++;
|
|
281 |
iLauncher->Start(
|
|
282 |
KExecuteCommandDelay,
|
|
283 |
KExecuteCommandDelay,
|
|
284 |
TCallBack( ExecuteCommand, this ) );
|
|
285 |
}
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
// ---------------------------------------------------------
|
|
290 |
// CWmPlugin::ForwardNumericKeysToPhone
|
|
291 |
// ---------------------------------------------------------
|
|
292 |
//
|
|
293 |
void CWmPlugin::ForwardNumericKeysToPhone( TBool aEnabled )
|
|
294 |
{
|
|
295 |
TInt value = aEnabled ?
|
|
296 |
EPSAiForwardNumericKeysToPhone :
|
|
297 |
EPSAiDontForwardNumericKeysToPhone;
|
|
298 |
|
|
299 |
RProperty::Set(
|
|
300 |
KPSUidAiInformation,
|
|
301 |
KActiveIdleForwardNumericKeysToPhone,
|
|
302 |
value );
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------
|
|
306 |
// CWmPlugin::SetPostponedCommandL
|
|
307 |
// ---------------------------------------------------------
|
|
308 |
//
|
|
309 |
void CWmPlugin::SetPostponedCommandL(
|
|
310 |
TCommand aCommand, CHsContentInfo& aContentInfo )
|
|
311 |
{
|
|
312 |
iPostponedCommand = aCommand;
|
|
313 |
delete iPostponedContent;
|
|
314 |
iPostponedContent = NULL;
|
|
315 |
iPostponedContent = aContentInfo.CloneL();
|
|
316 |
}
|
|
317 |
|
|
318 |
// ---------------------------------------------------------
|
|
319 |
// CWmPlugin::ExecuteCommand
|
|
320 |
// ---------------------------------------------------------
|
|
321 |
//
|
|
322 |
TInt CWmPlugin::ExecuteCommand( TAny* aSelf )
|
|
323 |
{
|
|
324 |
CWmPlugin* plugin = static_cast<CWmPlugin*>( aSelf );
|
|
325 |
plugin->DoExecuteCommand();
|
|
326 |
return 0;
|
|
327 |
}
|
|
328 |
|
|
329 |
// ---------------------------------------------------------
|
|
330 |
// CWmPlugin::DoExecuteCommand
|
|
331 |
// ---------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CWmPlugin::DoExecuteCommand()
|
|
334 |
{
|
|
335 |
// prevent multiple events
|
|
336 |
if ( iLauncher->IsActive() )
|
|
337 |
{
|
|
338 |
iLauncher->Cancel();
|
|
339 |
}
|
|
340 |
|
|
341 |
if ( !iEffectManager->IsEffectActive() ||
|
|
342 |
iExecutionCount == KMaxCmdExecutionCount )
|
|
343 |
{
|
|
344 |
if ( iPostponedCommand == EAddToHomescreen )
|
|
345 |
{
|
|
346 |
TRAP_IGNORE(
|
|
347 |
TInt err( KErrNone );
|
|
348 |
err = ContentController().AddWidgetL( *iPostponedContent );
|
|
349 |
if ( KErrNone != err )
|
|
350 |
ShowErrorNoteL( err );
|
|
351 |
);
|
|
352 |
}
|
|
353 |
iPostponedCommand = ENone;
|
|
354 |
delete iPostponedContent;
|
|
355 |
iPostponedContent = NULL;
|
|
356 |
iExecutionCount = 0; // reset counter
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
iExecutionCount++;
|
|
361 |
iLauncher->Start(
|
|
362 |
KExecuteCommandDelay,
|
|
363 |
KExecuteCommandDelay,
|
|
364 |
TCallBack( ExecuteCommand, this ) );
|
|
365 |
}
|
|
366 |
}
|
|
367 |
|
|
368 |
// ---------------------------------------------------------
|
|
369 |
// CWmPlugin::ShowErrorNoteL
|
|
370 |
// ---------------------------------------------------------
|
|
371 |
//
|
|
372 |
void CWmPlugin::ShowErrorNoteL( TInt aError )
|
|
373 |
{
|
|
374 |
switch ( aError )
|
|
375 |
{
|
|
376 |
case KHsErrorViewFull:
|
|
377 |
case KHsErrorDoesNotFit:
|
|
378 |
// Not enough space to add new widget to active page.
|
|
379 |
// Remove some content first.
|
|
380 |
ResourceLoader().InfoPopupL(
|
|
381 |
R_QTN_HS_ADD_WIDGET_NO_SPACE_NOTE, KNullDesC );
|
|
382 |
break;
|
|
383 |
case KErrNoMemory:
|
|
384 |
case KErrDiskFull:
|
|
385 |
// do not show error note here to avoid multiple error notes
|
|
386 |
break;
|
|
387 |
default:
|
|
388 |
ResourceLoader().ErrorPopup( aError );
|
|
389 |
break;
|
|
390 |
}
|
|
391 |
}
|
|
392 |
|
|
393 |
// ---------------------------------------------------------
|
|
394 |
// CWmPlugin::ViewAppUi
|
|
395 |
// ---------------------------------------------------------
|
|
396 |
//
|
|
397 |
CAknViewAppUi& CWmPlugin::ViewAppUi()
|
|
398 |
{
|
|
399 |
return *iViewAppUi;
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------
|
|
403 |
// CWmPlugin::ResourceLoader
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
//
|
|
406 |
CWmResourceLoader& CWmPlugin::ResourceLoader()
|
|
407 |
{
|
|
408 |
return *iResourceLoader;
|
|
409 |
}
|
|
410 |
|
|
411 |
// ---------------------------------------------------------
|
|
412 |
// CWmPlugin::ContentController
|
|
413 |
// ---------------------------------------------------------
|
|
414 |
//
|
|
415 |
MHsContentController& CWmPlugin::ContentController()
|
|
416 |
{
|
|
417 |
return *iHsContentController;
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------
|
|
421 |
// CWmPlugin::FileServer
|
|
422 |
// ---------------------------------------------------------
|
|
423 |
//
|
|
424 |
RFs& CWmPlugin::FileServer()
|
|
425 |
{
|
|
426 |
return *iFs;
|
|
427 |
}
|
|
428 |
|
|
429 |
// ---------------------------------------------------------
|
|
430 |
// CWmPlugin::NotifyWidgetListChanged
|
|
431 |
// ---------------------------------------------------------
|
|
432 |
//
|
|
433 |
void CWmPlugin::NotifyWidgetListChanged()
|
|
434 |
{
|
|
435 |
if ( iWmMainContainer && !iWmMainContainer->ClosingDown() )
|
|
436 |
{
|
|
437 |
iWmMainContainer->HandleWidgetListChanged();
|
|
438 |
}
|
|
439 |
}
|
|
440 |
|
|
441 |
// ---------------------------------------------------------
|
|
442 |
// CWmPlugin::WmInstaller
|
|
443 |
// ---------------------------------------------------------
|
|
444 |
//
|
|
445 |
CWmInstaller& CWmPlugin::WmInstaller()
|
|
446 |
{
|
|
447 |
return *iWmInstaller;
|
|
448 |
}
|
|
449 |
|
|
450 |
// ---------------------------------------------------------
|
|
451 |
// CWmPlugin::GetUnistalledWidget
|
|
452 |
// ---------------------------------------------------------
|
|
453 |
//
|
|
454 |
CWmWidgetData* CWmPlugin::GetUninstalledWidgetByUid( TUid aUid )
|
|
455 |
{
|
|
456 |
CWmWidgetData* retVal = NULL;
|
|
457 |
if ( iWmMainContainer )
|
|
458 |
{
|
|
459 |
const RWidgetDataValues& widgetArray =
|
|
460 |
iWmMainContainer->WmListBox().WidgetDataArray();
|
|
461 |
for ( TInt i = 0; i < widgetArray.Count(); i++ )
|
|
462 |
{
|
|
463 |
CWmWidgetData* widgetData = widgetArray[i];
|
|
464 |
if ( widgetData->IsUninstalling() &&
|
|
465 |
widgetData->PublisherUid() == aUid )
|
|
466 |
{
|
|
467 |
retVal = widgetArray[i];
|
|
468 |
break;
|
|
469 |
}
|
|
470 |
}
|
|
471 |
}
|
|
472 |
return retVal;
|
|
473 |
}
|
|
474 |
|
|
475 |
// End of file
|
|
476 |
|