78 |
77 |
79 CStsServer::~CStsServer() |
78 CStsServer::~CStsServer() |
80 { |
79 { |
81 iSessions.ResetAndDestroy(); |
80 iSessions.ResetAndDestroy(); |
82 CSts::Delete(iSts); |
81 CSts::Delete(iSts); |
83 REComSession::FinalClose(); |
|
84 } |
82 } |
85 |
83 |
86 CSession2* CStsServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
84 CSession2* CStsServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
87 { |
85 { |
88 if (aVersion.iMajor != KStsServerMajorVersion || aVersion.iMinor |
86 if (aVersion.iMajor != KStsServerMajorVersion || aVersion.iMinor |
89 != KStsServerMinorVersion || aVersion.iBuild != KStsServerBuild) |
87 != KStsServerMinorVersion || aVersion.iBuild != KStsServerBuild) |
90 { |
88 { |
91 User::Leave(KErrNotSupported); |
89 User::Leave(KErrNotSupported); |
92 } // end if |
90 } |
|
91 else |
|
92 { |
|
93 //TODO: Add trace here |
|
94 }// end if |
93 |
95 |
94 CStsServer& nonConstThis = *const_cast<CStsServer*> (this); |
96 CStsServer& nonConstThis = *const_cast<CStsServer*> (this); |
95 |
97 |
96 // Construct a new session, passing it a pointer to the server object. This function |
98 // Construct a new session, passing it a pointer to the server object. This function |
97 // is const, so the const-ness must be cast away from the this pointer. |
99 // is const, so the const-ness must be cast away from the this pointer. |
98 CSession2* returnValue = new (ELeave) CStsServerSession(nonConstThis, *iSts); |
100 CSession2* returnValue = new (ELeave) CStsServerSession(nonConstThis, |
|
101 *iSts); |
99 |
102 |
100 return returnValue; |
103 return returnValue; |
101 } |
104 } |
102 |
105 |
103 void CStsServer::AddSession(CStsServerSession* aSession) |
106 void CStsServer::AddSession(CStsServerSession* aSession) |
112 |
115 |
113 if (index != KErrNotFound) |
116 if (index != KErrNotFound) |
114 { |
117 { |
115 // Remove the session from the list of sessions. |
118 // Remove the session from the list of sessions. |
116 iSessions.Remove(index); |
119 iSessions.Remove(index); |
|
120 } |
|
121 else |
|
122 { |
|
123 //TODO: Add trace here |
117 } // end if |
124 } // end if |
118 |
125 |
119 if (iSessions.Count() == 0) |
126 if (iSessions.Count() == 0) |
120 { |
127 { |
121 // No more clients. Shutdown the server. |
128 // No more clients. Shutdown the server. |
123 } |
130 } |
124 } |
131 } |
125 |
132 |
126 // SERVER LAUNCHING FUNCTIONALITY |
133 // SERVER LAUNCHING FUNCTIONALITY |
127 |
134 |
128 EXPORT_C void CStsServer::RunServerL(bool aPerformProcessRendezvous, |
135 EXPORT_C void CStsServer::RunServerL() |
129 bool aPerformThreadRendezvous) |
|
130 { |
136 { |
131 // naming the server thread after the server helps to debug panics |
137 // naming the server thread after the server helps to debug panics |
132 User::LeaveIfError(User::RenameThread(KStsServerName)); |
138 User::LeaveIfError(User::RenameThread(KStsServerName)); |
133 |
139 |
134 // create and install the active scheduler |
140 // create and install the active scheduler |
137 CActiveScheduler::Install(scheduler); |
143 CActiveScheduler::Install(scheduler); |
138 |
144 |
139 // create the server (leave it on the cleanup stack) |
145 // create the server (leave it on the cleanup stack) |
140 CStsServer* server = CStsServer::NewLC(); |
146 CStsServer* server = CStsServer::NewLC(); |
141 |
147 |
142 // Initialisation complete, now signal the client, if requested. |
148 // Initialisation complete, now signal the client. |
143 |
149 RProcess::Rendezvous(KErrNone); |
144 if (aPerformProcessRendezvous) |
|
145 { |
|
146 RProcess::Rendezvous(KErrNone); |
|
147 } |
|
148 |
|
149 if (aPerformThreadRendezvous) |
|
150 { |
|
151 RThread::Rendezvous(KErrNone); |
|
152 } |
|
153 |
150 |
154 // Ready to run |
151 // Ready to run |
155 // Start wait loop, will return when server is shutdown |
152 // Start wait loop, will return when server is shutdown |
156 CActiveScheduler::Start(); |
153 CActiveScheduler::Start(); |
157 |
154 |