summaryrefslogtreecommitdiffstats
path: root/doc/network.doc
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2024-07-10 18:56:16 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-07-10 18:56:16 +0900
commit252a2ec8b0f0f9cf20c947737087b24a8185b588 (patch)
treeb48be8863db3bc1c223ac270a258b5c1124cb0e3 /doc/network.doc
parent87d29563e3ccdeb7fea0197e262e667ef323ff9c (diff)
downloadtqt-252a2ec8.tar.gz
tqt-252a2ec8.zip
Rename IO and network class nt* related files to equivalent tq*
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'doc/network.doc')
-rw-r--r--doc/network.doc242
1 files changed, 121 insertions, 121 deletions
diff --git a/doc/network.doc b/doc/network.doc
index 6c55a1ddb..1edfa3212 100644
--- a/doc/network.doc
+++ b/doc/network.doc
@@ -57,39 +57,39 @@ This module is part of the \link commercialeditions.html TQt Enterprise Edition
The network module offers classes to make network programming easier
and portable. Essentially, there are three sets of classes, first low
-level classes like \l QSocket, \l QServerSocket, \l QDns, etc. which
+level classes like \l TQSocket, \l TQServerSocket, \l TQDns, etc. which
allow you to work in a portable way with TCP/IP sockets. In addition,
-there are classes like \l QNetworkProtocol, \l QNetworkOperation in
+there are classes like \l TQNetworkProtocol, \l TQNetworkOperation in
the TQt base library, which provide an abstract layer for implementing
-network protocols and \c QUrlOperator which operates on such network
+network protocols and \c TQUrlOperator which operates on such network
protocols. Finally the third set of network classes are the passive
-ones, specifically \c QUrl and \c QUrlInfo which do URL parsing and
+ones, specifically \c TQUrl and \c TQUrlInfo which do URL parsing and
similar.
-The first set of classes (\l QSocket, \l QServerSocket, \l QDns, \l
-QFtp, etc.) are included in Qt's "network" module.
-
-The QSocket classes are not directly related to the QNetwork classes,
-but QSocket should and will be used for implementing network
-protocols, which are directly related to the QNetwork classes. For
-example, the QFtp class (which implements the FTP protocol) uses
-QSockets. But QSockets don't need to be used for protocol
-implementations, e.g. QLocalFs (which is an implementation of the
-local filesystem as network protocol) uses QDir and doesn't use
-QSocket. Using QNetworkProtocols you can implement everything which
+The first set of classes (\l TQSocket, \l TQServerSocket, \l TQDns, \l
+TQFtp, etc.) are included in Qt's "network" module.
+
+The TQSocket classes are not directly related to the TQNetwork classes,
+but TQSocket should and will be used for implementing network
+protocols, which are directly related to the TQNetwork classes. For
+example, the TQFtp class (which implements the FTP protocol) uses
+TQSockets. But TQSockets don't need to be used for protocol
+implementations, e.g. TQLocalFs (which is an implementation of the
+local filesystem as network protocol) uses TQDir and doesn't use
+TQSocket. Using TQNetworkProtocols you can implement everything which
fits into a hierarchical structure and can be accessed using URLs.
This could be, for example, a protocol which can read pictures from a
digital camera using a serial connection.
-\section1 Working Network Protocol independently with QUrlOperator and QNetworkOperation
+\section1 Working Network Protocol independently with TQUrlOperator and TQNetworkOperation
It is quite easy to just use existing network protocol implementations
and operate on URLs. For example, downloading a file from an FTP
server to the local filesystem can be done with following code:
\code
- QUrlOperator op;
+ TQUrlOperator op;
op.copy( "ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz", "file:/tmp", FALSE );
\endcode
@@ -102,52 +102,52 @@ renaming, etc. For example, to create a folder on a private FTP
account do
\code
- QUrlOperator op( "ftp://username:password@host.domain.no/home/username" );
+ TQUrlOperator op( "ftp://username:password@host.domain.no/home/username" );
op.mkdir( "New Directory" );
\endcode
-To see all available operations, look at the \c QUrlOperator class
+To see all available operations, look at the \c TQUrlOperator class
documentation.
Since networking works asynchronously, the function call for an
operation will normally return before the operation has been
completed. This means that the function cannot return a value
indicating failure or success. Instead, the return value always is a
-pointer to a \c QNetworkOperation, and this object stores
+pointer to a \c TQNetworkOperation, and this object stores
all the information about the operation.
-For example, \c QNetworkOperation has a method which returns the state
+For example, \c TQNetworkOperation has a method which returns the state
of this operation. Using this you can find out the state of the
operation at any time. The object also makes available the arguments
-you passed to the \c QUrlOperator method, the type of the operation
+you passed to the \c TQUrlOperator method, the type of the operation
and some more information. For more details see the class
-documentation of \c QNetworkOperation.
+documentation of \c TQNetworkOperation.
-The \c QUrlOperator emits signals to inform you about the progress of
+The \c TQUrlOperator emits signals to inform you about the progress of
the operations. As you can call many methods which operate on a \c
-QUrlOperator's URL, it queues up all the operations. So you can't know
-which operation the \c QUrlOperator just processed. Clearly you will
+TQUrlOperator's URL, it queues up all the operations. So you can't know
+which operation the \c TQUrlOperator just processed. Clearly you will
want to know which operation just took place, so each signal's last
-argument is a pointer to the \c QNetworkOperation object which was
+argument is a pointer to the \c TQNetworkOperation object which was
just processed and which caused the signal to be emitted.
Some of these operations send a \c start() signal at the beginning (if
this makes sense), and some of them send some signals during
processing. All operations send a \c finished() signal after they are
done. To find that out if an operation finished successfully you can
-use the \c QNetworkOperation pointer you got with the \c finished()
-signal. If \c QNetworkOperation::state() equals \c
-QNetworkProtocol::StDone the operation finished successfully, if it is
-\c QNetworkProtocol::StFailed the operation failed.
+use the \c TQNetworkOperation pointer you got with the \c finished()
+signal. If \c TQNetworkOperation::state() equals \c
+TQNetworkProtocol::StDone the operation finished successfully, if it is
+\c TQNetworkProtocol::StFailed the operation failed.
Example: A slot which you might connect to the
-\c{QUrlOperator::finished( QNetworkOperation * )}
+\c{TQUrlOperator::finished( TQNetworkOperation * )}
\code
-void MyClass::slotOperationFinished( QNetworkOperation *op )
+void MyClass::slotOperationFinished( TQNetworkOperation *op )
{
switch ( op->operation() ) {
- case QNetworkProtocol::OpMkDir:
- if ( op->state() == QNetworkProtocol::StFailed )
+ case TQNetworkProtocol::OpMkDir:
+ if ( op->state() == TQNetworkProtocol::StFailed )
tqDebug( "Couldn't create directory %s", op->arg( 0 ).latin1() );
else
tqDebug( "Successfully created directory %s", op->arg( 0 ).latin1() );
@@ -162,37 +162,37 @@ take the list children operation as an example (e.g. read a directory
on a FTP server):
\code
-QUrlOperator op;
+TQUrlOperator op;
MyClass::MyClass() : TQObject(), op( "ftp://ftp.trolltech.com" )
{
- connect( &op, TQ_SIGNAL( newChildren( const TQValueList<QUrlInfo> &, QNetworkOperation * ) ),
- this, TQ_SLOT( slotInsertEntries( const TQValueList<QUrlInfo> &, QNetworkOperation * ) ) );
- connect( &op, TQ_SIGNAL( start( QNetworkOperation * ) ),
- this, TQ_SLOT( slotStart( QNetworkOperation *) ) );
- connect( &op, TQ_SIGNAL( finished( QNetworkOperation * ) ),
- this, TQ_SLOT( slotFinished( QNetworkOperation *) ) );
+ connect( &op, TQ_SIGNAL( newChildren( const TQValueList<TQUrlInfo> &, TQNetworkOperation * ) ),
+ this, TQ_SLOT( slotInsertEntries( const TQValueList<TQUrlInfo> &, TQNetworkOperation * ) ) );
+ connect( &op, TQ_SIGNAL( start( TQNetworkOperation * ) ),
+ this, TQ_SLOT( slotStart( TQNetworkOperation *) ) );
+ connect( &op, TQ_SIGNAL( finished( TQNetworkOperation * ) ),
+ this, TQ_SLOT( slotFinished( TQNetworkOperation *) ) );
}
-void MyClass::slotInsertEntries( const TQValueList<QUrlInfo> &info, QNetworkOperation * )
+void MyClass::slotInsertEntries( const TQValueList<TQUrlInfo> &info, TQNetworkOperation * )
{
- TQValueList<QUrlInfo>::ConstIterator it = info.begin();
+ TQValueList<TQUrlInfo>::ConstIterator it = info.begin();
for ( ; it != info.end(); ++it ) {
- const QUrlInfo &inf = *it;
+ const TQUrlInfo &inf = *it;
tqDebug( "Name: %s, Size: %d, Last Modified: %s",
inf.name().latin1(), inf.size(), inf.lastModified().toString().latin1() );
}
}
-void MyClass::slotStart( QNetworkOperation * )
+void MyClass::slotStart( TQNetworkOperation * )
{
tqDebug( "Start reading '%s'", op.toString().latin1() );
}
-void MyClass::slotFinished( QNetworkOperation *operation )
+void MyClass::slotFinished( TQNetworkOperation *operation )
{
- if ( operation->operation() == QNetworkProtocol::OpListChildren ) {
- if ( operation->state() == QNetworkProtocol::StFailed )
+ if ( operation->operation() == TQNetworkProtocol::OpListChildren ) {
+ if ( operation->state() == TQNetworkProtocol::StFailed )
tqDebug( "Couldn't read '%s'! Following error occurred: %s",
op.toString().latin1(), operation->protocolDetail().latin1() );
else
@@ -202,14 +202,14 @@ void MyClass::slotFinished( QNetworkOperation *operation )
\endcode
-These examples demonstrate now how to use the \c QUrlOperator and \c
-QNetworkOperations. The network extension also contains useful example
+These examples demonstrate now how to use the \c TQUrlOperator and \c
+TQNetworkOperations. The network extension also contains useful example
code.
\section2 Implementing your own Network Protocol
-\c QNetworkProtocol provides a base class for implementations
+\c TQNetworkProtocol provides a base class for implementations
of network protocols and an architecture for the a dynamic
registration and de-registration of network protocols. If you use this
architecture you don't need to care about asynchronous programming, as
@@ -224,34 +224,34 @@ network protocol and easily used in Qt. This is not limited to
filesystems only!
To implement a network protocol create a class derived from
-\c QNetworkProtocol.
+\c TQNetworkProtocol.
Other classes will use this network protocol implementation
to operate on it. So you should reimplement following protected members
\code
- void QNetworkProtocol::operationListChildren( QNetworkOperation *op );
- void QNetworkProtocol::operationMkDir( QNetworkOperation *op );
- void QNetworkProtocol::operationRemove( QNetworkOperation *op );
- void QNetworkProtocol::operationRename( QNetworkOperation *op );
- void QNetworkProtocol::operationGet( QNetworkOperation *op );
- void QNetworkProtocol::operationPut( QNetworkOperation *op );
+ void TQNetworkProtocol::operationListChildren( TQNetworkOperation *op );
+ void TQNetworkProtocol::operationMkDir( TQNetworkOperation *op );
+ void TQNetworkProtocol::operationRemove( TQNetworkOperation *op );
+ void TQNetworkProtocol::operationRename( TQNetworkOperation *op );
+ void TQNetworkProtocol::operationGet( TQNetworkOperation *op );
+ void TQNetworkProtocol::operationPut( TQNetworkOperation *op );
\endcode
Some notes on reimplementing these methods: You always get a pointer
-to a \c QNetworkOperation as argument. This pointer holds all the
+to a \c TQNetworkOperation as argument. This pointer holds all the
information about the operation in the current state. If you start
processing such an operation, set the state to \c
-QNetworkProtocol::StInProgress. If you finished processing the
-operation, set the state to \c QNetworkProtocol::StDone if it was
-successful or \c QNetworkProtocol::StFailed if an error occurred. If
+TQNetworkProtocol::StInProgress. If you finished processing the
+operation, set the state to \c TQNetworkProtocol::StDone if it was
+successful or \c TQNetworkProtocol::StFailed if an error occurred. If
an error occurred you must set an error code (see
-\c{QNetworkOperation::setErrorCode()}) and if you know some details
+\c{TQNetworkOperation::setErrorCode()}) and if you know some details
(e.g. an error message) you can also set this message to the operation
-pointer (see \c{QNetworkOperation::setProtocolDetail()}). Also you get
+pointer (see \c{TQNetworkOperation::setProtocolDetail()}). Also you get
all the relevant information (type, arguments, etc.) about the
-operation from the \c QNetworkOperation pointer. For details about
-which arguments you can get and set look at \c{QNetworkOperation}'s
+operation from the \c TQNetworkOperation pointer. For details about
+which arguments you can get and set look at \c{TQNetworkOperation}'s
class documentation.
If you reimplement an operation function, it's very important to emit
@@ -302,13 +302,13 @@ specialized signals which are specific to operations:
And remember, always emit the \c finished() signal at the end!
For more details about these signals' arguments look at the \c
-QNetworkProtocol class documentation.
+TQNetworkProtocol class documentation.
-Here is a list of which \c QNetworkOperation arguments you can get and
+Here is a list of which \c TQNetworkOperation arguments you can get and
which you must set in which function:
(To get the URL on which you should work, use the \c
-QNetworkProtocol::url() method which returns a pointer to the URL
+TQNetworkProtocol::url() method which returns a pointer to the URL
operator. Using that you can get the path, host, name filter, etc.)
\list
@@ -318,41 +318,41 @@ operator. Using that you can get the path, host, name filter, etc.)
\endlist
\i In \c operationMkDir:
\list
- \i \c QNetworkOperation::arg( 0 ) contains the name of the directory which should be created
+ \i \c TQNetworkOperation::arg( 0 ) contains the name of the directory which should be created
\endlist
\i In \c operationRemove:
\list
- \i \c QNetworkOperation::arg( 0 ) contains the name of the file
+ \i \c TQNetworkOperation::arg( 0 ) contains the name of the file
which should be removed. Normally this is a relative name. But
- it could be absolute. Use QUrl( op->arg( 0 ) ).fileName()
+ it could be absolute. Use TQUrl( op->arg( 0 ) ).fileName()
to get the filename.
\endlist
\i In \c operationRename:
\list
- \i \c QNetworkOperation::arg( 0 ) contains the name of the file
+ \i \c TQNetworkOperation::arg( 0 ) contains the name of the file
which should be renamed
- \i \c QNetworkOperation::arg( 1 ) contains the name to which it
+ \i \c TQNetworkOperation::arg( 1 ) contains the name to which it
should be renamed.
\endlist
\i In \c operationGet:
\list
- \i \c QNetworkOperation::arg( 0 ) contains the full URL of the
+ \i \c TQNetworkOperation::arg( 0 ) contains the full URL of the
file which should be retrieved.
\endlist
\i In \c operationPut:
\list
- \i \c QNetworkOperation::arg( 0 ) contains the full URL of the
+ \i \c TQNetworkOperation::arg( 0 ) contains the full URL of the
file in which the data should be stored.
- \i \c QNetworkOperation::rawArg( 1 ) contains the data which
- should be stored in \c QNetworkOperation::arg( 0 )
+ \i \c TQNetworkOperation::rawArg( 1 ) contains the data which
+ should be stored in \c TQNetworkOperation::arg( 0 )
\endlist
\endlist
In summary: If you reimplement an operation function, you must emit
some special signals and at the end you must \e always emit a \c
finished() signal, regardless of success or failure. Also you must
-change the state of the \c QNetworkOperation during processing. You
-can also get and set \c QNetworkOperation arguments as the operation
+change the state of the \c TQNetworkOperation during processing. You
+can also get and set \c TQNetworkOperation arguments as the operation
progresses.
It may occur that the network protocol you implement only requires a
@@ -362,12 +362,12 @@ specify which operations you support. This is achieved by
reimplementing
\code
- int QNetworkProtocol::supportedOperations() const;
+ int TQNetworkProtocol::supportedOperations() const;
\endcode
In your implementation of this method return an \c int value
which is constructed by OR-ing together the correct values
-(supported operations) of the following enum (of \c QNetworkProtocol):
+(supported operations) of the following enum (of \c TQNetworkProtocol):
\list
\i \c OpListChildren
@@ -388,15 +388,15 @@ them, your implementation of \c supportedOperations() should do this:
The last method you must reimplement is
\code
- bool QNetworkProtocol::checkConnection( QNetworkOperation *op );
+ bool TQNetworkProtocol::checkConnection( TQNetworkOperation *op );
\endcode
Here you must return TRUE, if the connection is up and okay (this means
operations on the protocol can be done). If the connection is not okay,
return FALSE and start to try opening it. If you cannot open the
connection at all (e.g. because the host is not found), emit a \c finished()
-signal and set an error code and the \c QNetworkProtocol::StFailed state to
-the \c QNetworkOperation pointer you get here.
+signal and set an error code and the \c TQNetworkProtocol::StFailed state to
+the \c TQNetworkOperation pointer you get here.
Now, you never need to check before doing an operation yourself, if
the connection is okay. The network architecture does this, which
@@ -404,89 +404,89 @@ means it uses \c checkConnection() to see if an operation can be done
and if not, it tries it again and again for some time, only calling an
operation function if the connection is okay.
-To be able to use a network protocol with a QUrlOperator (and so, for
-example, in the QFileDialog), you must register the network
+To be able to use a network protocol with a TQUrlOperator (and so, for
+example, in the TQFileDialog), you must register the network
protocol implementation. This can be done like this:
\code
- QNetworkProtocol::registerNetworkProtocol( "myprot", new QNetworkProtocolFactory<MyProtocol> );
+ TQNetworkProtocol::registerNetworkProtocol( "myprot", new TQNetworkProtocolFactory<MyProtocol> );
\endcode
In this case \c MyProtocol would be a class you implemented as
-described here (derived from \c QNetworkProtocol) and the name of the
+described here (derived from \c TQNetworkProtocol) and the name of the
protocol would be "myprot". So to use it, you would do something like
\code
- QUrlOperator op( "myprot://host/path" );
+ TQUrlOperator op( "myprot://host/path" );
op.listChildren();
\endcode
Finally, as example of a network protocol implementation you could
-look at the implementation of QLocalFs. The network extension also
+look at the implementation of TQLocalFs. The network extension also
contains an example implementation of a network protocol.
\section2 Error Handling
Error handling is important for both implementing new network
-protocols for and using them (through \c QUrlOperator).
+protocols for and using them (through \c TQUrlOperator).
After processing an operation has been finished the network operation
-the QUrlOperator emits the \c finished() signal. This has as argument
-a pointer to the processed \c QNetworkOperation. If the state of this
-operation is \c QNetworkProtocol::StFailed, the operation contains
+the TQUrlOperator emits the \c finished() signal. This has as argument
+a pointer to the processed \c TQNetworkOperation. If the state of this
+operation is \c TQNetworkProtocol::StFailed, the operation contains
some more information about this error. The following error codes are
-defined in \c QNetworkProtocol:
+defined in \c TQNetworkProtocol:
\table
\header \i Error \i Meaning
-\row \i \c QNetworkProtocol::NoError
+\row \i \c TQNetworkProtocol::NoError
\i No error occurred
-\row \i \c QNetworkProtocol::ErrValid
+\row \i \c TQNetworkProtocol::ErrValid
\i The URL you are operating on is not valid
-\row \i \c QNetworkProtocol::ErrUnknownProtocol
+\row \i \c TQNetworkProtocol::ErrUnknownProtocol
\i There is no protocol implementation available for the protocol
of the URL you are operating on (e.g. if the protocol is http
and no http implementation has been registered)
-\row \i \c QNetworkProtocol::ErrUnsupported
+\row \i \c TQNetworkProtocol::ErrUnsupported
\i The operation is not supported by the protocol
-\row \i \c QNetworkProtocol::ErrParse
+\row \i \c TQNetworkProtocol::ErrParse
\i Parse error of the URL
-\row \i \c QNetworkProtocol::ErrLoginIncorrect
+\row \i \c TQNetworkProtocol::ErrLoginIncorrect
\i You needed to login but the username or password are wrong
-\row \i \c QNetworkProtocol::ErrHostNotFound
+\row \i \c TQNetworkProtocol::ErrHostNotFound
\i The specified host (in the URL) couldn't be found
-\row \i \c QNetworkProtocol::ErrListChildren
+\row \i \c TQNetworkProtocol::ErrListChildren
\i An error occurred while listing the children
-\row \i \c QNetworkProtocol::ErrMkDir
+\row \i \c TQNetworkProtocol::ErrMkDir
\i An error occurred when creating a directory
-\row \i \c QNetworkProtocol::ErrRemove
+\row \i \c TQNetworkProtocol::ErrRemove
\i An error occurred while removing a child
-\row \i \c QNetworkProtocol::ErrRename
+\row \i \c TQNetworkProtocol::ErrRename
\i An error occurred while renaming a child
-\row \i \c QNetworkProtocol::ErrGet
+\row \i \c TQNetworkProtocol::ErrGet
\i An error occurred while getting (retrieving) data
-\row \i \c QNetworkProtocol::ErrPut
+\row \i \c TQNetworkProtocol::ErrPut
\i An error occurred while putting (uploading) data
-\row \i \c QNetworkProtocol::ErrFileNotExisting
+\row \i \c TQNetworkProtocol::ErrFileNotExisting
\i A file which is needed by the operation doesn't exist
-\row \i \c QNetworkProtocol::ErrPermissionDenied
+\row \i \c TQNetworkProtocol::ErrPermissionDenied
\i The permission for doing the operation has been denied
\endtable
-\c QNetworkOperation::errorCode() returns one of these codes or
+\c TQNetworkOperation::errorCode() returns one of these codes or
perhaps a different one if you use your an own network protocol
implementation which defines additional error codes.
-\c QNetworkOperation::protocolDetails() may also return a string which
+\c TQNetworkOperation::protocolDetails() may also return a string which
contains an error message then which might be suitable for display to
the user.
If you implement your own network protocol, you must report any
errors which occurred. First you always need to be able to
-access the \c QNetworkOperation which is being processed at the
+access the \c TQNetworkOperation which is being processed at the
moment. This is done using \c
-QNetworkOperation::operationInProgress(), which returns a pointer to
+TQNetworkOperation::operationInProgress(), which returns a pointer to
the current network operation or 0 if no operation is processed at the
moment.
@@ -500,23 +500,23 @@ Now if an error occurred and you need to handle it, do this:
}
\endcode
-That's all. The connection to the \c QUrlOperator and so on is done
+That's all. The connection to the \c TQUrlOperator and so on is done
automatically. Additionally, if the error was really bad so that no
more operations can be done in the current state (e.g. if the host
-couldn't be found), call \c QNetworkProtocol::clearOperationStack() \e
+couldn't be found), call \c TQNetworkProtocol::clearOperationStack() \e
before emitting \c finished().
Ideally you should use one of the predefined error codes of \c
-QNetworkProtocol. If this is not possible, you can add own error codes
+TQNetworkProtocol. If this is not possible, you can add own error codes
- they are just normal \c{int}s. Just be careful that the value of the
error code doesn't conflict with an existing one.
An example to look at is in qt/examples/network/ftpclient.
This is the implementation of a fairly complete FTP client, which
supports uploading and downloading files, making directories, etc.,
-all done using \c QUrlOperators.
+all done using \c TQUrlOperators.
-You might also like to look at QFtp (in qt/src/network/qftp.cpp) or at
+You might also like to look at TQFtp (in qt/src/network/tqftp.cpp) or at
the example in qt/examples/network/networkprotocol/nntp.cpp.
*/