Skip to content

Commit

Permalink
FEAT(client): Introduced new mumble API
Browse files Browse the repository at this point in the history
This patch introduces a new API to link, unlink, start to listen,
stop the listen the channels and send the messages to the plugins
  • Loading branch information
mryamac committed May 21, 2024
1 parent 7a6274f commit 7d6cd18
Show file tree
Hide file tree
Showing 7 changed files with 628 additions and 1 deletion.
128 changes: 127 additions & 1 deletion plugins/MumblePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# define MUMBLE_PLUGIN_API_MAJOR_MACRO 1
# endif
# ifndef MUMBLE_PLUGIN_API_MINOR_MACRO
# define MUMBLE_PLUGIN_API_MINOR_MACRO 2
# define MUMBLE_PLUGIN_API_MINOR_MACRO 3
# endif
# ifndef MUMBLE_PLUGIN_API_PATCH_MACRO
# define MUMBLE_PLUGIN_API_PATCH_MACRO 0
Expand Down Expand Up @@ -1515,6 +1515,42 @@ struct MUMBLE_API_STRUCT_NAME {
mumble_channelid_t channelID,
const char **description);

# if SELECTED_API_VERSION >= MUMBLE_PLUGIN_VERSION_CHECK(1, 3, 0)

/**
* Checks whether the linkedChannelID is linked to channelID.
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelID The ID of the channel
* @param linkedChannelID The ID of the linked channel
* @param[out] linked A pointer to where the result of the check
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *isChannelLinkedTo)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t channelID,
mumble_channelid_t linkedChannelID,
bool *linked);

/**
* Gets the channel set the given channel is linked to.
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelID The ID of the channel
* @param[out] channels The set of channel IDs linked to the channelID
* @param[out] channelCount The amount of linked channels
* @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointers
* may be accessed.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getLinkedChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t channelID,
mumble_channelid_t **channels,
size_t *channelCount);

# endif

// -------- Request functions --------

Expand Down Expand Up @@ -1608,7 +1644,97 @@ struct MUMBLE_API_STRUCT_NAME {
mumble_connection_t connection,
const char *comment);

# if SELECTED_API_VERSION >= MUMBLE_PLUGIN_VERSION_CHECK(1, 3, 0)

/**
* Requests Mumble to link all channels in the given set to each other.
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelSet The set of channel IDs to link
* @param channelCount The number of elements in the channel list
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestLinkChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t *channelSet,
size_t channelCount);

/**
* Requests Mumble to remove any existing links between the provided channel and channels in the provided set.
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelID The ID of the channel to unlink
* @param channelSet The set of channel IDs to remove link from the channelID
* @param channelCount The number of elements in the channel set
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestUnlinkChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t channelID,
mumble_channelid_t *channelSet,
size_t channelCount);


/**
* Requests Mumble to remove all links between the provided channels.
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelSet The set of channel IDs to remove link
* @param channelCount The number of elements in the channel set
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestUnlinkGivenChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t *channelSet,
size_t channelCount);


/**
* Starts to listen channel set
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelSet The set of channel IDs to listen
* @param channelCount The number of elements in the channel set
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestStartListeningToChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t *channelSet,
size_t channelCount);

/**
* Stops to listen channel set
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param channelSet The set of channel IDs to stop listen
* @param channelCount The number of elements in the channel set
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestStopListeningToChannels)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_channelid_t *channelSet,
size_t channelCount);

/**
* Send text message to the given user
*
* @param callerID The ID of the plugin calling this function
* @param connection The ID of the server-connection
* @param userID The ID of the user to send the message
* @param message The message to send
* @returns The error code. If everything went well, STATUS_OK will be returned.
*/
mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestSendUserTextMessage)(mumble_plugin_id_t callerID,
mumble_connection_t connection,
mumble_userid_t userID,
const char *message);

# endif

// -------- Find functions --------

Expand Down
27 changes: 27 additions & 0 deletions src/mumble/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public slots:
void isLocalUserMuted_v_1_0_x(mumble_plugin_id_t callerID, bool *muted, std::shared_ptr< api_promise_t > promise);
void isLocalUserDeafened_v_1_0_x(mumble_plugin_id_t callerID, bool *deafened,
std::shared_ptr< api_promise_t > promise);
void isChannelLinkedTo_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t channelID, mumble_channelid_t linkedChannelID, bool *linked,
std::shared_ptr< api_promise_t > promise);
void getUserHash_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t userID,
const char **hash, std::shared_ptr< api_promise_t > promise);
void getServerHash_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection, const char **hash,
Expand All @@ -119,6 +122,9 @@ public slots:
void getChannelDescription_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t channelID, const char **description,
std::shared_ptr< api_promise_t > promise);
void getLinkedChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t channelID, mumble_channelid_t **channels,
std::size_t *channelCount, std::shared_ptr< api_promise_t > promise);
void requestUserMove_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t userID,
mumble_channelid_t channelID, const char *password,
std::shared_ptr< api_promise_t > promise);
Expand All @@ -132,6 +138,24 @@ public slots:
std::shared_ptr< api_promise_t > promise);
void requestSetLocalUserComment_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
const char *comment, std::shared_ptr< api_promise_t > promise);
void requestLinkChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t *channelList, std::size_t channelCount,
std::shared_ptr< api_promise_t > promise);
void requestUnlinkChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t channelID, mumble_channelid_t *unlinkList,
std::size_t unlinkCount, std::shared_ptr< api_promise_t > promise);
void requestUnlinkGivenChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t *unlinkList, std::size_t unlinkCount,
std::shared_ptr< api_promise_t > promise);
void requestStartListeningToChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t *channelList, std::size_t channelCount,
std::shared_ptr< api_promise_t > promise);
void requestStopListeningToChannels_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_channelid_t *channelList, std::size_t channelCount,
std::shared_ptr< api_promise_t > promise);
void requestSendUserTextMessage_v_1_3_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
mumble_userid_t userID, const char *message,
std::shared_ptr< api_promise_t > promise);
void findUserByName_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection, const char *userName,
mumble_userid_t *userID, std::shared_ptr< api_promise_t > promise);
void findChannelByName_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection, const char *channelName,
Expand Down Expand Up @@ -174,6 +198,9 @@ MumbleAPI_v_1_0_x getMumbleAPI_v_1_0_x();
/// @returns The Mumble API struct (v1.2.x)
MumbleAPI_v_1_2_x getMumbleAPI_v_1_2_x();

/// @returns The Mumble API struct (v1.3.x)
MumbleAPI_v_1_3_x getMumbleAPI_v_1_3_x();

/// Converts from the Qt key-encoding to the API's key encoding.
///
/// @param keyCode The Qt key-code that shall be converted
Expand Down
Loading

0 comments on commit 7d6cd18

Please sign in to comment.