Skip to content

Commit

Permalink
Merge branch 'jb49969_dbus_config' into 'master'
Browse files Browse the repository at this point in the history
Autogenerate D-Bus introspect and busconfig XML

See merge request mer-core/usb-moded!61
  • Loading branch information
spiiroin committed Jun 9, 2020
2 parents 80d0d0e + 08f2c5a commit 1c706dc
Show file tree
Hide file tree
Showing 9 changed files with 1,286 additions and 654 deletions.
15 changes: 15 additions & 0 deletions Makefile.custom
Expand Up @@ -203,6 +203,15 @@ usb_moded-OBJS += src/usb_moded-worker.o
usb_moded : $(usb_moded-OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)

update-configs:: debian/usb_moded.conf
update-configs:: src/com.meego.usb_moded.xml

debian/usb_moded.conf: usb_moded
./usb_moded --dbus-busconfig-xml > $@

src/com.meego.usb_moded.xml: usb_moded
./usb_moded --dbus-introspect-xml > $@

# ----------------------------------------------------------------------------
# usb-moded-devel
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -343,6 +352,12 @@ PROTO_CPPFLAGS += -DOFONO
PROTO_CPPFLAGS += -DSYSTEMD
PROTO_CPPFLAGS += -DUSE_MER_SSU
PROTO_CPPFLAGS += -DVERBOSE_WAKELOCKING=1
PROTO_CPPFLAGS += -D_Float32=float
PROTO_CPPFLAGS += -D_Float64=double
PROTO_CPPFLAGS += -D_Float128="long double"
PROTO_CPPFLAGS += -D_Float32x=float
PROTO_CPPFLAGS += -D_Float64x=double
PROTO_CPPFLAGS += -D_Float128x="long double"

%.q : CPPFLAGS += $(PROTO_CPPFLAGS)
%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) -O
Expand Down
101 changes: 67 additions & 34 deletions debian/usb_moded.conf
@@ -1,39 +1,72 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
<policy user="root">
<allow own="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"/>
</policy>
<policy context="default">
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="set_mode"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="mode_request"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="set_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_modes"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="net_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_net_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="rescue_off"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_target_mode_config"/>
<deny send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="set_whitelist"/>
<deny send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="set_in_whitelist"/>
<allow send_interface="org.freedesktop.DBus.Introspectable" />
<allow send_destination="com.meego.usb_moded" />
<deny own="com.meego.usb_moded"/>
</policy>
<policy user="root">
<allow own="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"/>
</policy>
<policy context="default">
<deny own="com.meego.usb_moded"/>
<deny send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="mode_request"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_target_state"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_target_mode_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="set_mode"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="set_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_modes"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_available_modes"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_available_modes_for_user"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="hide_mode"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="unhide_mode"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_hidden"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_whitelisted_modes"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="set_whitelisted_modes"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="set_whitelisted"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="net_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="get_net_config"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded"
send_member="rescue_off"/>
</policy>
</busconfig>

56 changes: 29 additions & 27 deletions src/com.meego.usb_moded.xml
@@ -1,5 +1,7 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

<node name="/com/meego/usb_moded">
<interface name="com.meego.usb_moded">
<method name="mode_request">
Expand All @@ -8,6 +10,10 @@
<method name="get_target_state">
<arg name="mode" type="s" direction="out"/>
</method>
<method name="get_target_mode_config">
<arg name="config" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method>
<method name="set_mode">
<arg name="mode" type="s" direction="in"/>
<arg name="mode" type="s" direction="out"/>
Expand All @@ -16,17 +22,6 @@
<arg name="config" type="s" direction="in"/>
<arg name="config" type="s" direction="out"/>
</method>
<method name="net_config">
<arg name="key" type="s" direction="in"/>
<arg name="value" type="s" direction="in"/>
<arg name="key" type="s" direction="out"/>
<arg name="value" type="s" direction="out"/>
</method>
<method name="get_net_config">
<arg name="key" type="s" direction="in"/>
<arg name="key" type="s" direction="out"/>
<arg name="value" type="s" direction="out"/>
</method>
<method name="get_config">
<arg name="mode" type="s" direction="out"/>
</method>
Expand Down Expand Up @@ -60,6 +55,17 @@
<arg name="mode" type="s" direction="in"/>
<arg name="whitelisted" type="b" direction="in"/>
</method>
<method name="net_config">
<arg name="key" type="s" direction="in"/>
<arg name="value" type="s" direction="in"/>
<arg name="key" type="s" direction="out"/>
<arg name="value" type="s" direction="out"/>
</method>
<method name="get_net_config">
<arg name="key" type="s" direction="in"/>
<arg name="key" type="s" direction="out"/>
<arg name="value" type="s" direction="out"/>
</method>
<method name="rescue_off"/>
<signal name="sig_usb_state_ind">
<arg name="mode_or_event" type="s"/>
Expand All @@ -70,36 +76,32 @@
<signal name="sig_usb_target_state_ind">
<arg name="mode" type="s"/>
</signal>
<signal name="sig_usb_taget_mode_config_ind">
<arg name="config" type="a{sv}"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
</signal>
<signal name="sig_usb_event_ind">
<arg name="event" type="s"/>
</signal>
<signal name="sig_usb_state_error_ind">
<arg name="error" type="s"/>
<signal name="sig_usb_config_ind">
<arg name="section" type="s"/>
<arg name="key" type="s"/>
<arg name="value" type="s"/>
</signal>
<signal name="sig_usb_supported_modes_ind">
<arg name="modes" type="s"/>
</signal>
<signal name="sig_usb_available_modes_ind">
<arg name="modes" type="s"/>
</signal>
<signal name="sig_usb_config_ind">
<arg name="section" type="s"/>
<arg name="key" type="s"/>
<arg name="value" type="s"/>
</signal>
<signal name="sig_usb_hidden_modes_ind">
<arg name="modes" type="s"/>
</signal>
<signal name="sig_usb_whitelisted_modes_ind">
<arg name="modes" type="s"/>
</signal>
<signal name="sig_usb_taget_mode_config_ind">
<arg name="config" type="a{sv}"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
</signal>
<method name="get_target_mode_config">
<arg name="config" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<signal name="sig_usb_state_error_ind">
<arg name="error" type="s"/>
</signal>
</interface>
</node>
4 changes: 2 additions & 2 deletions src/usb_moded-appsync-dbus.c
Expand Up @@ -91,7 +91,7 @@ static void dbusappsync_release_name(void)

if( dbus_error_is_set(&error) )
{
log_debug("DBUS ERROR: %s, %s \n", error.name, error.message);
log_debug("DBUS ERROR: %s, %s", error.name, error.message);
dbus_error_free(&error);
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ static gboolean dbusappsync_obtain_name(void)

if( dbus_error_is_set(&error) )
{
log_debug("DBUS ERROR: %s, %s \n", error.name, error.message);
log_debug("DBUS ERROR: %s, %s", error.name, error.message);
dbus_error_free(&error);
}

Expand Down
4 changes: 2 additions & 2 deletions src/usb_moded-appsync.c
Expand Up @@ -280,7 +280,7 @@ int appsync_activate_sync(const char *mode)
/* check dbus initialisation, skip dbus activated services if this fails */
if(!dbusappsync_init())
{
log_debug("dbus setup failed => skipping dbus launched apps \n");
log_debug("dbus setup failed => skipping dbus launched apps");
appsync_no_dbus = 1;
}

Expand Down Expand Up @@ -347,7 +347,7 @@ int appsync_activate_sync_post(const char *mode)
/* check dbus initialisation, skip dbus activated services if this fails */
if(!dbusappsync_init())
{
log_debug("dbus setup failed => skipping dbus launched apps \n");
log_debug("dbus setup failed => skipping dbus launched apps");
appsync_no_dbus = 1;
}
#endif /* APP_SYNC_DBUS */
Expand Down
2 changes: 2 additions & 0 deletions src/usb_moded-dbus-private.h
Expand Up @@ -65,6 +65,8 @@ typedef void (*usb_moded_get_name_owner_fn)(const char *owner);
* UMDBUS
* ------------------------------------------------------------------------- */

void umdbus_dump_introspect_xml (void);
void umdbus_dump_busconfig_xml (void);
void umdbus_send_config_signal (const char *section, const char *key, const char *value);
DBusConnection *umdbus_get_connection (void);
gboolean umdbus_init_connection (void);
Expand Down

0 comments on commit 1c706dc

Please sign in to comment.