#include "csmtp.h"\r
#include "registry.h"\r
#include "unicodeutils.h"\r
+#include "hwsmtp.h"\r
+#include "Windns.h"\r
+#include "Git.h"\r
\r
CPatch::CPatch()\r
{\r
\r
}\r
\r
-int CPatch::Send(CString &pathfile,CString &TO,CString &CC,bool bAttachment)\r
+void CPatch::ConvertToArray(CString &to,CStringArray &Array)\r
{\r
- CSmtp mail;\r
- \r
- if(mail.GetLastError() != CSMTP_NO_ERROR )\r
+ int start=0;\r
+ while(start>=0)\r
{\r
- return -1;\r
+ CString str=to.Tokenize(_T(";"),start);\r
+ if(!str.IsEmpty())\r
+ Array.Add(str);\r
}\r
- \r
+}\r
+\r
+int CPatch::Send(CString &pathfile,CString &TO,CString &CC,bool bAttachment)\r
+{\r
+ CHwSMTP mail;\r
if(this->Parser(pathfile) )\r
return -1;\r
\r
+ CStringArray attachments,CCArray;\r
+ if(bAttachment)\r
+ {\r
+ attachments.Add(pathfile);\r
+ }\r
+ \r
+ //ConvertToArray(CC,CCArray);\r
+\r
+ CString sender;\r
+ sender.Format(_T("%s <%s> "),g_Git.GetUserName(),g_Git.GetUserEmail());\r
\r
+ if(mail.SendSpeedEmail(this->m_Author,TO,this->m_Subject,this->m_strBody,NULL,&attachments,CC,25,sender))\r
+ return 0;\r
+ else\r
+ {\r
+ this->m_LastError=mail.GetLastErrorText();\r
+ return -1;\r
+ }\r
+#if 0\r
CRegString server(REG_SMTP_SERVER);\r
CRegDWORD port(REG_SMTP_PORT,25);\r
CRegDWORD bAuth(REG_SMTP_ISAUTH);\r
}\r
\r
return !mail.Send();\r
+#endif\r
+\r
+\r
+}\r
+int CPatch::Send(CTGitPathList &list,CString &To,CString &CC, CString &subject,bool bAttachment,CString *errortext)\r
+{\r
+ CStringArray attachments;\r
+ CString body;\r
+ for(int i=0;i<list.GetCount();i++)\r
+ {\r
+ CPatch patch;\r
+ patch.Parser((CString&)list[i].GetWinPathString());\r
+ if(bAttachment)\r
+ {\r
+ attachments.Add(list[i].GetWinPathString());\r
+ body+=patch.m_Subject;\r
+ body+=_T("\r\n");\r
+\r
+ }else\r
+ {\r
+ g_Git.StringAppend(&body,(BYTE*)patch.m_Body.GetBuffer(),CP_ACP,patch.m_Body.GetLength());\r
+ }\r
+\r
+ }\r
+\r
+ CHwSMTP mail;\r
+ \r
+ CString sender;\r
+ sender.Format(_T("%s <%s> "),g_Git.GetUserName(),g_Git.GetUserEmail());\r
+\r
+ if(mail.SendSpeedEmail(sender,To,subject,body,NULL,&attachments,CC,25,sender))\r
+ return 0;\r
+ else\r
+ {\r
+ if(errortext)\r
+ *errortext=mail.GetLastErrorText();\r
+ return -1;\r
+ }\r
\r
}\r
\r
{\r
CString str;\r
\r
- CStdioFile PatchFile;\r
+ CFile PatchFile;\r
\r
m_PathFile=pathfile;\r
if( ! PatchFile.Open(pathfile,CFile::modeRead) )\r
return -1;\r
\r
int i=0;\r
- while(PatchFile.ReadString(str))\r
- {\r
+#if 0\r
+ while(i<4)\r
+ { PatchFile.ReadString(str);\r
if(i==1)\r
this->m_Author=str.Right( str.GetLength() - 6 );\r
if(i==2)\r
this->m_Date = str.Right( str.GetLength() - 6 );\r
if(i==3)\r
this->m_Subject = str.Right( str.GetLength() - 8 );\r
- if(i==4)\r
- break;\r
+ \r
i++; \r
}\r
\r
- m_Body.resize(PatchFile.GetLength() - PatchFile.GetPosition());\r
- PatchFile.Read(&m_Body.at(0),PatchFile.GetLength() - PatchFile.GetPosition());\r
-\r
+ LONGLONG offset=PatchFile.GetPosition();\r
+#endif\r
+ PatchFile.Read(m_Body.GetBuffer(PatchFile.GetLength()),PatchFile.GetLength());\r
+ m_Body.ReleaseBuffer();\r
PatchFile.Close();\r
\r
+ int start=0;\r
+ CStringA one;\r
+ one=m_Body.Tokenize("\n",start);\r
+\r
+ one=m_Body.Tokenize("\n",start);\r
+ if(one.GetLength()>6)\r
+ g_Git.StringAppend(&m_Author,(BYTE*)one.GetBuffer()+6,CP_ACP,one.GetLength()-6);\r
+\r
+ one=m_Body.Tokenize("\n",start);\r
+ if(one.GetLength()>6)\r
+ g_Git.StringAppend(&m_Date,(BYTE*)one.GetBuffer()+6,CP_ACP,one.GetLength()-6);\r
+\r
+ one=m_Body.Tokenize("\n",start);\r
+ if(one.GetLength()>8)\r
+ g_Git.StringAppend(&m_Subject,(BYTE*)one.GetBuffer()+8,CP_ACP,one.GetLength()-8);\r
+\r
+ //one=m_Body.Tokenize("\n",start);\r
+ \r
+ g_Git.StringAppend(&m_strBody,(BYTE*)m_Body.GetBuffer()+start+1,CP_ACP,m_Body.GetLength()-start-1);\r
+ \r
+ return 0;\r
}\r
\r
void CPatch::GetNameAddress(CString &in, CString &name,CString &address)\r
else\r
address=in;\r
}\r
-\r
+#if 0\r
void CPatch::AddRecipient(CSmtp &mail, CString &tolist, bool isCC)\r
{\r
int pos=0;\r
mail.AddRecipient(CUnicodeUtils::GetUTF8(one));\r
}\r
}\r
-}
\ No newline at end of file
+}\r
+#endif
\ No newline at end of file