bluetoothengine/bteng/inc/btengpairbase.h
branchRCL_3
changeset 55 613943a21004
parent 54 0ba996a9b75d
child 56 9386f31cc85b
equal deleted inserted replaced
54:0ba996a9b75d 55:613943a21004
     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:  the base class of pairing handling
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BTENGPAIRBASE_H_
       
    20 #define BTENGPAIRBASE_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <bttypes.h>
       
    24 #include <btnotif.h>
       
    25 #include "btengactive.h"
       
    26 
       
    27 class CBTEngPairMan;
       
    28 
       
    29 /**  Identification for asynchronous operations */
       
    30 enum TPairBaseActiveRequestId
       
    31     {
       
    32     EDevicePairUserNotification = 1
       
    33     };
       
    34 
       
    35 /**
       
    36  *  Class CBTEngPairBase
       
    37  *
       
    38  *  The base class for pairing handling. 
       
    39  *  When the pairing has completed (successfully or unsuccessfully), the user
       
    40  *  is informed of the result
       
    41  *
       
    42  *  @since S60 S60 v5.1
       
    43  */
       
    44 NONSHARABLE_CLASS( CBTEngPairBase ) : public CBase, public MBTEngActiveObserver
       
    45     {
       
    46 public:
       
    47     
       
    48     /**
       
    49      * Destructor
       
    50      */
       
    51     virtual ~CBTEngPairBase();
       
    52     
       
    53     /**
       
    54      * Handle a pairing result from the pairing server.
       
    55      *
       
    56      * @param aAddr the address of the remote device which the result is for.
       
    57      * @param aResult The status code of the pairing or authentication result.
       
    58      */
       
    59     void HandlePairServerResult( const TBTDevAddr& aAddr, TInt aResult );
       
    60     
       
    61     /**
       
    62      * Handles event of new paired device event in registry.
       
    63      * @param aDev the remote device which the pair is with.
       
    64      */
       
    65     void HandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev );
       
    66     
       
    67     /**
       
    68      * Start observing the result of the pairing originated by
       
    69      * the remote device.
       
    70      * Must be specialized by subclass.
       
    71      * @param the address of the remote device to be paired
       
    72      * @return KErrNone if this request is accepted; otherwise an error code
       
    73      */
       
    74     virtual TInt ObserveIncomingPair( const TBTDevAddr& aAddr ) = 0;
       
    75 
       
    76     /**
       
    77      * Start an outgoing pairing with the remote device.
       
    78      * Must be specialized by subclass.
       
    79      * @param the address of the remote device to be paired
       
    80      * @return KErrNone if this request is accepted; otherwise an error code
       
    81      */
       
    82     virtual void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) = 0;
       
    83     
       
    84     /**
       
    85      * Cancel the outstanding pairing operation.
       
    86      */
       
    87     virtual void CancelOutgoingPair();
       
    88 
       
    89     /**
       
    90      * Cancels pairing handling with the specified device
       
    91      * @param aAddr the address of the device the pairing is with
       
    92      */
       
    93     virtual void StopPairHandling( const TBTDevAddr& aAddr ) = 0;
       
    94     
       
    95 protected:
       
    96     
       
    97     /**
       
    98      * Handle a pairing result with the remote device which this is for.
       
    99      * Must be specialized by subclass.
       
   100      *
       
   101      * @param aResult The status code of the pairing or authentication result.
       
   102      */
       
   103     virtual void DoHandlePairServerResult( TInt aResult ) = 0;
       
   104     
       
   105     /**
       
   106      * Handles event of registry new paired event with the remote 
       
   107      * device this is for.
       
   108      * Must be specialized by subclass.
       
   109      * @aType the type of authentication with the device.
       
   110      */
       
   111     virtual void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) = 0;
       
   112     
       
   113 protected:
       
   114     
       
   115     /**
       
   116      * C++ default constructor
       
   117      */
       
   118     CBTEngPairBase(CBTEngPairMan& aParent, const TBTDevAddr& aAddr);
       
   119     
       
   120     /**
       
   121      * Symbian 2nd-phase constructor
       
   122      */
       
   123     void BaseConstructL();
       
   124 
       
   125     /**
       
   126      * Cancels notifying user about the pairing result.
       
   127      */
       
   128     void CancelNotifier();
       
   129     
       
   130     /**
       
   131      * Show the pairing result and ask the user to authorize the device if
       
   132      * pair succeeded.
       
   133      *
       
   134      * @since S60 v5.1
       
   135      */
       
   136     void ShowPairingNoteAndAuthorizeQuery();    
       
   137     
       
   138     /**
       
   139      * Invalidate the pair result flag of this 
       
   140      */
       
   141     void UnSetPairResult();
       
   142     
       
   143     /**
       
   144      * Sets the pair result and validate pair result flag
       
   145      */
       
   146     void SetPairResult( TInt aResult );
       
   147     
       
   148     /**
       
   149      * Tells if the pair result has been set.
       
   150      * @ETrue if the result has been set.
       
   151      */
       
   152     TBool IsPairResultSet();
       
   153     
       
   154     /**
       
   155      * Tells if this is notifying user the pairing result.
       
   156      * @return ETrue if this is is notifying user the pairing result
       
   157      */
       
   158     TBool IsNotifyingPairResult();
       
   159     
       
   160 protected:
       
   161 
       
   162     /**
       
   163      * Address of the remote device we are trying to pair.
       
   164      */
       
   165     TBTDevAddr iAddr;
       
   166     
       
   167     /**
       
   168      * Contains the final result of pairing with the remote device
       
   169      */
       
   170     TInt iPairResult;
       
   171     
       
   172     /**
       
   173      * Pair result flag, ETrue if iPairResult is been set.
       
   174      */
       
   175     TBool iPairResultSet;
       
   176     
       
   177     /**
       
   178      * Reference to the owner of this object.
       
   179      */
       
   180     CBTEngPairMan& iParent;
       
   181 
       
   182     /**
       
   183      * Package buffer for passing parameters to authorization notifier.
       
   184      */
       
   185     TBTPairedDeviceSettingParamsPckg iAuthoPckg;
       
   186 
       
   187     /**
       
   188      * Session with the notifier server.
       
   189      * Own.
       
   190      */
       
   191     RNotifier iNotifier;
       
   192     
       
   193     /**
       
   194      * Active object helper for asynchronous operations.
       
   195      * Own.
       
   196      */
       
   197     CBTEngActive* iActive;
       
   198     };
       
   199 
       
   200 #endif /*BTENGPAIRBASE_H_*/