
//  Copyright (C) 2009 by Arnaud Dupuis
//  a.dupuis@infinityperl.org
//  http://www.infinityperl.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; either version 3 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 ASSUMA_MAILDIALOG
#define ASSUMA_MAILDIALOG

#include <QDialog>
#include <QMenu>
#include "ui_assuma_maildialog.h"

class QString;
class MailSender;
/*!  \class AssumaMailDialog
*	\brief AssumaMailDialog is a mailer dialog window.
*		It can send email with attachements to one or more destinations.
*
* This QObject can be used as a mailer window (wich it is actually...) to send text mail and attachements to one or more persons.
* It send one mail to one receiver at a time, so in case you send a mail to a whole mailing list, privacy is guaranted.
* Please note that this classe CANNOT send email through crypted SMTP connections.
*/
class AssumaMailDialog : public QDialog, public Ui::AssumaMailDialog
{
	Q_OBJECT
	
	public:
		//! AssumaMailDialog's constructor.
		/*!
		The constructor of this class. It can takes a QWidget parent as argument (but it is not mandatory).
		\param parent the parent window (optionnal)
		*/
		AssumaMailDialog(QWidget *parent=0);
	public slots:
		/*! Add an email adress to the adresses list.
		\param email the email SQtring to had
		*/
		void addEmail(const QString &);
		/*! Set the sender adress to use.
		\param from the sender adress.
		*/
		void setSender(const QString &);
		/*! Set the subject of the email.
		\param subject the subject string.
		*/
		void setSubject(const QString &);
		/*! Set the body of the email.
		\param body the body content string (so far, only text body).
		*/
		void setBody(const QString &);
		/*! Add an attachement to the email.
		\param attachement the attachement path.
		*/
		void addAttachement(const QString &);
		/*! Set a list of email adresses to add under the "Add email -> From database" button.
		\param list the list of email strings.
		*/
		void setEmailList(const QStringList &);
		/*! Set the SMTP server to use.
		\param smtpServer the SMTP server to use.
		*/
		void setSmtpServer(const QString&);
		/*! Set the login and password for SMTP authentication
		\param login the SMTP server login
		\param password the SMTP server password
		*/
		void setAuth(const QString &, const QString & );
		/*! Set the mail's characters encoding.
		\param encoding the encoding as a string. at the moment the choice is between ISO-8859-1 and UTF-8
		*/
		void setMailEncoding( const QString & );
		/*!
		Load a theme for the UI.
		\param themeName the name of the theme to load. This is the name of a directory in the theme/ directory.
		*/
		void loadTheme( const QString & themeName = "default" );
	private slots:
		void on_attachementButton_clicked();
		void on_delAttachementButton_clicked();
		void on_delAdressButton_clicked();
		void on_sendButton_clicked();
		void addDestinationEmail();
		void addDestinationEmail(bool);
	private:
		// Methods

		// Variables
		QMenu *addEmailMenu;
		QMenu *addEmailSubMenu;
		QLineEdit *addEmailLineEdit;
		QString _smtpServer;
		QString _smtpLogin;
		QString _smtpPassword;
		QString _mailEncoding;
	
};

#endif
