diff --git a/src/adapter.c b/src/adapter.c
index d647295..79f39f3 100644
--- a/src/adapter.c
+++ b/src/adapter.c
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);
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);
diff --git a/src/device.c b/src/device.c
index 30d5eb9..047c26a 100644
--- a/src/device.c
+++ b/src/device.c
uint16_t vendor;
uint16_t product;
uint16_t version;
+ uint16_t appearance;
struct btd_adapter *adapter;
GSList *uuids;
GSList *primaries; /* List of primary services */
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",
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;
}
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);
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;
}
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)
diff --git a/src/storage.c b/src/storage.c
index 38e5897..35049f1 100644
--- a/src/storage.c
+++ b/src/storage.c
return 0;
}
-int read_remote_appearance(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t *appearance)
-{
- char filename[PATH_MAX + 1], key[20], *str;
-
- create_filename(filename, PATH_MAX, local, "appearances");
-
- ba2str(peer, key);
- sprintf(&key[17], "#%hhu", bdaddr_type);
-
- str = textfile_get(filename, key);
- if (!str)
- return -ENOENT;
-
- if (sscanf(str, "%hx", appearance) != 1) {
- free(str);
- return -ENOENT;
- }
-
- free(str);
-
- return 0;
-}
-
-int write_remote_appearance(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t appearance)
-{
- char filename[PATH_MAX + 1], key[20], str[7];
-
- create_filename(filename, PATH_MAX, local, "appearances");
-
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- ba2str(peer, key);
- sprintf(&key[17], "#%hhu", bdaddr_type);
-
- sprintf(str, "0x%4.4x", appearance);
-
- return textfile_put(filename, key, str);
-}
-
ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin)
{
char filename[PATH_MAX + 1], addr[18], *str;
diff --git a/src/storage.h b/src/storage.h
index cc7f930..9a9c82f 100644
--- a/src/storage.h
+++ b/src/storage.h
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);