5 #include "unicodeutils.h"
21 void CPatch::ConvertToArray(CString
&to
,CStringArray
&Array
)
26 CString str
=to
.Tokenize(_T(";"),start
);
32 int CPatch::Send(CString
&pathfile
,CString
&TO
,CString
&CC
,bool bAttachment
)
35 if(this->Parser(pathfile
) )
38 CStringArray attachments
,CCArray
;
41 attachments
.Add(pathfile
);
44 //ConvertToArray(CC,CCArray);
47 sender
.Format(_T("%s <%s> "),g_Git
.GetUserName(),g_Git
.GetUserEmail());
49 if(mail
.SendSpeedEmail(this->m_Author
,TO
,this->m_Subject
,this->m_strBody
,NULL
,&attachments
,CC
,25,sender
))
53 this->m_LastError
=mail
.GetLastErrorText();
57 CRegString
server(REG_SMTP_SERVER
);
58 CRegDWORD
port(REG_SMTP_PORT
,25);
59 CRegDWORD
bAuth(REG_SMTP_ISAUTH
);
60 CRegString
user(REG_SMTP_USER
);
61 CRegString
password(REG_SMTP_PASSWORD
);
63 mail
.SetSMTPServer(CUnicodeUtils::GetUTF8(server
),port
);
65 AddRecipient(mail
,TO
,false);
66 AddRecipient(mail
,CC
,true);
69 mail
.AddAttachment(CUnicodeUtils::GetUTF8(pathfile
));
72 GetNameAddress(this->m_Author
,name
,address
);
73 mail
.SetSenderName(CUnicodeUtils::GetUTF8(name
));
74 mail
.SetSenderMail(CUnicodeUtils::GetUTF8(address
));
76 mail
.SetXPriority(XPRIORITY_NORMAL
);
77 mail
.SetXMailer("The Bat! (v3.02) Professional");
79 mail
.SetSubject(CUnicodeUtils::GetUTF8(this->m_Subject
));
81 mail
.SetMessageBody((char*)&this->m_Body
[0]);
85 mail
.SetLogin(CUnicodeUtils::GetUTF8((CString
&)user
));
86 mail
.SetPassword(CUnicodeUtils::GetUTF8((CString
&)password
));
94 int CPatch::Send(CTGitPathList
&list
,CString
&To
,CString
&CC
, CString
&subject
,bool bAttachment
,CString
*errortext
)
96 CStringArray attachments
;
98 for(int i
=0;i
<list
.GetCount();i
++)
101 patch
.Parser((CString
&)list
[i
].GetWinPathString());
104 attachments
.Add(list
[i
].GetWinPathString());
105 body
+=patch
.m_Subject
;
110 g_Git
.StringAppend(&body
,(BYTE
*)patch
.m_Body
.GetBuffer(),CP_ACP
,patch
.m_Body
.GetLength());
118 sender
.Format(_T("%s <%s> "),g_Git
.GetUserName(),g_Git
.GetUserEmail());
120 if(mail
.SendSpeedEmail(sender
,To
,subject
,body
,NULL
,&attachments
,CC
,25,sender
))
125 *errortext
=mail
.GetLastErrorText();
131 int CPatch::Parser(CString
&pathfile
)
138 if( ! PatchFile
.Open(pathfile
,CFile::modeRead
) )
144 { PatchFile
.ReadString(str
);
146 this->m_Author
=str
.Right( str
.GetLength() - 6 );
148 this->m_Date
= str
.Right( str
.GetLength() - 6 );
150 this->m_Subject
= str
.Right( str
.GetLength() - 8 );
155 LONGLONG offset
=PatchFile
.GetPosition();
157 PatchFile
.Read(m_Body
.GetBuffer(PatchFile
.GetLength()),PatchFile
.GetLength());
158 m_Body
.ReleaseBuffer();
163 one
=m_Body
.Tokenize("\n",start
);
165 one
=m_Body
.Tokenize("\n",start
);
166 if(one
.GetLength()>6)
167 g_Git
.StringAppend(&m_Author
,(BYTE
*)one
.GetBuffer()+6,CP_ACP
,one
.GetLength()-6);
169 one
=m_Body
.Tokenize("\n",start
);
170 if(one
.GetLength()>6)
171 g_Git
.StringAppend(&m_Date
,(BYTE
*)one
.GetBuffer()+6,CP_ACP
,one
.GetLength()-6);
173 one
=m_Body
.Tokenize("\n",start
);
174 if(one
.GetLength()>8)
175 g_Git
.StringAppend(&m_Subject
,(BYTE
*)one
.GetBuffer()+8,CP_ACP
,one
.GetLength()-8);
177 //one=m_Body.Tokenize("\n",start);
179 g_Git
.StringAppend(&m_strBody
,(BYTE
*)m_Body
.GetBuffer()+start
+1,CP_ACP
,m_Body
.GetLength()-start
-1);
184 void CPatch::GetNameAddress(CString
&in
, CString
&name
,CString
&address
)
187 start
=in
.Find(_T('<'));
188 end
=in
.Find(_T('>'));
190 if(start
>=0 && end
>=0)
193 address
=in
.Mid(start
+1,end
-start
-1);
199 void CPatch::AddRecipient(CSmtp
&mail
, CString
&tolist
, bool isCC
)
204 CString one
=tolist
.Tokenize(_T(";"),pos
);
205 int start
=one
.Find(_T('<'));
206 int end
= one
.Find(_T('>'));
209 if( start
>=0 && end
>=0)
211 name
=CUnicodeUtils::GetUTF8(one
.Left(start
));
212 address
=CUnicodeUtils::GetUTF8(one
.Mid(start
+1,end
-start
-1));
213 if(address
.IsEmpty())
216 mail
.AddCCRecipient(address
,name
);
218 mail
.AddRecipient(address
,name
);
225 mail
.AddCCRecipient(CUnicodeUtils::GetUTF8(one
));
227 mail
.AddRecipient(CUnicodeUtils::GetUTF8(one
));