summaryrefslogtreecommitdiff
path: root/attache/UploadSettings.h
blob: d7cd0dc4b9c7497c4a5788565ac8f574bed73281 (plain)
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
#pragma once
#include "FileInfo.h"
#include "FieldInfo.h"

class UploadSettings
{
	TCHAR m_strHostName[1024];
	TCHAR m_strUrlPath[MAX_PATH];

	FileInfoList m_files;
	FieldInfoList m_fields;

	DWORD m_dwCachedBytesPerSecond;

	// A random guess: 56Kbps modem (ish)
	static const DWORD INITIAL_ESTIMATED_TRANSFER_RATE = 5600;

public:
	UploadSettings()
		: m_dwCachedBytesPerSecond(INITIAL_ESTIMATED_TRANSFER_RATE)
	{
	}

	bool SetAddress(TCHAR *lpszAddress);

	TCHAR *GetAddress() const;
	const TCHAR *GetHostName() const { return &m_strHostName[0]; }
	const TCHAR *GetUrlPath() const { return &m_strUrlPath[0]; }

	void ClearFiles();
	void AddFile(TCHAR *lpszFieldName, TCHAR *lpszFileName, TCHAR *lpszContentType);
	void GetFiles(FileInfoList *pFiles) const;

	void ClearFields();
	void AddField(TCHAR *lpszFieldName, TCHAR *lpszFieldValue);
	void GetFields(FieldInfoList *pFields) const;

	DWORD GetCachedBytesPerSecond() const { return m_dwCachedBytesPerSecond; }
	void SetCachedBytesPerSecond(DWORD dwBytesPerSecond) { m_dwCachedBytesPerSecond = dwBytesPerSecond; }
};