|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SIMPLEOBEXCLIENT_H |
|
20 #define SIMPLEOBEXCLIENT_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32cons.h> |
|
25 #include <obex.h> |
|
26 #include <btsdp.h> |
|
27 #include "simpleObexApp.h" |
|
28 |
|
29 |
|
30 |
|
31 class CRFCOMMServiceFinder; |
|
32 |
|
33 |
|
34 /** |
|
35 * MRFCOMMServiceSeeker is a mixin class that contains a virtual function, |
|
36 * SearchResult, that is overridden by the SearchResult funtion in the |
|
37 * CObexClientHandler class. |
|
38 * |
|
39 */ |
|
40 class MRFCOMMServiceSeeker |
|
41 { |
|
42 public: |
|
43 virtual void SearchResult(TInt aError, TUint8 aPort)=0; // user implemented |
|
44 }; |
|
45 |
|
46 |
|
47 |
|
48 /** |
|
49 * CObexClientHandler is a wrapper class that is responsible for dealing |
|
50 * with an OBEX client. It implements MRFCOMMServiceSeeker to deal with |
|
51 * Bluetooth searches on other OBEX devices. |
|
52 * |
|
53 */ |
|
54 class CObexClientHandler : public CActive, public MRFCOMMServiceSeeker |
|
55 { |
|
56 public: |
|
57 static CObexClientHandler* NewL(CActiveConsole* aParent, TTransport aTransport); |
|
58 ~CObexClientHandler(); |
|
59 |
|
60 void SetMode(TUint mode); |
|
61 void Connect(); |
|
62 void Disconnect(); |
|
63 void GetByNameL(); |
|
64 void Put(TDes& filename); |
|
65 void SetName(TDes& aName); |
|
66 void SearchResult(TInt aError, TUint8 aPort); |
|
67 |
|
68 void ConnectWithAuthenticationL(); |
|
69 |
|
70 private: |
|
71 void ConstructL(TTransport aTransport); |
|
72 CObexClientHandler(CActiveConsole* aParent); |
|
73 void RunL (); |
|
74 void DoCancel (); |
|
75 TInt SetUpObjectFromFile (TDes& filename); |
|
76 void DisplayObjectInformation(); |
|
77 |
|
78 public: |
|
79 TBuf<64> iObexName; |
|
80 TBuf<64> iFilename1; |
|
81 TBuf<64> iFilename2; |
|
82 TBuf<64> iFilename3; |
|
83 TBuf<32> iSessionPath; |
|
84 TBuf<16> iChallengePassword; |
|
85 TBuf<16> iResponsePassword; |
|
86 TBuf<32> iGetType; |
|
87 private: |
|
88 enum TSendState |
|
89 { |
|
90 EIdle, |
|
91 EConnecting, |
|
92 EConnected, |
|
93 EPutting, |
|
94 EGetting, |
|
95 EDisconnecting |
|
96 }; |
|
97 |
|
98 CActiveConsole* iParent; |
|
99 CObexClient* iClient; |
|
100 CObexFileObject* iFileObject; |
|
101 CObexBufObject* iObject; |
|
102 CBufFlat* iObjectBuffer; |
|
103 TSendState iState; |
|
104 CObexNullObject* iTargetHeaderObject; |
|
105 CRFCOMMServiceFinder* iSdpServiceFinder; |
|
106 TBTDevAddr iDevAddr; |
|
107 |
|
108 }; |
|
109 |
|
110 |
|
111 /** |
|
112 * CRFCOMMServiceFinder is the clas that is responsible for searching the SDP |
|
113 * records of a specified device (by address) to see if OBEX FTP is supported |
|
114 * |
|
115 */ |
|
116 class CRFCOMMServiceFinder : public CBase, public MSdpAgentNotifier |
|
117 { |
|
118 public: |
|
119 static CRFCOMMServiceFinder* NewL( const TUUID& aServiceClass,const TBTDevAddr& aDevAddr,MRFCOMMServiceSeeker& aSeeker); |
|
120 ~CRFCOMMServiceFinder(); |
|
121 |
|
122 void FindPortL(); //Starts the search |
|
123 |
|
124 |
|
125 // MSdpAgentNotifier functions |
|
126 void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount); |
|
127 void AttributeRequestResult(TSdpServRecordHandle,TSdpAttributeID,CSdpAttrValue*) {User::Panic(_L("RFCOMMSEEK"), 0);} // Not using this API form |
|
128 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); |
|
129 |
|
130 private: |
|
131 CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker); |
|
132 void ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass); |
|
133 |
|
134 private: |
|
135 CSdpAgent* iAgent; |
|
136 CSdpSearchPattern* iPattern; |
|
137 TBool iFoundRFCOMMUUID; |
|
138 TUint8 iPort; |
|
139 MRFCOMMServiceSeeker& iSeeker;//initialised from aSeeker in the constructor |
|
140 CActiveConsole* iParent; |
|
141 }; |
|
142 |
|
143 #endif // SIMPLEOBEXCLIENT_H |