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/httpd-example.html | 84 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'doc/html/httpd-example.html') diff --git a/doc/html/httpd-example.html b/doc/html/httpd-example.html index 1c9bb8c17..aa923a156 100644 --- a/doc/html/httpd-example.html +++ b/doc/html/httpd-example.html @@ -33,7 +33,7 @@ body { background: #ffffff; color: black; }

-

This example shows how to use the TQServerSocket class. It is a very +

This example shows how to use the TQServerSocket class. It is a very simple implementation of a HTTP daemon that listens on port 8080 and sends back a simple HTML page back for every GET request it gets. After sending the page, it closes the connection. @@ -49,27 +49,27 @@ sending the page, it closes the connection. ** *****************************************************************************/ #include <stdlib.h> -#include <qsocket.h> -#include <qregexp.h> -#include <qserversocket.h> -#include <qapplication.h> -#include <qmainwindow.h> -#include <qtextstream.h> -#include <qvbox.h> -#include <qlabel.h> -#include <qtextview.h> -#include <qpushbutton.h> +#include <ntqsocket.h> +#include <ntqregexp.h> +#include <ntqserversocket.h> +#include <ntqapplication.h> +#include <ntqmainwindow.h> +#include <ntqtextstream.h> +#include <ntqvbox.h> +#include <ntqlabel.h> +#include <ntqtextview.h> +#include <ntqpushbutton.h> // HttpDaemon is the the class that implements the simple HTTP server. -class HttpDaemon : public TQServerSocket +class HttpDaemon : public TQServerSocket { Q_OBJECT public: - HttpDaemon( TQObject* parent=0 ) : - TQServerSocket(8080,1,parent) + HttpDaemon( TQObject* parent=0 ) : + TQServerSocket(8080,1,parent) { if ( !ok() ) { - qWarning("Failed to bind to port 8080"); + qWarning("Failed to bind to port 8080"); exit( 1 ); } } @@ -80,10 +80,10 @@ public: // communication with the client is done over this TQSocket. TQSocket // works asynchronouslyl, this means that all the communication is done // in the two slots readClient() and discardClient(). - TQSocket* s = new TQSocket( this ); - connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); - connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); - s->setSocket( socket ); + TQSocket* s = new TQSocket( this ); + connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); + connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); + s->setSocket( socket ); emit newConnect(); } @@ -98,24 +98,24 @@ private slots: // This slot is called when the client sent data to the server. The // server looks if it was a get request and sends a very simple HTML // document back. - TQSocket* socket = (TQSocket*)sender(); - if ( socket->canReadLine() ) { - TQStringList tokens = TQStringList::split( TQRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); + TQSocket* socket = (TQSocket*)sender(); + if ( socket->canReadLine() ) { + TQStringList tokens = TQStringList::split( TQRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); if ( tokens[0] == "GET" ) { - TQTextStream os( socket ); - os.setEncoding( TQTextStream::UnicodeUTF8 ); + TQTextStream os( socket ); + os.setEncoding( TQTextStream::UnicodeUTF8 ); os << "HTTP/1.0 200 Ok\r\n" "Content-Type: text/html; charset=\"utf-8\"\r\n" "\r\n" "<h1>Nothing to see here</h1>\n"; - socket->close(); + socket->close(); emit wroteToClient(); } } } void discardClient() { - TQSocket* socket = (TQSocket*)sender(); + TQSocket* socket = (TQSocket*)sender(); delete socket; emit endConnect(); } @@ -124,7 +124,7 @@ private slots: // HttpInfo provides a simple graphical user interface to the server and shows // the actions of the server. -class HttpInfo : public TQVBox +class HttpInfo : public TQVBox { Q_OBJECT public: @@ -132,20 +132,20 @@ public: { HttpDaemon *httpd = new HttpDaemon( this ); - TQString itext = TQString( + TQString itext = TQString( "This is a small httpd example.\n" "You can connect with your\n" "web browser to port %1" - ).arg( httpd->port() ); - TQLabel *lb = new TQLabel( itext, this ); - lb->setAlignment( AlignHCenter ); - infoText = new TQTextView( this ); - TQPushButton *quit = new TQPushButton( "quit" , this ); + ).arg( httpd->port() ); + TQLabel *lb = new TQLabel( itext, this ); + lb->setAlignment( AlignHCenter ); + infoText = new TQTextView( this ); + TQPushButton *quit = new TQPushButton( "quit" , this ); connect( httpd, SIGNAL(newConnect()), SLOT(newConnect()) ); connect( httpd, SIGNAL(endConnect()), SLOT(endConnect()) ); connect( httpd, SIGNAL(wroteToClient()), SLOT(wroteToClient()) ); - connect( quit, SIGNAL(pressed()), qApp, SLOT(quit()) ); + connect( quit, SIGNAL(pressed()), qApp, SLOT(quit()) ); } ~HttpInfo() @@ -155,29 +155,29 @@ public: private slots: void newConnect() { - infoText->append( "New connection" ); + infoText->append( "New connection" ); } void endConnect() { - infoText->append( "Connection closed\n\n" ); + infoText->append( "Connection closed\n\n" ); } void wroteToClient() { - infoText->append( "Wrote to client" ); + infoText->append( "Wrote to client" ); } private: - TQTextView *infoText; + TQTextView *infoText; }; int main( int argc, char** argv ) { - TQApplication app( argc, argv ); + TQApplication app( argc, argv ); HttpInfo info; - app.setMainWidget( &info ); - info.show(); - return app.exec(); + app.setMainWidget( &info ); + info.show(); + return app.exec(); } #include "httpd.moc" -- cgit v1.2.3