Repository: add support for attachment uploading
This commit is contained in:
@@ -59,11 +59,17 @@ namespace DBusService {
|
|||||||
[DBus (name = "DownloadAttachment")]
|
[DBus (name = "DownloadAttachment")]
|
||||||
public abstract void download_attachment(string attachment_id, bool preview) throws DBusError, IOError;
|
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")]
|
[DBus (name = "AttachmentDownloadCompleted")]
|
||||||
public signal void attachment_download_completed(string attachment_id);
|
public signal void attachment_download_completed(string attachment_id);
|
||||||
|
|
||||||
[DBus (name = "AttachmentDownloadFailed")]
|
[DBus (name = "AttachmentDownloadFailed")]
|
||||||
public signal void attachment_download_failed(string attachment_id, string error_message);
|
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 {
|
public struct RepositoryAttachmentInfoStruct {
|
||||||
|
|||||||
@@ -120,6 +120,11 @@
|
|||||||
"/>
|
"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name="UploadAttachment">
|
||||||
|
<arg type="s" name="path" direction="in"/>
|
||||||
|
<arg type="s" name="upload_guid" direction="out"/>
|
||||||
|
</method>
|
||||||
|
|
||||||
<signal name="AttachmentDownloadCompleted">
|
<signal name="AttachmentDownloadCompleted">
|
||||||
<arg type="s" name="attachment_id"/>
|
<arg type="s" name="attachment_id"/>
|
||||||
|
|
||||||
@@ -133,6 +138,18 @@
|
|||||||
<annotation name="org.freedesktop.DBus.DocString"
|
<annotation name="org.freedesktop.DBus.DocString"
|
||||||
value="Emitted when an attachment download fails."/>
|
value="Emitted when an attachment download fails."/>
|
||||||
</signal>
|
</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>
|
||||||
|
|
||||||
<interface name="net.buzzert.kordophone.Settings">
|
<interface name="net.buzzert.kordophone.Settings">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ public class Repository : DBusServiceProxy {
|
|||||||
public signal void conversations_updated();
|
public signal void conversations_updated();
|
||||||
public signal void messages_updated(string conversation_guid);
|
public signal void messages_updated(string conversation_guid);
|
||||||
public signal void attachment_downloaded(string attachment_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() {
|
public static Repository get_instance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@@ -41,6 +42,10 @@ public class Repository : DBusServiceProxy {
|
|||||||
attachment_downloaded(attachment_guid);
|
attachment_downloaded(attachment_guid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.dbus_repository.attachment_upload_completed.connect((upload_guid, attachment_guid) => {
|
||||||
|
attachment_uploaded(upload_guid, attachment_guid);
|
||||||
|
});
|
||||||
|
|
||||||
conversations_updated();
|
conversations_updated();
|
||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
warning("Failed to connect to repository: %s", e.message);
|
warning("Failed to connect to repository: %s", e.message);
|
||||||
@@ -100,4 +105,12 @@ public class Repository : DBusServiceProxy {
|
|||||||
|
|
||||||
dbus_repository.download_attachment(attachment_guid, preview);
|
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