1
0
Fork 0
tinmop/src/gui/server/public-api.lisp

81 lines
2.8 KiB
Common Lisp

;; tinmop: an humble gemini and pleroma client
;; Copyright (C) 2022 cage
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program.
;; If not, see [[http://www.gnu.org/licenses/][http://www.gnu.org/licenses/]].
(in-package :json-rpc-communication)
(defstruct box
(payload))
(defun make-rpc-parameters (&rest params)
(loop for (a b) on params by 'cddr collect (cons a b)))
(defmacro gen-rpc (public-function-name function-symbol &rest parameters)
`(rpc:register-function ,public-function-name
,function-symbol
(make-rpc-parameters ,@parameters)))
(defun quit-program ()
(fs:clean-temporary-directories)
(fs:clean-temporary-files)
(db-utils:close-db)
(os-utils:exit-program))
(defmacro prepare-rpc (&body body)
`(let ((rpc:*function-db* '()))
(gen-rpc "add"
'+
"a" 0
"b" 1)
(gen-rpc "complete-net-address"
'complete-net-address
"hint" 0)
(gen-rpc "gemini-request"
'gemini-request
"iri" 0
"use-cache" 1)
(gen-rpc "gemini-stream-info"
'gemini-stream-info
"iri" 0)
(gen-rpc "gemini-stream-parsed-line"
'gemini-stream-parsed-line
"iri" 0
"line-number" 1)
(gen-rpc "gemini-stream-parsed-line-slice"
'gemini-stream-parsed-line-slice
"iri" 0
"line-number-start" 1
"line-number-end" 2)
(gen-rpc "gemini-all-stream-info" 'gemini-all-stream-info)
(gen-rpc "gemini-current-url" 'gemini-current-url)
(gen-rpc "gemini-pop-url-from-history" 'gemini-pop-url-from-history)
(gen-rpc "gemini-certificates" 'gemini-certificates)
(gen-rpc "gemini-delete-certificate"
'gemini-delete-certificate
"cache-key" 0)
(gen-rpc "tour-shuffle" 'tour-shuffle)
(gen-rpc "tour-add-link"
'tour-add-link
"link-value" 0
"link-label" 1)
(gen-rpc "tour-pop-link" 'tour-pop-link)
(gen-rpc "tour-delete-link"
'tour-delete-link
"url" 0)
(gen-rpc "clear-tour" 'clear-tour)
(gen-rpc "quit-program" 'quit-program)
,@body))