--- a/btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp Wed Aug 18 09:59:05 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp Fri Sep 17 08:30:56 2010 +0300
@@ -30,15 +30,14 @@
#include <es_sock.h>
#include <bt_sock.h>
#include <bluetoothdevicedialogs.h>
-#include <hbtextresolversymbian.h>
// CONSTANTS
const TInt KBufferSize = 0x10000; // 64 kB
const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3
_LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
-_LIT(KLocFileName, "btdialogs_");
-_LIT(KPath, "z:/resource/qt/translations/");
+const TInt KMaxDisplayFileName = 20;
+const TInt KMinStringSize = 11;
// ================= MEMBER FUNCTIONS =======================
@@ -69,12 +68,6 @@
TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine,
KLCReceiveFolder,
iCenRepFolder);
- iDialog = CObexUtilsDialog::NewL(this);
- TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath);
- if (!ok)
- {
- User::Leave( KErrNotFound );
- }
}
COPPController::~COPPController()
@@ -91,9 +84,11 @@
delete iResultArray;
}
iFs.Close();
- delete iDialog;
+
delete iProgressDialog;
+ delete iFailureDialog;
delete iRecvDoneDialog;
+ delete iMemoryFullDailog;
}
// ---------------------------------------------------------
@@ -122,25 +117,21 @@
TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" )));
iReceivingFailed = ETrue;
iShowRecvCompleteDialog = EFalse;
- if( iObexTransferState == ETransferPut || iObexTransferState == ETransferPutDiskError )
+ if( iObexTransferState == ETransferPut || (!aAbort && iObexTransferState == ETransferPutDiskError) )
{
+ CancelTransfer();
+ if(iMediaType == ESrcsMediaBT)
+ {
+ TRAP_IGNORE(
+ LaunchFailureDialogL();
+ );
+ }
+ TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported)
+
if(iObexObject)
{
iObexObject->Reset();
}
- CancelTransfer();
- if(!aAbort)
- {
- if(iMediaType == ESrcsMediaBT)
- {
- TRAP_IGNORE(
- HBufC* note = HbTextResolverSymbian::LoadLC(_L("txt_bt_dpophead_receiving_failed"));
- iDialog->ShowErrorNoteL(note->Des());
- CleanupStack::PopAndDestroy(note);
- );
- }
- TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported)
- }
}
delete iBuf;
iBuf = NULL;
@@ -224,54 +215,50 @@
TRACE_FUNC
if(!iReceivingFailed && iShowRecvCompleteDialog)
{
+ TFileName shortname;
+ if ( iReceivingFileName.Length() > KMaxDisplayFileName )
+ {
+ // Filename is too long,
+ // We make it shorter. Hiding the chars in the middle part of filename.
+ shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+ shortname.Append(_L("..."));
+ shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+ }
+ else
+ {
+ shortname.Copy(iReceivingFileName);
+ }
+
//Launch recevice completed dialog.
iRecvDoneDialog = CHbDeviceDialogSymbian::NewL();
iRecvDoneDialog->SetObserver(this);
CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
CleanupStack::PushL(variantMap);
-
+
TInt dialogIdx = TBluetoothDialogParams::EReceiveDone;
- CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx),
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(dialogType);
- TBuf16<6> dialogTypeKey;
- dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
- User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
- CleanupStack::Pop(dialogType);
+ AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+ CHbSymbianVariant::EInt, *variantMap);
- CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName),
- CHbSymbianVariant::EDes );
- CleanupStack::PushL(deviceName);
- TBuf16<6> deviceNameKey;
- deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
- User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
- CleanupStack::Pop(deviceName);
+ AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+ CHbSymbianVariant::EDes, *variantMap);
+
+ AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+ CHbSymbianVariant::EDes, *variantMap);
- CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName),
- CHbSymbianVariant::EDes );
- CleanupStack::PushL(fileName);
- TBuf16<6> fileNameKey;
- fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
- User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
- CleanupStack::Pop(fileName);
+ AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+ CHbSymbianVariant::EInt, *variantMap);
- CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte,
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(fileSz);
- TBuf16<6> fileSzKey;
- fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
- User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
- CleanupStack::Pop(fileSz);
-
- CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount,
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(fileCnt);
- TBuf16<6> fileCntKey;
- fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
- User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
- CleanupStack::Pop(fileCnt);
-
+ AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ TBuf<KMinStringSize> key(_L("OpenCnvView"));
+ TBool option = ETrue;
+ CHbSymbianVariant* value = CHbSymbianVariant::NewL( (TAny*) &option, CHbSymbianVariant::EBool );
+ CleanupStack::PushL(value);
+ variantMap->Add(key, value);
+ CleanupStack::Pop(value);
+
iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this );
CleanupStack::PopAndDestroy(variantMap);
iShowRecvCompleteDialog = EFalse;
@@ -349,11 +336,8 @@
}
if(!capacity)
{
- //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
- //todo: Need to use Localized string.
- _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
- TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
-
+ LaunchMemoryFullDialogL(iDrive);
+
return KErrDiskFull;
}
}
@@ -517,10 +501,7 @@
//
if (SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, 0, iDrive ))
{
- //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
- //todo: Need to use Localized string.
- _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
- TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
+ LaunchMemoryFullDialogL(iDrive);
User::Leave(KErrGeneral);
}
@@ -786,53 +767,42 @@
{
if(iReceivingFileName.Length() > 0)
{
+ TFileName shortname;
+ if ( iReceivingFileName.Length() > KMaxDisplayFileName )
+ {
+ // Filename is too long,
+ // We make it shorter. Hiding the chars in the middle part of filename.
+ shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+ shortname.Append(_L("..."));
+ shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+ }
+ else
+ {
+ shortname.Copy(iReceivingFileName);
+ }
+
iProgressDialog = CHbDeviceDialogSymbian::NewL();
iProgressDialog->SetObserver(this);
CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
CleanupStack::PushL(variantMap);
-
+
TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress;
- CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx),
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(dialogType);
- TBuf16<6> dialogTypeKey;
- dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
- User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
- CleanupStack::Pop(dialogType);
+ AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+ CHbSymbianVariant::EInt, *variantMap);
- CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName),
- CHbSymbianVariant::EDes );
- CleanupStack::PushL(deviceName);
- TBuf16<6> deviceNameKey;
- deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
- User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
- CleanupStack::Pop(deviceName);
+ AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+ CHbSymbianVariant::EDes, *variantMap);
- CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName),
- CHbSymbianVariant::EDes );
- CleanupStack::PushL(fileName);
- TBuf16<6> fileNameKey;
- fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
- User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
- CleanupStack::Pop(fileName);
+ AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+ CHbSymbianVariant::EDes, *variantMap);
- CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte,
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(fileSz);
- TBuf16<6> fileSzKey;
- fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
- User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
- CleanupStack::Pop(fileSz);
+ AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+ CHbSymbianVariant::EInt, *variantMap);
- CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount,
- CHbSymbianVariant::EInt );
- CleanupStack::PushL(fileCnt);
- TBuf16<6> fileCntKey;
- fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
- User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
- CleanupStack::Pop(fileCnt);
-
+ AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+ CHbSymbianVariant::EInt, *variantMap);
+
iDialogActive = ETrue;
iProgressDialog->Show( KBTDevDialogId(), *variantMap, this );
CleanupStack::PopAndDestroy(variantMap);
@@ -1019,11 +989,6 @@
return EFalse;
}
- void COPPController::DialogDismissed(TInt aButtonId)
- {
- (void) aButtonId;
- }
-
void COPPController::DataReceived(CHbSymbianVariantMap& aData)
{
if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
@@ -1051,6 +1016,8 @@
delete iRecvDoneDialog;
iRecvDoneDialog = NULL;
}break;
+ default:
+ break;
}
}
}
@@ -1059,7 +1026,95 @@
{
(void) aCompletionCode;
}
+
+ void COPPController::LaunchFailureDialogL()
+ {
+ if(iFailureDialog)
+ {
+ iFailureDialog->Cancel();
+ delete iFailureDialog;
+ iFailureDialog = NULL;
+ }
-//////////////////////////// Global part ////////////////////////////
+ iFailureDialog = CHbDeviceDialogSymbian::NewL();
+
+ CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+ CleanupStack::PushL(variantMap);
+
+ TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+ AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+ CHbSymbianVariant::EDes, *variantMap);
+
+ TInt dialogTitleIdx = TBluetoothDialogParams::ERecvFailed;
+ AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ TUint32 deviceClass = iResultArray->At(0)->DeviceClass().DeviceClass();
+ AddParamL(TBluetoothDeviceDialog::EDeviceClass, (TAny*) &deviceClass,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ iFailureDialog->Show( KBTDevDialogId(), *variantMap );
+ CleanupStack::PopAndDestroy(variantMap);
+
+ iReceivingFailed = EFalse;
+ }
+
+ void COPPController::LaunchMemoryFullDialogL(TInt aDrive)
+ {
+ if(iMemoryFullDailog)
+ {
+ iMemoryFullDailog->Cancel();
+ delete iMemoryFullDailog;
+ iMemoryFullDailog = NULL;
+ }
+
+ iMemoryFullDailog = CHbDeviceDialogSymbian::NewL();
+
+ CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+ CleanupStack::PushL(variantMap);
+ TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+ AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ TInt dialogTitleIdx = TBluetoothDialogParams::EMemoryFull;
+ AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+ CHbSymbianVariant::EInt, *variantMap);
+
+ TChar driveLetter;
+ iFs.DriveToChar(aDrive, driveLetter);
+ AddParamL(TBluetoothDeviceDialog::EDriveLetter, (TAny*) &driveLetter,
+ CHbSymbianVariant::EChar, *variantMap);
+
+ TVolumeInfo volumeInfo;
+ iFs.Volume(volumeInfo, aDrive);
+ AddParamL(TBluetoothDeviceDialog::EDriveName, (TAny*) &(volumeInfo.iName),
+ CHbSymbianVariant::EDes, *variantMap);
+
+ iMemoryFullDailog->Show( KBTDevDialogId(), *variantMap );
+ CleanupStack::PopAndDestroy(variantMap);
+ }
+
+ void COPPController::AddParamL(const TInt aKey, const TAny* aValue,
+ CHbSymbianVariant::TType aValueType, CHbSymbianVariantMap& aVariantMap)
+ {
+ //Prepare the key
+ TBuf<KMinStringSize> key;
+ key.Num(aKey);
+
+ //Prepare the value
+ CHbSymbianVariant* value = CHbSymbianVariant::NewL( aValue, aValueType );
+ CleanupStack::PushL(value);
+
+ //add the key-value pair to the variant map
+ User::LeaveIfError(aVariantMap.Add(key, value));
+
+ CleanupStack::Pop(value);
+ }
+
+ //////////////////////////// Global part ////////////////////////////
+
// End of File