|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef _BTUTILS_H |
|
17 #define _BTUTILS_H |
|
18 |
|
19 #include <es_sock.h> |
|
20 #include <e32test.h> |
|
21 #include <es_prot.h> |
|
22 #include <e32cons.h> |
|
23 #include <obex.h> |
|
24 #include <btmanclient.h> |
|
25 #include <obex/internal/obexinternalheader.h> |
|
26 #include <obex/internal/obexinternalconstants.h> |
|
27 #include <btsdp.h> |
|
28 #include <obexfinalpacketobserver.h> |
|
29 |
|
30 |
|
31 |
|
32 class CRFCOMMServiceFinder; |
|
33 |
|
34 class MRFCOMMServiceSeeker |
|
35 { |
|
36 public: |
|
37 virtual void SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion)=0; // user implemented |
|
38 }; |
|
39 |
|
40 |
|
41 class CRFCOMMServiceFinder : public CBase, |
|
42 public MSdpElementBuilder, public MSdpAgentNotifier |
|
43 { |
|
44 public: |
|
45 static CRFCOMMServiceFinder* NewL( const TUUID& aServiceClass, |
|
46 const TBTDevAddr& aDevAddr, |
|
47 MRFCOMMServiceSeeker& aSeeker); |
|
48 |
|
49 ~CRFCOMMServiceFinder(); |
|
50 |
|
51 void FindPortL(); //Starts the search |
|
52 //Inherits MSdpElementBuilder and MSdpAgentNotifier interfaces, |
|
53 //most importantly... |
|
54 MSdpElementBuilder* BuildUintL(const TDesC8& aUint); |
|
55 MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID); |
|
56 MSdpElementBuilder* BuildDESL() {return this;} |
|
57 MSdpElementBuilder* BuildDEAL() {return this;} |
|
58 MSdpElementBuilder* StartListL() {return this;} |
|
59 MSdpElementBuilder* EndListL() {return this;} |
|
60 // All others are errors, so don’t override the default (leaves) |
|
61 void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount); |
|
62 |
|
63 void AttributeRequestResult(TSdpServRecordHandle,TSdpAttributeID,CSdpAttrValue*) {User::Panic(_L("RFCOMMSEEK"), 0);} // Not using this API form |
|
64 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); |
|
65 private: |
|
66 CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker); |
|
67 void ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass); |
|
68 void AttributeRequestL(TSdpServRecordHandle aHandle); |
|
69 |
|
70 private: |
|
71 enum TSdpSearchState { ENoUuidFound, EFoundRfcommUuid, EFoundProfileUuid }; |
|
72 CSdpAgent* iAgent; |
|
73 CSdpSearchPattern* iPattern; |
|
74 TSdpSearchState iSearchState; |
|
75 TUint8 iPort; |
|
76 TInt iProfileVersion; |
|
77 MRFCOMMServiceSeeker& iSeeker;//initialised from aSeeker in the constructor |
|
78 }; |
|
79 |
|
80 |
|
81 |
|
82 #endif // _BTUTILS_H |