summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAylur <[email protected]>2025-02-27 14:58:40 +0100
committerAylur <[email protected]>2025-02-27 15:04:40 +0100
commit98a488d0efe520533316b0df32386d9b40c2ef17 (patch)
tree4decb9c8be264c69901e504132c1039d29666f13 /lib
parentb7f10b99bc810e7ad6a949d6670cb440d33045a0 (diff)
rename: message -> request
the same thing was called either message or request now its only referred to as a request
Diffstat (limited to 'lib')
-rw-r--r--lib/astal/gtk3/src/application.vala4
-rw-r--r--lib/astal/gtk4/src/application.vala4
-rw-r--r--lib/astal/io/application.vala27
-rw-r--r--lib/astal/io/cli.vala4
-rw-r--r--lib/astal/io/daemon.vala4
5 files changed, 26 insertions, 17 deletions
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");
}