forked from eiskaltdcpp/eiskaltdcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DownloadManagerListener.h
82 lines (71 loc) · 2.7 KB
/
DownloadManagerListener.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (C) 2001-2012 Jacek Sieka, arnetheduck on gmail point com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include "typedefs.h"
#include "noexcept.h"
namespace dcpp {
/**
* Use this listener interface to get progress information for downloads.
*
* @remarks All methods are sending a pointer to a Download but the receiver
* (TransferView) is not using any of the methods in Download, only methods
* from its super class, Transfer. The listener functions should send Transfer
* objects instead.
*
* Changing this will will cause a problem with Download::List which is used
* in the on Tick function. One solution is reimplement on Tick to call once
* for every Downloads, sending one Download at a time. But maybe updating the
* GUI is not DownloadManagers problem at all???
*/
class DownloadManagerListener {
public:
virtual ~DownloadManagerListener() { }
template<int I> struct X { enum { TYPE = I }; };
typedef X<0> Complete;
typedef X<1> Failed;
typedef X<2> Starting;
typedef X<3> Tick;
typedef X<4> Requesting;
/**
* This is the first message sent before a download starts.
* No other messages will be sent before this.
*/
virtual void on(Requesting, Download*) noexcept { }
/**
* This is the first message sent before a download starts.
*/
virtual void on(Starting, Download*) noexcept { }
/**
* Sent once a second if something has actually been downloaded.
*/
virtual void on(Tick, const DownloadList&) noexcept { }
/**
* This is the last message sent before a download is deleted.
* No more messages will be sent after it.
*/
virtual void on(Complete, Download*) noexcept { }
/**
* This indicates some sort of failure with a particular download.
* No more messages will be sent after it.
*
* @remarks Should send an error code instead of a string and let the GUI
* display an error string.
*/
virtual void on(Failed, Download*, const string&) noexcept { }
};
} // namespace dcpp