#ifndef SCURL_H
#define SCURL_H

#include <QObject>
#include <QTimer>

#include "curl/curl.h"

class SCURL : public QObject
{
    Q_OBJECT
public:
    SCURL();

    virtual ~SCURL();

    static void Init();
    static void Release();

    static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream);

    int UploadFTP(QString strFilename);

    int UploadFTP2(QString strFilename);

    void StopCURL();

    curl_socket_t m_SocketFD;


    static int CurlProgress(void *clientp,   curl_off_t dltotal,   curl_off_t dlnow,   curl_off_t ultotal,   curl_off_t ulnow);

    static bool IsConnectNetwork();


signals:
    void SetProgressExportPercent(quint64 nCurrent, quint64 nTotal);

public slots:
    void OnTimer();

protected:
    static int m_nUsage;

    static quint64 m_nFileSize;
    static quint64 m_nCurrentRead;

    CURL* m_pCURL;

    QTimer m_Timer;

    static int m_nPrevCount;
    static int m_nErrorCount;

    bool m_bStop;

};

#endif // SCURL_H
