|
5 years ago | |
---|---|---|
html | 5 years ago | |
libevent-2.0.22-stable | 6 years ago | |
server | 5 years ago | |
.hgignore | 5 years ago | |
COPYING | 5 years ago | |
README-OSX.md | 5 years ago | |
README.md | 5 years ago |
The p≡p JSON Server Adapter provides a REST-like jQuery-compatible API to connect with the p≡p engine. It is language-independent and can be used by any client.
In order to use the p≡p JSON Server Adapter, you need to build and run it. Currently, Linux and OSX/macOS are supported, Windows is about to follow.
The p≡p JSON Server Adapter can be build on Debian and Ubuntu. Other flavors may work, but are not officially supported.
cd server
make
The p≡p JSON Server Adapter can be build on OS X or macOS with MacPorts.
For compiling the p≡p JSON Server Adapter and its dependencies, make sure you have the LANG variable set.
export LANG=en_US.UTF-8
The following dependencies need to be installed in order to be able to build the p≡p JSON Server Adapter.
Install MacPorts for your version of OS X/macOS.
If MacPorts is already installed on your machine, but was installed by a different user, make sure your PATH
variable is set as follows in ~/.profile
:
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
Install dependencies packaged with MacPorts as follows.
sudo port install openssl boost ossp-uuid
Install libevent.
cd libevent-2.0.22-stable
export LDFLAGS=-L/opt/local
export CFLAGS=-I/opt/local/include
./configure --prefix "$HOME"
make
make install
cd server
make
Run ./pep-json-server. This creates a file that is readable only by the current user (/tmp/pEp-json-token-${USER}) and contains the address and port the JSON adapter is listening on, normally 127.0.0.1:4223 and a "security-token" that must be given in each function call to authenticate you as the valid user.
./pep-json-server
Visit that address (normally http://127.0.0.1:4223/) in your javascript-enabled web browser to see the test JavaScript client.
Call any function ("version()" or "get_gpg_path()" should work just fine) with the correct security token.
In the following section, you'll find background information on how to use the adapter and its functions.
All C data types are mapped the same way, so some day the JSON wrapper can be generated from the p≡p Engine header files (or the JSON wrapper and the p≡p engine header are both generated from a common interface description file)
C type | JSON mapping |
---|---|
bool |
JSON boolean |
int |
JSON decimal number |
char* (representing a UTF-8-encoded NULL-terminated string |
JSON string |
char* (representing a binary string |
base64-encoded JSON string |
enum |
string with the enumerator constant (e.g. PEP_KEY_NOT_FOUND ) |
struct |
JSON object |
linked lists (e.g. bloblist_t , stringlist_t , identity_list etc.) |
JSON array of their member data type (without the next pointer) |
An complete overview with all functions that are callable from the client can be found in the [API Reference](pEp JSON Server Adapter/API Reference).
If you want to extend or customize the p≡p JSON Adapter, there are several rules and defitions to take into account.
The 'FunctionMap function' in mt-server.cc defines which functions are callable via the JSON-RPC interface. The existing entries show the syntax of that map.
The current implementation supports input and output parameters, no "inout".
For each type there must exist specializations of the template classes "In" (for input parameters) and "Out" (for output parameters). The linker will tell you, which specializations are needed.
The specializations for "generic types" are in function_map.cc
The specializations for "p≡p-specific types" are in pep-types.cc
The following issues are planned but not yet implemented.
Windows build:
Add unit tests
Fix the bugs that are found by the Unit tests, if any.
Generate all the tedious boiler plate code
Adapt the "p≡p Transport API", when it is final. (either manually or by code generator, if ready)