-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 46 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.h | 6 |
2 files changed, 51 insertions, 1 deletions
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 19093b1..8f909f9 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,99 +1,103 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qtextcodec.h> | ||
5 | #include <qtextstream.h> | ||
6 | #include <qfile.h> | ||
7 | |||
4 | //#include <opie2/odebug.h> | 8 | //#include <opie2/odebug.h> |
5 | #include <kconfig.h> | 9 | #include <kconfig.h> |
6 | 10 | ||
7 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
8 | #include "settings.h" | 12 | #include "settings.h" |
9 | //#include "defines.h" | 13 | //#include "defines.h" |
10 | 14 | ||
11 | #define IMAP_PORT "143" | 15 | #define IMAP_PORT "143" |
12 | #define IMAP_SSL_PORT "993" | 16 | #define IMAP_SSL_PORT "993" |
13 | #define SMTP_PORT "25" | 17 | #define SMTP_PORT "25" |
14 | #define SMTP_SSL_PORT "465" | 18 | #define SMTP_SSL_PORT "465" |
15 | #define POP3_PORT "110" | 19 | #define POP3_PORT "110" |
16 | #define POP3_SSL_PORT "995" | 20 | #define POP3_SSL_PORT "995" |
17 | #define NNTP_PORT "119" | 21 | #define NNTP_PORT "119" |
18 | #define NNTP_SSL_PORT "563" | 22 | #define NNTP_SSL_PORT "563" |
19 | 23 | ||
20 | 24 | ||
21 | Settings::Settings() | 25 | Settings::Settings() |
22 | : QObject() | 26 | : QObject() |
23 | { | 27 | { |
24 | accounts.setAutoDelete( true ); ; | 28 | accounts.setAutoDelete( true ); ; |
25 | updateAccounts(); | 29 | updateAccounts(); |
26 | //qDebug("++++++++++++++++++new settings "); | 30 | //qDebug("++++++++++++++++++new settings "); |
27 | } | 31 | } |
28 | 32 | ||
29 | void Settings::checkDirectory() | 33 | void Settings::checkDirectory() |
30 | { | 34 | { |
31 | return; | 35 | return; |
32 | locateLocal("data", "kopiemail" ); | 36 | locateLocal("data", "kopiemail" ); |
33 | /* | 37 | /* |
34 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 38 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
35 | system( "mkdir -p $HOME/Applications/opiemail" ); | 39 | system( "mkdir -p $HOME/Applications/opiemail" ); |
36 | qDebug("$HOME/Applications/opiemail created "); | 40 | qDebug("$HOME/Applications/opiemail created "); |
37 | } | 41 | } |
38 | */ | 42 | */ |
39 | } | 43 | } |
40 | 44 | ||
41 | QList<Account> Settings::getAccounts() | 45 | QList<Account> Settings::getAccounts() |
42 | { | 46 | { |
43 | return accounts; | 47 | return accounts; |
44 | } | 48 | } |
45 | 49 | ||
46 | void Settings::addAccount( Account *account ) | 50 | void Settings::addAccount( Account *account ) |
47 | { | 51 | { |
48 | accounts.append( account ); | 52 | accounts.append( account ); |
49 | } | 53 | } |
50 | 54 | ||
51 | void Settings::delAccount( Account *account ) | 55 | void Settings::delAccount( Account *account ) |
52 | { | 56 | { |
53 | account->remove(); | 57 | account->remove(); |
54 | accounts.remove( account ); | 58 | accounts.remove( account ); |
55 | } | 59 | } |
56 | 60 | ||
57 | void Settings::updateAccounts() | 61 | void Settings::updateAccounts() |
58 | { | 62 | { |
59 | accounts.clear(); | 63 | accounts.clear(); |
60 | QDir dir( locateLocal("data", "kopiemail" ) ); | 64 | QDir dir( locateLocal("data", "kopiemail" ) ); |
61 | QStringList::Iterator it; | 65 | QStringList::Iterator it; |
62 | 66 | ||
63 | QStringList imap = dir.entryList( "imap-*" ); | 67 | QStringList imap = dir.entryList( "imap-*" ); |
64 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 68 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
65 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 69 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
66 | accounts.append( account ); | 70 | accounts.append( account ); |
67 | } | 71 | } |
68 | 72 | ||
69 | QStringList pop3 = dir.entryList( "pop3-*" ); | 73 | QStringList pop3 = dir.entryList( "pop3-*" ); |
70 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 74 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
71 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 75 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
72 | accounts.append( account ); | 76 | accounts.append( account ); |
73 | } | 77 | } |
74 | 78 | ||
75 | QStringList smtp = dir.entryList( "smtp-*" ); | 79 | QStringList smtp = dir.entryList( "smtp-*" ); |
76 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 80 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
77 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 81 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
78 | accounts.append( account ); | 82 | accounts.append( account ); |
79 | } | 83 | } |
80 | 84 | ||
81 | QStringList nntp = dir.entryList( "nntp-*" ); | 85 | QStringList nntp = dir.entryList( "nntp-*" ); |
82 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 86 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
83 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 87 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
84 | accounts.append( account ); | 88 | accounts.append( account ); |
85 | } | 89 | } |
86 | 90 | ||
87 | readAccounts(); | 91 | readAccounts(); |
88 | } | 92 | } |
89 | 93 | ||
90 | void Settings::saveAccounts() | 94 | void Settings::saveAccounts() |
91 | { | 95 | { |
92 | checkDirectory(); | 96 | checkDirectory(); |
93 | Account *it; | 97 | Account *it; |
94 | 98 | ||
95 | for ( it = accounts.first(); it; it = accounts.next() ) { | 99 | for ( it = accounts.first(); it; it = accounts.next() ) { |
96 | it->save(); | 100 | it->save(); |
97 | } | 101 | } |
98 | } | 102 | } |
99 | 103 | ||
@@ -273,229 +277,269 @@ POP3account::POP3account( QString filename ) | |||
273 | 277 | ||
274 | QString POP3account::getUniqueFileName() | 278 | QString POP3account::getUniqueFileName() |
275 | { | 279 | { |
276 | int num = 0; | 280 | int num = 0; |
277 | QString unique; | 281 | QString unique; |
278 | 282 | ||
279 | QDir dir( locateLocal("data", "kopiemail" ) ); | 283 | QDir dir( locateLocal("data", "kopiemail" ) ); |
280 | 284 | ||
281 | QStringList imap = dir.entryList( "pop3-*" ); | 285 | QStringList imap = dir.entryList( "pop3-*" ); |
282 | do { | 286 | do { |
283 | unique.setNum( num++ ); | 287 | unique.setNum( num++ ); |
284 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 288 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
285 | 289 | ||
286 | return unique; | 290 | return unique; |
287 | } | 291 | } |
288 | 292 | ||
289 | void POP3account::read() | 293 | void POP3account::read() |
290 | { | 294 | { |
291 | KConfig *conf = new KConfig( getFileName()); | 295 | KConfig *conf = new KConfig( getFileName()); |
292 | conf->setGroup( "POP3 Account" ); | 296 | conf->setGroup( "POP3 Account" ); |
293 | accountName = conf->readEntry( "Account" ); | 297 | accountName = conf->readEntry( "Account" ); |
294 | server = conf->readEntry( "Server" ); | 298 | server = conf->readEntry( "Server" ); |
295 | port = conf->readEntry( "Port" ); | 299 | port = conf->readEntry( "Port" ); |
296 | ssl = conf->readBoolEntry( "SSL" ); | 300 | ssl = conf->readBoolEntry( "SSL" ); |
297 | connectionType = conf->readNumEntry( "ConnectionType" ); | 301 | connectionType = conf->readNumEntry( "ConnectionType" ); |
298 | user = conf->readEntry( "User" ); | 302 | user = conf->readEntry( "User" ); |
299 | //password = conf->readEntryCrypt( "Password" ); | 303 | //password = conf->readEntryCrypt( "Password" ); |
300 | setPasswordList( conf->readListEntry( "FolderHistory")); | 304 | setPasswordList( conf->readListEntry( "FolderHistory")); |
301 | offline = conf->readBoolEntry("Offline",false); | 305 | offline = conf->readBoolEntry("Offline",false); |
302 | localFolder = conf->readEntry( "LocalFolder" ); | 306 | localFolder = conf->readEntry( "LocalFolder" ); |
303 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); | 307 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); |
304 | int lf = conf->readNumEntry( "LastFetch",0 ); | 308 | int lf = conf->readNumEntry( "LastFetch",0 ); |
305 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 309 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
306 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); | 310 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); |
307 | lastFetch = dt.addSecs( lf ); | 311 | lastFetch = dt.addSecs( lf ); |
308 | delete conf; | 312 | delete conf; |
309 | } | 313 | } |
310 | 314 | ||
311 | void POP3account::save() | 315 | void POP3account::save() |
312 | { | 316 | { |
313 | Settings::checkDirectory(); | 317 | Settings::checkDirectory(); |
314 | 318 | ||
315 | KConfig *conf = new KConfig( getFileName() ); | 319 | KConfig *conf = new KConfig( getFileName() ); |
316 | conf->setGroup( "POP3 Account" ); | 320 | conf->setGroup( "POP3 Account" ); |
317 | conf->writeEntry( "Account", accountName ); | 321 | conf->writeEntry( "Account", accountName ); |
318 | conf->writeEntry( "Server", server ); | 322 | conf->writeEntry( "Server", server ); |
319 | conf->writeEntry( "Port", port ); | 323 | conf->writeEntry( "Port", port ); |
320 | conf->writeEntry( "SSL", ssl ); | 324 | conf->writeEntry( "SSL", ssl ); |
321 | conf->writeEntry( "ConnectionType", connectionType ); | 325 | conf->writeEntry( "ConnectionType", connectionType ); |
322 | conf->writeEntry( "User", user ); | 326 | conf->writeEntry( "User", user ); |
323 | //conf->writeEntryCrypt( "Password", password ); | 327 | //conf->writeEntryCrypt( "Password", password ); |
324 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 328 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
325 | conf->writeEntry( "Offline",offline); | 329 | conf->writeEntry( "Offline",offline); |
326 | conf->writeEntry( "LocalFolder", localFolder ); | 330 | conf->writeEntry( "LocalFolder", localFolder ); |
327 | conf->writeEntry( "MaxSize", maxMailSize ); | 331 | conf->writeEntry( "MaxSize", maxMailSize ); |
328 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 332 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
329 | int lf = dt.secsTo ( lastFetch ); | 333 | int lf = dt.secsTo ( lastFetch ); |
330 | conf->writeEntry( "LastFetch", lf ); | 334 | conf->writeEntry( "LastFetch", lf ); |
331 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 335 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
332 | conf->sync(); | 336 | conf->sync(); |
333 | delete conf; | 337 | delete conf; |
334 | } | 338 | } |
335 | 339 | ||
336 | 340 | ||
337 | QString POP3account::getFileName() | 341 | QString POP3account::getFileName() |
338 | { | 342 | { |
339 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; | 343 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; |
340 | } | 344 | } |
341 | 345 | ||
342 | SMTPaccount::SMTPaccount() | 346 | SMTPaccount::SMTPaccount() |
343 | : Account() | 347 | : Account() |
344 | { | 348 | { |
345 | file = SMTPaccount::getUniqueFileName(); | 349 | file = SMTPaccount::getUniqueFileName(); |
346 | accountName = "New SMTP Account"; | 350 | accountName = "New SMTP Account"; |
347 | ssl = false; | 351 | ssl = false; |
348 | connectionType = 1; | 352 | connectionType = 1; |
349 | login = false; | 353 | login = false; |
350 | useCC = false; | 354 | useCC = false; |
351 | useBCC = false; | 355 | useBCC = false; |
352 | useReply = false; | 356 | useReply = false; |
353 | type = MAILLIB::A_SMTP; | 357 | type = MAILLIB::A_SMTP; |
354 | port = SMTP_PORT; | 358 | port = SMTP_PORT; |
355 | } | 359 | } |
356 | 360 | ||
357 | SMTPaccount::SMTPaccount( QString filename ) | 361 | SMTPaccount::SMTPaccount( QString filename ) |
358 | : Account() | 362 | : Account() |
359 | { | 363 | { |
360 | file = filename; | 364 | file = filename; |
361 | accountName = "New SMTP Account"; | 365 | accountName = "New SMTP Account"; |
362 | ssl = false; | 366 | ssl = false; |
363 | connectionType = 1; | 367 | connectionType = 1; |
364 | login = false; | 368 | login = false; |
365 | type = MAILLIB::A_SMTP; | 369 | type = MAILLIB::A_SMTP; |
366 | port = SMTP_PORT; | 370 | port = SMTP_PORT; |
367 | } | 371 | } |
368 | 372 | ||
373 | QString SMTPaccount::getSignature() | ||
374 | { | ||
375 | QFileInfo fi ( signature ); | ||
376 | if ( ! fi.exists() ) | ||
377 | return QString(); | ||
378 | |||
379 | QFile file( signature ); | ||
380 | if (!file.open( IO_ReadOnly ) ) { | ||
381 | return QString(); | ||
382 | |||
383 | } | ||
384 | QTextStream ts( &file ); | ||
385 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
386 | QString text = ts.read(); | ||
387 | file.close(); | ||
388 | |||
389 | return text; | ||
390 | |||
391 | } | ||
392 | void SMTPaccount::setSignature( QString b ) | ||
393 | { | ||
394 | |||
395 | QFileInfo fi ( signature ); | ||
396 | if ( ! fi.exists() ) { | ||
397 | QString filedir( locateLocal("data", "kopiemail" ) ); | ||
398 | signature = filedir+ "/" + getAccountName() +".sig"; | ||
399 | qDebug("new sig %s ", signature.latin1()); | ||
400 | save(); | ||
401 | } | ||
402 | QFile fileIn( signature ); | ||
403 | if (!fileIn.open( IO_WriteOnly ) ) { | ||
404 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); | ||
405 | return ; | ||
406 | } | ||
407 | QTextStream tsIn( &fileIn ); | ||
408 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | ||
409 | tsIn << b ; | ||
410 | fileIn.close(); | ||
411 | } | ||
369 | QString SMTPaccount::getUniqueFileName() | 412 | QString SMTPaccount::getUniqueFileName() |
370 | { | 413 | { |
371 | int num = 0; | 414 | int num = 0; |
372 | QString unique; | 415 | QString unique; |
373 | 416 | ||
374 | QDir dir( locateLocal("data", "kopiemail" ) ); | 417 | QDir dir( locateLocal("data", "kopiemail" ) ); |
375 | 418 | ||
376 | QStringList imap = dir.entryList( "smtp-*" ); | 419 | QStringList imap = dir.entryList( "smtp-*" ); |
377 | do { | 420 | do { |
378 | unique.setNum( num++ ); | 421 | unique.setNum( num++ ); |
379 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 422 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
380 | 423 | ||
381 | return unique; | 424 | return unique; |
382 | } | 425 | } |
383 | 426 | ||
384 | void SMTPaccount::read() | 427 | void SMTPaccount::read() |
385 | { | 428 | { |
386 | KConfig *conf = new KConfig( getFileName() ); | 429 | KConfig *conf = new KConfig( getFileName() ); |
387 | conf->setGroup( "SMTP Account" ); | 430 | conf->setGroup( "SMTP Account" ); |
388 | accountName = conf->readEntry( "Account" ); | 431 | accountName = conf->readEntry( "Account" ); |
389 | server = conf->readEntry( "Server" ); | 432 | server = conf->readEntry( "Server" ); |
390 | port = conf->readEntry( "Port" ); | 433 | port = conf->readEntry( "Port" ); |
391 | ssl = conf->readBoolEntry( "SSL" ); | 434 | ssl = conf->readBoolEntry( "SSL" ); |
392 | connectionType = conf->readNumEntry( "ConnectionType" ); | 435 | connectionType = conf->readNumEntry( "ConnectionType" ); |
393 | login = conf->readBoolEntry( "Login" ); | 436 | login = conf->readBoolEntry( "Login" ); |
394 | user = conf->readEntry( "User" ); | 437 | user = conf->readEntry( "User" ); |
395 | //password = conf->readEntryCrypt( "Password" ); | 438 | signature = conf->readEntry( "SigFile" ); |
396 | setPasswordList( conf->readListEntry( "FolderHistory")); | 439 | setPasswordList( conf->readListEntry( "FolderHistory")); |
397 | delete conf; | 440 | delete conf; |
398 | } | 441 | } |
399 | 442 | ||
400 | void SMTPaccount::save() | 443 | void SMTPaccount::save() |
401 | { | 444 | { |
402 | Settings::checkDirectory(); | 445 | Settings::checkDirectory(); |
403 | 446 | ||
404 | KConfig *conf = new KConfig( getFileName() ); | 447 | KConfig *conf = new KConfig( getFileName() ); |
405 | conf->setGroup( "SMTP Account" ); | 448 | conf->setGroup( "SMTP Account" ); |
406 | conf->writeEntry( "Account", accountName ); | 449 | conf->writeEntry( "Account", accountName ); |
407 | conf->writeEntry( "Server", server ); | 450 | conf->writeEntry( "Server", server ); |
408 | conf->writeEntry( "Port", port ); | 451 | conf->writeEntry( "Port", port ); |
409 | conf->writeEntry( "SSL", ssl ); | 452 | conf->writeEntry( "SSL", ssl ); |
410 | conf->writeEntry( "ConnectionType", connectionType ); | 453 | conf->writeEntry( "ConnectionType", connectionType ); |
411 | conf->writeEntry( "Login", login ); | 454 | conf->writeEntry( "Login", login ); |
412 | conf->writeEntry( "User", user ); | 455 | conf->writeEntry( "User", user ); |
456 | conf->writeEntry( "SigFile", signature ); | ||
413 | //conf->writeEntryCrypt( "Password", password ); | 457 | //conf->writeEntryCrypt( "Password", password ); |
414 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 458 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
415 | conf->sync(); | 459 | conf->sync(); |
416 | delete conf; | 460 | delete conf; |
417 | } | 461 | } |
418 | 462 | ||
419 | 463 | ||
420 | QString SMTPaccount::getFileName() | 464 | QString SMTPaccount::getFileName() |
421 | { | 465 | { |
422 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; | 466 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; |
423 | } | 467 | } |
424 | 468 | ||
425 | NNTPaccount::NNTPaccount() | 469 | NNTPaccount::NNTPaccount() |
426 | : Account() | 470 | : Account() |
427 | { | 471 | { |
428 | file = NNTPaccount::getUniqueFileName(); | 472 | file = NNTPaccount::getUniqueFileName(); |
429 | accountName = "New NNTP Account"; | 473 | accountName = "New NNTP Account"; |
430 | ssl = false; | 474 | ssl = false; |
431 | login = false; | 475 | login = false; |
432 | type = MAILLIB::A_NNTP; | 476 | type = MAILLIB::A_NNTP; |
433 | port = NNTP_PORT; | 477 | port = NNTP_PORT; |
434 | } | 478 | } |
435 | 479 | ||
436 | NNTPaccount::NNTPaccount( QString filename ) | 480 | NNTPaccount::NNTPaccount( QString filename ) |
437 | : Account() | 481 | : Account() |
438 | { | 482 | { |
439 | file = filename; | 483 | file = filename; |
440 | accountName = "New NNTP Account"; | 484 | accountName = "New NNTP Account"; |
441 | ssl = false; | 485 | ssl = false; |
442 | login = false; | 486 | login = false; |
443 | type = MAILLIB::A_NNTP; | 487 | type = MAILLIB::A_NNTP; |
444 | port = NNTP_PORT; | 488 | port = NNTP_PORT; |
445 | } | 489 | } |
446 | 490 | ||
447 | QString NNTPaccount::getUniqueFileName() | 491 | QString NNTPaccount::getUniqueFileName() |
448 | { | 492 | { |
449 | int num = 0; | 493 | int num = 0; |
450 | QString unique; | 494 | QString unique; |
451 | 495 | ||
452 | QDir dir( locateLocal("data", "kopiemail" ) ); | 496 | QDir dir( locateLocal("data", "kopiemail" ) ); |
453 | 497 | ||
454 | QStringList imap = dir.entryList( "nntp-*" ); | 498 | QStringList imap = dir.entryList( "nntp-*" ); |
455 | do { | 499 | do { |
456 | unique.setNum( num++ ); | 500 | unique.setNum( num++ ); |
457 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 501 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
458 | 502 | ||
459 | return unique; | 503 | return unique; |
460 | } | 504 | } |
461 | 505 | ||
462 | void NNTPaccount::read() | 506 | void NNTPaccount::read() |
463 | { | 507 | { |
464 | KConfig *conf = new KConfig( getFileName() ); | 508 | KConfig *conf = new KConfig( getFileName() ); |
465 | conf->setGroup( "NNTP Account" ); | 509 | conf->setGroup( "NNTP Account" ); |
466 | accountName = conf->readEntry( "Account" ); | 510 | accountName = conf->readEntry( "Account" ); |
467 | server = conf->readEntry( "Server" ); | 511 | server = conf->readEntry( "Server" ); |
468 | port = conf->readEntry( "Port" ); | 512 | port = conf->readEntry( "Port" ); |
469 | ssl = conf->readBoolEntry( "SSL" ); | 513 | ssl = conf->readBoolEntry( "SSL" ); |
470 | login = conf->readBoolEntry( "Login" ); | 514 | login = conf->readBoolEntry( "Login" ); |
471 | user = conf->readEntry( "User" ); | 515 | user = conf->readEntry( "User" ); |
472 | //password = conf->readEntryCrypt( "Password" ); | 516 | //password = conf->readEntryCrypt( "Password" ); |
473 | setPasswordList( conf->readListEntry( "FolderHistory")); | 517 | setPasswordList( conf->readListEntry( "FolderHistory")); |
474 | subscribedGroups = conf->readListEntry( "Subscribed"); | 518 | subscribedGroups = conf->readListEntry( "Subscribed"); |
475 | delete conf; | 519 | delete conf; |
476 | } | 520 | } |
477 | 521 | ||
478 | void NNTPaccount::save() | 522 | void NNTPaccount::save() |
479 | { | 523 | { |
480 | Settings::checkDirectory(); | 524 | Settings::checkDirectory(); |
481 | 525 | ||
482 | KConfig *conf = new KConfig( getFileName() ); | 526 | KConfig *conf = new KConfig( getFileName() ); |
483 | conf->setGroup( "NNTP Account" ); | 527 | conf->setGroup( "NNTP Account" ); |
484 | conf->writeEntry( "Account", accountName ); | 528 | conf->writeEntry( "Account", accountName ); |
485 | conf->writeEntry( "Server", server ); | 529 | conf->writeEntry( "Server", server ); |
486 | conf->writeEntry( "Port", port ); | 530 | conf->writeEntry( "Port", port ); |
487 | conf->writeEntry( "SSL", ssl ); | 531 | conf->writeEntry( "SSL", ssl ); |
488 | conf->writeEntry( "Login", login ); | 532 | conf->writeEntry( "Login", login ); |
489 | conf->writeEntry( "User", user ); | 533 | conf->writeEntry( "User", user ); |
490 | //conf->writeEntryCrypt( "Password", password ); | 534 | //conf->writeEntryCrypt( "Password", password ); |
491 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 535 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
492 | conf->writeEntry( "Subscribed" , subscribedGroups ); | 536 | conf->writeEntry( "Subscribed" , subscribedGroups ); |
493 | conf->sync(); | 537 | conf->sync(); |
494 | delete conf; | 538 | delete conf; |
495 | } | 539 | } |
496 | 540 | ||
497 | 541 | ||
498 | QString NNTPaccount::getFileName() | 542 | QString NNTPaccount::getFileName() |
499 | { | 543 | { |
500 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; | 544 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; |
501 | } | 545 | } |
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h index c996fe0..a6e95fe 100644 --- a/kmicromail/libmailwrapper/settings.h +++ b/kmicromail/libmailwrapper/settings.h | |||
@@ -34,149 +34,155 @@ public: | |||
34 | 34 | ||
35 | void setUser(const QString&str){ user = str; } | 35 | void setUser(const QString&str){ user = str; } |
36 | const QString&getUser()const{ return user; } | 36 | const QString&getUser()const{ return user; } |
37 | 37 | ||
38 | void setPassword(const QString&str) { password = str; } | 38 | void setPassword(const QString&str) { password = str; } |
39 | const QString&getPassword()const { return password; } | 39 | const QString&getPassword()const { return password; } |
40 | 40 | ||
41 | void setPasswordList(const QStringList &str); | 41 | void setPasswordList(const QStringList &str); |
42 | QStringList getPasswordList(); | 42 | QStringList getPasswordList(); |
43 | 43 | ||
44 | void setSSL( bool b ) { ssl = b; } | 44 | void setSSL( bool b ) { ssl = b; } |
45 | bool getSSL() { return ssl; } | 45 | bool getSSL() { return ssl; } |
46 | 46 | ||
47 | void setConnectionType( int x ) { connectionType = x; } | 47 | void setConnectionType( int x ) { connectionType = x; } |
48 | int ConnectionType() { return connectionType; } | 48 | int ConnectionType() { return connectionType; } |
49 | 49 | ||
50 | void setMaxMailSize( int x ) { maxMailSize = x; } | 50 | void setMaxMailSize( int x ) { maxMailSize = x; } |
51 | int getMaxMailSize() { return maxMailSize; } | 51 | int getMaxMailSize() { return maxMailSize; } |
52 | 52 | ||
53 | void setOffline(bool b) {offline = b;} | 53 | void setOffline(bool b) {offline = b;} |
54 | bool getOffline()const{return offline;} | 54 | bool getOffline()const{return offline;} |
55 | 55 | ||
56 | bool getLeaveOnServer(){ return leaveOnServer;} | 56 | bool getLeaveOnServer(){ return leaveOnServer;} |
57 | void setLeaveOnServer(bool b){ leaveOnServer = b;} | 57 | void setLeaveOnServer(bool b){ leaveOnServer = b;} |
58 | 58 | ||
59 | virtual QString getFileName() { return accountName; } | 59 | virtual QString getFileName() { return accountName; } |
60 | virtual void read() { ; } | 60 | virtual void read() { ; } |
61 | virtual void save() { ; } | 61 | virtual void save() { ; } |
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | QString accountName, server, port, user, password; | 64 | QString accountName, server, port, user, password; |
65 | bool ssl; | 65 | bool ssl; |
66 | int connectionType; | 66 | int connectionType; |
67 | bool offline; | 67 | bool offline; |
68 | MAILLIB::ATYPE type; | 68 | MAILLIB::ATYPE type; |
69 | QString localFolder; | 69 | QString localFolder; |
70 | int maxMailSize; | 70 | int maxMailSize; |
71 | QDateTime lastFetch; | 71 | QDateTime lastFetch; |
72 | bool leaveOnServer; | 72 | bool leaveOnServer; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | class IMAPaccount : public Account | 75 | class IMAPaccount : public Account |
76 | { | 76 | { |
77 | 77 | ||
78 | public: | 78 | public: |
79 | IMAPaccount(); | 79 | IMAPaccount(); |
80 | IMAPaccount( QString filename ); | 80 | IMAPaccount( QString filename ); |
81 | 81 | ||
82 | static QString getUniqueFileName(); | 82 | static QString getUniqueFileName(); |
83 | 83 | ||
84 | virtual void read(); | 84 | virtual void read(); |
85 | virtual void save(); | 85 | virtual void save(); |
86 | virtual QString getFileName(); | 86 | virtual QString getFileName(); |
87 | 87 | ||
88 | void setPrefix(const QString&str) {prefix=str;} | 88 | void setPrefix(const QString&str) {prefix=str;} |
89 | const QString&getPrefix()const{return prefix;} | 89 | const QString&getPrefix()const{return prefix;} |
90 | 90 | ||
91 | private: | 91 | private: |
92 | QString file,prefix; | 92 | QString file,prefix; |
93 | 93 | ||
94 | }; | 94 | }; |
95 | 95 | ||
96 | class POP3account : public Account | 96 | class POP3account : public Account |
97 | { | 97 | { |
98 | 98 | ||
99 | public: | 99 | public: |
100 | POP3account(); | 100 | POP3account(); |
101 | POP3account( QString filename ); | 101 | POP3account( QString filename ); |
102 | 102 | ||
103 | static QString getUniqueFileName(); | 103 | static QString getUniqueFileName(); |
104 | 104 | ||
105 | virtual void read(); | 105 | virtual void read(); |
106 | virtual void save(); | 106 | virtual void save(); |
107 | virtual QString getFileName(); | 107 | virtual QString getFileName(); |
108 | 108 | ||
109 | private: | 109 | private: |
110 | QString file; | 110 | QString file; |
111 | 111 | ||
112 | }; | 112 | }; |
113 | 113 | ||
114 | class SMTPaccount : public Account | 114 | class SMTPaccount : public Account |
115 | { | 115 | { |
116 | 116 | ||
117 | public: | 117 | public: |
118 | SMTPaccount(); | 118 | SMTPaccount(); |
119 | SMTPaccount( QString filename ); | 119 | SMTPaccount( QString filename ); |
120 | 120 | ||
121 | static QString getUniqueFileName(); | 121 | static QString getUniqueFileName(); |
122 | 122 | ||
123 | virtual void read(); | 123 | virtual void read(); |
124 | virtual void save(); | 124 | virtual void save(); |
125 | virtual QString getFileName(); | 125 | virtual QString getFileName(); |
126 | 126 | ||
127 | void setLogin( bool b ) { login = b; } | 127 | void setLogin( bool b ) { login = b; } |
128 | bool getLogin() { return login; } | 128 | bool getLogin() { return login; } |
129 | 129 | ||
130 | void setSigFile( QString b ) { signature = b; } | ||
131 | QString getSigFile() { return signature; } | ||
132 | |||
133 | QString getSignature(); | ||
134 | void setSignature( QString b ); | ||
135 | |||
130 | private: | 136 | private: |
131 | QString file, name, mail, org, cc, bcc, reply, signature; | 137 | QString file, name, mail, org, cc, bcc, reply, signature; |
132 | bool useCC, useBCC, useReply, login; | 138 | bool useCC, useBCC, useReply, login; |
133 | 139 | ||
134 | }; | 140 | }; |
135 | 141 | ||
136 | class NNTPaccount : public Account | 142 | class NNTPaccount : public Account |
137 | { | 143 | { |
138 | 144 | ||
139 | public: | 145 | public: |
140 | NNTPaccount(); | 146 | NNTPaccount(); |
141 | NNTPaccount( QString filename ); | 147 | NNTPaccount( QString filename ); |
142 | 148 | ||
143 | static QString getUniqueFileName(); | 149 | static QString getUniqueFileName(); |
144 | 150 | ||
145 | virtual void read(); | 151 | virtual void read(); |
146 | virtual void save(); | 152 | virtual void save(); |
147 | virtual QString getFileName(); | 153 | virtual QString getFileName(); |
148 | 154 | ||
149 | void setLogin( bool b ) { login = b; } | 155 | void setLogin( bool b ) { login = b; } |
150 | bool getLogin() { return login; } | 156 | bool getLogin() { return login; } |
151 | 157 | ||
152 | void setGroups( QStringList list ) { subscribedGroups = list; } | 158 | void setGroups( QStringList list ) { subscribedGroups = list; } |
153 | QStringList getGroups() { return subscribedGroups; } | 159 | QStringList getGroups() { return subscribedGroups; } |
154 | 160 | ||
155 | private: | 161 | private: |
156 | QString file; | 162 | QString file; |
157 | bool login; | 163 | bool login; |
158 | QStringList subscribedGroups; | 164 | QStringList subscribedGroups; |
159 | 165 | ||
160 | }; | 166 | }; |
161 | 167 | ||
162 | class Settings : public QObject | 168 | class Settings : public QObject |
163 | { | 169 | { |
164 | Q_OBJECT | 170 | Q_OBJECT |
165 | 171 | ||
166 | public: | 172 | public: |
167 | Settings(); | 173 | Settings(); |
168 | //~Settings(){qDebug("-------------------settings "); }; | 174 | //~Settings(){qDebug("-------------------settings "); }; |
169 | QList<Account> getAccounts(); | 175 | QList<Account> getAccounts(); |
170 | void addAccount(Account *account); | 176 | void addAccount(Account *account); |
171 | void delAccount(Account *account); | 177 | void delAccount(Account *account); |
172 | void saveAccounts(); | 178 | void saveAccounts(); |
173 | void readAccounts(); | 179 | void readAccounts(); |
174 | static void checkDirectory(); | 180 | static void checkDirectory(); |
175 | 181 | ||
176 | private: | 182 | private: |
177 | void updateAccounts(); | 183 | void updateAccounts(); |
178 | QList<Account> accounts; | 184 | QList<Account> accounts; |
179 | 185 | ||
180 | }; | 186 | }; |
181 | 187 | ||
182 | #endif | 188 | #endif |