Message ID | 20231109184926.52629-2-prestwoj@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/3] client: Add shared code DBus interface | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
prestwoj/iwd-ci-gitlint | success | GitLint |
Hi James, On 11/9/23 12:49, James Prestwood wrote: > There was no way to call a method with anything except basic > arguments. Add a helper to use a builder to create more complex > args. > --- > client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++- > client/dbus-proxy.h | 9 +++++++++ > 2 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c > index 42b8427f..de252427 100644 > --- a/client/dbus-proxy.c > +++ b/client/dbus-proxy.c > @@ -2,7 +2,7 @@ > * > * Wireless daemon for Linux > * > - * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. > + * Copyright (C) 2017-2023 Intel Corporation. All rights reserved. Is this correct? > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy, > return true; > } > > +struct l_dbus_message_builder *proxy_interface_new_builder( > + const struct proxy_interface *proxy, > + const char *name) > +{ > + struct l_dbus_message *call = l_dbus_message_new_method_call(dbus, > + IWD_SERVICE, proxy->path, > + proxy->type->interface, name); > + > + return l_dbus_message_builder_new(call); Do you really need this 2 line function for a single call site? > +} > + > +bool proxy_interface_method_call_from_builder( > + const struct proxy_interface *proxy, > + struct l_dbus_message_builder *builder, > + l_dbus_message_func_t callback) > +{ > + struct proxy_callback_data *callback_data; > + struct l_dbus_message *call; > + > + if (!proxy || !builder) > + return false; > + > + call = l_dbus_message_builder_finalize(builder); > + > + callback_data = l_new(struct proxy_callback_data, 1); > + callback_data->callback = callback; > + callback_data->user_data = (void *) proxy; > + > + l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data, > + l_free); > + > + return true; > +} > + > void *proxy_interface_get_data(const struct proxy_interface *proxy) > { > return proxy->data; Regards, -Denis
Hi Denis, On 11/9/23 6:22 PM, Denis Kenzior wrote: > Hi James, > > On 11/9/23 12:49, James Prestwood wrote: >> There was no way to call a method with anything except basic >> arguments. Add a helper to use a builder to create more complex >> args. >> --- >> client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++- >> client/dbus-proxy.h | 9 +++++++++ >> 2 files changed, 44 insertions(+), 1 deletion(-) >> >> diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c >> index 42b8427f..de252427 100644 >> --- a/client/dbus-proxy.c >> +++ b/client/dbus-proxy.c >> @@ -2,7 +2,7 @@ >> * >> * Wireless daemon for Linux >> * >> - * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. >> + * Copyright (C) 2017-2023 Intel Corporation. All rights reserved. > > Is this correct? I'm generally terrible about updating the dates on the copyright and really never do it. Decided I'd try and do better this time :) But I'm not actually sure how this works. Should there be multiple copyright notices if different companies touch existing files? or should we just leave the copyrights as-is if the file already exists. > >> * >> * This library is free software; you can redistribute it and/or >> * modify it under the terms of the GNU Lesser General Public >> @@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct >> proxy_interface *proxy, >> return true; >> } >> +struct l_dbus_message_builder *proxy_interface_new_builder( >> + const struct proxy_interface *proxy, >> + const char *name) >> +{ >> + struct l_dbus_message *call = l_dbus_message_new_method_call(dbus, >> + IWD_SERVICE, proxy->path, >> + proxy->type->interface, name); >> + >> + return l_dbus_message_builder_new(call); > > Do you really need this 2 line function for a single call site? With knowledge that l_dbus_message_set_arguments can handle dictionaries I don't need this patch at all :) > >> +} >> + >> +bool proxy_interface_method_call_from_builder( >> + const struct proxy_interface *proxy, >> + struct l_dbus_message_builder *builder, >> + l_dbus_message_func_t callback) >> +{ >> + struct proxy_callback_data *callback_data; >> + struct l_dbus_message *call; >> + >> + if (!proxy || !builder) >> + return false; >> + >> + call = l_dbus_message_builder_finalize(builder); >> + >> + callback_data = l_new(struct proxy_callback_data, 1); >> + callback_data->callback = callback; >> + callback_data->user_data = (void *) proxy; >> + >> + l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data, >> + l_free); >> + >> + return true; >> +} >> + >> void *proxy_interface_get_data(const struct proxy_interface *proxy) >> { >> return proxy->data; > > Regards, > -Denis >
Hi Denis, On 11/10/23 4:28 AM, James Prestwood wrote: > Hi Denis, > > On 11/9/23 6:22 PM, Denis Kenzior wrote: >> Hi James, >> >> On 11/9/23 12:49, James Prestwood wrote: >>> There was no way to call a method with anything except basic >>> arguments. Add a helper to use a builder to create more complex >>> args. >>> --- >>> client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++- >>> client/dbus-proxy.h | 9 +++++++++ >>> 2 files changed, 44 insertions(+), 1 deletion(-) >>> >>> diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c >>> index 42b8427f..de252427 100644 >>> --- a/client/dbus-proxy.c >>> +++ b/client/dbus-proxy.c >>> @@ -2,7 +2,7 @@ >>> * >>> * Wireless daemon for Linux >>> * >>> - * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. >>> + * Copyright (C) 2017-2023 Intel Corporation. All rights reserved. >> >> Is this correct? > > I'm generally terrible about updating the dates on the copyright and > really never do it. Decided I'd try and do better this time :) > > But I'm not actually sure how this works. Should there be multiple > copyright notices if different companies touch existing files? or should > we just leave the copyrights as-is if the file already exists. Nevermind, took a look at the kernel and they just append the companies/dates. It had been so long at Intel I forgot how all this worked :) Thanks, James
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c index 42b8427f..de252427 100644 --- a/client/dbus-proxy.c +++ b/client/dbus-proxy.c @@ -2,7 +2,7 @@ * * Wireless daemon for Linux * - * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. + * Copyright (C) 2017-2023 Intel Corporation. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy, return true; } +struct l_dbus_message_builder *proxy_interface_new_builder( + const struct proxy_interface *proxy, + const char *name) +{ + struct l_dbus_message *call = l_dbus_message_new_method_call(dbus, + IWD_SERVICE, proxy->path, + proxy->type->interface, name); + + return l_dbus_message_builder_new(call); +} + +bool proxy_interface_method_call_from_builder( + const struct proxy_interface *proxy, + struct l_dbus_message_builder *builder, + l_dbus_message_func_t callback) +{ + struct proxy_callback_data *callback_data; + struct l_dbus_message *call; + + if (!proxy || !builder) + return false; + + call = l_dbus_message_builder_finalize(builder); + + callback_data = l_new(struct proxy_callback_data, 1); + callback_data->callback = callback; + callback_data->user_data = (void *) proxy; + + l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data, + l_free); + + return true; +} + void *proxy_interface_get_data(const struct proxy_interface *proxy) { return proxy->data; diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h index cd1b2305..94625b85 100644 --- a/client/dbus-proxy.h +++ b/client/dbus-proxy.h @@ -90,6 +90,15 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy, const char *name, const char *signature, l_dbus_message_func_t callback, ...); +bool proxy_interface_method_call_from_builder( + const struct proxy_interface *proxy, + struct l_dbus_message_builder *builder, + l_dbus_message_func_t callback); + +struct l_dbus_message_builder *proxy_interface_new_builder( + const struct proxy_interface *proxy, + const char *name); + void proxy_properties_display(const struct proxy_interface *proxy, const char *caption, const char *margin, unsigned int name_column_width,