22 #include "BTSUDebug.h" |
22 #include "BTSUDebug.h" |
23 #include "BTSOPPController.h" |
23 #include "BTSOPPController.h" |
24 #include "BTSBIPController.h" |
24 #include "BTSBIPController.h" |
25 #include "BTSBPPController.h" |
25 #include "BTSBPPController.h" |
26 |
26 |
27 #include <Obexutils.rsg> |
|
28 #include <obexutilsuilayer.h> |
|
29 #include <obexutilsmessagehandler.h> |
27 #include <obexutilsmessagehandler.h> |
30 #include <btnotif.h> |
|
31 #include <featmgr.h> |
28 #include <featmgr.h> |
32 #include "BTSProgresstimer.h" |
|
33 #include <hbdevicenotificationdialogsymbian.h> |
29 #include <hbdevicenotificationdialogsymbian.h> |
34 #include <btservices/bluetoothdevicedialogs.h> |
30 #include <hbtextresolversymbian.h> |
35 |
31 |
36 // CONSTANTS |
32 // CONSTANTS |
37 |
33 |
38 // From BT SIG - Assigned numbers |
34 // From BT SIG - Assigned numbers |
39 const TUint KBTServiceOPPSending = 0x1105; |
35 const TUint KBTServiceOPPSending = 0x1105; |
40 const TUint KBTServiceDirectPrinting = 0x1118; |
36 const TUint KBTServiceDirectPrinting = 0x1118; |
41 const TUint KBTServiceImagingResponder = 0x111B; |
37 const TUint KBTServiceImagingResponder = 0x111B; |
42 |
38 |
43 const TUint KBTProgressInterval = 1000000; |
39 const TUint KBTProgressInterval = 1000000; |
44 |
40 |
45 |
41 const TUid KUidMsgTypeBt = {0x10009ED5}; |
46 _LIT(KSendingDialog,"com.nokia.hb.btdevicedialog/1.0"); |
42 //todo need to find a suitable header to include. This is from obexutilslayer.h |
|
43 |
|
44 const TInt KMaxDesCLength = 256; |
|
45 |
|
46 |
|
47 //_LIT(KSendingDialog,"com.nokia.hb.btdevicedialog/1.0"); |
|
48 |
|
49 _LIT(KLocFileName, "btdialogs_"); |
|
50 _LIT(KPath, "z:/resource/qt/translations/"); |
|
51 |
|
52 _LIT(KFilesSentText, "txt_bt_dpophead_all_files_sent");//All files sent |
|
53 _LIT(KDeviceText,"txt_bt_dpopinfo_sent_to_1"); |
|
54 //_LIT(KNotConnectedText,"txt_bt_info_unable_to_connect_with_bluetooth"); |
|
55 _LIT(KSendingFailedText,"txt_bt_dpophead_sending_failed"); |
47 |
56 |
48 // ============================ MEMBER FUNCTIONS =============================== |
57 // ============================ MEMBER FUNCTIONS =============================== |
49 |
58 |
50 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
51 // CBTServiceStarter::CBTServiceStarter |
60 // CBTServiceStarter::CBTServiceStarter |
495 // |
462 // |
496 void CBTServiceStarter::CancelWaitNote() |
463 void CBTServiceStarter::CancelWaitNote() |
497 { |
464 { |
498 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelWaitNote()")); |
465 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelWaitNote()")); |
499 |
466 |
500 // if ( iDialog ) |
467 if ( iDialog ) |
501 // { |
468 { |
502 // TRAP_IGNORE( iDialog->CancelWaitDialogL() ); |
469 iDialog->CancelWaitDialog(); |
503 if(iProgressDialog) |
470 } |
504 { |
|
505 //This has to be tested |
|
506 iProgressDialog->Close(); |
|
507 } |
|
508 // } |
|
509 |
471 |
510 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelWaitNote() completed")); |
472 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelWaitNote() completed")); |
511 } |
473 } |
512 |
474 |
513 |
475 |
514 // ----------------------------------------------------------------------------- |
476 // ----------------------------------------------------------------------------- |
515 // CBTServiceStarter::LaunchProgressNoteL |
477 // CBTServiceStarter::LaunchProgressNoteL |
516 // ----------------------------------------------------------------------------- |
478 // ----------------------------------------------------------------------------- |
517 // |
479 // |
|
480 //todo reusing the second param aTotalSize to aFileCount as it is no longer used check it being used in other places |
518 void CBTServiceStarter::LaunchProgressNoteL( MBTServiceProgressGetter* aGetter, |
481 void CBTServiceStarter::LaunchProgressNoteL( MBTServiceProgressGetter* aGetter, |
519 TInt aTotalSize, TInt aFileCount) |
482 TInt aFileCount) |
520 { |
483 { |
521 FLOG(_L("[BTSU]\t CBTServiceStarter::LaunchProgressNoteL()")); |
484 FLOG(_L("[BTSU]\t CBTServiceStarter::LaunchProgressNoteL()")); |
522 (void) aTotalSize; |
485 RBuf deviceName; |
523 |
|
524 if ( iService != EBTPrintingService ) |
486 if ( iService != EBTPrintingService ) |
525 { |
487 { |
526 iProgressGetter = aGetter; |
488 iProgressGetter = aGetter; |
527 CancelWaitNote(); |
489 CancelWaitNote(); |
528 |
490 |
529 if ( !iProgressDialogActive ) |
491 if ( !iProgressDialogActive ) |
530 { |
492 { |
531 iFileCount = aFileCount; |
493 // todo need to change the last parameter because we are now using the textmap id which is a string |
|
494 // whether we replace it with that or remove the parameter is to be decided |
532 iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( |
495 iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( |
533 KUidMsgTypeBt, R_BT_SEND_OUTBOX_SENDING ); |
496 KUidMsgTypeBt, 0 ); |
534 // iDialog->LaunchProgressDialogL( this, aTotalSize, |
497 |
535 // R_BT_SENDING_DATA, KBTProgressInterval ); |
498 deviceName.CreateL(KMaxDesCLength); |
536 CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL(); |
499 |
537 CleanupStack::PushL(map); |
500 if ( iDevice->IsValidFriendlyName() ) |
538 if ( iProgressTimer ) |
501 { |
539 { |
502 deviceName.Copy( iDevice->FriendlyName() ); |
540 iProgressTimer->Cancel(); |
|
541 delete iProgressTimer; |
|
542 iProgressTimer = NULL; |
|
543 } |
503 } |
544 |
504 else |
545 iProgressTimer = CBTSProgressTimer::NewL( this ); |
505 { |
546 iProgressTimer->SetTimeout( KBTProgressInterval ); |
506 deviceName.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); |
547 |
507 } |
548 iProgressTimer->Tickle(); |
508 iDialog->LaunchProgressDialogL( this, aFileCount, |
549 |
509 deviceName, KBTProgressInterval ); |
550 CHbSymbianVariant* value = NULL; |
510 deviceName.Close(); |
551 TBuf<6> key; |
|
552 TInt data = TBluetoothDialogParams::ESend; |
|
553 key.Num(TBluetoothDialogParams::EDialogType); |
|
554 value = CHbSymbianVariant::NewL( (TAny*) &data, CHbSymbianVariant::EInt ); |
|
555 User::LeaveIfError(map->Add( key, value )); // Takes ownership of value |
|
556 iDeviceDialog->Show(KSendingDialog(),*map,this); |
|
557 CleanupStack::PopAndDestroy(map); |
|
558 } |
511 } |
559 iProgressDialogActive=ETrue; |
512 iProgressDialogActive=ETrue; |
560 } |
513 } |
561 |
514 |
562 FLOG(_L("[BTSU]\t CBTServiceStarter::LaunchProgressNoteL() completed")); |
515 FLOG(_L("[BTSU]\t CBTServiceStarter::LaunchProgressNoteL() completed")); |
563 } |
516 } |
564 |
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CBTServiceStarter::UpdateProgressNoteL |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
565 void CBTServiceStarter::UpdateProgressNoteL(TInt aFileSize,TInt aFileIndex, const TDesC& aFileName ) |
522 void CBTServiceStarter::UpdateProgressNoteL(TInt aFileSize,TInt aFileIndex, const TDesC& aFileName ) |
566 { |
523 { |
567 HBufC* key = HBufC::NewL(50); |
524 |
568 CleanupStack::PushL(key); |
525 iDialog->UpdateProgressNoteL(aFileSize,aFileIndex,aFileName); |
569 |
526 } |
570 HBufC* value = HBufC::NewL(50); |
527 |
571 CleanupStack::PushL(value); |
|
572 |
|
573 CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL(); |
|
574 CleanupStack::PushL(map); |
|
575 |
|
576 iFileIndex = aFileIndex+1; |
|
577 key->Des().Copy(_L("currentFileIdx")); |
|
578 value->Des().AppendNum(aFileIndex+1); |
|
579 CHbSymbianVariant* currentFileIdx = CHbSymbianVariant::NewL(value, CHbSymbianVariant::EDes); |
|
580 map->Add(*key,currentFileIdx); |
|
581 |
|
582 key->Des().Copy(_L("totalFilesCnt")); |
|
583 value->Des().Zero(); |
|
584 value->Des().AppendNum(iFileCount); |
|
585 CHbSymbianVariant* totalFilesCnt = CHbSymbianVariant::NewL(value, CHbSymbianVariant::EDes); |
|
586 map->Add(*key,totalFilesCnt); |
|
587 |
|
588 |
|
589 key->Des().Copy(_L("destinationName")); |
|
590 if ( iDevice->IsValidFriendlyName() ) |
|
591 { |
|
592 value->Des().Copy( iDevice->FriendlyName() ); |
|
593 } |
|
594 else |
|
595 { |
|
596 value->Des().Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); |
|
597 } |
|
598 |
|
599 CHbSymbianVariant* destinationName = CHbSymbianVariant::NewL(value, CHbSymbianVariant::EDes); |
|
600 map->Add(*key,destinationName); |
|
601 |
|
602 key->Des().Copy(_L("fileName")); |
|
603 value->Des().Copy(aFileName); |
|
604 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL(value, CHbSymbianVariant::EDes); |
|
605 map->Add(*key,fileName); |
|
606 |
|
607 key->Des().Copy(_L("fileSzTxt")); |
|
608 value->Des().Zero(); |
|
609 if(aFileSize < 1024) |
|
610 { |
|
611 value->Des().AppendNum(aFileSize); |
|
612 value->Des().Append(_L(" Bytes")); |
|
613 } |
|
614 else |
|
615 { |
|
616 TInt filesize = aFileSize/1024; |
|
617 value->Des().AppendNum(filesize); |
|
618 value->Des().Append(_L(" KB")); |
|
619 } |
|
620 |
|
621 CHbSymbianVariant* fileSzTxt = CHbSymbianVariant::NewL(value, CHbSymbianVariant::EDes); |
|
622 map->Add(*key,fileSzTxt); |
|
623 |
|
624 |
|
625 key->Des().Copy(_L("fileSz")); |
|
626 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL(&aFileSize, CHbSymbianVariant::EInt); |
|
627 map->Add(*key,fileSz); |
|
628 |
|
629 |
|
630 |
|
631 TInt ret = iDeviceDialog->Update(*map); |
|
632 CleanupStack::PopAndDestroy(map); |
|
633 CleanupStack::PopAndDestroy(value); |
|
634 CleanupStack::PopAndDestroy(key); |
|
635 } |
|
636 // ----------------------------------------------------------------------------- |
528 // ----------------------------------------------------------------------------- |
637 // CBTServiceStarter::CancelProgressNote |
529 // CBTServiceStarter::CancelProgressNote |
638 // ----------------------------------------------------------------------------- |
530 // ----------------------------------------------------------------------------- |
639 // |
531 // |
640 void CBTServiceStarter::CancelProgressNote() |
532 void CBTServiceStarter::CancelProgressNote() |
641 { |
533 { |
642 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelProgressNote()")); |
534 FLOG(_L("[BTSU]\t CBTServiceStarter::CancelProgressNote()")); |
643 |
535 |
644 // if ( iDialog ) |
536 if ( iDialog ) |
645 { |
537 { |
646 // TRAP_IGNORE( iDialog->CancelProgressDialogL() ); |
538 iDialog->CancelProgressDialog(); |
647 if ( iProgressTimer ) |
539 } |
648 { |
|
649 iProgressTimer->Cancel(); |
|
650 delete iProgressTimer; |
|
651 iProgressTimer = NULL; |
|
652 } |
|
653 } |
|
654 if(iDeviceDialog) |
|
655 { |
|
656 iDeviceDialog->Cancel(); |
|
657 } |
|
658 } |
540 } |
659 |
541 |
660 // ----------------------------------------------------------------------------- |
542 // ----------------------------------------------------------------------------- |
661 // CBTServiceStarter::DialogDismissed |
543 // CBTServiceStarter::DialogDismissed |
662 // ----------------------------------------------------------------------------- |
544 // ----------------------------------------------------------------------------- |
663 // |
545 // |
664 void CBTServiceStarter::DialogDismissed( TInt aButtonId ) |
546 void CBTServiceStarter::DialogDismissed(TInt aButtonId ) |
665 { |
547 { |
666 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed()")); |
548 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed()")); |
667 if( aButtonId == EAknSoftkeyCancel ) |
549 if( aButtonId == ECancelButton ) |
668 { |
550 { // this condition is hit for the progress dialog and connecting dialog cancel |
669 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDissmissed(), cancelled by user")); |
551 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDissmissed(), cancelled by user")); |
670 iUserCancel=ETrue; |
552 iUserCancel=ETrue; |
671 if ( iController ) |
553 if ( iController ) |
672 { |
554 { |
673 iController->Abort(); |
555 iController->Abort(); |
675 else |
557 else |
676 { |
558 { |
677 StopTransfer(KErrCancel); |
559 StopTransfer(KErrCancel); |
678 } |
560 } |
679 } |
561 } |
680 else if ( aButtonId == EAknSoftkeyNo ) |
562 else if ( aButtonId == ENoButton ) |
681 { |
563 { |
682 // user abortion |
564 // user abortion |
683 // |
565 // |
684 iUserCancel = ETrue; |
566 iUserCancel = ETrue; |
685 StopTransfer( KErrCancel ); |
567 StopTransfer( KErrCancel ); |
|
568 CancelWaitNote(); |
|
569 } |
|
570 else //EYesButton |
|
571 {// this condition is hit when user is ok with sending the unsupported images |
|
572 iController->SendUnSupportedFiles(); |
686 } |
573 } |
687 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed() completed")); |
574 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed() completed")); |
688 } |
575 } |
689 |
576 |
690 // ----------------------------------------------------------------------------- |
577 // ----------------------------------------------------------------------------- |
691 // CBTServiceStarter::ShowNote |
578 // CBTServiceStarter::ShowErrorNote |
692 // ----------------------------------------------------------------------------- |
579 // ----------------------------------------------------------------------------- |
693 // |
580 // |
694 void CBTServiceStarter::ShowNote( TInt aReason ) const |
581 void CBTServiceStarter::ShowErrorNote( TInt aReason ) const |
695 { |
582 { |
696 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowNote()")); |
583 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote()")); |
697 |
584 |
698 // TInt resource = 0; |
585 TBuf<KMaxDesCLength> buf; |
699 TBuf<255> buf; |
586 TPtrC sendTextMapId; |
|
587 |
|
588 if ( iDevice->IsValidFriendlyName() ) |
|
589 { |
|
590 buf.Copy( iDevice->FriendlyName() ); |
|
591 } |
|
592 else |
|
593 { |
|
594 TRAP_IGNORE( buf.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()))); |
|
595 } |
|
596 |
700 |
597 |
701 switch ( aReason ) |
598 switch ( aReason ) |
702 { |
599 { |
703 case EBTSNoError: |
600 case EBTSNoError: |
704 { |
601 { |
705 /* if ( iService == EBTPrintingService ) |
602 sendTextMapId.Set(KFilesSentText()); |
706 { |
|
707 // resource = R_BT_DATA_SENT2; |
|
708 |
|
709 _LIT(KText, "Data Sent"); |
|
710 buf.Copy(KText); |
|
711 } |
|
712 else |
|
713 { |
|
714 //resource = R_BT_DATA_SENT;*/ |
|
715 _LIT(KText, "All files Sent to "); |
|
716 buf.Copy(KText); |
|
717 if ( iDevice->IsValidFriendlyName() ) |
|
718 { |
|
719 buf.Append( iDevice->FriendlyName() ); |
|
720 } |
|
721 else |
|
722 { |
|
723 TRAP_IGNORE( buf.Append( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()))); |
|
724 } |
|
725 |
|
726 |
|
727 // } |
|
728 break; |
603 break; |
729 } |
604 } |
730 case EBTSConnectingFailed: |
605 case EBTSConnectingFailed: |
731 { |
|
732 //resource = R_BT_DEV_NOT_AVAIL; |
|
733 _LIT(KText, "Cannot establish Bluetooth connection"); |
|
734 buf.Copy(KText); |
|
735 break; |
|
736 } |
|
737 case EBTSGettingFailed: |
606 case EBTSGettingFailed: |
738 case EBTSPuttingFailed: |
607 case EBTSPuttingFailed: |
739 { |
608 case EBTSNoSuitableProfiles: |
740 if ( iService == EBTPrintingService ) |
609 //todo below three enums are not valid and it is not being used at anywhere do we need to have it |
741 { |
610 |
742 _LIT(KText, "Sending failed"); |
611 // case EBTSBIPSomeSend: |
743 //resource = R_BT_FAILED_TO_SEND2; |
612 // case EBTSBIPOneNotSend: |
744 buf.Copy(KText); |
613 // case EBTSBIPNoneSend: |
745 } |
614 default: |
746 else |
615 { |
747 { |
616 sendTextMapId.Set(KSendingFailedText()); |
748 _LIT(KText, "Failed to send Data"); |
|
749 //resource = R_BT_FAILED_TO_SEND; |
|
750 buf.Copy(KText); |
|
751 } |
|
752 break; |
617 break; |
753 } |
618 } |
754 case EBTSNoSuitableProfiles: |
|
755 { |
|
756 if ( iService == EBTPrintingService ) |
|
757 { |
|
758 _LIT(KText, "Printer not supported"); |
|
759 buf.Copy(KText); |
|
760 // resource = R_BT_PRINTING_NOT_SUPPORTED; |
|
761 } |
|
762 else |
|
763 { |
|
764 _LIT(KText, "Failed to send Data"); |
|
765 buf.Copy(KText); |
|
766 // resource = R_BT_FAILED_TO_SEND; |
|
767 } |
|
768 break; |
|
769 } |
|
770 case EBTSBIPSomeSend: |
|
771 { |
|
772 _LIT(KText, "Failed to send Data"); |
|
773 buf.Copy(KText); |
|
774 //resource = R_BT_FAILED_TO_SEND; |
|
775 break; |
|
776 } |
|
777 case EBTSBIPOneNotSend: |
|
778 { |
|
779 _LIT(KText, "Receiving device does not support this image format."); |
|
780 buf.Copy(KText); |
|
781 //resource = R_BT_NOT_RECEIVE_ONE; |
|
782 break; |
|
783 } |
|
784 case EBTSBIPNoneSend: |
|
785 { |
|
786 _LIT(KText, "Receiving device does not support the needed image formats."); |
|
787 buf.Copy(KText); |
|
788 //resource = R_BT_NOT_RECEIVE_ANY; |
|
789 break; |
|
790 } |
|
791 default: |
|
792 { |
|
793 // resource = R_BT_DEV_NOT_AVAIL; |
|
794 _LIT(KText, "Cannot establish Bluetooth connection"); |
|
795 buf.Copy(KText); |
|
796 break; |
|
797 } |
|
798 } |
619 } |
799 |
620 |
800 // TRAP_IGNORE(TObexUtilsUiLayer::ShowInformationNoteL( resource ) ); |
621 |
801 // CHbDeviceMessageBoxSymbian::InformationL(buf); |
622 if(iLocalisationInit) |
802 TRAP_IGNORE(CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC, buf, KNullDesC)); |
623 { |
803 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowNote() completed")); |
624 TRAP_IGNORE( |
804 } |
625 HBufC* sendText = HbTextResolverSymbian::LoadLC(sendTextMapId); |
|
626 HBufC* deviceName = HbTextResolverSymbian::LoadLC(KDeviceText,buf); |
|
627 CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC, deviceName->Des(), sendText->Des()); |
|
628 CleanupStack::PopAndDestroy( deviceName ); |
|
629 CleanupStack::PopAndDestroy( sendText ); |
|
630 ); |
|
631 } |
|
632 else |
|
633 { |
|
634 TRAP_IGNORE(CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC, KDeviceText(), sendTextMapId)); |
|
635 } |
|
636 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote() completed")); |
|
637 } |
|
638 |
|
639 |
805 |
640 |
806 // ----------------------------------------------------------------------------- |
641 // ----------------------------------------------------------------------------- |
807 // CBTServiceStarter::LaunchConfirmationQuery |
642 // CBTServiceStarter::LaunchConfirmationQuery |
808 // ----------------------------------------------------------------------------- |
643 // ----------------------------------------------------------------------------- |
809 // |
644 // |
810 TInt CBTServiceStarter::LaunchConfirmationQuery(TInt /*aResourceId*/) |
645 void CBTServiceStarter::LaunchConfirmationQuery(const TDesC& aConfirmText) |
811 { |
646 { |
812 TInt keypress=0; |
647 TRAP_IGNORE(iDialog->LaunchQueryDialogL(aConfirmText )); |
813 // TRAP_IGNORE( keypress = iDialog->LaunchQueryDialogL( aResourceId )); |
648 } |
814 if ( !keypress ) |
|
815 { |
|
816 FLOG(_L("[BTSU]\t CBTServiceStarter::LaunchConfirmationQuery(), cancelled by user")); |
|
817 DialogDismissed(EAknSoftkeyNo); |
|
818 CancelWaitNote(); |
|
819 } |
|
820 return keypress; |
|
821 } |
|
822 |
649 |
823 // ----------------------------------------------------------------------------- |
650 // ----------------------------------------------------------------------------- |
824 // CBTServiceStarter::StopTransfer |
651 // CBTServiceStarter::StopTransfer |
825 // ----------------------------------------------------------------------------- |
652 // ----------------------------------------------------------------------------- |
826 // |
653 // |