xref: /haiku/headers/os/package/Context.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2011-2015, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__CONTEXT_H_
6 #define _PACKAGE__CONTEXT_H_
7 
8 
9 #include <Entry.h>
10 #include <String.h>
11 
12 
13 namespace BSupportKit {
14 	struct BJobStateListener;
15 }
16 
17 
18 namespace BPackageKit {
19 
20 
21 namespace BPrivate {
22 	class TempfileManager;
23 }
24 
25 
26 struct BDecisionProvider {
27 	virtual						~BDecisionProvider();
28 
29 	virtual	bool				YesNoDecisionNeeded(const BString& description,
30 									const BString& question,
31 									const BString& yes, const BString& no,
32 									const BString& defaultChoice);
33 //	virtual	bool				ActionsAcceptanceDecisionNeeded(
34 //									const BString& description,
35 //									const BString& question) = 0;
36 //	virtual	int32				ChoiceDecisionNeeded(
37 //									const BString& question) = 0;
38 };
39 
40 
41 class BContext {
42 public:
43 								BContext(BDecisionProvider& decisionProvider,
44 									BSupportKit::BJobStateListener&
45 										jobStateListener);
46 								~BContext();
47 
48 			status_t			InitCheck() const;
49 
50 			status_t			GetNewTempfile(const BString& baseName,
51 									BEntry* entry) const;
52 
53 			BDecisionProvider&	DecisionProvider() const;
54 			BSupportKit::BJobStateListener&	JobStateListener() const;
55 
56 private:
57 			status_t			_Initialize();
58 
59 			BDecisionProvider&	fDecisionProvider;
60 			BSupportKit::BJobStateListener&	fJobStateListener;
61 			status_t			fInitStatus;
62 
63 	mutable	BPrivate::TempfileManager*	fTempfileManager;
64 };
65 
66 
67 }	// namespace BPackageKit
68 
69 
70 #endif // _PACKAGE__CONTEXT_H_
71