// 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)

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
	};

	enum Operation {
		OpListChildren,
		OpMkDir,
		OpRemove,
		OpRename,
		OpGet,
		OpPut
	};

	enum ConnectionState {
		ConHostFound,
		ConConnected,
		ConClosed
	};

	enum Error {
		NoError,
		ErrValid,
		ErrUnknownProtocol,
		ErrUnsupported,
		ErrParse,
		ErrLoginIncorrect,
		ErrHostNotFound,
		ErrListChildren,
		ErrMkDir,
		ErrRemove,
		ErrRename,
		ErrGet,
		ErrPut,
		ErrFileNotExisting,
		ErrPermissionDenied
	};

	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 *);
	virtual void operationPutChunk(TQNetworkOperation *);
	virtual bool checkConnection(TQNetworkOperation *);

private:
	TQNetworkProtocol(const TQNetworkProtocol &);
};


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:
	TQNetworkOperation(const TQNetworkOperation &);
};

%End
