bluetoothengine/btnotif/src/btuserconfnotifier.cpp
branchRCL_3
changeset 23 9386f31cc85b
parent 9 a42ed326b458
child 11 f7fbeaeb166a
child 24 269724087bed
equal deleted inserted replaced
22:613943a21004 23:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Declares User confirmation notifier for Secure Simle Pairing 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <StringLoader.h>    // Localisation stringloader
       
    21 #include <utf.h>             // Unicode character conversion utilities
       
    22 #include <avkon.mbg>
       
    23 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 #include <btextnotifiers.h>
       
    25 #else
       
    26 #include <btextnotifiers.h>
       
    27 #include <btextnotifierspartner.h>
       
    28 #endif
       
    29 #include <BTNotif.rsg>       // Own resources
       
    30 #include "btnotif.hrh"       // Own resource header
       
    31 #include "btuserconfnotifier.h"  // Own class definition
       
    32 #include "btNotifDebug.h"    // Debugging macros
       
    33 #include <btotgpairpub.inl>
       
    34 #include <btengconnman.h>
       
    35 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
       
    36 #include <bluetoothuiutil.h>
       
    37 #include "btnotifnameutils.h"
       
    38 
       
    39 #ifdef __SERIES60_HELP
       
    40 #include <hlplch.h>
       
    41 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
       
    42 #endif
       
    43 
       
    44 // ================= MEMBER FUNCTIONS =======================
       
    45 
       
    46 // ----------------------------------------------------------
       
    47 // CBTUserConfNotifier::NewL
       
    48 // Two-phased constructor.
       
    49 // ----------------------------------------------------------
       
    50 //
       
    51 CBTUserConfNotifier* CBTUserConfNotifier::NewL()
       
    52     {
       
    53     CBTUserConfNotifier* self=new (ELeave) CBTUserConfNotifier();
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop(self);
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------------
       
    61 // CBTUserConfNotifier::CBTUserConfNotifier
       
    62 // C++ default constructor can NOT contain any code, that
       
    63 // might leave.
       
    64 // ----------------------------------------------------------
       
    65 //
       
    66 CBTUserConfNotifier::CBTUserConfNotifier()
       
    67     {
       
    68     
       
    69     }
       
    70 
       
    71 // ----------------------------------------------------------
       
    72 // Destructor
       
    73 // ----------------------------------------------------------
       
    74 //
       
    75 CBTUserConfNotifier::~CBTUserConfNotifier()
       
    76     {
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------
       
    80 // CBTUserConfNotifier::RegisterL
       
    81 // Register notifier.
       
    82 // ----------------------------------------------------------
       
    83 //
       
    84 CBTUserConfNotifier::TNotifierInfo CBTUserConfNotifier::RegisterL()
       
    85     {
       
    86     iInfo.iUid = KBTUserConfirmationNotifierUidCopy;
       
    87     iInfo.iChannel = KBTUserConfirmationNotifierUidCopy;
       
    88     iInfo.iPriority=ENotifierPriorityVHigh;
       
    89     return iInfo;
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------
       
    93 // CBTUserConfNotifier::GetParamsL
       
    94 // Initialize parameters and check if device is already
       
    95 // in registry. Jump to RunL as soon as possible.
       
    96 // ----------------------------------------------------------
       
    97 //
       
    98 void CBTUserConfNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
       
    99     {
       
   100     FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL()"));
       
   101 
       
   102     CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage );
       
   103     
       
   104     TBTUserConfirmationParamsPckgCopy pckg;
       
   105  	pckg.Copy(aBuffer);
       
   106  	iBTAddr = pckg().DeviceAddress();
       
   107     if ( OtherOutgoPairing( iBTAddr) )
       
   108         {
       
   109         // We won't allow incoming pairing during outgoing pairing:
       
   110         FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier: outgoing pair in progress, reject incoming pair"));
       
   111         CompleteMessage(KErrCancel);
       
   112         return;
       
   113         }
       
   114     
       
   115 	iLocallyInitiated = pckg().LocallyInitiated(); 
       
   116 
       
   117 	// base class
       
   118 	ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() );
       
   119 	
       
   120 	FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL() completed"));
       
   121     }
       
   122 
       
   123 // ----------------------------------------------------------
       
   124 // CBTUserConfNotifier::HandleGetDeviceCompletedL
       
   125 // Ask user response and return it to caller.
       
   126 // Store device into registry if user has accepted pairing.
       
   127 // ----------------------------------------------------------
       
   128 //
       
   129 void CBTUserConfNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/)
       
   130     {
       
   131     FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL()"));
       
   132     
       
   133     // Check if blocked device. 
       
   134     if( CheckBlockedDeviceL() )
       
   135         return;
       
   136     
       
   137     // Turn lights on and deactivate apps -key
       
   138     iNotifUiUtil->TurnLightsOn();
       
   139 
       
   140    	// For incoming pairing request
       
   141     TBool answer = AuthoriseIncomingPairingL();
       
   142     if( !answer ) 
       
   143         {
       
   144         //User rejects the incoming pairing, complete message in QueryBlockDevice.
       
   145         FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() <<"));
       
   146         return;
       
   147         }
       
   148     CompleteMessage(answer, KErrNone);
       
   149 
       
   150     FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() completed"));
       
   151     }
       
   152 
       
   153 // End of File