|
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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <c32comm.h> |
|
22 #include <obexusbtransportinfo.h> |
|
23 #include "ObexUsbTransportController.h" |
|
24 #include "usbconn.h" |
|
25 #include "logger.h" |
|
26 |
|
27 #ifdef __FLOG_ACTIVE |
|
28 _LIT8(KLogComponent, "USB"); |
|
29 #endif |
|
30 |
|
31 #ifdef _DEBUG |
|
32 _LIT(KPanicCat, "ObexUsbTC"); |
|
33 enum |
|
34 { |
|
35 KUsbTCError = 0, |
|
36 }; |
|
37 #endif |
|
38 |
|
39 |
|
40 /** |
|
41 Constructs a CObexUsbTransportController object |
|
42 |
|
43 @param aTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo. |
|
44 |
|
45 @return A new CObexUsbTransportController object |
|
46 */ |
|
47 CObexUsbTransportController* CObexUsbTransportController::NewL(TObexTransportInfo& aTransportInfo) |
|
48 { |
|
49 CObexUsbTransportController* self = new(ELeave) CObexUsbTransportController; |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aTransportInfo); |
|
52 CleanupStack::Pop(self); |
|
53 return(self); |
|
54 } |
|
55 |
|
56 /** |
|
57 CObexUsbTransportController constructor. |
|
58 */ |
|
59 CObexUsbTransportController::CObexUsbTransportController() |
|
60 :CObexTransportControllerBase() |
|
61 { |
|
62 } |
|
63 |
|
64 |
|
65 /** |
|
66 2nd Phase Construction. |
|
67 |
|
68 @param aTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo. |
|
69 */ |
|
70 void CObexUsbTransportController::ConstructL(TObexTransportInfo& aTransportInfo) |
|
71 { |
|
72 //Note: The CObexUsbConnector will determine if UsbTransportInfo has type TObexUsbTransportInfo or TObexUsbV2TransportInfo. |
|
73 //CObexUsbTransportController does not need to know |
|
74 TObexUsbTransportInfo& usbTransportInfo = static_cast<TObexUsbTransportInfo&>(aTransportInfo); |
|
75 |
|
76 iConnector = CObexUsbConnector::NewL(*this, usbTransportInfo); |
|
77 iTransportInfo = new(ELeave) TObexUsbTransportInfo; |
|
78 Mem::Copy(iTransportInfo, &usbTransportInfo, sizeof(TObexUsbTransportInfo)); |
|
79 } |
|
80 |
|
81 /** |
|
82 CObexUsbTransportController destructor |
|
83 */ |
|
84 CObexUsbTransportController::~CObexUsbTransportController() |
|
85 { |
|
86 } |
|
87 |
|
88 |
|
89 /** |
|
90 Gets the socket associated with the connector and asks the socket for its remote name. |
|
91 |
|
92 @param aAddr Reference to a TSockAddr. Since this is the USB transport controller, there is no socket |
|
93 address to return, so the reference is zeroed. |
|
94 */ |
|
95 void CObexUsbTransportController::DoRemoteAddr(TSockAddr& aAddr) |
|
96 { |
|
97 Mem::FillZ(&aAddr, sizeof(TSockAddr)); |
|
98 } |
|
99 |
|
100 |
|
101 /** |
|
102 Used indirectly by CObex::ControlledTransportDown() to determine whether the transport |
|
103 can be forced down, or if the connection should just be cancelled and cleaned up. |
|
104 |
|
105 @return The USB transport cannot be restarted, so should not be forced down. Hence return EFalse |
|
106 */ |
|
107 TBool CObexUsbTransportController::DoIsTransportRestartable() const |
|
108 { |
|
109 return EFalse; |
|
110 } |
|
111 |
|
112 |
|
113 /** |
|
114 Returns the receive packet data limit |
|
115 |
|
116 @return The receive packet data limit |
|
117 */ |
|
118 TUint16 CObexUsbTransportController::GetReceivePacketDataLimit() |
|
119 { |
|
120 LOG_FUNC |
|
121 |
|
122 // Set initial "software throttle" for packets (how big OBEX says they are) |
|
123 __ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, KUsbTCError)); |
|
124 TUint16 receivePacketDataLimit = iTransportInfo->iReceiveMtu; |
|
125 return receivePacketDataLimit; |
|
126 } |
|
127 |
|
128 |
|
129 /* |
|
130 Creates the reader and writer and constructs the packets |
|
131 Called via CObexTransportControllerBase::DoTransportUp |
|
132 |
|
133 @param aInfo Connection info to pass to active reader/writer classes |
|
134 */ |
|
135 void CObexUsbTransportController::NewTransportL(TObexConnectionInfo& aInfo) |
|
136 { |
|
137 __ASSERT_DEBUG((aInfo.iSocketType == TObexConnectionInfo::EUsbStream), PANIC(KPanicCat, KUsbTCError)); |
|
138 |
|
139 //Get the RDevUsbcClient to pass to the active reader/writer |
|
140 RDevUsbcClient* usbc = reinterpret_cast<CObexUsbConnector*>(iConnector)->TransportObject(); |
|
141 |
|
142 // Get the packet size of the link |
|
143 TInt pktSize = reinterpret_cast<CObexUsbConnector*>(iConnector)->GetTransportPacketSize(); |
|
144 |
|
145 //CObexUsbActiveReader(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo); |
|
146 iActiveReader = CObexUsbActiveReader::NewL(*this, *usbc, aInfo); |
|
147 //CObexUsbActiveWriter(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo); |
|
148 iActiveWriter = CObexUsbActiveWriter::NewL(*this, *usbc, aInfo, pktSize); |
|
149 |
|
150 iConnectionInfo = aInfo; |
|
151 } |
|
152 |
|
153 |
|
154 /** |
|
155 Implements MObexTransportNotify |
|
156 Process the received packet. |
|
157 |
|
158 @param aPacket A reference to a CObexPacket |
|
159 */ |
|
160 void CObexUsbTransportController::DoProcess(CObexPacket &aPacket) |
|
161 { |
|
162 CObexTransportControllerBase::DoProcess(aPacket); |
|
163 } |
|
164 |
|
165 |
|
166 /* |
|
167 Implements MObexTransportNotify |
|
168 Calls base implementation |
|
169 Future proofing against BC breaks |
|
170 |
|
171 @param aError The error value |
|
172 */ |
|
173 void CObexUsbTransportController::DoError(TInt aError) |
|
174 { |
|
175 CObexTransportControllerBase::DoError(aError); |
|
176 } |
|
177 |
|
178 |
|
179 /* |
|
180 Implements MObexTransportNotify |
|
181 Calls base implementation |
|
182 Future proofing against BC breaks |
|
183 |
|
184 @param aInfo Connection info to pass to active reader/writer classes |
|
185 */ |
|
186 void CObexUsbTransportController::DoTransportUp(TObexConnectionInfo& aInfo) |
|
187 { |
|
188 CObexTransportControllerBase::DoTransportUp(aInfo); |
|
189 } |
|
190 |