Move endpoints from account config to implementation objects (1/3)
This removes Endpoint from ServiceInformation and moves it to a new ClientService class, since ServiceInformation is for apps to provide configuration, and Endpoints are effectively implementation detail. The new ClientService class is in effect an analoge to ServiceInformation in the same way as Account is to AccountInformation, and so this is a better place to store an account's endpoints. Two instances have been added to Account as `incoming` and `outgoing` properties instead of imap and SMTP to be a bit more generic and with an eye to supporting other protocols in the future. This is possble to implement now non-generic providers are populating ServiceInformation classes rather than Endpoints directly, and reduces the complexity of the code needed to manage endpoints since all of the untrusted_host callback complexity in AccountInformation and the Engine can be removed, and will also allow simplifing credentials and SMTP codepaths somewhat. This work has been broken up in to thee parts to make the changes clearer.
This commit is contained in:
parent
ed14156e17
commit
e760b074a2
15 changed files with 338 additions and 226 deletions
|
|
@ -31,8 +31,38 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
}
|
||||
|
||||
|
||||
public class MockClientService : ClientService {
|
||||
|
||||
public MockClientService(AccountInformation account,
|
||||
ServiceInformation service) {
|
||||
base(account, service);
|
||||
}
|
||||
|
||||
public override async void start(GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
public override async void stop(GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override bool is_online { get; protected set; default = false; }
|
||||
|
||||
public override ClientService incoming {
|
||||
get { return this.incoming; }
|
||||
}
|
||||
private ClientService _incoming;
|
||||
|
||||
public override ClientService outgoing {
|
||||
get { return this._outgoing; }
|
||||
}
|
||||
private ClientService _outgoing;
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
}
|
||||
|
|
@ -40,6 +70,12 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
|
||||
public MockAccount(string name, AccountInformation information) {
|
||||
base(name, information);
|
||||
this._incoming = new MockClientService(
|
||||
this.information, this.information.imap
|
||||
);
|
||||
this._outgoing = new MockClientService(
|
||||
this.information, this.information.smtp
|
||||
);
|
||||
}
|
||||
|
||||
public override async void open_async(Cancellable? cancellable = null) throws Error {
|
||||
|
|
@ -62,21 +98,14 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
void_call("rebuild_async", { cancellable });
|
||||
}
|
||||
|
||||
public override async void start_outgoing_client()
|
||||
throws Error {
|
||||
void_call("start_outgoing_client", {});
|
||||
}
|
||||
|
||||
public override async void start_incoming_client()
|
||||
throws Error {
|
||||
void_call("start_incoming_client", {});
|
||||
}
|
||||
|
||||
public override Gee.Collection<Folder> list_matching_folders(FolderPath? parent)
|
||||
throws Error {
|
||||
return object_call<Gee.Collection<Folder>>(
|
||||
"get_containing_folders_async", {parent}, Gee.List.empty<Folder>()
|
||||
);
|
||||
public override Gee.Collection<Folder> list_matching_folders(FolderPath? parent) {
|
||||
try {
|
||||
return object_call<Gee.Collection<Folder>>(
|
||||
"get_containing_folders_async", {parent}, Gee.List.empty<Folder>()
|
||||
);
|
||||
} catch (GLib.Error err) {
|
||||
return Gee.Collection.empty<Folder>();
|
||||
}
|
||||
}
|
||||
|
||||
public override Gee.Collection<Folder> list_folders() throws Error {
|
||||
|
|
@ -205,4 +234,12 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
);
|
||||
}
|
||||
|
||||
internal override void set_endpoints(Endpoint incoming, Endpoint outgoing) {
|
||||
try {
|
||||
void_call("set_endpoints", {incoming, outgoing});
|
||||
} catch (GLib.Error err) {
|
||||
// oh well
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue