/***************************************************************************
 *   Copyright (C) 2005 by xavier helluy   *
 *   xavier.helluy@web.de   *
 *                                                                         *
 *   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.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/

 


#include <kuniqueapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kdebug.h>
// #include <clucenemakeindex.h>
#include <kcluceneindexerdaemon.h>
static const char description[] =
    I18N_NOOP("A KDE KPart Application");

static const char version[] = "0.1";

static KCmdLineOptions options[] =
{
//    { "+[URL]", I18N_NOOP( "Document to open" ), 0 },
	KCmdLineLastOption
};


int main(int argc, char **argv)
{
	KAboutData about("kclucene-indexer-daemon", I18N_NOOP("CLuceneDCOPINDEXER"), version, description,
			 KAboutData::License_GPL, "(C) 2005 xavier helluy", 0, 0, "xavier.helluy@web.de");
	about.addAuthor( "xavier helluy", 0, "xavier.helluy@web.de" );
	KCmdLineArgs::init(argc, argv, &about);
	KCmdLineArgs::addCmdLineOptions( options );
	KUniqueApplication::addCmdLineOptions();
	if (!KUniqueApplication::start()) {
		fprintf(stderr, "clucenedcopindexer is already running!\n");
		exit(0);
	}
	KUniqueApplication myApp;
	myApp.disableSessionManagement();
	kdDebug() << "starting clucenedcopindexer " << endl;
    
    
    
    //this starts a DCOP
	KCLuceneIndexerDaemon * myDaemon = new KCLuceneIndexerDaemon();
    //when a NewQuery is received, it selects a Database and inits a SearchThread
    //the SearchThreads is informed of the applicationId and calls it the results when it has finished searching
    //this starts a thread responsible for running a query
    
    
    
    
	int a =myApp.exec();
	delete  myDaemon;
	return a;
} 
 
