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/settings.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/settings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 47 |
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 | |||
@@ -7,36 +7,35 @@ | |||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | //#include "defines.h" | 8 | //#include "defines.h" |
9 | 9 | ||
10 | #define IMAP_PORT "143" | 10 | #define IMAP_PORT "143" |
11 | #define IMAP_SSL_PORT "993" | 11 | #define IMAP_SSL_PORT "993" |
12 | #define SMTP_PORT "25" | 12 | #define SMTP_PORT "25" |
13 | #define SMTP_SSL_PORT "465" | 13 | #define SMTP_SSL_PORT "465" |
14 | #define POP3_PORT "110" | 14 | #define POP3_PORT "110" |
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 | |||
20 | Settings::Settings() | 19 | Settings::Settings() |
21 | : QObject() | 20 | : QObject() |
22 | { | 21 | { |
23 | updateAccounts(); | 22 | updateAccounts(); |
24 | } | 23 | } |
25 | 24 | ||
26 | void Settings::checkDirectory() | 25 | void 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 | ||
34 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
35 | { | 34 | { |
36 | return accounts; | 35 | return accounts; |
37 | } | 36 | } |
38 | 37 | ||
39 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
40 | { | 39 | { |
41 | accounts.append( account ); | 40 | accounts.append( account ); |
42 | } | 41 | } |
@@ -46,46 +45,46 @@ void Settings::delAccount( Account *account ) | |||
46 | accounts.remove( account ); | 45 | accounts.remove( account ); |
47 | account->remove(); | 46 | account->remove(); |
48 | } | 47 | } |
49 | 48 | ||
50 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
51 | { | 50 | { |
52 | accounts.clear(); | 51 | accounts.clear(); |
53 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
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 | ||
84 | readAccounts(); | 83 | readAccounts(); |
85 | } | 84 | } |
86 | 85 | ||
87 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
88 | { | 87 | { |
89 | checkDirectory(); | 88 | checkDirectory(); |
90 | Account *it; | 89 | Account *it; |
91 | 90 | ||
@@ -171,25 +170,25 @@ void IMAPaccount::read() | |||
171 | user = conf->readEntry( "User","" ); | 170 | user = conf->readEntry( "User","" ); |
172 | if (user.isNull()) user = ""; | 171 | if (user.isNull()) user = ""; |
173 | password = conf->readEntryCrypt( "Password","" ); | 172 | password = conf->readEntryCrypt( "Password","" ); |
174 | if (password.isNull()) password = ""; | 173 | if (password.isNull()) password = ""; |
175 | prefix = conf->readEntry("MailPrefix",""); | 174 | prefix = conf->readEntry("MailPrefix",""); |
176 | if (prefix.isNull()) prefix = ""; | 175 | if (prefix.isNull()) prefix = ""; |
177 | offline = conf->readBoolEntry("Offline",false); | 176 | offline = conf->readBoolEntry("Offline",false); |
178 | delete conf; | 177 | delete conf; |
179 | } | 178 | } |
180 | 179 | ||
181 | void IMAPaccount::save() | 180 | void 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" ); |
188 | conf->writeEntry( "Account", accountName ); | 187 | conf->writeEntry( "Account", accountName ); |
189 | conf->writeEntry( "Server", server ); | 188 | conf->writeEntry( "Server", server ); |
190 | conf->writeEntry( "Port", port ); | 189 | conf->writeEntry( "Port", port ); |
191 | conf->writeEntry( "SSL", ssl ); | 190 | conf->writeEntry( "SSL", ssl ); |
192 | conf->writeEntry( "ConnectionType", connectionType ); | 191 | conf->writeEntry( "ConnectionType", connectionType ); |
193 | conf->writeEntry( "User", user ); | 192 | conf->writeEntry( "User", user ); |
194 | conf->writeEntryCrypt( "Password", password ); | 193 | conf->writeEntryCrypt( "Password", password ); |
195 | conf->writeEntry( "MailPrefix",prefix); | 194 | conf->writeEntry( "MailPrefix",prefix); |
@@ -204,35 +203,39 @@ QString IMAPaccount::getFileName() | |||
204 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
205 | } | 204 | } |
206 | 205 | ||
207 | POP3account::POP3account() | 206 | POP3account::POP3account() |
208 | : Account() | 207 | : Account() |
209 | { | 208 | { |
210 | file = POP3account::getUniqueFileName(); | 209 | file = POP3account::getUniqueFileName(); |
211 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
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 | ||
218 | POP3account::POP3account( QString filename ) | 219 | POP3account::POP3account( QString filename ) |
219 | : Account() | 220 | : Account() |
220 | { | 221 | { |
221 | file = filename; | 222 | file = filename; |
222 | accountName = "New POP3 Account"; | 223 | accountName = "New POP3 Account"; |
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 | ||
229 | QString POP3account::getUniqueFileName() | 232 | QString POP3account::getUniqueFileName() |
230 | { | 233 | { |
231 | int num = 0; | 234 | int num = 0; |
232 | QString unique; | 235 | QString unique; |
233 | 236 | ||
234 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 237 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
235 | 238 | ||
236 | QStringList imap = dir.entryList( "pop3-*" ); | 239 | QStringList imap = dir.entryList( "pop3-*" ); |
237 | do { | 240 | do { |
238 | unique.setNum( num++ ); | 241 | unique.setNum( num++ ); |
@@ -244,52 +247,76 @@ QString POP3account::getUniqueFileName() | |||
244 | void POP3account::read() | 247 | void POP3account::read() |
245 | { | 248 | { |
246 | Config *conf = new Config( getFileName(), Config::File ); | 249 | Config *conf = new Config( getFileName(), Config::File ); |
247 | conf->setGroup( "POP3 Account" ); | 250 | conf->setGroup( "POP3 Account" ); |
248 | accountName = conf->readEntry( "Account" ); | 251 | accountName = conf->readEntry( "Account" ); |
249 | server = conf->readEntry( "Server" ); | 252 | server = conf->readEntry( "Server" ); |
250 | port = conf->readEntry( "Port" ); | 253 | port = conf->readEntry( "Port" ); |
251 | ssl = conf->readBoolEntry( "SSL" ); | 254 | ssl = conf->readBoolEntry( "SSL" ); |
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 | ||
259 | void POP3account::save() | 264 | void 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" ); |
266 | conf->writeEntry( "Account", accountName ); | 271 | conf->writeEntry( "Account", accountName ); |
267 | conf->writeEntry( "Server", server ); | 272 | conf->writeEntry( "Server", server ); |
268 | conf->writeEntry( "Port", port ); | 273 | conf->writeEntry( "Port", port ); |
269 | conf->writeEntry( "SSL", ssl ); | 274 | conf->writeEntry( "SSL", ssl ); |
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 | ||
278 | 285 | ||
279 | QString POP3account::getFileName() | 286 | 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 | ||
291 | bool POP3account::getCheckMaxSize()const | ||
292 | { | ||
293 | return m_CheckSize; | ||
294 | } | ||
295 | |||
296 | void POP3account::setCheckMaxSize(bool aValue) | ||
297 | { | ||
298 | m_CheckSize = aValue; | ||
299 | } | ||
300 | |||
301 | int POP3account::getMaxSize()const | ||
302 | { | ||
303 | return m_MaxSize; | ||
304 | } | ||
305 | |||
306 | void POP3account::setMaxSize(int aValue) | ||
307 | { | ||
308 | m_MaxSize = aValue; | ||
309 | } | ||
310 | |||
284 | SMTPaccount::SMTPaccount() | 311 | SMTPaccount::SMTPaccount() |
285 | : Account() | 312 | : Account() |
286 | { | 313 | { |
287 | file = SMTPaccount::getUniqueFileName(); | 314 | file = SMTPaccount::getUniqueFileName(); |
288 | accountName = "New SMTP Account"; | 315 | accountName = "New SMTP Account"; |
289 | ssl = false; | 316 | ssl = false; |
290 | connectionType = 1; | 317 | connectionType = 1; |
291 | login = false; | 318 | login = false; |
292 | useCC = false; | 319 | useCC = false; |
293 | useBCC = false; | 320 | useBCC = false; |
294 | useReply = false; | 321 | useReply = false; |
295 | type = MAILLIB::A_SMTP; | 322 | type = MAILLIB::A_SMTP; |
@@ -331,25 +358,25 @@ void SMTPaccount::read() | |||
331 | server = conf->readEntry( "Server" ); | 358 | server = conf->readEntry( "Server" ); |
332 | port = conf->readEntry( "Port" ); | 359 | port = conf->readEntry( "Port" ); |
333 | ssl = conf->readBoolEntry( "SSL" ); | 360 | ssl = conf->readBoolEntry( "SSL" ); |
334 | connectionType = conf->readNumEntry( "ConnectionType" ); | 361 | connectionType = conf->readNumEntry( "ConnectionType" ); |
335 | login = conf->readBoolEntry( "Login" ); | 362 | login = conf->readBoolEntry( "Login" ); |
336 | user = conf->readEntry( "User" ); | 363 | user = conf->readEntry( "User" ); |
337 | password = conf->readEntryCrypt( "Password" ); | 364 | password = conf->readEntryCrypt( "Password" ); |
338 | delete conf; | 365 | delete conf; |
339 | } | 366 | } |
340 | 367 | ||
341 | void SMTPaccount::save() | 368 | void 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" ); |
348 | conf->writeEntry( "Account", accountName ); | 375 | conf->writeEntry( "Account", accountName ); |
349 | conf->writeEntry( "Server", server ); | 376 | conf->writeEntry( "Server", server ); |
350 | conf->writeEntry( "Port", port ); | 377 | conf->writeEntry( "Port", port ); |
351 | conf->writeEntry( "SSL", ssl ); | 378 | conf->writeEntry( "SSL", ssl ); |
352 | conf->writeEntry( "ConnectionType", connectionType ); | 379 | conf->writeEntry( "ConnectionType", connectionType ); |
353 | conf->writeEntry( "Login", login ); | 380 | conf->writeEntry( "Login", login ); |
354 | conf->writeEntry( "User", user ); | 381 | conf->writeEntry( "User", user ); |
355 | conf->writeEntryCrypt( "Password", password ); | 382 | conf->writeEntryCrypt( "Password", password ); |
@@ -408,25 +435,25 @@ void NNTPaccount::read() | |||
408 | server = conf->readEntry( "Server" ); | 435 | server = conf->readEntry( "Server" ); |
409 | port = conf->readEntry( "Port" ); | 436 | port = conf->readEntry( "Port" ); |
410 | ssl = conf->readBoolEntry( "SSL" ); | 437 | ssl = conf->readBoolEntry( "SSL" ); |
411 | login = conf->readBoolEntry( "Login" ); | 438 | login = conf->readBoolEntry( "Login" ); |
412 | user = conf->readEntry( "User" ); | 439 | user = conf->readEntry( "User" ); |
413 | password = conf->readEntryCrypt( "Password" ); | 440 | password = conf->readEntryCrypt( "Password" ); |
414 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); | 441 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); |
415 | delete conf; | 442 | delete conf; |
416 | } | 443 | } |
417 | 444 | ||
418 | void NNTPaccount::save() | 445 | void 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" ); |
425 | conf->writeEntry( "Account", accountName ); | 452 | conf->writeEntry( "Account", accountName ); |
426 | conf->writeEntry( "Server", server ); | 453 | conf->writeEntry( "Server", server ); |
427 | conf->writeEntry( "Port", port ); | 454 | conf->writeEntry( "Port", port ); |
428 | conf->writeEntry( "SSL", ssl ); | 455 | conf->writeEntry( "SSL", ssl ); |
429 | conf->writeEntry( "Login", login ); | 456 | conf->writeEntry( "Login", login ); |
430 | conf->writeEntry( "User", user ); | 457 | conf->writeEntry( "User", user ); |
431 | conf->writeEntryCrypt( "Password", password ); | 458 | conf->writeEntryCrypt( "Password", password ); |
432 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); | 459 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); |