|
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 FILES |
|
29 #include "sensyncrequester.h" |
|
30 #include "msentransport.h" |
|
31 #include "msencoreservicemanager.h" // internal: Core\inc |
|
32 #include "senidentifier.h" |
|
33 #include "senguidgen.h" // internal: Utils\inc |
|
34 #include "MSenHostlet.h" |
|
35 #include "MSenProperties.h" |
|
36 |
|
37 EXPORT_C CSenSyncRequester* CSenSyncRequester::NewL(MSenTransport& aTransport, |
|
38 MSenCoreServiceManager& aManager) |
|
39 { |
|
40 CSenSyncRequester* pNew = CSenSyncRequester::NewLC(aTransport, aManager); |
|
41 CleanupStack::Pop(); |
|
42 return pNew; |
|
43 } |
|
44 |
|
45 EXPORT_C CSenSyncRequester* CSenSyncRequester::NewLC(MSenTransport& aTransport, |
|
46 MSenCoreServiceManager& aManager) |
|
47 { |
|
48 CSenSyncRequester* pNew = new (ELeave) CSenSyncRequester(aTransport, aManager); |
|
49 CleanupStack::PushL(pNew); |
|
50 pNew->BaseConstructL(); |
|
51 return pNew; |
|
52 } |
|
53 |
|
54 EXPORT_C CSenSyncRequester::~CSenSyncRequester() |
|
55 { |
|
56 delete ipResponse; |
|
57 delete ipResponseProperties; |
|
58 delete ipConsumerId; |
|
59 delete ipIdentifier; |
|
60 } |
|
61 |
|
62 EXPORT_C CSenSyncRequester::CSenSyncRequester(MSenTransport& aTransport, |
|
63 MSenCoreServiceManager& aManager) |
|
64 |
|
65 : iTransport(aTransport), |
|
66 iServiceManager(aManager), |
|
67 ipIdentifier(NULL), |
|
68 ipConsumerId(NULL), |
|
69 ipResponse(NULL), |
|
70 ipResponseProperties(NULL), |
|
71 iResponsePropertiesType(MSenProperties::ESenXmlProperties), |
|
72 iStatusCode(KErrNone) |
|
73 { |
|
74 } |
|
75 |
|
76 EXPORT_C void CSenSyncRequester::BaseConstructL() |
|
77 { |
|
78 ipConsumerId = iServiceManager.RandomGuidL(); |
|
79 ipIdentifier = CSenIdentifier::NewL(SenIdentifier::ESession, *ipConsumerId); |
|
80 } |
|
81 |
|
82 TInt CSenSyncRequester::SubmitL(const TDesC8& aEndpointUri, |
|
83 const TDesC8& aMessage, |
|
84 const TDesC8& aRequestTransportProperties, |
|
85 HBufC8*& apResponseTo) |
|
86 { |
|
87 iStatusCode = KErrNone; |
|
88 TInt txnId(KErrNone); |
|
89 TInt retCode = iTransport.SendL(aEndpointUri, |
|
90 aMessage, |
|
91 aRequestTransportProperties, |
|
92 *this, |
|
93 *this, |
|
94 txnId); |
|
95 |
|
96 if(retCode==KErrNone) |
|
97 { |
|
98 // Wait here until a callback from transport is received: |
|
99 iSchedulerWait.Start(); |
|
100 |
|
101 // Now read the response and return code from member variables, |
|
102 // and assign them to the references passed by the SubmitL caller: |
|
103 |
|
104 apResponseTo = ipResponse; |
|
105 ipResponse = NULL; |
|
106 //apResponseProperties = ipResponseProperties; // transport properties of the response. |
|
107 //ipResponseProperties = NULL; |
|
108 |
|
109 // On success, always return the transaction ID received from the transport: |
|
110 return txnId; |
|
111 } |
|
112 else // error occurred |
|
113 { |
|
114 // SendL failed, return the error immediately: |
|
115 return retCode; |
|
116 } |
|
117 } |
|
118 |
|
119 |
|
120 TInt CSenSyncRequester::SendToConsumerL(HBufC8* apMessage, |
|
121 const TInt aTxnId, |
|
122 MSenRemoteServiceConsumer& aConsumer, |
|
123 MSenProperties* aResponseTransportProperties) |
|
124 { |
|
125 // SendToConsumerL method will be changed to provide reference to |
|
126 // the transport properties which describe the RESPONSE, not request.. |
|
127 return aConsumer.HandleMessageL(apMessage, aTxnId, aResponseTransportProperties); |
|
128 } |
|
129 |
|
130 TInt CSenSyncRequester::SendErrorToConsumerL(const TInt aErrorCode, |
|
131 HBufC8* apError, |
|
132 const TInt aTxnId, |
|
133 MSenRemoteServiceConsumer& aConsumer, |
|
134 MSenProperties* aResponseTransportProperties) |
|
135 { |
|
136 // SendErrorToConsumerL method will be changed to provide reference to |
|
137 // the transport properties which describe the RESPONSE, not request.. |
|
138 return aConsumer.HandleErrorL(apError, aErrorCode, aTxnId, aResponseTransportProperties); |
|
139 } |
|
140 |
|
141 // Note: this method is meant for those SESSION implementations, which |
|
142 // actually are capable of handling certain errors between transport |
|
143 // and session. |
|
144 TInt CSenSyncRequester::HandleErrorL(const TInt aErrorCode, |
|
145 HBufC8* apError, |
|
146 const TInt /*aTxnId*/, |
|
147 MSenRemoteServiceConsumer& /*aConsumer*/, |
|
148 MSenProperties* /*aResponseTransportProperties*/) |
|
149 { |
|
150 // NONE of the errors between transport and session are handled in this level: |
|
151 delete apError; |
|
152 return aErrorCode; // simply bounce the error back to the caller |
|
153 } |
|
154 |
|
155 const TDesC8& CSenSyncRequester::Id() const |
|
156 { |
|
157 return *ipConsumerId; |
|
158 } |
|
159 |
|
160 TInt CSenSyncRequester::SetSessionL(MSenRemoteServiceSession& /*aServiceSession*/) |
|
161 { |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 // From MSenRemoteServiceConsumer |
|
166 TInt CSenSyncRequester::HandleMessageL(HBufC8* apMessage, |
|
167 const TInt aTxnId, |
|
168 MSenProperties* aResponseTransportProperties) |
|
169 { |
|
170 iStatusCode = KErrNone; |
|
171 ipResponse = apMessage; |
|
172 if( aResponseTransportProperties ) |
|
173 { |
|
174 iResponsePropertiesType = aResponseTransportProperties->PropertiesClassType(); |
|
175 ipResponseProperties = aResponseTransportProperties->AsUtf8L(); |
|
176 } |
|
177 // Now stop the SYNC wait in the SubmitL, so that the main thread |
|
178 // of the Serene Core Active Scheduler can continue it's execution |
|
179 iSchedulerWait.AsyncStop(); |
|
180 return aTxnId; |
|
181 } |
|
182 |
|
183 // From MSenServiceSession |
|
184 TInt CSenSyncRequester::HandleErrorL(HBufC8* apError, |
|
185 const TInt aErrorCode, |
|
186 const TInt aTxnId, |
|
187 MSenProperties* aResponseTransportProperties) |
|
188 { |
|
189 iStatusCode = aErrorCode; |
|
190 ipResponse = apError; |
|
191 if( aResponseTransportProperties ) |
|
192 { |
|
193 iResponsePropertiesType = aResponseTransportProperties->PropertiesClassType(); |
|
194 ipResponseProperties = aResponseTransportProperties->AsUtf8L(); |
|
195 } |
|
196 // Now stop the SYNC wait in the SubmitL, so that the main thread |
|
197 // of the Serene Core Active Scheduler can continue it's execution |
|
198 iSchedulerWait.AsyncStop(); |
|
199 return aTxnId; |
|
200 } |
|
201 |
|
202 void CSenSyncRequester::SetStatusL(const TInt /*aStatus*/) |
|
203 { |
|
204 // not implemented |
|
205 } |
|
206 |
|
207 MSenTransport& CSenSyncRequester::TransportL() |
|
208 { |
|
209 return (MSenTransport&)iTransport; |
|
210 } |
|
211 |
|
212 CSenIdentifier& CSenSyncRequester::Identifier() const |
|
213 { |
|
214 return *ipIdentifier; |
|
215 } |
|
216 |
|
217 |
|
218 TInt CSenSyncRequester::ChunkByTxnIdL(TInt /* aTxnId */, CSenChunk*& /* aChunk */) |
|
219 { |
|
220 return KErrNotSupported; |
|
221 } |
|
222 |
|
223 MSenRemoteHostlet* CSenSyncRequester::Hostlet() const |
|
224 { |
|
225 return NULL; |
|
226 } |
|
227 |
|
228 TInt CSenSyncRequester::SendToHostletL(MSenRemoteHostlet& /* aReceiver */, |
|
229 const TDesC8& /* aMessage */, |
|
230 const TInt /* aTxnId */, |
|
231 MSenRemoteServiceConsumer& /* aFrom */, |
|
232 MSenProperties* /* aProperties */) |
|
233 { |
|
234 return KErrNotSupported; |
|
235 } |
|
236 |
|
237 void CSenSyncRequester::FileProgress(TInt /*aTxnId*/, TBool /*aIncoming*/, TBool /*aIsSoap*/, |
|
238 const TDesC8& /*aSoapOrCid*/, TInt /*aProgress*/) |
|
239 { |
|
240 } |
|
241 void CSenSyncRequester::SetDataTrafficDetails( TSenDataTrafficDetails& /*aDetails*/) |
|
242 { |
|
243 } |
|
244 // End of File |
|
245 |