// This is the SIP interface definition for TQNetworkOperation, TQNetworkProtocol
// and TQNetworkProtocolFactoryBase.
//
// Copyright (c) 2007
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// 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
<Sect2><Title>TQNetworkOperation (TQt v2.1+)</Title>
<Para>
<Literal>TQNetworkOperation</Literal> is fully implemented.
</Para>
</Sect2>

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

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


%If (TQt_NETWORKPROTOCOL)
%If (TQt_2_1_0 -)

class TQNetworkProtocolFactoryBase
{
%TypeHeaderCode
#include <tqnetworkprotocol.h>
%End

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

};


class TQNetworkProtocol : TQObject
{
%TypeHeaderCode
#include <tqnetworkprotocol.h>
%End

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

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

	enum ConnectionState {
		ConHostFound,
		ConConnected,
		ConClosed
	};

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

	TQNetworkProtocol();

	virtual void setUrl(TQUrlOperator *);

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

	static void registerNetworkProtocol(const TQString &,
					    TQNetworkProtocolFactoryBase *);
	static TQNetworkProtocol *getNetworkProtocol(const TQString &) /Factory/;
	static bool hasOnlyLocalFileSystem();

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

	TQUrlOperator *url() const;
	TQNetworkOperation *operationInProgress() const;
	virtual void clearOperationQueue();
	virtual void stop();

signals:
	void data(const TQByteArray &,TQNetworkOperation *);
	void connectionStateChanged(int,const TQString &);
	void finished(TQNetworkOperation *);
	void start(TQNetworkOperation *);
	void newChildren(const TQValueList<TQUrlInfo> &,TQNetworkOperation *);
	void newChild(const TQUrlInfo &,TQNetworkOperation *);
	void createdDirectory(const TQUrlInfo &,TQNetworkOperation *);
	void removed(TQNetworkOperation *);
	void itemChanged(TQNetworkOperation *);
	void dataTransferProgress(int,int,TQNetworkOperation *);

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

private:
%If (TQt_3_1_0 -)
	TQNetworkProtocol(const TQNetworkProtocol &);
%End
};


class TQNetworkOperation : TQObject
{
%TypeHeaderCode
#include <tqnetworkprotocol.h>
%End

public:
	TQNetworkOperation(TQNetworkProtocol::Operation,const TQString &,
			  const TQString &,const TQString &);
	TQNetworkOperation(TQNetworkProtocol::Operation,const TQByteArray &,
			  const TQByteArray &,const TQByteArray &);

	void setState(TQNetworkProtocol::State);
	void setProtocolDetail(const TQString &);
	void setErrorCode(int);
	void setArg(int,const TQString &);
	void setRawArg(int,const TQByteArray &);

	TQNetworkProtocol::Operation operation() const;
	TQNetworkProtocol::State state() const;
	TQString arg(int) const;
	TQByteArray rawArg(int) const;
	TQString protocolDetail() const;
	int errorCode() const;

	void free();

private:
%If (TQt_3_1_0 -)
	TQNetworkOperation(const TQNetworkOperation &);
%End
};

%End
%End
