aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/entity
diff options
context:
space:
mode:
authorbobufa <bobufa@users.noreply.github.com>2018-06-19 18:07:00 +0200
committerbobufa <bobufa@users.noreply.github.com>2018-08-13 22:04:47 +0200
commit3ea00446fb5893804243f5b1a1aa89817b7bc19a (patch)
tree3be25cfd7b807cd6db4846e6fe1b6e404a58a1f4 /libdino/src/entity
parentab0bc7f04d156db9e398c3f8c4f8bdfc11dd7458 (diff)
downloaddino-3ea00446fb5893804243f5b1a1aa89817b7bc19a.tar.gz
dino-3ea00446fb5893804243f5b1a1aa89817b7bc19a.zip
refactor conversation item management (accumulate them in libdino)
Diffstat (limited to 'libdino/src/entity')
-rw-r--r--libdino/src/entity/file_transfer.vala20
1 files changed, 18 insertions, 2 deletions
diff --git a/libdino/src/entity/file_transfer.vala b/libdino/src/entity/file_transfer.vala
index e2542e74..93ba782f 100644
--- a/libdino/src/entity/file_transfer.vala
+++ b/libdino/src/entity/file_transfer.vala
@@ -23,7 +23,21 @@ public class FileTransfer : Object {
public DateTime? local_time { get; set; }
public Encryption encryption { get; set; }
- public InputStream input_stream { get; set; }
+ private InputStream? input_stream_ = null;
+ public InputStream input_stream {
+ get {
+ if (input_stream_ == null) {
+ File file = File.new_for_path(Path.build_filename(storage_dir, path ?? file_name));
+ try {
+ input_stream_ = file.read();
+ } catch (Error e) { }
+ }
+ return input_stream_;
+ }
+ set {
+ input_stream_ = value;
+ }
+ }
public OutputStream output_stream { get; set; }
public string file_name { get; set; }
@@ -41,9 +55,11 @@ public class FileTransfer : Object {
public string info { get; set; }
private Database? db;
+ private string storage_dir;
- public FileTransfer.from_row(Database db, Qlite.Row row) {
+ public FileTransfer.from_row(Database db, Qlite.Row row, string storage_dir) {
this.db = db;
+ this.storage_dir = storage_dir;
id = row[db.file_transfer.id];
account = db.get_account_by_id(row[db.file_transfer.account_id]); // TODO don’t have to generate acc new