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