Refactor to use single internal functions for register, unregister and query

This commit is contained in:
Marc Di Luzio
2019-02-10 11:48:41 +00:00
parent d4fdd9e3b4
commit 1d40c0cc1b
3 changed files with 92 additions and 153 deletions

View File

@ -67,17 +67,23 @@ void game_mode_context_destroy(GameModeContext *self);
* Register a new game client with the context
*
* @param pid Process ID for the remote client
* @returns True if the new client could be registered
* @param requester Process ID for the remote requestor
* @returns 0 if the request was accepted and the client could be registered
* -1 if the request was accepted but the client could not be registered
* -2 if the request was rejected
*/
bool game_mode_context_register(GameModeContext *self, pid_t pid);
int game_mode_context_register(GameModeContext *self, pid_t pid, pid_t requester);
/**
* Unregister an existing remote game client from the context
*
* @param pid Process ID for the remote client
* @returns True if the client was removed, and existed.
* @param requester Process ID for the remote requestor
* @returns 0 if the request was accepted and the client existed
* -1 if the request was accepted but the client did not exist
* -2 if the request was rejected
*/
bool game_mode_context_unregister(GameModeContext *self, pid_t pid);
int game_mode_context_unregister(GameModeContext *self, pid_t pid, pid_t requester);
/**
* Query the current status of gamemode
@ -86,41 +92,9 @@ bool game_mode_context_unregister(GameModeContext *self, pid_t pid);
* @returns Positive if gamemode is active
* 1 if gamemode is active but the client is not registered
* 2 if gamemode is active and the client is registered
* -2 if this requester was rejected
*/
int game_mode_context_query_status(GameModeContext *self, pid_t pid);
/**
* Register a new game client with the context on behalf of another process
*
* @param callerpid Process ID for the remote client making the request
* @param gamepid Process ID for the process to be registered
* @returns 0 if the request was accepted and the client could be registered
* -1 if the request was accepted but the client could not be registered
* -2 if the request was rejected
*/
int game_mode_context_register_by_pid(GameModeContext *self, pid_t callerpid, pid_t gamepid);
/**
* Unregister an existing remote game client from the context on behalf of another process
*
* @param callerpid Process ID for the remote client making the request
* @param gamepid Process ID for the process to be registered
* @returns 0 if the request was accepted and the client existed
* -1 if the request was accepted but the client did not exist
* -2 if the request was rejected
*/
int game_mode_context_unregister_by_pid(GameModeContext *self, pid_t callerpid, pid_t gamepid);
/**
* Query the current status of gamemode for another process
*
* @param pid Process ID for the remote client
* @returns Positive if gamemode is active
* 1 if gamemode is active but the client is not registered
* 2 if gamemode is active and the client is registered
* -2 if this supervisor was rejected
*/
int game_mode_context_query_status_by_pid(GameModeContext *self, pid_t callerpid, pid_t gamepid);
int game_mode_context_query_status(GameModeContext *self, pid_t pid, pid_t requester);
/**
* Query the config of a gamemode context