コード例 #1
0
gboolean
e_mapi_utils_add_property (struct mapi_SPropValue_array *properties,
			   uint32_t proptag,
			   gconstpointer propvalue,
			   TALLOC_CTX *mem_ctx)
{
	uint32_t ii;
	struct SPropValue sprop = { 0 };

	g_return_val_if_fail (properties != NULL, FALSE);
	g_return_val_if_fail (proptag != 0, FALSE);
	g_return_val_if_fail (propvalue != NULL, FALSE);
	g_return_val_if_fail (mem_ctx != NULL, FALSE);

	/* make copy of string properties */
	if ((proptag & 0xFFFF) == PT_STRING8 ||
	    (proptag & 0xFFFF) == PT_UNICODE)
		propvalue = talloc_strdup (mem_ctx, (const gchar *) propvalue);

	sprop.ulPropTag = proptag;
	g_return_val_if_fail (set_SPropValue (&sprop, propvalue), FALSE);

	for (ii = 0; ii < properties->cValues; ii++) {
		if (properties->lpProps[ii].ulPropTag == proptag) {
			cast_mapi_SPropValue (mem_ctx, &(properties->lpProps[ii]), &sprop);
			break;
		}
	}

	if (ii == properties->cValues) {
		properties->cValues++;
		properties->lpProps = talloc_realloc (mem_ctx,
			properties->lpProps,
			struct mapi_SPropValue,
			properties->cValues + 1);
		cast_mapi_SPropValue (mem_ctx, &(properties->lpProps[properties->cValues - 1]), &sprop);
		properties->lpProps[properties->cValues].ulPropTag = 0;
	}
コード例 #2
0
ファイル: pyocpf.c プロジェクト: EasyLinux/Openchange
static PyObject *py_ocpf_write(PyOcpfObject *self, PyObject *args)
{
	int				ret;
	PyObject			*pySPropValue;
	PySPropValueObject		*SPropValue;
	struct mapi_SPropValue_array	mapi_lpProps;
	PyObject			*mod_mapi;
	int				i;

	mod_mapi = PyImport_ImportModule("openchange.mapi");
	if (mod_mapi == NULL) {
		printf("Can't load module\n");
		return NULL;
	}
	SPropValue_Type = (PyTypeObject *)PyObject_GetAttrString(mod_mapi, "SPropValue");
	if (SPropValue_Type == NULL)
		return NULL;


	if (!PyArg_ParseTuple(args, "O", &pySPropValue)) {
		return NULL;
	}

	if (!PyObject_TypeCheck(pySPropValue, SPropValue_Type)) {
		PyErr_SetString(PyExc_TypeError, "Function require SPropValue object");
		return NULL;
	}
	SPropValue = (PySPropValueObject *) pySPropValue;

	mapi_lpProps.cValues = SPropValue->cValues;
	mapi_lpProps.lpProps = talloc_array(SPropValue->mem_ctx, struct mapi_SPropValue, SPropValue->cValues);
	for (i = 0; i < SPropValue->cValues; i++) {
	  cast_mapi_SPropValue((TALLOC_CTX *)mapi_lpProps.lpProps,
			       &(mapi_lpProps.lpProps[i]), &(SPropValue->SPropValue[i]));
	}

	ret = ocpf_write_auto(self->context_id, NULL, &mapi_lpProps);
	talloc_free(mapi_lpProps.lpProps);
	return PyInt_FromLong(ret);
}
コード例 #3
0
static enum MAPISTATUS
parse_property_cb (struct SPropValue prop, void *closure)
{
	EMapiFXParserClosure *data = closure;

	if (data->next_proptag_is_nameid == prop.ulPropTag) {
		prop.ulPropTag = data->next_nameid_proptag;
	}

	data->next_proptag_is_nameid = MAPI_E_RESERVED;
	data->next_nameid_proptag = MAPI_E_RESERVED;

	if (!data->current_properties) {
		if (data->marker)
			g_debug ("%s: Property received out of order under marker %s", G_STRFUNC, get_proptag_name (data->marker));
		return MAPI_E_SUCCESS;
	}

	switch (prop.ulPropTag & 0xFFFF) {
		case PT_BINARY:
			if (data->current_streamed_properties && data->current_streamed_properties_count &&
			    prop.value.bin.cb > 65535) {
				guint32 index;

				(*data->current_streamed_properties) = talloc_realloc (data->current_streamed_mem_ctx,
					(*data->current_streamed_properties),
					EMapiStreamedProp,
					(*data->current_streamed_properties_count) + 1);
				index = (*data->current_streamed_properties_count);
				(*data->current_streamed_properties_count)++;
				(*data->current_streamed_properties)[index].proptag = prop.ulPropTag;
				(*data->current_streamed_properties)[index].cb = prop.value.bin.cb;
				(*data->current_streamed_properties)[index].lpb = prop.value.bin.lpb;
				break;
			} else if (prop.value.bin.cb > 65535) {
				g_debug ("%s: PT_BINARY property 0x%X larger than 64KB (%d), will be truncated", G_STRFUNC, prop.ulPropTag, prop.value.bin.cb);
			}
		case PT_BOOLEAN:
		case PT_I2:
		case PT_LONG:
		case PT_DOUBLE:
		case PT_I8:
		case PT_STRING8:
		case PT_UNICODE:
		case PT_SYSTIME:
		case PT_ERROR:
		case PT_CLSID:
		case PT_SVREID:
		case PT_MV_STRING8:
		case PT_MV_UNICODE:
		case PT_MV_BINARY:
		case PT_MV_LONG:
			data->current_properties->cValues++;
			data->current_properties->lpProps = talloc_realloc (data->mem_ctx,
									    data->current_properties->lpProps,
									    struct mapi_SPropValue,
									    data->current_properties->cValues + 1);
			cast_mapi_SPropValue (data->mem_ctx, &data->current_properties->lpProps[data->current_properties->cValues - 1], &prop);
			data->current_properties->lpProps[data->current_properties->cValues].ulPropTag = 0;
			break;
		default:
			/* skip all of other type */
			break;
	}

	return MAPI_E_SUCCESS;
}