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 );
|
|
244 |
iIconArray.Append(icon);
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
err = KErrNotFound;
|
|
249 |
aObserver->Clean( *this, aContentId, aContentId );
|
|
250 |
}
|
|
251 |
}
|
|
252 |
else // Interpret as File path
|
|
253 |
{
|
|
254 |
RFile iconFile;
|
|
255 |
|
|
256 |
err = iconFile.Open( iRfs, aPath, EFileShareReadersOnly | EFileRead );
|
|
257 |
|
|
258 |
if( err == KErrNone )
|
|
259 |
{
|
|
260 |
aObserver->Publish( *this, aContentId, iconFile, aContentId );
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
aObserver->Clean( *this, aContentId, aContentId );
|
|
265 |
}
|
|
266 |
|
|
267 |
iconFile.Close();
|
|
268 |
}
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
// Publish a image to the widget
|
|
274 |
// ---------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver,
|
|
277 |
TInt& aContentId, TInt aHandle, TInt aMaskHandle )
|
|
278 |
{
|
|
279 |
if ( aObserver->CanPublish( *this, aContentId , aContentId ) )
|
|
280 |
{
|
|
281 |
if( aHandle != KErrBadHandle )
|
|
282 |
{
|
|
283 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
|
|
284 |
if( KErrNone == bitmap->Duplicate( aHandle) )
|
|
285 |
{
|
|
286 |
// Take the ownership
|
|
287 |
CGulIcon* icon = CGulIcon::NewL(bitmap);
|
|
288 |
if( aMaskHandle != KErrBadHandle )
|
|
289 |
{
|
|
290 |
CFbsBitmap* mask = new (ELeave) CFbsBitmap();
|
|
291 |
if (KErrNone == mask->Duplicate( aMaskHandle) )
|
|
292 |
{
|
|
293 |
icon->SetMask( mask );
|
|
294 |
}
|
|
295 |
}
|
|
296 |
aObserver->PublishPtr( *this, aContentId, icon , aContentId );
|
|
297 |
iIconArray.Append(icon);
|
|
298 |
}
|
|
299 |
else
|
|
300 |
{
|
|
301 |
delete bitmap;
|
|
302 |
bitmap = NULL;
|
|
303 |
aObserver->Clean( *this, aContentId, aContentId );
|
|
304 |
}
|
|
305 |
}
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
// ---------------------------------------------------------------------------
|
|
310 |
// Publish a data to the widget
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
void CSapiDataPlugin::PublishData( MAiContentObserver* aObserver,
|
|
314 |
TInt& aContentId, const TDesC8& aData )
|
|
315 |
{
|
|
316 |
if ( aObserver->CanPublish( *this, aContentId, aContentId ) )
|
|
317 |
{
|
|
318 |
aObserver->Publish( *this, aContentId, aData, aContentId );
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
// Gets the id of a content
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
TInt CSapiDataPlugin::GetIdL( TDesC& aObjectId)
|
|
327 |
{
|
|
328 |
TInt id = KErrNotFound;
|
|
329 |
for( TInt i = 0;i< iDataCount; i++ )
|
|
330 |
{
|
|
331 |
if( aObjectId == ContentCid(iContentModel[i] ) )
|
|
332 |
{
|
|
333 |
id = iContentModel[i].id;
|
|
334 |
break;
|
|
335 |
}
|
|
336 |
}
|
|
337 |
return id;
|
|
338 |
}
|
|
339 |
|
|
340 |
// ---------------------------------------------------------------------------
|
|
341 |
// Gets type of a content
|
|
342 |
// ---------------------------------------------------------------------------
|
|
343 |
//
|
|
344 |
const TDesC& CSapiDataPlugin::GetTypeL(TDesC& aObjectId )
|
|
345 |
{
|
|
346 |
for( TInt i = 0;i< iDataCount; i++ )
|
|
347 |
{
|
|
348 |
if( aObjectId == ContentCid(iContentModel[i]) )
|
|
349 |
{
|
|
350 |
if( iContentModel[i].type == KAiContentTypeText)
|
|
351 |
{
|
|
352 |
return KText();
|
|
353 |
}
|
|
354 |
else if( iContentModel[i].type == KAiContentTypeBitmap)
|
|
355 |
{
|
|
356 |
return KImage();
|
|
357 |
}
|
|
358 |
else if ( iContentModel[i].type == KAiContentTypeData )
|
|
359 |
{
|
|
360 |
return KData();
|
|
361 |
}
|
|
362 |
}
|
|
363 |
}
|
|
364 |
|
|
365 |
return KNullDesC();
|
|
366 |
}
|
|
367 |
|
|
368 |
// ---------------------------------------------------------------------------
|
|
369 |
//Refresh a specific image or text in the widget
|
|
370 |
// ---------------------------------------------------------------------------
|
|
371 |
//
|
|
372 |
void CSapiDataPlugin::RefreshL( TDesC& aContentType,
|
|
373 |
TDesC& aOperation,
|
|
374 |
CLiwDefaultMap* aDataMap )
|
|
375 |
{
|
|
376 |
__PRINTS("*** CSapiDataPlugin::RefreshL ***");
|
|
377 |
|
|
378 |
__PRINT( __DBG_FORMAT( "* Publisher name: %S, uid: 0x%x, content type: %S, operation: %S" ),
|
|
379 |
&PublisherInfo().Name(), PublisherInfo().Uid().iUid, &aContentType, &aOperation );
|
|
380 |
|
|
381 |
const TInt observerCount( iObservers.Count() );
|
|
382 |
const TInt transactionId = reinterpret_cast<TInt>( this );
|
|
383 |
|
|
384 |
for( TInt obsIndex = 0; obsIndex < observerCount; obsIndex++ )
|
|
385 |
{
|
|
386 |
MAiContentObserver* observer = iObservers[obsIndex];
|
|
387 |
|
|
388 |
if( observer->StartTransaction( transactionId ) == KErrNone )
|
|
389 |
{
|
|
390 |
if ( aOperation != KOperationDelete )
|
|
391 |
{
|
|
392 |
if( aDataMap )
|
|
393 |
{
|
|
394 |
iData->PublishDataL( observer, aDataMap );
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
iData->PublishL( observer, aContentType );
|
|
399 |
}
|
|
400 |
}
|
|
401 |
else
|
|
402 |
{
|
|
403 |
iData->RemoveL( observer, aContentType );
|
|
404 |
}
|
|
405 |
|
|
406 |
observer->Commit( transactionId );
|
|
407 |
}
|
|
408 |
|
|
409 |
// Relese memory of the published text
|
|
410 |
iDataArray.ResetAndDestroy();
|
|
411 |
iIconArray.Reset();
|
|
412 |
}
|
|
413 |
|
|
414 |
__PRINTS("*** CSapiDataPlugin::RefreshL - done ***");
|
|
415 |
}
|
|
416 |
|
|
417 |
// ---------------------------------------------------------------------------
|
|
418 |
// Cleans a data from the widget
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
void CSapiDataPlugin::Clean(MAiContentObserver* aObserver,
|
|
422 |
TInt& aContentId )
|
|
423 |
{
|
|
424 |
if ( aObserver->CanPublish( *this, aContentId, aContentId ) )
|
|
425 |
{
|
|
426 |
aObserver->Clean( *this, aContentId, aContentId );
|
|
427 |
}
|
|
428 |
}
|
|
429 |
|
|
430 |
// ----------------------------------------------------------------------------
|
|
431 |
// CSapiDataPlugin::Start
|
|
432 |
//
|
|
433 |
// ----------------------------------------------------------------------------
|
|
434 |
//
|
|
435 |
void CSapiDataPlugin::Start( TStartReason aReason )
|
|
436 |
{
|
|
437 |
iPluginState = EStarted;
|
|
438 |
|
|
439 |
TRAP_IGNORE( StartL( aReason ) );
|
|
440 |
}
|
|
441 |
|
|
442 |
// ----------------------------------------------------------------------------
|
|
443 |
// CSapiDataPlugin::StartL
|
|
444 |
//
|
|
445 |
// ----------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
void CSapiDataPlugin::StartL( TStartReason aReason )
|
|
448 |
{
|
|
449 |
// Activate the publisher
|
|
450 |
iData->ChangePublisherStatusL( KActive );
|
|
451 |
|
|
452 |
if ( aReason == ESystemStartup )
|
|
453 |
{
|
|
454 |
PublishL();
|
|
455 |
iData->SetStartupReasonL( KSystemStartup );
|
|
456 |
}
|
|
457 |
else if ( aReason == EPageStartup )
|
|
458 |
{
|
|
459 |
iData->SetStartupReasonL( KPageStartup );
|
|
460 |
}
|
|
461 |
else if ( aReason == EPluginStartup )
|
|
462 |
{
|
|
463 |
PublishL();
|
|
464 |
iData->SetStartupReasonL( KPluginStartup );
|
|
465 |
}
|
|
466 |
|
|
467 |
if ( !iPubObsRegistered )
|
|
468 |
{
|
|
469 |
// Listen for publisher registration to resend the events
|
|
470 |
iData->RegisterPublisherObserverL() ;
|
|
471 |
|
|
472 |
// Execute the active trigger
|
|
473 |
iData->TriggerActiveL();
|
|
474 |
|
|
475 |
iPubObsRegistered = ETrue;
|
|
476 |
}
|
|
477 |
}
|
|
478 |
|
|
479 |
// ----------------------------------------------------------------------------
|
|
480 |
// CSapiDataPlugin::Stop
|
|
481 |
//
|
|
482 |
// ----------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
void CSapiDataPlugin::Stop( TStopReason aReason )
|
|
485 |
{
|
|
486 |
TRAP_IGNORE( StopL( aReason ) );
|
|
487 |
|
|
488 |
iPluginState = EStopped;
|
|
489 |
}
|
|
490 |
|
|
491 |
// ----------------------------------------------------------------------------
|
|
492 |
// CSapiDataPlugin::StopL
|
|
493 |
//
|
|
494 |
// ----------------------------------------------------------------------------
|
|
495 |
//
|
|
496 |
void CSapiDataPlugin::StopL( TStopReason aReason )
|
|
497 |
{
|
|
498 |
if ( aReason == ESystemShutdown )
|
|
499 |
{
|
|
500 |
iData->ChangePublisherStatusL( KSystemShutdown );
|
|
501 |
}
|
|
502 |
else if ( aReason == EPageShutdown )
|
|
503 |
{
|
|
504 |
iData->ChangePublisherStatusL( KPageShutdown );
|
|
505 |
}
|
|
506 |
else if ( aReason == EPluginShutdown )
|
|
507 |
{
|
|
508 |
iData->ChangePublisherStatusL( KPluginShutdown );
|
|
509 |
}
|
|
510 |
|
|
511 |
if ( iData )
|
|
512 |
{
|
|
513 |
iData->ChangePublisherStatusL( KDeActive );
|
|
514 |
}
|
|
515 |
}
|
|
516 |
|
|
517 |
// ----------------------------------------------------------------------------
|
|
518 |
// CSapiDataPlugin::Resume
|
|
519 |
//
|
|
520 |
// ----------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
void CSapiDataPlugin::Resume( TResumeReason aReason )
|
|
523 |
{
|
|
524 |
if ( aReason == EForeground && iPluginState != EStopped )
|
|
525 |
{
|
|
526 |
iPluginState = EResume;
|
|
527 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KResume ));
|
|
528 |
}
|
|
529 |
}
|
|
530 |
|
|
531 |
// ----------------------------------------------------------------------------
|
|
532 |
// CSapiDataPlugin::Suspend
|
|
533 |
//
|
|
534 |
// ----------------------------------------------------------------------------
|
|
535 |
//
|
|
536 |
void CSapiDataPlugin::Suspend( TSuspendReason aReason )
|
|
537 |
{
|
|
538 |
if ( aReason == EBackground && iPluginState != EStopped )
|
|
539 |
{
|
|
540 |
iPluginState = ESuspend;
|
|
541 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KSuspend ));
|
|
542 |
}
|
|
543 |
}
|
|
544 |
|
|
545 |
// ----------------------------------------------------------------------------
|
|
546 |
// CSapiDataPlugin::SetOnline
|
|
547 |
//
|
|
548 |
// ----------------------------------------------------------------------------
|
|
549 |
//
|
|
550 |
void CSapiDataPlugin::SetOnline()
|
|
551 |
{
|
|
552 |
if ( iNetworkStatus != EOnline && iPluginState != EStopped )
|
|
553 |
{
|
|
554 |
iNetworkStatus = EOnline;
|
|
555 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KOnLine ));
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
// ----------------------------------------------------------------------------
|
|
560 |
// CSapiDataPlugin::SetOffline
|
|
561 |
//
|
|
562 |
// ----------------------------------------------------------------------------
|
|
563 |
//
|
|
564 |
void CSapiDataPlugin::SetOffline()
|
|
565 |
{
|
|
566 |
if ( iNetworkStatus != EOffline && iPluginState != EStopped )
|
|
567 |
{
|
|
568 |
iNetworkStatus = EOffline;
|
|
569 |
TRAP_IGNORE( iData->ChangePublisherStatusL( KOffLine ));
|
|
570 |
}
|
|
571 |
}
|
|
572 |
|
|
573 |
// ----------------------------------------------------------------------------
|
|
574 |
// CSapiDataPlugin::SubscribeL
|
|
575 |
//
|
|
576 |
// ----------------------------------------------------------------------------
|
|
577 |
//
|
|
578 |
void CSapiDataPlugin::SubscribeL( MAiContentObserver& aObserver )
|
|
579 |
{
|
|
580 |
iObservers.AppendL( &aObserver );
|
|
581 |
}
|
|
582 |
|
|
583 |
// ----------------------------------------------------------------------------
|
|
584 |
// CSapiDataPlugin::ConfigureL
|
|
585 |
//
|
|
586 |
// ----------------------------------------------------------------------------
|
|
587 |
//
|
|
588 |
void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
|
|
589 |
{
|
|
590 |
RAiSettingsItemArray contentItemsArr;
|
|
591 |
CleanupClosePushL( contentItemsArr );
|
|
592 |
|
|
593 |
RAiSettingsItemArray configurationItemsArr;
|
|
594 |
CleanupClosePushL( configurationItemsArr );
|
|
595 |
|
|
596 |
TInt count( aSettings.Count() );
|
|
597 |
|
|
598 |
for ( TInt i = 0; i < count; i++ )
|
|
599 |
{
|
|
600 |
MAiPluginSettings* setting( aSettings[i] );
|
|
601 |
|
|
602 |
if ( setting->AiPluginItemType() == EAiPluginContentItem )
|
|
603 |
{
|
|
604 |
contentItemsArr.Append( setting );
|
|
605 |
}
|
|
606 |
else if ( setting->AiPluginItemType() == EAiPluginConfigurationItem )
|
|
607 |
{
|
|
608 |
configurationItemsArr.Append( setting );
|
|
609 |
}
|
|
610 |
}
|
|
611 |
|
|
612 |
iDataCount = contentItemsArr.Count();
|
|
613 |
|
|
614 |
// Create the content Model
|
|
615 |
HBufC* contentId = HBufC::NewLC(
|
|
616 |
KAiContentIdMaxLength + KAiPluginNameMaxLength );
|
|
617 |
|
|
618 |
iContentModel = new TAiContentItem[iDataCount];
|
|
619 |
|
|
620 |
for ( TInt i = 0; i < iDataCount; i++ )
|
|
621 |
{
|
|
622 |
MAiPluginContentItem& contentItem(
|
|
623 |
contentItemsArr[i]->AiPluginContentItem() );
|
|
624 |
|
|
625 |
iContentModel[i].id = i;
|
|
626 |
|
|
627 |
const TDesC& type( contentItem.Type() );
|
|
628 |
|
|
629 |
if ( type == KText() || type == KNewsTicker() ||
|
|
630 |
type == KTextEditor() )
|
|
631 |
{
|
|
632 |
// text
|
|
633 |
iContentModel[i].type = KAiContentTypeText;
|
|
634 |
}
|
|
635 |
else if ( type == KImage() )
|
|
636 |
{
|
|
637 |
// image
|
|
638 |
iContentModel[i].type = KAiContentTypeBitmap;
|
|
639 |
}
|
|
640 |
else if ( type == KData() )
|
|
641 |
{
|
|
642 |
// data stream
|
|
643 |
iContentModel[i].type = KAiContentTypeData;
|
|
644 |
}
|
|
645 |
|
|
646 |
contentId->Des().Copy( contentItem.Name() );
|
|
647 |
contentId->Des().Delete( 0,
|
|
648 |
contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 );
|
|
649 |
|
|
650 |
TInt sizeOfContentId( contentId->Des().Size() + sizeof( wchar_t ) );
|
|
651 |
|
|
652 |
iContentModel[i].cid =
|
|
653 |
static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) );
|
|
654 |
|
|
655 |
Mem::Copy( ( TAny* )iContentModel[i].cid,
|
|
656 |
contentId->Des().PtrZ(), sizeOfContentId );
|
|
657 |
|
|
658 |
contentId->Des().Delete( 0, contentId->Des().Length() );
|
|
659 |
}
|
|
660 |
|
|
661 |
CleanupStack::PopAndDestroy( contentId );
|
|
662 |
|
|
663 |
iContent = AiUtility::CreateContentItemArrayIteratorL(
|
|
664 |
iContentModel, iDataCount );
|
|
665 |
|
|
666 |
iData->SetContentIdL( PublisherInfo().Namespace() );
|
|
667 |
|
|
668 |
// Configurations
|
|
669 |
iData->ConfigureL( configurationItemsArr );
|
|
670 |
|
|
671 |
// Listen the publisher content update
|
|
672 |
iData->RegisterContentObserverL();
|
|
673 |
|
|
674 |
CleanupStack::PopAndDestroy( 2, &contentItemsArr ); // configurationItemsArr
|
|
675 |
}
|
|
676 |
|
|
677 |
// ----------------------------------------------------------------------------
|
|
678 |
// CSapiDataPlugin::SetProperty
|
|
679 |
//
|
|
680 |
// ----------------------------------------------------------------------------
|
|
681 |
//
|
|
682 |
void CSapiDataPlugin::SetProperty( TProperty aProperty, TAny* aAny )
|
|
683 |
{
|
|
684 |
if ( aProperty == ECpsCmdBuffer )
|
|
685 |
{
|
|
686 |
iData->SetCommandBuffer( aAny );
|
|
687 |
}
|
|
688 |
}
|
|
689 |
// ----------------------------------------------------------------------------
|
|
690 |
// CSapiDataPlugin::GetProperty
|
|
691 |
//
|
|
692 |
// ----------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
TAny* CSapiDataPlugin::GetProperty( TProperty aProperty )
|
|
695 |
{
|
|
696 |
if ( aProperty == EPublisherContent )
|
|
697 |
{
|
|
698 |
return static_cast< MAiContentItemIterator* >( iContent );
|
|
699 |
}
|
|
700 |
|
|
701 |
return NULL;
|
|
702 |
}
|
|
703 |
|
|
704 |
// ----------------------------------------------------------------------------
|
|
705 |
// CSapiDataPlugin::HandleEvent
|
|
706 |
//
|
|
707 |
// ----------------------------------------------------------------------------
|
|
708 |
//
|
|
709 |
void CSapiDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam )
|
|
710 |
{
|
|
711 |
TRAP_IGNORE( iData->ExecuteActionL( aEventName , aParam ) );
|
|
712 |
}
|
|
713 |
|
|
714 |
// ----------------------------------------------------------------------------
|
|
715 |
// CSapiDataPlugin::HasMenuItem
|
|
716 |
//
|
|
717 |
// ----------------------------------------------------------------------------
|
|
718 |
//
|
|
719 |
TBool CSapiDataPlugin::HasMenuItem( const TDesC16& aMenuItem )
|
|
720 |
{
|
|
721 |
return iData->HasMenuItem ( aMenuItem );
|
|
722 |
}
|
|
723 |
|
|
724 |
// ----------------------------------------------------------------------------
|
|
725 |
// CSapiDataPlugin::IsActive
|
|
726 |
//
|
|
727 |
// ----------------------------------------------------------------------------
|
|
728 |
//
|
|
729 |
TBool CSapiDataPlugin::IsActive() const
|
|
730 |
{
|
|
731 |
return iPluginState == EResume;
|
|
732 |
}
|
|
733 |
|
|
734 |
// ----------------------------------------------------------------------------
|
|
735 |
// CSapiDataPlugin::IsStopped
|
|
736 |
//
|
|
737 |
// ----------------------------------------------------------------------------
|
|
738 |
//
|
|
739 |
TBool CSapiDataPlugin::IsStopped() const
|
|
740 |
{
|
|
741 |
return iPluginState == EStopped;
|
|
742 |
}
|
|
743 |
|
|
744 |
// ----------------------------------------------------------------------------
|
|
745 |
// CSapiDataPlugin::Data
|
|
746 |
//
|
|
747 |
// ----------------------------------------------------------------------------
|
|
748 |
//
|
|
749 |
CSapiData* CSapiDataPlugin::Data() const
|
|
750 |
{
|
|
751 |
return iData;
|
|
752 |
}
|
|
753 |
|
|
754 |
// ----------------------------------------------------------------------------
|
|
755 |
// CSapiDataPlugin::NetworkStatus
|
|
756 |
//
|
|
757 |
// ----------------------------------------------------------------------------
|
|
758 |
//
|
|
759 |
CSapiDataPlugin::TPluginNetworkStatus CSapiDataPlugin::NetworkStatus() const
|
|
760 |
{
|
|
761 |
return iNetworkStatus;
|
|
762 |
}
|
|
763 |
|
|
764 |
// End of file
|
|
765 |
|