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.
This commit is contained in:
Rene Gollent 2013-09-18 15:25:11 +02:00
parent 93cb796e37
commit 0c5468eef0
7 changed files with 258 additions and 11 deletions

View File

@ -0,0 +1,19 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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;
}

View File

@ -0,0 +1,20 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Copyright 2013, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef DECISION_PROVIDER_H
#define DECISION_PROVIDER_H
#include <package/Context.h>
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

View File

@ -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
;

View File

@ -0,0 +1,43 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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
}

View File

@ -0,0 +1,24 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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 <package/Job.h>
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

View File

@ -1,19 +1,34 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* 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 <ingo_weinhold@gmx.de>
* Stephan Aßmus <superstippi@gmx.de>
* Rene Gollent, reneGollent.com.
*/
#include "PackageManager.h"
#include <stdio.h>
#include <Catalog.h>
#include <package/DownloadFileRequest.h>
#include <package/RefreshRepositoryRequest.h>
#include <package/solver/SolverPackage.h>
#include <package/solver/SolverProblem.h>
#include <package/solver/SolverProblemSolution.h>
#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
}

View File

@ -1,11 +1,18 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2011, Ingo Weinhold, <ingo_weinhold@gmx.de>
* Copyright 2013, Rene Gollent, <rene@gollent.com>
*
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef PACKAGE_MANAGER_H
#define PACKAGE_MANAGER_H
#include <package/DaemonClient.h>
#include <package/manager/PackageManager.h>
#include "DecisionProvider.h"
#include "JobStateListener.h"
#include "PackageInfo.h"
@ -32,15 +39,56 @@ private:
typedef BReference<PackageAction> PackageActionRef;
typedef List<PackageActionRef, false> 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