diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /wizards | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'wizards')
45 files changed, 4980 insertions, 0 deletions
diff --git a/wizards/DESIGN b/wizards/DESIGN new file mode 100644 index 000000000..410d2990f --- /dev/null +++ b/wizards/DESIGN @@ -0,0 +1,8 @@ +Files +------ + +actionpage.* page with the add / edit / delete buttons +groupwarewizard.* main window +servertype.h interface for servertypes +servertypemanager.* manager for all server types +overviewpage.* page where you can select the server type diff --git a/wizards/Makefile.am b/wizards/Makefile.am new file mode 100644 index 000000000..0a211294c --- /dev/null +++ b/wizards/Makefile.am @@ -0,0 +1,121 @@ +METASOURCES = AUTO + +INCLUDES = -I$(top_srcdir)/libkpimidentities -I$(top_srcdir)/libkcal \ + -I$(top_srcdir)/kresources/kolab/shared -I$(top_srcdir) \ + -I$(top_srcdir)/knotes \ + -I$(top_srcdir)/certmanager/lib \ + -I$(top_builddir)/kresources/groupwise \ + -I$(top_builddir)/kresources/lib \ + -I$(top_srcdir)/kresources/lib \ + $(all_includes) + +bin_PROGRAMS = groupwarewizard egroupwarewizard sloxwizard kolabwizard \ + groupwisewizard exchangewizard scalixwizard + +kde_module_LTLIBRARIES = libegroupwarewizard.la libsloxwizard.la \ + libkolabwizard.la libgroupwisewizard.la \ + libexchangewizard.la libscalixwizard.la + + +groupwarewizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +groupwarewizard_LDADD = libegroupwarewizard.la libsloxwizard.la $(LIB_KDEUI) \ + libkolabwizard.la libgroupwisewizard.la \ + libexchangewizard.la +groupwarewizard_SOURCES = groupwarewizard.cpp main.cpp overviewpage.cpp + +# Kolab +libkolabwizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libkolabwizard_la_LIBADD = $(top_builddir)/kresources/kolab/kcal/libkcalkolab.la \ + $(top_builddir)/kresources/kolab/kabc/libkabckolab.la \ + $(top_builddir)/kresources/kolab/knotes/libknoteskolab.la \ + $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/libkpimidentities/libkpimidentities.la + +libkolabwizard_la_SOURCES = kolabwizard.cpp kmailchanges.cpp kolabconfig.kcfgc \ + kolabkmailchanges.cpp + +kolabwizard_LDADD = libkolabwizard.la $(LIB_KDEUI) +kolabwizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +kolabwizard_SOURCES = kolabmain.cpp + +# eGroupware +libegroupwarewizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libegroupwarewizard_la_SOURCES = egroupwarewizard.cpp egroupwareconfig.kcfgc +libegroupwarewizard_la_LIBADD = $(top_builddir)/kresources/egroupware/libkabc_xmlrpc.la \ + $(top_builddir)/kresources/egroupware/libkcal_xmlrpc.la \ + $(top_builddir)/kresources/egroupware/libknotes_xmlrpc.la \ + $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(LIB_KDEUI) + +egroupwarewizard_LDADD = libegroupwarewizard.la +egroupwarewizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +egroupwarewizard_SOURCES = egroupwaremain.cpp + +# SLOX +libsloxwizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libsloxwizard_la_SOURCES = sloxwizard.cpp sloxconfig.kcfgc +libsloxwizard_la_LIBADD = $(top_builddir)/kresources/slox/libkcal_slox.la \ + $(top_builddir)/kresources/slox/libkabc_slox.la \ + $(top_builddir)/libkdepim/libkdepim.la + +sloxwizard_LDADD = libsloxwizard.la +sloxwizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +sloxwizard_SOURCES = sloxmain.cpp + +# GroupWise +libgroupwisewizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libgroupwisewizard_la_SOURCES = groupwisewizard.cpp groupwiseconfig.kcfgc \ + kmailchanges.cpp +libgroupwisewizard_la_LIBADD = $(top_builddir)/kresources/groupwise/libkcal_groupwise.la \ + $(top_builddir)/kresources/groupwise/libkabc_groupwise.la \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/libkpimidentities/libkpimidentities.la +libgroupwisewizard_la_COMPILE_FIRST = $(top_builddir)/kresources/groupwise/kabc_groupwiseprefs.h \ + $(top_builddir)/kresources/groupwise/kcal_groupwiseprefsbase.h + + +groupwisewizard_LDADD = libgroupwisewizard.la +groupwisewizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +groupwisewizard_SOURCES = groupwisemain.cpp + +# Exchange +libexchangewizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libexchangewizard_la_SOURCES = exchangewizard.cpp +libexchangewizard_la_LIBADD = $(top_builddir)/kresources/newexchange/libkcal_newexchange.la \ + $(top_builddir)/kresources/newexchange/libkabc_newexchange.la \ + $(top_builddir)/libkdepim/libkdepim.la + +exchangewizard_LDADD = libexchangewizard.la +exchangewizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +exchangewizard_SOURCES = exchangemain.cpp + +# Scalix +libscalixwizard_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries) +libscalixwizard_la_LIBADD = $(top_builddir)/kresources/scalix/kcal/libkcalscalix.la \ + $(top_builddir)/kresources/scalix/kabc/libkabcscalix.la \ + $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/libkpimidentities/libkpimidentities.la + +libscalixwizard_la_SOURCES = scalixwizard.cpp kmailchanges.cpp scalixconfig.kcfgc \ + scalixkmailchanges.cpp + +scalixwizard_LDADD = libscalixwizard.la $(LIB_KDEUI) +scalixwizard_LDFLAGS = $(all_libraries) $(KDE_RPATH) +scalixwizard_SOURCES = scalixmain.cpp + +noinst_HEADERS = egroupwarewizard.h kmailchanges.h kolabwizard.h sloxwizard.h \ + groupwisewizard.h exchangewizard.h + +kde_kcfg_DATA = egroupware.kcfg slox.kcfg kolab.kcfg groupwise.kcfg scalix.kcfg + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kdepimwizards.pot + +egroupwarewizard.lo: ../kresources/egroupware/kabc_egroupwareprefs.h ../kresources/egroupware/kcal_egroupwareprefs.h ../kresources/egroupware/knotes_egroupwareprefs.h +exchangewizard.lo: ../kresources/lib/kresources_groupwareprefs.h +sloxwizard.lo: ../kresources/slox/kabcsloxprefs.h ../kresources/slox/kcalsloxprefs.h + +xdg_apps_DATA = groupwarewizard.desktop diff --git a/wizards/egroupware.kcfg b/wizards/egroupware.kcfg new file mode 100644 index 000000000..8a9152167 --- /dev/null +++ b/wizards/egroupware.kcfg @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="egroupwarerc"/> + + <group name="General"> + <entry name="Server" type="String"> + <label>Server name</label> + <default></default> + </entry> + <entry name="Domain" type="String"> + <label>Domain name</label> + <default>default</default> + </entry> + <entry name="User" type="String"> + <label>User name</label> + <default></default> + </entry> + <entry name="Password" type="Password"> + <label>User password</label> + <default></default> + </entry> + <entry name="xmlrpc_location" type="String"> + <label>XMLRPC location on server</label> + <default>egroupware/xmlrpc.php</default> + </entry> + <entry name="UseSSLConnection" type="Bool"> + <label>Use SSL connection</label> + <default></default> + </entry> + <entry name="LogFile" type="String"> + <label>Log File</label> + </entry> + </group> + +</kcfg> diff --git a/wizards/egroupwareconfig.kcfgc b/wizards/egroupwareconfig.kcfgc new file mode 100644 index 000000000..f38de74a6 --- /dev/null +++ b/wizards/egroupwareconfig.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for kconfig_compiler +File=egroupware.kcfg +ClassName=EGroupwareConfig +Singleton=true +Mutators=true +#Inherits=KPimPrefs +#IncludeFiles=libkdepim/kpimprefs.h +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/wizards/egroupwaremain.cpp b/wizards/egroupwaremain.cpp new file mode 100644 index 000000000..86777c61d --- /dev/null +++ b/wizards/egroupwaremain.cpp @@ -0,0 +1,57 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "egroupwarewizard.h" + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + + KAboutData aboutData( "egroupwarewizard", + "eGroupware Server Configuration Wizard", + "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + EGroupwareWizard wizard; + + wizard.exec(); +} diff --git a/wizards/egroupwarewizard.cpp b/wizards/egroupwarewizard.cpp new file mode 100644 index 000000000..75898ead3 --- /dev/null +++ b/wizards/egroupwarewizard.cpp @@ -0,0 +1,390 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "egroupwarewizard.h" +#include "egroupwareconfig.h" + +#include "kresources/egroupware/kabc_egroupwareprefs.h" +#include "kresources/egroupware/kabc_resourcexmlrpc.h" +#include "kresources/egroupware/kcal_egroupwareprefs.h" +#include "kresources/egroupware/kcal_resourcexmlrpc.h" +#include "kresources/egroupware/knotes_egroupwareprefs.h" +#include "kresources/egroupware/knotes_resourcexmlrpc.h" + +#include <libkcal/resourcecalendar.h> + +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qwhatsthis.h> + + +static QString createURL( const QString &server, bool useSSL, const QString &location ) +{ + KURL url; + + if ( useSSL ) + url.setProtocol( "https" ); + else + url.setProtocol( "http" ); + + url.setHost( server ); + url.setPath( "/" + location ); + + return url.url(); +} + +class CreateEGroupwareKabcResource : public KConfigPropagator::Change +{ + public: + CreateEGroupwareKabcResource() + : KConfigPropagator::Change( i18n("Create eGroupware Addressbook Resource") ) + { + } + + void apply() + { + kdDebug() << "Create eGroupware Addressbook Resource" << endl; + + KRES::Manager<KABC::Resource> manager( "contact" ); + manager.readConfig(); + + QString url = createURL( EGroupwareConfig::self()->server(), EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ); + + KABC::ResourceXMLRPC *resource = new KABC::ResourceXMLRPC( url, EGroupwareConfig::self()->domain(), + EGroupwareConfig::self()->user(), + EGroupwareConfig::self()->password() ); + resource->setResourceName( i18n( "eGroupware" ) ); + manager.add( resource ); + manager.writeConfig(); + } +}; + +// TODO: fix the i18n strings after freeze... +class ChangeEGroupwareKabcResource : public KConfigPropagator::Change +{ + public: + ChangeEGroupwareKabcResource( const QString &identifier ) + : KConfigPropagator::Change( i18n("Create eGroupware Addressbook Resource") ), + mIdentifier( identifier ) + { + } + + void apply() + { + kdDebug() << "Change eGroupware Addressbook Resource" << endl; + + KRES::Manager<KABC::Resource> manager( "contact" ); + manager.readConfig(); + + KRES::Manager<KABC::Resource>::Iterator it; + for ( it = manager.begin(); it != manager.end(); ++it ) { + if ( (*it)->identifier() == mIdentifier ) { + KABC::ResourceXMLRPC *resource = static_cast<KABC::ResourceXMLRPC*>( *it ); + + resource->prefs()->setUrl( createURL( EGroupwareConfig::self()->server(), + EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ) ); + resource->prefs()->setDomain( EGroupwareConfig::self()->domain() ); + resource->prefs()->setUser( EGroupwareConfig::self()->user() ); + resource->prefs()->setPassword( EGroupwareConfig::self()->password() ); + + manager.change( resource ); + manager.writeConfig(); + return; + } + } + } + + private: + QString mIdentifier; +}; + +class CreateEGroupwareKcalResource : public KConfigPropagator::Change +{ + public: + CreateEGroupwareKcalResource() + : KConfigPropagator::Change( i18n( "Create eGroupware Calendar Resource" ) ) + { + } + + void apply() + { + kdDebug() << "Create eGroupware Calendar Resource" << endl; + + KCal::CalendarResourceManager manager( "calendar" ); + manager.readConfig(); + + KCal::ResourceXMLRPC *resource = new KCal::ResourceXMLRPC(); + resource->setResourceName( i18n( "eGroupware" ) ); + resource->prefs()->setUrl( createURL( EGroupwareConfig::self()->server(), EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ) ); + resource->prefs()->setDomain( EGroupwareConfig::self()->domain() ); + resource->prefs()->setUser( EGroupwareConfig::self()->user() ); + resource->prefs()->setPassword( EGroupwareConfig::self()->password() ); + manager.add( resource ); + manager.writeConfig(); + } +}; + +class ChangeEGroupwareKcalResource : public KConfigPropagator::Change +{ + public: + ChangeEGroupwareKcalResource( const QString &identifier ) + : KConfigPropagator::Change( i18n( "Create eGroupware Calendar Resource" ) ), + mIdentifier( identifier ) + { + } + + void apply() + { + kdDebug() << "Change eGroupware Calendar Resource" << endl; + + KCal::CalendarResourceManager manager( "calendar" ); + manager.readConfig(); + + KCal::CalendarResourceManager::Iterator it; + for ( it = manager.begin(); it != manager.end(); ++it ) { + if ( (*it)->identifier() == mIdentifier ) { + KCal::ResourceXMLRPC *resource = static_cast<KCal::ResourceXMLRPC*>( *it ); + + resource->prefs()->setUrl( createURL( EGroupwareConfig::self()->server(), + EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ) ); + resource->prefs()->setDomain( EGroupwareConfig::self()->domain() ); + resource->prefs()->setUser( EGroupwareConfig::self()->user() ); + resource->prefs()->setPassword( EGroupwareConfig::self()->password() ); + + manager.change( resource ); + manager.writeConfig(); + return; + } + } + } + + private: + QString mIdentifier; +}; + +class CreateEGroupwareKnotesResource : public KConfigPropagator::Change +{ + public: + CreateEGroupwareKnotesResource() + : KConfigPropagator::Change( i18n("Create eGroupware Notes Resource") ) + { + } + + void apply() + { + kdDebug() << "Create eGroupware notes Resource" << endl; + + KRES::Manager<ResourceNotes> manager( "notes" ); + manager.readConfig(); + + QString url = createURL( EGroupwareConfig::self()->server(), EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ); + + KNotes::ResourceXMLRPC *resource = new KNotes::ResourceXMLRPC(); + resource->setResourceName( i18n( "eGroupware" ) ); + resource->prefs()->setUrl( createURL( EGroupwareConfig::self()->server(), EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ) ); + resource->prefs()->setDomain( EGroupwareConfig::self()->domain() ); + resource->prefs()->setUser( EGroupwareConfig::self()->user() ); + resource->prefs()->setPassword( EGroupwareConfig::self()->password() ); + manager.add( resource ); + manager.writeConfig(); + } +}; + +class ChangeEGroupwareKnotesResource : public KConfigPropagator::Change +{ + public: + ChangeEGroupwareKnotesResource( const QString &identifier ) + : KConfigPropagator::Change( i18n("Create eGroupware Notes Resource") ), + mIdentifier( identifier ) + { + } + + void apply() + { + kdDebug() << "Change eGroupware Notes Resource" << endl; + + KRES::Manager<ResourceNotes> manager( "notes" ); + manager.readConfig(); + + KRES::Manager<ResourceNotes>::Iterator it; + for ( it = manager.begin(); it != manager.end(); ++it ) { + if ( (*it)->identifier() == mIdentifier ) { + KNotes::ResourceXMLRPC *resource = static_cast<KNotes::ResourceXMLRPC*>( *it ); + + resource->prefs()->setUrl( createURL( EGroupwareConfig::self()->server(), + EGroupwareConfig::self()->useSSLConnection(), EGroupwareConfig::self()->xmlrpc_location() ) ); + resource->prefs()->setDomain( EGroupwareConfig::self()->domain() ); + resource->prefs()->setUser( EGroupwareConfig::self()->user() ); + resource->prefs()->setPassword( EGroupwareConfig::self()->password() ); + + manager.change( resource ); + manager.writeConfig(); + return; + } + } + } + + private: + QString mIdentifier; +}; + +class EGroupwarePropagator : public KConfigPropagator +{ + public: + EGroupwarePropagator() + : KConfigPropagator( EGroupwareConfig::self(), "egroupware.kcfg" ) + { + } + + protected: + void addCustomChanges( Change::List &changes ) + { + KCal::CalendarResourceManager kcalManager( "calendar" ); + kcalManager.readConfig(); + KCal::CalendarResourceManager::Iterator kcalIt; + for ( kcalIt = kcalManager.begin(); kcalIt != kcalManager.end(); ++kcalIt ) { + if ( (*kcalIt)->type() == "xmlrpc" ) break; + } + if ( kcalIt == kcalManager.end() ) { + changes.append( new CreateEGroupwareKcalResource ); + } else { + changes.append( new ChangeEGroupwareKcalResource( (*kcalIt)->identifier() ) ); + } + + KRES::Manager<KABC::Resource> kabcManager( "contact" ); + kabcManager.readConfig(); + KRES::Manager<KABC::Resource>::Iterator kabcIt; + for ( kabcIt = kabcManager.begin(); kabcIt != kabcManager.end(); ++kabcIt ) { + if ( (*kabcIt)->type() == "xmlrpc" ) break; + } + if ( kabcIt == kabcManager.end() ) { + changes.append( new CreateEGroupwareKabcResource ); + } else { + changes.append( new ChangeEGroupwareKabcResource( (*kabcIt)->identifier() ) ); + } + + KRES::Manager<ResourceNotes> knotesManager( "notes" ); + knotesManager.readConfig(); + KRES::Manager<ResourceNotes>::Iterator knotesIt; + for ( knotesIt = knotesManager.begin(); knotesIt != knotesManager.end(); ++knotesIt ) { + if ( (*knotesIt)->type() == "xmlrpc" ) break; + } + if ( knotesIt == knotesManager.end() ) { + changes.append( new CreateEGroupwareKnotesResource ); + } else { + changes.append( new ChangeEGroupwareKnotesResource( (*knotesIt)->identifier() ) ); + } + } +}; + +EGroupwareWizard::EGroupwareWizard() : KConfigWizard( new EGroupwarePropagator ) +{ + QFrame *page = createWizardPage( i18n( "eGroupware Server" ) ); + + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n( "&Server name:" ), page ); + topLayout->addWidget( label, 0, 0 ); + mServerEdit = new KLineEdit( page ); + label->setBuddy( mServerEdit ); + topLayout->addWidget( mServerEdit, 0, 1 ); + + label = new QLabel( i18n( "&Domain name:" ), page ); + topLayout->addWidget( label, 1, 0 ); + mDomainEdit = new KLineEdit( page ); + label->setBuddy( mDomainEdit ); + topLayout->addWidget( mDomainEdit, 1, 1 ); + + label = new QLabel( i18n( "&Username:" ), page ); + topLayout->addWidget( label, 2, 0 ); + mUserEdit = new KLineEdit( page ); + label->setBuddy( mUserEdit ); + topLayout->addWidget( mUserEdit, 2, 1 ); + + label = new QLabel( i18n( "&Password:" ), page ); + topLayout->addWidget( label, 3, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + label->setBuddy( mPasswordEdit ); + topLayout->addWidget( mPasswordEdit, 3, 1 ); + + label = new QLabel( i18n( "&Location xmlrpc.php on server:" ), page ); + topLayout->addWidget( label, 4, 0 ); + mXMLRPC = new KLineEdit( page ); + mXMLRPC->setMinimumWidth( 175 ); + label->setBuddy( mXMLRPC ); + topLayout->addWidget( mXMLRPC, 4, 1 ); + QWhatsThis::add( label, i18n( "Some servers may not have the xmlrpc.php file in the 'egroupware' folder of the server. With this option it is possible to eventually change the path to that file. For most servers, the default value is OK." ) ); + + mUseSSLConnectionCheck = new QCheckBox( i18n( "Use SS&L connection" ), page ); + topLayout->addMultiCellWidget( mUseSSLConnectionCheck, 5, 5, 0, 1 ); + + topLayout->setRowStretch( 6, 1 ); + + setupRulesPage(); + setupChangesPage(); + + resize( sizeHint() ); +} + +EGroupwareWizard::~EGroupwareWizard() +{ +} + +QString EGroupwareWizard::validate() +{ + if( !mXMLRPC->text().endsWith( "xmlrpc.php" ) ) + return i18n( "Invalid path to xmlrpc.php entered." ); + + if( mServerEdit->text().isEmpty() || + mDomainEdit->text().isEmpty() || + mUserEdit->text().isEmpty() || + mPasswordEdit->text().isEmpty() || + mXMLRPC->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + + return QString::null; +} + +void EGroupwareWizard::usrReadConfig() +{ + mServerEdit->setText( EGroupwareConfig::self()->server() ); + mDomainEdit->setText( EGroupwareConfig::self()->domain() ); + mUserEdit->setText( EGroupwareConfig::self()->user() ); + mPasswordEdit->setText( EGroupwareConfig::self()->password() ); + mXMLRPC->setText( EGroupwareConfig::self()->xmlrpc_location() ); + mUseSSLConnectionCheck->setChecked( EGroupwareConfig::self()->useSSLConnection() ); +} + +void EGroupwareWizard::usrWriteConfig() +{ + EGroupwareConfig::self()->setServer( mServerEdit->text() ); + EGroupwareConfig::self()->setDomain( mDomainEdit->text() ); + EGroupwareConfig::self()->setUser( mUserEdit->text() ); + EGroupwareConfig::self()->setPassword( mPasswordEdit->text() ); + EGroupwareConfig::self()->setXmlrpc_location( mXMLRPC->text() ); + EGroupwareConfig::self()->setUseSSLConnection( mUseSSLConnectionCheck->isChecked() ); +} diff --git a/wizards/egroupwarewizard.h b/wizards/egroupwarewizard.h new file mode 100644 index 000000000..f2eee1196 --- /dev/null +++ b/wizards/egroupwarewizard.h @@ -0,0 +1,50 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef EGROUPWAREWIZARD_H +#define EGROUPWAREWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KLineEdit; +class QCheckBox; + +class KDE_EXPORT EGroupwareWizard : public KConfigWizard +{ + public: + EGroupwareWizard(); + ~EGroupwareWizard(); + + QString validate(); + + void usrReadConfig(); + void usrWriteConfig(); + + private: + KLineEdit *mServerEdit; + KLineEdit *mDomainEdit; + KLineEdit *mUserEdit; + KLineEdit *mPasswordEdit; + KLineEdit *mXMLRPC; + QCheckBox *mUseSSLConnectionCheck; +}; + +#endif diff --git a/wizards/exchangemain.cpp b/wizards/exchangemain.cpp new file mode 100644 index 000000000..3b68951e5 --- /dev/null +++ b/wizards/exchangemain.cpp @@ -0,0 +1,57 @@ +/* + This file is part of kdepim. + + Copyright (c) 2005 Daniel Molkentin <molkentin@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "exchangewizard.h" + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + KAboutData aboutData( "exchangewizard", + I18N_NOOP( "Microsoft Exchange Server Configuration Wizard" ), + "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + ExchangeWizard wizard; + + wizard.exec(); +} diff --git a/wizards/exchangewizard.cpp b/wizards/exchangewizard.cpp new file mode 100644 index 000000000..e95480c14 --- /dev/null +++ b/wizards/exchangewizard.cpp @@ -0,0 +1,297 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "exchangewizard.h" + +#include "kresources/newexchange/kabc_resourceexchange.h" +#include "kresources/newexchange/kcal_resourceexchange.h" + +#include "kresources/lib/folderconfig.h" + +#include <libkcal/resourcecalendar.h> + +#include <klineedit.h> +#include <klocale.h> + +#include <qlayout.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qspinbox.h> + +#if 0 + +i18n("Please select folders for addressbook:") +i18n("Please select folders for events, to-dos and journal entries:") + +#endif + + +class CreateExchangeKcalResource : public KConfigPropagator::Change +{ + public: + CreateExchangeKcalResource() + : KConfigPropagator::Change( i18n("Create Exchange Calendar Resource") ) + { + } + + void apply() + { + #if 0 + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KURL url( exchangeUrl() ); + + KCal::ResourceExchange *r = new KCal::ResourceExchange( new KConfig );// url ); + r->setResourceName( i18n("Exchange Server") ); + r->prefs()->setUser( ExchangeConfig::self()->user() ); + r->prefs()->setPassword( ExchangeConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + m.add( r ); + m.writeConfig(); + + ExchangeConfig::self()->setKcalResource( r->identifier() ); + #endif + } +}; + +class UpdateExchangeKcalResource : public KConfigPropagator::Change +{ + public: + UpdateExchangeKcalResource() + : KConfigPropagator::Change( i18n("Update Exchange Calendar Resource") ) + { + } + + void apply() + { + #if 0 + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KURL url( exchangeUrl() ); + + KCal::CalendarResourceManager::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == ExchangeConfig::kcalResource() ) { + KCal::ResourceExchange *r = static_cast<KCal::ResourceExchange *>( *it ); + r->prefs()->setUrl( url.url() ); + r->prefs()->setUser( ExchangeConfig::self()->user() ); + r->prefs()->setPassword( ExchangeConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + } + } + m.writeConfig(); + #endif + } +}; + +class CreateExchangeKabcResource : public KConfigPropagator::Change +{ + public: + CreateExchangeKabcResource() + : KConfigPropagator::Change( i18n("Create Exchange Addressbook Resource") ) + { + } + + void apply() + { + #if 0 + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + KURL url( exchangeUrl() ); + QString user( ExchangeConfig::self()->user() ); + QString password( ExchangeConfig::self()->password() ); + + KABC::ResourceExchange *r = new KABC::ResourceExchange( url, user, password ); + r->setResourceName( i18n("Exchange Server") ); + m.add( r ); + m.writeConfig(); + + ExchangeConfig::self()->setKabcResource( r->identifier() ); + #endif + } +}; + +class UpdateExchangeKabcResource : public KConfigPropagator::Change +{ + public: + UpdateExchangeKabcResource() + : KConfigPropagator::Change( i18n("Update Exchange Addressbook Resource") ) + { + } + + void apply() + { + # if 0 + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + KURL url( exchangeUrl() ); + + KRES::Manager<KABC::Resource>::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == ExchangeConfig::kabcResource() ) { + KABC::ResourceExchange *r = static_cast<KABC::ResourceExchange *>( *it ); + r->prefs()->setUrl( url.url() ); + r->prefs()->setUser( ExchangeConfig::self()->user() ); + r->prefs()->setPassword( ExchangeConfig::self()->password() ); + } + } + m.writeConfig(); + #endif + } +}; + + +class ExchangePropagator : public KConfigPropagator +{ + public: + ExchangePropagator() + : KConfigPropagator( /*ExchangeConfig::self()*/ 0, "exchange.kcfg" ) + { + } + + ~ExchangePropagator() + { + //ExchangeConfig::self()->writeConfig(); + } + + protected: + void addCustomChanges( Change::List &changes ) + { + #if 0 + KCal::CalendarResourceManager m1( "calendar" ); + m1.readConfig(); + KCal::CalendarResourceManager::Iterator it; + for ( it = m1.begin(); it != m1.end(); ++it ) { + if ( (*it)->type() == "exchange" ) break; + } + if ( it == m1.end() ) { + changes.append( new CreateExchangeKcalResource ); + } else { + if ( (*it)->identifier() == ExchangeConfig::kcalResource() ) { + KCal::ExchangePrefs *prefs = static_cast<KCal::ResourceExchange *>( *it )->prefs(); + if ( prefs->url() != exchangeUrl() || + prefs->user() != ExchangeConfig::user() || + prefs->password() != ExchangeConfig::password() ) { + changes.append( new UpdateExchangeKcalResource ); + } + } + } + KRES::Manager<KABC::Resource> m2( "contact" ); + m2.readConfig(); + KRES::Manager<KABC::Resource>::Iterator it2; + for ( it2 = m2.begin(); it2 != m2.end(); ++it2 ) { + if ( (*it2)->type() == "exchange" ) break; + } + if ( it2 == m2.end() ) { + changes.append( new CreateExchangeKabcResource ); + } else { + if ( (*it2)->identifier() == ExchangeConfig::kabcResource() ) { + KABC::ExchangePrefs *prefs = static_cast<KABC::ResourceExchange *>( *it2 )->prefs(); + if ( prefs->url() != exchangeUrl() || + prefs->user() != ExchangeConfig::user() || + prefs->password() != ExchangeConfig::password() ) { + changes.append( new UpdateExchangeKabcResource ); + } + } + } + #endif + } +}; + +ExchangeWizard::ExchangeWizard() : KConfigWizard( new ExchangePropagator ) +{ + QFrame *page = createWizardPage( i18n("Microsoft Exchange Server") ); + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n("Server name:"), page ); + topLayout->addWidget( label, 0, 0 ); + mServerEdit = new KLineEdit( page ); + topLayout->addWidget( mServerEdit, 0, 1 ); + + label = new QLabel( i18n("Port:"), page ); + topLayout->addWidget( label, 1, 0 ); + mPortEdit = new QSpinBox( 1, 65536, 1, page ); + topLayout->addWidget( mPortEdit, 1, 1 ); + + label = new QLabel( i18n("User name:"), page ); + topLayout->addWidget( label, 2, 0 ); + mUserEdit = new KLineEdit( page ); + topLayout->addWidget( mUserEdit, 2, 1 ); + + label = new QLabel( i18n("Password:"), page ); + topLayout->addWidget( label, 3, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + topLayout->addWidget( mPasswordEdit, 3, 1 ); + + mSavePasswordCheck = new QCheckBox( i18n("Save password"), page ); + topLayout->addMultiCellWidget( mSavePasswordCheck, 4, 4, 0, 1 ); + + mSecureCheck = new QCheckBox( i18n("Encrypt communication with server"), + page ); + topLayout->addMultiCellWidget( mSecureCheck, 5, 5, 0, 1 ); + +#if 0 + KPIM::FolderConfig *fcfg = new KPIM::FolderConfig( page ); + topLayout->addMultiCellWidget( fcfg , 5, 5, 0, 1 ); +#endif + + topLayout->setRowStretch( 5, 1 ); + + setupRulesPage(); + setupChangesPage(); + + resize( 400, 300 ); +} + +ExchangeWizard::~ExchangeWizard() +{ +} + +void ExchangeWizard::usrReadConfig() +{ +#if 0 + mServerEdit->setText( ExchangeConfig::self()->server() ); + mUserEdit->setText( ExchangeConfig::self()->user() ); + mPasswordEdit->setText( ExchangeConfig::self()->password() ); + mSavePasswordCheck->setChecked( ExchangeConfig::self()->savePassword() ); + mSecureCheck->setChecked( ExchangeConfig::self()->useHttps() ); +#endif +} + +void ExchangeWizard::usrWriteConfig() +{ +#if 0 + ExchangeConfig::self()->setServer( mServerEdit->text() ); + ExchangeConfig::self()->setUser( mUserEdit->text() ); + ExchangeConfig::self()->setPassword( mPasswordEdit->text() ); + ExchangeConfig::self()->setSavePassword( mSavePasswordCheck->isChecked() ); + ExchangeConfig::self()->setUseHttps( mSecureCheck->isChecked() ); +#endif +} diff --git a/wizards/exchangewizard.h b/wizards/exchangewizard.h new file mode 100644 index 000000000..86dca9fcb --- /dev/null +++ b/wizards/exchangewizard.h @@ -0,0 +1,48 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef EXCHANGEWIZARD_H +#define EXCHANGEWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KLineEdit; +class QCheckBox; +class QSpinBox; + +class KDE_EXPORT ExchangeWizard : public KConfigWizard +{ + public: + ExchangeWizard(); + ~ExchangeWizard(); + + void usrReadConfig(); + void usrWriteConfig(); + + private: + KLineEdit *mServerEdit; + QSpinBox *mPortEdit; + KLineEdit *mUserEdit; + KLineEdit *mPasswordEdit; + QCheckBox *mSavePasswordCheck; + QCheckBox *mSecureCheck; +}; + +#endif diff --git a/wizards/groupwarewizard.cpp b/wizards/groupwarewizard.cpp new file mode 100644 index 000000000..80e323272 --- /dev/null +++ b/wizards/groupwarewizard.cpp @@ -0,0 +1,52 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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 <qapplication.h> +#include <qlayout.h> + +#include <klocale.h> + +#include "overviewpage.h" + +#include "groupwarewizard.h" + +GroupwareWizard::GroupwareWizard( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + setCaption( i18n( "KDE Groupware Wizard" ) ); + + QVBoxLayout *layout = new QVBoxLayout( this ); + + mOverViewPage = new OverViewPage( this ); + + layout->addWidget( mOverViewPage ); + + connect( mOverViewPage, SIGNAL( cancel() ), + qApp, SLOT( quit() ) ); + + resize( 400, 200 ); +} + +GroupwareWizard::~GroupwareWizard() +{ +} + +#include "groupwarewizard.moc" diff --git a/wizards/groupwarewizard.desktop b/wizards/groupwarewizard.desktop new file mode 100644 index 000000000..b5b38b874 --- /dev/null +++ b/wizards/groupwarewizard.desktop @@ -0,0 +1,53 @@ +[Desktop Entry] +Name=KDE Groupware Wizard +Name[af]=KDE groupware assistent +Name[ar]=مرشد KDE للبرمجيات الجماعية +Name[bg]=Помощник за група +Name[br]=Skoazeller strollant evit KDE +Name[ca]=Assistent de Groupware KDE +Name[cs]=Průvodce KDE groupwarem +Name[da]=KDE Groupware-guide +Name[de]=KDE Groupware-Assistent +Name[el]=Μάγος Groupware του KDE +Name[es]=Asistente de groupware de KDE +Name[et]=KDE Groupware nõustaja +Name[eu]=KDE groupware morroia +Name[fa]=جادوگر KDE Groupware +Name[fi]=KDE Groupwaren ohjattu toiminto +Name[fr]=Assistant KDE de travail collaboratif +Name[fy]=KDE Groupware-tsjoender +Name[ga]=Treoraí Groupware KDE +Name[gl]=Asistente de Traballo en Grupo de KDE +Name[hu]=KDE csoportmunka-varázsló +Name[is]=KDE hópvinnukerfisálfur +Name[it]=Assistente configurazione di KDE Groupware +Name[ja]=KDE グループウェアウィザード +Name[ka]=სერვერი Groupware +Name[kk]=KDE бірікен жұмыс шебері +Name[km]=អ្នកជំនួយការកម្មវិធីពហុអ្នកប្រើរបស់ KDE +Name[ko]=KDE 그룹웨어 마법사 +Name[lt]=KDE Groupware vedlys +Name[nb]=KDE gruppevareveiviser +Name[nds]=Groupware-Hölper vun KDE +Name[ne]=केडीई ग्रुपवेयर विजार्ड +Name[nl]=KDE Groupware-wizard +Name[nn]=KDE-vegvisar for gruppevare +Name[pl]=Asystent KDE Groupware +Name[pt]=Assistente Groupware do KDE +Name[pt_BR]=Assistente Groupware do KDE +Name[ru]=Мастер подключения к серверам совместной работы +Name[sk]=Sprievodca KDE Groupware +Name[sl]=Čarovnik za KDE Groupware +Name[sr]=KDE Groupware чаробњак +Name[sr@Latn]=KDE Groupware čarobnjak +Name[sv]=KDE-grupprogramguide +Name[tr]=Grup Çalışması (Groupware) Sihirbazı +Name[uk]=Майстер групової роботи для KDE +Name[zh_CN]=KDE 群件向导 +Name[zh_TW]=KDE 群組精靈 +Exec=groupwarewizard +Type=Application +Icon=kontact +Terminal=false +X-KDE-StartupNotify=true +Categories=Qt;KDE;X-KDE-Utilities-PIM;Office;Network;Email; diff --git a/wizards/groupwarewizard.h b/wizards/groupwarewizard.h new file mode 100644 index 000000000..bb9445376 --- /dev/null +++ b/wizards/groupwarewizard.h @@ -0,0 +1,41 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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. +*/ + +#ifndef GROUPWAREWIZARD_H +#define GROUPWAREWIZARD_H + +#include <qwidget.h> + +class OverViewPage; + +class GroupwareWizard : public QWidget +{ + Q_OBJECT + + public: + GroupwareWizard( QWidget *parent, const char *name = 0 ); + ~GroupwareWizard(); + + private: + OverViewPage *mOverViewPage; +}; + +#endif diff --git a/wizards/groupwise.kcfg b/wizards/groupwise.kcfg new file mode 100644 index 000000000..8885e0ecf --- /dev/null +++ b/wizards/groupwise.kcfg @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="groupwiserc" /> + + <group name="General" > + <entry key="Host" type="String" > + <label>Server name</label> + </entry> + <entry key="Port" type="UInt" > + <label>Port</label> + <default>7191</default> + </entry> + <entry key="User" type="String" > + <label>User name</label> + </entry> + <entry key="Path" type="String" > + <label>Path to SOAP interface</label> + <default>/soap</default> + </entry> + <entry key="Password" type="String" > + <label>User password</label> + </entry> + + <entry key="Email" type="String"> + <label>Email Address</label> + </entry> + <entry key="FullName" type="String"> + <label>Full Name of User</label> + </entry> + <entry key="CreateEmailAccount" type="Bool"> + <label>Create email account</label> + <default>false</default> + </entry> + + <entry key="SavePassword" type="Bool" > + <label>Save Password</label> + <default>true</default> + </entry> + <entry key="UseHttps" type="Bool" > + <label>Use HTTPS</label> + <default>true</default> + </entry> + <entry key="LogFile" type="String" > + <label>Log File</label> + </entry> + </group> + + <group name="Resources" > + <entry key="KcalResource" type="String" > + <label>Id of KCal resource</label> + </entry> + <entry key="KabcResource" type="String" > + <label>Id of KABC resource</label> + </entry> + <entry key="KMailAccountId" type="Int"> + <label>Id of KMail account for receiving mail</label> + <default>-1</default> + </entry> + <entry key="KMailTransportId" type="Int"> + <label>Id of KMail transport for sending mail</label> + <default>-1</default> + </entry> + </group> + + <group name="Constants"> + <entry name="EnableFreeBusy"> + <default>true</default> + </entry> + </group> + + <propagation source="groupwiserc/Constants/EnableFreeBusy" + target="korganizerrc/FreeBusy/FreeBusyRetrieveAuto" /> + + <propagation source="groupwiserc/General/User" + target="korganizerrc/FreeBusy/FreeBusyRetrieveUser" /> + <propagation source="groupwiserc/General/Password" + target="korganizerrc/FreeBusy/FreeBusyRetrievePassword" + hidevalue="true" /> + <propagation source="groupwiserc/General/SavePassword" + target="korganizerrc/FreeBusy/FreeBusyRetrieveSavePassword" /> + +</kcfg> diff --git a/wizards/groupwiseconfig.kcfgc b/wizards/groupwiseconfig.kcfgc new file mode 100644 index 000000000..185f35a1b --- /dev/null +++ b/wizards/groupwiseconfig.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for kconfig_compiler +File=groupwise.kcfg +ClassName=GroupwiseConfig +Singleton=true +Mutators=true +#Inherits=KPimPrefs +#IncludeFiles=libkdepim/kpimprefs.h +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/wizards/groupwisemain.cpp b/wizards/groupwisemain.cpp new file mode 100644 index 000000000..d3a2cbcf4 --- /dev/null +++ b/wizards/groupwisemain.cpp @@ -0,0 +1,58 @@ + /* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "groupwisewizard.h" + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + + KAboutData aboutData( "groupwisewizard", + I18N_NOOP( "Novell GroupWise Configuration Wizard" ), + "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + GroupwiseWizard wizard; + + wizard.exec(); +} diff --git a/wizards/groupwisewizard.cpp b/wizards/groupwisewizard.cpp new file mode 100644 index 000000000..6ddee3726 --- /dev/null +++ b/wizards/groupwisewizard.cpp @@ -0,0 +1,418 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "groupwisewizard.h" + +#include "groupwiseconfig.h" +#include "kmailchanges.h" + +#include "kresources/groupwise/kabc_groupwiseprefs.h" +#include "kresources/groupwise/kabc_resourcegroupwise.h" +#include "kresources/groupwise/kcal_groupwiseprefsbase.h" +#include "kresources/groupwise/kcal_resourcegroupwise.h" + +#include <libkcal/resourcecalendar.h> +#include <libemailfunctions/email.h> + +#include <klineedit.h> +#include <klocale.h> + +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qspinbox.h> +#include <qgroupbox.h> + +QString serverUrl() +{ + QString url; + if ( GroupwiseConfig::self()->useHttps() ) url = "https"; + else url = "http"; + url += "://" + GroupwiseConfig::self()->host() + ":" + + QString::number( GroupwiseConfig::self()->port() ) + GroupwiseConfig::self()->path(); + return url; +} + +class CreateGroupwiseKcalResource : public KConfigPropagator::Change +{ + public: + CreateGroupwiseKcalResource() + : KConfigPropagator::Change( i18n("Create GroupWise Calendar Resource") ) + { + } + + void apply() + { + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KCal::ResourceGroupwise *r = new KCal::ResourceGroupwise(); + + r->setResourceName( i18n("GroupWise") ); + r->prefs()->setUrl( serverUrl() ); + r->prefs()->setUser( GroupwiseConfig::self()->user() ); + r->prefs()->setPassword( GroupwiseConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + m.add( r ); + + m.writeConfig(); + + GroupwiseConfig::self()->setKcalResource( r->identifier() ); + } +}; + +class UpdateGroupwiseKcalResource : public KConfigPropagator::Change +{ + public: + UpdateGroupwiseKcalResource() + : KConfigPropagator::Change( i18n("Update GroupWise Calendar Resource") ) + { + } + + void apply() + { + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KCal::CalendarResourceManager::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == GroupwiseConfig::kcalResource() ) { + KCal::ResourceGroupwise *r = static_cast<KCal::ResourceGroupwise *>( *it ); + r->prefs()->setUrl( serverUrl() ); + r->prefs()->setUser( GroupwiseConfig::self()->user() ); + r->prefs()->setPassword( GroupwiseConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + } + } + m.writeConfig(); + } +}; + +class CreateGroupwiseKabcResource : public KConfigPropagator::Change +{ + public: + CreateGroupwiseKabcResource() + : KConfigPropagator::Change( i18n("Create GroupWise Addressbook Resource") ) + { + } + + void apply() + { + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + QString url = serverUrl(); + QString user( GroupwiseConfig::self()->user() ); + QString password( GroupwiseConfig::self()->password() ); + + KABC::ResourceGroupwise *r = new KABC::ResourceGroupwise( url, user, + password, + QStringList(), + QString::null ); + r->setResourceName( i18n("GroupWise") ); + m.add( r ); + m.writeConfig(); + + GroupwiseConfig::self()->setKabcResource( r->identifier() ); + } +}; + +class UpdateGroupwiseKabcResource : public KConfigPropagator::Change +{ + public: + UpdateGroupwiseKabcResource() + : KConfigPropagator::Change( i18n("Update GroupWise Addressbook Resource") ) + { + } + + void apply() + { + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + KRES::Manager<KABC::Resource>::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == GroupwiseConfig::kabcResource() ) { + KABC::ResourceGroupwise *r = static_cast<KABC::ResourceGroupwise *>( *it ); + r->prefs()->setUrl( serverUrl() ); + r->prefs()->setUser( GroupwiseConfig::self()->user() ); + r->prefs()->setPassword( GroupwiseConfig::self()->password() ); + } + } + m.writeConfig(); + } +}; + + +class GroupwisePropagator : public KConfigPropagator +{ + public: + GroupwisePropagator() + : KConfigPropagator( GroupwiseConfig::self(), "groupwise.kcfg" ) + { + } + + ~GroupwisePropagator() + { + GroupwiseConfig::self()->writeConfig(); + } + + protected: + class Writer : public CreateDisconnectedImapAccount::CustomWriter + { + public: + void writeFolder( KConfig &, int ) {} + void writeIds( int accountId, int transportId ) + { + GroupwiseConfig::setKMailAccountId( accountId ); + GroupwiseConfig::setKMailTransportId( transportId ); + } + }; + + void addCustomChanges( Change::List &changes ) + { + ChangeConfig *c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyRetrieveUrl"; + c->value = "groupwise://" + GroupwiseConfig::self()->host() + GroupwiseConfig::self()->path() + + "/freebusy/"; + changes.append( c ); + + KCal::CalendarResourceManager m1( "calendar" ); + m1.readConfig(); + KCal::CalendarResourceManager::Iterator it; + for ( it = m1.begin(); it != m1.end(); ++it ) { + if ( (*it)->type() == "groupwise" ) break; + } + if ( it == m1.end() ) { + changes.append( new CreateGroupwiseKcalResource ); + } else { + if ( (*it)->identifier() == GroupwiseConfig::kcalResource() ) { + KCal::GroupwisePrefsBase *prefs = + static_cast<KCal::ResourceGroupwise *>( *it )->prefs(); + if ( prefs->url() != serverUrl() || + prefs->port() != GroupwiseConfig::self()->port() || + prefs->user() != GroupwiseConfig::user() || + prefs->password() != GroupwiseConfig::password() ) { + changes.append( new UpdateGroupwiseKcalResource ); + } + } + } + + KRES::Manager<KABC::Resource> m2( "contact" ); + m2.readConfig(); + KRES::Manager<KABC::Resource>::Iterator it2; + for ( it2 = m2.begin(); it2 != m2.end(); ++it2 ) { + if ( (*it2)->type() == "groupwise" ) break; + } + if ( it2 == m2.end() ) { + changes.append( new CreateGroupwiseKabcResource ); + } else { + if ( (*it2)->identifier() == GroupwiseConfig::kabcResource() ) { + KABC::GroupwisePrefs *prefs = static_cast<KABC::ResourceGroupwise *>( *it2 )->prefs(); + if ( prefs->url() != serverUrl() || + prefs->user() != GroupwiseConfig::user() || + prefs->password() != GroupwiseConfig::password() ) { + changes.append( new UpdateGroupwiseKabcResource ); + } + } + } + + if ( GroupwiseConfig::createEmailAccount() ) { + CreateDisconnectedImapAccount *ca = + new CreateDisconnectedImapAccount( i18n("GroupWise") ); + + ca->setServer( GroupwiseConfig::host() ); + ca->setUser( GroupwiseConfig::user() ); + ca->setPassword( GroupwiseConfig::password() ); + ca->setRealName( GroupwiseConfig::fullName() ); + QString email = GroupwiseConfig::email(); + if ( !email.isEmpty() ) ca->setEmail( email ); + ca->enableSavePassword( true ); + ca->enableSieve( false ); + ca->setEncryption( CreateDisconnectedImapAccount::TLS ); + ca->setAuthenticationSend( CreateDisconnectedImapAccount::LOGIN ); + ca->setSmtpPort( 25 ); + + ca->setExistingAccountId( GroupwiseConfig::kMailAccountId() ); + ca->setExistingTransportId( GroupwiseConfig::kMailTransportId() ); + + ca->setCustomWriter( new Writer ); + + changes.append( ca ); + } + } +}; + +GroupwiseWizard::GroupwiseWizard() : KConfigWizard( new GroupwisePropagator ) +{ + QFrame *page = createWizardPage( i18n("Novell GroupWise") ); + + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n("Server name:"), page ); + topLayout->addWidget( label, 0, 0 ); + mServerEdit = new KLineEdit( page ); + topLayout->addWidget( mServerEdit, 0, 1 ); + + label = new QLabel( i18n("Path to SOAP interface:"), page ); + topLayout->addWidget( label, 1, 0 ); + mPathEdit = new KLineEdit( page ); + topLayout->addWidget( mPathEdit, 1, 1 ); + + label = new QLabel( i18n("Port:"), page ); + topLayout->addWidget( label, 2, 0 ); + mPortEdit = new QSpinBox( 1, 65536, 1, page ); + topLayout->addWidget( mPortEdit, 2, 1 ); + + label = new QLabel( i18n("User name:"), page ); + topLayout->addWidget( label, 3, 0 ); + mUserEdit = new KLineEdit( page ); + topLayout->addWidget( mUserEdit, 3, 1 ); + + label = new QLabel( i18n("Password:"), page ); + topLayout->addWidget( label, 4, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + topLayout->addWidget( mPasswordEdit, 4, 1 ); + + mSavePasswordCheck = new QCheckBox( i18n("Save password"), page ); + topLayout->addMultiCellWidget( mSavePasswordCheck, 5, 5, 0, 1 ); + + mSecureCheck = new QCheckBox( i18n("Encrypt communication with server"), + page ); + topLayout->addMultiCellWidget( mSecureCheck, 5, 5, 0, 1 ); + + topLayout->setRowStretch( 6, 1 ); + + + mEmailPage = createWizardPage( i18n("Mail") ); + + topLayout = new QGridLayout( mEmailPage ); + topLayout->setSpacing( spacingHint() ); + + mEmailBox = new QGroupBox( 1, Horizontal, + i18n("Create Mail Account"), mEmailPage ); + mEmailBox->setCheckable( true ); + topLayout->addWidget( mEmailBox, 0, 0 ); + + mEmailWidget = new QWidget( mEmailBox ); + connect( mEmailBox, SIGNAL( toggled( bool ) ), mEmailWidget, + SLOT( setEnabled( bool ) ) ); + + QGridLayout *accountLayout= new QGridLayout( mEmailWidget ); + accountLayout->setSpacing( spacingHint() ); + + label = new QLabel( i18n("Email address:"), mEmailWidget ); + accountLayout->addWidget( label, 0, 0 ); + + mEmailEdit = new KLineEdit( mEmailWidget ); + accountLayout->addWidget( mEmailEdit, 0, 1 ); + + label = new QLabel( i18n("Full name:"), mEmailWidget ); + accountLayout->addWidget( label, 1, 0 ); + + mFullNameEdit = new KLineEdit( mEmailWidget ); + accountLayout->addWidget( mFullNameEdit, 1, 1 ); + + accountLayout->setRowStretch( 2, 1 ); + + connect( this, SIGNAL( aboutToShowPage( QWidget * ) ), + SLOT( slotAboutToShowPage( QWidget * ) ) ); + + + setupRulesPage(); + setupChangesPage(); + + resize( 600, 400 ); +} + +GroupwiseWizard::~GroupwiseWizard() +{ +} + +QString GroupwiseWizard::validate() +{ + if( mServerEdit->text().isEmpty() || + mPathEdit->text().isEmpty() || + mPortEdit->text().isEmpty() || + mUserEdit->text().isEmpty() || + mPasswordEdit->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + + if ( mEmailBox->isChecked() ) { + if( !KPIM::isValidSimpleEmailAddress( mEmailEdit->text() ) ) + return i18n("Invalid email address entered."); + if( mFullNameEdit->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + } + + return QString::null; +} + +void GroupwiseWizard::usrReadConfig() +{ + mServerEdit->setText( GroupwiseConfig::self()->host() ); + mPathEdit->setText( GroupwiseConfig::self()->path() ); + mPortEdit->setValue( GroupwiseConfig::self()->port() ); + mUserEdit->setText( GroupwiseConfig::self()->user() ); + mPasswordEdit->setText( GroupwiseConfig::self()->password() ); + mSavePasswordCheck->setChecked( GroupwiseConfig::self()->savePassword() ); + mSecureCheck->setChecked( GroupwiseConfig::self()->useHttps() ); + mEmailEdit->setText( GroupwiseConfig::self()->email() ); + mFullNameEdit->setText( GroupwiseConfig::fullName() ); + mEmailBox->setChecked( GroupwiseConfig::createEmailAccount() ); +} + +void GroupwiseWizard::usrWriteConfig() +{ + GroupwiseConfig::self()->setHost( mServerEdit->text() ); + GroupwiseConfig::self()->setPath( mPathEdit->text() ); + GroupwiseConfig::self()->setPort( mPortEdit->value() ); + GroupwiseConfig::self()->setUser( mUserEdit->text() ); + GroupwiseConfig::self()->setPassword( mPasswordEdit->text() ); + GroupwiseConfig::self()->setSavePassword( mSavePasswordCheck->isChecked() ); + GroupwiseConfig::self()->setUseHttps( mSecureCheck->isChecked() ); + GroupwiseConfig::setEmail( mEmailEdit->text() ); + GroupwiseConfig::setFullName( mFullNameEdit->text() ); + GroupwiseConfig::setCreateEmailAccount( mEmailBox->isChecked() ); +} + +void GroupwiseWizard::slotAboutToShowPage( QWidget *page ) +{ + if ( page == mEmailPage ) { + if ( mEmailEdit->text().isEmpty() ) { + QString host = GroupwiseConfig::host(); + int pos = host.findRev( "." ); + if ( pos > 0 ) pos = host.findRev( ".", pos - 1 ); + if ( pos > 0 ) host = host.mid( pos + 1 ); + QString email = GroupwiseConfig::user() + "@" + host; + mEmailEdit->setText( email ); + } + } +} + +#include "groupwisewizard.moc" diff --git a/wizards/groupwisewizard.h b/wizards/groupwisewizard.h new file mode 100644 index 000000000..5cf09f64f --- /dev/null +++ b/wizards/groupwisewizard.h @@ -0,0 +1,61 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef GROUPWISEWIZARD_H +#define GROUPWISEWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KLineEdit; +class QCheckBox; +class QSpinBox; +class QGroupBox; + +class KDE_EXPORT GroupwiseWizard : public KConfigWizard +{ + Q_OBJECT + public: + GroupwiseWizard(); + ~GroupwiseWizard(); + + QString validate(); + void usrReadConfig(); + void usrWriteConfig(); + + protected slots: + void slotAboutToShowPage( QWidget * ); + + private: + KLineEdit *mServerEdit; + KLineEdit *mPathEdit; + QSpinBox *mPortEdit; + KLineEdit *mUserEdit; + KLineEdit *mPasswordEdit; + QCheckBox *mSavePasswordCheck; + QCheckBox *mSecureCheck; + + QFrame *mEmailPage; + QGroupBox *mEmailBox; + QWidget *mEmailWidget; + KLineEdit *mEmailEdit; + KLineEdit *mFullNameEdit; +}; + +#endif diff --git a/wizards/kmailchanges.cpp b/wizards/kmailchanges.cpp new file mode 100644 index 000000000..93c111952 --- /dev/null +++ b/wizards/kmailchanges.cpp @@ -0,0 +1,382 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + Copyright (c) 2004 Cornelius Schumacher <schumacher@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 "kmailchanges.h" + +#include <kapplication.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kemailsettings.h> +#include <identitymanager.h> +#include <identity.h> +#include <kdebug.h> +#include <kstringhandler.h> +#include <kwallet.h> +using namespace KWallet; + +static const char* s_folderContentsType[] = { + I18N_NOOP( "Calendar" ), + I18N_NOOP( "Contacts" ), + I18N_NOOP( "Notes" ), + I18N_NOOP( "Tasks" ), + I18N_NOOP( "Journal" ) }; + +Wallet* CreateImapAccount::mWallet = 0; + +CreateImapAccount::CreateImapAccount( const QString &accountName, const QString &title ) + : KConfigPropagator::Change( title ), + mAccountName( accountName ), mPort( 993 ), mEnableSieve( false ), mEnableSavePassword( true ), + mEncryption( None ), mAuthentication( NONE ), mAuthenticationSend( PLAIN ), mSmtpPort( 25 ), + mExistingAccountId( -1 ), mExistingTransportId( -1 ), + mCustomWriter( 0 ) +{ +} + +CreateImapAccount::~CreateImapAccount() +{ + delete mCustomWriter; +} + +void CreateImapAccount::setServer( const QString &s ) +{ + mServer = s; +} + +void CreateImapAccount::setUser( const QString &s ) +{ + mUser = s; +} + +void CreateImapAccount::setPassword( const QString &s ) +{ + mPassword = s; +} + +void CreateImapAccount::setRealName( const QString &s ) +{ + mRealName = s; +} + +void CreateImapAccount::setPort( int port ) +{ + mPort = port; +} + +void CreateImapAccount::setEmail( const QString &s ) +{ + mEmail = s; +} + +void CreateImapAccount::enableSieve( bool b ) +{ + mEnableSieve = b; +} + +void CreateImapAccount::setSieveVacationFileName( const QString& f ) +{ + mSieveVacationFileName = f; +} + +void CreateImapAccount::enableSavePassword( bool b ) +{ + mEnableSavePassword = b; +} + +void CreateImapAccount::setEncryption( + CreateImapAccount::Encryption e ) +{ + mEncryption = e; +} + +void CreateImapAccount::setAuthentication( + CreateImapAccount::Authentication a ) +{ + mAuthentication = a; +} + +void CreateImapAccount::setDefaultDomain(const QString &d) +{ + mDefaultDomain = d; +} + +void CreateImapAccount::setAuthenticationSend( + CreateImapAccount::Authentication a ) +{ + mAuthenticationSend = a; +} + +void CreateImapAccount::setSmtpPort( int port ) +{ + mSmtpPort = port; +} + +void CreateImapAccount::setExistingAccountId( int id ) +{ + mExistingAccountId = id; +} + +void CreateImapAccount::setExistingTransportId( int id ) +{ + mExistingTransportId = id; +} + +void CreateImapAccount::setCustomWriter( + CreateImapAccount::CustomWriter *writer ) +{ + mCustomWriter = writer; +} + + +CreateDisconnectedImapAccount::CreateDisconnectedImapAccount(const QString & accountName) : + CreateImapAccount( accountName, i18n("Create Disconnected IMAP Account for KMail") ), + mLocalSubscription( false ), mGroupwareType( GroupwareKolab ) +{ +} + +void CreateDisconnectedImapAccount::apply() +{ + if ( mEmail.isEmpty() ) mEmail = mUser + "@" + mServer; + + KConfig c( "kmailrc" ); + c.setGroup( "General" ); + c.writeEntry( "Default domain", mDefaultDomain ); + 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"); + + switch ( mAuthentication ) { + case NONE: + c.writeEntry( "auth", "*" ); + break; + case PLAIN: + c.writeEntry( "auth", "PLAIN" ); + break; + case LOGIN: + c.writeEntry( "auth", "LOGIN" ); + break; + case NTLM_SPA: + c.writeEntry( "auth", "NTLM" ); + break; + case GSSAPI: + c.writeEntry( "auth", "GSSAPI" ); + break; + case DIGEST_MD5: + c.writeEntry( "auth", "DIGEST-MD5" ); + break; + case CRAM_MD5: + c.writeEntry( "auth", "CRAM-MD5" ); + break; + } + + c.writeEntry( "Name", mAccountName ); + c.writeEntry( "host", mServer ); + c.writeEntry( "port", mPort ); + + c.writeEntry( "groupwareType", mGroupwareType ); + + // in case the user wants to get rid of some groupware folders + c.writeEntry( "locally-subscribed-folders", mLocalSubscription ); + + c.writeEntry( "login", mUser ); + + c.writeEntry( "sieve-support", mEnableSieve ? "true" : "false" ); + if ( !mSieveVacationFileName.isEmpty() ) + c.writeEntry( "sieve-vacation-filename", mSieveVacationFileName ); + + if ( mEncryption == SSL ) { + c.writeEntry( "use-ssl", true ); + } else if ( mEncryption == TLS ) { + c.writeEntry( "use-tls", true ); + } + + if ( mEnableSavePassword ) { + if ( !writeToWallet( "account", accountId ) ) { + c.writeEntry( "pass", KStringHandler::obscure( mPassword ) ); + c.writeEntry( "store-passwd", 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 ) { + if ( !writeToWallet( "transport", transportId ) ) { + 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... + // let's use the server name after that. + QString accountName = mAccountName; + const QStringList identities = identityManager.identities(); + if ( identities.find( accountName ) != identities.end() ) { + accountName = mServer; + int i = 2; + // And if there's already one, number them + while ( identities.find( accountName ) != identities.end() ) { + accountName = mServer + " " + QString::number( i++ ); + } + } + + KPIM::Identity& identity = identityManager.newFromScratch( accountName ); + identity.setFullName( mRealName ); + identity.setEmailAddr( mEmail ); + identityManager.commit(); + } + + if ( mCustomWriter ) { + mCustomWriter->writeFolder( c, uid ); + mCustomWriter->writeIds( accountId, transportId ); + } +} + +CreateOnlineImapAccount::CreateOnlineImapAccount(const QString & accountName) : + CreateImapAccount( accountName, i18n("Create Online IMAP Account for KMail") ) +{ +} + +void CreateOnlineImapAccount::apply() +{ + KConfig c( "kmailrc" ); + c.setGroup( "General" ); + uint accCnt = c.readNumEntry( "accounts", 0 ); + c.writeEntry( "accounts", accCnt+1 ); + + c.setGroup( QString("Account %1").arg(accCnt+1) ); + int uid = kapp->random(); + c.writeEntry( "Folder", uid ); + c.writeEntry( "Id", uid ); + c.writeEntry( "Type", "imap" ); + c.writeEntry( "auth", "*" ); + c.writeEntry( "Name", mAccountName ); + c.writeEntry( "host", mServer ); + + c.writeEntry( "login", mUser ); + + if ( mEnableSavePassword ) { + if ( !writeToWallet( "account", accCnt+1 ) ) { + c.writeEntry( "pass", KStringHandler::obscure( mPassword ) ); + c.writeEntry( "store-passwd", true ); + } + } + c.writeEntry( "port", "993" ); + + if ( mEncryption == SSL ) { + c.writeEntry( "use-ssl", true ); + } else if ( mEncryption == TLS ) { + c.writeEntry( "use-tls", true ); + } + + if ( mAuthenticationSend == PLAIN ) { + c.writeEntry( "authtype", "PLAIN" ); + } else if ( mAuthenticationSend == LOGIN ) { + c.writeEntry( "authtype", "LOGIN" ); + } + + c.writeEntry( "sieve-support", mEnableSieve ); + + // locally unsubscribe the default folders + c.writeEntry( "locally-subscribed-folders", true ); + QString groupwareFolders = QString("/INBOX/%1/,/INBOX/%2/,/INBOX/%3/,/INBOX/%4/,/INBOX/%5/") + .arg( i18n(s_folderContentsType[0]) ).arg( i18n(s_folderContentsType[1]) ) + .arg( i18n(s_folderContentsType[2]) ).arg( i18n(s_folderContentsType[3]) ) + .arg( i18n(s_folderContentsType[4]) ); + c.writeEntry( "locallyUnsubscribedFolders", groupwareFolders ); + + c.setGroup( QString("Folder-%1").arg( uid ) ); + c.writeEntry( "isOpen", true ); +} + +bool CreateImapAccount::writeToWallet(const QString & type, int id) +{ + if ( !Wallet::isEnabled() ) + return false; + if ( !mWallet || !mWallet->isOpen() ) { + delete mWallet; + WId window = 0; + if ( qApp->activeWindow() ) + window = qApp->activeWindow()->winId(); + mWallet = Wallet::openWallet( Wallet::NetworkWallet(), window ); + if ( !mWallet ) + return false; + if ( !mWallet->hasFolder( "kmail" ) ) + mWallet->createFolder( "kmail" ); + mWallet->setFolder( "kmail" ); + } + return mWallet->writePassword( type + "-" + QString::number( id ), mPassword ); +} diff --git a/wizards/kmailchanges.h b/wizards/kmailchanges.h new file mode 100644 index 000000000..b8ed477e0 --- /dev/null +++ b/wizards/kmailchanges.h @@ -0,0 +1,141 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + Copyright (c) 2004 Cornelius Schumacher <schumacher@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. +*/ +#ifndef KMAILCHANGES_H +#define KMAILCHANGES_H + +#include <kconfigpropagator.h> +#include <kconfig.h> + +namespace KWallet { + class Wallet; +} + +class CreateImapAccount : public KConfigPropagator::Change +{ + public: + class CustomWriter + { + public: + virtual void writeFolder( KConfig &, int folderId ) = 0; + virtual void writeIds( int accountId, int transportId ) = 0; + }; + + CreateImapAccount( const QString &accountName, const QString &title ); + ~CreateImapAccount(); + + void setServer( const QString & ); + void setUser( const QString & ); + void setPassword( const QString & ); + void setRealName( const QString & ); + void setPort( int ); + /** + Set email. Default is "user@server". + */ + void setEmail( const QString & ); + + void setDefaultDomain( const QString & ); + + void enableSieve( bool ); + void setSieveVacationFileName( const QString& ); + void enableSavePassword( bool ); + + enum Encryption { None, SSL, TLS }; + enum Authentication { NONE, PLAIN, LOGIN, NTLM_SPA, GSSAPI, DIGEST_MD5, CRAM_MD5 }; + + void setEncryption( Encryption ); + void setAuthentication( Authentication ); + + void setAuthenticationSend( Authentication ); + + void setSmtpPort( int ); + + void setExistingAccountId( int ); + void setExistingTransportId( int ); + + /** + Set custom writer. CreateImapAccount takes ownerhsip of the + object. + */ + void setCustomWriter( CustomWriter * ); + + protected: + bool writeToWallet( const QString &type, int id ); + + protected: + QString mAccountName; + + QString mServer; + QString mUser; + QString mPassword; + QString mRealName; + int mPort; + QString mEmail; + QString mDefaultDomain; + + QString mSieveVacationFileName; + bool mEnableSieve; + bool mEnableSavePassword; + + Encryption mEncryption; + Authentication mAuthentication; + Authentication mAuthenticationSend; + + int mSmtpPort; + + int mExistingAccountId; + int mExistingTransportId; + + CustomWriter *mCustomWriter; + + private: + static KWallet::Wallet *mWallet; +}; + +class CreateDisconnectedImapAccount : public CreateImapAccount +{ + public: + enum GroupwareType + { + GroupwareNone, + GroupwareKolab, + GroupwareScalix + }; + + CreateDisconnectedImapAccount( const QString &accountName ); + virtual void apply(); + + void enableLocalSubscription( bool b ) { mLocalSubscription = b; } + void setGroupwareType( GroupwareType type ) { mGroupwareType = type; } + + private: + bool mLocalSubscription; + GroupwareType mGroupwareType; +}; + +class CreateOnlineImapAccount : public CreateImapAccount +{ + public: + CreateOnlineImapAccount( const QString &accountName ); + virtual void apply(); +}; + +#endif diff --git a/wizards/kolab.kcfg b/wizards/kolab.kcfg new file mode 100644 index 000000000..34d7dd71b --- /dev/null +++ b/wizards/kolab.kcfg @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="kolabrc"/> + + <group name="General"> + <entry name="Server" type="String"> + <label>Kolab server name</label> + <default></default> + </entry> + <entry name="User" type="String"> + <label>Kolab user name</label> + <default></default> + </entry> + <entry name="RealName" type="String"> + <label>Real user name</label> + <default></default> + </entry> + <entry name="Password" type="Password"> + <label>Kolab user password</label> + <default></default> + </entry> + <entry name="SavePassword" type="Bool"> + <label>Save Password</label> + <default>false</default> + </entry> + + <entry name="UseOnlineForNonGroupware" type="Bool"> + <label>Use Online IMAP account for non groupware folders</label> + <default>false</default> + </entry> + + <entry name="Kolab1Legacy" type="Bool"> + <label>Enable Kolab 1 Legacy settings</label> + <default>false</default> + </entry> + </group> + + <group name="Constants"> + <entry name="EnableFreeBusy"> + <default>true</default> + </entry> + </group> + + <propagation source="kolabrc/General/Kolab1Legacy" + target="korganizerrc/FreeBusy/FreeBusyPublishAuto" /> + <propagation source="kolabrc/Constants/EnableFreeBusy" + target="korganizerrc/FreeBusy/FreeBusyRetrieveAuto" /> + + <propagation source="kolabrc/General/User" + target="korganizerrc/FreeBusy/FreeBusyPublishUser" /> + <propagation source="kolabrc/General/Password" + target="korganizerrc/FreeBusy/FreeBusyPublishPassword" + hidevalue="true" /> + <propagation source="kolabrc/General/SavePassword" + target="korganizerrc/FreeBusy/FreeBusyPublishSavePassword" /> + + <propagation source="kolabrc/General/User" + target="korganizerrc/FreeBusy/FreeBusyRetrieveUser" /> + <propagation source="kolabrc/General/Password" + target="korganizerrc/FreeBusy/FreeBusyRetrievePassword" + hidevalue="true" /> + <propagation source="kolabrc/General/SavePassword" + target="korganizerrc/FreeBusy/FreeBusyRetrieveSavePassword" /> + +</kcfg> diff --git a/wizards/kolabconfig.kcfgc b/wizards/kolabconfig.kcfgc new file mode 100644 index 000000000..165cd6d48 --- /dev/null +++ b/wizards/kolabconfig.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for kconfig_compiler +File=kolab.kcfg +ClassName=KolabConfig +Singleton=true +Mutators=true +#Inherits=KPimPrefs +#IncludeFiles=libkdepim/kpimprefs.h +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/wizards/kolabkmailchanges.cpp b/wizards/kolabkmailchanges.cpp new file mode 100644 index 000000000..cabbc7d71 --- /dev/null +++ b/wizards/kolabkmailchanges.cpp @@ -0,0 +1,168 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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 "kolabkmailchanges.h" + +#include "kolabconfig.h" +#include "kmailchanges.h" + +#include <klocale.h> +#include <kconfig.h> +#include <kdebug.h> + +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 = "TheIMAPResourceStorageFormat"; + c->value = KolabConfig::self()->kolab1Legacy() ? "IcalVcard" : "XML"; + 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 ); + + QString email; + QString defaultDomain = KolabConfig::self()->server(); + 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; + const QString h = user.mid( pos+1 ); + if ( !h.isEmpty() ) + // The user did type in a domain on the email address. Use that + defaultDomain = h; + } + else + // Construct the email address. And use it for the username also + user = email = user+"@"+KolabConfig::self()->server(); + + if ( KolabConfig::self()->useOnlineForNonGroupware() ) { + c = new KConfigPropagator::ChangeConfig; + c->file = "kmailrc"; + c->group = "IMAP Resource"; + c->name = "ShowOnlyGroupwareFoldersForGroupwareAccount"; + c->value = "true"; + changes.append( c ); + + CreateOnlineImapAccount *account = new CreateOnlineImapAccount( i18n("Kolab Server Mail") ); + + account->setServer( server ); + account->setUser( user ); + account->setPassword( KolabConfig::self()->password() ); + account->setRealName( KolabConfig::self()->realName() ); + account->setEmail( email ); + account->enableSieve( true ); + account->enableSavePassword( KolabConfig::self()->savePassword() ); + account->setEncryption( CreateImapAccount::SSL ); + account->setDefaultDomain( defaultDomain ); + + changes.append( account ); + } + + CreateDisconnectedImapAccount *account = + new CreateDisconnectedImapAccount( i18n("Kolab 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( CreateImapAccount::SSL ); + account->setAuthenticationSend( CreateDisconnectedImapAccount::PLAIN ); + account->setSmtpPort( 465 ); + account->setDefaultDomain( defaultDomain ); + account->enableLocalSubscription( KolabConfig::self()->useOnlineForNonGroupware() ); + + account->setCustomWriter( new KolabCustomWriter ); + + changes.append( account ); +} diff --git a/wizards/kolabkmailchanges.h b/wizards/kolabkmailchanges.h new file mode 100644 index 000000000..b1503f442 --- /dev/null +++ b/wizards/kolabkmailchanges.h @@ -0,0 +1,28 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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. +*/ +#ifndef KOLABKMAILCHANGES_H +#define KOLABKMAILCHANGES_H + +#include <kconfigpropagator.h> + +void createKMailChanges( KConfigPropagator::Change::List& ); + +#endif diff --git a/wizards/kolabmain.cpp b/wizards/kolabmain.cpp new file mode 100644 index 000000000..865dd9bdd --- /dev/null +++ b/wizards/kolabmain.cpp @@ -0,0 +1,57 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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 <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + + KAboutData aboutData( "kolabwizard", I18N_NOOP( "Kolab Configuration Wizard" ), "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + KolabWizard wizard; + + wizard.exec(); +} diff --git a/wizards/kolabwizard.cpp b/wizards/kolabwizard.cpp new file mode 100644 index 000000000..6dc720594 --- /dev/null +++ b/wizards/kolabwizard.cpp @@ -0,0 +1,338 @@ +/* + This file is part of kdepim. + + 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 <qcheckbox.h> +#include <qhbuttongroup.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qwhatsthis.h> + +class SetupLDAPSearchAccount : public KConfigPropagator::Change +{ + public: + SetupLDAPSearchAccount() + : KConfigPropagator::Change( i18n("Setup LDAP Search Account") ) + { + } + + void apply() + { + const QString host = KolabConfig::self()->server(); + + // Figure out the basedn + QString basedn = host; + // If the user gave a full email address, the domain name + // of that overrides the server name for the ldap dn + const QString user = KolabConfig::self()->user(); + int pos = user.find( "@" ); + if ( pos > 0 ) { + const QString 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( QString("SelectedHost%1").arg(i) ) == host ) + hasMyServer = true; + if ( !hasMyServer ) { + c.writeEntry( "NumSelectedHosts", selHosts + 1 ); + c.writeEntry( QString("SelectedHost%1").arg(selHosts), host); + c.writeEntry( QString("SelectedBase%1").arg(selHosts), basedn); + c.writeEntry( QString("SelectedPort%1").arg(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"; + + QString 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 ) +{ + QFrame *page = createWizardPage( i18n("Kolab Server") ); + + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n("Server name:"), page ); + topLayout->addWidget( label, 0, 0 ); + mServerEdit = new KLineEdit( page ); + topLayout->addWidget( mServerEdit, 0, 1 ); + + label = new QLabel( i18n("Email address:"), page ); + topLayout->addWidget( label, 1, 0 ); + mUserEdit = new KLineEdit( page ); + topLayout->addWidget( mUserEdit, 1, 1 ); + QWhatsThis::add(mUserEdit, i18n("Your email address on the Kolab Server. " + "Format: <i>name@example.net</i>")); + + label = new QLabel( i18n("Real name:"), page ); + topLayout->addWidget( label, 2, 0 ); + mRealNameEdit = new KLineEdit( page ); + topLayout->addWidget( mRealNameEdit, 2, 1 ); + + label = new QLabel( i18n("Password:"), page ); + topLayout->addWidget( label, 3, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + topLayout->addWidget( mPasswordEdit, 3, 1 ); + + mSavePasswordCheck = new QCheckBox( i18n("Save password"), page ); + topLayout->addMultiCellWidget( mSavePasswordCheck, 4, 4, 0, 1 ); + + topLayout->setRowStretch( 4, 1 ); + + mUseOnlineForNonGroupwareCheck = new QCheckBox( i18n("Use an online IMAP account for non-groupware folders"), page ); + topLayout->addMultiCellWidget( mUseOnlineForNonGroupwareCheck, 5, 5, 0, 1 ); + topLayout->setRowStretch( 5, 1 ); + + QButtonGroup *bg = new QHButtonGroup(i18n("Server Version"), page ); + QWhatsThis::add( bg, i18n("Choose the version of the Kolab Server you are using.") ); + mKolab1 = new QRadioButton( i18n ( "Kolab 1" ), bg ); + mKolab2 = new QRadioButton( i18n ( "Kolab 2" ), bg ); + topLayout->addMultiCellWidget( bg, 6, 6, 0, 1 ); + + setInitialSize( QSize( 600, 300 ) ); +} + +KolabWizard::~KolabWizard() +{ +} + +QString KolabWizard::validate() +{ + if( mServerEdit->text().isEmpty() || + mUserEdit->text().isEmpty() || + mRealNameEdit->text().isEmpty() || + mPasswordEdit->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + return QString::null; +} + +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() ); +} diff --git a/wizards/kolabwizard.h b/wizards/kolabwizard.h new file mode 100644 index 000000000..ebe1b3569 --- /dev/null +++ b/wizards/kolabwizard.h @@ -0,0 +1,52 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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. +*/ +#ifndef KOLABWIZARD_H +#define KOLABWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KLineEdit; +class QCheckBox; +class QRadioButton; + +class KDE_EXPORT KolabWizard : public KConfigWizard +{ + public: + KolabWizard(); + ~KolabWizard(); + + QString validate(); + void usrReadConfig(); + void usrWriteConfig(); + + private: + KLineEdit *mServerEdit; + KLineEdit *mUserEdit; + KLineEdit *mRealNameEdit; + KLineEdit *mPasswordEdit; + QCheckBox *mSavePasswordCheck; + QRadioButton *mKolab1, *mKolab2; + QCheckBox *mUseOnlineForNonGroupwareCheck; +}; + +#endif diff --git a/wizards/main.cpp b/wizards/main.cpp new file mode 100644 index 000000000..e93a2936c --- /dev/null +++ b/wizards/main.cpp @@ -0,0 +1,40 @@ +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +#include "groupwarewizard.h" + +static const KCmdLineOptions options[] = +{ + { "serverType <type>", "The server type", 0 }, + KCmdLineLastOption +}; + +int main( int argc, char **argv ) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + + KAboutData aboutData( "groupwarewizard", + I18N_NOOP( "KDE-PIM Groupware Configuration Wizard" ), "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + QString serverType; + if ( args->isSet( "serverType" ) ) + serverType = args->getOption( "serverType" ); + + GroupwareWizard wizard( 0 ); + app.setMainWidget( &wizard ); + + wizard.show(); + + app.exec(); +} diff --git a/wizards/overviewpage.cpp b/wizards/overviewpage.cpp new file mode 100644 index 000000000..0a4a5a3fa --- /dev/null +++ b/wizards/overviewpage.cpp @@ -0,0 +1,136 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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 <qbuttongroup.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> + +#include <kaccelmanager.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kpushbutton.h> +#include <kstdguiitem.h> + +#include "egroupwarewizard.h" +#include "kolabwizard.h" +#include "sloxwizard.h" +#include "groupwisewizard.h" +#include "exchangewizard.h" + +#include "overviewpage.h" + +OverViewPage::OverViewPage( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + QGridLayout *layout = new QGridLayout( this, 7, 4, KDialog::marginHint(), + KDialog::spacingHint() ); + + const QString msg = i18n( "KDE Groupware Wizard" ); + QLabel *label = new QLabel( "<qt><b><u><h2>" + msg + "</h2></u></b></qt>" , this ); + layout->addMultiCellWidget( label, 0, 0, 0, 2 ); + + label = new QLabel( this ); + label->setPixmap( KGlobal::iconLoader()->loadIcon( "network", KIcon::Desktop ) ); + layout->addWidget( label, 0, 3 ); + + label = new QLabel( "", this ); + layout->addWidget( label, 1, 0 ); + layout->setRowSpacing( 1, 20 ); + + label = new QLabel( i18n( "Select the type of server you want connect your KDE to:" ), this ); + layout->addMultiCellWidget( label, 2, 2, 0, 3 ); + + QPushButton *button = new QPushButton( i18n("eGroupware"), this ); + layout->addMultiCellWidget( button, 3, 3, 0, 3 ); + connect( button, SIGNAL( clicked() ), SLOT( showWizardEGroupware() ) ); + + // FIXME: Maybe hyperlinks would be better than buttons. + + button = new QPushButton( i18n("Kolab"), this ); + layout->addMultiCellWidget( button, 4, 4, 0, 3 ); + connect( button, SIGNAL( clicked() ), SLOT( showWizardKolab() ) ); + + button = new QPushButton( i18n("SUSE Linux Openexchange (SLOX)"), this ); + layout->addMultiCellWidget( button, 5, 5, 0, 3 ); + connect( button, SIGNAL( clicked() ), SLOT( showWizardSlox() ) ); + + button = new QPushButton( i18n("Novell GroupWise"), this ); + layout->addMultiCellWidget( button, 6, 6, 0, 3 ); + connect( button, SIGNAL( clicked() ), SLOT( showWizardGroupwise() ) ); + + button = new QPushButton( i18n("Microsoft Exchange"), this ); + button->hide(); // not quite ready yet + layout->addMultiCellWidget( button, 7, 7, 0, 3 ); + connect( button, SIGNAL( clicked() ), SLOT( showWizardExchange() ) ); + + + QFrame *frame = new QFrame( this ); + frame->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + layout->addMultiCellWidget( frame, 8, 8, 0, 3 ); + + QPushButton *cancelButton = new KPushButton( KStdGuiItem::close(), this ); + layout->addWidget( cancelButton, 9, 3 ); + + connect( cancelButton, SIGNAL( clicked() ), this, SIGNAL( cancel() ) ); + + layout->setRowStretch( 8, 1 ); + + KAcceleratorManager::manage( this ); +} + +OverViewPage::~OverViewPage() +{ +} + +void OverViewPage::showWizardEGroupware() +{ + EGroupwareWizard wizard; + wizard.exec(); +} + +void OverViewPage::showWizardKolab() +{ + KolabWizard wizard; + wizard.exec(); +} + +void OverViewPage::showWizardSlox() +{ + SloxWizard wizard; + wizard.exec(); +} + +void OverViewPage::showWizardGroupwise() +{ + GroupwiseWizard wizard; + wizard.exec(); +} + +void OverViewPage::showWizardExchange() +{ + ExchangeWizard wizard; + wizard.exec(); +} + +#include "overviewpage.moc" diff --git a/wizards/overviewpage.h b/wizards/overviewpage.h new file mode 100644 index 000000000..8c51bfb9b --- /dev/null +++ b/wizards/overviewpage.h @@ -0,0 +1,46 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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. +*/ + +#ifndef OVERVIEWPAGE_H +#define OVERVIEWPAGE_H + +#include <qwidget.h> + +class OverViewPage : public QWidget +{ + Q_OBJECT + + public: + OverViewPage( QWidget *parent, const char *name = 0 ); + ~OverViewPage(); + + private slots: + void showWizardEGroupware(); + void showWizardKolab(); + void showWizardSlox(); + void showWizardGroupwise(); + void showWizardExchange(); + + signals: + void cancel(); +}; + +#endif diff --git a/wizards/scalix.kcfg b/wizards/scalix.kcfg new file mode 100644 index 000000000..6efe9cda9 --- /dev/null +++ b/wizards/scalix.kcfg @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="scalixrc"/> + + <group name="General"> + <entry name="Server" type="String"> + <default></default> + </entry> + <entry name="User" type="String"> + <default></default> + </entry> + <entry name="RealName" type="String"> + <default></default> + </entry> + <entry name="EMail" type="String"> + <default></default> + </entry> + <entry name="Password" type="Password"> + <default></default> + </entry> + <entry name="SavePassword" type="Bool"> + <default>false</default> + </entry> + </group> + <group name="IMAP"> + <entry name="Security" type="Enum"> + <choices> + <choice name="None"/> + <choice name="TLS"/> + <choice name="SSL"/> + </choices> + <default>None</default> + </entry> + <entry name="Authentication" type="Enum"> + <choices> + <choice name="Password"/> + <choice name="NTLM_SPA"/> + <choice name="GSSAPI"/> + <choice name="DIGEST_MD5"/> + <choice name="CRAM_MD5"/> + </choices> + <default>Password</default> + </entry> + </group> +</kcfg> diff --git a/wizards/scalixconfig.kcfgc b/wizards/scalixconfig.kcfgc new file mode 100644 index 000000000..f4893ca07 --- /dev/null +++ b/wizards/scalixconfig.kcfgc @@ -0,0 +1,9 @@ +# Code generation options for kconfig_compiler +File=scalix.kcfg +ClassName=ScalixConfig +Singleton=true +Mutators=true +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/wizards/scalixkmailchanges.cpp b/wizards/scalixkmailchanges.cpp new file mode 100644 index 000000000..36099903f --- /dev/null +++ b/wizards/scalixkmailchanges.cpp @@ -0,0 +1,171 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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 "scalixkmailchanges.h" + +#include "scalixconfig.h" +#include "kmailchanges.h" + +#include <klocale.h> +#include <kconfig.h> +#include <kdebug.h> + +class ScalixCustomWriter : 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 ) ); + c.writeEntry( "HideGroupwareFolders", false ); + } + 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 = "TheIMAPResourceStorageFormat"; + c->value = "IcalVcard"; + changes.append( c ); + + c = new KConfigPropagator::ChangeConfig; + c->file = "kmailrc"; + c->group = "IMAP Resource"; + c->name = "Folder Language"; + c->value = "0"; + changes.append( c ); + + // Don't show the account wizard as we created an account already + c = new KConfigPropagator::ChangeConfig; + c->file = "kmailrc"; + c->group = "AccountWizard"; + c->name = "ShowOnStartup"; + c->value = "false"; + changes.append( c ); + + CreateDisconnectedImapAccount *account = + new CreateDisconnectedImapAccount( i18n("Scalix Server") ); + + account->setServer( ScalixConfig::self()->server() ); + account->setUser( ScalixConfig::self()->user() ); + account->setPassword( ScalixConfig::self()->password() ); + account->setRealName( ScalixConfig::self()->realName() ); + account->setEmail( ScalixConfig::self()->eMail() ); + if ( ScalixConfig::self()->security() == ScalixConfig::None ) + account->setPort( 143 ); + else + account->setPort( 993 ); + + account->enableSieve( false ); + account->enableSavePassword( ScalixConfig::self()->savePassword() ); + + switch ( ScalixConfig::self()->security() ) { + case ScalixConfig::None: + account->setEncryption( CreateImapAccount::None ); + break; + case ScalixConfig::TLS: + account->setEncryption( CreateImapAccount::TLS ); + break; + case ScalixConfig::SSL: + account->setEncryption( CreateImapAccount::SSL ); + break; + } + + switch ( ScalixConfig::self()->authentication() ) { + case ScalixConfig::Password: + account->setAuthentication( CreateImapAccount::NONE ); + break; + case ScalixConfig::NTLM_SPA: + account->setAuthentication( CreateImapAccount::NTLM_SPA ); + break; + case ScalixConfig::GSSAPI: + account->setAuthentication( CreateImapAccount::GSSAPI ); + break; + case ScalixConfig::DIGEST_MD5: + account->setAuthentication( CreateImapAccount::DIGEST_MD5 ); + break; + case ScalixConfig::CRAM_MD5: + account->setAuthentication( CreateImapAccount::CRAM_MD5 ); + break; + } + + account->setAuthenticationSend( CreateDisconnectedImapAccount::PLAIN ); + account->setSmtpPort( 465 ); + account->setDefaultDomain( ScalixConfig::self()->server() ); + account->enableLocalSubscription( false ); + account->setGroupwareType( CreateDisconnectedImapAccount::GroupwareScalix ); + + account->setCustomWriter( new ScalixCustomWriter ); + + changes.append( account ); +} diff --git a/wizards/scalixkmailchanges.h b/wizards/scalixkmailchanges.h new file mode 100644 index 000000000..b746a01af --- /dev/null +++ b/wizards/scalixkmailchanges.h @@ -0,0 +1,28 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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. +*/ +#ifndef SCALIXKMAILCHANGES_H +#define SCALIXKMAILCHANGES_H + +#include <kconfigpropagator.h> + +void createKMailChanges( KConfigPropagator::Change::List& ); + +#endif diff --git a/wizards/scalixmain.cpp b/wizards/scalixmain.cpp new file mode 100644 index 000000000..4884b19a9 --- /dev/null +++ b/wizards/scalixmain.cpp @@ -0,0 +1,57 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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 "scalixwizard.h" + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + + KAboutData aboutData( "scalixwizard", I18N_NOOP( "Scalix Configuration Wizard" ), "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + ScalixWizard wizard; + + wizard.exec(); +} diff --git a/wizards/scalixwizard.cpp b/wizards/scalixwizard.cpp new file mode 100644 index 000000000..058ff84dd --- /dev/null +++ b/wizards/scalixwizard.cpp @@ -0,0 +1,546 @@ +/* + This file is part of kdepim. + + 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 "scalixwizard.h" +#include "scalixconfig.h" + +#include "scalixkmailchanges.h" + +#include "kresources/scalix/kcal/resourcescalix.h" +#include "kresources/scalix/kabc/resourcescalix.h" + +#include <libkcal/resourcecalendar.h> +#include <kabc/resource.h> + +#include <dcopref.h> +#include <kcombobox.h> +#include <kdcopservicestarter.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstringhandler.h> + +#include <qapplication.h> +#include <qcheckbox.h> +#include <qhbuttongroup.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qwhatsthis.h> + +#include <unistd.h> + +class SetupLDAPSearchAccount : public KConfigPropagator::Change +{ + public: + SetupLDAPSearchAccount() + : KConfigPropagator::Change( i18n("Setup LDAP Search Account") ) + { + } + + void apply() + { + const QString host = ScalixConfig::self()->server(); + + QString basedn( "o=Scalix" ); + + { // while we're here, write default domain + KConfig c( "kmailrc" ); + c.setGroup( "General" ); + c.writeEntry( "Default domain", basedn ); + } + + // 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( QString("SelectedHost%1").arg(i) ) == host ) + hasMyServer = true; + if ( !hasMyServer ) { + c.writeEntry( "NumSelectedHosts", selHosts + 1 ); + c.writeEntry( QString("SelectedHost%1").arg(selHosts), host); + c.writeEntry( QString("SelectedBase%1").arg(selHosts), basedn); + c.writeEntry( QString("SelectedPort%1").arg(selHosts), "389"); + } + } + +}; + +class SetupScalixAdmin : public KConfigPropagator::Change +{ + public: + SetupScalixAdmin() + : KConfigPropagator::Change( i18n( "Setup ScalixAdmin Account" ) ) + { + } + + void apply() + { + KConfig c( "scalixadminrc" ); + c.setGroup( "Account" ); + + c.writeEntry( "user", ScalixConfig::self()->user() ); + c.writeEntry( "pass", KStringHandler::obscure( ScalixConfig::self()->password() ) ); + c.writeEntry( "host", ScalixConfig::self()->server() ); + if ( ScalixConfig::self()->security() == ScalixConfig::None ) + c.writeEntry( "port", 143 ); + else + c.writeEntry( "port", 993 ); + + switch ( ScalixConfig::self()->security() ) { + case ScalixConfig::None: + c.writeEntry( "use-ssl", "false" ); + c.writeEntry( "use-tls", "false" ); + break; + case ScalixConfig::TLS: + c.writeEntry( "use-ssl", "false" ); + c.writeEntry( "use-tls", "true" ); + break; + case ScalixConfig::SSL: + c.writeEntry( "use-ssl", "true" ); + c.writeEntry( "use-tls", "false" ); + break; + } + switch ( ScalixConfig::self()->authentication() ) { + case ScalixConfig::Password: + c.writeEntry( "auth", "*" ); + break; + case ScalixConfig::NTLM_SPA: + c.writeEntry( "auth", "NTLM" ); + break; + case ScalixConfig::GSSAPI: + c.writeEntry( "auth", "GSSAPI" ); + break; + case ScalixConfig::DIGEST_MD5: + c.writeEntry( "auth", "DIGEST-MD5" ); + break; + case ScalixConfig::CRAM_MD5: + c.writeEntry( "auth", "CRAM-MD5" ); + break; + } + + c.setGroup( "LDAP" ); + + c.writeEntry( "host", ScalixConfig::self()->server() ); + c.writeEntry( "port", "389" ); + c.writeEntry( "base", "o=Scalix" ); + c.writeEntry( "bindDn", "" ); + c.writeEntry( "password", "" ); + } +}; + +class CreateCalendarImapResource : public KConfigPropagator::Change +{ + public: + CreateCalendarImapResource() + : KConfigPropagator::Change( i18n("Create Calendar IMAP Resource") ) + { + } + + void apply() + { + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + KCal::ResourceScalix *r = new KCal::ResourceScalix( 0 ); + r->setResourceName( i18n("Scalix 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::ResourceScalix *r = new KABC::ResourceScalix( 0 ); + r->setResourceName( i18n("Scalix Server") ); + m.add( r ); + m.setStandardResource( r ); + m.writeConfig(); + } + +}; + +class SynchronizeScalixAccount : public KConfigPropagator::Change +{ + public: + SynchronizeScalixAccount() + : KConfigPropagator::Change( i18n("Synchronize Scalix Account") ) + { + } + + void apply() + { + QMessageBox *msg = new QMessageBox( qApp->mainWidget() ); + msg->setText( "Preparing initial synchronization with Scalix server..." ); + msg->show(); + qApp->processEvents(); + sleep( 1 ); + qApp->processEvents(); + + QString error; + QCString dcopService; + int result = KDCOPServiceStarter::self()-> + findServiceFor( "DCOP/ResourceBackend/IMAP", QString::null, + QString::null, &error, &dcopService ); + if ( result != 0 ) { + KMessageBox::error( 0, i18n( "Unable to start KMail to trigger initial synchronization with Scalix server" ) ); + delete msg; + return; + } + + DCOPRef ref( dcopService, "KMailIface" ); + + // loop until dcop iface is set up correctly + QStringList list; + while ( list.isEmpty() ) { + ref.call( "accounts()" ).get( list ); + } + + ref.call( "checkAccount(QString)", i18n( "Scalix Server" ) ); + + // ugly hack, but kmail needs a second before accepting the second dcop call + sleep( 5 ); + ref.call( "checkAccount(QString)", i18n( "Scalix Server" ) ); + + delete msg; + } + +}; + + +class ScalixPropagator : public KConfigPropagator +{ + public: + ScalixPropagator() + : KConfigPropagator( ScalixConfig::self(), "scalix.kcfg" ) + { + } + + protected: + void addKorganizerChanges( Change::List &changes ) + { + KURL freeBusyBaseUrl = "scalix://" + ScalixConfig::self()->server() + "/freebusy/"; + freeBusyBaseUrl.setUser( ScalixConfig::self()->user() ); + + ChangeConfig *c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyRetrieveUrl"; + c->value = freeBusyBaseUrl.url() + ScalixConfig::self()->eMail(); + changes.append( c ); + + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyRetrieveUser"; + c->value = ScalixConfig::self()->user(); + changes.append( c ); + + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyRetrievePassword"; + c->value = ScalixConfig::self()->password(); + changes.append( c ); + + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyPublishUrl"; + c->value = freeBusyBaseUrl.url() + "Calendar/" + ScalixConfig::self()->eMail(); + changes.append( c ); + + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyPublishUser"; + c->value = ScalixConfig::self()->user(); + changes.append( c ); + + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyPublishPassword"; + c->value = ScalixConfig::self()->password(); + 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 ); + + // Disable hostname checking + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyCheckHostname"; + c->value = "false"; + changes.append( c ); + + // Enable automatic retrieval + c = new ChangeConfig; + c->file = "korganizerrc"; + c->group = "FreeBusy"; + c->name = "FreeBusyRetrieveAuto"; + 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() == "scalix" ) break; + } + if ( it == m.end() ) { + changes.append( new CreateCalendarImapResource ); + changes.append( new CreateContactImapResource ); + } + + changes.append( new SetupScalixAdmin ); + + changes.append( new SynchronizeScalixAccount ); + } +}; + +ScalixWizard::ScalixWizard() : KConfigWizard( new ScalixPropagator ) +{ + QFrame *page = createWizardPage( i18n("Scalix Server") ); + + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n( "Full name:" ), page ); + topLayout->addWidget( label, 0, 0 ); + mRealNameEdit = new KLineEdit( page ); + topLayout->addWidget( mRealNameEdit, 0, 1 ); + label->setBuddy( mRealNameEdit ); + QWhatsThis::add( mRealNameEdit, i18n( "Your full name. " + "Example: <i>Joe User</i>" ) ); + + label = new QLabel( i18n( "Email address:" ), page ); + topLayout->addWidget( label, 1, 0 ); + mEMailEdit = new KLineEdit( page ); + topLayout->addWidget( mEMailEdit, 1, 1 ); + label->setBuddy( mEMailEdit ); + QWhatsThis::add( mEMailEdit, i18n( "Your email address on the Scalix Server. " + "Example: <i>name@crossplatform.com</i>" ) ); + + label = new QLabel( i18n( "Server:" ), page ); + topLayout->addWidget( label, 2, 0 ); + mServerEdit = new KLineEdit( page ); + topLayout->addWidget( mServerEdit, 2, 1 ); + label->setBuddy( mServerEdit ); + QWhatsThis::add( mServerEdit, i18n( "The name or IP of the Scalix Server. " + "Example: <i>scalix.domain.com</i>" ) ); + + label = new QLabel( i18n("Username:"), page ); + topLayout->addWidget( label, 3, 0 ); + mUserEdit = new KLineEdit( page ); + topLayout->addWidget( mUserEdit, 3, 1 ); + label->setBuddy( mUserEdit ); + QWhatsThis::add( mUserEdit, i18n( "The user respectively login name. " + "Example: <i>joe</i>" ) ); + + label = new QLabel( i18n("Password:"), page ); + topLayout->addWidget( label, 4, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + topLayout->addWidget( mPasswordEdit, 4, 1 ); + label->setBuddy( mPasswordEdit ); + QWhatsThis::add( mPasswordEdit, i18n( "The password to your login." ) ); + + mSavePasswordCheck = new QCheckBox( i18n("Save password"), page ); + topLayout->addMultiCellWidget( mSavePasswordCheck, 5, 5, 0, 1 ); + QWhatsThis::add( mSavePasswordCheck, i18n( "Shall the password be saved in KWallet?." ) ); + + label = new QLabel( i18n( "Use Secure Connection:" ), page ); + topLayout->addWidget( label, 6, 0 ); + mSecurity = new KComboBox( page ); + mSecurity->insertItem( i18n( "No encryption" ) ); + mSecurity->insertItem( i18n( "TLS encryption" ) ); + mSecurity->insertItem( i18n( "SSL encryption" ) ); + topLayout->addWidget( mSecurity, 6, 1 ); + label->setBuddy( mSecurity ); + QWhatsThis::add( mSecurity, i18n( "Choose the encryption type that is supported by your server." ) ); + + label = new QLabel( i18n( "Authentication Type:" ), page ); + topLayout->addWidget( label, 7, 0 ); + mAuthentication = new KComboBox( page ); + mAuthentication->insertItem( i18n( "Password" ) ); + mAuthentication->insertItem( i18n( "NTLM / SPA" ) ); + mAuthentication->insertItem( i18n( "GSSAPI" ) ); + mAuthentication->insertItem( i18n( "DIGEST-MD5" ) ); + mAuthentication->insertItem( i18n( "CRAM-MD5" ) ); + topLayout->addWidget( mAuthentication, 7, 1 ); + label->setBuddy( mAuthentication ); + QWhatsThis::add( mAuthentication, i18n( "Choose the authentication type that is supported by your server." ) ); + + topLayout->setRowStretch( 8, 1 ); + + //DF: I don't see the point in showing the user those pages. + //They are very 'internal' and of no use to anyone other than developers. + //(This is even more true for the rules page. The changes page is sort of OK) + + setupRulesPage(); + setupChangesPage(); + + setInitialSize( QSize( 600, 300 ) ); +} + +ScalixWizard::~ScalixWizard() +{ +} + +QString ScalixWizard::validate() +{ + if ( mRealNameEdit->text().isEmpty() || + mEMailEdit->text().isEmpty() || + mServerEdit->text().isEmpty() || + mUserEdit->text().isEmpty() || + mPasswordEdit->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + + return QString::null; +} + +void ScalixWizard::usrReadConfig() +{ + mRealNameEdit->setText( ScalixConfig::self()->realName() ); + mEMailEdit->setText( ScalixConfig::self()->eMail() ); + mServerEdit->setText( ScalixConfig::self()->server() ); + mUserEdit->setText( ScalixConfig::self()->user() ); + mPasswordEdit->setText( ScalixConfig::self()->password() ); + mSavePasswordCheck->setChecked( ScalixConfig::self()->savePassword() ); + + switch ( ScalixConfig::self()->security() ) { + default: + case ScalixConfig::None: + mSecurity->setCurrentItem( 0 ); + break; + case ScalixConfig::TLS: + mSecurity->setCurrentItem( 1 ); + break; + case ScalixConfig::SSL: + mSecurity->setCurrentItem( 2 ); + break; + } + + switch ( ScalixConfig::self()->authentication() ) { + default: + case ScalixConfig::Password: + mAuthentication->setCurrentItem( 0 ); + break; + case ScalixConfig::NTLM_SPA: + mAuthentication->setCurrentItem( 1 ); + break; + case ScalixConfig::GSSAPI: + mAuthentication->setCurrentItem( 2 ); + break; + case ScalixConfig::DIGEST_MD5: + mAuthentication->setCurrentItem( 3 ); + break; + case ScalixConfig::CRAM_MD5: + mAuthentication->setCurrentItem( 4 ); + break; + } +} + +void ScalixWizard::usrWriteConfig() +{ + ScalixConfig::self()->setRealName( mRealNameEdit->text() ); + ScalixConfig::self()->setEMail( mEMailEdit->text() ); + ScalixConfig::self()->setServer( mServerEdit->text() ); + ScalixConfig::self()->setUser( mUserEdit->text() ); + ScalixConfig::self()->setPassword( mPasswordEdit->text() ); + ScalixConfig::self()->setSavePassword( mSavePasswordCheck->isChecked() ); + + switch ( mSecurity->currentItem() ) { + default: + case 0: + ScalixConfig::self()->setSecurity( ScalixConfig::None ); + break; + case 1: + ScalixConfig::self()->setSecurity( ScalixConfig::TLS ); + break; + case 2: + ScalixConfig::self()->setSecurity( ScalixConfig::SSL ); + break; + } + + switch ( mAuthentication->currentItem() ) { + default: + case 0: + ScalixConfig::self()->setAuthentication( ScalixConfig::Password ); + break; + case 1: + ScalixConfig::self()->setAuthentication( ScalixConfig::NTLM_SPA ); + break; + case 2: + ScalixConfig::self()->setAuthentication( ScalixConfig::GSSAPI ); + break; + case 3: + ScalixConfig::self()->setAuthentication( ScalixConfig::DIGEST_MD5 ); + break; + case 4: + ScalixConfig::self()->setAuthentication( ScalixConfig::CRAM_MD5 ); + break; + } +} diff --git a/wizards/scalixwizard.h b/wizards/scalixwizard.h new file mode 100644 index 000000000..f2394d7b3 --- /dev/null +++ b/wizards/scalixwizard.h @@ -0,0 +1,53 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk> + + 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. +*/ +#ifndef SCALIXWIZARD_H +#define SCALIXWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KComboBox; +class KLineEdit; +class QCheckBox; + +class KDE_EXPORT ScalixWizard : public KConfigWizard +{ + public: + ScalixWizard(); + ~ScalixWizard(); + + QString validate(); + void usrReadConfig(); + void usrWriteConfig(); + + private: + KLineEdit *mServerEdit; + KLineEdit *mUserEdit; + KLineEdit *mEMailEdit; + KLineEdit *mRealNameEdit; + KLineEdit *mPasswordEdit; + QCheckBox *mSavePasswordCheck; + KComboBox *mSecurity; + KComboBox *mAuthentication; +}; + +#endif diff --git a/wizards/servertype.h b/wizards/servertype.h new file mode 100644 index 000000000..7062191db --- /dev/null +++ b/wizards/servertype.h @@ -0,0 +1,125 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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. +*/ + +#ifndef SERVERTYPE +#define SERVERTYPE + +#include <kconfigpropagator.h> +#include <klibloader.h> + +#include <qobject.h> + +class ServerType : public QObject +{ + public: + class ConnectionInfo + { + public: + /** + The unique identifier + */ + QString uid; + + /** + The user visible name + */ + QString name; + + /** + Whether the connection is active or passive + */ + bool active; + }; + + /** + This map contains the uids and the user visible names + of a server type. + */ + typedef QValueList<ConnectionInfo> ConnectionInfoList; + + ServerType( QObject *parent, const char *name ):QObject(parent, name) {} + virtual ~ServerType() {} + + /** + Returns the connection information of the server type. + */ + virtual ConnectionInfoList connectionInfo() const = 0; + + /** + This method is called whenever the user wants to add a new + connection. + */ + virtual void addConnection() = 0; + + /** + This method is called whenever the user wants to edit an existing + connection. + + @param uid The uid of the resource. + */ + virtual void editConnection( const QString& uid ) = 0; + + /** + This method is called whenever the user wants to remove an existing + connection. + + @param uid The uid of the resource. + */ + virtual void deleteConnection( const QString& uid ) = 0; + + /** + This method is called whenever the user marks an existing + connection as active or inactive. + + @param uid The uid of the resource. + @param active Whether the connection shall be set active or not. + */ + virtual void activateConnection( const QString& uid, bool active ) = 0; + + virtual KConfigPropagator::Change::List changes() = 0; +}; + + +/** + A factory class which loads/creates ServerType objects for us. + */ +class ServerTypeFactory : public KLibFactory +{ + public: + virtual ServerType *serverType( QObject *parent, const char *name = 0 ) = 0; + + /** + Returns the identifier. + */ + virtual QString identifier() const = 0; + + /** + Returns the i18n'ed name. + */ + virtual QString title() const = 0; + + protected: + virtual QObject* createObject( QObject*, const char*, + const char*, const QStringList & ) + { return 0; } +}; + +#endif diff --git a/wizards/servertypemanager.cpp b/wizards/servertypemanager.cpp new file mode 100644 index 000000000..e41ca60d6 --- /dev/null +++ b/wizards/servertypemanager.cpp @@ -0,0 +1,91 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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 <kstaticdeleter.h> + +#include "egroupwarehandler.h" + +#include "servertypemanager.h" + +ServerTypeManager* ServerTypeManager::mSelf = 0; +static KStaticDeleter<ServerTypeManager> serverManagerDeleter; + +ServerTypeManager::ServerTypeManager( QObject *parent, const char *name ) + : QObject( parent, name ) +{ + loadPlugins(); +} + +ServerTypeManager::~ServerTypeManager() +{ +} + +ServerTypeManager* ServerTypeManager::self() +{ + if ( !mSelf ) + serverManagerDeleter.setObject( mSelf, new ServerTypeManager( 0, + "ServerTypeManager" ) ); + + return mSelf; +} + +QStringList ServerTypeManager::identifiers() const +{ + return mServerTypeFactoryMap.keys(); +} + +QString ServerTypeManager::title( const QString& identifier ) const +{ + ServerTypeFactoryMap::ConstIterator it = mServerTypeFactoryMap.find( identifier ); + if ( it == mServerTypeFactoryMap.end() ) + return QString::null; + else + return it.data()->title(); +} + +ServerType* ServerTypeManager::serverType( const QString& identifier ) +{ + ServerTypeMap::ConstIterator serverIt = mServerTypeMap.find( identifier ); + if ( serverIt == mServerTypeMap.end() ) { // none server type loaded yet + ServerTypeFactoryMap::Iterator it = mServerTypeFactoryMap.find( identifier ); + if ( it == mServerTypeFactoryMap.end() ) // no factory for this type + return 0; + + ServerType *serverType = it.data()->serverType( 0, identifier.latin1() ); + if ( !serverType ) + return 0; + + mServerTypeMap.insert( identifier, serverType ); + } + + return mServerTypeMap[ identifier ]; +} + +void ServerTypeManager::loadPlugins() +{ + mServerTypeMap.clear(); + mServerTypeFactoryMap.clear(); + + ServerTypeFactory *factory = new EGroupwareHandlerFactory(); + mServerTypeFactoryMap.insert( factory->identifier(), factory ); +} + +#include "servertypemanager.moc" diff --git a/wizards/servertypemanager.h b/wizards/servertypemanager.h new file mode 100644 index 000000000..b2b029500 --- /dev/null +++ b/wizards/servertypemanager.h @@ -0,0 +1,71 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Tobias Koenig <tokoe@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. +*/ + +#ifndef SERVERTYPEMANAGER_H +#define SERVERTYPEMANAGER_H + +#include <qobject.h> + +#include "servertype.h" + +class ServerTypeManager : public QObject +{ + Q_OBJECT + + public: + static ServerTypeManager* self(); + + ~ServerTypeManager(); + + /** + Returns the list of identifiers of all available + server types. + */ + QStringList identifiers() const; + + /** + Returns the i18n'ed name of a server type. + + @param The identifier of the server type. + */ + QString title( const QString& ) const; + + /** + Returns a pointer to the server type with the given + identifier or 0 when it doesn't exist. + */ + ServerType* serverType( const QString& ); + + private: + typedef QMap<QString, ServerType*> ServerTypeMap; + typedef QMap<QString, ServerTypeFactory*> ServerTypeFactoryMap; + + void loadPlugins(); + + ServerTypeManager( QObject *parent, const char *name = 0 ); + + static ServerTypeManager* mSelf; + + ServerTypeMap mServerTypeMap; + ServerTypeFactoryMap mServerTypeFactoryMap; +}; + +#endif diff --git a/wizards/slox.kcfg b/wizards/slox.kcfg new file mode 100644 index 000000000..4f27f8a3b --- /dev/null +++ b/wizards/slox.kcfg @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="sloxrc"/> + + <group name="General"> + <entry name="Server" type="String"> + <label>Server name</label> + <default></default> + </entry> + <entry name="User" type="String"> + <label>User name</label> + <default></default> + </entry> + <entry name="Password" type="Password"> + <label>User password</label> + <default></default> + </entry> + <entry name="SavePassword" type="Bool"> + <label>Save Password</label> + <default>true</default> + </entry> + <entry name="UseHttps" type="Bool"> + <label>Use HTTPS</label> + <default>false</default> + </entry> + <entry name="LogFile" type="String"> + <label>Log File</label> + </entry> + </group> + + <group name="Resources"> + <entry name="KcalResource" type="String"> + <label>Id of KCal resource</label> + </entry> + <entry name="KabcResource" type="String"> + <label>Id of KABC resource</label> + </entry> + </group> + + <group name="Constants"> + <entry name="EnableFreeBusy"> + <default>true</default> + </entry> + </group> + + <propagation source="sloxrc/Constants/EnableFreeBusy" + target="korganizerrc/FreeBusy/FreeBusyRetrieveAuto" /> + +</kcfg> diff --git a/wizards/sloxconfig.kcfgc b/wizards/sloxconfig.kcfgc new file mode 100644 index 000000000..fa03da146 --- /dev/null +++ b/wizards/sloxconfig.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for kconfig_compiler +File=slox.kcfg +ClassName=SloxConfig +Singleton=true +Mutators=true +#Inherits=KPimPrefs +#IncludeFiles=libkdepim/kpimprefs.h +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/wizards/sloxmain.cpp b/wizards/sloxmain.cpp new file mode 100644 index 000000000..3ac84245d --- /dev/null +++ b/wizards/sloxmain.cpp @@ -0,0 +1,57 @@ + /* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "sloxwizard.h" + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> +#include <kglobal.h> +#include <klocale.h> + +static const KCmdLineOptions options[] = +{ + {"verbose", "Verbose output", 0}, + KCmdLineLastOption +}; + +int main(int argc,char **argv) +{ + KLocale::setMainCatalogue( "kdepimwizards" ); + KAboutData aboutData( "sloxwizard", + I18N_NOOP( "SUSE LINUX Openexchange Server Configuration Wizard" ), + "0.1" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + KGlobal::locale()->insertCatalogue( "libkdepim" ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + bool verbose = false; + if ( args->isSet( "verbose" ) ) verbose = true; + + SloxWizard wizard; + + wizard.exec(); +} diff --git a/wizards/sloxwizard.cpp b/wizards/sloxwizard.cpp new file mode 100644 index 000000000..8ac821dbc --- /dev/null +++ b/wizards/sloxwizard.cpp @@ -0,0 +1,291 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "sloxwizard.h" +#include "sloxconfig.h" + +#include "kresources/slox/kabcsloxprefs.h" +#include "kresources/slox/kabcresourceslox.h" +#include "kresources/slox/kcalsloxprefs.h" +#include "kresources/slox/kcalresourceslox.h" + +#include <libkcal/resourcecalendar.h> + +#include <klineedit.h> +#include <klocale.h> + +#include <qlayout.h> +#include <qcheckbox.h> +#include <qlabel.h> + + +QString sloxUrl() +{ + QString url; + + if ( SloxConfig::self()->useHttps() ) url = "https://"; + else url = "http://"; + + url += SloxConfig::self()->server(); + + return url; +} + +class CreateSloxKcalResource : public KConfigPropagator::Change +{ + public: + CreateSloxKcalResource() + : KConfigPropagator::Change( i18n("Create SLOX Calendar Resource") ) + { + } + + void apply() + { + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KURL url( sloxUrl() ); + + KCalResourceSlox *r = new KCalResourceSlox( url ); + r->setResourceName( i18n("Openexchange Server") ); + r->prefs()->setUser( SloxConfig::self()->user() ); + r->prefs()->setPassword( SloxConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + m.add( r ); + m.writeConfig(); + + SloxConfig::self()->setKcalResource( r->identifier() ); + } +}; + +class UpdateSloxKcalResource : public KConfigPropagator::Change +{ + public: + UpdateSloxKcalResource() + : KConfigPropagator::Change( i18n("Update SLOX Calendar Resource") ) + { + } + + void apply() + { + KCal::CalendarResourceManager m( "calendar" ); + m.readConfig(); + + KURL url( sloxUrl() ); + + KCal::CalendarResourceManager::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == SloxConfig::kcalResource() ) { + KCalResourceSlox *r = static_cast<KCalResourceSlox *>( *it ); + r->prefs()->setUrl( url.url() ); + r->prefs()->setUser( SloxConfig::self()->user() ); + r->prefs()->setPassword( SloxConfig::self()->password() ); + r->setSavePolicy( KCal::ResourceCached::SaveDelayed ); + r->setReloadPolicy( KCal::ResourceCached::ReloadInterval ); + r->setReloadInterval( 20 ); + } + } + m.writeConfig(); + } +}; + +class CreateSloxKabcResource : public KConfigPropagator::Change +{ + public: + CreateSloxKabcResource() + : KConfigPropagator::Change( i18n("Create SLOX Addressbook Resource") ) + { + } + + void apply() + { + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + KURL url( sloxUrl() ); + QString user( SloxConfig::self()->user() ); + QString password( SloxConfig::self()->password() ); + + KABC::ResourceSlox *r = new KABC::ResourceSlox( url, user, password ); + r->setResourceName( i18n("Openexchange Server") ); + m.add( r ); + m.writeConfig(); + + SloxConfig::self()->setKabcResource( r->identifier() ); + } +}; + +class UpdateSloxKabcResource : public KConfigPropagator::Change +{ + public: + UpdateSloxKabcResource() + : KConfigPropagator::Change( i18n("Update SLOX Addressbook Resource") ) + { + } + + void apply() + { + KRES::Manager<KABC::Resource> m( "contact" ); + m.readConfig(); + + KURL url( sloxUrl() ); + + KRES::Manager<KABC::Resource>::Iterator it; + for ( it = m.begin(); it != m.end(); ++it ) { + if ( (*it)->identifier() == SloxConfig::kabcResource() ) { + KABC::ResourceSlox *r = static_cast<KABC::ResourceSlox *>( *it ); + r->prefs()->setUrl( url.url() ); + r->prefs()->setUser( SloxConfig::self()->user() ); + r->prefs()->setPassword( SloxConfig::self()->password() ); + } + } + m.writeConfig(); + } +}; + + +class SloxPropagator : public KConfigPropagator +{ + public: + SloxPropagator() + : KConfigPropagator( SloxConfig::self(), "slox.kcfg" ) + { + } + + ~SloxPropagator() + { + SloxConfig::self()->writeConfig(); + } + + protected: + void addCustomChanges( Change::List &changes ) + { + KCal::CalendarResourceManager m1( "calendar" ); + m1.readConfig(); + KCal::CalendarResourceManager::Iterator it; + for ( it = m1.begin(); it != m1.end(); ++it ) { + if ( (*it)->type() == "slox" ) break; + } + if ( it == m1.end() ) { + changes.append( new CreateSloxKcalResource ); + } else { + if ( (*it)->identifier() == SloxConfig::kcalResource() ) { + KCal::SloxPrefs *prefs = static_cast<KCalResourceSlox *>( *it )->prefs(); + if ( prefs->url() != sloxUrl() || + prefs->user() != SloxConfig::user() || + prefs->password() != SloxConfig::password() ) { + changes.append( new UpdateSloxKcalResource ); + } + } + } + + KRES::Manager<KABC::Resource> m2( "contact" ); + m2.readConfig(); + KRES::Manager<KABC::Resource>::Iterator it2; + for ( it2 = m2.begin(); it2 != m2.end(); ++it2 ) { + if ( (*it2)->type() == "slox" ) break; + } + if ( it2 == m2.end() ) { + changes.append( new CreateSloxKabcResource ); + } else { + if ( (*it2)->identifier() == SloxConfig::kabcResource() ) { + KABC::SloxPrefs *prefs = static_cast<KABC::ResourceSlox *>( *it2 )->prefs(); + if ( prefs->url() != sloxUrl() || + prefs->user() != SloxConfig::user() || + prefs->password() != SloxConfig::password() ) { + changes.append( new UpdateSloxKabcResource ); + } + } + } + } +}; + +SloxWizard::SloxWizard() : KConfigWizard( new SloxPropagator ) +{ + QFrame *page = createWizardPage( i18n("SUSE LINUX OpenExchange Server") ); + + QGridLayout *topLayout = new QGridLayout( page ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n("Server name:"), page ); + topLayout->addWidget( label, 0, 0 ); + mServerEdit = new KLineEdit( page ); + topLayout->addWidget( mServerEdit, 0, 1 ); + + label = new QLabel( i18n("User name:"), page ); + topLayout->addWidget( label, 1, 0 ); + mUserEdit = new KLineEdit( page ); + topLayout->addWidget( mUserEdit, 1, 1 ); + + label = new QLabel( i18n("Password:"), page ); + topLayout->addWidget( label, 2, 0 ); + mPasswordEdit = new KLineEdit( page ); + mPasswordEdit->setEchoMode( KLineEdit::Password ); + topLayout->addWidget( mPasswordEdit, 2, 1 ); + + mSavePasswordCheck = new QCheckBox( i18n("Save password"), page ); + topLayout->addMultiCellWidget( mSavePasswordCheck, 3, 3, 0, 1 ); + + mSecureCheck = new QCheckBox( i18n("Encrypt communication with server"), + page ); + topLayout->addMultiCellWidget( mSecureCheck, 4, 4, 0, 1 ); + + topLayout->setRowStretch( 5, 1 ); + + setupRulesPage(); + setupChangesPage(); + + resize( 400, 300 ); +} + +SloxWizard::~SloxWizard() +{ +} + +QString SloxWizard::validate() +{ + KURL server( mServerEdit->text() ); + if ( !server.protocol().isEmpty() || + mServerEdit->text().isEmpty() || + mUserEdit->text().isEmpty() || + mPasswordEdit->text().isEmpty() ) + return i18n( "Please fill in all fields." ); + return QString::null; +} + +void SloxWizard::usrReadConfig() +{ + mServerEdit->setText( SloxConfig::self()->server() ); + mUserEdit->setText( SloxConfig::self()->user() ); + mPasswordEdit->setText( SloxConfig::self()->password() ); + mSavePasswordCheck->setChecked( SloxConfig::self()->savePassword() ); + mSecureCheck->setChecked( SloxConfig::self()->useHttps() ); +} + +void SloxWizard::usrWriteConfig() +{ + SloxConfig::self()->setServer( mServerEdit->text() ); + SloxConfig::self()->setUser( mUserEdit->text() ); + SloxConfig::self()->setPassword( mPasswordEdit->text() ); + SloxConfig::self()->setSavePassword( mSavePasswordCheck->isChecked() ); + SloxConfig::self()->setUseHttps( mSecureCheck->isChecked() ); +} diff --git a/wizards/sloxwizard.h b/wizards/sloxwizard.h new file mode 100644 index 000000000..14f7620dc --- /dev/null +++ b/wizards/sloxwizard.h @@ -0,0 +1,47 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef SLOXWIZARD_H +#define SLOXWIZARD_H + +#include <kconfigwizard.h> +#include <kdepimmacros.h> + +class KLineEdit; +class QCheckBox; + +class KDE_EXPORT SloxWizard : public KConfigWizard +{ + public: + SloxWizard(); + ~SloxWizard(); + + QString validate(); + void usrReadConfig(); + void usrWriteConfig(); + + private: + KLineEdit *mServerEdit; + KLineEdit *mUserEdit; + KLineEdit *mPasswordEdit; + QCheckBox *mSavePasswordCheck; + QCheckBox *mSecureCheck; +}; + +#endif |