aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-25 15:46:06 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-25 15:46:06 +0800
commit6ea2a4da8b06dd138bc815b242d6670d7c003223 (patch)
treec6c40aca0b8f4deb9c03a3d54d6385b8de17e711 /mail
parent6147ca54a454838e00dfa108db5b13ec10b9aa2f (diff)
downloadgsoc2013-evolution-6ea2a4da8b06dd138bc815b242d6670d7c003223.tar.gz
gsoc2013-evolution-6ea2a4da8b06dd138bc815b242d6670d7c003223.tar.zst
gsoc2013-evolution-6ea2a4da8b06dd138bc815b242d6670d7c003223.zip
Update to take argc and argv arguments since this is the new definition
2002-07-25 Jeffrey Stedfast <fejj@ximian.com> * mail-ops.c (mail_execute_shell_command): Update to take argc and argv arguments since this is the new definition for the CamelFilterDriverShellFunc. * mail-session.c (main_get_filter_driver): Updated for the renamed function. svn path=/trunk/; revision=17585
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-ops.c60
-rw-r--r--mail/mail-ops.h2
-rw-r--r--mail/mail-session.c3
4 files changed, 61 insertions, 13 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index c35438aab3..d27fd4af88 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,6 +1,13 @@
2002-07-25 Jeffrey Stedfast <fejj@ximian.com>
- * mail-display.c (link_open_in_browser): Mae sure that the
+ * mail-ops.c (mail_execute_shell_command): Update to take argc and
+ argv arguments since this is the new definition for the
+ CamelFilterDriverShellFunc.
+
+ * mail-session.c (main_get_filter_driver): Updated for the renamed
+ function.
+
+ * mail-display.c (link_open_in_browser): Make sure that the
html->pointer_url is non-NULL. Should fix bug #28159 (this seems
to be the only questionable way for a NULL url to be passed into
on_link_clicked).
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 5d3345fa8b..5de88d9633 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -2278,31 +2278,64 @@ mail_store_set_offline (CamelStore *store, gboolean offline,
struct _execute_shell_command_msg {
struct _mail_msg msg;
- char *command;
+ GPtrArray *argv;
};
-static char *execute_shell_command_desc (struct _mail_msg *mm, int done)
+static char *
+execute_shell_command_desc (struct _mail_msg *mm, int done)
{
struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm;
char *msg;
- msg = g_strdup_printf (_("Executing shell command: %s"), m->command);
+ msg = g_strdup_printf (_("Executing shell command: %s"), m->argv->pdata[0]);
return msg;
}
-static void execute_shell_command_do (struct _mail_msg *mm)
+static void
+execute_shell_command_do (struct _mail_msg *mm)
{
struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm;
+ pid_t result, pid;
+ int status;
+
+ if (!(pid = fork ())) {
+ /* child process */
+ GPtrArray *args;
+ int maxfd, i;
+
+ setsid ();
+
+ maxfd = sysconf (_SC_OPEN_MAX);
+ for (i = 0; i < maxfd; i++)
+ close (i);
+
+ execvp (m->argv->pdata[0], (char **) m->argv->pdata);
+
+ d(printf ("Could not execute %s: %s\n", m->argv->pdata[0], g_strerror (errno)));
+ _exit (255);
+ } else if (pid < 0) {
+ camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Failed to create create child process '%s': %s"),
+ m->argv->pdata[0], g_strerror (errno));
+ return -1;
+ }
- gnome_execute_shell (NULL, m->command);
+ do {
+ result = waitpid (pid, &status, 0);
+ } while (result != pid);
}
-static void execute_shell_command_free (struct _mail_msg *mm)
+static void
+execute_shell_command_free (struct _mail_msg *mm)
{
struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm;
+ int i;
- g_free (m->command);
+ for (i = 0; i < m->argv; i++)
+ g_free (m->argv->pdata[i]);
+
+ g_ptr_array_free (m->argv, TRUE);
}
static struct _mail_msg_op execute_shell_command_op = {
@@ -2313,15 +2346,22 @@ static struct _mail_msg_op execute_shell_command_op = {
};
void
-mail_execute_shell_command (CamelFilterDriver *driver, const char *command, void *data)
+mail_execute_shell_command (CamelFilterDriver *driver, int argc, char **argv, void *data)
{
struct _execute_shell_command_msg *m;
+ GPtrArray *args;
+ int i;
- if (command == NULL)
+ if (argc <= 0)
return;
+ args = g_ptr_array_new ();
+ for (i = 0; i < argc; i++)
+ g_ptr_array_add (args, g_strdup (argv[i]));
+ g_ptr_array_add (args, NULL);
+
m = mail_msg_new (&execute_shell_command_op, NULL, sizeof (*m));
- m->command = g_strdup (command);
+ m->argv = args;
e_thread_put (mail_thread_queued, (EMsg *) m);
}
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index e509577bd6..e2024108cc 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -156,7 +156,7 @@ void mail_store_set_offline(CamelStore *store, gboolean offline,
void *data);
/* filter driver execute shell command async callback */
-void mail_execute_shell_command (CamelFilterDriver *driver, const char *command, void *data);
+void mail_execute_shell_command (CamelFilterDriver *driver, int argc, char **argv, void *data);
#ifdef __cplusplus
}
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 2fb0628301..8a1d735ef0 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -19,6 +19,7 @@
*
*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -855,7 +856,7 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException
camel_filter_driver_set_logfile (driver, ms->filter_logfile);
}
- camel_filter_driver_set_shell_exec_func (driver, mail_execute_shell_command, NULL);
+ 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);