~ubuntu-branches/debian/experimental/nzbget/experimental

« back to all changes in this revision

Viewing changes to WebDownloader.h

  • Committer: Package Import Robot
  • Author(s): Andreas Moog
  • Date: 2014-12-25 12:58:06 UTC
  • mfrom: (1.2.1) (3.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20141225125806-vnzgajhm7mju9933
Tags: 14.1+dfsg-1
* New Upstream release (Closes: #768863)
* debian/patches:
  - Remove 0010_unnecessary_gcryptdep.patch, included upstream
  - Refresh remaining patches
* debian/control:
  - Remove no longer needed build-depends on libpar2-dev and libsigc++-dev
* debian/nzbget.conf
  - Update sample configuration file to include new options introduced by
    new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  This file is part of nzbget
3
 
 *
4
 
 *  Copyright (C) 2012 Andrey Prygunkov <hugbug@users.sourceforge.net>
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
 
 *
20
 
 * $Revision: 456 $
21
 
 * $Date: 2012-08-06 22:32:48 +0200 (Mon, 06 Aug 2012) $
22
 
 *
23
 
 */
24
 
 
25
 
 
26
 
#ifndef WEBDOWNLOADER_H
27
 
#define WEBDOWNLOADER_H
28
 
 
29
 
#include <time.h>
30
 
 
31
 
#include "Observer.h"
32
 
#include "Thread.h"
33
 
#include "Connection.h"
34
 
#include "Util.h"
35
 
 
36
 
class WebDownloader : public Thread, public Subject
37
 
{
38
 
public:
39
 
        enum EStatus
40
 
        {
41
 
                adUndefined,
42
 
                adRunning,
43
 
                adFinished,
44
 
                adFailed,
45
 
                adRetry,
46
 
                adNotFound,
47
 
                adConnectError,
48
 
                adFatalError
49
 
        };
50
 
                        
51
 
private:
52
 
        char*                           m_szURL;
53
 
        char*                           m_szOutputFilename;
54
 
        Connection*             m_pConnection;
55
 
        Mutex                           m_mutexConnection;
56
 
        EStatus                         m_eStatus;
57
 
        time_t                          m_tLastUpdateTime;
58
 
        char*                           m_szInfoName;
59
 
        FILE*                           m_pOutFile;
60
 
        int                                     m_iContentLen;
61
 
        bool                            m_bConfirmedLength;
62
 
        char*                           m_szOriginalFilename;
63
 
        bool                            m_bGZip;
64
 
#ifndef DISABLE_GZIP
65
 
        GUnzipStream*           m_pGUnzipStream;
66
 
#endif
67
 
 
68
 
        void                            SetStatus(EStatus eStatus);
69
 
        bool                            Write(void* pBuffer, int iLen);
70
 
        bool                            PrepareFile();
71
 
        void                            FreeConnection();
72
 
        EStatus                         CheckResponse(const char* szResponse);
73
 
        EStatus                         Download();
74
 
        EStatus                         CreateConnection(URL *pUrl);
75
 
        void                            ParseFilename(const char* szContentDisposition);
76
 
        void                            SendHeaders(URL *pUrl);
77
 
        EStatus                         DownloadHeaders();
78
 
        EStatus                         DownloadBody();
79
 
 
80
 
protected:
81
 
        virtual void            ProcessHeader(const char* szLine);
82
 
 
83
 
public:
84
 
                                                WebDownloader();
85
 
                                                ~WebDownloader();
86
 
        EStatus                         GetStatus() { return m_eStatus; }
87
 
        virtual void            Run();
88
 
        virtual void            Stop();
89
 
        bool                            Terminate();
90
 
        void                            SetInfoName(const char* v);
91
 
        const char*                     GetInfoName() { return m_szInfoName; }
92
 
        void                            SetURL(const char* szURL);
93
 
        const char*                     GetOutputFilename() { return m_szOutputFilename; }
94
 
        void                            SetOutputFilename(const char* v);
95
 
        time_t                          GetLastUpdateTime() { return m_tLastUpdateTime; }
96
 
        void                            SetLastUpdateTimeNow() { m_tLastUpdateTime = ::time(NULL); }
97
 
        bool                            GetConfirmedLength() { return m_bConfirmedLength; }
98
 
        const char*                     GetOriginalFilename() { return m_szOriginalFilename; }
99
 
 
100
 
        void                            LogDebugInfo();
101
 
};
102
 
 
103
 
#endif