Skip to content

Commit 49b7054

Browse files
committed
Update documentation
Signed-off-by: Alexey Gladkov <legion@kernel.org>
1 parent 714002e commit 49b7054

3 files changed

Lines changed: 149 additions & 0 deletions

File tree

Documentation/ipc-protocol.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# plainmouth IPC Protocol
2+
3+
This document describes the low-level request/response protocol used between
4+
`plainmouth` (client) and `plainmouthd` (server).
5+
6+
## 1. Transport
7+
8+
- Unix domain socket: `AF_UNIX`, `SOCK_STREAM`.
9+
- Messages are sent as NUL-terminated frames (C strings).
10+
- One socket connection can carry multiple request/response exchanges.
11+
12+
## 2. Message Flow
13+
14+
Each client request follows this sequence:
15+
16+
1. `HELLO`
17+
2. Server replies: `TAKE <id>`
18+
3. Client sends one or more: `PAIR <id> <key>=<value>`
19+
4. Client sends: `DONE <id>`
20+
5. Server sends zero or more: `RESPDATA <id> <key>=<value>`
21+
6. Server finalizes: `RESPONSE <id> OK` or `RESPONSE <id> ERROR [message]`
22+
23+
## 3. Wire Commands
24+
25+
### Client to Server
26+
27+
- `HELLO`
28+
- `PAIR <id> <key>=<value>`
29+
- `DONE <id>`
30+
31+
### Server to Client
32+
33+
- `TAKE <id>`
34+
- `RESPDATA <id> <key>=<value>`
35+
- `RESPONSE <id> OK`
36+
- `RESPONSE <id> ERROR`
37+
38+
## 4. Grammar (informal)
39+
40+
```text
41+
HELLO
42+
TAKE <id>
43+
PAIR <id> <key>=<value>
44+
DONE <id>
45+
RESPDATA <id> <key>=<value>
46+
RESPONSE <id> <status> [message]
47+
```
48+
49+
Notes:
50+
- `<id>` is an opaque token allocated by the peer handling `HELLO`.
51+
- `PAIR` and `RESPDATA` payloads use the first `=` as key/value delimiter.
52+
- Keys should not contain spaces or `=`.
53+
- Values may contain spaces.
54+
55+
## 5. Request Semantics
56+
57+
Application-level operations are transferred as key-value pairs, usually with
58+
an `action` key. Example request payload:
59+
60+
```text
61+
action=create
62+
plugin=msgbox
63+
id=w1
64+
width=40
65+
height=7
66+
text=Important message
67+
button=OK
68+
button=Cancel
69+
```
70+
71+
At protocol level this becomes multiple `PAIR <id> key=value` lines.
72+
73+
## 6. Response Semantics
74+
75+
- `RESPDATA` carries structured result fields.
76+
- `RESPONSE ... OK` marks successful completion.
77+
- `RESPONSE ... ERROR` marks failed completion.
78+
- Server may additionally send `RESPDATA <id> ERR=<message>` before final error.
79+
80+
## 7. Full Example: Create + Wait Result
81+
82+
### 7.1 Create dialog
83+
84+
```text
85+
C> HELLO
86+
S> TAKE 1
87+
C> PAIR 1 action=create
88+
C> PAIR 1 plugin=msgbox
89+
C> PAIR 1 id=w1
90+
C> PAIR 1 width=40
91+
C> PAIR 1 height=7
92+
C> PAIR 1 border=true
93+
C> PAIR 1 text=Important message.
94+
C> PAIR 1 button=OK
95+
C> PAIR 1 button=Cancel
96+
C> DONE 1
97+
S> RESPONSE 1 OK
98+
```
99+
100+
### 7.2 Wait for completion
101+
102+
```text
103+
C> HELLO
104+
S> TAKE 2
105+
C> PAIR 2 action=wait-result
106+
C> PAIR 2 id=w1
107+
C> DONE 2
108+
S> RESPONSE 2 OK
109+
```
110+
111+
### 7.3 Read result fields
112+
113+
```text
114+
C> HELLO
115+
S> TAKE 3
116+
C> PAIR 3 action=result
117+
C> PAIR 3 id=w1
118+
C> DONE 3
119+
S> RESPDATA 3 BUTTON_1=1
120+
S> RESPDATA 3 BUTTON_2=0
121+
S> RESPONSE 3 OK
122+
```
123+
124+
## 8. Error Example
125+
126+
```text
127+
C> HELLO
128+
S> TAKE 4
129+
C> PAIR 4 action=create
130+
C> PAIR 4 id=w2
131+
C> DONE 4
132+
S> RESPDATA 4 ERR=field is missing: plugin
133+
S> RESPONSE 4 ERROR
134+
```
135+
136+
## 9. Action Catalogue
137+
138+
See `Documentation/plainmouthd-commands.md` for application-level actions
139+
(`create`, `update`, `delete`, `focus`, `wait-result`, `set-style`, and others).
140+

Documentation/plainmouthd-commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
This document describes the command set implemented in `plainmouthd`. Commands
44
are sent by plugin instances to `plainmouthd` and are interpreted as **requests**.
55

6+
For wire format, framing rules, and full request/response transcripts, see
7+
`Documentation/ipc-protocol.md`.
8+
69
## Global Commands
710

811
### set-title

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ Dependencies include:
6363
- `ncurses` and `panel` development libraries
6464
- `pthread`
6565

66+
## Documentation
67+
68+
- `Documentation/architecture.md` - architecture and widget model
69+
- `Documentation/plainmouthd-commands.md` - command-level interface
70+
- `Documentation/ipc-protocol.md` - low-level IPC wire protocol and examples
71+
6672
## License
6773

6874
This software is licensed under the [GNU General Public License v2.0](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).

0 commit comments

Comments
 (0)