diff -r 2455ef1f5bbc -r d5e927d5853b javaextensions/bluetooth/bluetoothcommons/bluetoothplatformcontrol/src.s60/s60btdialog.cpp --- a/javaextensions/bluetooth/bluetoothcommons/bluetoothplatformcontrol/src.s60/s60btdialog.cpp Wed Sep 01 12:33:18 2010 +0100 +++ b/javaextensions/bluetooth/bluetoothcommons/bluetoothplatformcontrol/src.s60/s60btdialog.cpp Tue Sep 14 21:06:50 2010 +0300 @@ -23,6 +23,13 @@ #include "s60btdialog.h" #include "logger.h" +#ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS +#include +#include +#include + +#define QUERY_BUF_LEN 512 +#endif using namespace java::bluetooth; @@ -44,7 +51,9 @@ void CS60BTDialog::ConstructL() { LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::ConstructL()"); +#ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS User::LeaveIfError(mNotifier.Connect()); +#endif LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::ConstructL()"); } @@ -57,7 +66,9 @@ { CS60BTDialog* self = new(ELeave) CS60BTDialog; CleanupStack::PushL(self); +#ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS self->ConstructL(); +#endif return self; } @@ -70,8 +81,11 @@ { JELOG2(EJavaBluetooth); LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::~CS60BTDialog()"); + +#ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS DoCancel(); mNotifier.Close(); +#endif LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::~CS60BTDialog()"); } @@ -87,13 +101,41 @@ JELOG2(EJavaBluetooth); LOG1(EJavaBluetooth, EInfo,"+ CS60BTDialog::ShowBTQueryDialog(): aQueryType = %d", aQueryType); + +#ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS mQueryParamsPckg().iMessageType = aQueryType; mQueryParamsPckg().iNameExists = ETrue; mQueryParamsPckg().iName.Copy(aAppName); mNotifier.StartNotifierAndGetResponse(mStatus, KBTGenericQueryNotifierUid, mQueryParamsPckg, mQueryResult); + User::WaitForRequest(mStatus); - User::WaitForRequest(mStatus); +#else + _LIT(KAppInfo,"Application %S cannot be used when Bluetooth is off Activate Bluetooth ?"); + _LIT(KAppInfomsg,"Change 'My phone's visibility' setting to 'Show to all'? Application '%S' cannot be used when the visibility is set as 'Hidden'."); + + TBuf queryBuf; + TInt err = KErrNone; + TBool userOpt; + + queryBuf.Zero(); + if (aQueryType == EBTIsOffJavaQuery) + { + queryBuf.Format(KAppInfo,&aAppName); + } + else if (aQueryType == EBTIsNotShownQuery) + { + queryBuf.Format(KAppInfomsg,&aAppName); + } + + TRAP(err, userOpt = ShowBTQueryHbDialogL(queryBuf)); + LOG1(EJavaBluetooth, EInfo," CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", err); + + if (err != KErrNone ) + mQueryResult = EFalse; + else + mQueryResult = userOpt; +#endif LOG1(EJavaBluetooth, EInfo,"- CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", mQueryResult()); return mQueryResult(); @@ -109,6 +151,42 @@ void CS60BTDialog::DoCancel() { LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::DoCancel()"); +#ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS mNotifier.CancelNotifier(KBTGenericQueryNotifierUid); +#endif LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::DoCancel()"); } + +#ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS + +TBool CS60BTDialog::ShowBTQueryHbDialogL(const TDesC& aBufData) +{ + TBool result = EFalse; + + CHbDeviceMessageBoxSymbian* messageBox + = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EQuestion); + CleanupStack::PushL(messageBox); + + messageBox->SetTextL(aBufData); + messageBox->SetTimeout(HbPopup::NoTimeout); + + // Read localised versions instead of hard coded values. + _LIT(KAllowButtonText, "Yes"); + _LIT(KDenyButtonText, "No"); + + messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::EAcceptButton, KAllowButtonText); + messageBox->SetButton(CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue); + messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::ERejectButton, KDenyButtonText); + messageBox->SetButton(CHbDeviceMessageBoxSymbian::ERejectButton, ETrue); + + if (messageBox->ExecL() == CHbDeviceMessageBoxSymbian::EAcceptButton) + result = ETrue; + else + result = EFalse; + + messageBox->Close(); + CleanupStack::PopAndDestroy(messageBox); + + return result; +} +#endif