summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp60
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp60
-rw-r--r--noncore/net/mail/mainwindow.cpp2
3 files changed, 67 insertions, 55 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index eae85a7..dc02780 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -22,34 +22,40 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
22} 22}
23 23
24void IMAPwrapper::login() 24void IMAPwrapper::login()
25{ 25{
26 logout(); 26 logout();
27 const char *server, *user, *pass; 27 const char *server, *user, *pass;
28 uint16_t port; 28 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 29 int err = MAILIMAP_NO_ERROR;
30 30
31 server = account->getServer().latin1(); 31 server = account->getServer().latin1();
32 port = account->getPort().toUInt(); 32 port = account->getPort().toUInt();
33 user = account->getUser().latin1(); 33 user = account->getUser().latin1();
34 pass = account->getPassword().latin1(); 34 pass = account->getPassword().latin1();
35 35
36 m_imap = mailimap_new( 20, &imap_progress ); 36 m_imap = mailimap_new( 20, &imap_progress );
37 /* connect */ 37 /* connect */
38 err = mailimap_socket_connect( m_imap, (char*)server, port ); 38 // err = mailimap_socket_connect( m_imap, (char*)server, port );
39 if ( err != MAILIMAP_NO_ERROR && 39 if (account->getSSL()) {
40 err = mailimap_ssl_connect( m_imap, (char*)server, port );
41 } else {
42 err = mailimap_socket_connect( m_imap, (char*)server, port );
43 }
44
45 if ( err != MAILIMAP_NO_ERROR &&
40 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 46 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
41 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 47 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
42 qDebug("error connecting server: %s",m_imap->response); 48 qDebug("error connecting server: %s",m_imap->response);
43 mailimap_free( m_imap ); 49 mailimap_free( m_imap );
44 m_imap = 0; 50 m_imap = 0;
45 return; 51 return;
46 } 52 }
47 53
48 /* login */ 54 /* login */
49 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 55 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
50 if ( err != MAILIMAP_NO_ERROR ) { 56 if ( err != MAILIMAP_NO_ERROR ) {
51 qDebug("error logging in imap: %s",m_imap->response); 57 qDebug("error logging in imap: %s",m_imap->response);
52 err = mailimap_close( m_imap ); 58 err = mailimap_close( m_imap );
53 mailimap_free( m_imap ); 59 mailimap_free( m_imap );
54 m_imap = 0; 60 m_imap = 0;
55 } 61 }
@@ -69,17 +75,17 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
69{ 75{
70 const char *mb; 76 const char *mb;
71 int err = MAILIMAP_NO_ERROR; 77 int err = MAILIMAP_NO_ERROR;
72 clist *result; 78 clist *result;
73 clistcell *current; 79 clistcell *current;
74 mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; 80 mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate;
75 mailimap_fetch_type *fetchType; 81 mailimap_fetch_type *fetchType;
76 mailimap_set *set; 82 mailimap_set *set;
77 83
78 mb = mailbox.latin1(); 84 mb = mailbox.latin1();
79 login(); 85 login();
80 if (!m_imap) { 86 if (!m_imap) {
81 return; 87 return;
82 } 88 }
83 /* select mailbox READONLY for operations */ 89 /* select mailbox READONLY for operations */
84 err = mailimap_examine( m_imap, (char*)mb); 90 err = mailimap_examine( m_imap, (char*)mb);
85 if ( err != MAILIMAP_NO_ERROR ) { 91 if ( err != MAILIMAP_NO_ERROR ) {
@@ -90,30 +96,30 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
90 96
91 int last = m_imap->selection_info->exists; 97 int last = m_imap->selection_info->exists;
92 98
93 if (last == 0) { 99 if (last == 0) {
94 qDebug("mailbox has no mails"); 100 qDebug("mailbox has no mails");
95 logout(); 101 logout();
96 return; 102 return;
97 } 103 }
98 104
99 result = clist_new(); 105 result = clist_new();
100 /* the range has to start at 1!!! not with 0!!!! */ 106 /* the range has to start at 1!!! not with 0!!!! */
101 set = mailimap_set_new_interval( 1, last ); 107 set = mailimap_set_new_interval( 1, last );
102 fetchAtt = mailimap_fetch_att_new_envelope(); 108 fetchAtt = mailimap_fetch_att_new_envelope();
103 fetchAttFlags = mailimap_fetch_att_new_flags(); 109 fetchAttFlags = mailimap_fetch_att_new_flags();
104 fetchAttDate = mailimap_fetch_att_new_internaldate(); 110 fetchAttDate = mailimap_fetch_att_new_internaldate();
105 111
106 //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 112 //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
107 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 113 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
108 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); 114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt);
109 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); 115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags);
110 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate); 116 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate);
111 117
112 err = mailimap_fetch( m_imap, set, fetchType, &result ); 118 err = mailimap_fetch( m_imap, set, fetchType, &result );
113 mailimap_set_free( set ); 119 mailimap_set_free( set );
114 /* cleans up the fetch_att's too! */ 120 /* cleans up the fetch_att's too! */
115 mailimap_fetch_type_free( fetchType ); 121 mailimap_fetch_type_free( fetchType );
116 122
117 QString date,subject,from; 123 QString date,subject,from;
118 124
119 if ( err == MAILIMAP_NO_ERROR ) { 125 if ( err == MAILIMAP_NO_ERROR ) {
@@ -139,24 +145,24 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
139} 145}
140 146
141QList<IMAPFolder>* IMAPwrapper::listFolders() 147QList<IMAPFolder>* IMAPwrapper::listFolders()
142{ 148{
143 const char *path, *mask; 149 const char *path, *mask;
144 int err = MAILIMAP_NO_ERROR; 150 int err = MAILIMAP_NO_ERROR;
145 clist *result; 151 clist *result;
146 clistcell *current; 152 clistcell *current;
147 153
148 QList<IMAPFolder> * folders = new QList<IMAPFolder>(); 154 QList<IMAPFolder> * folders = new QList<IMAPFolder>();
149 folders->setAutoDelete( true ); 155 folders->setAutoDelete( true );
150 login(); 156 login();
151 if (!m_imap) { 157 if (!m_imap) {
152 return folders; 158 return folders;
153 } 159 }
154 160
155/* 161/*
156 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 162 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
157 * We must not forget to filter them out in next loop! 163 * We must not forget to filter them out in next loop!
158 * it seems like ugly code. and yes - it is ugly code. but the best way. 164 * it seems like ugly code. and yes - it is ugly code. but the best way.
159 */ 165 */
160 QString temp; 166 QString temp;
161 mask = "INBOX" ; 167 mask = "INBOX" ;
162 result = clist_new(); 168 result = clist_new();
@@ -171,37 +177,37 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
171 temp = list->mb; 177 temp = list->mb;
172 folders->append( new IMAPFolder(temp)); 178 folders->append( new IMAPFolder(temp));
173 current = current->next; 179 current = current->next;
174 } 180 }
175 } else { 181 } else {
176 qDebug("error fetching folders: %s",m_imap->response); 182 qDebug("error fetching folders: %s",m_imap->response);
177 } 183 }
178 mailimap_list_result_free( result ); 184 mailimap_list_result_free( result );
179 185
180/* 186/*
181 * second stage - get the other then inbox folders 187 * second stage - get the other then inbox folders
182 */ 188 */
183 mask = "*" ; 189 mask = "*" ;
184 path = account->getPrefix().latin1(); 190 path = account->getPrefix().latin1();
185 result = clist_new(); 191 result = clist_new();
186 qDebug(path); 192 qDebug(path);
187 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
188 if ( err == MAILIMAP_NO_ERROR ) { 194 if ( err == MAILIMAP_NO_ERROR ) {
189 current = result->first; 195 current = result->first;
190 for ( int i = result->count; i > 0; i-- ) { 196 for ( int i = result->count; i > 0; i-- ) {
191 list = (mailimap_mailbox_list *) current->data; 197 list = (mailimap_mailbox_list *) current->data;
192 // it is better use the deep copy mechanism of qt itself 198 // it is better use the deep copy mechanism of qt itself
193 // instead of using strdup! 199 // instead of using strdup!
194 temp = list->mb; 200 temp = list->mb;
195 current = current->next; 201 current = current->next;
196 if (temp.lower()=="inbox") 202 if (temp.lower()=="inbox")
197 continue; 203 continue;
198 folders->append(new IMAPFolder(temp)); 204 folders->append(new IMAPFolder(temp));
199 205
200 } 206 }
201 } else { 207 } else {
202 qDebug("error fetching folders %s",m_imap->response); 208 qDebug("error fetching folders %s",m_imap->response);
203 } 209 }
204 mailimap_list_result_free( result ); 210 mailimap_list_result_free( result );
205 return folders; 211 return folders;
206} 212}
207 213
@@ -209,17 +215,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
209{ 215{
210 RecMail * m = 0; 216 RecMail * m = 0;
211 mailimap_msg_att_item *item=0; 217 mailimap_msg_att_item *item=0;
212 clistcell *current,*c,*cf; 218 clistcell *current,*c,*cf;
213 mailimap_msg_att_dynamic*flist; 219 mailimap_msg_att_dynamic*flist;
214 mailimap_flag_fetch*cflag; 220 mailimap_flag_fetch*cflag;
215 QBitArray mFlags(7); 221 QBitArray mFlags(7);
216 QStringList addresslist; 222 QStringList addresslist;
217 223
218 if (!m_att) { 224 if (!m_att) {
219 return m; 225 return m;
220 } 226 }
221 227
222 c = clist_begin(m_att->list); 228 c = clist_begin(m_att->list);
223 while ( c ) { 229 while ( c ) {
224 current = c; 230 current = c;
225 c = c->next; 231 c = c->next;
@@ -324,55 +330,55 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
324 const char *mb; 330 const char *mb;
325 int err = MAILIMAP_NO_ERROR; 331 int err = MAILIMAP_NO_ERROR;
326 clist *result; 332 clist *result;
327 clistcell *current; 333 clistcell *current;
328 mailimap_fetch_att *fetchAtt; 334 mailimap_fetch_att *fetchAtt;
329 mailimap_fetch_type *fetchType; 335 mailimap_fetch_type *fetchType;
330 mailimap_set *set; 336 mailimap_set *set;
331 mailimap_body*body_desc; 337 mailimap_body*body_desc;
332 338
333 mb = mail.getMbox().latin1(); 339 mb = mail.getMbox().latin1();
334 340
335 login(); 341 login();
336 if (!m_imap) { 342 if (!m_imap) {
337 return body; 343 return body;
338 } 344 }
339 /* select mailbox READONLY for operations */ 345 /* select mailbox READONLY for operations */
340 err = mailimap_examine( m_imap, (char*)mb); 346 err = mailimap_examine( m_imap, (char*)mb);
341 if ( err != MAILIMAP_NO_ERROR ) { 347 if ( err != MAILIMAP_NO_ERROR ) {
342 qDebug("error selecting mailbox: %s",m_imap->response); 348 qDebug("error selecting mailbox: %s",m_imap->response);
343 logout(); 349 logout();
344 return body; 350 return body;
345 } 351 }
346 result = clist_new(); 352 result = clist_new();
347 /* the range has to start at 1!!! not with 0!!!! */ 353 /* the range has to start at 1!!! not with 0!!!! */
348 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
349 fetchAtt = mailimap_fetch_att_new_body(); 355 fetchAtt = mailimap_fetch_att_new_body();
350 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
351 err = mailimap_fetch( m_imap, set, fetchType, &result ); 357 err = mailimap_fetch( m_imap, set, fetchType, &result );
352 mailimap_set_free( set ); 358 mailimap_set_free( set );
353 mailimap_fetch_type_free( fetchType ); 359 mailimap_fetch_type_free( fetchType );
354 360
355 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
356 mailimap_msg_att * msg_att; 362 mailimap_msg_att * msg_att;
357 msg_att = (mailimap_msg_att*)current->data; 363 msg_att = (mailimap_msg_att*)current->data;
358 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; 364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data;
359 body_desc = item->msg_att_static->body; 365 body_desc = item->msg_att_static->body;
360 if (body_desc->type==MAILIMAP_BODY_1PART) { 366 if (body_desc->type==MAILIMAP_BODY_1PART) {
361 searchBodyText(mail,body_desc->body_1part,body); 367 searchBodyText(mail,body_desc->body_1part,body);
362 } else { 368 } else {
363 } 369 }
364 370
365 } else { 371 } else {
366 qDebug("error fetching body: %s",m_imap->response); 372 qDebug("error fetching body: %s",m_imap->response);
367 } 373 }
368 374
369 clist_free(result); 375 clist_free(result);
370 logout(); 376 logout();
371 return body; 377 return body;
372} 378}
373 379
374void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) 380void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
375{ 381{
376 if (!mailDescription) { 382 if (!mailDescription) {
377 return; 383 return;
378 } 384 }
@@ -391,32 +397,32 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
391 const char *mb; 397 const char *mb;
392 QString body=""; 398 QString body="";
393 int err = MAILIMAP_NO_ERROR; 399 int err = MAILIMAP_NO_ERROR;
394 clist *result; 400 clist *result;
395 clistcell *current; 401 clistcell *current;
396 mailimap_fetch_att *fetchAtt; 402 mailimap_fetch_att *fetchAtt;
397 mailimap_fetch_type *fetchType; 403 mailimap_fetch_type *fetchType;
398 mailimap_set *set; 404 mailimap_set *set;
399 405
400 mb = mail.getMbox().latin1(); 406 mb = mail.getMbox().latin1();
401 407
402 if (!m_imap) { 408 if (!m_imap) {
403 return; 409 return;
404 } 410 }
405 411
406 result = clist_new(); 412 result = clist_new();
407 /* the range has to start at 1!!! not with 0!!!! */ 413 /* the range has to start at 1!!! not with 0!!!! */
408 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 414 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
409 fetchAtt = mailimap_fetch_att_new_rfc822_text(); 415 fetchAtt = mailimap_fetch_att_new_rfc822_text();
410 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 416 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
411 err = mailimap_fetch( m_imap, set, fetchType, &result ); 417 err = mailimap_fetch( m_imap, set, fetchType, &result );
412 mailimap_set_free( set ); 418 mailimap_set_free( set );
413 mailimap_fetch_type_free( fetchType ); 419 mailimap_fetch_type_free( fetchType );
414 420
415 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 421 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
416 mailimap_msg_att * msg_att; 422 mailimap_msg_att * msg_att;
417 msg_att = (mailimap_msg_att*)current->data; 423 msg_att = (mailimap_msg_att*)current->data;
418 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; 424 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data;
419 if (item->msg_att_static && item->msg_att_static->rfc822_text) { 425 if (item->msg_att_static && item->msg_att_static->rfc822_text) {
420 body = item->msg_att_static->rfc822_text; 426 body = item->msg_att_static->rfc822_text;
421 } 427 }
422 } else { 428 } else {
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index eae85a7..dc02780 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -22,34 +22,40 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
22} 22}
23 23
24void IMAPwrapper::login() 24void IMAPwrapper::login()
25{ 25{
26 logout(); 26 logout();
27 const char *server, *user, *pass; 27 const char *server, *user, *pass;
28 uint16_t port; 28 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 29 int err = MAILIMAP_NO_ERROR;
30 30
31 server = account->getServer().latin1(); 31 server = account->getServer().latin1();
32 port = account->getPort().toUInt(); 32 port = account->getPort().toUInt();
33 user = account->getUser().latin1(); 33 user = account->getUser().latin1();
34 pass = account->getPassword().latin1(); 34 pass = account->getPassword().latin1();
35 35
36 m_imap = mailimap_new( 20, &imap_progress ); 36 m_imap = mailimap_new( 20, &imap_progress );
37 /* connect */ 37 /* connect */
38 err = mailimap_socket_connect( m_imap, (char*)server, port ); 38 // err = mailimap_socket_connect( m_imap, (char*)server, port );
39 if ( err != MAILIMAP_NO_ERROR && 39 if (account->getSSL()) {
40 err = mailimap_ssl_connect( m_imap, (char*)server, port );
41 } else {
42 err = mailimap_socket_connect( m_imap, (char*)server, port );
43 }
44
45 if ( err != MAILIMAP_NO_ERROR &&
40 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 46 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
41 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 47 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
42 qDebug("error connecting server: %s",m_imap->response); 48 qDebug("error connecting server: %s",m_imap->response);
43 mailimap_free( m_imap ); 49 mailimap_free( m_imap );
44 m_imap = 0; 50 m_imap = 0;
45 return; 51 return;
46 } 52 }
47 53
48 /* login */ 54 /* login */
49 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 55 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
50 if ( err != MAILIMAP_NO_ERROR ) { 56 if ( err != MAILIMAP_NO_ERROR ) {
51 qDebug("error logging in imap: %s",m_imap->response); 57 qDebug("error logging in imap: %s",m_imap->response);
52 err = mailimap_close( m_imap ); 58 err = mailimap_close( m_imap );
53 mailimap_free( m_imap ); 59 mailimap_free( m_imap );
54 m_imap = 0; 60 m_imap = 0;
55 } 61 }
@@ -69,17 +75,17 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
69{ 75{
70 const char *mb; 76 const char *mb;
71 int err = MAILIMAP_NO_ERROR; 77 int err = MAILIMAP_NO_ERROR;
72 clist *result; 78 clist *result;
73 clistcell *current; 79 clistcell *current;
74 mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; 80 mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate;
75 mailimap_fetch_type *fetchType; 81 mailimap_fetch_type *fetchType;
76 mailimap_set *set; 82 mailimap_set *set;
77 83
78 mb = mailbox.latin1(); 84 mb = mailbox.latin1();
79 login(); 85 login();
80 if (!m_imap) { 86 if (!m_imap) {
81 return; 87 return;
82 } 88 }
83 /* select mailbox READONLY for operations */ 89 /* select mailbox READONLY for operations */
84 err = mailimap_examine( m_imap, (char*)mb); 90 err = mailimap_examine( m_imap, (char*)mb);
85 if ( err != MAILIMAP_NO_ERROR ) { 91 if ( err != MAILIMAP_NO_ERROR ) {
@@ -90,30 +96,30 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
90 96
91 int last = m_imap->selection_info->exists; 97 int last = m_imap->selection_info->exists;
92 98
93 if (last == 0) { 99 if (last == 0) {
94 qDebug("mailbox has no mails"); 100 qDebug("mailbox has no mails");
95 logout(); 101 logout();
96 return; 102 return;
97 } 103 }
98 104
99 result = clist_new(); 105 result = clist_new();
100 /* the range has to start at 1!!! not with 0!!!! */ 106 /* the range has to start at 1!!! not with 0!!!! */
101 set = mailimap_set_new_interval( 1, last ); 107 set = mailimap_set_new_interval( 1, last );
102 fetchAtt = mailimap_fetch_att_new_envelope(); 108 fetchAtt = mailimap_fetch_att_new_envelope();
103 fetchAttFlags = mailimap_fetch_att_new_flags(); 109 fetchAttFlags = mailimap_fetch_att_new_flags();
104 fetchAttDate = mailimap_fetch_att_new_internaldate(); 110 fetchAttDate = mailimap_fetch_att_new_internaldate();
105 111
106 //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 112 //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
107 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 113 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
108 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); 114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt);
109 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); 115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags);
110 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate); 116 mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate);
111 117
112 err = mailimap_fetch( m_imap, set, fetchType, &result ); 118 err = mailimap_fetch( m_imap, set, fetchType, &result );
113 mailimap_set_free( set ); 119 mailimap_set_free( set );
114 /* cleans up the fetch_att's too! */ 120 /* cleans up the fetch_att's too! */
115 mailimap_fetch_type_free( fetchType ); 121 mailimap_fetch_type_free( fetchType );
116 122
117 QString date,subject,from; 123 QString date,subject,from;
118 124
119 if ( err == MAILIMAP_NO_ERROR ) { 125 if ( err == MAILIMAP_NO_ERROR ) {
@@ -139,24 +145,24 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
139} 145}
140 146
141QList<IMAPFolder>* IMAPwrapper::listFolders() 147QList<IMAPFolder>* IMAPwrapper::listFolders()
142{ 148{
143 const char *path, *mask; 149 const char *path, *mask;
144 int err = MAILIMAP_NO_ERROR; 150 int err = MAILIMAP_NO_ERROR;
145 clist *result; 151 clist *result;
146 clistcell *current; 152 clistcell *current;
147 153
148 QList<IMAPFolder> * folders = new QList<IMAPFolder>(); 154 QList<IMAPFolder> * folders = new QList<IMAPFolder>();
149 folders->setAutoDelete( true ); 155 folders->setAutoDelete( true );
150 login(); 156 login();
151 if (!m_imap) { 157 if (!m_imap) {
152 return folders; 158 return folders;
153 } 159 }
154 160
155/* 161/*
156 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 162 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
157 * We must not forget to filter them out in next loop! 163 * We must not forget to filter them out in next loop!
158 * it seems like ugly code. and yes - it is ugly code. but the best way. 164 * it seems like ugly code. and yes - it is ugly code. but the best way.
159 */ 165 */
160 QString temp; 166 QString temp;
161 mask = "INBOX" ; 167 mask = "INBOX" ;
162 result = clist_new(); 168 result = clist_new();
@@ -171,37 +177,37 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
171 temp = list->mb; 177 temp = list->mb;
172 folders->append( new IMAPFolder(temp)); 178 folders->append( new IMAPFolder(temp));
173 current = current->next; 179 current = current->next;
174 } 180 }
175 } else { 181 } else {
176 qDebug("error fetching folders: %s",m_imap->response); 182 qDebug("error fetching folders: %s",m_imap->response);
177 } 183 }
178 mailimap_list_result_free( result ); 184 mailimap_list_result_free( result );
179 185
180/* 186/*
181 * second stage - get the other then inbox folders 187 * second stage - get the other then inbox folders
182 */ 188 */
183 mask = "*" ; 189 mask = "*" ;
184 path = account->getPrefix().latin1(); 190 path = account->getPrefix().latin1();
185 result = clist_new(); 191 result = clist_new();
186 qDebug(path); 192 qDebug(path);
187 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
188 if ( err == MAILIMAP_NO_ERROR ) { 194 if ( err == MAILIMAP_NO_ERROR ) {
189 current = result->first; 195 current = result->first;
190 for ( int i = result->count; i > 0; i-- ) { 196 for ( int i = result->count; i > 0; i-- ) {
191 list = (mailimap_mailbox_list *) current->data; 197 list = (mailimap_mailbox_list *) current->data;
192 // it is better use the deep copy mechanism of qt itself 198 // it is better use the deep copy mechanism of qt itself
193 // instead of using strdup! 199 // instead of using strdup!
194 temp = list->mb; 200 temp = list->mb;
195 current = current->next; 201 current = current->next;
196 if (temp.lower()=="inbox") 202 if (temp.lower()=="inbox")
197 continue; 203 continue;
198 folders->append(new IMAPFolder(temp)); 204 folders->append(new IMAPFolder(temp));
199 205
200 } 206 }
201 } else { 207 } else {
202 qDebug("error fetching folders %s",m_imap->response); 208 qDebug("error fetching folders %s",m_imap->response);
203 } 209 }
204 mailimap_list_result_free( result ); 210 mailimap_list_result_free( result );
205 return folders; 211 return folders;
206} 212}
207 213
@@ -209,17 +215,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
209{ 215{
210 RecMail * m = 0; 216 RecMail * m = 0;
211 mailimap_msg_att_item *item=0; 217 mailimap_msg_att_item *item=0;
212 clistcell *current,*c,*cf; 218 clistcell *current,*c,*cf;
213 mailimap_msg_att_dynamic*flist; 219 mailimap_msg_att_dynamic*flist;
214 mailimap_flag_fetch*cflag; 220 mailimap_flag_fetch*cflag;
215 QBitArray mFlags(7); 221 QBitArray mFlags(7);
216 QStringList addresslist; 222 QStringList addresslist;
217 223
218 if (!m_att) { 224 if (!m_att) {
219 return m; 225 return m;
220 } 226 }
221 227
222 c = clist_begin(m_att->list); 228 c = clist_begin(m_att->list);
223 while ( c ) { 229 while ( c ) {
224 current = c; 230 current = c;
225 c = c->next; 231 c = c->next;
@@ -324,55 +330,55 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
324 const char *mb; 330 const char *mb;
325 int err = MAILIMAP_NO_ERROR; 331 int err = MAILIMAP_NO_ERROR;
326 clist *result; 332 clist *result;
327 clistcell *current; 333 clistcell *current;
328 mailimap_fetch_att *fetchAtt; 334 mailimap_fetch_att *fetchAtt;
329 mailimap_fetch_type *fetchType; 335 mailimap_fetch_type *fetchType;
330 mailimap_set *set; 336 mailimap_set *set;
331 mailimap_body*body_desc; 337 mailimap_body*body_desc;
332 338
333 mb = mail.getMbox().latin1(); 339 mb = mail.getMbox().latin1();
334 340
335 login(); 341 login();
336 if (!m_imap) { 342 if (!m_imap) {
337 return body; 343 return body;
338 } 344 }
339 /* select mailbox READONLY for operations */ 345 /* select mailbox READONLY for operations */
340 err = mailimap_examine( m_imap, (char*)mb); 346 err = mailimap_examine( m_imap, (char*)mb);
341 if ( err != MAILIMAP_NO_ERROR ) { 347 if ( err != MAILIMAP_NO_ERROR ) {
342 qDebug("error selecting mailbox: %s",m_imap->response); 348 qDebug("error selecting mailbox: %s",m_imap->response);
343 logout(); 349 logout();
344 return body; 350 return body;
345 } 351 }
346 result = clist_new(); 352 result = clist_new();
347 /* the range has to start at 1!!! not with 0!!!! */ 353 /* the range has to start at 1!!! not with 0!!!! */
348 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
349 fetchAtt = mailimap_fetch_att_new_body(); 355 fetchAtt = mailimap_fetch_att_new_body();
350 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
351 err = mailimap_fetch( m_imap, set, fetchType, &result ); 357 err = mailimap_fetch( m_imap, set, fetchType, &result );
352 mailimap_set_free( set ); 358 mailimap_set_free( set );
353 mailimap_fetch_type_free( fetchType ); 359 mailimap_fetch_type_free( fetchType );
354 360
355 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
356 mailimap_msg_att * msg_att; 362 mailimap_msg_att * msg_att;
357 msg_att = (mailimap_msg_att*)current->data; 363 msg_att = (mailimap_msg_att*)current->data;
358 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; 364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data;
359 body_desc = item->msg_att_static->body; 365 body_desc = item->msg_att_static->body;
360 if (body_desc->type==MAILIMAP_BODY_1PART) { 366 if (body_desc->type==MAILIMAP_BODY_1PART) {
361 searchBodyText(mail,body_desc->body_1part,body); 367 searchBodyText(mail,body_desc->body_1part,body);
362 } else { 368 } else {
363 } 369 }
364 370
365 } else { 371 } else {
366 qDebug("error fetching body: %s",m_imap->response); 372 qDebug("error fetching body: %s",m_imap->response);
367 } 373 }
368 374
369 clist_free(result); 375 clist_free(result);
370 logout(); 376 logout();
371 return body; 377 return body;
372} 378}
373 379
374void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) 380void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
375{ 381{
376 if (!mailDescription) { 382 if (!mailDescription) {
377 return; 383 return;
378 } 384 }
@@ -391,32 +397,32 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
391 const char *mb; 397 const char *mb;
392 QString body=""; 398 QString body="";
393 int err = MAILIMAP_NO_ERROR; 399 int err = MAILIMAP_NO_ERROR;
394 clist *result; 400 clist *result;
395 clistcell *current; 401 clistcell *current;
396 mailimap_fetch_att *fetchAtt; 402 mailimap_fetch_att *fetchAtt;
397 mailimap_fetch_type *fetchType; 403 mailimap_fetch_type *fetchType;
398 mailimap_set *set; 404 mailimap_set *set;
399 405
400 mb = mail.getMbox().latin1(); 406 mb = mail.getMbox().latin1();
401 407
402 if (!m_imap) { 408 if (!m_imap) {
403 return; 409 return;
404 } 410 }
405 411
406 result = clist_new(); 412 result = clist_new();
407 /* the range has to start at 1!!! not with 0!!!! */ 413 /* the range has to start at 1!!! not with 0!!!! */
408 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 414 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
409 fetchAtt = mailimap_fetch_att_new_rfc822_text(); 415 fetchAtt = mailimap_fetch_att_new_rfc822_text();
410 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 416 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
411 err = mailimap_fetch( m_imap, set, fetchType, &result ); 417 err = mailimap_fetch( m_imap, set, fetchType, &result );
412 mailimap_set_free( set ); 418 mailimap_set_free( set );
413 mailimap_fetch_type_free( fetchType ); 419 mailimap_fetch_type_free( fetchType );
414 420
415 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 421 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
416 mailimap_msg_att * msg_att; 422 mailimap_msg_att * msg_att;
417 msg_att = (mailimap_msg_att*)current->data; 423 msg_att = (mailimap_msg_att*)current->data;
418 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; 424 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data;
419 if (item->msg_att_static && item->msg_att_static->rfc822_text) { 425 if (item->msg_att_static && item->msg_att_static->rfc822_text) {
420 body = item->msg_att_static->rfc822_text; 426 body = item->msg_att_static->rfc822_text;
421 } 427 }
422 } else { 428 } else {
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 3edfff1..6d13a8b 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -10,17 +10,17 @@
10#include "mainwindow.h" 10#include "mainwindow.h"
11#include "viewmail.h" 11#include "viewmail.h"
12#include "mailtypes.h" 12#include "mailtypes.h"
13#include "mailistviewitem.h" 13#include "mailistviewitem.h"
14 14
15MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 15MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
16 : QMainWindow( parent, name, flags ) 16 : QMainWindow( parent, name, flags )
17{ 17{
18 setCaption( tr( "Opie-Mail" ) ); 18 setCaption( tr( "Mail" ) );
19 setToolBarsMovable( false ); 19 setToolBarsMovable( false );
20 20
21 toolBar = new QToolBar( this ); 21 toolBar = new QToolBar( this );
22 menuBar = new QMenuBar( toolBar ); 22 menuBar = new QMenuBar( toolBar );
23 mailMenu = new QPopupMenu( menuBar ); 23 mailMenu = new QPopupMenu( menuBar );
24 menuBar->insertItem( tr( "Mail" ), mailMenu ); 24 menuBar->insertItem( tr( "Mail" ), mailMenu );
25 settingsMenu = new QPopupMenu( menuBar ); 25 settingsMenu = new QPopupMenu( menuBar );
26 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 26 menuBar->insertItem( tr( "Settings" ), settingsMenu );