bluetoothengine/btserviceutil/src/advancedevdiscovererimpl.cpp
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:  class for searching BT devices
       
    15 *
       
    16 */
       
    17 #include "advancedevdiscovererimpl.h"
       
    18 #include "basicdevdiscoverer.h"
       
    19 
       
    20 
       
    21 // ----------------------------------------------------------
       
    22 // CAdvanceDevDiscovererImpl::CAdvanceDevDiscovererImpl
       
    23 // ----------------------------------------------------------
       
    24 //
       
    25 CAdvanceDevDiscovererImpl::CAdvanceDevDiscovererImpl(
       
    26         CBtDevRepository& aDevRep,
       
    27         MDevDiscoveryObserver& aObserver )
       
    28     :iDevRep( aDevRep ), iObserver( aObserver )
       
    29     {
       
    30     }
       
    31 
       
    32 // ----------------------------------------------------------
       
    33 // CAdvanceDevDiscovererImpl::ConstructL
       
    34 // ----------------------------------------------------------
       
    35 //
       
    36 void CAdvanceDevDiscovererImpl::ConstructL()
       
    37     {
       
    38     iBasicDiscoverer = CBasicDevDiscoverer::NewL( *this );   
       
    39     }
       
    40 
       
    41 // ----------------------------------------------------------
       
    42 // CAdvanceDevDiscovererImpl::NewL
       
    43 // ----------------------------------------------------------
       
    44 //
       
    45 CAdvanceDevDiscovererImpl* CAdvanceDevDiscovererImpl::NewL(
       
    46         CBtDevRepository& aDevRep,
       
    47         MDevDiscoveryObserver& aObserver )
       
    48     {
       
    49     CAdvanceDevDiscovererImpl* self = 
       
    50             new (ELeave) CAdvanceDevDiscovererImpl( aDevRep, aObserver );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ----------------------------------------------------------
       
    58 // CAdvanceDevDiscovererImpl::
       
    59 // ----------------------------------------------------------
       
    60 //
       
    61 CAdvanceDevDiscovererImpl::~CAdvanceDevDiscovererImpl()
       
    62     {
       
    63     delete iBasicDiscoverer;
       
    64     }
       
    65 
       
    66 // ----------------------------------------------------------
       
    67 // CAdvanceDevDiscovererImpl::SetObserver
       
    68 // ----------------------------------------------------------
       
    69 //
       
    70 void CAdvanceDevDiscovererImpl::SetObserver( MDevDiscoveryObserver& aObserver )
       
    71     {
       
    72     iObserver = aObserver;
       
    73     }
       
    74 
       
    75 // ----------------------------------------------------------
       
    76 // CAdvanceDevDiscovererImpl::
       
    77 // ----------------------------------------------------------
       
    78 //
       
    79 void CAdvanceDevDiscovererImpl::Cancel()
       
    80     {
       
    81     iBasicDiscoverer->Cancel();
       
    82     }
       
    83 
       
    84 // ----------------------------------------------------------
       
    85 // CAdvanceDevDiscovererImpl::
       
    86 // ----------------------------------------------------------
       
    87 //
       
    88 void CAdvanceDevDiscovererImpl::DiscoverDeviceL(
       
    89         CAdvanceDevDiscoverer::TDevDiscoveryFilter aFilter, 
       
    90         TBTMajorDeviceClass aDeviceClass )
       
    91     {
       
    92     iBasicDiscoverer->DiscoverDeviceL( aDeviceClass );
       
    93     iFilter = aFilter;
       
    94     }
       
    95 
       
    96 // ----------------------------------------------------------
       
    97 // CAdvanceDevDiscovererImpl::DiscoverDeviceL
       
    98 // ----------------------------------------------------------
       
    99 //
       
   100 void CAdvanceDevDiscovererImpl::DiscoverDeviceL( 
       
   101     const RBTDevAddrArray& aPriorityList )
       
   102     {
       
   103     // to be implemented when BTUI requires this feature.
       
   104     ( void ) aPriorityList;
       
   105     }
       
   106 
       
   107 // ----------------------------------------------------------
       
   108 // CAdvanceDevDiscovererImpl::HandleNextDiscoveryResult
       
   109 // ----------------------------------------------------------
       
   110 //
       
   111 void CAdvanceDevDiscovererImpl::HandleNextDiscoveryResultL( 
       
   112         const TInquirySockAddr& aAddr, const TDesC& aName )
       
   113     {
       
   114     TBool filtered = EFalse;
       
   115     if ( iFilter )
       
   116         {
       
   117         // For filtering, we need to examine the properties of
       
   118         // this device from repository.        
       
   119         const CBtDevExtension* devExt = iDevRep.Device( aAddr.BTAddr() );
       
   120         // No filter is needed if this device is not in registry.
       
   121         if ( devExt )
       
   122             {
       
   123             if ( iFilter & CAdvanceDevDiscoverer::ExcludeUserAwareBonded)
       
   124                 {
       
   125                 // client does not want to discover devices that have been
       
   126                 // bonded already.
       
   127                 if ( devExt->IsUserAwareBonded() )
       
   128                     {
       
   129                     filtered = ETrue;
       
   130                     }
       
   131                 }
       
   132             }
       
   133         }
       
   134     if ( !filtered )
       
   135         {
       
   136         iObserver.HandleNextDiscoveryResultL( aAddr, aName );
       
   137         }
       
   138     }
       
   139 
       
   140 // ----------------------------------------------------------
       
   141 // CAdvanceDevDiscovererImpl::HandleDiscoveryCompleted
       
   142 // ----------------------------------------------------------
       
   143 //
       
   144 void CAdvanceDevDiscovererImpl::HandleDiscoveryCompleted( TInt aErr )
       
   145     {
       
   146     iObserver.HandleDiscoveryCompleted( aErr );
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------
       
   150 // CAdvanceDevDiscovererImpl::RequestCompletedL
       
   151 // Inform caller for received device and issue next EIR/Name request
       
   152 // if the request was successful.
       
   153 // ----------------------------------------------------------
       
   154 //
       
   155 void CAdvanceDevDiscovererImpl::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
       
   156     {
       
   157     (void) aActive;
       
   158     (void) aStatus;
       
   159     }
       
   160 
       
   161 // ----------------------------------------------------------
       
   162 // CAdvanceDevDiscovererImpl::CancelRequest
       
   163 // ----------------------------------------------------------
       
   164 //
       
   165 void CAdvanceDevDiscovererImpl::CancelRequest( TInt aId )
       
   166     {
       
   167     (void) aId;
       
   168     }
       
   169 
       
   170 // ----------------------------------------------------------
       
   171 // CAdvanceDevDiscovererImpl::HandleError
       
   172 // ----------------------------------------------------------
       
   173 //
       
   174 void CAdvanceDevDiscovererImpl::HandleError( CBtSimpleActive* aActive, TInt aError )
       
   175     {
       
   176     (void) aActive;
       
   177     (void) aError;
       
   178     }
       
   179 
       
   180 // End of File