summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/settings.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/settings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp47
1 files changed, 37 insertions, 10 deletions
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
@@ -15,9 +15,8 @@
15#define POP3_SSL_PORT "995" 15#define POP3_SSL_PORT "995"
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{
23 updateAccounts(); 22 updateAccounts();
@@ -26,9 +25,9 @@ Settings::Settings()
26void Settings::checkDirectory() 25void Settings::checkDirectory()
27{ 26{
28 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 27 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
29 system( "mkdir -p $HOME/Applications/opiemail" ); 28 system( "mkdir -p $HOME/Applications/opiemail" );
30 odebug << "$HOME/Applications/opiemail created" << oendl; 29 odebug << "$HOME/Applications/opiemail created" << oendl;
31 } 30 }
32} 31}
33 32
34QList<Account> Settings::getAccounts() 33QList<Account> Settings::getAccounts()
@@ -54,30 +53,30 @@ void Settings::updateAccounts()
54 QStringList::Iterator it; 53 QStringList::Iterator it;
55 54
56 QStringList imap = dir.entryList( "imap-*" ); 55 QStringList imap = dir.entryList( "imap-*" );
57 for ( it = imap.begin(); it != imap.end(); it++ ) { 56 for ( it = imap.begin(); it != imap.end(); it++ ) {
58 odebug << "Added IMAP account" << oendl; 57 odebug << "Added IMAP account" << oendl;
59 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 58 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
60 accounts.append( account ); 59 accounts.append( account );
61 } 60 }
62 61
63 QStringList pop3 = dir.entryList( "pop3-*" ); 62 QStringList pop3 = dir.entryList( "pop3-*" );
64 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 63 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
65 odebug << "Added POP account" << oendl; 64 odebug << "Added POP account" << oendl;
66 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 65 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
67 accounts.append( account ); 66 accounts.append( account );
68 } 67 }
69 68
70 QStringList smtp = dir.entryList( "smtp-*" ); 69 QStringList smtp = dir.entryList( "smtp-*" );
71 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 70 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
72 odebug << "Added SMTP account" << oendl; 71 odebug << "Added SMTP account" << oendl;
73 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 72 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
74 accounts.append( account ); 73 accounts.append( account );
75 } 74 }
76 75
77 QStringList nntp = dir.entryList( "nntp-*" ); 76 QStringList nntp = dir.entryList( "nntp-*" );
78 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 77 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
79 odebug << "Added NNTP account" << oendl; 78 odebug << "Added NNTP account" << oendl;
80 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 79 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
81 accounts.append( account ); 80 accounts.append( account );
82 } 81 }
83 82
@@ -179,9 +178,9 @@ void IMAPaccount::read()
179} 178}
180 179
181void IMAPaccount::save() 180void IMAPaccount::save()
182{ 181{
183 odebug << "saving " + getFileName() << oendl; 182 odebug << "saving " + getFileName() << oendl;
184 Settings::checkDirectory(); 183 Settings::checkDirectory();
185 184
186 Config *conf = new Config( getFileName(), Config::File ); 185 Config *conf = new Config( getFileName(), Config::File );
187 conf->setGroup( "IMAP Account" ); 186 conf->setGroup( "IMAP Account" );
@@ -212,8 +211,10 @@ POP3account::POP3account()
212 ssl = false; 211 ssl = false;
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 )
219 : Account() 220 : Account()
@@ -223,8 +224,10 @@ POP3account::POP3account( QString filename )
223 ssl = false; 224 ssl = false;
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()
230{ 233{
@@ -252,14 +255,16 @@ void POP3account::read()
252 connectionType = conf->readNumEntry( "ConnectionType" ); 255 connectionType = conf->readNumEntry( "ConnectionType" );
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
259void POP3account::save() 264void POP3account::save()
260{ 265{
261 odebug << "saving " + getFileName() << oendl; 266 odebug << "saving " + getFileName() << oendl;
262 Settings::checkDirectory(); 267 Settings::checkDirectory();
263 268
264 Config *conf = new Config( getFileName(), Config::File ); 269 Config *conf = new Config( getFileName(), Config::File );
265 conf->setGroup( "POP3 Account" ); 270 conf->setGroup( "POP3 Account" );
@@ -270,8 +275,10 @@ void POP3account::save()
270 conf->writeEntry( "ConnectionType", connectionType ); 275 conf->writeEntry( "ConnectionType", connectionType );
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}
277 284
@@ -280,8 +287,28 @@ QString POP3account::getFileName()
280{ 287{
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{
287 file = SMTPaccount::getUniqueFileName(); 314 file = SMTPaccount::getUniqueFileName();
@@ -339,9 +366,9 @@ void SMTPaccount::read()
339} 366}
340 367
341void SMTPaccount::save() 368void SMTPaccount::save()
342{ 369{
343 odebug << "saving " + getFileName() << oendl; 370 odebug << "saving " + getFileName() << oendl;
344 Settings::checkDirectory(); 371 Settings::checkDirectory();
345 372
346 Config *conf = new Config( getFileName(), Config::File ); 373 Config *conf = new Config( getFileName(), Config::File );
347 conf->setGroup( "SMTP Account" ); 374 conf->setGroup( "SMTP Account" );
@@ -416,9 +443,9 @@ void NNTPaccount::read()
416} 443}
417 444
418void NNTPaccount::save() 445void NNTPaccount::save()
419{ 446{
420 odebug << "saving " + getFileName() << oendl; 447 odebug << "saving " + getFileName() << oendl;
421 Settings::checkDirectory(); 448 Settings::checkDirectory();
422 449
423 Config *conf = new Config( getFileName(), Config::File ); 450 Config *conf = new Config( getFileName(), Config::File );
424 conf->setGroup( "NNTP Account" ); 451 conf->setGroup( "NNTP Account" );