Example #1
0
void MainWindow::saveToIcsFile(icalcomponent *comp, std::string uid)
{
    icalset* file = icalfileset_new("/home/quentin/Public/test.ics");
    icalfileset *fset = (icalfileset*) file;

    icalcomponent* old = fetch(file, uid.c_str());
    if (old != NULL)
    {
        icalcomponent_remove_component(icalcomponent_get_first_component(fset->cluster, ICAL_ANY_COMPONENT), old);
    }

    icalcomponent_add_component(icalcomponent_get_first_component(fset->cluster, ICAL_ANY_COMPONENT), comp);

    icalfileset_mark(file);

    icalfileset_commit(file);
    icalfileset_free(file);
}
Example #2
0
/**
 * Add all VTODO components in a file to a list of iCal todo entries.
 * @param ical_todos [in] Current list of iCal todo entries.
 * @param filename [in] Path of the iCal file.
 * @return List of iCal todo entries.
 */
GSList*
read_vtodo_from_ical_file( GSList *ical_todos, const gchar *filename )
{
	icalset       *ical_set;
	icalcomponent *component;
	icalcomponent *c;

	/* Create an iCalendar set based on contents of the specified file. */
	ical_set = icalfileset_new( filename );

	/* Construct a list of iCalendar todo entries based on the VTODO components
	   in the iCalendar set. */
	for( component = icalfileset_get_first_component( ical_set );
		 component != NULL;
		 component = icalfileset_get_next_component( ical_set ) )
	{
		/* If the iCalendar component has a VTODO subcomponent then copy
		   the component into our iCalendar todo list. */
		for( c = icalcomponent_get_first_component( component,
													ICAL_VTODO_COMPONENT );
			 c != NULL;
			 c = icalcomponent_get_next_component( component,
												   ICAL_VTODO_COMPONENT ) )
		{
			{
				/* Add the component to the iCalendar todo list. */
				ical_todos = g_slist_append( ical_todos, c );
			}
		}

		icalcomponent_free( component );
	}

	icalfileset_free( ical_set );

	return( ical_todos );
}