aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_downloads/DownloadStatus.h
blob: 8e8eedbb80131720821e72fca6ed3550731bc7a2 (plain) (blame)
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
#ifndef NULLSOFT_DOWNLOADSTATUSH
#define NULLSOFT_DOWNLOADSTATUSH

#include "../nu/AutoLock.h"
#include <map>


class DownloadStatus
{
public:
	class Status
	{
	public:
		Status();
		~Status();
		const Status &operator =(const Status &copy);
		Status(size_t _downloaded, size_t _maxSize, const wchar_t *source, const  wchar_t *title, const wchar_t *path);
		size_t downloaded, maxSize;

		int killswitch;
		wchar_t *source;
		wchar_t *title;
		wchar_t *path;
	private:
	
		void Init();
		void Reset();
	};

	void AddDownloadThread(DownloadToken token, const wchar_t *source, const wchar_t *title, const wchar_t *path);
	void DownloadThreadDone(DownloadToken token);
	bool UpdateStatus(DownloadToken token, size_t downloaded, size_t maxSize);
	bool CurrentlyDownloading();
	void GetStatusString(wchar_t *status, size_t len);
	typedef	std::map<DownloadToken, Status> Downloads;
	Downloads downloads;
	Nullsoft::Utility::LockGuard statusLock;
};

extern DownloadStatus downloadStatus;
#endif