diff options
author | fiaxh <git@lightrise.org> | 2019-07-18 02:03:42 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-07-18 02:03:42 +0200 |
commit | f0abb8aaf9d06106235ca5e0e6b3ca2e425c4422 (patch) | |
tree | 03fce63f8c37b50b5202690a6801234724ed0021 /libdino/src/entity | |
parent | 30353e92d63c033857ad0396c921b3bf5cab44c3 (diff) | |
download | dino-f0abb8aaf9d06106235ca5e0e6b3ca2e425c4422.tar.gz dino-f0abb8aaf9d06106235ca5e0e6b3ca2e425c4422.zip |
Refactor file receive/send interfaces and UI
Diffstat (limited to 'libdino/src/entity')
-rw-r--r-- | libdino/src/entity/file_transfer.vala | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libdino/src/entity/file_transfer.vala b/libdino/src/entity/file_transfer.vala index 68234a48..4e4103b9 100644 --- a/libdino/src/entity/file_transfer.vala +++ b/libdino/src/entity/file_transfer.vala @@ -9,7 +9,7 @@ public class FileTransfer : Object { public enum State { COMPLETE, - IN_PROCESS, + IN_PROGRESS, NOT_STARTED, FAILED } @@ -27,7 +27,7 @@ public class FileTransfer : Object { public bool direction { get; set; } public DateTime time { get; set; } public DateTime? local_time { get; set; } - public Encryption encryption { get; set; } + public Encryption encryption { get; set; default=Encryption.NONE; } private InputStream? input_stream_ = null; public InputStream input_stream { @@ -54,9 +54,9 @@ public class FileTransfer : Object { public string path { get; set; } public string? mime_type { get; set; } // TODO(hrxi): expand to 64 bit - public int size { get; set; } + public int size { get; set; default=-1; } - public State state { get; set; } + public State state { get; set; default=State.NOT_STARTED; } public int provider { get; set; } public string info { get; set; } @@ -110,12 +110,15 @@ public class FileTransfer : Object { .value(db.file_transfer.local_time, (long) local_time.to_unix()) .value(db.file_transfer.encryption, encryption) .value(db.file_transfer.file_name, file_name) - .value(db.file_transfer.path, path) - .value(db.file_transfer.mime_type, mime_type) .value(db.file_transfer.size, size) .value(db.file_transfer.state, state) .value(db.file_transfer.provider, provider) .value(db.file_transfer.info, info); + + if (file_name != null) builder.value(db.file_transfer.file_name, file_name); + if (path != null) builder.value(db.file_transfer.path, path); + if (mime_type != null) builder.value(db.file_transfer.mime_type, mime_type); + id = (int) builder.perform(); notify.connect(on_update); } @@ -142,7 +145,14 @@ public class FileTransfer : Object { update_builder.set(db.file_transfer.encryption, encryption); break; case "file-name": update_builder.set(db.file_transfer.file_name, file_name); break; + case "path": + update_builder.set(db.file_transfer.path, path); break; + case "mime-type": + update_builder.set(db.file_transfer.mime_type, mime_type); break; + case "size": + update_builder.set(db.file_transfer.size, size); break; case "state": + if (state == State.IN_PROGRESS) return; update_builder.set(db.file_transfer.state, state); break; case "provider": update_builder.set(db.file_transfer.provider, provider); break; |