diff options
author | Tor Lillqvist <tml@novell.com> | 2005-12-17 22:05:09 +0800 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2005-12-17 22:05:09 +0800 |
commit | 6fee209459e6d39ce953371260b0515db1e31395 (patch) | |
tree | 6a0a7843ddae5d54d9150032e7cf22cf5d719f90 | |
parent | eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3 (diff) | |
download | gsoc2013-evolution-6fee209459e6d39ce953371260b0515db1e31395.tar.gz gsoc2013-evolution-6fee209459e6d39ce953371260b0515db1e31395.tar.zst gsoc2013-evolution-6fee209459e6d39ce953371260b0515db1e31395.zip |
Use g_build_filename(), g_filename_from_uri(), g_usleep().
2005-12-17 Tor Lillqvist <tml@novell.com>
* importers/icalendar-importer.c: Use g_build_filename(),
g_filename_from_uri(), g_usleep().
svn path=/trunk/; revision=30818
-rw-r--r-- | calendar/ChangeLog | 5 | ||||
-rw-r--r-- | calendar/importers/icalendar-importer.c | 52 |
2 files changed, 47 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f29074b532..8de3da0e90 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -28,7 +28,10 @@ * gui/dialogs/cal-attachment-bar.c: Remove unused files from CVS. * gui/dialogs/comp-editor.c: : Use gstdio wrappers. Use - g_filename_from_uri() + g_filename_from_uri(). + + * importers/icalendar-importer.c: Use g_build_filename(), + g_filename_from_uri(), g_usleep(). 2005-12-15 Srinivasa Ragavan <sragavan@novell.com> diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index b35c08e99a..eccd08d641 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -46,6 +46,7 @@ #include "common/authentication.h" #include "e-util/e-import.h" +#include "e-util/e-util-private.h" /* We timeout after 2 minutes, when opening the folders. */ #define IMPORTER_TIMEOUT_SECONDS 120 @@ -360,6 +361,7 @@ ivcal_cancel(EImport *ei, EImportTarget *target, EImportImporter *im) static gboolean ical_supported(EImport *ei, EImportTarget *target, EImportImporter *im) { + char *filename; char *contents; gboolean ret = FALSE; EImportTargetURI *s; @@ -374,7 +376,11 @@ ical_supported(EImport *ei, EImportTarget *target, EImportImporter *im) if (strncmp(s->uri_src, "file:///", 8) != 0) return FALSE; - if (g_file_get_contents (s->uri_src+7, &contents, NULL, NULL)) { + filename = g_filename_from_uri (s->uri_src, NULL, NULL); + if (!filename) + return FALSE; + + if (g_file_get_contents (filename, &contents, NULL, NULL)) { icalcomponent *icalcomp; icalcomp = e_cal_util_parse_ics_string (contents); @@ -388,6 +394,7 @@ ical_supported(EImport *ei, EImportTarget *target, EImportImporter *im) icalcomponent_free (icalcomp); } } + g_free (filename); return ret; } @@ -395,16 +402,24 @@ ical_supported(EImport *ei, EImportTarget *target, EImportImporter *im) static void ical_import(EImport *ei, EImportTarget *target, EImportImporter *im) { + char *filename; char *contents; icalcomponent *icalcomp; EImportTargetURI *s = (EImportTargetURI *)target; - /* FIXME: uri */ - if (!g_file_get_contents (s->uri_src+7, &contents, NULL, NULL)) { + filename = g_filename_from_uri (s->uri_src, NULL, NULL); + if (!filename) { e_import_complete(ei, target); return; } + if (!g_file_get_contents (filename, &contents, NULL, NULL)) { + g_free (filename); + e_import_complete(ei, target); + return; + } + g_free (filename); + icalcomp = e_cal_util_parse_ics_string (contents); g_free (contents); @@ -440,6 +455,7 @@ ical_importer_peek(void) static gboolean vcal_supported(EImport *ei, EImportTarget *target, EImportImporter *im) { + char *filename; char *contents; gboolean ret = FALSE; EImportTargetURI *s; @@ -454,9 +470,13 @@ vcal_supported(EImport *ei, EImportTarget *target, EImportImporter *im) if (strncmp(s->uri_src, "file:///", 8) != 0) return FALSE; + filename = g_filename_from_uri (s->uri_src, NULL, NULL); + if (!filename) + return FALSE; + /* Z: Wow, this is *efficient* */ - if (g_file_get_contents(s->uri_src+7, &contents, NULL, NULL)) { + if (g_file_get_contents(filename, &contents, NULL, NULL)) { VObject *vcal; /* parse the file */ @@ -476,6 +496,7 @@ vcal_supported(EImport *ei, EImportTarget *target, EImportImporter *im) cleanVObject (vcal); } } + g_free (filename); return ret; } @@ -488,8 +509,14 @@ load_vcalendar_file (const char *filename) icalvcal_defaults defaults = { 0 }; icalcomponent *icalcomp = NULL; char *contents; - - defaults.alarm_audio_url = "file://" EVOLUTION_SOUNDDIR "/default_alarm.wav"; + char *default_alarm_filename; + + default_alarm_filename = g_build_filename (EVOLUTION_SOUNDDIR, + "default_alarm.wav", + NULL); + defaults.alarm_audio_url = g_filename_to_uri (default_alarm_filename, + NULL, NULL); + g_free (default_alarm_filename); defaults.alarm_audio_fmttype = "audio/x-wav"; defaults.alarm_description = (char*) _("Reminder!!"); @@ -513,11 +540,18 @@ load_vcalendar_file (const char *filename) static void vcal_import(EImport *ei, EImportTarget *target, EImportImporter *im) { + char *filename; icalcomponent *icalcomp; EImportTargetURI *s = (EImportTargetURI *)target; - /* FIXME: uri */ - icalcomp = load_vcalendar_file(s->uri_src+7); + filename = g_filename_from_uri(s->uri_src, NULL, NULL); + if (!filename) { + e_import_complete(ei, target); + return; + } + + icalcomp = load_vcalendar_file(filename); + g_free (filename); if (icalcomp) ivcal_import(ei, target, icalcomp); else @@ -631,7 +665,7 @@ gnome_calendar_import(EImport *ei, EImportTarget *target, EImportImporter *im) && tasks_state == E_CAL_LOAD_LOADED) break; - sleep(1); + g_usleep(1000000); if (ici->cancelled) goto out; } |