Clean up Geary.Protocol string management
This commit is contained in:
parent
3049837973
commit
e794c8522c
2 changed files with 13 additions and 14 deletions
|
|
@ -68,7 +68,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
|
|||
debug(
|
||||
"Unable to fetch libsecret password for %s: %s %s",
|
||||
account.id,
|
||||
service.protocol.to_string(),
|
||||
to_proto_value(service.protocol),
|
||||
service.credentials.user
|
||||
);
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
|
|||
debug(
|
||||
"Unable to store libsecret password for %s: %s %s",
|
||||
account.id,
|
||||
service.protocol.to_string(),
|
||||
to_proto_value(service.protocol),
|
||||
service.credentials.user
|
||||
);
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
|
|||
SecretMediator.schema,
|
||||
new_attrs(service),
|
||||
Secret.COLLECTION_DEFAULT,
|
||||
"Geary %s password".printf(service.protocol.to_value()),
|
||||
"Geary %s password".printf(to_proto_value(service.protocol)),
|
||||
password,
|
||||
cancellable
|
||||
);
|
||||
|
|
@ -211,12 +211,16 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
|
|||
HashTable<string,string> table = new HashTable<string,string>(
|
||||
str_hash, str_equal
|
||||
);
|
||||
table.insert(ATTR_PROTO, service.protocol.to_value());
|
||||
table.insert(ATTR_PROTO, to_proto_value(service.protocol));
|
||||
table.insert(ATTR_HOST, service.host);
|
||||
table.insert(ATTR_LOGIN, service.credentials.user);
|
||||
return table;
|
||||
}
|
||||
|
||||
private inline string to_proto_value(Geary.Protocol protocol) {
|
||||
return protocol.to_value().ascii_up();
|
||||
}
|
||||
|
||||
private async string? migrate_old_password(Geary.ServiceInformation service,
|
||||
GLib.Cancellable? cancellable)
|
||||
throws GLib.Error {
|
||||
|
|
|
|||
|
|
@ -15,20 +15,15 @@ public enum Geary.Protocol {
|
|||
|
||||
public static Protocol for_value(string value)
|
||||
throws EngineError {
|
||||
switch (value.ascii_up()) {
|
||||
case "IMAP":
|
||||
return IMAP;
|
||||
case "SMTP":
|
||||
return SMTP;
|
||||
}
|
||||
throw new EngineError.BAD_PARAMETERS(
|
||||
"Unknown Protocol value: %s", value
|
||||
return ObjectUtils.from_enum_nick<Protocol>(
|
||||
typeof(Protocol), value.ascii_down()
|
||||
);
|
||||
}
|
||||
|
||||
public string to_value() {
|
||||
string value = to_string();
|
||||
return value.substring(value.last_index_of("_") + 1);
|
||||
return ObjectUtils.to_enum_nick<Protocol>(
|
||||
typeof(Protocol), this
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue