#include <q3networkprotocol.h>
Inheritance diagram for Q3NetworkProtocol:


This is a base class which should be used for network protocols implementations that can then be used in Qt (e.g. in the file dialog) together with the Q3UrlOperator.
The easiest way to implement a new network protocol is to reimplement the operation*() methods, e.g. operationGet(), etc. Only the supported operations should be reimplemented. To specify which operations are supported, also reimplement supportedOperations() and return an int that is OR'd together using the supported operations from the Q3NetworkProtocol::Operation enum.
When you implement a network protocol this way, it is important to emit the correct signals. Also, always emit the finished() signal when an operation is done (on success and on failure). Qt relies on correctly emitted finished() signals.
Definition at line 65 of file q3networkprotocol.h.
This enum contains the state that a Q3NetworkOperation can have.
StWaiting The operation is in the Q3NetworkProtocol's queue waiting to be prcessed.
StInProgress The operation is being processed.
StDone The operation has been processed successfully.
StFailed The operation has been processed but an error occurred.
StStopped The operation has been processed but has been stopped before it finished, and is waiting to be processed.
Definition at line 70 of file q3networkprotocol.h.
00070 { 00071 StWaiting = 0, 00072 StInProgress, 00073 StDone, 00074 StFailed, 00075 StStopped 00076 };
This enum lists the possible operations that a network protocol can support. supportedOperations() returns an int of these that is OR'd together. Also, the type() of a Q3NetworkOperation is always one of these values.
OpListChildren List the children of a URL, e.g. of a directory. OpMkDir Create a directory. OpRemove Remove a child (e.g. a file). OpRename Rename a child (e.g. a file). OpGet Get data from a location. OpPut Put data to a location. OpMkdir
Definition at line 78 of file q3networkprotocol.h.
00078 { 00079 OpListChildren = 1, 00080 OpMkDir = 2, 00081 OpMkdir = OpMkDir, // ### remove in 4.0 00082 OpRemove = 4, 00083 OpRename = 8, 00084 OpGet = 32, 00085 OpPut = 64 00086 };
When the connection state of a network protocol changes it emits the signal connectionStateChanged(). The first argument is one of the following values:
ConHostFound Host has been found. ConConnected Connection to the host has been established. ConClosed Connection has been closed.
Definition at line 88 of file q3networkprotocol.h.
00088 { 00089 ConHostFound, 00090 ConConnected, 00091 ConClosed 00092 };
When an operation fails (finishes unsuccessfully), the Q3NetworkOperation of the operation returns an error code which has one of the following values:
NoError No error occurred.
ErrValid The URL you are operating on is not valid.
ErrUnknownProtocol 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).
ErrUnsupported The operation is not supported by the protocol.
ErrParse The URL could not be parsed correctly.
ErrLoginIncorrect You needed to login but the username or password is wrong.
ErrHostNotFound The specified host (in the URL) couldn't be found.
ErrListChildren An error occurred while listing the children (files).
ErrMkDir An error occurred when creating a directory.
ErrRemove An error occurred when removing a child (file).
ErrRename An error occurred when renaming a child (file).
ErrGet An error occurred while getting (retrieving) data.
ErrPut An error occurred while putting (uploading) data.
ErrFileNotExisting A file which is needed by the operation doesn't exist.
ErrPermissionDenied Permission for doing the operation has been denied. ErrMkdir ErrListChlidren
You should also use these error codes when implementing custom network protocols. If this is not possible, you can define your own error codes by using integer values that don't conflict with any of these values.
Definition at line 94 of file q3networkprotocol.h.
00094 { 00095 // no error 00096 NoError = 0, 00097 // general errors 00098 ErrValid, 00099 ErrUnknownProtocol, 00100 ErrUnsupported, 00101 ErrParse, 00102 // errors on connect 00103 ErrLoginIncorrect, 00104 ErrHostNotFound, 00105 // protocol errors 00106 ErrListChildren, 00107 ErrListChlidren = ErrListChildren, // ### remove in 4.0 00108 ErrMkDir, 00109 ErrMkdir = ErrMkDir, // ### remove in 4.0 00110 ErrRemove, 00111 ErrRename, 00112 ErrGet, 00113 ErrPut, 00114 ErrFileNotExisting, 00115 ErrPermissionDenied 00116 };
| Q3NetworkProtocol::Q3NetworkProtocol | ( | ) |
Constructor of the network protocol base class. Does some initialization and connecting of signals and slots.
Definition at line 367 of file q3networkprotocol.cpp.
References QObject::connect(), connectionStateChanged(), createdDirectory(), d, data(), dataTransferProgress(), emitNewChildren(), finished(), itemChanged(), newChild(), newChildren(), Q3NetworkProtocolPrivate::opStartTimer, processNextOperation(), removed(), removeMe(), Q3NetworkProtocolPrivate::removeTimer, SIGNAL, SLOT, start(), startOps(), and url().
00368 : QObject() 00369 { 00370 d = new Q3NetworkProtocolPrivate( this ); 00371 00372 connect( d->opStartTimer, SIGNAL(timeout()), 00373 this, SLOT(startOps()) ); 00374 connect( d->removeTimer, SIGNAL(timeout()), 00375 this, SLOT(removeMe()) ); 00376 00377 if ( url() ) { 00378 connect( this, SIGNAL(data(QByteArray,Q3NetworkOperation*)), 00379 url(), SIGNAL(data(QByteArray,Q3NetworkOperation*)) ); 00380 connect( this, SIGNAL(finished(Q3NetworkOperation*)), 00381 url(), SIGNAL(finished(Q3NetworkOperation*)) ); 00382 connect( this, SIGNAL(start(Q3NetworkOperation*)), 00383 url(), SIGNAL(start(Q3NetworkOperation*)) ); 00384 connect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00385 url(), SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)) ); 00386 connect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00387 url(), SLOT(addEntry(Q3ValueList<QUrlInfo>)) ); 00388 connect( this, SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)), 00389 url(), SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)) ); 00390 connect( this, SIGNAL(removed(Q3NetworkOperation*)), 00391 url(), SIGNAL(removed(Q3NetworkOperation*)) ); 00392 connect( this, SIGNAL(itemChanged(Q3NetworkOperation*)), 00393 url(), SIGNAL(itemChanged(Q3NetworkOperation*)) ); 00394 connect( this, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)), 00395 url(), SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)) ); 00396 connect( this, SIGNAL(connectionStateChanged(int,QString)), 00397 url(), SIGNAL(connectionStateChanged(int,QString)) ); 00398 } 00399 00400 connect( this, SIGNAL(finished(Q3NetworkOperation*)), 00401 this, SLOT(processNextOperation(Q3NetworkOperation*)) ); 00402 connect( this, SIGNAL(newChild(QUrlInfo,Q3NetworkOperation*)), 00403 this, SLOT(emitNewChildren(QUrlInfo,Q3NetworkOperation*)) ); 00404 00405 }
Here is the call graph for this function:

| Q3NetworkProtocol::~Q3NetworkProtocol | ( | ) | [virtual] |
Destructor.
Definition at line 411 of file q3networkprotocol.cpp.
References d.
00412 { 00413 delete d; 00414 }
| void Q3NetworkProtocol::setUrl | ( | Q3UrlOperator * | u | ) | [virtual] |
Sets the Q3UrlOperator, on which the protocol works, to u.
Definition at line 422 of file q3networkprotocol.cpp.
References QObject::connect(), connectionStateChanged(), createdDirectory(), d, data(), dataTransferProgress(), QObject::disconnect(), finished(), Q3PtrQueue< type >::isEmpty(), itemChanged(), newChildren(), Q3NetworkProtocolPrivate::operationQueue, Q3NetworkProtocolPrivate::opInProgress, Q3NetworkProtocolPrivate::opStartTimer, removed(), SIGNAL, SLOT, start(), QTimer::start(), u, url(), and Q3NetworkProtocolPrivate::url.
Referenced by Q3UrlOperator::cdUp(), Q3UrlOperator::getNetworkProtocol(), Q3UrlOperator::setPath(), and stop().
00423 { 00424 if ( url() ) { 00425 disconnect( this, SIGNAL(data(QByteArray,Q3NetworkOperation*)), 00426 url(), SIGNAL(data(QByteArray,Q3NetworkOperation*)) ); 00427 disconnect( this, SIGNAL(finished(Q3NetworkOperation*)), 00428 url(), SIGNAL(finished(Q3NetworkOperation*)) ); 00429 disconnect( this, SIGNAL(start(Q3NetworkOperation*)), 00430 url(), SIGNAL(start(Q3NetworkOperation*)) ); 00431 disconnect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00432 url(), SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)) ); 00433 disconnect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00434 url(), SLOT(addEntry(Q3ValueList<QUrlInfo>)) ); 00435 disconnect( this, SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)), 00436 url(), SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)) ); 00437 disconnect( this, SIGNAL(removed(Q3NetworkOperation*)), 00438 url(), SIGNAL(removed(Q3NetworkOperation*)) ); 00439 disconnect( this, SIGNAL(itemChanged(Q3NetworkOperation*)), 00440 url(), SIGNAL(itemChanged(Q3NetworkOperation*)) ); 00441 disconnect( this, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)), 00442 url(), SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)) ); 00443 disconnect( this, SIGNAL(connectionStateChanged(int,QString)), 00444 url(), SIGNAL(connectionStateChanged(int,QString)) ); 00445 } 00446 00447 00448 // ### if autoDelete is true, we should delete the Q3UrlOperator (something 00449 // like below; but that is not possible since it would delete this, too). 00450 //if ( d->autoDelete && (d->url!=u) ) { 00451 // delete d->url; // destructor deletes the network protocol 00452 //} 00453 d->url = u; 00454 00455 if ( url() ) { 00456 connect( this, SIGNAL(data(QByteArray,Q3NetworkOperation*)), 00457 url(), SIGNAL(data(QByteArray,Q3NetworkOperation*)) ); 00458 connect( this, SIGNAL(finished(Q3NetworkOperation*)), 00459 url(), SIGNAL(finished(Q3NetworkOperation*)) ); 00460 connect( this, SIGNAL(start(Q3NetworkOperation*)), 00461 url(), SIGNAL(start(Q3NetworkOperation*)) ); 00462 connect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00463 url(), SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)) ); 00464 connect( this, SIGNAL(newChildren(Q3ValueList<QUrlInfo>,Q3NetworkOperation*)), 00465 url(), SLOT(addEntry(Q3ValueList<QUrlInfo>)) ); 00466 connect( this, SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)), 00467 url(), SIGNAL(createdDirectory(QUrlInfo,Q3NetworkOperation*)) ); 00468 connect( this, SIGNAL(removed(Q3NetworkOperation*)), 00469 url(), SIGNAL(removed(Q3NetworkOperation*)) ); 00470 connect( this, SIGNAL(itemChanged(Q3NetworkOperation*)), 00471 url(), SIGNAL(itemChanged(Q3NetworkOperation*)) ); 00472 connect( this, SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)), 00473 url(), SIGNAL(dataTransferProgress(int,int,Q3NetworkOperation*)) ); 00474 connect( this, SIGNAL(connectionStateChanged(int,QString)), 00475 url(), SIGNAL(connectionStateChanged(int,QString)) ); 00476 } 00477 00478 if ( !d->opInProgress && !d->operationQueue.isEmpty() ) 00479 d->opStartTimer->start( 0, true ); 00480 }
Here is the call graph for this function:

| void Q3NetworkProtocol::setAutoDelete | ( | bool | b, | |
| int | i = 10000 | |||
| ) | [virtual] |
Because it's sometimes hard to take care of removing network protocol instances, Q3NetworkProtocol provides an auto-delete mechanism. If you set b to true, the network protocol instance is removed after it has been inactive for i milliseconds (i.e. i milliseconds after the last operation has been processed). If you set b to false the auto-delete mechanism is switched off.
If you switch on auto-delete, the Q3NetworkProtocol also deletes its Q3UrlOperator.
Definition at line 857 of file q3networkprotocol.cpp.
References Q3NetworkProtocolPrivate::autoDelete, d, and Q3NetworkProtocolPrivate::removeInterval.
Referenced by Q3UrlOperator::continueCopy(), and Q3UrlOperator::copy().
00858 { 00859 d->autoDelete = b; 00860 d->removeInterval = i; 00861 }
| bool Q3NetworkProtocol::autoDelete | ( | ) | const |
Returns true if auto-deleting is enabled; otherwise returns false.
Definition at line 869 of file q3networkprotocol.cpp.
References Q3NetworkProtocolPrivate::autoDelete, and d.
00870 { 00871 return d->autoDelete; 00872 }
| void Q3NetworkProtocol::registerNetworkProtocol | ( | const QString & | protocol, | |
| Q3NetworkProtocolFactoryBase * | protocolFactory | |||
| ) | [static] |
Static method to register a network protocol for Qt. For example, if you have an implementation of NNTP (called Nntp) which is derived from Q3NetworkProtocol, call:
after which your implementation is registered for future nntp operations.The name of the protocol is given in protocol and a pointer to the protocol factory is given in protocolFactory.
Definition at line 544 of file q3networkprotocol.cpp.
References Q3Dict< type >::insert(), and q3networkProtocolRegister.
Referenced by getNetworkProtocol(), and Q3UrlOperator::q3InitNetworkProtocols().
00546 { 00547 if ( !q3networkProtocolRegister ) { 00548 q3networkProtocolRegister = new Q3NetworkProtocolDict; 00549 Q3NetworkProtocol::registerNetworkProtocol( "file", new Q3NetworkProtocolFactory< Q3LocalFs > ); 00550 } 00551 00552 q3networkProtocolRegister->insert( protocol, protocolFactory ); 00553 }
Here is the call graph for this function:

| Q3NetworkProtocol * Q3NetworkProtocol::getNetworkProtocol | ( | const QString & | protocol | ) | [static] |
Static method to get a new instance of the network protocol protocol. For example, if you need to do some FTP operations, do the following:
Q3Ftp *ftp = Q3NetworkProtocol::getNetworkProtocol( "ftp" );
Normally you should not work directly with network protocols, so you will not need to call this method yourself. Instead, use Q3UrlOperator, which makes working with network protocols much more convenient.
Definition at line 575 of file q3networkprotocol.cpp.
References Q3NetworkProtocolFactoryBase::createObject(), Q3Dict< type >::find(), QString::isNull(), q3networkProtocolRegister, and registerNetworkProtocol().
Referenced by Q3FileDialogPrivate::fileExists(), and Q3UrlOperator::getNetworkProtocol().
00576 { 00577 if ( !q3networkProtocolRegister ) { 00578 q3networkProtocolRegister = new Q3NetworkProtocolDict; 00579 Q3NetworkProtocol::registerNetworkProtocol( "file", new Q3NetworkProtocolFactory< Q3LocalFs > ); 00580 } 00581 00582 if ( protocol.isNull() ) 00583 return 0; 00584 00585 Q3NetworkProtocolFactoryBase *factory = q3networkProtocolRegister->find( protocol ); 00586 if ( factory ) 00587 return factory->createObject(); 00588 00589 return 0; 00590 }
Here is the call graph for this function:

| bool Q3NetworkProtocol::hasOnlyLocalFileSystem | ( | ) | [static] |
Returns true if the only protocol registered is for working on the local filesystem; returns false if other network protocols are also registered.
Definition at line 598 of file q3networkprotocol.cpp.
References Q3DictIterator< type >::current(), Q3DictIterator< type >::currentKey(), and q3networkProtocolRegister.
00599 { 00600 if ( !q3networkProtocolRegister ) 00601 return false; 00602 00603 Q3DictIterator< Q3NetworkProtocolFactoryBase > it( *q3networkProtocolRegister ); 00604 for ( ; it.current(); ++it ) 00605 if ( it.currentKey() != "file" ) 00606 return false; 00607 return true; 00608 }
Here is the call graph for this function:

| int Q3NetworkProtocol::supportedOperations | ( | ) | const [virtual] |
Returns an int that is OR'd together using the enum values of {Q3NetworkProtocol::Operation}, which describes which operations are supported by the network protocol. Should be reimplemented by new network protocols.
Definition at line 509 of file q3networkprotocol.cpp.
Referenced by Q3UrlOperator::copy(), and Q3UrlOperator::startOperation().
| void Q3NetworkProtocol::addOperation | ( | Q3NetworkOperation * | op | ) | [virtual] |
Adds the operation op to the operation queue. The operation will be processed as soon as possible. This method returns immediately.
Definition at line 520 of file q3networkprotocol.cpp.
References d, Q3PtrQueue< type >::enqueue(), Q3NetworkOperation::operation(), Q3NetworkProtocolPrivate::operationQueue, Q3NetworkProtocolPrivate::opInProgress, Q3NetworkProtocolPrivate::opStartTimer, qDebug(), and QTimer::start().
Referenced by Q3UrlOperator::continueCopy(), Q3UrlOperator::copy(), and Q3UrlOperator::startOperation().
00521 { 00522 #ifdef Q3NETWORKPROTOCOL_DEBUG 00523 qDebug( "Q3NetworkOperation: addOperation: %p %d", op, op->operation() ); 00524 #endif 00525 d->operationQueue.enqueue( op ); 00526 if ( !d->opInProgress ) 00527 d->opStartTimer->start( 0, true ); 00528 }
Here is the call graph for this function:

| Q3UrlOperator * Q3NetworkProtocol::url | ( | ) | const |
Returns the Q3UrlOperator on which the protocol works.
Definition at line 800 of file q3networkprotocol.cpp.
References d, and Q3NetworkProtocolPrivate::url.
Referenced by Q3Ftp::checkConnection(), Q3Http::clientStateChanged(), Q3Ftp::npListInfo(), Q3Ftp::npStateChanged(), Q3Ftp::operationListChildren(), Q3LocalFs::operationListChildren(), Q3LocalFs::operationMkDir(), Q3Ftp::operationRemove(), Q3LocalFs::operationRemove(), Q3Ftp::operationRename(), Q3LocalFs::operationRename(), Q3Ftp::parseDir(), Q3NetworkProtocol(), and setUrl().
| Q3NetworkOperation * Q3NetworkProtocol::operationInProgress | ( | ) | const |
Returns the operation, which is being processed, or 0 of no operation is being processed at the moment.
Definition at line 810 of file q3networkprotocol.cpp.
References d, and Q3NetworkProtocolPrivate::opInProgress.
Referenced by Q3Http::clientDone(), Q3Http::clientReply(), Q3Ftp::npDataTransferProgress(), Q3Ftp::npDone(), Q3Ftp::npListInfo(), Q3Ftp::npReadyRead(), Q3LocalFs::operationGet(), Q3Http::operationGet(), Q3Http::operationPut(), and Q3LocalFs::operationPut().
00811 { 00812 return d->opInProgress; 00813 }
| void Q3NetworkProtocol::clearOperationQueue | ( | ) | [virtual] |
Clears the operation queue.
Definition at line 819 of file q3networkprotocol.cpp.
References Q3PtrQueue< type >::clear(), d, Q3PtrQueue< type >::dequeue(), Q3NetworkProtocolPrivate::operationQueue, and Q3PtrQueue< type >::setAutoDelete().
Referenced by processNextOperation(), and stop().
00820 { 00821 d->operationQueue.dequeue(); 00822 d->operationQueue.setAutoDelete( true ); 00823 d->operationQueue.clear(); 00824 }
Here is the call graph for this function:

| void Q3NetworkProtocol::stop | ( | ) | [virtual] |
Stops the current operation that is being processed and clears all waiting operations.
Definition at line 831 of file q3networkprotocol.cpp.
References clearOperationQueue(), d, emit, finished(), Q3NetworkOperation::free(), Q3NetworkProtocolPrivate::opInProgress, Q3NetworkOperation::setProtocolDetail(), Q3NetworkOperation::setState(), setUrl(), and StStopped.
Referenced by Q3UrlOperator::stop().
00832 { 00833 Q3NetworkOperation *op = d->opInProgress; 00834 clearOperationQueue(); 00835 if ( op ) { 00836 op->setState( StStopped ); 00837 op->setProtocolDetail( tr( "Operation stopped by the user" ) ); 00838 emit finished( op ); 00839 setUrl( 0 ); 00840 op->free(); 00841 } 00842 }
Here is the call graph for this function:

| void Q3NetworkProtocol::data | ( | const QByteArray & | data, | |
| Q3NetworkOperation * | op | |||
| ) | [signal] |
This signal is emitted when new data has been received after calling get() or put(). op holds the name of the file from which data is retrieved or uploaded in its first argument, and the (raw) data in its second argument. You can get them with op->arg( 0 ) and op->rawArg( 1 ). op is the pointer to the operation object, which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator (which is used by the network protocol) emit its corresponding signal.
Referenced by Q3Http::clientReply(), Q3Ftp::npReadyRead(), Q3LocalFs::operationGet(), Q3Http::post(), Q3Ftp::put(), Q3NetworkProtocol(), Q3Http::request(), and setUrl().
| void Q3NetworkProtocol::connectionStateChanged | ( | int | state, | |
| const QString & | data | |||
| ) | [signal] |
This signal is emitted whenever the state of the connection of the network protocol is changed. state describes the new state, which is one of, ConHostFound, ConConnected or ConClosed. data is a message text.
Referenced by Q3Http::clientStateChanged(), Q3Ftp::npStateChanged(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::finished | ( | Q3NetworkOperation * | op | ) | [signal] |
This signal is emitted when an operation finishes. This signal is always emitted, for both success and failure. op is the pointer to the operation object which contains all the information about the operation, including the state, etc. Check the state and error code of the operation object to determine whether or not the operation was successful.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Http::clientDone(), Q3Ftp::init(), Q3Ftp::npDone(), Q3LocalFs::operationGet(), Q3LocalFs::operationListChildren(), Q3LocalFs::operationMkDir(), Q3LocalFs::operationPut(), Q3LocalFs::operationRemove(), Q3LocalFs::operationRename(), processNextOperation(), Q3NetworkProtocol(), setUrl(), and stop().
| void Q3NetworkProtocol::start | ( | Q3NetworkOperation * | op | ) | [signal] |
Some operations (such as listChildren()) emit this signal when they start processing the operation. op is the pointer to the operation object which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Ftp::operationListChildren(), Q3LocalFs::operationListChildren(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::newChildren | ( | const Q3ValueList< QUrlInfo > & | i, | |
| Q3NetworkOperation * | op | |||
| ) | [signal] |
This signal is emitted after listChildren() was called and new children (files) have been read from the list of files. i holds the information about the new children. op is the pointer to the operation object which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
When implementing your own network protocol and reading children, you usually don't read one child at once, but rather a list of them. That's why this signal takes a list of QUrlInfo objects. If you prefer to read just one child at a time you can use the convenience signal newChild(), which takes a single QUrlInfo object.
Referenced by emitNewChildren(), Q3LocalFs::operationListChildren(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::newChild | ( | const QUrlInfo & | i, | |
| Q3NetworkOperation * | op | |||
| ) | [signal] |
This signal is emitted if a new child (file) has been read. Q3NetworkProtocol automatically connects it to a slot which creates a list of QUrlInfo objects (with just one QUrlInfo i) and emits the newChildren() signal with this list. op is the pointer to the operation object which contains all the information about the operation that has finished, including the state, etc.
This is just a convenience signal useful for implementing your own network protocol. In all other cases connect to the newChildren() signal with its list of QUrlInfo objects.
Referenced by Q3Ftp::npDone(), Q3Ftp::npListInfo(), Q3LocalFs::operationMkDir(), and Q3NetworkProtocol().
| void Q3NetworkProtocol::createdDirectory | ( | const QUrlInfo & | i, | |
| Q3NetworkOperation * | op | |||
| ) | [signal] |
This signal is emitted when mkdir() has been successful and the directory has been created. i holds the information about the new directory. op is the pointer to the operation object which contains all the information about the operation, including the state, etc. Using op->arg( 0 ), you can get the file name of the new directory.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Ftp::npDone(), Q3LocalFs::operationMkDir(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::removed | ( | Q3NetworkOperation * | op | ) | [signal] |
This signal is emitted when remove() has been succesiisful and the file has been removed. op holds the file name of the removed file in the first argument, accessible with op->arg( 0 ). op is the pointer to the operation object which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Ftp::npDone(), Q3LocalFs::operationRemove(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::itemChanged | ( | Q3NetworkOperation * | op | ) | [signal] |
This signal is emitted whenever a file which is a child of this URL has been changed, e.g. by successfully calling rename(). op holds the original and the new file names in the first and second arguments, accessible with op->arg( 0 ) and op->arg( 1 ) respectively. op is the pointer to the operation object which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Ftp::npDone(), Q3LocalFs::operationRename(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::dataTransferProgress | ( | int | bytesDone, | |
| int | bytesTotal, | |||
| Q3NetworkOperation * | op | |||
| ) | [signal] |
This signal is emitted during the transfer of data (using put() or get()). bytesDone is how many bytes of bytesTotal have been transferred. bytesTotal may be -1, which means that the total number of bytes is not known. op is the pointer to the operation object which contains all the information about the operation, including the state, etc.
When a protocol emits this signal, Q3NetworkProtocol is smart enough to let the Q3UrlOperator, which is used by the network protocol, emit its corresponding signal.
Referenced by Q3Http::clientReply(), Q3Ftp::npDataTransferProgress(), Q3LocalFs::operationGet(), Q3LocalFs::operationPut(), Q3NetworkProtocol(), and setUrl().
| void Q3NetworkProtocol::processOperation | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
Definition at line 630 of file q3networkprotocol.cpp.
References Q3NetworkOperation::operation(), operationGet(), operationListChildren(), operationMkDir(), operationPut(), operationRemove(), operationRename(), OpGet, OpListChildren, OpMkDir, OpPut, OpRemove, and OpRename.
Referenced by processNextOperation().
00631 { 00632 if ( !op ) 00633 return; 00634 00635 switch ( op->operation() ) { 00636 case OpListChildren: 00637 operationListChildren( op ); 00638 break; 00639 case OpMkDir: 00640 operationMkDir( op ); 00641 break; 00642 case OpRemove: 00643 operationRemove( op ); 00644 break; 00645 case OpRename: 00646 operationRename( op ); 00647 break; 00648 case OpGet: 00649 operationGet( op ); 00650 break; 00651 case OpPut: 00652 operationPut( op ); 00653 break; 00654 } 00655 }
Here is the call graph for this function:

| void Q3NetworkProtocol::operationListChildren | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports listing children (files); this method should then process this Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 667 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationMkDir | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports making directories; this method should then process this Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 681 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationRemove | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports removing children (files); this method should then process this Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 695 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationRename | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports renaming children (files); this method should then process this Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 709 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationGet | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports getting data; this method should then process the Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 723 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationPut | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
When implementing a new network protocol, this method should be reimplemented if the protocol supports putting (uploading) data; this method should then process the Q3NetworkOperation.
op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.
Definition at line 737 of file q3networkprotocol.cpp.
Referenced by processOperation().
| void Q3NetworkProtocol::operationPutChunk | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
| bool Q3NetworkProtocol::checkConnection | ( | Q3NetworkOperation * | op | ) | [protected, virtual] |
For processing operations the network protocol base class calls this method quite often. This should be reimplemented by new network protocols. It should return true if the connection is OK (open); otherwise it should return false. If the connection is not open the protocol should open it.
If the connection can't be opened (e.g. because you already tried but the host couldn't be found), set the state of op to Q3NetworkProtocol::StFailed and emit the finished() signal with this Q3NetworkOperation as argument.
op is the operation that needs an open connection.
Definition at line 497 of file q3networkprotocol.cpp.
Referenced by processNextOperation().
| void Q3NetworkProtocol::processNextOperation | ( | Q3NetworkOperation * | old | ) | [private, slot] |
Definition at line 756 of file q3networkprotocol.cpp.
References Q3PtrList< type >::append(), Q3NetworkProtocolPrivate::autoDelete, checkConnection(), clearOperationQueue(), d, Q3PtrQueue< type >::dequeue(), emit, finished(), Q3PtrQueue< type >::head(), Q3PtrQueue< type >::isEmpty(), Q3NetworkProtocolPrivate::oldOps, Q3NetworkProtocolPrivate::operationQueue, Q3NetworkProtocolPrivate::opInProgress, Q3NetworkProtocolPrivate::opStartTimer, processOperation(), qDebug(), Q3NetworkProtocolPrivate::removeInterval, Q3NetworkProtocolPrivate::removeTimer, QTimer::start(), Q3NetworkOperation::state(), StFailed, and QTimer::stop().
Referenced by Q3NetworkProtocol(), and startOps().
00757 { 00758 #ifdef Q3NETWORKPROTOCOL_DEBUG 00759 qDebug( "Q3NetworkOperation: process next operation, old: %p", old ); 00760 #endif 00761 d->removeTimer->stop(); 00762 00763 if ( old ) 00764 d->oldOps.append( old ); 00765 if ( d->opInProgress && d->opInProgress!=old ) 00766 d->oldOps.append( d->opInProgress ); 00767 00768 if ( d->operationQueue.isEmpty() ) { 00769 d->opInProgress = 0; 00770 if ( d->autoDelete ) 00771 d->removeTimer->start( d->removeInterval, true ); 00772 return; 00773 } 00774 00775 Q3NetworkOperation *op = d->operationQueue.head(); 00776 00777 d->opInProgress = op; 00778 00779 if ( !checkConnection( op ) ) { 00780 if ( op->state() != Q3NetworkProtocol::StFailed ) { 00781 d->opStartTimer->start( 0, true ); 00782 } else { 00783 d->operationQueue.dequeue(); 00784 clearOperationQueue(); 00785 emit finished( op ); 00786 } 00787 00788 return; 00789 } 00790 00791 d->opInProgress = op; 00792 d->operationQueue.dequeue(); 00793 processOperation( op ); 00794 }
| void Q3NetworkProtocol::startOps | ( | ) | [private, slot] |
Definition at line 615 of file q3networkprotocol.cpp.
References processNextOperation(), and qDebug().
Referenced by Q3NetworkProtocol().
00616 { 00617 #ifdef Q3NETWORKPROTOCOL_DEBUG 00618 qDebug( "Q3NetworkOperation: start processing operations" ); 00619 #endif 00620 processNextOperation( 0 ); 00621 }
| void Q3NetworkProtocol::emitNewChildren | ( | const QUrlInfo & | i, | |
| Q3NetworkOperation * | op | |||
| ) | [private, slot] |
Definition at line 888 of file q3networkprotocol.cpp.
References emit, i, and newChildren().
Referenced by Q3NetworkProtocol().
00889 { 00890 Q3ValueList<QUrlInfo> lst; 00891 lst << i; 00892 emit newChildren( lst, op ); 00893 }
| void Q3NetworkProtocol::removeMe | ( | ) | [private, slot] |
Definition at line 878 of file q3networkprotocol.cpp.
References Q3NetworkProtocolPrivate::autoDelete, d, qDebug(), and Q3NetworkProtocolPrivate::url.
Referenced by Q3NetworkProtocol().
00879 { 00880 if ( d->autoDelete ) { 00881 #ifdef Q3NETWORKPROTOCOL_DEBUG 00882 qDebug( "Q3NetworkOperation: autodelete of Q3NetworkProtocol %p", this ); 00883 #endif 00884 delete d->url; // destructor deletes the network protocol 00885 } 00886 }
Q3NetworkProtocolPrivate* Q3NetworkProtocol::d [private] |
Definition at line 163 of file q3networkprotocol.h.
Referenced by Q3Ftp::abort(), Q3Ftp::addCommand(), addOperation(), autoDelete(), Q3Ftp::bytesAvailable(), Q3Ftp::checkConnection(), clearOperationQueue(), Q3Ftp::clearPendingCommands(), Q3Ftp::currentCommand(), Q3Ftp::currentDevice(), Q3Ftp::currentId(), Q3Ftp::error(), Q3Ftp::errorString(), Q3Ftp::hasPendingCommands(), Q3Ftp::init(), Q3Ftp::npDone(), operationInProgress(), Q3Ftp::piConnectState(), Q3Ftp::piError(), Q3Ftp::piFinished(), Q3Ftp::piFtpReply(), processNextOperation(), Q3NetworkProtocol(), Q3Ftp::readAll(), Q3Ftp::readBlock(), removeMe(), setAutoDelete(), setUrl(), Q3Ftp::startNextCommand(), Q3Ftp::state(), stop(), url(), and ~Q3NetworkProtocol().
1.5.1