1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
4 // Copyright (C) 2011-2013 Sven Strickroth <email@cs-ware.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 CSendMailPatch::CSendMailPatch(CString
&To
, CString
&CC
, CString
&subject
, bool bAttachment
, bool bCombine
, bool useMAPI
)
25 : CSendMailCombineable(To
, CC
, subject
, bAttachment
, bCombine
, useMAPI
)
29 CSendMailPatch::~CSendMailPatch()
33 int CSendMailPatch::SendAsSingleMail(CTGitPath
&path
, CGitProgressList
* instance
)
37 CString
pathfile(path
.GetWinPathString());
39 if (patch
.Parse(pathfile
))
41 instance
->ReportError(_T("Could not open/parse ") + pathfile
);
46 CStringArray attachments
;
48 attachments
.Add(pathfile
);
50 body
= patch
.m_strBody
;
52 return SendMail(path
, instance
, m_sSenderName
, m_sSenderMail
, m_sTo
, m_sCC
, patch
.m_Subject
, body
, attachments
, m_bUseMAPI
);
55 int CSendMailPatch::SendAsCombinedMail(CTGitPathList
&list
, CGitProgressList
* instance
)
59 CStringArray attachments
;
61 for (int i
= 0; i
< list
.GetCount(); ++i
)
64 if (patch
.Parse((CString
&)list
[i
].GetWinPathString()))
66 instance
->ReportError(_T("Could not open/parse ") + list
[i
].GetWinPathString());
71 attachments
.Add(list
[i
].GetWinPathString());
72 body
+= patch
.m_Subject
;
76 g_Git
.StringAppend(&body
, (BYTE
*)patch
.m_Body
.GetBuffer(), CP_UTF8
, patch
.m_Body
.GetLength());
78 return SendMail(CTGitPath(), instance
, m_sSenderName
, m_sSenderMail
, m_sTo
, m_sCC
, m_sSubject
, body
, attachments
, m_bUseMAPI
);
89 int CPatch::Parse(CString
&pathfile
)
93 m_PathFile
= pathfile
;
97 if (!PatchFile
.Open(m_PathFile
, CFile::modeRead
))
104 PatchFile
.ReadString(str
);
106 this->m_Author
=str
.Right( str
.GetLength() - 6 );
108 this->m_Date
= str
.Right( str
.GetLength() - 6 );
110 this->m_Subject
= str
.Right( str
.GetLength() - 8 );
115 LONGLONG offset
=PatchFile
.GetPosition();
117 PatchFile
.Read(m_Body
.GetBuffer((UINT
)PatchFile
.GetLength()), (UINT
)PatchFile
.GetLength());
118 m_Body
.ReleaseBuffer();
123 one
=m_Body
.Tokenize("\n",start
);
125 one
=m_Body
.Tokenize("\n",start
);
126 if(one
.GetLength()>6)
127 g_Git
.StringAppend(&m_Author
, (BYTE
*)one
.GetBuffer() + 6, CP_UTF8
, one
.GetLength() - 6);
129 one
=m_Body
.Tokenize("\n",start
);
130 if(one
.GetLength()>6)
131 g_Git
.StringAppend(&m_Date
, (BYTE
*)one
.GetBuffer() + 6, CP_UTF8
, one
.GetLength() - 6);
133 one
=m_Body
.Tokenize("\n",start
);
134 if(one
.GetLength()>9)
135 g_Git
.StringAppend(&m_Subject
, (BYTE
*)one
.GetBuffer() + 9, CP_UTF8
, one
.GetLength() - 9);
137 //one=m_Body.Tokenize("\n",start);
139 g_Git
.StringAppend(&m_strBody
, (BYTE
*)m_Body
.GetBuffer() + start
+ 1, CP_UTF8
, m_Body
.GetLength() - start
- 1);