// MailStructs.h: interface for the QtPop3 class.
//
//////////////////////////////////////////////////////////////////////

#ifndef MAILSTRUCTS_H
#define MAILSTRUCTS_H

struct UserItem
{
	QString user;
	QString name;

	UserItem()
	{
	}
	
	UserItem(const QString &_user)
	{
		user = name = _user;
	}

	UserItem(const QString &_user, const QString &_name)
	{
		user = _user;
		name = _name;
	}

	void clear()
	{
		user.clear();
		name.clear();
	}

	bool isEmpty()
	{
		return user.isEmpty();
	}
};


struct AttachmentItem
{
	QByteArray body;
	QString file;


	AttachmentItem()
	{
	}

	AttachmentItem(const QByteArray &_body, const QString &_file)
	{
		body = _body;
		file = _file;
	}
};


class MessageItem
{
public:
	QString from;
	QStringList to;
	QStringList cc;
	QString subject;
	QString body;
	QList<AttachmentItem> atts;
	QString uid;
	QString msgId;
	QList<MessageItem> subMessages;

	MessageItem()
	{
	}

	const MessageItem& operator=(const MessageItem& src)
	{
		copyTo(src);
		return *this;
	}

	MessageItem(const MessageItem& src)
	{
		copyTo(src);
	}

	void clear()
	{
		from.clear();
		to.clear();
		cc.clear();
		subject.clear();
		body.clear();
		atts.clear();
		uid.clear();
		msgId.clear();
		subMessages.clear();
	}

	void copyTo(const MessageItem& src)
	{
		int i;

		from = src.from;
		to.clear();
		for(i=0; i<src.to.size(); i++)
		{
			to.append(src.to[i]);
		}
		cc.clear();
		for(i=0; i<src.cc.size(); i++)
		{
			cc.append(src.cc[i]);
		}
		subject = src.subject;
		body = src.body;
		atts.clear();
		for(i=0; i<src.atts.size(); i++)
		{
			atts.append(src.atts[i]);
		}
		uid = src.uid;
		msgId = src.msgId;
		subMessages.clear();
		for(i=0; i<src.subMessages.size(); i++)
		{
			subMessages.append(src.subMessages[i]);
		}
	}
};


//////////////////////////////////////////////////////////////////////
// class tr - traces
//////////////////////////////////////////////////////////////////////

class tr
{
public:
	static void trace(const char *msg, ...)
	{
/*		char buf[4096];
		buf[4095] = '\0';
		va_list ap;
		va_start(ap, msg);
		if (msg)
			qvsnprintf(buf, 4095, msg, ap);
		va_end(ap);


		QFile file("C:\\!trace.txt");
		file.open(QFile::Append);
		file.write(buf);
		file.write("\r\n");
		file.close();*/
	}

	
	static void trace(QString text)
	{
/*		QFile file("C:\\!trace.txt");
		file.open(QFile::Append);
		file.write(qPrintable(text));
		file.write("\r\n");
		file.close();*/
	}
};

#endif
