void ical_property_TRANSP(struct exchange2ical *exchange2ical)
{
	icalproperty *prop;

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

	switch (*exchange2ical->BusyStatus) {
	case 0x00000000:
		prop = icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT);
		break;
	case 0x00000001:
	case 0x00000002:
	case 0x00000003:
		prop = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
		break;
	default:
		prop = icalproperty_new_transp(ICAL_TRANSP_NONE);
	}
	icalcomponent_add_property(exchange2ical->vevent, prop);
}
static void
set_transparency (ECalModelComponent *comp_data,
                  gconstpointer value)
{
	icalproperty *prop;

	prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_TRANSP_PROPERTY);

	if (string_is_empty (value)) {
		if (prop) {
			icalcomponent_remove_property (comp_data->icalcomp, prop);
			icalproperty_free (prop);
		}
	} else {
		icalproperty_transp transp;

		if (!g_ascii_strcasecmp (value, "FREE"))
			transp = ICAL_TRANSP_TRANSPARENT;
		else if (!g_ascii_strcasecmp (value, "OPAQUE"))
			transp = ICAL_TRANSP_OPAQUE;
		else {
			if (prop) {
				icalcomponent_remove_property (comp_data->icalcomp, prop);
				icalproperty_free (prop);
			}

			return;
		}

		if (prop)
			icalproperty_set_transp (prop, transp);
		else {
			prop = icalproperty_new_transp (transp);
			icalcomponent_add_property (comp_data->icalcomp, prop);
		}
	}
}
Example #3
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);
}