From: Matthew Barnes Date: Sun, 25 Sep 2011 19:40:05 +0000 (-0400) Subject: CamelService: Add "password" property. X-Git-Tag: upstream/3.7.4~1593 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20ab2930ea6cd22e2f8be0f8426ceee5c2783b9c;p=platform%2Fupstream%2Fevolution-data-server.git CamelService: Add "password" property. This is meant to be an alternative to caching passwords in CamelURLs. --- diff --git a/camel/camel-service.c b/camel/camel-service.c index a366ee9..01f501f 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -60,6 +60,7 @@ struct _CamelServicePrivate { gchar *user_data_dir; gchar *user_cache_dir; gchar *uid; + gchar *password; GCancellable *connect_op; CamelServiceConnectionStatus status; @@ -75,6 +76,7 @@ struct _AsyncContext { enum { PROP_0, PROP_DISPLAY_NAME, + PROP_PASSWORD, PROP_PROVIDER, PROP_SESSION, PROP_SETTINGS, @@ -236,6 +238,12 @@ service_set_property (GObject *object, g_value_get_string (value)); return; + case PROP_PASSWORD: + camel_service_set_password ( + CAMEL_SERVICE (object), + g_value_get_string (value)); + return; + case PROP_PROVIDER: service_set_provider ( CAMEL_SERVICE (object), @@ -283,6 +291,12 @@ service_get_property (GObject *object, CAMEL_SERVICE (object))); return; + case PROP_PASSWORD: + g_value_set_string ( + value, camel_service_get_password ( + CAMEL_SERVICE (object))); + return; + case PROP_PROVIDER: g_value_set_pointer ( value, camel_service_get_provider ( @@ -357,6 +371,7 @@ service_finalize (GObject *object) g_free (priv->user_data_dir); g_free (priv->user_cache_dir); g_free (priv->uid); + g_free (priv->password); g_static_rec_mutex_free (&priv->connect_lock); g_static_mutex_free (&priv->connect_op_lock); @@ -609,6 +624,18 @@ camel_service_class_init (CamelServiceClass *class) g_object_class_install_property ( object_class, + PROP_PASSWORD, + g_param_spec_string ( + "password", + "Password", + "The password for the service", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, PROP_PROVIDER, g_param_spec_pointer ( "provider", @@ -774,6 +801,48 @@ camel_service_set_display_name (CamelService *service, } /** + * camel_service_get_password: + * @service: a #CamelService + * + * Returns the password for @service. Some SASL mechanisms use this + * when attempting to authenticate. + * + * Returns: the password for @service + * + * Since: 3.4 + **/ +const gchar * +camel_service_get_password (CamelService *service) +{ + g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL); + + return service->priv->password; +} + +/** + * camel_service_set_password: + * @service: a #CamelService + * @password: the password for @service + * + * Sets the password for @service. Use this function to cache the password + * in memory after obtaining it through camel_session_get_password(). Some + * SASL mechanisms use this when attempting to authenticate. + * + * Since: 3.4 + **/ +void +camel_service_set_password (CamelService *service, + const gchar *password) +{ + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + g_free (service->priv->password); + service->priv->password = g_strdup (password); + + g_object_notify (G_OBJECT (service), "password"); +} + +/** * camel_service_get_user_data_dir: * @service: a #CamelService * diff --git a/camel/camel-service.h b/camel/camel-service.h index 0784dde..c072998 100644 --- a/camel/camel-service.h +++ b/camel/camel-service.h @@ -148,6 +148,9 @@ GQuark camel_service_error_quark (void) G_GNUC_CONST; const gchar * camel_service_get_display_name (CamelService *service); void camel_service_set_display_name (CamelService *service, const gchar *display_name); +const gchar * camel_service_get_password (CamelService *service); +void camel_service_set_password (CamelService *service, + const gchar *password); const gchar * camel_service_get_user_data_dir (CamelService *service); const gchar * camel_service_get_user_cache_dir (CamelService *service); diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt index 14d69f3..a2b9899 100644 --- a/docs/reference/camel/camel-sections.txt +++ b/docs/reference/camel/camel-sections.txt @@ -1954,6 +1954,8 @@ CamelServiceConnectionStatus CamelServiceAuthType camel_service_get_display_name camel_service_set_display_name +camel_service_get_password +camel_service_set_password camel_service_get_user_data_dir camel_service_get_name camel_service_get_provider @@ -2184,7 +2186,6 @@ CAMEL_STORE_INFO_FOLDER_UNKNOWN CamelStoreSummaryFlags camel_store_summary_new camel_store_summary_set_filename -camel_store_summary_set_uri_base camel_store_summary_load camel_store_summary_save camel_store_summary_header_load diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml index db5c5c7..f9d6c93 100644 --- a/docs/reference/camel/tmpl/camel-service.sgml +++ b/docs/reference/camel/tmpl/camel-service.sgml @@ -31,6 +31,11 @@ CamelService + + + + + @@ -112,6 +117,24 @@ CamelService @display_name: + + + + + +@service: +@Returns: + + + + + + + +@service: +@password: + +