mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-08-06 21:28:30 +02:00
Hook up interfaces for functions to register another process
This commit is contained in:
@@ -120,6 +120,48 @@ static int method_query_status(sd_bus_message *m, void *userdata,
|
||||
return sd_bus_reply_method_return(m, "i", status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the RegisterGameByPID D-BUS Method
|
||||
*/
|
||||
static int method_register_game_by_pid(sd_bus_message *m, void *userdata,
|
||||
__attribute__((unused)) sd_bus_error *ret_error)
|
||||
{
|
||||
int callerpid = 0;
|
||||
int gamepid = 0;
|
||||
GameModeContext *context = userdata;
|
||||
|
||||
int ret = sd_bus_message_read(m, "ii", &callerpid, &gamepid);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR("Failed to parse input parameters: %s\n", strerror(-ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int reply = game_mode_context_register_by_pid(context, (pid_t)callerpid, (pid_t)gamepid);
|
||||
|
||||
return sd_bus_reply_method_return(m, "i", reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the UnregisterGameByPID D-BUS Method
|
||||
*/
|
||||
static int method_unregister_game_by_pid(sd_bus_message *m, void *userdata,
|
||||
__attribute__((unused)) sd_bus_error *ret_error)
|
||||
{
|
||||
int callerpid = 0;
|
||||
int gamepid = 0;
|
||||
GameModeContext *context = userdata;
|
||||
|
||||
int ret = sd_bus_message_read(m, "ii", &callerpid, &gamepid);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR("Failed to parse input parameters: %s\n", strerror(-ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int reply = game_mode_context_unregister_by_pid(context, (pid_t)callerpid, (pid_t)gamepid);
|
||||
|
||||
return sd_bus_reply_method_return(m, "i", reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* D-BUS vtable to dispatch virtual methods
|
||||
*/
|
||||
@@ -128,6 +170,10 @@ static const sd_bus_vtable gamemode_vtable[] =
|
||||
SD_BUS_METHOD("RegisterGame", "i", "i", method_register_game, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("UnregisterGame", "i", "i", method_unregister_game, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("QueryStatus", "i", "i", method_query_status, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("RegisterGameByPID", "ii", "i", method_register_game_by_pid,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("UnregisterGameByPID", "ii", "i", method_unregister_game_by_pid,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_VTABLE_END };
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user