void ical_property_PRIORITY(struct exchange2ical *exchange2ical) { icalproperty *prop; /* Sanity check */ if (!exchange2ical->Importance) return; switch (*exchange2ical->Importance) { case 0x00000000: prop = icalproperty_new_priority(9); break; case 0x00000001: prop = icalproperty_new_priority(5); break; case 0x00000002: prop = icalproperty_new_priority(1); break; default: prop = icalproperty_new_priority(5); } icalcomponent_add_property(exchange2ical->vevent, prop); }
GNOKII_API char * gn_todo2icalstr(gn_todo *ctodo) { #ifdef HAVE_LIBICAL icalcomponent *pIcal = NULL; char compuid[64]; snprintf(compuid, sizeof(compuid), "guid.gnokii.org_%d_%d", ctodo->location, rand()); pIcal = icalcomponent_vanew(ICAL_VCALENDAR_COMPONENT, icalproperty_new_version("2.0"), icalproperty_new_prodid(get_prodid()), icalcomponent_vanew(ICAL_VTODO_COMPONENT, icalproperty_new_categories("GNOKII"), icalproperty_new_priority(ctodo->priority), icalproperty_new_summary(ctodo->text), 0), 0); if (pIcal) { char *icalstrbuf = NULL; const char *icalstr = icalcomponent_as_ical_string(pIcal); /* conversion to UTF-8 */ if (string_base64(icalstr)) { int icalstrlen = strlen(icalstr); icalstrbuf = malloc(icalstrlen * 2 + 1); utf8_encode(icalstrbuf, icalstrlen * 2, icalstr, icalstrlen); } else { icalstrbuf = strdup (icalstr); } icalcomponent_free(pIcal); return icalstrbuf; } return NULL; #else ical_string str; memset(&str, 0, sizeof(str)); ical_append_printf(&str, "BEGIN:VCALENDAR\r\n"); ical_append_printf(&str, "VERSION:1.0\r\n"); ical_append_printf(&str, "BEGIN:VTODO\r\n"); ical_append_printf(&str, "PRIORITY:%i\r\n", ctodo->priority); ical_append_printf(&str, "SUMMARY:%s\r\n", ctodo->text); ical_append_printf(&str, "END:VTODO\r\n"); ical_append_printf(&str, "END:VCALENDAR\r\n"); return str.str; #endif /* HAVE_LIBICAL */ }
void add_class(icalcomponent* calendar, vector<string>& classes) { cout << "What is the name of the class?" << endl; string class_name; cin >> class_name; classes.push_back(class_name); //List each property field one at a time string all_props[] = {"ATTACH", "ATTENDEE", "CATEGORIES", "CLASS", "COMMENT", "CONTACT", "CREATED", "DESCRIPTION", "DTEND", "DTSTAMP", "DTSTART", "DURATION", "EXDATE", "EXRULE", "GEO", "LAST-MOD", "LOCATION", "ORGANIZER", "PRIORITY", "RDATE", "RECURID", "RELATED", "RESOURCES", "RRULE", "RSTATUS", "SEQ", "STATUS", "SUMMARY", "TRANSP", "UID", "URL"}; //FIXME Start/end dates rely on default start/end of semester if user okays default vector<string> values; for (int i = 0; i < 31; i++) { cout << all_props[i] << ": "; std::flush(cout); string value = ""; getline(cin, value); if (cin.fail()) { throw cin_fail_ex; } //FIXME Take user input and validate values.push_back(value); cout << endl; } struct icaltimetype atime = icaltime_from_timet(time(0), 0); //Add the values to the event icalcomponent* class_event = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstamp(atime), icalproperty_new_contact(values[5].c_str()), icalproperty_new_comment(values[4].c_str()), icalproperty_vanew_attach( NULL, //FIXME icalattach *icalattach_new_from_url (const char *url); values[0].c_str(), //FIXME? 0 ), //FIXME icalproperty_new_duration(values[11].c_str()), //needs right type //FIXME icalproperty_new_exdate(values[13].c_str()), //needs struct icaltimetype v //FIXME icalproperty_new_geo(values[14].c_str()), //needs right type //FIXME icalproperty_new_lastmodified(values[15].c_str()), icalproperty_new_priority(atoi(values[18].c_str())), //FIXME icalproperty_vanew_recurid(), //FIXME icalproperty_vanew_related(), //FIXME icalproperty_vanew_resources(), //FIXME icalproperty_vanew_sequence(), //FIXME icalproperty_new_rrule(values[23].c_str()), //FIXME icalproperty_new_status(values[26].c_str()), //FIXME icalproperty_new_rstatus() may not exist... /*FIXME icalproperty_vanew_rdate( values[15].c_str(), icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ),*/ /*FIXME icalproperty_vanew_exdate( //FIXME exceptions to recurrences values[12].c_str(), //FIXME struct icaltimetype v icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ),*/ icalproperty_new_transp(ICAL_TRANSP_NONE), //FIXME values[28]... This is a six-way selector between ICAL_TRANSP_X, ICAL_TRANSP_OPAQUE, ICAL_TRANSP_OPAQUENOCONFLICT, ICAL_TRANSP_TRANSPARENT, ICAL_TRANSP_TRANSPARENTNOCONFLICT, ICAL_TRANSP_NONE... Relates to free/busy conflicts icalproperty_new_uid(values[29].c_str()), icalproperty_new_url(values[30].c_str()), icalproperty_vanew_organizer( values[17].c_str(), icalparameter_new_role(ICAL_ROLE_CHAIR), 0 ), icalproperty_vanew_attendee( values[1].c_str(), icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT), //FIXME overwrites user settings. Either ICAL_ROLE_REQPARTICIPANT, ICAL_ROLE_OPTPARTICIPANT, ICAL_ROLE_NONPARTICIPANT //FIXME icalparameter_new_rsvp(1), //FIXME overwrites user settings icalparameter_new_cutype(ICAL_CUTYPE_GROUP), //FIXME overwrites user settings. Type of calendar user specified by property? 0 ), icalproperty_new_description(values[7].c_str()), icalproperty_new_categories(values[2].c_str()), icalproperty_new_class(ICAL_CLASS_PUBLIC), //FIXME overwrites user settings icalproperty_new_created(atime), //FIXME overwrites user settings icalproperty_new_summary(values[27].c_str()), icalproperty_vanew_dtstart( atime, //FIXME overwrites user settings icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ), icalproperty_vanew_dtend( atime, //FIXME overwrites user settings icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ), icalproperty_new_location(values[16].c_str()), 0 ); //FIXME Handle alarm threads (to be implemented later) //Add the class component to calendar icalcomponent_add_component(calendar, class_event); append_action_to_closed_log("Add Class", true); }
void add_event(icalcomponent* calendar) { string class_name; //Ask if the event is for a class bool is_class_event = yes_no_prompt("Is this event for a class? (y/n)"); //FIXME Following not implemented in this sprint if (is_class_event) { //FIXME If event for class, make sure the semester is not over //FIXME If the semester is over, notify the user //If event for class, prompt for class id cout << "What is the name of this class?" << endl; cin >> class_name; } //List each property field one at a time cout << "Enter information for each of the following properties." << endl; string all_props[] = {"ATTACH", "ATTENDEE", "CATEGORIES", "CLASS", "COMMENT", "CONTACT", "CREATED", "DESCRIPTION", "DTEND", "DTSTAMP", "DTSTART", "DURATION", "EXDATE", "EXRULE", "GEO", "LAST-MOD", "LOCATION", "ORGANIZER", "PRIORITY", "RDATE", "RECURID", "RELATED", "RESOURCES", "RRULE", "RSTATUS", "SEQ", "STATUS", "SUMMARY", "TRANSP", "UID", "URL"}; vector<string> values; for (int i = 0; i < 31; i++) { cout << all_props[i] << ": "; flush(cout); string value = ""; getline(cin, value); //FIXME Check for failbit //FIXME Take user input and validate values.push_back(value); cout << endl; } //If event for class, add property X-CLASS string value = ""; if (is_class_event) { cout << "X-CLASS: "; flush(cout); getline(cin, value); //FIXME Check for failbit //FIXME Take user input and validate values.push_back(value); cout << endl; } struct icaltimetype atime = icaltime_from_timet(time(0), 0); //Add the values to the event icalcomponent* event = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstamp(atime), icalproperty_new_contact(values[5].c_str()), icalproperty_new_comment(values[4].c_str()), icalproperty_vanew_attach( NULL, //FIXME is this the file encoding? values[0].c_str(), 0 ), //FIXME icalproperty_new_duration(values[11].c_str()), //FIXME icalproperty_new_exdate(values[13].c_str()), //FIXME icalproperty_new_geo(values[14].c_str()), //FIXME icalproperty_new_lastmod(values[15].c_str()), icalproperty_new_priority(atoi(values[18].c_str())), //FIXME icalproperty_vanew_recurid(), //FIXME icalproperty_vanew_related(), //FIXME icalproperty_vanew_resources(), //FIXME icalproperty_vanew_sequence(), //FIXME icalproperty_new_rrule(values[23].c_str()), //FIXME icalproperty_new_status(values[26].c_str()), //FIXME icalproperty_new_rstatus() may not exist... /*FIXME icalproperty_vanew_rdate( values[15].c_str(), icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ),*/ /*FIXME icalproperty_vanew_exdate( values[12].c_str(), icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ),*/ //FIXME icalproperty_new_transp(values[28].c_str()), icalproperty_new_uid(values[29].c_str()), icalproperty_new_url(values[30].c_str()), icalproperty_vanew_organizer( values[17].c_str(), icalparameter_new_role(ICAL_ROLE_CHAIR), //FIXME overwrites user settings 0 ), icalproperty_vanew_attendee( values[1].c_str(), icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT), //FIXME overwrites user settings //FIXME icalparameter_new_rsvp(1), //FIXME overwrites user settings icalparameter_new_cutype(ICAL_CUTYPE_GROUP), //FIXME overwrites user settings 0 ), icalproperty_new_description(values[7].c_str()), icalproperty_new_categories(values[2].c_str()), icalproperty_new_class(ICAL_CLASS_PUBLIC), //FIXME overwrites user settings icalproperty_new_created(atime), //FIXME overwrites user settings icalproperty_new_summary(values[27].c_str()), icalproperty_vanew_dtstart( atime, //FIXME overwrites user settings icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ), icalproperty_vanew_dtend( atime, //FIXME overwrites user settings icalparameter_new_tzid("US-Central"), //FIXME should get timezone from user 0 ), icalproperty_new_location(values[16].c_str()), 0 ); if (is_class_event) { icalproperty* p; icalproperty_set_x(p, value.c_str()); icalcomponent_add_property(event, p); } //Add component event to calendar icalcomponent_add_component(calendar,event); //FIXME Handle alarm threads (to be implemented later) append_action_to_closed_log("Add Event", true); }