Geary.Imap: Make command cancellable a property of the command object
Since both submitting a command no longer requires a cancellable, and it is desirable to avoid sending a queued command that has already been cancelled beforehand, add a new `Command.should_send` Cancellable property to specify if a command should (still) be sent or not, and stop passing a cancellable to ClientSession when submitting commands. Allow call sites to pass in existing cancellable objects, and thus also add it it as a ctor property to the Command class and all subclasses. Lastly, throw a cancelled exception in `wait_until_complete` if send was cancelled so that the caller knows what happened. Remove redundant cancellable argument from `Imap.Client.command_transaction_async` and rename it to `submit_command` to make it more obvious about what it does.
This commit is contained in:
parent
67f0678b1d
commit
85e9046c71
33 changed files with 382 additions and 189 deletions
|
|
@ -16,7 +16,7 @@ class Geary.Imap.CreateCommandTest : TestCase {
|
|||
|
||||
public void basic_create() throws Error {
|
||||
assert_equal(
|
||||
new CreateCommand(new MailboxSpecifier("owatagusiam/")).to_string(),
|
||||
new CreateCommand(new MailboxSpecifier("owatagusiam/"), null).to_string(),
|
||||
"---- create owatagusiam/"
|
||||
);
|
||||
}
|
||||
|
|
@ -25,7 +25,8 @@ class Geary.Imap.CreateCommandTest : TestCase {
|
|||
assert_equal(
|
||||
new CreateCommand.special_use(
|
||||
new MailboxSpecifier("Everything"),
|
||||
ALL_MAIL
|
||||
ALL_MAIL,
|
||||
null
|
||||
).to_string(),
|
||||
"---- create Everything (use (\\All))"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Geary.Imap.FetchCommandTest : TestCase {
|
|||
data_items.add(FetchDataSpecifier.UID);
|
||||
|
||||
assert_equal(
|
||||
new FetchCommand(this.msg_set, data_items, null).to_string(),
|
||||
new FetchCommand(this.msg_set, data_items, null, null).to_string(),
|
||||
"---- fetch 1 uid"
|
||||
);
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ class Geary.Imap.FetchCommandTest : TestCase {
|
|||
);
|
||||
|
||||
assert_equal(
|
||||
new FetchCommand(this.msg_set, null, body_items).to_string(),
|
||||
new FetchCommand(this.msg_set, null, body_items, null).to_string(),
|
||||
"---- fetch 1 body[text]"
|
||||
);
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ class Geary.Imap.FetchCommandTest : TestCase {
|
|||
data_items.add(FetchDataSpecifier.BODY);
|
||||
|
||||
assert_equal(
|
||||
new FetchCommand(this.msg_set, data_items, null).to_string(),
|
||||
new FetchCommand(this.msg_set, data_items, null, null).to_string(),
|
||||
"---- fetch 1 (uid body)"
|
||||
);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ class Geary.Imap.FetchCommandTest : TestCase {
|
|||
);
|
||||
|
||||
assert_equal(
|
||||
new FetchCommand(this.msg_set, null, body_items).to_string(),
|
||||
new FetchCommand(this.msg_set, null, body_items, null).to_string(),
|
||||
"---- fetch 1 (body[header] body[text])"
|
||||
);
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class Geary.Imap.FetchCommandTest : TestCase {
|
|||
);
|
||||
|
||||
assert_equal(
|
||||
new FetchCommand(this.msg_set, data_items, body_items).to_string(),
|
||||
new FetchCommand(this.msg_set, data_items, body_items, null).to_string(),
|
||||
"---- fetch 1 (uid flags body[header] body[text])"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Geary.Imap.ClientConnectionTest : TestCase {
|
|||
private class TestCommand : Command {
|
||||
|
||||
public TestCommand() {
|
||||
base("TEST");
|
||||
base("TEST", null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue