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 |
625 |
619 TBTDevice device; |
626 TBTDevice device; |
620 device.iIndex = index; |
627 device.iIndex = index; |
621 iModel->GetDevice(device); |
628 iModel->GetDevice(device); |
622 |
629 |
623 HBufC* stringholder = NULL; |
630 RBuf stringholder; |
|
631 CleanupClosePushL( stringholder ); |
624 |
632 |
625 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
633 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
626 // Choose confirmation phrase |
634 // Choose confirmation phrase |
627 // |
635 TInt resourceId = ( device.iStatus & tmp ) ? R_BT_WARN_ERASE_CONNECTED : |
628 if ( device.iStatus & tmp ) |
636 R_BT_WARN_ERASE; |
629 { |
637 BluetoothUiUtil::LoadResourceAndSubstringL( |
630 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, |
638 stringholder, resourceId, device.iName, 0 ); |
631 device.iName); |
|
632 } |
|
633 else |
|
634 { |
|
635 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName ); |
|
636 } |
|
637 |
639 |
638 // Create confirmation query |
640 // Create confirmation query |
639 // |
641 // |
640 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
642 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
641 |
643 |
651 { |
653 { |
652 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too |
654 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 |
655 covercl->BufStream().CommitL(); // no more data to send so commit buf |
654 } |
656 } |
655 } |
657 } |
656 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder); |
658 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, stringholder); |
657 |
659 |
658 CleanupStack::PopAndDestroy(stringholder); // stringholder |
660 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
659 |
661 |
660 if(keypress) // User has accepted the dialog |
662 if(keypress) // User has accepted the dialog |
661 { |
663 { |
662 // If device is connected we need to first to disconnect |
664 // If device is connected we need to first to disconnect |
663 // then unpair, otherwise unpairing does not succeed. |
665 // then unpair, otherwise unpairing does not succeed. |
770 |
772 |
771 //check if this is connected device |
773 //check if this is connected device |
772 |
774 |
773 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
775 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
774 |
776 |
775 HBufC* stringHolder = NULL; |
777 RBuf stringHolder; |
|
778 CleanupClosePushL( stringHolder ); |
|
779 TInt resouseId; |
776 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
780 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
777 stringHolder = StringLoader::LoadLC( |
781 { |
778 (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP: |
782 resouseId = iHelpEnabled? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
779 R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), |
783 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
780 device.iName); |
784 } |
781 else |
785 else |
782 stringHolder = StringLoader::LoadLC( |
786 { |
783 (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP), |
787 resouseId = iHelpEnabled ? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
784 device.iName); |
788 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
785 |
789 } |
786 |
790 BluetoothUiUtil::LoadResourceAndSubstringL( |
787 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, |
791 stringHolder, resouseId, device.iName, 0 ); |
|
792 |
|
793 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (stringHolder, |
788 CAknQueryDialog::EConfirmationTone); |
794 CAknQueryDialog::EConfirmationTone); |
789 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
795 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
790 |
796 |
791 (queryDialog)->Heading()->SetTextL(*header); |
797 (queryDialog)->Heading()->SetTextL(*header); |
792 queryDialog->SetFocus(ETrue); |
798 queryDialog->SetFocus(ETrue); |
976 // ---------------------------------------------------------- |
982 // ---------------------------------------------------------- |
977 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
983 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
978 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
984 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
979 { |
985 { |
980 TRAPD(err, |
986 TRAPD(err, |
981 HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName ); |
987 RBuf stringholder; |
|
988 CleanupClosePushL( stringholder ); |
|
989 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
990 stringholder, aNoteTextResource, aDevName, 0 ); |
982 aWaitDialog = new (ELeave) CAknWaitDialog( |
991 aWaitDialog = new (ELeave) CAknWaitDialog( |
983 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
992 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
984 aWaitDialog->PrepareLC(aNoteResource); |
993 aWaitDialog->PrepareLC(aNoteResource); |
985 aWaitDialog->SetTextL(*stringholder); |
994 aWaitDialog->SetTextL(stringholder); |
986 |
995 |
987 if(iCoverDisplayEnabled) |
996 if(iCoverDisplayEnabled) |
988 { |
997 { |
989 aWaitDialog->PublishDialogL( |
998 aWaitDialog->PublishDialogL( |
990 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
999 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
996 } |
1005 } |
997 } |
1006 } |
998 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
1007 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
999 aWaitDialog->RunLD(); |
1008 aWaitDialog->RunLD(); |
1000 |
1009 |
1001 CleanupStack::PopAndDestroy(stringholder); // stringholder |
1010 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
1002 ); |
1011 ); |
1003 // if the above functions leaves the iWaitNote is deleted, but |
1012 // if the above functions leaves the iWaitNote is deleted, but |
1004 // not set to NULL. This will cause a problem, when |
1013 // not set to NULL. This will cause a problem, when |
1005 // the items may be deleted again, since it has to |
1014 // the items may be deleted again, since it has to |
1006 // be a member variable, in order to be closed |
1015 // be a member variable, in order to be closed |
1063 if(index == KErrNotFound) return; |
1072 if(index == KErrNotFound) return; |
1064 |
1073 |
1065 TBTDevice device; |
1074 TBTDevice device; |
1066 device.iIndex = index; |
1075 device.iIndex = index; |
1067 iModel->GetDevice(device); |
1076 iModel->GetDevice(device); |
|
1077 |
|
1078 if ( !( device.iStatus & EStatusBtuiConnected) ) |
|
1079 { |
|
1080 // If device is already disconnected, return immediately. |
|
1081 return; |
|
1082 } |
|
1083 |
1068 iDisconnectQueryDevice = device;//remember device related with query dialog |
1084 iDisconnectQueryDevice = device;//remember device related with query dialog |
1069 |
1085 |
1070 // Create confirmation query |
1086 // Create confirmation query |
1071 HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName); |
1087 RBuf stringholder; |
1072 if (!iDisconnectQueryDlg) |
1088 CleanupClosePushL( stringholder ); |
|
1089 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1090 stringholder, R_BT_DISCONNECT_FROM, device.iName, 0 ); |
|
1091 if ( !iDisconnectQueryDlg ) |
1073 { |
1092 { |
1074 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
1093 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
1075 } |
1094 } |
1076 |
1095 |
1077 if(iCoverDisplayEnabled) |
1096 if(iCoverDisplayEnabled) |
1084 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too |
1103 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 |
1104 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1086 } |
1105 } |
1087 } |
1106 } |
1088 |
1107 |
1089 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder); |
1108 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, stringholder); |
1090 |
1109 |
1091 CleanupStack::PopAndDestroy(stringholder); // stringholder |
1110 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
1092 |
1111 |
1093 iDisconnectQueryDlg = NULL; |
1112 iDisconnectQueryDlg = NULL; |
1094 if(keypress) // User has accepted the dialog |
1113 if(keypress) // User has accepted the dialog |
1095 { |
1114 { |
1096 device.iOperation = EOpDisconnect; |
1115 device.iOperation = EOpDisconnect; |
1187 case KErrCancel: |
1206 case KErrCancel: |
1188 TRACE_INFO(_L("aError = KErrCancel")) |
1207 TRACE_INFO(_L("aError = KErrCancel")) |
1189 break; |
1208 break; |
1190 case KErrAlreadyExists: // connection exists allready |
1209 case KErrAlreadyExists: // connection exists allready |
1191 { |
1210 { |
1192 HBufC* stringholder = NULL; |
1211 RBuf stringholder; |
|
1212 CleanupClosePushL( stringholder ); |
1193 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
1213 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
1194 { |
1214 { |
1195 if(aConflictingDeviceNames->Count() == 1) |
1215 if(aConflictingDeviceNames->Count() == 1) |
1196 { |
1216 { |
1197 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT, |
1217 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
1198 *(*aConflictingDeviceNames)[0],iCoeEnv ); |
1218 R_BT_DISCONNECT_FIRST_PROMPT, |
|
1219 *(*aConflictingDeviceNames)[0], 0 ); |
1199 } |
1220 } |
1200 else |
1221 else |
1201 { |
1222 { |
1202 CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1); |
1223 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
1203 aa->InsertL(0, *(*aConflictingDeviceNames)[0] ); |
1224 R_BT_DISCONNECT_FIRST_STEREO_PROMPT, |
1204 aa->InsertL(1, *(*aConflictingDeviceNames)[1] ); |
1225 *(*aConflictingDeviceNames)[0], 0 ); |
1205 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT , |
1226 BluetoothUiUtil::AddSubstringL( stringholder, *(*aConflictingDeviceNames)[1], 1 ); |
1206 *aa,iCoeEnv); |
|
1207 delete(aa); |
|
1208 } |
1227 } |
1209 TRACE_INFO(_L("KErrAllreadyExists")) |
1228 TRACE_INFO(_L("KErrAllreadyExists")) |
1210 } |
1229 } |
1211 else |
1230 else |
1212 { |
1231 { |
1259 TRACE_INFO(_L("aError = KErrNone")) |
1278 TRACE_INFO(_L("aError = KErrNone")) |
1260 // Create note |
1279 // Create note |
1261 // |
1280 // |
1262 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
1281 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
1263 |
1282 |
1264 HBufC* stringHolder = NULL; |
1283 RBuf stringHolder; |
|
1284 CleanupClosePushL( stringHolder ); |
1265 |
1285 |
1266 if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw)) |
1286 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
1267 { |
1287 R_BT_CONF_CONNECTED_PROMPT, aDevice.iName, 0 ); |
1268 if (CallOnGoing()) |
1288 |
1269 { |
1289 if(iCoverDisplayEnabled) |
1270 stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree" |
1290 { |
1271 |
1291 CleanupStack::PushL(notePtr); |
1272 if(iCoverDisplayEnabled) |
1292 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
1273 { |
1293 CleanupStack::Pop(notePtr); |
1274 CleanupStack::PushL(notePtr); |
1294 |
1275 notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support |
1295 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
1276 CleanupStack::Pop(notePtr); |
1296 if (covercl) // returns null if __COVER_DISPLAY is not defined |
1277 } |
1297 { |
1278 |
1298 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
1279 notePtr->ExecuteLD(*stringHolder); |
1299 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1280 } |
1300 } |
1281 else |
1301 } |
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 |
1302 |
1308 if(iCoverDisplayEnabled) |
1303 notePtr->ExecuteLD(stringHolder); |
1309 { |
1304 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 } |
1305 } |
1327 |
1306 |
1328 TRAP_IGNORE(LaunchSettingViewL();) |
1307 TRAP_IGNORE(LaunchSettingViewL();) |
1329 break; |
1308 break; |
1330 |
1309 |
1331 case KErrNotSupported: |
1310 case KErrNotSupported: |
1332 { |
1311 { |
1333 TRACE_INFO(_L("error = KErrNotSupported")) |
1312 TRACE_INFO(_L("error = KErrNotSupported")) |
1334 |
1313 |
|
1314 RBuf stringHolder; |
|
1315 CleanupClosePushL( stringHolder ); |
|
1316 |
|
1317 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
|
1318 R_BT_DEVICE_NOT_SUPPORTED, aDevice.iName, 0 ); |
1335 |
1319 |
1336 // create note |
1320 // create note |
1337 // |
1321 // |
1338 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
1322 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
1339 HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName); |
|
1340 |
1323 |
1341 if(iCoverDisplayEnabled) |
1324 if(iCoverDisplayEnabled) |
1342 { |
1325 { |
1343 CleanupStack::PushL(note); |
1326 CleanupStack::PushL(note); |
1344 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
1327 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
1611 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
1594 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
1612 // after this |
1595 // after this |
1613 } |
1596 } |
1614 TRACE_FUNC_EXIT |
1597 TRACE_FUNC_EXIT |
1615 } |
1598 } |
|
1599 |
|
1600 |
1616 // ------------------------------------------------------ |
1601 // ------------------------------------------------------ |
1617 // CBTUIPairedDevicesView::ShowDisconnecNote |
1602 // CBTUIPairedDevicesView::ShowDisconnecNote |
1618 // ------------------------------------------------------ |
1603 // ------------------------------------------------------ |
1619 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
1604 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
1620 { |
1605 { |
1621 HBufC* stringholder = StringLoader::LoadLC( |
1606 RBuf stringholder; |
1622 R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName); |
1607 CleanupClosePushL( stringholder ); |
1623 |
1608 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1609 stringholder, R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName, 0 ); |
1624 // Launch a waiting confirmation note |
1610 // Launch a waiting confirmation note |
1625 // |
1611 // |
1626 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
1612 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
1627 |
1613 |
1628 if(iCoverDisplayEnabled) |
1614 if(iCoverDisplayEnabled) |