565 if( sa.ResultFlags() & TInquirySockAddr::ERssiValid ) |
569 if( sa.ResultFlags() & TInquirySockAddr::ERssiValid ) |
566 { |
570 { |
567 rssi = sa.Rssi() + KRssiRangeOffset; |
571 rssi = sa.Rssi() + KRssiRangeOffset; |
568 } |
572 } |
569 |
573 |
570 BtNotifNameUtils::SetDeviceNameL(aDevName, *newDevice); |
574 TBTDeviceName name(aDevName); |
571 |
575 if (!aIsNameComplete) |
572 // Update device popup list with newDevice |
576 { |
573 UpdateDeviceListL( newDevice, rssi ); |
577 // Append a little "..." to partial names. |
|
578 _LIT(KToBeContd, "..."); |
|
579 if (name.MaxLength() - name.Length() >= KToBeContd().Length()) |
|
580 { |
|
581 name.Append(KToBeContd); |
|
582 } |
|
583 } |
|
584 BtNotifNameUtils::SetDeviceNameL(name, *newDevice); |
574 |
585 |
575 // Append newDevice in the bottom of the "last seen" device array. |
586 // Append newDevice in the bottom of the "last seen" device array. |
576 iLastSeenDevicesArray->AppendL(newDevice); |
587 iLastSeenDevicesArray->AppendL(newDevice); |
|
588 iLastSeenDevicesNameComplete.AppendL(aIsNameComplete); |
577 CleanupStack::Pop(); // new device is under iLastSeenDevicesArray control now |
589 CleanupStack::Pop(); // new device is under iLastSeenDevicesArray control now |
578 |
590 |
|
591 __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iLastSeenDevicesNameComplete.Count(), |
|
592 User::Panic(_L("BTNotifInqUI - device array and name resolution status array out of sync"), KErrCorrupt)); |
|
593 |
|
594 // Update device popup list with newDevice |
|
595 AddToDeviceListBoxL( newDevice, rssi ); |
|
596 |
|
597 __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(), |
|
598 User::Panic(_L("BTNotifInqUI - device array and UI list out of sync"), KErrCorrupt)); |
|
599 |
579 FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() completed")); |
600 FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() completed")); |
580 } |
601 } |
|
602 |
|
603 void CBTInqUI::DeviceNameUpdatedL(const TNameRecord& aNameRecord, TInt aLastSeenIndex) |
|
604 { |
|
605 FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() Name found: %S"), &(aNameRecord.iName) )); |
|
606 |
|
607 TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr ); |
|
608 |
|
609 TInt rssi = 0; |
|
610 if( sa.ResultFlags() & TInquirySockAddr::ERssiValid ) |
|
611 { |
|
612 rssi = sa.Rssi() + KRssiRangeOffset; |
|
613 } |
|
614 |
|
615 BtNotifNameUtils::SetDeviceNameL(aNameRecord.iName, *iLastSeenDevicesArray->At(aLastSeenIndex)); |
|
616 DeviceUpdatedL(rssi, aLastSeenIndex); |
|
617 |
|
618 FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() completed")); |
|
619 } |
|
620 |
|
621 void CBTInqUI::PageTimeoutOnDeviceWithPartialNameL(TInt aLastSeenIndex) |
|
622 { |
|
623 FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL()")); |
|
624 DeviceUpdatedL(KMinimumStrength, aLastSeenIndex); |
|
625 FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL() completed")); |
|
626 } |
|
627 |
|
628 |
|
629 void CBTInqUI::DeviceUpdatedL(TInt aSignalStrength, TInt aLastSeenIndex) |
|
630 { |
|
631 FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()")); |
|
632 |
|
633 HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); |
|
634 FormatListBoxEntryL(*iLastSeenDevicesArray->At(aLastSeenIndex), aSignalStrength, formatString->Des()); |
|
635 |
|
636 // The assumption here is that iLastSeenDevicesArray is always accurately reflected |
|
637 // in iDeviceListRows so device indexes match. |
|
638 __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(), |
|
639 User::Panic(_L("BTNotifInqUI - device array and UI dev list out of sync not created"), KErrCorrupt)); |
|
640 |
|
641 iDeviceListRows->Delete(aLastSeenIndex); |
|
642 iDeviceListRows->InsertL(aLastSeenIndex, *formatString); |
|
643 CleanupStack::PopAndDestroy(); // formatString |
|
644 |
|
645 __ASSERT_DEBUG(iDeviceListBox, |
|
646 User::Panic(_L("BTNotifInqUI - UI list non-existant on name update"), KErrCorrupt)); |
|
647 iDeviceListBox->HandleItemAdditionL(); |
|
648 |
|
649 FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()")); |
|
650 } |
|
651 |
|
652 void CBTInqUI::FormatListBoxEntryL(CBTDevice& aDevice, const TInt aSignalStrength, TPtr aFormatString) |
|
653 { |
|
654 FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL()")); |
|
655 |
|
656 TInt iconIndex (EDeviceIconDefault); |
|
657 TInt defNameIndex (EBTDeviceNameIndexDefault); |
|
658 |
|
659 // Check whether the device is already in registry. |
|
660 TInt index = LookupFromDevicesArray(iPairedDevicesArray, &aDevice ); |
|
661 if( index >= 0 ) |
|
662 { |
|
663 // Update device's link key and friendly name |
|
664 // with those found from registry. |
|
665 aDevice.UpdateL( *( iPairedDevicesArray->At( index ) ) ); |
|
666 } |
|
667 |
|
668 for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++) |
|
669 { |
|
670 if ( ( aDevice.DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) && |
|
671 ( (aDevice.DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) || |
|
672 KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) ) |
|
673 { |
|
674 iconIndex = KDeviceRowLayoutTable[i].iIconIndex; |
|
675 defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex; |
|
676 break; |
|
677 } |
|
678 } |
|
679 |
|
680 if ( !aDevice.IsValidFriendlyName() && !aDevice.IsValidDeviceName() ) |
|
681 { |
|
682 BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), aDevice); |
|
683 } |
|
684 |
|
685 //Convert device name to Unocode for display |
|
686 if ( aDevice.IsValidFriendlyName() ) |
|
687 { |
|
688 aFormatString.Copy( aDevice.FriendlyName() ); |
|
689 } |
|
690 else |
|
691 { |
|
692 aFormatString.Copy( BTDeviceNameConverter::ToUnicodeL(aDevice.DeviceName())); |
|
693 } |
|
694 |
|
695 TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat); |
|
696 |
|
697 aFormatString.Insert( 0, iconFormat ); |
|
698 |
|
699 if( aSignalStrength > 0) |
|
700 { |
|
701 if( aSignalStrength <= KMediumStrength ) |
|
702 { |
|
703 aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) ); |
|
704 } |
|
705 else if( aSignalStrength <= KHighStrength ) |
|
706 { |
|
707 aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) ); |
|
708 } |
|
709 else |
|
710 { |
|
711 aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) ); |
|
712 } |
|
713 } |
|
714 |
|
715 // If the device is paired, add paired icon to format list |
|
716 // Paired device using JustWork file transfering mode is not shown as paired here. |
|
717 if( index >= 0 && IsUserAwarePaired ( aDevice.AsNamelessDevice() ) ) |
|
718 { |
|
719 aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) ); |
|
720 } |
|
721 else |
|
722 { |
|
723 // if device is blocked, add blocked icon to format list |
|
724 |
|
725 TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, &aDevice ); |
|
726 |
|
727 if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned()) |
|
728 { |
|
729 aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) ); |
|
730 } |
|
731 } |
|
732 FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL() completed")); |
|
733 } |
|
734 |
581 |
735 |
582 // ---------------------------------------------------------- |
736 // ---------------------------------------------------------- |
583 // CBTInqUI::InquiryComplete |
737 // CBTInqUI::InquiryComplete |
584 // Inquiry has been completed. |
738 // Inquiry has been completed. |
585 // ---------------------------------------------------------- |
739 // ---------------------------------------------------------- |
755 |
909 |
756 // ---------------------------------------------------------- |
910 // ---------------------------------------------------------- |
757 // CBTInqUI::UpdateDeviceListL |
911 // CBTInqUI::UpdateDeviceListL |
758 // ---------------------------------------------------------- |
912 // ---------------------------------------------------------- |
759 // |
913 // |
760 void CBTInqUI::UpdateDeviceListL( CBTDevice* aDevice, const TInt aSignalStrength ) |
914 void CBTInqUI::AddToDeviceListBoxL( CBTDevice* aDevice, const TInt aSignalStrength ) |
761 { |
915 { |
762 FLOG(_L("[BTNOTIF]\t CBTInqUI::UpdateDeviceListL()")); |
916 FLOG(_L("[BTNOTIF]\t CBTInqUI::AddToDeviceListBoxL()")); |
763 |
|
764 TInt iconIndex (EDeviceIconDefault); |
|
765 TInt defNameIndex (EBTDeviceNameIndexDefault); |
|
766 |
917 |
767 HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); |
918 HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); |
768 |
919 FormatListBoxEntryL(*aDevice, aSignalStrength, formatString->Des()); |
769 // Check whether the device is already in registry. |
|
770 TInt index = LookupFromDevicesArray(iPairedDevicesArray, aDevice ); |
|
771 |
|
772 if( index >= 0 ) |
|
773 { |
|
774 // Update device's link key and friendly name |
|
775 // with those found from registry. |
|
776 aDevice->UpdateL( *( iPairedDevicesArray->At( index ) ) ); |
|
777 } |
|
778 |
|
779 for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++) |
|
780 { |
|
781 if ( ( aDevice->DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) && |
|
782 ( (aDevice->DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) || |
|
783 KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) ) |
|
784 { |
|
785 iconIndex = KDeviceRowLayoutTable[i].iIconIndex; |
|
786 defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex; |
|
787 break; |
|
788 } |
|
789 } |
|
790 |
|
791 if ( !aDevice->IsValidFriendlyName() && !aDevice->IsValidDeviceName() ) |
|
792 { |
|
793 BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), *aDevice); |
|
794 } |
|
795 |
|
796 //Convert device name to Unocode for display |
|
797 if ( aDevice->IsValidFriendlyName() ) |
|
798 { |
|
799 formatString->Des().Copy( aDevice->FriendlyName() ); |
|
800 } |
|
801 else |
|
802 { |
|
803 formatString->Des().Copy( BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName())); |
|
804 } |
|
805 |
|
806 TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat); |
|
807 |
|
808 formatString->Des().Insert( 0, iconFormat ); |
|
809 |
|
810 if( aSignalStrength > 0) |
|
811 { |
|
812 if( aSignalStrength <= KMediumStrength ) |
|
813 { |
|
814 formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) ); |
|
815 } |
|
816 else if( aSignalStrength <= KHighStrength ) |
|
817 { |
|
818 formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) ); |
|
819 } |
|
820 else |
|
821 { |
|
822 formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) ); |
|
823 } |
|
824 } |
|
825 |
|
826 // If the device is paired, add paired icon to format list |
|
827 // Paired device using JustWork file transfering mode is not shown as paired here. |
|
828 if( index >= 0 && IsUserAwarePaired ( aDevice->AsNamelessDevice() ) ) |
|
829 { |
|
830 formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) ); |
|
831 } |
|
832 else |
|
833 { |
|
834 // if device is blocked, add blocked icon to format list |
|
835 |
|
836 TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, aDevice ); |
|
837 |
|
838 if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned()) |
|
839 { |
|
840 formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) ); |
|
841 } |
|
842 } |
|
843 |
920 |
844 // Add device format string into device items |
921 // Add device format string into device items |
845 // |
922 // |
846 TInt deviceCount = iDeviceListRows->Count(); |
923 TInt deviceCount = iDeviceListRows->Count(); |
847 iDeviceListRows->InsertL( deviceCount, *formatString ); |
924 iDeviceListRows->InsertL( deviceCount, *formatString ); |
848 CleanupStack::PopAndDestroy(); // formatString |
925 CleanupStack::PopAndDestroy(); // formatString |
849 |
926 |
850 TInt currentItemIndex = 0; |
927 TInt currentItemIndex = 0; |
851 if(deviceCount != 0 && iDeviceListBox) |
928 if(deviceCount != 0 && iDeviceListBox) |
852 { |
929 { |
853 // Store temporarily the highlighted device and destroy list box |
930 // Store temporarily the highlighted device and destroy list box |
854 // |
931 // |