aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-utils.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-18 16:24:26 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-18 16:24:26 +0800
commit448d624c00f0c4e12917a4d31babd10555b2e8a4 (patch)
treec44c6e6864f1e0cd34455da2e71fc33ca13d61e6 /mail/em-utils.c
parent2f1a024be76933ba28ab80e76a52ff46358e33dd (diff)
downloadgsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar.gz
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar.bz2
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar.lz
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar.xz
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.tar.zst
gsoc2013-evolution-448d624c00f0c4e12917a4d31babd10555b2e8a4.zip
em-folder-browser.c em-folder-view.c em-format-html.c
2005-12-18 Tor Lillqvist <tml@novell.com> * em-folder-browser.c * em-folder-view.c * em-format-html.c * em-format-html-display.c * em-mailer-prefs.c * em-message-browser.c * em-migrate.c * em-subscribe-editor.c * em-sync-stream.c * em-utils.c * em-vfolder-editor.c * em-vfolder-rule.c * mail-autofilter.c * mail-component.c * mail-config.c * mail-folder-cache.c: Use gstdio wrappers. Construct pathnames of glade, xml, etspec and png files at run-time. Use g_filename_{to,from}_uri(). * em-folder-browser.c (emfb_init) * em-folder-view.c (emfv_finalise) * em-message-browser.c (emmb_init): As EMFolderView::ui_files now always is a list of filenames constructed with g_build_filename(), use g_free() on each list entry before calling g_slist_free() on the list. * em-folder-tree-model.c (em_folder_tree_model_load_state): Use e_xml_parse_file(). * em-migrate.c: Bypass all the code for upgrading from 1.x on Win32. (emm_setup_initial): Use GDir instead of dirent. * em-sync-stream.c * mail-folder-cache.c: Use pthread_equal() to compare pthread_t values. * em-vfs-stream.c: No EINPROGRESS or ELOOP on Win32. svn path=/trunk/; revision=30854
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r--mail/em-utils.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 434b0205d9..dcc8ec7971 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -31,6 +31,21 @@
#include <errno.h>
#include <time.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#ifdef G_OS_WIN32
+/* Work around namespace clobbage in <windows.h> */
+#define DATADIR windows_DATADIR
+#include <windows.h>
+#undef DATADIR
+#undef interface
+#endif
+
+#if !GLIB_CHECK_VERSION (2, 8, 0)
+#define g_access access
+#endif
+
#include <camel/camel-stream-fs.h>
#include <camel/camel-url-scanner.h>
#include <camel/camel-file-utils.h>
@@ -53,12 +68,13 @@
#include "mail-config.h"
#include "message-tag-followup.h"
-#include <e-util/e-mktemp.h>
-#include <e-util/e-account-list.h>
-#include <e-util/e-dialog-utils.h>
+#include "e-util/e-util.h"
+#include "e-util/e-util-private.h"
+#include "e-util/e-mktemp.h"
+#include "e-util/e-account-list.h"
+#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
-#include <e-util/e-util.h>
#include "em-utils.h"
#include "em-composer-utils.h"
@@ -317,9 +333,10 @@ em_utils_edit_filters (GtkWidget *parent)
fc = em_filter_context_new ();
user = g_strdup_printf ("%s/mail/filters.xml", base_directory);
- system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
+ system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
rule_context_load ((RuleContext *) fc, system, user);
g_free (user);
+ g_free (system);
if (((RuleContext *) fc)->error) {
e_error_run((GtkWindow *)parent, "mail:filter-load-error", ((RuleContext *)fc)->error, NULL);
@@ -420,11 +437,11 @@ emu_can_save(GtkWindow *parent, const char *path)
return FALSE;
/* make sure we can actually save to it... */
- if (stat (path, &st) != -1 && !S_ISREG (st.st_mode))
+ if (g_stat (path, &st) != -1 && !S_ISREG (st.st_mode))
return FALSE;
- if (access (path, F_OK) == 0) {
- if (access (path, W_OK) != 0) {
+ if (g_access (path, F_OK) == 0) {
+ if (g_access (path, W_OK) != 0) {
e_error_run(parent, "mail:no-save-path", path, g_strerror(errno), NULL);
return FALSE;
}
@@ -582,14 +599,14 @@ em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePar
}
g_free(dirname);
- if (access(filename, F_OK) == 0) {
- if (access(filename, W_OK) != 0) {
+ if (g_access(filename, F_OK) == 0) {
+ if (g_access(filename, W_OK) != 0) {
e_error_run((GtkWindow *)parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, filename, NULL);
return FALSE;
}
}
- if (stat(filename, &st) != -1 && !S_ISREG(st.st_mode)) {
+ if (g_stat(filename, &st) != -1 && !S_ISREG(st.st_mode)) {
e_error_run((GtkWindow *)parent, "mail:no-write-path-notfile", filename, NULL);
return FALSE;
}
@@ -1158,7 +1175,7 @@ em_utils_selection_set_urilist(GtkSelectionData *data, CamelFolder *folder, GPtr
{
char *tmpdir;
CamelStream *fstream;
- char *uri, *p, *file = NULL;
+ char *uri, *file = NULL, *tmpfile;
int fd;
CamelMessageInfo *info;
@@ -1183,25 +1200,30 @@ em_utils_selection_set_urilist(GtkSelectionData *data, CamelFolder *folder, GPtr
e_filename_make_safe(file);
- p = uri = g_alloca (strlen (tmpdir) + strlen(file) + 16);
- p += sprintf (uri, "file:///%s/%s", tmpdir, file);
+ tmpfile = g_build_filename(tmpdir, file, NULL);
g_free(tmpdir);
g_free(file);
- fd = open(uri + 7, O_WRONLY | O_CREAT | O_EXCL, 0666);
- if (fd == -1)
+ fd = g_open(tmpfile, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0666);
+ g_free(tmpfile);
+ if (fd == -1) {
return;
-
+ }
+
+ uri = g_filename_to_uri(tmpfile, NULL, NULL);
fstream = camel_stream_fs_new_with_fd(fd);
if (fstream) {
- /* terminate with \r\n to be compliant with the spec */
- strcpy (p, "\r\n");
-
- if (em_utils_write_messages_to_stream(folder, uids, fstream) == 0)
- gtk_selection_data_set(data, data->target, 8, uri, strlen(uri));
+ if (em_utils_write_messages_to_stream(folder, uids, fstream) == 0) {
+ /* terminate with \r\n to be compliant with the spec */
+ char *uri_crlf = g_strconcat(uri, "\r\n", NULL);
+
+ gtk_selection_data_set(data, data->target, 8, uri_crlf, strlen(uri_crlf));
+ g_free(uri_crlf);
+ }
camel_object_unref(fstream);
}
+ g_free(uri);
}
/**
@@ -1237,7 +1259,7 @@ em_utils_selection_get_urilist(GtkSelectionData *data, CamelFolder *folder)
continue;
if (strcmp(url->protocol, "file") == 0
- && (fd = open(url->path, O_RDONLY)) != -1) {
+ && (fd = g_open(url->path, O_RDONLY | O_BINARY, 0)) != -1) {
stream = camel_stream_fs_new_with_fd(fd);
res = em_utils_read_messages_from_stream(folder, stream);
camel_object_unref(stream);
@@ -1818,6 +1840,14 @@ char *em_uri_to_camel(const char *euri)
curl = camel_url_new("mbox:", NULL);
base = g_strdup_printf("%s/.evolution/mail/%s", g_get_home_dir(), eurl->user);
+#ifdef G_OS_WIN32
+ /* Turn backslashes into slashes to avoid URI encoding */
+ {
+ char *p = base;
+ while ((p = strchr (p, '\\')))
+ *p++ = '/';
+ }
+#endif
camel_url_set_path(curl, base);
g_free(base);
camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);