summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper
authoralwin <alwin>2004-10-24 00:55:14 (UTC)
committer alwin <alwin>2004-10-24 00:55:14 (UTC)
commit9755bc969d17fc683791abc5c6fbd50fa3112486 (patch) (unidiff)
tree0fdcf7b52b2f4627dd3efcd7330b116c4d9c4d98 /noncore/net/mail/libmailwrapper
parent12eed25c7f18285f0e342d49fd3c41eb4b14e151 (diff)
downloadopie-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') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp20
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp0
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp29
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h7
7 files changed, 66 insertions, 14 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 1caa375..5ec9415 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -3,6 +3,8 @@
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5#include <opie2/odebug.h> 5#include <opie2/odebug.h>
6#include <qpe/timestring.h>
7#include <qdatetime.h>
6 8
7using namespace Opie::Core; 9using namespace Opie::Core;
8Genericwrapper::Genericwrapper() 10Genericwrapper::Genericwrapper()
@@ -243,12 +245,11 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg )
243 245
244QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 246QString Genericwrapper::parseDateTime( mailimf_date_time *date )
245{ 247{
246 char tmp[23]; 248 QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
247 249 QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
248 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 250 timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
249 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 251 timestring.sprintf(timestring+" %+05i",date->dt_zone);
250 252 return timestring;
251 return QString( tmp );
252} 253}
253 254
254QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 255QString Genericwrapper::parseAddressList( mailimf_address_list *list )
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 9b7c0e0..fe75a15 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -237,12 +237,16 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
237 237
238 /* the range has to start at 1!!! not with 0!!!! */ 238 /* the range has to start at 1!!! not with 0!!!! */
239 set = mailimap_set_new_interval( 1, last ); 239 set = mailimap_set_new_interval( 1, last );
240
241
242 fetchType = mailimap_fetch_type_new_all();
243/*
240 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 244 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
241 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 245 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
242 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 246 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
243 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 247 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
244 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 248 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
245 249*/
246 err = mailimap_fetch( m_imap, set, fetchType, &result ); 250 err = mailimap_fetch( m_imap, set, fetchType, &result );
247 mailimap_set_free( set ); 251 mailimap_set_free( set );
248 mailimap_fetch_type_free( fetchType ); 252 mailimap_fetch_type_free( fetchType );
@@ -375,10 +379,10 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
375 if (!m_att) { 379 if (!m_att) {
376 return m; 380 return m;
377 } 381 }
382 size = 0;
378 m = new RecMail(); 383 m = new RecMail();
379 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 384 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
380 current = c; 385 current = c;
381 size = 0;
382 item = (mailimap_msg_att_item*)current->data; 386 item = (mailimap_msg_att_item*)current->data;
383 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 387 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
384 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 388 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
@@ -465,13 +469,20 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
465 } 469 }
466 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 470 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
467#if 0 471#if 0
468 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 472 mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date;
473 if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0;
474 //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
475 QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
476 timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
477 timestring.sprintf(timestring+" %+05i",date->dt_zone);
478 m->setDate(timestring);
469 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 479 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
470 odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; 480 odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
471 odebug << da.toString() << oendl; 481 odebug << da.toString() << oendl;
472#endif 482#endif
473 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 483 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
474 size = item->att_data.att_static->att_data.att_rfc822_size; 484 //size = item->att_data.att_static->att_data.att_rfc822_size;
485 m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size);
475 } 486 }
476 } 487 }
477 /* msg is already deleted */ 488 /* msg is already deleted */
@@ -481,7 +492,6 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
481 } 492 }
482 if (m) { 493 if (m) {
483 m->setFlags(mFlags); 494 m->setFlags(mFlags);
484 m->setMsgsize(size);
485 } 495 }
486 return m; 496 return m;
487} 497}
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 403afcf..765a21c 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
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
@@ -7,6 +7,7 @@
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
@@ -18,6 +19,8 @@ POP3wrapper::POP3wrapper( POP3account *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
23POP3wrapper::~POP3wrapper() { 26POP3wrapper::~POP3wrapper() {
@@ -45,8 +48,12 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
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) {
52 QString quest = QString(tr("Download mail?\nIt is %1 kByte but your limit is %2 kByte")).arg(mail->Msgsize()/1024).arg(m_maxsize);
53 int yesno = QMessageBox::warning(0,tr("Download message"),
54 quest,tr("Yes"),tr("No"),QString::null,0,1);
49 odebug << "Message to large: " << mail->Msgsize() << "" << oendl; 55 odebug << "Message to large: " << mail->Msgsize() << "" << oendl;
56 if (yesno==1)
50 return body; 57 return body;
51 } 58 }
52 59
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 5101fa5..8c36cf9 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -37,6 +37,8 @@ protected:
37 void login(); 37 void login();
38 POP3account *account; 38 POP3account *account;
39 mailstorage*m_pop3; 39 mailstorage*m_pop3;
40 int m_maxsize;
41 bool m_checksize;
40}; 42};
41 43
42#endif 44#endif
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 3c9b25c..09be91b 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -16,7 +16,6 @@
16#define NNTP_PORT "119" 16#define NNTP_PORT "119"
17#define NNTP_SSL_PORT "563" 17#define NNTP_SSL_PORT "563"
18 18
19
20Settings::Settings() 19Settings::Settings()
21 : QObject() 20 : QObject()
22{ 21{
@@ -213,6 +212,8 @@ POP3account::POP3account()
213 connectionType = 1; 212 connectionType = 1;
214 type = MAILLIB::A_POP3; 213 type = MAILLIB::A_POP3;
215 port = POP3_PORT; 214 port = POP3_PORT;
215 m_CheckSize = true;
216 m_MaxSize = 1024;
216} 217}
217 218
218POP3account::POP3account( QString filename ) 219POP3account::POP3account( QString filename )
@@ -224,6 +225,8 @@ POP3account::POP3account( QString filename )
224 connectionType = 1; 225 connectionType = 1;
225 type = MAILLIB::A_POP3; 226 type = MAILLIB::A_POP3;
226 port = POP3_PORT; 227 port = POP3_PORT;
228 m_CheckSize = true;
229 m_MaxSize = 1024;
227} 230}
228 231
229QString POP3account::getUniqueFileName() 232QString POP3account::getUniqueFileName()
@@ -253,6 +256,8 @@ void POP3account::read()
253 user = conf->readEntry( "User" ); 256 user = conf->readEntry( "User" );
254 password = conf->readEntryCrypt( "Password" ); 257 password = conf->readEntryCrypt( "Password" );
255 offline = conf->readBoolEntry("Offline",false); 258 offline = conf->readBoolEntry("Offline",false);
259 m_CheckSize = conf->readBoolEntry("Checkmaxsize",true);
260 m_MaxSize = conf->readNumEntry("Maxsize",1024);
256 delete conf; 261 delete conf;
257} 262}
258 263
@@ -271,6 +276,8 @@ void POP3account::save()
271 conf->writeEntry( "User", user ); 276 conf->writeEntry( "User", user );
272 conf->writeEntryCrypt( "Password", password ); 277 conf->writeEntryCrypt( "Password", password );
273 conf->writeEntry( "Offline",offline); 278 conf->writeEntry( "Offline",offline);
279 conf->writeEntry("Checkmaxsize",m_CheckSize);
280 conf->writeEntry("Maxsize",m_MaxSize);
274 conf->write(); 281 conf->write();
275 delete conf; 282 delete conf;
276} 283}
@@ -281,6 +288,26 @@ QString POP3account::getFileName()
281 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 288 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
282} 289}
283 290
291bool POP3account::getCheckMaxSize()const
292{
293 return m_CheckSize;
294}
295
296void POP3account::setCheckMaxSize(bool aValue)
297{
298 m_CheckSize = aValue;
299}
300
301int POP3account::getMaxSize()const
302{
303 return m_MaxSize;
304}
305
306void POP3account::setMaxSize(int aValue)
307{
308 m_MaxSize = aValue;
309}
310
284SMTPaccount::SMTPaccount() 311SMTPaccount::SMTPaccount()
285 : Account() 312 : Account()
286{ 313{
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h
index bf27b97..8683a05 100644
--- a/noncore/net/mail/libmailwrapper/settings.h
+++ b/noncore/net/mail/libmailwrapper/settings.h
@@ -89,10 +89,15 @@ public:
89 virtual void read(); 89 virtual void read();
90 virtual void save(); 90 virtual void save();
91 virtual QString getFileName(); 91 virtual QString getFileName();
92 virtual bool getCheckMaxSize()const;
93 virtual void setCheckMaxSize(bool);
94 virtual int getMaxSize()const;
95 virtual void setMaxSize(int);
92 96
93private: 97private:
94 QString file; 98 QString file;
95 99 bool m_CheckSize;
100 int m_MaxSize;
96}; 101};
97 102
98class SMTPaccount : public Account 103class SMTPaccount : public Account