/***************************************************************************
 *   Copyright (C) 2005 by xavier helluy				   *
 *   xavier.helluy@web.de						   *
 *   dbera.web@gmail.com						   *
 *                                                                         *
 *   This program 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 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef BEAGLETHREAD_H
#define BEAGLETHREAD_H


#include "searchthread.h"
#include "qdatastream.h"

extern "C" {
#include <glib.h>
#include <beagle/beagle.h>
#include <beagle/beagle-query-part-property.h>
}

/**
@author xavier helluy
*/

class BeagleThread : public SearchThread
{

	public:
		BeagleThread(QObject * o , const QString & str , QString  socketPath ,
			  QDict <ClientList> * QueryList ,
			  const bool &peer2peer );
		
    		~BeagleThread();

		
		BeagleClient *			       m_beagleClient;
		void hitsAddedCallback(BeagleQuery *, BeagleHitsAddedResponse *);
		void searchFinishedCallback(BeagleQuery *, BeagleFinishedResponse *);

		GMainLoop *			       m_mainloop;

		QStringList			       m_resultsList;
		QStringList 			       m_resultsDisplay;
		QStringList 			       m_resultsMimeType;
		QStringList 			       m_resultsModTime;
		QStringList 			       m_resultsMode;
		QStringList 			       m_resultsSize;
		QStringList 			       m_resultsStoredPreview;

		// SearchThread interface
		void run ();
		void encodeHits( void *hit_list ); // in beaglethread this will be GSList *
};

// callbacks
void hits_added_cb (BeagleQuery *, BeagleHitsAddedResponse *, BeagleThread *);
void finished_cb (BeagleQuery *, BeagleFinishedResponse *, BeagleThread *);

#endif
