diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 | 
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 | 
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /libmail/addressbookopen.C | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'libmail/addressbookopen.C')
| -rw-r--r-- | libmail/addressbookopen.C | 98 | 
1 files changed, 98 insertions, 0 deletions
| diff --git a/libmail/addressbookopen.C b/libmail/addressbookopen.C new file mode 100644 index 0000000..fd240c2 --- /dev/null +++ b/libmail/addressbookopen.C @@ -0,0 +1,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); +} | 
