示例#1
0
/**
   \details Open connection to indexing database for a given user

   \param mstore_ctx pointer to the mapistore context
   \param username name for which the indexing database has to be
   created

   \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
 */
_PUBLIC_ enum mapistore_error mapistore_indexing_add(struct mapistore_context *mstore_ctx, 
						     const char *username,
						     struct indexing_context **ictxp)
{
	struct indexing_context_list	*ictx;
	const char			*indexing_url;
	enum MAPISTATUS			retval;

	/* Sanity checks */
	MAPISTORE_RETVAL_IF(!mstore_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
	MAPISTORE_RETVAL_IF(!username, MAPISTORE_ERROR, NULL);

	/* Step 1. Search if the context already exists */
	*ictxp = mapistore_indexing_search(mstore_ctx, username);
	MAPISTORE_RETVAL_IF(*ictxp, MAPISTORE_SUCCESS, NULL);

	// indexing context has not been found, let's create it.
	retval = openchangedb_get_indexing_url(mstore_ctx->conn_info->oc_ctx, username, &indexing_url);
	if (retval != MAPI_E_SUCCESS) {
		indexing_url = default_indexing_url;
	}

	// indexing_url NULL means to use the default backend: tdb
	if (indexing_url == NULL) {
		ictx = talloc_zero(mstore_ctx, struct indexing_context_list);
		mapistore_indexing_tdb_init(mstore_ctx, username, &ictx->ctx);
	} else if (strncmp(indexing_url, "mysql://", strlen("mysql://")) == 0) {
示例#2
0
} END_TEST

START_TEST (test_get_indexing_url) {
	enum MAPISTATUS retval;
	const char	*indexing_url;

	/* Valid indexing url */
	retval = openchangedb_get_indexing_url(g_oc_ctx, USER1, &indexing_url);
	CHECK_SUCCESS;
	ck_assert_str_eq(indexing_url, "mysql://openchange@localhost/openchange");

	/* indexing_url is NULL */
	retval = openchangedb_get_indexing_url(g_oc_ctx, "null_indexing_url", &indexing_url);
	ck_assert_int_eq(retval, MAPI_E_NOT_FOUND);

	/* indexing_url is empty - "" */
	retval = openchangedb_get_indexing_url(g_oc_ctx, "empty_indexing_url", &indexing_url);
	ck_assert_int_eq(retval, MAPI_E_NOT_FOUND);
} END_TEST