diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-01 14:10:10 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-01 14:10:10 +0000 | 
| commit | 3f27f7f7a01ad43532b65504e6204194e3e259df (patch) | |
| tree | a7e252bc8a60a4bb7440d3c6122e938abbb6fc35 /input/storage.c | |
| parent | 553db8d4150c59628105bf8df4ddb68311b2fb58 (diff) | |
Input: Use stored device name instead of the service name attribute
Diffstat (limited to 'input/storage.c')
| -rw-r--r-- | input/storage.c | 34 | 
1 files changed, 31 insertions, 3 deletions
diff --git a/input/storage.c b/input/storage.c index be5ab3e3..fd8d4bcb 100644 --- a/input/storage.c +++ b/input/storage.c @@ -71,7 +71,6 @@ int parse_stored_device_info(const char *str, struct hidp_connadd_req *req)  			&vendor, &product, &version, &subclass, &country,  			&parser, &req->flags, &pos); -  	desc  = &str[pos];  	len = strlen(desc);  	if (len <= 0) @@ -84,8 +83,6 @@ int parse_stored_device_info(const char *str, struct hidp_connadd_req *req)  	req->country  = country;  	req->parser   = parser; -	/* FIXME: Retrieve the name from the filesystem file "names" */ -  	req->rd_size = len / 2;  	req->rd_data = g_try_malloc0(req->rd_size);  	if (!req->rd_data) { @@ -174,6 +171,37 @@ int store_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *req  	return err;  } +int read_device_name(bdaddr_t *local, bdaddr_t *peer, char **name) +{ +	char filename[PATH_MAX + 1], addr[18], *str; +	int len; + +	create_filename(filename, PATH_MAX, local, "names"); + +	ba2str(peer, addr); +	str = textfile_get(filename, addr); +	if (!str) +		return -ENOENT; + +	len = strlen(str); + +	/* HID max name size is 128 chars */ +	if (len < 128) { +		*name = str; +		return 0; +	} + +	*name = g_try_malloc0(128); +	if (!*name) +		return -ENOMEM; + +	snprintf(*name, 128, "%s", str); + +	free(str); + +	return 0; +} +  int encrypt_link(bdaddr_t *src, bdaddr_t *dst)  {  	char filename[PATH_MAX + 1];  | 
