aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-config.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-02-16 08:44:40 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-02-16 08:44:40 +0800
commit03d8740213e324efaf7b774b0c7497ced2fa626b (patch)
tree590073927ce64831efba1b4039404e7f5a5a49df /mail/mail-config.c
parentf7e298665b02f72890c6681e6d21ef5601beccbb (diff)
downloadgsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar.gz
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar.bz2
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar.lz
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar.xz
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.tar.zst
gsoc2013-evolution-03d8740213e324efaf7b774b0c7497ced2fa626b.zip
Move signature script execution to e-util/e-signature-utils.s so the
composer can invoke it. Composer no longer needs mail-config.h. Split signature preview into a new widget: ESignaturePreview. svn path=/branches/kill-bonobo/; revision=37272
Diffstat (limited to 'mail/mail-config.c')
-rw-r--r--mail/mail-config.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a7e8bb908c..3c39791dfa 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -39,10 +39,6 @@
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-#ifndef G_OS_WIN32
-#include <sys/wait.h>
-#endif
-
#include <gtkhtml/gtkhtml.h>
#include <glade/glade.h>
@@ -983,125 +979,3 @@ mail_config_get_lookup_book_local_only (void)
return config->book_lookup_local_only;
}
-
-char *
-mail_config_signature_run_script (const char *script)
-{
-#ifndef G_OS_WIN32
- int result, status;
- int in_fds[2];
- pid_t pid;
-
- if (config == NULL)
- mail_config_init ();
-
- if (config->scripts_disabled)
- return NULL;
-
- if (pipe (in_fds) == -1) {
- g_warning ("Failed to create pipe to '%s': %s", script, g_strerror (errno));
- return NULL;
- }
-
- if (!(pid = fork ())) {
- /* child process */
- int maxfd, i;
-
- close (in_fds [0]);
- if (dup2 (in_fds[1], STDOUT_FILENO) < 0)
- _exit (255);
- close (in_fds [1]);
-
- setsid ();
-
- maxfd = sysconf (_SC_OPEN_MAX);
- for (i = 3; i < maxfd; i++) {
- if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO)
- fcntl (i, F_SETFD, FD_CLOEXEC);
- }
-
- execlp("/bin/sh", "/bin/sh", "-c", script, NULL);
- g_warning ("Could not execute %s: %s\n", script, g_strerror (errno));
- _exit (255);
- } else if (pid < 0) {
- g_warning ("Failed to create create child process '%s': %s", script, g_strerror (errno));
- close (in_fds [0]);
- close (in_fds [1]);
- return NULL;
- } else {
- CamelStreamFilter *filtered_stream;
- CamelStreamMem *memstream;
- CamelMimeFilter *charenc;
- CamelStream *stream;
- GByteArray *buffer;
- char *charset;
- char *content;
-
- /* parent process */
- close (in_fds[1]);
-
- stream = camel_stream_fs_new_with_fd (in_fds[0]);
-
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- buffer = g_byte_array_new ();
- camel_stream_mem_set_byte_array (memstream, buffer);
-
- camel_stream_write_to_stream (stream, (CamelStream *) memstream);
- camel_object_unref (stream);
-
- /* signature scripts are supposed to generate UTF-8 content, but because users
- are known to not ever read the manual... we try to do our best if the
- content isn't valid UTF-8 by assuming that the content is in the user's
- preferred charset. */
- if (!g_utf8_validate ((char *)buffer->data, buffer->len, NULL)) {
- stream = (CamelStream *) memstream;
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (memstream, g_byte_array_new ());
-
- filtered_stream = camel_stream_filter_new_with_stream (stream);
- camel_object_unref (stream);
-
- charset = gconf_client_get_string (config->gconf, "/apps/evolution/mail/composer/charset", NULL);
- if (charset && *charset) {
- if ((charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "utf-8"))) {
- camel_stream_filter_add (filtered_stream, charenc);
- camel_object_unref (charenc);
- }
- }
- g_free (charset);
-
- camel_stream_write_to_stream ((CamelStream *) filtered_stream, (CamelStream *) memstream);
- camel_object_unref (filtered_stream);
- g_byte_array_free (buffer, TRUE);
-
- buffer = memstream->buffer;
- }
-
- camel_object_unref (memstream);
-
- g_byte_array_append (buffer, (const unsigned char *)"", 1);
- content = (char *)buffer->data;
- g_byte_array_free (buffer, FALSE);
-
- /* wait for the script process to terminate */
- result = waitpid (pid, &status, 0);
-
- if (result == -1 && errno == EINTR) {
- /* child process is hanging... */
- kill (pid, SIGTERM);
- sleep (1);
- result = waitpid (pid, &status, WNOHANG);
- if (result == 0) {
- /* ...still hanging, set phasers to KILL */
- kill (pid, SIGKILL);
- sleep (1);
- result = waitpid (pid, &status, WNOHANG);
- }
- }
-
- return content;
- }
-#else
- return NULL;
-#endif
-}