114
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Device status plugin interface.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <ecom/ecom.h>
|
|
20 |
#include <ecom/implementationproxy.h>
|
|
21 |
#include <coemain.h>
|
|
22 |
#include <data_caging_path_literals.hrh>
|
|
23 |
#include <bautils.h>
|
|
24 |
#include <aiutility.h>
|
|
25 |
#include <featmgr.h>
|
|
26 |
#include <aidevicestatuscontentmodel.h>
|
|
27 |
|
|
28 |
// User includes
|
|
29 |
#include "aidevicestatusplugin.h"
|
|
30 |
#include "aidevicestatuspluginengine.h"
|
|
31 |
#include "aipublishprioritizer.h"
|
|
32 |
#include "aimulticontentobserver.h"
|
|
33 |
#include "aipluginsettings.h"
|
|
34 |
#include "ainetworkinfolistener.h"
|
|
35 |
|
|
36 |
// Constants
|
|
37 |
_LIT( KResourceDrive, "Z:" );
|
|
38 |
_LIT( KResourceFile, "aidevstaplgres.rsc" );
|
|
39 |
|
|
40 |
#define KResourcePath KDC_RESOURCE_FILES_DIR
|
|
41 |
|
|
42 |
// ECOM implementation table
|
|
43 |
const TImplementationProxy KImplementationTable[] =
|
|
44 |
{
|
|
45 |
IMPLEMENTATION_PROXY_ENTRY(KImplUidDevStaPlugin, CAiDeviceStatusPlugin::NewL)
|
|
46 |
};
|
|
47 |
|
|
48 |
|
|
49 |
// ======== MEMBER FUNCTIONS ========
|
|
50 |
// ----------------------------------------------------------------------------
|
|
51 |
// CAiDeviceStatusPlugin::CAiDeviceStatusPlugin
|
|
52 |
//
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CAiDeviceStatusPlugin::CAiDeviceStatusPlugin()
|
|
56 |
: iResourceOffset( KErrNotFound ),
|
|
57 |
iRequirePublish( EFalse )
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
// CAiDeviceStatusPlugin::ConstructL
|
|
63 |
//
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CAiDeviceStatusPlugin::ConstructL()
|
|
67 |
{
|
|
68 |
FeatureManager::InitializeLibL();
|
|
69 |
|
|
70 |
// Create master instance to prevent deletion on Stop()
|
|
71 |
iListener = CAiNetworkInfoListener::InstanceL();
|
|
72 |
|
|
73 |
//Create content here since this is needed in optimization phase.
|
|
74 |
iContent = AiUtility::CreateContentItemArrayIteratorL( KAiDeviceStatusContent );
|
|
75 |
iResources = AiUtility::CreateContentItemArrayIteratorL( KAiDeviceStatusResources );
|
|
76 |
|
|
77 |
iContentObservers = CAiMultiContentObserver::NewL();
|
|
78 |
|
|
79 |
iPrioritizer = CAiPublishPrioritizer::NewL( *iContentObservers, *this );
|
|
80 |
}
|
|
81 |
|
|
82 |
// ----------------------------------------------------------------------------
|
|
83 |
// CAiDeviceStatusPlugin::NewL
|
|
84 |
//
|
|
85 |
// ----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CAiDeviceStatusPlugin* CAiDeviceStatusPlugin::NewL()
|
|
88 |
{
|
|
89 |
CAiDeviceStatusPlugin* self = CAiDeviceStatusPlugin::NewLC();
|
|
90 |
CleanupStack::Pop( self );
|
|
91 |
return self;
|
|
92 |
}
|
|
93 |
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
// CAiDeviceStatusPlugin::NewLC
|
|
96 |
//
|
|
97 |
// ----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
CAiDeviceStatusPlugin* CAiDeviceStatusPlugin::NewLC()
|
|
100 |
{
|
|
101 |
CAiDeviceStatusPlugin* self = new( ELeave ) CAiDeviceStatusPlugin;
|
|
102 |
CleanupStack::PushL( self );
|
|
103 |
self->ConstructL();
|
|
104 |
return self;
|
|
105 |
}
|
|
106 |
|
|
107 |
// ----------------------------------------------------------------------------
|
|
108 |
// CAiDeviceStatusPlugin::~CAiDeviceStatusPlugin
|
|
109 |
//
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
CAiDeviceStatusPlugin::~CAiDeviceStatusPlugin()
|
|
113 |
{
|
|
114 |
delete iPrioritizer;
|
|
115 |
|
|
116 |
FreeResources();
|
|
117 |
|
|
118 |
delete iContentObservers;
|
|
119 |
|
|
120 |
Release( iResources );
|
|
121 |
Release( iContent );
|
|
122 |
|
|
123 |
FeatureManager::UnInitializeLib();
|
|
124 |
|
|
125 |
if( iListener )
|
|
126 |
{
|
|
127 |
iListener->Release();
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
// ----------------------------------------------------------------------------
|
|
132 |
// CAiDeviceStatusPlugin::AllocateResourcesL
|
|
133 |
//
|
|
134 |
// ----------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
void CAiDeviceStatusPlugin::AllocateResourcesL()
|
|
137 |
{
|
|
138 |
//create engine
|
|
139 |
if( !iEngine )
|
|
140 |
{
|
|
141 |
iEngine = CAiDeviceStatusPluginEngine::NewL(
|
|
142 |
*iContentObservers, *this, *iPrioritizer );
|
|
143 |
}
|
|
144 |
|
|
145 |
if( iResourceOffset < 0 )
|
|
146 |
{
|
|
147 |
CCoeEnv* coe( CCoeEnv::Static() );
|
|
148 |
|
|
149 |
if ( coe )
|
|
150 |
{
|
|
151 |
//Add resource file to cone
|
|
152 |
TFullName resourceFile( KResourceDrive );
|
|
153 |
resourceFile.Append( KResourcePath );
|
|
154 |
resourceFile.Append( KResourceFile );
|
|
155 |
BaflUtils::NearestLanguageFile( coe->FsSession(), resourceFile );
|
|
156 |
iResourceOffset = coe->AddResourceFileL( resourceFile );
|
|
157 |
}
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
// ----------------------------------------------------------------------------
|
|
162 |
// CAiDeviceStatusPlugin::FreeResources
|
|
163 |
//
|
|
164 |
// ----------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CAiDeviceStatusPlugin::FreeResources()
|
|
167 |
{
|
|
168 |
iRequirePublish = EFalse;
|
|
169 |
|
|
170 |
if( iResourceOffset >= 0 )
|
|
171 |
{
|
|
172 |
CCoeEnv* coe = CCoeEnv::Static();
|
|
173 |
//If device status plugin is created when CCoeEnv is available and
|
|
174 |
//destroyed when it is not anymore available, cone will inform about
|
|
175 |
//resource leak.
|
|
176 |
if ( coe )
|
|
177 |
{
|
|
178 |
coe->DeleteResourceFile( iResourceOffset );
|
|
179 |
iResourceOffset = KErrNotFound;
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
delete iEngine;
|
|
184 |
iEngine = NULL;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ----------------------------------------------------------------------------
|
|
188 |
// CAiDeviceStatusPlugin::Start
|
|
189 |
//
|
|
190 |
// ----------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
void CAiDeviceStatusPlugin::Start( TStartReason /*aReason*/ )
|
|
193 |
{
|
|
194 |
iRequirePublish = ETrue;
|
|
195 |
|
|
196 |
if ( iContentObservers )
|
|
197 |
{
|
|
198 |
iContentObservers->ClearBlackList();
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
// ----------------------------------------------------------------------------
|
|
203 |
// CAiDeviceStatusPlugin::Stop
|
|
204 |
//
|
|
205 |
// ----------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CAiDeviceStatusPlugin::Stop( TStopReason /*aReason*/ )
|
|
208 |
{
|
|
209 |
iRequirePublish = EFalse;
|
|
210 |
}
|
|
211 |
|
|
212 |
// ----------------------------------------------------------------------------
|
|
213 |
// CAiDeviceStatusPlugin::Resume
|
|
214 |
//
|
|
215 |
// ----------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void CAiDeviceStatusPlugin::Resume( TResumeReason aReason )
|
|
218 |
{
|
|
219 |
if ( aReason == EForeground )
|
|
220 |
{
|
|
221 |
if ( iRequirePublish )
|
|
222 |
{
|
|
223 |
TRAP_IGNORE( DoResumeL() );
|
|
224 |
iRequirePublish = EFalse;
|
|
225 |
}
|
|
226 |
else
|
|
227 |
{
|
|
228 |
TRAP_IGNORE(
|
|
229 |
iEngine->RefreshActivePublishersL( EFalse ) );
|
|
230 |
}
|
|
231 |
}
|
|
232 |
}
|
|
233 |
|
|
234 |
// ----------------------------------------------------------------------------
|
|
235 |
// CAiDeviceStatusPlugin::Suspend
|
|
236 |
//
|
|
237 |
// ----------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
void CAiDeviceStatusPlugin::Suspend( TSuspendReason /*aReason*/ )
|
|
240 |
{
|
|
241 |
}
|
|
242 |
|
|
243 |
// ----------------------------------------------------------------------------
|
|
244 |
// CAiDeviceStatusPlugin::SubscribeL
|
|
245 |
//
|
|
246 |
// ----------------------------------------------------------------------------
|
|
247 |
//
|
|
248 |
void CAiDeviceStatusPlugin::SubscribeL( MAiContentObserver& aObserver )
|
|
249 |
{
|
|
250 |
iContentObservers->AddObserverL( aObserver );
|
|
251 |
}
|
|
252 |
|
|
253 |
// ----------------------------------------------------------------------------
|
|
254 |
// CAiDeviceStatusPlugin::ConfigureL
|
|
255 |
//
|
|
256 |
// ----------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
void CAiDeviceStatusPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
|
|
259 |
{
|
|
260 |
aSettings.ResetAndDestroy();
|
|
261 |
|
|
262 |
AllocateResourcesL();
|
|
263 |
}
|
|
264 |
|
|
265 |
// ----------------------------------------------------------------------------
|
|
266 |
// CAiDeviceStatusPlugin::GetProperty
|
|
267 |
//
|
|
268 |
// ----------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
TAny* CAiDeviceStatusPlugin::GetProperty( TProperty aProperty )
|
|
271 |
{
|
|
272 |
if ( aProperty == EPublisherContent )
|
|
273 |
{
|
|
274 |
return static_cast< MAiContentItemIterator* >( iContent );
|
|
275 |
}
|
|
276 |
else if ( aProperty == EPublisherResources )
|
|
277 |
{
|
|
278 |
return static_cast< MAiContentItemIterator* >( iResources );
|
|
279 |
}
|
|
280 |
else if ( aProperty == EContentRequest )
|
|
281 |
{
|
|
282 |
return static_cast< MAiContentRequest* >( this );
|
|
283 |
}
|
|
284 |
|
|
285 |
return NULL;
|
|
286 |
}
|
|
287 |
|
|
288 |
// ----------------------------------------------------------------------------
|
|
289 |
// CAiDeviceStatusPlugin::DoResumeL
|
|
290 |
//
|
|
291 |
// ----------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
void CAiDeviceStatusPlugin::DoResumeL()
|
|
294 |
{
|
|
295 |
iEngine->ResumePublishersL();
|
|
296 |
iEngine->RefreshPublishersL( EFalse );
|
|
297 |
}
|
|
298 |
|
|
299 |
// ----------------------------------------------------------------------------
|
|
300 |
// CAiDeviceStatusPlugin::RefreshContent
|
|
301 |
//
|
|
302 |
// ----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
TBool CAiDeviceStatusPlugin::RefreshContent( TInt aContentId )
|
|
305 |
{
|
|
306 |
TBool result( EFalse );
|
|
307 |
|
|
308 |
TRAP_IGNORE( result = iEngine->RefreshPublishersL( aContentId, EFalse ) );
|
|
309 |
|
|
310 |
return result;
|
|
311 |
}
|
|
312 |
|
|
313 |
// ----------------------------------------------------------------------------
|
|
314 |
// CAiDeviceStatusPlugin::SuspendContent
|
|
315 |
//
|
|
316 |
// ----------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
TBool CAiDeviceStatusPlugin::SuspendContent( TInt aContentId )
|
|
319 |
{
|
|
320 |
TBool result( EFalse );
|
|
321 |
|
|
322 |
TRAP_IGNORE( result = iEngine->SuspendPublishersL( aContentId, EFalse ) );
|
|
323 |
|
|
324 |
return result;
|
|
325 |
}
|
|
326 |
|
|
327 |
// ======== GLOBAL FUNCTIONS ========
|
|
328 |
// ----------------------------------------------------------------------------
|
|
329 |
// ImplementationGroupProxy
|
|
330 |
//
|
|
331 |
// ----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
|
|
334 |
TInt& aTableCount )
|
|
335 |
{
|
|
336 |
aTableCount = sizeof(KImplementationTable) / sizeof( TImplementationProxy );
|
|
337 |
|
|
338 |
return KImplementationTable;
|
|
339 |
}
|
|
340 |
|
|
341 |
// End of file
|