|
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 #include "musmanagerservercommon.h" |
|
29 |
|
30 using namespace MultimediaSharing; |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT8( KMusEngineName, "MultimediaSharing" ); |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CMusManagerServerCore::NewL |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMusManagerServerCore* CMusManagerServerCore::NewL( |
|
41 MMusManagerServerCoreObserver& aObserver ) |
|
42 { |
|
43 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::NewL()" ); |
|
44 |
|
45 CMusManagerServerCore* self = CMusManagerServerCore::NewLC( aObserver ); |
|
46 CleanupStack::Pop( self ); |
|
47 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::NewL()" ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMusManagerServerCore::NewLC |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMusManagerServerCore* CMusManagerServerCore::NewLC( |
|
56 MMusManagerServerCoreObserver& aObserver ) |
|
57 { |
|
58 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::NewLC()" ); |
|
59 |
|
60 CMusManagerServerCore* self |
|
61 = new( ELeave ) CMusManagerServerCore( aObserver ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::NewLC()" ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMusManagerServerCore::CMusManagerServerCore |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CMusManagerServerCore::CMusManagerServerCore( MMusManagerServerCoreObserver& aObserver ) |
|
73 : iObserver( aObserver ) |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CMusManagerServerCore::ConstructL |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CMusManagerServerCore::ConstructL() |
|
82 { |
|
83 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::ConstructL" ); |
|
84 |
|
85 iApplicationManager = CMusApplicationManager::NewL(); |
|
86 |
|
87 iApplicationManager->ResolvePluginNameL( iPluginName ); |
|
88 |
|
89 iPluginManager = CMusAvailabilityPluginManager::NewL( *this, *iApplicationManager ); |
|
90 |
|
91 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::ConstructL" ); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMusManagerServerCore::~CMusManagerServerCore |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CMusManagerServerCore::~CMusManagerServerCore() |
|
99 { |
|
100 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::CMusManagerServerCore" ); |
|
101 |
|
102 // inform ui via application manager (via session api) |
|
103 |
|
104 delete iPluginManager; |
|
105 |
|
106 delete iApplicationManager; |
|
107 |
|
108 // go through interested client sessions |
|
109 StopMonitoring(); |
|
110 iAvailabilityMonitors.Close(); |
|
111 |
|
112 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::CMusManagerServerCore" ); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CMusManagerServerCore::~CMusManagerServerCore |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 MultimediaSharing::TMusAvailabilityStatus CMusManagerServerCore::AvailabilityQueryL() |
|
120 { |
|
121 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::AvailabilityQueryL" ); |
|
122 MultimediaSharing::TMusAvailabilityStatus status |
|
123 = Availability(); |
|
124 |
|
125 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::AvailabilityQueryL" ); |
|
126 return status; |
|
127 } |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMusManagerServerCore::InvestigateAvailability |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CMusManagerServerCore::CommandL( MultimediaSharing::TCommandType aCommandType ) |
|
133 { |
|
134 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::CommandL" ); |
|
135 if ( aCommandType == MultimediaSharing::ECommandManualActivation && |
|
136 IsMusEnginePlugin() ) |
|
137 { |
|
138 MUS_LOG( "mus: [MUSSRV] Manual Activation is started" ) |
|
139 iPluginManager->ManualQueryL(); |
|
140 } |
|
141 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::CommandL" ); |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CMusManagerServerCore::InvestigateAvailability |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CMusManagerServerCore::InvestigateAvailabilityL() |
|
149 { |
|
150 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::InvestigateAvailabilityL" ); |
|
151 if ( IsMusEnginePlugin() ) |
|
152 { |
|
153 iPluginManager->InvestigateAvailabilityL(); |
|
154 } |
|
155 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::InvestigateAvailabilityL" ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMusManagerServerCore::InvitationReceived |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CMusManagerServerCore::InvitationReceivedL( TUid aChannelId ) |
|
163 { |
|
164 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::InvitationReceivedL" ); |
|
165 |
|
166 TInt uid = aChannelId.iUid; |
|
167 |
|
168 if( uid == CMusManager::ESipInviteDesired && |
|
169 ApplicationAllowed() ) |
|
170 { |
|
171 PrepareForReceivedInviteL(); |
|
172 |
|
173 // write session boundary values |
|
174 WriteSessionPropertiesL( |
|
175 MultimediaSharing::EMusReceive, |
|
176 Availability(), |
|
177 iPluginManager->SessionParametersL() ); |
|
178 |
|
179 iApplicationManager->StartApplicationL(); |
|
180 } |
|
181 else if( uid == CMusManager::ESipInviteDesired2WayVideo && |
|
182 ApplicationAllowed() ) |
|
183 { |
|
184 PrepareForReceivedInviteL(); |
|
185 |
|
186 // write session boundary values |
|
187 WriteSessionPropertiesL( |
|
188 MultimediaSharing::EMusReceiveTwoWayVideo, |
|
189 Availability(), |
|
190 iPluginManager->SessionParametersL() ); |
|
191 |
|
192 iApplicationManager->StartApplicationL(); |
|
193 } |
|
194 else if ( IsMusEnginePlugin() ) |
|
195 { |
|
196 if( uid == CMusManager::ESipInviteNotDesired ) |
|
197 { |
|
198 iPluginManager->InvitationReceivedL(); |
|
199 } |
|
200 else |
|
201 { |
|
202 User::Leave( KErrNotReady ); |
|
203 } |
|
204 } |
|
205 |
|
206 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::InvitationReceivedL" ); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CMusManagerServerCore::OptionsReceivedL( TUid /*aChannelId*/ ) |
|
214 { |
|
215 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::OptionsReceivedL" ); |
|
216 if ( IsMusEnginePlugin() ) |
|
217 { |
|
218 iPluginManager->OptionsReceivedL(); |
|
219 } |
|
220 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::OptionsReceivedL" ); |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void CMusManagerServerCore::StartMultimediaSharingL( MultimediaSharing::TMusUseCase aUseCase ) |
|
228 { |
|
229 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::StartMultimediaSharingL" ); |
|
230 if( !iApplicationManager->ApplicationRunning() && |
|
231 ApplicationAllowed() ) |
|
232 { |
|
233 // write session boundary values |
|
234 WriteSessionPropertiesL( |
|
235 aUseCase, |
|
236 Availability(), |
|
237 iPluginManager->SessionParametersL() ); |
|
238 |
|
239 // start actual application |
|
240 iApplicationManager->StartApplicationL(); |
|
241 } |
|
242 else |
|
243 { |
|
244 iApplicationManager->ShowApplicationL(); |
|
245 } |
|
246 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::StartMultimediaSharingL" ); |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 void CMusManagerServerCore::StopMultimediaSharingL() |
|
254 { |
|
255 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::StopMultimediaSharingL" ); |
|
256 iApplicationManager->StopApplicationL(); |
|
257 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::StopMultimediaSharingL" ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CMusManagerServerCore::EventNoSessions() |
|
265 { |
|
266 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::EventNoSessions" ); |
|
267 if ( IsMusEnginePlugin() ) |
|
268 { |
|
269 TRAPD( error, iPluginManager->StopPluginL() ); |
|
270 if( error ) |
|
271 { |
|
272 // iObserver.StopServer(); |
|
273 } |
|
274 } |
|
275 iObserver.StopServer(); |
|
276 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::EventNoSessions" ); |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CMusManagerServerCore::PluginStopped() |
|
284 { |
|
285 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::PluginStopped" ); |
|
286 if( iObserver.SessionCount() == 0 ) |
|
287 { |
|
288 iObserver.StopServer(); |
|
289 } |
|
290 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::PluginStopped" ); |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CMusManagerServerCore::AvailabilityChangedL( |
|
298 MultimediaSharing::TMusAvailabilityStatus aAvailability ) |
|
299 { |
|
300 MUS_LOG1( "mus: [MUSSRV] -> CMusManagerServerCore::AvailabilityChangedL( %d )", |
|
301 aAvailability ); |
|
302 |
|
303 if ( !IsMusEnginePlugin() ) |
|
304 { |
|
305 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::AvailabilityChangedL - \ |
|
306 non-MuS plugin"); |
|
307 return; |
|
308 } |
|
309 // inform ui via application manager (via session api) |
|
310 |
|
311 WriteSessionPropertiesL( |
|
312 aAvailability, |
|
313 iPluginManager->SessionParametersL() ); |
|
314 |
|
315 if( iAvailabilityMonitors.Count() ) |
|
316 { |
|
317 // go through interested client sessions |
|
318 for( TInt i=0; i<iAvailabilityMonitors.Count(); i++ ) |
|
319 { |
|
320 // and inform each about the new status |
|
321 iAvailabilityMonitors[i]->AvailabilityChangedL( |
|
322 aAvailability ); |
|
323 } |
|
324 } |
|
325 |
|
326 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::AvailabilityChangedL" ); |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 void CMusManagerServerCore::CancelMonitoring( MMusMonitorAvailabilityObserver* aObserver ) |
|
334 { |
|
335 TInt index = iAvailabilityMonitors.Find( aObserver ); |
|
336 |
|
337 if( index != KErrNotFound ) |
|
338 { |
|
339 iAvailabilityMonitors[index]->RequestComplete(); |
|
340 iAvailabilityMonitors.Remove( index ); |
|
341 } |
|
342 } |
|
343 |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CMusManagerServerCore::RegisterObserverL( |
|
350 MMusMonitorAvailabilityObserver* aObserver ) |
|
351 { |
|
352 if( iAvailabilityMonitors.Find( aObserver ) == KErrNotFound ) |
|
353 { |
|
354 iAvailabilityMonitors.AppendL( aObserver ); |
|
355 } |
|
356 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RegisterObserver" ); |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void CMusManagerServerCore::RemoveObserver( MMusMonitorAvailabilityObserver* aObserver ) |
|
364 { |
|
365 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RemoveObserver" ); |
|
366 TInt index = iAvailabilityMonitors.Find( aObserver ); |
|
367 |
|
368 if( index != KErrNotFound ) |
|
369 { |
|
370 iAvailabilityMonitors.Remove( index ); |
|
371 } |
|
372 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::RemoveObserver" ); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // From MMusAvailabilityPluginManagerObserver. |
|
377 // Starts live video sharing. |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 void CMusManagerServerCore::StartSharingWithUseCaseL( |
|
381 MultimediaSharing::TMusUseCase aUseCase ) |
|
382 { |
|
383 MUS_LOG1( "mus: [MUSSRV] -> CMusManagerServerCore::StartSharingWithUseCaseL:%d", |
|
384 aUseCase ); |
|
385 |
|
386 StartMultimediaSharingL( aUseCase ); |
|
387 |
|
388 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::StartSharingWithUseCaseL" ); |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void CMusManagerServerCore::StopMonitoring() |
|
396 { |
|
397 // go through interested client sessions |
|
398 for( TInt i=0; i<iAvailabilityMonitors.Count(); i++ ) |
|
399 { |
|
400 // and inform each about the new status |
|
401 iAvailabilityMonitors[i]->RequestComplete(); |
|
402 iAvailabilityMonitors.Remove( i ); |
|
403 } |
|
404 } |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CMusManagerServerCore::IsMusEnginePlugin |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 TBool CMusManagerServerCore::IsMusEnginePlugin() |
|
411 { |
|
412 TBool isMus( EFalse ); |
|
413 if ( !iPluginName.Compare( KMusEngineName ) ) |
|
414 { |
|
415 isMus = ETrue; |
|
416 } |
|
417 return isMus; |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CMusManagerServerCore::Availability |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 MultimediaSharing::TMusAvailabilityStatus CMusManagerServerCore::Availability() |
|
425 { |
|
426 MUS_LOG( "mus: [MUSSRV] -> CMusManagerServerCore::Availability" ); |
|
427 if ( IsMusEnginePlugin() ) |
|
428 { |
|
429 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::Availability - MuS plugin" ); |
|
430 return iPluginManager->Availability(); |
|
431 } |
|
432 else |
|
433 { |
|
434 MUS_LOG( "mus: [MUSSRV] <- CMusManagerServerCore::Availability - non-MuS plugin" ); |
|
435 return EMultimediaSharingAvailable; |
|
436 } |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CMusManagerServerCore::ApplicationAllowed |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 TBool CMusManagerServerCore::ApplicationAllowed() |
|
444 { |
|
445 if ( IsMusEnginePlugin() ) |
|
446 { |
|
447 return iPluginManager->ApplicationAllowed(); |
|
448 } |
|
449 else |
|
450 { |
|
451 return ETrue; |
|
452 } |
|
453 } |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CMusManagerServerCore::PrepareForReceivedInviteL |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 void CMusManagerServerCore::PrepareForReceivedInviteL() |
|
460 { |
|
461 if ( IsMusEnginePlugin() ) |
|
462 { |
|
463 iPluginManager->PrepareForReceivedInviteL(); |
|
464 } |
|
465 } |
|
466 |
|
467 // ----------------------------------------------------------------------------- |
|
468 // CMusManagerServerCore::WriteSessionPropertiesL |
|
469 // ----------------------------------------------------------------------------- |
|
470 // |
|
471 void CMusManagerServerCore::WriteSessionPropertiesL( |
|
472 MultimediaSharing::TMusUseCase aUseCase, |
|
473 MultimediaSharing::TMusAvailabilityStatus aStatus, |
|
474 MDesCArray& aSessionParameters ) |
|
475 { |
|
476 if ( IsMusEnginePlugin() ) |
|
477 { |
|
478 iApplicationManager->WriteSessionPropertiesL( |
|
479 aUseCase, |
|
480 aStatus, |
|
481 aSessionParameters ); |
|
482 } |
|
483 } |
|
484 |
|
485 // ----------------------------------------------------------------------------- |
|
486 // CMusManagerServerCore::WriteSessionPropertiesL |
|
487 // ----------------------------------------------------------------------------- |
|
488 // |
|
489 void CMusManagerServerCore::WriteSessionPropertiesL( |
|
490 MultimediaSharing::TMusAvailabilityStatus aStatus, |
|
491 MDesCArray& aSessionParameters ) |
|
492 { |
|
493 if ( IsMusEnginePlugin() ) |
|
494 { |
|
495 iApplicationManager->WriteSessionPropertiesL( |
|
496 aStatus, |
|
497 aSessionParameters ); |
|
498 } |
|
499 } |
|
500 |
|
501 // End of File |