|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements a Symbian OS server that exposes the RUsbMassStorage API |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #include <e32svr.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 #include <d32usbdi_hubdriver.h> |
|
29 #include <d32otgdi.h> |
|
30 |
|
31 #include "usbtypes.h" |
|
32 |
|
33 #include "cusbhostao.h" |
|
34 #include "cusbhost.h" |
|
35 |
|
36 |
|
37 #include "msmanclientserver.h" |
|
38 #include "cusbhostserver.h" |
|
39 #include "cusbhostsession.h" |
|
40 |
|
41 #include "tmslog.h" |
|
42 |
|
43 CUsbHostServer* CUsbHostServer::NewLC() |
|
44 { |
|
45 __MSFNSLOG |
|
46 CUsbHostServer* r = new (ELeave) CUsbHostServer(); |
|
47 CleanupStack::PushL(r); |
|
48 r->ConstructL(); |
|
49 return r; |
|
50 } |
|
51 |
|
52 |
|
53 CUsbHostServer::CUsbHostServer() |
|
54 : CServer2(EPriorityLow) |
|
55 { |
|
56 __MSFNSLOG |
|
57 } |
|
58 |
|
59 |
|
60 void CUsbHostServer::ConstructL() |
|
61 { |
|
62 __MSFNSLOG |
|
63 iUsbHost = CUsbHost::NewL(); |
|
64 StartL(KUsbHostServerName); |
|
65 } |
|
66 |
|
67 |
|
68 CUsbHostServer::~CUsbHostServer() |
|
69 { |
|
70 __MSFNSLOG |
|
71 delete iUsbHost; |
|
72 } |
|
73 |
|
74 |
|
75 CSession2* CUsbHostServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const |
|
76 { |
|
77 __MSFNSLOG |
|
78 TVersion v(KUsbHostSrvMajorVersionNumber, KUsbHostSrvMinorVersionNumber, KUsbHostSrvBuildVersionNumber); |
|
79 |
|
80 if (!User::QueryVersionSupported(v, aVersion)) |
|
81 User::Leave(KErrNotSupported); |
|
82 |
|
83 CUsbHostSession* session = CUsbHostSession::NewL(); |
|
84 |
|
85 return session; |
|
86 } |
|
87 |
|
88 |
|
89 |
|
90 TInt CUsbHostServer::RunError(TInt aError) |
|
91 { |
|
92 __MSFNSLOG |
|
93 |
|
94 Message().Complete(aError); |
|
95 ReStart(); |
|
96 return KErrNone; |
|
97 } |
|
98 |
|
99 |
|
100 void CUsbHostServer::AddSession() |
|
101 { |
|
102 __MSFNSLOG |
|
103 ++iSessionCount; |
|
104 } |
|
105 |
|
106 void CUsbHostServer::RemoveSession() |
|
107 { |
|
108 __MSFNSLOG |
|
109 if (--iSessionCount == 0) |
|
110 { |
|
111 User::After(1000000); |
|
112 CActiveScheduler::Stop(); |
|
113 } |
|
114 } |