22 |
22 |
23 #include "msmmengine.h" |
23 #include "msmmengine.h" |
24 #include "msmmnodebase.h" |
24 #include "msmmnodebase.h" |
25 |
25 |
26 #include <usb/usblogger.h> |
26 #include <usb/usblogger.h> |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "msmmengineTraces.h" |
|
30 #endif |
27 |
31 |
28 #ifdef __FLOG_ACTIVE |
|
29 _LIT8(KLogComponent, "UsbHostMsmmServer"); |
|
30 #endif |
|
31 |
32 |
32 CMsmmEngine::~CMsmmEngine() |
33 CMsmmEngine::~CMsmmEngine() |
33 { |
34 { |
34 LOG_FUNC |
35 OstTraceFunctionEntry0( CMSMMENGINE_CMSMMENGINE_DES_ENTRY ); |
|
36 |
35 if (iDataEntrys) |
37 if (iDataEntrys) |
36 { |
38 { |
37 delete iDataEntrys; |
39 delete iDataEntrys; |
38 } |
40 } |
|
41 OstTraceFunctionExit0( CMSMMENGINE_CMSMMENGINE_DES_EXIT ); |
39 } |
42 } |
40 |
43 |
41 CMsmmEngine* CMsmmEngine::NewL() |
44 CMsmmEngine* CMsmmEngine::NewL() |
42 { |
45 { |
43 LOG_STATIC_FUNC_ENTRY |
46 OstTraceFunctionEntry0( CMSMMENGINE_NEWL_ENTRY ); |
|
47 |
44 CMsmmEngine* self = CMsmmEngine::NewLC(); |
48 CMsmmEngine* self = CMsmmEngine::NewLC(); |
45 CleanupStack::Pop(self); |
49 CleanupStack::Pop(self); |
46 |
50 |
|
51 OstTraceFunctionExit0( CMSMMENGINE_NEWL_EXIT ); |
47 return self; |
52 return self; |
48 } |
53 } |
49 |
54 |
50 CMsmmEngine* CMsmmEngine::NewLC() |
55 CMsmmEngine* CMsmmEngine::NewLC() |
51 { |
56 { |
52 LOG_STATIC_FUNC_ENTRY |
57 OstTraceFunctionEntry0( CMSMMENGINE_NEWLC_ENTRY ); |
|
58 |
53 CMsmmEngine* self = new (ELeave) CMsmmEngine(); |
59 CMsmmEngine* self = new (ELeave) CMsmmEngine(); |
54 CleanupStack::PushL(self); |
60 CleanupStack::PushL(self); |
55 self->ConstructL(); |
61 self->ConstructL(); |
56 |
62 |
|
63 OstTraceFunctionExit0( CMSMMENGINE_NEWLC_EXIT ); |
57 return self; |
64 return self; |
58 } |
65 } |
59 |
66 |
60 void CMsmmEngine::AddUsbMsDeviceL(const TUSBMSDeviceDescription& aDevice) |
67 void CMsmmEngine::AddUsbMsDeviceL(const TUSBMSDeviceDescription& aDevice) |
61 { |
68 { |
62 LOG_FUNC |
69 OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSDEVICEL_ENTRY ); |
|
70 |
63 TUsbMsDevice* device = SearchDevice(aDevice.iDeviceId); |
71 TUsbMsDevice* device = SearchDevice(aDevice.iDeviceId); |
64 if (!device) |
72 if (!device) |
65 { |
73 { |
66 device = new (ELeave) TUsbMsDevice(aDevice); |
74 device = new (ELeave) TUsbMsDevice(aDevice); |
67 iDataEntrys->AddChild(device); |
75 iDataEntrys->AddChild(device); |
68 } |
76 } |
|
77 OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSDEVICEL_EXIT ); |
69 } |
78 } |
70 |
79 |
71 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceL(TInt aDeviceId, TUint8 aInterfaceNumber, |
80 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceL(TInt aDeviceId, TUint8 aInterfaceNumber, |
72 TInt32 aInterfaceToken) |
81 TInt32 aInterfaceToken) |
73 { |
82 { |
74 LOG_FUNC |
83 OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSINTERFACEL_ENTRY ); |
|
84 |
75 TUsbMsDevice* device = SearchDevice(aDeviceId); |
85 TUsbMsDevice* device = SearchDevice(aDeviceId); |
76 if (!device) |
86 if (!device) |
77 { |
87 { |
78 User::Leave(KErrArgument); |
88 User::Leave(KErrArgument); |
79 } |
89 } |
85 } |
95 } |
86 else |
96 else |
87 { |
97 { |
88 interface = AddUsbMsInterfaceNodeL(device, aInterfaceNumber, aInterfaceToken); |
98 interface = AddUsbMsInterfaceNodeL(device, aInterfaceNumber, aInterfaceToken); |
89 } |
99 } |
|
100 OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSINTERFACEL_EXIT ); |
90 return interface; |
101 return interface; |
91 } |
102 } |
92 |
103 |
93 void CMsmmEngine::AddUsbMsLogicalUnitL(TInt aDeviceId, |
104 void CMsmmEngine::AddUsbMsLogicalUnitL(TInt aDeviceId, |
94 TInt aInterfaceNumber, TInt aLogicalUnitNumber, TText aDrive) |
105 TInt aInterfaceNumber, TInt aLogicalUnitNumber, TText aDrive) |
95 { |
106 { |
96 LOG_FUNC |
107 OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSLOGICALUNITL_ENTRY ); |
|
108 |
97 TUsbMsDevice* device = SearchDevice(aDeviceId); |
109 TUsbMsDevice* device = SearchDevice(aDeviceId); |
98 if (!device) |
110 if (!device) |
99 { |
111 { |
100 User::Leave(KErrArgument); // A proper device node can't be found |
112 User::Leave(KErrArgument); // A proper device node can't be found |
101 } |
113 } |
107 } |
119 } |
108 else |
120 else |
109 { |
121 { |
110 User::Leave(KErrArgument); // A proper interface node can't be found |
122 User::Leave(KErrArgument); // A proper interface node can't be found |
111 } |
123 } |
|
124 OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSLOGICALUNITL_EXIT ); |
112 } |
125 } |
113 |
126 |
114 void CMsmmEngine::RemoveUsbMsNode(TMsmmNodeBase* aNodeToBeRemoved) |
127 void CMsmmEngine::RemoveUsbMsNode(TMsmmNodeBase* aNodeToBeRemoved) |
115 { |
128 { |
116 LOG_FUNC |
129 OstTraceFunctionEntry0( CMSMMENGINE_REMOVEUSBMSNODE_ENTRY ); |
|
130 |
117 delete aNodeToBeRemoved; |
131 delete aNodeToBeRemoved; |
|
132 OstTraceFunctionExit0( CMSMMENGINE_REMOVEUSBMSNODE_EXIT ); |
118 } |
133 } |
119 |
134 |
120 TUsbMsDevice* CMsmmEngine::SearchDevice(TInt aDeviceId) const |
135 TUsbMsDevice* CMsmmEngine::SearchDevice(TInt aDeviceId) const |
121 { |
136 { |
122 LOG_FUNC |
137 OstTraceFunctionEntry0( CMSMMENGINE_SEARCHDEVICE_ENTRY ); |
|
138 |
123 return static_cast<TUsbMsDevice*>( |
139 return static_cast<TUsbMsDevice*>( |
124 iDataEntrys->SearchInChildren(aDeviceId)); |
140 iDataEntrys->SearchInChildren(aDeviceId)); |
125 } |
141 } |
126 |
142 |
127 TUsbMsInterface* CMsmmEngine::SearchInterface(TMsmmNodeBase* aDevice, |
143 TUsbMsInterface* CMsmmEngine::SearchInterface(TMsmmNodeBase* aDevice, |
128 TInt aInterfaceNumber) const |
144 TInt aInterfaceNumber) const |
129 { |
145 { |
130 LOG_FUNC |
146 OstTraceFunctionEntry0( CMSMMENGINE_SEARCHINTERFACE_ENTRY ); |
|
147 |
131 return static_cast<TUsbMsInterface*>( |
148 return static_cast<TUsbMsInterface*>( |
132 aDevice->SearchInChildren(aInterfaceNumber)); |
149 aDevice->SearchInChildren(aInterfaceNumber)); |
133 } |
150 } |
134 |
151 |
135 CMsmmEngine::CMsmmEngine() |
152 CMsmmEngine::CMsmmEngine() |
136 { |
153 { |
137 LOG_FUNC |
154 OstTraceFunctionEntry0( CMSMMENGINE_CMSMMENGINE_CONS_ENTRY ); |
|
155 |
138 } |
156 } |
139 |
157 |
140 void CMsmmEngine::ConstructL() |
158 void CMsmmEngine::ConstructL() |
141 { |
159 { |
142 LOG_FUNC |
160 OstTraceFunctionEntry0( CMSMMENGINE_CONSTRUCTL_ENTRY ); |
|
161 |
143 // Create the root of the whole node tree |
162 // Create the root of the whole node tree |
144 iDataEntrys = new (ELeave) TMsmmNodeBase(0x0); |
163 iDataEntrys = new (ELeave) TMsmmNodeBase(0x0); |
|
164 OstTraceFunctionExit0( CMSMMENGINE_CONSTRUCTL_EXIT ); |
145 } |
165 } |
146 |
166 |
147 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceNodeL(TUsbMsDevice* iParent, |
167 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceNodeL(TUsbMsDevice* iParent, |
148 TInt aInterfaceNumber, TInt aInterfaceToken) |
168 TInt aInterfaceNumber, TInt aInterfaceToken) |
149 { |
169 { |
150 LOG_FUNC |
170 OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSINTERFACENODEL_ENTRY ); |
|
171 |
151 TUsbMsInterface* interface = new (ELeave) TUsbMsInterface( |
172 TUsbMsInterface* interface = new (ELeave) TUsbMsInterface( |
152 aInterfaceNumber, aInterfaceToken); |
173 aInterfaceNumber, aInterfaceToken); |
153 iParent->AddChild(interface); |
174 iParent->AddChild(interface); |
154 |
175 |
|
176 OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSINTERFACENODEL_EXIT ); |
155 return interface; |
177 return interface; |
156 } |
178 } |
157 |
179 |
158 TUsbMsLogicalUnit* CMsmmEngine::AddUsbMsLogicalUnitNodeL( |
180 TUsbMsLogicalUnit* CMsmmEngine::AddUsbMsLogicalUnitNodeL( |
159 TUsbMsInterface* iParent, TInt aLogicalUnitNumber, |
181 TUsbMsInterface* iParent, TInt aLogicalUnitNumber, |
160 TText aDrive) |
182 TText aDrive) |
161 { |
183 { |
162 LOG_FUNC |
184 OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSLOGICALUNITNODEL_ENTRY ); |
|
185 |
163 TUsbMsLogicalUnit* logicalUnit = new (ELeave) TUsbMsLogicalUnit( |
186 TUsbMsLogicalUnit* logicalUnit = new (ELeave) TUsbMsLogicalUnit( |
164 aLogicalUnitNumber, aDrive); |
187 aLogicalUnitNumber, aDrive); |
165 iParent->AddChild(logicalUnit); |
188 iParent->AddChild(logicalUnit); |
166 |
189 |
|
190 OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSLOGICALUNITNODEL_EXIT ); |
167 return logicalUnit; |
191 return logicalUnit; |
168 } |
192 } |
169 |
193 |
170 // End of file |
194 // End of file |