xref: /haiku/headers/private/package/DaemonClient.h (revision 29f8805f6c70f1c819eb58ac2220647d8e40d6e7)
1 /*
2  * Copyright 2013, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold <ingo_weinhold@gmx.de>
7  */
8 #ifndef _PACKAGE__PRIVATE__DAEMON_CLIENT_H_
9 #define _PACKAGE__PRIVATE__DAEMON_CLIENT_H_
10 
11 
12 #include <Messenger.h>
13 #include <package/PackageDefs.h>
14 #include <String.h>
15 
16 #include <package/DaemonDefs.h>
17 
18 
19 class BDirectory;
20 
21 
22 namespace BPackageKit {
23 
24 
25 class BInstallationLocationInfo;
26 class BPackageInfoSet;
27 
28 
29 namespace BPrivate {
30 
31 
32 class BActivationTransaction;
33 
34 
35 class BDaemonClient {
36 public:
37 			class BCommitTransactionResult;
38 
39 public:
40 								BDaemonClient();
41 								~BDaemonClient();
42 
43 			status_t			GetInstallationLocationInfo(
44 									BPackageInstallationLocation location,
45 									BInstallationLocationInfo& _info);
46 			status_t			CommitTransaction(
47 									const BActivationTransaction& transaction,
48 									BCommitTransactionResult& _result);
49 
50 			status_t			CreateTransaction(
51 									BPackageInstallationLocation location,
52 									BActivationTransaction& _transaction,
53 									BDirectory& _transactionDirectory);
54 
55 private:
56 			status_t			_InitMessenger();
57 			status_t			_ExtractPackageInfoSet(const BMessage& message,
58 									const char* field, BPackageInfoSet& _infos);
59 
60 			status_t			_CommitTransaction(
61 									const BActivationTransaction& transaction,
62 									BCommitTransactionResult& _result);
63 
64 private:
65 			BMessenger			fDaemonMessenger;
66 };
67 
68 
69 class BDaemonClient::BCommitTransactionResult {
70 public:
71 								BCommitTransactionResult();
72 								BCommitTransactionResult(int32 error,
73 									const BString& errorMessage,
74 									const BString& errorPackage,
75 									const BString& oldStateDirectory);
76 								~BCommitTransactionResult();
77 
78 			void				SetTo(int32 error, const BString& errorMessage,
79 									const BString& errorPackage,
80 									const BString& oldStateDirectory);
81 
82 			status_t			Error() const;
83 			BDaemonError		DaemonError() const;
84 									// may be B_DAEMON_OK, even if Error() is
85 									// != B_OK, then Error() is as specific as
86 									// is known
87 			const BString&		ErrorMessage() const;
88 									// may be empty, even on error
89 			const BString&		ErrorPackage() const;
90 									// may be empty, even on error
91 
92 			BString				FullErrorMessage() const;
93 
94 			const BString&		OldStateDirectory() const;
95 
96 private:
97 			int32				fError;
98 			BString				fErrorMessage;
99 			BString				fErrorPackage;
100 			BString				fOldStateDirectory;
101 };
102 
103 
104 }	// namespace BPrivate
105 }	// namespace BPackageKit
106 
107 
108 #endif	// _PACKAGE__PRIVATE__DAEMON_CLIENT_H_
109