~ubuntu-branches/ubuntu/saucy/apt-cacher-ng/saucy

« back to all changes in this revision

Viewing changes to include/dljob.h

  • Committer: Bazaar Package Importer
  • Author(s): Eduard Bloch
  • Date: 2011-08-07 17:53:21 UTC
  • mfrom: (24.2.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110807175321-k80jrotzovldgu3c
* New upstream version
  + fixes various regressions
* removed dependency on libfuse2 (now used via dlopen, moved to Suggests)
* support new build-* targets in rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef DLJOB_H_
2
 
#define DLJOB_H_
3
 
 
4
 
#include "meta.h"
5
 
#include "fileitem.h"
6
 
#include "acfg.h"
7
 
#include "acbuf.h"
8
 
 
9
 
class dlcon;
10
 
 
11
 
class tDlJob
12
 
{
13
 
public:
14
 
        
15
 
        bool bSuggestReconnect, bRequestEnqueued;
16
 
        
17
 
        inline bool HasBrokenStorage()
18
 
        {
19
 
                return (!m_pStorage || m_pStorage->GetStatus() >= FIST_ERROR);  
20
 
        }
21
 
        
22
 
    typedef enum {
23
 
        R_DONE, // 0
24
 
        R_MOREINPUT, //1
25
 
        R_SKIPITEM, //2
26
 
        R_ERROR_REMOTE, //3
27
 
        R_ERROR_LOCAL, //4
28
 
        R_NOOP, // 5
29
 
        R_NEXTSTATE // 6
30
 
    } tDlResult;
31
 
 
32
 
    tDlResult ProcessIncomming(acbuf & inBuf, mstring & sErrorRet);
33
 
 
34
 
        tDlJob(dlcon *m, tFileItemPtr pFi, const mstring & sHost,
35
 
                        const mstring & sPath);
36
 
        tDlJob(dlcon *m, tFileItemPtr pFi, acfg::tRepoData * pBackends,
37
 
                        const mstring & sPath);
38
 
        virtual ~tDlJob();
39
 
        
40
 
 
41
 
        void UnregDownloader(const mstring &sError);
42
 
    void BlacklistBackend();
43
 
        
44
 
        bool FindConfig();
45
 
        
46
 
        // needs connectedHost, blacklist, output buffer from the parent, proxy mode?
47
 
        bool AppendRequest(mstring sForThisHostOnly, tSS &head, const tHttpUrl * pProxy);
48
 
 
49
 
        inline bool HasStarted() { return m_DlState>STATE_GETHEADER; }
50
 
 
51
 
        inline const mstring GetPeerName()
52
 
        {
53
 
                return m_pBackend ? m_pBackend->sHost : m_fileUri.sHost;
54
 
        }
55
 
    mstring RemoteUri();
56
 
    mstring RemotePath();
57
 
    
58
 
    acfg::tRepoData::IHookHandler * GetConnStateObserver();
59
 
 
60
 
protected:
61
 
        
62
 
        /**
63
 
         * Called by the state machine when receiveing the data, allows the subclass to reimplement it.
64
 
         * 
65
 
         * @return: R_NEXTSTATE -> caller should switch state
66
 
         *                      anything else: return that value
67
 
         * */
68
 
        virtual tDlResult NewDataHandler(acbuf & inBuf, mstring &sErrorRet);
69
 
        
70
 
    typedef enum {
71
 
                STATE_GETHEADER
72
 
                ,STATE_GETDATA
73
 
                ,STATE_GETDATA_CHUNKED
74
 
                ,STATE_GETCHUNKHEAD
75
 
                ,STATE_FINISHJOB
76
 
        } tDlState;
77
 
 
78
 
        acfg::tRepoData * m_pHostiVec;
79
 
        tFileItemPtr m_pStorage;
80
 
        dlcon *m_parent;
81
 
        
82
 
        tHttpUrl m_fileUri, *m_pBackend;
83
 
        
84
 
        bool m_bReconnectASAP;
85
 
        
86
 
        off_t m_nRest;
87
 
        
88
 
        tDlState m_DlState;
89
 
        void _Init();
90
 
        
91
 
        // not to be copied
92
 
        tDlJob(const tDlJob&);
93
 
        tDlJob & operator=(const tDlJob&);
94
 
};
95
 
 
96
 
#endif /*DLJOB_H_*/