javaextensions/bluetooth/bluetoothcommons/bluetoothplatformcontrol/src.s60/s60btdialog.cpp
branchRCL_3
changeset 19 04becd199f91
child 57 59b3b4473dc8
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <badesca.h>
       
    22 
       
    23 #include "s60btdialog.h"
       
    24 #include "logger.h"
       
    25 
       
    26 
       
    27 using namespace java::bluetooth;
       
    28 
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // Constructor just sets the priority of this active object to standard priority.
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CS60BTDialog::CS60BTDialog()
       
    37 {
       
    38 }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Connect to notifier.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 void CS60BTDialog::ConstructL()
       
    45 {
       
    46     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::ConstructL()");
       
    47     User::LeaveIfError(mNotifier.Connect());
       
    48     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::ConstructL()");
       
    49 }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Standard implementation
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CS60BTDialog* CS60BTDialog::NewLC()
       
    57 {
       
    58     CS60BTDialog* self = new(ELeave) CS60BTDialog;
       
    59     CleanupStack::PushL(self);
       
    60     self->ConstructL();
       
    61     return self;
       
    62 }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Cancel asynchronous request if it is still active
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CS60BTDialog::~CS60BTDialog()
       
    70 {
       
    71     JELOG2(EJavaBluetooth);
       
    72     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::~CS60BTDialog()");
       
    73     DoCancel();
       
    74     mNotifier.Close();
       
    75     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::~CS60BTDialog()");
       
    76 }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Displays BT query dialog.
       
    80 // Returns boolean telling user response to query.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 TBool CS60BTDialog::ShowBTQueryDialog(
       
    84     const TDesC& aAppName, const TBool /*aInstalling*/,
       
    85     TBTGenericQueryNoteType aQueryType)
       
    86 {
       
    87     JELOG2(EJavaBluetooth);
       
    88     LOG1(EJavaBluetooth, EInfo,"+ CS60BTDialog::ShowBTQueryDialog(): aQueryType = %d", aQueryType);
       
    89 
       
    90     mQueryParamsPckg().iMessageType = aQueryType;
       
    91     mQueryParamsPckg().iNameExists = ETrue;
       
    92     mQueryParamsPckg().iName.Copy(aAppName);
       
    93     mNotifier.StartNotifierAndGetResponse(mStatus, KBTGenericQueryNotifierUid,
       
    94                                           mQueryParamsPckg, mQueryResult);
       
    95 
       
    96     User::WaitForRequest(mStatus);
       
    97 
       
    98     LOG1(EJavaBluetooth, EInfo,"- CS60BTDialog::ShowBTQueryDialog(): mQueryResult = %d", mQueryResult());
       
    99     return mQueryResult();
       
   100 }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // Store information about cancel to member variable.
       
   105 // Cancel asynchronous request.
       
   106 // Stop the inner active scheduler loop.
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CS60BTDialog::DoCancel()
       
   110 {
       
   111     LOG(EJavaBluetooth, EInfo, "+ CS60BTDialog::DoCancel()");
       
   112     mNotifier.CancelNotifier(KBTGenericQueryNotifierUid);
       
   113     LOG(EJavaBluetooth, EInfo, "- CS60BTDialog::DoCancel()");
       
   114 }