static void deliver_merge_vpoll_reply(icalcomponent *ical, icalcomponent *reply)
{
    icalproperty *mastervoterp;
    const char *voter;
    icalcomponent *comp;

    mastervoterp = icalcomponent_get_first_property(reply, ICAL_VOTER_PROPERTY);
    voter = icalproperty_get_voter(mastervoterp);

    /* Process each existing VPOLL subcomponent */
    for (comp = icalcomponent_get_first_component(ical, ICAL_ANY_COMPONENT);
	 comp;
	 comp = icalcomponent_get_next_component(ical, ICAL_ANY_COMPONENT)) {

	icalproperty *itemid, *voterp;
	int id;

	itemid =
	    icalcomponent_get_first_property(comp, ICAL_POLLITEMID_PROPERTY);
	if (!itemid) continue;

	id = icalproperty_get_pollitemid(itemid);

	/* Remove any existing voter property from the subcomponent */
	for (voterp = icalcomponent_get_first_property(comp,
						     ICAL_VOTER_PROPERTY);
	     voterp && strcmp(voter, icalproperty_get_voter(voterp));
	     voterp = icalcomponent_get_next_property(comp,
						    ICAL_VOTER_PROPERTY));

	if (voterp) {
	    icalcomponent_remove_property(comp, voterp);
	    icalproperty_free(voterp);
	}


	/* Find matching poll-item-id in the reply */
	for (itemid = icalcomponent_get_first_property(reply,
						       ICAL_POLLITEMID_PROPERTY);
	     itemid && (id != icalproperty_get_pollitemid(itemid));
	     itemid = icalcomponent_get_next_property(reply,
						      ICAL_POLLITEMID_PROPERTY));
	if (itemid) {
	    icalparameter *param;

	    /* Add a VOTER property with params from the reply */
	    voterp = icalproperty_new_clone(mastervoterp);

	    for (param =
		     icalproperty_get_first_parameter(itemid,
						      ICAL_ANY_PARAMETER);
		 param;
		 param =
		     icalproperty_get_next_parameter(itemid,
						     ICAL_ANY_PARAMETER)) {
		switch (icalparameter_isa(param)) {
		case ICAL_PUBLICCOMMENT_PARAMETER:
		case ICAL_RESPONSE_PARAMETER:
		    icalproperty_add_parameter(voterp,
					       icalparameter_new_clone(param));
		    break;

		default:
		    break;
		}
	    }

	    icalcomponent_add_property(comp, voterp);
	}
    }
}
static void deliver_merge_vpoll_reply(icalcomponent *ical, icalcomponent *reply)
{
    icalproperty *mastervoterp;
    const char *voter;
    icalcomponent *comp;

    mastervoterp = icalcomponent_get_first_property(reply, ICAL_VOTER_PROPERTY);
    voter = icalproperty_get_voter(mastervoterp);

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

	icalproperty *itemid, *voterp;
	int id;

	itemid =
	    icalcomponent_get_first_property(comp, ICAL_POLLITEMID_PROPERTY);
	if (!itemid) continue;

	id = icalproperty_get_pollitemid(itemid);

	 
	for (voterp = icalcomponent_get_first_property(comp,
						     ICAL_VOTER_PROPERTY);
	     voterp && strcmp(voter, icalproperty_get_voter(voterp));
	     voterp = icalcomponent_get_next_property(comp,
						    ICAL_VOTER_PROPERTY));

	if (voterp) {
	    icalcomponent_remove_property(comp, voterp);
	    icalproperty_free(voterp);
	}


	 
	for (itemid = icalcomponent_get_first_property(reply,
						       ICAL_POLLITEMID_PROPERTY);
	     itemid && (id != icalproperty_get_pollitemid(itemid));
	     itemid = icalcomponent_get_next_property(reply,
						      ICAL_POLLITEMID_PROPERTY));
	if (itemid) {
	    icalparameter *param;

	     
	    voterp = icalproperty_new_clone(mastervoterp);

	    for (param =
		     icalproperty_get_first_parameter(itemid,
						      ICAL_ANY_PARAMETER);
		 param;
		 param =
		     icalproperty_get_next_parameter(itemid,
						     ICAL_ANY_PARAMETER)) {
		switch (icalparameter_isa(param)) {
		case ICAL_PUBLICCOMMENT_PARAMETER:
		case ICAL_RESPONSE_PARAMETER:
		    icalproperty_add_parameter(voterp,
					       icalparameter_new_clone(param));
		    break;

		default:
		    break;
		}
	    }

	    icalcomponent_add_property(comp, voterp);
	}
    }
}