18 /** |
18 /** |
19 @file |
19 @file |
20 @internalComponent |
20 @internalComponent |
21 */ |
21 */ |
22 |
22 |
23 #include "deviceproxy.h" |
23 |
24 #include <usb/usblogger.h> |
24 #include <usb/usblogger.h> |
25 #include <usbhostdefs.h> |
25 #include <usbhostdefs.h> |
26 #include "utils.h" |
26 #include "utils.h" |
27 #include "event.h" |
27 #include "event.h" |
28 |
28 #include "deviceproxy.h" |
29 #ifdef __FLOG_ACTIVE |
29 #include "OstTraceDefinitions.h" |
30 _LIT8(KLogComponent, "fdf "); |
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "deviceproxyTraces.h" |
31 #endif |
32 #endif |
32 |
33 |
33 #ifdef _DEBUG |
34 #ifdef _DEBUG |
34 PANICCATEGORY("devproxy"); |
|
35 #endif |
|
36 |
|
37 #ifdef __FLOG_ACTIVE |
|
38 #define LOG Log() |
35 #define LOG Log() |
|
36 _LIT(KPanicCategory,"devproxy"); |
39 #else |
37 #else |
40 #define LOG |
38 #define LOG |
41 #endif |
39 #endif |
42 |
40 |
|
41 |
|
42 |
43 CDeviceProxy* CDeviceProxy::NewL(RUsbHubDriver& aHubDriver, TUint aDeviceId) |
43 CDeviceProxy* CDeviceProxy::NewL(RUsbHubDriver& aHubDriver, TUint aDeviceId) |
44 { |
44 { |
45 LOG_STATIC_FUNC_ENTRY |
45 OstTraceFunctionEntry0( CDEVICEPROXY_NEWL_ENTRY ); |
46 |
46 |
47 CDeviceProxy* self = new(ELeave) CDeviceProxy(aDeviceId); |
47 CDeviceProxy* self = new(ELeave) CDeviceProxy(aDeviceId); |
48 CleanupStack::PushL(self); |
48 CleanupStack::PushL(self); |
49 self->ConstructL(aHubDriver); |
49 self->ConstructL(aHubDriver); |
50 CLEANUPSTACK_POP1(self); |
50 CLEANUPSTACK_POP1(self); |
|
51 OstTraceFunctionExit0( CDEVICEPROXY_NEWL_EXIT ); |
51 return self; |
52 return self; |
52 } |
53 } |
53 |
54 |
54 CDeviceProxy::CDeviceProxy(TUint aDeviceId) |
55 CDeviceProxy::CDeviceProxy(TUint aDeviceId) |
55 : iId(aDeviceId) |
56 : iId(aDeviceId) |
56 { |
57 { |
57 LOG_FUNC |
58 OstTraceFunctionEntry0( CDEVICEPROXY_CDEVICEPROXY_CONS_ENTRY ); |
58 } |
59 } |
59 |
60 |
60 void CDeviceProxy::ConstructL(RUsbHubDriver& aHubDriver) |
61 void CDeviceProxy::ConstructL(RUsbHubDriver& aHubDriver) |
61 { |
62 { |
62 LOG_FUNC |
63 OstTraceFunctionEntry0( CDEVICEPROXY_CONSTRUCTL_ENTRY ); |
63 |
64 |
64 LEAVEIFERRORL(iHandle.Open(aHubDriver, iId)); |
65 TInt err=iHandle.Open(aHubDriver, iId); |
|
66 if (err<0) |
|
67 { |
|
68 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_CONSTRUCTL, "handle open with error %d", err ); |
|
69 User::Leave(err); |
|
70 } |
65 |
71 |
66 // Pre-allocate objects relating to this device for the event queue. |
72 // Pre-allocate objects relating to this device for the event queue. |
67 iAttachmentEvent = new(ELeave) TDeviceEvent; |
73 iAttachmentEvent = new(ELeave) TDeviceEvent; |
68 iAttachmentEvent->iInfo.iEventType = EDeviceAttachment; |
74 iAttachmentEvent->iInfo.iEventType = EDeviceAttachment; |
69 iAttachmentEvent->iInfo.iDeviceId = iId; |
75 iAttachmentEvent->iInfo.iDeviceId = iId; |
99 |
106 |
100 // '0' is the index of the string descriptor which holds the supported |
107 // '0' is the index of the string descriptor which holds the supported |
101 // language IDs. |
108 // language IDs. |
102 TBuf8<256> stringBuf; |
109 TBuf8<256> stringBuf; |
103 TUsbStringDescriptor* stringDesc = NULL; |
110 TUsbStringDescriptor* stringDesc = NULL; |
104 ASSERT_DEBUG(iHandle.Handle()); |
111 |
105 LEAVEIFERRORL(iHandle.GetStringDescriptor(stringDesc, stringBuf, 0)); |
112 if(!(iHandle.Handle())) |
|
113 { |
|
114 OstTrace0( TRACE_FATAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP1, "Empty handler" ); |
|
115 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
116 } |
|
117 |
|
118 TInt err=iHandle.GetStringDescriptor(stringDesc, stringBuf, 0); |
|
119 LEAVEIFERRORL(err, OstTrace1( TRACE_ERROR, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP6, |
|
120 "iHandle.GetStringDescriptor error %d", err );); |
106 CleanupStack::PushL(*stringDesc); |
121 CleanupStack::PushL(*stringDesc); |
107 |
122 |
108 // Copy the language IDs into our array. |
123 // Copy the language IDs into our array. |
109 TUint index = 0; |
124 TUint index = 0; |
110 TInt16 langId = stringDesc->GetLangId(index); |
125 TInt16 langId = stringDesc->GetLangId(index); |
111 while ( langId != KErrNotFound ) |
126 while ( langId != KErrNotFound ) |
112 { |
127 { |
113 LOGTEXT2(_L8("\tsupported language: 0x%04x"), langId); |
128 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL, "\tsupported language: 0x%04x", langId ); |
|
129 |
114 iLangIds.AppendL(langId); // stored as TUint |
130 iLangIds.AppendL(langId); // stored as TUint |
115 ++index; |
131 ++index; |
116 langId = stringDesc->GetLangId(index); |
132 langId = stringDesc->GetLangId(index); |
117 } |
133 } |
118 |
134 |
119 CleanupStack::PopAndDestroy(stringDesc); |
135 CleanupStack::PopAndDestroy(stringDesc); |
120 |
136 |
121 // Get the actual strings for each supported language. |
137 // Get the actual strings for each supported language. |
122 TUsbDeviceDescriptor deviceDescriptor; |
138 TUsbDeviceDescriptor deviceDescriptor; |
123 ASSERT_DEBUG(iHandle.Handle()); |
139 if(!(iHandle.Handle())) |
124 LEAVEIFERRORL(iHandle.GetDeviceDescriptor(deviceDescriptor)); |
140 { |
|
141 OstTrace0( TRACE_FATAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP2, "Empty handler" ); |
|
142 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
143 } |
|
144 |
|
145 err=iHandle.GetDeviceDescriptor(deviceDescriptor); |
|
146 LEAVEIFERRORL(err, OstTrace1( TRACE_ERROR, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP7, |
|
147 "iHandle.GetDeviceDescriptor error %d", err );); |
|
148 |
125 TUint8 manufacturerStringDescriptorIndex = deviceDescriptor.ManufacturerIndex(); |
149 TUint8 manufacturerStringDescriptorIndex = deviceDescriptor.ManufacturerIndex(); |
126 TUint8 productStringDescriptorIndex = deviceDescriptor.ProductIndex(); |
150 TUint8 productStringDescriptorIndex = deviceDescriptor.ProductIndex(); |
127 TUint8 serialNumberStringDescriptorIndex = deviceDescriptor.SerialNumberIndex(); |
151 TUint8 serialNumberStringDescriptorIndex = deviceDescriptor.SerialNumberIndex(); |
128 PopulateStringDescriptorsL(manufacturerStringDescriptorIndex, iManufacturerStrings); |
152 PopulateStringDescriptorsL(manufacturerStringDescriptorIndex, iManufacturerStrings); |
129 PopulateStringDescriptorsL(productStringDescriptorIndex, iProductStrings); |
153 PopulateStringDescriptorsL(productStringDescriptorIndex, iProductStrings); |
130 PopulateStringDescriptorsL(serialNumberStringDescriptorIndex, iSerialNumberStrings); |
154 PopulateStringDescriptorsL(serialNumberStringDescriptorIndex, iSerialNumberStrings); |
131 ASSERT_DEBUG(iManufacturerStrings.Count() == iLangIds.Count()); |
155 if(!(iManufacturerStrings.Count() == iLangIds.Count())) |
132 ASSERT_DEBUG(iProductStrings.Count() == iLangIds.Count()); |
156 { |
133 ASSERT_DEBUG(iSerialNumberStrings.Count() == iLangIds.Count()); |
157 OstTrace0( TRACE_FATAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP3, "iLangIds error" ); |
|
158 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
159 } |
|
160 if(!(iProductStrings.Count() == iLangIds.Count())) |
|
161 { |
|
162 OstTrace0( TRACE_FATAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP4, "iLangIds error" ); |
|
163 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
164 } |
|
165 if(!(iSerialNumberStrings.Count() == iLangIds.Count())) |
|
166 { |
|
167 OstTrace0( TRACE_FATAL, CDEVICEPROXY_READSTRINGDESCRIPTORSL_DUP5, "iLangIds error" ); |
|
168 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
169 } |
|
170 OstTraceFunctionExit0( CDEVICEPROXY_READSTRINGDESCRIPTORSL_EXIT ); |
134 } |
171 } |
135 |
172 |
136 // Populates the given array with the supported language variants of the given |
173 // Populates the given array with the supported language variants of the given |
137 // string. Can only leave with KErrNoMemory, which fails instantiation of the |
174 // string. Can only leave with KErrNoMemory, which fails instantiation of the |
138 // CDeviceProxy. (It is legal for instance for manufacturer strings to be |
175 // CDeviceProxy. (It is legal for instance for manufacturer strings to be |
139 // supported but serial number strings to *not* be.) |
176 // supported but serial number strings to *not* be.) |
140 void CDeviceProxy::PopulateStringDescriptorsL(TUint8 aStringDescriptorIndex, RArray<TName>& aStringArray) |
177 void CDeviceProxy::PopulateStringDescriptorsL(TUint8 aStringDescriptorIndex, RArray<TName>& aStringArray) |
141 { |
178 { |
142 LOG_FUNC |
179 OstTraceFunctionEntry0( CDEVICEPROXY_POPULATESTRINGDESCRIPTORSL_ENTRY ); |
143 |
180 |
144 const TUint langCount = iLangIds.Count(); |
181 const TUint langCount = iLangIds.Count(); |
145 for ( TUint ii = 0 ; ii < langCount ; ++ii ) |
182 for ( TUint ii = 0 ; ii < langCount ; ++ii ) |
146 { |
183 { |
147 TName string; |
184 TName string; |
148 TRAPD(err, GetStringDescriptorFromUsbdL(iLangIds[ii], string, aStringDescriptorIndex)); |
185 TRAPD(err, GetStringDescriptorFromUsbdL(iLangIds[ii], string, aStringDescriptorIndex)); |
180 iManufacturerStrings.Reset(); |
220 iManufacturerStrings.Reset(); |
181 iProductStrings.Reset(); |
221 iProductStrings.Reset(); |
182 iSerialNumberStrings.Reset(); |
222 iSerialNumberStrings.Reset(); |
183 |
223 |
184 iHandle.Close(); |
224 iHandle.Close(); |
|
225 OstTraceFunctionExit0( CDEVICEPROXY_CDEVICEPROXY_DES_EXIT ); |
185 } |
226 } |
186 |
227 |
187 TInt CDeviceProxy::GetDeviceDescriptor(TUsbDeviceDescriptor& aDescriptor) |
228 TInt CDeviceProxy::GetDeviceDescriptor(TUsbDeviceDescriptor& aDescriptor) |
188 { |
229 { |
189 LOG_FUNC |
230 OstTraceFunctionEntry0( CDEVICEPROXY_GETDEVICEDESCRIPTOR_ENTRY ); |
190 |
231 if(!(iHandle.Handle())) |
191 ASSERT_DEBUG(iHandle.Handle()); |
232 { |
|
233 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETDEVICEDESCRIPTOR_DUP1, "Empty handler" ); |
|
234 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
235 } |
192 TInt err = iHandle.GetDeviceDescriptor(aDescriptor); |
236 TInt err = iHandle.GetDeviceDescriptor(aDescriptor); |
193 |
237 |
194 LOGTEXT2(_L8("\terr = %d"), err); |
238 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETDEVICEDESCRIPTOR, "\terr = %d", err ); |
|
239 |
|
240 OstTraceFunctionExit0( CDEVICEPROXY_GETDEVICEDESCRIPTOR_EXIT ); |
195 return err; |
241 return err; |
196 } |
242 } |
197 |
243 |
198 TInt CDeviceProxy::GetConfigurationDescriptor(TUsbConfigurationDescriptor& aDescriptor) const |
244 TInt CDeviceProxy::GetConfigurationDescriptor(TUsbConfigurationDescriptor& aDescriptor) const |
199 { |
245 { |
200 LOG_FUNC |
246 OstTraceFunctionEntry0( CDEVICEPROXY_GETCONFIGURATIONDESCRIPTOR_ENTRY ); |
201 |
247 if(!(iHandle.Handle())) |
202 ASSERT_DEBUG(iHandle.Handle()); |
248 { |
|
249 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETCONFIGURATIONDESCRIPTOR, "Empty handler" ); |
|
250 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
251 } |
203 TInt err = const_cast<RUsbDevice&>(iHandle).GetConfigurationDescriptor(aDescriptor); |
252 TInt err = const_cast<RUsbDevice&>(iHandle).GetConfigurationDescriptor(aDescriptor); |
204 |
253 |
205 LOGTEXT2(_L8("\terr = %d"), err); |
254 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETCONFIGURATIONDESCRIPTOR_DUP1, "\terr = %d", err ); |
|
255 |
|
256 OstTraceFunctionExit0( CDEVICEPROXY_GETCONFIGURATIONDESCRIPTOR_EXIT ); |
206 return err; |
257 return err; |
207 } |
258 } |
208 |
259 |
209 TInt CDeviceProxy::GetTokenForInterface(TUint aIndex, TUint32& aToken) const |
260 TInt CDeviceProxy::GetTokenForInterface(TUint aIndex, TUint32& aToken) const |
210 { |
261 { |
211 LOG_FUNC |
262 OstTraceFunctionEntry0( CDEVICEPROXY_GETTOKENFORINTERFACE_ENTRY ); |
212 |
263 if(!(iHandle.Handle())) |
213 ASSERT_DEBUG(iHandle.Handle()); |
264 { |
214 // We shouldn't need to worry about whether the device is suspended or |
265 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETTOKENFORINTERFACE_DUP1, "Empty handler" ); |
|
266 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
267 } |
|
268 // We shouldn't need to worry about whether the device is suspended or |
215 // resumed before doing this. This function is only called if we find FDs |
269 // resumed before doing this. This function is only called if we find FDs |
216 // for the device, in which case we wouldn't have suspended it in the |
270 // for the device, in which case we wouldn't have suspended it in the |
217 // first place. |
271 // first place. |
218 TInt err = const_cast<RUsbDevice&>(iHandle).GetTokenForInterface(aIndex, aToken); |
272 TInt err = const_cast<RUsbDevice&>(iHandle).GetTokenForInterface(aIndex, aToken); |
219 |
273 |
220 LOGTEXT2(_L8("\terr = %d"), err); |
274 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETTOKENFORINTERFACE, "\terr = %d", err ); |
|
275 |
|
276 OstTraceFunctionExit0( CDEVICEPROXY_GETTOKENFORINTERFACE_EXIT ); |
221 return err; |
277 return err; |
222 } |
278 } |
223 |
279 |
224 const RArray<TUint>& CDeviceProxy::GetSupportedLanguages() const |
280 const RArray<TUint>& CDeviceProxy::GetSupportedLanguages() const |
225 { |
281 { |
226 LOG_FUNC |
282 OstTraceFunctionEntry0( CDEVICEPROXY_GETSUPPORTEDLANGUAGES_ENTRY ); |
227 |
283 |
228 return iLangIds; |
284 return iLangIds; |
229 } |
285 } |
230 |
286 |
231 void CDeviceProxy::GetManufacturerStringDescriptorL(TUint32 aLangId, TName& aString) const |
287 void CDeviceProxy::GetManufacturerStringDescriptorL(TUint32 aLangId, TName& aString) const |
232 { |
288 { |
233 LOG_FUNC |
289 OstTraceFunctionEntry0( CDEVICEPROXY_GETMANUFACTURERSTRINGDESCRIPTORL_ENTRY ); |
234 |
290 |
235 GetStringDescriptorFromCacheL(aLangId, aString, iManufacturerStrings); |
291 GetStringDescriptorFromCacheL(aLangId, aString, iManufacturerStrings); |
|
292 OstTraceFunctionExit0( CDEVICEPROXY_GETMANUFACTURERSTRINGDESCRIPTORL_EXIT ); |
236 } |
293 } |
237 |
294 |
238 void CDeviceProxy::GetProductStringDescriptorL(TUint32 aLangId, TName& aString) const |
295 void CDeviceProxy::GetProductStringDescriptorL(TUint32 aLangId, TName& aString) const |
239 { |
296 { |
240 LOG_FUNC |
297 OstTraceFunctionEntry0( CDEVICEPROXY_GETPRODUCTSTRINGDESCRIPTORL_ENTRY ); |
241 |
298 |
242 GetStringDescriptorFromCacheL(aLangId, aString, iProductStrings); |
299 GetStringDescriptorFromCacheL(aLangId, aString, iProductStrings); |
|
300 OstTraceFunctionExit0( CDEVICEPROXY_GETPRODUCTSTRINGDESCRIPTORL_EXIT ); |
243 } |
301 } |
244 |
302 |
245 void CDeviceProxy::GetSerialNumberStringDescriptorL(TUint32 aLangId, TName& aString) const |
303 void CDeviceProxy::GetSerialNumberStringDescriptorL(TUint32 aLangId, TName& aString) const |
246 { |
304 { |
247 LOG_FUNC |
305 OstTraceFunctionEntry0( CDEVICEPROXY_GETSERIALNUMBERSTRINGDESCRIPTORL_ENTRY ); |
248 |
306 |
249 GetStringDescriptorFromCacheL(aLangId, aString, iSerialNumberStrings); |
307 GetStringDescriptorFromCacheL(aLangId, aString, iSerialNumberStrings); |
|
308 OstTraceFunctionExit0( CDEVICEPROXY_GETSERIALNUMBERSTRINGDESCRIPTORL_EXIT ); |
250 } |
309 } |
251 |
310 |
252 void CDeviceProxy::GetOtgDescriptorL(TOtgDescriptor& aDescriptor) const |
311 void CDeviceProxy::GetOtgDescriptorL(TOtgDescriptor& aDescriptor) const |
253 { |
312 { |
254 LOG_FUNC |
313 OstTraceFunctionEntry0( CDEVICEPROXY_GETOTGDESCRIPTORL_ENTRY ); |
255 |
314 |
256 if (iOtgDescriptor) |
315 if (iOtgDescriptor) |
257 { |
316 { |
258 aDescriptor = *iOtgDescriptor; |
317 aDescriptor = *iOtgDescriptor; |
259 } |
318 } |
260 else |
319 else |
261 { |
320 { |
262 LEAVEL(KErrNotSupported); |
321 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETOTGDESCRIPTORL, "Error=%d", KErrNotSupported ); |
263 } |
322 User::Leave(KErrNotSupported); |
|
323 } |
|
324 OstTraceFunctionExit0( CDEVICEPROXY_GETOTGDESCRIPTORL_EXIT ); |
264 } |
325 } |
265 |
326 |
266 void CDeviceProxy::SetOtgDescriptorL(const TUsbOTGDescriptor& aDescriptor) |
327 void CDeviceProxy::SetOtgDescriptorL(const TUsbOTGDescriptor& aDescriptor) |
267 { |
328 { |
268 if (iOtgDescriptor) |
329 if (iOtgDescriptor) |
277 } |
338 } |
278 |
339 |
279 // Used during instantiation to read supported strings. |
340 // Used during instantiation to read supported strings. |
280 void CDeviceProxy::GetStringDescriptorFromUsbdL(TUint32 aLangId, TName& aString, TUint8 aStringDescriptorIndex) const |
341 void CDeviceProxy::GetStringDescriptorFromUsbdL(TUint32 aLangId, TName& aString, TUint8 aStringDescriptorIndex) const |
281 { |
342 { |
282 LOG_FUNC |
343 OstTraceFunctionEntry0( CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_ENTRY ); |
283 LOGTEXT3(_L8("\taLangId = 0x%04x, aStringDescriptorIndex = %d"), aLangId, aStringDescriptorIndex); |
344 |
284 |
345 OstTraceExt2( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL, "\taLangId = 0x%d, aStringDescriptorIndex = %d", aLangId, aStringDescriptorIndex ); |
|
346 |
285 // If the string is not defined by the device, leave. |
347 // If the string is not defined by the device, leave. |
286 if ( aStringDescriptorIndex == 0 ) |
348 if ( aStringDescriptorIndex == 0 ) |
287 { |
349 { |
288 LEAVEL(KErrNotFound); |
350 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_DUP1, "err=%d", KErrNotFound ); |
|
351 User::Leave(KErrNotFound); |
289 } |
352 } |
290 |
353 |
291 TBuf8<255> stringBuf; |
354 TBuf8<255> stringBuf; |
292 TUsbStringDescriptor* stringDesc = NULL; |
355 TUsbStringDescriptor* stringDesc = NULL; |
293 ASSERT_DEBUG(iHandle.Handle()); |
356 if(!(iHandle.Handle())) |
294 LEAVEIFERRORL(const_cast<RUsbDevice&>(iHandle).GetStringDescriptor(stringDesc, stringBuf, aStringDescriptorIndex, aLangId)); |
357 { |
|
358 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_DUP2, "Empty handler" ); |
|
359 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
360 } |
|
361 TInt err=const_cast<RUsbDevice&>(iHandle).GetStringDescriptor(stringDesc, stringBuf, aStringDescriptorIndex, aLangId); |
|
362 if(err<0) |
|
363 { |
|
364 OstTrace0( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_DUP4, "GetStringDescriptor error" ); |
|
365 User::Leave(err); |
|
366 } |
295 stringDesc->StringData(aString); |
367 stringDesc->StringData(aString); |
296 stringDesc->DestroyTree(); |
368 stringDesc->DestroyTree(); |
297 delete stringDesc; |
369 delete stringDesc; |
298 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
370 OstTraceExt1( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_DUP3, "\taString = \"%S\"", aString ); |
|
371 OstTraceFunctionExit0( CDEVICEPROXY_GETSTRINGDESCRIPTORFROMUSBDL_EXIT ); |
299 } |
372 } |
300 |
373 |
301 // Called indirectly by users of this class to query a string descriptor. |
374 // Called indirectly by users of this class to query a string descriptor. |
302 void CDeviceProxy::GetStringDescriptorFromCacheL(TUint32 aLangId, TName& aString, const RArray<TName>& aStringArray) const |
375 void CDeviceProxy::GetStringDescriptorFromCacheL(TUint32 aLangId, TName& aString, const RArray<TName>& aStringArray) const |
303 { |
376 { |
304 LOG_FUNC |
377 OstTraceFunctionEntry0( CDEVICEPROXY_GETSTRINGDESCRIPTORFROMCACHEL_ENTRY ); |
305 LOGTEXT2(_L8("\taLangId = 0x%04x"), aLangId); |
378 |
306 |
379 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMCACHEL_DUP1, "\taLangId = 0x%04x", aLangId ); |
|
380 |
307 // If the lang ID is not supported by the device, leave. At the same time |
381 // If the lang ID is not supported by the device, leave. At the same time |
308 // find the index of the required string in the given string array. |
382 // find the index of the required string in the given string array. |
309 const TUint langCount = iLangIds.Count(); |
383 const TUint langCount = iLangIds.Count(); |
310 TUint index = 0; |
384 TUint index = 0; |
311 for ( index = 0 ; index < langCount ; ++index ) |
385 for ( index = 0 ; index < langCount ; ++index ) |
315 break; |
389 break; |
316 } |
390 } |
317 } |
391 } |
318 if ( index == langCount ) |
392 if ( index == langCount ) |
319 { |
393 { |
320 LEAVEL(KErrNotFound); |
394 OstTrace0( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMCACHEL, "CDeviceProxy::GetStringDescriptorFromCacheL" ); |
|
395 User::Leave(KErrNotFound); |
321 } |
396 } |
322 |
397 |
323 aString = aStringArray[index]; |
398 aString = aStringArray[index]; |
324 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
399 OstTraceExt1( TRACE_NORMAL, CDEVICEPROXY_GETSTRINGDESCRIPTORFROMCACHEL_DUP2, "\taString = \"%S\"", aString ); |
|
400 |
|
401 OstTraceFunctionExit0( CDEVICEPROXY_GETSTRINGDESCRIPTORFROMCACHEL_EXIT ); |
325 } |
402 } |
326 |
403 |
327 TInt CDeviceProxy::Suspend() |
404 TInt CDeviceProxy::Suspend() |
328 { |
405 { |
329 LOG_FUNC |
406 OstTraceFunctionEntry0( CDEVICEPROXY_SUSPEND_ENTRY ); |
330 |
407 if(!(iHandle.Handle())) |
331 ASSERT_DEBUG(iHandle.Handle()); |
408 { |
|
409 OstTrace0( TRACE_FATAL, CDEVICEPROXY_SUSPEND_DUP1, "Empty handler" ); |
|
410 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
411 } |
332 TInt ret = iHandle.Suspend(); |
412 TInt ret = iHandle.Suspend(); |
333 |
413 |
334 LOGTEXT2(_L8("\tret = %d"), ret); |
414 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_SUSPEND, "\tret = %d", ret ); |
|
415 |
|
416 OstTraceFunctionExit0( CDEVICEPROXY_SUSPEND_EXIT ); |
335 return ret; |
417 return ret; |
336 } |
418 } |
337 |
419 |
338 TUint CDeviceProxy::DeviceId() const |
420 TUint CDeviceProxy::DeviceId() const |
339 { |
421 { |
340 return iId; |
422 return iId; |
341 } |
423 } |
342 |
424 |
343 void CDeviceProxy::SetDriverLoadingEventData(TDriverLoadStatus aStatus, TInt aError) |
425 void CDeviceProxy::SetDriverLoadingEventData(TDriverLoadStatus aStatus, TInt aError) |
344 { |
426 { |
345 LOG_FUNC |
427 OstTraceFunctionEntry0( CDEVICEPROXY_SETDRIVERLOADINGEVENTDATA_ENTRY ); |
346 LOGTEXT3(_L8("\taStatus = %d, aError = %d"), aStatus, aError); |
428 |
347 |
429 OstTraceExt2( TRACE_NORMAL, CDEVICEPROXY_SETDRIVERLOADINGEVENTDATA, "\taStatus = %d, aError = %d", aStatus, aError ); |
348 ASSERT_DEBUG(iDriverLoadingEvent); |
430 if(!iDriverLoadingEvent) |
349 iDriverLoadingEvent->iInfo.iDriverLoadStatus = aStatus; |
431 { |
|
432 OstTrace0( TRACE_FATAL, CDEVICEPROXY_SETDRIVERLOADINGEVENTDATA_DUP1, "Empty Driver Loading Event" ); |
|
433 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
434 } |
|
435 iDriverLoadingEvent->iInfo.iDriverLoadStatus = aStatus; |
350 iDriverLoadingEvent->iInfo.iError = aError; |
436 iDriverLoadingEvent->iInfo.iError = aError; |
351 |
437 |
352 LOG; |
438 LOG; |
|
439 OstTraceFunctionExit0( CDEVICEPROXY_SETDRIVERLOADINGEVENTDATA_EXIT ); |
353 } |
440 } |
354 |
441 |
355 TDeviceEvent* CDeviceProxy::GetAttachmentEventObject() |
442 TDeviceEvent* CDeviceProxy::GetAttachmentEventObject() |
356 { |
443 { |
357 LOG_FUNC |
444 OstTraceFunctionEntry0( CDEVICEPROXY_GETATTACHMENTEVENTOBJECT_ENTRY ); |
358 LOG; |
445 |
359 |
446 LOG; |
360 ASSERT_DEBUG(iAttachmentEvent); |
447 if(!iAttachmentEvent) |
|
448 { |
|
449 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETATTACHMENTEVENTOBJECT_DUP1, "Empty Attechment Event" ); |
|
450 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
451 } |
|
452 |
361 TDeviceEvent* const obj = iAttachmentEvent; |
453 TDeviceEvent* const obj = iAttachmentEvent; |
362 iAttachmentEvent = NULL; |
454 iAttachmentEvent = NULL; |
363 LOGTEXT2(_L8("\tobj = 0x%08x"), obj); |
455 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETATTACHMENTEVENTOBJECT, "\tobj = 0x%08x", obj ); |
|
456 |
|
457 OstTraceFunctionExit0( CDEVICEPROXY_GETATTACHMENTEVENTOBJECT_EXIT ); |
364 return obj; |
458 return obj; |
365 } |
459 } |
366 |
460 |
367 TDeviceEvent* CDeviceProxy::GetDriverLoadingEventObject() |
461 TDeviceEvent* CDeviceProxy::GetDriverLoadingEventObject() |
368 { |
462 { |
369 LOG_FUNC |
463 OstTraceFunctionEntry0( CDEVICEPROXY_GETDRIVERLOADINGEVENTOBJECT_ENTRY ); |
370 LOG; |
464 |
371 |
465 LOG; |
372 ASSERT_DEBUG(iDriverLoadingEvent); |
466 if(!iDriverLoadingEvent) |
|
467 { |
|
468 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETDRIVERLOADINGEVENTOBJECT, "Empty Driver Loading Event" ); |
|
469 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
470 } |
|
471 |
373 TDeviceEvent* const obj = iDriverLoadingEvent; |
472 TDeviceEvent* const obj = iDriverLoadingEvent; |
374 iDriverLoadingEvent = NULL; |
473 iDriverLoadingEvent = NULL; |
375 LOGTEXT2(_L8("\tobj = 0x%08x"), obj); |
474 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETDRIVERLOADINGEVENTOBJECT_DUP1, "\tobj = 0x%08x", obj ); |
|
475 |
|
476 OstTraceFunctionExit0( CDEVICEPROXY_GETDRIVERLOADINGEVENTOBJECT_EXIT ); |
376 return obj; |
477 return obj; |
377 } |
478 } |
378 |
479 |
379 TDeviceEvent* CDeviceProxy::GetDetachmentEventObject() |
480 TDeviceEvent* CDeviceProxy::GetDetachmentEventObject() |
380 { |
481 { |
381 LOG_FUNC |
482 OstTraceFunctionEntry0( CDEVICEPROXY_GETDETACHMENTEVENTOBJECT_ENTRY ); |
382 LOG; |
483 LOG; |
383 |
484 |
384 ASSERT_DEBUG(iDetachmentEvent); |
485 if(!iDetachmentEvent) |
|
486 { |
|
487 OstTrace0( TRACE_FATAL, CDEVICEPROXY_GETDETACHMENTEVENTOBJECT, "Empty Detachment Event" ); |
|
488 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory, __LINE__)); |
|
489 } |
385 TDeviceEvent* const obj = iDetachmentEvent; |
490 TDeviceEvent* const obj = iDetachmentEvent; |
386 iDetachmentEvent = NULL; |
491 iDetachmentEvent = NULL; |
387 LOGTEXT2(_L8("\tobj = 0x%08x"), obj); |
492 |
|
493 OstTrace1( TRACE_NORMAL, CDEVICEPROXY_GETDETACHMENTEVENTOBJECT_DUP1, "\tobj = 0x%08x", obj ); |
|
494 |
|
495 OstTraceFunctionExit0( CDEVICEPROXY_GETDETACHMENTEVENTOBJECT_EXIT ); |
388 return obj; |
496 return obj; |
389 } |
497 } |
390 |
498 |
391 #ifdef __FLOG_ACTIVE |
|
392 |
499 |
393 void CDeviceProxy::Log() |
500 void CDeviceProxy::Log() |
394 { |
501 { |
395 LOG_FUNC |
502 OstTraceFunctionEntry0( CDEVICEPROXY_LOG_ENTRY ); |
396 |
503 |
397 LOGTEXT2(_L8("\tiId = %d"), iId); |
504 OstTrace1( TRACE_DUMP, CDEVICEPROXY_LOG, "\tiId = %d", iId ); |
398 LOGTEXT2(_L8("\tiHandle.Handle() = %d"), iHandle.Handle()); |
505 OstTrace1( TRACE_DUMP, CDEVICEPROXY_LOG_DUP1, "\tiHandle.Handle() = %d", iHandle.Handle() ); |
399 if ( iAttachmentEvent ) |
506 |
400 { |
507 if ( iAttachmentEvent ) |
401 LOGTEXT(_L8("\tlogging iAttachmentEvent")); |
508 { |
402 iAttachmentEvent->Log(); |
509 OstTrace0( TRACE_DUMP, CDEVICEPROXY_LOG_DUP2, "\tlogging iAttachmentEvent" ); |
|
510 iAttachmentEvent->Log(); |
403 } |
511 } |
404 if ( iDriverLoadingEvent ) |
512 if ( iDriverLoadingEvent ) |
405 { |
513 { |
406 LOGTEXT(_L8("\tlogging iDriverLoadingEvent")); |
514 OstTrace0( TRACE_DUMP, CDEVICEPROXY_LOG_DUP3, "\tlogging iDriverLoadingEvent" ); |
|
515 |
407 iDriverLoadingEvent->Log(); |
516 iDriverLoadingEvent->Log(); |
408 } |
517 } |
409 if ( iDetachmentEvent ) |
518 if ( iDetachmentEvent ) |
410 { |
519 { |
411 LOGTEXT(_L8("\tlogging iDetachmentEvent")); |
520 OstTrace0( TRACE_DUMP, CDEVICEPROXY_LOG_DUP4, "\tlogging iDetachmentEvent" ); |
412 iDetachmentEvent->Log(); |
521 iDetachmentEvent->Log(); |
413 } |
522 } |
414 const TUint langCount = iLangIds.Count(); |
523 const TUint langCount = iLangIds.Count(); |
415 const TUint manufacturerCount = iManufacturerStrings.Count(); |
524 const TUint manufacturerCount = iManufacturerStrings.Count(); |
416 const TUint productCount = iProductStrings.Count(); |
525 const TUint productCount = iProductStrings.Count(); |
419 // from the code below we can see that some protection have been added |
528 // from the code below we can see that some protection have been added |
420 // if(ii<manufacturerCount) etc... |
529 // if(ii<manufacturerCount) etc... |
421 // This has been done to protect in case there have been an incomplete construction etc.. |
530 // This has been done to protect in case there have been an incomplete construction etc.. |
422 // when logging the data |
531 // when logging the data |
423 |
532 |
424 LOGTEXT2(_L8("\tlangCount = %d"), langCount); |
533 OstTrace1( TRACE_DUMP, CDEVICEPROXY_LOG_DUP5, "C\tlangCount = %d", langCount ); |
|
534 |
425 for ( TUint ii = 0 ; ii < langCount ; ++ii ) |
535 for ( TUint ii = 0 ; ii < langCount ; ++ii ) |
426 { |
536 { |
427 LOGTEXT2(_L("\tlang ID 0x%04x:"), iLangIds[ii]); |
537 OstTrace1( TRACE_FLOW, CDEVICEPROXY_LOG_DUP6, "\tlang ID 0x%04x:", iLangIds[ii] ); |
|
538 |
428 if(ii<manufacturerCount) |
539 if(ii<manufacturerCount) |
429 { |
540 { |
430 LOGTEXT2(_L("\t\tmanufacturer string: \"%S\""), &iManufacturerStrings[ii]); |
541 OstTraceExt1( TRACE_FLOW, CDEVICEPROXY_LOG_DUP7, "\t\tmanufacturer string: \"%S\"", iManufacturerStrings[ii] ); |
431 } |
542 } |
432 if(ii<productCount) |
543 if(ii<productCount) |
433 { |
544 { |
434 LOGTEXT2(_L("\t\tproduct string: \"%S\""), &iProductStrings[ii]); |
545 OstTraceExt1( TRACE_FLOW, CDEVICEPROXY_LOG_DUP8, "\t\tproduct string: \"%S\"", iProductStrings[ii]); |
435 } |
546 } |
436 if(ii<serialNumberCount) |
547 if(ii<serialNumberCount) |
437 { |
548 { |
438 LOGTEXT2(_L("\t\tserial number string: \"%S\""), &iSerialNumberStrings[ii]); |
549 OstTraceExt1( TRACE_FLOW, CDEVICEPROXY_LOG_DUP9, "\t\tserial number string: \"%S\"", iSerialNumberStrings[ii]); |
439 } |
550 } |
440 |
551 |
441 } |
552 } |
442 } |
553 OstTraceFunctionExit0( CDEVICEPROXY_LOG_EXIT ); |
443 |
554 } |
444 #endif |
555 |