/***************************************************************************
 *   Copyright (C) 2008 by Andreas Silberstorff   *
 *   taki@Rivendell   *
 *                                                                         *
 *   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 MPLAYERSCRIPTDEVICE_H
#define MPLAYERSCRIPTDEVICE_H

#include <PluginInterface>
#include <DeviceInterface>
#include <Data/Command>
#include <Data/Channel>
#include <KalvaGeneralSettings>

#include <QObject>
#include <QTime>
#include <klocale.h>
#include <KConfigDialog>
#include <KProcess>
#include <Phonon/VideoWidget>
#include <Phonon/MediaObject>

namespace MPlayerScriptDevice {

/**
 * A device plugin using solid to access dvb cards
 *
 * @short ScriptedMencoderDvbDevice
 * @author Andreas Silberstorff <ml@andreas-silberstorff.de>
 * @version 1.0.91
 */

class Plugin
 : public QObject,
   public KalvaPlugin::PluginInterface,
   public KalvaPlugin::DeviceInterface
{
	Q_OBJECT
	Q_INTERFACES( KalvaPlugin::PluginInterface KalvaPlugin::DeviceInterface )
public:
	Plugin();
	virtual ~Plugin();

	/**
	 * @see KalvaPlugin::PluginInterface
	 */
	inline QString title() { return i18n("MPlayer Device"); };

	/**
	 * @see KalvaPlugin::PluginInterface
	 */
	inline QString toolTip() { return i18n("Access a device through MPlayer / MEncoder"); };

	/**
	 * @see KalvaPlugin::PluginInterface
	 */
	inline QString whatsThis() { return i18n("Access a dvb device through mplayer. Warning: At the moment this is a dummy."); };

	/**
	 * @see KalvaPlugin::PluginInterface
	 */
	void addToConfigDialog( KConfigDialog *dialog );

	/**
	 * Implementing plugins must overwrite this to allow
	 * recording of the tv stream.
	 *
	 * The managing perspective must have set the video widget
	 * and the channellist and a station has to be selected
	 * before this function can be called!
	 */
	KalvaData::KalvaScriptCommand* createRecordCommand( QString titel, QTime duration );

	/**
	 * Implementing plugins must overwrite this to allow
	 * recording of the tv stream.
	 *
	 * The managing perspective must have set the video widget
	 * and the channellist and a station has to be selected
	 * before this function can be called!
	 */
	KalvaData::KalvaScriptCommand* createPlayCommand();

	/**
	 * Implementing plugins must overwrite this to
	 * get a pointer to the player widget.
	 * See kalvaview.
	 */
	inline void setVideoWidget( Phonon::VideoWidget * videoWidget) { _videoWidget = videoWidget; };
	
	void setKalvaGeneralSettings( KalvaData::KalvaGeneralSettings * );

public slots:

	/**
	 * 
	 */
	inline void setChannel( KalvaData::Channel * channel ) { _channel = channel; };

	/**
	 * @see KalvaPlugin::PluginInterface
	 */
	void settingsChanged();

private:
	Phonon::MediaObject* _mediaObject;
	Phonon::VideoWidget* _videoWidget;
	KalvaData::Channel* _channel;
	KProcess* _process;
	KalvaData::KalvaGeneralSettings * _kalvaGeneralSettings;
};

}

#endif
