2 This file is part of kdepim.
4 Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include "scalixkmailchanges.h"
24 #include "scalixconfig.h"
25 #include "kmailchanges.h"
31 class ScalixCustomWriter
: public CreateDisconnectedImapAccount::CustomWriter
33 void writeFolder( KConfig
&c
, int id
)
35 KConfigGroup g
= c
.group( "IMAP Resource" );
36 g
.writeEntry( "TheIMAPResourceAccount", id
);
37 g
.writeEntry( "TheIMAPResourceFolderParent", QString(".%1.directory/INBOX").arg( id
) );
38 g
.writeEntry( "HideGroupwareFolders", false );
40 void writeIds( int, int ) {}
43 void createKMailChanges( KConfigPropagator::Change::List
& changes
)
45 KConfigPropagator::ChangeConfig
*c
= new KConfigPropagator::ChangeConfig
;
47 c
->group
= "Groupware";
52 c
= new KConfigPropagator::ChangeConfig
;
54 c
->group
= "Groupware";
55 c
->name
= "AutoAccept";
59 c
= new KConfigPropagator::ChangeConfig
;
61 c
->group
= "Groupware";
62 c
->name
= "AutoDeclConflict";
66 c
= new KConfigPropagator::ChangeConfig
;
68 c
->group
= "Groupware";
69 c
->name
= "LegacyMangleFromToHeaders";
73 c
= new KConfigPropagator::ChangeConfig
;
75 c
->group
= "Groupware";
76 c
->name
= "LegacyBodyInvites";
80 c
= new KConfigPropagator::ChangeConfig
;
82 c
->group
= "IMAP Resource";
87 c
= new KConfigPropagator::ChangeConfig
;
89 c
->group
= "IMAP Resource";
90 c
->name
= "TheIMAPResourceEnabled";
94 c
= new KConfigPropagator::ChangeConfig
;
96 c
->group
= "IMAP Resource";
97 c
->name
= "TheIMAPResourceStorageFormat";
98 c
->value
= "IcalVcard";
101 c
= new KConfigPropagator::ChangeConfig
;
103 c
->group
= "IMAP Resource";
104 c
->name
= "Folder Language";
108 // Don't show the account wizard as we created an account already
109 c
= new KConfigPropagator::ChangeConfig
;
111 c
->group
= "AccountWizard";
112 c
->name
= "ShowOnStartup";
116 CreateDisconnectedImapAccount
*account
=
117 new CreateDisconnectedImapAccount( i18n("Scalix Server") );
119 account
->setServer( ScalixConfig::self()->server() );
120 account
->setUser( ScalixConfig::self()->user() );
121 account
->setPassword( ScalixConfig::self()->password() );
122 account
->setRealName( ScalixConfig::self()->realName() );
123 account
->setEmail( ScalixConfig::self()->eMail() );
124 if ( ScalixConfig::self()->security() == ScalixConfig::None
)
125 account
->setPort( 143 );
127 account
->setPort( 993 );
129 account
->enableSieve( false );
130 account
->enableSavePassword( ScalixConfig::self()->savePassword() );
132 switch ( ScalixConfig::self()->security() ) {
133 case ScalixConfig::None
:
134 account
->setEncryption( CreateImapAccount::None
);
136 case ScalixConfig::TLS
:
137 account
->setEncryption( CreateImapAccount::TLS
);
139 case ScalixConfig::SSL
:
140 account
->setEncryption( CreateImapAccount::SSL
);
144 switch ( ScalixConfig::self()->authentication() ) {
145 case ScalixConfig::Password
:
146 account
->setAuthentication( CreateImapAccount::NONE
);
148 case ScalixConfig::NTLM_SPA
:
149 account
->setAuthentication( CreateImapAccount::NTLM_SPA
);
151 case ScalixConfig::GSSAPI
:
152 account
->setAuthentication( CreateImapAccount::GSSAPI
);
154 case ScalixConfig::DIGEST_MD5
:
155 account
->setAuthentication( CreateImapAccount::DIGEST_MD5
);
157 case ScalixConfig::CRAM_MD5
:
158 account
->setAuthentication( CreateImapAccount::CRAM_MD5
);
162 account
->setAuthenticationSend( CreateDisconnectedImapAccount::PLAIN
);
163 account
->setSmtpPort( 465 );
164 account
->setDefaultDomain( ScalixConfig::self()->server() );
165 account
->enableLocalSubscription( false );
166 account
->setGroupwareType( CreateDisconnectedImapAccount::GroupwareScalix
);
168 account
->setCustomWriter( new ScalixCustomWriter
);
170 changes
.append( account
);