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". |
33 |
33 |
34 #include "msmanclientserver.h" |
34 #include "msmanclientserver.h" |
35 #include "cusbotgserver.h" |
35 #include "cusbotgserver.h" |
36 #include "cusbotgsession.h" |
36 #include "cusbotgsession.h" |
37 |
37 |
38 #include "tmslog.h" |
|
39 |
|
40 CUsbOtgServer* CUsbOtgServer::NewLC() |
38 CUsbOtgServer* CUsbOtgServer::NewLC() |
41 { |
39 { |
42 __MSFNSLOG |
40 CUsbOtgServer* r = new (ELeave) CUsbOtgServer(); |
43 CUsbOtgServer* r = new (ELeave) CUsbOtgServer(); |
41 CleanupStack::PushL(r); |
44 CleanupStack::PushL(r); |
|
45 r->ConstructL(); |
42 r->ConstructL(); |
46 return r; |
43 return r; |
47 } |
44 } |
48 |
45 |
49 |
46 |
50 CUsbOtgServer::CUsbOtgServer() |
47 CUsbOtgServer::CUsbOtgServer() |
51 : CServer2(EPriorityLow) |
48 : CServer2(EPriorityLow) |
52 { |
49 { |
53 __MSFNSLOG |
50 } |
54 } |
|
55 |
51 |
56 |
52 |
57 void CUsbOtgServer::ConstructL() |
53 void CUsbOtgServer::ConstructL() |
58 { |
54 { |
59 __MSFNSLOG |
55 iUsbOtg = CUsbOtg::NewL(); |
60 |
56 StartL(KUsbOtgServerName); |
61 iUsbOtg = CUsbOtg::NewL(); |
|
62 StartL(KUsbOtgServerName); |
|
63 } |
57 } |
64 |
58 |
65 |
59 |
66 CUsbOtgServer::~CUsbOtgServer() |
60 CUsbOtgServer::~CUsbOtgServer() |
67 { |
61 { |
68 __MSFNSLOG |
|
69 delete iUsbOtg; |
62 delete iUsbOtg; |
70 } |
63 } |
71 |
64 |
72 |
65 |
73 CSession2* CUsbOtgServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const |
66 CSession2* CUsbOtgServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const |
74 { |
67 { |
75 __MSFNSLOG |
68 TVersion v(KUsbOtgSrvMajorVersionNumber, KUsbOtgSrvMinorVersionNumber, KUsbOtgSrvBuildVersionNumber); |
76 TVersion v(KUsbOtgSrvMajorVersionNumber, KUsbOtgSrvMinorVersionNumber, KUsbOtgSrvBuildVersionNumber); |
|
77 |
69 |
78 if (!User::QueryVersionSupported(v, aVersion)) |
70 if (!User::QueryVersionSupported(v, aVersion)) |
79 User::Leave(KErrNotSupported); |
71 User::Leave(KErrNotSupported); |
80 |
72 |
81 CUsbOtgSession* session = CUsbOtgSession::NewL(); |
73 CUsbOtgSession* session = CUsbOtgSession::NewL(); |
82 |
74 |
83 return session; |
75 return session; |
84 } |
76 } |
85 |
77 |
86 |
78 |
87 |
79 |
88 TInt CUsbOtgServer::RunError(TInt aError) |
80 TInt CUsbOtgServer::RunError(TInt aError) |
89 { |
81 { |
90 __MSFNSLOG |
82 Message().Complete(aError); |
91 |
83 ReStart(); |
92 Message().Complete(aError); |
|
93 ReStart(); |
|
94 return KErrNone; |
84 return KErrNone; |
95 } |
85 } |
96 |
86 |
97 |
87 |
98 void CUsbOtgServer::AddSession() |
88 void CUsbOtgServer::AddSession() |
99 { |
89 { |
100 __MSFNSLOG |
|
101 ++iSessionCount; |
90 ++iSessionCount; |
102 } |
91 } |
103 |
92 |
104 void CUsbOtgServer::RemoveSession() |
93 void CUsbOtgServer::RemoveSession() |
105 { |
94 { |
106 __MSFNSLOG |
|
107 if (--iSessionCount == 0) |
95 if (--iSessionCount == 0) |
108 { |
96 { |
109 User::After(1000000); |
97 User::After(1000000); |
110 CActiveScheduler::Stop(); |
98 CActiveScheduler::Stop(); |
111 } |
99 } |