mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
daemon: export GameModeClient::Requester on D-Bus
Expose the requeter process identifier as 'Requester' property of the com.feralinteractive.GameMode.Game interface.
This commit is contained in:
parent
cfe0fb4f17
commit
5c1b2d0c74
@ -462,6 +462,39 @@ static int game_object_get_executable(sd_bus *local_bus, const char *path, const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the Requester property for Game objects
|
||||||
|
*/
|
||||||
|
static int game_object_get_requester(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;
|
||||||
|
pid_t requester;
|
||||||
|
pid_t pid;
|
||||||
|
int ret;
|
||||||
|
int pv;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
requester = game_mode_client_get_requester(client);
|
||||||
|
pv = (int) requester;
|
||||||
|
|
||||||
|
ret = sd_bus_message_append_basic(reply, 'i', &pv);
|
||||||
|
game_mode_client_unref(client);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Handles the Timestamp property for Game objects
|
* Handles the Timestamp property for Game objects
|
||||||
*/
|
*/
|
||||||
@ -493,7 +526,6 @@ static int game_object_get_timestamp(sd_bus *local_bus, const char *path, const
|
|||||||
return ret;
|
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[] = {
|
||||||
@ -502,6 +534,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("Requester", "i", game_object_get_requester, 0,
|
||||||
|
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||||
SD_BUS_PROPERTY("Timestamp", "t", game_object_get_timestamp, 0,
|
SD_BUS_PROPERTY("Timestamp", "t", game_object_get_timestamp, 0,
|
||||||
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||||
SD_BUS_VTABLE_END
|
SD_BUS_VTABLE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user