diff --git a/README.md b/README.md index 01740c1..70affcf 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ A python script is the code-generator for `qfacedotnet`. It is possible to integ + @@ -114,11 +115,18 @@ A predefined name pattern of bus name makes detection of related services possib **_NOTE:_** The "qface.registry." pattern is used in case "DBUS_SERVICE_NAME_PATTERN" environment variable not defined -### Life time of objects +### Service Lifetime -One may end the a service lifetime on dbus by unregistering the `DBusAdapter`. +Individual services can be disposed by respective `DBusAdapter`. +Given [object management](#Object-Management) governs service-client relation it would lead into connected `DBusProxy`s [ready property](#ready-property)] to be set to false. ``` -server, err := dbus.SessionBus() -qfacedotnet.ObjectManager(server).UnregisterObject(DBusAdapter.ObjectPath(), nil) -``` \ No newline at end of file +DBusAdapter.Dispose(); +``` + +## Limitation + +There are some limitation with regards to qface: +* keyword [Model](https://doc.qt.io/qt-5/model-view-programming.html) is not supported +* keyword [Flag](https://doc.qt.io/QtIVI/idl-syntax.html#enum-or-flag) is not supported +* extends keyword is not supported diff --git a/src/generator/codegen.py b/src/generator/codegen.py index 0068e56..7db7176 100644 --- a/src/generator/codegen.py +++ b/src/generator/codegen.py @@ -9,7 +9,7 @@ parser = argparse.ArgumentParser(description='Generates bindings for Tmds based on the qface IDL.') parser.add_argument('--input', dest='input', type=str, required=True, nargs='+', - help='input qface interfaces, folders will be walked looking for qface interfaces') + help='input qface interfaces, folders will be globbed looking for qface interfaces') parser.add_argument('--output', dest='output', type=str, required=False, default='.', help='relative output path of the generated code, default value is current directory') parser.add_argument('--dependency', dest='dependency', type=str, required=False, nargs='+', default=[], diff --git a/src/generator/templates/DBusAdapter.cs.template b/src/generator/templates/DBusAdapter.cs.template index ab7ac95..a91edbb 100644 --- a/src/generator/templates/DBusAdapter.cs.template +++ b/src/generator/templates/DBusAdapter.cs.template @@ -7,12 +7,12 @@ using qfacedotnet; namespace {{module.qualified_name}} { - public class {{interface.name}}DBusAdapter : IDBus{{interface.name}} + public class {{interface.name}}DBusAdapter : IDBus{{interface.name}}, IDisposable { protected static ObjectPath _DefaultPath = new ObjectPath("/{{interface.qualified_name|replace(".","/")}}"); private readonly ObjectPath _Path; protected I{{interface.name}} _impl; - + private Connection _conn; public ObjectPath ObjectPath { get => _Path;} public {{interface.name}}DBusAdapter(I{{interface.name}} impl, string path = "/{{interface.qualified_name|replace(".","/")}}") { @@ -28,6 +28,7 @@ namespace {{module.qualified_name}} } public async Task RegisterObject(Connection conn) { + _conn = conn; (await qfacedotnet.ObjectManager.Manager(conn)).RegisterObject(_Path, new Dictionary>()); await conn.RegisterObjectAsync(this); } @@ -37,6 +38,11 @@ namespace {{module.qualified_name}} conn.UnregisterObject(this); } + public async void Dispose() + { + await UnregisterObject(_conn); + } + {% for property in interface.properties %} public virtual {{property.qfacedotnet_type}} {{property.name}} { diff --git a/test/AddressBook/AddressBookTests.cs b/test/AddressBook/AddressBookTests.cs index a48ae4e..0059b76 100644 --- a/test/AddressBook/AddressBookTests.cs +++ b/test/AddressBook/AddressBookTests.cs @@ -155,7 +155,7 @@ public async Task AdapterRemoved() var proxyReady2 = new TaskCompletionSource(); proxy.readyChanged += args => proxyReady2.SetResult(args); - await addressBookAdapter.UnregisterObject(conn2); + addressBookAdapter.Dispose(); await proxyReady2.Task; Assert.False(proxy.ready);