From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/mail-example.html | 110 ++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'doc/html/mail-example.html') diff --git a/doc/html/mail-example.html b/doc/html/mail-example.html index 2dc1971ff..1598c1096 100644 --- a/doc/html/mail-example.html +++ b/doc/html/mail-example.html @@ -33,7 +33,7 @@ body { background: #ffffff; color: black; }

-

This example shows how to use the TQSocket class. The client can only be +

This example shows how to use the TQSocket class. The client can only be used to send mails. The interesting part is the implementation of the SMTP protocol.


@@ -51,24 +51,24 @@ SMTP protocol. #ifndef SMTP_H #define SMTP_H -#include <qobject.h> -#include <qstring.h> +#include <ntqobject.h> +#include <ntqstring.h> class TQSocket; class TQTextStream; class TQDns; -class Smtp : public TQObject +class Smtp : public TQObject { Q_OBJECT public: - Smtp( const TQString &from, const TQString &to, - const TQString &subject, const TQString &body ); + Smtp( const TQString &from, const TQString &to, + const TQString &subject, const TQString &body ); ~Smtp(); signals: - void status( const TQString & ); + void status( const TQString & ); private slots: void dnsLookupHelper(); @@ -86,14 +86,14 @@ private: Close }; - TQString message; - TQString from; - TQString rcpt; - TQSocket *socket; - TQTextStream * t; + TQString message; + TQString from; + TQString rcpt; + TQSocket *socket; + TQTextStream * t; int state; - TQString response; - TQDns * mxLookup; + TQString response; + TQDns * mxLookup; }; #endif @@ -113,37 +113,37 @@ private: #include "smtp.h" -#include <qtextstream.h> -#include <qsocket.h> -#include <qdns.h> -#include <qtimer.h> -#include <qapplication.h> -#include <qmessagebox.h> -#include <qregexp.h> +#include <ntqtextstream.h> +#include <ntqsocket.h> +#include <ntqdns.h> +#include <ntqtimer.h> +#include <ntqapplication.h> +#include <ntqmessagebox.h> +#include <ntqregexp.h> -Smtp::Smtp( const TQString &from, const TQString &to, - const TQString &subject, - const TQString &body ) +Smtp::Smtp( const TQString &from, const TQString &to, + const TQString &subject, + const TQString &body ) { - socket = new TQSocket( this ); - connect ( socket, SIGNAL( readyRead() ), + socket = new TQSocket( this ); + connect ( socket, SIGNAL( readyRead() ), this, SLOT( readyRead() ) ); - connect ( socket, SIGNAL( connected() ), + connect ( socket, SIGNAL( connected() ), this, SLOT( connected() ) ); - mxLookup = new TQDns( to.mid( to.find( '@' )+1 ), TQDns::Mx ); - connect( mxLookup, SIGNAL(resultsReady()), + mxLookup = new TQDns( to.mid( to.find( '@' )+1 ), TQDns::Mx ); + connect( mxLookup, SIGNAL(resultsReady()), this, SLOT(dnsLookupHelper()) ); - message = TQString::fromLatin1( "From: " ) + from + - TQString::fromLatin1( "\nTo: " ) + to + - TQString::fromLatin1( "\nSubject: " ) + subject + - TQString::fromLatin1( "\n\n" ) + body + "\n"; - message.replace( TQString::fromLatin1( "\n" ), - TQString::fromLatin1( "\r\n" ) ); - message.replace( TQString::fromLatin1( "\r\n.\r\n" ), - TQString::fromLatin1( "\r\n..\r\n" ) ); + message = TQString::fromLatin1( "From: " ) + from + + TQString::fromLatin1( "\nTo: " ) + to + + TQString::fromLatin1( "\nSubject: " ) + subject + + TQString::fromLatin1( "\n\n" ) + body + "\n"; + message.replace( TQString::fromLatin1( "\n" ), + TQString::fromLatin1( "\r\n" ) ); + message.replace( TQString::fromLatin1( "\r\n.\r\n" ), + TQString::fromLatin1( "\r\n..\r\n" ) ); this->from = from; rcpt = to; @@ -161,37 +161,37 @@ Smtp::~Smtp() void Smtp::dnsLookupHelper() { - TQValueList<TQDns::MailServer> s = mxLookup->mailServers(); - if ( s.isEmpty() ) { - if ( !mxLookup->isWorking() ) - emit status( tr( "Error in MX record lookup" ) ); + TQValueList<TQDns::MailServer> s = mxLookup->mailServers(); + if ( s.isEmpty() ) { + if ( !mxLookup->isWorking() ) + emit status( tr( "Error in MX record lookup" ) ); return; } - emit status( tr( "Connecting to %1" ).arg( s.first().name ) ); + emit status( tr( "Connecting to %1" ).arg( s.first().name ) ); - socket->connectToHost( s.first().name, 25 ); - t = new TQTextStream( socket ); + socket->connectToHost( s.first().name, 25 ); + t = new TQTextStream( socket ); } void Smtp::connected() { - emit status( tr( "Connected to %1" ).arg( socket->peerName() ) ); + emit status( tr( "Connected to %1" ).arg( socket->peerName() ) ); } void Smtp::readyRead() { // SMTP is line-oriented - if ( !socket->canReadLine() ) + if ( !socket->canReadLine() ) return; - TQString responseLine; + TQString responseLine; do { - responseLine = socket->readLine(); + responseLine = socket->readLine(); response += responseLine; - } while( socket->canReadLine() && responseLine[3] != ' ' ); - responseLine.truncate( 3 ); + } while( socket->canReadLine() && responseLine[3] != ' ' ); + responseLine.truncate( 3 ); if ( state == Init && responseLine[0] == '2' ) { // banner was okay, let's go on @@ -214,15 +214,15 @@ void Smtp::readyRead() *t << "TQUIT\r\n"; // here, we just close. state = Close; - emit status( tr( "Message sent" ) ); + emit status( tr( "Message sent" ) ); } else if ( state == Close ) { - deleteLater(); + deleteLater(); return; } else { // something broke. - TQMessageBox::warning( qApp->activeWindow(), - tr( "TQt Mail Example" ), - tr( "Unexpected reply from SMTP server:\n\n" ) + + TQMessageBox::warning( qApp->activeWindow(), + tr( "TQt Mail Example" ), + tr( "Unexpected reply from SMTP server:\n\n" ) + response ); state = Close; } -- cgit v1.2.1