Package Kit: FetchFileJob now contains package size.

* So that you know how much already was, and still has to be downloaded.
* Automatic whitespace cleanup.
* The link in FetchFileJob.h did not fetch the correct header under
  Haiku anymore (since the addition of the private headers to the
  image).
This commit is contained in:
Axel Dörfler
2015-03-31 13:40:42 +02:00
parent b49e806d3d
commit 1aaa0c2142
11 changed files with 79 additions and 49 deletions
+26 -9
View File
@@ -1,10 +1,11 @@
/*
* Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Oliver Tappe <zooey@hirschkaefer.de>
* Axel Dörfler <axeld@pinc-software.de>
* Rene Gollent <[email protected]>
* Oliver Tappe <[email protected]>
*/
@@ -62,6 +63,20 @@ FetchFileJob::DownloadFileName() const
}
off_t
FetchFileJob::DownloadBytes() const
{
return fBytes;
}
off_t
FetchFileJob::DownloadTotalBytes() const
{
return fTotalBytes;
}
status_t
FetchFileJob::Execute()
{
@@ -77,8 +92,8 @@ FetchFileJob::Execute()
result = curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0);
result = curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION,
&_ProgressCallback);
result = curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION,
&_TransferCallback);
if (result != CURLE_OK)
return B_BAD_VALUE;
@@ -117,12 +132,14 @@ FetchFileJob::Execute()
int
FetchFileJob::_ProgressCallback(void *userp, double dltotal, double dlnow,
double ultotal, double ulnow)
FetchFileJob::_TransferCallback(void* _job, off_t downloadTotal,
off_t downloaded, off_t uploadTotal, off_t uploaded)
{
FetchFileJob* job = reinterpret_cast<FetchFileJob*>(userp);
if (dltotal != 0) {
job->fDownloadProgress = dlnow / dltotal;
FetchFileJob* job = reinterpret_cast<FetchFileJob*>(_job);
if (downloadTotal != 0) {
job->fBytes = downloaded;
job->fTotalBytes = downloadTotal;
job->fDownloadProgress = downloaded / downloadTotal;
job->NotifyStateListeners();
}
return 0;