mapistore.h File Reference

MAPISTORE general API. More...

#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <tdb.h>
#include <ldb.h>
#include <talloc.h>
#include <libmemcached/memcached.h>
#include "libmapi/libmapi.h"

Functions

enum mapistore_error mapi_error_to_mapistore (enum MAPISTATUS)
 
enum mapistore_error mapistore_add_context (struct mapistore_context *, const char *, const char *, uint64_t, uint32_t *, void **)
 
enum mapistore_error mapistore_add_context_ref_count (struct mapistore_context *, uint32_t)
 
const char * mapistore_backend_get_installdir (void)
 
init_backend_fn * mapistore_backend_load (TALLOC_CTX *, const char *)
 
struct backend_context * mapistore_backend_lookup (struct backend_context_list *, uint32_t)
 
struct backend_context * mapistore_backend_lookup_by_name (TALLOC_CTX *, const char *)
 
struct backend_context * mapistore_backend_lookup_by_uri (struct backend_context_list *, const char *)
 
enum mapistore_error mapistore_backend_register (const void *)
 
bool mapistore_backend_run_init (init_backend_fn *)
 
enum mapistore_error mapistore_del_context (struct mapistore_context *, uint32_t)
 
const char * mapistore_errstr (enum mapistore_error)
 
enum mapistore_error mapistore_folder_create_folder (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, uint64_t, struct SRow *, void **)
 
enum mapistore_error mapistore_folder_create_message (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, uint64_t, uint8_t, void **)
 
enum mapistore_error mapistore_folder_delete (struct mapistore_context *, uint32_t, void *, uint8_t, TALLOC_CTX *, uint64_t **, uint32_t *)
 
enum mapistore_error mapistore_folder_delete_message (struct mapistore_context *, uint32_t, void *, uint64_t, uint8_t)
 
enum mapistore_error mapistore_folder_get_child_count (struct mapistore_context *, uint32_t, void *, enum mapistore_table_type, uint32_t *)
 
enum mapistore_error mapistore_folder_get_deleted_fmids (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, enum mapistore_table_type, uint64_t, struct UI8Array_r **, uint64_t *)
 
enum mapistore_error mapistore_folder_move_folder (struct mapistore_context *, uint32_t, void *, void *, TALLOC_CTX *, const char *)
 
enum mapistore_error mapistore_folder_open_folder (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, uint64_t, void **)
 
enum mapistore_error mapistore_folder_open_message (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, uint64_t, bool, void **)
 
enum mapistore_error mapistore_indexing_get_new_folderID (struct mapistore_context *, uint64_t *)
 
enum mapistore_error mapistore_indexing_get_new_folderID_as_user (struct mapistore_context *, const char *, uint64_t *)
 
enum mapistore_error mapistore_indexing_get_new_folderIDs (struct mapistore_context *, TALLOC_CTX *, uint64_t, struct UI8Array_r **)
 
enum mapistore_error mapistore_indexing_record_add_fid (struct mapistore_context *, uint32_t, const char *, uint64_t)
 
enum mapistore_error mapistore_indexing_record_add_fmid_for_uri (struct mapistore_context *, uint32_t, const char *, uint64_t, const char *)
 
enum mapistore_error mapistore_indexing_record_add_mid (struct mapistore_context *, uint32_t, const char *, uint64_t)
 
enum mapistore_error mapistore_indexing_record_del_fid (struct mapistore_context *, uint32_t, const char *, uint64_t, uint8_t)
 
enum mapistore_error mapistore_indexing_record_del_mid (struct mapistore_context *, uint32_t, const char *, uint64_t, uint8_t)
 
enum mapistore_error mapistore_indexing_record_get_uri (struct mapistore_context *, const char *, TALLOC_CTX *, uint64_t, char **, bool *)
 
enum mapistore_error mapistore_indexing_reserve_fmid_range (struct mapistore_context *, uint64_t, uint64_t *)
 
struct mapistore_context * mapistore_init (TALLOC_CTX *, struct loadparm_context *, const char *)
 
enum mapistore_error mapistore_message_get_message_data (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *, struct mapistore_message **)
 
enum mapistore_error mapistore_message_modify_recipients (struct mapistore_context *, uint32_t, void *, struct SPropTagArray *, uint16_t, struct mapistore_message_recipient *)
 
enum mapistore_error mapistore_message_save (struct mapistore_context *, uint32_t, void *, TALLOC_CTX *)
 
enum mapistore_error mapistore_message_set_read_flag (struct mapistore_context *, uint32_t, void *, uint8_t)
 
enum mapistore_error mapistore_message_submit (struct mapistore_context *, uint32_t, void *, enum SubmitFlags)
 
enum mapistore_error mapistore_namedprops_create_id (struct namedprops_context *, struct MAPINAMEID, uint16_t)
 
enum mapistore_error mapistore_namedprops_get_mapped_id (struct namedprops_context *, struct MAPINAMEID, uint16_t *)
 
enum mapistore_error mapistore_namedprops_get_nameid (struct namedprops_context *, uint16_t, TALLOC_CTX *mem_ctx, struct MAPINAMEID **)
 
enum mapistore_error mapistore_namedprops_get_nameid_type (struct namedprops_context *, uint16_t, uint16_t *)
 
enum mapistore_error mapistore_namedprops_next_unused_id (struct namedprops_context *, uint16_t *)
 
enum mapistore_error mapistore_notification_deliver_add (struct mapistore_context *, struct GUID, uint8_t *, size_t)
 
enum mapistore_error mapistore_notification_deliver_delete (struct mapistore_context *, struct GUID)
 
enum mapistore_error mapistore_notification_deliver_exist (struct mapistore_context *, struct GUID)
 
enum mapistore_error mapistore_notification_deliver_get (TALLOC_CTX *, struct mapistore_context *, struct GUID, uint8_t **, size_t *)
 
enum mapistore_error mapistore_notification_payload_newmail (TALLOC_CTX *, char *, char *, char *, char, uint8_t **, size_t *)
 
enum mapistore_error mapistore_notification_resolver_add (struct mapistore_context *, const char *, const char *)
 
enum mapistore_error mapistore_notification_resolver_delete (struct mapistore_context *, const char *, const char *)
 
enum mapistore_error mapistore_notification_resolver_exist (struct mapistore_context *, const char *)
 
enum mapistore_error mapistore_notification_resolver_get (TALLOC_CTX *, struct mapistore_context *, const char *, uint32_t *, const char ***)
 
enum mapistore_error mapistore_notification_session_add (struct mapistore_context *, struct GUID, struct GUID, const char *)
 
enum mapistore_error mapistore_notification_session_delete (struct mapistore_context *, struct GUID)
 
enum mapistore_error mapistore_notification_session_exist (struct mapistore_context *, struct GUID)
 
enum mapistore_error mapistore_notification_session_get (TALLOC_CTX *, struct mapistore_context *, struct GUID, struct GUID *, char **)
 
enum mapistore_error mapistore_notification_subscription_add (struct mapistore_context *, struct GUID, uint32_t, uint16_t, uint64_t, uint64_t, uint32_t, enum MAPITAGS *)
 
enum mapistore_error mapistore_notification_subscription_delete (struct mapistore_context *, struct GUID)
 
enum mapistore_error mapistore_notification_subscription_delete_by_handle (struct mapistore_context *, struct GUID, uint32_t)
 
enum mapistore_error mapistore_notification_subscription_exist (struct mapistore_context *, struct GUID)
 Check if a subscription record exist for the given session UUID More...
 
enum mapistore_error mapistore_release (struct mapistore_context *)
 
enum mapistore_error mapistore_replica_mapping_guid_to_replid (struct mapistore_context *, const char *username, const struct GUID *, uint16_t *)
 
enum mapistore_error mapistore_replica_mapping_replid_to_guid (struct mapistore_context *, const char *username, uint16_t, struct GUID *)
 
enum mapistore_error mapistore_search_context_by_uri (struct mapistore_context *, const char *, uint32_t *, void **)
 
enum mapistore_error mapistore_set_connection_info (struct mapistore_context *, struct ldb_context *, struct openchangedb_context *, const char *)
 
void mapistore_set_default_cache_url (const char *)
 
void mapistore_set_default_indexing_url (const char *)
 
enum mapistore_error mapistore_set_mapping_path (const char *)
 

Detailed Description

MAPISTORE general API.

This header contains general functions, primarily for users of the store (rather than storage providers).

Function Documentation

enum mapistore_error mapi_error_to_mapistore ( enum MAPISTATUS  mapi_err)

Map a MAPI error code to MAPISTORE error code. We cannot map 1 to 1 for the reduced MAPISTORE scope, then we mostly likely return general MAPISTORE error code.

Parameters
mapi_errthe mapi status error code
Returns
the mapped MAPISTORE error

References MAPISTORE_ERR_CORRUPTED, MAPISTORE_ERR_DENIED, MAPISTORE_ERR_EXIST, MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_FOUND, MAPISTORE_ERR_NOT_IMPLEMENTED, MAPISTORE_ERR_NOT_INITIALIZED, MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_add_context ( struct mapistore_context *  mstore_ctx,
const char *  owner,
const char *  uri,
uint64_t  fid,
uint32_t *  context_id,
void **  backend_object 
)

Add a new connection context to mapistore

Parameters
mstore_ctxpointer to the mapistore context
urithe connection context URI
context_idpointer to the context identifier the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_backend_create_context(), MAPISTORE_ERR_CONTEXT_FAILED, MAPISTORE_ERR_INVALID_NAMESPACE, mapistore_indexing_add(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_add_context_ref_count ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id 
)

Increase the reference counter of an existing context

Parameters
mstore_ctxpointer to the mapistore context
contex_idthe context identifier referencing the context to update
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_backend_add_ref_count(), mapistore_backend_lookup(), MAPISTORE_ERR_INVALID_PARAMETER, and MAPISTORE_ERROR.

const char* mapistore_backend_get_installdir ( void  )

Return the full path where mapistore backends are installed.

Returns
Pointer to the full path where backends are installed.

Referenced by mapistore_backend_load().

init_backend_fn* mapistore_backend_load ( TALLOC_CTX *  mem_ctx,
const char *  path 
)

Load the initialization functions from backends DSO

Parameters
mem_ctxpointer to the memory context
pathpointer to the backend's DSO folder
Returns
allocated array of functions pointers to initialization functions on success, otherwise NULL.

References mapistore_backend_get_installdir().

Referenced by mapistore_backend_init().

struct backend_context* mapistore_backend_lookup ( struct backend_context_list *  backend_list_ctx,
uint32_t  context_id 
)
struct backend_context* mapistore_backend_lookup_by_name ( TALLOC_CTX *  mem_ctx,
const char *  name 
)

Return a pointer on backend functions given its name

Parameters
mem_ctxpointer to the memory context
namethe backend name to lookup
Returns
Allocated pointer to the mapistore_backend context on success, otherwise NULL
struct backend_context* mapistore_backend_lookup_by_uri ( struct backend_context_list *  backend_list_ctx,
const char *  uri 
)

find the context matching given uri string

Parameters
backend_list_ctxpointer to the backend context list
urithe uri string to search
Returns
Pointer to the mapistore_backend context on success, otherwise NULL

Referenced by mapistore_search_context_by_uri().

enum mapistore_error mapistore_backend_register ( const void *  _backend)

Register mapistore backends

Parameters
backendpointer to the mapistore backend to register
Returns
MAPISTORE_SUCCESS on success

References MAPISTORE_ERR_INVALID_PARAMETER, and MAPISTORE_SUCCESS.

bool mapistore_backend_run_init ( init_backend_fn *  fns)

Run specified initialization functions.

Parameters
fnspointer to an array of mapistore backends initialization functions
Returns
true on success, otherwise false

Referenced by mapistore_backend_init().

enum mapistore_error mapistore_del_context ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id 
)

Delete an existing connection context from mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the context to delete
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_backend_delete_context(), mapistore_backend_lookup(), MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_REF_COUNT, MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_folder_create_folder ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
TALLOC_CTX *  mem_ctx,
uint64_t  fid,
struct SRow *  aRow,
void **  child_folder 
)

Create a directory in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the directory will be created
parent_fidthe parent folder identifier
new_fidthe folder identifier for the new folder
aRowpointer to MAPI data structures with properties to be added to the new folder
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_create_message ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
TALLOC_CTX *  mem_ctx,
uint64_t  mid,
uint8_t  associated,
void **  messagep 
)

Create a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the messagewill be created
parent_fidthe parent folder identifier
midthe message identifier to create
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_delete ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
uint8_t  flags,
TALLOC_CTX *  mem_ctx,
uint64_t **  deleted_fmids_p,
uint32_t *  deleted_fmids_count_p 
)

Remove a directory in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend
folderthe folder object
flagsflags that control the behaviour of the operation
mem_ctxmemory context where deleted_fmids_p is allocated
deleted_fmids_ppointer to the deleted fmids array
deleted_fmids_count_ppointer to the number of deleted fmids
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), MAPISTORE_ERR_EXIST, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_folder_delete_message ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
uint64_t  mid,
uint8_t  flags 
)

Delete a message from mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the message's to be located is stored
midthe message identifier of the folder to delete
flagsflags that control the behaviour of the operation (MAPISTORE_SOFT_DELETE or MAPISTORE_PERMANENT_DELETE)
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_get_child_count ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
enum mapistore_table_type  table_type,
uint32_t *  RowCount 
)

Retrieve the number of child messages within a mapistore folder

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend
fidthe folder identifier
RowCountpointer to the count result to return
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_get_deleted_fmids ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
TALLOC_CTX *  mem_ctx,
enum mapistore_table_type  table_type,
uint64_t  change_num,
struct UI8Array_r **  fmidsp,
uint64_t *  cnp 
)

Get the array of deleted items following a specific change number

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the message's to be located is stored
folderthe folder backend object
mem_ctxthe TALLOC_CTX that should be used as parent for the returned array
table_typethe type of object that we want to take into account
change_numthe reference change number
fmidspa pointer to the returned array
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_move_folder ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  move_folder,
void *  target_folder,
TALLOC_CTX *  mem_ctx,
const char *  new_folder_name 
)

Move a mapistore folder to target folder

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend
move_folderthe folder backend object to move
target_folderthe folder backend object which becomes the parent folder of move_folder. If it is NULL, then the move_folder will become to a root folder
mem_ctxthe TALLOC_CTX memory context
new_folder_namethe new folder name after performing the move operation
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_open_folder ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
TALLOC_CTX *  mem_ctx,
uint64_t  fid,
void **  child_folder 
)

Open a directory in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the directory will be opened
folderthe parent folder object
mem_ctxthe memory context where child_folder is created
fidfolder identifier to open
[out]child_folderlocation where to store new mapistore backend object on success
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_folder_open_message ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  folder,
TALLOC_CTX *  mem_ctx,
uint64_t  mid,
bool  read_write,
void **  messagep 
)

Open a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the directory will be opened
parent_fidthe parent folder identifier
midthe message identifier to open
pointerto the mapistore_message structure
Returns
MAPISTORE SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_indexing_get_new_folderID ( struct mapistore_context *  mstore_ctx,
uint64_t *  fid 
)

Allocates a new FolderID and returns it

Parameters
mstore_ctxpointer to the mapistore context
fidpointer to the fid value the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_indexing_get_new_folderID_as_user().

enum mapistore_error mapistore_indexing_get_new_folderID_as_user ( struct mapistore_context *  mstore_ctx,
const char *  username,
uint64_t *  fid 
)

Allocates a new FolderID for a specific user and returns it

Parameters
mstore_ctxpointer to the mapistore context
usernamename of the mailbox
fidpointer to the fid value the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_SUCCESS.

Referenced by mapistore_indexing_get_new_folderID().

enum mapistore_error mapistore_indexing_get_new_folderIDs ( struct mapistore_context *  mstore_ctx,
TALLOC_CTX *  mem_ctx,
uint64_t  max,
struct UI8Array_r **  fids_p 
)

Allocates a batch of new folder ids and returns them

Parameters
mstore_ctxpointer to the mapistore context
mem_ctxmemory context where the fid will be allocated
maxnumber of fids to allocate
fids_ppointer array of fids values the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_SUCCESS.

enum mapistore_error mapistore_indexing_record_add_fid ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
const char *  username,
uint64_t  fid 
)

Add a fid record to the indexing database

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the indexing database to update
fidthe fid to add
Note
This is a wrapper to the internal common mapistore_indexing_record_add_fmid function.
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_indexing_record_add_fmid().

enum mapistore_error mapistore_indexing_record_add_fmid_for_uri ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
const char *  username,
uint64_t  fmid,
const char *  mapistore_uri 
)

Add a folder or message record to the indexing database using the given URI

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the indexing database to update
usernamethe username who owns the new entry
fmidthe folder or message ID to add
mapistore_urithe URI to map against this fmid
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_backend_lookup(), MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERROR, and mapistore_indexing_add().

enum mapistore_error mapistore_indexing_record_add_mid ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
const char *  username,
uint64_t  mid 
)

Add a mid record to the indexing database

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the indexing database to update
midthe mid to add
Note
This is a wrapper to the internal common mapistore_indexing_record_add_fmid function.
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_indexing_record_add_fmid().

enum mapistore_error mapistore_indexing_record_del_fid ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
const char *  username,
uint64_t  fid,
uint8_t  flags 
)

Delete a fid record from the indexing database

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the indexing database to update
fidthe fid to remove
flagsthe type of deletion MAPISTORE_SOFT_DELETE or MAPISTORE_PERMANENT_DELETE
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_indexing_record_del_fmid().

enum mapistore_error mapistore_indexing_record_del_mid ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
const char *  username,
uint64_t  mid,
uint8_t  flags 
)

Delete a mid record from the indexing database

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the indexing database to update
midthe mid to remove
flagsthe type of deletion MAPISTORE_SOFT_DELETE or MAPISTORE_PERMANENT_DELETE
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_indexing_record_del_fmid().

enum mapistore_error mapistore_indexing_record_get_uri ( struct mapistore_context *  mstore_ctx,
const char *  username,
TALLOC_CTX *  mem_ctx,
uint64_t  fmid,
char **  urip,
bool *  soft_deletedp 
)

Returns record data

Parameters
mstore_ctxpointer to the mapistore context
usernamethe name of the account where to look for the indexing database
mem_ctxpointer to the memory context
fmidthe fmid/key to the record
urippointer to the uri pointer
soft_deletedppointer to the soft deleted pointer
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NOT_INITIALIZED, MAPISTORE_ERROR, and mapistore_indexing_add().

enum mapistore_error mapistore_indexing_reserve_fmid_range ( struct mapistore_context *  mstore_ctx,
uint64_t  range_len,
uint64_t *  first_fmidp 
)

Reserve a range of FMID

Parameters
mstore_ctxpointer to the mapistore context
range_lensize of the range of fmids to reserve
first_fmidppointer to the first reserved fid value the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_PARAMETER, mapistore_indexing_search(), and MAPISTORE_SUCCESS.

struct mapistore_context* mapistore_init ( TALLOC_CTX *  mem_ctx,
struct loadparm_context *  lp_ctx,
const char *  path 
)

Initialize the mapistore context

Parameters
mem_ctxpointer to the memory context
lp_ctxloadparm_context to get smb.conf options
paththe path to the location to load the backend providers from (NULL for default)
Returns
allocate mapistore context on success, otherwise NULL

References mapistore_backend_init(), mapistore_errstr(), mapistore_set_default_cache_url(), mapistore_set_default_indexing_url(), mapistore_set_mapping_path(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_message_get_message_data ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  message,
TALLOC_CTX *  mem_ctx,
struct mapistore_message **  msg 
)

Modify recipients of a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where properties will be stored
midthe identifier referencing the message the array of recipient rows the number of elements in the array
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_message_modify_recipients ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  message,
struct SPropTagArray *  columns,
uint16_t  count,
struct mapistore_message_recipient *  recipients 
)

Modify recipients of a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where properties will be stored
midthe identifier referencing the message the array of recipient rows the number of elements in the array
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_message_save ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  message,
TALLOC_CTX *  mem_ctx 
)

Commit the changes made to a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the message's changes will be saved
midthe message identifier to save
flagsflags associated to the commit operation
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_message_set_read_flag ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  message,
uint8_t  flag 
)

Commit the changes made to a message in mapistore

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the message's changes will be saved
midthe message identifier to save
flagsflags associated to the commit operation
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_message_submit ( struct mapistore_context *  mstore_ctx,
uint32_t  context_id,
void *  message,
enum SubmitFlags  flags 
)

Submits a message for sending.

Parameters
mstore_ctxpointer to the mapistore context
context_idthe context identifier referencing the backend where the message will be submitted
midthe message identifier representing the message to submit
flagsflags associated to the submit operation
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors

References mapistore_backend_lookup(), and MAPISTORE_ERR_INVALID_PARAMETER.

enum mapistore_error mapistore_namedprops_create_id ( struct namedprops_context *  nprops,
struct MAPINAMEID  nameid,
uint16_t  mapped_id 
)

return the mapped property ID matching the nameid structure passed in parameter.

Parameters
ldb_ctxpointer to the namedprops ldb context
nameidthe MAPINAMEID structure to lookup
propIDpointer to the property ID the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR

References MAPISTORE_ERROR.

enum mapistore_error mapistore_namedprops_get_mapped_id ( struct namedprops_context *  nprops,
struct MAPINAMEID  nameid,
uint16_t *  propID 
)

return the mapped property ID matching the nameid structure passed in parameter.

Parameters
ldb_ctxpointer to the namedprops ldb context
nameidthe MAPINAMEID structure to lookup
propIDpointer to the property ID the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR

References MAPISTORE_ERROR.

enum mapistore_error mapistore_namedprops_get_nameid ( struct namedprops_context *  nprops,
uint16_t  propID,
TALLOC_CTX *  mem_ctx,
struct MAPINAMEID **  nameidp 
)

return the nameid structture matching the mapped property ID passed in parameter.

Parameters
ldb_ctxpointer to the namedprops ldb context
propIDthe property ID to lookup
nameidpointer to the MAPINAMEID structure the function returns
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR

References MAPISTORE_ERROR.

enum mapistore_error mapistore_namedprops_get_nameid_type ( struct namedprops_context *  nprops,
uint16_t  propID,
uint16_t *  propTypeP 
)

return the type matching the mapped property ID passed in parameter.

Parameters
ldb_ctxpointer to the namedprops ldb context
propIDthe property ID to lookup
propTypePpointer to the uint16_t that will receive the property type
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR

References MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_namedprops_next_unused_id ( struct namedprops_context *  nprops,
uint16_t *  highest_id 
)

Returns the next unmapped property ID

Parameters
npropspointer to the namedprops context
highest_idpointer to the next unused id to return
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_PARAMETER, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_deliver_add ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid,
uint8_t *  payload,
size_t  length 
)

Add or update a deliver key

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session UUID
payloadthe payload data to add to the key
lengththe length of the payload data
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, mapistore_notification_deliver_exist(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_deliver_delete ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid 
)

Delete the deliver key

Parameters
mstore_ctxpointer to the mapistore context
uuidthe uuid of the session to delete content from
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_deliver_exist ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid 
)

Check if a deliver key exist for current session

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session UUID to compute
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERR_NOT_FOUND

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

Referenced by mapistore_notification_deliver_add().

enum mapistore_error mapistore_notification_deliver_get ( TALLOC_CTX *  mem_ctx,
struct mapistore_context *  mstore_ctx,
struct GUID  uuid,
uint8_t **  payload,
size_t *  length 
)

Retrieve the deliver payload

Parameters
mem_ctxthe memory context to use for data allocation
mstore_ctxpointer to the mapistore context
uuidthe UUID of the session
payloadpointer on pointer to the data to return
lengthpointer on the length of the payload data to return
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_payload_newmail ( TALLOC_CTX *  mem_ctx,
char *  backend,
char *  eml,
char *  folder,
char  separator,
uint8_t **  data,
size_t *  length 
)

Generate a newmail notification payload to be consumed by the service referenced by resolver entries.

Parameters
mem_ctxpointer to the memory context
backendthe mapistore backend consuming this url
emlthe eml message to index
folderthe destination folder
separatorthe folder separator
datapointer on pointer to the generated blob to return
lengthpointer to the length of the generated blob returned
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_resolver_add ( struct mapistore_context *  mstore_ctx,
const char *  cn,
const char *  host 
)

Add a record to the resolver

Parameters
mstore_ctxpointer to the mapistore context
cnthe common name (key) to use for host registration
hostthe host to register
Note
This function acts as a wrapper and manages both the creation of a new key/value pair and the update of an existing record. The following logic is implemented:

[START] Does the key exist? If yes: Update record If no: Insert key

Todo:
Note that a race condition is possible between the exist check and the addition of the record, where the same key could have been created by another instance, leading to the failure of the add operation. While this scenario is very unlikely to happen in real world, a retry with a counter should be implemented in further iterations to reasonably circumvent this use case.
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_EXIST, MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_FOUND, MAPISTORE_ERR_NOT_INITIALIZED, mapistore_notification_resolver_exist(), mapistore_notification_resolver_get(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_resolver_delete ( struct mapistore_context *  mstore_ctx,
const char *  cn,
const char *  host 
)

Unregister a host from a resolver entry

Parameters
mstore_ctxpointer to the mapistore context
cnthe resolver key to lookup
hostthe host entry to delete within record
Note
If the record has no longer host entry, the function deletes the record
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_FOUND, MAPISTORE_ERR_NOT_INITIALIZED, mapistore_notification_resolver_get(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_resolver_exist ( struct mapistore_context *  mstore_ctx,
const char *  cn 
)

Check if the resolver entry pointer by cn exist

Parameters
mstore_ctxpointer to the mapistore context
cnthe common name to lookup
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERR_NOT_FOUND or MAPISTORE generic error upon other failures.

References MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

Referenced by mapistore_notification_resolver_add().

enum mapistore_error mapistore_notification_resolver_get ( TALLOC_CTX *  mem_ctx,
struct mapistore_context *  mstore_ctx,
const char *  cn,
uint32_t *  countp,
const char ***  hostsp 
)

Get resolver data for a given resolver entry

Parameters
mem_ctxpointer to the memory context
mstore_ctxpointer to the mapistore context
cnthe resolver key to lookup
countppointer on the number of hosts returned
hostsppointer on the list of host to return
Note
calling function is responsible for freeing hostsp
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

Referenced by mapistore_notification_resolver_add(), and mapistore_notification_resolver_delete().

enum mapistore_error mapistore_notification_session_add ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid,
struct GUID  async_uuid,
const char *  cn 
)

Register and bind asynchronous emsmdb session handle to emsmdb one

Parameters
mstore_ctxpointer to the mapistore context
uuidthe emsmdb session uuid
async_uuidthe asynchronous emsmdb session uuid
cnthe common name (username or email) to associate
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_session_delete ( struct mapistore_context *  mstore_ctx,
struct GUID  async_uuid 
)

Unregister and unbind specified asynchronous emsmdb session

Parameters
mstore_ctxpointer to the mstore context
async_uuidthe asynchronous emsmdb session uuid used for computing the session key to be deleted
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_session_exist ( struct mapistore_context *  mstore_ctx,
struct GUID  async_uuid 
)

Check if an asynchronous session context exists

Parameters
mstore_ctxpointer to the mapistore context
async_uuidthe asynchronous emsmdb session uuid to lookup
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERR_NOT_FOUND or MAPISTORE error upon failure.

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_session_get ( TALLOC_CTX *  mem_ctx,
struct mapistore_context *  mstore_ctx,
struct GUID  async_uuid,
struct GUID *  uuid,
char **  cnp 
)

Retrieve EMSMDB session UUID and user name associated to specified asynchronous emsmdb session UUID

Parameters
mem_ctxpointer to the memory context to use to allocate data to return
mstore_ctxpointer to the mapistore context
async_uuidthe GUID of the asynchronous emsmdb session
uuidppointer to the GUID of the emsmdb session
cnppointer on pointer to the common name to return
Note
calling function is responsible for freeing cnp
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_subscription_add ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid,
uint32_t  handle,
uint16_t  flags,
uint64_t  fid,
uint64_t  mid,
uint32_t  count,
enum MAPITAGS *  properties 
)

Add a subscription entry for a MAPI object

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session UUID
handlethe handle to associate this subscription with
flagsthe notification bitmask to associate to this subscription
fidthe FolderID where relevant
midthe MessageId where relevant
countthe number of properties when subscribing for a table events
propertiespointer on an array of MAPI properties to add for table events
Note
subscription are uniquely identified by the com
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_EXIST, MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, mapistore_notification_subscription_exist(), and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_subscription_delete ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid 
)

Delete the subscription record associated to specified session UUID

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session UUID
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_subscription_delete_by_handle ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid,
uint32_t  handle 
)

Delete the subscription record associated to specified session UUID and referenced by specified handle

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session uuid
handlethe handle of the entry to delete
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_DATA, MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_FOUND, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_notification_subscription_exist ( struct mapistore_context *  mstore_ctx,
struct GUID  uuid 
)

Check if a subscription record exist for the given session UUID

Parameters
mstore_ctxpointer to the mapistore context
uuidthe session UUID to lookup
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERR_NOT_FOUND

References MAPISTORE_ERR_NO_MEMORY, MAPISTORE_ERR_NOT_AVAILABLE, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

Referenced by mapistore_notification_subscription_add().

enum mapistore_error mapistore_release ( struct mapistore_context *  mstore_ctx)

Release the mapistore context and destroy any data associated

Parameters
mstore_ctxpointer to the mapistore context
Note
The function needs to rely on talloc destructors which is not implemented in code yet.
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_replica_mapping_guid_to_replid ( struct mapistore_context *  mstore_ctx,
const char *  username,
const struct GUID *  guidP,
uint16_t *  replidP 
)

Search a replica guid in the database, creates it if it does not exist

Parameters
mstore_ctxpointer to the mapistore context
guidPthe replica guid
replidPpointer to the returned replica id
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_replica_mapping_replid_to_guid ( struct mapistore_context *  mstore_ctx,
const char *  username,
uint16_t  replid,
struct GUID *  guidP 
)

Search a replica id in the database

Parameters
mstore_ctxpointer to the mapistore context
replidthe replica id
guidPpointer to the returned replica guid
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_search_context_by_uri ( struct mapistore_context *  mstore_ctx,
const char *  uri,
uint32_t *  context_id,
void **  backend_object 
)

Search for an existing context given its uri

Parameters
mstore_ctxpointer to the mapistore context
urithe URI to lookup
context_idpointer to the context identifier to return
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References mapistore_backend_lookup_by_uri(), MAPISTORE_ERR_NOT_FOUND, MAPISTORE_ERROR, and MAPISTORE_SUCCESS.

enum mapistore_error mapistore_set_connection_info ( struct mapistore_context *  mstore_ctx,
struct ldb_context *  sam_ctx,
struct openchangedb_context *  oc_ctx,
const char *  username 
)

Set connection info for current mapistore context

Parameters
mstore_ctxpointer to the mapistore context
oc_ctxpointer to the openchange ldb database
usernamepointer to the current username
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_INVALID_PARAMETER, MAPISTORE_ERR_NOT_INITIALIZED, and MAPISTORE_SUCCESS.

void mapistore_set_default_cache_url ( const char *  url)

Set the default cache url. If none is set, 127.0.0.1:11211 will be used.

Parameters
urldefault backend url to be used

Referenced by mapistore_init().

void mapistore_set_default_indexing_url ( const char *  url)

Set the default backend url. If none is set, a tdb file per user will be used.

Parameters
urldefault backend url to be used

Referenced by mapistore_init().

enum mapistore_error mapistore_set_mapping_path ( const char *  path)

Set the mapping path

Parameters
pathpointer to the mapping path
Note
The mapping path can be set unless id_mapping_context is initialized. If path is NULL and mapping path is not yet initialized, then mapping_path will be reset to its default value when the initialization routine is called.
Returns
MAPISTORE_SUCCESS on success, otherwise MAPISTORE error

References MAPISTORE_ERR_NO_DIRECTORY, and MAPISTORE_SUCCESS.

Referenced by mapistore_init().


Creative Commons License
Creative Commons Attribution icon Creative Commons Share Alike icon
This content is licensed under the Creative Commons
Attribution ShareAlike License v. 3.0:
http://creativecommons.org/licenses/by-sa/3.0/