Package Kit: Implement progress notifications.
- BJobStateListener: Add progress state and corresponding hook. - FetchFileJob: Notify job progress hook on libcurl notifications. - UserInteractionHandler: Add hooks for download progress and checksum validation progress. - PackageManager: inherit from JobStateListener and watch for job notifications for internally generated jobs. Forward to corresponding UserInteractionHandler hooks as needed. - Adapt pkgman, HaikuDepot and package_daemon to above changes. Neither HaikuDepot nor package_daemon's progress hooks are wired up to do anything yet though.
This commit is contained in:
@@ -28,7 +28,8 @@ FetchFileJob::FetchFileJob(const BContext& context, const BString& title,
|
||||
inherited(context, title),
|
||||
fFileURL(fileURL),
|
||||
fTargetEntry(targetEntry),
|
||||
fTargetFile(&targetEntry, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)
|
||||
fTargetFile(&targetEntry, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY),
|
||||
fDownloadProgress(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,6 +39,27 @@ FetchFileJob::~FetchFileJob()
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
FetchFileJob::DownloadProgress() const
|
||||
{
|
||||
return fDownloadProgress;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
FetchFileJob::DownloadURL() const
|
||||
{
|
||||
return fFileURL.String();
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
FetchFileJob::DownloadFileName() const
|
||||
{
|
||||
return fTargetEntry.Name();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FetchFileJob::Execute()
|
||||
{
|
||||
@@ -87,19 +109,19 @@ FetchFileJob::Execute()
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
/* if (WIFSIGNALED(cmdResult)
|
||||
&& (WTERMSIG(cmdResult) == SIGINT || WTERMSIG(cmdResult) == SIGQUIT)) {
|
||||
return B_CANCELED;
|
||||
} */
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
FetchFileJob::_ProgressCallback(void *clientp, double dltotal, double dlnow,
|
||||
FetchFileJob::_ProgressCallback(void *userp, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow)
|
||||
{
|
||||
FetchFileJob* job = reinterpret_cast<FetchFileJob*>(userp);
|
||||
if (dltotal != 0) {
|
||||
job->fDownloadProgress = dlnow / dltotal;
|
||||
job->NotifyStateListeners();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user