39 const TUint KBTProgressInterval = 1000000; |
39 const TUint KBTProgressInterval = 1000000; |
40 |
40 |
41 const TUid KUidMsgTypeBt = {0x10009ED5}; |
41 const TUid KUidMsgTypeBt = {0x10009ED5}; |
42 //todo need to find a suitable header to include. This is from obexutilslayer.h |
42 //todo need to find a suitable header to include. This is from obexutilslayer.h |
43 |
43 |
44 const TInt KMaxDesCLength = 256; |
44 const TInt KMinStringSize = 10; |
45 |
45 |
46 |
46 |
47 //_LIT(KSendingDialog,"com.nokia.hb.btdevicedialog/1.0"); |
47 |
48 |
48 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
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"); |
|
56 |
49 |
57 // ============================ MEMBER FUNCTIONS =============================== |
50 // ============================ MEMBER FUNCTIONS =============================== |
58 |
51 |
59 // ----------------------------------------------------------------------------- |
52 // ----------------------------------------------------------------------------- |
60 // CBTServiceStarter::CBTServiceStarter |
53 // CBTServiceStarter::CBTServiceStarter |
89 iDevice = CBTDevice::NewL(); |
83 iDevice = CBTDevice::NewL(); |
90 iDialog = CObexUtilsDialog::NewL( this ); |
84 iDialog = CObexUtilsDialog::NewL( this ); |
91 iDelayedDestroyer = CBTServiceDelayedDestroyer::NewL(CActive::EPriorityStandard); |
85 iDelayedDestroyer = CBTServiceDelayedDestroyer::NewL(CActive::EPriorityStandard); |
92 FeatureManager::InitializeLibL(); |
86 FeatureManager::InitializeLibL(); |
93 iFeatureManagerInitialized = ETrue; |
87 iFeatureManagerInitialized = ETrue; |
94 iLocalisationInit = HbTextResolverSymbian::Init(KLocFileName, KPath); |
|
95 FLOG(_L("[BTSU]\t CBTServiceStarter::ConstructL() completed")); |
88 FLOG(_L("[BTSU]\t CBTServiceStarter::ConstructL() completed")); |
96 } |
89 } |
97 |
90 |
98 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
99 // CBTServiceStarter::NewL |
92 // CBTServiceStarter::NewL |
488 iProgressGetter = aGetter; |
488 iProgressGetter = aGetter; |
489 CancelWaitNote(); |
489 CancelWaitNote(); |
490 |
490 |
491 if ( !iProgressDialogActive ) |
491 if ( !iProgressDialogActive ) |
492 { |
492 { |
|
493 iShowDialogNote = ETrue; |
493 // todo need to change the last parameter because we are now using the textmap id which is a string |
494 // 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 |
495 // whether we replace it with that or remove the parameter is to be decided |
495 iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( |
496 iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( |
496 KUidMsgTypeBt, 0 ); |
497 KUidMsgTypeBt, 0 ); |
497 |
498 |
498 deviceName.CreateL(KMaxDesCLength); |
|
499 |
499 |
500 if ( iDevice->IsValidFriendlyName() ) |
500 if ( iDevice->IsValidFriendlyName() ) |
501 { |
501 { |
502 deviceName.Copy( iDevice->FriendlyName() ); |
502 deviceName.CreateL( iDevice->FriendlyName() ); |
503 } |
503 } |
504 else |
504 else |
505 { |
505 { |
506 deviceName.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); |
506 deviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); |
507 } |
507 } |
508 iDialog->LaunchProgressDialogL( this, aFileCount, |
508 iDialog->LaunchProgressDialogL( this, aFileCount, |
509 deviceName, KBTProgressInterval ); |
509 deviceName, KBTProgressInterval ); |
510 deviceName.Close(); |
510 deviceName.Close(); |
511 } |
511 } |
548 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed()")); |
548 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDismissed()")); |
549 if( aButtonId == ECancelButton ) |
549 if( aButtonId == ECancelButton ) |
550 { // this condition is hit for the progress dialog and connecting dialog cancel |
550 { // this condition is hit for the progress dialog and connecting dialog cancel |
551 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDissmissed(), cancelled by user")); |
551 FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDissmissed(), cancelled by user")); |
552 iUserCancel=ETrue; |
552 iUserCancel=ETrue; |
|
553 iShowDialogNote = EFalse; |
|
554 /* if ( iDevice->IsValidFriendlyName() ) |
|
555 { |
|
556 TRAP_IGNORE(iRemoteDeviceName.CreateL( iDevice->FriendlyName()) ); |
|
557 } |
|
558 else |
|
559 { |
|
560 TRAP_IGNORE( iRemoteDeviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()))); |
|
561 } |
|
562 |
|
563 iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass(); |
|
564 |
|
565 TRAP_IGNORE( ShowSendCompleteNoteL(ESendCancelled) );*/ |
|
566 |
553 if ( iController ) |
567 if ( iController ) |
554 { |
568 { |
555 iController->Abort(); |
569 iController->Abort(); |
556 } |
570 } |
557 else |
571 else |
576 |
591 |
577 // ----------------------------------------------------------------------------- |
592 // ----------------------------------------------------------------------------- |
578 // CBTServiceStarter::ShowErrorNote |
593 // CBTServiceStarter::ShowErrorNote |
579 // ----------------------------------------------------------------------------- |
594 // ----------------------------------------------------------------------------- |
580 // |
595 // |
581 void CBTServiceStarter::ShowErrorNote( TInt aReason ) const |
596 void CBTServiceStarter::ShowErrorNote( TInt aReason ) |
582 { |
597 { |
583 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote()")); |
598 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote()")); |
584 |
599 |
585 TBuf<KMaxDesCLength> buf; |
|
586 TPtrC sendTextMapId; |
|
587 |
|
588 if ( iDevice->IsValidFriendlyName() ) |
600 if ( iDevice->IsValidFriendlyName() ) |
589 { |
601 { |
590 buf.Copy( iDevice->FriendlyName() ); |
602 iRemoteDeviceName.CreateL( iDevice->FriendlyName() ); |
591 } |
603 } |
592 else |
604 else |
593 { |
605 { |
594 TRAP_IGNORE( buf.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()))); |
606 TRAP_IGNORE( iRemoteDeviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()))); |
595 } |
607 } |
596 |
608 |
|
609 iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass(); |
597 |
610 |
598 switch ( aReason ) |
611 switch ( aReason ) |
599 { |
612 { |
600 case EBTSNoError: |
613 case EBTSNoError: |
601 { |
614 { |
602 sendTextMapId.Set(KFilesSentText()); |
615 TRAP_IGNORE( ShowSendCompleteNoteL(ESendCompleted) ); |
603 break; |
616 break; |
604 } |
617 } |
605 case EBTSConnectingFailed: |
618 case EBTSConnectingFailed: |
606 case EBTSGettingFailed: |
619 case EBTSGettingFailed: |
607 case EBTSPuttingFailed: |
620 case EBTSPuttingFailed: |
|
621 { |
|
622 TRAP_IGNORE( ShowErrorMessageL(TBluetoothDialogParams::ESendFailed) ); |
|
623 break; |
|
624 } |
608 case EBTSNoSuitableProfiles: |
625 case EBTSNoSuitableProfiles: |
609 //todo below three enums are not valid and it is not being used at anywhere do we need to have it |
626 //todo below three enums are not valid and it is not being used at anywhere do we need to have it |
610 |
627 |
611 // case EBTSBIPSomeSend: |
628 // case EBTSBIPSomeSend: |
612 // case EBTSBIPOneNotSend: |
629 // case EBTSBIPOneNotSend: |
613 // case EBTSBIPNoneSend: |
630 // case EBTSBIPNoneSend: |
614 default: |
631 default: |
615 { |
|
616 sendTextMapId.Set(KSendingFailedText()); |
|
617 break; |
632 break; |
618 } |
|
619 } |
633 } |
620 |
|
621 |
|
622 if(iLocalisationInit) |
|
623 { |
|
624 TRAP_IGNORE( |
|
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")); |
634 FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote() completed")); |
637 } |
635 } |
638 |
636 |
639 |
637 |
640 |
638 |
642 // CBTServiceStarter::LaunchConfirmationQuery |
640 // CBTServiceStarter::LaunchConfirmationQuery |
643 // ----------------------------------------------------------------------------- |
641 // ----------------------------------------------------------------------------- |
644 // |
642 // |
645 void CBTServiceStarter::LaunchConfirmationQuery(const TDesC& aConfirmText) |
643 void CBTServiceStarter::LaunchConfirmationQuery(const TDesC& aConfirmText) |
646 { |
644 { |
647 TRAP_IGNORE(iDialog->LaunchQueryDialogL(aConfirmText )); |
645 TInt dialogTitle = TBluetoothDialogParams::EUnsupportedImages; |
|
646 iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass(); |
|
647 ShowErrorMessageL(dialogTitle,aConfirmText); |
648 } |
648 } |
649 |
649 |
650 // ----------------------------------------------------------------------------- |
650 // ----------------------------------------------------------------------------- |
651 // CBTServiceStarter::StopTransfer |
651 // CBTServiceStarter::StopTransfer |
652 // ----------------------------------------------------------------------------- |
652 // ----------------------------------------------------------------------------- |
1051 StopTransfer( aError ); |
1051 StopTransfer( aError ); |
1052 FLOG(_L("[BTSU]\t CBTServiceStarter::RunError() - completed")); |
1052 FLOG(_L("[BTSU]\t CBTServiceStarter::RunError() - completed")); |
1053 return KErrNone; |
1053 return KErrNone; |
1054 } |
1054 } |
1055 |
1055 |
1056 |
1056 void CBTServiceStarter::ShowSendCompleteNoteL(const TInt aDialogTitle) |
1057 |
1057 { |
1058 |
1058 iNotificationDialog = CHbDeviceDialogSymbian::NewL(); |
|
1059 iNotificationDialog->SetObserver(this); |
|
1060 |
|
1061 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1062 CleanupStack::PushL(variantMap); |
|
1063 |
|
1064 TInt dialogIdx = TBluetoothDialogParams::EGlobalNotif; |
|
1065 AddDataL(variantMap,TBluetoothDialogParams::EDialogType,&dialogIdx,CHbSymbianVariant::EInt); |
|
1066 |
|
1067 |
|
1068 AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceName,&iRemoteDeviceName, |
|
1069 CHbSymbianVariant::EDes); |
|
1070 |
|
1071 AddDataL(variantMap,TBluetoothDialogParams::EResource,&aDialogTitle, |
|
1072 CHbSymbianVariant::EInt); |
|
1073 |
|
1074 AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceClass,&iRemoteDeviceClass, |
|
1075 CHbSymbianVariant::EInt); |
|
1076 |
|
1077 iNotificationDialog->Show( KBTDevDialogId(), *variantMap, this ); |
|
1078 CleanupStack::PopAndDestroy(variantMap); |
|
1079 } |
|
1080 |
|
1081 void CBTServiceStarter::ShowErrorMessageL(const TInt aDialogTitle, |
|
1082 const TDesC& aConfirmText) |
|
1083 { |
|
1084 iNotificationDialog = CHbDeviceDialogSymbian::NewL(); |
|
1085 iNotificationDialog->SetObserver(this); |
|
1086 |
|
1087 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1088 CleanupStack::PushL(variantMap); |
|
1089 |
|
1090 TInt dialogIdx = TBluetoothDialogParams::EInformationDialog; |
|
1091 AddDataL(variantMap,TBluetoothDialogParams::EDialogType,&dialogIdx,CHbSymbianVariant::EInt); |
|
1092 |
|
1093 if(aDialogTitle == TBluetoothDialogParams::EUnsupportedImages ) |
|
1094 { |
|
1095 AddDataL(variantMap,TBluetoothDeviceDialog::EAdditionalDesc,&aConfirmText, |
|
1096 CHbSymbianVariant::EDes); |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceName,&iRemoteDeviceName, |
|
1101 CHbSymbianVariant::EDes); |
|
1102 } |
|
1103 |
|
1104 AddDataL(variantMap,TBluetoothDialogParams::EDialogTitle,&aDialogTitle, |
|
1105 CHbSymbianVariant::EInt); |
|
1106 |
|
1107 AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceClass,&iRemoteDeviceClass, |
|
1108 CHbSymbianVariant::EInt); |
|
1109 |
|
1110 iNotificationDialog->Show( KBTDevDialogId(), *variantMap, this ); |
|
1111 CleanupStack::PopAndDestroy(variantMap); |
|
1112 } |
|
1113 |
|
1114 void CBTServiceStarter::AddDataL(CHbSymbianVariantMap* aMap, const TInt aKey, |
|
1115 const TAny* aData, CHbSymbianVariant::TType aDataType) |
|
1116 { |
|
1117 TBuf<KMinStringSize> key; |
|
1118 key.Num(aKey); |
|
1119 |
|
1120 CHbSymbianVariant* value = CHbSymbianVariant::NewL(aData, aDataType); |
|
1121 CleanupStack::PushL( value ); |
|
1122 User::LeaveIfError( aMap->Add( key, value ) ); // aMap takes the ownership of value |
|
1123 CleanupStack::Pop( value ); |
|
1124 } |
|
1125 |
|
1126 |
|
1127 void CBTServiceStarter::DataReceived(CHbSymbianVariantMap& aData) |
|
1128 { |
|
1129 if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult"))==KErrNone) |
|
1130 { |
|
1131 TBool val = *(static_cast<TBool*>(aData.Get(_L("actionResult"))->Data())); |
|
1132 if(val) |
|
1133 { |
|
1134 DialogDismissed(EYesButton); |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 DialogDismissed(ENoButton); |
|
1139 } |
|
1140 if(iNotificationDialog) |
|
1141 { |
|
1142 delete iNotificationDialog; |
|
1143 iNotificationDialog = NULL; |
|
1144 } |
|
1145 } |
|
1146 } |
|
1147 |
|
1148 void CBTServiceStarter::DeviceDialogClosed(TInt aCompletionCode) |
|
1149 { |
|
1150 (void) aCompletionCode; |
|
1151 if(iNotificationDialog) |
|
1152 { |
|
1153 delete iNotificationDialog; |
|
1154 iNotificationDialog = NULL; |
|
1155 } |
|
1156 if ( iWaiter && iWaiter->IsStarted() ) |
|
1157 { |
|
1158 iWaiter->AsyncStop(); |
|
1159 } |
|
1160 } |
|
1161 |