First stab at implementing persistent storage of IMAP data: #3695.
This large diff represents a growth of the architecture to persist IMAP data as its downloaded. When listing folders, a local database is consulted first to immediately feed to the caller. In the background, network calls fetch the "real" list. The two are collated for differences which are reported to the caller via signals, who are then responsible for updating the user interface appropriately. No other synchronization work is represented in this diff. Note that this breaks functionality: when a folder is selected, no messages appear in the message list. Fixing this requires more work, and this patch was already large enough. It's ticketed here: #3741
This commit is contained in:
parent
38d9cb6790
commit
4b8ac5689f
38 changed files with 1014 additions and 425 deletions
56
src/engine/sqlite/api/Account.vala
Normal file
56
src/engine/sqlite/api/Account.vala
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* Copyright 2011 Yorba Foundation
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Geary.Sqlite.Account : Object, Geary.Account, Geary.LocalAccount {
|
||||
private MailDatabase db;
|
||||
private FolderTable folder_table;
|
||||
|
||||
public Account(Geary.Credentials cred) {
|
||||
try {
|
||||
db = new MailDatabase(cred.user);
|
||||
} catch (Error err) {
|
||||
error("Unable to open database: %s", err.message);
|
||||
}
|
||||
|
||||
folder_table = db.get_folder_table();
|
||||
}
|
||||
|
||||
public async Gee.Collection<Geary.Folder> list_async(string? parent_folder,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
Gee.List<FolderRow> rows = yield folder_table.list_async(Row.INVALID_ID, cancellable);
|
||||
|
||||
Gee.Collection<Geary.Folder> folders = new Gee.ArrayList<Geary.Sqlite.Folder>();
|
||||
foreach (FolderRow row in rows)
|
||||
folders.add(new Geary.Sqlite.Folder(row));
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
public async void create_async(Geary.Folder folder, Cancellable? cancellable = null) throws Error {
|
||||
yield folder_table.create_async(
|
||||
new FolderRow(folder.name, folder.supports_children, folder.is_openable),
|
||||
cancellable);
|
||||
}
|
||||
|
||||
public async void create_many_async(Gee.Collection<Geary.Folder> folders,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
Gee.List<FolderRow> rows = new Gee.ArrayList<FolderRow>();
|
||||
foreach (Geary.Folder folder in folders)
|
||||
rows.add(new FolderRow(folder.name, folder.supports_children, folder.is_openable));
|
||||
|
||||
yield folder_table.create_many_async(rows, cancellable);
|
||||
}
|
||||
|
||||
public async void remove_async(string folder, Cancellable? cancellable = null) throws Error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public async void remove_many_async(Gee.Set<string> folders, Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
48
src/engine/sqlite/api/Folder.vala
Normal file
48
src/engine/sqlite/api/Folder.vala
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* Copyright 2011 Yorba Foundation
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Geary.Sqlite.Folder : Object, Geary.Folder {
|
||||
private FolderRow row;
|
||||
|
||||
public string name { get; protected set; }
|
||||
public Trillian is_readonly { get; protected set; }
|
||||
public Trillian supports_children { get; protected set; }
|
||||
public Trillian has_children { get; protected set; }
|
||||
public Trillian is_openable { get; protected set; }
|
||||
|
||||
internal Folder(FolderRow row) throws Error {
|
||||
this.row = row;
|
||||
|
||||
name = row.name;
|
||||
is_readonly = Trillian.UNKNOWN;
|
||||
supports_children = row.supports_children;
|
||||
has_children = Trillian.UNKNOWN;
|
||||
is_openable = row.is_openable;
|
||||
}
|
||||
|
||||
public async void open_async(bool readonly, Cancellable? cancellable = null) throws Error {
|
||||
is_readonly = Trillian.TRUE;
|
||||
}
|
||||
|
||||
public async void close_async(Cancellable? cancellable = null) throws Error {
|
||||
is_readonly = Trillian.UNKNOWN;
|
||||
}
|
||||
|
||||
public int get_message_count() throws Error {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async Gee.List<Geary.EmailHeader>? read_async(int low, int count,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Geary.Email fetch_async(Geary.EmailHeader header,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
throw new EngineError.OPEN_REQUIRED("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue