114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <apgwgnam.h>
|
|
19 |
#include <apgtask.h>
|
|
20 |
#include <widgetregistryclient.h>
|
|
21 |
#include <mmf/common/mmfcontrollerpluginresolver.h>
|
|
22 |
|
|
23 |
#include "mcsrunningappswgmonitor.h"
|
|
24 |
#include "mcsrunningappshandler.h"
|
|
25 |
#include "menueng.h"
|
|
26 |
|
|
27 |
const TInt KWindowGroupPosition = -1;
|
|
28 |
const TInt KWindowGroupPriority = -1;
|
|
29 |
|
|
30 |
// ---------------------------------------------------------
|
|
31 |
// CMcsRunningAppsWgMonitor::NewL
|
|
32 |
// ---------------------------------------------------------
|
|
33 |
//
|
|
34 |
CMcsRunningAppsWgMonitor* CMcsRunningAppsWgMonitor::NewL(
|
|
35 |
CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler,
|
|
36 |
TInt aPriority )
|
|
37 |
{
|
|
38 |
CMcsRunningAppsWgMonitor* self =
|
|
39 |
new ( ELeave ) CMcsRunningAppsWgMonitor( aEng, aRunningAppsHandler,
|
|
40 |
aPriority );
|
|
41 |
CleanupStack::PushL( self );
|
|
42 |
self->ConstructL();
|
|
43 |
CleanupStack::Pop( self );
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------
|
|
48 |
// CMcsRunningAppsWgMonitor::~CWindowGroupChangeMonitor
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
//
|
|
51 |
CMcsRunningAppsWgMonitor::~CMcsRunningAppsWgMonitor()
|
|
52 |
{
|
|
53 |
Cancel();
|
|
54 |
iEng.DequeueOperation( *this );
|
|
55 |
iRunningApps.Close();
|
|
56 |
delete iWgName;
|
|
57 |
iWg.Close();
|
|
58 |
iWidgetSession.Close();
|
|
59 |
iWsSession.Close();
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
// CMcsRunningAppsWgMonitor::CMcsRunningAppsWgMonitor
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
//
|
|
66 |
CMcsRunningAppsWgMonitor::CMcsRunningAppsWgMonitor(
|
|
67 |
CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler,
|
|
68 |
TInt aPriority ):
|
|
69 |
CActive( aPriority ),
|
|
70 |
iEng(aEng),
|
|
71 |
iRunningAppsHandler(aRunningAppsHandler)
|
|
72 |
{
|
|
73 |
CActiveScheduler::Add( this );
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
// CMcsRunningAppsWgMonitor::ConstructL
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CMcsRunningAppsWgMonitor::ConstructL()
|
|
81 |
{
|
|
82 |
iOperationInProgress = EFalse;
|
|
83 |
User::LeaveIfError( iWsSession.Connect() );
|
|
84 |
User::LeaveIfError( iWidgetSession.Connect() );
|
|
85 |
|
|
86 |
iWg = RWindowGroup( iWsSession );
|
|
87 |
|
|
88 |
// Make a handle from the address of window group obj.
|
|
89 |
User::LeaveIfError( iWg.Construct(
|
|
90 |
reinterpret_cast<TUint32>( &iWg ) ) );
|
|
91 |
|
|
92 |
//myWindowGroup.AutoForeground( EFalse );
|
|
93 |
iWg.DisableFocusChangeEvents();
|
|
94 |
iWg.DisableModifierChangedEvents();
|
|
95 |
iWg.DisableOnEvents();
|
|
96 |
iWg.DisableScreenChangeEvents();
|
|
97 |
iWg.SetOrdinalPosition( KWindowGroupPosition, KWindowGroupPriority );
|
|
98 |
User::LeaveIfError( iWg.EnableGroupListChangeEvents() );
|
|
99 |
//it makes the soft keys working
|
|
100 |
iWg.EnableReceiptOfFocus( EFalse );
|
|
101 |
|
|
102 |
iWgName = CApaWindowGroupName::NewL( iWsSession );
|
|
103 |
iWgName->SetSystem( ETrue );
|
|
104 |
iWgName->SetHidden( ETrue );
|
|
105 |
iWgName->SetWindowGroupName( iWg );
|
|
106 |
|
|
107 |
|
|
108 |
UpdateRunningApplicationsL();
|
|
109 |
Start();
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------
|
|
113 |
// CMcsRunningAppsWgMonitor::Start
|
|
114 |
// ---------------------------------------------------------
|
|
115 |
//
|
|
116 |
void CMcsRunningAppsWgMonitor::Start()
|
|
117 |
{
|
|
118 |
if (!IsActive())
|
|
119 |
{
|
|
120 |
iWsSession.EventReady( &iStatus );
|
|
121 |
SetActive();
|
|
122 |
}
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------
|
|
126 |
// CMcsRunningAppsWgMonitor::DoCancel
|
|
127 |
// ---------------------------------------------------------
|
|
128 |
//
|
|
129 |
void CMcsRunningAppsWgMonitor::DoCancel()
|
|
130 |
{
|
|
131 |
iWsSession.EventReadyCancel();
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------
|
|
135 |
// CMcsRunningAppsWgMonitor::RunL
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CMcsRunningAppsWgMonitor::RunL()
|
|
139 |
{
|
|
140 |
User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL.
|
|
141 |
// AppArc app scan complete, we have the app list.
|
|
142 |
// Now queue this operation to be executed by the Engine.
|
|
143 |
|
|
144 |
TWsEvent event;
|
|
145 |
iWsSession.GetEvent(event);
|
|
146 |
Start();
|
|
147 |
|
|
148 |
if (!iOperationInProgress &&
|
|
149 |
(event.Type() == EEventWindowGroupListChanged ))
|
|
150 |
{
|
|
151 |
iOperationInProgress = ETrue;
|
|
152 |
iEng.QueueOperationL( *this );
|
|
153 |
}
|
|
154 |
else if ( event.Type() == EEventPowerMgmt )
|
|
155 |
{
|
|
156 |
TApaSystemEvent systemEvent( *(TApaSystemEvent*)(event.EventData()) );
|
|
157 |
// System secure shutdown, stop server
|
|
158 |
if ( systemEvent == EApaSystemEventSecureShutdown )
|
|
159 |
{
|
|
160 |
CActiveScheduler::Stop();
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------
|
|
166 |
// CMcsRunningAppsWgMonitor::RunError()
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
//
|
|
169 |
TInt CMcsRunningAppsWgMonitor::RunError( TInt /*aError*/ )
|
|
170 |
{
|
|
171 |
Start();
|
|
172 |
return KErrNone;
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------
|
|
176 |
// CMcsRunningAppsWgMonitor::RunMenuEngOperationL
|
|
177 |
// ---------------------------------------------------------
|
|
178 |
//
|
|
179 |
void CMcsRunningAppsWgMonitor::RunMenuEngOperationL()
|
|
180 |
{
|
|
181 |
iOperationInProgress = EFalse;
|
|
182 |
UpdateRunningApplicationsL();
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------
|
|
186 |
// CMcsRunningAppsWgMonitor::CompletedMenuEngOperation
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CMcsRunningAppsWgMonitor::CompletedMenuEngOperation( TInt /*aErr*/ )
|
|
190 |
{
|
|
191 |
// If there was error, ignore it (what else could we do?).
|
|
192 |
// When next AppArc update occurs, we will run again.
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------
|
|
196 |
// CMcsRunningAppsWgMonitor::UpdateRunningApplicationsL
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
//
|
|
199 |
void CMcsRunningAppsWgMonitor::UpdateRunningApplicationsL()
|
|
200 |
{
|
|
201 |
iRunningApps.Reset();
|
|
202 |
|
|
203 |
RArray<RWsSession::TWindowGroupChainInfo> windowGroupIds;
|
|
204 |
CleanupClosePushL( windowGroupIds );
|
|
205 |
|
|
206 |
User::LeaveIfError( iWsSession.WindowGroupList(0, &windowGroupIds) );
|
|
207 |
const TInt count = windowGroupIds.Count();
|
|
208 |
|
|
209 |
for (TInt i=0; i<count; i++)
|
|
210 |
{
|
|
211 |
TInt wgId = windowGroupIds[i].iId;
|
|
212 |
iWgName->ConstructFromWgIdL(wgId);
|
|
213 |
|
|
214 |
// find the window group id and check that it has no parent
|
|
215 |
if (windowGroupIds[i].iParentId <= 0)
|
|
216 |
{
|
|
217 |
TUid appUid = iWgName->AppUid();
|
|
218 |
if ( ( appUid.iUid ) &&
|
|
219 |
( iRunningApps.Find( appUid ) == KErrNotFound ))
|
|
220 |
{
|
|
221 |
iRunningApps.AppendL( appUid );
|
|
222 |
}
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
CleanupStack::PopAndDestroy( &windowGroupIds );
|
|
227 |
|
|
228 |
UpdateWidgetTaskListL();
|
|
229 |
|
|
230 |
iRunningAppsHandler->HandleListUpdateL( iRunningApps,
|
|
231 |
MMcsRunningAppsHandler::ERunningApps );
|
|
232 |
}
|
|
233 |
|
|
234 |
// ---------------------------------------------------------
|
|
235 |
// CMcsRunningAppsWgMonitor::UpdateWidgetTaskListL
|
|
236 |
// ---------------------------------------------------------
|
|
237 |
//
|
|
238 |
void CMcsRunningAppsWgMonitor::UpdateWidgetTaskListL( )
|
|
239 |
{
|
|
240 |
RWidgetInfoArray widgetInfoArr;
|
|
241 |
CleanupResetAndDestroyPushL( widgetInfoArr );
|
|
242 |
|
|
243 |
iWidgetSession.RunningWidgetsL( widgetInfoArr );
|
|
244 |
|
|
245 |
for (TInt i=0; i<widgetInfoArr.Count(); i++)
|
|
246 |
{
|
|
247 |
TUid wgUid( widgetInfoArr[i]->iUid );
|
|
248 |
if( iWidgetSession.IsWidgetInFullView( wgUid ) )
|
|
249 |
{
|
|
250 |
iRunningApps.AppendL( wgUid );
|
|
251 |
}
|
|
252 |
}
|
|
253 |
|
|
254 |
CleanupStack::PopAndDestroy( &widgetInfoArr ); // widgetInfoArr
|
|
255 |
}
|
|
256 |
// End of File
|