summaryrefslogtreecommitdiffstats
path: root/tdeio
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-09-03 13:32:46 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-09-03 13:32:46 -0500
commit70bb9dde2a97b4e2b456e679a05c6f039c2c912f (patch)
tree13745d2cbc2fa077542e1ec3b3a5c0543cb938e8 /tdeio
parentc51a15f04a99ee4226b58a32d0b90402e1d84447 (diff)
downloadtdelibs-70bb9dde2a97b4e2b456e679a05c6f039c2c912f.tar.gz
tdelibs-70bb9dde2a97b4e2b456e679a05c6f039c2c912f.zip
Fix compiler warnings from ignored write return values
Diffstat (limited to 'tdeio')
-rw-r--r--tdeio/misc/tdesendbugmail/smtp.cpp230
1 files changed, 131 insertions, 99 deletions
diff --git a/tdeio/misc/tdesendbugmail/smtp.cpp b/tdeio/misc/tdesendbugmail/smtp.cpp
index d282782fc..470f24050 100644
--- a/tdeio/misc/tdesendbugmail/smtp.cpp
+++ b/tdeio/misc/tdesendbugmail/smtp.cpp
@@ -128,20 +128,22 @@ void SMTP::closeConnection(void)
void SMTP::sendMessage(void)
{
- if(!connected)
- connectTimerTick();
- if(state == FINISHED && connected){
- kdDebug() << "state was == FINISHED\n" << endl;
- finished = false;
- state = IN;
- writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
- write(sock->socket(), writeString.ascii(), writeString.length());
- }
- if(connected){
- kdDebug() << "enabling read on sock...\n" << endl;
- interactTimer.start(timeOut, true);
- sock->enableRead(true);
- }
+ if(!connected)
+ connectTimerTick();
+ if(state == FINISHED && connected){
+ kdDebug() << "state was == FINISHED\n" << endl;
+ finished = false;
+ state = IN;
+ writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ }
+ }
+ if(connected){
+ kdDebug() << "enabling read on sock...\n" << endl;
+ interactTimer.start(timeOut, true);
+ sock->enableRead(true);
+ }
}
#include <stdio.h>
@@ -246,91 +248,121 @@ void SMTP::socketClose(TDESocket *socket)
void SMTP::processLine(TQString *line)
{
- int i, stat;
- TQString tmpstr;
-
- i = line->find(' ');
- tmpstr = line->left(i);
- if(i > 3)
- kdDebug() << "warning: SMTP status code longer then 3 digits: " << tmpstr << endl;
- stat = tmpstr.toInt();
- serverState = (SMTPServerStatus)stat;
- lastState = state;
-
- kdDebug() << "smtp state: [" << stat << "][" << *line << "]" << endl;
-
- switch(stat){
- case GREET: //220
- state = IN;
- writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case GOODBYE: //221
- state = QUIT;
- break;
- case SUCCESSFUL://250
- switch(state){
- case IN:
- state = READY;
- writeString = TQString::fromLatin1("mail from: %1\r\n").arg(senderAddress);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case READY:
- state = SENTFROM;
- writeString = TQString::fromLatin1("rcpt to: %1\r\n").arg(recipientAddress);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case SENTFROM:
- state = SENTTO;
- writeString = TQString::fromLatin1("data\r\n");
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case DATA:
- state = FINISHED;
- finished = true;
- sock->enableRead(false);
- emit messageSent();
- break;
- default:
- state = CERROR;
- kdDebug() << "smtp error (state error): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(COMMAND);
- break;
- }
- break;
- case READYDATA: //354
- state = DATA;
- writeString = TQString::fromLatin1("Subject: %1\r\n").arg(messageSubject);
- writeString += messageHeader;
- writeString += "\r\n";
- writeString += messageBody;
- writeString += TQString::fromLatin1(".\r\n");
- kdDebug() << "out: " << writeString;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case ERROR: //501
- state = CERROR;
- kdDebug() << "smtp error (command error): [" << lastState << "]:[" << stat << "][" << *line << "]\n" << endl;
- socketClose(sock);
- emit error(COMMAND);
- break;
- case UNKNOWN: //550
- state = CERROR;
- kdDebug() << "smtp error (unknown user): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(UNKNOWNUSER);
- break;
- default:
- state = CERROR;
- kdDebug() << "unknown response: [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(UNKNOWNRESPONSE);
- }
+ int i, stat;
+ TQString tmpstr;
+
+ i = line->find(' ');
+ tmpstr = line->left(i);
+ if(i > 3)
+ kdDebug() << "warning: SMTP status code longer then 3 digits: " << tmpstr << endl;
+ stat = tmpstr.toInt();
+ serverState = (SMTPServerStatus)stat;
+ lastState = state;
+
+ kdDebug() << "smtp state: [" << stat << "][" << *line << "]" << endl;
+
+ switch(stat){
+ case GREET: //220
+ state = IN;
+ writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
+ kdDebug() << "out: " << writeString << endl;
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ state = CERROR;
+ kdDebug() << "smtp error (write failed)" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ }
+ break;
+ case GOODBYE: //221
+ state = QUIT;
+ break;
+ case SUCCESSFUL://250
+ switch(state) {
+ case IN:
+ state = READY;
+ writeString = TQString::fromLatin1("mail from: %1\r\n").arg(senderAddress);
+ kdDebug() << "out: " << writeString << endl;
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ state = CERROR;
+ kdDebug() << "smtp error (write failed)" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ }
+ break;
+ case READY:
+ state = SENTFROM;
+ writeString = TQString::fromLatin1("rcpt to: %1\r\n").arg(recipientAddress);
+ kdDebug() << "out: " << writeString << endl;
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ state = CERROR;
+ kdDebug() << "smtp error (write failed)" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ }
+ break;
+ case SENTFROM:
+ state = SENTTO;
+ writeString = TQString::fromLatin1("data\r\n");
+ kdDebug() << "out: " << writeString << endl;
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ state = CERROR;
+ kdDebug() << "smtp error (write failed)" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ }
+ break;
+ case DATA:
+ state = FINISHED;
+ finished = true;
+ sock->enableRead(false);
+ emit messageSent();
+ break;
+ default:
+ state = CERROR;
+ kdDebug() << "smtp error (state error): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ break;
+ }
+ break;
+ case READYDATA: //354
+ state = DATA;
+ writeString = TQString::fromLatin1("Subject: %1\r\n").arg(messageSubject);
+ writeString += messageHeader;
+ writeString += "\r\n";
+ writeString += messageBody;
+ writeString += TQString::fromLatin1(".\r\n");
+ kdDebug() << "out: " << writeString;
+ if (write(sock->socket(), writeString.ascii(), writeString.length()) < 0) {
+ // Error
+ state = CERROR;
+ kdDebug() << "smtp error (write failed)" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ }
+ break;
+ case ERROR: //501
+ state = CERROR;
+ kdDebug() << "smtp error (command error): [" << lastState << "]:[" << stat << "][" << *line << "]\n" << endl;
+ socketClose(sock);
+ emit error(COMMAND);
+ break;
+ case UNKNOWN: //550
+ state = CERROR;
+ kdDebug() << "smtp error (unknown user): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
+ socketClose(sock);
+ emit error(UNKNOWNUSER);
+ break;
+ default:
+ state = CERROR;
+ kdDebug() << "unknown response: [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
+ socketClose(sock);
+ emit error(UNKNOWNRESPONSE);
+ }
}
#include "smtp.moc"