From 16434e5519f6224e231bc5f7202f0e495eda7bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 3 Jan 2023 00:52:18 +0100 Subject: Do rename qt=>tqt on source files, directories and libraries. Rename pyuic=>pytquic, pylupdate=>pytqlupdate. Do rename qt=>tqt on constants and variables. Do rename QT=>TQT on constants. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- sip/tqtnetwork/tqhttp.sip | 263 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 sip/tqtnetwork/tqhttp.sip (limited to 'sip/tqtnetwork/tqhttp.sip') diff --git a/sip/tqtnetwork/tqhttp.sip b/sip/tqtnetwork/tqhttp.sip new file mode 100644 index 0000000..2f80e22 --- /dev/null +++ b/sip/tqtnetwork/tqhttp.sip @@ -0,0 +1,263 @@ +// This is the SIP interface definition for TQHttp, TQHttpHeader, +// TQHttpRequestHeader and TQHttpResponseHeader. +// +// Copyright (c) 2007 +// Riverbank Computing Limited +// +// This file is part of PyTQt. +// +// This copy of PyTQt is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2, or (at your option) any later +// version. +// +// PyTQt 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 +// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +%ExportedDoc +TQHttp (TQt v3+) + + TQ_LONG readBlock + char *data + TQ_ULONG maxlen + + +This takes a single maxlen parameter. The +data is returned if there was no error, otherwise +None is returned. + + + +TQHttpHeader (TQt v3.1+) + +TQHttpHeader is fully implemented. + + + +TQHttpRequestHeader (TQt v3.1+) + +TQHttpRequestHeader is fully implemented. + + + +TQHttpResponseHeader (TQt v3.1+) + +TQHttpResponseHeader is fully implemented. + + +%End + + +%If (TQt_NETWORKPROTOCOL_HTTP) + +class TQHttpHeader +{ +%TypeHeaderCode +#include +%End + +public: + TQHttpHeader(); + TQHttpHeader(const TQHttpHeader &); + TQHttpHeader(const TQString &); + virtual ~TQHttpHeader(); + + TQString value(const TQString &) const; + void setValue(const TQString &,const TQString &); + void removeValue(const TQString &); + + TQStringList keys() const; + bool hasKey(const TQString &) const; + + bool hasContentLength() const; + uint contentLength() const; + void setContentLength(int); + + bool hasContentType() const; + TQString contentType() const; + void setContentType(const TQString &); + + virtual TQString toString() const; + bool isValid() const; + + virtual int majorVersion() const = 0; + virtual int minorVersion() const = 0; + +protected: + virtual bool parseLine(const TQString &,int); + bool parse(const TQString &); + void setValid(bool); +}; + + +class TQHttpResponseHeader : TQHttpHeader +{ +%TypeHeaderCode +#include +%End + +public: + TQHttpResponseHeader(); + TQHttpResponseHeader(const TQHttpResponseHeader &); + + int statusCode() const; + TQString reasonPhrase() const; + + int majorVersion() const; + int minorVersion() const; + + TQString toString() const; + +protected: + bool parseLine(const TQString &,int); +}; + + +class TQHttpRequestHeader : TQHttpHeader +{ +%TypeHeaderCode +#include +%End + +public: + TQHttpRequestHeader(); + TQHttpRequestHeader(const TQString &,const TQString &,int = 1,int = 1); + TQHttpRequestHeader(const TQHttpRequestHeader &); + TQHttpRequestHeader(const TQString &); + + void setRequest(const TQString &,const TQString &,int = 1,int = 1); + + TQString method() const; + TQString path() const; + + int majorVersion() const; + int minorVersion() const; + + TQString toString() const; + +protected: + bool parseLine(const TQString &,int); +}; + + +class TQHttp : TQNetworkProtocol +{ +%TypeHeaderCode +#include +%End + +public: + TQHttp(); + TQHttp(TQObject * /TransferThis/,const char * = 0); + TQHttp(const TQString &,TQ_UINT16 = 80,TQObject * /TransferThis/ = 0, + const char * = 0); + virtual ~TQHttp(); + + int supportedOperations() const; + + enum State { + Unconnected, + HostLookup, + Connecting, + Sending, + Reading, + Connected, + Closing + }; + + enum Error { + NoError, + UnknownError, + HostNotFound, + ConnectionRefused, + UnexpectedClose, + InvalidResponseHeader, + WrongContentLength, + Aborted + }; + + int setHost(const TQString &,TQ_UINT16 = 80); + + int get(const TQString &,TQIODevice * = 0) /ReleaseGIL/; + int post(const TQString &,TQIODevice *,TQIODevice * = 0) /ReleaseGIL/; + int post(const TQString &,const TQByteArray &, + TQIODevice * = 0) /ReleaseGIL/; + int head(const TQString &) /ReleaseGIL/; + int request(const TQHttpRequestHeader &,TQIODevice * = 0, + TQIODevice * = 0) /ReleaseGIL/; + int request(const TQHttpRequestHeader &,const TQByteArray &, + TQIODevice * = 0) /ReleaseGIL/; + + int closeConnection(); + + unsigned long bytesAvailable() const; + + SIP_PYOBJECT readBlock(TQ_ULONG) /ReleaseGIL/ [TQ_LONG (char *,TQ_ULONG)]; +%MethodCode + char *buf; + + if ((buf = (char *)sipMalloc(a0)) == NULL) + sipIsErr = 1; + else + { + TQ_LONG actlen; + + Py_BEGIN_ALLOW_THREADS + actlen = sipCpp -> TQHttp::readBlock(buf,a0); + Py_END_ALLOW_THREADS + + if (actlen < 0) + { + Py_INCREF(Py_None); + sipRes = Py_None; + } + else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL) + sipIsErr = 1; + + sipFree((void *)buf); + } +%End + + TQByteArray readAll() /ReleaseGIL/; + + int currentId() const; + TQIODevice *currentSourceDevice() const; + TQIODevice *currentDestinationDevice() const; + TQHttpRequestHeader currentRequest() const; + bool hasPendingRequests() const; + void clearPendingRequests(); + + State state() const; + + Error error() const; + TQString errorString() const; + +public slots: + void abort(); + +signals: + void stateChanged(int); + void responseHeaderReceived(const TQHttpResponseHeader &); + void readyRead(const TQHttpResponseHeader &); + void dataSendProgress(int,int); + void dataReadProgress(int,int); + + void requestStarted(int); + void requestFinished(int,bool); + void done(bool); + +protected: + void operationGet(TQNetworkOperation *); + void operationPut(TQNetworkOperation *); + + void timerEvent(TQTimerEvent *); +}; + +%End -- cgit v1.2.1