|
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 "irmetadata.h" |
|
20 #include "irpubsubkeys.h" |
|
21 |
|
22 #include "iractiveidleeng.h" |
|
23 #include "iractiveidleengnotifyhandler.h" |
|
24 #include "iractiveidleengpubsub.h" |
|
25 #include "irdebug.h" |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CIRActiveIdleEng::CIRActiveIdleEng |
|
30 // Default Constructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CIRActiveIdleEng::CIRActiveIdleEng( MIRActiveIdleEngNotifyHandler& aObserver ) |
|
34 : iObserver( aObserver ) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CIRActiveIdleEng::ConstructL |
|
40 // Second-phase constructor |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void CIRActiveIdleEng::ConstructL() |
|
44 { |
|
45 IRLOG_DEBUG( "CIRActiveIdleEng::ConstructL" ); |
|
46 //Subscriber for application running state |
|
47 User::LeaveIfError(iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
48 NewL( *this, KUidActiveInternetRadioApp, KIRPSDataApplicationRunning , |
|
49 RProperty::EInt) ) ); |
|
50 //Subsciber for meta data |
|
51 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
52 NewL( *this, KUidActiveInternetRadioApp, KIRPSMetaData, |
|
53 RProperty::ELargeText))); |
|
54 //Subsciber for the volume level |
|
55 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
56 NewL( *this, KUidActiveInternetRadioApp, KIRPSVolume , |
|
57 RProperty::EInt) ) ); |
|
58 //Subsciber for the key KIRPSPlayStop at stop state |
|
59 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
60 NewL( *this, KUidActiveInternetRadioApp, KIRPSPlayStop , |
|
61 RProperty::EInt) ) ); |
|
62 //Subsciber for the channel name |
|
63 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
64 NewL( *this, KUidActiveInternetRadioApp, KIRPSDataChannel, |
|
65 RProperty::ELargeText) ) ); |
|
66 //Subscriber for favourite channel preset index |
|
67 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
68 NewL( *this, KUidActiveInternetRadioApp, KIRPSPresetIndex , |
|
69 RProperty::EInt) ) ); |
|
70 |
|
71 //Subscriber for favourite channel preset index |
|
72 User::LeaveIfError( iPropertyObserverArray.Append( CIRActiveIdleEngPubSub:: |
|
73 NewL( *this, KUidActiveInternetRadioApp, KIRPSBufferingState , |
|
74 RProperty::EInt) ) ); |
|
75 IRLOG_DEBUG( "CIRActiveIdleEng::ConstructL - Exiting." ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CIRActiveIdleEng::SecondConstructL() |
|
80 // Finalizes the construction of the object |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C void CIRActiveIdleEng::SecondConstructL() |
|
84 { |
|
85 |
|
86 IRLOG_DEBUG( "CIRActiveIdleEng::SecondConstructL" ); |
|
87 for ( TInt i = 0; i < iPropertyObserverArray.Count(); i++ ) |
|
88 { |
|
89 iPropertyObserverArray[i]->SecondConstructL(); |
|
90 } |
|
91 IRLOG_DEBUG( "CIRActiveIdleEng::SecondConstructL - Exiting." ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CIRActiveIdleEng::NewL |
|
96 // Static constructor. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CIRActiveIdleEng* CIRActiveIdleEng::NewL( |
|
100 MIRActiveIdleEngNotifyHandler& aObserver ) |
|
101 { |
|
102 IRLOG_DEBUG( "CIRActiveIdleEng::NewL" ); |
|
103 CIRActiveIdleEng* self = new ( ELeave ) CIRActiveIdleEng( aObserver ); |
|
104 CleanupStack::PushL( self ); |
|
105 self->ConstructL(); |
|
106 CleanupStack::Pop( self ); |
|
107 IRLOG_DEBUG( "CIRActiveIdleEng::NewL - Exiting." ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CIRActiveIdleEng::~CIRActiveIdleEng() |
|
113 // standard C++ destructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CIRActiveIdleEng::~CIRActiveIdleEng() |
|
117 { |
|
118 IRLOG_DEBUG( "CIRActiveIdleEng::~CIRActiveIdleEng" ); |
|
119 iPropertyObserverArray.ResetAndDestroy(); |
|
120 iPropertyObserverArray.Close(); |
|
121 IRLOG_DEBUG( "CIRActiveIdleEng::~CIRActiveIdleEng - Exiting." ); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CIRActiveIdleEng::HandlePropertyChangeL |
|
126 // Invoked when any listened P&S key is changed. |
|
127 // --------------------------------------------------------------------------- |
|
128 void CIRActiveIdleEng::HandlePropertyChangeL( const TUid& aCategory, |
|
129 TUint aKey,const TDesC8& aText ) |
|
130 { |
|
131 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeL" ); |
|
132 if ( aCategory == KUidActiveInternetRadioApp ) |
|
133 { |
|
134 if( aKey == KIRPSDataChannel ) |
|
135 { |
|
136 iObserver.HandleChannelChangeL(); |
|
137 } |
|
138 else if( aKey == KIRPSMetaData ) |
|
139 { |
|
140 CIRMetaData* metaData = CIRMetaData::NewL( aText ); |
|
141 CleanupStack::PushL( metaData ); |
|
142 iObserver.HandleMetaDataReceivedL( *metaData ); |
|
143 CleanupStack::PopAndDestroy( metaData ); |
|
144 } |
|
145 else |
|
146 { |
|
147 // To avoid PC lint error |
|
148 } |
|
149 } |
|
150 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeL - Exiting." ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CIRActiveIdleEng::HandlePropertyChangeL |
|
155 // Invoked when any listened P&S key is changed. |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CIRActiveIdleEng::HandlePropertyChangeL( |
|
159 const TUid& aCategory, TUint aKey, TInt aValue ) |
|
160 { |
|
161 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeL" ); |
|
162 if ( aCategory == KUidActiveInternetRadioApp ) |
|
163 { |
|
164 if( aKey == KIRPSDataApplicationRunning) |
|
165 { |
|
166 iObserver.HandleApplicationRunningStateChangeL( |
|
167 static_cast<TIRPSApplicationRunningState>( aValue ) ); |
|
168 } |
|
169 else if( aKey == KIRPSVolume) |
|
170 { |
|
171 iObserver.HandleVolumeChangeL( aValue ); |
|
172 } |
|
173 else if( aKey == KIRPSPlayStop) |
|
174 { |
|
175 iObserver.HandlePlayStopL( static_cast<TIRStopPlayState>( aValue ) ); |
|
176 } |
|
177 else if( aKey == KIRPSBufferingState) |
|
178 { |
|
179 IRRDEBUG2("CIRActiveIdleEng::HandlePropertyChangeL KIRPSBufferingState=%d ",aValue); |
|
180 iObserver.HandleBufferingStateL(static_cast<TIRBufferingState>(aValue)); |
|
181 } |
|
182 else |
|
183 { |
|
184 // To avoid PC lint error |
|
185 } |
|
186 } |
|
187 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeL - Exiting." ); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CIRActiveIdleEng::HandlePropertyChangeErrorL |
|
192 // Invoked when an error has occured while fetching the new value of any listened P&S key. |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CIRActiveIdleEng::HandlePropertyChangeErrorL( const TUid& /*aCategory*/, |
|
196 TUint /*aKey*/, TInt aError ) |
|
197 { |
|
198 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeErrorL" ); |
|
199 if (aError < 0) |
|
200 { |
|
201 HandlePropertyChangeL(KUidActiveInternetRadioApp, |
|
202 KIRPSDataApplicationRunning, EIRPSApplicationClosing); |
|
203 } |
|
204 IRLOG_DEBUG( "CIRActiveIdleEng::HandlePropertyChangeErrorL" ); |
|
205 } |
|
206 |
|
207 |
|
208 |
|
209 |