/***************************************************************************
 * timiditylauncher.h: implementation of TimidityLauncher class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#ifndef TIMIDITYLAUNCHER_H
#define TIMIDITYLAUNCHER_H

#include <QProcess>
#include <QString>

/**
	The TimidityLauncher class. This class tries to launch the timidity process the classes wait until
	there is a console or an error message.
*/
class TimidityLauncher : public QProcess {
	Q_OBJECT
public:
	TimidityLauncher();
	
	/**
		Construct the TimidityLauncher.
		The constructor inits the QProcess parent.
		@param parent the parent widget
		@name name the widget name
		@see QProcess constructor
	*/
	TimidityLauncher(const QString& program, const QStringList& arguments);
	
	/**
		Destruct the TimidityLauncher
		It does nothing.
	*/
	virtual ~TimidityLauncher();
	
	virtual void setProgram(const QString& program);
	virtual QString program() const;
	
	virtual void setArguments(const QStringList& arguments);
	virtual QStringList arguments() const;
	
	/**
		Tries to launch timidity.
		It waits until there is messages output from the console from the timidity process.
		@Return true if the process is launched else false
	*/
	virtual bool launchTimidity();
	
	virtual bool launchTimidityByHand();
	
	virtual bool launchTimidityWithCmdLine(const QString& program, const QStringList& arguments);
	
	/**
		Return the console output from timidity.
		@return the ocnsole output
	*/
	virtual QString errorMsg();
	
	virtual void clearTimidityOutput();
private slots:
	void readFromStdout();
	void readFromStderr();
	
private:
	// Build the command line
	//
	void setupTimidity();
	
	QString mProgram;
	
	QStringList mArguments;
	
	// Timidity standart output
	//
	QString mResult;
	
	// Timidity error output
	//
	QString mError;
};

#endif
