📄 msg.cpp
字号:
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_AuthLevel
//=--------------------------------------------------------------------------=
// Sets authlevel for message
//
// Parameters:
// lAuthLevel - [in] message's authlevel
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_AuthLevel(long lAuthLevel)
{
switch (lAuthLevel) {
case MQMSG_AUTH_LEVEL_NONE:
case MQMSG_AUTH_LEVEL_ALWAYS:
EnterCriticalSection(&m_CSlocal);
m_lAuthLevel = lAuthLevel;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
default:
return CreateErrorHelper(
MQ_ERROR_ILLEGAL_PROPERTY_VALUE,
m_ObjectType);
}
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_IsAuthenticated
//=--------------------------------------------------------------------------=
//
// Parameters:
// pisAuthenticated [out]
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_IsAuthenticated(VARIANT_BOOL *pisAuthenticated)
{
*pisAuthenticated = m_fAuthenticated;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_Trace
//=--------------------------------------------------------------------------=
// Gets message's trace option
//
// Parameters:
// plTrace - [in] message's trace option
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_Trace(long FAR* plTrace)
{
*plTrace = m_lTrace;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_Trace
//=--------------------------------------------------------------------------=
// Sets trace option for message
//
// Parameters:
// trace - [in] message's trace option
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_Trace(long lTrace)
{
switch (lTrace) {
case MQMSG_TRACE_NONE:
case MQMSG_SEND_ROUTE_TO_REPORT_QUEUE:
EnterCriticalSection(&m_CSlocal);
m_lTrace = lTrace;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
default:
return CreateErrorHelper(
MQ_ERROR_ILLEGAL_PROPERTY_VALUE,
m_ObjectType);
}
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_Priority
//=--------------------------------------------------------------------------=
// Gets message's priority
//
// Parameters:
// plPriority - [out] message's priority
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_Priority(long FAR* plPriority)
{
*plPriority = m_lPriority;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_Priority
//=--------------------------------------------------------------------------=
// Sets message's priority
//
// Parameters:
// lPriority - [in] message's priority
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_Priority(long lPriority)
{
if ((lPriority >= MQ_MIN_PRIORITY) &&
(lPriority <= MQ_MAX_PRIORITY)) {
EnterCriticalSection(&m_CSlocal);
m_lPriority = lPriority;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
}
else {
return CreateErrorHelper(
MQ_ERROR_ILLEGAL_PROPERTY_VALUE,
m_ObjectType);
}
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_Journal
//=--------------------------------------------------------------------------=
// Gets message's journaling option
//
// Parameters:
// plJournal - [out] message's journaling option
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_Journal(long FAR* plJournal)
{
*plJournal = m_lJournal;
return NOERROR;
}
#define MQMSG_JOURNAL_MASK (MQMSG_JOURNAL_NONE | \
MQMSG_DEADLETTER | \
MQMSG_JOURNAL)
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_Journal
//=--------------------------------------------------------------------------=
// Sets journaling option for message
//
// Parameters:
// lJournal - [in] message's admin queue
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_Journal(long lJournal)
{
//
// ensure that no bits are set in incoming lJournal
// flags word other than our mask.
//
if (lJournal & ~MQMSG_JOURNAL_MASK) {
return CreateErrorHelper(
MQ_ERROR_ILLEGAL_PROPERTY_VALUE,
m_ObjectType);
}
else {
EnterCriticalSection(&m_CSlocal);
m_lJournal = lJournal;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
}
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_ResponseQueueInfo
//=--------------------------------------------------------------------------=
// Gets Response queue for message
//
// Parameters:
// ppqResponse - [out] message's Response queue
//
// Output:
//
// Notes:
// caller must Release returned obj pointer.
//
HRESULT CMSMQMessage::get_ResponseQueueInfo(
IMSMQQueueInfo FAR* FAR* ppqinfoResponse)
{
*ppqinfoResponse = m_pqinfoResponse;
ADDREF(*ppqinfoResponse);
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::putref_ResponseQueueInfo
//=--------------------------------------------------------------------------=
// Sets Response queue for message
//
// Parameters:
// pqResponse - [in] message's Response queue
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::putref_ResponseQueueInfo(
IMSMQQueueInfo FAR* pqinfoResponse)
{
BSTR bstrFormatName = NULL;
HRESULT hresult = NOERROR;
EnterCriticalSection(&m_CSlocal);
RELEASE(m_pqinfoResponse);
m_pqinfoResponse = pqinfoResponse;
ADDREF(m_pqinfoResponse);
//
// Update our resp formatname buffer
//
if (m_pqinfoResponse) {
IfFailRet(m_pqinfoResponse->get_FormatName(&bstrFormatName));
ASSERT(SysStringByteLen(bstrFormatName) < FORMAT_NAME_INIT_BUFFER,
L"resp queue buffer too short.");
memcpy(m_pwszRespQueue,
bstrFormatName,
SysStringByteLen(bstrFormatName));
m_cchRespQueue = SysStringLen(bstrFormatName);
//
// null terminate
//
memset(&m_pwszRespQueue[m_cchRespQueue], 0, sizeof(WCHAR));
}
LeaveCriticalSection(&m_CSlocal);
SysFreeString(bstrFormatName);
return hresult;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_AppSpecific
//=--------------------------------------------------------------------------=
// Gets message's app specific info of message
//
// Parameters:
// plAppSpecific - [out] message's app specific info
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_AppSpecific(long FAR* plAppSpecific)
{
*plAppSpecific = m_lAppSpecific;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_AppSpecific
//=--------------------------------------------------------------------------=
// Sets app specific info for message
//
// Parameters:
// lAppSpecific - [in] message's app specific info
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_AppSpecific(long lAppSpecific)
{
EnterCriticalSection(&m_CSlocal);
m_lAppSpecific = lAppSpecific;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_SentTime
//=--------------------------------------------------------------------------=
// Gets message's sent time
//
// Parameters:
// pvarSentTime - [out] time message was sent
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_SentTime(VARIANT FAR* pvarSentTime)
{
return GetVariantTimeOfTime(m_lSentTime, pvarSentTime);
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_ArrivedTime
//=--------------------------------------------------------------------------=
// Gets message's arrival time
//
// Parameters:
// pvarArrivedTime - [out] time message arrived
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_ArrivedTime(VARIANT FAR* pvarArrivedTime)
{
return GetVariantTimeOfTime(m_lArrivedTime, pvarArrivedTime);
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::AttachCurrentSecurityContext
//=--------------------------------------------------------------------------=
// Sets message's security context from current security context.
//
// Parameters:
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::AttachCurrentSecurityContext()
{
//
// pass binSenderCert property if set otherwise
// use default cert
//
return E_NOTIMPL;
#if 0
#if DEBUG
if (m_cbSenderCert) {
ASSERT(m_rgbSenderCert, L"should have sender cert buffer.");
}
#endif // DEBUG
return MQGetSecurityContext(
m_rgbSenderCert,
m_cbSenderCert,
(HANDLE *)&m_lSecurityContext);
#endif // 0
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_MaxTimeToReachQueue
//=--------------------------------------------------------------------------=
// Gets message's lifetime
//
// Parameters:
// plMaxTimeToReachQueue - [out] message's lifetime
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_MaxTimeToReachQueue(long FAR* plMaxTimeToReachQueue)
{
*plMaxTimeToReachQueue = m_lMaxTimeToReachQueue;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_MaxTimeToReachQueue
//=--------------------------------------------------------------------------=
// Sets message's lifetime
//
// Parameters:
// lMaxTimeToReachQueue - [in] message's lifetime
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_MaxTimeToReachQueue(long lMaxTimeToReachQueue)
{
EnterCriticalSection(&m_CSlocal);
m_lMaxTimeToReachQueue = lMaxTimeToReachQueue;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::get_MaxTimeToReceive
//=--------------------------------------------------------------------------=
// Gets message's lifetime
//
// Parameters:
// plMaxTimeToReceive - [out] message's lifetime
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::get_MaxTimeToReceive(long FAR* plMaxTimeToReceive)
{
*plMaxTimeToReceive = m_lMaxTimeToReceive;
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::put_MaxTimeToReceive
//=--------------------------------------------------------------------------=
// Sets message's lifetime
//
// Parameters:
// lMaxTimeToReceive - [in] message's lifetime
//
// Output:
//
// Notes:
//
HRESULT CMSMQMessage::put_MaxTimeToReceive(long lMaxTimeToReceive)
{
EnterCriticalSection(&m_CSlocal);
m_lMaxTimeToReceive = lMaxTimeToReceive;
LeaveCriticalSection(&m_CSlocal);
return NOERROR;
}
//=--------------------------------------------------------------------------=
// CMSMQMessage::GetVarBody
//=--------------------------------------------------------------------------=
// Gets message body
//
// Parameters:
// pvarBody - [out] pointer to message body variant
//
// Output:
//
// Notes:
// Supports intrinsic variant types
//
HRESULT CMSMQMessage::GetVarBody(VARIANT FAR* pvarBody)
{
VARTYPE vt = m_vtBody;
WCHAR *wszTmp = NULL;
UINT cchBody;
HRESULT hresult = NOERROR;
//
// UNDONE: VT_BYREF?
//
switch (vt) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -