diff --git a/src/bin/pkgman/JobStateListener.cpp b/src/bin/pkgman/JobStateListener.cpp index f410703257..1f27001835 100644 --- a/src/bin/pkgman/JobStateListener.cpp +++ b/src/bin/pkgman/JobStateListener.cpp @@ -13,6 +13,13 @@ using BPackageKit::BJob; +JobStateListener::JobStateListener(uint32 flags) + : + fFlags(flags) +{ +} + + void JobStateListener::JobStarted(BJob* job) { @@ -34,12 +41,14 @@ JobStateListener::JobFailed(BJob* job) error.ReplaceAll("\n", "\n*** "); fprintf(stderr, "%s", error.String()); } - DIE(job->Result(), "failed!"); + if ((fFlags & EXIT_ON_ERROR) != 0) + DIE(job->Result(), "failed!"); } void JobStateListener::JobAborted(BJob* job) { - DIE(job->Result(), "aborted"); + if ((fFlags & EXIT_ON_ABORT) != 0) + DIE(job->Result(), "aborted"); } diff --git a/src/bin/pkgman/JobStateListener.h b/src/bin/pkgman/JobStateListener.h index f765301403..9ff8c5340e 100644 --- a/src/bin/pkgman/JobStateListener.h +++ b/src/bin/pkgman/JobStateListener.h @@ -9,11 +9,26 @@ #include -struct JobStateListener : public BPackageKit::BJobStateListener { - virtual void JobStarted(BPackageKit::BJob* job); - virtual void JobSucceeded(BPackageKit::BJob* job); - virtual void JobFailed(BPackageKit::BJob* job); - virtual void JobAborted(BPackageKit::BJob* job); +class JobStateListener : public BPackageKit::BJobStateListener { +public: + enum { + EXIT_ON_ERROR = 0x01, + EXIT_ON_ABORT = 0x02, + }; + + +public: + JobStateListener( + uint32 flags = EXIT_ON_ERROR + | EXIT_ON_ABORT); + + virtual void JobStarted(BPackageKit::BJob* job); + virtual void JobSucceeded(BPackageKit::BJob* job); + virtual void JobFailed(BPackageKit::BJob* job); + virtual void JobAborted(BPackageKit::BJob* job); + +private: + uint32 fFlags; };