Private
Public Access
1
0

Finish daemon support for uploaded attachments + sending

This commit is contained in:
2025-06-12 19:46:53 -07:00
parent f3e59b9951
commit 137da5b3d1
5 changed files with 23 additions and 7 deletions

View File

@@ -69,7 +69,7 @@ public class MainWindow : Adw.ApplicationWindow
} }
try { try {
Repository.get_instance().send_message(selected_conversation, body); Repository.get_instance().send_message(selected_conversation, body, attachment_guids.to_array());
} catch (Error e) { } catch (Error e) {
GLib.warning("Failed to send message: %s", e.message); GLib.warning("Failed to send message: %s", e.message);
} }

View File

@@ -48,7 +48,7 @@ namespace DBusService {
public abstract GLib.HashTable<string, GLib.Variant>[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError; public abstract GLib.HashTable<string, GLib.Variant>[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError;
[DBus (name = "SendMessage")] [DBus (name = "SendMessage")]
public abstract string send_message(string conversation_id, string text) throws DBusError, IOError; public abstract string send_message(string conversation_id, string text, string[] attachment_guids) throws DBusError, IOError;
[DBus (name = "MessagesUpdated")] [DBus (name = "MessagesUpdated")]
public signal void messages_updated(string conversation_id); public signal void messages_updated(string conversation_id);

View File

@@ -81,10 +81,20 @@
<method name="SendMessage"> <method name="SendMessage">
<arg type="s" name="conversation_id" direction="in"/> <arg type="s" name="conversation_id" direction="in"/>
<arg type="s" name="text" direction="in"/> <arg type="s" name="text" direction="in"/>
<arg type="as" name="attachment_guids" direction="in"/>
<arg type="s" name="outgoing_message_id" direction="out"/> <arg type="s" name="outgoing_message_id" direction="out"/>
<annotation name="org.freedesktop.DBus.DocString" <annotation name="org.freedesktop.DBus.DocString"
value="Sends a message to the server. Returns the outgoing message ID."/> value="Sends a message to the server. Returns the outgoing message ID.
Arguments:
- conversation_id: The ID of the conversation to send the message to.
- text: The text of the message to send.
- attachment_guids: The GUIDs of the attachments to send.
Returns:
- outgoing_message_id: The ID of the outgoing message.
"/>
</method> </method>
<signal name="MessagesUpdated"> <signal name="MessagesUpdated">

View File

@@ -82,12 +82,12 @@ public class Repository : DBusServiceProxy {
return returned_messages; return returned_messages;
} }
public string send_message(string conversation_guid, string message) throws DBusServiceProxyError, GLib.Error { public string send_message(string conversation_guid, string message, string[] attachment_guids) throws DBusServiceProxyError, GLib.Error {
if (dbus_repository == null) { if (dbus_repository == null) {
throw new DBusServiceProxyError.NOT_CONNECTED("Repository not connected"); throw new DBusServiceProxyError.NOT_CONNECTED("Repository not connected");
} }
return dbus_repository.send_message(conversation_guid, message); return dbus_repository.send_message(conversation_guid, message, attachment_guids);
} }
public void sync_conversation(string conversation_guid) throws DBusServiceProxyError, GLib.Error { public void sync_conversation(string conversation_guid) throws DBusServiceProxyError, GLib.Error {

View File

@@ -34,6 +34,12 @@ class TranscriptContainerView : Adw.Bin
} }
} }
private bool can_send {
get {
return (message_entry.text.length > 0 || completed_attachments.size > 0) && pending_uploads.size == 0;
}
}
public TranscriptContainerView () { public TranscriptContainerView () {
container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
set_child (container); set_child (container);
@@ -183,11 +189,11 @@ class TranscriptContainerView : Adw.Bin
} }
private void update_send_button_sensitivity() { private void update_send_button_sensitivity() {
send_button.set_sensitive(message_entry.text.length > 0 && pending_uploads.size == 0); send_button.set_sensitive(can_send);
} }
private void on_request_send() { private void on_request_send() {
if (message_entry.text.length > 0 && pending_uploads.size == 0) { if (can_send) {
on_send(this); on_send(this);
// Clear the message entry // Clear the message entry