From 0c5468eef0c381f753da9ef0ca1a050cdba9040d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Sep 2013 15:25:11 +0200 Subject: [PATCH] HaikuDepot: Stub out various support classes for package kit use. - DecisionProvider and JobStateListener will be needed in order to interact with the package kit in various ways eventually, though the implementations are currently all empty. - Adjust HaikuDepot's PackageManager class to inherit from BPackageManager, so as to be able to actually interface with the package repositories. --- src/apps/haiku-depot/DecisionProvider.cpp | 19 ++++ src/apps/haiku-depot/DecisionProvider.h | 20 +++++ src/apps/haiku-depot/Jamfile | 8 +- src/apps/haiku-depot/JobStateListener.cpp | 43 +++++++++ src/apps/haiku-depot/JobStateListener.h | 24 +++++ src/apps/haiku-depot/PackageManager.cpp | 101 ++++++++++++++++++++-- src/apps/haiku-depot/PackageManager.h | 54 +++++++++++- 7 files changed, 258 insertions(+), 11 deletions(-) create mode 100644 src/apps/haiku-depot/DecisionProvider.cpp create mode 100644 src/apps/haiku-depot/DecisionProvider.h create mode 100644 src/apps/haiku-depot/JobStateListener.cpp create mode 100644 src/apps/haiku-depot/JobStateListener.h diff --git a/src/apps/haiku-depot/DecisionProvider.cpp b/src/apps/haiku-depot/DecisionProvider.cpp new file mode 100644 index 0000000000..9dfb455b9d --- /dev/null +++ b/src/apps/haiku-depot/DecisionProvider.cpp @@ -0,0 +1,19 @@ +/* + * Copyright 2011, Oliver Tappe + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "DecisionProvider.h" + + +bool +DecisionProvider::YesNoDecisionNeeded(const BString& description, + const BString& question, const BString& yes, const BString& no, + const BString& defaultChoice) +{ + // TODO: implement + + return true; +} diff --git a/src/apps/haiku-depot/DecisionProvider.h b/src/apps/haiku-depot/DecisionProvider.h new file mode 100644 index 0000000000..e37791bd76 --- /dev/null +++ b/src/apps/haiku-depot/DecisionProvider.h @@ -0,0 +1,20 @@ +/* + * Copyright 2011, Oliver Tappe + * Copyright 2013, Oliver Tappe + * Distributed under the terms of the MIT License. + */ +#ifndef DECISION_PROVIDER_H +#define DECISION_PROVIDER_H + + +#include + + +struct DecisionProvider : public BPackageKit::BDecisionProvider { + virtual bool YesNoDecisionNeeded(const BString& description, + const BString& question, const BString& yes, const BString& no, + const BString& defaultChoice); +}; + + +#endif // DECISION_PROVIDER_H diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile index ecc6f1f343..4117c24b61 100644 --- a/src/apps/haiku-depot/Jamfile +++ b/src/apps/haiku-depot/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src apps haiku-depot ; -UsePrivateHeaders interface shared ; +UsePrivateHeaders interface shared package ; # source directories local sourceDirs = @@ -33,7 +33,9 @@ Application HaikuDepot : App.cpp BitmapButton.cpp BitmapView.cpp + DecisionProvider.cpp FilterView.cpp + JobStateListener.cpp main.cpp MainWindow.cpp Model.cpp @@ -47,8 +49,8 @@ Application HaikuDepot : # text view stuff $(textDocumentSources) - : be translation libcolumnlistview.a libshared.a $(TARGET_LIBSUPC++) - localestub + : be package translation libcolumnlistview.a libshared.a + $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) localestub : HaikuDepot.rdef ; diff --git a/src/apps/haiku-depot/JobStateListener.cpp b/src/apps/haiku-depot/JobStateListener.cpp new file mode 100644 index 0000000000..e200c8a55c --- /dev/null +++ b/src/apps/haiku-depot/JobStateListener.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Oliver Tappe + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "JobStateListener.h" + + +using BPackageKit::BJob; + + +JobStateListener::JobStateListener() +{ +} + + +void +JobStateListener::JobStarted(BJob* job) +{ +} + + +void +JobStateListener::JobSucceeded(BJob* job) +{ + // TODO: notify user +} + + +void +JobStateListener::JobFailed(BJob* job) +{ + // TODO: notify user +} + + +void +JobStateListener::JobAborted(BJob* job) +{ + // TODO: notify user +} diff --git a/src/apps/haiku-depot/JobStateListener.h b/src/apps/haiku-depot/JobStateListener.h new file mode 100644 index 0000000000..8914adcdda --- /dev/null +++ b/src/apps/haiku-depot/JobStateListener.h @@ -0,0 +1,24 @@ +/* + * Copyright 2011, Oliver Tappe + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef JOB_STATE_LISTENER_H +#define JOB_STATE_LISTENER_H + + +#include + + +class JobStateListener : public BPackageKit::BJobStateListener { +public: + JobStateListener(); + + virtual void JobStarted(BPackageKit::BJob* job); + virtual void JobSucceeded(BPackageKit::BJob* job); + virtual void JobFailed(BPackageKit::BJob* job); + virtual void JobAborted(BPackageKit::BJob* job); +}; + + +#endif // JOB_STATE_LISTENER_H diff --git a/src/apps/haiku-depot/PackageManager.cpp b/src/apps/haiku-depot/PackageManager.cpp index b332a2454a..f3d91464b9 100644 --- a/src/apps/haiku-depot/PackageManager.cpp +++ b/src/apps/haiku-depot/PackageManager.cpp @@ -1,19 +1,34 @@ /* - * Copyright 2013, Stephan Aßmus . - * All rights reserved. Distributed under the terms of the MIT License. + * Copyright 2013, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Stephan Aßmus + * Rene Gollent, reneGollent.com. */ + #include "PackageManager.h" -#include - #include +#include +#include +#include +#include +#include + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "PackageManager" +using BPackageKit::BRefreshRepositoryRequest; +using BPackageKit::DownloadFileRequest; +using namespace BPackageKit::BPrivate; + + // #pragma mark - PackageAction @@ -56,8 +71,18 @@ public: // #pragma mark - PackageManager -PackageManager::PackageManager() +PackageManager::PackageManager(BPackageInstallationLocation location) + : + BPackageManager(location), + BPackageManager::UserInteractionHandler(), + fDecisionProvider(), + fJobStateListener(), + fContext(fDecisionProvider, fJobStateListener), + fClientInstallationInterface() { + fInstallationInterface = &fClientInstallationInterface; + fRequestHandler = this; + fUserInteractionHandler = this; } @@ -92,3 +117,69 @@ PackageManager::GetPackageActions(const PackageInfo& package) return actionList; } + + +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() +{ + // TODO: implement +} + + +void +PackageManager::ConfirmChanges(bool fromMostSpecific) +{ + // TODO: implement +} + + +void +PackageManager::Warn(status_t error, const char* format, ...) +{ + // TODO: implement +} + + +void +PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository) +{ + // TODO: implement +} + + +void +PackageManager::ProgressTransactionCommitted(InstalledRepository& repository, + const char* transactionDirectoryName) +{ + // TODO: implement +} + + +void +PackageManager::ProgressApplyingChangesDone(InstalledRepository& repository) +{ + // TODO: implement +} + + +void +PackageManager::_PrintResult(InstalledRepository& installationRepository) +{ + // TODO: implement +} diff --git a/src/apps/haiku-depot/PackageManager.h b/src/apps/haiku-depot/PackageManager.h index d0211feff0..903966f3eb 100644 --- a/src/apps/haiku-depot/PackageManager.h +++ b/src/apps/haiku-depot/PackageManager.h @@ -1,11 +1,18 @@ /* * Copyright 2013, Stephan Aßmus . + * Copyright 2011, Ingo Weinhold, + * Copyright 2013, Rene Gollent, + * * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef PACKAGE_MANAGER_H #define PACKAGE_MANAGER_H +#include +#include +#include "DecisionProvider.h" +#include "JobStateListener.h" #include "PackageInfo.h" @@ -32,15 +39,56 @@ private: typedef BReference PackageActionRef; typedef List PackageActionList; +using BPackageKit::BContext; +using BPackageKit::BPackageInstallationLocation; +using BPackageKit::BRepositoryConfig; +using BPackageKit::BPrivate::BDaemonClient; +using BPackageKit::BManager::BPrivate::BPackageManager; -class PackageManager { + +class PackageManager : public BPackageManager, + private BPackageManager::RequestHandler, + private BPackageManager::UserInteractionHandler { public: - PackageManager(); + PackageManager( + BPackageInstallationLocation location); virtual ~PackageManager(); virtual PackageState GetPackageState(const PackageInfo& package); virtual PackageActionList GetPackageActions(const PackageInfo& package); + +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(); + virtual void ConfirmChanges(bool fromMostSpecific); + + virtual void Warn(status_t error, const char* format, ...); + virtual void ProgressStartApplyingChanges( + InstalledRepository& repository); + virtual void ProgressTransactionCommitted( + InstalledRepository& repository, + const char* transactionDirectoryName); + virtual void ProgressApplyingChangesDone( + InstalledRepository& repository); + +private: + void _PrintResult(InstalledRepository& + installationRepository); + +private: + DecisionProvider fDecisionProvider; + JobStateListener fJobStateListener; + BContext fContext; + BPackageManager::ClientInstallationInterface + fClientInstallationInterface; }; - #endif // PACKAGE_MANAGER_H