author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kmicromail/libmailwrapper/settings.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'kmicromail/libmailwrapper/settings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 9436d43..fc01528 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,53 +1,53 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qtextcodec.h> | 4 | #include <qtextcodec.h> |
5 | #include <qtextstream.h> | 5 | #include <q3textstream.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | 7 | ||
8 | //#include <opie2/odebug.h> | 8 | //#include <opie2/odebug.h> |
9 | #include <kconfig.h> | 9 | #include <kconfig.h> |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include "settings.h" | 12 | #include "settings.h" |
13 | //#include "defines.h" | 13 | //#include "defines.h" |
14 | 14 | ||
15 | #define IMAP_PORT "143" | 15 | #define IMAP_PORT "143" |
16 | #define IMAP_SSL_PORT "993" | 16 | #define IMAP_SSL_PORT "993" |
17 | #define SMTP_PORT "25" | 17 | #define SMTP_PORT "25" |
18 | #define SMTP_SSL_PORT "465" | 18 | #define SMTP_SSL_PORT "465" |
19 | #define POP3_PORT "110" | 19 | #define POP3_PORT "110" |
20 | #define POP3_SSL_PORT "995" | 20 | #define POP3_SSL_PORT "995" |
21 | #define NNTP_PORT "119" | 21 | #define NNTP_PORT "119" |
22 | #define NNTP_SSL_PORT "563" | 22 | #define NNTP_SSL_PORT "563" |
23 | 23 | ||
24 | 24 | ||
25 | Settings::Settings() | 25 | Settings::Settings() |
26 | : QObject() | 26 | : QObject() |
27 | { | 27 | { |
28 | accounts.setAutoDelete( true ); ; | 28 | accounts.setAutoDelete( true ); ; |
29 | updateAccounts(); | 29 | updateAccounts(); |
30 | //qDebug("++++++++++++++++++new settings "); | 30 | //qDebug("++++++++++++++++++new settings "); |
31 | } | 31 | } |
32 | 32 | ||
33 | void Settings::checkDirectory() | 33 | void Settings::checkDirectory() |
34 | { | 34 | { |
35 | return; | 35 | return; |
36 | locateLocal("data", "kopiemail" ); | 36 | locateLocal("data", "kopiemail" ); |
37 | /* | 37 | /* |
38 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 38 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
39 | system( "mkdir -p $HOME/Applications/opiemail" ); | 39 | system( "mkdir -p $HOME/Applications/opiemail" ); |
40 | qDebug("$HOME/Applications/opiemail created "); | 40 | qDebug("$HOME/Applications/opiemail created "); |
41 | } | 41 | } |
42 | */ | 42 | */ |
43 | } | 43 | } |
44 | 44 | ||
45 | QList<Account> Settings::getAccounts() | 45 | QList<Account> Settings::getAccounts() |
46 | { | 46 | { |
47 | return accounts; | 47 | return accounts; |
48 | } | 48 | } |
49 | 49 | ||
50 | void Settings::addAccount( Account *account ) | 50 | void Settings::addAccount( Account *account ) |
51 | { | 51 | { |
52 | accounts.append( account ); | 52 | accounts.append( account ); |
53 | } | 53 | } |
@@ -331,124 +331,124 @@ void POP3account::save() | |||
331 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 331 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
332 | int lf = dt.secsTo ( lastFetch ); | 332 | int lf = dt.secsTo ( lastFetch ); |
333 | conf->writeEntry( "LastFetch", lf ); | 333 | conf->writeEntry( "LastFetch", lf ); |
334 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 334 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
335 | conf->sync(); | 335 | conf->sync(); |
336 | delete conf; | 336 | delete conf; |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | QString POP3account::getFileName() | 340 | QString POP3account::getFileName() |
341 | { | 341 | { |
342 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; | 342 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; |
343 | } | 343 | } |
344 | 344 | ||
345 | SMTPaccount::SMTPaccount() | 345 | SMTPaccount::SMTPaccount() |
346 | : Account() | 346 | : Account() |
347 | { | 347 | { |
348 | file = SMTPaccount::getUniqueFileName(); | 348 | file = SMTPaccount::getUniqueFileName(); |
349 | accountName = "New SMTP Account"; | 349 | accountName = "New SMTP Account"; |
350 | ssl = false; | 350 | ssl = false; |
351 | connectionType = 1; | 351 | connectionType = 1; |
352 | login = false; | 352 | login = false; |
353 | useCC = false; | 353 | useCC = false; |
354 | useBCC = false; | 354 | useBCC = false; |
355 | useReply = false; | 355 | useReply = false; |
356 | type = MAILLIB::A_SMTP; | 356 | type = MAILLIB::A_SMTP; |
357 | port = SMTP_PORT; | 357 | port = SMTP_PORT; |
358 | } | 358 | } |
359 | 359 | ||
360 | SMTPaccount::SMTPaccount( QString filename ) | 360 | SMTPaccount::SMTPaccount( QString filename ) |
361 | : Account() | 361 | : Account() |
362 | { | 362 | { |
363 | file = filename; | 363 | file = filename; |
364 | accountName = "New SMTP Account"; | 364 | accountName = "New SMTP Account"; |
365 | ssl = false; | 365 | ssl = false; |
366 | connectionType = 1; | 366 | connectionType = 1; |
367 | login = false; | 367 | login = false; |
368 | type = MAILLIB::A_SMTP; | 368 | type = MAILLIB::A_SMTP; |
369 | port = SMTP_PORT; | 369 | port = SMTP_PORT; |
370 | } | 370 | } |
371 | 371 | ||
372 | QString SMTPaccount::getSignature() | 372 | QString SMTPaccount::getSignature() |
373 | { | 373 | { |
374 | QFileInfo fi ( signature ); | 374 | QFileInfo fi ( signature ); |
375 | if ( ! fi.exists() ) | 375 | if ( ! fi.exists() ) |
376 | return QString(); | 376 | return QString(); |
377 | 377 | ||
378 | QFile file( signature ); | 378 | QFile file( signature ); |
379 | if (!file.open( IO_ReadOnly ) ) { | 379 | if (!file.open( QIODevice::ReadOnly ) ) { |
380 | return QString(); | 380 | return QString(); |
381 | 381 | ||
382 | } | 382 | } |
383 | QTextStream ts( &file ); | 383 | Q3TextStream ts( &file ); |
384 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 384 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
385 | QString text = ts.read(); | 385 | QString text = ts.read(); |
386 | file.close(); | 386 | file.close(); |
387 | 387 | ||
388 | return text; | 388 | return text; |
389 | 389 | ||
390 | } | 390 | } |
391 | void SMTPaccount::setSignature( QString b ) | 391 | void SMTPaccount::setSignature( QString b ) |
392 | { | 392 | { |
393 | 393 | ||
394 | QFileInfo fi ( signature ); | 394 | QFileInfo fi ( signature ); |
395 | if ( ! fi.exists() ) { | 395 | if ( ! fi.exists() ) { |
396 | QString filedir( locateLocal("data", "kopiemail" ) ); | 396 | QString filedir( locateLocal("data", "kopiemail" ) ); |
397 | signature = filedir+ "/" + getAccountName() +".sig"; | 397 | signature = filedir+ "/" + getAccountName() +".sig"; |
398 | qDebug("new sig %s ", signature.latin1()); | 398 | qDebug("new sig %s ", signature.latin1()); |
399 | save(); | 399 | save(); |
400 | } | 400 | } |
401 | QFile fileIn( signature ); | 401 | QFile fileIn( signature ); |
402 | if (!fileIn.open( IO_WriteOnly ) ) { | 402 | if (!fileIn.open( QIODevice::WriteOnly ) ) { |
403 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); | 403 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); |
404 | return ; | 404 | return ; |
405 | } | 405 | } |
406 | QTextStream tsIn( &fileIn ); | 406 | Q3TextStream tsIn( &fileIn ); |
407 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 407 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
408 | tsIn << b ; | 408 | tsIn << b ; |
409 | fileIn.close(); | 409 | fileIn.close(); |
410 | } | 410 | } |
411 | QString SMTPaccount::getUniqueFileName() | 411 | QString SMTPaccount::getUniqueFileName() |
412 | { | 412 | { |
413 | int num = 0; | 413 | int num = 0; |
414 | QString unique; | 414 | QString unique; |
415 | 415 | ||
416 | QDir dir( locateLocal("data", "kopiemail" ) ); | 416 | QDir dir( locateLocal("data", "kopiemail" ) ); |
417 | 417 | ||
418 | QStringList imap = dir.entryList( "smtp-*" ); | 418 | QStringList imap = dir.entryList( "smtp-*" ); |
419 | do { | 419 | do { |
420 | unique.setNum( num++ ); | 420 | unique.setNum( num++ ); |
421 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 421 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
422 | 422 | ||
423 | return unique; | 423 | return unique; |
424 | } | 424 | } |
425 | 425 | ||
426 | void SMTPaccount::read() | 426 | void SMTPaccount::read() |
427 | { | 427 | { |
428 | KConfig *conf = new KConfig( getFileName() ); | 428 | KConfig *conf = new KConfig( getFileName() ); |
429 | conf->setGroup( "SMTP Account" ); | 429 | conf->setGroup( "SMTP Account" ); |
430 | accountName = conf->readEntry( "Account" ); | 430 | accountName = conf->readEntry( "Account" ); |
431 | server = conf->readEntry( "Server" ); | 431 | server = conf->readEntry( "Server" ); |
432 | port = conf->readEntry( "Port" ); | 432 | port = conf->readEntry( "Port" ); |
433 | ssl = conf->readBoolEntry( "SSL" ); | 433 | ssl = conf->readBoolEntry( "SSL" ); |
434 | connectionType = conf->readNumEntry( "ConnectionType" ); | 434 | connectionType = conf->readNumEntry( "ConnectionType" ); |
435 | login = conf->readBoolEntry( "Login" ); | 435 | login = conf->readBoolEntry( "Login" ); |
436 | user = conf->readEntry( "User" ); | 436 | user = conf->readEntry( "User" ); |
437 | signature = conf->readEntry( "SigFile" ); | 437 | signature = conf->readEntry( "SigFile" ); |
438 | setPasswordList( conf->readListEntry( "FolderHistory")); | 438 | setPasswordList( conf->readListEntry( "FolderHistory")); |
439 | delete conf; | 439 | delete conf; |
440 | } | 440 | } |
441 | 441 | ||
442 | void SMTPaccount::save() | 442 | void SMTPaccount::save() |
443 | { | 443 | { |
444 | Settings::checkDirectory(); | 444 | Settings::checkDirectory(); |
445 | 445 | ||
446 | KConfig *conf = new KConfig( getFileName() ); | 446 | KConfig *conf = new KConfig( getFileName() ); |
447 | conf->setGroup( "SMTP Account" ); | 447 | conf->setGroup( "SMTP Account" ); |
448 | conf->writeEntry( "Account", accountName ); | 448 | conf->writeEntry( "Account", accountName ); |
449 | conf->writeEntry( "Server", server ); | 449 | conf->writeEntry( "Server", server ); |
450 | conf->writeEntry( "Port", port ); | 450 | conf->writeEntry( "Port", port ); |
451 | conf->writeEntry( "SSL", ssl ); | 451 | conf->writeEntry( "SSL", ssl ); |
452 | conf->writeEntry( "ConnectionType", connectionType ); | 452 | conf->writeEntry( "ConnectionType", connectionType ); |
453 | conf->writeEntry( "Login", login ); | 453 | conf->writeEntry( "Login", login ); |
454 | conf->writeEntry( "User", user ); | 454 | conf->writeEntry( "User", user ); |