0

DBus呼び出しを使用してsystemdサービスを管理することに頭を悩ませようとしています。ただし、何をしてもDBusエラーがスローされるため、メソッド呼び出しを行う正しい方法を理解できないようです

// Create connection
auto connection = Gio::DBus::Connection::get_sync(Gio::DBus::BusType::BUS_TYPE_SESSION);
// Create the parameters vector
std::vector<std::string> param_vec;
param_vec.push_back("my_unit_name");
auto param_vec_variant = Glib::Variant<std::vector<std::string>>::create(param_vec);
auto params = Glib::Variant<std::vector<std::string>>::create_tuple(param_vec_variant);

try {
    // Make the "GetUnit" dbus call to systemd
    auto response = connection->call_sync(
        "/org/freedesktop/systemd1",
        "org.freedesktop.systemd1.Manager",
        "GetUnit",
        params
    );
}
catch (Gio::DBus::Error err) {
    // org.freedesktop.DBus.Error.UnknownMethod being thrown
    std::cerr << Gio::DBus::ErrorUtils::get_remote_error(err) << std::endl;
}

誰かが私が間違っているところを指摘できますか?

4

1 に答える 1