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