BPackageManager: Eliminate RequestHandler.
- Pull functionality back into package manager itself since the extra indirection doesn't really buy us anything in this case, as neither request that it handles requires a decision provider. - Adjust pkgman and HaikuDepot accordingly.
This commit is contained in:
parent
672795a37e
commit
fe39d2eb8d
@ -41,7 +41,6 @@ public:
|
||||
class InstallationInterface;
|
||||
class ClientInstallationInterface;
|
||||
class UserInteractionHandler;
|
||||
class RequestHandler;
|
||||
|
||||
typedef BObjectList<RemoteRepository> RemoteRepositoryList;
|
||||
typedef BObjectList<InstalledRepository> InstalledRepositoryList;
|
||||
@ -56,8 +55,9 @@ public:
|
||||
|
||||
public:
|
||||
BPackageManager(
|
||||
BPackageInstallationLocation location);
|
||||
~BPackageManager();
|
||||
BPackageInstallationLocation location,
|
||||
BJobStateListener* listener);
|
||||
virtual ~BPackageManager();
|
||||
|
||||
void Init(uint32 flags);
|
||||
|
||||
@ -90,6 +90,13 @@ public:
|
||||
|
||||
void VerifyInstallation();
|
||||
|
||||
|
||||
virtual status_t DownloadPackage(const BString& fileURL,
|
||||
const BEntry& targetEntry,
|
||||
const BString& checksum);
|
||||
virtual status_t RefreshRepository(
|
||||
const BRepositoryConfig& repoConfig);
|
||||
|
||||
protected:
|
||||
InstalledRepository& InstallationRepository();
|
||||
|
||||
@ -133,8 +140,8 @@ protected:
|
||||
|
||||
// must be set by the derived class
|
||||
InstallationInterface* fInstallationInterface;
|
||||
RequestHandler* fRequestHandler;
|
||||
UserInteractionHandler* fUserInteractionHandler;
|
||||
BJobStateListener* fJobStateListener;
|
||||
};
|
||||
|
||||
|
||||
@ -243,18 +250,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class BPackageManager::RequestHandler {
|
||||
public:
|
||||
virtual ~RequestHandler();
|
||||
|
||||
virtual status_t RefreshRepository(
|
||||
const BRepositoryConfig& repoConfig) = 0;
|
||||
virtual status_t DownloadPackage(const BString& fileURL,
|
||||
const BEntry& targetEntry,
|
||||
const BString& checksum) = 0;
|
||||
};
|
||||
|
||||
|
||||
class BPackageManager::UserInteractionHandler {
|
||||
public:
|
||||
virtual ~UserInteractionHandler();
|
||||
|
@ -142,18 +142,16 @@ public:
|
||||
|
||||
PackageManager::PackageManager(BPackageInstallationLocation location)
|
||||
:
|
||||
BPackageManager(location),
|
||||
BPackageManager(location, &fJobStateListener),
|
||||
BPackageManager::UserInteractionHandler(),
|
||||
fDecisionProvider(),
|
||||
fJobStateListener(),
|
||||
fContext(fDecisionProvider, fJobStateListener),
|
||||
fClientInstallationInterface(),
|
||||
fProblemWindow(NULL),
|
||||
fCurrentInstallPackage(NULL),
|
||||
fCurrentUninstallPackage(NULL)
|
||||
{
|
||||
fInstallationInterface = &fClientInstallationInterface;
|
||||
fRequestHandler = this;
|
||||
fUserInteractionHandler = this;
|
||||
}
|
||||
|
||||
@ -228,7 +226,7 @@ PackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
||||
{
|
||||
status_t result;
|
||||
try {
|
||||
result = BRefreshRepositoryRequest(fContext, repoConfig).Process();
|
||||
result = BPackageManager::RefreshRepository(repoConfig);
|
||||
} catch (BFatalErrorException ex) {
|
||||
fprintf(stderr, "Fatal error occurred while refreshing repository: "
|
||||
"%s (%s)\n", ex.Message().String(), ex.Details().String());
|
||||
@ -249,8 +247,8 @@ PackageManager::DownloadPackage(const BString& fileURL,
|
||||
{
|
||||
status_t result;
|
||||
try {
|
||||
result = DownloadFileRequest(fContext, fileURL, targetEntry, checksum)
|
||||
.Process();
|
||||
result = BPackageManager::DownloadPackage(fileURL, targetEntry,
|
||||
checksum);
|
||||
} catch (BFatalErrorException ex) {
|
||||
fprintf(stderr, "Fatal error occurred while downloading package: "
|
||||
"%s: %s (%s)\n", fileURL.String(), ex.Message().String(),
|
||||
|
@ -37,7 +37,6 @@ using BPackageKit::BManager::BPrivate::BPackageManager;
|
||||
|
||||
|
||||
class PackageManager : public BPackageManager,
|
||||
private BPackageManager::RequestHandler,
|
||||
private BPackageManager::UserInteractionHandler {
|
||||
public:
|
||||
PackageManager(
|
||||
@ -51,13 +50,11 @@ public:
|
||||
PackageInfoRef package,
|
||||
bool install);
|
||||
|
||||
private:
|
||||
// RequestHandler
|
||||
virtual status_t RefreshRepository(
|
||||
const BRepositoryConfig& repoConfig);
|
||||
virtual status_t DownloadPackage(const BString& fileURL,
|
||||
const BEntry& targetEntry,
|
||||
const BString& checksum);
|
||||
const BEntry& targetEntry,
|
||||
const BString& checksum);
|
||||
|
||||
private:
|
||||
// UserInteractionHandler
|
||||
@ -85,7 +82,6 @@ private:
|
||||
private:
|
||||
DecisionProvider fDecisionProvider;
|
||||
JobStateListener fJobStateListener;
|
||||
BContext fContext;
|
||||
BPackageManager::ClientInstallationInterface
|
||||
fClientInstallationInterface;
|
||||
|
||||
|
@ -23,15 +23,13 @@ using namespace BPackageKit::BPrivate;
|
||||
|
||||
PackageManager::PackageManager(BPackageInstallationLocation location)
|
||||
:
|
||||
BPackageManager(location),
|
||||
BPackageManager(location, &fJobStateListener),
|
||||
BPackageManager::UserInteractionHandler(),
|
||||
fDecisionProvider(),
|
||||
fJobStateListener(JobStateListener::EXIT_ON_ABORT),
|
||||
fContext(fDecisionProvider, fJobStateListener),
|
||||
fClientInstallationInterface()
|
||||
{
|
||||
fInstallationInterface = &fClientInstallationInterface;
|
||||
fRequestHandler = this;
|
||||
fUserInteractionHandler = this;
|
||||
}
|
||||
|
||||
@ -41,22 +39,6 @@ PackageManager::~PackageManager()
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
PackageManager::HandleProblems()
|
||||
{
|
||||
|
@ -22,21 +22,12 @@ using BManager::BPrivate::BPackageManager;
|
||||
|
||||
|
||||
class PackageManager : public BPackageManager,
|
||||
private BPackageManager::RequestHandler,
|
||||
private BPackageManager::UserInteractionHandler {
|
||||
public:
|
||||
PackageManager(
|
||||
BPackageInstallationLocation location);
|
||||
~PackageManager();
|
||||
|
||||
private:
|
||||
// RequestHandler
|
||||
virtual status_t RefreshRepository(
|
||||
const BRepositoryConfig& repoConfig);
|
||||
virtual status_t DownloadPackage(const BString& fileURL,
|
||||
const BEntry& targetEntry,
|
||||
const BString& checksum);
|
||||
|
||||
private:
|
||||
// UserInteractionHandler
|
||||
virtual void HandleProblems();
|
||||
@ -58,7 +49,6 @@ private:
|
||||
private:
|
||||
DecisionProvider fDecisionProvider;
|
||||
JobStateListener fJobStateListener;
|
||||
BContext fContext;
|
||||
BPackageManager::ClientInstallationInterface
|
||||
fClientInstallationInterface;
|
||||
};
|
||||
|
@ -4,13 +4,16 @@
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
* Rene Gollent <rene@gollent.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <package/manager/PackageManager.h>
|
||||
|
||||
#include <Directory.h>
|
||||
#include <package/DownloadFileRequest.h>
|
||||
#include <package/PackageRoster.h>
|
||||
#include <package/RefreshRepositoryRequest.h>
|
||||
#include <package/RepositoryCache.h>
|
||||
#include <package/solver/SolverPackage.h>
|
||||
#include <package/solver/SolverPackageSpecifier.h>
|
||||
@ -37,7 +40,8 @@ namespace BPrivate {
|
||||
// #pragma mark - BPackageManager
|
||||
|
||||
|
||||
BPackageManager::BPackageManager(BPackageInstallationLocation location)
|
||||
BPackageManager::BPackageManager(BPackageInstallationLocation location,
|
||||
BJobStateListener* listener)
|
||||
:
|
||||
fLocation(location),
|
||||
fSolver(NULL),
|
||||
@ -51,8 +55,8 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location)
|
||||
fOtherRepositories(10, true),
|
||||
fTransactions(5, true),
|
||||
fInstallationInterface(NULL),
|
||||
fRequestHandler(NULL),
|
||||
fUserInteractionHandler(NULL)
|
||||
fUserInteractionHandler(NULL),
|
||||
fJobStateListener(listener)
|
||||
{
|
||||
}
|
||||
|
||||
@ -483,7 +487,7 @@ BPackageManager::_PreparePackageChanges(
|
||||
BString url = remoteRepository->Config().PackagesURL();
|
||||
url << '/' << fileName;
|
||||
|
||||
status_t error = fRequestHandler->DownloadPackage(url, entry,
|
||||
status_t error = DownloadPackage(url, entry,
|
||||
package->Info().Checksum());
|
||||
if (error != B_OK)
|
||||
DIE(error, "failed to download package");
|
||||
@ -671,7 +675,7 @@ BPackageManager::_GetRepositoryCache(BPackageRoster& roster,
|
||||
if (!refresh && roster.GetRepositoryCache(config.Name(), &_cache) == B_OK)
|
||||
return B_OK;
|
||||
|
||||
status_t error = fRequestHandler->RefreshRepository(config);
|
||||
status_t error = RefreshRepository(config);
|
||||
if (error != B_OK) {
|
||||
fUserInteractionHandler->Warn(error,
|
||||
"refreshing repository \"%s\" failed", config.Name().String());
|
||||
@ -702,6 +706,26 @@ BPackageManager::_NextSpecificInstallationLocation()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPackageManager::DownloadPackage(const BString& fileURL,
|
||||
const BEntry& targetEntry, const BString& checksum)
|
||||
{
|
||||
BDecisionProvider provider;
|
||||
BContext context(provider, *fJobStateListener);
|
||||
return DownloadFileRequest(context, fileURL, targetEntry, checksum)
|
||||
.Process();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
||||
{
|
||||
BDecisionProvider provider;
|
||||
BContext context(provider, *fJobStateListener);
|
||||
return BRefreshRepositoryRequest(context, repoConfig).Process();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - RemoteRepository
|
||||
|
||||
|
||||
@ -869,14 +893,6 @@ BPackageManager::ClientInstallationInterface::CommitTransaction(
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - RequestHandler
|
||||
|
||||
|
||||
BPackageManager::RequestHandler::~RequestHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - UserInteractionHandler
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user