diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | plugins/external-editor/ChangeLog | 17 | ||||
-rw-r--r-- | plugins/external-editor/Makefile.am | 38 | ||||
-rw-r--r-- | plugins/external-editor/external-editor.c | 152 | ||||
-rw-r--r-- | plugins/external-editor/org-gnome-external-editor.eplug.xml | 27 | ||||
-rw-r--r-- | plugins/external-editor/org-gnome-external-editor.error.xml | 4 | ||||
-rw-r--r-- | plugins/external-editor/org-gnome-external-editor.xml | 17 |
8 files changed, 265 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2007-10-25 Sankar P <psankar@novell.com> + + * configure.in: + * plugins/external-editor: + Added new plugins external-editor, which will + make it possible to use an external editor as + the mail composer. + 2007-10-23 Chenthill Palanisamy <pchenthill@novell.com> * configure.in diff --git a/configure.in b/configure.in index bf0595f7f0..60804fa4b0 100644 --- a/configure.in +++ b/configure.in @@ -1690,7 +1690,7 @@ plugins_standard_always="bbdb subject-thread save-calendar select-one-source cop plugins_standard="$plugins_standard_always" all_plugins_standard="$plugins_standard" -plugins_experimental_always="backup-restore folder-unsubscribe mail-to-meeting mail-remote save-attachments" +plugins_experimental_always="backup-restore folder-unsubscribe mail-to-meeting mail-remote save-attachments external-editor" plugins_experimental="$plugins_experimental_always $IPOD_SYNC $TNEF_ATTACHMENTS" all_plugins_experimental="$plugins_experimental_always ipod-sync tnef-attachments" @@ -1986,6 +1986,7 @@ plugins/import-ics-attachments/Makefile plugins/imap-features/Makefile plugins/tnef-attachments/Makefile plugins/face/Makefile +plugins/external-editor/Makefile smime/Makefile smime/lib/Makefile smime/gui/Makefile diff --git a/plugins/external-editor/ChangeLog b/plugins/external-editor/ChangeLog new file mode 100644 index 0000000000..48fd3ad228 --- /dev/null +++ b/plugins/external-editor/ChangeLog @@ -0,0 +1,17 @@ +2007-10-25 Sankar P <psankar@novell.com> + + * Makefile.am: + * org-gnome-external-editor.eplug.xml: + * org-gnome-external-editor.xml: + * org-gnome-external-editor.error.xml: + * external-editor.c: + + - Initial files for the plugin. + + - This plugin allows you to use an external editor + as the composer. + + - I've tested this gvim and it works fine. + + - Needs a lot of more work before this + moves out of experimental state. diff --git a/plugins/external-editor/Makefile.am b/plugins/external-editor/Makefile.am new file mode 100644 index 0000000000..beec48dc29 --- /dev/null +++ b/plugins/external-editor/Makefile.am @@ -0,0 +1,38 @@ +INCLUDES = \ + -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ + -DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \ + -DPREFIX=\""$(prefix)"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DDATADIR=\""$(datadir)"\" \ + -DLIBDIR=\""$(libdir)"\" \ + -I$(top_srcdir) \ + -I$(top_srcdir)/composer \ + $(SHELL_CFLAGS) \ + $(EVOLUTION_MAIL_CFLAGS) \ + $(E_UTIL_CFLAGS) + +@EVO_PLUGIN_RULE@ + +error_DATA = org-gnome-external-editor.error +errordir = $(privdatadir)/errors + +plugin_DATA = \ + org-gnome-external-editor.eplug \ + org-gnome-external-editor.xml + +plugin_LTLIBRARIES = liborg-gnome-external-editor.la + +liborg_gnome_external_editor_la_SOURCES = \ + external-editor.c + +liborg_gnome_external_editor_la_LDFLAGS = -module -avoid-version + +EXTRA_DIST = \ + org-gnome-external-editor.eplug.xml \ + org-gnome-external-editor.error.xml \ + org-gnome-external-editor.xml + +BUILT_SOURCES = org-gnome-external-editor.eplug \ + org-gnome-external-editor.error + +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c new file mode 100644 index 0000000000..5cb9068265 --- /dev/null +++ b/plugins/external-editor/external-editor.c @@ -0,0 +1,152 @@ +/* Sankar P - <psankar@novell.com> - GPL V3 or Later */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <mail/em-menu.h> +#include <mail/em-config.h> +#include <mail/em-composer-utils.h> +#include <mail/mail-config.h> +#include <e-util/e-error.h> + +#include <e-msg-composer.h> + +#include <sys/stat.h> +#include <sys/wait.h> + +#include <stdlib.h> +#include <string.h> + +#define d(x) x + +#define TEMPORARY_FILE "/tmp/evolution-composer" + +void org_gnome_external_editor (EPlugin *ep, EMMenuTargetSelect *select); + +/* Utility function to convert an email address to CamelInternetAddress. +May be this should belong to CamelInternetAddress file itself. */ + +static CamelInternetAddress * convert_to_camel_internet_address (char * emails) +{ + CamelInternetAddress *cia = camel_internet_address_new(); + gchar **address_tokens = NULL; + int i; + + if (emails && strlen (emails) > 1) { + address_tokens = g_strsplit (emails, ",", 0); + + if (address_tokens) { + for (i = 1; address_tokens[i]; ++i) { + camel_internet_address_add (cia, " ", address_tokens [i]); + d(printf ("\nAdding camel_internet_address[%s] \n", address_tokens [i])); + } + + return cia; + } + } + camel_object_unref (cia); + return NULL; +} + +void org_gnome_external_editor (EPlugin *ep, EMMenuTargetSelect *select) +{ + d(printf ("\n\nexternal_editor plugin is launched \n\n")); + + /* The template to be used in the external editor */ + char template[] = "###|||Insert , seperated TO addresses below this line. Do not delete this line. Optional field\n\n###||| Insert , seperated CC addresses below this line. Do not delete this line. Optional field\n\n###|||Insert , seperated BCC addresses below this line. Do not delete this line. Optional field\n\n###|||Insert SUBJECT below this line. Do not delete this line. Optional field\n\n###|||Insert BODY of mail below this line. Do not delete this line.\n\n"; + + + /* Push the template contents to the intermediate file */ + g_file_set_contents (TEMPORARY_FILE, template, strlen (template), NULL); + + char *editor; + + editor = (char *) g_getenv ("EDITOR"); + if (!editor) + editor = "gvim"; + +#if 1 + int status = 0; + gchar *argv[4]; + + argv[0] = editor; + + /* README: The -- params should come via the "Configure" option */ + argv[1] = "--nofork"; + + argv[2] = TEMPORARY_FILE; + argv[3] = NULL; + + /* FIXME: I guess NULL should do fine instead of /usr/bin */ + if (!g_spawn_sync ("/usr/bin", argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &status, NULL)) + { + g_warning ("Unable to launch %s: ", argv[0]); + return ; + } + + if (WEXITSTATUS (status) != 0) { + d(printf ("\n\nsome problem here with external editor\n\n")); + return ; + } else { + + gchar *buf; + CamelMimeMessage *message; + EMsgComposer *composer; + + message = camel_mime_message_new (); + + d(printf ("\n\nexternal editor works like a charm \n\n")); + + if (g_file_get_contents (TEMPORARY_FILE, &buf, NULL, NULL)) { + gchar **tokens; + int i, j; + + tokens = g_strsplit (buf, "###|||", 6); + + for (i = 1; tokens[i]; ++i) { + + for (j = 0; tokens[i][j] && tokens[i][j] != '\n'; ++j) { + tokens [i][j] = ' '; + } + + if (tokens[i][j] == '\n') + tokens[i][j] = ' '; + + g_strchug(tokens[i]); + + d(printf ("\nstripped off token[%d] is : %s \n", i, tokens[i])); + } + + camel_mime_message_set_recipients (message, "To", convert_to_camel_internet_address(tokens[1])); + camel_mime_message_set_recipients (message, "Cc", convert_to_camel_internet_address(tokens[2])); + camel_mime_message_set_recipients (message, "Bcc", convert_to_camel_internet_address(tokens[3])); + + camel_mime_message_set_subject (message, tokens[4]); + + camel_mime_part_set_content ((CamelMimePart *)message, tokens [5], strlen (tokens [5]), "text/plain"); + + + /* FIXME: We need to make mail-remote working properly. + So that we neednot invoke composer widget at all. + May be we can do it now itself by invoking local CamelTransport. + But all that is not needed for the first release. + */ + + composer = e_msg_composer_new_with_message (message); + g_signal_connect (GTK_OBJECT (composer), "send", G_CALLBACK (em_utils_composer_send_cb), NULL); + + g_signal_connect (GTK_OBJECT (composer), "save-draft", G_CALLBACK (em_utils_composer_save_draft_cb), NULL); + + gtk_widget_show (GTK_WIDGET (composer)); + } + } +#else + char *query; + + query = g_strdup_printf ("%s /tmp/evolution-composer", editor); + system (query); + g_free (query); + +#endif +} diff --git a/plugins/external-editor/org-gnome-external-editor.eplug.xml b/plugins/external-editor/org-gnome-external-editor.eplug.xml new file mode 100644 index 0000000000..cbe28ab022 --- /dev/null +++ b/plugins/external-editor/org-gnome-external-editor.eplug.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<e-plugin-list> + <!-- the path to the shared library --> + <e-plugin + id="org.gnome.plugin.external.editor" + type="shlib" + location="@PLUGINDIR@/liborg-gnome-external-editor@SOEXT@" + _name="External Editor"> + <author name="Sankar P" email="sankar2u@gmail.com"/> + <_description>A plugin for using an external editor as the composer. You can send only plain-text mails. </_description> + + <hook class="org.gnome.evolution.shell.bonobomenu:1.0"> + + <menu id="org.gnome.evolution.shell" target="shell"> + <!-- the path to the bonobo menu description --> + <ui file="@PLUGINDIR@/org-gnome-external-editor.xml"/> + <item + type="item" + verb="EPExtEditor" + path="/commands/EPExtEditor" + activate="org_gnome_external_editor"/> + </menu> + + </hook> + + </e-plugin> +</e-plugin-list> diff --git a/plugins/external-editor/org-gnome-external-editor.error.xml b/plugins/external-editor/org-gnome-external-editor.error.xml new file mode 100644 index 0000000000..05fbca60e9 --- /dev/null +++ b/plugins/external-editor/org-gnome-external-editor.error.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<error-list domain="org.gnome.external-editor"> + +</error-list> diff --git a/plugins/external-editor/org-gnome-external-editor.xml b/plugins/external-editor/org-gnome-external-editor.xml new file mode 100644 index 0000000000..ca7969c4b7 --- /dev/null +++ b/plugins/external-editor/org-gnome-external-editor.xml @@ -0,0 +1,17 @@ +<Root> + <commands> + + <cmd name="EPExtEditor" _label="Compose in External Editor" + _tip="Compose mails using an external editor" + pixtype="pixmap"/> + + </commands> + + <menu> + <submenu name="File"> + <placeholder name="FileOps"> + <menuitem name="EPExtEditor" verb=""/> + </placeholder> + </submenu> + </menu> +</Root> |