/*
  main.cpp - The KControl module for ktalkd

  Copyright (C) 1998 by David Faure, faure@kde.org
  
  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 Street, Fifth Floor, Boston, MA  02110-1301, USA.
   
  */


#include "main.h"
#include "soundpage.h"
#include "answmachpage.h"
#include "forwmachpage.h"
#include <ksimpleconfig.h>
#include <tdelocale.h>
#include <tdeglobal.h>
#include <tqtabwidget.h>
#include <tqlayout.h>

KTalkdConfigModule::KTalkdConfigModule(TQWidget *parent, const char *name)
    : TDECModule(parent, name)
{
    config = new KSimpleConfig("ktalkdrc");
    announceconfig = new KSimpleConfig("ktalkannouncerc");

	TQVBoxLayout *layout = new TQVBoxLayout(this);
    
	tab = new TQTabWidget(this);
    
	layout->addWidget(tab);

	soundpage = new KSoundPageConfig(this, "soundpage", config, announceconfig);
	answmachpage = new KAnswmachPageConfig(this, "answmachpage", config);
	forwmachpage = new KForwmachPageConfig(this, "forwmachpage", config);

	tab->addTab(soundpage, i18n("&Announcement"));
	tab->addTab(answmachpage, i18n("Ans&wering Machine"));
	tab->addTab(forwmachpage, i18n("forward call", "&Forward"));
	    
	connect(soundpage, TQ_SIGNAL(changed(bool)), this, TQ_SIGNAL(changed(bool)));
	connect(answmachpage, TQ_SIGNAL(changed(bool)), this, TQ_SIGNAL(changed(bool)));
	connect(forwmachpage, TQ_SIGNAL(changed(bool)), this, TQ_SIGNAL(changed(bool)));
	    }
	    
KTalkdConfigModule::~KTalkdConfigModule() {
	delete config;
	delete announceconfig;
	}

void KTalkdConfigModule::defaults() 
{
    if (soundpage) soundpage->defaults();
    if (answmachpage) answmachpage->defaults();    
    if (forwmachpage) forwmachpage->defaults();    
}

void KTalkdConfigModule::save()
{
    if (soundpage) soundpage->save();
    if (answmachpage) answmachpage->save();
    if (forwmachpage) forwmachpage->save();
}

void KTalkdConfigModule::load()
{
    if (soundpage) soundpage->load();
    if (answmachpage) answmachpage->load();
    if (forwmachpage) forwmachpage->load();
}

void KTalkdConfigModule::resizeEvent(TQResizeEvent *)
{
	tab->setGeometry(0,0,width(),height());
}

TQString KTalkdConfigModule::handbookSection() const
{
	// FIXME
	// No context-sensitive help documentation currently exists for this module!
	int index = tab->currentPageIndex();
	if (index == 0) {
		//return "";
		return TQString::null;
	}
	else {
		return TQString::null;
	}
}

extern "C"
{
	KDE_EXPORT TDECModule *create_ktalkd(TQWidget *parent, const char *)
	{
		return new KTalkdConfigModule(parent, "kcmktalkd");
}

	KDE_EXPORT TDECModule *create_ktalkd_answmach(TQWidget *parent, const char *)
{
		return new KAnswmachPageConfig(parent, "kcmktalkd");
	}

	KDE_EXPORT TDECModule *create_ktalkd_sound(TQWidget *parent, const char *)
	{
		return new KSoundPageConfig(parent, "kcmktalkd");
	}

	KDE_EXPORT TDECModule *create_ktalkd_forwmach(TQWidget *parent, const char *)
	{
		return new KForwmachPageConfig(parent, "kcmktalkd");
	}
}

#include "main.moc"

