Skip to content

Commit

Permalink
REFAC(plugins): Unified Mumble plugin headers
Browse files Browse the repository at this point in the history
Having different include files that are needed (and which are
inter-dependent) to create your own plugin, makes things harder than it
needs to be.

Therefore, all plugin header files (those for the "new" (1.4) plugin
framework anyway) have been combined into one header file. Thus,
developers now only have to download a single file and include that
instead of having to figure out what files to download and what to
include where.

Taking the chance, the version number has been removed from the header
file's name. This allows one to track changes made to the API via git
(which is not quite as easy if you create a new file every time you make
a change).
  • Loading branch information
Krzmbrzl committed Jul 9, 2023
1 parent e828ef0 commit d77912e
Show file tree
Hide file tree
Showing 19 changed files with 2,013 additions and 2,531 deletions.
16 changes: 5 additions & 11 deletions docs/dev/plugins/CreatePlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ also intended to be used as the basis for everyone that wants to start writing a

What you need for creating a plugin is
- A working C compiler. It does not matter which one
- The Mumble plugin framework header files which are the following (the exact version number in the filename may change depending on which API version
you intend to use):
* [MumbleAPI_v_1_0_x.h](https://github.com/mumble-voip/mumble/blob/master/plugins/MumbleAPI_v_1_0_x.h)
* [MumblePlugin_v_1_0_x.h](https://github.com/mumble-voip/mumble/blob/master/plugins/MumblePlugin_v_1_0_x.h)
* [PluginComponents_v_1_0_x.h](https://github.com/mumble-voip/mumble/blob/master/plugins/PluginComponents_v_1_0_x.h)
- The Mumble plugin header file: [MumblePlugin.h](https://github.com/mumble-voip/mumble/blob/master/plugins/MumblePlugin.h)

Although not strictly required, it usually is handy to use a build system for managing your plugin project. In this guide we'll use
[cmake](https://cmake.org/). If you have never used cmake before, have a look at [this short guide](https://stackoverflow.com/a/26007567).
Expand All @@ -28,9 +24,7 @@ All in all the following file structure is assumed to be present on your device:
```
.
├── include
│   ├── MumbleAPI_v_1_0_x.h
│   ├── MumblePlugin_v_1_0_x.h
│   └── PluginComponents_v_1_0_x.h
│   └── MumblePlugin.h
├── CMakeLists.txt
└── plugin.c
```
Expand Down Expand Up @@ -70,9 +64,9 @@ to build a shared library from the source file `plugin.c` and that everything in

Now that the boilerplate is out of the way, we can start writing the actual plugin. This will be done in the `plugin.c` source file.

The first thing you should do is to include `MumblePlugin_v_1_0_x.h`. Furthermore we'll need a few more C headers that we'll include as well:
The first thing you should do is to include `MumblePlugin.h`. Furthermore we'll need a few more C headers that we'll include as well:
```c
#include "MumblePlugin_v_1_0_x.h"
#include "MumblePlugin.h"

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -82,7 +76,7 @@ The first thing you should do is to include `MumblePlugin_v_1_0_x.h`. Furthermor
Furthermore every plugin needs a way to store at least the Mumble-API and its own ID. In C this can be done using global variables. Therefore go ahead
and create the respective variables in the global namespace:
```c
struct MumbleAPI_v_1_0_x mumbleAPI;
MumbleAPI mumbleAPI;
mumble_plugin_id_t ownID;
```

Expand Down
4 changes: 2 additions & 2 deletions docs/dev/plugins/MumbleAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ That is to say: You must not wait for a job to finish asynchronously that might

## Header files

The following header files describe the Mumble-API struct that contains the function pointers as well as descriptions of the respective functions:
- [Mumble-API v1.0.x](https://github.com/mumble-voip/mumble/blob/master/plugins/MumbleAPI_v_1_0_x.h)
The Mumble API definition is contained in the [MumblePlugin.h](https://github.com/mumble-voip/mumble/blob/master/plugins/MumblePlugin.h) header. It
contains a list of all available functions as well as documentation for every function.

4 changes: 2 additions & 2 deletions docs/dev/plugins/PluginAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ Unless otherwise noted in the function's description, all functions are called f

## Header files

The following header files describe the plugin-API interface. They also contain a description of what each function is for.
- [Plugin-API v1.0.x](https://github.com/mumble-voip/mumble/blob/master/plugins/MumblePlugin_v_1_0_x.h)
The plugin function definitions are contained in the [MumblePlugin.h](https://github.com/mumble-voip/mumble/blob/master/plugins/MumblePlugin.h) header. It
contains a list of all available functions as well as documentation for every function.

537 changes: 0 additions & 537 deletions plugins/MumbleAPI_v_1_0_x.h

This file was deleted.

539 changes: 0 additions & 539 deletions plugins/MumbleAPI_v_1_2_x.h

This file was deleted.

Loading

0 comments on commit d77912e

Please sign in to comment.