15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <avkon.hrh> // AVKON components |
|
21 #include "BIPController.h" |
20 #include "BIPController.h" |
22 #include "BIPCapabilityHandler.h" |
21 #include "BIPCapabilityHandler.h" |
23 #include "BIPImageHandler.h" |
22 #include "BIPImageHandler.h" |
24 |
23 |
25 |
24 |
26 #include <e32base.h> |
25 #include <e32base.h> |
27 #include <StringLoader.h> // Series 60 localisation stringloader |
|
28 #include <obexutilsmessagehandler.h> |
26 #include <obexutilsmessagehandler.h> |
29 #include <obexutilsuilayer.h> |
|
30 #include <obexutilsdialog.h> |
|
31 #include <UiklafInternalCRKeys.h> |
|
32 #include <Obexutils.rsg> |
|
33 #include <sysutil.h> |
27 #include <sysutil.h> |
34 #include <bautils.h> |
28 #include <bautils.h> |
35 #include <driveinfo.h> |
29 #include <driveinfo.h> |
36 #include <AknWaitDialog.h> |
|
37 #include <btengdomaincrkeys.h> |
30 #include <btengdomaincrkeys.h> |
38 #include <e32math.h> |
31 #include <e32math.h> |
39 #include <es_sock.h> |
32 #include <es_sock.h> |
40 #include <bt_sock.h> |
33 #include <bt_sock.h> |
41 #include <msvids.h> |
34 #include <msvids.h> |
42 #include "debug.h" |
35 #include "debug.h" |
|
36 #include <bluetoothdevicedialogs.h> |
|
37 #include <hbtextresolversymbian.h> |
43 |
38 |
44 // CONSTANTS |
39 // CONSTANTS |
45 _LIT8(KBipCapabilityType, "x-bt/img-capabilities\0"); |
40 _LIT8(KBipCapabilityType, "x-bt/img-capabilities\0"); |
46 |
41 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3 |
47 |
|
48 const TInt KBufferSize = 0x10000; // 64 kB |
42 const TInt KBufferSize = 0x10000; // 64 kB |
|
43 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
|
44 _LIT(KLocFileName, "btdialogs_"); |
|
45 _LIT(KPath, "z:/resource/qt/translations/"); |
|
46 |
49 |
47 |
50 // ================= MEMBER FUNCTIONS ======================= |
48 // ================= MEMBER FUNCTIONS ======================= |
51 |
49 |
52 CBIPController* CBIPController::NewL() |
50 CBIPController* CBIPController::NewL() |
53 { |
51 { |
78 iLowMemoryActiveMMC = CObexUtilsPropertyNotifier::NewL(this, ECheckMMCMemory); |
76 iLowMemoryActiveMMC = CObexUtilsPropertyNotifier::NewL(this, ECheckMMCMemory); |
79 iDevMan = CBTEngDevMan::NewL(this); |
77 iDevMan = CBTEngDevMan::NewL(this); |
80 iResultArray = new(ELeave) CBTDeviceArray(1); |
78 iResultArray = new(ELeave) CBTDeviceArray(1); |
81 // Get default folder from CenRep |
79 // Get default folder from CenRep |
82 TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, KLCReceiveFolder, iCenRepFolder); |
80 TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, KLCReceiveFolder, iCenRepFolder); |
|
81 iDialog = CObexUtilsDialog::NewL(this); |
|
82 TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath); |
|
83 if (!ok) |
|
84 { |
|
85 User::Leave( KErrNotFound ); |
|
86 } |
83 TRACE_FUNC_EXIT |
87 TRACE_FUNC_EXIT |
84 } |
88 } |
85 |
89 |
86 // --------------------------------------------------------- |
90 // --------------------------------------------------------- |
87 // ~CBIPController() |
91 // ~CBIPController() |
418 |
441 |
419 // --------------------------------------------------------- |
442 // --------------------------------------------------------- |
420 // SetPathIndication() |
443 // SetPathIndication() |
421 // --------------------------------------------------------- |
444 // --------------------------------------------------------- |
422 // |
445 // |
423 TInt CBIPController::SetPathIndication( const CObex::TSetPathInfo& /*aPathInfo*/, |
446 TInt CBIPController::SetPathIndication( const CObex::TSetPathInfo& aPathInfo, |
424 const TDesC8& /*aInfo*/) |
447 const TDesC8& aInfo) |
425 { |
448 { |
426 TRACE_FUNC |
449 TRACE_FUNC |
427 // SetPath is not implemented in BIP - so following IrOBEX guidance, return |
450 // SetPath is not implemented in BIP - so following IrOBEX guidance, return |
428 // the Forbidden response code. |
451 // the Forbidden response code. |
|
452 (void) aPathInfo; |
|
453 (void) aInfo; |
|
454 |
429 return KErrIrObexRespForbidden; |
455 return KErrIrObexRespForbidden; |
430 } |
456 } |
431 |
457 |
432 /** |
458 /** |
433 * This function is implementation for mixin-class for Obexutils. |
459 * This function is implementation for mixin-class for Obexutils. |
737 return; |
767 return; |
738 } |
768 } |
739 |
769 |
740 if(iTotalSizeByte > 0) |
770 if(iTotalSizeByte > 0) |
741 { |
771 { |
742 iProgressDialog = CGlobalProgressDialog::NewL(this); |
|
743 if(iReceivingFileName.Length() > 0) |
772 if(iReceivingFileName.Length() > 0) |
744 { |
773 { |
745 iProgressDialog->ShowProgressDialogNameSizeL(iReceivingFileName, iTotalSizeByte); |
774 iProgressDialog = CHbDeviceDialogSymbian::NewL(); |
|
775 iProgressDialog->SetObserver(this); |
|
776 |
|
777 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
778 CleanupStack::PushL(variantMap); |
|
779 |
|
780 TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress; |
|
781 CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), |
|
782 CHbSymbianVariant::EInt ); |
|
783 CleanupStack::PushL(dialogType); |
|
784 TBuf16<6> dialogTypeKey; |
|
785 dialogTypeKey.Num(TBluetoothDialogParams::EDialogType); |
|
786 User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType)); |
|
787 CleanupStack::Pop(dialogType); |
|
788 |
|
789 CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), |
|
790 CHbSymbianVariant::EDes ); |
|
791 CleanupStack::PushL(deviceName); |
|
792 TBuf16<6> deviceNameKey; |
|
793 deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName); |
|
794 User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName)); |
|
795 CleanupStack::Pop(deviceName); |
|
796 |
|
797 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), |
|
798 CHbSymbianVariant::EDes ); |
|
799 CleanupStack::PushL(fileName); |
|
800 TBuf16<6> fileNameKey; |
|
801 fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName); |
|
802 User::LeaveIfError(variantMap->Add(fileNameKey, fileName)); |
|
803 CleanupStack::Pop(fileName); |
|
804 |
|
805 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, |
|
806 CHbSymbianVariant::EInt ); |
|
807 CleanupStack::PushL(fileSz); |
|
808 TBuf16<6> fileSzKey; |
|
809 fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize); |
|
810 User::LeaveIfError(variantMap->Add(fileSzKey, fileSz)); |
|
811 CleanupStack::Pop(fileSz); |
|
812 |
|
813 CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, |
|
814 CHbSymbianVariant::EInt ); |
|
815 CleanupStack::PushL(fileCnt); |
|
816 TBuf16<6> fileCntKey; |
|
817 fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount); |
|
818 User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt)); |
|
819 CleanupStack::Pop(fileCnt); |
|
820 |
|
821 iDialogActive = ETrue; |
|
822 iProgressDialog->Show( KBTDevDialogId(), *variantMap, this ); |
|
823 CleanupStack::PopAndDestroy(variantMap); |
746 } |
824 } |
747 else |
825 else |
748 { |
826 { |
749 iProgressDialog->ShowProgressDialogL(R_BT_RECEIVING_DATA); |
827 // TODO |
|
828 iDialogActive = ETrue; |
750 } |
829 } |
751 } |
830 } |
752 else |
831 else |
753 { |
832 { |
754 iWaitDialog = CGlobalDialog::NewL(this); |
833 iDialogActive = ETrue; |
755 iWaitDialog->ShowNoteDialogL(R_BT_RECEIVING_DATA, ETrue); |
834 /* |
756 } |
835 * TODO - The functionality provided by CGlobalDialog will be removed |
757 } |
836 * TODO - and this will be provided by CGlobalProgressDialog. |
758 |
837 */ |
759 void CBIPController::UpdateReceivingIndicator() |
838 |
|
839 } |
|
840 } |
|
841 |
|
842 void CBIPController::UpdateReceivingIndicatorL() |
760 { |
843 { |
761 if(iProgressDialog) |
844 if(iProgressDialog) |
762 { |
845 { |
763 iProgressDialog->UpdateProgressDialog(iBTObject->BytesReceived(), iTotalSizeByte); |
846 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
764 } |
847 CleanupStack::PushL(variantMap); |
765 // else we are using a wait note, so no "need" to update |
848 |
766 } |
849 TInt bytesReceived = iBTObject->BytesReceived(); |
767 |
850 CHbSymbianVariant* progress = CHbSymbianVariant::NewL( (TAny*) &bytesReceived, CHbSymbianVariant::EInt ); |
768 void CBIPController::HandleGlobalProgressDialogL( TInt aSoftkey ) |
851 CleanupStack::PushL(progress); |
769 { |
852 User::LeaveIfError(variantMap->Add(_L("progress"), progress)); |
770 TRACE_FUNC |
853 CleanupStack::Pop(progress); |
771 |
854 |
772 if(aSoftkey == EAknSoftkeyCancel) |
855 iProgressDialog->Update(*variantMap); |
773 { |
856 CleanupStack::PopAndDestroy(variantMap); |
774 CancelTransfer(); |
|
775 } |
|
776 else if(aSoftkey == EAknSoftkeyHide) |
|
777 { |
|
778 CloseReceivingIndicator(EFalse); // Don't reset state as only hiding |
|
779 } |
|
780 } |
|
781 |
|
782 void CBIPController::HandleGlobalNoteDialogL( TInt aSoftkey ) |
|
783 { |
|
784 TRACE_FUNC |
|
785 |
|
786 if( aSoftkey == EAknSoftkeyCancel ) |
|
787 { |
|
788 CancelTransfer(); |
|
789 } |
|
790 else if( aSoftkey == EAknSoftkeyHide) |
|
791 { |
|
792 CloseReceivingIndicator(EFalse); // Don't reset state as only hiding |
|
793 } |
857 } |
794 } |
858 } |
795 |
859 |
796 void CBIPController::CloseReceivingIndicator(TBool aResetDisplayedState) |
860 void CBIPController::CloseReceivingIndicator(TBool aResetDisplayedState) |
797 { |
861 { |
888 } |
949 } |
889 } |
950 } |
890 } |
951 } |
891 } |
952 } |
892 |
953 |
|
954 TBool CBIPController::IsBackupRunning() |
|
955 { |
|
956 const TUint32 KFileManagerBkupStatus = 0x00000001; |
|
957 |
|
958 TInt status = EFileManagerBkupStatusUnset; |
|
959 TBool retValue = EFalse; |
|
960 TInt err = RProperty::Get( TUid::Uid(KFileManagerUID3), KFileManagerBkupStatus, |
|
961 status ); |
|
962 if ( err == KErrNone ) |
|
963 { |
|
964 if ( status == EFileManagerBkupStatusBackup || |
|
965 status == EFileManagerBkupStatusRestore ) |
|
966 { |
|
967 TSecureId fileManagerSecureId( KFileManagerUID3 ); |
|
968 //only returning ETrue if backup process is still active |
|
969 retValue = ProcessExists( fileManagerSecureId ); |
|
970 } |
|
971 } |
|
972 |
|
973 return retValue; |
|
974 } |
|
975 |
|
976 TBool CBIPController::ProcessExists( const TSecureId& aSecureId ) |
|
977 { |
|
978 _LIT( KFindPattern, "*" ); |
|
979 TFindProcess finder(KFindPattern); |
|
980 TFullName processName; |
|
981 while( finder.Next( processName ) == KErrNone ) |
|
982 { |
|
983 RProcess process; |
|
984 if ( process.Open( processName ) == KErrNone ) |
|
985 { |
|
986 TSecureId processId( process.SecureId() ); |
|
987 process.Close(); |
|
988 if( processId == aSecureId ) |
|
989 { |
|
990 return ETrue; |
|
991 } |
|
992 } |
|
993 } |
|
994 return EFalse; |
|
995 } |
|
996 |
|
997 void CBIPController::DialogDismissed(TInt aButtonId) |
|
998 { |
|
999 (void) aButtonId; |
|
1000 } |
|
1001 |
|
1002 void CBIPController::DataReceived(CHbSymbianVariantMap& aData) |
|
1003 { |
|
1004 if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0) |
|
1005 { |
|
1006 TInt val = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data())); |
|
1007 if(!val) |
|
1008 { |
|
1009 //Cancel has been clicked |
|
1010 CancelTransfer(); |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 //Hide has been clicked |
|
1015 CloseReceivingIndicator(EFalse); |
|
1016 } |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 void CBIPController::DeviceDialogClosed(TInt aCompletionCode) |
|
1021 { |
|
1022 (void) aCompletionCode; |
|
1023 } |
|
1024 |
|
1025 |
893 //////////////////////////// Global part //////////////////////////// |
1026 //////////////////////////// Global part //////////////////////////// |
894 |
1027 |
895 // End of File |
1028 // End of File |