As part of my GSoC this summer, I was making a DBus api for coala. Recently, we completed the basic api which is fairly usable 🙂
The coala DBus API essentially creates a server which can have multiple clients connected to it. The clients communicate to the coala server using DBus. To start the server, first install coala and then simple run
This spawns a bus with the name
org.coala.v1 as a SessionBus and can be verified and tested using a DBus debugger like DFeet. The bus has 1 object-path by default –
/org/coala/v1. This is the first point of contact with coala for any client.
/org/coala/v1 has the interface
org.coala.v1 which contains the two methods –
DisposeDocument. These are used to tell coala about the documents you wish to analyze.
CreateDocument method has 1 string argument – the path of the document. A document is defined by it’s path. The path should be a absolute path, not a relative one. This method returns an object-path which will be hence forth used to interact with that document. The
DisposeDocument method also has 1 string argument, and disposes the object-path corresponding to that path.
Now, the object-path returned by the
CreateDocument method also has the interface
org.coala.v1. This interface is used to handle which config file coala will use to analyze the document, and the function to get analysis results. It contains 4 functions:
GetConfigFile– Args: none. Returns: the config file path
SetConfigFile– Args: the config file path. Returns: the config path which is set after it executes.
FindConfigFile– Args: the config file path. Returns: the config path which is set after it executes.It attempts to find the config file related to the file by searching in parent directories till it finds a `.coafile`.
Analyze– Args: none. Returns: an array of DBus structures.
The structure contains:
- The name of the section
- Boolean which is true if all bears in the section executed successfully
- List of results where each result is a list which contains:(str)origin, (str)message, (str)file, (str)line_nr, (str)severity
Although this is a useful and simple API – there are some small issues with it which still need to incorporated. First off the error reporting isn’t up to par, there is no method of logging messages like warnings and information currently. Also, the settings can currently only be changed by using a coafile – and the DBus api itself cannot change it. We’ll be working on this and improving it soon 🙂