Index: trunk/kdepim/wizards/kolabkmailchanges.cpp =================================================================== --- trunk/kdepim/wizards/kolabkmailchanges.cpp (revision 378239) +++ trunk/kdepim/wizards/kolabkmailchanges.cpp (revision 378240) @@ -1,130 +1,131 @@ /* This file is part of kdepim. Copyright (c) 2004 Bo Thorsen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "kolabkmailchanges.h" #include "kolabconfig.h" #include "kmailchanges.h" #include #include #include class KolabCustomWriter : public CreateDisconnectedImapAccount::CustomWriter { void writeFolder( KConfig &c, int id ) { c.setGroup( "IMAP Resource" ); c.writeEntry( "TheIMAPResourceAccount", id ); c.writeEntry( "TheIMAPResourceFolderParent", QString(".%1.directory/INBOX").arg( id ) ); } void writeIds( int, int ) {} }; void createKMailChanges( KConfigPropagator::Change::List& changes ) { KConfigPropagator::ChangeConfig *c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "Groupware"; c->name = "Enabled"; c->value = "true"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "Groupware"; c->name = "AutoAccept"; c->value = "false"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "Groupware"; c->name = "AutoDeclConflict"; c->value = "false"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "Groupware"; c->name = "LegacyMangleFromToHeaders"; c->value = "true"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "Groupware"; c->name = "LegacyBodyInvites"; c->value = "true"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "IMAP Resource"; c->name = "Enabled"; c->value = "true"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "IMAP Resource"; c->name = "TheIMAPResourceEnabled"; c->value = "true"; changes.append( c ); c = new KConfigPropagator::ChangeConfig; c->file = "kmailrc"; c->group = "IMAP Resource"; c->name = "Folder Language"; c->value = "0"; // TODO: Fix the language changes.append( c ); CreateDisconnectedImapAccount *account = new CreateDisconnectedImapAccount( i18n("Kolab Server") ); QString email; const QString server = KolabConfig::self()->server(); QString user = KolabConfig::self()->user(); int pos = user.find( "@" ); // with kolab the userid _is_ the full email if ( pos > 0 ) // The user typed in a full email address. Assume it's correct email = user; else // Construct the email address. And use it for the username also user = email = user+"@"+KolabConfig::self()->server(); account->setServer( server ); account->setUser( user ); account->setPassword( KolabConfig::self()->password() ); account->setRealName( KolabConfig::self()->realName() ); account->setEmail( email ); account->enableSieve( true ); + account->setSieveVacationFileName( "kolab-vacation.siv" ); account->enableSavePassword( KolabConfig::self()->savePassword() ); account->setEncryption( CreateDisconnectedImapAccount::SSL ); account->setAuthenticationSend( CreateDisconnectedImapAccount::PLAIN ); account->setSmtpPort( 465 ); account->setCustomWriter( new KolabCustomWriter ); changes.append( account ); } Index: trunk/kdepim/wizards/kmailchanges.h =================================================================== --- trunk/kdepim/wizards/kmailchanges.h (revision 378239) +++ trunk/kdepim/wizards/kmailchanges.h (revision 378240) @@ -1,97 +1,99 @@ /* This file is part of kdepim. Copyright (c) 2004 Bo Thorsen Copyright (c) 2004 Cornelius Schumacher This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef KMAILCHANGES_H #define KMAILCHANGES_H #include #include class CreateDisconnectedImapAccount : public KConfigPropagator::Change { public: class CustomWriter { public: virtual void writeFolder( KConfig &, int folderId ) = 0; virtual void writeIds( int accountId, int transportId ) = 0; }; - + CreateDisconnectedImapAccount( const QString &accountName ); ~CreateDisconnectedImapAccount(); void apply(); void setServer( const QString & ); void setUser( const QString & ); void setPassword( const QString & ); void setRealName( const QString & ); /** Set email. Default is "user@server". */ void setEmail( const QString & ); void enableSieve( bool ); + void setSieveVacationFileName( const QString& ); void enableSavePassword( bool ); enum Encryption { None, SSL, TLS }; void setEncryption( Encryption ); enum Authentication { PLAIN, LOGIN }; void setAuthenticationSend( Authentication ); void setSmtpPort( int ); void setExistingAccountId( int ); void setExistingTransportId( int ); /** Set custom writer. CreateDisconnectedImapAccount takes ownerhsip of the object. */ void setCustomWriter( CustomWriter * ); private: QString mAccountName; QString mServer; QString mUser; QString mPassword; QString mRealName; QString mEmail; + QString mSieveVacationFileName; bool mEnableSieve; bool mEnableSavePassword; Encryption mEncryption; Authentication mAuthenticationSend; int mSmtpPort; int mExistingAccountId; int mExistingTransportId; CustomWriter *mCustomWriter; }; #endif Index: trunk/kdepim/wizards/kmailchanges.cpp =================================================================== --- trunk/kdepim/wizards/kmailchanges.cpp (revision 378239) +++ trunk/kdepim/wizards/kmailchanges.cpp (revision 378240) @@ -1,214 +1,220 @@ /* This file is part of kdepim. Copyright (c) 2004 Bo Thorsen Copyright (c) 2004 Cornelius Schumacher This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "kmailchanges.h" #include #include #include #include #include #include #include #include CreateDisconnectedImapAccount::CreateDisconnectedImapAccount( const QString &accountName ) : KConfigPropagator::Change( i18n("Create Disconnected IMAP Account for KMail") ), mAccountName( accountName ), mEnableSieve( false ), mEnableSavePassword( true ), mEncryption( None ), mAuthenticationSend( PLAIN ), mSmtpPort( 25 ), mExistingAccountId( -1 ), mExistingTransportId( -1 ), mCustomWriter( 0 ) { } CreateDisconnectedImapAccount::~CreateDisconnectedImapAccount() { delete mCustomWriter; } void CreateDisconnectedImapAccount::setServer( const QString &s ) { mServer = s; } void CreateDisconnectedImapAccount::setUser( const QString &s ) { mUser = s; } void CreateDisconnectedImapAccount::setPassword( const QString &s ) { mPassword = s; } void CreateDisconnectedImapAccount::setRealName( const QString &s ) { mRealName = s; } void CreateDisconnectedImapAccount::setEmail( const QString &s ) { mEmail = s; } void CreateDisconnectedImapAccount::enableSieve( bool b ) { mEnableSieve = b; } +void CreateDisconnectedImapAccount::setSieveVacationFileName( const QString& f ) +{ + mSieveVacationFileName = f; +} + void CreateDisconnectedImapAccount::enableSavePassword( bool b ) { mEnableSavePassword = b; } void CreateDisconnectedImapAccount::setEncryption( CreateDisconnectedImapAccount::Encryption e ) { mEncryption = e; } void CreateDisconnectedImapAccount::setAuthenticationSend( CreateDisconnectedImapAccount::Authentication a ) { mAuthenticationSend = a; } void CreateDisconnectedImapAccount::setSmtpPort( int port ) { mSmtpPort = port; } void CreateDisconnectedImapAccount::setExistingAccountId( int id ) { mExistingAccountId = id; } void CreateDisconnectedImapAccount::setExistingTransportId( int id ) { mExistingTransportId = id; } void CreateDisconnectedImapAccount::setCustomWriter( CreateDisconnectedImapAccount::CustomWriter *writer ) { mCustomWriter = writer; } void CreateDisconnectedImapAccount::apply() { if ( mEmail.isEmpty() ) mEmail = mUser + "@" + mServer; KConfig c( "kmailrc" ); c.setGroup( "General" ); int accountId; if ( mExistingAccountId < 0 ) { uint accCnt = c.readNumEntry( "accounts", 0 ); accountId = accCnt + 1; c.writeEntry( "accounts", accountId ); } else { accountId = mExistingAccountId; } int transportId; if ( mExistingTransportId < 0 ) { uint transCnt = c.readNumEntry( "transports", 0 ); transportId = transCnt + 1; c.writeEntry( "transports", transportId ); } else { transportId = mExistingTransportId; } c.setGroup( QString("Account %1").arg( accountId ) ); int uid; if ( mExistingAccountId < 0 ) { uid = kapp->random(); c.writeEntry( "Folder", uid ); } else { uid = c.readNumEntry( "Folder" ); } c.writeEntry( "Id", uid ); c.writeEntry( "Type", "cachedimap"); c.writeEntry( "auth", "*"); c.writeEntry( "Name", mAccountName ); c.writeEntry( "host", mServer ); c.writeEntry( "port", "993" ); c.writeEntry( "login", mUser ); c.writeEntry( "sieve-support", mEnableSieve ? "true" : "false" ); + c.writeEntry( "sieve-vacation-filename", mSieveVacationFileName ); if ( mEncryption == SSL ) { c.writeEntry( "use-ssl", true ); } else if ( mEncryption == TLS ) { c.writeEntry( "use-tls", true ); } c.setGroup( QString("Folder-%1").arg( uid ) ); c.writeEntry( "isOpen", true ); if ( mEnableSavePassword ) { c.writeEntry( "pass", KStringHandler::obscure( mPassword ) ); c.writeEntry( "store-passwd", true ); } c.setGroup( QString("Transport %1").arg( transportId ) ); c.writeEntry( "name", mAccountName ); c.writeEntry( "host", mServer ); c.writeEntry( "type", "smtp" ); c.writeEntry( "port", mSmtpPort ); if ( mEncryption == SSL ) { c.writeEntry( "encryption", "SSL" ); } else if ( mEncryption == TLS ) { c.writeEntry( "encryption", "TLS" ); } c.writeEntry( "auth", true ); if ( mAuthenticationSend == PLAIN ) { c.writeEntry( "authtype", "PLAIN" ); } else if ( mAuthenticationSend == LOGIN ) { c.writeEntry( "authtype", "LOGIN" ); } c.writeEntry( "user", mUser ); if ( mEnableSavePassword ) { c.writeEntry( "pass", KStringHandler::obscure( mPassword ) ); c.writeEntry( "storepass", "true" ); } // Write email in "default kcontrol settings", used by IdentityManager // if it has to create a default identity. KEMailSettings es; es.setSetting( KEMailSettings::RealName, mRealName ); es.setSetting( KEMailSettings::EmailAddress, mEmail ); KPIM::IdentityManager identityManager; if ( !identityManager.allEmails().contains( mEmail ) ) { // Not sure how to name the identity. First one is "Default", next one mAccountName, but then... KPIM::Identity& identity = identityManager.newFromScratch( mAccountName ); identity.setFullName( mRealName ); identity.setEmailAddr( mEmail ); identityManager.commit(); } if ( mCustomWriter ) { mCustomWriter->writeFolder( c, uid ); mCustomWriter->writeIds( accountId, transportId ); } }