bluetoothengine/btnotif/btnotifsrv/inc/btnotifbasepairinghandler.h
changeset 33 837dcc42fd6a
child 40 997690c3397a
equal deleted inserted replaced
19:43824b19ee35 33:837dcc42fd6a
       
     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 CBTNotifPairingManager;
       
    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 protected:
       
    99     
       
   100     /**
       
   101      * Handle a pairing result with the remote device which this is for.
       
   102      * Must be specialized by subclass.
       
   103      *
       
   104      * @param aResult The status code of the pairing or authentication result.
       
   105      */
       
   106     virtual void DoHandlePairServerResult( TInt aResult ) = 0;
       
   107     
       
   108     /**
       
   109      * Handles a registry new paired event with the remote 
       
   110      * device with which this handler is dealing.
       
   111      * Must be specialized by subclass.
       
   112      * @aType the type of authentication with the device.
       
   113      */
       
   114     virtual void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) = 0;
       
   115     
       
   116 protected:
       
   117     
       
   118     /**
       
   119      * C++ default constructor
       
   120      */
       
   121     CBTNotifBasePairingHandler(CBTNotifPairingManager& aParent, const TBTDevAddr& aAddr);
       
   122     
       
   123     /**
       
   124      * Symbian 2nd-phase constructor
       
   125      */
       
   126     void BaseConstructL();
       
   127     
       
   128     /**
       
   129      * Invalidate the pair result flag of this 
       
   130      */
       
   131     void UnSetPairResult();
       
   132     
       
   133     /**
       
   134      * Sets the pair result and validate pair result flag
       
   135      */
       
   136     void SetPairResult( TInt aResult );
       
   137     
       
   138     /**
       
   139      * Tells if the pair result has been set.
       
   140      * @ETrue if the result has been set.
       
   141      */
       
   142     TBool IsPairResultSet();
       
   143     
       
   144 protected:
       
   145 
       
   146     /**
       
   147      * Address of the remote device we are trying to pair.
       
   148      */
       
   149     TBTDevAddr iAddr;
       
   150     
       
   151     /**
       
   152      * Contains the final result of pairing with the remote device
       
   153      */
       
   154     TInt iPairResult;
       
   155     
       
   156     /**
       
   157      * Pair result flag, ETrue if iPairResult is been set.
       
   158      */
       
   159     TBool iPairResultSet;
       
   160     
       
   161     /**
       
   162      * Reference to the owner of this object.
       
   163      */
       
   164     CBTNotifPairingManager& iParent;
       
   165     
       
   166     /**
       
   167      * Active object helper for asynchronous operations.
       
   168      * Own.
       
   169      */
       
   170     CBtSimpleActive* iActive;
       
   171     };
       
   172 
       
   173 #endif /*BTNOTIFBASEPAIRINGHANDLER_H*/
       
   174 
       
   175 
       
   176