1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "dbus/dbus_result.h"
6 #include "dbus/message.h"
10 DBusResult GetResult(dbus::ErrorResponse* response) {
12 return DBusResult::kErrorResponseMissing;
15 const std::string& error_name = response->GetErrorName();
16 if (error_name == DBUS_ERROR_NO_REPLY) {
17 return DBusResult::kErrorNoReply;
20 if (error_name == DBUS_ERROR_TIMEOUT) {
21 return DBusResult::kErrorTimeout;
24 if (error_name == DBUS_ERROR_TIMED_OUT) {
25 return DBusResult::kErrorTimedOut;
28 if (error_name == DBUS_ERROR_NOT_SUPPORTED) {
29 return DBusResult::kErrorNotSupported;
32 if (error_name == DBUS_ERROR_ACCESS_DENIED) {
33 return DBusResult::kErrorAccessDenied;
36 if (error_name == DBUS_ERROR_DISCONNECTED) {
37 return DBusResult::kErrorDisconnected;
40 if (error_name == DBUS_ERROR_FAILED) {
41 return DBusResult::kErrorFailed;
44 if (error_name == DBUS_ERROR_NO_MEMORY) {
45 return DBusResult::kErrorNoMemory;
48 if (error_name == DBUS_ERROR_SERVICE_UNKNOWN) {
49 return DBusResult::kErrorServiceUnknown;
52 if (error_name == DBUS_ERROR_NAME_HAS_NO_OWNER) {
53 return DBusResult::kErrorNameHasNoOwner;
56 if (error_name == DBUS_ERROR_IO_ERROR) {
57 return DBusResult::kErrorIOError;
60 if (error_name == DBUS_ERROR_BAD_ADDRESS) {
61 return DBusResult::kErrorBadAddress;
64 if (error_name == DBUS_ERROR_LIMITS_EXCEEDED) {
65 return DBusResult::kErrorLimitsExceeded;
68 if (error_name == DBUS_ERROR_AUTH_FAILED) {
69 return DBusResult::kErrorAuthFailed;
72 if (error_name == DBUS_ERROR_NO_SERVER) {
73 return DBusResult::kErrorNoServer;
76 if (error_name == DBUS_ERROR_NO_NETWORK) {
77 return DBusResult::kErrorNoNetwork;
80 if (error_name == DBUS_ERROR_ADDRESS_IN_USE) {
81 return DBusResult::kErrorAddressInUse;
84 if (error_name == DBUS_ERROR_DISCONNECTED) {
85 return DBusResult::kErrorDisconnected;
88 if (error_name == DBUS_ERROR_INVALID_ARGS) {
89 return DBusResult::kErrorInvalidArgs;
92 if (error_name == DBUS_ERROR_FILE_NOT_FOUND) {
93 return DBusResult::kErrorFileNotFound;
96 if (error_name == DBUS_ERROR_FILE_EXISTS) {
97 return DBusResult::kErrorFileExists;
100 if (error_name == DBUS_ERROR_UNKNOWN_METHOD) {
101 return DBusResult::kErrorUnknownMethod;
104 if (error_name == DBUS_ERROR_UNKNOWN_OBJECT) {
105 return DBusResult::kErrorUnknownObject;
108 if (error_name == DBUS_ERROR_UNKNOWN_INTERFACE) {
109 return DBusResult::kErrorUnknownInterface;
112 if (error_name == DBUS_ERROR_UNKNOWN_PROPERTY) {
113 return DBusResult::kErrorUnknownProperty;
116 if (error_name == DBUS_ERROR_PROPERTY_READ_ONLY) {
117 return DBusResult::kErrorPropertyReadOnly;
120 if (error_name == DBUS_ERROR_MATCH_RULE_NOT_FOUND) {
121 return DBusResult::kErrorMatchRuleNotFound;
124 if (error_name == DBUS_ERROR_MATCH_RULE_INVALID) {
125 return DBusResult::kErrorMatchRuleInvalid;
128 if (error_name == DBUS_ERROR_SPAWN_EXEC_FAILED) {
129 return DBusResult::kErrorSpawnExecFailed;
132 if (error_name == DBUS_ERROR_SPAWN_FORK_FAILED) {
133 return DBusResult::kErrorSpawnForkFailed;
136 if (error_name == DBUS_ERROR_SPAWN_CHILD_EXITED) {
137 return DBusResult::kErrorSpawnChildExited;
140 if (error_name == DBUS_ERROR_SPAWN_CHILD_SIGNALED) {
141 return DBusResult::kErrorSpawnChildSignaled;
144 if (error_name == DBUS_ERROR_SPAWN_FAILED) {
145 return DBusResult::kErrorSpawnFailed;
148 if (error_name == DBUS_ERROR_SPAWN_SETUP_FAILED) {
149 return DBusResult::kErrorSpawnSetupFailed;
152 if (error_name == DBUS_ERROR_SPAWN_CONFIG_INVALID) {
153 return DBusResult::kErrorSpawnConfigInvalid;
156 if (error_name == DBUS_ERROR_SPAWN_SERVICE_INVALID) {
157 return DBusResult::kErrorSpawnServiceInvalid;
160 if (error_name == DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND) {
161 return DBusResult::kErrorSpawnServiceNotFound;
164 if (error_name == DBUS_ERROR_SPAWN_PERMISSIONS_INVALID) {
165 return DBusResult::kErrorSpawnPermissionsInvalid;
168 if (error_name == DBUS_ERROR_SPAWN_FILE_INVALID) {
169 return DBusResult::kErrorSpawnFileInvalid;
172 if (error_name == DBUS_ERROR_SPAWN_NO_MEMORY) {
173 return DBusResult::kErrorSpawnNoMemory;
176 if (error_name == DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN) {
177 return DBusResult::kErrorUnixProcessIDUnknown;
180 if (error_name == DBUS_ERROR_INVALID_SIGNATURE) {
181 return DBusResult::kErrorInvalidSignature;
184 if (error_name == DBUS_ERROR_INVALID_FILE_CONTENT) {
185 return DBusResult::kErrorInvalidFileContent;
188 if (error_name == DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN) {
189 return DBusResult::kErrorSELinuxSecurityContextUnknown;
192 if (error_name == DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN) {
193 return DBusResult::kErrorAdtAuditDataUnknown;
196 if (error_name == DBUS_ERROR_OBJECT_PATH_IN_USE) {
197 return DBusResult::kErrorObjectPathInUse;
200 if (error_name == DBUS_ERROR_INCONSISTENT_MESSAGE) {
201 return DBusResult::kErrorInconsistentMessage;
204 if (error_name == DBUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED) {
205 return DBusResult::kErrorInteractiveAuthorizationRequired;
208 return DBusResult::kErrorUnknown;