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:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2013, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__JOB_H_
|
#ifndef _PACKAGE__JOB_H_
|
||||||
@@ -22,6 +22,7 @@ struct BJobStateListener {
|
|||||||
|
|
||||||
// these default implementations do nothing
|
// these default implementations do nothing
|
||||||
virtual void JobStarted(BJob* job);
|
virtual void JobStarted(BJob* job);
|
||||||
|
virtual void JobProgress(BJob* job);
|
||||||
virtual void JobSucceeded(BJob* job);
|
virtual void JobSucceeded(BJob* job);
|
||||||
virtual void JobFailed(BJob* job);
|
virtual void JobFailed(BJob* job);
|
||||||
virtual void JobAborted(BJob* job);
|
virtual void JobAborted(BJob* job);
|
||||||
@@ -30,7 +31,8 @@ struct BJobStateListener {
|
|||||||
|
|
||||||
enum BJobState {
|
enum BJobState {
|
||||||
JOB_STATE_WAITING_TO_RUN,
|
JOB_STATE_WAITING_TO_RUN,
|
||||||
JOB_STATE_RUNNING,
|
JOB_STATE_STARTED,
|
||||||
|
JOB_STATE_IN_PROGRESS,
|
||||||
JOB_STATE_SUCCEEDED,
|
JOB_STATE_SUCCEEDED,
|
||||||
JOB_STATE_FAILED,
|
JOB_STATE_FAILED,
|
||||||
JOB_STATE_ABORTED,
|
JOB_STATE_ABORTED,
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public:
|
|||||||
const BEntry& targetEntry);
|
const BEntry& targetEntry);
|
||||||
virtual ~FetchFileJob();
|
virtual ~FetchFileJob();
|
||||||
|
|
||||||
|
float DownloadProgress() const;
|
||||||
|
const char* DownloadURL() const;
|
||||||
|
const char* DownloadFileName() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual status_t Execute();
|
virtual status_t Execute();
|
||||||
virtual void Cleanup(status_t jobResult);
|
virtual void Cleanup(status_t jobResult);
|
||||||
@@ -46,6 +50,7 @@ private:
|
|||||||
BString fFileURL;
|
BString fFileURL;
|
||||||
BEntry fTargetEntry;
|
BEntry fTargetEntry;
|
||||||
BFile fTargetFile;
|
BFile fTargetFile;
|
||||||
|
float fDownloadProgress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Ingo Weinhold <[email protected]>
|
* Ingo Weinhold <[email protected]>
|
||||||
|
* Rene Gollent <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__MANAGER__PRIVATE__PACKAGE_MANAGER_H_
|
#ifndef _PACKAGE__MANAGER__PRIVATE__PACKAGE_MANAGER_H_
|
||||||
#define _PACKAGE__MANAGER__PRIVATE__PACKAGE_MANAGER_H_
|
#define _PACKAGE__MANAGER__PRIVATE__PACKAGE_MANAGER_H_
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
|
|
||||||
#include <package/ActivationTransaction.h>
|
#include <package/ActivationTransaction.h>
|
||||||
#include <package/DaemonClient.h>
|
#include <package/DaemonClient.h>
|
||||||
|
#include <package/Job.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
@@ -33,7 +35,7 @@ using BPackageKit::BPrivate::BActivationTransaction;
|
|||||||
using BPackageKit::BPrivate::BDaemonClient;
|
using BPackageKit::BPrivate::BDaemonClient;
|
||||||
|
|
||||||
|
|
||||||
class BPackageManager {
|
class BPackageManager : protected BJobStateListener {
|
||||||
public:
|
public:
|
||||||
class RemoteRepository;
|
class RemoteRepository;
|
||||||
class InstalledRepository;
|
class InstalledRepository;
|
||||||
@@ -55,8 +57,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BPackageManager(
|
BPackageManager(
|
||||||
BPackageInstallationLocation location,
|
BPackageInstallationLocation location);
|
||||||
BJobStateListener* listener);
|
|
||||||
virtual ~BPackageManager();
|
virtual ~BPackageManager();
|
||||||
|
|
||||||
void Init(uint32 flags);
|
void Init(uint32 flags);
|
||||||
@@ -100,6 +101,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
InstalledRepository& InstallationRepository();
|
InstalledRepository& InstallationRepository();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// BJobStateListener
|
||||||
|
virtual void JobStarted(BJob* job);
|
||||||
|
virtual void JobProgress(BJob* job);
|
||||||
|
virtual void JobSucceeded(BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _HandleProblems();
|
void _HandleProblems();
|
||||||
void _AnalyzeResult();
|
void _AnalyzeResult();
|
||||||
@@ -141,7 +148,6 @@ protected:
|
|||||||
// must be set by the derived class
|
// must be set by the derived class
|
||||||
InstallationInterface* fInstallationInterface;
|
InstallationInterface* fInstallationInterface;
|
||||||
UserInteractionHandler* fUserInteractionHandler;
|
UserInteractionHandler* fUserInteractionHandler;
|
||||||
BJobStateListener* fJobStateListener;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -259,6 +265,19 @@ public:
|
|||||||
|
|
||||||
virtual void Warn(status_t error, const char* format, ...)
|
virtual void Warn(status_t error, const char* format, ...)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
|
virtual void ProgressPackageDownloadStarted(
|
||||||
|
const char* packageName) = 0;
|
||||||
|
virtual void ProgressPackageDownloadActive(
|
||||||
|
const char* packageName,
|
||||||
|
float completionPercentage) = 0;
|
||||||
|
virtual void ProgressPackageDownloadComplete(
|
||||||
|
const char* packageName) = 0;
|
||||||
|
virtual void ProgressPackageChecksumStarted(
|
||||||
|
const char* title) = 0;
|
||||||
|
virtual void ProgressPackageChecksumComplete(
|
||||||
|
const char* title) = 0;
|
||||||
|
|
||||||
virtual void ProgressStartApplyingChanges(
|
virtual void ProgressStartApplyingChanges(
|
||||||
InstalledRepository& repository) = 0;
|
InstalledRepository& repository) = 0;
|
||||||
virtual void ProgressTransactionCommitted(
|
virtual void ProgressTransactionCommitted(
|
||||||
|
|||||||
@@ -142,10 +142,9 @@ public:
|
|||||||
|
|
||||||
PackageManager::PackageManager(BPackageInstallationLocation location)
|
PackageManager::PackageManager(BPackageInstallationLocation location)
|
||||||
:
|
:
|
||||||
BPackageManager(location, &fJobStateListener),
|
BPackageManager(location),
|
||||||
BPackageManager::UserInteractionHandler(),
|
BPackageManager::UserInteractionHandler(),
|
||||||
fDecisionProvider(),
|
fDecisionProvider(),
|
||||||
fJobStateListener(),
|
|
||||||
fClientInstallationInterface(),
|
fClientInstallationInterface(),
|
||||||
fProblemWindow(NULL),
|
fProblemWindow(NULL),
|
||||||
fCurrentInstallPackage(NULL),
|
fCurrentInstallPackage(NULL),
|
||||||
@@ -317,6 +316,42 @@ PackageManager::Warn(status_t error, const char* format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadStarted(const char* packageName)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
||||||
|
float completionPercentage)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumStarted(const char* title)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumComplete(const char* title)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,6 +62,19 @@ private:
|
|||||||
virtual void ConfirmChanges(bool fromMostSpecific);
|
virtual void ConfirmChanges(bool fromMostSpecific);
|
||||||
|
|
||||||
virtual void Warn(status_t error, const char* format, ...);
|
virtual void Warn(status_t error, const char* format, ...);
|
||||||
|
|
||||||
|
virtual void ProgressPackageDownloadStarted(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageDownloadActive(
|
||||||
|
const char* packageName,
|
||||||
|
float completionPercentage);
|
||||||
|
virtual void ProgressPackageDownloadComplete(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageChecksumStarted(
|
||||||
|
const char* title);
|
||||||
|
virtual void ProgressPackageChecksumComplete(
|
||||||
|
const char* title);
|
||||||
|
|
||||||
virtual void ProgressStartApplyingChanges(
|
virtual void ProgressStartApplyingChanges(
|
||||||
InstalledRepository& repository);
|
InstalledRepository& repository);
|
||||||
virtual void ProgressTransactionCommitted(
|
virtual void ProgressTransactionCommitted(
|
||||||
@@ -81,7 +94,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DecisionProvider fDecisionProvider;
|
DecisionProvider fDecisionProvider;
|
||||||
JobStateListener fJobStateListener;
|
|
||||||
BPackageManager::ClientInstallationInterface
|
BPackageManager::ClientInstallationInterface
|
||||||
fClientInstallationInterface;
|
fClientInstallationInterface;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Ingo Weinhold <[email protected]>
|
* Ingo Weinhold <[email protected]>
|
||||||
|
* Rene Gollent <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -23,10 +24,9 @@ using namespace BPackageKit::BPrivate;
|
|||||||
|
|
||||||
PackageManager::PackageManager(BPackageInstallationLocation location)
|
PackageManager::PackageManager(BPackageInstallationLocation location)
|
||||||
:
|
:
|
||||||
BPackageManager(location, &fJobStateListener),
|
BPackageManager(location),
|
||||||
BPackageManager::UserInteractionHandler(),
|
BPackageManager::UserInteractionHandler(),
|
||||||
fDecisionProvider(),
|
fDecisionProvider(),
|
||||||
fJobStateListener(JobStateListener::EXIT_ON_ABORT),
|
|
||||||
fClientInstallationInterface()
|
fClientInstallationInterface()
|
||||||
{
|
{
|
||||||
fInstallationInterface = &fClientInstallationInterface;
|
fInstallationInterface = &fClientInstallationInterface;
|
||||||
@@ -39,6 +39,24 @@ PackageManager::~PackageManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::JobFailed(BJob* job)
|
||||||
|
{
|
||||||
|
BString error = job->ErrorString();
|
||||||
|
if (error.Length() > 0) {
|
||||||
|
error.ReplaceAll("\n", "\n*** ");
|
||||||
|
fprintf(stderr, "%s", error.String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::JobAborted(BJob* job)
|
||||||
|
{
|
||||||
|
DIE(job->Result(), "aborted");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::HandleProblems()
|
PackageManager::HandleProblems()
|
||||||
{
|
{
|
||||||
@@ -134,6 +152,42 @@ PackageManager::Warn(status_t error, const char* format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadStarted(const char* packageName)
|
||||||
|
{
|
||||||
|
printf("Downloading %s...\n", packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
||||||
|
float completionPercentage)
|
||||||
|
{
|
||||||
|
// TODO: how to report progress? ncurses perhaps?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
||||||
|
{
|
||||||
|
printf("Finished downloading %s...\n", packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumStarted(const char* title)
|
||||||
|
{
|
||||||
|
printf("%s...\n", title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumComplete(const char* title)
|
||||||
|
{
|
||||||
|
printf("%s complete.\n", title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Ingo Weinhold <[email protected]>
|
* Ingo Weinhold <[email protected]>
|
||||||
|
* Rene Gollent <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef PACKAGE_MANAGER_H
|
#ifndef PACKAGE_MANAGER_H
|
||||||
#define PACKAGE_MANAGER_H
|
#define PACKAGE_MANAGER_H
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
#include <package/manager/PackageManager.h>
|
#include <package/manager/PackageManager.h>
|
||||||
|
|
||||||
#include "DecisionProvider.h"
|
#include "DecisionProvider.h"
|
||||||
#include "JobStateListener.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace BPackageKit;
|
using namespace BPackageKit;
|
||||||
@@ -28,12 +28,29 @@ public:
|
|||||||
BPackageInstallationLocation location);
|
BPackageInstallationLocation location);
|
||||||
~PackageManager();
|
~PackageManager();
|
||||||
|
|
||||||
|
virtual void JobFailed(BJob* job);
|
||||||
|
virtual void JobAborted(BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// UserInteractionHandler
|
// UserInteractionHandler
|
||||||
virtual void HandleProblems();
|
virtual void HandleProblems();
|
||||||
virtual void ConfirmChanges(bool fromMostSpecific);
|
virtual void ConfirmChanges(bool fromMostSpecific);
|
||||||
|
|
||||||
virtual void Warn(status_t error, const char* format, ...);
|
virtual void Warn(status_t error, const char* format, ...);
|
||||||
|
|
||||||
|
|
||||||
|
virtual void ProgressPackageDownloadStarted(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageDownloadActive(
|
||||||
|
const char* packageName,
|
||||||
|
float completionPercentage);
|
||||||
|
virtual void ProgressPackageDownloadComplete(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageChecksumStarted(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageChecksumComplete(
|
||||||
|
const char* packageName);
|
||||||
|
|
||||||
virtual void ProgressStartApplyingChanges(
|
virtual void ProgressStartApplyingChanges(
|
||||||
InstalledRepository& repository);
|
InstalledRepository& repository);
|
||||||
virtual void ProgressTransactionCommitted(
|
virtual void ProgressTransactionCommitted(
|
||||||
@@ -48,7 +65,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DecisionProvider fDecisionProvider;
|
DecisionProvider fDecisionProvider;
|
||||||
JobStateListener fJobStateListener;
|
|
||||||
BPackageManager::ClientInstallationInterface
|
BPackageManager::ClientInstallationInterface
|
||||||
fClientInstallationInterface;
|
fClientInstallationInterface;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ FetchFileJob::FetchFileJob(const BContext& context, const BString& title,
|
|||||||
inherited(context, title),
|
inherited(context, title),
|
||||||
fFileURL(fileURL),
|
fFileURL(fileURL),
|
||||||
fTargetEntry(targetEntry),
|
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
|
status_t
|
||||||
FetchFileJob::Execute()
|
FetchFileJob::Execute()
|
||||||
{
|
{
|
||||||
@@ -87,19 +109,19 @@ FetchFileJob::Execute()
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (WIFSIGNALED(cmdResult)
|
|
||||||
&& (WTERMSIG(cmdResult) == SIGINT || WTERMSIG(cmdResult) == SIGQUIT)) {
|
|
||||||
return B_CANCELED;
|
|
||||||
} */
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
FetchFileJob::_ProgressCallback(void *clientp, double dltotal, double dlnow,
|
FetchFileJob::_ProgressCallback(void *userp, double dltotal, double dlnow,
|
||||||
double ultotal, double ulnow)
|
double ultotal, double ulnow)
|
||||||
{
|
{
|
||||||
|
FetchFileJob* job = reinterpret_cast<FetchFileJob*>(userp);
|
||||||
|
if (dltotal != 0) {
|
||||||
|
job->fDownloadProgress = dlnow / dltotal;
|
||||||
|
job->NotifyStateListeners();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Oliver Tappe <[email protected]>
|
* Oliver Tappe <[email protected]>
|
||||||
|
* Rene Gollent <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -28,6 +29,12 @@ BJobStateListener::JobStarted(BJob* job)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobProgress(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BJobStateListener::JobSucceeded(BJob* job)
|
BJobStateListener::JobSucceeded(BJob* job)
|
||||||
{
|
{
|
||||||
@@ -134,9 +141,10 @@ BJob::Run()
|
|||||||
if (fState != JOB_STATE_WAITING_TO_RUN)
|
if (fState != JOB_STATE_WAITING_TO_RUN)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
fState = JOB_STATE_RUNNING;
|
fState = JOB_STATE_STARTED;
|
||||||
NotifyStateListeners();
|
NotifyStateListeners();
|
||||||
|
|
||||||
|
fState = JOB_STATE_IN_PROGRESS;
|
||||||
fResult = Execute();
|
fResult = Execute();
|
||||||
Cleanup(fResult);
|
Cleanup(fResult);
|
||||||
|
|
||||||
@@ -227,9 +235,12 @@ BJob::NotifyStateListeners()
|
|||||||
if (listener == NULL)
|
if (listener == NULL)
|
||||||
continue;
|
continue;
|
||||||
switch (fState) {
|
switch (fState) {
|
||||||
case JOB_STATE_RUNNING:
|
case JOB_STATE_STARTED:
|
||||||
listener->JobStarted(this);
|
listener->JobStarted(this);
|
||||||
break;
|
break;
|
||||||
|
case JOB_STATE_IN_PROGRESS:
|
||||||
|
listener->JobProgress(this);
|
||||||
|
break;
|
||||||
case JOB_STATE_SUCCEEDED:
|
case JOB_STATE_SUCCEEDED:
|
||||||
listener->JobSucceeded(this);
|
listener->JobSucceeded(this);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,11 +25,17 @@
|
|||||||
#include <CopyEngine.h>
|
#include <CopyEngine.h>
|
||||||
#include <package/ActivationTransaction.h>
|
#include <package/ActivationTransaction.h>
|
||||||
#include <package/DaemonClient.h>
|
#include <package/DaemonClient.h>
|
||||||
|
#include <package/FetchFileJob.h>
|
||||||
#include <package/manager/RepositoryBuilder.h>
|
#include <package/manager/RepositoryBuilder.h>
|
||||||
|
#include <package/ValidateChecksumJob.h>
|
||||||
|
|
||||||
#include "PackageManagerUtils.h"
|
#include "PackageManagerUtils.h"
|
||||||
|
|
||||||
|
|
||||||
|
using BPackageKit::BPrivate::FetchFileJob;
|
||||||
|
using BPackageKit::BPrivate::ValidateChecksumJob;
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
namespace BManager {
|
namespace BManager {
|
||||||
@@ -40,8 +46,7 @@ namespace BPrivate {
|
|||||||
// #pragma mark - BPackageManager
|
// #pragma mark - BPackageManager
|
||||||
|
|
||||||
|
|
||||||
BPackageManager::BPackageManager(BPackageInstallationLocation location,
|
BPackageManager::BPackageManager(BPackageInstallationLocation location)
|
||||||
BJobStateListener* listener)
|
|
||||||
:
|
:
|
||||||
fLocation(location),
|
fLocation(location),
|
||||||
fSolver(NULL),
|
fSolver(NULL),
|
||||||
@@ -55,8 +60,7 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location,
|
|||||||
fOtherRepositories(10, true),
|
fOtherRepositories(10, true),
|
||||||
fTransactions(5, true),
|
fTransactions(5, true),
|
||||||
fInstallationInterface(NULL),
|
fInstallationInterface(NULL),
|
||||||
fUserInteractionHandler(NULL),
|
fUserInteractionHandler(NULL)
|
||||||
fJobStateListener(listener)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,6 +332,45 @@ BPackageManager::InstallationRepository()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageManager::JobStarted(BJob* job)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
|
fUserInteractionHandler->ProgressPackageDownloadStarted(
|
||||||
|
fetchJob->DownloadFileName());
|
||||||
|
} else if (dynamic_cast<ValidateChecksumJob*>(job) != NULL) {
|
||||||
|
fUserInteractionHandler->ProgressPackageChecksumStarted(
|
||||||
|
job->Title().String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageManager::JobProgress(BJob* job)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
|
fUserInteractionHandler->ProgressPackageDownloadActive(
|
||||||
|
fetchJob->DownloadFileName(), fetchJob->DownloadProgress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageManager::JobSucceeded(BJob* job)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
|
fUserInteractionHandler->ProgressPackageDownloadComplete(
|
||||||
|
fetchJob->DownloadFileName());
|
||||||
|
} else if (dynamic_cast<ValidateChecksumJob*>(job) != NULL) {
|
||||||
|
fUserInteractionHandler->ProgressPackageChecksumComplete(
|
||||||
|
job->Title().String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::_HandleProblems()
|
BPackageManager::_HandleProblems()
|
||||||
{
|
{
|
||||||
@@ -711,7 +754,7 @@ BPackageManager::DownloadPackage(const BString& fileURL,
|
|||||||
const BEntry& targetEntry, const BString& checksum)
|
const BEntry& targetEntry, const BString& checksum)
|
||||||
{
|
{
|
||||||
BDecisionProvider provider;
|
BDecisionProvider provider;
|
||||||
BContext context(provider, *fJobStateListener);
|
BContext context(provider, *this);
|
||||||
return DownloadFileRequest(context, fileURL, targetEntry, checksum)
|
return DownloadFileRequest(context, fileURL, targetEntry, checksum)
|
||||||
.Process();
|
.Process();
|
||||||
}
|
}
|
||||||
@@ -721,7 +764,7 @@ status_t
|
|||||||
BPackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
BPackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
||||||
{
|
{
|
||||||
BDecisionProvider provider;
|
BDecisionProvider provider;
|
||||||
BContext context(provider, *fJobStateListener);
|
BContext context(provider, *this);
|
||||||
return BRefreshRepositoryRequest(context, repoConfig).Process();
|
return BRefreshRepositoryRequest(context, repoConfig).Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ PackageManager::PackageManager(Root* root, Volume* volume)
|
|||||||
fProblemWindow(NULL)
|
fProblemWindow(NULL)
|
||||||
{
|
{
|
||||||
fInstallationInterface = this;
|
fInstallationInterface = this;
|
||||||
fRequestHandler = this;
|
|
||||||
fUserInteractionHandler = this;
|
fUserInteractionHandler = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,22 +252,6 @@ PackageManager::CommitTransaction(Transaction& transaction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
PackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
|
||||||
{
|
|
||||||
return BRefreshRepositoryRequest(fContext, repoConfig).Process();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
PackageManager::DownloadPackage(const BString& fileURL,
|
|
||||||
const BEntry& targetEntry, const BString& checksum)
|
|
||||||
{
|
|
||||||
return DownloadFileRequest(fContext, fileURL, targetEntry, checksum)
|
|
||||||
.Process();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::HandleProblems()
|
PackageManager::HandleProblems()
|
||||||
{
|
{
|
||||||
@@ -332,6 +315,37 @@ PackageManager::Warn(status_t error, const char* format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadStarted(const char* packageName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
||||||
|
float completionPercentage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumStarted(const char* title)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageManager::ProgressPackageChecksumComplete(const char* title)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,8 @@ class Volume;
|
|||||||
|
|
||||||
class PackageManager : public BPackageManager,
|
class PackageManager : public BPackageManager,
|
||||||
private BPackageManager::InstallationInterface,
|
private BPackageManager::InstallationInterface,
|
||||||
private BPackageManager::RequestHandler,
|
|
||||||
private BPackageManager::UserInteractionHandler,
|
private BPackageManager::UserInteractionHandler,
|
||||||
private BDecisionProvider, private BJobStateListener {
|
private BDecisionProvider {
|
||||||
public:
|
public:
|
||||||
PackageManager(Root* root, Volume* volume);
|
PackageManager(Root* root, Volume* volume);
|
||||||
~PackageManager();
|
~PackageManager();
|
||||||
@@ -57,20 +56,25 @@ private:
|
|||||||
BDaemonClient::BCommitTransactionResult&
|
BDaemonClient::BCommitTransactionResult&
|
||||||
_result);
|
_result);
|
||||||
|
|
||||||
private:
|
|
||||||
// RequestHandler
|
|
||||||
virtual status_t RefreshRepository(
|
|
||||||
const BRepositoryConfig& repoConfig);
|
|
||||||
virtual status_t DownloadPackage(const BString& fileURL,
|
|
||||||
const BEntry& targetEntry,
|
|
||||||
const BString& checksum);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// UserInteractionHandler
|
// UserInteractionHandler
|
||||||
virtual void HandleProblems();
|
virtual void HandleProblems();
|
||||||
virtual void ConfirmChanges(bool fromMostSpecific);
|
virtual void ConfirmChanges(bool fromMostSpecific);
|
||||||
|
|
||||||
virtual void Warn(status_t error, const char* format, ...);
|
virtual void Warn(status_t error, const char* format, ...);
|
||||||
|
|
||||||
|
virtual void ProgressPackageDownloadStarted(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageDownloadActive(
|
||||||
|
const char* packageName,
|
||||||
|
float completionPercentage);
|
||||||
|
virtual void ProgressPackageDownloadComplete(
|
||||||
|
const char* packageName);
|
||||||
|
virtual void ProgressPackageChecksumStarted(
|
||||||
|
const char* title);
|
||||||
|
virtual void ProgressPackageChecksumComplete(
|
||||||
|
const char* title);
|
||||||
|
|
||||||
virtual void ProgressStartApplyingChanges(
|
virtual void ProgressStartApplyingChanges(
|
||||||
InstalledRepository& repository);
|
InstalledRepository& repository);
|
||||||
virtual void ProgressTransactionCommitted(
|
virtual void ProgressTransactionCommitted(
|
||||||
|
|||||||
Reference in New Issue
Block a user