/
TaskLooper.h
62 lines (48 loc) · 1.42 KB
/
TaskLooper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* TaskLooper.h
* Copyright 2016 Brian Hill
* All rights reserved. Distributed under the terms of the BSD License.
*/
#ifndef TASK_LOOPER_H
#define TASK_LOOPER_H
#include <Job.h>
#include <Looper.h>
#include <ObjectList.h>
#include <String.h>
#include <StringList.h>
#include <package/Context.h>
#include "TaskTimer.h"
class DecisionProvider : public BPackageKit::BDecisionProvider {
public:
DecisionProvider(){}
virtual bool YesNoDecisionNeeded(const BString& description,
const BString& question,
const BString& yes,
const BString& no,
const BString& defaultChoice)
{ return true; }
};
class JobStateListener : public BSupportKit::BJobStateListener {
public:
JobStateListener(){}
virtual void JobStarted(BSupportKit::BJob* job);
virtual void JobSucceeded(BSupportKit::BJob* job);
virtual void JobFailed(BSupportKit::BJob* job);
virtual void JobAborted(BSupportKit::BJob* job);
BString GetJobLog();
private:
BStringList fJobLog;
};
class TaskLooper : public BLooper {
public:
TaskLooper(BLooper *target);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage*);
private:
BObjectList<Task> fTaskQueue;
void _RemoveAndDelete(Task *task);
static status_t _DoTask(void *data);
static void _AppendErrorDetails(BString &details,
JobStateListener *listener);
BLooper *fReplyTarget;
};
#endif