equal
deleted
inserted
replaced
20 #include <usb_std.h> |
20 #include <usb_std.h> |
21 #include <obex.h> |
21 #include <obex.h> |
22 #include <SrcsInterface.h> |
22 #include <SrcsInterface.h> |
23 #include <mmf/common/mmfcontrollerpluginresolver.h> //for CleanupResetAndDestroyPushL |
23 #include <mmf/common/mmfcontrollerpluginresolver.h> //for CleanupResetAndDestroyPushL |
24 #include <musbclasscontrollernotify.h> |
24 #include <musbclasscontrollernotify.h> |
25 #include "debug.h" |
25 |
26 |
26 // Panic category only used in debug builds |
|
27 #ifdef _DEBUG |
|
28 _LIT( KObexCcPanicCategory, "OBEXCC" ); |
|
29 #endif |
|
30 |
|
31 #ifdef __FLOG_ACTIVE |
|
32 _LIT8(KLogComponent, "UsbObexCc"); |
|
33 #endif |
27 |
34 |
28 /** |
35 /** |
29 * Panic codes for the USB OBEX Class Controller. |
36 * Panic codes for the USB OBEX Class Controller. |
30 */ |
37 */ |
31 enum TObexCCPanic |
38 enum TObexCCPanic |
34 EBadAsynchronousCall = 0, |
41 EBadAsynchronousCall = 0, |
35 /** Start() called while in an illegal state */ |
42 /** Start() called while in an illegal state */ |
36 EBadApiCallStart = 1, |
43 EBadApiCallStart = 1, |
37 /** Stop() called while in an illegal state */ |
44 /** Stop() called while in an illegal state */ |
38 EBadApiCallStop = 2, |
45 EBadApiCallStop = 2, |
39 /** Request completes in uknown state */ |
|
40 EUnkownState = 3 |
|
41 }; |
46 }; |
42 |
47 |
43 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
44 // Constructs a CUsbObexClassController object. |
49 // Constructs a CUsbObexClassController object. |
45 // --------------------------------------------------------------------------- |
50 // --------------------------------------------------------------------------- |
46 // |
51 // |
47 CUsbObexClassController* CUsbObexClassController::NewL( |
52 CUsbObexClassController* CUsbObexClassController::NewL( |
48 MUsbClassControllerNotify& aOwner) |
53 MUsbClassControllerNotify& aOwner) |
49 { |
54 { |
50 LOG_FUNC |
55 LOG_STATIC_FUNC_ENTRY |
51 |
56 |
52 CUsbObexClassController* self = new (ELeave) CUsbObexClassController(aOwner); |
57 CUsbObexClassController* self = new (ELeave) CUsbObexClassController(aOwner); |
53 CleanupStack::PushL(self); |
58 CleanupStack::PushL(self); |
54 self->ConstructL(); |
59 self->ConstructL(); |
55 CleanupStack::Pop(self); |
60 CleanupStack::Pop(self); |
100 void CUsbObexClassController::Start(TRequestStatus& aStatus) |
105 void CUsbObexClassController::Start(TRequestStatus& aStatus) |
101 { |
106 { |
102 |
107 |
103 LOG_FUNC |
108 LOG_FUNC |
104 //Start() should never be called if started, starting or stopping (or in state EUsbServiceFatalError) |
109 //Start() should never be called if started, starting or stopping (or in state EUsbServiceFatalError) |
105 ASSERT_DEBUG(iState == EUsbServiceIdle, EBadApiCallStart ); |
110 __ASSERT_DEBUG(iState == EUsbServiceIdle, _USB_PANIC(KObexCcPanicCategory, EBadApiCallStart)); |
106 |
111 |
107 // Start OBEX SM |
112 // Start OBEX SM |
108 iRequestStatus = &aStatus; |
113 iRequestStatus = &aStatus; |
109 iState = EUsbServiceStarting; |
114 iState = EUsbServiceStarting; |
110 aStatus = KRequestPending; |
115 aStatus = KRequestPending; |
111 LOG("CUsbObexClassController::Start() calling ManageUSBService(ETrue)"); |
116 LOGTEXT(_L8("CUsbObexClassController::Start() calling ManageUSBService(ETrue)")); |
112 iObexSM->ManageUSBServices(ETrue, iStatus); |
117 iObexSM->ManageUSBServices(ETrue, iStatus); |
113 SetActive(); |
118 SetActive(); |
114 } |
119 } |
115 |
120 |
116 // --------------------------------------------------------------------------- |
121 // --------------------------------------------------------------------------- |
120 // |
125 // |
121 void CUsbObexClassController::Stop(TRequestStatus& aStatus) |
126 void CUsbObexClassController::Stop(TRequestStatus& aStatus) |
122 { |
127 { |
123 |
128 |
124 LOG_FUNC |
129 LOG_FUNC |
125 LOG1("CUsbObexClassController::Stop iState = %d", iState); |
130 LOGTEXT2(_L8("CUsbObexClassController::Stop iState = %d"), iState); |
126 |
131 |
127 //Stop() should never be called if stopping or starting (or in state EUsbServiceFatalError) |
132 //Stop() should never be called if stopping or starting (or in state EUsbServiceFatalError) |
128 ASSERT_DEBUG(iState == EUsbServiceStarted || iState == EUsbServiceIdle, EBadApiCallStop ); |
133 __ASSERT_DEBUG(iState == EUsbServiceStarted || iState == EUsbServiceIdle, _USB_PANIC(KObexCcPanicCategory, EBadApiCallStop)); |
129 |
134 |
130 //state may be idle after Cancel |
135 //state may be idle after Cancel |
131 if ( iState == EUsbServiceIdle ) |
136 if ( iState == EUsbServiceIdle ) |
132 { |
137 { |
133 TRequestStatus* status = &aStatus; |
138 TRequestStatus* status = &aStatus; |
137 { |
142 { |
138 // Stop OBEX SM |
143 // Stop OBEX SM |
139 iRequestStatus = &aStatus; |
144 iRequestStatus = &aStatus; |
140 iState = EUsbServiceStopping; |
145 iState = EUsbServiceStopping; |
141 aStatus = KRequestPending; |
146 aStatus = KRequestPending; |
142 LOG("CUsbObexClassController::Stop() calling ManageUSBService(EFalse)"); |
147 LOGTEXT(_L8("CUsbObexClassController::Stop() calling ManageUSBService(EFalse)")); |
143 iObexSM->ManageUSBServices(EFalse, iStatus); |
148 iObexSM->ManageUSBServices(EFalse, iStatus); |
144 SetActive(); |
149 SetActive(); |
145 } |
150 } |
146 } |
151 } |
147 |
152 |
153 { |
158 { |
154 |
159 |
155 LOG_FUNC |
160 LOG_FUNC |
156 if (iStatus != KErrNone) |
161 if (iStatus != KErrNone) |
157 { |
162 { |
158 LOG1("CUsbObexClassController::RunL() iStatus = %d", iStatus.Int()); |
163 LOGTEXT2(_L8("CUsbObexClassController::RunL() Error = %d"), iStatus.Int()); |
159 User::RequestComplete(iRequestStatus, iStatus.Int()); |
164 User::RequestComplete(iRequestStatus, iStatus.Int()); |
160 return; |
165 return; |
161 } |
166 } |
162 LOG1("CUsbObexClassController::RunL() State is %d", iState); |
167 LOGTEXT2(_L8("CUsbObexClassController::RunL() State is %d"), iState); |
163 |
168 |
164 switch (iState) |
169 switch (iState) |
165 { |
170 { |
166 case EUsbServiceStarting: |
171 case EUsbServiceStarting: |
167 iState = EUsbServiceStarted; |
172 iState = EUsbServiceStarted; |
175 |
180 |
176 case EUsbServiceStarted: |
181 case EUsbServiceStarted: |
177 case EUsbServiceIdle: |
182 case EUsbServiceIdle: |
178 |
183 |
179 default: |
184 default: |
180 LOG("CUsbObexClassController::RunL() Unknown State"); |
185 LOGTEXT(_L8("CUsbObexClassController::RunL() Error or Unknown State")); |
181 PANIC(EUnkownState); |
|
182 break; |
186 break; |
183 } |
187 } |
184 } |
188 } |
185 |
189 |
186 // --------------------------------------------------------------------------- |
190 // --------------------------------------------------------------------------- |
192 { |
196 { |
193 LOG_FUNC |
197 LOG_FUNC |
194 TRAPD(ret, DoGetDescriptorInfoL(aDescriptorInfo)); |
198 TRAPD(ret, DoGetDescriptorInfoL(aDescriptorInfo)); |
195 if(ret!=KErrNone) |
199 if(ret!=KErrNone) |
196 { |
200 { |
197 LOG1("CUsbObexClassController::GetDescriptorInfo leave with code: %d", ret); |
201 LOGTEXT2(_L8("CUsbObexClassController::GetDescriptorInfo leave with code: %d"), ret); |
198 } |
202 } |
199 } |
203 } |
200 |
204 |
201 // --------------------------------------------------------------------------- |
205 // --------------------------------------------------------------------------- |
202 // Leave version of GetDescriptor info function for fit in Class Controller framework. |
206 // Leave version of GetDescriptor info function for fit in Class Controller framework. |
211 TEComResolverParams resolverParams; |
215 TEComResolverParams resolverParams; |
212 resolverParams.SetDataType(KSrcsTransportUSB); |
216 resolverParams.SetDataType(KSrcsTransportUSB); |
213 resolverParams.SetWildcardMatch(EFalse); |
217 resolverParams.SetWildcardMatch(EFalse); |
214 REComSession::ListImplementationsL(KCSrcsInterfaceUid, resolverParams, implInfoArray); |
218 REComSession::ListImplementationsL(KCSrcsInterfaceUid, resolverParams, implInfoArray); |
215 |
219 |
216 LOG1("CUsbObexClassController::DoGetDescriptorInfoL Number of Interfaces is %d", |
220 LOGTEXT2(_L8("CUsbObexClassController::DoGetDescriptorInfoL Number of Interfaces is %d"), |
217 implInfoArray.Count()); |
221 implInfoArray.Count()); |
218 aDescriptorInfo.iNumInterfaces = (implInfoArray.Count())*KObexNumInterfaces; |
222 aDescriptorInfo.iNumInterfaces = (implInfoArray.Count())*KObexNumInterfaces; |
219 aDescriptorInfo.iLength = 0; |
223 aDescriptorInfo.iLength = 0; |
220 |
224 |
221 CleanupStack::PopAndDestroy(&implInfoArray); |
225 CleanupStack::PopAndDestroy(&implInfoArray); |
236 case EUsbServiceStopping: |
240 case EUsbServiceStopping: |
237 iObexSM->CancelManageUSBServices(); |
241 iObexSM->CancelManageUSBServices(); |
238 break; |
242 break; |
239 |
243 |
240 default: |
244 default: |
241 ASSERT_DEBUG( EFalse, EBadAsynchronousCall ); |
245 __ASSERT_DEBUG( EFalse, _USB_PANIC(KObexCcPanicCategory, EBadAsynchronousCall) ); |
242 break; |
246 break; |
243 } |
247 } |
244 |
248 |
245 iState = EUsbServiceIdle; |
249 iState = EUsbServiceIdle; |
246 User::RequestComplete(iRequestStatus, KErrCancel); |
250 User::RequestComplete(iRequestStatus, KErrCancel); |
253 // --------------------------------------------------------------------------- |
257 // --------------------------------------------------------------------------- |
254 // |
258 // |
255 TInt CUsbObexClassController::RunError(TInt aError) |
259 TInt CUsbObexClassController::RunError(TInt aError) |
256 { |
260 { |
257 LOG_FUNC |
261 LOG_FUNC |
258 LOG1("CUsbObexClassController::RunError aError=%d", aError); |
262 LOGTEXT2(_L8("CUsbObexClassController::RunError aError=%d"), aError); |
259 return KErrNone; |
263 return KErrNone; |
260 } |
264 } |
261 |
265 |
262 void CUsbObexClassController::MosmError(TInt aError) |
266 void CUsbObexClassController::MosmError(TInt aError) |
263 { |
267 { |
264 LOG_FUNC |
268 LOG_FUNC |
265 LOG1("CUsbObexClassController::MosmError aError=%d", aError); |
269 LOGTEXT2(_L8("CUsbObexClassController::MosmError aError=%d"), aError); |
266 Owner().UccnError(aError); |
270 Owner().UccnError(aError); |
267 } |
271 } |
268 |
272 |
269 // End of File |
273 // End of File |