summaryrefslogtreecommitdiffstats
path: root/korn
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /korn
downloadtdepim-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 'korn')
-rw-r--r--korn/AUTHORS4
-rw-r--r--korn/ChangeLog38
-rw-r--r--korn/KOrn.desktop78
-rw-r--r--korn/Makefile.am124
-rw-r--r--korn/account_input.cpp173
-rw-r--r--korn/account_input.h310
-rw-r--r--korn/accountmanager.cpp268
-rw-r--r--korn/accountmanager.h155
-rw-r--r--korn/boxcontainer.cpp83
-rw-r--r--korn/boxcontainer.h103
-rw-r--r--korn/boxcontaineritem.cpp443
-rw-r--r--korn/boxcontaineritem.h236
-rw-r--r--korn/dcop_proto.cpp62
-rw-r--r--korn/dcop_proto.h117
-rw-r--r--korn/dcopdrop.cpp201
-rw-r--r--korn/dcopdrop.h190
-rw-r--r--korn/dcopdropif.cpp46
-rw-r--r--korn/dcopdropif.h71
-rw-r--r--korn/dockedcontainer.cpp37
-rw-r--r--korn/dockedcontainer.h45
-rw-r--r--korn/dockeditem.cpp92
-rw-r--r--korn/dockeditem.h96
-rw-r--r--korn/hi16-app-korn.pngbin0 -> 988 bytes
-rw-r--r--korn/hi32-app-korn.pngbin0 -> 2689 bytes
-rw-r--r--korn/hi48-app-korn.pngbin0 -> 4869 bytes
-rw-r--r--korn/hvcontainer.cpp52
-rw-r--r--korn/hvcontainer.h58
-rw-r--r--korn/hvitem.cpp82
-rw-r--r--korn/hvitem.h80
-rw-r--r--korn/imap_proto.cpp101
-rw-r--r--korn/imap_proto.h143
-rw-r--r--korn/imaps_proto.h40
-rw-r--r--korn/intid.cpp25
-rw-r--r--korn/intid.h52
-rw-r--r--korn/kconf_update/Makefile.am12
-rw-r--r--korn/kconf_update/korn-3-4-config_change.cpp261
-rw-r--r--korn/kconf_update/korn-3-4-config_change.upd3
-rw-r--r--korn/kconf_update/korn-3-5-metadata-update.pl43
-rw-r--r--korn/kconf_update/korn-3-5-ssl-update.pl39
-rw-r--r--korn/kconf_update/korn-3-5-update.upd10
-rw-r--r--korn/keditlistboxman.cpp301
-rw-r--r--korn/keditlistboxman.h147
-rw-r--r--korn/kio.cpp561
-rw-r--r--korn/kio.h207
-rw-r--r--korn/kio_count.cpp330
-rw-r--r--korn/kio_count.h81
-rw-r--r--korn/kio_delete.cpp201
-rw-r--r--korn/kio_delete.h69
-rw-r--r--korn/kio_proto.cpp81
-rw-r--r--korn/kio_proto.h157
-rw-r--r--korn/kio_read.cpp97
-rw-r--r--korn/kio_read.h60
-rw-r--r--korn/kio_single_subject.cpp155
-rw-r--r--korn/kio_single_subject.h68
-rw-r--r--korn/kio_subjects.cpp176
-rw-r--r--korn/kio_subjects.h74
-rw-r--r--korn/kmail_proto.cpp246
-rw-r--r--korn/kmail_proto.h122
-rw-r--r--korn/kornaccountcfg.ui249
-rw-r--r--korn/kornaccountcfgimpl.cpp232
-rw-r--r--korn/kornaccountcfgimpl.h69
-rw-r--r--korn/kornapp.cpp21
-rw-r--r--korn/kornapp.h43
-rw-r--r--korn/kornboxcfg.ui1698
-rw-r--r--korn/kornboxcfgimpl.cpp372
-rw-r--r--korn/kornboxcfgimpl.h93
-rw-r--r--korn/korncfg.ui176
-rw-r--r--korn/korncfgimpl.cpp253
-rw-r--r--korn/korncfgimpl.h61
-rw-r--r--korn/kornshell.cpp155
-rw-r--r--korn/kornshell.h57
-rw-r--r--korn/label.h43
-rw-r--r--korn/maildir_proto.h56
-rw-r--r--korn/maildlg.cpp109
-rw-r--r--korn/maildlg.h82
-rw-r--r--korn/maildrop.cpp250
-rw-r--r--korn/maildrop.h456
-rw-r--r--korn/mailid.cpp5
-rw-r--r--korn/mailid.h33
-rw-r--r--korn/mailsubject.cpp189
-rw-r--r--korn/mailsubject.h187
-rw-r--r--korn/main.cpp53
-rw-r--r--korn/mbox_proto.cpp47
-rw-r--r--korn/mbox_proto.h58
-rw-r--r--korn/nntp_proto.cpp57
-rw-r--r--korn/nntp_proto.h52
-rw-r--r--korn/password.cpp247
-rw-r--r--korn/password.h168
-rw-r--r--korn/polldrop.cpp90
-rw-r--r--korn/polldrop.h69
-rw-r--r--korn/pop3_proto.cpp102
-rw-r--r--korn/pop3_proto.h58
-rw-r--r--korn/pop3s_proto.h40
-rw-r--r--korn/process_proto.cpp47
-rw-r--r--korn/process_proto.h48
-rw-r--r--korn/progress_dialog.ui120
-rw-r--r--korn/progress_dialog.ui.h67
-rw-r--r--korn/protocol.h63
-rw-r--r--korn/protocols.cpp87
-rw-r--r--korn/protocols.h46
-rw-r--r--korn/qmail_proto.cpp49
-rw-r--r--korn/qmail_proto.h58
-rw-r--r--korn/sortedmailsubject.cpp33
-rw-r--r--korn/sortedmailsubject.h40
-rw-r--r--korn/stringid.cpp38
-rw-r--r--korn/stringid.h46
-rw-r--r--korn/subjectsdlg.cpp535
-rw-r--r--korn/subjectsdlg.h202
-rw-r--r--korn/systemtray.cpp42
-rw-r--r--korn/systemtray.h58
-rw-r--r--korn/uninstall.desktop2
-rw-r--r--korn/utils.h5
112 files changed, 14622 insertions, 0 deletions
diff --git a/korn/AUTHORS b/korn/AUTHORS
new file mode 100644
index 000000000..2bc55ebb6
--- /dev/null
+++ b/korn/AUTHORS
@@ -0,0 +1,4 @@
+Author: Sirtaj Singh Kang <taj@kde.org>
+Hatchet jobs: Cristian Tibirna <tibirna@kde.org>
+IMAP: Kurt Granoth <granoth@kde.org>
+More hatchet jobs: Rik Hemsley <rik@kde.org>
diff --git a/korn/ChangeLog b/korn/ChangeLog
new file mode 100644
index 000000000..d22d617aa
--- /dev/null
+++ b/korn/ChangeLog
@@ -0,0 +1,38 @@
+2000-06-14 Rik Hemsley <rik@kde.org>
+ * More porting to KDE/Qt 2. Shitloads to do, took all day :(
+ * Compiles cleanly with -DQT_NO_ASCII_CAST -DQT_NO_CAST_ASCII
+ -DQT_CLEAN_NAMESPACE
+ * Used an inline function called 'fu()' to convert all (const) char * to
+ QString. It calles QString::fromUtf8(), hence 'f(from)u(tf8)'.
+
+2000-06-12 Rik Hemsley <rik@kde.org>
+ * Minor icon fix.
+ * Fixes to kornbutt.
+
+2000-06-12 Rik Hemsley <rik@kde.org>
+ * Fixed enabling of buttons and initial selection in optdlg.
+ * Converted C-style casts to C++-style, and checked retvals
+ of dynamic_casts. Currently only assert() used, but that's
+ better than crashing.
+ * Fixed layout of polldlg.
+ * Split 'General' cfg widget into two, 'View' and 'Commands'
+ * Added some keyboard accelerators.
+ * Still need to connect config stuff up properly...
+
+2000-06-09 Rik Hemsley <rik@kde.org>
+ * Converted the dialogs to use KDialogBase etc.
+ * Changed 'Options' to 'Display' and moved to second place in
+ main config dialog.
+
+1999-06-23 Cristian Tibirna <ctibirna@total.net>
+
+ * temporarily take care of korn (with Taj's blessing)
+ * fix most of the layouts (/me being too stupid to fix Taj's nice
+ custom layout classes, I switched completely to pure QLayouts)
+ * fixed most of the i18n
+ * made FileDialogs start with the current path by default (instead no
+ path, used before)
+ * changed some UI details a it (repetitive "Box" word etc.)
+ * added the Cancel button to the main QTabDialog of Setup...
+ NOTICE: kornII always functioned correctly. My changes are only makeup
+
diff --git a/korn/KOrn.desktop b/korn/KOrn.desktop
new file mode 100644
index 000000000..50f088ad7
--- /dev/null
+++ b/korn/KOrn.desktop
@@ -0,0 +1,78 @@
+[Desktop Entry]
+GenericName=Mail Alert
+GenericName[af]=Pos inkennis stel
+GenericName[ar]=منبه للبريد الألكتروني
+GenericName[bg]=Аларма за е-поща
+GenericName[bs]=Obavještavanje o pristigloj pošti
+GenericName[ca]=Alerta per al correu
+GenericName[cs]=Upozornění na poštu
+GenericName[cy]=Rhybudd Ebost
+GenericName[da]=Meddelelse om post
+GenericName[de]=Mail-Benachrichtigung
+GenericName[el]=Ειδοποίηση για mail
+GenericName[eo]=Retpoŝtavertilo
+GenericName[es]=Aviso de correo
+GenericName[et]=E-kirjade teadustaja
+GenericName[eu]=Mail abisua
+GenericName[fa]=هشدارنامه
+GenericName[fi]=Saapuneen sähköpostin ilmoitus
+GenericName[fr]=Surveillance du courrier électronique
+GenericName[fy]=E-postnotifikaasje
+GenericName[ga]=Fógairt Ríomhphoist
+GenericName[gl]=Alerta de Correo-e
+GenericName[hi]=डाक सतर्क
+GenericName[hr]=Upozorenje na nove poruke
+GenericName[hu]=Levélfigyelő
+GenericName[is]=Póst áminning
+GenericName[it]=Programma per controllare la posta
+GenericName[ja]=メールの通知
+GenericName[ka]=საფოსტო სიგნალი
+GenericName[kk]=Пошта келген туралы хабарлау
+GenericName[km]=សញ្ញា​ជូនដំណឹងសំបុត្រ
+GenericName[lt]=Pašto pranešėjas
+GenericName[lv]=Pasta Brīdinājums
+GenericName[mk]=Известување за е-пошта
+GenericName[ms]=Celik Mel
+GenericName[mt]=Twissija tal-imejl
+GenericName[nb]=E-post-varsling
+GenericName[nds]=Nettpost-Benarichten
+GenericName[ne]=सावधानी पत्र
+GenericName[nl]=E-mailnotificatie
+GenericName[nn]=E-postvarsling
+GenericName[pl]=Program powiadamiający o poczcie
+GenericName[pt]=Alerta de E-mail
+GenericName[pt_BR]=Alerta de E-mail
+GenericName[ro]=Alertare e-mail nou
+GenericName[ru]=Уведомление о приходе почты
+GenericName[rw]=Iburira ry'Ubutumwa
+GenericName[sk]=Upozornenie na mail
+GenericName[sl]=Obvestilo o pošti
+GenericName[sr]=Провера поште
+GenericName[sr@Latn]=Provera pošte
+GenericName[sv]=E-postvarning
+GenericName[ta]=அஞ்சல் அறிவிப்பு
+GenericName[tg]=Маълумоти қабулшавии почта
+GenericName[th]=แจ้งเตือนจดหมาย
+GenericName[tr]=Midi Uyarısı
+GenericName[uk]=Нагадування пошти
+GenericName[uz]=Yangi xat haqida xabar beruvchi
+GenericName[uz@cyrillic]=Янги хат ҳақида хабар берувчи
+GenericName[ven]=U sedzesa poso
+GenericName[xh]=Umposi Wokulumkisa
+GenericName[zh_CN]=邮件警告
+GenericName[zh_TW]=信件警告
+GenericName[zu]=Umposi Ohlomile
+Exec=korn -caption "%c" %i %m %f
+Icon=korn
+Path=
+DocPath=korn/index.html
+Type=Application
+Terminal=false
+Name=Korn
+Name[eo]=Korno
+Name[hi]=कॉर्न
+Name[ne]=कर्न
+Name[ta]=கார்ன்
+Name[zh_TW]=Korn 信件通知
+X-DCOP-ServiceType=Unique
+Categories=Qt;KDE;Network;X-KDE-More;Office;Email;
diff --git a/korn/Makefile.am b/korn/Makefile.am
new file mode 100644
index 000000000..13d908dfc
--- /dev/null
+++ b/korn/Makefile.am
@@ -0,0 +1,124 @@
+KDE_CXXFLAGS = $(USE_RTTI)
+
+INCLUDES = -I$(top_srcdir)/libkmime \
+ $(all_includes)
+#INCLUDES = -I$(top_srcdir)/mimelib -I$(top_srcdir)/libkmime $(all_includes)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+METASOURCES = AUTO
+
+bin_PROGRAMS = korn
+korn_LDADD = $(LIB_KIO) $(top_builddir)/libkmime/libkmime.la
+#korn_LDADD = $(top_builddir)/mimelib/libmimelib.la $(LIB_KFILE) $(LIBSOCKET) $(top_builddir)/libkmime/libkmime.la
+
+korn_SOURCES = \
+ accountmanager.cpp \
+ account_input.cpp \
+ boxcontainer.cpp \
+ boxcontaineritem.cpp boxcontaineritem.skel \
+ dcopdrop.cpp \
+ dcopdropif.cpp dcopdropif.skel \
+ dcop_proto.cpp \
+ dockedcontainer.cpp \
+ dockeditem.cpp \
+ hvcontainer.cpp \
+ hvitem.cpp \
+ keditlistboxman.cpp \
+ nntp_proto.cpp \
+ maildrop.cpp \
+ main.cpp \
+ polldrop.cpp \
+ protocols.cpp \
+ kornshell.cpp \
+ subjectsdlg.cpp \
+ maildlg.cpp \
+ mailid.cpp \
+ mailsubject.cpp \
+ mbox_proto.cpp \
+ imap_proto.cpp \
+ intid.cpp \
+ stringid.cpp \
+ kornapp.cpp \
+ kio.cpp \
+ kio_count.cpp \
+ kio_proto.cpp \
+ kio_subjects.cpp \
+ kio_single_subject.cpp \
+ kio_read.cpp \
+ kio_delete.cpp \
+ kmail_proto.cpp \
+ sortedmailsubject.cpp \
+ korncfgimpl.cpp \
+ kornaccountcfgimpl.cpp \
+ kornboxcfgimpl.cpp \
+ kornaccountcfg.ui \
+ kornboxcfg.ui \
+ korncfg.ui \
+ password.cpp \
+ pop3_proto.cpp \
+ systemtray.cpp \
+ process_proto.cpp \
+ progress_dialog.ui \
+ qmail_proto.cpp
+
+noinst_HEADERS = \
+ accountmanager.h \
+ account_input.h \
+ boxcontainer.h \
+ boxcontaineritem.h \
+ dcop_proto.h \
+ dcopdrop.h \
+ dcopdropif.h \
+ dockeditem.h \
+ hvcontainer.h \
+ hvitem.h \
+ keditlistboxman.h \
+ kmail_proto.h \
+ kornaccountcfgimpl.h \
+ kornboxcfg.h \
+ kornboxcfgimpl.h \
+ korncfg.h \
+ korncfgimpl.h \
+ maildrop.h \
+ progress_dialog.ui.h \
+ protocols.h \
+ kornshell.h \
+ subjectsdlg.h \
+ maildlg.h \
+ mailid.h \
+ mailsubject.h \
+ mbox_proto.h \
+ intid.h \
+ stringid.h \
+ kornapp.h \
+ kio.h \
+ kio_count.h \
+ kio_subjects.h \
+ kio_single_subject.h \
+ kio_read.h \
+ kio_delete.h \
+ sortedmailsubject.h \
+ imap_proto.h \
+ imaps_proto.h \
+ kio_proto.h \
+ maildir_proto.h \
+ nntp_proto.h \
+ pop3_proto.h \
+ pop3s_proto.h \
+ password.h \
+ process_proto.h \
+ qmail_proto.h \
+ systemtray.h
+
+srcdoc:
+ kdoc -p -u "/~ssk/src/korn/" -n korn -d /home/ssk/web/src/korn *.h \
+ -lqt -lkdeui -lkdecore
+
+messages: rc.cpp
+ $(XGETTEXT) *.h *.cpp -o $(podir)/korn.pot
+
+KDE_ICON = korn
+
+xdg_apps_DATA = KOrn.desktop
+
+SUBDIRS = kconf_update
diff --git a/korn/account_input.cpp b/korn/account_input.cpp
new file mode 100644
index 000000000..363e04751
--- /dev/null
+++ b/korn/account_input.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "account_input.h"
+
+#include <kurlrequester.h>
+#include <klineedit.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvalidator.h>
+
+AccountInput::AccountInput( const QString& configName )
+ : _configName( new QString( configName ) )
+{
+}
+
+AccountInput::~AccountInput()
+{
+ delete _configName;
+}
+
+QString AccountInput::configName() const
+{
+ return *_configName;
+}
+
+TextInput::TextInput( QWidget *parent, const QString& title, Type type, const QString& defaul, const QString& configName )
+ : AccountInput( configName )
+{
+ _left = new QLabel( title, parent, "label" );
+ _right = new KLineEdit( "", parent, "edit" );
+ switch( type )
+ {
+ case text:
+ break;
+ case password:
+ _right->setEchoMode( QLineEdit::Password );
+ break;
+ }
+ setValue( defaul );
+}
+
+TextInput::TextInput( QWidget *parent, const QString& title, int min, int max, const QString& defaul, const QString& configName )
+ : AccountInput( configName )
+{
+ _left = new QLabel( title, parent, "label" );
+ _right = new KLineEdit( "", parent, "edit" );
+ _right->setValidator( new QIntValidator( min, max, _right, "validator" ) );
+ setValue( defaul );
+}
+
+TextInput::~TextInput()
+{
+ delete _left;
+ delete _right;
+}
+
+QString TextInput::value() const
+{
+ return _right->text();
+}
+
+void TextInput::setValue( const QString& value )
+{
+ return _right->setText( value );
+}
+
+URLInput::URLInput( QWidget *parent, const QString& title, const QString& defaul, const QString& configName )
+ : AccountInput( configName )
+{
+ _left = new QLabel( title, parent, "label" );
+ _right = new KURLRequester( "", parent, "kurledit" );
+ setValue( defaul );
+}
+
+URLInput::~URLInput()
+{
+ delete _left;
+ delete _right;
+}
+
+QString URLInput::value() const
+{
+ return _right->url();
+}
+
+void URLInput::setValue( const QString& value )
+{
+ _right->setURL( value );
+}
+
+ComboInput::ComboInput( QWidget *parent, const QString& title, const QMap<QString, QString>& list,
+ const QString& defaul, const QString& configName )
+ : AccountInput( configName )
+ , _list( new QMap< QString, QString >( list ) )
+{
+ _left = new QLabel( title, parent, "label" );
+ _right = new QComboBox( false, parent, "combo" );
+ _right->insertStringList( QStringList( _list->values() ) );
+ setValue( defaul );
+}
+
+ComboInput::~ComboInput()
+{
+ delete _left;
+ delete _right;
+}
+
+QString ComboInput::value() const
+{
+ if( _right->currentItem() >= 0 )
+ return _list->keys()[ _right->currentItem() ];
+ else
+ return "";
+}
+
+void ComboInput::setValue( const QString& value )
+{
+ if( _list->contains( value ) )
+ _right->setCurrentItem( _list->keys().findIndex( value ) );
+ else
+ _right->setCurrentItem( -1 );
+}
+
+CheckboxInput::CheckboxInput( QWidget *parent, const QString& title, const QString& defaul, const QString& configName )
+ : AccountInput( configName )
+{
+ _right = new QCheckBox( title, parent, "checkbox" );
+ setValue( defaul );
+}
+
+CheckboxInput::~CheckboxInput()
+{
+ delete _right;
+}
+
+QString CheckboxInput::value() const
+{
+ if( _right->isChecked() )
+ return "true";
+ else
+ return "false";
+}
+
+void CheckboxInput::setValue( const QString& value )
+{
+ if( value == "true" )
+ _right->setChecked( true );
+ else if( value == "false" )
+ _right->setChecked( false );
+ //Elsewise: do nothing
+}
+
diff --git a/korn/account_input.h b/korn/account_input.h
new file mode 100644
index 000000000..80f989034
--- /dev/null
+++ b/korn/account_input.h
@@ -0,0 +1,310 @@
+/*
+* Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+*
+* 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 MK_ACCOUNT_INPUT
+#define MK_ACCOUNT_INPUT
+
+class QWidget;
+class QString;
+class QStringList;
+
+class QLabel;
+class KLineEdit;
+class KURLRequester;
+class QComboBox;
+class QCheckBox;
+
+#include <qmap.h>
+
+/**
+ * This classe contains methods to use in the creation of the protocol configuration box.
+ * The subclasses of this classes define the methods.
+ */
+class AccountInput
+{
+public:
+ /**
+ * Constructor.
+ *
+ * @param configName The name as the information is stored in the configuration-file.
+ */
+ AccountInput( const QString& configName );
+ /**
+ * Destructor
+ */
+ virtual ~AccountInput();
+
+ /**
+ * Implementations should return the left widget. In the configuration, it is
+ * possible to make a left label and a right input box.
+ * @return The pointer to the widget.
+ */
+ virtual QWidget* leftWidget() = 0;
+ /**
+ * Implementations should return the right widget. In the configuration, it is
+ * possible to make a left label and a right input box.
+ * @return The pointer to the widget.
+ */
+ virtual QWidget* rightWidget() = 0;
+
+ /**
+ * This function return the config name. This is used for stored an retrieving information.
+ *
+ * @return The configName as used for this config field.
+ */
+ QString configName() const;
+
+ /**
+ * Return the value of the configuration object. In most cases, this is the value the user typed in.
+ * This information will be stored in the configuration file.
+ *
+ * @return The value of the object
+ */
+ virtual QString value() const = 0;
+
+ /**
+ * Implementation should edit there widget such that value() would return the parameter.
+ *
+ * @param value The value that the object must get.
+ */
+ virtual void setValue( const QString& value ) = 0;
+protected:
+ QString *_configName;
+};
+
+/**
+ * This class implement a simple text input.
+ * The left widget is a label, the right widget is a KLineEdit.
+ * The value of this object is determined by the value of the KLineEdit.
+ */
+class TextInput : public AccountInput
+{
+public:
+ /**
+ * Enum for specifing the type.
+ * text means a normal LineEdit,
+ * password means that *-sings are used instead of characters.
+ */
+ enum Type { text, password };
+
+ /**
+ * Constructor
+ *
+ * @param parent The parent widget
+ * @param title The title that appears on the screen
+ * @param type The type of TextEdit which is used
+ * @param defaul The default value of this object
+ * @param configName The name it has in the configuration box.
+ */
+ TextInput( QWidget *parent, const QString& title, Type type, const QString& defaul, const QString& configName );
+ /**
+ * Constructor. Use this one if you want to ensure a number is inserted.
+ *
+ * @param parent The parent widget
+ * @param title The title that appears on the screen
+ * @param min The minimum value that can be inserted
+ * @param max The maximum value that can be inserted
+ * @param defaul The default value of this object
+ * @param configName The name it has in the configuration box.
+ */
+ TextInput( QWidget *parent, const QString& title, int min, int max, const QString& defaul, const QString& configName );
+ /**
+ * Destructor
+ */
+ virtual ~TextInput();
+
+ /**
+ * Returns a pointer to the label.
+ * @return A pointer to the label
+ */
+ virtual QWidget* leftWidget() { return (QWidget*)_left; }
+ /**
+ * Returns a pointer to the KLineEdit.
+ * @return A pointer to the KLineEdit
+ */
+ virtual QWidget* rightWidget() { return (QWidget*)_right; }
+
+ /**
+ * The value of the lineedit.
+ * @return The value of the lineedit.
+ */
+ virtual QString value() const;
+ /**
+ * This function sets the text of the edit box.
+ * @param value The value to appear in the lineedit box.
+ */
+ virtual void setValue( const QString& value );
+private:
+ QLabel *_left;
+ KLineEdit *_right;
+};
+
+/**
+ * This class implements a URL AccountInput. It can be used to request a file.
+ */
+class URLInput : public AccountInput
+{
+public:
+ /**
+ * Constructor
+ * @param parent The parent of this object
+ * @param title The title of the label next to the URL.
+ * @param defaul The default value
+ * @param configName The name of the configuration entry
+ */
+ URLInput( QWidget *parent, const QString& title, const QString& defaul, const QString& configName );
+ /**
+ * Destructor
+ */
+ virtual ~URLInput();
+
+ /**
+ * This return a pointer to the label of this object
+ * @return A pointer to the label of this object
+ */
+ virtual QWidget* leftWidget() { return (QWidget*)_left; }
+ /**
+ * This return a pointer to the KURLRequestor of this object
+ * @return A pointer to the KURLRequestor of this object
+ */
+ virtual QWidget* rightWidget() { return (QWidget*)_right; }
+
+ /**
+ * This function returns the url as given in the KURLRequestor
+ * @return The currently selected url
+ */
+ virtual QString value() const;
+ /**
+ * Sets the currently selected url
+ * @param value The url to be set.
+ */
+ virtual void setValue( const QString& );
+
+private:
+ QLabel *_left;
+ KURLRequester *_right;
+};
+
+/**
+ * This is an imput for a combobox.
+ */
+class ComboInput : public AccountInput
+{
+public:
+ /**
+ * Constructor
+ *
+ * @param parent The parent of the widgets which are created
+ * @param title The title next to the combo box
+ * @param list A mapping which maps a value in the configuration to a (translated) entry in the
+ * combo box.
+ * @param default The default value of the combo box.
+ * @param configName The name in which the option is saved.
+ */
+ ComboInput( QWidget *parent, const QString& title, const QMap<QString,QString>& list,
+ const QString& defaul, const QString& configName );
+ /**
+ * Destructor
+ */
+ virtual ~ComboInput();
+
+ /**
+ * The left widget (a label with the title on it)
+ * @return A pointer to the label of this object.
+ */
+ virtual QWidget* leftWidget() { return (QWidget*)_left; }
+ /**
+ * The right widget (the combo box itselfs)
+ * @return A pointer to the combo box of this object
+ */
+ virtual QWidget* rightWidget() { return (QWidget*)_right; }
+
+ /**
+ * Return the value of the currently selected item
+ * @return The value of the currently selected item
+ */
+ virtual QString value() const;
+
+ /**
+ * This function sets the combo box to an item which has @p value as value.
+ *
+ * @param value The value to be searched
+ */
+ virtual void setValue( const QString& value );
+private:
+ QLabel *_left;
+ QComboBox *_right;
+ QMap< QString, QString > *_list;
+
+};
+
+/**
+ * This is an object for creating a text-box.
+ * If has no left widget, as the title is stored in the checkbox itselfs.
+ */
+class CheckboxInput : public AccountInput
+{
+public:
+ /**
+ * Constructor
+ *
+ * @param parent The parent for the objects which are created
+ * @param title The title of the checkbox
+ * @param defaul The default value ("true" for checked, "false" otherwise")
+ * @param configName The name of the configuration entry of this object
+ */
+ CheckboxInput( QWidget *parent, const QString& title, const QString& defaul, const QString& configName );
+ /**
+ * Destructor
+ */
+ virtual ~CheckboxInput();
+
+ /**
+ * Return a 0-pointer as this object doesn't have a left widget.
+ *
+ * @return 0
+ */
+ virtual QWidget* leftWidget() { return 0; }
+ /**
+ * This function returns the checkbox.
+ * @return A pointer to the checkbox.
+ */
+ virtual QWidget* rightWidget() { return (QWidget*)_right; }
+
+ /**
+ * This gives the value of the checkbox: "true" if checked, "false" otherwise.
+ *
+ * @return "true" if the checkbox is checked, "false" otherwise.
+ */
+ virtual QString value() const;
+ /**
+ * This function can change the state of the checkbox.
+ * It can check or uncheck it.
+ *
+ * @param value If this parameter is "true", the checkbox gets checked,
+ * if it is "false", the checkbox get unchecked.
+ */
+ virtual void setValue( const QString& value );
+
+private:
+ QCheckBox *_right;
+};
+
+#endif
+
diff --git a/korn/accountmanager.cpp b/korn/accountmanager.cpp
new file mode 100644
index 000000000..d8c482e42
--- /dev/null
+++ b/korn/accountmanager.cpp
@@ -0,0 +1,268 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "accountmanager.h"
+
+#include "dcopdrop.h"
+#include "kio.h"
+#include "maildrop.h"
+#include "password.h"
+#include "protocol.h"
+#include "protocols.h"
+#include "subjectsdlg.h"
+
+#include <kaudioplayer.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include <qptrlist.h>
+
+KornSubjectsDlg* AccountManager::_subjectsDlg = 0;
+
+AccountManager::AccountManager( QObject * parent, const char * name )
+ : QObject( parent, name ),
+ _kioList( new QPtrList< KMailDrop > ),
+ _dcopList( new QPtrList< DCOPDrop > ),
+ _dropInfo( new QMap< KMailDrop*, Dropinfo* > )
+{
+ _kioList->setAutoDelete( true );
+ _dcopList->setAutoDelete( true );
+}
+
+AccountManager::~AccountManager()
+{
+ delete _kioList;
+ delete _dcopList;
+ delete _dropInfo;
+}
+
+void AccountManager::readConfig( KConfig* config, const int index )
+{
+ KConfigGroup *masterGroup = new KConfigGroup( config, QString( "korn-%1" ).arg( index ) );
+ QStringList dcop = masterGroup->readListEntry( "dcop", ',' );
+ KConfigGroup *accountGroup;
+ int counter = 0;
+
+ while( config->hasGroup( QString( "korn-%1-%2" ).arg( index ).arg( counter ) ) )
+ {
+ accountGroup = new KConfigGroup( config, QString( "korn-%1-%2" ).arg( index ).arg( counter ) );
+
+ const Protocol *proto = Protocols::getProto( accountGroup->readEntry( "protocol" ) );
+ if( !proto )
+ {
+ kdWarning() << "Protocol werd niet gevonden" << endl;
+ ++counter;
+ continue;
+ }
+ QMap< QString, QString > *configmap = proto->createConfig( accountGroup,
+ KOrnPassword::readKOrnPassword( index, counter, *accountGroup ) );
+ KMailDrop *kiodrop = proto->createMaildrop( accountGroup );
+ const Protocol *nproto = proto->getProtocol( accountGroup );
+ Dropinfo *info = new Dropinfo;
+
+ if( !kiodrop || !configmap || !nproto )
+ {
+ //Error occured when reading for config
+ ++counter;
+ delete info;
+ continue;
+ }
+
+ //TODO: connect some stuff
+ connect( kiodrop, SIGNAL( changed( int, KMailDrop* ) ), this, SLOT( slotChanged( int, KMailDrop* ) ) );
+ connect( kiodrop, SIGNAL( showPassivePopup( QPtrList< KornMailSubject >*, int, bool, const QString& ) ),
+ this, SLOT( slotShowPassivePopup( QPtrList< KornMailSubject >*, int, bool, const QString& ) ) );
+ connect( kiodrop, SIGNAL( showPassivePopup( const QString&, const QString& ) ),
+ this, SLOT( slotShowPassivePopup( const QString&, const QString& ) ) );
+ connect( kiodrop, SIGNAL( validChanged( bool ) ), this, SLOT( slotValidChanged( bool ) ) );
+
+ kiodrop->readGeneralConfigGroup( *masterGroup );
+ if( !kiodrop->readConfigGroup( *accountGroup ) || !kiodrop->readConfigGroup( *configmap, nproto ) )
+ {
+ ++counter;
+ delete info;
+ continue;
+ }
+
+ kiodrop->startMonitor();
+
+ _kioList->append( kiodrop );
+
+ info->index = counter;
+ info->reset = accountGroup->readNumEntry( "reset", 0 );
+ info->msgnr = info->reset;
+ info->newMessages = false;
+
+ _dropInfo->insert( kiodrop, info );
+
+ ++counter;
+ }
+
+ QStringList::Iterator it;
+ for( it = dcop.begin(); it != dcop.end(); ++it )
+ {
+ DCOPDrop *dcopdrop = new DCOPDrop;
+ Dropinfo *info = new Dropinfo;
+
+ connect( dcopdrop, SIGNAL( changed( int, KMailDrop* ) ), this, SLOT( slotChanged( int, KMailDrop* ) ) );
+ connect( dcopdrop, SIGNAL( showPassivePopup( QPtrList< KornMailSubject >*, int, bool, const QString& ) ),
+ this, SLOT( slotShowPassivePopup( QPtrList< KornMailSubject >*, int, bool, const QString& ) ) );
+
+ dcopdrop->readConfigGroup( *masterGroup );
+ dcopdrop->setDCOPName( *it );
+
+ _dcopList->append( dcopdrop );
+
+ info->index = 0;
+ info->reset = 0;
+ info->msgnr = 0;
+ info->newMessages = false;
+
+ _dropInfo->insert( dcopdrop, info );
+ }
+
+ setCount( totalMessages(), hasNewMessages() );
+}
+
+void AccountManager::writeConfig( KConfig* config, const int index )
+{
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ {
+ config->setGroup( QString( "korn-%1-%2" ).arg( index ).arg( it.data()->index ) );
+ config->writeEntry( "reset", it.data()->reset );
+ }
+}
+
+QString AccountManager::getTooltip() const
+{
+ QStringList result;
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ if( it.key()->valid() )
+ result.append( QString( "%1: %2" ).arg( it.key()->realName() ).arg( it.data()->msgnr - it.data()->reset ));
+ else
+ result.append( QString( "%1: invalid" ).arg( it.key()->realName() ) );
+ result.sort();
+ return result.join( QChar( '\n' ) );
+}
+
+void AccountManager::doRecheck()
+{
+ KMailDrop *item;
+ for( item = _kioList->first(); item; item = _kioList->next() )
+ item->forceRecheck();
+}
+
+void AccountManager::doReset()
+{
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ {
+ it.data()->reset = it.data()->msgnr;
+ it.data()->newMessages = false;
+ }
+
+ setCount( 0, false );
+}
+
+void AccountManager::doView()
+{
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+
+ if( !_subjectsDlg )
+ _subjectsDlg = new KornSubjectsDlg();
+
+ _subjectsDlg->clear();
+
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ _subjectsDlg->addMailBox( it.key() );
+
+ _subjectsDlg->loadMessages();
+}
+
+void AccountManager::doStartTimer()
+{
+ KMailDrop *item;
+
+ for( item = _kioList->first(); item; item = _kioList->next() )
+ item->startMonitor();
+}
+
+void AccountManager::doStopTimer()
+{
+ KMailDrop *item;
+
+ for( item = _kioList->first(); item; item = _kioList->next() )
+ item->stopMonitor();
+}
+
+int AccountManager::totalMessages()
+{
+ int result = 0;
+
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ //if( it.date()->msgnr - it.date()->reset > 0 )
+ result += it.data()->msgnr - it.data()->reset;
+
+ return result;
+}
+
+bool AccountManager::hasNewMessages()
+{
+ QMap< KMailDrop*, Dropinfo* >::Iterator it;
+ for( it = _dropInfo->begin(); it != _dropInfo->end(); ++it )
+ if( it.data()->newMessages )
+ return true;
+
+ return false;
+}
+
+void AccountManager::playSound( const QString& file )
+{
+ KAudioPlayer::play( file );
+}
+
+void AccountManager::slotChanged( int count, KMailDrop* mailDrop )
+{
+ Dropinfo *info = _dropInfo->find( mailDrop ).data();
+ info->newMessages = count > info->msgnr || ( count == info->msgnr && info->newMessages );
+
+ if( count > info->msgnr )
+ {
+ if( !mailDrop->soundFile().isEmpty() )
+ playSound( mailDrop->soundFile() );
+ if( !mailDrop->newMailCmd().isEmpty() )
+ runCommand( mailDrop->newMailCmd() );
+ }
+
+ info->msgnr = count;
+ if( info->msgnr - info->reset < 0 )
+ info->reset = 0;
+
+ setCount( totalMessages(), hasNewMessages() && totalMessages() > 0 );
+ setTooltip( getTooltip() );
+}
+
+void AccountManager::slotValidChanged( bool )
+{
+ setTooltip( getTooltip() );
+}
+
+#include "accountmanager.moc"
diff --git a/korn/accountmanager.h b/korn/accountmanager.h
new file mode 100644
index 000000000..958e5b57c
--- /dev/null
+++ b/korn/accountmanager.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_ACCOUNTMANAGER_H
+#define MK_ACCOUNTMANAGER_H
+
+#include <qobject.h>
+
+class DCOPDrop;
+class KornSubjectsDlg;
+class KKioDrop;
+class KMailDrop;
+
+class KConfig;
+
+template< class T > class QPtrList;
+template< class T, class W > class QMap;
+
+
+/**
+ * This class manage the different accounts.
+ *
+ * This class reads the config and makes the accounts,
+ * and it communicate with the boxes.
+ */
+class AccountManager : public QObject
+{ Q_OBJECT
+public:
+ /**
+ * Constructor, parameters are directed to QObject.
+ */
+ AccountManager( QObject * parent = 0, const char * name = 0 );
+
+ /**
+ * Destructor
+ */
+ ~AccountManager();
+
+ /**
+ * This function is used to read the config.
+ *
+ * @param config The KConfig instance to the configuration
+ * @param index The index of the box. As there are different boxes,
+ * every box have it's own index. This number is used to get the
+ * right config-information out of the config parameter.
+ */
+ virtual void readConfig( KConfig* config, const int index );
+
+ /**
+ * This write the configuration into a file. Things that must be right is
+ * for example the reset number. The configuration isn't saved through this
+ * method; configurations are saved in the configurations classes.
+ *
+ * @param config The KConfig instance to which the configuration is written.
+ * @param index The index of the box.
+ */
+ virtual void writeConfig( KConfig* config, const int index );
+
+ /**
+ * This method makes a QString which can be used for a tooltip.
+ * In it, all accounts are summed and the number of new messages of
+ * every account is added.
+ *
+ * @return A string that can be used for the Tooltip of the box.
+ */
+ QString getTooltip() const;
+protected:
+ /**
+ * This function is called when the number of emails has changed.
+ * Boxes must override this method and update the information.
+ *
+ * @param numberOfNewMessages The number of unread messages.
+ * @param newMessages Are there any new messages (important for displaying it)?
+ */
+ virtual void setCount( int numberOfNewMessages, bool newMessages ) = 0;
+
+ /**
+ * This functions sets a new Tooltip. Boxes must override this method
+ * @param tooltip The tooltip to be set.
+ */
+ virtual void setTooltip( const QString& tooltip ) = 0;
+
+ /**
+ * This funtion is called if @p command have to be executed.
+ * For example, if new email has arrived, and the user setuped KOrn
+ * to execute a command. Boxes must override this function.
+ */
+ virtual void runCommand( const QString& command ) = 0;
+
+ /**
+ * This function can be called by classes that inherit this class.
+ * If this function is called, all account which are part of this
+ * box are rechecked.
+ */
+ void doRecheck();
+
+ /**
+ * If this method is called, the number of new messages of all of its account
+ * is resetted.
+ */
+ void doReset();
+
+ /**
+ * If this function is called, a windows with shows the message headers will popup.
+ */
+ void doView();
+
+ /**
+ * These functions are called if the user wants to start or stop the account being triggered.
+ */
+ void doStartTimer();
+ void doStopTimer();
+
+private:
+ struct Dropinfo
+ {
+ int index;
+ int msgnr;
+ bool newMessages;
+ int reset;
+ };
+
+ QPtrList< KMailDrop > *_kioList;
+ QPtrList< DCOPDrop > *_dcopList;
+
+ QMap< KMailDrop*, Dropinfo* > *_dropInfo;
+
+ static KornSubjectsDlg *_subjectsDlg;
+
+private:
+ int totalMessages();
+ bool hasNewMessages();
+ void playSound( const QString& );
+private slots:
+ void slotChanged( int, KMailDrop* );
+ void slotValidChanged( bool );
+};
+
+#endif //MK_ACCOUNTMANAGER_H
+
diff --git a/korn/boxcontainer.cpp b/korn/boxcontainer.cpp
new file mode 100644
index 000000000..e245004c7
--- /dev/null
+++ b/korn/boxcontainer.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "boxcontainer.h"
+#include "boxcontaineritem.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include <qptrlist.h>
+
+BoxContainer::BoxContainer( QObject * parent, const char * name )
+ : QObject( parent, name ),
+ _items( new QPtrList< BoxContainerItem > )
+{
+ _items->setAutoDelete( true );
+}
+
+BoxContainer::~BoxContainer()
+{
+ delete _items;
+}
+
+void BoxContainer::readConfig( KConfig* config )
+{
+ int counter = 0;
+ while( config->hasGroup( QString( "korn-%1" ).arg( counter ) ) )
+ {
+ config->setGroup( QString( "korn-%1" ).arg( counter ) );
+ BoxContainerItem *item = newBoxInstance();
+ item->readConfig( config, counter );
+ addItem( item );
+ ++counter;
+ }
+}
+
+void BoxContainer::writeConfig( KConfig *config )
+{
+ int index = 0;
+
+ BoxContainerItem *item;
+ for ( item = _items->first(); item; item = _items->next() )
+ {
+ item->writeConfig( config, index );
+ ++index;
+ }
+
+}
+
+void BoxContainer::showBox()
+{
+ BoxContainerItem *item;
+ for( item = _items->first(); item; item = _items->next() )
+ item->showBox();
+}
+
+void BoxContainer::slotShowConfiguration()
+{
+ emit showConfiguration();
+}
+
+void BoxContainer::addItem( BoxContainerItem* item )
+{
+ connect( item, SIGNAL( showConfiguration() ), this, SLOT( slotShowConfiguration() ) );
+ _items->append( item );
+}
+
+#include "boxcontainer.moc"
diff --git a/korn/boxcontainer.h b/korn/boxcontainer.h
new file mode 100644
index 000000000..800fab78e
--- /dev/null
+++ b/korn/boxcontainer.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_BOXCONTAINER_H
+#define MK_BOXCONTAINER_H
+
+#include <qobject.h>
+
+class BoxContainerItem;
+
+template< class T > class QPtrList;
+
+class KConfig;
+
+/**
+ * This class is the base for all BoxContainers. A BoxContainer is a place
+ * where BoxContainerItems can be placed. BoxContainerItems are the boxes you see.
+ */
+class BoxContainer : public QObject
+{ Q_OBJECT
+public:
+ /**
+ * Constructor: everything is passed to QObject.
+ *
+ * @param parent The parent of this object
+ * @param name The name of this object
+ */
+ BoxContainer( QObject *parent = 0, const char * name = 0 );
+ /**
+ * Destructor
+ */
+ ~BoxContainer();
+
+ /**
+ * This method reads the config from a certain KConfig instance.
+ *
+ * @param config The KConfig-instance to read the config from.
+ */
+ void readConfig( KConfig* config );
+
+ /**
+ * This method writes the config to a certain KConfig instance.
+ *
+ * @param config The KConfig-instance to write the config to.
+ */
+ void writeConfig( KConfig *config );
+
+ /**
+ * Shows all childs and itself
+ */
+ virtual void showBox();
+public slots:
+ /**
+ * This slot is triggered if the configuration window has to be shown.
+ * This call is passed through.
+ */
+ void slotShowConfiguration();
+
+protected:
+ /**
+ * This methos adds a child to the list.
+ *
+ * @param item The item to be added.
+ */
+ virtual void addItem( BoxContainerItem* item );
+
+ /**
+ * This method creates a new BoxContainerItem instance of the same
+ * type as the BoxContainer.
+ *
+ * @return A new instance to a BoxContainerItem of the same type.
+ */
+ virtual BoxContainerItem* newBoxInstance() const = 0;
+
+ /**
+ * The list of BoxContainerItems.
+ */
+ QPtrList< BoxContainerItem > *_items;
+
+signals:
+ /**
+ * This signal is used to pass the slotShowConfiguration call through
+ */
+ void showConfiguration();
+};
+
+#endif //MK_BOXCONTAINER_H
+
diff --git a/korn/boxcontaineritem.cpp b/korn/boxcontaineritem.cpp
new file mode 100644
index 000000000..fec7ab41d
--- /dev/null
+++ b/korn/boxcontaineritem.cpp
@@ -0,0 +1,443 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "boxcontaineritem.h"
+
+#include "mailsubject.h"
+
+#include <kaboutapplication.h>
+#include <kactioncollection.h>
+#include <kapplication.h>
+#include <kbugreport.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconeffect.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kpassivepopup.h>
+#include <kpopupmenu.h>
+#include <kprocess.h>
+#include <kshortcut.h>
+
+#include <qbitmap.h>
+#include <qcolor.h>
+#include <qfont.h>
+#include <qgrid.h>
+#include <qlabel.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qptrlist.h>
+#include <qstring.h>
+#include <qtooltip.h>
+#include <qvbox.h>
+
+BoxContainerItem::BoxContainerItem( QObject * parent, const char * name )
+ : AccountManager( parent, name ),
+ DCOPObject(),
+ _command( new QString )
+{
+ short i;
+
+ for( i = 0; i < 2; ++i )
+ {
+ _icons[ i ] = 0;
+ _anims[ i ] = 0;
+ _fgColour[ i ] = 0;
+ _bgColour[ i ] = 0;
+ _fonts[ i ] = 0;
+ }
+
+ for( i = 0; i < 3; ++i )
+ {
+ _recheckSettings[ i ] = false;
+ _resetSettings[ i ] = false;
+ _viewSettings[ i ] = false;
+ _runSettings[ i ] = false;
+ _popupSettings[ i ] = false;
+ }
+}
+
+BoxContainerItem::~BoxContainerItem()
+{
+ delete _command;
+}
+
+void BoxContainerItem::readConfig( KConfig* config, const int index )
+{
+ //Read information about how the thing have to look like
+ config->setGroup( QString( "korn-%1" ).arg( index ) );
+ if( config->readBoolEntry( "hasnormalicon", false ) )
+ _icons[ 0 ] = new QString( config->readEntry( "normalicon", "" ) );
+ else
+ _icons[ 0 ] = 0;
+ if( config->readBoolEntry( "hasnewicon", false ) )
+ _icons[ 1 ] = new QString( config->readEntry( "newicon", "" ) );
+ else
+ _icons[ 1 ] = 0;
+
+ if( config->readBoolEntry( "hasnormalanim", false ) )
+ _anims[ 0 ] = new QString( config->readEntry( "normalanim", "" ) );
+ else
+ _anims[ 0 ] = 0;
+ if( config->readBoolEntry( "hasnewanim", false ) )
+ _anims[ 1 ] = new QString( config->readEntry( "newanim", "" ) );
+ else
+ _anims[ 1 ] = 0;
+
+ if( config->readBoolEntry( "hasnormalfgcolour", false ) )
+ _fgColour[ 0 ] = new QColor( config->readColorEntry( "normalfgcolour" ) );
+ else
+ _fgColour[ 0 ] = 0;
+ if( config->readBoolEntry( "hasnewfgcolour", false ) )
+ _fgColour[ 1 ] = new QColor( config->readColorEntry( "newfgcolour" ) );
+ else
+ _fgColour[ 1 ] = 0;
+
+ if( config->readBoolEntry( "hasnormalbgcolour", false ) )
+ _bgColour[ 0 ] = new QColor( config->readColorEntry( "normalbgcolour" ) );
+ else
+ _bgColour[ 0 ] = 0;
+ if( config->readBoolEntry( "hasnewbgcolour", false ) )
+ _bgColour[ 1 ] = new QColor( config->readColorEntry( "newbgcolour" ) );
+ else
+ _bgColour[ 1 ] = 0;
+ if( config->readBoolEntry( "hasnormalfont", false ) )
+ _fonts[ 0 ] = new QFont( config->readFontEntry( "normalfont" ) );
+ else
+ _fonts[ 0 ] = 0;
+ if( config->readBoolEntry( "hasnewfont", false ) )
+ _fonts[ 1 ] = new QFont( config->readFontEntry( "newfont" ) );
+ else
+ _fonts[ 1 ] = 0;
+
+ //Read information about the mappings.
+ _recheckSettings[ 0 ] = config->readBoolEntry( "leftrecheck", true );
+ _recheckSettings[ 1 ] = config->readBoolEntry( "middlerecheck", false );
+ _recheckSettings[ 2 ] = config->readBoolEntry( "rightrecheck", false );
+
+ _resetSettings[ 0 ] = config->readBoolEntry( "leftreset", false );
+ _resetSettings[ 1 ] = config->readBoolEntry( "middlereset", false );
+ _resetSettings[ 2 ] = config->readBoolEntry( "rightreset", false );
+
+ _viewSettings[ 0 ] = config->readBoolEntry( "leftview", false );
+ _viewSettings[ 1 ] = config->readBoolEntry( "middleview", false );
+ _viewSettings[ 2 ] = config->readBoolEntry( "rightview", false );
+
+ _runSettings[ 0 ] = config->readBoolEntry( "leftrun", false );
+ _runSettings[ 1 ] = config->readBoolEntry( "middlerun", false );
+ _runSettings[ 2 ] = config->readBoolEntry( "rightrun", false );
+
+ _popupSettings[ 0 ] = config->readBoolEntry( "leftpopup", false );
+ _popupSettings[ 1 ] = config->readBoolEntry( "middlepopup", false );
+ _popupSettings[ 2 ] = config->readBoolEntry( "rightpopup", true );
+
+ //Read the command
+ *_command = config->readEntry( "command", "" );
+
+ //Sets the object ID for the DCOP-object
+ this->setObjId( config->readEntry( "name", "" ).utf8() );
+
+ //Read the settings of the reimplemented class.
+ //It is important to read this after the box-settings, because the
+ //setCount-function is called in AccountManager::readConfig
+ AccountManager::readConfig( config, index );
+}
+
+void BoxContainerItem::runCommand( const QString& cmd )
+{
+ KProcess *process = new KProcess;
+ process->setUseShell( true );
+ *process << cmd;
+ connect( process, SIGNAL( processExited (KProcess *) ), this, SLOT( processExited( KProcess * ) ) );
+ process->start();
+}
+
+void BoxContainerItem::mouseButtonPressed( Qt::ButtonState state )
+{
+ int button;
+ if( state & Qt::LeftButton )
+ button = 0;
+ else if( state & Qt::RightButton )
+ button = 2;
+ else if( state & Qt::MidButton )
+ button = 1;
+ else
+ return; //Invalid mouse button
+
+ if( _recheckSettings[ button ] )
+ doRecheck();
+ if( _resetSettings[ button ] )
+ doReset();
+ if( _viewSettings[ button ] )
+ doView();
+ if( _runSettings[ button ] )
+ runCommand();
+ if( _popupSettings[ button ] )
+ doPopup();
+}
+
+void BoxContainerItem::fillKPopupMenu( KPopupMenu* popupMenu, KActionCollection* actions ) const
+{
+ /*popupMenu->insertItem( i18n( "&Configure" ), this, SLOT( slotConfigure() ) );
+ popupMenu->insertItem( i18n( "&Recheck" ), this, SLOT( slotRecheck() ) );
+ popupMenu->insertItem( i18n( "R&eset Counter" ), this, SLOT( slotReset() ) );
+ popupMenu->insertItem( i18n( "&View Emails" ), this, SLOT( slotView() ) );
+ popupMenu->insertItem( i18n( "R&un Command" ), this, SLOT( slotRunCommand() ) );*/
+
+ (new KAction( i18n("&Configure"), KShortcut(), this, SLOT( slotConfigure() ), actions ))->plug( popupMenu );
+ (new KAction( i18n("&Recheck"), KShortcut(), this, SLOT( slotRecheck() ), actions ))->plug( popupMenu );
+ (new KAction( i18n("R&eset Counter"), KShortcut(), this, SLOT( slotReset() ), actions ))->plug( popupMenu );
+ (new KAction( i18n("&View Emails"), KShortcut(), this, SLOT( slotView() ), actions ))->plug( popupMenu );
+ (new KAction( i18n("R&un Command"), KShortcut(), this, SLOT( slotRunCommand() ), actions ))->plug( popupMenu );
+ popupMenu->insertSeparator();
+ KStdAction::help( this, SLOT( help() ), actions )->plug( popupMenu );
+ KStdAction::reportBug( this, SLOT( reportBug() ), actions )->plug( popupMenu );
+ KStdAction::aboutApp( this, SLOT( about() ), actions )->plug( popupMenu );
+}
+
+void BoxContainerItem::showPassivePopup( QWidget* parent, QPtrList< KornMailSubject >* list, int total,
+ const QString &accountName, bool date )
+{
+ KPassivePopup *popup = new KPassivePopup( parent, "Passive popup" );
+
+ QVBox *mainvlayout = popup->standardView( i18n( "KOrn - %1/%2 (total: %3)" ).arg( objId() ).arg( accountName )
+ .arg( total ), "", QPixmap(), 0 );
+ QGrid *mainglayout = new QGrid( date ? 3 : 2 ,mainvlayout, "Grid-Layout" );
+
+ QLabel *title = new QLabel( i18n("From"), mainglayout, "from_label" );
+ QFont font = title->font();
+ font.setBold( true );
+ title->setFont( font );
+
+ title = new QLabel( i18n("Subject"), mainglayout, "subject_label" );
+ font = title->font();
+ font.setBold( true );
+ title->setFont( font );
+
+ if( date )
+ {
+ title = new QLabel( i18n("Date"), mainglayout, "date_label" );
+ font = title->font();
+ font.setBold( true );
+ title->setFont( font );
+ }
+
+ for( KornMailSubject* subject = list->first(); subject; subject = list->next() )
+ {
+ new QLabel( subject->getSender(), mainglayout, "from-value" );
+ new QLabel( subject->getSubject(), mainglayout, "subject-value" );
+ if( date )
+ {
+ QDateTime tijd;
+ tijd.setTime_t( subject->getDate() );
+ new QLabel( tijd.toString(), mainglayout, "date-value" );
+ }
+ }
+
+ popup->setAutoDelete( true ); //Now, now care for deleting these pointers.
+
+ popup->setView( mainvlayout );
+
+ popup->show(); //Display it
+}
+
+void BoxContainerItem::drawLabel( QLabel *label, const int count, const bool newMessages )
+{
+ //This would fail if bool have fome other values.
+ short index = newMessages ? 1 : 0;
+
+ bool hasAnim = _anims[ index ] && !_anims[ index ]->isEmpty();
+ bool hasIcon = _icons[ index ] && !_icons[ index ]->isEmpty();
+ bool hasBg = _bgColour[ index ] && _bgColour[ index ]->isValid();
+ bool hasFg = _fgColour[ index ] && _fgColour[ index ]->isValid();
+
+ QPixmap pixmap;
+
+ label->setText( "" );
+ //QToolTip::add( label, this->getTooltip() );
+
+ if( hasAnim )
+ { //An animation can't have a foreground-colour and can't have a icon.
+ setAnimIcon( label, *_anims[ index ] );
+
+ hasFg = false;
+ hasIcon = false;
+ }
+
+ if( hasIcon )
+ pixmap = KGlobal::iconLoader()->loadIcon( *_icons[ index ], KIcon::Desktop, KIcon::SizeSmallMedium );
+
+ if( hasIcon && hasFg )
+ {
+ if( hasBg )
+ {
+ label->setPixmap( calcComplexPixmap( pixmap, *_fgColour[ index ], _fonts[ index ], count ) );
+ label->setBackgroundMode( Qt::FixedColor );
+ label->setPaletteBackgroundColor( *_bgColour[ index ] );
+ } else
+ {
+ label->setPixmap( calcComplexPixmap( pixmap, *_fgColour[ index ], _fonts[ index ], count ) );
+ }
+ return;
+ }
+
+ if( hasBg )
+ {
+ label->setBackgroundMode( Qt::FixedColor );
+ label->setPaletteBackgroundColor( *_bgColour[ index ] );
+ } else
+ {
+ label->setBackgroundMode( Qt::X11ParentRelative );
+ }
+
+ if( hasIcon )
+ {
+ label->setPixmap( pixmap );
+ }
+
+ if( hasFg )
+ {
+ if( _fonts[ index ] )
+ label->setFont( *_fonts[ index ] );
+ label->setPaletteForegroundColor( *_fgColour[ index ] );
+ label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
+ label->setText( QString::number( count ) );
+ }
+
+ if( hasFg || hasBg || hasIcon || hasAnim )
+ label->show();
+ else
+ label->hide();
+}
+
+//This function makes a pixmap which is based on icon, but has a number painted on it.
+QPixmap BoxContainerItem::calcComplexPixmap( const QPixmap &icon, const QColor& fgColour, const QFont* font, const int count )
+{
+ QPixmap result( icon );
+ QPixmap numberPixmap( icon.size() );
+ QImage iconImage( icon.convertToImage() );
+ QImage numberImage;
+ QRgb *rgbline;
+ QPainter p;
+
+ //Make a transparent number; first make a white number on a black background.
+ //This pixmap also is the base alpha-channel, the foreground colour is added later.
+ numberPixmap.fill( Qt::black );
+ p.begin( &numberPixmap, false );
+ p.setPen( Qt::white );
+ if( font )
+ p.setFont( *font );
+ p.drawText( icon.rect(), Qt::AlignCenter, QString::number( count ) );
+ p.end();
+
+ //Convert to image and add the alpha channel.
+ numberImage = numberPixmap.convertToImage();
+ if( numberImage.depth() != 32 ) //Make sure depth is 32 (and thus can have an alpha channel)
+ numberImage = numberImage.convertDepth( 32 );
+ numberImage.setAlphaBuffer( true ); //Enable alpha channel
+ for( int xx = 0; xx < numberImage.height(); ++xx )
+ {
+ rgbline = (QRgb*)numberImage.scanLine( xx );
+
+ for( int yy = 0; yy < numberImage.width(); ++yy )
+ {
+ //Set colour and alpha channel
+ rgbline[ yy ] = qRgba( fgColour.red(), fgColour.green(), fgColour.blue(), qRed( rgbline[ yy ] ) );
+ }
+ }
+
+ //Merge icon and number and convert to result.
+ KIconEffect::overlay( iconImage, numberImage );
+ result.convertFromImage( iconImage );
+
+ return result;
+}
+
+void BoxContainerItem::setAnimIcon( QLabel* label, const QString& anim )
+{
+ label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
+ label->setMovie( QMovie( anim ) );
+ label->show();
+}
+
+void BoxContainerItem::recheck()
+{
+ doRecheck();
+}
+
+void BoxContainerItem::reset()
+{
+ doReset();
+}
+
+void BoxContainerItem::view()
+{
+ doView();
+}
+
+void BoxContainerItem::runCommand()//Possible_unsafe?
+{
+ if( _command->isEmpty() )
+ return; //Don't execute an empty command
+ runCommand( *_command );
+}
+
+void BoxContainerItem::help()
+{
+ kapp->invokeHelp();
+}
+
+void BoxContainerItem::reportBug()
+{
+ KBugReport bug( 0, true );
+ bug.exec(); //modal: it doesn't recheck anymore
+}
+
+void BoxContainerItem::about()
+{
+ KAboutApplication about( 0, "KOrn About", true );
+ about.exec(); //modal: it doesn't recheck anymore
+}
+
+void BoxContainerItem::popup()
+{
+ doPopup();
+}
+
+void BoxContainerItem::showConfig()
+{
+ emit showConfiguration();
+}
+
+void BoxContainerItem::startTimer()
+{
+ doStartTimer();
+}
+
+void BoxContainerItem::stopTimer()
+{
+ doStopTimer();
+}
+
+void BoxContainerItem::processExited( KProcess* proc )
+{
+ delete proc;
+}
+
+#include "boxcontaineritem.moc"
diff --git a/korn/boxcontaineritem.h b/korn/boxcontaineritem.h
new file mode 100644
index 000000000..46f85da57
--- /dev/null
+++ b/korn/boxcontaineritem.h
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_BOXCONTAINERITEM_H
+#define MK_BOXCONTAINERITEM_H
+
+#include "accountmanager.h"
+#include <dcopobject.h>
+
+class KornMailSubject;
+
+class KActionCollection;
+class KConfig;
+class KPopupMenu;
+class KProcess;
+
+class QColor;
+class QLabel;
+//template< class T > class QPtrList;
+class QString;
+
+/**
+ * This class provide a base for an item. This item should be
+ * shown in a BoxContainer, and represent one number somewhere.
+ * This also is the DCOP-interface for such a box.
+ * @author Mart Kelder <mart.kde@hccnet.nl>
+ */
+class BoxContainerItem : public AccountManager, public DCOPObject
+{ Q_OBJECT
+ K_DCOP
+public:
+ /**
+ * Standaard QObject-constuctor
+ * This constructor implements the default arguments for any QObject.
+ * Note that is does not give a name to DCOPObject; that name
+ * is set in the readConfig-function.
+ * @param parent The parent of this object, See Object::QObject
+ * @param name The name of this object, See QObject::QObject
+ * @see BoxContainerItem::readConfig
+ */
+ BoxContainerItem( QObject * parent = 0, const char * name = 0 );
+
+ /**
+ * The default destructor. This only removes _command-pointer.
+ */
+ ~BoxContainerItem();
+
+ /**
+ * If this function should call a "show"-function of its widget.
+ */
+ virtual void showBox() = 0;
+
+ /**
+ * This function reads the config. It stores the readed values in the class.
+ * It also sets the DCOPObject-name.
+ * @param config The KConfigGroup-object which contains the configuration of this box.
+ * @param index The index of the box used in the config-file
+ */
+ virtual void readConfig( KConfig* config, const int index );
+
+public slots:
+ /**
+ * This functions sets the number to be displayed. It should be reimplemented.
+ * @param count The number of new messages waiting
+ * @param newMessages Are there any new messages added?
+ */
+ virtual void setCount( const int count, const bool newMessages ) = 0;
+
+ /**
+ * This functions execute a given command
+ *
+ * @param cmd The command to be executed.
+ */
+ virtual void runCommand( const QString& cmd );
+
+ /**
+ * This function displays the (kde) help dialog
+ */
+ void help();
+ /**
+ * This function calls a bug report dialog
+ */
+ void reportBug();
+ /**
+ * This function calls the about dialog
+ */
+ void about();
+
+ /**
+ * This functions should be called if a mouse-button has been pressed.
+ * This handles the connected events of it.
+ *
+ * @param button The button that was pressed, See Qt::ButtonState
+ */
+ void mouseButtonPressed( Qt::ButtonState button );
+protected:
+ /**
+ * This function filles a KPopupMenu-reference. The target is
+ * to set in all implementations the same KPopupMenu-content.
+ * Because some implementations (DockedItem) got a KPopupMenu
+ * by itself, this only changes a KPopupMenu instance.
+ * @param menu The menu to be changed.
+ * @param actions The actions to which the items should be added.
+ */
+ void fillKPopupMenu( KPopupMenu* menu, KActionCollection* actions ) const;
+
+ /**
+ * This displays the passive popup.
+ *
+ * @param parent The Winget of the visual widget
+ * @param list List with the first (five) subjects
+ * @param total The total numbers of unread mail
+ * @param accountName The name of the account it belongs to
+ * @param date Should the date be displayed?
+ */
+ void showPassivePopup( QWidget* parent, QPtrList< KornMailSubject >* list, int total, const QString& accountName, bool date );
+
+ //this functions should be reimplemented
+ /**
+ * This function is called when the implementation of the class
+ * should display the popup-menu.
+ */
+ virtual void doPopup() = 0;
+
+ /**
+ * This function draws a specified configuration into a label
+ * @param label The label to be filled
+ * @param count the number of new messages
+ * @param newMessages are the messages new?
+ */
+ void drawLabel( QLabel *label, const int count, const bool newMessages );
+
+private:
+ /**
+ * This function helps to make a pixmap
+ * @param icon The icon to be set in
+ * @param fgColour the colour of the foreground
+ * @param font the font; 0 is default font.
+ * @param count the number of messages
+ */
+ static QPixmap calcComplexPixmap( const QPixmap &icon, const QColor& fgColour, const QFont* font, const int count );
+
+ /**
+ * This functions sets a movie to a specified label
+ * @param label The label to set the movie in
+ * @param anim The path to the animation
+ */
+ void setAnimIcon( QLabel* label, const QString& anim );
+
+private slots:
+ void slotRecheck() { recheck(); }
+ void slotReset() { reset(); }
+ void slotView() { view(); }
+ void slotRunCommand() { runCommand(); }
+ void slotPopup() { popup(); }
+ void slotConfigure() { showConfig(); }
+public:
+k_dcop:
+ /**
+ * This call immediately checked all accounts of this box.
+ */
+ void recheck();
+ /**
+ * This call reset the number of unread messages to 0.
+ */
+ void reset();
+ /**
+ * This call popup's a window with the headers of the new messages.
+ */
+ void view();
+ /**
+ * This program executes the command as setup'ed.
+ */
+ void runCommand(); //Possible_unsafe?
+ /**
+ * This function lets the popup-menu's be displayed.
+ */
+ void popup();
+
+ /**
+ * This function lets the user edit the configuration
+ */
+ void showConfig();
+
+ /**
+ * With these DCOP-calls, a user can start and stop the accounts.
+ */
+ void startTimer();
+ void stopTimer();
+signals:
+ /**
+ * This signal is emitted when the user whants to configure something.
+ */
+ void showConfiguration();
+
+
+private slots:
+ /**
+ * This slot is called when a KProcess-instance needs to be deleted:)
+ * @param proc The instance of the instance which must be deleted.
+ */
+ void processExited( KProcess* proc );
+
+protected:
+ //This settings are stored here because every implementation needs them.
+ QString *_icons[ 2 ];
+ QString *_anims[ 2 ];
+ QColor *_fgColour[ 2 ];
+ QColor *_bgColour[ 2 ];
+ QFont *_fonts[ 2 ];
+
+private:
+ QString *_command;
+ bool _recheckSettings[ 3 ];
+ bool _resetSettings[ 3 ];
+ bool _viewSettings[ 3 ];
+ bool _runSettings[ 3 ];
+ bool _popupSettings[ 3 ];
+};
+
+#endif //MK_BOXCONTAINERITEM_H
diff --git a/korn/dcop_proto.cpp b/korn/dcop_proto.cpp
new file mode 100644
index 000000000..a5896b8f1
--- /dev/null
+++ b/korn/dcop_proto.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "dcop_proto.h"
+
+#include "account_input.h"
+#include "dcopdrop.h"
+
+#include <kconfigbase.h>
+#include <klocale.h>
+
+#include <qmap.h>
+#include <qptrlist.h>
+#include <qptrvector.h>
+
+KMailDrop* DCOP_Protocol::createMaildrop( KConfigGroup* ) const
+{
+ return new DCOPDrop();
+}
+
+QMap< QString, QString > * DCOP_Protocol::createConfig( KConfigGroup* config, const QString& ) const
+{
+ QMap< QString, QString > *result = new QMap< QString, QString >;
+
+ result->insert( "dcopname", config->readEntry( "dcopname", "korn_dcop" ) );
+
+ return result;
+}
+
+void DCOP_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "DCOP" );
+}
+
+void DCOP_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* result ) const
+{
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "DCOP name" ), TextInput::text, "korn_dcop", "dcopname" ) );
+}
+
+void DCOP_Protocol::readEntries( QMap< QString, QString >* ) const
+{
+}
+
+void DCOP_Protocol::writeEntries( QMap< QString, QString >* ) const
+{
+}
diff --git a/korn/dcop_proto.h b/korn/dcop_proto.h
new file mode 100644
index 000000000..cb92b8bf9
--- /dev/null
+++ b/korn/dcop_proto.h
@@ -0,0 +1,117 @@
+/*
+* Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+*
+* 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 DCOP_PROTO_H
+#define DCOP_PROTO_H
+
+#include "protocol.h"
+
+class AccountInput;
+class KConfigGroup;
+class KIO_Protocol;
+class KMailDrop;
+class Protocol;
+
+class QGroupBox;
+class QObject;
+class QStringList;
+class QWidget;
+
+template< class T> class QPtrList;
+template< class T> class QPtrVector;
+template< class T, class S> class QMap;
+
+#include <qstring.h>
+
+/**
+ * This class implements a DCOP-protocol.
+ * DCOP can be used to add messages to a box, or delete created dcop-messages.
+ * This can be usefull in scripts.
+ */
+class DCOP_Protocol : public Protocol
+{
+public:
+ /**
+ * Constructor
+ */
+ DCOP_Protocol() {}
+ /**
+ * Destructor
+ */
+ virtual ~DCOP_Protocol() {}
+
+ /**
+ * This function returns a Protocol pointer given a configuration.
+ * This function always returns itselfs, as the configuration never uses another protocol.
+ */
+ virtual const Protocol* getProtocol( KConfigGroup* ) const { return this; }
+ /**
+ * This function creates the maildrop used to count dcop-messages.
+ * @param config The configuration
+ */
+ virtual KMailDrop* createMaildrop( KConfigGroup* config ) const;
+ /**
+ * The function converts the information of the configuration file into a mapping.
+ *
+ * @param config The configuration instance to be mapped
+ * @return The keys and values of the configuration in a mapping
+ */
+ virtual QMap< QString, QString > * createConfig( KConfigGroup* config, const QString& passwd ) const;
+ /**
+ * This return the name of this protocol. It is always "dcop".
+ * @return The name of this protocol: "dcop"
+ */
+ virtual QString configName() const { return "dcop"; }
+
+ /**
+ * This function sets into the list the groupboxes.
+ *
+ * @param list A (empty) list, which is filled with the names of group-boxes.
+ */
+ virtual void configFillGroupBoxes( QStringList* list ) const;
+ /**
+ * This function filles the configuration field of this protocol.
+ * It is used to construct the configuration dialog.
+ *
+ * @param vector A vector with groupboxes.
+ * @param obj The pointer to the configDialog to connect signals to.
+ * @param result A list with AccountInput which is used to reconstruct the configuration.
+ */
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject* obj, QPtrList< AccountInput >* result ) const;
+ /**
+ * This function can edit some configuaration option before reading them.
+ */
+ virtual void readEntries( QMap< QString, QString >* ) const;
+ /**
+ * This function can edit some configuaration option before writing them.
+ */
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+
+ //Functions that return a derived class.
+ //This way, no explicit cast is needed
+ /**
+ * This function returns a cast to a KIO_Protocol. Because this isn't a KIO_Protocol,
+ * it returns 0.
+ *
+ * @return 0
+ */
+ virtual const KIO_Protocol* getKIOProtocol() const { return 0; }
+};
+
+#endif
diff --git a/korn/dcopdrop.cpp b/korn/dcopdrop.cpp
new file mode 100644
index 000000000..906f268de
--- /dev/null
+++ b/korn/dcopdrop.cpp
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "dcopdrop.h"
+
+#include "dcopdropif.h"
+#include "intid.h"
+#include "mailid.h"
+#include "mailsubject.h"
+
+#include <kconfigbase.h>
+#include <kdebug.h>
+
+#include <qdatetime.h>
+#include <qmap.h>
+#include <qstring.h>
+#include <qtimer.h>
+
+DCOPDrop::DCOPDrop()
+ : KMailDrop(),
+ _isRunning( false ),
+ _msgList( new QMap< int, KornMailSubject* > ),
+ _name( new QString( "" ) ),
+ _counter( 1 ),
+ _interface( 0 )
+{
+}
+
+DCOPDrop::~DCOPDrop()
+{
+ eraseList();
+ delete _interface;
+ delete _msgList;
+ delete _name;
+}
+
+void DCOPDrop::recheck()
+{
+ emit changed( _msgList->count(), this );
+ emit rechecked();
+}
+
+bool DCOPDrop::startMonitor()
+{
+ _isRunning = true;
+ return true;
+}
+
+bool DCOPDrop::stopMonitor()
+{
+ _isRunning = false;
+ return true;
+}
+
+bool DCOPDrop::readConfigGroup( const KConfigGroup &cfg )
+{
+ return KMailDrop::readConfigGroup( cfg );
+}
+
+bool DCOPDrop::readConfigGroup( const QMap< QString, QString > &map, const Protocol * )
+{
+ if( !map.contains( "dcopname" ) )
+ //The mapping MUST contain dcopname.
+ kdDebug() << "mapping is niet compleet" << endl;
+
+ this->setDCOPName( *map.find( "dcopname" ) );
+
+ return true;
+}
+
+bool DCOPDrop::writeConfigGroup( KConfigBase& cfg ) const
+{
+ KMailDrop::writeConfigGroup( cfg );
+
+ KMailDrop::writeConfigGroup( cfg );
+
+ cfg.writeEntry( "dcopname", *_name );
+ return true;
+}
+
+QString DCOPDrop::type() const
+{
+ return QString( "dcop" );
+}
+
+QValueVector< KornMailSubject >* DCOPDrop::doReadSubjects( bool * )
+{
+ emit readSubjectsTotalSteps( 1 );
+
+ /*
+ * This way, the function is really asynchrone.
+ * So, the return value arraves before any data arrives.
+ */
+ QTimer::singleShot( 1, this, SLOT( doReadSubjectsASync( void ) ) );
+
+ /*
+ * A empty QValueVector is made here.
+ * After that, the size is expanded to the expected number of subjects.
+ * This way, reallocation of memmory is minimized, and thus more efficient.
+ */
+ QValueVector<KornMailSubject> *vector = new QValueVector<KornMailSubject>( );
+ vector->reserve( _msgList->count() );
+ return vector;
+}
+
+bool DCOPDrop::deleteMails( QPtrList<const KornMailId> * ids, bool * )
+{
+ emit deleteMailsTotalSteps( 1 );
+
+ for( const KornMailId *it = ids->first(); it; it = ids->next() )
+ {
+ const KornIntId* id = dynamic_cast< const KornIntId* >( it );
+ if( _msgList->contains( id->getId() ) )
+ _msgList->erase( id->getId() );
+ }
+
+ emit deleteMailsProgress( 1 );
+ emit deleteMailsReady( true );
+
+ return true;
+}
+
+void DCOPDrop::eraseList( void )
+{
+ QMap<int, KornMailSubject* >::iterator it;
+ for( it = _msgList->begin(); it != _msgList->end(); ++it )
+ delete it.data();
+ _msgList->clear();
+}
+
+void DCOPDrop::doReadSubjectsASync( void )
+{
+ QMap<int, KornMailSubject* >::iterator it;
+ for( it = _msgList->begin(); it != _msgList->end(); ++it )
+ emit readSubject( new KornMailSubject( *it.data() ) );
+ emit readSubjectsProgress( 1 );
+ emit readSubjectsReady( true );
+}
+
+int DCOPDrop::addMessage( const QString& subject, const QString& message )
+{
+ KornIntId *id = new KornIntId( _counter );
+ KornMailSubject *mailsubject = new KornMailSubject( id, this );
+ ++_counter;
+
+ mailsubject->setSubject( subject );
+ mailsubject->setSender( QString( "DCOP: %1" ).arg( *_name ) );
+ mailsubject->setHeader( message, true );
+ mailsubject->setSize( message.length() );
+ mailsubject->setDate( QDateTime::currentDateTime().toTime_t() );
+
+ _msgList->insert( id->getId(), mailsubject );
+
+ emit changed( _msgList->count(), this );
+
+ return _counter - 1;
+}
+
+bool DCOPDrop::removeMessage( int id )
+{
+ if( ! _msgList->contains( id ) )
+ return false;
+
+ delete (*_msgList)[ id ];
+ _msgList->erase( id );
+
+ emit changed( _msgList->count(), this );
+
+ return true;
+}
+
+QString DCOPDrop::DCOPName() const
+{
+ return *_name;
+}
+
+void DCOPDrop::setDCOPName( const QString& name)
+{
+ *_name = name;
+ if( _interface )
+ _interface->changeName( name );
+ else
+ _interface = new DCOPDropInterface( this, name.utf8() );
+}
+
+#include "dcopdrop.moc"
diff --git a/korn/dcopdrop.h b/korn/dcopdrop.h
new file mode 100644
index 000000000..91bc8f98d
--- /dev/null
+++ b/korn/dcopdrop.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 DCOPDROP_H
+#define DCOPDROP_H
+
+#include "maildrop.h"
+
+#include <dcopobject.h>
+
+class DCOPDropInterface;
+//class KDropCfgDialog;
+class KornMailId;
+class KornMailSubject;
+
+class KConfigBase;
+
+template<class A, class B> class QMap;
+class QString;
+
+/**
+ * This class implements a KMailDrop for DCOP-objects.
+ * This class handles all new messages which are comming in through DCOP.
+ */
+class DCOPDrop : public KMailDrop
+{ Q_OBJECT
+public:
+ /**
+ * Constructor: no parameters
+ */
+ DCOPDrop();
+ /**
+ * Destructor
+ */
+ virtual ~DCOPDrop();
+
+ /**
+ * A DCOPDrop cannot produce error messages, so it always returns true.
+ *
+ * @return true is the box is valid
+ */
+ virtual bool valid() { return true; }
+ /**
+ * This forces the drop to recheck. It is inpossible to recheck dcop,
+ * so this function does nothing.
+ */
+ virtual void recheck();
+ /**
+ * This function starts the monitor, however, this drop is always running,
+ * and doesn't need to be started.
+ * The return value is always true.
+ *
+ * @return true
+ */
+ virtual bool startMonitor();
+ /**
+ * This function starts the monitor, however, this drop is always running,
+ * and doesn't need to be started.
+ * The return value is always true.
+ *
+ * @return true
+ */
+ virtual bool stopMonitor();
+ /**
+ * Return true is the monitor has been started before.
+ * @return true is it is 'running'.
+ */
+ virtual bool running() { return _isRunning; }
+
+ //virtual void addConfigPage( KDropCfgDialog* ) ;
+ /**
+ * This function gives a new instance of a DCOPDrop.
+ *
+ * @return A new instance of a DCOPDrop.
+ */
+ virtual KMailDrop* clone() const { return new DCOPDrop; }
+
+ /**
+ * This function reeds the config which are shipped which the group.
+ *
+ * @param config The configuration group which contains the info for this account.
+ * @return The same value as KMailDrop::readConfigGroup( config ) returns.
+ */
+ virtual bool readConfigGroup( const KConfigGroup& config );
+ /**
+ * This function also reeds the configurion, but from a mapping.
+ *
+ * @param map The mapping containing the configuration.
+ * @param protocol The protocol which comes with the mapping.
+ *
+ * @return true is all information is retrieved succesfully.
+ */
+ virtual bool readConfigGroup( const QMap< QString, QString > & map, const Protocol * protocol );
+ /**
+ * This function writes the information to a config group.
+ *
+ * @param config The configuration to write true
+ * @return true if no error occured.
+ */
+ virtual bool writeConfigGroup( KConfigBase& config ) const;
+ /**
+ * This returns the type of the box, in this case allways "dcop".
+ *
+ * @return "dcop"
+ */
+ virtual QString type() const;
+
+ /**
+ * This function should return true if it uses a synchrone comminucation.
+ * It doens't, so it returns false.
+ *
+ * @return false
+ */
+ virtual bool synchrone() const { return false; }
+
+ /**
+ * Return true if it is possible to read the subjects of new email.
+ *
+ * @return true
+ */
+ virtual bool canReadSubjects() { return true; }
+ /**
+ * This function does reads the subjects.
+ * @param stop A variable which isn't used: only used for synchrone actions
+ * @return A QValueVector which KornMailSubject* instance for every new mail.
+ */
+ virtual QValueVector< KornMailSubject >* doReadSubjects( bool *stop );
+
+ /**
+ * This function should return true if it is possible to delete emails.
+ * This is possible, so it always return true.
+ *
+ * @return true
+ */
+ virtual bool canDeleteMails() { return true; }
+ /**
+ * This function deletes the email.
+ *
+ * @param ids The id's of the email which must be deleted.
+ * @param stop Not used: only for synchrone opererations.
+ * @return true if deleting was succesfull
+ */
+ virtual bool deleteMails( QPtrList<const KornMailId> * ids, bool * stop );
+
+ /**
+ * This function returns true if it is possible to read emails.
+ * The emails are only given at once as a whole, so reading is impossible.
+ *
+ * @return false
+ */
+ virtual bool canReadMail() { return false; }
+
+
+private:
+ bool _isRunning;
+ QMap< int, KornMailSubject* > *_msgList;
+ QString *_name;
+ int _counter;
+ DCOPDropInterface *_interface;
+
+ void eraseList( void );
+
+private slots:
+ void doReadSubjectsASync( void );
+
+public: //accessed by DCOPDropInterface
+ int addMessage( const QString& subject, const QString& message );
+ bool removeMessage( int id );
+
+ //accessed by DCOPDropCfg
+ QString DCOPName() const;
+ void setDCOPName( const QString& );
+};
+
+#endif
diff --git a/korn/dcopdropif.cpp b/korn/dcopdropif.cpp
new file mode 100644
index 000000000..709161451
--- /dev/null
+++ b/korn/dcopdropif.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "dcopdropif.h"
+
+#include "dcopdrop.h"
+
+DCOPDropInterface::DCOPDropInterface( DCOPDrop* drop, const char* name )
+ : DCOPObject( name ),
+ _drop( drop )
+{
+}
+
+DCOPDropInterface::~DCOPDropInterface()
+{
+}
+
+void DCOPDropInterface::changeName( const QString& name )
+{
+ this->setObjId( name.utf8() );
+}
+
+int DCOPDropInterface::addMessage( const QString& subject, const QString& message )
+{
+ return _drop->addMessage( subject, message );
+}
+
+bool DCOPDropInterface::removeMessage( int id )
+{
+ return _drop->removeMessage( id );
+}
diff --git a/korn/dcopdropif.h b/korn/dcopdropif.h
new file mode 100644
index 000000000..a041ab059
--- /dev/null
+++ b/korn/dcopdropif.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 DCOPDROPIF_H
+#define DCOPDROPIF_H
+
+#include <dcopobject.h>
+
+class DCOPDrop;
+
+/**
+ * This DCOP-interface for the DCOPdrop.
+ */
+class DCOPDropInterface : virtual public DCOPObject
+{
+K_DCOP
+public:
+ /**
+ * Constructor
+ * @param drop The parent DCOPDrop
+ * @param name The name of the dcop-object
+ */
+ DCOPDropInterface( DCOPDrop* drop, const char* name );
+ /**
+ * Destructor
+ */
+ ~DCOPDropInterface();
+
+ /**
+ * This function is used to change the dcop-name
+ *
+ * @param name The new name of this dcop interface.
+ */
+ void changeName( const QString& name );
+k_dcop:
+ /**
+ * This function adds a message to list of new messages.
+ *
+ * @param subject The subject of the message
+ * @param message The body of the message
+ * @return The id which this message got
+ */
+ int addMessage( const QString& subject, const QString& message );
+ /**
+ * This function removes a message from the list of new messages.
+ *
+ * @param id The id of the message to be deleted. The id can be obtained in
+ * the "addMessage" dcop call.
+ */
+ bool removeMessage( int id );
+
+private:
+ DCOPDrop *_drop;
+};
+
+#endif
diff --git a/korn/dockedcontainer.cpp b/korn/dockedcontainer.cpp
new file mode 100644
index 000000000..e820c12c5
--- /dev/null
+++ b/korn/dockedcontainer.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "dockedcontainer.h"
+
+#include "dockeditem.h"
+
+DockedContainer::DockedContainer( QObject * parent, const char * name )
+ : BoxContainer( parent, name )
+{
+}
+
+DockedContainer::~DockedContainer()
+{
+}
+
+BoxContainerItem* DockedContainer::newBoxInstance() const
+{
+ return new DockedItem( 0, "foobar" );
+}
+
+#include "dockedcontainer.moc"
diff --git a/korn/dockedcontainer.h b/korn/dockedcontainer.h
new file mode 100644
index 000000000..96216f16f
--- /dev/null
+++ b/korn/dockedcontainer.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_DOCKEDCONTAINER_H
+#define MK_DOCKEDCONTAINER_H
+
+#include "boxcontainer.h"
+
+class BoxContainerItem;
+
+/**
+ * This class is a implementation of a BoxContainer and does almost nothing.
+ * The only thing it does is creating DocketItems.
+ */
+class DockedContainer : public BoxContainer
+{ Q_OBJECT
+public:
+ DockedContainer( QObject * parent = 0, const char * name = 0 );
+ ~DockedContainer();
+
+protected:
+ //virtual void addItem( BoxContainerItem* ); //Overiding not neccesairy
+
+ /**
+ * @return A new instance to a DocketItem.
+ */
+ virtual BoxContainerItem* newBoxInstance() const;
+};
+
+#endif //MK_DOCKEDCONTAINER_H
diff --git a/korn/dockeditem.cpp b/korn/dockeditem.cpp
new file mode 100644
index 000000000..2ec57a4f7
--- /dev/null
+++ b/korn/dockeditem.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "dockeditem.h"
+
+#include "systemtray.h"
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kpassivepopup.h>
+#include <kpopupmenu.h>
+#include <klocale.h>
+
+#include <qbitmap.h>
+#include <qcursor.h>
+#include <qtooltip.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qmovie.h>
+
+DockedItem::DockedItem( QWidget * parent, const char * name )
+ : BoxContainerItem( parent, name ),
+ _systemtray( new SystemTray( parent, "System tray" ) )
+{
+ this->fillKPopupMenu( _systemtray->contextMenu(), _systemtray->actionCollection() );
+
+ connect( _systemtray, SIGNAL( quitSelected() ), kapp, SLOT( quit() ) );
+ connect( _systemtray, SIGNAL( mouseButtonPressed( Qt::ButtonState ) ),
+ this, SLOT( mouseButtonPressed( Qt::ButtonState ) ) );
+}
+
+DockedItem::~DockedItem()
+{
+ delete _systemtray;
+}
+
+void DockedItem::showBox()
+{
+ _systemtray->show();
+}
+
+void DockedItem::readConfig( KConfig* config, const int index )
+{
+ BoxContainerItem::readConfig( config, index );
+
+ //No additional information to be loaded.
+}
+
+void DockedItem::setCount( const int count, const bool newMessages )
+{
+ drawLabel( _systemtray, count, newMessages );
+}
+
+void DockedItem::setTooltip( const QString& tooltip )
+{
+ QToolTip::add( _systemtray, tooltip );
+}
+
+void DockedItem::slotShowPassivePopup( QPtrList< KornMailSubject >* list, int total, bool date, const QString& name )
+{
+ showPassivePopup( _systemtray, list, total, name, date );
+}
+
+void DockedItem::slotShowPassivePopup( const QString& message, const QString& name )
+{
+ KPassivePopup::message( i18n( "Korn - %1/%2" ).arg( objId() ).arg( name ), message, _systemtray, "Passive error message" );
+}
+
+void DockedItem::doPopup()
+{
+ _systemtray->contextMenu()->popup( QCursor::pos() );
+}
+
+#include "dockeditem.moc"
diff --git a/korn/dockeditem.h b/korn/dockeditem.h
new file mode 100644
index 000000000..152fbb2cd
--- /dev/null
+++ b/korn/dockeditem.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_DOCKEDITEM_H
+#define MK_DOCKEDITEM_H
+
+#include "boxcontaineritem.h"
+
+class SystemTray;
+
+class KConfig;
+
+class QPixmap;
+
+/**
+ * This class is an implementation of a BoxContainerItem for the
+ * systemtray view. If also is a KSystemTray reimplementation.
+ *
+ * @see BoxContainerItem
+ * @author Mart Kelder <mart.kde@hccnet.nl>
+ */
+class DockedItem : public BoxContainerItem
+{ Q_OBJECT
+public:
+ /**
+ * This contructor gives all it parameters to its parents.
+ * @param parant The parent window
+ * @param name The name of the QObject's parents.
+ */
+ DockedItem( QWidget * parent = 0, const char * name = 0 );
+ /**
+ * Empty destructor; does nothing at the moment
+ */
+ ~DockedItem();
+
+ /**
+ * This functions shows the element in the systay.
+ */
+ virtual void showBox();
+
+ /**
+ * This functions reads the config. It used the parent
+ * version for the main things, but it is possible to
+ * add some configurations over here.
+ * @param config The KConfig-instance which contains the settings of this tray-item.
+ * @param index The index of the box in the configuration file
+ */
+ virtual void readConfig( KConfig* config, const int index );
+
+public slots:
+ /**
+ * This functions sets the number of messages to be displayed, and warns if there are new messages waiting.
+ * @param count The number of messages waiting
+ * @param newMessages if true than the settings for displaying new messages will be used.
+ */
+ virtual void setCount( const int count, const bool newMessages ) ;
+
+ /**
+ * This function sets the tooltip @p string to a box.
+ * @param string The tooltip to be added.
+ */
+ virtual void setTooltip( const QString& string );
+
+ void slotShowPassivePopup( QPtrList< KornMailSubject >* list, int total, bool date, const QString& );
+
+ void slotShowPassivePopup( const QString& error, const QString& );
+
+protected:
+ /**
+ * This function popup's the KPopupMenu inmideately.
+ */
+ virtual void doPopup();
+
+private:
+ void setAnimIcon( const QString& anim );
+
+private:
+ SystemTray *_systemtray;
+};
+
+#endif //MK_DOCKEDITEM_H
diff --git a/korn/hi16-app-korn.png b/korn/hi16-app-korn.png
new file mode 100644
index 000000000..be996e8e0
--- /dev/null
+++ b/korn/hi16-app-korn.png
Binary files differ
diff --git a/korn/hi32-app-korn.png b/korn/hi32-app-korn.png
new file mode 100644
index 000000000..46461d25f
--- /dev/null
+++ b/korn/hi32-app-korn.png
Binary files differ
diff --git a/korn/hi48-app-korn.png b/korn/hi48-app-korn.png
new file mode 100644
index 000000000..07fc14988
--- /dev/null
+++ b/korn/hi48-app-korn.png
Binary files differ
diff --git a/korn/hvcontainer.cpp b/korn/hvcontainer.cpp
new file mode 100644
index 000000000..f0268ba3a
--- /dev/null
+++ b/korn/hvcontainer.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "hvcontainer.h"
+
+#include "hvitem.h"
+
+#include <kdebug.h>
+
+#include <qvbox.h>
+
+HVContainer::HVContainer( Qt::Orientation orientation, QObject * parent, const char * name )
+ : BoxContainer( parent, name ),
+ box( 0 )
+{
+ if( orientation == Qt::Horizontal )
+ box = new QHBox( 0, "hbox" );
+ else
+ box = new QVBox( 0, "vbox" );
+}
+
+HVContainer::~HVContainer()
+{
+ delete box;
+}
+
+void HVContainer::showBox()
+{
+ box->show();
+}
+
+BoxContainerItem* HVContainer::newBoxInstance() const
+{
+ return new HVItem( box, "horizontal/vertical item" );
+}
+
+#include "hvcontainer.moc"
diff --git a/korn/hvcontainer.h b/korn/hvcontainer.h
new file mode 100644
index 000000000..9bae17b28
--- /dev/null
+++ b/korn/hvcontainer.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_HVCONTAINER_H
+#define MK_HVCONTAINER_H
+
+#include "boxcontainer.h"
+
+class BoxContainerItem;
+
+class QHBox;
+
+/**
+ * This is a BoxContainer for both Horizontal and Vertical displays.
+ */
+
+class HVContainer : public BoxContainer
+{ Q_OBJECT
+public:
+ /**
+ * Constructor: all elements are passed to BoxContainer, except orientation.
+ *
+ * @param orientation The orientation of the box: it is a vertical or horizontal box?
+ */
+ HVContainer( Qt::Orientation orientation, QObject * parent = 0 , const char * name = 0 );
+ ~HVContainer();
+
+ /**
+ * This functions calls show() to the box
+ */
+ virtual void showBox();
+protected:
+ /**
+ * This function returns a new instance of the container.
+ *
+ * @return A new instance of this container.
+ */
+ virtual BoxContainerItem* newBoxInstance() const;
+private:
+ QHBox *box;
+};
+
+#endif //MK_HVCONTAINER_H
diff --git a/korn/hvitem.cpp b/korn/hvitem.cpp
new file mode 100644
index 000000000..e8cc2483d
--- /dev/null
+++ b/korn/hvitem.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "hvitem.h"
+
+#include "label.h"
+
+#include <kactioncollection.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kpassivepopup.h>
+#include <kpopupmenu.h>
+#include <kstdaction.h>
+
+#include <qcursor.h>
+#include <qtooltip.h>
+
+HVItem::HVItem( QWidget *parent, const char *name )
+ : BoxContainerItem( 0, name ),
+ _label( new Label( parent, "label" ) ),
+ _popup( new KPopupMenu( _label, "popupmenu" ) ),
+ _actions( new KActionCollection( _popup, "actions" ) )
+{
+ _popup->insertTitle( kapp->miniIcon(), kapp->caption() );
+ this->fillKPopupMenu( _popup, _actions );
+ _popup->insertSeparator();
+ KStdAction::quit( kapp, SLOT( quit() ), _actions )->plug( _popup );
+
+ connect( _label, SIGNAL( mouseButtonPressed( Qt::ButtonState ) ), this, SLOT( mouseButtonPressed( Qt::ButtonState ) ) );
+}
+
+HVItem::~HVItem()
+{
+ //Let everything be deleted by his parents.
+}
+
+void HVItem::showBox()
+{
+ _label->show();
+}
+
+void HVItem::setCount( const int count, const bool newMessages )
+{
+ drawLabel( _label, count, newMessages );
+}
+
+void HVItem::setTooltip( const QString& string )
+{
+ QToolTip::add( _label, string );
+}
+
+void HVItem::slotShowPassivePopup( QPtrList< KornMailSubject >* list, int total, bool date, const QString& name )
+{
+ showPassivePopup( _label, list, total, name, date );
+}
+
+void HVItem::slotShowPassivePopup( const QString& errorMessage, const QString& name )
+{
+ KPassivePopup::message( QString( "korn-%1-%2" ).arg( objId() ).arg( name ), errorMessage, _label, "Passive error message" );
+}
+
+void HVItem::doPopup()
+{
+ _popup->popup( QCursor::pos() );
+}
+
+#include "hvitem.moc"
diff --git a/korn/hvitem.h b/korn/hvitem.h
new file mode 100644
index 000000000..ced99eb4d
--- /dev/null
+++ b/korn/hvitem.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_HVITEM_H
+#define MK_HVITEM_H
+
+#include <boxcontaineritem.h>
+
+class KActionCollection;
+class KPopupMenu;
+
+class Label;
+
+/**
+ * Item for a horizontal or vertical displayed window.
+ */
+class HVItem : public BoxContainerItem
+{ Q_OBJECT
+public:
+ HVItem( QWidget *parent = 0, const char *name = 0 );
+ ~HVItem();
+
+ /**
+ * This function calles show() to the label.
+ */
+ virtual void showBox();
+
+public slots:
+ /**
+ * Sets the number of new messages.
+ *
+ * @param count The number of unread messages.
+ * @param newMessages Are there any new messages?
+ */
+ void setCount( const int count, const bool newMessages );
+
+ /**
+ * This function sets the tooltip @p string to a box.
+ * @param string The tooltip to be added.
+ */
+ virtual void setTooltip( const QString& string );
+
+ /**
+ * This slot triggered when the passive popup is to be shown. It is transported
+ * to BoxContainerItem, but so it is possible to change the arguments.
+ */
+ void slotShowPassivePopup( QPtrList< KornMailSubject >* list, int total, bool date, const QString& );
+
+ /**
+ * This slot triggered when the passive popup is to be shown. It is transported
+ * to BoxContainerItem, but so it is possible to change the arguments.
+ */
+ void slotShowPassivePopup( const QString& errorMessage, const QString& name );
+
+ /**
+ * Trigered if the popup-menu is to be shown
+ */
+ virtual void doPopup();
+private:
+ Label *_label;
+ KPopupMenu *_popup;
+ KActionCollection *_actions;
+};
+
+#endif //MK_HVITEM_H
diff --git a/korn/imap_proto.cpp b/korn/imap_proto.cpp
new file mode 100644
index 000000000..d0be64360
--- /dev/null
+++ b/korn/imap_proto.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "imap_proto.h"
+
+#include "account_input.h"
+
+#include <qwidget.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qptrvector.h>
+#include <qptrlist.h>
+
+void Imap_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "Server" );
+ groupBoxes->append( "Identity" );
+}
+
+void Imap_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject* configDialog, QPtrList< AccountInput > * result ) const
+{
+ QMap< QString, QString > encrList;
+ encrList.insert( "ssl", i18n( "SSL" ) );
+ encrList.insert( "tls=auto", i18n( "TLS if possible" ) );
+ encrList.insert( "tls=on", i18n( "Always TLS" ) );
+ encrList.insert( "tls=off", i18n( "Never TLS" ) );
+
+ QMap< QString, QString > authList;
+ authList.insert( "auth=*", i18n( "Default" ) );
+ authList.insert( "auth=LOGIN", i18n( "LOGIN" ) ); //Note: LOGIN is an authentication method
+ authList.insert( "auth=ANONTMOUS", i18n( "Anonymous" ) ); //Note: ANONYMOUS is an authentication method
+ authList.insert( "auth=CRAM-MD5", i18n( "CRAM-MD5" ) ); //Note: CRAM-MD5 is an authentication method
+
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Server" ), TextInput::text, "", "server" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Port" ), 0, 65535, "143", "port" ) );
+ result->append( new ComboInput( (QWidget*)vector->at( 0 ), i18n( "Encryption" ), encrList, "tls=auto", "encryption" ) );
+ QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( activated( int) ),
+ configDialog, SLOT( slotSSLChanged() ) );
+
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Username" ), TextInput::text, "", "username" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Mailbox" ), TextInput::text, "INBOX", "mailbox" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Password" ), TextInput::password, "", "password" ) );
+ result->append( new CheckboxInput( (QWidget*)vector->at( 1 ), i18n( "Save password" ), "true", "savepassword" ) );
+ QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( toggled( bool ) ),
+ (QObject*)result->prev()->rightWidget(), SLOT( setEnabled( bool ) ) );
+ result->last()->setValue( "false" );
+ result->append( new ComboInput( (QWidget*)vector->at( 1 ), i18n( "Authentication" ), authList, "auth=*", "auth" ) );
+}
+
+void Imap_Protocol::readEntries( QMap< QString, QString >* map, QMap< QString, QString > *metadata ) const
+{
+ if( map->contains( "ssl" ) && *map->find( "ssl" ) == "true" )
+ map->insert( "encryption", "ssl" );
+ if( metadata->contains( "tls" ) )
+ map->insert( "encryption", QString( "tls=%1" ).arg( *metadata->find( "tls" ) ) );
+ if( metadata->contains( "auth" ) )
+ map->insert( "auth", QString( "auth=%1" ).arg( *metadata->find( "auth" ) ) );
+}
+
+void Imap_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ QString metadata;
+ if( map->contains( "encryption" ) )
+ {
+ if( *map->find( "encryption" ) == "ssl" )
+ map->insert( "ssl", "true" );
+ else
+ {
+ map->insert( "ssl", "false" );
+ metadata += *map->find( "encryption" );
+ }
+ map->erase( "encryption" );
+ }
+
+ if( map->contains( "auth" ) )
+ {
+ if( !metadata.isEmpty() )
+ metadata += ",";
+ metadata += *map->find( "auth" );
+ map->erase( "auth" );
+ }
+
+ map->insert( "metadata", metadata );
+}
+
diff --git a/korn/imap_proto.h b/korn/imap_proto.h
new file mode 100644
index 000000000..c4dfc896d
--- /dev/null
+++ b/korn/imap_proto.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_IMAP_PROTO_H
+#define MK_IMAP_PROTO_H
+
+#include "kio_proto.h"
+#include <kurl.h>
+
+/*
+ * With deleting and IMAP4 is a small problem: messages don't looks as deleted, as they
+ * apear with their full body. By deletion, kio_imap marks the message with FLAGS.SILENT as \DELETED.
+ * If there is a commit-function, it should be installed in this file.
+ */
+
+/**
+ * This class define the way a imap-protocol works.
+ * It implements function of KIO_Protocol to make the kio-modules work with it,
+ * as well as function of Protocol, to configure it.
+ */
+class Imap_Protocol : public KIO_Protocol
+{
+public:
+ /**
+ * Constructor
+ */
+ Imap_Protocol() {}
+ /**
+ * Destructor
+ */
+ virtual ~Imap_Protocol() {}
+
+ /**
+ * This function should return true if the protocol is connection-based.
+ * imap is, so this return "true".
+ *
+ * @return true
+ */
+ virtual bool connectionBased() const { return true; }
+
+ /**
+ * This gives the two names for a kioslave: imaps if ssl is selected, imap if not.
+ *
+ * @param ssl true if ssl is selected.
+ * @return "imaps" if ssl is true, "imap" otherwise
+ */
+ virtual QString protocol( bool ssl ) const { return ssl ? "imaps" : "imap"; }
+ /**
+ * This name of this protocol: it goed in the configuration under this name.
+ *
+ * @return The name of this protocol: "imap"
+ */
+ virtual QString configName() const { return "imap"; }
+ /**
+ * true, because it is possible to read subjects with imap.
+ *
+ * @return true
+ */
+ virtual bool canReadSubjects() const { return true; }
+ /**
+ * false, because deleting imap-mails doesn't work that well. See the commen above this class:
+ * metadata expunge=auto doesn't work.
+ *
+ * @return false
+ */
+ virtual bool canDeleteMail() const { return false; } //See comment above class: metadata expunge=auto doesn't work.
+ /**
+ * true, because it is possible to read the whole message.
+ *
+ * @return true
+ */
+ virtual bool canReadMail() const { return true; }
+
+ /**
+ * This function returns the default port. This depends whether ssl is used or not.
+ * If ssl is used, it return 993, elsewise 143.
+ *
+ * @param ssl Is ssl used?
+ * @return 993 if ssl is true, false otherwise.
+ */
+ virtual unsigned short defaultPort( bool ssl ) const { return ssl ? 993 : 143; }
+
+ virtual QStringList authList() const { return QStringList::split( '|', "*|LOGIN|ANONYMOUS|CRAM-MD5", false); }
+ //Could not test did, my server don't support other authentication methods.
+
+ /**
+ * These function change the kurl and the metadata.
+ * In this case, "unseen" is added to the query to only list unlees kurls.
+ * These function are called in kio_*.cpp
+ */
+ virtual void recheckKURL ( KURL &kurl, KIO::MetaData & ) const { kurl.setQuery( "unseen" ); }
+ virtual void readSubjectKURL( KURL &kurl, KIO::MetaData & ) const { kurl.setPath( kurl.path() + ";section=ENVELOPE" ); }
+ virtual void deleteMailConnectKURL( KURL &, KIO::MetaData & metadata ) const { metadata.insert( "expunge", "auto" ); }
+
+ /**
+ * This functions gives a list of names of groupboxes which are to be set in the configuration.
+ * In this case, two elements are added: "Server" and "Identity".
+ *
+ * @param list A list to add the name of groupboxes in.
+ */
+ virtual void configFillGroupBoxes( QStringList* list ) const;
+ /**
+ * This function adds elements to the groupbox.
+ *
+ * @param vector The vector containing the groupBoxes
+ * @param object The object to connect signals to
+ * @param ptrlist A list with object which is filled in this function. The list must already be created.
+ */
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject* object, QPtrList< AccountInput >* ptrlist ) const;
+ /**
+ * This function is used to change the configuration.
+ * In the case, the metadata-key is splitted out, and put in the @p metadata parameter.
+ *
+ * @param map The mapping containing the configuration. This object can change in this function.
+ * @param metadata An empty mapping at the begin, a mapping containing metadata at the end.
+ */
+ virtual void readEntries( QMap< QString, QString >* map, QMap< QString, QString >* metadata ) const;
+ /**
+ * This function edits writeEntry. It merge things back to a metadata-key and adds this
+ * key to the configuration.
+ *
+ * @param map The mapping which contains the information to be written to a configuarion file.
+ * the contents of this mapping can change in this function.
+ */
+ virtual void writeEntries( QMap< QString, QString >* map ) const;
+};
+
+#endif
diff --git a/korn/imaps_proto.h b/korn/imaps_proto.h
new file mode 100644
index 000000000..06b4920bc
--- /dev/null
+++ b/korn/imaps_proto.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_IMAPS_PROTO_H
+#define MK_IMAPS_PROTO_H
+
+#include "kio_proto.h"
+
+//Looks very simular to Imap_Protocol, so I inheritanced it.
+
+class Imaps_Protocol : public Imap_Protocol
+{
+public:
+ Imaps_Protocol() {}
+ virtual ~Imaps_Protocol() {}
+
+ virtual KIO_Protocol * clone() const { return new Imaps_Protocol; }
+
+ virtual QString protocol() const { return "imaps"; }
+ virtual QString configName() const { return "imaps"; }
+
+ virtual unsigned short defaultPort() const { return 993; }
+};
+
+#endif
diff --git a/korn/intid.cpp b/korn/intid.cpp
new file mode 100644
index 000000000..060f9c962
--- /dev/null
+++ b/korn/intid.cpp
@@ -0,0 +1,25 @@
+#include "intid.h"
+
+#include<kdebug.h>
+
+KornIntId::KornIntId(int id) : _id(id)
+{
+}
+
+KornIntId::KornIntId(const KornIntId& src) : KornMailId(), _id(src._id)
+{
+}
+
+KornIntId::~KornIntId()
+{
+}
+
+QString KornIntId::toString() const
+{
+ return QString("KornIntId, Id: ") + QString::number(_id);
+}
+
+KornMailId * KornIntId::clone() const
+{
+ return new KornIntId(*this);
+}
diff --git a/korn/intid.h b/korn/intid.h
new file mode 100644
index 000000000..ab4b4d3cc
--- /dev/null
+++ b/korn/intid.h
@@ -0,0 +1,52 @@
+#ifndef IntId_h
+#define IntId_h
+
+#include "mailid.h"
+
+/**
+ * Mail ID for mailboxes, which identify their mails by an integer number
+ */
+class KornIntId : public KornMailId
+{
+ /**
+ * the mail id
+ */
+ int _id;
+public:
+ /**
+ * KornIntId Destructor
+ */
+ virtual ~KornIntId();
+
+ /**
+ * KornIntId Constructor
+ * @param id: mail id
+ */
+ KornIntId(int id);
+
+ /**
+ * KornIntId Copy Constructor
+ * @param src: KornIntId to copy from
+ */
+ KornIntId(const KornIntId& src);
+
+ /**
+ * Return the mail id
+ * @return the mail id
+ */
+ int getId() const {return _id;}
+
+ /**
+ * Return a string representation of this (for debugging purposes only)
+ * @return a string representation
+ */
+ virtual QString toString() const;
+
+ /**
+ * Create an exact copy of this.
+ * @return the cloned object
+ */
+ virtual KornMailId * clone() const;
+};
+
+#endif
diff --git a/korn/kconf_update/Makefile.am b/korn/kconf_update/Makefile.am
new file mode 100644
index 000000000..87b23ad85
--- /dev/null
+++ b/korn/kconf_update/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES=$(all_includes)
+
+update_DATA = korn-3-4-config_change.upd korn-3-5-update.upd
+update_SCRIPTS = korn-3-5-ssl-update.pl korn-3-5-metadata-update.pl
+updatedir = $(kde_datadir)/kconf_update
+
+kconf_PROGRAMS = korn-3-4-config_change
+kconfdir = $(libdir)/kconf_update_bin
+
+korn_3_4_config_change_SOURCES = korn-3-4-config_change.cpp
+korn_3_4_config_change_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+korn_3_4_config_change_LDADD = $(LIB_QT)
diff --git a/korn/kconf_update/korn-3-4-config_change.cpp b/korn/kconf_update/korn-3-4-config_change.cpp
new file mode 100644
index 000000000..f8afa1ff4
--- /dev/null
+++ b/korn/kconf_update/korn-3-4-config_change.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 <qstring.h>
+#include <qregexp.h>
+#include <qtextstream.h>
+#include <qmap.h>
+#include <qvaluelist.h>
+
+#include <stdio.h>
+
+QString decodeString( const QString &password )
+{
+ unsigned int i, val;
+ unsigned int len = password.length();
+ QString result="";
+ for ( i=0; i < len; i++ )
+ {
+ val = password[i].latin1() - ' ';
+ val = (255-' ') - val;
+ result += (char)(val + ' ');
+ }
+ return result;
+}
+
+void printToprint( QTextStream &out, QMap<QString,QString> &to_printed, const QString type )
+{
+ out << "printToprint( " << type << " )" << endl;
+
+ if( type == "mbox" )
+ {
+ out << "mailbox=" << to_printed[ "file" ] << endl;
+ }
+ else if( type == "qmail" )
+ {
+ out << "mailbox=" << to_printed[ "maildir" ] << endl;
+ }
+ else if( type == "pop3" )
+ {
+ out << "host=" << to_printed[ "host" ] << endl;
+ out << "port=" << to_printed[ "port" ] << endl;
+ out << "username=" << to_printed[ "user" ] << endl;
+ if( to_printed[ "APOP" ] == "true" )
+ out << "auth=APOP" << endl;
+ else
+ out << "auth=" << endl;
+ }
+ else if( type == "imap4" )
+ {
+ out << "host=" << to_printed[ "host" ] << endl;
+ out << "port=" << to_printed[ "port" ] << endl;
+ out << "username=" << to_printed[ "user" ] << endl;
+ out << "mailbox=" << to_printed[ "mailbox" ] << endl;
+ }
+ else if( type == "nntp" )
+ {
+ out << "host=" << to_printed[ "host" ] << endl;
+ out << "port=" << to_printed[ "port" ] << endl;
+ out << "mailbox=" << to_printed[ "group" ] << endl;
+ }
+ else if( type == "process" )
+ {
+ out << "mailbox=" << to_printed[ "command" ] << endl;
+ }
+ else if( type == "kio" )
+ {
+ out << "host=" << to_printed[ "host" ] << endl;
+ out << "port=" << to_printed[ "port" ] << endl;
+ out << "username=" << to_printed[ "username" ] << endl;
+ out << "mailbox=" << to_printed[ "mailbox" ] << endl;
+ out << "password=" << decodeString( to_printed[ "password" ] ) << endl;
+ }
+
+ if( type == "pop3" || type == "imap4" )
+ {
+ out << "password=" << to_printed[ "pass" ] << endl;
+ if( to_printed[ "pass" ].isEmpty() )
+ out << "savepassword=false" << endl;
+ else
+ out << "savepassword=true" << endl;
+ }
+
+ if( to_printed[ "resetcounter" ] != "-1" )
+ out << "reset=" << to_printed[ "resetcounter" ] << endl;
+ else
+ out << "reset=0" << endl;
+ out << "interval=" << to_printed[ "poll" ] << endl;
+}
+
+int main( int, char** )
+{
+ QString line = QString::null;
+ QString currentGroup1 = QString::null;
+ QString currentGroup2 = QString::null;
+ QString type = QString::null;
+ QString password = QString::null;
+ QRegExp interesting_group( "^\\[box-(\\d+)\\]" );
+ QRegExp key_value( "^(\\w*)=(.*)$" );
+ QValueList<QString> tobe_deleted;
+ int numboxes = -1;
+ bool isKey = false;
+
+ QTextStream in( stdin, IO_ReadOnly );
+ QTextStream out( stdout, IO_WriteOnly );
+
+ in.setEncoding( QTextStream::UnicodeUTF8 );
+ out.setEncoding( QTextStream::UnicodeUTF8 );
+
+ QMap<QString,QString> mapping1;
+ QValueList<QString> mapping2;
+ QMap<QString,QString> to_printed;
+
+ mapping1.insert( "caption", "name" );
+ mapping1.insert( "onclick", "command" );
+ mapping1.insert( "onnewmail", "newcommand" );
+ mapping1.insert( "soundfile", "sound" );
+ mapping1.insert( "passive_popup", "passivepopup" );
+ mapping1.insert( "passive_data", "passivedata" );
+ mapping1.insert( "reset", "reset" );
+ mapping1.insert( "fgcolour", "normalfgcolour" );
+ mapping1.insert( "bgcolour", "normalbgcolour" );
+ mapping1.insert( "newmailfgcolour", "newfgcolour" );
+ mapping1.insert( "newmailbgcolour", "newbgcolour" );
+ mapping1.insert( "icon", "normalicon" );
+ mapping1.insert( "newmailicon", "newicon" );
+
+ mapping2.append( "file" );
+ mapping2.append( "maildir" );
+ mapping2.append( "host" );
+ mapping2.append( "port" );
+ mapping2.append( "user" );
+ mapping2.append( "APOP" );
+ mapping2.append( "mailbox" );
+ mapping2.append( "group" );
+ mapping2.append( "command" );
+ mapping2.append( "protocol" );
+ mapping2.append( "pass" );
+ mapping2.append( "password" );
+ mapping2.append( "resetcounter" );
+ mapping2.append( "poll" );
+
+ while( !in.atEnd() )
+ {
+ line = in.readLine();
+
+ isKey = key_value.search( line ) >= 0;
+
+ if( line.left( 1 ) == "[" )
+ {
+ if( !currentGroup1.isNull() )
+ {
+ out << currentGroup2 << endl;
+ printToprint( out, to_printed, type );
+ }
+
+ currentGroup1 = QString::null;
+ }
+
+ if( interesting_group.search( line ) >= 0 )
+ {
+ if( numboxes > -1 && interesting_group.cap( 1 ).toInt() < numboxes )
+ {
+ currentGroup1 = QString( "[korn-%1]" ).arg( interesting_group.cap( 1 ) );
+ currentGroup2 = QString( "[korn-%1-0]" ).arg( interesting_group.cap( 1 ) );
+ }
+ tobe_deleted.append( line );
+ continue;
+ }
+ else if( isKey && key_value.cap( 1 ) == "numboxes" )
+ {
+ numboxes = key_value.cap( 2 ).toInt();
+ continue;
+ }
+ else if( currentGroup1.isNull() || !isKey )
+ continue;
+ if( mapping1.contains( key_value.cap( 1 ) ) )
+ {
+ out << currentGroup1 << endl;
+ out << mapping1[ key_value.cap( 1 ) ] << "=" << key_value.cap( 2 ) << endl;
+ if( key_value.cap( 1 ) == "caption" )
+ {
+ out << currentGroup2 << endl;
+ out << "name=" << key_value.cap( 2 ) << endl;
+ }
+ }
+ else if( mapping2.contains( key_value.cap( 1 ) ) )
+ {
+ to_printed.insert( key_value.cap( 1 ), key_value.cap( 2 ) );
+ }
+ else if( key_value.cap( 1 ) == "type" && key_value.cap( 2 ) != "kio" )
+ {
+ out << currentGroup2 << endl;
+ if( key_value.cap( 2 ) == "imap4" )
+ out << "protocol=imap" << endl;
+ else
+ out << "protocol=" << key_value.cap( 2 ) << endl;
+ type = key_value.cap( 2 );
+
+ }
+ else if( key_value.cap( 1 ) == "type" && key_value.cap( 2 ) == "kio" )
+ {
+ type = "kio";
+ }
+ else if( key_value.cap( 1 ) == "displaystyle" )
+ {
+ out << currentGroup1 << endl;
+ if( key_value.cap( 2 ) == "2" )
+ {
+ out << "hasnormalfgcolour=false" << endl;
+ out << "hasnormalbgcolour=false" << endl;
+ out << "hasnewfgcolour=false" << endl;
+ out << "hasnewbgcolour=false" << endl;
+ out << "hasnormalicon=true" << endl;
+ out << "hasnormalanim=false" << endl;
+ out << "hasnewicon=true" << endl;
+ out << "hasnewanim=false" << endl;
+ }
+ else
+ {
+ out << "hasnormalfgcolour=true" << endl;
+ out << "hasnormalbgcolour=true" << endl;
+ out << "hasnewfgcolour=true" << endl;
+ out << "hasnewbgcolour=true" << endl;
+ out << "hasnormalicon=false" << endl;
+ out << "hasnormalanim=false" << endl;
+ out << "hasnewicon=false" << endl;
+ out << "hasnewanim=false" << endl;
+ }
+ }
+ }
+
+ if( !currentGroup1.isNull() )
+ {
+ out << currentGroup2 << endl;
+ printToprint( out, to_printed, type );
+ }
+
+ QValueList<QString>::Iterator it1 = tobe_deleted.begin();
+ QValueList<QString>::Iterator it1_end = tobe_deleted.end();
+
+ for( ; it1 != it1_end; ++it1 )
+ out << "# DELETEGROUP " << *it1 << endl;
+
+ return 0;
+}
+
diff --git a/korn/kconf_update/korn-3-4-config_change.upd b/korn/kconf_update/korn-3-4-config_change.upd
new file mode 100644
index 000000000..530304fad
--- /dev/null
+++ b/korn/kconf_update/korn-3-4-config_change.upd
@@ -0,0 +1,3 @@
+Id=korn_kde_3_4_config_change
+File=kornrc
+Script=korn-3-4-config_change
diff --git a/korn/kconf_update/korn-3-5-metadata-update.pl b/korn/kconf_update/korn-3-5-metadata-update.pl
new file mode 100644
index 000000000..95723c4ee
--- /dev/null
+++ b/korn/kconf_update/korn-3-5-metadata-update.pl
@@ -0,0 +1,43 @@
+my $input;
+my $group;
+my $auth = "";
+my $tls = "";
+my $metadata = "";
+
+while( $input = <STDIN> )
+{
+ chop $input;
+ if( $input =~ /^\[.*\]$/ )
+ {
+ if( $metadata )
+ {
+ print "[$group]\n";
+ print "metadata=$metadata\n";
+ $metadata="";
+ }
+
+ if( $input =~ /^\[(korn-(\d+)-\d+)\]$/ )
+ {
+ $group = $1;
+ }
+ else
+ {
+ $group = "";
+ }
+ $auth="";
+ $tls="";
+ }
+
+ if( $input =~ /^auth\=(.*)/ )
+ {
+ $metadata=$tls ? "auth=$1,tls=$tls" : "auth=$1";
+ $auth=$1;
+ print "# DELETE [$group]auth\n";
+ }
+ elsif( $input =~ /^tls\=(.*)/ )
+ {
+ $metadata=$auth ? "auth=$auth,tls=$1" : "tls=$1";
+ $tls=$1;
+ print "# DELETE [$tls]tls\n";
+ }
+}
diff --git a/korn/kconf_update/korn-3-5-ssl-update.pl b/korn/kconf_update/korn-3-5-ssl-update.pl
new file mode 100644
index 000000000..b44ce10ff
--- /dev/null
+++ b/korn/kconf_update/korn-3-5-ssl-update.pl
@@ -0,0 +1,39 @@
+my $input;
+my $group;
+my $protocol;
+
+while( $input = <STDIN> )
+{
+ chop $input;
+ if( $input =~ /^\[.*\]$/ )
+ {
+ if( $input =~ /^\[(korn-(\d+)-\d+)\]$/ )
+ {
+ $group = $1;
+ }
+ else
+ {
+ $group = "";
+ }
+ }
+
+ if( $input =~ /^protocol\=(.*)/ )
+ {
+ $protocol=$1;
+ print "[$group]\n";
+ if( $protocol eq "imaps" )
+ {
+ print "protocol=imap\n";
+ print "ssl=true\n";
+ }
+ elsif( $protocol eq "pop3s" )
+ {
+ print "protocol=pop3\n";
+ print "ssl=true\n";
+ }
+ else
+ {
+ print "ssl=false\n";
+ }
+ }
+}
diff --git a/korn/kconf_update/korn-3-5-update.upd b/korn/kconf_update/korn-3-5-update.upd
new file mode 100644
index 000000000..d954d7826
--- /dev/null
+++ b/korn/kconf_update/korn-3-5-update.upd
@@ -0,0 +1,10 @@
+Id=korn-3-5-ssl-update
+File=kornrc
+Options=overwrite
+Script=korn-3-5-ssl-update.pl,perl
+
+Id=korn-3-5-metadata-update
+File=kornrc
+Options=overwrite
+Script=korn-3-5-metadata-update.pl,perl
+
diff --git a/korn/keditlistboxman.cpp b/korn/keditlistboxman.cpp
new file mode 100644
index 000000000..43cce8318
--- /dev/null
+++ b/korn/keditlistboxman.cpp
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "keditlistboxman.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include <qmap.h>
+#include <qstring.h>
+
+KEditListBoxManager::KEditListBoxManager( QWidget *parent, const char *name,
+ bool checkAtEntering, int buttons )
+ : KEditListBox( parent, name, checkAtEntering, buttons ),
+ _config( 0 ),
+ _groupName( 0 ),
+ _subGroupName( 0 ),
+ _prevCount( 0 )
+{
+ init();
+}
+
+KEditListBoxManager::KEditListBoxManager( const QString& title, QWidget *parent,
+ const char *name, bool checkAtEntering,
+ int buttons)
+ : KEditListBox( title, parent, name, checkAtEntering, buttons ),
+ _config( 0 ),
+ _groupName( 0 ),
+ _subGroupName( 0 ),
+ _prevCount( 0 )
+{
+ init();
+}
+
+KEditListBoxManager::KEditListBoxManager( const QString& title,
+ const KEditListBox::CustomEditor &customEditor,
+ QWidget *parent, const char *name,
+ bool checkAtEntering, int buttons )
+ : KEditListBox( title, customEditor, parent, name, checkAtEntering, buttons ),
+ _config( 0 ),
+ _groupName( 0 ),
+ _subGroupName( 0 ),
+ _prevCount( 0 )
+{
+ init();
+}
+
+KEditListBoxManager::~KEditListBoxManager()
+{
+ delete _groupName;
+}
+
+void KEditListBoxManager::setConfig( KConfig* config )
+{
+ _config = config;
+ if( _groupName )
+ readNames();
+}
+
+void KEditListBoxManager::setGroupName( const QString& name )
+{
+ if( _groupName )
+ *_groupName = name;
+ else
+ _groupName = new QString( name );
+
+ if( _config )
+ readNames();
+}
+
+void KEditListBoxManager::setSubGroupName( const QString& name )
+{
+ if( _subGroupName )
+ *_subGroupName = name;
+ else
+ _subGroupName = new QString( name );
+
+ if( _config && _groupName )
+ readNames();
+}
+
+void KEditListBoxManager::init()
+{
+ connect( this, SIGNAL( changed() ), this, SLOT( slotChanged() ) );
+ connect( this, SIGNAL( added( const QString& ) ), this, SLOT( slotAdded( const QString& ) ) );
+ connect( this, SIGNAL( removed( const QString& ) ), this, SLOT( slotRemoved( const QString& ) ) );
+
+ connect( this->listBox(), SIGNAL( doubleClicked( QListBoxItem * ) ), this, SLOT( slotActivated( QListBoxItem * ) ) );
+ connect( this->listBox(), SIGNAL( returnPressed( QListBoxItem * ) ), this, SLOT( slotActivated( QListBoxItem * ) ) );
+}
+
+void KEditListBoxManager::readNames()
+{
+ int number = 0;
+
+ this->clear();
+ while( _config->hasGroup( _groupName->arg( number ) ) )
+ {
+ _config->setGroup( _groupName->arg( number ) );
+ this->insertItem( _config->readEntry( "name", QString::null ) );
+ ++number;
+ }
+
+ _prevCount = this->count();
+}
+
+void KEditListBoxManager::slotChanged()
+{
+ /* Three thing could be hapened:
+ * 1. the text is changed;
+ * 2. the item has moved up;
+ * 3. the item has moved down.
+ */
+
+ //_prevCount is invariant under all of these operation
+ //if _prevCount is changed, is wasn't one of those operations.
+
+ if( _prevCount != this->count() )
+ return;
+
+ if( !_config || !_groupName )
+ return;
+
+ //First check if the item was moved up
+
+ _config->setGroup( _groupName->arg( this->currentItem() ) );
+
+ if( this->currentItem() > 0 && this->text( this->currentItem() - 1 ) == _config->readEntry( "name", QString::null ) )
+ changeItem( this->currentItem() - 1, this->currentItem() ); //moved down
+ else if( this->currentItem() < this->count() - 1 &&
+ this->text( this->currentItem() + 1 ) == _config->readEntry( "name", QString::null ) )
+ changeItem( this->currentItem(), this->currentItem() + 1 ); //moved up
+ else if( this->currentText() != _config->readEntry( "name", QString::null ) )
+ changedText(); //changed
+}
+
+void KEditListBoxManager::slotAdded( const QString& name )
+{
+ //Update _prevCount
+ _prevCount = this->count();
+
+ if( !_config || !_groupName )
+ return;
+
+ int number = 0;
+ while( _config->hasGroup( _groupName->arg( number ) ) )
+ ++number;
+
+ _config->setGroup( _groupName->arg( number ) );
+ _config->writeEntry( "name", name );
+
+ emit setDefaults( name, number, _config );
+}
+
+void KEditListBoxManager::slotRemoved( const QString& name )
+{
+ //Update prevCount
+ _prevCount = this->count();
+
+ if( !_config || !_groupName )
+ return;
+
+ //First: search the item number.
+ int number = 0;
+ int subnumber = 0;
+ while( true )
+ {
+ if( !_config->hasGroup( _groupName->arg( number ) ) )
+ {
+ number = -1; //not found
+ break;
+ }
+ _config->setGroup( _groupName->arg( number ) );
+ if( name == _config->readEntry( "name", QString::null ) )
+ break; //found
+
+ ++number; //Try next group
+ }
+
+ if( number < 0 ) //failure
+ return; //do nothing
+
+ _config->deleteGroup( _groupName->arg( number ), true, false );
+ emit elementDeleted( number );
+ while( _subGroupName && _config->hasGroup( _subGroupName->arg( number ).arg( subnumber ) ) )
+ {
+ _config->deleteGroup( _subGroupName->arg( number ).arg( subnumber ) );
+ ++subnumber;
+ }
+
+ //rotate groups
+ while( _config->hasGroup( _groupName->arg( number + 1 ) ) )
+ {
+ moveItem( number + 1, number );
+
+ ++number;
+ }
+}
+
+void KEditListBoxManager::slotActivated( QListBoxItem* item )
+{
+ if( item )
+ emit activated( item->text() );
+}
+
+void KEditListBoxManager::moveItem( int src, int dest )
+{
+ QMap<QString, QString> *srcList = new QMap<QString, QString >;
+ QMap<QString, QString>::iterator it;
+ int subnumber = 0;
+
+ *srcList = _config->entryMap( _groupName->arg( src ) );
+ _config->deleteGroup( _groupName->arg( src ) );
+
+ _config->setGroup( _groupName->arg( dest ) );
+ for( it = srcList->begin(); it != srcList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ while( _subGroupName && _config->hasGroup( _subGroupName->arg( src ).arg( subnumber ) ) )
+ {
+ _config->deleteGroup( _subGroupName->arg( dest ).arg( subnumber ) );
+ _config->setGroup( _subGroupName->arg( dest ).arg( subnumber ) );
+ for( it = srcList->begin(); it != srcList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ ++subnumber;
+ }
+
+ emit elementsSwapped( src, dest );
+
+ delete srcList;
+}
+
+void KEditListBoxManager::changeItem( int first, int last )
+{
+ QMap<QString, QString> *firstList = new QMap<QString, QString >;
+ QMap<QString, QString> *lastList = new QMap<QString, QString >;
+ QMap<QString, QString>::iterator it;
+ int subnumber = 0;
+
+ *firstList = _config->entryMap( _groupName->arg( first ) );
+ *lastList = _config->entryMap( _groupName->arg( last ) );
+ _config->deleteGroup( _groupName->arg( first ) );
+ _config->deleteGroup( _groupName->arg( last ) );
+
+ _config->setGroup( _groupName->arg( last ) );
+ for( it = firstList->begin(); it != firstList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ _config->setGroup( _groupName->arg( first ) );
+ for( it = lastList->begin(); it != lastList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ while( _subGroupName && (
+ _config->hasGroup( _subGroupName->arg( first ).arg( subnumber ) ) ||
+ _config->hasGroup( _subGroupName->arg( last ).arg( subnumber ) ) ) )
+ {
+ *firstList = _config->entryMap( _subGroupName->arg( first ).arg( subnumber ) );
+ *lastList = _config->entryMap( _subGroupName->arg( last ).arg( subnumber ) );
+ _config->deleteGroup( _subGroupName->arg( first ).arg( subnumber ) );
+ _config->deleteGroup( _subGroupName->arg( last ).arg( subnumber ) );
+
+ _config->setGroup( _subGroupName->arg( last ).arg( subnumber ) );
+ for( it = firstList->begin(); it != firstList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ _config->setGroup( _subGroupName->arg( first ).arg( subnumber ) );
+ for( it = lastList->begin(); it != lastList->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ ++subnumber;
+ }
+
+ emit elementsSwapped( first, last );
+
+ delete firstList;
+ delete lastList;
+}
+
+void KEditListBoxManager::changedText()
+{
+ _config->setGroup( _groupName->arg( this->currentItem() ) );
+ _config->writeEntry( "name", this->currentText() );
+}
+
+#include "keditlistboxman.moc"
diff --git a/korn/keditlistboxman.h b/korn/keditlistboxman.h
new file mode 100644
index 000000000..6792ee814
--- /dev/null
+++ b/korn/keditlistboxman.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KEDITLISTBOXMAN_H
+#define MK_KEDITLISTBOXMAN_H
+
+#include <keditlistbox.h>
+
+class KConfig;
+
+class QString;
+class QWidget;
+
+/**
+ * This class is a extention on KEditListBox.
+ * It also handles the configuration.
+ * @author Mart Kelder (mart.kde@hccnet.nl)
+ */
+class KEditListBoxManager : public KEditListBox
+{ Q_OBJECT
+public:
+ /**
+ * Constructor: @see KEditListBoxManager::KEditListBoxManager( const QString&, QWidget, const char * name, bool, int )
+ */
+ KEditListBoxManager( QWidget *parent = 0, const char *name = 0,
+ bool checkAtEntering=true, int buttons = All );
+
+ /**
+ * The save as above, but with other options for KEditListBox.
+ */
+ KEditListBoxManager( const QString& title, QWidget *parent = 0,
+ const char *name = 0, bool checkAtEntering=true,
+ int buttons = All );
+
+ /**
+ * The save as above, but with other options for KEditListBox.
+ */
+ KEditListBoxManager( const QString& title,
+ const KEditListBox::CustomEditor &customEditor,
+ QWidget *parent = 0, const char *name = 0,
+ bool checkAtEntering = true, int buttons = All );
+
+ /**
+ * Destructor
+ */
+ ~KEditListBoxManager();
+
+
+ /**
+ * Set the KConfig object (required before doing something
+ * @param config The KConfig-object
+ */
+ void setConfig( KConfig* config );
+ /**
+ * Sets the groupName. groupName should contain at least one %1.
+ * It is used for makeing groupnames.
+ * @param name The groupname
+ */
+ void setGroupName( const QString& name );
+
+ /**
+ * Sets the subGroupName. subGroupName should contain %1 and %2.
+ * It is used to execute operations on a group and its subgroups.
+ * @param name The groupname
+ */
+ void setSubGroupName( const QString& name );
+private:
+ /**
+ * This functions is called from and only from the constructor to prevent writing the
+ * same code for all constructors
+ */
+ void init();
+
+ /**
+ * This function reads the names out the config.
+ */
+ void readNames();
+private:
+ KConfig *_config; //Stores the KConfig-object
+ QString *_groupName; //Stores the groupName string.
+ QString *_subGroupName;
+ int _prevCount;
+
+private slots:
+ //These comes directly from the KEditListBox itselfs.
+ void slotChanged();
+ void slotAdded( const QString& );
+ void slotRemoved( const QString& );
+
+ void slotActivated( QListBoxItem* );
+private:
+ /**
+ * This private method moves an item. It is called from slotChanged().
+ * @param src The number of the source-group.
+ * @param dest The number of the destanation-group
+ */
+ void moveItem( int src, int dest );
+
+ /**
+ * This private functions switch to groups: first^=last; last^=first; first^=last
+ * @param first the first number of a group.
+ * @param last the second number of a group (and the last number).
+ */
+ void changeItem( int first, int last );
+
+ /**
+ * This function is called if the user change the name of the group
+ */
+ void changedText();
+
+signals:
+ /**
+ * This signal is emitted when somebody selects an item
+ * @param text The text of the newly selected item.
+ */
+ void activated( const QString& text );
+
+ /**
+ * This signal is emitted when defaults have to be set.
+ * @param name The name of the object: this is filled in the KEditListBox;
+ * @param config The configuration in which the config have to be parsed.
+ * @param index The number of the item.
+ * this config is already in the right group.
+ */
+ void setDefaults( const QString& name, const int index, KConfig* config );
+
+ void elementsSwapped( int, int );
+ void elementDeleted( int );
+
+};
+
+#endif //MK_KEDITLISTBOXMAN_H
diff --git a/korn/kio.cpp b/korn/kio.cpp
new file mode 100644
index 000000000..4677c81cf
--- /dev/null
+++ b/korn/kio.cpp
@@ -0,0 +1,561 @@
+/*
+ * Copyright (C) Sirtaj Singh Kang
+ * Copyright (C) Kurt Granroth
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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
+ */
+
+/*
+ * kio.cpp -- Implementation of class KKIODrop.
+ * It is copyied from imap.cpp, with was writed by:
+ * Author: Kurt Granroth
+ * Version: $Id$
+ * Changed by:
+ * Mart Kelder <mart.kde@hccnet.nl>, 2004
+ */
+
+#include "kio.h"
+#include "kio_count.h"
+#include "kio_subjects.h"
+#include "kio_read.h"
+#include "kio_delete.h"
+#include "protocol.h"
+#include "protocols.h"
+#include "stringid.h"
+#include"utils.h"
+//#include"kiocfg.h"
+//#include"dropdlg.h"
+#include "mailsubject.h"
+
+#include<kconfig.h>
+#include<kconfigbase.h>
+#include<kdebug.h>
+#include<klocale.h>
+#include<kprocess.h>
+
+#include<qptrlist.h>
+#include<qregexp.h>
+#include<qvaluelist.h>
+#include<qvaluevector.h>
+
+#include<assert.h>
+#include<ctype.h>
+#include<stdio.h>
+#include<stdlib.h>
+
+//Headers of protocols
+#include"kio_proto.h"
+//#include"pop3_proto.h"
+//#include"pop3s_proto.h"
+//#include"imap_proto.h"
+//#include"imaps_proto.h"
+//#include"nntp_proto.h"
+//#include"maildir_proto.h"
+//#include"qmail_proto.h"
+//#include"process_proto.h"
+#include"mbox_proto.h"
+
+/*
+ * The 'process' maildrop is a lot different than the other protocols:
+ * it haven't a kioslave and could not result in file list. To prevent
+ * trowing it away, that functionality is hacked in this file.
+ */
+
+KKioDrop::KKioDrop()
+ : KPollableDrop(),
+ _kurl( 0 ),
+ _metadata( 0 ),
+ _valid(false),
+ _protocol( 0 ),
+ _ssl(false),
+ _count( 0 ),
+ _subjects( 0 ),
+ _read( 0 ),
+ _readSubjectsTotalSteps( 0 ),
+ _deleteMailsTotalSteps( 0 ),
+ _process( 0 ),
+ _mailurls( 0 )
+{
+ _kurl = new KURL;
+ _metadata = new KIO::MetaData;
+
+ //Initialising protocol; if no protocol is set before first use, it will use the first protocol
+ _protocol = Protocols::firstProtocol()->getKIOProtocol(); //The first protocol is the default
+ _kurl->setPort( _protocol->defaultPort( _ssl ) );
+
+ //Creating children and connect them to the outside world; this class passes the messages for them...
+ //This class handles all the counting.
+ _count = new KIO_Count( this, "kio_count" );
+
+ //This class is responsible for providing the available subjects
+ _subjects = new KIO_Subjects( this, "kio_subjects" );
+
+ //This class is used when a full message has to be read.
+ _read = new KIO_Read( this, "kio_read" );
+
+ //This class can delete mails.
+ _delete = new KIO_Delete( this, "kio_delete" );
+
+ _mailurls = new QValueList<FileInfo>;
+}
+
+KKioDrop::KKioDrop( KConfigGroup* )
+ : KPollableDrop(),
+ _kurl( 0 ),
+ _metadata( 0 ),
+ _valid(false),
+ _protocol( 0 ),
+ _ssl(false),
+ _count( 0 ),
+ _subjects( 0 ),
+ _read( 0 ),
+ _readSubjectsTotalSteps( 0 ),
+ _deleteMailsTotalSteps( 0 ),
+ _process( 0 ),
+ _mailurls( 0 )
+{
+ _kurl = new KURL;
+ _metadata = new KIO::MetaData;
+
+ //Initialising protocol; if no protocol is set before first use, it will use the first protocol
+ _protocol = Protocols::firstProtocol()->getKIOProtocol(); //The first protocol is the default
+ _kurl->setPort( _protocol->defaultPort( _ssl ) );
+
+ //Creating children and connect them to the outside world; this class passes the messages for them...
+ //This class handles all the counting.
+ _count = new KIO_Count( this, "kio_count" );
+
+ //This class is responsible for providing the available subjects
+ _subjects = new KIO_Subjects( this, "kio_subjects" );
+
+ //This class is used when a full message has to be read.
+ _read = new KIO_Read( this, "kio_read" );
+
+ //This class can delete mails.
+ _delete = new KIO_Delete( this, "kio_delete" );
+
+ _mailurls = new QValueList<FileInfo>;
+
+ //readConfigGroup( *config );
+}
+
+void KKioDrop::setKioServer( const QString & proto, const QString & server, int port )
+{
+ //Settings default for last vars; could not inline because KIO::MetaData-object is not defined in header.
+ setKioServer( proto, server, port, KIO::MetaData(), false, true );
+}
+
+void KKioDrop::setKioServer(const QString & proto, const QString & server, int port, const KIO::MetaData metadata, bool ssl,
+ bool setProtocol )
+{
+ QString auth;
+
+ if( port == -1 )
+ port = _protocol->defaultPort( ssl );
+
+ if( setProtocol ) //false if _protocol already made
+ {
+ _protocol = Protocols::getProto( proto )->getKIOProtocol();
+
+ if( ! _protocol )
+ _protocol = Protocols::firstProtocol()->getKIOProtocol();
+ }
+
+ _kurl->setProtocol( _protocol->protocol( ssl ) );
+ _kurl->setHost ( server );
+ _kurl->setPort ( port );
+ _ssl = ssl;
+
+ //Checking for authentication-settings.
+ //if( _metadata->contains("auth") )
+ //{
+ // auth = (*_metadata)["auth"];
+ // *_metadata = metadata;
+ // if( ! _metadata->contains("auth") )
+ // (*_metadata)["auth"] = auth;
+ //} else
+ *_metadata = metadata;
+
+ _count->stopActiveCount();
+}
+
+void KKioDrop::setUser(const QString & user, const QString & password,
+ const QString & mailbox, const QString & auth )
+{
+ _kurl->setUser( user );
+ _password = password ;
+ _kurl->setPass( _password );
+ _kurl->setPath( mailbox );
+ if( ! auth.isEmpty() && auth != "Plain" )
+ (*_metadata)["auth"] = auth;
+ else if( _metadata->contains( "auth" ) )
+ _metadata->erase( "auth" );
+
+ _valid = _kurl->isValid();
+ emit validChanged( valid() );
+
+ if( ! _valid )
+ kdWarning() << i18n( "url is not valid" ) << endl;
+
+ _count->stopActiveCount();
+}
+
+QString KKioDrop::protocol() const
+{
+ return _protocol->configName();
+}
+
+QString KKioDrop::server() const
+{
+ return _kurl->host();
+}
+int KKioDrop::port() const
+{
+ return _kurl->port();
+}
+
+QString KKioDrop::user() const
+{
+ return _kurl->user();
+}
+QString KKioDrop::password() const
+{
+ return _password ;
+}
+QString KKioDrop::mailbox() const
+{
+ return _kurl->path();
+}
+QString KKioDrop::auth() const
+{
+ return ( _metadata->contains("auth")?(*_metadata)["auth"]:"" );
+}
+
+void KKioDrop::recheck()
+{
+ if( _protocol->configName() == "process" ) //Process isn't pollable
+ {
+ emit rechecked();
+ return;
+ }
+
+ _count->count( this );
+
+ return;
+}
+
+void KKioDrop::forceRecheck()
+{
+ if( _protocol->configName() == "process" )
+ return;
+
+ _count->stopActiveCount();
+ _count->count( this );
+
+ return;
+}
+
+bool KKioDrop::valid()
+{
+ return _valid && _count->valid() && _subjects->valid();
+}
+
+KKioDrop::~KKioDrop()
+{
+ delete _count;
+ delete _subjects;
+ delete _kurl;
+ delete _metadata;
+ delete _mailurls;
+}
+
+bool KKioDrop::canReadSubjects( )
+{
+ return (_protocol!=0?_protocol->canReadSubjects():false);
+}
+
+QValueVector<KornMailSubject> * KKioDrop::doReadSubjects(bool * )
+{
+ _subjects->doReadSubjects( this );
+
+ /*
+ * A empty QValueVector is made here.
+ * After that, the size is expanded to the expected number of subjects.
+ * This way, reallocation of memmory is minimized, and thus more efficient.
+ */
+ QValueVector<KornMailSubject> *vector = new QValueVector<KornMailSubject>( );
+ vector->reserve( _mailurls->count() );
+ return vector;
+}
+
+bool KKioDrop::canReadMail( )
+{
+ return (_protocol!=0?_protocol->canReadMail():false);
+}
+
+bool KKioDrop::deleteMails(QPtrList<const KornMailId> * ids, bool * /*stop*/)
+{
+ _delete->deleteMails( ids, this );
+ return _delete->valid();
+}
+
+bool KKioDrop::canDeleteMails ()
+{
+ return (_protocol!=0?_protocol->canDeleteMail():false);
+}
+
+QString KKioDrop::readMail(const KornMailId * item, bool * )
+{
+ _read->readMail( item, this );
+
+ return "";
+}
+
+KMailDrop* KKioDrop::clone() const
+{
+ KKioDrop *clone = new KKioDrop;
+
+ *clone = *this;
+
+ return clone;
+}
+
+bool KKioDrop::readConfigGroup( const QMap< QString, QString > &map, const Protocol* protocol )
+{
+ QString val, val2;
+
+ if( !map.contains( "server" ) || !map.contains( "port" ) || !map.contains( "ssl" ) || !map.contains( "username" ) ||
+ !map.contains( "mailbox" ) || !map.contains( "password" ) || !map.contains( "metadata" ) || !map.contains( "name" ) )
+ {
+ kdWarning() << "Bug: map niet compleet" << endl;
+ return false;
+ }
+
+ this->setName( (*map.find( "name" )).utf8() );
+
+ _protocol = protocol->getKIOProtocol();
+ if( !_protocol )
+ _protocol = Protocols::firstProtocol()->getKIOProtocol();
+
+ val = *map.find( "server" );
+ setKioServer( val2, val, (*map.find( "port" )).toInt(), KIO::MetaData(), *map.find( "ssl" ) == "true", false );
+
+ _kurl->setUser( *map.find( "username" ) );
+ _kurl->setPath( *map.find( "mailbox" ) );
+
+ _kurl->setPass( *map.find( "password" ) );
+
+ QStringList list = QStringList::split( ',', *map.find( "metadata" ) );
+ QStringList::Iterator it;
+ for( it = list.begin(); it != list.end(); ++it )
+ {
+ int split = (*it).find( "=" );
+ if( split > 0 )
+ _metadata->insert( (*it).left( split ), (*it).right( (*it).length() - split - 1 ) );
+ }
+
+ _valid = true;
+ emitValidChanged();
+
+ return true;
+}
+
+bool KKioDrop::writeConfigGroup( KConfigBase& cfg ) const
+{
+ KPollableDrop::writeConfigGroup( cfg );
+ /*QString p;
+
+ if( _kurl->hasPass() ) {
+ p = _kurl->pass();
+ //encrypt ( p );
+ }
+
+ cfg.writeEntry(fu(ProtoConfigKey), _protocol->configName() );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::server )
+ cfg.writeEntry(fu(HostConfigKey), _kurl->host() );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::port )
+ cfg.writeEntry(fu(PortConfigKey), _kurl->port() );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::username )
+ cfg.writeEntry(fu(UserConfigKey), _kurl->user() );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::mailbox )
+ cfg.writeEntry(fu(MailboxConfigKey), _kurl->path() );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::password )
+ cfg.writeEntry(fu(PassConfigKey), p );
+ if( ( _protocol->fields() | _protocol->urlFields() ) & KIO_Protocol::auth )
+ cfg.writeEntry(fu(AuthConfigKey), auth() );
+ */
+ return true;
+}
+
+KKioDrop& KKioDrop::operator = ( const KKioDrop& other )
+{
+ *_kurl=*other._kurl;
+ setFreq( other.freq() );
+
+ if( other._protocol )
+ _protocol = other._protocol->getKIOProtocol();
+ _ssl = other._ssl;
+
+ return *this;
+}
+
+//Public slots
+void KKioDrop::readSubjectsCanceled()
+{
+ _subjects->cancelled();
+}
+
+void KKioDrop::readMailCanceled()
+{
+ _read->canceled( );
+}
+
+void KKioDrop::deleteMailsCanceled()
+{
+ _delete->canceled( );
+}
+
+//Private slots for displaying connection errors
+void KKioDrop::slotConnectionError( int number, const QString& arg )
+{
+ kdError() << KIO::buildErrorString( number, arg ) << endl;
+// if( passivePopup() )
+ emitShowPassivePopup( KIO::buildErrorString( number, arg ) );
+}
+
+void KKioDrop::slotConnectionWarning( const QString& msg )
+{
+ kdWarning() << msg << endl;
+}
+
+void KKioDrop::slotConnectionInfoMessage( const QString& msg )
+{
+ kdDebug() << msg << endl; //Display only in debug modes
+}
+
+//Private slots
+
+//The next functions are needed for process maildrops.
+bool KKioDrop::startProcess()
+{ //code copyied from edrop.cpp
+
+ if( _protocol->configName() != "process" )
+ return true;
+
+ if( _process != 0 ) {
+ return false;
+ }
+
+ // debug( "proc start: %s", _command.data() );
+
+ _process = new KProcess;
+ _process->setUseShell( true );
+
+ // only reading stdin yet
+
+ connect( _process,SIGNAL(receivedStdout( KProcess *, char *, int)),
+ this, SLOT(receivedStdout( KProcess *,char *,int)) );
+ connect( _process, SIGNAL(processExited(KProcess*)),
+ this, SLOT(processExit(KProcess*)) );
+ *_process << _kurl->path();
+ _process->start( KProcess::NotifyOnExit, KProcess::Stdout );
+
+ return true;
+}
+
+bool KKioDrop::stopProcess()
+{ //code copied from edrop.cpp
+ if( _protocol->configName() != "process" )
+ return true;
+
+ if( _process != 0 ) {
+ // debug( "proc stop" );
+ _process->kill( SIGHUP );
+ delete _process;
+ _process = 0;
+ }
+
+ return true;
+}
+
+void KKioDrop::receivedStdout( KProcess *proc, char * buffer, int /*len*/ )
+{
+ assert(static_cast<void *>(proc) == static_cast<void *>(_process));
+
+ //Original code
+ /*char *buf = new char[ len + 1 ];
+ memcpy( buf, buffer, len );
+ buf[ len ] = '\0';
+
+ char *ptr = buf, *start = buf;
+ int num = 0;
+
+ while( *ptr ) {
+ // find number
+ while( *ptr && !isdigit( *ptr ) ) {
+ ptr++;
+ }
+ start = ptr;
+ if( *ptr == 0 ) {
+ break;
+ }
+
+ // find end
+ while( *ptr && isdigit( *ptr ) ) {
+ ptr++;
+ }
+
+ // atoi number
+ char back = *ptr;
+ *ptr = 0;
+ num = atoi( start );
+ *ptr = back;
+ }
+
+ emit changed( num );
+ delete [] buf;*/
+
+ //Alternatieve code
+ QString buf = buffer;
+ QRegExp regexp( "^(.*\\D+|\\D*)(\\d+)\\D*$" );
+
+ if( regexp.search( buf ) == 0 )
+ { //Number found
+ emit changed( regexp.cap( 2 ).toInt(), this );
+ }
+
+
+}
+
+void KKioDrop::processExit(KProcess* proc)
+{
+ assert(static_cast<void *>(proc) == static_cast<void *>(_process));
+
+ _process = 0;
+
+// debug( "proc exited" );
+}
+
+const char *KKioDrop::ProtoConfigKey = "protocol";
+const char *KKioDrop::HostConfigKey = "server";
+const char *KKioDrop::PortConfigKey = "port";
+const char *KKioDrop::UserConfigKey = "username";
+const char *KKioDrop::PassConfigKey = "password";
+const char *KKioDrop::MailboxConfigKey = "mailbox";
+const char *KKioDrop::SavePassConfigKey = "savepass";
+const char *KKioDrop::MetadataConfigKey = "metadata";
+
+#include "kio.moc"
diff --git a/korn/kio.h b/korn/kio.h
new file mode 100644
index 000000000..8ffde2f4b
--- /dev/null
+++ b/korn/kio.h
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) Kurt Granroth
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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
+ */
+
+/*
+ * kio.h -- Declaration of class KKIODrop.
+ */
+#ifndef KEG_KIODROP_H
+#define KEG_KIODROP_H
+
+#include "polldrop.h"
+
+class QWidget;
+class KDropDialog;
+class KornMailSubject;
+class KProcess;
+class KIO_Count;
+class KIO_Protocol;
+class KIO_Subjects;
+class KIO_Read;
+class KIO_Delete;
+class KConfigGroup;
+class KURL;
+template<class> class QPtrList;
+template<class> class QValueList;
+namespace KIO { class Job; class MetaData; class Slave; class TransferJob; }
+
+/**
+ * Polling monitor for IMAP4 maildrops.
+ * @author Kurt Granroth (granroth@kde.org)
+ * Changes to poll with KIO
+ * @author Mart Kelder (mart.kde@hccnet.nl)
+ * $version $Id$
+ */
+class KKioDrop : public KPollableDrop
+{
+ Q_OBJECT
+private:
+ KURL *_kurl;
+ KIO::MetaData *_metadata;
+
+ QString _password;
+
+ bool _valid;
+
+ const KIO_Protocol * _protocol;
+ bool _ssl;
+
+ KIO_Count *_count;
+ KIO_Subjects *_subjects;
+ KIO_Read *_read;
+ KIO_Delete *_delete;
+
+ int _readSubjectsTotalSteps;
+ int _deleteMailsTotalSteps;
+ //For process
+ KProcess *_process;
+
+ //List of mailurls fetched by the last time emails were counted
+ struct FileInfo {
+ QString name;
+ long size;
+ };
+ QValueList<FileInfo> *_mailurls;
+
+ /*
+ * The help-classes of this functions are friend functions, because this way, they can
+ * access the _kurl and _metadata-values without a function; and this way, no signal or
+ * public functions are neccesairy to emit a signal from KKioDrop.
+ */
+ friend class KIO_Count;
+ friend class KIO_Subjects;
+ friend class KIO_Read;
+ friend class KIO_Delete;
+ friend class KIO_Single_Subjects;
+public:
+ static const char *ProtoConfigKey;
+ static const char *HostConfigKey;
+ static const char *PortConfigKey;
+ static const char *UserConfigKey;
+ static const char *MailboxConfigKey;
+ static const char *PassConfigKey;
+ static const char *SavePassConfigKey;
+ static const char *MetadataConfigKey;
+
+public:
+ /**
+ * KKioDrop Constructor
+ */
+ KKioDrop();
+ KKioDrop( KConfigGroup* );
+
+ /**
+ * Set the server that will be checked for new mail.
+ */
+ void setKioServer( const QString & proto, const QString & server, int port = -1 );
+ void setKioServer( const QString & proto, const QString & server, int port,
+ const KIO::MetaData metadata, bool ssl, bool setProtocol = true ); //Last argument inits _protocol
+
+ /** Set the account information for the PROTO server. */
+ void setUser( const QString & user, const QString & password, const QString & mailbox, const QString & auth );
+
+ // The next functions return settings
+ QString protocol() const;
+ QString server() const;
+ int port() const;
+
+ QString user() const;
+ QString password() const;
+ QString mailbox() const;
+ QString auth() const;
+
+ virtual void recheck();
+ virtual void forceRecheck();
+
+ virtual bool valid();
+
+ /**
+ * KKioDrop Destructor
+ */
+ virtual ~KKioDrop();
+
+ virtual bool canReadSubjects(void);
+ virtual QValueVector<KornMailSubject> * doReadSubjects(bool * stop);
+
+ virtual bool canDeleteMails();
+ virtual bool deleteMails(QPtrList<const KornMailId> * ids, bool * stop);
+
+ virtual bool canReadMail ();
+ virtual QString readMail(const KornMailId * id, bool * stop);
+
+ virtual KMailDrop* clone () const ;
+ virtual bool readConfigGroup ( const QMap< QString, QString >& map, const Protocol * protocol );
+ virtual bool writeConfigGroup ( KConfigBase& cfg ) const;
+ virtual QString type() const { return QString::fromUtf8("kio"); }
+
+ virtual bool synchrone() const { return false; } //class is not synchrone
+
+ //virtual void addConfigPage( KDropCfgDialog * );
+
+ virtual bool asynchrone() const { return true; }
+
+private:
+ KKioDrop& operator = ( const KKioDrop& );
+ //static void encrypt( QString& str );
+ //static void decrypt( QString& str );
+
+ /*
+ * The next functions are called from the help-classes (which are friend of the class).
+ * The only thing this functions do is emitting signals.
+ */
+ void emitRechecked() { emit rechecked(); }
+ void emitChanged( int value ) { emit changed( value, this ); }
+
+ void emitReadSubjectsReady( bool success ) { emit readSubjectsReady( success ); }
+ void emitReadSubjectsRead( KornMailSubject * subject ) { emit readSubject( subject ); }
+ void emitReadSubjectsTotalSteps( int value ) { _readSubjectsTotalSteps = value; emit readSubjectsTotalSteps( value ); }
+ void emitReadSubjectsProgress( int value ) { emit readSubjectsProgress( _readSubjectsTotalSteps - value ); }
+
+ void emitReadMailReady( QString* msg ) { emit readMailReady( msg ); }
+
+ void emitDeleteMailsReady( bool value ) { emit deleteMailsReady( value ); }
+ void emitDeleteMailsTotalSteps( int value ) { _deleteMailsTotalSteps = value; emit deleteMailsTotalSteps( value ); }
+ void emitDeleteMailsProgress( int value ) { emit deleteMailsProgress( _deleteMailsTotalSteps - value ); }
+
+ void emitShowPassivePopup( QPtrList< KornMailSubject > *subject, int total )
+ { emit showPassivePopup( subject, total, passiveDate(), this->realName() ); }
+ void emitShowPassivePopup( const QString& error )
+ { if( passivePopup() ) { emit showPassivePopup( error, this->realName() ); } }
+ void emitValidChanged() { emit validChanged( valid() ); }
+
+private slots:
+ void slotConnectionError( int, const QString& );
+ void slotConnectionWarning( const QString& );
+ void slotConnectionInfoMessage( const QString& );
+
+protected:
+ //The next functions are needed for Process;
+ virtual bool startProcess();
+ virtual bool stopProcess();
+
+public slots:
+ virtual void readSubjectsCanceled();
+ virtual void readMailCanceled();
+ virtual void deleteMailsCanceled();
+
+private slots:
+ //For Process too
+ void processExit(KProcess*);
+ void receivedStdout( KProcess *, char *, int);
+};
+#endif // KEG_KIODROP_H
diff --git a/korn/kio_count.cpp b/korn/kio_count.cpp
new file mode 100644
index 000000000..e82827bb4
--- /dev/null
+++ b/korn/kio_count.cpp
@@ -0,0 +1,330 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_count.h"
+
+#include "kio.h"
+#include "kio_proto.h"
+#include "kio_single_subject.h"
+#include "mailsubject.h"
+#include "sortedmailsubject.h"
+
+#include <kdebug.h>
+#include <kio/jobclasses.h>
+#include <kio/scheduler.h>
+#include <kio/slave.h>
+#include <kio/global.h>
+#include <kurl.h>
+#include <qvaluelist.h>
+
+#include <qstring.h>
+
+KIO_Count::KIO_Count( QObject * parent, const char * name )
+ : QObject ( parent, name ),
+ _kurl( 0 ),
+ _metadata( 0 ),
+ _protocol( 0 ),
+ _valid( true ),
+ _new_mailurls( 0 ),
+ _subjects_pending( 0 ),
+ _total_new_messages( 0 ),
+ _popup_subjects( 0 )
+{
+}
+
+KIO_Count::~KIO_Count()
+{
+ // Delete copies of urls.
+ delete _kurl;
+ delete _metadata;
+}
+
+void KIO_Count::count( KKioDrop *drop )
+{
+ if( _new_mailurls )
+ return; //A counting is pending, so no new one is started.
+
+ delete _kurl;
+ delete _metadata;
+ _kio = drop;
+
+ /*
+ * Saving current settings: all actions are asynchroon, so if someone
+ * use slow servers, settings could been changed before this class is
+ * finished with counten. To be able to track back te staring values;
+ * these are saved in the class.
+ */
+ _kurl = new KURL( *_kio->_kurl );
+ _metadata = new KIO::MetaData( *_kio->_metadata );
+ _protocol = _kio->_protocol;
+
+ KURL kurl = *_kurl;
+ KIO::MetaData metadata = *_metadata;
+
+ // Serup a connection
+ if( _protocol->connectionBased( ) )
+ {
+ _protocol->recheckConnectKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( _protocol->defaultPort( _kio->_ssl ) );
+
+ if( ! ( _slave = KIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) //Forcing reload
+ {
+ kdWarning() << i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) << endl;
+ _kio->emitShowPassivePopup( i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) );
+ _valid = false;
+ _kio->emitValidChanged();
+ _slave = 0;
+ //delete _new_mailurls; _new_mailurls = 0; //No connection pending
+ return;
+ }
+
+ connect( _slave, SIGNAL( error( int, const QString& ) ), _kio, SLOT( slotConnectionError( int, const QString& ) ) );
+ connect( _slave, SIGNAL( warning( const QString& ) ), _kio, SLOT( slotConnectionWarning( const QString& ) ) );
+ connect( _slave, SIGNAL( infoMessage( const QString& ) ), _kio, SLOT( slotConnectionInfoMessage( const QString& ) ) );
+
+ /*
+ * _protocol->recheckConnectKURL could have change kurl and metadata in order to have the right
+ * settings to connect. But some other functions assumed unmodified settings,
+ * so the settings are set back to his originals.
+ */
+ kurl = *_kurl;
+ metadata = *_metadata;
+ }
+ else
+ {
+ _slave = 0; //Prevent disconnecting not-existing slave
+ }
+
+ /* Blocking this function: no new counts can be started from now */
+ _new_mailurls = new QValueList< KKioDrop::FileInfo >;
+
+ _protocol->recheckKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( _protocol->defaultPort( _kio->_ssl ) );
+
+ //Making job to fetch file-list
+
+ _job = KIO::listDir( kurl, false );
+ _job->addMetaData( metadata );
+
+ connect( _job, SIGNAL( result( KIO::Job* ) ), this, SLOT( result( KIO::Job* ) ) );
+ connect( _job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList& ) ),
+ this, SLOT( entries( KIO::Job*, const KIO::UDSEntryList& ) ) );
+
+ if( _protocol->connectionBased() )
+ KIO::Scheduler::assignJobToSlave( _slave, _job );
+ else
+ KIO::Scheduler::scheduleJob( _job );
+}
+
+void KIO_Count::stopActiveCount()
+{
+ if( !_new_mailurls )
+ return;
+
+ disconnect( _job, SIGNAL( result( KIO::Job* ) ), this, SLOT( result( KIO::Job* ) ) );
+ disconnect( _job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList& ) ),
+ this, SLOT( entries( KIO::Job*, const KIO::UDSEntryList& ) ) );
+
+ KIO::Scheduler::cancelJob( _job );
+
+ if( _slave )
+ {
+ //Slave seems to be disconnected by canceling the last job of the slave
+ //KIO::Scheduler::disconnectSlave( _slave );
+ _slave = 0;
+ }
+
+ //Deletings settings
+ delete _kurl; _kurl = 0;
+ delete _metadata; _metadata = 0;
+
+ delete _new_mailurls; _new_mailurls = 0;
+}
+
+void KIO_Count::showPassive( const QString& id )
+{
+ KURL kurl = *_kio->_kurl;
+ KIO::MetaData metadata = *_kio->_metadata;
+ kurl = id;
+ //KIO::Slave *slave = 0;
+
+ _kio->_protocol->readSubjectKURL( kurl, metadata );
+ if( kurl.port() == 0 )
+ kurl.setPort( _kio->_protocol->defaultPort( _kio->_ssl ) );
+
+ KIO_Single_Subject *subject = new KIO_Single_Subject( this, id.latin1(), kurl, metadata, _kio->_protocol, _slave, id, 0 );
+
+ _subjects_pending++;
+
+ connect( subject, SIGNAL( readSubject( KornMailSubject* ) ), this, SLOT( addtoPassivePopup( KornMailSubject* ) ) );
+ connect( subject, SIGNAL( finished( KIO_Single_Subject* ) ), this, SLOT( deleteSingleSubject( KIO_Single_Subject* ) ) );
+}
+
+void KIO_Count::disconnectSlave()
+{
+ if( _subjects_pending > 0 )
+ return; //Still getting data
+
+ if( !_protocol->connectionBased() )
+ return; //Protocol doesn't have a connection
+
+ if( !_slave )
+ return; //Slave doens't exist
+
+ //Disconnect slave
+ KIO::Scheduler::disconnectSlave( _slave );
+ _slave = 0;
+ _protocol = 0;
+}
+
+//This function is called when fetching is over
+void KIO_Count::result( KIO::Job* job )
+{
+ //job should be the latest job; elsewise: print an error.
+ if( job != _job )
+ kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl;
+
+ //look of an error occurred. If there is, print the error.
+ //This could be very useful by resolving bugs.
+ if( job->error() )
+ {
+ kdError() << i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) << endl;
+ _kio->emitShowPassivePopup( i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) );
+ _valid = false;
+ _kio->emitValidChanged();
+ }
+
+ disconnect( job, SIGNAL( result( KIO::Job* ) ), this, SLOT( result( KIO::Job* ) ) );
+ disconnect( job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList& ) ),
+ this, SLOT( entries( KIO::Job*, const KIO::UDSEntryList& ) ) );
+
+ disconnectSlave();
+
+ //Deletings settings
+ delete _kurl; _kurl = 0;
+ delete _metadata; _metadata = 0;
+
+ if( _kio->_mailurls->count() != _new_mailurls->count() )
+ {
+ *_kio->_mailurls = *_new_mailurls;
+ _kio->emitChanged(_kio->_mailurls->count());
+ }
+ else
+ {
+ *_kio->_mailurls = *_new_mailurls;
+ }
+ delete _new_mailurls; _new_mailurls = 0;
+
+ _valid = true;
+ _kio->emitValidChanged();
+ _kio->emitRechecked();
+}
+
+//An file list is ready; now save it in _kio->_mailurls.
+void KIO_Count::entries( KIO::Job* job, const KIO::UDSEntryList &list )
+{
+ QStringList old_list;
+ KIO::UDSEntryListConstIterator it1 ;
+ KIO::UDSEntry::ConstIterator it2 ;
+ KIO::MetaData metadata;
+ KURL kurl;
+ bool isFile;
+
+ //job should be the latest job
+ if( job != _job )
+ kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl;
+
+ for( QValueListConstIterator<KKioDrop::FileInfo> it = _kio->_mailurls->begin(); it != _kio->_mailurls->end(); ++it )
+ old_list.append( (*it).name );
+
+ for ( it1 = list.begin() ; it1 != list.end() ; it1++ )
+ {
+ /*
+ * The list contains multiple objects. Each object could be a file.
+ * Settings about it are saved in this scope until it is added to the list.
+ */
+ isFile=false;
+ KKioDrop::FileInfo fileinfo;
+ fileinfo.name = QString::null;
+ fileinfo.size = 0;
+
+ for ( it2 = (*it1).begin() ; it2 != (*it1).end() ; it2++ )
+ {
+ if( (*it2).m_uds == KIO::UDS_FILE_TYPE &&
+ ((long)(*it2).m_long & S_IFREG ) )
+ isFile=true;
+ else if( (*it2).m_uds == KIO::UDS_URL )
+ fileinfo.name = (*it2).m_str;
+ else if( (*it2).m_uds == KIO::UDS_NAME )
+ { //The file kioslave doesn't return UDS_URL.
+ kurl = *_kurl;
+ metadata = *_metadata;
+ _protocol->recheckKURL( kurl, metadata );
+ kurl.setPath ( kurl.path() + '/' + (*it2).m_str );
+ fileinfo.name = kurl.url();
+ }
+ else if( (*it2).m_uds == KIO::UDS_SIZE )
+ {
+ fileinfo.size = (*it2).m_long;
+ }
+ }
+
+ //Add the entry.
+ if( ! fileinfo.name.isNull() && isFile )
+ {
+ _new_mailurls->append( fileinfo );
+ if( ! old_list.contains( fileinfo.name ) && _kio->passivePopup() )
+ showPassive( fileinfo.name );
+ }
+ }
+}
+
+void KIO_Count::addtoPassivePopup( KornMailSubject* subject )
+{
+ if( ! _popup_subjects )
+ {
+ _popup_subjects = new SortedMailSubject;
+ _popup_subjects->setAutoDelete( true );
+ }
+
+ _popup_subjects->inSort( subject );
+ if( _popup_subjects->count() > 5 )
+ _popup_subjects->removeFirst(); //Overhead: subject is downloaded
+
+ _subjects_pending--;
+ _total_new_messages++;
+ if( _subjects_pending == 0 )
+ {
+ _kio->emitShowPassivePopup( dynamic_cast< QPtrList<KornMailSubject>* >( _popup_subjects ), _total_new_messages );
+ delete _popup_subjects; _popup_subjects = 0;
+ _total_new_messages = 0;
+
+ disconnectSlave();
+ }
+}
+
+void KIO_Count::deleteSingleSubject( KIO_Single_Subject* single_subject )
+{
+ delete single_subject;
+}
+
+#include "kio_count.moc"
diff --git a/korn/kio_count.h b/korn/kio_count.h
new file mode 100644
index 000000000..c9a1b9f08
--- /dev/null
+++ b/korn/kio_count.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIOCOUNT_H
+#define MK_KIOCOUNT_H
+
+//This class count the number of message available.
+
+#include <qobject.h>
+
+#include "kio.h" //Alsewise, no access to KKioDrop::FileInfo (needed in template)
+
+#include <kio/global.h> //FIXME: without this, moc-compiler fails.
+
+class KIO_Protocol;
+class KIO_Single_Subject;
+class KKioDrop;
+
+class KornMailSubject;
+class SortedMailSubject;
+
+template<class T> class QValueList;
+namespace KIO { class Job; class ListJob; class MetaData; class Slave; }
+
+class KURL;
+
+class QString;
+
+class KIO_Count : public QObject
+{ Q_OBJECT
+public:
+ KIO_Count( QObject * parent = 0, const char * name = 0 );
+ ~KIO_Count();
+
+ //This function starts counting
+ void count( KKioDrop* );
+
+ //This functions returns true of no error has occurred.
+ bool valid( ) { return _valid; }
+
+ void stopActiveCount();
+private:
+ KKioDrop *_kio;
+ KIO::ListJob *_job;
+ KIO::Slave *_slave;
+ KURL *_kurl;
+ KIO::MetaData *_metadata;
+ const KIO_Protocol *_protocol;
+ bool _valid;
+ QValueList<KKioDrop::FileInfo> *_new_mailurls; //entries can come with more function calls.
+ int _subjects_pending;
+ int _total_new_messages;
+ SortedMailSubject *_popup_subjects;
+private:
+ void showPassive( const QString& );
+ void disconnectSlave();
+
+private slots:
+ void result( KIO::Job* );
+ void entries( KIO::Job*, const KIO::UDSEntryList &list );
+
+ void addtoPassivePopup( KornMailSubject* );
+ void deleteSingleSubject( KIO_Single_Subject* );
+};
+
+#endif
diff --git a/korn/kio_delete.cpp b/korn/kio_delete.cpp
new file mode 100644
index 000000000..78c2d88ac
--- /dev/null
+++ b/korn/kio_delete.cpp
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_delete.h"
+
+#include "mailid.h"
+#include "stringid.h"
+#include "kio.h"
+#include "kio_proto.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kio/global.h>
+#include <kio/jobclasses.h>
+#include <kio/scheduler.h>
+
+#include <qptrlist.h>
+
+KIO_Delete::KIO_Delete( QObject * parent, const char * name ) : QObject( parent, name ),
+ _kio( 0 ),
+ _total( 0 ),
+ _jobs( 0 ),
+ _slave( 0 ),
+ _valid( true )
+{
+ _jobs = new QPtrList< KIO::Job >;
+}
+
+KIO_Delete::~KIO_Delete( )
+{
+ disConnect( );
+ delete _jobs;
+}
+
+bool KIO_Delete::deleteMails( QPtrList< const KornMailId > * ids, KKioDrop *drop )
+{
+ KURL kurl = *drop->_kurl;
+ KIO::MetaData metadata = *drop->_metadata;
+
+ _kio = drop;
+ _valid = true;
+
+ //disConnect earlier operations
+ disConnect( );
+ if( _kio->_protocol->connectionBased( ) )
+ {
+ if( ! setupSlave( kurl, metadata, _kio->_protocol ) )
+ {
+ _valid = false;
+ return false;
+ }
+ }
+
+ _total = ids->count( );
+
+ for( const KornMailId * item = ids->first(); item; item = ids->next() )
+ deleteItem( item, kurl, metadata, _kio->_protocol );
+
+ if( _jobs->count() == 0 )
+ {
+ _kio->emitDeleteMailsReady( true );
+ disConnect( );
+ return true;
+ }
+
+ if( _kio->_protocol->commitDelete() )
+ commitDelete( kurl, metadata, _kio->_protocol );
+
+ _kio->emitDeleteMailsTotalSteps( _total );
+
+ return true;
+}
+
+void KIO_Delete::disConnect( )
+{
+ _jobs->clear( );
+
+ if( _slave )
+ {
+ KIO::Scheduler::disconnectSlave( _slave );
+ _slave = 0;
+ }
+}
+
+bool KIO_Delete::setupSlave( KURL kurl, KIO::MetaData metadata, const KIO_Protocol *& protocol )
+{
+ protocol->deleteMailConnectKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( protocol->defaultPort( _kio->_ssl ) );
+
+ if( ! ( _slave = KIO::Scheduler::getConnectedSlave( kurl, metadata ) ) )
+ {
+ kdWarning() << i18n( "Could not get a connected slave; I cannot delete this way..." ) << endl;
+ _valid = false;
+ return false;
+ }
+
+ return true;
+}
+
+void KIO_Delete::deleteItem( const KornMailId *item, KURL kurl, KIO::MetaData metadata, const KIO_Protocol *& protocol )
+{
+ KIO::Job* job = 0;
+
+ kurl = dynamic_cast<const KornStringId*>( item )->getId();
+
+ protocol->deleteMailKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( protocol->defaultPort( _kio->_ssl ) );
+
+ if( protocol->deleteFunction() == KIO_Protocol::get )
+ {
+ job = KIO::get( kurl, true, false );
+
+ if( protocol->connectionBased() )
+ KIO::Scheduler::assignJobToSlave( _slave, dynamic_cast< KIO::SimpleJob* >( job ) );
+ else
+ KIO::Scheduler::scheduleJob( dynamic_cast< KIO::SimpleJob* >( job ) );
+ }
+ else if( protocol->deleteFunction() == KIO_Protocol::del )
+ {
+ job = KIO::del( kurl, false, false );
+ }
+ else
+ return; //Unknown deleteFunction
+
+ connect( job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotResult( KIO::Job* ) ) );
+
+ job->addMetaData( metadata );
+
+ _jobs->append( dynamic_cast< KIO::Job* >( job ) );
+}
+
+/*
+ * Some protocols needs to a command to commit protocols.
+ */
+void KIO_Delete::commitDelete( KURL kurl, KIO::MetaData metadata, const KIO_Protocol *& protocol )
+{
+ protocol->deleteCommitKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( protocol->defaultPort( _kio->_ssl ) );
+
+ KIO::TransferJob *job = KIO::get( kurl, true, false );
+ job->addMetaData( metadata );
+ connect( job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotResult( KIO::Job* ) ) );
+
+ _jobs->append( dynamic_cast< KIO::Job* >( job ) );
+
+ if( protocol->connectionBased() )
+ KIO::Scheduler::assignJobToSlave( _slave, job );
+ else
+ KIO::Scheduler::scheduleJob( job );
+
+ _total++;
+}
+
+void KIO_Delete::canceled( )
+{
+ disConnect( );
+}
+
+void KIO_Delete::slotResult( KIO::Job* job )
+{
+ if( job->error() )
+ {
+ kdWarning() << i18n( "An error occurred when deleting email: %1." ).arg( job->errorString() ) << endl;
+ _valid = false;
+ }
+
+ _jobs->remove( job );
+
+ _kio->emitDeleteMailsProgress( _total - _jobs->count() );
+
+ if( _jobs->isEmpty() )
+ {
+ _kio->emitDeleteMailsReady( _valid );
+ disConnect();
+ }
+}
+
+
+#include "kio_delete.moc"
diff --git a/korn/kio_delete.h b/korn/kio_delete.h
new file mode 100644
index 000000000..a22c6f17f
--- /dev/null
+++ b/korn/kio_delete.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIO_DELETE_H
+#define MK_KIO_DELETE_H
+
+/*
+ * This class handles removing of selected messages.
+ * This class starts working when deleteMails() is called.
+ */
+
+#include <qobject.h>
+class KKioDrop;
+class KIO_Protocol;
+class KornMailId;
+
+class KURL;
+namespace KIO { class MetaData; class Job; class Slave; }
+
+template<class T> class QPtrList;
+
+class KIO_Delete : public QObject
+{ Q_OBJECT
+public:
+ //constructors
+ KIO_Delete( QObject * parent = 0, const char * name = 0 );
+ ~KIO_Delete( );
+
+ //This function should be called if there are messages to be deleted.
+ bool deleteMails( QPtrList< const KornMailId > *, KKioDrop* );
+
+ //This function should return false then and only then if an error occurred.
+ bool valid( ) { return _valid; }
+
+public slots:
+ //If this slot is called, the whole deletion is canceled.
+ void canceled( );
+private slots:
+ void slotResult( KIO::Job* );
+
+private:
+ void disConnect( );
+ bool setupSlave( KURL kurl, KIO::MetaData metadata, const KIO_Protocol *& protocol );
+ void deleteItem( const KornMailId *item, KURL, KIO::MetaData, const KIO_Protocol *&);
+ void commitDelete( KURL, KIO::MetaData, const KIO_Protocol *& );
+
+ KKioDrop *_kio;
+ unsigned int _total;
+ QPtrList< KIO::Job > *_jobs;
+ KIO::Slave *_slave;
+ bool _valid;
+};
+
+#endif //MK_KIO_DELETE_H
diff --git a/korn/kio_proto.cpp b/korn/kio_proto.cpp
new file mode 100644
index 000000000..a3de22723
--- /dev/null
+++ b/korn/kio_proto.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_proto.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include <qmap.h>
+
+QMap< QString, QString >* KIO_Protocol::createConfig( KConfigGroup * group, const QString& password ) const
+{
+ QMap< QString, QString > *result = new QMap< QString, QString >;
+
+ result->insert( "name", group->readEntry( "name", "" ) );
+ result->insert( "server", group->readEntry( "server", "" ) );
+ result->insert( "port", group->readEntry( "port", "" ) );
+ result->insert( "username", group->readEntry( "username", "" ) );
+ result->insert( "password", password );
+ result->insert( "mailbox", group->readEntry( "mailbox", "" ) );
+ result->insert( "savepassword", group->readEntry( "savepassword", "false" ) );
+ result->insert( "ssl", group->readEntry( "ssl", "false" ) );
+ result->insert( "metadata", group->readEntry( "metadata", "" ) );
+
+ return result;
+}
+
+void KIO_Protocol::clearFields( QMap<QString, QString> *map, const KIO_Protocol::Fields fields ) const
+{
+ if( fields & server )
+ map->insert( "server", "" );
+ if( fields & port )
+ map->insert( "port", "" );
+ if( fields & username )
+ map->insert( "username", "" );
+ if( fields & password )
+ map->insert( "password", "" );
+ if( fields & mailbox )
+ map->insert( "mailbox", "" );
+ if( fields & save_password )
+ map->insert( "savepassword", "" );
+ if( fields & metadata )
+ map->insert( "metadata", "" );
+}
+
+void KIO_Protocol::readEntries( QMap< QString, QString >* map ) const
+{
+ QMap< QString, QString> *metadata = new QMap< QString, QString >;
+
+ if( map->contains( "metadata" ) )
+ {
+ QStringList list = QStringList::split( ",", *map->find( "metadata" ) );
+ QStringList::Iterator it;
+ for( it = list.begin(); it != list.end(); ++it )
+ {
+ int split = (*it).find( '=' );
+
+ metadata->insert( (*it).left( split ), (*it).right( (*it).length() - split - 1 ) );
+ }
+ }
+
+ this->readEntries( map, metadata );
+
+ delete metadata;
+}
diff --git a/korn/kio_proto.h b/korn/kio_proto.h
new file mode 100644
index 000000000..3770f1209
--- /dev/null
+++ b/korn/kio_proto.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIO_PROTO_H
+#define MK_KIO_PROTO_H
+
+/*
+ * KIO can handle multiple protocols. But some protocols have their own
+ * manipulations of KURL or MetaData , and some protocols could do more then other
+ * protocols. So, this class is the generic class of a class specified
+ * by a protocol.
+ */
+
+class QString;
+#include <kio/global.h>
+#include <klocale.h>
+#include <qstringlist.h>
+#include "protocol.h"
+
+#include "kio.h"
+
+class KIO_Protocol : public Protocol
+{
+public:
+ /*
+ * Constuctor; empty
+ */
+ KIO_Protocol() {}
+
+ /*
+ * Destructor; empty too
+ */
+ virtual ~KIO_Protocol() {}
+
+ /*
+ * Public enumeration
+ */
+ enum DeleteTypeEnum { get, del };
+ /**
+ * This are the implementation of the Protocol-functions
+ */
+ virtual const Protocol* getProtocol( KConfigGroup* ) const { return this; }
+
+ virtual KMailDrop* createMaildrop( KConfigGroup* config ) const { return new KKioDrop( config ); }
+
+ virtual QMap< QString, QString >* createConfig( KConfigGroup *group, const QString& password ) const;
+
+ /*
+ * @return: the name of the kio_slave
+ */
+ virtual QString protocol( bool ) const { return "file"; }
+
+ /*
+ * @return: the name of the protocol used by the configuration
+ */
+ virtual QString configName() const { return "not specified"; }
+
+ virtual bool connectionBased() const { return false; }
+
+ /*
+ * The next four functions return the [capebilities] of a protocol.
+ * fullMessage means that by downloaden, the whole message is downloaded.
+ * if it is false, only the headers should be downloaded.
+ */
+ virtual bool canReadSubjects() const { return false; }
+ virtual bool canDeleteMail() const { return false; }
+ virtual bool canReadMail() const { return false; }
+ virtual bool fullMessage() const { return false; }
+
+ /*
+ * The following lines are the options in the configuration;
+ * true means that an option is enabled;
+ * false means that the option is disabled.
+ */
+ //virtual int fields() const { return server | port | username | password | mailbox; }
+ //virtual int urlFields() const { return no_fields; }
+ virtual unsigned short defaultPort( bool ) const { return 0; }
+
+ /*
+ * This sets the string of such fields in Configuration
+ */
+ virtual QString serverName() const { return i18n( "Server:" ); }
+ virtual QString portName() const { return i18n( "Port:" ); }
+ virtual QString usernameName() const { return i18n( "Username:" ); }
+ virtual QString mailboxName() const { return i18n( "Mailbox:" ); }
+ virtual QString passwordName() const { return i18n( "Password:" ); }
+ virtual QString savePasswordName() const { return i18n( "Save password" ); }
+ virtual QString authName() const { return i18n( "Authentication:" ); }
+
+ /*
+ * The next function returns the method of deleting: some protoocols
+ * like to delete files with KIO::get; other with KIO::del
+ */
+ virtual DeleteTypeEnum deleteFunction() const { return del; }
+
+ /*
+ * The next options are the input for the Authentication Combo, seperated by '|'.
+ * The name should be the same as the auth-metadata.
+ */
+ virtual QStringList authList() const { return QStringList::split( '|', "Plain", false ); }
+
+ /*
+ * The next functions are manipulations of an KURL.
+ * At some points in the code, a KURL is used. But sometimes,
+ * these have to had a little retouch. That is possible with these function.
+ *
+ * For example, by imap, by default, the whole message is downloaded and marked as reed.
+ * By changing an option to the KURL path, this can be prevented.
+ *
+ * The most functions are recognized by name.
+ * commitDelete return true if a protocol has to confirm a deletion.
+ * It will be called after marking the messages for deletion.
+ * deleteCommitKURL is the KURL manipulator; the KURL is as in the settings.
+ * That KURL isn't retouch by deleteMailKURL.
+ */
+ virtual void recheckConnectKURL( KURL &, KIO::MetaData & ) const { }
+ virtual void recheckKURL ( KURL &, KIO::MetaData & ) const { };
+ virtual void readSubjectConnectKURL ( KURL & kurl, KIO::MetaData & ) const { kurl.setPath( "" ); }
+ virtual void readSubjectKURL ( KURL &, KIO::MetaData & ) const { } //For editing a kurl (adding extra options)
+ virtual void deleteMailConnectKURL( KURL & kurl, KIO::MetaData & ) const { kurl.setPath( "" ); }
+ virtual void deleteMailKURL ( KURL &, KIO::MetaData & ) const { }
+ virtual bool commitDelete() const { return false; }
+ virtual void deleteCommitKURL( KURL &, KIO::MetaData & ) const { }
+ virtual void readMailKURL ( KURL &, KIO::MetaData & ) const { }
+
+
+ virtual const KIO_Protocol* getKIOProtocol() const { return this; }
+
+ virtual void readEntries( QMap< QString, QString >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const = 0;
+
+protected:
+ /*
+ * This enumeration is used when returning the capebilitys of a protocol
+ */
+ enum Fields { no_fields = 0, server = 1, port = 2, username = 4, password = 8,
+ mailbox = 16, save_password = 32, metadata = 64 };
+
+ void clearFields( QMap< QString, QString > *map, const Fields fields ) const;
+};
+
+#endif //MK_KIO_PROTO_H
diff --git a/korn/kio_read.cpp b/korn/kio_read.cpp
new file mode 100644
index 000000000..e1f5211e4
--- /dev/null
+++ b/korn/kio_read.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_read.h"
+
+#include "kio.h"
+#include "kio_proto.h"
+#include "mailid.h"
+#include "stringid.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kio/global.h>
+#include <kio/jobclasses.h>
+#include <kio/scheduler.h>
+
+#include <qcstring.h>
+#include <qstring.h>
+
+KIO_Read::KIO_Read( QObject * parent, const char * name )
+ : QObject( parent, name ),
+ _job( 0 ),
+ _message( 0 )
+{
+ _message = new QString;
+}
+
+KIO_Read::~KIO_Read()
+{
+ delete _message;
+ delete _job;
+}
+
+void KIO_Read::readMail( const KornMailId *& mailid, KKioDrop* drop )
+{
+ _kio = drop;
+ KURL kurl = *_kio->_kurl;
+ KIO::MetaData metadata = *_kio->_metadata;
+
+ kurl = dynamic_cast<const KornStringId*>(mailid)->getId( );
+
+ _kio->_protocol->readMailKURL( kurl, metadata );
+
+ _job = KIO::get( kurl, false, false );
+ _job->addMetaData( metadata );
+
+ connect( _job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotResult( KIO::Job* ) ) );
+ connect( _job, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray & ) ) );
+}
+
+void KIO_Read::canceled( )
+{
+ if( _job )
+ delete _job;
+ _job = 0;
+}
+
+void KIO_Read::slotResult( KIO::Job* job )
+{
+ if( job != _job )
+ kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl;
+
+ if( job->error() )
+ kdWarning() << i18n( "An error occurred when fetching the requested email: %1." ).arg( job->errorString() ) << endl;
+
+ _kio->emitReadMailReady( _message );
+
+ *_message = "";
+ _job = 0;
+}
+
+void KIO_Read::slotData( KIO::Job* job, const QByteArray & data )
+{
+ if( job != _job )
+ kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl;
+
+ if( !data.isEmpty() )
+ _message->append( data );
+}
+
+#include "kio_read.moc"
diff --git a/korn/kio_read.h b/korn/kio_read.h
new file mode 100644
index 000000000..52dd986ab
--- /dev/null
+++ b/korn/kio_read.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIO_READ_H
+#define MK_KIO_READ_H
+
+//This class should be used if someone wants to read the Full Message
+
+#include <qobject.h>
+
+class KKioDrop;
+class KornMailId;
+
+class KURL;
+namespace KIO { class MetaData; class Job; }
+class KIO_Protocol;
+
+class QString;
+
+class KIO_Read : public QObject
+{ Q_OBJECT
+public:
+ KIO_Read( QObject * parent = 0, const char * name = 0 );
+ ~KIO_Read();
+
+public slots:
+ //This is the function which makes the nessesairy slaves for reading a message
+ void readMail( const KornMailId *&, KKioDrop* );
+ //This function should be called if the user presses canceled.
+ void canceled();
+private:
+ KKioDrop *_kio;
+ KIO::Job *_job;
+ QString *_message;
+
+signals:
+ //This signal is emitted when the whole message is read; the message got passed as QString*
+ void ready( QString* );
+
+private slots:
+ void slotResult( KIO::Job* );
+ void slotData( KIO::Job*, const QByteArray& );
+};
+
+#endif //MK_KIO_READ_H
diff --git a/korn/kio_single_subject.cpp b/korn/kio_single_subject.cpp
new file mode 100644
index 000000000..cdb70733f
--- /dev/null
+++ b/korn/kio_single_subject.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_single_subject.h"
+
+#include "mailsubject.h"
+#include "kio_proto.h"
+#include "stringid.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kio/global.h>
+#include <kio/scheduler.h>
+#include <kio/job.h>
+#include <kio/jobclasses.h>
+#include <krfcdate.h>
+
+#include <qregexp.h>
+#include <qcstring.h>
+#include <qstring.h>
+
+KIO_Single_Subject::KIO_Single_Subject( QObject * parent, const char * name,
+ KURL &kurl, KIO::MetaData &metadata, const KIO_Protocol * protocol, KIO::Slave *& slave,
+ const QString &url, const long size )
+ : QObject( parent, name )
+{
+ _kurl = new KURL( kurl );
+ _metadata = new KIO::MetaData( metadata );
+ _protocol = protocol;
+ _name = new QString( url );
+ _size = size;
+ _message = new QString;
+
+ init( slave );
+}
+
+KIO_Single_Subject::~KIO_Single_Subject( )
+{
+ if( _job )
+ KIO::Scheduler::cancelJob( _job );
+ delete _kurl;
+ delete _metadata;
+ delete _name;
+ delete _message;
+}
+
+void KIO_Single_Subject::init( KIO::Slave *& slave)
+{
+ _job = KIO::get( *_kurl, false, false );
+ _job->addMetaData( *_metadata );
+
+ connect( _job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotResult( KIO::Job* ) ) );
+ connect( _job, SIGNAL( data (KIO::Job *, const QByteArray &) ),
+ this, SLOT( slotData(KIO::Job *, const QByteArray &) ) );
+
+ if( _protocol->connectionBased( ) && slave )
+ KIO::Scheduler::assignJobToSlave( slave , _job );
+ else
+ KIO::Scheduler::scheduleJob( _job );
+
+}
+
+void KIO_Single_Subject::parseMail( QString * message, KornMailSubject *subject, bool fullMessage )
+{
+ QTextStream stream( message, IO_ReadOnly );
+ QString line;
+ QRegExp rx_sender( "^[fF]rom: " ); //Ex: From: ...
+ QRegExp rx_sender_has_name1( "^[fF]rom:\\s*(\\w+[\\w\\s]*)\\<" ); //Ex: From: A name<email@domein.country>
+ QRegExp rx_sender_has_name2( "^[fF]rom:\\s*\\\"\\s*(\\w+[\\w\\s]*)\\\""); //Ex: From: "A name"<a@invalid>
+ QRegExp rx_subject( "^[sS]ubject: " ); //Ex: Subject: ...
+ QRegExp rx_date ( "^[dD]ate: ");
+ bool inheader = true;
+ int fieldnumber = 0;
+
+ while ( ! stream.atEnd() )
+ {
+ line = stream.readLine();
+ if( line.isEmpty() && fieldnumber >= 2 )
+ inheader = false;
+
+ if( inheader )
+ {
+ if( rx_sender.search( line ) == 0 )
+ {
+ if( rx_sender_has_name1.search( line ) == 0 )
+ subject->setSender( rx_sender_has_name1.cap( 1 ) );
+ else if(rx_sender_has_name2.search( line ) == 0)
+ subject->setSender( rx_sender_has_name2.cap( 1 ) );
+ else
+ subject->setSender( line.remove( rx_sender ) );
+ ++fieldnumber;
+ }
+ else if( rx_subject.search( line ) == 0 )
+ {
+ subject->setSubject( line.remove( rx_subject ) );
+ ++fieldnumber;
+ }
+ else if( rx_date.search( line ) == 0 )
+ {
+ subject->setDate( KRFCDate::parseDate( line.right( line.length() - 6 ) ) );
+ ++fieldnumber;
+ }
+ }
+ }
+
+ subject->setHeader( *message, fullMessage );
+}
+
+void KIO_Single_Subject::slotData( KIO::Job* job, const QByteArray& data )
+{
+ if( job != _job )
+ kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl;
+ if( !data.isEmpty() )
+ _message->append( data );
+}
+
+//KIO::Scheduler::disconnectSlave missing if connection stops
+void KIO_Single_Subject::slotResult( KIO::Job *job )
+{
+ if( job != _job )
+ kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl;
+
+ if( job->error() )
+ {
+ kdWarning() << i18n( "Error when fetching %1: %2" ).arg( *_name ).arg( job->errorString() ) << endl;
+ } else {
+ KornMailSubject * mailSubject = new KornMailSubject( new KornStringId( *_name ), 0 );
+ parseMail( _message, mailSubject, _protocol->fullMessage() );
+ mailSubject->decodeHeaders();
+ mailSubject->setSize( _size );
+ emit readSubject( mailSubject );
+ }
+
+ _job = 0;
+
+ emit finished( this );
+}
+
+#include "kio_single_subject.moc"
diff --git a/korn/kio_single_subject.h b/korn/kio_single_subject.h
new file mode 100644
index 000000000..d235680ab
--- /dev/null
+++ b/korn/kio_single_subject.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIO_SINGEL_SUBJECT_H
+#define MK_KIO_SINGEL_SUBJECT_H
+
+//This function reads a single subject
+
+#include <qobject.h>
+
+class KornMailSubject;
+
+class KURL;
+namespace KIO { class MetaData; class Job; class TransferJob; class Slave; }
+class KIO_Protocol;
+
+class QString;
+template<class T> class QMemArray;
+typedef QMemArray<char> QByteArray;
+
+class KIO_Single_Subject : public QObject
+{ Q_OBJECT
+public:
+ KIO_Single_Subject( QObject * parent, const char * name, KURL &, KIO::MetaData &, const KIO_Protocol *,
+ KIO::Slave *&, const QString &, const long );
+ ~KIO_Single_Subject( );
+
+ //This functions try's te parse EMail; data, sender names and so on...
+ static void parseMail( QString * message, KornMailSubject *subject, bool );
+
+private:
+ QString *_message;
+ QString *_name;
+ KURL *_kurl;
+ const KIO_Protocol *_protocol;
+ KIO::MetaData *_metadata;
+ KIO::TransferJob* _job;
+ long _size;
+
+ void init( KIO::Slave*& );
+
+private slots:
+ void slotResult( KIO::Job* );
+ void slotData( KIO::Job*, const QByteArray& );
+
+signals:
+ //This signal is emitted if the headers are read and put into a KornMailSubject*
+ void readSubject( KornMailSubject* );
+ //This signal is emitted if this class could be destroyed.
+ void finished( KIO_Single_Subject* );
+};
+
+#endif
diff --git a/korn/kio_subjects.cpp b/korn/kio_subjects.cpp
new file mode 100644
index 000000000..ba4278ff8
--- /dev/null
+++ b/korn/kio_subjects.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kio_subjects.h"
+
+#include "kio.h"
+#include "kio_single_subject.h"
+#include "kio_proto.h"
+#include "mailsubject.h"
+
+#include <kio/global.h>
+#include <kio/scheduler.h>
+#include <kdebug.h>
+
+#include <qptrlist.h>
+#include <qvaluelist.h>
+#include <qstring.h>
+
+KIO_Subjects::KIO_Subjects( QObject * parent, const char * name )
+ : QObject( parent, name ),
+ _protocol( 0 ),
+ _slave( 0 ),
+ _valid( true )
+{
+ _jobs = new QPtrList<KIO_Single_Subject>;
+ _kurl = new KURL;
+ _metadata = new KIO::MetaData;
+
+ _jobs->setAutoDelete( true );
+}
+
+KIO_Subjects::~KIO_Subjects( )
+{
+ delete _jobs;
+ delete _kurl;
+ delete _metadata;
+ _protocol = 0;
+}
+
+void KIO_Subjects::doReadSubjects( KKioDrop *drop )
+{
+ QValueList<KKioDrop::FileInfo>::ConstIterator it;
+ QValueList<KKioDrop::FileInfo>::ConstIterator end_it = drop->_mailurls->end();
+
+ _kio = drop;
+ _protocol = _kio->_protocol;
+ *_kurl = *_kio->_kurl;
+ *_metadata = *_kio->_metadata;
+
+ if( _jobs->count() > 0 )
+ kdWarning() << i18n( "Already a slave pending." ) << endl;
+
+ _jobs->clear( );
+
+ //Open connection
+ getConnection( );
+
+ //Open jobs for easy item in the list
+ for( it = _kio->_mailurls->begin(); it != end_it; it++ )
+ startJob( (*it).name, (*it).size );
+
+ //close connection for trivial situations (empty list)
+ disConnect( true );
+
+ //passing number of subjects for progress bar.
+ _kio->emitReadSubjectsTotalSteps( _jobs->count() );
+}
+
+void KIO_Subjects::getConnection( )
+{
+ KURL kurl = *_kurl;
+ KIO::MetaData metadata = *_metadata;
+
+ if( _slave )
+ {
+ KIO::Scheduler::disconnectSlave( _slave );
+ _slave = 0;
+ }
+
+ if( _protocol->connectionBased( ) )
+ {
+ _protocol->readSubjectConnectKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( _protocol->defaultPort( _kio->_ssl ) );
+
+ if( ! ( _slave = KIO::Scheduler::getConnectedSlave( kurl, metadata ) ) )
+ {
+ kdWarning() << i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() );
+ _kio->emitShowPassivePopup( i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() ) );
+ _valid = false;
+ _kio->emitValidChanged();
+ _slave = 0;
+ _kio->emitReadSubjectsReady( false );
+ return;
+ }
+ }
+}
+
+void KIO_Subjects::startJob( const QString &name, const long size )
+{
+ KURL kurl = *_kurl;
+ KIO::MetaData metadata = *_metadata;
+ KIO_Single_Subject *subject;
+
+ kurl = name;
+
+ _protocol->readSubjectKURL( kurl, metadata );
+
+ if( kurl.port() == 0 )
+ kurl.setPort( _protocol->defaultPort( _kio->_ssl ) );
+
+ subject = new KIO_Single_Subject( this, name.latin1(), kurl, metadata, _protocol, _slave, name, size );
+
+ connect( subject, SIGNAL( readSubject( KornMailSubject* ) ), this, SLOT( slotReadSubject( KornMailSubject* ) ) );
+ connect( subject, SIGNAL( finished( KIO_Single_Subject* ) ), this, SLOT( slotFinished( KIO_Single_Subject* ) ) );
+
+ _jobs->append( subject );
+}
+
+void KIO_Subjects::disConnect( bool result )
+{
+ if( _jobs->isEmpty() )
+ {
+ if( _slave )
+ {
+ KIO::Scheduler::disconnectSlave( _slave );
+ _slave = 0;
+ }
+ _kio->emitReadSubjectsReady( result );
+ }
+}
+
+void KIO_Subjects::cancelled( )
+{
+ _jobs->clear();
+ //_slave died in cancelJob with is by called from the destructor of KIO_Single_Subject,
+ //withs is by called by _jobs->clear because autoRemove equals true.
+ _slave = 0;
+ disConnect( false );
+}
+
+void KIO_Subjects::slotReadSubject( KornMailSubject* subject )
+{
+ _valid = true;
+ _kio->emitValidChanged();
+ subject->setMailDrop( _kio );
+ _kio->emitReadSubjectsRead( subject );
+}
+
+void KIO_Subjects::slotFinished( KIO_Single_Subject* item )
+{
+ //Remove sender.... I didn't know of the computer gonna like me, but it seems he does :)
+ _jobs->remove( item );
+
+ _kio->emitReadSubjectsProgress( _jobs->count( ) );
+
+ disConnect( true ); //Only works when all jobs are finished.
+}
+
+#include "kio_subjects.moc"
diff --git a/korn/kio_subjects.h b/korn/kio_subjects.h
new file mode 100644
index 000000000..c14ff43be
--- /dev/null
+++ b/korn/kio_subjects.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KIO_SUBJECTS_H
+#define MK_KIO_SUBJECTS_H
+
+//This class calls other class to read all the subjects
+
+#include <qobject.h>
+class KKioDrop;
+class KIO_Single_Subject;
+class KIO_Protocol;
+class KornMailSubject;
+
+namespace KIO { class MetaData; class Slave; }
+class KURL;
+
+template<class T> class QPtrList;
+class QString;
+template<class T> class QValueList;
+
+class KIO_Subjects : public QObject
+{ Q_OBJECT
+public:
+ KIO_Subjects( QObject * parent, const char * name );
+ ~KIO_Subjects( );
+
+ //This function let it start fetching headers.
+ void doReadSubjects( KKioDrop* );
+
+ //This function should return true then and only then of no error occurred.
+ bool valid( ) { return _valid; }
+
+private:
+ KKioDrop *_kio;
+ KURL *_kurl;
+ KIO::MetaData *_metadata;
+ const KIO_Protocol *_protocol;
+ QPtrList<KIO_Single_Subject> *_jobs;
+ KIO::Slave *_slave;
+ bool _valid;
+
+ //Opens a connection.
+ void getConnection( );
+ //Start a job; the job itself is executed in KIO_Single_Subject
+ void startJob( const QString&, const long );
+ //Disconnect the connection
+ void disConnect( bool );
+
+public slots:
+ //This function called the fetching of headers.
+ void cancelled( );
+
+private slots:
+ void slotReadSubject( KornMailSubject* );
+ void slotFinished( KIO_Single_Subject* );
+};
+
+#endif
diff --git a/korn/kmail_proto.cpp b/korn/kmail_proto.cpp
new file mode 100644
index 000000000..15b228f39
--- /dev/null
+++ b/korn/kmail_proto.cpp
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kmail_proto.h"
+
+#include "account_input.h"
+#include "kio.h"
+#include "password.h"
+#include "protocols.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <qmap.h>
+#include <qobject.h>
+#include <qptrvector.h>
+#include <qstringlist.h>
+
+const char* KMail_Protocol::kmailGroupName = "Account %1";
+const char* KMail_Protocol::kmailKeyType = "Type";
+const char* KMail_Protocol::kmailKeyName = "Name";
+const char* KMail_Protocol::kmailKeyId = "Id";
+const char* KMail_Protocol::kmailKeyMBox = "Location";
+const char* KMail_Protocol::kmailKeyQMail = "Location";
+const int KMail_Protocol::kmailFirstGroup = 1;
+
+class KMailDrop;
+
+KMail_Protocol::KMail_Protocol()
+{
+}
+
+KMail_Protocol::~KMail_Protocol()
+{
+}
+
+const Protocol* KMail_Protocol::getProtocol( KConfigGroup* config ) const
+{
+ KConfig kmailconfig( "kmailrc", true, false );
+ int id;
+ QString type = getTypeAndConfig( config->readEntry( "kmailname" ), kmailconfig, id );
+
+ if( type == "imap" )
+ return Protocols::getProto( "imap" );
+ if( type == "cachedimap" )
+ return Protocols::getProto( "imap" );
+ if( type == "pop" )
+ return Protocols::getProto( "pop3" );
+ if( type == "local" )
+ return Protocols::getProto( "mbox" );
+ if( type == "maildir" )
+ return Protocols::getProto( "qmail" );
+
+ //Type not recognized, or does not exist in KOrn
+ kdWarning() << "KMail configuration not found" << endl;
+ return 0;
+}
+
+KMailDrop* KMail_Protocol::createMaildrop( KConfigGroup *config ) const
+{
+ int id;
+ KConfig kmailconfig( "kmailrc", true, false );
+ QString type = getTypeAndConfig( config->readEntry( "kmailname" ), kmailconfig, id );
+
+ if( type == "imap" || type == "cachedimap" || type == "pop" || type == "local" || type == "maildir" )
+ return new KKioDrop();
+
+ kdWarning() << "KMail configuration not found" << endl;
+ return 0;
+}
+
+QMap< QString, QString > * KMail_Protocol::createConfig( KConfigGroup* config, const QString& ) const
+{
+ QMap< QString, QString > *result = new QMap<QString, QString>;
+ int id;
+ KConfig kmailconfig( "kmailrc", true, false );
+ //First: find the account in the configuration and get the type and id out of it.
+ QString type = getTypeAndConfig( config->readEntry( "kmailname" ), kmailconfig, id );
+ QString metadata;
+
+ if( type == "imap" || type == "cachedimap" )
+ {
+ //Construct metadata
+ if( kmailconfig.hasKey( "auth" ) )
+ metadata += QString( "auth=%1," ).arg( kmailconfig.readEntry( "auth" ) );
+ if( !kmailconfig.hasKey( "use-tls" ) )
+ metadata += "tls=auto";
+ else
+ {
+ if( kmailconfig.readBoolEntry( "use-tls", false ) )
+ metadata += "tls=on";
+ else
+ metadata += "tls=off";
+ }
+ //Add the fields into the mapping.
+ result->insert( "name", config->readEntry( "name", "" ) );
+ result->insert( "server", kmailconfig.readEntry( "host", "localhost" ) );
+ result->insert( "port", kmailconfig.readEntry( "port", "143" ) );
+ result->insert( "ssl", kmailconfig.readEntry( "use-ssl", "false" ) );
+ result->insert( "metadata", metadata );
+ result->insert( "username", kmailconfig.readEntry( "login", "" ) );
+ result->insert( "mailbox", "INBOX" ); //Didn't find a good way to get this out of the configuration yet.
+ result->insert( "password", readPassword( kmailconfig.readBoolEntry( "store-passwd", false ), kmailconfig, id ) );
+ result->insert( "savepassword", kmailconfig.readEntry( "store-passwd", "false" ) );
+ }
+ if( type == "pop" )
+ {
+ //Constructing metadata
+ if( kmailconfig.hasKey( "auth" ) )
+ metadata += QString( "auth=%1," ).arg( kmailconfig.readEntry( "auth" ) );
+ if( !kmailconfig.hasKey( "use-tls" ) )
+ metadata += "tls=auto";
+ else
+ {
+ if( kmailconfig.readBoolEntry( "use-tls", false ) )
+ metadata += "tls=on";
+ else
+ metadata += "tls=off";
+ }
+ result->insert( "name", config->readEntry( "name", "" ) );
+ result->insert( "server", kmailconfig.readEntry( "host", "localhost" ) );
+ result->insert( "port", kmailconfig.readEntry( "port", "110" ) );
+ result->insert( "ssl", kmailconfig.readEntry( "use-ssl", "false" ) );
+ result->insert( "metadata", metadata );
+ result->insert( "username", kmailconfig.readEntry( "login", "" ) );
+ result->insert( "mailbox", "" );
+ result->insert( "password", readPassword( kmailconfig.readBoolEntry( "store-passwd", false ), kmailconfig, id ) );
+ result->insert( "savepassword", kmailconfig.readEntry( "store-password", "false" ) );
+ }
+ if( type == "local" ) //mbox
+ {
+ result->insert( "name", config->readEntry( "name", "" ) );
+ result->insert( "server", "" );
+ result->insert( "port", "0" );
+ result->insert( "ssl", "false" );
+ result->insert( "metadata", "" );
+ result->insert( "username", "" );
+ result->insert( "mailbox", kmailconfig.readPathEntry( kmailKeyMBox, "" ) );
+ result->insert( "password", "" );
+ result->insert( "savepassword", "false" );
+ }
+ if( type == "maildir" )
+ {
+ result->insert( "name", config->readEntry( "name", "" ) );
+ result->insert( "server", "" );
+ result->insert( "port", "0" );
+ result->insert( "ssl", "false" );
+ result->insert( "metadata", "" );
+ result->insert( "username", "" );
+ result->insert( "mailbox", kmailconfig.readPathEntry( kmailKeyQMail, "" ) );
+ result->insert( "password", "" );
+ result->insert( "savepassword", "false" );
+ }
+
+ return result;
+}
+
+void KMail_Protocol::configFillGroupBoxes( QStringList* lijst ) const
+{
+ lijst->append( "KMail" );
+}
+
+void KMail_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* result ) const
+{
+ QMap< QString, QString > accountList;
+ QString type;
+ QString name;
+ int nummer = kmailFirstGroup - 1;
+
+ KConfig kmailconfig( "kmailrc", true, false );
+ while( kmailconfig.hasGroup( QString( kmailGroupName ).arg( ++nummer ) ) )
+ {
+ kmailconfig.setGroup( QString( kmailGroupName ).arg( nummer ) );
+ type = kmailconfig.readEntry( kmailKeyType, QString::null );
+ name = kmailconfig.readEntry( kmailKeyName, QString::null );
+ if( type == "imap" || type == "cachedimap" || type == "pop" || type == "local" )
+ {
+ accountList.insert( name, name );
+ }
+ }
+
+ result->append( new ComboInput( (QWidget*)vector->at( 0 ), i18n( "KMail name" ), accountList, *accountList.begin(), "kmailname" ) );
+}
+
+void KMail_Protocol::readEntries( QMap< QString, QString >* ) const
+{
+ //The configuartion is read out on the right way
+}
+
+void KMail_Protocol::writeEntries( QMap< QString, QString >* ) const
+{
+ //The configuartion is read out on the right way
+}
+
+QString KMail_Protocol::readPassword( bool store, const KConfigBase& config, int id ) const
+{
+ if( !store )
+ return "";
+
+ return KOrnPassword::readKMailPassword( id, config );
+}
+
+QString KMail_Protocol::getTypeAndConfig( const QString& kmailname, KConfig &kmailconfig, int &id ) const
+{
+ int nummer = kmailFirstGroup - 1;
+ bool found = false;
+
+ id = -1;
+
+ while( kmailconfig.hasGroup( QString( kmailGroupName ).arg( ++nummer ) ) )
+ {
+ kmailconfig.setGroup( QString( kmailGroupName ).arg( nummer ) );
+ if( kmailconfig.readEntry( kmailKeyName, QString::null ) == kmailname )
+ {
+ id = kmailconfig.readNumEntry( kmailKeyId, 0 );
+ found = true;
+ break;
+ }
+ }
+ if( !found )
+ {
+ nummer = -1;
+ return QString::null;
+ }
+
+ //The correct group is found, and kmailconfig.setGroup() is already called for the right group.
+ return kmailconfig.readEntry( kmailKeyType, QString::null );
+}
+
diff --git a/korn/kmail_proto.h b/korn/kmail_proto.h
new file mode 100644
index 000000000..6e055b406
--- /dev/null
+++ b/korn/kmail_proto.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KMAILPROTOCOL
+#define MK_KMAILPROTOCOL
+
+#include "protocol.h"
+
+class KConfig;
+class KConfigBase;
+
+/**
+ * This class is the comminucation between KOrn and KMail.
+ * If provides an configuration option to fill in the KMail account name,
+ * and it provides a conversion from the KMail config to a configuration KOrn can read.
+ * That conversion is done every time, so that changing the settings in KMail also affects
+ * the settings in KOrn.
+ */
+class KMail_Protocol : public Protocol
+{
+public:
+ /**
+ * Constructor
+ */
+ KMail_Protocol();
+ /**
+ * Destructor
+ */
+ ~KMail_Protocol();
+
+ /**
+ * This function returns the protocol of the resulting configuration.
+ * This is not itself, because an real Protocol of type KMail doesn't exist.
+ *
+ * @param config The configuration group to read the kmailname from.
+ * @return A pointer to a Protocol (not newly created) or 0 if an error orrured.
+ */
+ virtual const Protocol* getProtocol( KConfigGroup* config ) const;
+ /**
+ * This gives a new Maildrop back. The maildrop is responsible to execute the configuration.
+ * In most cases, it will return a new instance of the KKioDrop Maildrop.
+ * @param config The configuration group to read the kmailname from.
+ * @return A new KMailDrop, or a 0 pointer if an error occured.
+ */
+ virtual KMailDrop* createMaildrop( KConfigGroup* config ) const;
+ /**
+ * This does the real convertion: given a namen of a KMail account (hidden in config),
+ * it calculates how the configuration whould have looked in KOrn.
+ *
+ * @param config The configuration group to read the kmailname from.
+ * @param password The password fetched out of the configuration or KWallet.
+ * @return A mapping containing the configuration if success, and empty mapping otherwise.
+ */
+ virtual QMap< QString, QString > * createConfig( KConfigGroup* config, const QString& password ) const;
+ /**
+ * The name of thes protocol
+ *
+ * @return "kmail"
+ */
+ virtual QString configName() const { return "kmail"; }
+
+ /**
+ * This adds the names of the groupboxes neccesairy for configuration to list.
+ *
+ * @param list A empty list at calling; after this function, "KMail" is added, because KMail is the only group here.
+ */
+ virtual void configFillGroupBoxes( QStringList* list ) const;
+ /**
+ * This filles the config fields of the configuration.
+ * There is only one config field, containing the accounts of KMail.
+ *
+ * @param vector A vector containing the groupboxes.
+ * @param object An object to connect slots to.
+ * @param result The resulting object.
+ */
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject* object, QPtrList< AccountInput >* result ) const;
+ /**
+ * This can manipulate entries that are readed from the configuartion.
+ * This function does nothing here.
+ *
+ * @param config The configuration mapping as read from the configuration file
+ */
+ virtual void readEntries( QMap< QString, QString >* config ) const;
+
+ /**
+ * This can manipulate entries that are writed to the configuartion file.
+ * This function does nothing here.
+ *
+ * @param config The configuration mapping as to be written to the configuration file (can be modified)
+ */
+ virtual void writeEntries( QMap< QString, QString >* config ) const;
+
+private:
+ QString readPassword( bool store, const KConfigBase &config, int id ) const;
+ QString getTypeAndConfig( const QString& kmailname, KConfig &config, int &nummer ) const;
+
+ static const char* kmailGroupName;
+ static const char* kmailKeyName;
+ static const char* kmailKeyType;
+ static const char* kmailKeyId;
+ static const char* kmailKeyMBox;
+ static const char* kmailKeyQMail;
+ static const int kmailFirstGroup;
+};
+
+#endif //MK_KMAILPROTOCOL
diff --git a/korn/kornaccountcfg.ui b/korn/kornaccountcfg.ui
new file mode 100644
index 000000000..18b068291
--- /dev/null
+++ b/korn/kornaccountcfg.ui
@@ -0,0 +1,249 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KornAccountCfg</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KornAccountCfg</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>472</width>
+ <height>471</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>server_tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Server</string>
+ </attribute>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lbProtocol</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>41</y>
+ <width>206</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>&amp;Protocol:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cbProtocol</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>cbProtocol</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>223</x>
+ <y>41</y>
+ <width>206</width>
+ <height>24</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Account</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout35</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lbInterval</cstring>
+ </property>
+ <property name="text">
+ <string>C&amp;heck every (sec):</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edInterval</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>edInterval</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Events</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chUseBox</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Use settings of box</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>gbNewMail</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>On New Mail</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout33</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>edRunCommand</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>lbRunCommand</cstring>
+ </property>
+ <property name="text">
+ <string>Run &amp;command:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edRunCommand</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="1">
+ <property name="name">
+ <cstring>edPlaySound</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lbPlaySound</cstring>
+ </property>
+ <property name="text">
+ <string>Play sou&amp;nd:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edPlaySound</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chPassivePopup</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;passive popup</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chPassiveDate</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Add &amp;date to passive popup</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>chUseBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>gbNewMail</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chPassivePopup</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>chPassiveDate</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>cbProtocol</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>KornAccountCfg</receiver>
+ <slot>slotProtocolChanged(const QString&amp;)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tab</tabstop>
+ <tabstop>edInterval</tabstop>
+ <tabstop>chUseBox</tabstop>
+ <tabstop>edRunCommand</tabstop>
+ <tabstop>edPlaySound</tabstop>
+ <tabstop>chPassivePopup</tabstop>
+ <tabstop>chPassiveDate</tabstop>
+</tabstops>
+<slots>
+ <slot access="protected">slotProtocolChanged( const QString&amp; )</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/korn/kornaccountcfgimpl.cpp b/korn/kornaccountcfgimpl.cpp
new file mode 100644
index 000000000..f4980ca97
--- /dev/null
+++ b/korn/kornaccountcfgimpl.cpp
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "kornaccountcfgimpl.h"
+
+#include "account_input.h"
+#include "kio_proto.h"
+#include "password.h"
+#include "protocol.h"
+#include "protocols.h"
+
+#include <kconfigbase.h>
+#include <kdebug.h>
+#include <klineedit.h>
+#include <kurlrequester.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qptrvector.h>
+#include <qlayout.h>
+#include <qmap.h>
+#include <qlabel.h>
+#include <qwidget.h>
+
+KornAccountCfgImpl::KornAccountCfgImpl( QWidget * parent, const char * name )
+ : KornAccountCfg( parent, name ),
+ _config( 0 ),
+ _fields( 0 ),
+ _urlfields( 0 ),
+ _boxnr( 0 ),
+ _accountnr( 0 ),
+ _vlayout( 0 ),
+ _protocolLayout( 0 ),
+ _groupBoxes( 0 ),
+ _accountinput( new QPtrList< AccountInput >() )
+{
+ connect( parent, SIGNAL( okClicked() ), this, SLOT( slotOK() ) );
+ connect( parent, SIGNAL( cancelClicked() ), this, SLOT( slotCancel() ) );
+
+ this->cbProtocol->insertStringList( Protocols::getProtocols() );
+
+ _accountinput->setAutoDelete( true );
+
+}
+
+KornAccountCfgImpl::~KornAccountCfgImpl()
+{
+ delete _accountinput;
+}
+
+void KornAccountCfgImpl::readConfig( KConfigGroup *config, QMap< QString, QString > *entries, int boxnr, int accountnr )
+{
+ AccountInput *input;
+
+ _config = config;
+
+ _accountinput->clear();
+
+ this->cbProtocol->setCurrentText( _config->readEntry( "protocol", "mbox" ) );
+ slotProtocolChanged( this->cbProtocol->currentText() );
+ const Protocol *protocol = Protocols::getProto( _config->readEntry( "protocol", "mbox" ) );
+
+ protocol->readEntries( entries );
+
+ (*entries)[ "password" ] = KOrnPassword::readKOrnPassword( boxnr, accountnr, *config );
+
+ for( input = _accountinput->first(); input; input = _accountinput->next() )
+ if( entries->contains( input->configName() ) )
+ input->setValue( *(entries->find( input->configName() ) ) );
+
+ this->edInterval->setText( _config->readEntry( "interval", "300" ) );
+
+ this->chUseBox->setChecked( _config->readBoolEntry( "boxsettings", true ) );
+ this->edRunCommand->setURL( _config->readEntry( "newcommand", "" ) );
+ this->edPlaySound->setURL( _config->readEntry( "sound", "" ) );
+ this->chPassivePopup->setChecked( _config->readBoolEntry( "passivepopup", false ) );
+ this->chPassiveDate->setChecked( _config->readBoolEntry( "passivedate", false ) );
+
+ _boxnr = boxnr;
+ _accountnr = accountnr;
+}
+
+void KornAccountCfgImpl::writeConfig()
+{
+ AccountInput *input;
+ const Protocol *protocol = Protocols::getProto( this->cbProtocol->currentText() );
+
+ if( !protocol )
+ {
+ kdWarning() << "An error occured during writing the account information: protocol does not exist" << endl;
+ return;
+ }
+
+ _config->writeEntry( "protocol", this->cbProtocol->currentText() );
+
+ QMap< QString, QString > *map = new QMap< QString, QString >;
+ QMap< QString, QString >::ConstIterator it;
+ for( input = _accountinput->first(); input; input = _accountinput->next() )
+ map->insert( input->configName(), input->value() );
+
+ protocol->writeEntries( map );
+
+ if( map->contains( "password" ) )
+ {
+ KOrnPassword::writeKOrnPassword( _boxnr, _accountnr, *_config, *map->find( "password" ) );
+ map->erase( "password" );
+ }
+
+ for( it = map->begin(); it != map->end(); ++it )
+ _config->writeEntry( it.key(), it.data() );
+
+ delete map;
+
+ _config->writeEntry( "interval", this->edInterval->text().toInt() );
+
+ _config->writeEntry( "boxsettings", this->chUseBox->isChecked() );
+ _config->writeEntry( "newcommand", this->edRunCommand->url() );
+ _config->writeEntry( "sound", this->edPlaySound->url() );
+ _config->writeEntry( "passivepopup", this->chPassivePopup->isChecked() );
+ _config->writeEntry( "passivedate", this->chPassiveDate->isChecked() );
+}
+
+void KornAccountCfgImpl::slotSSLChanged()
+{
+ AccountInput *input;
+ const Protocol* protocol = Protocols::getProto( this->cbProtocol->currentText() );
+ bool ssl = false;
+
+ if( !protocol )
+ return;
+
+ for( input = _accountinput->first(); input; input = _accountinput->next() )
+ if( ( input->configName() == "ssl" && input->value() == "true" ) || input->value() == "ssl" )
+ ssl = true;
+
+ for( input = _accountinput->first(); input; input = _accountinput->next() )
+ if( input->configName() == "port" && ( input->value() == QString::number( protocol->defaultPort( !ssl ) ) ) )
+ input->setValue( QString::number( protocol->defaultPort( ssl ) ) );
+}
+
+void KornAccountCfgImpl::slotOK()
+{
+ writeConfig();
+}
+
+void KornAccountCfgImpl::slotCancel()
+{
+}
+
+void KornAccountCfgImpl::slotProtocolChanged( const QString& proto )
+{
+ const Protocol *protocol = Protocols::getProto( proto );
+ QStringList *groupBoxes = new QStringList;
+ int counter = 1;
+
+ protocol->configFillGroupBoxes( groupBoxes );
+
+ _accountinput->clear();
+ delete _groupBoxes;
+ delete _protocolLayout;
+ delete _vlayout;
+ _vlayout = new QVBoxLayout( this->server_tab, groupBoxes->count() + 1 );
+ _vlayout->setSpacing( 10 );
+ _vlayout->setMargin( 10 );
+
+ _protocolLayout = new QHBoxLayout( _vlayout );
+ _protocolLayout->addWidget( this->lbProtocol );
+ _protocolLayout->addWidget( this->cbProtocol );
+
+ QStringList::iterator it;
+ counter = 0;
+ _groupBoxes = new QPtrVector< QWidget >( groupBoxes->count() );
+ _groupBoxes->setAutoDelete( true );
+ for( it = groupBoxes->begin(); it != groupBoxes->end(); ++it )
+ {
+ _groupBoxes->insert( counter, new QGroupBox( (*it), this->server_tab, "groupbox" ) );
+ _vlayout->addWidget( _groupBoxes->at( counter ) );
+ ++counter;
+ }
+ delete groupBoxes;
+
+ AccountInput *input;
+ protocol->configFields( _groupBoxes, this, _accountinput );
+
+ for( unsigned int groupCounter = 0; groupCounter < _groupBoxes->count(); ++groupCounter )
+ {
+ int counter = 0;
+ QGridLayout *grid = new QGridLayout( _groupBoxes->at( groupCounter ), 0, 2 );
+ grid->setSpacing( 10 );
+ grid->setMargin( 15 );
+ for( input = _accountinput->first(); input; input = _accountinput->next() )
+ {
+ if( input->leftWidget() && _groupBoxes->at( groupCounter ) == input->leftWidget()->parent() )
+ {
+ grid->addWidget( input->leftWidget(), counter, 0 );
+ if( input->rightWidget() && _groupBoxes->at( groupCounter ) == input->rightWidget()->parent() )
+ grid->addWidget( input->rightWidget(), counter, 1 );
+ ++counter;
+ } else {
+ if( input->rightWidget() && _groupBoxes->at( groupCounter ) == input->rightWidget()->parent() )
+ {
+ grid->addWidget( input->rightWidget(), counter, 1 );
+ ++counter;
+ }
+ }
+ }
+
+ _groupBoxes->at( groupCounter )->show();
+ }
+
+ this->lbInterval->setEnabled( proto != "process" && proto != "dcop" );
+ this->edInterval->setEnabled( proto != "process" && proto != "dcop" );
+
+ this->server_tab->updateGeometry();
+}
+
+#include "kornaccountcfgimpl.moc"
diff --git a/korn/kornaccountcfgimpl.h b/korn/kornaccountcfgimpl.h
new file mode 100644
index 000000000..1bbb44c3b
--- /dev/null
+++ b/korn/kornaccountcfgimpl.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KORNACCOUNTCFGIMPL_H
+#define MK_KORNACCOUNTCFGIMPL_H
+
+#include "kornaccountcfg.h"
+
+class KConfigGroup;
+class KURLRequester;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+class QString;
+class QWidget;
+
+class AccountInput;
+
+template< class T > class QPtrList;
+template< class T > class QPtrVector;
+
+class KornAccountCfgImpl : public KornAccountCfg
+{ Q_OBJECT
+public:
+ KornAccountCfgImpl( QWidget * parent = 0, const char * name = 0 );
+ ~KornAccountCfgImpl();
+
+ void readConfig( KConfigGroup *config, QMap< QString, QString > *entries, int boxnr, int accountnr );
+ void writeConfig();
+
+public slots:
+ void slotSSLChanged();
+
+protected slots:
+ virtual void slotProtocolChanged( const QString& );
+
+private slots:
+ void slotOK();
+ void slotCancel();
+private:
+ KConfigGroup *_config;
+ int _fields;
+ int _urlfields;
+ int _boxnr, _accountnr;
+
+ QVBoxLayout *_vlayout;
+ QHBoxLayout *_protocolLayout;
+ QPtrVector< QWidget > *_groupBoxes;
+
+ QPtrList< AccountInput > *_accountinput;
+};
+
+#endif //MK_KORNACCOUNTCFGIMPL_H
diff --git a/korn/kornapp.cpp b/korn/kornapp.cpp
new file mode 100644
index 000000000..1205c8002
--- /dev/null
+++ b/korn/kornapp.cpp
@@ -0,0 +1,21 @@
+/*
+* kornapp.cpp -- Implementation of class KornApp.
+* Author: Sirtaj Singh Kang
+* Version: $Id$
+* Generated: Sun Apr 22 23:50:49 EST 2001
+*/
+
+#include"kornapp.h"
+#include<kdebug.h>
+#include"kornshell.h"
+
+int KornApp::newInstance()
+{
+ if( _instanceCount ) {
+ _shell->optionDlg();
+ }
+ _instanceCount++;
+
+ return 0;
+}
+#include "kornapp.moc"
diff --git a/korn/kornapp.h b/korn/kornapp.h
new file mode 100644
index 000000000..c07ac55c7
--- /dev/null
+++ b/korn/kornapp.h
@@ -0,0 +1,43 @@
+/*
+* kornapp.h -- Declaration of class KornApp.
+* Generated by newclass on Sun Apr 22 23:50:49 EST 2001.
+*/
+#ifndef SSK_KORNAPP_H
+#define SSK_KORNAPP_H
+
+#include <kuniqueapplication.h>
+
+class KornShell;
+
+/**
+* @short KornApp
+* @author Sirtaj Singh Kang (taj@kde.org)
+* @version $Id$
+*/
+class KornApp : public KUniqueApplication
+{
+ Q_OBJECT
+
+public:
+ /**
+ * KornApp Constructor
+ */
+ KornApp() : KUniqueApplication(), _shell( 0 ), _instanceCount( 0 ) {}
+
+ /**
+ * KornApp Destructor
+ */
+ virtual ~KornApp(){}
+
+ virtual int newInstance();
+ void setShell( KornShell *shell ){ _shell = shell; };
+
+private:
+ KornShell *_shell;
+ int _instanceCount;
+
+ KornApp& operator=( const KornApp& );
+ KornApp( const KornApp& );
+};
+
+#endif // SSK_KORNAPP_H
diff --git a/korn/kornboxcfg.ui b/korn/kornboxcfg.ui
new file mode 100644
index 000000000..4b61ee06f
--- /dev/null
+++ b/korn/kornboxcfg.ui
@@ -0,0 +1,1698 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KornBoxCfg</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KornBoxCfg</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>340</width>
+ <height>448</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabWidget3</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;View</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="2">
+ <property name="name">
+ <cstring>layout32</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNewText</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KColorButton">
+ <property name="name">
+ <cstring>cbNewText</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout34</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNormalBack</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KColorButton">
+ <property name="name">
+ <cstring>cbNormalBack</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>208</red>
+ <green>208</green>
+ <blue>208</blue>
+ </color>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>lbIcon</cstring>
+ </property>
+ <property name="text">
+ <string>Icon:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>lbBackground</cstring>
+ </property>
+ <property name="text">
+ <string>Background:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="2">
+ <property name="name">
+ <cstring>layout33</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNewBack</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KColorButton">
+ <property name="name">
+ <cstring>cbNewBack</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="1">
+ <property name="name">
+ <cstring>lbNormal</cstring>
+ </property>
+ <property name="text">
+ <string>Normal</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="2">
+ <property name="name">
+ <cstring>layout36</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNewIcon</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KIconButton">
+ <property name="name">
+ <cstring>ibNewIcon</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>lbNew</cstring>
+ </property>
+ <property name="text">
+ <string>New Mail</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lbText</cstring>
+ </property>
+ <property name="text">
+ <string>Text:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNormalText</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KColorButton">
+ <property name="name">
+ <cstring>cbNormalText</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="1">
+ <property name="name">
+ <cstring>layout35</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNormalIcon</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KIconButton">
+ <property name="name">
+ <cstring>ibNormalIcon</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer row="6" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>160</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="5" column="1">
+ <property name="name">
+ <cstring>layout29</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNormalAnim</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbNormalAnim</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Change</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="2">
+ <property name="name">
+ <cstring>layout28</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNewAnim</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbNewAnim</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Change</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>lbAnimation</cstring>
+ </property>
+ <property name="text">
+ <string>Animation:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>lbFont</cstring>
+ </property>
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="2">
+ <property name="name">
+ <cstring>layout28_2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNewFont</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbNewFont</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Change</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="1">
+ <property name="name">
+ <cstring>layout29_2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chNormalFont</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbNormalFont</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Change</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Events</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>lbLeft</cstring>
+ </property>
+ <property name="text">
+ <string>Left</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="2">
+ <property name="name">
+ <cstring>layout52_7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chMiddleRun</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="1" column="3">
+ <property name="name">
+ <cstring>lbRight</cstring>
+ </property>
+ <property name="text">
+ <string>Right</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="2">
+ <property name="name">
+ <cstring>layout52</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chMiddleRecheck</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="1">
+ <property name="name">
+ <cstring>layout52_4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chLeftReset</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="3">
+ <property name="name">
+ <cstring>layout52_9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_9_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chRightRun</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_9_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout52</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chLeftRecheck</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>lbReset</cstring>
+ </property>
+ <property name="text">
+ <string>Reset counter:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>lbMouseButton</cstring>
+ </property>
+ <property name="text">
+ <string>Mousebutton</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="3">
+ <property name="name">
+ <cstring>layout52_9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chRightView</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="1">
+ <property name="name">
+ <cstring>layout52_5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_5_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chLeftRun</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_5_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>lbMiddle</cstring>
+ </property>
+ <property name="text">
+ <string>Middle</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="6" column="1">
+ <property name="name">
+ <cstring>layout52_5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_5_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chLeftPopup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_5_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="6" column="0">
+ <property name="name">
+ <cstring>lbPopup</cstring>
+ </property>
+ <property name="text">
+ <string>Popup:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="3">
+ <property name="name">
+ <cstring>layout52_8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chRightReset</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>lbView</cstring>
+ </property>
+ <property name="text">
+ <string>View emails:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="6" column="2">
+ <property name="name">
+ <cstring>layout52_7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chMiddlePopup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>lbRecheck</cstring>
+ </property>
+ <property name="text">
+ <string>Recheck:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="1">
+ <property name="name">
+ <cstring>layout52_5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chLeftView</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="3">
+ <property name="name">
+ <cstring>layout52_3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chRightRecheck</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="2">
+ <property name="name">
+ <cstring>layout52_6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chMiddleReset</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="2">
+ <property name="name">
+ <cstring>layout52_7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chMiddleView</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>lbRun</cstring>
+ </property>
+ <property name="text">
+ <string>Run command:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="6" column="3">
+ <property name="name">
+ <cstring>layout52_9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_9_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chRightPopup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_9_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout31_3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lbCommand</cstring>
+ </property>
+ <property name="text">
+ <string>Co&amp;mmand:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edCommand</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>edCommand</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>gbNewMail</cstring>
+ </property>
+ <property name="title">
+ <string>On &amp;New Mail</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout33</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>edNewRun</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>lbNewRun</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Run command:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edNewRun</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="1">
+ <property name="name">
+ <cstring>edPlaySound</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lbPlaySound</cstring>
+ </property>
+ <property name="text">
+ <string>Play &amp;sound:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edPlaySound</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chShowPassive</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;passive popup</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chPassiveDate</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Add da&amp;te to passive popup</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Acco&amp;unts</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBoxManager">
+ <property name="name">
+ <cstring>elbAccounts</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbEdit</cstring>
+ </property>
+ <property name="text">
+ <string>E&amp;dit</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;DCOP</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox">
+ <property name="name">
+ <cstring>elbDCOP</cstring>
+ </property>
+ <property name="title">
+ <string>DCO&amp;Objects</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The names of DCOP-objects by this box. DCOP-objects let other programs add 'virtual' emails to the box.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>KEditListBoxManager</class>
+ <header location="local">keditlistboxman.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ <signal>activated( const QString&amp; )</signal>
+ <signal>activated( const int )</signal>
+ <signal>setDefaults( const QString&amp;, KConfig* )</signal>
+ <signal>setDefaults( const QString&amp;, const int, KConfig* )</signal>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154388db59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a09643cc7ce0000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>chNormalText</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cbNormalText</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewText</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cbNewText</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNormalBack</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cbNormalBack</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewBack</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cbNewBack</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNormalIcon</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>ibNormalIcon</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewIcon</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>ibNewIcon</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chShowPassive</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>chPassiveDate</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>pbEdit</sender>
+ <signal>clicked()</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotEditBox()</slot>
+ </connection>
+ <connection>
+ <sender>elbAccounts</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotActivated(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>elbAccounts</sender>
+ <signal>setDefaults(const QString&amp;,const int,KConfig*)</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotSetDefaults(const QString&amp;,const int,KConfig*)</slot>
+ </connection>
+ <connection>
+ <sender>pbNormalFont</sender>
+ <signal>pressed()</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotChangeNormalFont()</slot>
+ </connection>
+ <connection>
+ <sender>pbNewFont</sender>
+ <signal>pressed()</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotChangeNewFont()</slot>
+ </connection>
+ <connection>
+ <sender>pbNormalAnim</sender>
+ <signal>released()</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotChangeNormalAnim()</slot>
+ </connection>
+ <connection>
+ <sender>pbNewAnim</sender>
+ <signal>pressed()</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotChangeNewAnim()</slot>
+ </connection>
+ <connection>
+ <sender>chNormalFont</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pbNormalFont</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewFont</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pbNewFont</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNormalAnim</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pbNormalAnim</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewAnim</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pbNewAnim</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNormalAnim</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotNormalAnimToggled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>chNewAnim</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>KornBoxCfg</receiver>
+ <slot>slotNewAnimToggled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tabWidget3</tabstop>
+ <tabstop>chNormalText</tabstop>
+ <tabstop>cbNormalText</tabstop>
+ <tabstop>chNewText</tabstop>
+ <tabstop>cbNewText</tabstop>
+ <tabstop>chNormalBack</tabstop>
+ <tabstop>cbNormalBack</tabstop>
+ <tabstop>chNewBack</tabstop>
+ <tabstop>cbNewBack</tabstop>
+ <tabstop>chNormalIcon</tabstop>
+ <tabstop>ibNormalIcon</tabstop>
+ <tabstop>chNewIcon</tabstop>
+ <tabstop>ibNewIcon</tabstop>
+ <tabstop>chNormalFont</tabstop>
+ <tabstop>pbNormalFont</tabstop>
+ <tabstop>chNewFont</tabstop>
+ <tabstop>pbNewFont</tabstop>
+ <tabstop>chNormalAnim</tabstop>
+ <tabstop>pbNormalAnim</tabstop>
+ <tabstop>chNewAnim</tabstop>
+ <tabstop>pbNewAnim</tabstop>
+ <tabstop>chLeftRecheck</tabstop>
+ <tabstop>chMiddleRecheck</tabstop>
+ <tabstop>chRightRecheck</tabstop>
+ <tabstop>chLeftReset</tabstop>
+ <tabstop>chMiddleReset</tabstop>
+ <tabstop>chRightReset</tabstop>
+ <tabstop>chLeftView</tabstop>
+ <tabstop>chMiddleView</tabstop>
+ <tabstop>chRightView</tabstop>
+ <tabstop>chLeftRun</tabstop>
+ <tabstop>chMiddleRun</tabstop>
+ <tabstop>chRightRun</tabstop>
+ <tabstop>chLeftPopup</tabstop>
+ <tabstop>chMiddlePopup</tabstop>
+ <tabstop>chRightPopup</tabstop>
+ <tabstop>edCommand</tabstop>
+ <tabstop>edNewRun</tabstop>
+ <tabstop>edPlaySound</tabstop>
+ <tabstop>chShowPassive</tabstop>
+ <tabstop>chPassiveDate</tabstop>
+ <tabstop>pbEdit</tabstop>
+</tabstops>
+<slots>
+ <slot access="protected">slotEditBox()</slot>
+ <slot access="protected">slotActivated( const QString&amp; )</slot>
+ <slot access="protected">slotActivated( const int )</slot>
+ <slot access="protected">slotSetDefaults( const QString&amp;, const int, KConfig* )</slot>
+ <slot access="protected">slotChangeNormalFont()</slot>
+ <slot access="protected">slotChangeNewFont()</slot>
+ <slot access="protected">slotChangeNormalAnim()</slot>
+ <slot access="protected">slotChangeNewAnim()</slot>
+ <slot access="protected">slotNormalAnimToggled( bool )</slot>
+ <slot access="protected">slotNewAnimToggled( bool )</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/korn/kornboxcfgimpl.cpp b/korn/kornboxcfgimpl.cpp
new file mode 100644
index 000000000..6ab6ce5e0
--- /dev/null
+++ b/korn/kornboxcfgimpl.cpp
@@ -0,0 +1,372 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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
+ */
+
+class KConfig;
+#include "kornboxcfgimpl.h"
+
+#include "keditlistboxman.h"
+#include "kornaccountcfgimpl.h"
+#include "password.h"
+
+#include <kconfig.h>
+#include <kcolorbutton.h>
+#include <kdebug.h>
+#include <kfiledialog.h>
+#include <kfontdialog.h>
+#include <klocale.h>
+#include <kicondialog.h>
+#include <kurlrequester.h>
+
+#include <qcheckbox.h>
+#include <qcolor.h>
+#include <qfont.h>
+#include <qlabel.h>
+#include <qstring.h>
+
+KornBoxCfgImpl::KornBoxCfgImpl( QWidget * parent, const char * name )
+ : KornBoxCfg( parent, name ),
+ _config( 0 ),
+ _base( 0 ),
+ _index( -1 )
+{
+ _fonts[ 0 ] = new QFont;
+ _fonts[ 1 ] = new QFont;
+ _anims[ 0 ] = new QString;
+ _anims[ 1 ] = new QString;
+
+ lbLeft->setText( i18n( "Left mousebutton", "Left" ) );
+ if( lbLeft->text() == "Left" )
+ lbLeft->setText( i18n( "Left" ) );
+ lbRight->setText( i18n( "Right mousebutton", "Right" ) );
+ if( lbRight->text() == "Right" )
+ lbRight->setText( i18n( "Right" ) );
+
+ connect( parent, SIGNAL( okClicked() ), this, SLOT( slotOK() ) );
+ connect( parent, SIGNAL( cancelClicked() ), this, SLOT( slotCancel() ) );
+
+ elbAccounts->setTitle( i18n( "Accounts" ) );
+
+ connect( elbAccounts, SIGNAL( elementsSwapped( int, int ) ), this, SLOT( slotAccountsSwapped( int, int ) ) );
+ connect( elbAccounts, SIGNAL( elementDeleted( int ) ), this, SLOT( slotAccountDeleted( int ) ) );
+}
+
+KornBoxCfgImpl::~KornBoxCfgImpl()
+{
+ delete _fonts[ 0 ];
+ delete _fonts[ 1 ];
+ delete _anims[ 0 ];
+ delete _anims[ 1 ];
+}
+
+void KornBoxCfgImpl::readConfig( KConfig * config, const int index )
+{
+ _config = config;
+ _index = index;
+
+ _config->setGroup( QString( "korn-%1" ).arg( index ) );
+
+ readViewConfig();
+ readEventConfig();
+ readDCOPConfig();
+ readAccountsConfig();
+}
+
+void KornBoxCfgImpl::writeConfig( KConfig * config, const int index )
+{
+ config->setGroup( QString( "korn-%1" ).arg( index ) );
+
+ writeViewConfig( config );
+ writeEventConfig( config );
+ writeDCOPConfig( config );
+ writeAccountsConfig( config );
+}
+
+//private
+void KornBoxCfgImpl::readViewConfig()
+{
+ this->chNormalText->setChecked(_config->readBoolEntry ( "hasnormalfgcolour", true ) );
+ this->cbNormalText->setColor( _config->readColorEntry( "normalfgcolour", &Qt::black ) );
+ this->chNewText->setChecked( _config->readBoolEntry ( "hasnewfgcolour", true ) );
+ this->cbNewText->setColor( _config->readColorEntry( "newfgcolour", &Qt::black ) );
+ this->chNormalBack->setChecked(_config->readBoolEntry ( "hasnormalbgcolour", false ) );
+ this->cbNormalBack->setColor( _config->readColorEntry( "normalbgcolour", &Qt::white ) );
+ this->chNewBack->setChecked( _config->readBoolEntry ( "hasnewbgcolour", false ) );
+ this->cbNewBack->setColor( _config->readColorEntry( "newbgcolour", &Qt::white ) );
+
+ this->chNormalIcon->setChecked(_config->readBoolEntry( "hasnormalicon", false ) );
+ this->ibNormalIcon->setIcon( _config->readEntry ( "normalicon", "" ) );
+ this->chNewIcon->setChecked( _config->readBoolEntry( "hasnewicon", false ) );
+ this->ibNewIcon->setIcon( _config->readEntry ( "newicon", "" ) );
+
+ this->chNormalFont->setChecked(_config->readBoolEntry( "hasnormalfont", false ) );
+ this->chNewFont->setChecked (_config->readBoolEntry( "hasnewfont", false ) );
+ this->chNormalAnim->setChecked(_config->readBoolEntry( "hasnormalanim", false ) );
+ this->chNewAnim->setChecked( _config->readBoolEntry( "hasnewanim", false ) );
+ *_fonts[ 0 ] = _config->readFontEntry( "normalfont" );
+ *_fonts[ 1 ] = _config->readFontEntry( "newfont" );
+ *_anims[ 0 ] = _config->readEntry ( "normalanim", "" );
+ *_anims[ 1 ] = _config->readEntry ( "newanim", "" );
+}
+
+void KornBoxCfgImpl::readEventConfig()
+{
+ this->chLeftRecheck ->setChecked( _config->readBoolEntry( "leftrecheck", true ) );
+ this->chMiddleRecheck->setChecked( _config->readBoolEntry( "middlerecheck", false ) );
+ this->chRightRecheck ->setChecked( _config->readBoolEntry( "rightrecheck", false ) );
+
+ this->chLeftReset ->setChecked( _config->readBoolEntry( "leftreset", false ) );
+ this->chMiddleReset->setChecked( _config->readBoolEntry( "middlereset", false ) );
+ this->chRightReset ->setChecked( _config->readBoolEntry( "rightreset", false ) );
+
+ this->chLeftView ->setChecked( _config->readBoolEntry( "leftview", false ) );
+ this->chMiddleView->setChecked( _config->readBoolEntry( "middleview", false ) );
+ this->chRightView ->setChecked( _config->readBoolEntry( "rightview", false ) );
+
+ this->chLeftRun ->setChecked( _config->readBoolEntry( "leftrun", false ) );
+ this->chMiddleRun->setChecked( _config->readBoolEntry( "middlerun", false ) );
+ this->chRightRun ->setChecked( _config->readBoolEntry( "rightrun", false ) );
+
+ this->chLeftPopup ->setChecked( _config->readBoolEntry( "leftpopup", false ) );
+ this->chMiddlePopup->setChecked( _config->readBoolEntry( "middlepopup", false ) );
+ this->chRightPopup ->setChecked( _config->readBoolEntry( "rightpopup", true ) );
+
+ this->edCommand->setURL( _config->readEntry( "command", "" ) );
+
+ this->edNewRun->setURL( _config->readEntry( "newcommand", "" ) );
+ this->edPlaySound->setURL( _config->readEntry( "sound", "" ) );
+ this->chShowPassive->setChecked( _config->readBoolEntry( "passivepopup", false ) );
+ this->chPassiveDate->setChecked( _config->readBoolEntry( "passivedate", false ) );
+}
+
+void KornBoxCfgImpl::readAccountsConfig()
+{
+ elbAccounts->setGroupName( QString( "korn-%1-%2" ).arg( _index ) );
+ elbAccounts->setConfig( _config );
+}
+
+void KornBoxCfgImpl::readDCOPConfig()
+{
+ elbDCOP->clear();
+ elbDCOP->insertStringList( _config->readListEntry( "dcop", ',' ) );
+}
+
+void KornBoxCfgImpl::writeViewConfig( KConfig* config )
+{
+ QColor invalid;
+
+ config->writeEntry( "hasnormalfgcolour", this->chNormalText->isChecked() );
+ config->writeEntry( "normalfgcolour", this->chNormalText->isChecked() ? this->cbNormalText->color() : invalid );
+ config->writeEntry( "hasnewfgcolour", this->chNewText->isChecked() );
+ config->writeEntry( "newfgcolour", this->chNewText->isChecked() ? this->cbNewText->color() : invalid );
+ config->writeEntry( "hasnormalbgcolour", this->chNormalBack->isChecked() );
+ config->writeEntry( "normalbgcolour", this->chNormalBack->isChecked() ? this->cbNormalBack->color() : invalid );
+ config->writeEntry( "hasnewbgcolour", this->chNewBack->isChecked() );
+ config->writeEntry( "newbgcolour", this->chNewBack->isChecked() ? this->cbNewBack->color() : invalid );
+
+ config->writeEntry( "hasnormalicon", this->chNormalIcon->isChecked() );
+ config->writeEntry( "normalicon", this->chNormalIcon->isChecked() ? this->ibNormalIcon->icon() : "" );
+ config->writeEntry( "hasnewicon", this->chNewIcon->isChecked() );
+ config->writeEntry( "newicon", this->chNewIcon->isChecked() ? this->ibNewIcon->icon() : "" );
+
+ config->writeEntry( "hasnormalfont", this->chNormalFont->isChecked() );
+ config->writeEntry( "normalfont", this->chNormalFont->isChecked() ? *_fonts[ 0 ] : QFont() );
+ config->writeEntry( "hasnewfont", this->chNewFont->isChecked() );
+ config->writeEntry( "newfont", this->chNewFont->isChecked() ? *_fonts[ 1 ] : QFont() );
+ config->writeEntry( "hasnormalanim", this->chNormalAnim->isChecked() );
+ config->writeEntry( "normalanim", this->chNormalAnim->isChecked() ? *_anims[ 0 ] : "" );
+ config->writeEntry( "hasnewanim", this->chNewAnim->isChecked() );
+ config->writeEntry( "newanim", this->chNewAnim->isChecked() ? *_anims[ 1 ] : "" );
+
+}
+
+void KornBoxCfgImpl::writeEventConfig( KConfig *config )
+{
+ config->writeEntry( "leftrecheck", this->chLeftRecheck ->isChecked() );
+ config->writeEntry( "middlerecheck", this->chMiddleRecheck->isChecked() );
+ config->writeEntry( "rightrecheck", this->chRightRecheck ->isChecked() );
+
+ config->writeEntry( "leftreset", this->chLeftReset ->isChecked() );
+ config->writeEntry( "middlereset", this->chMiddleReset->isChecked() );
+ config->writeEntry( "rightreset", this->chRightReset ->isChecked() );
+
+ config->writeEntry( "leftview", this->chLeftView ->isChecked() );
+ config->writeEntry( "middleview", this->chMiddleView->isChecked() );
+ config->writeEntry( "rightview", this->chRightView ->isChecked() );
+
+ config->writeEntry( "leftrun", this->chLeftRun ->isChecked() );
+ config->writeEntry( "middlerun", this->chMiddleRun->isChecked() );
+ config->writeEntry( "rightrun", this->chRightRun ->isChecked() );
+
+ config->writeEntry( "leftpopup", this->chLeftPopup ->isChecked() );
+ config->writeEntry( "middlepopup", this->chMiddlePopup->isChecked() );
+ config->writeEntry( "rightpopup", this->chRightPopup ->isChecked() );
+
+ config->writeEntry( "command", this->edCommand->url() );
+
+ config->writeEntry( "newcommand", this->edNewRun->url() );
+ config->writeEntry( "sound", this->edPlaySound->url() );
+ config->writeEntry( "passivepopup", this->chShowPassive->isChecked() );
+ config->writeEntry( "passivedate", this->chPassiveDate->isChecked() );
+}
+
+void KornBoxCfgImpl::writeAccountsConfig( KConfig */*config */)
+{
+}
+
+void KornBoxCfgImpl::writeDCOPConfig( KConfig *config )
+{
+ config->writeEntry( "dcop", elbDCOP->items(), ',' );
+}
+
+void KornBoxCfgImpl::slotEditBox()
+{
+ if( _base )
+ return; //Already a dialog open
+ if( elbAccounts->listBox()->currentItem() < 0 )
+ return; //No item selected
+ elbAccounts->setEnabled( false );
+
+ _base = new KDialogBase( this, "Account Dialog", false, i18n("Box Configuration"),
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true );
+ KornAccountCfgImpl *widget = new KornAccountCfgImpl( _base, "Account Widget" );
+
+ _base->setMainWidget( widget );
+
+ connect( _base, SIGNAL( finished() ), this, SLOT( slotDialogDestroyed() ) );
+
+ _group = new KConfigGroup( _config, QString( "korn-%1-%2" ).
+ arg( _index ).arg(elbAccounts->listBox()->currentItem() ) );
+
+ QMap< QString, QString > *map = new QMap< QString, QString >( _config->entryMap( QString( "korn-%1-%2" ).
+ arg( _index ).arg(elbAccounts->listBox()->currentItem() ) ) );
+ widget->readConfig( _group, map, _index, elbAccounts->listBox()->currentItem() );
+ delete map;
+
+ _base->show();
+}
+
+void KornBoxCfgImpl::slotActivated( const QString& )
+{
+ slotEditBox();
+}
+
+void KornBoxCfgImpl::slotActivated( const int )
+{
+ slotEditBox();
+}
+
+void KornBoxCfgImpl::slotSetDefaults( const QString& name, const int, KConfig* config )
+{
+ config->writeEntry( "name", name );
+ config->writeEntry( "protocol", "mbox" );
+ config->writeEntry( "host", QString::null );
+ config->writeEntry( "port", QString::null );
+ config->writeEntry( "username", QString::null );
+ config->writeEntry( "mailbox", "/var/spool/mail/" );
+ config->writeEntry( "savepassword", 0 );
+ config->writeEntry( "password", QString::null );
+ config->writeEntry( "auth", QString::null );
+ config->writeEntry( "interval", 300 );
+ config->writeEntry( "boxsettings", true );
+ config->writeEntry( "command", "" );
+ config->writeEntry( "sound", "" );
+ config->writeEntry( "passivepopup", false );
+ config->writeEntry( "passivedate", false );
+}
+
+void KornBoxCfgImpl::slotChangeNormalAnim()
+{
+ *_anims[ 0 ] = KFileDialog::getOpenFileName( *_anims[ 0 ], ".mng .gif", this, i18n("Normal animation") );
+}
+
+void KornBoxCfgImpl::slotChangeNewAnim()
+{
+ *_anims[ 1 ] = KFileDialog::getOpenFileName( *_anims[ 1 ], ".mng .gif", this, i18n("Normal animation") );
+}
+
+void KornBoxCfgImpl::slotChangeNormalFont()
+{
+ KFontDialog fd( this, "font dialog" );
+ fd.setFont( *_fonts[ 0 ], false );
+ fd.exec();
+ *_fonts[ 0 ] = fd.font();
+}
+
+void KornBoxCfgImpl::slotChangeNewFont()
+{
+ KFontDialog fd( this, "font dialog" );
+ fd.setFont( *_fonts[ 1 ], false );
+ fd.exec();
+ *_fonts[ 1 ] = fd.font();
+}
+
+void KornBoxCfgImpl::slotNormalAnimToggled( bool enabled )
+{
+ this->chNormalText->setEnabled( !enabled );
+ //this->chNormalBack->setEnabled( !enabled );
+ this->chNormalIcon->setEnabled( !enabled );
+ this->chNormalFont->setEnabled( !enabled );
+
+ this->cbNormalText->setEnabled( !enabled && this->chNormalText->isChecked() );
+ //this->cbNormalBack->setEnabled( !enabled && this->chNormalBack->isChecked() );
+ this->ibNormalIcon->setEnabled( !enabled && this->chNormalIcon->isChecked() );
+ this->pbNormalFont->setEnabled( !enabled && this->chNormalFont->isChecked() );
+}
+
+void KornBoxCfgImpl::slotNewAnimToggled( bool enabled )
+{
+ this->chNewText->setEnabled( !enabled );
+ //this->chNewBack->setEnabled( !enabled );
+ this->chNewIcon->setEnabled( !enabled );
+ this->chNewFont->setEnabled( !enabled );
+
+ this->cbNewText->setEnabled( !enabled && this->chNewText->isChecked() );
+ //this->cbNewBack->setEnabled( !enabled && this->chNewBack->isChecked() );
+ this->ibNewIcon->setEnabled( !enabled && this->chNewIcon->isChecked() );
+ this->pbNewFont->setEnabled( !enabled && this->chNewFont->isChecked() );
+}
+
+void KornBoxCfgImpl::slotOK()
+{
+ writeConfig( _config, _index );
+}
+
+void KornBoxCfgImpl::slotCancel()
+{
+ readConfig( _config, _index );
+}
+
+void KornBoxCfgImpl::slotDialogDestroyed()
+{
+ _base->deleteLater(); _base = 0;
+ _group->deleteLater();
+ elbAccounts->setEnabled( true );
+}
+
+void KornBoxCfgImpl::slotAccountsSwapped( int account1, int account2 )
+{
+ KOrnPassword::swapKOrnWalletPassword( _index, account1, _index, account2 );
+}
+
+void KornBoxCfgImpl::slotAccountDeleted( int account )
+{
+ KOrnPassword::deleteKOrnPassword( _index, account );
+}
+
+#include "kornboxcfgimpl.moc"
+
diff --git a/korn/kornboxcfgimpl.h b/korn/kornboxcfgimpl.h
new file mode 100644
index 000000000..3a3ea2eec
--- /dev/null
+++ b/korn/kornboxcfgimpl.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KORNBOXCFGIMPL_H
+#define MK_KORNBOXCFGIMPL_H
+
+#include "kornboxcfg.h"
+
+class KConfig;
+class KConfigGroup;
+class KDialogBase;
+
+class QFont;
+class QString;
+class QWidget;
+
+class KornBoxCfgImpl : public KornBoxCfg
+{ Q_OBJECT
+public:
+ KornBoxCfgImpl( QWidget *parent, const char * name );
+ ~KornBoxCfgImpl();
+
+ /**
+ * This method write the current configuration to a specified KConfig-object.
+ *
+ * @param config The config where in which the configuration should be added.
+ * @param index The index of the selected config. This is the group-number.
+ */
+ void writeConfig( KConfig * config, const int index );
+
+ /**
+ * This method write the current configuration to a specified KConfig-object.
+ *
+ * @param config The config where in which the configuration should be added. Note that this object is stored locally until the object is destroyed.
+ * @param index The index of the selected config. This is the group-number.
+ */
+ void readConfig( KConfig * config, const int index );
+
+private:
+ void readViewConfig();
+ void readEventConfig();
+ void readAccountsConfig();
+ void readDCOPConfig();
+
+ void writeViewConfig( KConfig* config );
+ void writeEventConfig( KConfig *config );
+ void writeAccountsConfig( KConfig *config );
+ void writeDCOPConfig( KConfig *config );
+
+ KConfig* _config;
+ KConfigGroup *_group;
+ KDialogBase *_base;
+ int _index;
+ QString *_anims[ 2 ];
+ QFont *_fonts[ 2 ];
+
+protected slots:
+ virtual void slotEditBox();
+ virtual void slotActivated( const QString& );
+ virtual void slotActivated( const int );
+ virtual void slotSetDefaults( const QString&, const int, KConfig* );
+ virtual void slotChangeNormalAnim();
+ virtual void slotChangeNewAnim();
+ virtual void slotChangeNormalFont();
+ virtual void slotChangeNewFont();
+ virtual void slotNormalAnimToggled( bool enabled );
+ virtual void slotNewAnimToggled( bool enabled );
+
+private slots:
+ void slotOK();
+ void slotCancel();
+ void slotDialogDestroyed();
+
+ void slotAccountsSwapped( int account1, int account2 );
+ void slotAccountDeleted( int account );
+};
+
+#endif //MK_KORNBOXCFGIMPL_H
diff --git a/korn/korncfg.ui b/korn/korncfg.ui
new file mode 100644
index 000000000..46a812a56
--- /dev/null
+++ b/korn/korncfg.ui
@@ -0,0 +1,176 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KornCfgWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KornCfgWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>350</width>
+ <height>336</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Korn Configuration</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabKornCfg</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Boxes</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBoxManager">
+ <property name="name">
+ <cstring>elbBoxes</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbEdit</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Edit</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>chUseWallet</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;KWallet if possible</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;View</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>bgCheckBoxes</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>rbHorizontal</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Horizontal</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>rbVertical</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Vertical</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>rbDocked</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Docked</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>KEditListBoxManager</class>
+ <header location="local">keditlistboxman.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ <signal>activated( const QString&amp; )</signal>
+ <signal>activated( const int )</signal>
+ <signal>setDefaults( const QString&amp;, KConfig* )</signal>
+ <signal>setDefaults( const QString&amp;, const int, KConfig* )</signal>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154388db59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a09643cc7ce0000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>elbBoxes</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>KornCfgWidget</receiver>
+ <slot>slotActivated(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>elbBoxes</sender>
+ <signal>setDefaults(const QString&amp;,const int,KConfig*)</signal>
+ <receiver>KornCfgWidget</receiver>
+ <slot>slotSetDefaults(const QString&amp;,const int,KConfig*)</slot>
+ </connection>
+ <connection>
+ <sender>pbEdit</sender>
+ <signal>clicked()</signal>
+ <receiver>KornCfgWidget</receiver>
+ <slot>slotEditBox()</slot>
+ </connection>
+</connections>
+<slots>
+ <slot access="protected">slotActivated( const QString&amp; )</slot>
+ <slot access="protected">slotActivated( const int )</slot>
+ <slot>slotOK()</slot>
+ <slot>slotApply()</slot>
+ <slot>slotCancel()</slot>
+ <slot access="protected">slotSetDefaults( const QString&amp;, const int, KConfig* )</slot>
+ <slot access="protected">slotEditBox()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/korn/korncfgimpl.cpp b/korn/korncfgimpl.cpp
new file mode 100644
index 000000000..6860c17e9
--- /dev/null
+++ b/korn/korncfgimpl.cpp
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "korncfgimpl.h"
+
+#include "keditlistboxman.h"
+#include "kornboxcfgimpl.h"
+#include "password.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include <qcolor.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qstring.h>
+#include <qtimer.h>
+
+
+/*
+ * parent should be of type KDialogBase
+ */
+KornCfgImpl::KornCfgImpl( QWidget * parent, const char * name )
+ : KornCfgWidget( parent, name ),
+ _config( new KConfig( "kornrc" ) ),
+ _base( 0 )
+{
+ elbBoxes->setSubGroupName( "korn-%1-%2" );
+ elbBoxes->setGroupName( "korn-%1" );
+ elbBoxes->setConfig( _config );
+ elbBoxes->setTitle( i18n( "Boxes" ) );
+
+ connect( parent, SIGNAL( okClicked() ), this, SLOT( slotOK() ) );
+ connect( parent, SIGNAL( cancelClicked() ), this, SLOT( slotCancel() ) );
+ connect( parent, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) );
+
+ connect( elbBoxes, SIGNAL( elementsSwapped( int, int ) ), this, SLOT( slotElementsSwapped( int, int ) ) );
+ connect( elbBoxes, SIGNAL( elementDeleted( int ) ), this, SLOT( slotElementDeleted( int ) ) );
+
+ readConfig();
+}
+
+KornCfgImpl::~KornCfgImpl()
+{
+ _config->sync();
+}
+
+void KornCfgImpl::slotEditBox()
+{
+ if( _base )
+ return; //Already a dialog open
+ if( elbBoxes->listBox()->currentItem() < 0 )
+ return; //No item selected
+ elbBoxes->setEnabled( false );
+
+ _base = new KDialogBase( this, "Box Dialog", false, "Box Configuration",
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true );
+ KornBoxCfgImpl *widget = new KornBoxCfgImpl( _base, "Box Widget" );
+
+ connect( _base, SIGNAL( finished() ), this, SLOT( slotDialogDestroyed() ) );
+
+ _base->setMainWidget( widget );
+ widget->readConfig( _config, elbBoxes->listBox()->currentItem() );
+
+ _base->show();
+}
+
+void KornCfgImpl::slotDialogDestroyed()
+{
+ _base->deleteLater(); _base = 0;
+ elbBoxes->setEnabled( true );
+}
+
+void KornCfgImpl::slotElementsSwapped( int box1, int box2 )
+{
+ int accountnumber1 = 0, accountnumber2 = 0;
+ while( _config->hasGroup( QString( "korn-%1-%2" ).arg( box1 ).arg( accountnumber1 ) ) )
+ ++accountnumber1;
+
+ while( _config->hasGroup( QString( "korn-%1-%2" ).arg( box2 ).arg( accountnumber2 ) ) )
+ ++accountnumber2;
+
+ KOrnPassword::swapKOrnWalletPasswords( box1, accountnumber1, box2, accountnumber2 );
+}
+
+void KornCfgImpl::slotElementDeleted( int box )
+{
+ int accountnumber = 0;
+ while( _config->hasGroup( QString( "korn-%1-%2" ).arg( box ).arg( accountnumber ) ) )
+ {
+ KOrnPassword::deleteKOrnPassword( box, accountnumber );
+ ++accountnumber;
+ }
+}
+
+void KornCfgImpl::slotActivated( const QString& )
+{
+ slotEditBox();
+}
+
+void KornCfgImpl::slotActivated( const int )
+{
+ slotEditBox();
+}
+
+void KornCfgImpl::slotSetDefaults( const QString& name, const int index, KConfig* config )
+{
+ config->writeEntry( "name", name );
+ config->writeEntry( "hasnormalfgcolour", true );
+ config->writeEntry( "hasnewfgcolour", true );
+ config->writeEntry( "hasnormalbgcolour", false );
+ config->writeEntry( "hasnewbgcolour", false );
+ config->writeEntry( "hasnormalicon", false );
+ config->writeEntry( "hasnewicon", false );
+ config->writeEntry( "hasnormalanim", false );
+ config->writeEntry( "hasnewanim", false );
+ config->writeEntry( "normalfgcolour", Qt::black );
+ config->writeEntry( "newfgcolour", Qt::black );
+ config->writeEntry( "normalbgcolour", QString::null );
+ config->writeEntry( "newbgcolour", QString::null );
+ config->writeEntry( "normalicon", QString::null );
+ config->writeEntry( "newicon", QString::null );
+ config->writeEntry( "normalanim", QString::null );
+ config->writeEntry( "newanim", QString::null );
+ config->writeEntry( "leftrecheck", true );
+ config->writeEntry( "middlerecheck", false );
+ config->writeEntry( "rightrecheck", false );
+ config->writeEntry( "leftreset", false );
+ config->writeEntry( "middlereset", false );
+ config->writeEntry( "rightreset", false );
+ config->writeEntry( "leftview", false );
+ config->writeEntry( "middleview", false );
+ config->writeEntry( "rightview", false );
+ config->writeEntry( "leftcommand", false );
+ config->writeEntry( "middlecommand", false );
+ config->writeEntry( "rightcommand", false );
+ config->writeEntry( "leftpopup", false );
+ config->writeEntry( "middlepopupk", false );
+ config->writeEntry( "rightpopup", true );
+ config->writeEntry( "command", "" );
+ config->writeEntry( "newcommand", "" );
+ config->writeEntry( "sound", "" );
+ config->writeEntry( "passivepopup", false );
+ config->writeEntry( "passivedate", false );
+ config->writeEntry( "numaccounts", 1 );
+ config->writeEntry( "dcop", QStringList() );
+ config->setGroup( QString( "korn-%1-0" ).arg( index ) );
+ config->writeEntry( "name", name );
+ config->writeEntry( "protocol", "mbox" );
+ config->writeEntry( "server", QString::null );
+ config->writeEntry( "port", QString::null );
+ config->writeEntry( "username", QString::null );
+ config->writeEntry( "mailbox", "/var/spool/mail/" );
+ config->writeEntry( "savepassword", 0 );
+ config->writeEntry( "password", QString::null );
+ config->writeEntry( "auth", QString::null );
+ config->writeEntry( "interval", 300 );
+ config->writeEntry( "boxsettings", true );
+ config->writeEntry( "command", "" );
+ config->writeEntry( "sound", "" );
+ config->writeEntry( "passivepopup", false );
+ config->writeEntry( "passivedate", false );
+}
+
+void KornCfgImpl::slotOK()
+{
+ writeConfig();
+}
+
+void KornCfgImpl::slotCancel()
+{
+ _config->rollback();
+}
+
+void KornCfgImpl::slotApply()
+{
+ writeConfig();
+}
+
+void KornCfgImpl::readConfig()
+{
+ _config->setGroup( "korn" );
+
+ QChar layout = _config->readEntry( "layout" ).stripWhiteSpace()[0].upper();
+ if( layout == QChar( 'H' ) )
+ rbHorizontal->setChecked( true );
+ else if( layout == QChar( 'V' ) )
+ rbVertical->setChecked( true );
+ else
+ rbDocked->setChecked( true );
+
+ chUseWallet->setChecked( _config->readBoolEntry( "usewallet", true ) );
+}
+
+void KornCfgImpl::writeConfig()
+{
+ _config->setGroup( "korn" );
+
+ if( rbHorizontal->isChecked() )
+ _config->writeEntry( "layout", "Horizontal" );
+ if( rbVertical->isChecked() )
+ _config->writeEntry( "layout", "Vertical" );
+ if( rbDocked->isChecked() )
+ _config->writeEntry( "layout", "Docked" );
+
+ //Default is 'false' here, because if no option is set, KWallet isn't used.
+ if( _config->readBoolEntry( "usewallet", false ) != chUseWallet->isChecked() )
+ //Configuration box changed => setting over configuration
+ rewritePasswords();
+
+ _config->writeEntry( "usewallet", chUseWallet->isChecked() );
+
+ _config->sync();
+}
+
+void KornCfgImpl::rewritePasswords()
+{
+ int box = 0 - 1;
+ int account = 0 - 1;
+ KConfigGroup *group;
+
+ while( _config->hasGroup( QString( "korn-%1" ).arg( ++box ) ) )
+ {
+ account = 0 - 1;
+ while( _config->hasGroup( QString( "korn-%1-%2" ).arg( box ).arg( ++account ) ) )
+ {
+ group = new KConfigGroup( _config, QString( "korn-%1-%2" ).arg( box ).arg( account ) );
+ KOrnPassword::rewritePassword( box, account, *group, chUseWallet->isChecked() );
+ delete group;
+ }
+ }
+
+ _config->setGroup( "korn" );
+}
+
+#include "korncfgimpl.moc"
diff --git a/korn/korncfgimpl.h b/korn/korncfgimpl.h
new file mode 100644
index 000000000..fc86a4fad
--- /dev/null
+++ b/korn/korncfgimpl.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_KORNCFGIMPL_H
+#define MK_KORNCFGIMPL_H
+
+class KConfig;
+#include "korncfg.h"
+
+class KDialogBase;
+
+class QObject;
+class QString;
+
+class KornCfgImpl : public KornCfgWidget
+{ Q_OBJECT
+public:
+ KornCfgImpl( QWidget * parent = 0, const char * name = 0 );
+ ~KornCfgImpl();
+
+private slots:
+ virtual void slotDialogDestroyed();
+ void slotElementsSwapped( int box1, int box2 );
+ void slotElementDeleted( int box );
+protected slots:
+ virtual void slotEditBox();
+ virtual void slotActivated( const QString& );
+ virtual void slotActivated( const int );
+ virtual void slotSetDefaults( const QString&, const int, KConfig* );
+public slots:
+ virtual void slotOK();
+ virtual void slotCancel();
+ virtual void slotApply();
+
+private:
+ void readConfig();
+ void writeConfig();
+
+ void rewritePasswords();
+
+ KConfig *_config;
+ KDialogBase *_base;
+};
+
+
+#endif //MK_KORNCFGIMPL_H
diff --git a/korn/kornshell.cpp b/korn/kornshell.cpp
new file mode 100644
index 000000000..3e87ba42f
--- /dev/null
+++ b/korn/kornshell.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2004-2006, Mart Kelder (mart@kelder31.nl)
+ *
+ * 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 "kornshell.h"
+
+#include "boxcontainer.h"
+#include "dockedcontainer.h"
+#include "korncfgimpl.h"
+#include "hvcontainer.h"
+#include "password.h"
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include <qtimer.h>
+
+KornShell::KornShell( QWidget * parent, const char * name )
+ : QWidget( parent, name ),
+ _config( new KConfig( "kornrc" ) ),
+ _box( 0 ),
+ _configDialog( 0 ),
+ _show( false )
+{
+ _config->checkUpdate( "korn_kde_3_4_config_change", "korn-3-4-config_change.upd" );
+ if( kapp->isRestored() )
+ {
+ _config->setGroup( "korn" );
+ QTimer::singleShot( _config->readNumEntry( "session_startup_delay", 2000 ), this, SLOT(readConfig()) );
+ kdDebug() << "startup delayed" << endl;
+ }
+ else
+ {
+ kdDebug() << "Startup not delayed" << endl;
+ readConfig();
+ }
+
+}
+
+KornShell::~KornShell()
+{
+ if( _box )
+ _box->writeConfig( _config );
+ delete _config;
+ delete _box;
+}
+
+void KornShell::show()
+{
+ if( _box )
+ _box->showBox();
+ else
+ _show = true;
+}
+
+void KornShell::optionDlg()
+{
+ if( _configDialog )
+ {
+ _configDialog->show();
+ return;
+ }
+
+ _configDialog = new KDialogBase( 0, "Configuration Dialog", false, i18n( "Korn Configuration" ),
+ KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, KDialogBase::Ok, true );
+
+ KornCfgImpl *widget = new KornCfgImpl( _configDialog, "Configuration widget" );
+ _configDialog->setMainWidget( widget );
+
+ connect( _configDialog, SIGNAL( finished() ), this, SLOT( slotDialogClosed() ) );
+ connect( _configDialog, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) );
+
+ _configDialog->show();
+}
+
+void KornShell::readConfig()
+{
+ static bool shownConfig = false;
+
+ _config->setGroup( "korn" );
+ QChar layout = _config->readEntry( "layout", "Docked" )[0].upper();
+ KOrnPassword::setUseWallet( _config->readBoolEntry( "usewallet", false ) );
+
+ if( layout == 'H' )
+ _box = new HVContainer( Qt::Horizontal, this, "horizontal container" );
+ else if( layout == 'V' )
+ _box = new HVContainer( Qt::Vertical, this, "vertical container" );
+ else
+ _box = new DockedContainer( this, "docked container" );
+
+ connect( _box, SIGNAL( showConfiguration() ), this, SLOT( optionDlg() ) );
+
+ _box->readConfig( _config );
+
+ //Show configuration dialog of no boxes are configurated
+ if( !_config->hasGroup( "korn-0" ) )
+ //If user pressed cancel, or did not add a box, close KOrn
+ if( !shownConfig )
+ {
+ shownConfig = true;
+ optionDlg();
+ }
+ else
+ {
+ kapp->quit();
+ }
+
+ if( _show )
+ {
+ // Show is called, but _box wasn't available at that time
+ show();
+ _show = false;
+ }
+}
+
+void KornShell::slotDialogClosed()
+{
+ _configDialog->deleteLater(); _configDialog = 0;
+
+ //At this time, just delete all widgets and make a new one.
+ //Maybe, this should replaces later by a better variant.
+ slotApply();
+}
+
+void KornShell::slotApply()
+{
+ //At this time, just delete all widgets and make a new one.
+ //Maybe, this should replaces later by a better variant.
+
+ delete _box; _box = 0;
+
+ _config->reparseConfiguration();
+
+ readConfig();
+ _box->showBox();
+}
+
+#include "kornshell.moc"
diff --git a/korn/kornshell.h b/korn/kornshell.h
new file mode 100644
index 000000000..b999bfed4
--- /dev/null
+++ b/korn/kornshell.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004-2006, Mart Kelder (mart@kelder31.nl)
+ *
+ * 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 MK_KORNSHELL_H
+#define MK_KORNSHELL_H
+
+class BoxContainer;
+class KDialogBase;
+
+class KConfig;
+
+#include <qwidget.h>
+
+/**
+ * This is a rewritten KornShell class. It is rewritten because the depending classes changed.
+ */
+class KornShell : public QWidget
+{ Q_OBJECT
+public:
+ KornShell( QWidget * parent = 0, const char * name = 0 );
+ ~KornShell();
+
+ void show();
+public slots:
+ /**
+ * This function shows the configuration-dialog
+ */
+ void optionDlg();
+
+private slots:
+ void slotDialogClosed();
+ void slotApply();
+ void readConfig();
+
+private:
+ KConfig *_config;
+ BoxContainer *_box;
+ KDialogBase *_configDialog;
+ bool _show;
+};
+
+#endif //MK_KORNSHELL_H
diff --git a/korn/label.h b/korn/label.h
new file mode 100644
index 000000000..d3c87ae9c
--- /dev/null
+++ b/korn/label.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_LABEL_H
+#define MK_LABEL_H
+
+#include <qlabel.h>
+#include <qevent.h>
+
+/**
+ * A simple overriding of the QLabel class to get a mouseButtonPressed() signal
+ */
+class Label : public QLabel
+{ Q_OBJECT
+public:
+ Label( QWidget * parent = 0, const char * name = 0 ) : QLabel( parent, name ) {}
+ virtual ~Label() {}
+
+protected:
+ virtual void mousePressEvent( QMouseEvent *e ) { emit mouseButtonPressed( e->button() ); }
+signals:
+ /**
+ * Emitted when a button is pressed.
+ */
+ void mouseButtonPressed( Qt::ButtonState );
+};
+
+#endif //MK_LABEL_H
diff --git a/korn/maildir_proto.h b/korn/maildir_proto.h
new file mode 100644
index 000000000..b3b7ae3a1
--- /dev/null
+++ b/korn/maildir_proto.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_MAILDIR_PROTO_H
+#define MK_MAILDIR_PROTO_H
+
+#include "kio_proto.h"
+
+/*
+ * Protocol for (postfix?) maildir
+ * Only tested with a copy of a maildir forder
+ */
+class Maildir_Protocol : public KIO_Protocol
+{
+public:
+ Maildir_Protocol() {}
+ virtual ~Maildir_Protocol() {}
+
+ virtual KIO_Protocol * clone() const { return new Maildir_Protocol; }
+
+ virtual QString protocol() const { return "file"; }
+ virtual QString configName() const { return "maildir"; }
+
+ virtual bool canReadSubjects() const { return true; }
+ virtual bool canDeleteMail() const { return true; }
+ virtual bool canReadMail() const { return true; }
+ virtual bool fullMessage() const { return true; }
+
+ virtual int fields() const { return server | mailbox; }
+ virtual int urlFields() const { return no_fields; }
+
+ virtual QString serverName() const { return i18n( "Path:" ); }
+
+ virtual void recheckKURL( KURL &kurl, KIO::MetaData & )
+ { kurl.setPath( kurl.host() + "/." + kurl.path().replace( '/' , '.' ) + "/new" ); kurl.setHost( "" ); }
+ virtual void readSubjectKURL( KURL &, KIO::MetaData & ) { }
+ virtual void deleteMailKURL( KURL &, KIO::MetaData & ) { }
+ virtual void readMailKURL( KURL &, KIO::MetaData & ) { }
+};
+
+#endif
diff --git a/korn/maildlg.cpp b/korn/maildlg.cpp
new file mode 100644
index 000000000..3e6cd4cce
--- /dev/null
+++ b/korn/maildlg.cpp
@@ -0,0 +1,109 @@
+#include "maildlg.h"
+#include <qlayout.h>
+#include<kdebug.h>
+#include<klocale.h>
+#include<qapplication.h>
+#include "mailsubject.h"
+#include <qprogressdialog.h>
+#include "maildrop.h"
+
+KornMailDlg::KornMailDlg( QWidget *parent )
+ : KDialogBase( parent, "maildialog", true, i18n("Mail Details"), User1|Close, Close, true, KGuiItem(i18n("&Full Message"))),
+ _progress( 0 )
+{
+ QWidget * page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout * topLayout = new QVBoxLayout( page, 0, spacingHint() );
+ _editCtrl = new KEdit(page);
+ topLayout->addWidget(_editCtrl, 10);
+ _editCtrl->setReadOnly(true);
+ connect(this, SIGNAL(user1Clicked()), this, SLOT(showFullMessage()));
+ setInitialSize(QSize(QApplication::desktop()->width()*9/10, QApplication::desktop()->height()/2));
+}
+
+KornMailDlg::~KornMailDlg()
+{
+}
+
+void KornMailDlg::loadMailCanceled()
+{
+ _loadMailCanceled = true;
+}
+
+
+void KornMailDlg::showFullMessage()
+{
+ _loadMailCanceled = false;
+
+ // create progress dialog
+ _progress = new QProgressDialog(this, "bla", TRUE);
+ _progress->setMinimumDuration(0);
+ _progress->setLabelText(i18n("Loading full mail. Please wait..."));
+
+ // this should show it even if the mailbox does not support progress bars
+ _progress->setTotalSteps(1000);
+ _progress->setProgress(1);
+ qApp->processEvents();
+
+ // connect the mailbox with the progress dialog in case it supports progress bars
+ connect(_mailDrop, SIGNAL(readMailTotalSteps(int)), _progress, SLOT(setTotalSteps(int)));
+ connect(_mailDrop, SIGNAL(readMailProgress(int)), _progress, SLOT(setProgress(int)));
+ qApp->processEvents();
+
+ // connect the mailbox's cancel button
+ connect(_progress, SIGNAL(canceled()), this, SLOT(loadMailCanceled()));
+
+ connect(_mailDrop, SIGNAL(readMailReady(QString*)), this, SLOT(readMailReady(QString*)));
+
+ // now load the mail fully
+ if( _mailDrop->synchrone() )
+ {
+ QString mail = _mailDrop->readMail(_mailSubject->getId(), &_loadMailCanceled);
+ readMailReady( &mail );
+ }
+ else
+ _mailDrop->readMail(_mailSubject->getId(), &_loadMailCanceled);
+}
+
+void KornMailDlg::setMailSubject( KornMailSubject * mailSubject )
+{
+ _mailSubject = mailSubject;
+ _mailDrop = mailSubject->getMailDrop();
+
+ // show mail
+ _editCtrl->setText(_mailSubject->getHeader());
+
+ // disable "Full Message" button if mail is already loaded fully
+ enableButton(User1, !_mailSubject->isHeaderFullMessage() && _mailDrop->canReadMail());
+}
+
+void KornMailDlg::readMailReady( QString* mail )
+{
+ deleteProgress();
+
+ // if loading was not canceled and did not fail
+ if ( mail->length() > 0)
+ {
+ // store full mail in KornMailSubject instance (so that it has not to be loaded again next time)
+ _mailSubject->setHeader(*mail, true);
+
+ // show fully loaded mail
+ _editCtrl->setText(*mail);
+
+ // disable "Full Message" button
+ enableButton(User1, false);
+ }
+}
+
+void KornMailDlg::deleteProgress()
+{
+ _progress->setProgress(_progress->totalSteps());
+ _progress->hide();
+
+ disconnect( _mailDrop, SIGNAL(readMailReady(QString*)), this, SLOT(readMailReady(QString*)));
+
+ delete _progress;
+ _progress = 0;
+}
+
+#include "maildlg.moc"
diff --git a/korn/maildlg.h b/korn/maildlg.h
new file mode 100644
index 000000000..0d222a706
--- /dev/null
+++ b/korn/maildlg.h
@@ -0,0 +1,82 @@
+#ifndef KornMailDlg_h
+#define KornMailDlg_h
+
+#include<kdialogbase.h>
+#include <keditcl.h>
+
+class KornMailSubject;
+class KMailDrop;
+
+class QProgressDialog;
+class QString;
+
+/**
+ * KornMailDlg shows the header and (if available) the body of a mail.
+ * If the mails body is not available a button allows the user to load it.
+ */
+class KornMailDlg : public KDialogBase
+{
+ Q_OBJECT
+
+ /**
+ * Edit control showing the mail (read only)
+ */
+ KEdit * _editCtrl;
+
+ /**
+ * The mail to show
+ */
+ KornMailSubject * _mailSubject;
+
+ /**
+ * The mailbox which can load the mail fully
+ */
+ KMailDrop * _mailDrop;
+
+ /**
+ * Flag used during the load process. Set to true if the user clicks the cancel button.
+ */
+ bool _loadMailCanceled;
+
+ /**
+ * Progress bar
+ */
+ QProgressDialog *_progress;
+public:
+ /**
+ * KornMailDlg Constructor
+ * @param parent parent widget
+ */
+ KornMailDlg( QWidget *parent=0 );
+
+ /**
+ * Set the mail details to show. The mails body is transfered to the edit control
+ * and the "Full Message" button is enabled, if the mail body is not available and
+ * if the mailbox can load the mail fully.
+ * @param mailDrop maibox which can load the mesage fully
+ * @param mailSubject mail to show
+ */
+ void setMailSubject( KornMailSubject * mailSubject);
+
+ /**
+ * KornMailDlg Destructor
+ */
+ virtual ~KornMailDlg();
+
+private:
+ void deleteProgress();
+private slots:
+ /**
+ * Slot triggered if the user presses the "Full Message" button
+ */
+ void showFullMessage();
+
+ /**
+ * Slot triggered if the user canceles the message loading process
+ */
+ void loadMailCanceled();
+
+ void readMailReady( QString* );
+};
+
+#endif
diff --git a/korn/maildrop.cpp b/korn/maildrop.cpp
new file mode 100644
index 000000000..7a1dd4443
--- /dev/null
+++ b/korn/maildrop.cpp
@@ -0,0 +1,250 @@
+/*
+* maildrop.cpp -- Implementation of class KMailDrop.
+* Author: Sirtaj Singh Kang
+* Version: $Id$
+* Generated: Sat Nov 29 20:07:45 EST 1997
+*/
+
+#include<assert.h>
+#include<qapplication.h>
+
+#include<kconfigbase.h>
+#include<kdebug.h>
+
+#include"utils.h"
+#include"maildrop.h"
+#include"mailsubject.h"
+
+const char *KMailDrop::TypeConfigKey = "type";
+const char *KMailDrop::CaptionConfigKey = "caption";
+const char *KMailDrop::ClickConfigKey = "onclick";
+const char *KMailDrop::NewMailConfigKey = "newcommand";
+const char *KMailDrop::SoundFileConfigKey = "sound";
+const char *KMailDrop::BgColourConfigKey = "bgcolour";
+const char *KMailDrop::FgColourConfigKey = "fgcolour";
+const char *KMailDrop::NBgColourConfigKey = "newmailbgcolour";
+const char *KMailDrop::NFgColourConfigKey = "newmailfgcolour";
+const char *KMailDrop::IconConfigKey = "icon";
+const char *KMailDrop::NewMailIconConfigKey = "newmailicon";
+const char *KMailDrop::DisplayStyleConfigKey = "displaystyle";
+const char *KMailDrop::ResetCounterConfigKey = "resetcounter";
+const char *KMailDrop::PassivePopupConfigKey = "passivepopup";
+const char *KMailDrop::PassiveDateConfigKey = "passivedate";
+const char *KMailDrop::UseBoxSettingsConfigKey = "boxsettings";
+const char *KMailDrop::RealNameConfigKey = "name";
+
+KMailDrop::KMailDrop()
+ : _style(Plain),
+ _lastCount(0)
+{
+ connect(this, SIGNAL(changed( int, KMailDrop* )), SLOT(setCount( int, KMailDrop* )));
+
+ //Set default colours; this prevents black (QColor::invalid) boxes after creating a new box.
+ _bgColour = QApplication::palette().active().background();
+ _fgColour = QApplication::palette().active().text();
+ _nbgColour = QApplication::palette().active().background();
+ _nfgColour = QApplication::palette().active().text();
+}
+
+KMailDrop::~KMailDrop()
+{
+ // Empty.
+}
+
+void KMailDrop::setCount(int count, KMailDrop*)
+{
+ _lastCount = count;
+}
+
+void KMailDrop::notifyClients()
+{
+ emit(notifyDisconnect());
+}
+
+//void KMailDrop::addConfigPage(KDropCfgDialog * dlg)
+//{
+// dlg->addConfigPage(new KGeneralCfg(this));
+// dlg->addConfigPage(new KCommandsCfg(this));
+//}
+
+void KMailDrop::forceCountZero()
+{
+ emit changed( 0, this );
+}
+
+void KMailDrop::readGeneralConfigGroup( const KConfigBase& cfg )
+{
+ _passivePopup = cfg.readBoolEntry(fu(PassivePopupConfigKey), false );
+ _passiveDate = cfg.readBoolEntry(fu(PassiveDateConfigKey), false );
+ _soundFile = cfg.readEntry(fu(SoundFileConfigKey),"");
+ _nMailCmd = cfg.readEntry(fu(NewMailConfigKey),"");
+
+ emit(configChanged());
+}
+
+bool KMailDrop::readConfigGroup(const KConfigBase & c)
+{
+ _caption = c.readEntry(fu(CaptionConfigKey));
+ _clickCmd = c.readPathEntry(fu(ClickConfigKey));
+ _style = Style(c.readUnsignedNumEntry(fu(DisplayStyleConfigKey), Plain));
+ _bgColour = c.readColorEntry(fu(BgColourConfigKey), &QApplication::palette().active().background());
+ _fgColour = c.readColorEntry(fu(FgColourConfigKey), &QApplication::palette().active().text());
+ _nbgColour = c.readColorEntry(fu(NBgColourConfigKey), &QApplication::palette().active().background());
+ _nfgColour = c.readColorEntry(fu(NFgColourConfigKey), &QApplication::palette().active().text());
+ _icon = c.readEntry(fu(IconConfigKey));
+ _nIcon = c.readEntry(fu(NewMailIconConfigKey));
+ _realName = c.readEntry(fu(RealNameConfigKey));
+
+ if( !c.readBoolEntry(fu(UseBoxSettingsConfigKey), true ) )
+ readGeneralConfigGroup( c );
+
+ emit(configChanged());
+
+ return true;
+}
+
+bool KMailDrop::writeConfigGroup(KConfigBase & c) const
+{
+ c.writeEntry(fu(TypeConfigKey), type());
+ c.writeEntry(fu(CaptionConfigKey), caption());
+ c.writePathEntry(fu(ClickConfigKey), clickCmd());
+ c.writePathEntry(fu(NewMailConfigKey), newMailCmd());
+ c.writePathEntry(fu(SoundFileConfigKey), soundFile());
+ c.writeEntry(fu(DisplayStyleConfigKey), _style);
+ c.writeEntry(fu(BgColourConfigKey), _bgColour);
+ c.writeEntry(fu(FgColourConfigKey), _fgColour);
+ c.writeEntry(fu(NBgColourConfigKey), _nbgColour);
+ c.writeEntry(fu(NFgColourConfigKey), _nfgColour);
+ c.writeEntry(fu(IconConfigKey), _icon);
+ c.writeEntry(fu(NewMailIconConfigKey), _nIcon);
+ c.writeEntry(fu(PassivePopupConfigKey), _passivePopup );
+ c.writeEntry(fu(PassiveDateConfigKey), _passiveDate );
+
+ return true;
+}
+
+QValueVector<KornMailSubject> * KMailDrop::doReadSubjects(bool * /*stop*/)
+{
+ return new QValueVector<KornMailSubject>(); // empty vector
+}
+
+QValueVector<KornMailSubject> * KMailDrop::readSubjects(bool * stop)
+{
+ // remember timer status
+ bool timerWasRunning = running();
+
+ // stop timer to avoid conflicts with reading mesage count
+ if (timerWasRunning)
+ stopMonitor();
+
+ // read the subjects
+ QValueVector<KornMailSubject> * result = doReadSubjects(stop);
+ int newcount = result->size();
+
+ // if the mail count has changed: notify the button!
+ if( newcount != count() && (!stop || !*stop) && synchrone() )
+ { //asynchrone connections don't have a list at this time
+ emit changed( newcount, this );
+ }
+
+ // if the timer was previously running, start it again
+ if (timerWasRunning)
+ startMonitor();
+ return result;
+}
+
+
+bool KMailDrop::deleteMails(QPtrList<const KornMailId> * /*ids*/, bool * /*stop*/)
+{
+ return false;
+}
+
+QString KMailDrop::readMail(const KornMailId * /*id*/, bool * /*stop*/)
+{
+ return "";
+}
+
+void KMailDrop::setCaption(QString s)
+{
+ _caption = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setClickCmd(QString s)
+{
+ _clickCmd = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setNewMailCmd(QString s)
+{
+ _nMailCmd = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setSoundFile(QString s)
+{
+ _soundFile = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setDisplayStyle(Style s)
+{
+ _style = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setBgColour(QColor c)
+{
+ _bgColour = c;
+ emit(configChanged());
+}
+
+void KMailDrop::setFgColour(QColor c)
+{
+ _fgColour = c;
+ emit(configChanged());
+}
+
+void KMailDrop::setNewBgColour(QColor c)
+{
+ _nbgColour = c;
+ emit(configChanged());
+}
+
+void KMailDrop::setNewFgColour(QColor c)
+{
+ _nfgColour = c;
+ emit(configChanged());
+}
+
+void KMailDrop::setIcon(QString s)
+{
+ _icon = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setNewIcon(QString s)
+{
+ _nIcon = s;
+ emit(configChanged());
+}
+
+void KMailDrop::setPassivePopup( bool pp )
+{
+ _passivePopup = pp;
+ emit(configChanged());
+}
+
+void KMailDrop::setPassiveDate( bool pd )
+{
+ _passiveDate = pd;
+ emit(configChanged());
+}
+
+void KMailDrop::setRealName(QString str)
+{
+ _realName = str;
+}
+
+#include "maildrop.moc"
diff --git a/korn/maildrop.h b/korn/maildrop.h
new file mode 100644
index 000000000..4bf8f0faa
--- /dev/null
+++ b/korn/maildrop.h
@@ -0,0 +1,456 @@
+/*
+* maildrop.h -- Declaration of class KMailDrop.
+* Generated by newclass on Sat Nov 29 20:07:45 EST 1997.
+*/
+#ifndef SSK_MAILDROP_H
+#define SSK_MAILDROP_H
+
+#include<qobject.h>
+#include<qstring.h>
+#include<qcolor.h>
+#include<qvaluevector.h>
+#include <qptrlist.h>
+
+class Protocol;
+
+class KConfigBase;
+class KConfigGroup;
+class KDropCfgDialog;
+class QColor;
+class KornMailSubject;
+class KornMailId;
+
+template< class T, class R > class QMap;
+
+/**
+* Abstract base class for all mailbox monitors.
+* @author Sirtaj Singh Kang (taj@kde.org)
+* @version $Id$
+*/
+class KMailDrop : public QObject
+{
+ Q_OBJECT
+
+ public:
+
+ enum Style { Plain, Colour, Icon };
+
+ private:
+
+ QString _caption;
+ QString _clickCmd;
+ QString _nMailCmd;
+ QString _soundFile;
+ Style _style;
+ QColor _bgColour;
+ QColor _fgColour;
+ QColor _nbgColour;
+ QColor _nfgColour;
+ QString _icon;
+ QString _nIcon;
+ int _lastCount;
+ QString _realName;
+ bool _passivePopup;
+ bool _passiveDate;
+
+ public:
+
+ static const char *TypeConfigKey;
+ static const char *CaptionConfigKey;
+ static const char *ClickConfigKey;
+ static const char *NewMailConfigKey;
+ static const char *SoundFileConfigKey;
+ static const char *DisplayStyleConfigKey;
+ static const char *NFgColourConfigKey;
+ static const char *NBgColourConfigKey;
+ static const char *FgColourConfigKey;
+ static const char *BgColourConfigKey;
+ static const char *IconConfigKey;
+ static const char *NewMailIconConfigKey;
+ static const char *ResetCounterConfigKey;
+ static const char *PassivePopupConfigKey;
+ static const char *PassiveDateConfigKey; //Enabled date in Passive popup
+ static const char *UseBoxSettingsConfigKey;
+ static const char *RealNameConfigKey;
+
+ /**
+ * KMailDrop Constructor
+ */
+ KMailDrop();
+
+ /**
+ * KMailDrop Destructor
+ */
+ virtual ~KMailDrop();
+
+ /**
+ * @return TRUE if the mailbox and its configuration are valid.
+ */
+ virtual bool valid() = 0;
+
+ /**
+ * Number of messages in the mailbox at the last count.
+ * @return The number of messages in the mailbox since last count.
+ */
+ int count() {return _lastCount;};
+
+ /**
+ * Recheck the number of letters in this mailbox. Raises the
+ * changed(int) signal if new mail is found.
+ *
+ * Concrete subclasses MUST reimplement this method.
+ */
+ virtual void recheck()=0;
+
+ /**
+ * Force a recheck
+ */
+ virtual void forceRecheck() { recheck(); }
+
+ /**
+ */
+ virtual bool startMonitor()=0;
+
+ /**
+ */
+ virtual bool stopMonitor()=0;
+
+ /**
+ * Check monitor run status.
+ * @return true if monitor is running.
+ */
+ virtual bool running()=0;
+
+ /**
+ * Add a configuration page to the configuration dialog.
+ * Each reimplementation should first call the inherited implementation,
+ * then call @ref KDropCfgDialog::addConfigPage with a custom
+ * @ref KMonitorCfg object.
+ */
+// virtual void addConfigPage( KDropCfgDialog * );
+
+ /**
+ * Returns a newly created KBoxFactory object initialized to
+ * be equivalent to this object (prototype pattern).
+ *
+ * Deletion of the returned object becomes the responsibility of
+ * the caller.
+ *
+ * Subclasses should override this to return objects of their
+ * own type.
+ */
+ virtual KMailDrop *clone() const = 0;
+
+ /**
+ * This function reads the settings which can be used by several
+ * accounts. These values can be overwritten by the readConfigGroup
+ * -function.
+ *
+ *@param cfg A configuration object with the group already
+ * set to the configuration for this box
+ */
+ virtual void readGeneralConfigGroup( const KConfigBase& cfg );
+
+ /**
+ * Read box configuration from a config group. Subclasses that
+ * reimplement this should call the overridden method.
+ *
+ * @param cfg A configuration object with the group already set to
+ * the configuration for this box.
+ * @return true if read was successful, false otherwise.
+ */
+ virtual bool readConfigGroup( const KConfigBase& cfg );
+ virtual bool readConfigGroup( const QMap< QString, QString > &, const Protocol * ) { return true; }
+
+ /**
+ * Write box configuration to a config group. Subclasses that
+ * reimplement this should call the overridden method.
+ *
+ * @param cfg A configuration object with the group already set to
+ * the configuration for this box.
+ * @return true if read was successful, false otherwise.
+ */
+ virtual bool writeConfigGroup( KConfigBase& cfg ) const;
+
+ /**
+ * Return the type of this monitor, for display and
+ * configuration purposes. Each concrete subclass should return a
+ * unique identifier.
+ */
+ virtual QString type() const = 0;
+
+ /**
+ * Return if the maildrop is synchrone (true) or asynchrone (false).
+ * This way, classes like KornSubjectDlg know if functions like
+ * readSubject() return a result immediately.
+ * @param true by a synchrone type; false by an asynchrone (like KKkioDrop) type.
+ */
+ virtual bool synchrone() const { return true; }
+
+ /**
+ * Return true if the concrete subclass can read the subjects of
+ * all new mails. This will enable the "Read Subjects" menu item.
+ */
+ virtual bool canReadSubjects() {return false;}
+
+ /**
+ * Read the subjects of all new mails.
+ * NOTE: the default implementation stops the timer, calls
+ * doReadSubjects, restarts the time if necessary and updates
+ * the displayed mail count. Concrete implementations should not
+ * touch readSubjects() but implement doReadSubjects() instead!
+ * @param stop: stop flag. If it is set to true during the execution,
+ * readSubjects shoulkd return as soon as possible. The return value
+ * is invalid in this case. If stop is 0, readSubjects will not
+ * terminate before all mail subjects are loaded.
+ * @return all new mails subjects as a vector.
+ */
+ virtual QValueVector<KornMailSubject> * readSubjects(bool * stop);
+
+ /**
+ * Read the subjects of all new mails. The concrete subclass has
+ * to implement it, if canReadSubjects() returns true.
+ * @param stop: stop flag. If it is set to true during the execution,
+ * readSubjects should return as soon as possible. The return value
+ * is invalid in this case. If stop is 0, readSubjects will not
+ * terminate before all mail subjects are loaded.
+ * @return all new mails subjects as a vector.
+ */
+ virtual QValueVector<KornMailSubject> * doReadSubjects(bool * stop);
+
+ /**
+ * Return true if the concrete subclass can delete individual mails.
+ * This will enable the "Delete" button in the mail subjects dialog.
+ */
+ virtual bool canDeleteMails() {return false;}
+
+ /**
+ * Delete some mails in the mailbox. The concrete subclass has
+ * to implement it, if canDeleteMails() returns true.
+ * @param ids list of mail ids to delete. The ids are taken from
+ * the corresponding KornMailSubject instances returned by a previous
+ * call to doReadSubjects().
+ * @param stop: stop flag. If it is set to true during the execution,
+ * deleteMails() should return as soon as possible. The return value
+ * is invalid in this case. If stop is 0, deleteMails() will not
+ * terminate before the mails are deleted.
+ * @return true, if the mail ids of the remaining mails might have changed.
+ * The corresponding KornMailSubject instances returned by a previous
+ * call to doReadSubjects() have to be discarded and readSubjects() must
+ * be called again to get the correct mail ids. If false is returned,
+ * the KornMailSubject instances of the remaining mails might be used
+ * further more.
+ */
+ virtual bool deleteMails(QPtrList<const KornMailId> * ids, bool * stop);
+
+ /**
+ * Return true if the concrete subclass can load individual mails fully.
+ * This will enable the "Full Message" button in the mail dialog.
+ */
+ virtual bool canReadMail() {return false;}
+
+ /**
+ * Load a mail from the mailbox fulle . The concrete subclass has
+ * to implement it, if deleteMails() returns true.
+ * @param id id of the mail to load. The id is taken from the corresponding
+ * KornMailSubject instances returned by a previous call to doReadSubjects().
+ * @param stop: stop flag. If it is set to true during the execution,
+ * readMail() should return as soon as possible. The return value
+ * is invalid in this case. If stop is 0, readMail() will not
+ * terminate before the mail is loaded.
+ * @return the fully loaded mail (header and body) or "" on error.
+ */
+ virtual QString readMail(const KornMailId * id, bool * stop);
+
+ // data that belongs in every monitor
+
+ QString caption() const { return _caption; }
+ QString clickCmd() const { return _clickCmd; }
+ QString newMailCmd() const { return _nMailCmd; }
+ QString soundFile() const { return _soundFile;}
+ QColor bgColour() const { return _bgColour; }
+ QColor fgColour() const { return _fgColour; }
+ QColor newBgColour() const { return _nbgColour; }
+ QColor newFgColour() const { return _nfgColour; }
+ QString icon() const { return _icon; }
+ QString newIcon() const { return _nIcon; }
+ Style displayStyle() const { return _style; }
+ bool passivePopup() const { return _passivePopup; }
+ bool passiveDate() const { return _passiveDate; }
+ QString realName() const { return _realName; }
+;
+ void setCaption(QString);
+ void setClickCmd(QString);
+ void setNewMailCmd(QString);
+ void setSoundFile(QString);
+ void setDisplayStyle(Style);
+ void setBgColour(QColor);
+ void setFgColour(QColor);
+ void setNewBgColour(QColor);
+ void setNewFgColour(QColor);
+ void setIcon(QString);
+ void setNewIcon(QString);
+ void setResetCounter(int);
+ void setPassivePopup(bool);
+ void setPassiveDate(bool);
+ void setRealName(QString);
+
+ /**
+ * This is called by the manager when it wishes to delete
+ * a monitor. Clients should connect to the @ref ::notifyDisconnect
+ * signal and ensure that the monitor is not accessed after
+ * the signal has been received.
+ *
+ * Reimplementations should call this implementation too.
+ */
+ virtual void notifyClients();
+
+ public slots:
+
+ /**
+ * Forcibly set the count to zero;
+ */
+ virtual void forceCountZero();
+
+ /*
+ * The next slots are used by kio; the present at this places
+ * prevent warnings at runtime.
+ */
+ virtual void readSubjectsCanceled() {}
+ virtual void readMailCanceled() {}
+ virtual void deleteMailsCanceled() {}
+
+ protected slots:
+
+ void setCount( int, KMailDrop* );
+
+signals:
+
+ /**
+ * This signal is emitted when the mailbox discovers
+ * new messages in the maildrop.
+ */
+ void changed( int, KMailDrop* );
+
+ /**
+ * This signal is emitted when the valid-status changes.
+ * @param isValid true then and only then if the box is valid
+ */
+ void validChanged( bool isValid );
+
+ /**
+ * This is emitted on configuration change, normally
+ * on an updateConfig() but
+ */
+ void configChanged();
+
+ /**
+ * Clients should connect to this and discontinue use
+ * after it is emitted.
+ */
+ void notifyDisconnect();
+
+ /**
+ * rechecked() is called if an asynchrone maildrop has
+ * rechecked the availability of email.
+ */
+ void rechecked();
+
+ /**
+ * The next signal is emitted when a passive popup could be displayed.
+ * As argument, there is a KornSubject, which contains a subject and
+ * some more info that could be used with the popup.
+ */
+ void showPassivePopup( QPtrList< KornMailSubject >*, int, bool, const QString& realname );
+
+ /**
+ * This signal is emitted when a passive error message should be displayed.
+ *
+ * @param error The error message
+ * @param realName The real name of this object.
+ */
+ void showPassivePopup( const QString& error, const QString& realname );
+
+ /**
+ * readSubjects() might signal readSubject() if
+ * an subject is received. This is only useful in
+ * asynchrone situations.
+ * @param the subject structure which is read
+ */
+ void readSubject( KornMailSubject * );
+
+ /**
+ * readSubjects() might signal readSubjectsTotalSteps() to
+ * send the expected total number of steps to a possible
+ * progress bar. See readSubjectsProgress();
+ * @param totalSteps expected total number of steps.
+ */
+ void readSubjectsTotalSteps(int totalSteps);
+
+ /**
+ * readSubjects() might signal readSubjectsProgress() to
+ * send the current progress in relation to the
+ * expected total number of steps (see readSubjectsTotalSteps()).
+ * @param curent progress.
+ */
+ void readSubjectsProgress(int progress);
+
+ /**
+ * readSubjects() might signal readSubjectsReady() to
+ * remove the progress bar in asynchrone situations.
+ * @param: true if succes, false if cancelled
+ */
+ void readSubjectsReady( bool success );
+
+ /**
+ * deleteMails() might signal deleteMailsTotalSteps() to
+ * send the expected total number of steps to a possible
+ * progress bar. See deleteMailsProgress();
+ * @param totalSteps expected total number of steps.
+ */
+ void deleteMailsTotalSteps(int totalSteps);
+
+ /**
+ * deleteMails() might signal deleteMailsProgress() to
+ * send the current progress in relation to the
+ * expected total number of steps (see deleteMailsTotalSteps()).
+ * @param curent progress.
+ */
+ void deleteMailsProgress(int progress);
+
+ /**
+ * deleteMails() might signal deleteMailsReady() if
+ * it is not going to do something anyway.
+ * This could be the case when an email has been succesfully
+ * removed, or when the deletions failed. This is useful
+ * in asynchrone situations.
+ * @param: true if deletion was succesful; elsewise false.
+ */
+ void deleteMailsReady( bool );
+
+ /**
+ * readMail() might signal readMailTotalSteps() to
+ * send the expected total number of steps to a possible
+ * progress bar. See readMailProgress();
+ * @param totalSteps expected total number of steps.
+ */
+ void readMailTotalSteps(int totalSteps);
+
+ /**
+ * readMail() might signal readMailProgress() to
+ * send the current progress in relation to the
+ * expected total number of steps (see readMailTotalSteps()).
+ * @param curent progress.
+ */
+ void readMailProgress(int progress);
+
+ /**
+ * readMail() might signal readMailReady() if
+ * a email is totally read. This is useful
+ * in asynchrone situations.
+ * @param pointer to the full email-message.
+ */
+ void readMailReady( QString* );
+};
+
+#endif // SSK_MAILDROP_H
diff --git a/korn/mailid.cpp b/korn/mailid.cpp
new file mode 100644
index 000000000..a4822024c
--- /dev/null
+++ b/korn/mailid.cpp
@@ -0,0 +1,5 @@
+#include "mailid.h"
+
+KornMailId::~KornMailId()
+{
+}
diff --git a/korn/mailid.h b/korn/mailid.h
new file mode 100644
index 000000000..d640bfe7f
--- /dev/null
+++ b/korn/mailid.h
@@ -0,0 +1,33 @@
+#ifndef MailId_h
+#define MailId_h
+
+#include <qstring.h>
+
+/**
+ * Abstract base class for mail ids. Concrete mail ids store the id.
+ * Its sole purpose is to treat all possible mail id format in a unique
+ * way (by inheritence).
+ */
+class KornMailId
+{
+public:
+ /**
+ * KornMailId Destructor
+ */
+ virtual ~KornMailId();
+
+ /**
+ * Return a string representation of this (for debuggin purposes only)
+ * @return a string representation
+ */
+ virtual QString toString() const = 0;
+
+ /**
+ * Create an exact copy of this.
+ * @return the cloned object
+ */
+ virtual KornMailId * clone() const = 0;
+};
+
+
+#endif
diff --git a/korn/mailsubject.cpp b/korn/mailsubject.cpp
new file mode 100644
index 000000000..1f2011a02
--- /dev/null
+++ b/korn/mailsubject.cpp
@@ -0,0 +1,189 @@
+#include"mailsubject.h"
+
+#include <kmime_codecs.h>
+#include <kcharsets.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <qdatetime.h>
+#include <qtextcodec.h>
+#include <ctype.h>
+
+KornMailSubject::KornMailSubject() : _id(0), _drop(0), _size(-1), _date(-1), _fullMessage(false)
+{
+}
+
+KornMailSubject::KornMailSubject(KornMailId * id, KMailDrop *drop)
+ : _id(id), _drop( drop ), _size(-1), _date(-1), _fullMessage(false)
+{
+}
+
+KornMailSubject::KornMailSubject(const KornMailSubject & src)
+ : _id(0), _drop(0), _size(-1), _date(-1)
+{
+ operator=(src);
+}
+
+KornMailSubject & KornMailSubject::operator= (const KornMailSubject & src)
+{
+ _size = src._size;
+ _date = src._date;
+ _subject = src._subject;
+ _sender = src._sender;
+ _header = src._header;
+ _fullMessage = src._fullMessage;
+ if (_id)
+ delete _id;
+ _id = 0;
+ if (src._id)
+ _id = src._id->clone();
+ _drop = src._drop;
+ return *this;
+}
+
+KornMailSubject::~KornMailSubject()
+{
+ if (_id)
+ delete _id;
+ _id = 0;
+}
+
+QString KornMailSubject::toString() const
+{
+ QDateTime date;
+ date.setTime_t(_date);
+ return QString("KornMailSubject, Id: ") + (_id?_id->toString():QString("NULL")) + ", " + i18n("Subject:") + " " + _subject
+ + ", " + i18n("Sender:") + " " + _sender + ", " + i18n("Size:") + " " + QString::number(_size)
+ + ", " + i18n("Date:") + " " + date.toString(Qt::ISODate);
+}
+
+QString KornMailSubject::decodeRFC2047String(const QCString& aStr)
+{
+ if ( aStr.isEmpty() )
+ return QString::null;
+
+ const QCString str = unfold( aStr );
+
+ if ( str.isEmpty() )
+ return QString::null;
+
+ if ( str.find( "=?" ) < 0 ) {
+ // No need to decode
+ return QString(str);
+ }
+
+ QString result;
+ QCString LWSP_buffer;
+ bool lastWasEncodedWord = false;
+
+ for ( const char * pos = str.data() ; *pos ; ++pos ) {
+ // collect LWSP after encoded-words,
+ // because we might need to throw it out
+ // (when the next word is an encoded-word)
+ if ( lastWasEncodedWord && isBlank( pos[0] ) ) {
+ LWSP_buffer += pos[0];
+ continue;
+ }
+ // verbatimly copy normal text
+ if (pos[0]!='=' || pos[1]!='?') {
+ result += LWSP_buffer + pos[0];
+ LWSP_buffer = 0;
+ lastWasEncodedWord = false;
+ continue;
+ }
+ // found possible encoded-word
+ const char * const beg = pos;
+ {
+ // parse charset name
+ QCString charset;
+ int i = 2;
+ pos += 2;
+ for ( ; *pos != '?' && ( *pos==' ' || ispunct(*pos) || isalnum(*pos) ); ++i, ++pos ) {
+ charset += *pos;
+ }
+ if ( *pos!='?' || i<4 )
+ goto invalid_encoded_word;
+
+ // get encoding and check delimiting question marks
+ const char encoding[2] = { pos[1], '\0' };
+ if (pos[2]!='?' || (encoding[0]!='Q' && encoding[0]!='q' &&
+ encoding[0]!='B' && encoding[0]!='b'))
+ goto invalid_encoded_word;
+ pos+=3; i+=3; // skip ?x?
+ const char * enc_start = pos;
+ // search for end of encoded part
+ while ( *pos && !(*pos=='?' && *(pos+1)=='=') ) {
+ i++;
+ pos++;
+ }
+ if ( !*pos )
+ goto invalid_encoded_word;
+
+ // valid encoding: decode and throw away separating LWSP
+ const KMime::Codec * c = KMime::Codec::codecForName( encoding );
+ kdFatal( !c ) << "No \"" << encoding << "\" codec!?" << endl;
+
+ QByteArray in; in.setRawData( enc_start, pos - enc_start );
+ const QByteArray enc = c->decode( in );
+ in.resetRawData( enc_start, pos - enc_start );
+
+ const QTextCodec * codec = codecForName(charset);
+ if (!codec) return QString::null;
+ result += codec->toUnicode(enc);
+ lastWasEncodedWord = true;
+
+ ++pos; // eat '?' (for loop eats '=')
+ LWSP_buffer = 0;
+ }
+ continue;
+invalid_encoded_word:
+ // invalid encoding, keep separating LWSP.
+ pos = beg;
+ if ( !LWSP_buffer.isNull() )
+ result += LWSP_buffer;
+ result += "=?";
+ lastWasEncodedWord = false;
+ ++pos; // eat '?' (for loop eats '=')
+ LWSP_buffer = 0;
+ }
+ return result;
+}
+
+QCString KornMailSubject::unfold( const QCString & header )
+{
+ if ( header.isEmpty() )
+ return QCString();
+
+ QCString result( header.size() ); // size() >= length()+1 and size() is O(1)
+ char * d = result.data();
+
+ for ( const char * s = header.data() ; *s ; )
+ if ( *s == '\r' ) { // ignore
+ ++s;
+ continue;
+ } else if ( *s == '\n' ) { // unfold
+ while ( this->isBlank( *++s ) );
+ *d++ = ' ';
+ } else
+ *d++ = *s++;
+
+ *d++ = '\0';
+
+ result.truncate( d - result.data() );
+ return result;
+}
+
+//-----------------------------------------------------------------------------
+const QTextCodec* KornMailSubject::codecForName(const QCString& _str)
+{
+ if (_str.isEmpty()) return 0;
+ QCString codec = _str;
+ return KGlobal::charsets()->codecForName(codec);
+}
+
+void KornMailSubject::decodeHeaders()
+{
+ _subject = decodeRFC2047String( _subject.latin1() );
+ _sender = decodeRFC2047String( _sender.latin1() );
+}
+
diff --git a/korn/mailsubject.h b/korn/mailsubject.h
new file mode 100644
index 000000000..f3e2e4577
--- /dev/null
+++ b/korn/mailsubject.h
@@ -0,0 +1,187 @@
+#ifndef MailSubject_h
+#define MailSubject_h
+
+class QTextCodec;
+
+class KMailDrop;
+
+#include "mailid.h"
+
+
+
+/**
+ * A KornMailSubject instance represents a single mail. It stores
+ * its id, sender, subject, header, size and date and possibly its
+ * mail body
+ */
+class KornMailSubject
+{
+ KornMailId * _id;
+ KMailDrop * _drop;
+ QString _subject;
+ QString _sender;
+ QString _header;
+ int _size;
+ int _date;
+ bool _fullMessage;
+public:
+ /**
+ * KornMailSubject default constructor
+ */
+ KornMailSubject();
+
+ /**
+ * KornMailSubject constructor
+ * @param id id of the mail. The KornMailId instance should
+ * not be touched or deleted afterwards. It is destroyed by
+ * KornMailSubject's destructor.
+ * @param drop The KMailDrop.
+ */
+ KornMailSubject(KornMailId * id, KMailDrop * drop);
+
+ /**
+ * KornMailSubject copy constructor. All data of the source
+ * KornMailSubject instance are cloned.
+ * @param src KornMailSubject to copy from
+ */
+ KornMailSubject(const KornMailSubject & src);
+
+ /**
+ * replaces the contents of this by the contents of another
+ * KornMailSubject instance. All data of the source
+ * KornMailSubject instance are cloned.
+ * @param src KornMailSubject to copy from
+ */
+ KornMailSubject & operator= (const KornMailSubject & src);
+
+ /**
+ * KornMailSubject destructor
+ */
+ virtual ~KornMailSubject();
+
+ /**
+ * Return the mail id.
+ * @return the mail id.
+ */
+ const KornMailId * getId() const {return _id;}
+
+ /**
+ * Set the mails subject.
+ * @param subject the mails subject.
+ */
+ void setSubject(const QString & subject) {_subject = subject;}
+
+ /**
+ * Return the subject.
+ * @return the subject.
+ */
+ const QString & getSubject() const {return _subject;}
+
+ /**
+ * Set the mails sender.
+ * @param sender the mails sender.
+ */
+ void setSender(const QString & sender) {_sender = sender;}
+
+ /**
+ * Return the sender.
+ * @return the sender.
+ */
+ const QString & getSender() const {return _sender;}
+
+ /**
+ * Set the mails header and (if possible) body.
+ * @param header the mails header with or without body (see fullMessage parameter).
+ * @param fullMessage true, if header contains the message body as well, false otherwise.
+ */
+ void setHeader(const QString & header, bool fullMessage) {_header = header; _fullMessage = fullMessage;}
+
+ /**
+ * Return the header or the full message (if isHeaderFullMessage() is true).
+ * @return the header or the full message.
+ */
+ const QString & getHeader() const {return _header;}
+
+ /**
+ * Return true, if the header contains the header and the full message.
+ * Return false if the header just contains the header.
+ * @return see above.
+ */
+ bool isHeaderFullMessage() const {return _fullMessage;}
+
+ /**
+ * Set the size of the full mail.
+ * @param the mails full size.
+ */
+ void setSize(int size) {_size = size;}
+
+ /**
+ * Return the size of the full mail.
+ * @return the size of the full mail.
+ */
+ int getSize() const {return _size;}
+
+ /**
+ * Set the mails date in seconds since 1970-01-01 00:00:00.
+ * @param date the mails date.
+ */
+ void setDate(int date) {_date = date;}
+
+ /**
+ * Return the mails date in seconds since 1970-01-01 00:00:00.
+ * @return the mails date.
+ */
+ int getDate() const {return _date;}
+
+ /**
+ * Return a string representation of this (for debugging purposes only)
+ * @return a string representation
+ */
+ QString toString() const;
+
+ /**
+ * Sets the KMailDrop field.
+ * @param drop The KMailDrop-object
+ */
+ void setMailDrop( KMailDrop* drop ) { _drop = drop; }
+
+ /**
+ * Returns the KMailDrop instance of the Maildrop which owns the subject
+ */
+ KMailDrop* getMailDrop() const { return _drop; }
+
+ /**
+ * decodes headers using decodeRFC2047String
+ */
+ void decodeHeaders();
+
+private:
+
+ /**
+ * Decode a string based on RFC2047
+ */
+ QString decodeRFC2047String(const QCString& aStr);
+
+ /**
+ * Unfolding a string (basically changing tabs to spaces
+ */
+ QCString unfold( const QCString & header );
+
+ /**
+ * Returns true if the parameter is a blank (or tab)
+ *
+ * Note from KMail's code, where this function is taken from:
+ * don't rely on isblank(), which is a GNU extension in
+ * <cctype>. But if someone wants to write a configure test for
+ * isblank(), we can then rename this function to isblank and #ifdef
+ * it's definition...
+ */
+ inline bool isBlank( char ch ) { return ch == ' ' || ch == '\t' ; }
+
+ /**
+ * ??
+ */
+ const QTextCodec* codecForName(const QCString& _str);
+};
+
+#endif
diff --git a/korn/main.cpp b/korn/main.cpp
new file mode 100644
index 000000000..97a79441c
--- /dev/null
+++ b/korn/main.cpp
@@ -0,0 +1,53 @@
+/*
+ * (C) 1999, 2000 Sirtaj Singh Kang <taj@kde.org>
+ * (C) 2000 Rik Hemsley <rik@kde.org>
+ */
+
+#include"kornapp.h"
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+#include"kornshell.h"
+
+static const char description[] = I18N_NOOP("KDE mail checker");
+static const char version[] = "0.4";
+
+
+int main(int argc, char *argv[])
+{
+ KAboutData aboutData(argv[0], I18N_NOOP("Korn"),
+ version, description, KAboutData::License_GPL,
+ I18N_NOOP("(c) 1999-2004, The Korn Developers"));
+ aboutData.addAuthor("Sirtaj Singh Kang",0, "taj@kde.org");
+ aboutData.addAuthor("Cristian Tibirna",0, "tibirna@kde.org");
+ aboutData.addAuthor("Kurt Granroth",0, "granroth@kde.org");
+ aboutData.addAuthor("Rik Hemsley",0, "rik@kde.org");
+ aboutData.addAuthor("Fixes by Jörg Habenicht",0, "j.habenicht@europemail.com");
+ aboutData.addAuthor("Preview by Heiner Eichmann",0, "h.eichmann@gmx.de");
+ aboutData.addAuthor("Mart Kelder",0,"mart@kelder31.nl");
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KUniqueApplication::addCmdLineOptions();
+
+ if( !KUniqueApplication::start() ) {
+ // Already running. Should pop up the preferences dialog
+ return 0;
+ }
+
+ KornApp *app = new KornApp();
+ KornShell *korn = new KornShell( 0, "shell" );
+ app->setShell( korn );
+
+ //app->enableSessionManagement( true );
+
+ //if( korn->init() ) {
+ korn->show();
+ app->exec();
+ //}
+
+ delete korn;
+ delete app;
+
+ return 0;
+}
diff --git a/korn/mbox_proto.cpp b/korn/mbox_proto.cpp
new file mode 100644
index 000000000..5ee327114
--- /dev/null
+++ b/korn/mbox_proto.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "mbox_proto.h"
+
+#include <kdebug.h>
+
+#include <qlayout.h>
+#include <qptrvector.h>
+#include <qstringlist.h>
+
+#include "account_input.h"
+
+void MBox_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "mbox" );
+}
+
+void MBox_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput > *result ) const
+{
+ result->append( new URLInput( (QWidget*)vector->at( 0 ), i18n( "File:" ), "", "mailbox" ) );
+}
+
+void MBox_Protocol::readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const
+{
+}
+
+void MBox_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ clearFields( map, (KIO_Protocol::Fields)( server | port | username | password | save_password | metadata ) );
+}
diff --git a/korn/mbox_proto.h b/korn/mbox_proto.h
new file mode 100644
index 000000000..d33ff8944
--- /dev/null
+++ b/korn/mbox_proto.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_MBOX_PROTO_H
+#define MK_MBOX_PROTO_H
+
+#include "kio_proto.h"
+
+/*
+ * Protocol for mbox
+ */
+class MBox_Protocol : public KIO_Protocol
+{
+public:
+ MBox_Protocol() {}
+ virtual ~MBox_Protocol() {}
+
+ virtual QString protocol( bool ) const { return "mbox"; }
+ virtual QString configName() const { return "mbox"; }
+
+ virtual bool canReadSubjects() const { return true; }
+ virtual bool canDeleteMail() const { return false; }
+ virtual bool canReadMail() const { return true; }
+ virtual bool fullMessage() const { return true; }
+
+ //virtual int fields() const { return no_fields; }
+ //virtual int urlFields() const { return mailbox; }
+
+ virtual QString mailboxName() const { return i18n( "File:" ); }
+
+ virtual void recheckKURL( KURL &, KIO::MetaData & md ) const
+ { md.insert( "onlynew", "" ); md.insert( "savetime", "" ); }
+ virtual void readSubjectKURL( KURL &, KIO::MetaData & ) const { }
+ virtual void deleteMailKURL( KURL &, KIO::MetaData & ) const { }
+ virtual void readMailKURL( KURL &, KIO::MetaData & ) const { }
+
+ virtual void configFillGroupBoxes( QStringList* ) const;
+ virtual void configFields( QPtrVector< QWidget >*, const QObject*, QPtrList< AccountInput >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const;
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+};
+
+#endif
diff --git a/korn/nntp_proto.cpp b/korn/nntp_proto.cpp
new file mode 100644
index 000000000..532ac47a9
--- /dev/null
+++ b/korn/nntp_proto.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "nntp_proto.h"
+
+#include "account_input.h"
+
+#include <qwidget.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qptrvector.h>
+#include <qptrlist.h>
+
+void Nntp_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "server" );
+ groupBoxes->append( "user" );
+}
+
+void Nntp_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput > * result ) const
+{
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Server" ), TextInput::text, "", "server" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Port" ), 0, 65535, "119", "port" ) );
+
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Username" ), TextInput::text, "", "username" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Password" ), TextInput::password, "", "password" ) );
+ result->append( new CheckboxInput( (QWidget*)vector->at( 1 ), i18n( "Save password" ), "true", "savepassword" ) );
+ QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( toggled( bool ) ),
+ (QObject*)result->prev()->rightWidget(), SLOT( setEnabled( bool ) ) );
+ result->last()->setValue( "false" );
+}
+
+void Nntp_Protocol::readEntries( QMap< QString, QString >*, QMap< QString, QString > * ) const
+{
+}
+
+void Nntp_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ clearFields( map, (KIO_Protocol::Fields)( KIO_Protocol::mailbox | KIO_Protocol::metadata ) );
+}
+
diff --git a/korn/nntp_proto.h b/korn/nntp_proto.h
new file mode 100644
index 000000000..c32a50b6d
--- /dev/null
+++ b/korn/nntp_proto.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_NNTP_PROTO_H
+#define MK_NNTP_PROTO_H
+
+#include "kio_proto.h"
+
+class Nntp_Protocol : public KIO_Protocol
+{
+public:
+ Nntp_Protocol() { }
+ virtual ~Nntp_Protocol() { }
+
+ virtual KIO_Protocol * clone() const { return new Nntp_Protocol; }
+
+ virtual bool connectionBased() const { return true; }
+
+ virtual QString protocol() const { return "nntp"; }
+ virtual QString configName() const { return "nntp"; }
+
+ virtual bool canReadSubjects() const { return true; }
+ virtual bool canDeleteMail() const { return false; }
+ virtual bool canReadMail() const { return true; }
+ virtual bool fullMessage() const { return true; }
+
+ //virtual int fields() const { return server | port | username | password | mailbox; }
+ //virtual int urlFields() const { return no_fields; }
+ virtual unsigned short defaultPort( bool ) const { return 119; }
+
+ virtual void configFillGroupBoxes( QStringList* ) const;
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const;
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+};
+
+#endif
diff --git a/korn/password.cpp b/korn/password.cpp
new file mode 100644
index 000000000..a3eb76ed9
--- /dev/null
+++ b/korn/password.cpp
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "password.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kwallet.h>
+
+#include <qstring.h>
+#include <qstringlist.h>
+
+KWallet::Wallet* KOrnPassword::m_wallet = 0;
+bool KOrnPassword::m_openFailed = false;
+bool KOrnPassword::m_useWallet = false; //Not default true until moving works
+
+QString KOrnPassword::readKOrnPassword( int box, int account, const KConfigBase &fallbackConfig )
+{
+ QString result;
+
+ if( readKOrnPassword( box, account, result ) )
+ return result;
+ else
+ return fallbackConfig.readEntry( "password" );
+}
+
+QString KOrnPassword::readKMailPassword( int accountnr, const KConfigBase& fallbackConfig )
+{
+ QString password;
+ open();
+
+ if( !m_wallet || !m_wallet->isOpen() || m_openFailed )
+ return KMailDecrypt( fallbackConfig.readEntry( "pass" ) );
+
+ if( !m_wallet->hasFolder( "kmail" ) )
+ return KMailDecrypt( fallbackConfig.readEntry( "pass" ));
+ m_wallet->setFolder( "kmail" );
+
+ if( m_wallet->readPassword( QString( "account-%1" ).arg( accountnr ), password ) != 0 )
+ return fallbackConfig.readEntry( "password" );
+
+ return password;
+}
+
+void KOrnPassword::writeKOrnPassword( int box, int account, KConfigBase& fallbackConfig, const QString& password )
+{
+ if( writeKOrnPassword( box, account, password ) )
+ {
+ if( fallbackConfig.hasKey( "password" ) )
+ fallbackConfig.deleteEntry( "password" );
+ }
+ else
+ fallbackConfig.writeEntry( "password", password );
+}
+
+void KOrnPassword::deleteKOrnPassword( int box, int account, KConfigBase& fallbackConfig )
+{
+ deleteKOrnPassword( box, account );
+ if( fallbackConfig.hasKey( "password" ) )
+ fallbackConfig.deleteEntry( "password" );
+}
+
+bool KOrnPassword::deleteKOrnPassword( int box, int account )
+{
+ if( !m_useWallet )
+ //Wallet should not be used => saving in config file
+ return false;
+
+ //Open wallet
+ open();
+
+ if( !m_wallet || !m_wallet->isOpen() || m_openFailed )
+ //Opening failed => delete in config file
+ return false;
+
+ //Make folder for KOrn if needed
+ if( !m_wallet->hasFolder( "korn" ) )
+ return false; //It does not exist
+ m_wallet->setFolder( "korn" );
+
+ //Write to wallet
+ if( m_wallet->removeEntry( QString( "account-%1-%2" ).arg( box ).arg( account ) ) != 0 )
+ //Writing failed
+ return false;
+
+ //Password succesfully stored in the configuration.
+ return true;
+}
+
+void KOrnPassword::moveKOrnPassword( int boxSrc, int accountSrc, KConfigBase& configSrc,
+ int boxDest, int accountDest, KConfigBase &configDest )
+{
+ QString password;
+
+ password = readKOrnPassword( boxSrc, accountSrc, configSrc );
+ deleteKOrnPassword( boxSrc, accountSrc, configSrc );
+ writeKOrnPassword( boxDest, accountDest, configDest, password );
+}
+
+void KOrnPassword::swapKOrnPassword( int box1, int account1, KConfigBase &config1, int box2, int account2, KConfigBase &config2 )
+{
+ QString password1, password2;
+ password1 = readKOrnPassword( box1, account1, config1 );
+ password2 = readKOrnPassword( box2, account2, config2 );
+ deleteKOrnPassword( box1, account1, config1 );
+ deleteKOrnPassword( box2, account2, config2 );
+ writeKOrnPassword( box1, account1, config1, password2 );
+ writeKOrnPassword( box2, account2, config2, password1 );
+}
+
+void KOrnPassword::swapKOrnWalletPassword( int box1, int account1, int box2, int account2 )
+{
+ QString password1, password2;
+ bool passExist1, passExist2;
+ passExist1 = readKOrnPassword( box1, account1, password1 );
+ passExist2 = readKOrnPassword( box2, account2, password2 );
+
+ if( passExist1 )
+ deleteKOrnPassword( box1, account1 );
+ if( passExist2 )
+ deleteKOrnPassword( box2, account2 );
+
+ if( passExist1 )
+ writeKOrnPassword( box2, account2, password1 );
+ if( passExist2 )
+ writeKOrnPassword( box1, account1, password2 );
+}
+
+void KOrnPassword::swapKOrnWalletPasswords( int box1, int accountnumber1 ,int box2, int accountnumber2 )
+{
+ int max = accountnumber1 > accountnumber2 ? accountnumber1 : accountnumber2;
+ for( int xx = 0; xx < max; ++xx )
+ swapKOrnWalletPassword( box1, xx, box2, xx );
+}
+
+void KOrnPassword::rewritePassword( int box, int account, KConfigBase &config, bool newUseWalletValue )
+{
+ bool useWallet = m_useWallet;
+ QString password;
+
+ setUseWallet( !newUseWalletValue );
+ password = readKOrnPassword( box, account, config );
+ deleteKOrnPassword( box, account, config );
+
+ setUseWallet( newUseWalletValue );
+ writeKOrnPassword( box, account, config, password );
+
+ setUseWallet( useWallet );
+}
+
+void KOrnPassword::setUseWallet( const bool value )
+{
+ m_useWallet = value;
+}
+
+void KOrnPassword::open()
+{
+ if( m_wallet && m_wallet->isOpen() )
+ return; //Already open
+
+ if( m_openFailed )
+ return; //Not open, and can't be opened
+
+ delete m_wallet; m_wallet = 0;
+ m_wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0 );
+
+ if( !m_wallet )
+ m_openFailed = true;
+}
+
+bool KOrnPassword::readKOrnPassword( int box, int account, QString& password )
+{
+ if( !m_useWallet )
+ return false;
+
+ //Otherwise: try to open the wallet
+ open();
+
+ if( !m_wallet || !m_wallet->isOpen() || m_openFailed )
+ //Opening failed: getting value out of config if it exists there
+ return false;
+
+ if( !m_wallet->hasFolder( "korn" ) )
+ //No folder korn exist, so no password stored in the wallet.
+ return false;
+ m_wallet->setFolder( "korn" );
+
+ if( m_wallet->readPassword( QString( "account-%1-%2" ).arg( box ).arg( account ), password ) != 0 )
+ //Error during reading the password: use the one in the config file
+ return false;
+
+ //Reading completed: returning
+ return true;
+}
+
+bool KOrnPassword::writeKOrnPassword( int box, int account, const QString& password )
+{
+ if( !m_useWallet )
+ //Wallet should not be used => saving in the config file
+ return false;
+
+ //Open wallet
+ open();
+
+ if( !m_wallet || !m_wallet->isOpen() || m_openFailed )
+ //Opening failed => write to configfile
+ return false;
+
+ //Make folder for KOrn if needed
+ if( !m_wallet->hasFolder( "korn" ) )
+ m_wallet->createFolder( "korn" );
+ m_wallet->setFolder( "korn" );
+
+ //Write to wallet
+ if( m_wallet->writePassword( QString( "account-%1-%2" ).arg( box ).arg( account ), password ) != 0 )
+ //Writing failed
+ return false;
+
+ //Password succesfully stored in the configuration.
+ return true;
+}
+
+//This function is copyed from kmail/kmaccount.cpp
+QString KOrnPassword::KMailDecrypt( const QString& enc )
+{
+ QString result;
+ for (uint i = 0; i < enc.length(); i++)
+ result += (enc[i].unicode() <= 0x21) ? enc[i] : QChar(0x1001F - enc[i].unicode());
+
+ return result;
+}
diff --git a/korn/password.h b/korn/password.h
new file mode 100644
index 000000000..b024fa842
--- /dev/null
+++ b/korn/password.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 KORNPASSWORD_H
+#define KORNPASSWORD_H
+
+class KConfigBase;
+namespace KWallet { class Wallet; }
+
+class QString;
+
+/**
+ * This class can be used to store and retrieve passwords.
+ * It uses KWallet if possible, and the configuartion files otherwise.
+ */
+class KOrnPassword
+{
+public:
+ /**
+ * Constructor: empty
+ */
+ KOrnPassword();
+ /**
+ * Destructor: empty
+ */
+ ~KOrnPassword();
+
+ /**
+ * This function gets a password for KOrn.
+ *
+ * @param box The boxnumber of the account
+ * @param account The accountnumber of the account
+ * @param fallbackConfig The configuration file if KWallet cannot be used.
+ * @return The password, or QString::null if it failes.
+ */
+ static QString readKOrnPassword( int box, int account, const KConfigBase& fallbackConfig );
+ /**
+ * This function gets a password with is puts in KWallet by KMail
+ *
+ * @param accountnr The id of the KMail account
+ * @param fallbackConfig The configuration used if KWallet isn't available.
+ * @return The password, QStirng::null if it failes.
+ */
+ static QString readKMailPassword( int accountnr, const KConfigBase& fallbackConfig );
+
+ /**
+ * This function saves a password for usage in KOrn.
+ *
+ * @param box The boxnumber of the account.
+ * @param account The accountnumber of the account.
+ * @param fallbackConfig The configuration file if KWallet isn't available.
+ * @param password The password to be stored.
+ */
+ static void writeKOrnPassword( int box, int account, KConfigBase& fallbackConfig, const QString& password );
+
+ /**
+ * This function deletes a password from both KWallet and the configuration file
+ *
+ * @param box The boxnumber of the account.
+ * @param account The accountnumber of the account.
+ * @param fallbackConfig The configuration file if KWallet isn't available.
+ */
+ static void deleteKOrnPassword( int box, int account, KConfigBase& fallbackConfig );
+
+ /**
+ * This function deletes a password from KWallet
+ *
+ * @param box The boxnumber of the account.
+ * @param account The accountnumber of the account.
+ */
+ static bool deleteKOrnPassword( int box, int account );
+
+ /**
+ * This function moves a password
+ *
+ * @param boxSrc The source box number.
+ * @param accountSrc The source account number.
+ * @param configSrc The source configuration group.
+ * @param boxDest The destination box number.
+ * @param accountDest The destination account number
+ * @param configDest The destination configuration group.
+ */
+ static void moveKOrnPassword( int boxSrc, int accountSrc, KConfigBase &configSrc,
+ int boxDest, int accountDest, KConfigBase &configDest );
+
+ /**
+ * This swaps the password from one box/account combination to another.
+ *
+ * @param box1 The box number of the first password.
+ * @param account1 The account number of the first password.
+ * @param config1 The configurationgroup of the first password.
+ * @param box2 The box number of the second password.
+ * @param account2 The account number of the second password.
+ * @param config2 The configurationgroup of the second password.
+ */
+ static void swapKOrnPassword( int box1, int account1, KConfigBase &config1, int box2, int account2, KConfigBase &config2 );
+
+ /**
+ * This swaps the Wallet password from one box/account combination to another.
+ *
+ * @param box1 The box number of the first password.
+ * @param account1 The number of accounts to be investigated
+ * @param box2 The box number of the first password.
+ * @param account2 The number of accounts to be investigated
+ */
+ static void swapKOrnWalletPassword( int box1, int account1 ,int box2, int account2 );
+
+ /**
+ * This swaps the password from one box to another.
+ *
+ * @param box1 The box number of the first password.
+ * @param accountnumber1 The number of accounts to be investigated
+ * @param box2 The box number of the first password.
+ * @param accountnumber2 The number of accounts to be investigated
+ */
+ static void swapKOrnWalletPasswords( int box1, int accountnumber1 ,int box2, int accountnumber2 );
+
+ /**
+ * This function read the password from the configuration (wallet or configuration) with UseWallet set to !newUseWalletValue,
+ * afterwards, it writes the password to the configuration with UseWallet set to newUseWalletValue
+ *
+ * @param box The box number
+ * @param account The account number
+ * @param config The configuration group
+ * @param newUseWalletValue true to transport a password from a configuration to a wallet, false the other wat around
+ */
+ static void rewritePassword( int box, int account, KConfigBase &config, bool newUseWalletValue );
+
+ /**
+ * If set to true, this class will try to use KWallet,
+ * if false, it will not.
+ *
+ * The default value is true.
+ *
+ * @param value The value to be set to this property.
+ */
+ static void setUseWallet( const bool value );
+private:
+ static void open();
+
+ static bool readKOrnPassword( int box, int account, QString& password );
+ static bool writeKOrnPassword( int box, int account, const QString& password );
+
+ static QString KMailDecrypt( const QString& enc );
+
+ static KWallet::Wallet *m_wallet;
+ static bool m_openFailed;
+ static bool m_useWallet;
+};
+
+#endif //KORNPASSWORD_H
+
diff --git a/korn/polldrop.cpp b/korn/polldrop.cpp
new file mode 100644
index 000000000..32a44be43
--- /dev/null
+++ b/korn/polldrop.cpp
@@ -0,0 +1,90 @@
+/*
+* polldrop.cpp -- Implementation of class KPollableDrop.
+* Author: Sirtaj Singh Kang
+* Version: $Id$
+* Generated: Sun Nov 30 22:41:49 EST 1997
+*/
+
+
+#include<kconfigbase.h>
+
+#include"utils.h"
+#include"polldrop.h"
+
+KPollableDrop::KPollableDrop()
+ : KMailDrop()
+{
+ _timerId = 0;
+ _timerRunning = false;
+ _freq = 300;
+}
+
+
+bool KPollableDrop::startMonitor()
+{
+ if( !running() ) {
+ recheck();
+
+ _timerId = startTimer( _freq * 1000 );
+ _timerRunning = true;
+
+ return startProcess();
+ }
+
+ return false;
+}
+
+bool KPollableDrop::stopMonitor()
+{
+ if( running() ) {
+ killTimer( _timerId );
+ _timerId = 0;
+ _timerRunning = false;
+
+ return stopProcess();
+ }
+
+ return false;
+}
+
+
+void KPollableDrop::timerEvent( QTimerEvent *ev )
+{
+ if( _timerRunning && (ev->timerId() == _timerId) ) {
+ // this event is ours.
+ recheck(); // should be reimplemented by children.
+ }
+ else {
+ QObject::timerEvent( ev );
+ }
+}
+
+bool KPollableDrop::readConfigGroup( const KConfigBase& cfg )
+{
+ KMailDrop::readConfigGroup( cfg );
+
+ setFreq( cfg.readNumEntry(fu(PollConfigKey), DefaultPoll ) );
+
+ return true;
+}
+
+bool KPollableDrop::writeConfigGroup( KConfigBase& cfg ) const
+{
+ KMailDrop::writeConfigGroup( cfg );
+
+ cfg.writeEntry(fu(PollConfigKey), freq() );
+
+ return true;
+}
+
+//void KPollableDrop::addConfigPage( KDropCfgDialog *dlg )
+//{
+// dlg->addConfigPage( new KPollCfg( this ) );
+//
+// KMailDrop::addConfigPage( dlg );
+//}
+
+const char *KPollableDrop::PollConfigKey = "interval";
+const int KPollableDrop::DefaultPoll = 300; // 5 minutes
+
+#include "polldrop.moc"
diff --git a/korn/polldrop.h b/korn/polldrop.h
new file mode 100644
index 000000000..b7ea69aba
--- /dev/null
+++ b/korn/polldrop.h
@@ -0,0 +1,69 @@
+/*
+* polldrop.h -- Declaration of class KPollableDrop.
+* Generated by newclass on Sun Nov 30 22:41:49 EST 1997.
+*/
+#ifndef SSK_POLLDROP_H
+#define SSK_POLLDROP_H
+
+#include"maildrop.h"
+
+class QTimerEvent;
+
+/**
+* Superclass for all pollable maildrop monitors.
+*
+* To implement a polling maildrop, reimplement recheck and emit
+* changed(int) in recheck if new messages have been received.
+*
+* @author Sirtaj Singh Kang (taj@kde.org)
+* @version $Id$
+*/
+class KPollableDrop : public KMailDrop
+{
+ Q_OBJECT
+public:
+ static const char *PollConfigKey;
+ static const int DefaultPoll;
+
+private:
+ int _freq;
+ int _timerId;
+ bool _timerRunning;
+
+public:
+ /**
+ * KPollableDrop Constructor
+ */
+ KPollableDrop();
+
+ virtual bool startMonitor();
+ virtual bool stopMonitor();
+ virtual bool startProcess() { return true; } //Start en stop-functions for progress; it is not pollable, but a member of kio
+ virtual bool stopProcess() { return true; }
+
+ virtual bool running() { return _timerRunning; };
+
+ int freq() const { return _freq; }
+ void setFreq( int freq );
+
+ virtual bool readConfigGroup ( const KConfigBase& cfg );
+ virtual bool writeConfigGroup ( KConfigBase& cfg ) const;
+
+ //virtual void addConfigPage( KDropCfgDialog * );
+
+protected:
+ void timerEvent( QTimerEvent * );
+};
+
+inline void KPollableDrop::setFreq( int freq )
+{
+ bool r = running();
+
+ if( r ) stopMonitor();
+
+ _freq = freq;
+
+ if( r ) startMonitor();
+}
+
+#endif // SSK_POLLDROP_H
diff --git a/korn/pop3_proto.cpp b/korn/pop3_proto.cpp
new file mode 100644
index 000000000..7e88f7fb2
--- /dev/null
+++ b/korn/pop3_proto.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "pop3_proto.h"
+
+#include "account_input.h"
+
+#include <kdebug.h>
+
+#include <qwidget.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qptrvector.h>
+#include <qptrlist.h>
+
+void Pop3_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "Server" );
+ groupBoxes->append( "Identify" );
+}
+
+void Pop3_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject* configDialog, QPtrList< AccountInput > * result ) const
+{
+ QMap< QString, QString > encrList;
+ encrList.insert( "ssl", i18n( "SSL" ) );
+ encrList.insert( "tls=auto", i18n( "TLS if possible" ) );
+ encrList.insert( "tls=on", i18n( "Always TLS" ) );
+ encrList.insert( "tls=off", i18n( "Never TLS" ) );
+
+ QMap< QString, QString > authList;
+ authList.insert( "", i18n( "Plain" ) );
+ authList.insert( "auth=APOP", i18n( "APOP" ) );
+
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Server" ), TextInput::text, "", "server" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 0 ), i18n( "Port" ), 0, 65535, "110", "port" ) );
+ result->append( new ComboInput( (QWidget*)vector->at( 0 ), i18n( "Encryption" ), encrList, "tls=auto", "encryption" ) );
+ QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( activated( int) ),
+ configDialog, SLOT( slotSSLChanged() ) );
+
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Username" ), TextInput::text, "", "username" ) );
+ result->append( new TextInput( (QWidget*)vector->at( 1 ), i18n( "Password" ), TextInput::password, "", "password" ) );
+ result->append( new CheckboxInput( (QWidget*)vector->at( 1 ), i18n( "Save password" ), "true", "savepassword" ) );
+ QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( toggled( bool ) ),
+ (QObject*)result->prev()->rightWidget(), SLOT( setEnabled( bool ) ) );
+ result->last()->setValue( "false" );
+ result->append( new ComboInput( (QWidget*)vector->at( 1 ), i18n( "Authentication" ), authList, "", "auth" ) );
+}
+
+void Pop3_Protocol::readEntries( QMap< QString, QString >* map, QMap< QString, QString > *metadata ) const
+{
+ if( map->contains( "ssl" ) && *map->find( "ssl" ) == "true" )
+ map->insert( "encryption", "ssl" );
+ if( metadata->contains( "tls" ) )
+ map->insert( "encryption", QString( "tls=%1" ).arg( *metadata->find( "tls" ) ) );
+ if( metadata->contains( "auth" ) )
+ map->insert( "auth", QString( "auth=APOP" ) );
+}
+
+void Pop3_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ QString metadata;
+ if( map->contains( "encryption" ) )
+ {
+ if( *map->find( "encryption" ) == "ssl" )
+ map->insert( "ssl", "true" );
+ else
+ {
+ map->insert( "ssl", "false" );
+ metadata += *map->find( "encryption" );
+ }
+ map->erase( "encryption" );
+ }
+
+ if( map->contains( "auth" ) )
+ {
+ if( !metadata.isEmpty() && ! (*map->find( "auth" )).isEmpty() )
+ metadata += ",";
+ metadata += *map->find( "auth" );
+ map->erase( "auth" );
+ }
+
+ map->insert( "metadata", metadata );
+
+ clearFields( map, KIO_Protocol::mailbox );
+}
+
diff --git a/korn/pop3_proto.h b/korn/pop3_proto.h
new file mode 100644
index 000000000..bf67896bd
--- /dev/null
+++ b/korn/pop3_proto.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_POP3_PROTO_H
+#define MK_POP3_PROTO_H
+
+#include "kio_proto.h"
+#include <kurl.h>
+
+class Pop3_Protocol : public KIO_Protocol
+{
+public:
+ Pop3_Protocol() {}
+ virtual ~Pop3_Protocol() {}
+
+ virtual KIO_Protocol * clone() const { return new Pop3_Protocol; }
+
+ virtual bool connectionBased() const { return true; }
+
+ virtual QString protocol( bool ssl ) const { return ssl ? "pop3s" : "pop3"; }
+ virtual QString configName() const { return "pop3"; }
+ virtual bool canReadSubjects() const { return true; }
+ virtual bool canDeleteMail() const { return true; }
+ virtual bool canReadMail() const { return true; }
+
+ virtual unsigned short defaultPort( bool ssl ) const { return ssl?995:110; }
+
+ virtual DeleteTypeEnum deleteFunction() const { return get; }
+
+ virtual QStringList authList() const { return QStringList::split( '|', "Plain|APOP", false ); }
+
+ virtual void readSubjectKURL( KURL & kurl, KIO::MetaData & ) const { kurl.setPath( kurl.path().replace( "/download/", "/headers/" ) ); }
+ virtual void deleteMailKURL ( KURL & kurl, KIO::MetaData & ) const { kurl.setPath( kurl.path().replace( "/download/", "/remove/" ) ); }
+ virtual bool commitDelete () const { return true; }
+ virtual void deleteCommitKURL(KURL & kurl, KIO::MetaData & ) const { kurl.setPath( "commit" ); }
+
+ virtual void configFillGroupBoxes( QStringList* ) const;
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const;
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+};
+
+#endif
diff --git a/korn/pop3s_proto.h b/korn/pop3s_proto.h
new file mode 100644
index 000000000..32beb4a06
--- /dev/null
+++ b/korn/pop3s_proto.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_POP3S_PROTO_H
+#define MK_POP3S_PROTO_H
+
+//Looks very simulay to Pop3_Protocol, so I inherit it, and only overload the difference.
+
+#include "pop3_proto.h"
+
+class Pop3s_Protocol : public Pop3_Protocol
+{
+public:
+ Pop3s_Protocol() {}
+ virtual ~Pop3s_Protocol() {}
+
+ virtual KIO_Protocol * clone() const { return new Pop3s_Protocol; }
+
+ virtual QString protocol() const { return "pop3s"; }
+ virtual QString configName() const { return "pop3s"; }
+
+ virtual unsigned short defaultPort() const { return 995; }
+};
+
+#endif
diff --git a/korn/process_proto.cpp b/korn/process_proto.cpp
new file mode 100644
index 000000000..30cb6f4d5
--- /dev/null
+++ b/korn/process_proto.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "process_proto.h"
+
+#include <kdebug.h>
+
+#include <qlayout.h>
+#include <qptrvector.h>
+#include <qstringlist.h>
+
+#include "account_input.h"
+
+void Process_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "Process" );
+}
+
+void Process_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput > *result ) const
+{
+ result->append( new URLInput( (QWidget*)vector->at( 0 ), i18n( "Program:" ), "", "mailbox" ) );
+}
+
+void Process_Protocol::readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const
+{
+}
+
+void Process_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ clearFields( map, (KIO_Protocol::Fields)( server | port | username | password | save_password | metadata ) );
+}
diff --git a/korn/process_proto.h b/korn/process_proto.h
new file mode 100644
index 000000000..6275be2c6
--- /dev/null
+++ b/korn/process_proto.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_PROCESS_PROTOCOL
+#define MK_PROCESS_PROTOCOL
+
+#include "kio_proto.h"
+
+class Process_Protocol : public KIO_Protocol
+{
+public:
+ Process_Protocol() { }
+ virtual ~Process_Protocol() { }
+
+ virtual KIO_Protocol * clone() const { return new Process_Protocol; }
+
+ virtual QString protocol() const { return "process"; }
+ virtual QString configName() const { return "process"; }
+
+ virtual bool canReadSubjects() const { return false; }
+ virtual bool canDeleteMail() const { return false; }
+ virtual bool canReadMail() const { return false; }
+ virtual bool fullMessage() const { return false; }
+
+ virtual QString mailboxName() const { return i18n("Program: "); }
+
+ virtual void configFillGroupBoxes( QStringList* ) const;
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const;
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+};
+
+#endif
diff --git a/korn/progress_dialog.ui b/korn/progress_dialog.ui
new file mode 100644
index 000000000..6e6b53fad
--- /dev/null
+++ b/korn/progress_dialog.ui
@@ -0,0 +1,120 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>DoubleProgressDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>DoubleProgressDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>286</width>
+ <height>140</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Progress</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lbText</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QProgressBar">
+ <property name="name">
+ <cstring>pbBoxes</cstring>
+ </property>
+ </widget>
+ <widget class="QProgressBar">
+ <property name="name">
+ <cstring>pbProgress</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>DoubleProgressDialog</receiver>
+ <slot>cancelbutton()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pbCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">progress_dialog.ui.h</include>
+</includes>
+<signals>
+ <signal>cancelPressed()</signal>
+</signals>
+<slots>
+ <slot>setText( const QString &amp; str )</slot>
+ <slot>setNumberOfBoxes( int number )</slot>
+ <slot>setProgressOfBoxes( int number )</slot>
+ <slot>setNumberOfSteps( int number )</slot>
+ <slot>setProgress( int number )</slot>
+ <slot access="private" specifier="non virtual">cancelbutton()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/korn/progress_dialog.ui.h b/korn/progress_dialog.ui.h
new file mode 100644
index 000000000..fc982b8a0
--- /dev/null
+++ b/korn/progress_dialog.ui.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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
+ */
+
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+
+void DoubleProgressDialog::setText( const QString & str )
+{
+ lbText->setText( str );
+}
+
+
+void DoubleProgressDialog::setNumberOfBoxes( int number )
+{
+ pbBoxes->setTotalSteps( number );
+ pbBoxes->setProgress( 0 );
+}
+
+
+void DoubleProgressDialog::setProgressOfBoxes( int number )
+{
+ pbBoxes->setProgress( number );
+}
+
+
+void DoubleProgressDialog::setNumberOfSteps( int number )
+{
+ pbProgress->setTotalSteps( number );
+ pbProgress->setProgress( 0 );
+}
+
+
+void DoubleProgressDialog::setProgress( int number )
+{
+ pbProgress->setProgress( number );
+}
+
+
+void DoubleProgressDialog::cancelbutton()
+{
+ emit cancelPressed();
+}
diff --git a/korn/protocol.h b/korn/protocol.h
new file mode 100644
index 000000000..75062b515
--- /dev/null
+++ b/korn/protocol.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 PROTOCOL_H
+#define PROTOCOL_H
+
+class AccountInput;
+class KConfigGroup;
+class KIO_Protocol;
+class KMailDrop;
+
+class QGroupBox;
+class QObject;
+class QStringList;
+class QWidget;
+
+template< class T> class QPtrList;
+template< class T> class QPtrVector;
+template< class T, class S> class QMap;
+
+#include <qstring.h>
+
+class Protocol
+{
+public:
+ Protocol() {}
+ virtual ~Protocol() {}
+
+ virtual const Protocol* getProtocol( KConfigGroup* ) const = 0;
+ virtual KMailDrop* createMaildrop( KConfigGroup* ) const = 0;
+ virtual QMap< QString, QString > * createConfig( KConfigGroup* config, const QString& password ) const = 0;
+ virtual QString configName() const { return "not specified"; }
+
+ virtual void configFillGroupBoxes( QStringList* ) const = 0;
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* ) const = 0;
+ virtual void readEntries( QMap< QString, QString >* ) const = 0;
+ virtual void writeEntries( QMap< QString, QString >* ) const = 0;
+
+ virtual unsigned short defaultPort( bool ) const { return 0; }
+
+ //Functions that return a derived class.
+ //This way, no explicit cast is needed
+ virtual const KIO_Protocol* getKIOProtocol() const { return 0; }
+};
+
+#endif //PROTOCOL_H
+
diff --git a/korn/protocols.cpp b/korn/protocols.cpp
new file mode 100644
index 000000000..60fac95a1
--- /dev/null
+++ b/korn/protocols.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "protocols.h"
+
+#include "kio_proto.h"
+
+#include "imap_proto.h"
+#include "mbox_proto.h"
+#include "pop3_proto.h"
+#include "process_proto.h"
+//#include "imaps_proto.h"
+#include "nntp_proto.h"
+//#include "pop3s_proto.h"
+#include "qmail_proto.h"
+#include "dcop_proto.h"
+#include "kmail_proto.h"
+
+#include <qdict.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+QDict<Protocol>* Protocols::protocols = 0;
+
+const Protocol* Protocols::getProto( const QString& proto )
+{
+ if( !protocols )
+ fillProtocols();
+
+ return protocols->find( proto );
+}
+
+const Protocol* Protocols::firstProtocol()
+{
+ return getProto( "mbox" );
+}
+
+QStringList Protocols::getProtocols()
+{
+ QStringList output;
+
+ if( !protocols )
+ fillProtocols();
+
+ QDictIterator<Protocol> it( *protocols );
+ for( ; it.current(); ++it )
+ output.append( it.currentKey() );
+
+ output.sort();
+
+ return output;
+}
+
+void Protocols::fillProtocols()
+{
+ protocols = new QDict< Protocol>;
+ protocols->setAutoDelete( true );
+ addProtocol( new Imap_Protocol );
+ addProtocol( new MBox_Protocol );
+ addProtocol( new Pop3_Protocol );
+ addProtocol( new Process_Protocol );
+ addProtocol( new Nntp_Protocol );
+ addProtocol( new QMail_Protocol );
+ addProtocol( new DCOP_Protocol );
+ addProtocol( new KMail_Protocol );
+}
+
+void Protocols::addProtocol( Protocol* proto )
+{
+ protocols->insert( proto->configName(), proto );
+}
+
diff --git a/korn/protocols.h b/korn/protocols.h
new file mode 100644
index 000000000..02492ce13
--- /dev/null
+++ b/korn/protocols.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_PROTOCOLS_H
+#define MK_PROTOCOLS_H
+
+class Protocol;
+
+template< class T > class QDict;
+class QString;
+class QStringList;
+
+class Protocols
+{
+public:
+ Protocols() {}
+ ~Protocols() {}
+
+ static const Protocol* getProto( const QString& );
+ static const Protocol* firstProtocol();
+
+ static QStringList getProtocols();
+
+ static void fillProtocols();
+private:
+ static void addProtocol( Protocol* );
+
+ static QDict<Protocol> *protocols;
+};
+
+#endif //MK_PROTOCOLS_H
diff --git a/korn/qmail_proto.cpp b/korn/qmail_proto.cpp
new file mode 100644
index 000000000..8accfbdb1
--- /dev/null
+++ b/korn/qmail_proto.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "qmail_proto.h"
+
+#include <kdebug.h>
+#include <kurlrequester.h>
+
+#include <qlayout.h>
+#include <qptrvector.h>
+#include <qstringlist.h>
+
+#include "account_input.h"
+
+void QMail_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
+{
+ groupBoxes->append( "Maildir" );
+}
+
+void QMail_Protocol::configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput > *result ) const
+{
+ result->append( new URLInput( (QWidget*)vector->at( 0 ), i18n( "Path:" ), "", "mailbox" ) );
+ dynamic_cast<KURLRequester*>(result->last()->rightWidget())->setMode( KFile::Directory );
+}
+
+void QMail_Protocol::readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const
+{
+}
+
+void QMail_Protocol::writeEntries( QMap< QString, QString >* map ) const
+{
+ clearFields( map, (KIO_Protocol::Fields)( server | port | username | password | save_password | metadata ) );
+}
diff --git a/korn/qmail_proto.h b/korn/qmail_proto.h
new file mode 100644
index 000000000..90c1bc381
--- /dev/null
+++ b/korn/qmail_proto.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_QMAIL_PROTO_H
+#define MK_QMAIL_PROTO_H
+
+#include "kio_proto.h"
+
+class QMail_Protocol : public KIO_Protocol
+{
+public:
+ QMail_Protocol() {}
+ virtual ~QMail_Protocol() {}
+
+ virtual KIO_Protocol * clone() const { return new QMail_Protocol; }
+
+ virtual bool connectionBased() const { return false; }
+
+ virtual QString protocol() const { return "file"; }
+ virtual QString configName() const { return "qmail"; }
+
+ virtual bool canReadSubjects() const { return true; }
+ virtual bool canDeleteMail() const { return true; }
+ virtual bool canReadMail() const { return true; }
+ virtual bool fullMessage() const { return true; }
+
+ virtual void recheckKURL( KURL &kurl, KIO::MetaData& ) const
+ { if( kurl.path().right( 1 ) == "/" )
+ kurl.setPath( kurl.path() + "new" );
+ else
+ kurl.setPath( kurl.path() + "/new" );
+ }
+
+
+ virtual QString mailboxName() const { return i18n( "Path:" ); }
+
+ virtual void configFillGroupBoxes( QStringList* ) const;
+ virtual void configFields( QPtrVector< QWidget >* vector, const QObject*, QPtrList< AccountInput >* ) const;
+ virtual void readEntries( QMap< QString, QString >*, QMap< QString, QString >* ) const;
+ virtual void writeEntries( QMap< QString, QString >* ) const;
+};
+
+#endif
diff --git a/korn/sortedmailsubject.cpp b/korn/sortedmailsubject.cpp
new file mode 100644
index 000000000..5b9da297b
--- /dev/null
+++ b/korn/sortedmailsubject.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "sortedmailsubject.h"
+
+int SortedMailSubject::compareItems ( QPtrCollection::Item item1, QPtrCollection::Item item2 )
+{
+ int date1, date2;
+ date1 = ( (KornMailSubject*)item1 )->getDate();
+ date2 = ( (KornMailSubject*)item2 )->getDate();
+
+ if( date1 < date2 )
+ return -1;
+ else if( date1 == date2 )
+ return 0;
+ else
+ return 1;
+}
diff --git a/korn/sortedmailsubject.h b/korn/sortedmailsubject.h
new file mode 100644
index 000000000..e0011c122
--- /dev/null
+++ b/korn/sortedmailsubject.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_SORTEDMAILSUBJECT_H
+#define MK_SORTEDMAILSUBJECT_H
+
+#include "mailsubject.h"
+#include <qptrlist.h>
+
+/*
+ * This class is a normal QPtrList with an overloaded function compareItems.
+ * This way, it is possible to sort this list on date.
+ */
+
+class SortedMailSubject : public QPtrList< KornMailSubject >
+{
+public:
+ SortedMailSubject() : QPtrList< KornMailSubject >() {}
+ SortedMailSubject( const SortedMailSubject& sms ) : QPtrList< KornMailSubject >( sms ) {}
+ ~SortedMailSubject() {}
+
+ virtual int compareItems ( QPtrCollection::Item item1, QPtrCollection::Item item2 );
+};
+
+#endif //MK_SORTEDMAILSUBJECT_H
diff --git a/korn/stringid.cpp b/korn/stringid.cpp
new file mode 100644
index 000000000..43f5ea4a1
--- /dev/null
+++ b/korn/stringid.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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
+ */
+
+/*
+ * Implementation of KornStringId
+ * Author: Mart Kelder
+ */
+
+#include "stringid.h"
+
+KornStringId::KornStringId( const QString & id ) : _id( id )
+{
+}
+
+KornStringId::KornStringId( const KornStringId & src ) : KornMailId(), _id( src._id )
+{
+}
+
+KornMailId * KornStringId::clone() const
+{
+ return ( new KornStringId( *this ) );
+}
+
diff --git a/korn/stringid.h b/korn/stringid.h
new file mode 100644
index 000000000..871f97ec2
--- /dev/null
+++ b/korn/stringid.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_STRINGID_H
+#define MK_STRINGID_H
+
+/*
+ * This class provides a identification with string,
+ * because in KIO, I don't know if emails return in the same order.
+ * Author Mart Kelder
+ */
+
+#include<qstring.h>
+#include"mailid.h"
+
+class KornStringId : public KornMailId
+{
+private:
+ QString _id;
+public:
+ KornStringId( const QString & id );
+ KornStringId( const KornStringId & src );
+ ~KornStringId() {}
+
+ QString getId() const { return _id; }
+ virtual QString toString() const { return _id; }
+
+ virtual KornMailId *clone() const;
+};
+
+#endif //MK_STRINGID_H
diff --git a/korn/subjectsdlg.cpp b/korn/subjectsdlg.cpp
new file mode 100644
index 000000000..9b675e0bf
--- /dev/null
+++ b/korn/subjectsdlg.cpp
@@ -0,0 +1,535 @@
+#include "subjectsdlg.h"
+#include "maildrop.h"
+#include <qapplication.h>
+#include <kcursor.h>
+#include <kdebug.h>
+#include <qlayout.h>
+#include <qdatetime.h>
+#include <qtimer.h>
+#include "mailsubject.h"
+#include <klocale.h>
+#include <qprogressdialog.h>
+#include <kmessagebox.h>
+#include "maildlg.h"
+#include "progress_dialog.h"
+
+KornSubjectsDlg::SubjectListViewItem::SubjectListViewItem( QListView *parent, KornMailSubject * item)
+ // set the column strings except column 2 (date)
+ : KListViewItem(parent, item->getSender(), item->getSubject(), "", KGlobal::locale()->formatNumber(item->getSize(), 0))
+ , _mailSubject( new KornMailSubject( *item ) )
+{
+ // convert the date according to the user settings and show it in column 2
+ QDateTime date;
+ date.setTime_t(_mailSubject->getDate());
+ setText(2, KGlobal::locale()->formatDateTime(date, true, true));
+}
+
+KornSubjectsDlg::SubjectListViewItem::~SubjectListViewItem()
+{
+ delete _mailSubject;
+}
+
+int KornSubjectsDlg::SubjectListViewItem::compare( QListViewItem* item, int column, bool ascending ) const
+{
+ if ( column == 2 )
+ {
+ // if column 2 was clicked, compare the dates.
+ QDateTime d, e;
+ d.setTime_t(_mailSubject->getDate());
+ e.setTime_t(((SubjectListViewItem *)item)->_mailSubject->getDate());
+ return e.secsTo( d );
+ }
+ else if ( column == 3 )
+ {
+ // if column 3 was clicked, compare the sizes.
+ int i1 = _mailSubject->getSize();
+ int i2 = ((SubjectListViewItem *)item)->_mailSubject->getSize();
+ return i1 - i2;
+ }
+ else
+ {
+ // otherwise call default handling (i.e. string compare)
+ return KListViewItem::compare( item, column, ascending );
+ }
+}
+
+KornSubjectsDlg::KornSubjectsDlg( QWidget *parent )
+ : KDialogBase( parent, "urldialog", true, "test", Close, Close, true), _mailDrop( new QPtrList< KMailDrop > ),
+ _subjects(0), _delete(0), mailDlg(0), _canDeleteMaildrop( true )
+{
+ _loadSubjectsCanceled = false;
+ setModal( true );
+
+ // The dialog contains a list view and several buttons.
+ // Two box layouts hol dthem.
+ QWidget * page = new QWidget( this );
+ setMainWidget(page);
+ invertSelButton = new KPushButton(i18n("&Invert Selection"), page);
+ clearSelButton = new KPushButton(i18n("&Remove Selection"), page);
+ deleteButton = new KPushButton(i18n("&Delete"), page);
+ showButton = new KPushButton(i18n("&Show"), page);
+ deleteButton->setEnabled(false);
+ showButton->setEnabled(false);
+ QVBoxLayout * topLayout = new QVBoxLayout( page, 0, spacingHint() );
+ QHBoxLayout * buttons = new QHBoxLayout();
+ _list = new KListView(page);
+ topLayout->addWidget(_list, 10);
+ topLayout->addLayout(buttons, 0);
+ buttons->addWidget(invertSelButton, 0);
+ buttons->addWidget(clearSelButton, 0);
+ buttons->addWidget(deleteButton, 0);
+ buttons->addWidget(showButton, 0);
+ buttons->addStretch(10);
+
+ // feed the list view with its colums
+ _list->setSelectionMode(QListView::Multi);
+ _list->addColumn(i18n("From"));
+ _list->addColumn(i18n("Subject"));
+ _list->addColumn(i18n("Date"));
+ _list->addColumn(i18n("Size (Bytes)"));
+
+ // column 3 contains a number (change alignment)
+ _list->setColumnAlignment(3, Qt::AlignRight);
+ _list->setItemMargin(3);
+
+ // connect the selection changed and double click events of the list view
+ connect(_list, SIGNAL(selectionChanged()), this, SLOT(listSelectionChanged()));
+ connect(_list, SIGNAL(executed(QListViewItem *)), this, SLOT(doubleClicked(QListViewItem *)));
+
+ // connect the buttons
+ connect(invertSelButton, SIGNAL(clicked()), this, SLOT(invertSelection()));
+ connect(clearSelButton, SIGNAL(clicked()), this, SLOT(removeSelection()));
+ connect(showButton, SIGNAL(clicked()), this, SLOT(showMessage()));
+ connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteMessage()));
+ setInitialSize(QSize(QApplication::desktop()->width(), QApplication::desktop()->height()));
+}
+
+void KornSubjectsDlg::clear()
+{
+ _mailDrop->clear();
+}
+
+void KornSubjectsDlg::addMailBox(KMailDrop* mailDrop)
+{
+ _mailDrop->append( mailDrop );
+}
+
+void KornSubjectsDlg::loadMessages()
+{
+ reloadSubjects();
+ exec();
+}
+
+void KornSubjectsDlg::listSelectionChanged()
+{
+ QPtrList< QListViewItem > list( _list->selectedItems() );
+
+ if (!_mailDrop)
+ return;
+ int selected = list.count();
+ bool enableDelete = selected > 0;
+
+ if(enableDelete)
+ {
+ KornSubjectsDlg::SubjectListViewItem* current = (SubjectListViewItem*)list.first();
+ KMailDrop *drop = current->getMailSubject()->getMailDrop();
+ enableDelete = drop->canDeleteMails();
+
+ while( enableDelete && ( current = (SubjectListViewItem*)list.next() ) )
+ enableDelete = current->getMailSubject()->getMailDrop()->canDeleteMails();
+ }
+
+ // eneable the show button if one is selected
+ showButton->setEnabled(selected == 1);
+
+ // eneable the delete button if one or more items are selected
+
+ deleteButton->setEnabled(enableDelete);
+}
+
+void KornSubjectsDlg::doubleClicked(QListViewItem * item)
+{
+ // show the message
+ showMessage(item);
+}
+
+KornSubjectsDlg::~KornSubjectsDlg()
+{
+ if (_subjects)
+ delete _subjects;
+ _subjects = 0;
+}
+
+void KornSubjectsDlg::loadSubjectsCanceled()
+{
+ _loadSubjectsCanceled = true;
+}
+
+void KornSubjectsDlg::invertSelection()
+{
+ _list->invertSelection();
+}
+
+void KornSubjectsDlg::removeSelection()
+{
+ _list->clearSelection();
+}
+
+void KornSubjectsDlg::showMessage()
+{
+ if (!_mailDrop)
+ return;
+
+ // get selcted item
+ QPtrList<QListViewItem> messages = _list->selectedItems();
+ QListViewItem * item = messages.first();
+
+ // and show it
+ showMessage(item);
+}
+
+void KornSubjectsDlg::showMessage(QListViewItem * item )
+{
+ if (!item)
+ return;
+
+ // Create mail dialog if it has not been created so far.
+ if (!mailDlg)
+ mailDlg = new KornMailDlg (this);
+
+ // Feed the mail dailog with data and show it (modal dialog)
+ mailDlg->setMailSubject( ( ( KornSubjectsDlg::SubjectListViewItem *)item )->getMailSubject() );
+ mailDlg->exec();
+}
+
+void KornSubjectsDlg::showSubjectsDlg( const QString& name )
+{
+ setCaption( i18n("Mails in Box: %1").arg( name ) );
+
+ // load the subjects
+ reloadSubjects();
+ // if the load process was not cancled: show the dialog
+ if( this->isVisible() )
+ exec();
+}
+
+void KornSubjectsDlg::closeDialog( )
+{
+ disconnect( this, SIGNAL( finished() ), this, SLOT( closeDialog() ) );
+}
+
+//----------------------------
+// ALL FUNCTIONS WITH HAVE SOMETHING TO DO WITH FETCHING SUBJECTS
+//----------------------------
+
+//The public function
+void KornSubjectsDlg::reloadSubjects()
+{
+ if( _subjects )
+ return; //Already fetching
+
+ makeSubjectsStruct();
+
+ _subjects->progress->setNumberOfBoxes( _mailDrop->count() );
+ _subjects->progress->setProgressOfBoxes( 0 );
+ _subjects->progress->setNumberOfSteps( 1 );
+ _subjects->progress->setProgress( 0 );
+
+ _subjects->it->toFirst();
+
+ if( !_subjects->it->current() )
+ return; //No maildrops available.
+
+ _subjects->progress->show();
+
+ prepareStep1Subjects( _subjects->it->current() );
+}
+
+//Private help-functions
+void KornSubjectsDlg::prepareStep1Subjects( KMailDrop *drop )
+{
+ _subjects->progress->setText( i18n( "Rechecking box..." ) );
+ _subjects->progress->setNumberOfSteps( 1 );
+ _subjects->progress->setProgress( 0 );
+ _subjects->atRechecking = true;
+
+ connect( drop, SIGNAL( rechecked() ), this, SLOT( slotReloadRechecked() ) );
+ drop->recheck();
+}
+
+void KornSubjectsDlg::removeStep1Subjects( KMailDrop *drop )
+{
+ disconnect( drop, SIGNAL( rechecked() ), this, SLOT( slotReloadRechecked() ) );
+}
+
+void KornSubjectsDlg::prepareStep2Subjects( KMailDrop *drop )
+{
+ _subjects->progress->setText( i18n( "Fetching messages..." ) );
+ _subjects->atRechecking = false;
+
+ connect( drop, SIGNAL( readSubject( KornMailSubject* ) ), this, SLOT( subjectAvailable( KornMailSubject* ) ) );
+ connect( drop, SIGNAL( readSubjectsReady( bool ) ), this, SLOT( subjectsReady( bool ) ) );
+ connect( drop, SIGNAL( readSubjectsTotalSteps( int ) ), _subjects->progress, SLOT( setNumberOfSteps( int ) ) );
+ connect( drop, SIGNAL( readSubjectsProgress( int ) ), _subjects->progress, SLOT( setProgress( int ) ) );
+ connect( _subjects->progress, SIGNAL( cancelPressed() ), drop, SLOT( readSubjectsCanceled() ) );
+
+ if( _subjects->it->current()->canReadSubjects() )
+ _subjects->it->current()->readSubjects( 0 );
+ else
+ subjectsReady( true );
+}
+
+void KornSubjectsDlg::removeStep2Subjects( KMailDrop *drop )
+{
+ disconnect( drop, SIGNAL( readSubject( KornMailSubject* ) ), this, SLOT( subjectAvailable( KornMailSubject* ) ) );
+ disconnect( drop, SIGNAL( readSubjectsReady( bool ) ), this, SLOT( subjectsReady( bool ) ) );
+ disconnect( drop, SIGNAL( readSubjectsTotalSteps( int ) ), _subjects->progress, SLOT( setNumberOfSteps( int ) ) );
+ disconnect( drop, SIGNAL( readSubjectsProgress( int ) ), _subjects->progress, SLOT( setProgress( int ) ) );
+ disconnect( _subjects->progress, SIGNAL( cancelPressed() ), drop, SLOT( readSubjectsCanceled() ) );
+}
+
+bool KornSubjectsDlg::makeSubjectsStruct()
+{
+ if( _subjects ) //Subjects are already being checked
+ return false;
+
+ _subjects = new SubjectsData;
+ _subjects->it = new QPtrListIterator< KMailDrop >( *_mailDrop );
+ _subjects->subjects = new QValueVector< KornMailSubject >;
+ _subjects->progress = new DoubleProgressDialog( this, "progress" );
+ _subjects->atRechecking = true;
+
+ connect( _subjects->progress, SIGNAL( cancelPressed() ), this, SLOT( slotSubjectsCanceled() ) );
+
+ return true;
+}
+
+void KornSubjectsDlg::deleteSubjectsStruct()
+{
+ if( !_subjects )
+ return;
+
+ disconnect( _subjects->progress, SIGNAL( cancelPressed() ), this, SLOT( slotSubjectsCanceled() ) );
+
+ this->unsetCursor();
+
+ delete _subjects->progress;
+ delete _subjects->subjects;
+ delete _subjects->it;
+ delete _subjects; _subjects = 0;
+}
+
+//Slots
+void KornSubjectsDlg::slotReloadRechecked()
+{
+ _subjects->progress->setText( i18n( "Downloading subjects..." ) ); //Progress message when fetching messages
+
+ removeStep1Subjects( _subjects->it->current() );
+ _subjects->subjects->reserve( _subjects->it->current()->count() ); //enlarge QValueVector to speed adding up.
+ prepareStep2Subjects( _subjects->it->current() );
+}
+
+void KornSubjectsDlg::slotSubjectsCanceled()
+{
+ if( !_subjects )
+ return; //Nothing to do
+
+ if( _subjects->atRechecking )
+ removeStep1Subjects( _subjects->it->current() );
+ else
+ removeStep2Subjects( _subjects->it->current() );
+
+ deleteSubjectsStruct();
+}
+
+void KornSubjectsDlg::subjectAvailable( KornMailSubject * subject )
+{
+ if( _subjects )
+ _subjects->subjects->push_back( *subject );
+
+ delete subject;
+
+}
+
+void KornSubjectsDlg::subjectsReady( bool success )
+{
+ static int progress;
+
+ if( !_subjects )
+ return;
+
+ if( _subjects->it->atFirst() )
+ progress = 0;
+
+ removeStep2Subjects( _subjects->it->current() );
+
+ //Goto next drop
+ ++(*_subjects->it);
+ ++progress;
+
+ _subjects->progress->setProgressOfBoxes( progress );
+
+ if( _subjects->it->current() )
+ {
+ prepareStep1Subjects( _subjects->it->current() );
+ } else {
+ //Clear list first
+ _list->clear();
+
+ //All subjects downloaded
+ for( QValueVector<KornMailSubject>::iterator it = _subjects->subjects->begin(); it != _subjects->subjects->end();
+ ++it )
+ { //Draw entry's
+ new SubjectListViewItem(_list, &(*it));
+ }
+
+ if( _subjects->subjects->capacity() != _subjects->subjects->count() )
+ _subjects->subjects->resize( _subjects->subjects->count() );
+
+ deleteSubjectsStruct();
+ //If windows isn't visible already, shows it.
+ if( !isVisible() && success )
+ show();
+ }
+}
+//---------------------------------
+//Here comes all functions with have to do something with deleting messages
+//---------------------------------
+
+
+//Main function
+void KornSubjectsDlg::deleteMessage()
+{
+ if ( _delete )
+ return; //A delete action is already pending
+
+ makeDeleteStruct();
+
+ fillDeleteMessageList();
+
+ if ( _delete->messages->count() == 0 )
+ {
+ deleteDeleteStruct();
+ return; //No messages to delete
+ } else {
+ _delete->totalNumberOfMessages = _delete->messages->count();
+ }
+
+ QString confirmation = i18n( "Do you really want to delete %n message?",
+ "Do you really want to delete %n messages?", _delete->messages->count() );
+
+ if( KMessageBox::questionYesNo( this, confirmation, i18n( "Confirmation" ), KStdGuiItem::del(), KStdGuiItem::cancel() ) != KMessageBox::Yes )
+ {
+ deleteDeleteStruct();
+ return; //Not excepted
+ }
+
+ _delete->progress->setLabelText( i18n( "Deleting mail; please wait...." ) );
+ _delete->progress->setTotalSteps( _delete->totalNumberOfMessages );
+ _delete->progress->setProgress( 0 );
+ _delete->progress->show();
+
+ deleteNextMessage();
+}
+
+//Private help functions
+void KornSubjectsDlg::makeDeleteStruct()
+{
+ _delete = new DeleteData;
+ _delete->messages = new QPtrList< KornMailSubject >;
+ _delete->ids = new QPtrList< const KornMailId >;
+ _delete->progress = new QProgressDialog( this, "progress" );
+ _delete->totalNumberOfMessages = 0;
+
+ connect( _delete->progress, SIGNAL( canceled() ), this, SLOT( slotDeleteCanceled() ) );
+}
+
+void KornSubjectsDlg::deleteDeleteStruct()
+{
+ disconnect( _delete->progress, SIGNAL( canceled() ), this, SLOT( slotDeleteCanceled() ) );
+
+ delete _delete->messages;
+ delete _delete->ids;
+ delete _delete->progress;
+ delete _delete; _delete = 0;
+}
+
+void KornSubjectsDlg::fillDeleteMessageList()
+{
+ QListViewItem *current;
+ QPtrList< QListViewItem > list( _list->selectedItems() );
+
+ for( current = list.first(); current; current = list.next() )
+ _delete->messages->append( ( ( KornSubjectsDlg::SubjectListViewItem * ) current )->getMailSubject() );
+}
+
+void KornSubjectsDlg::fillDeleteIdList( KMailDrop *drop )
+{
+ _delete->ids->clear();
+ KornMailSubject *current;
+
+ for( current = _delete->messages->first(); current; )
+ {
+ if( current->getMailDrop() == drop )
+ {
+ _delete->ids->append( current->getId() );
+ if( _delete->messages->remove( current ) )
+ current = _delete->messages->current(); //If successfull, current() is already the next message
+ else
+ current = _delete->messages->next(); // If removal failed, goto the next item
+ } else {
+ current = _delete->messages->next(); //Goto next item
+ }
+ }
+}
+
+void KornSubjectsDlg::deleteNextMessage()
+{
+ if( _delete->messages->count() == 0 ) //No more messages to delete
+ {
+ QTimer::singleShot( 100, this, SLOT( reloadSubjects() ) );
+ deleteDeleteStruct();
+ //reloadSubjects(); //Reload all subjects again
+ return;
+ }
+
+ _delete->ids = new QPtrList< const KornMailId >;
+ _delete->drop = _delete->messages->getFirst()->getMailDrop();
+
+ fillDeleteIdList( _delete->drop );
+
+ // Connect the progress bar signals of the mail box
+ connect( _delete->drop, SIGNAL( deleteMailsTotalSteps( int ) ), _delete->progress, SLOT( setTotalSteps( int ) ) );
+ connect( _delete->drop, SIGNAL( deleteMailsProgress( int ) ), _delete->progress, SLOT( setProgress( int ) ) );
+ connect( _delete->drop, SIGNAL( deleteMailsReady( bool ) ), this, SLOT( deleteMailsReady( bool ) ) );
+
+ // connect the cancel button of the progress bar
+ connect( _delete->progress, SIGNAL( canceled() ), _delete->drop, SLOT( deleteMailsCanceled() ) );
+
+ // delete the mails
+ _delete->drop->deleteMails( _delete->ids, 0 );
+}
+
+void KornSubjectsDlg::deleteMailsReady( bool /*success*/ )
+{
+ if( !_delete )
+ return;
+
+ disconnect( _delete->drop, SIGNAL( deleteMailsTotalSteps( int ) ), _delete->progress, SLOT( setTotalSteps( int ) ) );
+ disconnect( _delete->drop, SIGNAL( deleteMailsProgress( int ) ), _delete->progress, SLOT( setProgress( int ) ) );
+ disconnect( _delete->drop, SIGNAL( deleteMailsReady( bool ) ), this, SLOT( deleteMailsReady( bool ) ) );
+
+ // disconnect the cancel button of the progress bar
+ disconnect( _delete->progress, SIGNAL( canceled() ), _delete->drop, SLOT( deleteMailsCanceled() ) );
+
+ deleteNextMessage();
+}
+
+void KornSubjectsDlg::slotDeleteCanceled()
+{
+ deleteDeleteStruct();
+ reloadSubjects();
+}
+
+#include "subjectsdlg.moc"
+
diff --git a/korn/subjectsdlg.h b/korn/subjectsdlg.h
new file mode 100644
index 000000000..064b6c8ef
--- /dev/null
+++ b/korn/subjectsdlg.h
@@ -0,0 +1,202 @@
+#ifndef KornSubjectsDlg_h
+#define KornSubjectsDlg_h
+
+#include<kdialogbase.h>
+#include <klistview.h>
+#include<qvaluevector.h>
+#include <kpushbutton.h>
+
+class KMailDrop;
+class KornMailSubject;
+class KornMailId;
+class KListView;
+class KornMailDlg;
+class QProgressDialog;
+class DoubleProgressDialog;
+
+template< class T > class QPtrList;
+
+/**
+ * KornSubjectsDlg loads all mail subjects and shows them in a list control.
+ * Buttons allow the user to select several mails, delete them or to show one
+ * of the mails.
+ */
+class KornSubjectsDlg: public KDialogBase
+{
+ Q_OBJECT
+
+ /**
+ * SubjectListViewItem is a helper class representing one line in the list view.
+ * It stores the mail subject the line represents and controls the sorting.
+ */
+ class SubjectListViewItem : public KListViewItem
+ {
+ KornMailSubject * _mailSubject;
+ public:
+ /**
+ * SubjectListViewItem Constructor
+ * @param parent list view
+ * @param item KornMailSubject this item should represent. It is NOT deleted
+ * if SubjectListViewItem is deleted.
+ */
+ SubjectListViewItem( QListView *parent, KornMailSubject * item);
+
+ /**
+ * SubjectListViewItem Destructor
+ */
+ ~SubjectListViewItem();
+
+ /**
+ * Compare to list view item. Called if the sort header are clicked.
+ * @param item item to compare this with
+ * @param column column to compare
+ * @param ascending search order
+ */
+ int compare( QListViewItem* item, int column, bool ascending ) const;
+
+ /**
+ * Return the mail subject.
+ * @return the mail subject
+ */
+ KornMailSubject * getMailSubject() const {return _mailSubject;}
+ };
+
+ QPtrList< KMailDrop > *_mailDrop;
+ struct SubjectsData
+ {
+ QPtrListIterator< KMailDrop > *it;
+ QValueVector< KornMailSubject > *subjects;
+ DoubleProgressDialog *progress;
+ bool atRechecking;
+ } *_subjects;
+
+ struct DeleteData
+ {
+ QPtrList< KornMailSubject > *messages;
+ QPtrList< const KornMailId > *ids;
+ QProgressDialog *progress;
+ KMailDrop *drop;
+ int totalNumberOfMessages;
+ } *_delete;
+
+ KListView * _list;
+ KPushButton * invertSelButton;
+ KPushButton * clearSelButton;
+ KPushButton * deleteButton;
+ KPushButton * showButton;
+ KornMailDlg * mailDlg;
+
+ bool _loadSubjectsCanceled, _deleteMailsCanceled;
+ bool _canDeleteMaildrop;
+
+ /**
+ * Load the mails subjects and refresh the list view.
+ * @return false if the load process was cancled (close the dialog!), true otherwise
+ */
+ //bool reload();
+
+ /**
+ * Show a message in a separate dialog
+ * @param item message to show
+ */
+ void showMessage(QListViewItem * item);
+public:
+ /**
+ * KornSubjectsDlg Constructor
+ * @param parent parent widget
+ */
+ KornSubjectsDlg( QWidget *parent=0 );
+
+ /**
+ * This functions clears all available KMailDrop's.
+ */
+ void clear();
+
+ /**
+ * This function adds a maildrop to the list.
+ * @param mailDrop The maildrop which have to be added.
+ */
+ void addMailBox(KMailDrop* mailDrop);
+
+ /**
+ * This method loads the messages and shows the dialog.
+ */
+ void loadMessages();
+
+ /**
+ * Show the KornSubjectsDlg as a modal dialog.
+ * @param name The name of the box
+ */
+ void showSubjectsDlg( const QString& name );
+
+ /**
+ * KornSubjectsDlg Destructor
+ */
+ virtual ~KornSubjectsDlg();
+
+private slots:
+
+ /**
+ * called if the cancel button was clicked while loadind the subjects
+ */
+ void loadSubjectsCanceled();
+
+ /**
+ * called if the selction of the list view was changed
+ */
+ void listSelectionChanged();
+
+ /**
+ * called if the "Invert Selection" button was clicked
+ */
+ void invertSelection();
+
+ /**
+ * called if the "Remove Selection" button was clicked
+ */
+ void removeSelection();
+
+ /**
+ * called if the "Show" button was clicked
+ */
+ void showMessage();
+
+ /**
+ * called if a list view item was double clicked
+ */
+ void doubleClicked ( QListViewItem *item );
+
+ void closeDialog();
+
+ //Functions for the subjects
+public slots:
+ void reloadSubjects();
+private:
+ void prepareStep1Subjects( KMailDrop* );
+ void removeStep1Subjects( KMailDrop* );
+ void prepareStep2Subjects( KMailDrop* );
+ void removeStep2Subjects( KMailDrop* );
+ bool makeSubjectsStruct();
+ void deleteSubjectsStruct();
+private slots:
+ void slotReloadRechecked();
+ void slotSubjectsCanceled();
+ void subjectAvailable( KornMailSubject* );
+ void subjectsReady( bool );
+
+ //Functions neccesairy for delete
+public slots:
+ void deleteMessage();
+private:
+ void makeDeleteStruct();
+ void deleteDeleteStruct();
+ void fillDeleteMessageList();
+ void fillDeleteIdList( KMailDrop *drop );
+ void deleteNextMessage();
+private slots:
+ void deleteMailsReady( bool );
+ void slotDeleteCanceled();
+
+};
+
+#endif
diff --git a/korn/systemtray.cpp b/korn/systemtray.cpp
new file mode 100644
index 000000000..f3681d550
--- /dev/null
+++ b/korn/systemtray.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 "systemtray.h"
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include <qmovie.h>
+
+SystemTray::SystemTray( QWidget * parent, const char * name )
+ : KSystemTray( parent, name )
+{
+}
+
+SystemTray::~SystemTray()
+{
+}
+
+void SystemTray::mousePressEvent( QMouseEvent* ee )
+{
+ //Use the general function to determe what must be done
+ emit mouseButtonPressed( ee->button() );
+}
+
+#include "systemtray.moc"
diff --git a/korn/systemtray.h b/korn/systemtray.h
new file mode 100644
index 000000000..4b8aa616f
--- /dev/null
+++ b/korn/systemtray.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * 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 MK_SYSTEMTRAY_H
+#define MK_SYSTEMTRAY_H
+
+#include <ksystemtray.h>
+
+class QWidget;
+
+/**
+ * This class is an implementation of a KSystemTray class.
+ * It uses different handling of button-clicks.
+ *
+ * @author Mart Kelder <mart.kde@hccnet.nl>
+ */
+class SystemTray : public KSystemTray
+{ Q_OBJECT
+public:
+ /**
+ * This contructor gives all it parameters to its parents.
+ * @param parant The parent window
+ * @param name The name of the QObject's parents.
+ */
+ SystemTray( QWidget * parent = 0, const char * name = 0 );
+ /**
+ * Empty destructor; does nothing at the moment
+ */
+ ~SystemTray();
+
+protected:
+ /**
+ * Reimplementation because in the reimplementation of KSystray it popup's of restores.
+ * In this implemention, the action depends on the settings.
+ * @param me An object which contains the mousebutton which is pressed.
+ */
+ virtual void mousePressEvent( QMouseEvent* me );
+
+signals:
+ void mouseButtonPressed( Qt::ButtonState );
+};
+
+#endif //MK_SYSTEMTRAY_H
diff --git a/korn/uninstall.desktop b/korn/uninstall.desktop
new file mode 100644
index 000000000..e1e3e1732
--- /dev/null
+++ b/korn/uninstall.desktop
@@ -0,0 +1,2 @@
+[Desktop Entry]
+Hidden=true
diff --git a/korn/utils.h b/korn/utils.h
new file mode 100644
index 000000000..4dc279556
--- /dev/null
+++ b/korn/utils.h
@@ -0,0 +1,5 @@
+#ifndef KORN_UTILS_H
+#define KORN_UTILS_H
+#include <qstring.h>
+inline QString fu(const char * s) { return QString::fromUtf8(s); }
+#endif