|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: CUpnpStateUpdateHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnpstateupdatehandler.h" |
|
21 #include "upnpavcpstring.h" |
|
22 |
|
23 // CONSTANTS |
|
24 using namespace UpnpAVCPStrings; |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CUpnpStateUpdateHandler::CUpnpStateUpdateHandler |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CUpnpStateUpdateHandler::CUpnpStateUpdateHandler( |
|
34 MUpnpAVControlPointObserver& aAVCPObserver, |
|
35 CUpnpAVControlPoint& aAVCP ) |
|
36 :iAVControlPointObserver( aAVCPObserver ), iAVCP( aAVCP ) |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CUpnpStateUpdateHandler::ConstructL |
|
42 // Symbian 2nd phase constructor can leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 void CUpnpStateUpdateHandler::ConstructL() |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CSuperDir::NewL |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CUpnpStateUpdateHandler* CUpnpStateUpdateHandler::NewL( |
|
55 MUpnpAVControlPointObserver& aAVCPObserver, |
|
56 CUpnpAVControlPoint& aAVCP ) |
|
57 { |
|
58 CUpnpStateUpdateHandler* self = new (ELeave) CUpnpStateUpdateHandler( |
|
59 aAVCPObserver, aAVCP ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CUpnpStateUpdateHandler::~CUpnpStateUpdateHandler |
|
68 // Destructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CUpnpStateUpdateHandler::~CUpnpStateUpdateHandler() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CUpnpStateUpdateHandler::ContentDirectoryStateUpdated |
|
77 // In this function are update events from content directory handled. |
|
78 // (other items were commented in a header) |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CUpnpStateUpdateHandler::ContentDirectoryStateUpdated( CUpnpDevice& aDevice, |
|
82 CUpnpService*& aService) |
|
83 { |
|
84 CUpnpStateVariable* systemUpdateId = |
|
85 aService->StateVariable( KSystemUpdateID ); |
|
86 CUpnpStateVariable* containerUpdateIds = |
|
87 aService->StateVariable( KContainerUpdateIDs ); |
|
88 CUpnpStateVariable* transferIds = |
|
89 aService->StateVariable( KTransferIds ); |
|
90 |
|
91 if( !(systemUpdateId || containerUpdateIds || transferIds) ) |
|
92 { |
|
93 return KErrArgument; |
|
94 } |
|
95 |
|
96 // |
|
97 if( systemUpdateId ) |
|
98 { |
|
99 TLex8 updateidLex( systemUpdateId->Value() ); |
|
100 TInt systemUpdate; |
|
101 updateidLex.Val( systemUpdate ); |
|
102 iAVControlPointObserver.CdsUpdateEvent( |
|
103 aDevice.Uuid(), |
|
104 systemUpdate |
|
105 ); |
|
106 } |
|
107 if( containerUpdateIds ) |
|
108 { |
|
109 iAVControlPointObserver.CdsContainerEvent( |
|
110 aDevice.Uuid(), |
|
111 containerUpdateIds->Value() |
|
112 ); |
|
113 } |
|
114 if( transferIds ) |
|
115 { |
|
116 iAVControlPointObserver.CdsTransferEvent( |
|
117 aDevice.Uuid(), |
|
118 transferIds->Value() |
|
119 ); |
|
120 } |
|
121 return KErrNone; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CUpnpStateUpdateHandler::StateUpdatedL |
|
126 // This is the place to start handling state updates |
|
127 // (other items were commented in a header) |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CUpnpStateUpdateHandler::StateUpdated(CUpnpService*& aService) |
|
131 { |
|
132 TInt err( KErrNone ); |
|
133 CUpnpDevice& device = aService->Device(); |
|
134 if (aService->ServiceType().Match( KRenderingControl ) != KErrNotFound ) |
|
135 { |
|
136 err = RenderingControlStateUpdated( device, aService ); |
|
137 } |
|
138 else if (aService->ServiceType().Match( KConnectionManager ) != KErrNotFound ) |
|
139 { |
|
140 err = ConnectionManagerStateUpdated( device, aService ); |
|
141 } |
|
142 else if (aService->ServiceType().Match( KAVTransport ) != KErrNotFound ) |
|
143 { |
|
144 err = AVTransportStateUpdated( device, aService ); |
|
145 } |
|
146 else if (aService->ServiceType().Match( KContentDirectory ) != KErrNotFound ) |
|
147 { |
|
148 err = ContentDirectoryStateUpdated( device, aService ); |
|
149 } |
|
150 else |
|
151 { |
|
152 err = KErrGeneral; |
|
153 } |
|
154 return err; |
|
155 |
|
156 } |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CUpnpStateUpdateHandler::RenderingControlStateUpdated |
|
159 // In this function are rendering control events are handled. |
|
160 // (other items were commented in a header) |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CUpnpStateUpdateHandler::RenderingControlStateUpdated( CUpnpDevice& aDevice, |
|
164 CUpnpService*& aService ) |
|
165 { |
|
166 CUpnpStateVariable* lastChange = aService->StateVariable( KLastChange ); |
|
167 if( !lastChange ) |
|
168 { |
|
169 return KErrArgument; |
|
170 } |
|
171 else |
|
172 { |
|
173 iAVControlPointObserver.RcLastChangeEvent( |
|
174 aDevice.Uuid(), |
|
175 lastChange->Value() |
|
176 ); |
|
177 return KErrNone; |
|
178 } |
|
179 } |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CUpnpStateUpdateHandler::KAVTransportStateUpdatedL |
|
182 // In this function are updates for mediarenderer handled. |
|
183 // (other items were commented in a header) |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TInt CUpnpStateUpdateHandler::AVTransportStateUpdated( CUpnpDevice& aDevice, |
|
187 CUpnpService*& aService ) |
|
188 { |
|
189 CUpnpStateVariable* lastChange = aService->StateVariable( KLastChange ); |
|
190 if( !lastChange ) |
|
191 { |
|
192 return KErrArgument; |
|
193 } |
|
194 else |
|
195 { |
|
196 iAVControlPointObserver.AvtLastChangeEvent( |
|
197 aDevice.Uuid(), |
|
198 lastChange->Value() |
|
199 ); |
|
200 return KErrNone; |
|
201 } |
|
202 } |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CUpnpStateUpdateHandler::ConnectionManagerStateUpdated |
|
205 // In this function are update events from rendering control handled. |
|
206 // (other items were commented in a header) |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 TInt CUpnpStateUpdateHandler::ConnectionManagerStateUpdated(CUpnpDevice& aDevice, |
|
210 CUpnpService*& aService) |
|
211 { |
|
212 CUpnpStateVariable* source = |
|
213 aService->StateVariable( KSourceProtocolInfo ); |
|
214 CUpnpStateVariable* sink = |
|
215 aService->StateVariable( KSinkProtocolInfo ); |
|
216 CUpnpStateVariable* connections = |
|
217 aService->StateVariable( KCurrentConnectionIds ); |
|
218 |
|
219 if( !(source || sink || connections) ) |
|
220 { |
|
221 return KErrArgument; |
|
222 } |
|
223 |
|
224 if( source ) |
|
225 { |
|
226 iAVControlPointObserver.CmSourceEvent( |
|
227 aDevice.Uuid(), |
|
228 source->Value() |
|
229 ); |
|
230 } |
|
231 if( sink ) |
|
232 { |
|
233 iAVControlPointObserver.CmSinkEvent( |
|
234 aDevice.Uuid(), |
|
235 sink->Value() |
|
236 ); |
|
237 } |
|
238 if( connections ) |
|
239 { |
|
240 iAVControlPointObserver.CmConnectionsEvent( |
|
241 aDevice.Uuid(), |
|
242 connections->Value() |
|
243 ); |
|
244 } |
|
245 |
|
246 return KErrNone; |
|
247 } |
|
248 |