Fix issue sending from wrong account; fix #6299

This adds an account property to the composer window.  We had been using
the current account, which was problematic if you opened the window,
switched to a folder on a different account, then hit send.
This commit is contained in:
Charles Lindsay 2013-02-01 17:18:11 -08:00
parent c4250b826c
commit 5e9703a1e5
2 changed files with 12 additions and 5 deletions

View file

@ -60,6 +60,8 @@ public class ComposerWindow : Gtk.Window {
// Signal sent when the "Send" button is clicked.
public signal void send(ComposerWindow composer);
public Geary.Account account { get; private set; }
public string from { get; set; }
public string to {
@ -135,7 +137,10 @@ public class ComposerWindow : Gtk.Window {
private Gtk.UIManager ui;
private ContactEntryCompletion[] contact_entry_completions;
public ComposerWindow(Geary.ContactStore? contact_store, Geary.ComposedEmail? prefill = null) {
public ComposerWindow(Geary.Account account, Geary.ContactStore? contact_store,
Geary.ComposedEmail? prefill = null) {
this.account = account;
contact_entry_completions = {
new ContactEntryCompletion(contact_store),
new ContactEntryCompletion(contact_store),

View file

@ -1033,9 +1033,11 @@ public class GearyController {
}
private void create_compose_window(Geary.ComposedEmail? prefill = null) {
Geary.ContactStore? contact_store = (current_account == null ? null
: current_account.get_contact_store());
ComposerWindow window = new ComposerWindow(contact_store, prefill);
if (current_account == null)
return;
Geary.ContactStore? contact_store = current_account.get_contact_store();
ComposerWindow window = new ComposerWindow(current_account, contact_store, prefill);
window.set_position(Gtk.WindowPosition.CENTER);
window.send.connect(on_send);
@ -1169,7 +1171,7 @@ public class GearyController {
}
private void on_send(ComposerWindow composer_window) {
current_account.send_email_async.begin(composer_window.get_composed_email(get_from()));
composer_window.account.send_email_async.begin(composer_window.get_composed_email(get_from()));
composer_window.destroy();
}