コード例 #1
0
ファイル: mapidump.c プロジェクト: ThHirsch/openchange
/**
  Output a row of the public address book
  
  \param aRow one row of the public address book (Global Address List)
  
  This function is usually used with GetGALTable, which can obtain several
  rows at once - you'll need to iterate over the rows.
  
  The SRow is assumed to contain entries for PR_ADDRTYPE_UNICODE, PR_DISPLAY_NAME_UNICODE,
  PR_EMAIL_ADDRESS_UNICODE and PR_ACCOUNT_UNICODE.
*/
_PUBLIC_ void mapidump_PAB_entry(struct PropertyRow_r *aRow)
{
	const char	*addrtype;
	const char	*name;
	const char	*email;
	const char	*account;

	addrtype = (const char *)find_PropertyValue_data(aRow, PR_ADDRTYPE_UNICODE);
	name = (const char *)find_PropertyValue_data(aRow, PR_DISPLAY_NAME_UNICODE);
	email = (const char *)find_PropertyValue_data(aRow, PR_EMAIL_ADDRESS_UNICODE);
	account = (const char *)find_PropertyValue_data(aRow, PR_ACCOUNT_UNICODE);

	printf("[%s] %s:\n\tName: %-25s\n\tEmail: %-25s\n", 
	       addrtype, account, name, email);
	fflush(0);
}
コード例 #2
0
gconstpointer
e_mapi_util_find_propertyrow_propval (struct PropertyRow_r *rRow,
				      uint32_t proptag)
{
	if (((proptag & 0xFFFF) == PT_STRING8) ||
	    ((proptag & 0xFFFF) == PT_UNICODE)) {
		gconstpointer str = NULL;

		proptag = (proptag & 0xFFFF0000) | PT_UNICODE;
		str = find_PropertyValue_data (rRow, proptag);
		if (str)
			return str;

		proptag = (proptag & 0xFFFF0000) | PT_STRING8;
		str = find_PropertyValue_data (rRow, proptag);
		if (str)
			return str;

		return NULL;
	}

	return find_PropertyValue_data (rRow, proptag);
}
コード例 #3
0
ファイル: module_nspi.c プロジェクト: ThHirsch/openchange
/**
   \details Test the NspiModProps RPC operation (0xb)
 
   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
*/
_PUBLIC_ bool mapitest_nspi_ModProps(struct mapitest *mt)
{
	TALLOC_CTX			*mem_ctx;
	enum MAPISTATUS			retval;
	struct nspi_context		*nspi_ctx;
	struct PropertyRow_r		*pRow;
	struct SPropTagArray		*pPropTags;
	struct PropertyValue_r		modProp;
	struct PropertyTagArray_r	*MIds;
	struct PropertyRowSet_r		*RowSet;
	struct SPropTagArray		*SPropTagArray;
	struct PropertyValue_r		*lpProp;
	struct Restriction_r		Filter;
	const char			*original_office_location;
	bool				ret = true;

	mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_ModProps");
	nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;

	/* Build the array of columns we want to retrieve */
	SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_DISPLAY_NAME,
					  PR_DISPLAY_TYPE);

	/* Build the restriction we want for NspiGetMatches */
	lpProp = talloc_zero(mem_ctx, struct PropertyValue_r);
	lpProp->ulPropTag = PR_ACCOUNT;
	lpProp->dwAlignPad = 0;
	lpProp->value.lpszA = mt->mapi_ctx->session->profile->username;

	Filter.rt = RES_PROPERTY;
	Filter.res.resProperty.relop = RES_PROPERTY;
	Filter.res.resProperty.ulPropTag = PR_ACCOUNT;
	Filter.res.resProperty.lpProp = lpProp;

	RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r);
	MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
	retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &RowSet, &MIds);
	MAPIFreeBuffer(lpProp);
	MAPIFreeBuffer(RowSet);
	MAPIFreeBuffer(SPropTagArray);
	mapitest_print_retval_clean(mt, "nspi_GetMatches", retval);
	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(MIds);
		talloc_free(mem_ctx);
		return false;
	}

	/* Query the rows */
	RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r);
	retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &RowSet);
	mapitest_print_retval_clean(mt, "nspi_QueryRows", retval);
	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(MIds);
		MAPIFreeBuffer(RowSet);
		talloc_free(mem_ctx);
		return false;
	}
	if (RowSet->cRows != 1) {
		mapitest_print(mem_ctx, "unexpected number of rows: %i\n", RowSet->cRows);
		MAPIFreeBuffer(MIds);
		MAPIFreeBuffer(RowSet);
		talloc_free(mem_ctx);
		return false;
	}
	original_office_location = (const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION);
	mapitest_print(mt, "original PR_OFFICE_LOCATION value: %s\n", original_office_location);

	/* Build the SRow and SPropTagArray for NspiModProps */
	pRow = talloc_zero(mem_ctx, struct PropertyRow_r);
	modProp.ulPropTag = PR_OFFICE_LOCATION;
	modProp.value.lpszA = "MT office location";
	PropertyRow_addprop(pRow, modProp);

	pPropTags = set_SPropTagArray(mem_ctx, 0x1, PR_OFFICE_LOCATION);
	retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow);
	mapitest_print_retval_clean(mt, "nspi_ModProps", retval);
	MAPIFreeBuffer(pRow);

	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(MIds);
		MAPIFreeBuffer(pPropTags);
		talloc_free(mem_ctx);
		return false;
	}

	/* Check that the property was set correctly */
	RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r);
	retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &RowSet);
	mapitest_print_retval_clean(mt, "nspi_QueryRows", retval);
	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(MIds);
		MAPIFreeBuffer(RowSet);
		talloc_free(mem_ctx);
		return false;
	}
	if (RowSet->cRows != 1) {
		mapitest_print(mem_ctx, "unexpected number of rows: %i\n", RowSet->cRows);
		MAPIFreeBuffer(MIds);
		MAPIFreeBuffer(RowSet);
		talloc_free(mem_ctx);
		return false;
	}
	if (strcmp((const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION), "MT office location") != 0) {
		mapitest_print(mt, "PR_OFFICE_LOCATION string value mismatch: %s", (const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION));
		ret = false;
	} else {
		mapitest_print(mt, "correctly set PR_OFFICE_LOCATION\n");
	}

	/* try to reset the office location back to the original value */
	pRow = talloc_zero(mem_ctx, struct PropertyRow_r);
	modProp.ulPropTag = PR_OFFICE_LOCATION;
	modProp.value.lpszA = original_office_location;
	PropertyRow_addprop(pRow, modProp);

	retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow);
	mapitest_print_retval_clean(mt, "nspi_ModProps (reset original value)", retval);
	if (retval != MAPI_E_SUCCESS) {
		ret = false;
	}

	MAPIFreeBuffer(MIds);
	MAPIFreeBuffer(pPropTags);
	MAPIFreeBuffer(pRow);

	talloc_free(mem_ctx);
	
	return ret;
}