HaikuDepot: Start implementing UserInteractionHandler hooks.
- Use package daemon's ProblemWindow/ResultWindow for the HandleProblems() and ConfirmChanges() hooks respectively.
This commit is contained in:
@@ -12,6 +12,7 @@ for sourceDir in $(sourceDirs) {
|
|||||||
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps haiku-depot $(sourceDir) ] ;
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps haiku-depot $(sourceDir) ] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ;
|
||||||
local textDocumentSources =
|
local textDocumentSources =
|
||||||
Bullet.cpp
|
Bullet.cpp
|
||||||
BulletData.cpp
|
BulletData.cpp
|
||||||
@@ -46,6 +47,10 @@ Application HaikuDepot :
|
|||||||
PackageManager.cpp
|
PackageManager.cpp
|
||||||
support.cpp
|
support.cpp
|
||||||
|
|
||||||
|
# package_daemon
|
||||||
|
ProblemWindow.cpp
|
||||||
|
ResultWindow.cpp
|
||||||
|
|
||||||
# text view stuff
|
# text view stuff
|
||||||
$(textDocumentSources)
|
$(textDocumentSources)
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,10 @@
|
|||||||
#include <package/solver/SolverProblem.h>
|
#include <package/solver/SolverProblem.h>
|
||||||
#include <package/solver/SolverProblemSolution.h>
|
#include <package/solver/SolverProblemSolution.h>
|
||||||
|
|
||||||
|
#include "AutoDeleter.h"
|
||||||
#include "AutoLocker.h"
|
#include "AutoLocker.h"
|
||||||
|
#include "ProblemWindow.h"
|
||||||
|
#include "ResultWindow.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
@@ -30,16 +33,14 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace BPackageKit::BPrivate;
|
using namespace BPackageKit::BPrivate;
|
||||||
|
using namespace BPackageKit::BManager::BPrivate;
|
||||||
|
|
||||||
using BPackageKit::BRefreshRepositoryRequest;
|
using BPackageKit::BRefreshRepositoryRequest;
|
||||||
using BPackageKit::DownloadFileRequest;
|
using BPackageKit::DownloadFileRequest;
|
||||||
using BPackageKit::BManager::BPrivate::BException;
|
|
||||||
using BPackageKit::BManager::BPrivate::BFatalErrorException;
|
|
||||||
using BPackageKit::BSolver;
|
using BPackageKit::BSolver;
|
||||||
using BPackageKit::BSolverPackage;
|
using BPackageKit::BSolverPackage;
|
||||||
using BPackageKit::BSolverRepository;
|
using BPackageKit::BSolverRepository;
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - PackageAction
|
// #pragma mark - PackageAction
|
||||||
|
|
||||||
|
|
||||||
@@ -139,7 +140,8 @@ PackageManager::PackageManager(BPackageInstallationLocation location)
|
|||||||
fDecisionProvider(),
|
fDecisionProvider(),
|
||||||
fJobStateListener(),
|
fJobStateListener(),
|
||||||
fContext(fDecisionProvider, fJobStateListener),
|
fContext(fDecisionProvider, fJobStateListener),
|
||||||
fClientInstallationInterface()
|
fClientInstallationInterface(),
|
||||||
|
fProblemWindow(NULL)
|
||||||
{
|
{
|
||||||
fInstallationInterface = &fClientInstallationInterface;
|
fInstallationInterface = &fClientInstallationInterface;
|
||||||
fRequestHandler = this;
|
fRequestHandler = this;
|
||||||
@@ -160,6 +162,9 @@ PackageManager::~PackageManager()
|
|||||||
delete_sem(fPendingActionsSem);
|
delete_sem(fPendingActionsSem);
|
||||||
status_t result;
|
status_t result;
|
||||||
wait_for_thread(fPendingActionsWorker, &result);
|
wait_for_thread(fPendingActionsWorker, &result);
|
||||||
|
|
||||||
|
if (fProblemWindow != NULL)
|
||||||
|
fProblemWindow->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,14 +283,39 @@ PackageManager::DownloadPackage(const BString& fileURL,
|
|||||||
void
|
void
|
||||||
PackageManager::HandleProblems()
|
PackageManager::HandleProblems()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
if (fProblemWindow == NULL)
|
||||||
|
fProblemWindow = new ProblemWindow;
|
||||||
|
|
||||||
|
ProblemWindow::SolverPackageSet dummy;
|
||||||
|
if (!fProblemWindow->Go(fSolver,dummy, dummy))
|
||||||
|
throw BAbortedByUserException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ConfirmChanges(bool fromMostSpecific)
|
PackageManager::ConfirmChanges(bool fromMostSpecific)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
ResultWindow* window = new ResultWindow;
|
||||||
|
ObjectDeleter<ResultWindow> windowDeleter(window);
|
||||||
|
|
||||||
|
bool hasOtherChanges = false;
|
||||||
|
int32 count = fInstalledRepositories.CountItems();
|
||||||
|
if (fromMostSpecific) {
|
||||||
|
for (int32 i = count - 1; i >= 0; i--)
|
||||||
|
hasOtherChanges
|
||||||
|
|= _AddResults(*fInstalledRepositories.ItemAt(i), window);
|
||||||
|
} else {
|
||||||
|
for (int32 i = 0; i < count; i++)
|
||||||
|
hasOtherChanges
|
||||||
|
|= _AddResults(*fInstalledRepositories.ItemAt(i), window);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasOtherChanges)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// show the window
|
||||||
|
if (windowDeleter.Detach()->Go() == 0)
|
||||||
|
throw BAbortedByUserException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -338,3 +368,19 @@ PackageManager::_PackageActionWorker(void* arg)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PackageManager::_AddResults(InstalledRepository& repository,
|
||||||
|
ResultWindow* window)
|
||||||
|
{
|
||||||
|
if (!repository.HasChanges())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ProblemWindow::SolverPackageSet dummy;
|
||||||
|
return window->AddLocationChanges(repository.Name(),
|
||||||
|
repository.PackagesToActivate(), dummy,
|
||||||
|
repository.PackagesToDeactivate(), dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
|
|
||||||
class PackageManager;
|
class PackageManager;
|
||||||
|
class ProblemWindow;
|
||||||
|
class ResultWindow;
|
||||||
|
|
||||||
|
|
||||||
class PackageAction : public BReferenceable {
|
class PackageAction : public BReferenceable {
|
||||||
@@ -94,6 +96,11 @@ private:
|
|||||||
private:
|
private:
|
||||||
static status_t _PackageActionWorker(void* arg);
|
static status_t _PackageActionWorker(void* arg);
|
||||||
|
|
||||||
|
bool _AddResults(
|
||||||
|
BPackageManager::InstalledRepository&
|
||||||
|
repository,
|
||||||
|
ResultWindow* window);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DecisionProvider fDecisionProvider;
|
DecisionProvider fDecisionProvider;
|
||||||
JobStateListener fJobStateListener;
|
JobStateListener fJobStateListener;
|
||||||
@@ -105,6 +112,7 @@ private:
|
|||||||
PackageActionList fPendingActions;
|
PackageActionList fPendingActions;
|
||||||
BLocker fPendingActionsLock;
|
BLocker fPendingActionsLock;
|
||||||
sem_id fPendingActionsSem;
|
sem_id fPendingActionsSem;
|
||||||
|
ProblemWindow* fProblemWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKAGE_MANAGER_H
|
#endif // PACKAGE_MANAGER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user