1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#include "libmail_config.h"
#include "addressbookopen.H"
#include "envelope.H"
using namespace std;
mail::addressbook::Open::Open(mail::addressbook *addressBookArg,
mail::callback &callbackArg)
: addressBook(addressBookArg),
callback(callbackArg)
{
}
mail::addressbook::Open::~Open()
{
}
void mail::addressbook::Open::success(string msg)
{
(this->*successFunc)(msg);
}
void mail::addressbook::Open::fail(string msg)
{
try {
callback.fail(msg);
delete this;
} catch (...) {
delete this;
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
}
// 1. Select the folder
void mail::addressbook::Open::go()
{
successFunc= &mail::addressbook::Open::opened;
addressBook->folder->open(*this, NULL, *addressBook);
}
// 2. Read envelopes of all messages in the folder
void mail::addressbook::Open::opened(string successMsg)
{
addressBook->index.clear();
addressBook->index.insert(addressBook->index.end(),
addressBook->server->getFolderIndexSize(),
Index());
vector<size_t> msgs;
size_t i;
for (i=0; i<addressBook->index.size(); i++)
msgs.push_back(i);
successFunc= &mail::addressbook::Open::readIndex;
addressBook->server->readMessageAttributes(msgs,
addressBook->server
-> ENVELOPE,
*this);
}
void mail::addressbook::Open::readIndex(string msg)
{
try {
callback.success(msg);
delete this;
} catch (...) {
delete this;
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
}
void mail::addressbook::Open
::messageEnvelopeCallback(size_t messageNumber,
const class mail::envelope &envelope)
{
addressBook->setIndex(messageNumber, envelope.subject);
}
void mail::addressbook::Open::reportProgress(size_t bytesCompleted,
size_t bytesEstimatedTotal,
size_t messagesCompleted,
size_t messagesEstimatedTotal)
{
callback.reportProgress(bytesCompleted, bytesEstimatedTotal,
messagesCompleted, messagesEstimatedTotal);
}
|