|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "musuisendcontroller.h" |
|
21 #include "musuieventobserver.h" |
|
22 #include "musuisharingobserver.h" |
|
23 #include "musuisendobserver.h" |
|
24 #include "musuidialogutil.h" |
|
25 #include "musuicallbackservice.h" |
|
26 #include "musuifileutil.h" |
|
27 #include "mussettings.h" |
|
28 #include "musuipropertywatch.h" |
|
29 #include "mussessionproperties.h" |
|
30 #include "mussettingskeys.h" |
|
31 #include "musuiresourcehandler.h" |
|
32 #include "muslogger.h" // debug logging |
|
33 |
|
34 #include "musengmceoutsession.h" |
|
35 #include "musenguriparser.h" |
|
36 #include <musui.rsg> |
|
37 |
|
38 #include <StringLoader.h> |
|
39 #include <pathinfo.h> |
|
40 #include <CDirectoryLocalizer.h> |
|
41 |
|
42 |
|
43 using namespace NMusSessionApi; |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CMusUiSendController::~CMusUiSendController() |
|
50 { |
|
51 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::~CMusUiSendController" ); |
|
52 |
|
53 delete iAddress; |
|
54 delete iRemoteSipAddress; |
|
55 delete iRemoteSipAddressProposal; |
|
56 delete iVideoFileName; |
|
57 delete iLocalizer; |
|
58 |
|
59 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::~CMusUiSendController" ); |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CMusEngMceSession* CMusUiSendController::EngineSession() |
|
68 { |
|
69 return EngineOutSession(); // Engine out session is CMusEngMceSession |
|
70 } |
|
71 |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMusUiSendController::DeleteEngineSession() |
|
78 { |
|
79 // Cancel invite |
|
80 if ( EngineOutSession() && !ConnectionEstablished() ) |
|
81 { |
|
82 MUS_LOG( "mus: [MUSUI ] CMusUiSendController::DeleteEngineSession:\ |
|
83 Canceling inviting..." ); |
|
84 TRAP_IGNORE( EngineOutSession()->CancelInviteL() ); |
|
85 } |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CMusUiSendController::HandlePropertyError( const TInt aReason ) |
|
94 { |
|
95 MUS_LOG1( "mus: [MUSUI ] -> CMusUiEventController::HandleError [%d]", |
|
96 aReason ); |
|
97 TRAP_IGNORE( DeleteVideoL() ); |
|
98 |
|
99 CMusUiEventController::HandlePropertyError( aReason ); // For the base class |
|
100 |
|
101 MUS_LOG( "mus: [MUSUI ] <- CMusUiEventController::HandleError" ); |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CMusUiSendController::HandleAsyncEventL( TMusUiAsyncEvent aEventId ) |
|
110 { |
|
111 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::HandleAsyncEventL" ); |
|
112 switch ( aEventId ) |
|
113 { |
|
114 case EMusUiAsyncInviteCancel: |
|
115 { |
|
116 MUS_LOG( "mus: [MUSUI ] CMusUiSendController::\ |
|
117 HandleAsyncEventL: EMusUiAsyncInviteCancel" ); |
|
118 HandleExitL(); |
|
119 break; |
|
120 } |
|
121 case EMusUiAsyncManualAddressEntry: |
|
122 { |
|
123 iResourceHandler->RequestKeypadL( ETrue ); // Exits on fail |
|
124 iSendObserver.ManualAddressEntryL( *iRemoteSipAddressProposal ); |
|
125 break; |
|
126 } |
|
127 case EMusUiAsyncStartInvitation: |
|
128 { |
|
129 MUS_LOG( "mus: [MUSUI ] CMusUiSendController::\ |
|
130 HandleAsyncEventL: EMusUiAsyncStartInvitation" ); |
|
131 InviteL(); |
|
132 break; |
|
133 } |
|
134 default: |
|
135 { |
|
136 // Not send specific, let the base class handle |
|
137 CMusUiEventController::HandleAsyncEventL( aEventId ); |
|
138 } |
|
139 } |
|
140 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::HandleAsyncEventL" ); |
|
141 |
|
142 } |
|
143 |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 const TDesC& CMusUiSendController::TypedAddress() const |
|
150 { |
|
151 return *iAddress; |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 TBool CMusUiSendController::ManualAddressTyped() const |
|
160 { |
|
161 return iManualAddressTyped; |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CMusUiSendController::StartInvitationL() |
|
170 { |
|
171 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::StartInvitationL" ); |
|
172 |
|
173 iCallbackService->AsyncEventL( EMusUiAsyncStartInvitation ); |
|
174 |
|
175 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::StartInvitationL" ); |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CMusUiSendController::InviteL() |
|
184 { |
|
185 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::InviteL" ); |
|
186 |
|
187 if ( !iSipRegistrationPending ) |
|
188 { |
|
189 TRAPD( error, |
|
190 iRemoteSipAddress = CMusUiPropertyWatch::ReadDescPropertyL( |
|
191 KRemoteSipAddress ) ); |
|
192 if ( error != KErrNone ) |
|
193 { |
|
194 iRemoteSipAddress = KNullDesC().AllocL(); |
|
195 } |
|
196 |
|
197 TRAP( error, iRemoteSipAddressProposal = |
|
198 CMusUiPropertyWatch::ReadDescPropertyL( |
|
199 KRemoteSipAddressProposal ) ); |
|
200 if ( error != KErrNone ) |
|
201 { |
|
202 iRemoteSipAddressProposal = KNullDesC().AllocL(); |
|
203 } |
|
204 |
|
205 if ( iRemoteSipAddress->Length() > 0 ) |
|
206 { |
|
207 if ( iRemoteSipAddress->Find( KMusCommaSymbol ) == KErrNotFound ) |
|
208 { |
|
209 InviteL( *iRemoteSipAddress ); |
|
210 } |
|
211 else |
|
212 { |
|
213 // Split the addresses using KMusCommaSymbol as a separator |
|
214 CDesCArray* addressArray = |
|
215 new ( ELeave ) CDesCArrayFlat( |
|
216 KMusSipAddressesMaxAmount ); |
|
217 SplitL( *iRemoteSipAddress, KMusCommaSymbol, addressArray ); |
|
218 // Show List Query Dialog |
|
219 TBuf<KMusSipAddressMaxLength> selectedAddress; |
|
220 if ( MusUiDialogUtil::SelectAddressDialogL( addressArray, |
|
221 selectedAddress ) ) |
|
222 { |
|
223 // Invite with the chosen address |
|
224 InviteL( selectedAddress ); |
|
225 } |
|
226 else |
|
227 { |
|
228 HandleExitL(); |
|
229 } |
|
230 } |
|
231 } |
|
232 else |
|
233 { |
|
234 iResourceHandler->RequestKeypadL( ETrue ); // Exits on failure |
|
235 iManualAddressTyped = ETrue; |
|
236 iSendObserver.ManualAddressEntryL( *iRemoteSipAddressProposal ); |
|
237 } |
|
238 } |
|
239 else |
|
240 { |
|
241 // Show waiting dialog |
|
242 delete iDialogPrompt; |
|
243 iDialogPrompt = NULL; |
|
244 iDialogPrompt = StringLoader::LoadL( |
|
245 R_MUS_REGISTRATION_PENDING_WAIT_NOTE_TXT ); |
|
246 |
|
247 if ( !iSharingObserver.ShowWaitDialogL( |
|
248 *iDialogPrompt, |
|
249 KMusInviteExpireTimeout, //Reuse 1 min timer |
|
250 R_MUS_LIVE_SHARING_VIEW_NOTE_NO_REG ) ) |
|
251 { |
|
252 iEventObserver.HandleExit(); |
|
253 } |
|
254 |
|
255 } |
|
256 |
|
257 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::InviteL" ); |
|
258 } |
|
259 |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CMusUiSendController::CancelInvitationL() |
|
266 { |
|
267 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::CancelInvitationL" ); |
|
268 |
|
269 if ( EngineOutSession() && !ConnectionEstablished() ) |
|
270 { |
|
271 TRAP_IGNORE( EngineOutSession()->CancelInviteL() ); |
|
272 } |
|
273 |
|
274 HandleExitL(); |
|
275 |
|
276 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::CancelInvitationL" ); |
|
277 } |
|
278 |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CMusUiSendController::HandleForegroundEventL( TBool aForeground ) |
|
285 { |
|
286 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::HandleForegroundEventL" ); |
|
287 |
|
288 CMusUiEventController::HandleForegroundEventL( aForeground ); |
|
289 |
|
290 if ( ConnectionEstablished() && !ExitOccured() ) |
|
291 { |
|
292 if ( aForeground ) |
|
293 { |
|
294 if ( iContinuePlayingWhenForeground ) |
|
295 { |
|
296 MUS_LOG( "mus: [MUSUI ] Resume playing" ); |
|
297 PlayL(); |
|
298 } |
|
299 } |
|
300 else |
|
301 { |
|
302 MUS_LOG( "mus: [MUSUI ] Pause playing" ); |
|
303 if ( EngineOutSession() ) |
|
304 { |
|
305 iContinuePlayingWhenForeground = IsPlayingL(); |
|
306 } |
|
307 PauseL(); |
|
308 } |
|
309 } |
|
310 |
|
311 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::HandleForegroundEventL" ); |
|
312 } |
|
313 |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void CMusUiSendController::PlayL() |
|
320 { |
|
321 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::PlayL" ); |
|
322 if ( EngineOutSession() ) |
|
323 { |
|
324 EngineOutSession()->PlayL(); |
|
325 } |
|
326 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::PlayL" ); |
|
327 } |
|
328 |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 void CMusUiSendController::PauseL() |
|
335 { |
|
336 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::PauseL" ); |
|
337 if ( EngineOutSession() ) |
|
338 { |
|
339 EngineOutSession()->PauseL(); |
|
340 } |
|
341 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::PauseL" ); |
|
342 } |
|
343 |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 TBool CMusUiSendController::IsPlayingL() |
|
350 { |
|
351 TBool isPlaying( EFalse ); |
|
352 |
|
353 if ( EngineOutSession() ) |
|
354 { |
|
355 isPlaying = EngineOutSession()->IsPlayingL(); |
|
356 } |
|
357 |
|
358 return isPlaying; |
|
359 } |
|
360 |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CMusUiSendController::SessionEstablished() |
|
367 { |
|
368 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionEstablished" ); |
|
369 |
|
370 // Common handling first |
|
371 CMusUiEventController::SessionEstablished(); |
|
372 |
|
373 iConnectionEstablished = ETrue; |
|
374 DismissWaitDialog(); |
|
375 |
|
376 if ( iForeground ) |
|
377 { |
|
378 MUS_LOG( "mus: [MUSUI ] Enable display and start playing" ); |
|
379 TRAP_IGNORE( PlayL(); |
|
380 EnableDisplayL( ETrue ); ) |
|
381 |
|
382 iEventObserver.SetToolbarVisibility( ETrue ); |
|
383 |
|
384 } |
|
385 else |
|
386 { |
|
387 MUS_LOG( "mus: [MUSUI ] In background, don't start playing yet" ); |
|
388 iContinuePlayingWhenForeground = ETrue; |
|
389 } |
|
390 |
|
391 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionEstablished" ); |
|
392 } |
|
393 |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CMusUiSendController::SessionRejected() |
|
400 { |
|
401 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionRejected" ); |
|
402 DismissWaitDialog(); |
|
403 TRAP_IGNORE ( |
|
404 MusUiDialogUtil::ShowInformationDialogL( |
|
405 R_MUS_LIVE_SHARING_VIEW_NOTE_CONNECTION_REJECTED ) ); |
|
406 |
|
407 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
408 |
|
409 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionRejected" ); |
|
410 } |
|
411 |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CMusUiSendController::SessionBadRequest() |
|
418 { |
|
419 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionBadRequest" ); |
|
420 |
|
421 DismissWaitDialog(); |
|
422 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
423 |
|
424 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionBadRequest" ); |
|
425 } |
|
426 |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void CMusUiSendController::SessionUnauthorized() |
|
433 { |
|
434 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionUnauthorized" ); |
|
435 |
|
436 DismissWaitDialog(); |
|
437 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
438 |
|
439 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionUnauthorized" ); |
|
440 } |
|
441 |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void CMusUiSendController::SessionPaymentRequired() |
|
448 { |
|
449 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionPaymentRequired" ); |
|
450 |
|
451 DismissWaitDialog(); |
|
452 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
453 |
|
454 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionPaymentRequired" ); |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 void CMusUiSendController::SessionRecipientNotFound() |
|
462 { |
|
463 MUS_LOG1( "mus: [MUSUI ] -> CMusUiSendController::SessionRecipientNotFound [%d]", |
|
464 iTriedInvitations ); |
|
465 DismissWaitDialog(); |
|
466 if ( ExitOccured() ) |
|
467 { |
|
468 return; |
|
469 } |
|
470 if ( ++iTriedInvitations > 1 ) |
|
471 { |
|
472 TRAP_IGNORE( MusUiDialogUtil::ShowInformationDialogL( |
|
473 R_MUS_LIVE_SHARING_VIEW_NOTE_WRONG_ADDRESS ) ); |
|
474 |
|
475 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncInviteCancel ) ); |
|
476 |
|
477 } |
|
478 else |
|
479 { |
|
480 TRAP_IGNORE( MusUiDialogUtil::ShowInformationDialogL( |
|
481 R_MUS_LIVE_SHARING_VIEW_NOTE_WRONG_ADDRESS ) ); |
|
482 iManualAddressTyped = ETrue; |
|
483 |
|
484 TRAP_IGNORE( |
|
485 iCallbackService->AsyncEventL( EMusUiAsyncManualAddressEntry ) ); |
|
486 |
|
487 } |
|
488 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionRecipientNotFound" ); |
|
489 } |
|
490 |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CMusUiSendController::SessionProxyAuthenticationRequired() |
|
497 { |
|
498 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionProxyAuthenticationRequired" ); |
|
499 |
|
500 DismissWaitDialog(); |
|
501 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
502 |
|
503 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionProxyAuthenticationRequired" ); |
|
504 } |
|
505 |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 void CMusUiSendController::SessionRequestTimeOut() |
|
512 { |
|
513 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionRequestTimeOut" ); |
|
514 DismissWaitDialog(); |
|
515 TRAP_IGNORE( MusUiDialogUtil::ShowInformationDialogL( |
|
516 R_MUS_LIVE_SHARING_VIEW_NOTE_NO_RESPONSE ) ); |
|
517 |
|
518 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
519 |
|
520 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionRequestTimeOut" ); |
|
521 } |
|
522 |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 void CMusUiSendController::SessionUnsupportedMediaType() |
|
529 { |
|
530 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionUnsupportedMediaType" ); |
|
531 DismissWaitDialog(); |
|
532 if ( !ExitOccured() ) |
|
533 { |
|
534 TRAP_IGNORE( MusUiDialogUtil::ShowGlobalErrorDialogL( |
|
535 R_MUS_LIVE_SHARING_VIEW_NOTE_APP_N_A ) ); |
|
536 } |
|
537 |
|
538 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
539 |
|
540 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionUnsupportedMediaType" ); |
|
541 } |
|
542 |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 void CMusUiSendController::SessionBusyHere() |
|
549 { |
|
550 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionBusyHere" ); |
|
551 DismissWaitDialog(); |
|
552 TRAP_IGNORE( |
|
553 MusUiDialogUtil::ShowInformationDialogL( |
|
554 R_MUS_LIVE_SHARING_VIEW_NOTE_RECIPIENT_N_A ) ); |
|
555 |
|
556 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
557 |
|
558 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionBusyHere" ); |
|
559 } |
|
560 |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 void CMusUiSendController::SessionRequestCancelled() |
|
567 { |
|
568 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionRequestCancelled" ); |
|
569 DismissWaitDialog(); |
|
570 TRAP_IGNORE( |
|
571 MusUiDialogUtil::ShowInformationDialogL( |
|
572 R_MUS_LIVE_SHARING_VIEW_NOTE_INVITATION_CANCELLED ) ); |
|
573 |
|
574 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
575 |
|
576 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionRequestCancelled" ); |
|
577 } |
|
578 |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 void CMusUiSendController::SessionTemporarilyNotAvailable() |
|
585 { |
|
586 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SessionRequestCancelled" ); |
|
587 DismissWaitDialog(); |
|
588 if ( !ExitOccured() ) |
|
589 { |
|
590 TRAP_IGNORE( MusUiDialogUtil::ShowGlobalErrorDialogL( |
|
591 R_MUS_LIVE_SHARING_VIEW_NOTE_SERVICE_N_A ) ); |
|
592 } |
|
593 |
|
594 TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) ); |
|
595 |
|
596 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::SessionRequestCancelled" ); |
|
597 } |
|
598 |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 void CMusUiSendController::ConstructL() |
|
605 { |
|
606 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::ConstructL" ); |
|
607 |
|
608 CMusUiEventController::ConstructL(); // Base class construction |
|
609 iLocalizer = CDirectoryLocalizer::NewL(); |
|
610 |
|
611 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::ConstructL" ); |
|
612 } |
|
613 |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 CMusUiSendController::CMusUiSendController( |
|
620 MMusUiEventObserver& aEventObserver, |
|
621 MMusUiSharingObserver& aSharingObserver, |
|
622 MMusUiSendObserver& aSendObserver ) |
|
623 : CMusUiEventController( aEventObserver, aSharingObserver ), |
|
624 iSendObserver( aSendObserver ), |
|
625 iTriedInvitations( 0 ), |
|
626 iContinuePlayingWhenForeground( ETrue ), |
|
627 iWaitDialogCallback( *this ) |
|
628 { |
|
629 |
|
630 } |
|
631 |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 void CMusUiSendController::ExitProcedureL( TBool aUserAcceptance ) |
|
638 { |
|
639 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::ExitProcedureL" ); |
|
640 |
|
641 DismissWaitDialog(); |
|
642 |
|
643 switch ( iShutdownState ) |
|
644 { |
|
645 case EMusUiShutdownStarted: |
|
646 { |
|
647 MUS_LOG( "mus: [MUSUI ] ExitProcedureL: EMusuiShutdownStarted" ); |
|
648 |
|
649 if ( iVideoToBeSaved && |
|
650 iVideoFileName && |
|
651 MusUiFileUtil::FileExists( *iVideoFileName ) ) |
|
652 { |
|
653 iShutdownState = EMusUiShutdownVideoSaved; |
|
654 ShowVideoSavedDialogL(); |
|
655 ExitProcedureL( ETrue ); // Accept saving |
|
656 } |
|
657 else |
|
658 { |
|
659 CMusUiEventController::ExitProcedureL( aUserAcceptance ); |
|
660 } |
|
661 break; |
|
662 } |
|
663 |
|
664 case EMusUiShutdownVideoSaved: |
|
665 { |
|
666 MUS_LOG( "mus: [MUSUI ] ExitProcedureL: EMusuiShutdownVideoSaved" ); |
|
667 |
|
668 // Check if our address is valid sip or tel uri. If not, there is no |
|
669 // point to query user about permission to save it to contacts. |
|
670 |
|
671 TInt error = KErrNotFound; |
|
672 if ( iAddress ) |
|
673 { |
|
674 TMusEngUriParser parser( *iAddress ); |
|
675 TRAP( error, parser.ParseUriL() ) |
|
676 } |
|
677 |
|
678 // Save Address to Contacts query if manually entered |
|
679 // and if is the standard variant. |
|
680 // NOTE: KErrNotSupported means there is more than one contact id. |
|
681 if ( !iOperatorSpecificFunctionality && ManualAddressTyped() && |
|
682 iContactId != KErrNotSupported && |
|
683 error == KErrNone ) |
|
684 { |
|
685 iShutdownState = EMusUiShutdownContactSavingQueried; |
|
686 SaveContactQueryL(); |
|
687 } |
|
688 else |
|
689 { |
|
690 // Nothing send specific, let the base class handle |
|
691 CMusUiEventController::ExitProcedureL( aUserAcceptance ); |
|
692 } |
|
693 break; |
|
694 } |
|
695 |
|
696 default: |
|
697 { |
|
698 // Nothing send specific, let the base class handle |
|
699 CMusUiEventController::ExitProcedureL( aUserAcceptance ); |
|
700 break; |
|
701 } |
|
702 } |
|
703 |
|
704 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::ExitProcedureL" ); |
|
705 } |
|
706 |
|
707 |
|
708 // ----------------------------------------------------------------------------- |
|
709 // Handles status changes specific to sending sharing types. |
|
710 // Calls base class version for status changes that are not sending specific. |
|
711 // ----------------------------------------------------------------------------- |
|
712 // |
|
713 void CMusUiSendController::HandleChangedStatusL( |
|
714 TMusAvailabilityStatus aStatus ) |
|
715 { |
|
716 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::HandleChangedStatusL" ) |
|
717 switch( aStatus ) |
|
718 { |
|
719 case ESipRegistrationPending: |
|
720 { |
|
721 MUS_LOG( "mus: [MUSUI ] ESipRegistrationPending" ); |
|
722 iSipRegistrationPending = ETrue; |
|
723 break; |
|
724 } |
|
725 case ESipOptionsNotSent: // FALLTHROUGH |
|
726 case ESipOptionsSent: // FALLTHROUGH |
|
727 { |
|
728 break; |
|
729 } |
|
730 case EManualActivation: // FALLTHROUGH |
|
731 case EMultimediaSharingAvailable: |
|
732 { |
|
733 MUS_LOG( "mus: [MUSUI ] EManualActivation or EMultimediaSharingAvailable" ) |
|
734 |
|
735 if( iSipRegistrationPending ) |
|
736 { |
|
737 iSipRegistrationPending = EFalse; |
|
738 // Set callback service, Call StartInvitationL when wait dialog dismissed |
|
739 TRAPD( err, iSharingObserver.SetWaitDialogCallbackL( |
|
740 &iWaitDialogCallback ) ); |
|
741 // Dismiss pending wait note |
|
742 iSharingObserver.DismissWaitDialogL(); |
|
743 if ( err == KErrNotReady ) |
|
744 { |
|
745 StartInvitationL(); |
|
746 } |
|
747 } |
|
748 break; |
|
749 } |
|
750 |
|
751 default: |
|
752 { |
|
753 // Not sending specific, let the base class handle |
|
754 CMusUiEventController::HandleChangedStatusL( aStatus ); |
|
755 break; |
|
756 } |
|
757 } |
|
758 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::HandleChangedStatusL" ) |
|
759 } |
|
760 |
|
761 |
|
762 // ----------------------------------------------------------------------------- |
|
763 // |
|
764 // ----------------------------------------------------------------------------- |
|
765 // |
|
766 const TDesC& CMusUiSendController::VideoFileNameL() |
|
767 { |
|
768 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::VideoFileNameL" ); |
|
769 |
|
770 TParse parse; |
|
771 TPtrC rootPath; |
|
772 |
|
773 SetVideoPathValueL();//sets video rootpath according to setting value. |
|
774 |
|
775 if ( parse.Set( iVideoFilePath,NULL,NULL) != KErrBadName ) |
|
776 { |
|
777 |
|
778 if(parse.Drive().Compare( PathInfo::MemoryCardRootPath())) |
|
779 { |
|
780 TRAPD(error,MusUiFileUtil::VideoFilePathExistsL(iVideoFilePath)); |
|
781 |
|
782 switch(error) |
|
783 { |
|
784 case KErrNotReady: |
|
785 case KErrCorrupt: |
|
786 case KErrLocked: |
|
787 { |
|
788 MusUiDialogUtil::ShowGlobalInformationDialogL( |
|
789 R_MUS_VIEW_NOTE_MEMORYCARD_PROBLEM); |
|
790 |
|
791 MUS_LOG( "mus: [MUSUI ] -> Changing to Phone Memory " ); |
|
792 rootPath.Set(PathInfo::PhoneMemoryRootPath()); |
|
793 TParsePtrC pathPtr(rootPath); |
|
794 iVideoFilePath = rootPath; |
|
795 iVideoFilePath += PathInfo::VideosPath(); |
|
796 // Make sure the new path exists |
|
797 TRAP_IGNORE( MusUiFileUtil::VideoFilePathExistsL(iVideoFilePath) ) |
|
798 break; |
|
799 } |
|
800 case KErrAlreadyExists: |
|
801 case KErrNone: |
|
802 { |
|
803 MUS_LOG( "mus: [MUSUI ] -> Using MMC " ); |
|
804 rootPath.Set(PathInfo::MemoryCardRootPath()); |
|
805 break; |
|
806 } |
|
807 default: |
|
808 { |
|
809 delete iVideoFileName; |
|
810 iVideoFileNamePlain = KNullDesC; |
|
811 iVideoFileName = iVideoFileNamePlain.AllocL(); |
|
812 HandleError( error); |
|
813 break; |
|
814 } |
|
815 } |
|
816 } |
|
817 else//Phone memory is being used. |
|
818 { |
|
819 TRAPD(error,MusUiFileUtil::VideoFilePathExistsL(iVideoFilePath)); |
|
820 |
|
821 switch(error) |
|
822 { |
|
823 case KErrAlreadyExists: |
|
824 case KErrNone: |
|
825 { |
|
826 MUS_LOG( "mus: [MUSUI ] -> Using Phone memory" ); |
|
827 rootPath.Set(PathInfo::PhoneMemoryRootPath()); |
|
828 break; |
|
829 } |
|
830 default: |
|
831 { |
|
832 delete iVideoFileName; |
|
833 iVideoFileNamePlain = KNullDesC; |
|
834 iVideoFileName = iVideoFileNamePlain.AllocL(); |
|
835 HandleError( error); |
|
836 break; |
|
837 } |
|
838 } |
|
839 } |
|
840 |
|
841 } |
|
842 else |
|
843 { |
|
844 delete iVideoFileName; |
|
845 iVideoFileNamePlain = KNullDesC; |
|
846 iVideoFileName = iVideoFileNamePlain.AllocL(); |
|
847 HandleError(KErrBadName); |
|
848 } |
|
849 |
|
850 TParsePtrC pathPtr(rootPath); |
|
851 iVideoFilePath += pathPtr.NameAndExt(); |
|
852 MusUiFileUtil::CreateVideoFileNameL(iVideoFilePath, |
|
853 iVideoFileNamePlain); |
|
854 |
|
855 delete iVideoFileName; |
|
856 TFileName videoFileName; |
|
857 videoFileName += iVideoFilePath; |
|
858 videoFileName += iVideoFileNamePlain; |
|
859 videoFileName += KMusVideoFileNameExtension; |
|
860 iVideoFileName = videoFileName.AllocL(); |
|
861 |
|
862 MUS_LOG_TDESC( "mus: [MUSUI ] <- CMusUiSendController::VideoFileNameL:", |
|
863 iVideoFileName->Des() ); |
|
864 return *iVideoFileName; |
|
865 } |
|
866 |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 void CMusUiSendController::ShowInvitingWaitDialogL() |
|
873 { |
|
874 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::ShowWaitDialogL" ); |
|
875 delete iDialogPrompt; |
|
876 iDialogPrompt = NULL; |
|
877 iDialogPrompt = StringLoader::LoadL( |
|
878 R_MUS_LIVE_SHARING_VIEW_INVITING_WAIT_NOTE_TXT, |
|
879 MusContactName().Length() > 0 ? |
|
880 MusContactName() : iOperatorSpecificFunctionality ? |
|
881 MusTelNumberValue() : *iAddress ); |
|
882 |
|
883 if ( !iSharingObserver.ShowWaitDialogL( |
|
884 *iDialogPrompt, |
|
885 KMusInviteExpireTimeout, |
|
886 R_MUS_LIVE_SHARING_VIEW_NOTE_NO_RESPONSE ) ) |
|
887 { |
|
888 CancelInvitationL(); |
|
889 } |
|
890 |
|
891 |
|
892 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::ShowWaitDialogL" ); |
|
893 } |
|
894 |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // |
|
898 // ----------------------------------------------------------------------------- |
|
899 // |
|
900 void CMusUiSendController::DismissWaitDialog() |
|
901 { |
|
902 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::DismissWaitDialog" ); |
|
903 TRAPD( err, iSharingObserver.DismissWaitDialogL(); ); |
|
904 if ( err != KErrNone ) |
|
905 { |
|
906 HandleError( err ); |
|
907 } |
|
908 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::DismissWaitDialog" ); |
|
909 } |
|
910 |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // |
|
914 // ----------------------------------------------------------------------------- |
|
915 // |
|
916 void CMusUiSendController::SplitL( const TDesC& aDes, |
|
917 const TDesC& aChar, |
|
918 CDesCArray* aArray ) |
|
919 { |
|
920 TInt charPos( 0 ); |
|
921 TPtrC ptr( aDes ); |
|
922 TBool found = EFalse; |
|
923 while( ( charPos = ptr.Find( aChar ) ) > 0 ) |
|
924 { |
|
925 found = ETrue; |
|
926 TPtrC str = ptr.Left( charPos ); |
|
927 aArray->AppendL( str ); |
|
928 ptr.Set( ptr.Right( ptr.Length() - str.Length() - 1 ) ); |
|
929 } |
|
930 if ( found && ptr.Length() > 0 ) |
|
931 { |
|
932 aArray->AppendL( ptr ); |
|
933 } |
|
934 } |
|
935 |
|
936 |
|
937 // ----------------------------------------------------------------------------- |
|
938 // |
|
939 // ----------------------------------------------------------------------------- |
|
940 // |
|
941 void CMusUiSendController::SetVideoPathValueL() |
|
942 { |
|
943 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::SetVideoPathValueL" ); |
|
944 TInt drive = MultimediaSharingSettings::VideoLocationSettingL(); |
|
945 |
|
946 TFileName rootPath; |
|
947 User::LeaveIfError( PathInfo::GetRootPath( rootPath, drive ) ); |
|
948 |
|
949 TParsePtrC pathPtr(rootPath); |
|
950 iVideoFilePath = rootPath; |
|
951 iVideoFilePath += PathInfo::VideosPath(); |
|
952 MUS_LOG_TDESC( "mus: [MUSUI ] <- CMusUiSendController::SetVideoPathValueL: ", |
|
953 iVideoFilePath ); |
|
954 iLocalizer->SetFullPath( iVideoFilePath ); |
|
955 if ( iLocalizer->IsLocalized() ) |
|
956 { |
|
957 iLocalizedVideoFilePath =iLocalizer->LocalizedName(); |
|
958 } |
|
959 } |
|
960 |
|
961 |
|
962 // ----------------------------------------------------------------------------- |
|
963 // |
|
964 // ----------------------------------------------------------------------------- |
|
965 // |
|
966 void CMusUiSendController::ShowVideoSavedDialogL() |
|
967 { |
|
968 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::ShowVideoSavedDialogL" ); |
|
969 //MUS_LOG_TDESC( "mus: [MUSUI ] ", iVideoFileNamePlain ); |
|
970 //MUS_LOG_TDESC( "mus: [MUSUI ] ", iVideoFilePath ); |
|
971 |
|
972 delete iDialogPrompt; |
|
973 iDialogPrompt = NULL; |
|
974 |
|
975 TBuf<KMusFileNameMaxLength> buf; |
|
976 TFileName videoFileName; |
|
977 videoFileName += iVideoFileNamePlain; |
|
978 videoFileName += KMusVideoFileNameExtension; |
|
979 buf = videoFileName; |
|
980 |
|
981 CDesCArrayFlat* savingTextsArray = |
|
982 new ( ELeave ) CDesCArrayFlat( KMusStringSubstArrayGranularity ); |
|
983 CleanupStack::PushL( savingTextsArray ); |
|
984 //"File %0U saved to folder %1U" |
|
985 //%0U = iVideoFileName |
|
986 //%1U = iVideoFilePath |
|
987 savingTextsArray->InsertL( 0, videoFileName ); |
|
988 |
|
989 if ( MultimediaSharingSettings::OperatorVariantSettingL() == |
|
990 MusSettingsKeys::EOperatorSpecific ) // For AT&T products |
|
991 { |
|
992 HBufC* folder = StringLoader::LoadLC( R_MUS_VIDEO_SAVE_FOLDER_NAME ); |
|
993 savingTextsArray->InsertL( 1, *folder ); |
|
994 CleanupStack::PopAndDestroy( folder ); |
|
995 } |
|
996 else // Standard products |
|
997 { |
|
998 if ( iLocalizer->IsLocalized() ) |
|
999 { |
|
1000 savingTextsArray->InsertL( 1, iLocalizedVideoFilePath ); |
|
1001 } |
|
1002 else |
|
1003 { |
|
1004 savingTextsArray->InsertL( 1, iVideoFilePath ); |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 MUS_LOG_TDESC( "mus: [MUSUI ] filename:", savingTextsArray->MdcaPoint( 0 ) ); |
|
1009 MUS_LOG_TDESC( "mus: [MUSUI ] path:", savingTextsArray->MdcaPoint( 1 ) ); |
|
1010 |
|
1011 iDialogPrompt = StringLoader::LoadL( R_MUS_VIEW_NOTE_VIDEO_SAVED, |
|
1012 *savingTextsArray ); |
|
1013 CleanupStack::Pop( savingTextsArray ); |
|
1014 |
|
1015 MUS_LOG_TDESC( "mus: [MUSUI ] ", iDialogPrompt->Des() ); |
|
1016 |
|
1017 MusUiDialogUtil::ShowGlobalInformationDialogL( *iDialogPrompt ); |
|
1018 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::ShowVideoSavedDialogL" ); |
|
1019 } |
|
1020 |
|
1021 |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // |
|
1026 void CMusUiSendController::DeleteVideoL() |
|
1027 { |
|
1028 MUS_LOG( "mus: [MUSUI ] -> CMusUiSendController::DeleteVideoL" ); |
|
1029 if ( iVideoFileName ) |
|
1030 { |
|
1031 MusUiFileUtil::DeleteFileL( *iVideoFileName ); |
|
1032 } |
|
1033 MUS_LOG( "mus: [MUSUI ] <- CMusUiSendController::DeleteVideoL" ); |
|
1034 } |
|
1035 |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 CMusUiSendController:: |
|
1042 TWaitDialogCallback::TWaitDialogCallback( CMusUiSendController& aController ) |
|
1043 : iController( aController ) |
|
1044 { |
|
1045 } |
|
1046 |
|
1047 |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // |
|
1052 void CMusUiSendController:: |
|
1053 TWaitDialogCallback::DialogDismissedL( TInt /*aButtonId*/ ) |
|
1054 { |
|
1055 iController.StartInvitationL(); |
|
1056 } |
|
1057 |
|
1058 // End of file |
|
1059 |