sptk2 logo
SPTK Home Page
ImapDS.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <functional>
30#include <sptk5/MemoryDS.h>
31#include <sptk5/net/ImapConnect.h>
32
33namespace sptk {
34
43using ProgressCallback = std::function<void(int total, int progress)>;
44
51class SP_EXPORT ImapDS
52 : public MemoryDS
53{
54public:
59
63 void host(const Host& host)
64 {
65 m_imap.host(host);
66 }
67
71 const Host& host() const
72 {
73 return m_imap.host();
74 }
75
79 void user(const String& usr)
80 {
81 m_user = usr;
82 }
83
87 const String& user() const
88 {
89 return m_user;
90 }
91
95 void password(const String& pwd)
96 {
97 m_password = pwd;
98 }
99
103 const String& password() const
104 {
105 return m_password;
106 }
107
111 void folder(const String& d)
112 {
113 m_folder = d;
114 }
115
119 const String& folder() const
120 {
121 return m_folder;
122 }
123
128 void messageID(int msgid)
129 {
130 m_msgid = msgid;
131 }
132
136 int messageID() const
137 {
138 return m_msgid;
139 }
140
145 void fetchBody(bool fb)
146 {
147 m_fetchbody = fb;
148 }
149
154 bool fetchBody() const
155 {
156 return m_fetchbody;
157 }
158
163 bool open() override;
164
170 {
171 m_callback = cb;
172 }
173
174private:
175 ImapConnect m_imap;
176 String m_folder;
177 String m_user;
178 String m_password;
179 bool m_fetchbody {false};
180 ProgressCallback m_callback {nullptr};
181 int m_msgid {0};
182};
186} // namespace sptk
Definition: Host.h:55
Definition: ImapConnect.h:50
IMAP datasource.
Definition: ImapDS.h:53
void password(const String &pwd)
Definition: ImapDS.h:95
void user(const String &usr)
Definition: ImapDS.h:79
void callback(const ProgressCallback &cb)
Definition: ImapDS.h:169
bool fetchBody() const
Definition: ImapDS.h:154
const String & user() const
Definition: ImapDS.h:87
int messageID() const
Definition: ImapDS.h:136
bool open() override
const String & folder() const
Definition: ImapDS.h:119
void folder(const String &d)
Definition: ImapDS.h:111
void host(const Host &host)
Definition: ImapDS.h:63
const String & password() const
Definition: ImapDS.h:103
void fetchBody(bool fb)
Definition: ImapDS.h:145
const Host & host() const
Definition: ImapDS.h:71
void messageID(int msgid)
Definition: ImapDS.h:128
Base (memory) datasource.
Definition: MemoryDS.h:52
MemoryDS()=default
Definition: String.h:49
std::function< void(int total, int progress)> ProgressCallback
Definition: ImapDS.h:43

Fri Oct 14 2022 09:58:32: SPTK 5.4.1