#ifndef LHFILEREMOTE_H
#define LHFILEREMOTE_H

#include <QString>

//class QFile;

struct SUsreDate
{
    char  btRequestType;//请求类型 0:获取授权令牌 1:任务请求 2:状态请求
    void* pOwner;
    QString strContent;
    char* buffer;
    int  buffersize;
};

struct SUpDownData
{
    char*    pBuffer;   //内存指针
    FILE*    pFile;     //文件指针
    qint64 llTotal;     //总共要写的字节
    qint64 llCurrent;   //当前写的字节
    long*    nProgress; //进度 0-100
    qint64 llBaseSize;  //开始写的基础位置(相对于总字节)
};

class CLHFileRemote
{
public:
    CLHFileRemote(void);
    ~CLHFileRemote(void);

    bool LoginServer(const QString& lpszPath, const QString& lpszUser, const QString& lpszPwd);
    size_t curl_ReceivePost(SUsreDate* ud);
    bool curl_Post(const QString& strUrl,const QString& strContent);
    bool curl_IsFileExist(const QString& strRemoteFile);
    bool curl_Upload(const char* szLocalFile, const char* szRemoteFile,const char* szUser,const char* szPwd);
    bool curl_Download(const char* szLocalFile, const char* szRemoteFile,const char* szUser,const char* szPwd,qint64 llSize,qint64 llEnd,bool bAppendFile,qint64 nTotal,qint64 nBaseSize,long& nProgress);
    qint64 curl_Read(char* pBuffer,const char* szRemoteFile,const char* szUser,const char* szPwd,qint64 llStart,qint64 llSize,long& nProgress);
    qint64 curl_GetFileLength(const char* szRemoteFile,const char* szUser,const char* szPwd);
    QString GetLastError() {return m_strError;}
protected:
    //CString UTF8ToGBK(CString str);
    //CString GBKToUTF8(CString& str);

    QString m_strError;
    char m_btCurlPASV;
public:
    QString m_strErrorPostContent;
};

#endif // LHFILEREMOTE_H