diff options
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; |