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