📄 qnetworkprotocol.3qt
字号:
'\" t.TH QNetworkProtocol 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQNetworkProtocol \- Common API for network protocols.SH SYNOPSIS\fC#include <qnetworkprotocol.h>\fR.PPInherits QObject..PPInherited by QFtp, QHttp, and QLocalFs..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBState\fR { StWaiting = 0, StInProgress, StDone, StFailed, StStopped }".br.ti -1c.BI "enum \fBOperation\fR { OpListChildren = 1, OpMkDir = 2, OpMkdir = OpMkDir, OpRemove = 4, OpRename = 8, OpGet = 32, OpPut = 64 }".br.ti -1c.BI "enum \fBConnectionState\fR { ConHostFound, ConConnected, ConClosed }".br.ti -1c.BI "enum \fBError\fR { NoError = 0, ErrValid, ErrUnknownProtocol, ErrUnsupported, ErrParse, ErrLoginIncorrect, ErrHostNotFound, ErrListChildren, ErrListChlidren = ErrListChildren, ErrMkDir, ErrMkdir = ErrMkDir, ErrRemove, ErrRename, ErrGet, ErrPut, ErrFileNotExisting, ErrPermissionDenied }".br.ti -1c.BI "\fBQNetworkProtocol\fR ()".br.ti -1c.BI "virtual \fB~QNetworkProtocol\fR ()".br.ti -1c.BI "virtual void \fBsetUrl\fR ( QUrlOperator * u )".br.ti -1c.BI "virtual void \fBsetAutoDelete\fR ( bool b, int i = 10000 )".br.ti -1c.BI "bool \fBautoDelete\fR () const".br.ti -1c.BI "virtual int \fBsupportedOperations\fR () const".br.ti -1c.BI "virtual void \fBaddOperation\fR ( QNetworkOperation * op )".br.ti -1c.BI "QUrlOperator * \fBurl\fR () const".br.ti -1c.BI "QNetworkOperation * \fBoperationInProgress\fR () const".br.ti -1c.BI "virtual void \fBclearOperationQueue\fR ()".br.ti -1c.BI "virtual void \fBstop\fR ()".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBdata\fR ( const QByteArray & data, QNetworkOperation * op )".br.ti -1c.BI "void \fBconnectionStateChanged\fR ( int state, const QString & data )".br.ti -1c.BI "void \fBfinished\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBstart\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBnewChildren\fR ( const QValueList<QUrlInfo> & i, QNetworkOperation * op )".br.ti -1c.BI "void \fBnewChild\fR ( const QUrlInfo & i, QNetworkOperation * op )".br.ti -1c.BI "void \fBcreatedDirectory\fR ( const QUrlInfo & i, QNetworkOperation * op )".br.ti -1c.BI "void \fBremoved\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBitemChanged\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBdataTransferProgress\fR ( int bytesDone, int bytesTotal, QNetworkOperation * op )".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "void \fBregisterNetworkProtocol\fR ( const QString & protocol, QNetworkProtocolFactoryBase * protocolFactory )".br.ti -1c.BI "QNetworkProtocol * \fBgetNetworkProtocol\fR ( const QString & protocol )".br.ti -1c.BI "bool \fBhasOnlyLocalFileSystem\fR ()".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBoperationListChildren\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual void \fBoperationMkDir\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual void \fBoperationRemove\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual void \fBoperationRename\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual void \fBoperationGet\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual void \fBoperationPut\fR ( QNetworkOperation * op )".br.ti -1c.BI "virtual bool \fBcheckConnection\fR ( QNetworkOperation * op )".br.in -1c.SH DESCRIPTIONThe QNetworkProtocol class provides a common API for network protocols..PPThis 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 QUrlOperator..PPThe 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 QNetworkProtocol::Operation enum..PPWhen 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 \fIand\fR on failure). Qt relies on correctly emitted finished() signals..PPFor a detailed description of the Qt Network Architecture and how to implement and use network protocols in Qt, see the Qt Network Documentation..PPSee also Input/Output and Networking..SS "Member Type Documentation".SH "QNetworkProtocol::ConnectionState"When the connection state of a network protocol changes it emits the signal connectionStateChanged(). The first argument is one of the following values:.TP\fCQNetworkProtocol::ConHostFound\fR - Host has been found..TP\fCQNetworkProtocol::ConConnected\fR - Connection to the host has been established..TP\fCQNetworkProtocol::ConClosed\fR - Connection has been closed..SH "QNetworkProtocol::Error"When an operation fails (finishes unsuccessfully), the QNetworkOperation of the operation returns an error code which has one of the following values:.TP\fCQNetworkProtocol::NoError\fR - No error occurred..TP\fCQNetworkProtocol::ErrValid\fR - The URL you are operating on is not valid..TP\fCQNetworkProtocol::ErrUnknownProtocol\fR - 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)..TP\fCQNetworkProtocol::ErrUnsupported\fR - The operation is not supported by the protocol..TP\fCQNetworkProtocol::ErrParse\fR - The URL could not be parsed correctly..TP\fCQNetworkProtocol::ErrLoginIncorrect\fR - You needed to login but the username or password is wrong..TP\fCQNetworkProtocol::ErrHostNotFound\fR - The specified host (in the URL) couldn't be found..TP\fCQNetworkProtocol::ErrListChildren\fR - An error occurred while listing the children (files)..TP\fCQNetworkProtocol::ErrMkDir\fR - An error occurred when creating a directory..TP\fCQNetworkProtocol::ErrRemove\fR - An error occurred when removing a child (file)..TP\fCQNetworkProtocol::ErrRename\fR - An error occurred when renaming a child (file)..TP\fCQNetworkProtocol::ErrGet\fR - An error occurred while getting (retrieving) data..TP\fCQNetworkProtocol::ErrPut\fR - An error occurred while putting (uploading) data..TP\fCQNetworkProtocol::ErrFileNotExisting\fR - A file which is needed by the operation doesn't exist..TP\fCQNetworkProtocol::ErrPermissionDenied\fR - Permission for doing the operation has been denied..PPYou 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..SH "QNetworkProtocol::Operation"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 QNetworkOperation is always one of these values..TP\fCQNetworkProtocol::OpListChildren\fR - List the children of a URL, e.g. of a directory..TP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -