|
1 /* |
|
2 * Copyright (c) 2006-2010 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: SAT Active Idle publisher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <ecom/implementationproxy.h> |
|
21 #include <aicontentobserver.h> |
|
22 #include <aiutility.h> |
|
23 #include <aipluginsettings.h> |
|
24 #include <flogger.h> |
|
25 #include <AknUtils.h> |
|
26 #include <gulicon.h> // For CGulIcon |
|
27 #include <fbs.h> // For CFbsBitmap |
|
28 #include <SATInternalPSKeys.h> |
|
29 |
|
30 #include "aisatcontentmodel.h" |
|
31 #include "caisatplugin.h" |
|
32 #include "caisatengine.h" |
|
33 #include "tflogger.h" |
|
34 |
|
35 const TImplementationProxy KImplementationTable[] = |
|
36 { |
|
37 //lint -e{611,1924} Warning "Suspicious cast" can not be avoided. |
|
38 IMPLEMENTATION_PROXY_ENTRY( KImplUidSatPlugin, CAiSatPlugin::NewL ) |
|
39 }; |
|
40 |
|
41 // static cleanup function |
|
42 static void TransactionCleanup( TAny* aAny ) |
|
43 { |
|
44 static_cast<MAiContentObserver*>( aAny )-> |
|
45 CancelTransaction( KImplUidSatPlugin ); |
|
46 } |
|
47 |
|
48 // ============================ MEMBER FUNCTIONS ============================= |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Symbian 2nd phase constructor can leave |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CAiSatPlugin* CAiSatPlugin::NewL() |
|
55 { |
|
56 TFLOGSTRING( "CAiSatPlugin::NewL() starts" ) |
|
57 |
|
58 CAiSatPlugin* self = new ( ELeave ) CAiSatPlugin; |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 TFLOGSTRING( "CAiSatPlugin::NewL() exits" ) |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // Deletes all data created to heap |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CAiSatPlugin::~CAiSatPlugin() |
|
73 { |
|
74 TFLOGSTRING( "CAiSatPlugin::~CAiSatPlugin() starts" ) |
|
75 |
|
76 Release( iContent ); |
|
77 iContent = NULL; |
|
78 |
|
79 Release( iResources ); |
|
80 iResources = NULL; |
|
81 |
|
82 Release( iEvents ); |
|
83 iEvents = NULL; |
|
84 |
|
85 delete iEngine; |
|
86 |
|
87 iObservers.Close(); |
|
88 |
|
89 TFLOGSTRING( "CAiSatPlugin::~CAiSatPlugin() exits" ) |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Publish a icon to the idle area. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CAiSatPlugin::PublishIcon( |
|
97 MAiContentObserver& aObserver, |
|
98 CGulIcon* aIcon ) |
|
99 { |
|
100 TFLOGSTRING( "CAiSatPlugin::PublishIcon() starts" ) |
|
101 |
|
102 TInt error( KErrNotSupported ); |
|
103 |
|
104 // Check whether the icon can be published or not. |
|
105 if ( aIcon && aObserver.CanPublish( *this, KSatContent[ESatContentIcon].id, |
|
106 ESatContentIcon ) ) |
|
107 { |
|
108 // If the icon can be published, and then publish it. |
|
109 error = aObserver.Publish( *this, KSatContent[ESatContentIcon].id, |
|
110 TPckgC<TAny*>( aIcon ), ESatContentIcon ); |
|
111 } |
|
112 |
|
113 TFLOGSTRING2( "CAiSatPlugin::PublishIcon() exits, error: %d", error ) |
|
114 |
|
115 return error; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Clean idle area icon |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CAiSatPlugin::CleanIcon( MAiContentObserver& aObserver ) |
|
123 { |
|
124 TFLOGSTRING( "CAiSatPlugin::CleanIcon() starts" ) |
|
125 TInt error( KErrNotSupported ); |
|
126 |
|
127 error = aObserver.Clean( *this, KSatContent[ESatContentIcon].id, |
|
128 ESatContentIcon ); |
|
129 |
|
130 TFLOGSTRING2( "CAiSatPlugin::CleanIcon() exits, error %d", error ) |
|
131 return error; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // Publish a SetUpIdleModeText string. |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 TInt CAiSatPlugin::PublishText( MAiContentObserver& aObserver, |
|
139 const TDesC& aText ) |
|
140 { |
|
141 TFLOGSTRING( "CAiSatPlugin::PublishText() starts" ) |
|
142 TFLOGSTRING2( "CAiSatPlugin::PublishText() length %i", aText.Length() ) |
|
143 |
|
144 TInt error( KErrNotSupported ); |
|
145 |
|
146 // Check whether the SetUpIdleModeText string can be published or not |
|
147 if ( aText.Length() && |
|
148 aObserver.CanPublish( *this, KSatContent[ESatContentText].id, |
|
149 ESatContentText ) ) |
|
150 { |
|
151 // If SetUpIdleModeText can be published, and then publish it. |
|
152 error = aObserver.Publish( *this, KSatContent[ESatContentText].id, |
|
153 aText, ESatContentText ); |
|
154 } |
|
155 TFLOGSTRING2( "CAiSatPlugin::PublishText() exits, error: \ |
|
156 %d", error ) |
|
157 |
|
158 return error; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // Clean idle area text |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 TInt CAiSatPlugin::CleanText( MAiContentObserver& aObserver ) |
|
166 { |
|
167 TFLOGSTRING( "CAiSatPlugin::CleanText() starts" ) |
|
168 TInt error( KErrNotSupported ); |
|
169 |
|
170 error = aObserver.Clean( *this, KSatContent[ESatContentText].id, |
|
171 ESatContentText ); |
|
172 |
|
173 TFLOGSTRING2( "CAiSatPlugin::CleanText() exits, error %d", error ) |
|
174 |
|
175 return error; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // Publishes the SAT Set Up Idle Mode Text and or Icon |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CAiSatPlugin::PublishSatL() |
|
183 { |
|
184 TFLOGSTRING( "CAiSatPlugin::PublishSatL() starts" ) |
|
185 |
|
186 TInt error( KErrNone ); |
|
187 TInt iconError( KErrNone ); |
|
188 TInt textError( KErrNone ); |
|
189 TInt observers( iObservers.Count() ); |
|
190 TInt transactionId( KImplUidSatPlugin ); |
|
191 MAiContentObserver* observer( NULL ); |
|
192 CGulIcon* icon( NULL ); // The icon for publishing. |
|
193 TInt i( 0 ); |
|
194 TBool commitNeeded( EFalse ); |
|
195 |
|
196 // Publish sat data to all observers. |
|
197 TFLOGSTRING2( "CAiSatPlugin::PublishSatL() observer count: %i", observers ) |
|
198 for ( i = 0; i < observers; i++ ) |
|
199 { |
|
200 commitNeeded = EFalse; |
|
201 observer = iObservers[i]; |
|
202 TFLOGSTRING2( "CAiSatPlugin::PublishSatL() observer id: %i", observer ) |
|
203 |
|
204 // Start publish transaciton. |
|
205 error = observer->StartTransaction( transactionId ); |
|
206 TCleanupItem item( TransactionCleanup, observer ); |
|
207 CleanupStack::PushL( item ); |
|
208 |
|
209 // Publish icon and text to idle mode area. |
|
210 iEngine->ContentIconL( icon ); |
|
211 TPtrC text( KNullDesC ); |
|
212 iEngine->ContentText( text ); |
|
213 if ( !icon && !text.Length() ) // Nothing |
|
214 { |
|
215 if ( !iDupIcon ) |
|
216 { |
|
217 error = CleanIcon( *observer ); |
|
218 commitNeeded = ETrue; |
|
219 } |
|
220 if ( !iDupText ) |
|
221 { |
|
222 error = CleanText( *observer ); |
|
223 commitNeeded = ETrue; |
|
224 } |
|
225 } |
|
226 else if ( icon && !text.Length() ) // Icon only |
|
227 { |
|
228 if ( !iDupIcon ) |
|
229 { |
|
230 error = CleanIcon( *observer ); |
|
231 iconError = PublishIcon( *observer, icon ); |
|
232 commitNeeded = ETrue; |
|
233 } |
|
234 if ( !iDupText ) |
|
235 { |
|
236 error = CleanText( *observer ); |
|
237 commitNeeded = ETrue; |
|
238 } |
|
239 } |
|
240 else if ( !icon && text.Length() ) // Text only |
|
241 { |
|
242 if ( !iDupIcon ) |
|
243 { |
|
244 error = CleanIcon( *observer ); |
|
245 commitNeeded = ETrue; |
|
246 } |
|
247 if ( !iDupText ) |
|
248 { |
|
249 error = CleanText( *observer ); |
|
250 textError = PublishText( *observer, text ); |
|
251 commitNeeded = ETrue; |
|
252 } |
|
253 } |
|
254 else // Text and icon |
|
255 { |
|
256 if ( !iDupIcon ) |
|
257 { |
|
258 error = CleanIcon( *observer ); |
|
259 iconError = PublishIcon( *observer, icon ); |
|
260 commitNeeded = ETrue; |
|
261 } |
|
262 if ( !iDupText ) |
|
263 { |
|
264 error = CleanText( *observer ); |
|
265 textError = PublishText( *observer, text ); |
|
266 commitNeeded = ETrue; |
|
267 } |
|
268 } |
|
269 |
|
270 // Commit the publishing of the icon and text. |
|
271 if ( !textError && !iconError && commitNeeded ) |
|
272 { |
|
273 TFLOGSTRING( "CAiSatPlugin::PublishSatL() commit transaction" ) |
|
274 error = observer->Commit( transactionId ); |
|
275 } |
|
276 else |
|
277 { |
|
278 TFLOGSTRING( "CAiSatPlugin::PublishSatL() cancel transaction" ) |
|
279 error = observer->CancelTransaction( transactionId ); |
|
280 } |
|
281 CleanupStack::Pop(); |
|
282 } |
|
283 |
|
284 TFLOGSTRING( "CAiSatPlugin::PublishSatL() exits" ) |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CAiSatPlugin::Start |
|
289 // |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CAiSatPlugin::Start( TStartReason /*aReason*/ ) |
|
293 { |
|
294 TFLOGSTRING( "CAiSatPlugin::Start() starts" ) |
|
295 |
|
296 iPublishRequired = ETrue; |
|
297 |
|
298 TFLOGSTRING( "CAiSatPlugin::Start() exits" ) |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CAiSatPlugin::Stop |
|
303 // |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 void CAiSatPlugin::Stop( TStopReason /*aReason*/ ) |
|
307 { |
|
308 TFLOGSTRING( "CAiSatPlugin::Stop() starts - exits" ) |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // CAiSatPlugin::Resume |
|
313 // |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 void CAiSatPlugin::Resume( TResumeReason aReason ) |
|
317 { |
|
318 TFLOGSTRING2( "CAiSatPlugin::Resume() reason %d", aReason ) |
|
319 |
|
320 if ( aReason == EForeground ) |
|
321 { |
|
322 if ( iPublishRequired ) |
|
323 { |
|
324 iPublishRequired = EFalse; |
|
325 |
|
326 TRAP_IGNORE( UpdateSatL() ) |
|
327 } |
|
328 } |
|
329 |
|
330 TFLOGSTRING( "CAiSatPlugin::Resume() exits" ) |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // CAiSatPlugin::Suspend |
|
335 // |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CAiSatPlugin::Suspend( TSuspendReason aReason ) |
|
339 { |
|
340 TFLOGSTRING( "CAiSatPlugin::Suspend() starts" ) |
|
341 |
|
342 if ( aReason == EGeneralThemeChange ) |
|
343 { |
|
344 iPublishRequired = ETrue; |
|
345 } |
|
346 |
|
347 TFLOGSTRING( "CAiSatPlugin::Suspend() exits" ) |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CAiSatPlugin::SubscribeL |
|
352 // |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 void CAiSatPlugin::SubscribeL( MAiContentObserver& aObserver ) |
|
356 { |
|
357 TFLOGSTRING( "CAiSatPlugin::SubscribeL() starts" ) |
|
358 |
|
359 iObservers.AppendL( &aObserver ); |
|
360 |
|
361 TFLOGSTRING( "CAiSatPlugin::SubscribeL() exits" ) |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CAiSatPlugin::ConfigureL |
|
366 // |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CAiSatPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
370 { |
|
371 TFLOGSTRING( "CAiSatPlugin::ConfigureL() starts" ) |
|
372 |
|
373 TInt count = aSettings.Count(); |
|
374 TFLOGSTRING2( "CAiSatPlugin::ConfigureL count: %d", count ) |
|
375 if ( count > 0 ) |
|
376 { |
|
377 TInt i( 0 ); |
|
378 for ( i = 0; i < count; i++ ) |
|
379 { |
|
380 MAiPluginSettings* settings = aSettings[i]; |
|
381 MAiPluginSettingsItem& item = settings->AiPluginSettingsItem(); |
|
382 item.SetValueL( item.Value(), EFalse ); |
|
383 } |
|
384 TFLOGSTRING2( "CAiSatPlugin::ConfigureL i: %d", i ) |
|
385 } |
|
386 |
|
387 TFLOGSTRING( "CAiSatPlugin::ConfigureL() exits" ) |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // CAiSatPlugin::GetProperty |
|
392 // |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 TAny* CAiSatPlugin::GetProperty( TProperty aProperty ) |
|
396 { |
|
397 TFLOGSTRING( "CAiSatPlugin::GetProperty() starts" ) |
|
398 |
|
399 TAny* property( NULL ); |
|
400 |
|
401 TFLOGSTRING2( "CAiSatPlugin::GetProperty aProperty: %d", aProperty ) |
|
402 |
|
403 if ( aProperty == EPublisherContent ) |
|
404 { |
|
405 property = iContent; |
|
406 } |
|
407 else if ( aProperty == EPublisherResources ) |
|
408 { |
|
409 property = iResources; |
|
410 } |
|
411 else if ( aProperty == EPublisherEvents ) |
|
412 { |
|
413 property = iEvents; |
|
414 } |
|
415 |
|
416 TFLOGSTRING( "CAiSatPlugin::GetProperty() exits" ) |
|
417 |
|
418 return property; |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------- |
|
422 // This method is called from the engine, when the P&S |
|
423 // data content has been changed. Method call is made through |
|
424 // the MPluginAPI interface. |
|
425 // --------------------------------------------------------- |
|
426 // |
|
427 void CAiSatPlugin::NotifyContentUpdate() |
|
428 { |
|
429 TFLOGSTRING( "CAiSatPlugin::NotifyContentUpdate() starts" ) |
|
430 |
|
431 if ( iEngine ) |
|
432 { |
|
433 // Get the idle mode data first. |
|
434 TRAP_IGNORE( iEngine->PrepareIdleModeDataL( iDupIcon, iDupText ) ); |
|
435 |
|
436 // Send response to client side |
|
437 TRAP_IGNORE( iEngine->HandleNotifyL() ); |
|
438 |
|
439 // Publish set up idle mode data |
|
440 TRAP_IGNORE( PublishSatL() ); |
|
441 } |
|
442 |
|
443 TFLOGSTRING( "CAiSatPlugin::NotifyContentUpdate() exits" ) |
|
444 } |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // Default constructor |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 CAiSatPlugin::CAiSatPlugin() |
|
451 { |
|
452 TFLOGSTRING( "CAiSatPlugin::CAiSatPlugin() starts-exits" ) |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // Symbian 2nd phase constructor can leave |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 void CAiSatPlugin::ConstructL() |
|
460 { |
|
461 TFLOGSTRING( "CAiSatPlugin::ConstructL() starts" ) |
|
462 |
|
463 iContent = AiUtility::CreateContentItemArrayIteratorL( KSatContent ); |
|
464 iResources = AiUtility::CreateContentItemArrayIteratorL( KSatResources ); |
|
465 iEvents = AiUtility::CreateContentItemArrayIteratorL( KSatEvents ); |
|
466 |
|
467 iEngine = CAiSatEngine::NewL( *this ); |
|
468 |
|
469 TFLOGSTRING( "CAiSatPlugin::ConstructL() exits" ) |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // Update idle area when plug in reload. |
|
474 // --------------------------------------------------------------------------- |
|
475 // |
|
476 void CAiSatPlugin::UpdateSatL() |
|
477 { |
|
478 TFLOGSTRING( "CAiSatPlugin::UpdateSatL() starts" ) |
|
479 iEngine->PrepareIdleModeDataL( iDupIcon, iDupText ); |
|
480 PublishSatL(); |
|
481 TFLOGSTRING( "CAiSatPlugin::UpdateSatL() exits" ) |
|
482 } |
|
483 |
|
484 // ============================ GLOBAL FUNCTIONS ============================= |
|
485 |
|
486 // --------------------------------------------------------------------------- |
|
487 // Constructs and returns an application object. |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
491 TInt& aTableCount ) |
|
492 { |
|
493 TFLOGSTRING( "CAiSatPlugin::ImplementationGroupProxy() starts-exits" ) |
|
494 aTableCount = |
|
495 sizeof( KImplementationTable ) / sizeof( TImplementationProxy ); |
|
496 |
|
497 return KImplementationTable; |
|
498 } |