Skip to content

Commit

Permalink
Added option to create inline images on the fly. Enhanced mail header…
Browse files Browse the repository at this point in the history
… fields decoder according to RFC 2047..
  • Loading branch information
zigm committed Jul 31, 2019
1 parent 84210a6 commit 8d98a9b
Show file tree
Hide file tree
Showing 18 changed files with 1,118 additions and 333 deletions.
7 changes: 7 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Changes
---

v 1.0.3.3

- To improve mboxview, please post reviews on what works, what doesn't, create bug tickets and enhancment requests;
- Added an option to create inline image cache on the fly to reduce initial startup time;
- Enhanced mail header field decoder according to RFC 2047 to resolve occasional text display issues;
- Updated User Manual to describe new and updated features;

v 1.0.3.2

- To improve mboxview, please post reviews on what works, what doesn't, create bug tickets and enhancment requests;
Expand Down
7 changes: 7 additions & 0 deletions ReadMe.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ Features
Changes
---

v 1.0.3.3

- To improve mboxview, please post reviews on what works, what doesn't, create bug tickets and enhancment requests;
- Added an option to create inline image cache on the fly to reduce initial startup time;
- Enhanced mail header field decoder according to RFC 2047 to resolve occasional text display issues;
- Updated User Manual to describe new and updated features;

v 1.0.3.2

- To improve mboxview, please post reviews on what works, what doesn't, create bug tickets and enhancment requests;
Expand Down
Binary file modified UserGuide.odt
Binary file not shown.
Binary file modified UserGuide.pdf
Binary file not shown.
42 changes: 22 additions & 20 deletions src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ void CMainFrame::OnFileOptions()
}
void CMainFrame::OnFileOpen()
{
int paneId = 0;
CString sText;
sText.Format("Opening new folder with mails ...");
SetStatusBarPaneText(paneId, sText);

if (m_bEnhancedSelectFolderDlg == FALSE)
{
Expand Down Expand Up @@ -470,6 +474,9 @@ void CMainFrame::OnFileOpen()
int deb = 1;
}
#endif

sText.Format("Ready");
SetStatusBarPaneText(paneId, sText);
}

void CMainFrame::DoOpen(CString& path)
Expand Down Expand Up @@ -1006,14 +1013,21 @@ void CMainFrame::OnUpdateBydate(CCmdUI *pCmdUI)
pCmdUI->Enable(MboxMail::s_mails.GetSize() > 0);
}


void CMainFrame::OnByfrom()
void CMainFrame::SortByColumn(int column)
{
// TODO: Add your command handler code here
NListView *pListView = 0;
pListView = GetListView();
if (pListView)
pListView->SortByColumn(2);
{
pListView->SortByColumn(column);
}
}


void CMainFrame::OnByfrom()
{
// TODO: Add your command handler code here
SortByColumn(2);
}


Expand All @@ -1027,10 +1041,7 @@ void CMainFrame::OnUpdateByfrom(CCmdUI *pCmdUI)
void CMainFrame::OnByto()
{
// TODO: Add your command handler code here
NListView *pListView = 0;
pListView = GetListView();
if (pListView)
pListView->SortByColumn(3);
SortByColumn(3);
}


Expand All @@ -1044,10 +1055,7 @@ void CMainFrame::OnUpdateByto(CCmdUI *pCmdUI)
void CMainFrame::OnBysubject()
{
// TODO: Add your command handler code here
NListView *pListView = 0;
pListView = GetListView();
if (pListView)
pListView->SortByColumn(4);
SortByColumn(4);
}


Expand All @@ -1061,10 +1069,7 @@ void CMainFrame::OnUpdateBysubject(CCmdUI *pCmdUI)
void CMainFrame::OnBysize()
{
// TODO: Add your command handler code here
NListView *pListView = 0;
pListView = GetListView();
if (pListView)
pListView->SortByColumn(5);
SortByColumn(5);
}


Expand All @@ -1078,10 +1083,7 @@ void CMainFrame::OnUpdateBysize(CCmdUI *pCmdUI)
void CMainFrame::OnByconversation()
{
// TODO: Add your command handler code here
NListView *pListView = 0;
pListView = GetListView();
if (pListView)
pListView->SortByColumn(0);
SortByColumn(0);
}


Expand Down
1 change: 1 addition & 0 deletions src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class CMainFrame : public CFrameWnd
static int CountMailFilesInFolder(CString &folder, CString &extension);

void SetStatusBarPaneText(int paneId, CString &sText);
void SortByColumn(int column);

#ifdef _DEBUG
virtual void AssertValid() const;
Expand Down
63 changes: 51 additions & 12 deletions src/MboxMail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ int MboxMail::m_nextGroupId = 0;

SimpleString* MboxMail::m_outbuf = new SimpleString(10000);
SimpleString* MboxMail::m_inbuf = new SimpleString(10000);
SimpleString* MboxMail::m_outdata = new SimpleString(10000);
SimpleString* MboxMail::m_indata = new SimpleString(10000);
SimpleString* MboxMail::m_workbuf = new SimpleString(10000);
SimpleString* MboxMail::m_tmpbuf = new SimpleString(10000);

Expand Down Expand Up @@ -1854,11 +1856,20 @@ int GetParamValue(CString &fieldLine, int startPos, const char *param, int param
return 1;
}

char *strchar(char *beg, char *end, char c)
{
while ((beg < end) && (*beg != c)) { beg++; };
if (beg < end)
return beg;
else
return 0;
}

char *strnstrUpper2Lower(char *any, char *end, const char *lower, int lowerlength)
{
// TODO: not very efficient; optimize
char *p;
for (p = any; p < (end - lowerlength) ; p++)
for (p = any; p <= (end - lowerlength) ; p++)
{
if (strncmpUpper2Lower(p, end, lower, lowerlength) == 0)
return p;
Expand Down Expand Up @@ -4404,6 +4415,9 @@ int MboxMail::printMailArchiveToTextFile(TEXTFILE_CONFIG &textConfig, CString &t
if (progressBar && MboxMail::pCUPDUPData)
MboxMail::pCUPDUPData->SetProgress((UINT_PTR)curstep);

int cnt = lastMail - firstMail;
if (cnt <= 0)
cnt = 1;
for (int i = firstMail; i <= lastMail; i++)
{
if (textType == 0) {
Expand Down Expand Up @@ -4432,6 +4446,20 @@ int MboxMail::printMailArchiveToTextFile(TEXTFILE_CONFIG &textConfig, CString &t
int deb = 1;
break;
}

CString fileNum;
int nFileNum = (i + 1);
int stepSize = 100;
if (textType == 0)
stepSize = 1000;

if ((nFileNum % stepSize) == 0) {
if (textType == 0)
fileNum.Format(_T("Printing mails to single TEXT file ... %d of %d"), nFileNum, cnt);
else
fileNum.Format(_T("Printing mails to single HTML file ... %d of %d"), nFileNum, cnt);
if (MboxMail::pCUPDUPData) MboxMail::pCUPDUPData->SetProgress(fileNum, (UINT_PTR)(newstep));
}
}
}

Expand Down Expand Up @@ -4682,8 +4710,8 @@ int MboxMail::DecodeBody(CFile &fpm, MailBodyContent *body, int mailPosition, Si
MboxMail *m = MboxMail::s_mails[mailPosition];

// We are using global buffers so check and assert if we collide.
SimpleString *inbuf = MboxMail::m_inbuf;
SimpleString *workbuf = MboxMail::m_workbuf;
SimpleString *inbuf = MboxMail::m_indata;
SimpleString *workbuf = MboxMail::m_outdata;
ASSERT(outbuf != inbuf);
ASSERT(outbuf != workbuf);

Expand Down Expand Up @@ -6120,6 +6148,8 @@ void MboxMail::ReleaseResources()
delete MboxMail::m_outbuf;
delete MboxMail::m_workbuf;
delete MboxMail::m_tmpbuf;
delete MboxMail::m_indata;
delete MboxMail::m_outdata;
delete MailBody::m_mpool;
delete m_pMessageIdTable;
delete m_pMboxMailTable;
Expand Down Expand Up @@ -7434,6 +7464,10 @@ int MboxMail::PrintMailRangeToSingleTextFile_WorkerThread(TEXTFILE_CONFIG &textC
}
}

int cnt = lastMail - firstMail;
if (cnt <= 0)
cnt = 0;

for (int i = firstMail; i <= lastMail; i++)
{
if (textType == 0)
Expand Down Expand Up @@ -7462,15 +7496,19 @@ int MboxMail::PrintMailRangeToSingleTextFile_WorkerThread(TEXTFILE_CONFIG &textC
curstep = newstep;
}

#if 0
CString fileNum;
int nFileNum = (i + 1);
int stepSize = 100;
if (textType == 0)
fileNum.Format(_T("Printing mails to TEXT file ... %d"), nFileNum);
else
fileNum.Format(_T("Printing mails to HTML file ... %d"), nFileNum);
if (MboxMail::pCUPDUPData) MboxMail::pCUPDUPData->SetProgress(fileNum, (UINT_PTR)(newstep));
#endif
stepSize = 1000;

if ((nFileNum % stepSize) == 0) {
if (textType == 0)
fileNum.Format(_T("Printing mails to single TEXT file ... %d of %d"), nFileNum, cnt);
else
fileNum.Format(_T("Printing mails to single HTML file ... %d of %d"), nFileNum, cnt);
if (MboxMail::pCUPDUPData) MboxMail::pCUPDUPData->SetProgress(fileNum, (UINT_PTR)(newstep));
}
}
}

Expand Down Expand Up @@ -7571,9 +7609,9 @@ int MboxMail::PrintMailSelectedToSingleTextFile_WorkerThread(TEXTFILE_CONFIG &te
if (MboxMail::pCUPDUPData) MboxMail::pCUPDUPData->SetProgress((UINT_PTR)(newstep));
curstep = newstep;
}
#if 0
#if 1
int nFileNum = (j + 1);
if ((nFileNum % 10) == 0) {
if ((nFileNum % 100) == 0) {
if (textType == 0)
fileNum.Format(_T("Printing mails to single TEXT file ... %d of %d"), nFileNum, cnt);
else
Expand All @@ -7586,7 +7624,7 @@ int MboxMail::PrintMailSelectedToSingleTextFile_WorkerThread(TEXTFILE_CONFIG &te

newstep = 100;
if (MboxMail::pCUPDUPData) MboxMail::pCUPDUPData->SetProgress((UINT_PTR)(newstep));
#if 0
#if 1
int nFileNum = cnt;
if (textType == 0)
fileNum.Format(_T("Printing mails to single TEXT file ... %d of %d"), nFileNum, cnt);
Expand Down Expand Up @@ -7847,3 +7885,4 @@ void ShowMemStatus()




5 changes: 4 additions & 1 deletion src/MboxMail.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ class MboxMail
// Tricky to use to avoid ownership conflict when two function on stack use the same buffer; Asking for trouble :)
static SimpleString *m_outbuf;
static SimpleString *m_inbuf;
static SimpleString *m_outdata;
static SimpleString *m_indata;
static SimpleString *m_workbuf;
static SimpleString *m_tmpbuf;

Expand Down Expand Up @@ -454,8 +456,9 @@ class MboxMail
static bool GetPrintCachePath(CString &rootPrintSubFolder, CString &targetPrintSubFolder, CString &prtCachePath, CString &errorText);
static void MakeValidFileName(CString &name);
static void MakeValidFileName(SimpleString &name);


//

static void ReleaseResources();
static void assert_unexpected();
};
Expand Down
47 changes: 44 additions & 3 deletions src/MimeCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,53 @@ int CMimeCodeQP::Decode(unsigned char* pbOutput, int nMaxSize)
unsigned char* pbOutStart = pbOutput;
unsigned char* pbOutEnd = pbOutput + nMaxSize;

while (pbData < pbEnd)
if (m_bEncodedWord == false)
{
while (pbData < pbEnd)
{
if (pbOutput >= pbOutEnd)
break;

unsigned char ch = *pbData++;
if (ch == '=')
{
if (pbData + 2 > pbEnd)
break; // invalid endcoding
ch = *pbData++;
//if (CMimeChar::IsHexDigit(toupper(ch)) && !CMimeChar::IsHexDigit(ch))
//int deb = 1;
// Mime protocol says as below but Thunderbird relax the rule to if (CMimeChar::IsHexDigit(toupper(ch)))
if (CMimeChar::IsHexDigit(ch))
{
ch -= ch > '9' ? 0x37 : '0';
*pbOutput = ch << 4;
ch = *pbData++;
ch -= ch > '9' ? 0x37 : '0';
*pbOutput++ |= ch & 0x0f;
}
else if (ch == '\r' && *pbData == '\n')
pbData++; // Soft Line Break, eat it
else if (ch == '\n')
int deb = 1; // Soft Line Break
else // invalid endcoding, let it go
*pbOutput++ = ch;
}
else// if (ch != '\r' && ch != '\n')
*pbOutput++ = ch;
}
}
else while (pbData < pbEnd)
{
if (pbOutput >= pbOutEnd)
break;

unsigned char ch = *pbData++;
if (ch == '=')
{
if (pbData+2 > pbEnd)
if (pbData + 2 > pbEnd)
break; // invalid endcoding
ch = *pbData++;
if (CMimeChar::IsHexDigit(ch))
if (CMimeChar::IsHexDigit(toupper(ch)))
{
ch -= ch > '9' ? 0x37 : '0';
*pbOutput = ch << 4;
Expand All @@ -380,6 +415,10 @@ int CMimeCodeQP::Decode(unsigned char* pbOutput, int nMaxSize)
else // invalid endcoding, let it go
*pbOutput++ = ch;
}
else if (ch == '_')
{
*pbOutput++ = ' ';
}
else// if (ch != '\r' && ch != '\n')
*pbOutput++ = ch;
}
Expand Down Expand Up @@ -533,6 +572,7 @@ int CMimeEncodedWord::GetEncodeLength() const
CMimeCodeQP qp;
qp.SetInput((const char*)m_pbInput, m_nInputSize, true);
qp.QuoteLineBreak(false);
qp.SetEncodedWord(true);
nLength = qp.GetOutputLength();
}

Expand Down Expand Up @@ -595,6 +635,7 @@ int CMimeEncodedWord::Decode(unsigned char* pbOutput, int nMaxSize)
{
CMimeCodeQP qp;
qp.SetInput(pszHeaderEnd, nCodeLen, false);
qp.SetEncodedWord(true);
nDecoded = qp.GetOutput(pbOutput, nMaxSize);
}
else
Expand Down
Loading

0 comments on commit 8d98a9b

Please sign in to comment.