@ -3,21 +3,23 @@
# include <memory>
# include <memory>
namespace util {
namespace util {
std : : vector < ical : : ical_o bject* > parse_cal_dir ( std : : string directory ) {
std : : vector < ical : : ical_o bject* > objects ;
std : : vector < ical : : IcalO bject* > parse_cal_dir ( std : : string directory ) {
std : : vector < ical : : IcalO bject* > objects ;
std : : vector < icalcomponent * > components ;
std : : vector < icalcomponent * > components ;
uint counter = 0 ;
uint counter = 0 ;
for ( boost : : filesystem : : directory_entry & entry : boost : : filesystem : : directory_iterator ( directory ) ) {
for ( boost : : filesystem : : directory_entry & entry : boost : : filesystem : : directory_iterator ( directory ) ) {
DEBUG < < " Parsing: " + entry . path ( ) . generic_string ( ) ;
DEBUG < < " Parsing: " + entry . path ( ) . generic_string ( ) ;
ical : : ical_o bject* object = new ical : : ical_o bject( ) ;
ical : : IcalO bject* object = new ical : : IcalO bject( ) ;
parse_main_component ( object , parse_ics_file ( entry . path ( ) . generic_string ( ) ) ) ;
parse_main_component ( object , parse_ics_file ( entry . path ( ) . generic_string ( ) ) ) ;
objects . push_back ( object ) ;
counter + + ;
counter + + ;
}
}
DEBUG < < " files parsed: " < < counter ;
DEBUG < < " files parsed: " < < counter ;
DEBUG < < " objects: " < < objects . size ( ) ;
return objects ;
return objects ;
}
}
icalcomponent * parse_main_component ( ical : : ical_o bject* object , icalcomponent * component ) {
icalcomponent * parse_main_component ( ical : : IcalO bject* object , icalcomponent * component ) {
icalcomponent * c = icalcomponent_get_first_component ( component , ICAL_ANY_COMPONENT ) ;
icalcomponent * c = icalcomponent_get_first_component ( component , ICAL_ANY_COMPONENT ) ;
while ( c ! = 0 ) {
while ( c ! = 0 ) {
if ( c ! = 0 ) {
if ( c ! = 0 ) {
@ -31,197 +33,197 @@ namespace util {
return c ;
return c ;
}
}
void parse_component ( ical : : ical_o bject* object , icalcomponent * component ) {
void parse_component ( ical : : IcalO bject* object , icalcomponent * component ) {
switch ( icalcomponent_isa ( component ) ) {
switch ( icalcomponent_isa ( component ) ) {
case ICAL_VALARM_COMPONENT : break ;
case ICAL_VALARM_COMPONENT : break ;
case ICAL_NO_COMPONENT :
case ICAL_NO_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_NO_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_NO_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_ANY_COMPONENT :
case ICAL_ANY_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_ANY_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_ANY_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XROOT_COMPONENT :
case ICAL_XROOT_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XROOT_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XROOT_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XATTACH_COMPONENT :
case ICAL_XATTACH_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XATTACH_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XATTACH_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VEVENT_COMPONENT :
case ICAL_VEVENT_COMPONENT :
{
{
//DEBUG << "parsed component: ICAL_VEVENT_COMPONENT";
//DEBUG << "parsed component: ICAL_VEVENT_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
ical : : Event ( object , component ) ;
object - > add_event ( new ical : : Event ( component ) ) ;
break ;
break ;
}
}
case ICAL_VTODO_COMPONENT :
case ICAL_VTODO_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VTODO_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VTODO_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VJOURNAL_COMPONENT :
case ICAL_VJOURNAL_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VJOURNAL_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VJOURNAL_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VCALENDAR_COMPONENT :
case ICAL_VCALENDAR_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VCALENDAR_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VCALENDAR_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VAGENDA_COMPONENT :
case ICAL_VAGENDA_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VAGENDA_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VAGENDA_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VFREEBUSY_COMPONENT :
case ICAL_VFREEBUSY_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VFREEBUSY_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VFREEBUSY_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XAUDIOALARM_COMPONENT :
case ICAL_XAUDIOALARM_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XAUDIOALARM_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XAUDIOALARM_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XDISPLAYALARM_COMPONENT :
case ICAL_XDISPLAYALARM_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XDISPLAYALARM_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XDISPLAYALARM_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XEMAILALARM_COMPONENT :
case ICAL_XEMAILALARM_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XEMAILALARM_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XEMAILALARM_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XPROCEDUREALARM_COMPONENT :
case ICAL_XPROCEDUREALARM_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XPROCEDUREALARM_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XPROCEDUREALARM_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VTIMEZONE_COMPONENT :
case ICAL_VTIMEZONE_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VTIMEZONE_COMPONENT " ;
//DEBUG << "parsed component: ICAL_VTIMEZONE_COMPONENT";
break ;
break ;
}
}
case ICAL_XSTANDARD_COMPONENT :
case ICAL_XSTANDARD_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XSTANDARD_COMPONENT " ;
//DEBUG << "parsed component: ICAL_XSTANDARD_COMPONENT";
break ;
break ;
}
}
case ICAL_XDAYLIGHT_COMPONENT :
case ICAL_XDAYLIGHT_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XDAYLIGHT_COMPONENT " ;
//DEBUG << "parsed component: ICAL_XDAYLIGHT_COMPONENT";
break ;
break ;
}
}
case ICAL_X_COMPONENT :
case ICAL_X_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_X_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_X_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VSCHEDULE_COMPONENT :
case ICAL_VSCHEDULE_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VSCHEDULE_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VSCHEDULE_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VQUERY_COMPONENT :
case ICAL_VQUERY_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VQUERY_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VQUERY_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VREPLY_COMPONENT :
case ICAL_VREPLY_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VREPLY_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VREPLY_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VCAR_COMPONENT :
case ICAL_VCAR_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VCAR_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VCAR_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VCOMMAND_COMPONENT :
case ICAL_VCOMMAND_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VCOMMAND_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VCOMMAND_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XLICINVALID_COMPONENT :
case ICAL_XLICINVALID_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XLICINVALID_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XLICINVALID_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XLICMIMEPART_COMPONENT :
case ICAL_XLICMIMEPART_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XLICMIMEPART_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XLICMIMEPART_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VAVAILABILITY_COMPONENT :
case ICAL_VAVAILABILITY_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VAVAILABILITY_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VAVAILABILITY_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XAVAILABLE_COMPONENT :
case ICAL_XAVAILABLE_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XAVAILABLE_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XAVAILABLE_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VPOLL_COMPONENT :
case ICAL_VPOLL_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VPOLL_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VPOLL_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VVOTER_COMPONENT :
case ICAL_VVOTER_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VVOTER_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VVOTER_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XVOTE_COMPONENT :
case ICAL_XVOTE_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XVOTE_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XVOTE_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_VPATCH_COMPONENT :
case ICAL_VPATCH_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_VPATCH_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_VPATCH_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
case ICAL_XPATCH_COMPONENT :
case ICAL_XPATCH_COMPONENT :
{
{
DEBUG < < " parsed component: ICAL_XPATCH_COMPONENT " ;
DEBUG < < " \n " < < icalcomponent_as_ical_string_r ( component ) ;
//DEBUG << "parsed component: ICAL_XPATCH_COMPONENT";
//DEBUG << "\n" << icalcomponent_as_ical_string_r(component);
break ;
break ;
}
}
default :
default :