00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
#ifdef HAVE_CONFIG_H
00035
#include <config.h>
00036
#endif
00037
00038
#include "startupwizard.h"
00039
00040
#include "kmfoldercombobox.h"
00041
#include "configuredialog_p.h"
00042
#include "kmacctmgr.h"
00043
#include "kmcomposewin.h"
00044
#include "kmfoldermgr.h"
00045
#include "kmacctcachedimap.h"
00046
#include "kmfoldercachedimap.h"
00047
#include <libkpimidentities/identity.h>
00048
#include <libkpimidentities/identitymanager.h>
00049
#include "kmtransport.h"
00050
#include "kmsender.h"
00051
#include "kmgroupware.h"
00052
#include "kmkernel.h"
00053
#include "kmailicalifaceimpl.h"
00054
#include "globalsettings.h"
00055
00056
#include <kdebug.h>
00057
#include <klocale.h>
00058
#include <knuminput.h>
00059
#include <kapplication.h>
00060
#include <kconfig.h>
00061
00062
#include <qvbox.h>
00063
#include <qvbuttongroup.h>
00064
#include <qtextbrowser.h>
00065
#include <qwhatsthis.h>
00066
#include <qvalidator.h>
00067
00068 WizardIdentityPage::WizardIdentityPage(
QWidget * parent,
const char * name )
00069 :
QWidget( parent, name )
00070 {
00071
00072 KPIM::IdentityManager *im = kmkernel->identityManager();
00073
if( im->identities().count() > 0 )
00074 mIdentity = im->defaultIdentity().uoid();
00075
else {
00076 mIdentity = im->newFromScratch(
"Kolab Identity" ).uoid();
00077 im->setAsDefault( mIdentity );
00078 }
00079
00080 KPIM::Identity & ident = im->identityForUoid( mIdentity );
00081
00082
QGridLayout *grid =
new QGridLayout(
this, 3, 2, KDialog::marginHint(),
00083 KDialog::spacingHint() );
00084 grid->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00085 grid->setRowStretch( 15, 10 );
00086 grid->setColStretch( 1, 10 );
00087
00088
QLabel *label =
new QLabel( i18n(
"&Your name:"),
this );
00089 QWhatsThis::add( label, i18n(
"Write your name here.") );
00090 grid->addWidget( label, 0, 0 );
00091 nameEdit =
new QLineEdit( ident.fullName(),
this );
00092 nameEdit->setFocus();
00093 label->setBuddy( nameEdit );
00094 grid->addWidget( nameEdit, 0, 1 );
00095
00096 label =
new QLabel( i18n(
"Organi&zation:"),
this );
00097 QWhatsThis::add( label, i18n(
"You can write the company or organization you work for.") );
00098 grid->addWidget( label, 1, 0 );
00099 orgEdit =
new QLineEdit( ident.organization(),
this );
00100 label->setBuddy( orgEdit );
00101 grid->addWidget( orgEdit, 1, 1 );
00102
00103 label =
new QLabel( i18n(
"&Email address:"),
this );
00104 grid->addWidget( label, 2, 0 );
00105 emailEdit =
new QLineEdit( ident.emailAddr(),
this );
00106 label->setBuddy( emailEdit );
00107 grid->addWidget( emailEdit, 2, 1 );
00108 }
00109
00110
void WizardIdentityPage::apply()
const {
00111
00112 KPIM::Identity & ident = identity();
00113 ident.setFullName( nameEdit->text().stripWhiteSpace() );
00114 ident.setOrganization( orgEdit->text().stripWhiteSpace() );
00115 ident.setEmailAddr( emailEdit->text().stripWhiteSpace() );
00116 kmkernel->identityManager()->sort();
00117 kmkernel->identityManager()->commit();
00118 }
00119
00120 KPIM::Identity & WizardIdentityPage::identity()
const {
00121
return kmkernel->identityManager()->identityForUoid( mIdentity );
00122 }
00123
00124 WizardKolabPage::WizardKolabPage(
QWidget * parent,
const char * name )
00125 :
QWidget( parent, name ), mFolder(0), mAccount(0), mTransport( 0 )
00126 {
00127 QGridLayout *grid =
new QGridLayout(
this, 7, 2, KDialog::marginHint(),
00128 KDialog::spacingHint() );
00129 grid->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00130 grid->setRowStretch( 15, 10 );
00131 grid->setColStretch( 1, 10 );
00132
00133 QLabel *label =
new QLabel( i18n(
"&Login:"),
this );
00134 QWhatsThis::add( label, i18n(
"Your Internet Service Provider gave you a <em>user name</em> which is used to authenticate you with their servers. It usually is the first part of your email address (the part before <em>@</em>).") );
00135 grid->addWidget( label, 0, 0 );
00136 loginEdit =
new QLineEdit(
this );
00137 label->setBuddy( loginEdit );
00138 grid->addWidget( loginEdit, 0, 1 );
00139
00140 label =
new QLabel( i18n(
"P&assword:"),
this );
00141 grid->addWidget( label, 1, 0 );
00142 passwordEdit =
new QLineEdit(
this );
00143 passwordEdit->setEchoMode( QLineEdit::Password );
00144 label->setBuddy( passwordEdit );
00145 grid->addWidget( passwordEdit, 1, 1 );
00146
00147 label =
new QLabel( i18n(
"Ho&st:"),
this );
00148 grid->addWidget( label, 2, 0 );
00149 hostEdit =
new QLineEdit(
this );
00150
00151
00152 hostEdit->setValidator(
new QRegExpValidator(
QRegExp(
"[A-Za-z0-9-_:.]*" ), 0 ) );
00153 label->setBuddy( hostEdit );
00154 grid->addWidget( hostEdit, 2, 1 );
00155
00156 storePasswordCheck =
00157
new QCheckBox( i18n(
"Sto&re IMAP password in configuration file"),
this );
00158 storePasswordCheck->setChecked(
true );
00159 grid->addMultiCellWidget( storePasswordCheck, 3, 3, 0, 1 );
00160
00161 excludeCheck =
new QCheckBox( i18n(
"E&xclude from \"Check Mail\""),
this );
00162 grid->addMultiCellWidget( excludeCheck, 4, 4, 0, 1 );
00163
00164 intervalCheck =
new QCheckBox( i18n(
"Enable &interval mail checking"),
this );
00165 intervalCheck->setChecked(
true );
00166 grid->addMultiCellWidget( intervalCheck, 5, 5, 0, 2 );
00167 intervalLabel =
new QLabel( i18n(
"Check inter&val:"),
this );
00168 grid->addWidget( intervalLabel, 6, 0 );
00169 intervalSpin =
new KIntNumInput(
this );
00170 intervalSpin->setRange( 1, 60, 1, FALSE );
00171 intervalSpin->setValue( 1 );
00172 intervalSpin->setSuffix( i18n(
" min" ) );
00173 intervalLabel->setBuddy( intervalSpin );
00174 connect( intervalCheck, SIGNAL(toggled(
bool)), intervalSpin, SLOT(setEnabled(
bool)) );
00175 grid->addWidget( intervalSpin, 6, 1 );
00176 }
00177
00178
void WizardKolabPage::init(
const QString &email )
00179 {
00180
static bool first =
true;
00181
if( !first )
return;
00182 first =
false;
00183
00184
00185 loginEdit->setFocus();
00186
00187
int at = email.find(
'@');
00188
if( at > 1 && email.length() > (uint)at ) {
00189
00190 loginEdit->setText( email );
00191 hostEdit->setText( email.mid( at + 1 ) );
00192 }
00193 }
00194
00195
void WizardKolabPage::apply()
00196 {
00197
00198
if( mAccount == 0 ) {
00199
00200 mAccount = static_cast<KMAcctCachedImap*>
00201 ( kmkernel->acctMgr()->create(
QString(
"cachedimap"),
"Kolab" ) );
00202 mAccount->init();
00203 kmkernel->acctMgr()->add(mAccount);
00204
00205
00206
00207 mAccount->setAuth(
"PLAIN" );
00208 mAccount->setPrefix(
"/" );
00209 mAccount->setUseSSL(
false );
00210 mAccount->setUseTLS(
true );
00211 mAccount->setSieveConfig( KMail::SieveConfig(
true ) );
00212 kmkernel->cleanupImapFolders();
00213 assert( mAccount->folder() );
00214
00215
00216 mAccount->setAutoExpunge(
false );
00217 }
00218
00219 mAccount->setLogin( loginEdit->text().stripWhiteSpace() );
00220 mAccount->setPasswd( passwordEdit->text() );
00221 mAccount->setHost( hostEdit->text().stripWhiteSpace() );
00222 mAccount->setStorePasswd( storePasswordCheck->isChecked() );
00223 mAccount->setCheckExclude( excludeCheck->isChecked() );
00224
00225 kmkernel->acctMgr()->writeConfig(
false );
00226
00227
00228 kdDebug(5006) << mAccount->folder()->name() << endl;
00229
00230
if( mFolder == 0 ) {
00231
KMFolderDir *child = mAccount->folder()->child();
00232
if( child == 0 )
00233 child = mAccount->folder()->createChildFolder();
00234
00235 mFolder = kmkernel->dimapFolderMgr()->
00236 createFolder(
"INBOX",
false, KMFolderTypeCachedImap, child );
00237 static_cast<KMFolderCachedImap*>(mFolder)->setSilentUpload(
true );
00238 }
00239
if ( !mAccount->checkingMail() ) {
00240 mAccount->setCheckingMail(
true );
00241 mAccount->processNewMail(
false );
00242 }
00243
00244
00245
if( mTransport == 0 ) {
00246 mTransport =
new KMTransportInfo();
00247 mTransport->type =
"smtp";
00248 mTransport->name =
"Kolab";
00249 mTransport->port =
"25";
00250 mTransport->encryption =
"TLS";
00251 mTransport->authType =
"PLAIN";
00252 mTransport->auth =
true;
00253 mTransport->precommand =
"";
00254 }
00255
00256 mTransport->host = hostEdit->text().stripWhiteSpace();
00257 mTransport->user = loginEdit->text().stripWhiteSpace();
00258 mTransport->pass = passwordEdit->text();
00259 mTransport->storePass = storePasswordCheck->isChecked();
00260
00261
00262 KConfigGroup general( KMKernel::config(),
"General" );
00263 KConfigGroup composer( KMKernel::config(),
"Composer" );
00264
00265 general.writeEntry(
"transports", 1 );
00266
00267
00268
00269 mTransport->writeConfig(1);
00270
00271
00272 general.writeEntry(
"sendOnCheck",
false );
00273 kmkernel->msgSender()->setSendImmediate(
true );
00274 }
00275
00276
00277 StartupWizard::StartupWizard(
QWidget* parent,
const char* name,
bool modal )
00278 :
QWizard( parent, name, modal ), mGroupwareEnabled(true)
00279 {
00280 addPage( mIntroPage = createIntroPage(), i18n(
"Groupware Functionality for KMail") );
00281 addPage( mIdentityPage = createIdentityPage(), i18n(
"Your Identity") );
00282 addPage( mKolabPage = createKolabPage(), i18n(
"Kolab Groupware Settings") );
00283 addPage( mAccountPage = createAccountPage(), i18n(
"Accounts") );
00284 addPage( mFolderSelectionPage = createFolderSelectionPage(), i18n(
"Folder Selection") );
00285 addPage( mLanguagePage = createLanguagePage(), i18n(
"Folder Language") );
00286 addPage( mFolderCreationPage = createFolderCreationPage(), i18n(
"Folder Creation") );
00287 addPage( mOutroPage = createOutroPage(), i18n(
"Done") );
00288 }
00289
00290
int StartupWizard::language()
const
00291
{
00292
return mLanguageCombo->currentItem();
00293 }
00294
00295
KMFolder* StartupWizard::folder()
const
00296
{
00297
if( groupwareEnabled() && useDefaultKolabSettings() )
00298
return mKolabWidget->folder();
00299
else
00300
return mFolderCombo->getFolder();
00301 }
00302
00303
void StartupWizard::setAppropriatePages()
00304 {
00305 setAppropriate( mKolabPage, groupwareEnabled() && useDefaultKolabSettings() );
00306 setAppropriate( mAccountPage, !groupwareEnabled() || !useDefaultKolabSettings() );
00307 setAppropriate( mLanguagePage, groupwareEnabled() );
00308 setAppropriate( mFolderSelectionPage, groupwareEnabled() && !useDefaultKolabSettings() );
00309 setAppropriate( mFolderCreationPage, groupwareEnabled() );
00310 setAppropriate( mOutroPage, !groupwareEnabled() );
00311 setNextEnabled( mOutroPage,
false);
00312 setFinishEnabled( mOutroPage,
true );
00313 setFinishEnabled( mFolderCreationPage,
true );
00314 }
00315
00316
void StartupWizard::slotGroupwareEnabled(
int i )
00317 {
00318 mGroupwareEnabled = (i == 0);
00319 serverSettings->setEnabled( mGroupwareEnabled );
00320 }
00321
00322
void StartupWizard::slotServerSettings(
int i )
00323 {
00324 mUseDefaultKolabSettings = (i == 0);
00325 }
00326
00327
QWidget* StartupWizard::createIntroPage()
00328 {
00329
QWidget* page =
new QWidget(
this,
"intro_page");
00330
QBoxLayout* top =
new QHBoxLayout( page );
00331
QTextBrowser* text =
new QTextBrowser( page );
00332 text->setText( i18n(
"<b>You do not seem to have any groupware folders "
00333
"configured in KMail.</b><br>"
00334
"This is probably because you are running KMail for the first time, or "
00335
"because you have enabled the groupware functionality for the first time.<br>"
00336
"You now have the choice between disabling the groupware functionality, "
00337
"or leaving it enabled and going through this wizard.<br>"
00338
"If you disable the groupware functionality for now, you can always enable it again from "
00339
"the KMail configure dialog."));
00340 top->
addWidget( text );
00341
00342
QVBox* rightSide =
new QVBox( page );
00343 top->
addWidget( rightSide, 1 );
00344
00345
QButtonGroup* bg =
new QVButtonGroup( i18n(
"Groupware Functions"), rightSide );
00346
00347 (
new QRadioButton( i18n(
"Enable groupware functions"), bg ))->setChecked( TRUE );
00348 (
void)
new QRadioButton( i18n(
"Disable groupware functions"), bg );
00349 connect( bg, SIGNAL( clicked(
int) ),
this, SLOT( slotGroupwareEnabled(
int) ) );
00350
00351 bg = serverSettings =
new QVButtonGroup( i18n(
"Groupware Server Setup"), rightSide );
00352 (
new QRadioButton( i18n(
"Use standard groupware server settings"), bg ))->setChecked(TRUE);
00353 (
void)
new QRadioButton( i18n(
"Advanced server setup"), bg );
00354 connect( bg, SIGNAL( clicked(
int) ),
this, SLOT(slotServerSettings(
int) ) );
00355
00356
00357 slotGroupwareEnabled( 0 );
00358 slotServerSettings( 0 );
00359 setHelpEnabled( page,
false );
00360 setBackEnabled( page,
false );
00361
return page;
00362 }
00363
00364 QWidget* StartupWizard::createIdentityPage()
00365 {
00366 QWidget* page =
new QWidget(
this,
"identity_page" );
00367
QBoxLayout* top =
new QHBoxLayout( page );
00368 QTextBrowser* text =
new QTextBrowser( page );
00369 text->setText( i18n(
"Please set at least your name and email address.") );
00370 top->
addWidget( text );
00371
00372 mIdentityWidget =
new WizardIdentityPage( page,
"identity_page" );
00373 top->
addWidget( mIdentityWidget, 1 );
00374 setHelpEnabled( page,
false );
00375
return page;
00376 }
00377
00378 QWidget* StartupWizard::createKolabPage()
00379 {
00380 QWidget* page =
new QWidget(
this,
"kolabserver_page" );
00381
QBoxLayout* top =
new QHBoxLayout( page );
00382 QTextBrowser* text =
new QTextBrowser( page );
00383 text->setText( i18n(
"If the groupware server is a kolab server with default"
00384
" settings, you only need to set these settings.") );
00385 top->
addWidget( text );
00386
00387 mKolabWidget =
new WizardKolabPage( page,
"kolabserver_page" );
00388 top->
addWidget( mKolabWidget, 1 );
00389 setHelpEnabled( page,
false );
00390
return page;
00391 }
00392
00393 QWidget* StartupWizard::createAccountPage()
00394 {
00395 QWidget* page =
new QWidget(
this,
"account_page");
00396
QBoxLayout* top =
new QHBoxLayout( page );
00397 QTextBrowser* text =
new QTextBrowser( page );
00398 text->setText(i18n(
"If you want, you can create new accounts before going on with"
00399
" groupware configuration."));
00400 top->
addWidget( text );
00401
00402 mAccountWidget =
new NetworkPage( page,
"account_page" );
00403 mAccountWidget->setup();
00404 top->
addWidget( mAccountWidget, 1 );
00405 setHelpEnabled( page,
false );
00406
return page;
00407 }
00408
00409 QWidget* StartupWizard::createLanguagePage()
00410 {
00411 QWidget* page =
new QWidget(
this,
"language_page");
00412
QBoxLayout* top =
new QHBoxLayout( page );
00413 QTextBrowser* text =
new QTextBrowser( page );
00414 text->setText( i18n(
"If you want to make your groupware folders work with other "
00415
"applications, you might want to select a different language "
00416
"than English.<br>"
00417
"If this is not an issue, leave the language as is."));
00418 top->
addWidget( text );
00419
00420 QVBox* rightSide =
new QVBox( page );
00421 top->
addWidget( rightSide, 1 );
00422
00423 mLanguageLabel =
new QLabel( rightSide );
00424
00425 mLanguageCombo =
new QComboBox(
false, rightSide );
00426
00427
QStringList lst;
00428 lst << i18n(
"English") << i18n(
"German") << i18n(
"French") << i18n(
"Dutch");
00429 mLanguageCombo->insertStringList( lst );
00430
00431 setLanguage( 0,
false );
00432 setHelpEnabled( page,
false );
00433
return page;
00434 }
00435
00436 QWidget* StartupWizard::createFolderSelectionPage()
00437 {
00438 QWidget* page =
new QWidget(
this,
"foldersel_page");
00439
QBoxLayout* top =
new QHBoxLayout( page );
00440 QTextBrowser* text =
new QTextBrowser( page );
00441 text->setText(i18n(
"The groupware functionality needs some special folders to store "
00442
"the contents of the calendar, contacts, tasks etc.<br>"
00443
"Please select the folder that the groupware folders should "
00444
"be subfolders of."));
00445 top->
addWidget( text );
00446 mFolderCombo =
new KMFolderComboBox( page );
00447 top->
addWidget( mFolderCombo, 1 );
00448 connect( mFolderCombo, SIGNAL( activated(
int) ),
00449
this, SLOT( slotUpdateParentFolderName() ) );
00450 setHelpEnabled( page,
false );
00451
return page;
00452 }
00453
00454
void StartupWizard::slotUpdateParentFolderName()
00455 {
00456
KMFolder* folder = mFolderCombo->getFolder();
00457
QString fldrName = i18n(
"<unnamed>");
00458
if( folder ) fldrName = folder->name();
00459 mFolderCreationText
00460 ->setText( i18n(
"You have chosen the folder <b>%1</b> as parent of the "
00461
"groupware folders. When pressing the Finish button, "
00462
"those folders will be created if "
00463
"they do not already exist").arg( fldrName ));
00464 }
00465
00466
void StartupWizard::setLanguage(
int language,
bool guessed )
00467 {
00468 mLanguageCombo->setCurrentItem( language );
00469
if( guessed ) {
00470 mLanguageLabel->setText( i18n(
"The folders present indicates that you want to use the selected folder language"));
00471 }
else {
00472 mLanguageLabel->setText( i18n(
"The folder language cannot be guessed, please select a language:"));
00473 }
00474 }
00475
00476 QWidget* StartupWizard::createFolderCreationPage()
00477 {
00478
QHBox* page =
new QHBox(
this,
"foldercre_page");
00479 mFolderCreationText =
new QTextBrowser( page );
00480 slotUpdateParentFolderName();
00481 setFinishEnabled( page,
true );
00482 setNextEnabled( page,
false);
00483 setHelpEnabled( page,
false );
00484
return page;
00485 }
00486
00487 QWidget* StartupWizard::createOutroPage()
00488 {
00489
QHBox* page =
new QHBox(
this,
"outtro_page");
00490 QTextBrowser* text =
new QTextBrowser( page );
00491 text->setText( i18n(
"The groupware functionality has been disabled.") );
00492 setFinishEnabled( page,
true );
00493 setNextEnabled( page,
false);
00494 setHelpEnabled( page,
false );
00495
return page;
00496 }
00497
00498
void StartupWizard::back()
00499 {
00500 QWizard::back();
00501 }
00502
00503
void StartupWizard::next()
00504 {
00505
if( currentPage() == mAccountPage ) {
00506 kdDebug(5006) <<
"AccountPage appropriate: " << appropriate(mAccountPage) << endl;
00507 mAccountWidget->apply();
00508 }
else if( currentPage() == mFolderSelectionPage ) {
00509
00510 guessExistingFolderLanguage();
00511 }
else if( currentPage() == mKolabPage ) {
00512
00513 mKolabWidget->apply();
00514
00515
00516
00517
00518 mFolderCreationText->setText( i18n(
"You have chosen to use standard kolab settings.\nPress Finish to proceed.") );
00519
00520 }
else if( currentPage() == mIdentityPage ) {
00521 mIdentityWidget->apply();
00522 mKolabWidget->init( userIdentity().emailAddr() );
00523 }
00524
00525
00526 setAppropriatePages();
00527
00528 QWizard::next();
00529 }
00530
00531
static bool checkSubfolders(
KMFolderDir* dir,
int language )
00532 {
00533 KMailICalIfaceImpl& ical = kmkernel->iCalIface();
00534
return dir->
hasNamedFolder( ical.folderName( KFolderTreeItem::Inbox, language ) ) &&
00535 dir->
hasNamedFolder( ical.folderName( KFolderTreeItem::Calendar, language ) ) &&
00536 dir->
hasNamedFolder( ical.folderName( KFolderTreeItem::Contacts, language ) ) &&
00537 dir->
hasNamedFolder( ical.folderName( KFolderTreeItem::Notes, language ) ) &&
00538 dir->
hasNamedFolder( ical.folderName( KFolderTreeItem::Tasks, language ) );
00539 }
00540
00541
void StartupWizard::guessExistingFolderLanguage()
00542 {
00543
KMFolderDir* dir = folder()->
child();
00544
00545
if( checkSubfolders( dir, 0 ) ) {
00546
00547 setLanguage( 0,
true );
00548 }
else if( checkSubfolders( dir, 1 ) ) {
00549
00550 setLanguage( 1,
true );
00551 }
else {
00552 setLanguage( 0,
false );
00553 }
00554 }
00555
00556 KPIM::Identity &StartupWizard::userIdentity()
00557 {
00558
return mIdentityWidget->identity();
00559 }
00560
00561
const KPIM::Identity &StartupWizard::userIdentity()
const
00562
{
00563
return mIdentityWidget->identity();
00564 }
00565
00566
QString StartupWizard::name()
const
00567
{
00568
return userIdentity().fullName();
00569 }
00570
00571
QString StartupWizard::login()
const
00572
{
00573
return mKolabWidget->loginEdit->text().stripWhiteSpace();
00574 }
00575
00576
QString StartupWizard::host()
const
00577
{
00578
return mKolabWidget->hostEdit->text().stripWhiteSpace();
00579 }
00580
00581
QString StartupWizard::email()
const
00582
{
00583
return userIdentity().emailAddr();
00584 }
00585
00586
QString StartupWizard::passwd()
const
00587
{
00588
return KMAccount::encryptStr( mKolabWidget->passwordEdit->text() );
00589 }
00590
00591
bool StartupWizard::storePasswd()
const
00592
{
00593
return mKolabWidget->storePasswordCheck->isChecked();
00594 }
00595
00596
00597
void StartupWizard::run()
00598 {
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 KConfigGroup options( KMKernel::config(),
"Groupware" );
00609
00610
00611
if( options.readEntry(
"Enabled",
"notset" ) !=
"notset" )
00612
return;
00613
00614 StartupWizard wiz(0,
"groupware wizard", TRUE );
00615
int rc = wiz.exec();
00616
00617 options.writeEntry(
"Enabled", rc == QDialog::Accepted && wiz.groupwareEnabled() );
00618
if( rc == QDialog::Accepted ) {
00619 options.writeEntry(
"FolderLanguage", wiz.language() );
00620 options.writeEntry(
"GroupwareFolder", wiz.folder()->idString() );
00621
00622 kmkernel->groupware().readConfig();
00623
00624
if( wiz.groupwareEnabled() && wiz.useDefaultKolabSettings() ) {
00625
00626 writeKOrganizerConfig( wiz );
00627 writeKAbcConfig();
00628 writeKAddressbookConfig( wiz );
00629 }
00630 }
00631 }
00632
00633
00634
00635
void StartupWizard::writeKOrganizerConfig(
const StartupWizard& wiz ) {
00636 KConfig config(
"korganizerrc" );
00637
00638 KConfigGroup optionsKOrgGeneral( &config,
"Personal Settings" );
00639 optionsKOrgGeneral.writeEntry(
"Use Control Center Email",
false );
00640 optionsKOrgGeneral.writeEntry(
"user_name", wiz.name() );
00641 optionsKOrgGeneral.writeEntry(
"user_email", wiz.email() );
00642
00643 KConfigGroup optionsKOrgFreeBusy( &config,
"Freebusy" );
00644 optionsKOrgFreeBusy.writeEntry(
"Publish to Kolab server name",wiz.host() );
00645 optionsKOrgFreeBusy.writeEntry(
"Remember Publish Password", wiz.storePasswd() );
00646 optionsKOrgFreeBusy.writeEntry(
"Publish User Name", wiz.login() );
00647
if( wiz.storePasswd() ) {
00648 }
00649 optionsKOrgFreeBusy.writeEntry(
"Remember Retrieve Password", wiz.storePasswd() );
00650 optionsKOrgFreeBusy.writeEntry(
"Retrieve From Kolab Server Name",wiz.host() );
00651 optionsKOrgFreeBusy.writeEntry(
"Retrieve User Name", wiz.login() );
00652
00653
00654 KConfigGroup optionsKOrgGroupware( &config,
"Groupware" );
00655 optionsKOrgGroupware.writeEntry(
"Publish FreeBusy lists",
true );
00656 optionsKOrgGroupware.writeEntry(
"Publish FreeBusy days", 60 );
00657 optionsKOrgGroupware.writeEntry(
"Publish to Kolab server",
true );
00658 optionsKOrgGroupware.writeEntry(
"Publish to Kolab server name", wiz.host() );
00659 optionsKOrgGroupware.writeEntry(
"Publish user name", wiz.login() );
00660 optionsKOrgGroupware.writeEntry(
"Remember publish password", wiz.storePasswd() );
00661
if( wiz.storePasswd() ) {
00662 optionsKOrgGroupware.writeEntry(
"Publish Server Password", wiz.passwd() );
00663 optionsKOrgGroupware.writeEntry(
"Retrieve Server Password", wiz.passwd() );
00664 }
00665 optionsKOrgGroupware.writeEntry(
"Retrieve FreeBusy lists",
true );
00666 optionsKOrgGroupware.writeEntry(
"Retrieve from Kolab server",
true );
00667 optionsKOrgGroupware.writeEntry(
"Retrieve from Kolab server name", wiz.host() );
00668 optionsKOrgGroupware.writeEntry(
"Retrieve user name", wiz.login() );
00669 optionsKOrgGroupware.writeEntry(
"Remember retrieve password", wiz.storePasswd() );
00670
00671 config.sync();
00672 }
00673
00674
00675
00676
void StartupWizard::writeKAbcConfig() {
00677 KConfig config(
"kabcrc" );
00678 KConfigGroup optionsKAbcGeneral( &config,
"General" );
00679
QString standardKey = optionsKAbcGeneral.readEntry(
"Standard" );
00680
QString newStandardKey;
00681
00682
QStringList activeKeys = optionsKAbcGeneral.readListEntry(
"ResourceKeys" );
00683
QStringList passiveKeys = optionsKAbcGeneral.readListEntry(
"PassiveResourceKeys" );
00684
QStringList keys = activeKeys + passiveKeys;
00685
for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
00686 KConfigGroup entry( &config,
"Resource_" + (*it) );
00687
if( entry.readEntry(
"ResourceType" ) ==
"imap" && newStandardKey.isNull() ) {
00688
00689 newStandardKey = *it;
00690
00691
00692 entry.writeEntry(
"ResourceIsReadOnly",
false );
00693 }
else
00694
00695 entry.writeEntry(
"ResourceIsReadOnly",
true );
00696 }
00697
00698
if( newStandardKey.isNull() ) {
00699
00700 newStandardKey = KApplication::randomString( 10 );
00701 KConfigGroup entry( &config,
"Resource_" + newStandardKey );
00702 entry.writeEntry(
"ResourceName",
"imap-resource" );
00703 entry.writeEntry(
"ResourceType",
"imap" );
00704 entry.writeEntry(
"ResourceIsReadOnly",
false );
00705 entry.writeEntry(
"ResourceIsFast",
true );
00706 activeKeys += newStandardKey;
00707 }
else if( passiveKeys.remove( newStandardKey ) > 0 )
00708
00709 activeKeys += newStandardKey;
00710
00711
00712 optionsKAbcGeneral.writeEntry(
"ResourceKeys", activeKeys );
00713 optionsKAbcGeneral.writeEntry(
"PassiveResourceKeys", passiveKeys );
00714 optionsKAbcGeneral.writeEntry(
"Standard", newStandardKey );
00715
00716 config.sync();
00717 }
00718
00719
00720
00721
void StartupWizard::writeKAddressbookConfig(
const StartupWizard& wiz ) {
00722 KConfig config(
"kaddressbookrc" );
00723 KConfigGroup options( &config,
"LDAP" );
00724
00725
QString hostBase =
QString(
"dc=" ) + wiz.host();
00726 hostBase.replace(
'.',
",dc=" );
00727
00728
00729 uint count = options.readUnsignedNumEntry(
"NumSelectedHosts");
00730
for ( uint i = 0; i < count; ++i ) {
00731 QString host = options.readEntry( QString(
"SelectedHost%1").arg( i ) );
00732
int port = options.readUnsignedNumEntry( QString(
"SelectedPort%1" ).arg( i ) );
00733 QString base = options.readEntry( QString(
"SelectedBase%1" ).arg( i ) );
00734
00735
if( host == wiz.host() && port == 389 && base == hostBase )
00736
00737
return;
00738 }
00739
00740
00741 count = options.readUnsignedNumEntry(
"NumHosts" );
00742
for ( uint i = 0; i < count; ++i ) {
00743 QString host = options.readEntry( QString(
"SelectedHost%1").arg( i ) );
00744
int port = options.readUnsignedNumEntry( QString(
"SelectedPort%1" ).arg( i ) );
00745 QString base = options.readEntry( QString(
"SelectedBase%1" ).arg( i ) );
00746
00747
if( host == wiz.host() && port == 389 && base == hostBase ) {
00748
00749
for( ++i; i < count; ++i ) {
00750 host = options.readEntry( QString(
"Host%1" ).arg( i ) );
00751 port = options.readUnsignedNumEntry( QString(
"Port%1" ).arg( i ) );
00752 base = options.readEntry( QString(
"Base%1" ).arg( i ) );
00753 options.writeEntry( QString(
"Host%1" ).arg( i-1 ), host );
00754 options.writeEntry( QString(
"Port%1" ).arg( i-1 ), port );
00755 options.writeEntry( QString(
"Base%1" ).arg( i-1 ), base );
00756 }
00757
00758
00759 --count;
00760 options.deleteEntry( QString(
"Host%1" ).arg( count ) );
00761 options.deleteEntry( QString(
"Port%1" ).arg( count ) );
00762 options.deleteEntry( QString(
"Base%1" ).arg( count ) );
00763 options.writeEntry(
"NumHosts", count );
00764
break;
00765 }
00766 }
00767
00768
00769 count = options.readUnsignedNumEntry(
"NumSelectedHosts");
00770 options.writeEntry( QString(
"SelectedHost%1" ).arg( count ), wiz.host() );
00771 options.writeEntry( QString(
"SelectedPort%1" ).arg( count ), 389 );
00772 options.writeEntry( QString(
"SelectedBase%1" ).arg( count ), hostBase );
00773 options.writeEntry(
"NumSelectedHosts", count+1 );
00774 }
00775
00776
00777
#include "startupwizard.moc"