28 #include <msvids.h> |
28 #include <msvids.h> |
29 #include <driveinfo.h> |
29 #include <driveinfo.h> |
30 #include <es_sock.h> |
30 #include <es_sock.h> |
31 #include <bt_sock.h> |
31 #include <bt_sock.h> |
32 #include <bluetoothdevicedialogs.h> |
32 #include <bluetoothdevicedialogs.h> |
33 #include <hbtextresolversymbian.h> |
|
34 |
33 |
35 // CONSTANTS |
34 // CONSTANTS |
36 |
35 |
37 const TInt KBufferSize = 0x10000; // 64 kB |
36 const TInt KBufferSize = 0x10000; // 64 kB |
38 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3 |
37 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3 |
39 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
38 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
40 _LIT(KLocFileName, "btdialogs_"); |
39 const TInt KMaxDisplayFileName = 20; |
41 _LIT(KPath, "z:/resource/qt/translations/"); |
40 const TInt KMinStringSize = 11; |
42 |
41 |
43 // ================= MEMBER FUNCTIONS ======================= |
42 // ================= MEMBER FUNCTIONS ======================= |
44 |
43 |
45 |
44 |
46 COPPController* COPPController::NewL() |
45 COPPController* COPPController::NewL() |
120 void COPPController::HandleError(TBool aAbort) |
115 void COPPController::HandleError(TBool aAbort) |
121 { |
116 { |
122 TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" ))); |
117 TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" ))); |
123 iReceivingFailed = ETrue; |
118 iReceivingFailed = ETrue; |
124 iShowRecvCompleteDialog = EFalse; |
119 iShowRecvCompleteDialog = EFalse; |
125 if( iObexTransferState == ETransferPut || iObexTransferState == ETransferPutDiskError ) |
120 if( iObexTransferState == ETransferPut || (!aAbort && iObexTransferState == ETransferPutDiskError) ) |
126 { |
121 { |
|
122 CancelTransfer(); |
|
123 if(iMediaType == ESrcsMediaBT) |
|
124 { |
|
125 TRAP_IGNORE( |
|
126 LaunchFailureDialogL(); |
|
127 ); |
|
128 } |
|
129 TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported) |
|
130 |
127 if(iObexObject) |
131 if(iObexObject) |
128 { |
132 { |
129 iObexObject->Reset(); |
133 iObexObject->Reset(); |
130 } |
134 } |
131 CancelTransfer(); |
|
132 if(!aAbort) |
|
133 { |
|
134 if(iMediaType == ESrcsMediaBT) |
|
135 { |
|
136 TRAP_IGNORE( |
|
137 HBufC* note = HbTextResolverSymbian::LoadLC(_L("txt_bt_dpophead_receiving_failed")); |
|
138 iDialog->ShowErrorNoteL(note->Des()); |
|
139 CleanupStack::PopAndDestroy(note); |
|
140 ); |
|
141 } |
|
142 TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported) |
|
143 } |
|
144 } |
135 } |
145 delete iBuf; |
136 delete iBuf; |
146 iBuf = NULL; |
137 iBuf = NULL; |
147 iObexTransferState = ETransferIdle; |
138 iObexTransferState = ETransferIdle; |
148 TRAP_IGNORE(TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMsvIdParent)); |
139 TRAP_IGNORE(TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMsvIdParent)); |
222 void COPPController::TransportDownIndication() |
213 void COPPController::TransportDownIndication() |
223 { |
214 { |
224 TRACE_FUNC |
215 TRACE_FUNC |
225 if(!iReceivingFailed && iShowRecvCompleteDialog) |
216 if(!iReceivingFailed && iShowRecvCompleteDialog) |
226 { |
217 { |
|
218 TFileName shortname; |
|
219 if ( iReceivingFileName.Length() > KMaxDisplayFileName ) |
|
220 { |
|
221 // Filename is too long, |
|
222 // We make it shorter. Hiding the chars in the middle part of filename. |
|
223 shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2); |
|
224 shortname.Append(_L("...")); |
|
225 shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2)); |
|
226 } |
|
227 else |
|
228 { |
|
229 shortname.Copy(iReceivingFileName); |
|
230 } |
|
231 |
227 //Launch recevice completed dialog. |
232 //Launch recevice completed dialog. |
228 iRecvDoneDialog = CHbDeviceDialogSymbian::NewL(); |
233 iRecvDoneDialog = CHbDeviceDialogSymbian::NewL(); |
229 iRecvDoneDialog->SetObserver(this); |
234 iRecvDoneDialog->SetObserver(this); |
230 |
235 |
231 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
236 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
232 CleanupStack::PushL(variantMap); |
237 CleanupStack::PushL(variantMap); |
|
238 |
|
239 TInt dialogIdx = TBluetoothDialogParams::EReceiveDone; |
|
240 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
241 CHbSymbianVariant::EInt, *variantMap); |
233 |
242 |
234 TInt dialogIdx = TBluetoothDialogParams::EReceiveDone; |
243 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
235 CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), |
244 CHbSymbianVariant::EDes, *variantMap); |
236 CHbSymbianVariant::EInt ); |
|
237 CleanupStack::PushL(dialogType); |
|
238 TBuf16<6> dialogTypeKey; |
|
239 dialogTypeKey.Num(TBluetoothDialogParams::EDialogType); |
|
240 User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType)); |
|
241 CleanupStack::Pop(dialogType); |
|
242 |
245 |
243 CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), |
246 AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname, |
244 CHbSymbianVariant::EDes ); |
247 CHbSymbianVariant::EDes, *variantMap); |
245 CleanupStack::PushL(deviceName); |
|
246 TBuf16<6> deviceNameKey; |
|
247 deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName); |
|
248 User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName)); |
|
249 CleanupStack::Pop(deviceName); |
|
250 |
248 |
251 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), |
249 AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte, |
252 CHbSymbianVariant::EDes ); |
250 CHbSymbianVariant::EInt, *variantMap); |
253 CleanupStack::PushL(fileName); |
|
254 TBuf16<6> fileNameKey; |
|
255 fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName); |
|
256 User::LeaveIfError(variantMap->Add(fileNameKey, fileName)); |
|
257 CleanupStack::Pop(fileName); |
|
258 |
251 |
259 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, |
252 AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount, |
260 CHbSymbianVariant::EInt ); |
253 CHbSymbianVariant::EInt, *variantMap); |
261 CleanupStack::PushL(fileSz); |
254 |
262 TBuf16<6> fileSzKey; |
255 TBuf<KMinStringSize> key(_L("OpenCnvView")); |
263 fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize); |
256 TBool option = ETrue; |
264 User::LeaveIfError(variantMap->Add(fileSzKey, fileSz)); |
257 CHbSymbianVariant* value = CHbSymbianVariant::NewL( (TAny*) &option, CHbSymbianVariant::EBool ); |
265 CleanupStack::Pop(fileSz); |
258 CleanupStack::PushL(value); |
266 |
259 variantMap->Add(key, value); |
267 CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, |
260 CleanupStack::Pop(value); |
268 CHbSymbianVariant::EInt ); |
261 |
269 CleanupStack::PushL(fileCnt); |
|
270 TBuf16<6> fileCntKey; |
|
271 fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount); |
|
272 User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt)); |
|
273 CleanupStack::Pop(fileCnt); |
|
274 |
|
275 iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this ); |
262 iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this ); |
276 CleanupStack::PopAndDestroy(variantMap); |
263 CleanupStack::PopAndDestroy(variantMap); |
277 iShowRecvCompleteDialog = EFalse; |
264 iShowRecvCompleteDialog = EFalse; |
278 } |
265 } |
279 |
266 |
784 |
765 |
785 if(iTotalSizeByte > 0) |
766 if(iTotalSizeByte > 0) |
786 { |
767 { |
787 if(iReceivingFileName.Length() > 0) |
768 if(iReceivingFileName.Length() > 0) |
788 { |
769 { |
|
770 TFileName shortname; |
|
771 if ( iReceivingFileName.Length() > KMaxDisplayFileName ) |
|
772 { |
|
773 // Filename is too long, |
|
774 // We make it shorter. Hiding the chars in the middle part of filename. |
|
775 shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2); |
|
776 shortname.Append(_L("...")); |
|
777 shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2)); |
|
778 } |
|
779 else |
|
780 { |
|
781 shortname.Copy(iReceivingFileName); |
|
782 } |
|
783 |
789 iProgressDialog = CHbDeviceDialogSymbian::NewL(); |
784 iProgressDialog = CHbDeviceDialogSymbian::NewL(); |
790 iProgressDialog->SetObserver(this); |
785 iProgressDialog->SetObserver(this); |
791 |
786 |
792 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
787 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
793 CleanupStack::PushL(variantMap); |
788 CleanupStack::PushL(variantMap); |
|
789 |
|
790 TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress; |
|
791 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
792 CHbSymbianVariant::EInt, *variantMap); |
794 |
793 |
795 TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress; |
794 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
796 CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), |
795 CHbSymbianVariant::EDes, *variantMap); |
797 CHbSymbianVariant::EInt ); |
|
798 CleanupStack::PushL(dialogType); |
|
799 TBuf16<6> dialogTypeKey; |
|
800 dialogTypeKey.Num(TBluetoothDialogParams::EDialogType); |
|
801 User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType)); |
|
802 CleanupStack::Pop(dialogType); |
|
803 |
796 |
804 CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), |
797 AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname, |
805 CHbSymbianVariant::EDes ); |
798 CHbSymbianVariant::EDes, *variantMap); |
806 CleanupStack::PushL(deviceName); |
|
807 TBuf16<6> deviceNameKey; |
|
808 deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName); |
|
809 User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName)); |
|
810 CleanupStack::Pop(deviceName); |
|
811 |
799 |
812 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), |
800 AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte, |
813 CHbSymbianVariant::EDes ); |
801 CHbSymbianVariant::EInt, *variantMap); |
814 CleanupStack::PushL(fileName); |
|
815 TBuf16<6> fileNameKey; |
|
816 fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName); |
|
817 User::LeaveIfError(variantMap->Add(fileNameKey, fileName)); |
|
818 CleanupStack::Pop(fileName); |
|
819 |
802 |
820 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, |
803 AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount, |
821 CHbSymbianVariant::EInt ); |
804 CHbSymbianVariant::EInt, *variantMap); |
822 CleanupStack::PushL(fileSz); |
805 |
823 TBuf16<6> fileSzKey; |
|
824 fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize); |
|
825 User::LeaveIfError(variantMap->Add(fileSzKey, fileSz)); |
|
826 CleanupStack::Pop(fileSz); |
|
827 |
|
828 CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, |
|
829 CHbSymbianVariant::EInt ); |
|
830 CleanupStack::PushL(fileCnt); |
|
831 TBuf16<6> fileCntKey; |
|
832 fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount); |
|
833 User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt)); |
|
834 CleanupStack::Pop(fileCnt); |
|
835 |
|
836 iDialogActive = ETrue; |
806 iDialogActive = ETrue; |
837 iProgressDialog->Show( KBTDevDialogId(), *variantMap, this ); |
807 iProgressDialog->Show( KBTDevDialogId(), *variantMap, this ); |
838 CleanupStack::PopAndDestroy(variantMap); |
808 CleanupStack::PopAndDestroy(variantMap); |
839 } |
809 } |
840 else |
810 else |
1049 //In case of Show, the device dialog will handle the opening of conversation view. |
1014 //In case of Show, the device dialog will handle the opening of conversation view. |
1050 iRecvDoneDialog->Cancel(); |
1015 iRecvDoneDialog->Cancel(); |
1051 delete iRecvDoneDialog; |
1016 delete iRecvDoneDialog; |
1052 iRecvDoneDialog = NULL; |
1017 iRecvDoneDialog = NULL; |
1053 }break; |
1018 }break; |
|
1019 default: |
|
1020 break; |
1054 } |
1021 } |
1055 } |
1022 } |
1056 } |
1023 } |
1057 |
1024 |
1058 void COPPController::DeviceDialogClosed(TInt aCompletionCode) |
1025 void COPPController::DeviceDialogClosed(TInt aCompletionCode) |
1059 { |
1026 { |
1060 (void) aCompletionCode; |
1027 (void) aCompletionCode; |
1061 } |
1028 } |
1062 |
1029 |
1063 //////////////////////////// Global part //////////////////////////// |
1030 void COPPController::LaunchFailureDialogL() |
1064 |
1031 { |
|
1032 if(iFailureDialog) |
|
1033 { |
|
1034 iFailureDialog->Cancel(); |
|
1035 delete iFailureDialog; |
|
1036 iFailureDialog = NULL; |
|
1037 } |
|
1038 |
|
1039 iFailureDialog = CHbDeviceDialogSymbian::NewL(); |
|
1040 |
|
1041 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1042 CleanupStack::PushL(variantMap); |
|
1043 |
|
1044 TInt dialogIdx = TBluetoothDialogParams::EInformationDialog; |
|
1045 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
1046 CHbSymbianVariant::EInt, *variantMap); |
|
1047 |
|
1048 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
|
1049 CHbSymbianVariant::EDes, *variantMap); |
|
1050 |
|
1051 TInt dialogTitleIdx = TBluetoothDialogParams::ERecvFailed; |
|
1052 AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx, |
|
1053 CHbSymbianVariant::EInt, *variantMap); |
|
1054 |
|
1055 TUint32 deviceClass = iResultArray->At(0)->DeviceClass().DeviceClass(); |
|
1056 AddParamL(TBluetoothDeviceDialog::EDeviceClass, (TAny*) &deviceClass, |
|
1057 CHbSymbianVariant::EInt, *variantMap); |
|
1058 |
|
1059 iFailureDialog->Show( KBTDevDialogId(), *variantMap ); |
|
1060 CleanupStack::PopAndDestroy(variantMap); |
|
1061 |
|
1062 iReceivingFailed = EFalse; |
|
1063 } |
|
1064 |
|
1065 void COPPController::LaunchMemoryFullDialogL(TInt aDrive) |
|
1066 { |
|
1067 if(iMemoryFullDailog) |
|
1068 { |
|
1069 iMemoryFullDailog->Cancel(); |
|
1070 delete iMemoryFullDailog; |
|
1071 iMemoryFullDailog = NULL; |
|
1072 } |
|
1073 |
|
1074 iMemoryFullDailog = CHbDeviceDialogSymbian::NewL(); |
|
1075 |
|
1076 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1077 CleanupStack::PushL(variantMap); |
|
1078 |
|
1079 TInt dialogIdx = TBluetoothDialogParams::EInformationDialog; |
|
1080 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
1081 CHbSymbianVariant::EInt, *variantMap); |
|
1082 |
|
1083 TInt dialogTitleIdx = TBluetoothDialogParams::EMemoryFull; |
|
1084 AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx, |
|
1085 CHbSymbianVariant::EInt, *variantMap); |
|
1086 |
|
1087 TChar driveLetter; |
|
1088 iFs.DriveToChar(aDrive, driveLetter); |
|
1089 AddParamL(TBluetoothDeviceDialog::EDriveLetter, (TAny*) &driveLetter, |
|
1090 CHbSymbianVariant::EChar, *variantMap); |
|
1091 |
|
1092 TVolumeInfo volumeInfo; |
|
1093 iFs.Volume(volumeInfo, aDrive); |
|
1094 AddParamL(TBluetoothDeviceDialog::EDriveName, (TAny*) &(volumeInfo.iName), |
|
1095 CHbSymbianVariant::EDes, *variantMap); |
|
1096 |
|
1097 iMemoryFullDailog->Show( KBTDevDialogId(), *variantMap ); |
|
1098 CleanupStack::PopAndDestroy(variantMap); |
|
1099 } |
|
1100 |
|
1101 void COPPController::AddParamL(const TInt aKey, const TAny* aValue, |
|
1102 CHbSymbianVariant::TType aValueType, CHbSymbianVariantMap& aVariantMap) |
|
1103 { |
|
1104 //Prepare the key |
|
1105 TBuf<KMinStringSize> key; |
|
1106 key.Num(aKey); |
|
1107 |
|
1108 //Prepare the value |
|
1109 CHbSymbianVariant* value = CHbSymbianVariant::NewL( aValue, aValueType ); |
|
1110 CleanupStack::PushL(value); |
|
1111 |
|
1112 //add the key-value pair to the variant map |
|
1113 User::LeaveIfError(aVariantMap.Add(key, value)); |
|
1114 |
|
1115 CleanupStack::Pop(value); |
|
1116 } |
|
1117 |
|
1118 //////////////////////////// Global part //////////////////////////// |
|
1119 |
1065 // End of File |
1120 // End of File |