Repository: add support for attachment uploading
This commit is contained in:
@@ -59,11 +59,17 @@ namespace DBusService {
|
||||
[DBus (name = "DownloadAttachment")]
|
||||
public abstract void download_attachment(string attachment_id, bool preview) throws DBusError, IOError;
|
||||
|
||||
[DBus (name = "UploadAttachment")]
|
||||
public abstract string upload_attachment(string path) 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);
|
||||
|
||||
[DBus (name = "AttachmentUploadCompleted")]
|
||||
public signal void attachment_upload_completed(string upload_guid, string attachment_guid);
|
||||
}
|
||||
|
||||
public struct RepositoryAttachmentInfoStruct {
|
||||
|
||||
@@ -120,6 +120,11 @@
|
||||
"/>
|
||||
</method>
|
||||
|
||||
<method name="UploadAttachment">
|
||||
<arg type="s" name="path" direction="in"/>
|
||||
<arg type="s" name="upload_guid" direction="out"/>
|
||||
</method>
|
||||
|
||||
<signal name="AttachmentDownloadCompleted">
|
||||
<arg type="s" name="attachment_id"/>
|
||||
|
||||
@@ -133,6 +138,18 @@
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when an attachment download fails."/>
|
||||
</signal>
|
||||
|
||||
<signal name="AttachmentUploadCompleted">
|
||||
<arg type="s" name="upload_guid"/>
|
||||
<arg type="s" name="attachment_guid"/>
|
||||
|
||||
<annotation name="org.freedesktop.DBus.DocString"
|
||||
value="Emitted when an attachment upload completes successfully.
|
||||
Returns:
|
||||
- upload_guid: The GUID of the upload.
|
||||
- attachment_guid: The GUID of the attachment on the server.
|
||||
"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="net.buzzert.kordophone.Settings">
|
||||
|
||||
@@ -5,6 +5,7 @@ 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 signal void attachment_uploaded(string upload_guid, string attachment_guid);
|
||||
|
||||
public static Repository get_instance() {
|
||||
if (instance == null) {
|
||||
@@ -41,6 +42,10 @@ public class Repository : DBusServiceProxy {
|
||||
attachment_downloaded(attachment_guid);
|
||||
});
|
||||
|
||||
this.dbus_repository.attachment_upload_completed.connect((upload_guid, attachment_guid) => {
|
||||
attachment_uploaded(upload_guid, attachment_guid);
|
||||
});
|
||||
|
||||
conversations_updated();
|
||||
} catch (GLib.Error e) {
|
||||
warning("Failed to connect to repository: %s", e.message);
|
||||
@@ -100,4 +105,12 @@ public class Repository : DBusServiceProxy {
|
||||
|
||||
dbus_repository.download_attachment(attachment_guid, preview);
|
||||
}
|
||||
|
||||
public string upload_attachment(string filename) throws DBusServiceProxyError, GLib.Error {
|
||||
if (dbus_repository == null) {
|
||||
throw new DBusServiceProxyError.NOT_CONNECTED("Repository not connected");
|
||||
}
|
||||
|
||||
return dbus_repository.upload_attachment(filename);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user