diff options
author | pixel <pixel> | 2007-10-15 13:47:12 +0000 |
---|---|---|
committer | pixel <pixel> | 2007-10-15 13:47:12 +0000 |
commit | 9c5c95217a11a36525ac25b546579fff1eace660 (patch) | |
tree | 26eb464fb3dd39dd5561d280f8ae82933697c239 | |
parent | 6ac96734fe74dd8b64535a10780e052dc9f77ce7 (diff) |
Various fixes for the MailClient.
-rw-r--r-- | lib/LuaTask.cc | 24 | ||||
-rw-r--r-- | lib/MailClient.cc | 20 | ||||
-rw-r--r-- | lib/SocketClient.cc | 8 |
3 files changed, 33 insertions, 19 deletions
diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index d25efda..f7497be 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaTask.cc,v 1.17 2007-10-12 15:18:26 pixel Exp $ */ +/* $Id: LuaTask.cc,v 1.18 2007-10-15 13:47:12 pixel Exp $ */ #include <LuaTask.h> #include <LuaHandle.h> @@ -201,23 +201,23 @@ int LuaTask::Do() throw (GeneralException) { String smtp, subject, from, body; MailClient::strings_t headers, tos, ccs, bccs, fakes; - if (L->gettop() != 9) { - L->error("Incorrect parameters to MailClient."); + if (L->gettop() != 10) { + L->error("Incorrect number of parameters to MailClient."); return TASK_DONE; } - smtp = L->tostring(1); - subject = L->tostring(2); - from = L->tostring(3); + smtp = L->tostring(2); + subject = L->tostring(3); + from = L->tostring(4); try { - headers = array_to_vector(4); - tos = array_to_vector(5); - ccs = array_to_vector(6); - bccs = array_to_vector(7); - fakes = array_to_vector(8); + headers = array_to_vector(5); + tos = array_to_vector(6); + ccs = array_to_vector(7); + bccs = array_to_vector(8); + fakes = array_to_vector(9); } catch (GeneralException e) { L->error("Incorrect parameters to MailClient."); } - body = L->tostring(9); + body = L->tostring(10); b = new Buffer(true); (*b) << body; diff --git a/lib/MailClient.cc b/lib/MailClient.cc index 380c878..8691f4f 100644 --- a/lib/MailClient.cc +++ b/lib/MailClient.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: MailClient.cc,v 1.1 2007-10-12 13:07:42 pixel Exp $ */ +/* $Id: MailClient.cc,v 1.2 2007-10-15 13:47:12 pixel Exp $ */ #include <TaskMan.h> #include <MailClient.h> @@ -145,7 +145,7 @@ String MailClient::getNext() { } } - return *(ptr++); + return getEmail(*(ptr++)); } int MailClient::Do() throw (GeneralException) { @@ -157,6 +157,7 @@ int MailClient::Do() throw (GeneralException) { switch (current) { case 0: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 1; Suspend(TASK_ON_HOLD); @@ -168,11 +169,13 @@ int MailClient::Do() throw (GeneralException) { b << "EHLO foobar\r\n"; WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 2; Suspend(TASK_ON_HOLD); case 2: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 3; Suspend(TASK_ON_HOLD); @@ -184,11 +187,13 @@ int MailClient::Do() throw (GeneralException) { b << "MAIL FROM: " << getEmail(from) << "\r\n"; WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 4; Suspend(TASK_ON_HOLD); case 4: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 5; Suspend(TASK_ON_HOLD); @@ -197,7 +202,7 @@ int MailClient::Do() throw (GeneralException) { if (cur_rcpt == RCPT_BEGIN) { status = "SMTP server rejected our MAIL FROM: " + msg; return TASK_DONE; - // } else { // SMTP server rejecter one RCPT TO, nevermind it. + // } else { // SMTP server rejected one RCPT TO, nevermind it. } } @@ -206,17 +211,20 @@ int MailClient::Do() throw (GeneralException) { if (cur_rcpt != RCPT_END) { b << "RCPT TO: " << n << "\r\n"; WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 4; Suspend(TASK_ON_HOLD); } b << "DATA\r\n"; WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 6; Suspend(TASK_ON_HOLD); case 6: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 7; Suspend(TASK_ON_HOLD); @@ -228,11 +236,13 @@ int MailClient::Do() throw (GeneralException) { writeEmail(&b); WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 8; Suspend(TASK_ON_HOLD); case 8: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 9; Suspend(TASK_ON_HOLD); @@ -242,13 +252,15 @@ int MailClient::Do() throw (GeneralException) { return TASK_DONE; } - b << "QUIT\n\r"; + b << "QUIT\r\n"; WaitFor(c = new CopyJob(&b, &s)); + WaitTimeout(); current = 10; Suspend(TASK_ON_HOLD); case 10: WaitFor(c = new ReadJob(&s, &b, final_line)); + WaitTimeout(); current = 11; Suspend(TASK_ON_HOLD); diff --git a/lib/SocketClient.cc b/lib/SocketClient.cc index a86629a..cc59014 100644 --- a/lib/SocketClient.cc +++ b/lib/SocketClient.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: SocketClient.cc,v 1.1 2007-10-12 13:07:42 pixel Exp $ */ +/* $Id: SocketClient.cc,v 1.2 2007-10-15 13:47:12 pixel Exp $ */ #include <TaskMan.h> #include <SocketClient.h> @@ -67,7 +67,6 @@ void SocketClient::subDo() throw (GeneralException) { } RemoveTimeout(); - WaitFor(timeout); return; default: @@ -82,7 +81,10 @@ void SocketClient::subDo() throw (GeneralException) { } RemoveTimeout(); - WaitFor(timeout); return; } } + +void SocketClient::WaitTimeout() { + WaitFor(timeout); +} |