|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System include files |
|
19 #include <s32strm.h> |
|
20 #include <s32mem.h> |
|
21 #include <hscontentcontroller.h> |
|
22 #include <hscontentinfoarray.h> |
|
23 #include <hscontentinfo.h> |
|
24 |
|
25 // User include files |
|
26 #include "hsccproviderclient.h" |
|
27 #include "ccresource.h" |
|
28 #include "ccsrvapi.h" |
|
29 #include "hsccapi.h" |
|
30 |
|
31 // Local constants |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CHsCcProviderClient::NewL() |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 EXPORT_C CHsCcProviderClient* CHsCcProviderClient::NewL( |
|
40 MHsContentController& aController ) |
|
41 { |
|
42 CHsCcProviderClient* self = new ( ELeave ) CHsCcProviderClient( aController ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop( self ); |
|
46 return( self ) ; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------- |
|
50 // CHsCcProviderClient::ConstructL() |
|
51 // ----------------------------------------------------------------------- |
|
52 // |
|
53 void CHsCcProviderClient::ConstructL() |
|
54 { |
|
55 User::LeaveIfError( iSession.Connect() ); |
|
56 |
|
57 TPckgBuf<TUint32> provider( ECcHomescreen ); |
|
58 TPckgBuf<TUint32> address; |
|
59 User::LeaveIfError( iSession.RegisterProvider( |
|
60 provider, |
|
61 address ) ); |
|
62 iAddress = address(); |
|
63 |
|
64 WaitForApiReqL(); |
|
65 |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------- |
|
69 // CHsCcProviderClient::CHsCcProviderClient() |
|
70 // ----------------------------------------------------------------------- |
|
71 // |
|
72 CHsCcProviderClient::CHsCcProviderClient( |
|
73 MHsContentController& aController ) |
|
74 :CActive( EPriorityStandard ) |
|
75 ,iController( aController ) |
|
76 ,iAddress( 0 ) |
|
77 ,iApiHeader( NULL ) |
|
78 ,iApiHeaderPtr( NULL, 0 ) |
|
79 ,iApiData( NULL ) |
|
80 ,iApiDataPtr( NULL, 0 ) |
|
81 { |
|
82 CActiveScheduler::Add( this ); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------- |
|
86 // CHsCcProviderClient::~CHsCcProviderClient() |
|
87 // ----------------------------------------------------------------------- |
|
88 // |
|
89 CHsCcProviderClient::~CHsCcProviderClient() |
|
90 { |
|
91 Cancel(); |
|
92 iSession.Close(); |
|
93 delete iApiHeader; |
|
94 delete iApiData; |
|
95 iObservers.Close(); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CHsCcClient::RunL() |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CHsCcProviderClient::RunL() |
|
103 { |
|
104 |
|
105 if ( !iStatus.Int() ) |
|
106 { |
|
107 // Get received message header |
|
108 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
109 CleanupStack::PushL( message ); |
|
110 RDesReadStream stream( iApiHeaderPtr ); |
|
111 CleanupClosePushL( stream ); |
|
112 message->InternalizeHeaderL( stream ); |
|
113 CleanupStack::PopAndDestroy( &stream ); |
|
114 if ( message->DataSize() ) |
|
115 { |
|
116 // Get message data |
|
117 HBufC8* dataBuf = HBufC8::NewL( message->DataSize() ); |
|
118 CleanupStack::PushL( dataBuf ); |
|
119 TPtr8 dataPtr( NULL, 0 ); |
|
120 dataPtr.Set( dataBuf->Des() ); |
|
121 TPckgBuf<TUint32> trId( message->TrId() ); |
|
122 iSession.GetMsgData( trId, dataPtr ); |
|
123 message->SetData( dataPtr ); |
|
124 CleanupStack::PopAndDestroy( dataBuf ); |
|
125 } |
|
126 |
|
127 switch ( message->MsgId() ) |
|
128 { |
|
129 case ECcRegisterObserverNtf: |
|
130 HandleRegisterObserverNtfL( *message ); |
|
131 break; |
|
132 case ECcUnregisterObserverNtf: |
|
133 HandleUnregisterObserverNtfL( *message ); |
|
134 break; |
|
135 case EHsCcWidgetListReq: |
|
136 HandleWidgetListReqL( *message ); |
|
137 break; |
|
138 case EHsCcAddWidgetReq: |
|
139 HandleAddWidgetReqL( *message ); |
|
140 break; |
|
141 case EHsCcRemoveWidgetReq: |
|
142 HandleRemoveWidgetReqL( *message ); |
|
143 break; |
|
144 case EHsCcViewListReq: |
|
145 HandleViewListReqL( *message ); |
|
146 break; |
|
147 case EHsCcAddViewReq: |
|
148 HandleAddViewReqL( *message ); |
|
149 break; |
|
150 case EHsCcRemoveViewReq: |
|
151 HandleRemoveViewReqL( *message ); |
|
152 break; |
|
153 case EHsCcActivateViewReq: |
|
154 HandleActivateViewReqL( *message ); |
|
155 break; |
|
156 case EHsCcAppListReq: |
|
157 HandleAppListReqL( *message ); |
|
158 break; |
|
159 case EHsCcActivateAppReq: |
|
160 HandleActivateAppReqL( *message ); |
|
161 break; |
|
162 default: |
|
163 HandleNotSupportedReqL( *message ); |
|
164 break; |
|
165 } |
|
166 CleanupStack::PopAndDestroy( message ); |
|
167 } |
|
168 |
|
169 // Receive next API request |
|
170 WaitForApiReqL(); |
|
171 |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CHsCcProviderClient::DoCancel() |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CHsCcProviderClient::DoCancel() |
|
179 { |
|
180 if ( IsActive() ) |
|
181 { |
|
182 TPckgBuf<TInt> function( ECcWaitForApiReq ); |
|
183 iSession.CancelReq( function ); |
|
184 } |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CHsCcProviderClient::NotifyWidgetListChanged() |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CHsCcProviderClient::NotifyWidgetListChanged() |
|
192 { |
|
193 if ( iObservers.Count() ) |
|
194 { |
|
195 TRAP_IGNORE( SendNtfL( EHsCcWidgetListChangedNtf ) ); |
|
196 } |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CHsCcProviderClient::NotifyViewListChanged() |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 void CHsCcProviderClient::NotifyViewListChanged() |
|
204 { |
|
205 if ( iObservers.Count() ) |
|
206 { |
|
207 TRAP_IGNORE( SendNtfL( EHsCcViewListChangedNtf ) ); |
|
208 } |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CHsCcProviderClient::NotifyAppListChanged() |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CHsCcProviderClient::NotifyAppListChanged() |
|
216 { |
|
217 if ( iObservers.Count() ) |
|
218 { |
|
219 TRAP_IGNORE( SendNtfL( EHsCcAppListChangedNtf ) ); |
|
220 } |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CHsCcProviderClient::WaitForApiReqL() |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void CHsCcProviderClient::WaitForApiReqL() |
|
228 { |
|
229 |
|
230 if ( iApiHeader ) |
|
231 { |
|
232 delete iApiHeader; |
|
233 iApiHeader = NULL; |
|
234 } |
|
235 iApiHeader = HBufC8::NewL( KCcHeaderSize ); |
|
236 iApiHeaderPtr.Set( iApiHeader->Des() ); |
|
237 |
|
238 TPckgBuf<TUint32> provider( ECcHomescreen ); |
|
239 iPckgSender = 0; |
|
240 iPckgReceiver = 0; |
|
241 |
|
242 iSession.WaitForApiReq( provider, iPckgSender, iPckgReceiver, iApiHeaderPtr, iStatus ); |
|
243 SetActive(); |
|
244 |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CHsCcProviderClient::HandleRegisterObserverNtfL() |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CHsCcProviderClient::HandleRegisterObserverNtfL( |
|
252 CCcSrvMsg& /* aMessage */ ) |
|
253 { |
|
254 TUint32 observer = iPckgSender(); |
|
255 iObservers.AppendL( observer ); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CHsCcProviderClient::HandleUnregisterObserverNtfL() |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CHsCcProviderClient::HandleUnregisterObserverNtfL( |
|
263 CCcSrvMsg& /* aMessage */ ) |
|
264 { |
|
265 TUint32 observer = iPckgSender(); |
|
266 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
267 { |
|
268 if ( iObservers[ i ] == observer ) |
|
269 { |
|
270 iObservers.Remove( i ); |
|
271 break; |
|
272 } |
|
273 } |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CHsCcProviderClient::HandleWidgetListReqL() |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CHsCcProviderClient::HandleWidgetListReqL( |
|
281 CCcSrvMsg& aMessage ) |
|
282 { |
|
283 // Get widget list |
|
284 CHsContentInfoArray* widgets = CHsContentInfoArray::NewL(); |
|
285 CleanupStack::PushL( widgets ); |
|
286 TInt err = iController.WidgetListL( *widgets ); |
|
287 |
|
288 // Create and send WidgetListResp |
|
289 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
290 CleanupStack::PushL( message ); |
|
291 message->SetMsgId( EHsCcWidgetListResp ); |
|
292 message->SetTrId( aMessage.TrId() ); |
|
293 message->SetStatus( err ); |
|
294 |
|
295 if ( !err ) |
|
296 { |
|
297 // Externalize widget list |
|
298 HBufC8* dataBuf = widgets->MarshalL(); |
|
299 CleanupStack::PushL( dataBuf ); |
|
300 TPtr8 dataPtr( NULL, 0 ); |
|
301 dataPtr.Set( dataBuf->Des() ); |
|
302 message->SetData( dataPtr ); |
|
303 CleanupStack::PopAndDestroy( dataBuf ); |
|
304 } |
|
305 |
|
306 SendRespL( *message ); |
|
307 |
|
308 CleanupStack::PopAndDestroy( message ); |
|
309 CleanupStack::PopAndDestroy( widgets ); |
|
310 |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CHsCcProviderClient::HandleAddWidgetReqL() |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CHsCcProviderClient::HandleAddWidgetReqL( |
|
318 CCcSrvMsg& aMessage ) |
|
319 { |
|
320 TInt err( KErrNone ); |
|
321 if ( aMessage.DataSize() ) |
|
322 { |
|
323 // Internalize message data |
|
324 RDesReadStream dataStream( aMessage.Data() ); |
|
325 CleanupClosePushL( dataStream ); |
|
326 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
327 CleanupStack::PopAndDestroy( &dataStream ); |
|
328 CleanupStack::PushL( info ); |
|
329 |
|
330 // Add widget |
|
331 err = iController.AddWidgetL( *info ); |
|
332 |
|
333 CleanupStack::PopAndDestroy( info ); |
|
334 } |
|
335 else |
|
336 { |
|
337 // Mandatory message data missing |
|
338 err = KErrArgument; |
|
339 } |
|
340 |
|
341 // Create and send AddWidgetResp |
|
342 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
343 CleanupStack::PushL( message ); |
|
344 message->SetMsgId( EHsCcAddWidgetResp ); |
|
345 message->SetTrId( aMessage.TrId() ); |
|
346 message->SetStatus( err ); |
|
347 message->SetData( KNullDesC8() ); |
|
348 |
|
349 SendRespL( *message ); |
|
350 |
|
351 CleanupStack::PopAndDestroy( message ); |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CHsCcProviderClient::HandleRemoveWidgetReqL() |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void CHsCcProviderClient::HandleRemoveWidgetReqL( |
|
359 CCcSrvMsg& aMessage ) |
|
360 { |
|
361 TInt err( KErrNone ); |
|
362 if ( aMessage.DataSize() ) |
|
363 { |
|
364 // Internalize message data |
|
365 RDesReadStream dataStream( aMessage.Data() ); |
|
366 CleanupClosePushL( dataStream ); |
|
367 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
368 CleanupStack::PopAndDestroy( &dataStream ); |
|
369 CleanupStack::PushL( info ); |
|
370 |
|
371 // Remove widget |
|
372 err = iController.RemoveWidgetL( *info ); |
|
373 |
|
374 CleanupStack::PopAndDestroy( info ); |
|
375 } |
|
376 else |
|
377 { |
|
378 // Mandatory message data missing |
|
379 err = KErrArgument; |
|
380 } |
|
381 |
|
382 // Create and send RemoveWidgetResp |
|
383 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
384 CleanupStack::PushL( message ); |
|
385 message->SetMsgId( EHsCcRemoveWidgetResp ); |
|
386 message->SetTrId( aMessage.TrId() ); |
|
387 message->SetStatus( err ); |
|
388 message->SetData( KNullDesC8() ); |
|
389 |
|
390 SendRespL( *message ); |
|
391 |
|
392 CleanupStack::PopAndDestroy( message ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CHsCcProviderClient::HandleViewListReqL() |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CHsCcProviderClient::HandleViewListReqL( |
|
400 CCcSrvMsg& aMessage ) |
|
401 { |
|
402 // Get view list |
|
403 CHsContentInfoArray* views = CHsContentInfoArray::NewL(); |
|
404 CleanupStack::PushL( views ); |
|
405 TInt err = iController.ViewListL( *views ); |
|
406 |
|
407 // Create and send ViewListResp |
|
408 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
409 CleanupStack::PushL( message ); |
|
410 message->SetMsgId( EHsCcViewListResp ); |
|
411 message->SetTrId( aMessage.TrId() ); |
|
412 message->SetStatus( err ); |
|
413 |
|
414 if ( !err ) |
|
415 { |
|
416 // Externalize view list |
|
417 HBufC8* dataBuf = views->MarshalL(); |
|
418 CleanupStack::PushL( dataBuf ); |
|
419 TPtr8 dataPtr( NULL, 0 ); |
|
420 dataPtr.Set( dataBuf->Des() ); |
|
421 message->SetData( dataPtr ); |
|
422 CleanupStack::PopAndDestroy( dataBuf ); |
|
423 } |
|
424 |
|
425 SendRespL( *message ); |
|
426 |
|
427 CleanupStack::PopAndDestroy( message ); |
|
428 CleanupStack::PopAndDestroy( views ); |
|
429 |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CHsCcProviderClient::HandleAddViewReqL() |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 void CHsCcProviderClient::HandleAddViewReqL( |
|
437 CCcSrvMsg& aMessage ) |
|
438 { |
|
439 TInt err( KErrNone ); |
|
440 if ( aMessage.DataSize() ) |
|
441 { |
|
442 // Internalize message data |
|
443 RDesReadStream dataStream( aMessage.Data() ); |
|
444 CleanupClosePushL( dataStream ); |
|
445 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
446 CleanupStack::PopAndDestroy( &dataStream ); |
|
447 CleanupStack::PushL( info ); |
|
448 |
|
449 // Add view |
|
450 err = iController.AddViewL( *info ); |
|
451 |
|
452 CleanupStack::PopAndDestroy( info ); |
|
453 } |
|
454 else |
|
455 { |
|
456 // Mandatory message data missing |
|
457 err = KErrArgument; |
|
458 } |
|
459 |
|
460 // Create and send AddViewResp |
|
461 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
462 CleanupStack::PushL( message ); |
|
463 message->SetMsgId( EHsCcAddViewResp ); |
|
464 message->SetTrId( aMessage.TrId() ); |
|
465 message->SetStatus( err ); |
|
466 message->SetData( KNullDesC8() ); |
|
467 |
|
468 SendRespL( *message ); |
|
469 |
|
470 CleanupStack::PopAndDestroy( message ); |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CHsCcProviderClient::HandleRemoveViewReqL() |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 void CHsCcProviderClient::HandleRemoveViewReqL( |
|
478 CCcSrvMsg& aMessage ) |
|
479 { |
|
480 TInt err( KErrNone ); |
|
481 if ( aMessage.DataSize() ) |
|
482 { |
|
483 // Internalize message data |
|
484 RDesReadStream dataStream( aMessage.Data() ); |
|
485 CleanupClosePushL( dataStream ); |
|
486 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
487 CleanupStack::PopAndDestroy( &dataStream ); |
|
488 CleanupStack::PushL( info ); |
|
489 |
|
490 // Remove view |
|
491 err = iController.RemoveViewL( *info ); |
|
492 |
|
493 CleanupStack::PopAndDestroy( info ); |
|
494 } |
|
495 else |
|
496 { |
|
497 // Mandatory message data missing |
|
498 err = KErrArgument; |
|
499 } |
|
500 |
|
501 // Create and send RemoveViewResp |
|
502 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
503 CleanupStack::PushL( message ); |
|
504 message->SetMsgId( EHsCcRemoveViewResp ); |
|
505 message->SetTrId( aMessage.TrId() ); |
|
506 message->SetStatus( err ); |
|
507 message->SetData( KNullDesC8() ); |
|
508 |
|
509 SendRespL( *message ); |
|
510 |
|
511 CleanupStack::PopAndDestroy( message ); |
|
512 } |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CHsCcProviderClient::HandleActivateViewReqL() |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 void CHsCcProviderClient::HandleActivateViewReqL( |
|
519 CCcSrvMsg& aMessage ) |
|
520 { |
|
521 TInt err( KErrNone ); |
|
522 if ( aMessage.DataSize() ) |
|
523 { |
|
524 // Internalize message data |
|
525 RDesReadStream dataStream( aMessage.Data() ); |
|
526 CleanupClosePushL( dataStream ); |
|
527 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
528 CleanupStack::PopAndDestroy( &dataStream ); |
|
529 CleanupStack::PushL( info ); |
|
530 |
|
531 // Activate view |
|
532 err = iController.ActivateViewL( *info ); |
|
533 |
|
534 CleanupStack::PopAndDestroy( info ); |
|
535 } |
|
536 else |
|
537 { |
|
538 // Mandatory message data missing |
|
539 err = KErrArgument; |
|
540 } |
|
541 |
|
542 // Create and send ActivateViewResp |
|
543 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
544 CleanupStack::PushL( message ); |
|
545 message->SetMsgId( EHsCcActivateViewResp ); |
|
546 message->SetTrId( aMessage.TrId() ); |
|
547 message->SetStatus( err ); |
|
548 message->SetData( KNullDesC8() ); |
|
549 |
|
550 SendRespL( *message ); |
|
551 |
|
552 CleanupStack::PopAndDestroy( message ); |
|
553 } |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CHsCcProviderClient::HandleAppListReqL() |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CHsCcProviderClient::HandleAppListReqL( |
|
560 CCcSrvMsg& aMessage ) |
|
561 { |
|
562 // Get app list |
|
563 CHsContentInfoArray* apps = CHsContentInfoArray::NewL(); |
|
564 CleanupStack::PushL( apps ); |
|
565 TInt err = iController.AppListL( *apps ); |
|
566 |
|
567 // Create and send AppListResp |
|
568 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
569 CleanupStack::PushL( message ); |
|
570 message->SetMsgId( EHsCcAppListResp ); |
|
571 message->SetTrId( aMessage.TrId() ); |
|
572 message->SetStatus( err ); |
|
573 if ( !err ) |
|
574 { |
|
575 // Externalize app list |
|
576 HBufC8* dataBuf = apps->MarshalL(); |
|
577 CleanupStack::PushL( dataBuf ); |
|
578 TPtr8 dataPtr( NULL, 0 ); |
|
579 dataPtr.Set( dataBuf->Des() ); |
|
580 message->SetData( dataPtr ); |
|
581 CleanupStack::PopAndDestroy( dataBuf ); |
|
582 } |
|
583 |
|
584 SendRespL( *message ); |
|
585 |
|
586 CleanupStack::PopAndDestroy( message ); |
|
587 CleanupStack::PopAndDestroy( apps ); |
|
588 |
|
589 } |
|
590 |
|
591 // ----------------------------------------------------------------------------- |
|
592 // CHsCcProviderClient::HandleActivateAppReqL() |
|
593 // ----------------------------------------------------------------------------- |
|
594 // |
|
595 void CHsCcProviderClient::HandleActivateAppReqL( |
|
596 CCcSrvMsg& aMessage ) |
|
597 { |
|
598 TInt err( KErrNone ); |
|
599 if ( aMessage.DataSize() ) |
|
600 { |
|
601 // Internalize message data |
|
602 RDesReadStream dataStream( aMessage.Data() ); |
|
603 CleanupClosePushL( dataStream ); |
|
604 CHsContentInfo* info = CHsContentInfo::NewL( dataStream ); |
|
605 CleanupStack::PopAndDestroy( &dataStream ); |
|
606 CleanupStack::PushL( info ); |
|
607 |
|
608 // Activate view |
|
609 err = iController.ActivateAppL( *info ); |
|
610 |
|
611 CleanupStack::PopAndDestroy( info ); |
|
612 } |
|
613 else |
|
614 { |
|
615 // Mandatory message data missing |
|
616 err = KErrArgument; |
|
617 } |
|
618 |
|
619 // Create and send ActivateAppResp |
|
620 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
621 CleanupStack::PushL( message ); |
|
622 message->SetMsgId( EHsCcActivateAppResp ); |
|
623 message->SetTrId( aMessage.TrId() ); |
|
624 message->SetStatus( err ); |
|
625 message->SetData( KNullDesC8() ); |
|
626 |
|
627 SendRespL( *message ); |
|
628 |
|
629 CleanupStack::PopAndDestroy( message ); |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // CHsCcProviderClient::HandleNotSupportedReqL() |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 void CHsCcProviderClient::HandleNotSupportedReqL( |
|
637 CCcSrvMsg& aMessage ) |
|
638 { |
|
639 // Create and send NotSupportedResp |
|
640 CCcSrvMsg* message = CCcSrvMsg::NewL(); |
|
641 CleanupStack::PushL( message ); |
|
642 message->SetMsgId( EHsCcNotSupportedResp ); |
|
643 message->SetTrId( aMessage.TrId() ); |
|
644 message->SetStatus( KErrNone ); |
|
645 message->SetData( KNullDesC8() ); |
|
646 |
|
647 SendRespL( *message ); |
|
648 |
|
649 CleanupStack::PopAndDestroy( message ); |
|
650 |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // CHsCcProviderClient::SendNtfL() |
|
655 // ----------------------------------------------------------------------------- |
|
656 // |
|
657 void CHsCcProviderClient::SendNtfL( |
|
658 TUint32 aNtf ) |
|
659 { |
|
660 // Notify registered observers |
|
661 CCcSrvMsg* ntf = CCcSrvMsg::NewL(); |
|
662 CleanupStack::PushL( ntf ); |
|
663 ntf->SetMsgId( aNtf ); |
|
664 HBufC8* ntfBuf = ntf->MarshalL(); |
|
665 CleanupStack::PushL( ntfBuf ); |
|
666 TPtr8 ntfPtr( NULL, 0 ); |
|
667 ntfPtr.Set( ntfBuf->Des() ); |
|
668 |
|
669 TPckgBuf<TUint32> provider( ECcHomescreen ); |
|
670 TPckgBuf<TUint32> sender( iAddress ); |
|
671 TPckgBuf<TUint32> receiver( 0 ); |
|
672 iSession.Send( ECcApiNtf, provider, sender, receiver, ntfPtr ); |
|
673 |
|
674 CleanupStack::PopAndDestroy( ntfBuf ); |
|
675 CleanupStack::PopAndDestroy( ntf ); |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CHsCcProviderClient::SendRespL() |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CHsCcProviderClient::SendRespL( |
|
683 CCcSrvMsg& aMessage ) |
|
684 { |
|
685 HBufC8* msgBuf = aMessage.MarshalL(); |
|
686 CleanupStack::PushL( msgBuf ); |
|
687 TPtr8 msgPtr( NULL, 0 ); |
|
688 msgPtr.Set( msgBuf->Des() ); |
|
689 |
|
690 TPckgBuf<TUint32> provider( ECcHomescreen ); |
|
691 iSession.Send( ECcApiResp, provider, iPckgReceiver, iPckgSender, msgPtr ); |
|
692 |
|
693 CleanupStack::PopAndDestroy( msgBuf ); |
|
694 } |
|
695 |
|
696 // End of file |