1/*
2 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <stdio.h>
8
9#include "JobStateListener.h"
10#include "pkgman.h"
11
12
13using BSupportKit::BJob;
14
15
16JobStateListener::JobStateListener(uint32 flags)
17	:
18	fFlags(flags)
19{
20}
21
22
23void
24JobStateListener::JobStarted(BJob* job)
25{
26	printf("%s ...\n", job->Title().String());
27}
28
29
30void
31JobStateListener::JobSucceeded(BJob* job)
32{
33}
34
35
36void
37JobStateListener::JobFailed(BJob* job)
38{
39	BString error = job->ErrorString();
40	if (error.Length() > 0) {
41		error.ReplaceAll("\n", "\n*** ");
42		fprintf(stderr, "%s", error.String());
43	}
44	if ((fFlags & EXIT_ON_ERROR) != 0)
45		DIE(job->Result(), "failed!");
46}
47
48
49void
50JobStateListener::JobAborted(BJob* job)
51{
52	if ((fFlags & EXIT_ON_ABORT) != 0)
53		DIE(job->Result(), "aborted");
54}
55