📄 qnetworkprotocol.3qt
字号:
\fCErrGet\fR - An error occurred while getting (retrieving) data.TP\fCErrPut\fR - An error occurred while putting (uploading) data.TP\fCErrFileNotExisting\fR - A file which is needed by the operation doesn't exist.TP\fCErrPermissionDenied\fR - The permission for doing the operation has been denied.PPWhen implementing custom network protocols, you should also use these values of error codes. If this is not possible, you can define your own ones by using an integer value which doesn't conflict with one of these vales..SH "QNetworkProtocol::Operation"This enum lists all possible operations which a network protocol can support. supportedOperations() returns an int which is or'd together of these values, also the type() or a QNetworkOperation is always one of these values..TP\fCOpListChildren\fR - Listing the children of a URL, e.g. of a directory.TP\fCOpMkdir\fR - Create a directory.TP\fCOpRemove\fR - remove a child (e.g. file).TP\fCOpRename\fR - rename a child (e.g. file ).TP\fCOpGet\fR - get data from a location.TP\fCOpPut\fR - put data to a location.SH "QNetworkProtocol::State"This enum contains the state which a QNetworkOperation can have:.TP\fCStWaiting\fR - The operation is in the queue of the QNetworkProtocol and is waiting for being prcessed.TP\fCStInProgress\fR - The operation is just processed.TP\fCStDone\fR - The operation has been processed succesfully.TP\fCStFailed\fR - The operation has been processed but an error occurred.TP\fCStStopped\fR - The operation has been processed but has been stopped before it finished.SH MEMBER FUNCTION DOCUMENTATION.SH "QNetworkProtocol::QNetworkProtocol ()"Constructor of the network protocol baseclass. Does some initialization and connecting of signals and slots..SH "QNetworkProtocol::~QNetworkProtocol () \fC[virtual]\fR"Destructor..SH "void QNetworkProtocol::addOperation ( QNetworkOperation * op ) \fC[virtual]\fR"Adds the operation \fIop\fR the operation queue. The operation will be processed as soon as possible. This method returns immediately..SH "bool QNetworkProtocol::autoDelete () const"Returns TRUE, of autodeleting is enabled, else FALSE..PPSee also QNetworkProtocol::setAutoDelete()..SH "bool QNetworkProtocol::checkConnection ( QNetworkOperation * ) \fC[virtual protected]\fR"For processing operations the newtork protocol baseclass calls this method quite often. This should be reimplemented by new network protocols. It should return TRUE, if the connection is ok (open), else FALSE. If the connection is not open, the protocol should open it..PPIf the connection can't be opened (e.g. because you already tried it, but the host couldn't be found or something like that), set the state of \fIop\fR to QNetworkProtocol::StFailed and emit the finished() signal with this QNetworkOperation as argument..PP\fIop\fR is the operation which needs an open connection..PPReimplemented in QFtp..SH "void QNetworkProtocol::clearOperationQueue () \fC[virtual]\fR"Clears the operation queue..SH "void QNetworkProtocol::connectionStateChanged ( int state, const QString & data ) \fC[signal]\fR"This signal is emitted whenever the state of the connection of the network protocol is changed. \fIstate\fR describes the new state, which is one of ConHostFound, ConConnected, ConClosed \fIdata\fR is a message text..SH "void QNetworkProtocol::createdDirectory ( const QUrlInfo & i, QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted when mkdir() has been succesful and the directory has been created. \fIi\fR holds the information about the new directory. \fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on and using op->arg( 0 ) you also get the filename of the new directory..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::data ( const QByteArray & data, QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted when new \fIdata\fR has been received after e.g. calling get() or put(). \fIop\fR holds the name of the file which data is retrieved in the first argument and the data in the second argument (raw). You get them with op->arg( 0 ) and op->rawArg( 1 )..PP\fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::dataTransferProgress ( int bytesDone, int bytesTotal, QNetworkOperation * op ) \fC[signal]\fR"When transferring data (using put() or get()) this signal is emitted during the progress. \fIbytesDone\fR tells how many bytes of \fIbytesTotal\fR are transferred. More information about the operation is stored in the \fIop,\fR the pointer to the network operation which is processed. \fIbytesTotal\fR may be -1, which means that the number of total bytes is not known..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::finished ( QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted when an operation of some sort finished. This signal is emitted always, this means on success and on failure. \fIop\fR is the pointer to the operation object, which contains all infos of the operation which has been finished, including the state and so on. To check if the operation was successful or not, check the state and error code of the operation object..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "QNetworkProtocol * QNetworkProtocol::getNetworkProtocol ( const QString & protocol ) \fC[static]\fR"Static method to get a new instance of a network protocol. E.g. if you need to do some FTP operations, do.PPQFtp *ftp = QNetworkProtocol::getNetworkProtocol( "ftp" );.PPThis returns now either NULL, if no protocol for ftp was registered, or a pointer to a new instance of an FTP implementation. The ownership of the pointer is transferred to you, so you have to delete it, if you don磘 need it anymore..PPNormally you should not work directly with network protocols, so you will not need to call this method yourself. Rather use the QUrlOperator, which makes working with network protocols much more convenient..PPSee also QUrlOperator..SH "bool QNetworkProtocol::hasOnlyLocalFileSystem () \fC[static]\fR"Returns TRUE, if only a protocol for working on the local filesystem is registered, or FALSE if also other network protocols are registered..SH "void QNetworkProtocol::itemChanged ( QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted whenever a file, which is a child of this URL, has been changed e.g. by successfully calling rename(). \fIop\fR holds the original and the new filenames in the first and second arguments. You get them with op->arg( 0 ) and op->arg( 1 )..PP\fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::newChild ( const QUrlInfo & i, QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted if a new child has been read. QNetworkProtocol automatically connects that to a slot which creates a list of QUrlInfo objects (with just the one QUrlInfo \fIi)\fR and emits then newChildren() signal with this created list..PPSo this is just a convenience signal when implementing an own network protocol. In all other cases just care about the newChildren() signal with the list of QUrlInfo objects..SH "void QNetworkProtocol::newChildren ( const QValueList<QUrlInfo> & i, QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted after listChildren() was called and new children (e.g. files) have been read from list of files. \fIi\fR holds the information about the new children. \fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..PPWhen implementing an own network protocol and reading children in most cases you don't read one child at once, but a list of them. That's why this signal takes a list of QUrlInfo objects. But if you read only one child at once, you can use the convenience signal newChild(), which takes only a single QUrlInfo object..SH "void QNetworkProtocol::operationGet ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports getting data, and process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "QNetworkOperation * QNetworkProtocol::operationInProgress () const"Returns the operation, which is just processed, or NULL of none is processed at the moment..SH "void QNetworkProtocol::operationListChildren ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports listing children, and this method should then process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "void QNetworkProtocol::operationMkDir ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports making directories, and this method should then process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "void QNetworkProtocol::operationPut ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports putting data, and this method should then process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "void QNetworkProtocol::operationRemove ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports removing children, and this method should then process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "void QNetworkProtocol::operationRename ( QNetworkOperation * ) \fC[virtual protected]\fR"When implemeting a new newtork protocol this method should be reimplemented, if the protocol supports renaming children, and this method should then process this QNetworkOperation..PPWhen you reimplement this method, it's very important that you emit the correct signals at the correct time (esp. the finished() signal after processing an operation). So have a look at the Qt Network Documentation, there it is described in detail how to reimplement this method. Also you may look at the example implementation of qt/extenstions/network/examples/networkprotocol/nntp.cpp..SH "void QNetworkProtocol::registerNetworkProtocol ( const QString & protocol, QNetworkProtocolFactoryBase * protocolFactory ) \fC[static]\fR"Static method to register a network protocol for Qt. E.g. if you have a implementation of NNTP (called Nntp), which is derived from QNetworkProtocol, call.PPQNetworkProtocol::registerNetworkProtocol( "nntp", new QNetworkProtocolFactory<Nntp> );.PPAfter that, this implementation is registered for nntp operations..SH "void QNetworkProtocol::removed ( QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted when remove() has been succesful and the file has been removed. \fIop\fR holds the filename of the removed file in the first argument, you get it with op->arg( 0 )..PP\fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::setAutoDelete ( bool b, int i = 10000 ) \fC[virtual]\fR"Because it's sometimes hard to care about removing network protocol instances, QNetworkProtocol provides an autodelete mechanism. If you set \fIb\fR to TRUE, this network protocol instance gets removed after it has been \fIi\fR milliseconds inactive (this means \fIi\fR ms after the last operation has been processed). If you set \fIb\fR to FALSE, the autodelete mechanism is switched off..PPNOTE: If you switch on autodeleting, the QNetworkProtocol also deletes its QUrlOperator!..SH "void QNetworkProtocol::setUrl ( QUrlOperator * u ) \fC[virtual]\fR"Sets the QUrlOperator, on which the protocol works..PPSee also QUrlOperator..SH "void QNetworkProtocol::start ( QNetworkOperation * op ) \fC[signal]\fR"Some operations (like listChildren()) emit this signal when they start processing the operation. \fIop\fR is the pointer to the operation object, which contains all infos of the operation, including the state and so on..PPWhen a protocol emits this signal, QNetworkProtocol is smart enough to let the QUrlOperator, which is used by the network protocol, emit its corresponding signal..SH "void QNetworkProtocol::stop () \fC[virtual]\fR"Stops the current operation which is just processed and clears all waiting operations..SH "int QNetworkProtocol::supportedOperations () const \fC[virtual]\fR"Returns an int, which is or'd together using the enum values of \fCQNetworkProtocol::Operation,\fR which describes which operations are supported by the network protocol. Should be reimplemented by new network protocols..SH "QUrlOperator * QNetworkProtocol::url () const"Returns the QUrlOperator on which the protocol works..SH "void QNetworkProtocol::processOperation ( QNetworkOperation * op ) \fC[virtual protected]\fR"For internal use only..SH "SEE ALSO".BR http://doc.trolltech.com/qnetworkprotocol.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qnetworkprotocol.3qt) and the Qtversion (2.3.10).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -