// STKMsgRow.cpp : implementation file
|
//
|
|
#include "stdafx.h"
|
#include "mbamdb.h"
|
#include "STKMsgRow.h"
|
#include "Msg.h"
|
|
// STKMsgRow
|
|
CSTKMsgRow::CSTKMsgRow()
|
{
|
m_pCursor = NULL;
|
m_pAConnect = NULL;
|
}
|
|
CSTKMsgRow::~CSTKMsgRow()
|
{
|
}
|
|
|
// STKMsgRow member functions
|
|
void CSTKMsgRow::operator = ( const CSTKMsgRow &Item )
|
{
|
m_pCursor = Item.m_pCursor;
|
m_pAConnect = Item.m_pAConnect;
|
}
|
|
bool CSTKMsgRow::GetMsgID( CString &strMsgID )
|
{
|
strMsgID = _T("");
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strMsgID = ((CMsgs *)m_pCursor)->m_strID;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgSubject( CString &strSubject )
|
{
|
strSubject = _T( "" );
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strSubject = ((CMsgs *)m_pCursor)->m_strSubject;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetSender( CString &strName )
|
{
|
strName = _T( "" );
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strName = ((CMsgs *)m_pCursor)->m_strSender;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetSenderName( CString &strName )
|
{
|
strName = _T( "" );
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strName = ((CMsgs *)m_pCursor)->m_strSenderName;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetSendDate( CString &strSendDate )
|
{
|
strSendDate = _T( "" );
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
COleVariant variant;
|
COleDateTime tmSendDate;
|
|
((CMsgs *)m_pCursor)->GetItemValue( _T( "SendDate" ), variant );
|
tmSendDate = variant;
|
strSendDate = tmSendDate.Format( _T("%Y-%m-%d %H:%M:%S") );
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgContent( enum AMMSGCONTENTTYPE nContentType, CString &strMsgContent )
|
{
|
strMsgContent = _T( "" );
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
strMsgContent = ((CMsgs *)m_pCursor)->m_strContent;
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgOwnerCount( long &nCount )
|
{
|
nCount = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgOwners.GetSize();
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgOwner( long nIndex, CString &strLogin )
|
{
|
int nCount = 0;
|
|
strLogin = _T( "" );
|
|
if ( nIndex < 0 )
|
return false;
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgOwners.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgOwners msgOwners( m_pAConnect );
|
msgOwners.LoadData( ((CMsgs *)m_pCursor)->m_arMsgOwners[nIndex] );
|
|
strLogin = msgOwners.m_strOwner;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgOwnerName( long nIndex, CString &strName )
|
{
|
int nCount = 0;
|
|
strName = _T( "" );
|
|
if ( nIndex < 0 )
|
return false;
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgOwners.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgOwners msgOwners( m_pAConnect );
|
msgOwners.LoadData( ((CMsgs *)m_pCursor)->m_arMsgOwners[nIndex] );
|
|
strName = msgOwners.m_strOwnerName;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgOwnerRData( long nIndex, CString &strOpenDate )
|
{
|
int nCount = 0;
|
|
strOpenDate = _T( "" );
|
|
if ( nIndex < 0 )
|
return false;
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgOwners.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgOwners msgOwners( m_pAConnect );
|
msgOwners.LoadData( ((CMsgs *)m_pCursor)->m_arMsgOwners[nIndex] );
|
|
COleVariant variant;
|
COleDateTime tmOpenDate;
|
|
if ( !msgOwners.GetItemValue( _T( "OpenDate" ), variant ) )
|
return false;
|
|
tmOpenDate = variant;
|
strOpenDate = tmOpenDate.Format( _T("%Y-%m-%d %H:%M:%S") );
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttachCount( long &nCount )
|
{
|
nCount = 0;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_nAttachCount;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttachName( long nIndex, CString &strName )
|
{
|
int nCount = 0;
|
|
strName = _T( "" );
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
|
strName = msgAttachs.m_strFileName;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttachSize( long nIndex, __int64 &nSize )
|
{
|
int nCount = 0;
|
|
nSize = 0;
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
|
nSize = msgAttachs.m_nFileSize;
|
|
return true;
|
}
|
bool CSTKMsgRow::GetAttachFileID( long nIndex, CString &strFileID )
|
{
|
int nCount = 0;
|
|
strFileID = _T("");
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
|
strFileID = msgAttachs.m_strFileID;
|
|
return true;
|
}
|
bool CSTKMsgRow::GetAttachFileSFlag( long nIndex, CString &strFileSFlag )
|
{
|
int nCount = 0;
|
|
strFileSFlag = _T("");
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
|
strFileSFlag = msgAttachs.m_strFileSFlag;
|
|
return true;
|
}
|
bool CSTKMsgRow::GetAttachFilePath( long nIndex, CString &strFilePath )
|
{
|
int nCount = 0;
|
|
strFilePath = _T("");
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
|
strFilePath = msgAttachs.m_strFilePath;
|
|
return true;
|
}
|
bool CSTKMsgRow::GetAttachFileMD5( long nIndex, CString &strFileMD5 )
|
{
|
int nCount = 0;
|
|
strFileMD5 = _T("");
|
if ( nIndex < 0 )
|
return false;
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgAttachments.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgAttachments msgAttachs( m_pAConnect );
|
msgAttachs.LoadData( ((CMsgs *)m_pCursor)->m_arMsgAttachments[nIndex] );
|
strFileMD5 = msgAttachs.m_strFileMD5;
|
|
return true;
|
}
|
;
|
bool CSTKMsgRow::GetAttribCount( long &nCount )
|
{
|
nCount = 0;
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgPropertys msgProp( m_pAConnect );
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgPropertys.GetSize();
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttribName( long nIndex, CString &strName )
|
{
|
strName = _T("");
|
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
if ( nIndex < 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgPropertys msgProp( m_pAConnect );
|
|
int nCount;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgPropertys.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
msgProp.LoadData( ((CMsgs *)m_pCursor)->m_arMsgPropertys[nIndex] );
|
strName = msgProp.m_strName;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttribValue( long nIndex, CString &strValue )
|
{
|
strValue = _T("");
|
|
if ( !m_pAConnect )
|
return false;
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
if ( nIndex < 0 )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgPropertys msgProp( m_pAConnect );
|
|
int nCount;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgPropertys.GetSize();
|
if ( nIndex >= nCount )
|
return false;
|
if ( nCount == 0 )
|
return false;
|
|
msgProp.LoadData( ((CMsgs *)m_pCursor)->m_arMsgPropertys[nIndex] );
|
strValue = msgProp.m_strValue;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::IsNeedConfirm( long &bIsConfirm )
|
{
|
bIsConfirm = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
bIsConfirm = ((CMsgs *)m_pCursor)->m_nNeedConfirm;
|
|
return true;
|
}
|
bool CSTKMsgRow::IsGroupSend( long &bIsGroupSend )
|
{
|
bIsGroupSend = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
bIsGroupSend = ((CMsgs *)m_pCursor)->m_nIsGroupSend;
|
|
return true;
|
}
|
bool CSTKMsgRow::GetItemValue( CString strItemName, VARIANT &vData )
|
{
|
vData.vt = VT_EMPTY;
|
|
if ( !m_pCursor )
|
return false;
|
|
CString strName = strItemName;
|
if ( strName.IsEmpty() )
|
return false;
|
|
COleVariant varData;
|
if ( !m_pCursor->GetItemValue( strName, varData ) )
|
return false;
|
|
vData = varData;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetItemValueStr( CString strItemName, CString &strData )
|
{
|
strData = _T( "" );
|
|
if ( !m_pCursor )
|
return false;
|
|
CString strName = strItemName;
|
if ( strName.IsEmpty() )
|
return false;
|
|
if ( !m_pCursor->GetItemValue( strName, strData ) )
|
return false;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgContentType( enum AMMSGCONTENTTYPE &nContentType )
|
{
|
nContentType = AM_CONTENTTYPE_NONE;
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
CString strContentType = ((CMsgs *)m_pCursor)->m_strContentType;
|
if ( strContentType.CompareNoCase(CONTYPE_TEXT_PLAIN) == 0 )
|
nContentType = AM_CONTENTTYPE_MSG;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_TEXT) == 0 )
|
nContentType = AM_CONTENTTYPE_TEXT;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_AML) == 0 )
|
nContentType = AM_CONTENTTYPE_AML;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_PDM) == 0 )
|
nContentType = AM_CONTENTTYPE_PDM;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_HTML) == 0 )
|
nContentType = AM_CONTENTTYPE_HTML;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_URL) == 0 )
|
nContentType = AM_CONTENTTYPE_URL;
|
else if ( strContentType.CompareNoCase(CONTYPE_TEXT_XML) == 0 )
|
nContentType = AM_CONTENTTYPE_XML;
|
else
|
return false;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetSourceMsgID( CString &strMsgID )
|
{
|
strMsgID = _T("");
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strMsgID = ((CMsgs*)m_pCursor)->m_strSourceID;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::IsDownloaded( BOOL bAdvanced, BOOL &bReturn )
|
{
|
bReturn = false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
if( ((CMsgs *)m_pCursor)->m_nReadState & MSG_READSTATE_DOWNLOAD )
|
bReturn = true;
|
else
|
bReturn = false;
|
|
return true;
|
}
|
|
|
bool CSTKMsgRow::GetReadState( long &nReturn )
|
{
|
nReturn = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nReturn = ((CMsgs *)m_pCursor)->m_nReadState;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetAttitudeset( CString &strData )
|
{
|
strData = _T("");
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
strData = ((CMsgs *)m_pCursor)->m_strAttitudeset;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgType( long &nType )
|
{
|
nType = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nType = ((CMsgs *)m_pCursor)->m_nType;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetMsgFlag( long &nFlag )
|
{
|
nFlag = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nFlag = ((CMsgs *)m_pCursor)->m_nMsgFlag;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetCharSet( long &nCharset )
|
{
|
nCharset = 0;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
nCharset = ((CMsgs *)m_pCursor)->m_nCharset;
|
|
return true;
|
}
|
|
bool CSTKMsgRow::ParesReceiversInfo( CString strReceiversInfo, CStringArray &asLogin, CStringArray &asUserName )
|
{
|
asLogin.RemoveAll( );
|
asUserName.RemoveAll( );
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
CString strResult;
|
CString strTemp, strItem;
|
CString strReceiver;
|
CString strReceiverName;
|
|
while ( GetStrItem( strReceiversInfo, strItem, _T( "|" ) ) )
|
{
|
// Login Name
|
if ( !GetStrItem( strItem, strTemp, _T(";") ) )
|
return false;
|
strReceiver = strTemp;
|
// User Name
|
if ( !GetStrItem( strItem, strTemp, _T(";") ) )
|
return false;
|
strReceiverName = strTemp;
|
|
asLogin.Add( strReceiver );
|
asUserName.Add( strReceiverName );
|
}
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetStrItem( CString &strBuff, CString &strItem, CString strApart )
|
{
|
if ( strBuff.IsEmpty() || strApart.IsEmpty() )
|
return false;
|
|
int nPos = strBuff.Find( strApart );
|
if ( nPos == -1 )
|
{
|
strItem = strBuff;
|
strBuff.Empty();
|
}
|
else
|
{
|
strItem = strBuff.Left( nPos );
|
strBuff = strBuff.Mid( nPos + strApart.GetLength() );
|
}
|
|
return true;
|
}
|
|
bool CSTKMsgRow::GetProp( CString strDataName, CString &strDataValue )
|
{
|
strDataValue = _T("");
|
|
if ( !m_pAConnect )
|
return false;
|
|
if ( !m_pCursor || m_pCursor->m_nRowType != ROWTYPE_MSG )
|
return false;
|
|
m_pAConnect->AddRef();
|
CMsgPropertys msgProp( m_pAConnect );
|
|
int nNum, nCount;
|
CString strName, strValue;
|
|
nCount = ((CMsgs *)m_pCursor)->m_arMsgPropertys.GetSize();
|
for ( nNum = 0 ; nNum < nCount ; nNum++ )
|
{
|
msgProp.LoadData( ((CMsgs *)m_pCursor)->m_arMsgPropertys[nNum] );
|
|
strName = msgProp.m_strName;
|
if ( strName == strDataName )
|
{
|
strValue = msgProp.m_strValue;
|
strDataValue = strValue;
|
|
return true;
|
}
|
}
|
|
return false;
|
}
|