void ical_property_CONTACT(struct exchange2ical *exchange2ical)
{
	icalproperty	*prop;
	uint32_t	i;

	/* Sanity check */
	if (!exchange2ical->Contacts) return;
	if (!exchange2ical->Contacts->cValues) return;

	for (i = 0; i < exchange2ical->Contacts->cValues; i++) {
		prop = icalproperty_new_contact(exchange2ical->Contacts->lppszA[i]);
		icalcomponent_add_property(exchange2ical->vevent, prop);
	}
}
Example #2
0
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);
}
Example #3
0
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);
}