Implements attachments display in transcript
This commit is contained in:
@@ -52,5 +52,24 @@ namespace DBusService {
|
||||
|
||||
[DBus (name = "MessagesUpdated")]
|
||||
public signal void messages_updated(string conversation_id);
|
||||
|
||||
[DBus (name = "GetAttachmentInfo")]
|
||||
public abstract RepositoryAttachmentInfoStruct get_attachment_info(string attachment_id) throws DBusError, IOError;
|
||||
|
||||
[DBus (name = "DownloadAttachment")]
|
||||
public abstract void download_attachment(string attachment_id, bool preview) throws DBusError, IOError;
|
||||
|
||||
[DBus (name = "AttachmentDownloadCompleted")]
|
||||
public signal void attachment_download_completed(string attachment_id);
|
||||
|
||||
[DBus (name = "AttachmentDownloadFailed")]
|
||||
public signal void attachment_download_failed(string attachment_id, string error_message);
|
||||
}
|
||||
|
||||
public struct RepositoryAttachmentInfoStruct {
|
||||
public string attr1;
|
||||
public string attr2;
|
||||
public bool attr3;
|
||||
public bool attr4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<interface name="net.buzzert.kordophone.Repository">
|
||||
<method name="GetVersion">
|
||||
<arg type="s" name="version" direction="out" />
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Returns the version of the client daemon."/>
|
||||
</method>
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<method name="GetConversations">
|
||||
<arg type="i" name="limit" direction="in"/>
|
||||
<arg type="i" name="offset" direction="in"/>
|
||||
|
||||
|
||||
<arg type="aa{sv}" direction="out" name="conversations">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Array of dictionaries. Each dictionary has keys:
|
||||
'id' (string): Unique identifier
|
||||
'display_name' (string): Display name
|
||||
@@ -28,28 +28,28 @@
|
||||
</method>
|
||||
|
||||
<method name="SyncConversationList">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Initiates a background sync of the conversation list with the server."/>
|
||||
</method>
|
||||
|
||||
<method name="SyncAllConversations">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Initiates a background sync of all conversations with the server."/>
|
||||
</method>
|
||||
|
||||
<method name="SyncConversation">
|
||||
<arg type="s" name="conversation_id" direction="in"/>
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Initiates a background sync of a single conversation with the server."/>
|
||||
</method>
|
||||
|
||||
<signal name="ConversationsUpdated">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when the list of conversations is updated."/>
|
||||
</signal>
|
||||
|
||||
<method name="DeleteAllConversations">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Deletes all conversations from the database."/>
|
||||
</method>
|
||||
|
||||
@@ -58,7 +58,24 @@
|
||||
<method name="GetMessages">
|
||||
<arg type="s" name="conversation_id" direction="in"/>
|
||||
<arg type="s" name="last_message_id" direction="in"/>
|
||||
<arg type="aa{sv}" direction="out" name="messages"/>
|
||||
<arg type="aa{sv}" direction="out" name="messages">
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Array of dictionaries. Each dictionary has keys:
|
||||
'id' (string): Unique message identifier
|
||||
'text' (string): Message body text
|
||||
'date' (int64): Message timestamp
|
||||
'sender' (string): Sender display name
|
||||
'attachments' (array of dictionaries): List of attachments
|
||||
'guid' (string): Attachment GUID
|
||||
'path' (string): Attachment path
|
||||
'preview_path' (string): Preview attachment path
|
||||
'downloaded' (boolean): Whether the attachment is downloaded
|
||||
'preview_downloaded' (boolean): Whether the preview is downloaded
|
||||
'metadata' (dictionary, optional): Attachment metadata
|
||||
'attribution_info' (dictionary, optional): Attribution info
|
||||
'width' (int32, optional): Width
|
||||
'height' (int32, optional): Height"/>
|
||||
</arg>
|
||||
</method>
|
||||
|
||||
<method name="SendMessage">
|
||||
@@ -66,16 +83,56 @@
|
||||
<arg type="s" name="text" direction="in"/>
|
||||
<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."/>
|
||||
</method>
|
||||
|
||||
<signal name="MessagesUpdated">
|
||||
<arg type="s" name="conversation_id" direction="in"/>
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when the list of messages is updated."/>
|
||||
</signal>
|
||||
|
||||
|
||||
<!-- Attachments -->
|
||||
|
||||
<method name="GetAttachmentInfo">
|
||||
<arg type="s" name="attachment_id" direction="in"/>
|
||||
<arg type="(ssbb)" name="attachment_info" direction="out"/>
|
||||
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Returns attachment info:
|
||||
- path: string
|
||||
- preview_path: string
|
||||
- downloaded: boolean
|
||||
- preview_downloaded: boolean
|
||||
"/>
|
||||
</method>
|
||||
|
||||
<method name="DownloadAttachment">
|
||||
<arg type="s" name="attachment_id" direction="in"/>
|
||||
<arg type="b" name="preview" direction="in"/>
|
||||
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Initiates download of the specified attachment if not already downloaded.
|
||||
Arguments:
|
||||
attachment_id: the attachment GUID
|
||||
preview: whether to download the preview (true) or full attachment (false)
|
||||
"/>
|
||||
</method>
|
||||
|
||||
<signal name="AttachmentDownloadCompleted">
|
||||
<arg type="s" name="attachment_id"/>
|
||||
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when an attachment download completes successfully."/>
|
||||
</signal>
|
||||
|
||||
<signal name="AttachmentDownloadFailed">
|
||||
<arg type="s" name="attachment_id"/>
|
||||
<arg type="s" name="error_message"/>
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when an attachment download fails."/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="net.buzzert.kordophone.Settings">
|
||||
@@ -90,6 +147,6 @@
|
||||
</method>
|
||||
|
||||
<!-- emitted when anything changes -->
|
||||
<signal name="ConfigChanged"/>
|
||||
<signal name="ConfigChanged"/>
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -4,6 +4,7 @@ using Gee;
|
||||
public class Repository : DBusServiceProxy {
|
||||
public signal void conversations_updated();
|
||||
public signal void messages_updated(string conversation_guid);
|
||||
public signal void attachment_downloaded(string attachment_guid);
|
||||
|
||||
public static Repository get_instance() {
|
||||
if (instance == null) {
|
||||
@@ -36,6 +37,10 @@ public class Repository : DBusServiceProxy {
|
||||
messages_updated(conversation_guid);
|
||||
});
|
||||
|
||||
this.dbus_repository.attachment_download_completed.connect((attachment_guid) => {
|
||||
attachment_downloaded(attachment_guid);
|
||||
});
|
||||
|
||||
conversations_updated();
|
||||
} catch (GLib.Error e) {
|
||||
warning("Failed to connect to repository: %s", e.message);
|
||||
@@ -87,4 +92,12 @@ public class Repository : DBusServiceProxy {
|
||||
|
||||
dbus_repository.sync_conversation(conversation_guid);
|
||||
}
|
||||
|
||||
public void download_attachment(string attachment_guid, bool preview) throws DBusServiceProxyError, GLib.Error {
|
||||
if (dbus_repository == null) {
|
||||
throw new DBusServiceProxyError.NOT_CONNECTED("Repository not connected");
|
||||
}
|
||||
|
||||
dbus_repository.download_attachment(attachment_guid, preview);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user