1 /* |
|
2 * Copyright (c) 2006-2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32strm.h> |
|
20 |
|
21 #include "ircommon.h" |
|
22 #include "irdebug.h" |
|
23 #include "irmetadata.h" |
|
24 #include "irpropertyobserver.h" |
|
25 #include "irpubsub.h" |
|
26 |
|
27 /** |
|
28 *C++ default constructor can NOT contain any code, that |
|
29 * might leave. |
|
30 */ |
|
31 CIRPubSub::CIRPubSub() |
|
32 { |
|
33 IRLOG_DEBUG( "CIRPubSub::CIRPubSub" ); |
|
34 } |
|
35 |
|
36 /** |
|
37 * Function: ConstructL |
|
38 * Symbian 2nd phase constructor can leave. |
|
39 */ |
|
40 |
|
41 void CIRPubSub::ConstructL() |
|
42 { |
|
43 IRLOG_DEBUG( "CIRPubSub::ConstructL - Entering" ); |
|
44 // Define data properties. |
|
45 DefinePropertyL( KIRPSDataApplicationRunning, RProperty::EInt, ETrue ); |
|
46 DefinePropertyL( KIRPSPresetIndex, RProperty::EInt, ETrue ); |
|
47 DefinePropertyL( KIRPSDataChannel, RProperty::ELargeText, ETrue ); |
|
48 DefinePropertyL( KIRPSMetaData, RProperty::ELargeText, ETrue ); |
|
49 DefinePropertyL( KIRPSVolume, RProperty::EInt, ETrue ); |
|
50 DefinePropertyL( KIRPSPlayStop, RProperty::EInt, ETrue ); |
|
51 DefinePropertyL( KIRPSChannelUrl, RProperty::ELargeText, ETrue ); |
|
52 DefinePropertyL( KIRPSBitrate, RProperty::EInt, ETrue ); |
|
53 DefinePropertyL( KIRPSMultiplePlay, RProperty::EInt, ETrue ); |
|
54 DefinePropertyL( KIRPSStationName, RProperty::ELargeText, ETrue ); |
|
55 DefinePropertyL( KIRPSAppInstanceRunning, RProperty::EInt, ETrue ); |
|
56 DefinePropertyL( KIRPSChannelType, RProperty::EInt, ETrue ); |
|
57 DefinePropertyL( KIRPSChannelId, RProperty::EInt, ETrue ); |
|
58 DefinePropertyL( KIRPSDataChannelDesc, RProperty::ELargeText, ETrue ); |
|
59 DefinePropertyL( KIRPSChannelMusicFlag, RProperty::ELargeText, ETrue ); |
|
60 DefinePropertyL( KIRPSBufferingState, RProperty::EInt, ETrue ); |
|
61 //Gets the integer value for the property KIRPSAppInstanceRunning |
|
62 //which gives the number of instances of iRapp running |
|
63 RProperty::Get( KUidActiveInternetRadioApp,KIRPSAppInstanceRunning,iApplicationInstanceCount); |
|
64 //Increment the count and set the integer value for the property |
|
65 //KIRPSAppInstanceRunning to track the number of instances of iRapp |
|
66 //running |
|
67 iApplicationInstanceCount++; |
|
68 RProperty::Set( KUidActiveInternetRadioApp,KIRPSAppInstanceRunning,iApplicationInstanceCount); |
|
69 DefinePropertyL( KIRPSControlSetPlayState, RProperty::EInt, EFalse ); |
|
70 |
|
71 IRLOG_DEBUG( "CIRPubSub::ConstructL - Exiting." ); |
|
72 } |
|
73 |
|
74 /** |
|
75 * Function: NewL |
|
76 * Two-phased constructor. |
|
77 * @return An Instance of CIRBufferingControl |
|
78 */ |
|
79 CIRPubSub* CIRPubSub::NewL() |
|
80 { |
|
81 IRLOG_DEBUG( "CIRPubSub::NewL - Entering" ); |
|
82 CIRPubSub* self = new (ELeave) CIRPubSub(); |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(); |
|
85 CleanupStack::Pop(self); |
|
86 IRLOG_DEBUG( "CIRPubSub::NewL - Exiting." ); |
|
87 return self; |
|
88 } |
|
89 |
|
90 |
|
91 /** |
|
92 * Function: ~CIRPubSub |
|
93 * Destructs all the Property Instances |
|
94 */ |
|
95 CIRPubSub::~CIRPubSub() |
|
96 { |
|
97 IRLOG_DEBUG( "CIRPubSub::~CIRPubSub - Entering" ); |
|
98 iPropertyArray.ResetAndDestroy(); |
|
99 iPropertyArray.Close(); |
|
100 RProperty::Get( KUidActiveInternetRadioApp,KIRPSAppInstanceRunning,iApplicationInstanceCount); |
|
101 iApplicationInstanceCount--; |
|
102 |
|
103 //Delete the property only when one instance of iRapp is running |
|
104 if(!iApplicationInstanceCount ) |
|
105 { |
|
106 DeleteProperty( KIRPSDataApplicationRunning ); |
|
107 DeleteProperty( KIRPSDataChannel ); |
|
108 DeleteProperty( KIRPSMetaData ); |
|
109 DeleteProperty( KIRPSPresetIndex ); |
|
110 DeleteProperty( KIRPSVolume ); |
|
111 DeleteProperty( KIRPSPlayStop ); |
|
112 DeleteProperty( KIRPSChannelUrl ); |
|
113 DeleteProperty( KIRPSBitrate ); |
|
114 DeleteProperty( KIRPSMultiplePlay ); |
|
115 DeleteProperty( KIRPSStationName ); |
|
116 DeleteProperty( KIRPSAppInstanceRunning ); |
|
117 DeleteProperty( KIRPSChannelType ); |
|
118 DeleteProperty( KIRPSChannelId ); |
|
119 DeleteProperty( KIRPSDataChannelDesc ); |
|
120 DeleteProperty( KIRPSChannelMusicFlag ); |
|
121 DeleteProperty( KIRPSControlSetPlayState ); |
|
122 DeleteProperty( KIRPSBufferingState ); |
|
123 } |
|
124 RProperty::Set( KUidActiveInternetRadioApp,KIRPSAppInstanceRunning,iApplicationInstanceCount); |
|
125 |
|
126 IRLOG_DEBUG( "CIRPubSub::~CIRPubSub - Exiting." ); |
|
127 } |
|
128 |
|
129 /* |
|
130 * CIRPubSub::DefinePropertyL |
|
131 * Defines a property. |
|
132 */ |
|
133 void CIRPubSub::DefinePropertyL( TUint aKey, TInt aAttr, TBool aDataProperty ) |
|
134 const |
|
135 { |
|
136 IRLOG_DEBUG( "CIRPubSub::DefinePropertyL - Entering" ); |
|
137 _LIT_SECURITY_POLICY_PASS(KIRExternalAccessPolicy); |
|
138 _LIT_SECURITY_POLICY_S0(KIRInternalAccessPolicy, KUIDIRAPP); |
|
139 |
|
140 TInt err = KErrNone; |
|
141 if(aDataProperty) |
|
142 { |
|
143 // For data properties, grant read access for all, but write access only for iRAPP |
|
144 err = RProperty::Define( KUidActiveInternetRadioApp, aKey, aAttr, |
|
145 KIRExternalAccessPolicy, KIRInternalAccessPolicy ); |
|
146 } |
|
147 else |
|
148 { |
|
149 // For control properties, grant read access only for IRA, but write access for all |
|
150 err = RProperty::Define( KUidActiveInternetRadioApp, aKey, aAttr, |
|
151 KIRInternalAccessPolicy, KIRExternalAccessPolicy ); |
|
152 } |
|
153 if ( err && err != KErrAlreadyExists ) |
|
154 { |
|
155 User::Leave( err ); |
|
156 } |
|
157 IRLOG_DEBUG( "CIRPubSub::DefinePropertyL - Exiting." ); |
|
158 } |
|
159 |
|
160 /* |
|
161 * CIRPubSub::DeleteProperty |
|
162 * Deletes a property |
|
163 */ |
|
164 |
|
165 void CIRPubSub::DeleteProperty( TUint aKey ) const |
|
166 { |
|
167 IRLOG_DEBUG( "CIRPubSub::DeleteProperty Entering" ); |
|
168 RProperty::Delete( KUidActiveInternetRadioApp, aKey ); |
|
169 IRLOG_DEBUG( "CIRPubSub::DeleteProperty - Exiting." ); |
|
170 } |
|
171 |
|
172 |
|
173 /* |
|
174 * CIRPubSub::PublishChannel |
|
175 * Publishes the property value for key KIRPSDataChannel |
|
176 */ |
|
177 |
|
178 void CIRPubSub::PublishChannel(const TDesC16& aChannelName ) const |
|
179 { |
|
180 IRLOG_DEBUG( "CIRPubSub::PublishChannel - Entering" ); |
|
181 RProperty::Set( KUidActiveInternetRadioApp, KIRPSDataChannel, |
|
182 aChannelName ); |
|
183 IRLOG_DEBUG( "CIRPubSub::PublishChannel - Exiting." ); |
|
184 } |
|
185 |
|
186 /* |
|
187 * CIRPubSub::PublishVolumeL |
|
188 * Publishes the property value for key KIRPSVolume |
|
189 */ |
|
190 |
|
191 void CIRPubSub::PublishVolume( TInt aVol ) const |
|
192 { |
|
193 IRLOG_DEBUG( "CIRPubSub::PublishVolumeL - Entering" ); |
|
194 RProperty::Set( KUidActiveInternetRadioApp, KIRPSVolume , aVol ); |
|
195 IRLOG_DEBUG( "CIRPubSub::PublishVolumeL - Exiting." ); |
|
196 } |
|
197 |
|
198 /* |
|
199 * CIRPubSub::PublishPlayStop |
|
200 * Publishes the property value for playing status |
|
201 */ |
|
202 void CIRPubSub::PublishPlayStop ( TIRStopPlayState aPlayingState ) const |
|
203 { |
|
204 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Entering" ); |
|
205 RProperty::Set( KUidActiveInternetRadioApp, KIRPSPlayStop, aPlayingState ); |
|
206 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Exiting." ); |
|
207 } |
|
208 |
|
209 /* |
|
210 * CIRPubSub::PublishApplicationRunningStateL |
|
211 * Publishes the property value for key KIRPSVolume |
|
212 */ |
|
213 |
|
214 void CIRPubSub::PublishApplicationRunningStateL( TIRPSApplicationRunningState |
|
215 aRunningState ) const |
|
216 { |
|
217 IRLOG_DEBUG( "CIRPubSub::ConstructL - Entering" ); |
|
218 User::LeaveIfError( RProperty::Set( KUidActiveInternetRadioApp, |
|
219 KIRPSDataApplicationRunning, aRunningState ) ); |
|
220 IRLOG_DEBUG( "CIRPubSub::ConstructL - Exiting." ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // Publishes meta data information. |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CIRPubSub::PublishMetaDataL( const CIRMetaData& aMetaData ) const |
|
228 { |
|
229 IRLOG_INFO4( "CIRPubSub::PublishMetaDataL( aMetaData.Artist()=%S, aMetaData.Song()=%S, aMetaData.StreamUrl()=%S )", |
|
230 &aMetaData.Artist(), &aMetaData.Song(), &aMetaData.StreamUrl() ); |
|
231 |
|
232 HBufC8* buffer = HBufC8::NewLC( aMetaData.Artist().Size() + aMetaData.Song().Size() + |
|
233 aMetaData.StreamUrl().Size() ); |
|
234 |
|
235 TPtr8 bufferPtr( buffer->Des() ); |
|
236 |
|
237 RDesWriteStream stream( bufferPtr ); |
|
238 CleanupClosePushL( stream ); |
|
239 |
|
240 aMetaData.ExternalizeL( stream ); |
|
241 User::LeaveIfError( RProperty::Set( KUidActiveInternetRadioApp, KIRPSMetaData, bufferPtr ) ); |
|
242 |
|
243 CleanupStack::PopAndDestroy(&stream); |
|
244 CleanupStack::PopAndDestroy( buffer ); |
|
245 |
|
246 IRLOG_DEBUG( "CIRPubSub::PublishMetaDataL - Exit" ); |
|
247 } |
|
248 |
|
249 /* |
|
250 * CIRPubSub::PublishChannelType |
|
251 * Publishes the property value for KIRPSChannelType |
|
252 */ |
|
253 void CIRPubSub::PublishChannelType ( TInt aChannelType ) const |
|
254 { |
|
255 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Entering" ); |
|
256 RProperty::Set( KUidActiveInternetRadioApp, KIRPSChannelType, aChannelType ); |
|
257 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Exiting." ); |
|
258 } |
|
259 |
|
260 /* |
|
261 * CIRPubSub::PublishChannelId |
|
262 * Publishes the property value for KIRPSChannelId |
|
263 */ |
|
264 void CIRPubSub::PublishChannelId ( TInt aChannelId ) const |
|
265 { |
|
266 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Entering" ); |
|
267 RProperty::Set( KUidActiveInternetRadioApp, KIRPSChannelId, aChannelId ); |
|
268 IRLOG_DEBUG( "CIRPubSub::PublishPlayStop - Exiting." ); |
|
269 } |
|
270 |
|
271 /* |
|
272 * CIRPubSub::PublishChannelDesc |
|
273 * Publishes the property value for key KIRPSDataChannel |
|
274 */ |
|
275 |
|
276 void CIRPubSub::PublishChannelDesc(const TDesC16& aChannelDesc ) const |
|
277 { |
|
278 IRLOG_DEBUG( "CIRPubSub::PublishChannel - Entering" ); |
|
279 RProperty::Set( KUidActiveInternetRadioApp, KIRPSDataChannelDesc, |
|
280 aChannelDesc ); |
|
281 IRLOG_DEBUG( "CIRPubSub::PublishChannel - Exiting." ); |
|
282 } |
|
283 /* |
|
284 * CIRPubSub::PublishChannelMusicFlag |
|
285 * Publishes the property value for key KIRPSChannelMusicFlag |
|
286 */ |
|
287 |
|
288 void CIRPubSub::PublishChannelMusicFlag(const TDesC16& aChannelMusicFlag ) const |
|
289 { |
|
290 IRLOG_DEBUG( "CIRPubSub::PublishChannelMusicFlag - Entering" ); |
|
291 RProperty::Set( KUidActiveInternetRadioApp, KIRPSChannelMusicFlag, |
|
292 aChannelMusicFlag ); |
|
293 IRLOG_DEBUG( "CIRPubSub::PublishChannelMusicFlag - Exiting." ); |
|
294 } |
|
295 /* |
|
296 * CIRPubSub::PublishBufferingState |
|
297 * Publishes the property value for key KIRPSBufferingState |
|
298 */ |
|
299 |
|
300 void CIRPubSub::PublishBufferingState(TIRBufferingState aState) const |
|
301 { |
|
302 IRLOG_DEBUG( "CIRPubSub::PublishBufferingState - Entering" ); |
|
303 RProperty::Set( KUidActiveInternetRadioApp, KIRPSBufferingState, |
|
304 aState ); |
|
305 IRLOG_DEBUG( "CIRPubSub::PublishBufferingState - Exiting." ); |
|
306 } |
|
307 // End of File |
|