diff options
author | Sankar P <psankar@novell.com> | 2007-01-22 19:50:16 +0800 |
---|---|---|
committer | Sankarasivasubramanian Pasupathilingam <psankar@src.gnome.org> | 2007-01-22 19:50:16 +0800 |
commit | 0b9195cb2c24add072671f82d1d1498b78a8b217 (patch) | |
tree | b9f81e77c96feba58139dfb095159a9f9e4e553a /plugins/imap-features | |
parent | b159b35b8fd0fd97e0c2cbeceee1739518e0fb23 (diff) | |
download | gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar.gz gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar.bz2 gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar.lz gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar.xz gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.tar.zst gsoc2013-evolution-0b9195cb2c24add072671f82d1d1498b78a8b217.zip |
Added support for configuring the imap-headers plugin.
2007-01-22 Sankar P <psankar@novell.com>
* configure.in: Added support for configuring the
imap-headers plugin.
svn path=/trunk/; revision=33133
Diffstat (limited to 'plugins/imap-features')
-rw-r--r-- | plugins/imap-features/ChangeLog | 9 | ||||
-rw-r--r-- | plugins/imap-features/Makefile.am | 40 | ||||
-rw-r--r-- | plugins/imap-features/imap-headers.c | 251 | ||||
-rw-r--r-- | plugins/imap-features/imap-headers.glade | 296 | ||||
-rw-r--r-- | plugins/imap-features/org-gnome-imap-features.eplug.xml | 18 |
5 files changed, 614 insertions, 0 deletions
diff --git a/plugins/imap-features/ChangeLog b/plugins/imap-features/ChangeLog new file mode 100644 index 0000000000..ee9075ce21 --- /dev/null +++ b/plugins/imap-features/ChangeLog @@ -0,0 +1,9 @@ +2007-01-22 Sankar P <psankar@novell.com> + + * ChangeLog + * imap-headers.c + * imap-headers.glade + * Makefile.am + * org-gnome-imap-features.eplug.xml: + + Initial list of files for the imap-features plugin diff --git a/plugins/imap-features/Makefile.am b/plugins/imap-features/Makefile.am new file mode 100644 index 0000000000..d84f600702 --- /dev/null +++ b/plugins/imap-features/Makefile.am @@ -0,0 +1,40 @@ +if OS_WIN32 +NO_UNDEFINED_REQUIRED_LIBS = $(top_builddir)/mail/libevolution-mail.la +endif + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/mail \ + -I$(top_srcdir)/libedataserver \ + $(EVOLUTION_MAIL_CFLAGS) \ + $(CAMEL_IMAP_CFLAGS) \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-imap-features.eplug +plugin_LTLIBRARIES = liborg-gnome-imap-features.la + +liborg_gnome_imap_features_la_SOURCES = \ + imap-headers.c + +liborg_gnome_imap_features_la_LIBADD= \ + $(NO_UNDEFINED_REQUIRED_LIBS) \ + $(EVOLUTION_MAIL_LIBS) + + +liborg_gnome_imap_features_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) + +glade_DATA = \ + imap-headers.glade + +errordir = $(privdatadir)/errors + +BUILT_SOURCES = org-gnome-imap-features.eplug $(error_i18n) + +EXTRA_DIST = \ + $(glade_DATA) \ + org-gnome-imap-features.eplug.xml + +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c new file mode 100644 index 0000000000..d08f32489d --- /dev/null +++ b/plugins/imap-features/imap-headers.c @@ -0,0 +1,251 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author: Sankar P <psankar@novell.com> + * + * Copyright 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> + +#include <mail/em-config.h> +#include <mail/mail-config.h> + +#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> + +#include <libedataserver/e-account.h> +#include <libedataserver/e-account-list.h> + +#include <camel/camel-url.h> +#include <camel/camel-exception.h> + +#include <glade/glade.h> + +#include <glib/gi18n.h> + +GtkWidget *all_headers, *basic_headers, *mailing_list_headers; +GtkWidget *custom_headers_box = NULL; +GtkTreeView *custom_headers_tree; +GtkTreeStore *store ; +GtkTreeIter iter; + +GtkButton *add_header, *remove_header; + +gchar **custom_headers_array = NULL; + +void imap_headers_abort (GtkWidget *button, EConfigHookItemFactoryData *data); +void imap_headers_commit (GtkWidget *button, EConfigHookItemFactoryData *data); +GtkWidget * org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data); + +void +imap_headers_abort (GtkWidget *button, EConfigHookItemFactoryData *data) +{ +} + +void +imap_headers_commit (GtkWidget *button, EConfigHookItemFactoryData *data) +{ + EMConfigTargetAccount *target_account; + EAccount *account; + + target_account = (EMConfigTargetAccount *)data->config->target; + account = target_account->account; + + if (g_str_has_prefix (account->source->url, "imap://")) { + EAccount *temp = NULL; + EAccountList *accounts = mail_config_get_accounts (); + CamelURL *url = NULL; + CamelException ex; + GtkTreeModel *model; + GtkTreeIter iter; + GString *str; + + str = g_string_new(""); + + temp = mail_config_get_account_by_source_url (account->source->url); + + url = camel_url_new (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), &ex); + + model = gtk_tree_view_get_model (custom_headers_tree); + if (gtk_tree_model_get_iter_first(model, &iter)) { + gchar *header; + do + { + gtk_tree_model_get (model, &iter, 0, &header, -1); + str = g_string_append (str, g_strstrip(header)); + str = g_string_append (str, " "); + } while (gtk_tree_model_iter_next(model, &iter)); + } + + camel_url_set_param (url, "imap_custom_headers", str->str); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(all_headers))) { + camel_url_set_param (url, "all_headers", "1"); + camel_url_set_param (url, "basic_headers", NULL); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_headers))) { + camel_url_set_param (url, "basic_headers", "1"); + camel_url_set_param (url, "all_headers", NULL); + } else { + camel_url_set_param (url, "all_headers", NULL); + camel_url_set_param (url, "basic_headers", NULL); + } + + e_account_set_string (temp, E_ACCOUNT_SOURCE_URL, camel_url_to_string (url, 0)); + camel_url_free (url); + g_string_free (str, TRUE); + e_account_list_change (accounts, temp); + e_account_list_save (accounts); + } +} + +static void +add_header_clicked (GtkButton *button) +{ + GtkDialog *dialog; + GtkEntry *header; + GtkTreeModel *model; + GtkTreeIter iter; + gint result; + + dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Custom Header"), + NULL, + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + NULL)); + header = GTK_ENTRY(gtk_entry_new ()); + gtk_container_add (GTK_CONTAINER(dialog->vbox), GTK_WIDGET(header)); + gtk_dialog_set_default_response (dialog, GTK_RESPONSE_ACCEPT); + gtk_widget_show_all (GTK_WIDGET(dialog)); + result = gtk_dialog_run (GTK_DIALOG (dialog)); + switch (result) + { + case GTK_RESPONSE_ACCEPT: + model = gtk_tree_view_get_model (custom_headers_tree); + gtk_tree_store_append (GTK_TREE_STORE(model), &iter, NULL); + gtk_tree_store_set (GTK_TREE_STORE(model), &iter, 0, gtk_entry_get_text (header), -1); + break; + } + gtk_widget_destroy (GTK_WIDGET(dialog)); +} + +static void +remove_header_clicked (GtkButton *button) +{ + GtkTreeSelection *select; + GtkTreeModel *model; + GtkTreeIter iter; + + select = gtk_tree_view_get_selection (custom_headers_tree); + + if (gtk_tree_selection_get_selected (select, &model, &iter)) + { + gtk_tree_store_remove(GTK_TREE_STORE(model), &iter); + } +} + +static void +fetch_all_headers_toggled (GtkWidget *all_option) +{ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(all_option))) + gtk_widget_set_sensitive (custom_headers_box, FALSE); + else + gtk_widget_set_sensitive (custom_headers_box, TRUE); +} + + +GtkWidget * +org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data) +{ + EMConfigTargetAccount *target_account; + EAccount *account; + GtkWidget *vbox; + CamelURL *url = NULL; + CamelException ex; + char *gladefile; + GladeXML *gladexml; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + target_account = (EMConfigTargetAccount *)data->config->target; + account = target_account->account; + + if(!g_str_has_prefix (account->source->url, "imap://")) + return NULL; + + gladefile = g_build_filename (EVOLUTION_GLADEDIR, "imap-headers.glade", NULL); + gladexml = glade_xml_new (gladefile, "vbox2", NULL); + g_free (gladefile); + + vbox = glade_xml_get_widget (gladexml, "vbox2"); + all_headers = glade_xml_get_widget (gladexml, "allHeaders"); + basic_headers = glade_xml_get_widget (gladexml, "basicHeaders"); + mailing_list_headers = glade_xml_get_widget (gladexml, "mailingListHeaders"); + custom_headers_box = glade_xml_get_widget (gladexml, "custHeaderHbox"); + custom_headers_tree = GTK_TREE_VIEW(glade_xml_get_widget (gladexml, "custHeaderTree")); + add_header = GTK_BUTTON(glade_xml_get_widget (gladexml, "addHeader")); + remove_header = GTK_BUTTON(glade_xml_get_widget (gladexml, "removeHeader")); + + url = camel_url_new (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), &ex); + if (url) { + char *custom_headers; + store = gtk_tree_store_new (1, G_TYPE_STRING); + custom_headers = g_strdup(camel_url_get_param (url, "imap_custom_headers")); + + if (custom_headers) { + int i=0; + + custom_headers_array = g_strsplit (custom_headers, " ", -1); + while (custom_headers_array[i] ) { + if (strlen(g_strstrip(custom_headers_array[i]))) { + gtk_tree_store_append (store, &iter, NULL); + gtk_tree_store_set (store, &iter, 0, custom_headers_array[i], -1); + } + i++; + } + g_strfreev (custom_headers_array); + gtk_tree_view_set_model (custom_headers_tree, GTK_TREE_MODEL(store)); + } + g_free (custom_headers); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(mailing_list_headers), TRUE); + if (camel_url_get_param (url, "all_headers")) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(all_headers), TRUE); + gtk_widget_set_sensitive (custom_headers_box, FALSE); + } else if (camel_url_get_param (url, "basic_headers")) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(basic_headers), TRUE); + camel_url_free (url); + } + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Custom Headers"), renderer, "text", 0, NULL); + gtk_tree_view_append_column (custom_headers_tree , column); + + g_signal_connect (all_headers, "toggled", G_CALLBACK(fetch_all_headers_toggled), NULL); + g_signal_connect (add_header, "clicked", G_CALLBACK(add_header_clicked), NULL); + g_signal_connect (remove_header, "clicked", G_CALLBACK(remove_header_clicked), NULL); + + gtk_notebook_append_page ((GtkNotebook *)(data->parent), vbox, gtk_label_new("IMAP Headers")); + gtk_widget_show_all (vbox); + return NULL; +} diff --git a/plugins/imap-features/imap-headers.glade b/plugins/imap-features/imap-headers.glade new file mode 100644 index 0000000000..38c57cc495 --- /dev/null +++ b/plugins/imap-features/imap-headers.glade @@ -0,0 +1,296 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window1"> + <property name="visible">True</property> + <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> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">2</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>IMAP Headers </b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Select your IMAP Header Preferences. +The more headers you have the more time it will take to download.</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.070000000298</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="allHeaders"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Fetch A_ll Headers</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</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="GtkRadioButton" id="basicHeaders"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Basic Headers - (Fastest) +Use this if you do not have filters based on mailing lists</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">allHeaders</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="mailingListHeaders"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Basic and _Mailing List Headers (Default)</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">allHeaders</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Custom Headers</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="Custom Headers"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Give the extra headers that you need to fetch in addition to the above standard headers. +You can ignore this if you choose "All Headers".</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">True</property> + <property name="xalign">0.0799999982119</property> + <property name="yalign">0</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="custHeaderHbox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">5</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="custHeaderTree"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkButton" id="addHeader"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-add</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">4</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="removeHeader"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-remove</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">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> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/plugins/imap-features/org-gnome-imap-features.eplug.xml b/plugins/imap-features/org-gnome-imap-features.eplug.xml new file mode 100644 index 0000000000..a5d24f7590 --- /dev/null +++ b/plugins/imap-features/org-gnome-imap-features.eplug.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<e-plugin-list> + <e-plugin id="org.gnome.evolution.imap_features" type="shlib" _name="IMAP Features" + location="@PLUGINDIR@/liborg-gnome-imap-features@SOEXT@"> + <author name="Sankar P" email="psankar@novell.com"/> + + <_description>A plugin for the features in the IMAP accounts.</_description> + + <hook class="org.gnome.evolution.mail.config:1.0"> + <group id="org.gnome.evolution.mail.config.accountEditor" + target="account" commit = "imap_headers_commit" abort="imap_headers_abort"> + <item type="page" path="70.IMAP Headers" label="IMAP Headers" factory="org_gnome_imap_headers"/> + </group> + </hook> + + </e-plugin> + +</e-plugin-list> |