Moved BJob, and JobQueue into the support kit.
* Put it in the BSupportKit namespace, following the style introduced with the package kit for now. * The BSupportKit::BJob class no longer knows about the package kit's Context class. However, the BPackageKit::BJob class does. * Due to the namespace juggling, a lot of files had to be touched. * The JobQueue class remains private. * Due to the way Haiku is built on itself, you cannot build this change under Haiku with an older release.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
#include <../os/support/Job.h>
|
||||||
@@ -1 +0,0 @@
|
|||||||
#include <../private/package/JobQueue.h>
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../private/support/JobPrivate.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../private/support/JobQueue.h>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__ADD_REPOSITORY_REQUEST_H_
|
#ifndef _PACKAGE__ADD_REPOSITORY_REQUEST_H_
|
||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BJobStateListener
|
// BJobStateListener
|
||||||
virtual void JobSucceeded(BJob* job);
|
virtual void JobSucceeded(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fRepositoryBaseURL;
|
BString fRepositoryBaseURL;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__CONTEXT_H_
|
#ifndef _PACKAGE__CONTEXT_H_
|
||||||
@@ -10,10 +10,14 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BSupportKit {
|
||||||
|
class BJobStateListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
class BJobStateListener;
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
class TempfileManager;
|
class TempfileManager;
|
||||||
}
|
}
|
||||||
@@ -37,7 +41,8 @@ struct BDecisionProvider {
|
|||||||
class BContext {
|
class BContext {
|
||||||
public:
|
public:
|
||||||
BContext(BDecisionProvider& decisionProvider,
|
BContext(BDecisionProvider& decisionProvider,
|
||||||
BJobStateListener& jobStateListener);
|
BSupportKit::BJobStateListener&
|
||||||
|
jobStateListener);
|
||||||
~BContext();
|
~BContext();
|
||||||
|
|
||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
@@ -46,13 +51,13 @@ public:
|
|||||||
BEntry* entry) const;
|
BEntry* entry) const;
|
||||||
|
|
||||||
BDecisionProvider& DecisionProvider() const;
|
BDecisionProvider& DecisionProvider() const;
|
||||||
BJobStateListener& JobStateListener() const;
|
BSupportKit::BJobStateListener& JobStateListener() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _Initialize();
|
status_t _Initialize();
|
||||||
|
|
||||||
BDecisionProvider& fDecisionProvider;
|
BDecisionProvider& fDecisionProvider;
|
||||||
BJobStateListener& fJobStateListener;
|
BSupportKit::BJobStateListener& fJobStateListener;
|
||||||
status_t fInitStatus;
|
status_t fInitStatus;
|
||||||
|
|
||||||
mutable BPrivate::TempfileManager* fTempfileManager;
|
mutable BPrivate::TempfileManager* fTempfileManager;
|
||||||
|
|||||||
@@ -1,42 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2013, Haiku, Inc.
|
* Copyright 2011-2015, 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_
|
||||||
#define _PACKAGE__JOB_H_
|
#define _PACKAGE__JOB_H_
|
||||||
|
|
||||||
|
|
||||||
#include <ObjectList.h>
|
#include <support/Job.h>
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
class BContext;
|
class BContext;
|
||||||
class BJob;
|
|
||||||
|
|
||||||
|
|
||||||
struct BJobStateListener {
|
|
||||||
virtual ~BJobStateListener();
|
|
||||||
|
|
||||||
// these default implementations do nothing
|
|
||||||
virtual void JobStarted(BJob* job);
|
|
||||||
virtual void JobProgress(BJob* job);
|
|
||||||
virtual void JobSucceeded(BJob* job);
|
|
||||||
virtual void JobFailed(BJob* job);
|
|
||||||
virtual void JobAborted(BJob* job);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum BJobState {
|
|
||||||
JOB_STATE_WAITING_TO_RUN,
|
|
||||||
JOB_STATE_STARTED,
|
|
||||||
JOB_STATE_IN_PROGRESS,
|
|
||||||
JOB_STATE_SUCCEEDED,
|
|
||||||
JOB_STATE_FAILED,
|
|
||||||
JOB_STATE_ABORTED,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
@@ -44,64 +20,14 @@ namespace BPrivate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BJob {
|
class BJob : public BSupportKit::BJob {
|
||||||
public:
|
public:
|
||||||
BJob(const BContext& context,
|
BJob(const BContext& context,
|
||||||
const BString& title);
|
const BString& title);
|
||||||
virtual ~BJob();
|
virtual ~BJob();
|
||||||
|
|
||||||
status_t InitCheck() const;
|
|
||||||
|
|
||||||
virtual status_t Run();
|
|
||||||
|
|
||||||
const BString& Title() const;
|
|
||||||
BJobState State() const;
|
|
||||||
status_t Result() const;
|
|
||||||
const BString& ErrorString() const;
|
|
||||||
|
|
||||||
uint32 TicketNumber() const;
|
|
||||||
|
|
||||||
status_t AddStateListener(BJobStateListener* listener);
|
|
||||||
status_t RemoveStateListener(
|
|
||||||
BJobStateListener* listener);
|
|
||||||
|
|
||||||
bool IsRunnable() const;
|
|
||||||
status_t AddDependency(BJob* job);
|
|
||||||
status_t RemoveDependency(BJob* job);
|
|
||||||
int32 CountDependencies() const;
|
|
||||||
|
|
||||||
BJob* DependantJobAt(int32 index) const;
|
|
||||||
protected:
|
protected:
|
||||||
virtual status_t Execute() = 0;
|
|
||||||
virtual void Cleanup(status_t jobResult);
|
|
||||||
|
|
||||||
void SetErrorString(const BString&);
|
|
||||||
|
|
||||||
void NotifyStateListeners();
|
|
||||||
|
|
||||||
const BContext& fContext;
|
const BContext& fContext;
|
||||||
|
|
||||||
private:
|
|
||||||
friend class BPrivate::JobQueue;
|
|
||||||
void _SetTicketNumber(uint32 ticketNumber);
|
|
||||||
void _ClearTicketNumber();
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t fInitStatus;
|
|
||||||
BString fTitle;
|
|
||||||
|
|
||||||
BJobState fState;
|
|
||||||
status_t fResult;
|
|
||||||
BString fErrorString;
|
|
||||||
|
|
||||||
uint32 fTicketNumber;
|
|
||||||
|
|
||||||
typedef BObjectList<BJob> JobList;
|
|
||||||
JobList fDependencies;
|
|
||||||
JobList fDependantJobs;
|
|
||||||
|
|
||||||
typedef BObjectList<BJobStateListener> StateListenerList;
|
|
||||||
StateListenerList fStateListeners;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__REFRESH_REPOSITORY_REQUEST_H_
|
#ifndef _PACKAGE__REFRESH_REPOSITORY_REQUEST_H_
|
||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BJobStateListener
|
// BJobStateListener
|
||||||
virtual void JobSucceeded(BJob* job);
|
virtual void JobSucceeded(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _FetchRepositoryCache();
|
status_t _FetchRepositoryCache();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__REQUEST_H_
|
#ifndef _PACKAGE__REQUEST_H_
|
||||||
@@ -11,16 +11,20 @@
|
|||||||
#include <package/Job.h>
|
#include <package/Job.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BSupportKit {
|
||||||
|
namespace BPrivate {
|
||||||
|
class JobQueue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
class BContext;
|
class BContext;
|
||||||
namespace BPrivate {
|
|
||||||
class JobQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class BRequest : protected BJobStateListener {
|
class BRequest : protected BSupportKit::BJobStateListener {
|
||||||
public:
|
public:
|
||||||
BRequest(const BContext& context);
|
BRequest(const BContext& context);
|
||||||
virtual ~BRequest();
|
virtual ~BRequest();
|
||||||
@@ -29,18 +33,19 @@ public:
|
|||||||
|
|
||||||
virtual status_t CreateInitialJobs() = 0;
|
virtual status_t CreateInitialJobs() = 0;
|
||||||
|
|
||||||
BJob* PopRunnableJob();
|
BSupportKit::BJob* PopRunnableJob();
|
||||||
|
|
||||||
status_t Process(bool failIfCanceledOnly = false);
|
status_t Process(bool failIfCanceledOnly = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
status_t QueueJob(BJob* job);
|
status_t QueueJob(BSupportKit::BJob* job);
|
||||||
|
|
||||||
const BContext& fContext;
|
const BContext& fContext;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
status_t fInitStatus;
|
status_t fInitStatus;
|
||||||
BPrivate::JobQueue* fJobQueue;
|
BSupportKit::BPrivate::JobQueue*
|
||||||
|
fJobQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _SUPPORT_JOB_H_
|
||||||
|
#define _SUPPORT_JOB_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BSupportKit {
|
||||||
|
|
||||||
|
|
||||||
|
class BJob;
|
||||||
|
|
||||||
|
|
||||||
|
struct BJobStateListener {
|
||||||
|
virtual ~BJobStateListener();
|
||||||
|
|
||||||
|
// these default implementations do nothing
|
||||||
|
virtual void JobStarted(BJob* job);
|
||||||
|
virtual void JobProgress(BJob* job);
|
||||||
|
virtual void JobSucceeded(BJob* job);
|
||||||
|
virtual void JobFailed(BJob* job);
|
||||||
|
virtual void JobAborted(BJob* job);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum BJobState {
|
||||||
|
B_JOB_STATE_WAITING_TO_RUN,
|
||||||
|
B_JOB_STATE_STARTED,
|
||||||
|
B_JOB_STATE_IN_PROGRESS,
|
||||||
|
B_JOB_STATE_SUCCEEDED,
|
||||||
|
B_JOB_STATE_FAILED,
|
||||||
|
B_JOB_STATE_ABORTED,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BJob {
|
||||||
|
public:
|
||||||
|
BJob(const BString& title);
|
||||||
|
virtual ~BJob();
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
|
||||||
|
virtual status_t Run();
|
||||||
|
|
||||||
|
const BString& Title() const;
|
||||||
|
BJobState State() const;
|
||||||
|
status_t Result() const;
|
||||||
|
const BString& ErrorString() const;
|
||||||
|
|
||||||
|
uint32 TicketNumber() const;
|
||||||
|
|
||||||
|
status_t AddStateListener(BJobStateListener* listener);
|
||||||
|
status_t RemoveStateListener(
|
||||||
|
BJobStateListener* listener);
|
||||||
|
|
||||||
|
bool IsRunnable() const;
|
||||||
|
status_t AddDependency(BJob* job);
|
||||||
|
status_t RemoveDependency(BJob* job);
|
||||||
|
int32 CountDependencies() const;
|
||||||
|
|
||||||
|
BJob* DependantJobAt(int32 index) const;
|
||||||
|
|
||||||
|
class Private;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual status_t Execute() = 0;
|
||||||
|
virtual void Cleanup(status_t jobResult);
|
||||||
|
|
||||||
|
void SetErrorString(const BString&);
|
||||||
|
|
||||||
|
void NotifyStateListeners();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class Private;
|
||||||
|
|
||||||
|
void _SetTicketNumber(uint32 ticketNumber);
|
||||||
|
void _ClearTicketNumber();
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t fInitStatus;
|
||||||
|
BString fTitle;
|
||||||
|
|
||||||
|
BJobState fState;
|
||||||
|
status_t fResult;
|
||||||
|
BString fErrorString;
|
||||||
|
|
||||||
|
uint32 fTicketNumber;
|
||||||
|
|
||||||
|
typedef BObjectList<BJob> JobList;
|
||||||
|
JobList fDependencies;
|
||||||
|
JobList fDependantJobs;
|
||||||
|
|
||||||
|
typedef BObjectList<BJobStateListener> StateListenerList;
|
||||||
|
StateListenerList fStateListeners;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BSupportKit
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _SUPPORT_JOB_H_
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
class BCommitTransactionResult;
|
class BCommitTransactionResult;
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ using BPackageKit::BPrivate::BActivationTransaction;
|
|||||||
using BPackageKit::BPrivate::BDaemonClient;
|
using BPackageKit::BPrivate::BDaemonClient;
|
||||||
|
|
||||||
|
|
||||||
class BPackageManager : protected BJobStateListener {
|
class BPackageManager : protected BSupportKit::BJobStateListener {
|
||||||
public:
|
public:
|
||||||
class RemoteRepository;
|
class RemoteRepository;
|
||||||
class LocalRepository;
|
class LocalRepository;
|
||||||
@@ -118,9 +118,9 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BJobStateListener
|
// BJobStateListener
|
||||||
virtual void JobStarted(BJob* job);
|
virtual void JobStarted(BSupportKit::BJob* job);
|
||||||
virtual void JobProgress(BJob* job);
|
virtual void JobProgress(BSupportKit::BJob* job);
|
||||||
virtual void JobSucceeded(BJob* job);
|
virtual void JobSucceeded(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _HandleProblems();
|
void _HandleProblems();
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _JOB_PRIVATE_H_
|
||||||
|
#define _JOB_PRIVATE_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <Job.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BSupportKit {
|
||||||
|
|
||||||
|
|
||||||
|
class BJob::Private {
|
||||||
|
public:
|
||||||
|
Private(BJob& job)
|
||||||
|
:
|
||||||
|
fJob(job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTicketNumber(uint32 ticketNumber)
|
||||||
|
{
|
||||||
|
fJob._SetTicketNumber(ticketNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearTicketNumber()
|
||||||
|
{
|
||||||
|
fJob._ClearTicketNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BJob& fJob;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BSupportKit
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _JOB_PRIVATE_H_
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2011-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__PRIVATE__JOB_QUEUE_H_
|
#ifndef _SUPPORT_PRIVATE_JOB_QUEUE_H_
|
||||||
#define _PACKAGE__PRIVATE__JOB_QUEUE_H_
|
#define _SUPPORT_PRIVATE_JOB_QUEUE_H_
|
||||||
|
|
||||||
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include <package/Job.h>
|
#include <Job.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BSupportKit {
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
} // namespace BPackageKit
|
} // namespace BSupportKit
|
||||||
|
|
||||||
|
|
||||||
#endif // _PACKAGE__PRIVATE__JOB_QUEUE_H_
|
#endif // _SUPPORT_PRIVATE_JOB_QUEUE_H_
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "JobStateListener.h"
|
#include "JobStateListener.h"
|
||||||
|
|
||||||
|
|
||||||
using BPackageKit::BJob;
|
using BSupportKit::BJob;
|
||||||
|
|
||||||
|
|
||||||
JobStateListener::JobStateListener()
|
JobStateListener::JobStateListener()
|
||||||
|
|||||||
@@ -7,17 +7,17 @@
|
|||||||
#define JOB_STATE_LISTENER_H
|
#define JOB_STATE_LISTENER_H
|
||||||
|
|
||||||
|
|
||||||
#include <package/Job.h>
|
#include <Job.h>
|
||||||
|
|
||||||
|
|
||||||
class JobStateListener : public BPackageKit::BJobStateListener {
|
class JobStateListener : public BSupportKit::BJobStateListener {
|
||||||
public:
|
public:
|
||||||
JobStateListener();
|
JobStateListener();
|
||||||
|
|
||||||
virtual void JobStarted(BPackageKit::BJob* job);
|
virtual void JobStarted(BSupportKit::BJob* job);
|
||||||
virtual void JobSucceeded(BPackageKit::BJob* job);
|
virtual void JobSucceeded(BSupportKit::BJob* job);
|
||||||
virtual void JobFailed(BPackageKit::BJob* job);
|
virtual void JobFailed(BSupportKit::BJob* job);
|
||||||
virtual void JobAborted(BPackageKit::BJob* job);
|
virtual void JobAborted(BSupportKit::BJob* job);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "pkgman.h"
|
#include "pkgman.h"
|
||||||
|
|
||||||
|
|
||||||
using BPackageKit::BJob;
|
using BSupportKit::BJob;
|
||||||
|
|
||||||
|
|
||||||
JobStateListener::JobStateListener(uint32 flags)
|
JobStateListener::JobStateListener(uint32 flags)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#define JOB_STATE_LISTENER_H
|
#define JOB_STATE_LISTENER_H
|
||||||
|
|
||||||
|
|
||||||
#include <package/Job.h>
|
#include <Job.h>
|
||||||
|
|
||||||
|
|
||||||
class JobStateListener : public BPackageKit::BJobStateListener {
|
class JobStateListener : public BSupportKit::BJobStateListener {
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
EXIT_ON_ERROR = 0x01,
|
EXIT_ON_ERROR = 0x01,
|
||||||
@@ -22,10 +22,10 @@ public:
|
|||||||
uint32 flags = EXIT_ON_ERROR
|
uint32 flags = EXIT_ON_ERROR
|
||||||
| EXIT_ON_ABORT);
|
| EXIT_ON_ABORT);
|
||||||
|
|
||||||
virtual void JobStarted(BPackageKit::BJob* job);
|
virtual void JobStarted(BSupportKit::BJob* job);
|
||||||
virtual void JobSucceeded(BPackageKit::BJob* job);
|
virtual void JobSucceeded(BSupportKit::BJob* job);
|
||||||
virtual void JobFailed(BPackageKit::BJob* job);
|
virtual void JobFailed(BSupportKit::BJob* job);
|
||||||
virtual void JobAborted(BPackageKit::BJob* job);
|
virtual void JobAborted(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 fFlags;
|
uint32 fFlags;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ PackageManager::SetInteractive(bool interactive)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::JobFailed(BJob* job)
|
PackageManager::JobFailed(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
BString error = job->ErrorString();
|
BString error = job->ErrorString();
|
||||||
if (error.Length() > 0) {
|
if (error.Length() > 0) {
|
||||||
@@ -64,7 +64,7 @@ PackageManager::JobFailed(BJob* job)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::JobAborted(BJob* job)
|
PackageManager::JobAborted(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
DIE(job->Result(), "aborted");
|
DIE(job->Result(), "aborted");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public:
|
|||||||
|
|
||||||
void SetInteractive(bool interactive);
|
void SetInteractive(bool interactive);
|
||||||
|
|
||||||
virtual void JobFailed(BJob* job);
|
virtual void JobFailed(BSupportKit::BJob* job);
|
||||||
virtual void JobAborted(BJob* job);
|
virtual void JobAborted(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// UserInteractionHandler
|
// UserInteractionHandler
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ BuildPlatformMergeObjectPIC <libbe_build>support_kit.o :
|
|||||||
DataIO.cpp
|
DataIO.cpp
|
||||||
DataPositionIOWrapper.cpp
|
DataPositionIOWrapper.cpp
|
||||||
Flattenable.cpp
|
Flattenable.cpp
|
||||||
|
Job.cpp
|
||||||
|
JobQueue.cpp
|
||||||
List.cpp
|
List.cpp
|
||||||
Locker.cpp
|
Locker.cpp
|
||||||
PointerList.cpp
|
PointerList.cpp
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ BuildPlatformSharedLibrary libpackage_build.so
|
|||||||
FetchFileJob.cpp
|
FetchFileJob.cpp
|
||||||
InstallationLocationInfo.cpp
|
InstallationLocationInfo.cpp
|
||||||
Job.cpp
|
Job.cpp
|
||||||
JobQueue.cpp
|
|
||||||
PackageInfo.cpp
|
PackageInfo.cpp
|
||||||
PackageInfoContentHandler.cpp
|
PackageInfoContentHandler.cpp
|
||||||
PackageInfoParser.cpp
|
PackageInfoParser.cpp
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -77,7 +77,7 @@ ActivateRepositoryConfigJob::Execute()
|
|||||||
void
|
void
|
||||||
ActivateRepositoryConfigJob::Cleanup(status_t jobResult)
|
ActivateRepositoryConfigJob::Cleanup(status_t jobResult)
|
||||||
{
|
{
|
||||||
if (jobResult != B_OK && State() != JOB_STATE_ABORTED
|
if (jobResult != B_OK && State() != BSupportKit::B_JOB_STATE_ABORTED
|
||||||
&& fTargetEntry.InitCheck() == B_OK)
|
&& fTargetEntry.InitCheck() == B_OK)
|
||||||
fTargetEntry.Remove();
|
fTargetEntry.Remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
#include <package/AddRepositoryRequest.h>
|
#include <package/AddRepositoryRequest.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
|
#include <JobQueue.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include <package/ActivateRepositoryConfigJob.h>
|
#include <package/ActivateRepositoryConfigJob.h>
|
||||||
#include <package/FetchFileJob.h>
|
#include <package/FetchFileJob.h>
|
||||||
#include <package/JobQueue.h>
|
|
||||||
#include <package/PackageRoster.h>
|
#include <package/PackageRoster.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ AddRepositoryRequest::CreateInitialJobs()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddRepositoryRequest::JobSucceeded(BJob* job)
|
AddRepositoryRequest::JobSucceeded(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (job == fActivateJob)
|
if (job == fActivateJob)
|
||||||
fRepositoryName = fActivateJob->RepositoryName();
|
fRepositoryName = fActivateJob->RepositoryName();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -39,7 +39,7 @@ BDecisionProvider::YesNoDecisionNeeded(const BString& description,
|
|||||||
|
|
||||||
|
|
||||||
BContext::BContext(BDecisionProvider& decisionProvider,
|
BContext::BContext(BDecisionProvider& decisionProvider,
|
||||||
BJobStateListener& jobStateListener)
|
BSupportKit::BJobStateListener& jobStateListener)
|
||||||
:
|
:
|
||||||
fDecisionProvider(decisionProvider),
|
fDecisionProvider(decisionProvider),
|
||||||
fJobStateListener(jobStateListener),
|
fJobStateListener(jobStateListener),
|
||||||
@@ -74,7 +74,7 @@ BContext::GetNewTempfile(const BString& baseName, BEntry* entry) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BJobStateListener&
|
BSupportKit::BJobStateListener&
|
||||||
BContext::JobStateListener() const
|
BContext::JobStateListener() const
|
||||||
{
|
{
|
||||||
return fJobStateListener;
|
return fJobStateListener;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
#include <package/DropRepositoryRequest.h>
|
#include <package/DropRepositoryRequest.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
|
#include <JobQueue.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include <package/RemoveRepositoryJob.h>
|
#include <package/RemoveRepositoryJob.h>
|
||||||
#include <package/JobQueue.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
InitTerminateLibPackage.cpp
|
InitTerminateLibPackage.cpp
|
||||||
InstallationLocationInfo.cpp
|
InstallationLocationInfo.cpp
|
||||||
Job.cpp
|
Job.cpp
|
||||||
JobQueue.cpp
|
|
||||||
PackageInfo.cpp
|
PackageInfo.cpp
|
||||||
PackageInfoContentHandler.cpp
|
PackageInfoContentHandler.cpp
|
||||||
PackageInfoParser.cpp
|
PackageInfoParser.cpp
|
||||||
|
|||||||
+3
-233
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -10,60 +10,15 @@
|
|||||||
|
|
||||||
#include <package/Job.h>
|
#include <package/Job.h>
|
||||||
|
|
||||||
#include <Errors.h>
|
|
||||||
|
|
||||||
#include <package/Context.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
BJobStateListener::~BJobStateListener()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJobStateListener::JobStarted(BJob* job)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJobStateListener::JobProgress(BJob* job)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJobStateListener::JobSucceeded(BJob* job)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJobStateListener::JobFailed(BJob* job)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJobStateListener::JobAborted(BJob* job)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BJob::BJob(const BContext& context, const BString& title)
|
BJob::BJob(const BContext& context, const BString& title)
|
||||||
:
|
:
|
||||||
fContext(context),
|
BSupportKit::BJob(title),
|
||||||
fTitle(title),
|
fContext(context)
|
||||||
fState(JOB_STATE_WAITING_TO_RUN),
|
|
||||||
fTicketNumber(0xFFFFFFFFUL)
|
|
||||||
{
|
{
|
||||||
if (fTitle.Length() == 0)
|
|
||||||
fInitStatus = B_BAD_VALUE;
|
|
||||||
else
|
|
||||||
fInitStatus = B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -72,189 +27,4 @@ BJob::~BJob()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::InitCheck() const
|
|
||||||
{
|
|
||||||
return fInitStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const BString&
|
|
||||||
BJob::Title() const
|
|
||||||
{
|
|
||||||
return fTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BJobState
|
|
||||||
BJob::State() const
|
|
||||||
{
|
|
||||||
return fState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::Result() const
|
|
||||||
{
|
|
||||||
return fResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const BString&
|
|
||||||
BJob::ErrorString() const
|
|
||||||
{
|
|
||||||
return fErrorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32
|
|
||||||
BJob::TicketNumber() const
|
|
||||||
{
|
|
||||||
return fTicketNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJob::_SetTicketNumber(uint32 ticketNumber)
|
|
||||||
{
|
|
||||||
fTicketNumber = ticketNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJob::_ClearTicketNumber()
|
|
||||||
{
|
|
||||||
fTicketNumber = 0xFFFFFFFFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJob::SetErrorString(const BString& error)
|
|
||||||
{
|
|
||||||
fErrorString = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::Run()
|
|
||||||
{
|
|
||||||
if (fState != JOB_STATE_WAITING_TO_RUN)
|
|
||||||
return B_NOT_ALLOWED;
|
|
||||||
|
|
||||||
fState = JOB_STATE_STARTED;
|
|
||||||
NotifyStateListeners();
|
|
||||||
|
|
||||||
fState = JOB_STATE_IN_PROGRESS;
|
|
||||||
fResult = Execute();
|
|
||||||
Cleanup(fResult);
|
|
||||||
|
|
||||||
fState = fResult == B_OK
|
|
||||||
? JOB_STATE_SUCCEEDED
|
|
||||||
: fResult == B_CANCELED
|
|
||||||
? JOB_STATE_ABORTED
|
|
||||||
: JOB_STATE_FAILED;
|
|
||||||
NotifyStateListeners();
|
|
||||||
|
|
||||||
return fResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJob::Cleanup(status_t /*jobResult*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::AddStateListener(BJobStateListener* listener)
|
|
||||||
{
|
|
||||||
return fStateListeners.AddItem(listener) ? B_OK : B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::RemoveStateListener(BJobStateListener* listener)
|
|
||||||
{
|
|
||||||
return fStateListeners.RemoveItem(listener) ? B_OK : B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::AddDependency(BJob* job)
|
|
||||||
{
|
|
||||||
if (fDependencies.HasItem(job))
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
if (fDependencies.AddItem(job) && job->fDependantJobs.AddItem(this))
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
BJob::RemoveDependency(BJob* job)
|
|
||||||
{
|
|
||||||
if (!fDependencies.HasItem(job))
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
if (fDependencies.RemoveItem(job) && job->fDependantJobs.RemoveItem(this))
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BJob::IsRunnable() const
|
|
||||||
{
|
|
||||||
return fDependencies.IsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
BJob::CountDependencies() const
|
|
||||||
{
|
|
||||||
return fDependencies.CountItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BJob*
|
|
||||||
BJob::DependantJobAt(int32 index) const
|
|
||||||
{
|
|
||||||
return fDependantJobs.ItemAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BJob::NotifyStateListeners()
|
|
||||||
{
|
|
||||||
int32 count = fStateListeners.CountItems();
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
BJobStateListener* listener = fStateListeners.ItemAt(i);
|
|
||||||
if (listener == NULL)
|
|
||||||
continue;
|
|
||||||
switch (fState) {
|
|
||||||
case JOB_STATE_STARTED:
|
|
||||||
listener->JobStarted(this);
|
|
||||||
break;
|
|
||||||
case JOB_STATE_IN_PROGRESS:
|
|
||||||
listener->JobProgress(this);
|
|
||||||
break;
|
|
||||||
case JOB_STATE_SUCCEEDED:
|
|
||||||
listener->JobSucceeded(this);
|
|
||||||
break;
|
|
||||||
case JOB_STATE_FAILED:
|
|
||||||
listener->JobFailed(this);
|
|
||||||
break;
|
|
||||||
case JOB_STATE_ABORTED:
|
|
||||||
listener->JobAborted(this);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPackageKit
|
} // namespace BPackageKit
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -12,11 +12,12 @@
|
|||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
|
#include <JobQueue.h>
|
||||||
|
|
||||||
#include <package/ActivateRepositoryCacheJob.h>
|
#include <package/ActivateRepositoryCacheJob.h>
|
||||||
#include <package/ChecksumAccessors.h>
|
#include <package/ChecksumAccessors.h>
|
||||||
#include <package/ValidateChecksumJob.h>
|
#include <package/ValidateChecksumJob.h>
|
||||||
#include <package/FetchFileJob.h>
|
#include <package/FetchFileJob.h>
|
||||||
#include <package/JobQueue.h>
|
|
||||||
#include <package/RepositoryCache.h>
|
#include <package/RepositoryCache.h>
|
||||||
#include <package/RepositoryConfig.h>
|
#include <package/RepositoryConfig.h>
|
||||||
#include <package/PackageRoster.h>
|
#include <package/PackageRoster.h>
|
||||||
@@ -96,7 +97,7 @@ BRefreshRepositoryRequest::CreateInitialJobs()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRefreshRepositoryRequest::JobSucceeded(BJob* job)
|
BRefreshRepositoryRequest::JobSucceeded(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (job == fValidateChecksumJob
|
if (job == fValidateChecksumJob
|
||||||
&& !fValidateChecksumJob->ChecksumsMatch()) {
|
&& !fValidateChecksumJob->ChecksumsMatch()) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -11,14 +11,15 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <JobQueue.h>
|
||||||
|
|
||||||
#include <package/Context.h>
|
#include <package/Context.h>
|
||||||
#include <package/JobQueue.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
|
||||||
using BPrivate::JobQueue;
|
using BSupportKit::BPrivate::JobQueue;
|
||||||
|
|
||||||
|
|
||||||
BRequest::BRequest(const BContext& context)
|
BRequest::BRequest(const BContext& context)
|
||||||
@@ -42,7 +43,7 @@ BRequest::InitCheck() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BJob*
|
BSupportKit::BJob*
|
||||||
BRequest::PopRunnableJob()
|
BRequest::PopRunnableJob()
|
||||||
{
|
{
|
||||||
if (fJobQueue == NULL)
|
if (fJobQueue == NULL)
|
||||||
@@ -63,7 +64,7 @@ BRequest::Process(bool failIfCanceledOnly)
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
while (BJob* job = PopRunnableJob()) {
|
while (BSupportKit::BJob* job = PopRunnableJob()) {
|
||||||
error = job->Run();
|
error = job->Run();
|
||||||
delete job;
|
delete job;
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
@@ -77,7 +78,7 @@ BRequest::Process(bool failIfCanceledOnly)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BRequest::QueueJob(BJob* job)
|
BRequest::QueueJob(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (fJobQueue == NULL)
|
if (fJobQueue == NULL)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ BPackageManager::InstallationRepository()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::JobStarted(BJob* job)
|
BPackageManager::JobStarted(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
@@ -378,7 +378,7 @@ BPackageManager::JobStarted(BJob* job)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::JobProgress(BJob* job)
|
BPackageManager::JobProgress(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
@@ -390,7 +390,7 @@ BPackageManager::JobProgress(BJob* job)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::JobSucceeded(BJob* job)
|
BPackageManager::JobSucceeded(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
if (dynamic_cast<FetchFileJob*>(job) != NULL) {
|
||||||
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
FetchFileJob* fetchJob = (FetchFileJob*)job;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
DataPositionIOWrapper.cpp
|
DataPositionIOWrapper.cpp
|
||||||
DateTime.cpp
|
DateTime.cpp
|
||||||
Flattenable.cpp
|
Flattenable.cpp
|
||||||
|
Job.cpp
|
||||||
|
JobQueue.cpp
|
||||||
List.cpp
|
List.cpp
|
||||||
Locker.cpp
|
Locker.cpp
|
||||||
PointerList.cpp
|
PointerList.cpp
|
||||||
|
|||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Oliver Tappe <[email protected]>
|
||||||
|
* Rene Gollent <[email protected]>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <Job.h>
|
||||||
|
|
||||||
|
#include <Errors.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BSupportKit {
|
||||||
|
|
||||||
|
|
||||||
|
BJobStateListener::~BJobStateListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobStarted(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobProgress(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobSucceeded(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobFailed(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJobStateListener::JobAborted(BJob* job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BJob::BJob(const BString& title)
|
||||||
|
:
|
||||||
|
fTitle(title),
|
||||||
|
fState(B_JOB_STATE_WAITING_TO_RUN),
|
||||||
|
fTicketNumber(0xFFFFFFFFUL)
|
||||||
|
{
|
||||||
|
if (fTitle.Length() == 0)
|
||||||
|
fInitStatus = B_BAD_VALUE;
|
||||||
|
else
|
||||||
|
fInitStatus = B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BJob::~BJob()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::InitCheck() const
|
||||||
|
{
|
||||||
|
return fInitStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BString&
|
||||||
|
BJob::Title() const
|
||||||
|
{
|
||||||
|
return fTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BJobState
|
||||||
|
BJob::State() const
|
||||||
|
{
|
||||||
|
return fState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::Result() const
|
||||||
|
{
|
||||||
|
return fResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BString&
|
||||||
|
BJob::ErrorString() const
|
||||||
|
{
|
||||||
|
return fErrorString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32
|
||||||
|
BJob::TicketNumber() const
|
||||||
|
{
|
||||||
|
return fTicketNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJob::_SetTicketNumber(uint32 ticketNumber)
|
||||||
|
{
|
||||||
|
fTicketNumber = ticketNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJob::_ClearTicketNumber()
|
||||||
|
{
|
||||||
|
fTicketNumber = 0xFFFFFFFFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJob::SetErrorString(const BString& error)
|
||||||
|
{
|
||||||
|
fErrorString = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::Run()
|
||||||
|
{
|
||||||
|
if (fState != B_JOB_STATE_WAITING_TO_RUN)
|
||||||
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
|
fState = B_JOB_STATE_STARTED;
|
||||||
|
NotifyStateListeners();
|
||||||
|
|
||||||
|
fState = B_JOB_STATE_IN_PROGRESS;
|
||||||
|
fResult = Execute();
|
||||||
|
Cleanup(fResult);
|
||||||
|
|
||||||
|
fState = fResult == B_OK
|
||||||
|
? B_JOB_STATE_SUCCEEDED
|
||||||
|
: fResult == B_CANCELED
|
||||||
|
? B_JOB_STATE_ABORTED
|
||||||
|
: B_JOB_STATE_FAILED;
|
||||||
|
NotifyStateListeners();
|
||||||
|
|
||||||
|
return fResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJob::Cleanup(status_t /*jobResult*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::AddStateListener(BJobStateListener* listener)
|
||||||
|
{
|
||||||
|
return fStateListeners.AddItem(listener) ? B_OK : B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::RemoveStateListener(BJobStateListener* listener)
|
||||||
|
{
|
||||||
|
return fStateListeners.RemoveItem(listener) ? B_OK : B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::AddDependency(BJob* job)
|
||||||
|
{
|
||||||
|
if (fDependencies.HasItem(job))
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (fDependencies.AddItem(job) && job->fDependantJobs.AddItem(this))
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BJob::RemoveDependency(BJob* job)
|
||||||
|
{
|
||||||
|
if (!fDependencies.HasItem(job))
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (fDependencies.RemoveItem(job) && job->fDependantJobs.RemoveItem(this))
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BJob::IsRunnable() const
|
||||||
|
{
|
||||||
|
return fDependencies.IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BJob::CountDependencies() const
|
||||||
|
{
|
||||||
|
return fDependencies.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BJob*
|
||||||
|
BJob::DependantJobAt(int32 index) const
|
||||||
|
{
|
||||||
|
return fDependantJobs.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BJob::NotifyStateListeners()
|
||||||
|
{
|
||||||
|
int32 count = fStateListeners.CountItems();
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
BJobStateListener* listener = fStateListeners.ItemAt(i);
|
||||||
|
if (listener == NULL)
|
||||||
|
continue;
|
||||||
|
switch (fState) {
|
||||||
|
case B_JOB_STATE_STARTED:
|
||||||
|
listener->JobStarted(this);
|
||||||
|
break;
|
||||||
|
case B_JOB_STATE_IN_PROGRESS:
|
||||||
|
listener->JobProgress(this);
|
||||||
|
break;
|
||||||
|
case B_JOB_STATE_SUCCEEDED:
|
||||||
|
listener->JobSucceeded(this);
|
||||||
|
break;
|
||||||
|
case B_JOB_STATE_FAILED:
|
||||||
|
listener->JobFailed(this);
|
||||||
|
break;
|
||||||
|
case B_JOB_STATE_ABORTED:
|
||||||
|
listener->JobAborted(this);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPackageKit
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,16 +7,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <package/JobQueue.h>
|
#include <JobQueue.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Job.h>
|
||||||
|
|
||||||
#include <package/Job.h>
|
#include <JobPrivate.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BSupportKit {
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
@@ -26,11 +27,11 @@ struct JobQueue::JobPriorityLess {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// sort jobs by:
|
/*! Sort jobs by:
|
||||||
// 1. descending count of dependencies (only jobs without dependencies are
|
1. descending count of dependencies (only jobs without dependencies are
|
||||||
// runnable)
|
runnable)
|
||||||
// 2. job ticket number (order in which jobs were added to the queue)
|
2. job ticket number (order in which jobs were added to the queue)
|
||||||
//
|
*/
|
||||||
bool
|
bool
|
||||||
JobQueue::JobPriorityLess::operator()(const BJob* left, const BJob* right) const
|
JobQueue::JobPriorityLess::operator()(const BJob* left, const BJob* right) const
|
||||||
{
|
{
|
||||||
@@ -86,7 +87,7 @@ JobQueue::AddJob(BJob* job)
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
job->_SetTicketNumber(fNextTicketNumber++);
|
BJob::Private(*job).SetTicketNumber(fNextTicketNumber++);
|
||||||
job->AddStateListener(this);
|
job->AddStateListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ JobQueue::RemoveJob(BJob* job)
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
job->_ClearTicketNumber();
|
BJob::Private(*job).ClearTicketNumber();
|
||||||
job->RemoveStateListener(this);
|
job->RemoveStateListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,14 +363,14 @@ PackageManager::ProgressApplyingChangesDone(InstalledRepository& repository)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::JobFailed(BJob* job)
|
PackageManager::JobFailed(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
// TODO:...
|
// TODO:...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::JobAborted(BJob* job)
|
PackageManager::JobAborted(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
// TODO:...
|
// TODO:...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
using BPackageKit::BCommitTransactionResult;
|
using BPackageKit::BCommitTransactionResult;
|
||||||
using BPackageKit::BContext;
|
using BPackageKit::BContext;
|
||||||
using BPackageKit::BJob;
|
|
||||||
using BPackageKit::BJobStateListener;
|
|
||||||
using BPackageKit::BPackageInstallationLocation;
|
using BPackageKit::BPackageInstallationLocation;
|
||||||
using BPackageKit::BRepositoryConfig;
|
using BPackageKit::BRepositoryConfig;
|
||||||
using BPackageKit::BSolverPackage;
|
using BPackageKit::BSolverPackage;
|
||||||
|
using BSupportKit::BJob;
|
||||||
|
using BSupportKit::BJobStateListener;
|
||||||
|
|
||||||
using BPackageKit::BPrivate::BDaemonClient;
|
using BPackageKit::BPrivate::BDaemonClient;
|
||||||
using BPackageKit::BManager::BPrivate::BPackageManager;
|
using BPackageKit::BManager::BPrivate::BPackageManager;
|
||||||
@@ -84,8 +84,8 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// BJobStateListener
|
// BJobStateListener
|
||||||
virtual void JobFailed(BJob* job);
|
virtual void JobFailed(BSupportKit::BJob* job);
|
||||||
virtual void JobAborted(BJob* job);
|
virtual void JobAborted(BSupportKit::BJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::set<BSolverPackage*> SolverPackageSet;
|
typedef std::set<BSolverPackage*> SolverPackageSet;
|
||||||
|
|||||||
Reference in New Issue
Block a user