Fixed some doc + getHeader() now returns a ref.

This commit is contained in:
Vincent Richard 2005-07-24 20:04:23 +00:00
parent 06ed35edf7
commit e14a8b6adb
7 changed files with 38 additions and 46 deletions

View File

@ -272,7 +272,7 @@ private:
IMAPMessage::IMAPMessage(IMAPFolder* folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
m_expunged(false), m_header(NULL), m_structure(NULL)
m_expunged(false), m_structure(NULL)
{
m_folder->registerMessage(this);
}
@ -345,12 +345,12 @@ structure& IMAPMessage::getStructure()
}
const header& IMAPMessage::getHeader() const
ref <const header> IMAPMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
return (*m_header);
return (m_header);
}
@ -582,57 +582,57 @@ void IMAPMessage::processFetchResponse
if (!(options & folder::FETCH_FULL_HEADER))
{
const IMAPParser::envelope* env = (*it)->envelope();
vmime::header& hdr = getOrCreateHeader();
ref <vmime::header> hdr = getOrCreateHeader();
// Date
hdr.Date()->setValue(env->env_date()->value());
hdr->Date()->setValue(env->env_date()->value());
// Subject
text subject;
text::decodeAndUnfold(env->env_subject()->value(), &subject);
hdr.Subject()->setValue(subject);
hdr->Subject()->setValue(subject);
// From
mailboxList from;
convertAddressList(*(env->env_from()), from);
if (!from.isEmpty())
hdr.From()->setValue(*(from.getMailboxAt(0)));
hdr->From()->setValue(*(from.getMailboxAt(0)));
// To
mailboxList to;
convertAddressList(*(env->env_to()), to);
hdr.To()->setValue(to);
hdr->To()->setValue(to);
// Sender
mailboxList sender;
convertAddressList(*(env->env_sender()), sender);
if (!sender.isEmpty())
hdr.Sender()->setValue(*(sender.getMailboxAt(0)));
hdr->Sender()->setValue(*(sender.getMailboxAt(0)));
// Reply-to
mailboxList replyTo;
convertAddressList(*(env->env_reply_to()), replyTo);
if (!replyTo.isEmpty())
hdr.ReplyTo()->setValue(*(replyTo.getMailboxAt(0)));
hdr->ReplyTo()->setValue(*(replyTo.getMailboxAt(0)));
// Cc
mailboxList cc;
convertAddressList(*(env->env_cc()), cc);
if (!cc.isEmpty())
hdr.Cc()->setValue(cc);
hdr->Cc()->setValue(cc);
// Bcc
mailboxList bcc;
convertAddressList(*(env->env_bcc()), bcc);
if (!bcc.isEmpty())
hdr.Bcc()->setValue(bcc);
hdr->Bcc()->setValue(bcc);
}
break;
@ -644,7 +644,7 @@ void IMAPMessage::processFetchResponse
}
case IMAPParser::msg_att_item::RFC822_HEADER:
{
getOrCreateHeader().parse((*it)->nstring()->value());
getOrCreateHeader()->parse((*it)->nstring()->value());
break;
}
case IMAPParser::msg_att_item::RFC822_SIZE:
@ -663,7 +663,7 @@ void IMAPMessage::processFetchResponse
header tempHeader;
tempHeader.parse((*it)->nstring()->value());
vmime::header& hdr = getOrCreateHeader();
vmime::header& hdr = *getOrCreateHeader();
std::vector <ref <headerField> > fields = tempHeader.getFieldList();
for (std::vector <ref <headerField> >::const_iterator jt = fields.begin() ;
@ -692,12 +692,12 @@ void IMAPMessage::processFetchResponse
}
header& IMAPMessage::getOrCreateHeader()
ref <header> IMAPMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (*m_header);
return (m_header);
else
return (*(m_header = vmime::create <header>()));
return (m_header = vmime::create <header>());
}

View File

@ -212,7 +212,7 @@ structure& maildirPart::getStructure()
maildirMessage::maildirMessage(weak_ref <maildirFolder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
m_expunged(false), m_header(NULL), m_structure(NULL)
m_expunged(false), m_structure(NULL)
{
m_folder->registerMessage(this);
}
@ -276,12 +276,12 @@ structure& maildirMessage::getStructure()
}
const header& maildirMessage::getHeader() const
ref <const header> maildirMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
return (*m_header);
return (m_header);
}
@ -483,18 +483,18 @@ void maildirMessage::fetch(weak_ref <maildirFolder> folder, const int options)
folder::FETCH_CONTENT_INFO |
folder::FETCH_FULL_HEADER))
{
getOrCreateHeader().copyFrom(*(msg.getHeader()));
getOrCreateHeader()->copyFrom(*(msg.getHeader()));
}
}
}
header& maildirMessage::getOrCreateHeader()
ref <header> maildirMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (*m_header);
return (m_header);
else
return (*(m_header = vmime::create <header>()));
return (m_header = vmime::create <header>());
}

View File

@ -30,7 +30,7 @@ namespace pop3 {
POP3Message::POP3Message(POP3Folder* folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_deleted(false), m_header(NULL)
: m_folder(folder), m_num(num), m_size(-1), m_deleted(false)
{
m_folder->registerMessage(this);
}
@ -40,8 +40,6 @@ POP3Message::~POP3Message()
{
if (m_folder)
m_folder->unregisterMessage(this);
delete (m_header);
}
@ -101,12 +99,12 @@ structure& POP3Message::getStructure()
}
const header& POP3Message::getHeader() const
ref <const header> POP3Message::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
return (*m_header);
return (m_header);
}
@ -194,13 +192,7 @@ void POP3Message::fetch(POP3Folder* folder, const int options)
string buffer;
m_folder->m_store->readResponse(buffer, true);
if (m_header != NULL)
{
delete (m_header);
m_header = NULL;
}
m_header = new header();
m_header = vmime::create <header>();
m_header->parse(buffer);
}
catch (exceptions::command_error& e)

View File

@ -63,7 +63,7 @@ public:
const structure& getStructure() const;
structure& getStructure();
const header& getHeader() const;
ref <const header> getHeader() const;
const int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
@ -85,7 +85,7 @@ private:
void convertAddressList(const IMAPParser::address_list& src, mailboxList& dest);
header& getOrCreateHeader();
ref <header> getOrCreateHeader();
void onFolderClosed();

View File

@ -61,7 +61,7 @@ public:
const structure& getStructure() const;
structure& getStructure();
const header& getHeader() const;
ref <const header> getHeader() const;
const int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
@ -77,7 +77,7 @@ private:
void onFolderClosed();
header& getOrCreateHeader();
ref <header> getOrCreateHeader();
void extractImpl(utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const;

View File

@ -87,7 +87,7 @@ public:
/** Return the sub-part at the specified position.
* This provide easy access to parts:
* Eg: "message->extract(message->structure()[3][1][2])".
* Eg: "message->extractPart(message->getStructure()[3][1][2])".
*
* @param x index of the sub-part
* @return sub-part at position 'x'
@ -96,7 +96,7 @@ public:
/** Return the sub-part at the specified position.
* This provide easy access to parts:
* Eg: "message->extract(message->structure()[3][1][2])".
* Eg: "message->extractPart(message->getStructure()[3][1][2])".
*
* @param x index of the sub-part
* @return sub-part at position 'x'
@ -183,7 +183,7 @@ public:
*
* @return header section of the message
*/
virtual const header& getHeader() const = 0;
virtual ref <const header> getHeader() const = 0;
/** Return the sequence number of this message. This number is
* used to reference the message in the folder.
@ -262,7 +262,7 @@ public:
*/
virtual void extract(utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const = 0;
/** Extract the specified (MIME) part of the message (header + contents).
/** Extract the specified MIME part of the message (header + contents).
*
* \warning Partial fetch might not be supported by the underlying protocol.
*

View File

@ -63,7 +63,7 @@ public:
const structure& getStructure() const;
structure& getStructure();
const header& getHeader() const;
ref <const header> getHeader() const;
const int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
@ -86,7 +86,7 @@ private:
bool m_deleted;
header* m_header;
ref <header> m_header;
};