/***************************************************************************
 *   Copyright (C) 2008 by Dr Pierre-Marie DESOMBRE                        *
 *   pm.desombre@medsyn.fr                                                 *
 *                  on a idea from Eric Maeker                             *
 *   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.             *
 ***************************************************************************/
#include "connexion.h"
#include "copyMyChoices.h"

#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include <QString>
#include <QMessageBox>
#include <iostream> 

int main (int argc, char * argv[])
{
	QApplication a(argc,argv);
	QString arg;
	QString file;
	QStringList args;
	args = a.arguments();
	if (args.size()>1)
	{
		  file = a.arguments()[1];
	    }
        QFile returnFile(a.applicationDirPath()+"/../../../../tmp/returnFile.txt");
	if (!returnFile.open(QIODevice::ReadWrite|QIODevice::Text))
	{
		QMessageBox::warning(0,"Warning","Exchange file cannot open",QMessageBox::Ok);
	    }
	QTextStream stream(&returnFile);
	Common::Connexion * c = new Common::Connexion;
	if (!c->connect())
	{
		  qWarning() << __FILE__ << QString::number(__LINE__) << "cannot connect to database" ;
	    }
	CopyMyChoices * copy = new CopyMyChoices(0);
	copy->run(arg);
	stream << copy->returnString();
	int r = a.exec();
	//QMessageBox::information(0,"Warning",copy->returnString(),QMessageBox::Ok);
	

	return r;
}
