/*
 *  Copyright (C) 2007-2008 CMM Sigma Andrzej Chmielowiec <cmmsigma@cmmsigma.eu>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  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.
 */

// FtpDistDialog.h: interface for the FtpDistDialog class.
//
//////////////////////////////////////////////////////////////////////

#ifndef FTP_DIST_DIALOG_H
#define FTP_DIST_DIALOG_H

#include <QtGui>
#include <QFtp>
#include <QQueue>
#include "CaOptions.h"

class FtpDistDialog : public QDialog  
{
	Q_OBJECT

public:
	FtpDistDialog(CaOptions::FTPConfig *ftpConfig, QByteArray *crlData, QWidget *parent = 0, Qt::WindowFlags f = 0);
	virtual ~FtpDistDialog();

protected:
	QPushButton *mBreak;
	QProgressBar *mServerProgress;
	QProgressBar *mFileProgress;
	QProgressBar *mTransferProgress;
	QTextEdit *mLog;
	QFtp *mFtp;
	
	void connect2NextServer();
	void login2Server();
	void sendNextFile();
	
	CaOptions::FTPConfig *mFtpConfig;
	QByteArray *mCrlData;
	QQueue<int> *mIndexes;
	int mCurrServer;
	int mCurrIndex;
	int mCurrFile;
	QString mCurrFileName;
	QString mRootDir;
	bool mError;

public slots:
	void ftpDataTransferProgress(qint64 readBytes, qint64 totalBytes);
	void ftpDone(bool error);
	void ftpCommandFinished(int, bool error);
	void ftpRawCommandReply(int replyCode, const QString & detail);
};

#endif
