mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-07 08:07:20 +02:00
daemon: export GameModeClient::Timestamp on D-Bus
Expose the timestamp that a client was created as 'Timestamp' property of the com.feralinteractive.GameMode.Game interface.
This commit is contained in:
parent
52367772c8
commit
288b3a005e
@ -462,6 +462,38 @@ static int game_object_get_executable(sd_bus *local_bus, const char *path, const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the Timestamp property for Game objects
|
||||||
|
*/
|
||||||
|
static int game_object_get_timestamp(sd_bus *local_bus, const char *path, const char *interface,
|
||||||
|
const char *property, sd_bus_message *reply, void *userdata,
|
||||||
|
sd_bus_error *ret_error)
|
||||||
|
{
|
||||||
|
GameModeClient *client;
|
||||||
|
GameModeContext *context;
|
||||||
|
uint64_t timestamp;
|
||||||
|
pid_t pid;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pid = pid_from_pointer(userdata);
|
||||||
|
|
||||||
|
context = game_mode_context_instance();
|
||||||
|
client = game_mode_context_lookup_client(context, pid);
|
||||||
|
|
||||||
|
if (client == NULL) {
|
||||||
|
return sd_bus_error_setf(ret_error,
|
||||||
|
SD_BUS_ERROR_UNKNOWN_OBJECT,
|
||||||
|
"No client registered with id '%d'", (int) pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamp = game_mode_client_get_timestamp(client);
|
||||||
|
ret = sd_bus_message_append_basic(reply, 't', ×tamp);
|
||||||
|
game_mode_client_unref(client);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Same as above: this bit seems to be formatted differently by different clang-format versions */
|
/* Same as above: this bit seems to be formatted differently by different clang-format versions */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
static const sd_bus_vtable game_vtable[] = {
|
static const sd_bus_vtable game_vtable[] = {
|
||||||
@ -470,6 +502,8 @@ static const sd_bus_vtable game_vtable[] = {
|
|||||||
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||||
SD_BUS_PROPERTY("Executable", "s", game_object_get_executable, 0,
|
SD_BUS_PROPERTY("Executable", "s", game_object_get_executable, 0,
|
||||||
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||||
|
SD_BUS_PROPERTY("Timestamp", "t", game_object_get_timestamp, 0,
|
||||||
|
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||||
SD_BUS_VTABLE_END
|
SD_BUS_VTABLE_END
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user