Fails to build with sdbus-cpp 2.0.0
Regressed by Kistler-Group/sdbus-cpp@bdf313bc60df. Note, some other sdbus-cpp consumers like xdg-desktop-portal-hyprland, hypridle have already switched to 2.0.0 API.
In file included from impl/Session.cpp:6:
In file included from impl/SecretService.h:9:
impl/../adaptors/secretsadaptor.h:26:17: error: no member named 'registerMethod' in 'sdbus::IObject'
26 | object_.registerMethod("OpenSession").onInterface(INTERFACE_NAME).withInputParamNames("algorithm", "input").withOutputParamNames("output", "result").implementedAs([this](const std::string& algorithm, const sdbus::Variant& input){ return this->OpenSession(algorithm, input); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:27:17: error: no member named 'registerMethod' in 'sdbus::IObject'
27 | object_.registerMethod("CreateCollection").onInterface(INTERFACE_NAME).withInputParamNames("properties", "alias").withOutputParamNames("collection", "prompt").implementedAs([this](const std::map<std::string, sdbus::Variant>& properties, const std::string& alias){ return this->CreateCollection(properties, alias); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:28:17: error: no member named 'registerMethod' in 'sdbus::IObject'
28 | object_.registerMethod("SearchItems").onInterface(INTERFACE_NAME).withInputParamNames("attributes").withOutputParamNames("unlocked", "locked").implementedAs([this](const std::map<std::string, std::string>& attributes){ return this->SearchItems(attributes); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:29:17: error: no member named 'registerMethod' in 'sdbus::IObject'
29 | object_.registerMethod("Unlock").onInterface(INTERFACE_NAME).withInputParamNames("objects").withOutputParamNames("unlocked", "prompt").implementedAs([this](const std::vector<sdbus::ObjectPath>& objects){ return this->Unlock(objects); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:30:17: error: no member named 'registerMethod' in 'sdbus::IObject'
30 | object_.registerMethod("Lock").onInterface(INTERFACE_NAME).withInputParamNames("objects").withOutputParamNames("locked", "Prompt").implementedAs([this](const std::vector<sdbus::ObjectPath>& objects){ return this->Lock(objects); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:31:17: error: no member named 'registerMethod' in 'sdbus::IObject'
31 | object_.registerMethod("LockService").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->LockService(); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:32:17: error: no member named 'registerMethod' in 'sdbus::IObject'
32 | object_.registerMethod("ChangeLock").onInterface(INTERFACE_NAME).withInputParamNames("collection").withOutputParamNames("prompt").implementedAs([this](const sdbus::ObjectPath& collection){ return this->ChangeLock(collection); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:33:17: error: no member named 'registerMethod' in 'sdbus::IObject'
33 | object_.registerMethod("GetSecrets").onInterface(INTERFACE_NAME).withInputParamNames("items", "session").withOutputParamNames("secrets").implementedAs([this](const std::vector<sdbus::ObjectPath>& items, const sdbus::ObjectPath& session){ return this->GetSecrets(items, session); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:34:17: error: no member named 'registerMethod' in 'sdbus::IObject'
34 | object_.registerMethod("ReadAlias").onInterface(INTERFACE_NAME).withInputParamNames("name").withOutputParamNames("collection").implementedAs([this](const std::string& name){ return this->ReadAlias(name); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:35:17: error: no member named 'registerMethod' in 'sdbus::IObject'
35 | object_.registerMethod("SetAlias").onInterface(INTERFACE_NAME).withInputParamNames("name", "collection").implementedAs([this](const std::string& name, const sdbus::ObjectPath& collection){ return this->SetAlias(name, collection); });
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:36:17: error: no member named 'registerSignal' in 'sdbus::IObject'
36 | object_.registerSignal("CollectionCreated").onInterface(INTERFACE_NAME).withParameters<sdbus::ObjectPath>("collection");
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:37:17: error: no member named 'registerSignal' in 'sdbus::IObject'
37 | object_.registerSignal("CollectionDeleted").onInterface(INTERFACE_NAME).withParameters<sdbus::ObjectPath>("collection");
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:38:17: error: no member named 'registerSignal' in 'sdbus::IObject'
38 | object_.registerSignal("CollectionChanged").onInterface(INTERFACE_NAME).withParameters<sdbus::ObjectPath>("collection");
| ~~~~~~~ ^
impl/../adaptors/secretsadaptor.h:39:17: error: no member named 'registerProperty' in 'sdbus::IObject'
39 | object_.registerProperty("Collections").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Collections(); });
| ~~~~~~~ ^
I believe what happened is that sdbus-cpp dependency has released a new major version v2.0.0 and it has a bunch of breaking changes, which requires some maintenance to make pass-secrets work again.
I am not very familiar with it nor its APIs at all, but I was able to find some short summary about this, I hope this can be helpful: https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c++.md#migrating-to-sdbus-c-v2
If nothing happens, I'll try to migrate the old methods into new API and maybe make a pull request with fixes, but for the time being I'm throwing out this information - maybe someone smarter can make a fix better/faster.
Also, I believe that #14 is basically the same issue.
Thanks for the pointers. I've been very busy recently, so if someone could make a PR I wouldn't mind. If not, I can probably fix this sometime next month.
Most of the breakage came from sdbus implementing stronger types: These have been fixed in hopefully all relevent places by instanciating the correct classes.
These mainly impact the following instances:
sdbus::Error("NAME", "MSG");
sdbus::Error(sdbus::Error::Name{"NAME"}, "MSG");
emitPropertiesChangedSignal("NAME", {"PROPERTY"});
emitPropertiesChangedSignal(sdbus::InterfaceName("NAME"), { sdbus::PropertyName("PROPERTY") })
AdaptorInterfaces(conn, std::move(path))
AdaptorInterfaces(conn, sdbus::ObjectPath(path))
I think that these objects have the right lifetime and are properly destroyed after use.
Someone with more c++ experience needs to verify this.
Especially the instanciation in the AdaptorInterfaces where I have removed the std::move.
Also all instances of getObjectPath() have been prefixed with the required getObject().
I was running into a compilation error registering the Close() method in the Session/Plain class.
The problem stems from it having a different signature than its parent class.
I have created a stub Close_Stub() which matches the expected signature.
You should look into properly fixing this as I don't fully understand it.
All adaptors needed to be regenerated using sdbus-c++-xml2cpp.
This patch includes those regenerated files.
I have regenerated them using:
cd adaptors/
sdbus-c++-xml2cpp --adaptor=collectionadaptor.h ../introspection/collection.xml
...
Polling
The following is in regard to the polling DBus Events in main.cpp.
The changes follow the recomendations in [1].
renamed processPendingRequest() to processPendingEvent()
Poll fd and eventFd.
The member for timeout polling has been changed to std::chrono::microseconds.
The invalid check has been removed.
TODO: You need to check whether this is still needed.
[1] https://raw.githubusercontent.com/Kistler-Group/sdbus-cpp/refs/heads/master/docs/using-sdbus-c%2B%2B.md