javaextensions/bluetooth/bluetoothcommons/bluetoothplatformcontrol/src.s60/s60btdialog.cpp
branchRCL_3
changeset 71 d5e927d5853b
parent 66 2455ef1f5bbc
child 83 26b2b12093af
equal deleted inserted replaced
66:2455ef1f5bbc 71:d5e927d5853b
    21 #include <badesca.h>
    21 #include <badesca.h>
    22 
    22 
    23 #include "s60btdialog.h"
    23 #include "s60btdialog.h"
    24 #include "logger.h"
    24 #include "logger.h"
    25 
    25 
       
    26 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
       
    27 #include <hbdevicemessageboxsymbian.h>
       
    28 #include <hbpopup.h>
       
    29 #include <QtCore\qvariant.h>
       
    30 
       
    31 #define QUERY_BUF_LEN 512
       
    32 #endif
    26 
    33 
    27 using namespace java::bluetooth;
    34 using namespace java::bluetooth;
    28 
    35 
    29 
    36 
    30 // ======== MEMBER FUNCTIONS ========
    37 // ======== MEMBER FUNCTIONS ========
    42 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    43 //
    50 //
    44 void CS60BTDialog::ConstructL()
    51 void CS60BTDialog::ConstructL()
    45 {
    52 {
    46     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::ConstructL()");
    53     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::ConstructL()");
       
    54 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
    47     User::LeaveIfError(mNotifier.Connect());
    55     User::LeaveIfError(mNotifier.Connect());
       
    56 #endif
    48     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::ConstructL()");
    57     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::ConstructL()");
    49 }
    58 }
    50 
    59 
    51 
    60 
    52 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    55 //
    64 //
    56 CS60BTDialog* CS60BTDialog::NewLC()
    65 CS60BTDialog* CS60BTDialog::NewLC()
    57 {
    66 {
    58     CS60BTDialog* self = new(ELeave) CS60BTDialog;
    67     CS60BTDialog* self = new(ELeave) CS60BTDialog;
    59     CleanupStack::PushL(self);
    68     CleanupStack::PushL(self);
       
    69 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
    60     self->ConstructL();
    70     self->ConstructL();
       
    71 #endif
    61     return self;
    72     return self;
    62 }
    73 }
    63 
    74 
    64 
    75 
    65 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    68 //
    79 //
    69 CS60BTDialog::~CS60BTDialog()
    80 CS60BTDialog::~CS60BTDialog()
    70 {
    81 {
    71     JELOG2(EJavaBluetooth);
    82     JELOG2(EJavaBluetooth);
    72     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::~CS60BTDialog()");
    83     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::~CS60BTDialog()");
       
    84 
       
    85 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
    73     DoCancel();
    86     DoCancel();
    74     mNotifier.Close();
    87     mNotifier.Close();
       
    88 #endif
    75     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::~CS60BTDialog()");
    89     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::~CS60BTDialog()");
    76 }
    90 }
    77 
    91 
    78 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    79 // Displays BT query dialog.
    93 // Displays BT query dialog.
    85     TBTGenericQueryNoteType aQueryType)
    99     TBTGenericQueryNoteType aQueryType)
    86 {
   100 {
    87     JELOG2(EJavaBluetooth);
   101     JELOG2(EJavaBluetooth);
    88     LOG1(EJavaBluetooth, EInfo,"+ CS60BTDialog::ShowBTQueryDialog(): aQueryType = %d", aQueryType);
   102     LOG1(EJavaBluetooth, EInfo,"+ CS60BTDialog::ShowBTQueryDialog(): aQueryType = %d", aQueryType);
    89 
   103 
       
   104 
       
   105 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
    90     mQueryParamsPckg().iMessageType = aQueryType;
   106     mQueryParamsPckg().iMessageType = aQueryType;
    91     mQueryParamsPckg().iNameExists = ETrue;
   107     mQueryParamsPckg().iNameExists = ETrue;
    92     mQueryParamsPckg().iName.Copy(aAppName);
   108     mQueryParamsPckg().iName.Copy(aAppName);
    93     mNotifier.StartNotifierAndGetResponse(mStatus, KBTGenericQueryNotifierUid,
   109     mNotifier.StartNotifierAndGetResponse(mStatus, KBTGenericQueryNotifierUid,
    94                                           mQueryParamsPckg, mQueryResult);
   110                                           mQueryParamsPckg, mQueryResult);
       
   111     User::WaitForRequest(mStatus);
    95 
   112 
    96     User::WaitForRequest(mStatus);
   113 #else
       
   114     _LIT(KAppInfo,"Application %S cannot  be used when  Bluetooth is off Activate Bluetooth ?");
       
   115     _LIT(KAppInfomsg,"Change 'My phone's visibility' setting to 'Show to all'? Application '%S' cannot be used when the visibility is set as 'Hidden'.");
       
   116 
       
   117     TBuf<QUERY_BUF_LEN> queryBuf;
       
   118     TInt err = KErrNone;
       
   119     TBool userOpt;
       
   120 
       
   121     queryBuf.Zero();
       
   122     if (aQueryType == EBTIsOffJavaQuery)
       
   123     {
       
   124         queryBuf.Format(KAppInfo,&aAppName);
       
   125     }
       
   126     else if (aQueryType == EBTIsNotShownQuery)
       
   127     {
       
   128         queryBuf.Format(KAppInfomsg,&aAppName);
       
   129     }
       
   130 
       
   131     TRAP(err, userOpt = ShowBTQueryHbDialogL(queryBuf));
       
   132     LOG1(EJavaBluetooth, EInfo,"  CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", err);
       
   133 
       
   134     if (err != KErrNone )
       
   135         mQueryResult = EFalse;
       
   136     else
       
   137         mQueryResult = userOpt;
       
   138 #endif
    97 
   139 
    98     LOG1(EJavaBluetooth, EInfo,"- CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", mQueryResult());
   140     LOG1(EJavaBluetooth, EInfo,"- CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", mQueryResult());
    99     return mQueryResult();
   141     return mQueryResult();
   100 }
   142 }
   101 
   143 
   107 // ---------------------------------------------------------------------------
   149 // ---------------------------------------------------------------------------
   108 //
   150 //
   109 void CS60BTDialog::DoCancel()
   151 void CS60BTDialog::DoCancel()
   110 {
   152 {
   111     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::DoCancel()");
   153     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::DoCancel()");
       
   154 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
   112     mNotifier.CancelNotifier(KBTGenericQueryNotifierUid);
   155     mNotifier.CancelNotifier(KBTGenericQueryNotifierUid);
       
   156 #endif
   113     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::DoCancel()");
   157     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::DoCancel()");
   114 }
   158 }
       
   159 
       
   160 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
       
   161 
       
   162 TBool CS60BTDialog::ShowBTQueryHbDialogL(const TDesC& aBufData)
       
   163 {
       
   164     TBool result = EFalse;
       
   165 
       
   166     CHbDeviceMessageBoxSymbian* messageBox
       
   167     = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EQuestion);
       
   168     CleanupStack::PushL(messageBox);
       
   169 
       
   170     messageBox->SetTextL(aBufData);
       
   171     messageBox->SetTimeout(HbPopup::NoTimeout);
       
   172 
       
   173     // Read localised versions instead of hard coded values.
       
   174     _LIT(KAllowButtonText, "Yes");
       
   175     _LIT(KDenyButtonText, "No");
       
   176 
       
   177     messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::EAcceptButton, KAllowButtonText);
       
   178     messageBox->SetButton(CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue);
       
   179     messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::ERejectButton, KDenyButtonText);
       
   180     messageBox->SetButton(CHbDeviceMessageBoxSymbian::ERejectButton, ETrue);
       
   181 
       
   182     if (messageBox->ExecL() == CHbDeviceMessageBoxSymbian::EAcceptButton)
       
   183         result = ETrue;
       
   184     else
       
   185         result = EFalse;
       
   186 
       
   187     messageBox->Close();
       
   188     CleanupStack::PopAndDestroy(messageBox);
       
   189 
       
   190     return result;
       
   191 }
       
   192 #endif