xref: /haiku/src/bin/pkgman/JobStateListener.cpp (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
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 
13 using BSupportKit::BJob;
14 
15 
16 JobStateListener::JobStateListener(uint32 flags)
17 	:
18 	fFlags(flags)
19 {
20 }
21 
22 
23 void
24 JobStateListener::JobStarted(BJob* job)
25 {
26 	printf("%s ...\n", job->Title().String());
27 }
28 
29 
30 void
31 JobStateListener::JobSucceeded(BJob* job)
32 {
33 }
34 
35 
36 void
37 JobStateListener::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 
49 void
50 JobStateListener::JobAborted(BJob* job)
51 {
52 	if ((fFlags & EXIT_ON_ABORT) != 0)
53 		DIE(job->Result(), "aborted");
54 }
55