📄 httpxxxtools.h
字号:
/*
============================================================================
Name : HttpxxxTools.h
Author : xxx
Version : 1.0
Copyright : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Description : CHttpxxxTools declaration
============================================================================
*/
#ifndef HTTPXXXTOOLS_H
#define HTTPXXXTOOLS_H
// INCLUDES
#include <e32std.h>
#include <ES_SOCK.H>
#include <e32base.h>
#include <mhttptransactioncallback.h>
#include <mhttpdatasupplier.h>
#include <mhttpauthenticationcallback.h>
//#include <>
// CLASS DECLARATION
/**
* CHttpxxxTools
*
*/
class MHttpDataHandleObserver
{
public:
virtual void WriteDAtaToFile(char* aFileName, char* aFileData, int aFiledDataLenth) = 0;
virtual void WriteNULL() = 0;
};
class RHTTPSession;
class RHTTPTransaction;
class RSocketServ;
class RConnection;
class CImageTestAppView;
class CHttpxxxTools : public CBase,
public MHTTPTransactionCallback,
public MHTTPDataSupplier,
public MHTTPAuthenticationCallback
{
public:
// Constructors and destructor
/**
* Destructor.
*/
~CHttpxxxTools();
/**
* Two-phased constructor.
*/
static CHttpxxxTools* NewL(MHttpDataHandleObserver& aObserver);
/**
* Two-phased constructor.
*/
static CHttpxxxTools* NewLC(MHttpDataHandleObserver& aObserver);
void IssueHTTPGetL(const TDesC8& aUri);
// to get
void HttpGet(char* uri);
void IssueHTTPPostL(const TDesC8& aUri,
const TDesC8& aContentType,
const TDesC8& aBody);
// to post
void HttpPost(char* uri,char* contenttype, char* body);
// to cancel trasaction
void CancelTransaction();
//
void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField,
const TDesC8& aHdrValue);
private:
/**
* Constructor for performing 1st stage construction
*/
CHttpxxxTools(MHttpDataHandleObserver& aObserver);
/**
* EPOC default constructor for performing 2nd stage construction
*/
void ConstructL();
/*
* SetupConnectionL()
*
* The method set the internet access point and connection setups.
*
*/
void SetupConnectionL();
//inherit from MHTTPDataSupplier
private:
/*
* ReleaseData()
*
* Called by framework to allow data supplier to release resources
* related to previous data part.
*
* Params:
* -
*
* Returns:
* -
*
*/
void ReleaseData();
/*
* GetNextDataPart()
*
* Called when next data part is needed.
*
* Params:
* aDataPart: Must be set to point to the next data part.
*
* Returns:
* ETrue if the provided data part is the last one. If more data parts
* are needed after the provided one, return EFalse.
*
*/
TBool GetNextDataPart(TPtrC8& aDataPart);
/*
* Reset()
*
* Called by framework to reset the data supplier to its initial state.
*
* Params:
* -
*
* Returns:
* KErrNone if successfull.
*
*/
TInt Reset();
/*
* OverallDataSize()
*
* Called by framework when it needs to know the size of the
* body data.
*
* Params:
* -
*
* Returns:
* Size of the data, or KErrNotFound (or KErrNotSupported)
* if the size of the data is not known.
*
*/
TInt OverallDataSize();
//inherit from MHTTPTransactionCallback
private:
void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
TInt MHFRunError( TInt aError,
RHTTPTransaction aTransaction,
const THTTPEvent& aEvent);
/*
* From MHTTPAuthenticationCallback (needed for HTTP authentication)
*/
private:
/*
* GetCredentialsL()
*
* Called by framework when username and password for requested URI is
* needed.
*
* Params:
* aURI: The URI being requested (e.g. "http://host.org")
* aRealm: The realm being requested (e.g. "user@host.org")
* aAuthenticationType: Authentication type. (e.g. "Basic")
* aUsername: Given user name.
* aPassword: Given password.
*
* Returns:
* A pointer to the created document
*
*/
TBool GetCredentialsL( const TUriC8& aURI,
RString aRealm,
RStringF aAuthenticationType,
RString& aUsername,
RString& aPassword);
private:
#ifdef __WINS__
RSocketServ iSocketServ;
RConnection iConnection;
#endif
RHTTPSession iSession;
RHTTPTransaction iTransaction;
HBufC8* iPostData; // Data for HTTP POST
TBool iRunning; // ETrue, if transaction running
TBool iConnectionSetupDone;
HBufC8* iBodyData;
MHttpDataHandleObserver& iObserver;
};
#endif // HTTPXXXTOOLS_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -