diff options
author | David Zeuthen <davidz@redhat.com> | 2011-05-25 15:54:03 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-05-25 15:54:03 -0400 |
commit | c6b207076a7dec3ced76bae4641f522845af6fe0 (patch) | |
tree | 6f46410dd0cac2565e46877b9996a9a8014b00f6 | |
parent | 704c2609b81199fe9474730976accb25ab96143d (diff) |
Add properties for the IMAP and SMTP servers
This should enable e.g. Evolution to actually use this data.
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | data/dbus-interfaces.xml | 69 | ||||
-rw-r--r-- | doc/goa-docs.xml | 3 | ||||
-rw-r--r-- | doc/goa-sections.txt | 48 | ||||
-rw-r--r-- | doc/goa.types | 2 | ||||
-rw-r--r-- | src/goabackend/Makefile.am | 4 | ||||
-rw-r--r-- | src/goabackend/goabackend.h | 2 | ||||
-rw-r--r-- | src/goabackend/goabackendtypes.h | 4 | ||||
-rw-r--r-- | src/goabackend/goagenericmailprovider.c | 58 | ||||
-rw-r--r-- | src/goabackend/goagoogleprovider.c | 25 | ||||
-rw-r--r-- | src/goabackend/goainternetmail.c (renamed from src/goabackend/goaimapmail.c) | 262 | ||||
-rw-r--r-- | src/goabackend/goainternetmail.h (renamed from src/goabackend/goaimapmail.h) | 28 | ||||
-rw-r--r-- | src/goabackend/goaprovider.c | 8 |
12 files changed, 329 insertions, 184 deletions
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml index 9aef07b..3bd95b3 100644 --- a/data/dbus-interfaces.xml +++ b/data/dbus-interfaces.xml @@ -338,6 +338,75 @@ format. --> <property name="EmailAddress" type="s" access="read"/> + + <!-- ImapSupported: + Set to %TRUE if the messages for the account can be accessed + and manipulated using the + <ulink url="http://tools.ietf.org/html/rfc3501">IMAP</ulink> + protocol. + --> + <property name="ImapSupported" type="b" access="read"/> + + <!-- ImapHost: + The IMAP server to use. + + This may be in any of a number of recognized formats; an IPv6 + address, an IPv4 address, or a domain name. A port override + may be specified in the usual way with a colon. Ports may be + given as decimal numbers or symbolic names + (cf. the <filename>/etc/services</filename> file). + + If a port override is not given, then applications should try + to connect to port 993 if + #org.gnome.OnlineAccounts.Mail:ImapUseTls is %TRUE and port + 143 if not. + --> + <property name="ImapHost" type="s" access="read"/> + + <!-- ImapUseTls: Whether TLS should be used to establish the connection. --> + <property name="ImapUseTls" type="b" access="read"/> + + <!-- ImapUserName: + The user name to use for logging in. + + This may be blank if username/password authentication isn't + used or if the user name of the current user should be used. + --> + <property name="ImapUserName" type="s" access="read"/> + + <!-- SmtpSupported: + Set to %TRUE if the + <ulink url="http://tools.ietf.org/html/rfc5321">SMTP</ulink> + protocol can be used to send messages for the account. + --> + <property name="SmtpSupported" type="b" access="read"/> + + <!-- SmtpHost: + The SMTP server to use. + + This may be in any of a number of recognized formats; an IPv6 + address, an IPv4 address, or a domain name. A port override + may be specified in the usual way with a colon. Ports may be + given as decimal numbers or symbolic names + (cf. the <filename>/etc/services</filename> file). + + If a port override is not given, then applications should try + to connect to port 465 if + #org.gnome.OnlineAccounts.Mail:SmtpUseTls is %TRUE and port + 587 (or 25) if not. + --> + <property name="SmtpHost" type="s" access="read"/> + + <!-- SmtpUseTls: Whether TLS should be used to establish the connection. --> + <property name="SmtpUseTls" type="b" access="read"/> + + <!-- SmtpUserName: + The user name to use for logging in. + + This may be blank if username/password authentication isn't + used or if the user name of the current user should be used. + --> + <property name="SmtpUserName" type="s" access="read"/> </interface> <!-- diff --git a/doc/goa-docs.xml b/doc/goa-docs.xml index 9596c3e..645d828 100644 --- a/doc/goa-docs.xml +++ b/doc/goa-docs.xml @@ -134,6 +134,7 @@ <part id="ref-backend-library"> <title>Backend Library API Reference</title> <xi:include href="xml/goalog.xml"/> + <xi:include href="xml/goautil.xml"/> <xi:include href="xml/goaprovider.xml"/> <xi:include href="xml/goagenericmailprovider.xml"/> <xi:include href="xml/goaoauthprovider.xml"/> @@ -146,7 +147,7 @@ <xi:include href="xml/goaimapauthlogin.xml"/> <xi:include href="xml/goaimapauthoauth.xml"/> <xi:include href="xml/goaimapclient.xml"/> - <xi:include href="xml/goaimapmail.xml"/> + <xi:include href="xml/goainternetmail.xml"/> </part> <part id="tools-fileformats"> diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt index c253157..9bafcfc 100644 --- a/doc/goa-sections.txt +++ b/doc/goa-sections.txt @@ -124,6 +124,10 @@ goa_account_get_attention_needed goa_account_set_attention_needed goa_account_get_name goa_account_set_name +goa_account_get_keyfile_group +goa_account_set_keyfile_group +goa_account_get_keyfile_path +goa_account_set_keyfile_path goa_account_call_set_name goa_account_call_set_name_finish goa_account_call_set_name_sync @@ -666,6 +670,7 @@ goa_twitter_provider_get_type <FILE>GoaMail</FILE> GoaMail GoaMailIface +goa_mail_override_properties goa_mail_interface_info goa_mail_call_create_monitor goa_mail_call_create_monitor_finish @@ -673,6 +678,22 @@ goa_mail_call_create_monitor_sync goa_mail_complete_create_monitor goa_mail_get_email_address goa_mail_set_email_address +goa_mail_get_imap_host +goa_mail_set_imap_host +goa_mail_get_imap_supported +goa_mail_set_imap_supported +goa_mail_get_imap_use_tls +goa_mail_set_imap_use_tls +goa_mail_get_imap_user_name +goa_mail_set_imap_user_name +goa_mail_get_smtp_host +goa_mail_get_smtp_supported +goa_mail_set_smtp_supported +goa_mail_set_smtp_host +goa_mail_get_smtp_use_tls +goa_mail_set_smtp_use_tls +goa_mail_get_smtp_user_name +goa_mail_set_smtp_user_name GoaMailProxy GoaMailProxyClass goa_mail_proxy_new @@ -776,14 +797,14 @@ goa_imap_client_get_type </SECTION> <SECTION> -<FILE>goaimapmail</FILE> -GoaImapMail -goa_imap_mail_new +<FILE>goainternetmail</FILE> +GoaInternetMail +goa_internet_mail_new <SUBSECTION Standard> -GOA_IMAP_MAIL -GOA_IS_IMAP_MAIL -GOA_TYPE_IMAP_MAIL -goa_imap_mail_get_type +GOA_INTERNET_MAIL +GOA_IS_INTERNET_MAIL +GOA_TYPE_INTERNET_MAIL +goa_internet_mail_get_type </SECTION> <SECTION> @@ -836,3 +857,16 @@ goa_warning goa_error <SUBSECTION Standard> </SECTION> + +<SECTION> +<FILE>goautil</FILE> +goa_util_add_heading +goa_util_add_row_check_button_from_keyfile +goa_util_add_row_editable_label_from_keyfile +goa_util_add_row_label +goa_util_add_row_switch_from_keyfile +goa_util_add_row_widget +goa_util_lookup_keyfile_boolean +goa_util_lookup_keyfile_string +<SUBSECTION Standard> +</SECTION> diff --git a/doc/goa.types b/doc/goa.types index 65e400b..7174895 100644 --- a/doc/goa.types +++ b/doc/goa.types @@ -43,4 +43,4 @@ goa_imap_auth_get_type goa_imap_auth_login_get_type goa_imap_auth_oauth_get_type goa_imap_client_get_type -goa_imap_mail_get_type +goa_internet_mail_get_type diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am index 1e7f2ad..d8b9855 100644 --- a/src/goabackend/Makefile.am +++ b/src/goabackend/Makefile.am @@ -57,7 +57,7 @@ libgoa_backend_1_0_la_HEADERS = \ goaimapauthlogin.h \ goaimapauthoauth.h \ goaimapclient.h \ - goaimapmail.h \ + goainternetmail.h \ $(NULL) libgoa_backend_1_0_la_SOURCES = \ @@ -79,7 +79,7 @@ libgoa_backend_1_0_la_SOURCES = \ goaimapauthlogin.h goaimapauthlogin.c \ goaimapauthoauth.h goaimapauthoauth.c \ goaimapclient.h goaimapclient.c \ - goaimapmail.h goaimapmail.c \ + goainternetmail.h goainternetmail.c \ $(NULL) libgoa_backend_1_0_la_CPPFLAGS = \ diff --git a/src/goabackend/goabackend.h b/src/goabackend/goabackend.h index f5d177b..be0f136 100644 --- a/src/goabackend/goabackend.h +++ b/src/goabackend/goabackend.h @@ -43,7 +43,7 @@ #include <goabackend/goaimapauthlogin.h> #include <goabackend/goaimapauthoauth.h> #include <goabackend/goaimapclient.h> -#include <goabackend/goaimapmail.h> +#include <goabackend/goainternetmail.h> #undef __GOA_BACKEND_INSIDE_GOA_BACKEND_H__ #endif /* __GOA_BACKEND_H__ */ diff --git a/src/goabackend/goabackendtypes.h b/src/goabackend/goabackendtypes.h index 310bb00..46e4438 100644 --- a/src/goabackend/goabackendtypes.h +++ b/src/goabackend/goabackendtypes.h @@ -69,8 +69,8 @@ typedef struct _GoaImapAuthOAuth GoaImapAuthOAuth; struct _GoaImapClient; typedef struct _GoaImapClient GoaImapClient; -struct _GoaImapMail; -typedef struct _GoaImapMail GoaImapMail; +struct _GoaInternetMail; +typedef struct _GoaInternetMail GoaInternetMail; struct _GoaEditableLabel; typedef struct _GoaEditableLabel GoaEditableLabel; diff --git a/src/goabackend/goagenericmailprovider.c b/src/goabackend/goagenericmailprovider.c index 59cb3c0..35e25e1 100644 --- a/src/goabackend/goagenericmailprovider.c +++ b/src/goabackend/goagenericmailprovider.c @@ -30,7 +30,7 @@ #include "goaimapauthlogin.h" #include "goaeditablelabel.h" -#include "goaimapmail.h" +#include "goainternetmail.h" /** * GoaGenericMailProvider: @@ -98,21 +98,29 @@ build_object (GoaProvider *provider, GoaMail *mail; GoaPasswordBased *password_based; gboolean ret; - gchar *imap_host_and_port; - gboolean imap_use_tls; - gboolean imap_ignore_bad_tls; + gchar *email_address; + gchar *imap_host; gchar *imap_user_name; gchar *imap_password; - gchar *email_address; + gboolean imap_use_tls; + gboolean imap_ignore_bad_tls; + gchar *smtp_host; + gchar *smtp_user_name; + gchar *smtp_password; + gboolean smtp_use_tls; + gboolean smtp_ignore_bad_tls; gboolean enabled; account = NULL; mail = NULL; password_based = NULL; - imap_host_and_port = NULL; + email_address = NULL; + imap_host = NULL; imap_user_name = NULL; imap_password = NULL; - email_address = NULL; + smtp_host = NULL; + smtp_user_name = NULL; + smtp_password = NULL; ret = FALSE; /* Chain up */ @@ -131,22 +139,37 @@ build_object (GoaProvider *provider, if (enabled) { 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_host = g_key_file_get_string (key_file, group, "ImapHost", 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) + 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); + + smtp_host = g_key_file_get_string (key_file, group, "SmtpHost", NULL); + smtp_user_name = g_key_file_get_string (key_file, group, "SmtpUserName", NULL); + smtp_password = g_key_file_get_string (key_file, group, "SmtpPassword", NULL); + smtp_use_tls = g_key_file_get_boolean (key_file, group, "SmtpUseTls", NULL); + smtp_ignore_bad_tls = g_key_file_get_boolean (key_file, group, "SmtpIgnoreBadTls", NULL); + if (imap_host != NULL && smtp_host != NULL) { if (mail == NULL) { - GoaImapAuth *auth; + GoaImapAuth *imap_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); + imap_auth = goa_imap_auth_login_new (provider, GOA_OBJECT (object), imap_user_name, imap_password); + mail = goa_internet_mail_new (imap_host, + imap_user_name, + imap_use_tls, + imap_ignore_bad_tls, + imap_auth, + smtp_host, + smtp_user_name, + smtp_use_tls, + smtp_ignore_bad_tls); goa_object_skeleton_set_mail (object, mail); - g_object_unref (auth); + g_object_unref (imap_auth); } } else @@ -185,9 +208,12 @@ build_object (GoaProvider *provider, g_object_unref (password_based); if (mail != NULL) g_object_unref (mail); - g_free (imap_host_and_port); + g_free (imap_host); g_free (imap_user_name); g_free (imap_password); + g_free (smtp_host); + g_free (smtp_user_name); + g_free (smtp_password); if (account != NULL) g_object_unref (account); return ret; diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c index 393970c..ed5c63d 100644 --- a/src/goabackend/goagoogleprovider.c +++ b/src/goabackend/goagoogleprovider.c @@ -30,7 +30,7 @@ #include "goaoauthprovider.h" #include "goagoogleprovider.h" -#include "goaimapmail.h" +#include "goainternetmail.h" #include "goaimapauthoauth.h" /** @@ -289,18 +289,23 @@ build_object (GoaProvider *provider, { if (mail == NULL) { - GoaImapAuth *auth; + GoaImapAuth *imap_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); + imap_auth = goa_imap_auth_oauth_new (GOA_OAUTH_PROVIDER (provider), + GOA_OBJECT (object), + request_uri); + mail = goa_internet_mail_new ("imap.gmail.com", + "", /* user_name */ + TRUE, /* use_tls */ + FALSE, /* ignore_bad_tls */ + imap_auth, + "smtp.gmail.com", + "", /* user_name */ + TRUE, /* use_tls */ + FALSE); /* ignore_bad_tls */ goa_object_skeleton_set_mail (object, mail); - g_object_unref (auth); + g_object_unref (imap_auth); g_free (request_uri); goa_mail_set_email_address (mail, email_address); diff --git a/src/goabackend/goaimapmail.c b/src/goabackend/goainternetmail.c index e7f599d..31e74a2 100644 --- a/src/goabackend/goaimapmail.c +++ b/src/goabackend/goainternetmail.c @@ -31,28 +31,28 @@ #include "goalogging.h" #include "goaimapauth.h" #include "goaimapclient.h" -#include "goaimapmail.h" +#include "goainternetmail.h" /** - * GoaImapMail: + * GoaInternetMail: * - * The #GoaImapMail structure contains only private data and should + * The #GoaInternetMail structure contains only private data and should * only be accessed using the provided API. */ -struct _GoaImapMail +struct _GoaInternetMail { /*< private >*/ GoaMailSkeleton parent_instance; - gchar *host_and_port; - gboolean use_tls; - gboolean ignore_bad_tls; - GoaImapAuth *auth; + gboolean imap_ignore_bad_tls; + GoaImapAuth *imap_auth; + + gboolean smtp_ignore_bad_tls; }; -typedef struct _GoaImapMailClass GoaImapMailClass; +typedef struct _GoaInternetMailClass GoaInternetMailClass; -struct _GoaImapMailClass +struct _GoaInternetMailClass { GoaMailSkeletonClass parent_class; }; @@ -60,64 +60,57 @@ struct _GoaImapMailClass enum { PROP_0, - PROP_HOST_AND_PORT, - PROP_USE_TLS, - PROP_IGNORE_BAD_TLS, - PROP_AUTH + PROP_IMAP_IGNORE_BAD_TLS, + PROP_IMAP_AUTH, + PROP_SMTP_IGNORE_BAD_TLS }; /** - * SECTION:goaimapmail - * @title: GoaImapMail - * @short_description: Implementation of the #GoaMail interface for IMAP servers + * SECTION:goainternetmail + * @title: GoaInternetMail + * @short_description: Implementation of the #GoaMail interface for standards-based Internet Mail. * - * #GoaImapMail is an implementation of the #GoaMail D-Bus - * interface that uses a #GoaImapClient instance to speak to a - * remote IMAP server. + * #GoaInternetMail is an implementation of the #GoaMail D-Bus + * interface for IMAP and SMTP servers. */ -static void goa_imap_mail__goa_mail_iface_init (GoaMailIface *iface); +static void goa_internet_mail__goa_mail_iface_init (GoaMailIface *iface); -G_DEFINE_TYPE_WITH_CODE (GoaImapMail, goa_imap_mail, GOA_TYPE_MAIL_SKELETON, - G_IMPLEMENT_INTERFACE (GOA_TYPE_MAIL, goa_imap_mail__goa_mail_iface_init)); +G_DEFINE_TYPE_WITH_CODE (GoaInternetMail, goa_internet_mail, GOA_TYPE_MAIL_SKELETON, + G_IMPLEMENT_INTERFACE (GOA_TYPE_MAIL, goa_internet_mail__goa_mail_iface_init)); /* ---------------------------------------------------------------------------------------------------- */ static void -goa_imap_mail_finalize (GObject *object) +goa_internet_mail_finalize (GObject *object) { - GoaImapMail *mail = GOA_IMAP_MAIL (object); + GoaInternetMail *mail = GOA_INTERNET_MAIL (object); - g_free (mail->host_and_port); - g_object_unref (mail->auth); + g_object_unref (mail->imap_auth); - G_OBJECT_CLASS (goa_imap_mail_parent_class)->finalize (object); + G_OBJECT_CLASS (goa_internet_mail_parent_class)->finalize (object); } static void -goa_imap_mail_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +goa_internet_mail_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - GoaImapMail *mail = GOA_IMAP_MAIL (object); + GoaInternetMail *mail = GOA_INTERNET_MAIL (object); switch (prop_id) { - case PROP_HOST_AND_PORT: - g_value_set_string (value, mail->host_and_port); - break; - - case PROP_USE_TLS: - g_value_set_boolean (value, mail->use_tls); + case PROP_IMAP_IGNORE_BAD_TLS: + g_value_set_boolean (value, mail->imap_ignore_bad_tls); break; - case PROP_IGNORE_BAD_TLS: - g_value_set_boolean (value, mail->ignore_bad_tls); + case PROP_IMAP_AUTH: + g_value_set_object (value, mail->imap_auth); break; - case PROP_AUTH: - g_value_set_object (value, mail->auth); + case PROP_SMTP_IGNORE_BAD_TLS: + g_value_set_boolean (value, mail->smtp_ignore_bad_tls); break; default: @@ -127,29 +120,25 @@ goa_imap_mail_get_property (GObject *object, } static void -goa_imap_mail_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +goa_internet_mail_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - GoaImapMail *mail = GOA_IMAP_MAIL (object); + GoaInternetMail *mail = GOA_INTERNET_MAIL (object); switch (prop_id) { - case PROP_HOST_AND_PORT: - mail->host_and_port = g_value_dup_string (value); + case PROP_IMAP_IGNORE_BAD_TLS: + mail->imap_ignore_bad_tls = g_value_get_boolean (value); break; - case PROP_USE_TLS: - mail->use_tls = g_value_get_boolean (value); + case PROP_IMAP_AUTH: + mail->imap_auth = g_value_dup_object (value); break; - case PROP_IGNORE_BAD_TLS: - mail->ignore_bad_tls = g_value_get_boolean (value); - break; - - case PROP_AUTH: - mail->auth = g_value_dup_object (value); + case PROP_SMTP_IGNORE_BAD_TLS: + mail->smtp_ignore_bad_tls = g_value_get_boolean (value); break; default: @@ -159,7 +148,7 @@ goa_imap_mail_set_property (GObject *object, } static void -goa_imap_mail_init (GoaImapMail *mail) +goa_internet_mail_init (GoaInternetMail *mail) { /* Ensure D-Bus method invocations run in their own thread */ g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (mail), @@ -167,85 +156,92 @@ goa_imap_mail_init (GoaImapMail *mail) } static void -goa_imap_mail_class_init (GoaImapMailClass *klass) +goa_internet_mail_class_init (GoaInternetMailClass *klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = goa_imap_mail_finalize; - gobject_class->set_property = goa_imap_mail_set_property; - gobject_class->get_property = goa_imap_mail_get_property; - - g_object_class_install_property (gobject_class, - PROP_HOST_AND_PORT, - g_param_spec_string ("host-and-port", - "host-and-port", - "host-and-port", - NULL, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, - PROP_USE_TLS, - g_param_spec_boolean ("use-tls", - "use-tls", - "use-tls", - TRUE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + gobject_class->finalize = goa_internet_mail_finalize; + gobject_class->set_property = goa_internet_mail_set_property; + gobject_class->get_property = goa_internet_mail_get_property; g_object_class_install_property (gobject_class, - PROP_IGNORE_BAD_TLS, - g_param_spec_boolean ("ignore-bad-tls", - "ignore-bad-tls", - "ignore-bad-tls", - TRUE, + PROP_IMAP_IGNORE_BAD_TLS, + g_param_spec_boolean ("imap-ignore-bad-tls", + "imap-ignore-bad-tls", + "imap-ignore-bad-tls", + FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, - PROP_AUTH, - g_param_spec_object ("auth", - "auth", - "auth", + PROP_IMAP_AUTH, + g_param_spec_object ("imap-auth", + "imap-auth", + "imap-auth", GOA_TYPE_IMAP_AUTH, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + PROP_SMTP_IGNORE_BAD_TLS, + g_param_spec_boolean ("smtp-ignore-bad-tls", + "smtp-ignore-bad-tls", + "smtp-ignore-bad-tls", + FALSE, + G_PARAM_READABLE | + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + } /* ---------------------------------------------------------------------------------------------------- */ /** - * goa_imap_mail_new: - * @host_and_port: The name and optionally port to connect to. - * @use_tls: Whether TLS should be used. - * @ignore_bad_tls: Whether errors (e.g. %G_TLS_ERROR_BAD_CERTIFICATE) about TLS certificates should be ignored. - * @auth: Object used for authenticating the connection. + * goa_internet_mail_new: + * @imap_host: The IMAP server. + * @imap_user_name: (allow-none): The user name to use. + * @imap_use_tls: Whether TLS should be used connections to the IMAP server. + * @imap_ignore_bad_tls: Whether errors (e.g. %G_TLS_ERROR_BAD_CERTIFICATE) about TLS certificates while connecting to @imap_host should be ignored. + * @imap_auth: Object used for authenticating the IMAP connection. + * @smtp_host: The SMTP server. + * @smtp_user_name: (allow-none): The user name to use. + * @smtp_use_tls: Whether TLS should be used connections to the SMTP server. + * @smtp_ignore_bad_tls: Whether errors (e.g. %G_TLS_ERROR_BAD_CERTIFICATE) about TLS certificates while connecting to @smtp_host should be ignored. * * Creates a new #GoaMail object. * - * Returns: (type GoaImapMail): A new #GoaMail instance. + * Returns: (type GoaInternetMail): A new #GoaMail instance. */ GoaMail * -goa_imap_mail_new (const gchar *host_and_port, - gboolean use_tls, - gboolean ignore_bad_tls, - GoaImapAuth *auth) +goa_internet_mail_new (const gchar *imap_host, + const gchar *imap_user_name, + gboolean imap_use_tls, + gboolean imap_ignore_bad_tls, + GoaImapAuth *imap_auth, + const gchar *smtp_host, + const gchar *smtp_user_name, + gboolean smtp_use_tls, + gboolean smtp_ignore_bad_tls) { - g_return_val_if_fail (host_and_port != NULL, NULL); - return GOA_MAIL (g_object_new (GOA_TYPE_IMAP_MAIL, - "host-and-port", host_and_port, - "use-tls", use_tls, - "ignore-bad-tls", ignore_bad_tls, - "auth", auth, + g_return_val_if_fail (imap_host != NULL, NULL); + return GOA_MAIL (g_object_new (GOA_TYPE_INTERNET_MAIL, + "imap-supported", TRUE, + "imap-host", imap_host, + "imap-user-name", imap_user_name, + "imap-use-tls", imap_use_tls, + "imap-ignore-bad-tls", imap_ignore_bad_tls, + "imap-auth", imap_auth, + "smtp-supported", TRUE, + "smtp-host", smtp_host, + "smtp-user-name", smtp_user_name, + "smtp-use-tls", smtp_use_tls, + "smtp-ignore-bad-tls", smtp_ignore_bad_tls, NULL)); } @@ -255,7 +251,7 @@ typedef struct { volatile gint ref_count; - GoaImapMail *mail; + GoaInternetMail *mail; GoaMailMonitor *monitor; /* Used so we can nuke the monitor if the creator vanishes */ @@ -866,10 +862,10 @@ imap_client_sync_single (ImapClientData *data) error = NULL; if (!goa_imap_client_connect_sync (client, - data->monitor_data->mail->host_and_port, - data->monitor_data->mail->use_tls, - data->monitor_data->mail->ignore_bad_tls, - data->monitor_data->mail->auth, + goa_mail_get_imap_host (GOA_MAIL (data->monitor_data->mail)), + goa_mail_get_imap_use_tls (GOA_MAIL (data->monitor_data->mail)), + data->monitor_data->mail->imap_ignore_bad_tls, + data->monitor_data->mail->imap_auth, NULL, /* GCancellable */ &error)) goto out; @@ -1071,7 +1067,7 @@ imap_client_sync (MonitorData *data) imap_data->monitor_data = monitor_data_ref (data); goa_info ("Using thread for IMAP client at %s for account %s", - data->mail->host_and_port, + goa_mail_get_imap_host (GOA_MAIL (data->mail)), g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (data->mail)))); while (TRUE) @@ -1079,7 +1075,7 @@ imap_client_sync (MonitorData *data) GPollFD poll_fd; goa_info ("Connecting to IMAP server at %s for account %s", - data->mail->host_and_port, + goa_mail_get_imap_host (GOA_MAIL (data->mail)), g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (data->mail)))); /* tries connecting - blocks until the connection is closed */ @@ -1257,9 +1253,9 @@ typedef gboolean (*ImapHelperFunc) (GoaImapClient *client, GError **error); static gboolean -imap_helper (const gchar *host_and_port, - gboolean use_tls, - gboolean ignore_bad_tls, +imap_helper (const gchar *imap_host, + gboolean imap_use_tls, + gboolean imap_ignore_bad_tls, GoaImapAuth *auth, guint uidvalidity, ImapHelperFunc func, @@ -1281,9 +1277,9 @@ imap_helper (const gchar *host_and_port, G_CALLBACK (on_untagged_response_uidvalidity), &read_uidvalidity); if (!goa_imap_client_connect_sync (client, - host_and_port, - use_tls, - ignore_bad_tls, + imap_host, + imap_use_tls, + imap_ignore_bad_tls, auth, NULL, /* GCancellable */ error)) @@ -1391,10 +1387,10 @@ monitor_on_handle_add_star (GoaMailMonitor *monitor, request = g_strdup_printf ("UID COPY %d %s", (gint) (message_uid & 0xffffffff), data->starred_folder); - imap_helper (data->mail->host_and_port, - data->mail->use_tls, - data->mail->ignore_bad_tls, - data->mail->auth, + imap_helper (goa_mail_get_imap_host (GOA_MAIL (data->mail)), + goa_mail_get_imap_use_tls (GOA_MAIL (data->mail)), + data->mail->imap_ignore_bad_tls, + data->mail->imap_auth, (message_uid >> 32), add_star_func, request, @@ -1476,10 +1472,10 @@ monitor_on_handle_mark_as_spam (GoaMailMonitor *monitor, data->spam_folder); requests[1] = g_strdup_printf ("UID STORE %d +FLAGS (\\Deleted)", (gint) (message_uid & 0xffffffff)); - imap_helper (data->mail->host_and_port, - data->mail->use_tls, - data->mail->ignore_bad_tls, - data->mail->auth, + imap_helper (goa_mail_get_imap_host (GOA_MAIL (data->mail)), + goa_mail_get_imap_use_tls (GOA_MAIL (data->mail)), + data->mail->imap_ignore_bad_tls, + data->mail->imap_auth, (message_uid >> 32), mark_as_spam_func, requests, @@ -1501,7 +1497,7 @@ static gboolean handle_create_monitor (GoaMail *_mail, GDBusMethodInvocation *invocation) { - GoaImapMail *mail = GOA_IMAP_MAIL (_mail); + GoaInternetMail *mail = GOA_INTERNET_MAIL (_mail); gchar *monitor_object_path; GError *error; MonitorData *data; @@ -1591,7 +1587,7 @@ handle_create_monitor (GoaMail *_mail, /* ---------------------------------------------------------------------------------------------------- */ static void -goa_imap_mail__goa_mail_iface_init (GoaMailIface *iface) +goa_internet_mail__goa_mail_iface_init (GoaMailIface *iface) { iface->handle_create_monitor = handle_create_monitor; } diff --git a/src/goabackend/goaimapmail.h b/src/goabackend/goainternetmail.h index b8a5899..20357bf 100644 --- a/src/goabackend/goaimapmail.h +++ b/src/goabackend/goainternetmail.h @@ -24,23 +24,29 @@ #error "Only <goabackend/goabackend.h> can be included directly." #endif -#ifndef __GOA_IMAP_MAIL_H__ -#define __GOA_IMAP_MAIL_H__ +#ifndef __GOA_INTERNET_MAIL_H__ +#define __GOA_INTERNET_MAIL_H__ #include <goabackend/goabackendtypes.h> G_BEGIN_DECLS -#define GOA_TYPE_IMAP_MAIL (goa_imap_mail_get_type ()) -#define GOA_IMAP_MAIL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GOA_TYPE_IMAP_MAIL, GoaImapMail)) -#define GOA_IS_IMAP_MAIL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOA_TYPE_IMAP_MAIL)) +#define GOA_TYPE_INTERNET_MAIL (goa_internet_mail_get_type ()) +#define GOA_INTERNET_MAIL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GOA_TYPE_INTERNET_MAIL, GoaInternetMail)) +#define GOA_IS_INTERNET_MAIL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOA_TYPE_INTERNET_MAIL)) + +GType goa_internet_mail_get_type (void) G_GNUC_CONST; +GoaMail *goa_internet_mail_new (const gchar *imap_host, + const gchar *imap_user_name, + gboolean imap_use_tls, + gboolean imap_ignore_bad_tls, + GoaImapAuth *imap_auth, + const gchar *smtp_host, + const gchar *smtp_user_name, + gboolean smtp_use_tls, + gboolean smtp_ignore_bad_tls); -GType goa_imap_mail_get_type (void) G_GNUC_CONST; -GoaMail *goa_imap_mail_new (const gchar *host_and_port, - gboolean use_tls, - gboolean ignore_bad_tls, - GoaImapAuth *auth); G_END_DECLS -#endif /* __GOA_IMAP_MAIL_H__ */ +#endif /* __GOA_INTERNET_MAIL_H__ */ diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c index 021d47e..da1e1af 100644 --- a/src/goabackend/goaprovider.c +++ b/src/goabackend/goaprovider.c @@ -798,6 +798,14 @@ goa_provider_lookup_credentials_sync (GoaProvider *provider, /* ---------------------------------------------------------------------------------------------------- */ /** + * SECTION:goautil + * @title: Utilities + * @short_description: Various utility routines + * + * Various utility routines. + */ + +/** * goa_util_add_row_widget: * @table: A #GtkTable. * @label_text: (allow-none): The text to insert on the left side or %NULL for no label. |