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

« back to all changes in this revision

Viewing changes to .pc/fix_fsf_address.patch/DownloadInfo.h

  • Committer: Package Import Robot
  • Author(s): Andreas Moog
  • Date: 2013-07-18 14:50:28 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130718145028-qhxse81w1sj5w424
Tags: 11.0+dfsg-1
* New upstream release (Closes: #701896)
* Repackage original tarball to remove copies of jquery and twitter-
  bootstrap
* debian/watch: Update for new versioning scheme
* debian/patches: Remove all old patches, add one patch:
  - dont-embed-libraries.patch: Don't install embedded jquery and bootstrap 
    libraries
* debian/combat: Upgrade to debhelper combat 9
* debian/control:
  - Fix Vcs-Git field
  - Adjust debhelper version for combat level 9
  - Add jquery and bootstrap to depends for integrated webserver
  - Add python to recommends for post-processing scripts
  - Bump build-depends on libpar2-dev to support the cancel function
* debian/links:
  - Use the system jquery and bootstrap libraries
* debian/rules:
  - Add get-orig-source target to build modified upstream tarball
* Adjust sample nzbget.conf:
  - Only listen to 127.0.0.1 instead of 0.0.0.0
  - Use nzbget.conf as template for webui configuration
* Adjust sample nzbgetd init file:
  - Point to correct location of nzbget binary

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  This file is part of nzbget
3
 
 *
4
 
 *  Copyright (C) 2004 Sven Henkel <sidddy@users.sourceforge.net>
5
 
 *  Copyright (C) 2007-2010 Andrei Prygounkov <hugbug@users.sourceforge.net>
6
 
 *
7
 
 *  This program is free software; you can redistribute it and/or modify
8
 
 *  it under the terms of the GNU General Public License as published by
9
 
 *  the Free Software Foundation; either version 2 of the License, or
10
 
 *  (at your option) any later version.
11
 
 *
12
 
 *  This program is distributed in the hope that it will be useful,
13
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details.
16
 
 *
17
 
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 *
21
 
 * $Revision: 378 $
22
 
 * $Date: 2010-01-29 10:34:44 +0100 (Fri, 29 Jan 2010) $
23
 
 *
24
 
 */
25
 
 
26
 
 
27
 
#ifndef DOWNLOADINFO_H
28
 
#define DOWNLOADINFO_H
29
 
 
30
 
#include <vector>
31
 
#include <deque>
32
 
#include <time.h>
33
 
 
34
 
#include "Log.h"
35
 
#include "Thread.h"
36
 
 
37
 
class NZBInfo;
38
 
class DownloadQueue;
39
 
 
40
 
class ArticleInfo
41
 
{
42
 
public:
43
 
        enum EStatus
44
 
        {
45
 
                aiUndefined,
46
 
                aiRunning,
47
 
                aiFinished,
48
 
                aiFailed
49
 
        };
50
 
        
51
 
private:
52
 
        int                                     m_iPartNumber;
53
 
        char*                           m_szMessageID;
54
 
        int                                     m_iSize;
55
 
        EStatus                         m_eStatus;
56
 
        char*                           m_szResultFilename;
57
 
 
58
 
public:
59
 
                                                ArticleInfo();
60
 
                                                ~ArticleInfo();
61
 
        void                            SetPartNumber(int s) { m_iPartNumber = s; }
62
 
        int                             GetPartNumber() { return m_iPartNumber; }
63
 
        const char*             GetMessageID() { return m_szMessageID; }
64
 
        void                            SetMessageID(const char* szMessageID);
65
 
        void                            SetSize(int s) { m_iSize = s; }
66
 
        int                             GetSize() { return m_iSize; }
67
 
        EStatus                         GetStatus() { return m_eStatus; }
68
 
        void                            SetStatus(EStatus Status) { m_eStatus = Status; }
69
 
        const char*                     GetResultFilename() { return m_szResultFilename; }
70
 
        void                            SetResultFilename(const char* v);
71
 
};
72
 
 
73
 
class FileInfo
74
 
{
75
 
public:
76
 
        typedef std::vector<ArticleInfo*>       Articles;
77
 
        typedef std::vector<char*>                      Groups;
78
 
 
79
 
private:
80
 
        int                                     m_iID;
81
 
        NZBInfo*                        m_pNZBInfo;
82
 
        Articles                        m_Articles;
83
 
        Groups                          m_Groups;
84
 
        char*                           m_szSubject;
85
 
        char*                           m_szFilename;
86
 
        long long                       m_lSize;
87
 
        long long                       m_lRemainingSize;
88
 
        time_t                          m_tTime;
89
 
        bool                            m_bPaused;
90
 
        bool                            m_bDeleted;
91
 
        bool                            m_bFilenameConfirmed;
92
 
        int                                     m_iCompleted;
93
 
        bool                            m_bOutputInitialized;
94
 
        Mutex                           m_mutexOutputFile;
95
 
 
96
 
        static int                      m_iIDGen;
97
 
 
98
 
public:
99
 
                                                FileInfo();
100
 
                                                ~FileInfo();
101
 
        int                                     GetID() { return m_iID; }
102
 
        void                            SetID(int s);
103
 
        NZBInfo*                        GetNZBInfo() { return m_pNZBInfo; }
104
 
        void                            SetNZBInfo(NZBInfo* pNZBInfo);
105
 
        Articles*                       GetArticles() { return &m_Articles; }
106
 
        Groups*                         GetGroups() { return &m_Groups; }
107
 
        const char*                     GetSubject() { return m_szSubject; }
108
 
        void                            SetSubject(const char* szSubject);
109
 
        const char*                     GetFilename() { return m_szFilename; }
110
 
        void                            SetFilename(const char* szFilename);
111
 
        void                            MakeValidFilename();
112
 
        bool                            GetFilenameConfirmed() { return m_bFilenameConfirmed; }
113
 
        void                            SetFilenameConfirmed(bool bFilenameConfirmed) { m_bFilenameConfirmed = bFilenameConfirmed; }
114
 
        void                            SetSize(long long s) { m_lSize = s; m_lRemainingSize = s; }
115
 
        long long                       GetSize() { return m_lSize; }
116
 
        long long                       GetRemainingSize() { return m_lRemainingSize; }
117
 
        void                            SetRemainingSize(long long s) { m_lRemainingSize = s; }
118
 
        time_t                          GetTime() { return m_tTime; }
119
 
        void                            SetTime(time_t tTime) { m_tTime = tTime; }
120
 
        bool                            GetPaused() { return m_bPaused; }
121
 
        void                            SetPaused(bool Paused) { m_bPaused = Paused; }
122
 
        bool                            GetDeleted() { return m_bDeleted; }
123
 
        void                            SetDeleted(bool Deleted) { m_bDeleted = Deleted; }
124
 
        int                                     GetCompleted() { return m_iCompleted; }
125
 
        void                            SetCompleted(int s) { m_iCompleted = s; }
126
 
        void                            ClearArticles();
127
 
        void                            LockOutputFile();
128
 
        void                            UnlockOutputFile();
129
 
        bool                            GetOutputInitialized() { return m_bOutputInitialized; }
130
 
        void                            SetOutputInitialized(bool bOutputInitialized) { m_bOutputInitialized = bOutputInitialized; }
131
 
        bool                            IsDupe(const char* szFilename);
132
 
};
133
 
                              
134
 
typedef std::deque<FileInfo*> FileQueue;
135
 
 
136
 
class GroupInfo
137
 
{
138
 
private:
139
 
        NZBInfo*                        m_pNZBInfo;
140
 
        int                                     m_iFirstID;
141
 
        int                                     m_iLastID;
142
 
        int                                     m_iRemainingFileCount;
143
 
        int                                     m_iPausedFileCount;
144
 
        long long                       m_lRemainingSize;
145
 
        long long                       m_lPausedSize;
146
 
        int                                     m_iRemainingParCount;
147
 
        time_t                          m_tMinTime;
148
 
        time_t                          m_tMaxTime;
149
 
 
150
 
        friend class DownloadQueue;
151
 
 
152
 
public:
153
 
                                                GroupInfo();
154
 
                                                ~GroupInfo();
155
 
        NZBInfo*                        GetNZBInfo() { return m_pNZBInfo; }
156
 
        int                                     GetFirstID() { return m_iFirstID; }
157
 
        int                                     GetLastID() { return m_iLastID; }
158
 
        long long                       GetRemainingSize() { return m_lRemainingSize; }
159
 
        long long                       GetPausedSize() { return m_lPausedSize; }
160
 
        int                                     GetRemainingFileCount() { return m_iRemainingFileCount; }
161
 
        int                                     GetPausedFileCount() { return m_iPausedFileCount; }
162
 
        int                                     GetRemainingParCount() { return m_iRemainingParCount; }
163
 
        time_t                          GetMinTime() { return m_tMinTime; }
164
 
        time_t                          GetMaxTime() { return m_tMaxTime; }
165
 
};
166
 
 
167
 
typedef std::deque<GroupInfo*> GroupQueue;
168
 
 
169
 
class NZBParameter
170
 
{
171
 
private:
172
 
        char*                           m_szName;
173
 
        char*                           m_szValue;
174
 
 
175
 
        void                            SetValue(const char* szValue);
176
 
 
177
 
        friend class NZBParameterList;
178
 
 
179
 
public:
180
 
                                                NZBParameter(const char* szName);
181
 
                                                ~NZBParameter();
182
 
        const char*                     GetName() { return m_szName; }
183
 
        const char*                     GetValue() { return m_szValue; }
184
 
};
185
 
 
186
 
typedef std::deque<NZBParameter*> NZBParameterListBase;
187
 
 
188
 
class NZBParameterList : public NZBParameterListBase
189
 
{
190
 
public:
191
 
        void                            SetParameter(const char* szName, const char* szValue);
192
 
};
193
 
 
194
 
class NZBInfoList;
195
 
 
196
 
class NZBInfo
197
 
{
198
 
public:
199
 
        enum EParStatus
200
 
        {
201
 
                prNone,
202
 
                prFailure,
203
 
                prRepairPossible,
204
 
                prSuccess
205
 
        };
206
 
 
207
 
        enum EScriptStatus
208
 
        {
209
 
                srNone,
210
 
                srUnknown,
211
 
                srFailure,
212
 
                srSuccess
213
 
        };
214
 
 
215
 
        typedef std::vector<char*>                      Files;
216
 
        typedef std::deque<Message*>            Messages;
217
 
 
218
 
private:
219
 
        int                                     m_iID;
220
 
        int                                     m_iRefCount;
221
 
        char*                           m_szFilename;
222
 
        char*                           m_szDestDir;
223
 
        char*                           m_szCategory;
224
 
        int                                     m_iFileCount;
225
 
        int                                     m_iParkedFileCount;
226
 
        long long                       m_lSize;
227
 
        Files                           m_completedFiles;
228
 
        bool                            m_bPostProcess;
229
 
        EParStatus                      m_eParStatus;
230
 
        EScriptStatus           m_eScriptStatus;
231
 
        char*                           m_szQueuedFilename;
232
 
        bool                            m_bDeleted;
233
 
        bool                            m_bParCleanup;
234
 
        bool                            m_bCleanupDisk;
235
 
        time_t                          m_tHistoryTime;
236
 
        NZBInfoList*            m_Owner;
237
 
        NZBParameterList        m_ppParameters;
238
 
        Mutex                           m_mutexLog;
239
 
        Messages                        m_Messages;
240
 
        int                                     m_iIDMessageGen;
241
 
 
242
 
        static int                      m_iIDGen;
243
 
 
244
 
        friend class NZBInfoList;
245
 
 
246
 
public:
247
 
                                                NZBInfo();
248
 
                                                ~NZBInfo();
249
 
        void                            AddReference();
250
 
        void                            Release();
251
 
        int                                     GetID() { return m_iID; }
252
 
        const char*                     GetFilename() { return m_szFilename; }
253
 
        void                            SetFilename(const char* szFilename);
254
 
        void                            GetNiceNZBName(char* szBuffer, int iSize);
255
 
        static void                     MakeNiceNZBName(const char* szNZBFilename, char* szBuffer, int iSize);
256
 
        const char*                     GetDestDir() { return m_szDestDir; }   // needs locking (for shared objects)
257
 
        void                            SetDestDir(const char* szDestDir);     // needs locking (for shared objects)
258
 
        const char*                     GetCategory() { return m_szCategory; } // needs locking (for shared objects)
259
 
        void                            SetCategory(const char* szCategory);   // needs locking (for shared objects)
260
 
        long long                       GetSize() { return m_lSize; }
261
 
        void                            SetSize(long long lSize) { m_lSize = lSize; }
262
 
        int                                     GetFileCount() { return m_iFileCount; }
263
 
        void                            SetFileCount(int iFileCount) { m_iFileCount = iFileCount; }
264
 
        int                                     GetParkedFileCount() { return m_iParkedFileCount; }
265
 
        void                            SetParkedFileCount(int iParkedFileCount) { m_iParkedFileCount = iParkedFileCount; }
266
 
        void                            BuildDestDirName();
267
 
        Files*                          GetCompletedFiles() { return &m_completedFiles; }               // needs locking (for shared objects)
268
 
        void                            ClearCompletedFiles();
269
 
        bool                            GetPostProcess() { return m_bPostProcess; }
270
 
        void                            SetPostProcess(bool bPostProcess) { m_bPostProcess = bPostProcess; }
271
 
        EParStatus                      GetParStatus() { return m_eParStatus; }
272
 
        void                            SetParStatus(EParStatus eParStatus) { m_eParStatus = eParStatus; }
273
 
        EScriptStatus           GetScriptStatus() { return m_eScriptStatus; }
274
 
        void                            SetScriptStatus(EScriptStatus eScriptStatus) { m_eScriptStatus = eScriptStatus; }
275
 
        const char*                     GetQueuedFilename() { return m_szQueuedFilename; }
276
 
        void                            SetQueuedFilename(const char* szQueuedFilename);
277
 
        bool                            GetDeleted() { return m_bDeleted; }
278
 
        void                            SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
279
 
        bool                            GetParCleanup() { return m_bParCleanup; }
280
 
        void                            SetParCleanup(bool bParCleanup) { m_bParCleanup = bParCleanup; }
281
 
        bool                            GetCleanupDisk() { return m_bCleanupDisk; }
282
 
        void                            SetCleanupDisk(bool bCleanupDisk) { m_bCleanupDisk = bCleanupDisk; }
283
 
        time_t                          GetHistoryTime() { return m_tHistoryTime; }
284
 
        void                            SetHistoryTime(time_t tHistoryTime) { m_tHistoryTime = tHistoryTime; }
285
 
        NZBParameterList*       GetParameters() { return &m_ppParameters; }                             // needs locking (for shared objects)
286
 
        void                            SetParameter(const char* szName, const char* szValue);  // needs locking (for shared objects)
287
 
        void                            AppendMessage(Message::EKind eKind, time_t tTime, const char* szText);
288
 
        Messages*                       LockMessages();
289
 
        void                            UnlockMessages();
290
 
};
291
 
 
292
 
typedef std::deque<NZBInfo*> NZBInfoListBase;
293
 
 
294
 
class NZBInfoList : public NZBInfoListBase
295
 
{
296
 
public:
297
 
        void                            Add(NZBInfo* pNZBInfo);
298
 
        void                            Remove(NZBInfo* pNZBInfo);
299
 
        void                            ReleaseAll();
300
 
};
301
 
 
302
 
class PostInfo
303
 
{
304
 
public:
305
 
        enum EStage
306
 
        {
307
 
                ptQueued,
308
 
                ptLoadingPars,
309
 
                ptVerifyingSources,
310
 
                ptRepairing,
311
 
                ptVerifyingRepaired,
312
 
                ptExecutingScript,
313
 
                ptFinished
314
 
        };
315
 
 
316
 
        enum EParStatus
317
 
        {
318
 
                psNone,
319
 
                psFailure,
320
 
                psSuccess,
321
 
                psRepairPossible
322
 
        };
323
 
 
324
 
        enum ERequestParCheck
325
 
        {
326
 
                rpNone,
327
 
                rpCurrent,
328
 
                rpAll
329
 
        };
330
 
 
331
 
        enum EScriptStatus
332
 
        {
333
 
                srNone,
334
 
                srUnknown,
335
 
                srFailure,
336
 
                srSuccess
337
 
        };
338
 
 
339
 
        typedef std::deque<Message*>    Messages;
340
 
 
341
 
private:
342
 
        int                                     m_iID;
343
 
        NZBInfo*                        m_pNZBInfo;
344
 
        char*                           m_szParFilename;
345
 
        char*                           m_szInfoName;
346
 
        bool                            m_bWorking;
347
 
        bool                            m_bDeleted;
348
 
        bool                            m_bParCheck;
349
 
        EParStatus                      m_eParStatus;
350
 
        EScriptStatus           m_eScriptStatus;
351
 
        ERequestParCheck        m_eRequestParCheck;
352
 
        EStage                          m_eStage;
353
 
        char*                           m_szProgressLabel;
354
 
        int                                     m_iFileProgress;
355
 
        int                                     m_iStageProgress;
356
 
        time_t                          m_tStartTime;
357
 
        time_t                          m_tStageTime;
358
 
        Thread*                         m_pScriptThread;
359
 
        
360
 
        Mutex                           m_mutexLog;
361
 
        Messages                        m_Messages;
362
 
        int                                     m_iIDMessageGen;
363
 
 
364
 
        static int                      m_iIDGen;
365
 
 
366
 
public:
367
 
                                                PostInfo();
368
 
                                                ~PostInfo();
369
 
        int                                     GetID() { return m_iID; }
370
 
        NZBInfo*                        GetNZBInfo() { return m_pNZBInfo; }
371
 
        void                            SetNZBInfo(NZBInfo* pNZBInfo);
372
 
        const char*                     GetParFilename() { return m_szParFilename; }
373
 
        void                            SetParFilename(const char* szParFilename);
374
 
        const char*                     GetInfoName() { return m_szInfoName; }
375
 
        void                            SetInfoName(const char* szInfoName);
376
 
        EStage                          GetStage() { return m_eStage; }
377
 
        void                            SetStage(EStage eStage) { m_eStage = eStage; }
378
 
        void                            SetProgressLabel(const char* szProgressLabel);
379
 
        const char*                     GetProgressLabel() { return m_szProgressLabel; }
380
 
        int                                     GetFileProgress() { return m_iFileProgress; }
381
 
        void                            SetFileProgress(int iFileProgress) { m_iFileProgress = iFileProgress; }
382
 
        int                                     GetStageProgress() { return m_iStageProgress; }
383
 
        void                            SetStageProgress(int iStageProgress) { m_iStageProgress = iStageProgress; }
384
 
        time_t                          GetStartTime() { return m_tStartTime; }
385
 
        void                            SetStartTime(time_t tStartTime) { m_tStartTime = tStartTime; }
386
 
        time_t                          GetStageTime() { return m_tStageTime; }
387
 
        void                            SetStageTime(time_t tStageTime) { m_tStageTime = tStageTime; }
388
 
        bool                            GetWorking() { return m_bWorking; }
389
 
        void                            SetWorking(bool bWorking) { m_bWorking = bWorking; }
390
 
        bool                            GetDeleted() { return m_bDeleted; }
391
 
        void                            SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
392
 
        bool                            GetParCheck() { return m_bParCheck; }
393
 
        void                            SetParCheck(bool bParCheck) { m_bParCheck = bParCheck; }
394
 
        EParStatus                      GetParStatus() { return m_eParStatus; }
395
 
        void                            SetParStatus(EParStatus eParStatus) { m_eParStatus = eParStatus; }
396
 
        ERequestParCheck        GetRequestParCheck() { return m_eRequestParCheck; }
397
 
        void                            SetRequestParCheck(ERequestParCheck eRequestParCheck) { m_eRequestParCheck = eRequestParCheck; }
398
 
        EScriptStatus           GetScriptStatus() { return m_eScriptStatus; }
399
 
        void                            SetScriptStatus(EScriptStatus eScriptStatus) { m_eScriptStatus = eScriptStatus; }
400
 
        void                            AppendMessage(Message::EKind eKind, const char* szText);
401
 
        Thread*                         GetScriptThread() { return m_pScriptThread; }
402
 
        void                            SetScriptThread(Thread* pScriptThread) { m_pScriptThread = pScriptThread; }
403
 
        Messages*                       LockMessages();
404
 
        void                            UnlockMessages();
405
 
};
406
 
 
407
 
typedef std::deque<PostInfo*> PostQueue;
408
 
 
409
 
typedef std::vector<int> IDList;
410
 
 
411
 
typedef std::deque<NZBInfo*> HistoryList;
412
 
 
413
 
class DownloadQueue
414
 
{
415
 
protected:
416
 
        NZBInfoList                     m_NZBInfoList;
417
 
        FileQueue                       m_FileQueue;
418
 
        PostQueue                       m_PostQueue;
419
 
        HistoryList                     m_HistoryList;
420
 
        FileQueue                       m_ParkedFiles;
421
 
 
422
 
public:
423
 
        NZBInfoList*            GetNZBInfoList() { return &m_NZBInfoList; }
424
 
        FileQueue*                      GetFileQueue() { return &m_FileQueue; }
425
 
        PostQueue*                      GetPostQueue() { return &m_PostQueue; }
426
 
        HistoryList*            GetHistoryList() { return &m_HistoryList; }
427
 
        FileQueue*                      GetParkedFiles() { return &m_ParkedFiles; }
428
 
        void                            BuildGroups(GroupQueue* pGroupQueue);
429
 
};
430
 
 
431
 
class DownloadQueueHolder
432
 
{
433
 
public:
434
 
        virtual                                 ~DownloadQueueHolder() {};
435
 
        virtual DownloadQueue*  LockQueue() = 0;
436
 
        virtual void                    UnlockQueue() = 0;
437
 
};
438
 
 
439
 
#endif