diff options
author | Robert Adam <dev@robert-adam.de> | 2021-04-16 22:02:25 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2021-04-16 22:05:52 +0300 |
commit | 923045ac6029bc7433c60ce2fad5a35e025beedd (patch) | |
tree | abf6a4001f7b795242e49b619fc3ffb6c0623633 | |
parent | d4a5fc1047837ce2018a6381e0e74a51f65b2a8f (diff) |
FORMAT: Run clang-format 10 on all source files
107 files changed, 3491 insertions, 3007 deletions
diff --git a/plugins/MumbleAPI_v_1_0_x.h b/plugins/MumbleAPI_v_1_0_x.h index 34b178f87..2e0a79466 100644 --- a/plugins/MumbleAPI_v_1_0_x.h +++ b/plugins/MumbleAPI_v_1_0_x.h @@ -17,17 +17,20 @@ #define MUMBLE_PLUGIN_API_MINOR_MACRO 0 #define MUMBLE_PLUGIN_API_PATCH_MACRO 0 -constexpr int32_t MUMBLE_PLUGIN_API_MAJOR = MUMBLE_PLUGIN_API_MAJOR_MACRO; -constexpr int32_t MUMBLE_PLUGIN_API_MINOR = MUMBLE_PLUGIN_API_MINOR_MACRO; -constexpr int32_t MUMBLE_PLUGIN_API_PATCH = MUMBLE_PLUGIN_API_PATCH_MACRO; -const mumble_version_t MUMBLE_PLUGIN_API_VERSION = { MUMBLE_PLUGIN_API_MAJOR, MUMBLE_PLUGIN_API_MINOR, MUMBLE_PLUGIN_API_PATCH }; +constexpr int32_t MUMBLE_PLUGIN_API_MAJOR = MUMBLE_PLUGIN_API_MAJOR_MACRO; +constexpr int32_t MUMBLE_PLUGIN_API_MINOR = MUMBLE_PLUGIN_API_MINOR_MACRO; +constexpr int32_t MUMBLE_PLUGIN_API_PATCH = MUMBLE_PLUGIN_API_PATCH_MACRO; +const mumble_version_t MUMBLE_PLUGIN_API_VERSION = { MUMBLE_PLUGIN_API_MAJOR, MUMBLE_PLUGIN_API_MINOR, + MUMBLE_PLUGIN_API_PATCH }; // Create macro for casting the pointer to the API object to the proper struct. // Note that this must only be used if the API uses MUMBLE_PLUGIN_API_VERSION of the API. -#define MUMBLE_CONCAT_HELPER(a, b) a ## _ ## b +#define MUMBLE_CONCAT_HELPER(a, b) a##_##b #define MUMBLE_CONCAT(a, b) MUMBLE_CONCAT_HELPER(a, b) -#define MUMBLE_API_STRUCT MUMBLE_CONCAT(MumbleAPI_v, MUMBLE_CONCAT(MUMBLE_PLUGIN_API_MAJOR_MACRO, MUMBLE_CONCAT(MUMBLE_PLUGIN_API_MINOR_MACRO, x))) -#define MUMBLE_API_CAST(ptrName) ( *((struct MUMBLE_API_STRUCT *) ptrName) ) +#define MUMBLE_API_STRUCT \ + MUMBLE_CONCAT(MumbleAPI_v, \ + MUMBLE_CONCAT(MUMBLE_PLUGIN_API_MAJOR_MACRO, MUMBLE_CONCAT(MUMBLE_PLUGIN_API_MINOR_MACRO, x))) +#define MUMBLE_API_CAST(ptrName) (*((struct MUMBLE_API_STRUCT *) ptrName)) struct MumbleAPI_v_1_0_x { @@ -53,35 +56,38 @@ struct MumbleAPI_v_1_0_x { // -------- Memory management -------- - + /// Frees the given pointer. /// /// @param callerID The ID of the plugin calling this function /// @param pointer The pointer to free /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *freeMemory)(mumble_plugin_id_t callerID, const void *pointer); + mumble_error_t(PLUGIN_CALLING_CONVENTION *freeMemory)(mumble_plugin_id_t callerID, const void *pointer); + - // -------- Getter functions -------- /// Gets the connection ID of the server the user is currently active on (the user's audio output is directed at). /// /// @param callerID The ID of the plugin calling this function /// @param[out] connection A pointer to the memory location the ID should be written to - /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then it is valid to access the - /// value of the provided pointer - mumble_error_t (PLUGIN_CALLING_CONVENTION *getActiveServerConnection)(mumble_plugin_id_t callerID, mumble_connection_t *connection); + /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then it is valid to access + /// the value of the provided pointer + mumble_error_t(PLUGIN_CALLING_CONVENTION *getActiveServerConnection)(mumble_plugin_id_t callerID, + mumble_connection_t *connection); /// Checks whether the given connection has finished initializing yet. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context - /// @param[out] A pointer to the boolean variable that'll hold the info whether the server has finished synchronization yet - /// after this function has executed successfully. + /// @param[out] A pointer to the boolean variable that'll hold the info whether the server has finished + /// synchronization yet after this function has executed successfully. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *isConnectionSynchronized)(mumble_plugin_id_t callerID, mumble_connection_t connection, bool *synchronized); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *isConnectionSynchronized)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + bool *synchronized); /// Fills in the information about the local user. /// @@ -89,64 +95,69 @@ struct MumbleAPI_v_1_0_x { /// @param connection The ID of the server-connection to use as a context /// @param[out] userID A pointer to the memory the user's ID shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getLocalUserID)(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t *userID); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getLocalUserID)(mumble_plugin_id_t callerID, + mumble_connection_t connection, mumble_userid_t *userID); /// Fills in the information about the given user's name. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param userID The user's ID whose name should be obtained - /// @param[out] userName A pointer to where the pointer to the allocated string (C-encoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// @param[out] userName A pointer to where the pointer to the allocated string (C-encoded) should be written to. + /// The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getUserName)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_userid_t userID, const char **userName); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getUserName)(mumble_plugin_id_t callerID, mumble_connection_t connection, + mumble_userid_t userID, const char **userName); /// Fills in the information about the given channel's name. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param channelID The channel's ID whose name should be obtained - /// @param[out] channelName A pointer to where the pointer to the allocated string (C-ecoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// @param[out] channelName A pointer to where the pointer to the allocated string (C-ecoded) should be written to. + /// The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getChannelName)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_channelid_t channelID, const char **channelName); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getChannelName)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + mumble_channelid_t channelID, const char **channelName); - /// Gets an array of all users that are currently connected to the provided server. Passing a nullptr as any of the out-parameter - /// will prevent that property to be set/allocated. If you are only interested in the user count you can thus pass nullptr as the - /// users parameter and save time on allocating + freeing the channels-array while still getting the size out. + /// Gets an array of all users that are currently connected to the provided server. Passing a nullptr as any of the + /// out-parameter will prevent that property to be set/allocated. If you are only interested in the user count you + /// can thus pass nullptr as the users parameter and save time on allocating + freeing the channels-array while + /// still getting the size out. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param[out] users A pointer to where the pointer of the allocated array shall be written. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @param[out] userCount A pointer to where the size of the allocated user-array shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getAllUsers)(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t **users, - size_t *userCount); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getAllUsers)(mumble_plugin_id_t callerID, mumble_connection_t connection, + mumble_userid_t **users, size_t *userCount); /// Gets an array of all channels on the provided server. Passing a nullptr as any of the out-parameter will prevent - /// that property to be set/allocated. If you are only interested in the channel count you can thus pass nullptr as the - /// channels parameter and save time on allocating + freeing the channels-array while still getting the size out. + /// that property to be set/allocated. If you are only interested in the channel count you can thus pass nullptr as + /// the channels parameter and save time on allocating + freeing the channels-array while still getting the size + /// out. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param[out] channels A pointer to where the pointer of the allocated array shall be written. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @param[out] channelCount A pointer to where the size of the allocated channel-array shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getAllChannels)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_channelid_t **channels, size_t *channelCount); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getAllChannels)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + mumble_channelid_t **channels, size_t *channelCount); /// Gets the ID of the channel the given user is currently connected to. /// @@ -155,31 +166,35 @@ struct MumbleAPI_v_1_0_x { /// @param userID The ID of the user to search for /// @param[out] A pointer to where the ID of the channel shall be written /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getChannelOfUser)(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t userID, - mumble_channelid_t *channel); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getChannelOfUser)(mumble_plugin_id_t callerID, + mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t *channel); /// Gets an array of all users in the specified channel. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param channelID The ID of the channel whose users shall be retrieved - /// @param[out] userList A pointer to where the pointer of the allocated array shall be written. The allocated memory has - /// to be freed by a call to freeMemory by the plugin eventually. The memory will only be allocated if this function - /// returns STATUS_OK. + /// @param[out] userList A pointer to where the pointer of the allocated array shall be written. The allocated + /// memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be allocated if + /// this function returns STATUS_OK. /// @param[out] userCount A pointer to where the size of the allocated user-array shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getUsersInChannel)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_channelid_t channelID, mumble_userid_t **userList, size_t *userCount); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getUsersInChannel)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + mumble_channelid_t channelID, + mumble_userid_t **userList, size_t *userCount); /// Gets the current transmission mode of the local user. /// /// @param callerID The ID of the plugin calling this function /// @param[out] transmissionMode A pointer to where the transmission mode shall be written. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getLocalUserTransmissionMode)(mumble_plugin_id_t callerID, mumble_transmission_mode_t *transmissionMode); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getLocalUserTransmissionMode)( + mumble_plugin_id_t callerID, mumble_transmission_mode_t *transmissionMode); /// Checks whether the given user is currently locally muted. /// @@ -188,25 +203,26 @@ struct MumbleAPI_v_1_0_x { /// @param userID The ID of the user to check for /// @param[out] muted A pointer to where the local mute state of that user shall be written /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *isUserLocallyMuted)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_userid_t userID, bool *muted); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *isUserLocallyMuted)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + mumble_userid_t userID, bool *muted); /// Checks whether the local user is currently muted. /// /// @param callerID The ID of the plugin calling this function /// @param[out] muted A pointer to where the mute state of the local user shall be written /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *isLocalUserMuted)(mumble_plugin_id_t callerID, bool *muted); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *isLocalUserMuted)(mumble_plugin_id_t callerID, bool *muted); /// Checks whether the local user is currently deafened. /// /// @param callerID The ID of the plugin calling this function /// @param[out] deafened A pointer to where the deaf state of the local user shall be written /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *isLocalUserDeafened)(mumble_plugin_id_t callerID, bool *deafened); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *isLocalUserDeafened)(mumble_plugin_id_t callerID, bool *deafened); /// Gets the hash of the given user (can be used to recognize users between restarts) /// @@ -214,65 +230,70 @@ struct MumbleAPI_v_1_0_x { /// @param connection The ID of the server-connection to use as a context /// @param userID The ID of the user to search for /// @param[out] hash A pointer to where the pointer to the allocated string (C-encoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getUserHash)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_userid_t userID, const char **hash); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getUserHash)(mumble_plugin_id_t callerID, mumble_connection_t connection, + mumble_userid_t userID, const char **hash); /// Gets the hash of the server for the given connection (can be used to recognize servers between restarts) /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection /// @param[out] hash A pointer to where the pointer to the allocated string (C-encoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getServerHash)(mumble_plugin_id_t callerID, mumble_connection_t connection, const char **hash); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getServerHash)(mumble_plugin_id_t callerID, + mumble_connection_t connection, const char **hash); - /// Gets the comment of the given user. Note that a user might have a comment configured that hasn't been synchronized - /// to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now there is now way - /// to request the synchronization to happen via the Plugin-API. + /// Gets the comment of the given user. Note that a user might have a comment configured that hasn't been + /// synchronized to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now there + /// is now way to request the synchronization to happen via the Plugin-API. /// /// @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 whose comment should be obtained /// @param[out] comment A pointer to where the pointer to the allocated string (C-encoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getUserComment)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_userid_t userID, const char **comment); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getUserComment)(mumble_plugin_id_t callerID, + mumble_connection_t connection, mumble_userid_t userID, + const char **comment); - /// Gets the description of the given channel. Note that a channel might have a description configured that hasn't been synchronized - /// to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now there is now way - /// to request the synchronization to happen via the Plugin-API. + /// Gets the description of the given channel. Note that a channel might have a description configured that hasn't + /// been synchronized to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now + /// there is now way to request the synchronization to happen via the Plugin-API. /// /// @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 whose comment should be obtained - /// @param[out] description A pointer to where the pointer to the allocated string (C-encoded) should be written to. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// @param[out] description A pointer to where the pointer to the allocated string (C-encoded) should be written to. + /// The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be + /// allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *getChannelDescription)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_channelid_t channelID, const char **description); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *getChannelDescription)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + mumble_channelid_t channelID, + const char **description); // -------- Request functions -------- - - /// Requests Mumble to set the local user's transmission mode to the specified one. If you only need to temporarily set - /// the transmission mode to continous, use requestMicrophoneActivationOverwrite instead as this saves you the work of - /// restoring the previous state afterwards. + + /// Requests Mumble to set the local user's transmission mode to the specified one. If you only need to temporarily + /// set the transmission mode to continous, use requestMicrophoneActivationOverwrite instead as this saves you the + /// work of restoring the previous state afterwards. /// /// @param callerID The ID of the plugin calling this function /// @param transmissionMode The requested transmission mode /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestLocalUserTransmissionMode)(mumble_plugin_id_t callerID, mumble_transmission_mode_t transmissionMode); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestLocalUserTransmissionMode)( + mumble_plugin_id_t callerID, mumble_transmission_mode_t transmissionMode); /// Requests Mumble to move the given user into the given channel /// @@ -280,50 +301,52 @@ struct MumbleAPI_v_1_0_x { /// @param connection The ID of the server-connection to use as a context /// @param userID The ID of the user that shall be moved /// @param channelID The ID of the channel to move the user to - /// @param password The password of the target channel (UTF-8 encoded as a C-string). Pass NULL if the target channel does not require a - /// password for entering + /// @param password The password of the target channel (UTF-8 encoded as a C-string). Pass NULL if the target + /// channel does not require a password for entering /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestUserMove)(mumble_plugin_id_t callerID, mumble_connection_t connection, mumble_userid_t userID, - mumble_channelid_t channelID, const char *password); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestUserMove)(mumble_plugin_id_t callerID, + mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t channelID, const char *password); - /// Requests Mumble to overwrite the microphone activation so that the microphone is always on (same as if the user had chosen - /// the continous transmission mode). If a plugin requests this overwrite, it is responsible for deactivating the overwrite again - /// once it is no longer required + /// Requests Mumble to overwrite the microphone activation so that the microphone is always on (same as if the user + /// had chosen the continous transmission mode). If a plugin requests this overwrite, it is responsible for + /// deactivating the overwrite again once it is no longer required /// /// @param callerID The ID of the plugin calling this function /// @param activate Whether to activate the overwrite (false deactivates an existing overwrite) /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestMicrophoneActivationOvewrite)(mumble_plugin_id_t callerID, bool activate); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestMicrophoneActivationOvewrite)(mumble_plugin_id_t callerID, + bool activate); - /// Requests Mumble to set the local mute state of the given client. Note that this only affects the **local** mute state - /// opposed to a server-mute (client is globally muted by the server) or the client's own mute-state (client has muted its - /// microphone and thus isn't transmitting any audio). - /// Furthermore it must be noted that muting the local user with this function does not work (it doesn't make sense). If - /// you try to do so, this function will fail. In order to make this work, this function will also fail if the server - /// has not finished synchronizing with the client yet. - /// For muting the local user, use requestLocalUserMute instead. + /// Requests Mumble to set the local mute state of the given client. Note that this only affects the **local** mute + /// state opposed to a server-mute (client is globally muted by the server) or the client's own mute-state (client + /// has muted its microphone and thus isn't transmitting any audio). Furthermore it must be noted that muting the + /// local user with this function does not work (it doesn't make sense). If you try to do so, this function will + /// fail. In order to make this work, this function will also fail if the server has not finished synchronizing with + /// the client yet. For muting the local user, use requestLocalUserMute instead. /// /// @param callerID The ID of the plugin calling this function. /// @param connection The ID of the server-connection to use as a context /// @param userID The ID of the user that shall be muted /// @param muted Whether to locally mute the given client (opposed to unmuting it) /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestLocalMute)(mumble_plugin_id_t callerID, mumble_connection_t connection, - mumble_userid_t userID, bool muted); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestLocalMute)(mumble_plugin_id_t callerID, + mumble_connection_t connection, mumble_userid_t userID, + bool muted); /// Requests Mumble to set the mute state of the local user. In the UI this is referred to as "self-mute". /// /// @param callerID The ID of the plugin calling this function. /// @param muted Whether to locally mute the local user (opposed to unmuting it) /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestLocalUserMute)(mumble_plugin_id_t callerID, bool muted); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestLocalUserMute)(mumble_plugin_id_t callerID, bool muted); /// Requests Mumble to set the deaf state of the local user. In the UI this is referred to as "self-deaf". /// /// @param callerID The ID of the plugin calling this function. /// @param deafened Whether to locally deafen the local user (opposed to undeafening it) /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestLocalUserDeaf)(mumble_plugin_id_t callerID, bool deafened); + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestLocalUserDeaf)(mumble_plugin_id_t callerID, bool deafened); /// Sets the comment of the local user /// @@ -331,127 +354,141 @@ struct MumbleAPI_v_1_0_x { /// @param connection The ID of the server-connection /// @param comment The new comment to use (C-encoded). A subset of HTML formatting is supported. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer - /// may be accessed - mumble_error_t (PLUGIN_CALLING_CONVENTION *requestSetLocalUserComment)(mumble_plugin_id_t callerID, mumble_connection_t connection, - const char *comment); + /// may be accessed + mumble_error_t(PLUGIN_CALLING_CONVENTION *requestSetLocalUserComment)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + const char *comment); // -------- Find functions -------- - - /// Fills in the information about a user with the specified name, if such a user exists. The search is case-sensitive. + + /// Fills in the information about a user with the specified name, if such a user exists. The search is + /// case-sensitive. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param userName The respective user's name /// @param[out] userID A pointer to the memory the user's ID shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *findUserByName)(mumble_plugin_id_t callerID, mumble_connection_t connection, const char *userName, - mumble_userid_t *userID); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *findUserByName)(mumble_plugin_id_t callerID, + mumble_connection_t connection, const char *userName, + mumble_userid_t *userID); - /// Fills in the information about a channel with the specified name, if such a channel exists. The search is case-sensitive. + /// Fills in the information about a channel with the specified name, if such a channel exists. The search is + /// case-sensitive. /// /// @param callerID The ID of the plugin calling this function /// @param connection The ID of the server-connection to use as a context /// @param channelName The respective channel's name /// @param[out] channelID A pointer to the memory the channel's ID shall be written to /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *findChannelByName)(mumble_plugin_id_t callerID, mumble_connection_t connection, - const char *channelName, mumble_channelid_t *channelID); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *findChannelByName)(mumble_plugin_id_t callerID, + mumble_connection_t connection, + const char *channelName, + mumble_channelid_t *channelID); // -------- Settings -------- - /// Fills in the current value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a bool! + /// Fills in the current value of the setting with the given key. Note that this function can only be used for + /// settings whose value is a bool! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param[out] outValue A pointer to the memory the setting's value shall be written to. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *getMumbleSetting_bool)(mumble_plugin_id_t callerID, mumble_settings_key_t key, bool *outValue); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *getMumbleSetting_bool)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, bool *outValue); - /// Fills in the current value of the setting with the given key. Note that this function can only be used for settings whose value - /// is an int! + /// Fills in the current value of the setting with the given key. Note that this function can only be used for + /// settings whose value is an int! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param[out] outValue A pointer to the memory the setting's value shall be written to. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *getMumbleSetting_int)(mumble_plugin_id_t callerID, mumble_settings_key_t key, int64_t *outValue); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *getMumbleSetting_int)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, int64_t *outValue); - /// Fills in the current value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a double! + /// Fills in the current value of the setting with the given key. Note that this function can only be used for + /// settings whose value is a double! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param[out] outValue A pointer to the memory the setting's value shall be written to. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *getMumbleSetting_double)(mumble_plugin_id_t callerID, mumble_settings_key_t key, double *outValue); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *getMumbleSetting_double)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, double *outValue); - /// Fills in the current value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a String! + /// Fills in the current value of the setting with the given key. Note that this function can only be used for + /// settings whose value is a String! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting - /// @param[out] outValue The memory address to which the pointer to the setting's value (the String) will be written. The - /// allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be - /// allocated if this function returns STATUS_OK. + /// @param[out] outValue The memory address to which the pointer to the setting's value (the String) will be + /// written. The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will + /// only be allocated if this function returns STATUS_OK. /// @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may - /// be accessed. - mumble_error_t (PLUGIN_CALLING_CONVENTION *getMumbleSetting_string)(mumble_plugin_id_t callerID, mumble_settings_key_t key, const char **outValue); + /// be accessed. + mumble_error_t(PLUGIN_CALLING_CONVENTION *getMumbleSetting_string)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, + const char **outValue); - /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a bool! + /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose + /// value is a bool! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param value The value that should be set for the given setting /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *setMumbleSetting_bool)(mumble_plugin_id_t callerID, mumble_settings_key_t key, bool value); + mumble_error_t(PLUGIN_CALLING_CONVENTION *setMumbleSetting_bool)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, bool value); - /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose value - /// is an int! + /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose + /// value is an int! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param value The value that should be set for the given setting /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *setMumbleSetting_int)(mumble_plugin_id_t callerID, mumble_settings_key_t key, int64_t value); + mumble_error_t(PLUGIN_CALLING_CONVENTION *setMumbleSetting_int)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, int64_t value); - /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a double! + /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose + /// value is a double! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param value The value that should be set for the given setting /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *setMumbleSetting_double)(mumble_plugin_id_t callerID, mumble_settings_key_t key, double value); + mumble_error_t(PLUGIN_CALLING_CONVENTION *setMumbleSetting_double)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, double value); - /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose value - /// is a string! + /// Sets the value of the setting with the given key. Note that this function can only be used for settings whose + /// value is a string! /// /// @param callerID The ID of the plugin calling this function /// @param key The key to the desired setting /// @param value The value that should be set for the given setting /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *setMumbleSetting_string)(mumble_plugin_id_t callerID, mumble_settings_key_t key, const char *value); - + mumble_error_t(PLUGIN_CALLING_CONVENTION *setMumbleSetting_string)(mumble_plugin_id_t callerID, + mumble_settings_key_t key, const char *value); // -------- Miscellaneous -------- - - /// Sends the provided data to the provided client(s). This kind of data can only be received by another plugin active - /// on that client. The sent data can be seen by any active plugin on the receiving client. Therefore the sent data - /// must not contain sensitive information or anything else that shouldn't be known by others. + + /// Sends the provided data to the provided client(s). This kind of data can only be received by another plugin + /// active on that client. The sent data can be seen by any active plugin on the receiving client. Therefore the + /// sent data must not contain sensitive information or anything else that shouldn't be known by others. /// /// NOTE: Messages sent via this API function are rate-limited by the server. If the rate-limit is hit, the message /// will be dropped without an error message. The rate-limiting is global (e.g. it doesn't matter which plugin sent @@ -464,29 +501,30 @@ struct MumbleAPI_v_1_0_x { /// @param users An array of user IDs to send the data to /// @param userCount The size of the provided user-array /// @param data The data array that shall be sent. This can be an arbitrary sequence of bytes. Note that the size of - /// is restricted to <= 1KB. + /// is restricted to <= 1KB. /// @param dataLength The length of the data array - /// @param dataID The ID of the sent data. This has to be used by the receiving plugin(s) to figure out what to do with - /// the data. This has to be a C-encoded String. It is recommended that the ID starts with a plugin-specific prefix - /// in order to avoid name clashes. Note that the size of this string is restricted to <= 100 bytes. + /// @param dataID The ID of the sent data. This has to be used by the receiving plugin(s) to figure out what to do + /// with the data. This has to be a C-encoded String. It is recommended that the ID starts with a plugin-specific + /// prefix in order to avoid name clashes. Note that the size of this string is restricted to <= 100 bytes. /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *sendData)(mumble_plugin_id_t callerID, mumble_connection_t connection, const mumble_userid_t *users, - size_t userCount, const uint8_t *data, size_t dataLength, const char *dataID); + mumble_error_t(PLUGIN_CALLING_CONVENTION *sendData)(mumble_plugin_id_t callerID, mumble_connection_t connection, + const mumble_userid_t *users, size_t userCount, + const uint8_t *data, size_t dataLength, const char *dataID); /// Logs the given message (typically to Mumble's console). All passed strings have to be UTF-8 encoded. /// /// @param callerID The ID of the plugin calling this function /// @param message The message to log /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *log)(mumble_plugin_id_t callerID, const char *message); + mumble_error_t(PLUGIN_CALLING_CONVENTION *log)(mumble_plugin_id_t callerID, const char *message); - /// Plays the provided sample. It uses libsndfile as a backend so the respective file format needs to be supported by it - /// in order for this to work out (see http://www.mega-nerd.com/libsndfile/). + /// Plays the provided sample. It uses libsndfile as a backend so the respective file format needs to be supported + /// by it in order for this to work out (see http://www.mega-nerd.com/libsndfile/). /// /// @param callerID The ID of the plugin calling this function /// @param samplePath The path to the sample that shall be played (UTF-8 encoded) /// @returns The error code. If everything went well, STATUS_OK will be returned. - mumble_error_t (PLUGIN_CALLING_CONVENTION *playSample)(mumble_plugin_id_t callerID, const char *samplePath); + mumble_error_t(PLUGIN_CALLING_CONVENTION *playSample)(mumble_plugin_id_t callerID, const char *samplePath); }; #endif diff --git a/plugins/MumblePlugin_v_1_0_x.h b/plugins/MumblePlugin_v_1_0_x.h index f3feb740b..8f816b1a1 100644 --- a/plugins/MumblePlugin_v_1_0_x.h +++ b/plugins/MumblePlugin_v_1_0_x.h @@ -8,20 +8,20 @@ #ifndef EXTERNAL_MUMBLE_PLUGIN_H_ #define EXTERNAL_MUMBLE_PLUGIN_H_ -#include "PluginComponents_v_1_0_x.h" #include "MumbleAPI_v_1_0_x.h" -#include <stdint.h> -#include <stddef.h> +#include "PluginComponents_v_1_0_x.h" #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> #if defined(__GNUC__) && !defined(__MINGW32__) // GCC on Unix-like systems - #define PLUGIN_EXPORT __attribute__((visibility("default"))) +# define PLUGIN_EXPORT __attribute__((visibility("default"))) #elif defined(_MSC_VER) - #define PLUGIN_EXPORT __declspec(dllexport) +# define PLUGIN_EXPORT __declspec(dllexport) #elif defined(__MINGW32__) - #define PLUGIN_EXPORT __attribute__((dllexport)) +# define PLUGIN_EXPORT __attribute__((dllexport)) #else - #error No PLUGIN_EXPORT definition available +# error No PLUGIN_EXPORT definition available #endif @@ -29,374 +29,400 @@ extern "C" { #endif - ////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////// MANDATORY FUNCTIONS /////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////// - - /// Gets called right after loading the plugin in order to let the plugin initialize. - /// - /// Registers the ID of this plugin. - /// @param id The ID for this plugin. This is the ID Mumble will reference this plugin with - /// and by which this plugin can identify itself when communicating with Mumble. - /// @returns The status of the initialization. If everything went fine, return STATUS_OK - PLUGIN_EXPORT mumble_error_t PLUGIN_CALLING_CONVENTION mumble_init(uint32_t id); - - /// Gets called when unloading the plugin in order to allow it to clean up after itself. - /// Note that it is still safe to call API functions from within this callback. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_shutdown(); - - /// Gets the name of the plugin. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns A String-wrapper containing the requested name - PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getName(); - - /// Gets the Version of the plugin-API this plugin intends to use. - /// Mumble will decide whether this plugin is loadable or not based on the return value of this function. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns The respective API Version - PLUGIN_EXPORT mumble_version_t PLUGIN_CALLING_CONVENTION mumble_getAPIVersion(); - - /// Provides the MumbleAPI struct to the plugin. This struct contains function pointers that can be used - /// to interact with the Mumble client. It is up to the plugin to store this struct somewhere if it wants to make use - /// of it at some point. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @param api A pointer to the MumbleAPI struct. The API struct must be cast to the version corresponding to the - /// user API version. If your plugin is e.g. using the 1.0.x API, then you have to cast this pointer to - /// MumbleAPI_v_1_0_x. Note also that you **must not store this pointer**. It will become invalid. Therefore - /// you have to copy the struct in order to use it later on. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_registerAPIFunctions(void *apiStruct); - - /// Releases the resource pointed to by the given pointer. If the respective resource has been allocated before, - /// this would be the time to free/delete it. - /// The resources processed by this functions are only those that have been specifically allocated in order to return - /// them in one of the plugin functions to Mumble (e.g. the String returned by mumble_getName) and has nothing to do - /// with your plugin's internal resource management. - /// In short: Only resources passed from the plugin to Mumble via a return value may be processed by this function. - /// - /// NOTE1: This function may be called without the plugin being loaded - /// - /// NOTE2: that the pointer might be pointing to memory that had to be allocated without the plugin being loaded. - /// Therefore you should be very sure that there'll be another callback in which you want to free this memory, - /// should you decide to not do it here (which is hereby explicitly advised against). - /// - /// NOTE3: The pointer is const as Mumble won't mess with the memory allocated by the plugin (no modifications). - /// Nontheless this function is explicitly responsible for freeing the respective memory parts. If the memory has - /// been allocated using malloc(), it needs to be freed using free() which requires a const-cast. If however the - /// memory has been created using the new operator you have to cast the pointer back to its original type and then - /// use the delete operator on it (no const-cast necessary in this case). - /// See https://stackoverflow.com/questions/2819535/unable-to-free-const-pointers-in-c - /// and https://stackoverflow.com/questions/941832/is-it-safe-to-delete-a-void-pointer - /// - /// @param pointer The pointer to the memory that needs free-ing - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_releaseResource(const void *pointer); - - - - ////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////// GENERAL FUNCTIONS ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////// - - /// Tells the plugin some basic information about the Mumble client loading it. - /// This function will be the first one that is being called on this plugin - even before it is decided whether to load - /// the plugin at all. - /// - /// @param mumbleVersion The Version of the Mumble client - /// @param mumbleAPIVersion The Version of the plugin-API the Mumble client runs with - /// @param minimumExpectedAPIVersion The minimum Version the Mumble clients expects this plugin to meet in order to load it - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, mumble_version_t minimumExpectedAPIVersion); - - /// Gets the Version of this plugin - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns The plugin's version - PLUGIN_EXPORT mumble_version_t PLUGIN_CALLING_CONVENTION mumble_getVersion(); - - /// Gets the name of the plugin author(s). - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns A String-wrapper containing the requested author name(s) - PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getAuthor(); - - /// Gets the description of the plugin. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns A String-wrapper containing the requested description - PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getDescription(); - - /// Gets the feature set of this plugin. The feature set is described by bitwise or'ing the elements of the Mumble_PluginFeature enum - /// together. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns The feature set of this plugin - PLUGIN_EXPORT uint32_t PLUGIN_CALLING_CONVENTION mumble_getFeatures(); - - /// Requests this plugin to deactivate the given (sub)set of provided features. - /// If this is not possible, the features that can't be deactivated shall be returned by this function. - /// - /// Example (check if FEATURE_POSITIONAL shall be deactivated): - /// @code - /// if (features & FEATURE_POSITIONAL) { - /// // positional shall be deactivated - /// }; - /// @endcode - /// - /// @param features The feature set that shall be deactivated - /// @returns The feature set that can't be disabled (bitwise or'ed). If all requested features can be disabled, return - /// FEATURE_NONE. If none of the requested features can be disabled return the unmodified features parameter. - PLUGIN_EXPORT uint32_t PLUGIN_CALLING_CONVENTION mumble_deactivateFeatures(uint32_t features); - - - - ////////////////////////////////////////////////////////////////////////////////// - //////////////////////////// POSITIONAL DATA ///////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////// - // If this plugin wants to provide positional data, ALL functions of this category - // have to be implemented - - /// Indicates that Mumble wants to use this plugin to request positional data. Therefore it should check whether it is currently - /// able to do so and allocate memory that is needed for that process. - /// As a parameter this function gets an array of names and an array of PIDs. They are of same length and the PID at index i - /// belongs to a program whose name is listed at index i in the "name-array". - /// - /// @param programNames An array of pointers to the program names - /// @param programPIDs An array of the corresponding program PIDs - /// @param programCount The length of programNames and programPIDs - /// @returns The error code. If everything went fine PDEC_OK shall be returned. In that case Mumble will start frequently - /// calling fetchPositionalData. If this returns anything but PDEC_OK, Mumble will assume that the plugin is (currently) - /// uncapable of providing positional data. In this case this function must not have allocated any memory that needs to be - /// cleaned up later on. Depending on the returned error code, Mumble might try to call this function again at some point. - PLUGIN_EXPORT uint8_t PLUGIN_CALLING_CONVENTION mumble_initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount); - - /// Retrieves the positional data. If no data can be fetched, set all float-vectors to 0 and return false. - /// - /// @param[out] avatarPos A float-array of size 3 representing the cartesian position of the player/avatar in the ingame world. - /// One unit represents one meter of distance. - /// @param[out] avatarDir A float-array of size 3 representing the cartesian direction-vector of the player/avatar ingame (where it - /// is facing). - /// @param[out] avatarAxis A float-array of size 3 representing the vector pointing from the toes of the character to its head. One - /// unit represents one meter of distance. - /// @param[out] cameraPos A float-array of size 3 representing the cartesian position of the camera in the ingame world. - /// One unit represents one meter of distance. - /// @param[out] cameraDir A float-array of size 3 representing the cartesian direction-vector of the camera ingame (where it - /// is facing). - /// @param[out] cameraAxis A float-array of size 3 representing a vector from the bottom of the camera to its top. One unit - /// represents one meter of distance. - /// @param[out] context A pointer to where the pointer to a C-encoded string storing the context of the provided positional data - /// shall be written. This context should include information about the server (and team) the player is on. Only players with identical - /// context will be able to hear each other's audio. The returned pointer has to remain valid until the next invokation of this function - /// or until shutdownPositionalData is called. - /// @param[out] identity A pointer to where the pointer to a C-encoded string storing the identity of the player shall be written. It can - /// be polled by external scripts from the server and should uniquely identify the player in the game. The pointer has to remain valid - /// until the next invokation of this function or until shutdownPositionalData is called. - /// @returns Whether this plugin can continue delivering positional data. If this function returns false, shutdownPositionalData will - /// be called. - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_fetchPositionalData(float *avatarPos, float *avatarDir, float *avatarAxis, float *cameraPos, float *cameraDir, - float *cameraAxis, const char **context, const char **identity); - - /// Indicates that this plugin will not be asked for positional data any longer. Thus any memory allocated for this purpose should - /// be freed at this point. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_shutdownPositionalData(); - - - - ////////////////////////////////////////////////////////////////////////////////// - ////////////////////// EVENTHANDLERS / CALLBACK FUNCTIONS //////////////////////// - ////////////////////////////////////////////////////////////////////////////////// - - /// Called when connecting to a server. - /// Note that in most cases you'll want to use mumble_onServerSynchronized instead. - /// Note also that this callback will be called from a DIFFERENT THREAD! - /// - /// @param connection The ID of the newly established server-connection - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerConnected(mumble_connection_t connection); - - /// Called when disconnecting from a server. - /// Note that this callback is called from a DIFFERENT THREAD! - /// - /// @param connection The ID of the server-connection that has been terminated - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerDisconnected(mumble_connection_t connection); - - /// Called when the client has finished synchronizing with the server - /// - /// @param connection The ID of the server-connection that has been terminated - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerSynchronized(mumble_connection_t connection); - - /// Called whenever any user on the server enters a channel - /// This function will also be called when freshly connecting to a server as each user on that - /// server needs to be "added" to the respective channel as far as the local client is concerned. - /// - /// @param connection The ID of the server-connection this event is connected to - /// @param userID The ID of the user this event has been triggered for - /// @param previousChannelID The ID of the chanel the user is coming from. Negative IDs indicate that there is no previous channel (e.g. the user - /// freshly connected to the server) or the channel isn't available because of any other reason. - /// @param newChannelID The ID of the channel the user has entered. If the ID is negative, the new channel could not be retrieved. This means - /// that the ID is invalid. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t previousChannelID, - mumble_channelid_t newChannelID); - - /// Called whenever a user leaves a channel. - /// This includes a client disconnecting from the server as this will also lead to the user not being in that channel anymore. - /// - /// @param connection The ID of the server-connection this event is connected to - /// @param userID The ID of the user that left the channel - /// @param channelID The ID of the channel the user left. If the ID is negative, the channel could not be retrieved. This means that the ID is - /// invalid. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelExited(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t channelID); - - /// Called when any user changes his/her talking state. - /// - /// @param connection The ID of the server-connection this event is connected to - /// @param userID The ID of the user whose talking state has been changed - /// @param talkingState The new TalkingState the user has switched to. - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, mumble_talking_state_t talkingState); - - /// Called whenever there is audio input. - /// Note that this callback will be called from the AUDIO THREAD. - /// Note also that blocking this callback will cause Mumble's audio processing to get suspended. - /// - /// @param inputPCM A pointer to a short-array holding the pulse-code-modulation (PCM) representing the audio input. Its length - /// is sampleCount * channelCount. The PCM format for stereo input is [LRLRLR...] where L and R are samples of the left and right - /// channel respectively. - /// @param sampleCount The amount of sample points per channel - /// @param channelCount The amount of channels in the audio - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech A boolean flag indicating whether Mumble considers the input as part of speech (instead of background noise) - /// @returns Whether this callback has modified the audio input-array - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, - uint32_t sampleRate, bool isSpeech); - - /// Called whenever Mumble fetches data from an active audio source (could be a voice packet or a playing sample). - /// The provided audio buffer is the raw buffer without any processing applied to it yet. - /// Note that this callback will be called from the AUDIO THREAD. - /// Note also that blocking this callback will cause Mumble's audio processing to get suspended. - /// - /// @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output. Its length - /// is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples of the left and right - /// channel respectively. - /// @param sampleCount The amount of sample points per channel - /// @param channelCount The amount of channels in the audio - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech Whether this audio belongs to a received voice packet (and will thus (most likely) contain speech) - /// @param userID If isSpeech is true, this contains the ID of the user this voice packet belongs to. If isSpeech is false, - /// the content of this parameter is unspecified and should not be accessed - /// @returns Whether this callback has modified the audio output-array - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, - uint32_t sampleRate, bool isSpeech, mumble_userid_t userID); - - /// Called whenever the fully mixed and processed audio is about to be handed to the audio backend (about to be played). - /// Note that this happens immediately before Mumble clips the audio buffer. - /// Note that this callback will be called from the AUDIO THREAD. - /// Note also that blocking this callback will cause Mumble's audio processing to get suspended. - /// - /// @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output. Its length - /// is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples of the left and right - /// channel respectively. - /// @param sampleCount The amount of sample points per channel - /// @param channelCount The amount of channels in the audio - /// @param sampleRate The used sample rate in Hz - /// @returns Whether this callback has modified the audio output-array - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, - uint32_t sampleRate); - - /// Called whenever data has been received that has been sent by a plugin. This data should only be processed by the - /// intended plugin. For this reason a dataID is provided that should be used to determine whether the data is intended - /// for this plugin or not. As soon as the data has been processed, no further plugins will be notified about it. - /// - /// @param connection The ID of the server-connection the data is coming from - /// @param sender The ID of the user whose client's plugin has sent the data - /// @param data The sent data array. This can be an arbitrary sequence of bytes. - /// @param dataLength The length of the data array - /// @param dataID The ID of this data (C-encoded) - /// @return Whether the given data has been processed by this plugin - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onReceiveData(mumble_connection_t connection, mumble_userid_t sender, - const uint8_t *data, size_t dataLength, const char *dataID); - - /// Called when a new user gets added to the user model. This is the case when that new user freshly connects to the server the - /// local user is on but also when the local user connects to a server other clients are already connected to (in this case this - /// method will be called for every client already on that server). - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that has been added - - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserAdded(mumble_connection_t connection, mumble_userid_t userID); - - /// Called when a user gets removed from the user model. This is the case when that user disconnects from the server the - /// local user is on but also when the local user disconnects from a server other clients are connected to (in this case this - /// method will be called for every client on that server). - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that has been removed - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserRemoved(mumble_connection_t connection, mumble_userid_t userID); - - /// Called when a new channel gets added to the user model. This is the case when a new channel is created on the server the local - /// user is on but also when the local user connects to a server that contains channels other than the root-channel (in this case - /// this method will be called for ever non-root channel on that server). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been added - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelAdded(mumble_connection_t connection, mumble_channelid_t channelID); - - /// Called when a channel gets removed from the user model. This is the case when a channel is removed on the server the local - /// user is on but also when the local user disconnects from a server that contains channels other than the root-channel (in this case - /// this method will be called for ever non-root channel on that server). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been removed - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelRemoved(mumble_connection_t connection, mumble_channelid_t channelID); - - /// Called when a channel gets renamed. This also applies when a new channel is created (thus assigning it an initial name is also - /// considered renaming). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been renamed - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelRenamed(mumble_connection_t connection, mumble_channelid_t channelID); - - /// Called when a key has been pressed or released while Mumble has keyboard focus. - /// Note that this callback will only work if the user has explicitly given permission to monitor keyboard - /// events for this plugin. Thus if you want to use this callback, make sure your users know that they have to - /// enable that. - /// - /// @param keyCode The key code of the respective key. The character codes are defined - /// via the Mumble_KeyCode enum. For printable 7-bit ASCII characters these codes conform - /// to the ASCII code-page with the only difference that case is not distinguished. Therefore - /// always the upper-case letter code will be used for letters. - /// @param wasPres Whether the respective key has been pressed (instead of released) - PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onKeyEvent(uint32_t keyCode, bool wasPress); - - - - ////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////// PLUGIN UPDATES //////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////// - - /// This function is used to determine whether the plugin can find an update for itself that is available for download. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @return Whether the plugin was able to find an update for itself - PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_hasUpdate(); - - /// This function is used to retrieve the URL for downloading the newer/updated version of this plugin. - /// - /// NOTE: This function may be called without the plugin being loaded - /// - /// @returns A String-wrapper containing the requested URL - PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getUpdateDownloadURL(); +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////// MANDATORY FUNCTIONS /////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// + +/// Gets called right after loading the plugin in order to let the plugin initialize. +/// +/// Registers the ID of this plugin. +/// @param id The ID for this plugin. This is the ID Mumble will reference this plugin with +/// and by which this plugin can identify itself when communicating with Mumble. +/// @returns The status of the initialization. If everything went fine, return STATUS_OK +PLUGIN_EXPORT mumble_error_t PLUGIN_CALLING_CONVENTION mumble_init(uint32_t id); + +/// Gets called when unloading the plugin in order to allow it to clean up after itself. +/// Note that it is still safe to call API functions from within this callback. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_shutdown(); + +/// Gets the name of the plugin. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns A String-wrapper containing the requested name +PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getName(); + +/// Gets the Version of the plugin-API this plugin intends to use. +/// Mumble will decide whether this plugin is loadable or not based on the return value of this function. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns The respective API Version +PLUGIN_EXPORT mumble_version_t PLUGIN_CALLING_CONVENTION mumble_getAPIVersion(); + +/// Provides the MumbleAPI struct to the plugin. This struct contains function pointers that can be used +/// to interact with the Mumble client. It is up to the plugin to store this struct somewhere if it wants to make use +/// of it at some point. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @param api A pointer to the MumbleAPI struct. The API struct must be cast to the version corresponding to the +/// user API version. If your plugin is e.g. using the 1.0.x API, then you have to cast this pointer to +/// MumbleAPI_v_1_0_x. Note also that you **must not store this pointer**. It will become invalid. Therefore +/// you have to copy the struct in order to use it later on. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_registerAPIFunctions(void *apiStruct); + +/// Releases the resource pointed to by the given pointer. If the respective resource has been allocated before, +/// this would be the time to free/delete it. +/// The resources processed by this functions are only those that have been specifically allocated in order to return +/// them in one of the plugin functions to Mumble (e.g. the String returned by mumble_getName) and has nothing to do +/// with your plugin's internal resource management. +/// In short: Only resources passed from the plugin to Mumble via a return value may be processed by this function. +/// +/// NOTE1: This function may be called without the plugin being loaded +/// +/// NOTE2: that the pointer might be pointing to memory that had to be allocated without the plugin being loaded. +/// Therefore you should be very sure that there'll be another callback in which you want to free this memory, +/// should you decide to not do it here (which is hereby explicitly advised against). +/// +/// NOTE3: The pointer is const as Mumble won't mess with the memory allocated by the plugin (no modifications). +/// Nontheless this function is explicitly responsible for freeing the respective memory parts. If the memory has +/// been allocated using malloc(), it needs to be freed using free() which requires a const-cast. If however the +/// memory has been created using the new operator you have to cast the pointer back to its original type and then +/// use the delete operator on it (no const-cast necessary in this case). +/// See https://stackoverflow.com/questions/2819535/unable-to-free-const-pointers-in-c +/// and https://stackoverflow.com/questions/941832/is-it-safe-to-delete-a-void-pointer +/// +/// @param pointer The pointer to the memory that needs free-ing +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_releaseResource(const void *pointer); + + + +////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// GENERAL FUNCTIONS ////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// + +/// Tells the plugin some basic information about the Mumble client loading it. +/// This function will be the first one that is being called on this plugin - even before it is decided whether to load +/// the plugin at all. +/// +/// @param mumbleVersion The Version of the Mumble client +/// @param mumbleAPIVersion The Version of the plugin-API the Mumble client runs with +/// @param minimumExpectedAPIVersion The minimum Version the Mumble clients expects this plugin to meet in order to load +/// it +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_setMumbleInfo(mumble_version_t mumbleVersion, + mumble_version_t mumbleAPIVersion, + mumble_version_t minimumExpectedAPIVersion); + +/// Gets the Version of this plugin +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns The plugin's version +PLUGIN_EXPORT mumble_version_t PLUGIN_CALLING_CONVENTION mumble_getVersion(); + +/// Gets the name of the plugin author(s). +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns A String-wrapper containing the requested author name(s) +PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getAuthor(); + +/// Gets the description of the plugin. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns A String-wrapper containing the requested description +PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getDescription(); + +/// Gets the feature set of this plugin. The feature set is described by bitwise or'ing the elements of the +/// Mumble_PluginFeature enum together. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns The feature set of this plugin +PLUGIN_EXPORT uint32_t PLUGIN_CALLING_CONVENTION mumble_getFeatures(); + +/// Requests this plugin to deactivate the given (sub)set of provided features. +/// If this is not possible, the features that can't be deactivated shall be returned by this function. +/// +/// Example (check if FEATURE_POSITIONAL shall be deactivated): +/// @code +/// if (features & FEATURE_POSITIONAL) { +/// // positional shall be deactivated +/// }; +/// @endcode +/// +/// @param features The feature set that shall be deactivated +/// @returns The feature set that can't be disabled (bitwise or'ed). If all requested features can be disabled, return +/// FEATURE_NONE. If none of the requested features can be disabled return the unmodified features parameter. +PLUGIN_EXPORT uint32_t PLUGIN_CALLING_CONVENTION mumble_deactivateFeatures(uint32_t features); + + + +////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// POSITIONAL DATA ///////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +// If this plugin wants to provide positional data, ALL functions of this category +// have to be implemented + +/// Indicates that Mumble wants to use this plugin to request positional data. Therefore it should check whether it is +/// currently able to do so and allocate memory that is needed for that process. As a parameter this function gets an +/// array of names and an array of PIDs. They are of same length and the PID at index i belongs to a program whose name +/// is listed at index i in the "name-array". +/// +/// @param programNames An array of pointers to the program names +/// @param programPIDs An array of the corresponding program PIDs +/// @param programCount The length of programNames and programPIDs +/// @returns The error code. If everything went fine PDEC_OK shall be returned. In that case Mumble will start +/// frequently calling fetchPositionalData. If this returns anything but PDEC_OK, Mumble will assume that the plugin is +/// (currently) uncapable of providing positional data. In this case this function must not have allocated any memory +/// that needs to be cleaned up later on. Depending on the returned error code, Mumble might try to call this function +/// again at some point. +PLUGIN_EXPORT uint8_t PLUGIN_CALLING_CONVENTION mumble_initPositionalData(const char *const *programNames, + const uint64_t *programPIDs, + size_t programCount); + +/// Retrieves the positional data. If no data can be fetched, set all float-vectors to 0 and return false. +/// +/// @param[out] avatarPos A float-array of size 3 representing the cartesian position of the player/avatar in the ingame +/// world. One unit represents one meter of distance. +/// @param[out] avatarDir A float-array of size 3 representing the cartesian direction-vector of the player/avatar +/// ingame (where it is facing). +/// @param[out] avatarAxis A float-array of size 3 representing the vector pointing from the toes of the character to +/// its head. One unit represents one meter of distance. +/// @param[out] cameraPos A float-array of size 3 representing the cartesian position of the camera in the ingame world. +/// One unit represents one meter of distance. +/// @param[out] cameraDir A float-array of size 3 representing the cartesian direction-vector of the camera ingame +/// (where it is facing). +/// @param[out] cameraAxis A float-array of size 3 representing a vector from the bottom of the camera to its top. One +/// unit represents one meter of distance. +/// @param[out] context A pointer to where the pointer to a C-encoded string storing the context of the provided +/// positional data shall be written. This context should include information about the server (and team) the player is +/// on. Only players with identical context will be able to hear each other's audio. The returned pointer has to remain +/// valid until the next invokation of this function or until shutdownPositionalData is called. +/// @param[out] identity A pointer to where the pointer to a C-encoded string storing the identity of the player shall +/// be written. It can be polled by external scripts from the server and should uniquely identify the player in the +/// game. The pointer has to remain valid until the next invokation of this function or until shutdownPositionalData is +/// called. +/// @returns Whether this plugin can continue delivering positional data. If this function returns false, +/// shutdownPositionalData will be called. +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_fetchPositionalData(float *avatarPos, float *avatarDir, + float *avatarAxis, float *cameraPos, + float *cameraDir, float *cameraAxis, + const char **context, const char **identity); + +/// Indicates that this plugin will not be asked for positional data any longer. Thus any memory allocated for this +/// purpose should be freed at this point. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_shutdownPositionalData(); + + + +////////////////////////////////////////////////////////////////////////////////// +////////////////////// EVENTHANDLERS / CALLBACK FUNCTIONS //////////////////////// +////////////////////////////////////////////////////////////////////////////////// + +/// Called when connecting to a server. +/// Note that in most cases you'll want to use mumble_onServerSynchronized instead. +/// Note also that this callback will be called from a DIFFERENT THREAD! +/// +/// @param connection The ID of the newly established server-connection +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerConnected(mumble_connection_t connection); + +/// Called when disconnecting from a server. +/// Note that this callback is called from a DIFFERENT THREAD! +/// +/// @param connection The ID of the server-connection that has been terminated +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerDisconnected(mumble_connection_t connection); + +/// Called when the client has finished synchronizing with the server +/// +/// @param connection The ID of the server-connection that has been terminated +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onServerSynchronized(mumble_connection_t connection); + +/// Called whenever any user on the server enters a channel +/// This function will also be called when freshly connecting to a server as each user on that +/// server needs to be "added" to the respective channel as far as the local client is concerned. +/// +/// @param connection The ID of the server-connection this event is connected to +/// @param userID The ID of the user this event has been triggered for +/// @param previousChannelID The ID of the chanel the user is coming from. Negative IDs indicate that there is no +/// previous channel (e.g. the user freshly connected to the server) or the channel isn't available because of any other +/// reason. +/// @param newChannelID The ID of the channel the user has entered. If the ID is negative, the new channel could not be +/// retrieved. This means that the ID is invalid. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelEntered(mumble_connection_t connection, + mumble_userid_t userID, + mumble_channelid_t previousChannelID, + mumble_channelid_t newChannelID); + +/// Called whenever a user leaves a channel. +/// This includes a client disconnecting from the server as this will also lead to the user not being in that channel +/// anymore. +/// +/// @param connection The ID of the server-connection this event is connected to +/// @param userID The ID of the user that left the channel +/// @param channelID The ID of the channel the user left. If the ID is negative, the channel could not be retrieved. +/// This means that the ID is invalid. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelExited(mumble_connection_t connection, + mumble_userid_t userID, + mumble_channelid_t channelID); + +/// Called when any user changes his/her talking state. +/// +/// @param connection The ID of the server-connection this event is connected to +/// @param userID The ID of the user whose talking state has been changed +/// @param talkingState The new TalkingState the user has switched to. +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserTalkingStateChanged(mumble_connection_t connection, + mumble_userid_t userID, + mumble_talking_state_t talkingState); + +/// Called whenever there is audio input. +/// Note that this callback will be called from the AUDIO THREAD. +/// Note also that blocking this callback will cause Mumble's audio processing to get suspended. +/// +/// @param inputPCM A pointer to a short-array holding the pulse-code-modulation (PCM) representing the audio input. Its +/// length is sampleCount * channelCount. The PCM format for stereo input is [LRLRLR...] where L and R are samples of +/// the left and right channel respectively. +/// @param sampleCount The amount of sample points per channel +/// @param channelCount The amount of channels in the audio +/// @param sampleRate The used sample rate in Hz +/// @param isSpeech A boolean flag indicating whether Mumble considers the input as part of speech (instead of +/// background noise) +/// @returns Whether this callback has modified the audio input-array +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioInput(short *inputPCM, uint32_t sampleCount, + uint16_t channelCount, uint32_t sampleRate, + bool isSpeech); + +/// Called whenever Mumble fetches data from an active audio source (could be a voice packet or a playing sample). +/// The provided audio buffer is the raw buffer without any processing applied to it yet. +/// Note that this callback will be called from the AUDIO THREAD. +/// Note also that blocking this callback will cause Mumble's audio processing to get suspended. +/// +/// @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output. +/// Its length is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples +/// of the left and right channel respectively. +/// @param sampleCount The amount of sample points per channel +/// @param channelCount The amount of channels in the audio +/// @param sampleRate The used sample rate in Hz +/// @param isSpeech Whether this audio belongs to a received voice packet (and will thus (most likely) contain speech) +/// @param userID If isSpeech is true, this contains the ID of the user this voice packet belongs to. If isSpeech is +/// false, the content of this parameter is unspecified and should not be accessed +/// @returns Whether this callback has modified the audio output-array +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, + uint16_t channelCount, uint32_t sampleRate, + bool isSpeech, mumble_userid_t userID); + +/// Called whenever the fully mixed and processed audio is about to be handed to the audio backend (about to be played). +/// Note that this happens immediately before Mumble clips the audio buffer. +/// Note that this callback will be called from the AUDIO THREAD. +/// Note also that blocking this callback will cause Mumble's audio processing to get suspended. +/// +/// @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output. +/// Its length is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples +/// of the left and right channel respectively. +/// @param sampleCount The amount of sample points per channel +/// @param channelCount The amount of channels in the audio +/// @param sampleRate The used sample rate in Hz +/// @returns Whether this callback has modified the audio output-array +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, + uint16_t channelCount, + uint32_t sampleRate); + +/// Called whenever data has been received that has been sent by a plugin. This data should only be processed by the +/// intended plugin. For this reason a dataID is provided that should be used to determine whether the data is intended +/// for this plugin or not. As soon as the data has been processed, no further plugins will be notified about it. +/// +/// @param connection The ID of the server-connection the data is coming from +/// @param sender The ID of the user whose client's plugin has sent the data +/// @param data The sent data array. This can be an arbitrary sequence of bytes. +/// @param dataLength The length of the data array +/// @param dataID The ID of this data (C-encoded) +/// @return Whether the given data has been processed by this plugin +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_onReceiveData(mumble_connection_t connection, + mumble_userid_t sender, const uint8_t *data, + size_t dataLength, const char *dataID); + +/// Called when a new user gets added to the user model. This is the case when that new user freshly connects to the +/// server the local user is on but also when the local user connects to a server other clients are already connected to +/// (in this case this method will be called for every client already on that server). +/// +/// @param connection An object used to identify the current connection +/// @param userID The ID of the user that has been added + +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserAdded(mumble_connection_t connection, mumble_userid_t userID); + +/// Called when a user gets removed from the user model. This is the case when that user disconnects from the server the +/// local user is on but also when the local user disconnects from a server other clients are connected to (in this case +/// this method will be called for every client on that server). +/// +/// @param connection An object used to identify the current connection +/// @param userID The ID of the user that has been removed +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onUserRemoved(mumble_connection_t connection, + mumble_userid_t userID); + +/// Called when a new channel gets added to the user model. This is the case when a new channel is created on the server +/// the local user is on but also when the local user connects to a server that contains channels other than the +/// root-channel (in this case this method will be called for ever non-root channel on that server). +/// +/// @param connection An object used to identify the current connection +/// @param channelID The ID of the channel that has been added +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelAdded(mumble_connection_t connection, + mumble_channelid_t channelID); + +/// Called when a channel gets removed from the user model. This is the case when a channel is removed on the server the +/// local user is on but also when the local user disconnects from a server that contains channels other than the +/// root-channel (in this case this method will be called for ever non-root channel on that server). +/// +/// @param connection An object used to identify the current connection +/// @param channelID The ID of the channel that has been removed +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelRemoved(mumble_connection_t connection, + mumble_channelid_t channelID); + +/// Called when a channel gets renamed. This also applies when a new channel is created (thus assigning it an initial +/// name is also considered renaming). +/// +/// @param connection An object used to identify the current connection +/// @param channelID The ID of the channel that has been renamed +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onChannelRenamed(mumble_connection_t connection, + mumble_channelid_t channelID); + +/// Called when a key has been pressed or released while Mumble has keyboard focus. +/// Note that this callback will only work if the user has explicitly given permission to monitor keyboard +/// events for this plugin. Thus if you want to use this callback, make sure your users know that they have to +/// enable that. +/// +/// @param keyCode The key code of the respective key. The character codes are defined +/// via the Mumble_KeyCode enum. For printable 7-bit ASCII characters these codes conform +/// to the ASCII code-page with the only difference that case is not distinguished. Therefore +/// always the upper-case letter code will be used for letters. +/// @param wasPres Whether the respective key has been pressed (instead of released) +PLUGIN_EXPORT void PLUGIN_CALLING_CONVENTION mumble_onKeyEvent(uint32_t keyCode, bool wasPress); + + + +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////// PLUGIN UPDATES //////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// + +/// This function is used to determine whether the plugin can find an update for itself that is available for download. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @return Whether the plugin was able to find an update for itself +PLUGIN_EXPORT bool PLUGIN_CALLING_CONVENTION mumble_hasUpdate(); + +/// This function is used to retrieve the URL for downloading the newer/updated version of this plugin. +/// +/// NOTE: This function may be called without the plugin being loaded +/// +/// @returns A String-wrapper containing the requested URL +PLUGIN_EXPORT struct MumbleStringWrapper PLUGIN_CALLING_CONVENTION mumble_getUpdateDownloadURL(); #ifdef __cplusplus } -#endif +#endif #endif diff --git a/plugins/PluginComponents_v_1_0_x.h b/plugins/PluginComponents_v_1_0_x.h index 628283f22..8448b8ad4 100644 --- a/plugins/PluginComponents_v_1_0_x.h +++ b/plugins/PluginComponents_v_1_0_x.h @@ -8,32 +8,32 @@ #ifndef MUMBLE_PLUGINCOMPONENT_H_ #define MUMBLE_PLUGINCOMPONENT_H_ -#include <stdint.h> -#include <stddef.h> #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> #ifdef __cplusplus # include <string> #endif #ifdef QT_VERSION - #include <QString> +# include <QString> #endif // define the calling convention macro based on the compiler being used #if defined(_MSC_VER) - #define PLUGIN_CALLING_CONVENTION __cdecl +# define PLUGIN_CALLING_CONVENTION __cdecl #elif defined(__MINGW32__) - #define PLUGIN_CALLING_CONVENTION __attribute__((cdecl)) +# define PLUGIN_CALLING_CONVENTION __attribute__((cdecl)) #else - #define PLUGIN_CALLING_CONVENTION +# define PLUGIN_CALLING_CONVENTION #endif /// A macro holding the exit status of a successful operation #define STATUS_OK EC_OK /// A macro holding the version object that is considered to correspond to an unknown version -#define VERSION_UNKNOWN Version({0,0,0}) +#define VERSION_UNKNOWN Version({ 0, 0, 0 }) /// This enum's values correspond to special feature sets a plugin may provide. @@ -48,30 +48,19 @@ enum Mumble_PluginFeature { }; /// This enum's values represent talking states a user can be in when using Mumble. -enum Mumble_TalkingState { - INVALID=-1, - PASSIVE=0, - TALKING, - WHISPERING, - SHOUTING, - TALKING_MUTED -}; +enum Mumble_TalkingState { INVALID = -1, PASSIVE = 0, TALKING, WHISPERING, SHOUTING, TALKING_MUTED }; /// This enum's values represent transmission modes a user might have configured. Transmission mode /// in this context is referring to a method that determines when a user is speaking and thus when /// to transmit audio packets. -enum Mumble_TransmissionMode { - TM_CONTINOUS, - TM_VOICE_ACTIVATION, - TM_PUSH_TO_TALK -}; +enum Mumble_TransmissionMode { TM_CONTINOUS, TM_VOICE_ACTIVATION, TM_PUSH_TO_TALK }; /// This enum's values represent the error codes that are being used by the MumbleAPI. /// You can get a string-representation for each error code via the errorMessage function. enum Mumble_ErrorCode { EC_INTERNAL_ERROR = -2, - EC_GENERIC_ERROR = -1, - EC_OK = 0, + EC_GENERIC_ERROR = -1, + EC_OK = 0, EC_POINTER_NOT_FOUND, EC_NO_ACTIVE_CONNECTION, EC_USER_NOT_FOUND, @@ -106,45 +95,45 @@ enum Mumble_PositionalDataErrorCode { /// This enum's values represent keys for specific settings inside Mumble. enum Mumble_SettingsKey { - MSK_INVALID = -1, - MSK_AUDIO_INPUT_VOICE_HOLD = 0, + MSK_INVALID = -1, + MSK_AUDIO_INPUT_VOICE_HOLD = 0, MSK_AUDIO_INPUT_VAD_SILENCE_THRESHOLD = 1, - MSK_AUDIO_INPUT_VAD_SPEECH_THRESHOLD = 2, - MSK_AUDIO_OUTPUT_PA_MINIMUM_DISTANCE = 3, - MSK_AUDIO_OUTPUT_PA_MAXIMUM_DISTANCE = 4, - MSK_AUDIO_OUTPUT_PA_BLOOM = 5, - MSK_AUDIO_OUTPUT_PA_MINIMUM_VOLUME = 6, + MSK_AUDIO_INPUT_VAD_SPEECH_THRESHOLD = 2, + MSK_AUDIO_OUTPUT_PA_MINIMUM_DISTANCE = 3, + MSK_AUDIO_OUTPUT_PA_MAXIMUM_DISTANCE = 4, + MSK_AUDIO_OUTPUT_PA_BLOOM = 5, + MSK_AUDIO_OUTPUT_PA_MINIMUM_VOLUME = 6, }; /// This enum's values represent the key-codes Mumble's API uses to reference keys on the keyboard. enum Mumble_KeyCode { - KC_INVALID = -1, + KC_INVALID = -1, // Non-printable characters first - KC_NULL = 0, - KC_END = 1, - KC_LEFT = 2, - KC_RIGHT = 4, - KC_UP = 5, - KC_DOWN = 6, - KC_DELETE = 7, - KC_BACKSPACE = 8, - KC_TAB = 9, - KC_ENTER = 10, // == '\n' - KC_ESCAPE = 27, - KC_PAGE_UP = 11, - KC_PAGE_DOWN = 12, - KC_SHIFT = 13, - KC_CONTROL = 14, - KC_META = 15, - KC_ALT = 16, - KC_ALT_GR = 17, - KC_CAPSLOCK = 18, - KC_NUMLOCK = 19, - KC_SUPER = 20, // == windows key - KC_HOME = 21, // == Pos1 - KC_PRINT = 22, - KC_SCROLLLOCK = 23, + KC_NULL = 0, + KC_END = 1, + KC_LEFT = 2, + KC_RIGHT = 4, + KC_UP = 5, + KC_DOWN = 6, + KC_DELETE = 7, + KC_BACKSPACE = 8, + KC_TAB = 9, + KC_ENTER = 10, // == '\n' + KC_ESCAPE = 27, + KC_PAGE_UP = 11, + KC_PAGE_DOWN = 12, + KC_SHIFT = 13, + KC_CONTROL = 14, + KC_META = 15, + KC_ALT = 16, + KC_ALT_GR = 17, + KC_CAPSLOCK = 18, + KC_NUMLOCK = 19, + KC_SUPER = 20, // == windows key + KC_HOME = 21, // == Pos1 + KC_PRINT = 22, + KC_SCROLLLOCK = 23, // Printable characters are assigned to their ASCII code KC_SPACE = ' ', @@ -207,43 +196,43 @@ enum Mumble_KeyCode { KC_Y = 'Y', KC_Z = 'Z', // leave out lowercase letters (for now) - KC_OPEN_BRACKET = '[', - KC_BACKSLASH = '\\', - KC_CLOSE_BRACKET = ']', - KC_CIRCUMFLEX = '^', - KC_UNDERSCORE = '_', - KC_GRAVE_AKCENT = '`', - KC_OPEN_BRACE = '{', - KC_VERTICAL_BAR = '|', - KC_CLOSE_BRACE = '}', - KC_TILDE = '~', + KC_OPEN_BRACKET = '[', + KC_BACKSLASH = '\\', + KC_CLOSE_BRACKET = ']', + KC_CIRCUMFLEX = '^', + KC_UNDERSCORE = '_', + KC_GRAVE_AKCENT = '`', + KC_OPEN_BRACE = '{', + KC_VERTICAL_BAR = '|', + KC_CLOSE_BRACE = '}', + KC_TILDE = '~', // Some characters from the extended ASCII code - KC_DEGREE_SIGN = 176, + KC_DEGREE_SIGN = 176, // F-keys // Start at a value of 256 as extended ASCII codes range up to 255 - KC_F1 = 256, - KC_F2 = 257, - KC_F3 = 258, - KC_F4 = 259, - KC_F5 = 260, - KC_F6 = 261, - KC_F7 = 262, - KC_F8 = 263, - KC_F9 = 264, - KC_F10 = 265, - KC_F11 = 266, - KC_F12 = 267, - KC_F13 = 268, - KC_F14 = 269, - KC_F15 = 270, - KC_F16 = 271, - KC_F17 = 272, - KC_F18 = 273, - KC_F19 = 274, + KC_F1 = 256, + KC_F2 = 257, + KC_F3 = 258, + KC_F4 = 259, + KC_F5 = 260, + KC_F6 = 261, + KC_F7 = 262, + KC_F8 = 263, + KC_F9 = 264, + KC_F10 = 265, + KC_F11 = 266, + KC_F12 = 267, + KC_F13 = 268, + KC_F14 = 269, + KC_F15 = 270, + KC_F16 = 271, + KC_F17 = 272, + KC_F18 = 273, + KC_F19 = 274, }; /// A struct for representing a version of the form major.minor.patch @@ -252,7 +241,7 @@ struct Version { int32_t minor; int32_t patch; #ifdef __cplusplus - bool operator<(const Version& other) const { + bool operator<(const Version &other) const { if (this->major != other.major) { return this->major < other.major; } @@ -263,7 +252,7 @@ struct Version { return this->patch < other.patch; } - bool operator>(const Version& other) const { + bool operator>(const Version &other) const { if (this->major != other.major) { return this->major > other.major; } @@ -274,7 +263,7 @@ struct Version { return this->patch > other.patch; } - bool operator>=(const Version& other) const { + bool operator>=(const Version &other) const { if (this->major != other.major) { return this->major > other.major; } @@ -285,7 +274,7 @@ struct Version { return this->patch >= other.patch; } - bool operator<=(const Version& other) const { + bool operator<=(const Version &other) const { if (this->major != other.major) { return this->major < other.major; } @@ -296,36 +285,37 @@ struct Version { return this->patch <= other.patch; } - bool operator==(const Version& other) const { + bool operator==(const Version &other) const { return this->major == other.major && this->minor == other.minor && this->patch == other.patch; } - bool operator!=(const Version& other) const { + bool operator!=(const Version &other) const { return this->major != other.major || this->minor != other.minor || this->patch != other.patch; } operator std::string() const { - return std::string("v") + std::to_string(this->major) + std::string(".") + std::to_string(this->minor) + std::string(".") + std::to_string(this->patch); + return std::string("v") + std::to_string(this->major) + std::string(".") + std::to_string(this->minor) + + std::string(".") + std::to_string(this->patch); } -#ifdef QT_VERSION +# ifdef QT_VERSION operator QString() const { return QString::fromLatin1("v%0.%1.%2").arg(this->major).arg(this->minor).arg(this->patch); } -#endif +# endif #endif }; -/// Obtains a String representation for the given numeric error code. +/// Obtains a String representation for the given numeric error code. /// Note that the exact String representation corresponding to an error code may change and is thus /// not part of the plugin API as such. This function acts merely as a convenience helper for printing /// errors in a meaningful way. /// /// @param errorCode The error code to get the String representation for /// @returns The error message coresponding to the given error code. The message -/// is encoded as a C-string and is static, meaning that it is safe to use the -/// returned pointer in your code. -inline const char* errorMessage(int16_t errorCode) { +/// is encoded as a C-string and is static, meaning that it is safe to use the +/// returned pointer in your code. +inline const char *errorMessage(int16_t errorCode) { switch (errorCode) { case EC_GENERIC_ERROR: return "Generic error"; diff --git a/plugins/amongus/amongus.cpp b/plugins/amongus/amongus.cpp index c671e72ea..fd4112f6a 100644 --- a/plugins/amongus/amongus.cpp +++ b/plugins/amongus/amongus.cpp @@ -82,7 +82,7 @@ static int tryLock(const std::multimap< std::wstring, unsigned long long int > & return false; } - game = std::make_unique<Game>(id, name); + game = std::make_unique< Game >(id, name); if (!game->isOk()) { game.reset(); return false; diff --git a/plugins/bf1/bf1.cpp b/plugins/bf1/bf1.cpp index 766316018..f990a0b07 100644 --- a/plugins/bf1/bf1.cpp +++ b/plugins/bf1/bf1.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header +#include "../mumble_positional_audio_main.h" // Include standard positional audio header #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/plugins/bf2142/bf2142.cpp b/plugins/bf2142/bf2142.cpp index 7f7bb91d3..f392b27bf 100644 --- a/plugins/bf2142/bf2142.cpp +++ b/plugins/bf2142/bf2142.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". // Variable to contain module's addresses diff --git a/plugins/bf4/bf4.cpp b/plugins/bf4/bf4.cpp index 287dd8dc6..bb6b2586e 100644 --- a/plugins/bf4/bf4.cpp +++ b/plugins/bf4/bf4.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/plugins/bf4_x86/bf4_x86.cpp b/plugins/bf4_x86/bf4_x86.cpp index af7400e00..a1387a280 100644 --- a/plugins/bf4_x86/bf4_x86.cpp +++ b/plugins/bf4_x86/bf4_x86.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/plugins/ffxiv/ffxiv.cpp b/plugins/ffxiv/ffxiv.cpp index f7742bcdc..c332266be 100644 --- a/plugins/ffxiv/ffxiv.cpp +++ b/plugins/ffxiv/ffxiv.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". #include <cmath> diff --git a/plugins/gtav/gtav.cpp b/plugins/gtav/gtav.cpp index d00237c76..8ba6f3a87 100644 --- a/plugins/gtav/gtav.cpp +++ b/plugins/gtav/gtav.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". #include <algorithm> // Include algorithm header for the game version detector diff --git a/plugins/mumble_legacy_plugin.h b/plugins/mumble_legacy_plugin.h index 14c35cf40..1407990ae 100644 --- a/plugins/mumble_legacy_plugin.h +++ b/plugins/mumble_legacy_plugin.h @@ -8,15 +8,16 @@ // By default translation units including this file will not compile due to a preprocessor error. This is intended // behaviour as you shouldn't be using this API any longer. Use the API from MumblePlugin.h instead. // -// If for some reason you absolutely have to include this header file, you have to define the macro MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API -// before including this header. +// If for some reason you absolutely have to include this header file, you have to define the macro +// MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API before including this header. #ifndef MUMBLE_LEGACY_PLUGIN_H_ #define MUMBLE_LEGACY_PLUGIN_H_ #ifndef MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API - #error "You are trying to use a deprecated plugin API. Use the new API from MumblePlugin.h instead. If you think you really need this deprecated one, see the instructions at the top of this file." +# error \ + "You are trying to use a deprecated plugin API. Use the new API from MumblePlugin.h instead. If you think you really need this deprecated one, see the instructions at the top of this file." #else - #undef MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API +# undef MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #endif #include <stdint.h> diff --git a/plugins/ql/ql.cpp b/plugins/ql/ql.cpp index 69c0441a3..b57ab0acf 100644 --- a/plugins/ql/ql.cpp +++ b/plugins/ql/ql.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/plugins/testPlugin/testPlugin.cpp b/plugins/testPlugin/testPlugin.cpp index e18822fed..2c7726baa 100644 --- a/plugins/testPlugin/testPlugin.cpp +++ b/plugins/testPlugin/testPlugin.cpp @@ -5,25 +5,24 @@ // Include the definitions of the plugin functions // Not that this will also include ../PluginComponents.h -#include "../MumblePlugin_v_1_0_x.h" #include "../MumbleAPI_v_1_0_x.h" +#include "../MumblePlugin_v_1_0_x.h" -#include <iostream> #include <cstring> +#include <iostream> // These are just some utility functions facilitating writing logs and the like // The actual implementation of the plugin is further down -std::ostream& pLog() { +std::ostream &pLog() { std::cout << "TestPlugin: "; return std::cout; } -template<typename T> -void pluginLog(T log) { +template< typename T > void pluginLog(T log) { pLog() << log << std::endl; } -std::ostream& operator<<(std::ostream& stream, const mumble_version_t version) { +std::ostream &operator<<(std::ostream &stream, const mumble_version_t version) { stream << "v" << version.major << "." << version.minor << "." << version.patch; return stream; } @@ -99,9 +98,9 @@ void mumble_registerAPIFunctions(void *api) { // to interact with Mumble. Thus you should store it somewhere safe for later usage. // The pointer has to be cast to the respective API struct. You always have to cast to the same API version - // as this plugin itself is using. Thus if this plugin is compiled using the API version 1.0.x (where x is an arbitrary version) - // the pointer has to be cast to MumbleAPI_v_1_0_x (where x is a literal "x"). - // Furthermore the struct HAS TO BE COPIED!!! Storing the pointer is not an option as it will become invalid quickly! + // as this plugin itself is using. Thus if this plugin is compiled using the API version 1.0.x (where x is an + // arbitrary version) the pointer has to be cast to MumbleAPI_v_1_0_x (where x is a literal "x"). Furthermore the + // struct HAS TO BE COPIED!!! Storing the pointer is not an option as it will become invalid quickly! // **If** you are using the same API version that is specified in the included header file (as you should), you // can simply use the MUMBLE_API_CAST to cast the pointer to the correct type and automatically dereferencing it. @@ -134,11 +133,12 @@ void mumble_releaseResource(const void *pointer) { // The implementation of below functions is optional. If you don't need them, don't include them in your // plugin -void mumble_setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, mumble_version_t minimumExpectedAPIVersion) { +void mumble_setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, + mumble_version_t minimumExpectedAPIVersion) { // this function will always be the first one to be called. Even before init() // In here you can get info about the Mumble version this plugin is about to run in. - pLog() << "Mumble version: " << mumbleVersion << "; Mumble API-Version: " << mumbleAPIVersion << "; Minimal expected API-Version: " - << minimumExpectedAPIVersion << std::endl; + pLog() << "Mumble version: " << mumbleVersion << "; Mumble API-Version: " << mumbleAPIVersion + << "; Minimal expected API-Version: " << minimumExpectedAPIVersion << std::endl; } mumble_version_t mumble_getVersion() { @@ -160,8 +160,8 @@ MumbleStringWrapper mumble_getAuthor() { } MumbleStringWrapper mumble_getDescription() { - static const char *description = - "This plugin is merely a reference implementation without any real functionality. It shouldn't be included in the release build of Mumble."; + static const char *description = "This plugin is merely a reference implementation without any real functionality. " + "It shouldn't be included in the release build of Mumble."; MumbleStringWrapper wrapper; wrapper.data = description; @@ -186,8 +186,8 @@ uint32_t mumble_deactivateFeatures(uint32_t features) { return features; } -uint8_t mumble_initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount) { - std::ostream& stream = pLog() << "Got " << programCount << " programs to init positional data."; +uint8_t mumble_initPositionalData(const char *const *programNames, const uint64_t *programPIDs, size_t programCount) { + std::ostream &stream = pLog() << "Got " << programCount << " programs to init positional data."; if (programCount > 0) { stream << " The first name is " << programNames[0] << " and has PID " << programPIDs[0]; @@ -196,24 +196,28 @@ uint8_t mumble_initPositionalData(const char *const*programNames, const uint64_t stream << std::endl; // As this plugin doesn't provide PD, we return PDEC_ERROR_PERM to indicate that even in the future we won't do so - // If your plugin is indeed delivering positional data but is only temporarily unable to do so, return PDEC_ERROR_TEMP. - // and if you deliver PD and succeeded initializing return PDEC_OK. + // If your plugin is indeed delivering positional data but is only temporarily unable to do so, return + // PDEC_ERROR_TEMP. and if you deliver PD and succeeded initializing return PDEC_OK. return PDEC_ERROR_PERM; } -#define SET_TO_ZERO(name) name[0] = 0.0f; name[1] = 0.0f; name[2] = 0.0f -bool mumble_fetchPositionalData(float *avatarPos, float *avatarDir, float *avatarAxis, float *cameraPos, float *cameraDir, - float *cameraAxis, const char **context, const char **identity) { +#define SET_TO_ZERO(name) \ + name[0] = 0.0f; \ + name[1] = 0.0f; \ + name[2] = 0.0f +bool mumble_fetchPositionalData(float *avatarPos, float *avatarDir, float *avatarAxis, float *cameraPos, + float *cameraDir, float *cameraAxis, const char **context, const char **identity) { pluginLog("Has been asked to deliver positional data"); - // If unable to provide positional data, this function should return false and reset all given values to 0 / empty Strings + // If unable to provide positional data, this function should return false and reset all given values to 0 / empty + // Strings SET_TO_ZERO(avatarPos); SET_TO_ZERO(avatarDir); SET_TO_ZERO(avatarAxis); SET_TO_ZERO(cameraPos); SET_TO_ZERO(cameraDir); SET_TO_ZERO(cameraAxis); - *context = ""; + *context = ""; *identity = ""; // This function returns whether it can continue to deliver positional data @@ -239,7 +243,8 @@ void mumble_onServerDisconnected(mumble_connection_t connection) { const char *serverHash; if (mumAPI.getServerHash(ownID, connection, &serverHash) == STATUS_OK) { - pLog() << "Disconnected from server-connection with ID " << connection << "(hash: " << serverHash << ")" << std::endl; + pLog() << "Disconnected from server-connection with ID " << connection << "(hash: " << serverHash << ")" + << std::endl; mumAPI.freeMemory(ownID, serverHash); } else { @@ -251,7 +256,8 @@ void mumble_onServerSynchronized(mumble_connection_t connection) { // The client has finished synchronizing with the server. Thus we can now obtain a list of all users on this server const char *serverHash; if (mumAPI.getServerHash(ownID, connection, &serverHash) == STATUS_OK) { - pLog() << "Server has finished synchronizing (ServerConnection: " << connection << "; hash: " << serverHash << ")" << std::endl ; + pLog() << "Server has finished synchronizing (ServerConnection: " << connection << "; hash: " << serverHash + << ")" << std::endl; mumAPI.freeMemory(ownID, serverHash); } else { @@ -274,7 +280,7 @@ void mumble_onServerSynchronized(mumble_connection_t connection) { pLog() << "There are " << userCount << " users on this server. Their names are:" << std::endl; - for(size_t i=0; i<userCount; i++) { + for (size_t i = 0; i < userCount; i++) { const char *userName; if (mumAPI.getUserName(ownID, connection, userIDs[i], &userName) != STATUS_OK) { pLog() << "<Unable to fetch user name>" << std::endl; @@ -285,7 +291,7 @@ void mumble_onServerSynchronized(mumble_connection_t connection) { if (mumAPI.getUserHash(ownID, connection, userIDs[i], &userHash) != STATUS_OK) { pluginLog("<Unable to get user-hash>"); } - + pLog() << "\t" << userName << " (" << userHash << ")" << std::endl; // Mute the user "MuteMe" if this is not the name of the local user (in which case it'd fail) @@ -319,26 +325,32 @@ void mumble_onServerSynchronized(mumble_connection_t connection) { return; } - if (mumAPI.sendData(ownID, activeConnection, &localUser, 1, reinterpret_cast<const uint8_t *>("Just a test"), 12, "testMsg") == STATUS_OK) { + if (mumAPI.sendData(ownID, activeConnection, &localUser, 1, reinterpret_cast< const uint8_t * >("Just a test"), 12, + "testMsg") + == STATUS_OK) { pluginLog("Successfully sent plugin message"); // Try break the rate-limiter for plugin messages - for (int i = 0; i < 40; i++) { + for (int i = 0; i < 40; i++) { std::string data = "Rate-limit message #" + std::to_string(i); - mumAPI.sendData(ownID, activeConnection, &localUser, 1, reinterpret_cast<const uint8_t * >(data.c_str()), data.size(), "testMsg"); + mumAPI.sendData(ownID, activeConnection, &localUser, 1, reinterpret_cast< const uint8_t * >(data.c_str()), + data.size(), "testMsg"); } } else { pluginLog("Failed at sending message"); } - if (mumAPI.requestSetLocalUserComment(ownID, connection, "This user has the TestPlugin enabled - <b>hand over a cookie!</b>") != STATUS_OK) { + if (mumAPI.requestSetLocalUserComment(ownID, connection, + "This user has the TestPlugin enabled - <b>hand over a cookie!</b>") + != STATUS_OK) { pluginLog("Failed at setting the local user's comment"); } } -void mumble_onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t previousChannelID, mumble_channelid_t newChannelID) { - std::ostream& stream = pLog() << "User with ID " << userID << " entered channel with ID " << newChannelID << "."; +void mumble_onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t previousChannelID, mumble_channelid_t newChannelID) { + std::ostream &stream = pLog() << "User with ID " << userID << " entered channel with ID " << newChannelID << "."; // negative ID means that there was no previous channel (e.g. because the user just connected) if (previousChannelID >= 0) { @@ -349,14 +361,16 @@ void mumble_onChannelEntered(mumble_connection_t connection, mumble_userid_t use } void mumble_onChannelExited(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t channelID) { - pLog() << "User with ID " << userID << " has left channel with ID " << channelID << ". (ServerConnection: " << connection << ")" << std::endl; + pLog() << "User with ID " << userID << " has left channel with ID " << channelID + << ". (ServerConnection: " << connection << ")" << std::endl; } -void mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, mumble_talking_state_t talkingState) { - std::ostream& stream = pLog() << "User with ID " << userID << " changed his talking state to "; +void mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, + mumble_talking_state_t talkingState) { + std::ostream &stream = pLog() << "User with ID " << userID << " changed his talking state to "; // The possible values are contained in the TalkingState enum inside PluginComponent.h - switch(talkingState) { + switch (talkingState) { case INVALID: stream << "Invalid"; break; @@ -379,8 +393,10 @@ void mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_use stream << ". (ServerConnection: " << connection << ")" << std::endl; } -bool mumble_onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech) { - // pLog() << "Audio input with " << channelCount << " channels and " << sampleCount << " samples per channel encountered. IsSpeech: " +bool mumble_onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, + bool isSpeech) { + // pLog() << "Audio input with " << channelCount << " channels and " << sampleCount << " samples per channel + // encountered. IsSpeech: " // << isSpeech << " Sample rate is " << sampleRate << "Hz" << std::endl; // mark variables as unused @@ -394,9 +410,11 @@ bool mumble_onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channel return false; } -bool mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech, mumble_userid_t userID) { - std::ostream& stream = pLog() << "Audio output source with " << channelCount << " channels and " << sampleCount << " samples per channel " - << "(" << sampleRate << " Hz) fetched."; +bool mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, + bool isSpeech, mumble_userid_t userID) { + std::ostream &stream = pLog() << "Audio output source with " << channelCount << " channels and " << sampleCount + << " samples per channel " + << "(" << sampleRate << " Hz) fetched."; if (isSpeech) { stream << " The output is speech from user with ID " << userID << "."; @@ -411,9 +429,10 @@ bool mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_ return false; } -bool mumble_onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate) { - // pLog() << "The resulting audio output has " << channelCount << " channels with " << sampleCount << " samples per channel (" - // sampleRate << " Hz)" << std::endl; +bool mumble_onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, + uint32_t sampleRate) { + // pLog() << "The resulting audio output has " << channelCount << " channels with " << sampleCount << " samples per + // channel (" sampleRate << " Hz)" << std::endl; // mark variables as unused (void) outputPCM; @@ -425,13 +444,14 @@ bool mumble_onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uin return false; } -bool mumble_onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, size_t dataLength, const char *dataID) { - pLog() << "Received data with ID \"" << dataID << "\" from user with ID " << sender << ". Its length is " << dataLength - << ". (ServerConnection:" << connection << ")" << std::endl; +bool mumble_onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, + size_t dataLength, const char *dataID) { + pLog() << "Received data with ID \"" << dataID << "\" from user with ID " << sender << ". Its length is " + << dataLength << ". (ServerConnection:" << connection << ")" << std::endl; if (std::strcmp(dataID, "testMsg") == 0) { // We know that data is only a normal C-encoded String, so the reinterpret_cast is safe - pLog() << "The received data: " << reinterpret_cast<const char *>(data) << std::endl; + pLog() << "The received data: " << reinterpret_cast< const char * >(data) << std::endl; } // This function returns whether it has processed the data (preventing further plugins from seeing it) diff --git a/plugins/ut99/ut99.cpp b/plugins/ut99/ut99.cpp index 7ee98151a..e14531673 100644 --- a/plugins/ut99/ut99.cpp +++ b/plugins/ut99/ut99.cpp @@ -65,7 +65,7 @@ static void norm(float *a) { } static bool correctFront(float *front, float *top) { - float n[3] = {0}; + float n[3] = { 0 }; if (top[1] < 0) { front[0] *= -1; diff --git a/plugins/wow/wow.cpp b/plugins/wow/wow.cpp index e64fe9b89..b59695e5b 100644 --- a/plugins/wow/wow.cpp +++ b/plugins/wow/wow.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/plugins/wow_x64/wow_x64.cpp b/plugins/wow_x64/wow_x64.cpp index 50b04f6ad..2415c2909 100644 --- a/plugins/wow_x64/wow_x64.cpp +++ b/plugins/wow_x64/wow_x64.cpp @@ -6,7 +6,7 @@ #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../mumble_legacy_plugin.h" -#include "../mumble_positional_audio_main.h" // Include standard positional audio header. +#include "../mumble_positional_audio_main.h" // Include standard positional audio header. #include "../mumble_positional_audio_utils.h" // Include positional audio header for special functions, like "escape". static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, diff --git a/src/Channel.cpp b/src/Channel.cpp index 2462b2edb..077232f43 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -70,10 +70,12 @@ Channel *Channel::add(int id, const QString &name) { Channel *c = new Channel(id, name, nullptr); c_qhChannels.insert(id, c); - // We have to use a direct connection here in order to make sure that the user object that gets passed to the callback - // does not get invalidated or deleted while the callback is running. - QObject::connect(c, &Channel::channelEntered, Global::get().pluginManager, &PluginManager::on_channelEntered, Qt::DirectConnection); - QObject::connect(c, &Channel::channelExited, Global::get().pluginManager, &PluginManager::on_channelExited, Qt::DirectConnection); + // We have to use a direct connection here in order to make sure that the user object that gets passed to the + // callback does not get invalidated or deleted while the callback is running. + QObject::connect(c, &Channel::channelEntered, Global::get().pluginManager, &PluginManager::on_channelEntered, + Qt::DirectConnection); + QObject::connect(c, &Channel::channelExited, Global::get().pluginManager, &PluginManager::on_channelExited, + Qt::DirectConnection); return c; } diff --git a/src/Channel.h b/src/Channel.h index 95e6bf972..2d35f6f8a 100644 --- a/src/Channel.h +++ b/src/Channel.h @@ -100,19 +100,19 @@ public: operator QString() const; - signals: - /// Signal emitted whenever a user enters a channel. - /// - /// @param newChannel A pointer to the Channel the user has just entered - /// @param prevChannel A pointer to the Channel the user is coming from or nullptr if - /// there is no such channel. - /// @param user A pointer to the User that has triggered this signal - void channelEntered(const Channel *newChannel, const Channel *prevChannel, const User *user); - /// Signal emitted whenever a user leaves a channel. - /// - /// @param channel A pointer to the Channel the user has left - /// @param user A pointer to the User that has triggered this signal - void channelExited(const Channel *channel, const User *user); +signals: + /// Signal emitted whenever a user enters a channel. + /// + /// @param newChannel A pointer to the Channel the user has just entered + /// @param prevChannel A pointer to the Channel the user is coming from or nullptr if + /// there is no such channel. + /// @param user A pointer to the User that has triggered this signal + void channelEntered(const Channel *newChannel, const Channel *prevChannel, const User *user); + /// Signal emitted whenever a user leaves a channel. + /// + /// @param channel A pointer to the Channel the user has left + /// @param user A pointer to the User that has triggered this signal + void channelExited(const Channel *channel, const User *user); }; #endif diff --git a/src/ChannelListener.cpp b/src/ChannelListener.cpp index 1f0656d19..c6cc0d2a4 100644 --- a/src/ChannelListener.cpp +++ b/src/ChannelListener.cpp @@ -262,10 +262,11 @@ void ChannelListener::saveToDB() { } // Save the currently listened channels - Global::get().db->setChannelListeners(Global::get().sh->qbaDigest, ChannelListener::getListenedChannelsForUser(Global::get().uiSession)); + Global::get().db->setChannelListeners(Global::get().sh->qbaDigest, + ChannelListener::getListenedChannelsForUser(Global::get().uiSession)); // And also the currently set volume adjustments (if they're not set to 1.0) - Global::get().db->setChannelListenerLocalVolumeAdjustments(Global::get().sh->qbaDigest, - ChannelListener::getAllListenerLocalVolumeAdjustments(true)); + Global::get().db->setChannelListenerLocalVolumeAdjustments( + Global::get().sh->qbaDigest, ChannelListener::getAllListenerLocalVolumeAdjustments(true)); } #endif diff --git a/src/ProcessResolver.cpp b/src/ProcessResolver.cpp index 39011d4ba..80238ff49 100644 --- a/src/ProcessResolver.cpp +++ b/src/ProcessResolver.cpp @@ -6,9 +6,7 @@ #include "ProcessResolver.h" #include <cstring> -ProcessResolver::ProcessResolver(bool resolveImmediately) - : m_processNames(), - m_processPIDs() { +ProcessResolver::ProcessResolver(bool resolveImmediately) : m_processNames(), m_processPIDs() { if (resolveImmediately) { resolve(); } @@ -20,19 +18,17 @@ ProcessResolver::~ProcessResolver() { void ProcessResolver::freeAndClearData() { // delete all names - foreach(const char *currentName, m_processNames) { - delete currentName; - } + foreach (const char *currentName, m_processNames) { delete currentName; } m_processNames.clear(); m_processPIDs.clear(); } -const QVector<const char*>& ProcessResolver::getProcessNames() const { +const QVector< const char * > &ProcessResolver::getProcessNames() const { return m_processNames; } -const QVector<uint64_t>& ProcessResolver::getProcessPIDs() const { +const QVector< uint64_t > &ProcessResolver::getProcessPIDs() const { return m_processPIDs; } @@ -52,11 +48,11 @@ size_t ProcessResolver::amountOfProcesses() const { /// /// @param stackName The pointer to the stack-variable /// @param destVec The destination vector to add the pointer to -void addName(const char *stackName, QVector<const char*>& destVec) { +void addName(const char *stackName, QVector< const char * > &destVec) { // We can't store the pointer of a stack-variable (will be invalid as soon as we exit scope) // so we'll have to allocate memory on the heap and copy the name there. size_t nameLength = std::strlen(stackName) + 1; // +1 for terminating NULL-byte - char *name = new char[nameLength]; + char *name = new char[nameLength]; std::strcpy(name, stackName); @@ -64,244 +60,244 @@ void addName(const char *stackName, QVector<const char*>& destVec) { } // The implementation of the doResolve-function is platfrom-dependent -// The different implementations are heavily inspired by the ones given at https://github.com/davidebeatrici/list-processes +// The different implementations are heavily inspired by the ones given at +// https://github.com/davidebeatrici/list-processes #ifdef Q_OS_WIN - // Implementation for Windows - #ifndef UNICODE - #define UNICODE - #endif - - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - - #include <windows.h> - #include <tlhelp32.h> - #include <limits> - - bool utf16ToUtf8(const wchar_t *source, const int size, char *destination) { - if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, size, NULL, NULL)) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: WideCharToMultiByte() failed with error %d\n", GetLastError()); -#endif - return false; - } - - return true; +// Implementation for Windows +# ifndef UNICODE +# define UNICODE +# endif + +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif + +# include <windows.h> +# include <tlhelp32.h> +# include <limits> + +bool utf16ToUtf8(const wchar_t *source, const int size, char *destination) { + if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, size, NULL, NULL)) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: WideCharToMultiByte() failed with error %d\n", GetLastError()); +# endif + return false; } - void ProcessResolver::doResolve() { - HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hSnap == INVALID_HANDLE_VALUE) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: CreateToolhelp32Snapshot() failed with error %d", GetLastError()); -#endif - return; - } + return true; +} - PROCESSENTRY32 pe; - pe.dwSize = sizeof(pe); +void ProcessResolver::doResolve() { + HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (hSnap == INVALID_HANDLE_VALUE) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: CreateToolhelp32Snapshot() failed with error %d", GetLastError()); +# endif + return; + } - BOOL ok = Process32First(hSnap, &pe); - if (!ok) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: Process32First() failed with error %d\n", GetLastError()); -#endif - return; - } + PROCESSENTRY32 pe; + pe.dwSize = sizeof(pe); - char name[MAX_PATH]; + BOOL ok = Process32First(hSnap, &pe); + if (!ok) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: Process32First() failed with error %d\n", GetLastError()); +# endif + return; + } - while (ok) { - if (utf16ToUtf8(pe.szExeFile, sizeof(name), name)) { - // Store name - addName(name, m_processNames); + char name[MAX_PATH]; - // Store corresponding PID - m_processPIDs.append(pe.th32ProcessID); - } -#ifndef QT_NO_DEBUG - else { - qWarning("ProcessResolver: utf16ToUtf8() failed, skipping entry..."); - } -#endif + while (ok) { + if (utf16ToUtf8(pe.szExeFile, sizeof(name), name)) { + // Store name + addName(name, m_processNames); - ok = Process32Next(hSnap, &pe); + // Store corresponding PID + m_processPIDs.append(pe.th32ProcessID); + } +# ifndef QT_NO_DEBUG + else { + qWarning("ProcessResolver: utf16ToUtf8() failed, skipping entry..."); } +# endif - CloseHandle(hSnap); + ok = Process32Next(hSnap, &pe); } + + CloseHandle(hSnap); +} #elif defined(Q_OS_LINUX) - // Implementation for Linux - #include <QtCore/QFile> - #include <QtCore/QDir> - #include <QtCore/QStringList> - #include <QtCore/QFileInfo> - #include <QtCore/QByteArray> - #include <QtCore/QString> +// Implementation for Linux +# include <QtCore/QFile> +# include <QtCore/QDir> +# include <QtCore/QStringList> +# include <QtCore/QFileInfo> +# include <QtCore/QByteArray> +# include <QtCore/QString> - static constexpr const char *PROC_DIR = "/proc/"; +static constexpr const char *PROC_DIR = "/proc/"; - void ProcessResolver::doResolve() { - QDir procDir(QString::fromLatin1(PROC_DIR)); - QStringList entries = procDir.entryList(); +void ProcessResolver::doResolve() { + QDir procDir(QString::fromLatin1(PROC_DIR)); + QStringList entries = procDir.entryList(); - bool ok; + bool ok; - foreach(const QString& currentEntry, entries) { - uint64_t pid = static_cast<unsigned long long int>(currentEntry.toLongLong(&ok, 10)); + foreach (const QString ¤tEntry, entries) { + uint64_t pid = static_cast< unsigned long long int >(currentEntry.toLongLong(&ok, 10)); - if (!ok) { - continue; - } + if (!ok) { + continue; + } - QString exe = QFile::symLinkTarget(QString::fromLatin1(PROC_DIR) + currentEntry + QString::fromLatin1("/exe")); - QFileInfo fi(exe); - QString firstPart = fi.baseName(); - QString completeSuffix = fi.completeSuffix(); - QString baseName; - if (completeSuffix.isEmpty()) { - baseName = firstPart; - } else { - baseName = firstPart + QLatin1String(".") + completeSuffix; - } + QString exe = QFile::symLinkTarget(QString::fromLatin1(PROC_DIR) + currentEntry + QString::fromLatin1("/exe")); + QFileInfo fi(exe); + QString firstPart = fi.baseName(); + QString completeSuffix = fi.completeSuffix(); + QString baseName; + if (completeSuffix.isEmpty()) { + baseName = firstPart; + } else { + baseName = firstPart + QLatin1String(".") + completeSuffix; + } - if (baseName == QLatin1String("wine-preloader") || baseName == QLatin1String("wine64-preloader")) { - QFile f(QString::fromLatin1(PROC_DIR) + currentEntry + QString::fromLatin1("/cmdline")); - if (f.open(QIODevice::ReadOnly)) { - QByteArray cmdline = f.readAll(); - f.close(); + if (baseName == QLatin1String("wine-preloader") || baseName == QLatin1String("wine64-preloader")) { + QFile f(QString::fromLatin1(PROC_DIR) + currentEntry + QString::fromLatin1("/cmdline")); + if (f.open(QIODevice::ReadOnly)) { + QByteArray cmdline = f.readAll(); + f.close(); - int nul = cmdline.indexOf('\0'); - if (nul != -1) { - cmdline.truncate(nul); - } + int nul = cmdline.indexOf('\0'); + if (nul != -1) { + cmdline.truncate(nul); + } - QString exe = QString::fromUtf8(cmdline); - if (exe.contains(QLatin1String("\\"))) { - int lastBackslash = exe.lastIndexOf(QLatin1String("\\")); - if (exe.count() > lastBackslash + 1) { - baseName = exe.mid(lastBackslash + 1); - } + QString exe = QString::fromUtf8(cmdline); + if (exe.contains(QLatin1String("\\"))) { + int lastBackslash = exe.lastIndexOf(QLatin1String("\\")); + if (exe.count() > lastBackslash + 1) { + baseName = exe.mid(lastBackslash + 1); } } } + } - if (!baseName.isEmpty()) { - // add name - addName(baseName.toUtf8().data(), m_processNames); + if (!baseName.isEmpty()) { + // add name + addName(baseName.toUtf8().data(), m_processNames); - // add corresponding PID - m_processPIDs.append(pid); - } + // add corresponding PID + m_processPIDs.append(pid); } } +} #elif defined(Q_OS_MACOS) - // Implementation for MacOS - // Code taken from https://stackoverflow.com/questions/49506579/how-to-find-the-pid-of-any-process-in-mac-osx-c - #include <libproc.h> - - void ProcessResolver::doResolve() { - pid_t pids[2048]; - int bytes = proc_listpids(PROC_ALL_PIDS, 0, pids, sizeof(pids)); - int n_proc = bytes / sizeof(pids[0]); - for (int i = 0; i < n_proc; i++) { - struct proc_bsdinfo proc; - int st = proc_pidinfo(pids[i], PROC_PIDTBSDINFO, 0, - &proc, PROC_PIDTBSDINFO_SIZE); - if (st == PROC_PIDTBSDINFO_SIZE) { - // add name - addName(proc.pbi_name, m_processNames); - - // add corresponding PID - m_processPIDs.append(pids[i]); - } +// Implementation for MacOS +// Code taken from https://stackoverflow.com/questions/49506579/how-to-find-the-pid-of-any-process-in-mac-osx-c +# include <libproc.h> + +void ProcessResolver::doResolve() { + pid_t pids[2048]; + int bytes = proc_listpids(PROC_ALL_PIDS, 0, pids, sizeof(pids)); + int n_proc = bytes / sizeof(pids[0]); + for (int i = 0; i < n_proc; i++) { + struct proc_bsdinfo proc; + int st = proc_pidinfo(pids[i], PROC_PIDTBSDINFO, 0, &proc, PROC_PIDTBSDINFO_SIZE); + if (st == PROC_PIDTBSDINFO_SIZE) { + // add name + addName(proc.pbi_name, m_processNames); + + // add corresponding PID + m_processPIDs.append(pids[i]); } } +} #elif defined(Q_OS_FREEBSD) - // Implementation for FreeBSD - #include <libutil.h> - #include <sys/types.h> - #include <sys/user.h> - - void ProcessResolver::doResolve() { - int n_procs; - struct kinfo_proc *procs_info = kinfo_getallproc(&n_procs); - if (!procs_info) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: kinfo_getallproc() failed\n"); -#endif - return; - } - - for (int i = 0; i < n_procs; ++i) { - // Add name - addName(procs_info[i].ki_comm, m_processNames); +// Implementation for FreeBSD +# include <libutil.h> +# include <sys/types.h> +# include <sys/user.h> + +void ProcessResolver::doResolve() { + int n_procs; + struct kinfo_proc *procs_info = kinfo_getallproc(&n_procs); + if (!procs_info) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: kinfo_getallproc() failed\n"); +# endif + return; + } - // Add corresponding PID - m_processPIDs.append(procs_info[i].ki_pid); - } + for (int i = 0; i < n_procs; ++i) { + // Add name + addName(procs_info[i].ki_comm, m_processNames); - free(procs_info); + // Add corresponding PID + m_processPIDs.append(procs_info[i].ki_pid); } -#elif defined(Q_OS_BSD4) - // Implementation of generic BSD other than FreeBSD - #include <limits.h> - - #include <fcntl.h> - #include <kvm.h> - #include <paths.h> - #include <sys/sysctl.h> - #include <sys/user.h> - - bool kvm_cleanup(kvm_t *kd) { - if (kvm_close(kd) == -1) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: kvm_close() failed with error %d\n", errno); -#endif - return false; - } - return true; + free(procs_info); +} +#elif defined(Q_OS_BSD4) +// Implementation of generic BSD other than FreeBSD +# include <limits.h> + +# include <fcntl.h> +# include <kvm.h> +# include <paths.h> +# include <sys/sysctl.h> +# include <sys/user.h> + +bool kvm_cleanup(kvm_t *kd) { + if (kvm_close(kd) == -1) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: kvm_close() failed with error %d\n", errno); +# endif + return false; } - void ProcessResolver::doResolve() { - char error[_POSIX2_LINE_MAX]; -#ifdef KVM_NO_FILES - kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, error); -#else - kvm_t *kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, error); -#endif - - if (!kd) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: kvm_open2() failed with error: %s\n", error); -#endif - return; - } + return true; +} - int n_procs; - struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_procs); - if (!procs_info) { -#ifndef QT_NO_DEBUG - qCritical("ProcessResolver: kvm_getprocs() failed\n"); -#endif - kvm_cleanup(kd); +void ProcessResolver::doResolve() { + char error[_POSIX2_LINE_MAX]; +# ifdef KVM_NO_FILES + kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, error); +# else + kvm_t *kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, error); +# endif + + if (!kd) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: kvm_open2() failed with error: %s\n", error); +# endif + return; + } - return; - } + int n_procs; + struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_procs); + if (!procs_info) { +# ifndef QT_NO_DEBUG + qCritical("ProcessResolver: kvm_getprocs() failed\n"); +# endif + kvm_cleanup(kd); - for (int i = 0; i < n_procs; ++i) { - // Add name - addName(procs_info[i].ki_comm, m_processNames); + return; + } - // Add corresponding PIDs - m_processPIDs.append(procs_info[i].ki_pid); - } + for (int i = 0; i < n_procs; ++i) { + // Add name + addName(procs_info[i].ki_comm, m_processNames); - kvm_cleanup(kd); + // Add corresponding PIDs + m_processPIDs.append(procs_info[i].ki_pid); } + + kvm_cleanup(kd); +} #else - #error "No implementation of ProcessResolver::resolve() available for this operating system" +# error "No implementation of ProcessResolver::resolve() available for this operating system" #endif diff --git a/src/ProcessResolver.h b/src/ProcessResolver.h index 59ada3a1c..bdee041d9 100644 --- a/src/ProcessResolver.h +++ b/src/ProcessResolver.h @@ -6,35 +6,37 @@ #ifndef MUMBLE_PROCESS_RESOLVER_H_ #define MUMBLE_PROCESS_RESOLVER_H_ -#include <stdint.h> #include <QtCore/QVector> +#include <stdint.h> -/// This ProcessResolver can be used to get a QVector of running process names and associated PIDs on multiple platforms. -/// This object is by no means thread-safe! +/// This ProcessResolver can be used to get a QVector of running process names and associated PIDs on multiple +/// platforms. This object is by no means thread-safe! class ProcessResolver { - protected: - /// The vector for the pointers to the process names - QVector<const char*> m_processNames; - /// The vector for the process PIDs - QVector<uint64_t> m_processPIDs; +protected: + /// The vector for the pointers to the process names + QVector< const char * > m_processNames; + /// The vector for the process PIDs + QVector< uint64_t > m_processPIDs; + + /// Deletes all names currently stored in processNames and clears processNames and processPIDs + void freeAndClearData(); + /// The OS specific implementation of filling in details about running process names and PIDs + void doResolve(); - /// Deletes all names currently stored in processNames and clears processNames and processPIDs - void freeAndClearData(); - /// The OS specific implementation of filling in details about running process names and PIDs - void doResolve(); - public: - /// @param resolveImmediately Whether the constructor should directly invoke ProcesResolver::resolve() - ProcessResolver(bool resolveImmediately = true); - virtual ~ProcessResolver(); +public: + /// @param resolveImmediately Whether the constructor should directly invoke ProcesResolver::resolve() + ProcessResolver(bool resolveImmediately = true); + virtual ~ProcessResolver(); - /// Resolves the namaes and PIDs of the running processes - void resolve(); - /// Gets a reference to the stored process names - const QVector<const char*>& getProcessNames() const; - /// Gets a reference to the stored process PIDs (corresponding to the names returned by ProcessResolver::getProcessNames()) - const QVector<uint64_t>& getProcessPIDs() const; - /// @returns The amount of processes that have been resolved by this object - size_t amountOfProcesses() const; + /// Resolves the namaes and PIDs of the running processes + void resolve(); + /// Gets a reference to the stored process names + const QVector< const char * > &getProcessNames() const; + /// Gets a reference to the stored process PIDs (corresponding to the names returned by + /// ProcessResolver::getProcessNames()) + const QVector< uint64_t > &getProcessPIDs() const; + /// @returns The amount of processes that have been resolved by this object + size_t amountOfProcesses() const; }; #endif // MUMBLE_PROCESS_RESOLVER_H_ diff --git a/src/QtUtils.cpp b/src/QtUtils.cpp index 73d63c595..800974fbf 100644 --- a/src/QtUtils.cpp +++ b/src/QtUtils.cpp @@ -4,8 +4,8 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include <QObject> -#include <QUrl> #include <QStringList> +#include <QUrl> namespace Mumble { namespace QtUtils { diff --git a/src/mumble/ACLEditor.cpp b/src/mumble/ACLEditor.cpp index 616a7936b..d4bea977c 100644 --- a/src/mumble/ACLEditor.cpp +++ b/src/mumble/ACLEditor.cpp @@ -298,7 +298,8 @@ void ACLEditor::accept() { // Update channel state if (bAddChannelMode) { Global::get().sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(), - qsbChannelPosition->value(), qcbChannelTemporary->isChecked(), qsbChannelMaxUsers->value()); + qsbChannelPosition->value(), qcbChannelTemporary->isChecked(), + qsbChannelMaxUsers->value()); } else { bool needs_update = false; diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp index 2e64d5b8d..b2b2e28aa 100644 --- a/src/mumble/ALSAAudio.cpp +++ b/src/mumble/ALSAAudio.cpp @@ -212,8 +212,8 @@ ALSAEnumerator::ALSAEnumerator() { int err; snd_ctl_t *ctl = nullptr; if ((err = snd_card_get_longname(card, &name)) != 0) { - Global::get().mw->msgBox( - tr("Getting name (longname) of the sound card failed: %1").arg(QString::fromUtf8(snd_strerror(err)).toHtmlEscaped())); + Global::get().mw->msgBox(tr("Getting name (longname) of the sound card failed: %1") + .arg(QString::fromUtf8(snd_strerror(err)).toHtmlEscaped())); return; } QByteArray dev = QString::fromLatin1("hw:%1").arg(card).toUtf8(); @@ -223,8 +223,8 @@ ALSAEnumerator::ALSAEnumerator() { char *cname = nullptr; if ((err = snd_card_get_name(card, &cname)) != 0) { - Global::get().mw->msgBox( - tr("Getting name of the sound card failed: %1").arg(QString::fromUtf8(snd_strerror(err)).toHtmlEscaped())); + Global::get().mw->msgBox(tr("Getting name of the sound card failed: %1") + .arg(QString::fromUtf8(snd_strerror(err)).toHtmlEscaped())); return; } int device = -1; diff --git a/src/mumble/API_v_1_0_x.cpp b/src/mumble/API_v_1_0_x.cpp index ac8adf6f1..58a54314b 100644 --- a/src/mumble/API_v_1_0_x.cpp +++ b/src/mumble/API_v_1_0_x.cpp @@ -10,12 +10,12 @@ #include "Database.h" #include "Log.h" #include "MainWindow.h" +#include "MumbleConstants.h" #include "PluginComponents_v_1_0_x.h" #include "PluginManager.h" #include "ServerHandler.h" #include "Settings.h" #include "UserModel.h" -#include "MumbleConstants.h" #include "Global.h" #include <QVariant> @@ -35,22 +35,22 @@ } \ return; -#define VERIFY_PLUGIN_ID(id) \ +#define VERIFY_PLUGIN_ID(id) \ if (!Global::get().pluginManager->pluginExists(id)) { \ - EXIT_WITH(EC_INVALID_PLUGIN_ID); \ + EXIT_WITH(EC_INVALID_PLUGIN_ID); \ } // Right now there can only be one connection managed by the current ServerHandler -#define VERIFY_CONNECTION(connection) \ +#define VERIFY_CONNECTION(connection) \ if (!Global::get().sh || Global::get().sh->getConnectionID() != connection) { \ - EXIT_WITH(EC_CONNECTION_NOT_FOUND); \ + EXIT_WITH(EC_CONNECTION_NOT_FOUND); \ } -// Right now whether or not a connection has finished synchronizing is indicated by Global::get().uiSession. If it is zero, -// synchronization is not done yet (or there is no connection to begin with). The connection parameter in the macro is -// only present in case it will be needed in the future +// Right now whether or not a connection has finished synchronizing is indicated by Global::get().uiSession. If it is +// zero, synchronization is not done yet (or there is no connection to begin with). The connection parameter in the +// macro is only present in case it will be needed in the future #define ENSURE_CONNECTION_SYNCHRONIZED(connection) \ - if (Global::get().uiSession == 0) { \ + if (Global::get().uiSession == 0) { \ EXIT_WITH(EC_CONNECTION_UNSYNCHRONIZED); \ } @@ -67,7 +67,8 @@ MumbleAPICurator::~MumbleAPICurator() { entry.m_deleter(current.first); // Print an error about the leaked resource - printf("[ERROR]: Plugin with ID %d leaked memory from a call to API function \"%s\"\n", entry.m_pluginID, entry.m_sourceFunctionName); + printf("[ERROR]: Plugin with ID %d leaked memory from a call to API function \"%s\"\n", entry.m_pluginID, + entry.m_sourceFunctionName); } } // Some common delete-functions @@ -86,12 +87,12 @@ void defaultDeleter(const void *ptr) { // This macro registers type, type * and type ** to Qt's metatype system // and also their const variants (except const value as that doesn't make sense) -#define REGISTER_METATYPE(type) \ - qRegisterMetaType< type >(#type); \ - qRegisterMetaType< type * >(#type " *"); \ - qRegisterMetaType< type ** >(#type " **"); \ - qRegisterMetaType< const type * >("const " #type " *"); \ - qRegisterMetaType< const type ** >("const " #type " **"); \ +#define REGISTER_METATYPE(type) \ + qRegisterMetaType< type >(#type); \ + qRegisterMetaType< type * >(#type " *"); \ + qRegisterMetaType< type ** >(#type " **"); \ + qRegisterMetaType< const type * >("const " #type " *"); \ + qRegisterMetaType< const type ** >("const " #type " **"); MumbleAPI::MumbleAPI() { // Move this object to the main thread @@ -194,8 +195,8 @@ void MumbleAPI::isConnectionSynchronized_v_1_0_x(mumble_plugin_id_t callerID, mu VERIFY_PLUGIN_ID(callerID); VERIFY_CONNECTION(connection); - // Right now there can only be one connection and if Global::get().uiSession is zero, then the synchronization has not finished - // yet (or there is no connection to begin with) + // Right now there can only be one connection and if Global::get().uiSession is zero, then the synchronization has + // not finished yet (or there is no connection to begin with) *synchronized = Global::get().uiSession != 0; EXIT_WITH(STATUS_OK); diff --git a/src/mumble/ASIOInput.cpp b/src/mumble/ASIOInput.cpp index 1014fe6f9..11cc5c33a 100644 --- a/src/mumble/ASIOInput.cpp +++ b/src/mumble/ASIOInput.cpp @@ -43,8 +43,7 @@ const QList< audioDevice > ASIOAudioInputRegistrar::getDeviceChoices() { } bool ASIOAudioInputRegistrar::canEcho(EchoCancelOptionID echoOption, const QString &) const { - return (echoOption == EchoCancelOptionID::SPEEX_MIXED - || echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL); + return (echoOption == EchoCancelOptionID::SPEEX_MIXED || echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL); } void ASIOAudioInputRegistrar::setDeviceChoice(const QVariant &, Settings &) { diff --git a/src/mumble/About.cpp b/src/mumble/About.cpp index c086653f1..2abac5852 100644 --- a/src/mumble/About.cpp +++ b/src/mumble/About.cpp @@ -60,7 +60,7 @@ AboutDialog::AboutDialog(QWidget *p) : QDialog(p) { QString copyrightText; #ifdef MUMBLE_BUILD_YEAR copyrightText = "Copyright 2005-" QUOTE(MUMBLE_BUILD_YEAR) " The Mumble Developers"; -#else // MUMBLE_BUILD_YEAR +#else // MUMBLE_BUILD_YEAR copyrightText = "Copyright 2005-now The Mumble Developers"; #endif // MUMBLE_BUILD_YEAR diff --git a/src/mumble/Audio.cpp b/src/mumble/Audio.cpp index b2d61025d..ab78c762f 100644 --- a/src/mumble/Audio.cpp +++ b/src/mumble/Audio.cpp @@ -270,15 +270,16 @@ void Audio::stopInput() { void Audio::start(const QString &input, const QString &output) { startInput(input); startOutput(output); - + // Now that the audio input and output is created, we connect them to the PluginManager - // As these callbacks might want to change the audio before it gets further processed, all these connections have to be direct + // As these callbacks might want to change the audio before it gets further processed, all these connections have to + // be direct QObject::connect(Global::get().ai.get(), &AudioInput::audioInputEncountered, Global::get().pluginManager, - &PluginManager::on_audioInput, Qt::DirectConnection); + &PluginManager::on_audioInput, Qt::DirectConnection); QObject::connect(Global::get().ao.get(), &AudioOutput::audioSourceFetched, Global::get().pluginManager, - &PluginManager::on_audioSourceFetched, Qt::DirectConnection); + &PluginManager::on_audioSourceFetched, Qt::DirectConnection); QObject::connect(Global::get().ao.get(), &AudioOutput::audioOutputAboutToPlay, Global::get().pluginManager, - &PluginManager::on_audioOutputAboutToPlay, Qt::DirectConnection); + &PluginManager::on_audioOutputAboutToPlay, Qt::DirectConnection); } void Audio::stop() { diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp index c9b65a4e0..bed102293 100644 --- a/src/mumble/AudioConfigDialog.cpp +++ b/src/mumble/AudioConfigDialog.cpp @@ -245,13 +245,14 @@ void AudioInputDialog::verifyMicrophonePermission() { qcbDevice->setEnabled(false); if (air->name == QLatin1String("CoreAudio")) { qlInputHelp->setVisible(true); - qlInputHelp->setText(tr("Access to the microphone was denied. Please allow Mumble to use the microphone " - "by changing the settings in System Preferences -> Security & Privacy -> Privacy -> " - "Microphone.")); + qlInputHelp->setText( + tr("Access to the microphone was denied. Please allow Mumble to use the microphone " + "by changing the settings in System Preferences -> Security & Privacy -> Privacy -> " + "Microphone.")); } else if (air->name == QLatin1String("WASAPI")) { qlInputHelp->setVisible(true); - qlInputHelp->setText( tr("Access to the microphone was denied. Please check that your operating system's " - "microphone settings allow Mumble to use the microphone.")); + qlInputHelp->setText(tr("Access to the microphone was denied. Please check that your operating system's " + "microphone settings allow Mumble to use the microphone.")); } } else { qcbDevice->setEnabled(true); @@ -297,7 +298,7 @@ void AudioInputDialog::save() const { s.qsTxAudioCueOff = qlePushClickPathOff->text(); s.qsAudioInput = qcbSystem->currentText(); - s.echoOption = static_cast<EchoCancelOptionID>(qcbEcho->currentData().toInt()); + s.echoOption = static_cast< EchoCancelOptionID >(qcbEcho->currentData().toInt()); s.bExclusiveInput = qcbExclusive->isChecked(); if (AudioInputRegistrar::qmNew) { @@ -519,9 +520,9 @@ void AudioInputDialog::updateEchoEnableState() { for (EchoCancelOptionID ecoid : air->echoOptions) { if (air->canEcho(ecoid, outputInterface)) { ++i; - hasUsableEchoOption = true; - const EchoCancelOption &echoOption = echoCancelOptions[static_cast<int>(ecoid)]; - qcbEcho->insertItem(i, echoOption.description, static_cast<int>(ecoid)); + hasUsableEchoOption = true; + const EchoCancelOption &echoOption = echoCancelOptions[static_cast< int >(ecoid)]; + qcbEcho->insertItem(i, echoOption.description, static_cast< int >(ecoid)); qcbEcho->setItemData(i, echoOption.explanation, Qt::ToolTipRole); if (s.echoOption == ecoid) { qcbEcho->setCurrentIndex(i); @@ -535,9 +536,9 @@ void AudioInputDialog::updateEchoEnableState() { qcbEcho->setCurrentIndex(0); qcbEcho->setEnabled(false); qcbEcho->setToolTip(QObject::tr("Echo cancellation is not supported for the interface " - "combination \"%1\" (in) and \"%2\" (out).") - .arg(air->name) - .arg(outputInterface)); + "combination \"%1\" (in) and \"%2\" (out).") + .arg(air->name) + .arg(outputInterface)); } } diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index cf1ca3820..0ac244a40 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -10,18 +10,16 @@ #ifdef USE_OPUS # include "OpusCodec.h" #endif +#include "API.h" #include "MainWindow.h" -#include "User.h" -#include "PacketDataStream.h" -#include "PluginManager.h" #include "Message.h" #include "NetworkConfig.h" #include "PacketDataStream.h" +#include "PluginManager.h" #include "ServerHandler.h" #include "User.h" #include "Utils.h" #include "VoiceRecorder.h" -#include "API.h" #include "Global.h" @@ -177,7 +175,7 @@ AudioInputPtr AudioInputRegistrar::newFromChoice(QString choice) { if (!choice.isEmpty() && qmNew->contains(choice)) { Global::get().s.qsAudioInput = choice; - current = choice; + current = choice; return AudioInputPtr(qmNew->value(current)->create()); } choice = Global::get().s.qsAudioInput; @@ -711,19 +709,20 @@ void AudioInput::setMaxBandwidth(int bitspersec) { if (bitspersec != -1) { if ((bitrate != Global::get().s.iQuality) || (frames != Global::get().s.iFramesPerPacket)) - Global::get().mw->msgBox(tr("Server maximum network bandwidth is only %1 kbit/s. Audio quality auto-adjusted to %2 " - "kbit/s (%3 ms)") - .arg(bitspersec / 1000) - .arg(bitrate / 1000) - .arg(frames * 10)); + Global::get().mw->msgBox( + tr("Server maximum network bandwidth is only %1 kbit/s. Audio quality auto-adjusted to %2 " + "kbit/s (%3 ms)") + .arg(bitspersec / 1000) + .arg(bitrate / 1000) + .arg(frames * 10)); } AudioInputPtr ai = Global::get().ai; if (ai) { - Global::get().iAudioBandwidth = getNetworkBandwidth(bitrate, frames); - ai->iAudioQuality = bitrate; - ai->iAudioFrames = frames; - ai->bAllowLowDelay = allowLowDelay; + Global::get().iAudioBandwidth = getNetworkBandwidth(bitrate, frames); + ai->iAudioQuality = bitrate; + ai->iAudioFrames = frames; + ai->bAllowLowDelay = allowLowDelay; return; } @@ -734,8 +733,8 @@ void AudioInput::setMaxBandwidth(int bitspersec) { } int AudioInput::getNetworkBandwidth(int bitrate, int frames) { - int overhead = - 20 + 8 + 4 + 1 + 2 + (Global::get().s.bTransmitPosition ? 12 : 0) + (NetworkConfig::TcpModeEnabled() ? 12 : 0) + frames; + int overhead = 20 + 8 + 4 + 1 + 2 + (Global::get().s.bTransmitPosition ? 12 : 0) + + (NetworkConfig::TcpModeEnabled() ? 12 : 0) + frames; overhead *= (800 / frames); int bw = overhead + bitrate; @@ -810,7 +809,8 @@ bool AudioInput::selectCodec() { if (!useOpus) { CELTCodec *switchto = nullptr; - if ((!Global::get().uiSession || (Global::get().s.lmLoopMode == Settings::Local)) && (!Global::get().qmCodecs.isEmpty())) { + if ((!Global::get().uiSession || (Global::get().s.lmLoopMode == Settings::Local)) + && (!Global::get().qmCodecs.isEmpty())) { // Use latest for local loopback QMap< int, CELTCodec * >::const_iterator i = Global::get().qmCodecs.constEnd(); --i; @@ -824,9 +824,11 @@ bool AudioInput::selectCodec() { } } if (!switchto) { - switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecAlpha : Global::get().iCodecBeta); + switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecAlpha + : Global::get().iCodecBeta); if (!switchto) - switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecBeta : Global::get().iCodecAlpha); + switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecBeta + : Global::get().iCodecAlpha); } if (switchto != cCodec) { if (cCodec && ceEncoder) { @@ -1062,13 +1064,15 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) { iHoldFrames = 0; } - if (Global::get().s.atTransmit == Settings::Continuous || API::PluginData::get().overwriteMicrophoneActivation.load()) { + if (Global::get().s.atTransmit == Settings::Continuous + || API::PluginData::get().overwriteMicrophoneActivation.load()) { // Continous transmission is enabled bIsSpeech = true; } else if (Global::get().s.atTransmit == Settings::PushToTalk) { // PTT is enabled, so check if it is currently active - bIsSpeech = - Global::get().s.uiDoublePush && ((Global::get().uiDoublePush < Global::get().s.uiDoublePush) || (Global::get().tDoublePush.elapsed() < Global::get().s.uiDoublePush)); + bIsSpeech = Global::get().s.uiDoublePush + && ((Global::get().uiDoublePush < Global::get().s.uiDoublePush) + || (Global::get().tDoublePush.elapsed() < Global::get().s.uiDoublePush)); } // If Global::get().iPushToTalk > 0 that means that we are currently in some sort of PTT action. For @@ -1076,8 +1080,8 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) { bIsSpeech = bIsSpeech || (Global::get().iPushToTalk > 0); ClientUser *p = ClientUser::get(Global::get().uiSession); - if (Global::get().s.bMute || ((Global::get().s.lmLoopMode != Settings::Local) && p && (p->bMute || p->bSuppress)) || Global::get().bPushToMute - || (voiceTargetID < 0)) { + if (Global::get().s.bMute || ((Global::get().s.lmLoopMode != Settings::Local) && p && (p->bMute || p->bSuppress)) + || Global::get().bPushToMute || (voiceTargetID < 0)) { bIsSpeech = false; } @@ -1148,7 +1152,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) { Q_ASSERT(buffer.size() >= static_cast< size_t >(iAudioQuality / 100 * iAudioFrames / 8)); emit audioInputEncountered(psSource, iFrameSize, iMicChannels, SAMPLE_RATE, bIsSpeech); - + int len = 0; bool encoded = true; @@ -1281,7 +1285,7 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT } if (Global::get().s.bTransmitPosition && Global::get().pluginManager && !Global::get().bCenterPosition - && Global::get().pluginManager->fetchPositionalData()) { + && Global::get().pluginManager->fetchPositionalData()) { Position3D currentPos = Global::get().pluginManager->getPositionalData().getPlayerPos(); pds << currentPos.x; diff --git a/src/mumble/AudioInput.h b/src/mumble/AudioInput.h index 0410db421..d69c28f84 100644 --- a/src/mumble/AudioInput.h +++ b/src/mumble/AudioInput.h @@ -261,7 +261,8 @@ signals: /// @param channelCount The amount of channels in the input /// @param sampleRate The used sample rate in Hz /// @param isSpeech Whether Mumble considers the inpu to be speech - void audioInputEncountered(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech); + void audioInputEncountered(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool isSpeech); public: typedef enum { ActivityStateIdle, ActivityStateReturnedFromIdle, ActivityStateActive } ActivityState; diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index 784a29245..3216ee286 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -47,7 +47,7 @@ AudioOutputPtr AudioOutputRegistrar::newFromChoice(QString choice) { if (!choice.isEmpty() && qmNew->contains(choice)) { Global::get().s.qsAudioOutput = choice; - current = choice; + current = choice; return AudioOutputPtr(qmNew->value(choice)->create()); } choice = Global::get().s.qsAudioOutput; @@ -116,8 +116,9 @@ float AudioOutput::calcGain(float dotproduct, float distance) { if (mvol < 0.01f) mvol = 0.01f; - float drel = (distance - Global::get().s.fAudioMinDistance) / (Global::get().s.fAudioMaxDistance - Global::get().s.fAudioMinDistance); - datt = powf(10.0f, log10f(mvol) * drel); + float drel = (distance - Global::get().s.fAudioMinDistance) + / (Global::get().s.fAudioMaxDistance - Global::get().s.fAudioMinDistance); + datt = powf(10.0f, log10f(mvol) * drel); } att = datt * dotfactor; @@ -395,13 +396,13 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { prioritySpeakerActive = true; } - // If the audio backend uses a float-array we can sample and mix the audio sources directly into the output. Otherwise we'll have to - // use an intermediate buffer which we will convert to an array of shorts later - STACKVAR(float, fOutput, iChannels * frameCount); - float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast<float *>(outbuff) : fOutput; + // If the audio backend uses a float-array we can sample and mix the audio sources directly into the output. + // Otherwise we'll have to use an intermediate buffer which we will convert to an array of shorts later + STACKVAR(float, fOutput, iChannels *frameCount); + float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast< float * >(outbuff) : fOutput; memset(output, 0, sizeof(float) * frameCount * iChannels); - if (! qlMix.isEmpty()) { + if (!qlMix.isEmpty()) { // There are audio sources available -> mix those sources together and feed them into the audio backend STACKVAR(float, speaker, iChannels * 3); STACKVAR(float, svol, iChannels); @@ -497,7 +498,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { AudioOutputSpeech *speech = qobject_cast< AudioOutputSpeech * >(aop); const ClientUser *user = nullptr; if (speech) { - user = speech->p; + user = speech->p; volumeAdjustment *= user->getLocalVolumeAdjustments(); if (user->cChannel && ChannelListener::isListening(Global::get().uiSession, user->cChannel->iId) @@ -639,7 +640,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { bool pluginModifiedAudio = false; emit audioOutputAboutToPlay(output, frameCount, nchan, SAMPLE_RATE, &pluginModifiedAudio); - if (pluginModifiedAudio || (! qlMix.isEmpty())) { + if (pluginModifiedAudio || (!qlMix.isEmpty())) { // Clip the output audio if (eSampleFormat == SampleFloat) for (unsigned int i = 0; i < frameCount * iChannels; i++) @@ -662,7 +663,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { #endif // Return whether data has been written to the outbuff - return (pluginModifiedAudio || (! qlMix.isEmpty())); + return (pluginModifiedAudio || (!qlMix.isEmpty())); } bool AudioOutput::isAlive() const { diff --git a/src/mumble/AudioOutput.h b/src/mumble/AudioOutput.h index 3d5c5b6da..b36b87e2c 100644 --- a/src/mumble/AudioOutput.h +++ b/src/mumble/AudioOutput.h @@ -137,7 +137,8 @@ signals: /// @param sampleRate The used sample rate in Hz /// @param isSpeech Whether the fetched output is considered to be speech /// @param A pointer to the user that this speech belongs to or nullptr if this isn't speech - void audioSourceFetched(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech, const ClientUser *user); + void audioSourceFetched(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool isSpeech, const ClientUser *user); /// Signal emitted whenever an audio is about to be played to the user /// /// @param outputPCM The output PCM that is to be played @@ -145,7 +146,8 @@ signals: /// @param channelCount The amount of channels in the output /// @param sampleRate The used sample rate in Hz /// @param modifiedAudio Pointer to bool if audio has been modified or not and should be played - void audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool *modifiedAudio); + void audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool *modifiedAudio); }; #endif diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp index ee7426a1e..2903f57ad 100644 --- a/src/mumble/AudioOutputSpeech.cpp +++ b/src/mumble/AudioOutputSpeech.cpp @@ -335,7 +335,8 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) { QByteArray qba = qlFrames.takeFirst(); if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) { - int wantversion = (umtType == MessageHandler::UDPVoiceCELTAlpha) ? Global::get().iCodecAlpha : Global::get().iCodecBeta; + int wantversion = (umtType == MessageHandler::UDPVoiceCELTAlpha) ? Global::get().iCodecAlpha + : Global::get().iCodecBeta; if ((p == &LoopUser::lpLoopy) && (!Global::get().qmCodecs.isEmpty())) { QMap< int, CELTCodec * >::const_iterator i = Global::get().qmCodecs.constEnd(); --i; diff --git a/src/mumble/AudioWizard.cpp b/src/mumble/AudioWizard.cpp index 885858b0a..494960ea7 100644 --- a/src/mumble/AudioWizard.cpp +++ b/src/mumble/AudioWizard.cpp @@ -10,9 +10,9 @@ #include "Log.h" #include "MainWindow.h" #include "Utils.h" +#include "Global.h" #include "GlobalShortcut.h" #include "GlobalShortcutButtons.h" -#include "Global.h" #include <QtGui/QMouseEvent> #include <QtWidgets/QGraphicsEllipseItem> @@ -20,8 +20,8 @@ #include <cmath> AudioWizard::AudioWizard(QWidget *p) : QWizard(p) { - bInit = true; - bLastActive = false; + bInit = true; + bLastActive = false; Global::get().bInAudioWizard = true; ticker = new QTimer(this); @@ -170,7 +170,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) { resize(700, 500); updateTriggerWidgets(qrPTT->isChecked()); - sOldSettings = Global::get().s; + sOldSettings = Global::get().s; Global::get().s.lmLoopMode = Settings::Local; Global::get().s.dPacketLoss = 0.0; Global::get().s.dMaxPacketDelay = 0.0; @@ -318,7 +318,7 @@ void AudioWizard::showPage(int pageid) { Global::get().s.bMute = true; playChord(); } else if (cp == qwpPositional) { - fX = fY = 0.0f; + fX = fY = 0.0f; Global::get().s.bMute = true; Global::get().bPosTest = true; if (qgsScene) { @@ -390,7 +390,7 @@ void AudioWizard::reject() { AudioOutputPtr ao = Global::get().ao; if (ao) ao->wipe(); - aosSource = nullptr; + aosSource = nullptr; Global::get().bInAudioWizard = false; QWizard::reject(); @@ -646,15 +646,15 @@ void AudioWizard::on_qpbPTT_clicked() { shortcuts << shortcut; } - Global::get().s.qlShortcuts = shortcuts; + Global::get().s.qlShortcuts = shortcuts; GlobalShortcutEngine::engine->bNeedRemap = true; GlobalShortcutEngine::engine->needRemap(); } void AudioWizard::on_qcbEcho_clicked(bool on) { if (on) { - AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText()); - Global::get().s.echoOption = firstUsableEchoCancellation(air, qcbOutput->currentText()); + AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText()); + Global::get().s.echoOption = firstUsableEchoCancellation(air, qcbOutput->currentText()); } else { Global::get().s.echoOption = EchoCancelOptionID::DISABLED; } diff --git a/src/mumble/ClientUser.cpp b/src/mumble/ClientUser.cpp index 8a66cf496..dea92fe92 100644 --- a/src/mumble/ClientUser.cpp +++ b/src/mumble/ClientUser.cpp @@ -63,7 +63,8 @@ ClientUser *ClientUser::add(unsigned int uiSession, QObject *po) { p->uiSession = uiSession; c_qmUsers[uiSession] = p; - QObject::connect(p, &ClientUser::talkingStateChanged, Global::get().pluginManager, &PluginManager::on_userTalkingStateChanged); + QObject::connect(p, &ClientUser::talkingStateChanged, Global::get().pluginManager, + &PluginManager::on_userTalkingStateChanged); return p; } diff --git a/src/mumble/ConfigDialog.cpp b/src/mumble/ConfigDialog.cpp index 8649ec307..5abf4035f 100644 --- a/src/mumble/ConfigDialog.cpp +++ b/src/mumble/ConfigDialog.cpp @@ -13,8 +13,8 @@ #include <QtCore/QMutexLocker> #include <QtGui/QScreen> #include <QtWidgets/QDesktopWidget> -#include <QtWidgets/QPushButton> #include <QtWidgets/QMessageBox> +#include <QtWidgets/QPushButton> // init static member fields @@ -74,8 +74,7 @@ ConfigDialog::ConfigDialog(QWidget *p) : QDialog(p) { "changed.<br />" "To restore all settings to their defaults, you can press the \"Defaults (All)\" button.")); - QPushButton *restoreAllButton = - pageButtonBox->addButton(tr("Defaults (All)"), QDialogButtonBox::ResetRole); + QPushButton *restoreAllButton = pageButtonBox->addButton(tr("Defaults (All)"), QDialogButtonBox::ResetRole); restoreAllButton->setToolTip(tr("Restore all defaults")); restoreAllButton->setWhatsThis(tr("This button will restore the defaults for all settings.")); @@ -162,15 +161,14 @@ void ConfigDialog::on_pageButtonBox_clicked(QAbstractButton *b) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); msgBox.setText(QObject::tr("Reset all settings?")); - msgBox.setInformativeText(QObject::tr("Do you really want to reset all settings (not only the ones currently visible) to their default value?")); + msgBox.setInformativeText(QObject::tr("Do you really want to reset all settings (not only the ones " + "currently visible) to their default value?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); if (msgBox.exec() == QMessageBox::Yes) { Settings defaultSetting; - foreach (ConfigWidget *cw, qmWidgets) { - cw->load(defaultSetting); - } + foreach (ConfigWidget *cw, qmWidgets) { cw->load(defaultSetting); } } break; } diff --git a/src/mumble/ConnectDialog.cpp b/src/mumble/ConnectDialog.cpp index 279c3b7b3..536e5c0ce 100644 --- a/src/mumble/ConnectDialog.cpp +++ b/src/mumble/ConnectDialog.cpp @@ -406,10 +406,10 @@ ServerItem *ServerItem::fromUrl(QUrl url, QWidget *p) { if (url.userName().isEmpty()) { if (Global::get().s.qsUsername.isEmpty()) { bool ok; - QString defUserName = - QInputDialog::getText(p, ConnectDialog::tr("Adding host %1").arg(url.host()), - ConnectDialog::tr("Enter username"), QLineEdit::Normal, Global::get().s.qsUsername, &ok) - .trimmed(); + QString defUserName = QInputDialog::getText(p, ConnectDialog::tr("Adding host %1").arg(url.host()), + ConnectDialog::tr("Enter username"), QLineEdit::Normal, + Global::get().s.qsUsername, &ok) + .trimmed(); if (!ok) return nullptr; if (defUserName.isEmpty()) diff --git a/src/mumble/CrashReporter.cpp b/src/mumble/CrashReporter.cpp index 73e85d789..c12cbf28e 100644 --- a/src/mumble/CrashReporter.cpp +++ b/src/mumble/CrashReporter.cpp @@ -93,8 +93,9 @@ void CrashReporter::uploadFinished() { } } else { QMessageBox::critical(nullptr, tr("Crash upload failed"), - tr("Internal error encountered in CrashReporter.cpp: Received network reply does not contain an HTTP status code." - " Please inform a developer about error code %1") + tr("Internal error encountered in CrashReporter.cpp: Received network reply does not " + "contain an HTTP status code." + " Please inform a developer about error code %1") .arg(qnrReply->error())); } diff --git a/src/mumble/CustomElements.cpp b/src/mumble/CustomElements.cpp index 9e51ae37e..caed34c53 100644 --- a/src/mumble/CustomElements.cpp +++ b/src/mumble/CustomElements.cpp @@ -181,7 +181,7 @@ bool ChatbarTextEdit::sendImagesFromMimeData(const QMimeData *source) { if (Global::get().bAllowHTML) { if (source->hasImage()) { // Process the image pasted onto the chatbar. - QImage image = qvariant_cast<QImage>(source->imageData()); + QImage image = qvariant_cast< QImage >(source->imageData()); if (emitPastedImage(image)) { return true; } else { @@ -191,7 +191,7 @@ bool ChatbarTextEdit::sendImagesFromMimeData(const QMimeData *source) { } else if (source->hasUrls()) { // Process the files dropped onto the chatbar. URLs here should be understood as the URIs of files. - QList<QUrl> urlList = source->urls(); + QList< QUrl > urlList = source->urls(); int count = 0; for (int i = 0; i < urlList.size(); ++i) { @@ -256,7 +256,8 @@ bool ChatbarTextEdit::event(QEvent *evt) { } else if (kev->key() == Qt::Key_Down && kev->modifiers() == Qt::ControlModifier) { historyDown(); return true; - } else if (kev->key() == Qt::Key_V && (kev->modifiers() & Qt::ControlModifier) && (kev->modifiers() & Qt::ShiftModifier)) { + } else if (kev->key() == Qt::Key_V && (kev->modifiers() & Qt::ControlModifier) + && (kev->modifiers() & Qt::ShiftModifier)) { pasteAndSend_triggered(); return true; } diff --git a/src/mumble/Database.cpp b/src/mumble/Database.cpp index 7f76fc917..7e21c5be9 100644 --- a/src/mumble/Database.cpp +++ b/src/mumble/Database.cpp @@ -209,7 +209,8 @@ Database::Database(const QString &dbname) { execQueryAndLogFailure(query, QLatin1String("CREATE UNIQUE INDEX IF NOT EXISTS `volume_hash` ON `volume`(`hash`)")); execQueryAndLogFailure(query, QLatin1String("CREATE TABLE IF NOT EXISTS `nicknames` (`id` INTEGER PRIMARY KEY " "AUTOINCREMENT, `hash` TEXT, `nickname` TEXT)")); - execQueryAndLogFailure(query, QLatin1String("CREATE UNIQUE INDEX IF NOT EXISTS `nicknames_hash` ON `nicknames`(`hash`)")); + execQueryAndLogFailure(query, + QLatin1String("CREATE UNIQUE INDEX IF NOT EXISTS `nicknames_hash` ON `nicknames`(`hash`)")); // Note: A previous snapshot version created a table called 'hidden' execQueryAndLogFailure( diff --git a/src/mumble/Database.h b/src/mumble/Database.h index 7de543405..5210d670e 100644 --- a/src/mumble/Database.h +++ b/src/mumble/Database.h @@ -53,7 +53,7 @@ public: QString getUserLocalNickname(const QString &hash); void setUserLocalNickname(const QString &hash, const QString &nickname); - + bool isChannelFiltered(const QByteArray &server_cert_digest, const int channel_id); void setChannelFiltered(const QByteArray &server_cert_digest, const int channel_id, bool hidden); diff --git a/src/mumble/EchoCancelOption.h b/src/mumble/EchoCancelOption.h index 8cb63cfc7..f556b0e70 100644 --- a/src/mumble/EchoCancelOption.h +++ b/src/mumble/EchoCancelOption.h @@ -13,10 +13,10 @@ /// Each audio backend will determine which option is indeed available to that backend and /// to the specific device combination enum class EchoCancelOptionID { - DISABLED = 0, - SPEEX_MIXED = 1, - SPEEX_MULTICHANNEL = 2, - APPLE_AEC = 3 // Apple's Acoustic Echo Cancellation support for macOS and iOS. + DISABLED = 0, + SPEEX_MIXED = 1, + SPEEX_MULTICHANNEL = 2, + APPLE_AEC = 3 // Apple's Acoustic Echo Cancellation support for macOS and iOS. }; struct EchoCancelOption { @@ -27,23 +27,19 @@ struct EchoCancelOption { // Please strictly follow the order of the EchoCancelOptionID when adding items to this array. static const EchoCancelOption echoCancelOptions[] = { - { EchoCancelOptionID::DISABLED, - QObject::tr("Disabled"), - QObject::tr("Echo cancellation is disabled.") }, - { EchoCancelOptionID::SPEEX_MIXED, - QObject::tr("Mixed echo cancellation (speex)"), + { EchoCancelOptionID::DISABLED, QObject::tr("Disabled"), QObject::tr("Echo cancellation is disabled.") }, + { EchoCancelOptionID::SPEEX_MIXED, QObject::tr("Mixed echo cancellation (speex)"), QObject::tr("Mixed has low CPU impact, but only works well if your " - "speakers are equally loud and equidistant from the microphone.") }, - { EchoCancelOptionID::SPEEX_MULTICHANNEL, - QObject::tr("Multichannel echo cancellation (speex)"), + "speakers are equally loud and equidistant from the microphone.") }, + { EchoCancelOptionID::SPEEX_MULTICHANNEL, QObject::tr("Multichannel echo cancellation (speex)"), QObject::tr("Multichannel echo cancellation provides much better echo " - "cancellation, but at a higher CPU cost. " - "Multichannel echo cancellation requires more CPU, so " - "you should try mixed first.") }, + "cancellation, but at a higher CPU cost. " + "Multichannel echo cancellation requires more CPU, so " + "you should try mixed first.") }, // Available only on Apple devices - { EchoCancelOptionID::APPLE_AEC, - QObject::tr("EXPERIMENTAL: Acoustic echo cancellation (Apple)."), - QObject::tr("The support for this option is experimental only! This option works best when using built-in microphone and speaker.") } + { EchoCancelOptionID::APPLE_AEC, QObject::tr("EXPERIMENTAL: Acoustic echo cancellation (Apple)."), + QObject::tr("The support for this option is experimental only! This option works best when using built-in " + "microphone and speaker.") } }; #endif // MUMBLE_ECHOCANCELLATIONOPTION_H diff --git a/src/mumble/GlobalShortcut.cpp b/src/mumble/GlobalShortcut.cpp index 720a61a01..338be677e 100644 --- a/src/mumble/GlobalShortcut.cpp +++ b/src/mumble/GlobalShortcut.cpp @@ -10,8 +10,8 @@ #include "ClientUser.h" #include "Database.h" #include "MainWindow.h" -#include "GlobalShortcutButtons.h" #include "Global.h" +#include "GlobalShortcutButtons.h" #include <QtCore/QProcess> #include <QtCore/QSortFilterProxyModel> diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp index 20bed0ddc..f061ed046 100644 --- a/src/mumble/GlobalShortcut_win.cpp +++ b/src/mumble/GlobalShortcut_win.cpp @@ -131,7 +131,7 @@ GlobalShortcutWin::~GlobalShortcutWin() { void GlobalShortcutWin::run() { if (HAS_FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, - reinterpret_cast< void ** >(&pDI), nullptr))) { + reinterpret_cast< void ** >(&pDI), nullptr))) { qFatal("GlobalShortcutWin: Failed to create d8input"); return; } diff --git a/src/mumble/JackAudio.cpp b/src/mumble/JackAudio.cpp index 4207ad329..5b19ffb59 100644 --- a/src/mumble/JackAudio.cpp +++ b/src/mumble/JackAudio.cpp @@ -392,7 +392,8 @@ bool JackAudioSystem::isOk() { } uint8_t JackAudioSystem::outPorts() { - return static_cast< uint8_t >(qBound< unsigned >(1, Global::get().s.qsJackAudioOutput.toUInt(), JACK_MAX_OUTPUT_PORTS)); + return static_cast< uint8_t >( + qBound< unsigned >(1, Global::get().s.qsJackAudioOutput.toUInt(), JACK_MAX_OUTPUT_PORTS)); } jack_nframes_t JackAudioSystem::sampleRate() { diff --git a/src/mumble/LCD.cpp b/src/mumble/LCD.cpp index a2248f0fe..e6323a917 100644 --- a/src/mumble/LCD.cpp +++ b/src/mumble/LCD.cpp @@ -186,7 +186,8 @@ LCD::LCD() : QObject() { connect(qtTimer, SIGNAL(timeout()), this, SLOT(tick())); foreach (LCDDevice *d, devmgr.qlDevices) { - bool enabled = Global::get().s.qmLCDDevices.contains(d->name()) ? Global::get().s.qmLCDDevices.value(d->name()) : true; + bool enabled = + Global::get().s.qmLCDDevices.contains(d->name()) ? Global::get().s.qmLCDDevices.value(d->name()) : true; d->setEnabled(enabled); } qiLogo = QIcon(QLatin1String("skin:mumble.svg")).pixmap(48, 48).toImage().convertToFormat(QImage::Format_MonoLSB); diff --git a/src/mumble/LegacyPlugin.cpp b/src/mumble/LegacyPlugin.cpp index 420f3cf73..eaa4b5165 100644 --- a/src/mumble/LegacyPlugin.cpp +++ b/src/mumble/LegacyPlugin.cpp @@ -6,27 +6,24 @@ #include "LegacyPlugin.h" #include "MumblePlugin_v_1_0_x.h" +#include <codecvt> #include <cstdlib> -#include <wchar.h> +#include <locale> #include <map> #include <string.h> -#include <codecvt> -#include <locale> +#include <wchar.h> #include <QRegularExpression> /// A regular expression used to extract the version from the legacy plugin's description -static const QRegularExpression versionRegEx(QString::fromLatin1("(?:v)?(?:ersion)?[ \\t]*(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), QRegularExpression::CaseInsensitiveOption); +static const QRegularExpression + versionRegEx(QString::fromLatin1("(?:v)?(?:ersion)?[ \\t]*(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), + QRegularExpression::CaseInsensitiveOption); LegacyPlugin::LegacyPlugin(QString path, bool isBuiltIn, QObject *p) - : Plugin(path, isBuiltIn, p), - m_name(), - m_description(), - m_version(VERSION_UNKNOWN), - m_mumPlug(0), - m_mumPlug2(0), + : Plugin(path, isBuiltIn, p), m_name(), m_description(), m_version(VERSION_UNKNOWN), m_mumPlug(0), m_mumPlug2(0), m_mumPlugQt(0) { } @@ -37,19 +34,19 @@ bool LegacyPlugin::doInitialize() { if (Plugin::doInitialize()) { // initialization seems to have succeeded so far // This means that mumPlug is initialized - + m_name = QString::fromStdWString(m_mumPlug->shortname); // Although the MumblePlugin struct has a member called "description", the actual description seems to - // always only be returned by the longdesc function (The description member is actually just the name with some version - // info) + // always only be returned by the longdesc function (The description member is actually just the name with some + // version info) m_description = QString::fromStdWString(m_mumPlug->longdesc()); // The version field in the MumblePlugin2 struct is the positional-audio-plugin-API version and not the version // of the plugin itself. This information is not provided for legacy plugins. - // Most of them however provide information about the version of the game they support. Thus we will try to parse the - // description and extract this version using it for the plugin's version as well. - // Some plugins have the version in the actual description field of the old API (see above comment why these aren't the same) - // so we will use a combination of both to search for the version. If multiple version(-like) strings are found, the last one - // will be used. + // Most of them however provide information about the version of the game they support. Thus we will try to + // parse the description and extract this version using it for the plugin's version as well. Some plugins have + // the version in the actual description field of the old API (see above comment why these aren't the same) so + // we will use a combination of both to search for the version. If multiple version(-like) strings are found, + // the last one will be used. QString matchContent = m_description + QChar::Null + QString::fromStdWString(m_mumPlug->description); QRegularExpressionMatchIterator matchIt = versionRegEx.globalMatch(matchContent); @@ -61,7 +58,7 @@ bool LegacyPlugin::doInitialize() { if (match.hasMatch()) { // Store version - m_version = { match.captured(1).toInt(), match.captured(2).toInt(), match.captured(3).toInt() }; + m_version = { match.captured(1).toInt(), match.captured(2).toInt(), match.captured(3).toInt() }; } return true; @@ -84,9 +81,9 @@ void LegacyPlugin::resolveFunctionPointers() { QWriteLocker lock(&m_pluginLock); - mumblePluginFunc pluginFunc = reinterpret_cast<mumblePluginFunc>(m_lib.resolve("getMumblePlugin")); - mumblePlugin2Func plugin2Func = reinterpret_cast<mumblePlugin2Func>(m_lib.resolve("getMumblePlugin2")); - mumblePluginQtFunc pluginQtFunc = reinterpret_cast<mumblePluginQtFunc>(m_lib.resolve("getMumblePluginQt")); + mumblePluginFunc pluginFunc = reinterpret_cast< mumblePluginFunc >(m_lib.resolve("getMumblePlugin")); + mumblePlugin2Func plugin2Func = reinterpret_cast< mumblePlugin2Func >(m_lib.resolve("getMumblePlugin2")); + mumblePluginQtFunc pluginQtFunc = reinterpret_cast< mumblePluginQtFunc >(m_lib.resolve("getMumblePluginQt")); if (pluginFunc) { m_mumPlug = pluginFunc(); @@ -102,15 +99,16 @@ void LegacyPlugin::resolveFunctionPointers() { // and the plugin has been compiled by the same compiler as this client (determined by the plugin's // "magic") and it isn't retracted bool suitableMagic = m_mumPlug && m_mumPlug->magic == MUMBLE_PLUGIN_MAGIC; - bool retracted = m_mumPlug && m_mumPlug->shortname == L"Retracted"; - m_pluginIsValid = pluginFunc && suitableMagic && !retracted; + bool retracted = m_mumPlug && m_mumPlug->shortname == L"Retracted"; + m_pluginIsValid = pluginFunc && suitableMagic && !retracted; #ifdef MUMBLE_PLUGIN_DEBUG if (!m_pluginIsValid) { if (!pluginFunc) { qDebug("Plugin \"%s\" is missing the getMumblePlugin() function", qPrintable(m_pluginPath)); } else if (!suitableMagic) { - qDebug("Plugin \"%s\" was compiled with a different compiler (magic differs)", qPrintable(m_pluginPath)); + qDebug("Plugin \"%s\" was compiled with a different compiler (magic differs)", + qPrintable(m_pluginPath)); } else { qDebug("Plugin \"%s\" is retracted", qPrintable(m_pluginPath)); } @@ -138,7 +136,7 @@ QString LegacyPlugin::getName() const { return m_name; } else { return QString::fromLatin1("<Unknown Legacy Plugin>"); - } + } } QString LegacyPlugin::getDescription() const { @@ -185,18 +183,20 @@ bool LegacyPlugin::showConfigDialog(QWidget *parent) const { return false; } -uint8_t LegacyPlugin::initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount) { +uint8_t LegacyPlugin::initPositionalData(const char *const *programNames, const uint64_t *programPIDs, + size_t programCount) { int retCode; if (m_mumPlug2) { // Create and populate a multimap holding the names and PIDs to pass to the tryLock-function - std::multimap<std::wstring, unsigned long long int> pidMap; + std::multimap< std::wstring, unsigned long long int > pidMap; - for (size_t i=0; i<programCount; i++) { + for (size_t i = 0; i < programCount; i++) { std::string currentName = programNames[i]; - std::wstring currentNameWstr = std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(currentName); + std::wstring currentNameWstr = + std::wstring_convert< std::codecvt_utf8< wchar_t > >().from_bytes(currentName); - pidMap.insert(std::pair<std::wstring, unsigned long long int>(currentNameWstr, programPIDs[i])); + pidMap.insert(std::pair< std::wstring, unsigned long long int >(currentNameWstr, programPIDs[i])); } retCode = m_mumPlug2->trylock(pidMap); @@ -220,15 +220,18 @@ uint8_t LegacyPlugin::initPositionalData(const char *const*programNames, const u } } -bool LegacyPlugin::fetchPositionalData(Position3D& avatarPos, Vector3D& avatarDir, Vector3D& avatarAxis, Position3D& cameraPos, Vector3D& cameraDir, - Vector3D& cameraAxis, QString& context, QString& identity) const { +bool LegacyPlugin::fetchPositionalData(Position3D &avatarPos, Vector3D &avatarDir, Vector3D &avatarAxis, + Position3D &cameraPos, Vector3D &cameraDir, Vector3D &cameraAxis, + QString &context, QString &identity) const { std::wstring identityWstr; std::string contextStr; - int retCode = m_mumPlug->fetch(static_cast<float*>(avatarPos), static_cast<float*>(avatarDir), static_cast<float*>(avatarAxis), - static_cast<float*>(cameraPos), static_cast<float*>(cameraDir), static_cast<float*>(cameraAxis), contextStr, identityWstr); + int retCode = m_mumPlug->fetch(static_cast< float * >(avatarPos), static_cast< float * >(avatarDir), + static_cast< float * >(avatarAxis), static_cast< float * >(cameraPos), + static_cast< float * >(cameraDir), static_cast< float * >(cameraAxis), contextStr, + identityWstr); - context = QString::fromStdString(contextStr); + context = QString::fromStdString(contextStr); identity = QString::fromStdWString(identityWstr); // The fetch-function should return if it is "still locked on" meaning that it can continue providing diff --git a/src/mumble/LegacyPlugin.h b/src/mumble/LegacyPlugin.h index 250b624a0..8dd163c9b 100644 --- a/src/mumble/LegacyPlugin.h +++ b/src/mumble/LegacyPlugin.h @@ -10,8 +10,8 @@ #include <QtCore/QString> -#include <string> #include <memory> +#include <string> #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "mumble_legacy_plugin.h" @@ -19,64 +19,67 @@ class LegacyPlugin; /// Typedef for a LegacyPlugin pointer -typedef std::shared_ptr<LegacyPlugin> legacy_plugin_ptr_t; +typedef std::shared_ptr< LegacyPlugin > legacy_plugin_ptr_t; /// Typedef for a const LegacyPlugin pointer -typedef std::shared_ptr<const LegacyPlugin> const_legacy_plugin_ptr_t; +typedef std::shared_ptr< const LegacyPlugin > const_legacy_plugin_ptr_t; /// This class is meant for compatibility for old Mumble "plugins" that stem from before the plugin framework has been /// introduced. Thus the "plugins" represented by this class are for positional data gathering only. class LegacyPlugin : public Plugin { friend class Plugin; // needed in order for Plugin::createNew to access LegacyPlugin::doInitialize() - private: - Q_OBJECT - Q_DISABLE_COPY(LegacyPlugin) - - protected: - /// The name of the "plugin" - QString m_name; - /// The description of the "plugin" - QString m_description; - /// The Version of the "plugin" - mumble_version_t m_version; - /// A pointer to the PluginStruct in its initial version. After initialization this - /// field is effectively const and therefore it is not needed to protect read-access by a lock. - MumblePlugin *m_mumPlug; - /// A pointer to the PluginStruct in its second, enhanced version. After initialization this - /// field is effectively const and therefore it is not needed to protect read-access by a lock. - MumblePlugin2 *m_mumPlug2; - /// A pointer to the PluginStruct that encorporates Qt functionality. After initialization this - /// field is effectively const and therefore it is not needed to protect read-access by a lock. - MumblePluginQt *m_mumPlugQt; - - virtual void resolveFunctionPointers() override; - virtual bool doInitialize() override; - - LegacyPlugin(QString path, bool isBuiltIn = false, QObject *p = 0); - - virtual bool showAboutDialog(QWidget *parent) const override; - virtual bool showConfigDialog(QWidget *parent) const override; - virtual uint8_t initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount) override; - virtual bool fetchPositionalData(Position3D& avatarPos, Vector3D& avatarDir, Vector3D& avatarAxis, Position3D& cameraPos, Vector3D& cameraDir, - Vector3D& cameraAxis, QString& context, QString& identity) const override; - virtual void shutdownPositionalData() override; - public: - virtual ~LegacyPlugin() override; - - virtual mumble_error_t init() override; - - // functions for direct plugin-interaction - virtual QString getName() const override; - - virtual QString getDescription() const override; - virtual uint32_t getFeatures() const override; - virtual mumble_version_t getAPIVersion() const override; - - virtual mumble_version_t getVersion() const override; - - // functions for checking which underlying plugin functions are implemented - virtual bool providesAboutDialog() const override; - virtual bool providesConfigDialog() const override; +private: + Q_OBJECT + Q_DISABLE_COPY(LegacyPlugin) + +protected: + /// The name of the "plugin" + QString m_name; + /// The description of the "plugin" + QString m_description; + /// The Version of the "plugin" + mumble_version_t m_version; + /// A pointer to the PluginStruct in its initial version. After initialization this + /// field is effectively const and therefore it is not needed to protect read-access by a lock. + MumblePlugin *m_mumPlug; + /// A pointer to the PluginStruct in its second, enhanced version. After initialization this + /// field is effectively const and therefore it is not needed to protect read-access by a lock. + MumblePlugin2 *m_mumPlug2; + /// A pointer to the PluginStruct that encorporates Qt functionality. After initialization this + /// field is effectively const and therefore it is not needed to protect read-access by a lock. + MumblePluginQt *m_mumPlugQt; + + virtual void resolveFunctionPointers() override; + virtual bool doInitialize() override; + + LegacyPlugin(QString path, bool isBuiltIn = false, QObject *p = 0); + + virtual bool showAboutDialog(QWidget *parent) const override; + virtual bool showConfigDialog(QWidget *parent) const override; + virtual uint8_t initPositionalData(const char *const *programNames, const uint64_t *programPIDs, + size_t programCount) override; + virtual bool fetchPositionalData(Position3D &avatarPos, Vector3D &avatarDir, Vector3D &avatarAxis, + Position3D &cameraPos, Vector3D &cameraDir, Vector3D &cameraAxis, QString &context, + QString &identity) const override; + virtual void shutdownPositionalData() override; + +public: + virtual ~LegacyPlugin() override; + + virtual mumble_error_t init() override; + + // functions for direct plugin-interaction + virtual QString getName() const override; + + virtual QString getDescription() const override; + virtual uint32_t getFeatures() const override; + virtual mumble_version_t getAPIVersion() const override; + + virtual mumble_version_t getVersion() const override; + + // functions for checking which underlying plugin functions are implemented + virtual bool providesAboutDialog() const override; + virtual bool providesConfigDialog() const override; }; #endif diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 5a2b14edc..2f3e05562 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -334,7 +334,7 @@ QVector< LogMessage > Log::qvDeferredLogs; Log::Log(QObject *p) : QObject(p) { - qRegisterMetaType<Log::MsgType>(); + qRegisterMetaType< Log::MsgType >(); #ifndef USE_NO_TTS tts = new TextToSpeech(this); @@ -687,7 +687,8 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own tc.insertBlock(); } - const QString timeString = dt.time().toString(QLatin1String(Global::get().s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP")); + const QString timeString = + dt.time().toString(QLatin1String(Global::get().s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP")); tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(timeString.toHtmlEscaped()), Log::Time)); validHtml(console, &tc); diff --git a/src/mumble/LookConfig.cpp b/src/mumble/LookConfig.cpp index 53afa73ae..1683f0e4f 100644 --- a/src/mumble/LookConfig.cpp +++ b/src/mumble/LookConfig.cpp @@ -271,7 +271,8 @@ void LookConfig::save() const { } void LookConfig::accept() const { - Global::get().mw->setShowDockTitleBars((Global::get().s.wlWindowLayout == Settings::LayoutCustom) && !Global::get().s.bLockLayout); + Global::get().mw->setShowDockTitleBars((Global::get().s.wlWindowLayout == Settings::LayoutCustom) + && !Global::get().s.bLockLayout); } void LookConfig::themeDirectoryChanged() { diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index f2718f0a3..d4698d00d 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -33,8 +33,8 @@ #include "ChannelListener.h" #include "ListenerLocalVolumeDialog.h" #include "Markdown.h" -#include "PluginManager.h" #include "PTTButtonWidget.h" +#include "PluginManager.h" #include "RichTextEditor.h" #include "SSLCipherInfo.h" #include "Screen.h" @@ -186,7 +186,8 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) { || (Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInMinimal) || (!Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInNormal)); - QObject::connect(this, &MainWindow::serverSynchronized, Global::get().pluginManager, &PluginManager::on_serverSynchronized); + QObject::connect(this, &MainWindow::serverSynchronized, Global::get().pluginManager, + &PluginManager::on_serverSynchronized); } void MainWindow::createActions() { @@ -318,14 +319,16 @@ void MainWindow::setupGui() { this, &MainWindow::userRemovedChannelListener, pmModel, static_cast< void (UserModel::*)(const ClientUser *, const Channel *) >(&UserModel::removeChannelListener)); QObject::connect(&ChannelListener::get(), &ChannelListener::localVolumeAdjustmentsChanged, pmModel, - &UserModel::on_channelListenerLocalVolumeAdjustmentChanged); + &UserModel::on_channelListenerLocalVolumeAdjustmentChanged); // connect slots to PluginManager QObject::connect(pmModel, &UserModel::userAdded, Global::get().pluginManager, &PluginManager::on_userAdded); QObject::connect(pmModel, &UserModel::userRemoved, Global::get().pluginManager, &PluginManager::on_userRemoved); QObject::connect(pmModel, &UserModel::channelAdded, Global::get().pluginManager, &PluginManager::on_channelAdded); - QObject::connect(pmModel, &UserModel::channelRemoved, Global::get().pluginManager, &PluginManager::on_channelRemoved); - QObject::connect(pmModel, &UserModel::channelRenamed, Global::get().pluginManager, &PluginManager::on_channelRenamed); + QObject::connect(pmModel, &UserModel::channelRemoved, Global::get().pluginManager, + &PluginManager::on_channelRemoved); + QObject::connect(pmModel, &UserModel::channelRenamed, Global::get().pluginManager, + &PluginManager::on_channelRenamed); qaAudioMute->setChecked(Global::get().s.bMute); qaAudioDeaf->setChecked(Global::get().s.bDeaf); @@ -758,7 +761,7 @@ void MainWindow::on_qtvUsers_customContextMenuRequested(const QPoint &mpos, bool qtvUsers->setCurrentIndex(idx); } - ClientUser *p = pmModel->getUser(idx); + ClientUser *p = pmModel->getUser(idx); Channel *channel = pmModel->getChannel(idx); qpContextPosition = mpos; @@ -906,25 +909,27 @@ static void recreateServerHandler() { Global::get().sh = sh; Global::get().mw->connect(sh.get(), SIGNAL(connected()), Global::get().mw, SLOT(serverConnected())); Global::get().mw->connect(sh.get(), SIGNAL(disconnected(QAbstractSocket::SocketError, QString)), Global::get().mw, - SLOT(serverDisconnected(QAbstractSocket::SocketError, QString))); + SLOT(serverDisconnected(QAbstractSocket::SocketError, QString))); Global::get().mw->connect(sh.get(), SIGNAL(error(QAbstractSocket::SocketError, QString)), Global::get().mw, - SLOT(resolverError(QAbstractSocket::SocketError, QString))); + SLOT(resolverError(QAbstractSocket::SocketError, QString))); - QObject::connect(sh.get(), &ServerHandler::disconnected, Global::get().talkingUI, &TalkingUI::on_serverDisconnected); + QObject::connect(sh.get(), &ServerHandler::disconnected, Global::get().talkingUI, + &TalkingUI::on_serverDisconnected); // We have to use direct connections for these here as the PluginManager must be able to access the connection's ID // and in order for that to be possible the (dis)connection process must not proceed in the background. Global::get().pluginManager->connect(sh.get(), &ServerHandler::connected, Global::get().pluginManager, - &PluginManager::on_serverConnected, Qt::DirectConnection); + &PluginManager::on_serverConnected, Qt::DirectConnection); // We connect the plugin manager to "aboutToDisconnect" instead of "disconnect" in order for the slot to be // guaranteed to be completed *before* the acutal disconnect logic (e.g. MainWindow::serverDisconnected) kicks in. // In order for that to work it is ESSENTIAL to use a DIRECT CONNECTION! Global::get().pluginManager->connect(sh.get(), &ServerHandler::aboutToDisconnect, Global::get().pluginManager, - &PluginManager::on_serverDisconnected, Qt::DirectConnection); + &PluginManager::on_serverDisconnected, Qt::DirectConnection); } void MainWindow::openUrl(const QUrl &url) { - Global::get().l->log(Log::Information, tr("Opening URL %1").arg(url.toString(QUrl::RemovePassword).toHtmlEscaped())); + Global::get().l->log(Log::Information, + tr("Opening URL %1").arg(url.toString(QUrl::RemovePassword).toHtmlEscaped())); if (url.scheme() == QLatin1String("file")) { QFile f(url.toLocalFile()); if (!f.exists() || !f.open(QIODevice::ReadOnly)) { @@ -966,26 +971,27 @@ void MainWindow::openUrl(const QUrl &url) { if (version.size() > 0) { if (!MumbleVersion::get(&major, &minor, &patch, version)) { // The version format is invalid - Global::get().l->log(Log::Warning, QObject::tr("The provided URL uses an invalid version format: \"%1\"").arg(version)); + Global::get().l->log(Log::Warning, + QObject::tr("The provided URL uses an invalid version format: \"%1\"").arg(version)); return; } } // We can't handle URLs for versions < 1.2.0 - const int minMajor = 1; - const int minMinor = 2; - const int minPatch = 0; + const int minMajor = 1; + const int minMinor = 2; + const int minPatch = 0; const bool isPre_120 = major < minMajor || (major == minMajor && minor < minMinor) - || (major == minMajor && minor == minMinor && patch < minPatch); + || (major == minMajor && minor == minMinor && patch < minPatch); // We also can't handle URLs for versions newer than the running Mumble instance - const bool isFuture = major > thismajor || (major == thismajor && minor > thisminor) - || (major == thismajor && minor == thisminor && patch > thispatch); + const bool isFuture = major > thismajor || (major == thismajor && minor > thisminor) + || (major == thismajor && minor == thisminor && patch > thispatch); if (isPre_120 || isFuture) { Global::get().l->log(Log::Warning, tr("This version of Mumble can't handle URLs for Mumble version %1.%2.%3") - .arg(major) - .arg(minor) - .arg(patch)); + .arg(major) + .arg(minor) + .arg(patch)); return; } @@ -1029,10 +1035,11 @@ void MainWindow::openUrl(const QUrl &url) { recreateServerHandler(); Global::get().s.qsLastServer = name; - rtLast = MumbleProto::Reject_RejectType_None; - bRetryServer = true; + rtLast = MumbleProto::Reject_RejectType_None; + bRetryServer = true; qaServerDisconnect->setEnabled(true); - Global::get().l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(host.toHtmlEscaped(), Log::Server))); + Global::get().l->log(Log::Information, + tr("Connecting to server %1.").arg(Log::msgColor(host.toHtmlEscaped(), Log::Server))); Global::get().sh->setConnectionInfo(host, port, user, pw); Global::get().sh->start(QThread::TimeCriticalPriority); } @@ -1254,8 +1261,9 @@ void MainWindow::on_qaServerConnect_triggered(bool autoconnect) { rtLast = MumbleProto::Reject_RejectType_None; bRetryServer = true; qaServerDisconnect->setEnabled(true); - Global::get().l->log(Log::Information, - tr("Connecting to server %1.").arg(Log::msgColor(cd->qsServer.toHtmlEscaped(), Log::Server))); + Global::get().l->log( + Log::Information, + tr("Connecting to server %1.").arg(Log::msgColor(cd->qsServer.toHtmlEscaped(), Log::Server))); Global::get().sh->setConnectionInfo(cd->qsServer, cd->usPort, cd->qsUsername, cd->qsPassword); Global::get().sh->start(QThread::TimeCriticalPriority); } @@ -1585,10 +1593,12 @@ void MainWindow::qmUser_aboutToShow() { qaUserTextureReset->setEnabled(!p->qbaTextureHash.isEmpty() && (Global::get().pPermissions & (ChanACL::Move | ChanACL::Write))); } else { - qaUserCommentReset->setEnabled(!p->qbaCommentHash.isEmpty() - && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write))); - qaUserTextureReset->setEnabled(!p->qbaTextureHash.isEmpty() - && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write))); + qaUserCommentReset->setEnabled( + !p->qbaCommentHash.isEmpty() + && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write))); + qaUserTextureReset->setEnabled( + !p->qbaTextureHash.isEmpty() + && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write))); } qaUserCommentView->setEnabled(!p->qbaCommentHash.isEmpty()); @@ -1868,8 +1878,9 @@ void MainWindow::openTextMessageDialog(ClientUser *p) { if (!msg.isEmpty()) { Global::get().sh->sendUserTextMessage(p->uiSession, msg); - Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), texm->message()), - tr("Message to %1").arg(p->qsName), true); + Global::get().l->log(Log::TextMessage, + tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), texm->message()), + tr("Message to %1").arg(p->qsName), true); } } delete texm; @@ -1995,12 +2006,12 @@ void MainWindow::sendChatbarMessage(QString qsMessage) { Global::get().sh->sendChannelTextMessage(c->iId, qsMessage, false); Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsMessage), - tr("Message to channel %1").arg(c->qsName), true); + tr("Message to channel %1").arg(c->qsName), true); } else { // User message Global::get().sh->sendUserTextMessage(p->uiSession, qsMessage); Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), qsMessage), - tr("Message to %1").arg(p->qsName), true); + tr("Message to %1").arg(p->qsName), true); } } @@ -2305,10 +2316,10 @@ void MainWindow::on_qaChannelSendMessage_triggered() { if (texm->bTreeMessage) Global::get().l->log(Log::TextMessage, tr("To %1 (Tree): %2").arg(Log::formatChannel(c), texm->message()), - tr("Message to tree %1").arg(c->qsName), true); + tr("Message to tree %1").arg(c->qsName), true); else Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), texm->message()), - tr("Message to channel %1").arg(c->qsName), true); + tr("Message to channel %1").arg(c->qsName), true); } delete texm; } @@ -2458,7 +2469,8 @@ void MainWindow::userStateChanged() { case Settings::Shouting: Global::get().bAttenuateOthers = Global::get().s.bAttenuateOthersOnTalk; - Global::get().prioritySpeakerActiveOverride = Global::get().s.bAttenuateUsersOnPrioritySpeak && user->bPrioritySpeaker; + Global::get().prioritySpeakerActiveOverride = + Global::get().s.bAttenuateUsersOnPrioritySpeak && user->bPrioritySpeaker; break; case Settings::Passive: @@ -2536,8 +2548,8 @@ void MainWindow::on_qaAudioDeaf_triggered() { Global::get().s.bDeaf = qaAudioDeaf->isChecked(); if (Global::get().s.bDeaf && !Global::get().s.bMute) { - bAutoUnmute = true; - Global::get().s.bMute = true; + bAutoUnmute = true; + Global::get().s.bMute = true; qaAudioMute->setChecked(true); Global::get().l->log(Log::SelfDeaf, tr("Muted and deafened.")); } else if (Global::get().s.bDeaf) { @@ -3028,7 +3040,7 @@ void MainWindow::on_gsSendTextMessage_triggered(bool down, QVariant scdata) { Channel *c = ClientUser::get(Global::get().uiSession)->cChannel; Global::get().sh->sendChannelTextMessage(c->iId, qsText, false); Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsText), - tr("Message to channel %1").arg(c->qsName), true); + tr("Message to channel %1").arg(c->qsName), true); } void MainWindow::on_gsSendClipboardTextMessage_triggered(bool down, QVariant) { @@ -3053,8 +3065,7 @@ void MainWindow::whisperReleased(QVariant scdata) { updateTarget(); } -void MainWindow::onResetAudio() -{ +void MainWindow::onResetAudio() { qWarning("MainWindow: Start audio reset"); Audio::stop(); Audio::start(); @@ -3260,7 +3271,8 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re vc.exec(); continue; } else if (res == QMessageBox::Yes) { - Global::get().db->setDigest(host, port, QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex())); + Global::get().db->setDigest(host, port, + QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex())); qaServerDisconnect->setEnabled(true); on_Reconnect_timeout(); } @@ -3277,7 +3289,8 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re if (!reason.isEmpty()) { - Global::get().l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped())); + Global::get().l->log(Log::ServerDisconnected, + tr("Server connection failed: %1.").arg(reason.toHtmlEscaped())); } else { Global::get().l->log(Log::ServerDisconnected, tr("Disconnected from server.")); } @@ -3587,11 +3600,12 @@ QPair< QByteArray, QImage > MainWindow::openImageFile() { } void MainWindow::logChangeNotPermanent(const QString &actionName, ClientUser *const p) const { - Global::get().l->log(Log::Warning, - QObject::tr( - "\"%1\" could not be saved permanently and is lost on restart because %2 does not have a certificate.") - .arg(actionName) - .arg(Log::formatClientUser(p, Log::Target))); + Global::get().l->log( + Log::Warning, + QObject::tr( + "\"%1\" could not be saved permanently and is lost on restart because %2 does not have a certificate.") + .arg(actionName) + .arg(Log::formatClientUser(p, Log::Target))); } void MainWindow::destroyUserInformation() { diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 20c8a3000..f29064831 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -17,8 +17,8 @@ #include "Message.h" #include "Mumble.pb.h" #include "Usage.h" -#include "UserLocalVolumeDialog.h" #include "UserLocalNicknameDialog.h" +#include "UserLocalVolumeDialog.h" #include "ui_MainWindow.h" @@ -81,7 +81,8 @@ public: GlobalShortcut *gsToggleOverlay; #endif GlobalShortcut *gsMinimal, *gsVolumeUp, *gsVolumeDown, *gsWhisper, *gsLinkChannel; - GlobalShortcut *gsCycleTransmitMode, *gsToggleMainWindowVisibility, *gsTransmitModePushToTalk, *gsTransmitModeContinuous, *gsTransmitModeVAD; + GlobalShortcut *gsCycleTransmitMode, *gsToggleMainWindowVisibility, *gsTransmitModePushToTalk, + *gsTransmitModeContinuous, *gsTransmitModeVAD; GlobalShortcut *gsSendTextMessage, *gsSendClipboardTextMessage; DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle; diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp index e4ea84336..b90aefe9f 100644 --- a/src/mumble/ManualPlugin.cpp +++ b/src/mumble/ManualPlugin.cpp @@ -13,8 +13,8 @@ #include <QPointer> -#include <float.h> #include <cmath> +#include <float.h> #define MUMBLE_ALLOW_DEPRECATED_LEGACY_PLUGIN_API #include "../../plugins/mumble_legacy_plugin.h" @@ -136,7 +136,7 @@ void Manual::on_qpbActivated_clicked(bool b) { } void Manual::on_qdsbX_valueChanged(double d) { - my.avatar_pos[0] = my.camera_pos[0] = static_cast<float>(d); + my.avatar_pos[0] = my.camera_pos[0] = static_cast< float >(d); m_qgiPosition->setPos(my.avatar_pos[0], -my.avatar_pos[2]); } @@ -145,7 +145,7 @@ void Manual::on_qdsbY_valueChanged(double d) { } void Manual::on_qdsbZ_valueChanged(double d) { - my.avatar_pos[2] = my.camera_pos[2] = static_cast<float>(d); + my.avatar_pos[2] = my.camera_pos[2] = static_cast< float >(d); m_qgiPosition->setPos(my.avatar_pos[0], -my.avatar_pos[2]); } @@ -265,7 +265,7 @@ void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > position const float speakerRadius = 1.2; QGraphicsItem *speakerItem = m_qgsScene->addEllipse(-speakerRadius, -speakerRadius, 2 * speakerRadius, - 2 * speakerRadius, QPen(), QBrush(Qt::red)); + 2 * speakerRadius, QPen(), QBrush(Qt::red)); Position2D pos = remainingIt.value(); @@ -427,6 +427,6 @@ ManualPlugin::~ManualPlugin() { } void ManualPlugin::resolveFunctionPointers() { - m_mumPlug = &manual; + m_mumPlug = &manual; m_mumPlugQt = &manualqt; } diff --git a/src/mumble/ManualPlugin.h b/src/mumble/ManualPlugin.h index dbeee0d31..64a36f615 100644 --- a/src/mumble/ManualPlugin.h +++ b/src/mumble/ManualPlugin.h @@ -11,8 +11,8 @@ #include <QtWidgets/QGraphicsItem> #include <QtWidgets/QGraphicsScene> -#include "ui_ManualPlugin.h" #include "LegacyPlugin.h" +#include "ui_ManualPlugin.h" #include <atomic> #include <chrono> @@ -86,16 +86,16 @@ MumblePluginQt *ManualPlugin_getMumblePluginQt(); /// A built-in "plugin" for positional data gatherig allowing for manually placing the "players" in a UI class ManualPlugin : public LegacyPlugin { friend class Plugin; // needed in order for Plugin::createNew to access LegacyPlugin::doInitialize() - private: - Q_OBJECT - Q_DISABLE_COPY(ManualPlugin) - - protected: - virtual void resolveFunctionPointers() Q_DECL_OVERRIDE; - ManualPlugin(QObject *p = nullptr); - - public: - virtual ~ManualPlugin() Q_DECL_OVERRIDE; +private: + Q_OBJECT + Q_DISABLE_COPY(ManualPlugin) + +protected: + virtual void resolveFunctionPointers() Q_DECL_OVERRIDE; + ManualPlugin(QObject *p = nullptr); + +public: + virtual ~ManualPlugin() Q_DECL_OVERRIDE; }; #endif diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 729085f5e..34018abe4 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -24,6 +24,7 @@ # include "Overlay.h" #endif #include "ChannelListener.h" +#include "PluginManager.h" #include "ServerHandler.h" #include "TalkingUI.h" #include "User.h" @@ -34,7 +35,6 @@ #include "VersionCheck.h" #include "ViewCert.h" #include "crypto/CryptState.h" -#include "PluginManager.h" #include "Global.h" #include <QTextDocumentFragment> @@ -52,11 +52,11 @@ return; \ } -#define SELF_INIT \ +#define SELF_INIT \ ClientUser *pSelf = ClientUser::get(Global::get().uiSession); \ - if (!pSelf) { \ + if (!pSelf) { \ qWarning("MainWindow: Received message outside of session (sid %d).", Global::get().uiSession); \ - return; \ + return; \ } /// The authenticate message is being used by the client to send the authentication credentials to the server. Therefore @@ -198,12 +198,13 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) { { // Since we are only loading the adjustments from the database, we don't really want to consider the adjustments // to have "changed" by this action. Furthermore we are setting the volume adjustments before the listeners - // officially exist. Therefore some code that would receive the change-event would try to get the respective listener - // and fail due to it not existing yet. - // Therefore we block all signals while setting the volume adjustments. + // officially exist. Therefore some code that would receive the change-event would try to get the respective + // listener and fail due to it not existing yet. Therefore we block all signals while setting the volume + // adjustments. const QSignalBlocker blocker(ChannelListener::get()); - QHash< int, float > volumeMap = Global::get().db->getChannelListenerLocalVolumeAdjustments(Global::get().sh->qbaDigest); + QHash< int, float > volumeMap = + Global::get().db->getChannelListenerLocalVolumeAdjustments(Global::get().sh->qbaDigest); QHashIterator< int, float > it(volumeMap); while (it.hasNext()) { it.next(); @@ -265,13 +266,13 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { } else { if (pDst == pSelf) Global::get().l->log(Log::PermissionDenied, tr("You were denied %1 privileges in %2.") - .arg(Log::msgColor(pname, Log::Privilege)) - .arg(Log::formatChannel(c))); + .arg(Log::msgColor(pname, Log::Privilege)) + .arg(Log::formatChannel(c))); else Global::get().l->log(Log::PermissionDenied, tr("%3 was denied %1 privileges in %2.") - .arg(Log::msgColor(pname, Log::Privilege)) - .arg(Log::formatChannel(c)) - .arg(Log::formatClientUser(pDst, Log::Target))); + .arg(Log::msgColor(pname, Log::Privilege)) + .arg(Log::formatChannel(c)) + .arg(Log::formatClientUser(pDst, Log::Target))); } } break; case MumbleProto::PermissionDenied_DenyType_SuperUser: { @@ -285,14 +286,15 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { } break; case MumbleProto::PermissionDenied_DenyType_H9K: { if (Global::get().bHappyEaster) { - bool bold = Global::get().s.bDeaf; - bool bold2 = Global::get().s.bTTS; - Global::get().s.bDeaf = false; - Global::get().s.bTTS = true; - quint32 oflags = Global::get().s.qmMessages.value(Log::PermissionDenied); - Global::get().s.qmMessages[Log::PermissionDenied] = (oflags | Settings::LogTTS) & (~Settings::LogSoundfile); - Global::get().l->log(Log::PermissionDenied, - QString::fromUtf8(Global::get().ccHappyEaster + 39).arg(Global::get().s.qsUsername.toHtmlEscaped())); + bool bold = Global::get().s.bDeaf; + bool bold2 = Global::get().s.bTTS; + Global::get().s.bDeaf = false; + Global::get().s.bTTS = true; + quint32 oflags = Global::get().s.qmMessages.value(Log::PermissionDenied); + Global::get().s.qmMessages[Log::PermissionDenied] = + (oflags | Settings::LogTTS) & (~Settings::LogSoundfile); + Global::get().l->log(Log::PermissionDenied, QString::fromUtf8(Global::get().ccHappyEaster + 39) + .arg(Global::get().s.qsUsername.toHtmlEscaped())); Global::get().s.qmMessages[Log::PermissionDenied] = oflags; Global::get().s.bDeaf = bold; Global::get().s.bTTS = bold2; @@ -310,12 +312,14 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { if (pDst == pSelf) Global::get().l->log(Log::PermissionDenied, tr("You need a certificate to perform this operation.")); else - Global::get().l->log(Log::PermissionDenied, - tr("%1 does not have a certificate.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::PermissionDenied, + tr("%1 does not have a certificate.").arg(Log::formatClientUser(pDst, Log::Target))); } break; case MumbleProto::PermissionDenied_DenyType_UserName: { if (msg.has_name()) - Global::get().l->log(Log::PermissionDenied, tr("Invalid username: %1.").arg(u8(msg.name()).toHtmlEscaped())); + Global::get().l->log(Log::PermissionDenied, + tr("Invalid username: %1.").arg(u8(msg.name()).toHtmlEscaped())); else Global::get().l->log(Log::PermissionDenied, tr("Invalid username.")); } break; @@ -327,14 +331,14 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { } break; case MumbleProto::PermissionDenied_DenyType_ChannelCountLimit: { Global::get().l->log(Log::PermissionDenied, - tr("Channel count limit reached. Need to delete channels before creating new ones.")); + tr("Channel count limit reached. Need to delete channels before creating new ones.")); } break; case MumbleProto::PermissionDenied_DenyType_ChannelListenerLimit: { Global::get().l->log(Log::PermissionDenied, tr("No more listeners allowed in this channel.")); } break; case MumbleProto::PermissionDenied_DenyType_UserListenerLimit: { Global::get().l->log(Log::PermissionDenied, - tr("You are not allowed to listen to more channels than you currently are.")); + tr("You are not allowed to listen to more channels than you currently are.")); } break; default: { if (msg.has_reason()) @@ -390,8 +394,9 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { if (pSelf) { if (pDst->cChannel == pSelf->cChannel) { - Global::get().l->log(Log::ChannelJoinConnect, - tr("%1 connected and entered channel.").arg(Log::formatClientUser(pDst, Log::Source))); + Global::get().l->log( + Log::ChannelJoinConnect, + tr("%1 connected and entered channel.").arg(Log::formatClientUser(pDst, Log::Source))); } else { Global::get().l->log(Log::UserJoin, tr("%1 connected.").arg(Log::formatClientUser(pDst, Log::Source))); } @@ -421,49 +426,53 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { if (pDst == pSelf) { if (pSrc == pSelf) { - Global::get().l->log(Log::SelfChannelJoin, tr("You joined %1.").arg(Log::formatChannel(channel))); + Global::get().l->log(Log::SelfChannelJoin, + tr("You joined %1.").arg(Log::formatChannel(channel))); } else { - Global::get().l->log(Log::SelfChannelJoinOther, tr("You were moved to %1 by %2.") - .arg(Log::formatChannel(channel)) - .arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::SelfChannelJoinOther, + tr("You were moved to %1 by %2.") + .arg(Log::formatChannel(channel)) + .arg(Log::formatClientUser(pSrc, Log::Source))); } } else if (pSrc == pSelf) { if (channel == pSelf->cChannel) { Global::get().l->log(Log::ChannelJoin, tr("You moved %1 to %2.") - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatChannel(channel))); + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatChannel(channel))); } else { Global::get().l->log(Log::ChannelLeave, tr("You moved %1 to %2.") - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatChannel(channel))); + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatChannel(channel))); } } else if ((channel == pSelf->cChannel) || (oldChannel == pSelf->cChannel)) { if (pDst == pSrc) { if (channel == pSelf->cChannel) { - Global::get().l->log(Log::ChannelJoin, - tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::ChannelJoin, + tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target))); } else { Global::get().l->log(Log::ChannelLeave, tr("%1 moved to %2.") - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatChannel(channel))); + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatChannel(channel))); } } else { if (channel == pSelf->cChannel) { Global::get().l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.") - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatChannel(oldChannel)) - .arg(Log::formatClientUser(pSrc, Log::Source))); + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatChannel(oldChannel)) + .arg(Log::formatClientUser(pSrc, Log::Source))); } else { Global::get().l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.") - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatChannel(channel)) - .arg(Log::formatClientUser(pSrc, Log::Source))); + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatChannel(channel)) + .arg(Log::formatClientUser(pSrc, Log::Source))); } } } if ((channel == pSelf->cChannel) && pDst->bRecording) { - Global::get().l->log(Log::Recording, tr("%1 is recording").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log(Log::Recording, + tr("%1 is recording").arg(Log::formatClientUser(pDst, Log::Target))); } } } @@ -529,13 +538,13 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { if (!oldName.isNull() && oldName != newName) { if (pSrc != pDst) { Global::get().l->log(Log::UserRenamed, tr("%1 renamed to %2 by %3.") - .arg(Log::formatClientUser(pDst, Log::Target, oldName)) - .arg(Log::formatClientUser(pDst, Log::Target)) - .arg(Log::formatClientUser(pSrc, Log::Source))); + .arg(Log::formatClientUser(pDst, Log::Target, oldName)) + .arg(Log::formatClientUser(pDst, Log::Target)) + .arg(Log::formatClientUser(pSrc, Log::Source))); } else { Global::get().l->log(Log::UserRenamed, tr("%1 renamed to %2.") - .arg(Log::formatClientUser(pDst, Log::Target, oldName), - Log::formatClientUser(pDst, Log::Target))); + .arg(Log::formatClientUser(pDst, Log::Target, oldName), + Log::formatClientUser(pDst, Log::Target))); } } } @@ -564,11 +573,13 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { && ((pDst->cChannel == pSelf->cChannel) || pDst->cChannel->allLinks().contains(pSelf->cChannel))) { if (pDst->bSelfMute && pDst->bSelfDeaf) Global::get().l->log(Log::OtherSelfMute, - tr("%1 is now muted and deafened.").arg(Log::formatClientUser(pDst, Log::Target))); + tr("%1 is now muted and deafened.").arg(Log::formatClientUser(pDst, Log::Target))); else if (pDst->bSelfMute) - Global::get().l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log(Log::OtherSelfMute, + tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target))); else - Global::get().l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log(Log::OtherSelfMute, + tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target))); } } @@ -585,9 +596,11 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { } } else if (pDst->cChannel->allLinks().contains(pSelf->cChannel)) { if (pDst->bRecording) { - Global::get().l->log(Log::Recording, tr("%1 started recording.").arg(Log::formatClientUser(pDst, Log::Source))); + Global::get().l->log(Log::Recording, + tr("%1 started recording.").arg(Log::formatClientUser(pDst, Log::Source))); } else { - Global::get().l->log(Log::Recording, tr("%1 stopped recording.").arg(Log::formatClientUser(pDst, Log::Source))); + Global::get().l->log(Log::Recording, + tr("%1 stopped recording.").arg(Log::formatClientUser(pDst, Log::Source))); } } } @@ -609,13 +622,14 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { Log::YouMutedOther, tr("%1 revoked your priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } else { - Global::get().l->log(Log::YouMutedOther, - tr("%1 gave you priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMutedOther, + tr("%1 gave you priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } } else if ((pSrc == pSelf) && (pSrc != pDst)) { if (pDst->bPrioritySpeaker) { Global::get().l->log(Log::YouMutedOther, tr("You revoked priority speaker status for %1.") - .arg(Log::formatClientUser(pDst, Log::Target))); + .arg(Log::formatClientUser(pDst, Log::Target))); } else { Global::get().l->log( Log::YouMutedOther, @@ -627,18 +641,19 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { Log::OtherMutedOther, tr("%1 revoked own priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } else { - Global::get().l->log(Log::OtherMutedOther, - tr("%1 assumed priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::OtherMutedOther, + tr("%1 assumed priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } } else if ((pSrc != pSelf) && (pDst != pSelf)) { if (pDst->bPrioritySpeaker) { Global::get().l->log(Log::OtherMutedOther, tr("%1 revoked priority speaker status for %2.") - .arg(Log::formatClientUser(pSrc, Log::Source), - Log::formatClientUser(pDst, Log::Target))); + .arg(Log::formatClientUser(pSrc, Log::Source), + Log::formatClientUser(pDst, Log::Target))); } else if (!pDst->bPrioritySpeaker) { Global::get().l->log(Log::OtherMutedOther, tr("%1 gave priority speaker status to %2.") - .arg(Log::formatClientUser(pSrc, Log::Source), - Log::formatClientUser(pDst, Log::Target))); + .arg(Log::formatClientUser(pSrc, Log::Source), + Log::formatClientUser(pDst, Log::Target))); } } } @@ -659,8 +674,9 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { || (pSrc == pSelf))) { if (pDst == pSelf) { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { - Global::get().l->log(Log::YouMuted, - tr("You were muted and deafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMuted, + tr("You were muted and deafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { Global::get().l->log( Log::YouMuted, @@ -668,17 +684,20 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { } else { if (msg.has_mute()) { if (pDst->bMute) - Global::get().l->log(Log::YouMuted, - tr("You were muted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMuted, + tr("You were muted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); else - Global::get().l->log(Log::YouMuted, - tr("You were unmuted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMuted, + tr("You were unmuted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } if (msg.has_deaf()) { if (!pDst->bDeaf) - Global::get().l->log(Log::YouMuted, - tr("You were undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMuted, + tr("You were undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } } @@ -689,85 +708,96 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { if (msg.has_channel_id()) Global::get().l->log(Log::YouMuted, tr("You were unsuppressed.")); else - Global::get().l->log(Log::YouMuted, - tr("You were unsuppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log( + Log::YouMuted, + tr("You were unsuppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } } updateTrayIcon(); } else if (pSrc == pSelf) { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { - Global::get().l->log(Log::YouMutedOther, - tr("You muted and deafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::YouMutedOther, + tr("You muted and deafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { - Global::get().l->log(Log::YouMutedOther, - tr("You unmuted and undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::YouMutedOther, + tr("You unmuted and undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } else { if (msg.has_mute()) { if (pDst->bMute) Global::get().l->log(Log::YouMutedOther, - tr("You muted %1.").arg(Log::formatClientUser(pDst, Log::Target))); + tr("You muted %1.").arg(Log::formatClientUser(pDst, Log::Target))); else Global::get().l->log(Log::YouMutedOther, - tr("You unmuted %1.").arg(Log::formatClientUser(pDst, Log::Target))); + tr("You unmuted %1.").arg(Log::formatClientUser(pDst, Log::Target))); } if (msg.has_deaf()) { if (!pDst->bDeaf) - Global::get().l->log(Log::YouMutedOther, - tr("You undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::YouMutedOther, + tr("You undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } } if (msg.has_suppress()) { if (!msg.has_channel_id()) { if (pDst->bSuppress) - Global::get().l->log(Log::YouMutedOther, - tr("You suppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::YouMutedOther, + tr("You suppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); else - Global::get().l->log(Log::YouMutedOther, - tr("You unsuppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); + Global::get().l->log( + Log::YouMutedOther, + tr("You unsuppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); } } } else { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { Global::get().l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { Global::get().l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); } else { if (msg.has_mute()) { if (pDst->bMute) - Global::get().l->log(Log::OtherMutedOther, tr("%1 muted by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::OtherMutedOther, + tr("%1 muted by %2.") + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); else - Global::get().l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::OtherMutedOther, + tr("%1 unmuted by %2.") + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); } if (msg.has_deaf()) { if (!pDst->bDeaf) - Global::get().l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::OtherMutedOther, + tr("%1 undeafened by %2.") + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); } } if (msg.has_suppress()) { if (!msg.has_channel_id()) { if (pDst->bSuppress) - Global::get().l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::OtherMutedOther, + tr("%1 suppressed by %2.") + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); else - Global::get().l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.") - .arg(Log::formatClientUser(pDst, Log::Target), - Log::formatClientUser(pSrc, Log::Source))); + Global::get().l->log(Log::OtherMutedOther, + tr("%1 unsuppressed by %2.") + .arg(Log::formatClientUser(pDst, Log::Target), + Log::formatClientUser(pSrc, Log::Source))); } } } @@ -816,29 +846,29 @@ void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) { bRetryServer = false; if (msg.ban()) Global::get().l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.") - .arg(Log::formatClientUser(pSrc, Log::Source)) - .arg(reason)); + .arg(Log::formatClientUser(pSrc, Log::Source)) + .arg(reason)); else Global::get().l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.") - .arg(Log::formatClientUser(pSrc, Log::Source)) - .arg(reason)); + .arg(Log::formatClientUser(pSrc, Log::Source)) + .arg(reason)); } else if (pSrc) { if (msg.ban()) Global::get().l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, - tr("%3 was kicked and banned from the server by %1: %2.") - .arg(Log::formatClientUser(pSrc, Log::Source)) - .arg(reason) - .arg(Log::formatClientUser(pDst, Log::Target))); + tr("%3 was kicked and banned from the server by %1: %2.") + .arg(Log::formatClientUser(pSrc, Log::Source)) + .arg(reason) + .arg(Log::formatClientUser(pDst, Log::Target))); else Global::get().l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, - tr("%3 was kicked from the server by %1: %2.") - .arg(Log::formatClientUser(pSrc, Log::Source)) - .arg(reason) - .arg(Log::formatClientUser(pDst, Log::Target))); + tr("%3 was kicked from the server by %1: %2.") + .arg(Log::formatClientUser(pSrc, Log::Source)) + .arg(reason) + .arg(Log::formatClientUser(pDst, Log::Target))); } else { if (pDst->cChannel == pSelf->cChannel || pDst->cChannel->allLinks().contains(pSelf->cChannel)) { Global::get().l->log(Log::ChannelLeaveDisconnect, - tr("%1 left channel and disconnected.").arg(Log::formatClientUser(pDst, Log::Source))); + tr("%1 left channel and disconnected.").arg(Log::formatClientUser(pDst, Log::Source))); } else { Global::get().l->log(Log::UserLeave, tr("%1 disconnected.").arg(Log::formatClientUser(pDst, Log::Source))); } @@ -969,7 +999,8 @@ void MainWindow::msgChannelRemove(const MumbleProto::ChannelRemove &msg) { c->bFiltered = false; } if (!pmModel->removeChannel(c, true)) { - Global::get().l->log(Log::CriticalError, tr("Protocol violation. Server sent remove for occupied channel.")); + Global::get().l->log(Log::CriticalError, + tr("Protocol violation. Server sent remove for occupied channel.")); Global::get().sh->disconnect(); return; } @@ -1017,8 +1048,8 @@ void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) { const QString prefixMessage = target.isEmpty() ? name : tr("(%1) %2").arg(target).arg(name); Global::get().l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage, - tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName), false, - overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false); + tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName), + false, overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false); } /// This message is being received when the server informs the client about the access control list (ACL) for @@ -1210,10 +1241,11 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) { #ifdef USE_OPUS static bool warnedOpus = false; - Global::get().bOpus = msg.opus(); + Global::get().bOpus = msg.opus(); if (!Global::get().oCodec && !warnedOpus) { - Global::get().l->log(Log::CriticalError, tr("Failed to load Opus, it will not be available for audio encoding/decoding.")); + Global::get().l->log(Log::CriticalError, + tr("Failed to load Opus, it will not be available for audio encoding/decoding.")); warnedOpus = true; } #endif @@ -1244,8 +1276,9 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) { if (!Global::get().qmCodecs.contains(willuse)) { if (!warnedCELT) { - Global::get().l->log(Log::CriticalError, tr("Unable to find matching CELT codecs with other clients. You will not be " - "able to talk to all users.")); + Global::get().l->log(Log::CriticalError, + tr("Unable to find matching CELT codecs with other clients. You will not be " + "able to talk to all users.")); warnedCELT = true; } } else { @@ -1286,8 +1319,9 @@ void MainWindow::msgRequestBlob(const MumbleProto::RequestBlob &) { /// @param msg The message object containing the suggestions void MainWindow::msgSuggestConfig(const MumbleProto::SuggestConfig &msg) { if (msg.has_version() && (msg.version() > MumbleVersion::getRaw())) { - Global::get().l->log(Log::Warning, - tr("The server requests minimum client version %1").arg(MumbleVersion::toString(msg.version()))); + Global::get().l->log( + Log::Warning, + tr("The server requests minimum client version %1").arg(MumbleVersion::toString(msg.version()))); } if (msg.has_positional() && (msg.positional() != Global::get().s.doPositionalAudio())) { if (msg.positional()) @@ -1306,19 +1340,21 @@ void MainWindow::msgSuggestConfig(const MumbleProto::SuggestConfig &msg) { void MainWindow::msgPluginDataTransmission(const MumbleProto::PluginDataTransmission &msg) { // Another client's plugin has sent us some data. Verify the necessary parts are there and delegate it to the // PluginManager - + if (!msg.has_sendersession() || !msg.has_data() || !msg.has_dataid()) { - // if the message contains no sender session, no data or no ID for the data, it is of no use to us and we discard it + // if the message contains no sender session, no data or no ID for the data, it is of no use to us and we + // discard it return; } const ClientUser *sender = ClientUser::get(msg.sendersession()); - const std::string &data = msg.data(); + const std::string &data = msg.data(); if (sender) { static_assert(sizeof(unsigned char) == sizeof(uint8_t), "Unsigned char does not have expected 8bit size"); // As long as above assertion is true, we are only casting away the sign, which is fine - Global::get().pluginManager->on_receiveData(sender, reinterpret_cast< const uint8_t * >(data.c_str()), data.size(), msg.dataid().c_str()); + Global::get().pluginManager->on_receiveData(sender, reinterpret_cast< const uint8_t * >(data.c_str()), + data.size(), msg.dataid().c_str()); } } diff --git a/src/mumble/MumbleApplication.cpp b/src/mumble/MumbleApplication.cpp index eb78b40b3..f729438ce 100644 --- a/src/mumble/MumbleApplication.cpp +++ b/src/mumble/MumbleApplication.cpp @@ -7,8 +7,8 @@ #include "EnvUtils.h" #include "MainWindow.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #if defined(Q_OS_WIN) # include "GlobalShortcut_win.h" diff --git a/src/mumble/NetworkConfig.cpp b/src/mumble/NetworkConfig.cpp index 6b75bd644..674caedb1 100644 --- a/src/mumble/NetworkConfig.cpp +++ b/src/mumble/NetworkConfig.cpp @@ -196,8 +196,8 @@ void Network::prepareRequest(QNetworkRequest &req) { } else { req.setRawHeader(QString::fromLatin1("User-Agent").toUtf8(), QString::fromLatin1("Mozilla/5.0 (%1; %2) Mumble/%3 %4") - .arg(OSInfo::getOS(), OSInfo::getOSVersion(), - QLatin1String(MUMTEXT(MUMBLE_VERSION)), QLatin1String(MUMBLE_RELEASE)) + .arg(OSInfo::getOS(), OSInfo::getOSVersion(), QLatin1String(MUMTEXT(MUMBLE_VERSION)), + QLatin1String(MUMBLE_RELEASE)) .toUtf8()); } } diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp index b594472e5..2904b084c 100644 --- a/src/mumble/Overlay.cpp +++ b/src/mumble/Overlay.cpp @@ -17,8 +17,8 @@ #include "User.h" #include "Utils.h" #include "WebFetch.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #include <QtCore/QProcessEnvironment> #include <QtCore/QtEndian> diff --git a/src/mumble/OverlayClient.cpp b/src/mumble/OverlayClient.cpp index 24b229b95..37efb29b6 100644 --- a/src/mumble/OverlayClient.cpp +++ b/src/mumble/OverlayClient.cpp @@ -16,8 +16,8 @@ #include "Themes.h" #include "User.h" #include "Utils.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #ifdef Q_OS_WIN # include <QtGui/QBitmap> diff --git a/src/mumble/OverlayConfig.cpp b/src/mumble/OverlayConfig.cpp index b3e7c59cc..1fdbbf384 100644 --- a/src/mumble/OverlayConfig.cpp +++ b/src/mumble/OverlayConfig.cpp @@ -18,8 +18,8 @@ #include "Screen.h" #include "ServerHandler.h" #include "User.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #ifdef Q_OS_WIN # include "../../overlay/overlay_blacklist.h" diff --git a/src/mumble/OverlayEditor.cpp b/src/mumble/OverlayEditor.cpp index e35ad417a..a73662ca5 100644 --- a/src/mumble/OverlayEditor.cpp +++ b/src/mumble/OverlayEditor.cpp @@ -15,8 +15,8 @@ #include "ServerHandler.h" #include "User.h" #include "Utils.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #include <QtWidgets/QGraphicsProxyWidget> diff --git a/src/mumble/OverlayEditorScene.cpp b/src/mumble/OverlayEditorScene.cpp index 7ed0c848f..6cc4c632c 100644 --- a/src/mumble/OverlayEditorScene.cpp +++ b/src/mumble/OverlayEditorScene.cpp @@ -16,8 +16,8 @@ #include "ServerHandler.h" #include "User.h" #include "Utils.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #include <QtGui/QImageReader> #include <QtWidgets/QColorDialog> diff --git a/src/mumble/OverlayUser.cpp b/src/mumble/OverlayUser.cpp index 84f14e2f9..5ff764a86 100644 --- a/src/mumble/OverlayUser.cpp +++ b/src/mumble/OverlayUser.cpp @@ -15,8 +15,8 @@ #include "ServerHandler.h" #include "User.h" #include "Utils.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #include <QtGui/QImageReader> diff --git a/src/mumble/OverlayUserGroup.cpp b/src/mumble/OverlayUserGroup.cpp index d8dff48fa..087752ba9 100644 --- a/src/mumble/OverlayUserGroup.cpp +++ b/src/mumble/OverlayUserGroup.cpp @@ -18,8 +18,8 @@ #include "ServerHandler.h" #include "User.h" #include "Utils.h" -#include "GlobalShortcut.h" #include "Global.h" +#include "GlobalShortcut.h" #include <QtGui/QImageReader> #include <QtWidgets/QGraphicsSceneContextMenuEvent> diff --git a/src/mumble/Plugin.cpp b/src/mumble/Plugin.cpp index 8317c584f..95260e7fd 100644 --- a/src/mumble/Plugin.cpp +++ b/src/mumble/Plugin.cpp @@ -4,11 +4,11 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include "Plugin.h" -#include "Version.h" #include "API.h" +#include "Version.h" -#include <QWriteLocker> #include <QMutexLocker> +#include <QWriteLocker> #include <cstring> @@ -17,7 +17,7 @@ plugin_id_t Plugin::s_nextID = 1; QMutex Plugin::s_idLock(QMutex::NonRecursive); -void assertPluginLoaded(const Plugin* plugin) { +void assertPluginLoaded(const Plugin *plugin) { // don't throw and exception in release build if (!plugin->isLoaded()) { #ifdef QT_DEBUG @@ -29,15 +29,8 @@ void assertPluginLoaded(const Plugin* plugin) { } Plugin::Plugin(QString path, bool isBuiltIn, QObject *p) - : QObject(p), - m_lib(path), - m_pluginPath(path), - m_pluginIsLoaded(false), - m_pluginLock(QReadWriteLock::NonRecursive), - m_pluginFnc(), - m_isBuiltIn(isBuiltIn), - m_positionalDataIsEnabled(true), - m_positionalDataIsActive(false), + : QObject(p), m_lib(path), m_pluginPath(path), m_pluginIsLoaded(false), m_pluginLock(QReadWriteLock::NonRecursive), + m_pluginFnc(), m_isBuiltIn(isBuiltIn), m_positionalDataIsEnabled(true), m_positionalDataIsActive(false), m_mayMonitorKeyboard(false) { // See if the plugin is loadable in the first place unless it is a built-in plugin m_pluginIsValid = isBuiltIn || m_lib.load(); @@ -66,7 +59,7 @@ QString Plugin::extractWrappedString(MumbleStringWrapper wrapper) const { QString wrappedString = QString::fromUtf8(wrapper.data, wrapper.size); if (wrapper.needsReleasing) { - releaseResource(static_cast<const void *>(wrapper.data)); + releaseResource(static_cast< const void * >(wrapper.data)); } return wrappedString; @@ -74,7 +67,7 @@ QString Plugin::extractWrappedString(MumbleStringWrapper wrapper) const { bool Plugin::doInitialize() { resolveFunctionPointers(); - + return m_pluginIsValid; } @@ -84,66 +77,107 @@ void Plugin::resolveFunctionPointers() { // the missing ones QWriteLocker lock(&m_pluginLock); - + // resolve the mandatory functions first - m_pluginFnc.init = reinterpret_cast<decltype(MumblePluginFunctions::init)>(m_lib.resolve("mumble_init")); - m_pluginFnc.shutdown = reinterpret_cast<decltype(MumblePluginFunctions::shutdown)>(m_lib.resolve("mumble_shutdown")); - m_pluginFnc.getName = reinterpret_cast<decltype(MumblePluginFunctions::getName)>(m_lib.resolve("mumble_getName")); - m_pluginFnc.getAPIVersion = reinterpret_cast<decltype(MumblePluginFunctions::getAPIVersion)>(m_lib.resolve("mumble_getAPIVersion")); - m_pluginFnc.registerAPIFunctions = reinterpret_cast<decltype(MumblePluginFunctions::registerAPIFunctions)>(m_lib.resolve("mumble_registerAPIFunctions")); - m_pluginFnc.releaseResource = reinterpret_cast<decltype(MumblePluginFunctions::releaseResource)>(m_lib.resolve("mumble_releaseResource")); + m_pluginFnc.init = reinterpret_cast< decltype(MumblePluginFunctions::init) >(m_lib.resolve("mumble_init")); + m_pluginFnc.shutdown = + reinterpret_cast< decltype(MumblePluginFunctions::shutdown) >(m_lib.resolve("mumble_shutdown")); + m_pluginFnc.getName = + reinterpret_cast< decltype(MumblePluginFunctions::getName) >(m_lib.resolve("mumble_getName")); + m_pluginFnc.getAPIVersion = + reinterpret_cast< decltype(MumblePluginFunctions::getAPIVersion) >(m_lib.resolve("mumble_getAPIVersion")); + m_pluginFnc.registerAPIFunctions = reinterpret_cast< decltype(MumblePluginFunctions::registerAPIFunctions) >( + m_lib.resolve("mumble_registerAPIFunctions")); + m_pluginFnc.releaseResource = reinterpret_cast< decltype(MumblePluginFunctions::releaseResource) >( + m_lib.resolve("mumble_releaseResource")); // validate that all those functions are available in the loaded lib m_pluginIsValid = m_pluginFnc.init && m_pluginFnc.shutdown && m_pluginFnc.getName && m_pluginFnc.getAPIVersion - && m_pluginFnc.registerAPIFunctions && m_pluginFnc.releaseResource; + && m_pluginFnc.registerAPIFunctions && m_pluginFnc.releaseResource; if (!m_pluginIsValid) { // Don't bother trying to resolve any other functions #ifdef MUMBLE_PLUGIN_DEBUG -#define CHECK_AND_LOG(name) if (!m_pluginFnc.name) { qDebug("\t\"%s\" is missing the %s() function", qPrintable(m_pluginPath), "mumble_" #name); } +# define CHECK_AND_LOG(name) \ + if (!m_pluginFnc.name) { \ + qDebug("\t\"%s\" is missing the %s() function", qPrintable(m_pluginPath), "mumble_" #name); \ + } CHECK_AND_LOG(init); CHECK_AND_LOG(shutdown); CHECK_AND_LOG(getName); CHECK_AND_LOG(getAPIVersion); CHECK_AND_LOG(registerAPIFunctions); CHECK_AND_LOG(releaseResource); -#undef CHECK_AND_LOG +# undef CHECK_AND_LOG #endif return; } // The mandatory functions are there, now see if any optional functions are implemented as well - m_pluginFnc.setMumbleInfo = reinterpret_cast<decltype(MumblePluginFunctions::setMumbleInfo)>(m_lib.resolve("mumble_setMumbleInfo")); - m_pluginFnc.getVersion = reinterpret_cast<decltype(MumblePluginFunctions::getVersion)>(m_lib.resolve("mumble_getVersion")); - m_pluginFnc.getAuthor = reinterpret_cast<decltype(MumblePluginFunctions::getAuthor)>(m_lib.resolve("mumble_getAuthor")); - m_pluginFnc.getDescription = reinterpret_cast<decltype(MumblePluginFunctions::getDescription)>(m_lib.resolve("mumble_getDescription")); - m_pluginFnc.getFeatures = reinterpret_cast<decltype(MumblePluginFunctions::getFeatures)>(m_lib.resolve("mumble_getFeatures")); - m_pluginFnc.deactivateFeatures = reinterpret_cast<decltype(MumblePluginFunctions::deactivateFeatures)>(m_lib.resolve("mumble_deactivateFeatures")); - m_pluginFnc.initPositionalData = reinterpret_cast<decltype(MumblePluginFunctions::initPositionalData)>(m_lib.resolve("mumble_initPositionalData")); - m_pluginFnc.fetchPositionalData = reinterpret_cast<decltype(MumblePluginFunctions::fetchPositionalData)>(m_lib.resolve("mumble_fetchPositionalData")); - m_pluginFnc.shutdownPositionalData = reinterpret_cast<decltype(MumblePluginFunctions::shutdownPositionalData)>(m_lib.resolve("mumble_shutdownPositionalData")); - m_pluginFnc.onServerConnected = reinterpret_cast<decltype(MumblePluginFunctions::onServerConnected)>(m_lib.resolve("mumble_onServerConnected")); - m_pluginFnc.onServerDisconnected = reinterpret_cast<decltype(MumblePluginFunctions::onServerDisconnected)>(m_lib.resolve("mumble_onServerDisconnected")); - m_pluginFnc.onChannelEntered = reinterpret_cast<decltype(MumblePluginFunctions::onChannelEntered)>(m_lib.resolve("mumble_onChannelEntered")); - m_pluginFnc.onChannelExited = reinterpret_cast<decltype(MumblePluginFunctions::onChannelExited)>(m_lib.resolve("mumble_onChannelExited")); - m_pluginFnc.onUserTalkingStateChanged = reinterpret_cast<decltype(MumblePluginFunctions::onUserTalkingStateChanged)>(m_lib.resolve("mumble_onUserTalkingStateChanged")); - m_pluginFnc.onReceiveData = reinterpret_cast<decltype(MumblePluginFunctions::onReceiveData)>(m_lib.resolve("mumble_onReceiveData")); - m_pluginFnc.onAudioInput = reinterpret_cast<decltype(MumblePluginFunctions::onAudioInput)>(m_lib.resolve("mumble_onAudioInput")); - m_pluginFnc.onAudioSourceFetched = reinterpret_cast<decltype(MumblePluginFunctions::onAudioSourceFetched)>(m_lib.resolve("mumble_onAudioSourceFetched")); - m_pluginFnc.onAudioOutputAboutToPlay = reinterpret_cast<decltype(MumblePluginFunctions::onAudioOutputAboutToPlay)>(m_lib.resolve("mumble_onAudioOutputAboutToPlay")); - m_pluginFnc.onServerSynchronized = reinterpret_cast<decltype(MumblePluginFunctions::onServerSynchronized)>(m_lib.resolve("mumble_onServerSynchronized")); - m_pluginFnc.onUserAdded = reinterpret_cast<decltype(MumblePluginFunctions::onUserAdded)>(m_lib.resolve("mumble_onUserAdded")); - m_pluginFnc.onUserRemoved = reinterpret_cast<decltype(MumblePluginFunctions::onUserRemoved)>(m_lib.resolve("mumble_onUserRemoved")); - m_pluginFnc.onChannelAdded = reinterpret_cast<decltype(MumblePluginFunctions::onChannelAdded)>(m_lib.resolve("mumble_onChannelAdded")); - m_pluginFnc.onChannelRemoved = reinterpret_cast<decltype(MumblePluginFunctions::onChannelRemoved)>(m_lib.resolve("mumble_onChannelRemoved")); - m_pluginFnc.onChannelRenamed = reinterpret_cast<decltype(MumblePluginFunctions::onChannelRenamed)>(m_lib.resolve("mumble_onChannelRenamed")); - m_pluginFnc.onKeyEvent = reinterpret_cast<decltype(MumblePluginFunctions::onKeyEvent)>(m_lib.resolve("mumble_onKeyEvent")); - m_pluginFnc.hasUpdate = reinterpret_cast<decltype(MumblePluginFunctions::hasUpdate)>(m_lib.resolve("mumble_hasUpdate")); - m_pluginFnc.getUpdateDownloadURL = reinterpret_cast<decltype(MumblePluginFunctions::getUpdateDownloadURL)>(m_lib.resolve("mumble_getUpdateDownloadURL")); + m_pluginFnc.setMumbleInfo = + reinterpret_cast< decltype(MumblePluginFunctions::setMumbleInfo) >(m_lib.resolve("mumble_setMumbleInfo")); + m_pluginFnc.getVersion = + reinterpret_cast< decltype(MumblePluginFunctions::getVersion) >(m_lib.resolve("mumble_getVersion")); + m_pluginFnc.getAuthor = + reinterpret_cast< decltype(MumblePluginFunctions::getAuthor) >(m_lib.resolve("mumble_getAuthor")); + m_pluginFnc.getDescription = + reinterpret_cast< decltype(MumblePluginFunctions::getDescription) >(m_lib.resolve("mumble_getDescription")); + m_pluginFnc.getFeatures = + reinterpret_cast< decltype(MumblePluginFunctions::getFeatures) >(m_lib.resolve("mumble_getFeatures")); + m_pluginFnc.deactivateFeatures = reinterpret_cast< decltype(MumblePluginFunctions::deactivateFeatures) >( + m_lib.resolve("mumble_deactivateFeatures")); + m_pluginFnc.initPositionalData = reinterpret_cast< decltype(MumblePluginFunctions::initPositionalData) >( + m_lib.resolve("mumble_initPositionalData")); + m_pluginFnc.fetchPositionalData = reinterpret_cast< decltype(MumblePluginFunctions::fetchPositionalData) >( + m_lib.resolve("mumble_fetchPositionalData")); + m_pluginFnc.shutdownPositionalData = + reinterpret_cast< decltype(MumblePluginFunctions::shutdownPositionalData) >( + m_lib.resolve("mumble_shutdownPositionalData")); + m_pluginFnc.onServerConnected = reinterpret_cast< decltype(MumblePluginFunctions::onServerConnected) >( + m_lib.resolve("mumble_onServerConnected")); + m_pluginFnc.onServerDisconnected = reinterpret_cast< decltype(MumblePluginFunctions::onServerDisconnected) >( + m_lib.resolve("mumble_onServerDisconnected")); + m_pluginFnc.onChannelEntered = reinterpret_cast< decltype(MumblePluginFunctions::onChannelEntered) >( + m_lib.resolve("mumble_onChannelEntered")); + m_pluginFnc.onChannelExited = reinterpret_cast< decltype(MumblePluginFunctions::onChannelExited) >( + m_lib.resolve("mumble_onChannelExited")); + m_pluginFnc.onUserTalkingStateChanged = + reinterpret_cast< decltype(MumblePluginFunctions::onUserTalkingStateChanged) >( + m_lib.resolve("mumble_onUserTalkingStateChanged")); + m_pluginFnc.onReceiveData = + reinterpret_cast< decltype(MumblePluginFunctions::onReceiveData) >(m_lib.resolve("mumble_onReceiveData")); + m_pluginFnc.onAudioInput = + reinterpret_cast< decltype(MumblePluginFunctions::onAudioInput) >(m_lib.resolve("mumble_onAudioInput")); + m_pluginFnc.onAudioSourceFetched = reinterpret_cast< decltype(MumblePluginFunctions::onAudioSourceFetched) >( + m_lib.resolve("mumble_onAudioSourceFetched")); + m_pluginFnc.onAudioOutputAboutToPlay = + reinterpret_cast< decltype(MumblePluginFunctions::onAudioOutputAboutToPlay) >( + m_lib.resolve("mumble_onAudioOutputAboutToPlay")); + m_pluginFnc.onServerSynchronized = reinterpret_cast< decltype(MumblePluginFunctions::onServerSynchronized) >( + m_lib.resolve("mumble_onServerSynchronized")); + m_pluginFnc.onUserAdded = + reinterpret_cast< decltype(MumblePluginFunctions::onUserAdded) >(m_lib.resolve("mumble_onUserAdded")); + m_pluginFnc.onUserRemoved = + reinterpret_cast< decltype(MumblePluginFunctions::onUserRemoved) >(m_lib.resolve("mumble_onUserRemoved")); + m_pluginFnc.onChannelAdded = + reinterpret_cast< decltype(MumblePluginFunctions::onChannelAdded) >(m_lib.resolve("mumble_onChannelAdded")); + m_pluginFnc.onChannelRemoved = reinterpret_cast< decltype(MumblePluginFunctions::onChannelRemoved) >( + m_lib.resolve("mumble_onChannelRemoved")); + m_pluginFnc.onChannelRenamed = reinterpret_cast< decltype(MumblePluginFunctions::onChannelRenamed) >( + m_lib.resolve("mumble_onChannelRenamed")); + m_pluginFnc.onKeyEvent = + reinterpret_cast< decltype(MumblePluginFunctions::onKeyEvent) >(m_lib.resolve("mumble_onKeyEvent")); + m_pluginFnc.hasUpdate = + reinterpret_cast< decltype(MumblePluginFunctions::hasUpdate) >(m_lib.resolve("mumble_hasUpdate")); + m_pluginFnc.getUpdateDownloadURL = reinterpret_cast< decltype(MumblePluginFunctions::getUpdateDownloadURL) >( + m_lib.resolve("mumble_getUpdateDownloadURL")); #ifdef MUMBLE_PLUGIN_DEBUG -#define CHECK_AND_LOG(name) qDebug("\t" "mumble_" #name ": %s", (m_pluginFnc.name == nullptr ? "no" : "yes")) +# define CHECK_AND_LOG(name) \ + qDebug("\t" \ + "mumble_" #name ": %s", \ + (m_pluginFnc.name == nullptr ? "no" : "yes")) qDebug(">>>> Found optional functions for plugin \"%s\"", qUtf8Printable(m_pluginPath)); CHECK_AND_LOG(setMumbleInfo); CHECK_AND_LOG(getVersion); @@ -178,12 +212,14 @@ void Plugin::resolveFunctionPointers() { // If positional audio is to be supported, all three corresponding functions have to be implemented // For PA it is all or nothing if (!(m_pluginFnc.initPositionalData && m_pluginFnc.fetchPositionalData && m_pluginFnc.shutdownPositionalData) - && (m_pluginFnc.initPositionalData || m_pluginFnc.fetchPositionalData || m_pluginFnc.shutdownPositionalData)) { - m_pluginFnc.initPositionalData = nullptr; - m_pluginFnc.fetchPositionalData = nullptr; + && (m_pluginFnc.initPositionalData || m_pluginFnc.fetchPositionalData + || m_pluginFnc.shutdownPositionalData)) { + m_pluginFnc.initPositionalData = nullptr; + m_pluginFnc.fetchPositionalData = nullptr; m_pluginFnc.shutdownPositionalData = nullptr; #ifdef MUMBLE_PLUGIN_DEBUG - qDebug("\t\"%s\" has only partially implemented positional data functions -> deactivating all of them", qPrintable(m_pluginPath)); + qDebug("\t\"%s\" has only partially implemented positional data functions -> deactivating all of them", + qPrintable(m_pluginPath)); #endif } } @@ -272,11 +308,12 @@ mumble_error_t Plugin::init() { ////////////////////////////// // Step 2: Provide the API functions to the plugin const mumble_version_t apiVersion = getAPIVersion(); - if (apiVersion >= mumble_version_t({1, 0, 0}) && apiVersion < mumble_version_t({1, 2, 0})) { + if (apiVersion >= mumble_version_t({ 1, 0, 0 }) && apiVersion < mumble_version_t({ 1, 2, 0 })) { MumbleAPI_v_1_0_x api = API::getMumbleAPI_v_1_0_x(); registerAPIFunctions(&api); } else { - // The API version could not be obtained -> this is an invalid plugin that shouldn't have been loaded in the first place + // The API version could not be obtained -> this is an invalid plugin that shouldn't have been loaded in the + // first place qWarning("Unable to obtain requested MumbleAPI version"); return EC_INVALID_API_VERSION; } @@ -354,7 +391,8 @@ void Plugin::releaseResource(const void *pointer) const { } } -void Plugin::setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, mumble_version_t minimalExpectedAPIVersion) const { +void Plugin::setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, + mumble_version_t minimalExpectedAPIVersion) const { if (m_pluginFnc.setMumbleInfo) { m_pluginFnc.setMumbleInfo(mumbleVersion, mumbleAPIVersion, minimalExpectedAPIVersion); } @@ -416,7 +454,7 @@ bool Plugin::showConfigDialog(QWidget *parent) const { return false; } -uint8_t Plugin::initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount) { +uint8_t Plugin::initPositionalData(const char *const *programNames, const uint64_t *programPIDs, size_t programCount) { assertPluginLoaded(this); if (m_pluginFnc.initPositionalData) { @@ -433,19 +471,21 @@ uint8_t Plugin::initPositionalData(const char *const*programNames, const uint64_ } } -bool Plugin::fetchPositionalData(Position3D& avatarPos, Vector3D& avatarDir, Vector3D& avatarAxis, Position3D& cameraPos, Vector3D& cameraDir, - Vector3D& cameraAxis, QString& context, QString& identity) const { +bool Plugin::fetchPositionalData(Position3D &avatarPos, Vector3D &avatarDir, Vector3D &avatarAxis, + Position3D &cameraPos, Vector3D &cameraDir, Vector3D &cameraAxis, QString &context, + QString &identity) const { assertPluginLoaded(this); if (m_pluginFnc.fetchPositionalData) { - const char *contextPtr = ""; + const char *contextPtr = ""; const char *identityPtr = ""; - bool retStatus = m_pluginFnc.fetchPositionalData(static_cast<float*>(avatarPos), static_cast<float*>(avatarDir), - static_cast<float*>(avatarAxis), static_cast<float*>(cameraPos), static_cast<float*>(cameraDir), static_cast<float*>(cameraAxis), - &contextPtr, &identityPtr); + bool retStatus = m_pluginFnc.fetchPositionalData( + static_cast< float * >(avatarPos), static_cast< float * >(avatarDir), static_cast< float * >(avatarAxis), + static_cast< float * >(cameraPos), static_cast< float * >(cameraDir), static_cast< float * >(cameraAxis), + &contextPtr, &identityPtr); - context = QString::fromUtf8(contextPtr); + context = QString::fromUtf8(contextPtr); identity = QString::fromUtf8(identityPtr); return retStatus; @@ -456,9 +496,9 @@ bool Plugin::fetchPositionalData(Position3D& avatarPos, Vector3D& avatarDir, Vec cameraPos.toZero(); cameraDir.toZero(); cameraAxis.toZero(); - context = QString(); + context = QString(); identity = QString(); - + return false; } } @@ -489,8 +529,8 @@ void Plugin::onServerDisconnected(mumble_connection_t connection) const { } } -void Plugin::onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t previousChannelID, - mumble_channelid_t newChannelID) const { +void Plugin::onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t previousChannelID, mumble_channelid_t newChannelID) const { assertPluginLoaded(this); if (m_pluginFnc.onChannelEntered) { @@ -498,7 +538,8 @@ void Plugin::onChannelEntered(mumble_connection_t connection, mumble_userid_t us } } -void Plugin::onChannelExited(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t channelID) const { +void Plugin::onChannelExited(mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t channelID) const { assertPluginLoaded(this); if (m_pluginFnc.onChannelExited) { @@ -506,7 +547,8 @@ void Plugin::onChannelExited(mumble_connection_t connection, mumble_userid_t use } } -void Plugin::onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, mumble_talking_state_t talkingState) const { +void Plugin::onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, + mumble_talking_state_t talkingState) const { assertPluginLoaded(this); if (m_pluginFnc.onUserTalkingStateChanged) { @@ -514,7 +556,8 @@ void Plugin::onUserTalkingStateChanged(mumble_connection_t connection, mumble_us } } -bool Plugin::onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, size_t dataLength, const char *dataID) const { +bool Plugin::onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, + size_t dataLength, const char *dataID) const { assertPluginLoaded(this); if (m_pluginFnc.onReceiveData) { @@ -524,7 +567,8 @@ bool Plugin::onReceiveData(mumble_connection_t connection, mumble_userid_t sende } } -bool Plugin::onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech) const { +bool Plugin::onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, + bool isSpeech) const { assertPluginLoaded(this); if (m_pluginFnc.onAudioInput) { @@ -534,7 +578,8 @@ bool Plugin::onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channe } } -bool Plugin::onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech, mumble_userid_t userID) const { +bool Plugin::onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, + bool isSpeech, mumble_userid_t userID) const { assertPluginLoaded(this); if (m_pluginFnc.onAudioSourceFetched) { @@ -544,7 +589,8 @@ bool Plugin::onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16 } } -bool Plugin::onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate) const { +bool Plugin::onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, + uint32_t sampleRate) const { assertPluginLoaded(this); if (m_pluginFnc.onAudioOutputAboutToPlay) { @@ -645,9 +691,7 @@ bool Plugin::providesConfigDialog() const { /////////////////// Implementation of the PluginReadLocker ///////////////////////// -PluginReadLocker::PluginReadLocker(QReadWriteLock *lock) - : m_lock(lock), - m_unlocked(false) { +PluginReadLocker::PluginReadLocker(QReadWriteLock *lock) : m_lock(lock), m_unlocked(false) { relock(); } @@ -671,14 +715,14 @@ void PluginReadLocker::relock() { // First try to lock for read-access if (!m_lock->tryLockForRead()) { // if that fails, we'll try to lock for write-access - // That will only succeed in the case that the current thread holds the write-access to this lock already which caused - // the previous attempt to lock for reading to fail (by design of the QtReadWriteLock). - // As we are in the thread with the write-access, it means that this threads has asked for read-access on top of it which we will - // grant (in contrast of QtReadLocker) because if you have the permission to change something you surely should have permission - // to read it. This assumes that the thread won't try to read data it temporarily has corrupted. + // That will only succeed in the case that the current thread holds the write-access to this lock already which + // caused the previous attempt to lock for reading to fail (by design of the QtReadWriteLock). As we are in the + // thread with the write-access, it means that this threads has asked for read-access on top of it which we will + // grant (in contrast of QtReadLocker) because if you have the permission to change something you surely should + // have permission to read it. This assumes that the thread won't try to read data it temporarily has corrupted. if (!m_lock->tryLockForWrite()) { - // If we couldn't lock for write at this point, it means another thread has write-access granted by the lock so we'll have to wait - // in order to gain regular read-access as would be with QtReadLocker + // If we couldn't lock for write at this point, it means another thread has write-access granted by the lock + // so we'll have to wait in order to gain regular read-access as would be with QtReadLocker m_lock->lockForRead(); } } diff --git a/src/mumble/Plugin.h b/src/mumble/Plugin.h index 049e622f2..28324cc83 100644 --- a/src/mumble/Plugin.h +++ b/src/mumble/Plugin.h @@ -7,96 +7,97 @@ #define MUMBLE_MUMBLE_PLUGIN_H_ #include "MumbleAPI_v_1_0_x.h" +#include "MumblePlugin_v_1_0_x.h" #include "PluginComponents_v_1_0_x.h" #include "PositionalData.h" -#include "MumblePlugin_v_1_0_x.h" +#include <QLibrary> +#include <QMutex> #include <QObject> #include <QReadWriteLock> #include <QString> -#include <QLibrary> -#include <QMutex> #include <QUrl> -#include <stdexcept> #include <memory> +#include <stdexcept> /// A struct for holding the function pointers to the functions inside the plugin's library /// For the documentation of those functions, see the plugin's header file (the one used when developing a plugin) struct MumblePluginFunctions { - decltype(&mumble_init) init; - decltype(&mumble_shutdown) shutdown; - decltype(&mumble_getName) getName; - decltype(&mumble_getAPIVersion) getAPIVersion; - decltype(&mumble_registerAPIFunctions) registerAPIFunctions; - decltype(&mumble_releaseResource) releaseResource; - - // Further utility functions the plugin may implement - decltype(&mumble_setMumbleInfo) setMumbleInfo; - decltype(&mumble_getVersion) getVersion; - decltype(&mumble_getAuthor) getAuthor; - decltype(&mumble_getDescription) getDescription; - decltype(&mumble_getFeatures) getFeatures; - decltype(&mumble_deactivateFeatures) deactivateFeatures; - - // Functions for dealing with positional audio (or rather the fetching of the needed data) - decltype(&mumble_initPositionalData) initPositionalData; - decltype(&mumble_fetchPositionalData) fetchPositionalData; - decltype(&mumble_shutdownPositionalData) shutdownPositionalData; - - // Callback functions and EventHandlers - decltype(&mumble_onServerConnected) onServerConnected; - decltype(&mumble_onServerDisconnected) onServerDisconnected; - decltype(&mumble_onChannelEntered) onChannelEntered; - decltype(&mumble_onChannelExited) onChannelExited; - decltype(&mumble_onUserTalkingStateChanged) onUserTalkingStateChanged; - decltype(&mumble_onReceiveData) onReceiveData; - decltype(&mumble_onAudioInput) onAudioInput; - decltype(&mumble_onAudioSourceFetched) onAudioSourceFetched; - decltype(&mumble_onAudioOutputAboutToPlay) onAudioOutputAboutToPlay; - decltype(&mumble_onServerSynchronized) onServerSynchronized; - decltype(&mumble_onUserAdded) onUserAdded; - decltype(&mumble_onUserRemoved) onUserRemoved; - decltype(&mumble_onChannelAdded) onChannelAdded; - decltype(&mumble_onChannelRemoved) onChannelRemoved; - decltype(&mumble_onChannelRenamed) onChannelRenamed; - decltype(&mumble_onKeyEvent) onKeyEvent; - - // Plugin updates - decltype(&mumble_hasUpdate) hasUpdate; - decltype(&mumble_getUpdateDownloadURL) getUpdateDownloadURL; + decltype(&mumble_init) init; + decltype(&mumble_shutdown) shutdown; + decltype(&mumble_getName) getName; + decltype(&mumble_getAPIVersion) getAPIVersion; + decltype(&mumble_registerAPIFunctions) registerAPIFunctions; + decltype(&mumble_releaseResource) releaseResource; + + // Further utility functions the plugin may implement + decltype(&mumble_setMumbleInfo) setMumbleInfo; + decltype(&mumble_getVersion) getVersion; + decltype(&mumble_getAuthor) getAuthor; + decltype(&mumble_getDescription) getDescription; + decltype(&mumble_getFeatures) getFeatures; + decltype(&mumble_deactivateFeatures) deactivateFeatures; + + // Functions for dealing with positional audio (or rather the fetching of the needed data) + decltype(&mumble_initPositionalData) initPositionalData; + decltype(&mumble_fetchPositionalData) fetchPositionalData; + decltype(&mumble_shutdownPositionalData) shutdownPositionalData; + + // Callback functions and EventHandlers + decltype(&mumble_onServerConnected) onServerConnected; + decltype(&mumble_onServerDisconnected) onServerDisconnected; + decltype(&mumble_onChannelEntered) onChannelEntered; + decltype(&mumble_onChannelExited) onChannelExited; + decltype(&mumble_onUserTalkingStateChanged) onUserTalkingStateChanged; + decltype(&mumble_onReceiveData) onReceiveData; + decltype(&mumble_onAudioInput) onAudioInput; + decltype(&mumble_onAudioSourceFetched) onAudioSourceFetched; + decltype(&mumble_onAudioOutputAboutToPlay) onAudioOutputAboutToPlay; + decltype(&mumble_onServerSynchronized) onServerSynchronized; + decltype(&mumble_onUserAdded) onUserAdded; + decltype(&mumble_onUserRemoved) onUserRemoved; + decltype(&mumble_onChannelAdded) onChannelAdded; + decltype(&mumble_onChannelRemoved) onChannelRemoved; + decltype(&mumble_onChannelRenamed) onChannelRenamed; + decltype(&mumble_onKeyEvent) onKeyEvent; + + // Plugin updates + decltype(&mumble_hasUpdate) hasUpdate; + decltype(&mumble_getUpdateDownloadURL) getUpdateDownloadURL; }; /// An exception that is being thrown by a plugin whenever it encounters an error class PluginError : public std::runtime_error { - public: - // inherit constructors of runtime_error - using std::runtime_error::runtime_error; +public: + // inherit constructors of runtime_error + using std::runtime_error::runtime_error; }; /// An implementation similar to QReadLocker except that this one allows to lock on a lock the same thread is already -/// holding a write-lock on. This could also result in obtaining a write-lock though so it shouldn't be used for code regions -/// that take quite some time and rely on other readers still having access to the locked object. +/// holding a write-lock on. This could also result in obtaining a write-lock though so it shouldn't be used for code +/// regions that take quite some time and rely on other readers still having access to the locked object. class PluginReadLocker { - protected: - /// The lock this lock-guard is acting upon - QReadWriteLock *m_lock; - /// A flag indicating whether the lock has been unlocked (manually) and thus doesn't have to be unlocked - /// in the destructor. - bool m_unlocked; - public: - /// Constructor of the PluginReadLocker. If the passed lock-pointer is not nullptr, the constructor will - /// already lock the provided lock. - /// - /// @param lock A pointer to the QReadWriteLock that shall be managed by this object. May be nullptr - PluginReadLocker(QReadWriteLock *lock); - /// Locks this lock again after it has been unlocked before (Locking a locked lock results in a runtime error) - void relock(); - /// Unlocks this lock - void unlock(); - ~PluginReadLocker(); +protected: + /// The lock this lock-guard is acting upon + QReadWriteLock *m_lock; + /// A flag indicating whether the lock has been unlocked (manually) and thus doesn't have to be unlocked + /// in the destructor. + bool m_unlocked; + +public: + /// Constructor of the PluginReadLocker. If the passed lock-pointer is not nullptr, the constructor will + /// already lock the provided lock. + /// + /// @param lock A pointer to the QReadWriteLock that shall be managed by this object. May be nullptr + PluginReadLocker(QReadWriteLock *lock); + /// Locks this lock again after it has been unlocked before (Locking a locked lock results in a runtime error) + void relock(); + /// Unlocks this lock + void unlock(); + ~PluginReadLocker(); }; class Plugin; @@ -104,314 +105,328 @@ class Plugin; /// Typedef for the plugin ID typedef uint32_t plugin_id_t; /// Typedef for a plugin pointer -typedef std::shared_ptr<Plugin> plugin_ptr_t; +typedef std::shared_ptr< Plugin > plugin_ptr_t; /// Typedef for a const plugin pointer -typedef std::shared_ptr<const Plugin> const_plugin_ptr_t; +typedef std::shared_ptr< const Plugin > const_plugin_ptr_t; -/// A class representing a plugin library attached to Mumble. It can be used to manage (load/unload) and access plugin libraries. +/// A class representing a plugin library attached to Mumble. It can be used to manage (load/unload) and access plugin +/// libraries. class Plugin : public QObject { friend class PluginManager; friend class PluginConfig; - private: - Q_OBJECT - Q_DISABLE_COPY(Plugin) - protected: - /// A mutex guarding Plugin::nextID - static QMutex s_idLock; - /// The ID of the plugin that will be loaded next. Whenever accessing this field, Plugin::idLock should be locked. - static plugin_id_t s_nextID; - - /// Constructor of the Plugin. - /// - /// @param path The path to the plugin's shared library file. This path has to exist unless isBuiltIn is true - /// @param isBuiltIn A flag indicating that this is a plugin built into Mumble itself and is does not backed by a shared library - /// @param p A pointer to a QObject representing the parent of this object or nullptr if there is no parent - Plugin(QString path, bool isBuiltIn = false, QObject *p = nullptr); - - /// A flag indicating whether this plugin is valid. It is mainly used throughout the plugin's initialization. - bool m_pluginIsValid; - /// The QLibrary representing the shared library of this plugin - QLibrary m_lib; - /// The path to the shared library file in the host's filesystem - QString m_pluginPath; - /// The unique ID of this plugin. Note though that this ID is not suitable for uniquely identifying this plugin between restarts of Mumble - /// (not even between rescans of the plugins) let alone across clients. - plugin_id_t m_pluginID; - // a flag indicating whether this plugin has been loaded by calling its init function. - bool m_pluginIsLoaded; - /// The lock guarding this plugin object. Every time a member is accessed this lock should be locked accordingly. - /// After successful construction and initialization (doInitilize()), this member variable is effectively const - /// and therefore no locking is required in order to read from it! - /// In fact protecting read-accesses by a non-recursive lock can introduce deadlocks by plugins using certain - /// API functions. - mutable QReadWriteLock m_pluginLock; - /// The struct holding the function pointers to the functions in the shared library. - MumblePluginFunctions m_pluginFnc; - /// A flag indicating whether this plugin is built into Mumble and is thus not represented by a shared library. - bool m_isBuiltIn; - /// A flag indicating whether positional data gathering is enabled for this plugin (Enabled as in allowed via preferences). - bool m_positionalDataIsEnabled; - /// A flag indicating whether positional data gathering is currently active (Active as in running) - bool m_positionalDataIsActive; - /// A flag indicating whether this plugin has permission to monitor keyboard events that occur while - /// Mumble has the keyboard focus. - bool m_mayMonitorKeyboard; - - - QString extractWrappedString(MumbleStringWrapper wrapper) const; - - - // Most of this class's functions are protected in order to only allow access to them via the PluginManager - // as some require additional handling before/after calling them. - - /// Initializes this plugin. This function must be called directly after construction. This is guaranteed when the - /// plugin is created via Plugin::createNew - virtual bool doInitialize(); - /// Resolves the function pointers in the shared library and sets the respective fields in Plugin::apiFnc - virtual void resolveFunctionPointers(); - /// Enables positional data gathering for this plugin (as in allowing) - /// - /// @param enable Whether to enable the data gathering - virtual void enablePositionalData(bool enable = true); - /// Allows or forbids the monitoring of keyboard events for this plugin. - /// - /// @param allow Whether to allow or forbid it - virtual void allowKeyboardMonitoring(bool allow); - - - /// Initializes this plugin - virtual mumble_error_t init(); - /// Shuts this plugin down - virtual void shutdown(); - /// Delegates the struct of API function pointers to the plugin backend - /// - /// @param api The pointer to the API struct - virtual void registerAPIFunctions(void *api) const; - /// Asks the plugin to release (free/delete) the resource pointed to by the given pointer - /// - /// @param pointer Pointer to the resource - virtual void releaseResource(const void *pointer) const; - /// Provides the plugin backend with some version information about Mumble - /// - /// @param mumbleVersion The version of the Mumble client - /// @param mumbleAPIVersion The API version used by the Mumble client - /// @param minimalExpectedAPIVersion The minimal API version expected to be used by the plugin backend - virtual void setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, mumble_version_t minimalExpectedAPIVersion) const; - /// Asks the plugin to deactivate certain features - /// - /// @param features The feature list or'ed together - /// @returns The list of features that couldn't be deactivated or'ed together - virtual uint32_t deactivateFeatures(uint32_t features) const; - /// Shows an about-dialog - /// - /// @parent A pointer to the QWidget that should be used as a parent - /// @returns Whether the dialog could be shown successfully - virtual bool showAboutDialog(QWidget *parent) const; - /// Shows a config-dialog - /// - /// @parent A pointer to the QWidget that should be used as a parent - /// @returns Whether the dialog could be shown successfully - virtual bool showConfigDialog(QWidget *parent) const; - /// Initializes the positional data gathering - /// - /// @params programNames A pointer to an array of const char* representing the program names - /// @params programCount A pointer to an array of PIDs corresponding to the program names - /// @params programCount The length of the two previous arrays - virtual uint8_t initPositionalData(const char *const*programNames, const uint64_t *programPIDs, size_t programCount); - /// Fetches the positional data - /// - /// @param[out] avatarPos The position of the ingame avatar (player) - /// @param[out] avatarDir The directiion in which the avatar (player) is looking/facing - /// @param[out] avatarAxis The vector from the avatar's toes to its head - /// @param[out] cameraPos The position of the ingame camera - /// @param[out] cameraDir The direction in which the camera is looking/facing - /// @param[out] cameraAxis The vector from the camera's bottom to its top - /// @param[out] context The context of the current game-session (includes server/squad info) - /// @param[out] identity The ingame identity of the player (name) - virtual bool fetchPositionalData(Position3D& avatarPos, Vector3D& avatarDir, Vector3D& avatarAxis, Position3D& cameraPos, Vector3D& cameraDir, - Vector3D& cameraAxis, QString& context, QString& identity) const; - /// Shuts down positional data gathering - virtual void shutdownPositionalData(); - /// Called to indicate that the client has connected to a server - /// - /// @param connection An object used to identify the current connection - virtual void onServerConnected(mumble_connection_t connection) const; - /// Called to indicate that the client disconnected from a server - /// - /// @param connection An object used to identify the connection that has been disconnected - virtual void onServerDisconnected(mumble_connection_t connection) const; - /// Called to indicate that a user has switched its channel - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that switched channel - /// @param previousChannelID The ID of the channel the user came from (-1 if there is no previous channel) - /// æparam newChannelID The ID of the channel the user has switched to - virtual void onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t previousChannelID, - mumble_channelid_t newChannelID) const; - /// Called to indicate that a user exited a channel. - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that switched channel - /// @param channelID The ID of the channel the user exited - virtual void onChannelExited(mumble_connection_t connection, mumble_userid_t userID, mumble_channelid_t channelID) const; - /// Called to indicate that a user has changed its talking state - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that switched channel - /// @param talkingState The new talking state of the user - virtual void onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, mumble_talking_state_t talkingState) const; - /// Called to indicate that a data packet has been received - /// - /// @param connection An object used to identify the current connection - /// @param sender The ID of the user whose client sent the data - /// @param data The actual data - /// @param dataLength The length of the data array - /// @param datID The ID of the data used to determine whether this plugin handles this data or not - /// @returns Whether this plugin handled the data - virtual bool onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, size_t dataLength, const char *dataID) const; - /// Called to indicate that there is audio input - /// - /// @param inputPCM A pointer to a short array representing the input PCM - /// @param sampleCount The amount of samples per channel - /// @param channelCount The amount of channels in the PCM - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech Whether Mumble considers the input as speech - /// @returns Whether this pluign has modified the audio - virtual bool onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech) const; - /// Called to indicate that an audio source has been fetched - /// - /// @param outputPCM A pointer to a short array representing the output PCM - /// @param sampleCount The amount of samples per channel - /// @param channelCount The amount of channels in the PCM - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech Whether Mumble considers the output as speech - /// @param userID The ID of the user responsible for the output (only relevant if isSpeech == true) - /// @returns Whether this pluign has modified the audio - virtual bool onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, bool isSpeech, mumble_userid_t userID) const; - /// Called to indicate that audio is about to be played - /// - /// @param outputPCM A pointer to a short array representing the output PCM - /// @param sampleCount The amount of samples per channel - /// @param channelCount The amount of channels in the PCM - /// @param sampleRate The used sample rate in Hz - /// @returns Whether this pluign has modified the audio - virtual bool onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate) const; - /// Called when the server has synchronized with the client - /// - /// @param connection An object used to identify the current connection - virtual void onServerSynchronized(mumble_connection_t connection) const; - /// Called when a new user gets added to the user model. This is the case when that new user freshly connects to the server the - /// local user is on but also when the local user connects to a server other clients are already connected to (in this case this - /// method will be called for every client already on that server). - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that has been added - virtual void onUserAdded(mumble_connection_t connection, mumble_userid_t userID) const; - /// Called when a user gets removed from the user model. This is the case when that user disconnects from the server the - /// local user is on but also when the local user disconnects from a server other clients are connected to (in this case this - /// method will be called for every client on that server). - /// - /// @param connection An object used to identify the current connection - /// @param userID The ID of the user that has been removed - virtual void onUserRemoved(mumble_connection_t connection, mumble_userid_t userID) const; - /// Called when a new channel gets added to the user model. This is the case when a new channel is created on the server the local - /// user is on but also when the local user connects to a server that contains channels other than the root-channel (in this case - /// this method will be called for ever non-root channel on that server). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been added - virtual void onChannelAdded(mumble_connection_t connection, mumble_channelid_t channelID) const; - /// Called when a channel gets removed from the user model. This is the case when a channel is removed on the server the local - /// user is on but also when the local user disconnects from a server that contains channels other than the root-channel (in this case - /// this method will be called for ever non-root channel on that server). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been removed - virtual void onChannelRemoved(mumble_connection_t connection, mumble_channelid_t channelID) const; - /// Called when a channel gets renamed. This also applies when a new channel is created (thus assigning it an initial name is - /// also considered renaming). - /// - /// @param connection An object used to identify the current connection - /// @param channelID The ID of the channel that has been renamed - virtual void onChannelRenamed(mumble_connection_t connection, mumble_channelid_t channelID) const; - /// Called when a key has been pressed or released while Mumble has keyboard focus. - /// - /// @param keyCode The key code of the respective key. The character codes are defined - /// via the KeyCode enum. For printable 7-bit ASCII characters these codes conform - /// to the ASCII code-page with the only difference that case is not distinguished. Therefore - /// always the upper-case letter code will be used for letters. - /// @param wasPress Whether the key has been pressed (instead of released) - virtual void onKeyEvent(mumble_keycode_t keyCode, bool wasPress) const; - - - public: - /// A template function for instantiating new plugin objects and initializing them. The plugin will be allocated on the heap and has - /// thus to be deleted via the delete instruction. - /// - /// @tparam T The type of the plugin to be instantiated - /// @tparam Ts The types of the contructor arguments - /// @param args A list of args passed to the contructor of the plugin object - /// @returns A pointer to the allocated plugin - /// - /// @throws PluginError if the plugin could not be loaded - template<typename T, typename ... Ts> - static T* createNew(Ts&&...args) { - static_assert(std::is_base_of<Plugin, T>::value, "The Plugin::create() can only be used to instantiate objects of base-type Plugin"); - static_assert(!std::is_pointer<T>::value, "Plugin::create() can't be used to instantiate pointers. It will return a pointer automatically"); - - T *instancePtr = new T(std::forward<Ts>(args)...); - - // call the initialize-method and throw an exception of it doesn't succeed - if (!instancePtr->doInitialize()) { - delete instancePtr; - // Delete the constructed object to prevent a memory leak - throw PluginError("Failed to initialize plugin"); - } - - return instancePtr; +private: + Q_OBJECT + Q_DISABLE_COPY(Plugin) +protected: + /// A mutex guarding Plugin::nextID + static QMutex s_idLock; + /// The ID of the plugin that will be loaded next. Whenever accessing this field, Plugin::idLock should be locked. + static plugin_id_t s_nextID; + + /// Constructor of the Plugin. + /// + /// @param path The path to the plugin's shared library file. This path has to exist unless isBuiltIn is true + /// @param isBuiltIn A flag indicating that this is a plugin built into Mumble itself and is does not backed by a + /// shared library + /// @param p A pointer to a QObject representing the parent of this object or nullptr if there is no parent + Plugin(QString path, bool isBuiltIn = false, QObject *p = nullptr); + + /// A flag indicating whether this plugin is valid. It is mainly used throughout the plugin's initialization. + bool m_pluginIsValid; + /// The QLibrary representing the shared library of this plugin + QLibrary m_lib; + /// The path to the shared library file in the host's filesystem + QString m_pluginPath; + /// The unique ID of this plugin. Note though that this ID is not suitable for uniquely identifying this plugin + /// between restarts of Mumble (not even between rescans of the plugins) let alone across clients. + plugin_id_t m_pluginID; + // a flag indicating whether this plugin has been loaded by calling its init function. + bool m_pluginIsLoaded; + /// The lock guarding this plugin object. Every time a member is accessed this lock should be locked accordingly. + /// After successful construction and initialization (doInitilize()), this member variable is effectively const + /// and therefore no locking is required in order to read from it! + /// In fact protecting read-accesses by a non-recursive lock can introduce deadlocks by plugins using certain + /// API functions. + mutable QReadWriteLock m_pluginLock; + /// The struct holding the function pointers to the functions in the shared library. + MumblePluginFunctions m_pluginFnc; + /// A flag indicating whether this plugin is built into Mumble and is thus not represented by a shared library. + bool m_isBuiltIn; + /// A flag indicating whether positional data gathering is enabled for this plugin (Enabled as in allowed via + /// preferences). + bool m_positionalDataIsEnabled; + /// A flag indicating whether positional data gathering is currently active (Active as in running) + bool m_positionalDataIsActive; + /// A flag indicating whether this plugin has permission to monitor keyboard events that occur while + /// Mumble has the keyboard focus. + bool m_mayMonitorKeyboard; + + + QString extractWrappedString(MumbleStringWrapper wrapper) const; + + + // Most of this class's functions are protected in order to only allow access to them via the PluginManager + // as some require additional handling before/after calling them. + + /// Initializes this plugin. This function must be called directly after construction. This is guaranteed when the + /// plugin is created via Plugin::createNew + virtual bool doInitialize(); + /// Resolves the function pointers in the shared library and sets the respective fields in Plugin::apiFnc + virtual void resolveFunctionPointers(); + /// Enables positional data gathering for this plugin (as in allowing) + /// + /// @param enable Whether to enable the data gathering + virtual void enablePositionalData(bool enable = true); + /// Allows or forbids the monitoring of keyboard events for this plugin. + /// + /// @param allow Whether to allow or forbid it + virtual void allowKeyboardMonitoring(bool allow); + + + /// Initializes this plugin + virtual mumble_error_t init(); + /// Shuts this plugin down + virtual void shutdown(); + /// Delegates the struct of API function pointers to the plugin backend + /// + /// @param api The pointer to the API struct + virtual void registerAPIFunctions(void *api) const; + /// Asks the plugin to release (free/delete) the resource pointed to by the given pointer + /// + /// @param pointer Pointer to the resource + virtual void releaseResource(const void *pointer) const; + /// Provides the plugin backend with some version information about Mumble + /// + /// @param mumbleVersion The version of the Mumble client + /// @param mumbleAPIVersion The API version used by the Mumble client + /// @param minimalExpectedAPIVersion The minimal API version expected to be used by the plugin backend + virtual void setMumbleInfo(mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, + mumble_version_t minimalExpectedAPIVersion) const; + /// Asks the plugin to deactivate certain features + /// + /// @param features The feature list or'ed together + /// @returns The list of features that couldn't be deactivated or'ed together + virtual uint32_t deactivateFeatures(uint32_t features) const; + /// Shows an about-dialog + /// + /// @parent A pointer to the QWidget that should be used as a parent + /// @returns Whether the dialog could be shown successfully + virtual bool showAboutDialog(QWidget *parent) const; + /// Shows a config-dialog + /// + /// @parent A pointer to the QWidget that should be used as a parent + /// @returns Whether the dialog could be shown successfully + virtual bool showConfigDialog(QWidget *parent) const; + /// Initializes the positional data gathering + /// + /// @params programNames A pointer to an array of const char* representing the program names + /// @params programCount A pointer to an array of PIDs corresponding to the program names + /// @params programCount The length of the two previous arrays + virtual uint8_t initPositionalData(const char *const *programNames, const uint64_t *programPIDs, + size_t programCount); + /// Fetches the positional data + /// + /// @param[out] avatarPos The position of the ingame avatar (player) + /// @param[out] avatarDir The directiion in which the avatar (player) is looking/facing + /// @param[out] avatarAxis The vector from the avatar's toes to its head + /// @param[out] cameraPos The position of the ingame camera + /// @param[out] cameraDir The direction in which the camera is looking/facing + /// @param[out] cameraAxis The vector from the camera's bottom to its top + /// @param[out] context The context of the current game-session (includes server/squad info) + /// @param[out] identity The ingame identity of the player (name) + virtual bool fetchPositionalData(Position3D &avatarPos, Vector3D &avatarDir, Vector3D &avatarAxis, + Position3D &cameraPos, Vector3D &cameraDir, Vector3D &cameraAxis, QString &context, + QString &identity) const; + /// Shuts down positional data gathering + virtual void shutdownPositionalData(); + /// Called to indicate that the client has connected to a server + /// + /// @param connection An object used to identify the current connection + virtual void onServerConnected(mumble_connection_t connection) const; + /// Called to indicate that the client disconnected from a server + /// + /// @param connection An object used to identify the connection that has been disconnected + virtual void onServerDisconnected(mumble_connection_t connection) const; + /// Called to indicate that a user has switched its channel + /// + /// @param connection An object used to identify the current connection + /// @param userID The ID of the user that switched channel + /// @param previousChannelID The ID of the channel the user came from (-1 if there is no previous channel) + /// æparam newChannelID The ID of the channel the user has switched to + virtual void onChannelEntered(mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t previousChannelID, mumble_channelid_t newChannelID) const; + /// Called to indicate that a user exited a channel. + /// + /// @param connection An object used to identify the current connection + /// @param userID The ID of the user that switched channel + /// @param channelID The ID of the channel the user exited + virtual void onChannelExited(mumble_connection_t connection, mumble_userid_t userID, + mumble_channelid_t channelID) const; + /// Called to indicate that a user has changed its talking state + /// + /// @param connection An object used to identify the current connection + /// @param userID The ID of the user that switched channel + /// @param talkingState The new talking state of the user + virtual void onUserTalkingStateChanged(mumble_connection_t connection, mumble_userid_t userID, + mumble_talking_state_t talkingState) const; + /// Called to indicate that a data packet has been received + /// + /// @param connection An object used to identify the current connection + /// @param sender The ID of the user whose client sent the data + /// @param data The actual data + /// @param dataLength The length of the data array + /// @param datID The ID of the data used to determine whether this plugin handles this data or not + /// @returns Whether this plugin handled the data + virtual bool onReceiveData(mumble_connection_t connection, mumble_userid_t sender, const uint8_t *data, + size_t dataLength, const char *dataID) const; + /// Called to indicate that there is audio input + /// + /// @param inputPCM A pointer to a short array representing the input PCM + /// @param sampleCount The amount of samples per channel + /// @param channelCount The amount of channels in the PCM + /// @param sampleRate The used sample rate in Hz + /// @param isSpeech Whether Mumble considers the input as speech + /// @returns Whether this pluign has modified the audio + virtual bool onAudioInput(short *inputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate, + bool isSpeech) const; + /// Called to indicate that an audio source has been fetched + /// + /// @param outputPCM A pointer to a short array representing the output PCM + /// @param sampleCount The amount of samples per channel + /// @param channelCount The amount of channels in the PCM + /// @param sampleRate The used sample rate in Hz + /// @param isSpeech Whether Mumble considers the output as speech + /// @param userID The ID of the user responsible for the output (only relevant if isSpeech == true) + /// @returns Whether this pluign has modified the audio + virtual bool onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, + uint32_t sampleRate, bool isSpeech, mumble_userid_t userID) const; + /// Called to indicate that audio is about to be played + /// + /// @param outputPCM A pointer to a short array representing the output PCM + /// @param sampleCount The amount of samples per channel + /// @param channelCount The amount of channels in the PCM + /// @param sampleRate The used sample rate in Hz + /// @returns Whether this pluign has modified the audio + virtual bool onAudioOutputAboutToPlay(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, + uint32_t sampleRate) const; + /// Called when the server has synchronized with the client + /// + /// @param connection An object used to identify the current connection + virtual void onServerSynchronized(mumble_connection_t connection) const; + /// Called when a new user gets added to the user model. This is the case when that new user freshly connects to the + /// server the local user is on but also when the local user connects to a server other clients are already + /// connected to (in this case this method will be called for every client already on that server). + /// + /// @param connection An object used to identify the current connection + /// @param userID The ID of the user that has been added + virtual void onUserAdded(mumble_connection_t connection, mumble_userid_t userID) const; + /// Called when a user gets removed from the user model. This is the case when that user disconnects from the server + /// the local user is on but also when the local user disconnects from a server other clients are connected to (in + /// this case this method will be called for every client on that server). + /// + /// @param connection An object used to identify the current connection + /// @param userID The ID of the user that has been removed + virtual void onUserRemoved(mumble_connection_t connection, mumble_userid_t userID) const; + /// Called when a new channel gets added to the user model. This is the case when a new channel is created on the + /// server the local user is on but also when the local user connects to a server that contains channels other than + /// the root-channel (in this case this method will be called for ever non-root channel on that server). + /// + /// @param connection An object used to identify the current connection + /// @param channelID The ID of the channel that has been added + virtual void onChannelAdded(mumble_connection_t connection, mumble_channelid_t channelID) const; + /// Called when a channel gets removed from the user model. This is the case when a channel is removed on the server + /// the local user is on but also when the local user disconnects from a server that contains channels other than + /// the root-channel (in this case this method will be called for ever non-root channel on that server). + /// + /// @param connection An object used to identify the current connection + /// @param channelID The ID of the channel that has been removed + virtual void onChannelRemoved(mumble_connection_t connection, mumble_channelid_t channelID) const; + /// Called when a channel gets renamed. This also applies when a new channel is created (thus assigning it an + /// initial name is also considered renaming). + /// + /// @param connection An object used to identify the current connection + /// @param channelID The ID of the channel that has been renamed + virtual void onChannelRenamed(mumble_connection_t connection, mumble_channelid_t channelID) const; + /// Called when a key has been pressed or released while Mumble has keyboard focus. + /// + /// @param keyCode The key code of the respective key. The character codes are defined + /// via the KeyCode enum. For printable 7-bit ASCII characters these codes conform + /// to the ASCII code-page with the only difference that case is not distinguished. Therefore + /// always the upper-case letter code will be used for letters. + /// @param wasPress Whether the key has been pressed (instead of released) + virtual void onKeyEvent(mumble_keycode_t keyCode, bool wasPress) const; + + +public: + /// A template function for instantiating new plugin objects and initializing them. The plugin will be allocated on + /// the heap and has thus to be deleted via the delete instruction. + /// + /// @tparam T The type of the plugin to be instantiated + /// @tparam Ts The types of the contructor arguments + /// @param args A list of args passed to the contructor of the plugin object + /// @returns A pointer to the allocated plugin + /// + /// @throws PluginError if the plugin could not be loaded + template< typename T, typename... Ts > static T *createNew(Ts &&... args) { + static_assert(std::is_base_of< Plugin, T >::value, + "The Plugin::create() can only be used to instantiate objects of base-type Plugin"); + static_assert(!std::is_pointer< T >::value, + "Plugin::create() can't be used to instantiate pointers. It will return a pointer automatically"); + + T *instancePtr = new T(std::forward< Ts >(args)...); + + // call the initialize-method and throw an exception of it doesn't succeed + if (!instancePtr->doInitialize()) { + delete instancePtr; + // Delete the constructed object to prevent a memory leak + throw PluginError("Failed to initialize plugin"); } - /// Destructor - virtual ~Plugin() Q_DECL_OVERRIDE; - /// @returns Whether this plugin is in a valid state - virtual bool isValid() const; - /// @returns Whether this plugin is loaded (has been initialized via Plugin::init()) - virtual bool isLoaded() const Q_DECL_FINAL; - /// @returns The unique ID of this plugin. This ID holds only as long as this plugin isn't "reconstructed". - virtual plugin_id_t getID() const Q_DECL_FINAL; - /// @returns Whether this plugin is built into Mumble (thus not backed by a shared library) - virtual bool isBuiltInPlugin() const Q_DECL_FINAL; - /// @returns The path to the shared library in the host's filesystem - virtual QString getFilePath() const; - /// @returns Whether positional data gathering is enabled (as in allowed via preferences) - virtual bool isPositionalDataEnabled() const Q_DECL_FINAL; - /// @returns Whether positional data gathering is currently active (as in running) - virtual bool isPositionalDataActive() const Q_DECL_FINAL; - /// @returns Whether this plugin is currently allowed to monitor keyboard events - virtual bool isKeyboardMonitoringAllowed() const Q_DECL_FINAL; - - - /// @returns Whether this plugin provides an about-dialog - virtual bool providesAboutDialog() const; - /// @returns Whether this plugin provides an config-dialog - virtual bool providesConfigDialog() const; - /// @returns The name of this plugin - virtual QString getName() const; - /// @returns The API version this plugin intends to use - virtual mumble_version_t getAPIVersion() const; - /// @returns The version of this plugin - virtual mumble_version_t getVersion() const; - /// @returns The author of this plugin - virtual QString getAuthor() const; - /// @returns The plugin's description - virtual QString getDescription() const; - /// @returns The plugin's features or'ed together (See the PluginFeature enum in MumblePlugin.h for what features are available) - virtual uint32_t getFeatures() const; - /// @return Whether the plugin has found a new/updated version of itself available for download - virtual bool hasUpdate() const; - /// @return The URL to download the updated plugin. May be empty - virtual QUrl getUpdateDownloadURL() const; + return instancePtr; + } + + /// Destructor + virtual ~Plugin() Q_DECL_OVERRIDE; + /// @returns Whether this plugin is in a valid state + virtual bool isValid() const; + /// @returns Whether this plugin is loaded (has been initialized via Plugin::init()) + virtual bool isLoaded() const Q_DECL_FINAL; + /// @returns The unique ID of this plugin. This ID holds only as long as this plugin isn't "reconstructed". + virtual plugin_id_t getID() const Q_DECL_FINAL; + /// @returns Whether this plugin is built into Mumble (thus not backed by a shared library) + virtual bool isBuiltInPlugin() const Q_DECL_FINAL; + /// @returns The path to the shared library in the host's filesystem + virtual QString getFilePath() const; + /// @returns Whether positional data gathering is enabled (as in allowed via preferences) + virtual bool isPositionalDataEnabled() const Q_DECL_FINAL; + /// @returns Whether positional data gathering is currently active (as in running) + virtual bool isPositionalDataActive() const Q_DECL_FINAL; + /// @returns Whether this plugin is currently allowed to monitor keyboard events + virtual bool isKeyboardMonitoringAllowed() const Q_DECL_FINAL; + + + /// @returns Whether this plugin provides an about-dialog + virtual bool providesAboutDialog() const; + /// @returns Whether this plugin provides an config-dialog + virtual bool providesConfigDialog() const; + /// @returns The name of this plugin + virtual QString getName() const; + /// @returns The API version this plugin intends to use + virtual mumble_version_t getAPIVersion() const; + /// @returns The version of this plugin + virtual mumble_version_t getVersion() const; + /// @returns The author of this plugin + virtual QString getAuthor() const; + /// @returns The plugin's description + virtual QString getDescription() const; + /// @returns The plugin's features or'ed together (See the PluginFeature enum in MumblePlugin.h for what features + /// are available) + virtual uint32_t getFeatures() const; + /// @return Whether the plugin has found a new/updated version of itself available for download + virtual bool hasUpdate() const; + /// @return The URL to download the updated plugin. May be empty + virtual QUrl getUpdateDownloadURL() const; }; #endif diff --git a/src/mumble/PluginConfig.cpp b/src/mumble/PluginConfig.cpp index e70877067..6b1c1dd31 100644 --- a/src/mumble/PluginConfig.cpp +++ b/src/mumble/PluginConfig.cpp @@ -7,20 +7,20 @@ #include "Log.h" #include "MainWindow.h" +#include "ManualPlugin.h" #include "Message.h" -#include "ServerHandler.h" -#include "WebFetch.h" #include "MumbleApplication.h" -#include "ManualPlugin.h" -#include "Utils.h" #include "PluginInstaller.h" #include "PluginManager.h" +#include "ServerHandler.h" +#include "Utils.h" +#include "WebFetch.h" -#include <QtWidgets/QMessageBox> -#include <QtCore/QUrl> #include <QtCore/QDir> #include <QtCore/QStandardPaths> +#include <QtCore/QUrl> #include <QtWidgets/QFileDialog> +#include <QtWidgets/QMessageBox> #include "Global.h" const QString PluginConfig::name = QLatin1String("PluginConfig"); @@ -74,7 +74,8 @@ void PluginConfig::on_qpbInstallPlugin_clicked() { // Reload plugins so the new one actually shows up on_qpbReload_clicked(); - QMessageBox::information(this, "Mumble", tr("The plugin was installed successfully"), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::information(this, "Mumble", tr("The plugin was installed successfully"), QMessageBox::Ok, + QMessageBox::NoButton); } } catch (const PluginInstallException &e) { QMessageBox::critical(this, "Mumble", e.getMessage(), QMessageBox::Ok, QMessageBox::NoButton); @@ -91,15 +92,14 @@ void PluginConfig::save() const { Global::get().pluginManager->unlinkPositionalData(); } - constexpr int enableCol = 1; - constexpr int positionalDataCol = 2; + constexpr int enableCol = 1; + constexpr int positionalDataCol = 2; constexpr int keyboardMonitorCol = 3; - QList<QTreeWidgetItem *> list = qtwPlugins->findItems(QString(), Qt::MatchContains); - for(QTreeWidgetItem *i : list) { - - bool enable = (i->checkState(enableCol) == Qt::Checked); - bool positionalDataEnabled = (i->checkState(positionalDataCol) == Qt::Checked); + QList< QTreeWidgetItem * > list = qtwPlugins->findItems(QString(), Qt::MatchContains); + for (QTreeWidgetItem *i : list) { + bool enable = (i->checkState(enableCol) == Qt::Checked); + bool positionalDataEnabled = (i->checkState(positionalDataCol) == Qt::Checked); bool keyboardMonitoringEnabled = (i->checkState(keyboardMonitorCol) == Qt::Checked); const_plugin_ptr_t plugin = pluginForItem(i); @@ -122,10 +122,13 @@ void PluginConfig::save() const { } if (featuresToDeactivate != FEATURE_NONE) { - uint32_t remainingFeatures = Global::get().pluginManager->deactivateFeaturesFor(plugin->getID(), featuresToDeactivate); + uint32_t remainingFeatures = + Global::get().pluginManager->deactivateFeaturesFor(plugin->getID(), featuresToDeactivate); if (remainingFeatures != FEATURE_NONE) { - Global::get().l->log(Log::Warning, tr("Unable to deactivate all requested features for plugin \"%1\"").arg(plugin->getName())); + Global::get().l->log(Log::Warning, + tr("Unable to deactivate all requested features for plugin \"%1\"") + .arg(plugin->getName())); } } } else { @@ -137,8 +140,10 @@ void PluginConfig::save() const { Global::get().pluginManager->unloadPlugin(plugin->getID()); } - QString pluginKey = QLatin1String(QCryptographicHash::hash(plugin->getFilePath().toUtf8(), QCryptographicHash::Sha1).toHex()); - s.qhPluginSettings.insert(pluginKey, { plugin->getFilePath(), enable, positionalDataEnabled, keyboardMonitoringEnabled }); + QString pluginKey = QLatin1String( + QCryptographicHash::hash(plugin->getFilePath().toUtf8(), QCryptographicHash::Sha1).toHex()); + s.qhPluginSettings.insert( + pluginKey, { plugin->getFilePath(), enable, positionalDataEnabled, keyboardMonitoringEnabled }); } } } @@ -157,7 +162,8 @@ void PluginConfig::on_qpbConfig_clicked() { if (plugin) { if (!plugin->showConfigDialog(this)) { // if the plugin doesn't support showing such a dialog, we'll show a default one - QMessageBox::information(this, QLatin1String("Mumble"), tr("Plugin has no configure function."), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::information(this, QLatin1String("Mumble"), tr("Plugin has no configure function."), + QMessageBox::Ok, QMessageBox::NoButton); } } } @@ -168,7 +174,8 @@ void PluginConfig::on_qpbAbout_clicked() { if (plugin) { if (!plugin->showAboutDialog(this)) { // if the plugin doesn't support showing such a dialog, we'll show a default one - QMessageBox::information(this, QLatin1String("Mumble"), tr("Plugin has no about function."), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::information(this, QLatin1String("Mumble"), tr("Plugin has no about function."), + QMessageBox::Ok, QMessageBox::NoButton); } } } @@ -203,13 +210,13 @@ void PluginConfig::refillPluginList() { qtwPlugins->clear(); // get plugins already sorted according to their name - const QVector<const_plugin_ptr_t > plugins = Global::get().pluginManager->getPlugins(true); + const QVector< const_plugin_ptr_t > plugins = Global::get().pluginManager->getPlugins(true); - foreach(const_plugin_ptr_t currentPlugin, plugins) { + foreach (const_plugin_ptr_t currentPlugin, plugins) { QTreeWidgetItem *i = new QTreeWidgetItem(qtwPlugins); i->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); i->setCheckState(1, currentPlugin->isLoaded() ? Qt::Checked : Qt::Unchecked); - + if (currentPlugin->getFeatures() & FEATURE_POSITIONAL) { i->setCheckState(2, currentPlugin->isPositionalDataEnabled() ? Qt::Checked : Qt::Unchecked); i->setToolTip(2, tr("Whether the positional audio feature of this plugin should be enabled")); @@ -218,7 +225,8 @@ void PluginConfig::refillPluginList() { } i->setCheckState(3, currentPlugin->isKeyboardMonitoringAllowed() ? Qt::Checked : Qt::Unchecked); - i->setToolTip(3, tr("Whether this plugin has the permission to be listening to all keyboard events that occur while Mumble has focus")); + i->setToolTip(3, tr("Whether this plugin has the permission to be listening to all keyboard events that occur " + "while Mumble has focus")); i->setText(0, currentPlugin->getName()); i->setToolTip(0, currentPlugin->getDescription().toHtmlEscaped()); diff --git a/src/mumble/PluginConfig.h b/src/mumble/PluginConfig.h index cab9ce7b3..807422085 100644 --- a/src/mumble/PluginConfig.h +++ b/src/mumble/PluginConfig.h @@ -7,60 +7,61 @@ #define MUMBLE_MUMBLE_PLUGINS_H_ #include "ConfigDialog.h" -#include "ui_PluginConfig.h" #include "Plugin.h" +#include "ui_PluginConfig.h" -#include <QtCore/QObject> #include <QtCore/QMutex> +#include <QtCore/QObject> #include <QtCore/QReadWriteLock> struct PluginInfo; class PluginConfig : public ConfigWidget, public Ui::PluginConfig { - private: - Q_OBJECT - Q_DISABLE_COPY(PluginConfig) - protected: - /// Clears and (re-) populates the plugin list in the UI with the currently available plugins - void refillPluginList(); - /// @param item The QTreeWidgetItem to retrieve the plugin for - /// @returns The plugin corresponding to the provided item - const_plugin_ptr_t pluginForItem(QTreeWidgetItem *item) const; - public: - /// The unique name of this ConfigWidget - static const QString name; - /// Constructor - /// - /// @param st The settings object to work on - PluginConfig(Settings &st); - /// @returns The title of this widget - virtual QString title() const Q_DECL_OVERRIDE; - /// @returns The name of this ConfigWidget - const QString &getName() const Q_DECL_OVERRIDE; - /// @returns The icon for this widget - virtual QIcon icon() const Q_DECL_OVERRIDE; - public slots: - /// Saves the current configuration to the respective settings object - void save() const Q_DECL_OVERRIDE; - /// Loads the transmit-position from the provided settings object - /// - /// @param The setting sobject to read from - void load(const Settings &r) Q_DECL_OVERRIDE; - /// Slot triggered when the install-button in the UI has been clicked - void on_qpbInstallPlugin_clicked(); - /// Slot triggered when the config-button in the UI has been clicked - void on_qpbConfig_clicked(); - /// Slot triggered when the about-button in the UI has been clicked - void on_qpbAbout_clicked(); - /// Slot triggered when the reload-button in the UI has been clicked - void on_qpbReload_clicked(); - /// Slot triggered when the unload-button in the UI has been clicked - void on_qpbUnload_clicked(); - /// Slot triggered when the selection in the plugin list hast changed - /// - /// @param current The currently selected item - /// @param old The previously selected item (if applicable - otherwise NULL/nullptr) - void on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *old); +private: + Q_OBJECT + Q_DISABLE_COPY(PluginConfig) +protected: + /// Clears and (re-) populates the plugin list in the UI with the currently available plugins + void refillPluginList(); + /// @param item The QTreeWidgetItem to retrieve the plugin for + /// @returns The plugin corresponding to the provided item + const_plugin_ptr_t pluginForItem(QTreeWidgetItem *item) const; + +public: + /// The unique name of this ConfigWidget + static const QString name; + /// Constructor + /// + /// @param st The settings object to work on + PluginConfig(Settings &st); + /// @returns The title of this widget + virtual QString title() const Q_DECL_OVERRIDE; + /// @returns The name of this ConfigWidget + const QString &getName() const Q_DECL_OVERRIDE; + /// @returns The icon for this widget + virtual QIcon icon() const Q_DECL_OVERRIDE; +public slots: + /// Saves the current configuration to the respective settings object + void save() const Q_DECL_OVERRIDE; + /// Loads the transmit-position from the provided settings object + /// + /// @param The setting sobject to read from + void load(const Settings &r) Q_DECL_OVERRIDE; + /// Slot triggered when the install-button in the UI has been clicked + void on_qpbInstallPlugin_clicked(); + /// Slot triggered when the config-button in the UI has been clicked + void on_qpbConfig_clicked(); + /// Slot triggered when the about-button in the UI has been clicked + void on_qpbAbout_clicked(); + /// Slot triggered when the reload-button in the UI has been clicked + void on_qpbReload_clicked(); + /// Slot triggered when the unload-button in the UI has been clicked + void on_qpbUnload_clicked(); + /// Slot triggered when the selection in the plugin list hast changed + /// + /// @param current The currently selected item + /// @param old The previously selected item (if applicable - otherwise NULL/nullptr) + void on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *old); }; #endif diff --git a/src/mumble/PluginInstaller.cpp b/src/mumble/PluginInstaller.cpp index 41494d64e..f9c7a9a35 100644 --- a/src/mumble/PluginInstaller.cpp +++ b/src/mumble/PluginInstaller.cpp @@ -6,25 +6,24 @@ #include "PluginInstaller.h" #include "Global.h" -#include <QtCore/QString> +#include <QtCore/QDir> #include <QtCore/QException> #include <QtCore/QObject> +#include <QtCore/QString> #include <QtCore/QStringList> -#include <QtCore/QDir> #include <QtGui/QIcon> #include <exception> -#include <string> #include <fstream> +#include <string> +#include <Poco/Exception.h> +#include <Poco/StreamCopier.h> #include <Poco/Zip/ZipArchive.h> #include <Poco/Zip/ZipStream.h> -#include <Poco/StreamCopier.h> -#include <Poco/Exception.h> -PluginInstallException::PluginInstallException(const QString& msg) - : m_msg(msg) { +PluginInstallException::PluginInstallException(const QString &msg) : m_msg(msg) { } QString PluginInstallException::getMessage() const { @@ -33,14 +32,14 @@ QString PluginInstallException::getMessage() const { const QString PluginInstaller::pluginFileExtension = QLatin1String("mumble_plugin"); -bool PluginInstaller::canBePluginFile(const QFileInfo& fileInfo) noexcept { +bool PluginInstaller::canBePluginFile(const QFileInfo &fileInfo) noexcept { if (!fileInfo.isFile()) { // A plugin file has to be a file (obviously) return false; } if (fileInfo.suffix().compare(PluginInstaller::pluginFileExtension, Qt::CaseInsensitive) == 0 - || fileInfo.suffix().compare(QLatin1String("zip"), Qt::CaseInsensitive) == 0) { + || fileInfo.suffix().compare(QLatin1String("zip"), Qt::CaseInsensitive) == 0) { // A plugin file has either the extension given in PluginInstaller::pluginFileExtension or zip return true; } @@ -49,12 +48,8 @@ bool PluginInstaller::canBePluginFile(const QFileInfo& fileInfo) noexcept { return QLibrary::isLibrary(fileInfo.fileName()); } -PluginInstaller::PluginInstaller(const QFileInfo& fileInfo, QWidget *p) - : QDialog(p), - m_pluginArchive(fileInfo), - m_plugin(nullptr), - m_pluginSource(), - m_pluginDestination(), +PluginInstaller::PluginInstaller(const QFileInfo &fileInfo, QWidget *p) + : QDialog(p), m_pluginArchive(fileInfo), m_plugin(nullptr), m_pluginSource(), m_pluginDestination(), m_copyPlugin(false) { setupUi(this); @@ -96,8 +91,11 @@ void PluginInstaller::init() { if (QLibrary::isLibrary(currentFileName)) { if (!pluginName.isEmpty()) { // There seem to be multiple plugins in here. That's not allowed - throw PluginInstallException(tr("Found more than one plugin library for the current OS in \"%1\" (\"%2\" and \"%3\")!").arg( - m_pluginArchive.fileName()).arg(pluginName).arg(currentFileName)); + throw PluginInstallException( + tr("Found more than one plugin library for the current OS in \"%1\" (\"%2\" and \"%3\")!") + .arg(m_pluginArchive.fileName()) + .arg(pluginName) + .arg(currentFileName)); } pluginName = currentFileName; @@ -107,22 +105,24 @@ void PluginInstaller::init() { } if (pluginName.isEmpty()) { - throw PluginInstallException(tr("Unable to find a plugin for the current OS in \"%1\"").arg(m_pluginArchive.fileName())); + throw PluginInstallException( + tr("Unable to find a plugin for the current OS in \"%1\"").arg(m_pluginArchive.fileName())); } // Unpack the plugin library into the tmp dir // We don't have to create the directory structure as we're only interested in the library itself QString tmpPluginPath = QDir::temp().filePath(QFileInfo(pluginName).fileName()); - auto pluginIt = archive.findHeader(pluginName.toStdString()); + auto pluginIt = archive.findHeader(pluginName.toStdString()); zipInput.clear(); Poco::Zip::ZipInputStream zipin(zipInput, pluginIt->second); std::ofstream out(tmpPluginPath.toStdString()); Poco::StreamCopier::copyStream(zipin, out); m_pluginSource = QFileInfo(tmpPluginPath); - } catch(const Poco::Exception &e) { + } catch (const Poco::Exception &e) { // Something didn't work out during the Zip processing - throw PluginInstallException(QString::fromStdString(std::string("Failed to process zip archive: ") + e.message())); + throw PluginInstallException( + QString::fromStdString(std::string("Failed to process zip archive: ") + e.message())); } } @@ -130,9 +130,10 @@ void PluginInstaller::init() { // Try to load the plugin up to see if it is actually valid try { - m_plugin = Plugin::createNew<Plugin>(m_pluginSource.absoluteFilePath()); - } catch(const PluginError&) { - throw PluginInstallException(tr("Unable to load plugin \"%1\" - check the plugin interface!").arg(pluginFileName)); + m_plugin = Plugin::createNew< Plugin >(m_pluginSource.absoluteFilePath()); + } catch (const PluginError &) { + throw PluginInstallException( + tr("Unable to load plugin \"%1\" - check the plugin interface!").arg(pluginFileName)); } m_pluginDestination = QFileInfo(QString::fromLatin1("%1/%2").arg(getInstallDir()).arg(pluginFileName)); @@ -141,11 +142,12 @@ void PluginInstaller::init() { // Now that we located the plugin, it is time to fill in its details in the UI qlName->setText(m_plugin->getName()); - mumble_version_t pluginVersion = m_plugin->getVersion(); + mumble_version_t pluginVersion = m_plugin->getVersion(); mumble_version_t usedAPIVersion = m_plugin->getAPIVersion(); - qlVersion->setText(QString::fromLatin1("%1 (API %2)").arg(pluginVersion == VERSION_UNKNOWN ? - "Unknown" : static_cast<QString>(pluginVersion)).arg( - usedAPIVersion == VERSION_UNKNOWN ? "Unknown" : static_cast<QString>(usedAPIVersion))); + qlVersion->setText( + QString::fromLatin1("%1 (API %2)") + .arg(pluginVersion == VERSION_UNKNOWN ? "Unknown" : static_cast< QString >(pluginVersion)) + .arg(usedAPIVersion == VERSION_UNKNOWN ? "Unknown" : static_cast< QString >(usedAPIVersion))); qlAuthor->setText(m_plugin->getAuthor()); @@ -166,19 +168,22 @@ void PluginInstaller::install() const { if (m_pluginDestination.exists()) { // Delete old version first if (!QFile(m_pluginDestination.absoluteFilePath()).remove()) { - throw PluginInstallException(tr("Unable to delete old plugin at \"%1\"").arg(m_pluginDestination.absoluteFilePath())); + throw PluginInstallException( + tr("Unable to delete old plugin at \"%1\"").arg(m_pluginDestination.absoluteFilePath())); } } if (m_copyPlugin) { if (!QFile(m_pluginSource.absoluteFilePath()).copy(m_pluginDestination.absoluteFilePath())) { - throw PluginInstallException(tr("Unable to copy plugin library from \"%1\" to \"%2\"").arg(m_pluginSource.absoluteFilePath()).arg( - m_pluginDestination.absoluteFilePath())); + throw PluginInstallException(tr("Unable to copy plugin library from \"%1\" to \"%2\"") + .arg(m_pluginSource.absoluteFilePath()) + .arg(m_pluginDestination.absoluteFilePath())); } } else { // Move the plugin into the respective dir if (!QFile(m_pluginSource.absoluteFilePath()).rename(m_pluginDestination.absoluteFilePath())) { - throw PluginInstallException(tr("Unable to move plugin library to \"%1\"").arg(m_pluginDestination.absoluteFilePath())); + throw PluginInstallException( + tr("Unable to move plugin library to \"%1\"").arg(m_pluginDestination.absoluteFilePath())); } } } diff --git a/src/mumble/PluginInstaller.h b/src/mumble/PluginInstaller.h index d8df3c303..e092ee8f9 100644 --- a/src/mumble/PluginInstaller.h +++ b/src/mumble/PluginInstaller.h @@ -7,8 +7,8 @@ #define MUMBLE_MUMBLE_PLUGININSTALLER_H_ -#include <QtCore/QFileInfo> #include <QtCore/QException> +#include <QtCore/QFileInfo> #include "Plugin.h" @@ -16,69 +16,72 @@ /// An exception thrown by the PluginInstaller class PluginInstallException : public QException { - protected: - /// The exception's message - QString m_msg; - public: - /// @param msg The message stating why this exception has been thrown - PluginInstallException(const QString& msg); - - /// @returns This exception's message - QString getMessage() const; +protected: + /// The exception's message + QString m_msg; + +public: + /// @param msg The message stating why this exception has been thrown + PluginInstallException(const QString &msg); + + /// @returns This exception's message + QString getMessage() const; }; /// The PluginInstaller can be used to install plugins into Mumble. It verifies that the respective /// plugin is functional and will automatiacally copy/move the plugin library to the respective /// directory on the FileSystem. class PluginInstaller : public QDialog, public Ui::PluginInstaller { - private: - Q_OBJECT; - Q_DISABLE_COPY(PluginInstaller); - protected: - /// The file the installer has been invoked on - QFileInfo m_pluginArchive; - /// A pointer to the plugin instance created from the plugin library that shall be installed - Plugin *m_plugin; - /// The actual plugin library file - QFileInfo m_pluginSource; - /// The destinaton file to which the plugin library shall be copied - QFileInfo m_pluginDestination; - /// A flag indicating that the plugin library shall be copied instead of moved in order - /// to install it. - bool m_copyPlugin; - - /// Initializes this installer by processing the provided plugin source and filling all - /// internal fields. This function is called from the constructor. - /// - /// @throws PluginInstallException If something isn't right or goes wrong - void init(); - public: - /// The "special" file-extension associated with Mumble plugins - static const QString pluginFileExtension; - - /// A helper function checking whether the provided file could be a plugin source - /// - /// @param fileInfo The file to check - /// @returns Whether the provided file could (!) be a plugin source - static bool canBePluginFile(const QFileInfo& fileInfo) noexcept; - - /// @param fileInfo The plugin source to process - /// - /// @throws PluginInstallException If something isn't right or goes wrong - PluginInstaller(const QFileInfo& fileInfo, QWidget *p = nullptr); - /// Destructor - ~PluginInstaller(); - - /// Performs the actual installation (moving/copying of the library) of the plugin - void install() const; - - static QString getInstallDir(); - - public slots: - /// Slot called when the user clicks the yes button - void on_qpbYesClicked(); - /// Slot called when the user clicks the no button - void on_qpbNoClicked(); +private: + Q_OBJECT; + Q_DISABLE_COPY(PluginInstaller); + +protected: + /// The file the installer has been invoked on + QFileInfo m_pluginArchive; + /// A pointer to the plugin instance created from the plugin library that shall be installed + Plugin *m_plugin; + /// The actual plugin library file + QFileInfo m_pluginSource; + /// The destinaton file to which the plugin library shall be copied + QFileInfo m_pluginDestination; + /// A flag indicating that the plugin library shall be copied instead of moved in order + /// to install it. + bool m_copyPlugin; + + /// Initializes this installer by processing the provided plugin source and filling all + /// internal fields. This function is called from the constructor. + /// + /// @throws PluginInstallException If something isn't right or goes wrong + void init(); + +public: + /// The "special" file-extension associated with Mumble plugins + static const QString pluginFileExtension; + + /// A helper function checking whether the provided file could be a plugin source + /// + /// @param fileInfo The file to check + /// @returns Whether the provided file could (!) be a plugin source + static bool canBePluginFile(const QFileInfo &fileInfo) noexcept; + + /// @param fileInfo The plugin source to process + /// + /// @throws PluginInstallException If something isn't right or goes wrong + PluginInstaller(const QFileInfo &fileInfo, QWidget *p = nullptr); + /// Destructor + ~PluginInstaller(); + + /// Performs the actual installation (moving/copying of the library) of the plugin + void install() const; + + static QString getInstallDir(); + +public slots: + /// Slot called when the user clicks the yes button + void on_qpbYesClicked(); + /// Slot called when the user clicks the no button + void on_qpbNoClicked(); }; #endif // MUMBLE_MUMBLE_PLUGININSTALLER_H_ diff --git a/src/mumble/PluginManager.cpp b/src/mumble/PluginManager.cpp index 817eb69be..db7a8dfef 100644 --- a/src/mumble/PluginManager.cpp +++ b/src/mumble/PluginManager.cpp @@ -3,56 +3,47 @@ // that can be found in the LICENSE file at the root of the // Mumble source tree or at <https://www.mumble.info/LICENSE>. -#include <limits> +#include <limits> -#include "PluginManager.h" #include "LegacyPlugin.h" -#include <QReadLocker> -#include <QWriteLocker> -#include <QReadLocker> -#include <QDir> -#include <QFileInfoList> -#include <QFileInfo> -#include <QVector> +#include "PluginManager.h" #include <QByteArray> #include <QChar> -#include <QMutexLocker> +#include <QDir> +#include <QFileInfo> +#include <QFileInfoList> #include <QHashIterator> #include <QKeyEvent> +#include <QMutexLocker> +#include <QReadLocker> #include <QTimer> +#include <QVector> +#include <QWriteLocker> -#include "ManualPlugin.h" +#include "API.h" #include "Log.h" +#include "ManualPlugin.h" #include "PluginInstaller.h" +#include "PluginUpdater.h" #include "ProcessResolver.h" #include "ServerHandler.h" -#include "PluginUpdater.h" -#include "API.h" #include "Global.h" #include <memory> #ifdef Q_OS_WIN - #include <tlhelp32.h> - #include <string> +# include <tlhelp32.h> +# include <string> #endif #ifdef Q_OS_LINUX - #include <QtCore/QStringList> +# include <QtCore/QStringList> #endif -PluginManager::PluginManager(QSet<QString> *additionalSearchPaths, QObject *p) - : QObject(p), - m_pluginCollectionLock(QReadWriteLock::NonRecursive), - m_pluginHashMap(), - m_positionalData(), - m_positionalDataCheckTimer(), - m_sentDataMutex(), - m_sentData(), - m_activePosDataPluginLock(QReadWriteLock::NonRecursive), - m_activePositionalDataPlugin(), - m_updater() { - +PluginManager::PluginManager(QSet< QString > *additionalSearchPaths, QObject *p) + : QObject(p), m_pluginCollectionLock(QReadWriteLock::NonRecursive), m_pluginHashMap(), m_positionalData(), + m_positionalDataCheckTimer(), m_sentDataMutex(), m_sentData(), + m_activePosDataPluginLock(QReadWriteLock::NonRecursive), m_activePositionalDataPlugin(), m_updater() { // Setup search-paths if (additionalSearchPaths) { for (const auto ¤tPath : *additionalSearchPaths) { @@ -72,7 +63,8 @@ PluginManager::PluginManager(QSet<QString> *additionalSearchPaths, QObject *p) // Path to "plugins" dir right next to the executable's location. This is the case for when Mumble // is run after compilation without having installed it anywhere special - m_pluginSearchPaths.insert(QString::fromLatin1("%1/plugins").arg(MumbleApplication::instance()->applicationVersionRootPath())); + m_pluginSearchPaths.insert( + QString::fromLatin1("%1/plugins").arg(MumbleApplication::instance()->applicationVersionRootPath())); // Path to where the plugin installer will write plugins m_pluginSearchPaths.insert(PluginInstaller::getInstallDir()); @@ -91,7 +83,7 @@ PluginManager::PluginManager(QSet<QString> *additionalSearchPaths, QObject *p) TOKEN_PRIVILEGES tp; LUID luid; - m_cbPrevious=sizeof(TOKEN_PRIVILEGES); + m_cbPrevious = sizeof(TOKEN_PRIVILEGES); LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid); @@ -116,7 +108,8 @@ PluginManager::PluginManager(QSet<QString> *additionalSearchPaths, QObject *p) // Set up the timer for regularly checking for available positional data plugins m_positionalDataCheckTimer.setInterval(POSITIONAL_DATA_CHECK_INTERVAL); m_positionalDataCheckTimer.start(); - QObject::connect(&m_positionalDataCheckTimer, &QTimer::timeout, this, &PluginManager::checkForAvailablePositionalDataPlugin); + QObject::connect(&m_positionalDataCheckTimer, &QTimer::timeout, this, + &PluginManager::checkForAvailablePositionalDataPlugin); QObject::connect(&m_updater, &PluginUpdater::updatesAvailable, this, &PluginManager::on_updatesAvailable); QObject::connect(this, &PluginManager::keyEvent, this, &PluginManager::on_keyEvent); @@ -134,15 +127,15 @@ PluginManager::~PluginManager() { /// Emits a log about a plugin with the given name having lost link (positional audio) /// /// @param pluginName The name of the plugin that lost link -void reportLostLink(const QString& pluginName) { - Global::get().l->log(Log::Information, PluginManager::tr("%1 lost link").arg(pluginName.toHtmlEscaped())); +void reportLostLink(const QString &pluginName) { + Global::get().l->log(Log::Information, PluginManager::tr("%1 lost link").arg(pluginName.toHtmlEscaped())); } bool PluginManager::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { - static QVector<QKeyEvent*> processedEvents; + static QVector< QKeyEvent * > processedEvents; - QKeyEvent *kEvent = static_cast<QKeyEvent *>(event); + QKeyEvent *kEvent = static_cast< QKeyEvent * >(event); // We have to keep track of which events we have processed already as // the same event might be sent to multiple targets and since this is @@ -162,7 +155,6 @@ bool PluginManager::eventFilter(QObject *target, QEvent *event) { QTimer::singleShot(0, []() { processedEvents.clear(); }); } } - } // standard event processing @@ -200,8 +192,8 @@ bool PluginManager::selectActivePositionalDataPlugin() { QWriteLocker activePluginLock(&m_activePosDataPluginLock); if (!Global::get().s.bTransmitPosition) { - // According to the settings the position shall not be transmitted meaning that we don't have to select any plugin - // for positional data + // According to the settings the position shall not be transmitted meaning that we don't have to select any + // plugin for positional data m_activePositionalDataPlugin = nullptr; return false; @@ -217,26 +209,28 @@ bool PluginManager::selectActivePositionalDataPlugin() { plugin_ptr_t currentPlugin = it.value(); if (currentPlugin->isPositionalDataEnabled() && currentPlugin->isLoaded()) { - switch(currentPlugin->initPositionalData(procRes.getProcessNames().data(), - procRes.getProcessPIDs().data(), procRes.amountOfProcesses())) { + switch (currentPlugin->initPositionalData(procRes.getProcessNames().data(), procRes.getProcessPIDs().data(), + procRes.amountOfProcesses())) { case PDEC_OK: // the plugin is ready to provide positional data m_activePositionalDataPlugin = currentPlugin; - Global::get().l->log(Log::Information, tr("%1 linked").arg(currentPlugin->getName().toHtmlEscaped())); + Global::get().l->log(Log::Information, + tr("%1 linked").arg(currentPlugin->getName().toHtmlEscaped())); return true; case PDEC_ERROR_PERM: // the plugin encountered a permanent error -> disable it - Global::get().l->log(Log::Warning, tr( - "Plugin \"%1\" encountered a permanent error in positional data gathering").arg(currentPlugin->getName())); + Global::get().l->log(Log::Warning, + tr("Plugin \"%1\" encountered a permanent error in positional data gathering") + .arg(currentPlugin->getName())); currentPlugin->enablePositionalData(false); break; case PDEC_ERROR_TEMP: - //The plugin encountered a temporary error -> skip it for now (that is: do nothing) + // The plugin encountered a temporary error -> skip it for now (that is: do nothing) break; } } @@ -249,7 +243,8 @@ bool PluginManager::selectActivePositionalDataPlugin() { return false; } -#define LOG_FOUND(plugin, path, legacyStr) qDebug("Found %splugin '%s' at \"%s\"", legacyStr, qUtf8Printable(plugin->getName()), qUtf8Printable(path));\ +#define LOG_FOUND(plugin, path, legacyStr) \ + qDebug("Found %splugin '%s' at \"%s\"", legacyStr, qUtf8Printable(plugin->getName()), qUtf8Printable(path)); \ qDebug() << "Its description:" << qUtf8Printable(plugin->getDescription()) #define LOG_FOUND_PLUGIN(plugin, path) LOG_FOUND(plugin, path, "") #define LOG_FOUND_LEGACY_PLUGIN(plugin, path) LOG_FOUND(plugin, path, "legacy ") @@ -264,41 +259,43 @@ void PluginManager::rescanPlugins() { for (const auto ¤tPath : m_pluginSearchPaths) { QFileInfoList currentList = QDir(currentPath).entryInfoList(); - for (int k=0; k<currentList.size(); k++) { + for (int k = 0; k < currentList.size(); k++) { QFileInfo currentInfo = currentList[k]; if (!QLibrary::isLibrary(currentInfo.absoluteFilePath())) { // consider only files that actually could be libraries continue; } - + try { - plugin_ptr_t p(Plugin::createNew<Plugin>(currentInfo.absoluteFilePath())); + plugin_ptr_t p(Plugin::createNew< Plugin >(currentInfo.absoluteFilePath())); #ifdef MUMBLE_PLUGIN_DEBUG LOG_FOUND_PLUGIN(p, currentInfo.absoluteFilePath()); #endif - // if this code block is reached, the plugin was instantiated successfully so we can add it to the map + // if this code block is reached, the plugin was instantiated successfully so we can add it to the + // map m_pluginHashMap.insert(p->getID(), p); - } catch(const PluginError& e) { + } catch (const PluginError &e) { Q_UNUSED(e); // If an exception is thrown, this library does not represent a proper plugin // Check if it might be a legacy plugin instead try { - legacy_plugin_ptr_t lp(Plugin::createNew<LegacyPlugin>(currentInfo.absoluteFilePath())); - + legacy_plugin_ptr_t lp(Plugin::createNew< LegacyPlugin >(currentInfo.absoluteFilePath())); + #ifdef MUMBLE_PLUGIN_DEBUG LOG_FOUND_LEGACY_PLUGIN(lp, currentInfo.absoluteFilePath()); #endif m_pluginHashMap.insert(lp->getID(), lp); - } catch(const PluginError& e) { + } catch (const PluginError &e) { Q_UNUSED(e); - - // At the time this function is running the MainWindow is not necessarily created yet, so we can't use - // the normal Log::log function - Log::logOrDefer(Log::Warning, - tr("Non-plugin found in plugin directory: \"%1\"").arg(currentInfo.absoluteFilePath())); + + // At the time this function is running the MainWindow is not necessarily created yet, so we + // can't use the normal Log::log function + Log::logOrDefer( + Log::Warning, + tr("Non-plugin found in plugin directory: \"%1\"").arg(currentInfo.absoluteFilePath())); } } } @@ -307,13 +304,13 @@ void PluginManager::rescanPlugins() { // handle built-in plugins #ifdef USE_MANUAL_PLUGIN try { - std::shared_ptr<ManualPlugin> mp(Plugin::createNew<ManualPlugin>()); + std::shared_ptr< ManualPlugin > mp(Plugin::createNew< ManualPlugin >()); m_pluginHashMap.insert(mp->getID(), mp); -#ifdef MUMBLE_PLUGIN_DEBUG +# ifdef MUMBLE_PLUGIN_DEBUG LOG_FOUND_BUILTIN(mp); -#endif - } catch(const PluginError& e) { +# endif + } catch (const PluginError &e) { // At the time this function is running the MainWindow is not necessarily created yet, so we can't use // the normal Log::log function Log::logOrDefer(Log::Warning, tr("Failed at loading manual plugin: %1").arg(QString::fromUtf8(e.what()))); @@ -328,14 +325,15 @@ void PluginManager::rescanPlugins() { auto it = Global::get().s.qhPluginSettings.constBegin(); while (it != Global::get().s.qhPluginSettings.constEnd()) { // for this we need a way to get a plugin based on the filepath - const QString pluginKey = it.key(); + const QString pluginKey = it.key(); const PluginSetting setting = it.value(); // iterate over all loaded plugins to see if the current setting is applicable auto pluginIt = m_pluginHashMap.begin(); while (pluginIt != m_pluginHashMap.end()) { plugin_ptr_t plugin = pluginIt.value(); - QString pluginHash = QLatin1String(QCryptographicHash::hash(plugin->getFilePath().toUtf8(), QCryptographicHash::Sha1).toHex()); + QString pluginHash = QLatin1String( + QCryptographicHash::hash(plugin->getFilePath().toUtf8(), QCryptographicHash::Sha1).toHex()); if (pluginKey == pluginHash) { if (setting.enabled) { loadPlugin(plugin->getID()); @@ -366,7 +364,7 @@ void PluginManager::rescanPlugins() { const_plugin_ptr_t PluginManager::getPlugin(plugin_id_t pluginID) const { QReadLocker lock(&m_pluginCollectionLock); - + return m_pluginHashMap.value(pluginID); } @@ -379,9 +377,9 @@ bool PluginManager::fetchPositionalData() { // This is for testing-purposes only so the "fetched" position doesn't have any real meaning m_positionalData.reset(); - m_positionalData.m_playerDir.z = 1.0f; + m_positionalData.m_playerDir.z = 1.0f; m_positionalData.m_playerAxis.y = 1.0f; - m_positionalData.m_cameraDir.z = 1.0f; + m_positionalData.m_cameraDir.z = 1.0f; m_positionalData.m_cameraAxis.y = 1.0f; return true; @@ -399,9 +397,10 @@ bool PluginManager::fetchPositionalData() { QWriteLocker posDataLock(&m_positionalData.m_lock); - bool retStatus = m_activePositionalDataPlugin->fetchPositionalData(m_positionalData.m_playerPos, m_positionalData.m_playerDir, - m_positionalData.m_playerAxis, m_positionalData.m_cameraPos, m_positionalData.m_cameraDir, m_positionalData.m_cameraAxis, - m_positionalData.m_context, m_positionalData.m_identity); + bool retStatus = m_activePositionalDataPlugin->fetchPositionalData( + m_positionalData.m_playerPos, m_positionalData.m_playerDir, m_positionalData.m_playerAxis, + m_positionalData.m_cameraPos, m_positionalData.m_cameraDir, m_positionalData.m_cameraAxis, + m_positionalData.m_context, m_positionalData.m_identity); // Add the plugin's name to the context as well to prevent name-clashes between plugins if (!m_positionalData.m_context.isEmpty()) { @@ -420,15 +419,15 @@ bool PluginManager::fetchPositionalData() { selectActivePositionalDataPlugin(); } else { // If the return-status doesn't indicate an error, we can assume that positional data is available - // The remaining problematic case is, if the player is exactly at position (0,0,0) as this is used as an indicator for the - // absence of positional data in the mix() function in AudioOutput.cpp - // Thus we have to make sure that this position is never set if positional data is actually available. - // We solve this problem by shifting the player a minimal amount on the z-axis + // The remaining problematic case is, if the player is exactly at position (0,0,0) as this is used as an + // indicator for the absence of positional data in the mix() function in AudioOutput.cpp Thus we have to make + // sure that this position is never set if positional data is actually available. We solve this problem by + // shifting the player a minimal amount on the z-axis if (m_positionalData.m_playerPos == Position3D(0.0f, 0.0f, 0.0f)) { - m_positionalData.m_playerPos = {0.0f, 0.0f, std::numeric_limits<float>::min()}; + m_positionalData.m_playerPos = { 0.0f, 0.0f, std::numeric_limits< float >::min() }; } if (m_positionalData.m_cameraPos == Position3D(0.0f, 0.0f, 0.0f)) { - m_positionalData.m_cameraPos = {0.0f, 0.0f, std::numeric_limits<float>::min()}; + m_positionalData.m_cameraPos = { 0.0f, 0.0f, std::numeric_limits< float >::min() }; } } @@ -454,7 +453,7 @@ bool PluginManager::isPositionalDataAvailable() const { return m_activePositionalDataPlugin != nullptr; } -const PositionalData& PluginManager::getPositionalData() const { +const PositionalData &PluginManager::getPositionalData() const { return m_positionalData; } @@ -468,24 +467,23 @@ void PluginManager::enablePositionalDataFor(plugin_id_t pluginID, bool enable) c } } -const QVector<const_plugin_ptr_t > PluginManager::getPlugins(bool sorted) const { +const QVector< const_plugin_ptr_t > PluginManager::getPlugins(bool sorted) const { QReadLocker lock(&m_pluginCollectionLock); - QVector<const_plugin_ptr_t> pluginList; + QVector< const_plugin_ptr_t > pluginList; auto it = m_pluginHashMap.constBegin(); if (sorted) { - QList<plugin_id_t> ids = m_pluginHashMap.keys(); + QList< plugin_id_t > ids = m_pluginHashMap.keys(); // sort keys so that the corresponding Plugins are in alphabetical order based on their name std::sort(ids.begin(), ids.end(), [this](plugin_id_t first, plugin_id_t second) { return QString::compare(m_pluginHashMap.value(first)->getName(), m_pluginHashMap.value(second)->getName(), - Qt::CaseInsensitive) <= 0; + Qt::CaseInsensitive) + <= 0; }); - foreach(plugin_id_t currentID, ids) { - pluginList.append(m_pluginHashMap.value(currentID)); - } + foreach (plugin_id_t currentID, ids) { pluginList.append(m_pluginHashMap.value(currentID)); } } else { while (it != m_pluginHashMap.constEnd()) { pluginList.append(it.value()); @@ -509,7 +507,7 @@ bool PluginManager::loadPlugin(plugin_id_t pluginID) const { // before hitting ok. return true; } - + return plugin->init() == STATUS_OK; } @@ -551,7 +549,7 @@ bool PluginManager::clearPlugin(plugin_id_t pluginID) { return plugin != nullptr; } -uint32_t PluginManager::deactivateFeaturesFor(plugin_id_t pluginID, uint32_t features) const { +uint32_t PluginManager::deactivateFeaturesFor(plugin_id_t pluginID, uint32_t features) const { QReadLocker lock(&m_pluginCollectionLock); plugin_ptr_t plugin = m_pluginHashMap.value(pluginID); @@ -579,7 +577,7 @@ bool PluginManager::pluginExists(plugin_id_t pluginID) const { return m_pluginHashMap.contains(pluginID); } -void PluginManager::foreachPlugin(std::function<void(Plugin&)> pluginProcessor) const { +void PluginManager::foreachPlugin(std::function< void(Plugin &) > pluginProcessor) const { QReadLocker lock(&m_pluginCollectionLock); auto it = m_pluginHashMap.constBegin(); @@ -598,7 +596,7 @@ void PluginManager::on_serverConnected() const { qDebug("PluginManager: Connected to a server with connection ID %d", connectionID); #endif - foreachPlugin([connectionID](Plugin& plugin) { + foreachPlugin([connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onServerConnected(connectionID); } @@ -612,7 +610,7 @@ void PluginManager::on_serverDisconnected() const { qDebug("PluginManager: Disconnected from a server with connection ID %d", connectionID); #endif - foreachPlugin([connectionID](Plugin& plugin) { + foreachPlugin([connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onServerDisconnected(connectionID); } @@ -621,7 +619,8 @@ void PluginManager::on_serverDisconnected() const { void PluginManager::on_channelEntered(const Channel *newChannel, const Channel *prevChannel, const User *user) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: User" << user->qsName << "entered channel" << newChannel->qsName << "- ID:" << newChannel->iId; + qDebug() << "PluginManager: User" << user->qsName << "entered channel" << newChannel->qsName + << "- ID:" << newChannel->iId; #endif if (!Global::get().sh) { @@ -631,21 +630,22 @@ void PluginManager::on_channelEntered(const Channel *newChannel, const Channel * const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([user, newChannel, prevChannel, connectionID](Plugin& plugin) { + foreachPlugin([user, newChannel, prevChannel, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { - plugin.onChannelEntered(connectionID, user->uiSession, prevChannel ? prevChannel->iId : -1, newChannel->iId); + plugin.onChannelEntered(connectionID, user->uiSession, prevChannel ? prevChannel->iId : -1, + newChannel->iId); } }); } void PluginManager::on_channelExited(const Channel *channel, const User *user) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: User" << user->qsName << "left channel" << channel->qsName << "- ID:" << channel->iId; + qDebug() << "PluginManager: User" << user->qsName << "left channel" << channel->qsName << "- ID:" << channel->iId; #endif const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([user, channel, connectionID](Plugin& plugin) { + foreachPlugin([user, channel, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onChannelExited(connectionID, user->uiSession, channel->iId); } @@ -653,7 +653,7 @@ void PluginManager::on_channelExited(const Channel *channel, const User *user) c } QString getTalkingStateStr(Settings::TalkState ts) { - switch(ts) { + switch (ts) { case Settings::TalkState::Passive: return QString::fromLatin1("Passive"); case Settings::TalkState::Talking: @@ -670,10 +670,11 @@ QString getTalkingStateStr(Settings::TalkState ts) { } void PluginManager::on_userTalkingStateChanged() const { - const ClientUser *user = qobject_cast<ClientUser*>(QObject::sender()); + const ClientUser *user = qobject_cast< ClientUser * >(QObject::sender()); #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG if (user) { - qDebug() << "PluginManager: User" << user->qsName << "changed talking state to" << getTalkingStateStr(user->tsState); + qDebug() << "PluginManager: User" << user->qsName << "changed talking state to" + << getTalkingStateStr(user->tsState); } else { qCritical() << "PluginManager: Unable to identify ClientUser"; } @@ -683,7 +684,7 @@ void PluginManager::on_userTalkingStateChanged() const { // Convert Mumble's talking state to the TalkingState used in the API mumble_talking_state_t ts = INVALID; - switch(user->tsState) { + switch (user->tsState) { case Settings::TalkState::Passive: ts = PASSIVE; break; @@ -709,7 +710,7 @@ void PluginManager::on_userTalkingStateChanged() const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([user, ts, connectionID](Plugin& plugin) { + foreachPlugin([user, ts, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onUserTalkingStateChanged(connectionID, user->uiSession, ts); } @@ -717,54 +718,63 @@ void PluginManager::on_userTalkingStateChanged() const { } } -void PluginManager::on_audioInput(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech) const { +void PluginManager::on_audioInput(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool isSpeech) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: AudioInput with" << channelCount << "channels and" << sampleCount << "samples per channel. IsSpeech:" << isSpeech; + qDebug() << "PluginManager: AudioInput with" << channelCount << "channels and" << sampleCount + << "samples per channel. IsSpeech:" << isSpeech; #endif - foreachPlugin([inputPCM, sampleCount, channelCount, sampleRate, isSpeech](Plugin& plugin) { + foreachPlugin([inputPCM, sampleCount, channelCount, sampleRate, isSpeech](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onAudioInput(inputPCM, sampleCount, channelCount, sampleRate, isSpeech); } }); } -void PluginManager::on_audioSourceFetched(float* outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech, const ClientUser* user) const { +void PluginManager::on_audioSourceFetched(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool isSpeech, const ClientUser *user) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: AudioSource with" << channelCount << "channels and" << sampleCount << "samples per channel fetched. IsSpeech:" << isSpeech; + qDebug() << "PluginManager: AudioSource with" << channelCount << "channels and" << sampleCount + << "samples per channel fetched. IsSpeech:" << isSpeech; if (user != nullptr) { qDebug() << "Sender-ID:" << user->uiSession; } #endif - foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, isSpeech, user](Plugin& plugin) { + foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, isSpeech, user](Plugin &plugin) { if (plugin.isLoaded()) { - plugin.onAudioSourceFetched(outputPCM, sampleCount, channelCount, sampleRate, isSpeech, user ? user->uiSession : -1); + plugin.onAudioSourceFetched(outputPCM, sampleCount, channelCount, sampleRate, isSpeech, + user ? user->uiSession : -1); } }); } -void PluginManager::on_audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool *modifiedAudio) const { +void PluginManager::on_audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool *modifiedAudio) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: AudioOutput with" << channelCount << "channels and" << sampleCount << "samples per channel"; + qDebug() << "PluginManager: AudioOutput with" << channelCount << "channels and" << sampleCount + << "samples per channel"; #endif - foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, modifiedAudio](Plugin& plugin) { + foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, modifiedAudio](Plugin &plugin) { if (plugin.isLoaded()) { - if(plugin.onAudioOutputAboutToPlay(outputPCM, sampleCount, sampleRate, channelCount)) { + if (plugin.onAudioOutputAboutToPlay(outputPCM, sampleCount, sampleRate, channelCount)) { *modifiedAudio = true; } } }); } -void PluginManager::on_receiveData(const ClientUser *sender, const uint8_t *data, size_t dataLength, const char *dataID) const { +void PluginManager::on_receiveData(const ClientUser *sender, const uint8_t *data, size_t dataLength, + const char *dataID) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: Data with ID" << dataID << "and length" << dataLength << "received. Sender-ID:" << sender->uiSession; + qDebug() << "PluginManager: Data with ID" << dataID << "and length" << dataLength + << "received. Sender-ID:" << sender->uiSession; #endif const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([sender, data, dataLength, dataID, connectionID](Plugin& plugin) { + foreachPlugin([sender, data, dataLength, dataID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onReceiveData(connectionID, sender->uiSession, data, dataLength, dataID); } @@ -778,7 +788,7 @@ void PluginManager::on_serverSynchronized() const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([connectionID](Plugin& plugin) { + foreachPlugin([connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onServerSynchronized(connectionID); } @@ -792,7 +802,7 @@ void PluginManager::on_userAdded(mumble_userid_t userID) const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([userID, connectionID](Plugin& plugin) { + foreachPlugin([userID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onUserAdded(connectionID, userID); }; @@ -806,7 +816,7 @@ void PluginManager::on_userRemoved(mumble_userid_t userID) const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([userID, connectionID](Plugin& plugin) { + foreachPlugin([userID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onUserRemoved(connectionID, userID); }; @@ -820,7 +830,7 @@ void PluginManager::on_channelAdded(mumble_channelid_t channelID) const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([channelID, connectionID](Plugin& plugin) { + foreachPlugin([channelID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onChannelAdded(connectionID, channelID); }; @@ -834,7 +844,7 @@ void PluginManager::on_channelRemoved(mumble_channelid_t channelID) const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([channelID, connectionID](Plugin& plugin) { + foreachPlugin([channelID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onChannelRemoved(connectionID, channelID); }; @@ -848,7 +858,7 @@ void PluginManager::on_channelRenamed(int channelID) const { const mumble_connection_t connectionID = Global::get().sh->getConnectionID(); - foreachPlugin([channelID, connectionID](Plugin& plugin) { + foreachPlugin([channelID, connectionID](Plugin &plugin) { if (plugin.isLoaded()) { plugin.onChannelRenamed(connectionID, channelID); }; @@ -857,8 +867,8 @@ void PluginManager::on_channelRenamed(int channelID) const { void PluginManager::on_keyEvent(unsigned int key, Qt::KeyboardModifiers modifiers, bool isPress) const { #ifdef MUMBLE_PLUGIN_CALLBACK_DEBUG - qDebug() << "PluginManager: Key event detected: keyCode =" << key << "modifiers:" - << modifiers << "isPress =" << isPress; + qDebug() << "PluginManager: Key event detected: keyCode =" << key << "modifiers:" << modifiers + << "isPress =" << isPress; #else Q_UNUSED(modifiers); #endif @@ -889,7 +899,8 @@ void PluginManager::on_syncPositionalData() { QMutexLocker mLock(&m_sentDataMutex); QReadLocker rLock(&m_positionalData.m_lock); - if (m_sentData.context != m_positionalData.m_context || m_sentData.identity != m_positionalData.m_identity ) { + if (m_sentData.context != m_positionalData.m_context + || m_sentData.identity != m_positionalData.m_identity) { MumbleProto::UserState mpus; mpus.set_session(Global::get().uiSession); diff --git a/src/mumble/PluginManager.h b/src/mumble/PluginManager.h index 02f4db5fa..891e0ff91 100644 --- a/src/mumble/PluginManager.h +++ b/src/mumble/PluginManager.h @@ -6,27 +6,27 @@ #ifndef MUMBLE_MUMBLE_PLUGINMANAGER_H_ #define MUMBLE_MUMBLE_PLUGINMANAGER_H_ +#include <QHash> +#include <QMutex> #include <QObject> #include <QReadWriteLock> #include <QString> #include <QTimer> -#include <QHash> -#include <QMutex> #ifdef Q_OS_WIN - #ifndef NOMINMAX - #define NOMINMAX - #endif - #include <windows.h> +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include <windows.h> #endif -#include "Plugin.h" #include "MumbleApplication.h" +#include "Plugin.h" #include "PositionalData.h" -#include "User.h" -#include "ClientUser.h" #include "Channel.h" -#include "Settings.h" +#include "ClientUser.h" #include "PluginUpdater.h" +#include "Settings.h" +#include "User.h" #include <functional> @@ -41,239 +41,254 @@ struct PluginManager_SentData { /// finding, loading and managing the plugins. It also is responsible for invoking callback functions in the plugins /// and can be used by Mumble to communicate with them class PluginManager : public QObject { - private: - Q_OBJECT - Q_DISABLE_COPY(PluginManager) - protected: - /// Lock for pluginHashMap. This lock has to be aquired when accessing pluginHashMap - mutable QReadWriteLock m_pluginCollectionLock; - /// A map between plugin-IDs and the actual plugin objects. You have to aquire pluginCollectionLock before - /// accessing this map. - QHash<plugin_id_t, plugin_ptr_t> m_pluginHashMap; - /// A set of directories to search plugins in - QSet<QString> m_pluginSearchPaths; +private: + Q_OBJECT + Q_DISABLE_COPY(PluginManager) +protected: + /// Lock for pluginHashMap. This lock has to be aquired when accessing pluginHashMap + mutable QReadWriteLock m_pluginCollectionLock; + /// A map between plugin-IDs and the actual plugin objects. You have to aquire pluginCollectionLock before + /// accessing this map. + QHash< plugin_id_t, plugin_ptr_t > m_pluginHashMap; + /// A set of directories to search plugins in + QSet< QString > m_pluginSearchPaths; #ifdef Q_OS_WIN - // This stuff is apparently needed on Windows in order to deal with DLLs - HANDLE m_hToken; - TOKEN_PRIVILEGES m_tpPrevious; - DWORD m_cbPrevious; + // This stuff is apparently needed on Windows in order to deal with DLLs + HANDLE m_hToken; + TOKEN_PRIVILEGES m_tpPrevious; + DWORD m_cbPrevious; #endif - /// The PositionalData object holding the current positional data (as retrieved by the respective plugin) - PositionalData m_positionalData; + /// The PositionalData object holding the current positional data (as retrieved by the respective plugin) + PositionalData m_positionalData; + + /// A timer that causes the manager to regularly check for available plugins that can currently + /// deliver positional data. + QTimer m_positionalDataCheckTimer; + + /// The mutex for sentData. This has to be aquired before accessing sentData + mutable QMutex m_sentDataMutex; + /// The bits of the positional data that have already been sent to the server. It is used to determine whether + /// the new data has to be sent to the server (in case it has changed). You have ti aquire sentDataMutex before + /// accessing this field. + PluginManager_SentData m_sentData; - /// A timer that causes the manager to regularly check for available plugins that can currently - /// deliver positional data. - QTimer m_positionalDataCheckTimer; + /// The lock for activePositionalDataPlugin. It has to be aquired before accessing the respective field. + mutable QReadWriteLock m_activePosDataPluginLock; + /// The plugin that is currently used to retrieve positional data. You have to aquire activePosDataPluginLock before + /// accessing this field. + plugin_ptr_t m_activePositionalDataPlugin; + /// The PluginUpdater used to handle plugin updates. + PluginUpdater m_updater; - /// The mutex for sentData. This has to be aquired before accessing sentData - mutable QMutex m_sentDataMutex; - /// The bits of the positional data that have already been sent to the server. It is used to determine whether - /// the new data has to be sent to the server (in case it has changed). You have ti aquire sentDataMutex before - /// accessing this field. - PluginManager_SentData m_sentData; + // We override the QObject::eventFilter function in order to be able to install the pluginManager as an event filter + // to the main application in order to get notified about keystrokes. + bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE; - /// The lock for activePositionalDataPlugin. It has to be aquired before accessing the respective field. - mutable QReadWriteLock m_activePosDataPluginLock; - /// The plugin that is currently used to retrieve positional data. You have to aquire activePosDataPluginLock before - /// accessing this field. - plugin_ptr_t m_activePositionalDataPlugin; - /// The PluginUpdater used to handle plugin updates. - PluginUpdater m_updater; + /// Unloads all plugins that are currently loaded. + void unloadPlugins() const; + /// Clears the current list of plugins + void clearPlugins(); + /// Iterates over the plugins and tries to select a plugin that currently claims to be able to deliver positional + /// data. If it found a plugin, activePositionalDataPlugin is set accordingly. If not, it is set to nullptr. + /// + /// @returns Whether this function succeeded in finding such a plugin + bool selectActivePositionalDataPlugin(); - // We override the QObject::eventFilter function in order to be able to install the pluginManager as an event filter - // to the main application in order to get notified about keystrokes. - bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE; - - /// Unloads all plugins that are currently loaded. - void unloadPlugins() const; - /// Clears the current list of plugins - void clearPlugins(); - /// Iterates over the plugins and tries to select a plugin that currently claims to be able to deliver positional data. If - /// it found a plugin, activePositionalDataPlugin is set accordingly. If not, it is set to nullptr. - /// - /// @returns Whether this function succeeded in finding such a plugin - bool selectActivePositionalDataPlugin(); + /// A internal helper function that iterates over all plugins and calls the given function providing the current + /// plugin as a parameter. + void foreachPlugin(std::function< void(Plugin &) >) const; - /// A internal helper function that iterates over all plugins and calls the given function providing the current plugin as - /// a parameter. - void foreachPlugin(std::function<void(Plugin&)>) const; - public: - // How often positional data (identity & context) should be synched with the server if there is any (in ms) - static constexpr int POSITIONAL_SERVER_SYNC_INTERVAL = 500; - // How often the manager should check for available positional data plugins - static constexpr int POSITIONAL_DATA_CHECK_INTERVAL = 1000; +public: + // How often positional data (identity & context) should be synched with the server if there is any (in ms) + static constexpr int POSITIONAL_SERVER_SYNC_INTERVAL = 500; + // How often the manager should check for available positional data plugins + static constexpr int POSITIONAL_DATA_CHECK_INTERVAL = 1000; - /// Constructor - /// - /// @param additionalSearchPaths A pointer to a set of additional search paths or nullptr if no additional - /// paths are required. - /// @param p The parent QObject - PluginManager(QSet<QString> *additionalSearchPaths = nullptr, QObject *p = nullptr); - /// Destructor - virtual ~PluginManager() Q_DECL_OVERRIDE; + /// Constructor + /// + /// @param additionalSearchPaths A pointer to a set of additional search paths or nullptr if no additional + /// paths are required. + /// @param p The parent QObject + PluginManager(QSet< QString > *additionalSearchPaths = nullptr, QObject *p = nullptr); + /// Destructor + virtual ~PluginManager() Q_DECL_OVERRIDE; - /// @param pluginID The ID of the plugin that should be retreved - /// @returns A pointer to the plugin with the given ID or nullptr if no such plugin could be found - const_plugin_ptr_t getPlugin(plugin_id_t pluginID) const; - /// Checks whether there are any updates for the plugins and if there are it invokes the PluginUpdater. - void checkForPluginUpdates(); - /// Fetches positional data from the activePositionalDataPlugin if there is one set. This function will update the - /// positionalData field - /// - /// @returns Whether the positional data could be retrieved successfully - bool fetchPositionalData(); - /// Unlinks the currently active positional data plugin. Effectively this sets activePositionalDataPlugin to nullptr - void unlinkPositionalData(); - /// @returns Whether positional data is currently available (it has been successfully set via fetchPositionalData) - bool isPositionalDataAvailable() const; - /// @returns The most recent positional data - const PositionalData& getPositionalData() const; - /// Enables positional data gathering for the plugin with the given ID. A plugin is only even asked whether it can deliver - /// positional data if this is enabled. - /// - /// @param pluginID The ID of the plugin to access - /// @param enable Whether to enable positional data (alternative is to disable it) - void enablePositionalDataFor(plugin_id_t pluginID, bool enable = true) const; - /// @returns A const vector of the plugins - const QVector<const_plugin_ptr_t> getPlugins(bool sorted = false) const; - /// Loads the plugin with the given ID. Loading means initializing the plugin. - /// - /// @param pluginID The ID of the plugin to load - /// @returns Whether the plugin could be successfully loaded - bool loadPlugin(plugin_id_t pluginID) const; - /// Unloads the plugin with the given ID. Unloading means shutting the plugign down. - /// - /// @param pluginID The ID of the plugin to unload - void unloadPlugin(plugin_id_t pluginID) const; - /// Unloads the given plugin. Unloading means shutting the plugign down. - /// - /// @param plugin The plugin to unload - void unloadPlugin(Plugin &plugin) const; - /// Clears the plugin from the list of known plugins - /// - /// @param pluginID The ID of the plugin to forget about - /// @returns Whether the plugin has been cleared successfully - bool clearPlugin(plugin_id_t pluginID); - /// Deactivates the given features for the plugin with the given ID - /// - /// @param pluginID The ID of the plugin to access - /// @param features The feature set that should be deactivated. The features are or'ed together. - /// @returns The feature set that could not be deactivated - uint32_t deactivateFeaturesFor(plugin_id_t pluginID, uint32_t features) const; - /// Allows or forbids the given plugin to monitor keyboard events. - /// - /// @param pluginID The ID of the plugin to access - /// @param allow Whether to allow the monitoring or not - void allowKeyboardMonitoringFor(plugin_id_t pluginID, bool allow) const; - /// Checks whether a plugin with the given ID exists. - /// - /// @param pluginID The ID to check - /// @returns Whether such a plugin exists - bool pluginExists(plugin_id_t pluginID) const; + /// @param pluginID The ID of the plugin that should be retreved + /// @returns A pointer to the plugin with the given ID or nullptr if no such plugin could be found + const_plugin_ptr_t getPlugin(plugin_id_t pluginID) const; + /// Checks whether there are any updates for the plugins and if there are it invokes the PluginUpdater. + void checkForPluginUpdates(); + /// Fetches positional data from the activePositionalDataPlugin if there is one set. This function will update the + /// positionalData field + /// + /// @returns Whether the positional data could be retrieved successfully + bool fetchPositionalData(); + /// Unlinks the currently active positional data plugin. Effectively this sets activePositionalDataPlugin to nullptr + void unlinkPositionalData(); + /// @returns Whether positional data is currently available (it has been successfully set via fetchPositionalData) + bool isPositionalDataAvailable() const; + /// @returns The most recent positional data + const PositionalData &getPositionalData() const; + /// Enables positional data gathering for the plugin with the given ID. A plugin is only even asked whether it can + /// deliver positional data if this is enabled. + /// + /// @param pluginID The ID of the plugin to access + /// @param enable Whether to enable positional data (alternative is to disable it) + void enablePositionalDataFor(plugin_id_t pluginID, bool enable = true) const; + /// @returns A const vector of the plugins + const QVector< const_plugin_ptr_t > getPlugins(bool sorted = false) const; + /// Loads the plugin with the given ID. Loading means initializing the plugin. + /// + /// @param pluginID The ID of the plugin to load + /// @returns Whether the plugin could be successfully loaded + bool loadPlugin(plugin_id_t pluginID) const; + /// Unloads the plugin with the given ID. Unloading means shutting the plugign down. + /// + /// @param pluginID The ID of the plugin to unload + void unloadPlugin(plugin_id_t pluginID) const; + /// Unloads the given plugin. Unloading means shutting the plugign down. + /// + /// @param plugin The plugin to unload + void unloadPlugin(Plugin &plugin) const; + /// Clears the plugin from the list of known plugins + /// + /// @param pluginID The ID of the plugin to forget about + /// @returns Whether the plugin has been cleared successfully + bool clearPlugin(plugin_id_t pluginID); + /// Deactivates the given features for the plugin with the given ID + /// + /// @param pluginID The ID of the plugin to access + /// @param features The feature set that should be deactivated. The features are or'ed together. + /// @returns The feature set that could not be deactivated + uint32_t deactivateFeaturesFor(plugin_id_t pluginID, uint32_t features) const; + /// Allows or forbids the given plugin to monitor keyboard events. + /// + /// @param pluginID The ID of the plugin to access + /// @param allow Whether to allow the monitoring or not + void allowKeyboardMonitoringFor(plugin_id_t pluginID, bool allow) const; + /// Checks whether a plugin with the given ID exists. + /// + /// @param pluginID The ID to check + /// @returns Whether such a plugin exists + bool pluginExists(plugin_id_t pluginID) const; - public slots: - /// Rescans the plugin directory and load all plugins from there after having cleared the current plugin list - void rescanPlugins(); - /// Slot that gets called whenever data from another plugin has been received. This function will then delegate - /// this to the respective plugin callback - /// - /// @param sender A pointer to the ClientUser whose client has sent the data - /// @param data The byte-array representing the sent data - /// @param dataLength The length of the data array - /// @param dataID The ID of the data - void on_receiveData(const ClientUser *sender, const uint8_t *data, size_t dataLength, const char *dataID) const; - /// Slot that gets called when the local client connects to a server. It will delegate it to the respective plugin callback. - void on_serverConnected() const; - /// Slot that gets called when the local client disconnects to a server. It will delegate it to the respective plugin callback. - void on_serverDisconnected() const; - /// Slot that gets called when a client enters a channel. It will delegate it to the respective plugin callback. - /// - /// @param newChannel A pointer to the new channel - /// @param prevChannel A pointer to the previous channel or nullptr if no such channel exists - /// @param user A pointer to the user that entered the channel - void on_channelEntered(const Channel *newChannel, const Channel *prevChannel, const User *user) const; - /// Slot that gets called when a client leaves a channel. It will delegate it to the respective plugin callback. - /// - /// @param channel A pointer to the channel that has been left - /// @param user A pointer to the user that entered the channel - void on_channelExited(const Channel *channel, const User *user) const; - /// Slot that gets called when the local client changes its talking state. It will delegate it to the respective plugin callback. - void on_userTalkingStateChanged() const; - /// Slot that gets called when the local client receives audio input. It will delegate it to the respective plugin callback. - /// - /// @param inputPCM The array containing the input PCM (pulse-code-modulation). Its length is sampleCount * channelCount - /// @param sampleCount The amount of samples in the PCM array - /// @param channelCount The amount of channels in the PCM array - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech Whether Mumble considers this input as speech - void on_audioInput(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech) const; - /// Slot that gets called when the local client has fetched an audio source. It will delegate it to the respective plugin callback. - /// - /// @param outputPCM The array containing the output-PCM (pulse-code-modulation). Its length is sampleCount * channelCount - /// @param sampleCount The amount of samples in the PCM array - /// @param channelCount The amount of channels in the PCM array - /// @param sampleRate The used sample rate in Hz - /// @param isSpeech Whether Mumble considers this input as speech - /// @param user A pointer to the ClientUser the audio source corresposnds to - void on_audioSourceFetched(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, bool isSpeech, - const ClientUser *user) const; - /// Slot that gets called when the local client is about to play some audio. It will delegate it to the respective plugin callback. - /// - /// @param outputPCM The array containing the output-PCM (pulse-code-modulation). Its length is sampleCount * channelCount - /// @param sampleCount The amount of samples in the PCM array - /// @param channelCount The amount of channels in the PCM array - /// @param sampleRate The used sample rate in Hz - void on_audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, - bool *modifiedAudio) const; - /// Slot that gets called after the local client has finished synchronizing with the server. It will delegate it to the respective - /// plugin callback. - void on_serverSynchronized() const; - /// Slot that gets called when a new user is added to the user model. It will delegate it to the respective plugin callbacks. - /// - /// @param userID The ID of the added user - void on_userAdded(unsigned int userID) const; - /// Slot that gets called when a user is removed from the user model. It will delegate it to the respective plugin callbacks. - /// - /// @param userID The ID of the removed user - void on_userRemoved(unsigned int userID) const; - /// Slot that gets called when a new channel is added to the user model. It will delegate it to the respective plugin callbacks. - /// - /// @param channelID The ID of the added channel - void on_channelAdded(int channelID) const; - /// Slot that gets called when a channel is removed from the user model. It will delegate it to the respective plugin callbacks. - /// - /// @param channelID The ID of the removed channel - void on_channelRemoved(int channelID) const; - /// Slot that gets called when a channel is renamed. It will delegate it to the respective plugin callbacks. - /// - /// @param channelID The ID of the renamed channel - void on_channelRenamed(int channelID) const; - /// Slot that gets called when a key has been pressed or released while Mumble has keyboard focus. - /// - /// @param key The code of the affected key (as encoded by Qt::Key) - /// @param modifiers The modifiers that were active in the moment of the event - /// @param isPress True if the key has been pressed, false if it has been released - void on_keyEvent(unsigned int key, Qt::KeyboardModifiers modifiers, bool isPress) const; +public slots: + /// Rescans the plugin directory and load all plugins from there after having cleared the current plugin list + void rescanPlugins(); + /// Slot that gets called whenever data from another plugin has been received. This function will then delegate + /// this to the respective plugin callback + /// + /// @param sender A pointer to the ClientUser whose client has sent the data + /// @param data The byte-array representing the sent data + /// @param dataLength The length of the data array + /// @param dataID The ID of the data + void on_receiveData(const ClientUser *sender, const uint8_t *data, size_t dataLength, const char *dataID) const; + /// Slot that gets called when the local client connects to a server. It will delegate it to the respective plugin + /// callback. + void on_serverConnected() const; + /// Slot that gets called when the local client disconnects to a server. It will delegate it to the respective + /// plugin callback. + void on_serverDisconnected() const; + /// Slot that gets called when a client enters a channel. It will delegate it to the respective plugin callback. + /// + /// @param newChannel A pointer to the new channel + /// @param prevChannel A pointer to the previous channel or nullptr if no such channel exists + /// @param user A pointer to the user that entered the channel + void on_channelEntered(const Channel *newChannel, const Channel *prevChannel, const User *user) const; + /// Slot that gets called when a client leaves a channel. It will delegate it to the respective plugin callback. + /// + /// @param channel A pointer to the channel that has been left + /// @param user A pointer to the user that entered the channel + void on_channelExited(const Channel *channel, const User *user) const; + /// Slot that gets called when the local client changes its talking state. It will delegate it to the respective + /// plugin callback. + void on_userTalkingStateChanged() const; + /// Slot that gets called when the local client receives audio input. It will delegate it to the respective plugin + /// callback. + /// + /// @param inputPCM The array containing the input PCM (pulse-code-modulation). Its length is sampleCount * + /// channelCount + /// @param sampleCount The amount of samples in the PCM array + /// @param channelCount The amount of channels in the PCM array + /// @param sampleRate The used sample rate in Hz + /// @param isSpeech Whether Mumble considers this input as speech + void on_audioInput(short *inputPCM, unsigned int sampleCount, unsigned int channelCount, unsigned int sampleRate, + bool isSpeech) const; + /// Slot that gets called when the local client has fetched an audio source. It will delegate it to the respective + /// plugin callback. + /// + /// @param outputPCM The array containing the output-PCM (pulse-code-modulation). Its length is sampleCount * + /// channelCount + /// @param sampleCount The amount of samples in the PCM array + /// @param channelCount The amount of channels in the PCM array + /// @param sampleRate The used sample rate in Hz + /// @param isSpeech Whether Mumble considers this input as speech + /// @param user A pointer to the ClientUser the audio source corresposnds to + void on_audioSourceFetched(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool isSpeech, const ClientUser *user) const; + /// Slot that gets called when the local client is about to play some audio. It will delegate it to the respective + /// plugin callback. + /// + /// @param outputPCM The array containing the output-PCM (pulse-code-modulation). Its length is sampleCount * + /// channelCount + /// @param sampleCount The amount of samples in the PCM array + /// @param channelCount The amount of channels in the PCM array + /// @param sampleRate The used sample rate in Hz + void on_audioOutputAboutToPlay(float *outputPCM, unsigned int sampleCount, unsigned int channelCount, + unsigned int sampleRate, bool *modifiedAudio) const; + /// Slot that gets called after the local client has finished synchronizing with the server. It will delegate it to + /// the respective plugin callback. + void on_serverSynchronized() const; + /// Slot that gets called when a new user is added to the user model. It will delegate it to the respective plugin + /// callbacks. + /// + /// @param userID The ID of the added user + void on_userAdded(unsigned int userID) const; + /// Slot that gets called when a user is removed from the user model. It will delegate it to the respective plugin + /// callbacks. + /// + /// @param userID The ID of the removed user + void on_userRemoved(unsigned int userID) const; + /// Slot that gets called when a new channel is added to the user model. It will delegate it to the respective + /// plugin callbacks. + /// + /// @param channelID The ID of the added channel + void on_channelAdded(int channelID) const; + /// Slot that gets called when a channel is removed from the user model. It will delegate it to the respective + /// plugin callbacks. + /// + /// @param channelID The ID of the removed channel + void on_channelRemoved(int channelID) const; + /// Slot that gets called when a channel is renamed. It will delegate it to the respective plugin callbacks. + /// + /// @param channelID The ID of the renamed channel + void on_channelRenamed(int channelID) const; + /// Slot that gets called when a key has been pressed or released while Mumble has keyboard focus. + /// + /// @param key The code of the affected key (as encoded by Qt::Key) + /// @param modifiers The modifiers that were active in the moment of the event + /// @param isPress True if the key has been pressed, false if it has been released + void on_keyEvent(unsigned int key, Qt::KeyboardModifiers modifiers, bool isPress) const; - /// Slot that gets called whenever the positional data should be synchronized with the server. Before it does that, it tries to - /// fetch new data. - void on_syncPositionalData(); - /// Slot called if there are plugin updates available - void on_updatesAvailable(); + /// Slot that gets called whenever the positional data should be synchronized with the server. Before it does that, + /// it tries to fetch new data. + void on_syncPositionalData(); + /// Slot called if there are plugin updates available + void on_updatesAvailable(); - protected slots: - /// If there is no active positional data plugin, this function will initiate searching for a - /// new one. - void checkForAvailablePositionalDataPlugin(); +protected slots: + /// If there is no active positional data plugin, this function will initiate searching for a + /// new one. + void checkForAvailablePositionalDataPlugin(); - signals: - /// A signal emitted if the PluginManager (acting as an event filter) detected - /// a QKeyEvent. - /// - /// @param key The code of the affected key (as encoded by Qt::Key) - /// @param modifiers The modifiers that were active in the moment of the event - /// @param isPress True if the key has been pressed, false if it has been released - void keyEvent(unsigned int key, Qt::KeyboardModifiers modifiers, bool isPress); +signals: + /// A signal emitted if the PluginManager (acting as an event filter) detected + /// a QKeyEvent. + /// + /// @param key The code of the affected key (as encoded by Qt::Key) + /// @param modifiers The modifiers that were active in the moment of the event + /// @param isPress True if the key has been pressed, false if it has been released + void keyEvent(unsigned int key, Qt::KeyboardModifiers modifiers, bool isPress); }; #endif diff --git a/src/mumble/PluginUpdater.cpp b/src/mumble/PluginUpdater.cpp index e7f4f2594..694f977a6 100644 --- a/src/mumble/PluginUpdater.cpp +++ b/src/mumble/PluginUpdater.cpp @@ -4,31 +4,26 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include "PluginUpdater.h" -#include "PluginManager.h" #include "Log.h" #include "PluginInstaller.h" +#include "PluginManager.h" #include "Global.h" -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QLabel> -#include <QtCore/QHashIterator> -#include <QtCore/QSignalBlocker> +#include <QNetworkRequest> +#include <QtConcurrent> #include <QtCore/QByteArray> #include <QtCore/QDir> #include <QtCore/QFile> -#include <QtConcurrent> -#include <QNetworkRequest> +#include <QtCore/QHashIterator> +#include <QtCore/QSignalBlocker> +#include <QtWidgets/QCheckBox> +#include <QtWidgets/QLabel> #include <algorithm> PluginUpdater::PluginUpdater(QWidget *parent) - : QDialog(parent), - m_wasInterrupted(false), - m_dataMutex(), - m_pluginsToUpdate(), - m_networkManager(), + : QDialog(parent), m_wasInterrupted(false), m_dataMutex(), m_pluginsToUpdate(), m_networkManager(), m_pluginUpdateWidgets() { - QObject::connect(&m_networkManager, &QNetworkAccessManager::finished, this, &PluginUpdater::on_updateDownloaded); } @@ -41,7 +36,7 @@ void PluginUpdater::checkForUpdates() { QtConcurrent::run([this]() { QMutexLocker lock(&m_dataMutex); - const QVector<const_plugin_ptr_t> plugins = Global::get().pluginManager->getPlugins(); + const QVector< const_plugin_ptr_t > plugins = Global::get().pluginManager->getPlugins(); for (int i = 0; i < plugins.size(); i++) { const_plugin_ptr_t plugin = plugins[i]; @@ -100,7 +95,7 @@ void PluginUpdater::populateUI() { QMutexLocker l(&m_dataMutex); for (int i = 0; i < m_pluginsToUpdate.size(); i++) { UpdateEntry currentEntry = m_pluginsToUpdate[i]; - plugin_id_t pluginID = currentEntry.pluginID; + plugin_id_t pluginID = currentEntry.pluginID; const_plugin_ptr_t plugin = Global::get().pluginManager->getPlugin(pluginID); @@ -125,15 +120,16 @@ void PluginUpdater::populateUI() { } // sort the plugins alphabetically - std::sort(m_pluginUpdateWidgets.begin(), m_pluginUpdateWidgets.end(), [](const UpdateWidgetPair &first, const UpdateWidgetPair &second) { - return first.pluginCheckBox->text().compare(second.pluginCheckBox->text(), Qt::CaseInsensitive) < 0; - }); + std::sort(m_pluginUpdateWidgets.begin(), m_pluginUpdateWidgets.end(), + [](const UpdateWidgetPair &first, const UpdateWidgetPair &second) { + return first.pluginCheckBox->text().compare(second.pluginCheckBox->text(), Qt::CaseInsensitive) < 0; + }); // add the widgets to the layout for (int i = 0; i < m_pluginUpdateWidgets.size(); i++) { UpdateWidgetPair ¤tPair = m_pluginUpdateWidgets[i]; - static_cast<QFormLayout*>(qwContent->layout())->addRow(currentPair.pluginCheckBox, currentPair.urlLabel); + static_cast< QFormLayout * >(qwContent->layout())->addRow(currentPair.pluginCheckBox, currentPair.urlLabel); } } @@ -160,7 +156,7 @@ void PluginUpdater::on_selectAll(int checkState) { for (int i = 0; i < m_pluginUpdateWidgets.size(); i++) { UpdateWidgetPair ¤tPair = m_pluginUpdateWidgets[i]; - currentPair.pluginCheckBox->setCheckState(static_cast<Qt::CheckState>(checkState)); + currentPair.pluginCheckBox->setCheckState(static_cast< Qt::CheckState >(checkState)); } } @@ -210,9 +206,9 @@ void PluginUpdater::on_finished(int result) { bool updateCurrent = false; for (int k = 0; k < m_pluginUpdateWidgets.size(); k++) { QCheckBox *checkBox = m_pluginUpdateWidgets[k].pluginCheckBox; - QVariant idVariant = checkBox->property("pluginID"); + QVariant idVariant = checkBox->property("pluginID"); - if (idVariant.isValid() && static_cast<plugin_id_t>(idVariant.toInt()) == id) { + if (idVariant.isValid() && static_cast< plugin_id_t >(idVariant.toInt()) == id) { updateCurrent = checkBox->isChecked(); break; } @@ -263,8 +259,8 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { if (!foundID) { // Can't match the URL to a pluginID - qWarning() << "PluginUpdater: Requested update for plugin from" - << reply->url() << "but didn't find corresponding plugin again!"; + qWarning() << "PluginUpdater: Requested update for plugin from" << reply->url() + << "but didn't find corresponding plugin again!"; return; } @@ -273,8 +269,8 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { if (!plugin) { // Can't find plugin with given ID - qWarning() << "PluginUpdater: Got update for plugin with id" - << entry.pluginID << "but it doesn't seem to exist anymore!"; + qWarning() << "PluginUpdater: Got update for plugin with id" << entry.pluginID + << "but it doesn't seem to exist anymore!"; return; } @@ -282,13 +278,11 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { if (reply->error() != QNetworkReply::NoError) { // There was an error during this request. Report it Log::logOrDefer(Log::Warning, - tr("Unable to download plugin update for \"%1\" from \"%2\" (%3)").arg( - plugin->getName()).arg(reply->url().toString()).arg( - QString::fromLatin1( - QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(reply->error()) - ) - ) - ); + tr("Unable to download plugin update for \"%1\" from \"%2\" (%3)") + .arg(plugin->getName()) + .arg(reply->url().toString()) + .arg(QString::fromLatin1( + QMetaEnum::fromType< QNetworkReply::NetworkError >().valueToKey(reply->error())))); return; } @@ -300,13 +294,14 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { // We have been redirected if (entry.redirects >= MAX_REDIRECTS - 1) { // Maximum redirect count exceeded - Log::logOrDefer(Log::Warning, tr("Update for plugin \"%1\" failed due to too many redirects").arg(plugin->getName())); + Log::logOrDefer(Log::Warning, + tr("Update for plugin \"%1\" failed due to too many redirects").arg(plugin->getName())); return; } QUrl redirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); - // Because the redirection url can be relative, + // Because the redirection url can be relative, // we have to use the previous one to resolve it redirectedUrl = reply->url().resolved(redirectedUrl); @@ -329,9 +324,10 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { if (httpStatusCode < 200 || httpStatusCode >= 300) { // HTTP request has failed Log::logOrDefer(Log::Warning, - tr("Unable to download plugin update for \"%1\" from \"%2\" (HTTP status code %3)").arg( - plugin->getName()).arg(reply->url().toString()).arg(httpStatusCode) - ); + tr("Unable to download plugin update for \"%1\" from \"%2\" (HTTP status code %3)") + .arg(plugin->getName()) + .arg(reply->url().toString()) + .arg(httpStatusCode)); return; } @@ -341,8 +337,8 @@ void PluginUpdater::on_updateDownloaded(QNetworkReply *reply) { // Write the content to a file in the temp-dir if (content.isEmpty()) { - qWarning() << "PluginUpdater: Update for" << plugin->getName() << "from" - << reply->url().toString() << "resulted in no content!"; + qWarning() << "PluginUpdater: Update for" << plugin->getName() << "from" << reply->url().toString() + << "resulted in no content!"; return; } diff --git a/src/mumble/PluginUpdater.h b/src/mumble/PluginUpdater.h index 2d9041d3d..499325f4d 100644 --- a/src/mumble/PluginUpdater.h +++ b/src/mumble/PluginUpdater.h @@ -6,16 +6,16 @@ #ifndef MUMBLE_MUMBLE_PLUGINUPDATER_H_ #define MUMBLE_MUMBLE_PLUGINUPDATER_H_ -#include <QtCore/QVector> -#include <QtCore/QUrl> -#include <QtCore/QMutex> #include <QNetworkAccessManager> #include <QNetworkReply> +#include <QtCore/QMutex> +#include <QtCore/QUrl> +#include <QtCore/QVector> #include <atomic> -#include "ui_PluginUpdater.h" #include "Plugin.h" +#include "ui_PluginUpdater.h" /// A helper struct to store a pair of a CheckBox and a label corresponding to /// a single plugin. @@ -36,72 +36,72 @@ struct UpdateEntry { /// A class designed for managing plugin updates. At the same time this also represents /// a Dialog that can be used to prompt the user whether certain updates should be updated. class PluginUpdater : public QDialog, public Ui::PluginUpdater { - private: - Q_OBJECT; - Q_DISABLE_COPY(PluginUpdater); +private: + Q_OBJECT; + Q_DISABLE_COPY(PluginUpdater); - protected: - /// An atomic flag indicating whether the plugin update has been interrupted. It is used - /// to exit some loops in different threads before they are done. - std::atomic<bool> m_wasInterrupted; - /// A mutex for m_pluginsToUpdate. - QMutex m_dataMutex; - /// A vector holding plugins that can be updated by storing a pluginID and the download URL - /// in form of an UpdateEntry. - QVector<UpdateEntry> m_pluginsToUpdate; - /// The NetworkManager used to perform the downloding of plugins. - QNetworkAccessManager m_networkManager; - /// A vector of the UI elements created for the individual plugins (in form of UpdateWidgetPairs). - /// NOTE: This vector may only be accessed from the UI thread this dialog is living in! - QVector<UpdateWidgetPair> m_pluginUpdateWidgets; +protected: + /// An atomic flag indicating whether the plugin update has been interrupted. It is used + /// to exit some loops in different threads before they are done. + std::atomic< bool > m_wasInterrupted; + /// A mutex for m_pluginsToUpdate. + QMutex m_dataMutex; + /// A vector holding plugins that can be updated by storing a pluginID and the download URL + /// in form of an UpdateEntry. + QVector< UpdateEntry > m_pluginsToUpdate; + /// The NetworkManager used to perform the downloding of plugins. + QNetworkAccessManager m_networkManager; + /// A vector of the UI elements created for the individual plugins (in form of UpdateWidgetPairs). + /// NOTE: This vector may only be accessed from the UI thread this dialog is living in! + QVector< UpdateWidgetPair > m_pluginUpdateWidgets; - /// Populates the UI with plugins that have been found to have an update available (through a call - /// to checkForUpdates()). - void populateUI(); + /// Populates the UI with plugins that have been found to have an update available (through a call + /// to checkForUpdates()). + void populateUI(); - public: - /// Constructor - /// - /// @param parent A pointer to the QWidget parent of this object - PluginUpdater(QWidget *parent = nullptr); - /// Destructor - ~PluginUpdater(); +public: + /// Constructor + /// + /// @param parent A pointer to the QWidget parent of this object + PluginUpdater(QWidget *parent = nullptr); + /// Destructor + ~PluginUpdater(); - // The maximum number of redirects to allow - static constexpr int MAX_REDIRECTS = 10; + // The maximum number of redirects to allow + static constexpr int MAX_REDIRECTS = 10; - /// Triggers an update check for all plugins that are currently recognized by Mumble. This is done - /// in a non-blocking fashion (in another thread). Once all plugins have been checked and if there - /// are updates available, the updatesAvailable signal is emitted. - void checkForUpdates(); - /// Launches a Dialog that asks the user which of the plugins an update has been found for, shall be - /// updated. If the user has selected at least selected one plugin and has accepted the dialog, this - /// function will automatically call update(). - void promptAndUpdate(); - /// Starts the update process of the plugins. This is done asynchronously. - void update(); - public slots: - /// Clears the UI from the widgets created for the individual plugins. - void clearUI(); - /// Slot triggered if the user changes the state of the selectAll CheckBox. - void on_selectAll(int checkState); - /// Slot triggered if the user toggles the CheckBox for any individual plugin. - void on_singleSelectionChanged(int checkState); - /// Slot triggered when the dialog is being closed. - void on_finished(int result); - /// Slot that can be triggered to ask for the update process to be interrupted. - void interrupt(); - protected slots: - /// Slot triggered once an update for a plugin has been downloaded. - void on_updateDownloaded(QNetworkReply *reply); + /// Triggers an update check for all plugins that are currently recognized by Mumble. This is done + /// in a non-blocking fashion (in another thread). Once all plugins have been checked and if there + /// are updates available, the updatesAvailable signal is emitted. + void checkForUpdates(); + /// Launches a Dialog that asks the user which of the plugins an update has been found for, shall be + /// updated. If the user has selected at least selected one plugin and has accepted the dialog, this + /// function will automatically call update(). + void promptAndUpdate(); + /// Starts the update process of the plugins. This is done asynchronously. + void update(); +public slots: + /// Clears the UI from the widgets created for the individual plugins. + void clearUI(); + /// Slot triggered if the user changes the state of the selectAll CheckBox. + void on_selectAll(int checkState); + /// Slot triggered if the user toggles the CheckBox for any individual plugin. + void on_singleSelectionChanged(int checkState); + /// Slot triggered when the dialog is being closed. + void on_finished(int result); + /// Slot that can be triggered to ask for the update process to be interrupted. + void interrupt(); +protected slots: + /// Slot triggered once an update for a plugin has been downloaded. + void on_updateDownloaded(QNetworkReply *reply); - signals: - /// This signal is emitted once it has been determined that there are plugin updates available. - void updatesAvailable(); - /// This signal is emitted once all plugin updates have been downloaded and processed. - void updatingFinished(); - /// This signal is emitted every time the update process has been interrupted. - void updateInterrupted(); +signals: + /// This signal is emitted once it has been determined that there are plugin updates available. + void updatesAvailable(); + /// This signal is emitted once all plugin updates have been downloaded and processed. + void updatingFinished(); + /// This signal is emitted every time the update process has been interrupted. + void updateInterrupted(); }; #endif // MUMBLE_MUMBLE_PLUGINUPDATER_H_ diff --git a/src/mumble/PositionalData.cpp b/src/mumble/PositionalData.cpp index 8a510e1df..8dd9332a9 100644 --- a/src/mumble/PositionalData.cpp +++ b/src/mumble/PositionalData.cpp @@ -17,14 +17,14 @@ Vector3D::Vector3D() : x(0.0f), y(0.0f), z(0.0f) { Vector3D::Vector3D(float x, float y, float z) : x(x), y(y), z(z) { } -Vector3D::Vector3D(const Vector3D& other) : x(other.x), y(other.y), z(other.z) { +Vector3D::Vector3D(const Vector3D &other) : x(other.x), y(other.y), z(other.z) { } Vector3D::~Vector3D() { } float Vector3D::operator[](Coord coord) const { - switch(coord) { + switch (coord) { case Coord::X: return x; case Coord::Y: @@ -57,15 +57,15 @@ void Vector3D::operator/=(float divisor) { z /= divisor; } -bool Vector3D::operator==(const Vector3D& other) const { +bool Vector3D::operator==(const Vector3D &other) const { return equals(other, 0.0f); } -Vector3D Vector3D::operator-(const Vector3D& other) const { +Vector3D Vector3D::operator-(const Vector3D &other) const { return { x - other.x, y - other.y, z - other.z }; } -Vector3D Vector3D::operator+(const Vector3D& other) const { +Vector3D Vector3D::operator+(const Vector3D &other) const { return { x + other.x, y + other.y, z + other.z }; } @@ -77,21 +77,22 @@ float Vector3D::norm() const { return std::sqrt(normSquared()); } -float Vector3D::dotProduct(const Vector3D& other) const { +float Vector3D::dotProduct(const Vector3D &other) const { return x * other.x + y * other.y + z * other.z; } -Vector3D Vector3D::crossProduct(const Vector3D& other) const { +Vector3D Vector3D::crossProduct(const Vector3D &other) const { return { y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x }; } -bool Vector3D::equals(const Vector3D& other, float threshold) const { +bool Vector3D::equals(const Vector3D &other, float threshold) const { if (threshold == 0.0f) { return x == other.x && y == other.y && z == other.z; } else { threshold = std::abs(threshold); - return std::abs(x - other.x) < threshold && std::abs(y - other.y) < threshold && std::abs(z - other.z) < threshold; + return std::abs(x - other.x) < threshold && std::abs(y - other.y) < threshold + && std::abs(z - other.z) < threshold; } } @@ -118,27 +119,14 @@ void Vector3D::toZero() { } PositionalData::PositionalData() - : m_playerPos(), - m_playerDir(), - m_playerAxis(), - m_cameraPos(), - m_cameraDir(), - m_cameraAxis(), - m_context(), - m_identity(), - m_lock(QReadWriteLock::NonRecursive) { + : m_playerPos(), m_playerDir(), m_playerAxis(), m_cameraPos(), m_cameraDir(), m_cameraAxis(), m_context(), + m_identity(), m_lock(QReadWriteLock::NonRecursive) { } PositionalData::PositionalData(Position3D playerPos, Vector3D playerDir, Vector3D playerAxis, Position3D cameraPos, - Vector3D cameraDir, Vector3D cameraAxis, QString context, QString identity) - : m_playerPos(playerPos), - m_playerDir(playerDir), - m_playerAxis(playerAxis), - m_cameraPos(cameraPos), - m_cameraDir(cameraDir), - m_cameraAxis(cameraAxis), - m_context(context), - m_identity(identity), + Vector3D cameraDir, Vector3D cameraAxis, QString context, QString identity) + : m_playerPos(playerPos), m_playerDir(playerDir), m_playerAxis(playerAxis), m_cameraPos(cameraPos), + m_cameraDir(cameraDir), m_cameraAxis(cameraAxis), m_context(context), m_identity(identity), m_lock(QReadWriteLock::NonRecursive) { } @@ -146,7 +134,7 @@ PositionalData::~PositionalData() { } -void PositionalData::getPlayerPos(Position3D& pos) const { +void PositionalData::getPlayerPos(Position3D &pos) const { QReadLocker lock(&m_lock); pos = m_playerPos; @@ -158,7 +146,7 @@ Position3D PositionalData::getPlayerPos() const { return m_playerPos; } -void PositionalData::getPlayerDir(Vector3D& vec) const { +void PositionalData::getPlayerDir(Vector3D &vec) const { QReadLocker lock(&m_lock); vec = m_playerDir; @@ -170,7 +158,7 @@ Vector3D PositionalData::getPlayerDir() const { return m_playerDir; } -void PositionalData::getPlayerAxis(Vector3D& vec) const { +void PositionalData::getPlayerAxis(Vector3D &vec) const { QReadLocker lock(&m_lock); vec = m_playerAxis; @@ -182,7 +170,7 @@ Vector3D PositionalData::getPlayerAxis() const { return m_playerAxis; } -void PositionalData::getCameraPos(Position3D& pos) const { +void PositionalData::getCameraPos(Position3D &pos) const { QReadLocker lock(&m_lock); pos = m_cameraPos; @@ -194,7 +182,7 @@ Position3D PositionalData::getCameraPos() const { return m_cameraPos; } -void PositionalData::getCameraDir(Vector3D& vec) const { +void PositionalData::getCameraDir(Vector3D &vec) const { QReadLocker lock(&m_lock); vec = m_cameraDir; @@ -206,7 +194,7 @@ Vector3D PositionalData::getCameraDir() const { return m_cameraDir; } -void PositionalData::getCameraAxis(Vector3D& vec) const { +void PositionalData::getCameraAxis(Vector3D &vec) const { QReadLocker lock(&m_lock); vec = m_cameraAxis; @@ -237,6 +225,6 @@ void PositionalData::reset() { m_cameraPos.toZero(); m_cameraDir.toZero(); m_cameraAxis.toZero(); - m_context = QString(); + m_context = QString(); m_identity = QString(); } diff --git a/src/mumble/PositionalData.h b/src/mumble/PositionalData.h index a0f6f4013..5bbbeb9f8 100644 --- a/src/mumble/PositionalData.h +++ b/src/mumble/PositionalData.h @@ -6,99 +6,100 @@ #ifndef MUMBLE_MUMBLE_POSITIONAL_AUDIO_CONTEXT_H_ #define MUMBLE_MUMBLE_POSITIONAL_AUDIO_CONTEXT_H_ -#include <QtCore/QString> #include <QtCore/QReadWriteLock> +#include <QtCore/QString> /// An enum for the three cartesian coordinate axes x, y and z -enum class Coord {X=0,Y,Z}; +enum class Coord { X = 0, Y, Z }; /// A 3D vector class holding an x-, y- and z-coordinate struct Vector3D { - /// The vector's x-coordinate - float x; - /// The vector's y-coordinate - float y; - /// The vector's z-coordinate - float z; + /// The vector's x-coordinate + float x; + /// The vector's y-coordinate + float y; + /// The vector's z-coordinate + float z; - /// Access the respective coordinate in an array-like fashion - /// - /// @param coord The Coord to access - /// @returns The value of the respective coordinate - float operator[](Coord coord) const; - /// @param factor The factor to scale by - /// @returns A new vector that has been created by scaling this vector by the given factor - Vector3D operator*(float factor) const; - /// @param divisor The divisor to apply to all coordinates - /// @returns A new vector obtained from this one by applying the divisor to all coordinates - Vector3D operator/(float divisor) const; - /// Scales this vector by the given factor - /// - /// @param factor The factor to use - void operator*=(float factor); - /// Divides all of this vector's coordinates by the given divisor - /// - /// @param divisor The divisor to use - void operator/=(float divisor); - /// @param other The vector to compare this one to - /// @returns Whether the given vector is equal to this one (their coordinates are the same) - bool operator==(const Vector3D& other) const; - /// @param other The vector to subtract from this one - /// @returns A new vector representing the difference of this vector and the other one - Vector3D operator-(const Vector3D& other) const; - /// @param other The vector to add to this one - /// @returns A new vector representing the sum of this vector and the other one - Vector3D operator+(const Vector3D& other) const; - /// @param other The vector to copy - /// @returns A copy of the other vector - Vector3D& operator=(const Vector3D& other) = default; + /// Access the respective coordinate in an array-like fashion + /// + /// @param coord The Coord to access + /// @returns The value of the respective coordinate + float operator[](Coord coord) const; + /// @param factor The factor to scale by + /// @returns A new vector that has been created by scaling this vector by the given factor + Vector3D operator*(float factor) const; + /// @param divisor The divisor to apply to all coordinates + /// @returns A new vector obtained from this one by applying the divisor to all coordinates + Vector3D operator/(float divisor) const; + /// Scales this vector by the given factor + /// + /// @param factor The factor to use + void operator*=(float factor); + /// Divides all of this vector's coordinates by the given divisor + /// + /// @param divisor The divisor to use + void operator/=(float divisor); + /// @param other The vector to compare this one to + /// @returns Whether the given vector is equal to this one (their coordinates are the same) + bool operator==(const Vector3D &other) const; + /// @param other The vector to subtract from this one + /// @returns A new vector representing the difference of this vector and the other one + Vector3D operator-(const Vector3D &other) const; + /// @param other The vector to add to this one + /// @returns A new vector representing the sum of this vector and the other one + Vector3D operator+(const Vector3D &other) const; + /// @param other The vector to copy + /// @returns A copy of the other vector + Vector3D &operator=(const Vector3D &other) = default; - // allow explicit conversions from this struct to a float-array / float-pointer - /// Explicit conversion to a float-array (of length 3) containing the coordinates of this vector - explicit operator const float*() const { return &x; }; - /// Explicit conversion to a float-array (of length 3) containing the coordinates of this vector - explicit operator float*() { return &x; }; + // allow explicit conversions from this struct to a float-array / float-pointer + /// Explicit conversion to a float-array (of length 3) containing the coordinates of this vector + explicit operator const float *() const { return &x; }; + /// Explicit conversion to a float-array (of length 3) containing the coordinates of this vector + explicit operator float *() { return &x; }; - /// Default constructor - sets all coordinates to 0 - Vector3D(); - /// @param x The x-coordinate - /// @param y The y-coordinate - /// @param z The z-coordinate - Vector3D(float x, float y, float z); - /// Copy constructor - /// - /// @param other The vector to copy - Vector3D(const Vector3D& other); - /// Destructor - ~Vector3D(); - /// @returns The squared euclidean norm (length of the vector) - float normSquared() const; - /// If possible normSquared() should be preferred as this doesn't require a square-root operator - /// - /// @returns The euclidean norm (length of the vector) - float norm() const; - /// @param other The vector to calculate the dot-product with - /// @returns The dot-product between this vector an the other one - float dotProduct(const Vector3D& other) const; - /// @param other The vector to calculate the cross-product (vector-product) with - /// @returns The vector resulting from the cross-product (vector-product) - Vector3D crossProduct(const Vector3D& other) const; - /// @param other The vector to compare this one to - /// @param threshold The maximum absolute difference for coordinates to still be considered equal - /// @returns Whether this and the given vector are equal - bool equals(const Vector3D& other, float threshold = 0.0f) const; - /// @param threshold The maximum absolute value a coordinate may have to still be considered zero - /// @returns Whether this vector is the zero-vector - bool isZero(float threshold = 0.0f) const; - /// Normalizes this vector to a unit-vector. Callin this function on a zero-vector results in undefined behaviour! - void normalize(); - /// Transforms this vector to a zero-vector by setting all coordinates to zero - void toZero(); + /// Default constructor - sets all coordinates to 0 + Vector3D(); + /// @param x The x-coordinate + /// @param y The y-coordinate + /// @param z The z-coordinate + Vector3D(float x, float y, float z); + /// Copy constructor + /// + /// @param other The vector to copy + Vector3D(const Vector3D &other); + /// Destructor + ~Vector3D(); + /// @returns The squared euclidean norm (length of the vector) + float normSquared() const; + /// If possible normSquared() should be preferred as this doesn't require a square-root operator + /// + /// @returns The euclidean norm (length of the vector) + float norm() const; + /// @param other The vector to calculate the dot-product with + /// @returns The dot-product between this vector an the other one + float dotProduct(const Vector3D &other) const; + /// @param other The vector to calculate the cross-product (vector-product) with + /// @returns The vector resulting from the cross-product (vector-product) + Vector3D crossProduct(const Vector3D &other) const; + /// @param other The vector to compare this one to + /// @param threshold The maximum absolute difference for coordinates to still be considered equal + /// @returns Whether this and the given vector are equal + bool equals(const Vector3D &other, float threshold = 0.0f) const; + /// @param threshold The maximum absolute value a coordinate may have to still be considered zero + /// @returns Whether this vector is the zero-vector + bool isZero(float threshold = 0.0f) const; + /// Normalizes this vector to a unit-vector. Callin this function on a zero-vector results in undefined behaviour! + void normalize(); + /// Transforms this vector to a zero-vector by setting all coordinates to zero + void toZero(); }; -// As we're casting the vector struct to float-arrays, we have to make sure that the compiler won't introduce any padding -// into the structure -static_assert(sizeof(Vector3D) == 3*sizeof(float), "The compiler added padding to the Vector3D structure so it can't be cast to a float-array!"); +// As we're casting the vector struct to float-arrays, we have to make sure that the compiler won't introduce any +// padding into the structure +static_assert(sizeof(Vector3D) == 3 * sizeof(float), + "The compiler added padding to the Vector3D structure so it can't be cast to a float-array!"); /// A convenient alias as a position can be treated the same way a vector can typedef Vector3D Position3D; @@ -107,65 +108,65 @@ typedef Vector3D Position3D; /// A class holding positional data used in the positional audio feature class PositionalData { friend class PluginManager; // needed in order for PluginManager::fetch to write to the contained fields - protected: - /// The player's position in the 3D world - Position3D m_playerPos; - /// The direction in which the player is looking - Vector3D m_playerDir; - /// The connection vector between the player's feet and his/her head - Vector3D m_playerAxis; - /// The camera's position un the 3D world - Position3D m_cameraPos; - /// The direction in which the camera is looking - Vector3D m_cameraDir; - /// The connection from the camera's bottom to its top - Vector3D m_cameraAxis; - /// The context of this positional data. This might include the game's name, the server currently connected to, etc. and is used - /// to determine which players can hear one another - QString m_context; - /// The player's ingame identity (name) - QString m_identity; - /// The lock guarding all fields of this class - mutable QReadWriteLock m_lock; +protected: + /// The player's position in the 3D world + Position3D m_playerPos; + /// The direction in which the player is looking + Vector3D m_playerDir; + /// The connection vector between the player's feet and his/her head + Vector3D m_playerAxis; + /// The camera's position un the 3D world + Position3D m_cameraPos; + /// The direction in which the camera is looking + Vector3D m_cameraDir; + /// The connection from the camera's bottom to its top + Vector3D m_cameraAxis; + /// The context of this positional data. This might include the game's name, the server currently connected to, etc. + /// and is used to determine which players can hear one another + QString m_context; + /// The player's ingame identity (name) + QString m_identity; + /// The lock guarding all fields of this class + mutable QReadWriteLock m_lock; - public: - /// Default constructor - PositionalData(); - /// Constructor initializing all fields to a specific value - PositionalData(Position3D playerPos, Vector3D playerDir, Vector3D playerAxis, Position3D cameraPos, Vector3D cameraDir, - Vector3D cameraAxis, QString context, QString identity); - /// Destructor - ~PositionalData(); - /// @param[out] pos The player's 3D position - void getPlayerPos(Position3D& pos) const; - /// @returns The player's 3D position - Position3D getPlayerPos() const; - /// @param[out] vec The direction in which the player is currently looking - void getPlayerDir(Vector3D& vec) const; - /// @returns The direction in which the player is currently looking - Vector3D getPlayerDir() const; - /// @param[out] axis The connection between the player's feet and his/her head - void getPlayerAxis(Vector3D& axis) const; - /// @returns The connection between the player's feet and his/her head - Vector3D getPlayerAxis() const; - /// @param[out] pos The camera's 3D position - void getCameraPos(Position3D& pos) const; - /// @returns The camera's 3D position - Position3D getCameraPos() const; - /// @param[out] vec The direction in which the camera is currently looking - void getCameraDir(Vector3D& vec) const; - /// @returns The direction in which the camera is currently looking - Vector3D getCameraDir() const; - /// @param[out] axis The connection between the player's feet and his/her head - void getCameraAxis(Vector3D& axis) const; - /// @returns The connection between the player's feet and his/her head - Vector3D getCameraAxis() const; - /// @returns The player's identity - QString getPlayerIdentity() const; - /// @returns The current context - QString getContext() const; - /// Resets all fields in this object - void reset(); +public: + /// Default constructor + PositionalData(); + /// Constructor initializing all fields to a specific value + PositionalData(Position3D playerPos, Vector3D playerDir, Vector3D playerAxis, Position3D cameraPos, + Vector3D cameraDir, Vector3D cameraAxis, QString context, QString identity); + /// Destructor + ~PositionalData(); + /// @param[out] pos The player's 3D position + void getPlayerPos(Position3D &pos) const; + /// @returns The player's 3D position + Position3D getPlayerPos() const; + /// @param[out] vec The direction in which the player is currently looking + void getPlayerDir(Vector3D &vec) const; + /// @returns The direction in which the player is currently looking + Vector3D getPlayerDir() const; + /// @param[out] axis The connection between the player's feet and his/her head + void getPlayerAxis(Vector3D &axis) const; + /// @returns The connection between the player's feet and his/her head + Vector3D getPlayerAxis() const; + /// @param[out] pos The camera's 3D position + void getCameraPos(Position3D &pos) const; + /// @returns The camera's 3D position + Position3D getCameraPos() const; + /// @param[out] vec The direction in which the camera is currently looking + void getCameraDir(Vector3D &vec) const; + /// @returns The direction in which the camera is currently looking + Vector3D getCameraDir() const; + /// @param[out] axis The connection between the player's feet and his/her head + void getCameraAxis(Vector3D &axis) const; + /// @returns The connection between the player's feet and his/her head + Vector3D getCameraAxis() const; + /// @returns The player's identity + QString getPlayerIdentity() const; + /// @returns The current context + QString getContext() const; + /// Resets all fields in this object + void reset(); }; #endif diff --git a/src/mumble/PulseAudio.cpp b/src/mumble/PulseAudio.cpp index dcfb1cef5..947532dd8 100644 --- a/src/mumble/PulseAudio.cpp +++ b/src/mumble/PulseAudio.cpp @@ -320,7 +320,6 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) { qsInputCache = idev; m_pulseAudio.stream_connect_record(pasInput, qPrintable(idev), &buff, PA_STREAM_ADJUST_LATENCY); - } } @@ -920,8 +919,8 @@ void PulseAudioInputRegistrar::setDeviceChoice(const QVariant &choice, Settings } bool PulseAudioInputRegistrar::canEcho(EchoCancelOptionID echoOption, const QString &osys) const { - return (echoOption == EchoCancelOptionID::SPEEX_MIXED - || echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL) && (osys == name); + return (echoOption == EchoCancelOptionID::SPEEX_MIXED || echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL) + && (osys == name); } PulseAudioOutputRegistrar::PulseAudioOutputRegistrar() : AudioOutputRegistrar(QLatin1String("PulseAudio"), 10) { diff --git a/src/mumble/RichTextEditor.cpp b/src/mumble/RichTextEditor.cpp index 5d361059d..6a8cd1759 100644 --- a/src/mumble/RichTextEditor.cpp +++ b/src/mumble/RichTextEditor.cpp @@ -235,7 +235,8 @@ void RichTextEditor::on_qaImage_triggered() { if (qba.isEmpty()) return; - if ((Global::get().uiImageLength > 0) && (static_cast< unsigned int >(qba.length()) > Global::get().uiImageLength)) { + if ((Global::get().uiImageLength > 0) + && (static_cast< unsigned int >(qba.length()) > Global::get().uiImageLength)) { QMessageBox::warning(this, tr("Failed to load image"), tr("Image file too large to embed in document. Please use images smaller than %1 kB.") .arg(Global::get().uiImageLength / 1024)); diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 429adc3f3..4eb8d6e14 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -462,9 +462,9 @@ void ServerHandler::run() { #ifdef Q_OS_WIN if (hQoS) { if (!QOSRemoveSocketFromFlow(hQoS, 0, dwFlowUDP, 0)) { - qWarning( - "ServerHandler: Failed to remove UDP from QoS. QOSRemoveSocketFromFlow() failed with error %lu!", - GetLastError()); + qWarning("ServerHandler: Failed to remove UDP from QoS. QOSRemoveSocketFromFlow() failed with " + "error %lu!", + GetLastError()); } dwFlowUDP = 0; @@ -644,9 +644,11 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) { Global::get().mw->msgBox( tr("UDP packets cannot be sent to or received from the server. Switching to TCP mode.")); else if (connection->csCrypt->uiRemoteGood == 0) - Global::get().mw->msgBox(tr("UDP packets cannot be sent to the server. Switching to TCP mode.")); + Global::get().mw->msgBox( + tr("UDP packets cannot be sent to the server. Switching to TCP mode.")); else - Global::get().mw->msgBox(tr("UDP packets cannot be received from the server. Switching to TCP mode.")); + Global::get().mw->msgBox( + tr("UDP packets cannot be received from the server. Switching to TCP mode.")); database->setUdp(qbaDigest, false); } diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index aac13c4a9..aa85f4220 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -13,13 +13,13 @@ #include "../../overlay/overlay.h" -#include <QtCore/QProcessEnvironment> -#include <QtCore/QStandardPaths> #include <QtCore/QFileInfo> +#include <QtCore/QProcessEnvironment> #include <QtCore/QRegularExpression> +#include <QtCore/QStandardPaths> #include <QtGui/QImageReader> #include <QtWidgets/QSystemTrayIcon> -#if QT_VERSION >= QT_VERSION_CHECK(5,9,0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) # include <QOperatingSystemVersion> #endif @@ -365,7 +365,7 @@ Settings::Settings() { bLockLayout = false; #ifdef Q_OS_WIN // Don't enable minimize to tray by default on Windows >= 7 -# if QT_VERSION >= QT_VERSION_CHECK(5,9,0) +# if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) // Since Qt 5.9 QOperatingSystemVersion is preferred over QSysInfo::WinVersion bHideInTray = QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows7; # else @@ -549,7 +549,7 @@ Settings::Settings() { qmMessages[Log::OtherMutedOther] = Settings::LogConsole; qmMessages[Log::UserRenamed] = Settings::LogConsole; qmMessages[Log::PluginMessage] = Settings::LogConsole; - + // Default theme themeName = QLatin1String("Mumble"); themeStyleName = QLatin1String("Lite"); @@ -560,7 +560,7 @@ bool Settings::doEcho() const { AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qsAudioInput); if (air) { if ((Global::get().s.echoOption != EchoCancelOptionID::DISABLED) - && air->canEcho(Global::get().s.echoOption, qsAudioOutput)) + && air->canEcho(Global::get().s.echoOption, qsAudioOutput)) return true; } } @@ -619,7 +619,7 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(QList, 1) // a zero value. #ifdef Q_OS_MACOS # undef LOAD -# define LOAD(var, name) \ +# define LOAD(var, name) \ do { \ if (settings_ptr->value(QLatin1String(name)).toString() != QLatin1String("@Variant(")) { \ var = qvariant_cast< BOOST_TYPEOF(var) >(settings_ptr->value(QLatin1String(name), var)); \ @@ -1011,12 +1011,12 @@ void Settings::load(QSettings *settings_ptr) { // Plugins settings_ptr->beginGroup(QLatin1String("plugins")); - foreach(const QString &pluginKey, settings_ptr->childGroups()) { + foreach (const QString &pluginKey, settings_ptr->childGroups()) { QString pluginHash; if (pluginKey.contains(QLatin1String("_"))) { // The key contains the filename as well as the hash - int index = pluginKey.lastIndexOf(QLatin1String("_")); + int index = pluginKey.lastIndexOf(QLatin1String("_")); pluginHash = pluginKey.right(pluginKey.size() - index - 1); } else { pluginHash = pluginKey; @@ -1024,9 +1024,11 @@ void Settings::load(QSettings *settings_ptr) { PluginSetting pluginSettings; pluginSettings.path = settings_ptr->value(pluginKey + QLatin1String("/path")).toString(); - pluginSettings.allowKeyboardMonitoring = settings_ptr->value(pluginKey + QLatin1String("/allowKeyboardMonitoring")).toBool(); + pluginSettings.allowKeyboardMonitoring = + settings_ptr->value(pluginKey + QLatin1String("/allowKeyboardMonitoring")).toBool(); pluginSettings.enabled = settings_ptr->value(pluginKey + QLatin1String("/enabled")).toBool(); - pluginSettings.positionalDataEnabled = settings_ptr->value(pluginKey + QLatin1String("/positionalDataEnabled")).toBool(); + pluginSettings.positionalDataEnabled = + settings_ptr->value(pluginKey + QLatin1String("/positionalDataEnabled")).toBool(); qhPluginSettings.insert(pluginHash, pluginSettings); } @@ -1038,7 +1040,7 @@ void Settings::load(QSettings *settings_ptr) { } #undef LOAD -#define SAVE(var, name) \ +#define SAVE(var, name) \ if (var != def.var) \ settings_ptr->setValue(QLatin1String(name), var); \ else \ @@ -1401,13 +1403,13 @@ void Settings::save() { settings_ptr->remove(d); } settings_ptr->endGroup(); - + // Plugins - foreach(const QString &pluginHash, qhPluginSettings.keys()) { - QString savePath = QString::fromLatin1("plugins/"); + foreach (const QString &pluginHash, qhPluginSettings.keys()) { + QString savePath = QString::fromLatin1("plugins/"); const PluginSetting settings = qhPluginSettings.value(pluginHash); const QFileInfo info(settings.path); - QString baseName = info.baseName(); // Get the filename without file extensions + QString baseName = info.baseName(); // Get the filename without file extensions const bool containsNonASCII = baseName.contains(QRegularExpression(QStringLiteral("[^\\x{0000}-\\x{007F}]"))); if (containsNonASCII || baseName.isEmpty()) { @@ -1428,14 +1430,14 @@ void Settings::save() { settings_ptr->setValue(QLatin1String("allowKeyboardMonitoring"), settings.allowKeyboardMonitoring); settings_ptr->endGroup(); } - + settings_ptr->beginGroup(QLatin1String("overlay")); os.save(settings_ptr); settings_ptr->endGroup(); } -QDataStream& operator>>(QDataStream &arch, PluginSetting &setting) { +QDataStream &operator>>(QDataStream &arch, PluginSetting &setting) { arch >> setting.enabled; arch >> setting.positionalDataEnabled; arch >> setting.allowKeyboardMonitoring; @@ -1443,7 +1445,7 @@ QDataStream& operator>>(QDataStream &arch, PluginSetting &setting) { return arch; } -QDataStream& operator<<(QDataStream &arch, const PluginSetting &setting) { +QDataStream &operator<<(QDataStream &arch, const PluginSetting &setting) { arch << setting.enabled; arch << setting.positionalDataEnabled; arch << setting.allowKeyboardMonitoring; diff --git a/src/mumble/Settings.h b/src/mumble/Settings.h index ab46e5391..18c5b9edb 100644 --- a/src/mumble/Settings.h +++ b/src/mumble/Settings.h @@ -65,8 +65,8 @@ struct PluginSetting { bool positionalDataEnabled; bool allowKeyboardMonitoring; }; -QDataStream& operator>>(QDataStream &arch, PluginSetting &setting); -QDataStream& operator<<(QDataStream &arch, const PluginSetting &setting); +QDataStream &operator>>(QDataStream &arch, PluginSetting &setting); +QDataStream &operator<<(QDataStream &arch, const PluginSetting &setting); Q_DECLARE_METATYPE(PluginSetting); diff --git a/src/mumble/TalkingUI.cpp b/src/mumble/TalkingUI.cpp index 03ff76b88..92a0a6e58 100644 --- a/src/mumble/TalkingUI.cpp +++ b/src/mumble/TalkingUI.cpp @@ -235,7 +235,7 @@ void TalkingUI::setupUI() { } void TalkingUI::setFontSize(MultiStyleWidgetWrapper &widgetWrapper) { - const double fontFactor = Global::get().s.iTalkingUI_RelativeFontSize / 100.0; + const double fontFactor = Global::get().s.iTalkingUI_RelativeFontSize / 100.0; const int origLineHeight = QFontMetrics(font()).height(); if (font().pixelSize() >= 0) { @@ -244,7 +244,7 @@ void TalkingUI::setFontSize(MultiStyleWidgetWrapper &widgetWrapper) { widgetWrapper.setFontSize(pixelSize, true); } else { // font specified in points - uint32_t pointSize = static_cast< uint32_t >(std::max(fontFactor * font().pointSize(), 1.0)); + uint32_t pointSize = static_cast< uint32_t >(std::max(fontFactor * font().pointSize(), 1.0)); widgetWrapper.setFontSize(pointSize, false); } @@ -329,11 +329,11 @@ QString createChannelName(const Channel *chan, bool abbreviateName, int minPrefi void TalkingUI::addChannel(const Channel *channel) { if (findContainer(channel->iId, ContainerType::CHANNEL) < 0) { // Create a QGroupBox for this channel - const QString channelName = - createChannelName(channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount, - Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength, - Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator, - Global::get().s.qsTalkingUI_AbbreviationReplacement, Global::get().s.bTalkingUI_AbbreviateCurrentChannel); + const QString channelName = createChannelName( + channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount, + Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength, + Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator, + Global::get().s.qsTalkingUI_AbbreviationReplacement, Global::get().s.bTalkingUI_AbbreviateCurrentChannel); std::unique_ptr< TalkingUIChannel > channelContainer = std::make_unique< TalkingUIChannel >(channel->iId, channelName, *this); @@ -391,7 +391,7 @@ TalkingUIUser *TalkingUI::findOrAddUser(const ClientUser *user) { } std::unique_ptr< TalkingUIUser > userEntry = std::make_unique< TalkingUIUser >(*user); - TalkingUIUser *newUserEntry = userEntry.get(); + TalkingUIUser *newUserEntry = userEntry.get(); // * 1000 as the setting is in seconds whereas the timer expects milliseconds userEntry->setLifeTime(Global::get().s.iTalkingUI_SilentUserLifeTime * 1000); @@ -552,7 +552,8 @@ void TalkingUI::mousePressEvent(QMouseEvent *event) { // resulting in the proper context menu being shown at the position of the mouse which in this case is in // the TalkingUI. QMetaObject::invokeMethod(Global::get().mw, "on_qtvUsers_customContextMenuRequested", Qt::QueuedConnection, - Q_ARG(QPoint, Global::get().mw->qtvUsers->mapFromGlobal(event->globalPos())), Q_ARG(bool, false)); + Q_ARG(QPoint, Global::get().mw->qtvUsers->mapFromGlobal(event->globalPos())), + Q_ARG(bool, false)); } } else { // Clear selection @@ -725,11 +726,12 @@ void TalkingUI::on_settingsChanged() { if (channel) { // Update - channelContainer->setName( - createChannelName(channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount, - Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength, - Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator, - Global::get().s.qsTalkingUI_AbbreviationReplacement, Global::get().s.bTalkingUI_AbbreviateCurrentChannel)); + channelContainer->setName(createChannelName( + channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount, + Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength, + Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator, + Global::get().s.qsTalkingUI_AbbreviationReplacement, + Global::get().s.bTalkingUI_AbbreviateCurrentChannel)); } else { qCritical("TalkingUI: Can't find channel for stored ID"); } diff --git a/src/mumble/Translations.cpp b/src/mumble/Translations.cpp index 377732c23..87332cd06 100644 --- a/src/mumble/Translations.cpp +++ b/src/mumble/Translations.cpp @@ -14,12 +14,13 @@ namespace Mumble { namespace Translations { - LifetimeGuard::LifetimeGuard(LifetimeGuard &&old) : m_bundledTranslator(old.m_bundledTranslator), - m_overwriteTranslator(old.m_overwriteTranslator), m_qtTranslator(old.m_qtTranslator) { + LifetimeGuard::LifetimeGuard(LifetimeGuard &&old) + : m_bundledTranslator(old.m_bundledTranslator), m_overwriteTranslator(old.m_overwriteTranslator), + m_qtTranslator(old.m_qtTranslator) { // Reset values of old - old.m_bundledTranslator = nullptr; + old.m_bundledTranslator = nullptr; old.m_overwriteTranslator = nullptr; - old.m_qtTranslator = nullptr; + old.m_qtTranslator = nullptr; } LifetimeGuard::~LifetimeGuard() { @@ -121,9 +122,11 @@ namespace Translations { app.installTranslator(guard.m_qtTranslator); } else if (guard.m_qtTranslator->load(locale, ":/mumble_overwrite_qtbase_")) { app.installTranslator(guard.m_qtTranslator); - } else if (guard.m_qtTranslator->load(locale, "qt_", prefix, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { + } else if (guard.m_qtTranslator->load(locale, "qt_", prefix, + QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { app.installTranslator(guard.m_qtTranslator); - } else if (guard.m_qtTranslator->load(locale, "qtbase_", prefix, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { + } else if (guard.m_qtTranslator->load(locale, "qtbase_", prefix, + QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { app.installTranslator(guard.m_qtTranslator); } else if (guard.m_qtTranslator->load(locale, ":/qt_")) { app.installTranslator(guard.m_qtTranslator); diff --git a/src/mumble/Translations.h b/src/mumble/Translations.h index 2a0b8f3d7..ebb2d0650 100644 --- a/src/mumble/Translations.h +++ b/src/mumble/Translations.h @@ -19,9 +19,9 @@ namespace Translations { * A lifetime guard for translators. Basically a smart-pointer for an ensemble of translators */ struct LifetimeGuard { - QTranslator *m_bundledTranslator = nullptr; + QTranslator *m_bundledTranslator = nullptr; QTranslator *m_overwriteTranslator = nullptr; - QTranslator *m_qtTranslator = nullptr; + QTranslator *m_qtTranslator = nullptr; LifetimeGuard() = default; LifetimeGuard(LifetimeGuard &&old); diff --git a/src/mumble/Usage.cpp b/src/mumble/Usage.cpp index 94a313bd6..af8ba0199 100644 --- a/src/mumble/Usage.cpp +++ b/src/mumble/Usage.cpp @@ -30,7 +30,8 @@ Usage::Usage(QObject *p) : QObject(p) { void Usage::registerUsage() { if (!Global::get().s.bUsage - || Global::get().s.uiUpdateCounter == 0) // Only register usage if allowed by the user and first wizard run has finished + || Global::get().s.uiUpdateCounter + == 0) // Only register usage if allowed by the user and first wizard run has finished return; QDomDocument doc; diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp index 1ecc996e9..70925e7c3 100644 --- a/src/mumble/UserInformation.cpp +++ b/src/mumble/UserInformation.cpp @@ -104,7 +104,8 @@ void UserInformation::update(const MumbleProto::UserStats &msg) { if (alts.contains(QSsl::EmailEntry)) qlCertificate->setText(QStringList(alts.values(QSsl::EmailEntry)).join(tr(", "))); else - qlCertificate->setText(Mumble::QtUtils::decode_first_utf8_qssl_string(cert.subjectInfo(QSslCertificate::CommonName))); + qlCertificate->setText( + Mumble::QtUtils::decode_first_utf8_qssl_string(cert.subjectInfo(QSslCertificate::CommonName))); if (msg.strong_certificate()) { QFont f = qfCertificateFont; diff --git a/src/mumble/UserLocalNicknameDialog.cpp b/src/mumble/UserLocalNicknameDialog.cpp index bb2dea4e1..c5bea6ad0 100644 --- a/src/mumble/UserLocalNicknameDialog.cpp +++ b/src/mumble/UserLocalNicknameDialog.cpp @@ -13,8 +13,7 @@ #include <QtWidgets/QPushButton> UserLocalNicknameDialog::UserLocalNicknameDialog( - unsigned int sessionId, - std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker) + unsigned int sessionId, std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker) : QDialog(nullptr), m_clientSession(sessionId), m_qmUserNicknameTracker(qmUserNicknameTracker) { setupUi(this); @@ -44,16 +43,16 @@ void UserLocalNicknameDialog::closeEvent(QCloseEvent *event) { event->accept(); } -void UserLocalNicknameDialog::present( - unsigned int sessionId, - std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker) { +void UserLocalNicknameDialog::present(unsigned int sessionId, + std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker) { if (qmUserNicknameTracker.find(sessionId) != qmUserNicknameTracker.end()) { qmUserNicknameTracker.at(sessionId)->show(); qmUserNicknameTracker.at(sessionId)->raise(); } else { // Make sure to use the custom deleter for QObjects that calls deleteLater() on them instead of using // delete directly as the latter can lead to segmentation faults. - NicknameDialogPtr userNickname(new UserLocalNicknameDialog(sessionId, qmUserNicknameTracker), Mumble::QtUtils::deleteQObject); + NicknameDialogPtr userNickname(new UserLocalNicknameDialog(sessionId, qmUserNicknameTracker), + Mumble::QtUtils::deleteQObject); userNickname->show(); qmUserNicknameTracker.insert(std::make_pair(sessionId, std::move(userNickname))); } diff --git a/src/mumble/UserLocalNicknameDialog.h b/src/mumble/UserLocalNicknameDialog.h index 06083f848..830851019 100644 --- a/src/mumble/UserLocalNicknameDialog.h +++ b/src/mumble/UserLocalNicknameDialog.h @@ -40,12 +40,10 @@ public slots: void reject(); public: - static void - present(unsigned int sessionId, - std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker); - UserLocalNicknameDialog( - unsigned int sessionId, - std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker); + static void present(unsigned int sessionId, + std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker); + UserLocalNicknameDialog(unsigned int sessionId, + std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker); }; #endif diff --git a/src/mumble/UserModel.cpp b/src/mumble/UserModel.cpp index ceb7c1dd4..474585eb2 100644 --- a/src/mumble/UserModel.cpp +++ b/src/mumble/UserModel.cpp @@ -1176,7 +1176,8 @@ void UserModel::setComment(ClientUser *cu, const QString &comment) { QWhatsThis::showText(Global::get().mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()), data(index(cu, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers); } else { - QToolTip::showText(QCursor::pos(), data(index(cu, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers); + QToolTip::showText(QCursor::pos(), data(index(cu, 0), Qt::ToolTipRole).toString(), + Global::get().mw->qtvUsers); } } else if (cu->uiSession == ~uiSessionComment) { uiSessionComment = 0; @@ -1241,7 +1242,8 @@ void UserModel::setComment(Channel *c, const QString &comment) { QWhatsThis::showText(Global::get().mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()), data(index(c, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers); } else { - QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers); + QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(), + Global::get().mw->qtvUsers); } } else { item->bCommentSeen = Global::get().db->seenComment(item->hash(), c->qbaDescHash); @@ -1784,16 +1786,17 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c int ret; switch (Global::get().s.ceUserDrag) { case Settings::Ask: - ret = - QMessageBox::question(Global::get().mw, QLatin1String("Mumble"), tr("Are you sure you want to drag this user?"), - QMessageBox::Yes, QMessageBox::No); + ret = QMessageBox::question(Global::get().mw, QLatin1String("Mumble"), + tr("Are you sure you want to drag this user?"), QMessageBox::Yes, + QMessageBox::No); if (ret == QMessageBox::No) return false; break; case Settings::DoNothing: - Global::get().l->log(Log::Information, - MainWindow::tr("You have User Dragging set to \"Do Nothing\" so the user wasn't moved.")); + Global::get().l->log( + Log::Information, + MainWindow::tr("You have User Dragging set to \"Do Nothing\" so the user wasn't moved.")); return false; break; case Settings::Move: @@ -1824,7 +1827,8 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c case Settings::Move: break; default: - Global::get().l->log(Log::CriticalError, MainWindow::tr("Unknown Channel Drag mode in UserModel::dropMimeData.")); + Global::get().l->log(Log::CriticalError, + MainWindow::tr("Unknown Channel Drag mode in UserModel::dropMimeData.")); return false; break; } @@ -2004,7 +2008,8 @@ QString UserModel::createDisplayString(const ClientUser &user, bool isChannelLis displayString += " " + friendTag; } - if (!Global::get().s.bShowNicknamesOnly && !nickname.isEmpty() && user.qsName.compare(nickname, Qt::CaseInsensitive) != 0) { + if (!Global::get().s.bShowNicknamesOnly && !nickname.isEmpty() + && user.qsName.compare(nickname, Qt::CaseInsensitive) != 0) { displayString += " " + QString::fromLatin1("[%1]").arg(nickname); } diff --git a/src/mumble/VersionCheck.cpp b/src/mumble/VersionCheck.cpp index 3fb90caf7..123665e57 100644 --- a/src/mumble/VersionCheck.cpp +++ b/src/mumble/VersionCheck.cpp @@ -54,8 +54,9 @@ VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p), if (autocheck) queryItems << qMakePair(QString::fromLatin1("auto"), QString::fromLatin1("1")); - queryItems << qMakePair(QString::fromLatin1("locale"), - Global::get().s.qsLanguage.isEmpty() ? QLocale::system().name() : Global::get().s.qsLanguage); + queryItems << qMakePair(QString::fromLatin1("locale"), Global::get().s.qsLanguage.isEmpty() + ? QLocale::system().name() + : Global::get().s.qsLanguage); QFile f(qApp->applicationFilePath()); if (!f.open(QIODevice::ReadOnly)) { @@ -105,8 +106,8 @@ void VersionCheck::fetched(QByteArray a, QUrl url) { if (!fetch.isValid()) { Global::get().mw->msgBox(QString::fromUtf8(a)); } else { - QString filename = - Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(fetch.path()).fileName()); + QString filename = Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + + QFileInfo(fetch.path()).fileName()); QFile qf(filename); if (qf.exists()) { @@ -157,15 +158,16 @@ void VersionCheck::fetched(QByteArray a, QUrl url) { } } else { - Global::get().mw->msgBox(tr("Corrupt download of new version detected. Automatically removed.")); + Global::get().mw->msgBox( + tr("Corrupt download of new version detected. Automatically removed.")); qf.remove(); } // Delete all but the N most recent snapshots size_t numberOfSnapshotsToKeep = 1; - QDir snapdir(Global::get().qdBasePath.absolutePath() + QLatin1String("/Snapshots/"), QString(), QDir::Name, - QDir::Files); + QDir snapdir(Global::get().qdBasePath.absolutePath() + QLatin1String("/Snapshots/"), QString(), + QDir::Name, QDir::Files); foreach (const QFileInfo fileInfo, snapdir.entryInfoList(QStringList(), QDir::NoFilter, QDir::Time)) { @@ -180,14 +182,14 @@ void VersionCheck::fetched(QByteArray a, QUrl url) { } } else { Global::get().mw->msgBox(tr("Downloading new snapshot from %1 to %2") - .arg(fetch.toString().toHtmlEscaped(), filename.toHtmlEscaped())); + .arg(fetch.toString().toHtmlEscaped(), filename.toHtmlEscaped())); WebFetch::fetch(QLatin1String("dl"), fetch, this, SLOT(fetched(QByteArray, QUrl))); return; } } } else { - QString filename = - Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(url.path()).fileName()); + QString filename = Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + + QFileInfo(url.path()).fileName()); QFile qf(filename); if (qf.open(QIODevice::WriteOnly)) { diff --git a/src/mumble/VoiceRecorderDialog.cpp b/src/mumble/VoiceRecorderDialog.cpp index e3d9ddc12..0f8c1d8c8 100644 --- a/src/mumble/VoiceRecorderDialog.cpp +++ b/src/mumble/VoiceRecorderDialog.cpp @@ -96,7 +96,7 @@ void VoiceRecorderDialog::closeEvent(QCloseEvent *evt) { else Global::get().s.rmRecordingMode = Settings::RecordingMultichannel; - int i = qcbFormat->currentIndex(); + int i = qcbFormat->currentIndex(); Global::get().s.iRecordingFormat = (i == -1) ? 0 : i; reset(); diff --git a/src/mumble/WASAPI.cpp b/src/mumble/WASAPI.cpp index bdc3d1ee6..91f071f14 100644 --- a/src/mumble/WASAPI.cpp +++ b/src/mumble/WASAPI.cpp @@ -208,8 +208,8 @@ void WASAPIInputRegistrar::setDeviceChoice(const QVariant &choice, Settings &s) } bool WASAPIInputRegistrar::canEcho(EchoCancelOptionID echoOptionIDs, const QString &outputSystem) const { - return (echoOptionIDs == EchoCancelOptionID::SPEEX_MIXED - || echoOptionIDs == EchoCancelOptionID::SPEEX_MULTICHANNEL) && (outputSystem == name); + return (echoOptionIDs == EchoCancelOptionID::SPEEX_MIXED || echoOptionIDs == EchoCancelOptionID::SPEEX_MULTICHANNEL) + && (outputSystem == name); } bool WASAPIInputRegistrar::canExclusive() const { @@ -485,8 +485,9 @@ void WASAPIInput::run() { qWarning("WASAPIInput: Mic Initialize failed: hr=0x%08lx", hr); if (hr == E_ACCESSDENIED) { WASAPIInputRegistrar::hasOSPermissionDenied = true; - Global::get().mw->msgBox(tr("Access to the microphone was denied. Please check that your operating system's " - "microphone settings allow Mumble to use the microphone.")); + Global::get().mw->msgBox( + tr("Access to the microphone was denied. Please check that your operating system's " + "microphone settings allow Mumble to use the microphone.")); } goto cleanup; } @@ -885,10 +886,11 @@ void WASAPIOutput::run() { int ns = 0; unsigned int chanmasks[32]; QMap< DWORD, float > qmVolumes; - bool lastspoke = false; - REFERENCE_TIME bufferDuration = (Global::get().s.iOutputDelay > 1) ? (Global::get().s.iOutputDelay + 1) * 100000 : 0; - bool exclusive = false; - bool mixed = false; + bool lastspoke = false; + REFERENCE_TIME bufferDuration = + (Global::get().s.iOutputDelay > 1) ? (Global::get().s.iOutputDelay + 1) * 100000 : 0; + bool exclusive = false; + bool mixed = false; CoInitialize(nullptr); @@ -1015,7 +1017,8 @@ void WASAPIOutput::run() { iMixerFreq = pwfx->nSamplesPerSec; qWarning("WASAPIOutput: Periods %lldus %lldus (latency %lldus)", def / 10LL, min / 10LL, latency / 10LL); - qWarning("WASAPIOutput: Buffer is %dus (%d)", (bufferFrameCount * 1000000) / iMixerFreq, Global::get().s.iOutputDelay); + qWarning("WASAPIOutput: Buffer is %dus (%d)", (bufferFrameCount * 1000000) / iMixerFreq, + Global::get().s.iOutputDelay); hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void **) &pRenderClient); if (FAILED(hr)) { diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index a1ef34826..a0d3f337d 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -11,8 +11,6 @@ #include "AudioWizard.h" #include "Cert.h" #include "Database.h" -#include "Log.h" -#include "LogEmitter.h" #include "DeveloperConsole.h" #include "LCD.h" #include "Log.h" @@ -37,22 +35,22 @@ #include "License.h" #include "MumbleApplication.h" #include "NetworkConfig.h" +#include "PluginInstaller.h" +#include "PluginManager.h" #include "SSL.h" #include "SocketRPC.h" #include "TalkingUI.h" -#include "Translations.h" #include "Themes.h" +#include "Translations.h" #include "UserLockFile.h" #include "VersionCheck.h" -#include "PluginInstaller.h" -#include "PluginManager.h" #include "Global.h" +#include <QLocale> +#include <QScreen> #include <QtCore/QProcess> #include <QtGui/QDesktopServices> #include <QtWidgets/QMessageBox> -#include <QLocale> -#include <QScreen> #ifdef USE_DBUS # include <QtDBus/QDBusInterface> @@ -75,7 +73,7 @@ extern void os_init(); extern char *os_lang; QScreen *screenAt(QPoint point) { -#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // screenAt was only introduced in Qt 5.10 return QGuiApplication::screenAt(point); #else @@ -95,14 +93,16 @@ bool positionIsOnScreen(QPoint point) { QPoint getTalkingUIPosition() { QPoint talkingUIPos = QPoint(0, 0); - if (Global::get().s.qpTalkingUI_Position != Settings::UNSPECIFIED_POSITION && positionIsOnScreen(Global::get().s.qpTalkingUI_Position)) { + if (Global::get().s.qpTalkingUI_Position != Settings::UNSPECIFIED_POSITION + && positionIsOnScreen(Global::get().s.qpTalkingUI_Position)) { // Restore last position talkingUIPos = Global::get().s.qpTalkingUI_Position; } else { // Place the TalkingUI next to the MainWindow by default const QPoint mainWindowPos = Global::get().mw->pos(); const int horizontalBuffer = 10; - const QPoint defaultPos = QPoint(mainWindowPos.x() + Global::get().mw->size().width() + horizontalBuffer, mainWindowPos.y()); + const QPoint defaultPos = + QPoint(mainWindowPos.x() + Global::get().mw->size().width() + horizontalBuffer, mainWindowPos.y()); if (positionIsOnScreen(defaultPos)) { talkingUIPos = defaultPos; @@ -115,8 +115,8 @@ QPoint getTalkingUIPosition() { const QSize talkingUISize = Global::get().talkingUI->size(); // The screen should always be found at this point as we have chosen to pos to be on a screen - const QScreen *screen = screenAt(talkingUIPos); - const QRect screenGeom = screen ? screen->availableGeometry() : QRect(0,0,0,0); + const QScreen *screen = screenAt(talkingUIPos); + const QRect screenGeom = screen ? screen->availableGeometry() : QRect(0, 0, 0, 0); // Check whether the TalkingUI fits on the screen in x-direction if (!positionIsOnScreen(talkingUIPos + QPoint(talkingUISize.width(), 0))) { @@ -340,12 +340,12 @@ int main(int argc, char **argv) { } else if (args.at(i) == QLatin1String("-m") || args.at(i) == QLatin1String("--multiple")) { bAllowMultiple = true; } else if (args.at(i) == QLatin1String("-n") || args.at(i) == QLatin1String("--noidentity")) { - suppressIdentity = true; + suppressIdentity = true; Global::get().s.bSuppressIdentity = true; } else if (args.at(i) == QLatin1String("-jn") || args.at(i) == QLatin1String("--jackname")) { if (i + 1 < args.count()) { Global::get().s.qsJackClientName = QString(args.at(i + 1)); - customJackClientName = true; + customJackClientName = true; ++i; } else { qCritical("Missing argument for --jackname!"); @@ -428,15 +428,16 @@ int main(int argc, char **argv) { QString infoString = QObject::tr("The directories in which Mumble searches for extra translation files are:\n"); int counter = 1; - for (const QString ¤tTranslationDir : Mumble::Translations::getTranslationDirectories(a, extraTranslationDirs)) { + for (const QString ¤tTranslationDir : + Mumble::Translations::getTranslationDirectories(a, extraTranslationDirs)) { infoString += QString::fromLatin1("%1. ").arg(counter) + currentTranslationDir + "\n"; counter++; } #if defined(Q_OS_WIN) - QMessageBox::information(nullptr, QObject::tr("Invocation"), infoString); + QMessageBox::information(nullptr, QObject::tr("Invocation"), infoString); #else - printf("%s", qUtf8Printable(infoString)); + printf("%s", qUtf8Printable(infoString)); #endif return 0; @@ -594,24 +595,23 @@ int main(int argc, char **argv) { } if (!pluginsToBeInstalled.isEmpty()) { - - foreach(QString currentPlugin, pluginsToBeInstalled) { - + foreach (QString currentPlugin, pluginsToBeInstalled) { try { PluginInstaller installer(currentPlugin); installer.exec(); - } catch(const PluginInstallException& e) { + } catch (const PluginInstallException &e) { qCritical() << qUtf8Printable(e.getMessage()); } - } return 0; } - qWarning("Locale is \"%s\" (System: \"%s\")", qUtf8Printable(settingsLocale.name()), qUtf8Printable(systemLocale.name())); + qWarning("Locale is \"%s\" (System: \"%s\")", qUtf8Printable(settingsLocale.name()), + qUtf8Printable(systemLocale.name())); - Mumble::Translations::LifetimeGuard translationGuard = Mumble::Translations::installTranslators(settingsLocale, a, extraTranslationDirs); + Mumble::Translations::LifetimeGuard translationGuard = + Mumble::Translations::installTranslators(settingsLocale, a, extraTranslationDirs); // Initialize proxy settings NetworkConfig::SetupProxy(); @@ -631,7 +631,7 @@ int main(int argc, char **argv) { // Initialize zeroconf Global::get().zeroconf = new Zeroconf(); #endif - + // PluginManager Global::get().pluginManager = new PluginManager(); Global::get().pluginManager->rescanPlugins(); @@ -661,12 +661,15 @@ int main(int argc, char **argv) { // window's frame to be included in the positioning calculation on X11 (at least using KDE Plasma) Global::get().talkingUI->setVisible(Global::get().s.bShowTalkingUI); - QObject::connect(Global::get().mw, &MainWindow::userAddedChannelListener, Global::get().talkingUI, &TalkingUI::on_channelListenerAdded); - QObject::connect(Global::get().mw, &MainWindow::userRemovedChannelListener, Global::get().talkingUI, &TalkingUI::on_channelListenerRemoved); + QObject::connect(Global::get().mw, &MainWindow::userAddedChannelListener, Global::get().talkingUI, + &TalkingUI::on_channelListenerAdded); + QObject::connect(Global::get().mw, &MainWindow::userRemovedChannelListener, Global::get().talkingUI, + &TalkingUI::on_channelListenerRemoved); QObject::connect(&ChannelListener::get(), &ChannelListener::localVolumeAdjustmentsChanged, Global::get().talkingUI, &TalkingUI::on_channelListenerLocalVolumeAdjustmentChanged); - QObject::connect(Global::get().mw, &MainWindow::serverSynchronized, Global::get().talkingUI, &TalkingUI::on_serverSynchronized); + QObject::connect(Global::get().mw, &MainWindow::serverSynchronized, Global::get().talkingUI, + &TalkingUI::on_serverSynchronized); // Initialize logger // Log::log() needs the MainWindow to already exist. Thus creating the Log instance @@ -708,7 +711,7 @@ int main(int argc, char **argv) { Global::get().s.iaeIdleAction = Settings::Nothing; } else { Global::get().s.iIdleTime = 60 * qRound(Global::get().s.iIdleTime / 60.); // Round to minutes - Global::get().s.iaeIdleAction = Settings::Deafen; // Old behavior + Global::get().s.iaeIdleAction = Settings::Deafen; // Old behavior } } @@ -745,9 +748,10 @@ int main(int argc, char **argv) { } if (QDateTime::currentDateTime().daysTo(Global::get().s.kpCertificate.first.first().expiryDate()) < 14) - Global::get().l->log(Log::Warning, - CertWizard::tr("<b>Certificate Expiry:</b> Your certificate is about to expire. You need to renew it, " - "or you will no longer be able to connect to servers you are registered on.")); + Global::get().l->log( + Log::Warning, + CertWizard::tr("<b>Certificate Expiry:</b> Your certificate is about to expire. You need to renew it, " + "or you will no longer be able to connect to servers you are registered on.")); #ifdef QT_NO_DEBUG // Only perform the version-check for non-debug builds @@ -766,7 +770,7 @@ int main(int argc, char **argv) { if (Global::get().s.bPluginCheck) { Global::get().pluginManager->checkForPluginUpdates(); } -#else // QT_NO_DEBUG +#else // QT_NO_DEBUG Global::get().mw->msgBox(MainWindow::tr("Skipping version check in debug mode.")); #endif // QT_NO_DEBUG @@ -832,7 +836,7 @@ int main(int argc, char **argv) { Global::get().sh.reset(); - while (sh && ! sh.unique()) + while (sh && !sh.unique()) QThread::yieldCurrentThread(); sh.reset(); diff --git a/src/mumble/os_win.cpp b/src/mumble/os_win.cpp index 6cfd95f34..0e5ac74de 100644 --- a/src/mumble/os_win.cpp +++ b/src/mumble/os_win.cpp @@ -278,9 +278,8 @@ void os_init() { } } - QString comment = - QString::fromLatin1("%1\n%2\n%3") - .arg(QString::fromLatin1(MUMBLE_RELEASE), QString::fromLatin1(MUMTEXT(MUMBLE_VERSION)), hash); + QString comment = QString::fromLatin1("%1\n%2\n%3") + .arg(QString::fromLatin1(MUMBLE_RELEASE), QString::fromLatin1(MUMTEXT(MUMBLE_VERSION)), hash); wcscpy_s(wcComment, DUMP_BUFFER_SIZE, comment.toStdWString().c_str()); musComment.Type = CommentStreamW; diff --git a/src/mumble/widgets/MultiStyleWidgetWrapper.cpp b/src/mumble/widgets/MultiStyleWidgetWrapper.cpp index 288c094b9..be5950df3 100644 --- a/src/mumble/widgets/MultiStyleWidgetWrapper.cpp +++ b/src/mumble/widgets/MultiStyleWidgetWrapper.cpp @@ -5,13 +5,13 @@ #include "MultiStyleWidgetWrapper.h" -#include <QWidget> #include <QFont> #include <QFontMetrics> +#include <QWidget> const uint32_t MultiStyleWidgetWrapper::UNSET_FONTSIZE = 0; -const QString MultiStyleWidgetWrapper::UNSET_COLOR = ""; -const QString MultiStyleWidgetWrapper::UNSET_SELECTOR = "*"; +const QString MultiStyleWidgetWrapper::UNSET_COLOR = ""; +const QString MultiStyleWidgetWrapper::UNSET_SELECTOR = "*"; MultiStyleWidgetWrapper::MultiStyleWidgetWrapper(QWidget *widget) : m_widget(widget) { } diff --git a/src/mumble/widgets/MultiStyleWidgetWrapper.h b/src/mumble/widgets/MultiStyleWidgetWrapper.h index 1cdfa4fdd..f158e2031 100644 --- a/src/mumble/widgets/MultiStyleWidgetWrapper.h +++ b/src/mumble/widgets/MultiStyleWidgetWrapper.h @@ -16,37 +16,37 @@ class QWidget; /// set single properties within a widget's stylesheet without potentially overwriting other /// properties set through it. class MultiStyleWidgetWrapper { - public: - void setFontSize(uint32_t fontSize, bool isPixels = true); - void setFontSizeSelector(const QString &selector); - void setBackgroundColor(const QString &color); - void setBackgroundColorSelector(const QString &selector); - - void clearFontSize(); - void clearFontSizeSelector(); - void clearBackgroundColor(); - void clearBackgroundColorSelector(); - - QWidget *operator->(); - - MultiStyleWidgetWrapper(QWidget *widget); - - protected: - static const uint32_t UNSET_FONTSIZE; - static const QString UNSET_COLOR; - static const QString UNSET_SELECTOR; - /// The wrapped widget - QWidget *m_widget; - /// The current font size in pixels - uint32_t m_fontSize = UNSET_FONTSIZE; - /// The CSS selector to be applied to the font size - QString m_fontSizeSelector = UNSET_SELECTOR; - /// The current background color - QString m_backgroundColor = UNSET_COLOR; - /// The CSS selector to be applied to the background color - QString m_backgroundColorSelector = UNSET_SELECTOR; - - void updateStyleSheet(); +public: + void setFontSize(uint32_t fontSize, bool isPixels = true); + void setFontSizeSelector(const QString &selector); + void setBackgroundColor(const QString &color); + void setBackgroundColorSelector(const QString &selector); + + void clearFontSize(); + void clearFontSizeSelector(); + void clearBackgroundColor(); + void clearBackgroundColorSelector(); + + QWidget *operator->(); + + MultiStyleWidgetWrapper(QWidget *widget); + +protected: + static const uint32_t UNSET_FONTSIZE; + static const QString UNSET_COLOR; + static const QString UNSET_SELECTOR; + /// The wrapped widget + QWidget *m_widget; + /// The current font size in pixels + uint32_t m_fontSize = UNSET_FONTSIZE; + /// The CSS selector to be applied to the font size + QString m_fontSizeSelector = UNSET_SELECTOR; + /// The current background color + QString m_backgroundColor = UNSET_COLOR; + /// The CSS selector to be applied to the background color + QString m_backgroundColorSelector = UNSET_SELECTOR; + + void updateStyleSheet(); }; #endif // MUMBLE_MUMBLE_WIDGETS_MULTISTYLEWIDGETWRAPPER_H_ diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index 6fb23e141..16cb63221 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -381,7 +381,7 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg { QWriteLocker wl(&qrwlVoiceThread); uSource->uiSession = qqIds.dequeue(); - uSource->sState = ServerUser::Authenticated; + uSource->sState = ServerUser::Authenticated; qhUsers.insert(uSource->uiSession, uSource); qhHostUsers[uSource->haAddress].insert(uSource); } @@ -1417,9 +1417,7 @@ void Server::msgTextMessage(ServerUser *uSource, MumbleProto::TextMessage &msg) } // Users directly in that channel - foreach (User *p, c->qlUsers) { - users.insert(static_cast< ServerUser * >(p)); - } + foreach (User *p, c->qlUsers) { users.insert(static_cast< ServerUser * >(p)); } // Users only listening in that channel foreach (unsigned int session, ChannelListener::getListenersForChannel(c)) { @@ -1458,13 +1456,9 @@ void Server::msgTextMessage(ServerUser *uSource, MumbleProto::TextMessage &msg) while (!q.isEmpty()) { Channel *c = q.dequeue(); if (ChanACL::hasPermission(uSource, c, ChanACL::TextMessage, &acCache)) { - foreach (Channel *sub, c->qlChannels) { - q.enqueue(sub); - } + foreach (Channel *sub, c->qlChannels) { q.enqueue(sub); } // Users directly in that channel - foreach (User *p, c->qlUsers) { - users.insert(static_cast< ServerUser * >(p)); - } + foreach (User *p, c->qlUsers) { users.insert(static_cast< ServerUser * >(p)); } // Users only listening in that channel foreach (unsigned int session, ChannelListener::getListenersForChannel(c)) { ServerUser *currentUser = qhUsers.value(session); @@ -1494,9 +1488,7 @@ void Server::msgTextMessage(ServerUser *uSource, MumbleProto::TextMessage &msg) users.remove(uSource); // Actually send the original message to the affected users - foreach (ServerUser *u, users) { - sendMessage(u, msg); - } + foreach (ServerUser *u, users) { sendMessage(u, msg); } // Emit the signal for RPC consumers emit userTextMessage(uSource, tm); @@ -2175,16 +2167,19 @@ void Server::msgPluginDataTransmission(ServerUser *sender, MumbleProto::PluginDa } if (!msg.has_data() || !msg.has_dataid()) { - // Messages without data and/or without a data ID can't be used by the clients. Thus we don't even have to send them + // Messages without data and/or without a data ID can't be used by the clients. Thus we don't even have to send + // them return; } if (msg.data().size() > Mumble::Plugins::PluginMessage::MAX_DATA_LENGTH) { - qWarning("Dropping plugin message sent from \"%s\" (%d) - data too large", qUtf8Printable(sender->qsName), sender->uiSession); + qWarning("Dropping plugin message sent from \"%s\" (%d) - data too large", qUtf8Printable(sender->qsName), + sender->uiSession); return; } if (msg.dataid().size() > Mumble::Plugins::PluginMessage::MAX_DATA_ID_LENGTH) { - qWarning("Dropping plugin message sent from \"%s\" (%d) - data ID too long", qUtf8Printable(sender->qsName), sender->uiSession); + qWarning("Dropping plugin message sent from \"%s\" (%d) - data ID too long", qUtf8Printable(sender->qsName), + sender->uiSession); return; } @@ -2194,15 +2189,15 @@ void Server::msgPluginDataTransmission(ServerUser *sender, MumbleProto::PluginDa // Copy needed data from message in order to be able to remove info about receivers from the message as this doesn't // matter for the client - size_t receiverAmount = msg.receiversessions_size(); - const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > receiverSessions = msg.receiversessions(); + size_t receiverAmount = msg.receiversessions_size(); + const ::google::protobuf::RepeatedField<::google::protobuf::uint32 > receiverSessions = msg.receiversessions(); msg.clear_receiversessions(); - QSet<uint32_t> uniqueReceivers; + QSet< uint32_t > uniqueReceivers; uniqueReceivers.reserve(receiverSessions.size()); - for(int i = 0; static_cast<size_t>(i) < receiverAmount; i++) { + for (int i = 0; static_cast< size_t >(i) < receiverAmount; i++) { uint32_t userSession = receiverSessions.Get(i); if (!uniqueReceivers.contains(userSession)) { diff --git a/src/murmur/MurmurGRPCImpl.h b/src/murmur/MurmurGRPCImpl.h index e797de468..9835aedf5 100644 --- a/src/murmur/MurmurGRPCImpl.h +++ b/src/murmur/MurmurGRPCImpl.h @@ -212,7 +212,8 @@ public: private: void *writeCB() { - auto callback = ::boost::bind(&RPCSingleStreamCall< InType, OutType >::writeCallback, this, boost::placeholders::_1); + auto callback = + ::boost::bind(&RPCSingleStreamCall< InType, OutType >::writeCallback, this, boost::placeholders::_1); return new ::boost::function< void(bool) >(callback); } diff --git a/src/murmur/MurmurI.h b/src/murmur/MurmurI.h index 8dcb23e27..73598d828 100644 --- a/src/murmur/MurmurI.h +++ b/src/murmur/MurmurI.h @@ -156,7 +156,7 @@ public: const Ice::Current &); virtual void sendWelcomeMessage_async(const ::Murmur::AMD_Server_sendWelcomeMessagePtr &, - const ::Murmur::IdList &p1, const ::Ice::Current ¤t); + const ::Murmur::IdList &p1, const ::Ice::Current ¤t); virtual void ice_ping(const Ice::Current &) const; }; diff --git a/src/murmur/MurmurIce.cpp b/src/murmur/MurmurIce.cpp index f256713fd..db549c514 100644 --- a/src/murmur/MurmurIce.cpp +++ b/src/murmur/MurmurIce.cpp @@ -1765,7 +1765,8 @@ static void impl_Server_getListeningUsers(const ::Murmur::AMD_Server_getListenin cb->ice_response(userSessions); } -static void impl_Server_sendWelcomeMessage(const ::Murmur::AMD_Server_sendWelcomeMessagePtr cb, int server_id, ::Murmur::IdList receiverUserIDs) { +static void impl_Server_sendWelcomeMessage(const ::Murmur::AMD_Server_sendWelcomeMessagePtr cb, int server_id, + ::Murmur::IdList receiverUserIDs) { NEED_SERVER; for (unsigned int session : receiverUserIDs) { diff --git a/src/murmur/MurmurIceWrapper.cpp b/src/murmur/MurmurIceWrapper.cpp index 94c4abc30..a0ffd3ce9 100644 --- a/src/murmur/MurmurIceWrapper.cpp +++ b/src/murmur/MurmurIceWrapper.cpp @@ -18,7 +18,7 @@ void ::Murmur::ServerI::isRunning_async(const ::Murmur::AMD_Server_isRunningPtr bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_isRunning_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_isRunning_READ @@ -35,7 +35,8 @@ void ::Murmur::ServerI::isRunning_async(const ::Murmur::AMD_Server_isRunningPtr } #endif // ACCESS_Server_isRunning_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_isRunning, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_isRunning, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } @@ -50,7 +51,7 @@ void ::Murmur::ServerI::start_async(const ::Murmur::AMD_Server_startPtr &cb, con bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_start_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_start_READ @@ -82,7 +83,7 @@ void ::Murmur::ServerI::stop_async(const ::Murmur::AMD_Server_stopPtr &cb, const bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_stop_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_stop_READ @@ -114,7 +115,7 @@ void ::Murmur::ServerI::delete_async(const ::Murmur::AMD_Server_deletePtr &cb, c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_delete_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_delete_READ @@ -131,7 +132,8 @@ void ::Murmur::ServerI::delete_async(const ::Murmur::AMD_Server_deletePtr &cb, c } #endif // ACCESS_Server_delete_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_delete, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_delete, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } @@ -146,7 +148,7 @@ void ::Murmur::ServerI::id_async(const ::Murmur::AMD_Server_idPtr &cb, const ::I bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_id_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_id_READ @@ -167,7 +169,8 @@ void ::Murmur::ServerI::id_async(const ::Murmur::AMD_Server_idPtr &cb, const ::I QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::addCallback_async(const ::Murmur::AMD_Server_addCallbackPtr &cb, const ServerCallbackPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::addCallback_async(const ::Murmur::AMD_Server_addCallbackPtr &cb, const ServerCallbackPrx &p1, + const ::Ice::Current ¤t) { // qWarning() << "addCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_addCallback_ALL # ifdef ACCESS_Server_addCallback_READ @@ -178,7 +181,7 @@ void ::Murmur::ServerI::addCallback_async(const ::Murmur::AMD_Server_addCallback bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_addCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_addCallback_READ @@ -195,11 +198,13 @@ void ::Murmur::ServerI::addCallback_async(const ::Murmur::AMD_Server_addCallback } #endif // ACCESS_Server_addCallback_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_addCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_addCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::removeCallback_async(const ::Murmur::AMD_Server_removeCallbackPtr &cb, const ServerCallbackPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::removeCallback_async(const ::Murmur::AMD_Server_removeCallbackPtr &cb, + const ServerCallbackPrx &p1, const ::Ice::Current ¤t) { // qWarning() << "removeCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_removeCallback_ALL # ifdef ACCESS_Server_removeCallback_READ @@ -210,7 +215,7 @@ void ::Murmur::ServerI::removeCallback_async(const ::Murmur::AMD_Server_removeCa bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_removeCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_removeCallback_READ @@ -227,11 +232,13 @@ void ::Murmur::ServerI::removeCallback_async(const ::Murmur::AMD_Server_removeCa } #endif // ACCESS_Server_removeCallback_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_removeCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_removeCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setAuthenticator_async(const ::Murmur::AMD_Server_setAuthenticatorPtr &cb, const ServerAuthenticatorPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setAuthenticator_async(const ::Murmur::AMD_Server_setAuthenticatorPtr &cb, + const ServerAuthenticatorPrx &p1, const ::Ice::Current ¤t) { // qWarning() << "setAuthenticator" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setAuthenticator_ALL # ifdef ACCESS_Server_setAuthenticator_READ @@ -242,7 +249,7 @@ void ::Murmur::ServerI::setAuthenticator_async(const ::Murmur::AMD_Server_setAut bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setAuthenticator_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setAuthenticator_READ @@ -259,11 +266,13 @@ void ::Murmur::ServerI::setAuthenticator_async(const ::Murmur::AMD_Server_setAut } #endif // ACCESS_Server_setAuthenticator_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setAuthenticator, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_setAuthenticator, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getConf_async(const ::Murmur::AMD_Server_getConfPtr &cb, const ::std::string& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getConf_async(const ::Murmur::AMD_Server_getConfPtr &cb, const ::std::string &p1, + const ::Ice::Current ¤t) { // qWarning() << "getConf" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getConf_ALL # ifdef ACCESS_Server_getConf_READ @@ -274,7 +283,7 @@ void ::Murmur::ServerI::getConf_async(const ::Murmur::AMD_Server_getConfPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getConf_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getConf_READ @@ -291,7 +300,8 @@ void ::Murmur::ServerI::getConf_async(const ::Murmur::AMD_Server_getConfPtr &cb, } #endif // ACCESS_Server_getConf_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getConf, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getConf, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } @@ -306,7 +316,7 @@ void ::Murmur::ServerI::getAllConf_async(const ::Murmur::AMD_Server_getAllConfPt bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getAllConf_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getAllConf_READ @@ -323,11 +333,13 @@ void ::Murmur::ServerI::getAllConf_async(const ::Murmur::AMD_Server_getAllConfPt } #endif // ACCESS_Server_getAllConf_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getAllConf, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getAllConf, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setConf_async(const ::Murmur::AMD_Server_setConfPtr &cb, const ::std::string& p1, const ::std::string& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setConf_async(const ::Murmur::AMD_Server_setConfPtr &cb, const ::std::string &p1, + const ::std::string &p2, const ::Ice::Current ¤t) { // qWarning() << "setConf" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setConf_ALL # ifdef ACCESS_Server_setConf_READ @@ -338,7 +350,7 @@ void ::Murmur::ServerI::setConf_async(const ::Murmur::AMD_Server_setConfPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setConf_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setConf_READ @@ -355,11 +367,13 @@ void ::Murmur::ServerI::setConf_async(const ::Murmur::AMD_Server_setConfPtr &cb, } #endif // ACCESS_Server_setConf_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setConf, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_setConf, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setSuperuserPassword_async(const ::Murmur::AMD_Server_setSuperuserPasswordPtr &cb, const ::std::string& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setSuperuserPassword_async(const ::Murmur::AMD_Server_setSuperuserPasswordPtr &cb, + const ::std::string &p1, const ::Ice::Current ¤t) { // qWarning() << "setSuperuserPassword" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setSuperuserPassword_ALL # ifdef ACCESS_Server_setSuperuserPassword_READ @@ -370,7 +384,7 @@ void ::Murmur::ServerI::setSuperuserPassword_async(const ::Murmur::AMD_Server_se bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setSuperuserPassword_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setSuperuserPassword_READ @@ -387,11 +401,13 @@ void ::Murmur::ServerI::setSuperuserPassword_async(const ::Murmur::AMD_Server_se } #endif // ACCESS_Server_setSuperuserPassword_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setSuperuserPassword, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_setSuperuserPassword, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getLog_async(const ::Murmur::AMD_Server_getLogPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getLog_async(const ::Murmur::AMD_Server_getLogPtr &cb, ::Ice::Int p1, ::Ice::Int p2, + const ::Ice::Current ¤t) { // qWarning() << "getLog" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getLog_ALL # ifdef ACCESS_Server_getLog_READ @@ -402,7 +418,7 @@ void ::Murmur::ServerI::getLog_async(const ::Murmur::AMD_Server_getLogPtr &cb, : bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getLog_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getLog_READ @@ -419,7 +435,8 @@ void ::Murmur::ServerI::getLog_async(const ::Murmur::AMD_Server_getLogPtr &cb, : } #endif // ACCESS_Server_getLog_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getLog, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getLog, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } @@ -434,7 +451,7 @@ void ::Murmur::ServerI::getLogLen_async(const ::Murmur::AMD_Server_getLogLenPtr bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getLogLen_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getLogLen_READ @@ -451,7 +468,8 @@ void ::Murmur::ServerI::getLogLen_async(const ::Murmur::AMD_Server_getLogLenPtr } #endif // ACCESS_Server_getLogLen_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getLogLen, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getLogLen, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } @@ -466,7 +484,7 @@ void ::Murmur::ServerI::getUsers_async(const ::Murmur::AMD_Server_getUsersPtr &c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getUsers_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getUsers_READ @@ -483,11 +501,13 @@ void ::Murmur::ServerI::getUsers_async(const ::Murmur::AMD_Server_getUsersPtr &c } #endif // ACCESS_Server_getUsers_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getUsers, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getUsers, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getChannels_async(const ::Murmur::AMD_Server_getChannelsPtr &cb, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getChannels_async(const ::Murmur::AMD_Server_getChannelsPtr &cb, + const ::Ice::Current ¤t) { // qWarning() << "getChannels" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getChannels_ALL # ifdef ACCESS_Server_getChannels_READ @@ -498,7 +518,7 @@ void ::Murmur::ServerI::getChannels_async(const ::Murmur::AMD_Server_getChannels bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getChannels_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getChannels_READ @@ -515,11 +535,13 @@ void ::Murmur::ServerI::getChannels_async(const ::Murmur::AMD_Server_getChannels } #endif // ACCESS_Server_getChannels_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getChannels, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getChannels, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getCertificateList_async(const ::Murmur::AMD_Server_getCertificateListPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getCertificateList_async(const ::Murmur::AMD_Server_getCertificateListPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getCertificateList" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getCertificateList_ALL # ifdef ACCESS_Server_getCertificateList_READ @@ -530,7 +552,7 @@ void ::Murmur::ServerI::getCertificateList_async(const ::Murmur::AMD_Server_getC bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getCertificateList_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getCertificateList_READ @@ -547,7 +569,8 @@ void ::Murmur::ServerI::getCertificateList_async(const ::Murmur::AMD_Server_getC } #endif // ACCESS_Server_getCertificateList_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getCertificateList, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getCertificateList, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } @@ -562,7 +585,7 @@ void ::Murmur::ServerI::getTree_async(const ::Murmur::AMD_Server_getTreePtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getTree_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getTree_READ @@ -579,7 +602,8 @@ void ::Murmur::ServerI::getTree_async(const ::Murmur::AMD_Server_getTreePtr &cb, } #endif // ACCESS_Server_getTree_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getTree, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getTree, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } @@ -594,7 +618,7 @@ void ::Murmur::ServerI::getBans_async(const ::Murmur::AMD_Server_getBansPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getBans_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getBans_READ @@ -611,11 +635,13 @@ void ::Murmur::ServerI::getBans_async(const ::Murmur::AMD_Server_getBansPtr &cb, } #endif // ACCESS_Server_getBans_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getBans, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getBans, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setBans_async(const ::Murmur::AMD_Server_setBansPtr &cb, const BanList& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setBans_async(const ::Murmur::AMD_Server_setBansPtr &cb, const BanList &p1, + const ::Ice::Current ¤t) { // qWarning() << "setBans" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setBans_ALL # ifdef ACCESS_Server_setBans_READ @@ -626,7 +652,7 @@ void ::Murmur::ServerI::setBans_async(const ::Murmur::AMD_Server_setBansPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setBans_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setBans_READ @@ -643,11 +669,13 @@ void ::Murmur::ServerI::setBans_async(const ::Murmur::AMD_Server_setBansPtr &cb, } #endif // ACCESS_Server_setBans_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setBans, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_setBans, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::kickUser_async(const ::Murmur::AMD_Server_kickUserPtr &cb, ::Ice::Int p1, const ::std::string& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::kickUser_async(const ::Murmur::AMD_Server_kickUserPtr &cb, ::Ice::Int p1, + const ::std::string &p2, const ::Ice::Current ¤t) { // qWarning() << "kickUser" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_kickUser_ALL # ifdef ACCESS_Server_kickUser_READ @@ -658,7 +686,7 @@ void ::Murmur::ServerI::kickUser_async(const ::Murmur::AMD_Server_kickUserPtr &c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_kickUser_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_kickUser_READ @@ -675,11 +703,13 @@ void ::Murmur::ServerI::kickUser_async(const ::Murmur::AMD_Server_kickUserPtr &c } #endif // ACCESS_Server_kickUser_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_kickUser, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_kickUser, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getState_async(const ::Murmur::AMD_Server_getStatePtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getState_async(const ::Murmur::AMD_Server_getStatePtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getState" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getState_ALL # ifdef ACCESS_Server_getState_READ @@ -690,7 +720,7 @@ void ::Murmur::ServerI::getState_async(const ::Murmur::AMD_Server_getStatePtr &c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getState_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getState_READ @@ -707,11 +737,13 @@ void ::Murmur::ServerI::getState_async(const ::Murmur::AMD_Server_getStatePtr &c } #endif // ACCESS_Server_getState_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getState, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getState, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setState_async(const ::Murmur::AMD_Server_setStatePtr &cb, const User& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setState_async(const ::Murmur::AMD_Server_setStatePtr &cb, const User &p1, + const ::Ice::Current ¤t) { // qWarning() << "setState" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setState_ALL # ifdef ACCESS_Server_setState_READ @@ -722,7 +754,7 @@ void ::Murmur::ServerI::setState_async(const ::Murmur::AMD_Server_setStatePtr &c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setState_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setState_READ @@ -739,11 +771,13 @@ void ::Murmur::ServerI::setState_async(const ::Murmur::AMD_Server_setStatePtr &c } #endif // ACCESS_Server_setState_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setState, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_setState, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::sendMessage_async(const ::Murmur::AMD_Server_sendMessagePtr &cb, ::Ice::Int p1, const ::std::string& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::sendMessage_async(const ::Murmur::AMD_Server_sendMessagePtr &cb, ::Ice::Int p1, + const ::std::string &p2, const ::Ice::Current ¤t) { // qWarning() << "sendMessage" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_sendMessage_ALL # ifdef ACCESS_Server_sendMessage_READ @@ -754,7 +788,7 @@ void ::Murmur::ServerI::sendMessage_async(const ::Murmur::AMD_Server_sendMessage bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_sendMessage_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_sendMessage_READ @@ -771,11 +805,13 @@ void ::Murmur::ServerI::sendMessage_async(const ::Murmur::AMD_Server_sendMessage } #endif // ACCESS_Server_sendMessage_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_sendMessage, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_sendMessage, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::hasPermission_async(const ::Murmur::AMD_Server_hasPermissionPtr &cb, ::Ice::Int p1, ::Ice::Int p2, ::Ice::Int p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::hasPermission_async(const ::Murmur::AMD_Server_hasPermissionPtr &cb, ::Ice::Int p1, + ::Ice::Int p2, ::Ice::Int p3, const ::Ice::Current ¤t) { // qWarning() << "hasPermission" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_hasPermission_ALL # ifdef ACCESS_Server_hasPermission_READ @@ -786,7 +822,7 @@ void ::Murmur::ServerI::hasPermission_async(const ::Murmur::AMD_Server_hasPermis bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_hasPermission_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_hasPermission_READ @@ -803,11 +839,13 @@ void ::Murmur::ServerI::hasPermission_async(const ::Murmur::AMD_Server_hasPermis } #endif // ACCESS_Server_hasPermission_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_hasPermission, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_hasPermission, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::effectivePermissions_async(const ::Murmur::AMD_Server_effectivePermissionsPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::effectivePermissions_async(const ::Murmur::AMD_Server_effectivePermissionsPtr &cb, + ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { // qWarning() << "effectivePermissions" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_effectivePermissions_ALL # ifdef ACCESS_Server_effectivePermissions_READ @@ -818,7 +856,7 @@ void ::Murmur::ServerI::effectivePermissions_async(const ::Murmur::AMD_Server_ef bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_effectivePermissions_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_effectivePermissions_READ @@ -835,11 +873,15 @@ void ::Murmur::ServerI::effectivePermissions_async(const ::Murmur::AMD_Server_ef } #endif // ACCESS_Server_effectivePermissions_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_effectivePermissions, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_effectivePermissions, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::addContextCallback_async(const ::Murmur::AMD_Server_addContextCallbackPtr &cb, ::Ice::Int p1, const ::std::string& p2, const ::std::string& p3, const ServerContextCallbackPrx& p4, ::Ice::Int p5, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::addContextCallback_async(const ::Murmur::AMD_Server_addContextCallbackPtr &cb, ::Ice::Int p1, + const ::std::string &p2, const ::std::string &p3, + const ServerContextCallbackPrx &p4, ::Ice::Int p5, + const ::Ice::Current ¤t) { // qWarning() << "addContextCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_addContextCallback_ALL # ifdef ACCESS_Server_addContextCallback_READ @@ -850,7 +892,7 @@ void ::Murmur::ServerI::addContextCallback_async(const ::Murmur::AMD_Server_addC bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_addContextCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_addContextCallback_READ @@ -867,11 +909,13 @@ void ::Murmur::ServerI::addContextCallback_async(const ::Murmur::AMD_Server_addC } #endif // ACCESS_Server_addContextCallback_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_addContextCallback, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3, p4, p5)); + ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_addContextCallback, cb, + QString::fromStdString(current.id.name).toInt(), p1, p2, p3, p4, p5)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::removeContextCallback_async(const ::Murmur::AMD_Server_removeContextCallbackPtr &cb, const ServerContextCallbackPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::removeContextCallback_async(const ::Murmur::AMD_Server_removeContextCallbackPtr &cb, + const ServerContextCallbackPrx &p1, const ::Ice::Current ¤t) { // qWarning() << "removeContextCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_removeContextCallback_ALL # ifdef ACCESS_Server_removeContextCallback_READ @@ -882,7 +926,7 @@ void ::Murmur::ServerI::removeContextCallback_async(const ::Murmur::AMD_Server_r bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_removeContextCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_removeContextCallback_READ @@ -899,11 +943,13 @@ void ::Murmur::ServerI::removeContextCallback_async(const ::Murmur::AMD_Server_r } #endif // ACCESS_Server_removeContextCallback_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_removeContextCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_removeContextCallback, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getChannelState_async(const ::Murmur::AMD_Server_getChannelStatePtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getChannelState_async(const ::Murmur::AMD_Server_getChannelStatePtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getChannelState" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getChannelState_ALL # ifdef ACCESS_Server_getChannelState_READ @@ -914,7 +960,7 @@ void ::Murmur::ServerI::getChannelState_async(const ::Murmur::AMD_Server_getChan bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getChannelState_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getChannelState_READ @@ -931,11 +977,13 @@ void ::Murmur::ServerI::getChannelState_async(const ::Murmur::AMD_Server_getChan } #endif // ACCESS_Server_getChannelState_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getChannelState, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getChannelState, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setChannelState_async(const ::Murmur::AMD_Server_setChannelStatePtr &cb, const Channel& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setChannelState_async(const ::Murmur::AMD_Server_setChannelStatePtr &cb, const Channel &p1, + const ::Ice::Current ¤t) { // qWarning() << "setChannelState" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setChannelState_ALL # ifdef ACCESS_Server_setChannelState_READ @@ -946,7 +994,7 @@ void ::Murmur::ServerI::setChannelState_async(const ::Murmur::AMD_Server_setChan bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setChannelState_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setChannelState_READ @@ -963,11 +1011,13 @@ void ::Murmur::ServerI::setChannelState_async(const ::Murmur::AMD_Server_setChan } #endif // ACCESS_Server_setChannelState_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setChannelState, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_setChannelState, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::removeChannel_async(const ::Murmur::AMD_Server_removeChannelPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::removeChannel_async(const ::Murmur::AMD_Server_removeChannelPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "removeChannel" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_removeChannel_ALL # ifdef ACCESS_Server_removeChannel_READ @@ -978,7 +1028,7 @@ void ::Murmur::ServerI::removeChannel_async(const ::Murmur::AMD_Server_removeCha bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_removeChannel_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_removeChannel_READ @@ -995,11 +1045,13 @@ void ::Murmur::ServerI::removeChannel_async(const ::Murmur::AMD_Server_removeCha } #endif // ACCESS_Server_removeChannel_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_removeChannel, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_removeChannel, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::addChannel_async(const ::Murmur::AMD_Server_addChannelPtr &cb, const ::std::string& p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::addChannel_async(const ::Murmur::AMD_Server_addChannelPtr &cb, const ::std::string &p1, + ::Ice::Int p2, const ::Ice::Current ¤t) { // qWarning() << "addChannel" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_addChannel_ALL # ifdef ACCESS_Server_addChannel_READ @@ -1010,7 +1062,7 @@ void ::Murmur::ServerI::addChannel_async(const ::Murmur::AMD_Server_addChannelPt bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_addChannel_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_addChannel_READ @@ -1027,11 +1079,13 @@ void ::Murmur::ServerI::addChannel_async(const ::Murmur::AMD_Server_addChannelPt } #endif // ACCESS_Server_addChannel_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_addChannel, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_addChannel, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::sendMessageChannel_async(const ::Murmur::AMD_Server_sendMessageChannelPtr &cb, ::Ice::Int p1, bool p2, const ::std::string& p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::sendMessageChannel_async(const ::Murmur::AMD_Server_sendMessageChannelPtr &cb, ::Ice::Int p1, + bool p2, const ::std::string &p3, const ::Ice::Current ¤t) { // qWarning() << "sendMessageChannel" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_sendMessageChannel_ALL # ifdef ACCESS_Server_sendMessageChannel_READ @@ -1042,7 +1096,7 @@ void ::Murmur::ServerI::sendMessageChannel_async(const ::Murmur::AMD_Server_send bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_sendMessageChannel_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_sendMessageChannel_READ @@ -1059,11 +1113,13 @@ void ::Murmur::ServerI::sendMessageChannel_async(const ::Murmur::AMD_Server_send } #endif // ACCESS_Server_sendMessageChannel_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_sendMessageChannel, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_sendMessageChannel, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getACL_async(const ::Murmur::AMD_Server_getACLPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getACL_async(const ::Murmur::AMD_Server_getACLPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getACL" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getACL_ALL # ifdef ACCESS_Server_getACL_READ @@ -1074,7 +1130,7 @@ void ::Murmur::ServerI::getACL_async(const ::Murmur::AMD_Server_getACLPtr &cb, : bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getACL_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getACL_READ @@ -1091,11 +1147,13 @@ void ::Murmur::ServerI::getACL_async(const ::Murmur::AMD_Server_getACLPtr &cb, : } #endif // ACCESS_Server_getACL_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getACL, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getACL, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setACL_async(const ::Murmur::AMD_Server_setACLPtr &cb, ::Ice::Int p1, const ACLList& p2, const GroupList& p3, bool p4, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setACL_async(const ::Murmur::AMD_Server_setACLPtr &cb, ::Ice::Int p1, const ACLList &p2, + const GroupList &p3, bool p4, const ::Ice::Current ¤t) { // qWarning() << "setACL" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setACL_ALL # ifdef ACCESS_Server_setACL_READ @@ -1106,7 +1164,7 @@ void ::Murmur::ServerI::setACL_async(const ::Murmur::AMD_Server_setACLPtr &cb, : bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setACL_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setACL_READ @@ -1123,11 +1181,13 @@ void ::Murmur::ServerI::setACL_async(const ::Murmur::AMD_Server_setACLPtr &cb, : } #endif // ACCESS_Server_setACL_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setACL, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3, p4)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_setACL, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3, p4)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::addUserToGroup_async(const ::Murmur::AMD_Server_addUserToGroupPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::std::string& p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::addUserToGroup_async(const ::Murmur::AMD_Server_addUserToGroupPtr &cb, ::Ice::Int p1, + ::Ice::Int p2, const ::std::string &p3, const ::Ice::Current ¤t) { // qWarning() << "addUserToGroup" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_addUserToGroup_ALL # ifdef ACCESS_Server_addUserToGroup_READ @@ -1138,7 +1198,7 @@ void ::Murmur::ServerI::addUserToGroup_async(const ::Murmur::AMD_Server_addUserT bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_addUserToGroup_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_addUserToGroup_READ @@ -1155,11 +1215,14 @@ void ::Murmur::ServerI::addUserToGroup_async(const ::Murmur::AMD_Server_addUserT } #endif // ACCESS_Server_addUserToGroup_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_addUserToGroup, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_addUserToGroup, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::removeUserFromGroup_async(const ::Murmur::AMD_Server_removeUserFromGroupPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::std::string& p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::removeUserFromGroup_async(const ::Murmur::AMD_Server_removeUserFromGroupPtr &cb, ::Ice::Int p1, + ::Ice::Int p2, const ::std::string &p3, + const ::Ice::Current ¤t) { // qWarning() << "removeUserFromGroup" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_removeUserFromGroup_ALL # ifdef ACCESS_Server_removeUserFromGroup_READ @@ -1170,7 +1233,7 @@ void ::Murmur::ServerI::removeUserFromGroup_async(const ::Murmur::AMD_Server_rem bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_removeUserFromGroup_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_removeUserFromGroup_READ @@ -1187,11 +1250,14 @@ void ::Murmur::ServerI::removeUserFromGroup_async(const ::Murmur::AMD_Server_rem } #endif // ACCESS_Server_removeUserFromGroup_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_removeUserFromGroup, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_removeUserFromGroup, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::redirectWhisperGroup_async(const ::Murmur::AMD_Server_redirectWhisperGroupPtr &cb, ::Ice::Int p1, const ::std::string& p2, const ::std::string& p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::redirectWhisperGroup_async(const ::Murmur::AMD_Server_redirectWhisperGroupPtr &cb, + ::Ice::Int p1, const ::std::string &p2, const ::std::string &p3, + const ::Ice::Current ¤t) { // qWarning() << "redirectWhisperGroup" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_redirectWhisperGroup_ALL # ifdef ACCESS_Server_redirectWhisperGroup_READ @@ -1202,7 +1268,7 @@ void ::Murmur::ServerI::redirectWhisperGroup_async(const ::Murmur::AMD_Server_re bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_redirectWhisperGroup_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_redirectWhisperGroup_READ @@ -1219,11 +1285,13 @@ void ::Murmur::ServerI::redirectWhisperGroup_async(const ::Murmur::AMD_Server_re } #endif // ACCESS_Server_redirectWhisperGroup_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_redirectWhisperGroup, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_redirectWhisperGroup, cb, + QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getUserNames_async(const ::Murmur::AMD_Server_getUserNamesPtr &cb, const IdList& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getUserNames_async(const ::Murmur::AMD_Server_getUserNamesPtr &cb, const IdList &p1, + const ::Ice::Current ¤t) { // qWarning() << "getUserNames" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getUserNames_ALL # ifdef ACCESS_Server_getUserNames_READ @@ -1234,7 +1302,7 @@ void ::Murmur::ServerI::getUserNames_async(const ::Murmur::AMD_Server_getUserNam bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getUserNames_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getUserNames_READ @@ -1251,11 +1319,13 @@ void ::Murmur::ServerI::getUserNames_async(const ::Murmur::AMD_Server_getUserNam } #endif // ACCESS_Server_getUserNames_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getUserNames, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getUserNames, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getUserIds_async(const ::Murmur::AMD_Server_getUserIdsPtr &cb, const NameList& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getUserIds_async(const ::Murmur::AMD_Server_getUserIdsPtr &cb, const NameList &p1, + const ::Ice::Current ¤t) { // qWarning() << "getUserIds" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getUserIds_ALL # ifdef ACCESS_Server_getUserIds_READ @@ -1266,7 +1336,7 @@ void ::Murmur::ServerI::getUserIds_async(const ::Murmur::AMD_Server_getUserIdsPt bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getUserIds_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getUserIds_READ @@ -1283,11 +1353,13 @@ void ::Murmur::ServerI::getUserIds_async(const ::Murmur::AMD_Server_getUserIdsPt } #endif // ACCESS_Server_getUserIds_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getUserIds, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getUserIds, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::registerUser_async(const ::Murmur::AMD_Server_registerUserPtr &cb, const UserInfoMap& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::registerUser_async(const ::Murmur::AMD_Server_registerUserPtr &cb, const UserInfoMap &p1, + const ::Ice::Current ¤t) { // qWarning() << "registerUser" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_registerUser_ALL # ifdef ACCESS_Server_registerUser_READ @@ -1298,7 +1370,7 @@ void ::Murmur::ServerI::registerUser_async(const ::Murmur::AMD_Server_registerUs bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_registerUser_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_registerUser_READ @@ -1315,11 +1387,13 @@ void ::Murmur::ServerI::registerUser_async(const ::Murmur::AMD_Server_registerUs } #endif // ACCESS_Server_registerUser_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_registerUser, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_registerUser, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::unregisterUser_async(const ::Murmur::AMD_Server_unregisterUserPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::unregisterUser_async(const ::Murmur::AMD_Server_unregisterUserPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "unregisterUser" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_unregisterUser_ALL # ifdef ACCESS_Server_unregisterUser_READ @@ -1330,7 +1404,7 @@ void ::Murmur::ServerI::unregisterUser_async(const ::Murmur::AMD_Server_unregist bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_unregisterUser_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_unregisterUser_READ @@ -1347,11 +1421,13 @@ void ::Murmur::ServerI::unregisterUser_async(const ::Murmur::AMD_Server_unregist } #endif // ACCESS_Server_unregisterUser_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_unregisterUser, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_unregisterUser, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::updateRegistration_async(const ::Murmur::AMD_Server_updateRegistrationPtr &cb, ::Ice::Int p1, const UserInfoMap& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::updateRegistration_async(const ::Murmur::AMD_Server_updateRegistrationPtr &cb, ::Ice::Int p1, + const UserInfoMap &p2, const ::Ice::Current ¤t) { // qWarning() << "updateRegistration" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_updateRegistration_ALL # ifdef ACCESS_Server_updateRegistration_READ @@ -1362,7 +1438,7 @@ void ::Murmur::ServerI::updateRegistration_async(const ::Murmur::AMD_Server_upda bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_updateRegistration_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_updateRegistration_READ @@ -1379,11 +1455,13 @@ void ::Murmur::ServerI::updateRegistration_async(const ::Murmur::AMD_Server_upda } #endif // ACCESS_Server_updateRegistration_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_updateRegistration, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_updateRegistration, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getRegistration_async(const ::Murmur::AMD_Server_getRegistrationPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getRegistration_async(const ::Murmur::AMD_Server_getRegistrationPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getRegistration" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getRegistration_ALL # ifdef ACCESS_Server_getRegistration_READ @@ -1394,7 +1472,7 @@ void ::Murmur::ServerI::getRegistration_async(const ::Murmur::AMD_Server_getRegi bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getRegistration_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getRegistration_READ @@ -1411,11 +1489,13 @@ void ::Murmur::ServerI::getRegistration_async(const ::Murmur::AMD_Server_getRegi } #endif // ACCESS_Server_getRegistration_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getRegistration, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getRegistration, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getRegisteredUsers_async(const ::Murmur::AMD_Server_getRegisteredUsersPtr &cb, const ::std::string& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getRegisteredUsers_async(const ::Murmur::AMD_Server_getRegisteredUsersPtr &cb, + const ::std::string &p1, const ::Ice::Current ¤t) { // qWarning() << "getRegisteredUsers" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getRegisteredUsers_ALL # ifdef ACCESS_Server_getRegisteredUsers_READ @@ -1426,7 +1506,7 @@ void ::Murmur::ServerI::getRegisteredUsers_async(const ::Murmur::AMD_Server_getR bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getRegisteredUsers_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getRegisteredUsers_READ @@ -1443,11 +1523,13 @@ void ::Murmur::ServerI::getRegisteredUsers_async(const ::Murmur::AMD_Server_getR } #endif // ACCESS_Server_getRegisteredUsers_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getRegisteredUsers, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getRegisteredUsers, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::verifyPassword_async(const ::Murmur::AMD_Server_verifyPasswordPtr &cb, const ::std::string& p1, const ::std::string& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::verifyPassword_async(const ::Murmur::AMD_Server_verifyPasswordPtr &cb, const ::std::string &p1, + const ::std::string &p2, const ::Ice::Current ¤t) { // qWarning() << "verifyPassword" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_verifyPassword_ALL # ifdef ACCESS_Server_verifyPassword_READ @@ -1458,7 +1540,7 @@ void ::Murmur::ServerI::verifyPassword_async(const ::Murmur::AMD_Server_verifyPa bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_verifyPassword_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_verifyPassword_READ @@ -1475,11 +1557,13 @@ void ::Murmur::ServerI::verifyPassword_async(const ::Murmur::AMD_Server_verifyPa } #endif // ACCESS_Server_verifyPassword_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_verifyPassword, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_verifyPassword, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getTexture_async(const ::Murmur::AMD_Server_getTexturePtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getTexture_async(const ::Murmur::AMD_Server_getTexturePtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getTexture" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getTexture_ALL # ifdef ACCESS_Server_getTexture_READ @@ -1490,7 +1574,7 @@ void ::Murmur::ServerI::getTexture_async(const ::Murmur::AMD_Server_getTexturePt bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getTexture_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getTexture_READ @@ -1507,11 +1591,13 @@ void ::Murmur::ServerI::getTexture_async(const ::Murmur::AMD_Server_getTexturePt } #endif // ACCESS_Server_getTexture_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getTexture, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getTexture, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::setTexture_async(const ::Murmur::AMD_Server_setTexturePtr &cb, ::Ice::Int p1, const Texture& p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::setTexture_async(const ::Murmur::AMD_Server_setTexturePtr &cb, ::Ice::Int p1, const Texture &p2, + const ::Ice::Current ¤t) { // qWarning() << "setTexture" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_setTexture_ALL # ifdef ACCESS_Server_setTexture_READ @@ -1522,7 +1608,7 @@ void ::Murmur::ServerI::setTexture_async(const ::Murmur::AMD_Server_setTexturePt bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_setTexture_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_setTexture_READ @@ -1539,7 +1625,8 @@ void ::Murmur::ServerI::setTexture_async(const ::Murmur::AMD_Server_setTexturePt } #endif // ACCESS_Server_setTexture_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_setTexture, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_setTexture, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } @@ -1554,7 +1641,7 @@ void ::Murmur::ServerI::getUptime_async(const ::Murmur::AMD_Server_getUptimePtr bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getUptime_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getUptime_READ @@ -1571,11 +1658,14 @@ void ::Murmur::ServerI::getUptime_async(const ::Murmur::AMD_Server_getUptimePtr } #endif // ACCESS_Server_getUptime_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getUptime, cb, QString::fromStdString(current.id.name).toInt())); + ExecEvent *ie = + new ExecEvent(boost::bind(&impl_Server_getUptime, cb, QString::fromStdString(current.id.name).toInt())); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::updateCertificate_async(const ::Murmur::AMD_Server_updateCertificatePtr &cb, const ::std::string& p1, const ::std::string& p2, const ::std::string& p3, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::updateCertificate_async(const ::Murmur::AMD_Server_updateCertificatePtr &cb, + const ::std::string &p1, const ::std::string &p2, + const ::std::string &p3, const ::Ice::Current ¤t) { // qWarning() << "updateCertificate" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_updateCertificate_ALL # ifdef ACCESS_Server_updateCertificate_READ @@ -1586,7 +1676,7 @@ void ::Murmur::ServerI::updateCertificate_async(const ::Murmur::AMD_Server_updat bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_updateCertificate_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_updateCertificate_READ @@ -1603,11 +1693,13 @@ void ::Murmur::ServerI::updateCertificate_async(const ::Murmur::AMD_Server_updat } #endif // ACCESS_Server_updateCertificate_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_updateCertificate, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_updateCertificate, cb, QString::fromStdString(current.id.name).toInt(), p1, p2, p3)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::startListening_async(const ::Murmur::AMD_Server_startListeningPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::startListening_async(const ::Murmur::AMD_Server_startListeningPtr &cb, ::Ice::Int p1, + ::Ice::Int p2, const ::Ice::Current ¤t) { // qWarning() << "startListening" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_startListening_ALL # ifdef ACCESS_Server_startListening_READ @@ -1618,7 +1710,7 @@ void ::Murmur::ServerI::startListening_async(const ::Murmur::AMD_Server_startLis bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_startListening_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_startListening_READ @@ -1635,11 +1727,13 @@ void ::Murmur::ServerI::startListening_async(const ::Murmur::AMD_Server_startLis } #endif // ACCESS_Server_startListening_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_startListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_startListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::stopListening_async(const ::Murmur::AMD_Server_stopListeningPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::stopListening_async(const ::Murmur::AMD_Server_stopListeningPtr &cb, ::Ice::Int p1, + ::Ice::Int p2, const ::Ice::Current ¤t) { // qWarning() << "stopListening" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_stopListening_ALL # ifdef ACCESS_Server_stopListening_READ @@ -1650,7 +1744,7 @@ void ::Murmur::ServerI::stopListening_async(const ::Murmur::AMD_Server_stopListe bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_stopListening_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_stopListening_READ @@ -1667,11 +1761,13 @@ void ::Murmur::ServerI::stopListening_async(const ::Murmur::AMD_Server_stopListe } #endif // ACCESS_Server_stopListening_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_stopListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_stopListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::isListening_async(const ::Murmur::AMD_Server_isListeningPtr &cb, ::Ice::Int p1, ::Ice::Int p2, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::isListening_async(const ::Murmur::AMD_Server_isListeningPtr &cb, ::Ice::Int p1, ::Ice::Int p2, + const ::Ice::Current ¤t) { // qWarning() << "isListening" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_isListening_ALL # ifdef ACCESS_Server_isListening_READ @@ -1682,7 +1778,7 @@ void ::Murmur::ServerI::isListening_async(const ::Murmur::AMD_Server_isListening bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_isListening_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_isListening_READ @@ -1699,11 +1795,13 @@ void ::Murmur::ServerI::isListening_async(const ::Murmur::AMD_Server_isListening } #endif // ACCESS_Server_isListening_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_isListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_isListening, cb, QString::fromStdString(current.id.name).toInt(), p1, p2)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getListeningChannels_async(const ::Murmur::AMD_Server_getListeningChannelsPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getListeningChannels_async(const ::Murmur::AMD_Server_getListeningChannelsPtr &cb, + ::Ice::Int p1, const ::Ice::Current ¤t) { // qWarning() << "getListeningChannels" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getListeningChannels_ALL # ifdef ACCESS_Server_getListeningChannels_READ @@ -1714,7 +1812,7 @@ void ::Murmur::ServerI::getListeningChannels_async(const ::Murmur::AMD_Server_ge bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getListeningChannels_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getListeningChannels_READ @@ -1731,11 +1829,13 @@ void ::Murmur::ServerI::getListeningChannels_async(const ::Murmur::AMD_Server_ge } #endif // ACCESS_Server_getListeningChannels_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getListeningChannels, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getListeningChannels, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::getListeningUsers_async(const ::Murmur::AMD_Server_getListeningUsersPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::getListeningUsers_async(const ::Murmur::AMD_Server_getListeningUsersPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getListeningUsers" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_getListeningUsers_ALL # ifdef ACCESS_Server_getListeningUsers_READ @@ -1746,7 +1846,7 @@ void ::Murmur::ServerI::getListeningUsers_async(const ::Murmur::AMD_Server_getLi bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_getListeningUsers_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_getListeningUsers_READ @@ -1763,11 +1863,13 @@ void ::Murmur::ServerI::getListeningUsers_async(const ::Murmur::AMD_Server_getLi } #endif // ACCESS_Server_getListeningUsers_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_getListeningUsers, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_getListeningUsers, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::ServerI::sendWelcomeMessage_async(const ::Murmur::AMD_Server_sendWelcomeMessagePtr &cb, const IdList& p1, const ::Ice::Current ¤t) { +void ::Murmur::ServerI::sendWelcomeMessage_async(const ::Murmur::AMD_Server_sendWelcomeMessagePtr &cb, const IdList &p1, + const ::Ice::Current ¤t) { // qWarning() << "sendWelcomeMessage" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Server_sendWelcomeMessage_ALL # ifdef ACCESS_Server_sendWelcomeMessage_READ @@ -1778,7 +1880,7 @@ void ::Murmur::ServerI::sendWelcomeMessage_async(const ::Murmur::AMD_Server_send bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Server_sendWelcomeMessage_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Server_sendWelcomeMessage_READ @@ -1795,11 +1897,13 @@ void ::Murmur::ServerI::sendWelcomeMessage_async(const ::Murmur::AMD_Server_send } #endif // ACCESS_Server_sendWelcomeMessage_ALL - ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_sendWelcomeMessage, cb, QString::fromStdString(current.id.name).toInt(), p1)); + ExecEvent *ie = new ExecEvent( + boost::bind(&impl_Server_sendWelcomeMessage, cb, QString::fromStdString(current.id.name).toInt(), p1)); QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getServer_async(const ::Murmur::AMD_Meta_getServerPtr &cb, ::Ice::Int p1, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::getServer_async(const ::Murmur::AMD_Meta_getServerPtr &cb, ::Ice::Int p1, + const ::Ice::Current ¤t) { // qWarning() << "getServer" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_getServer_ALL # ifdef ACCESS_Meta_getServer_READ @@ -1810,7 +1914,7 @@ void ::Murmur::MetaI::getServer_async(const ::Murmur::AMD_Meta_getServerPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getServer_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getServer_READ @@ -1842,7 +1946,7 @@ void ::Murmur::MetaI::newServer_async(const ::Murmur::AMD_Meta_newServerPtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_newServer_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_newServer_READ @@ -1863,7 +1967,8 @@ void ::Murmur::MetaI::newServer_async(const ::Murmur::AMD_Meta_newServerPtr &cb, QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getBootedServers_async(const ::Murmur::AMD_Meta_getBootedServersPtr &cb, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::getBootedServers_async(const ::Murmur::AMD_Meta_getBootedServersPtr &cb, + const ::Ice::Current ¤t) { // qWarning() << "getBootedServers" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_getBootedServers_ALL # ifdef ACCESS_Meta_getBootedServers_READ @@ -1874,7 +1979,7 @@ void ::Murmur::MetaI::getBootedServers_async(const ::Murmur::AMD_Meta_getBootedS bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getBootedServers_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getBootedServers_READ @@ -1895,7 +2000,8 @@ void ::Murmur::MetaI::getBootedServers_async(const ::Murmur::AMD_Meta_getBootedS QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getAllServers_async(const ::Murmur::AMD_Meta_getAllServersPtr &cb, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::getAllServers_async(const ::Murmur::AMD_Meta_getAllServersPtr &cb, + const ::Ice::Current ¤t) { // qWarning() << "getAllServers" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_getAllServers_ALL # ifdef ACCESS_Meta_getAllServers_READ @@ -1906,7 +2012,7 @@ void ::Murmur::MetaI::getAllServers_async(const ::Murmur::AMD_Meta_getAllServers bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getAllServers_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getAllServers_READ @@ -1927,7 +2033,8 @@ void ::Murmur::MetaI::getAllServers_async(const ::Murmur::AMD_Meta_getAllServers QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getDefaultConf_async(const ::Murmur::AMD_Meta_getDefaultConfPtr &cb, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::getDefaultConf_async(const ::Murmur::AMD_Meta_getDefaultConfPtr &cb, + const ::Ice::Current ¤t) { // qWarning() << "getDefaultConf" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_getDefaultConf_ALL # ifdef ACCESS_Meta_getDefaultConf_READ @@ -1938,7 +2045,7 @@ void ::Murmur::MetaI::getDefaultConf_async(const ::Murmur::AMD_Meta_getDefaultCo bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getDefaultConf_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getDefaultConf_READ @@ -1970,7 +2077,7 @@ void ::Murmur::MetaI::getVersion_async(const ::Murmur::AMD_Meta_getVersionPtr &c bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getVersion_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getVersion_READ @@ -1991,7 +2098,8 @@ void ::Murmur::MetaI::getVersion_async(const ::Murmur::AMD_Meta_getVersionPtr &c QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::addCallback_async(const ::Murmur::AMD_Meta_addCallbackPtr &cb, const MetaCallbackPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::addCallback_async(const ::Murmur::AMD_Meta_addCallbackPtr &cb, const MetaCallbackPrx &p1, + const ::Ice::Current ¤t) { // qWarning() << "addCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_addCallback_ALL # ifdef ACCESS_Meta_addCallback_READ @@ -2002,7 +2110,7 @@ void ::Murmur::MetaI::addCallback_async(const ::Murmur::AMD_Meta_addCallbackPtr bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_addCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_addCallback_READ @@ -2023,7 +2131,8 @@ void ::Murmur::MetaI::addCallback_async(const ::Murmur::AMD_Meta_addCallbackPtr QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::removeCallback_async(const ::Murmur::AMD_Meta_removeCallbackPtr &cb, const MetaCallbackPrx& p1, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::removeCallback_async(const ::Murmur::AMD_Meta_removeCallbackPtr &cb, const MetaCallbackPrx &p1, + const ::Ice::Current ¤t) { // qWarning() << "removeCallback" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_removeCallback_ALL # ifdef ACCESS_Meta_removeCallback_READ @@ -2034,7 +2143,7 @@ void ::Murmur::MetaI::removeCallback_async(const ::Murmur::AMD_Meta_removeCallba bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_removeCallback_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_removeCallback_READ @@ -2066,7 +2175,7 @@ void ::Murmur::MetaI::getUptime_async(const ::Murmur::AMD_Meta_getUptimePtr &cb, bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getUptime_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getUptime_READ @@ -2087,7 +2196,8 @@ void ::Murmur::MetaI::getUptime_async(const ::Murmur::AMD_Meta_getUptimePtr &cb, QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getSliceChecksums_async(const ::Murmur::AMD_Meta_getSliceChecksumsPtr &cb, const ::Ice::Current ¤t) { +void ::Murmur::MetaI::getSliceChecksums_async(const ::Murmur::AMD_Meta_getSliceChecksumsPtr &cb, + const ::Ice::Current ¤t) { // qWarning() << "getSliceChecksums" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); #ifndef ACCESS_Meta_getSliceChecksums_ALL # ifdef ACCESS_Meta_getSliceChecksums_READ @@ -2098,7 +2208,7 @@ void ::Murmur::MetaI::getSliceChecksums_async(const ::Murmur::AMD_Meta_getSliceC bool ok = !meta->mp.qsIceSecretWrite.isEmpty(); # endif // ACCESS_Meta_getSliceChecksums_READ ::Ice::Context::const_iterator i = current.ctx.find("secret"); - ok = ok && (i != current.ctx.end()); + ok = ok && (i != current.ctx.end()); if (ok) { const QString &secret = u8((*i).second); # ifdef ACCESS_Meta_getSliceChecksums_READ @@ -2119,6 +2229,127 @@ void ::Murmur::MetaI::getSliceChecksums_async(const ::Murmur::AMD_Meta_getSliceC QCoreApplication::instance()->postEvent(mi, ie); } -void ::Murmur::MetaI::getSlice_async(const ::Murmur::AMD_Meta_getSlicePtr &cb, const Ice::Current&) { - cb->ice_response(std::string("\n\n\n\n#include <Ice/SliceChecksumDict.ice>\nmodule Murmur\n{\n\n[\"python:seq:tuple\"] sequence<byte> NetAddress;\n\nstruct User {\nint session;\nint userid;\nbool mute;\nbool deaf;\nbool suppress;\nbool prioritySpeaker;\nbool selfMute;\nbool selfDeaf;\nbool recording;\nint channel;\nstring name;\nint onlinesecs;\nint bytespersec;\nint version;\nstring release;\nstring os;\nstring osversion;\nstring identity;\nstring context;\nstring comment;\nNetAddress address;\nbool tcponly;\nint idlesecs;\nfloat udpPing;\nfloat tcpPing;\n};\nsequence<int> IntList;\n\nstruct TextMessage {\nIntList sessions;\nIntList channels;\nIntList trees;\nstring text;\n};\n\nstruct Channel {\nint id;\nstring name;\nint parent;\nIntList links;\nstring description;\nbool temporary;\nint position;\n};\n\nstruct Group {\nstring name;\nbool inherited;\nbool inherit;\nbool inheritable;\nIntList add;\nIntList remove;\nIntList members;\n};\n\nconst int PermissionWrite = 0x01;\nconst int PermissionTraverse = 0x02;\nconst int PermissionEnter = 0x04;\nconst int PermissionSpeak = 0x08;\nconst int PermissionWhisper = 0x100;\nconst int PermissionMuteDeafen = 0x10;\nconst int PermissionMove = 0x20;\nconst int PermissionMakeChannel = 0x40;\nconst int PermissionMakeTempChannel = 0x400;\nconst int PermissionLinkChannel = 0x80;\nconst int PermissionTextMessage = 0x200;\nconst int PermissionKick = 0x10000;\nconst int PermissionBan = 0x20000;\nconst int PermissionRegister = 0x40000;\nconst int PermissionRegisterSelf = 0x80000;\nconst int ResetUserContent = 0x100000;\n\nstruct ACL {\nbool applyHere;\nbool applySubs;\nbool inherited;\nint userid;\nstring group;\nint allow;\nint deny;\n};\n\nstruct Ban {\nNetAddress address;\nint bits;\nstring name;\nstring hash;\nstring reason;\nint start;\nint duration;\n};\n\nstruct LogEntry {\nint timestamp;\nstring txt;\n};\nclass Tree;\nsequence<Tree> TreeList;\nenum ChannelInfo { ChannelDescription, ChannelPosition };\nenum UserInfo { UserName, UserEmail, UserComment, UserHash, UserPassword, UserLastActive, UserKDFIterations };\ndictionary<int, User> UserMap;\ndictionary<int, Channel> ChannelMap;\nsequence<Channel> ChannelList;\nsequence<User> UserList;\nsequence<Group> GroupList;\nsequence<ACL> ACLList;\nsequence<LogEntry> LogList;\nsequence<Ban> BanList;\nsequence<int> IdList;\nsequence<string> NameList;\ndictionary<int, string> NameMap;\ndictionary<string, int> IdMap;\nsequence<byte> Texture;\ndictionary<string, string> ConfigMap;\nsequence<string> GroupNameList;\nsequence<byte> CertificateDer;\nsequence<CertificateDer> CertificateList;\n\ndictionary<UserInfo, string> UserInfoMap;\n\nclass Tree {\nChannel c;\nTreeList children;\nUserList users;\n};\nexception MurmurException {};\nexception InvalidSessionException extends MurmurException {};\nexception InvalidChannelException extends MurmurException {};\nexception InvalidServerException extends MurmurException {};\nexception ServerBootedException extends MurmurException {};\nexception ServerFailureException extends MurmurException {};\nexception InvalidUserException extends MurmurException {};\nexception InvalidTextureException extends MurmurException {};\nexception InvalidCallbackException extends MurmurException {};\nexception InvalidSecretException extends MurmurException {};\nexception NestingLimitException extends MurmurException {};\nexception WriteOnlyException extends MurmurException {};\nexception InvalidInputDataException extends MurmurException {};\n\ninterface ServerCallback {\nidempotent void userConnected(User state);\nidempotent void userDisconnected(User state);\nidempotent void userStateChanged(User state);\nidempotent void userTextMessage(User state, TextMessage message);\nidempotent void channelCreated(Channel state);\nidempotent void channelRemoved(Channel state);\nidempotent void channelStateChanged(Channel state);\n};\n\nconst int ContextServer = 0x01;\nconst int ContextChannel = 0x02;\nconst int ContextUser = 0x04;\n\ninterface ServerContextCallback {\nidempotent void contextAction(string action, User usr, int session, int channelid);\n};\n\ninterface ServerAuthenticator {\nidempotent int authenticate(string name, string pw, CertificateList certificates, string certhash, bool certstrong, out string newname, out GroupNameList groups);\n\nidempotent bool getInfo(int id, out UserInfoMap info);\n\nidempotent int nameToId(string name);\n\nidempotent string idToName(int id);\n\nidempotent Texture idToTexture(int id);\n};\n\ninterface ServerUpdatingAuthenticator extends ServerAuthenticator {\nint registerUser(UserInfoMap info);\n\nint unregisterUser(int id);\n\nidempotent NameMap getRegisteredUsers(string filter);\n\nidempotent int setInfo(int id, UserInfoMap info);\n\nidempotent int setTexture(int id, Texture tex);\n};\n\n[\"amd\"] interface Server {\nidempotent bool isRunning() throws InvalidSecretException;\n\nvoid start() throws ServerBootedException, ServerFailureException, InvalidSecretException;\n\nvoid stop() throws ServerBootedException, InvalidSecretException;\n\nvoid delete() throws ServerBootedException, InvalidSecretException;\n\nidempotent int id() throws InvalidSecretException;\n\nvoid addCallback(ServerCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nvoid removeCallback(ServerCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nvoid setAuthenticator(ServerAuthenticator *auth) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nidempotent string getConf(string key) throws InvalidSecretException, WriteOnlyException;\n\nidempotent ConfigMap getAllConf() throws InvalidSecretException;\n\nidempotent void setConf(string key, string value) throws InvalidSecretException;\n\nidempotent void setSuperuserPassword(string pw) throws InvalidSecretException;\n\nidempotent LogList getLog(int first, int last) throws InvalidSecretException;\n\nidempotent int getLogLen() throws InvalidSecretException;\n\nidempotent UserMap getUsers() throws ServerBootedException, InvalidSecretException;\n\nidempotent ChannelMap getChannels() throws ServerBootedException, InvalidSecretException;\n\nidempotent CertificateList getCertificateList(int session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent Tree getTree() throws ServerBootedException, InvalidSecretException;\n\nidempotent BanList getBans() throws ServerBootedException, InvalidSecretException;\n\nidempotent void setBans(BanList bans) throws ServerBootedException, InvalidSecretException;\n\nvoid kickUser(int session, string reason) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent User getState(int session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent void setState(User state) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;\n\nvoid sendMessage(int session, string text) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nbool hasPermission(int session, int channelid, int perm) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;\n\nidempotent int effectivePermissions(int session, int channelid) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;\n\nvoid addContextCallback(int session, string action, string text, ServerContextCallback *cb, int ctx) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nvoid removeContextCallback(ServerContextCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nidempotent Channel getChannelState(int channelid) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nidempotent void setChannelState(Channel state) throws ServerBootedException, InvalidChannelException, InvalidSecretException, NestingLimitException;\n\nvoid removeChannel(int channelid) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nint addChannel(string name, int parent) throws ServerBootedException, InvalidChannelException, InvalidSecretException, NestingLimitException;\n\nvoid sendMessageChannel(int channelid, bool tree, string text) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nidempotent void getACL(int channelid, out ACLList acls, out GroupList groups, out bool inherit) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nidempotent void setACL(int channelid, ACLList acls, GroupList groups, bool inherit) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nidempotent void addUserToGroup(int channelid, int session, string group) throws ServerBootedException, InvalidChannelException, InvalidSessionException, InvalidSecretException;\n\nidempotent void removeUserFromGroup(int channelid, int session, string group) throws ServerBootedException, InvalidChannelException, InvalidSessionException, InvalidSecretException;\n\nidempotent void redirectWhisperGroup(int session, string source, string target) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent NameMap getUserNames(IdList ids) throws ServerBootedException, InvalidSecretException;\n\nidempotent IdMap getUserIds(NameList names) throws ServerBootedException, InvalidSecretException;\n\nint registerUser(UserInfoMap info) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nvoid unregisterUser(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent void updateRegistration(int userid, UserInfoMap info) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent UserInfoMap getRegistration(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent NameMap getRegisteredUsers(string filter) throws ServerBootedException, InvalidSecretException;\n\nidempotent int verifyPassword(string name, string pw) throws ServerBootedException, InvalidSecretException;\n\nidempotent Texture getTexture(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent void setTexture(int userid, Texture tex) throws ServerBootedException, InvalidUserException, InvalidTextureException, InvalidSecretException;\n\nidempotent int getUptime() throws ServerBootedException, InvalidSecretException;\n\n idempotent void updateCertificate(string certificate, string privateKey, string passphrase) throws ServerBootedException, InvalidSecretException, InvalidInputDataException;\n \n idempotent void startListening(int userid, int channelid);\n \n idempotent void stopListening(int userid, int channelid);\n \n idempotent bool isListening(int userid, int channelid);\n \n idempotent IntList getListeningChannels(int userid);\n \n idempotent IntList getListeningUsers(int channelid);\n \n idempotent void sendWelcomeMessage(IdList receiverUserIDs);\n};\n\ninterface MetaCallback {\nvoid started(Server *srv);\n\nvoid stopped(Server *srv);\n};\nsequence<Server *> ServerList;\n\n[\"amd\"] interface Meta {\nidempotent Server *getServer(int id) throws InvalidSecretException;\n\nServer *newServer() throws InvalidSecretException;\n\nidempotent ServerList getBootedServers() throws InvalidSecretException;\n\nidempotent ServerList getAllServers() throws InvalidSecretException;\n\nidempotent ConfigMap getDefaultConf() throws InvalidSecretException;\n\nidempotent void getVersion(out int major, out int minor, out int patch, out string text);\n\nvoid addCallback(MetaCallback *cb) throws InvalidCallbackException, InvalidSecretException;\n\nvoid removeCallback(MetaCallback *cb) throws InvalidCallbackException, InvalidSecretException;\n\nidempotent int getUptime();\n\nidempotent string getSlice();\n\nidempotent Ice::SliceChecksumDict getSliceChecksums();\n};\n};\n")); +void ::Murmur::MetaI::getSlice_async(const ::Murmur::AMD_Meta_getSlicePtr &cb, const Ice::Current &) { + cb->ice_response(std::string( + "\n\n\n\n#include <Ice/SliceChecksumDict.ice>\nmodule Murmur\n{\n\n[\"python:seq:tuple\"] sequence<byte> " + "NetAddress;\n\nstruct User {\nint session;\nint userid;\nbool mute;\nbool deaf;\nbool suppress;\nbool " + "prioritySpeaker;\nbool selfMute;\nbool selfDeaf;\nbool recording;\nint channel;\nstring name;\nint " + "onlinesecs;\nint bytespersec;\nint version;\nstring release;\nstring os;\nstring osversion;\nstring " + "identity;\nstring context;\nstring comment;\nNetAddress address;\nbool tcponly;\nint idlesecs;\nfloat " + "udpPing;\nfloat tcpPing;\n};\nsequence<int> IntList;\n\nstruct TextMessage {\nIntList sessions;\nIntList " + "channels;\nIntList trees;\nstring text;\n};\n\nstruct Channel {\nint id;\nstring name;\nint parent;\nIntList " + "links;\nstring description;\nbool temporary;\nint position;\n};\n\nstruct Group {\nstring name;\nbool " + "inherited;\nbool inherit;\nbool inheritable;\nIntList add;\nIntList remove;\nIntList members;\n};\n\nconst " + "int PermissionWrite = 0x01;\nconst int PermissionTraverse = 0x02;\nconst int PermissionEnter = 0x04;\nconst " + "int PermissionSpeak = 0x08;\nconst int PermissionWhisper = 0x100;\nconst int PermissionMuteDeafen = " + "0x10;\nconst int PermissionMove = 0x20;\nconst int PermissionMakeChannel = 0x40;\nconst int " + "PermissionMakeTempChannel = 0x400;\nconst int PermissionLinkChannel = 0x80;\nconst int PermissionTextMessage " + "= 0x200;\nconst int PermissionKick = 0x10000;\nconst int PermissionBan = 0x20000;\nconst int " + "PermissionRegister = 0x40000;\nconst int PermissionRegisterSelf = 0x80000;\nconst int ResetUserContent = " + "0x100000;\n\nstruct ACL {\nbool applyHere;\nbool applySubs;\nbool inherited;\nint userid;\nstring group;\nint " + "allow;\nint deny;\n};\n\nstruct Ban {\nNetAddress address;\nint bits;\nstring name;\nstring hash;\nstring " + "reason;\nint start;\nint duration;\n};\n\nstruct LogEntry {\nint timestamp;\nstring txt;\n};\nclass " + "Tree;\nsequence<Tree> TreeList;\nenum ChannelInfo { ChannelDescription, ChannelPosition };\nenum UserInfo { " + "UserName, UserEmail, UserComment, UserHash, UserPassword, UserLastActive, UserKDFIterations " + "};\ndictionary<int, User> UserMap;\ndictionary<int, Channel> ChannelMap;\nsequence<Channel> " + "ChannelList;\nsequence<User> UserList;\nsequence<Group> GroupList;\nsequence<ACL> " + "ACLList;\nsequence<LogEntry> LogList;\nsequence<Ban> BanList;\nsequence<int> IdList;\nsequence<string> " + "NameList;\ndictionary<int, string> NameMap;\ndictionary<string, int> IdMap;\nsequence<byte> " + "Texture;\ndictionary<string, string> ConfigMap;\nsequence<string> GroupNameList;\nsequence<byte> " + "CertificateDer;\nsequence<CertificateDer> CertificateList;\n\ndictionary<UserInfo, string> " + "UserInfoMap;\n\nclass Tree {\nChannel c;\nTreeList children;\nUserList users;\n};\nexception MurmurException " + "{};\nexception InvalidSessionException extends MurmurException {};\nexception InvalidChannelException extends " + "MurmurException {};\nexception InvalidServerException extends MurmurException {};\nexception " + "ServerBootedException extends MurmurException {};\nexception ServerFailureException extends MurmurException " + "{};\nexception InvalidUserException extends MurmurException {};\nexception InvalidTextureException extends " + "MurmurException {};\nexception InvalidCallbackException extends MurmurException {};\nexception " + "InvalidSecretException extends MurmurException {};\nexception NestingLimitException extends MurmurException " + "{};\nexception WriteOnlyException extends MurmurException {};\nexception InvalidInputDataException extends " + "MurmurException {};\n\ninterface ServerCallback {\nidempotent void userConnected(User state);\nidempotent " + "void userDisconnected(User state);\nidempotent void userStateChanged(User state);\nidempotent void " + "userTextMessage(User state, TextMessage message);\nidempotent void channelCreated(Channel state);\nidempotent " + "void channelRemoved(Channel state);\nidempotent void channelStateChanged(Channel state);\n};\n\nconst int " + "ContextServer = 0x01;\nconst int ContextChannel = 0x02;\nconst int ContextUser = 0x04;\n\ninterface " + "ServerContextCallback {\nidempotent void contextAction(string action, User usr, int session, int " + "channelid);\n};\n\ninterface ServerAuthenticator {\nidempotent int authenticate(string name, string pw, " + "CertificateList certificates, string certhash, bool certstrong, out string newname, out GroupNameList " + "groups);\n\nidempotent bool getInfo(int id, out UserInfoMap info);\n\nidempotent int nameToId(string " + "name);\n\nidempotent string idToName(int id);\n\nidempotent Texture idToTexture(int id);\n};\n\ninterface " + "ServerUpdatingAuthenticator extends ServerAuthenticator {\nint registerUser(UserInfoMap info);\n\nint " + "unregisterUser(int id);\n\nidempotent NameMap getRegisteredUsers(string filter);\n\nidempotent int " + "setInfo(int id, UserInfoMap info);\n\nidempotent int setTexture(int id, Texture tex);\n};\n\n[\"amd\"] " + "interface Server {\nidempotent bool isRunning() throws InvalidSecretException;\n\nvoid start() throws " + "ServerBootedException, ServerFailureException, InvalidSecretException;\n\nvoid stop() throws " + "ServerBootedException, InvalidSecretException;\n\nvoid delete() throws ServerBootedException, " + "InvalidSecretException;\n\nidempotent int id() throws InvalidSecretException;\n\nvoid " + "addCallback(ServerCallback *cb) throws ServerBootedException, InvalidCallbackException, " + "InvalidSecretException;\n\nvoid removeCallback(ServerCallback *cb) throws ServerBootedException, " + "InvalidCallbackException, InvalidSecretException;\n\nvoid setAuthenticator(ServerAuthenticator *auth) throws " + "ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nidempotent string getConf(string " + "key) throws InvalidSecretException, WriteOnlyException;\n\nidempotent ConfigMap getAllConf() throws " + "InvalidSecretException;\n\nidempotent void setConf(string key, string value) throws " + "InvalidSecretException;\n\nidempotent void setSuperuserPassword(string pw) throws " + "InvalidSecretException;\n\nidempotent LogList getLog(int first, int last) throws " + "InvalidSecretException;\n\nidempotent int getLogLen() throws InvalidSecretException;\n\nidempotent UserMap " + "getUsers() throws ServerBootedException, InvalidSecretException;\n\nidempotent ChannelMap getChannels() " + "throws ServerBootedException, InvalidSecretException;\n\nidempotent CertificateList getCertificateList(int " + "session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent Tree " + "getTree() throws ServerBootedException, InvalidSecretException;\n\nidempotent BanList getBans() throws " + "ServerBootedException, InvalidSecretException;\n\nidempotent void setBans(BanList bans) throws " + "ServerBootedException, InvalidSecretException;\n\nvoid kickUser(int session, string reason) throws " + "ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent User getState(int " + "session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent void " + "setState(User state) throws ServerBootedException, InvalidSessionException, InvalidChannelException, " + "InvalidSecretException;\n\nvoid sendMessage(int session, string text) throws ServerBootedException, " + "InvalidSessionException, InvalidSecretException;\n\nbool hasPermission(int session, int channelid, int perm) " + "throws ServerBootedException, InvalidSessionException, InvalidChannelException, " + "InvalidSecretException;\n\nidempotent int effectivePermissions(int session, int channelid) throws " + "ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;\n\nvoid " + "addContextCallback(int session, string action, string text, ServerContextCallback *cb, int ctx) throws " + "ServerBootedException, InvalidCallbackException, InvalidSecretException;\n\nvoid " + "removeContextCallback(ServerContextCallback *cb) throws ServerBootedException, InvalidCallbackException, " + "InvalidSecretException;\n\nidempotent Channel getChannelState(int channelid) throws ServerBootedException, " + "InvalidChannelException, InvalidSecretException;\n\nidempotent void setChannelState(Channel state) throws " + "ServerBootedException, InvalidChannelException, InvalidSecretException, NestingLimitException;\n\nvoid " + "removeChannel(int channelid) throws ServerBootedException, InvalidChannelException, " + "InvalidSecretException;\n\nint addChannel(string name, int parent) throws ServerBootedException, " + "InvalidChannelException, InvalidSecretException, NestingLimitException;\n\nvoid sendMessageChannel(int " + "channelid, bool tree, string text) throws ServerBootedException, InvalidChannelException, " + "InvalidSecretException;\n\nidempotent void getACL(int channelid, out ACLList acls, out GroupList groups, out " + "bool inherit) throws ServerBootedException, InvalidChannelException, InvalidSecretException;\n\nidempotent " + "void setACL(int channelid, ACLList acls, GroupList groups, bool inherit) throws ServerBootedException, " + "InvalidChannelException, InvalidSecretException;\n\nidempotent void addUserToGroup(int channelid, int " + "session, string group) throws ServerBootedException, InvalidChannelException, InvalidSessionException, " + "InvalidSecretException;\n\nidempotent void removeUserFromGroup(int channelid, int session, string group) " + "throws ServerBootedException, InvalidChannelException, InvalidSessionException, " + "InvalidSecretException;\n\nidempotent void redirectWhisperGroup(int session, string source, string target) " + "throws ServerBootedException, InvalidSessionException, InvalidSecretException;\n\nidempotent NameMap " + "getUserNames(IdList ids) throws ServerBootedException, InvalidSecretException;\n\nidempotent IdMap " + "getUserIds(NameList names) throws ServerBootedException, InvalidSecretException;\n\nint " + "registerUser(UserInfoMap info) throws ServerBootedException, InvalidUserException, " + "InvalidSecretException;\n\nvoid unregisterUser(int userid) throws ServerBootedException, " + "InvalidUserException, InvalidSecretException;\n\nidempotent void updateRegistration(int userid, UserInfoMap " + "info) throws ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent UserInfoMap " + "getRegistration(int userid) throws ServerBootedException, InvalidUserException, " + "InvalidSecretException;\n\nidempotent NameMap getRegisteredUsers(string filter) throws ServerBootedException, " + "InvalidSecretException;\n\nidempotent int verifyPassword(string name, string pw) throws " + "ServerBootedException, InvalidSecretException;\n\nidempotent Texture getTexture(int userid) throws " + "ServerBootedException, InvalidUserException, InvalidSecretException;\n\nidempotent void setTexture(int " + "userid, Texture tex) throws ServerBootedException, InvalidUserException, InvalidTextureException, " + "InvalidSecretException;\n\nidempotent int getUptime() throws ServerBootedException, " + "InvalidSecretException;\n\n idempotent void updateCertificate(string certificate, string privateKey, string " + "passphrase) throws ServerBootedException, InvalidSecretException, InvalidInputDataException;\n \n idempotent " + "void startListening(int userid, int channelid);\n \n idempotent void stopListening(int userid, int " + "channelid);\n \n idempotent bool isListening(int userid, int channelid);\n \n idempotent IntList " + "getListeningChannels(int userid);\n \n idempotent IntList getListeningUsers(int channelid);\n \n idempotent " + "void sendWelcomeMessage(IdList receiverUserIDs);\n};\n\ninterface MetaCallback {\nvoid started(Server " + "*srv);\n\nvoid stopped(Server *srv);\n};\nsequence<Server *> ServerList;\n\n[\"amd\"] interface Meta " + "{\nidempotent Server *getServer(int id) throws InvalidSecretException;\n\nServer *newServer() throws " + "InvalidSecretException;\n\nidempotent ServerList getBootedServers() throws " + "InvalidSecretException;\n\nidempotent ServerList getAllServers() throws InvalidSecretException;\n\nidempotent " + "ConfigMap getDefaultConf() throws InvalidSecretException;\n\nidempotent void getVersion(out int major, out " + "int minor, out int patch, out string text);\n\nvoid addCallback(MetaCallback *cb) throws " + "InvalidCallbackException, InvalidSecretException;\n\nvoid removeCallback(MetaCallback *cb) throws " + "InvalidCallbackException, InvalidSecretException;\n\nidempotent int getUptime();\n\nidempotent string " + "getSlice();\n\nidempotent Ice::SliceChecksumDict getSliceChecksums();\n};\n};\n")); } diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index c0c979814..5d8a789e0 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -1280,8 +1280,8 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { ServerUser *pDst = static_cast< ServerUser * >(qhUsers.value(currentSession)); if (pDst && (!group || Group::isMember(tc, tc, qsg, pDst))) { - // Only send audio to listener if the user exists and it is in the group the speech is directed - // at (if any) + // Only send audio to listener if the user exists and it is in the group the + // speech is directed at (if any) listener << pDst; } } diff --git a/src/murmur/ServerUser.cpp b/src/murmur/ServerUser.cpp index 367889bee..7e0a61ccc 100644 --- a/src/murmur/ServerUser.cpp +++ b/src/murmur/ServerUser.cpp @@ -13,8 +13,8 @@ #endif ServerUser::ServerUser(Server *p, QSslSocket *socket) - : Connection(p, socket), User(), s(nullptr), - leakyBucket(p->iMessageLimit, p->iMessageBurst), m_pluginMessageBucket(5, 20) { + : Connection(p, socket), User(), s(nullptr), leakyBucket(p->iMessageLimit, p->iMessageBurst), + m_pluginMessageBucket(5, 20) { sState = ServerUser::Connected; sUdpSocket = INVALID_SOCKET; diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index 472539789..7afc01d68 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -343,7 +343,8 @@ void UnixMurmur::finalcap() { qCritical("Failed to get priority limits."); } else { using ulong_t = unsigned long long int; - static_assert(std::numeric_limits< ulong_t >::max() >= std::numeric_limits< rlim_t >::max(), "rlim_t is unexpectedly large"); + static_assert(std::numeric_limits< ulong_t >::max() >= std::numeric_limits< rlim_t >::max(), + "rlim_t is unexpectedly large"); ulong_t current = r.rlim_cur; ulong_t max = r.rlim_max; qWarning("Resource limits were %llu %llu", current, max); diff --git a/src/tests/TestCrypt/TestCrypt.cpp b/src/tests/TestCrypt/TestCrypt.cpp index 2361da968..16b01240e 100644 --- a/src/tests/TestCrypt/TestCrypt.cpp +++ b/src/tests/TestCrypt/TestCrypt.cpp @@ -265,8 +265,8 @@ void TestCrypt::xexstarAttack() { } // Actual content should have been changed such that the critical block is no longer all 0. - QCOMPARE(src[0], static_cast<unsigned char>(0)); - QCOMPARE(decrypted[0], static_cast<unsigned char>(1)); + QCOMPARE(src[0], static_cast< unsigned char >(0)); + QCOMPARE(decrypted[0], static_cast< unsigned char >(1)); } void TestCrypt::tamper() { diff --git a/src/tests/TestXMLTools/TestXMLTools.cpp b/src/tests/TestXMLTools/TestXMLTools.cpp index de4e8b588..1524d7d30 100644 --- a/src/tests/TestXMLTools/TestXMLTools.cpp +++ b/src/tests/TestXMLTools/TestXMLTools.cpp @@ -107,13 +107,13 @@ void TestXMLTools::testParseConvertStyleBold() { QLatin1String("<b>one</b>")); // These currently fail // QCOMPARE(doParse(QLatin1String("<html><head></head><body><span - //style=\"font-weight:700;\">one</span></body></html>")), QLatin1String("<b>one</b>")); + // style=\"font-weight:700;\">one</span></body></html>")), QLatin1String("<b>one</b>")); // QCOMPARE(doParse(QLatin1String("<html><head></head><body><span - //style=\"font-weight:800;\">one</span></body></html>")), QLatin1String("<b>one</b>")); + // style=\"font-weight:800;\">one</span></body></html>")), QLatin1String("<b>one</b>")); // QCOMPARE(doParse(QLatin1String("<html><head></head><body><span - //style=\"font-weight:900;\">one</span></body></html>")), QLatin1String("<b>one</b>")); + // style=\"font-weight:900;\">one</span></body></html>")), QLatin1String("<b>one</b>")); // QCOMPARE(doParse(QLatin1String("<html><head></head><body><span - //style=\"font-weight:bold;\">one</span></body></html>")), QLatin1String("<b>one</b>")); + // style=\"font-weight:bold;\">one</span></body></html>")), QLatin1String("<b>one</b>")); } void TestXMLTools::testParseConvertStyleUnderline() { @@ -150,7 +150,7 @@ void TestXMLTools::testParseDropEmptyFirstParagraphs() { QLatin1String("<div>one</div>")); // <br> would be invalid XML. It is not dropped "correctly". // QCOMPARE(doParse(QLatin1String("<html><head></head><body><p><br></p><p>one</p></body></html>")), - //QLatin1String("<p>one</p>")); + // QLatin1String("<p>one</p>")); // This is different from what is expected from a comment in the method being tested. It says // contents of empty paragraph would be dropped as well, but the br/space persists. QCOMPARE(doParse(QLatin1String("<html><head></head><body><p><br/></p><p>one</p></body></html>")), @@ -275,7 +275,7 @@ void TestXMLTools::testUndupStandard() { // Will warn and fail. // void TestXMLTools::testUndupInvalidXml1() { // QCOMPARE(doUnduplicate(QLatin1String("<unduplicate><b>bold with <i></b>italic</i></unduplicate>")), -//QLatin1String("<b>bold with <i>italic</i></b>")); +// QLatin1String("<b>bold with <i>italic</i></b>")); //} QTEST_MAIN(TestXMLTools) |