125
|
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 |
*
|
|
16 |
*/
|
|
17 |
#include <apgwgnam.h>
|
|
18 |
|
|
19 |
#include "tswindowgroupsmonitorimp.h"
|
|
20 |
#include "tsrunningappstorageimp.h"
|
|
21 |
#include "tsresourcemanager.h"
|
|
22 |
|
|
23 |
|
|
24 |
const int KOrdinalPositionNoZOrder(-1);
|
|
25 |
// -----------------------------------------------------------------------------
|
|
26 |
//
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
//
|
|
29 |
CTsWindowGroupsMonitor* CTsWindowGroupsMonitor::NewL(MTsResourceManager &resources)
|
|
30 |
{
|
|
31 |
CTsWindowGroupsMonitor* self = new (ELeave) CTsWindowGroupsMonitor(resources);
|
|
32 |
CleanupStack::PushL(self);
|
|
33 |
self->ConstructL();
|
|
34 |
CleanupStack::Pop(self);
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CTsWindowGroupsMonitor::CTsWindowGroupsMonitor(MTsResourceManager &resources)
|
|
43 |
:
|
|
44 |
CActive(EPriorityStandard),
|
|
45 |
iResources(resources)
|
|
46 |
{
|
|
47 |
CActiveScheduler::Add(this);
|
|
48 |
}
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CTsWindowGroupsMonitor::ConstructL()
|
|
55 |
{
|
|
56 |
|
|
57 |
// Initial window group
|
|
58 |
iWg = RWindowGroup (iResources.WsSession());
|
|
59 |
User::LeaveIfError (iWg.Construct ((TUint32)&iWg, EFalse));
|
|
60 |
iWg.SetOrdinalPosition (KOrdinalPositionNoZOrder);
|
|
61 |
iWg.EnableReceiptOfFocus (EFalse);
|
|
62 |
|
|
63 |
// Hide window
|
|
64 |
CApaWindowGroupName* wn = CApaWindowGroupName::NewLC(iResources.WsSession());
|
|
65 |
wn->SetHidden (ETrue);
|
|
66 |
wn->SetWindowGroupName (iWg);
|
|
67 |
CleanupStack::PopAndDestroy (wn);
|
|
68 |
|
|
69 |
// Window group change event
|
|
70 |
User::LeaveIfError (iWg.EnableGroupListChangeEvents());
|
|
71 |
Subscribe();
|
|
72 |
}
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CTsWindowGroupsMonitor::~CTsWindowGroupsMonitor()
|
|
79 |
{
|
|
80 |
CActive::Cancel();
|
|
81 |
iWg.Close();
|
|
82 |
}
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CTsWindowGroupsMonitor::SubscribeL(MTsWindowGroupsObserver &observer)
|
|
89 |
{
|
|
90 |
const TInt offset(iObservers.Find(&observer));
|
|
91 |
KErrNotFound == offset ? iObservers.InsertL(&observer, 0) :
|
|
92 |
User::Leave(KErrAlreadyExists);
|
|
93 |
}
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void CTsWindowGroupsMonitor::Cancel(MTsWindowGroupsObserver & observer)
|
|
100 |
{
|
|
101 |
const TInt offset(iObservers.Find(&observer));
|
|
102 |
if (KErrNotFound != offset) {
|
|
103 |
iObservers.Remove(offset);
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CTsWindowGroupsMonitor::RunL()
|
|
112 |
{
|
|
113 |
User::LeaveIfError(iStatus.Int());
|
|
114 |
ProvideEventL();
|
|
115 |
Subscribe();
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
void CTsWindowGroupsMonitor::DoCancel()
|
|
123 |
{
|
|
124 |
if (IsActive()) {
|
|
125 |
iResources.WsSession().EventReadyCancel();
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
TInt CTsWindowGroupsMonitor::RunError(TInt error)
|
|
134 |
{
|
|
135 |
if (!IsActive() && KErrCancel != error) {
|
|
136 |
Subscribe();
|
|
137 |
}
|
|
138 |
return KErrNone;
|
|
139 |
}
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CTsWindowGroupsMonitor::Subscribe()
|
|
146 |
{
|
|
147 |
iResources.WsSession().EventReady( &iStatus );
|
|
148 |
SetActive();
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CTsWindowGroupsMonitor::ProvideEventL()
|
|
156 |
{
|
|
157 |
TWsEvent wsEvent;
|
|
158 |
iResources.WsSession().GetEvent(wsEvent);
|
|
159 |
if( EEventWindowGroupListChanged == wsEvent.Type() )
|
|
160 |
{
|
|
161 |
|
|
162 |
CTsRunningAppStorage *storage = CTsRunningAppStorage::NewLC();
|
|
163 |
|
|
164 |
RArray<RWsSession::TWindowGroupChainInfo> filteredWgInfo, fullWgInfo;
|
|
165 |
CleanupClosePushL(filteredWgInfo);
|
|
166 |
CleanupClosePushL(fullWgInfo);
|
|
167 |
User::LeaveIfError(iResources.WsSession().WindowGroupList(0, &filteredWgInfo));
|
|
168 |
User::LeaveIfError(iResources.WsSession().WindowGroupList(&fullWgInfo));
|
|
169 |
storage->HandleWindowGroupChanged(iResources,
|
|
170 |
fullWgInfo.Array(),
|
|
171 |
filteredWgInfo.Array());
|
|
172 |
CleanupStack::PopAndDestroy( &fullWgInfo );
|
|
173 |
CleanupStack::PopAndDestroy( &filteredWgInfo );
|
|
174 |
|
|
175 |
for( TInt iter(0); iter < iObservers.Count(); ++iter )
|
|
176 |
{
|
|
177 |
iObservers[iter]->HandleWindowGroupChanged( iResources, *storage );
|
|
178 |
}
|
|
179 |
CleanupStack::PopAndDestroy( storage );
|
|
180 |
|
|
181 |
}
|
|
182 |
}
|