vmime/src/messaging/maildirMessage.cpp

160 lines
3.1 KiB
C++
Raw Normal View History

2004-10-05 10:28:21 +00:00
//
// VMime library (http://vmime.sourceforge.net)
// Copyright (C) 2002-2004 Vincent Richard <vincent@vincent-richard.net>
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "maildirMessage.hpp"
2004-10-21 15:05:47 +00:00
#include "maildirFolder.hpp"
2004-12-04 20:25:48 +00:00
#include "maildirUtils.hpp"
#include "../exception.hpp"
#include "../platformDependant.hpp"
2004-10-05 10:28:21 +00:00
namespace vmime {
namespace messaging {
2004-10-21 15:05:47 +00:00
maildirMessage::maildirMessage(maildirFolder* folder, const int num)
2004-12-04 20:25:48 +00:00
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED)
2004-10-21 15:05:47 +00:00
{
m_folder->registerMessage(this);
}
maildirMessage::~maildirMessage()
{
if (m_folder)
m_folder->unregisterMessage(this);
}
void maildirMessage::onFolderClosed()
{
m_folder = NULL;
}
const int maildirMessage::getNumber() const
{
2004-12-04 20:25:48 +00:00
return (m_num);
2004-10-21 15:05:47 +00:00
}
const message::uid maildirMessage::getUniqueId() const
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
const int maildirMessage::getSize() const
{
2004-12-04 20:25:48 +00:00
if (m_size == -1)
throw exceptions::unfetched_object();
return (m_size);
2004-10-21 15:05:47 +00:00
}
const bool maildirMessage::isExpunged() const
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
const structure& maildirMessage::getStructure() const
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
structure& maildirMessage::getStructure()
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
const header& maildirMessage::getHeader() const
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
const int maildirMessage::getFlags() const
{
2004-12-04 20:25:48 +00:00
if (m_flags == FLAG_UNDEFINED)
throw exceptions::unfetched_object();
return (m_flags);
2004-10-21 15:05:47 +00:00
}
void maildirMessage::setFlags(const int flags, const int mode)
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
2004-12-04 20:25:48 +00:00
void maildirMessage::extract(utility::outputStream& os,
progressionListener* progress, const int start, const int length) const
2004-10-21 15:05:47 +00:00
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
2004-12-04 20:25:48 +00:00
void maildirMessage::extractPart(const part& p, utility::outputStream& os,
progressionListener* progress, const int start, const int length) const
2004-10-21 15:05:47 +00:00
{
2004-12-04 20:25:48 +00:00
// TODO
2004-10-21 15:05:47 +00:00
}
void maildirMessage::fetchPartHeader(part& p)
{
2004-12-04 20:25:48 +00:00
// TODO
}
void maildirMessage::fetch(maildirFolder* folder, const int options)
{
if (m_folder != folder)
throw exceptions::folder_not_found();
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
utility::auto_ptr <utility::file> file = fsf->create(path);
/*
TODO: FETCH_ENVELOPE
TODO: FETCH_STRUCTURE
TODO: FETCH_CONTENT_INFO
TODO: FETCH_FULL_HEADER
TODO: FETCH_UID
*/
if (options & folder::FETCH_FLAGS)
m_flags = maildirUtils::extractFlags(path.getLastComponent());
if (options & folder::FETCH_SIZE)
m_size = file->length();
2004-10-21 15:05:47 +00:00
}
2004-10-05 10:28:21 +00:00
} // messaging
} // vmime