|
1 /* |
|
2 * Copyright (c) 2002-2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 #include "senlocaltransportplugin.h" |
|
29 |
|
30 #include <SenServiceConnection.h> // errorcode constants, like KErrSenNoEndpoint |
|
31 |
|
32 #include "msenprovider.h" |
|
33 #include "senhostletrequest.h" // internal Provider\inc |
|
34 #include "senhostletresponse.h" // internal Provider\inc |
|
35 |
|
36 #include "senidentifier.h" // internal Utils\inc |
|
37 #include "senidentifier.h" // internal Utils\inc |
|
38 #include "sendebug.h" // internal Utils\inc |
|
39 |
|
40 #include "senprovider.h" // internal Framework\inc |
|
41 #include "sensyncrequester.h" // internal Framework\inc |
|
42 #include <SenTransportProperties.h> // internal Framework\inc |
|
43 |
|
44 #include "msentransport.h" |
|
45 #include "msencoreservicemanager.h" // internal: Core\inc |
|
46 |
|
47 #include "senlayeredtransportproperties.h" |
|
48 #include "senhostletrequest.h" // internal Provider\inc |
|
49 #include "senguidgen.h" |
|
50 #include "senlogger.h" |
|
51 |
|
52 #include <RSenDocument.h> |
|
53 namespace |
|
54 { |
|
55 //Deleted to fix for compiler warning #177-D |
|
56 |
|
57 //const TInt maxThreadHeapSize(KMinHeapSize*256); |
|
58 |
|
59 void threadMainL(TAny* aPtr) |
|
60 { |
|
61 CSenLocalRequest* pRequest = (CSenLocalRequest*) aPtr; |
|
62 pRequest->ExecuteL(); |
|
63 TRequestStatus* status = &pRequest->iStatus; |
|
64 RThread owner; |
|
65 TInt error=owner.Open(pRequest->OwnerThreadId()); //CodeScannerWarnings |
|
66 if(error != KErrNone) //CodeScannerWarnings |
|
67 { |
|
68 } |
|
69 owner.RequestComplete(status, CSenLocalRequest::EDeliverResponse ); //iTransactionID ); |
|
70 // Go safely out of scope (will destroy this thread) |
|
71 } |
|
72 |
|
73 TInt threadFunction(TAny* aPtr) |
|
74 { |
|
75 CTrapCleanup* pCleanup = CTrapCleanup::New(); |
|
76 CActiveScheduler::Install(NULL); // remove one |
|
77 CActiveScheduler* pScheduler = new (ELeave) CActiveScheduler(); |
|
78 CActiveScheduler::Install(pScheduler); |
|
79 |
|
80 RSenDocument::ManualXmlEngineTlsAttachL(); |
|
81 |
|
82 TInt leaveCode(KErrNone); |
|
83 TRAP(leaveCode, threadMainL(aPtr)); |
|
84 |
|
85 RSenDocument::ManualXmlEngineTlsCleanup(); |
|
86 |
|
87 CActiveScheduler::Install(NULL); // uninstall scheduler |
|
88 delete pScheduler; |
|
89 delete pCleanup; |
|
90 |
|
91 return leaveCode; |
|
92 } |
|
93 } |
|
94 CSenLocalTransportPlugin* CSenLocalTransportPlugin::NewL(CSenTransportContext* apCtx) |
|
95 { |
|
96 CSenLocalTransportPlugin* pNew = NewLC(apCtx); |
|
97 CleanupStack::Pop(pNew); |
|
98 return pNew; |
|
99 } |
|
100 |
|
101 CSenLocalTransportPlugin* CSenLocalTransportPlugin::NewLC(CSenTransportContext* apCtx) |
|
102 { |
|
103 CSenLocalTransportPlugin* pNew = |
|
104 new (ELeave) CSenLocalTransportPlugin(apCtx); |
|
105 CleanupStack::PushL(pNew); |
|
106 pNew->ConstructL(); |
|
107 return pNew; |
|
108 } |
|
109 |
|
110 CSenLocalTransportPlugin::CSenLocalTransportPlugin(CSenTransportContext* apCtx) |
|
111 : CSenTransport(apCtx), |
|
112 ipRequester(NULL), |
|
113 iInvokedProvider(NULL), |
|
114 iStatusCode(0), |
|
115 iTransactionID(0), |
|
116 iRequestMap(ETrue, ETrue), |
|
117 ipTransportProperties(NULL) |
|
118 { |
|
119 } |
|
120 |
|
121 CSenLocalTransportPlugin::~CSenLocalTransportPlugin() |
|
122 { |
|
123 TLSLOG(KSenLocalTransportLogChannelBase,KMinLogLevel,_L("Log file closed.")); |
|
124 TLSLOG_CLOSE(KSenLocalTransportLogChannelBase); |
|
125 iRequestMap.Reset(); // Cleanup the request queue |
|
126 delete ipRequester; |
|
127 delete iInvokedProvider; |
|
128 delete ipTransportProperties; |
|
129 } |
|
130 |
|
131 void CSenLocalTransportPlugin::ConstructL() |
|
132 { |
|
133 // Open connection to the file logger server |
|
134 TLSLOG_OPEN(KSenLocalTransportLogChannelBase,KSenLocalTransportLogLevel,KSenLocalTransportLogDir,KSenLocalTransportLogFile); |
|
135 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"CSenLocalTransportPlugin::ConstructL - Log file opened."); |
|
136 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"CSenLocalTransportPlugin::ConstructL - Version 2 [2006-05-09]"); |
|
137 MSenCoreServiceManager& core = Context().GetCoreL(); |
|
138 ipRequester = CSenSyncRequester::NewL(*this, core); |
|
139 ipTransportProperties = CSenLayeredTransportProperties::NewL(); |
|
140 } |
|
141 |
|
142 TInt CSenLocalTransportPlugin::SubmitL(const TDesC8& aEndpoint, |
|
143 const TDesC8& aMessage, |
|
144 const TDesC8& aTransportProperties, |
|
145 HBufC8*& apResponse, |
|
146 MSenRemoteServiceConsumer& /*aConsumer*/) |
|
147 { |
|
148 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"CSenLocalTransportPlugin::SubmitL:"); |
|
149 |
|
150 // Sanity check the endpoint |
|
151 if (aEndpoint.Length() <= 0) |
|
152 { |
|
153 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"- No endpoint!"); |
|
154 return KErrSenNoEndpoint; // from SenServiceConnection.h (public API) |
|
155 } |
|
156 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("- Endpoint: %S"), &aEndpoint)); |
|
157 |
|
158 TLSLOG_L(KSenLocalTransportLogChannelBase,KMaxLogLevel,"- Message:"); |
|
159 TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,( aMessage )); |
|
160 |
|
161 TInt leaveCode(KErrNone); |
|
162 TInt statusCode(KErrNone); |
|
163 |
|
164 /* |
|
165 statusCode = ipRequester->SubmitL(aEndpoint, // endpoint |
|
166 aMessage, // request body |
|
167 aTransportProperties, // request props |
|
168 apResponse); |
|
169 */ |
|
170 |
|
171 TRAP( leaveCode, statusCode = ipRequester->SubmitL(aEndpoint, // endpoint |
|
172 aMessage, // request body |
|
173 aTransportProperties, // request props |
|
174 apResponse); ) // response body |
|
175 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("CSenLocalTransportPlugin::SubmitL returned: (%d)"), statusCode)); |
|
176 |
|
177 |
|
178 if(leaveCode!=KErrNone) |
|
179 { |
|
180 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("CSenLocalTransportPlugin::SubmitL leaved: (%d)"), leaveCode)); |
|
181 if(statusCode==KErrNone) |
|
182 { |
|
183 statusCode = leaveCode; |
|
184 } |
|
185 } |
|
186 else // did not leave |
|
187 { |
|
188 if(!apResponse) |
|
189 { |
|
190 TLSLOG(KSenLocalTransportLogChannelBase,KMinLogLevel,(_L("After calling CSenLocalTransportPlugin::SubmitL => response==NULL => leaving!"))); |
|
191 User::Leave(KErrCorrupt); |
|
192 } |
|
193 TLSLOG_L(KSenLocalTransportLogChannelBase,KMaxLogLevel,"CSenLocalTransportPlugin::SubmitL response:"); |
|
194 TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,(*apResponse)); |
|
195 } |
|
196 |
|
197 return statusCode; |
|
198 } |
|
199 |
|
200 TInt CSenLocalTransportPlugin::SendL(const TDesC8& aEndpoint, |
|
201 const TDesC8& aMessage, |
|
202 const TDesC8& aTransportProperties, |
|
203 MSenServiceSession& aReplyTo, |
|
204 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
205 TInt& aTxnId) |
|
206 { |
|
207 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"CSenLocalTransportPlugin::SendL:"); |
|
208 |
|
209 // Sanity check the endpoint |
|
210 if (aEndpoint.Length() <= 0) |
|
211 { |
|
212 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"- No endpoint!"); |
|
213 return KErrSenNoEndpoint; // from SenServiceConnection.h (public API) |
|
214 } |
|
215 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("- Endpoint: %S"), &aEndpoint)); |
|
216 |
|
217 TLSLOG_L(KSenLocalTransportLogChannelBase,KMaxLogLevel,"- Message:"); |
|
218 TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,( aMessage )); |
|
219 |
|
220 iTransactionID++; |
|
221 TInt* txnID = new (ELeave) TInt(iTransactionID); |
|
222 aTxnId = iTransactionID; |
|
223 |
|
224 CleanupStack::PushL(txnID); // memory leaks if CSenLocalRequest::NewLC leaves... |
|
225 |
|
226 // CSenLocalTransportPlugin::ProviderL method ("local proxy" for single consumer |
|
227 // -- since each consumer always owns its own transport) has now been **replaced** |
|
228 // with "provider factory" methods implemented to WSF **core**: |
|
229 |
|
230 MSenCoreServiceManager& core = Context().GetCoreL(); |
|
231 CSenLocalRequest* pRequest = CSenLocalRequest::NewLC(aEndpoint, |
|
232 aMessage, |
|
233 aTransportProperties, |
|
234 aReplyTo, |
|
235 aConsumer, |
|
236 core, |
|
237 *txnID); |
|
238 |
|
239 #ifdef _SENDEBUG |
|
240 //pRequest->SetLogger(iLogger); |
|
241 #endif // _SENDEBUG |
|
242 |
|
243 TInt retVal = iRequestMap.Append(pRequest, txnID); |
|
244 |
|
245 if(retVal==KErrNone) |
|
246 { |
|
247 CleanupStack::Pop(pRequest); |
|
248 CleanupStack::Pop(txnID); |
|
249 if(!pRequest->IsActive()) |
|
250 { |
|
251 TLSLOG_L(KSenLocalTransportLogChannelBase,KNormalLogLevel,"- Activating request / async call to the provider."); |
|
252 pRequest->SetActive(); |
|
253 } |
|
254 pRequest->iStatus = KRequestPending; |
|
255 TRequestStatus* status = &pRequest->iStatus; |
|
256 User::RequestComplete( status, CSenLocalRequest::EInvokeService ); //iTransactionID ); |
|
257 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KNormalLogLevel, _L8("- Request status: %d"), pRequest->iStatus.Int())); |
|
258 } |
|
259 else |
|
260 { |
|
261 CleanupStack::PopAndDestroy(pRequest); // orphanized request |
|
262 CleanupStack::Pop(txnID); |
|
263 } |
|
264 return retVal; // status code |
|
265 } |
|
266 |
|
267 |
|
268 TInt CSenLocalTransportPlugin::SetPropertiesL(const TDesC8& /* aProperties */, |
|
269 MSenLayeredProperties::TSenPropertiesLayer /* aTargetLayer */, |
|
270 MSenRemoteServiceConsumer* /*aConsumer*/) |
|
271 { |
|
272 return KErrNotSupported; // not implemented |
|
273 } |
|
274 |
|
275 TInt CSenLocalTransportPlugin::PropertiesL(HBufC8*& /* aProperties */) |
|
276 { |
|
277 return KErrNotSupported; // not implemented |
|
278 } |
|
279 |
|
280 TInt CSenLocalTransportPlugin::CompleteTransaction(const TInt /*aTxnId*/, |
|
281 const TInt /*aStatus*/) |
|
282 { |
|
283 return KErrNotSupported; // not supported by HTTP Channel |
|
284 } |
|
285 |
|
286 TInt CSenLocalTransportPlugin::CancelTransaction(const TInt /* aTxnId */) |
|
287 { |
|
288 return KErrNotSupported; |
|
289 } |
|
290 |
|
291 TPtrC8 CSenLocalTransportPlugin::UriSchemeL() |
|
292 { |
|
293 return KSenLocalTransportUriScheme(); |
|
294 } |
|
295 |
|
296 |
|
297 MSenProperties& CSenLocalTransportPlugin::PropertiesL() |
|
298 { |
|
299 return *ipTransportProperties; |
|
300 } |
|
301 |
|
302 /* |
|
303 RFileLogger* CSenLocalTransportPlugin::Log() const |
|
304 { |
|
305 return (RFileLogger*) &iLogger; |
|
306 } |
|
307 */ |
|
308 CSenLocalRequest* CSenLocalRequest::NewLC(const TDesC8& aEndpoint, //MSenProvider& aRequestTo, |
|
309 const TDesC8& aMessage, |
|
310 const TDesC8& aTransportProperties, |
|
311 MSenServiceSession& aReplyTo, |
|
312 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
313 MSenCoreServiceManager& aProviderProxy, |
|
314 TInt aTxnId) |
|
315 { |
|
316 //CSenLocalRequest* pNew = new (ELeave) CSenLocalRequest(aRequestTo, aReplyTo, aConsumer, aProviderProxy, aTxnId); |
|
317 CSenLocalRequest* pNew = new (ELeave) CSenLocalRequest(aEndpoint, aReplyTo, aConsumer, aProviderProxy, aTxnId); |
|
318 CleanupStack::PushL(pNew); |
|
319 pNew->ConstructL(aMessage, aTransportProperties); |
|
320 return pNew; |
|
321 } |
|
322 |
|
323 |
|
324 CSenLocalRequest::CSenLocalRequest(const TDesC8& aEndpoint, //MSenProvider& aRequestTo, |
|
325 MSenServiceSession& aReplyTo, |
|
326 MSenRemoteServiceConsumer& aConsumer, |
|
327 MSenCoreServiceManager& aProviderProxy, |
|
328 TInt aTxnId) |
|
329 : |
|
330 CActive(EPriorityStandard), |
|
331 ipProvider(NULL), |
|
332 iEndpoint(aEndpoint), |
|
333 iProviderProxy(aProviderProxy), |
|
334 ipRequestImpl(NULL), |
|
335 ipResponseImpl(NULL), |
|
336 ipTransportProperties(NULL), |
|
337 iReplyTo(aReplyTo), |
|
338 iConsumer(aConsumer), |
|
339 iTxnId(aTxnId), |
|
340 iLeaveCode(KErrNone), |
|
341 iRetVal(KErrNone), |
|
342 iDelivered(EFalse), |
|
343 ipResponse(NULL) |
|
344 { |
|
345 CActiveScheduler::Add(this); |
|
346 } |
|
347 |
|
348 |
|
349 CSenLocalRequest::~CSenLocalRequest() |
|
350 { |
|
351 DoCancel(); |
|
352 delete ipTransportProperties; |
|
353 delete ipRequestImpl; |
|
354 delete ipResponseImpl; |
|
355 iThread.Close(); |
|
356 delete ipResponse; |
|
357 // delete ipReqIdentifier; |
|
358 } |
|
359 |
|
360 |
|
361 // Called when local request thread crashes due to wrong local provider code |
|
362 // WS-Stack catches this crash |
|
363 // Stack still remain stable and communicates the failure to the request or consumer |
|
364 void CSenLocalRequest::LocalRequestExceptionHandlerL(TExcType aType) |
|
365 { |
|
366 // Crash is caused by local provider's ServiceL method |
|
367 // So nothing to be handled here and just return request thread |
|
368 // died status or OOM |
|
369 switch(aType) |
|
370 { |
|
371 case EExcStackFault: //stack overflow |
|
372 case EExcAccessViolation: //heap memory overflow |
|
373 User::Leave(KErrNoMemory);//OOM |
|
374 break; |
|
375 default: |
|
376 User::Leave(KErrDied); |
|
377 break; |
|
378 } |
|
379 } |
|
380 |
|
381 void CSenLocalRequest::ExecuteL() |
|
382 { |
|
383 // Allow only single thread to run ServiceL at the same time, |
|
384 // this is mandatory, since the provider might be sharable, |
|
385 // and providers might then have some status (session data) |
|
386 // which could be violated in multi-threaded execution. |
|
387 // @see MSenProvider.h |
|
388 |
|
389 |
|
390 if(ipProvider->Threadsafe()) |
|
391 { |
|
392 // Only threadsafe providers block access from other threads. |
|
393 // The non-threadsafe providers allow multiple threads to get |
|
394 // inside ServiceL() - in such case the provider typically |
|
395 // needs to implement critical section handling *itself* |
|
396 ipProvider->iCriticalSection.Wait(); |
|
397 } |
|
398 |
|
399 User::SetExceptionHandler(CSenLocalRequest::LocalRequestExceptionHandlerL, KExceptionFault); |
|
400 |
|
401 // try processing the message through the provider - trap any leave |
|
402 TRAP(iLeaveCode, iRetVal = ipProvider->ServiceL(*ipRequestImpl, *ipResponseImpl)); |
|
403 |
|
404 // If no crashes or leaves during ServiceL |
|
405 if (iLeaveCode == KErrNone) |
|
406 { |
|
407 ipResponse = ipResponseImpl->ExtractResponseUtf8(); |
|
408 } |
|
409 |
|
410 // ipRequestImpl and ipResponseImpl are created within local provider thread |
|
411 // scope. Since these objects involve XmlEngineAttachL and XmlEngineCleanup |
|
412 // calls, the cleanup is done within the threads scope otherwise XmlEngineCleanup |
|
413 // will happen in main thread's scope which move the xmlengine reference count |
|
414 // below 0, XmlEngine data structures will cleanup. This is unintended behaviour. So |
|
415 // to avoid this cleanup is done within local provider thread scope |
|
416 delete ipRequestImpl; |
|
417 ipRequestImpl = NULL; |
|
418 delete ipResponseImpl; |
|
419 ipResponseImpl = NULL; |
|
420 |
|
421 if(ipProvider->Threadsafe()) |
|
422 { |
|
423 // Notify next thread that it can proceed and run |
|
424 // ServiceL (needed for sharable providers): |
|
425 ipProvider->iCriticalSection.Signal(); |
|
426 } |
|
427 |
|
428 iStatus = KRequestPending; |
|
429 SetActive(); |
|
430 } |
|
431 |
|
432 const TThreadId CSenLocalRequest::OwnerThreadId() const |
|
433 { |
|
434 return iOwnerThreadId; |
|
435 } |
|
436 |
|
437 void CSenLocalRequest::RunL() |
|
438 { |
|
439 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("CSenLocalRequest::RunL(), status: %d"), iStatus.Int())); |
|
440 |
|
441 switch(iStatus.Int()) |
|
442 { |
|
443 |
|
444 case EInvokeService: // executed in "main", server thread by the ActiveScheduler |
|
445 { |
|
446 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"EInvokeService -- "); |
|
447 |
|
448 #ifdef _SENDEBUG |
|
449 TName fullThreadName = iThread.FullName(); |
|
450 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KNormalLogLevel, _L8("'%S'"), &fullThreadName)); |
|
451 #endif // _SENDEBUG |
|
452 iThread.Resume(); // this will issue ExecuteL call from *another thread*! |
|
453 } |
|
454 break; |
|
455 |
|
456 case EDeliverResponse: // executed in "main", server thread by the ActiveScheduler |
|
457 { |
|
458 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"EDeliverResponse"); |
|
459 DeliverL(); |
|
460 } |
|
461 break; |
|
462 |
|
463 default: |
|
464 { |
|
465 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"- Unknown request. Processing not implemented."); |
|
466 } |
|
467 // unknown |
|
468 break; |
|
469 } |
|
470 } |
|
471 |
|
472 void CSenLocalRequest::DeliverL() |
|
473 { |
|
474 if(iLeaveCode) |
|
475 { |
|
476 // send error to consumer |
|
477 iRetVal = iLeaveCode; |
|
478 TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("CSenProvider::ExecuteL leaved: %d"), iLeaveCode)); |
|
479 |
|
480 Session().SendErrorToConsumerL(iRetVal, |
|
481 NULL, |
|
482 TxnId(), |
|
483 Consumer()); |
|
484 } |
|
485 else |
|
486 { |
|
487 // TPtrC8 response = ipResponseImpl->ResponseUtf8(); |
|
488 //HBufC8* pResponse = ipResponseImpl->ExtractResponseUtf8(); |
|
489 TLSLOG_L(KSenLocalTransportLogChannelBase,KMaxLogLevel,"CSenLocalRequest::ExecuteL() hostlet response:"); |
|
490 |
|
491 #ifdef _SENDEBUG |
|
492 if( ipResponse ) |
|
493 { |
|
494 TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,( *ipResponse )); |
|
495 } |
|
496 else |
|
497 { |
|
498 TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"-Fatal(!): pResponse == NULL"); |
|
499 } |
|
500 #endif // _SENDEBUG |
|
501 |
|
502 if( iRetVal!=KErrNone ) |
|
503 { |
|
504 // send error to the consumer |
|
505 Session().SendErrorToConsumerL(iRetVal, |
|
506 ipResponse, |
|
507 TxnId(), |
|
508 Consumer()); |
|
509 // Ownership is transferred if response is delivered so no cleanup |
|
510 ipResponse = NULL; |
|
511 } |
|
512 else |
|
513 { |
|
514 // send message to consumer |
|
515 Session().SendToConsumerL(ipResponse, |
|
516 TxnId(), |
|
517 Consumer()); |
|
518 // Ownership is transferred if response is delivered so no cleanup |
|
519 ipResponse = NULL; |
|
520 } |
|
521 } |
|
522 iProviderProxy.ReleaseHostletL(ipProvider, iThread.FullName(), iConsumer.Id()); |
|
523 iThread.Close(); |
|
524 } |
|
525 |
|
526 void CSenLocalRequest::DoCancel() |
|
527 { |
|
528 } |
|
529 |
|
530 void CSenLocalRequest::ConstructL(const TDesC8& aMessage, |
|
531 const TDesC8& aTransportProperties) |
|
532 |
|
533 { |
|
534 |
|
535 ipTransportProperties = aTransportProperties.AllocL(); |
|
536 |
|
537 TInt consumerIdLength(iConsumer.Id().Length()); |
|
538 |
|
539 HBufC* pTemp = HBufC::NewLC(consumerIdLength); |
|
540 // Consumer id (UCS8) does not contain any special, |
|
541 // "UTF-8 to Unicode" -convertible characters, so |
|
542 // copying is OK. |
|
543 TPtr temp = pTemp->Des(); |
|
544 temp.Copy(iConsumer.Id()); |
|
545 HBufC* pConsumerIdUnicode = HBufC::NewLC(consumerIdLength); |
|
546 TPtr consumerIdUnicode = pConsumerIdUnicode->Des(); |
|
547 TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,(consumerIdUnicode)); |
|
548 |
|
549 if(consumerIdLength>KSenUuidPrefixLength) |
|
550 { |
|
551 consumerIdUnicode.Append(pTemp->Right(consumerIdLength-KSenUuidPrefixLength)); |
|
552 } |
|
553 |
|
554 // Remove dashes |
|
555 _LIT(KDash, "-"); |
|
556 TInt pos = consumerIdUnicode.Find(KDash); |
|
557 while (pos != KErrNotFound) |
|
558 { |
|
559 consumerIdUnicode.Replace(pos, KDash().Length(), KNullDesC); |
|
560 pos = consumerIdUnicode.Find(KDash); |
|
561 } |
|
562 |
|
563 TName threadName; |
|
564 _LIT(KNameFmt, "CSenLocalRequest%d.%S"); |
|
565 threadName.Format(KNameFmt, iTxnId, pConsumerIdUnicode); |
|
566 |
|
567 CleanupStack::PopAndDestroy(2); // pConsumerIdUnicode, pTemp |
|
568 |
|
569 #ifdef EKA2 |
|
570 RAllocator& heap = User::Allocator(); // RHeap is deprecated in EKA2 |
|
571 iThread.Create(threadName, // name |
|
572 threadFunction, |
|
573 KDefaultStackSize, |
|
574 &heap, |
|
575 this); |
|
576 #else // EKA1 |
|
577 RHeap& heap = User::Heap(); |
|
578 iThread.Create(threadName, // name |
|
579 threadFunction, |
|
580 KDefaultStackSize, |
|
581 &heap, |
|
582 this); |
|
583 #endif // EKA |
|
584 |
|
585 RThread thread; |
|
586 iOwnerThreadId = thread.Id(); |
|
587 |
|
588 |
|
589 ipResponseImpl = CSenHostletResponse::NewL(iTxnId); |
|
590 |
|
591 CSenChunk* pChunk = NULL; |
|
592 |
|
593 /* TInt getChunkRetCode(KErrNotFound); |
|
594 getChunkRetCode = */ |
|
595 iConsumer.ChunkByTxnIdL(iTxnId, pChunk); |
|
596 |
|
597 |
|
598 ipRequestImpl = CSenHostletRequest::NewL(iTxnId, aMessage, iThread, iConsumer.Identifier(), pChunk); |
|
599 |
|
600 // getChunkRetCode = 0; // not used atm (in release builds) |
|
601 |
|
602 //TBuf8<128> threadName; |
|
603 //_LIT8(KNameFmt, "CSenLocalRequest-%d"); |
|
604 //threadName.Format(KNameFmt, iTxnId); |
|
605 //ipReqIdentifier = CSenIdentifier::NewL(SenIdentifier::EThread, threadName); |
|
606 |
|
607 ipProvider = & iProviderProxy.LookupHostletForL(iEndpoint, iThread.FullName(), iConsumer.Id()); |
|
608 |
|
609 } |
|
610 |
|
611 |
|
612 MSenServiceSession& CSenLocalRequest::Session() const |
|
613 { |
|
614 return iReplyTo; |
|
615 } |
|
616 |
|
617 MSenRemoteServiceConsumer& CSenLocalRequest::Consumer() const |
|
618 { |
|
619 return iConsumer; |
|
620 } |
|
621 |
|
622 |
|
623 TInt CSenLocalRequest::TxnId() const |
|
624 { |
|
625 return iTxnId; |
|
626 } |
|
627 |
|
628 |
|
629 TBool CSenLocalRequest::Delivered() const |
|
630 { |
|
631 return iDelivered; |
|
632 } |
|
633 |
|
634 CSenHostletResponse& CSenLocalRequest::Response() |
|
635 { |
|
636 return *ipResponseImpl; |
|
637 } |
|
638 |
|
639 TPtrC8 CSenLocalRequest::TransportProperties() const |
|
640 { |
|
641 return *ipTransportProperties; |
|
642 } |
|
643 |
|
644 /*void CSenLocalRequest::SetLogger(RFileLogger& aLogger) |
|
645 { |
|
646 iLogger = &aLogger; |
|
647 } |
|
648 |
|
649 RFileLogger* CSenLocalRequest::Log() const |
|
650 { |
|
651 return (RFileLogger*) iLogger; |
|
652 } |
|
653 */ |
|
654 |
|
655 // END OF FILE |