summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp20
-rw-r--r--noncore/net/mail/pop3wrapper.cpp20
4 files changed, 70 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 838300a..cce3d34 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -1,21 +1,22 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "imapwrapper.h" 4#include "imapwrapper.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include "logindialog.h"
6#include <libetpan/mailimap.h> 7#include <libetpan/mailimap.h>
7 8
8IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 9IMAPwrapper::IMAPwrapper( IMAPaccount *a )
9 : AbstractMail() 10 : AbstractMail()
10{ 11{
11 account = a; 12 account = a;
12 m_imap = 0; 13 m_imap = 0;
13} 14}
14 15
15IMAPwrapper::~IMAPwrapper() 16IMAPwrapper::~IMAPwrapper()
16{ 17{
17 logout(); 18 logout();
18} 19}
19 20
20void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 21void IMAPwrapper::imap_progress( size_t current, size_t maximum )
21{ 22{
@@ -23,34 +24,48 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
23} 24}
24 25
25void IMAPwrapper::login() 26void IMAPwrapper::login()
26{ 27{
27 const char *server, *user, *pass; 28 const char *server, *user, *pass;
28 uint16_t port; 29 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 30 int err = MAILIMAP_NO_ERROR;
30 31
31 /* we are connected this moment */ 32 /* we are connected this moment */
32 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 33 /* TODO: setup a timer holding the line or if connection closed - delete the value */
33 if (m_imap) { 34 if (m_imap) {
34 mailstream_flush(m_imap->imap_stream); 35 mailstream_flush(m_imap->imap_stream);
35 return; 36 return;
36 } 37 }
37 server = account->getServer().latin1(); 38 server = account->getServer().latin1();
38 port = account->getPort().toUInt(); 39 port = account->getPort().toUInt();
39 user = account->getUser().latin1(); 40 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
40 pass = account->getPassword().latin1(); 41 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
42 login.show();
43 if ( QDialog::Accepted == login.exec() ) {
44 // ok
45 user = strdup( login.getUser().latin1() );
46 pass = strdup( login.getPassword().latin1() );
47 } else {
48 // cancel
49 qDebug( "IMAP: Login canceled" );
50 return;
51 }
52 } else {
53 user = account->getUser().latin1();
54 pass = account->getPassword().latin1();
55 }
41 56
42 m_imap = mailimap_new( 20, &imap_progress ); 57 m_imap = mailimap_new( 20, &imap_progress );
43 /* connect */ 58 /* connect */
44 if (account->getSSL()) { 59 if (account->getSSL()) {
45 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 60 err = mailimap_ssl_connect( m_imap, (char*)server, port );
46 } else { 61 } else {
47 err = mailimap_socket_connect( m_imap, (char*)server, port ); 62 err = mailimap_socket_connect( m_imap, (char*)server, port );
48 } 63 }
49 64
50 if ( err != MAILIMAP_NO_ERROR && 65 if ( err != MAILIMAP_NO_ERROR &&
51 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 66 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 67 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
53 qDebug("error connecting server: %s",m_imap->imap_response); 68 qDebug("error connecting server: %s",m_imap->imap_response);
54 mailimap_free( m_imap ); 69 mailimap_free( m_imap );
55 m_imap = 0; 70 m_imap = 0;
56 return; 71 return;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 838300a..cce3d34 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,21 +1,22 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "imapwrapper.h" 4#include "imapwrapper.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include "logindialog.h"
6#include <libetpan/mailimap.h> 7#include <libetpan/mailimap.h>
7 8
8IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 9IMAPwrapper::IMAPwrapper( IMAPaccount *a )
9 : AbstractMail() 10 : AbstractMail()
10{ 11{
11 account = a; 12 account = a;
12 m_imap = 0; 13 m_imap = 0;
13} 14}
14 15
15IMAPwrapper::~IMAPwrapper() 16IMAPwrapper::~IMAPwrapper()
16{ 17{
17 logout(); 18 logout();
18} 19}
19 20
20void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 21void IMAPwrapper::imap_progress( size_t current, size_t maximum )
21{ 22{
@@ -23,34 +24,48 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
23} 24}
24 25
25void IMAPwrapper::login() 26void IMAPwrapper::login()
26{ 27{
27 const char *server, *user, *pass; 28 const char *server, *user, *pass;
28 uint16_t port; 29 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 30 int err = MAILIMAP_NO_ERROR;
30 31
31 /* we are connected this moment */ 32 /* we are connected this moment */
32 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 33 /* TODO: setup a timer holding the line or if connection closed - delete the value */
33 if (m_imap) { 34 if (m_imap) {
34 mailstream_flush(m_imap->imap_stream); 35 mailstream_flush(m_imap->imap_stream);
35 return; 36 return;
36 } 37 }
37 server = account->getServer().latin1(); 38 server = account->getServer().latin1();
38 port = account->getPort().toUInt(); 39 port = account->getPort().toUInt();
39 user = account->getUser().latin1(); 40 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
40 pass = account->getPassword().latin1(); 41 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
42 login.show();
43 if ( QDialog::Accepted == login.exec() ) {
44 // ok
45 user = strdup( login.getUser().latin1() );
46 pass = strdup( login.getPassword().latin1() );
47 } else {
48 // cancel
49 qDebug( "IMAP: Login canceled" );
50 return;
51 }
52 } else {
53 user = account->getUser().latin1();
54 pass = account->getPassword().latin1();
55 }
41 56
42 m_imap = mailimap_new( 20, &imap_progress ); 57 m_imap = mailimap_new( 20, &imap_progress );
43 /* connect */ 58 /* connect */
44 if (account->getSSL()) { 59 if (account->getSSL()) {
45 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 60 err = mailimap_ssl_connect( m_imap, (char*)server, port );
46 } else { 61 } else {
47 err = mailimap_socket_connect( m_imap, (char*)server, port ); 62 err = mailimap_socket_connect( m_imap, (char*)server, port );
48 } 63 }
49 64
50 if ( err != MAILIMAP_NO_ERROR && 65 if ( err != MAILIMAP_NO_ERROR &&
51 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 66 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 67 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
53 qDebug("error connecting server: %s",m_imap->imap_response); 68 qDebug("error connecting server: %s",m_imap->imap_response);
54 mailimap_free( m_imap ); 69 mailimap_free( m_imap );
55 m_imap = 0; 70 m_imap = 0;
56 return; 71 return;
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 22a4c70..b0b985c 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,19 +1,20 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "logindialog.h"
4#include <libetpan/mailpop3.h> 5#include <libetpan/mailpop3.h>
5#include <libetpan/mailmime.h> 6#include <libetpan/mailmime.h>
6#include <libetpan/data_message_driver.h> 7#include <libetpan/data_message_driver.h>
7#include <qfile.h> 8#include <qfile.h>
8 9
9/* we don't fetch messages larger than 5 MB */ 10/* we don't fetch messages larger than 5 MB */
10#define HARD_MSG_SIZE_LIMIT 5242880 11#define HARD_MSG_SIZE_LIMIT 5242880
11 12
12POP3wrapper::POP3wrapper( POP3account *a ) 13POP3wrapper::POP3wrapper( POP3account *a )
13{ 14{
14 account = a; 15 account = a;
15 m_pop3 = NULL; 16 m_pop3 = NULL;
16 msgTempName = a->getFileName()+"_msg_cache"; 17 msgTempName = a->getFileName()+"_msg_cache";
17 last_msg_id = 0; 18 last_msg_id = 0;
18} 19}
19 20
@@ -344,34 +345,49 @@ QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
344 } 345 }
345 346
346 return result; 347 return result;
347} 348}
348 349
349void POP3wrapper::login() 350void POP3wrapper::login()
350{ 351{
351 /* we'll hold the line */ 352 /* we'll hold the line */
352 if ( m_pop3 != NULL ) return; 353 if ( m_pop3 != NULL ) return;
353 354
354 const char *server, *user, *pass; 355 const char *server, *user, *pass;
355 uint16_t port; 356 uint16_t port;
356 int err = MAILPOP3_NO_ERROR; 357 int err = MAILPOP3_NO_ERROR;
357 358
358 server = account->getServer().latin1(); 359 server = account->getServer().latin1();
359 port = account->getPort().toUInt(); 360 port = account->getPort().toUInt();
360 user = account->getUser().latin1(); 361
361 pass = account->getPassword().latin1(); 362 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
363 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
364 login.show();
365 if ( QDialog::Accepted == login.exec() ) {
366 // ok
367 user = strdup( login.getUser().latin1() );
368 pass = strdup( login.getPassword().latin1() );
369 } else {
370 // cancel
371 qDebug( "POP3: Login canceled" );
372 return;
373 }
374 } else {
375 user = account->getUser().latin1();
376 pass = account->getPassword().latin1();
377 }
362 378
363 m_pop3 = mailpop3_new( 200, &pop3_progress ); 379 m_pop3 = mailpop3_new( 200, &pop3_progress );
364 380
365 // connect 381 // connect
366 if (account->getSSL()) { 382 if (account->getSSL()) {
367 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 383 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
368 } else { 384 } else {
369 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 385 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
370 } 386 }
371 387
372 if ( err != MAILPOP3_NO_ERROR ) { 388 if ( err != MAILPOP3_NO_ERROR ) {
373 qDebug( "pop3: error connecting to %s\n reason: %s", server, 389 qDebug( "pop3: error connecting to %s\n reason: %s", server,
374 m_pop3->pop3_response ); 390 m_pop3->pop3_response );
375 mailpop3_free( m_pop3 ); 391 mailpop3_free( m_pop3 );
376 m_pop3 = NULL; 392 m_pop3 = NULL;
377 return; 393 return;
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 22a4c70..b0b985c 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,19 +1,20 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "logindialog.h"
4#include <libetpan/mailpop3.h> 5#include <libetpan/mailpop3.h>
5#include <libetpan/mailmime.h> 6#include <libetpan/mailmime.h>
6#include <libetpan/data_message_driver.h> 7#include <libetpan/data_message_driver.h>
7#include <qfile.h> 8#include <qfile.h>
8 9
9/* we don't fetch messages larger than 5 MB */ 10/* we don't fetch messages larger than 5 MB */
10#define HARD_MSG_SIZE_LIMIT 5242880 11#define HARD_MSG_SIZE_LIMIT 5242880
11 12
12POP3wrapper::POP3wrapper( POP3account *a ) 13POP3wrapper::POP3wrapper( POP3account *a )
13{ 14{
14 account = a; 15 account = a;
15 m_pop3 = NULL; 16 m_pop3 = NULL;
16 msgTempName = a->getFileName()+"_msg_cache"; 17 msgTempName = a->getFileName()+"_msg_cache";
17 last_msg_id = 0; 18 last_msg_id = 0;
18} 19}
19 20
@@ -344,34 +345,49 @@ QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
344 } 345 }
345 346
346 return result; 347 return result;
347} 348}
348 349
349void POP3wrapper::login() 350void POP3wrapper::login()
350{ 351{
351 /* we'll hold the line */ 352 /* we'll hold the line */
352 if ( m_pop3 != NULL ) return; 353 if ( m_pop3 != NULL ) return;
353 354
354 const char *server, *user, *pass; 355 const char *server, *user, *pass;
355 uint16_t port; 356 uint16_t port;
356 int err = MAILPOP3_NO_ERROR; 357 int err = MAILPOP3_NO_ERROR;
357 358
358 server = account->getServer().latin1(); 359 server = account->getServer().latin1();
359 port = account->getPort().toUInt(); 360 port = account->getPort().toUInt();
360 user = account->getUser().latin1(); 361
361 pass = account->getPassword().latin1(); 362 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
363 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
364 login.show();
365 if ( QDialog::Accepted == login.exec() ) {
366 // ok
367 user = strdup( login.getUser().latin1() );
368 pass = strdup( login.getPassword().latin1() );
369 } else {
370 // cancel
371 qDebug( "POP3: Login canceled" );
372 return;
373 }
374 } else {
375 user = account->getUser().latin1();
376 pass = account->getPassword().latin1();
377 }
362 378
363 m_pop3 = mailpop3_new( 200, &pop3_progress ); 379 m_pop3 = mailpop3_new( 200, &pop3_progress );
364 380
365 // connect 381 // connect
366 if (account->getSSL()) { 382 if (account->getSSL()) {
367 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 383 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
368 } else { 384 } else {
369 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 385 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
370 } 386 }
371 387
372 if ( err != MAILPOP3_NO_ERROR ) { 388 if ( err != MAILPOP3_NO_ERROR ) {
373 qDebug( "pop3: error connecting to %s\n reason: %s", server, 389 qDebug( "pop3: error connecting to %s\n reason: %s", server,
374 m_pop3->pop3_response ); 390 m_pop3->pop3_response );
375 mailpop3_free( m_pop3 ); 391 mailpop3_free( m_pop3 );
376 m_pop3 = NULL; 392 m_pop3 = NULL;
377 return; 393 return;