aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-03-25 21:57:25 +0800
committerDan Winship <danw@src.gnome.org>2003-03-25 21:57:25 +0800
commit5d40c589ac1f330e06d6384ebd150f24f15c04a9 (patch)
treec92a8d01fdd15526c650b1d67fa74b4c8ba6f224 /calendar/pcs
parentbe58e1949e5df9f14d07f1019a273a74aa4982f8 (diff)
downloadgsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.gz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.bz2
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.lz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.xz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.zst
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.zip
Utility wrapper around icalparser.
* cal-util/cal-util.c (cal_util_parse_ics_file): Utility wrapper around icalparser. * cal-util/test-recur.c (main): Use it * pcs/cal-backend-file.c (open_cal): Likewise * gui/comp-editor-factory.c (open_client): Add the OpenClient to the hash before calling cal_client_open_calendar, since in some failure cases, that will call cal_opened_cb (which will free the oc) with a failure immediately, causing a crash if we then try to deref it. svn path=/trunk/; revision=20492
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-backend-file.c49
1 files changed, 6 insertions, 43 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index 7ab6506aa9..d11df6d076 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <string.h>
+#include <unistd.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
#include <libgnome/gnome-i18n.h>
@@ -679,53 +680,19 @@ scan_vcalendar (CalBackendFile *cbfile)
}
}
-/* Callback used from icalparser_parse() */
-static char *
-get_line_fn (char *s, size_t size, void *data)
-{
- FILE *file;
-
- file = data;
- return fgets (s, size, file);
-}
-
-/* Parses an open iCalendar file and returns a toplevel component with the contents */
-static icalcomponent *
-parse_file (FILE *file)
-{
- icalparser *parser;
- icalcomponent *icalcomp;
-
- parser = icalparser_new ();
- icalparser_set_gen_data (parser, file);
-
- icalcomp = icalparser_parse (parser, get_line_fn);
- icalparser_free (parser);
-
- return icalcomp;
-}
-
/* Parses an open iCalendar file and loads it into the backend */
static CalBackendOpenStatus
-open_cal (CalBackendFile *cbfile, const char *uristr, FILE *file)
+open_cal (CalBackendFile *cbfile, const char *uristr)
{
CalBackendFilePrivate *priv;
icalcomponent *icalcomp;
priv = cbfile->priv;
- icalcomp = parse_file (file);
-
- if (fclose (file) != 0) {
- if (icalcomp)
- icalcomponent_free (icalcomp);
-
- return CAL_BACKEND_OPEN_ERROR;
- }
-
+ icalcomp = cal_util_parse_ics_file (uristr);
if (!icalcomp)
return CAL_BACKEND_OPEN_ERROR;
-
+
/* FIXME: should we try to demangle XROOT components and
* individual components as well?
*/
@@ -771,7 +738,6 @@ cal_backend_file_open (CalBackend *backend, const char *uristr, gboolean only_if
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
- FILE *file;
char *str_uri;
GnomeVFSURI *uri;
CalBackendOpenStatus status;
@@ -806,11 +772,8 @@ cal_backend_file_open (CalBackend *backend, const char *uristr, gboolean only_if
return CAL_BACKEND_OPEN_ERROR;
}
- /* Load! */
- file = fopen (str_uri, "r");
-
- if (file)
- status = open_cal (cbfile, str_uri, file);
+ if (access (str_uri, R_OK) == 0)
+ status = open_cal (cbfile, str_uri);
else {
if (only_if_exists)
status = CAL_BACKEND_OPEN_NOT_FOUND;