114
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2006 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: Engine class for Device Status Plug-in
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
|
|
20 |
// User includes
|
|
21 |
#include <aicontentobserver.h>
|
|
22 |
#include "aidevicestatuspluginengine.h"
|
|
23 |
#include "aipublisherfactory.h"
|
|
24 |
#include "aidevicestatuspublisher.h"
|
|
25 |
|
|
26 |
// ======== MEMBER FUNCTIONS ========
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// CAiDeviceStatusPluginEngine::CAiDeviceStatusPluginEngine
|
|
29 |
//
|
|
30 |
// ----------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CAiDeviceStatusPluginEngine::CAiDeviceStatusPluginEngine(
|
|
33 |
MAiContentObserver& aObserver, CHsContentPublisher& aExtension,
|
|
34 |
MAiPublishPrioritizer& aPrioritizer )
|
|
35 |
: iContentObserver( &aObserver ), iExtension( &aExtension ),
|
|
36 |
iPrioritizer( &aPrioritizer )
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
// CAiDeviceStatusPluginEngine::ConstructL
|
|
42 |
//
|
|
43 |
// ----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
void CAiDeviceStatusPluginEngine::ConstructL()
|
|
46 |
{
|
|
47 |
// Instantiate all publishers via factory
|
|
48 |
MAiDeviceStatusPublisher* publisher = AiPublisherFactory::CreateDatePublisherL();
|
|
49 |
CleanupStack::PushL( publisher );
|
|
50 |
AddPublisherL( publisher );
|
|
51 |
CleanupStack::Pop( publisher );
|
|
52 |
|
|
53 |
publisher = AiPublisherFactory::CreateSimRegPublisherL();
|
|
54 |
CleanupStack::PushL( publisher );
|
|
55 |
AddPublisherL( publisher );
|
|
56 |
CleanupStack::Pop( publisher );
|
|
57 |
|
|
58 |
publisher = AiPublisherFactory::CreateNWSPublisherL();
|
|
59 |
CleanupStack::PushL( publisher );
|
|
60 |
AddPublisherL( publisher );
|
|
61 |
CleanupStack::Pop( publisher );
|
|
62 |
|
|
63 |
publisher = AiPublisherFactory::CreateBTSAPPublisherL();
|
|
64 |
CleanupStack::PushL( publisher );
|
|
65 |
AddPublisherL( publisher );
|
|
66 |
CleanupStack::Pop( publisher );
|
|
67 |
|
|
68 |
publisher = AiPublisherFactory::CreateOperatorLogoPublisherL();
|
|
69 |
CleanupStack::PushL( publisher );
|
|
70 |
AddPublisherL( publisher );
|
|
71 |
CleanupStack::Pop( publisher );
|
|
72 |
|
|
73 |
publisher = AiPublisherFactory::CreateOperatorNamePublisherL();
|
|
74 |
CleanupStack::PushL( publisher );
|
|
75 |
AddPublisherL( publisher );
|
|
76 |
CleanupStack::Pop( publisher );
|
|
77 |
|
|
78 |
publisher = AiPublisherFactory::CreateMCNPublisherL();
|
|
79 |
CleanupStack::PushL( publisher );
|
|
80 |
AddPublisherL( publisher );
|
|
81 |
CleanupStack::Pop( publisher );
|
|
82 |
|
|
83 |
publisher = AiPublisherFactory::CreateCUGPublisherL();
|
|
84 |
CleanupStack::PushL( publisher );
|
|
85 |
AddPublisherL( publisher );
|
|
86 |
CleanupStack::Pop( publisher );
|
|
87 |
|
|
88 |
publisher = AiPublisherFactory::CreateVHZPublisherL();
|
|
89 |
CleanupStack::PushL( publisher );
|
|
90 |
AddPublisherL( publisher );
|
|
91 |
CleanupStack::Pop( publisher );
|
|
92 |
|
|
93 |
publisher = AiPublisherFactory::CreateCUGMCNPublisherL();
|
|
94 |
CleanupStack::PushL( publisher );
|
|
95 |
AddPublisherL( publisher );
|
|
96 |
CleanupStack::Pop( publisher );
|
|
97 |
|
|
98 |
// Subscribe all publishers once they are instantiated
|
|
99 |
const TInt count( iPublishers.Count() );
|
|
100 |
|
|
101 |
for ( TInt i( 0 ); i < count; i++ )
|
|
102 |
{
|
|
103 |
iPublishers[i]->Subscribe(
|
|
104 |
*iContentObserver, *iExtension, *iPrioritizer, *this );
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
// ----------------------------------------------------------------------------
|
|
109 |
// CAiDeviceStatusPluginEngine::NewL
|
|
110 |
//
|
|
111 |
// ----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
CAiDeviceStatusPluginEngine* CAiDeviceStatusPluginEngine::NewL(
|
|
114 |
MAiContentObserver& aObserver, CHsContentPublisher& aExtension,
|
|
115 |
MAiPublishPrioritizer& aPrioritizer )
|
|
116 |
{
|
|
117 |
CAiDeviceStatusPluginEngine* self =
|
|
118 |
new( ELeave ) CAiDeviceStatusPluginEngine( aObserver, aExtension, aPrioritizer );
|
|
119 |
|
|
120 |
CleanupStack::PushL( self );
|
|
121 |
self->ConstructL();
|
|
122 |
CleanupStack::Pop( self );
|
|
123 |
return self;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
// CAiDeviceStatusPluginEngine::~CAiDeviceStatusPluginEngine
|
|
128 |
//
|
|
129 |
// ----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
|
|
132 |
CAiDeviceStatusPluginEngine::~CAiDeviceStatusPluginEngine()
|
|
133 |
{
|
|
134 |
iPublishers.ResetAndDestroy();
|
|
135 |
}
|
|
136 |
|
|
137 |
// ----------------------------------------------------------------------------
|
|
138 |
// CAiDeviceStatusPluginEngine::AddPublisherL
|
|
139 |
//
|
|
140 |
// ----------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void CAiDeviceStatusPluginEngine::AddPublisherL(
|
|
143 |
MAiDeviceStatusPublisher* aPublisher )
|
|
144 |
{
|
|
145 |
//Add publisher to list.
|
|
146 |
if ( aPublisher )
|
|
147 |
{
|
|
148 |
CleanupDeletePushL( aPublisher );
|
|
149 |
User::LeaveIfError( iPublishers.Append( aPublisher ) );
|
|
150 |
CleanupStack::Pop(aPublisher);//aPublisher
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// ----------------------------------------------------------------------------
|
|
155 |
// CAiDeviceStatusPluginEngine::ResumePublishersL
|
|
156 |
//
|
|
157 |
// ----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
void CAiDeviceStatusPluginEngine::ResumePublishersL()
|
|
160 |
{
|
|
161 |
const TInt count( iPublishers.Count() );
|
|
162 |
|
|
163 |
for ( TInt i( 0 ); i < count; i++ )
|
|
164 |
{
|
|
165 |
iPublishers[i]->ResumeL();
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
// ----------------------------------------------------------------------------
|
|
170 |
// CAiDeviceStatusPluginEngine::RefreshActivePublishersL
|
|
171 |
//
|
|
172 |
// ----------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CAiDeviceStatusPluginEngine::RefreshActivePublishersL( TBool aClean )
|
|
175 |
{
|
|
176 |
iContentObserver->StartTransaction( KImplUidDevStaPlugin );
|
|
177 |
|
|
178 |
const TInt count( iPublishers.Count() );
|
|
179 |
|
|
180 |
for ( TInt i( 0 ); i < count; i++ )
|
|
181 |
{
|
|
182 |
iPublishers[i]->RefreshIfActiveL( aClean );
|
|
183 |
}
|
|
184 |
|
|
185 |
iContentObserver->Commit( KImplUidDevStaPlugin );
|
|
186 |
}
|
|
187 |
|
|
188 |
// ----------------------------------------------------------------------------
|
|
189 |
// CAiDeviceStatusPluginEngine::RefreshPublishersL
|
|
190 |
//
|
|
191 |
// ----------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void CAiDeviceStatusPluginEngine::RefreshPublishersL( TBool aClean )
|
|
194 |
{
|
|
195 |
iContentObserver->StartTransaction( KImplUidDevStaPlugin );
|
|
196 |
|
|
197 |
const TInt count( iPublishers.Count() );
|
|
198 |
|
|
199 |
for ( TInt i( 0 ); i < count; i++ )
|
|
200 |
{
|
|
201 |
iPublishers[i]->RefreshL( aClean );
|
|
202 |
}
|
|
203 |
|
|
204 |
iContentObserver->Commit( KImplUidDevStaPlugin );
|
|
205 |
}
|
|
206 |
|
|
207 |
// ----------------------------------------------------------------------------
|
|
208 |
// CAiDeviceStatusPluginEngine::RefreshPublishersL
|
|
209 |
//
|
|
210 |
// ----------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
TBool CAiDeviceStatusPluginEngine::RefreshPublishersL( TInt aContentId,
|
|
213 |
TBool aClean )
|
|
214 |
{
|
|
215 |
TBool success( EFalse );
|
|
216 |
|
|
217 |
iContentObserver->StartTransaction( KImplUidDevStaPlugin );
|
|
218 |
|
|
219 |
const TInt count( iPublishers.Count() );
|
|
220 |
|
|
221 |
for ( TInt i( 0 ); i < count; i++ )
|
|
222 |
{
|
|
223 |
if ( iPublishers[i]->RefreshL( aContentId, aClean ) )
|
|
224 |
{
|
|
225 |
success = ETrue;
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
if ( success )
|
|
230 |
{
|
|
231 |
iContentObserver->Commit( KImplUidDevStaPlugin );
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
iContentObserver->CancelTransaction( KImplUidDevStaPlugin );
|
|
236 |
}
|
|
237 |
|
|
238 |
return success;
|
|
239 |
}
|
|
240 |
|
|
241 |
// ----------------------------------------------------------------------------
|
|
242 |
// CAiDeviceStatusPluginEngine::SuspendPublishersL
|
|
243 |
//
|
|
244 |
// ----------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
TBool CAiDeviceStatusPluginEngine::SuspendPublishersL( TInt aContentId,
|
|
247 |
TBool aClean )
|
|
248 |
{
|
|
249 |
TBool success( EFalse );
|
|
250 |
|
|
251 |
const TInt count( iPublishers.Count() );
|
|
252 |
|
|
253 |
for ( TInt i( 0 ); i < count; i++ )
|
|
254 |
{
|
|
255 |
if ( iPublishers[i]->SuspendL( aContentId, aClean ) )
|
|
256 |
{
|
|
257 |
success = ETrue;
|
|
258 |
}
|
|
259 |
}
|
|
260 |
|
|
261 |
return success;
|
|
262 |
}
|
|
263 |
|
|
264 |
// ----------------------------------------------------------------------------
|
|
265 |
// CAiDeviceStatusPluginEngine::RefreshPriorizedPublishersL
|
|
266 |
//
|
|
267 |
// ----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
TBool CAiDeviceStatusPluginEngine::RefreshPriorizedPublishersL( TInt aContentId,
|
|
270 |
TInt aPriority )
|
|
271 |
{
|
|
272 |
iContentObserver->StartTransaction( KImplUidDevStaPlugin );
|
|
273 |
|
|
274 |
TBool success( EFalse );
|
|
275 |
|
|
276 |
const TInt count( iPublishers.Count() );
|
|
277 |
|
|
278 |
for ( TInt i( 0 ); i < count; i++ )
|
|
279 |
{
|
|
280 |
MAiDeviceStatusPublisher* publisher( iPublishers[i] );
|
|
281 |
|
|
282 |
if( publisher->RefreshContentWithPriorityL( aContentId, aPriority ) )
|
|
283 |
{
|
|
284 |
success = ETrue;
|
|
285 |
break;
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
if ( success )
|
|
290 |
{
|
|
291 |
iContentObserver->Commit( KImplUidDevStaPlugin );
|
|
292 |
}
|
|
293 |
else
|
|
294 |
{
|
|
295 |
iContentObserver->CancelTransaction( KImplUidDevStaPlugin );
|
|
296 |
}
|
|
297 |
|
|
298 |
return success;
|
|
299 |
}
|
|
300 |
|
|
301 |
// End of file
|