author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:55:16 +0300 | |
branch | RCL_3 |
changeset 118 | 8baec10861af |
parent 114 | a5a39a295112 |
child 130 | 67f2ed48ad91 |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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: SAPI data plug-in publisher |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <ecom/ecom.h> |
|
20 |
#include <ecom/implementationproxy.h> |
|
21 |
#include <PUAcodes.hrh> |
|
22 |
#include <badesca.h> |
|
23 |
#include <fbs.h> |
|
24 |
#include <gulicon.h> |
|
25 |
#include <AknsSkinInstance.h> |
|
26 |
#include <AknsUtils.h> |
|
27 |
#include <AknsConstants.h> |
|
28 |
#include <e32property.h> |
|
29 |
||
30 |
// User includes |
|
31 |
#include <hspublisherinfo.h> |
|
32 |
#include <aicontentobserver.h> |
|
33 |
#include <aiutility.h> |
|
34 |
#include <aipspropertyobserver.h> |
|
35 |
#include <aipluginsettings.h> |
|
36 |
#include <activeidle2domainpskeys.h> |
|
37 |
#include <debug.h> |
|
38 |
||
39 |
#include "sapidatapluginconst.h" |
|
40 |
#include "sapidatapluginuids.hrh" |
|
41 |
#include "sapidataplugin.h" |
|
42 |
#include "sapidata.h" |
|
43 |
||
44 |
// Constants |
|
45 |
const TImplementationProxy KImplementationTable[] = |
|
46 |
{ |
|
47 |
IMPLEMENTATION_PROXY_ENTRY( KImplUidDataPlugin, CSapiDataPlugin::NewL ) |
|
48 |
}; |
|
49 |
||
50 |
// ======== MEMBER FUNCTIONS ======== |
|
51 |
// --------------------------------------------------------------------------- |
|
52 |
// Constructs and returns an application object. |
|
53 |
// --------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount ) |
|
56 |
{ |
|
57 |
aTableCount = sizeof( KImplementationTable ) / |
|
58 |
sizeof( TImplementationProxy ); |
|
59 |
return KImplementationTable; |
|
60 |
} |
|
61 |
||
62 |
// ======== MEMBER FUNCTIONS ======== |
|
63 |
||
64 |
// --------------------------------------------------------------------------- |
|
65 |
// Symbian 2nd phase constructor can leave |
|
66 |
// --------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
CSapiDataPlugin* CSapiDataPlugin::NewL() |
|
69 |
{ |
|
70 |
CSapiDataPlugin* self = new (ELeave) CSapiDataPlugin; |
|
71 |
CleanupStack::PushL( self ); |
|
72 |
self->ConstructL(); |
|
73 |
CleanupStack::Pop( self ); |
|
74 |
return self; |
|
75 |
} |
|
76 |
||
77 |
// --------------------------------------------------------------------------- |
|
78 |
// Default constructor |
|
79 |
// --------------------------------------------------------------------------- |
|
80 |
// |
|
81 |
CSapiDataPlugin::CSapiDataPlugin() |
|
82 |
: iNetworkStatus( EUnknown ), iPluginState( EStopped ) |
|
83 |
{ |
|
84 |
} |
|
85 |
||
86 |
// --------------------------------------------------------------------------- |
|
87 |
// Symbian 2nd phase constructor can leave |
|
88 |
// --------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
void CSapiDataPlugin::ConstructL() |
|
91 |
{ |
|
92 |
User::LeaveIfError( iRfs.Connect() ); |
|
93 |
||
94 |
iData = CSapiData::NewL( this ); |
|
95 |
} |
|
96 |
||
97 |
// --------------------------------------------------------------------------- |
|
98 |
// Destructor |
|
99 |
// Deletes all data created to heap |
|
100 |
// --------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
CSapiDataPlugin::~CSapiDataPlugin() |
|
103 |
{ |
|
104 |
// deactivate the publishers |
|
105 |
delete iData; |
|
106 |
iObservers.Close(); |
|
107 |
Release( iContent ); |
|
108 |
iDataArray.ResetAndDestroy(); |
|
109 |
||
110 |
if ( iContentModel ) |
|
111 |
{ |
|
112 |
for ( TInt i = iDataCount - 1; i >= 0 ; i-- ) |
|
113 |
{ |
|
114 |
User::Free((TAny*)iContentModel[i].cid); |
|
115 |
} |
|
116 |
||
117 |
delete [] iContentModel; |
|
118 |
} |
|
119 |
||
120 |
iIconArray.Reset(); |
|
121 |
iRfs.Close(); |
|
122 |
} |
|
123 |
||
124 |
// --------------------------------------------------------------------------- |
|
125 |
// Publishes widget's texts and images |
|
126 |
// --------------------------------------------------------------------------- |
|
127 |
// |
|
128 |
void CSapiDataPlugin::PublishL() |
|
129 |
{ |
|
130 |
TInt observers( iObservers.Count() ); |
|
131 |
TInt transactionId = reinterpret_cast<TInt>( this ); |
|
132 |
||
133 |
for ( TInt i = 0; i < observers; i++ ) |
|
134 |
{ |
|
135 |
MAiContentObserver* observer = iObservers[i]; |
|
136 |
||
137 |
if ( observer->StartTransaction( transactionId ) == KErrNone ) |
|
138 |
{ |
|
139 |
// Publish all the data |
|
140 |
iData->PublishL(observer, KAll ); |
|
141 |
observer->Commit( transactionId ); |
|
142 |
} |
|
143 |
||
144 |
// Release memory of the published text |
|
145 |
iDataArray.ResetAndDestroy(); |
|
146 |
// Release memory of the published icons |
|
147 |
iIconArray.Reset(); |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
// --------------------------------------------------------------------------- |
|
152 |
// Publish a specific text to the widget |
|
153 |
// --------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
void CSapiDataPlugin::PublishTextL(MAiContentObserver* aObserver, |
|
156 |
TInt& aContentId, TDesC& aContentValue) |
|
157 |
{ |
|
158 |
if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
159 |
{ |
|
160 |
if( aContentValue.Length() > 0 ) |
|
161 |
{ |
|
162 |
HBufC* contentText = HBufC::NewLC(aContentValue.Size()); |
|
163 |
TPtr cDes = contentText->Des(); |
|
164 |
cDes.Copy(aContentValue); |
|
165 |
aObserver->Publish( *this, aContentId, cDes, aContentId ); |
|
166 |
iDataArray.AppendL( contentText ); |
|
167 |
CleanupStack::Pop( contentText ); |
|
168 |
} |
|
169 |
else |
|
170 |
{ |
|
171 |
aObserver->Clean( *this, aContentId, aContentId ); |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
||
176 |
// --------------------------------------------------------------------------- |
|
177 |
// Publish a specific image to the widget |
|
178 |
// --------------------------------------------------------------------------- |
|
179 |
// |
|
180 |
void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, |
|
181 |
TInt aContentId, TDesC& aPath ) |
|
182 |
{ |
|
183 |
TInt err = KErrNone; |
|
184 |
TAknsItemID iconId; |
|
185 |
iconId.iMajor=0; |
|
186 |
iconId.iMinor=0; |
|
187 |
TInt bitmapId(0); |
|
188 |
TInt maskId(0); |
|
189 |
TFileName fileName; |
|
190 |
CGulIcon* icon = NULL; |
|
191 |
CFbsBitmap* bitmap = NULL; |
|
192 |
CFbsBitmap* mask = NULL; |
|
193 |
||
194 |
if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
195 |
{ |
|
196 |
TBool inSkin = iData->ResolveSkinIdAndMifId( aPath, iconId, bitmapId, maskId, fileName ); |
|
197 |
if ( inSkin ) |
|
198 |
{ |
|
199 |
// Load from skin |
|
200 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
201 |
if ( iconId.iMajor != 0 && iconId.iMajor!=0 ) |
|
202 |
{ |
|
203 |
// Create icon with fall back |
|
204 |
TRAP_IGNORE(AknsUtils::CreateIconL( |
|
205 |
skin, |
|
206 |
iconId, |
|
207 |
bitmap, |
|
208 |
mask, |
|
209 |
fileName, /* backup filename */ |
|
210 |
bitmapId, /* backup bit map id */ |
|
211 |
maskId)); /* backup mask id */ |
|
212 |
} |
|
213 |
else if( bitmapId !=0 ) |
|
214 |
{ |
|
215 |
if ( maskId!=0 ) |
|
216 |
{ |
|
217 |
// Create icon from Mif filename , bitmap id and mask id |
|
218 |
TRAP_IGNORE(icon = AknsUtils::CreateGulIconL( |
|
219 |
skin, |
|
220 |
iconId, |
|
221 |
fileName, |
|
222 |
bitmapId, |
|
223 |
maskId) ); |
|
224 |
} |
|
225 |
else |
|
226 |
{ |
|
227 |
TRAP_IGNORE(AknsUtils::CreateIconL( |
|
228 |
skin, |
|
229 |
iconId, |
|
230 |
bitmap, |
|
231 |
fileName, /* backup filename */ |
|
232 |
bitmapId)); /* backup bit map id */ |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
if ( icon == NULL && bitmap != NULL ) |
|
237 |
{ |
|
238 |
icon = CGulIcon::NewL( bitmap, mask ); |
|
239 |
} |
|
240 |
||
241 |
if ( icon != NULL ) // Syntax correct but icon not found |
|
242 |
{ |
|
243 |
aObserver->PublishPtr( *this, aContentId, icon , aContentId ); |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
244 |
CleanupStack::PushL( icon ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
245 |
iIconArray.AppendL( icon ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
246 |
CleanupStack::Pop( icon ); |
114 | 247 |
} |
248 |
else |
|
249 |
{ |
|
250 |
err = KErrNotFound; |
|
251 |
aObserver->Clean( *this, aContentId, aContentId ); |
|
252 |
} |
|
253 |
} |
|
254 |
else // Interpret as File path |
|
255 |
{ |
|
256 |
RFile iconFile; |
|
257 |
||
258 |
err = iconFile.Open( iRfs, aPath, EFileShareReadersOnly | EFileRead ); |
|
259 |
||
260 |
if( err == KErrNone ) |
|
261 |
{ |
|
262 |
aObserver->Publish( *this, aContentId, iconFile, aContentId ); |
|
263 |
} |
|
264 |
else |
|
265 |
{ |
|
266 |
aObserver->Clean( *this, aContentId, aContentId ); |
|
267 |
} |
|
268 |
||
269 |
iconFile.Close(); |
|
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 |
||
274 |
// --------------------------------------------------------------------------- |
|
275 |
// Publish a image to the widget |
|
276 |
// --------------------------------------------------------------------------- |
|
277 |
// |
|
278 |
void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, |
|
279 |
TInt& aContentId, TInt aHandle, TInt aMaskHandle ) |
|
280 |
{ |
|
281 |
if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
282 |
{ |
|
283 |
if( aHandle != KErrBadHandle ) |
|
284 |
{ |
|
285 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
286 |
if( KErrNone == bitmap->Duplicate( aHandle) ) |
|
287 |
{ |
|
288 |
// Take the ownership |
|
289 |
CGulIcon* icon = CGulIcon::NewL(bitmap); |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
290 |
CleanupStack::PushL( icon ); |
114 | 291 |
if( aMaskHandle != KErrBadHandle ) |
292 |
{ |
|
293 |
CFbsBitmap* mask = new (ELeave) CFbsBitmap(); |
|
294 |
if (KErrNone == mask->Duplicate( aMaskHandle) ) |
|
295 |
{ |
|
296 |
icon->SetMask( mask ); |
|
297 |
} |
|
298 |
} |
|
299 |
aObserver->PublishPtr( *this, aContentId, icon , aContentId ); |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
300 |
iIconArray.AppendL( icon ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
301 |
CleanupStack::Pop( icon ); |
114 | 302 |
} |
303 |
else |
|
304 |
{ |
|
305 |
delete bitmap; |
|
306 |
bitmap = NULL; |
|
307 |
aObserver->Clean( *this, aContentId, aContentId ); |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
} |
|
312 |
||
313 |
// --------------------------------------------------------------------------- |
|
314 |
// Publish a data to the widget |
|
315 |
// --------------------------------------------------------------------------- |
|
316 |
// |
|
317 |
void CSapiDataPlugin::PublishData( MAiContentObserver* aObserver, |
|
318 |
TInt& aContentId, const TDesC8& aData ) |
|
319 |
{ |
|
320 |
if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
|
321 |
{ |
|
322 |
aObserver->Publish( *this, aContentId, aData, aContentId ); |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
// --------------------------------------------------------------------------- |
|
327 |
// Gets the id of a content |
|
328 |
// --------------------------------------------------------------------------- |
|
329 |
// |
|
330 |
TInt CSapiDataPlugin::GetIdL( TDesC& aObjectId) |
|
331 |
{ |
|
332 |
TInt id = KErrNotFound; |
|
333 |
for( TInt i = 0;i< iDataCount; i++ ) |
|
334 |
{ |
|
335 |
if( aObjectId == ContentCid(iContentModel[i] ) ) |
|
336 |
{ |
|
337 |
id = iContentModel[i].id; |
|
338 |
break; |
|
339 |
} |
|
340 |
} |
|
341 |
return id; |
|
342 |
} |
|
343 |
||
344 |
// --------------------------------------------------------------------------- |
|
345 |
// Gets type of a content |
|
346 |
// --------------------------------------------------------------------------- |
|
347 |
// |
|
348 |
const TDesC& CSapiDataPlugin::GetTypeL(TDesC& aObjectId ) |
|
349 |
{ |
|
350 |
for( TInt i = 0;i< iDataCount; i++ ) |
|
351 |
{ |
|
352 |
if( aObjectId == ContentCid(iContentModel[i]) ) |
|
353 |
{ |
|
354 |
if( iContentModel[i].type == KAiContentTypeText) |
|
355 |
{ |
|
356 |
return KText(); |
|
357 |
} |
|
358 |
else if( iContentModel[i].type == KAiContentTypeBitmap) |
|
359 |
{ |
|
360 |
return KImage(); |
|
361 |
} |
|
362 |
else if ( iContentModel[i].type == KAiContentTypeData ) |
|
363 |
{ |
|
364 |
return KData(); |
|
365 |
} |
|
366 |
} |
|
367 |
} |
|
368 |
||
369 |
return KNullDesC(); |
|
370 |
} |
|
371 |
||
372 |
// --------------------------------------------------------------------------- |
|
373 |
//Refresh a specific image or text in the widget |
|
374 |
// --------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
void CSapiDataPlugin::RefreshL( TDesC& aContentType, |
|
377 |
TDesC& aOperation, |
|
378 |
CLiwDefaultMap* aDataMap ) |
|
379 |
{ |
|
380 |
__PRINTS("*** CSapiDataPlugin::RefreshL ***"); |
|
381 |
||
382 |
__PRINT( __DBG_FORMAT( "* Publisher name: %S, uid: 0x%x, content type: %S, operation: %S" ), |
|
383 |
&PublisherInfo().Name(), PublisherInfo().Uid().iUid, &aContentType, &aOperation ); |
|
384 |
||
385 |
const TInt observerCount( iObservers.Count() ); |
|
386 |
const TInt transactionId = reinterpret_cast<TInt>( this ); |
|
387 |
||
388 |
for( TInt obsIndex = 0; obsIndex < observerCount; obsIndex++ ) |
|
389 |
{ |
|
390 |
MAiContentObserver* observer = iObservers[obsIndex]; |
|
391 |
||
392 |
if( observer->StartTransaction( transactionId ) == KErrNone ) |
|
393 |
{ |
|
394 |
if ( aOperation != KOperationDelete ) |
|
395 |
{ |
|
396 |
if( aDataMap ) |
|
397 |
{ |
|
398 |
iData->PublishDataL( observer, aDataMap ); |
|
399 |
} |
|
400 |
else |
|
401 |
{ |
|
402 |
iData->PublishL( observer, aContentType ); |
|
403 |
} |
|
404 |
} |
|
405 |
else |
|
406 |
{ |
|
407 |
iData->RemoveL( observer, aContentType ); |
|
408 |
} |
|
409 |
||
410 |
observer->Commit( transactionId ); |
|
411 |
} |
|
412 |
||
413 |
// Relese memory of the published text |
|
414 |
iDataArray.ResetAndDestroy(); |
|
415 |
iIconArray.Reset(); |
|
416 |
} |
|
417 |
||
418 |
__PRINTS("*** CSapiDataPlugin::RefreshL - done ***"); |
|
419 |
} |
|
420 |
||
421 |
// --------------------------------------------------------------------------- |
|
422 |
// Cleans a data from the widget |
|
423 |
// --------------------------------------------------------------------------- |
|
424 |
// |
|
425 |
void CSapiDataPlugin::Clean(MAiContentObserver* aObserver, |
|
426 |
TInt& aContentId ) |
|
427 |
{ |
|
428 |
if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
|
429 |
{ |
|
430 |
aObserver->Clean( *this, aContentId, aContentId ); |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
// ---------------------------------------------------------------------------- |
|
435 |
// CSapiDataPlugin::Start |
|
436 |
// |
|
437 |
// ---------------------------------------------------------------------------- |
|
438 |
// |
|
439 |
void CSapiDataPlugin::Start( TStartReason aReason ) |
|
440 |
{ |
|
441 |
iPluginState = EStarted; |
|
442 |
||
443 |
TRAP_IGNORE( StartL( aReason ) ); |
|
444 |
} |
|
445 |
||
446 |
// ---------------------------------------------------------------------------- |
|
447 |
// CSapiDataPlugin::StartL |
|
448 |
// |
|
449 |
// ---------------------------------------------------------------------------- |
|
450 |
// |
|
451 |
void CSapiDataPlugin::StartL( TStartReason aReason ) |
|
452 |
{ |
|
453 |
// Activate the publisher |
|
454 |
iData->ChangePublisherStatusL( KActive ); |
|
455 |
||
456 |
if ( aReason == ESystemStartup ) |
|
457 |
{ |
|
458 |
PublishL(); |
|
459 |
iData->SetStartupReasonL( KSystemStartup ); |
|
460 |
} |
|
461 |
else if ( aReason == EPageStartup ) |
|
462 |
{ |
|
463 |
iData->SetStartupReasonL( KPageStartup ); |
|
464 |
} |
|
465 |
else if ( aReason == EPluginStartup ) |
|
466 |
{ |
|
467 |
PublishL(); |
|
468 |
iData->SetStartupReasonL( KPluginStartup ); |
|
469 |
} |
|
470 |
||
471 |
if ( !iPubObsRegistered ) |
|
472 |
{ |
|
473 |
// Listen for publisher registration to resend the events |
|
474 |
iData->RegisterPublisherObserverL() ; |
|
475 |
||
476 |
// Execute the active trigger |
|
477 |
iData->TriggerActiveL(); |
|
478 |
||
479 |
iPubObsRegistered = ETrue; |
|
480 |
} |
|
481 |
} |
|
482 |
||
483 |
// ---------------------------------------------------------------------------- |
|
484 |
// CSapiDataPlugin::Stop |
|
485 |
// |
|
486 |
// ---------------------------------------------------------------------------- |
|
487 |
// |
|
488 |
void CSapiDataPlugin::Stop( TStopReason aReason ) |
|
489 |
{ |
|
490 |
TRAP_IGNORE( StopL( aReason ) ); |
|
491 |
} |
|
492 |
||
493 |
// ---------------------------------------------------------------------------- |
|
494 |
// CSapiDataPlugin::StopL |
|
495 |
// |
|
496 |
// ---------------------------------------------------------------------------- |
|
497 |
// |
|
498 |
void CSapiDataPlugin::StopL( TStopReason aReason ) |
|
499 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
500 |
if ( iPluginState != EStopped ) |
114 | 501 |
{ |
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
502 |
if ( aReason == ESystemShutdown ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
503 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
504 |
iData->ChangePublisherStatusL( KSystemShutdown ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
505 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
506 |
else if ( aReason == EPageShutdown ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
507 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
508 |
iData->ChangePublisherStatusL( KPageShutdown ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
509 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
510 |
else if ( aReason == EPluginShutdown ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
511 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
512 |
iData->ChangePublisherStatusL( KPluginShutdown ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
513 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
514 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
515 |
if ( iData ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
516 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
517 |
iData->ChangePublisherStatusL( KDeActive ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
518 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
519 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
520 |
iPluginState = EStopped; |
114 | 521 |
} |
522 |
} |
|
523 |
||
524 |
// ---------------------------------------------------------------------------- |
|
525 |
// CSapiDataPlugin::Resume |
|
526 |
// |
|
527 |
// ---------------------------------------------------------------------------- |
|
528 |
// |
|
529 |
void CSapiDataPlugin::Resume( TResumeReason aReason ) |
|
530 |
{ |
|
531 |
if ( aReason == EForeground && iPluginState != EStopped ) |
|
532 |
{ |
|
533 |
iPluginState = EResume; |
|
534 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KResume )); |
|
535 |
} |
|
536 |
} |
|
537 |
||
538 |
// ---------------------------------------------------------------------------- |
|
539 |
// CSapiDataPlugin::Suspend |
|
540 |
// |
|
541 |
// ---------------------------------------------------------------------------- |
|
542 |
// |
|
543 |
void CSapiDataPlugin::Suspend( TSuspendReason aReason ) |
|
544 |
{ |
|
545 |
if ( aReason == EBackground && iPluginState != EStopped ) |
|
546 |
{ |
|
547 |
iPluginState = ESuspend; |
|
548 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KSuspend )); |
|
549 |
} |
|
550 |
} |
|
551 |
||
552 |
// ---------------------------------------------------------------------------- |
|
553 |
// CSapiDataPlugin::SetOnline |
|
554 |
// |
|
555 |
// ---------------------------------------------------------------------------- |
|
556 |
// |
|
557 |
void CSapiDataPlugin::SetOnline() |
|
558 |
{ |
|
559 |
if ( iNetworkStatus != EOnline && iPluginState != EStopped ) |
|
560 |
{ |
|
561 |
iNetworkStatus = EOnline; |
|
562 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KOnLine )); |
|
563 |
} |
|
564 |
} |
|
565 |
||
566 |
// ---------------------------------------------------------------------------- |
|
567 |
// CSapiDataPlugin::SetOffline |
|
568 |
// |
|
569 |
// ---------------------------------------------------------------------------- |
|
570 |
// |
|
571 |
void CSapiDataPlugin::SetOffline() |
|
572 |
{ |
|
573 |
if ( iNetworkStatus != EOffline && iPluginState != EStopped ) |
|
574 |
{ |
|
575 |
iNetworkStatus = EOffline; |
|
576 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KOffLine )); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
// ---------------------------------------------------------------------------- |
|
581 |
// CSapiDataPlugin::SubscribeL |
|
582 |
// |
|
583 |
// ---------------------------------------------------------------------------- |
|
584 |
// |
|
585 |
void CSapiDataPlugin::SubscribeL( MAiContentObserver& aObserver ) |
|
586 |
{ |
|
587 |
iObservers.AppendL( &aObserver ); |
|
588 |
} |
|
589 |
||
590 |
// ---------------------------------------------------------------------------- |
|
591 |
// CSapiDataPlugin::ConfigureL |
|
592 |
// |
|
593 |
// ---------------------------------------------------------------------------- |
|
594 |
// |
|
595 |
void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
596 |
{ |
|
597 |
RAiSettingsItemArray contentItemsArr; |
|
598 |
CleanupClosePushL( contentItemsArr ); |
|
599 |
||
600 |
RAiSettingsItemArray configurationItemsArr; |
|
601 |
CleanupClosePushL( configurationItemsArr ); |
|
602 |
||
603 |
TInt count( aSettings.Count() ); |
|
604 |
||
605 |
for ( TInt i = 0; i < count; i++ ) |
|
606 |
{ |
|
607 |
MAiPluginSettings* setting( aSettings[i] ); |
|
608 |
||
609 |
if ( setting->AiPluginItemType() == EAiPluginContentItem ) |
|
610 |
{ |
|
611 |
contentItemsArr.Append( setting ); |
|
612 |
} |
|
613 |
else if ( setting->AiPluginItemType() == EAiPluginConfigurationItem ) |
|
614 |
{ |
|
615 |
configurationItemsArr.Append( setting ); |
|
616 |
} |
|
617 |
} |
|
618 |
||
619 |
iDataCount = contentItemsArr.Count(); |
|
620 |
||
621 |
// Create the content Model |
|
622 |
HBufC* contentId = HBufC::NewLC( |
|
623 |
KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
|
624 |
||
625 |
iContentModel = new TAiContentItem[iDataCount]; |
|
626 |
||
627 |
for ( TInt i = 0; i < iDataCount; i++ ) |
|
628 |
{ |
|
629 |
MAiPluginContentItem& contentItem( |
|
630 |
contentItemsArr[i]->AiPluginContentItem() ); |
|
631 |
||
632 |
iContentModel[i].id = i; |
|
633 |
||
634 |
const TDesC& type( contentItem.Type() ); |
|
635 |
||
636 |
if ( type == KText() || type == KNewsTicker() || |
|
637 |
type == KTextEditor() ) |
|
638 |
{ |
|
639 |
// text |
|
640 |
iContentModel[i].type = KAiContentTypeText; |
|
641 |
} |
|
642 |
else if ( type == KImage() ) |
|
643 |
{ |
|
644 |
// image |
|
645 |
iContentModel[i].type = KAiContentTypeBitmap; |
|
646 |
} |
|
647 |
else if ( type == KData() ) |
|
648 |
{ |
|
649 |
// data stream |
|
650 |
iContentModel[i].type = KAiContentTypeData; |
|
651 |
} |
|
652 |
||
653 |
contentId->Des().Copy( contentItem.Name() ); |
|
654 |
contentId->Des().Delete( 0, |
|
655 |
contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); |
|
656 |
||
657 |
TInt sizeOfContentId( contentId->Des().Size() + sizeof( wchar_t ) ); |
|
658 |
||
659 |
iContentModel[i].cid = |
|
660 |
static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); |
|
661 |
||
662 |
Mem::Copy( ( TAny* )iContentModel[i].cid, |
|
663 |
contentId->Des().PtrZ(), sizeOfContentId ); |
|
664 |
||
665 |
contentId->Des().Delete( 0, contentId->Des().Length() ); |
|
666 |
} |
|
667 |
||
668 |
CleanupStack::PopAndDestroy( contentId ); |
|
669 |
||
670 |
iContent = AiUtility::CreateContentItemArrayIteratorL( |
|
671 |
iContentModel, iDataCount ); |
|
672 |
||
673 |
iData->SetContentIdL( PublisherInfo().Namespace() ); |
|
674 |
||
675 |
// Configurations |
|
676 |
iData->ConfigureL( configurationItemsArr ); |
|
677 |
||
678 |
// Listen the publisher content update |
|
679 |
iData->RegisterContentObserverL(); |
|
680 |
||
681 |
CleanupStack::PopAndDestroy( 2, &contentItemsArr ); // configurationItemsArr |
|
682 |
} |
|
683 |
||
684 |
// ---------------------------------------------------------------------------- |
|
685 |
// CSapiDataPlugin::SetProperty |
|
686 |
// |
|
687 |
// ---------------------------------------------------------------------------- |
|
688 |
// |
|
689 |
void CSapiDataPlugin::SetProperty( TProperty aProperty, TAny* aAny ) |
|
690 |
{ |
|
691 |
if ( aProperty == ECpsCmdBuffer ) |
|
692 |
{ |
|
693 |
iData->SetCommandBuffer( aAny ); |
|
694 |
} |
|
695 |
} |
|
696 |
// ---------------------------------------------------------------------------- |
|
697 |
// CSapiDataPlugin::GetProperty |
|
698 |
// |
|
699 |
// ---------------------------------------------------------------------------- |
|
700 |
// |
|
701 |
TAny* CSapiDataPlugin::GetProperty( TProperty aProperty ) |
|
702 |
{ |
|
703 |
if ( aProperty == EPublisherContent ) |
|
704 |
{ |
|
705 |
return static_cast< MAiContentItemIterator* >( iContent ); |
|
706 |
} |
|
707 |
||
708 |
return NULL; |
|
709 |
} |
|
710 |
||
711 |
// ---------------------------------------------------------------------------- |
|
712 |
// CSapiDataPlugin::HandleEvent |
|
713 |
// |
|
714 |
// ---------------------------------------------------------------------------- |
|
715 |
// |
|
716 |
void CSapiDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
|
717 |
{ |
|
718 |
TRAP_IGNORE( iData->ExecuteActionL( aEventName , aParam ) ); |
|
719 |
} |
|
720 |
||
721 |
// ---------------------------------------------------------------------------- |
|
722 |
// CSapiDataPlugin::HasMenuItem |
|
723 |
// |
|
724 |
// ---------------------------------------------------------------------------- |
|
725 |
// |
|
726 |
TBool CSapiDataPlugin::HasMenuItem( const TDesC16& aMenuItem ) |
|
727 |
{ |
|
728 |
return iData->HasMenuItem ( aMenuItem ); |
|
729 |
} |
|
730 |
||
731 |
// ---------------------------------------------------------------------------- |
|
732 |
// CSapiDataPlugin::IsActive |
|
733 |
// |
|
734 |
// ---------------------------------------------------------------------------- |
|
735 |
// |
|
736 |
TBool CSapiDataPlugin::IsActive() const |
|
737 |
{ |
|
738 |
return iPluginState == EResume; |
|
739 |
} |
|
740 |
||
741 |
// ---------------------------------------------------------------------------- |
|
742 |
// CSapiDataPlugin::IsStopped |
|
743 |
// |
|
744 |
// ---------------------------------------------------------------------------- |
|
745 |
// |
|
746 |
TBool CSapiDataPlugin::IsStopped() const |
|
747 |
{ |
|
748 |
return iPluginState == EStopped; |
|
749 |
} |
|
750 |
||
751 |
// ---------------------------------------------------------------------------- |
|
752 |
// CSapiDataPlugin::Data |
|
753 |
// |
|
754 |
// ---------------------------------------------------------------------------- |
|
755 |
// |
|
756 |
CSapiData* CSapiDataPlugin::Data() const |
|
757 |
{ |
|
758 |
return iData; |
|
759 |
} |
|
760 |
||
761 |
// ---------------------------------------------------------------------------- |
|
762 |
// CSapiDataPlugin::NetworkStatus |
|
763 |
// |
|
764 |
// ---------------------------------------------------------------------------- |
|
765 |
// |
|
766 |
CSapiDataPlugin::TPluginNetworkStatus CSapiDataPlugin::NetworkStatus() const |
|
767 |
{ |
|
768 |
return iNetworkStatus; |
|
769 |
} |
|
770 |
||
771 |
// End of file |
|
772 |