2 * Copyright 2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _PACKAGE__COMMIT_TRANSACTION_RESULT_H_
6 #define _PACKAGE__COMMIT_TRANSACTION_RESULT_H_
9 #include <ObjectList.h>
16 namespace BPackageKit
{
19 enum BTransactionError
{
21 B_TRANSACTION_NO_MEMORY
,
22 B_TRANSACTION_INTERNAL_ERROR
,
23 B_TRANSACTION_INSTALLATION_LOCATION_BUSY
,
24 B_TRANSACTION_CHANGE_COUNT_MISMATCH
,
25 B_TRANSACTION_BAD_REQUEST
,
26 B_TRANSACTION_NO_SUCH_PACKAGE
,
27 B_TRANSACTION_PACKAGE_ALREADY_EXISTS
,
28 B_TRANSACTION_FAILED_TO_GET_ENTRY_PATH
,
29 B_TRANSACTION_FAILED_TO_OPEN_DIRECTORY
,
30 B_TRANSACTION_FAILED_TO_CREATE_DIRECTORY
,
31 B_TRANSACTION_FAILED_TO_REMOVE_DIRECTORY
,
32 B_TRANSACTION_FAILED_TO_MOVE_DIRECTORY
,
33 B_TRANSACTION_FAILED_TO_WRITE_ACTIVATION_FILE
,
34 B_TRANSACTION_FAILED_TO_READ_PACKAGE_FILE
,
35 B_TRANSACTION_FAILED_TO_EXTRACT_PACKAGE_FILE
,
36 B_TRANSACTION_FAILED_TO_OPEN_FILE
,
37 B_TRANSACTION_FAILED_TO_MOVE_FILE
,
38 B_TRANSACTION_FAILED_TO_COPY_FILE
,
39 B_TRANSACTION_FAILED_TO_WRITE_FILE_ATTRIBUTE
,
40 B_TRANSACTION_FAILED_TO_ACCESS_ENTRY
,
41 B_TRANSACTION_FAILED_TO_ADD_GROUP
,
42 B_TRANSACTION_FAILED_TO_ADD_USER
,
43 B_TRANSACTION_FAILED_TO_ADD_USER_TO_GROUP
,
44 B_TRANSACTION_FAILED_TO_CHANGE_PACKAGE_ACTIVATION
,
48 class BTransactionIssue
{
51 B_WRITABLE_FILE_TYPE_MISMATCH
,
52 B_WRITABLE_FILE_NO_PACKAGE_ATTRIBUTE
,
53 B_WRITABLE_FILE_OLD_ORIGINAL_FILE_MISSING
,
54 B_WRITABLE_FILE_OLD_ORIGINAL_FILE_TYPE_MISMATCH
,
55 B_WRITABLE_FILE_COMPARISON_FAILED
,
56 B_WRITABLE_FILE_NOT_EQUAL
,
57 B_WRITABLE_SYMLINK_COMPARISON_FAILED
,
58 B_WRITABLE_SYMLINK_NOT_EQUAL
,
59 B_POST_INSTALL_SCRIPT_NOT_FOUND
,
60 B_STARTING_POST_INSTALL_SCRIPT_FAILED
,
61 B_POST_INSTALL_SCRIPT_FAILED
,
66 BTransactionIssue(BType type
,
67 const BString
& packageName
,
68 const BString
& path1
, const BString
& path2
,
69 status_t systemError
, int exitCode
);
71 const BTransactionIssue
& other
);
75 const BString
& PackageName() const;
76 const BString
& Path1() const;
77 const BString
& Path2() const;
78 status_t
SystemError() const;
81 BString
ToString() const;
83 status_t
AddToMessage(BMessage
& message
) const;
84 status_t
ExtractFromMessage(const BMessage
& message
);
86 BTransactionIssue
& operator=(const BTransactionIssue
& other
);
93 status_t fSystemError
;
98 class BCommitTransactionResult
{
100 BCommitTransactionResult();
101 BCommitTransactionResult(
102 BTransactionError error
);
103 BCommitTransactionResult(
104 const BCommitTransactionResult
& other
);
105 ~BCommitTransactionResult();
109 int32
CountIssues() const;
110 const BTransactionIssue
* IssueAt(int32 index
) const;
111 bool AddIssue(const BTransactionIssue
& issue
);
113 BTransactionError
Error() const;
114 void SetError(BTransactionError error
);
116 status_t
SystemError() const;
117 void SetSystemError(status_t error
);
119 const BString
& ErrorPackage() const;
120 // may be empty, even on error
121 void SetErrorPackage(const BString
& packageName
);
123 BString
FullErrorMessage() const;
125 const BString
& Path1() const;
126 void SetPath1(const BString
& path
);
128 const BString
& Path2() const;
129 void SetPath2(const BString
& path
);
131 const BString
& Path3() const;
132 void SetPath3(const BString
& path
);
134 const BString
& String1() const;
135 void SetString1(const BString
& string
);
137 const BString
& String2() const;
138 void SetString2(const BString
& string
);
140 const BString
& OldStateDirectory() const;
141 void SetOldStateDirectory(const BString
& directory
);
143 status_t
AddToMessage(BMessage
& message
) const;
144 status_t
ExtractFromMessage(const BMessage
& message
);
146 BCommitTransactionResult
& operator=(
147 const BCommitTransactionResult
& other
);
150 typedef BObjectList
<BTransactionIssue
> IssueList
;
153 BTransactionError fError
;
154 status_t fSystemError
;
155 BString fErrorPackage
;
160 BString fOldStateDirectory
;
165 } // namespace BPackageKit
168 #endif // _PACKAGE__COMMIT_TRANSACTION_RESULT_H_