[geary/wip/768975-service-info] Minor cleanup.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/768975-service-info] Minor cleanup.
- Date: Fri, 13 Oct 2017 03:47:51 +0000 (UTC)
commit 2ab6b38adcd6312ac48fb4718ad8275418a99bf9
Author: Michael James Gratton <mike vee net>
Date: Thu Oct 12 20:47:37 2017 -0700
Minor cleanup.
* src/engine/api/geary-account-information.vala
(AccountInformation::from_file): Pass primary email through for default
login when loading credentials.
* src/engine/api/geary-config.vala (Config): Ensure get_string returns a
string with escaping applied, and get_escaped_string doesn't.
* src/engine/api/geary-local-service-information.vala
(ServiceInformation): Don't re-load config key file in load_settings
and load_credentials if it already exists.
src/engine/api/geary-account-information.vala | 4 ++--
src/engine/api/geary-config.vala | 4 ++--
.../api/geary-local-service-information.vala | 14 ++++++++++----
3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index ccee59d..c4c8a57 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -205,8 +205,8 @@ public class Geary.AccountInformation : BaseObject {
}
}
- this.imap.load_credentials(key_file);
- this.smtp.load_credentials(key_file);
+ this.imap.load_credentials(key_file, primary_email);
+ this.smtp.load_credentials(key_file, primary_email);
this.service_provider = Geary.ServiceProvider.from_string(
Config.get_string_value(
diff --git a/src/engine/api/geary-config.vala b/src/engine/api/geary-config.vala
index ec19504..30503ab 100644
--- a/src/engine/api/geary-config.vala
+++ b/src/engine/api/geary-config.vala
@@ -39,7 +39,7 @@ namespace Geary.Config {
public static string get_string_value(KeyFile key_file, string group, string key, string def = "") {
try {
- return key_file.get_value(group, key);
+ return key_file.get_string(group, key);
} catch(KeyFileError err) {
// Ignore.
}
@@ -49,7 +49,7 @@ namespace Geary.Config {
public static string get_escaped_string(KeyFile key_file, string group, string key, string def = "") {
try {
- return key_file.get_string(group, key);
+ return key_file.get_value(group, key);
} catch (KeyFileError err) {
// ignore
}
diff --git a/src/engine/api/geary-local-service-information.vala
b/src/engine/api/geary-local-service-information.vala
index 41bb7dc..aef3bfa 100644
--- a/src/engine/api/geary-local-service-information.vala
+++ b/src/engine/api/geary-local-service-information.vala
@@ -20,14 +20,17 @@ public class Geary.LocalServiceInformation : Geary.ServiceInformation {
this.credentials_method = "METHOD_LIBSECRET";
}
- public override void load_settings(KeyFile? key_file = null) throws Error {
+ public override void load_settings(KeyFile? existing = null) throws Error {
string host_key = "";
string port_key = "";
string use_ssl_key = "";
string use_starttls_key = "";
uint16 default_port = 0;
- key_file.load_from_file(file.get_path() ?? "", KeyFileFlags.NONE);
+ KeyFile key_file = existing ?? new KeyFile();
+ if (existing == null) {
+ key_file.load_from_file(file.get_path() ?? "", KeyFileFlags.NONE);
+ }
switch (service) {
case Geary.Service.IMAP:
@@ -62,11 +65,14 @@ public class Geary.LocalServiceInformation : Geary.ServiceInformation {
key_file, Geary.Config.GROUP, use_starttls_key, this.use_starttls);
}
- public override void load_credentials(KeyFile? key_file = null, string? email_address = null) throws
Error {
+ public override void load_credentials(KeyFile? existing = null, string? email_address = null) throws
Error {
string remember_password_key = "";
string username_key = "";
- key_file.load_from_file(file.get_path() ?? "", KeyFileFlags.NONE);
+ KeyFile key_file = existing ?? new KeyFile();
+ if (existing == null) {
+ key_file.load_from_file(file.get_path() ?? "", KeyFileFlags.NONE);
+ }
switch (this.service) {
case Geary.Service.IMAP:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]