/***************************************************************************
                          sitemanagerdbapp.cpp  -  description
                             -------------------
    begin                : tis mar 12 2002
    copyright            : (C) 2003 by Björn Sahlström
    email                : kbjorn@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

//////////////////////////////////////////////////////////////////////
// Qt specific include files
#include <qlayout.h>
//////////////////////////////////////////////////////////////////////
// KDE specific include files
#include <kaboutapplication.h>
#include <kaboutdata.h>
#include <kstartupinfo.h>
#include <kglobal.h>
#include <klocale.h>
#include <kiconloader.h>
#include <dcopclient.h>
#include <kdebug.h>
//////////////////////////////////////////////////////////////////////
// Application specific include files
#include "sitemanagerdbapp.h"

//-----------------------------------------------
SiteManagerDBApp::SiteManagerDBApp()
	:	KUniqueApplication( false, true ),
		m_siteManagerDB( 0L )
	
{
	if( ! kapp->dcopClient()->isRegistered() ) {
		kapp->dcopClient()->attach();
		kapp->dcopClient()->registerAs( "kbearsitemanagerdb" );
	}
	kapp->dcopClient()->setDaemonMode( true );
	

/*
	KAboutContainer* about = new KAboutContainer;
	about->addImage( KGlobal::iconLoader()->iconPath( "kbearsitemanager", KIcon::Desktop ) );
	KAboutPerson p = aboutData()->authors().first();
	about->addTitle( aboutData()->programName() + aboutData()->version() );
	about->addPerson( p.name(), p.emailAddress(), p.webAddress(), p.task() );
	setMainWidget( about );
*/
}
//-----------------------------------------------
SiteManagerDBApp::~SiteManagerDBApp(){
	m_siteManagerDB->save();
	if( m_siteManagerDB )
		delete m_siteManagerDB;
}
//-----------------------------------------------
int SiteManagerDBApp::newInstance() {
	KStartupInfo::appStarted();
	// Check if we already have a database
	if( ! m_siteManagerDB) {
		m_siteManagerDB = new SiteManagerDB();
	}
	return 0;
}
//-----------------------------------------------
