0
|
1 |
// Copyright (c) 2004-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
|
286
|
15 |
//
|
0
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalTechnology
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <e32svr.h>
|
|
24 |
#include "usbmsshared.h"
|
|
25 |
#include "cusbmassstorageserver.h"
|
|
26 |
#include "cusbmassstoragesession.h"
|
286
|
27 |
#include "drivemanager.h"
|
0
|
28 |
#include "cusbmassstoragecontroller.h"
|
286
|
29 |
#include "smassstorage.h"
|
|
30 |
#include "usbmsserversecuritypolicy.h"
|
0
|
31 |
|
286
|
32 |
#include "OstTraceDefinitions.h"
|
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
34 |
#include "cusbmassstorageserverTraces.h"
|
|
35 |
#endif
|
|
36 |
|
0
|
37 |
/**
|
|
38 |
Constructs a USB mass storage Server
|
286
|
39 |
|
0
|
40 |
@return a pointer to CUsbMassStorageServer object
|
|
41 |
*/
|
|
42 |
CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController)
|
286
|
43 |
{
|
|
44 |
CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
|
|
45 |
CleanupStack::PushL(r);
|
|
46 |
r->StartL(KUsbMsServerName);
|
|
47 |
return r;
|
|
48 |
}
|
0
|
49 |
|
|
50 |
/**
|
|
51 |
Destructor
|
|
52 |
*/
|
|
53 |
CUsbMassStorageServer::~CUsbMassStorageServer()
|
286
|
54 |
{
|
0
|
55 |
// Intentionally left blank
|
286
|
56 |
}
|
0
|
57 |
|
|
58 |
|
|
59 |
/**
|
|
60 |
Constructor
|
|
61 |
|
|
62 |
@param aController a USB mass storage controller reference
|
|
63 |
*/
|
|
64 |
CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController)
|
286
|
65 |
: CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
|
0
|
66 |
, iController(aController)
|
286
|
67 |
{
|
|
68 |
OstTraceFunctionEntry0(CUSBMASSSTORAGESERVER_100);
|
|
69 |
}
|
0
|
70 |
|
|
71 |
/**
|
|
72 |
Create a new session on this server
|
286
|
73 |
|
|
74 |
@param &aVersion Version of client
|
|
75 |
@return A pointer to a session object to be used for the client
|
0
|
76 |
*/
|
|
77 |
CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
|
286
|
78 |
{
|
|
79 |
OstTraceFunctionEntry0(CUSBMASSSTORAGESERVER_110);
|
|
80 |
TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
|
|
81 |
if (!User::QueryVersionSupported(v, aVersion))
|
|
82 |
User::Leave(KErrNotSupported);
|
0
|
83 |
|
286
|
84 |
CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
|
|
85 |
CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
|
|
86 |
return sess;
|
|
87 |
}
|
0
|
88 |
|
|
89 |
|
|
90 |
/**
|
|
91 |
Inform the client there has been an error.
|
286
|
92 |
|
|
93 |
@param aError The error that has occurred
|
0
|
94 |
*/
|
|
95 |
void CUsbMassStorageServer::Error(TInt aError)
|
286
|
96 |
{
|
|
97 |
OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_120,
|
|
98 |
"aError=%d", aError);
|
|
99 |
Message().Complete(aError);
|
|
100 |
ReStart();
|
|
101 |
}
|
0
|
102 |
|
|
103 |
/**
|
|
104 |
Increment the open session count (iSessionCount) by one.
|
286
|
105 |
|
|
106 |
@post the number of open sessions is incremented by one
|
0
|
107 |
*/
|
|
108 |
void CUsbMassStorageServer::IncrementSessionCount()
|
286
|
109 |
{
|
|
110 |
OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_130,
|
|
111 |
"SessionCount=%d", iSessionCount);
|
|
112 |
__ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
|
|
113 |
++iSessionCount;
|
|
114 |
}
|
0
|
115 |
|
|
116 |
/**
|
|
117 |
Decrement the open session count (iSessionCount) by one.
|
286
|
118 |
|
|
119 |
@post the number of open sessions is decremented by one
|
0
|
120 |
*/
|
|
121 |
void CUsbMassStorageServer::DecrementSessionCount()
|
286
|
122 |
{
|
|
123 |
OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_140,
|
|
124 |
"SessionCount=%d", iSessionCount);
|
|
125 |
__ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
|
|
126 |
--iSessionCount;
|
|
127 |
}
|
0
|
128 |
|