audio: Remove profile enabling/disabling logic
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/4 audio: Remove profile enabling/disabling logic
From: Luiz Augusto von Dentz <[email protected]>
This should be handle by the core for all profiles
---
v2: Don't use main_opts for storing disabled profiles list and cleanup hcid.h
profiles/audio/audio.conf | 4 --- profiles/audio/manager.c | 62 ++++++----------------------------------------- 2 files changed, 8 insertions(+), 58 deletions(-)
profiles/audio/audio.conf +0 -4
@@ -6,7 +6,3 @@ # Switch to master role for incoming connections (defaults to true) #Master=true - -# If we want to disable support for specific services -# Defaults to supporting the services: Sink, Control -#Disable=Source
profiles/audio/manager.c +8 -54
81 lines not on this page · raw message
Signature · 1 line
1.8.1.2
Luiz Augusto von Dentz
maintainerPATCH v2 2/4 core: Add DisableProfiles entry to main.conf
From: Luiz Augusto von Dentz <[email protected]>
This entry can be used to globally disable profiles, this is specially useful for qualification purposes where some platforms may decide to only qualify a subset of the supported profiles.
--- src/main.c | 17 +++++++++++++++-- src/main.conf | 4 ++++ src/profile.c | 26 +++++++++++++++++++++++++- src/profile.h | 2 +- 4 files changed, 45 insertions(+), 4 deletions(-)
src/main.c +15 -2
@@ -65,6 +65,7 @@#define SHUTDOWN_GRACE_SECONDS 10struct main_opts main_opts; +static char **disabled_profiles =NULL ;static const char *const supported_options[] = {"Name" ,
@@ -76,6 +77,7 @@ static const char * const supported_options[] = {"ReverseServiceDiscovery" ,"NameResolving" ,"DebugKeys" , + "DisableProfiles" };static GKeyFile *load_config (const char *file)
@@ -263,6 +265,15 @@ static void parse_config(GKeyFile *config)g_clear_error (&err); else main_opts.debug_keys = boolean; + + str =g_key_file_get_string (config,"General" ,"DisableProfiles" , &err); +if (err) { +DBG ("%s" , err->message); +g_clear_error (&err); + }else { + disabled_profiles =g_strsplit (str," " ,-1 ); +g_free (str); + } }static void init_defaults (void )
@@ -538,7 +549,7 @@ int main(int argc, char *argv[])btd_device_init ();btd_agent_init (); -btd_profile_init (); +btd_profile_init (disabled_profiles);if (option_experimental) gdbus_flags =G_DBUS_FLAG_ENABLE_EXPERIMENTAL ;
@@ -600,8 +611,10 @@ int main(int argc, char *argv[])g_main_loop_unref (event_loop); -if (config) +if (config) {g_key_file_free (config); +g_strfreev (disabled_profiles); + }disconnect_dbus ();
src/main.conf +4 -0
@@ -46,3 +46,7 @@ # makes debug link keys valid only for the duration of the connection # that they were created for. #DebugKeys = false + +# Disable Profile, both driver name and 128 bits UUIDs can be used. +# By default all profiles are enabled. +#DisableProfiles = <profile1> <profile2> ...
src/profile.c +25 -1
@@ -585,6 +585,7 @@ static GSList *custom_props = NULL;static GSList *profiles =NULL ;static GSList *ext_profiles =NULL ; +static char **blacklist =NULL ;void btd_profile_foreach (void (*func)(struct btd_profile *p,void *data),void *data)
@@ -610,6 +611,27 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),int btd_profile_register (struct btd_profile *profile) { +int i; + +if (blacklist ==NULL ) + goto done; + +for (i =0 ; blacklist[i]; i++) { +if (g_pattern_match_simple (blacklist[i], profile->name) ==0 ) +return -EPROTONOSUPPORT ; + +if (profile->local_uuid !=NULL &&strcasecmp (blacklist[i], + profile->local_uuid) ==0 ) +return -EPROTONOSUPPORT ; + +if (profile->remote_uuids ==NULL ) +continue ; + +if (strcasecmp (blacklist[i], profile->remote_uuids[0 ]) ==0 ) +return -EPROTONOSUPPORT ; + } + +done: profiles =g_slist_append (profiles, profile);return 0 ; }
@@ -2335,8 +2357,10 @@ bool btd_profile_remove_custom_prop(const char *uuid, const char *name)return false; } -void btd_profile_init (void ) +void btd_profile_init (char **disabled_profiles) { + blacklist = disabled_profiles; +g_dbus_register_interface (btd_get_dbus_connection (),"/org/bluez" ,"org.bluez.ProfileManager1" , methods,NULL ,NULL ,NULL ,NULL );
src/profile.h +1 -1
@@ -74,5 +74,5 @@ bool btd_profile_add_custom_prop(const char *uuid, const char *type, void *user_data);bool btd_profile_remove_custom_prop (const char *uuid,const char *name); -void btd_profile_init (void ); +void btd_profile_init (char **disabled_profiles);void btd_profile_cleanup (void );
Signature · 1 line
1.8.1.2
Re: [PATCH BlueZ 2/4 v2] core: Add DisableProfiles entry to main.conf
Hi Luiz,
Review
Quoted 2 lines · Luiz Augusto von Dentz
(quoted diff) +2
-0+ if (g_pattern_match_simple(blacklist[i], profile->name) == 0) + return -EPROTONOSUPPORT;
g_pattern_match_simple() returns gboolean so IMHO it is more readable if you use "== FALSE" or simply "if (!g_pattern_match_simple(...))" above.
Quoted 6 lines
src/profile.c +6
-0+ +if (profile->local_uuid !=NULL &&strcasecmp (blacklist[i], + profile->local_uuid) ==0 ) +return -EPROTONOSUPPORT ; + +if (profile->remote_uuids ==NULL )
src/profile.c void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data), · line 637
Quoted 10 lines
src/profile.c +7
-0+continue ; + +if (strcasecmp (blacklist[i], profile->remote_uuids[0 ]) ==0 ) +return -EPROTONOSUPPORT ; + } + +done: profiles =g_slist_append (profiles, profile);return 0 ; }
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Luiz Augusto von Dentz
maintainerPATCH 3/4 core: Move plugin_init and plugin_cleanup to plugin.h
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- profiles/input/manager.c | 2 ++ profiles/scanparam/scan.c | 2 ++ src/hcid.h | 3 --- src/main.c | 1 + src/plugin.h | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-)
profiles/input/manager.c +2 -0
@@ -32,6 +32,8 @@#include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> +#include <glib.h> +#include "log.h" #include "plugin.h"
profiles/scanparam/scan.c +2 -0
@@ -31,6 +31,8 @@#include <bluetooth/bluetooth.h> +#include <glib.h> +#include "lib/uuid.h" #include "log.h" #include "plugin.h"
src/hcid.h +0 -3
@@ -41,9 +41,6 @@ struct main_opts {extern struct main_opts main_opts; -gboolean plugin_init (const char *enable,const char *disable); -void plugin_cleanup (void ); -void rfkill_init (void );void rfkill_exit (void );
src/main.c +1 -0
@@ -56,6 +56,7 @@#include "agent.h" #include "profile.h" #include "systemd.h" +#include "plugin.h" #define BLUEZ_NAME "org.bluez"
src/plugin.h +2 -0
@@ -39,6 +39,8 @@ struct bluetooth_plugin_desc { struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ #name, version, priority, init, exit \ }; +gboolean plugin_init(const char *enable, const char *disable); +void plugin_cleanup(void); #else #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ extern struct btd_debug_desc __start___debug[] \
Signature · 1 line
1.8.1.2
Marcel Holtmann
maintainerRe: [PATCH BlueZ 3/4] core: Move plugin_init and plugin_cleanup to plugin.h
Hi Luiz,
Quoted 64 lines
profiles/input/manager.c | 2 ++ profiles/scanparam/scan.c | 2 ++ src/hcid.h | 3 --- src/main.c | 1 + src/plugin.h | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-)profiles/input/manager.c +2
-0@@ -32,6 +32,8 @@#include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> +#include <glib.h> +#include "log.h" #include "plugin.h" profiles/scanparam/scan.c +2
-0@@ -31,6 +31,8 @@#include <bluetooth/bluetooth.h> +#include <glib.h> +#include "lib/uuid.h" #include "log.h" #include "plugin.h" src/hcid.h +0
-3@@ -41,9 +41,6 @@ struct main_opts {extern struct main_opts main_opts; -gboolean plugin_init (const char *enable,const char *disable); -void plugin_cleanup (void ); -void rfkill_init (void );void rfkill_exit (void );src/main.c +1
-0@@ -56,6 +56,7 @@#include "agent.h" #include "profile.h" #include "systemd.h" +#include "plugin.h" #define BLUEZ_NAME "org.bluez"src/plugin.h +0
-0
src/plugin.h struct bluetooth_plugin_desc { · line 46
Quoted 8 lines
src/plugin.h +2
-0@@ -39,6 +39,8 @@ struct bluetooth_plugin_desc { struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ #name, version, priority, init, exit \ }; +gboolean plugin_init(const char *enable, const char *disable); +void plugin_cleanup(void); #else #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ extern struct btd_debug_desc __start___debug[] \\
why are we doing this?
Regards
Marcel
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 3/4] core: Move plugin_init and plugin_cleanup to plugin.h
Hi Marcel,
Quoted 61 lines · Marcel Holtmann
Hi Luiz,
Quoted 59 lines
profiles/input/manager.c | 2 ++ profiles/scanparam/scan.c | 2 ++ src/hcid.h | 3 --- src/main.c | 1 + src/plugin.h | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-)profiles/input/manager.c +2
-0@@ -32,6 +32,8 @@#include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> +#include <glib.h> +#include "log.h" #include "plugin.h" profiles/scanparam/scan.c +2
-0@@ -31,6 +31,8 @@#include <bluetooth/bluetooth.h> +#include <glib.h> +#include "lib/uuid.h" #include "log.h" #include "plugin.h" src/hcid.h +0
-3@@ -41,9 +41,6 @@ struct main_opts {extern struct main_opts main_opts; -gboolean plugin_init (const char *enable,const char *disable); -void plugin_cleanup (void ); -void rfkill_init (void );void rfkill_exit (void );src/main.c +1
-0@@ -56,6 +56,7 @@#include "agent.h" #include "profile.h" #include "systemd.h" +#include "plugin.h" #define BLUEZ_NAME "org.bluez"
Quoted 15 lines
src/plugin.h struct bluetooth_plugin_desc { · line 46
Quoted 13 lines
src/plugin.h +2
-0@@ -39,6 +39,8 @@ struct bluetooth_plugin_desc { struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ #name, version, priority, init, exit \ }; +gboolean plugin_init(const char *enable, const char *disable); +void plugin_cleanup(void); #else #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ extern struct btd_debug_desc __start___debug[] \\why are we doing this?
Didn't you want to cleanup hcid.h to minimize the usage of it, or you are referring to the declarations being inside the #ifdef for built-in plugins? If you have the declarations outside the ifdef then the external plugins would have those functions undefined. Perhaps you change your mind after seeing what it actually mean, perhaps we should leave as it is? But IMO the main header should follow the binary name of the daemon as is done for obexd and you got me scared when I look into connman.h and ofono.h, 800+ lines in a header? You change those files you basically have to recompile the whole thing.
Signature · 1 line
Luiz Augusto von Dentz
Marcel Holtmann
maintainerRe: [PATCH BlueZ 3/4] core: Move plugin_init and plugin_cleanup to plugin.h
Hi Luiz,
Quoted 75 lines
Quoted 59 lines
Quoted 59 lines
profiles/input/manager.c | 2 ++ profiles/scanparam/scan.c | 2 ++ src/hcid.h | 3 --- src/main.c | 1 + src/plugin.h | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-)profiles/input/manager.c +2
-0@@ -32,6 +32,8 @@#include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> +#include <glib.h> +#include "log.h" #include "plugin.h" profiles/scanparam/scan.c +2
-0@@ -31,6 +31,8 @@#include <bluetooth/bluetooth.h> +#include <glib.h> +#include "lib/uuid.h" #include "log.h" #include "plugin.h" src/hcid.h +0
-3@@ -41,9 +41,6 @@ struct main_opts {extern struct main_opts main_opts; -gboolean plugin_init (const char *enable,const char *disable); -void plugin_cleanup (void ); -void rfkill_init (void );void rfkill_exit (void );src/main.c +1
-0@@ -56,6 +56,7 @@#include "agent.h" #include "profile.h" #include "systemd.h" +#include "plugin.h" #define BLUEZ_NAME "org.bluez"Quoted 15 lines
src/plugin.h struct bluetooth_plugin_desc { · line 46
Quoted 13 lines
src/plugin.h +2
-0@@ -39,6 +39,8 @@ struct bluetooth_plugin_desc { struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ #name, version, priority, init, exit \ }; +gboolean plugin_init(const char *enable, const char *disable); +void plugin_cleanup(void); #else #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ extern struct btd_debug_desc __start___debug[] \\why are we doing this?
Quoted 9 lines
Didn't you want to cleanup
hcid.hto minimize the usage of it, or you are referring to the declarations being inside the #ifdef for built-in plugins? If you have the declarations outside the ifdef then the external plugins would have those functions undefined. Perhaps you change your mind after seeing what it actually mean, perhaps we should leave as it is? But IMO the main header should follow the binary name of the daemon as is done for obexd and you got me scared when I look intoconnman.handofono.h, 800+ lines in a header? You change those files you basically have to recompile the whole thing.
yes, this is mainly about the declaration inside the ifdef. I have no idea what you are trying to achieve. Why does a plugin now need these? If it does, we are doing something wrong.
There are headers that are for including from plugins (aka public headers) and there are some for internal to the daemon. So BlueZ has a pretty much loose definition of this and never had a clean include directory to separate them. However this does not mean, you should be messing that up.
Everything in plugin.h is for plugins and not for putting internal function declaration that are only used inside the daemon. If you mix these up, we will never get to the stage to allow moving over to ELL. Inside ELL, I have nicely separated this since ELL will deal with the plugin part so we do not have to copy it over into every single project.
So my advise here is to not start with the this one. Try to minimize the rest of hcid.h that does not have an impact on plugins and is purely internal to bluetoothd and obexd.
Regards
Marcel
Luiz Augusto von Dentz
maintainerPATCH 4/4 core: Move rfkill_init and rfkill_cleanup to rfkill.h
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- Makefile.am | 3 ++- src/hcid.h | 3 --- src/main.c | 1 + src/rfkill.c | 2 +- src/rfkill.h | 24 ++++++++++++++++++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 src/rfkill.h
Makefile.am +2 -1
@@ -127,7 +127,8 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \ src/bluetooth.ver \ src/main.c src/log.h src/log.c \ src/systemd.h src/systemd.c \ - src/rfkill.c src/hcid.h src/sdpd.h \ + src/rfkill.c src/rfkill.h \ + src/hcid.h src/sdpd.h \ src/sdpd-server.c src/sdpd-request.c \ src/sdpd-service.c src/sdpd-database.c \ src/attrib-server.h src/attrib-server.c \
src/hcid.h +0 -3
@@ -41,7 +41,4 @@ struct main_opts {extern struct main_opts main_opts; -void rfkill_init (void ); -void rfkill_exit (void ); -void btd_exit (void );
src/main.c +1 -0
@@ -57,6 +57,7 @@#include "profile.h" #include "systemd.h" #include "plugin.h" +#include "rfkill.h" #define BLUEZ_NAME "org.bluez"
src/rfkill.c +1 -1
@@ -37,7 +37,7 @@#include "log.h" #include "adapter.h" -#include "hcid.h" +#include "rfkill.h" enum rfkill_type {RFKILL_TYPE_ALL =0 ,
src/rfkill.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2013 Intel Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +void rfkill_init (void ); +void rfkill_exit (void );
Signature · 1 line
1.8.1.2