-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 83 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.h | 3 |
2 files changed, 63 insertions, 23 deletions
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index f996d9c..766eba0 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp @@ -1,11 +1,11 @@ #include <stdlib.h> #include <qdir.h> //#include <opie2/odebug.h> -#include <qpe/config.h> +#include <kconfig.h> #include <kstandarddirs.h> #include "settings.h" //#include "defines.h" #define IMAP_PORT "143" @@ -110,20 +110,47 @@ Account::Account() { accountName = "changeMe"; type = MAILLIB::A_UNDEFINED; ssl = false; connectionType = 1; offline = false; + maxMailSize = 0; + lastFetch; + leaveOnServer = false; } void Account::remove() { QFile file( getFileName() ); file.remove(); } +void Account::setPasswordList(const QStringList &str) +{ + password = ""; + int i; + for ( i = 0; i < str.count() ; ++i ) { + QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); + password.append( c ); + } + //qDebug("password %s ", password.latin1()); +} +QStringList Account::getPasswordList() +{ + int i; + int len = password.length(); + QStringList str; + + for ( i = 0; i < len ; ++i ) { + int val = password.at(i).unicode()*(len-(i%3))+131; + str.append( QString::number( val ) ); + // qDebug("append %s ", str[i].latin1()); + } + return str; +} + IMAPaccount::IMAPaccount() : Account() { file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; @@ -157,61 +184,65 @@ QString IMAPaccount::getUniqueFileName() return unique; } void IMAPaccount::read() { - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "IMAP Account" ); accountName = conf->readEntry( "Account","" ); if (accountName.isNull()) accountName = ""; server = conf->readEntry( "Server","" ); if (server.isNull()) server=""; port = conf->readEntry( "Port","" ); if (port.isNull()) port="143"; connectionType = conf->readNumEntry( "ConnectionType" ); ssl = conf->readBoolEntry( "SSL",false ); user = conf->readEntry( "User","" ); if (user.isNull()) user = ""; - password = conf->readEntryCrypt( "Password","" ); + //password = conf->readEntryCrypt( "Password","" ); + setPasswordList( conf->readListEntry( "FolderHistory")); if (password.isNull()) password = ""; prefix = conf->readEntry("MailPrefix",""); if (prefix.isNull()) prefix = ""; offline = conf->readBoolEntry("Offline",false); localFolder = conf->readEntry( "LocalFolder" ); maxMailSize = conf->readNumEntry( "MaxSize",0 ); int lf = conf->readNumEntry( "LastFetch",0 ); QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); + qDebug("reading last fetch: %d ", lf); + if ( lf < 0 ) lf = 0; lastFetch = dt.addSecs( lf ); delete conf; } void IMAPaccount::save() { qDebug("saving %s ",getFileName().latin1() ); Settings::checkDirectory(); - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "IMAP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); - conf->writeEntryCrypt( "Password", password ); + //conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "FolderHistory",getPasswordList() ); conf->writeEntry( "MailPrefix",prefix); conf->writeEntry( "Offline",offline); conf->writeEntry( "LocalFolder", localFolder ); conf->writeEntry( "MaxSize", maxMailSize ); QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); int lf = dt.secsTo ( lastFetch ); conf->writeEntry( "LastFetch", lf ); conf->writeEntry( "LeaveOnServer", leaveOnServer); - conf->write(); + conf->sync(); delete conf; } QString IMAPaccount::getFileName() { @@ -254,21 +285,22 @@ QString POP3account::getUniqueFileName() return unique; } void POP3account::read() { - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName()); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); connectionType = conf->readNumEntry( "ConnectionType" ); user = conf->readEntry( "User" ); - password = conf->readEntryCrypt( "Password" ); + //password = conf->readEntryCrypt( "Password" ); + setPasswordList( conf->readListEntry( "FolderHistory")); offline = conf->readBoolEntry("Offline",false); localFolder = conf->readEntry( "LocalFolder" ); maxMailSize = conf->readNumEntry( "MaxSize",0 ); int lf = conf->readNumEntry( "LastFetch",0 ); QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); @@ -277,29 +309,30 @@ void POP3account::read() } void POP3account::save() { Settings::checkDirectory(); - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "POP3 Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); - conf->writeEntryCrypt( "Password", password ); + //conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "FolderHistory",getPasswordList() ); conf->writeEntry( "Offline",offline); conf->writeEntry( "LocalFolder", localFolder ); conf->writeEntry( "MaxSize", maxMailSize ); QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); int lf = dt.secsTo ( lastFetch ); conf->writeEntry( "LastFetch", lf ); conf->writeEntry( "LeaveOnServer", leaveOnServer); - conf->write(); + conf->sync(); delete conf; } QString POP3account::getFileName() { @@ -347,40 +380,42 @@ QString SMTPaccount::getUniqueFileName() return unique; } void SMTPaccount::read() { - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); connectionType = conf->readNumEntry( "ConnectionType" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); - password = conf->readEntryCrypt( "Password" ); + //password = conf->readEntryCrypt( "Password" ); + setPasswordList( conf->readListEntry( "FolderHistory")); delete conf; } void SMTPaccount::save() { Settings::checkDirectory(); - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "SMTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); - conf->writeEntryCrypt( "Password", password ); - conf->write(); + //conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "FolderHistory",getPasswordList() ); + conf->sync(); delete conf; } QString SMTPaccount::getFileName() { @@ -423,40 +458,42 @@ QString NNTPaccount::getUniqueFileName() return unique; } void NNTPaccount::read() { - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "NNTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); - password = conf->readEntryCrypt( "Password" ); - subscribedGroups = conf->readListEntry( "Subscribed", ',' ); + //password = conf->readEntryCrypt( "Password" ); + setPasswordList( conf->readListEntry( "FolderHistory")); + subscribedGroups = conf->readListEntry( "Subscribed"); delete conf; } void NNTPaccount::save() { Settings::checkDirectory(); - Config *conf = new Config( getFileName(), Config::File ); + KConfig *conf = new KConfig( getFileName() ); conf->setGroup( "NNTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); - conf->writeEntryCrypt( "Password", password ); - conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); - conf->write(); + //conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "FolderHistory",getPasswordList() ); + conf->writeEntry( "Subscribed" , subscribedGroups ); + conf->sync(); delete conf; } QString NNTPaccount::getFileName() { diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h index 85b817c..61051dd 100644 --- a/kmicromail/libmailwrapper/settings.h +++ b/kmicromail/libmailwrapper/settings.h @@ -34,12 +34,15 @@ public: void setUser(const QString&str){ user = str; } const QString&getUser()const{ return user; } void setPassword(const QString&str) { password = str; } const QString&getPassword()const { return password; } + void setPasswordList(const QStringList &str); + QStringList getPasswordList(); + void setSSL( bool b ) { ssl = b; } bool getSSL() { return ssl; } void setConnectionType( int x ) { connectionType = x; } int ConnectionType() { return connectionType; } |