// STKMsgAttachmentRow.cpp : implementation file // #include "stdafx.h" #include "mbamdb.h" #include "STKMsgAttachmentRow.h" #include "Msg.h" // STKMsgAttachmentRow CSTKMsgAttachmentRow::CSTKMsgAttachmentRow() { m_pCursor = NULL; m_pAConnect = NULL; } CSTKMsgAttachmentRow::~CSTKMsgAttachmentRow() { } // STKMsgAttachmentRow member functions void CSTKMsgAttachmentRow::operator = ( const CSTKMsgAttachmentRow &Item ) { m_pCursor = Item.m_pCursor; m_pAConnect = Item.m_pAConnect; } bool CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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 CSTKMsgAttachmentRow::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; }