New file naming scheme and organization for the Engine.
The code base is growing much faster than expected, faster than Shotwell it seems (not necessarily line count, but files and necessary organization of the library vs. Shotwell's initial flat directory). After some thought decided to move to a more standard Vala/GTK naming scheme of all lowercase with dashes for spaces starting with namespace (minus the "geary-", unless the class was in the topmost namespace). Three motivations: 1. Often confusing when working on code to see three "Folder.vala" in the gedit tabs: one IMAP, one SQLite, and one the interface definition. 2. This paves the way for waf integration, as right now we're held up using it because it barfs on projects with two files of the same name in different directories. 3. I find the CamelCase in the file browser becoming hard on the eyes, and this scheme seems a little more browsable.
This commit is contained in:
parent
f94018474b
commit
41faa36103
78 changed files with 83 additions and 77 deletions
79
src/engine/sqlite/api/sqlite-account.vala
Normal file
79
src/engine/sqlite/api/sqlite-account.vala
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* 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;
|
||||
private MessageTable message_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();
|
||||
message_table = db.get_message_table();
|
||||
}
|
||||
|
||||
public Geary.Email.Field get_required_fields_for_writing() {
|
||||
return Geary.Email.Field.NONE;
|
||||
}
|
||||
|
||||
public async void create_folder_async(Geary.Folder? parent, Geary.Folder folder,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
yield folder_table.create_async(new FolderRow(folder_table, folder.get_name(), Row.INVALID_ID),
|
||||
cancellable);
|
||||
}
|
||||
|
||||
public async void create_many_folders_async(Geary.Folder? parent, 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(db.get_folder_table(), folder.get_name(), Row.INVALID_ID));
|
||||
|
||||
yield folder_table.create_many_async(rows, cancellable);
|
||||
}
|
||||
|
||||
public async Gee.Collection<Geary.Folder> list_folders_async(Geary.Folder? parent,
|
||||
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(db, row));
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
public async Geary.Folder fetch_folder_async(Geary.Folder? parent, string folder_name,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
FolderRow? row = yield folder_table.fetch_async(Row.INVALID_ID, folder_name, cancellable);
|
||||
if (row == null)
|
||||
throw new EngineError.NOT_FOUND("\"%s\" not found in local database", folder_name);
|
||||
|
||||
return new Geary.Sqlite.Folder(db, row);
|
||||
}
|
||||
|
||||
public async void remove_folder_async(Geary.Folder folder, Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public async void remove_many_folders_async(Gee.Set<Geary.Folder> folders,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public async bool has_message_id_async(Geary.RFC822.MessageID message_id, out int count,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
count = yield message_table.search_message_id_count_async(message_id);
|
||||
|
||||
return (count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue