/*
 * Copyright (C) 2006-2007	Andre Beckedorf
 * 					 		<evilJazz _AT_ katastrophos _DOT_ 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.
 *
 * 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 MEDIAIDENTIFIER_H_
#define MEDIAIDENTIFIER_H_

#include <qfileinfo.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qfile.h>
#include <qdir.h>
#include <qurl.h>
#include <qstringlist.h>
#include <qobject.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <qtimer.h>
#include <qintcache.h>

#include <qprocess.h>
#include "media.h"

class MediaIdentifier : public QObject
{
	Q_OBJECT

public:
	static MediaIdentifier& singleton();
#	define g_MediaIdentifier MediaIdentifier::singleton()

	MediaIdentifier();
	virtual ~MediaIdentifier();
	
	void identify(Media *media, const MediaLocation &location);	
	
private slots:
	void parseLines();
	void killIdentifyProcessTimerTimedOut();
	
private:
	Media *media_;
	bool fileScanningFinished_;
	QProcess *identifyProcess_;
	QTimer killIdentifyProcessTimer_;
	QString tempLine_;

	void cleanUpIdentifyProcess();
	void sendCommand(const QString &command);
		
	// Load tags
	bool loadTags(const MediaLocation &location);
	
	void addMediadata(const QString &tag, const QString &value);	
};

#endif /*MEDIAIDENTIFIER_H_*/
