bluetoothengine/btnotif/btnotifsrv/inc/btnotifbasepairinghandler.h
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56: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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTNOTIFBASEPAIRINGHANDLER_H
       
    19 #define BTNOTIFBASEPAIRINGHANDLER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <bttypes.h>
       
    23 #include <btnotif.h>
       
    24 #include <btengconstants.h>
       
    25 #include <btservices/btsimpleactive.h>
       
    26 
       
    27 class CBTNotifSecurityManager;
       
    28 
       
    29 /**
       
    30  *  Class CBTNotifBasePairingHandler
       
    31  *
       
    32  *  The base class for pairing handling. 
       
    33  *  When the pairing has completed (successfully or unsuccessfully), the user
       
    34  *  is informed of the result
       
    35  *
       
    36  *  @since Symbian^4
       
    37  */
       
    38 NONSHARABLE_CLASS( CBTNotifBasePairingHandler ) : 
       
    39     public CBase, public MBtSimpleActiveObserver
       
    40     {
       
    41 public:
       
    42     
       
    43     /**
       
    44      * Destructor
       
    45      */
       
    46     virtual ~CBTNotifBasePairingHandler();
       
    47     
       
    48     /**
       
    49      * Handle a pairing result from the pairing server.
       
    50      *
       
    51      * @param aAddr the address of the remote device which the result is for.
       
    52      * @param aResult The status code of the pairing or authentication result.
       
    53      */
       
    54     void HandlePairServerResult( const TBTDevAddr& aAddr, TInt aResult );
       
    55     
       
    56     /**
       
    57      * Handles event of new paired device event in registry.
       
    58      * @param aDev the remote device which the pair is with.
       
    59      */
       
    60     void HandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev );
       
    61     
       
    62     /**
       
    63      * Start observing the result of the pairing originated by
       
    64      * the remote device.
       
    65      * Must be specialized by subclass.
       
    66      * @param the address of the remote device to be paired
       
    67      * @return KErrNone if this request is accepted; otherwise an error code
       
    68      */
       
    69     virtual TInt ObserveIncomingPair( const TBTDevAddr& aAddr ) = 0;
       
    70 
       
    71     /**
       
    72      * Start an outgoing pairing with the remote device.
       
    73      * Must be specialized by subclass.
       
    74      * @param the address of the remote device to be paired
       
    75      * @return KErrNone if this request is accepted; otherwise an error code
       
    76      */
       
    77     virtual void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) = 0;
       
    78     
       
    79     /**
       
    80      * Cancel the outstanding pairing operation.
       
    81      */
       
    82     virtual void CancelOutgoingPair();
       
    83 
       
    84     /**
       
    85      * Cancels pairing handling with the specified device
       
    86      * @param aAddr the address of the device the pairing is with
       
    87      */
       
    88     virtual void StopPairHandling( const TBTDevAddr& aAddr ) = 0;
       
    89     
       
    90     /**
       
    91      * Gets the pin code to be used for pairing a device.
       
    92      * @param aPin contains the pin code if it is not empty
       
    93      * @param aAddr the device to which pairing is performed.
       
    94      * @param the required minimum length of a pin code.
       
    95      */
       
    96     virtual void GetPinCode( TBTPinCode& aPin, const TBTDevAddr& aAddr, TInt aMinPinLength );
       
    97  
       
    98     /**
       
    99      * Show a dialog for pairing success or failure
       
   100      * @param aResult The result of the pairing
       
   101      */
       
   102     void ShowPairingResultNoteL(TInt aResult);
       
   103     
       
   104 protected:
       
   105     
       
   106     /**
       
   107      * Handle a pairing result with the remote device which this is for.
       
   108      * Must be specialized by subclass.
       
   109      *
       
   110      * @param aResult The status code of the pairing or authentication result.
       
   111      */
       
   112     virtual void DoHandlePairServerResult( TInt aResult ) = 0;
       
   113     
       
   114     /**
       
   115      * Handles a registry new paired event with the remote 
       
   116      * device with which this handler is dealing.
       
   117      * Must be specialized by subclass.
       
   118      * @aType the type of authentication with the device.
       
   119      */
       
   120     virtual void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) = 0;
       
   121     
       
   122 protected:
       
   123     
       
   124     /**
       
   125      * C++ default constructor
       
   126      */
       
   127     CBTNotifBasePairingHandler(CBTNotifSecurityManager& aParent, const TBTDevAddr& aAddr);
       
   128     
       
   129     /**
       
   130      * Symbian 2nd-phase constructor
       
   131      */
       
   132     void BaseConstructL();
       
   133     
       
   134     /**
       
   135      * Invalidate the pair result flag of this 
       
   136      */
       
   137     void UnSetPairResult();
       
   138     
       
   139     /**
       
   140      * Sets the pair result and validate pair result flag
       
   141      */
       
   142     void SetPairResult( TInt aResult );
       
   143     
       
   144     /**
       
   145      * Tells if the pair result has been set.
       
   146      * @ETrue if the result has been set.
       
   147      */
       
   148     TBool IsPairResultSet();
       
   149     
       
   150 protected:
       
   151 
       
   152     /**
       
   153      * Address of the remote device we are trying to pair.
       
   154      */
       
   155     TBTDevAddr iAddr;
       
   156     
       
   157     /**
       
   158      * Contains the final result of pairing with the remote device
       
   159      */
       
   160     TInt iPairResult;
       
   161     
       
   162     /**
       
   163      * Pair result flag, ETrue if iPairResult is been set.
       
   164      */
       
   165     TBool iPairResultSet;
       
   166     
       
   167     /**
       
   168      * Reference to the owner of this object.
       
   169      */
       
   170     CBTNotifSecurityManager& iParent;
       
   171     
       
   172     /**
       
   173      * Active object helper for asynchronous operations.
       
   174      * Own.
       
   175      */
       
   176     CBtSimpleActive* iActive;
       
   177     };
       
   178 
       
   179 #endif /*BTNOTIFBASEPAIRINGHANDLER_H*/
       
   180 
       
   181 
       
   182