adapter: Add btd_adapter_for_each_device()
PATCH 1/13 adapter: Add btd_adapter_for_each_device()
--- src/adapter.c | 7 +++++++ src/adapter.h | 4 ++++ 2 files changed, 11 insertions(+)
src/adapter.c +7 -0
@@ -3635,3 +3635,10 @@ void adapter_read_local_oob_data_complete(struct btd_adapter *adapter,g_free (adapter->oob_handler); adapter->oob_handler =NULL ; } + +void btd_adapter_for_each_device (struct btd_adapter *adapter, +void (*cb)(struct btd_device *device,void *data), +void *data) +{ +g_slist_foreach (adapter->devices, (GFunc ) cb, data); +}
src/adapter.h +4 -0
@@ -231,3 +231,7 @@ void btd_adapter_set_oob_handler(struct btd_adapter *adapter,gboolean btd_adapter_check_oob_handler (struct btd_adapter *adapter);void adapter_store_cached_name (const bdaddr_t *local,const bdaddr_t *peer,const char *name); + +void btd_adapter_for_each_device (struct btd_adapter *adapter, +void (*cb)(struct btd_device *device,void *data), +void *data);
Signature · 1 line
1.7.9.5
PATCH 2/13 alert: Use ccc file from device storage
--- profiles/alert/server.c | 69 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 35 deletions(-)
profiles/alert/server.c +34 -35
@@ -322,29 +322,41 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)g_slist_foreach (alert_adapters, update_supported_categories,NULL ); } -static struct btd_device *get_notifiable_device (struct btd_adapter *adapter, -char *key,char *value, -uint16_t ccc) +static gboolean is_notifiable_device (struct btd_device *device,uint16_t ccc) { -struct btd_device *device; -char addr[18 ]; -uint16_t hnd, val; -uint8_t bdaddr_type; +char *filename; +GKeyFile *key_file; +char handle[6 ]; +char *str; +uint16_t val; +gboolean result; + +sprintf (handle,"%hu" , ccc); -sscanf (key,"%17s#%hhu#%04hX" , addr, &bdaddr_type, &hnd); + filename =btd_device_get_storage_path (device,"ccc" ); -if (hnd != ccc) -return NULL ; + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); - val =strtol (value,NULL ,16 ); -if (!(val &0x0001 )) -return NULL ; + str =g_key_file_get_string (key_file, handle,"Value" ,NULL ); +if (!str) { + result = FALSE; + goto end; + } + + val =strtol (str,NULL ,16 ); +if (!(val &0x0001 )) { + result = FALSE; + goto end; + } - device =adapter_find_device (adapter, addr); -if (device ==NULL ) -return NULL ; + result = TRUE; +end: +g_free (str); +g_free (filename); +g_key_file_free (key_file); -return btd_device_ref (device); +return result; }static void attio_connected_cb (GAttrib *attrib,gpointer user_data)
@@ -392,40 +404,27 @@ end:g_free (cb); } -static void filter_devices_notify (char *key,char *value,void *user_data) +static void filter_devices_notify (struct btd_device *device,void *user_data) {struct notify_data *notify_data = user_data;struct alert_adapter *al_adapter = notify_data->al_adapter;enum notify_type type = notify_data->type; -struct btd_device *device;struct notify_callback *cb; - device =get_notifiable_device (al_adapter->adapter, key, value, - al_adapter->hnd_ccc[type]); -if (device ==NULL ) +if (!is_notifiable_device (device, al_adapter->hnd_ccc[type]))return ; cb = g_new0(struct notify_callback, 1); cb->notify_data = notify_data; - cb->device = device; + cb->device =btd_device_ref (device); cb->id =btd_device_add_attio_callback (device, attio_connected_cb,NULL , cb); } -static void create_filename (char *filename,struct btd_adapter *adapter) -{ -char srcaddr[18 ]; - -ba2str (adapter_get_address (adapter), srcaddr); - -create_name (filename,PATH_MAX ,STORAGEDIR , srcaddr,"ccc" ); -} -static void notify_devices (struct alert_adapter *al_adapter,enum notify_type type,uint8_t *value,size_t len) {struct notify_data *notify_data; -char filename[PATH_MAX +1 ]; notify_data = g_new0(struct notify_data, 1); notify_data->al_adapter = al_adapter;
@@ -433,8 +432,8 @@ static void notify_devices(struct alert_adapter *al_adapter, notify_data->value =g_memdup (value, len); notify_data->len = len; -create_filename (filename, al_adapter->adapter); -textfile_foreach (filename, filter_devices_notify, notify_data); +btd_adapter_for_each_device (al_adapter->adapter, filter_devices_notify, + notify_data); }static void pasp_notification (enum notify_type type)
Signature · 1 line
1.7.9.5
PATCH 3/13 doc: Add device appearance in settings-storage doc
In reply to Frédéric Danis--- doc/settings-storage.txt | 3 +++ 1 file changed, 3 insertions(+)
doc/settings-storage.txt +3 -0
@@ -165,6 +165,9 @@ Long term key) related to a remote device. Class String Device class in hexadecimal, i.e. 0x000000 + Appearance String Device appearance in hexadecimal, + i.e. 0x0000 + SupportedTechnologies List of List of technologies supported by strings device, separated by ";" Technologies can be BR/EDR or LE
Signature · 1 line
1.7.9.5
PATCH 4/13 adapter: Convert appearances file
In reply to Frédéric Danis--- src/adapter.c | 8 ++++++++ 1 file changed, 8 insertions(+)
src/adapter.c +8 -0
@@ -2190,6 +2190,11 @@ static void convert_profiles_entry(GKeyFile *key_file, void *value)g_key_file_set_string (key_file,"General" ,"Services" , value); } +static void convert_appearances_entry (GKeyFile *key_file,void *value) +{ +g_key_file_set_string (key_file,"General" ,"Appearance" , value); +} +static void convert_entry (char *key,char *value,void *user_data) {struct device_converter *converter = user_data;
@@ -2642,6 +2647,9 @@ static void convert_device_storage(struct btd_adapter *adapter)textfile_put (filename,"converted" ,"yes" ); }free (str); + +/* Convert appearances */ +convert_file ("appearances" , address, convert_appearances_entry, FALSE); } static void convert_config(struct btd_adapter *adapter, const char *filename,
Signature · 1 line
1.7.9.5
PATCH 5/13 device: Load appearance from storage
In reply to Frédéric DanisUpdate adapter_update_found_devices() to store appearance in device.
Remove no more used functions in storage.[ch].
--- src/adapter.c | 7 +++---- src/device.c | 37 +++++++++++++++++++++++-------------- src/storage.c | 41 ----------------------------------------- src/storage.h | 4 ---- 4 files changed, 26 insertions(+), 63 deletions(-)
src/adapter.c +3 -4
@@ -3074,10 +3074,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter,return ; } -if (eir_data.appearance !=0 ) -write_remote_appearance (&adapter->bdaddr, bdaddr, bdaddr_type, - eir_data.appearance); -if (eir_data.name !=NULL && eir_data.name_complete)adapter_store_cached_name (&adapter->bdaddr, bdaddr, eir_data.name);
@@ -3101,6 +3097,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter,device_set_legacy (dev, legacy);device_set_rssi (dev, rssi); +if (eir_data.appearance !=0 ) +device_set_appearance (dev, eir_data.appearance); +if (eir_data.name)device_set_name (dev, eir_data.name);
src/device.c +23 -14
@@ -149,6 +149,7 @@ struct btd_device {uint16_t vendor;uint16_t product;uint16_t version; +uint16_t appearance;struct btd_adapter *adapter;GSList *uuids;GSList *primaries;/* List of primary services */
@@ -241,6 +242,13 @@ static gboolean store_device_info_cb(gpointer user_data)g_key_file_remove_key (key_file,"General" ,"Class" ,NULL ); } +if (device->appearance) { +sprintf (class,"0x%4.4x" , device->appearance); +g_key_file_set_string (key_file,"General" ,"Appearance" , class); + }else { +g_key_file_remove_key (key_file,"General" ,"Appearance" ,NULL ); + } +switch (device->bdaddr_type) {case BDADDR_BREDR : g_key_file_set_string(key_file, "General",
@@ -564,10 +572,10 @@ static gboolean get_appearance(const GDBusPropertyTable *property, void *data,if (dev_property_exists_class (property, data))return FALSE; -if (read_remote_appearance (adapter_get_address (device->adapter), - &device->bdaddr, device->bdaddr_type, - appearance) ==0 ) +if (device->appearance) { + *appearance = device->appearance;return TRUE; + }return FALSE; }
@@ -1745,6 +1753,13 @@ static void load_info(struct btd_device *device, const gchar *local,g_free (str); } +/* Load appearance */ + str =g_key_file_get_string (key_file,"General" ,"Appearance" ,NULL ); +if (str) { + device->appearance =strtol (str,NULL ,16 ); +g_free (str); + } +/* Load device technology */ techno =g_key_file_get_string_list (key_file,"General" ,"SupportedTechnologies" ,NULL ,NULL );
@@ -4093,17 +4108,11 @@ void btd_device_unref(struct btd_device *device)int device_get_appearance (struct btd_device *device,uint16_t *value) { -uint16_t app; -int err; - - err =read_remote_appearance (adapter_get_address (device->adapter), - &device->bdaddr, device->bdaddr_type, - &app); -if (err <0 ) -return err; +if (device->appearance ==0 ) +return -1 ;if (value) - *value = app; + *value = device->appearance;return 0 ; }
@@ -4119,8 +4128,8 @@ void device_set_appearance(struct btd_device *device, uint16_t value)g_dbus_emit_property_changed (btd_get_dbus_connection (), device->path,DEVICE_INTERFACE ,"Icon" ); -write_remote_appearance (adapter_get_address (device->adapter), - &device->bdaddr, device->bdaddr_type, value); + device->appearance = value; +store_device_info (device); }static gboolean notify_attios (gpointer user_data)
src/storage.c +0 -41
47 lines not on this page · raw message
src/storage.h +0 -4
@@ -27,10 +27,6 @@ int read_discoverable_timeout(const char *src, int *timeout);int read_pairable_timeout (const char *src,int *timeout);int read_on_mode (const char *src,char *mode,int length);int read_local_name (const bdaddr_t *bdaddr,char *name); -int write_remote_appearance (const bdaddr_t *local,const bdaddr_t *peer, -uint8_t bdaddr_type,uint16_t appearance); -int read_remote_appearance (const bdaddr_t *local,const bdaddr_t *peer, -uint8_t bdaddr_type,uint16_t *appearance);ssize_t read_pin_code (const bdaddr_t *local,const bdaddr_t *peer,char *pin);sdp_record_t *record_from_string (const gchar *str);sdp_record_t *find_record_in_list (sdp_list_t *recs,const char *uuid);
Signature · 1 line
1.7.9.5
PATCH 6/13 adapter: Convert gatt file
In reply to Frédéric Danis--- src/adapter.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
src/adapter.c +63 -0
@@ -2564,6 +2564,56 @@ static void convert_ccc_entry(char *key, char *value, void *user_data)g_key_file_free (key_file); } +static void convert_gatt_entry (char *key,char *value,void *user_data) +{ +char *src_addr = user_data; +char dst_addr[18 ]; +char type =BDADDR_BREDR ; +int handle, ret; +char filename[PATH_MAX +1 ]; +GKeyFile *key_file; +struct stat st; +int err; +char group[6 ]; +char *data; +gsize length =0 ; + + ret =sscanf (key,"%17s#%hhu#%04X" , dst_addr, &type, &handle); +if (ret <3 ) +return ; + +if (bachk (dst_addr) !=0 ) +return ; + +/* Check if the device directory has been created as records should +* only be converted for known devices */ +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/%s" , src_addr, dst_addr); + filename[PATH_MAX ] ='\0' ; + + err =stat (filename, &st); +if (err || !S_ISDIR (st.st_mode)) +return ; + +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/%s/gatt" , src_addr, + dst_addr); + filename[PATH_MAX ] ='\0' ; + + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); + +sprintf (group,"%hu" , handle); +g_key_file_set_string (key_file, group,"Value" , value); + + data =g_key_file_to_data (key_file, &length,NULL ); +if (length >0 ) { +create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); +g_file_set_contents (filename, data, length,NULL ); + } + +g_free (data); +g_key_file_free (key_file); +} +static void convert_device_storage (struct btd_adapter *adapter) {char filename[PATH_MAX +1 ];
@@ -2650,6 +2700,19 @@ static void convert_device_storage(struct btd_adapter *adapter)/* Convert appearances */ convert_file ("appearances" , address, convert_appearances_entry, FALSE); + +/* Convert gatt */ +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/gatt" , address); + filename[PATH_MAX ] ='\0' ; + + str =textfile_get (filename,"converted" ); +if (str &&strcmp (str,"yes" ) ==0 ) { +DBG ("Legacy %s file already converted" , filename); + }else { +textfile_foreach (filename, convert_gatt_entry, address); +textfile_put (filename,"converted" ,"yes" ); + } +free (str); } static void convert_config(struct btd_adapter *adapter, const char *filename,
Signature · 1 line
1.7.9.5
PATCH 7/13 gatt: Use new storage architecture
In reply to Frédéric Danis--- profiles/gatt/gas.c | 80 +++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 44 deletions(-)
profiles/gatt/gas.c +36 -44
@@ -77,60 +77,58 @@ static gint cmp_device(gconstpointer a, gconstpointer b)return (gas->device == device ?0 :-1 ); } -static inline int create_filename (char *buf,size_t size, -const bdaddr_t *bdaddr,const char *name) -{ -char addr[18 ]; - -ba2str (bdaddr, addr); - -return create_name (buf, size,STORAGEDIR , addr, name); -} - -static int write_ctp_handle (const bdaddr_t *sba,const bdaddr_t *dba, -uint8_t bdaddr_type,uint16_t uuid, +static void write_ctp_handle (struct btd_device *device,uint16_t uuid,uint16_t handle) { -char filename[PATH_MAX +1 ], addr[18 ], key[27 ], value[7 ]; +char *filename, group[6 ], value[7 ]; +GKeyFile *key_file; +char *data; +gsize length =0 ; -create_filename (filename,PATH_MAX , sba,"gatt" ); + filename =btd_device_get_storage_path (device,"gatt" ); -create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); -ba2str (dba, addr); +snprintf (group,sizeof (group),"%hu" , uuid); +snprintf (value,sizeof (value),"0x%4.4X" , handle); +g_key_file_set_string (key_file, group,"Value" , value); -snprintf (key,sizeof (key),"%17s#%hhu#0x%4.4x" , addr, bdaddr_type, - uuid); -snprintf (value,sizeof (value),"0x%4.4x" , handle); + data =g_key_file_to_data (key_file, &length,NULL ); +if (length >0 ) { +create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); +g_file_set_contents (filename, data, length,NULL ); + } -return textfile_put (filename, key, value); +g_free (data); +g_free (filename); +g_key_file_free (key_file); } -static int read_ctp_handle (const bdaddr_t *sba,const bdaddr_t *dba, -uint8_t bdaddr_type,uint16_t uuid, +static int read_ctp_handle (struct btd_device *device,uint16_t uuid,uint16_t *value) { -char filename[PATH_MAX +1 ], addr[18 ], key[27 ]; +char *filename, group[6 ]; +GKeyFile *key_file;char *str; +int err =0 ; -create_filename (filename,PATH_MAX , sba,"gatt" ); + filename =btd_device_get_storage_path (device,"gatt" ); -ba2str (dba, addr); -snprintf (key,sizeof (key),"%17s#%hhu#0x%04x" , addr, bdaddr_type, - uuid); +snprintf (group,sizeof (group),"%hu" , uuid); - str =textfile_get (filename, key); -if (str ==NULL ) -return -errno; + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); -if (sscanf (str,"%hx" , value) !=1 ) { -free (str); -return -ENOENT ; - } + str =g_key_file_get_string (key_file, group,"Value" ,NULL ); +if (str ==NULL ||sscanf (str,"%hx" , value) !=1 ) + err = -ENOENT ; -free (str); +g_free (str); +g_free (filename); +g_key_file_free (key_file); -return 0 ; +return err; } static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
@@ -214,10 +212,7 @@ static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen, gas->changed_handle, indication_cb, gas, NULL); -write_ctp_handle (adapter_get_address (device_get_adapter (gas->device)), -device_get_address (gas->device), -device_get_addr_type (gas->device), -GATT_CHARAC_SERVICE_CHANGED , +write_ctp_handle (gas->device,GATT_CHARAC_SERVICE_CHANGED , gas->changed_handle); }
@@ -391,10 +386,7 @@ int gas_register(struct btd_device *device, struct att_range *gap, attio_connected_cb, attio_disconnected_cb, gas); -read_ctp_handle (adapter_get_address (device_get_adapter (gas->device)), -device_get_address (gas->device), -device_get_addr_type (gas->device), -GATT_CHARAC_SERVICE_CHANGED , +read_ctp_handle (gas->device,GATT_CHARAC_SERVICE_CHANGED , &gas->changed_handle);return 0 ;
Signature · 1 line
1.7.9.5
PATCH 8/13 adapter: Convert proximity file
In reply to Frédéric Danis--- src/adapter.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
src/adapter.c +61 -0
@@ -2614,6 +2614,54 @@ static void convert_gatt_entry(char *key, char *value, void *user_data)g_key_file_free (key_file); } +static void convert_proximity_entry (char *key,char *value,void *user_data) +{ +char *src_addr = user_data; +char *alert; +char filename[PATH_MAX +1 ]; +GKeyFile *key_file; +struct stat st; +int err; +char *data; +gsize length =0 ; + +if (!strchr (key,'#' )) +return ; + + key[17 ] ='\0' ; + alert = &key[18 ]; + +if (bachk (key) !=0 ) +return ; + +/* Check if the device directory has been created as records should +* only be converted for known devices */ +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/%s" , src_addr, key); + filename[PATH_MAX ] ='\0' ; + + err =stat (filename, &st); +if (err || !S_ISDIR (st.st_mode)) +return ; + +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/%s/proximity" , src_addr, + key); + filename[PATH_MAX ] ='\0' ; + + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); + +g_key_file_set_string (key_file, alert,"Level" , value); + + data =g_key_file_to_data (key_file, &length,NULL ); +if (length >0 ) { +create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); +g_file_set_contents (filename, data, length,NULL ); + } + +g_free (data); +g_key_file_free (key_file); +} +static void convert_device_storage (struct btd_adapter *adapter) {char filename[PATH_MAX +1 ];
@@ -2713,6 +2761,19 @@ static void convert_device_storage(struct btd_adapter *adapter)textfile_put (filename,"converted" ,"yes" ); }free (str); + +/* Convert proximity */ +snprintf (filename,PATH_MAX ,STORAGEDIR "/%s/proximity" , address); + filename[PATH_MAX ] ='\0' ; + + str =textfile_get (filename,"converted" ); +if (str &&strcmp (str,"yes" ) ==0 ) { +DBG ("Legacy %s file already converted" , filename); + }else { +textfile_foreach (filename, convert_proximity_entry, address); +textfile_put (filename,"converted" ,"yes" ); + } +free (str); } static void convert_config(struct btd_adapter *adapter, const char *filename,
Signature · 1 line
1.7.9.5
PATCH 9/13 proximity: Use new storage architecture
In reply to Frédéric Danis--- profiles/proximity/monitor.c | 72 ++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 38 deletions(-)
profiles/proximity/monitor.c +34 -38
@@ -83,51 +83,52 @@ struct monitor {guint attioid; }; -static inline int create_filename (char *buf,size_t size, -const bdaddr_t *bdaddr,const char *name) +static void write_proximity_config (struct btd_device *device,const char *alert, +const char *level) { -char addr[18 ]; +char *filename; +GKeyFile *key_file; +char *data; +gsize length =0 ; -ba2str (bdaddr, addr); + filename =btd_device_get_storage_path (device,"proximity" ); -return create_name (buf, size,STORAGEDIR , addr, name); -} - -static int write_proximity_config (const bdaddr_t *sba,const bdaddr_t *dba, -const char *alert,const char *level) -{ -char filename[PATH_MAX +1 ], addr[18 ], key[38 ]; - -create_filename (filename,PATH_MAX , sba,"proximity" ); + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); -create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); +if (level) +g_key_file_set_string (key_file, alert,"Level" , level); +else +g_key_file_remove_group (key_file, alert,NULL ); -ba2str (dba, addr); - -snprintf (key,sizeof (key),"%17s#%s" , addr, alert); + data =g_key_file_to_data (key_file, &length,NULL ); +if (length >0 ) { +create_file (filename,S_IRUSR |S_IWUSR |S_IRGRP |S_IROTH ); +g_file_set_contents (filename, data, length,NULL ); + } -return textfile_put (filename, key, level); +g_free (data); +g_free (filename); +g_key_file_free (key_file); } -static char *read_proximity_config (const bdaddr_t *sba,const bdaddr_t *dba, -const char *alert) +static char *read_proximity_config (struct btd_device *device,const char *alert) { -char filename[PATH_MAX +1 ], addr[18 ], key[38 ]; -char *str, *strnew; +char *filename; +GKeyFile *key_file; +char *str; -create_filename (filename,PATH_MAX , sba,"proximity" ); + filename =btd_device_get_storage_path (device,"proximity" ); -ba2str (dba, addr); -snprintf (key,sizeof (key),"%17s#%s" , addr, alert); + key_file =g_key_file_new (); +g_key_file_load_from_file (key_file, filename,0 ,NULL ); - str =textfile_caseget (filename, key); -if (str ==NULL ) -return NULL ; + str =g_key_file_get_string (key_file, alert,"Level" ,NULL ); - strnew =g_strdup (str); -free (str); +g_free (filename); +g_key_file_free (key_file); -return strnew; +return str; }static uint8_t str2level (const char *level)
@@ -417,7 +418,6 @@ static void property_set_link_loss_level(const GDBusPropertyTable *property, DBusMessageIter *iter, GDBusPendingPropertySet id, void *data) { struct monitor *monitor = data; -struct btd_device *device = monitor->device;const char *level;if (dbus_message_iter_get_arg_type (iter) !=DBUS_TYPE_STRING )
@@ -438,9 +438,7 @@ static void property_set_link_loss_level(const GDBusPropertyTable *property,g_free (monitor->linklosslevel); monitor->linklosslevel =g_strdup (level); -write_proximity_config (adapter_get_address (device_get_adapter (device)), -device_get_address (device), -"LinkLossAlertLevel" , level); +write_proximity_config (monitor->device,"LinkLossAlertLevel" , level);if (monitor->attrib)write_alert_level (monitor);
@@ -601,9 +599,7 @@ int monitor_register(struct btd_device *device,struct monitor *monitor;char *level; - level =read_proximity_config ( -adapter_get_address (device_get_adapter (device)), -device_get_address (device),"LinkLossAlertLevel" ); + level =read_proximity_config (device,"LinkLossAlertLevel" ); monitor = g_new0(struct monitor, 1); monitor->device =btd_device_ref (device);
Signature · 1 line
1.7.9.5
PATCH 10/13 adapter: Remove support of pincodes storage file
In reply to Frédéric DanisThis is no more supported in new storage.
--- src/adapter.c | 3 +-- src/storage.c | 20 -------------------- src/storage.h | 1 - 3 files changed, 1 insertion(+), 23 deletions(-)
src/adapter.c +1 -2
@@ -3594,8 +3594,7 @@ ssize_t btd_adapter_get_pin(struct btd_adapter *adapter, struct btd_device *dev,return ret; } -return read_pin_code (&adapter->bdaddr,device_get_address (dev), - pin_buf); +return -1 ; } int btd_adapter_set_fast_connectable(struct btd_adapter *adapter,
src/storage.c +0 -20
@@ -144,26 +144,6 @@ int read_local_name(const bdaddr_t *bdaddr, char *name)return 0 ; } -ssize_t read_pin_code (const bdaddr_t *local,const bdaddr_t *peer,char *pin) -{ -char filename[PATH_MAX +1 ], addr[18 ], *str; -ssize_t len; - -create_filename (filename,PATH_MAX , local,"pincodes" ); - -ba2str (peer, addr); - str =textfile_get (filename, addr); -if (!str) -return -ENOENT ; - -strncpy (pin, str,16 ); - len =strlen (pin); - -free (str); - -return len; -} -sdp_record_t *record_from_string (const gchar *str) {sdp_record_t *rec;
src/storage.h +0 -1
@@ -27,7 +27,6 @@ int read_discoverable_timeout(const char *src, int *timeout);int read_pairable_timeout (const char *src,int *timeout);int read_on_mode (const char *src,char *mode,int length);int read_local_name (const bdaddr_t *bdaddr,char *name); -ssize_t read_pin_code (const bdaddr_t *local,const bdaddr_t *peer,char *pin);sdp_record_t *record_from_string (const gchar *str);sdp_record_t *find_record_in_list (sdp_list_t *recs,const char *uuid);int read_device_pairable (const bdaddr_t *local,gboolean *mode);
Signature · 1 line
1.7.9.5
PATCH 11/13 adapter: Fix invalid read in conversions
In reply to Frédéric Danis==8664== Invalid read of size 1
==8664== at 0x45B214: convert_entry (adapter.c:2325) ==8664== by 0x456A44: textfile_foreach (textfile.c:464) ==8664== by 0x45A823: convert_file (adapter.c:2387) ==8664== by 0x45ABDE: convert_device_storage (adapter.c:2869) ==8664== by 0x45F6CE: adapter_init (adapter.c:3043) ==8664== by 0x4594D9: btd_manager_register_adapter (manager.c:176) ==8664== by 0x46DB3E: mgmt_event.part.38 (mgmt.c:1206) ==8664== by 0x4E79D52: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) ==8664== by 0x4E7A09F: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) ==8664== by 0x4E7A499: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) ==8664== by 0x409D53: main (main.c:513) ==8664== Address 0x60b99c1 is not stack'd, malloc'd or (recently) free'd ==8664== --- src/adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/adapter.c +2 -2
@@ -2204,7 +2204,7 @@ static void convert_entry(char *key, char *value, void *user_data)char *data;gsize length =0 ; -if (key[17 ] =='#' ) { +if (strchr (key,'#' )) { key[17 ] ='\0' ; type = key[18 ] -'0' ; }
@@ -2446,7 +2446,7 @@ static void convert_primaries_entry(char *key, char *value, void *user_data)char *data;gsize length =0 ; -if (key[17 ] =='#' ) { +if (strchr (key,'#' )) { key[17 ] ='\0' ; device_type = key[18 ] -'0' ; }
Signature · 1 line
1.7.9.5
PATCH 12/13 bluetoothd: Remove storage info from man page
In reply to Frédéric Danis--- src/bluetoothd.8.in | 50 -------------------------------------------------- 1 file changed, 50 deletions(-)
src/bluetoothd.8.in +0 -50
@@ -37,55 +37,5 @@ Use specific MTU size for SDP server. .I @CONFIGDIR@/main.conf Default location of the global configuration file. -.TP -.I @STORAGEDIR@/nn:nn:nn:nn:nn:nn/linkkeys -Default location for link keys of paired devices. The directory -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP -is the address of the local device. The file is line separated, with -the following columns separated by whitespace: - -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP Remote device address. - -\fInnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\fP Link key. - -\fIn\fP Link type integer. - -.TP -.I @STORAGEDIR@/nn:nn:nn:nn:nn:nn/names -Default location for the device name cache. The directory -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP -is the address of the local device. The file is line separated, with -the following columns separated by whitespace: - -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP Remote device address. - -\fIname\fP Remote device name, terminated with newline. - -.TP -.I @STORAGEDIR@/nn:nn:nn:nn:nn:nn/features -Default location for the features cache. The directory -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP -is the address of the local device. The file is line separated, with -the following columns separated by whitespace: - -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP Remote device address. - -\fInnnnnnnnnnnnnnnn\fP Remote device LMP features coded as an 8 byte bitfield. - -.TP -.I @STORAGEDIR@/nn:nn:nn:nn:nn:nn/manufacturers -Default location for the manufacturers cache. The directory -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP -is the address of the local device. The file is line separated, with -the following columns separated by whitespace: - -\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP\fB:\fP\fInn\fP Remote device address. - -\fIn\fP Remote device manufacturer integer. - -\fIn\fP Remote device LMP version integer. - -\fIn\fP Remote device LMP sub-version integer. - .SH "AUTHOR" This manual page was written by Marcel Holtmann, Philipp Matthias Hahn and Fredrik Noring.
Signature · 1 line
1.7.9.5
PATCH 13/13 TODO: Mark convert storage to ini-file item as done
In reply to Frédéric Danis--- TODO | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
TODO +2 -3
@@ -60,11 +60,10 @@ BlueZ 5 Priority/Complexity omitted as all items are required before 5.0 is released. -- [pending] Convert storage to user per-remote device directories and - ini-file format - Completed items: +- Convert storage to user per-remote device directories and ini-file format + - Don't install libbluetooth by default (put it behind a configure switch) - Switch plugins to standard D-Bus properties interface
Signature · 1 line
1.7.9.5
Hi Frédéric,
Quoted 4 lines · Frédéric Danis
--- src/adapter.c | 7 +++++++ src/adapter.h | 4 ++++ 2 files changed, 11 insertions(+)
All patches in this set have been applied. Thanks.
Johan