32 #include <es_sock.h> |
32 #include <es_sock.h> |
33 #include <bt_sock.h> |
33 #include <bt_sock.h> |
34 #include <msvids.h> |
34 #include <msvids.h> |
35 #include "debug.h" |
35 #include "debug.h" |
36 #include <bluetoothdevicedialogs.h> |
36 #include <bluetoothdevicedialogs.h> |
37 #include <hbtextresolversymbian.h> |
|
38 |
37 |
39 // CONSTANTS |
38 // CONSTANTS |
40 _LIT8(KBipCapabilityType, "x-bt/img-capabilities\0"); |
39 _LIT8(KBipCapabilityType, "x-bt/img-capabilities\0"); |
41 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3 |
40 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3 |
42 const TInt KBufferSize = 0x10000; // 64 kB |
41 const TInt KBufferSize = 0x10000; // 64 kB |
43 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
42 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" ); |
44 _LIT(KLocFileName, "btdialogs_"); |
43 const TInt KMaxDisplayFileName = 20; |
45 _LIT(KPath, "z:/resource/qt/translations/"); |
44 const TInt KMinStringSize = 11; |
46 |
45 |
47 |
46 |
48 // ================= MEMBER FUNCTIONS ======================= |
47 // ================= MEMBER FUNCTIONS ======================= |
49 |
48 |
50 CBIPController* CBIPController::NewL() |
49 CBIPController* CBIPController::NewL() |
76 iLowMemoryActiveMMC = CObexUtilsPropertyNotifier::NewL(this, ECheckMMCMemory); |
75 iLowMemoryActiveMMC = CObexUtilsPropertyNotifier::NewL(this, ECheckMMCMemory); |
77 iDevMan = CBTEngDevMan::NewL(this); |
76 iDevMan = CBTEngDevMan::NewL(this); |
78 iResultArray = new(ELeave) CBTDeviceArray(1); |
77 iResultArray = new(ELeave) CBTDeviceArray(1); |
79 // Get default folder from CenRep |
78 // Get default folder from CenRep |
80 TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, KLCReceiveFolder, iCenRepFolder); |
79 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 } |
|
87 TRACE_FUNC_EXIT |
80 TRACE_FUNC_EXIT |
88 } |
81 } |
89 |
82 |
90 // --------------------------------------------------------- |
83 // --------------------------------------------------------- |
91 // ~CBIPController() |
84 // ~CBIPController() |
251 void CBIPController::TransportDownIndication() |
246 void CBIPController::TransportDownIndication() |
252 { |
247 { |
253 TRACE_FUNC |
248 TRACE_FUNC |
254 if(!iReceivingFailed && iShowRecvCompleteDialog) |
249 if(!iReceivingFailed && iShowRecvCompleteDialog) |
255 { |
250 { |
|
251 TFileName shortname; |
|
252 if ( iReceivingFileName.Length() > KMaxDisplayFileName ) |
|
253 { |
|
254 // Filename is too long, |
|
255 // We make it shorter. Hiding the chars in the middle part of filename. |
|
256 shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2); |
|
257 shortname.Append(_L("...")); |
|
258 shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2)); |
|
259 } |
|
260 else |
|
261 { |
|
262 shortname.Copy(iReceivingFileName); |
|
263 } |
|
264 |
256 //Launch recevice completed dialog. |
265 //Launch recevice completed dialog. |
257 iRecvDoneDialog = CHbDeviceDialogSymbian::NewL(); |
266 iRecvDoneDialog = CHbDeviceDialogSymbian::NewL(); |
258 iRecvDoneDialog->SetObserver(this); |
267 iRecvDoneDialog->SetObserver(this); |
259 |
268 |
260 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
269 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
261 CleanupStack::PushL(variantMap); |
270 CleanupStack::PushL(variantMap); |
262 |
271 |
263 TInt dialogIdx = TBluetoothDialogParams::EReceiveDone; |
272 TInt dialogIdx = TBluetoothDialogParams::EReceiveDone; |
264 CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), |
273 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
265 CHbSymbianVariant::EInt ); |
274 CHbSymbianVariant::EInt, *variantMap); |
266 CleanupStack::PushL(dialogType); |
275 |
267 TBuf16<6> dialogTypeKey; |
276 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
268 dialogTypeKey.Num(TBluetoothDialogParams::EDialogType); |
277 CHbSymbianVariant::EDes, *variantMap); |
269 User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType)); |
278 |
270 CleanupStack::Pop(dialogType); |
279 AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname, |
271 |
280 CHbSymbianVariant::EDes, *variantMap); |
272 CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), |
281 |
273 CHbSymbianVariant::EDes ); |
282 AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte, |
274 CleanupStack::PushL(deviceName); |
283 CHbSymbianVariant::EInt, *variantMap); |
275 TBuf16<6> deviceNameKey; |
284 |
276 deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName); |
285 AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount, |
277 User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName)); |
286 CHbSymbianVariant::EInt, *variantMap); |
278 CleanupStack::Pop(deviceName); |
287 |
279 |
288 TBuf<KMinStringSize> key(_L("OpenCnvView")); |
280 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), |
289 TBool option = ETrue; |
281 CHbSymbianVariant::EDes ); |
290 CHbSymbianVariant* value = CHbSymbianVariant::NewL( (TAny*) &option, CHbSymbianVariant::EBool ); |
282 CleanupStack::PushL(fileName); |
291 CleanupStack::PushL(value); |
283 TBuf16<6> fileNameKey; |
292 variantMap->Add(key, value); |
284 fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName); |
293 CleanupStack::Pop(value); |
285 User::LeaveIfError(variantMap->Add(fileNameKey, fileName)); |
294 |
286 CleanupStack::Pop(fileName); |
|
287 |
|
288 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, |
|
289 CHbSymbianVariant::EInt ); |
|
290 CleanupStack::PushL(fileSz); |
|
291 TBuf16<6> fileSzKey; |
|
292 fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize); |
|
293 User::LeaveIfError(variantMap->Add(fileSzKey, fileSz)); |
|
294 CleanupStack::Pop(fileSz); |
|
295 |
|
296 CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, |
|
297 CHbSymbianVariant::EInt ); |
|
298 CleanupStack::PushL(fileCnt); |
|
299 TBuf16<6> fileCntKey; |
|
300 fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount); |
|
301 User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt)); |
|
302 CleanupStack::Pop(fileCnt); |
|
303 |
|
304 iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this ); |
295 iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this ); |
305 CleanupStack::PopAndDestroy(variantMap); |
296 CleanupStack::PopAndDestroy(variantMap); |
306 |
297 |
307 iShowRecvCompleteDialog = EFalse; |
298 iShowRecvCompleteDialog = EFalse; |
308 } |
299 } |
829 |
822 |
830 if(iTotalSizeByte > 0) |
823 if(iTotalSizeByte > 0) |
831 { |
824 { |
832 if(iReceivingFileName.Length() > 0) |
825 if(iReceivingFileName.Length() > 0) |
833 { |
826 { |
|
827 TFileName shortname; |
|
828 if ( iReceivingFileName.Length() > KMaxDisplayFileName ) |
|
829 { |
|
830 // Filename is too long, |
|
831 // We make it shorter. Hiding the chars in the middle part of filename. |
|
832 shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2); |
|
833 shortname.Append(_L("...")); |
|
834 shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2)); |
|
835 } |
|
836 else |
|
837 { |
|
838 shortname.Copy(iReceivingFileName); |
|
839 } |
|
840 |
834 iProgressDialog = CHbDeviceDialogSymbian::NewL(); |
841 iProgressDialog = CHbDeviceDialogSymbian::NewL(); |
835 iProgressDialog->SetObserver(this); |
842 iProgressDialog->SetObserver(this); |
836 |
843 |
837 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
844 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
838 CleanupStack::PushL(variantMap); |
845 CleanupStack::PushL(variantMap); |
839 |
846 |
840 TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress; |
847 TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress; |
841 CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), |
848 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
842 CHbSymbianVariant::EInt ); |
849 CHbSymbianVariant::EInt, *variantMap); |
843 CleanupStack::PushL(dialogType); |
|
844 TBuf16<6> dialogTypeKey; |
|
845 dialogTypeKey.Num(TBluetoothDialogParams::EDialogType); |
|
846 User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType)); |
|
847 CleanupStack::Pop(dialogType); |
|
848 |
850 |
849 CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), |
851 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
850 CHbSymbianVariant::EDes ); |
852 CHbSymbianVariant::EDes, *variantMap); |
851 CleanupStack::PushL(deviceName); |
|
852 TBuf16<6> deviceNameKey; |
|
853 deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName); |
|
854 User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName)); |
|
855 CleanupStack::Pop(deviceName); |
|
856 |
853 |
857 CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), |
854 AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname, |
858 CHbSymbianVariant::EDes ); |
855 CHbSymbianVariant::EDes, *variantMap); |
859 CleanupStack::PushL(fileName); |
|
860 TBuf16<6> fileNameKey; |
|
861 fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName); |
|
862 User::LeaveIfError(variantMap->Add(fileNameKey, fileName)); |
|
863 CleanupStack::Pop(fileName); |
|
864 |
856 |
865 CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, |
857 AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte, |
866 CHbSymbianVariant::EInt ); |
858 CHbSymbianVariant::EInt, *variantMap); |
867 CleanupStack::PushL(fileSz); |
|
868 TBuf16<6> fileSzKey; |
|
869 fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize); |
|
870 User::LeaveIfError(variantMap->Add(fileSzKey, fileSz)); |
|
871 CleanupStack::Pop(fileSz); |
|
872 |
859 |
873 CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, |
860 AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount, |
874 CHbSymbianVariant::EInt ); |
861 CHbSymbianVariant::EInt, *variantMap); |
875 CleanupStack::PushL(fileCnt); |
862 |
876 TBuf16<6> fileCntKey; |
|
877 fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount); |
|
878 User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt)); |
|
879 CleanupStack::Pop(fileCnt); |
|
880 |
|
881 iDialogActive = ETrue; |
863 iDialogActive = ETrue; |
882 iProgressDialog->Show( KBTDevDialogId(), *variantMap, this ); |
864 iProgressDialog->Show( KBTDevDialogId(), *variantMap, this ); |
883 CleanupStack::PopAndDestroy(variantMap); |
865 CleanupStack::PopAndDestroy(variantMap); |
884 } |
866 } |
885 else |
867 else |
1084 //In case of Show, the device dialog will handle the opening of conversation view. |
1061 //In case of Show, the device dialog will handle the opening of conversation view. |
1085 iRecvDoneDialog->Cancel(); |
1062 iRecvDoneDialog->Cancel(); |
1086 delete iRecvDoneDialog; |
1063 delete iRecvDoneDialog; |
1087 iRecvDoneDialog = NULL; |
1064 iRecvDoneDialog = NULL; |
1088 }break; |
1065 }break; |
|
1066 default: |
|
1067 break; |
1089 } |
1068 } |
1090 } |
1069 } |
1091 } |
1070 } |
1092 |
1071 |
1093 void CBIPController::DeviceDialogClosed(TInt aCompletionCode) |
1072 void CBIPController::DeviceDialogClosed(TInt aCompletionCode) |
1094 { |
1073 { |
1095 (void) aCompletionCode; |
1074 (void) aCompletionCode; |
1096 } |
1075 } |
1097 |
1076 |
|
1077 void CBIPController::LaunchFailureDialogL() |
|
1078 { |
|
1079 if(iFailureDialog) |
|
1080 { |
|
1081 iFailureDialog->Cancel(); |
|
1082 delete iFailureDialog; |
|
1083 iFailureDialog = NULL; |
|
1084 } |
|
1085 |
|
1086 iFailureDialog = CHbDeviceDialogSymbian::NewL(); |
|
1087 |
|
1088 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1089 CleanupStack::PushL(variantMap); |
|
1090 |
|
1091 TInt dialogIdx = TBluetoothDialogParams::EInformationDialog; |
|
1092 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
1093 CHbSymbianVariant::EInt, *variantMap); |
|
1094 |
|
1095 AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName, |
|
1096 CHbSymbianVariant::EDes, *variantMap); |
|
1097 |
|
1098 TInt dialogTitleIdx = TBluetoothDialogParams::ERecvFailed; |
|
1099 AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx, |
|
1100 CHbSymbianVariant::EInt, *variantMap); |
|
1101 |
|
1102 TUint32 deviceClass = iResultArray->At(0)->DeviceClass().DeviceClass(); |
|
1103 AddParamL(TBluetoothDeviceDialog::EDeviceClass, (TAny*) &deviceClass, |
|
1104 CHbSymbianVariant::EInt, *variantMap); |
|
1105 |
|
1106 iFailureDialog->Show( KBTDevDialogId(), *variantMap ); |
|
1107 CleanupStack::PopAndDestroy(variantMap); |
|
1108 |
|
1109 iReceivingFailed = EFalse; |
|
1110 } |
1098 |
1111 |
1099 //////////////////////////// Global part //////////////////////////// |
1112 void CBIPController::LaunchMemoryFullDialogL(TInt aDrive) |
|
1113 { |
|
1114 if(iMemoryFullDailog) |
|
1115 { |
|
1116 iMemoryFullDailog->Cancel(); |
|
1117 delete iMemoryFullDailog; |
|
1118 iMemoryFullDailog = NULL; |
|
1119 } |
|
1120 |
|
1121 iMemoryFullDailog = CHbDeviceDialogSymbian::NewL(); |
|
1122 |
|
1123 CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL(); |
|
1124 CleanupStack::PushL(variantMap); |
|
1125 |
|
1126 TInt dialogIdx = TBluetoothDialogParams::EInformationDialog; |
|
1127 AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, |
|
1128 CHbSymbianVariant::EInt, *variantMap); |
|
1129 |
|
1130 TInt dialogTitleIdx = TBluetoothDialogParams::EMemoryFull; |
|
1131 AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx, |
|
1132 CHbSymbianVariant::EInt, *variantMap); |
|
1133 |
|
1134 TChar driveLetter; |
|
1135 iFs.DriveToChar(aDrive, driveLetter); |
|
1136 AddParamL(TBluetoothDeviceDialog::EDriveLetter, (TAny*) &driveLetter, |
|
1137 CHbSymbianVariant::EChar, *variantMap); |
|
1138 |
|
1139 TVolumeInfo volumeInfo; |
|
1140 iFs.Volume(volumeInfo, aDrive); |
|
1141 AddParamL(TBluetoothDeviceDialog::EDriveName, (TAny*) &(volumeInfo.iName), |
|
1142 CHbSymbianVariant::EDes, *variantMap); |
|
1143 |
|
1144 iMemoryFullDailog->Show( KBTDevDialogId(), *variantMap ); |
|
1145 CleanupStack::PopAndDestroy(variantMap); |
|
1146 } |
|
1147 |
|
1148 void CBIPController::AddParamL(const TInt aKey, const TAny* aValue, |
|
1149 CHbSymbianVariant::TType aValueType, CHbSymbianVariantMap& aVariantMap) |
|
1150 { |
|
1151 //Prepare the key |
|
1152 TBuf<KMinStringSize> key; |
|
1153 key.Num(aKey); |
|
1154 |
|
1155 //Prepare the value |
|
1156 CHbSymbianVariant* value = CHbSymbianVariant::NewL( aValue, aValueType ); |
|
1157 CleanupStack::PushL(value); |
|
1158 |
|
1159 //add the key-value pair to the variant map |
|
1160 User::LeaveIfError(aVariantMap.Add(key, value)); |
|
1161 |
|
1162 CleanupStack::Pop(value); |
|
1163 } |
|
1164 |
|
1165 //////////////////////////// Global part //////////////////////////// |
1100 |
1166 |
1101 // End of File |
1167 // End of File |