Finish daemon support for uploaded attachments + sending
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
[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);
|
||||
|
||||
@@ -81,10 +81,20 @@
|
||||
<method name="SendMessage">
|
||||
<arg type="s" name="conversation_id" 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"/>
|
||||
|
||||
<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>
|
||||
|
||||
<signal name="MessagesUpdated">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user