/* This file is part of the KDE project
   Copyright (c) 2004 Kevin Ottens <ervin ipsquad net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KIO_REMOTE_H
#define KIO_REMOTE_H


#include <kdirlister.h>
#include <kio/slavebase.h>
#include <kio/forwardingslavebase.h>

#include "kwestimpl.h"

//#include "kio_clucene_dcopiface.h"
#include <dcopobject.h>
#include <dcopclient.h>
#include <kprocess.h>
#include "mydirlister.h"

class KwestProtocol : public KIO::ForwardingSlaveBase
{
	Q_OBJECT
public:
	KwestProtocol(const QCString &protocol, const QCString &pool,
	               const QCString &app);
	virtual ~KwestProtocol();
	
	void symlink( const QString &   target,const KURL &   dest, bool   overwrite);

	bool rewriteURL(const KURL &url, KURL &newUrl);
	
	virtual void mkdir(const KURL &url, int permissions);
	virtual void prepareUDSEntry(KIO::UDSEntry & entry, bool   listing );
	virtual void copy(KURL src , KURL dest, int perms, bool over);
	virtual void listDir(const KURL &url);
	virtual void stat(const KURL &url);
	virtual void del(const KURL &url, bool isFile);
	virtual void get(const KURL &);
	
	KURL m_currentURL;
	MyDirLister *m_lister;
	
// 	void mimetype(const KURL & url);

	void notifyRootDirChanged();
	
	//KProcess stuff
	//or dcop stuff
	//QString getQueryString(const QString);
	
	bool m_AllHitsAreHere;
	bool m_HighlightingsReceived;
	
	//create and write to disk a query-desktopfile  FIXME:must be in impl
	void createDesktopFile(const QString &   target);
	
	public slots:
		void processKwestHits();
		void processKwestHighlightings();
		void processCluceneFinished();
		void processAllHitsAreHere();
		
		//comm with external apps
		bool processGUIOutput();
		bool processConfigOutput();
		
		//config stuff
	
		//void KwestProtocol::saveProperties(KConfig *config);
		//void KwestProtocol::readProperties(KConfig *config);
		
		//dirlister stuff
		void gotDirListerCanceled(const KURL &);
		void gotDirListerCanceled();
	signals:
		void kwestFinished();
		
		
	

private:
	

	void listRoot();
	
	KwestImpl m_impl;
	int m_Redirected ;//
	int m_rootUpdated;//
	int m_fromListDir;//
	int m_fromStat;//
	QString m_stored_queriesDir;
	
	
};

#endif
