diff options
Diffstat (limited to 'lib/astal/io')
-rw-r--r-- | lib/astal/io/application.vala | 27 | ||||
-rw-r--r-- | lib/astal/io/cli.vala | 4 | ||||
-rw-r--r-- | lib/astal/io/daemon.vala | 4 |
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/astal/io/application.vala b/lib/astal/io/application.vala index 09b61b5..bd6d779 100644 --- a/lib/astal/io/application.vala +++ b/lib/astal/io/application.vala @@ -5,8 +5,7 @@ public errordomain AppError { } /** - * This interface is used as a placeholder for the Astal Application class. - * It is not meant to be used by consumers. + * This interface is used internally in Astal3 and Astal4, not meant for public usage. */ public interface Application : Object { public abstract void quit() throws Error; @@ -15,7 +14,7 @@ public interface Application : Object { public abstract string instance_name { owned get; construct set; } public abstract void acquire_socket() throws Error; - public virtual void request(string msg, SocketConnection conn) throws Error { + public virtual void request(string request, SocketConnection conn) throws Error { write_sock.begin(conn, @"missing response implementation on $instance_name"); } } @@ -61,8 +60,8 @@ public SocketService acquire_socket(Application app, out string sock) throws Err service.incoming.connect((conn) => { read_sock.begin(conn, (_, res) => { try { - string message = read_sock.end(res); - app.request(message != null ? message.strip() : "", conn); + string request = read_sock.end(res); + app.request(request != null ? request.strip() : "", conn); } catch (Error err) { critical(err.message); } @@ -142,21 +141,31 @@ public static void toggle_window_by_name(string instance, string window) throws } /** - * Send a message to an Astal instances. - * It is the equivalent of `astal -i instance content of the message`. + * Use [[email protected]_request] instead. */ -public static string send_message(string instance, string msg) throws Error { +[Version (deprecated = true)] +public static string send_message(string instance, string request) throws Error { + return send_request(instance, request); +} + +/** + * Send a request to an Astal instances. + * It is the equivalent of `astal -i instance "request content"`. + */ +public static string send_request(string instance, string request) throws Error { var rundir = Environment.get_user_runtime_dir(); var socket_path = @"$rundir/astal/$instance.sock"; var client = new SocketClient(); var conn = client.connect(new UnixSocketAddress(socket_path), null); - conn.output_stream.write(msg.concat("\x04").data); + conn.output_stream.write(request.concat("\x04").data); var stream = new DataInputStream(conn.input_stream); return stream.read_upto("\x04", -1, null, null); } +// TODO: send_request_async + /** * Read the socket of an Astal.Application instance. */ diff --git a/lib/astal/io/cli.vala b/lib/astal/io/cli.vala index 9e47b53..23abd14 100644 --- a/lib/astal/io/cli.vala +++ b/lib/astal/io/cli.vala @@ -38,7 +38,7 @@ int main(string[] argv) { if (help) { print("Client for Astal.Application instances\n\n"); print("Usage:\n"); - print(" %s [flags] message\n\n", argv[0]); + print(" %s [flags] requet\n\n", argv[0]); print("Flags:\n"); print(" -h, --help Print this help and exit\n"); print(" -v, --version Print version number and exit\n"); @@ -92,7 +92,7 @@ int main(string[] argv) { } try { - var reply = AstalIO.send_message(instance_name, request); + var reply = AstalIO.send_request(instance_name, request); print("%s\n", reply); } catch (IOError.NOT_FOUND e) { return err(@"there is no \"$instance_name\" instance runnning\n"); diff --git a/lib/astal/io/daemon.vala b/lib/astal/io/daemon.vala index 7f3173e..1dca26d 100644 --- a/lib/astal/io/daemon.vala +++ b/lib/astal/io/daemon.vala @@ -22,11 +22,11 @@ public class AstalIO.Daemon : GLib.Application, AstalIO.Application { /** * Handler for an incoming request. * - * @param msg Body of the message + * @param request Body of the request * @param conn The connection which expects the response. */ [DBus (visible=false)] - public virtual void request(string msg, SocketConnection conn) { + public virtual void request(string request, SocketConnection conn) { AstalIO.write_sock.begin(conn, @"missing response implementation on $application_id"); } |