26
26
#include <e-contact-entry.h>
27
27
#include <glib/gi18n-lib.h>
28
29
#include <string.h>
29
30
#include "nautilus-sendto-plugin.h"
31
32
#define GCONF_COMPLETION "/apps/evolution/addressbook"
32
33
#define GCONF_COMPLETION_SOURCES GCONF_COMPLETION "/sources"
33
#define DEFAULT_MAILTO "/desktop/gnome/url-handlers/mailto/command"
35
35
#define CONTACT_FORMAT "%s <%s>"
47
47
static char *email = NULL;
48
48
static char *name = NULL;
55
char *cmds[] = {"evolution",
60
"evolution-2.8", /* for the future */
61
"evolution-3.0", /* but how far to go ? */
66
for (i = 0; cmds[i] != NULL; i++) {
67
tmp = g_find_program_in_path (cmds[i]);
75
retval = g_strdup_printf ("%s --component=mail %%s", tmp);
81
51
init (NstPlugin *plugin)
85
55
g_print ("Init evolution plugin\n");
87
57
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
88
58
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
90
client = gconf_client_get_default ();
91
mail_cmd = gconf_client_get_string (client, DEFAULT_MAILTO, NULL);
92
g_object_unref (client);
60
app = g_app_info_get_default_for_uri_scheme ("mailto");
61
mail_cmd = g_strdup (g_app_info_get_executable (app));
94
if (mail_cmd == NULL || *mail_cmd == '\0') {
96
mail_cmd = get_evo_cmd ();
64
/* Find what the default mailer is */
65
if (strstr (mail_cmd, "balsa"))
67
else if (strstr (mail_cmd, "thunder") || strstr (mail_cmd, "seamonkey"))
68
type = MAILER_THUNDERBIRD;
69
else if (strstr (mail_cmd, "sylpheed") || strstr (mail_cmd, "claws"))
70
type = MAILER_SYLPHEED;
71
else if (strstr (mail_cmd, "anjal"))
99
/* Find what the default mailer is */
100
if (strstr (mail_cmd, "balsa"))
102
else if (strstr (mail_cmd, "thunder") || strstr (mail_cmd, "seamonkey")) {
105
type = MAILER_THUNDERBIRD;
107
/* Thunderbird sucks, see
108
* https://bugzilla.gnome.org/show_bug.cgi?id=614222 */
109
strv = g_strsplit (mail_cmd, " ", -1);
111
mail_cmd = g_strdup_printf ("%s %%s", strv[0]);
113
} else if (strstr (mail_cmd, "sylpheed") || strstr (mail_cmd, "claws"))
114
type = MAILER_SYLPHEED;
115
else if (strstr (mail_cmd, "anjal"))
119
74
if (mail_cmd == NULL)
254
if (strstr (mail_cmd, " -m ") == NULL && strstr (mail_cmd, " --compose=") == NULL)
255
g_string_append (mailto, " --compose=");
209
g_string_append (mailto, " --compose=");
256
210
if (email != NULL) {
257
211
if (name != NULL)
258
212
g_string_append_printf (mailto, "\""CONTACT_FORMAT"\"", name, email);
291
246
if (text != NULL && *text != '\0')
292
247
g_string_append_printf (mailto, "to='%s',", text);
294
g_string_append_printf (mailto,"attachment='%s", (char *)file_list->data);
250
/* XXX: Work around https://launchpad.net/bugs/757976 . Thunderbird
251
* doesn't properly unescape the file URI's, so just convert them back
252
* to filenames again */
253
filename = g_filename_from_uri ((char *)file_list->data, NULL, NULL);
254
g_string_append_printf (mailto,"attachment='%s", filename);
295
256
for (l = file_list->next ; l; l=l->next){
296
g_string_append_printf (mailto,",%s", (char *)l->data);
257
filename = g_filename_from_uri ((char *)l->data, NULL, NULL);
258
g_string_append_printf (mailto,",%s", filename);
298
261
g_string_append (mailto, "'\"");
348
311
get_evo_mailto (contact_widget, mailto, file_list);
351
cmd = g_strdup_printf (mail_cmd, mailto->str);
314
cmd = g_strconcat (mail_cmd, " ", mailto->str, NULL);
352
315
g_string_free (mailto, TRUE);
354
317
g_message ("Mailer type: %d", type);