aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/file_manager.vala
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service/file_manager.vala')
-rw-r--r--libdino/src/service/file_manager.vala24
1 files changed, 7 insertions, 17 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 667076dd..18f1735d 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -84,13 +84,7 @@ public class FileManager : StreamInteractionModule, Object {
.with(db.file_transfer.account_id, "=", account.id)
.order_by(db.file_transfer.local_time, "DESC")
.limit(n);
-
- Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>();
- foreach (Qlite.Row row in select) {
- FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir());
- ret.insert(0, file_transfer);
- }
- return ret;
+ return get_transfers_from_qry(select);
}
public Gee.List<FileTransfer> get_transfers_before(Account account, Jid counterpart, DateTime before, int n) {
@@ -100,23 +94,19 @@ public class FileManager : StreamInteractionModule, Object {
.with(db.file_transfer.local_time, "<", (long)before.to_unix())
.order_by(db.file_transfer.local_time, "DESC")
.limit(n);
-
- Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>();
- foreach (Qlite.Row row in select) {
- FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir());
- ret.insert(0, file_transfer);
- }
- return ret;
+ return get_transfers_from_qry(select);
}
- public Gee.List<FileTransfer> get_file_transfers(Account account, Jid counterpart, DateTime after, DateTime before) {
+ public Gee.List<FileTransfer> get_transfers_after(Account account, Jid counterpart, DateTime after, int n) {
Qlite.QueryBuilder select = db.file_transfer.select()
.with(db.file_transfer.counterpart_id, "=", db.get_jid_id(counterpart))
.with(db.file_transfer.account_id, "=", account.id)
.with(db.file_transfer.local_time, ">", (long)after.to_unix())
- .with(db.file_transfer.local_time, "<", (long)before.to_unix())
- .order_by(db.file_transfer.id, "DESC");
+ .limit(n);
+ return get_transfers_from_qry(select);
+ }
+ private Gee.List<FileTransfer> get_transfers_from_qry(Qlite.QueryBuilder select) {
Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>();
foreach (Qlite.Row row in select) {
FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir());