diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-11-25 05:16:42 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-11-25 05:16:42 +0800 |
commit | f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9 (patch) | |
tree | d14e7bdd45ff4fec4372812f9e975803ff2ea6ce /mail/e-mail-ui-session.c | |
parent | 70d219dff6e4e633bd7775965c8a1cc6a1e17335 (diff) | |
download | gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar.gz gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar.bz2 gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar.lz gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar.xz gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.tar.zst gsoc2013-evolution-f3d3802199b98a1d97fe0c2d8dcd7c7c69211cd9.zip |
EMailUISession: Add "check-junk" property.
Takes over CamelSession's "check-junk" property.
Diffstat (limited to 'mail/e-mail-ui-session.c')
-rw-r--r-- | mail/e-mail-ui-session.c | 85 |
1 files changed, 82 insertions, 3 deletions
diff --git a/mail/e-mail-ui-session.c b/mail/e-mail-ui-session.c index 667fd1b09f..4bd2af5daf 100644 --- a/mail/e-mail-ui-session.c +++ b/mail/e-mail-ui-session.c @@ -74,11 +74,13 @@ struct _EMailUISessionPrivate { EMailAccountStore *account_store; EMailLabelListStore *label_store; EPhotoCache *photo_cache; + gboolean check_junk; }; enum { PROP_0, PROP_ACCOUNT_STORE, + PROP_CHECK_JUNK, PROP_LABEL_STORE, PROP_PHOTO_CACHE }; @@ -368,6 +370,7 @@ main_get_filter_driver (CamelSession *session, GSettings *settings; ERuleContext *fc; EMailUISessionPrivate *priv; + gboolean add_junk_test; priv = E_MAIL_UI_SESSION_GET_PRIVATE (session); @@ -403,10 +406,12 @@ main_get_filter_driver (CamelSession *session, camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL); camel_filter_driver_set_system_beep_func (driver, session_system_beep, NULL); - if ((!strcmp (type, E_FILTER_SOURCE_INCOMING) || - !strcmp (type, E_FILTER_SOURCE_JUNKTEST)) - && camel_session_get_check_junk (session)) { + add_junk_test = + priv->check_junk && ( + g_str_equal (type, E_FILTER_SOURCE_INCOMING) || + g_str_equal (type, E_FILTER_SOURCE_JUNKTEST)); + if (add_junk_test) { /* implicit junk check as 1st rule */ camel_filter_driver_add_rule ( driver, "Junk check", "(junk-test)", @@ -475,6 +480,23 @@ mail_ui_session_add_service_cb (SourceContext *context) } static void +mail_ui_session_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CHECK_JUNK: + e_mail_ui_session_set_check_junk ( + E_MAIL_UI_SESSION (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void mail_ui_session_get_property (GObject *object, guint property_id, GValue *value, @@ -488,6 +510,13 @@ mail_ui_session_get_property (GObject *object, E_MAIL_UI_SESSION (object))); return; + case PROP_CHECK_JUNK: + g_value_set_boolean ( + value, + e_mail_ui_session_get_check_junk ( + E_MAIL_UI_SESSION (object))); + return; + case PROP_LABEL_STORE: g_value_set_object ( value, @@ -753,6 +782,7 @@ e_mail_ui_session_class_init (EMailUISessionClass *class) g_type_class_add_private (class, sizeof (EMailUISessionPrivate)); object_class = G_OBJECT_CLASS (class); + object_class->set_property = mail_ui_session_set_property; object_class->get_property = mail_ui_session_get_property; object_class->dispose = mail_ui_session_dispose; object_class->constructed = mail_ui_session_constructed; @@ -770,6 +800,18 @@ e_mail_ui_session_class_init (EMailUISessionClass *class) g_object_class_install_property ( object_class, + PROP_CHECK_JUNK, + g_param_spec_boolean ( + "check-junk", + "Check Junk", + "Check if incoming messages are junk", + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, PROP_LABEL_STORE, g_param_spec_object ( "label-store", @@ -835,6 +877,43 @@ e_mail_ui_session_get_account_store (EMailUISession *session) return session->priv->account_store; } +/** + * e_mail_ui_session_get_check_junk: + * @session: an #EMailUISession + * + * Returns whether to automatically check incoming messages for junk content. + * + * Returns: whether to check for junk messages + **/ +gboolean +e_mail_ui_session_get_check_junk (EMailUISession *session) +{ + g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), FALSE); + + return session->priv->check_junk; +} + +/** + * e_mail_ui_session_set_check_junk: + * @session: an #EMailUISession + * @check_junk: whether to check for junk messages + * + * Sets whether to automatically check incoming messages for junk content. + **/ +void +e_mail_ui_session_set_check_junk (EMailUISession *session, + gboolean check_junk) +{ + g_return_if_fail (E_IS_MAIL_UI_SESSION (session)); + + if (check_junk == session->priv->check_junk) + return; + + session->priv->check_junk = check_junk; + + g_object_notify (G_OBJECT (session), "check-junk"); +} + EMailLabelListStore * e_mail_ui_session_get_label_store (EMailUISession *session) { |