author | zautrix <zautrix> | 2005-02-03 10:48:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 10:48:05 (UTC) |
commit | fb6753570dc90e936b4e89092554ab012e946a56 (patch) (unidiff) | |
tree | 6d3ae5c866f0bbb99f0b6bc8194d04d2c7681ff9 /kmicromail/libmailwrapper | |
parent | e0fce8c0f108e054cb6e4e4767affd04b398da45 (diff) | |
download | kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.zip kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.tar.gz kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.tar.bz2 |
mail fixes
-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,35 +1,39 @@ | |||
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" ); |
@@ -337,108 +341,148 @@ void POP3account::save() | |||
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; |
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 | |||
@@ -98,64 +98,70 @@ class POP3account : public Account | |||
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 | ||