17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
20 @internalComponent |
20 @internalComponent |
21 */ |
21 */ |
22 |
|
23 #include "fdcproxy.h" |
|
24 #include <ecom/ecom.h> |
22 #include <ecom/ecom.h> |
25 #include "utils.h" |
|
26 #include <usbhost/internal/fdcplugin.h> |
23 #include <usbhost/internal/fdcplugin.h> |
27 #include <usbhost/internal/fdcinterface.h> |
24 #include <usbhost/internal/fdcinterface.h> |
|
25 |
|
26 #include "fdcproxy.h" |
|
27 #include "utils.h" |
28 #include "fdf.h" |
28 #include "fdf.h" |
29 #include "utils.h" |
29 #include "utils.h" |
30 |
30 #include "OstTraceDefinitions.h" |
31 #ifdef __FLOG_ACTIVE |
31 #ifdef OST_TRACE_COMPILER_IN_USE |
32 _LIT8(KLogComponent, "fdf "); |
32 #include "fdcproxyTraces.h" |
33 #endif |
33 #endif |
34 |
34 |
35 #ifdef __FLOG_ACTIVE |
35 |
|
36 #ifdef _DEBUG |
36 #define LOG Log() |
37 #define LOG Log() |
37 #else |
38 #define INVARIANT Invariant() |
|
39 #else |
38 #define LOG |
40 #define LOG |
39 #endif |
|
40 |
|
41 #ifdef _DEBUG |
|
42 #define INVARIANT Invariant() |
|
43 #else |
|
44 #define INVARIANT |
41 #define INVARIANT |
45 #endif |
42 #endif |
46 |
43 |
47 PANICCATEGORY("fdcproxy"); |
44 _LIT(KPanicCategory, "fdcproxy"); |
48 |
|
49 |
|
50 |
45 |
51 CFdcProxy* CFdcProxy::NewL(CFdf& aFdf, CImplementationInformation& aImplInfo) |
46 CFdcProxy* CFdcProxy::NewL(CFdf& aFdf, CImplementationInformation& aImplInfo) |
52 { |
47 { |
53 LOG_STATIC_FUNC_ENTRY |
48 OstTraceFunctionEntry0( CFDCPROXY_NEWL_ENTRY ); |
54 |
49 |
55 CFdcProxy* self = new(ELeave) CFdcProxy(aFdf); |
50 CFdcProxy* self = new(ELeave) CFdcProxy(aFdf); |
56 CleanupStack::PushL(self); |
51 CleanupStack::PushL(self); |
57 self->ConstructL(aImplInfo); |
52 self->ConstructL(aImplInfo); |
58 #ifdef __FLOG_ACTIVE |
53 #ifdef _DEBUG |
59 self->INVARIANT; |
54 self->INVARIANT; |
60 #endif |
55 #endif |
61 CleanupStack::Pop(self); |
56 CleanupStack::Pop(self); |
|
57 OstTraceFunctionExit0( CFDCPROXY_NEWL_EXIT ); |
62 return self; |
58 return self; |
63 } |
59 } |
64 |
60 |
65 |
61 |
66 void CFdcProxy::ConstructL(CImplementationInformation& aImplInfo) |
62 void CFdcProxy::ConstructL(CImplementationInformation& aImplInfo) |
67 { |
63 { |
68 LOG_FUNC |
64 OstTraceFunctionEntry0( CFDCPROXY_CONSTRUCTL_ENTRY ); |
69 |
65 |
70 LOGTEXT2(_L8("\t\tFDC implementation UID: 0x%08x"), aImplInfo.ImplementationUid()); |
66 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL, "FDC implementation UID: 0x%08x", aImplInfo.ImplementationUid().iUid ); |
71 LOGTEXT2(_L("\t\tFDC display name: \"%S\""), &aImplInfo.DisplayName()); |
67 OstTraceExt1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP1, "FDC display name: \"%S\"", aImplInfo.DisplayName() ); |
72 LOGTEXT2(_L8("\t\tFDC default_data: \"%S\""), &aImplInfo.DataType()); |
68 OstTraceExt1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP2, "FDC default_data: \"%s\"", aImplInfo.DataType() ); |
73 LOGTEXT2(_L8("\t\tFDC version: %d"), aImplInfo.Version()); |
69 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP3, "FDC version: %d", aImplInfo.Version() ); |
74 LOGTEXT2(_L8("\t\tFDC disabled: %d"), aImplInfo.Disabled()); |
70 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP4, "FDC disabled: %d", aImplInfo.Disabled()); |
75 TDriveName drvName = aImplInfo.Drive().Name(); |
71 TDriveName drvName = aImplInfo.Drive().Name(); |
76 LOGTEXT2(_L8("\t\tFDC drive: %S"), &drvName); |
72 |
77 LOGTEXT2(_L8("\t\tFDC rom only: %d"), aImplInfo.RomOnly()); |
73 OstTraceExt1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP5, "FDC drive: %S", drvName ); |
78 LOGTEXT2(_L8("\t\tFDC rom based: %d"), aImplInfo.RomBased()); |
74 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP6, "FDC rom only: %d", aImplInfo.RomOnly() ); |
79 LOGTEXT2(_L8("\t\tFDC vendor ID: %08x"), (TUint32)aImplInfo.VendorId()); |
75 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP7, "FDC rom based: %d", aImplInfo.RomBased() ); |
80 |
76 OstTrace1( TRACE_DUMP, CFDCPROXY_CONSTRUCTL_DUP8, "FDC vendor ID: %08x", (TUint32)aImplInfo.VendorId() ); |
|
77 |
|
78 |
81 // Before PREQ2080 a reference to the CImplementationInformation object was held. This is no longer |
79 // Before PREQ2080 a reference to the CImplementationInformation object was held. This is no longer |
82 // possible because as soon as REComSession::ListImplementations() is called the reference will be |
80 // possible because as soon as REComSession::ListImplementations() is called the reference will be |
83 // invalid. |
81 // invalid. |
84 iImplementationUid = aImplInfo.ImplementationUid(); |
82 iImplementationUid = aImplInfo.ImplementationUid(); |
85 iVersion = aImplInfo.Version(); |
83 iVersion = aImplInfo.Version(); |
86 iDefaultData.CreateL(aImplInfo.DataType()); |
84 iDefaultData.CreateL(aImplInfo.DataType()); |
87 iRomBased = aImplInfo.RomBased(); |
85 iRomBased = aImplInfo.RomBased(); |
|
86 OstTraceFunctionExit0( CFDCPROXY_CONSTRUCTL_EXIT ); |
88 } |
87 } |
89 |
88 |
90 CFdcProxy::CFdcProxy(CFdf& aFdf) |
89 CFdcProxy::CFdcProxy(CFdf& aFdf) |
91 : iFdf(aFdf), |
90 : iFdf(aFdf), |
92 i0thInterface(-1) // -1 means unassigned |
91 i0thInterface(-1) // -1 means unassigned |
93 { |
92 { |
94 LOG_FUNC |
93 OstTraceFunctionEntry0( CFDCPROXY_CFDCPROXY_CONS_ENTRY ); |
95 } |
94 } |
96 |
95 |
97 |
96 |
98 CFdcProxy::~CFdcProxy() |
97 CFdcProxy::~CFdcProxy() |
99 { |
98 { |
100 LOG_FUNC |
99 OstTraceFunctionEntry0( CFDCPROXY_CFDCPROXY_DES_ENTRY ); |
101 INVARIANT; |
100 INVARIANT; |
102 |
101 |
103 // Only executed when the FDF is finally shutting down. |
102 // Only executed when the FDF is finally shutting down. |
104 // By this time detachment of all devices should have been signalled to |
103 // By this time detachment of all devices should have been signalled to |
105 // all FDCs and the FDC plugins should have been cleaned up. |
104 // all FDCs and the FDC plugins should have been cleaned up. |
106 // If is safe to assert this because iPlugin and iDeviceIds are not |
105 // If is safe to assert this because iPlugin and iDeviceIds are not |
107 // allocated on construction so this doesn't have to safe against partial |
106 // allocated on construction so this doesn't have to safe against partial |
108 // construction. |
107 // construction. |
109 ASSERT_DEBUG(!iPlugin); |
108 |
110 ASSERT_DEBUG(iDeviceIds.Count() == 0); |
109 if(iPlugin) |
111 iDeviceIds.Close(); |
110 { |
|
111 OstTrace0( TRACE_FATAL, CFDCPROXY_CFDCPROXY_DUP2, "Plugin should empty" ); |
|
112 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
113 } |
|
114 if(!(iDeviceIds.Count() == 0)) |
|
115 { |
|
116 OstTrace0( TRACE_FATAL, CFDCPROXY_CFDCPROXY_DUP3, "DeviceCount should be 0" ); |
|
117 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
118 } |
|
119 iDeviceIds.Close(); |
112 iDefaultData.Close(); |
120 iDefaultData.Close(); |
113 |
121 |
114 INVARIANT; |
122 INVARIANT; |
|
123 OstTraceFunctionExit0( CFDCPROXY_CFDCPROXY_DES_EXIT ); |
115 } |
124 } |
116 |
125 |
117 |
126 |
118 TInt CFdcProxy::NewFunction(TUint aDeviceId, |
127 TInt CFdcProxy::NewFunction(TUint aDeviceId, |
119 const RArray<TUint>& aInterfaces, |
128 const RArray<TUint>& aInterfaces, |
120 const TUsbDeviceDescriptor& aDeviceDescriptor, |
129 const TUsbDeviceDescriptor& aDeviceDescriptor, |
121 const TUsbConfigurationDescriptor& aConfigurationDescriptor) |
130 const TUsbConfigurationDescriptor& aConfigurationDescriptor) |
122 { |
131 { |
123 LOG_FUNC |
132 OstTraceFunctionEntry0( CFDCPROXY_NEWFUNCTION_ENTRY ); |
124 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
133 |
|
134 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTION, "aDeviceId = %d", aDeviceId ); |
125 INVARIANT; |
135 INVARIANT; |
126 |
136 |
127 // Create a plugin object if required, call Mfi1NewFunction on it, and |
137 // Create a plugin object if required, call Mfi1NewFunction on it, and |
128 // update our iDeviceIds. |
138 // update our iDeviceIds. |
129 TRAPD(err, NewFunctionL(aDeviceId, aInterfaces, aDeviceDescriptor, aConfigurationDescriptor)); |
139 TRAPD(err, NewFunctionL(aDeviceId, aInterfaces, aDeviceDescriptor, aConfigurationDescriptor)); |
130 INVARIANT; |
140 INVARIANT; |
131 LOGTEXT2(_L8("\terr = %d"), err); |
141 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTION_DUP1, "err = %d", err ); |
|
142 OstTraceFunctionExit0( CFDCPROXY_NEWFUNCTION_EXIT ); |
132 return err; |
143 return err; |
133 } |
144 } |
134 |
145 |
135 |
146 |
136 void CFdcProxy::NewFunctionL(TUint aDeviceId, |
147 void CFdcProxy::NewFunctionL(TUint aDeviceId, |
137 const RArray<TUint>& aInterfaces, |
148 const RArray<TUint>& aInterfaces, |
138 const TUsbDeviceDescriptor& aDeviceDescriptor, |
149 const TUsbDeviceDescriptor& aDeviceDescriptor, |
139 const TUsbConfigurationDescriptor& aConfigurationDescriptor) |
150 const TUsbConfigurationDescriptor& aConfigurationDescriptor) |
140 { |
151 { |
141 LOG_FUNC |
152 OstTraceFunctionEntry0( CFDCPROXY_NEWFUNCTIONL_ENTRY ); |
142 |
153 |
143 // We may already have aDeviceId in our collection of device IDs, if the |
154 // We may already have aDeviceId in our collection of device IDs, if the |
144 // device is offering multiple Functions of the same type. In this case we |
155 // device is offering multiple Functions of the same type. In this case we |
145 // don't want to add the device ID again. |
156 // don't want to add the device ID again. |
146 // If we already know about this device, then we should definitely have |
157 // If we already know about this device, then we should definitely have |
157 { |
168 { |
158 alreadyKnowThisDevice = ETrue; |
169 alreadyKnowThisDevice = ETrue; |
159 break; |
170 break; |
160 } |
171 } |
161 } |
172 } |
162 LOGTEXT2(_L8("\talreadyKnowThisDevice = %d"), alreadyKnowThisDevice); |
173 |
163 |
174 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL, "alreadyKnowThisDevice = %d", alreadyKnowThisDevice ); |
|
175 |
164 TArrayRemove arrayRemove(iDeviceIds, aDeviceId); |
176 TArrayRemove arrayRemove(iDeviceIds, aDeviceId); |
165 if ( !alreadyKnowThisDevice ) |
177 if ( !alreadyKnowThisDevice ) |
166 { |
178 { |
167 // We add the device ID to our array first because it's failable. |
179 // We add the device ID to our array first because it's failable. |
168 // Logically, it should be done *after* we call Mfi1NewFunction on the |
180 // Logically, it should be done *after* we call Mfi1NewFunction on the |
169 // plugin, but we can't have the failable step of adding the device ID |
181 // plugin, but we can't have the failable step of adding the device ID |
170 // to the array after telling the FDC. |
182 // to the array after telling the FDC. |
171 LEAVEIFERRORL(iDeviceIds.Append(aDeviceId)); |
183 TInt error=iDeviceIds.Append(aDeviceId); |
|
184 LEAVEIFERRORL(error,OstTrace0( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUT1, "iDeviceIds append fails" );); |
|
185 |
172 // This cleanup item removes aDeviceId from iDeviceIds on a leave. |
186 // This cleanup item removes aDeviceId from iDeviceIds on a leave. |
173 CleanupRemovePushL(arrayRemove); |
187 CleanupRemovePushL(arrayRemove); |
174 } |
188 } |
175 |
189 |
176 TBool neededToMakePlugin = EFalse; |
190 TBool neededToMakePlugin = EFalse; |
177 CFdcPlugin* plugin = iPlugin; |
191 CFdcPlugin* plugin = iPlugin; |
178 MFdcInterfaceV1* iface = iInterface; |
192 MFdcInterfaceV1* iface = iInterface; |
179 if ( !plugin ) |
193 if ( !plugin ) |
180 { |
194 { |
181 neededToMakePlugin = ETrue; |
195 neededToMakePlugin = ETrue; |
182 LOGTEXT2(_L8("\t\tFDC implementation UID: 0x%08x"), iImplementationUid); |
196 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUP2, "FDC implementation UID: 0x%08x", iImplementationUid.iUid ); |
183 plugin = CFdcPlugin::NewL(iImplementationUid, *this); |
197 plugin = CFdcPlugin::NewL(iImplementationUid, *this); |
184 CleanupStack::PushL(plugin); |
198 CleanupStack::PushL(plugin); |
185 iface = reinterpret_cast<MFdcInterfaceV1*>(plugin->GetInterface(TUid::Uid(KFdcInterfaceV1))); |
199 iface = reinterpret_cast<MFdcInterfaceV1*>(plugin->GetInterface(TUid::Uid(KFdcInterfaceV1))); |
186 } |
200 } |
187 ASSERT_DEBUG(iface); |
201 |
|
202 if(!iface) |
|
203 { |
|
204 OstTrace0( TRACE_FATAL, CFDCPROXY_NEWFUNCTIONL_DUP3, "Empty interface" ); |
|
205 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
206 } |
|
207 |
|
208 |
188 TInt err = KErrNone; |
209 TInt err = KErrNone; |
189 |
210 |
190 // Log the interfaces they're being offered. |
211 // Log the interfaces they're being offered. |
191 #ifdef __FLOG_ACTIVE |
|
192 const TUint ifCount = aInterfaces.Count(); |
212 const TUint ifCount = aInterfaces.Count(); |
193 LOGTEXT2(_L8("\toffering %d interfaces:"), ifCount); |
213 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUP4, "offering %d interfaces:", ifCount ); |
194 for ( TUint ii = 0 ; ii < ifCount ; ++ii ) |
214 for ( TUint ii = 0 ; ii < ifCount ; ++ii ) |
195 { |
215 { |
196 LOGTEXT2(_L8("\t\tinterface %d"), aInterfaces[ii]); |
216 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUP5, "interface %d", aInterfaces[ii] ); |
197 } |
217 } |
198 #endif |
|
199 |
218 |
200 iInMfi1NewFunction = ETrue; |
219 iInMfi1NewFunction = ETrue; |
201 // Check that the FDC always claims the 0th interface. |
220 // Check that the FDC always claims the 0th interface. |
202 ASSERT_DEBUG(i0thInterface == -1); |
221 if(!(i0thInterface == -1)) |
|
222 { |
|
223 OstTrace0( TRACE_FATAL, CFDCPROXY_NEWFUNCTIONL_DUP6, "the FDC not claims the 0th interface" ); |
|
224 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
225 } |
|
226 |
203 i0thInterface = aInterfaces[0]; |
227 i0thInterface = aInterfaces[0]; |
204 err = iface->Mfi1NewFunction( aDeviceId, |
228 err = iface->Mfi1NewFunction( aDeviceId, |
205 aInterfaces.Array(), // actually pass them a TArray for const access |
229 aInterfaces.Array(), // actually pass them a TArray for const access |
206 aDeviceDescriptor, |
230 aDeviceDescriptor, |
207 aConfigurationDescriptor); |
231 aConfigurationDescriptor); |
208 LOGTEXT2(_L8("\terr = %d"), err); |
232 OstTrace1( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUP11, "err = %d", err); |
209 iInMfi1NewFunction = EFalse; |
233 iInMfi1NewFunction = EFalse; |
210 // The implementation of Mfi1NewFunction may not leave. |
234 // The implementation of Mfi1NewFunction may not leave. |
211 // ASSERT_ALWAYS(leave_err == KErrNone); |
235 // ASSERT_ALWAYS(leave_err == KErrNone); |
212 // This is set back to -1 when the FDC claims the 0th interface. |
236 // This is set back to -1 when the FDC claims the 0th interface. |
213 ASSERT_DEBUG(i0thInterface == -1); |
237 if(!(i0thInterface == -1)) |
214 |
238 { |
|
239 OstTrace0( TRACE_FATAL, CFDCPROXY_NEWFUNCTIONL_DUP7, "the FDC not claims the 0th interface" ); |
|
240 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
241 } |
|
242 |
215 // If this leaves, then: |
243 // If this leaves, then: |
216 // (a) aDeviceId will be removed from iDeviceIds (if we needed to add it). |
244 // (a) aDeviceId will be removed from iDeviceIds (if we needed to add it). |
217 // (b) the FDF will get the leave code. |
245 // (b) the FDF will get the leave code. |
218 // If this doesn't leave, then iPlugin, iInterface and iDeviceIds are |
246 // If this doesn't leave, then iPlugin, iInterface and iDeviceIds are |
219 // populated OK and the FDF will get KErrNone. |
247 // populated OK and the FDF will get KErrNone. |
220 LEAVEIFERRORL(err); |
248 LEAVEIFERRORL(err,OstTrace0( TRACE_NORMAL, CFDCPROXY_NEWFUNCTIONL_DUP8,"iface->Mfi1NewFunction function fails");); |
221 |
249 |
222 if ( neededToMakePlugin ) |
250 if ( neededToMakePlugin ) |
223 { |
251 { |
224 CLEANUPSTACK_POP1(plugin); |
252 CLEANUPSTACK_POP1(plugin); |
225 // Now everything failable has been done we can assign iPlugin and |
253 // Now everything failable has been done we can assign iPlugin and |
226 // iInterface. |
254 // iInterface. |
227 ASSERT_DEBUG(plugin); |
255 if(!plugin) |
228 ASSERT_DEBUG(iface); |
256 { |
|
257 OstTrace0( TRACE_FATAL, CFDCPROXY_NEWFUNCTIONL_DUP9,"Empty plugin"); |
|
258 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
259 } |
|
260 if(!iface) |
|
261 { |
|
262 OstTrace0( TRACE_FATAL, CFDCPROXY_NEWFUNCTIONL_DUP10,"Empty iface"); |
|
263 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
264 } |
229 iPlugin = plugin; |
265 iPlugin = plugin; |
230 iInterface = iface; |
266 iInterface = iface; |
231 } |
267 } |
232 if ( !alreadyKnowThisDevice ) |
268 if ( !alreadyKnowThisDevice ) |
233 { |
269 { |
234 CLEANUPSTACK_POP1(&arrayRemove); |
270 CLEANUPSTACK_POP1(&arrayRemove); |
235 } |
271 } |
|
272 OstTraceFunctionExit0( CFDCPROXY_NEWFUNCTIONL_EXIT ); |
236 } |
273 } |
237 |
274 |
238 |
275 |
239 // Called by the FDF whenever a device is detached. |
276 // Called by the FDF whenever a device is detached. |
240 // We check if the device is relevant to us. If it is, we signal its |
277 // We check if the device is relevant to us. If it is, we signal its |
241 // detachment to the plugin. |
278 // detachment to the plugin. |
242 void CFdcProxy::DeviceDetached(TUint aDeviceId) |
279 void CFdcProxy::DeviceDetached(TUint aDeviceId) |
243 { |
280 { |
244 LOG_FUNC |
281 OstTraceFunctionEntry0( CFDCPROXY_DEVICEDETACHED_ENTRY ); |
245 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
282 OstTrace1( TRACE_NORMAL, CFDCPROXY_DEVICEDETACHED, "aDeviceId = %d", aDeviceId ); |
|
283 |
246 INVARIANT; |
284 INVARIANT; |
247 |
285 |
248 const TUint count = iDeviceIds.Count(); |
286 const TUint count = iDeviceIds.Count(); |
249 for ( TUint ii = 0 ; ii < count ; ++ii ) |
287 for ( TUint ii = 0 ; ii < count ; ++ii ) |
250 { |
288 { |
251 if ( iDeviceIds[ii] == aDeviceId ) |
289 if ( iDeviceIds[ii] == aDeviceId ) |
252 { |
290 { |
253 LOGTEXT(_L8("\tmatching device id- calling Mfi1DeviceDetached!")); |
291 OstTrace0( TRACE_FATAL, CFDCPROXY_DEVICEDETACHED_DUP1, "matching device id- calling Mfi1DeviceDetached!"); |
254 ASSERT_DEBUG(iInterface); |
292 if(!iInterface) |
|
293 { |
|
294 OstTrace0( TRACE_NORMAL, CFDCPROXY_DEVICEDETACHED_DUP2, "Empty iInterface" ); |
|
295 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
296 } |
|
297 |
255 iInterface->Mfi1DeviceDetached(aDeviceId); |
298 iInterface->Mfi1DeviceDetached(aDeviceId); |
256 // The implementation of Mfi1DeviceDetached may not leave. |
299 // The implementation of Mfi1DeviceDetached may not leave. |
257 // ASSERT_ALWAYS(err == KErrNone); |
300 // ASSERT_ALWAYS(err == KErrNone); |
258 iDeviceIds.Remove(ii); |
301 iDeviceIds.Remove(ii); |
259 break; |
302 break; |
260 } |
303 } |
261 } |
304 } |
262 |
305 OstTrace1( TRACE_NORMAL, CFDCPROXY_DEVICEDETACHED_DUP3, "iDeviceIds.Count() = %d", iDeviceIds.Count() ); |
263 LOGTEXT2(_L8("\tiDeviceIds.Count() = %d"), iDeviceIds.Count()); |
306 |
264 if ( iDeviceIds.Count() == 0 ) |
307 if ( iDeviceIds.Count() == 0 ) |
265 { |
308 { |
266 delete iPlugin; |
309 delete iPlugin; |
267 iPlugin = NULL; |
310 iPlugin = NULL; |
268 iInterface = NULL; |
311 iInterface = NULL; |
273 #pragma message("ECom defect DEF122443 raised") |
316 #pragma message("ECom defect DEF122443 raised") |
274 REComSession::FinalClose(); |
317 REComSession::FinalClose(); |
275 } |
318 } |
276 |
319 |
277 INVARIANT; |
320 INVARIANT; |
278 } |
321 OstTraceFunctionExit0( CFDCPROXY_DEVICEDETACHED_EXIT ); |
279 |
322 } |
280 |
323 |
281 #ifdef _DEBUG |
324 |
282 void CFdcProxy::Invariant() const |
325 void CFdcProxy::Invariant() const |
283 { |
326 { |
284 // If the class invariant fails hopefully it will be clear why from |
327 // If the class invariant fails hopefully it will be clear why from |
285 // inspection of this object dump. |
328 // inspection of this object dump. |
286 LOG; |
329 LOG; |
287 |
330 |
288 // Either these are all 0 or none of them are: |
331 // Either these are all 0 or none of them are: |
289 // iDeviceIds.Count, iPlugin, iInterface |
332 // iDeviceIds.Count, iPlugin, iInterface |
290 |
333 |
291 ASSERT_DEBUG( |
334 if(!( |
292 ( |
335 ( |
293 iDeviceIds.Count() != 0 && iPlugin && iInterface |
336 iDeviceIds.Count() != 0 && iPlugin && iInterface |
294 ) |
337 ) |
295 || |
338 || |
296 ( |
339 ( |
297 iDeviceIds.Count() == 0 && !iPlugin && !iInterface |
340 iDeviceIds.Count() == 0 && !iPlugin && !iInterface |
298 ) |
341 ) |
299 ); |
342 )) |
|
343 { |
|
344 OstTrace0( TRACE_FATAL, CFDCPROXY_INVARIANT, "iDeviceIds count error" ); |
|
345 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
346 } |
|
347 |
300 |
348 |
301 // Each device ID appears only once in the device ID array. |
349 // Each device ID appears only once in the device ID array. |
302 const TUint count = iDeviceIds.Count(); |
350 const TUint count = iDeviceIds.Count(); |
303 for ( TUint ii = 0 ; ii < count ; ++ii ) |
351 for ( TUint ii = 0 ; ii < count ; ++ii ) |
304 { |
352 { |
305 for ( TUint jj = ii+1 ; jj < count ; ++jj ) |
353 for ( TUint jj = ii+1 ; jj < count ; ++jj ) |
306 { |
354 { |
307 ASSERT_DEBUG(iDeviceIds[ii] != iDeviceIds[jj]); |
355 if(!(iDeviceIds[ii] != iDeviceIds[jj])) |
|
356 { |
|
357 OstTrace0( TRACE_FATAL, CFDCPROXY_INVARIANT_DUP1, "Repeated iDeviceIDs" ); |
|
358 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
359 } |
|
360 |
308 } |
361 } |
309 } |
362 } |
310 } |
363 } |
311 |
364 |
312 |
365 |
313 void CFdcProxy::Log() const |
366 void CFdcProxy::Log() const |
314 { |
367 { |
315 LOGTEXT2(_L8("\tLogging CFdcProxy 0x%08x:"), this); |
368 OstTrace1( TRACE_DUMP, CFDCPROXY_LOG, "Logging CFdcProxy 0x%08x:", this ); |
316 const TUint count = iDeviceIds.Count(); |
369 const TUint count = iDeviceIds.Count(); |
317 LOGTEXT2(_L8("\t\tiDeviceIds.Count() = %d"), count); |
370 OstTrace1( TRACE_DUMP, CFDCPROXY_LOG_DUP1, "iDeviceIds.Count() = %d", count ); |
|
371 |
318 for ( TUint i = 0 ; i < count ; ++i ) |
372 for ( TUint i = 0 ; i < count ; ++i ) |
319 { |
373 { |
320 LOGTEXT3(_L8("\t\t\tiDeviceIds[%d] = %d"), i, iDeviceIds[i]); |
374 OstTraceExt2( TRACE_DUMP, CFDCPROXY_LOG_DUP2, "iDeviceIds[%u] = %u", i, iDeviceIds[i] ); |
321 } |
375 } |
322 LOGTEXT2(_L8("\t\tiPlugin = 0x%08x"), iPlugin); |
376 OstTrace1( TRACE_DUMP, CFDCPROXY_LOG_DUP3, "iPlugin = 0x%08x", iPlugin ); |
323 LOGTEXT2(_L8("\t\tiInterface = 0x%08x"), iInterface); |
377 OstTrace1( TRACE_DUMP, CFDCPROXY_LOG_DUP4, "iInterface = 0x%08x", iInterface ); |
324 } |
378 } |
325 #endif // _DEBUG |
|
326 |
379 |
327 |
380 |
328 const TDesC8& CFdcProxy::DefaultDataField() const |
381 const TDesC8& CFdcProxy::DefaultDataField() const |
329 { |
382 { |
330 return iDefaultData; |
383 return iDefaultData; |
399 } |
457 } |
400 |
458 |
401 |
459 |
402 const RArray<TUint>& CFdcProxy::MfpoGetSupportedLanguagesL(TUint aDeviceId) |
460 const RArray<TUint>& CFdcProxy::MfpoGetSupportedLanguagesL(TUint aDeviceId) |
403 { |
461 { |
404 LOG_FUNC |
462 OstTraceFunctionEntry0( CFDCPROXY_MFPOGETSUPPORTEDLANGUAGESL_ENTRY ); |
405 |
463 |
406 CheckDeviceIdL(aDeviceId); |
464 CheckDeviceIdL(aDeviceId); |
407 |
465 |
408 return iFdf.GetSupportedLanguagesL(aDeviceId); |
466 return iFdf.GetSupportedLanguagesL(aDeviceId); |
409 } |
467 } |
410 |
468 |
411 |
469 |
412 TInt CFdcProxy::MfpoGetManufacturerStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
470 TInt CFdcProxy::MfpoGetManufacturerStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
413 { |
471 { |
414 LOG_FUNC |
472 OstTraceFunctionEntry0( CFDCPROXY_MFPOGETMANUFACTURERSTRINGDESCRIPTOR_ENTRY ); |
415 |
473 |
416 TRAPD(err, |
474 TRAPD(err, |
417 CheckDeviceIdL(aDeviceId); |
475 CheckDeviceIdL(aDeviceId); |
418 iFdf.GetManufacturerStringDescriptorL(aDeviceId, aLangId, aString) |
476 iFdf.GetManufacturerStringDescriptorL(aDeviceId, aLangId, aString) |
419 ); |
477 ); |
420 |
478 |
421 #ifdef __FLOG_ACTIVE |
|
422 if ( !err ) |
479 if ( !err ) |
423 { |
480 { |
424 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
481 OstTraceExt1( TRACE_NORMAL, CFDCPROXY_MFPOGETMANUFACTURERSTRINGDESCRIPTOR, "aString = \"%S\"", aString ); |
425 } |
482 } |
426 #endif |
483 |
427 LOGTEXT2(_L8("\terr = %d"), err); |
484 OstTrace1( TRACE_NORMAL, CFDCPROXY_MFPOGETMANUFACTURERSTRINGDESCRIPTOR_DUP1, "err = %d", err ); |
|
485 |
|
486 OstTraceFunctionExit0( CFDCPROXY_MFPOGETMANUFACTURERSTRINGDESCRIPTOR_EXIT ); |
428 return err; |
487 return err; |
429 } |
488 } |
430 |
489 |
431 |
490 |
432 TInt CFdcProxy::MfpoGetProductStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
491 TInt CFdcProxy::MfpoGetProductStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
433 { |
492 { |
434 LOG_FUNC |
493 OstTraceFunctionEntry0( CFDCPROXY_MFPOGETPRODUCTSTRINGDESCRIPTOR_ENTRY ); |
435 |
494 |
436 TRAPD(err, |
495 TRAPD(err, |
437 CheckDeviceIdL(aDeviceId); |
496 CheckDeviceIdL(aDeviceId); |
438 iFdf.GetProductStringDescriptorL(aDeviceId, aLangId, aString) |
497 iFdf.GetProductStringDescriptorL(aDeviceId, aLangId, aString) |
439 ); |
498 ); |
440 |
499 |
441 #ifdef __FLOG_ACTIVE |
|
442 if ( !err ) |
500 if ( !err ) |
443 { |
501 { |
444 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
502 OstTraceExt1( TRACE_NORMAL, CFDCPROXY_MFPOGETPRODUCTSTRINGDESCRIPTOR, "aString = \"%S\"", aString ); |
445 } |
503 } |
446 #endif |
504 |
447 LOGTEXT2(_L8("\terr = %d"), err); |
505 OstTrace1( TRACE_NORMAL, CFDCPROXY_MFPOGETPRODUCTSTRINGDESCRIPTOR_DUP1, "err = %d", err ); |
|
506 OstTraceFunctionExit0( CFDCPROXY_MFPOGETPRODUCTSTRINGDESCRIPTOR_EXIT ); |
448 return err; |
507 return err; |
449 } |
508 } |
450 |
509 |
451 |
510 |
452 TInt CFdcProxy::MfpoGetSerialNumberStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
511 TInt CFdcProxy::MfpoGetSerialNumberStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString) |
453 { |
512 { |
454 LOG_FUNC |
513 OstTraceFunctionEntry0( CFDCPROXY_MFPOGETSERIALNUMBERSTRINGDESCRIPTOR_ENTRY ); |
455 |
514 |
456 TRAPD(err, |
515 TRAPD(err, |
457 CheckDeviceIdL(aDeviceId); |
516 CheckDeviceIdL(aDeviceId); |
458 iFdf.GetSerialNumberStringDescriptorL(aDeviceId, aLangId, aString) |
517 iFdf.GetSerialNumberStringDescriptorL(aDeviceId, aLangId, aString) |
459 ); |
518 ); |
460 |
519 |
461 #ifdef __FLOG_ACTIVE |
|
462 if ( !err ) |
520 if ( !err ) |
463 { |
521 { |
464 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
522 OstTraceExt1( TRACE_NORMAL, CFDCPROXY_MFPOGETSERIALNUMBERSTRINGDESCRIPTOR, "aString = \"%S\"", aString ); |
465 } |
523 } |
466 #endif |
524 |
467 LOGTEXT2(_L8("\terr = %d"), err); |
525 OstTrace1( TRACE_NORMAL, CFDCPROXY_MFPOGETSERIALNUMBERSTRINGDESCRIPTOR_DUP1, "err = %d", err ); |
|
526 OstTraceFunctionExit0( CFDCPROXY_MFPOGETSERIALNUMBERSTRINGDESCRIPTOR_EXIT ); |
468 return err; |
527 return err; |
469 } |
528 } |
470 |
529 |
471 /** |
530 /** |
472 Leaves with KErrNotFound if aDeviceId is not on our array of device IDs. |
531 Leaves with KErrNotFound if aDeviceId is not on our array of device IDs. |
473 Used to ensure that FDCs can only request strings etc from devices that are |
532 Used to ensure that FDCs can only request strings etc from devices that are |
474 'their business'. |
533 'their business'. |
475 */ |
534 */ |
476 void CFdcProxy::CheckDeviceIdL(TUint aDeviceId) const |
535 void CFdcProxy::CheckDeviceIdL(TUint aDeviceId) const |
477 { |
536 { |
478 LOG_FUNC |
537 OstTraceFunctionEntry0( CFDCPROXY_CHECKDEVICEIDL_ENTRY ); |
479 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
538 OstTrace1( TRACE_NORMAL, CFDCPROXY_CHECKDEVICEIDL, "aDeviceId = %d", aDeviceId ); |
480 |
539 |
481 TBool found = EFalse; |
540 TBool found = EFalse; |
482 const TUint count = iDeviceIds.Count(); |
541 const TUint count = iDeviceIds.Count(); |
483 for ( TUint i = 0 ; i < count ; ++i ) |
542 for ( TUint i = 0 ; i < count ; ++i ) |
484 { |
543 { |
485 if ( iDeviceIds[i] == aDeviceId ) |
544 if ( iDeviceIds[i] == aDeviceId ) |