1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
36 |
36 |
37 #include "msmanclientserver.h" |
37 #include "msmanclientserver.h" |
38 #include "cusbhostserver.h" |
38 #include "cusbhostserver.h" |
39 #include "cusbhostsession.h" |
39 #include "cusbhostsession.h" |
40 |
40 |
41 #include "tmslog.h" |
|
42 |
|
43 CUsbHostServer* CUsbHostServer::NewLC() |
41 CUsbHostServer* CUsbHostServer::NewLC() |
44 { |
42 { |
45 __MSFNSLOG |
43 CUsbHostServer* r = new (ELeave) CUsbHostServer(); |
46 CUsbHostServer* r = new (ELeave) CUsbHostServer(); |
44 CleanupStack::PushL(r); |
47 CleanupStack::PushL(r); |
|
48 r->ConstructL(); |
45 r->ConstructL(); |
49 return r; |
46 return r; |
50 } |
47 } |
51 |
48 |
52 |
49 |
53 CUsbHostServer::CUsbHostServer() |
50 CUsbHostServer::CUsbHostServer() |
54 : CServer2(EPriorityLow) |
51 : CServer2(EPriorityLow) |
55 { |
52 { |
56 __MSFNSLOG |
53 } |
57 } |
|
58 |
54 |
59 |
55 |
60 void CUsbHostServer::ConstructL() |
56 void CUsbHostServer::ConstructL() |
61 { |
57 { |
62 __MSFNSLOG |
|
63 iUsbHost = CUsbHost::NewL(); |
58 iUsbHost = CUsbHost::NewL(); |
64 StartL(KUsbHostServerName); |
59 StartL(KUsbHostServerName); |
65 } |
60 } |
66 |
61 |
67 |
62 |
68 CUsbHostServer::~CUsbHostServer() |
63 CUsbHostServer::~CUsbHostServer() |
69 { |
64 { |
70 __MSFNSLOG |
|
71 delete iUsbHost; |
65 delete iUsbHost; |
72 } |
66 } |
73 |
67 |
74 |
68 |
75 CSession2* CUsbHostServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const |
69 CSession2* CUsbHostServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const |
76 { |
70 { |
77 __MSFNSLOG |
71 TVersion v(KUsbHostSrvMajorVersionNumber, KUsbHostSrvMinorVersionNumber, KUsbHostSrvBuildVersionNumber); |
78 TVersion v(KUsbHostSrvMajorVersionNumber, KUsbHostSrvMinorVersionNumber, KUsbHostSrvBuildVersionNumber); |
|
79 |
72 |
80 if (!User::QueryVersionSupported(v, aVersion)) |
73 if (!User::QueryVersionSupported(v, aVersion)) |
81 User::Leave(KErrNotSupported); |
74 User::Leave(KErrNotSupported); |
82 |
75 |
83 CUsbHostSession* session = CUsbHostSession::NewL(); |
76 CUsbHostSession* session = CUsbHostSession::NewL(); |
84 |
77 |
85 return session; |
78 return session; |
86 } |
79 } |
87 |
80 |
88 |
81 |
89 |
82 |
90 TInt CUsbHostServer::RunError(TInt aError) |
83 TInt CUsbHostServer::RunError(TInt aError) |
91 { |
84 { |
92 __MSFNSLOG |
85 Message().Complete(aError); |
93 |
86 ReStart(); |
94 Message().Complete(aError); |
|
95 ReStart(); |
|
96 return KErrNone; |
87 return KErrNone; |
97 } |
88 } |
98 |
89 |
99 |
90 |
100 void CUsbHostServer::AddSession() |
91 void CUsbHostServer::AddSession() |
101 { |
92 { |
102 __MSFNSLOG |
|
103 ++iSessionCount; |
93 ++iSessionCount; |
104 } |
94 } |
105 |
95 |
106 void CUsbHostServer::RemoveSession() |
96 void CUsbHostServer::RemoveSession() |
107 { |
97 { |
108 __MSFNSLOG |
|
109 if (--iSessionCount == 0) |
98 if (--iSessionCount == 0) |
110 { |
99 { |
111 User::After(1000000); |
100 User::After(1000000); |
112 CActiveScheduler::Stop(); |
101 CActiveScheduler::Stop(); |
113 } |
102 } |