hti/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/btservicesearcher.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Bluetooth service searcher.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __BTSERVICESEARCHER_H__
       
    20 #define __BTSERVICESEARCHER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <bttypes.h>
       
    25 #include <btextnotifiers.h>
       
    26 
       
    27 #include "sdpattributeparser.h"
       
    28 #include "sdpattributenotifier.h"
       
    29 
       
    30 // CONSTANTS
       
    31 #include "messageprotocolconstants.h"
       
    32 
       
    33 // CLASS DECLARATIONS
       
    34 /**
       
    35 * CBTServiceSearcher
       
    36 * Searches for a service on a remote machine
       
    37 */
       
    38 
       
    39 class CBTServiceSearcher : public CBase,
       
    40                            public MSdpAgentNotifier,
       
    41                            public MSdpAttributeNotifier
       
    42     {
       
    43     public: // Destructor
       
    44 
       
    45         /**
       
    46         * ~CBTServiceSearcher()
       
    47         * Destroy the object and release all memory objects
       
    48         */
       
    49         virtual ~CBTServiceSearcher();
       
    50 
       
    51     public: // New functions
       
    52 
       
    53         /**
       
    54         * SelectDeviceByDiscoveryL()
       
    55         * Select a device
       
    56         * @param aObserverRequestStatus the observer that is to
       
    57         * be notified when the device selection is complete.
       
    58         */
       
    59         void SelectDeviceByDiscoveryL( TRequestStatus&
       
    60                                        aObserverRequestStatus );
       
    61 
       
    62        /**
       
    63         * SelectDeviceByNameL()
       
    64         * Select a device by BT device name.
       
    65         * @param aDeviceName the name of the device to search and select.
       
    66         * @param aObserverRequestStatus the observer that is to
       
    67         * be notified when the device selection is complete.
       
    68         */
       
    69         void SelectDeviceByNameL( const TDesC& aDeviceName,
       
    70                                   TRequestStatus& aObserverRequestStatus );
       
    71 
       
    72         /**
       
    73         * FindServiceL()
       
    74         * Find a service on the specified device
       
    75         * @param aDeviceAddress the BT address of the device to search for
       
    76         * the service
       
    77         * @param aObserverRequestStatus the observer that is to be notified
       
    78         * when the service search is complete
       
    79         */
       
    80         void FindServiceL( const TBTDevAddr& aDeviceAddress,
       
    81             TRequestStatus& aObserverRequestStatus );
       
    82 
       
    83         /**
       
    84         * BTDevAddr()
       
    85         * @return the bluetooth device address
       
    86         */
       
    87         const TBTDevAddr& BTDevAddr();
       
    88 
       
    89         /**
       
    90         * ResponseParams()
       
    91         * @return Information about the device selected by the user
       
    92         */
       
    93         const TBTDeviceResponseParams& ResponseParams();
       
    94 
       
    95     protected:  // New functions
       
    96 
       
    97         /**
       
    98         * CBTServiceSearcher()
       
    99         * Constructs this object
       
   100         */
       
   101         CBTServiceSearcher();
       
   102 
       
   103         /**
       
   104         * Finished()
       
   105         * The search has finished. Notify the observer
       
   106         * that the process is complete.
       
   107         */
       
   108         virtual void Finished( TInt aError = KErrNone );
       
   109 
       
   110         /**
       
   111         * HasFinishedSearching()
       
   112         * Is the instance still wanting to search.
       
   113         * @return EFalse if the instance wants searching to continue.
       
   114         */
       
   115         virtual TBool HasFinishedSearching() const;
       
   116 
       
   117         /**
       
   118         * HasFoundService()
       
   119         * @return ETrue if a service has been found
       
   120         */
       
   121         TBool HasFoundService() const;
       
   122 
       
   123     protected: // abstract methods
       
   124 
       
   125         /**
       
   126         * ProtocolList()
       
   127         * The list of Protocols required by the service.
       
   128         */
       
   129         virtual const TSdpAttributeParser::TSdpAttributeList&
       
   130                                            ProtocolList() const = 0;
       
   131 
       
   132         /**
       
   133         * ServiceClass()
       
   134         * The service class to search for
       
   135         * @return the service class UUID
       
   136         */
       
   137         virtual const TUUID& ServiceClass() const = 0;
       
   138 
       
   139         /**
       
   140         * FoundElementL()
       
   141         * Read the data element
       
   142         * @param aKey a key that identifies the element
       
   143         * @param aValue the data element
       
   144         */
       
   145         virtual void FoundElementL( TInt aKey, CSdpAttrValue& aValue ) = 0;
       
   146 
       
   147     public: // from MSdpAgentNotifier
       
   148 
       
   149         /**
       
   150         * NextRecordRequestComplete()
       
   151         * Process the result of the next record request
       
   152         * @param aError the error code
       
   153         * @param aHandle the handle of the service record
       
   154         * @param aTotalRecordsCount the total number of matching
       
   155         * service records
       
   156         */
       
   157         void NextRecordRequestComplete( TInt aError,
       
   158                                         TSdpServRecordHandle aHandle,
       
   159                                         TInt aTotalRecordsCount );
       
   160 
       
   161         /**
       
   162         * AttributeRequestResult()
       
   163         * Process the next attribute requested
       
   164         * @param aHandle the handle of the service record
       
   165         * @param aAttrID the id of the attribute
       
   166         * @param aAttrValue the value of the attribute
       
   167         */
       
   168         void AttributeRequestResult( TSdpServRecordHandle aHandle,
       
   169                                      TSdpAttributeID aAttrID,
       
   170                                      CSdpAttrValue* aAttrValue );
       
   171 
       
   172         /**
       
   173         * AttributeRequestComplete()
       
   174         * Process the arrtibute request completion
       
   175         * @param aHandle the handle of the service record
       
   176         * @param aError the error code
       
   177         */
       
   178         void AttributeRequestComplete( TSdpServRecordHandle aHandle,
       
   179                                        TInt aError );
       
   180 
       
   181     private:    // Functions from base classes
       
   182 
       
   183         /**
       
   184         * NextRecordRequestCompleteL()
       
   185         * Process the result of the next record request
       
   186         * @param aError the error code
       
   187         * @param aHandle the handle of the service record
       
   188         * @param aTotalRecordsCount the total number of
       
   189         * matching service records
       
   190         */
       
   191         void NextRecordRequestCompleteL( TInt aError,
       
   192                                          TSdpServRecordHandle aHandle,
       
   193                                          TInt aTotalRecordsCount );
       
   194 
       
   195         /**
       
   196         * AttributeRequestResultL()
       
   197         * Process the next attribute requested
       
   198         * @param aHandle the handle of the service record
       
   199         * @param aAttrID the id of the attribute
       
   200         * @param aAttrValue the value of the attribute
       
   201         */
       
   202         void AttributeRequestResultL( TSdpServRecordHandle aHandle,
       
   203                                       TSdpAttributeID aAttrID,
       
   204                                       CSdpAttrValue* aAttrValue );
       
   205 
       
   206         /**
       
   207         * AttributeRequestCompleteL()
       
   208         * Process the arrtibute request completion
       
   209         * @param aHandle the handle of the service record
       
   210         * @param aError the error code
       
   211         */
       
   212         void AttributeRequestCompleteL( TSdpServRecordHandle,
       
   213                                         TInt aError );
       
   214 
       
   215     private:    // data
       
   216 
       
   217         /**
       
   218         * iStatusObserver pointer to the request status observer
       
   219         * Not owned by CBTServiceSearcher
       
   220         */
       
   221         TRequestStatus* iStatusObserver;
       
   222 
       
   223         /**
       
   224         * iIsDeviceSelectorConnected is the device
       
   225         * selector connected?
       
   226         */
       
   227         TBool iIsDeviceSelectorConnected;
       
   228 
       
   229         /**
       
   230         * iDeviceSelector
       
   231         * a handle to the bluetooth device selector notifier
       
   232         */
       
   233         RNotifier iDeviceSelector;
       
   234 
       
   235         /**
       
   236         * iResponse
       
   237         * the response of the device selection.
       
   238         */
       
   239         TBTDeviceResponseParamsPckg iResponse;
       
   240 
       
   241         /**
       
   242         * iSelectionFilter
       
   243         * Request a device selection
       
   244         */
       
   245         TBTDeviceSelectionParamsPckg iSelectionFilter;
       
   246         /**
       
   247         * iAgent a connetction to the SDP client
       
   248         * Owned by CBTServiceSearcher
       
   249         */
       
   250         CSdpAgent* iAgent;
       
   251 
       
   252         /**
       
   253         * iSdpSearchPattern a search pattern
       
   254         * Owned by CBTServiceSearcher
       
   255         */
       
   256         CSdpSearchPattern* iSdpSearchPattern;
       
   257 
       
   258         /** iHasFoundService has the service been found ? */
       
   259         TBool iHasFoundService;
       
   260     };
       
   261 
       
   262 #endif // __BTSERVICESEARCHER_H__
       
   263 
       
   264 // End of File