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