diff options
author | David Zeuthen <davidz@redhat.com> | 2011-05-23 14:54:45 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-05-23 14:54:45 -0400 |
commit | 69af5b2ea2164437ec44e29750fc04179be03923 (patch) | |
tree | 9b204187ccda0521b809080d26950589272f0727 | |
parent | b2910d45e2c44f5ec7f8afbf02b899e4833af390 (diff) |
Make the "Enabled" switches actually work
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | src/goabackend/goagenericmailprovider.c | 45 | ||||
-rw-r--r-- | src/goabackend/goagoogleprovider.c | 43 |
2 files changed, 54 insertions, 34 deletions
diff --git a/src/goabackend/goagenericmailprovider.c b/src/goabackend/goagenericmailprovider.c index fe7a568..59cb3c0 100644 --- a/src/goabackend/goagenericmailprovider.c +++ b/src/goabackend/goagenericmailprovider.c @@ -104,6 +104,7 @@ build_object (GoaProvider *provider, gchar *imap_user_name; gchar *imap_password; gchar *email_address; + gboolean enabled; account = NULL; mail = NULL; @@ -125,25 +126,36 @@ build_object (GoaProvider *provider, account = goa_object_get_account (GOA_OBJECT (object)); /* mail */ - email_address = g_key_file_get_string (key_file, group, "EmailAddress", NULL); - imap_host_and_port = g_key_file_get_string (key_file, group, "ImapHost", NULL); - imap_use_tls = g_key_file_get_boolean (key_file, group, "ImapUseTls", NULL); - imap_ignore_bad_tls = g_key_file_get_boolean (key_file, group, "ImapIgnoreBadTls", NULL); - imap_user_name = g_key_file_get_string (key_file, group, "ImapUserName", NULL); - imap_password = g_key_file_get_string (key_file, group, "ImapPassword", NULL); mail = goa_object_get_mail (GOA_OBJECT (object)); - if (imap_host_and_port != NULL) + enabled = g_key_file_get_boolean (key_file, group, "Enabled", NULL); + if (enabled) { - if (mail == NULL) + email_address = g_key_file_get_string (key_file, group, "EmailAddress", NULL); + imap_host_and_port = g_key_file_get_string (key_file, group, "ImapHost", NULL); + imap_use_tls = g_key_file_get_boolean (key_file, group, "ImapUseTls", NULL); + imap_ignore_bad_tls = g_key_file_get_boolean (key_file, group, "ImapIgnoreBadTls", NULL); + imap_user_name = g_key_file_get_string (key_file, group, "ImapUserName", NULL); + imap_password = g_key_file_get_string (key_file, group, "ImapPassword", NULL); + if (imap_host_and_port != NULL) { - GoaImapAuth *auth; - if (imap_user_name == NULL) - imap_user_name = g_strdup (g_get_user_name ()); - auth = goa_imap_auth_login_new (provider, GOA_OBJECT (object), imap_user_name, imap_password); - mail = goa_imap_mail_new (imap_host_and_port, imap_use_tls, imap_ignore_bad_tls, auth); - goa_object_skeleton_set_mail (object, mail); - g_object_unref (auth); + if (mail == NULL) + { + GoaImapAuth *auth; + if (imap_user_name == NULL) + imap_user_name = g_strdup (g_get_user_name ()); + auth = goa_imap_auth_login_new (provider, GOA_OBJECT (object), imap_user_name, imap_password); + mail = goa_imap_mail_new (imap_host_and_port, imap_use_tls, imap_ignore_bad_tls, auth); + goa_object_skeleton_set_mail (object, mail); + g_object_unref (auth); + } } + else + { + if (mail != NULL) + goa_object_skeleton_set_mail (object, NULL); + } + /* TODO: support substitutions a'la ${USERNAME}@redhat.com for e.g. system-wide .conf files */ + goa_mail_set_email_address (mail, email_address); } else { @@ -151,9 +163,6 @@ build_object (GoaProvider *provider, goa_object_skeleton_set_mail (object, NULL); } - /* TODO: support substitutions a'la ${USERNAME}@redhat.com for e.g. system-wide .conf files */ - goa_mail_set_email_address (mail, email_address); - password_based = goa_object_get_password_based (GOA_OBJECT (object)); if (password_based == NULL) { diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c index f7475fe..393970c 100644 --- a/src/goabackend/goagoogleprovider.c +++ b/src/goabackend/goagoogleprovider.c @@ -245,6 +245,7 @@ build_object (GoaProvider *provider, GoaMail *mail; gboolean ret; gchar *email_address; + gboolean mail_enabled; email_address = NULL; account = NULL; @@ -283,24 +284,34 @@ build_object (GoaProvider *provider, goa_google_account_set_email_address (google_account, email_address); mail = goa_object_get_mail (GOA_OBJECT (object)); - if (mail == NULL) + mail_enabled = g_key_file_get_boolean (key_file, group, "MailEnabled", NULL); + if (mail_enabled) { - GoaImapAuth *auth; - gchar *request_uri; - request_uri = g_strdup_printf ("https://mail.google.com/mail/b/%s/imap/", email_address); - auth = goa_imap_auth_oauth_new (GOA_OAUTH_PROVIDER (provider), - GOA_OBJECT (object), - request_uri); - mail = goa_imap_mail_new ("imap.gmail.com", - TRUE, /* use_tls */ - FALSE, /* ignore_bad_tls */ - auth); - goa_object_skeleton_set_mail (object, mail); - g_object_unref (auth); - g_free (request_uri); - - goa_mail_set_email_address (mail, email_address); + if (mail == NULL) + { + GoaImapAuth *auth; + gchar *request_uri; + request_uri = g_strdup_printf ("https://mail.google.com/mail/b/%s/imap/", email_address); + auth = goa_imap_auth_oauth_new (GOA_OAUTH_PROVIDER (provider), + GOA_OBJECT (object), + request_uri); + mail = goa_imap_mail_new ("imap.gmail.com", + TRUE, /* use_tls */ + FALSE, /* ignore_bad_tls */ + auth); + goa_object_skeleton_set_mail (object, mail); + g_object_unref (auth); + g_free (request_uri); + + goa_mail_set_email_address (mail, email_address); + } } + else + { + if (mail != NULL) + goa_object_skeleton_set_mail (object, NULL); + } + ret = TRUE; |