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.
This commit is contained in:
Michael Gratton 2019-12-29 12:32:45 +10:30 committed by Michael James Gratton
parent cc5efc5f98
commit 7e77133bda
2 changed files with 13 additions and 5 deletions

View file

@ -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);

View file

@ -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);