diff options
Diffstat (limited to 'libdino/src/entity')
-rw-r--r-- | libdino/src/entity/conversation.vala | 7 | ||||
-rw-r--r-- | libdino/src/entity/file_transfer.vala | 22 | ||||
-rw-r--r-- | libdino/src/entity/message.vala | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index 9026e33f..585db07e 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -105,8 +105,11 @@ public class Conversation : Object { Xmpp.XmppStream? stream = stream_interactor.get_stream(account); if (!Application.get_default().settings.notifications) return NotifySetting.OFF; if (type_ == Type.GROUPCHAT) { - bool members_only = stream.get_flag(Xmpp.Xep.Muc.Flag.IDENTITY).has_room_feature(counterpart.bare_jid, Xmpp.Xep.Muc.Feature.MEMBERS_ONLY); - return members_only ? NotifySetting.ON : NotifySetting.HIGHLIGHT; + Xmpp.Xep.Muc.Flag flag = stream.get_flag(Xmpp.Xep.Muc.Flag.IDENTITY); + if (flag != null) { + bool members_only = flag.has_room_feature(counterpart.bare_jid, Xmpp.Xep.Muc.Feature.MEMBERS_ONLY); + return members_only ? NotifySetting.ON : NotifySetting.HIGHLIGHT; + } } return NotifySetting.ON; } diff --git a/libdino/src/entity/file_transfer.vala b/libdino/src/entity/file_transfer.vala index e2542e74..be472796 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 @@ -61,7 +77,7 @@ public class FileTransfer : Object { } direction = row[db.file_transfer.direction]; time = new DateTime.from_unix_utc(row[db.file_transfer.time]); - local_time = new DateTime.from_unix_utc(row[db.file_transfer.time]); + local_time = new DateTime.from_unix_utc(row[db.file_transfer.local_time]); encryption = (Encryption) row[db.file_transfer.encryption]; file_name = row[db.file_transfer.file_name]; path = row[db.file_transfer.path]; diff --git a/libdino/src/entity/message.vala b/libdino/src/entity/message.vala index 6e34e458..ac54a7c2 100644 --- a/libdino/src/entity/message.vala +++ b/libdino/src/entity/message.vala @@ -82,7 +82,7 @@ public class Message : Object { } direction = row[db.message.direction]; time = new DateTime.from_unix_utc(row[db.message.time]); - local_time = new DateTime.from_unix_utc(row[db.message.time]); + local_time = new DateTime.from_unix_utc(row[db.message.local_time]); body = row[db.message.body]; marked = (Message.Marked) row[db.message.marked]; encryption = (Encryption) row[db.message.encryption]; |