2011-01-22 01:18:58 +03:00
|
|
|
/*
|
2011-01-24 23:48:03 +03:00
|
|
|
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
|
2013-09-25 07:31:31 +04:00
|
|
|
* Copyright 2013, Rene Gollent <rene@gollent.com>
|
2015-01-24 16:26:26 +03:00
|
|
|
* Copyright 2015, Axel Dörfler <axeld@pinc-software.de>
|
2011-01-22 01:18:58 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-25 20:07:27 +03:00
|
|
|
#ifndef _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
|
|
|
|
#define _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
|
2011-01-22 01:18:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <Entry.h>
|
2013-09-25 07:31:31 +04:00
|
|
|
#include <File.h>
|
2011-01-22 01:18:58 +03:00
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include <package/Job.h>
|
|
|
|
|
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
namespace BPackageKit {
|
2011-01-22 01:18:58 +03:00
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
namespace BPrivate {
|
2011-01-22 01:18:58 +03:00
|
|
|
|
2011-01-24 23:48:03 +03:00
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
class FetchFileJob : public BJob {
|
2011-01-25 22:36:09 +03:00
|
|
|
typedef BJob inherited;
|
2011-01-22 01:18:58 +03:00
|
|
|
|
|
|
|
public:
|
2011-01-25 20:07:27 +03:00
|
|
|
FetchFileJob(const BContext& context,
|
2011-01-22 22:30:21 +03:00
|
|
|
const BString& title,
|
2011-01-22 01:18:58 +03:00
|
|
|
const BString& fileURL,
|
|
|
|
const BEntry& targetEntry);
|
|
|
|
virtual ~FetchFileJob();
|
|
|
|
|
2013-09-28 21:12:47 +04:00
|
|
|
float DownloadProgress() const;
|
|
|
|
const char* DownloadURL() const;
|
|
|
|
const char* DownloadFileName() const;
|
2015-01-24 16:26:26 +03:00
|
|
|
off_t DownloadBytes() const;
|
|
|
|
off_t DownloadTotalBytes() const;
|
2013-09-28 21:12:47 +04:00
|
|
|
|
2011-01-22 01:18:58 +03:00
|
|
|
protected:
|
|
|
|
virtual status_t Execute();
|
|
|
|
virtual void Cleanup(status_t jobResult);
|
|
|
|
|
2013-09-25 07:31:31 +04:00
|
|
|
private:
|
|
|
|
// libcurl callbacks
|
2015-01-24 16:26:26 +03:00
|
|
|
static int _TransferCallback(void* _job,
|
|
|
|
off_t downloadTotal, off_t downloaded,
|
|
|
|
off_t uploadTotal, off_t uploaded);
|
2013-09-25 07:31:31 +04:00
|
|
|
|
2015-01-24 16:26:26 +03:00
|
|
|
static size_t _WriteCallback(void* buffer, size_t size,
|
|
|
|
size_t nmemb, void* userp);
|
2013-09-25 07:31:31 +04:00
|
|
|
|
2011-01-22 01:18:58 +03:00
|
|
|
private:
|
|
|
|
BString fFileURL;
|
|
|
|
BEntry fTargetEntry;
|
2013-09-25 07:31:31 +04:00
|
|
|
BFile fTargetFile;
|
2013-09-28 21:12:47 +04:00
|
|
|
float fDownloadProgress;
|
2015-01-24 16:26:26 +03:00
|
|
|
off_t fBytes;
|
|
|
|
off_t fTotalBytes;
|
2011-01-22 01:18:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
} // namespace BPrivate
|
2011-01-22 01:18:58 +03:00
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
} // namespace BPackageKit
|
2011-01-22 01:18:58 +03:00
|
|
|
|
|
|
|
|
2011-01-25 20:07:27 +03:00
|
|
|
#endif // _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
|