📄 httpclientengine.h
字号:
/*
* Copyright (c) 2007,苏州丰达
* All rights reserved.
* 版权所有(C)2007-2008 苏州丰达
* 公司地址:中国,江苏省苏州市
* 网址:http://www.
*
* 文件名称:CHTTPClientEngine.cpp
* 摘 要:
*
* 产品版本:彩视 1.0
*
* 作 者:xxxx
* 创建日期:xxxxx
* 负责人:xxxxx
*
* 修改者:司治国
* 修改日期:2008.1.17
*
* 编译器或环境等描述:uiqsdk2.1
* 适用于VC2003+symbian 7.x的环境开发。
*
**/
#ifndef HTTPEXAMPLEENGINE_H
#define HTTPEXAMPLEENGINE_H
// System includes
#include <http\mhttpdatasupplier.h>
#include <http\mhttptransactioncallback.h>
#include <http\RHTTPSession.h>
#include <http\RHTTPTransaction.h>
#include <http\mhttpauthenticationcallback.h>
#include <http\mhttpsessioneventcallback.h>
#include <chttpformencoder.h>
// CONSTANTS
class MHTTPClientEngineObserver
{
public:
virtual void ResponseStatusL(TInt aStatusCode, const TDesC &aStatusText) = 0;
virtual void ResponseReceivedL(const TDesC &aResponseBuffer) = 0;
virtual void ResponseReceivedDownL(const HBufC8 *aResponse) = 0;
};
class CHTTPClientEngine : public CBase, public MHTTPSessionEventCallback, public MHTTPTransactionCallback, public MHTTPDataSupplier, public MHTTPAuthenticationCallback
{
public:
static CHTTPClientEngine *NewL(MHTTPClientEngineObserver &aObserver);
~CHTTPClientEngine();
/*
* 事件动作类型
*/
typedef enum
{
EGeneral, EUp, EDown, ECheckUpdate, ERegister, EContinueUpload
} TActionOps;
/**
* 处理登录和检查更新
**/
void GetRequestL(const TDesC &aUri);
/**
* 处理上传下载
**/
void PostRequestL(const TDesC &aText, const TDesC *aPostContent, TActionOps);
/**
* 上传
**/
void PostUploadRequestL(const TDesC &aText, const TDesC *aFullPath, const TDesC *aPostContent, TInt aFsize, TInt aPos = 0, TInt aCatche = 0);
/**
* 下载
**/
void PostDownloadRequestL(const TDesC &aText, const TDesC &aFname);
void Cancel();
private: // from MHTTPTransactionCallback
virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
private:
CHTTPClientEngine(MHTTPClientEngineObserver &aObserver);
void ConstructL();
void ParseUriL(const TDesC &aUri);
void AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8 &aHeaderValue);
//clean prev Receive Data;
void ResetReceiveData();
public:
/**
* 用户启动时登陆
**/
void LunachRegister(TInt aUid);
/*
* 续传数据
*/
void ContinueUpload(TDesC* aUrl);
/*
* 检查更新
*/
void CheckUpdate();
private://from MHTTPDataSupplier
TBool GetNextDataPart(TPtrC8 &aDataPart);
TInt Reset();
TInt OverallDataSize();
void ReleaseData();
//from MHTTPSessionEventCallback
void MHFSessionRunL(const THTTPSessionEvent& aEvent);
TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);
private://from MHTTPAuthenticationCallback
/*
* 如果请求路径需要用户名和密码,有框架调用
*
* 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:
TUriParser8 iUriParser;
RHTTPSession iSession;
RHTTPTransaction iTransaction;
HBufC8 *iUri;
HBufC8 *iPostData;
HBufC8 *iResponseBuffer;
MHTTPClientEngineObserver &iObserver;
CHTTPFormEncoder *iFormEncoder;
TActionOps iAct;
TBuf16<256> iFileName;
TInt iFileSize;
TInt iPos;
TInt iCatche;
};
#endif // #ifndef HTTPEXAMPLEENGINE_H
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -