summaryrefslogtreecommitdiff
authoralwin <alwin>2004-10-25 22:34:15 (UTC)
committer alwin <alwin>2004-10-25 22:34:15 (UTC)
commit9e97864f04686ca8fc672de950cbbef4ff6a5ec6 (patch) (unidiff)
tree7aa5b07b4bb6fce77844d7883d947100a1ae3759
parentd29de6d360b0570c12778beea9f654a8fcdbe3c7 (diff)
downloadopie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.zip
opie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.tar.gz
opie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.tar.bz2
fixed the problem with displaying date/time of a mail
usage of helper class
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp18
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h3
2 files changed, 5 insertions, 16 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index fe75a15..56efa0b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,1198 +1,1186 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include <qpe/global.h> 3#include <qpe/global.h>
4#include <opie2/oapplication.h> 4#include <opie2/oapplication.h>
5#include <opie2/odebug.h> 5#include <opie2/odebug.h>
6 6
7#include "imapwrapper.h" 7#include "imapwrapper.h"
8#include "mailtypes.h" 8#include "mailtypes.h"
9#include "logindialog.h" 9#include "logindialog.h"
10 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 12IMAPwrapper::IMAPwrapper( IMAPaccount *a )
13 : AbstractMail() 13 : AbstractMail(),MailStatics()
14{ 14{
15 account = a; 15 account = a;
16 m_imap = 0; 16 m_imap = 0;
17 m_Lastmbox = ""; 17 m_Lastmbox = "";
18} 18}
19 19
20IMAPwrapper::~IMAPwrapper() 20IMAPwrapper::~IMAPwrapper()
21{ 21{
22 logout(); 22 logout();
23} 23}
24 24
25/* to avoid to often select statements in loops etc. 25/* to avoid to often select statements in loops etc.
26 we trust that we are logged in and connection is established!*/ 26 we trust that we are logged in and connection is established!*/
27int IMAPwrapper::selectMbox(const QString&mbox) 27int IMAPwrapper::selectMbox(const QString&mbox)
28{ 28{
29 if (mbox == m_Lastmbox) { 29 if (mbox == m_Lastmbox) {
30 return MAILIMAP_NO_ERROR; 30 return MAILIMAP_NO_ERROR;
31 } 31 }
32 int err = mailimap_select( m_imap, (char*)mbox.latin1()); 32 int err = mailimap_select( m_imap, (char*)mbox.latin1());
33 if ( err != MAILIMAP_NO_ERROR ) { 33 if ( err != MAILIMAP_NO_ERROR ) {
34 odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; 34 odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl;
35 m_Lastmbox = ""; 35 m_Lastmbox = "";
36 return err; 36 return err;
37 } 37 }
38 m_Lastmbox = mbox; 38 m_Lastmbox = mbox;
39 return err; 39 return err;
40} 40}
41 41
42void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 42void IMAPwrapper::imap_progress( size_t current, size_t maximum )
43{ 43{
44 qApp->processEvents(); 44 qApp->processEvents();
45 odebug << "IMAP: " << current << " of " << maximum << "" << oendl; 45 odebug << "IMAP: " << current << " of " << maximum << "" << oendl;
46} 46}
47 47
48bool IMAPwrapper::start_tls(bool force_tls) 48bool IMAPwrapper::start_tls(bool force_tls)
49{ 49{
50 int err; 50 int err;
51 bool try_tls; 51 bool try_tls;
52 mailimap_capability_data * cap_data = 0; 52 mailimap_capability_data * cap_data = 0;
53 53
54 err = mailimap_capability(m_imap,&cap_data); 54 err = mailimap_capability(m_imap,&cap_data);
55 if (err != MAILIMAP_NO_ERROR) { 55 if (err != MAILIMAP_NO_ERROR) {
56 Global::statusMessage("error getting capabilities!"); 56 Global::statusMessage("error getting capabilities!");
57 odebug << "error getting capabilities!" << oendl; 57 odebug << "error getting capabilities!" << oendl;
58 return false; 58 return false;
59 } 59 }
60 clistiter * cur; 60 clistiter * cur;
61 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 61 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
62 struct mailimap_capability * cap; 62 struct mailimap_capability * cap;
63 cap = (struct mailimap_capability *)clist_content(cur); 63 cap = (struct mailimap_capability *)clist_content(cur);
64 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 64 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
65 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 65 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
66 try_tls = true; 66 try_tls = true;
67 break; 67 break;
68 } 68 }
69 } 69 }
70 } 70 }
71 if (cap_data) { 71 if (cap_data) {
72 mailimap_capability_data_free(cap_data); 72 mailimap_capability_data_free(cap_data);
73 } 73 }
74 if (try_tls) { 74 if (try_tls) {
75 err = mailimap_starttls(m_imap); 75 err = mailimap_starttls(m_imap);
76 if (err != MAILIMAP_NO_ERROR && force_tls) { 76 if (err != MAILIMAP_NO_ERROR && force_tls) {
77 Global::statusMessage(tr("Server has no TLS support!")); 77 Global::statusMessage(tr("Server has no TLS support!"));
78 odebug << "Server has no TLS support!" << oendl; 78 odebug << "Server has no TLS support!" << oendl;
79 try_tls = false; 79 try_tls = false;
80 } else { 80 } else {
81 mailstream_low * low; 81 mailstream_low * low;
82 mailstream_low * new_low; 82 mailstream_low * new_low;
83 low = mailstream_get_low(m_imap->imap_stream); 83 low = mailstream_get_low(m_imap->imap_stream);
84 if (!low) { 84 if (!low) {
85 try_tls = false; 85 try_tls = false;
86 } else { 86 } else {
87 int fd = mailstream_low_get_fd(low); 87 int fd = mailstream_low_get_fd(low);
88 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 88 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
89 mailstream_low_free(low); 89 mailstream_low_free(low);
90 mailstream_set_low(m_imap->imap_stream, new_low); 90 mailstream_set_low(m_imap->imap_stream, new_low);
91 } else { 91 } else {
92 try_tls = false; 92 try_tls = false;
93 } 93 }
94 } 94 }
95 } 95 }
96 } 96 }
97 return try_tls; 97 return try_tls;
98} 98}
99 99
100void IMAPwrapper::login() 100void IMAPwrapper::login()
101{ 101{
102 const char *server, *user, *pass; 102 const char *server, *user, *pass;
103 uint16_t port; 103 uint16_t port;
104 int err = MAILIMAP_NO_ERROR; 104 int err = MAILIMAP_NO_ERROR;
105 105
106 if (account->getOffline()) return; 106 if (account->getOffline()) return;
107 /* we are connected this moment */ 107 /* we are connected this moment */
108 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 108 /* TODO: setup a timer holding the line or if connection closed - delete the value */
109 if (m_imap) { 109 if (m_imap) {
110 err = mailimap_noop(m_imap); 110 err = mailimap_noop(m_imap);
111 if (err!=MAILIMAP_NO_ERROR) { 111 if (err!=MAILIMAP_NO_ERROR) {
112 logout(); 112 logout();
113 } else { 113 } else {
114 mailstream_flush(m_imap->imap_stream); 114 mailstream_flush(m_imap->imap_stream);
115 return; 115 return;
116 } 116 }
117 } 117 }
118 server = account->getServer().latin1(); 118 server = account->getServer().latin1();
119 port = account->getPort().toUInt(); 119 port = account->getPort().toUInt();
120 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 120 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
121 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 121 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
122 login.show(); 122 login.show();
123 if ( QDialog::Accepted == login.exec() ) { 123 if ( QDialog::Accepted == login.exec() ) {
124 // ok 124 // ok
125 user = login.getUser().latin1(); 125 user = login.getUser().latin1();
126 pass = login.getPassword().latin1(); 126 pass = login.getPassword().latin1();
127 } else { 127 } else {
128 // cancel 128 // cancel
129 odebug << "IMAP: Login canceled" << oendl; 129 odebug << "IMAP: Login canceled" << oendl;
130 return; 130 return;
131 } 131 }
132 } else { 132 } else {
133 user = account->getUser().latin1(); 133 user = account->getUser().latin1();
134 pass = account->getPassword().latin1(); 134 pass = account->getPassword().latin1();
135 } 135 }
136 136
137 m_imap = mailimap_new( 20, &imap_progress ); 137 m_imap = mailimap_new( 20, &imap_progress );
138 138
139 /* connect */ 139 /* connect */
140 bool ssl = false; 140 bool ssl = false;
141 bool try_tls = false; 141 bool try_tls = false;
142 bool force_tls = false; 142 bool force_tls = false;
143 143
144 if ( account->ConnectionType() == 2 ) { 144 if ( account->ConnectionType() == 2 ) {
145 ssl = true; 145 ssl = true;
146 } 146 }
147 if (account->ConnectionType()==1) { 147 if (account->ConnectionType()==1) {
148 force_tls = true; 148 force_tls = true;
149 } 149 }
150 150
151 if ( ssl ) { 151 if ( ssl ) {
152 odebug << "using ssl" << oendl; 152 odebug << "using ssl" << oendl;
153 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 153 err = mailimap_ssl_connect( m_imap, (char*)server, port );
154 } else { 154 } else {
155 err = mailimap_socket_connect( m_imap, (char*)server, port ); 155 err = mailimap_socket_connect( m_imap, (char*)server, port );
156 } 156 }
157 157
158 if ( err != MAILIMAP_NO_ERROR && 158 if ( err != MAILIMAP_NO_ERROR &&
159 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 159 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
160 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 160 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
161 QString failure = ""; 161 QString failure = "";
162 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 162 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
163 failure="Connection refused"; 163 failure="Connection refused";
164 } else { 164 } else {
165 failure="Unknown failure"; 165 failure="Unknown failure";
166 } 166 }
167 Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); 167 Global::statusMessage(tr("error connecting imap server: %1").arg(failure));
168 mailimap_free( m_imap ); 168 mailimap_free( m_imap );
169 m_imap = 0; 169 m_imap = 0;
170 return; 170 return;
171 } 171 }
172 172
173 if (!ssl) { 173 if (!ssl) {
174 try_tls = start_tls(force_tls); 174 try_tls = start_tls(force_tls);
175 } 175 }
176 176
177 bool ok = true; 177 bool ok = true;
178 if (force_tls && !try_tls) { 178 if (force_tls && !try_tls) {
179 Global::statusMessage(tr("Server has no TLS support!")); 179 Global::statusMessage(tr("Server has no TLS support!"));
180 odebug << "Server has no TLS support!" << oendl; 180 odebug << "Server has no TLS support!" << oendl;
181 ok = false; 181 ok = false;
182 } 182 }
183 183
184 184
185 /* login */ 185 /* login */
186 186
187 if (ok) { 187 if (ok) {
188 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 188 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
189 if ( err != MAILIMAP_NO_ERROR ) { 189 if ( err != MAILIMAP_NO_ERROR ) {
190 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); 190 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
191 ok = false; 191 ok = false;
192 } 192 }
193 } 193 }
194 if (!ok) { 194 if (!ok) {
195 err = mailimap_close( m_imap ); 195 err = mailimap_close( m_imap );
196 mailimap_free( m_imap ); 196 mailimap_free( m_imap );
197 m_imap = 0; 197 m_imap = 0;
198 } 198 }
199} 199}
200 200
201void IMAPwrapper::logout() 201void IMAPwrapper::logout()
202{ 202{
203 int err = MAILIMAP_NO_ERROR; 203 int err = MAILIMAP_NO_ERROR;
204 if (!m_imap) return; 204 if (!m_imap) return;
205 err = mailimap_logout( m_imap ); 205 err = mailimap_logout( m_imap );
206 err = mailimap_close( m_imap ); 206 err = mailimap_close( m_imap );
207 mailimap_free( m_imap ); 207 mailimap_free( m_imap );
208 m_imap = 0; 208 m_imap = 0;
209 m_Lastmbox = ""; 209 m_Lastmbox = "";
210} 210}
211 211
212void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 212void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
213{ 213{
214 int err = MAILIMAP_NO_ERROR; 214 int err = MAILIMAP_NO_ERROR;
215 clist *result = 0; 215 clist *result = 0;
216 clistcell *current; 216 clistcell *current;
217 mailimap_fetch_type *fetchType = 0; 217 mailimap_fetch_type *fetchType = 0;
218 mailimap_set *set = 0; 218 mailimap_set *set = 0;
219 219
220 login(); 220 login();
221 if (!m_imap) { 221 if (!m_imap) {
222 return; 222 return;
223 } 223 }
224 /* select mailbox READONLY for operations */ 224 /* select mailbox READONLY for operations */
225 err = selectMbox(mailbox); 225 err = selectMbox(mailbox);
226 if ( err != MAILIMAP_NO_ERROR ) { 226 if ( err != MAILIMAP_NO_ERROR ) {
227 return; 227 return;
228 } 228 }
229 229
230 int last = m_imap->imap_selection_info->sel_exists; 230 int last = m_imap->imap_selection_info->sel_exists;
231 231
232 if (last == 0) { 232 if (last == 0) {
233 Global::statusMessage(tr("Mailbox has no mails")); 233 Global::statusMessage(tr("Mailbox has no mails"));
234 return; 234 return;
235 } else { 235 } else {
236 } 236 }
237 237
238 /* the range has to start at 1!!! not with 0!!!! */ 238 /* the range has to start at 1!!! not with 0!!!! */
239 set = mailimap_set_new_interval( 1, last ); 239 set = mailimap_set_new_interval( 1, last );
240 240
241 241
242 fetchType = mailimap_fetch_type_new_all(); 242 fetchType = mailimap_fetch_type_new_all();
243/* 243/*
244 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 244 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
245 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 245 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
246 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 246 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
247 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 247 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
248 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 248 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
249*/ 249*/
250 err = mailimap_fetch( m_imap, set, fetchType, &result ); 250 err = mailimap_fetch( m_imap, set, fetchType, &result );
251 mailimap_set_free( set ); 251 mailimap_set_free( set );
252 mailimap_fetch_type_free( fetchType ); 252 mailimap_fetch_type_free( fetchType );
253 253
254 QString date,subject,from; 254 QString date,subject,from;
255 255
256 if ( err == MAILIMAP_NO_ERROR ) { 256 if ( err == MAILIMAP_NO_ERROR ) {
257 mailimap_msg_att * msg_att; 257 mailimap_msg_att * msg_att;
258 int i = 0; 258 int i = 0;
259 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 259 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
260 ++i; 260 ++i;
261 msg_att = (mailimap_msg_att*)current->data; 261 msg_att = (mailimap_msg_att*)current->data;
262 RecMail*m = parse_list_result(msg_att); 262 RecMail*m = parse_list_result(msg_att);
263 if (m) { 263 if (m) {
264 m->setNumber(i); 264 m->setNumber(i);
265 m->setMbox(mailbox); 265 m->setMbox(mailbox);
266 m->setWrapper(this); 266 m->setWrapper(this);
267 target.append(m); 267 target.append(m);
268 } 268 }
269 } 269 }
270 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); 270 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
271 } else { 271 } else {
272 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); 272 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
273 } 273 }
274 if (result) mailimap_fetch_list_free(result); 274 if (result) mailimap_fetch_list_free(result);
275} 275}
276 276
277QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 277QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
278{ 278{
279 const char *path, *mask; 279 const char *path, *mask;
280 int err = MAILIMAP_NO_ERROR; 280 int err = MAILIMAP_NO_ERROR;
281 clist *result = 0; 281 clist *result = 0;
282 clistcell *current = 0; 282 clistcell *current = 0;
283 clistcell*cur_flag = 0; 283 clistcell*cur_flag = 0;
284 mailimap_mbx_list_flags*bflags = 0; 284 mailimap_mbx_list_flags*bflags = 0;
285 285
286 QValueList<FolderP>* folders = new QValueList<FolderP>(); 286 QValueList<FolderP>* folders = new QValueList<FolderP>();
287 login(); 287 login();
288 if (!m_imap) { 288 if (!m_imap) {
289 return folders; 289 return folders;
290 } 290 }
291 291
292/* 292/*
293 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 293 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
294 * We must not forget to filter them out in next loop! 294 * We must not forget to filter them out in next loop!
295 * it seems like ugly code. and yes - it is ugly code. but the best way. 295 * it seems like ugly code. and yes - it is ugly code. but the best way.
296 */ 296 */
297 QString temp; 297 QString temp;
298 mask = "INBOX" ; 298 mask = "INBOX" ;
299 mailimap_mailbox_list *list; 299 mailimap_mailbox_list *list;
300 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 300 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
301 QString del; 301 QString del;
302 bool selectable = true; 302 bool selectable = true;
303 bool no_inferiors = false; 303 bool no_inferiors = false;
304 if ( err == MAILIMAP_NO_ERROR ) { 304 if ( err == MAILIMAP_NO_ERROR ) {
305 current = result->first; 305 current = result->first;
306 for ( int i = result->count; i > 0; i-- ) { 306 for ( int i = result->count; i > 0; i-- ) {
307 list = (mailimap_mailbox_list *) current->data; 307 list = (mailimap_mailbox_list *) current->data;
308 // it is better use the deep copy mechanism of qt itself 308 // it is better use the deep copy mechanism of qt itself
309 // instead of using strdup! 309 // instead of using strdup!
310 temp = list->mb_name; 310 temp = list->mb_name;
311 del = list->mb_delimiter; 311 del = list->mb_delimiter;
312 current = current->next; 312 current = current->next;
313 if ( (bflags = list->mb_flag) ) { 313 if ( (bflags = list->mb_flag) ) {
314 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 314 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
315 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 315 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
316 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 316 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
317 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 317 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
318 no_inferiors = true; 318 no_inferiors = true;
319 } 319 }
320 } 320 }
321 } 321 }
322 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 322 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
323 } 323 }
324 } else { 324 } else {
325 odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; 325 odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl;
326 } 326 }
327 mailimap_list_result_free( result ); 327 mailimap_list_result_free( result );
328 328
329/* 329/*
330 * second stage - get the other then inbox folders 330 * second stage - get the other then inbox folders
331 */ 331 */
332 mask = "*" ; 332 mask = "*" ;
333 path = account->getPrefix().latin1(); 333 path = account->getPrefix().latin1();
334 if (!path) path = ""; 334 if (!path) path = "";
335 odebug << path << oendl; 335 odebug << path << oendl;
336 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 336 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
337 if ( err == MAILIMAP_NO_ERROR ) { 337 if ( err == MAILIMAP_NO_ERROR ) {
338 current = result->first; 338 current = result->first;
339 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 339 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
340 no_inferiors = false; 340 no_inferiors = false;
341 list = (mailimap_mailbox_list *) current->data; 341 list = (mailimap_mailbox_list *) current->data;
342 // it is better use the deep copy mechanism of qt itself 342 // it is better use the deep copy mechanism of qt itself
343 // instead of using strdup! 343 // instead of using strdup!
344 temp = list->mb_name; 344 temp = list->mb_name;
345 if (temp.lower()=="inbox") 345 if (temp.lower()=="inbox")
346 continue; 346 continue;
347 if (temp.lower()==account->getPrefix().lower()) 347 if (temp.lower()==account->getPrefix().lower())
348 continue; 348 continue;
349 if ( (bflags = list->mb_flag) ) { 349 if ( (bflags = list->mb_flag) ) {
350 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 350 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
351 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 351 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
352 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 352 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
353 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 353 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
354 no_inferiors = true; 354 no_inferiors = true;
355 } 355 }
356 } 356 }
357 } 357 }
358 del = list->mb_delimiter; 358 del = list->mb_delimiter;
359 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 359 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
360 } 360 }
361 } else { 361 } else {
362 odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; 362 odebug << "error fetching folders " << m_imap->imap_response << "" << oendl;
363 } 363 }
364 if (result) mailimap_list_result_free( result ); 364 if (result) mailimap_list_result_free( result );
365 return folders; 365 return folders;
366} 366}
367 367
368RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 368RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
369{ 369{
370 RecMail * m = 0; 370 RecMail * m = 0;
371 mailimap_msg_att_item *item=0; 371 mailimap_msg_att_item *item=0;
372 clistcell *current,*c,*cf; 372 clistcell *current,*c,*cf;
373 mailimap_msg_att_dynamic*flist; 373 mailimap_msg_att_dynamic*flist;
374 mailimap_flag_fetch*cflag; 374 mailimap_flag_fetch*cflag;
375 int size; 375 int size;
376 QBitArray mFlags(7); 376 QBitArray mFlags(7);
377 QStringList addresslist; 377 QStringList addresslist;
378 378
379 if (!m_att) { 379 if (!m_att) {
380 return m; 380 return m;
381 } 381 }
382 size = 0; 382 size = 0;
383 m = new RecMail(); 383 m = new RecMail();
384 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 384 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
385 current = c; 385 current = c;
386 item = (mailimap_msg_att_item*)current->data; 386 item = (mailimap_msg_att_item*)current->data;
387 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 387 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
388 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 388 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
389 if (!flist->att_list) { 389 if (!flist->att_list) {
390 continue; 390 continue;
391 } 391 }
392 cf = flist->att_list->first; 392 cf = flist->att_list->first;
393 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 393 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
394 cflag = (mailimap_flag_fetch*)cf->data; 394 cflag = (mailimap_flag_fetch*)cf->data;
395 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 395 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
396 switch (cflag->fl_flag->fl_type) { 396 switch (cflag->fl_flag->fl_type) {
397 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 397 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
398 mFlags.setBit(FLAG_ANSWERED); 398 mFlags.setBit(FLAG_ANSWERED);
399 break; 399 break;
400 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 400 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
401 mFlags.setBit(FLAG_FLAGGED); 401 mFlags.setBit(FLAG_FLAGGED);
402 break; 402 break;
403 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 403 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
404 mFlags.setBit(FLAG_DELETED); 404 mFlags.setBit(FLAG_DELETED);
405 break; 405 break;
406 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 406 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
407 mFlags.setBit(FLAG_SEEN); 407 mFlags.setBit(FLAG_SEEN);
408 break; 408 break;
409 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 409 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
410 mFlags.setBit(FLAG_DRAFT); 410 mFlags.setBit(FLAG_DRAFT);
411 break; 411 break;
412 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 412 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
413 break; 413 break;
414 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 414 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
415 break; 415 break;
416 default: 416 default:
417 break; 417 break;
418 } 418 }
419 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 419 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
420 mFlags.setBit(FLAG_RECENT); 420 mFlags.setBit(FLAG_RECENT);
421 } 421 }
422 } 422 }
423 continue; 423 continue;
424 } 424 }
425 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 425 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
426 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 426 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
427 m->setDate(head->env_date); 427 m->setDate(parseDateTime(head->env_date));
428 m->setSubject(convert_String((const char*)head->env_subject)); 428 m->setSubject(convert_String((const char*)head->env_subject));
429 //m->setSubject(head->env_subject);
430 if (head->env_from!=NULL) { 429 if (head->env_from!=NULL) {
431 addresslist = address_list_to_stringlist(head->env_from->frm_list); 430 addresslist = address_list_to_stringlist(head->env_from->frm_list);
432 if (addresslist.count()) { 431 if (addresslist.count()) {
433 m->setFrom(addresslist.first()); 432 m->setFrom(addresslist.first());
434 } 433 }
435 } 434 }
436 if (head->env_to!=NULL) { 435 if (head->env_to!=NULL) {
437 addresslist = address_list_to_stringlist(head->env_to->to_list); 436 addresslist = address_list_to_stringlist(head->env_to->to_list);
438 m->setTo(addresslist); 437 m->setTo(addresslist);
439 } 438 }
440 if (head->env_cc!=NULL) { 439 if (head->env_cc!=NULL) {
441 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 440 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
442 m->setCC(addresslist); 441 m->setCC(addresslist);
443 } 442 }
444 if (head->env_bcc!=NULL) { 443 if (head->env_bcc!=NULL) {
445 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 444 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
446 m->setBcc(addresslist); 445 m->setBcc(addresslist);
447 } 446 }
448 /* reply to address, eg. email. */ 447 /* reply to address, eg. email. */
449 if (head->env_reply_to!=NULL) { 448 if (head->env_reply_to!=NULL) {
450 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 449 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
451 if (addresslist.count()) { 450 if (addresslist.count()) {
452 m->setReplyto(addresslist.first()); 451 m->setReplyto(addresslist.first());
453 } 452 }
454 } 453 }
455 if (head->env_in_reply_to!=NULL) { 454 if (head->env_in_reply_to!=NULL) {
456 QString h(head->env_in_reply_to); 455 QString h(head->env_in_reply_to);
457 while (h.length()>0 && h[0]=='<') { 456 while (h.length()>0 && h[0]=='<') {
458 h.remove(0,1); 457 h.remove(0,1);
459 } 458 }
460 while (h.length()>0 && h[h.length()-1]=='>') { 459 while (h.length()>0 && h[h.length()-1]=='>') {
461 h.remove(h.length()-1,1); 460 h.remove(h.length()-1,1);
462 } 461 }
463 if (h.length()>0) { 462 if (h.length()>0) {
464 m->setInreply(QStringList(h)); 463 m->setInreply(QStringList(h));
465 } 464 }
466 } 465 }
467 if (head->env_message_id) { 466 if (head->env_message_id) {
468 m->setMsgid(QString(head->env_message_id)); 467 m->setMsgid(QString(head->env_message_id));
469 } 468 }
470 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 469 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
471#if 0 470 // not used this moment
472 mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date;
473 if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0;
474 //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
475 QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
476 timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
477 timestring.sprintf(timestring+" %+05i",date->dt_zone);
478 m->setDate(timestring);
479 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
480 odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
481 odebug << da.toString() << oendl;
482#endif
483 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 471 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
484 //size = item->att_data.att_static->att_data.att_rfc822_size; 472 //size = item->att_data.att_static->att_data.att_rfc822_size;
485 m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); 473 m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size);
486 } 474 }
487 } 475 }
488 /* msg is already deleted */ 476 /* msg is already deleted */
489 if (mFlags.testBit(FLAG_DELETED) && m) { 477 if (mFlags.testBit(FLAG_DELETED) && m) {
490 delete m; 478 delete m;
491 m = 0; 479 m = 0;
492 } 480 }
493 if (m) { 481 if (m) {
494 m->setFlags(mFlags); 482 m->setFlags(mFlags);
495 } 483 }
496 return m; 484 return m;
497} 485}
498 486
499RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 487RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
500{ 488{
501 RecBodyP body = new RecBody(); 489 RecBodyP body = new RecBody();
502 const char *mb; 490 const char *mb;
503 int err = MAILIMAP_NO_ERROR; 491 int err = MAILIMAP_NO_ERROR;
504 clist *result = 0; 492 clist *result = 0;
505 clistcell *current; 493 clistcell *current;
506 mailimap_fetch_att *fetchAtt = 0; 494 mailimap_fetch_att *fetchAtt = 0;
507 mailimap_fetch_type *fetchType = 0; 495 mailimap_fetch_type *fetchType = 0;
508 mailimap_set *set = 0; 496 mailimap_set *set = 0;
509 mailimap_body*body_desc = 0; 497 mailimap_body*body_desc = 0;
510 498
511 mb = mail->getMbox().latin1(); 499 mb = mail->getMbox().latin1();
512 500
513 login(); 501 login();
514 if (!m_imap) { 502 if (!m_imap) {
515 return body; 503 return body;
516 } 504 }
517 err = selectMbox(mail->getMbox()); 505 err = selectMbox(mail->getMbox());
518 if ( err != MAILIMAP_NO_ERROR ) { 506 if ( err != MAILIMAP_NO_ERROR ) {
519 return body; 507 return body;
520 } 508 }
521 509
522 /* the range has to start at 1!!! not with 0!!!! */ 510 /* the range has to start at 1!!! not with 0!!!! */
523 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); 511 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
524 fetchAtt = mailimap_fetch_att_new_bodystructure(); 512 fetchAtt = mailimap_fetch_att_new_bodystructure();
525 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 513 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
526 err = mailimap_fetch( m_imap, set, fetchType, &result ); 514 err = mailimap_fetch( m_imap, set, fetchType, &result );
527 mailimap_set_free( set ); 515 mailimap_set_free( set );
528 mailimap_fetch_type_free( fetchType ); 516 mailimap_fetch_type_free( fetchType );
529 517
530 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 518 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
531 mailimap_msg_att * msg_att; 519 mailimap_msg_att * msg_att;
532 msg_att = (mailimap_msg_att*)current->data; 520 msg_att = (mailimap_msg_att*)current->data;
533 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 521 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
534 QValueList<int> path; 522 QValueList<int> path;
535 body_desc = item->att_data.att_static->att_data.att_body; 523 body_desc = item->att_data.att_static->att_data.att_body;
536 traverseBody(mail,body_desc,body,0,path); 524 traverseBody(mail,body_desc,body,0,path);
537 } else { 525 } else {
538 odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; 526 odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
539 } 527 }
540 if (result) mailimap_fetch_list_free(result); 528 if (result) mailimap_fetch_list_free(result);
541 return body; 529 return body;
542} 530}
543 531
544QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 532QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
545{ 533{
546 QStringList l; 534 QStringList l;
547 QString from; 535 QString from;
548 bool named_from; 536 bool named_from;
549 clistcell *current = NULL; 537 clistcell *current = NULL;
550 mailimap_address * current_address=NULL; 538 mailimap_address * current_address=NULL;
551 if (!list) { 539 if (!list) {
552 return l; 540 return l;
553 } 541 }
554 unsigned int count = 0; 542 unsigned int count = 0;
555 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 543 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
556 from = ""; 544 from = "";
557 named_from = false; 545 named_from = false;
558 current_address=(mailimap_address*)current->data; 546 current_address=(mailimap_address*)current->data;
559 if (current_address->ad_personal_name){ 547 if (current_address->ad_personal_name){
560 from+=convert_String((const char*)current_address->ad_personal_name); 548 from+=convert_String((const char*)current_address->ad_personal_name);
561 from+=" "; 549 from+=" ";
562 named_from = true; 550 named_from = true;
563 } 551 }
564 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 552 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
565 from+="<"; 553 from+="<";
566 } 554 }
567 if (current_address->ad_mailbox_name) { 555 if (current_address->ad_mailbox_name) {
568 from+=QString(current_address->ad_mailbox_name); 556 from+=QString(current_address->ad_mailbox_name);
569 from+="@"; 557 from+="@";
570 } 558 }
571 if (current_address->ad_host_name) { 559 if (current_address->ad_host_name) {
572 from+=QString(current_address->ad_host_name); 560 from+=QString(current_address->ad_host_name);
573 } 561 }
574 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 562 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
575 from+=">"; 563 from+=">";
576 } 564 }
577 l.append(QString(from)); 565 l.append(QString(from));
578 if (++count > 99) { 566 if (++count > 99) {
579 break; 567 break;
580 } 568 }
581 } 569 }
582 return l; 570 return l;
583} 571}
584 572
585encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) 573encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
586{ 574{
587 encodedString*res=new encodedString; 575 encodedString*res=new encodedString;
588 int err; 576 int err;
589 mailimap_fetch_type *fetchType; 577 mailimap_fetch_type *fetchType;
590 mailimap_set *set; 578 mailimap_set *set;
591 clistcell*current,*cur; 579 clistcell*current,*cur;
592 mailimap_section_part * section_part = 0; 580 mailimap_section_part * section_part = 0;
593 mailimap_section_spec * section_spec = 0; 581 mailimap_section_spec * section_spec = 0;
594 mailimap_section * section = 0; 582 mailimap_section * section = 0;
595 mailimap_fetch_att * fetch_att = 0; 583 mailimap_fetch_att * fetch_att = 0;
596 584
597 login(); 585 login();
598 if (!m_imap) { 586 if (!m_imap) {
599 return res; 587 return res;
600 } 588 }
601 if (!internal_call) { 589 if (!internal_call) {
602 err = selectMbox(mail->getMbox()); 590 err = selectMbox(mail->getMbox());
603 if ( err != MAILIMAP_NO_ERROR ) { 591 if ( err != MAILIMAP_NO_ERROR ) {
604 return res; 592 return res;
605 } 593 }
606 } 594 }
607 set = mailimap_set_new_single(mail->getNumber()); 595 set = mailimap_set_new_single(mail->getNumber());
608 596
609 clist*id_list = 0; 597 clist*id_list = 0;
610 598
611 /* if path == empty then its a request for the whole rfc822 mail and generates 599 /* if path == empty then its a request for the whole rfc822 mail and generates
612 a "fetch <id> (body[])" statement on imap server */ 600 a "fetch <id> (body[])" statement on imap server */
613 if (path.count()>0 ) { 601 if (path.count()>0 ) {
614 id_list = clist_new(); 602 id_list = clist_new();
615 for (unsigned j=0; j < path.count();++j) { 603 for (unsigned j=0; j < path.count();++j) {
616 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 604 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
617 *p_id = path[j]; 605 *p_id = path[j];
618 clist_append(id_list,p_id); 606 clist_append(id_list,p_id);
619 } 607 }
620 section_part = mailimap_section_part_new(id_list); 608 section_part = mailimap_section_part_new(id_list);
621 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 609 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
622 } 610 }
623 611
624 section = mailimap_section_new(section_spec); 612 section = mailimap_section_new(section_spec);
625 fetch_att = mailimap_fetch_att_new_body_section(section); 613 fetch_att = mailimap_fetch_att_new_body_section(section);
626 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 614 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
627 615
628 clist*result = 0; 616 clist*result = 0;
629 617
630 err = mailimap_fetch( m_imap, set, fetchType, &result ); 618 err = mailimap_fetch( m_imap, set, fetchType, &result );
631 mailimap_set_free( set ); 619 mailimap_set_free( set );
632 mailimap_fetch_type_free( fetchType ); 620 mailimap_fetch_type_free( fetchType );
633 621
634 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 622 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
635 mailimap_msg_att * msg_att; 623 mailimap_msg_att * msg_att;
636 msg_att = (mailimap_msg_att*)current->data; 624 msg_att = (mailimap_msg_att*)current->data;
637 mailimap_msg_att_item*msg_att_item; 625 mailimap_msg_att_item*msg_att_item;
638 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 626 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
639 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 627 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
640 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 628 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
641 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 629 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
642 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 630 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
643 /* detach - we take over the content */ 631 /* detach - we take over the content */
644 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 632 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
645 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); 633 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
646 } 634 }
647 } 635 }
648 } 636 }
649 } else { 637 } else {
650 odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; 638 odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
651 } 639 }
652 if (result) mailimap_fetch_list_free(result); 640 if (result) mailimap_fetch_list_free(result);
653 return res; 641 return res;
654} 642}
655 643
656/* current_recursion is for recursive calls. 644/* current_recursion is for recursive calls.
657 current_count means the position inside the internal loop! */ 645 current_count means the position inside the internal loop! */
658void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, 646void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
659 int current_recursion,QValueList<int>recList,int current_count) 647 int current_recursion,QValueList<int>recList,int current_count)
660{ 648{
661 if (!body || current_recursion>=10) { 649 if (!body || current_recursion>=10) {
662 return; 650 return;
663 } 651 }
664 switch (body->bd_type) { 652 switch (body->bd_type) {
665 case MAILIMAP_BODY_1PART: 653 case MAILIMAP_BODY_1PART:
666 { 654 {
667 QValueList<int>countlist = recList; 655 QValueList<int>countlist = recList;
668 countlist.append(current_count); 656 countlist.append(current_count);
669 RecPartP currentPart = new RecPart(); 657 RecPartP currentPart = new RecPart();
670 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 658 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
671 QString id(""); 659 QString id("");
672 currentPart->setPositionlist(countlist); 660 currentPart->setPositionlist(countlist);
673 for (unsigned int j = 0; j < countlist.count();++j) { 661 for (unsigned int j = 0; j < countlist.count();++j) {
674 id+=(j>0?" ":""); 662 id+=(j>0?" ":"");
675 id+=QString("%1").arg(countlist[j]); 663 id+=QString("%1").arg(countlist[j]);
676 } 664 }
677 odebug << "ID = " << id.latin1() << "" << oendl; 665 odebug << "ID = " << id.latin1() << "" << oendl;
678 currentPart->setIdentifier(id); 666 currentPart->setIdentifier(id);
679 fillSinglePart(currentPart,part1); 667 fillSinglePart(currentPart,part1);
680 /* important: Check for is NULL 'cause a body can be empty! 668 /* important: Check for is NULL 'cause a body can be empty!
681 And we put it only into the mail if it is the FIRST part */ 669 And we put it only into the mail if it is the FIRST part */
682 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 670 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
683 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 671 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
684 target_body->setDescription(currentPart); 672 target_body->setDescription(currentPart);
685 target_body->setBodytext(body_text); 673 target_body->setBodytext(body_text);
686 if (countlist.count()>1) { 674 if (countlist.count()>1) {
687 target_body->addPart(currentPart); 675 target_body->addPart(currentPart);
688 } 676 }
689 } else { 677 } else {
690 target_body->addPart(currentPart); 678 target_body->addPart(currentPart);
691 } 679 }
692 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 680 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
693 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 681 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
694 } 682 }
695 } 683 }
696 break; 684 break;
697 case MAILIMAP_BODY_MPART: 685 case MAILIMAP_BODY_MPART:
698 { 686 {
699 QValueList<int>countlist = recList; 687 QValueList<int>countlist = recList;
700 clistcell*current=0; 688 clistcell*current=0;
701 mailimap_body*current_body=0; 689 mailimap_body*current_body=0;
702 unsigned int ccount = 1; 690 unsigned int ccount = 1;
703 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 691 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
704 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 692 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
705 current_body = (mailimap_body*)current->data; 693 current_body = (mailimap_body*)current->data;
706 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 694 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
707 RecPartP targetPart = new RecPart(); 695 RecPartP targetPart = new RecPart();
708 targetPart->setType("multipart"); 696 targetPart->setType("multipart");
709 fillMultiPart(targetPart,mailDescription); 697 fillMultiPart(targetPart,mailDescription);
710 countlist.append(current_count); 698 countlist.append(current_count);
711 targetPart->setPositionlist(countlist); 699 targetPart->setPositionlist(countlist);
712 target_body->addPart(targetPart); 700 target_body->addPart(targetPart);
713 QString id(""); 701 QString id("");
714 for (unsigned int j = 0; j < countlist.count();++j) { 702 for (unsigned int j = 0; j < countlist.count();++j) {
715 id+=(j>0?" ":""); 703 id+=(j>0?" ":"");
716 id+=QString("%1").arg(countlist[j]); 704 id+=QString("%1").arg(countlist[j]);
717 } 705 }
718 odebug << "ID(mpart) = " << id.latin1() << "" << oendl; 706 odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
719 } 707 }
720 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 708 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
721 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 709 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
722 countlist = recList; 710 countlist = recList;
723 } 711 }
724 ++ccount; 712 ++ccount;
725 } 713 }
726 } 714 }
727 break; 715 break;
728 default: 716 default:
729 break; 717 break;
730 } 718 }
731} 719}
732 720
733void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) 721void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
734{ 722{
735 if (!Description) { 723 if (!Description) {
736 return; 724 return;
737 } 725 }
738 switch (Description->bd_type) { 726 switch (Description->bd_type) {
739 case MAILIMAP_BODY_TYPE_1PART_TEXT: 727 case MAILIMAP_BODY_TYPE_1PART_TEXT:
740 target_part->setType("text"); 728 target_part->setType("text");
741 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 729 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
742 break; 730 break;
743 case MAILIMAP_BODY_TYPE_1PART_BASIC: 731 case MAILIMAP_BODY_TYPE_1PART_BASIC:
744 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 732 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
745 break; 733 break;
746 case MAILIMAP_BODY_TYPE_1PART_MSG: 734 case MAILIMAP_BODY_TYPE_1PART_MSG:
747 target_part->setType("message"); 735 target_part->setType("message");
748 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 736 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
749 break; 737 break;
750 default: 738 default:
751 break; 739 break;
752 } 740 }
753} 741}
754 742
755void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) 743void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
756{ 744{
757 if (!which) { 745 if (!which) {
758 return; 746 return;
759 } 747 }
760 QString sub; 748 QString sub;
761 sub = which->bd_media_text; 749 sub = which->bd_media_text;
762 odebug << "Type= text/" << which->bd_media_text << "" << oendl; 750 odebug << "Type= text/" << which->bd_media_text << "" << oendl;
763 target_part->setSubtype(sub.lower()); 751 target_part->setSubtype(sub.lower());
764 target_part->setLines(which->bd_lines); 752 target_part->setLines(which->bd_lines);
765 fillBodyFields(target_part,which->bd_fields); 753 fillBodyFields(target_part,which->bd_fields);
766} 754}
767 755
768void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) 756void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
769{ 757{
770 if (!which) { 758 if (!which) {
771 return; 759 return;
772 } 760 }
773 target_part->setSubtype("rfc822"); 761 target_part->setSubtype("rfc822");
774 odebug << "Message part" << oendl; 762 odebug << "Message part" << oendl;
775 /* we set this type to text/plain */ 763 /* we set this type to text/plain */
776 target_part->setLines(which->bd_lines); 764 target_part->setLines(which->bd_lines);
777 fillBodyFields(target_part,which->bd_fields); 765 fillBodyFields(target_part,which->bd_fields);
778} 766}
779 767
780void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) 768void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
781{ 769{
782 if (!which) return; 770 if (!which) return;
783 QString sub = which->bd_media_subtype; 771 QString sub = which->bd_media_subtype;
784 target_part->setSubtype(sub.lower()); 772 target_part->setSubtype(sub.lower());
785 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 773 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
786 clistcell*cur = 0; 774 clistcell*cur = 0;
787 mailimap_single_body_fld_param*param=0; 775 mailimap_single_body_fld_param*param=0;
788 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 776 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
789 param = (mailimap_single_body_fld_param*)cur->data; 777 param = (mailimap_single_body_fld_param*)cur->data;
790 if (param) { 778 if (param) {
791 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 779 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
792 } 780 }
793 } 781 }
794 } 782 }
795} 783}
796 784
797void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) 785void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
798{ 786{
799 if (!which) { 787 if (!which) {
800 return; 788 return;
801 } 789 }
802 QString type,sub; 790 QString type,sub;
803 switch (which->bd_media_basic->med_type) { 791 switch (which->bd_media_basic->med_type) {
804 case MAILIMAP_MEDIA_BASIC_APPLICATION: 792 case MAILIMAP_MEDIA_BASIC_APPLICATION:
805 type = "application"; 793 type = "application";
806 break; 794 break;
807 case MAILIMAP_MEDIA_BASIC_AUDIO: 795 case MAILIMAP_MEDIA_BASIC_AUDIO:
808 type = "audio"; 796 type = "audio";
809 break; 797 break;
810 case MAILIMAP_MEDIA_BASIC_IMAGE: 798 case MAILIMAP_MEDIA_BASIC_IMAGE:
811 type = "image"; 799 type = "image";
812 break; 800 break;
813 case MAILIMAP_MEDIA_BASIC_MESSAGE: 801 case MAILIMAP_MEDIA_BASIC_MESSAGE:
814 type = "message"; 802 type = "message";
815 break; 803 break;
816 case MAILIMAP_MEDIA_BASIC_VIDEO: 804 case MAILIMAP_MEDIA_BASIC_VIDEO:
817 type = "video"; 805 type = "video";
818 break; 806 break;
819 case MAILIMAP_MEDIA_BASIC_OTHER: 807 case MAILIMAP_MEDIA_BASIC_OTHER:
820 default: 808 default:
821 if (which->bd_media_basic->med_basic_type) { 809 if (which->bd_media_basic->med_basic_type) {
822 type = which->bd_media_basic->med_basic_type; 810 type = which->bd_media_basic->med_basic_type;
823 } else { 811 } else {
824 type = ""; 812 type = "";
825 } 813 }
826 break; 814 break;
827 } 815 }
828 if (which->bd_media_basic->med_subtype) { 816 if (which->bd_media_basic->med_subtype) {
829 sub = which->bd_media_basic->med_subtype; 817 sub = which->bd_media_basic->med_subtype;
830 } else { 818 } else {
831 sub = ""; 819 sub = "";
832 } 820 }
833 odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; 821 odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
834 target_part->setType(type.lower()); 822 target_part->setType(type.lower());
835 target_part->setSubtype(sub.lower()); 823 target_part->setSubtype(sub.lower());
836 fillBodyFields(target_part,which->bd_fields); 824 fillBodyFields(target_part,which->bd_fields);
837} 825}
838 826
839void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) 827void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
840{ 828{
841 if (!which) return; 829 if (!which) return;
842 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 830 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
843 clistcell*cur; 831 clistcell*cur;
844 mailimap_single_body_fld_param*param=0; 832 mailimap_single_body_fld_param*param=0;
845 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 833 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
846 param = (mailimap_single_body_fld_param*)cur->data; 834 param = (mailimap_single_body_fld_param*)cur->data;
847 if (param) { 835 if (param) {
848 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 836 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
849 } 837 }
850 } 838 }
851 } 839 }
852 mailimap_body_fld_enc*enc = which->bd_encoding; 840 mailimap_body_fld_enc*enc = which->bd_encoding;
853 QString encoding(""); 841 QString encoding("");
854 switch (enc->enc_type) { 842 switch (enc->enc_type) {
855 case MAILIMAP_BODY_FLD_ENC_7BIT: 843 case MAILIMAP_BODY_FLD_ENC_7BIT:
856 encoding = "7bit"; 844 encoding = "7bit";
857 break; 845 break;
858 case MAILIMAP_BODY_FLD_ENC_8BIT: 846 case MAILIMAP_BODY_FLD_ENC_8BIT:
859 encoding = "8bit"; 847 encoding = "8bit";
860 break; 848 break;
861 case MAILIMAP_BODY_FLD_ENC_BINARY: 849 case MAILIMAP_BODY_FLD_ENC_BINARY:
862 encoding="binary"; 850 encoding="binary";
863 break; 851 break;
864 case MAILIMAP_BODY_FLD_ENC_BASE64: 852 case MAILIMAP_BODY_FLD_ENC_BASE64:
865 encoding="base64"; 853 encoding="base64";
866 break; 854 break;
867 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 855 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
868 encoding="quoted-printable"; 856 encoding="quoted-printable";
869 break; 857 break;
870 case MAILIMAP_BODY_FLD_ENC_OTHER: 858 case MAILIMAP_BODY_FLD_ENC_OTHER:
871 default: 859 default:
872 if (enc->enc_value) { 860 if (enc->enc_value) {
873 char*t=enc->enc_value; 861 char*t=enc->enc_value;
874 encoding=QString(enc->enc_value); 862 encoding=QString(enc->enc_value);
875 enc->enc_value=0L; 863 enc->enc_value=0L;
876 free(t); 864 free(t);
877 } 865 }
878 } 866 }
879 if (which->bd_description) { 867 if (which->bd_description) {
880 target_part->setDescription(QString(which->bd_description)); 868 target_part->setDescription(QString(which->bd_description));
881 } 869 }
882 target_part->setEncoding(encoding); 870 target_part->setEncoding(encoding);
883 target_part->setSize(which->bd_size); 871 target_part->setSize(which->bd_size);
884} 872}
885 873
886void IMAPwrapper::deleteMail(const RecMailP&mail) 874void IMAPwrapper::deleteMail(const RecMailP&mail)
887{ 875{
888 mailimap_flag_list*flist; 876 mailimap_flag_list*flist;
889 mailimap_set *set; 877 mailimap_set *set;
890 mailimap_store_att_flags * store_flags; 878 mailimap_store_att_flags * store_flags;
891 int err; 879 int err;
892 login(); 880 login();
893 if (!m_imap) { 881 if (!m_imap) {
894 return; 882 return;
895 } 883 }
896 err = selectMbox(mail->getMbox()); 884 err = selectMbox(mail->getMbox());
897 if ( err != MAILIMAP_NO_ERROR ) { 885 if ( err != MAILIMAP_NO_ERROR ) {
898 return; 886 return;
899 } 887 }
900 flist = mailimap_flag_list_new_empty(); 888 flist = mailimap_flag_list_new_empty();
901 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 889 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
902 store_flags = mailimap_store_att_flags_new_set_flags(flist); 890 store_flags = mailimap_store_att_flags_new_set_flags(flist);
903 set = mailimap_set_new_single(mail->getNumber()); 891 set = mailimap_set_new_single(mail->getNumber());
904 err = mailimap_store(m_imap,set,store_flags); 892 err = mailimap_store(m_imap,set,store_flags);
905 mailimap_set_free( set ); 893 mailimap_set_free( set );
906 mailimap_store_att_flags_free(store_flags); 894 mailimap_store_att_flags_free(store_flags);
907 895
908 if (err != MAILIMAP_NO_ERROR) { 896 if (err != MAILIMAP_NO_ERROR) {
909 odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 897 odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
910 return; 898 return;
911 } 899 }
912 odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 900 odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
913 /* should we realy do that at this moment? */ 901 /* should we realy do that at this moment? */
914 err = mailimap_expunge(m_imap); 902 err = mailimap_expunge(m_imap);
915 if (err != MAILIMAP_NO_ERROR) { 903 if (err != MAILIMAP_NO_ERROR) {
916 odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 904 odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
917 } 905 }
918 odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 906 odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
919} 907}
920 908
921void IMAPwrapper::answeredMail(const RecMailP&mail) 909void IMAPwrapper::answeredMail(const RecMailP&mail)
922{ 910{
923 mailimap_flag_list*flist; 911 mailimap_flag_list*flist;
924 mailimap_set *set; 912 mailimap_set *set;
925 mailimap_store_att_flags * store_flags; 913 mailimap_store_att_flags * store_flags;
926 int err; 914 int err;
927 login(); 915 login();
928 if (!m_imap) { 916 if (!m_imap) {
929 return; 917 return;
930 } 918 }
931 err = selectMbox(mail->getMbox()); 919 err = selectMbox(mail->getMbox());
932 if ( err != MAILIMAP_NO_ERROR ) { 920 if ( err != MAILIMAP_NO_ERROR ) {
933 return; 921 return;
934 } 922 }
935 flist = mailimap_flag_list_new_empty(); 923 flist = mailimap_flag_list_new_empty();
936 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 924 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
937 store_flags = mailimap_store_att_flags_new_add_flags(flist); 925 store_flags = mailimap_store_att_flags_new_add_flags(flist);
938 set = mailimap_set_new_single(mail->getNumber()); 926 set = mailimap_set_new_single(mail->getNumber());
939 err = mailimap_store(m_imap,set,store_flags); 927 err = mailimap_store(m_imap,set,store_flags);
940 mailimap_set_free( set ); 928 mailimap_set_free( set );
941 mailimap_store_att_flags_free(store_flags); 929 mailimap_store_att_flags_free(store_flags);
942 930
943 if (err != MAILIMAP_NO_ERROR) { 931 if (err != MAILIMAP_NO_ERROR) {
944 odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; 932 odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
945 return; 933 return;
946 } 934 }
947} 935}
948 936
949QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) 937QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
950{ 938{
951 QString body(""); 939 QString body("");
952 encodedString*res = fetchRawPart(mail,path,internal_call); 940 encodedString*res = fetchRawPart(mail,path,internal_call);
953 encodedString*r = decode_String(res,enc); 941 encodedString*r = decode_String(res,enc);
954 delete res; 942 delete res;
955 if (r) { 943 if (r) {
956 if (r->Length()>0) { 944 if (r->Length()>0) {
957 body = r->Content(); 945 body = r->Content();
958 } 946 }
959 delete r; 947 delete r;
960 } 948 }
961 return body; 949 return body;
962} 950}
963 951
964QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 952QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
965{ 953{
966 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); 954 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
967} 955}
968 956
969encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) 957encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
970{ 958{
971 encodedString*res = fetchRawPart(mail,part->Positionlist(),false); 959 encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
972 encodedString*r = decode_String(res,part->Encoding()); 960 encodedString*r = decode_String(res,part->Encoding());
973 delete res; 961 delete res;
974 return r; 962 return r;
975} 963}
976 964
977encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) 965encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
978{ 966{
979 return fetchRawPart(mail,part->Positionlist(),false); 967 return fetchRawPart(mail,part->Positionlist(),false);
980} 968}
981 969
982int IMAPwrapper::deleteAllMail(const FolderP&folder) 970int IMAPwrapper::deleteAllMail(const FolderP&folder)
983{ 971{
984 login(); 972 login();
985 if (!m_imap) { 973 if (!m_imap) {
986 return 0; 974 return 0;
987 } 975 }
988 mailimap_flag_list*flist; 976 mailimap_flag_list*flist;
989 mailimap_set *set; 977 mailimap_set *set;
990 mailimap_store_att_flags * store_flags; 978 mailimap_store_att_flags * store_flags;
991 int err = selectMbox(folder->getName()); 979 int err = selectMbox(folder->getName());
992 if ( err != MAILIMAP_NO_ERROR ) { 980 if ( err != MAILIMAP_NO_ERROR ) {
993 return 0; 981 return 0;
994 } 982 }
995 983
996 int last = m_imap->imap_selection_info->sel_exists; 984 int last = m_imap->imap_selection_info->sel_exists;
997 if (last == 0) { 985 if (last == 0) {
998 Global::statusMessage(tr("Mailbox has no mails!")); 986 Global::statusMessage(tr("Mailbox has no mails!"));
999 return 0; 987 return 0;
1000 } 988 }
1001 flist = mailimap_flag_list_new_empty(); 989 flist = mailimap_flag_list_new_empty();
1002 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 990 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1003 store_flags = mailimap_store_att_flags_new_set_flags(flist); 991 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1004 set = mailimap_set_new_interval( 1, last ); 992 set = mailimap_set_new_interval( 1, last );
1005 err = mailimap_store(m_imap,set,store_flags); 993 err = mailimap_store(m_imap,set,store_flags);
1006 mailimap_set_free( set ); 994 mailimap_set_free( set );
1007 mailimap_store_att_flags_free(store_flags); 995 mailimap_store_att_flags_free(store_flags);
1008 if (err != MAILIMAP_NO_ERROR) { 996 if (err != MAILIMAP_NO_ERROR) {
1009 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 997 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1010 return 0; 998 return 0;
1011 } 999 }
1012 odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1000 odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1013 /* should we realy do that at this moment? */ 1001 /* should we realy do that at this moment? */
1014 err = mailimap_expunge(m_imap); 1002 err = mailimap_expunge(m_imap);
1015 if (err != MAILIMAP_NO_ERROR) { 1003 if (err != MAILIMAP_NO_ERROR) {
1016 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1004 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1017 return 0; 1005 return 0;
1018 } 1006 }
1019 odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 1007 odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
1020 return 1; 1008 return 1;
1021} 1009}
1022 1010
1023int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) 1011int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
1024{ 1012{
1025 if (folder.length()==0) return 0; 1013 if (folder.length()==0) return 0;
1026 login(); 1014 login();
1027 if (!m_imap) {return 0;} 1015 if (!m_imap) {return 0;}
1028 QString pre = account->getPrefix(); 1016 QString pre = account->getPrefix();
1029 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { 1017 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
1030 pre+=delemiter; 1018 pre+=delemiter;
1031 } 1019 }
1032 if (parentfolder) { 1020 if (parentfolder) {
1033 pre += parentfolder->getDisplayName()+delemiter; 1021 pre += parentfolder->getDisplayName()+delemiter;
1034 } 1022 }
1035 pre+=folder; 1023 pre+=folder;
1036 if (getsubfolder) { 1024 if (getsubfolder) {
1037 if (delemiter.length()>0) { 1025 if (delemiter.length()>0) {
1038 pre+=delemiter; 1026 pre+=delemiter;
1039 } else { 1027 } else {
1040 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); 1028 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
1041 return 0; 1029 return 0;
1042 } 1030 }
1043 } 1031 }
1044 odebug << "Creating " << pre.latin1() << "" << oendl; 1032 odebug << "Creating " << pre.latin1() << "" << oendl;
1045 int res = mailimap_create(m_imap,pre.latin1()); 1033 int res = mailimap_create(m_imap,pre.latin1());
1046 if (res != MAILIMAP_NO_ERROR) { 1034 if (res != MAILIMAP_NO_ERROR) {
1047 Global::statusMessage(tr("%1").arg(m_imap->imap_response)); 1035 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
1048 return 0; 1036 return 0;
1049 } 1037 }
1050 return 1; 1038 return 1;
1051} 1039}
1052 1040
1053int IMAPwrapper::deleteMbox(const FolderP&folder) 1041int IMAPwrapper::deleteMbox(const FolderP&folder)
1054{ 1042{
1055 if (!folder) return 0; 1043 if (!folder) return 0;
1056 login(); 1044 login();
1057 if (!m_imap) {return 0;} 1045 if (!m_imap) {return 0;}
1058 int res = mailimap_delete(m_imap,folder->getName()); 1046 int res = mailimap_delete(m_imap,folder->getName());
1059 if (res != MAILIMAP_NO_ERROR) { 1047 if (res != MAILIMAP_NO_ERROR) {
1060 Global::statusMessage(tr("%1").arg(m_imap->imap_response)); 1048 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
1061 return 0; 1049 return 0;
1062 } 1050 }
1063 return 1; 1051 return 1;
1064} 1052}
1065 1053
1066void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 1054void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
1067{ 1055{
1068 mailimap_status_att_list * att_list =0; 1056 mailimap_status_att_list * att_list =0;
1069 mailimap_mailbox_data_status * status=0; 1057 mailimap_mailbox_data_status * status=0;
1070 clistiter * cur = 0; 1058 clistiter * cur = 0;
1071 int r = 0; 1059 int r = 0;
1072 target_stat.message_count = 0; 1060 target_stat.message_count = 0;
1073 target_stat.message_unseen = 0; 1061 target_stat.message_unseen = 0;
1074 target_stat.message_recent = 0; 1062 target_stat.message_recent = 0;
1075 login(); 1063 login();
1076 if (!m_imap) { 1064 if (!m_imap) {
1077 return; 1065 return;
1078 } 1066 }
1079 att_list = mailimap_status_att_list_new_empty(); 1067 att_list = mailimap_status_att_list_new_empty();
1080 if (!att_list) return; 1068 if (!att_list) return;
1081 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); 1069 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
1082 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); 1070 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
1083 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); 1071 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
1084 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 1072 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
1085 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { 1073 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
1086 for (cur = clist_begin(status->st_info_list); 1074 for (cur = clist_begin(status->st_info_list);
1087 cur != NULL ; cur = clist_next(cur)) { 1075 cur != NULL ; cur = clist_next(cur)) {
1088 mailimap_status_info * status_info; 1076 mailimap_status_info * status_info;
1089 status_info = (mailimap_status_info *)clist_content(cur); 1077 status_info = (mailimap_status_info *)clist_content(cur);
1090 switch (status_info->st_att) { 1078 switch (status_info->st_att) {
1091 case MAILIMAP_STATUS_ATT_MESSAGES: 1079 case MAILIMAP_STATUS_ATT_MESSAGES:
1092 target_stat.message_count = status_info->st_value; 1080 target_stat.message_count = status_info->st_value;
1093 break; 1081 break;
1094 case MAILIMAP_STATUS_ATT_RECENT: 1082 case MAILIMAP_STATUS_ATT_RECENT:
1095 target_stat.message_recent = status_info->st_value; 1083 target_stat.message_recent = status_info->st_value;
1096 break; 1084 break;
1097 case MAILIMAP_STATUS_ATT_UNSEEN: 1085 case MAILIMAP_STATUS_ATT_UNSEEN:
1098 target_stat.message_unseen = status_info->st_value; 1086 target_stat.message_unseen = status_info->st_value;
1099 break; 1087 break;
1100 } 1088 }
1101 } 1089 }
1102 } else { 1090 } else {
1103 odebug << "Error retrieving status" << oendl; 1091 odebug << "Error retrieving status" << oendl;
1104 } 1092 }
1105 if (status) mailimap_mailbox_data_status_free(status); 1093 if (status) mailimap_mailbox_data_status_free(status);
1106 if (att_list) mailimap_status_att_list_free(att_list); 1094 if (att_list) mailimap_status_att_list_free(att_list);
1107} 1095}
1108 1096
1109void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 1097void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
1110{ 1098{
1111 login(); 1099 login();
1112 if (!m_imap) return; 1100 if (!m_imap) return;
1113 if (!msg) return; 1101 if (!msg) return;
1114 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); 1102 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
1115 if (r != MAILIMAP_NO_ERROR) { 1103 if (r != MAILIMAP_NO_ERROR) {
1116 Global::statusMessage("Error storing mail!"); 1104 Global::statusMessage("Error storing mail!");
1117 } 1105 }
1118} 1106}
1119 1107
1120MAILLIB::ATYPE IMAPwrapper::getType()const 1108MAILLIB::ATYPE IMAPwrapper::getType()const
1121{ 1109{
1122 return account->getType(); 1110 return account->getType();
1123} 1111}
1124 1112
1125const QString&IMAPwrapper::getName()const 1113const QString&IMAPwrapper::getName()const
1126{ 1114{
1127 odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; 1115 odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
1128 return account->getAccountName(); 1116 return account->getAccountName();
1129} 1117}
1130 1118
1131encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) 1119encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
1132{ 1120{
1133 // dummy 1121 // dummy
1134 QValueList<int> path; 1122 QValueList<int> path;
1135 return fetchRawPart(mail,path,false); 1123 return fetchRawPart(mail,path,false);
1136} 1124}
1137 1125
1138void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, 1126void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1139 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1127 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1140{ 1128{
1141 if (targetWrapper != this) { 1129 if (targetWrapper != this) {
1142 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 1130 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
1143 odebug << "Using generic" << oendl; 1131 odebug << "Using generic" << oendl;
1144 return; 1132 return;
1145 } 1133 }
1146 mailimap_set *set = 0; 1134 mailimap_set *set = 0;
1147 login(); 1135 login();
1148 if (!m_imap) { 1136 if (!m_imap) {
1149 return; 1137 return;
1150 } 1138 }
1151 int err = selectMbox(fromFolder->getName()); 1139 int err = selectMbox(fromFolder->getName());
1152 if ( err != MAILIMAP_NO_ERROR ) { 1140 if ( err != MAILIMAP_NO_ERROR ) {
1153 return; 1141 return;
1154 } 1142 }
1155 int last = m_imap->imap_selection_info->sel_exists; 1143 int last = m_imap->imap_selection_info->sel_exists;
1156 set = mailimap_set_new_interval( 1, last ); 1144 set = mailimap_set_new_interval( 1, last );
1157 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1145 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1158 mailimap_set_free( set ); 1146 mailimap_set_free( set );
1159 if ( err != MAILIMAP_NO_ERROR ) { 1147 if ( err != MAILIMAP_NO_ERROR ) {
1160 QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); 1148 QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
1161 Global::statusMessage(error_msg); 1149 Global::statusMessage(error_msg);
1162 odebug << error_msg << oendl; 1150 odebug << error_msg << oendl;
1163 return; 1151 return;
1164 } 1152 }
1165 if (moveit) { 1153 if (moveit) {
1166 deleteAllMail(fromFolder); 1154 deleteAllMail(fromFolder);
1167 } 1155 }
1168} 1156}
1169 1157
1170void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1158void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1171{ 1159{
1172 if (targetWrapper != this) { 1160 if (targetWrapper != this) {
1173 odebug << "Using generic" << oendl; 1161 odebug << "Using generic" << oendl;
1174 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); 1162 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
1175 return; 1163 return;
1176 } 1164 }
1177 mailimap_set *set = 0; 1165 mailimap_set *set = 0;
1178 login(); 1166 login();
1179 if (!m_imap) { 1167 if (!m_imap) {
1180 return; 1168 return;
1181 } 1169 }
1182 int err = selectMbox(mail->getMbox()); 1170 int err = selectMbox(mail->getMbox());
1183 if ( err != MAILIMAP_NO_ERROR ) { 1171 if ( err != MAILIMAP_NO_ERROR ) {
1184 return; 1172 return;
1185 } 1173 }
1186 set = mailimap_set_new_single(mail->getNumber()); 1174 set = mailimap_set_new_single(mail->getNumber());
1187 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1175 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1188 mailimap_set_free( set ); 1176 mailimap_set_free( set );
1189 if ( err != MAILIMAP_NO_ERROR ) { 1177 if ( err != MAILIMAP_NO_ERROR ) {
1190 QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); 1178 QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response);
1191 Global::statusMessage(error_msg); 1179 Global::statusMessage(error_msg);
1192 odebug << error_msg << oendl; 1180 odebug << error_msg << oendl;
1193 return; 1181 return;
1194 } 1182 }
1195 if (moveit) { 1183 if (moveit) {
1196 deleteMail(mail); 1184 deleteMail(mail);
1197 } 1185 }
1198} 1186}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index e56605a..5efcfc9 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,80 +1,81 @@
1#ifndef __IMAPWRAPPER 1#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 2#define __IMAPWRAPPER
3 3
4#include <qlist.h> 4#include <qlist.h>
5#include "mailwrapper.h" 5#include "mailwrapper.h"
6#include "abstractmail.h" 6#include "abstractmail.h"
7#include "mailstatics.h"
7#include <libetpan/clist.h> 8#include <libetpan/clist.h>
8 9
9struct mailimap; 10struct mailimap;
10struct mailimap_body; 11struct mailimap_body;
11struct mailimap_body_type_1part; 12struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 13struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 14struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 15struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 16struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 17struct mailimap_body_fields;
17struct mailimap_msg_att; 18struct mailimap_msg_att;
18class encodedString; 19class encodedString;
19 20
20class IMAPwrapper : public AbstractMail 21class IMAPwrapper : public AbstractMail,public MailStatics
21{ 22{
22 Q_OBJECT 23 Q_OBJECT
23public: 24public:
24 IMAPwrapper( IMAPaccount *a ); 25 IMAPwrapper( IMAPaccount *a );
25 virtual ~IMAPwrapper(); 26 virtual ~IMAPwrapper();
26 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 27 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
27 virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); 28 virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 29 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 30
30 virtual void deleteMail(const RecMailP&mail); 31 virtual void deleteMail(const RecMailP&mail);
31 virtual void answeredMail(const RecMailP&mail); 32 virtual void answeredMail(const RecMailP&mail);
32 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); 33 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder);
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 34 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 35 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
35 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 36 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
36 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 37 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
37 38
38 virtual RecBodyP fetchBody(const RecMailP&mail); 39 virtual RecBodyP fetchBody(const RecMailP&mail);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); 40 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
40 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); 41 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
41 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); 42 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
42 virtual encodedString* fetchRawBody(const RecMailP&mail); 43 virtual encodedString* fetchRawBody(const RecMailP&mail);
43 44
44 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, 45 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
45 const QString& delemiter="/",bool getsubfolder=false); 46 const QString& delemiter="/",bool getsubfolder=false);
46 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); 47 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder);
47 48
48 static void imap_progress( size_t current, size_t maximum ); 49 static void imap_progress( size_t current, size_t maximum );
49 50
50 virtual void logout(); 51 virtual void logout();
51 virtual MAILLIB::ATYPE getType()const; 52 virtual MAILLIB::ATYPE getType()const;
52 virtual const QString&getName()const; 53 virtual const QString&getName()const;
53 54
54protected: 55protected:
55 RecMail*parse_list_result(mailimap_msg_att*); 56 RecMail*parse_list_result(mailimap_msg_att*);
56 void login(); 57 void login();
57 bool start_tls(bool force=true); 58 bool start_tls(bool force=true);
58 59
59 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 60 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
60 virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); 61 virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call);
61 int selectMbox(const QString&mbox); 62 int selectMbox(const QString&mbox);
62 63
63 void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); 64 void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description);
64 void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); 65 void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which);
65 void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); 66 void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which);
66 void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); 67 void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which);
67 void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); 68 void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which);
68 void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); 69 void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
69 70
70 /* just helpers */ 71 /* just helpers */
71 static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); 72 static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which);
72 static QStringList address_list_to_stringlist(clist*list); 73 static QStringList address_list_to_stringlist(clist*list);
73 74
74 75
75 IMAPaccount *account; 76 IMAPaccount *account;
76 mailimap *m_imap; 77 mailimap *m_imap;
77 QString m_Lastmbox; 78 QString m_Lastmbox;
78}; 79};
79 80
80#endif 81#endif