diff --git a/src/application/main-window.vala b/src/application/main-window.vala index 63e0cc4..499f30e 100644 --- a/src/application/main-window.vala +++ b/src/application/main-window.vala @@ -69,7 +69,7 @@ public class MainWindow : Adw.ApplicationWindow } try { - Repository.get_instance().send_message(selected_conversation, body); + Repository.get_instance().send_message(selected_conversation, body, attachment_guids.to_array()); } catch (Error e) { GLib.warning("Failed to send message: %s", e.message); } diff --git a/src/service/interface/dbusservice.vala b/src/service/interface/dbusservice.vala index 1a6d95c..f352da2 100644 --- a/src/service/interface/dbusservice.vala +++ b/src/service/interface/dbusservice.vala @@ -48,7 +48,7 @@ namespace DBusService { public abstract GLib.HashTable[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError; [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")] public signal void messages_updated(string conversation_id); diff --git a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml index bdc0fb2..8e93ca5 100644 --- a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml +++ b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml @@ -81,10 +81,20 @@ + + + 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. + "/> diff --git a/src/service/repository.vala b/src/service/repository.vala index 8753f6b..f89f757 100644 --- a/src/service/repository.vala +++ b/src/service/repository.vala @@ -82,12 +82,12 @@ public class Repository : DBusServiceProxy { 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) { 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 { diff --git a/src/transcript/transcript-container-view.vala b/src/transcript/transcript-container-view.vala index 9b26d06..4da4f65 100644 --- a/src/transcript/transcript-container-view.vala +++ b/src/transcript/transcript-container-view.vala @@ -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 () { container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); set_child (container); @@ -183,11 +189,11 @@ class TranscriptContainerView : Adw.Bin } 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() { - if (message_entry.text.length > 0 && pending_uploads.size == 0) { + if (can_send) { on_send(this); // Clear the message entry