// qabstractsocket.sip generated by MetaSIP on Fri Sep 28 17:07:47 2007 // // This file is part of the QtNetwork Python extension module. // // Copyright (c) 2007 // Phil Thompson // // This file is part of PyQt. // // This copy of PyQt is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License version 2 as published by // the Free Software Foundation and appearing in the file LICENSE included in the // packaging of this file. // // PyQt is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // PyQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class QAbstractSocket : QIODevice { %TypeHeaderCode #include %End %ConvertToSubClassCode static struct class_graph { char *name; sipWrapperType **type; int yes, no; } graph[] = { {sipName_QFtp, &sipClass_QFtp, -1, 1}, {sipName_QTcpServer, &sipClass_QTcpServer, -1, 2}, {sipName_QAbstractSocket, &sipClass_QAbstractSocket, 4, 3}, {sipName_QHttp, &sipClass_QHttp, -1, -1}, {sipName_QUdpSocket, &sipClass_QUdpSocket, -1, 5}, {sipName_QTcpSocket, &sipClass_QTcpSocket, 6, -1}, #if QT_VERSION >= 0x040300 && !defined(QT_NO_OPENSSL) {sipName_QSslSocket, &sipClass_QSslSocket, -1, -1}, #else {0, 0, -1, -1}, #endif }; int i = 0; sipClass = NULL; do { struct class_graph *cg = &graph[i]; if (cg->name != NULL && sipCpp->inherits(cg->name)) { sipClass = *cg->type; i = cg->yes; } else i = cg->no; } while (i >= 0); %End public: enum SocketType { TcpSocket, UdpSocket, UnknownSocketType, }; enum NetworkLayerProtocol { IPv4Protocol, IPv6Protocol, UnknownNetworkLayerProtocol, }; enum SocketError { ConnectionRefusedError, RemoteHostClosedError, HostNotFoundError, SocketAccessError, SocketResourceError, SocketTimeoutError, DatagramTooLargeError, NetworkError, AddressInUseError, SocketAddressNotAvailableError, UnsupportedSocketOperationError, UnknownSocketError, %If (Qt_4_3_0 -) UnfinishedSocketOperationError, %End %If (Qt_4_3_0 -) ProxyAuthenticationRequiredError, %End }; enum SocketState { UnconnectedState, HostLookupState, ConnectingState, ConnectedState, BoundState, ListeningState, ClosingState, }; QAbstractSocket(QAbstractSocket::SocketType socketType, QObject *parent /TransferThis/); virtual ~QAbstractSocket(); void connectToHost(const QString &hostName, quint16 port, QFlags mode = QIODevice::ReadWrite) /ReleaseGIL/; void connectToHost(const QHostAddress &address, quint16 port, QFlags mode = QIODevice::ReadWrite) /ReleaseGIL/; void disconnectFromHost() /ReleaseGIL/; bool isValid() const; virtual qint64 bytesAvailable() const; virtual qint64 bytesToWrite() const; virtual bool canReadLine() const; quint16 localPort() const; QHostAddress localAddress() const; quint16 peerPort() const; QHostAddress peerAddress() const; QString peerName() const; qint64 readBufferSize() const; void setReadBufferSize(qint64 size); void abort(); int socketDescriptor() const; bool setSocketDescriptor(int socketDescriptor, QAbstractSocket::SocketState state = QAbstractSocket::ConnectedState, QFlags openMode = QIODevice::ReadWrite); QAbstractSocket::SocketType socketType() const; QAbstractSocket::SocketState state() const; QAbstractSocket::SocketError error() const; virtual void close(); virtual bool isSequential() const; virtual bool atEnd() const; bool flush() /ReleaseGIL/; bool waitForConnected(int msecs = 30000) /ReleaseGIL/; virtual bool waitForReadyRead(int msecs = 30000) /ReleaseGIL/; virtual bool waitForBytesWritten(int msecs = 30000) /ReleaseGIL/; bool waitForDisconnected(int msecs = 30000) /ReleaseGIL/; void setProxy(const QNetworkProxy &networkProxy); QNetworkProxy proxy() const; signals: void hostFound(); void connected(); void disconnected(); void stateChanged(QAbstractSocket::SocketState); void error(QAbstractSocket::SocketError); %If (Qt_4_3_0 -) void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); %End protected slots: void connectToHostImplementation(const QString &hostName, quint16 port, QFlags mode = QIODevice::ReadWrite); void disconnectFromHostImplementation(); protected: virtual SIP_PYOBJECT readData(qint64 maxlen) /ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; %MethodCode // Return the data read or None if there was an error. char *s; if ((s = (char *)sipMalloc(a0)) == NULL) sipIsErr = 1; else { qint64 len; Py_BEGIN_ALLOW_THREADS len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0); Py_END_ALLOW_THREADS if (len < 0) { sipFree((ANY *)s); Py_INCREF(Py_None); sipRes = Py_None; } else { sipRes = PyString_FromStringAndSize(s, len); sipFree((ANY *)s); if (sipRes == NULL) sipIsErr = 1; } } %End virtual SIP_PYOBJECT readLineData(qint64 maxlen) /ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; %MethodCode // Return the data read or None if there was an error. char *s; if ((s = (char *)sipMalloc(a0)) == NULL) sipIsErr = 1; else { qint64 len; Py_BEGIN_ALLOW_THREADS len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0); Py_END_ALLOW_THREADS if (len < 0) { sipFree((ANY *)s); Py_INCREF(Py_None); sipRes = Py_None; } else { sipRes = PyString_FromStringAndSize(s, len); sipFree((ANY *)s); if (sipRes == NULL) sipIsErr = 1; } } %End virtual qint64 writeData(const char *data /Array/, qint64 len /ArraySize/) /ReleaseGIL/; void setSocketState(QAbstractSocket::SocketState state); void setSocketError(QAbstractSocket::SocketError socketError); void setLocalPort(quint16 port); void setLocalAddress(const QHostAddress &address); void setPeerPort(quint16 port); void setPeerAddress(const QHostAddress &address); void setPeerName(const QString &name); private: QAbstractSocket(const QAbstractSocket &); };