|
1 /* |
|
2 * Copyright (c) 2010 Sun Microsystems, Inc. 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 Contributor: |
|
10 * Maximilian Odendahl |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: basic http/webdav functionality |
|
15 * handles all needed internet access for Caldav |
|
16 */ |
|
17 |
|
18 #include "httpclient.h" |
|
19 #include "caldavutils.h" |
|
20 #include <uri8.h> |
|
21 #include <http.h> |
|
22 #include <EIKENV.H> |
|
23 |
|
24 _LIT8(KTextXml,"text/xml"); |
|
25 _LIT8(KTextCalendar,"text/calendar"); |
|
26 _LIT8(KDepth,"depth"); |
|
27 |
|
28 /** |
|
29 * CHttpClient::CHttpClient |
|
30 * default constructor |
|
31 */ |
|
32 CHttpClient::CHttpClient() : |
|
33 iUser(0), iPassword(0), iEtag(0), iCredentialCount(0) |
|
34 { |
|
35 } |
|
36 |
|
37 /** |
|
38 * CHttpClient::~CHttpClient |
|
39 * default destructor |
|
40 */ |
|
41 CHttpClient::~CHttpClient() |
|
42 { |
|
43 delete iUser; |
|
44 delete iPassword; |
|
45 delete iEtag; |
|
46 |
|
47 iSess.Close(); |
|
48 iRConnection.Close(); |
|
49 iSocketServ.Close(); |
|
50 |
|
51 } |
|
52 |
|
53 /** |
|
54 * CHttpClient::NewLC |
|
55 * first phase constructor |
|
56 */ |
|
57 CHttpClient* CHttpClient::NewLC() |
|
58 { |
|
59 CHttpClient* me = new (ELeave) CHttpClient; |
|
60 CleanupStack::PushL(me); |
|
61 me->ConstructL(); |
|
62 return me; |
|
63 } |
|
64 |
|
65 /** |
|
66 * CHttpClient::NewL |
|
67 * first phase construction |
|
68 */ |
|
69 CHttpClient* CHttpClient::NewL() |
|
70 { |
|
71 CHttpClient* me = NewLC(); |
|
72 CleanupStack::Pop(me); |
|
73 return me; |
|
74 } |
|
75 |
|
76 /** |
|
77 * CHttpClient::OpenSessionL |
|
78 * open session and instal authentification |
|
79 */ |
|
80 void CHttpClient::OpenSessionL() |
|
81 { |
|
82 TRAPD(err, iSess.OpenL()); |
|
83 |
|
84 if (err != KErrNone) |
|
85 { |
|
86 _LIT(KErrMsg, "Cannot create session. Is internet access point configured?"); |
|
87 _LIT(KExitingApp, "Exiting app."); |
|
88 CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp); |
|
89 User::Leave(err); |
|
90 } |
|
91 |
|
92 // Install this class as the callback for authentication requests |
|
93 InstallAuthenticationL(iSess); |
|
94 |
|
95 // Set the session's connection info... |
|
96 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
97 // ...to use the socket server |
|
98 connInfo.SetPropertyL(iSess.StringPool().StringF(HTTP::EHttpSocketServ, |
|
99 RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle())); |
|
100 // ...to use the connection |
|
101 connInfo.SetPropertyL( |
|
102 iSess.StringPool().StringF(HTTP::EHttpSocketConnection, |
|
103 RHTTPSession::GetTable()), |
|
104 THTTPHdrVal(REINTERPRET_CAST(TInt, &(iRConnection)))); |
|
105 |
|
106 } |
|
107 |
|
108 /** |
|
109 * CHttpClient::ConstructL |
|
110 * second phase construction |
|
111 */ |
|
112 void CHttpClient::ConstructL() |
|
113 { |
|
114 User::LeaveIfError(iSocketServ.Connect()); |
|
115 User::LeaveIfError(iRConnection.Open(iSocketServ)); |
|
116 |
|
117 iExtPrefs.SetSnapPurpose( CMManager::ESnapPurposeInternet ); |
|
118 iExtPrefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnDisableNotes); |
|
119 iPrefList.AppendL(&iExtPrefs); |
|
120 iRConnection.Start(iPrefList); |
|
121 |
|
122 OpenSessionL(); |
|
123 } |
|
124 |
|
125 /** |
|
126 * CHttpClient::DeleteL |
|
127 * HTTP DELETE |
|
128 */ |
|
129 TInt CHttpClient::DeleteL(const TDesC8 &aUrl, const TDesC8 &aETag) |
|
130 { |
|
131 iReturnCode = ERROR; |
|
132 |
|
133 TUriParser8 uri; |
|
134 uri.Parse(aUrl); |
|
135 |
|
136 iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF( |
|
137 HTTP::EDELETE, RHTTPSession::GetTable())); |
|
138 if (aETag != KNullDesC8) |
|
139 SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EIfMatch, |
|
140 aETag); |
|
141 SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent, |
|
142 KUserAgent); |
|
143 iTrans.SubmitL(); |
|
144 |
|
145 CActiveScheduler::Start(); |
|
146 return iReturnCode; |
|
147 } |
|
148 |
|
149 /** |
|
150 * CHttpClient::HeadL |
|
151 * HTTP HEAD |
|
152 */ |
|
153 TInt CHttpClient::HeadL(const TDesC8 &aUrl) |
|
154 { |
|
155 iReturnCode = ERROR; |
|
156 |
|
157 TUriParser8 uri; |
|
158 uri.Parse(aUrl); |
|
159 |
|
160 iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF( |
|
161 HTTP::EHEAD, RHTTPSession::GetTable())); |
|
162 SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent, |
|
163 KUserAgent); |
|
164 iTrans.SubmitL(); |
|
165 CActiveScheduler::Start(); |
|
166 return iReturnCode; |
|
167 } |
|
168 |
|
169 /** |
|
170 * CHttpClient::GetL |
|
171 * HTTP Get |
|
172 */ |
|
173 TInt CHttpClient::GetL(const TDesC8 &aUrl, CBufFlat *aResponse) |
|
174 { |
|
175 iReturnCode = ERROR; |
|
176 |
|
177 iBodyResponse = aResponse; |
|
178 |
|
179 TUriParser8 uri; |
|
180 uri.Parse(aUrl); |
|
181 |
|
182 iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF( |
|
183 HTTP::EGET, RHTTPSession::GetTable())); |
|
184 SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent, |
|
185 KUserAgent); |
|
186 iTrans.SubmitL(); |
|
187 CActiveScheduler::Start(); |
|
188 iBodyResponse = NULL; |
|
189 return iReturnCode; |
|
190 } |
|
191 |
|
192 /** |
|
193 * CHttpClient::MkCalendarL |
|
194 * Caldav MKCALENDAR |
|
195 */ |
|
196 TInt CHttpClient::MkCalendarL(const TDesC8 &aUrl, const TDesC8 &aBody, |
|
197 CBufFlat *aResponse) |
|
198 { |
|
199 iReturnCode = ERROR; |
|
200 |
|
201 if (aBody != KNullDesC8) |
|
202 { |
|
203 iBodyRequest = aBody.Alloc(); |
|
204 iTrans.Request().SetBody(*this); |
|
205 } |
|
206 |
|
207 iBodyResponse = aResponse; |
|
208 |
|
209 TUriParser8 uri; |
|
210 uri.Parse(aUrl); |
|
211 |
|
212 RStringF mkcalendar = iSess.StringPool().OpenFStringL(MKCALENDAR); |
|
213 iTrans = iSess.OpenTransactionL(uri, *this, mkcalendar); |
|
214 RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); |
|
215 |
|
216 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); |
|
217 SetHeaderL(hdr, HTTP::EContentType, KTextXml); |
|
218 |
|
219 iTrans.SubmitL(); |
|
220 CActiveScheduler::Start(); |
|
221 |
|
222 mkcalendar.Close(); |
|
223 if (iBodyRequest) |
|
224 { |
|
225 delete iBodyRequest; |
|
226 iBodyRequest = NULL; |
|
227 } |
|
228 iBodyResponse = NULL; |
|
229 |
|
230 return iReturnCode; |
|
231 } |
|
232 |
|
233 /** |
|
234 * CHttpClient::PutL |
|
235 * HTTP PUT |
|
236 */ |
|
237 TInt CHttpClient::PutL(const TDesC8 &aUrl, const TDesC8 &aIcs, |
|
238 CBufFlat *aResponse, const TDesC8 &aEtag) |
|
239 { |
|
240 iReturnCode = ERROR; |
|
241 |
|
242 iBodyRequest = aIcs.Alloc(); |
|
243 iBodyResponse = aResponse; |
|
244 |
|
245 TUriParser8 uri; |
|
246 uri.Parse(aUrl); |
|
247 |
|
248 iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF( |
|
249 HTTP::EPUT, RHTTPSession::GetTable())); |
|
250 RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); |
|
251 |
|
252 iTrans.Request().SetBody(*this); |
|
253 |
|
254 if (aEtag == KNullDesC8) |
|
255 { |
|
256 _LIT8(KStar, "*"); |
|
257 SetHeaderL(hdr, HTTP::EIfNoneMatch, KStar); |
|
258 } |
|
259 else |
|
260 { |
|
261 #ifdef ETAG |
|
262 SetHeaderL(hdr,HTTP::EIfMatch,aEtag); |
|
263 #endif |
|
264 } |
|
265 |
|
266 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); |
|
267 SetHeaderL(hdr, HTTP::EContentType, KTextCalendar); |
|
268 |
|
269 iTrans.SubmitL(); |
|
270 CActiveScheduler::Start(); |
|
271 |
|
272 delete iBodyRequest; |
|
273 iBodyRequest = NULL; |
|
274 iBodyResponse = NULL; |
|
275 |
|
276 return iReturnCode; |
|
277 } |
|
278 |
|
279 /** |
|
280 * CHttpClient::ReportL |
|
281 * Caldav REPORT |
|
282 */ |
|
283 TInt CHttpClient::ReportL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest, |
|
284 CBufFlat *aResponse) |
|
285 { |
|
286 iReturnCode = ERROR; |
|
287 iBodyResponse = aResponse; |
|
288 |
|
289 TUriParser8 uri; |
|
290 uri.Parse(aUrl); |
|
291 |
|
292 RStringF report = iSess.StringPool().OpenFStringL(REPORT); |
|
293 iTrans = iSess.OpenTransactionL(uri, *this, report); |
|
294 if (aBodyRequest.Length()) |
|
295 { |
|
296 iBodyRequest = aBodyRequest.Alloc(); |
|
297 iTrans.Request().SetBody(*this); |
|
298 } |
|
299 |
|
300 RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); |
|
301 SetHeaderL(hdr, HTTP::EContentType, KTextXml); |
|
302 SetHeaderL(hdr, KDepth, ONE); |
|
303 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); |
|
304 iTrans.SubmitL(); |
|
305 CActiveScheduler::Start(); |
|
306 |
|
307 report.Close(); |
|
308 |
|
309 delete iBodyRequest; |
|
310 iBodyRequest = NULL; |
|
311 iBodyResponse = NULL; |
|
312 |
|
313 return iReturnCode; |
|
314 } |
|
315 |
|
316 /** |
|
317 * CHttpClient::PropfindL |
|
318 * WebDAV PROPFIND |
|
319 */ |
|
320 TInt CHttpClient::PropfindL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest, |
|
321 CBufFlat *aResponse, TBool depth) |
|
322 { |
|
323 iReturnCode = ERROR; |
|
324 iBodyResponse = aResponse; |
|
325 |
|
326 TUriParser8 uri; |
|
327 uri.Parse(aUrl); |
|
328 |
|
329 RStringF propfind = iSess.StringPool().OpenFStringL(PROPFIND); |
|
330 iTrans = iSess.OpenTransactionL(uri, *this, propfind); |
|
331 if (aBodyRequest.Length()) |
|
332 { |
|
333 iBodyRequest = aBodyRequest.Alloc(); |
|
334 iTrans.Request().SetBody(*this); |
|
335 } |
|
336 |
|
337 RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); |
|
338 SetHeaderL(hdr, HTTP::EContentType, KTextXml); |
|
339 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); |
|
340 if (depth) |
|
341 SetHeaderL(hdr, KDepth, ZERO); |
|
342 else |
|
343 SetHeaderL(hdr, KDepth, ONE); |
|
344 |
|
345 iTrans.SubmitL(); |
|
346 CActiveScheduler::Start(); |
|
347 |
|
348 propfind.Close(); |
|
349 |
|
350 delete iBodyRequest; |
|
351 iBodyRequest = NULL; |
|
352 iBodyResponse = NULL; |
|
353 |
|
354 return iReturnCode; |
|
355 } |
|
356 |
|
357 /** |
|
358 * CHttpClient::ProppatchL |
|
359 * Webdav PROPPATCH |
|
360 */ |
|
361 TInt CHttpClient::ProppatchL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest, CBufFlat *aResponse) |
|
362 { |
|
363 iReturnCode = ERROR; |
|
364 iBodyResponse = aResponse; |
|
365 |
|
366 TUriParser8 uri; |
|
367 uri.Parse(aUrl); |
|
368 |
|
369 RStringF proppatch = iSess.StringPool().OpenFStringL(PROPPATCH); |
|
370 iTrans = iSess.OpenTransactionL(uri, *this, proppatch); |
|
371 RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); |
|
372 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); |
|
373 SetHeaderL(hdr, HTTP::EContentType, KTextXml); |
|
374 |
|
375 iBodyRequest = aBodyRequest.Alloc(); |
|
376 iTrans.Request().SetBody(*this); |
|
377 |
|
378 iTrans.SubmitL(); |
|
379 CActiveScheduler::Start(); |
|
380 |
|
381 proppatch.Close(); |
|
382 |
|
383 delete iBodyRequest; |
|
384 iBodyRequest = NULL; |
|
385 iBodyResponse = NULL; |
|
386 |
|
387 return iReturnCode; |
|
388 } |
|
389 |
|
390 /** |
|
391 * CHttpClient::GetServerOptionsL |
|
392 * HTTP OPTIONS |
|
393 */ |
|
394 TInt CHttpClient::GetServerOptionsL(const TDesC8 &aUrl, |
|
395 TCalDAVOptions &aOptions) |
|
396 { |
|
397 iReturnCode = ERROR; |
|
398 iAction = EActionOption; |
|
399 iOptions = &aOptions; |
|
400 |
|
401 TUriParser8 uri; |
|
402 uri.Parse(aUrl); |
|
403 |
|
404 RStringF options = iSess.StringPool().OpenFStringL(OPTIONS); |
|
405 iTrans = iSess.OpenTransactionL(uri, *this, options); |
|
406 SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent, |
|
407 KUserAgent); |
|
408 iTrans.SubmitL(); |
|
409 |
|
410 CActiveScheduler::Start(); |
|
411 |
|
412 options.Close(); |
|
413 |
|
414 iAction = EActionNone; |
|
415 return iReturnCode; |
|
416 } |
|
417 |
|
418 /** |
|
419 * CHttpClient::GetNextDataPart |
|
420 * GetNextDataPart callback |
|
421 */ |
|
422 TBool CHttpClient::GetNextDataPart(TPtrC8& aDataPart) |
|
423 { |
|
424 aDataPart.Set(iBodyRequest->Des()); |
|
425 return ETrue; |
|
426 } |
|
427 |
|
428 /** |
|
429 * CHttpClient::ReleaseData |
|
430 * ReleaseData callback |
|
431 */ |
|
432 void CHttpClient::ReleaseData() |
|
433 { |
|
434 } |
|
435 |
|
436 /** |
|
437 * CHttpClient::OverallDataSize |
|
438 * OverallDataSize callback |
|
439 */ |
|
440 TInt CHttpClient::OverallDataSize() |
|
441 { |
|
442 if (iBodyRequest) |
|
443 return iBodyRequest->Length(); |
|
444 else |
|
445 return 0; |
|
446 } |
|
447 |
|
448 /** |
|
449 * CHttpClient::Reset |
|
450 * Reset callback |
|
451 */ |
|
452 TInt CHttpClient::Reset() |
|
453 { |
|
454 return KErrNone; |
|
455 } |
|
456 |
|
457 /** |
|
458 * CHttpClient::SetHeaderL |
|
459 * sets int header at session headers |
|
460 */ |
|
461 void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, |
|
462 const TDesC8& aHdrValue) |
|
463 { |
|
464 RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue); |
|
465 CleanupClosePushL(valStr); |
|
466 THTTPHdrVal val(valStr); |
|
467 aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField, |
|
468 RHTTPSession::GetTable()), val); |
|
469 CleanupStack::PopAndDestroy(&valStr); |
|
470 } |
|
471 |
|
472 /** |
|
473 * CHttpClient::SetHeaderL |
|
474 * set string header at session headers |
|
475 */ |
|
476 void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, const TDesC8 &aField, |
|
477 const TDesC8 &aValue) |
|
478 { |
|
479 RStringF FieldVal = iSess.StringPool().OpenFStringL(aField); |
|
480 CleanupClosePushL(FieldVal); |
|
481 RStringF valStr = iSess.StringPool().OpenFStringL(aValue); |
|
482 CleanupClosePushL(valStr); |
|
483 THTTPHdrVal val(valStr); |
|
484 aHeaders.SetFieldL(FieldVal, val); |
|
485 CleanupStack::PopAndDestroy(&valStr); |
|
486 CleanupStack::PopAndDestroy(&FieldVal); |
|
487 } |
|
488 |
|
489 /** |
|
490 * CHttpClient::GetCredentialsL |
|
491 * ask for username and password for authentification |
|
492 */ |
|
493 TBool CHttpClient::GetCredentialsL(const TUriC8& /*aURI*/, RString aRealm, |
|
494 RStringF /*aAuthenticationType*/, RString& aUsername, |
|
495 RString& aPassword) |
|
496 { |
|
497 if (iCredentialCount) |
|
498 { |
|
499 iCredentialCount = 0; |
|
500 User::Leave(KErrAccessDenied); |
|
501 } |
|
502 iCredentialCount++; |
|
503 aUsername = aRealm.Pool().OpenStringL(*iUser); |
|
504 aPassword = aRealm.Pool().OpenStringL(*iPassword); |
|
505 return ETrue; |
|
506 } |
|
507 |
|
508 /** |
|
509 * CHttpClient::GetEtagHeaderL |
|
510 * check for ETag and save it |
|
511 */ |
|
512 void CHttpClient::GetEtagHeaderL(RHTTPTransaction &aTransaction) |
|
513 { |
|
514 RStringF Header = aTransaction.Session().StringPool().StringF(HTTP::EETag, |
|
515 RHTTPSession::GetTable()); |
|
516 THTTPHdrVal HeaderVal; |
|
517 if (aTransaction.Response().GetHeaderCollection().GetField(Header, 0, |
|
518 HeaderVal) == KErrNone) |
|
519 { |
|
520 RStringF FieldValStr = aTransaction.Session().StringPool().StringF( |
|
521 HeaderVal.StrF()); |
|
522 const TDesC8 &FieldValDesC = FieldValStr.DesC(); |
|
523 delete iEtag; |
|
524 iEtag = NULL; |
|
525 iEtag = FieldValDesC.AllocL(); |
|
526 } |
|
527 } |
|
528 |
|
529 /** |
|
530 * CHttpClient::MHFRunL |
|
531 * http state machine callback |
|
532 */ |
|
533 void CHttpClient::MHFRunL(RHTTPTransaction aTransaction, |
|
534 const THTTPEvent& aEvent) |
|
535 { |
|
536 switch (aEvent.iStatus) |
|
537 { |
|
538 case THTTPEvent::EGotResponseHeaders: |
|
539 { |
|
540 // HTTP response headers have been received. We can determine now if there is |
|
541 // going to be a response body to save. |
|
542 RHTTPResponse resp = aTransaction.Response(); |
|
543 iReturnCode = resp.StatusCode(); |
|
544 |
|
545 if (iAction == EActionOption) |
|
546 { |
|
547 CalDavUtils::ScanAllowHeaderL(aTransaction, *iOptions); |
|
548 CalDavUtils::ScanDAVHeaderL(aTransaction, *iOptions); |
|
549 } |
|
550 |
|
551 GetEtagHeaderL(aTransaction); |
|
552 |
|
553 TBool cancelling = ETrue; |
|
554 if (resp.HasBody() && (iReturnCode >= OK) && (iReturnCode |
|
555 < MUTIPLECHOICES)) |
|
556 cancelling = EFalse; |
|
557 |
|
558 if (cancelling) |
|
559 { |
|
560 aTransaction.Close(); |
|
561 CActiveScheduler::Stop(); |
|
562 } |
|
563 } |
|
564 break; |
|
565 case THTTPEvent::EGotResponseBodyData: |
|
566 { |
|
567 // Get the body data supplier |
|
568 MHTTPDataSupplier* body = aTransaction.Response().Body(); |
|
569 TPtrC8 dataChunk; |
|
570 TBool isLast = body->GetNextDataPart(dataChunk); |
|
571 if (iBodyResponse) |
|
572 iBodyResponse->InsertL(iBodyResponse->Size(), dataChunk); |
|
573 // Done with that bit of body data |
|
574 body->ReleaseData(); |
|
575 } |
|
576 break; |
|
577 case THTTPEvent::EResponseComplete: |
|
578 { |
|
579 // The transaction's response is complete |
|
580 } |
|
581 break; |
|
582 case THTTPEvent::ESucceeded: |
|
583 { |
|
584 aTransaction.Close(); |
|
585 CActiveScheduler::Stop(); |
|
586 } |
|
587 break; |
|
588 case THTTPEvent::EFailed: |
|
589 { |
|
590 aTransaction.Close(); |
|
591 CActiveScheduler::Stop(); |
|
592 } |
|
593 break; |
|
594 case THTTPEvent::ERedirectedPermanently: |
|
595 { |
|
596 } |
|
597 break; |
|
598 case THTTPEvent::ERedirectedTemporarily: |
|
599 { |
|
600 } |
|
601 break; |
|
602 default: |
|
603 { |
|
604 // close off the transaction if it's an error |
|
605 if (aEvent.iStatus < 0) |
|
606 { |
|
607 iReturnCode = aEvent.iStatus; |
|
608 aTransaction.Close(); |
|
609 CActiveScheduler::Stop(); |
|
610 } |
|
611 } |
|
612 break; |
|
613 } |
|
614 } |
|
615 |
|
616 /** |
|
617 * CHttpClient::MHFRunError |
|
618 * http stack erros |
|
619 */ |
|
620 TInt CHttpClient::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, |
|
621 const THTTPEvent& /*aEvent*/) |
|
622 { |
|
623 iReturnCode = aError; |
|
624 return KErrNone; |
|
625 } |
|
626 |
|
627 /** |
|
628 * CHttpClient::SetUserL |
|
629 * set username for authentification |
|
630 */ |
|
631 void CHttpClient::SetUserL(const TDesC8 &aUser) |
|
632 { |
|
633 if (iUser) |
|
634 delete iUser; |
|
635 iUser = aUser.Alloc(); |
|
636 iSess.Close(); |
|
637 OpenSessionL(); |
|
638 } |
|
639 |
|
640 /** |
|
641 * CHttpClient::SetPasswordL |
|
642 * Set Password for authentification |
|
643 */ |
|
644 void CHttpClient::SetPasswordL(const TDesC8 &aPassword) |
|
645 { |
|
646 if (iPassword) |
|
647 delete iPassword; |
|
648 iPassword = aPassword.Alloc(); |
|
649 iSess.Close(); |
|
650 OpenSessionL(); |
|
651 } |
|
652 |
|
653 /** |
|
654 * CHttpClient::User |
|
655 * get username |
|
656 */ |
|
657 TPtrC8 CHttpClient::User() |
|
658 { |
|
659 return iUser ? *iUser : KNullDesC8(); |
|
660 } |
|
661 |
|
662 /** |
|
663 * CHttpClient::Password |
|
664 * get password |
|
665 */ |
|
666 TPtrC8 CHttpClient::Password() |
|
667 { |
|
668 return iPassword ? *iPassword : KNullDesC8(); |
|
669 } |
|
670 |
|
671 /** |
|
672 * CHttpClient::ReturnCode |
|
673 * get returned HTTP code |
|
674 */ |
|
675 TInt CHttpClient::ReturnCode() |
|
676 { |
|
677 return iReturnCode; |
|
678 } |
|
679 |
|
680 /** |
|
681 * CHttpClient::ETag |
|
682 * get ETag |
|
683 */ |
|
684 TPtrC8 CHttpClient::ETag() |
|
685 { |
|
686 return iEtag ? *iEtag : KNullDesC8(); |
|
687 } |