MailMerge: Put non-plugin classes in own namespace, rename source files
Use a new top-level `MailMerge` namespace for non-plugin classes, rename source files to match.
This commit is contained in:
parent
b1807df1be
commit
67ecf11a83
7 changed files with 30 additions and 24 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
|
||||
/** Denotes CSV-specific error conditions. */
|
||||
public errordomain Plugin.Util.Csv.DataError {
|
||||
public errordomain MailMerge.Csv.DataError {
|
||||
|
||||
/** The input stream contained non-text data. */
|
||||
NON_TEXT_DATA,
|
||||
|
|
@ -26,7 +26,7 @@ public errordomain Plugin.Util.Csv.DataError {
|
|||
* To use this class, simply construct an instance start calling
|
||||
* {@link read_record}.
|
||||
*/
|
||||
public class Plugin.Util.Csv.Reader : Geary.BaseObject {
|
||||
public class MailMerge.Csv.Reader : Geary.BaseObject {
|
||||
|
||||
|
||||
// UTF byte prefixes indicating multi-byte codepoints
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
/**
|
||||
* Plugin to Fill in and send email templates using a spreadsheet.
|
||||
*/
|
||||
public class Plugin.MailMergeFolder : Geary.AbstractLocalFolder {
|
||||
public class MailMerge.Folder : Geary.AbstractLocalFolder {
|
||||
|
||||
|
||||
private class EmailIdentifier : Geary.EmailIdentifier {
|
||||
|
|
@ -119,14 +119,14 @@ public class Plugin.MailMergeFolder : Geary.AbstractLocalFolder {
|
|||
private Gee.List<Geary.Email> list =
|
||||
new Gee.ArrayList<Geary.Email>();
|
||||
private Geary.Email template;
|
||||
private Util.Csv.Reader data;
|
||||
private Csv.Reader data;
|
||||
private GLib.Cancellable loading = new GLib.Cancellable();
|
||||
|
||||
|
||||
public MailMergeFolder(Geary.Account account,
|
||||
Geary.FolderRoot root,
|
||||
Geary.Email template,
|
||||
Util.Csv.Reader data) {
|
||||
public Folder(Geary.Account account,
|
||||
Geary.FolderRoot root,
|
||||
Geary.Email template,
|
||||
Csv.Reader data) {
|
||||
this._account = account;
|
||||
this._path = root.get_child("$Plugin.MailMerge$");
|
||||
this.template = template;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/**
|
||||
* Substitutes merge fields in an email with actual data.
|
||||
*/
|
||||
public class Plugin.MailMergeProcessor : GLib.Object {
|
||||
public class MailMerge.Processor : GLib.Object {
|
||||
|
||||
|
||||
public const Geary.Email.Field REQUIRED_FIELDS =
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Plugin.MailMergeTestReader : ValaUnit.TestCase {
|
||||
public class MailMerge.TestReader : ValaUnit.TestCase {
|
||||
|
||||
|
||||
public MailMergeTestReader() {
|
||||
base("MailMergeTestReader");
|
||||
public TestReader() {
|
||||
base("MailMerge.TestReader");
|
||||
add_test("read_simple_lf", read_simple_lf);
|
||||
add_test("read_simple_crlf", read_simple_crlf);
|
||||
add_test("read_no_trailing_new_line", read_no_trailing_new_line);
|
||||
|
|
@ -150,9 +150,9 @@ bar",""""""";
|
|||
assert_array_is_null(eof1);
|
||||
}
|
||||
|
||||
private async Plugin.Util.Csv.Reader new_reader(uint8[] data)
|
||||
private async MailMerge.Csv.Reader new_reader(uint8[] data)
|
||||
throws GLib.Error {
|
||||
return yield new Plugin.Util.Csv.Reader(
|
||||
return yield new MailMerge.Csv.Reader(
|
||||
new GLib.MemoryInputStream.from_data(data, null)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ int main(string[] args) {
|
|||
}
|
||||
|
||||
GLib.TestSuite root = GLib.TestSuite.get_root();
|
||||
root.add_suite(new Plugin.MailMergeTestReader().suite);
|
||||
root.add_suite(new MailMerge.TestReader().suite);
|
||||
|
||||
GLib.MainLoop loop = new GLib.MainLoop();
|
||||
int ret = -1;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class Plugin.MailMerge :
|
|||
private FolderStore? folder_store = null;
|
||||
private EmailStore? email_store = null;
|
||||
|
||||
private MailMergeFolder? merge_folder = null;
|
||||
private global::MailMerge.Folder? merge_folder = null;
|
||||
|
||||
private GLib.SimpleAction? edit_action = null;
|
||||
private GLib.SimpleAction? merge_action = null;
|
||||
|
|
@ -130,7 +130,9 @@ public class Plugin.MailMerge :
|
|||
try {
|
||||
Geary.Email? email = yield load_merge_email(plugin);
|
||||
if (email != null) {
|
||||
is_merge = MailMergeProcessor.is_mail_merge_template(email);
|
||||
is_merge = global::MailMerge.Processor.is_mail_merge_template(
|
||||
email
|
||||
);
|
||||
}
|
||||
} catch (GLib.Error err) {
|
||||
warning("Unable to load merge template: %s", err.message);
|
||||
|
|
@ -169,7 +171,9 @@ public class Plugin.MailMerge :
|
|||
GLib.Priority.DEFAULT,
|
||||
this.cancellable
|
||||
);
|
||||
var csv = yield new Util.Csv.Reader(csv_input, this.cancellable);
|
||||
var csv = yield new global::MailMerge.Csv.Reader(
|
||||
csv_input, this.cancellable
|
||||
);
|
||||
|
||||
Gee.Collection<Email> emails = yield this.email_store.get_email(
|
||||
Geary.Collection.single(id),
|
||||
|
|
@ -181,7 +185,7 @@ public class Plugin.MailMerge :
|
|||
);
|
||||
var email = Geary.Collection.first(emails);
|
||||
|
||||
this.merge_folder = new Plugin.MailMergeFolder(
|
||||
this.merge_folder = new global::MailMerge.Folder(
|
||||
account_context.account,
|
||||
account_context.account.local_folder_root,
|
||||
yield load_merge_email(email),
|
||||
|
|
@ -298,7 +302,9 @@ public class Plugin.MailMerge :
|
|||
GLib.Priority.DEFAULT,
|
||||
this.cancellable
|
||||
);
|
||||
var csv = yield new Util.Csv.Reader(input, this.cancellable);
|
||||
var csv = yield new global::MailMerge.Csv.Reader(
|
||||
input, this.cancellable
|
||||
);
|
||||
var record = yield csv.read_record();
|
||||
|
||||
var text_fields_menu = new GLib.Menu();
|
||||
|
|
@ -347,19 +353,19 @@ public class Plugin.MailMerge :
|
|||
}
|
||||
|
||||
private void insert_field(Composer composer, string field) {
|
||||
composer.insert_text(MailMergeProcessor.to_field(field));
|
||||
composer.insert_text(global::MailMerge.Processor.to_field(field));
|
||||
}
|
||||
|
||||
private async Geary.Email load_merge_email(Email plugin) throws GLib.Error {
|
||||
Geary.Email? engine = this.client_plugins.to_engine_email(plugin);
|
||||
if (engine != null &&
|
||||
!engine.fields.fulfills(MailMergeProcessor.REQUIRED_FIELDS)) {
|
||||
!engine.fields.fulfills(global::MailMerge.Processor.REQUIRED_FIELDS)) {
|
||||
var account_context = this.client_plugins.to_client_account(
|
||||
plugin.identifier.account
|
||||
);
|
||||
engine = yield account_context.emails.fetch_email_async(
|
||||
engine.id,
|
||||
MailMergeProcessor.REQUIRED_FIELDS,
|
||||
global::MailMerge.Processor.REQUIRED_FIELDS,
|
||||
Geary.Folder.ListFlags.LOCAL_ONLY,
|
||||
this.cancellable
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ plugin_dest = plugins_dir / plugin_name
|
|||
|
||||
lib_src = files(
|
||||
'mail-merge-folder.vala',
|
||||
'mail-merge-csv.vala',
|
||||
'mail-merge-processor.vala',
|
||||
'util-csv.vala',
|
||||
)
|
||||
|
||||
test_src = files(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue