diff mbox series

[RFC,2/5] dbus: remove iwd.h dependency

Message ID 20230630191812.2884637-3-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series Initial refactor for hwsim frame processing | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood June 30, 2023, 7:18 p.m. UTC
Require a compile time flag to set the service
---
 Makefile.am |  1 +
 src/dbus.c  | 33 ++++++++++++++++-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

Comments

Denis Kenzior July 6, 2023, 3:17 a.m. UTC | #1
Hi James,

On 6/30/23 14:18, James Prestwood wrote:
> Require a compile time flag to set the service
> ---
>   Makefile.am |  1 +
>   src/dbus.c  | 33 ++++++++++++++++-----------------
>   2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 401d2ac5..2fb03aa9 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -268,6 +268,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \
>   
>   src_iwd_LDADD = $(ell_ldadd) -ldl
>   src_iwd_DEPENDENCIES = $(ell_dependencies)
> +src_iwd_CFLAGS = -DDBUS_SERVICE=\"net.connman.iwd\"
>   

I'm not really a fan of doing it this way.

> @@ -38,99 +37,99 @@ static dbus_agent_shutdown_func_t agent_shutdown;
>   
>   struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg)
>   {
> -	return l_dbus_message_new_error(msg, IWD_SERVICE ".InProgress",
> +	return l_dbus_message_new_error(msg, DBUS_SERVICE ".InProgress",
>   					"Operation already in progress");

I wonder if we can add this to ell instead.  We have almost the same code in 
oFono for example. And something very similar inside connman src/error.c.

Perhaps we can simply pull the name from l_dbus_name_acquire?  Our apps are 
unlikely to ever register more than a single service name on the bus?  Other ideas?

Regards,
-Denis
James Prestwood July 10, 2023, 4:58 p.m. UTC | #2
Hi Denis,

On 7/5/23 8:17 PM, Denis Kenzior wrote:
> Hi James,
> 
> On 6/30/23 14:18, James Prestwood wrote:
>> Require a compile time flag to set the service
>> ---
>>   Makefile.am |  1 +
>>   src/dbus.c  | 33 ++++++++++++++++-----------------
>>   2 files changed, 17 insertions(+), 17 deletions(-)
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index 401d2ac5..2fb03aa9 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -268,6 +268,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h 
>> src/iwd.h src/missing.h \
>>   src_iwd_LDADD = $(ell_ldadd) -ldl
>>   src_iwd_DEPENDENCIES = $(ell_dependencies)
>> +src_iwd_CFLAGS = -DDBUS_SERVICE=\"net.connman.iwd\"
> 
> I'm not really a fan of doing it this way.
> 
>> @@ -38,99 +37,99 @@ static dbus_agent_shutdown_func_t agent_shutdown;
>>   struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg)
>>   {
>> -    return l_dbus_message_new_error(msg, IWD_SERVICE ".InProgress",
>> +    return l_dbus_message_new_error(msg, DBUS_SERVICE ".InProgress",
>>                       "Operation already in progress");
> 
> I wonder if we can add this to ell instead.  We have almost the same 
> code in oFono for example. And something very similar inside connman 
> src/error.c.
> 
> Perhaps we can simply pull the name from l_dbus_name_acquire?  Our apps 
> are unlikely to ever register more than a single service name on the 
> bus?  Other ideas?

Since ofono and maybe others have the same code I can add these in ELL 
and use the service name thats registered.

> 
> Regards,
> -Denis
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 401d2ac5..2fb03aa9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -268,6 +268,7 @@  src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \
 
 src_iwd_LDADD = $(ell_ldadd) -ldl
 src_iwd_DEPENDENCIES = $(ell_dependencies)
+src_iwd_CFLAGS = -DDBUS_SERVICE=\"net.connman.iwd\"
 
 if OFONO
 builtin_modules += ofono
diff --git a/src/dbus.c b/src/dbus.c
index 1e0021f2..4ffa4db1 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -30,7 +30,6 @@ 
 
 #include <ell/ell.h>
 
-#include "src/iwd.h"
 #include "src/dbus.h"
 
 static struct l_dbus *g_dbus = NULL;
@@ -38,99 +37,99 @@  static dbus_agent_shutdown_func_t agent_shutdown;
 
 struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".InProgress",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".InProgress",
 					"Operation already in progress");
 }
 
 struct l_dbus_message *dbus_error_failed(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".Failed",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".Failed",
 					"Operation failed");
 }
 
 struct l_dbus_message *dbus_error_aborted(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".Aborted",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".Aborted",
 					"Operation aborted");
 }
 
 struct l_dbus_message *dbus_error_not_available(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotAvailable",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotAvailable",
 					"Operation not available");
 }
 
 struct l_dbus_message *dbus_error_invalid_args(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".InvalidArguments",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".InvalidArguments",
 					"Argument type is wrong");
 }
 
 struct l_dbus_message *dbus_error_invalid_format(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".InvalidFormat",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".InvalidFormat",
 					"Argument format is invalid");
 }
 
 struct l_dbus_message *dbus_error_already_exists(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".AlreadyExists",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".AlreadyExists",
 					"Object already exists");
 }
 
 struct l_dbus_message *dbus_error_not_found(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotFound",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotFound",
 					"Object not found");
 }
 
 struct l_dbus_message *dbus_error_not_supported(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotSupported",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotSupported",
 					"Operation not supported");
 }
 
 struct l_dbus_message *dbus_error_no_agent(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NoAgent",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NoAgent",
 					"No Agent registered");
 }
 
 struct l_dbus_message *dbus_error_not_connected(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotConnected",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotConnected",
 					"Not connected");
 }
 
 struct l_dbus_message *dbus_error_not_configured(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotConfigured",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotConfigured",
 					"Not configured");
 }
 
 struct l_dbus_message *dbus_error_not_implemented(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotImplemented",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotImplemented",
 					"Not implemented");
 }
 
 struct l_dbus_message *dbus_error_service_set_overlap(
 						struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".ServiceSetOverlap",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".ServiceSetOverlap",
 					"Service set overlap");
 }
 
 struct l_dbus_message *dbus_error_already_provisioned(
 						struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".AlreadyProvisioned",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".AlreadyProvisioned",
 					"Already provisioned");
 }
 
 struct l_dbus_message *dbus_error_not_hidden(struct l_dbus_message *msg)
 {
-	return l_dbus_message_new_error(msg, IWD_SERVICE ".NotHidden",
+	return l_dbus_message_new_error(msg, DBUS_SERVICE ".NotHidden",
 					"Not hidden");
 }