|
1 /* |
|
2 * Copyright (c) 2003-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Sub Session Command handler notify. |
|
15 * The stub version of this file can be found from file |
|
16 * CPhSrvSubSessionCommandHandlerNotifyStub.cpp |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "CPhSrvSubSessionCommandHandlerNotify.h" |
|
24 #include "CPhSrvSession.h" |
|
25 #include "CPhSrvServer.h" |
|
26 #include <PhCltTypes.h> |
|
27 #include "MPhSrvComHandNegotiators.h" |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CPhSrvSubSessionCommandHandlerNotify::CPhSrvSubSessionCommandHandlerNotify |
|
37 // |
|
38 // Constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CPhSrvSubSessionCommandHandlerNotify::CPhSrvSubSessionCommandHandlerNotify( |
|
42 CPhSrvSession& aSession ) |
|
43 : CPhSrvSubSessionBase( aSession, EPhSrvSubSessionTypeComHandNotify ) |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CPhSrvSubSessionCommandHandlerNotify::NewL |
|
50 // |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CPhSrvSubSessionBase* |
|
55 CPhSrvSubSessionCommandHandlerNotify::NewL( |
|
56 CPhSrvSession& aSession ) |
|
57 { |
|
58 // Just to make sure that the destructor does not leave. |
|
59 aSession.PhoneServer().ComHandNegotiatorL(); |
|
60 |
|
61 CPhSrvSubSessionBase* self = |
|
62 new( ELeave ) CPhSrvSubSessionCommandHandlerNotify( aSession ); |
|
63 |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CPhSrvSubSessionCommandHandlerNotify::~CPhSrvSubSessionCommandHandlerNotify |
|
70 // |
|
71 // Destructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CPhSrvSubSessionCommandHandlerNotify::~CPhSrvSubSessionCommandHandlerNotify() |
|
75 { |
|
76 // Inform that we are not ready to process requests anymore. |
|
77 if ( PhoneSession().PhoneServer().IsComHandNegotiator() ) |
|
78 { |
|
79 PhoneSession(). |
|
80 PhoneServer(). |
|
81 ComHandNegotiator(). |
|
82 SetNegotiatorReadyRequestCancel( *this ); |
|
83 } |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CPhSrvSubSessionCommandHandlerNotify::PhSrvMessageDecoderCanProcessMessage |
|
89 // |
|
90 // Framework function. Returns ETrue for the op codes that |
|
91 // this subsession can handle. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 TBool |
|
95 CPhSrvSubSessionCommandHandlerNotify::PhSrvMessageDecoderCanProcessMessage( |
|
96 TInt aFunction ) |
|
97 { |
|
98 switch( aFunction ) |
|
99 { |
|
100 case EPhoneServerComHandNotifySubSessionClose: |
|
101 case EPhoneServerComHandNotifySubSessionComHandRequest: |
|
102 case EPhoneServerComHandNotifySubSessionComHandRequestCancel: |
|
103 case EPhoneServerComHandNotifySubSessionReportComHandResult: |
|
104 return ETrue; |
|
105 |
|
106 default: |
|
107 return EFalse; |
|
108 } |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CPhSrvSubSessionCommandHandlerNotify::PhSrvMessageProcessorHandleMessageL |
|
114 // |
|
115 // Framework function. Handle any op-codes here. |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CPhSrvSubSessionCommandHandlerNotify::PhSrvMessageProcessorHandleMessageL( |
|
119 const RMessage2& aMessage ) |
|
120 { |
|
121 switch( aMessage.Function() ) |
|
122 { |
|
123 case EPhoneServerComHandNotifySubSessionClose: |
|
124 CmdSubSessionClose( aMessage ); |
|
125 break; |
|
126 |
|
127 case EPhoneServerComHandNotifySubSessionComHandRequest: |
|
128 CmdSubSessionComHandNotifyRequestL( aMessage ); |
|
129 break; |
|
130 |
|
131 case EPhoneServerComHandNotifySubSessionComHandRequestCancel: |
|
132 CmdSubSessionComHandNotifyRequestCancelL( aMessage ); |
|
133 break; |
|
134 |
|
135 case EPhoneServerComHandNotifySubSessionReportComHandResult: |
|
136 CmdSubSessionComHandNotifyReportL( aMessage ); |
|
137 break; |
|
138 |
|
139 default: |
|
140 PhoneSession().PanicClient( |
|
141 aMessage, |
|
142 EPhCltServerInitiatedPanicInvalidRequest ); |
|
143 break; |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CPhSrvSubSessionCommandHandlerNotify::InitiatorMakeAsynchronousComHandRequest |
|
150 // |
|
151 // Called by the command handler negotiator when it wants this object to |
|
152 // initiate a command handler request (on behalf of the external interface). |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CPhSrvSubSessionCommandHandlerNotify:: |
|
156 InitiatorMakeAsynchronousComHandRequest( |
|
157 const TPhCltComHandCommandParameters& aParams ) |
|
158 { |
|
159 // Package up the data to send |
|
160 TPckgC< TPhCltComHandCommandParameters > |
|
161 comHandDetails( aParams ); |
|
162 |
|
163 // Write to command handler notifier's address space |
|
164 PhoneSession().Write( |
|
165 iPendingComHandRequestPointer, |
|
166 0, |
|
167 comHandDetails ); |
|
168 |
|
169 // Indicate that the command handler notifier should try to perform the |
|
170 // request. |
|
171 if ( !iPendingComHandRequestPointer.IsNull() ) |
|
172 { |
|
173 iPendingComHandRequestPointer.Complete( KErrNone ); |
|
174 } |
|
175 iHavePendingComHandRequestPointer = EFalse; |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CPhSrvSubSessionCommandHandlerNotify::InitiatorIsReadyToPerformRequest |
|
181 // |
|
182 // Does this session have a pending request? |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TBool CPhSrvSubSessionCommandHandlerNotify::InitiatorIsReadyToPerformRequest() |
|
186 const |
|
187 { |
|
188 return iHavePendingComHandRequestPointer; |
|
189 } |
|
190 |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionClose |
|
195 // |
|
196 // Close the sub-session. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionClose( |
|
200 const RMessage2& aMessage ) |
|
201 { |
|
202 PhoneSession().CloseSubSession( aMessage ); |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionComHandNotifyRequestL |
|
208 // |
|
209 // Handle command handler notifier's request. |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionComHandNotifyRequestL( |
|
213 const RMessage2& aMessage ) |
|
214 { |
|
215 // Update our pending request pointer if it's not already set |
|
216 if ( iHavePendingComHandRequestPointer ) |
|
217 { |
|
218 PhoneSession().PanicClient( |
|
219 aMessage, |
|
220 EPhCltServerInitiatedPanicRequestAlreadyActive ); |
|
221 } |
|
222 else |
|
223 { |
|
224 iPendingComHandRequestPointer = aMessage; |
|
225 iHavePendingComHandRequestPointer = ETrue; |
|
226 |
|
227 // The phone app engine is ready to process a command handler request. |
|
228 // Tell the negotiator that we're ready to process any pending |
|
229 // requests. |
|
230 MPhSrvComHandNegotiator& comHandNegotiator = |
|
231 PhoneSession().PhoneServer().ComHandNegotiatorL(); |
|
232 comHandNegotiator.SetNegotiatorReadyRequestL( *this ); |
|
233 } |
|
234 } |
|
235 |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CPhSrvSubSessionCommandHandlerNotify:: |
|
239 // CmdSubSessionComHandNotifyRequestCancelL |
|
240 // |
|
241 // Handle command handler notifier's request cancel. |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CPhSrvSubSessionCommandHandlerNotify:: |
|
245 CmdSubSessionComHandNotifyRequestCancelL( |
|
246 const RMessage2& aMessage ) |
|
247 { |
|
248 if ( iHavePendingComHandRequestPointer ) |
|
249 { |
|
250 iPendingComHandRequestPointer.Complete( KErrCancel ); |
|
251 iHavePendingComHandRequestPointer = EFalse; |
|
252 } |
|
253 |
|
254 aMessage.Complete( KErrNone ); |
|
255 } |
|
256 |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionComHandNotifyReportL |
|
260 // |
|
261 // Tell the result of the request execution to the command handler client. |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CPhSrvSubSessionCommandHandlerNotify::CmdSubSessionComHandNotifyReportL( |
|
265 const RMessage2& aMessage ) |
|
266 { |
|
267 // Get result |
|
268 const TPhCltPhoneResults result = |
|
269 static_cast< TPhCltPhoneResults >( aMessage.Int0() ); |
|
270 |
|
271 // Tell command handler negotiator of result |
|
272 MPhSrvComHandNegotiator& comHandNegotiator = |
|
273 PhoneSession().PhoneServer().ComHandNegotiatorL(); |
|
274 comHandNegotiator.SetNegotiatorAttemptedRequestResponseValue( result ); |
|
275 |
|
276 // Complete the request |
|
277 aMessage.Complete( KErrNone ); |
|
278 } |
|
279 |
|
280 |
|
281 // End of File |