Geary.Imap.ClientSession: Treat logout as disconnect
Convert `get_protocol_state` to an automatic property, so that rather than requiring explcit signals for lifecycle events, a GObject notify signal can be used instead. Convert disconnect signal to a property so it can be accessed if needed. Convert code listening to the disconnect signal to listen to notify signals for `protocol_state` instead, and hence also treat the session as disconnected when a logout is in progress. Fixes #986
This commit is contained in:
parent
ed4ba33127
commit
41be8693d4
6 changed files with 130 additions and 96 deletions
|
|
@ -44,17 +44,17 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.disconnect_async.begin(null, this.async_completion);
|
||||
test_article.disconnect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
TestServer.Result result = this.server.wait_for_script(this.main_loop);
|
||||
assert_true(
|
||||
|
|
@ -148,13 +148,13 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.login_async.begin(
|
||||
new Credentials(PASSWORD, "test", "password"),
|
||||
|
|
@ -162,11 +162,11 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.async_completion
|
||||
);
|
||||
test_article.login_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == AUTHORIZED);
|
||||
assert_true(test_article.protocol_state == AUTHORIZED);
|
||||
|
||||
test_article.disconnect_async.begin(null, this.async_completion);
|
||||
test_article.disconnect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
TestServer.Result result = this.server.wait_for_script(this.main_loop);
|
||||
assert_true(
|
||||
|
|
@ -185,17 +185,17 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.logout_async.begin(null, this.async_completion);
|
||||
test_article.logout_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
TestServer.Result result = this.server.wait_for_script(this.main_loop);
|
||||
assert_true(
|
||||
|
|
@ -216,13 +216,13 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.login_async.begin(
|
||||
new Credentials(PASSWORD, "test", "password"),
|
||||
|
|
@ -230,11 +230,11 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.async_completion
|
||||
);
|
||||
test_article.login_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == AUTHORIZED);
|
||||
assert_true(test_article.protocol_state == AUTHORIZED);
|
||||
|
||||
test_article.logout_async.begin(null, this.async_completion);
|
||||
test_article.logout_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
TestServer.Result result = this.server.wait_for_script(this.main_loop);
|
||||
assert_true(
|
||||
|
|
@ -261,13 +261,13 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.initiate_session_async.begin(
|
||||
new Credentials(PASSWORD, "test", "password"),
|
||||
|
|
@ -305,13 +305,13 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.initiate_session_async.begin(
|
||||
new Credentials(PASSWORD, "test", "password"),
|
||||
|
|
@ -368,13 +368,13 @@ class Geary.Imap.ClientSessionTest : TestCase {
|
|||
this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
|
||||
|
||||
var test_article = new ClientSession(new_endpoint(), new Quirks());
|
||||
assert_true(test_article.get_protocol_state() == NOT_CONNECTED);
|
||||
assert_true(test_article.protocol_state == NOT_CONNECTED);
|
||||
|
||||
test_article.connect_async.begin(
|
||||
CONNECT_TIMEOUT, null, this.async_completion
|
||||
);
|
||||
test_article.connect_async.end(async_result());
|
||||
assert_true(test_article.get_protocol_state() == UNAUTHORIZED);
|
||||
assert_true(test_article.protocol_state == UNAUTHORIZED);
|
||||
|
||||
test_article.initiate_session_async.begin(
|
||||
new Credentials(PASSWORD, "test", "password"),
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Integration.Imap.ClientSession : TestCase {
|
|||
}
|
||||
|
||||
public override void tear_down() throws GLib.Error {
|
||||
if (this.session.get_protocol_state() != NOT_CONNECTED) {
|
||||
if (this.session.protocol_state != NOT_CONNECTED) {
|
||||
this.session.disconnect_async.begin(null, this.async_completion);
|
||||
this.session.disconnect_async.end(async_result());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue