summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-16 21:34:08 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-16 21:34:08 +0000
commit28a77bb7c841ce428071f6b6edd3539e1f8dc16a (patch)
tree73927203a3e2ad599246a708f6c96311cd3234b1 /hcid
parentef29c39ffc97adc9893841165f9e9a3f6a1e9a0a (diff)
Move append_dict_entry to utils/common and change the name to dbus_message_iter_append_dict_entry.
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c49
-rw-r--r--hcid/dbus-common.c35
-rw-r--r--hcid/dbus-common.h3
-rw-r--r--hcid/dbus-service.c12
4 files changed, 37 insertions, 62 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 2fad51d6..1aba759d 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -273,45 +273,53 @@ static DBusHandlerResult adapter_get_info(DBusConnection *conn,
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
- append_dict_entry(&dict, "address", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "address",
+ DBUS_TYPE_STRING, &property);
memset(str, 0, sizeof(str));
property = str;
str2ba(adapter->address, &ba);
if (!read_local_name(&ba, str))
- append_dict_entry(&dict, "name", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "name",
+ DBUS_TYPE_STRING, &property);
get_device_version(adapter->dev_id, str, sizeof(str));
- append_dict_entry(&dict, "version", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "version",
+ DBUS_TYPE_STRING, &property);
get_device_revision(adapter->dev_id, str, sizeof(str));
- append_dict_entry(&dict, "revision", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "revision",
+ DBUS_TYPE_STRING, &property);
get_device_manufacturer(adapter->dev_id, str, sizeof(str));
- append_dict_entry(&dict, "manufacturer", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "manufacturer",
+ DBUS_TYPE_STRING, &property);
get_device_company(adapter->dev_id, str, sizeof(str));
- append_dict_entry(&dict, "company", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "company",
+ DBUS_TYPE_STRING, &property);
property = hcimode2str(adapter->mode);
- append_dict_entry(&dict, "mode", DBUS_TYPE_STRING, &property);
+ dbus_message_iter_append_dict_entry(&dict, "mode",
+ DBUS_TYPE_STRING, &property);
- append_dict_entry(&dict, "discoverable_timeout",
+ dbus_message_iter_append_dict_entry(&dict, "discoverable_timeout",
DBUS_TYPE_UINT32, &adapter->discov_timeout);
if (!read_local_class(&ba, cls)) {
uint32_t class;
memcpy(&class, cls, 3);
- append_dict_entry(&dict, "class", DBUS_TYPE_UINT32, &class);
+ dbus_message_iter_append_dict_entry(&dict, "class",
+ DBUS_TYPE_UINT32, &class);
property = major_class_str(class);
- append_dict_entry(&dict, "major_class",
+ dbus_message_iter_append_dict_entry(&dict, "major_class",
DBUS_TYPE_STRING, &property);
property = minor_class_str(class);
- append_dict_entry(&dict, "minor_class",
+ dbus_message_iter_append_dict_entry(&dict, "minor_class",
DBUS_TYPE_STRING, &property);
}
@@ -1150,7 +1158,8 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "names");
str = textfile_caseget(filename, addr_ptr);
if (str) {
- append_dict_entry(&dict, "name", DBUS_TYPE_STRING, &str);
+ dbus_message_iter_append_dict_entry(&dict, "name",
+ DBUS_TYPE_STRING, &str);
free(str);
}
@@ -1160,18 +1169,18 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
/* Major/Minor Class */
if (read_remote_class(&src, &dst, &class) == 0) {
ptr = major_class_str(class);
- append_dict_entry(&dict, "major_class",
+ dbus_message_iter_append_dict_entry(&dict, "major_class",
DBUS_TYPE_STRING, &ptr);
ptr = minor_class_str(class);
- append_dict_entry(&dict, "minor_class",
+ dbus_message_iter_append_dict_entry(&dict, "minor_class",
DBUS_TYPE_STRING, &ptr);
}
/* Alias */
if (get_device_alias(adapter->dev_id, &dst, buf, sizeof(buf)) > 0) {
ptr = buf;
- append_dict_entry(&dict, "alias",
+ dbus_message_iter_append_dict_entry(&dict, "alias",
DBUS_TYPE_STRING, &ptr);
}
@@ -1186,12 +1195,12 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
boolean = FALSE;
}
- append_dict_entry(&dict, "bonded",
+ dbus_message_iter_append_dict_entry(&dict, "bonded",
DBUS_TYPE_BOOLEAN, &boolean);
/* Trusted */
boolean = read_trust(&src, addr_ptr, GLOBAL_TRUST);
- append_dict_entry(&dict, "trusted",
+ dbus_message_iter_append_dict_entry(&dict, "trusted",
DBUS_TYPE_BOOLEAN, &boolean);
/* HCI Revision/Manufacturer/Version */
@@ -1212,11 +1221,11 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
ptr = buf;
snprintf(buf, 16, "HCI 0x%X", subver);
- append_dict_entry(&dict, "revision",
+ dbus_message_iter_append_dict_entry(&dict, "revision",
DBUS_TYPE_STRING, &ptr);
ptr = bt_compidtostr(compid);
- append_dict_entry(&dict, "manufacturer",
+ dbus_message_iter_append_dict_entry(&dict, "manufacturer",
DBUS_TYPE_STRING, &ptr);
ptr = lmp_vertostr(ver);
@@ -1239,7 +1248,7 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
free(str);
}
ptr = buf;
- append_dict_entry(&dict, "version",
+ dbus_message_iter_append_dict_entry(&dict, "version",
DBUS_TYPE_STRING, &ptr);
done:
diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c
index 7bdb2830..7ea19ba9 100644
--- a/hcid/dbus-common.c
+++ b/hcid/dbus-common.c
@@ -70,41 +70,6 @@ static sdp_session_t *sess = NULL;
static int experimental = 0;
-void append_dict_entry(DBusMessageIter *dict, const char *key,
- int type, void *val)
-{
- DBusMessageIter entry;
- DBusMessageIter value;
- char *sig;
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- switch (type) {
- case DBUS_TYPE_STRING:
- sig = DBUS_TYPE_STRING_AS_STRING;
- break;
- case DBUS_TYPE_UINT32:
- sig = DBUS_TYPE_UINT32_AS_STRING;
- break;
- case DBUS_TYPE_BOOLEAN:
- sig = DBUS_TYPE_BOOLEAN_AS_STRING;
- break;
- default:
- sig = DBUS_TYPE_VARIANT_AS_STRING;
- break;
- }
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, sig, &value);
-
- dbus_message_iter_append_basic(&value, type, val);
-
- dbus_message_iter_close_container(&entry, &value);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
service_handler_func_t find_service_handler(struct service_data *handlers, DBusMessage *msg)
{
struct service_data *current;
diff --git a/hcid/dbus-common.h b/hcid/dbus-common.h
index 21a6b003..54e7b58d 100644
--- a/hcid/dbus-common.h
+++ b/hcid/dbus-common.h
@@ -36,9 +36,6 @@ typedef DBusHandlerResult (*service_handler_func_t) (DBusConnection *conn,
DBusMessage *msg,
void *user_data);
-void append_dict_entry(DBusMessageIter *dict, const char *key,
- int type, void *val);
-
struct service_data {
const char *name;
service_handler_func_t handler_func;
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index 803bef13..81c4b2da 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -121,15 +121,19 @@ static DBusHandlerResult get_info(DBusConnection *conn,
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
- append_dict_entry(&dict, "identifier", DBUS_TYPE_STRING, &service->ident);
+ dbus_message_iter_append_dict_entry(&dict, "identifier",
+ DBUS_TYPE_STRING, &service->ident);
- append_dict_entry(&dict, "name", DBUS_TYPE_STRING, &service->name);
+ dbus_message_iter_append_dict_entry(&dict, "name",
+ DBUS_TYPE_STRING, &service->name);
- append_dict_entry(&dict, "description", DBUS_TYPE_STRING, &service->descr);
+ dbus_message_iter_append_dict_entry(&dict, "description",
+ DBUS_TYPE_STRING, &service->descr);
running = (service->external || service->bus_name) ? TRUE : FALSE;
- append_dict_entry(&dict, "running", DBUS_TYPE_BOOLEAN, &running);
+ dbus_message_iter_append_dict_entry(&dict, "running",
+ DBUS_TYPE_BOOLEAN, &running);
dbus_message_iter_close_container(&iter, &dict);