[fix] sessiond: Rename DBus error enums so they are not confused with 48/275648/1
authorAdam Michalski <a.michalski2@partner.samsung.com>
Fri, 27 May 2022 12:03:05 +0000 (14:03 +0200)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Fri, 27 May 2022 12:03:05 +0000 (14:03 +0200)
the error codes defined in libsessiond.

Change-Id: I89964a5207a24d7b1b8cea482430dbfc83c731df

sessiond/src/main.cpp

index 36240ac..8a69bde 100644 (file)
@@ -126,12 +126,12 @@ struct sessiond_context {
        {
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return true;
                }
                if (subsession_id <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative subsession_id passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative subsession_id passed");
                        return true;
                }
 
@@ -170,7 +170,7 @@ struct sessiond_context {
                        current_subsession_id = last_subsession_per_session.at(session_uid);
                if (subsession_id == current_subsession_id) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_RESOURCE_BUSY].second.data(), "Cannot remove currently active user");
+                               sessiond_errors[DBUS_ERROR_RESOURCE_BUSY].second.data(), "Cannot remove currently active user");
                        return;
                }
 
@@ -193,19 +193,19 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
                // N.B. Switch to user '0' is possible and it means no subsession is currently active
                if (next_subsession_id < 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative subsession_id passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative subsession_id passed");
                        return;
                }
 
                if (next_subsession_id > 0 && !fs_helpers::subsession_exists(session_uid, next_subsession_id)) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_DOES_NOT_EXIST].second.data(), "Subsession does not exist");
+                               sessiond_errors[DBUS_ERROR_NOT_AVAILABLE].second.data(), "Subsession does not exist");
                        return;
                }
 
@@ -234,7 +234,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -250,7 +250,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -266,7 +266,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -308,7 +308,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -324,7 +324,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -345,7 +345,7 @@ struct sessiond_context {
 
                if (session_uid <= 0) {
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
+                               sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), "Negative UID passed");
                        return;
                }
 
@@ -381,28 +381,28 @@ struct sessiond_context {
                (self->*(to_call->second))(invocation, std::string_view(sender), parameters);
        } catch (const std::invalid_argument &ex) {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                       sessiond_errors[SUBSESSION_ERROR_INVALID_PARAMETER].second.data(), ex.what());
+                       sessiond_errors[DBUS_ERROR_INVALID_PARAMETER].second.data(), ex.what());
                log_exception(ex, sender, method_name);
        } catch (const std::system_error &ex) {
                switch (ex.code().value()) {
                case EEXIST:
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_ALREADY_EXISTS].second.data(), ex.what());
+                               sessiond_errors[DBUS_ERROR_ALREADY_EXISTS].second.data(), ex.what());
                        break;
                case ENOENT:
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_DOES_NOT_EXIST].second.data(), ex.what());
+                               sessiond_errors[DBUS_ERROR_NOT_AVAILABLE].second.data(), ex.what());
                        break;
                default:
                        g_dbus_method_invocation_return_dbus_error(invocation,
-                               sessiond_errors[SUBSESSION_ERROR_IO_ERROR].second.data(),
+                               sessiond_errors[DBUS_ERROR_IO_ERROR].second.data(),
                                (std::string("Unable to complete requested operation: ") + ex.what()).c_str());
                        break;
                }
                log_exception(ex, sender, method_name);
        } catch (const std::runtime_error &ex) {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                       sessiond_errors[SUBSESSION_ERROR_IO_ERROR].second.data(),
+                       sessiond_errors[DBUS_ERROR_IO_ERROR].second.data(),
                        (std::string("Unable to complete requested operation: ") + ex.what()).c_str());
                log_exception(ex, sender, method_name);
                // Swallow the exception; the show must go on
@@ -511,19 +511,19 @@ struct sessiond_context {
        };
 
        enum {
-               SUBSESSION_ERROR_INVALID_PARAMETER,
-               SUBSESSION_ERROR_IO_ERROR,
-               SUBSESSION_ERROR_ALREADY_EXISTS,
-               SUBSESSION_ERROR_DOES_NOT_EXIST,
-               SUBSESSION_ERROR_RESOURCE_BUSY,
+               DBUS_ERROR_INVALID_PARAMETER,
+               DBUS_ERROR_IO_ERROR,
+               DBUS_ERROR_ALREADY_EXISTS,
+               DBUS_ERROR_NOT_AVAILABLE,
+               DBUS_ERROR_RESOURCE_BUSY,
        };
 
        constexpr static std::array sessiond_errors = {
-               std::make_pair(SUBSESSION_ERROR_INVALID_PARAMETER, "org.tizen.sessiond.Error.InvalidParameter"sv),
-               std::make_pair(SUBSESSION_ERROR_IO_ERROR,          "org.tizen.sessiond.Error.IOError"sv),
-               std::make_pair(SUBSESSION_ERROR_ALREADY_EXISTS,    "org.tizen.sessiond.Error.SubsessionAlreadyExists"sv),
-               std::make_pair(SUBSESSION_ERROR_DOES_NOT_EXIST,    "org.tizen.sessiond.Error.SubsessionDoesNotExist"sv),
-               std::make_pair(SUBSESSION_ERROR_RESOURCE_BUSY,     "org.tizen.sessiond.Error.UserIsActive"sv),
+               std::make_pair(DBUS_ERROR_INVALID_PARAMETER, "org.tizen.sessiond.Error.InvalidParameter"sv),
+               std::make_pair(DBUS_ERROR_IO_ERROR,          "org.tizen.sessiond.Error.IOError"sv),
+               std::make_pair(DBUS_ERROR_ALREADY_EXISTS,    "org.tizen.sessiond.Error.SubsessionAlreadyExists"sv),
+               std::make_pair(DBUS_ERROR_NOT_AVAILABLE,     "org.tizen.sessiond.Error.SubsessionDoesNotExist"sv),
+               std::make_pair(DBUS_ERROR_RESOURCE_BUSY,     "org.tizen.sessiond.Error.UserIsActive"sv),
        };
 
        // TODO: Currently, the first parameter is always a single-element tuple.