コード例 #1
0
/**
 * get parameters from the icalendar property and store them in the internal
 * struct if the parameter describes a hidden or inline attachment.
 */
static void
add_e_attachment_parameters(icalproperty *prop, I_common *i_common, gboolean inln)
{
	gboolean binary = FALSE;
	gchar* mime_type = NULL;
	gchar* label = NULL;

	/* iterate over all parameters of the attachment property */
	int i, pc = icalproperty_count_parameters(prop);
	icalparameter *para;
	for (i = 0; i < pc; i++) {
		icalparameter_kind kind;
		icalparameter_value xvalue;

		para = i == 0 ? icalproperty_get_first_parameter(prop, ICAL_ANY_PARAMETER) :
			icalproperty_get_next_parameter(prop, ICAL_ANY_PARAMETER);

		kind = icalparameter_isa(para);
		xvalue = icalparameter_get_value(para);
		if (kind == ICAL_VALUE_PARAMETER && xvalue == ICAL_VALUE_BINARY)
			binary = TRUE; /* not a link attachment */
		else if (kind == ICAL_FMTTYPE_PARAMETER) /* found mime type */
			mime_type = (gchar*) icalparameter_get_xvalue(para);
		else if (xvalue == ICAL_VALUE_X) { /* found attachment name */
			const char* name = icalparameter_get_xname(para);
			const char* value = icalparameter_get_xvalue(para);
			if (name && strcmp(name, ICONTACT_KOLAB_STORE_ATTACHMENT_NAME) == 0)
				label = (gchar*) value;
		}
	}

	if (binary) { /* if not a linked attachment add data to struct */
		Kolab_conv_mail_part *mpart = g_new0(Kolab_conv_mail_part, 1);
		gchar* pname = NULL;

		if (label != NULL) {
			if (inln)
				i_common->inline_attachment_names = g_list_append(
				                                                  i_common->inline_attachment_names,
				                                                  strdup(label));
			mpart->name = strdup(label);
		}
		if (mime_type != NULL)
			mpart->mime_type = strdup(mime_type);
		/* add data and length */
		pname = (gchar*) icalproperty_get_value_as_string(prop);
		if (pname) {
			gsize outlen;
			mpart->data = (gchar*) g_base64_decode (pname, &outlen);
			mpart->length = outlen;
			/* add created mail part to the attachment list */
			i_common->kolab_attachment_store = g_list_append(i_common->kolab_attachment_store, mpart);
		}
	}
}
コード例 #2
0
NS_IMETHODIMP
calIcalProperty::ClearXParameters()
{
    int oldcount, paramcount = 0;
    do {
        oldcount = paramcount;
        icalproperty_remove_parameter(mProperty, ICAL_X_PARAMETER);
        paramcount = icalproperty_count_parameters(mProperty);
    } while (oldcount != paramcount);
    return NS_OK;
}