Diffstat (limited to 'noncore/net/mail/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 60 |
1 files changed, 33 insertions, 27 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 | |||
@@ -28,14 +28,20 @@ void IMAPwrapper::login() | |||
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 ) { |
@@ -45,5 +51,5 @@ void IMAPwrapper::login() | |||
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 ); |
@@ -75,5 +81,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
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(); |
@@ -96,6 +102,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
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 ); |
@@ -103,5 +109,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
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(); |
@@ -109,5 +115,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
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 ); |
@@ -145,5 +151,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
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 ); |
@@ -152,5 +158,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
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. |
@@ -177,9 +183,9 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
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(); |
@@ -197,5 +203,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
197 | continue; | 203 | continue; |
198 | folders->append(new IMAPFolder(temp)); | 204 | folders->append(new IMAPFolder(temp)); |
199 | 205 | ||
200 | } | 206 | } |
201 | } else { | 207 | } else { |
@@ -215,5 +221,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
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; |
@@ -330,7 +336,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
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) { |
@@ -344,8 +350,8 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
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 ); |
@@ -362,5 +368,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
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); |
@@ -368,5 +374,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
368 | 374 | ||
369 | clist_free(result); | 375 | clist_free(result); |
370 | logout(); | 376 | logout(); |
371 | return body; | 377 | return body; |
372 | } | 378 | } |
@@ -397,12 +403,12 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
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() ); |
@@ -412,5 +418,5 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
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; |