[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdebase/kioslave/smtp
From: Dirk Mueller <mueller () kde ! org>
Date: 2004-10-24 20:01:44
Message-ID: 20041024200144.0EB5E16C43 () office ! kde ! org
[Download RAW message or body]
CVS commit by mueller:
automoc-ify
A interactivesmtpserver.h 1.1 [GPL (+Qt exception)]
M +1 -7 Makefile.am 1.27
M +20 -86 interactivesmtpserver.cc 1.3
--- kdebase/kioslave/smtp/Makefile.am #1.26:1.27
@@ -32,11 +32,5 @@
interactivesmtpserver_LDADD = $(LIB_QT)
interactivesmtpserver_LDFLAGS = $(all_libraries)
-
-interactivesmtpserver.o: interactivesmtpserver.moc
-
-interactivesmtpserver.moc: $(srcdir)/interactivesmtpserver.cc
- $(MOC) -i $< -o $@
-
-CLEANFILES = interactivesmtpserver.moc
+interactivesmtpserver_METASOURCES = AUTO
messages:
--- kdebase/kioslave/smtp/interactivesmtpserver.cc #1.2:1.3
@@ -48,37 +48,9 @@
#include <cassert>
-static const QHostAddress localhost( 0x7f000001 ); // 127.0.0.1
-
-static QString err2str( int err ) {
- switch ( err ) {
- case QSocket::ErrConnectionRefused: return "Connection refused";
- case QSocket::ErrHostNotFound: return "Host not found";
- case QSocket::ErrSocketRead: return "Failed to read from socket";
- default: return "Unknown error";
- }
-}
-
-static QString escape( QString s ) {
- return s
- .replace( '&', "&" )
- .replace( '>', ">" )
- .replace( '<', "<" )
- .replace( '"', """ )
- ;
-}
+#include "interactivesmtpserver.h"
-static QString trim( const QString & s ) {
- if ( s.endsWith( "\r\n" ) )
- return s.left( s.length() - 2 );
- if ( s.endsWith( "\r" ) || s.endsWith( "\n" ) )
- return s.left( s.length() - 1 );
- return s;
-}
+static const QHostAddress localhost( 0x7f000001 ); // 127.0.0.1
-class InteractiveSMTPServerWindow : public QWidget {
- Q_OBJECT
-public:
- InteractiveSMTPServerWindow( QSocket * socket, QWidget * parent=0, const char * name=0, WFlags f=0 );
- ~InteractiveSMTPServerWindow() {
+InteractiveSMTPServerWindow::~InteractiveSMTPServerWindow() {
if ( mSocket ) {
mSocket->close();
@@ -90,8 +62,8 @@ public:
mSocket = 0;
}
- }
+}
-public slots:
- void slotSendResponse() {
+void InteractiveSMTPServerWindow::slotSendResponse()
+{
const QString line = mLineEdit->text();
mLineEdit->clear();
@@ -99,48 +71,10 @@ public slots:
s << line + "\r\n";
slotDisplayServer( line );
- }
- void slotDisplayClient( const QString & s ) {
- mTextEdit->append( "C:" + escape(s) );
- }
- void slotDisplayServer( const QString & s ) {
- mTextEdit->append( "S:" + escape(s) );
- }
- void slotDisplayMeta( const QString & s ) {
- mTextEdit->append( "<font color=\"red\">" + escape(s) + "</font>" );
- }
- void slotReadyRead() {
- while ( mSocket->canReadLine() )
- slotDisplayClient( trim( mSocket->readLine() ) );
- }
- void slotError( int err ) {
- slotDisplayMeta( QString( "E: %1 (%2)" ).arg( err2str( err ) ).arg( err ) );
- }
- void slotConnectionClosed() {
- slotDisplayMeta( "Connection closed by peer" );
- }
- void slotCloseConnection() {
- mSocket->close();
- }
-private:
- QSocket * mSocket;
- QTextEdit * mTextEdit;
- QLineEdit * mLineEdit;
-};
-
-class InteractiveSMTPServer : public QServerSocket {
- Q_OBJECT
-public:
- InteractiveSMTPServer( QObject * parent=0 )
- : QServerSocket( localhost, 2525, 1, parent ) {}
- ~InteractiveSMTPServer() {}
+}
- /*! \reimp */
- void newConnection( int fd ) {
- QSocket * socket = new QSocket();
- socket->setSocket( fd );
- InteractiveSMTPServerWindow * w = new InteractiveSMTPServerWindow( socket );
- w->show();
- }
-};
+InteractiveSMTPServer::InteractiveSMTPServer( QObject* parent )
+ : QServerSocket( localhost, 2525, 1, parent )
+{
+}
int main( int argc, char * argv[] ) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic