114
|
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 |
TInt err( iStatus.Int() );
|
|
106 |
HBufC8* header( NULL );
|
|
107 |
TPtr8 headerPtr( NULL, 0 );
|
|
108 |
|
|
109 |
if ( !err )
|
|
110 |
{
|
|
111 |
// Read API request header
|
|
112 |
header = iApiHeader->AllocL();
|
|
113 |
CleanupStack::PushL( header );
|
|
114 |
headerPtr.Set( header->Des() );
|
|
115 |
}
|
|
116 |
|
|
117 |
// Receive next API notification
|
|
118 |
WaitForApiNtfL();
|
|
119 |
|
|
120 |
if ( !err )
|
|
121 |
{
|
|
122 |
// Get received message header
|
|
123 |
CCcSrvMsg* message = CCcSrvMsg::NewL();
|
|
124 |
CleanupStack::PushL( message );
|
|
125 |
RDesReadStream stream( headerPtr );
|
|
126 |
CleanupClosePushL( stream );
|
|
127 |
message->InternalizeHeaderL( stream );
|
|
128 |
CleanupStack::PopAndDestroy( &stream );
|
|
129 |
|
|
130 |
switch ( message->MsgId() )
|
|
131 |
{
|
|
132 |
case EHsCcWidgetListChangedNtf:
|
|
133 |
if ( iObserver )
|
|
134 |
{
|
|
135 |
iObserver->NotifyWidgetListChanged();
|
|
136 |
}
|
|
137 |
break;
|
|
138 |
case EHsCcViewListChangedNtf:
|
|
139 |
if ( iObserver )
|
|
140 |
{
|
|
141 |
iObserver->NotifyViewListChanged();
|
|
142 |
}
|
|
143 |
break;
|
|
144 |
case EHsCcAppListChangedNtf:
|
|
145 |
if ( iObserver )
|
|
146 |
{
|
|
147 |
iObserver->NotifyAppListChanged();
|
|
148 |
}
|
|
149 |
break;
|
|
150 |
default:
|
|
151 |
// No action required
|
|
152 |
break;
|
|
153 |
}
|
|
154 |
CleanupStack::PopAndDestroy( message );
|
|
155 |
}
|
|
156 |
if ( header )
|
|
157 |
{
|
|
158 |
CleanupStack::PopAndDestroy( header );
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
// CHsCcApiClient::DoCancel()
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CHsCcApiClient::DoCancel()
|
|
167 |
{
|
|
168 |
if ( IsActive() )
|
|
169 |
{
|
|
170 |
TPckgBuf<TInt> function( ECcWaitForApiNtf );
|
|
171 |
iSession.CancelReq( function );
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
// CHsCcApiClient::WidgetListL
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
TInt CHsCcApiClient::WidgetListL( CHsContentInfoArray& aArray )
|
|
180 |
{
|
|
181 |
TInt err( KErrNone );
|
|
182 |
|
|
183 |
// Create WidgetListReq API request
|
|
184 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
185 |
CleanupStack::PushL( reqMsg );
|
|
186 |
reqMsg->SetMsgId( EHsCcWidgetListReq );
|
|
187 |
reqMsg->SetTrId( 0 );
|
|
188 |
reqMsg->SetData( KNullDesC8() );
|
|
189 |
|
|
190 |
// Marshal API request
|
|
191 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
192 |
CleanupStack::PushL( msgBuf );
|
|
193 |
TPtr8 msgPtr( NULL, 0 );
|
|
194 |
msgPtr.Set( msgBuf->Des() );
|
|
195 |
|
|
196 |
// Send API request
|
|
197 |
// Sender and receiver address not defined -> message is routed
|
|
198 |
// according to the provider id
|
|
199 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
200 |
TPckgBuf<TUint32> sender;
|
|
201 |
TPckgBuf<TUint32> receiver;
|
|
202 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
203 |
|
|
204 |
if ( !err )
|
|
205 |
{
|
|
206 |
// Internalize response message
|
|
207 |
TUint32 trId;
|
|
208 |
TUint32 dataSize;
|
|
209 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
210 |
if ( !err && dataSize )
|
|
211 |
{
|
|
212 |
// Internalize API response data
|
|
213 |
err = InternalizeContentInfoArrayL( aArray, trId, dataSize );
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
|
217 |
// Cleanup
|
|
218 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
219 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
220 |
|
|
221 |
return err;
|
|
222 |
}
|
|
223 |
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
// CHsCcApiClient::WidgetListL
|
|
226 |
// -----------------------------------------------------------------------------
|
|
227 |
//
|
|
228 |
TInt CHsCcApiClient::WidgetListL(
|
|
229 |
CHsContentInfo& aInfo, CHsContentInfoArray& aArray )
|
|
230 |
{
|
|
231 |
TInt err( KErrNone );
|
|
232 |
|
|
233 |
// Create WidgetListReq API request
|
|
234 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
235 |
CleanupStack::PushL( reqMsg );
|
|
236 |
reqMsg->SetMsgId( EHsCcWidgetListReq );
|
|
237 |
reqMsg->SetTrId( 0 );
|
|
238 |
|
|
239 |
// Marshal WidgetListReq data to a descriptor
|
|
240 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
241 |
TPtr8 dataPtr( NULL, 0 );
|
|
242 |
dataPtr.Set( dataBuf->Des() );
|
|
243 |
reqMsg->SetData( dataPtr );
|
|
244 |
|
|
245 |
delete dataBuf;
|
|
246 |
dataBuf = NULL;
|
|
247 |
|
|
248 |
// Marshal API request
|
|
249 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
250 |
CleanupStack::PushL( msgBuf );
|
|
251 |
TPtr8 msgPtr( NULL, 0 );
|
|
252 |
msgPtr.Set( msgBuf->Des() );
|
|
253 |
|
|
254 |
// Send API request
|
|
255 |
// Sender and receiver address not defined -> message is routed
|
|
256 |
// according to the provider id
|
|
257 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
258 |
TPckgBuf<TUint32> sender;
|
|
259 |
TPckgBuf<TUint32> receiver;
|
|
260 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
261 |
|
|
262 |
if ( !err )
|
|
263 |
{
|
|
264 |
// Internalize response message
|
|
265 |
TUint32 trId;
|
|
266 |
TUint32 dataSize;
|
|
267 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
268 |
if ( !err && dataSize )
|
|
269 |
{
|
|
270 |
// Internalize API response data
|
|
271 |
err = InternalizeContentInfoArrayL( aArray, trId, dataSize );
|
|
272 |
}
|
|
273 |
}
|
|
274 |
|
|
275 |
// Cleanup
|
|
276 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
277 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
278 |
|
|
279 |
return err;
|
|
280 |
}
|
|
281 |
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
// CHsCcApiClient::ViewListL
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
TInt CHsCcApiClient::ViewListL( CHsContentInfoArray& aArray )
|
|
287 |
{
|
|
288 |
TInt err( KErrNone );
|
|
289 |
|
|
290 |
// Create ViewListReq API request
|
|
291 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
292 |
CleanupStack::PushL( reqMsg );
|
|
293 |
reqMsg->SetMsgId( EHsCcViewListReq );
|
|
294 |
reqMsg->SetTrId( 0 );
|
|
295 |
reqMsg->SetData( KNullDesC8() );
|
|
296 |
|
|
297 |
// Marshal API request
|
|
298 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
299 |
CleanupStack::PushL( msgBuf );
|
|
300 |
TPtr8 msgPtr( NULL, 0 );
|
|
301 |
msgPtr.Set( msgBuf->Des() );
|
|
302 |
|
|
303 |
// Send API request
|
|
304 |
// Sender and receiver address not defined -> message is routed
|
|
305 |
// according to the provider id
|
|
306 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
307 |
TPckgBuf<TUint32> sender;
|
|
308 |
TPckgBuf<TUint32> receiver;
|
|
309 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
310 |
|
|
311 |
if ( !err )
|
|
312 |
{
|
|
313 |
// Internalize response message
|
|
314 |
TUint32 trId;
|
|
315 |
TUint32 dataSize;
|
|
316 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
317 |
if ( !err && dataSize )
|
|
318 |
{
|
|
319 |
// Internalize API response data
|
|
320 |
err = InternalizeContentInfoArrayL( aArray, trId, dataSize );
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
// Cleanup
|
|
325 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
326 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
327 |
|
|
328 |
return err;
|
|
329 |
}
|
|
330 |
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
// CHsCcApiClient::ViewListL
|
|
333 |
// -----------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
TInt CHsCcApiClient::ViewListL(
|
|
336 |
CHsContentInfo& aInfo, CHsContentInfoArray& aArray )
|
|
337 |
{
|
|
338 |
TInt err( KErrNone );
|
|
339 |
|
|
340 |
// Create ViewListReq API request
|
|
341 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
342 |
CleanupStack::PushL( reqMsg );
|
|
343 |
reqMsg->SetMsgId( EHsCcViewListReq );
|
|
344 |
reqMsg->SetTrId( 0 );
|
|
345 |
|
|
346 |
// Marshal ViewListReq data to a descriptor
|
|
347 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
348 |
TPtr8 dataPtr( NULL, 0 );
|
|
349 |
dataPtr.Set( dataBuf->Des() );
|
|
350 |
reqMsg->SetData( dataPtr );
|
|
351 |
|
|
352 |
delete dataBuf;
|
|
353 |
dataBuf = NULL;
|
|
354 |
|
|
355 |
// Marshal API request
|
|
356 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
357 |
CleanupStack::PushL( msgBuf );
|
|
358 |
TPtr8 msgPtr( NULL, 0 );
|
|
359 |
msgPtr.Set( msgBuf->Des() );
|
|
360 |
|
|
361 |
// Send API request
|
|
362 |
// Sender and receiver address not defined -> message is routed
|
|
363 |
// according to the provider id
|
|
364 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
365 |
TPckgBuf<TUint32> sender;
|
|
366 |
TPckgBuf<TUint32> receiver;
|
|
367 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
368 |
|
|
369 |
if ( !err )
|
|
370 |
{
|
|
371 |
// Internalize response message
|
|
372 |
TUint32 trId;
|
|
373 |
TUint32 dataSize;
|
|
374 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
375 |
if ( !err && dataSize )
|
|
376 |
{
|
|
377 |
// Internalize API response data
|
|
378 |
err = InternalizeContentInfoArrayL( aArray, trId, dataSize );
|
|
379 |
}
|
|
380 |
}
|
|
381 |
|
|
382 |
// Cleanup
|
|
383 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
384 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
385 |
|
|
386 |
return err;
|
|
387 |
}
|
|
388 |
|
|
389 |
// -----------------------------------------------------------------------------
|
|
390 |
// CHsCcApiClient::AppListL
|
|
391 |
// -----------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
TInt CHsCcApiClient::AppListL( CHsContentInfoArray& aArray )
|
|
394 |
{
|
|
395 |
TInt err( KErrNone );
|
|
396 |
|
|
397 |
// Create AppListReq API request
|
|
398 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
399 |
CleanupStack::PushL( reqMsg );
|
|
400 |
reqMsg->SetMsgId( EHsCcAppListReq );
|
|
401 |
reqMsg->SetTrId( 0 );
|
|
402 |
reqMsg->SetData( KNullDesC8() );
|
|
403 |
|
|
404 |
// Marshal API request
|
|
405 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
406 |
CleanupStack::PushL( msgBuf );
|
|
407 |
TPtr8 msgPtr( NULL, 0 );
|
|
408 |
msgPtr.Set( msgBuf->Des() );
|
|
409 |
|
|
410 |
// Send API request
|
|
411 |
// Sender and receiver address not defined -> message is routed
|
|
412 |
// according to the provider id
|
|
413 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
414 |
TPckgBuf<TUint32> sender;
|
|
415 |
TPckgBuf<TUint32> receiver;
|
|
416 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
417 |
|
|
418 |
if ( !err )
|
|
419 |
{
|
|
420 |
// Internalize response message
|
|
421 |
TUint32 trId;
|
|
422 |
TUint32 dataSize;
|
|
423 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
424 |
if ( !err && dataSize )
|
|
425 |
{
|
|
426 |
// Internalize API response data
|
|
427 |
err = InternalizeContentInfoArrayL( aArray, trId, dataSize );
|
|
428 |
}
|
|
429 |
}
|
|
430 |
|
|
431 |
// Cleanup
|
|
432 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
433 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
434 |
|
|
435 |
return err;
|
|
436 |
}
|
|
437 |
|
|
438 |
// -----------------------------------------------------------------------------
|
|
439 |
// CHsCcApiClient::AddWidgetL
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
TInt CHsCcApiClient::AddWidgetL( CHsContentInfo& aInfo )
|
|
443 |
{
|
|
444 |
TInt err( KErrNone );
|
|
445 |
|
|
446 |
// Create AddWidgetReq API request
|
|
447 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
448 |
CleanupStack::PushL( reqMsg );
|
|
449 |
reqMsg->SetMsgId( EHsCcAddWidgetReq );
|
|
450 |
reqMsg->SetTrId( 0 );
|
|
451 |
|
|
452 |
// Marshal AddWidgetReq data to a descriptor
|
|
453 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
454 |
TPtr8 dataPtr( NULL, 0 );
|
|
455 |
dataPtr.Set( dataBuf->Des() );
|
|
456 |
reqMsg->SetData( dataPtr );
|
|
457 |
|
|
458 |
delete dataBuf;
|
|
459 |
dataBuf = NULL;
|
|
460 |
|
|
461 |
// Marshal API request
|
|
462 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
463 |
CleanupStack::PushL( msgBuf );
|
|
464 |
TPtr8 msgPtr( NULL, 0 );
|
|
465 |
msgPtr.Set( msgBuf->Des() );
|
|
466 |
|
|
467 |
// Send API request
|
|
468 |
// Sender and receiver address not defined -> message is routed
|
|
469 |
// according to the provider id
|
|
470 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
471 |
TPckgBuf<TUint32> sender;
|
|
472 |
TPckgBuf<TUint32> receiver;
|
|
473 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
474 |
|
|
475 |
if ( !err )
|
|
476 |
{
|
|
477 |
// Internalize response message
|
|
478 |
TUint32 trId;
|
|
479 |
TUint32 dataSize;
|
|
480 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
481 |
}
|
|
482 |
|
|
483 |
// Cleanup
|
|
484 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
485 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
486 |
|
|
487 |
return err;
|
|
488 |
}
|
|
489 |
|
|
490 |
// -----------------------------------------------------------------------------
|
|
491 |
// CHsCcApiClient::RemoveWidgetL
|
|
492 |
// -----------------------------------------------------------------------------
|
|
493 |
//
|
|
494 |
TInt CHsCcApiClient::RemoveWidgetL( CHsContentInfo& aInfo )
|
|
495 |
{
|
|
496 |
TInt err( KErrNone );
|
|
497 |
|
|
498 |
// Create RemoveWidgetReq API request
|
|
499 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
500 |
CleanupStack::PushL( reqMsg );
|
|
501 |
reqMsg->SetMsgId( EHsCcRemoveWidgetReq );
|
|
502 |
reqMsg->SetTrId( 0 );
|
|
503 |
|
|
504 |
// Marshal RemoveWidgetReq data to a descriptor
|
|
505 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
506 |
TPtr8 dataPtr( NULL, 0 );
|
|
507 |
dataPtr.Set( dataBuf->Des() );
|
|
508 |
reqMsg->SetData( dataPtr );
|
|
509 |
|
|
510 |
delete dataBuf;
|
|
511 |
dataBuf = NULL;
|
|
512 |
|
|
513 |
// Marshal API request
|
|
514 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
515 |
CleanupStack::PushL( msgBuf );
|
|
516 |
TPtr8 msgPtr( NULL, 0 );
|
|
517 |
msgPtr.Set( msgBuf->Des() );
|
|
518 |
|
|
519 |
// Send API request
|
|
520 |
// Sender and receiver address not defined -> message is routed
|
|
521 |
// according to the provider id
|
|
522 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
523 |
TPckgBuf<TUint32> sender;
|
|
524 |
TPckgBuf<TUint32> receiver;
|
|
525 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
526 |
|
|
527 |
if ( !err )
|
|
528 |
{
|
|
529 |
// Internalize response message
|
|
530 |
TUint32 trId;
|
|
531 |
TUint32 dataSize;
|
|
532 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
533 |
}
|
|
534 |
|
|
535 |
// Cleanup
|
|
536 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
537 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
538 |
|
|
539 |
return err;
|
|
540 |
}
|
|
541 |
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
// CHsCcApiClient::AddViewL
|
|
544 |
// -----------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
TInt CHsCcApiClient::AddViewL( CHsContentInfo& aInfo )
|
|
547 |
{
|
|
548 |
TInt err( KErrNone );
|
|
549 |
|
|
550 |
// Create AddViewReq API request
|
|
551 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
552 |
CleanupStack::PushL( reqMsg );
|
|
553 |
reqMsg->SetMsgId( EHsCcAddViewReq );
|
|
554 |
reqMsg->SetTrId( 0 );
|
|
555 |
|
|
556 |
// Marshal AddViewReq data to a descriptor
|
|
557 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
558 |
TPtr8 dataPtr( NULL, 0 );
|
|
559 |
dataPtr.Set( dataBuf->Des() );
|
|
560 |
reqMsg->SetData( dataPtr );
|
|
561 |
|
|
562 |
delete dataBuf;
|
|
563 |
dataBuf = NULL;
|
|
564 |
|
|
565 |
// Marshal API request
|
|
566 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
567 |
CleanupStack::PushL( msgBuf );
|
|
568 |
TPtr8 msgPtr( NULL, 0 );
|
|
569 |
msgPtr.Set( msgBuf->Des() );
|
|
570 |
|
|
571 |
// Send API request
|
|
572 |
// Sender and receiver address not defined -> message is routed
|
|
573 |
// according to the provider id
|
|
574 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
575 |
TPckgBuf<TUint32> sender;
|
|
576 |
TPckgBuf<TUint32> receiver;
|
|
577 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
578 |
|
|
579 |
if ( !err )
|
|
580 |
{
|
|
581 |
// Internalize response message
|
|
582 |
TUint32 trId;
|
|
583 |
TUint32 dataSize;
|
|
584 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
585 |
}
|
|
586 |
|
|
587 |
// Cleanup
|
|
588 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
589 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
590 |
|
|
591 |
return err;
|
|
592 |
}
|
|
593 |
|
|
594 |
// -----------------------------------------------------------------------------
|
|
595 |
// CHsCcApiClient::RemoveViewL
|
|
596 |
// -----------------------------------------------------------------------------
|
|
597 |
//
|
|
598 |
TInt CHsCcApiClient::RemoveViewL( CHsContentInfo& aInfo )
|
|
599 |
{
|
|
600 |
TInt err( KErrNone );
|
|
601 |
|
|
602 |
// Create RemoveViewReq API request
|
|
603 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
604 |
CleanupStack::PushL( reqMsg );
|
|
605 |
reqMsg->SetMsgId( EHsCcRemoveViewReq );
|
|
606 |
reqMsg->SetTrId( 0 );
|
|
607 |
|
|
608 |
// Marshal RemoveViewReq data to a descriptor
|
|
609 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
610 |
TPtr8 dataPtr( NULL, 0 );
|
|
611 |
dataPtr.Set( dataBuf->Des() );
|
|
612 |
reqMsg->SetData( dataPtr );
|
|
613 |
|
|
614 |
delete dataBuf;
|
|
615 |
dataBuf = NULL;
|
|
616 |
|
|
617 |
// Marshal API request
|
|
618 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
619 |
CleanupStack::PushL( msgBuf );
|
|
620 |
TPtr8 msgPtr( NULL, 0 );
|
|
621 |
msgPtr.Set( msgBuf->Des() );
|
|
622 |
|
|
623 |
// Send API request
|
|
624 |
// Sender and receiver address not defined -> message is routed
|
|
625 |
// according to the provider id
|
|
626 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
627 |
TPckgBuf<TUint32> sender;
|
|
628 |
TPckgBuf<TUint32> receiver;
|
|
629 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
630 |
|
|
631 |
if ( !err )
|
|
632 |
{
|
|
633 |
// Internalize response message
|
|
634 |
TUint32 trId;
|
|
635 |
TUint32 dataSize;
|
|
636 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
637 |
}
|
|
638 |
|
|
639 |
// Cleanup
|
|
640 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
641 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
642 |
|
|
643 |
return err;
|
|
644 |
}
|
|
645 |
|
|
646 |
// -----------------------------------------------------------------------------
|
|
647 |
// CHsCcApiClient::ActivateViewL
|
|
648 |
// -----------------------------------------------------------------------------
|
|
649 |
//
|
|
650 |
TInt CHsCcApiClient::ActivateViewL( CHsContentInfo& aInfo )
|
|
651 |
{
|
|
652 |
TInt err( KErrNone );
|
|
653 |
|
|
654 |
// Create ActivateViewReq API request
|
|
655 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
656 |
CleanupStack::PushL( reqMsg );
|
|
657 |
reqMsg->SetMsgId( EHsCcActivateViewReq );
|
|
658 |
reqMsg->SetTrId( 0 );
|
|
659 |
|
|
660 |
// Marshal ActivateViewReq data to a descriptor
|
|
661 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
662 |
TPtr8 dataPtr( NULL, 0 );
|
|
663 |
dataPtr.Set( dataBuf->Des() );
|
|
664 |
reqMsg->SetData( dataPtr );
|
|
665 |
|
|
666 |
delete dataBuf;
|
|
667 |
dataBuf = NULL;
|
|
668 |
|
|
669 |
// Marshal API request
|
|
670 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
671 |
CleanupStack::PushL( msgBuf );
|
|
672 |
TPtr8 msgPtr( NULL, 0 );
|
|
673 |
msgPtr.Set( msgBuf->Des() );
|
|
674 |
|
|
675 |
// Send API request
|
|
676 |
// Sender and receiver address not defined -> message is routed
|
|
677 |
// according to the provider id
|
|
678 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
679 |
TPckgBuf<TUint32> sender;
|
|
680 |
TPckgBuf<TUint32> receiver;
|
|
681 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
682 |
|
|
683 |
if ( !err )
|
|
684 |
{
|
|
685 |
// Internalize response message
|
|
686 |
TUint32 trId;
|
|
687 |
TUint32 dataSize;
|
|
688 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
689 |
}
|
|
690 |
|
|
691 |
// Cleanup
|
|
692 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
693 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
694 |
|
|
695 |
return err;
|
|
696 |
}
|
|
697 |
|
|
698 |
// -----------------------------------------------------------------------------
|
|
699 |
// CHsCcApiClient::ActivateAppL
|
|
700 |
// -----------------------------------------------------------------------------
|
|
701 |
//
|
|
702 |
TInt CHsCcApiClient::ActivateAppL( CHsContentInfo& aInfo )
|
|
703 |
{
|
|
704 |
TInt err( KErrNone );
|
|
705 |
|
|
706 |
// Create ActivateAppReq API request
|
|
707 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
708 |
CleanupStack::PushL( reqMsg );
|
|
709 |
reqMsg->SetMsgId( EHsCcActivateAppReq );
|
|
710 |
reqMsg->SetTrId( 0 );
|
|
711 |
|
|
712 |
// Marshal ActivateAppReq data to a descriptor
|
|
713 |
HBufC8* dataBuf = aInfo.MarshalL();
|
|
714 |
TPtr8 dataPtr( NULL, 0 );
|
|
715 |
dataPtr.Set( dataBuf->Des() );
|
|
716 |
reqMsg->SetData( dataPtr );
|
|
717 |
|
|
718 |
delete dataBuf;
|
|
719 |
dataBuf = NULL;
|
|
720 |
|
|
721 |
// Marshal API request
|
|
722 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
723 |
CleanupStack::PushL( msgBuf );
|
|
724 |
TPtr8 msgPtr( NULL, 0 );
|
|
725 |
msgPtr.Set( msgBuf->Des() );
|
|
726 |
|
|
727 |
// Send API request
|
|
728 |
// Sender and receiver address not defined -> message is routed
|
|
729 |
// according to the provider id
|
|
730 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
731 |
TPckgBuf<TUint32> sender;
|
|
732 |
TPckgBuf<TUint32> receiver;
|
|
733 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
734 |
|
|
735 |
if ( !err )
|
|
736 |
{
|
|
737 |
// Internalize response message
|
|
738 |
TUint32 trId;
|
|
739 |
TUint32 dataSize;
|
|
740 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
741 |
}
|
|
742 |
|
|
743 |
// Cleanup
|
|
744 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
745 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
746 |
|
|
747 |
return err;
|
|
748 |
}
|
|
749 |
|
|
750 |
// -----------------------------------------------------------------------------
|
|
751 |
// CHsCcApiClient::ActiveViewL
|
|
752 |
// -----------------------------------------------------------------------------
|
|
753 |
//
|
|
754 |
TInt CHsCcApiClient::ActiveViewL( CHsContentInfo& aInfo )
|
|
755 |
{
|
|
756 |
TInt err( KErrNone );
|
|
757 |
|
|
758 |
// Create ActiveViewReq API request
|
|
759 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
760 |
CleanupStack::PushL( reqMsg );
|
|
761 |
reqMsg->SetMsgId( EHsCcActiveViewReq );
|
|
762 |
reqMsg->SetTrId( 0 );
|
|
763 |
reqMsg->SetData( KNullDesC8() );
|
|
764 |
|
|
765 |
// Marshal API request
|
|
766 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
767 |
CleanupStack::PushL( msgBuf );
|
|
768 |
TPtr8 msgPtr( NULL, 0 );
|
|
769 |
msgPtr.Set( msgBuf->Des() );
|
|
770 |
|
|
771 |
// Send API request
|
|
772 |
// Sender and receiver address not defined -> message is routed
|
|
773 |
// according to the provider id
|
|
774 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
775 |
TPckgBuf<TUint32> sender;
|
|
776 |
TPckgBuf<TUint32> receiver;
|
|
777 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
778 |
|
|
779 |
if ( !err )
|
|
780 |
{
|
|
781 |
// Internalize response message
|
|
782 |
TUint32 trId;
|
|
783 |
TUint32 dataSize;
|
|
784 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
785 |
if ( !err && dataSize )
|
|
786 |
{
|
|
787 |
// Internalize API response data
|
|
788 |
err = InternalizeContentInfoL( aInfo, trId, dataSize );
|
|
789 |
}
|
|
790 |
}
|
|
791 |
|
|
792 |
// Cleanup
|
|
793 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
794 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
795 |
|
|
796 |
return err;
|
|
797 |
}
|
|
798 |
|
|
799 |
// -----------------------------------------------------------------------------
|
|
800 |
// CHsCcApiClient::ActiveAppL
|
|
801 |
// -----------------------------------------------------------------------------
|
|
802 |
//
|
|
803 |
TInt CHsCcApiClient::ActiveAppL( CHsContentInfo& aInfo )
|
|
804 |
{
|
|
805 |
TInt err( KErrNone );
|
|
806 |
|
|
807 |
// Create ActiveViewReq API request
|
|
808 |
CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
|
|
809 |
CleanupStack::PushL( reqMsg );
|
|
810 |
reqMsg->SetMsgId( EHsCcActiveAppReq );
|
|
811 |
reqMsg->SetTrId( 0 );
|
|
812 |
reqMsg->SetData( KNullDesC8() );
|
|
813 |
|
|
814 |
// Marshal API request
|
|
815 |
HBufC8* msgBuf = reqMsg->MarshalL();
|
|
816 |
CleanupStack::PushL( msgBuf );
|
|
817 |
TPtr8 msgPtr( NULL, 0 );
|
|
818 |
msgPtr.Set( msgBuf->Des() );
|
|
819 |
|
|
820 |
// Send API request
|
|
821 |
// Sender and receiver address not defined -> message is routed
|
|
822 |
// according to the provider id
|
|
823 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
824 |
TPckgBuf<TUint32> sender;
|
|
825 |
TPckgBuf<TUint32> receiver;
|
|
826 |
err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
|
|
827 |
|
|
828 |
if ( !err )
|
|
829 |
{
|
|
830 |
// Internalize response message
|
|
831 |
TUint32 trId;
|
|
832 |
TUint32 dataSize;
|
|
833 |
err = InternalizeRespL( msgPtr, trId, dataSize );
|
|
834 |
if ( !err && dataSize )
|
|
835 |
{
|
|
836 |
// Internalize API response data
|
|
837 |
err = InternalizeContentInfoL( aInfo, trId, dataSize );
|
|
838 |
}
|
|
839 |
}
|
|
840 |
|
|
841 |
// Cleanup
|
|
842 |
CleanupStack::PopAndDestroy( msgBuf );
|
|
843 |
CleanupStack::PopAndDestroy( reqMsg );
|
|
844 |
|
|
845 |
return err;
|
|
846 |
}
|
|
847 |
|
|
848 |
// -----------------------------------------------------------------------------
|
|
849 |
// CHsCcApiClient::WaitForApiNtfL()
|
|
850 |
// -----------------------------------------------------------------------------
|
|
851 |
//
|
|
852 |
void CHsCcApiClient::WaitForApiNtfL()
|
|
853 |
{
|
|
854 |
|
|
855 |
if ( iApiHeader )
|
|
856 |
{
|
|
857 |
delete iApiHeader;
|
|
858 |
iApiHeader = NULL;
|
|
859 |
}
|
|
860 |
iApiHeader = HBufC8::NewL( KCcHeaderSize );
|
|
861 |
iApiHeaderPtr.Set( iApiHeader->Des() );
|
|
862 |
|
|
863 |
TPckgBuf<TUint32> provider( ECcHomescreen );
|
|
864 |
iPckgSender = 0;
|
|
865 |
iPckgReceiver = 0;
|
|
866 |
|
|
867 |
iSession.WaitForApiNtf( provider, iPckgSender, iPckgReceiver, iApiHeaderPtr, iStatus );
|
|
868 |
SetActive();
|
|
869 |
|
|
870 |
}
|
|
871 |
|
|
872 |
// -----------------------------------------------------------------------------
|
|
873 |
// CHsCcApiClient::InternalizeRespL()
|
|
874 |
// -----------------------------------------------------------------------------
|
|
875 |
//
|
|
876 |
TInt CHsCcApiClient::InternalizeRespL(
|
|
877 |
TPtr8& aResp, TUint32& aTrId, TUint32& aDataSize )
|
|
878 |
{
|
|
879 |
TInt err( KErrNone );
|
|
880 |
|
|
881 |
CCcSrvMsg* respMsg = CCcSrvMsg::NewL();
|
|
882 |
CleanupStack::PushL( respMsg );
|
|
883 |
RDesReadStream respStream( aResp );
|
|
884 |
CleanupClosePushL( respStream );
|
|
885 |
respMsg->InternalizeHeaderL( respStream );
|
|
886 |
CleanupStack::PopAndDestroy( &respStream );
|
|
887 |
err = respMsg->Status();
|
|
888 |
aTrId = respMsg->TrId();
|
|
889 |
aDataSize = respMsg->DataSize();
|
|
890 |
CleanupStack::PopAndDestroy( respMsg );
|
|
891 |
|
|
892 |
return err;
|
|
893 |
}
|
|
894 |
|
|
895 |
// -----------------------------------------------------------------------------
|
|
896 |
// CHsCcApiClient::InternalizeContentInfoL()
|
|
897 |
// -----------------------------------------------------------------------------
|
|
898 |
//
|
|
899 |
TInt CHsCcApiClient::InternalizeContentInfoL(
|
|
900 |
CHsContentInfo& aInfo, TUint32 aTrId, TUint32 aDataSize )
|
|
901 |
{
|
|
902 |
TInt err( KErrNone );
|
|
903 |
|
|
904 |
HBufC8* dataBuf = HBufC8::NewL( aDataSize );
|
|
905 |
CleanupStack::PushL( dataBuf );
|
|
906 |
TPtr8 dataPtr( NULL, 0 );
|
|
907 |
dataPtr.Set( dataBuf->Des() );
|
|
908 |
TPckgBuf<TUint32> trId( aTrId );
|
|
909 |
err = iSession.GetMsgData( trId, dataPtr );
|
|
910 |
if ( !err )
|
|
911 |
{
|
|
912 |
// Internalize API response data
|
|
913 |
RDesReadStream dataStream( dataPtr );
|
|
914 |
CleanupClosePushL( dataStream );
|
|
915 |
aInfo.InternalizeL( dataStream );
|
|
916 |
CleanupStack::PopAndDestroy( &dataStream );
|
|
917 |
}
|
|
918 |
CleanupStack::PopAndDestroy( dataBuf );
|
|
919 |
|
|
920 |
return err;
|
|
921 |
}
|
|
922 |
|
|
923 |
// -----------------------------------------------------------------------------
|
|
924 |
// CHsCcApiClient::InternalizeContentInfoArrayL()
|
|
925 |
// -----------------------------------------------------------------------------
|
|
926 |
//
|
|
927 |
TInt CHsCcApiClient::InternalizeContentInfoArrayL(
|
|
928 |
CHsContentInfoArray& aInfo, TUint32 aTrId, TUint32 aDataSize )
|
|
929 |
{
|
|
930 |
TInt err( KErrNone );
|
|
931 |
|
|
932 |
HBufC8* dataBuf = HBufC8::NewL( aDataSize );
|
|
933 |
CleanupStack::PushL( dataBuf );
|
|
934 |
TPtr8 dataPtr( NULL, 0 );
|
|
935 |
dataPtr.Set( dataBuf->Des() );
|
|
936 |
TPckgBuf<TUint32> trId( aTrId );
|
|
937 |
err = iSession.GetMsgData( trId, dataPtr );
|
|
938 |
if ( !err )
|
|
939 |
{
|
|
940 |
// Internalize API response data
|
|
941 |
RDesReadStream dataStream( dataPtr );
|
|
942 |
CleanupClosePushL( dataStream );
|
|
943 |
aInfo.InternalizeL( dataStream );
|
|
944 |
CleanupStack::PopAndDestroy( &dataStream );
|
|
945 |
}
|
|
946 |
CleanupStack::PopAndDestroy( dataBuf );
|
|
947 |
|
|
948 |
return err;
|
|
949 |
}
|
|
950 |
|
|
951 |
// End of file
|