author | alwin <alwin> | 2004-10-24 00:55:14 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-24 00:55:14 (UTC) |
commit | 9755bc969d17fc683791abc5c6fbd50fa3112486 (patch) (unidiff) | |
tree | 0fdcf7b52b2f4627dd3efcd7330b116c4d9c4d98 /noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |
parent | 12eed25c7f18285f0e342d49fd3c41eb4b14e151 (diff) | |
download | opie-9755bc969d17fc683791abc5c6fbd50fa3112486.zip opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.gz opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.bz2 |
new options for pop3 accounts
KATE eated a lot of last spaces in files
some tryouts
Diffstat (limited to 'noncore/net/mail/libmailwrapper/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 3cfd1ee..2d66fc9 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -4,35 +4,38 @@ | |||
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qmessagebox.h> | ||
10 | 11 | ||
11 | /* we don't fetch messages larger than 5 MB */ | 12 | /* we don't fetch messages larger than 5 MB */ |
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 13 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 14 | ||
14 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
15 | POP3wrapper::POP3wrapper( POP3account *a ) | 16 | POP3wrapper::POP3wrapper( POP3account *a ) |
16 | : Genericwrapper() { | 17 | : Genericwrapper() { |
17 | account = a; | 18 | account = a; |
18 | m_pop3 = NULL; | 19 | m_pop3 = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 20 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 21 | last_msg_id = 0; |
22 | m_maxsize = account->getMaxSize(); | ||
23 | m_checksize = account->getCheckMaxSize(); | ||
21 | } | 24 | } |
22 | 25 | ||
23 | POP3wrapper::~POP3wrapper() { | 26 | POP3wrapper::~POP3wrapper() { |
24 | logout(); | 27 | logout(); |
25 | QFile msg_cache(msgTempName); | 28 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 29 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 30 | msg_cache.remove(); |
28 | } | 31 | } |
29 | } | 32 | } |
30 | 33 | ||
31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 34 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
32 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 35 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
33 | } | 36 | } |
34 | 37 | ||
35 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 38 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = MAILPOP3_NO_ERROR; | 39 | int err = MAILPOP3_NO_ERROR; |
37 | char *message = 0; | 40 | char *message = 0; |
38 | size_t length = 0; | 41 | size_t length = 0; |
@@ -42,15 +45,19 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | |||
42 | login(); | 45 | login(); |
43 | if ( !m_pop3 ) { | 46 | if ( !m_pop3 ) { |
44 | return body; | 47 | return body; |
45 | } | 48 | } |
46 | 49 | ||
47 | mailmessage * mailmsg; | 50 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 51 | if (mail->Msgsize()/1024>m_maxsize && m_checksize && mail->getNumber()!=last_msg_id) { |
49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 52 | QString quest = QString(tr("Download mail?\nIt is %1 kByte but your limit is %2 kByte")).arg(mail->Msgsize()/1024).arg(m_maxsize); |
50 | return body; | 53 | int yesno = QMessageBox::warning(0,tr("Download message"), |
54 | quest,tr("Yes"),tr("No"),QString::null,0,1); | ||
55 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | ||
56 | if (yesno==1) | ||
57 | return body; | ||
51 | } | 58 | } |
52 | 59 | ||
53 | QFile msg_cache(msgTempName); | 60 | QFile msg_cache(msgTempName); |
54 | 61 | ||
55 | cleanMimeCache(); | 62 | cleanMimeCache(); |
56 | 63 | ||
@@ -128,13 +135,13 @@ void POP3wrapper::login() | |||
128 | if ( QDialog::Accepted == login.exec() ) { | 135 | if ( QDialog::Accepted == login.exec() ) { |
129 | // ok | 136 | // ok |
130 | user = login.getUser().latin1(); | 137 | user = login.getUser().latin1(); |
131 | pass = login.getPassword().latin1(); | 138 | pass = login.getPassword().latin1(); |
132 | } else { | 139 | } else { |
133 | // cancel | 140 | // cancel |
134 | odebug << "POP3: Login canceled" << oendl; | 141 | odebug << "POP3: Login canceled" << oendl; |
135 | return; | 142 | return; |
136 | } | 143 | } |
137 | } else { | 144 | } else { |
138 | user = account->getUser().latin1(); | 145 | user = account->getUser().latin1(); |
139 | pass = account->getPassword().latin1(); | 146 | pass = account->getPassword().latin1(); |
140 | } | 147 | } |
@@ -160,13 +167,13 @@ void POP3wrapper::login() | |||
160 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 167 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
161 | (char*)user,(char*)pass,0,0,0); | 168 | (char*)user,(char*)pass,0,0,0); |
162 | 169 | ||
163 | 170 | ||
164 | err = mailstorage_connect(m_pop3); | 171 | err = mailstorage_connect(m_pop3); |
165 | if (err != MAIL_NO_ERROR) { | 172 | if (err != MAIL_NO_ERROR) { |
166 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 173 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
167 | Global::statusMessage(tr("Error initializing folder")); | 174 | Global::statusMessage(tr("Error initializing folder")); |
168 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
169 | m_pop3 = 0; | 176 | m_pop3 = 0; |
170 | } else { | 177 | } else { |
171 | mailsession * session = m_pop3->sto_session; | 178 | mailsession * session = m_pop3->sto_session; |
172 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 179 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
@@ -234,13 +241,13 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | |||
234 | target_stat.message_recent = 0; | 241 | target_stat.message_recent = 0; |
235 | if (!m_pop3) | 242 | if (!m_pop3) |
236 | return; | 243 | return; |
237 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 244 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
238 | &target_stat.message_recent,&target_stat.message_unseen); | 245 | &target_stat.message_recent,&target_stat.message_unseen); |
239 | if (r != MAIL_NO_ERROR) { | 246 | if (r != MAIL_NO_ERROR) { |
240 | odebug << "error getting folter status." << oendl; | 247 | odebug << "error getting folter status." << oendl; |
241 | } | 248 | } |
242 | } | 249 | } |
243 | 250 | ||
244 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 251 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
245 | char*target=0; | 252 | char*target=0; |
246 | size_t length=0; | 253 | size_t length=0; |