2008-02-18 Milan Crha <mcrha@redhat.com> ** Part of fix for bug #515744 * addressbook/gui/component/addressbook-migrate.c: (get_source_name): * plugins/groupwise-features/send-options.c: (get_source): * plugins/groupwise-features/share-folder-common.c: (get_container_id): * plugins/groupwise-features/install-shared.c: (install_folder_response): * plugins/external-editor/external-editor.c: (convert_to_camel_internet_address), (org_gnome_external_editor): * plugins/itip-formatter/itip-formatter.c: (idle_open_cb): * mail/em-folder-view.c: (emfv_setup_view_instance): * mail/mail-component.c: (impl_finalize): * mail/message-list.c: (ml_tree_value_at): * composer/e-msg-composer.c: (drop_action): * e-util/e-config.c: (ep_finalise): Use proper member to free. * widgets/misc/e-cursors.c: (e_cursors_init): * widgets/misc/e-calendar-item.c: (e_calendar_item_draw_month): * calendar/gui/dialogs/comp-editor.c: (drop_action): * calendar/gui/calendar-config.c: (calendar_config_get_hide_completed_tasks_sexp): * calendar/gui/comp-editor-factory.c: (edit_existing): * calendar/gui/e-day-view.c: (e_day_view_reshape_long_event), (e_day_view_on_top_canvas_drag_data_received): * calendar/gui/e-day-view-main-item.c: (e_day_view_main_item_draw_events_in_vbars), (e_day_view_main_item_draw_long_events_in_vbars): * calendar/gui/e-day-view-top-item.c: (e_day_view_top_item_draw_long_event): * calendar/gui/e-cal-model.c: (redo_queries): * calendar/gui/e-calendar-table.c: (e_calendar_table_open_task): * calendar/gui/e-memo-table.c: (open_memo): * calendar/gui/print.c: (print_todo_details): * calendar/gui/migration.c: (get_source_name): Memory leak fix. * calendar/gui/e-week-view.c: (e_week_view_reshape_events): Simplifies things. svn path=/trunk/; revision=35044
156 lines
4.4 KiB
C
156 lines
4.4 KiB
C
/* 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]));
|
|
}
|
|
g_strfreev (address_tokens);
|
|
|
|
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));
|
|
|
|
g_strfreev (tokens);
|
|
}
|
|
}
|
|
#else
|
|
char *query;
|
|
|
|
query = g_strdup_printf ("%s /tmp/evolution-composer", editor);
|
|
system (query);
|
|
g_free (query);
|
|
|
|
#endif
|
|
}
|