// This is the SIP interface definition for QNetworkOperation, QNetworkProtocol
// and QNetworkProtocolFactoryBase.
//
// Copyright (c) 2007
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// 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 as published by the Free
// Software Foundation; either version 2, or (at your option) any later
// version.
// 
// 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.


%ExportedDoc
<Sect2><Title>QNetworkOperation (Qt v2.1+)</Title>
<Para>
<Literal>QNetworkOperation</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>QNetworkProtocol (Qt v2.1+)</Title>
<Para>
<Literal>QNetworkProtocol</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>QNetworkProtocolFactoryBase (Qt v2.1+)</Title>
<Para>
<Literal>QNetworkProtocolFactoryBase</Literal> is fully implemented.
</Para>
</Sect2>
%End


%If (Qt_NETWORKPROTOCOL)
%If (Qt_2_1_0 -)

class QNetworkProtocolFactoryBase
{
%TypeHeaderCode
#include <qnetworkprotocol.h>
%End

public:
	virtual QNetworkProtocol *createObject() = 0 /Factory/;

};


class QNetworkProtocol : QObject
{
%TypeHeaderCode
#include <qnetworkprotocol.h>
%End

public:
	enum State {
		StWaiting,
		StInProgress,
		StDone,
		StFailed,
		StStopped
	};

%If (- Qt_3_0_0)
	enum Operation {
		OpListChildren,
		OpMkdir,
		OpRemove,
		OpRename,
		OpGet,
		OpPut
	};
%End
%If (Qt_3_0_0 -)
	enum Operation {
		OpListChildren,
		OpMkDir,
		OpRemove,
		OpRename,
		OpGet,
		OpPut
	};
%End

	enum ConnectionState {
		ConHostFound,
		ConConnected,
		ConClosed
	};

%If (- Qt_3_0_0)
	enum Error {
		NoError,
		ErrValid,
		ErrUnknownProtocol,
		ErrUnsupported,
		ErrParse,
		ErrLoginIncorrect,
		ErrHostNotFound,
		ErrListChlidren,
		ErrMkdir,
		ErrRemove,
		ErrRename,
		ErrGet,
		ErrPut,
		ErrFileNotExisting,
		ErrPermissionDenied
	};
%End
%If (Qt_3_0_0 -)
	enum Error {
		NoError,
		ErrValid,
		ErrUnknownProtocol,
		ErrUnsupported,
		ErrParse,
		ErrLoginIncorrect,
		ErrHostNotFound,
		ErrListChildren,
		ErrMkDir,
		ErrRemove,
		ErrRename,
		ErrGet,
		ErrPut,
		ErrFileNotExisting,
		ErrPermissionDenied
	};
%End

	QNetworkProtocol();

	virtual void setUrl(QUrlOperator *);

	virtual void setAutoDelete(bool,int = 10000);
	bool autoDelete() const;

	static void registerNetworkProtocol(const QString &,
					    QNetworkProtocolFactoryBase *);
	static QNetworkProtocol *getNetworkProtocol(const QString &) /Factory/;
	static bool hasOnlyLocalFileSystem();

	virtual int supportedOperations() const;
	virtual void addOperation(QNetworkOperation *);

	QUrlOperator *url() const;
	QNetworkOperation *operationInProgress() const;
	virtual void clearOperationQueue();
	virtual void stop();

signals:
	void data(const QByteArray &,QNetworkOperation *);
	void connectionStateChanged(int,const QString &);
	void finished(QNetworkOperation *);
	void start(QNetworkOperation *);
	void newChildren(const QValueList<QUrlInfo> &,QNetworkOperation *);
	void newChild(const QUrlInfo &,QNetworkOperation *);
	void createdDirectory(const QUrlInfo &,QNetworkOperation *);
	void removed(QNetworkOperation *);
	void itemChanged(QNetworkOperation *);
	void dataTransferProgress(int,int,QNetworkOperation *);

protected:
	virtual void processOperation(QNetworkOperation *);
	virtual void operationListChildren(QNetworkOperation *);
	virtual void operationMkDir(QNetworkOperation *);
	virtual void operationRemove(QNetworkOperation *);
	virtual void operationRename(QNetworkOperation *);
	virtual void operationGet(QNetworkOperation *);
	virtual void operationPut(QNetworkOperation *);
%If (Qt_3_0_0 -)
	virtual void operationPutChunk(QNetworkOperation *);
%End
	virtual bool checkConnection(QNetworkOperation *);

private:
%If (Qt_3_1_0 -)
	QNetworkProtocol(const QNetworkProtocol &);
%End
};


class QNetworkOperation : QObject
{
%TypeHeaderCode
#include <qnetworkprotocol.h>
%End

public:
	QNetworkOperation(QNetworkProtocol::Operation,const QString &,
			  const QString &,const QString &);
	QNetworkOperation(QNetworkProtocol::Operation,const QByteArray &,
			  const QByteArray &,const QByteArray &);

	void setState(QNetworkProtocol::State);
	void setProtocolDetail(const QString &);
	void setErrorCode(int);
	void setArg(int,const QString &);
	void setRawArg(int,const QByteArray &);

	QNetworkProtocol::Operation operation() const;
	QNetworkProtocol::State state() const;
	QString arg(int) const;
	QByteArray rawArg(int) const;
	QString protocolDetail() const;
	int errorCode() const;

	void free();

private:
%If (Qt_3_1_0 -)
	QNetworkOperation(const QNetworkOperation &);
%End
};

%End
%End
