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