diff options
author | Radek Doulik <rodo@ximian.com> | 2003-12-04 22:14:36 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2003-12-04 22:14:36 +0800 |
commit | 429ac6ac1df8c8e91a615c9c0fb3f709230e52bc (patch) | |
tree | 2ea11ae54535cddfced86e559bea42b635743ff2 /mail | |
parent | 23017711eb711dc8e9296b4ed7a5a24d193fe6f2 (diff) | |
download | gsoc2013-evolution-429ac6ac1df8c8e91a615c9c0fb3f709230e52bc.tar.gz gsoc2013-evolution-429ac6ac1df8c8e91a615c9c0fb3f709230e52bc.tar.zst gsoc2013-evolution-429ac6ac1df8c8e91a615c9c0fb3f709230e52bc.zip |
monitor gconf key /apps/evolution/mail/junk/check_incoming and keep
2003-12-04 Radek Doulik <rodo@ximian.com>
* mail-session.c: monitor gconf key
/apps/evolution/mail/junk/check_incoming and keep session junk
flag uptodate
* em-mailer-prefs.c (em_mailer_prefs_construct): added junk
preferences
svn path=/trunk/; revision=23630
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 9 | ||||
-rw-r--r-- | mail/em-junk-plugin.h | 11 | ||||
-rw-r--r-- | mail/em-mailer-prefs.c | 10 | ||||
-rw-r--r-- | mail/em-mailer-prefs.h | 3 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in.in | 16 | ||||
-rw-r--r-- | mail/mail-config.glade | 155 | ||||
-rw-r--r-- | mail/mail-session.c | 68 |
7 files changed, 246 insertions, 26 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index f8233a7bd3..10c13bb6d5 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2003-12-04 Radek Doulik <rodo@ximian.com> + + * mail-session.c: monitor gconf key + /apps/evolution/mail/junk/check_incoming and keep session junk + flag uptodate + + * em-mailer-prefs.c (em_mailer_prefs_construct): added junk + preferences + 2003-12-03 Jeffrey Stedfast <fejj@ximian.com> * mail-config.c (uri_to_evname): Updated to add use mail subdirs. diff --git a/mail/em-junk-plugin.h b/mail/em-junk-plugin.h index 0c7eacd165..bd4af4cf9a 100644 --- a/mail/em-junk-plugin.h +++ b/mail/em-junk-plugin.h @@ -34,14 +34,13 @@ struct _EMJunkPlugin { CamelJunkPlugin csp; - /* when called, it should insert own GUI configuration into supplied. - container. returns data pointer which is later passed to apply, + /* when called, it should return widget containing UI configuration. plugin has to call (*changed_cb) (); whenever configuration - is changed to notify settings dialog about a change. - if setup_config_ui is NULL, it means there are no options */ + is changed to notify settings dialog about that change. + if setup_widget is NULL, it means there is no UI configuration */ - gpointer (*setup_config_ui) (GtkWidget *container, void (*changed_cb) ()); - void (*apply) (gpointer data); + GtkWidget (*setup_widget) (void (*changed_cb) ()); + void (*apply) (); }; #endif diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index b391af1655..a4c5f2e25a 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -360,6 +360,12 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) prefs->restore_labels = GTK_BUTTON (glade_xml_get_widget (gui, "cmdRestoreLabels")); g_signal_connect (prefs->restore_labels, "clicked", G_CALLBACK (restore_labels_clicked), prefs); + + /* Junk prefs */ + prefs->check_incoming = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkCheckIncomingMail")); + bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming", NULL); + gtk_toggle_button_set_active (prefs->check_incoming, bool); + g_signal_connect (prefs->check_incoming, "toggled", G_CALLBACK (settings_changed), prefs); } @@ -470,5 +476,9 @@ em_mailer_prefs_apply (EMMailerPrefs *prefs) l = n; } + /* junk prefs */ + gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming", + gtk_toggle_button_get_active (prefs->check_incoming), NULL); + gconf_client_suggest_sync (prefs->gconf, NULL); } diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h index 0555d03b06..27de7b3ca9 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -98,6 +98,9 @@ struct _EMMailerPrefs { GnomeColorPicker *color; } labels[5]; GtkButton *restore_labels; + + /* Junk prefs */ + GtkToggleButton *check_incoming; }; struct _EMMailerPrefsClass { diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index 013af3f96a..297d158d6b 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -603,6 +603,22 @@ </locale> </schema> + <!-- Junk --> + + <schema> + <key>/schemas/apps/evolution/mail/junk/check_incoming</key> + <applyto>/apps/evolution/mail/junk/check_incoming</applyto> + <owner>evolution-mail</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Check incoming mail being junk</short> + <long> + Run junk test on incoming mail + </long> + </locale> + </schema> + <!-- Account settings --> <schema> diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 68fc074247..7b451f0a56 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -4475,6 +4475,107 @@ For example: "Work" or "Personal"</property> <property name="type">tab</property> </packing> </child> + + <child> + <widget class="GtkVBox" id="vbox161"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkVBox" id="vbox162"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkCheckButton" id="chkCheckIncomingMail"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Checks incoming mail messages to be Junk</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Check _Incoming Mail</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frameFilterOptions"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> + + <child> + <placeholder/> + </child> + + <child> + <widget class="GtkLabel" id="label474"> + <property name="visible">True</property> + <property name="label" translatable="yes">Filter Options</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label473"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Junk</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> </widget> </child> </widget> @@ -5862,4 +5963,58 @@ for display purposes only. </property> </child> </widget> +<widget class="GtkWindow" id="sa_options"> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + + <child> + <widget class="GtkVBox" id="vbox163"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkCheckButton" id="chkLocalTestsOnly"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Local Tests Only</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="chkUseDaemon"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use _Daemon</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> diff --git a/mail/mail-session.c b/mail/mail-session.c index b484fd03ef..75f95f906b 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -53,7 +53,7 @@ #define d(x) CamelSession *session; - +static int session_check_junk_notify_id = -1; #define MAIL_SESSION_TYPE (mail_session_get_type ()) #define MAIL_SESSION(obj) (CAMEL_CHECK_CAST((obj), MAIL_SESSION_TYPE, MailSession)) @@ -100,6 +100,9 @@ init (MailSession *session) static void finalise (MailSession *session) { + if (session_check_junk_notify_id != -1) + gconf_client_notify_remove (mail_config_get_gconf_client (), session_check_junk_notify_id); + mail_async_event_destroy(session->async); e_mutex_destroy(session->lock); } @@ -586,7 +589,6 @@ static CamelFilterDriver * main_get_filter_driver (CamelSession *session, const char *type, CamelException *ex) { CamelFilterDriver *driver; - GString *fsearch, *faction; FilterRule *rule = NULL; char *user, *system; GConfClient *gconf; @@ -623,26 +625,33 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException camel_filter_driver_set_shell_func (driver, mail_execute_shell_command, NULL); camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL); camel_filter_driver_set_system_beep_func (driver, session_system_beep, NULL); - - fsearch = g_string_new (""); - faction = g_string_new (""); - /* implicit junk check as 1st rule */ - camel_filter_driver_add_rule (driver, "Junk check", "(junk-test)", "(begin (set-system-flag \"junk\"))"); - - /* add the user-defined rules next */ - while ((rule = rule_context_next_rule (fc, rule, type))) { - g_string_truncate (fsearch, 0); - g_string_truncate (faction, 0); + if ((!strcmp (type, FILTER_SOURCE_INCOMING) || !strcmp (type, FILTER_SOURCE_JUNKTEST)) + && camel_session_check_junk (session)) { + /* implicit junk check as 1st rule */ + camel_filter_driver_add_rule (driver, "Junk check", "(junk-test)", "(begin (set-system-flag \"junk\"))"); + } + + if (strcmp (type, FILTER_SOURCE_JUNKTEST)) { + GString *fsearch, *faction; + + fsearch = g_string_new (""); + faction = g_string_new (""); + + /* add the user-defined rules next */ + while ((rule = rule_context_next_rule (fc, rule, type))) { + g_string_truncate (fsearch, 0); + g_string_truncate (faction, 0); - filter_rule_build_code (rule, fsearch); - filter_filter_build_action ((FilterFilter *) rule, faction); - camel_filter_driver_add_rule (driver, rule->name, fsearch->str, faction->str); + filter_rule_build_code (rule, fsearch); + filter_filter_build_action ((FilterFilter *) rule, faction); + camel_filter_driver_add_rule (driver, rule->name, fsearch->str, faction->str); + } + + g_string_free (fsearch, TRUE); + g_string_free (faction, TRUE); } - g_string_free (fsearch, TRUE); - g_string_free (faction, TRUE); - g_object_unref (fc); return driver; @@ -745,11 +754,25 @@ mail_session_forget_password (const char *key) e_passwords_forget_password ("Mail", key); } +static void +mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry, CamelSession *session) +{ + gchar *key; + + g_return_if_fail (gconf_entry_get_key (entry) != NULL); + g_return_if_fail (gconf_entry_get_value (entry) != NULL); + + key = strrchr (gconf_entry_get_key (entry), '/'); + if (!strcmp (key, "check_incoming")) + camel_session_set_check_junk (session, gconf_value_get_bool (gconf_entry_get_value (entry))); +} + void mail_session_init (const char *base_directory) { char *camel_dir; - + GConfClient *gconf; + if (camel_init (base_directory, TRUE) != 0) exit (0); @@ -758,8 +781,13 @@ mail_session_init (const char *base_directory) camel_dir = g_strdup_printf ("%s/mail", base_directory); camel_session_construct (session, camel_dir); + gconf = mail_config_get_gconf_client (); + camel_session_set_check_junk (session, gconf_client_get_bool (gconf, "/apps/evolution/mail/junk/check_incoming", NULL)); + session_check_junk_notify_id = gconf_client_notify_add (gconf, "/apps/evolution/mail/junk", + (GConfClientNotifyFunc) mail_session_check_junk_notify, + session, NULL, NULL); session->junk_plugin = CAMEL_JUNK_PLUGIN (em_junk_filter_get_plugin ()); - + /* The shell will tell us to go online. */ camel_session_set_online ((CamelSession *) session, FALSE); |