aboutsummaryrefslogtreecommitdiffstats
path: root/mail/importers
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-18 02:35:37 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-18 02:35:37 +0800
commitdf6c612eaa2e2f1b1b691d1f56d7079c9700a826 (patch)
tree43b9e2789ee71d340483f87b4c26c9a639dab08a /mail/importers
parent20085e766ba79c4ecf7da1ba26dc6e09e2c7450d (diff)
downloadgsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.gz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.bz2
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.lz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.xz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.zst
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.zip
importers/elm-importer.c importers/evolution-mbox-importer.c
2005-12-17 Tor Lillqvist <tml@novell.com> * importers/elm-importer.c * importers/evolution-mbox-importer.c * importers/evolution-outlook-importer.c * importers/mail-importer.c * importers/netscape-importer.c * importers/pine-importer.c: Use GLib API when applicable. svn path=/trunk/; revision=30843
Diffstat (limited to 'mail/importers')
-rw-r--r--mail/importers/elm-importer.c5
-rw-r--r--mail/importers/evolution-mbox-importer.c11
-rw-r--r--mail/importers/evolution-outlook-importer.c9
-rw-r--r--mail/importers/mail-importer.c27
-rw-r--r--mail/importers/netscape-importer.c3
-rw-r--r--mail/importers/pine-importer.c5
6 files changed, 37 insertions, 23 deletions
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index 7d8abdfa04..cf8479ef90 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -159,7 +159,6 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
const char *maildir;
char *elmdir;
gboolean mailexists, exists;
- struct stat st;
if (target->type != E_IMPORT_TARGET_HOME)
return FALSE;
@@ -167,7 +166,7 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
s = (EImportTargetHome *)target;
elmdir = g_build_filename(s->homedir, ".elm", NULL);
- exists = lstat(elmdir, &st) == 0 && S_ISDIR(st.st_mode);
+ exists = g_file_test(elmdir, G_FILE_TEST_IS_DIR);
g_free(elmdir);
if (!exists)
return FALSE;
@@ -181,7 +180,7 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
else
elmdir = g_strdup (maildir);
- mailexists = lstat(elmdir, &st) == 0 && S_ISDIR(st.st_mode);
+ mailexists = g_file_test(elmdir, G_FILE_TEST_IS_DIR);
g_free (elmdir);
return mailexists;
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index 804a137543..32d0ab60ef 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -40,6 +40,7 @@
#include <gtk/gtklabel.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <camel/camel-exception.h>
@@ -102,6 +103,7 @@ mbox_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
gboolean ret = FALSE;
int fd, n;
EImportTargetURI *s;
+ char *filename;
if (target->type != E_IMPORT_TARGET_URI)
return FALSE;
@@ -113,7 +115,9 @@ mbox_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
if (strncmp(s->uri_src, "file:///", strlen("file:///")) != 0)
return FALSE;
- fd = open(s->uri_src + strlen("file://"), O_RDONLY);
+ filename = g_filename_from_uri(s->uri_src, NULL, NULL);
+ fd = g_open(filename, O_RDONLY, 0);
+ g_free(filename);
if (fd != -1) {
n = read(fd, signature, 5);
ret = n == 5 && memcmp(signature, "From ", 5) == 0;
@@ -178,6 +182,7 @@ static void
mbox_import(EImport *ei, EImportTarget *target, EImportImporter *im)
{
MboxImporter *importer;
+ char *filename;
/* TODO: do we validate target? */
@@ -189,7 +194,9 @@ mbox_import(EImport *ei, EImportTarget *target, EImportImporter *im)
importer->status_timeout_id = g_timeout_add(100, mbox_status_timeout, importer);
importer->cancel = camel_operation_new(mbox_status, importer);
- mail_importer_import_mbox(((EImportTargetURI *)target)->uri_src+strlen("file://"), ((EImportTargetURI *)target)->uri_dest, importer->cancel, mbox_import_done, importer);
+ filename = g_filename_from_uri(((EImportTargetURI *)target)->uri_src, NULL, NULL);
+ mail_importer_import_mbox(filename, ((EImportTargetURI *)target)->uri_dest, importer->cancel, mbox_import_done, importer);
+ g_free(filename);
}
static void
diff --git a/mail/importers/evolution-outlook-importer.c b/mail/importers/evolution-outlook-importer.c
index ca04678260..04f14bfc01 100644
--- a/mail/importers/evolution-outlook-importer.c
+++ b/mail/importers/evolution-outlook-importer.c
@@ -34,6 +34,9 @@
#include <ctype.h>
#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkmessagedialog.h>
@@ -51,6 +54,8 @@
#include <importer/evolution-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
+#include <e-util/e-util-private.h>
+
#include "mail/em-folder-selection-button.h"
#include "mail/mail-component.h"
@@ -154,7 +159,7 @@ support_format_fn(EvolutionImporter *importer, const char *filename, void *data)
Taken from liboe 0.92 (STABLE)
Copyright (C) 2000 Stephan B. Nedregård (stephan@micropop.com) */
- handle = fopen (filename, "rb");
+ handle = g_fopen (filename, "rb");
if (handle == NULL)
return FALSE; /* Can't open file: Can't support it :) */
@@ -332,7 +337,7 @@ import_outlook_import(struct _mail_msg *mm)
int fd;
off_t pos;
- fd = open(m->path, O_RDONLY);
+ fd = g_open(m->path, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
goto fail;
diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c
index e1a7110be7..f317797c1d 100644
--- a/mail/importers/mail-importer.c
+++ b/mail/importers/mail-importer.c
@@ -28,12 +28,14 @@
#include <string.h>
#include <sys/types.h>
-#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
#include <gmodule.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-i18n.h>
@@ -196,7 +198,7 @@ import_mbox_import(struct _mail_msg *mm)
int fd;
CamelMessageInfo *info;
- if (stat(m->path, &st) == -1) {
+ if (g_stat(m->path, &st) == -1) {
g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
return;
}
@@ -212,7 +214,7 @@ import_mbox_import(struct _mail_msg *mm)
if (S_ISREG(st.st_mode)) {
CamelOperation *oldcancel = NULL;
- fd = open(m->path, O_RDONLY);
+ fd = g_open(m->path, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
goto fail1;
@@ -359,13 +361,13 @@ struct _import_folders_data {
static void
import_folders_rec(struct _import_folders_data *m, const char *filepath, const char *folderparent)
{
- DIR *dir;
- struct dirent *d;
+ GDir *dir;
+ const char *d;
struct stat st;
char *filefull, *foldersub, *uri, *utf8_filename;
const char *folder;
- dir = opendir(filepath);
+ dir = g_dir_open(filepath, 0, NULL);
if (dir == NULL)
return;
@@ -373,21 +375,21 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
camel_operation_start(NULL, _("Scanning %s"), utf8_filename);
g_free (utf8_filename);
- while ( (d=readdir(dir)) ) {
- if (d->d_name[0] == '.')
+ while ( (d=g_dir_read_name(dir))) {
+ if (d[0] == '.')
continue;
- filefull = g_build_filename(filepath, d->d_name, NULL);
+ filefull = g_build_filename(filepath, d, NULL);
/* skip non files and directories, and skip directories in mozilla mode */
- if (stat(filefull, &st) == -1
+ if (g_stat(filefull, &st) == -1
|| !(S_ISREG(st.st_mode)
|| (m->elmfmt && S_ISDIR(st.st_mode)))) {
g_free(filefull);
continue;
}
- folder = d->d_name;
+ folder = d;
if (folderparent == NULL) {
int i;
@@ -412,7 +414,7 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
g_free(filefull);
filefull = tmp;
- if (stat(filefull, &st) == -1) {
+ if (g_stat(filefull, &st) == -1) {
g_free(filefull);
continue;
}
@@ -426,6 +428,7 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
g_free(filefull);
}
+ g_dir_close(dir);
camel_operation_end(NULL);
}
diff --git a/mail/importers/netscape-importer.c b/mail/importers/netscape-importer.c
index d36f98ce73..518ca2fd4c 100644
--- a/mail/importers/netscape-importer.c
+++ b/mail/importers/netscape-importer.c
@@ -36,6 +36,7 @@
#include <dirent.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <gnome.h>
#include <gconf/gconf.h>
@@ -1652,7 +1653,7 @@ is_dir_empty (const char *path)
}
fullpath = g_build_filename(path, contents->d_name, NULL);
- if (lstat (fullpath, &buf) == -1) {
+ if (g_lstat (fullpath, &buf) == -1) {
g_free(fullpath);
continue;
}
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index ea6c9b669b..05f893f678 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -74,7 +74,6 @@ pine_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
EImportTargetHome *s;
char *maildir, *addrfile;
gboolean md_exists, addr_exists;
- struct stat st;
if (target->type != E_IMPORT_TARGET_HOME)
return FALSE;
@@ -82,11 +81,11 @@ pine_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
s = (EImportTargetHome *)target;
maildir = g_build_filename(s->homedir, "mail", NULL);
- md_exists = lstat(maildir, &st) == 0 && S_ISDIR(st.st_mode);
+ md_exists = g_file_test(maildir, G_FILE_TEST_IS_DIR);
g_free(maildir);
addrfile = g_build_filename(s->homedir, ".addressbook", NULL);
- addr_exists = lstat(addrfile, &st) == 0 && S_ISREG(st.st_mode);
+ addr_exists = g_file_test(addrfile, G_FILE_TEST_IS_REGULAR);
g_free (addrfile);
return md_exists || addr_exists;