46 #include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h> |
46 #include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h> |
47 #include <csxhelp/bt.hlp.hrh> // Help IDs |
47 #include <csxhelp/bt.hlp.hrh> // Help IDs |
48 |
48 |
49 #include <gstabhelper.h> |
49 #include <gstabhelper.h> |
50 #include <btui.mbg> // Tab icon for General Setting |
50 #include <btui.mbg> // Tab icon for General Setting |
|
51 #include <bluetoothuiutil.h> |
51 #include "BTUIMainView.h" // base View. |
52 #include "BTUIMainView.h" // base View. |
|
53 |
52 |
54 |
53 const TInt KAutoConnect2ndTry = 1; |
55 const TInt KAutoConnect2ndTry = 1; |
54 const TUint32 SetExcludePairedDeviceMask = 0x800000; |
56 const TUint32 SetExcludePairedDeviceMask = 0x800000; |
55 |
57 |
56 // ================= MEMBER FUNCTIONS ======================= |
58 // ================= MEMBER FUNCTIONS ======================= |
618 |
620 |
619 TBTDevice device; |
621 TBTDevice device; |
620 device.iIndex = index; |
622 device.iIndex = index; |
621 iModel->GetDevice(device); |
623 iModel->GetDevice(device); |
622 |
624 |
623 HBufC* stringholder = NULL; |
625 RBuf stringholder; |
|
626 CleanupClosePushL( stringholder ); |
624 |
627 |
625 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
628 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
626 // Choose confirmation phrase |
629 // Choose confirmation phrase |
627 // |
630 TInt resourceId = ( device.iStatus & tmp ) ? R_BT_WARN_ERASE_CONNECTED : |
628 if ( device.iStatus & tmp ) |
631 R_BT_WARN_ERASE; |
629 { |
632 BluetoothUiUtil::LoadResourceAndSubstringL( |
630 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, |
633 stringholder, resourceId, device.iName, 0 ); |
631 device.iName); |
|
632 } |
|
633 else |
|
634 { |
|
635 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName ); |
|
636 } |
|
637 |
634 |
638 // Create confirmation query |
635 // Create confirmation query |
639 // |
636 // |
640 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
637 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
641 |
638 |
651 { |
648 { |
652 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too |
649 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too |
653 covercl->BufStream().CommitL(); // no more data to send so commit buf |
650 covercl->BufStream().CommitL(); // no more data to send so commit buf |
654 } |
651 } |
655 } |
652 } |
656 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder); |
653 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, stringholder); |
657 |
654 |
658 CleanupStack::PopAndDestroy(stringholder); // stringholder |
655 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
659 |
656 |
660 if(keypress) // User has accepted the dialog |
657 if(keypress) // User has accepted the dialog |
661 { |
658 { |
662 // If device is connected we need to first to disconnect |
659 // If device is connected we need to first to disconnect |
663 // then unpair, otherwise unpairing does not succeed. |
660 // then unpair, otherwise unpairing does not succeed. |
770 |
767 |
771 //check if this is connected device |
768 //check if this is connected device |
772 |
769 |
773 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
770 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
774 |
771 |
775 HBufC* stringHolder = NULL; |
772 RBuf stringHolder; |
|
773 CleanupClosePushL( stringHolder ); |
|
774 TInt resouseId; |
776 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
775 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
777 stringHolder = StringLoader::LoadLC( |
776 { |
778 (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP: |
777 resouseId = iHelpEnabled? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
779 R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), |
778 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
780 device.iName); |
779 } |
781 else |
780 else |
782 stringHolder = StringLoader::LoadLC( |
781 { |
783 (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP), |
782 resouseId = iHelpEnabled ? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
784 device.iName); |
783 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
785 |
784 } |
786 |
785 BluetoothUiUtil::LoadResourceAndSubstringL( |
787 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, |
786 stringHolder, resouseId, device.iName, 0 ); |
|
787 |
|
788 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (stringHolder, |
788 CAknQueryDialog::EConfirmationTone); |
789 CAknQueryDialog::EConfirmationTone); |
789 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
790 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
790 |
791 |
791 (queryDialog)->Heading()->SetTextL(*header); |
792 (queryDialog)->Heading()->SetTextL(*header); |
792 queryDialog->SetFocus(ETrue); |
793 queryDialog->SetFocus(ETrue); |
976 // ---------------------------------------------------------- |
977 // ---------------------------------------------------------- |
977 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
978 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
978 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
979 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
979 { |
980 { |
980 TRAPD(err, |
981 TRAPD(err, |
981 HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName ); |
982 RBuf stringholder; |
|
983 CleanupClosePushL( stringholder ); |
|
984 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
985 stringholder, aNoteTextResource, aDevName, 0 ); |
982 aWaitDialog = new (ELeave) CAknWaitDialog( |
986 aWaitDialog = new (ELeave) CAknWaitDialog( |
983 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
987 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
984 aWaitDialog->PrepareLC(aNoteResource); |
988 aWaitDialog->PrepareLC(aNoteResource); |
985 aWaitDialog->SetTextL(*stringholder); |
989 aWaitDialog->SetTextL(stringholder); |
986 |
990 |
987 if(iCoverDisplayEnabled) |
991 if(iCoverDisplayEnabled) |
988 { |
992 { |
989 aWaitDialog->PublishDialogL( |
993 aWaitDialog->PublishDialogL( |
990 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
994 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
996 } |
1000 } |
997 } |
1001 } |
998 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
1002 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
999 aWaitDialog->RunLD(); |
1003 aWaitDialog->RunLD(); |
1000 |
1004 |
1001 CleanupStack::PopAndDestroy(stringholder); // stringholder |
1005 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
1002 ); |
1006 ); |
1003 // if the above functions leaves the iWaitNote is deleted, but |
1007 // if the above functions leaves the iWaitNote is deleted, but |
1004 // not set to NULL. This will cause a problem, when |
1008 // not set to NULL. This will cause a problem, when |
1005 // the items may be deleted again, since it has to |
1009 // the items may be deleted again, since it has to |
1006 // be a member variable, in order to be closed |
1010 // be a member variable, in order to be closed |
1066 device.iIndex = index; |
1070 device.iIndex = index; |
1067 iModel->GetDevice(device); |
1071 iModel->GetDevice(device); |
1068 iDisconnectQueryDevice = device;//remember device related with query dialog |
1072 iDisconnectQueryDevice = device;//remember device related with query dialog |
1069 |
1073 |
1070 // Create confirmation query |
1074 // Create confirmation query |
1071 HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName); |
1075 RBuf stringholder; |
1072 if (!iDisconnectQueryDlg) |
1076 CleanupClosePushL( stringholder ); |
|
1077 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1078 stringholder, R_BT_DISCONNECT_FROM, device.iName, 0 ); |
|
1079 if ( !iDisconnectQueryDlg ) |
1073 { |
1080 { |
1074 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
1081 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
1075 } |
1082 } |
1076 |
1083 |
1077 if(iCoverDisplayEnabled) |
1084 if(iCoverDisplayEnabled) |
1084 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too |
1091 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too |
1085 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1092 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1086 } |
1093 } |
1087 } |
1094 } |
1088 |
1095 |
1089 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder); |
1096 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, stringholder); |
1090 |
1097 |
1091 CleanupStack::PopAndDestroy(stringholder); // stringholder |
1098 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
1092 |
1099 |
1093 iDisconnectQueryDlg = NULL; |
1100 iDisconnectQueryDlg = NULL; |
1094 if(keypress) // User has accepted the dialog |
1101 if(keypress) // User has accepted the dialog |
1095 { |
1102 { |
1096 device.iOperation = EOpDisconnect; |
1103 device.iOperation = EOpDisconnect; |
1187 case KErrCancel: |
1194 case KErrCancel: |
1188 TRACE_INFO(_L("aError = KErrCancel")) |
1195 TRACE_INFO(_L("aError = KErrCancel")) |
1189 break; |
1196 break; |
1190 case KErrAlreadyExists: // connection exists allready |
1197 case KErrAlreadyExists: // connection exists allready |
1191 { |
1198 { |
1192 HBufC* stringholder = NULL; |
1199 RBuf stringholder; |
|
1200 CleanupClosePushL( stringholder ); |
1193 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
1201 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
1194 { |
1202 { |
1195 if(aConflictingDeviceNames->Count() == 1) |
1203 if(aConflictingDeviceNames->Count() == 1) |
1196 { |
1204 { |
1197 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT, |
1205 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
1198 *(*aConflictingDeviceNames)[0],iCoeEnv ); |
1206 R_BT_DISCONNECT_FIRST_PROMPT, |
|
1207 *(*aConflictingDeviceNames)[0], 0 ); |
1199 } |
1208 } |
1200 else |
1209 else |
1201 { |
1210 { |
1202 CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1); |
1211 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
1203 aa->InsertL(0, *(*aConflictingDeviceNames)[0] ); |
1212 R_BT_DISCONNECT_FIRST_STEREO_PROMPT, |
1204 aa->InsertL(1, *(*aConflictingDeviceNames)[1] ); |
1213 *(*aConflictingDeviceNames)[0], 0 ); |
1205 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT , |
1214 BluetoothUiUtil::AddSubstringL( stringholder, *(*aConflictingDeviceNames)[1], 1 ); |
1206 *aa,iCoeEnv); |
|
1207 delete(aa); |
|
1208 } |
1215 } |
1209 TRACE_INFO(_L("KErrAllreadyExists")) |
1216 TRACE_INFO(_L("KErrAllreadyExists")) |
1210 } |
1217 } |
1211 else |
1218 else |
1212 { |
1219 { |
1259 TRACE_INFO(_L("aError = KErrNone")) |
1266 TRACE_INFO(_L("aError = KErrNone")) |
1260 // Create note |
1267 // Create note |
1261 // |
1268 // |
1262 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
1269 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
1263 |
1270 |
1264 HBufC* stringHolder = NULL; |
1271 RBuf stringHolder; |
|
1272 CleanupClosePushL( stringHolder ); |
1265 |
1273 |
1266 if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw)) |
1274 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
1267 { |
1275 R_BT_CONF_CONNECTED_PROMPT, aDevice.iName, 0 ); |
1268 if (CallOnGoing()) |
1276 |
1269 { |
1277 if(iCoverDisplayEnabled) |
1270 stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree" |
1278 { |
1271 |
1279 CleanupStack::PushL(notePtr); |
1272 if(iCoverDisplayEnabled) |
1280 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
1273 { |
1281 CleanupStack::Pop(notePtr); |
1274 CleanupStack::PushL(notePtr); |
1282 |
1275 notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support |
1283 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
1276 CleanupStack::Pop(notePtr); |
1284 if (covercl) // returns null if __COVER_DISPLAY is not defined |
1277 } |
1285 { |
1278 |
1286 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
1279 notePtr->ExecuteLD(*stringHolder); |
1287 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1280 } |
1288 } |
1281 else |
1289 } |
1282 { |
|
1283 TRACE_INFO(_L("No call ongoing. Connected to")) |
|
1284 stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); // "Connected to %U" |
|
1285 |
|
1286 if(iCoverDisplayEnabled) |
|
1287 { |
|
1288 CleanupStack::PushL(notePtr); |
|
1289 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
|
1290 CleanupStack::Pop(notePtr); |
|
1291 |
|
1292 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
|
1293 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1294 { |
|
1295 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1296 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 notePtr->ExecuteLD(*stringHolder); |
|
1301 } |
|
1302 } |
|
1303 else |
|
1304 { |
|
1305 TRACE_INFO(_L("AccFW Supported. Connected to")) |
|
1306 stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); |
|
1307 |
1290 |
1308 if(iCoverDisplayEnabled) |
1291 notePtr->ExecuteLD(stringHolder); |
1309 { |
1292 CleanupStack::PopAndDestroy(&stringHolder); |
1310 CleanupStack::PushL(notePtr); |
|
1311 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
|
1312 CleanupStack::Pop(notePtr); |
|
1313 |
|
1314 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
|
1315 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1316 { |
|
1317 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1318 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1319 } |
|
1320 } |
|
1321 |
|
1322 notePtr->ExecuteLD(*stringHolder); |
|
1323 } |
|
1324 |
|
1325 CleanupStack::PopAndDestroy(stringHolder); |
|
1326 } |
1293 } |
1327 |
1294 |
1328 TRAP_IGNORE(LaunchSettingViewL();) |
1295 TRAP_IGNORE(LaunchSettingViewL();) |
1329 break; |
1296 break; |
1330 |
1297 |
1331 case KErrNotSupported: |
1298 case KErrNotSupported: |
1332 { |
1299 { |
1333 TRACE_INFO(_L("error = KErrNotSupported")) |
1300 TRACE_INFO(_L("error = KErrNotSupported")) |
1334 |
1301 |
|
1302 RBuf stringHolder; |
|
1303 CleanupClosePushL( stringHolder ); |
|
1304 |
|
1305 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
|
1306 R_BT_DEVICE_NOT_SUPPORTED, aDevice.iName, 0 ); |
1335 |
1307 |
1336 // create note |
1308 // create note |
1337 // |
1309 // |
1338 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
1310 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
1339 HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName); |
|
1340 |
1311 |
1341 if(iCoverDisplayEnabled) |
1312 if(iCoverDisplayEnabled) |
1342 { |
1313 { |
1343 CleanupStack::PushL(note); |
1314 CleanupStack::PushL(note); |
1344 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
1315 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
1611 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
1582 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
1612 // after this |
1583 // after this |
1613 } |
1584 } |
1614 TRACE_FUNC_EXIT |
1585 TRACE_FUNC_EXIT |
1615 } |
1586 } |
|
1587 |
|
1588 |
1616 // ------------------------------------------------------ |
1589 // ------------------------------------------------------ |
1617 // CBTUIPairedDevicesView::ShowDisconnecNote |
1590 // CBTUIPairedDevicesView::ShowDisconnecNote |
1618 // ------------------------------------------------------ |
1591 // ------------------------------------------------------ |
1619 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
1592 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
1620 { |
1593 { |
1621 HBufC* stringholder = StringLoader::LoadLC( |
1594 RBuf stringholder; |
1622 R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName); |
1595 CleanupClosePushL( stringholder ); |
1623 |
1596 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1597 stringholder, R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName, 0 ); |
1624 // Launch a waiting confirmation note |
1598 // Launch a waiting confirmation note |
1625 // |
1599 // |
1626 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
1600 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
1627 |
1601 |
1628 if(iCoverDisplayEnabled) |
1602 if(iCoverDisplayEnabled) |