javaextensions/bluetooth/omjbluetooth/src.s60/bluetoothservicesearcher.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BLUETOOTHSERVICESEARCHER_H
       
    20 #define BLUETOOTHSERVICESEARCHER_H
       
    21 
       
    22 #include <string>
       
    23 #include <btsdp.h>
       
    24 #include <bt_sock.h>
       
    25 #include <bttypes.h>
       
    26 #include <e32base.h>
       
    27 
       
    28 #include "logger.h"
       
    29 #include "bluetoothfunctionserver.h"
       
    30 #include "btservicerecordpopulator.h"
       
    31 //#include "discoveryagent.h"
       
    32 
       
    33 namespace java
       
    34 {
       
    35 namespace bluetooth
       
    36 {
       
    37 
       
    38 class DiscoveryAgent;
       
    39 
       
    40 class BluetoothServiceSearcher: public MSdpAgentNotifier
       
    41 {
       
    42 public:
       
    43     static BluetoothServiceSearcher* New(DiscoveryAgent *aDiscoveryAgent,
       
    44                                          BluetoothFunctionServer* aServer);
       
    45 
       
    46     ~BluetoothServiceSearcher();
       
    47 
       
    48     void SearchServicesL(TInt64 aRemoteAddress, TPtrC8 aUuidsDes,
       
    49                          TPtrC16 aAttrIdsDes);
       
    50 
       
    51     void cancelServiceSearch();
       
    52 
       
    53     // From MSdpAgentNotifier
       
    54     void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle,
       
    55                                    TInt aTotalRecordsCount);
       
    56 
       
    57     void AttributeRequestResult(TSdpServRecordHandle aHandle,
       
    58                                 TSdpAttributeID aAttrID, CSdpAttrValue *aAttrValue);
       
    59 
       
    60     void AttributeRequestComplete(TSdpServRecordHandle, TInt aError);
       
    61 
       
    62     void PopulateServiceRecordsL(TInt64 aRemoteAddress, long aHandle,
       
    63                                  TPtrC16 aAttrIdsDes, jobject aServiceRecordImpl);
       
    64 private:
       
    65     BluetoothServiceSearcher();
       
    66 
       
    67     void Construct(DiscoveryAgent *aDiscoveryAgent,
       
    68                    BluetoothFunctionServer* aServer);
       
    69 
       
    70     void FillSearchPatternL(TDesC8& uuidsBytes);
       
    71 
       
    72     void FillAttributeListL(TDesC16& attrIds);
       
    73 
       
    74     void Cleanup();
       
    75 
       
    76 private:
       
    77     CSdpAgent* mSDPAgent;
       
    78     CSdpSearchPattern* mSpat;
       
    79     CSdpAttrIdMatchList* mAttributeList;
       
    80     DiscoveryAgent* mDiscoveryAgent;
       
    81     BluetoothFunctionServer* mServer;
       
    82     BTServiceRecordPopulator* mSrPopulator;
       
    83 
       
    84     TUUID mUUID;
       
    85     TInt64 mRemoteDeviceAddress;
       
    86     bool mFoundServiceRecord;
       
    87     bool mIsPopulateRecordMode;
       
    88 
       
    89     JNIEnv* mJni;
       
    90     jobject mPeer;
       
    91     jclass mServiceRecordImplClass;
       
    92     jmethodID mCreateServiceRecordMethod;
       
    93     jobject mServiceRecordImpl;
       
    94 };
       
    95 
       
    96 } //end namespace bluetooth
       
    97 } //end namespace java
       
    98 
       
    99 #endif // BLUETOOTHSERVICESEARCHER_H