Merge branch 'mjog/931-cannot-remove-accounts' into 'mainline'
Cannot remove accounts Closes #931 See merge request GNOME/geary!550
This commit is contained in:
commit
fe269267a3
4 changed files with 37 additions and 52 deletions
|
|
@ -50,7 +50,7 @@ valac = meson.get_compiler('vala')
|
|||
# Required libraries and other dependencies
|
||||
#
|
||||
|
||||
target_vala = '0.46.2'
|
||||
target_vala = '0.48.6'
|
||||
target_glib = '2.60.4'
|
||||
target_gtk = '3.24.7'
|
||||
target_webkit = '2.26'
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public class Accounts.Manager : GLib.Object {
|
|||
* restore_account}.
|
||||
*/
|
||||
public async void remove_account(Geary.AccountInformation account,
|
||||
GLib.Cancellable cancellable)
|
||||
GLib.Cancellable? cancellable)
|
||||
throws GLib.Error {
|
||||
this.accounts.unset(account.id);
|
||||
this.removed.add(account);
|
||||
|
|
@ -324,7 +324,7 @@ public class Accounts.Manager : GLib.Object {
|
|||
* he account was removed.
|
||||
*/
|
||||
public async void restore_account(Geary.AccountInformation account,
|
||||
GLib.Cancellable cancellable)
|
||||
GLib.Cancellable? cancellable)
|
||||
throws GLib.Error {
|
||||
if (this.removed.remove(account)) {
|
||||
yield save_account(account, cancellable);
|
||||
|
|
|
|||
|
|
@ -1184,11 +1184,14 @@ public class Application.Client : Gtk.Application {
|
|||
private void on_activate_new_window() {
|
||||
// If there was an existing active main, select the same
|
||||
// account/folder/conversation.
|
||||
Geary.Folder? folder = null;
|
||||
Gee.Collection<Geary.App.Conversation>? conversations = null;
|
||||
MainWindow? current = this.last_active_main_window;
|
||||
this.new_window.begin(
|
||||
current.selected_folder,
|
||||
current.conversation_list_view.copy_selected()
|
||||
);
|
||||
if (current != null) {
|
||||
folder = current.selected_folder;
|
||||
conversations = current.conversation_list_view.copy_selected();
|
||||
}
|
||||
this.new_window.begin(folder, conversations);
|
||||
}
|
||||
|
||||
private void on_activate_preferences() {
|
||||
|
|
|
|||
|
|
@ -947,6 +947,16 @@ internal class Application.Controller :
|
|||
}
|
||||
}
|
||||
|
||||
private void add_account(Geary.AccountInformation added) {
|
||||
try {
|
||||
this.application.engine.add_account(added);
|
||||
} catch (Geary.EngineError.ALREADY_EXISTS err) {
|
||||
// all good
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(new Geary.AccountProblemReport(added, err));
|
||||
}
|
||||
}
|
||||
|
||||
private async void open_account(Geary.Account account) {
|
||||
AccountContext context = new AccountContext(
|
||||
account,
|
||||
|
|
@ -1012,6 +1022,19 @@ internal class Application.Controller :
|
|||
update_account_status();
|
||||
}
|
||||
|
||||
private async void remove_account(Geary.AccountInformation removed) {
|
||||
yield close_account(removed, false);
|
||||
try {
|
||||
this.application.engine.remove_account(removed);
|
||||
} catch (Geary.EngineError.NOT_FOUND err) {
|
||||
// all good
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(
|
||||
new Geary.AccountProblemReport(removed, err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async void close_account(Geary.AccountInformation config,
|
||||
bool is_shutdown) {
|
||||
AccountContext? context = this.accounts.get(config);
|
||||
|
|
@ -1540,11 +1563,7 @@ internal class Application.Controller :
|
|||
private void on_account_added(Geary.AccountInformation added,
|
||||
Accounts.Manager.Status status) {
|
||||
if (status == Accounts.Manager.Status.ENABLED) {
|
||||
try {
|
||||
this.application.engine.add_account(added);
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(new Geary.AccountProblemReport(added, err));
|
||||
}
|
||||
this.add_account(added);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1552,33 +1571,12 @@ internal class Application.Controller :
|
|||
Accounts.Manager.Status status) {
|
||||
switch (status) {
|
||||
case Accounts.Manager.Status.ENABLED:
|
||||
if (!this.application.engine.has_account(changed)) {
|
||||
try {
|
||||
this.application.engine.add_account(changed);
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(new Geary.AccountProblemReport(changed, err));
|
||||
}
|
||||
}
|
||||
this.add_account(changed);
|
||||
break;
|
||||
|
||||
case Accounts.Manager.Status.UNAVAILABLE:
|
||||
case Accounts.Manager.Status.DISABLED:
|
||||
if (this.application.engine.has_account(changed)) {
|
||||
this.close_account.begin(
|
||||
changed,
|
||||
false,
|
||||
(obj, res) => {
|
||||
this.close_account.end(res);
|
||||
try {
|
||||
this.application.engine.remove_account(changed);
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(
|
||||
new Geary.AccountProblemReport(changed, err)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
this.remove_account.begin(changed);
|
||||
break;
|
||||
|
||||
case Accounts.Manager.Status.REMOVED:
|
||||
|
|
@ -1588,23 +1586,7 @@ internal class Application.Controller :
|
|||
}
|
||||
|
||||
private void on_account_removed(Geary.AccountInformation removed) {
|
||||
debug("%s: Closing account for removal", removed.id);
|
||||
this.close_account.begin(
|
||||
removed,
|
||||
false,
|
||||
(obj, res) => {
|
||||
this.close_account.end(res);
|
||||
debug("%s: Account closed", removed.id);
|
||||
try {
|
||||
this.application.engine.remove_account(removed);
|
||||
debug("%s: Account removed from engine", removed.id);
|
||||
} catch (GLib.Error err) {
|
||||
report_problem(
|
||||
new Geary.AccountProblemReport(removed, err)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
this.remove_account.begin(removed);
|
||||
}
|
||||
|
||||
private void on_report_problem(Geary.ProblemReport problem) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue