From 7e77133bda686959c892be581f3aa58c6da8f4b6 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Sun, 29 Dec 2019 12:32:45 +1030 Subject: [PATCH] Update Geary.Imap.Command API Make the class abstract, since it only gets used by subclases. Allow a null cancellable when waiting for the command to complete. --- src/engine/imap/command/imap-command.vala | 6 +++--- .../imap/transport/imap-client-connection-test.vala | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/engine/imap/command/imap-command.vala b/src/engine/imap/command/imap-command.vala index 570fe3ba..58163671 100644 --- a/src/engine/imap/command/imap-command.vala +++ b/src/engine/imap/command/imap-command.vala @@ -17,7 +17,7 @@ * * See [[http://tools.ietf.org/html/rfc3501#section-6]] */ -public class Geary.Imap.Command : BaseObject { +public abstract class Geary.Imap.Command : BaseObject { /** * Default timeout to wait for a server response for a command. @@ -97,7 +97,7 @@ public class Geary.Imap.Command : BaseObject { * * @see Tag */ - public Command(string name, string[]? args = null) { + protected Command(string name, string[]? args = null) { this.tag = Tag.get_unassigned(); this.name = name; if (args != null) { @@ -250,7 +250,7 @@ public class Geary.Imap.Command : BaseObject { * cancelled, if the command timed out, or if the command's * response was bad. */ - public async void wait_until_complete(GLib.Cancellable cancellable) + public async void wait_until_complete(GLib.Cancellable? cancellable) throws GLib.Error { yield this.complete_lock.wait_async(cancellable); diff --git a/test/engine/imap/transport/imap-client-connection-test.vala b/test/engine/imap/transport/imap-client-connection-test.vala index 56f6029b..c98f0dc5 100644 --- a/test/engine/imap/transport/imap-client-connection-test.vala +++ b/test/engine/imap/transport/imap-client-connection-test.vala @@ -8,6 +8,14 @@ class Geary.Imap.ClientConnectionTest : TestCase { + private class TestCommand : Command { + + public TestCommand() { + base("TEST"); + } + + } + private TestServer? server = null; @@ -88,7 +96,7 @@ class Geary.Imap.ClientConnectionTest : TestCase { assert_true(test_article.is_in_idle(), "Post idle command timeout"); - var command = new Command("TEST"); + var command = new TestCommand(); test_article.send_command(command); command.wait_until_complete.begin(null, this.async_complete_full); command.wait_until_complete.end(async_result()); @@ -121,7 +129,7 @@ class Geary.Imap.ClientConnectionTest : TestCase { test_article.connect_async.begin(null, this.async_complete_full); test_article.connect_async.end(async_result()); - var command = new Command("TEST"); + var command = new TestCommand(); command.response_timed_out.connect(() => { timed_out = true; }); test_article.send_command(command);