|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 4afbccded23f5144e39a7f7b243393799186ba39 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Sun, 28 Sep 2014 22:13:07 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] core/swap: advertise Discard over dbus
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/dbus-swap.c | 24 ++++++++++++++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 24 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 93eae53c29..c854716b48 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/dbus-swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/dbus-swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -55,12 +55,36 @@ static int property_get_priority(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return sd_bus_message_append(reply, "i", p);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int property_get_discard(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_bus *bus,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const char *path,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const char *interface,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const char *property,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_bus_message *reply,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ void *userdata,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_bus_error *error) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ Swap *s = SWAP(userdata);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const char *p;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert(bus);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert(reply);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (s->from_fragment)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ p = s->parameters_fragment.discard ?: "none";
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ p = "none";
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return sd_bus_message_append(reply, "s", p);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const sd_bus_vtable bus_swap_vtable[] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_VTABLE_START(0),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_PROPERTY("What", "s", NULL, offsetof(Swap, what), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_PROPERTY("Priority", "i", property_get_priority, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ SD_BUS_PROPERTY("Discard", "s", property_get_discard, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_PROPERTY("TimeoutUSec", "t", bus_property_get_usec, offsetof(Swap, timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Swap, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Swap, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|