Ejemplo n.º 1
0
icalproperty *icallangbind_get_next_property(icalcomponent *c, const char *prop)
{
    icalproperty_kind kind = icalenum_string_to_property_kind(prop);
    icalproperty *p;

    if (kind == ICAL_NO_PROPERTY) {
        return 0;
    }

    if (kind == ICAL_X_PROPERTY) {
        for (p = icalcomponent_get_next_property(c, kind);
             p != 0; p = icalcomponent_get_next_property(c, kind)) {

            if (strcmp(icalproperty_get_x_name(p), prop) == 0) {
                return p;
            }
        }
    } else {
        p = icalcomponent_get_next_property(c, kind);

        return p;
    }

    return 0;
}
NS_IMETHODIMP
calIcalComponent::GetNextProperty(const nsACString &kind, calIIcalProperty **prop)
{
    NS_ENSURE_ARG_POINTER(prop);

    icalproperty_kind propkind =
        icalproperty_string_to_kind(PromiseFlatCString(kind).get());

    if (propkind == ICAL_NO_PROPERTY)
        return NS_ERROR_INVALID_ARG;
    icalproperty *icalprop = nullptr;
    if (propkind == ICAL_X_PROPERTY) {
        for (icalprop =
                 icalcomponent_get_next_property(mComponent, ICAL_X_PROPERTY);
             icalprop;
             icalprop = icalcomponent_get_next_property(mComponent,
                                                        ICAL_X_PROPERTY)) {

            if (kind.Equals(icalproperty_get_x_name(icalprop)))
                break;
        }
    } else {
        icalprop = icalcomponent_get_next_property(mComponent, propkind);
    }

    if (!icalprop) {
        *prop = nullptr;
        return NS_OK;
    }

    *prop = new calIcalProperty(icalprop, this);
    CAL_ENSURE_MEMORY(*prop);
    NS_ADDREF(*prop);
    return NS_OK;
}
Ejemplo n.º 3
0
void view_event(icalcomponent* calendar)
{
  //Ask user if they want null fields in addition to filled ones
  bool show_null_fields_too = yes_no_prompt("Do you want to view empty fields? (y/n)");
    
  icalcomponent* event = find_event(calendar);
  
  if (event == NULL)
  {
    append_action_to_closed_log("View event", false);
  }
  
  //Once user selects desired one, displays all needed fields  
  icalproperty* p;
  for(p = icalcomponent_get_first_property(event,ICAL_ANY_PROPERTY); p != 0; p = icalcomponent_get_next_property(event,ICAL_ANY_PROPERTY))
  {
    if ((icalproperty_get_comment(p) != NULL) || (show_null_fields_too))
    {
      cout << icalproperty_get_x_name(p) << ": ";
      cout << icalproperty_get_comment(p) << endl;
    }
  }
  
  append_action_to_closed_log("View event", true);
}
Ejemplo n.º 4
0
static icalproperty *icalmessage_find_attendee(icalcomponent *comp, const char *user)
{
    icalcomponent *inner = icalmessage_get_inner(comp);
    icalproperty *p, *attendee = 0;
    char *luser = lowercase(user);

    for (p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY);
         p != 0;
         p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY)) {

        char *lattendee;

        lattendee = lowercase(icalproperty_get_attendee(p));

        if (strstr(lattendee, user) != 0) {
            free(lattendee);
            attendee = p;
            break;
        }

        free(lattendee);
    }

    free(luser);

    return attendee;
}
Ejemplo n.º 5
0
void
scalix_appointment_unset (ScalixAppointment * comp, const char *key)
{
    icalcomponent *icomp;
    icalproperty *icalprop;
    const char *x_val;
    GSList *list, *iter;

    list = NULL;
    icomp = e_cal_component_get_icalcomponent (E_CAL_COMPONENT (comp));
    icalprop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY);

    while (icalprop) {
        const char *x_name;

        x_name = icalproperty_get_x_name (icalprop);
        x_val = icalproperty_get_x (icalprop);

        if (!strcmp (x_name, key)) {
            list = g_slist_prepend (list, icalprop);
        }

        icalprop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY);
    }

    for (iter = list; iter; iter = iter->next) {
        icalprop = iter->data;
        icalcomponent_remove_property (icomp, icalprop);
        icalproperty_free (icalprop);
    }

    return;
}
Ejemplo n.º 6
0
/** Set icalcomponent X-* property.
 *
 * @param comp iCal component.
 * @param key Property name (i.e. X-EEE-WHATEVER).
 * @param value Property value.
 */
static void icomp_x_prop_set(icalcomponent *comp, const char *key, const char *value)
{
    icalproperty *iter;

    g_return_if_fail(comp != NULL);
    g_return_if_fail(key != NULL);

again:
    for (iter = icalcomponent_get_first_property(comp, ICAL_X_PROPERTY);
         iter;
         iter = icalcomponent_get_next_property(comp, ICAL_X_PROPERTY))
    {
        const char *str = icalproperty_get_x_name(iter);

        if (str && !g_strcmp0(str, key))
        {
            icalcomponent_remove_property(comp, iter);
            icalproperty_free(iter);
            goto again;
        }
    }

    if (value)
    {
        iter = icalproperty_new_x(value);
        icalproperty_set_x_name(iter, key);
        icalcomponent_add_property(comp, iter);
    }
}
Ejemplo n.º 7
0
gboolean
scalix_appointment_get (ScalixAppointment * comp, const char *key, char **value)
{
    icalcomponent *icomp;
    icalproperty *icalprop;
    const char *x_val;

    icomp = e_cal_component_get_icalcomponent (E_CAL_COMPONENT (comp));
    icalprop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY);

    while (icalprop) {
        const char *x_name;

        x_name = icalproperty_get_x_name (icalprop);
        x_val = icalproperty_get_x (icalprop);

        if (!strcmp (x_name, key)) {
            break;
        }

        icalprop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY);
    }

    if (icalprop) {
        *value = g_strdup (x_val);
        return TRUE;
    }

    *value = NULL;

    return FALSE;
}
Ejemplo n.º 8
0
static icalproperty *
find_attendee (icalcomponent *ical_comp, const char *address)
{
	icalproperty *prop;

	if (address == NULL)
		return NULL;

	for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY);
	     prop != NULL;
	     prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) {
		icalvalue *value;
		const char *attendee;
		char *text;

		value = icalproperty_get_value (prop);
		if (!value)
			continue;

		attendee = icalvalue_get_string (value);

		text = g_strdup (itip_strip_mailto (attendee));
		text = g_strstrip (text);
		if (!g_ascii_strcasecmp (address, text)) {
			g_free (text);
			break;
		}
		g_free (text);
	}

	return prop;
}
Ejemplo n.º 9
0
/** Gets the LOCATION or X-LIC-LOCATION property from a VTIMEZONE. */
static char*
icaltimezone_get_location_from_vtimezone (icalcomponent *component)
{
    icalproperty *prop;
    const char *location;
    const char *name;

    prop = icalcomponent_get_first_property (component,
					     ICAL_LOCATION_PROPERTY);
    if (prop) {
	location = icalproperty_get_location (prop);
	if (location)
	    return strdup (location);
    }

    prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY);
    while (prop) {
	name = icalproperty_get_x_name (prop);
	if (name && !strcasecmp (name, "X-LIC-LOCATION")) {
	    location = icalproperty_get_x (prop);
	    if (location)
		return strdup (location);
	}
	prop = icalcomponent_get_next_property (component,
						ICAL_X_PROPERTY);
    }

    return NULL;
}
Ejemplo n.º 10
0
/*
 * Construct a JSON array for an iCalendar component.
 */
static json_t *icalcomponent_as_json_array(icalcomponent *comp)
{
    icalcomponent *c;
    icalproperty *p;
    icalcomponent_kind kind;
    const char* kind_string;
    json_t *jcomp, *jprops, *jsubs;

    if (!comp) return NULL;

    kind = icalcomponent_isa(comp);
    switch (kind) {
    case ICAL_NO_COMPONENT:
        return NULL;
        break;

    case ICAL_X_COMPONENT:
        kind_string = ""; //comp->x_name;
        break;

    default:
        kind_string = icalcomponent_kind_to_string(kind);
    }


    /* Create component array */
    jcomp = json_array();


    /* Add component name */
    json_array_append_new(jcomp,
        json_string(lcase(icalmemory_tmp_copy(kind_string))));


    /* Add properties */
    jprops = json_array();
    for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY);
         p;
         p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) {

        json_array_append_new(jprops, icalproperty_as_json_array(p));
    }
    json_array_append_new(jcomp, jprops);


    /* Add sub-components */
    jsubs = json_array();
    for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT);
         c;
         c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) {

        json_array_append_new(jsubs, icalcomponent_as_json_array(c));
    }
    json_array_append_new(jcomp, jsubs);

    return jcomp;
}
Ejemplo n.º 11
0
void calIcalComponent::ClearAllProperties(icalproperty_kind kind)
{
    for (icalproperty *prop = icalcomponent_get_first_property(mComponent, kind), *next;
         prop; prop = next)
    {
        next = icalcomponent_get_next_property(mComponent, kind);
        icalcomponent_remove_property(mComponent, prop);
        icalproperty_free(prop);
    }
}
Ejemplo n.º 12
0
icalspanlist *icalspanlist_from_vfreebusy(icalcomponent *comp)
{
    icalcomponent *inner;
    icalproperty *prop;
    icalspanlist *sl;

    icalerror_check_arg_rz((comp != NULL), "comp");

    inner = icalcomponent_get_inner(comp);
    if (!inner)
        return NULL;

    if ((sl = (icalspanlist *) malloc(sizeof(icalspanlist))) == 0) {
        icalerror_set_errno(ICAL_NEWFAILED_ERROR);
        return 0;
    }
    sl->spans = pvl_newlist();

    /* cycle through each FREEBUSY property, adding to the spanlist */
    for (prop = icalcomponent_get_first_property(inner, ICAL_FREEBUSY_PROPERTY);
         prop != NULL;
         prop = icalcomponent_get_next_property(inner, ICAL_FREEBUSY_PROPERTY)) {
        icaltime_span *s = (icaltime_span *) malloc(sizeof(icaltime_span));
        icalparameter *param;
        struct icalperiodtype period;
        icalparameter_fbtype fbtype;

        if (s == 0) {
            icalerror_set_errno(ICAL_NEWFAILED_ERROR);
            icalspanlist_free(sl);
            return 0;
        }

        param = icalproperty_get_first_parameter(prop, ICAL_FBTYPE_PARAMETER);
        fbtype = (param) ? icalparameter_get_fbtype(param) : ICAL_FBTYPE_BUSY;

        switch (fbtype) {
        case ICAL_FBTYPE_FREE:
        case ICAL_FBTYPE_NONE:
        case ICAL_FBTYPE_X:
            s->is_busy = 1;
            break;
        default:
            s->is_busy = 0;
        }

        period = icalproperty_get_freebusy(prop);
        s->start = icaltime_as_timet_with_zone(period.start, icaltimezone_get_utc_timezone());
        s->end = icaltime_as_timet_with_zone(period.end, icaltimezone_get_utc_timezone());
        ;
        pvl_insert_ordered(sl->spans, compare_span, (void *)s);
    }
  /** @todo calculate start/end limits.. fill in holes? **/
    return sl;
}
Ejemplo n.º 13
0
/*
 * Construct a XML element for an iCalendar component.
 */
static xmlNodePtr icalcomponent_as_xml_element(icalcomponent *comp)
{
    icalcomponent *c;
    icalproperty *p;
    icalcomponent_kind kind;
    const char* kind_string;
    xmlNodePtr xcomp, xprops = NULL, xsubs = NULL;

    if (!comp) return NULL;

    kind = icalcomponent_isa(comp);
    switch (kind) {
    case ICAL_NO_COMPONENT:
        return NULL;
        break;

    case ICAL_X_COMPONENT:
        kind_string = ""; //comp->x_name;
        break;

    default:
        kind_string = icalcomponent_kind_to_string(kind);
    }


    /* Create component */
    xcomp = xmlNewNode(NULL,
                       BAD_CAST lcase(icalmemory_tmp_copy(kind_string)));


    /* Add properties */
    for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY);
            p;
            p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) {

        if (!xprops)
            xprops = xmlNewChild(xcomp, NULL, BAD_CAST "properties", NULL);

        xmlAddChild(xprops, icalproperty_as_xml_element(p));
    }


    /* Add sub-components */
    for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT);
            c;
            c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) {

        if (!xsubs)
            xsubs = xmlNewChild(xcomp, NULL, BAD_CAST "components", NULL);

        xmlAddChild(xsubs, icalcomponent_as_xml_element(c));
    }

    return xcomp;
}
Ejemplo n.º 14
0
/* Return the first category that is not equal to GNOKII */
static const char *comp_get_category(icalcomponent *comp)
{
	icalproperty *cat = NULL;
	const char *str;

	for (cat = icalcomponent_get_first_property(comp, ICAL_CATEGORIES_PROPERTY);
	     cat;
	     cat = icalcomponent_get_next_property(comp, ICAL_CATEGORIES_PROPERTY)) {
		str = icalproperty_get_categories(cat);
		if (strncasecmp("GNOKII", str, 6) != 0)
			return str;
	}
	return NULL;
}
Ejemplo n.º 15
0
icalproperty *icalcomponent_get_next_invitee(icalcomponent *comp)
{
    icalproperty *prop;

    if (icalcomponent_isa(comp) == ICAL_VPOLL_COMPONENT) {
        icalcomponent *vvoter =
            icalcomponent_get_next_component(comp, ICAL_VVOTER_COMPONENT);

        prop = icalcomponent_get_first_property(vvoter, ICAL_VOTER_PROPERTY);
    }
    else {
        prop = icalcomponent_get_next_property(comp, ICAL_ATTENDEE_PROPERTY);
    }

    return prop;
}
Ejemplo n.º 16
0
void component_errors(icalcomponent *comp)
{
    int errors;
    icalproperty *p;

    /* presume that we just got this component from the parser */

    errors = icalcomponent_count_errors(comp);

    printf("This component has %d parsing errors\n", errors);

    /* Print out all of the parsing errors. This is not strictly
       correct, because it does not descend into any sub-components,
       as icalcomponent_count_errors() does. */

    for(p = icalcomponent_get_first_property(comp,ICAL_XLICERROR_PROPERTY);
        p != 0;
        p = icalcomponent_get_next_property(comp,ICAL_XLICERROR_PROPERTY))
    {

        printf("-- The error is %s:\n",icalproperty_get_xlicerror(p));
    }



    /* Check the component for iTIP compilance, and add more
       X-LIC-ERROR properties if it is non-compilant. */
    icalrestriction_check(comp);


    /* Count the new errors.  */
    if(errors != icalcomponent_count_errors(comp)){
       printf(" -- The component also has iTIP restriction errors \n");
    }

    /* Since there are iTIP restriction errors, it may be impossible
       to process this component as an iTIP request. In this case, the
       X-LIC-ERROR proeprties should be expressed as REQUEST-STATUS
       properties in the reply. This following routine makes this
       conversion */


    icalcomponent_convert_errors(comp);

}
Ejemplo n.º 17
0
void Todo::updateDataFromIcal() {
    assert(_ptrIcal);
    assert(icalcomponent_isa(_ptrIcal) == ICAL_VTODO_COMPONENT);

    for (icalproperty * ptrProperty = icalcomponent_get_first_property(_ptrIcal, ICAL_ANY_PROPERTY);
            ptrProperty != 0;
            ptrProperty = icalcomponent_get_next_property(_ptrIcal, ICAL_ANY_PROPERTY)) {

        icalproperty_kind propertyKind = icalproperty_isa(ptrProperty);

        switch (propertyKind) {
            case ICAL_SUMMARY_PROPERTY:     convertIcalToString(_summary, ptrProperty);         break;
            case ICAL_LOCATION_PROPERTY:    convertIcalToString(_location, ptrProperty);        break;
            case ICAL_DESCRIPTION_PROPERTY: convertIcalToString(_description, ptrProperty);     break;
            default: break;
        }
    }
}
Ejemplo n.º 18
0
/* Fills the procedure alarm data with the values from the widgets */
static void
palarm_widgets_to_alarm (Dialog *dialog,
                         ECalComponentAlarm *alarm)
{
	gchar *program;
	icalattach *attach;
	gchar *str;
	ECalComponentText description;
	icalcomponent *icalcomp;
	icalproperty *icalprop;

	program = e_dialog_editable_get (dialog->palarm_program);
	attach = icalattach_new_from_url (program ? program : "");
	g_free (program);

	e_cal_component_alarm_set_attach (alarm, attach);
	icalattach_unref (attach);

	str = e_dialog_editable_get (dialog->palarm_args);

		description.value = str;
		description.altrep = NULL;

		e_cal_component_alarm_set_description (alarm, &description);

	g_free (str);

	/* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that
	 * we don't re-set the alarm's description */
	icalcomp = e_cal_component_alarm_get_icalcomponent (alarm);
	icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
	while (icalprop) {
		const gchar *x_name;

		x_name = icalproperty_get_x_name (icalprop);
		if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) {
			icalcomponent_remove_property (icalcomp, icalprop);
			break;
		}

		icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
	}
}
void update_attendees(icalcomponent* event)
{
    icalproperty* p;
    icalparameter* parameter;

    assert(event != 0);
        assert(icalcomponent_isa(event) == ICAL_VEVENT_COMPONENT);

    for(
        p = icalcomponent_get_first_property(event,ICAL_ATTENDEE_PROPERTY);
        p != 0;
        p = icalcomponent_get_next_property(event,ICAL_ATTENDEE_PROPERTY)
        ) {

        parameter = icalproperty_get_first_parameter(p,ICAL_PARTSTAT_PARAMETER);

        if (parameter == 0) {

            /* There was no PARTSTAT parameter, so add one.  */
            icalproperty_add_parameter(
                p,
                icalparameter_new_partstat(ICAL_PARTSTAT_TENTATIVE)
                );

        } else if (icalparameter_get_partstat(parameter) == ICAL_PARTSTAT_NEEDSACTION) {
            /* Remove the NEEDSACTION parameter and replace it with
               TENTATIVE */

            icalproperty_remove_parameter_by_kind(p,ICAL_PARTSTAT_PARAMETER);

            /* Don't forget to free it */
            icalparameter_free(parameter);

            /* Add a new one */
            icalproperty_add_parameter(
                p,
                icalparameter_new_partstat(ICAL_PARTSTAT_TENTATIVE)
                );
        }

    }
}
Ejemplo n.º 20
0
static const char *get_expect(icalcomponent *c)
{
    icalproperty *p;
    const char *note = 0;

    if (c != 0) {
        for (p = icalcomponent_get_first_property(c, ICAL_X_PROPERTY);
             p != 0; p = icalcomponent_get_next_property(c, ICAL_X_PROPERTY)) {
            if (strcmp(icalproperty_get_x_name(p), "X-LIC-EXPECT") == 0) {
                note = icalproperty_get_x(p);
            }
        }
    }

    if (note == 0) {
        note = "None";
    }

    return note;
}
Ejemplo n.º 21
0
/* Fills the display alarm data with the values from the widgets */
static void
dalarm_widgets_to_alarm (Dialog *dialog,
                         ECalComponentAlarm *alarm)
{
	gchar *str;
	ECalComponentText description;
	GtkTextBuffer *text_buffer;
	GtkTextIter text_iter_start, text_iter_end;
	icalcomponent *icalcomp;
	icalproperty *icalprop;

	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->dalarm_message)))
		return;

	text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->dalarm_description));
	gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start);
	gtk_text_buffer_get_end_iter   (text_buffer, &text_iter_end);
	str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE);

	description.value = str;
	description.altrep = NULL;

	e_cal_component_alarm_set_description (alarm, &description);
	g_free (str);

	/* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that
	 * we don't re-set the alarm's description */
	icalcomp = e_cal_component_alarm_get_icalcomponent (alarm);
	icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
	while (icalprop) {
		const gchar *x_name;

		x_name = icalproperty_get_x_name (icalprop);
		if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) {
			icalcomponent_remove_property (icalcomp, icalprop);
			break;
		}

		icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
	}
}
Ejemplo n.º 22
0
HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP)
{
	icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
	icalparameter *partstat_param;
	icalproperty *p;
	CalAttendee *Att;
	HashList *Attendees = NULL;
	const char *ch;
	int n = 0;

	/* If the component has attendees, iterate through them. */
	for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); 
	     (p != NULL); 
	     p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
		ch = icalproperty_get_attendee(p);
		if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
			Att = (CalAttendee*) malloc(sizeof(CalAttendee));

			/** screen name or email address */
			Att->AttendeeStr = NewStrBufPlain(ch + 7, -1);
			StrBufTrim(Att->AttendeeStr);

			/** participant status */
			partstat_param = icalproperty_get_first_parameter(
				p,
				ICAL_PARTSTAT_PARAMETER
				);
			if (partstat_param == NULL) {
				Att->partstat = ICAL_PARTSTAT_X;
			}
			else {
				Att->partstat = icalparameter_get_partstat(partstat_param);
			}
			if (Attendees == NULL)
				Attendees = NewHash(1, Flathash);
			Put(Attendees, IKEY(n), Att, DeleteAtt);
			n++;
		}
	}
	return Attendees;
}
void get_required_attendees(icalcomponent* event)
{
    icalproperty* p;
    icalparameter* parameter;

    assert(event != 0);
    assert(icalcomponent_isa(event) == ICAL_VEVENT_COMPONENT);

    /* This loop iterates over all of the ATTENDEE properties in the
       event */

    /* The iteration routines save their state in the event
       struct, so the are not thread safe unless you lock the whole
       component. */

    for(
        p = icalcomponent_get_first_property(event,ICAL_ATTENDEE_PROPERTY);
        p != 0;
        p = icalcomponent_get_next_property(event,ICAL_ATTENDEE_PROPERTY)
        ) {

        /* Get the first ROLE parameter in the property. There should
           only be one, so we won't bother to iterate over them. But,
           you can iterate over parameters just like with properties */

        parameter = icalproperty_get_first_parameter(p,ICAL_ROLE_PARAMETER);

        /* If the parameter indicates the participant is required, get
           the attendees name and stick a copy of it into the output
           array */

        if ( icalparameter_get_role(parameter) == ICAL_ROLE_REQPARTICIPANT)
        {
            /* Remember, the caller does not own this string, so you
               should strdup it if you want to change it. */
            const char *attendee = icalproperty_get_attendee(p);
            printf("%s",attendee);
        }
    }

}
Ejemplo n.º 24
0
/** Get X-* property value from icalcomponent object.
 *
 * @param comp iCal component.
 * @param key Property name (i.e. X-EEE-WHATEVER).
 *
 * @return Property value or NULL.
 */
static const char *icomp_x_prop_get(icalcomponent *comp, const char *key)
{
    icalproperty *iter;

    g_return_val_if_fail(comp != NULL, NULL);
    g_return_val_if_fail(key != NULL, NULL);

    for (iter = icalcomponent_get_first_property(comp, ICAL_X_PROPERTY);
         iter;
         iter = icalcomponent_get_next_property(comp, ICAL_X_PROPERTY))
    {
        const char *str = icalproperty_get_x_name(iter);

        if (str && !g_strcmp0(str, key))
        {
            return icalproperty_get_value_as_string(iter);
        }
    }

    return NULL;
}
Ejemplo n.º 25
0
static icalproperty *
get_attendee_prop (icalcomponent *icalcomp,
                   const gchar *address)
{
	icalproperty *prop;

	if (!(address && *address))
		return NULL;

	for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
	     prop;
	     prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
		const gchar *attendee = icalproperty_get_attendee (prop);

		if (g_str_equal (itip_strip_mailto (attendee), address)) {
			return prop;
		}
	}

	return NULL;
}
Ejemplo n.º 26
0
const char *get_icalcomponent_errstr(icalcomponent *ical)
{
    icalcomponent *comp;

    for (comp = icalcomponent_get_first_component(ical, ICAL_ANY_COMPONENT);
         comp;
         comp = icalcomponent_get_next_component(ical, ICAL_ANY_COMPONENT)) {
        icalproperty *prop;

        for (prop = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY);
             prop;
             prop = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) {

            if (icalproperty_isa(prop) == ICAL_XLICERROR_PROPERTY) {
                const char *errstr = icalproperty_get_xlicerror(prop);
                char propname[256];

                if (!errstr) return "Unknown iCal parsing error";

                /* Check if this is an empty property error */
                if (sscanf(errstr,
                           "No value for %s property", propname) == 1) {
                    /* Empty LOCATION is OK */
                    if (!strcasecmp(propname, "LOCATION")) continue;
                    if (!strcasecmp(propname, "COMMENT")) continue;
                    if (!strcasecmp(propname, "DESCRIPTION")) continue;
                }
                else {
                    /* Ignore unknown property errors */
                    if (!strncmp(errstr, "Parse error in property name", 28))
                        continue;
                }

                return errstr;
            }
        }
    }

    return NULL;
}
Ejemplo n.º 27
0
/**
 * is_attendee_declined:
 * @icalcomp: Component where to check the attendee list.
 * @email: Attendee's email to look for.
 *
 * Returns: Whether the required attendee declined or not.
 *          It's not necessary to have this attendee in the list.
 **/
static gboolean
is_attendee_declined (icalcomponent *icalcomp,
                      const gchar *email)
{
	icalproperty *prop;
	icalparameter *param;

	g_return_val_if_fail (icalcomp != NULL, FALSE);
	g_return_val_if_fail (email != NULL, FALSE);

	for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
	     prop != NULL;
	     prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
		gchar *attendee;
		gchar *text = NULL;

		attendee = icalproperty_get_value_as_string_r (prop);
		if (!attendee)
			continue;

		if (!g_ascii_strncasecmp (attendee, "mailto:", 7))
			text = g_strdup (attendee + 7);
		text = g_strstrip (text);

		if (!g_ascii_strcasecmp (email, text)) {
			g_free (text);
			g_free (attendee);
			break;
		}
		g_free (text);
		g_free (attendee);
	}

	if (!prop)
		return FALSE;

	param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER);

	return param && icalparameter_get_partstat (param) == ICAL_PARTSTAT_DECLINED;
}
static void
patch_tzids (icalcomponent *subcomp,
             GHashTable *mapping)
{
	gchar *tzid = NULL;

	if (icalcomponent_isa (subcomp) != ICAL_VTIMEZONE_COMPONENT) {
		icalproperty *prop = icalcomponent_get_first_property (
			subcomp, ICAL_ANY_PROPERTY);
		while (prop) {
			icalparameter *param = icalproperty_get_first_parameter (
				prop, ICAL_TZID_PARAMETER);
			while (param) {
				const gchar *oldtzid;
				const gchar *newtzid;

				g_free (tzid);
				tzid = g_strdup (icalparameter_get_tzid (param));

				if (!g_hash_table_lookup_extended (
					mapping, tzid,
					(gpointer *) &oldtzid,
					(gpointer *) &newtzid)) {
					/* Corresponding VTIMEZONE not seen before! */
					newtzid = e_cal_match_tzid (tzid);
				}
				if (newtzid) {
					icalparameter_set_tzid (param, newtzid);
				}
				param = icalproperty_get_next_parameter (
					prop, ICAL_TZID_PARAMETER);
			}
			prop = icalcomponent_get_next_property (
				subcomp, ICAL_ANY_PROPERTY);
		}
	}

	g_free (tzid);
}
Ejemplo n.º 29
0
icalcomponent *icalmessage_new_error_reply(icalcomponent *c,
                                           const char *user,
                                           const char *msg,
                                           const char *debug, icalrequeststatus code)
{
    icalcomponent *reply;
    icalcomponent *inner, *cinner;
    struct icalreqstattype rs;

    icalerror_check_arg_rz(c, "c");

    memset(&rs, 0, sizeof(struct icalreqstattype));
    reply = icalmessage_new_reply_base(c, user, msg);
    inner = icalmessage_get_inner(reply);
    cinner = icalmessage_get_inner(c);
    if (reply == 0) {
        return 0;
    }

    if (code != ICAL_UNKNOWN_STATUS) {
        rs.code = code;
        rs.debug = debug;

        icalcomponent_add_property(inner, icalproperty_new_requeststatus(rs));
    } else {    /*  code == ICAL_UNKNOWN_STATUS */

        /* Copy all of the request status properties */
        icalproperty *p;

        for (p = icalcomponent_get_first_property(cinner, ICAL_REQUESTSTATUS_PROPERTY);
             p != 0;
             p = icalcomponent_get_next_property(cinner, ICAL_REQUESTSTATUS_PROPERTY)) {
            icalcomponent_add_property(inner, icalproperty_new_clone(p));
        }
    }

    return reply;
}
Ejemplo n.º 30
0
static int get_expected_numevents(icalcomponent *c)
{
    icalproperty *p;
    const char* note = 0;
    int num_events = 0;

    if(c != 0){
        for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY);
            p!= 0;
            p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){
            if(strcmp(icalproperty_get_x_name(p),"X-EXPECT-NUMEVENTS")==0){
	      note = icalproperty_get_x(p);
            }
        }
    } 
    
    if(note != 0){
      num_events = atoi(note);
    }
    
    
    return num_events;
}