int main(int argc, char *argv[]) { VObject *vcal = 0; icalcomponent *comp; char *file; if (argc != 2) { file = "../../test-data/user-cal.vcf"; } else { file = argv[1]; } vcal = Parse_MIME_FromFileName(file); assert(vcal != 0); comp = icalvcal_convert(vcal); printf("%s\n", icalcomponent_as_ical_string(comp)); return 0; }
static gboolean vcal_supported (EImport *ei, EImportTarget *target, EImportImporter *im) { gchar *filename; gchar *contents; gboolean ret = FALSE; EImportTargetURI *s; if (target->type != E_IMPORT_TARGET_URI) return FALSE; s = (EImportTargetURI *) target; if (s->uri_src == NULL) return TRUE; 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 (filename, &contents, NULL, NULL)) { VObject *vcal; icalcomponent *icalcomp; icalcomp = e_cal_util_parse_ics_string (contents); if (icalcomp && is_icalcomp_usable (icalcomp)) { /* If we can create proper iCalendar from the file, then * rather use ics importer, because it knows to read more * information than older version, the vCalendar. */ ret = FALSE; g_free (contents); } else { if (icalcomp) icalcomponent_free (icalcomp); /* parse the file */ vcal = Parse_MIME (contents, strlen (contents)); g_free (contents); if (vcal) { icalcomp = icalvcal_convert (vcal); if (icalcomp) { icalcomponent_free (icalcomp); ret = TRUE; } cleanVObject (vcal); } } } g_free (filename); return ret; }