/*
 *  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 2
 *  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.
 */

#include "MessageStructs.h"

UserItem::UserItem()
{
}

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

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

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

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

AttachmentItem::AttachmentItem()
{
}

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

MessageItem::MessageItem()
{
}

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

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

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

void
MessageItem::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]);
	}
}
