24 #include "fdfsession.h" |
24 #include "fdfsession.h" |
25 #include <usb/usblogger.h> |
25 #include <usb/usblogger.h> |
26 #include "utils.h" |
26 #include "utils.h" |
27 #include "fdfapi.h" |
27 #include "fdfapi.h" |
28 #include "fdf.h" |
28 #include "fdf.h" |
29 |
29 #include "OstTraceDefinitions.h" |
30 #ifdef __FLOG_ACTIVE |
30 #ifdef OST_TRACE_COMPILER_IN_USE |
31 _LIT8(KLogComponent, "fdf "); |
31 #include "fdfserverTraces.h" |
32 #endif |
32 #endif |
33 |
33 |
34 #ifdef _DEBUG |
34 #ifdef _DEBUG |
35 PANICCATEGORY("fdfsrv"); |
35 _LIT(KPanicCategory, "fdfsrv"); |
36 #endif |
36 #endif |
|
37 |
37 |
38 |
38 void CFdfServer::NewLC() |
39 void CFdfServer::NewLC() |
39 { |
40 { |
40 LOG_STATIC_FUNC_ENTRY |
41 OstTraceFunctionEntry0( CFDFSERVER_NEWLC_ENTRY ); |
41 |
42 |
42 CFdfServer* self = new(ELeave) CFdfServer; |
43 CFdfServer* self = new(ELeave) CFdfServer; |
43 CleanupStack::PushL(self); |
44 CleanupStack::PushL(self); |
44 // StartL is where the kernel checks that there isn't already an instance |
45 // StartL is where the kernel checks that there isn't already an instance |
45 // of the same server running, so do it before ConstructL. |
46 // of the same server running, so do it before ConstructL. |
46 self->StartL(KUsbFdfServerName); |
47 self->StartL(KUsbFdfServerName); |
47 self->ConstructL(); |
48 self->ConstructL(); |
|
49 OstTraceFunctionExit0( CFDFSERVER_NEWLC_EXIT ); |
48 } |
50 } |
49 |
51 |
50 CFdfServer::~CFdfServer() |
52 CFdfServer::~CFdfServer() |
51 { |
53 { |
52 LOG_FUNC |
54 OstTraceFunctionEntry0( CFDFSERVER_CFDFSERVER_DES_ENTRY ); |
|
55 |
53 |
56 |
54 delete iFdf; |
57 delete iFdf; |
|
58 OstTraceFunctionExit0( CFDFSERVER_CFDFSERVER_DES_EXIT ); |
55 } |
59 } |
56 |
60 |
57 CFdfServer::CFdfServer() |
61 CFdfServer::CFdfServer() |
58 : CServer2(CActive::EPriorityHigh) |
62 : CServer2(CActive::EPriorityHigh) |
59 { |
63 { |
60 } |
64 } |
61 |
65 |
62 void CFdfServer::ConstructL() |
66 void CFdfServer::ConstructL() |
63 { |
67 { |
64 LOG_FUNC |
68 OstTraceFunctionEntry0( CFDFSERVER_CONSTRUCTL_ENTRY ); |
65 |
69 |
66 iFdf = CFdf::NewL(); |
70 iFdf = CFdf::NewL(); |
|
71 OstTraceFunctionExit0( CFDFSERVER_CONSTRUCTL_EXIT ); |
67 } |
72 } |
68 |
73 |
69 CSession2* CFdfServer::NewSessionL(const TVersion& aVersion, |
74 CSession2* CFdfServer::NewSessionL(const TVersion& aVersion, |
70 const RMessage2& aMessage) const |
75 const RMessage2& aMessage) const |
71 { |
76 { |
72 LOG_LINE |
77 OstTraceFunctionEntry0( CFDFSERVER_NEWSESSIONL_ENTRY ); |
73 LOG_FUNC; |
78 OstTraceExt3( TRACE_NORMAL, CFDFSERVER_NEWSESSIONL, "aVersion = (%d,%d,%d)", aVersion.iMajor, aVersion.iMinor, aVersion.iBuild ); |
74 LOGTEXT4(_L8("\taVersion = (%d,%d,%d)"), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild); |
|
75 (void)aMessage; |
79 (void)aMessage; |
76 |
80 |
77 // Check if we already have a session open. |
81 // Check if we already have a session open. |
78 if ( iSession ) |
82 if ( iSession ) |
79 { |
83 { |
80 LEAVEL(KErrInUse); |
84 OstTrace0( TRACE_NORMAL, CFDFSERVER_NEWSESSIONL_DUP1, |
|
85 "Session in use"); |
|
86 User::Leave(KErrInUse); |
81 } |
87 } |
82 |
88 |
83 // In the production system, check the secure ID of the prospective |
89 // In the production system, check the secure ID of the prospective |
84 // client. It should be that of USBSVR. |
90 // client. It should be that of USBSVR. |
85 // For unit testing, don't check the SID of the connecting client (it will |
91 // For unit testing, don't check the SID of the connecting client (it will |
94 // use a _LIT_SECURITY_POLICY_S0 here. This is because (a) we emit our own |
100 // use a _LIT_SECURITY_POLICY_S0 here. This is because (a) we emit our own |
95 // diagnostic messages, and (b) we don't want configuring this security |
101 // diagnostic messages, and (b) we don't want configuring this security |
96 // check OFF to allow any client to pass and thereby break our |
102 // check OFF to allow any client to pass and thereby break our |
97 // architecture. |
103 // architecture. |
98 TInt error = ( aMessage.SecureId() == KUsbsvrSecureId ) ? KErrNone : KErrPermissionDenied; |
104 TInt error = ( aMessage.SecureId() == KUsbsvrSecureId ) ? KErrNone : KErrPermissionDenied; |
99 LEAVEIFERRORL(error); |
105 LEAVEIFERRORL(error,OstTrace0( TRACE_NORMAL, CFDFSERVER_NEWSESSIONL_DUP2, |
|
106 "SecureId error");); |
100 #endif // __TEST_FDF__ |
107 #endif // __TEST_FDF__ |
101 |
108 |
102 #endif // __OVER_DUMMYUSBDI__ |
109 #endif // __OVER_DUMMYUSBDI__ |
103 |
110 |
104 // Version number check... |
111 // Version number check... |
106 KUsbFdfSrvMinorVersionNumber, |
113 KUsbFdfSrvMinorVersionNumber, |
107 KUsbFdfSrvBuildNumber); |
114 KUsbFdfSrvBuildNumber); |
108 |
115 |
109 if ( !User::QueryVersionSupported(v, aVersion) ) |
116 if ( !User::QueryVersionSupported(v, aVersion) ) |
110 { |
117 { |
111 LEAVEL(KErrNotSupported); |
118 OstTrace0( TRACE_NORMAL, CFDFSERVER_NEWSESSIONL_DUP3, |
|
119 "Version not supported"); |
|
120 User::Leave(KErrNotSupported); |
112 } |
121 } |
113 |
122 |
114 CFdfServer* ncThis = const_cast<CFdfServer*>(this); |
123 CFdfServer* ncThis = const_cast<CFdfServer*>(this); |
115 ncThis->iSession = new(ELeave) CFdfSession(*iFdf, *ncThis); |
124 ncThis->iSession = new(ELeave) CFdfSession(*iFdf, *ncThis); |
116 ASSERT_DEBUG(ncThis->iFdf); |
125 if(!ncThis->iFdf) |
|
126 { |
|
127 OstTrace0( TRACE_FATAL, CFDFSERVER_NEWSESSIONL_DUP4,"ncThis->iFdf is empty"); |
|
128 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
129 } |
|
130 |
117 ncThis->iFdf->SetSession(iSession); |
131 ncThis->iFdf->SetSession(iSession); |
118 |
132 |
119 LOGTEXT2(_L8("\tiSession = 0x%08x"), iSession); |
133 OstTrace1( TRACE_NORMAL, CFDFSERVER_NEWSESSIONL_DUP5, "iSession = 0x%08x", iSession ); |
|
134 OstTraceFunctionExit0( CFDFSERVER_NEWSESSIONL_EXIT ); |
120 return iSession; |
135 return iSession; |
121 } |
136 } |
122 |
137 |
123 void CFdfServer::SessionClosed() |
138 void CFdfServer::SessionClosed() |
124 { |
139 { |
125 LOG_FUNC |
140 OstTraceFunctionEntry0( CFDFSERVER_SESSIONCLOSED_ENTRY ); |
126 |
141 |
127 ASSERT_DEBUG(iSession); |
142 if(!iSession) |
|
143 { |
|
144 OstTrace0( TRACE_FATAL, CFDFSERVER_SESSIONCLOSED,"Empty iSession" ); |
|
145 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
146 } |
|
147 |
128 iSession = NULL; |
148 iSession = NULL; |
129 iFdf->SetSession(NULL); |
149 iFdf->SetSession(NULL); |
130 |
150 |
131 LOGTEXT(_L8("\tno remaining sessions- shutting down")); |
151 OstTrace0( TRACE_NORMAL, CFDFSERVER_SESSIONCLOSED_DUP1, "no remaining sessions- shutting down" ); |
|
152 |
132 // This returns control to the server boilerplate in main.cpp. This |
153 // This returns control to the server boilerplate in main.cpp. This |
133 // destroys all the objects, which includes signalling device detachment |
154 // destroys all the objects, which includes signalling device detachment |
134 // to any extant FDCs. |
155 // to any extant FDCs. |
135 // The session object could perfectly well do this in its destructor but |
156 // The session object could perfectly well do this in its destructor but |
136 // it's arguably more clear for the server to do it as it's the server |
157 // it's arguably more clear for the server to do it as it's the server |
137 // that's created immediately before calling CActiveScheduler::Start in |
158 // that's created immediately before calling CActiveScheduler::Start in |
138 // main.cpp. |
159 // main.cpp. |
139 CActiveScheduler::Stop(); |
160 CActiveScheduler::Stop(); |
|
161 OstTraceFunctionExit0( CFDFSERVER_SESSIONCLOSED_EXIT ); |
140 } |
162 } |