engine/src/HttpEventHandler.cpp
author Brendan Donegan <brendand@symbian.org>
Sat, 06 Mar 2010 10:28:29 +0000
changeset 36 e010fc411ddc
parent 2 29cda98b007e
child 60 4d230e702aa3
child 115 d87e984bd8b8
permissions -rw-r--r--
Merge, plus minor fix to CFeedEngine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
// HttpEventHandler.cpp
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include <e32debug.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include <httperr.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "HttpEventHandler.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include "bautils.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include "Httpclient.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
void CHttpEventHandler::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
	//iVerbose = ETrue;	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
CHttpEventHandler::CHttpEventHandler(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs): 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
	iFileServ(aFs), iHttpClient(aClient), iCallbacks(aCallbacks)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
CHttpEventHandler::~CHttpEventHandler()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
	{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
CHttpEventHandler* CHttpEventHandler::NewLC(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	CHttpEventHandler* me = new(ELeave)CHttpEventHandler(aClient, aCallbacks, aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	CleanupStack::PushL(me);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	me->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	return me;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
CHttpEventHandler* CHttpEventHandler::NewL(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	CHttpEventHandler* me = NewLC(aClient, aCallbacks, aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
	CleanupStack::Pop(me);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
	return me;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
void CHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	switch (aEvent.iStatus)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
		case THTTPEvent::EGotResponseHeaders:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
			// HTTP response headers have been received. We can determine now if there is
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
			// going to be a response body to save.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
			RHTTPResponse resp = aTransaction.Response();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
			iLastStatusCode = resp.StatusCode();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
			RStringF statusStr = resp.StatusText();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
			TBuf<32> statusStr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
			statusStr16.Copy(statusStr.DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
			DP2("Status: %d (%S)", iLastStatusCode, &statusStr16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
			// Dump the headers if we're being verbose
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
			//DumpRespHeadersL(aTransaction);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
			// Determine if the body will be saved to disk
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
			iSavingResponseBody = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
			TBool cancelling = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
			if (resp.HasBody() && (iLastStatusCode >= 200) && (iLastStatusCode < 300) && (iLastStatusCode != 204))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
				//iBytesDownloaded = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
				TInt dataSize = resp.Body()->OverallDataSize();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
				if (dataSize >= 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
					DP1("Response body size is %d", dataSize);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
					iBytesTotal = dataSize;	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
				} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
					DP("Response body size is unknown");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
					iBytesTotal = -1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
				iCallbacks.DownloadInfo(iHttpClient, dataSize);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
				cancelling = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
			// If we're cancelling, must do it now..
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
			if (cancelling)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
				DP("Transaction Cancelled");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
				aTransaction.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
				iHttpClient->ClientRequestCompleteL(KErrCancel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
			else if (iSavingResponseBody) // If we're saving, then open a file handle for the new file
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
				iFileServ.Parse(iFileName, iParsedFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
				TInt valid = iFileServ.IsValidName(iFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
				if (!valid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
					DP("The specified filename is not valid!.");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
					iSavingResponseBody = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
				else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
					if (iContinue) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
						TInt err = iRespBodyFile.Open(iFileServ, iParsedFileName.FullName(),EFileWrite);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
						if (err)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
							{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
							DP("There was an error opening file");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
							iSavingResponseBody = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
							User::Leave(err);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
							} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
							int pos = -KByteOverlap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
							if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
								DP("Failed to set position!");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
								User::Leave(err);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
							}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
							iBytesDownloaded = (pos > 0) ? pos : 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
							iBytesTotal += iBytesDownloaded;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
							DP1("Total bytes is now %u", iBytesTotal);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
							DP1("Seeking end: %d", pos);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
							}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
					} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
						TInt err = iRespBodyFile.Replace(iFileServ,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
														 iParsedFileName.FullName(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
														 EFileWrite);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
						if (err)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
							{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
							DP("There was an error replacing file");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
							iSavingResponseBody = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
							User::Leave(err);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
							}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
						}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
		case THTTPEvent::EGotResponseBodyData:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
			// Get the body data supplier
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
			iRespBody = aTransaction.Response().Body();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
			// Some (more) body data has been received (in the HTTP response)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
			//DumpRespBody(aTransaction);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
			//DP1("Saving: %d", iSavingResponseBody);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
			// Append to the output file if we're saving responses
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
			if (iSavingResponseBody)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
				TPtrC8 bodyData;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
				iRespBody->GetNextDataPart(bodyData);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
				iBytesDownloaded += bodyData.Length();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
				TInt error = iRespBodyFile.Write(bodyData);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
				// on writing error we close connection 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
				if (error != KErrNone) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
					//aTransaction.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
					iCallbacks.FileError(error);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
					iHttpClient->ClientRequestCompleteL(error);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
					return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
				if (!iSilent) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
					iCallbacks.Progress(iHttpClient, iBytesDownloaded, iBytesTotal);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
			// Done with that bit of body data
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
			iRespBody->ReleaseData();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
		case THTTPEvent::EResponseComplete:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
			// The transaction's response is complete
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
			DP("Transaction Complete");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
			DP("Closing file");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
			iRespBodyFile.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
		case THTTPEvent::ESucceeded:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
			DP("Transaction Successful");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
			aTransaction.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
			iHttpClient->ClientRequestCompleteL(KErrNone);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
		case THTTPEvent::EFailed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
			DP("Transaction Failed");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
			aTransaction.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
			if(iLastStatusCode == HTTPStatus::EOk || iLastStatusCode == HTTPStatus::ECreated || iLastStatusCode == HTTPStatus::EAccepted)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
				iLastStatusCode = KErrNone;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
			iHttpClient->ClientRequestCompleteL(iLastStatusCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
		case THTTPEvent::ERedirectedPermanently:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
			DP("Permanent Redirection");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
		case THTTPEvent::ERedirectedTemporarily:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
			DP("Temporary Redirection");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
			DP1("<unrecognised event: %d>", aEvent.iStatus);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
			// close off the transaction if it's an error
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
			if (aEvent.iStatus < 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
				aTransaction.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
				iHttpClient->ClientRequestCompleteL(aEvent.iStatus);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
			} break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
	DP1("MHFRunError fired with error code %d", aError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	return KErrNone;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
void CHttpEventHandler::SetSaveFileName(const TDesC &fName, TBool aContinue)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
	iFileName.Copy(fName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
	iContinue = aContinue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
void CHttpEventHandler::DumpRespHeadersL(RHTTPTransaction& aTrans)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
	RHTTPResponse resp = aTrans.Response();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
	RStringPool strP = aTrans.Session().StringPool();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
	RHTTPHeaders hdr = resp.GetHeaderCollection();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
	THTTPHdrFieldIter it = hdr.Fields();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
	TBuf<KMaxHeaderNameLen>  fieldName16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
	TBuf<KMaxHeaderValueLen> fieldVal16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
	while (it.AtEnd() == EFalse)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
		RStringTokenF fieldName = it();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
		RStringF fieldNameStr = strP.StringF(fieldName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
		THTTPHdrVal fieldVal;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
		if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
			const TDesC8& fieldNameDesC = fieldNameStr.DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
			fieldName16.Copy(fieldNameDesC.Left(KMaxHeaderNameLen));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
			switch (fieldVal.Type())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
			case THTTPHdrVal::KTIntVal:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
				DP2("%S: %d", &fieldName16, fieldVal.Int());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
			case THTTPHdrVal::KStrFVal:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
				RStringF fieldValStr = strP.StringF(fieldVal.StrF());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
				const TDesC8& fieldValDesC = fieldValStr.DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
				fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
				DP2("%S: %S", &fieldName16, &fieldVal16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
			case THTTPHdrVal::KStrVal:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
				RString fieldValStr = strP.String(fieldVal.Str());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
				const TDesC8& fieldValDesC = fieldValStr.DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
				fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
				DP2("%S: %S", &fieldName16, &fieldVal16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
			case THTTPHdrVal::KDateVal:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
				TDateTime date = fieldVal.DateTime();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
				} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
			default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
				DP1("%S: <unrecognised value type>", &fieldName16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   290
			// Display realm for WWW-Authenticate header
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
			RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
			if (fieldNameStr == wwwAuth)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
				// check the auth scheme is 'basic'
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
				RStringF basic = strP.StringF(HTTP::EBasic,RHTTPSession::GetTable());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
				RStringF realm = strP.StringF(HTTP::ERealm,RHTTPSession::GetTable());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   297
				THTTPHdrVal realmVal;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   298
				if ((fieldVal.StrF() == basic) && 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   299
					(!hdr.GetParam(wwwAuth, realm, realmVal)))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   301
					RStringF realmValStr = strP.StringF(realmVal.StrF());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
					fieldVal16.Copy(realmValStr.DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
					DP1("Realm is: %S", &fieldVal16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
		++it;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   308
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   310
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   311
void CHttpEventHandler::DumpRespBody(RHTTPTransaction& aTrans)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   312
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
	MHTTPDataSupplier* body = aTrans.Response().Body();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
	TPtrC8 dataChunk;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
	TBool isLast = body->GetNextDataPart(dataChunk);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   316
	DumpIt(dataChunk);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
	if (isLast)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   318
		DP("Got last data chunk.");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   319
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
void CHttpEventHandler::DumpIt(const TDesC8& aData)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   323
//Do a formatted dump of binary data
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   324
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   325
	// Iterate the supplied block of data in blocks of cols=80 bytes
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   326
	const TInt cols=16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   327
	TInt pos = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
	TBuf<KMaxFileName - 2> logLine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
	TBuf<KMaxFileName - 2> anEntry;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
	const TInt dataLength = aData.Length();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
	while (pos < dataLength)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   334
		//start-line hexadecimal( a 4 digit number)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   335
		anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
		logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   337
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   338
		// Hex output
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   339
		TInt offset;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   340
		for (offset = 0; offset < cols; ++offset)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   341
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
			if (pos + offset < aData.Length())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   344
				TInt nextByte = aData[pos + offset];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
				anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
				logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
			else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   350
				//fill the remaining spaces with blanks untill the cols-th Hex number 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   351
				anEntry.Format(TRefByValue<const TDesC>_L("   "));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   352
				logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   354
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   355
			anEntry.Format(TRefByValue<const TDesC>_L(": "));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   356
			logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   357
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   358
		// Char output
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   359
		for (offset = 0; offset < cols; ++offset)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
			if (pos + offset < aData.Length())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
				TInt nextByte = aData[pos + offset];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
				if ((nextByte >= ' ') && (nextByte <= '~'))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   366
					anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   367
					logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   368
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
				else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   370
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   371
					anEntry.Format(TRefByValue<const TDesC>_L("."));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   372
					logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   373
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   374
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
			else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
				anEntry.Format(TRefByValue<const TDesC>_L(" "));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
				logLine.Append(anEntry);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   381
			logLine.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   382
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
		// Advance to next  byte segment (1 seg= cols)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   384
		pos += cols;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   385
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   386
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   387
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   388
void CHttpEventHandler::SetSilent(TBool aSilent)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   389
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   390
	iSilent = aSilent;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   391
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   392
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   393
void CHttpEventHandler::CloseSaveFile()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   394
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   395
	if(iRespBody != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   396
	{		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   397
		if(iRespBodyFile.SubSessionHandle() != 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   398
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   399
			TInt size;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   400
			iRespBodyFile.Size(size);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   401
			DP2("Closing file at size %d, bytes downloaded %d", size, iBytesDownloaded);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   402
			iRespBodyFile.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   403
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   404
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   405
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   406