|
1 /* |
|
2 * Copyright (c) 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "musunittesting.h" |
|
20 |
|
21 #include "musmanagerservercore.h" |
|
22 #include "musapplicationmanager.h" |
|
23 #include "musavailabilitypluginmanager.h" |
|
24 #include "musmonitoravailabilityobserver.h" |
|
25 #include "muslogger.h" |
|
26 #include "musmanagerservercoreobserver.h" |
|
27 #include "musmanager.h" |
|
28 |
|
29 using namespace MultimediaSharing; |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CMusManagerServerCore::NewL |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CMusManagerServerCore* CMusManagerServerCore::NewL( |
|
38 MMusManagerServerCoreObserver& aObserver ) |
|
39 { |
|
40 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::NewL()" ); |
|
41 |
|
42 CMusManagerServerCore* self = CMusManagerServerCore::NewLC( aObserver ); |
|
43 CleanupStack::Pop( self ); |
|
44 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::NewL()" ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMusManagerServerCore::NewLC |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMusManagerServerCore* CMusManagerServerCore::NewLC( |
|
53 MMusManagerServerCoreObserver& aObserver ) |
|
54 { |
|
55 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::NewLC()" ); |
|
56 |
|
57 CMusManagerServerCore* self |
|
58 = new( ELeave ) CMusManagerServerCore( aObserver ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::NewLC()" ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMusManagerServerCore::CMusManagerServerCore |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CMusManagerServerCore::CMusManagerServerCore( MMusManagerServerCoreObserver& aObserver ) |
|
70 : iObserver( aObserver ) |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CMusManagerServerCore::ConstructL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CMusManagerServerCore::ConstructL() |
|
79 { |
|
80 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::ConstructL" ); |
|
81 |
|
82 iApplicationManager = CMusApplicationManager::NewL(); |
|
83 |
|
84 iPluginManager = CMusAvailabilityPluginManager::NewL( *this, *iApplicationManager ); |
|
85 |
|
86 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::ConstructL" ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMusManagerServerCore::~CMusManagerServerCore |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CMusManagerServerCore::~CMusManagerServerCore() |
|
94 { |
|
95 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::CMusManagerServerCore" ); |
|
96 |
|
97 // inform ui via application manager (via session api) |
|
98 |
|
99 delete iPluginManager; |
|
100 |
|
101 delete iApplicationManager; |
|
102 |
|
103 // go through interested client sessions |
|
104 StopMonitoring(); |
|
105 iAvailabilityMonitors.Close(); |
|
106 |
|
107 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::CMusManagerServerCore" ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CMusManagerServerCore::~CMusManagerServerCore |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 MultimediaSharing::TMusAvailabilityStatus CMusManagerServerCore::AvailabilityQueryL() |
|
115 { |
|
116 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::AvailabilityQueryL" ); |
|
117 MultimediaSharing::TMusAvailabilityStatus status |
|
118 = iPluginManager->Availability(); |
|
119 |
|
120 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::AvailabilityQueryL" ); |
|
121 return status; |
|
122 } |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMusManagerServerCore::InvestigateAvailability |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CMusManagerServerCore::CommandL( MultimediaSharing::TCommandType aCommandType ) |
|
128 { |
|
129 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::CommandL" ); |
|
130 if ( aCommandType == MultimediaSharing::ECommandManualActivation ) |
|
131 { |
|
132 MUS_LOG( "mus: [MUSSRV] Manual Activation is started" ) |
|
133 iPluginManager->ManualQueryL(); |
|
134 } |
|
135 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::CommandL" ); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMusManagerServerCore::InvestigateAvailability |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CMusManagerServerCore::InvestigateAvailabilityL() |
|
143 { |
|
144 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::InvestigateAvailabilityL" ); |
|
145 iPluginManager->InvestigateAvailabilityL(); |
|
146 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::InvestigateAvailabilityL" ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMusManagerServerCore::InvitationReceived |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMusManagerServerCore::InvitationReceivedL( TUid aChannelId ) |
|
154 { |
|
155 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::InvitationReceivedL" ); |
|
156 |
|
157 TInt uid = aChannelId.iUid; |
|
158 |
|
159 if( uid == CMusManager::ESipInviteDesired && |
|
160 iPluginManager->ApplicationAllowed() ) |
|
161 { |
|
162 // write session boundary values |
|
163 iApplicationManager->WriteSessionPropertiesL( |
|
164 MultimediaSharing::EMusReceive, |
|
165 iPluginManager->Availability(), |
|
166 iPluginManager->SessionParametersL() ); |
|
167 |
|
168 iApplicationManager->StartApplicationL(); |
|
169 } |
|
170 else if( uid == CMusManager::ESipInviteNotDesired ) |
|
171 { |
|
172 iPluginManager->InvitationReceivedL(); |
|
173 } |
|
174 else |
|
175 { |
|
176 User::Leave( KErrNotReady ); |
|
177 } |
|
178 |
|
179 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::InvitationReceivedL" ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CMusManagerServerCore::OptionsReceivedL( TUid /*aChannelId*/ ) |
|
187 { |
|
188 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::OptionsReceivedL" ); |
|
189 iPluginManager->OptionsReceivedL(); |
|
190 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::OptionsReceivedL" ); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CMusManagerServerCore::StartMultimediaSharingL( MultimediaSharing::TMusUseCase aUseCase ) |
|
198 { |
|
199 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::StartMultimediaSharingL" ); |
|
200 if( !iApplicationManager->ApplicationRunning() && |
|
201 iPluginManager->ApplicationAllowed() ) |
|
202 { |
|
203 // write session boundary values |
|
204 iApplicationManager->WriteSessionPropertiesL( |
|
205 aUseCase, |
|
206 iPluginManager->Availability(), |
|
207 iPluginManager->SessionParametersL() ); |
|
208 |
|
209 // start actual application |
|
210 iApplicationManager->StartApplicationL(); |
|
211 } |
|
212 else |
|
213 { |
|
214 iApplicationManager->ShowApplicationL(); |
|
215 } |
|
216 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::StartMultimediaSharingL" ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CMusManagerServerCore::StopMultimediaSharingL() |
|
224 { |
|
225 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::StopMultimediaSharingL" ); |
|
226 iApplicationManager->StopApplicationL(); |
|
227 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::StopMultimediaSharingL" ); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CMusManagerServerCore::EventNoSessions() |
|
235 { |
|
236 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::EventNoSessions" ); |
|
237 TRAPD( error, iPluginManager->StopPluginL() ); |
|
238 if( error ) |
|
239 { |
|
240 // iObserver.StopServer(); |
|
241 } |
|
242 iObserver.StopServer(); |
|
243 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::EventNoSessions" ); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CMusManagerServerCore::PluginStopped() |
|
251 { |
|
252 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::PluginStopped" ); |
|
253 if( iObserver.SessionCount() == 0 ) |
|
254 { |
|
255 iObserver.StopServer(); |
|
256 } |
|
257 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::PluginStopped" ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CMusManagerServerCore::AvailabilityChangedL( |
|
265 MultimediaSharing::TMusAvailabilityStatus aAvailability ) |
|
266 { |
|
267 MUS_LOG1( "mus: [MUSSRV] -> CMusManagerServerCore::AvailabilityChangedL( %d )", |
|
268 aAvailability ); |
|
269 // inform ui via application manager (via session api) |
|
270 |
|
271 iApplicationManager->WriteSessionPropertiesL( |
|
272 aAvailability, |
|
273 iPluginManager->SessionParametersL() ); |
|
274 |
|
275 if( iAvailabilityMonitors.Count() ) |
|
276 { |
|
277 // go through interested client sessions |
|
278 for( TInt i=0; i<iAvailabilityMonitors.Count(); i++ ) |
|
279 { |
|
280 // and inform each about the new status |
|
281 iAvailabilityMonitors[i]->AvailabilityChangedL( |
|
282 aAvailability ); |
|
283 } |
|
284 } |
|
285 |
|
286 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::AvailabilityChangedL" ); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CMusManagerServerCore::CancelMonitoring( MMusMonitorAvailabilityObserver* aObserver ) |
|
294 { |
|
295 TInt index = iAvailabilityMonitors.Find( aObserver ); |
|
296 |
|
297 if( index != KErrNotFound ) |
|
298 { |
|
299 iAvailabilityMonitors[index]->RequestComplete(); |
|
300 iAvailabilityMonitors.Remove( index ); |
|
301 } |
|
302 } |
|
303 |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CMusManagerServerCore::RegisterObserverL( |
|
310 MMusMonitorAvailabilityObserver* aObserver ) |
|
311 { |
|
312 if( iAvailabilityMonitors.Find( aObserver ) == KErrNotFound ) |
|
313 { |
|
314 iAvailabilityMonitors.AppendL( aObserver ); |
|
315 } |
|
316 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RegisterObserver" ); |
|
317 } |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 void CMusManagerServerCore::RemoveObserver( MMusMonitorAvailabilityObserver* aObserver ) |
|
324 { |
|
325 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RemoveObserver" ); |
|
326 TInt index = iAvailabilityMonitors.Find( aObserver ); |
|
327 |
|
328 if( index != KErrNotFound ) |
|
329 { |
|
330 iAvailabilityMonitors.Remove( index ); |
|
331 } |
|
332 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RemoveObserver" ); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // From MMusAvailabilityPluginManagerObserver. |
|
337 // Starts live video sharing. |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CMusManagerServerCore::StartLiveSharingL() |
|
341 { |
|
342 StartMultimediaSharingL( MultimediaSharing::EMusLiveVideo ); |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CMusManagerServerCore::StopMonitoring() |
|
350 { |
|
351 // go through interested client sessions |
|
352 for( TInt i=0; i<iAvailabilityMonitors.Count(); i++ ) |
|
353 { |
|
354 // and inform each about the new status |
|
355 iAvailabilityMonitors[i]->RequestComplete(); |
|
356 iAvailabilityMonitors.Remove( i ); |
|
357 } |
|
358 } |
|
359 |
|
360 // End of File |