|
1 /* |
|
2 * Copyright (c) 2002-2005 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 the License "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: Implements LiveTv Client API.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include <s32mem.h> |
|
24 #include "IptvLiveLogger.h" |
|
25 |
|
26 #include "IptvClientServerCommon.h" |
|
27 #include "CIptvLiveTvClient.h" |
|
28 #include "IptvServer.pan" |
|
29 |
|
30 // ============================= LOCAL FUNCTIONS =============================== |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CIptvLiveTvClient::CIptvLiveTvClient |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 CIptvLiveTvClient::CIptvLiveTvClient() : |
|
40 iMsgPtr( (unsigned char*)0, 0 ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CIptvLiveTvClient::ConstructL |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CIptvLiveTvClient::ConstructL() |
|
50 { |
|
51 LIVE_TV_TRACE1( _L("CIptvLiveTvClient::ConstructL")); |
|
52 TInt error( iSession.Connect() ); |
|
53 LIVE_TV_TRACE2( _L("iSession.Connect() returned %d"), error ); |
|
54 if( error != KErrNone ) |
|
55 { |
|
56 User::Leave( error ); |
|
57 } |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CIptvLiveTvClient::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CIptvLiveTvClient* CIptvLiveTvClient::NewL() |
|
66 { |
|
67 CIptvLiveTvClient* self = |
|
68 new ( ELeave ) CIptvLiveTvClient(); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CIptvLiveTvClient::~CIptvLiveTvClient |
|
77 // Destructor |
|
78 // ----------------------------------------------------------------------------- |
|
79 EXPORT_C CIptvLiveTvClient::~CIptvLiveTvClient() |
|
80 { |
|
81 iSession.Close(); |
|
82 if ( iMsg ) |
|
83 { |
|
84 delete iMsg; |
|
85 } |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CIptvLiveTvClient::UpdateEPG, asynchronous |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CIptvLiveTvClient::UpdateEPG( TUint32 /*aServiceProviderId*/, |
|
93 TRequestStatus& aStatus ) |
|
94 { |
|
95 LIVE_TV_TRACE1( _L("CIptvLiveTvClient::UpdateEPG()" ) ); |
|
96 iSession.SendRequest( EIptvEngineLiveTvUpdateEPGReq, aStatus ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CIptvLiveTvClient::UpdateChannelOrder, synchronous |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C TInt CIptvLiveTvClient::UpdateChannelOrderL( const TUint32 aServiceId, |
|
104 const TInt64 aChannelId, |
|
105 const TUint32 aOrder ) |
|
106 { |
|
107 LIVE_TV_TRACE4(_L("CIptvLiveTvClient::UpdateChannelOrder() in, aChannelId: %Li, aServiceId: %u, aOrder:%u"), aChannelId, aServiceId, aOrder ); |
|
108 delete iMsg; |
|
109 iMsg = NULL; |
|
110 |
|
111 iMsg = HBufC8::NewL( KIptvChannelOrderReqSize ); |
|
112 iMsgPtr.Set( iMsg->Des() ); |
|
113 RDesWriteStream stream; |
|
114 CleanupClosePushL( stream ); |
|
115 stream.Open( iMsgPtr ); |
|
116 stream.WriteUint32L( aServiceId ); |
|
117 stream << aChannelId; // Can leave too. Does this work with TInt64? |
|
118 stream.WriteUint32L( aOrder ); |
|
119 CleanupStack::PopAndDestroy( &stream ); // Closes stream |
|
120 |
|
121 return iSession.SendRequest( EIptvEngineLiveTvUpdateChannelReq, iMsgPtr ); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CIptvLiveTvClient::AddServiceIdL, asynchronous |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CIptvLiveTvClient::AddServiceIdL( TUint32 aServiceId, |
|
129 TRequestStatus& aStatus ) |
|
130 { |
|
131 delete iMsg; |
|
132 iMsg = NULL; |
|
133 |
|
134 iMsg = HBufC8::NewL( KIptvSizeRequestSize ); |
|
135 iMsgPtr.Set( iMsg->Des() ); |
|
136 RDesWriteStream stream; |
|
137 CleanupClosePushL( stream ); |
|
138 stream.Open( iMsgPtr ); |
|
139 stream.WriteUint32L( aServiceId ); |
|
140 CleanupStack::PopAndDestroy( &stream ); // closes stream |
|
141 |
|
142 iSession.SendRequest( EIptvEngineLiveTvContentServiceId, iMsgPtr, aStatus ); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CIptvLiveTvClient::SetIapL, synchronous |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C TInt CIptvLiveTvClient::SetIapL( TUint32 aIap ) |
|
150 { |
|
151 TBuf8<KIptvSizeRequestSize> buf; |
|
152 |
|
153 RDesWriteStream stream; |
|
154 CleanupClosePushL( stream ); |
|
155 stream.Open( buf ); |
|
156 stream.WriteUint32L( aIap ); |
|
157 CleanupStack::PopAndDestroy( &stream ); // closes stream |
|
158 |
|
159 return iSession.SendRequest( EIptvEngineLiveTvSetIap, buf ); |
|
160 } |