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