libmapi/emsmdb.c File Reference

EMSMDB stack functions. More...

#include <unistd.h>
#include <fcntl.h>
#include "libmapi/libmapi.h"
#include "libmapi/libmapi_private.h"

Functions

enum MAPISTATUS emsmdb_async_connect (struct emsmdb_context *emsmdb_ctx)
struct mapi_notify_ctxemsmdb_bind_notification (struct mapi_context *mapi_ctx, TALLOC_CTX *mem_ctx)
struct emsmdb_contextemsmdb_connect (TALLOC_CTX *parent_mem_ctx, struct mapi_session *session, struct dcerpc_pipe *p, struct cli_credentials *cred, int *return_value)
struct emsmdb_contextemsmdb_connect_ex (TALLOC_CTX *mem_ctx, struct mapi_session *session, struct dcerpc_pipe *p, struct cli_credentials *cred, int *return_value)
enum MAPISTATUS emsmdb_disconnect (struct emsmdb_context *emsmdb_ctx)
int emsmdb_disconnect_dtor (void *data)
_PUBLIC_ struct emsmdb_infoemsmdb_get_info (struct mapi_session *session)
enum MAPISTATUS emsmdb_get_SPropValue (TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, DATA_BLOB *content, struct SPropTagArray *tags, struct SPropValue **propvals, uint32_t *cn_propvals, uint8_t flag)
void emsmdb_get_SRow (TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct SRow *aRow, struct SPropTagArray *proptags, uint16_t propcount, DATA_BLOB *content, uint8_t flag, uint8_t align)
_PUBLIC_ void emsmdb_get_SRowSet (TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct SRowSet *rowset, struct SPropTagArray *proptags, DATA_BLOB *content)
NTSTATUS emsmdb_register_notification (struct mapi_session *session, struct NOTIFKEY *notifkey, uint16_t ulEventMask)
_PUBLIC_ NTSTATUS emsmdb_transaction (struct emsmdb_context *emsmdb_ctx, TALLOC_CTX *mem_ctx, struct mapi_request *req, struct mapi_response **repl)
_PUBLIC_ NTSTATUS emsmdb_transaction_ext2 (struct emsmdb_context *emsmdb_ctx, TALLOC_CTX *mem_ctx, struct mapi_request *req, struct mapi_response **repl)
_PUBLIC_ NTSTATUS emsmdb_transaction_null (struct emsmdb_context *emsmdb_ctx, struct mapi_response **res)
_PUBLIC_ NTSTATUS emsmdb_transaction_wrapper (struct mapi_session *session, TALLOC_CTX *mem_ctx, struct mapi_request *req, struct mapi_response **repl)
void free_emsmdb_property (struct SPropValue *lpProp, void *data)
const void * pull_emsmdb_property (TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, uint32_t *offset, enum MAPITAGS tag, DATA_BLOB *data)
bool server_version_at_least (struct emsmdb_context *ctx, uint16_t major_ver, uint16_t minor_ver, uint16_t major_build, uint16_t minor_build)

Detailed Description

EMSMDB stack functions.


Function Documentation

enum MAPISTATUS emsmdb_async_connect ( struct emsmdb_context emsmdb_ctx)

Get an async notification context handle

Parameters:
emsmdb_ctxpointer to the EMSMDB context
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References OPENCHANGE_RETVAL_IF, emsmdb_context::handle, emsmdb_context::async_handle, emsmdb_context::rpc_connection, and emsmdb_context::mem_ctx.

Referenced by Logon().

struct mapi_notify_ctx* emsmdb_bind_notification ( struct mapi_context mapi_ctx,
TALLOC_CTX *  mem_ctx 
) [read]

Initialize the notify context structure and bind a local UDP port to receive notifications from the server

Parameters:
mapi_ctxpointer to the MAPI context
mem_ctxpointer to the memory context
Returns:
an allocated mapi_notify_ctx structure on success, otherwise NULL

References DFLT_NOTIF_PORT, mapi_context::session, mapi_session::profile, mapi_notify_ctx::notifications, mapi_context::lp_ctx, and mapi_profile::server.

Referenced by RegisterNotification().

struct emsmdb_context* emsmdb_connect ( TALLOC_CTX *  parent_mem_ctx,
struct mapi_session session,
struct dcerpc_pipe *  p,
struct cli_credentials *  cred,
int *  return_value 
) [read]

Establishes a new Session Context with the server on the exchange_emsmdb pipe

Parameters:
parent_mem_ctxpointer to the memory context
sessionpointer to the MAPI session context
ppointer to the DCERPC pipe
credpointer to the user credentials
return_valuepointer on EcDoConnect MAPI return value
Returns:
an allocated emsmdb_context on success, otherwise NULL

References emsmdb_context::mem_ctx, emsmdb_context::rpc_connection, emsmdb_context::cache_requests, emsmdb_context::info, emsmdb_info::szDisplayName, emsmdb_info::szDNPrefix, mapi_session::profile, mapi_profile::mailbox, mapi_profile::codepage, mapi_profile::language, mapi_profile::method, emsmdb_context::handle, emsmdb_info::pcmsPollsMax, emsmdb_info::pcRetry, emsmdb_info::pcmsRetryDelay, emsmdb_info::picxr, mapi_errstr(), emsmdb_info::rgwServerVersion, emsmdb_context::cred, emsmdb_context::max_data, and emsmdb_context::setup.

Referenced by Logon().

struct emsmdb_context* emsmdb_connect_ex ( TALLOC_CTX *  mem_ctx,
struct mapi_session session,
struct dcerpc_pipe *  p,
struct cli_credentials *  cred,
int *  return_value 
) [read]

Establishes a new Session Context with the server on the exchange_emsmdb pipe using 0xA EcDoConnectEx opnum

Parameters:
mem_ctxpointer to the memory context
sessionpointer to the MAPI session context
ppointer to the DCERPC pipe
credpointer to the user credentials
return_valuepointer on EcDoConnectEx MAPI return value
Returns:
an allocated emsmdb_context structure on success, otherwise NULL

References emsmdb_context::rpc_connection, emsmdb_context::mem_ctx, emsmdb_context::info, emsmdb_info::szDisplayName, emsmdb_info::szDNPrefix, emsmdb_context::handle, mapi_session::profile, mapi_profile::mailbox, mapi_profile::codepage, mapi_profile::language, mapi_profile::method, emsmdb_info::pcmsPollsMax, emsmdb_info::pcRetry, emsmdb_info::pcmsRetryDelay, emsmdb_info::picxr, mapi_errstr(), emsmdb_info::rgwServerVersion, emsmdb_context::cred, emsmdb_context::max_data, and emsmdb_context::setup.

Referenced by Logon().

enum MAPISTATUS emsmdb_disconnect ( struct emsmdb_context emsmdb_ctx)

Destroy the EMSMDB context handle

Parameters:
emsmdb_ctxpointer to the EMSMDB context
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References OPENCHANGE_RETVAL_IF, emsmdb_context::handle, and emsmdb_context::rpc_connection.

Referenced by emsmdb_disconnect_dtor().

int emsmdb_disconnect_dtor ( void *  data)

Destructor for the EMSMDB context. Call the EcDoDisconnect function.

Parameters:
datageneric pointer to data with mapi_provider information
Returns:
MAPI_E_SUCCESS on success, otherwise -1

References mapi_provider::ctx, emsmdb_disconnect(), emsmdb_context::cache_requests, emsmdb_context::info, emsmdb_info::szDisplayName, and emsmdb_info::szDNPrefix.

Referenced by MapiLogonProvider().

_PUBLIC_ struct emsmdb_info* emsmdb_get_info ( struct mapi_session session) [read]

Retrieves the EMSMDB context server information structure

Parameters:
sessionpointer to the MAPI session context
Returns:
the server info structure on success, otherwise NULL

References mapi_session::emsmdb, and mapi_provider::ctx.

enum MAPISTATUS emsmdb_get_SPropValue ( TALLOC_CTX *  mem_ctx,
struct loadparm_context *  lp_ctx,
DATA_BLOB *  content,
struct SPropTagArray *  tags,
struct SPropValue **  propvals,
uint32_t *  cn_propvals,
uint8_t  flag 
)

Get a SPropValue array from a DATA blob

Parameters:
mem_ctxpointer to the memory context
lp_ctxpointer to the loadparm context
contentpointer to the DATA blob content
tagspointer to a list of property tags to lookup
propvalspointer on pointer to the returned SPropValues
cn_propvalspointer to the number of propvals
flagdescribes the type data
Returns:
MAPI_E_SUCCESS on success

References PT_ERROR, pull_emsmdb_property(), set_SPropValue(), and free_emsmdb_property().

Referenced by GetProps().

void emsmdb_get_SRow ( TALLOC_CTX *  mem_ctx,
struct loadparm_context *  lp_ctx,
struct SRow *  aRow,
struct SPropTagArray *  proptags,
uint16_t  propcount,
DATA_BLOB *  content,
uint8_t  flag,
uint8_t  align 
)

Get a SRow from a DATA blob

Parameters:
mem_ctxpointer on the memory context
lp_ctxpointer on the loadparm context
aRowpointer on the returned SRow
proptagspointer on a list of property tags to lookup
propcountnumber of SPropValue entries in aRow
contentpointer on the DATA blob content
flagthe type data
alignalignment pad
Returns:
MAPI_E_SUCCESS on success
Note:
TODO: We shouldn't have any alignment pad here

References PT_ERROR, pull_emsmdb_property(), set_SPropValue(), and free_emsmdb_property().

Referenced by OpenEmbeddedMessage(), OpenMessage(), and ReloadCachedInformation().

_PUBLIC_ void emsmdb_get_SRowSet ( TALLOC_CTX *  mem_ctx,
struct loadparm_context *  lp_ctx,
struct SRowSet *  rowset,
struct SPropTagArray *  proptags,
DATA_BLOB *  content 
)

Get a SRowSet from a DATA blob

Parameters:
mem_ctxpointer on the memory context
lp_ctxpointer on the loadparm context
rowsetpointer on the returned SRowSe
proptagspointer on a list of property tags to lookup
contentpointer on the DATA blob content
Returns:
MAPI_E_SUCCESS on success
Note:
TODO: this doesn't yet handle the TypedPropertyValue and FlaggedPropertyValueWithTypeSpecified variants

References PT_ERROR, pull_emsmdb_property(), set_SPropValue(), and free_emsmdb_property().

Referenced by QueryRows(), FindRow(), and ExpandRow().

NTSTATUS emsmdb_register_notification ( struct mapi_session session,
struct NOTIFKEY *  notifkey,
uint16_t  ulEventMask 
)

Register for notifications on the server

Parameters:
sessionPointer to the current MAPI session
notifkeyThe opaque client-generated context data
ulEventMaskNotification flags. Exchange completely ignores this value and it should be set to 0
Returns:
NTSTATUS_OK on success, otherwise NT status error

References mapi_session::emsmdb, mapi_provider::ctx, mapi_session::notify_ctx, emsmdb_context::handle, mapi_notify_ctx::addr, emsmdb_context::rpc_connection, and emsmdb_context::mem_ctx.

Referenced by RegisterNotification().

_PUBLIC_ NTSTATUS emsmdb_transaction ( struct emsmdb_context emsmdb_ctx,
TALLOC_CTX *  mem_ctx,
struct mapi_request *  req,
struct mapi_response **  repl 
)

Make a EMSMDB transaction.

Parameters:
emsmdb_ctxpointer to the EMSMDB connection context
mem_ctxpointer to the memory context
reqpointer to the MAPI request to send
replpointer on pointer to the MAPI reply returned by the server
Returns:
NT_STATUS_OK on success, otherwise NT status error

References emsmdb_context::handle, emsmdb_context::max_data, emsmdb_context::mem_ctx, emsmdb_context::cache_count, emsmdb_context::cache_requests, emsmdb_context::cache_size, emsmdb_context::rpc_connection, and emsmdb_context::setup.

Referenced by emsmdb_transaction_wrapper().

_PUBLIC_ NTSTATUS emsmdb_transaction_ext2 ( struct emsmdb_context emsmdb_ctx,
TALLOC_CTX *  mem_ctx,
struct mapi_request *  req,
struct mapi_response **  repl 
)

Make a EMSMDB EXT2 transaction.

Parameters:
emsmdb_ctxpointer to the EMSMDB connection context
mem_ctxpointer to the memory context
reqpointer to the MAPI request to send
replpointer on pointer to the MAPI reply returned by the server
Returns:
NT_STATUS_OK on success, otherwise NT status error

References emsmdb_context::handle, and emsmdb_context::rpc_connection.

Referenced by emsmdb_transaction_wrapper().

_PUBLIC_ NTSTATUS emsmdb_transaction_null ( struct emsmdb_context emsmdb_ctx,
struct mapi_response **  res 
)

Send an empty MAPI packet - useful to keep connection up or force notifications.

Parameters:
emsmdb_ctxpointer to the EMSMDB connection context
respointer on pointer to a MAPI response structure
Returns:
NT_STATUS_OK on success, otherwise NT status error

References emsmdb_context::mem_ctx, emsmdb_context::handle, emsmdb_context::max_data, emsmdb_context::rpc_connection, and MAPI_STATUS_IS_OK.

Referenced by DispatchNotifications(), and MonitorNotification().

_PUBLIC_ NTSTATUS emsmdb_transaction_wrapper ( struct mapi_session session,
TALLOC_CTX *  mem_ctx,
struct mapi_request *  req,
struct mapi_response **  repl 
)

References mapi_session::profile, mapi_profile::exchange_version, emsmdb_transaction(), mapi_session::emsmdb, mapi_provider::ctx, and emsmdb_transaction_ext2().

Referenced by GetLocalReplicaIds(), FXDestConfigure(), TellVersion(), FXCopyFolder(), FXCopyMessages(), FXCopyTo(), FXCopyProperties(), FXGetBuffer(), FXPutBuffer(), ICSSyncConfigure(), ICSSyncUploadStateBegin(), ICSSyncUploadStateContinue(), ICSSyncUploadStateEnd(), SetLocalReplicaMidsetDeleted(), ICSSyncOpenCollector(), ICSSyncGetTransferState(), GetContentsTable(), GetHierarchyTable(), GetPermissionsTable(), GetRulesTable(), ModifyPermissions(), SetSearchCriteria(), GetSearchCriteria(), CreateMessage(), DeleteMessage(), HardDeleteMessage(), GetMessageStatus(), SetMessageStatus(), MoveCopyMessages(), CreateFolder(), EmptyFolder(), DeleteFolder(), MoveFolder(), CopyFolder(), SetReadFlags(), HardDeleteMessagesAndSubfolders(), GetProps(), SetProps(), SaveChangesAttachment(), GetPropList(), GetPropsAll(), DeleteProps(), SetPropertiesNoReplicate(), DeletePropertiesNoReplicate(), GetNamesFromIDs(), GetIDsFromNames(), QueryNamedProperties(), CopyProps(), CopyTo(), OpenPublicFolder(), OpenUserMailbox(), Subscribe(), SetColumns(), QueryPosition(), QueryRows(), QueryColumns(), SeekRow(), SeekRowBookmark(), SeekRowApprox(), CreateBookmark(), FreeBookmark(), SortTable(), Reset(), Restrict(), FindRow(), GetStatus(), Abort(), ExpandRow(), CollapseRow(), GetCollapseState(), SetCollapseState(), CreateAttach(), DeleteAttach(), GetAttachmentTable(), GetValidAttach(), OpenAttach(), ModifyRecipients(), ReadRecipients(), RemoveAllRecipients(), SubmitMessage(), AbortSubmit(), SaveChangesMessage(), TransportSend(), SetMessageReadFlag(), OpenEmbeddedMessage(), OpenFolder(), PublicFolderIsGhosted(), OpenPublicFolderByName(), SetReceiveFolder(), GetReceiveFolder(), GetReceiveFolderTable(), GetTransportFolder(), GetOwningServers(), GetStoreState(), TransportNewMail(), OpenMessage(), ReloadCachedInformation(), OpenStream(), ReadStream(), WriteStream(), CommitStream(), GetStreamSize(), SeekStream(), SetStreamSize(), CopyToStream(), LockRegionStream(), UnlockRegionStream(), CloneStream(), WriteAndCommitStream(), Release(), GetLongTermIdFromId(), GetIdFromLongTermId(), AddressTypes(), SetSpooler(), SpoolerLockMessage(), OptionsData(), SyncOpenAdvisor(), and SetSyncNotificationGuid().

void free_emsmdb_property ( struct SPropValue *  lpProp,
void *  data 
)

Free property values retrieved with pull_emsmdb_property

Parameters:
lpProppointer to SPropValue structure
datageneric pointer to associated lpProp data

References PT_I2, PT_ERROR, PT_LONG, PT_I8, and PT_BOOLEAN.

Referenced by emsmdb_get_SPropValue(), emsmdb_get_SRowSet(), and emsmdb_get_SRow().

const void* pull_emsmdb_property ( TALLOC_CTX *  mem_ctx,
struct loadparm_context *  lp_ctx,
uint32_t *  offset,
enum MAPITAGS  tag,
DATA_BLOB *  data 
)

Retrieves a property value from a DATA blob

Parameters:
mem_ctxpointer to the memory context
lp_ctxpointer to the loadparm context
offsetpointer on pointer to the current offset
tagthe property tag which value is to be retrieved
datapointer to the data
Returns:
pointer on constant generic data on success, otherwise NULL

References PT_I2, PT_ERROR, PT_LONG, PT_BOOLEAN, PT_I8, PT_DOUBLE, PT_UNICODE, PT_STRING8, PT_SYSTIME, PT_CLSID, PT_BINARY, PT_MV_LONG, PT_MV_STRING8, PT_MV_UNICODE, and PT_MV_BINARY.

Referenced by emsmdb_get_SPropValue(), emsmdb_get_SRowSet(), and emsmdb_get_SRow().

bool server_version_at_least ( struct emsmdb_context ctx,
uint16_t  major_ver,
uint16_t  minor_ver,
uint16_t  major_build,
uint16_t  minor_build 
)

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/