1 /* |
1 /* |
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
18 |
18 |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include "SrcsServiceManager.h" |
21 #include "SrcsServiceManager.h" |
22 #include "debug.h" |
22 #include "debug.h" |
|
23 #include <e32property.h> |
|
24 #include "obexservicemanprop.h" |
23 |
25 |
24 |
26 |
25 // CONSTANTS |
27 // CONSTANTS |
26 |
28 |
27 // The granularity of the array used to hold BT, IrDA and USB connnection objects |
29 // The granularity of the array used to hold BT, IrDA and USB connnection objects |
28 static const TInt KConnectionArrayGranularity = 4; |
30 static const TInt KConnectionArrayGranularity = 4; |
29 |
31 |
|
32 const TUint32 KObexSMSid = {0x101F7C87}; |
|
33 static _LIT_SECURITY_POLICY_S0(KObexSMOnlyPolicy,KObexSMSid); |
|
34 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
35 |
30 // ================= MEMBER FUNCTIONS ======================= |
36 // ================= MEMBER FUNCTIONS ======================= |
31 |
37 |
32 |
38 |
33 // --------------------------------------------------------- |
39 // --------------------------------------------------------- |
34 // C++ default constructor can NOT contain any code, that |
40 // C++ default constructor can NOT contain any code, that |
44 // Destructor |
50 // Destructor |
45 // --------------------------------------------------------- |
51 // --------------------------------------------------------- |
46 // |
52 // |
47 CSrcsServiceManager::~CSrcsServiceManager() |
53 CSrcsServiceManager::~CSrcsServiceManager() |
48 { |
54 { |
49 Cancel(); |
55 Cancel(); |
|
56 RProperty::Delete(KUidObexSMCategory, KObexSMPostInitErrorProperty); |
50 if ( iBTConnectionArray ) |
57 if ( iBTConnectionArray ) |
51 { |
58 { |
52 // Cleanup the array |
59 // Cleanup the array |
53 iBTConnectionArray->ResetAndDestroy(); |
60 iBTConnectionArray->ResetAndDestroy(); |
54 } |
61 } |
93 void CSrcsServiceManager::ConstructL() |
100 void CSrcsServiceManager::ConstructL() |
94 { |
101 { |
95 iBTConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
102 iBTConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
96 iUSBConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
103 iUSBConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
97 iIrDAConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
104 iIrDAConnectionArray = new(ELeave) CArrayPtrFlat<CSrcsTransport>(KConnectionArrayGranularity); |
|
105 |
|
106 TInt err = RProperty::Define(KUidObexSMCategory, KObexSMPostInitErrorProperty, RProperty::EInt, KAllowAllPolicy, KObexSMOnlyPolicy); |
|
107 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
108 { |
|
109 User::LeaveIfError(err); |
|
110 } |
|
111 (void)RProperty::Set(KUidObexSMCategory,KObexSMPostInitErrorProperty,KErrNone); |
98 } |
112 } |
99 |
113 |
100 // --------------------------------------------------------- |
114 // --------------------------------------------------------- |
101 // ManagerServicesL |
115 // ManagerServicesL |
102 // Method to manage service controllers on all supported transports. |
116 // Method to manage service controllers on all supported transports. |
130 void CSrcsServiceManager::DoManageServices(TSrcsTransport aTransport, TBool aState, MObexSMRequestObserver* aObserver, |
144 void CSrcsServiceManager::DoManageServices(TSrcsTransport aTransport, TBool aState, MObexSMRequestObserver* aObserver, |
131 const RMessage2& aMessage) |
145 const RMessage2& aMessage) |
132 { |
146 { |
133 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: DoManageServices")); |
147 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: DoManageServices")); |
134 iObserver=aObserver; |
148 iObserver=aObserver; |
135 iMessage=aMessage; |
149 iMessage=aMessage; |
|
150 iTransportType = aTransport; |
|
151 iTransportState = aState; |
136 TRAPD(error,RealDoManageServiceL(aTransport,aState)); |
152 TRAPD(error,RealDoManageServiceL(aTransport,aState)); |
137 if (error != KErrNone) |
153 if (error != KErrNone) |
138 { |
154 { |
139 iErrorState=error; |
155 iErrorState=error; |
140 } |
156 } |
150 // |
166 // |
151 void CSrcsServiceManager::RunL() |
167 void CSrcsServiceManager::RunL() |
152 { |
168 { |
153 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL")); |
169 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL")); |
154 iObserver->RequestCompleted(iMessage,iStatus.Int()); |
170 iObserver->RequestCompleted(iMessage,iStatus.Int()); |
|
171 |
|
172 // If the transport is being turned on, launch post-initialization routine |
|
173 // for appropriate service controllers array |
|
174 if (iTransportState) |
|
175 { |
|
176 switch(iTransportType) |
|
177 { |
|
178 case ESrcsTransportBT: |
|
179 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL(Bluetooth)")); |
|
180 PostInitialize(*iBTConnectionArray); |
|
181 break; |
|
182 case ESrcsTransportUSB: |
|
183 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL(USB)")); |
|
184 PostInitialize(*iUSBConnectionArray); |
|
185 break; |
|
186 case ESrcsTransportIrDA: |
|
187 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL(IrDA)")); |
|
188 PostInitialize(*iIrDAConnectionArray); |
|
189 break; |
|
190 default: |
|
191 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL. Transport not supported."))); |
|
192 break; |
|
193 } |
|
194 } |
|
195 else |
|
196 { |
|
197 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL() - transport is turned off")); |
|
198 } |
|
199 |
155 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL exit")); |
200 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RunL exit")); |
156 } |
201 } |
157 // --------------------------------------------------------- |
202 // --------------------------------------------------------- |
158 // RunErrorL |
203 // RunErrorL |
159 // --------------------------------------------------------- |
204 // --------------------------------------------------------- |
175 // --------------------------------------------------------- |
220 // --------------------------------------------------------- |
176 // |
221 // |
177 void CSrcsServiceManager::RealDoManageServiceL(TSrcsTransport aTransport, TBool aState) |
222 void CSrcsServiceManager::RealDoManageServiceL(TSrcsTransport aTransport, TBool aState) |
178 { |
223 { |
179 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL")); |
224 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL")); |
180 |
225 |
181 switch(aTransport) |
226 switch(aTransport) |
182 { |
227 { |
183 case ESrcsTransportBT: |
228 case ESrcsTransportBT: |
184 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Bluetooth)")); |
229 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Bluetooth)")); |
185 iTransportName.Set(KSrcsTransportBT); |
230 iTransportName.Set(KSrcsTransportBT); |
274 { |
319 { |
275 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL. Transport implementation not found."))); |
320 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL. Transport implementation not found."))); |
276 } |
321 } |
277 |
322 |
278 // Clean up |
323 // Clean up |
279 infoArrayTranport.ResetAndDestroy(); |
324 infoArrayTranport.ResetAndDestroy(); |
280 infoArrayServiceController.ResetAndDestroy(); |
325 infoArrayServiceController.ResetAndDestroy(); |
281 CleanupStack::PopAndDestroy(2); //infoArrayServiceController |
326 CleanupStack::PopAndDestroy(2); //infoArrayServiceController |
282 |
327 |
283 } |
328 } |
284 } |
329 } |
285 else // turn off service |
330 else // turn off service |
286 { |
331 { |
287 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Turn OFF)")); |
332 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Turn OFF)")); |
288 aTransport.ResetAndDestroy(); |
333 aTransport.ResetAndDestroy(); |
|
334 // This is a special case for USB transport. Clear errors. |
|
335 if (iTransportType == ESrcsTransportUSB) |
|
336 { |
|
337 (void)RProperty::Set(KUidObexSMCategory,KObexSMPostInitErrorProperty,KErrNone); |
|
338 } |
289 } |
339 } |
290 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL exit")); |
340 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL exit")); |
291 } |
341 } |
|
342 |
|
343 // ------------------------------------------------------------------------------------------ |
|
344 // CSrcsServiceManager |
|
345 // This function iterates through all detected service controllers for given transport |
|
346 // and calls post-initialization routines. |
|
347 // This solution is implemented mainly to satisfy tough timing requirements for USB transport |
|
348 // ------------------------------------------------------------------------------------------ |
|
349 // |
|
350 void CSrcsServiceManager::PostInitialize(CArrayPtr<CSrcsTransport> &aTransport) |
|
351 { |
|
352 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: PostInitialize()")); |
|
353 for (TInt i=0; i < aTransport.Count(); ++i) |
|
354 { |
|
355 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: PostInitilize. Processing Service Controller[%d]"), i)); |
|
356 TRAPD(err,aTransport[i]->PostInitializeL()); |
|
357 |
|
358 // This is a special case for USB transport to notify the USB OBEX class controller about any errors occured |
|
359 // at Post-Initialization stage. |
|
360 // Post-initialization is not implemented for Bluetooth and IrDA transports, so there is no need to notify. |
|
361 if ((err != KErrNone) && (iTransportType == ESrcsTransportUSB)) |
|
362 { |
|
363 (void)RProperty::Set(KUidObexSMCategory,KObexSMPostInitErrorProperty,err); |
|
364 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: PostInitialize. Transport[%d]::PostInitializeL() returned %d, exiting..."), i, err)); |
|
365 break; |
|
366 } |
|
367 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: PostInitialize() - DONE post initialization")); |
|
368 } |
|
369 FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: PostInitialize() exit")); |
|
370 } |
|
371 |
292 // End of file |
372 // End of file |