/*
    smpppdcsplugin.h

    Copyright (c) 2002-2003 by Chris Howells         <howells@kde.org>
    Copyright (c) 2003      by Martijn Klingens      <klingens@kde.org>
    Copyright (c) 2004-2006 by Heiko Schaefer        <heiko@rangun.de>

    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@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; version 2 of the License.               *
    *                                                                       *
    *************************************************************************
*/

#ifndef SMPPPDCSPLUGIN_H
#define SMPPPDCSPLUGIN_H

#include "detector.h"
#include "iconnector.h"
#include "smpppdcsiface.h"

#include "kopeteplugin.h"
#include "kopeteaccount.h"
#include <QByteArray>

class QTimer;
class Detector;
class OnlineInquiry;

/**
 * @brief Plugin for the detection of an internet connection
 *
 * This plugin inquires either the smpppd or netstat
 * for an existing internet connection and depending
 * on that connects or disconnects all accounts.
 *
 * Therefore it should be enabled on dial up network
 * connections.
 *
 * @author Chris Howells <howells@kde.org>, Heiko Sch&auml;fer <heiko@rangun.de>
 */
class SMPPPDCSPlugin : public Kopete::Plugin, public IConnector
{
		Q_OBJECT

		Q_CLASSINFO ( "D-Bus Interface", "org.kde.kopete.plugin.smpppdcs /MainPlugin" )

		SMPPPDCSPlugin ( const SMPPPDCSPlugin& );
		SMPPPDCSPlugin& operator= ( const SMPPPDCSPlugin& );

	public:
		/**
		 * @brief Creates an <code>SMPPPDCSPlugin</code> instance
		 */
		SMPPPDCSPlugin ( QObject *parent, const QStringList &args );

		/**
		 * @brief Destroys an <code>SMPPPDCSPlugin</code> instance
		 */
		virtual ~SMPPPDCSPlugin();

		/**
		 * @brief Sets the status in all allowed accounts.
		 * Allowed accounts are set in the config dialog of the plugin.
		 *
		 * @see SMPPPDCSPrefs
		 */
		virtual void setConnectedStatus ( bool newStatus );

		virtual void aboutToUnload();

	public slots:
		// Implementation of DBUS iface
		/**
		 * @brief Checks if we are online.
		 * @note This method is reserved for future use. Do not use at the moment!
		 * @return <code>true</code> if online, otherwise <code>false</code>
		 */
		Q_SCRIPTABLE virtual bool isOnline() const;
		Q_SCRIPTABLE virtual QString detectionMethod() const;

		void smpppdServerChanged ( const QString& server );

	private slots:
		void slotCheckStatus();
		void allPluginsLoaded();

	private:
		void connectAllowed();
		void disconnectAllowed();

	private:
		Detector      * m_detectorSMPPPD;
		Detector      * m_detectorNetstat;
		Detector      * m_detectorNetworkStatus;
		bool            m_pluginConnected;
		QTimer        * m_timer;
		OnlineInquiry * m_onlineInquiry;
};

#endif /* SMPPPDCSPLUGIN_H */

// vim: set noet ts=4 sts=4 sw=4:
