Beispiel #1
0
static gboolean property_get_immediate_alert_level(
					const GDBusPropertyTable *property,
					DBusMessageIter *iter, void *data)
{
	struct btd_device *device = data;
	const char *level;

	level = imm_alert_get_level(device);

	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &level);

	return TRUE;
}
Beispiel #2
0
static DBusMessage *get_properties(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessageIter iter;
	DBusMessageIter dict;
	DBusMessage *reply = NULL;
	const char *linkloss_level, *immalert_level;
	struct btd_device *device = data;

	reply = dbus_message_new_method_return(msg);
	if (!reply)
		return NULL;

	linkloss_level = link_loss_get_alert_level(device);
	immalert_level = imm_alert_get_level(device);

	dbus_message_iter_init_append(reply, &iter);

	if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
			DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
			DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
			DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict))
		goto err;

	dict_append_entry(&dict, "LinkLossAlertLevel", DBUS_TYPE_STRING,
							&linkloss_level);
	dict_append_entry(&dict, "ImmediateAlertLevel", DBUS_TYPE_STRING,
							&immalert_level);

	if (!dbus_message_iter_close_container(&iter, &dict))
		goto err;

	return reply;

err:
	if (reply)
		dbus_message_unref(reply);
	return btd_error_failed(msg, "not enough memory");
}