Example #1
0
/**
   \details This function dumps the properties relating to a task (to-do list entry)
   to standard output

   The expected way to obtain the properties array is to use OpenMessage() to obtain the
   task object, then to use GetPropsAll() to obtain all the properties.

   \param properties array of task properties
   \param id identification to display for the task (can be NULL)

   \sa mapidump_message, mapidump_appointment, mapidump_contact, mapidump_note
*/
_PUBLIC_ void mapidump_task(struct mapi_SPropValue_array *properties, const char *id)
{
	const struct mapi_SLPSTRArray	*contacts = NULL;
	const char			*subject = NULL;
	const char			*body = NULL;
	const double			*complete = 0;
	const uint32_t			*status;
	const uint32_t			*importance;
	const uint8_t			*private_tag;
	uint32_t       			i;

	contacts = (const struct mapi_SLPSTRArray *)find_mapi_SPropValue_data(properties, PidLidContacts);
	subject = (const char *)find_mapi_SPropValue_data(properties, PR_CONVERSATION_TOPIC);
	body = (const char *)find_mapi_SPropValue_data(properties, PR_BODY);
	complete = (const double *)find_mapi_SPropValue_data(properties, PidLidPercentComplete);
	status = (const uint32_t *)find_mapi_SPropValue_data(properties, PidLidTaskStatus);
	importance = (const uint32_t *)find_mapi_SPropValue_data(properties, PR_IMPORTANCE);
	private_tag = (const uint8_t *)find_mapi_SPropValue_data(properties, PidLidPrivate);

	printf("|== %s ==| %s\n", subject?subject:"", id?id:"");
	fflush(0);

	printf("\tBody: %s\n", body?body:"none");
	fflush(0);

	if (complete) {
		printf("\tComplete: %u %c\n", (uint32_t)(*complete * 100), '%');
		fflush(0);
	}

	if (status) {
		printf("\tStatus: %s\n", get_task_status(*status));
		fflush(0);
		if (*status == olTaskComplete) {
			mapidump_date(properties, PidLidTaskDateCompleted, "Date Completed");
		}
	}

	if (importance) {
		printf("\tImportance: %s\n", get_importance(*importance));
		fflush(0);
	}

	mapidump_date(properties, PidLidTaskDueDate,"Due Date");
	mapidump_date(properties, PidLidTaskStartDate, "Start Date");

	if (private_tag) {
		printf("\tPrivate: %s\n", (*private_tag == true)?"True":"False");
		fflush(0);
	} else {
		printf("\tPrivate: false\n");
		fflush(0);
	}

	if (contacts) {
		for (i = 0; i < contacts->cValues; i++) {
			printf("\tContact: %s\n", contacts->strings[i].lppszA);
			fflush(0);
		}
	}
}
Example #2
0
/**
   \details Test dump using mapidump_task

   This function:
   -# Tests the mapidump_task() function
   -# modifies the task to be completed
   -# Tests the associated get_importance() function
   -# Tests the associated get_task_status() function

   \param mt pointer to the top-level mapitest structure

   \return true on success, otherwise false
   
   \note This currently doesn't check the results are sane, so manual inspection is required
*/ 
_PUBLIC_ bool mapitest_mapidump_task(struct mapitest *mt)
{
	struct mapi_SPropValue_array	props;

	props.cValues = 9;
	props.lpProps = talloc_array(mt->mem_ctx, struct mapi_SPropValue, props.cValues);

	props.lpProps[0].ulPropTag = PR_CONVERSATION_TOPIC;
	props.lpProps[0].value.lpszA = "Topic of the Task";

	props.lpProps[1].ulPropTag = PR_BODY;
	props.lpProps[1].value.lpszA = "This is the body of the task. It has two sentences.";

	props.lpProps[2].ulPropTag = PidLidTaskDueDate;
	props.lpProps[2].value.ft.dwLowDateTime = 0x12345678;
	props.lpProps[2].value.ft.dwHighDateTime = 0x01CA6CE4;

	props.lpProps[3].ulPropTag = PidLidPrivate;
	props.lpProps[3].value.b = 0;

	props.lpProps[4].ulPropTag = PR_IMPORTANCE;
	props.lpProps[4].value.l = IMPORTANCE_HIGH;

	props.lpProps[5].ulPropTag = PidLidPercentComplete;
	props.lpProps[5].value.dbl = 0.78;

	props.lpProps[6].ulPropTag = PidLidTaskStartDate;
	props.lpProps[6].value.ft.dwLowDateTime = 0x09876543;
	props.lpProps[6].value.ft.dwHighDateTime = 0x01CA6AE4;

	props.lpProps[7].ulPropTag = PidLidTaskStatus;
	props.lpProps[7].value.l = olTaskWaiting;

	props.lpProps[8].ulPropTag = PidLidContacts;
	props.lpProps[8].value.MVszA.cValues = 2;
	props.lpProps[8].value.MVszA.strings = talloc_array(mt->mem_ctx, struct mapi_LPSTR, 2);
	props.lpProps[8].value.MVszA.strings[0].lppszA = "Contact One";
	props.lpProps[8].value.MVszA.strings[1].lppszA = "Contact Two Jr.";

	mapidump_task(&props, "[dummy ID]");

	props.lpProps[7].ulPropTag = PidLidTaskStatus;
	props.lpProps[7].value.l = olTaskComplete;

	props.lpProps[3].ulPropTag = PidLidTaskDateCompleted;
	props.lpProps[3].value.ft.dwLowDateTime = 0x22345678;
	props.lpProps[3].value.ft.dwHighDateTime = 0x01CA6CB4;

	mapidump_task(&props, "[dummy ID]");

	if (strcmp("Low", get_importance(IMPORTANCE_LOW)) != 0) {
		mapitest_print(mt, "* %-40s: bad result IMPORTANCE_LOW\n", "mapidump_task");
		return false;
	}
	if (strcmp("Normal", get_importance(IMPORTANCE_NORMAL)) != 0) {
		mapitest_print(mt, "* %-40s: bad result IMPORTANCE_NORMAL\n", "mapidump_task");
		return false;
	}
	if (strcmp("High", get_importance(IMPORTANCE_HIGH)) != 0) {
		mapitest_print(mt, "* %-40s: bad result IMPORTANCE_HIGH\n", "mapidump_task");
		return false;
	}
	if (get_importance(IMPORTANCE_HIGH+1) != 0) {
		mapitest_print(mt, "* %-40s: bad result OUT_OF_RANGE\n", "mapidump_task");
		return false;
	}

	if (strcmp("Not Started", get_task_status(olTaskNotStarted)) != 0) {
		mapitest_print(mt, "* %-40s: bad result olTaskNotStarted\n", "mapidump_task");
		return false;
	}
	if (strcmp("In Progress", get_task_status(olTaskInProgress)) != 0) {
		mapitest_print(mt, "* %-40s: bad result olTaskInProgress\n", "mapidump_task");
		return false;
	}
	if (strcmp("Completed", get_task_status(olTaskComplete)) != 0) {
		mapitest_print(mt, "* %-40s: bad result olTaskCompleted\n", "mapidump_task");
		return false;
	}
	if (strcmp("Waiting on someone else", get_task_status(olTaskWaiting)) != 0) {
		mapitest_print(mt, "* %-40s: bad result olTaskWaiting\n", "mapidump_task");
		return false;
	}
	if (strcmp("Deferred", get_task_status(olTaskDeferred)) != 0) {
		mapitest_print(mt, "* %-40s: bad result olTaskDeferred\n", "mapidump_task");
		return false;
	}
	if (get_task_status(olTaskDeferred+1) != 0) {
		mapitest_print(mt, "* %-40s: bad result OUT_OF_RANGE\n", "mapidump_task");
		return false;
	}
	return true;
}