| 78 | } |
| 79 | |
| 80 | void DBusBridge::handleRootMethodCall(const std::string& method_name, GVariant* parameters, GDBusMethodInvocation* invocation) |
| 81 | { |
| 82 | if (method_name == "getParameter") { |
| 83 | GDBusError authErrorCode = G_DBUS_ERROR_FAILED; |
| 84 | const gchar* authErrorMessage = NULL; |
| 85 | |
| 86 | if (! isAuthorizedByPolkit(invocation, &authErrorCode, &authErrorMessage)) { |
| 87 | g_dbus_method_invocation_return_error_literal(invocation, G_DBUS_ERROR, authErrorCode, authErrorMessage); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | const char* name_cstr = nullptr; |
| 92 | g_variant_get(parameters, "(&s)", &name_cstr); |
| 93 | std::string name(name_cstr); |
| 94 | auto value = getParameter(name); |
| 95 | g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", value.c_str())); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | if (method_name == "setParameter") { |
| 100 | GDBusError authErrorCode = G_DBUS_ERROR_FAILED; |
| 101 | const gchar* authErrorMessage = NULL; |
| 102 | |
| 103 | if (! isAuthorizedByPolkit(invocation, &authErrorCode, &authErrorMessage)) { |
| 104 | g_dbus_method_invocation_return_error_literal(invocation, G_DBUS_ERROR, authErrorCode, authErrorMessage); |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | const char* name_cstr = nullptr; |
| 109 | const char* value_cstr = nullptr; |
| 110 | g_variant_get(parameters, "(&s&s)", &name_cstr, &value_cstr); |
| 111 | const std::string name(name_cstr); |
| 112 | const std::string value(value_cstr); |
| 113 | auto previous_value = setParameter(name, value); |
| 114 | g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", previous_value.c_str())); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, |
| 119 | G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method interface"); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | void DBusBridge::handlePolicyMethodCall(const std::string& method_name, GVariant* parameters, GDBusMethodInvocation* invocation) |
| 124 | { |
nothing calls this directly
no outgoing calls
no test coverage detected