diff options
author | Aylur <[email protected]> | 2025-02-27 14:58:40 +0100 |
---|---|---|
committer | Aylur <[email protected]> | 2025-02-27 15:04:40 +0100 |
commit | 98a488d0efe520533316b0df32386d9b40c2ef17 (patch) | |
tree | 4decb9c8be264c69901e504132c1039d29666f13 | |
parent | b7f10b99bc810e7ad6a949d6670cb440d33045a0 (diff) |
rename: message -> request
the same thing was called either message or request
now its only referred to as a request
-rwxr-xr-x | examples/gtk3/py/simple-bar/app.py | 2 | ||||
-rw-r--r-- | examples/gtk3/vala/simple-bar/app.in.vala | 2 | ||||
-rw-r--r-- | lang/gjs/src/_app.ts | 2 | ||||
-rw-r--r-- | lang/lua/astal/gtk3/app.lua | 2 | ||||
-rw-r--r-- | lib/astal/gtk3/src/application.vala | 4 | ||||
-rw-r--r-- | lib/astal/gtk4/src/application.vala | 4 | ||||
-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 |
9 files changed, 30 insertions, 21 deletions
diff --git a/examples/gtk3/py/simple-bar/app.py b/examples/gtk3/py/simple-bar/app.py index d95dc0e..ba3a910 100755 --- a/examples/gtk3/py/simple-bar/app.py +++ b/examples/gtk3/py/simple-bar/app.py @@ -33,4 +33,4 @@ if __name__ == "__main__": app.acquire_socket() app.run(None) except Exception as e: - print(AstalIO.send_message(instance_name, "".join(sys.argv[1:]))) + print(AstalIO.send_request(instance_name, "".join(sys.argv[1:]))) diff --git a/examples/gtk3/vala/simple-bar/app.in.vala b/examples/gtk3/vala/simple-bar/app.in.vala index b04a1fa..91e2adc 100644 --- a/examples/gtk3/vala/simple-bar/app.in.vala +++ b/examples/gtk3/vala/simple-bar/app.in.vala @@ -24,7 +24,7 @@ class App : Astal.Application { App.instance.acquire_socket(); App.instance.run(null); } catch (Error err) { - print(AstalIO.send_message(instance_name, string.joinv(" ", args))); + print(AstalIO.send_request(instance_name, string.joinv(" ", args))); } } } diff --git a/lang/gjs/src/_app.ts b/lang/gjs/src/_app.ts index 46497c1..13853f4 100644 --- a/lang/gjs/src/_app.ts +++ b/lang/gjs/src/_app.ts @@ -101,7 +101,7 @@ export function mkApp(App: App3 | App4) { try { app.acquire_socket() } catch (error) { - return client(msg => IO.send_message(app.instanceName, msg)!, ...programArgs) + return client(msg => IO.send_request(app.instanceName, msg)!, ...programArgs) } if (css) diff --git a/lang/lua/astal/gtk3/app.lua b/lang/lua/astal/gtk3/app.lua index 58564ce..4d99eb9 100644 --- a/lang/lua/astal/gtk3/app.lua +++ b/lang/lua/astal/gtk3/app.lua @@ -77,7 +77,7 @@ function Astal.Application:start(config) local _, err = app:acquire_socket() if err ~= nil then return config.client(function(msg) - return AstalIO.send_message(self.instance_name, msg) + return AstalIO.send_request(self.instance_name, msg) end, table.unpack(arg)) end diff --git a/lib/astal/gtk3/src/application.vala b/lib/astal/gtk3/src/application.vala index baa0ee5..320f4b1 100644 --- a/lib/astal/gtk3/src/application.vala +++ b/lib/astal/gtk3/src/application.vala @@ -189,11 +189,11 @@ public class Astal.Application : Gtk.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"); } diff --git a/lib/astal/gtk4/src/application.vala b/lib/astal/gtk4/src/application.vala index e5871c0..314443e 100644 --- a/lib/astal/gtk4/src/application.vala +++ b/lib/astal/gtk4/src/application.vala @@ -182,11 +182,11 @@ public class Astal.Application : Gtk.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"); } 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"); } |