1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
/*
This file is part of tdepim.
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2004 Daniel Molkentin <molkentin@kde.org>
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kolabwizard.h"
#include "kolabconfig.h"
#include "kolabkmailchanges.h"
#include "kresources/kolab/kcal/resourcekolab.h"
#include "kresources/kolab/kabc/resourcekolab.h"
#include "kresources/kolab/knotes/resourcekolab.h"
#include <libkcal/resourcecalendar.h>
#include <kabc/resource.h>
#include <klineedit.h>
#include <klocale.h>
#include <tqcheckbox.h>
#include <tqhbuttongroup.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqradiobutton.h>
#include <tqwhatsthis.h>
class SetupLDAPSearchAccount : public KConfigPropagator::Change
{
public:
SetupLDAPSearchAccount()
: KConfigPropagator::Change( i18n("Setup LDAP Search Account") )
{
}
void apply()
{
const TQString host = KolabConfig::self()->server();
// Figure out the basedn
TQString basedn = host;
// If the user gave a full email address, the domain name
// of that overrides the server name for the ldap dn
const TQString user = KolabConfig::self()->user();
int pos = user.find( "@" );
if ( pos > 0 ) {
const TQString h = user.mid( pos+1 );
if ( !h.isEmpty() )
// The user did type in a domain on the email address. Use that
basedn = h;
}
{ // while we're here, write default domain
KConfig c( "kmailrc" );
c.setGroup( "General" );
c.writeEntry( "Default domain", basedn );
}
basedn.replace(".",",dc=");
basedn.prepend("dc=");
// Set the changes
KConfig c( "kabldaprc" );
c.setGroup( "LDAP" );
bool hasMyServer = false;
uint selHosts = c.readNumEntry("NumSelectedHosts", 0);
for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i )
if ( c.readEntry( TQString("SelectedHost%1").tqarg(i) ) == host )
hasMyServer = true;
if ( !hasMyServer ) {
c.writeEntry( "NumSelectedHosts", selHosts + 1 );
c.writeEntry( TQString("SelectedHost%1").tqarg(selHosts), host);
c.writeEntry( TQString("SelectedBase%1").tqarg(selHosts), basedn);
c.writeEntry( TQString("SelectedPort%1").tqarg(selHosts), "389");
}
}
};
class CreateCalendarImapResource : public KConfigPropagator::Change
{
public:
CreateCalendarImapResource()
: KConfigPropagator::Change( i18n("Create Calendar IMAP Resource") )
{
}
void apply()
{
KCal::CalendarResourceManager m( "calendar" );
m.readConfig();
KCal::ResourceKolab *r = new KCal::ResourceKolab( 0 );
r->setResourceName( i18n("Kolab Server") );
m.add( r );
m.setStandardResource( r );
m.writeConfig();
}
};
class CreateContactImapResource : public KConfigPropagator::Change
{
public:
CreateContactImapResource()
: KConfigPropagator::Change( i18n("Create Contact IMAP Resource") )
{
}
void apply()
{
KRES::Manager<KABC::Resource> m( "contact" );
m.readConfig();
KABC::ResourceKolab *r = new KABC::ResourceKolab( 0 );
r->setResourceName( i18n("Kolab Server") );
m.add( r );
m.setStandardResource( r );
m.writeConfig();
}
};
class CreateNotesImapResource : public KConfigPropagator::Change
{
public:
CreateNotesImapResource()
: KConfigPropagator::Change( i18n("Create Notes IMAP Resource") )
{
}
void apply()
{
KRES::Manager<ResourceNotes> m( "notes" );
m.readConfig();
Kolab::ResourceKolab *r = new Kolab::ResourceKolab( 0 );
r->setResourceName( i18n("Kolab Server") );
m.add( r );
m.setStandardResource( r );
m.writeConfig();
}
};
class KolabPropagator : public KConfigPropagator
{
public:
KolabPropagator()
: KConfigPropagator( KolabConfig::self(), "kolab.kcfg" )
{
}
protected:
void addKorganizerChanges( Change::List &changes )
{
KURL freeBusyBaseUrl;
// usrWriteConfig() is called first, so kolab1Legacy is correct
if ( KolabConfig::self()->kolab1Legacy() ) {
freeBusyBaseUrl = "webdavs://" + KolabConfig::self()->server() +
"/freebusy/";
ChangeConfig *c = new ChangeConfig;
c->file = "korganizerrc";
c->group = "FreeBusy";
c->name = "FreeBusyPublishUrl";
TQString user = KolabConfig::self()->user();
// We now use the full email address in the freebusy URL
//int pos = user.find( "@" );
//if ( pos > 0 ) user = user.left( pos );
KURL publishURL = freeBusyBaseUrl;
publishURL.addPath( user + ".ifb" ); // this encodes the '@' in the username
c->value = publishURL.url();
changes.append( c );
} else {
// Kolab2: only need FreeBusyRetrieveUrl
// "Uploading" is done by triggering a server-side script with an HTTP GET
// (done by kmail)
freeBusyBaseUrl = "https://" + KolabConfig::self()->server() +
"/freebusy/";
}
ChangeConfig *c = new ChangeConfig;
c->file = "korganizerrc";
c->group = "FreeBusy";
c->name = "FreeBusyRetrieveUrl";
c->value = freeBusyBaseUrl.url();
changes.append( c );
// Use full email address for retrieval of free/busy lists
c = new ChangeConfig;
c->file = "korganizerrc";
c->group = "FreeBusy";
c->name = "FreeBusyFullDomainRetrieval";
c->value = "true";
changes.append( c );
c = new ChangeConfig;
c->file = "korganizerrc";
c->group = "Group Scheduling";
c->name = "Use Groupware Communication";
c->value = "true";
changes.append( c );
// Use identity "from control center", i.e. from emaildefaults
c = new ChangeConfig;
c->file = "korganizerrc";
c->group = "Personal Settings";
c->name = "Use Control Center Email";
c->value = "true";
changes.append( c );
}
virtual void addCustomChanges( Change::List &changes )
{
addKorganizerChanges( changes );
// KMail cruft has been outsourced to kolabkmailchanges.cpp
createKMailChanges( changes );
changes.append( new SetupLDAPSearchAccount );
KCal::CalendarResourceManager m( "calendar" );
m.readConfig();
KCal::CalendarResourceManager::Iterator it;
for ( it = m.begin(); it != m.end(); ++it ) {
if ( (*it)->type() == "imap" ) break;
}
if ( it == m.end() ) {
changes.append( new CreateCalendarImapResource );
changes.append( new CreateContactImapResource );
changes.append( new CreateNotesImapResource );
}
}
};
KolabWizard::KolabWizard() : KConfigWizard( new KolabPropagator )
{
TQFrame *page = createWizardPage( i18n("Kolab Server") );
TQGridLayout *topLayout = new TQGridLayout( page );
topLayout->setSpacing( spacingHint() );
TQLabel *label = new TQLabel( i18n("Server name:"), page );
topLayout->addWidget( label, 0, 0 );
mServerEdit = new KLineEdit( page );
topLayout->addWidget( mServerEdit, 0, 1 );
label = new TQLabel( i18n("Email address:"), page );
topLayout->addWidget( label, 1, 0 );
mUserEdit = new KLineEdit( page );
topLayout->addWidget( mUserEdit, 1, 1 );
TQWhatsThis::add(mUserEdit, i18n("Your email address on the Kolab Server. "
"Format: <i>name@example.net</i>"));
label = new TQLabel( i18n("Real name:"), page );
topLayout->addWidget( label, 2, 0 );
mRealNameEdit = new KLineEdit( page );
topLayout->addWidget( mRealNameEdit, 2, 1 );
label = new TQLabel( i18n("Password:"), page );
topLayout->addWidget( label, 3, 0 );
mPasswordEdit = new KLineEdit( page );
mPasswordEdit->setEchoMode( KLineEdit::Password );
topLayout->addWidget( mPasswordEdit, 3, 1 );
mSavePasswordCheck = new TQCheckBox( i18n("Save password"), page );
topLayout->addMultiCellWidget( mSavePasswordCheck, 4, 4, 0, 1 );
topLayout->setRowStretch( 4, 1 );
mUseOnlineForNonGroupwareCheck = new TQCheckBox( i18n("Use an online IMAP account for non-groupware folders"), page );
topLayout->addMultiCellWidget( mUseOnlineForNonGroupwareCheck, 5, 5, 0, 1 );
topLayout->setRowStretch( 5, 1 );
TQButtonGroup *bg = new TQHButtonGroup(i18n("Server Version"), page );
TQWhatsThis::add( bg, i18n("Choose the version of the Kolab Server you are using.") );
mKolab1 = new TQRadioButton( i18n ( "Kolab 1" ), bg );
mKolab2 = new TQRadioButton( i18n ( "Kolab 2" ), bg );
topLayout->addMultiCellWidget( bg, 6, 6, 0, 1 );
setInitialSize( TQSize( 600, 300 ) );
}
KolabWizard::~KolabWizard()
{
}
TQString KolabWizard::validate()
{
if( mServerEdit->text().isEmpty() ||
mUserEdit->text().isEmpty() ||
mRealNameEdit->text().isEmpty() ||
mPasswordEdit->text().isEmpty() )
return i18n( "Please fill in all fields." );
return TQString();
}
void KolabWizard::usrReadConfig()
{
mServerEdit->setText( KolabConfig::self()->server() );
mUserEdit->setText( KolabConfig::self()->user() );
mRealNameEdit->setText( KolabConfig::self()->realName() );
mPasswordEdit->setText( KolabConfig::self()->password() );
mSavePasswordCheck->setChecked( KolabConfig::self()->savePassword() );
mKolab1->setChecked( KolabConfig::self()->kolab1Legacy() );
mKolab2->setChecked( !KolabConfig::self()->kolab1Legacy() );
mUseOnlineForNonGroupwareCheck->setChecked( KolabConfig::self()->useOnlineForNonGroupware() );
}
void KolabWizard::usrWriteConfig()
{
KolabConfig::self()->setServer( mServerEdit->text() );
KolabConfig::self()->setUser( mUserEdit->text() );
KolabConfig::self()->setRealName( mRealNameEdit->text() );
KolabConfig::self()->setPassword( mPasswordEdit->text() );
KolabConfig::self()->setSavePassword( mSavePasswordCheck->isChecked() );
KolabConfig::self()->setKolab1Legacy( mKolab1->isChecked() );
KolabConfig::self()->setUseOnlineForNonGroupware( mUseOnlineForNonGroupwareCheck->isChecked() );
}
|