blob: 90ff1bc599aa9feb2c2370058351bab8140d31d1 (
plain)
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
  | 
/*
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#ifndef libmail_addressbookget_H
#define libmail_addressbookget_H
#include "addressbook.H"
#include "structure.H"
#include "rfcaddr.H"
#include <map>
//
// Extract an address book entry, as follows:
//
// 1. Read the message's MIME structure.
// 2. Verify the presence of text/x-libmail-addressbook content.
// 3. Read text/x-libmail-addressbook content.
template<class T>
class mail::addressbook::GetAddressList : public mail::callback::message {
	mail::ptr<mail::addressbook> addressBook;
	size_t msgNum;
	std::vector<T> &addrListRet;
	mail::callback &callback;
	mail::mimestruct mimeStructure;
	void success(std::string successMsg);
	void (mail::addressbook::GetAddressList<T>::*successFunc)(std::string);
	void readstructure(std::string successMsg);
	void readContents(std::string successMsg);
	void fail(std::string failMsg);
	void messageStructureCallback(size_t messageNumber,
				      const mail::mimestruct
				      &messageStructure);
	void messageTextCallback(size_t n, std::string text);
	void reportProgress(size_t bytesCompleted,
			    size_t bytesEstimatedTotal,
			    size_t messagesCompleted,
			    size_t messagesEstimatedTotal);
	std::string linebuffer;
	// Reading x-libmail-addressbook content; partial line read.
	void addressBookLine(std::string text);
	std::map<std::string, std::string> addressBookLineMap;
	std::string lastAddressBookLine;
	// Name of the current x-libmail-addressbook header line being read.
public:
	GetAddressList(mail::addressbook *addressBookArg,
		       size_t msgNumArg,
		       std::vector<T> &addrListRetArg,
		       mail::callback &callbackArg);
	~GetAddressList();
	void go();
};
#endif
  |