backport the last commits by tmcguire at his request:
[kdepim.git] / wizards / scalixkmailchanges.cpp
blobbda2e62080f112d04ba5735e0dc6bc8f512e1ca8
1 /*
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"
27 #include <klocale.h>
28 #include <kconfig.h>
29 #include <kdebug.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;
46 c->file = "kmailrc";
47 c->group = "Groupware";
48 c->name = "Enabled";
49 c->value = "true";
50 changes.append( c );
52 c = new KConfigPropagator::ChangeConfig;
53 c->file = "kmailrc";
54 c->group = "Groupware";
55 c->name = "AutoAccept";
56 c->value = "false";
57 changes.append( c );
59 c = new KConfigPropagator::ChangeConfig;
60 c->file = "kmailrc";
61 c->group = "Groupware";
62 c->name = "AutoDeclConflict";
63 c->value = "false";
64 changes.append( c );
66 c = new KConfigPropagator::ChangeConfig;
67 c->file = "kmailrc";
68 c->group = "Groupware";
69 c->name = "LegacyMangleFromToHeaders";
70 c->value = "true";
71 changes.append( c );
73 c = new KConfigPropagator::ChangeConfig;
74 c->file = "kmailrc";
75 c->group = "Groupware";
76 c->name = "LegacyBodyInvites";
77 c->value = "true";
78 changes.append( c );
80 c = new KConfigPropagator::ChangeConfig;
81 c->file = "kmailrc";
82 c->group = "IMAP Resource";
83 c->name = "Enabled";
84 c->value = "true";
85 changes.append( c );
87 c = new KConfigPropagator::ChangeConfig;
88 c->file = "kmailrc";
89 c->group = "IMAP Resource";
90 c->name = "TheIMAPResourceEnabled";
91 c->value = "true";
92 changes.append( c );
94 c = new KConfigPropagator::ChangeConfig;
95 c->file = "kmailrc";
96 c->group = "IMAP Resource";
97 c->name = "TheIMAPResourceStorageFormat";
98 c->value = "IcalVcard";
99 changes.append( c );
101 c = new KConfigPropagator::ChangeConfig;
102 c->file = "kmailrc";
103 c->group = "IMAP Resource";
104 c->name = "Folder Language";
105 c->value = "0";
106 changes.append( c );
108 // Don't show the account wizard as we created an account already
109 c = new KConfigPropagator::ChangeConfig;
110 c->file = "kmailrc";
111 c->group = "AccountWizard";
112 c->name = "ShowOnStartup";
113 c->value = "false";
114 changes.append( c );
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 );
126 else
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 );
135 break;
136 case ScalixConfig::TLS:
137 account->setEncryption( CreateImapAccount::TLS );
138 break;
139 case ScalixConfig::SSL:
140 account->setEncryption( CreateImapAccount::SSL );
141 break;
144 switch ( ScalixConfig::self()->authentication() ) {
145 case ScalixConfig::Password:
146 account->setAuthentication( CreateImapAccount::NONE );
147 break;
148 case ScalixConfig::NTLM_SPA:
149 account->setAuthentication( CreateImapAccount::NTLM_SPA );
150 break;
151 case ScalixConfig::GSSAPI:
152 account->setAuthentication( CreateImapAccount::GSSAPI );
153 break;
154 case ScalixConfig::DIGEST_MD5:
155 account->setAuthentication( CreateImapAccount::DIGEST_MD5 );
156 break;
157 case ScalixConfig::CRAM_MD5:
158 account->setAuthentication( CreateImapAccount::CRAM_MD5 );
159 break;
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 );