summaryrefslogtreecommitdiffstats
path: root/kshowmail
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 15:57:00 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 15:57:00 -0500
commitb888c7edb54e483ec0e3c2e2ce0eafd73acdcc65 (patch)
tree7ca76d42f66fb21ea08142de9a8d3bf16e597404 /kshowmail
downloadkshowmail-b888c7edb54e483ec0e3c2e2ce0eafd73acdcc65.tar.gz
kshowmail-b888c7edb54e483ec0e3c2e2ce0eafd73acdcc65.zip
Initial import from kshowmail 3.3.1 sources
Diffstat (limited to 'kshowmail')
-rw-r--r--kshowmail/AlertDlg.ui114
-rw-r--r--kshowmail/Makefile.am60
-rw-r--r--kshowmail/alertdialog.cpp39
-rw-r--r--kshowmail/alertdialog.h40
-rw-r--r--kshowmail/configelem.cpp1759
-rw-r--r--kshowmail/configelem.h1097
-rw-r--r--kshowmail/configlist.cpp1203
-rw-r--r--kshowmail/configlist.h734
-rw-r--r--kshowmail/constants.h367
-rw-r--r--kshowmail/decodeRFC2047.cpp182
-rw-r--r--kshowmail/decodeRFC2047.h51
-rw-r--r--kshowmail/encryption.cpp85
-rw-r--r--kshowmail/encryption.h46
-rw-r--r--kshowmail/filteritem.cpp166
-rw-r--r--kshowmail/filteritem.h117
-rw-r--r--kshowmail/filteritemcriteria.cpp241
-rw-r--r--kshowmail/filteritemcriteria.h146
-rw-r--r--kshowmail/filterlog.cpp235
-rw-r--r--kshowmail/filterlog.h183
-rw-r--r--kshowmail/filterlogentry.cpp145
-rw-r--r--kshowmail/filterlogentry.h196
-rw-r--r--kshowmail/filterlogview.cpp121
-rw-r--r--kshowmail/filterlogview.h87
-rw-r--r--kshowmail/filterlogviewdeleteditem.cpp58
-rw-r--r--kshowmail/filterlogviewdeleteditem.h95
-rw-r--r--kshowmail/filterlogviewmoveditem.cpp58
-rw-r--r--kshowmail/filterlogviewmoveditem.h101
-rw-r--r--kshowmail/headerfilter.cpp151
-rw-r--r--kshowmail/headerfilter.h117
-rw-r--r--kshowmail/kcmconfigs/Makefile.am36
-rw-r--r--kshowmail/kcmconfigs/accountsetupdialog.cpp362
-rw-r--r--kshowmail/kcmconfigs/accountsetupdialog.h165
-rw-r--r--kshowmail/kcmconfigs/accountsetupitem.cpp207
-rw-r--r--kshowmail/kcmconfigs/accountsetupitem.h242
-rw-r--r--kshowmail/kcmconfigs/configaccounts.cpp203
-rw-r--r--kshowmail/kcmconfigs/configaccounts.h131
-rw-r--r--kshowmail/kcmconfigs/configactions.cpp267
-rw-r--r--kshowmail/kcmconfigs/configactions.h202
-rw-r--r--kshowmail/kcmconfigs/configdisplay.cpp221
-rw-r--r--kshowmail/kcmconfigs/configdisplay.h169
-rw-r--r--kshowmail/kcmconfigs/configfilter.cpp613
-rw-r--r--kshowmail/kcmconfigs/configfilter.h288
-rw-r--r--kshowmail/kcmconfigs/configgeneral.cpp181
-rw-r--r--kshowmail/kcmconfigs/configgeneral.h141
-rw-r--r--kshowmail/kcmconfigs/configlog.cpp255
-rw-r--r--kshowmail/kcmconfigs/configlog.h152
-rw-r--r--kshowmail/kcmconfigs/configspamcheck.cpp236
-rw-r--r--kshowmail/kcmconfigs/configspamcheck.h161
-rw-r--r--kshowmail/kcmconfigs/encryption.cpp85
-rw-r--r--kshowmail/kcmconfigs/encryption.h46
-rw-r--r--kshowmail/kcmconfigs/filtercriteriawidget.cpp338
-rw-r--r--kshowmail/kcmconfigs/filtercriteriawidget.h163
-rw-r--r--kshowmail/kcmconfigs/filtersetupdialog.cpp451
-rw-r--r--kshowmail/kcmconfigs/filtersetupdialog.h191
-rw-r--r--kshowmail/kcmconfigs/filtersetupitem.cpp347
-rw-r--r--kshowmail/kcmconfigs/filtersetupitem.h240
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfigaccounts.desktop20
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfigactions.desktop20
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfigdisplay.desktop19
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfigfilter.desktop19
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfiggeneral.desktop19
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfiglog.desktop16
-rw-r--r--kshowmail/kcmconfigs/kshowmailconfigspamcheck.desktop20
-rw-r--r--kshowmail/kcmconfigs/kwalletaccess.cpp137
-rw-r--r--kshowmail/kcmconfigs/kwalletaccess.h45
-rw-r--r--kshowmail/kcmconfigs/mailboxwizard.cpp164
-rw-r--r--kshowmail/kcmconfigs/mailboxwizard.h131
-rw-r--r--kshowmail/kcmconfigs/mailboxwizardlistitem.cpp28
-rw-r--r--kshowmail/kcmconfigs/mailboxwizardlistitem.h61
-rw-r--r--kshowmail/kcmconfigs/senderlistdialog.cpp151
-rw-r--r--kshowmail/kcmconfigs/senderlistdialog.h112
-rw-r--r--kshowmail/kfeedback.cpp504
-rw-r--r--kshowmail/kfeedback.h463
-rw-r--r--kshowmail/kshowmail.cpp861
-rw-r--r--kshowmail/kshowmail.desktop13
-rw-r--r--kshowmail/kshowmail.h424
-rw-r--r--kshowmail/kshowmaildoc.cpp81
-rw-r--r--kshowmail/kshowmaildoc.h81
-rw-r--r--kshowmail/kshowmaildock.cpp83
-rw-r--r--kshowmail/kshowmaildock.h46
-rw-r--r--kshowmail/kshowmailfeedback.cpp159
-rw-r--r--kshowmail/kshowmailui.rc45
-rw-r--r--kshowmail/kshowmailview.cpp449
-rw-r--r--kshowmail/kshowmailview.h157
-rw-r--r--kshowmail/kwalletaccess.cpp137
-rw-r--r--kshowmail/kwalletaccess.h45
-rw-r--r--kshowmail/main.cpp114
-rw-r--r--kshowmail/senderlistfilter.cpp102
-rw-r--r--kshowmail/senderlistfilter.h113
-rw-r--r--kshowmail/serverdialog.cpp336
-rw-r--r--kshowmail/serverdialog.h168
-rw-r--r--kshowmail/showheaderdialog.cpp52
-rw-r--r--kshowmail/showheaderdialog.h53
-rw-r--r--kshowmail/showlistviewitem.cpp114
-rw-r--r--kshowmail/showlistviewitem.h69
-rw-r--r--kshowmail/showmaildialog.cpp101
-rw-r--r--kshowmail/showmaildialog.h90
-rw-r--r--kshowmail/showrecord.cpp669
-rw-r--r--kshowmail/showrecord.h314
-rw-r--r--kshowmail/showrecordelem.cpp632
-rw-r--r--kshowmail/showrecordelem.h447
-rw-r--r--kshowmail/templates/cpp_template16
-rw-r--r--kshowmail/templates/header_template16
-rw-r--r--kshowmail/types.h122
-rw-r--r--kshowmail/uniqueapp.cpp78
-rw-r--r--kshowmail/uniqueapp.h65
106 files changed, 22268 insertions, 0 deletions
diff --git a/kshowmail/AlertDlg.ui b/kshowmail/AlertDlg.ui
new file mode 100644
index 0000000..506a530
--- /dev/null
+++ b/kshowmail/AlertDlg.ui
@@ -0,0 +1,114 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>AlertDlg</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>AlertDlg</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>271</width>
+ <height>127</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>KShowmail</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="2" column="2">
+ <property name="name">
+ <cstring>m_ButtonIgnore</cstring>
+ </property>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_ButtonOk</cstring>
+ </property>
+ <property name="text">
+ <string>Show main window</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>PixmapLabel2</cstring>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>QLabel_1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <bold>1</bold>
+ <italic>1</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>New mail</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>QLabel_2</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <bold>1</bold>
+ <italic>1</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>has arrived !</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="6670">789ced96db4e23471086ef790a8bba4351ade7e81945b98031272fc7656177897231278319836db0394579f7d454550ff6d86683b41b4511db5bb43f4fd3d57fffd53d7c586b7c3dda6fac7d58b91bc7e35eda482fe3dbc65a36b9be7efafd8fdffe5c59758306fdb72cb761affeb2b27a3c6ea48d83c14d5e02b609a0c9ff98ed92ada6955a41c9901bb6e5f9a9b0dd543e17760261489903331eb292ed267d239c289bf97c61331f9c289bf191b01bb8168fdf2fd9b11c5d2f7c346c87fcbc63d8e1f1f0593970f83998dfd7f96058b24be3953bc2aed98f436593df628e9da0c9fb8307257bb69b7abcb9782bec35953f2987c2f024dc0a5b0ef34838b0dc9879c3b08edf638e7dc3cf25fbb6edaade96b01be8f35de16afc99615fd6b3a96cf23f32c7663fb12c0e68394e53c7df0bbbaa0706c2d5efdf08b73c1d7f673890e7a7caa1f27ac981e3653eebc51361df12bf90fd0a5d3f54ffdac2a115bbcc7de1384e84797d611ae7f21cb91e62b75aef8370188632fe4a388e538fb9104e6c9dbf279c1ade14ce6dc987ec47e2ba81aed7136e197fb799b340f5e24038b7251f364b4e3de33f4e84533b93e743655d1f8e8433bbeb3347c2d57c41c9991758eac78e709c8729f35838f5938cc7f7853393afa79c2b17c2b9797ea99c67725f6c19ce653d0fc25d5b18b8feb3dc577f41c6e7a11724cc87c2b1a77e39caea1fa0b0f103bf29c7525f3031acfe5f08a7b1eabb16ce0ce7c2b9591fd767eed37d24e7f748b895e9fe1d0b937fb2de583913467d1e5a7a1f7c5136faba86a5def04638337e5e0957fb9b1ad6fdd4dfefdaa9acffc2b08ecf94631d0fca5da90fe0fb88ccf13c395f1bcaa19ecf4761d22beb15fdb49f5a2f7c5f757d735fe393b0e36abdbbc2aeabfacf94cdfdf85539d5fbec5ad86b0a6328ec9bfb6247d8ec3f26c25d53efb1b2ea43beffbaddea7db52b5cbd5f2e2b167fd795cdfb0c84cdfb01b785cd7a8fc73fb7bde778cff19ee3bf900301e31f1d7339124c31c39c22a596f3cf14bb14171497143d8e2b8a62aaef735c53dc500c28861c23ca728b77351d098ea94d34ee354bd91eaa78c4277ca6b68e1b94c1b47e1591e618d127c03665d99cca11bfaa618bfb6d9ebf873bdcefb28e624a43841dfc887b14fbaca38d0778b840c798669318cf6978e656d067f97434a5a154d0c763caf6094ff033a929739ccee448bea3e10acf74e62f34a37cfa3ae34344ed1b9ed32e37d1521d764d87acfd5e75dcab2ad150cce870f4933ba5417478e853961606eac7ac8e173f8c86172d575a47219e01620f407240cc1aa6fc8004cf21a5c864af209ff3235dd05efc28380ae8aa8a75ad296911cd1a55fdf08d7ecc9c0bb8804bcde12c3917436efd257ed41af4e0aad400e5eacba0bd876bd5f0a5565366fd91e62896f851d7d0861b18d01a47d40f61447ccb3edcc178e65c88e303d660a258e847dd87a21e30610d8f3367dbd4d4b486653a92f97301035a3bf9401aeee1013b544fbbf048fc201a6058d3307c831f5a4bf0844378a20c7d1a1d41b94bebf4a9800dca52f611b4e7bca080cda57ed4cf76af3a171cb045f755edbb053e488b5ef563ea3c900e52401515d1ae44b00d3bb47bec0355c2036e72dfa1756fd0b8ce8c1ffd257ed4efa71efb31a29d296054cec635d6865d9a7b041dee3f963db53de8e8ec13fe39307ec07e4d47fd4c57679b341d704d850b6ba95653d37ecce48817dc4fe65df7720b3ec3e1d4b998f7a1cc70445a2a3fe6742cbc9f66eea86738aeeea785e7a2d440d15fa82359f2ded6905b0a3e2dbd9fc469f3fd3ff7a3d0be2f5a48c3cbfbfbfbfd223fe087b79a1f94a5fd13da692dc71ddec2c9a24627c9a6d1f9db7bf83c9be3780ca7704a7f112d6f87af35d85fd8cefeddbf77df73bce778cff1bfcef1d7af2b7f0349d57768</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>m_ButtonIgnore</sender>
+ <signal>clicked()</signal>
+ <receiver>AlertDlg</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>m_ButtonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>AlertDlg</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>m_ButtonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>AlertDlg</receiver>
+ <slot>slotOk()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>m_ButtonOk</tabstop>
+ <tabstop>m_ButtonIgnore</tabstop>
+</tabstops>
+<slots>
+ <slot>slotOk()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kshowmail/Makefile.am b/kshowmail/Makefile.am
new file mode 100644
index 0000000..bf6eda0
--- /dev/null
+++ b/kshowmail/Makefile.am
@@ -0,0 +1,60 @@
+####### kdevelop will overwrite this part!!! (begin)##########
+bin_PROGRAMS = kshowmail
+
+## INCLUDES were found outside kdevelop specific part
+
+kshowmail_SOURCES = AlertDlg.ui alertdialog.cpp configelem.cpp configlist.cpp \
+ decodeRFC2047.cpp encryption.cpp filteritem.cpp filteritemcriteria.cpp filterlog.cpp \
+ filterlogentry.cpp headerfilter.cpp kfeedback.cpp kshowmail.cpp kshowmaildoc.cpp \
+ kshowmaildock.cpp kshowmailfeedback.cpp kshowmailview.cpp kwalletaccess.cpp main.cpp \
+ senderlistfilter.cpp serverdialog.cpp showheaderdialog.cpp showlistviewitem.cpp \
+ showmaildialog.cpp showrecord.cpp showrecordelem.cpp uniqueapp.cpp filterlogview.cpp \
+ filterlogviewdeleteditem.cpp filterlogviewmoveditem.cpp
+kshowmail_LDADD = $(LIB_KUTILS) -lmimelib $(LIB_KFILE) $(LIB_KDEUI) \
+ $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
+
+
+EXTRA_DIST = main.cpp kshowmail.cpp kshowmail.h kshowmaildoc.cpp kshowmaildoc.h commandentry.cpp commandentry.h kshowmailview.cpp kshowmailview.h OptionDlg.ui OptionDlg.h optiondialog.cpp optiondialog.h ServerDlg.ui serverdialog.cpp serverdialog.h EditDlg.ui editdialog.cpp editdialog.h commanddialog.cpp commanddialog.h CommandDlg.ui commandlist.cpp commandlist.h CommandEntryDlg.ui commandentrydialog.cpp commandentrydialog.h configelem.cpp configelem.h kshowmaildock.cpp kshowmaildock.h configlist.cpp configlist.h AlertDlg.ui alertdialog.cpp alertdialog.h uniqueapp.cpp uniqueapp.h showrecordelem.cpp showrecordelem.h showrecord.cpp showrecord.h kshowmail.desktop decodeRFC2047.h decodeRFC2047.cpp showlistviewitem.cpp showlistviewitem.h kfeedback.cpp kfeedback.h kshowmailfeedback.cpp filter.cpp filter.h filterelem.cpp filterelem.h filterdialog.cpp filterdialog.h FilterDlg.ui FilterEntryDlg.ui filterentrydialog.cpp filterentrydialog.h filterlist.cpp filterlist.h logger.cpp logger.h
+
+
+####### kdevelop will overwrite this part!!! (end)############
+# this 10 paths are KDE specific. Use them:
+# kde_htmldir Where your docs should go to. (contains lang subdirs)
+# kde_appsdir Where your application file (.kdelnk) should go to.
+# kde_icondir Where your icon should go to.
+# kde_minidir Where your mini icon should go to.
+# kde_datadir Where you install application data. (Use a subdir)
+# kde_locale Where translation files should go to.(contains lang subdirs)
+# kde_cgidir Where cgi-bin executables should go to.
+# kde_confdir Where config files should go to.
+# kde_mimedir Where mimetypes should go to.
+# kde_toolbardir Where general toolbar icons should go to.
+# kde_wallpaperdir Where general wallpapers should go to.
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+METASOURCES = AUTO
+
+# the library search path.
+kshowmail_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+rcdir = $(kde_datadir)/kshowmail
+rc_DATA = kshowmailui.rc
+
+messages: rc.cpp
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/kshowmail.pot; \
+ fi
+
+noinst_HEADERS = constants.h encryption.h filteritem.h filteritemcriteria.h \
+ filterlog.h filterlogentry.h headerfilter.h kshowmail.desktop kwalletaccess.h \
+ senderlistfilter.h showheaderdialog.h showmaildialog.h types.h filterlogview.h \
+ filterlogviewdeleteditem.h filterlogviewmoveditem.h
+
+shelldesktopdir = $(kde_appsdir)/Internet
+shelldesktop_DATA = kshowmail.desktop
+
+KDE_ICON = kshowmail
+SUBDIRS = kcmconfigs
diff --git a/kshowmail/alertdialog.cpp b/kshowmail/alertdialog.cpp
new file mode 100644
index 0000000..b80f976
--- /dev/null
+++ b/kshowmail/alertdialog.cpp
@@ -0,0 +1,39 @@
+/***************************************************************************
+ alertdialog.cpp - description
+ -------------------
+ begin : Sun Nov 4 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "alertdialog.h"
+
+AlertDialog::AlertDialog(QWidget *parent, const char *name ):
+ AlertDlg(parent,name,true)
+{
+ // position the dialog at the upper left corner of the main window.
+ // if the main window is iconized, the last position on screen is used.
+ setGeometry (parent->x (), parent->y (), width (), height ());
+
+ // now show the dialog
+ show ();
+}
+
+AlertDialog::~AlertDialog()
+{
+}
+
+void AlertDialog::slotOk ()
+{
+ emit signalOk ();
+}
+
diff --git a/kshowmail/alertdialog.h b/kshowmail/alertdialog.h
new file mode 100644
index 0000000..ba1cb2b
--- /dev/null
+++ b/kshowmail/alertdialog.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ alertdialog.h - description
+ -------------------
+ begin : Sun Nov 4 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef ALERTDIALOG_H
+#define ALERTDIALOG_H
+
+#include <qwidget.h>
+#include "AlertDlg.h"
+
+/**
+ *@author Eggert Ehmke
+ */
+
+class AlertDialog : public AlertDlg
+{
+ Q_OBJECT
+public:
+ AlertDialog(QWidget *parent=0, const char *name=0);
+ ~AlertDialog();
+public slots:
+ void slotOk ();
+signals:
+ void signalOk ();
+};
+
+#endif
diff --git a/kshowmail/configelem.cpp b/kshowmail/configelem.cpp
new file mode 100644
index 0000000..9941c75
--- /dev/null
+++ b/kshowmail/configelem.cpp
@@ -0,0 +1,1759 @@
+/***************************************************************************
+ ConfigElem.cpp - description
+ -------------------
+ begin : Tue May 9 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "configelem.h"
+
+int const ConfigElem::continueShowHeaders( 0 );
+int const ConfigElem::cancelShowHeaders( 1 );
+
+
+ConfigElem::ConfigElem( ) : QObject()
+{
+ //initialize account
+ init();
+
+ //set default values
+ m_url.setProtocol( "pop3" );
+ m_url.setPort( 110 );
+ m_bActive = false;
+ appConfig = NULL;
+ m_strAccount = "";
+}
+
+ConfigElem::ConfigElem( ConfigList* config ) : QObject()
+{
+ //initialize account
+ init();
+
+ m_url.setProtocol( "pop3" );
+ m_url.setPort (110);
+
+ m_bActive = false;
+
+ appConfig = config;
+
+}
+
+ConfigElem::ConfigElem( ConfigElem* pElem ) : QObject()
+{
+ //initialize account
+ init();
+
+ //set active by default
+ m_bActive = pElem->isActive();
+
+ //copy some interesting stuff from the sample
+ //the url object contains all necessary information about the server
+ m_strAccount = pElem->getAccountName();
+ m_url = pElem->getURL();
+ appConfig = pElem->appConfig;
+
+}
+
+ConfigElem::ConfigElem( ConfigList* config, const QString& account ) : QObject()
+{
+ //initialize account
+ init();
+
+ //set account name
+ m_strAccount = account;
+
+ //deactivate it by default
+ m_bActive = false;
+
+ //set the pointer to the general app configuration
+ appConfig = config;
+}
+
+void ConfigElem::init( )
+{
+ //initialize timeout timer
+ pop3Timer = new QTimer( this );
+ connect( pop3Timer, SIGNAL( timeout() ), this, SLOT( slotTimeout() ) );
+
+ //state is idle
+ state = AccountIdle;
+
+ //create new empty mail list
+ m_pshowrecord = new ShowRecord();
+
+ //the account has no appropriate account list view item yet
+ m_pViewItem = NULL;
+
+ //set default values
+ PasswordStorage = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+ filterApplied = false;
+ deletionPerformedByFilters = false;
+ refreshPerformedByFilters = false;
+ downloadActionsInvoked = false;
+
+ //initialize counters
+ moveCounter = 0;
+ nmbDeletedMailsLastRefresh = 0;
+ nmbDeletedMailsLastStart = 0;
+ nmbMovedMailsLastRefresh = 0;
+ nmbMovedMailsLastStart = 0;
+ nmbIgnoredMails = 0;
+}
+
+
+ConfigElem::~ConfigElem()
+{
+ // do not delete m_pshowrecord here
+}
+
+void ConfigElem::saveOptions( QDomDocument& doc, QDomElement& parent )
+{
+ //get application config
+ KConfig* config = KApplication::kApplication()->config();
+
+ //save the active state
+ config->setGroup( getAccountName() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, m_bActive );
+ config->sync();
+
+ //save the stored mails inside this account
+ parent.setAttribute( ATTRIBUTE_ACCOUNT_NAME, m_strAccount );
+ m_pshowrecord->saveOptions( doc, parent );
+}
+
+void ConfigElem::readStoredMails( QDomElement& parent )
+{
+ //get mails
+ m_pshowrecord->readStoredMails( parent );
+}
+
+
+int ConfigElem::count()
+{
+ return m_pshowrecord->count();
+}
+
+bool ConfigElem::isActive( ) const
+{
+ return m_bActive;
+}
+
+void ConfigElem::setActive( bool active )
+{
+ m_bActive = active;
+}
+
+QString ConfigElem::getAccountName( ) const
+{
+ return m_strAccount;
+}
+
+void ConfigElem::setAccountName( QString name )
+{
+ if( name != NULL )
+ m_strAccount = name;
+}
+
+QString ConfigElem::getPassword( ) const
+{
+ return m_url.pass();
+}
+
+void ConfigElem::setPassword( const QString& password )
+{
+ m_url.setPass( password );
+}
+
+KURL ConfigElem::getURL( ) const
+{
+ return m_url;
+}
+
+bool ConfigElem::hasPassword( ) const
+{
+ return m_url.hasPass();
+}
+
+void ConfigElem::setListViewItem( QListViewItem* item )
+{
+ m_pViewItem = item;
+}
+
+QListViewItem * ConfigElem::getListViewItem( )
+{
+ return m_pViewItem;
+}
+
+bool ConfigElem::isSelected( ) const
+{
+ if( m_pViewItem == NULL )
+
+ return false;
+
+ else
+
+ return m_pViewItem->isSelected();
+}
+
+void ConfigElem::clearMailList( )
+{
+ if( m_pshowrecord == NULL )
+ //there is no mail list yet, create a one
+ m_pshowrecord = new ShowRecord;
+ else
+ //clear the existing mail list
+ m_pshowrecord->clear();
+}
+
+void ConfigElem::setHost( const QString& host )
+{
+ m_url.setHost( host );
+}
+
+void ConfigElem::setProtocol( const QString& protocol )
+{
+ m_url.setProtocol( protocol );
+}
+
+void ConfigElem::setPort( unsigned short int port )
+{
+ m_url.setPort( port );
+}
+
+void ConfigElem::setUser( const QString & user )
+{
+ m_url.setUser( user );
+}
+
+QString ConfigElem::getUser( ) const
+{
+ return m_url.user();
+}
+
+QString ConfigElem::getHost( ) const
+{
+ return m_url.host();
+}
+
+void ConfigElem::deleteSelectedMails( )
+{
+ //return if this account has no selected mails or
+ //the account is not idle or the account is not active
+ if( !m_pshowrecord->hasSelectedMails() || state != AccountIdle || !isActive() )
+ {
+ emit sigDeleteReady( m_strAccount );
+ return;
+ }
+
+ //check whether we have a password for this account
+ //if not, ask for it
+ //return when no password is available
+ if( !assertPassword() )
+ {
+ emit sigDeleteReady( m_strAccount );
+ return;
+ }
+
+ //get the numbers of all selected mails
+ MailsToDelete = m_pshowrecord->getSelectedMails();
+ if( MailsToDelete.empty() )
+ {
+ kdError() << "ConfigElem::deleteSelectedMails (Account " << m_strAccount << "): The account has selected mails to delete but ShowRecord::getSelectedMails has returned an empty list." << endl;
+ emit sigDeleteReady( m_strAccount );
+ return;
+ }
+
+ //set account state
+ state = AccountDeleting;
+
+ //start the deleting of all mails in MailsToDelete
+ deleteNextMail();
+}
+
+bool ConfigElem::assertPassword( bool force )
+{
+ //is a password stored?
+ if ( !hasPassword() || force )
+ {
+ //no password found, we will ask the user!
+ //set normal cursor
+ while( QApplication::overrideCursor() )
+ QApplication::restoreOverrideCursor();
+
+ QCString password; //for the password dialog to store the password
+ int result = KPasswordDialog::getPassword( password, i18n( "Please type in the password for %1" ).arg( getAccountName() ) );
+
+ //set waiting cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ //let's look, what the user has done :o)
+ if( result == KPasswordDialog::Accepted )
+ {
+ //the user has clicked OK in the password dialog
+ //store the password
+ setPassword( password );
+
+ //save password in file or KWallet
+ KConfig* config = KApplication::kApplication()->config();
+ config->setGroup( getAccountName() );
+
+ if( PasswordStorage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE )
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, crypt( m_url ) );
+ else
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, QString::null );
+
+ if( PasswordStorage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ KWalletAccess::savePassword( getAccountName(), m_url.pass() );
+
+ config->sync();
+
+ //emit configuration changed signal
+ emit ( sigConfigChanged() );
+
+ //tell we have a password
+ return true;
+ }
+ else
+ //the user has clicked Cancel in the password dialog; we don't have a password
+ return false;
+ }
+ else
+ //we have already a password for this account
+ return true;
+
+}
+
+void ConfigElem::deleteNextMail( )
+{
+ //if the list of mails to delete is empty, finalize the deletion and return
+ if( MailsToDelete.empty() )
+ {
+ if( deletionPerformedByFilters )
+ {
+ applyFiltersDeleted();
+ }
+ else
+ {
+ commitDeletion();
+ }
+ return;
+ }
+
+ //start job
+ startKIOJob( QString( "/remove/%1" ).arg( *MailsToDelete.begin() ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotMailDeleted( KIO::Job* ) ) );
+}
+
+void ConfigElem::slotMailDeleted( KIO::Job* job )
+{
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error is occured, the deletion will be canceled
+ //or will ask for a new password
+ if( job->error() == KIO::ERR_COULD_NOT_LOGIN )
+ {
+ //login failed, ask for a new password
+ job->showErrorDialog();
+ bool res = assertPassword( true );
+ if( res == false )
+ {
+ //we have not got a new password; cancel delete
+ if( deletionPerformedByFilters )
+ {
+ applyFiltersDeleted();
+ }
+ else
+ {
+ slotFinalizeDeletion( NULL );
+ }
+ return;
+ }
+ //if we have got a new password, it jumps to the end of the if-statement
+ }
+ else if( job->error() != 0 )
+ {
+ //unknown error, show message and cancel delete
+ job->showErrorDialog();
+ if( deletionPerformedByFilters )
+ {
+ applyFiltersDeleted();
+ }
+ else
+ {
+ slotFinalizeDeletion( NULL );
+ }
+ return;
+ }
+ else
+ {
+ //operation was successful
+ //remove the deleted mail from the internal mail list
+ m_pshowrecord->removeMail( *MailsToDelete.begin() );
+
+ //remove the first item of the list of mails to delete
+ MailsToDelete.remove( MailsToDelete.begin() );
+
+ //if the list of mails to delete is empty, finalize the deletion and return
+ if( MailsToDelete.empty() )
+ {
+ if( deletionPerformedByFilters )
+ {
+ applyFiltersDeleted();
+ }
+ else
+ {
+ commitDeletion();
+ }
+ return;
+ }
+ }
+
+ //delete next mail in list
+ deleteNextMail();
+
+
+}
+
+void ConfigElem::slotFinalizeDeletion( KIO::Job* )
+{
+ //stop timeout time
+ pop3Timer->stop();
+
+ //set account state to idle
+ state = AccountIdle;
+
+ //emit signal to report the deletion is ready
+ emit sigDeleteReady( m_strAccount );
+}
+
+void ConfigElem::startKIOJob( const QString & path )
+{
+ KIO::MetaData options; //options for the pop3 job
+
+ //set options
+ options.insert( "progress", "off" );
+ options.insert( "pipelining", "off" );
+
+ if( useTLS )
+ options.insert( "tls", "on" );
+ else
+ options.insert( "tls", "off" );
+
+ //Where is secure login?
+ //I have decided against a configurable secure login because the used POP3 kioslave
+ //always tries to login with APOP, if the server has sent a timestap (inside of the greeting string) for this authentification type.
+ //It just follows the auth-metadata, if the server doesn't support APOP (no timestamp inside of the greeting string).
+ //But I think, there is no server, which support a SASL authentification without also provide APOP.
+ //Ulrich Weigelt
+
+ //set the given command and parameters
+ m_url.setPath( path );
+
+ //print debug message
+ kdDebug() << "ConfigElem::startKIOJob: start KIO job on URL " << m_url.url() << endl;
+
+ //start the job and get handle to it
+ pop3Job = KIO::get( m_url, false, false );
+
+ //put options to the job
+ pop3Job->addMetaData( options );
+
+ //start timeout timer
+ pop3Timer->start( getTimeoutTime() * 1000, true );
+}
+
+Types::AccountState_Type ConfigElem::getState( )
+{
+ return state;
+}
+
+void ConfigElem::commitDeletion( )
+{
+ //start job to commit
+ startKIOJob( QString( "/commit" ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotFinalizeDeletion( KIO::Job* ) ) );
+}
+
+unsigned int ConfigElem::getTimeoutTime( )
+{
+ //return default time, if the configuration is not accessable
+ if( appConfig == NULL )
+ return DEFAULT_TIMEOUT_TIME;
+
+ //get time from configuration
+ unsigned int time = appConfig->getTimeoutTime();
+
+ //take minimum time, if get time is less
+ if( time < MINIMUM_TIMEOUT_TIME )
+ time = MINIMUM_TIMEOUT_TIME;
+
+ return time;
+}
+
+void ConfigElem::slotTimeout( )
+{
+ //kill a running job
+ if( pop3Job != NULL )
+ pop3Job->kill( true );
+
+ //show error message (during refresh if desired only)
+ kdError() << "Timeout error!" << endl;
+
+ if( state != AccountRefreshing || appConfig->showConnectionErrors() )
+ KMessageBox::error( NULL, QString( i18n( "Time out on %1. The operation could not be finished on time" ) ).arg( m_strAccount ), i18n( "Time Out" ) );
+
+ //call the appropriate finalize methode
+ switch( state )
+ {
+ case AccountIdle : break;
+ case AccountDeleting : slotFinalizeDeletion( NULL ); break;
+ case AccountDownloading : slotFinalizeShowMail( NULL ); break;
+ case AccountRefreshing : cancelRefresh(); break;
+
+ default : break;
+ }
+}
+
+QStringList ConfigElem::getSelectedSubjects( ) const
+{
+ return m_pshowrecord->getSelectedSubjects();
+}
+
+bool ConfigElem::hasSelectedMails( )
+{
+ return m_pshowrecord->hasSelectedMails();
+}
+
+void ConfigElem::showSelectedMails( )
+{
+ //return if this account has no selected mails or
+ //the account is not idle or the account is not active
+ if( !m_pshowrecord->hasSelectedMails() || state != AccountIdle || !isActive() )
+ {
+ emit sigShowBodiesReady( m_strAccount );
+ return;
+ }
+
+ //check whether we have a password for this account
+ //if not, ask for it
+ //return when no password is available
+ if( !assertPassword() )
+ {
+ emit sigShowBodiesReady( m_strAccount );
+ return;
+ }
+
+ //get the numbers of all selected mails
+ MailsToShow = m_pshowrecord->getSelectedMails();
+ if( MailsToShow.empty() )
+ {
+ kdError() << "ConfigElem::showSelectedMails (Account " << m_strAccount << "): The account has selected mails to show but ShowRecord::getSelectedMails has returned an empty list." << endl;
+ emit sigShowBodiesReady( m_strAccount );
+ return;
+ }
+
+ //set account state
+ state = AccountDownloading;
+
+ //start the deleting of all mails in MailsToDelete
+ showNextMail();
+
+}
+
+void ConfigElem::showNextMail( )
+{
+ //if the list of mails to show is empty, finalize it and return
+ if( MailsToShow.empty() )
+ {
+ slotFinalizeShowMail( NULL );
+ return;
+ }
+
+ //clear the class variable mailbody, which contains the downloaded mail body
+ mailbody.resize( 0 );
+
+ //start job
+ startKIOJob( QString( "/download/%1" ).arg( *MailsToShow.begin() ) );
+ connect( pop3Job, SIGNAL( data( KIO::Job*, const QByteArray & ) ), SLOT( slotDataMailBody( KIO::Job*, const QByteArray & ) ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotBodyDownloaded( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotBodyDownloaded( KIO::Job * job )
+{
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error has occured, the download will be canceled
+ //or will ask for a new password
+ if( job->error() == KIO::ERR_COULD_NOT_LOGIN )
+ {
+ //login failed, ask for a new password
+ job->showErrorDialog();
+ bool res = assertPassword( true );
+ if( res == false )
+ {
+ //we have not got a new password; cancel delete
+ slotFinalizeShowMail( NULL );
+ return;
+ }
+ //if we have got a new password, jump to the end of the if-statement
+ }
+ else if( job->error() != 0 )
+ {
+ job->showErrorDialog();
+ slotFinalizeShowMail( NULL );
+ return;
+ }
+ else
+ {
+ //succesful download
+ //show mail
+ int currentMail = *MailsToShow.begin();
+ QString tsender = m_pshowrecord->getSenderOf( currentMail );
+ QString tdate = m_pshowrecord->getDateOf( currentMail );
+ QString tsize = m_pshowrecord->getSizeOf( currentMail );
+ QString tsubject = m_pshowrecord->getSubjectOf( currentMail );
+ QString tmailbody( m_pshowrecord->decodeMailBody( mailbody, currentMail, appConfig->allowHTML() ) );
+
+ //emit signal to notify the opening of a window
+ emit sigMessageWindowOpened();
+
+ //create and open the window
+ ShowMailDialog dlg( kapp->mainWidget(), m_strAccount, appConfig->allowHTML(), tsender, tdate, tsize, tsubject, tmailbody );
+ int ret = dlg.exec();
+
+ //emit signal to notify the closing of a window
+ emit sigMessageWindowClosed();
+
+ //cancel the download if desired
+ if( ret == KDialogBase::Rejected )
+ {
+ MailsToShow.clear();
+ commitDownloading();
+ return;
+ }
+
+ //remove the first item of the list of mails to show
+ MailsToShow.remove( MailsToShow.begin() );
+
+ //if the list of mails is empty, finalize the showing and return
+ if( MailsToShow.empty() )
+ {
+ commitDownloading();
+ return;
+ }
+ }
+
+
+ //show next mail in list
+ showNextMail();
+}
+
+void ConfigElem::slotFinalizeShowMail( KIO::Job* )
+{
+ //stop timeout time
+ pop3Timer->stop();
+
+ //set account state to idle
+ state = AccountIdle;
+
+ //emit signal to report the download is ready
+ emit sigShowBodiesReady( m_strAccount );
+}
+
+void ConfigElem::slotDataMailBody( KIO::Job *, const QByteArray & datas )
+{
+ if( !datas.isEmpty() )
+ {
+ //we get the next part of the mail
+ //append it
+ uint lastSize = mailbody.size();
+ mailbody.resize( lastSize + datas.size() );
+ for( uint i = 0; i < datas.size(); i++ )
+ mailbody[ lastSize + i ] = datas[ i ];
+ }
+}
+
+void ConfigElem::commitDownloading( )
+{
+ //start job to commit
+ startKIOJob( QString( "/commit" ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotFinalizeShowMail( KIO::Job* ) ) );
+}
+
+void ConfigElem::refreshMailList( FilterLog* log )
+{
+ //store pointer to log
+ if( log != NULL )
+ FLog = log;
+
+ //return, if account is not active
+ if( !isActive() )
+ {
+ emit sigRefreshReady( m_strAccount );
+ return;
+ }
+
+ //check whether we have a password for this account
+ //if not, ask for it
+ //return when no password is available
+ if( !assertPassword() )
+ {
+ emit sigRefreshReady( m_strAccount );
+ return;
+ }
+
+ //create a new ShowRecord instance
+ //When the refresh has finished successfully, this will
+ //replace the old mail list
+ tempMailList = new ShowRecord();
+
+ //set account state
+ state = AccountRefreshing;
+
+ //init counter
+ if( !refreshPerformedByFilters )
+ {
+ nmbDeletedMailsLastRefresh = 0;
+ nmbMovedMailsLastRefresh = 0;
+ nmbIgnoredMails = 0;
+ }
+
+ //the first step is to get the UIDs
+ getUIDs();
+}
+
+void ConfigElem::getUIDs( )
+{
+ //clears the QString list, which contains all received UIDs
+ receivedUIDs.clear();
+
+ //start job
+ startKIOJob( QString( "/uidl" ) );
+ connect( pop3Job, SIGNAL( data( KIO::Job*, const QByteArray & ) ), SLOT( slotReceiveUID( KIO::Job*, const QByteArray & ) ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotUIDsReceived( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotReceiveUID( KIO::Job*, const QByteArray& data )
+{
+ //return, when data is empty
+ if( data.isEmpty() ) return;
+
+ //cast the data to QString
+ QString uid( data );
+
+ //insert the uid at the end of the UID list
+ receivedUIDs.append( uid );
+}
+
+void ConfigElem::slotUIDsReceived( KIO::Job * job )
+{
+ int number; //an extracted mail number
+ QString uid; //an extracted uid
+ bool corruptData = false; //set to TRUE, if a data is corrupt
+ bool isNew = false; //state of the received mail
+
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error has occured, the refresh will be canceled
+ //or will ask for a new password
+ if( job->error() == KIO::ERR_COULD_NOT_LOGIN )
+ {
+ //login failed, ask for a new password
+ job->showErrorDialog();
+ bool res = assertPassword( true );
+ if( res == true )
+ {
+ //we have got a new password, try again
+ delete tempMailList;
+ refreshMailList();
+ }
+ else
+ //we have not got a new password; cancel refresh
+ cancelRefresh();
+
+ return;
+ }
+ else if( job->error() != 0 )
+ {
+ //show error message if desired
+ if( appConfig->showConnectionErrors() )
+ job->showErrorDialog();
+
+ cancelRefresh();
+ return;
+ }
+
+ //analyze UIDs
+ if( !receivedUIDs.isEmpty() )
+ {
+ //iterate over all UIDs in the list
+ for ( QStringList::Iterator it = receivedUIDs.begin(); it != receivedUIDs.end(); ++it )
+ {
+ QString line = *it;
+
+ //every line has the format "number UID", e.g.: 1 bf10d38018de7c1d628d65288d722f6a
+ //get the position of the separating space
+ int positionOfSpace = line.find( " " );
+
+ //if no space was found, the line is corrupt
+ if( positionOfSpace == -1 )
+ {
+ kdError() << "ConfigElem::slotUIDsReceived: get a corrupt UID from " << dynamic_cast<KIO::SimpleJob*>(job)->url().host() << ". No space. : " << line << endl;
+ corruptData = true;
+ }
+ else
+ {
+ //extract mail number and uid
+ bool isNumber;
+ number = line.left( positionOfSpace ).toInt( &isNumber );
+ //check number
+ if( !isNumber )
+ {
+ //the first part is not a number
+ kdError() << "ConfigElem::slotUIDsReceived: get a corrupt UID from " << dynamic_cast<KIO::SimpleJob*>(job)->url().host() << ". No number found at begin. : " << line << endl;
+ corruptData = true;
+ }
+ else
+ {
+ //number is ok; extract uid
+ uid = line.mid( positionOfSpace + 1 );
+
+ //determine about new mail or not
+ if( !m_pshowrecord->hasMail( uid ) )
+ {
+ //the old list doesn't contain a mail with this uid
+ //the mail is new
+ isNew = true;
+ }
+ else if( ( appConfig->keepNew() || refreshPerformedByFilters ) && m_pshowrecord->isNew( uid ) )
+ {
+ //the mail is already in the old list
+ //but we will leave the state of formerly new mails, because the user wants it or this refresh is performed by filters
+ isNew = true;
+ }
+ else
+ isNew = false;
+
+ //append mail to the list
+ tempMailList->appendNewMail( number, uid, isNew );
+
+ }
+ }
+ }
+
+ //if the data are ok, start the second step: get sizes
+ //otherwise cancel the refresh
+ if( !corruptData )
+ getSizes();
+ else
+ cancelRefresh();
+ }
+ else
+ {
+ //we haven't received any UIDs. The account has no mails.
+ //finalize the refresh
+ swapMailLists();
+ }
+
+}
+
+void ConfigElem::cancelRefresh()
+{
+ //print error message
+ kdError() << m_strAccount << ": " << "Refresh canceled" << endl;
+
+ //delete the new mail list
+ delete tempMailList;
+
+ //delete old mail list and create a new empty one
+ delete m_pshowrecord;
+ m_pshowrecord = new ShowRecord();
+
+ //emit signal
+ emit sigRefreshReady( m_strAccount );
+
+ //set account state to idle
+ state = AccountIdle;
+
+ //we don't need an error message, because the KIO job has shown one
+}
+
+void ConfigElem::slotFinalizeRefresh( KIO::Job* )
+{
+ //stop timeout time
+ pop3Timer->stop();
+
+ //unset the flag
+ refreshPerformedByFilters = false;
+
+ //emit signal
+ emit sigRefreshReady( m_strAccount );
+
+ //set account state to idle
+ state = AccountIdle;
+
+
+}
+
+void ConfigElem::commitRefresh( )
+{
+ //start job to commit
+ startKIOJob( QString( "/commit" ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotFinalizeRefresh( KIO::Job* ) ) );
+}
+
+void ConfigElem::getSizes( )
+{
+ //clears the QString list, which contains all received UIDs
+ receivedSizes.clear();
+
+ //start job
+ startKIOJob( QString( "/index" ) );
+ connect( pop3Job, SIGNAL( data( KIO::Job*, const QByteArray & ) ), SLOT( slotReceiveSize( KIO::Job*, const QByteArray & ) ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotSizesReceived( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotSizesReceived( KIO::Job * job )
+{
+ int number; //an extracted mail number
+ long size; //an extracted size
+ bool corruptData = false; //set to TRUE, if a data is corrupt
+
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error has occured, the refresh will be canceled
+ if( job->error() != 0 )
+ {
+ //show error message if desired
+ if( appConfig->showConnectionErrors() )
+ job->showErrorDialog();
+ cancelRefresh();
+ return;
+ }
+
+ //analyze UIDs
+ if( !receivedSizes.isEmpty() )
+ {
+ //iterate over all sizes in the list
+ for ( QStringList::Iterator it = receivedSizes.begin(); it != receivedSizes.end(); ++it )
+ {
+ QString line = *it;
+
+ //every line has the format "number size", e.g.: 1 1234
+ //get the position of the separating space
+ int positionOfSpace = line.find( " " );
+
+ //if no space was found, the line is corrupt
+ if( positionOfSpace == -1 )
+ {
+ kdError() << "ConfigElem::slotSizesReceived: get a corrupt size from " << dynamic_cast<KIO::SimpleJob*>(job)->url().host() << ". No space. : " << line << endl;
+ corruptData = true;
+ }
+ else
+ {
+ //extract mail number and size
+ bool isNumber;
+ number = line.left( positionOfSpace ).toInt( &isNumber );
+ //check number
+ if( !isNumber )
+ {
+ //the first part is not a number
+ kdError() << "ConfigElem::slotSizesReceived: get a corrupt size from " << dynamic_cast<KIO::SimpleJob*>(job)->url().host() << ". No number found at begin. : " << line << endl;
+ corruptData = true;
+ }
+ else
+ {
+ //number is ok; extract size
+ size = line.mid( positionOfSpace + 1 ).toLong( &isNumber );
+
+ //check size
+ if( !isNumber )
+ {
+ //the second part of the string is not a number
+ kdError() << "ConfigElem::slotSizesReceived: get a corrupt size from " << dynamic_cast<KIO::SimpleJob*>(job)->url().host() << ". No size found at end. : " << line << endl;
+ corruptData = true;
+ }
+ else
+ {
+ //size is ok
+ //set it
+ tempMailList->setSize( number, size );
+ }
+ }
+ }
+ }
+
+ //if the data are ok, start the third step: get headers
+ //otherwise cancel the refresh
+ if( !corruptData )
+ getHeaders();
+ else
+ cancelRefresh();
+ }
+}
+
+void ConfigElem::slotReceiveSize( KIO::Job *, const QByteArray & data )
+{
+ //return, when data is empty
+ if( data.isEmpty() ) return;
+
+ //cast the data to QString
+ QString size( data );
+
+ //insert the uid at the end of the sizes list
+ receivedSizes.append( size );
+
+}
+
+void ConfigElem::getHeaders( )
+{
+ //get the numbers of all new mails
+ newMails = tempMailList->getNewMails();
+ if( newMails.empty() )
+ {
+ //no new mails available; copy the known headers from the old mail list
+ copyHeaders();
+ return;
+ }
+
+ //get the headers
+ getNextHeader();
+}
+
+void ConfigElem::getNextHeader( )
+{
+ //if the list of mails empty, copy the known headers from the old mail list
+ if( newMails.empty() )
+ {
+ copyHeaders();
+ return;
+ }
+
+ //clear temporary header store
+ receivedHeader.resize( 0 );
+
+ //start job
+ startKIOJob( QString( "/headers/%1" ).arg( *newMails.begin() ) );
+ connect( pop3Job, SIGNAL( data( KIO::Job*, const QByteArray & ) ), this, SLOT( slotReceiveHeader( KIO::Job*, const QByteArray & ) ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotHeaderDownloaded( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotHeaderDownloaded( KIO::Job * job )
+{
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error is occured, the download will be canceled
+ if( job->error() != 0 )
+ {
+ //show error message if desired
+ if( appConfig->showConnectionErrors() )
+ job->showErrorDialog();
+
+ cancelRefresh();
+ return;
+ }
+
+ //store header
+ tempMailList->setHeader( *newMails.begin(), QString( receivedHeader ) );
+
+ //remove the first item of the list of new mails
+ newMails.remove( newMails.begin() );
+
+ //if the list of new mails is empty, copy the headers of old mails to the new list
+ if( newMails.empty() )
+ {
+ copyHeaders();
+ return;
+ }
+
+ //get next header
+ getNextHeader();
+}
+
+void ConfigElem::copyHeaders( )
+{
+ //get the UIDs of the old mails in the temporary mail list
+ QStringList UIDs = tempMailList->getUIDsOfOldMails();
+
+ //iterate over all members of the list,
+ //get the header from the old list and store it in the new one
+ QStringList::iterator it;
+ for ( it = UIDs.begin(); it != UIDs.end(); ++it )
+ {
+ QString header = m_pshowrecord->getHeaderOf( *it );
+ tempMailList->setHeader( *it, header );
+ }
+
+ //now we have the a complete new mail list
+ swapMailLists();
+}
+
+void ConfigElem::slotReceiveHeader( KIO::Job *, const QByteArray & data )
+{
+ if( !data.isEmpty() )
+ {
+ //we get the next part of the mail
+ //append it
+ uint lastSize = receivedHeader.size();
+ receivedHeader.resize( lastSize + data.size() );
+ for( uint i = 0; i < data.size(); i++ )
+ receivedHeader[ lastSize + i ] = data[ i ];
+ }
+}
+
+int ConfigElem::getNumberNewMails( )
+{
+ return m_pshowrecord->getNumberNewMails();
+}
+
+int ConfigElem::getNumberMails( )
+{
+ return m_pshowrecord->getNumberMails();
+}
+
+long ConfigElem::getTotalSize( )
+{
+ return m_pshowrecord->getTotalSize();
+}
+
+void ConfigElem::fillMailListView( KshowmailView* view )
+{
+ m_pshowrecord->fillMailListView( view, m_strAccount );
+}
+
+void ConfigElem::refreshAccountListItem( )
+{
+ if( m_pViewItem != NULL )
+ {
+ if( isActive() )
+ {
+ m_pViewItem->setText( 4, QString( "%1" ).arg( getNumberMails(), 3 ) );
+ m_pViewItem->setText( 5, QString( "%1" ).arg( getTotalSize(), 8 ) );
+ }
+ else
+ {
+ m_pViewItem->setText( 4, QString( "???" ) );
+ m_pViewItem->setText( 5, QString( "???" ) );
+ }
+ }
+}
+
+void ConfigElem::killPOP3Job( )
+{
+ //just try to kill, if it is not idle
+ if( state != AccountIdle )
+ {
+ //kill a running job
+ if( pop3Job != NULL )
+ pop3Job->kill( true );
+
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //call the appropriate finalize method
+ switch( state )
+ {
+ case AccountDeleting : slotFinalizeDeletion( NULL ); break;
+ case AccountDownloading : slotFinalizeShowMail( NULL ); break;
+ case AccountRefreshing : cancelRefresh(); break;
+
+ default : break;
+ }
+ }
+}
+
+int ConfigElem::showSelectedHeaders( )
+{
+ //return, if no mails are selected
+ if( !hasSelectedMails() )
+ return ConfigElem::continueShowHeaders;
+
+ //order the mail list to show the headers of the selected mails
+ int ret = m_pshowrecord->showSelectedHeaders( m_strAccount );
+
+ return ret == ShowRecord::continueShowHeaders ? ConfigElem::continueShowHeaders : ConfigElem::cancelShowHeaders;
+}
+
+void ConfigElem::printSetup( ) const
+{
+ kdDebug() << "Setup of " << m_strAccount << ":" << endl;
+ kdDebug() << "Host: " << m_url.host() << endl;
+ kdDebug() << "Protocol: " << m_url.protocol() << endl;
+ kdDebug() << "Port: " << m_url.port() << endl;
+ kdDebug() << "User: " << m_url.user() << endl;
+ kdDebug() << "Password: " << m_url.pass() << endl;
+
+ switch( PasswordStorage )
+ {
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE : kdDebug() << "Password Storage: don't save" << endl; break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE : kdDebug() << "Password Storage: save in file" << endl; break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET : kdDebug() << "Password Storage: use KWallet" << endl; break;
+ default : kdDebug() << "Password Storage: invalid value" << endl;
+
+ }
+
+ kdDebug() << "active: " << m_bActive << endl << endl;
+
+
+}
+
+void ConfigElem::setPasswordStorage( int storage )
+{
+ if( storage == CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE ||
+ storage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE ||
+ storage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+
+ PasswordStorage = storage;
+
+ else
+
+ PasswordStorage = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+}
+
+int ConfigElem::getPasswordStorage( ) const
+{
+ return PasswordStorage;
+}
+
+QString ConfigElem::getProtocol( bool upperCase ) const
+{
+ if( upperCase )
+ return m_url.protocol().upper();
+ else
+ return m_url.protocol();
+}
+
+unsigned short int ConfigElem::getPort( ) const
+{
+ return m_url.port();
+}
+
+void ConfigElem::setTLS( bool tls )
+{
+ useTLS = tls;
+}
+
+bool ConfigElem::getTLS( ) const
+{
+ return useTLS;
+}
+
+void ConfigElem::reloadFilterSettings( )
+{
+ headerFilter.load();
+}
+
+void ConfigElem::applyFilters( )
+{
+ //are we executed by the MOVE routines?
+ if( !downloadActionsInvoked )
+ {
+ //this is the first call (at the current refresh cycle) of this methode
+ //we get the lists of mails to delete an move and call the MOVE routines if necessary
+
+ //OK, the filters were applied
+ filterApplied = true;
+
+ //order the mail list to apply the header filters
+ //it returns lists of mail numbers which shall be deleted or moved
+ //the marking will be done by the mail list itself
+ //the mail list removes all mails which shall be ignored itself
+ MailsToDelete.clear();
+ m_pshowrecord->applyHeaderFilter( &headerFilter, getAccountName(), MailsToDelete, MailsToDownload, nmbIgnoredMails, FLog );
+ nmbDeletedMailsLastRefresh += MailsToDelete.count();
+ nmbDeletedMailsLastStart += MailsToDelete.count();
+
+ //This part will be executed, if mails shall be downloaded
+ if( !MailsToDownload.empty() )
+ {
+ downloadActionsInvoked = true;
+ doDownloadActions();
+
+ //we quit this methode at this point, because after the bodies are downloaded and written this methode will recalled.
+ //At this time the else branch of this IF-statement will be executed and the methode continues
+ return;
+ }
+
+ }
+ else
+ {
+ //this is the second call (at the current refresh cycle) of this methode.
+ //it is called by the Move routines.
+ //the downloading of the mailbodies and writing it to the mailboxes has ended.
+ //A second call was just exceuted, if there was mails to move
+ downloadActionsInvoked = false;
+
+ //after an move error there are maybe some mails leftover in MailsToMove
+ MailsToDownload.clear();
+ }
+
+
+
+ //we have get the list of mails to delete and the all mails to move are written to its mailboxes
+ //now we delete this mails (the moved mails too)
+
+ if( !MailsToDelete.empty() )
+ {
+ //there are mails to delete
+ //we delete they
+ //after the delete cycle has done its job, it will call applyFiltersDeleted()
+ deletionPerformedByFilters = true; //this is set to indicate the deletion is performed by filters and not by user
+ //the deletion methodes need it to decide on branch targets
+ deleteNextMail();
+ }
+ else
+ {
+ //if we need not to start a second refresh cycle (no mails was deleted or moved)
+ //we just commit the refresh and let the filter applied flag to false for the next regular refresh
+ commitRefresh();
+ filterApplied = false;
+ }
+}
+
+void ConfigElem::swapMailLists( )
+{
+ //delete old mail list
+ delete m_pshowrecord;
+
+ //assign the new list
+ if( tempMailList != NULL )
+ m_pshowrecord = tempMailList;
+ else
+ m_pshowrecord = new ShowRecord();
+
+ //if the filters were not applied yet, we do it now
+ //applyFilters() will either start a second refresh cycle if it did some deletions
+ //or call commitRefresh() to commit the refresh cycle.
+ //if the filters were already applied we commit the refresh.
+ if( filterApplied | !headerFilter.isActive() )
+ {
+ commitRefresh();
+ filterApplied = false;
+ return;
+ }
+ else
+ {
+ applyFilters();
+ return;
+ }
+}
+
+void ConfigElem::applyFiltersDeleted( )
+{
+ //unset the flag
+ deletionPerformedByFilters = false;
+
+ //start the second refresh cycle
+ refreshPerformedByFilters = true;
+
+ //this sends a commit and restart the refresh
+ commitBeforeRefresh();
+ return;
+ //refreshMailList();
+}
+
+
+bool ConfigElem::writeToMailBox( const QString & mail, const QString & box )
+{
+ QDir mailDir( box );
+
+ //check whether the given path is a maildir
+ if( !isMailDir( mailDir ) )
+ {
+ //show an error message
+ KMessageBox::error( NULL, i18n( QString( "%1 is not a mailbox." ).arg( box ) ) );
+ return false;
+ }
+
+ //create unique file name according http://cr.yp.to/proto/maildir.html
+ QString partTime = QString::number( time( NULL ) ); //left part, output of time()
+
+ char hname[256]; //right part, the hostname
+ QString partHostname;
+ if( gethostname( hname, 255 ) == 0 )
+ partHostname = QString( hname );
+ else
+ {
+ //the hostname is not readable
+ //show an error message and exit
+ KMessageBox::error( NULL, i18n( QString( "Can't read the hostname of your computer. But KShowmail need it to write a mail into the mailbox." ) ) );
+ return false;
+ }
+
+ QString partPID = QString::number( getpid() ); //middle part, the PID
+
+ QString partCounter = QString::number( moveCounter++ );
+
+ QString uniqueName( partTime + "." + partPID + partCounter + "." + partHostname );
+
+ //build absolute path
+ mailDir.cd( "tmp" );
+ QString absFile = mailDir.filePath( uniqueName );
+
+ //and writing!
+ QFile file( absFile );
+ if( file.open( IO_WriteOnly ) )
+ {
+ QTextStream stream( &file );
+ stream << mail << endl;
+ file.close();
+ }
+ else
+ {
+ KMessageBox::detailedError( NULL, i18n( QString( "Could not file a mail to %1." ) ).arg( box ), i18n( file.errorString() ) );
+ return false;
+ }
+
+ //now we move it to the "new" subdirectory
+ mailDir.cdUp();
+ mailDir.cd( "new" );
+ QString absNewFile = mailDir.filePath( uniqueName );
+
+ if( rename( absFile.ascii(), absNewFile.ascii() ) == -1 )
+ {
+ KMessageBox::error( NULL, i18n( QString( "Could not move a mail from %1 to %2." ) ).arg( absFile ).arg( absNewFile ) );
+ return false;
+ }
+
+ //the writing was successful
+ return true;
+}
+
+void ConfigElem::doDownloadActions()
+{
+ //get first mail
+ getNextMailForDownloadActions();
+}
+
+bool ConfigElem::isMailDir( const QDir & path )
+{
+ //get a list of all subdirectories in this directory
+ const QStringList entries = path.entryList( QDir::Dirs | QDir::Readable | QDir::Writable | QDir::Hidden, QDir::Name | QDir::IgnoreCase | QDir::LocaleAware );
+
+ //a maildir folder must contains the folders "cur", "new" and "tmp"
+ bool curFound = false;
+ bool newFound = false;
+ bool tmpFound = false;
+
+ //iterate over all directories and look for the three necessary dirs
+ QStringList::const_iterator it = entries.begin();
+ while( it != entries.end() && !( curFound && newFound && tmpFound ) )
+ {
+ if( *it == "tmp" )
+ tmpFound = true;
+ else if( *it == "cur" )
+ curFound = true;
+ else if( *it == "new" )
+ newFound = true;
+
+ ++it;
+ }
+
+ return curFound && newFound && tmpFound;
+}
+
+void ConfigElem::getNextMailForDownloadActions()
+{
+ //if the list of mails to move is empty return to applyFilters
+ if( MailsToDownload.empty() )
+ {
+ applyFilters();
+ return;
+ }
+
+ //clear the class variable mailbody, which contains the downloaded mail body
+ mailbody.resize( 0 );
+
+ //start job
+ startKIOJob( QString( "/download/%1" ).arg( MailsToDownload.begin().key() ) );
+ connect( pop3Job, SIGNAL( data( KIO::Job*, const QByteArray & ) ), SLOT( slotDataMailBody( KIO::Job*, const QByteArray & ) ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotMailDownloadedForAction( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotMailDownloadedForAction(KIO::Job * job)
+{
+ //stop timeout timer
+ pop3Timer->stop();
+
+ //check for errors
+ //if an error has occured, the download will be canceled
+ //or will ask for a new password
+ if( job->error() == KIO::ERR_COULD_NOT_LOGIN )
+ {
+ //login failed, ask for a new password
+ job->showErrorDialog();
+ bool res = assertPassword( true );
+ if( res == false )
+ {
+ //we have not got a new password; cancel delete
+ applyFilters();
+ return;
+ }
+ //if we have got a new password, jump to the end of the if-statement
+ }
+ else if( job->error() != 0 )
+ {
+ job->showErrorDialog();
+ applyFilters();
+ return;
+ }
+ else
+ {
+ //succesful download
+ //do action
+ MailToDownloadMap_Type::Iterator firstMail = MailsToDownload.begin();
+ int currentMailNumber = firstMail.key(); //get mail number
+ QString currentMailBox( firstMail.data().mailbox ); //get mailbox
+ QString mail( mailbody ); //convert mailtext
+ FilterAction_Type action = firstMail.data().action; //get action
+
+ bool resultMove = false; //TRUE - mail is written into the mailbox
+ bool resultSpam = false; //TRUE - mail is Spam
+ bool deleteIt = false; //TRUE - mail shall be deleted
+ bool resultAction = false; //True - the action was succesful performed
+
+ switch( action )
+ {
+ case FActMove : resultMove = writeToMailBox( mail, currentMailBox );
+ //log entry is made by ShowRecordElem::applyHeaderFilter
+ if( resultMove == true )
+ {
+ nmbMovedMailsLastRefresh++;
+ nmbMovedMailsLastStart++;
+
+ resultAction = true;
+ deleteIt = true;
+ }
+ else
+ {
+ resultAction = false;
+ deleteIt = false;
+ }
+ break;
+
+ case FActSpamcheck : resultSpam = isSpam( mailbody ); //it is spam?
+ if( resultSpam == true ) //yes, it is spam! Arrgghh! Torture it!!!
+ {
+ switch( appConfig->getSpamAction() )
+ {
+ case FActMove : resultMove = writeToMailBox( mail, appConfig->getSpamMailbox() );
+ if( resultMove == true )
+ {
+ nmbMovedMailsLastRefresh++;
+ nmbMovedMailsLastStart++;
+
+ if( FLog != NULL )
+ m_pshowrecord->writeToMoveLog( FLog, currentMailNumber, getAccountName(), appConfig->getSpamMailbox() );
+ resultAction = true;
+ deleteIt = true;
+ }
+ else
+ {
+ resultAction = false;
+ deleteIt = false;
+ }
+ break;
+
+ case FActMark : m_pshowrecord->setMarkAtNextViewRefresh( currentMailNumber );
+ resultAction = true;
+ deleteIt = false;
+ break;
+
+ case FActDelete : if( FLog != NULL )
+ m_pshowrecord->writeToDeleteLog( FLog, currentMailNumber, getAccountName() );
+
+ nmbDeletedMailsLastRefresh++;
+ nmbDeletedMailsLastStart++;
+ resultAction = true;
+ deleteIt = true;
+ break;
+
+ default : kdError() << "invalid action for spam mail" << endl;
+ resultAction = false;
+ deleteIt = false;
+ break;
+
+ }
+ }
+ else //mail is not spam
+ {
+ resultAction = true;
+ deleteIt = false;
+ }
+ break;
+
+ default : deleteIt = false;
+ resultAction = false;
+
+ }
+
+ if( resultAction == true )
+ {
+ //Action was successful
+ //remove this mail from the list
+ MailsToDownload.remove( firstMail );
+
+ //maybe add this mail to list of mails to delete
+ if( deleteIt )
+ MailsToDelete.append( currentMailNumber );
+ }
+ else
+ {
+ //Action was not successful
+ //returns to applyFilters() to continue the filtering
+ applyFilters();
+ return;
+ }
+
+
+ //if the list of mails is empty, return to applyFilters() to continue the filtering
+ if( MailsToDownload.empty() )
+ {
+ applyFilters();
+ return;
+ }
+ }
+
+
+ //show next mail in list
+ getNextMailForDownloadActions();
+}
+
+bool ConfigElem::isSpam( QByteArray mail ) const
+{
+ //check for a running spamassassin
+ if( !isSpamAssassinRunning() )
+ {
+ KMessageBox::information( NULL, i18n( "You want to check your mails for spam, but SpamAssassin is not running.\nKShowmail skips the spam check." ), i18n( "SpamAssassin is not running" ), "ConfigElemNoSpamAssassinRunning" );
+ return false;
+ }
+
+ //append an \0 at the end of the string
+ int size = mail.size();
+ if( mail[ size - 1 ] != '\0' )
+ {
+ mail.resize( size + 1 );
+ mail[ size ] = '\0';
+ }
+
+ //calls spmac and get an file pointer to stdin of it
+ FILE *write_fp;
+ write_fp = popen( "spamc -E", "w" );
+
+ //forward the mail to SpamAssassin
+ if( write_fp != NULL )
+ {
+ fwrite( mail.data(), sizeof( char), mail.size(), write_fp );
+
+ //check exit code of spamc and return result
+ int excode = pclose( write_fp );
+ if( excode == 0 )
+ return false;
+ else
+ return true;
+ }
+ else
+ {
+ kdError() << "Could not call the command spamc of SpamAssassin." << endl;
+ return false;
+ }
+
+ return false;
+}
+
+bool ConfigElem::isSpamAssassinRunning( ) const
+{
+ FILE *read_fp;
+ char buffer[ BUFSIZ + 1 ];
+ int chars_read;
+ bool found = false;
+
+ memset( buffer, '\0', sizeof( buffer ) );
+ read_fp = popen( "ps -eo comm", "r" );
+ if( read_fp != NULL )
+ {
+ chars_read = fread( buffer, sizeof( char ), BUFSIZ, read_fp );
+ while( chars_read > 0 )
+ {
+ buffer[ chars_read - 1 ] = '\0';
+ QString output( buffer );
+ found = output.contains( NAME_SPAMASSASSIN_DAEMON ) > 0;
+ chars_read = fread( buffer, sizeof( char ), BUFSIZ, read_fp );
+ }
+ pclose( read_fp );
+ }
+
+ return found;
+}
+
+int ConfigElem::numberDeletedMailsLastRefresh( )
+{
+ return nmbDeletedMailsLastRefresh;
+}
+
+int ConfigElem::numberDeletedMailsStart( )
+{
+ return nmbDeletedMailsLastStart;
+}
+
+int ConfigElem::numberMovedMailsLastRefresh( )
+{
+ return nmbMovedMailsLastRefresh;
+}
+
+int ConfigElem::numberMovedMailsStart( )
+{
+ return nmbMovedMailsLastStart;
+}
+
+int ConfigElem::numberIgnoredMails( )
+{
+ return nmbIgnoredMails;
+}
+
+QStringList ConfigElem::getSelectedSenders( ) const
+{
+ return m_pshowrecord->getSelectedSenders();
+}
+
+
+
+
+void ConfigElem::commitBeforeRefresh()
+{
+ //start job to commit
+ startKIOJob( QString( "/commit" ) );
+ connect( pop3Job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotCommitBeforeRefreshDone( KIO::Job* ) ) );
+
+}
+
+void ConfigElem::slotCommitBeforeRefreshDone(KIO::Job *)
+{
+ //after a commit was send, we start a new refresh cyle
+ refreshMailList();
+} \ No newline at end of file
diff --git a/kshowmail/configelem.h b/kshowmail/configelem.h
new file mode 100644
index 0000000..14f79ca
--- /dev/null
+++ b/kshowmail/configelem.h
@@ -0,0 +1,1097 @@
+/***************************************************************************
+ configelem.h - description
+ -------------------
+ begin : Tue May 9 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef CONFIGELEM_H
+#define CONFIGELEM_H
+
+//C headers
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+//QT headers
+#include <qstring.h>
+#include <qlistview.h>
+#include <qdom.h>
+#include <qobject.h>
+#include <qtimer.h>
+#include <qregexp.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qtextstream.h>
+
+//KDE headers
+#include <kurl.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kpassdlg.h>
+#include <kio/job.h>
+#include <kio/global.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include "showrecord.h"
+#include "constants.h"
+#include "types.h"
+#include "configlist.h"
+#include "showmaildialog.h"
+#include "decodeRFC2047.h"
+#include "kshowmailview.h"
+#include "encryption.h"
+#include "kwalletaccess.h"
+#include "headerfilter.h"
+#include "filterlog.h"
+
+
+
+using namespace Constants;
+using namespace Types;
+using namespace Encryption;
+
+//forward class declarations
+class KshowmailView;
+class ConfigList;
+class ShowRecordElem;
+class ShowRecord;
+
+/**
+ * @brief Represents a mail account.
+ *
+ * Contains all datas of the account like server, user password and so on.
+ * It also contains the mails read from the server.
+ * Used in class ConfigList and ConfigAccounts.
+ *
+ * @see ShowRecord
+ * @see ConfigList
+ * @see ConfigAccounts::Accounts
+ * @author Eggert Ehmke <eggert.ehmke@berlin.de>
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigElem : public QObject {
+
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Returned by showSelectedHeaders(), if the user has
+ * clicked OK.
+ */
+ static const int continueShowHeaders;
+
+ /**
+ * Returned by showSelectedHeaders(), if the user has
+ * clicked Cancel.
+ */
+ static const int cancelShowHeaders;
+
+ /**
+ * General Constructor
+ * Warning: The pointer to the application configuration (ConfigList)
+ * will not be set.
+ */
+ ConfigElem();
+
+ /**
+ * Default Constructor
+ * @param config pointer to the general app configuration
+ */
+ ConfigElem ( ConfigList* config );
+
+ /**
+ * Copy Constructor.
+ * It doesn't copy the mail list but creates a new empty one.
+ * The pointer to the appropriate account list view item is set
+ * to NULL.The new account is active by default.
+ * @param pElem the account which will be copied
+ */
+ ConfigElem( ConfigElem* pElem );
+
+ /**
+ * Constructs a account which is called like the given name.
+ * Creates a empty mail list. Sets the pointer to the appropriate
+ * account list view item to NULL. The account is deactivated by default.
+ * The url doesn't contain any server informations.
+ * @param config pointer to the general app configuration
+ * @param account name of the new account
+ */
+ ConfigElem( ConfigList* config, const QString& account );
+
+ /**
+ * Destructor
+ * Does nothing.
+ */
+ ~ConfigElem();
+
+ /**
+ * Returns whether the account is active.
+ * @return TRUE - account is active; FALSE - account is not active
+ */
+ bool isActive() const;
+
+ /**
+ * Sets the account active.
+ * @param active TRUE - active account; FALSE - deactivate account
+ */
+ void setActive( bool active );
+
+ /**
+ * Gets the account name.
+ * @return account name
+ */
+ QString getAccountName() const;
+
+ /**
+ * Sets the account name.
+ * @param name the account name
+ */
+ void setAccountName( QString name );
+
+ /**
+ * Gets the account password.
+ * @return password
+ */
+ QString getPassword() const;
+
+ /**
+ * Sets the account password. To save it in the configuration file
+ * call saveOptions().
+ * @param password new password
+ */
+ void setPassword( const QString& password );
+
+ /**
+ * Returns whether a password is stored.
+ * @return TRUE - there is password stored; FALSE - no password stored
+ */
+ bool hasPassword() const;
+
+ /**
+ * Returns the url of this account.
+ * @return url
+ */
+ KURL getURL() const;
+
+ /**
+ * Sets the pointer to the item in the account list view item.
+ * @see m_pViewItem
+ * @param item account list view item
+ */
+ void setListViewItem( QListViewItem* item );
+
+ /**
+ * Returns the pointer to the account list view item.
+ * @see m_pViewItem
+ * @return pointer to the appropriate list view item
+ */
+ QListViewItem* getListViewItem();
+
+ /**
+ * Returns TRUE, if the appropriate list view item is selected.
+ * @return TRUE - list view item is selected
+ * @return FALSE - list view item is not selected
+ */
+ bool isSelected() const;
+
+ /**
+ * Clears the mail list or creates a new one.
+ */
+ void clearMailList();
+
+ /**
+ * Sets the host name.
+ * @param host host name
+ */
+ void setHost( const QString& host );
+
+ /**
+ * Returns the hostname.
+ * @return the name of the host or QString::null if no host is set
+ */
+ QString getHost() const;
+
+ /**
+ * Sets the protocol.
+ * @param protocol the protocol
+ */
+ void setProtocol( const QString& protocol );
+
+ /**
+ * Returns the protocol.
+ * @param upperCase TRUE - transforms the protocol string to upper case
+ * @return protocol
+ */
+ QString getProtocol( bool upperCase = false ) const;
+
+ /**
+ * Enable or disable TLS.
+ * @param tls TRUE: use TLS; FALSE: don't use TLS
+ */
+ void setTLS( bool tls );
+
+ /**
+ * Returns whether TLS is enabled.
+ * @return TRUE: TLS is enabled
+ * @return FALSE: TLS is disabled
+ */
+ bool getTLS() const;
+
+ /**
+ * Sets the port.
+ * @param port the port
+ */
+ void setPort( unsigned short int port );
+
+ /**
+ * Returns the port number.
+ * @return port number
+ */
+ unsigned short int getPort() const;
+
+ /**
+ * Sets the user.
+ * @param user username
+ */
+ void setUser( const QString& user );
+
+ /**
+ * Returns the user name.
+ * @return the user name or QString::null if there is no user name
+ */
+ QString getUser() const;
+
+ /**
+ * Sets the password storage type.
+ * The Constants are defined in constants.h
+ * @param storage type of password storage; valid values are: CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET
+ */
+ void setPasswordStorage( int storage );
+
+ /**
+ * Returns the password storage type.
+ * The Constants are defined in constants.h.
+ * @return type of password storage; valid values are: CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET
+ */
+ int getPasswordStorage() const;
+
+
+ /**
+ * Saves the stored mails into the given
+ * DOM document. It doesn't create a new DOM element but used the given one.
+ * Saves the setup into the application config.
+ * @param doc DOM document which contains all application settings, mails and account settings
+ * @param parent DOM element in which all settings and mails of this account will be saved
+ */
+ void saveOptions( QDomDocument& doc, QDomElement& parent );
+
+ /**
+ * Gets the stored mails.
+ * @param parent DOM element which contains the mails of this account
+ */
+ void readStoredMails( QDomElement& parent );
+
+ /**
+ * Returns the number of stored mails.
+ * @return number of mails
+ */
+ int count();
+
+ /**
+ * Deletes all selected mails.
+ * This just starts the deletion and returns after then.
+ * When the deletion is ready the signal sigDeleteReady will be emitted.
+ */
+ void deleteSelectedMails();
+
+ /**
+ * Downloads and shows the bodies of all selected mails.
+ * This just starts the download and returns after then.
+ * When the download is ready and the body is shown the sigShowBodiesReady
+ * will be emitted.
+ */
+ void showSelectedMails();
+
+ /**
+ * Opens a dialog to ask for a password, stores it temporarily in the account settings and
+ * emits the signal sigConfigChanged.
+ * Does not open a dialog if a password is already stored in the account settings.
+ * @param force ask for a new password even if a password is stored
+ * @return TRUE - a password is available
+ * @return FALSE - no password is available
+ */
+ bool assertPassword( bool force = false );
+
+ /**
+ * Returns the state of the account.
+ * @return account state
+ */
+ Types::AccountState_Type getState();
+
+ /**
+ * Returns the subjects of the selected mails.
+ * @return subjects of selected mails
+ */
+ QStringList getSelectedSubjects() const;
+
+ /**
+ * Returns whether there are mails in the list that are selected
+ * in the list view.
+ * @return TRUE - there are selected mails
+ * @return FALSE - there aren't selected mails
+ */
+ bool hasSelectedMails();
+
+ /**
+ * Refreshes the mail list.
+ * This just starts the refresh and returns after then.
+ * When the refresh is ready, the signal sigRefreshReady
+ * will be emitted.
+ * @param log Pointer to the filter log
+ * @see sigRefreshReady
+ */
+ void refreshMailList( FilterLog* log = NULL );
+
+ /**
+ * Returns the number of new mails.
+ * @return number of new mails
+ */
+ int getNumberNewMails();
+
+ /**
+ * Returns the number of mails.
+ * @return number of mails
+ */
+ int getNumberMails();
+
+ /**
+ * Returns the total size of all mails.
+ * @return total size
+ */
+ long getTotalSize();
+
+ /**
+ * Creates for every mail a list view item and insert it
+ * into the mail list view.
+ * @param view pointer to the application view
+ */
+ void fillMailListView( KshowmailView* view );
+
+ /**
+ * Refreshes the appropriate entry of the account list
+ * (number of mails and total size)
+ * Uses the pointer to the list view item stored in m_pViewItem.
+ */
+ void refreshAccountListItem();
+
+ /**
+ * Kills a running pop3 job.
+ */
+ void killPOP3Job();
+
+ /**
+ * Shows the headers of all selected mails.
+ * @return continueShowHeaders - the user has clicked OK. The invoking function will show the next header
+ * @return cancelShowHeaders - the user has clicked Cancel. The invoking function will not show the next header.
+ * @return continueShowHeaders - no mails of this account are selected
+ */
+ int showSelectedHeaders();
+
+ /**
+ * Prints the setup to stdout.
+ */
+ void printSetup() const;
+
+ /**
+ * Reloads the settings of the filters.
+ * It just calls the load() methode of the header filter.
+ */
+ void reloadFilterSettings();
+
+ /**
+ * Returns the number of deleted mails by last refresh.
+ * @return number of deleted mails by last refresh
+ */
+ int numberDeletedMailsLastRefresh();
+
+ /**
+ * Returns the number of deleted mails since start.
+ * @return number of deleted mails since start
+ */
+ int numberDeletedMailsStart();
+
+ /**
+ * Returns the number of moved mails by last refresh.
+ * @return number of moved mails by last refresh
+ */
+ int numberMovedMailsLastRefresh();
+
+ /**
+ * Returns the number of moved mails since start.
+ * @return number of moved mails since start
+ */
+ int numberMovedMailsStart();
+
+ /**
+ * Returns the number of ignored mails by last refresh.
+ * @return number of ignored mails by last refresh
+ */
+ int numberIgnoredMails();
+
+ /**
+ * Returns the senders of the selected mails
+ * @return senders of the selected mails
+ */
+ QStringList getSelectedSenders() const;
+
+
+ private:
+
+ /**
+ * Pointer to the configuration of the application.
+ * Set by the constructors.
+ */
+ ConfigList* appConfig;
+
+ /**
+ * Pointer to the filter log.
+ * Will be set by refreshMailList() at every refresh.
+ */
+ FilterLog* FLog;
+
+ /**
+ * State of the account.
+ */
+ Types::AccountState_Type state;
+
+ /**
+ * Type of password storage.
+ * valid values are: CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET
+ * The Constants are defined in constants.h
+ * @see saveOptions()
+ * @see setPasswordStorage()
+ */
+ int PasswordStorage;
+
+ /**
+ * TRUE - account is active; FALSE - account is not active
+ */
+ bool m_bActive;
+
+ /**
+ * Account Name
+ */
+ QString m_strAccount;
+
+ /**
+ * Pointer to the appropriate item in the account list view.
+ */
+ QListViewItem* m_pViewItem;
+
+ /**
+ * List which contains all read mails from the server.
+ */
+ ShowRecord* m_pshowrecord;
+
+ /**
+ * Uniform Resource Locator of the account on the pop3 server.
+ */
+ KURL m_url;
+
+ /**
+ * Type of secure login.
+ * See constants.h for valid values (CONFIG_VALUE_ACCOUNT_SECLOGIN_...)
+ */
+ int secureLoginType;
+
+ /**
+ * False: TLS is enabled
+ */
+ bool useTLS;
+
+ /**
+ * Contains a downloaded mail body.
+ * Will be set by slotDataMailBody() and read by slotBodyDownloaded().
+ */
+ QByteArray mailbody;
+
+ /**
+ * Contains the numbers of mails which will be deleted.
+ * Set by deleteSelectedMails() and applyFilters() and used by deleteNextMail() to get
+ * the number of the next mail to delete.
+ * @see deleteSelectedMails()
+ * @see deleteNextMail()
+ * @see applyFilters()
+ */
+ MailNumberList_Type MailsToDelete;
+
+ /**
+ * Contains the numbers of the mails shall be moved for actions like moving to mailbox or spam check.
+ * Contains also some parameters (like mailbox) about the action which have to be performed.
+ * Set and used by applyFilters().
+ * @see applyFilters()
+ */
+ MailToDownloadMap_Type MailsToDownload;
+
+ /**
+ * Contains the numbers of mails for which the bodies will be shown.
+ * Set by showSelectedMails() and used by showNextMail() to get
+ * the number of the next mail to show.
+ * @see showSelectedMails()
+ * @see showNextMail()
+ */
+ MailNumberList_Type MailsToShow;
+
+ /**
+ * Contains the numbers of new mails.
+ * Set by getHeaders() and used by getNextHeader() to download
+ * the headers of the new mails.
+ * @see getHeaders()
+ * @see getNextHeader()
+ */
+ MailNumberList_Type newMails;
+
+ /**
+ * Pointer to a launched pop3 job.
+ */
+ KIO::TransferJob* pop3Job;
+
+ /**
+ * timeout timer. Will be started together with every pop3 job.
+ * If it runs down, slotTimeout() will be invoked.
+ */
+ QTimer* pop3Timer;
+
+ /**
+ * While refreshing, this ShowRecord instance will be used to
+ * build a new mail list. After that this pointer will be assigned
+ * to m_pshowrecord.
+ */
+ ShowRecord* tempMailList;
+
+ /**
+ * List of received mail UIDs (unique ID).
+ * Used by slotReceiveUID() and slotUIDsReceived().
+ */
+ QStringList receivedUIDs;
+
+ /**
+ * List of received mail sizes.
+ * Used by slotReceiveSize() and slotSizesReceived().
+ */
+ QStringList receivedSizes;
+
+ /**
+ * A received mail header.
+ * Set by slotReceiveHeader() and used by slotHeaderDownloaded().
+ */
+ QByteArray receivedHeader;
+
+ /**
+ * Every account has is own header filter instance.
+ */
+ HeaderFilter headerFilter;
+
+ /**
+ * This is a flag whether the filters was applied during a refresh cycle.
+ * If the some mails was deleted (recommend by the filter), we need a actual
+ * list of mails from the server. Therefore a second refresh cycle will be started.
+ * To avoid a never-ending loop this flag will be set to TRUE by applyFilters().
+ * If the second refresh is running this one will not invoke the filters.
+ */
+ bool filterApplied;
+
+ /**
+ * This flag is set by applyFilters() to indicate the deletion cycle is performed by filters and not by user.
+ * The deletion methodes need it to decide on branch targets
+ */
+ bool deletionPerformedByFilters;
+
+ /**
+ * This flag is set by applyFiltersDeleted() to indicate the refresh cycle is the second one after a deletion which was performed by filters.
+ * The refresh cycle need it to hold the remaining mails as new.
+ */
+ bool refreshPerformedByFilters;
+
+ /**
+ * This flag is set to TRUE by applyFilters() to indicate the mailbodies are downloading and writing to the mailboxes or spam checking.
+ * When this is ended, applyFilters() will be called again and it reset this flag
+ */
+ bool downloadActionsInvoked;
+
+ /**
+ * Counter for moving to create an unique file name
+ */
+ int moveCounter;
+
+ /**
+ * Number of deleted mails by last refresh.
+ */
+ int nmbDeletedMailsLastRefresh;
+
+ /**
+ * Number of deleted mails since start.
+ */
+ int nmbDeletedMailsLastStart;
+
+ /**
+ * Number of moved mails by last refresh.
+ */
+ int nmbMovedMailsLastRefresh;
+
+ /**
+ * Number of moved mails since start.
+ */
+ int nmbMovedMailsLastStart;
+
+ /**
+ * Number of ignored mails by last refresh.
+ */
+ int nmbIgnoredMails;
+
+ /**
+ * Initializes the account.
+ */
+ void init();
+
+ /**
+ * Deletes the first mail of MailsToDelete.
+ * After a succesful deletion this mail will be removed from the list
+ * by slotMailDeleted() and this method will be invoked again.
+ * If the list is empty, it will call commitDelete.
+ * @see slotMailDeleted()
+ * @see MailsToDelete
+ */
+ void deleteNextMail();
+
+ /**
+ * Commits the deletion.
+ * Starts a pop3 job that will do the commit. Its signal
+ * result is connected with slotFinalizeDeletion().
+ * @see slotFinalizeDeletion()
+ */
+ void commitDeletion();
+
+ /**
+ * Shows the body of the first mail in MailsToShow.
+ * After a succesful download and opening of the window this
+ * mail will be removed from the list by slotBodyDownloaded() and this
+ * method will be invoked again.
+ * If the list is empty, it will call commitDownloading().
+ * @see commitDownloading()
+ * @see slotBodyDownloaded()
+ */
+ void showNextMail();
+
+ /**
+ * Commits the downloading of mail bodies.
+ * Starts a pop3 job that will do the commit. Its signal
+ * result is connected with slotFinalizeShowMail().
+ * @see slotFinalizeShowMail()
+ */
+ void commitDownloading();
+
+ /**
+ * Creates a POP3 transfer job (KIO Job), which will be stored in pop3Job.
+ * @param path command and parameters of the job as URL path
+ */
+ void startKIOJob( const QString& path );
+
+ /**
+ * Returns the timeout time in seconds which is stored in the
+ * general configuration of the application.
+ * Returns POP3_DEFAULT_TIMEOUT_TIME (defined in constants.h),
+ * if no time is available.
+ * Returns POP3_MINIMUM_TIMEOUT_TIME (defined in constants.h),
+ * if the get time is less than POP3_MINIMUM_TIMEOUT_TIME.
+ * @return seconds to timeout
+ */
+ unsigned int getTimeoutTime();
+
+ /**
+ * First step of the refresh cycle.
+ * Gets the UIDs of the available mails from the server.
+ * It starts a KIO job to get the UIDs. The UIDs will be stored
+ * in receivedUIDs by slotReceiveUID().
+ * When the job is ready, it will invoke slotUIDsReceived().
+ */
+ void getUIDs();
+
+ /**
+ * Second step of the refresh cycle.
+ * Gets the sizes of the available mails from the server.
+ * It starts a KIO job to get these. The Sizes will be temporarily
+ * stored in receivedSizes by slotReceiveSize().
+ * When the job is ready, it will invoke slotSizesReceived().
+ */
+ void getSizes();
+
+ /**
+ * Third step of the refresh cycle.
+ * Gets the header of the new mails from the server.
+ */
+ void getHeaders();
+
+ /**
+ * Get the header of the first mail in newMails.
+ * After a succesful download this
+ * mail will be removed from the list by slotHeaderDownloaded() and this
+ * method will be invoked again.
+ * If the list is empty, it will call copyHeaders() to get the known
+ * headers from the old mail list (m_pshowrecord).
+ * @see copyHeaders()
+ * @see slotHeaderDownloaded()
+ */
+ void getNextHeader();
+
+ /**
+ * Fourth step of the refresh cycle.
+ * Copies the known headers of the old mails from the
+ * old mail list to the new one.
+ * At the end it invokes swapMailLists().
+ */
+ void copyHeaders();
+
+ /**
+ * Sixth step of the refresh cycle.
+ * Applies the filters to the mails in the mail list.
+ * Invoked by swapMailLists().
+ * This methode maybe starts a new refresh cycle because after a deletion or moving we need a
+ * actual list of mails on the server.
+ * To avoid a never-ending loop you must not call this methode during the second refresh cycle.
+ * Therefore it sets filterApplied to TRUE.
+ * @see filterApplied
+ * @see applyFiltersDeleted()
+ */
+ void applyFilters();
+
+ /**
+ * If there are mails to delete by filters applyFilters will call the regular deletion cycle of this class with set byFilter-flag.
+ * Therefore the deletion will not branch to commitDeletion() but to this methode.
+ * This performs a second refresh cycle to get an effective mail list from the server.
+ * This new cycle will not apply the filters again, because the flag filterApplied is set to TRUE.
+ * @see applyFilters()
+ * @see filterApplied
+ */
+ void applyFiltersDeleted();
+
+ /**
+ * Cancels the refresh. Will be invoked, when a pop3 job has
+ * reported an error.
+ */
+ void cancelRefresh();
+
+ /**
+ * Commits the refresh.
+ * Starts a pop3 job that will do the commit. Its signal
+ * result is connected with slotFinalizeRefresh().
+ * Invoked by copyHeaders() if the filters was applied or applyFilters()
+ * if not second refresh was necessary.
+ * @see slotFinalizeRefresh()
+ * @see applyFilters()
+ */
+ void commitRefresh();
+
+ /**
+ * Send a commit and restart the refresh cycle
+ * We restart the refresh to get a fresh maillist after a deletion performed by the filter.
+ * We need a commit before because the mails server only after a commit reorders the mail numbers
+ */
+ void commitBeforeRefresh();
+
+ /**
+ * Fifth step of the refresh cycle.
+ * Copies the pointer to the temporary list to m_pshowrecord.
+ * Invoked by copyHeaders() and slotUIDsReceived().
+ * The temporary list will be the current mail list.
+ * At the end it invokes commitRefresh() if the filters were applied
+ * (filterApplied == TRUE) or deactive or it invokes
+ * applyFilters() if the filters were not
+ * applied (filterApplied == FALSE).
+ * @see m_pshowrecord
+ * @see copyHeaders()
+ * @see slotUIDsReceived()
+ * @see commitRefresh()
+ * @see filterApplied
+ */
+ void swapMailLists();
+
+ /**
+ * Does all filter actions for which we have to download the mails
+ * These are:
+ * Moving, spam check
+ * It doesn't removes they from the server.
+ */
+ void doDownloadActions();
+
+ /**
+ * Gets the body of the first mail in MailsToDownload.
+ * After a succesful download and writing into the mailbox this
+ * mail will be removed from the list by slotMailDownloadedforDownloadActions() and this
+ * method will be invoked again.
+ * If the list is empty, it will call applyFilters() to continue the filtering.
+ * @see applyFilters()
+ * @see slotMailDownloadedforDownloadActions()
+ */
+ void getNextMailForDownloadActions();
+
+ /**
+ * Returns whether the given directory is a maildir directory
+ * @param path the directory for test
+ * @return TRUE - directory is a maildir directory
+ */
+ bool isMailDir( const QDir& path );
+
+ /**
+ * Writes the given mail into the mailbox.
+ * @param mail the Mail
+ * @param box path to the mailbox
+ * @return TRUE - Writing was succesful
+ */
+ bool writeToMailBox( const QString& mail, const QString& box );
+
+ private slots:
+
+ /**
+ * Connected with signal result of the launched pop3 job.
+ * Removes the deleted mail from the internal mail list (m_pshowrecord).
+ * Removes the first mail from MailsToDelete and invokes
+ * deleteNextMail() again to delete the next mail.
+ * If the list is empty after it has removed the first item, it will call
+ * commitDelete().
+ * If an error is occured, it will call slotFinalizeDeletion().
+ * @param job job which has emit the result signal
+ * @see deleteNextMail()
+ * @see MailsToDelete
+ * @see pop3Job
+ * @see slotFinalizeDeletion()
+ */
+ void slotMailDeleted( KIO::Job* job );
+
+ /**
+ * Connected with the signal result of the job which commits the deletion.
+ * Finalizes the deletion of mails.
+ * Emits signal sigDeleteReady.
+ * @see deleteNextMail()
+ * @see slotMailDeleted()
+ * @see sigDeleteReady
+ */
+ void slotFinalizeDeletion( KIO::Job* );
+
+ /**
+ * Connected with signal result of the launched pop3 job to
+ * download a mail body.
+ * Opens a window (class ShowMailDialog) with the downloaded mail body.
+ * Removes the first mail from MailsToShow and invokes showNextMail()
+ * again to show the next mail.
+ * If the list is empty after it has removed the first item, it will call
+ * commitDownloading().
+ * If an error is occured, it will call slotFinalizeShowMail().
+ * @param job job which has emit the result signal
+ * @see showNextMail()
+ * @see commitDownloading()
+ * @see MailsToShow
+ * @see pop3Job
+ * @see slotFinalizeShowMail()
+ * @see ShowMailDialog
+ */
+ void slotBodyDownloaded( KIO::Job* job );
+
+ /**
+ * Connected with signal result of the launched pop3 job to
+ * download a mail to write it into a mailbox or do a spam check.
+ * Maybe it puts the number of the downloaded mail into the list of mails to delete (MailsToDelete).
+ * Removes the first mail from MailsToMove and invokes getNextMailForMove()
+ * again to get and write the next mail.
+ * If the list is empty after it has removed the first item, it will call
+ * applyFilters() to continue the filtering.
+ * If an error is occured the current mail will not put into MailsToDelete. And it returns
+ * to applyFilters() immediately.
+ * @param job job which has emit the result signal
+ * @see MailsToDownload
+ * @see getNextMailForDownloadActions()
+ * @see applyFilters()
+ */
+ void slotMailDownloadedForAction( KIO::Job* job );
+
+ /**
+ * Connected with signal data of the launched pop3 job to
+ * download a mail body.
+ * Receives the downloaded data from the job. This lot will be called
+ * several times during the donwload. At the last one the array is empty.
+ * It extracts the body from the downloaded data and stores it in DownloadedMailBody.
+ * @param datas the downloaded mail
+ */
+ void slotDataMailBody( KIO::Job*, const QByteArray & datas );
+
+ /**
+ * Connected with the signal result of the job which commits the download
+ * of the mail bodies.
+ * Finalizes the downloading and showing of the selected mails.
+ * Emits signal sigShowBodiesReady and sets account state to idle.
+ * @see showNextMail()
+ * @see slotBodyDownloaded()
+ * @see sigShowBodiesReady
+ */
+ void slotFinalizeShowMail( KIO::Job* );
+
+ /**
+ * Connected with signal timeout() of the timeout timer pop3Timer.
+ * Will be called when the timer is run down, if the pop3 job
+ * has not ended on time.
+ * It kills a running pop3 job and invokes the appropriate finalize slot
+ * of the running operation.
+ */
+ void slotTimeout();
+
+ /**
+ * Connected with the signal "data" of the pop3 transfer job which gets mail
+ * UIDs (Unique ID). Therefore it will be called when the job has received
+ * an UIDL from the server. Every received UID causes a call of this slot.
+ * When the job ends, it causes a last call but with an empty data array.
+ * The UIDs will be stored in receivedUIDs.
+ * @param data received data, which contain an uid
+ */
+ void slotReceiveUID( KIO::Job*, const QByteArray& data );
+
+ /**
+ * Connected with signal result of the launched pop3 job to get the UIDs.
+ * Will be invoked, when all UIDs are received and stored in receivedUIDs.
+ * Analyzes the received UID datas and creates new ShowRecordElem instances
+ * in the new mail list accordingly.
+ * @param job job which has emitted the result signal
+ */
+ void slotUIDsReceived( KIO::Job* job );
+
+ /**
+ * Connected with the signal "data" of the pop3 transfer job which gets mail
+ * Sizes. Therefore it will be called when the job has received
+ * a size from the server. Every received size causes a call of this slot.
+ * When the job ends, it causes a last call but with an empty data array.
+ * The UIDs will be stored in receivedSizes.
+ * @param data received data, which contain a size
+ */
+ void slotReceiveSize( KIO::Job*, const QByteArray& data );
+
+ /**
+ * Connected with signal result of the launched pop3 job to get the Sizes.
+ * Will be invoked, when all Sizes are received and stored in receivedSizes.
+ * Analyzes the received datas and writes these in the appropriate mail instances.
+ * @param job job which has emitted the result signal
+ */
+ void slotSizesReceived( KIO::Job* job );
+
+
+ /**
+ * Connected with signal result of the job which commits the refresh.
+ * Finalizes a succesful refresh.
+ * Emits sigRefreshReady and sets account state to idle
+ */
+ void slotFinalizeRefresh( KIO::Job* );
+
+ /**
+ * Connected with signal result of the launched pop3 job.
+ * Stores the received headers into the appropriate instance of the mail list.
+ * Removes the first mail from newMails and invokes
+ * getNextHeader() again to get the next header.
+ * If the list is empty after it has removed the first item, it will call
+ * copyHeaders().
+ * If an error has occured, it will call cancelRefresh().
+ * @param job job which has emit the result signal
+ * @see getNextHeader()
+ * @see newMails
+ * @see pop3Job
+ * @see cancelRefresh()
+ * @see copyHeaders()
+ */
+ void slotHeaderDownloaded( KIO::Job* job );
+
+ /**
+ * Connected with the signal "data" of the pop3 transfer job which gets a mail
+ * header. Therefore it will be called when the job has received
+ * a part of the header from the server.
+ * When the job ends, it causes a last call but with an empty data array.
+ * The complete header will be stored in receivedHeader.
+ * @param data received data, which contains a header part
+ */
+ void slotReceiveHeader( KIO::Job*, const QByteArray& data );
+
+ /**
+ * Connected with the result signal of the pop3 job launched by commitBeforeRefresh()
+ * Restarts a second refresh cycle after a deletion performed by the filter.
+ * @see commitBeforeRefresh
+ * @see applyFiltersDeleted
+ */
+ void slotCommitBeforeRefreshDone( KIO::Job* );
+
+
+ signals:
+
+ /**
+ * Will be emitted when all selected mails are deleted.
+ * @param account name of the account, which has emitted this signal
+ */
+ void sigDeleteReady( QString account );
+
+ /**
+ * Will be emitted when the bodies of all selected mails are
+ * downloaded and shown.
+ * @param account name of the account, which has emitted this signal
+ */
+ void sigShowBodiesReady( QString account );
+
+ /**
+ * Will be emitted when the settings have been changed.
+ */
+ void sigConfigChanged();
+
+ /**
+ * Will be emitted, when a window to show a message was opened.
+ */
+ void sigMessageWindowOpened();
+
+ /**
+ * Will be emitted, when a window to show a message was closed.
+ */
+ void sigMessageWindowClosed();
+
+ /**
+ * Will be emitted, when the mail list was refreshed.
+ * @param account name of the account, which has emitted this signal
+ */
+ void sigRefreshReady( QString account );
+
+ protected:
+
+ /**
+ * Forwards the given mail to SpamAssassin and returns the test result
+ * @param mail the mail to test
+ * @return TRUE - mail is spam
+ */
+ bool isSpam( QByteArray mail ) const;
+
+ /**
+ * Looks for a running spamd daemon of SpamAssassin.
+ * @return TRUE - SpamAssassin is running
+ */
+ bool isSpamAssassinRunning() const;
+
+
+
+};
+#endif
diff --git a/kshowmail/configlist.cpp b/kshowmail/configlist.cpp
new file mode 100644
index 0000000..0098550
--- /dev/null
+++ b/kshowmail/configlist.cpp
@@ -0,0 +1,1203 @@
+/***************************************************************************
+ configlist.cpp - description
+ -------------------
+ begin : Tue May 9 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+
+ 26 Sep 2002 - Allow for columns to be hidden. Allistar Melville
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <qfile.h>
+
+#include <kconfig.h>
+#include <ksavefile.h>
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <kaudioplayer.h>
+#include <kdebug.h>
+
+#include "configlist.h"
+
+ConfigList::ConfigList() : QObject()
+{
+ setAutoDelete (true);
+
+ //assume, no window to show a mail is open at beginning
+ ctrOpenMessageWindows = 0;
+
+ //set default values
+ m_bShowMessage = DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW;
+ m_bShowMainWindow = DEFAULT_ACTION_NEW_MAIL_MAINWINDOW;
+ m_bBeep = DEFAULT_ACTION_NEW_MAIL_BEEP;
+ m_bSound = DEFAULT_ACTION_NEW_MAIL_SOUND;
+ m_bCommand = DEFAULT_ACTION_NEW_MAIL_COMMAND;
+ m_bMinimize = DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE;
+ m_bTerminate = DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE;
+
+ m_bConfirmClose = DEFAULT_CONFIRM_CLOSE;
+ m_bConfirmDelete = DEFAULT_CONFIRM_DELETE;
+ m_bStartMinimized = DEFAULT_START_MINIMIZED;
+ m_bCloseMinimizes = DEFAULT_CLOSE_TO_TRAY;
+ m_bMinimizeToTray = DEFAULT_MINIMIZE_TO_TRAY;
+ m_bShowConnectionErrors = DEFAULT_SHOW_CONNECTION_ERRORS;
+ m_bKeepNew = DEFAULT_KEEP_NEW;
+ m_nInitTimer = DEFAULT_INITIAL_TIME;
+ m_nIntervalTimer = DEFAULT_INTERVAL_TIME;
+ m_nPop3Timer = DEFAULT_TIMEOUT_TIME;
+
+}
+
+int ConfigList::compareItems( QCollection::Item item1, QCollection::Item item2 )
+{
+ ConfigElem* p1 = (ConfigElem*)item1;
+ ConfigElem* p2 = (ConfigElem*)item2;
+
+ return strcmp( p1->getAccountName(), p2->getAccountName() );
+}
+
+QCollection::Item ConfigList::newItem( QCollection::Item item )
+{
+ return new ConfigElem( (ConfigElem*)item );
+}
+
+void ConfigList::saveOptions ()
+{
+ kdDebug () << "ConfigList::saveOptions" << endl;
+
+ //create XML document
+ QDomDocument doc( "KShowmail" );
+
+ //create root element
+ QDomElement accounts = doc.createElement( ROOT_ELEMENT );
+
+ //create for every account an element
+ //the account saves its mails into this element
+ //after that the element will be appended to the root element
+ int i = 0;
+ ConfigElem* account = NULL; //current processed account
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ //save mails
+ QDomElement accElem = doc.createElement( QString( ACCOUNT_ELEMENT ) + QString( "%1" ).arg( i++ ) );
+ account->saveOptions( doc, accElem ); //account saves the mails into given XML document and the setup into the application config file
+ accounts.appendChild( accElem );
+
+ }
+
+ //append root element to XML document
+ doc.appendChild( accounts );
+
+ //save XML document
+ QCString str = doc.toCString(); //convert XML document to a string
+ QString cachefilename = locateLocal( "config", MAIL_FILE ); //get file path
+ KSaveFile file( cachefilename, 0600 ); //create file
+
+ if( file.status() != 0 )
+ {
+ kdError() << "Couldn't save mail cache. " << strerror( file.status() );
+ return;
+ }
+
+ //write data
+ file.file()->writeBlock( str.data(), str.length() );
+
+ //close file
+ if( !file.close() )
+ {
+ kdError () << "Couldn't save mail cache. " << strerror(file.status());
+ return;
+ }
+}
+
+
+void ConfigList::setList (QListView* list)
+{
+ QPixmap pix (::locate ("data", "kshowmail/pics/ok.png"));
+ list->clear ();
+ int nIndex = at ();
+ QListViewItem* last = NULL;
+ for (ConfigElem* pElem = first(); pElem; pElem = next())
+ {
+ last = new QListViewItem (list, last, "", pElem->getAccountName(), pElem->getURL().host(), pElem->getURL().user(), "?");
+ pElem->setListViewItem( last );
+ if (pElem->isActive())
+ pElem->getListViewItem()->setPixmap (0, pix);
+ }
+
+ if (nIndex >= 0)
+ {
+ at (nIndex);
+// list->setCurrentItem (nIndex);
+ }
+}
+
+
+bool ConfigList::setItem (const char* item)
+{
+ int nPos = at ();
+ ConfigElem* pActive = new ConfigElem (this, item);
+ bool result = (find (pActive) >= 0);
+ delete pActive;
+ if (result)
+ return true;
+ else
+ {
+ at (nPos);
+ return false;
+ }
+}
+
+void ConfigList::beep ()
+{
+ if (m_bBeep)
+ kapp->beep ();
+}
+
+void ConfigList::playSound ()
+{
+ if (m_bSound)
+ playSound (m_strSoundFile);
+}
+
+void ConfigList::playSound (const char* file)
+{
+ KAudioPlayer::play(file);
+}
+
+int ConfigList::getRefreshTimeInterval( ) const
+{
+ return m_nIntervalTimer;
+}
+
+void ConfigList::setRefreshTimeInterval( unsigned int interval )
+{
+ m_nIntervalTimer = interval;
+}
+
+bool ConfigList::AutoRefreshOn( ) const
+{
+ return ( m_nIntervalTimer > 0 );
+}
+
+bool ConfigList::hasActiveAccounts( )
+{
+ bool activeAccountFound = false; //when a active account was found, this will be set to TRUE
+ ConfigElem* currentAccount; //saved current account
+ ConfigElem* Account; //used by the search
+
+ //save the current account
+ currentAccount = current();
+
+ //get the first account
+ Account = first();
+
+ //looking for an active account
+ while( Account != NULL && !activeAccountFound )
+ {
+ //have we found one?
+ activeAccountFound = Account->isActive();
+
+ //get next account
+ Account = next();
+ }
+
+ //set the saved account to current
+ if( currentAccount != NULL )
+ findRef( currentAccount );
+
+ //return the result
+ return activeAccountFound;
+}
+
+
+uint ConfigList::getTimeoutTime( ) const
+{
+ return m_nPop3Timer;
+}
+
+void ConfigList::setTimeoutTime( uint time )
+{
+ if( time < MINIMUM_TIMEOUT_TIME )
+ m_nPop3Timer = MINIMUM_TIMEOUT_TIME;
+ else
+ m_nPop3Timer = time;
+}
+
+ConfigElem* ConfigList::getSelectedAccount( )
+{
+ //get the first account in the list
+ ConfigElem* account = first();
+
+ //return NULL if there are no accounts
+ if( account == NULL )
+ return NULL;
+
+ //return the account, if it is selected
+ if( account->isSelected() )
+ return account;
+
+ //iterate over all accounts
+ bool selectedAccountFound = false; //is TRUE, if a selected account was found
+ while( account != NULL && !selectedAccountFound )
+ {
+ //get next account
+ account = next();
+
+ //is the account selected?
+ if( account != NULL )
+ selectedAccountFound = account->isSelected();
+ else
+ selectedAccountFound = false;
+ }
+
+ //return the current account if we have found a selected account
+ //otherwise return FALSE
+ if( selectedAccountFound )
+ return account;
+ else
+ return NULL;
+}
+
+void ConfigList::deleteSelectedMails( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //clear the map, which contains the names of the accounts,
+ //which have gotten an order to delete
+ AccountDeletionMap.clear();
+
+ //refresh connects
+ connectAccounts();
+
+ //inserts an item for every account which will get an order to delete
+ //its selected mails. The key is the account name and the data is TRUE.
+ //it is important to do this in a seperate iteration because this avoids
+ //race conditions
+ while( ( account = it.current() ) != NULL )
+ {
+ //insert item
+ AccountDeletionMap.insert( account->getAccountName(), true );
+
+ //get next account
+ ++it;
+ }
+
+ //order all accounts to delete its selected mail
+ it.toFirst();
+ while( ( account = it.current() ) != NULL )
+ {
+ account->deleteSelectedMails();
+
+ //get next account
+ ++it;
+ }
+}
+
+void ConfigList::slotAccountConfigChanged( )
+{
+ emit sigConfigChanged();
+}
+
+void ConfigList::slotCheckDeletionState( QString account )
+{
+ bool accountDeleting = false; //set to TRUE if an account is still deleting
+ AccountTaskMap_Type::Iterator it; //iterator over the account deletion map
+
+ //set the appropriate item in AccountDeletionMap to FALSE
+ AccountDeletionMap[ account ] = false;
+
+ //iterate over the account deletion map to check, whether all accounts
+ //are ready
+ for ( it = AccountDeletionMap.begin(); it != AccountDeletionMap.end(); ++it )
+ {
+ if( *it == true )
+ accountDeleting = true;
+ }
+
+ //emit sigDeleteReady if all accounts are ready
+ if( !accountDeleting )
+ emit sigDeleteReady();
+}
+
+void ConfigList::connectAccounts( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to connect
+
+ while( ( account = it.current() ) != NULL )
+ {
+ //disconnect old connections
+ account->disconnect();
+
+ //connect
+ connect( account, SIGNAL( sigConfigChanged() ), this, SLOT( slotAccountConfigChanged() ) );
+ connect( account, SIGNAL( sigDeleteReady( QString ) ), this, SLOT( slotCheckDeletionState( QString ) ) );
+ connect( account, SIGNAL( sigShowBodiesReady( QString ) ), this, SLOT( slotCheckShowBodiesState( QString ) ) );
+ connect( account, SIGNAL( sigMessageWindowOpened() ), this, SLOT( slotMessageWindowOpened() ) );
+ connect( account, SIGNAL( sigMessageWindowClosed() ), this, SLOT( slotMessageWindowClosed() ) );
+ connect( account, SIGNAL( sigRefreshReady( QString ) ), this, SLOT( slotCheckRefreshState( QString ) ) );
+
+ //get next account
+ ++it;
+ }
+}
+
+void ConfigList::setConfirmDeletion( bool confirm )
+{
+ m_bConfirmDelete = confirm;
+}
+
+bool ConfigList::confirmDeletion( )
+{
+ return m_bConfirmDelete;
+}
+
+QStringList ConfigList::getSelectedSubjects( ) const
+{
+ QStringList subjects; //contains all subjects
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //current account
+
+ while( ( account = it.current() ) != NULL )
+ {
+ //get subjects of the current account and append them to the list
+ subjects += account->getSelectedSubjects();
+
+ //get next account
+ ++it;
+ }
+
+ return subjects;
+}
+
+bool ConfigList::hasSelectedMails( )
+{
+ bool foundSelected = false; //set to TRUE, when an account with selected mails was found
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //current account
+
+ while( ( account = it.current() ) != NULL && !foundSelected )
+ {
+ foundSelected = account->hasSelectedMails();
+
+ //get next account
+ ++it;
+ }
+
+ return foundSelected;
+
+}
+
+void ConfigList::showSelectedMails( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //clear the map, which contains the names of the accounts,
+ //which have gotten an order to show mails
+ AccountShowBodiesMap.clear();
+
+ //refresh connects
+ connectAccounts();
+
+ //inserts an item for every account which will get an order to show
+ //its selected mails. The key is the account name and the data is TRUE.
+ //it is important to do this in a seperate iteration because this avoids
+ //race conditions
+ while( ( account = it.current() ) != NULL )
+ {
+ //insert item
+ AccountShowBodiesMap.insert( account->getAccountName(), true );
+
+ //get next account
+ ++it;
+ }
+
+ //order all accounts to show its selected mail
+ it.toFirst();
+ while( ( account = it.current() ) != NULL )
+ {
+ account->showSelectedMails();
+
+ //get next account
+ ++it;
+ }
+
+}
+
+void ConfigList::slotCheckShowBodiesState( QString account )
+{
+ bool accountDownloading = false; //set to TRUE if an account is downloading mail body yet
+ AccountTaskMap_Type::Iterator it; //iterator over the account map
+
+ //set the appropriate item in AccountShowBodiesMap to FALSE
+ AccountShowBodiesMap[ account ] = false;
+
+ //iterate over the account map to check, whether all accounts
+ //are ready
+ for ( it = AccountShowBodiesMap.begin(); it != AccountShowBodiesMap.end(); ++it )
+ {
+ if( *it == true )
+ accountDownloading = true;
+ }
+
+ //emit sigShowBodiesReady if all accounts are ready
+ //and assume all windows to show the mails are closed
+ if( !accountDownloading )
+ {
+ emit sigShowBodiesReady();
+ ctrOpenMessageWindows = 0;
+ }
+}
+
+void ConfigList::setAllowHTML( bool allowHTML )
+{
+ m_bAllowHTML = allowHTML;
+}
+
+bool ConfigList::allowHTML( ) const
+{
+ return m_bAllowHTML;
+}
+
+void ConfigList::slotMessageWindowOpened( )
+{
+ //increment the window counter
+ ctrOpenMessageWindows++;
+
+ //if the counter was incremented from zero
+ //(the first window was opened), emit the
+ //signal
+ if( ctrOpenMessageWindows == 1 )
+ emit sigMessageWindowOpened();
+}
+
+void ConfigList::slotMessageWindowClosed( )
+{
+ //decrement the window counter
+ ctrOpenMessageWindows--;
+ if( ctrOpenMessageWindows < 0 )
+ ctrOpenMessageWindows = 0;
+
+ //if counter is zero (all windows was closed),
+ //emit signal
+ if( ctrOpenMessageWindows == 0 )
+ emit sigAllMessageWindowsClosed();
+}
+
+void ConfigList::refreshMailLists( FilterLog* log )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //return, if no accounts available
+ if( count() == 0 )
+ {
+ emit sigRefreshReady();
+ return;
+ }
+
+ //clear the map, which contains the names of the accounts,
+ //which have gotten an order to show mails
+ AccountRefreshMap.clear();
+
+ //refresh connects
+ connectAccounts();
+
+ //inserts an item for every account which will get an order to refresh
+ //its mail list. The key is the account name and the data is TRUE.
+ //it is important to do this in a seperate iteration because this avoids
+ //race conditions
+ while( ( account = it.current() ) != NULL )
+ {
+ //insert item
+ AccountRefreshMap.insert( account->getAccountName(), true );
+
+ //get next account
+ ++it;
+ }
+
+ //order all accounts to refresh their mail lists
+ it.toFirst();
+ while( ( account = it.current() ) != NULL )
+ {
+ account->refreshMailList( log );
+
+ //get next account
+ ++it;
+ }
+
+}
+
+void ConfigList::slotCheckRefreshState( QString account )
+{
+ bool accountRefreshing = false; //set to TRUE if an account is still refreshing
+ AccountTaskMap_Type::Iterator it; //iterator over the account map
+
+ //set the appropriate item in AccountRefreshMap to FALSE
+ AccountRefreshMap[ account ] = false;
+
+ //iterate over the account map to check whether all accounts
+ //are ready
+ for ( it = AccountRefreshMap.begin(); it != AccountRefreshMap.end(); ++it )
+ {
+ if( *it == true )
+ accountRefreshing = true;
+ }
+
+ //emit sigRefreshReady if all accounts are ready
+ if( !accountRefreshing )
+ {
+ emit sigRefreshReady();
+ }
+
+}
+
+int ConfigList::getNumberNewMails( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+ int number = 0; //number of new mails
+
+ //iterate over all accounts and sum up the number of new mails
+ while( ( account = it.current() ) != NULL )
+ {
+ if( account->isActive() )
+ number += account->getNumberNewMails();
+
+ //get next account
+ ++it;
+ }
+
+ return number;
+}
+
+int ConfigList::getNumberMails( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+ int number = 0; //number of mails
+
+ //iterate over all accounts and sum up the number of mails
+ while( ( account = it.current() ) != NULL )
+ {
+ if( account->isActive() )
+ number += account->getNumberMails();
+
+ //get next account
+ ++it;
+ }
+
+ return number;
+}
+
+long ConfigList::getTotalSize( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+ long size = 0; //total size of all mails
+
+ //iterate over all accounts and sum up the size of all mails
+ while( ( account = it.current() ) != NULL )
+ {
+ if( account->isActive() )
+ size += account->getTotalSize();
+
+ //get next account
+ ++it;
+ }
+
+ return size;
+}
+
+void ConfigList::fillMailListView( KshowmailView * view )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //iterate over all accounts and order the active accounts to fill their mails
+ //into the list view
+ while( ( account = it.current() ) != NULL )
+ {
+ if( account->isActive() )
+ account->fillMailListView( view );
+
+ //get next account
+ ++it;
+ }
+
+}
+
+bool ConfigList::showMainWindowForNewMails( )
+{
+ return m_bShowMainWindow;
+}
+
+bool ConfigList::showAlertMessageForNewMails( )
+{
+ return m_bShowMessage;
+}
+
+bool ConfigList::quitNoNewMails( )
+{
+ return m_bTerminate;
+}
+
+bool ConfigList::minimizeMainWindowNoNewMails( )
+{
+ return m_bMinimize;
+}
+
+int ConfigList::getInitTime( )
+{
+ return m_nInitTimer;
+}
+
+void ConfigList::setInitTime( int time )
+{
+ if( time >= 0 )
+ m_nInitTimer = time;
+ else
+ m_nInitTimer = 0;
+}
+
+bool ConfigList::hasInitTime( )
+{
+ return m_nInitTimer > 0;
+}
+
+void ConfigList::refreshAccountList( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //iterate over all accounts and order the account to refresh its
+ //account list view item
+ while( ( account = it.current() ) != NULL )
+ {
+ account->refreshAccountListItem();
+
+ //get next account
+ ++it;
+ }
+
+}
+
+void ConfigList::killPOP3Jobs( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+
+ //iterate over all accounts and order the account to kill
+ //a running pop3 job
+ while( ( account = it.current() ) != NULL )
+ {
+ account->killPOP3Job();
+
+ //get next account
+ ++it;
+ }
+}
+
+void ConfigList::showSelectedHeaders( )
+{
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //account to process
+ int showNextHeader = ConfigElem::continueShowHeaders; //return value of ConfigElem::showSelectedHeaders
+
+ //iterate over all accounts and order the account to show
+ //the headers of all selected mails.
+ while( ( account = it.current() ) != NULL && showNextHeader == ConfigElem::continueShowHeaders )
+ {
+ if( account->hasSelectedMails() )
+ showNextHeader = account->showSelectedHeaders();
+
+ //get next account
+ ++it;
+ }
+}
+
+void ConfigList::refreshSetup( KListView* view )
+{
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //read actions group
+ config->setGroup( CONFIG_GROUP_ACTIONS );
+
+ m_bShowMessage = config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_ALERTWINDOW, DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW );
+ m_bShowMainWindow = config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_MAINWINDOW, DEFAULT_ACTION_NEW_MAIL_MAINWINDOW );
+ m_bBeep = config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_BEEP, DEFAULT_ACTION_NEW_MAIL_BEEP );
+ m_bSound = config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_SOUND, DEFAULT_ACTION_NEW_MAIL_SOUND );
+ m_strSoundFile = config->readEntry( CONFIG_ENTRY_NEW_MAIL_SOUNDPATH );
+ m_bCommand = config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_COMMAND, DEFAULT_ACTION_NEW_MAIL_COMMAND );
+ m_strCommandPath = config->readEntry( CONFIG_ENTRY_NEW_MAIL_COMMANDPATH );
+ m_bMinimize = config->readBoolEntry( CONFIG_ENTRY_NO_NEW_MAIL_MINIMIZE, DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE );
+ m_bTerminate = config->readBoolEntry( CONFIG_ENTRY_NO_NEW_MAIL_TERMINATE, DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE );
+
+ //read general group
+ config->setGroup( CONFIG_GROUP_GENERAL );
+ m_bConfirmClose = config->readBoolEntry( CONFIG_ENTRY_CONFIRM_CLOSE, DEFAULT_CONFIRM_CLOSE );
+ m_bConfirmDelete = config->readBoolEntry( CONFIG_ENTRY_CONFIRM_DELETE, DEFAULT_CONFIRM_DELETE );
+ m_bStartMinimized = config->readBoolEntry( CONFIG_ENTRY_START_MINIMIZED, DEFAULT_START_MINIMIZED );
+ m_bCloseMinimizes = config->readBoolEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, DEFAULT_CLOSE_TO_TRAY );
+ m_bMinimizeToTray = config->readBoolEntry( CONFIG_ENTRY_MINIMIZE_TO_TRAY, DEFAULT_MINIMIZE_TO_TRAY );
+ m_bShowConnectionErrors = config->readBoolEntry( CONFIG_ENTRY_SHOW_CONNECTION_ERRORS, DEFAULT_SHOW_CONNECTION_ERRORS );
+ m_bKeepNew = config->readBoolEntry( CONFIG_ENTRY_KEEP_NEW, DEFAULT_KEEP_NEW );
+
+ m_nInitTimer = config->readNumEntry( CONFIG_ENTRY_INITIAL_TIME, DEFAULT_INITIAL_TIME );
+ m_nIntervalTimer = config->readNumEntry( CONFIG_ENTRY_INTERVAL_TIME, DEFAULT_INTERVAL_TIME);
+ m_nPop3Timer = config->readNumEntry( CONFIG_ENTRY_TIMEOUT_TIME, DEFAULT_TIMEOUT_TIME );
+
+ //read display group
+ config->setGroup( CONFIG_GROUP_VIEW );
+ m_bAllowHTML = config->readBoolEntry( CONFIG_ENTRY_VIEW_USE_HTML, DEFAULT_VIEW_USE_HTML );
+
+ //read Spam configs
+ config->setGroup( CONFIG_GROUP_SPAMCHECK );
+ int intSpamAction = config->readNumEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, DEFAULT_SPAMCHECK_ACTION );
+
+ switch( intSpamAction )
+ {
+ case CONFIG_VALUE_SPAMCHECK_ACTION_DELETE : spamAction = FActDelete; break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MARK : spamAction = FActMark; break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MOVE : spamAction = FActMove; break;
+ default :
+ kdError() << "Invalid value in " << CONFIG_ENTRY_SPAMCHECK_ACTION << ". Set default value." << endl;
+ switch( DEFAULT_SPAMCHECK_ACTION )
+ {
+ case CONFIG_VALUE_SPAMCHECK_ACTION_DELETE : spamAction = FActDelete; break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MARK : spamAction = FActMark; break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MOVE : spamAction = FActMove; break;
+ default : spamAction = FActMark; break;
+ }
+
+ }
+
+ if( spamAction == FActMove )
+ spamMailbox = config->readEntry( CONFIG_ENTRY_SPAMCHECK_MOVE_MAILBOX, DEFAULT_SPAMCHECK_ACTION_MOVE_MAILBOX );
+
+
+ //read account configuration and setup accounts
+ //---------------------------------------------
+
+ //get account names from the config file
+ config->setGroup( CONFIG_GROUP_ACCOUNTS );
+ QStringList accounts = config->readListEntry( CONFIG_ENTRY_ACCOUNTS_LIST, QStringList() );
+
+ //remove deleted accounts from the account list
+ //accounts are deleted, if the are in ConfigList yet, but not in the list of the config file (accounts)
+ ConfigElem* accountDel = NULL; //current processed account
+ QPtrListIterator<ConfigElem> iter( *this ); //iterator for the account list (ConfigList)
+
+ //iterate over all accounts (ConfigList)
+ while( ( accountDel = iter.current() ) != NULL )
+ {
+ //increment iterator to get next account
+ ++iter;
+
+ //search for the current account in the account list of the config file
+ QStringList::Iterator foundAccount = accounts.find( accountDel->getAccountName() );
+
+ //remove account from ConfigList, if it is not in the list of the config file
+ if( foundAccount == accounts.end() )
+ remove( accountDel );
+ }
+
+ //add or edit accounts
+ ConfigElem* acc;
+ //iterate over all items of the account list of the config file
+ for( QStringList::Iterator it = accounts.begin(); it != accounts.end(); ++it )
+ {
+ //create a new account, if it is not in the list yet (ConfigList)
+ //or get the account
+ if( !hasAccount( *it ) )
+ {
+ //create new account
+ acc = new ConfigElem( this, *it );
+ inSort( acc );
+
+ //the pointer list inserts a copy of the new account object
+ //we have to delete the original
+ delete acc;
+ }
+
+ //get account from ConfigList
+ acc = getAccount( *it );
+
+ //get the setup of the account from the config file and setup the account
+ config->setGroup( *it );
+
+ acc->setHost( config->readEntry( CONFIG_ENTRY_ACCOUNT_SERVER, DEFAULT_ACCOUNT_SERVER ) );
+
+ //set protocol and security
+ //if the read protocol is POP3 and SSL is enabled, the account protocol will set to "pop3s"
+ QString proto = config->readEntry( CONFIG_ENTRY_ACCOUNT_PROTOCOL, DEFAULT_ACCOUNT_PROTOCOL ).lower();
+ int secureTransfer = config->readNumEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, DEFAULT_ACCOUNT_SECTRANSFER );
+
+ if( proto == "pop3" && secureTransfer == CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL )
+ {
+ acc->setProtocol( "pop3s" );
+ }
+ else
+ {
+ acc->setProtocol( proto );
+ }
+
+ if( secureTransfer == CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS )
+ acc->setTLS( true );
+ else
+ acc->setTLS( false );
+
+
+ acc->setPort( config->readNumEntry( CONFIG_ENTRY_ACCOUNT_PORT, DEFAULT_ACCOUNT_PORT_POP3 ) );
+ acc->setUser( config->readEntry( CONFIG_ENTRY_ACCOUNT_USER, DEFAULT_ACCOUNT_USER ) );
+ acc->setActive( config->readBoolEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, DEFAULT_ACCOUNT_ACTIVE ) );
+ int StorageType = config->readNumEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+
+ switch( StorageType )
+ {
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE:
+ acc->setPasswordStorage( CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE );
+ acc->setPassword( QString::null );
+ break;
+
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE:
+ acc->setPasswordStorage( CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE );
+ acc->setPassword( Encryption::decrypt( config->readEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, DEFAULT_ACCOUNT_PASSWORD ) ) );
+ break;
+
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET:
+ acc->setPasswordStorage( CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET );
+ acc->setPassword( KWalletAccess::getPassword( *it ) );
+ break;
+
+ default:
+ acc->setPasswordStorage( DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+ acc->setPassword( QString::null );
+ }
+
+ //order the account to reloads its filter setup
+ acc->reloadFilterSettings();
+ }
+
+ //connect the signals of the accounts with ConfigList
+ connectAccounts();
+
+ //refresh account list view
+ setList( view );
+}
+
+void ConfigList::executeNewMailCommand( )
+{
+ if( m_bCommand )
+ {
+ if( m_strCommandPath != QString::null && m_strCommandPath != "" )
+ {
+ KShellProcess proc; //process handler to execute the binary
+
+ proc << m_strCommandPath;
+
+ proc.start( KShellProcess::DontCare );
+ }
+ }
+}
+
+bool ConfigList::keepNew( )
+{
+ return m_bKeepNew;
+}
+
+bool ConfigList::confirmClose( ) const
+{
+ return m_bConfirmClose;
+}
+
+bool ConfigList::startMinimized( ) const
+{
+ return m_bStartMinimized;
+}
+
+bool ConfigList::closeToTray( ) const
+{
+ return m_bCloseMinimizes;
+}
+
+bool ConfigList::minimizesToTray( ) const
+{
+ return m_bMinimizeToTray;
+}
+
+bool ConfigList::showConnectionErrors( ) const
+{
+ return m_bShowConnectionErrors;
+}
+
+bool ConfigList::hasAccount( const QString & name ) const
+{
+ bool found = false; //TRUE if we have found the given account
+ ConfigElem* account; //account from which we want to get its name
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next account
+ ++it;
+
+ //if current account is the searched one set found to TRUE
+ if( account->getAccountName() == name )
+ found = true;
+ }
+
+ return found;
+}
+
+ConfigElem * ConfigList::getAccount( const QString & name ) const
+{
+ bool found = false; //TRUE if we have found the given account
+ ConfigElem* account = NULL; //account from which we want to get its name
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ ConfigElem* returnValue = NULL;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next account
+ ++it;
+
+ //if current account is the searched one set found to TRUE
+ if( account->getAccountName() == name )
+ {
+ found = true;
+ returnValue = account;
+ }
+ }
+
+ return returnValue;
+}
+
+void ConfigList::printSetup( )
+{
+ ConfigElem* account = NULL; //account from which we want to print the setup
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ //print setup
+ account->printSetup();
+ }
+}
+
+void ConfigList::readStoredMails( )
+{
+ //open file
+ QString MailFileName = locateLocal( "config", MAIL_FILE );
+ QFile file( MailFileName );
+ bool fileOpen = file.open( IO_ReadOnly );
+
+ //return, if the file could not be opened
+ if( !fileOpen )
+ {
+ kdError() << "ConfigList::readStoredMails: File " << MailFileName << " could not be opened." << endl;
+ return;
+ }
+
+ //create DOM document with the content read from the file
+ QDomDocument doc( MAIL_FILE_DOCTYPE );
+ QString* errorMsg = new QString();
+
+ bool success = doc.setContent( &file );
+ if( !success )
+ {
+ kdError() << "ConfigList::readStoredMails: Invalid content in " << MAIL_FILE << ". " << *errorMsg << endl;
+ }
+
+ //get the root element
+ QDomElement accounts = doc.namedItem ( ROOT_ELEMENT ).toElement();
+
+ //get the first account element
+ QDomNode accNode = accounts.firstChild();
+
+ //get all account elements
+ while( !accNode.isNull() )
+ {
+ //convert account node to DOM element
+ QDomElement accElem = accNode.toElement();
+
+ //get the account name
+ QString accName = accElem.attribute( ATTRIBUTE_ACCOUNT_NAME );
+
+ //get the proper account object
+ ConfigElem* account = getAccount( accName );
+
+ //order the account to read its stored mails
+ account->readStoredMails( accElem );
+
+ //get next account node
+ accNode = accNode.nextSibling();
+ }
+
+ //close file
+ file.close();
+}
+
+FilterAction_Type ConfigList::getSpamAction( )
+{
+ return spamAction;
+}
+
+QString ConfigList::getSpamMailbox( )
+{
+ return spamMailbox;
+}
+
+int ConfigList::numberDeletedMailsLastRefresh( )
+{
+ ConfigElem* account = NULL;
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ int number = 0;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ number += account->numberDeletedMailsLastRefresh();
+ }
+
+ return number;
+}
+
+int ConfigList::numberDeletedMailsStart( )
+{
+ ConfigElem* account = NULL;
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ int number = 0;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ number += account->numberDeletedMailsStart();
+ }
+
+ return number;
+}
+
+int ConfigList::numberMovedMailsLastRefresh( )
+{
+ ConfigElem* account = NULL;
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ int number = 0;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ number += account->numberMovedMailsLastRefresh();
+ }
+
+ return number;
+}
+
+int ConfigList::numberMovedMailsStart( )
+{
+ ConfigElem* account = NULL;
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ int number = 0;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ number += account->numberMovedMailsStart();
+ }
+
+ return number;
+}
+
+int ConfigList::numberIgnoredMails( )
+{
+ ConfigElem* account = NULL;
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+ int number = 0;
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ number += account->numberIgnoredMails();
+ }
+
+ return number;
+}
+
+QStringList ConfigList::getSelectedSenders( ) const
+{
+ QStringList senders; //contains all senders
+ QPtrListIterator<ConfigElem> it( *this ); //to iterate over all accounts
+ ConfigElem* account; //current account
+
+ while( ( account = it.current() ) != NULL )
+ {
+ //get senders of the current account and append them to the list
+ senders += account->getSelectedSenders();
+
+ //get next account
+ ++it;
+ }
+
+ return senders;
+}
+
+void ConfigList::refreshFilterSetup( )
+{
+ ConfigElem* account; //account
+ QPtrListIterator<ConfigElem> it( *this ); //iterator for the account list
+
+ //iterate over all accounts
+ while( ( account = it.current() ) != NULL )
+ {
+ //increment iterator to next account
+ ++it;
+
+ //reload filter setup of the current account
+ account->reloadFilterSettings();
+ }
+
+}
+
+
diff --git a/kshowmail/configlist.h b/kshowmail/configlist.h
new file mode 100644
index 0000000..97418cd
--- /dev/null
+++ b/kshowmail/configlist.h
@@ -0,0 +1,734 @@
+/***************************************************************************
+ configlist.h - description
+ -------------------
+ begin : Tue May 9 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ (C) 2007 by Ulrich Weigelt
+ email : eggert.ehmke@berlin.de
+ ulrich.weigelt@gmx.de
+
+ 26 Sep 2002 - Allow for columns to be hidden. Allistar Melville
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef CONFIGLIST_H
+#define CONFIGLIST_H
+
+//Qt header
+#include <qptrlist.h>
+#include <qlistview.h>
+#include <qobject.h>
+
+//KDE headers
+#include <kcombobox.h>
+#include <kprocess.h>
+#include <kdebug.h>
+
+//KShowmail headers
+#include "configelem.h"
+#include "constants.h"
+#include "kshowmailview.h"
+#include "types.h"
+#include "encryption.h"
+#include "kwalletaccess.h"
+#include "filteritem.h"
+#include "headerfilter.h"
+#include "filterlog.h"
+
+using namespace Constants;
+using namespace Types;
+using namespace Encryption;
+
+class ConfigElem;
+class KshowmailView;
+
+/**
+ * Contains the application and account settings. The account
+ * settings are stored in ConfigElem objects.
+ * @author Eggert Ehmke
+ * @author Ulrich Weigelt
+ */
+class ConfigList : public QObject, public QPtrList<ConfigElem>
+{
+
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Constructor.
+ */
+ ConfigList ();
+
+ /**
+ * Destructor
+ */
+ virtual ~ConfigList () {};
+
+ /**
+ * Reads the setup from the configuration file (kshowmailrc) and
+ * sets the properties.
+ * @param view pointer to the account list view
+ */
+ void refreshSetup( KListView* view );
+
+ /**
+ * Reloads the filter settings
+ */
+ void refreshFilterSetup();
+
+ /**
+ * Returns the auto refresh time interval.
+ * @return refresh time interval [minutes]
+ */
+ int getRefreshTimeInterval() const;
+
+ /**
+ * Sets the auto refresh time interval.
+ * @param interval the new time interval [minutes]
+ */
+ void setRefreshTimeInterval( unsigned int interval );
+
+ /**
+ * Returns whether auto refresh is on.
+ * @return TRUE - auto refresh is on; FALSE - auto refresh is off
+ */
+ bool AutoRefreshOn() const;
+
+ /**
+ * Sets whether the user has to confirm a deletion.
+ * @param confirm TRUE - user has to confirm; FALSE - the user does not have to confirm
+ */
+ void setConfirmDeletion( bool confirm );
+
+ /**
+ * Returns whether the user has to confirm a deletion.
+ * @return TRUE - the user has to confirm
+ * @return FALSE - the user does not have to confirm
+ */
+ bool confirmDeletion();
+
+ /**
+ * Returns whether the user has to confirm window close.
+ * @return TRUE - user has to confirm
+ * @return FALSE - user does not have to confirm
+ */
+ bool confirmClose() const;
+
+ /**
+ * Returns whether the app shall start minimized.
+ * @return TRUE - start minimized
+ * @return FALSE - don't start minimized
+ */
+ bool startMinimized() const;
+
+ /**
+ * Returns whether the close button leaves the application running in tray.
+ * @return TRUE - leaves running
+ * @return FALSE - app will be closed
+ */
+ bool closeToTray() const;
+
+ /**
+ * Returns whether minimizes to the tray rather than to the taskbar.
+ * @return TRUE - minimizes to the tray
+ * @return FALSE - minimizes to the taskbar
+ */
+ bool minimizesToTray() const;
+
+ /**
+ * Returns whether connection errors will be shown during refresh.
+ * @return TRUE - show errors
+ * @return FALSE - don't show errors
+ */
+ bool showConnectionErrors() const;
+
+ /**
+ * Sets whether the mail show dialog has to use HTML.
+ * @param allowHTML TRUE - the dialog has to use HTML; FALSE - the dialog must not use HTML
+ * @see m_bAllowHTML
+ * */
+ void setAllowHTML( bool allowHTML );
+
+ /**
+ * Returns whether the mail show dialog has to use HTML.
+ * @return TRUE - the dialog has to use HTML
+ * @return FALSE - the dialog must not use HTML
+ * @see m_bAllowHTML
+ */
+ bool allowHTML() const;
+
+ /**
+ * Returns whether there are active accounts.
+ * Doesn't set the current account.
+ * @return TRUE - Yes, there are active accounts (at least one :o) ); FALSE - no active accounts
+ */
+ bool hasActiveAccounts();
+
+ /**
+ * Returns the number of seconds the application will be wait for a pop3 job.
+ * @return seconds to timeout
+ */
+ uint getTimeoutTime() const;
+
+ /**
+ * Sets the number of seconds the application will be wait for a pop3 job.
+ * Minimum time is POP3_MINIMUM_TIMEOUT_TIME seconds.
+ * @param time seconds to timeout
+ * @see constants.h
+ */
+ void setTimeoutTime( uint time );
+
+ /**
+ * Returns the first account, for which an appropriate item is
+ * selected in the account list view.
+ * @return pointer to the selected account object
+ * @return NULL - no account is selected
+ */
+ ConfigElem* getSelectedAccount();
+
+ /**
+ * Deletes all selected mails from the servers and the mail lists.
+ * This just starts the deletion and returns after then. When all
+ * accounts are ready the signal sigDeleteReady will be emitted.
+ */
+ void deleteSelectedMails();
+
+ /**
+ * Connects the signals of the accounts with the slots of this
+ * class.
+ * It is necessary to do this after an account has been appended to the
+ * list and it is a good idea to call this method before you invoke
+ * an operation on an account that may emit a signal.
+ * The reason is that the pointer list seemingly often changes the
+ * adresses of the inserted accounts. After that the connections are corrupt.
+ */
+ void connectAccounts();
+
+ /**
+ * Returns the subjects of the selected mails.
+ * @return subjects of selected mails
+ */
+ QStringList getSelectedSubjects() const;
+
+ /**
+ * Returns whether there are mails in this list which are selected
+ * in the list view.
+ * @return TRUE - there are selected mails
+ * @return FALSE - there aren't selected mails
+ */
+ bool hasSelectedMails();
+
+ /**
+ * Downloads and shows the bodies of the selected mails.
+ * This just starts the download and returns after then. When all
+ * bodies are downloaded and shown the signal sigShowBodiesReady will be
+ * emitted.
+ */
+ void showSelectedMails();
+
+ /**
+ * Refreshes the mail list of all accounts.
+ * This just starts the refresh and returns after then. When all
+ * accounts have refreshed their mail list the signal sigRefreshReady will be
+ * emitted.
+ * @param log Pointer to the filter log.
+ */
+ void refreshMailLists( FilterLog* log = NULL );
+
+ /**
+ * Returns the number of new mails.
+ * @return number of new mails
+ */
+ int getNumberNewMails();
+
+ /**
+ * Returns the number of mails.
+ * @return number of mails
+ */
+ int getNumberMails();
+
+ /**
+ * Returns the total size of all mails.
+ * @return total size
+ */
+ long getTotalSize();
+
+ /**
+ * Creates for every mail a list view item and inserts it
+ * into the mail list view.
+ * @param view pointer to the application view
+ */
+ void fillMailListView( KshowmailView* view );
+
+ /**
+ * Returns whether the main window will be shown, if
+ * new mails was received.
+ * @return TRUE - main window will be shown
+ * @return FALSE - main window will not be shown
+ */
+ bool showMainWindowForNewMails();
+
+ /**
+ * Returns whether an alert message will be shown if
+ * new mails were received.
+ * @return TRUE - will be shown
+ * @return FALSE - will not be shown
+ */
+ bool showAlertMessageForNewMails();
+
+ /**
+ * Returns whether the app will be terminated if
+ * no new mails were received.
+ * @return TRUE - will be terminated
+ * @return FALSE - will not be terminated
+ */
+ bool quitNoNewMails();
+
+ /**
+ * Returns whether the main window will be minimized, if
+ * no new mails were received.
+ * @return TRUE - main window will be minimized
+ * @return FALSE - main window will not be minimized
+ */
+ bool minimizeMainWindowNoNewMails();
+
+ /**
+ * Returns the configured time to the first refresh.
+ * @return time to the first refresh (seconds)
+ */
+ int getInitTime();
+
+ /**
+ * Sets the time to the first refresh.
+ * @param time time (seconds) to the first refresh
+ */
+ void setInitTime( int time );
+
+ /**
+ * Returns whether a time to first refresh is configured.
+ * @return TRUE - init time configured
+ * @return FALSE - no init time configured
+ */
+ bool hasInitTime();
+
+ /**
+ * Refreshes the account list (number of mails and total size).
+ */
+ void refreshAccountList();
+
+ /**
+ * Kills all running pop3 jobs.
+ */
+ void killPOP3Jobs();
+
+ /**
+ * Shows the headers of all selected mails.
+ */
+ void showSelectedHeaders();
+
+ /**
+ * Executes the configure new mail command.
+ * Does nothing, if the command option is switched off (m_bCommand == false).
+ */
+ void executeNewMailCommand();
+
+ /**
+ * Returns whether all new mails will keep new status until the app is closed.
+ * @return TRUE - mails keep new status at next refresh
+ * @return FALSE - mails don't keep new status at next refresh
+ */
+ bool keepNew();
+
+ /**
+ * Prints the setup.
+ */
+ void printSetup();
+
+ /**
+ * Saves the current mails data and the account setups.
+ * The mails data will be saved into an XML file (kshowmail.xml).
+ * The account setups will be saved into the application config file (kshowmailrc).
+ */
+ void saveOptions();
+
+ /**
+ * Reads stored mails data.
+ * At every setup saving (e.g. at exit) the mails data will be stored into the file kshowmail.xml.
+ * At application start we read this file to identify mails which are not new at first refresh.
+ */
+ void readStoredMails();
+
+ /**
+ * Returns the action to used on spam mails
+ * @return action to used on spam mails
+ */
+ FilterAction_Type getSpamAction();
+
+ /**
+ * Returns the mailbox for spam mails
+ * @return mailbox for spam
+ */
+ QString getSpamMailbox();
+
+ /**
+ * Returns the number of deleted mails by last refresh.
+ * @return number of deleted mails by last refresh
+ */
+ int numberDeletedMailsLastRefresh();
+
+ /**
+ * Returns the number of deleted mails since start.
+ * @return number of deleted mails since start
+ */
+ int numberDeletedMailsStart();
+
+ /**
+ * Returns the number of moved mails by last refresh.
+ * @return number of moved mails by last refresh
+ */
+ int numberMovedMailsLastRefresh();
+
+ /**
+ * Returns the number of moved mails since start.
+ * @return number of moved mails since start
+ */
+ int numberMovedMailsStart();
+
+ /**
+ * Returns the number of ignored mails by last refresh.
+ * @return number of ignored mails by last refresh
+ */
+ int numberIgnoredMails();
+
+ /**
+ * Returns the senders of the selected mails
+ * @return senders of the selected mails
+ */
+ QStringList getSelectedSenders() const;
+
+ bool setItem (const char* item);
+ void setList (QListView* list);
+ void beep ();
+ void playSound ();
+ void playSound (const char* file);
+
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Time in minutes to the next automatic refresh.
+ */
+ int m_nIntervalTimer;
+
+ /**
+ * Number of seconds the application will wait for a pop3 job to complete.
+ */
+ uint m_nPop3Timer;
+
+ /**
+ * This map is used by the delete methods.
+ * deleteSelectedMails() clears it and after that inserts for every account
+ * an item. The Key is the account name and the data is TRUE.
+ * When slotCheckDeletionState() is invoked by a signal sent by an account,
+ * this slot will set the appropriate item data to FALSE. If the data of all
+ * items are set to FALSE, the method will know all accounts have ended the
+ * deletion and will emit sigDeleteReady.
+ * @see deleteSelectedMails()
+ * @see slotCheckDeletionState()
+ */
+ AccountTaskMap_Type AccountDeletionMap;
+
+ /**
+ * This map is used by the methods to show the mail body.
+ * showSelectedMails() clears it and after that inserts for every account
+ * an item. The Key is the account name and the data is TRUE.
+ * When slotCheckShowBodiesState() is invoked by a signal sent by an account,
+ * this slot will set the appropriate item data to FALSE. If the data of all
+ * items are set to FALSE, the method will know all accounts have shown the
+ * mail body and will emit sigShowBodiesReady.
+ * @see showSelectedMails()
+ * @see slotCheckShowBodiesState()
+ */
+ AccountTaskMap_Type AccountShowBodiesMap;
+
+ /**
+ * This map is used by the methods to refresh the account mail lists.
+ * refreshMailLists() clears it and after that inserts for every account
+ * an item. The Key ist the account name and the data is TRUE.
+ * When slotCheckRefreshState() is invoked by a signal sent by an account,
+ * this slot will set the appropriate item data to FALSE. If the data of all
+ * items are set to FALSE, the method will know all accounts have refreshed their
+ * mail list and will emit sigRefreshReady.
+ * @see refreshMailLists()
+ * @see slotCheckRefreshState()
+ */
+ AccountTaskMap_Type AccountRefreshMap;
+
+ /**
+ * TRUE - the user has to confirm a deletion,
+ * FALSE - the user does not have to confirm a deletion
+ */
+ bool m_bConfirmDelete;
+
+ /**
+ * TRUE - allow HTML formatting in the mail show dialog box
+ * FALSE - don't allow HTML formatting
+ * @see setAllowHTML()
+ * @see allowHTML()
+ */
+ bool m_bAllowHTML;
+
+ /**
+ * Number of windows, which have been opened by the accounts to show mails.
+ * Used by slotMessageWindowOpened() and slotMessageWindowClosed().
+ * @see slotMessageWindowOpened
+ * @see slotMessageWindowClosed
+ */
+ int ctrOpenMessageWindows;
+
+ /**
+ * Contains the time (seconds) to first refresh.
+ * @see setInitTime()
+ * @see getInitTime()
+ */
+ int m_nInitTimer;
+
+ /**
+ * TRUE - If a new mail is arrived an alert window will be shown.
+ */
+ bool m_bShowMessage;
+
+ /**
+ * TRUE - If a new mail is arrived the main window will be shown.
+ */
+ bool m_bShowMainWindow;
+
+ /**
+ * TRUE - If a new mail is arrived the system will beep.
+ */
+ bool m_bBeep;
+
+ /**
+ * TRUE - If a new mail is arrived a sound will be played.
+ */
+ bool m_bSound;
+
+ /**
+ * Sound file which will be played if a new mail is arrived.
+ */
+ QString m_strSoundFile;
+
+ /**
+ * TRUE - If a new mail is arrived a command will be executed.
+ */
+ bool m_bCommand;
+
+ /**
+ * Path to command which will be executed if a new mail is arrived.
+ */
+ QString m_strCommandPath;
+
+ /**
+ * TRUE - If no new mail is arrived the application will be ended.
+ */
+ bool m_bTerminate;
+
+ /**
+ * TRUE - If no new mail is arrived the main window will be minimized.
+ */
+ bool m_bMinimize;
+
+ /**
+ * TRUE - If a connection error occures during refresh an error message will be shown.
+ */
+ bool m_bShowConnectionErrors;
+
+ /**
+ * TRUE - The user has to confirm window close.
+ */
+ bool m_bConfirmClose;
+
+ /**
+ * TRUE - the app starts minimized.
+ */
+ bool m_bStartMinimized;
+
+ /**
+ * TRUE - the close button leaves the application running in tray
+ */
+ bool m_bCloseMinimizes;
+
+ /**
+ * TRUE - minimizes to the tray rather than to the taskbar
+ */
+ bool m_bMinimizeToTray;
+
+ /**
+ * TRUE - mails keep new until termination
+ */
+ bool m_bKeepNew;
+
+ /**
+ * Mailbox for Spam, if configured
+ */
+ QString spamMailbox;
+
+ /**
+ * Action which shall be done, if the mail is Spam
+ */
+ FilterAction_Type spamAction;
+
+
+ protected:
+
+ /**
+ * Makes a copy from the given account object and returns the pointer to it.
+ * Reimplementation of QPtrList::newItem().
+ * Used by QPtrList to add new items.
+ * @param item account object
+ * @return pointer to the new account object
+ */
+ virtual QCollection::Item newItem( QCollection::Item item );
+
+ /**
+ * Compares two ConfigElem objects.
+ * Reimplementation of QPtrList::compareItems(). Used by inSort().
+ * @param item1 account 1
+ * @param item2 account 2
+ * @return 0 if account name 1 == account name 2
+ * @return nonzero if account name 2 != account name 2
+ */
+ virtual int compareItems( QCollection::Item item1, QCollection::Item item2 );
+
+ /**
+ * Returns whether the given account is in the list
+ * @param name name of the searched account
+ * @return TRUE - account is existent
+ * @return FALSE - account is not existent
+ */
+ bool hasAccount( const QString& name ) const;
+
+ /**
+ * Returns the pointer to the account named like the given name.
+ * @param name of the searched account
+ * @return account or NULL, if the account was not found
+ */
+ ConfigElem* getAccount( const QString& name ) const;
+
+ protected slots:
+
+ /**
+ * Connected with signal sigConfigChanged of all accounts.
+ * Emits the signal sigConfigChanged.
+ */
+ void slotAccountConfigChanged();
+
+ /**
+ * Connected with signal sigDeleteReady of all accounts.
+ * When an account has sent this signal its appropriate item
+ * in AccountDeletionMap will set to FALSE.
+ * When all accounts have done the deletion it will emit signal
+ * sigDeleteReady.
+ * @param account name of the account which has emitted the signal
+ * @see AccountDeletionMap
+ */
+ void slotCheckDeletionState( QString account );
+
+ /**
+ * Connected with signal sigShowBodiesReady of all accounts.
+ * When an account has sent this signal its appropriate item
+ * in AccountShowBodiesMap will set to FALSE.
+ * When all accounts have shown the mail it will emit signal
+ * sigShowBodiesReady.
+ * @param account name of the account which has emitted the signal
+ * @see AccountShowBodiesMap
+ */
+ void slotCheckShowBodiesState( QString account );
+
+ /**
+ * Connected with signal sigMessageWindowOpened of all accounts.
+ * When an account has sent this signal the counter ctrOpenMessageWindows
+ * will be incremented.
+ * When the counter was incremented from zero (the first window was opened)
+ * the signal sigMessageWindowOpened will be emitted.
+ * @see ctrOpenMessageWindows
+ * @see sigMessageWindowOpened
+ */
+ void slotMessageWindowOpened();
+
+ /**
+ * Connected with signal sigMessageWindowClosed of all accounts.
+ * When an account has sent this signal the counter ctrOpenMessageWindows
+ * will be decremented.
+ * When the counter has reached zero the signal sigAllMessageWindowsClosed
+ * will be emitted.
+ * @see ctrOpenMessageWindows
+ * @see sigAllMessageWindowsClosed
+ */
+ void slotMessageWindowClosed();
+
+ /**
+ * Connected with signal sigRefreshReady of all accounts.
+ * When an account has sent this signal its appropriate item
+ * in AccountRefreshMap will set to FALSE.
+ * When all accounts have refreshed their mail list it will emit
+ * signal sigRefreshReady.
+ * @param account name of the account which has emitted the signal
+ * @see AccountRefreshMap
+ */
+ void slotCheckRefreshState( QString account );
+
+ signals:
+
+ /**
+ * Will be emitted when the configuration of an account or of the app
+ * was changed.
+ */
+ void sigConfigChanged();
+
+ /**
+ * Will be emitted when all selected mails are deleted.
+ */
+ void sigDeleteReady();
+
+ /**
+ * Will be emitted when all selected mails are shown.
+ */
+ void sigShowBodiesReady();
+
+ /**
+ * Will be emitted by slotMessageWindowOpened when an account has
+ * opened a window to show a mail.
+ * @see slotMessageWindowOpened
+ */
+ void sigMessageWindowOpened();
+
+ /**
+ * Will be emitted by slotMessageWindowClosed when all accounts have
+ * closed their windows to show mails.
+ * @see slotMessageWindowClosed
+ */
+ void sigAllMessageWindowsClosed();
+
+ /**
+ * Will be emitted, when all accounts have refreshed their mail list.
+ */
+ void sigRefreshReady();
+
+};
+
+#endif
diff --git a/kshowmail/constants.h b/kshowmail/constants.h
new file mode 100644
index 0000000..fe91a2a
--- /dev/null
+++ b/kshowmail/constants.h
@@ -0,0 +1,367 @@
+//
+// C++ Interface: constants
+//
+// Description:
+// Containts all constants.
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef CONSTANTS_H
+#define CONSTANTS_H
+
+/**
+ * Contains all constants.
+ */
+namespace Constants
+{
+ /**
+ * Command Line Options
+ */
+ //option for show config dialog at start
+ #define CMDLINE_CONFIG "configure"
+ #define CMDLINE_CONFIG_SHORT "c"
+ //option for looking for new mails at start
+ #define CMDLINE_REFRESH "refresh"
+ #define CMDLINE_REFRESH_SHORT "r"
+
+ /**
+ * Defaults
+ */
+ //general defaults
+ #define DEFAULT_CONFIRM_CLOSE false
+ #define DEFAULT_CONFIRM_DELETE true
+ #define DEFAULT_START_MINIMIZED false
+ #define DEFAULT_CLOSE_TO_TRAY true
+ #define DEFAULT_MINIMIZE_TO_TRAY true
+ #define DEFAULT_SHOW_CONNECTION_ERRORS true
+ #define DEFAULT_KEEP_NEW false
+
+ #define DEFAULT_INITIAL_TIME 0
+ #define DEFAULT_INTERVAL_TIME 0
+ #define MINIMUM_TIMEOUT_TIME 5
+ #define DEFAULT_TIMEOUT_TIME 30
+
+ //default actions
+ #define DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW true
+ #define DEFAULT_ACTION_NEW_MAIL_MAINWINDOW false
+ #define DEFAULT_ACTION_NEW_MAIL_BEEP false
+ #define DEFAULT_ACTION_NEW_MAIL_SOUND false
+ #define DEFAULT_ACTION_NEW_MAIL_COMMAND false
+ #define DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE false
+ #define DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE false
+
+ //default display options
+ #define DEFAULT_DISPLAY_ACCOUNT_ACTIVE true
+ #define DEFAULT_DISPLAY_ACCOUNT_ACCOUNT true
+ #define DEFAULT_DISPLAY_ACCOUNT_SERVER true
+ #define DEFAULT_DISPLAY_ACCOUNT_USER true
+ #define DEFAULT_DISPLAY_ACCOUNT_MESSAGES true
+ #define DEFAULT_DISPLAY_ACCOUNT_SIZE true
+ #define DEFAULT_DISPLAY_MESSAGE_NUMBER true
+ #define DEFAULT_DISPLAY_MESSAGE_ACCOUNT true
+ #define DEFAULT_DISPLAY_MESSAGE_FROM true
+ #define DEFAULT_DISPLAY_MESSAGE_TO true
+ #define DEFAULT_DISPLAY_MESSAGE_SUBJECT true
+ #define DEFAULT_DISPLAY_MESSAGE_DATE true
+ #define DEFAULT_DISPLAY_MESSAGE_SIZE true
+ #define DEFAULT_DISPLAY_MESSAGE_CONTENT true
+ #define DEFAULT_DISPLAY_MESSAGE_STATE true
+
+ //default view options
+ #define DEFAULT_VIEW_USE_HTML false
+
+ //default column widthes
+ #define DEFAULT_WIDTH_ACCOUNT_ACTIVE 50
+ #define DEFAULT_WIDTH_ACCOUNT_ACCOUNT 100
+ #define DEFAULT_WIDTH_ACCOUNT_SERVER 100
+ #define DEFAULT_WIDTH_ACCOUNT_USER 100
+ #define DEFAULT_WIDTH_ACCOUNT_MESSAGES 80
+ #define DEFAULT_WIDTH_ACCOUNT_SIZE 80
+ #define DEFAULT_WIDTH_MESSAGE_NUMBER 50
+ #define DEFAULT_WIDTH_MESSAGE_ACCOUNT 100
+ #define DEFAULT_WIDTH_MESSAGE_FROM 200
+ #define DEFAULT_WIDTH_MESSAGE_TO 200
+ #define DEFAULT_WIDTH_MESSAGE_SUBJECT 350
+ #define DEFAULT_WIDTH_MESSAGE_DATE 100
+ #define DEFAULT_WIDTH_MESSAGE_SIZE 80
+ #define DEFAULT_WIDTH_MESSAGE_CONTENT 80
+ #define DEFAULT_WIDTH_MESSAGE_STATE 50
+
+ //account defaults
+ #define DEFAULT_ACCOUNT_NAME ""
+ #define DEFAULT_ACCOUNT_SERVER ""
+ #define DEFAULT_ACCOUNT_PROTOCOL "POP3"
+ #define DEFAULT_ACCOUNT_PORT_POP3 110
+ #define DEFAULT_ACCOUNT_PORT_POP3SSL 995
+ #define DEFAULT_ACCOUNT_USER ""
+ #define DEFAULT_ACCOUNT_PASSWORD ""
+ #define DEFAULT_ACCOUNT_PASSWORD_STORAGE 1
+ //1: don't save, 2: save in file, 3: use KWallet
+ #define DEFAULT_ACCOUNT_ACTIVE true
+ #define DEFAULT_ACCOUNT_SECTRANSFER 1
+ //1: no secure transfer, 2: SSL, 3: TLS
+
+ //filter defaults
+ #define DEFAULT_FILTER_ACTIVE false
+ #define DEFAULT_FILTER_OTHERS_ACTION 1
+ //1: Pass, 2: Delete, 3: Mark, 4: Move to Mailbox, 5: Spamcheck, 6: Ignore
+ #define DEFAULT_FILTER_BLACKLIST_ACTION 1
+ //1: Delete, 2: Mark
+ #define DEFAULT_FILTER_NAME "New Filter"
+ #define DEFAULT_FILTER_CRITERIA_LINKAGE 1
+ //1: Match all (AND); 2: Match any (OR)
+ #define DEFAULT_FILTER_CRITERIA_SOURCE 1
+ //1: From, 2: To, 3: Size (Bytes), 4: Subject, 5: Header, 6: Account
+ #define DEFAULT_FILTER_CRITERIA_COND_TEXT 1
+ //1: contains, 2: doesn't contains, 3: equals, 4: doesn't equal, 5: matches regular expression, 6: doesn't match regular expression
+ #define DEFAULT_FILTER_CRITERIA_COND_NUM 3
+ //1: is equal to, 2: is not equal to, 3: is greater than, 4: is greater than or equal to, 5: is less than, 6: is less than or equal to
+ #define DEFAULT_FILTER_CRITERIA_SIZE 20000
+ #define DEFAULT_FILTER_CRITERIA_CASE_SENSITIVE false
+ #define DEFAULT_FILTER_ACTION 1
+ //1: Pass, 2: Delete, 3: Mark, 4: Move to Mailbox, 5: Spamcheck, 6: Ignore
+ #define DEFAULT_FILTER_ACTION_MOVE_MAILBOX ""
+
+ //Spam check defaults
+ #define DEFAULT_SPAMCHECK_ACTION 3
+ //2: Delete, 3: Mark, 4: Move to Mailbox
+ #define DEFAULT_SPAMCHECK_ACTION_MOVE_MAILBOX ""
+
+
+ //Log Defaults
+ #define DEFAULT_LOG_LOG_DELETED_MAILS true
+ #define DEFAULT_LOG_LOG_MOVED_MAILS true
+ //the log entires will be deleted after some days (constant value is "days") or at app exit (value is "exit")
+ #define DEFAULT_LOG_REMOVE_DELETED_MAILS "days"
+ #define DEFAULT_LOG_REMOVE_MOVED_MAILS "exit"
+ //number of days the entries will be stored
+ #define DEFAULT_LOG_HOLDDAYS_DELETED_MAILS 7
+ #define DEFAULT_LOG_HOLDDAYS_MOVED_MAILS 7
+
+ /**
+ * XML file to store mails
+ */
+ #define MAIL_FILE "kshowmail.xml"
+ #define MAIL_FILE_DOCTYPE "KShowmail"
+ #define ROOT_ELEMENT "accounts"
+ #define ACCOUNT_ELEMENT "account"
+ #define ATTRIBUTE_ACCOUNT_NAME "account"
+ #define ATTRIBUTE_MAIL_UID "uidl"
+ #define ATTRIBUTE_MAIL_SIZE "size"
+ #define ATTRIBUTE_MAIL_NUMBER "number"
+ #define ITEM_MAIL_HEADER "header"
+ #define ITEM_MESSAGE "message"
+
+ /**
+ * Log
+ */
+ #define LOG_FILE "kshowmaillog.xml"
+ #define LOG_DOCTYPE "KShowmailLog"
+ #define LOG_ROOT_ELEMENT "DeletedMails"
+ #define LOG_ENTRY_ELEMENT "LogEntry"
+ #define LOG_ENTRY_ATTRIBUTE_DATETIME "DateTime"
+ #define LOG_ENTRY_ATTRIBUTE_SENDER "Sender"
+ #define LOG_ENTRY_ATTRIBUTE_ACCOUNT "Account"
+ #define LOG_ENTRY_ATTRIBUTE_SUBJECT "Subject"
+
+ /**
+ * Geometry
+ */
+ //Size of the view, which shows the mail text
+ #define WIDTH_VIEW_MAILBODY 500
+ #define HEIGHT_VIEW_MAILBODY 400
+
+ //Size of the view, which shows the mail header
+ #define WIDTH_VIEW_MAILHEADER 500
+ #define HEIGHT_VIEW_MAILHEADER 400
+
+ //Size of the text comparative value line of the filter criteria widget
+ #define WIDTH_FILTER_TEXT_VALUE_LINE 300
+
+ /**
+ * Configuration file
+ */
+ #define CONFIG_GROUP_GENERAL "General"
+ #define CONFIG_ENTRY_CONFIRM_CLOSE "confirmClose"
+ #define CONFIG_ENTRY_CONFIRM_DELETE "confirmDelete"
+ #define CONFIG_ENTRY_START_MINIMIZED "startMinimized"
+ #define CONFIG_ENTRY_CLOSE_TO_TRAY "closeToTray"
+ #define CONFIG_ENTRY_MINIMIZE_TO_TRAY "minimizeToTray"
+ #define CONFIG_ENTRY_SHOW_CONNECTION_ERRORS "showConnectionErrors"
+ #define CONFIG_ENTRY_KEEP_NEW "keepMailsNew"
+ #define CONFIG_ENTRY_INITIAL_TIME "InitialTime"
+ #define CONFIG_ENTRY_INTERVAL_TIME "IntervalTime"
+ #define CONFIG_ENTRY_TIMEOUT_TIME "TimeoutTime"
+
+ #define CONFIG_GROUP_ACTIONS "Actions"
+ #define CONFIG_ENTRY_NEW_MAIL_ALERTWINDOW "showAlertMessageIfNewMail"
+ #define CONFIG_ENTRY_NEW_MAIL_MAINWINDOW "showMainWindowIfNewMail"
+ #define CONFIG_ENTRY_NEW_MAIL_BEEP "beepIfNewMail"
+ #define CONFIG_ENTRY_NEW_MAIL_SOUND "playSoundIfNewMail"
+ #define CONFIG_ENTRY_NEW_MAIL_SOUNDPATH "PathToSoundFile"
+ #define CONFIG_ENTRY_NEW_MAIL_COMMAND "executeCommandIfNewMail"
+ #define CONFIG_ENTRY_NEW_MAIL_COMMANDPATH "Command"
+ #define CONFIG_ENTRY_NO_NEW_MAIL_TERMINATE "exitIfNoNewMails"
+ #define CONFIG_ENTRY_NO_NEW_MAIL_MINIMIZE "minimizeMainWindowIfNoNewMails"
+
+ #define CONFIG_GROUP_VIEW "View"
+ #define CONFIG_ENTRY_VIEW_USE_HTML "useHTML"
+
+ #define CONFIG_GROUP_ACCOUNT_LIST "LayoutAccountList"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_ACTIVE "showAccountListActiveColumn"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_ACCOUNT "showAccountListAccountColumn"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_SERVER "showAccountListServerColumn"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_USER "showAccountListUserColumn"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_MESSAGES "showAccountListMessagesColumn"
+ #define CONFIG_ENTRY_DISPLAY_ACCOUNT_SIZE "showAccountListSizeColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_ACTIVE "oldWidthAccountListActiveColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_ACCOUNT "oldWidthAccountListAccountColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_SERVER "oldWidthAccountListServerColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_USER "oldWidthAccountListUserColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_MESSAGES "oldWidthAccountListMessagesColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_SIZE "oldWidthAccountListSizeColumn"
+
+
+ #define CONFIG_GROUP_MESSAGE_LIST "LayoutMessageList"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_NUMBER "showMessageListNumberColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_ACCOUNT "showMessageListAccountColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_FROM "showMessageListFromColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_TO "showMessageListToColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_SUBJECT "showMessageListSubjectColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_DATE "showMessageListDateColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_SIZE "showMessageListSizeColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_CONTENT "showMessageListContentColumn"
+ #define CONFIG_ENTRY_DISPLAY_MESSAGE_STATE "showMessageListStateColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_NUMBER "oldWidthMessageListNumberColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_ACCOUNT "oldWidthMessageListAccountColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_FROM "oldWidthMessageListFromColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_TO "oldWidthMessageListToColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_SUBJECT "oldWidthMessageListSubjectColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_DATE "oldWidthMessageListDateColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_SIZE "oldWidthMessageListSizeColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_CONTENT "oldWidthMessageListContentColumn"
+ #define CONFIG_ENTRY_OLD_WIDTH_MESSAGE_STATE "oldWidthMessageListStateColumn"
+
+ #define CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE 1
+ #define CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE 2
+ #define CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET 3
+ #define CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE 1
+ #define CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL 2
+ #define CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS 3
+
+ #define CONFIG_GROUP_ACCOUNTS "Accounts"
+ #define CONFIG_ENTRY_ACCOUNTS_LIST "NamesList"
+
+ #define CONFIG_ENTRY_ACCOUNT_NAME "Name"
+ #define CONFIG_ENTRY_ACCOUNT_SERVER "Server"
+ #define CONFIG_ENTRY_ACCOUNT_PROTOCOL "Protocol"
+ #define CONFIG_ENTRY_ACCOUNT_PORT "Port"
+ #define CONFIG_ENTRY_ACCOUNT_USER "User"
+ #define CONFIG_ENTRY_ACCOUNT_PASSWORD "Password"
+ #define CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE "PasswordStorage"
+ #define CONFIG_ENTRY_ACCOUNT_ACTIVE "Active"
+ #define CONFIG_ENTRY_ACCOUNT_SECTRANSFER "SecureTransfer"
+
+
+ //general filter
+ #define CONFIG_GROUP_FILTER "Filter"
+
+ #define CONFIG_ENTRY_FILTER_ACTIVE "Active"
+
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS 1
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE 2
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK 3
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE 4
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK 5
+ #define CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE 6
+
+ #define CONFIG_ENTRY_FILTER_OTHERS_ACTION "ActionForOthers"
+ #define CONFIG_ENTRY_FILTER_OTHERS_MAILBOX "MailboxForOthers"
+
+ #define CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE 1
+ #define CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK 2
+
+ #define CONFIG_ENTRY_FILTER_BLACKLIST_ACTION "ActionBlacklist"
+ #define CONFIG_ENTRY_FILTER_BLACKLIST "Blacklist"
+ #define CONFIG_ENTRY_FILTER_WHITELIST "Whitelist"
+ #define CONFIG_ENTRY_FILTER_NUMBER_OF_FILTERS "NumberFilters"
+
+ //single filter
+ #define CONFIG_ENTRY_FILTER_NAME "Name"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_LINKAGE "CriteriaLinkage"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_NUMBER "CriteriaNumber"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_SOURCE "CriteriaSource"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_CONDITION "CriteriaCondition"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_VALUE "CriteriaValue"
+ #define CONFIG_ENTRY_FILTER_CRITERIA_CASESENSITIVE "CriteriaCaseSensitive"
+ #define CONFIG_ENTRY_FILTER_ACTION "Action"
+ #define CONFIG_ENTRY_FILTER_MOVE_MAILBOX "Mailbox"
+
+ #define CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL 1
+ #define CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY 2
+
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM 1
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO 2
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE 3
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT 4
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER 5
+ #define CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT 6
+
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS 1
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS 2
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS 3
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS 4
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR 5
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR 6
+
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL 1
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL 2
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER 3
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL 4
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS 5
+ #define CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL 6
+
+ #define CONFIG_VALUE_FILTER_ACTION_PASS 1
+ #define CONFIG_VALUE_FILTER_ACTION_DELETE 2
+ #define CONFIG_VALUE_FILTER_ACTION_MARK 3
+ #define CONFIG_VALUE_FILTER_ACTION_MOVE 4
+ #define CONFIG_VALUE_FILTER_ACTION_SPAMCHECK 5
+ #define CONFIG_VALUE_FILTER_ACTION_IGNORE 6
+
+ //Spamcheck
+ #define CONFIG_GROUP_SPAMCHECK "Spamcheck"
+
+ #define CONFIG_ENTRY_SPAMCHECK_ACTION "Action"
+ #define CONFIG_ENTRY_SPAMCHECK_MOVE_MAILBOX "Mailbox"
+
+ #define CONFIG_VALUE_SPAMCHECK_ACTION_DELETE 2
+ #define CONFIG_VALUE_SPAMCHECK_ACTION_MARK 3
+ #define CONFIG_VALUE_SPAMCHECK_ACTION_MOVE 4
+
+ //Log
+ #define CONFIG_GROUP_LOG "Log"
+ #define CONFIG_ENTRY_LOG_LOG_DELETED_MAILS "LogDeletedMails"
+ #define CONFIG_ENTRY_LOG_LOG_MOVED_MAILS "LogMovedMails"
+ #define CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS "RemoveEventOfDeletedMails"
+ #define CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS "RemoveEvendOfMovedMails"
+ #define CONFIG_ENTRY_LOG_HOLDDAYS_DELETED_MAILS "HoldDaysOfDeletedMails"
+ #define CONFIG_ENTRY_LOG_HOLDDAYS_MOVED_MAILS "HoldDaysOfMovedMails"
+
+ #define CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT "exit"
+ #define CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS "days"
+
+ //Status Bar
+ #define STATUSBAR_FIELD_STATE 1
+ #define STATUSBAR_FIELD_FILTER 2
+ #define STATUSBAR_FIELD_NEXT_REFRESH 3
+ #define STATUSBAR_FIELD_LAST_REFRESH 4
+
+ //Misc
+ #define NAME_SPAMASSASSIN_DAEMON "spamd"
+}
+#endif
diff --git a/kshowmail/decodeRFC2047.cpp b/kshowmail/decodeRFC2047.cpp
new file mode 100644
index 0000000..adf53de
--- /dev/null
+++ b/kshowmail/decodeRFC2047.cpp
@@ -0,0 +1,182 @@
+/***************************************************************************
+ decodeRFC2047.cpp - description
+ -------------------
+ begin : Mon Jan 28 2002
+ copyright : (C) 2002 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+
+#include "decodeRFC2047.h"
+
+/*
+ * These functions have been adapted from the KMail program
+ */
+
+QCString decodeQuotedPrintable(const QCString& aStr)
+{
+ QCString bStr = aStr;
+ if (aStr.isNull())
+ bStr = "";
+
+ DwString dwsrc(bStr.data());
+ DwString dwdest;
+
+ DwDecodeQuotedPrintable(dwsrc, dwdest);
+ return dwdest.c_str();
+}
+
+QCString decodeBase64(const QCString& aStr)
+{
+ QCString bStr = aStr;
+ if (aStr.isNull())
+ bStr = "";
+ while (bStr.length() < 16) bStr += "=";
+
+ DwString dwsrc(bStr.data(), bStr.length());
+ DwString dwdest;
+ QCString result;
+
+ DwDecodeBase64(dwsrc, dwdest);
+ result = dwdest.c_str();
+ return result;
+}
+
+QTextCodec* codecForName(const QCString& _str)
+{
+ if (_str.isEmpty()) return NULL;
+ if (_str.lower() == "shift_jis" || _str.lower() == "shift-jis")
+ return QTextCodec::codecForName("sjis");
+ return QTextCodec::codecForName(_str.lower().replace(
+ QRegExp("windows"), "cp") );
+}
+
+QString Codecs::decodeRFC2047(const QCString& aStr)
+{
+ QString result;
+ QCString charset;
+ char *pos, *beg, *end, *mid;
+ QCString str, cstr, LWSP_buffer;
+ char encoding, ch;
+ bool valid, lastWasEncodedWord=FALSE;
+ const int maxLen=200;
+ int i;
+
+ if (aStr.find("=?") < 0)
+ return QString::fromLocal8Bit(aStr).replace(QRegExp("\n[\t ]")," ");
+
+ for (pos=aStr.data(); *pos; pos++)
+ {
+ // line unfolding
+ if ( pos[0] == '\r' && pos[1] == '\n' ) {
+ pos++;
+ continue;
+ }
+ if ( pos[0] == '\n' )
+ continue;
+ // collect LWSP after encoded-words,
+ // because we might need to throw it out
+ // (when the next word is an encoded-word)
+ if ( lastWasEncodedWord && ( pos[0] == ' ' || pos[0] == '\t' ) )
+ {
+ 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
+ beg = pos+2;
+ end = beg;
+ valid = TRUE;
+ // parse charset name
+ charset = "";
+ for (i=2,pos+=2; i<maxLen && (*pos!='?'&&(*pos==' '||ispunct(*pos)||isalnum(*pos))); i++)
+ {
+ charset += *pos;
+ pos++;
+ }
+ if (*pos!='?' || i<4 || i>=maxLen) valid = FALSE;
+ else
+ {
+ // get encoding and check delimiting question marks
+ encoding = toupper(pos[1]);
+ if (pos[2]!='?' || (encoding!='Q' && encoding!='B'))
+ valid = FALSE;
+ pos+=3;
+ i+=3;
+ }
+ if (valid)
+ {
+ mid = pos;
+ // search for end of encoded part
+ while (i<maxLen && *pos && !(*pos=='?' && *(pos+1)=='='))
+ {
+ i++;
+ pos++;
+ }
+ end = pos+2;//end now points to the first char after the encoded string
+ if (i>=maxLen || !*pos)
+ valid = FALSE;
+ }
+ if (valid)
+ {
+ // valid encoding: decode and throw away separating LWSP
+ ch = *pos;
+ *pos = '\0';
+ str = QCString(mid).left((int)(mid - pos - 1));
+ if (encoding == 'Q')
+ {
+ // decode quoted printable text
+ for (i=str.length()-1; i>=0; i--)
+ if (str[i]=='_')
+ str[i]=' ';
+ cstr = decodeQuotedPrintable(str);
+ }
+ else
+ {
+ // decode base64 text
+ cstr = decodeBase64(str);
+ }
+ QTextCodec *codec = codecForName(charset);
+ if (!codec)
+ codec = codecForName(KGlobal::locale()->encoding());
+ if (codec)
+ result += codec->toUnicode(cstr);
+ else
+ result += QString::fromLocal8Bit(cstr);
+ lastWasEncodedWord = TRUE;
+
+ *pos = ch;
+ pos = end -1;
+ }
+ else
+ {
+ // invalid encoding, keep separating LWSP.
+ //result += "=?";
+ //pos = beg -1; // because pos gets increased shortly afterwards
+ pos = beg - 2;
+ result += LWSP_buffer;
+ result += *pos++;
+ result += *pos;
+ lastWasEncodedWord = FALSE;
+ }
+ LWSP_buffer = 0;
+ }
+ return result;
+}
+
diff --git a/kshowmail/decodeRFC2047.h b/kshowmail/decodeRFC2047.h
new file mode 100644
index 0000000..d4822a9
--- /dev/null
+++ b/kshowmail/decodeRFC2047.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ decodeRFC2047.h - description
+ -------------------
+ begin : Mon Jan 28 2002
+ copyright : (C) 2002 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef DECODE_RFC2047_H
+#define DECODE_RFC2047_H
+
+#include <ctype.h>
+#include <stdlib.h>
+
+//Qt header
+#include <qtextcodec.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qcstring.h>
+
+//KDE header
+#include <klocale.h>
+#include <kglobal.h>
+#include <mimelib/mimepp.h>
+
+
+/**
+ * Contains functions to decode and encode parts of a mail.
+ */
+namespace Codecs
+{
+
+ /**
+ * Decodes a string which is coded according RFC 2047.
+ * Adapted from KMail.
+ * @param aStr the coded string
+ * @return the decoded representation of the given string
+ */
+ QString decodeRFC2047( const QCString& aStr );
+
+}
+
+#endif
diff --git a/kshowmail/encryption.cpp b/kshowmail/encryption.cpp
new file mode 100644
index 0000000..dd3bcec
--- /dev/null
+++ b/kshowmail/encryption.cpp
@@ -0,0 +1,85 @@
+//
+// C++ Implementation: encryption
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "encryption.h"
+
+//used in crypt() and decrypt()
+static const char scramble1 [50] = "C6FDC7A1EDFBB6FEE3DBF5BEBAEFDDF7ABC6FDC7A1EDFBB6";
+static const char hexstr [17] = "0123456789ABCDEF";
+
+int Encryption::hexbyt( const char c )
+{
+ if( c >= '0' && c <= '9' )
+ return c - '0';
+ else
+ return c - 'A' + 10;
+}
+
+const QString Encryption::crypt( const KURL& url )
+{
+ char result[50];
+ char scramble2[50];
+ QString hexresult;
+
+ memset (result, 0, 50);
+ memset (scramble2, 0, 50);
+ int pos = url.pass().length () + 1;
+ unsigned int free = 50 - pos;
+
+ if( url.user().length() <= free )
+ {
+ strcpy( &scramble2[pos], url.user() );
+ pos += url.user().length();
+ free -= url.user().length();
+ }
+ else
+ {
+ memcpy( &scramble2[pos], url.user().latin1(), free );
+ free = 0;
+ }
+
+ if( url.host().length() <= free )
+ {
+ strcpy( &scramble2[pos], url.host() );
+ pos += url.host().length();
+ free -= url.host().length();
+ }
+ else
+ {
+ memcpy( &scramble2[pos], url.host().latin1(), free );
+ free = 0;
+ }
+
+ memcpy( result, url.pass().latin1(), url.pass().length() );
+ for (int i = 0; i <= 31; i++)
+ {
+ result[i] = (char)( result[i] ^ ( scramble1[i] ^ scramble2[i] ) );
+ hexresult += hexstr[ result[i] / 16 ];
+ hexresult += hexstr[ result[i] % 16 ];
+ }
+
+ return hexresult;
+}
+
+const QString Encryption::decrypt( const QString& pass )
+{
+ char result[50];
+
+ memset( result, 0, 50 );
+ int i;
+ for( i = 0; i <= 31; i++ )
+ {
+ result[i] = (char)hexbyt( pass[ i * 2 ] ) * 16 + hexbyt( pass[ i * 2 + 1 ] );
+ result[i] = (char)( result[i] ^ scramble1[i] );
+ }
+
+ return result;
+}
diff --git a/kshowmail/encryption.h b/kshowmail/encryption.h
new file mode 100644
index 0000000..376cc26
--- /dev/null
+++ b/kshowmail/encryption.h
@@ -0,0 +1,46 @@
+//
+// C++ Interface: encryption
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+//Qt headers
+#include <qstring.h>
+
+//KDE headers
+#include <kurl.h>
+
+/**
+ * @brief Provides functions to crypt and decrypt a password.
+ */
+namespace Encryption
+{
+ /**
+ * Transforms the given hex numeric character to integer.
+ * For example: a given '2' will transformed to 2; 'B' to 12.
+ * @param c character to transform [0..9, 'A'..'F']; no lower case letters
+ * @return integer value of the given character
+ */
+ int hexbyt( const char c );
+
+ /**
+ * Encrypts the the password in the given url and returns it.
+ * The encryption algorithm uses host and user name to crypt the password.
+ * @param url the url with password, host and user name
+ * @return encrypted password
+ */
+ const QString crypt( const KURL& url );
+
+ /**
+ * Decrypts the given encrypted password.
+ * @param pass encrypted password
+ * @return decrypted password
+ */
+ const QString decrypt( const QString& pass );
+}
diff --git a/kshowmail/filteritem.cpp b/kshowmail/filteritem.cpp
new file mode 100644
index 0000000..97c284b
--- /dev/null
+++ b/kshowmail/filteritem.cpp
@@ -0,0 +1,166 @@
+//
+// C++ Implementation: filteritem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filteritem.h"
+
+FilterItem::FilterItem( uint filterNr )
+{
+ //get the application config object
+ config = KApplication::kApplication()->config();
+
+ //save number
+ filterNumber = filterNr;
+
+ //set config group
+ config->setGroup( QString( "%1%2" ).arg( CONFIG_GROUP_FILTER ).arg( filterNr ) );
+
+ //get name
+ name = config->readEntry( CONFIG_ENTRY_FILTER_NAME );
+
+ //get number of criterias
+ numberCriterias = config->readNumEntry( CONFIG_ENTRY_FILTER_CRITERIA_NUMBER );
+
+ //get criteria linkage
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_CRITERIA_LINKAGE, DEFAULT_FILTER_CRITERIA_LINKAGE ) )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL : linkage = LinkAll; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY : linkage = LinkAny; break;
+ default : kdError() << "FilterItem::FilterItem(): Unknown linkage value read. Set ALL. ( Filter " << filterNumber << ")" << endl;
+ linkage = LinkAll;
+ break;
+ }
+
+ //get action
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_ACTION, DEFAULT_FILTER_ACTION ) )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_PASS : action = FActPass; break;
+ case CONFIG_VALUE_FILTER_ACTION_DELETE : action = FActDelete; break;
+ case CONFIG_VALUE_FILTER_ACTION_MARK : action = FActMark; break;
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : action = FActMove; break;
+ case CONFIG_VALUE_FILTER_ACTION_IGNORE : action = FActIgnore; break;
+ case CONFIG_VALUE_FILTER_ACTION_SPAMCHECK : action = FActSpamcheck; break;
+ default : kdError() << "FilterItem::FilterItem(): Unknown filter action read. Set PASS. (Filter " << filterNumber << ")" << endl;
+ action = FActPass;
+ break;
+ }
+
+ //get mailbox name if filter action is move
+ if( action == FActMove )
+ {
+ mailbox = config->readEntry( CONFIG_ENTRY_FILTER_MOVE_MAILBOX );
+ if( mailbox.isNull() || mailbox.isEmpty() )
+ {
+ kdWarning() << "Filter " << filterNumber << ": No mailbox name found. Set default: " << DEFAULT_FILTER_ACTION_MOVE_MAILBOX << endl;
+ mailbox = QString( DEFAULT_FILTER_ACTION_MOVE_MAILBOX );
+ }
+ }
+
+ //now we get the criterias
+ criterias.setAutoDelete( true ); //the list shall delete all criterias if it will be deleted itself
+ for( uint critNr = 1; critNr <= numberCriterias; critNr++ )
+ {
+ criterias.append( new FilterItemCriteria( filterNr, critNr ) ); //a new created criteria loads its settings itself
+ }
+}
+
+
+FilterItem::~FilterItem()
+{
+}
+
+FilterAction_Type FilterItem::check( QString from, QString to, uint size, QString subject, QString header, QString account, QString& mailboxName ) const
+{
+ bool match = false; //TRUE, if filter matches
+
+ //return NONE if no criterias available
+ if( criterias.isEmpty() ) return FActNone;
+
+ //get iterator
+ QPtrListIterator<FilterItemCriteria> it( criterias );
+
+ FilterItemCriteria* crit;
+
+ //check criterias
+ if( linkage == LinkAll )
+ {
+ match = true;
+ while( ( crit = it.current() ) != NULL && match )
+ {
+ ++it;
+
+ match = match && crit->check( from, to, size, subject, header, account );
+ }
+ }
+ else if( linkage == LinkAny )
+ {
+ match = false;
+ while( ( crit = it.current() ) != NULL && !match )
+ {
+ ++it;
+
+ match = crit->check( from, to, size, subject, header, account );
+ }
+ }
+ else
+ kdError() << "FilterItem::check(): Unknown linkage (Filter " << filterNumber << ")" << endl;
+
+ //return action if filter matches
+ if( match )
+ {
+ //set mailbox name if neccessary
+ if( action == FActMove )
+ {
+ mailboxName.remove( 0, mailboxName.length() );
+ mailboxName.append( mailbox );
+ }
+
+ return action;
+ }
+
+ //default return value, filter doesn't match
+ return FActNone;
+}
+
+void FilterItem::print( ) const
+{
+ kdDebug() << "Settings of filter " << filterNumber << ":" << endl;
+ kdDebug() << "Name: " << name << endl;
+ kdDebug() << "Number of criterias: " << numberCriterias << endl;
+
+ switch( linkage )
+ {
+ case LinkAll : kdDebug() << "Criteria Linkage: ALL (AND)" << endl; break;
+ case LinkAny : kdDebug() << "Criteria Linkage: ANY (OR)" << endl; break;
+ default : kdDebug() << "Unknown Criteria LInkage" << endl; break;
+ }
+
+ switch( action )
+ {
+ case FActPass : kdDebug() << "Action: PASS" << endl; break;
+ case FActDelete : kdDebug() << "Action: DELETE" << endl; break;
+ case FActMark : kdDebug() << "Action: MARK" << endl; break;
+ case FActMove : kdDebug() << "Action: MOVE to " << mailbox << endl; break;
+ case FActSpamcheck : kdDebug() << "Action: SPAMCHECK" << endl; break;
+ case FActIgnore : kdDebug() << "Action: IGNORE" << endl; break;
+ default : kdDebug() << "Unknown Action" << endl; break;
+ }
+
+ kdDebug() << "Criterias:" << endl;
+ QPtrListIterator<FilterItemCriteria> it( criterias );
+ FilterItemCriteria* crit;
+ while( ( crit = it.current() ) != NULL )
+ {
+ ++it;
+ crit->print();
+ }
+}
+
+
diff --git a/kshowmail/filteritem.h b/kshowmail/filteritem.h
new file mode 100644
index 0000000..291bc65
--- /dev/null
+++ b/kshowmail/filteritem.h
@@ -0,0 +1,117 @@
+//
+// C++ Interface: filteritem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERITEM_H
+#define FILTERITEM_H
+
+//Qt headers
+#include <qstring.h>
+#include <qptrlist.h>
+
+//KDE headers
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kconfig.h>
+
+//KShowmail headers
+#include "filteritemcriteria.h"
+#include "constants.h"
+#include "types.h"
+
+using namespace Types;
+
+/**
+ * This is a filter item. It contains a list of criterias (class FilterItemCriteria).
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterItem{
+
+ public:
+
+ /**
+ * Constructor
+ * Loads the settings from the config file
+ * @param filterNr Number of the filter
+ */
+ FilterItem( uint filterNr );
+
+ /**
+ * Destructor
+ */
+ ~FilterItem();
+
+ /**
+ * Prints the settings.
+ */
+ void print() const;
+
+ /**
+ * Checks the given mail header.
+ * @param from Sender
+ * @param to Addressee
+ * @param size Size
+ * @param subject Subject
+ * @param header Header
+ * @param account Account
+ * @param mailboxName contains the mailbox name after call, if filter action is MOVE
+ * @return recommend action
+ */
+ FilterAction_Type check( QString from, QString to, uint size, QString subject, QString header, QString account, QString& mailboxName ) const;
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Filter number. Just for messages.
+ */
+ uint filterNumber;
+
+ /**
+ * Filter name. Just for messages.
+ */
+ QString name;
+
+ /**
+ * Number of criterias
+ */
+ uint numberCriterias;
+
+ /**
+ * Type of criteria linkage
+ */
+ enum Linkage_Type{ LinkAll, LinkAny };
+
+ /**
+ * Criteria Linkage
+ */
+ Linkage_Type linkage;
+
+ /**
+ * Filter Action
+ */
+ FilterAction_Type action;
+
+ /**
+ * Mailbox Name for move action
+ */
+ QString mailbox;
+
+ /**
+ * This list holds the criterias.
+ */
+ QPtrList<FilterItemCriteria> criterias;
+};
+
+#endif
diff --git a/kshowmail/filteritemcriteria.cpp b/kshowmail/filteritemcriteria.cpp
new file mode 100644
index 0000000..5577a6a
--- /dev/null
+++ b/kshowmail/filteritemcriteria.cpp
@@ -0,0 +1,241 @@
+//
+// C++ Implementation: filteritemcriteria
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filteritemcriteria.h"
+
+FilterItemCriteria::FilterItemCriteria( uint FilterNr, uint CritNr )
+{
+ //get the application config object
+ config = KApplication::kApplication()->config();
+
+ //save numbers
+ FilterNumber = FilterNr;
+ CriteriaNumber = CritNr;
+
+ //get setup
+ //---------
+
+ //set group
+ config->setGroup( QString( "%1%2" ).arg( CONFIG_GROUP_FILTER ).arg( FilterNr ) );
+
+ //get source
+ switch( config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_SOURCE ).arg( CritNr ), DEFAULT_FILTER_CRITERIA_SOURCE ) )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM : source = SrcFrom; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO : source = SrcTo; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT : source = SrcSubject; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : source = SrcSize; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER : source = SrcHeader; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT : source = SrcAccount; break;
+ default : source = SrcFrom; break;
+ }
+
+ //get condition
+ if( source == SrcSize )
+ {
+ switch( config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CONDITION ).arg( CritNr ), DEFAULT_FILTER_CRITERIA_COND_NUM ) )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL : numCondition = NumCondEqual; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL : numCondition = NumCondNotEqual; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER : numCondition = NumCondGreater; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL : numCondition = NumCondGreaterEqual; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS : numCondition = NumCondLess; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL : numCondition = NumCondLessEqual; break;
+ default : numCondition = NumCondGreater; break;
+ }
+ }
+ else
+ {
+ switch( config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CONDITION ).arg( CritNr ), DEFAULT_FILTER_CRITERIA_COND_TEXT ) )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS : txtCondition = TxtCondContains; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS : txtCondition = TxtCondNotContains; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS : txtCondition = TxtCondEqual; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS : txtCondition = TxtCondNotEqual; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR : txtCondition = TxtCondRegExpr; break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR : txtCondition = TxtCondNotRegExpr; break;
+ default : txtCondition = TxtCondContains; break;
+ }
+
+ cs = config->readBoolEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CASESENSITIVE ).arg( CritNr ), DEFAULT_FILTER_CRITERIA_CASE_SENSITIVE );
+ }
+
+ //get Value
+ if( source == SrcSize )
+ {
+ numValue = config->readUnsignedNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( CritNr ) );
+ }
+ else
+ {
+ txtValue = config->readEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( CritNr ) );
+ }
+
+}
+
+FilterItemCriteria::~FilterItemCriteria()
+{
+}
+
+bool FilterItemCriteria::check( QString from, QString to, uint size, QString subject, QString header, QString account ) const
+{
+ switch( source )
+ {
+ case SrcFrom : return checkText( from ); break;
+ case SrcTo : return checkText( to ); break;
+ case SrcHeader : return checkText( header ); break;
+ case SrcSize : return checkNum( size ); break;
+ case SrcSubject : return checkText( subject ); break;
+ case SrcAccount : return checkText( account ); break;
+ default : return false;
+ }
+
+ //this is the default
+ return false;
+}
+
+bool FilterItemCriteria::checkText( QString value ) const
+{
+ //return false if the source is not text
+ if( source != SrcFrom && source != SrcTo && source != SrcHeader && source != SrcSubject && source != SrcAccount )
+ {
+ kdError() << "FilterItemCriteria::checkText: The source is not text. (Filter " << FilterNumber << ", Criteria " << CriteriaNumber << ")" << endl;
+ return false;
+ }
+
+ //return false if given value is not valid
+ if( value.isNull() || value.isEmpty() )
+ {
+ kdError() << "FilterItemCriteria::checkText: The given value is empty or null. (Filter " << FilterNumber << ", Criteria " << CriteriaNumber << ")" << endl;
+ return false;
+ }
+
+ //return false if the value of this criteria is an empty string
+ if( txtValue.isEmpty() || txtValue.isNull() )
+ {
+ kdWarning() << "There is no value for Filter " << FilterNumber << "/Criteria " << CriteriaNumber << endl;
+ }
+
+ switch( txtCondition )
+ {
+ case TxtCondContains : return value.contains( txtValue, cs ) > 0; break;
+
+ case TxtCondNotContains : return value.contains( txtValue, cs ) < 1; break;
+
+ case TxtCondEqual : if( cs )
+ {
+ return value.localeAwareCompare( txtValue ) == 0;
+ }
+ else
+ {
+ return QString::localeAwareCompare( txtValue.upper(), value.upper() ) == 0;
+ }
+ break;
+
+ case TxtCondNotEqual : if( cs )
+ return value.localeAwareCompare( txtValue ) != 0;
+ else
+ return value.localeAwareCompare( txtValue.upper(), value.upper() ) != 0;
+ break;
+
+ case TxtCondRegExpr : return value.find( QRegExp( txtValue ) ) != -1; break;
+
+ case TxtCondNotRegExpr : return value.find( QRegExp( txtValue ) ) == -1; break;
+
+ default : return false;
+ }
+
+ //default
+ return false;
+}
+
+bool FilterItemCriteria::checkNum( uint value ) const
+{
+ //return false if the source is not numeric
+ if ( source != SrcSize )
+ {
+ kdError() << "FilterItemCriteria::checkNum: The source is not numeric." << endl;
+ return false;
+ }
+
+ switch( numCondition )
+ {
+ case NumCondEqual : return value == numValue; break;
+ case NumCondNotEqual : return value != numValue; break;
+ case NumCondGreater : return value > numValue; break;
+ case NumCondGreaterEqual : return value >= numValue; break;
+ case NumCondLess : return value < numValue; break;
+ case NumCondLessEqual : return value <= numValue; break;
+ default : kdError() << "FilterItemCriteria::checkNum: Unknown numeric condiction. Return false." << endl;
+ }
+
+ //default
+ return false;
+}
+
+void FilterItemCriteria::print( ) const
+{
+ QString output;
+
+ output.append( QString( "Criteria %1 of Filter %2: Source: " ).arg( CriteriaNumber ).arg( FilterNumber ) );
+
+ switch( source )
+ {
+ case SrcFrom : output.append( "From" ); break;
+ case SrcTo : output.append( "To" ); break;
+ case SrcAccount : output.append( "Account" ); break;
+ case SrcHeader : output.append( "Header" ); break;
+ case SrcSize : output.append( "Size" ); break;
+ case SrcSubject : output.append( "Subject" ); break;
+ default : output.append( "unknown" ); break;
+ }
+
+ output.append( "; Condition: " );
+
+ if( source == SrcSize )
+ {
+ switch( numCondition )
+ {
+ case NumCondEqual : output.append( QString( "equals %1" ).arg( numValue ) ); break;
+ case NumCondGreater : output.append( QString( "greater than %1" ).arg( numValue ) ); break;
+ case NumCondGreaterEqual : output.append( QString( "greater than or equals %1" ).arg( numValue ) ); break;
+ case NumCondLess : output.append( QString( "less than %1" ).arg( numValue ) ); break;
+ case NumCondLessEqual : output.append( QString( "less than or equals %1" ).arg( numValue ) ); break;
+ case NumCondNotEqual : output.append( QString( "not equals %1" ).arg( numValue ) ); break;
+ default : output.append( QString( "unknown; Value: %1" ).arg( numValue ) ); break;
+ }
+ }
+ else
+ {
+ switch( txtCondition )
+ {
+ case TxtCondContains : output.append( QString( "contains %1" ).arg( txtValue ) ); break;
+ case TxtCondEqual : output.append( QString( "equals %1" ).arg( txtValue ) ); break;
+ case TxtCondNotContains : output.append( QString( "not contains %1" ).arg( txtValue ) ); break;
+ case TxtCondNotEqual : output.append( QString( "not equals %1" ).arg( txtValue ) ); break;
+ case TxtCondRegExpr : output.append( QString( "matches to regular expression %1" ).arg( txtValue ) ); break;
+ case TxtCondNotRegExpr : output.append( QString( "doesn't match to regular expression %1" ).arg( txtValue ) ); break;
+ default : output.append( QString( "unknown; Value: %1" ).arg( txtValue ) ); break;
+ }
+
+ if( txtCondition != TxtCondRegExpr && txtCondition != TxtCondNotRegExpr )
+ {
+ if( cs )
+ output.append( " (case sensitive)" );
+ else
+ output.append( " (not case sensitive)" );
+ }
+ }
+
+ kdDebug() << output << endl;
+}
+
+
+
diff --git a/kshowmail/filteritemcriteria.h b/kshowmail/filteritemcriteria.h
new file mode 100644
index 0000000..eaa4d49
--- /dev/null
+++ b/kshowmail/filteritemcriteria.h
@@ -0,0 +1,146 @@
+//
+// C++ Interface: filteritemcriteria
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERITEMCRITERIA_H
+#define FILTERITEMCRITERIA_H
+
+//Qt headers
+#include <qstring.h>
+#include <qregexp.h>
+
+//KDE headers
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+//Kshowmail headers
+#include "types.h"
+#include "constants.h"
+
+/**
+ * @brief This is a criteria of a filter item.
+ * For using create an object and call check().
+ * It gets its configuration itself from the config file at creation time. You can't reload the setup.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterItemCriteria{
+
+ public:
+
+ /**
+ * Constructor
+ * @param FilterNr number of the filter item
+ * @param CritNr number of this criteria
+ */
+ FilterItemCriteria( uint FilterNr, uint CritNr );
+
+ /**
+ * Destructor
+ */
+ ~FilterItemCriteria();
+
+ /**
+ * Checks for match.
+ * @param from Sender
+ * @param to Addressee
+ * @param size Size
+ * @param subject Subject
+ * @param header Header
+ * @param account Account
+ * @return TRUE - the criteria matches; FALSE - the criteria doesn't match
+ */
+ bool check( QString from, QString to, uint size, QString subject, QString header, QString account ) const;
+
+ /**
+ * Prints the settings.
+ */
+ void print() const;
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Types of source.
+ */
+ enum Source_Type{ SrcFrom, SrcTo, SrcSize, SrcSubject, SrcHeader, SrcAccount };
+
+ /**
+ * Source of the criteria.
+ */
+ Source_Type source;
+
+ /**
+ * Text Condition Types
+ */
+ enum TextCondition_Type{ TxtCondContains, TxtCondNotContains, TxtCondEqual, TxtCondNotEqual, TxtCondRegExpr, TxtCondNotRegExpr };
+
+ /**
+ * Numeric Condition Types
+ */
+ enum NumCondition_Type{ NumCondEqual, NumCondNotEqual, NumCondGreater, NumCondGreaterEqual, NumCondLess, NumCondLessEqual };
+
+ /**
+ * Text Condition
+ */
+ TextCondition_Type txtCondition;
+
+ /**
+ * Numeric Condition
+ */
+ NumCondition_Type numCondition;
+
+ /**
+ * Text Value
+ */
+ QString txtValue;
+
+ /**
+ * Numeric Value
+ */
+ uint numValue;
+
+ /**
+ * Case Sensitive; used by text condition
+ */
+ bool cs;
+
+ /**
+ * Filter number. Just for error messages.
+ */
+ uint FilterNumber;
+
+ /**
+ * Criteria number. Just for error messages.
+ */
+ uint CriteriaNumber;
+
+ protected:
+
+ /**
+ * Compares a text value.
+ * @param value Value to compare
+ * @return TRUE - value matches; FALSE - value doesn't match
+ */
+ bool checkText( QString value ) const;
+
+ /**
+ * Compares a numeric value.
+ * @param value Value to compare
+ * @return TRUE - value matches; FALSE - value doesn't match
+ */
+ bool checkNum( uint value ) const;
+};
+
+#endif
diff --git a/kshowmail/filterlog.cpp b/kshowmail/filterlog.cpp
new file mode 100644
index 0000000..73665cd
--- /dev/null
+++ b/kshowmail/filterlog.cpp
@@ -0,0 +1,235 @@
+//
+// C++ Implementation: filterlog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filterlog.h"
+
+FilterLog::FilterLog()
+{
+ //get the application config object
+ config = KApplication::kApplication()->config();
+
+ //load the setup
+ loadSetup();
+
+ //load stored entries
+ load();
+}
+
+
+FilterLog::~FilterLog()
+{
+}
+
+void FilterLog::addDeletedMail(const QDateTime & dateTime, const QString & sender, const QString & account, const QString & subject)
+{
+ if( logDeletedMails )
+ addEntry( FActDelete, dateTime, sender, account, subject, "" );
+}
+
+void FilterLog::addMovedMail(const QDateTime & dateTime, const QString & sender, const QString & account, const QString & subject, const QString & mailbox)
+{
+ if( logMovedMails )
+ addEntry( FActMove, dateTime, sender, account, subject, mailbox );
+}
+
+void FilterLog::addEntry(FilterAction_Type action, const QDateTime & dateTime, const QString & sender, const QString & account, const QString & subject, const QString & mailbox)
+{
+ //create entry
+ FilterLogEntry entry = FilterLogEntry( action, dateTime, sender, account, subject, mailbox );
+
+ //add entry to the appropriate list
+ switch( action )
+ {
+ case FActDelete : listDeletedMails.append( entry ); break;
+ case FActMove : listMovedMails.append( entry ); break;
+ default : kdError( "FilterLog::addEntry: Could not relate the following mail:" );
+ entry.print();
+ break;
+ }
+}
+
+void FilterLog::print()
+{
+ kdDebug() << "Log state:" << endl;
+ kdDebug() << "----------" << endl;
+
+ //print all entries about deleted mails
+ kdDebug() << "Deleted mails:" << endl;
+ LogEntryList::iterator it;
+ for ( it = listDeletedMails.begin(); it != listDeletedMails.end(); ++it )
+ (*it).print();
+
+ kdDebug() << endl;
+
+ //print all entries about moved mails
+ kdDebug() << "Moved mails:" << endl;
+ for ( it = listMovedMails.begin(); it != listMovedMails.end(); ++it )
+ (*it).print();
+}
+
+void FilterLog::clearDeletedMailsLog()
+{
+ listDeletedMails.clear();
+}
+
+void FilterLog::clearMovedMailsLog()
+{
+ listMovedMails.clear();
+}
+
+void FilterLog::save()
+{
+ //maybe we have to remove old entries, calculate minimum date
+ QDateTime minTime = QDateTime::currentDateTime();
+ minTime = minTime.addDays( daysStoreDeletedMails * -1 );
+
+ //we need a XML document
+ QDomDocument doc( LOG_DOCTYPE );
+
+ //and a root element
+ QDomElement rootElem = doc.createElement( LOG_ROOT_ELEMENT );
+ doc.appendChild( rootElem );
+
+ //store the entries of the deleted mails list into the document
+ //if the user want it
+ if( deletedMailsStorageMode != exit )
+ {
+ LogEntryList::iterator it;
+ for ( it = listDeletedMails.begin(); it != listDeletedMails.end(); ++it )
+ {
+ if( (*it).getDate() >= minTime )
+ (*it).save( doc, rootElem );
+ }
+ }
+
+
+ //get the name of the file to save
+ QString filename = locateLocal( "appdata", LOG_FILE );
+
+ //and save
+ QFile file( filename );
+
+ if ( file.open( IO_WriteOnly ) ) //open file
+ {
+ QTextStream stream( &file );
+ doc.save( stream, 2 );
+ file.close();
+ }
+ else
+ {
+ KMessageBox::error( NULL, i18n( "Could not save the filter log." ) );
+ }
+}
+
+void FilterLog::load()
+{
+ //maybe we have to remove old entries, calculate minimum date
+ QDateTime minTime = QDateTime::currentDateTime();
+ minTime = minTime.addDays( daysStoreDeletedMails * -1 );
+
+ //we need a XML document
+ QDomDocument doc( LOG_DOCTYPE );
+
+ //get the name of the file
+ QString filename = locateLocal( "appdata", LOG_FILE );
+
+ //load the log from file into the DOM document
+ QFile file( filename );
+
+ if ( !file.open( IO_ReadOnly ) )
+ return; //return, if the file can't opened
+
+ if ( !doc.setContent( &file ) ) {
+ file.close(); //return, if the content of the file is invalid
+ return;
+ }
+
+ //the content was loaded, close the file
+ file.close();
+
+ //iterate over all DOM elements and generate the log entries
+ QDomElement docElem = doc.documentElement(); //get root element
+
+ //return, if the root element is not LOG_ROOT_ELEMENT
+ if( docElem.tagName() != LOG_ROOT_ELEMENT ) return;
+
+ QDomNode n = docElem.firstChild(); //get first child (this is the first log entry)
+ while( !n.isNull() )
+ {
+ QDomElement e = n.toElement(); //try to convert the node to an element.
+ if( !e.isNull() )
+ {
+ if( e.tagName() == LOG_ENTRY_ELEMENT )
+ {
+ //add the read entry to the list of deleted mails
+ QDateTime mailTime = QDateTime::fromString( e.attribute( LOG_ENTRY_ATTRIBUTE_DATETIME ), Qt::ISODate );
+ if( mailTime >= minTime )
+ addDeletedMail( mailTime,
+ e.attribute( LOG_ENTRY_ATTRIBUTE_SENDER ),
+ e.attribute( LOG_ENTRY_ATTRIBUTE_ACCOUNT ),
+ e.attribute( LOG_ENTRY_ATTRIBUTE_SUBJECT ) );
+ }
+ }
+ n = n.nextSibling(); //get next child
+ }
+}
+
+LogEntryList FilterLog::getDeletedMails( )
+{
+ return listDeletedMails;
+}
+
+LogEntryList FilterLog::getMovedMails( )
+{
+ return listMovedMails;
+}
+
+void FilterLog::loadSetup( )
+{
+ config->setGroup( CONFIG_GROUP_LOG );
+
+ logDeletedMails = config->readBoolEntry( CONFIG_ENTRY_LOG_LOG_DELETED_MAILS, DEFAULT_LOG_LOG_DELETED_MAILS );
+ logMovedMails = config->readBoolEntry( CONFIG_ENTRY_LOG_LOG_MOVED_MAILS, DEFAULT_LOG_LOG_MOVED_MAILS );
+
+ if( logDeletedMails )
+ {
+ QString storageMode = config->readEntry(CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, DEFAULT_LOG_REMOVE_DELETED_MAILS );
+ if( storageMode == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ deletedMailsStorageMode = exit;
+ else if( storageMode == CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS )
+ deletedMailsStorageMode = days;
+ else
+ deletedMailsStorageMode = days;
+
+ if( deletedMailsStorageMode == days )
+ daysStoreDeletedMails = config->readNumEntry( CONFIG_ENTRY_LOG_HOLDDAYS_DELETED_MAILS, DEFAULT_LOG_HOLDDAYS_DELETED_MAILS );
+ else
+ daysStoreDeletedMails = 7;
+ }
+ else
+ {
+ deletedMailsStorageMode = days;
+ daysStoreDeletedMails = 7;
+ }
+}
+
+int FilterLog::numberDeletedMails( )
+{
+ return listDeletedMails.count();
+}
+
+int FilterLog::numberMovedMails( )
+{
+ return listMovedMails.count();
+}
+
+
+
diff --git a/kshowmail/filterlog.h b/kshowmail/filterlog.h
new file mode 100644
index 0000000..9896796
--- /dev/null
+++ b/kshowmail/filterlog.h
@@ -0,0 +1,183 @@
+//
+// C++ Interface: filterlog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERLOG_H
+#define FILTERLOG_H
+
+//Qt headers
+#include <qvaluelist.h>
+#include <qdatetime.h>
+#include <qdom.h>
+#include <qfile.h>
+#include <qtextstream.h>
+
+//KDE headers
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kconfig.h>
+
+//KShowmail headers
+#include "filterlogentry.h"
+#include "constants.h"
+
+/**
+ * @brief This is the log of the filters.
+ * It holds two lists of entry objects (class FilterLogEntry). One for the deleted mails and the other one for
+ * the moved mails.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+
+typedef QValueList<FilterLogEntry> LogEntryList;
+
+
+class FilterLog{
+
+
+ public:
+
+ /**
+ * Default constructor
+ */
+ FilterLog();
+
+ /**
+ * Destructor
+ */
+ ~FilterLog();
+
+ /**
+ * Adds an entry about a deleted mail.
+ * @param dateTime date and time on which the mail was sent
+ * @param sender sender of the mail
+ * @param account Account which has received the mail
+ * @param subject Subject of the mail
+ */
+ void addDeletedMail( const QDateTime& dateTime, const QString& sender, const QString& account, const QString& subject );
+
+ /**
+ * Adds an entry about a moved mail.
+ * @param dateTime date and time on which the mail was sent
+ * @param sender sender of the mail
+ * @param account Account which has received the mail
+ * @param subject Subject of the mail
+ * @param mailbox mailbox
+ */
+ void addMovedMail( const QDateTime& dateTime, const QString& sender, const QString& account, const QString& subject, const QString& mailbox );
+
+ /**
+ * Prints the log state.
+ */
+ void print();
+
+ /**
+ * Clears the log of deleted mails.
+ */
+ void clearDeletedMailsLog();
+
+ /**
+ * Clears the log of moved mails.
+ */
+ void clearMovedMailsLog();
+
+ /**
+ * Saved the log of deleted mails as XML document.
+ */
+ void save();
+
+ /**
+ * Loads the log of deleted mails from the XML document and get settings.
+ */
+ void load();
+
+ /**
+ * Returns a copy of the list of deleted mails.
+ * @return copy of the deleted mails list
+ */
+ LogEntryList getDeletedMails();
+
+ /**
+ * Retruns a copy of the list of moved mails.
+ * @return copy of the moved mails list
+ */
+ LogEntryList getMovedMails();
+
+ /**
+ * Loads the settings
+ */
+ void loadSetup();
+
+ /**
+ * Returns the number of logged deleted mails.
+ * @return number of logged deleted mails
+ */
+ int numberDeletedMails();
+
+ /**
+ * Returns the number of logged moved mails.
+ * @return number of logged moved mails
+ */
+ int numberMovedMails();
+
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * List of entries about deleted mails.
+ */
+ LogEntryList listDeletedMails;
+
+ /**
+ * List of entries about moved mails.
+ */
+ LogEntryList listMovedMails;
+
+ /**
+ * TRUE - the log accepts orders to log deleted mails
+ */
+ bool logDeletedMails;
+
+ /**
+ * TRUE - the log accepts orders to log moved mails
+ */
+ bool logMovedMails;
+
+ /**
+ * exit - hold log of deleted mails until application exit
+ * days - hold log some days
+ */
+ enum{ exit, days } deletedMailsStorageMode;
+
+ /**
+ * Time (days) a entry of a deleted mail will be stored.
+ */
+ unsigned int daysStoreDeletedMails;
+
+ protected:
+
+ /**
+ * adds an entry.
+ * The target list will be coose on the basis of the given filter action.
+ */
+ void addEntry( FilterAction_Type action, const QDateTime& dateTime, const QString& sender, const QString& account, const QString& subject, const QString& mailbox = QString::null );
+
+};
+
+
+#endif
diff --git a/kshowmail/filterlogentry.cpp b/kshowmail/filterlogentry.cpp
new file mode 100644
index 0000000..8f9af1c
--- /dev/null
+++ b/kshowmail/filterlogentry.cpp
@@ -0,0 +1,145 @@
+
+
+//
+// C++ Implementation: filterlogentry
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filterlogentry.h"
+
+FilterLogEntry::FilterLogEntry()
+{
+ //set default values
+ sentDateTime.setDate( QDate( 2007, 11, 7 ) );
+ sentDateTime.setTime( QTime( 19, 05 ) );
+ act = FActNone;
+}
+
+FilterLogEntry::FilterLogEntry( FilterAction_Type action, const QDateTime& dateTime, const QString& sender, const QString& account, const QString& subject, const QString& mailbox)
+ : act( action ), sentDateTime( dateTime ), sender( sender ), account( account ), subject( subject ), mailbox( mailbox )
+{
+}
+
+FilterLogEntry::~FilterLogEntry()
+{
+}
+
+void FilterLogEntry::print()
+{
+ QString strAction;
+ switch( act )
+ {
+ case FActPass : strAction = "Passed"; break;
+ case FActDelete : strAction = "Deleted"; break;
+ case FActMark : strAction = "Marked"; break;
+ case FActSpamcheck : strAction = "forwarded to check for spam"; break;
+ case FActMove : strAction = QString( "moved to %1" ).arg( mailbox); break;
+ case FActNone : strAction = "no Action (THIS IS AN ERROR!)"; break;
+ default : strAction = "ERROR! UNKNOWN ACTION"; break;
+ }
+
+ kdDebug() << sentDateTime.toString( Qt::LocalDate ) << ";" << account << ";" << sender << ";" << subject << ";" << strAction << endl;
+}
+
+FilterLogEntry::FilterLogEntry(const FilterLogEntry & ent)
+{
+ this->sentDateTime = ent.sentDateTime;
+ this->account = ent.account;
+ this->sender = ent.sender;
+ this->subject = ent.subject;
+ this->act = ent.act;
+ this->mailbox = ent.mailbox;
+}
+
+FilterLogEntry& FilterLogEntry::operator=( const FilterLogEntry & ent )
+{
+ if( this == &ent ) return *this;
+
+ this->sentDateTime = ent.sentDateTime;
+ this->account = ent.account;
+ this->sender = ent.sender;
+ this->subject = ent.subject;
+ this->mailbox = ent.mailbox;
+ this->act = ent.act;
+
+ return *this;
+}
+
+bool FilterLogEntry::isOlder( uint days )
+{
+ return sentDateTime.date().addDays( days ) < QDate::currentDate();
+}
+
+bool FilterLogEntry::operator== ( const FilterLogEntry& ent ) const
+{
+ return sentDateTime == ent.sentDateTime;
+}
+
+bool FilterLogEntry::operator!=( const FilterLogEntry& ent ) const
+{
+ return sentDateTime != ent.sentDateTime;
+}
+
+bool FilterLogEntry::operator>( const FilterLogEntry& ent ) const
+{
+ return sentDateTime > ent.sentDateTime;
+}
+
+bool FilterLogEntry::operator>=( const FilterLogEntry& ent ) const
+{
+ return sentDateTime >= ent.sentDateTime;
+}
+
+bool FilterLogEntry::operator<( const FilterLogEntry& ent ) const
+{
+ return sentDateTime < ent.sentDateTime;
+}
+
+bool FilterLogEntry::operator<=( const FilterLogEntry & ent ) const
+{
+ return sentDateTime <= ent.sentDateTime;
+}
+
+void FilterLogEntry::save( QDomDocument& doc, QDomElement& parent )
+{
+ //create a new element and store the entry
+ QDomElement elem = doc.createElement( LOG_ENTRY_ELEMENT );
+ elem.setAttribute( LOG_ENTRY_ATTRIBUTE_DATETIME, sentDateTime.toString( Qt::ISODate) );
+ elem.setAttribute( LOG_ENTRY_ATTRIBUTE_SENDER, sender );
+ elem.setAttribute( LOG_ENTRY_ATTRIBUTE_ACCOUNT, account );
+ elem.setAttribute( LOG_ENTRY_ATTRIBUTE_SUBJECT, subject );
+
+ //add entry element to the log (parent) element
+ parent.appendChild( elem );
+}
+
+QDateTime FilterLogEntry::getDate( )
+{
+ return sentDateTime;
+}
+
+QString FilterLogEntry::getSender( )
+{
+ return sender;
+}
+
+QString FilterLogEntry::getAccount( )
+{
+ return account;
+}
+
+QString FilterLogEntry::getSubject( )
+{
+ return subject;
+}
+
+QString FilterLogEntry::getMailbox( )
+{
+ return mailbox;
+}
diff --git a/kshowmail/filterlogentry.h b/kshowmail/filterlogentry.h
new file mode 100644
index 0000000..9dbd1be
--- /dev/null
+++ b/kshowmail/filterlogentry.h
@@ -0,0 +1,196 @@
+//
+// C++ Interface: filterlogentry
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERLOGENTRY_H
+#define FILTERLOGENTRY_H
+
+//Qt headers
+#include <qdatetime.h>
+#include <qstring.h>
+#include <qdom.h>
+
+//KDE headers
+#include <kdebug.h>
+
+//KShowmail headers
+#include "types.h"
+#include "constants.h"
+
+using namespace Types;
+
+/**
+ * @brief An Object of this class contains the datas about a deleted or moved mail.
+ * These objects are stored in the lists of the filter log.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+
+class FilterLogEntry{
+
+ public:
+
+ /**
+ * Default constructor
+ */
+ FilterLogEntry();
+
+ /**
+ * General constructor
+ * @param action executed action
+ * @param dateTime date and time on which the mail was sent
+ * @param sender sender of the mail
+ * @param account Account which has received the mail
+ * @param subject Subject of the mail
+ * @param mailbox mailbox where the mails was moved
+ */
+ FilterLogEntry( FilterAction_Type action, const QDateTime& dateTime, const QString& sender, const QString& account, const QString& subject, const QString& mailbox = QString::null );
+
+ /**
+ * Copy Constructor
+ * @param ent source entry
+ */
+ FilterLogEntry( const FilterLogEntry& ent );
+
+ /**
+ * Destructor
+ */
+ ~FilterLogEntry();
+
+ /**
+ * Assignment operator
+ * @param ent source entry
+ */
+ FilterLogEntry& operator=( const FilterLogEntry& ent );
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is equal to te time of the given entry.
+ */
+ bool operator==( const FilterLogEntry& ent ) const;
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is not equal to the time of the given entry.
+ */
+ bool operator!=( const FilterLogEntry& ent ) const;
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is later than the time of the given entry.
+ */
+ bool operator>( const FilterLogEntry& ent ) const;
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is later than or equal to the time of the given entry.
+ */
+ bool operator>=( const FilterLogEntry& ent ) const;
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is earlier than the time of the given entry.
+ */
+ bool operator<( const FilterLogEntry& ent ) const;
+
+ /**
+ * Compares this entry with the given entry
+ * @param ent entry to compare
+ * @return TRUE - the time of this entry is earlier than or equal to the time of the given entry.
+ */
+ bool operator<=( const FilterLogEntry& ent ) const;
+
+ /**
+ * Prints the datas of this entry to Stdout.
+ */
+ void print();
+
+ /**
+ * Returns whether the mail of this entry is older than the given number of days.
+ * @param days number of days to compare
+ * @return TRUE - the mail is older than the given date
+ */
+ bool isOlder( uint days );
+
+ /**
+ * Stores the entry into the given DOM document as child of the given DOM element.
+ */
+ void save( QDomDocument& doc, QDomElement& parent );
+
+ /**
+ * Returns the date and time of send
+ * @return send date and time
+ */
+ QDateTime getDate();
+
+ /**
+ * Returns the sender.
+ * @return Sender
+ */
+ QString getSender();
+
+ /**
+ * Returns the account.
+ * @return Account
+ */
+ QString getAccount();
+
+ /**
+ * Returns the subject
+ * @return Subject
+ */
+ QString getSubject();
+
+ /**
+ * Returns the mailbox
+ * @return mailbox
+ */
+ QString getMailbox();
+
+ private:
+
+ /**
+ * executed action
+ */
+ FilterAction_Type act;
+
+ /**
+ * Delivery date and time
+ */
+ QDateTime sentDateTime;
+
+ /**
+ * Sender
+ */
+ QString sender;
+
+ /**
+ * Account
+ */
+ QString account;
+
+ /**
+ * Subject
+ */
+ QString subject;
+
+ /**
+ * mailbox if the mails was moved
+ */
+ QString mailbox;
+
+};
+
+#endif
diff --git a/kshowmail/filterlogview.cpp b/kshowmail/filterlogview.cpp
new file mode 100644
index 0000000..22a4a54
--- /dev/null
+++ b/kshowmail/filterlogview.cpp
@@ -0,0 +1,121 @@
+//
+// C++ Implementation: filterlogview
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filterlogview.h"
+
+FilterLogView::FilterLogView( QWidget *parent, FilterLog* log )
+ : KDialogBase( parent, "FilterLogView", true, QString::null, Ok, Ok, true )
+{
+ //save the log pointer
+ this->log = log;
+
+ //set caption
+ setCaption( i18n( "Filter Log View" ) );
+
+ //main widget
+ QWidget* pgMain = new QWidget( this );
+ setMainWidget( pgMain );
+
+ //basic layout
+ QVBoxLayout* layMain = new QVBoxLayout( pgMain, 0, spacingHint() );
+
+ //view of deleted views
+ QLabel* lblDeletedMails = new QLabel( i18n( "Deleted Mails:"), pgMain, "lblDeletedMails" );
+ layMain->addWidget( lblDeletedMails );
+
+ lstViewDeleted = new KListView( pgMain, "lstViewDeleted" );
+ lstViewDeleted->addColumn( i18n( "Date" ) );
+ lstViewDeleted->addColumn( i18n( "Sender" ) );
+ lstViewDeleted->addColumn( i18n( "Account" ) );
+ lstViewDeleted->addColumn( i18n( "Subject" ) );
+ lstViewDeleted->setColumnWidthMode( 0, QListView::Maximum );
+ lstViewDeleted->setColumnWidthMode( 1, QListView::Maximum );
+ lstViewDeleted->setColumnWidthMode( 2, QListView::Maximum );
+ lstViewDeleted->setColumnWidthMode( 3, QListView::Maximum );
+ lstViewDeleted->setResizeMode( QListView::NoColumn );
+ lstViewDeleted->setSortColumn( 0 );
+ lstViewDeleted->setSortOrder( Qt::Ascending );
+ layMain->addWidget( lstViewDeleted );
+
+ KPushButton* btnClearDeleted = new KPushButton( KStdGuiItem::clear(), pgMain, "btnClearDeleted" );
+ QToolTip::add( btnClearDeleted, i18n( "Clear the list of deleted mails" ) );
+ connect( btnClearDeleted, SIGNAL( clicked() ), this, SLOT( slotClearDeletedMails() ) );
+ btnClearDeleted->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ layMain->addWidget( btnClearDeleted );
+
+ //create a seperator
+ layMain->addWidget( new KSeparator( pgMain ) );
+
+ //view of deleted views
+ QLabel* lblMovedMails = new QLabel( i18n( "Moved Mails:"), pgMain, "lblMovedMails" );
+ layMain->addWidget( lblMovedMails );
+
+ lstViewMoved = new KListView( pgMain, "lstViewMoved" );
+ lstViewMoved->addColumn( i18n( "Date" ) );
+ lstViewMoved->addColumn( i18n( "Sender" ) );
+ lstViewMoved->addColumn( i18n( "Account" ) );
+ lstViewMoved->addColumn( i18n( "Moved To" ) );
+ lstViewMoved->addColumn( i18n( "Subject" ) );
+ lstViewMoved->setColumnWidthMode( 0, QListView::Maximum );
+ lstViewMoved->setColumnWidthMode( 1, QListView::Maximum );
+ lstViewMoved->setColumnWidthMode( 2, QListView::Maximum );
+ lstViewMoved->setColumnWidthMode( 3, QListView::Maximum );
+ lstViewMoved->setColumnWidthMode( 4, QListView::Maximum );
+ lstViewMoved->setResizeMode( QListView::NoColumn );
+ lstViewMoved->setSortColumn( 0 );
+ lstViewMoved->setSortOrder( Qt::Ascending );
+ layMain->addWidget( lstViewMoved );
+
+ KPushButton* btnClearMoved = new KPushButton( KStdGuiItem::clear(), pgMain, "btnClearMoved" );
+ QToolTip::add( btnClearMoved, i18n( "Clear the list of moved mails" ) );
+ connect( btnClearMoved, SIGNAL( clicked() ), this, SLOT( slotClearMovedMails() ) );
+ btnClearMoved->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ layMain->addWidget( btnClearMoved );
+
+ //now we load the content for the list views
+ LogEntryList listDeletedMails = log->getDeletedMails();
+ LogEntryList::iterator it;
+ for( it = listDeletedMails.begin(); it != listDeletedMails.end(); it++ )
+ {
+ //create a new list view item
+ FilterLogViewDeletedItem* item = new FilterLogViewDeletedItem( lstViewDeleted );
+ item->setValues( (*it).getDate(), (*it).getSender(), (*it).getAccount(), (*it).getSubject() );
+ }
+
+ LogEntryList listMovedMails = log->getMovedMails();
+ for( it = listMovedMails.begin(); it != listMovedMails.end(); it++ )
+ {
+ //create a new list view item
+ FilterLogViewMovedItem* item = new FilterLogViewMovedItem( lstViewMoved );
+ item->setValues( (*it).getDate(), (*it).getSender(), (*it).getAccount(), (*it).getMailbox(), (*it).getSubject() );
+ }
+}
+
+
+FilterLogView::~FilterLogView()
+{
+}
+
+void FilterLogView::slotClearDeletedMails( )
+{
+ log->clearDeletedMailsLog();
+ lstViewDeleted->clear();
+
+}
+
+void FilterLogView::slotClearMovedMails( )
+{
+ log->clearMovedMailsLog();
+ lstViewMoved->clear();
+}
+
+
+#include "filterlogview.moc"
diff --git a/kshowmail/filterlogview.h b/kshowmail/filterlogview.h
new file mode 100644
index 0000000..a138de8
--- /dev/null
+++ b/kshowmail/filterlogview.h
@@ -0,0 +1,87 @@
+//
+// C++ Interface: filterlogview
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERLOGVIEW_H
+#define FILTERLOGVIEW_H
+
+//Qt headers
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <klistview.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#include <kseparator.h>
+
+//KShowmail headers
+#include "filterlog.h"
+#include "filterlogviewdeleteditem.h"
+#include "filterlogviewmoveditem.h"
+
+/**
+ * @brief This dialog box shows the filter log.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterLogView : public KDialogBase
+{
+
+Q_OBJECT
+
+ public:
+
+ /**
+ * General constructor
+ * @param parent pointer to the parent widget
+ * @param log pointer to the filter log
+ */
+ FilterLogView( QWidget* parent = NULL, FilterLog* log = NULL );
+
+ /**
+ * Destructor
+ */
+ ~FilterLogView();
+
+ private:
+
+ /**
+ * Pointer to the filter log.
+ */
+ FilterLog* log;
+
+ /**
+ * List view of deleted mails
+ */
+ KListView* lstViewDeleted;
+
+ /**
+ * List view of moved mails
+ */
+ KListView* lstViewMoved;
+
+ private slots:
+
+ /**
+ * Clears the list of deleted mails.
+ */
+ void slotClearDeletedMails();
+
+ /**
+ * Clears th elist of moved mails.
+ */
+ void slotClearMovedMails();
+
+};
+
+#endif
diff --git a/kshowmail/filterlogviewdeleteditem.cpp b/kshowmail/filterlogviewdeleteditem.cpp
new file mode 100644
index 0000000..587f079
--- /dev/null
+++ b/kshowmail/filterlogviewdeleteditem.cpp
@@ -0,0 +1,58 @@
+//
+// C++ Implementation: filterlogviewdeleteditem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filterlogviewdeleteditem.h"
+
+FilterLogViewDeletedItem::FilterLogViewDeletedItem( KListView* parent )
+ : KListViewItem( parent )
+{
+}
+
+
+FilterLogViewDeletedItem::~FilterLogViewDeletedItem()
+{
+}
+
+void FilterLogViewDeletedItem::setValues( QDateTime date, QString sender, QString account, QString subject )
+{
+ //store values
+ this->date = date;
+ this->sender = sender;
+ this->account = account;
+ this->subject = subject;
+
+ //set column text
+ setText( ColDate, date.toString( Qt::LocalDate ) );
+ setText( ColSender, sender );
+ setText( ColAccount, account );
+ setText( ColSubject, subject );
+}
+
+int FilterLogViewDeletedItem::compare( QListViewItem * i, int col, bool ascending ) const
+{
+ if( col == ColDate )
+ {
+ if( this->date < ((FilterLogViewDeletedItem*)i)->getDate() ) return -1;
+ if( this->date > ((FilterLogViewDeletedItem*)i)->getDate() ) return 1;
+ else return 0;
+ }
+ else
+ return key( col, ascending ).compare( i->key( col, ascending) );
+
+}
+
+QDateTime FilterLogViewDeletedItem::getDate( )
+{
+ return date;
+}
+
+
+
diff --git a/kshowmail/filterlogviewdeleteditem.h b/kshowmail/filterlogviewdeleteditem.h
new file mode 100644
index 0000000..6692106
--- /dev/null
+++ b/kshowmail/filterlogviewdeleteditem.h
@@ -0,0 +1,95 @@
+//
+// C++ Interface: filterlogviewdeleteditem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERLOGVIEWDELETEDITEM_H
+#define FILTERLOGVIEWDELETEDITEM_H
+
+//Qt Headers
+#include <qdatetime.h>
+
+//KDE headers
+#include <klistview.h>
+
+/**
+ * @brief Item of the filter log view of deleted mails
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterLogViewDeletedItem : public KListViewItem
+{
+
+ public:
+
+ /**
+ * Column Numbers.
+ */
+ enum Column{ ColDate = 0, ColSender = 1, ColAccount = 2, ColSubject = 3 };
+
+ /**
+ * Constructor
+ * @param parent the log view of this items
+ */
+ FilterLogViewDeletedItem( KListView* parent );
+
+ /**
+ * Destrutor
+ */
+ ~FilterLogViewDeletedItem();
+
+ /**
+ * Sets the column values.
+ * @param date date and time at which the mail was sent
+ * @param sender sender of the mail
+ * @param account account
+ * @param subject mail subject
+ */
+ void setValues( QDateTime date, QString sender, QString account, QString subject );
+
+ /**
+ * Reimplemantation of QListViewItem::compare.
+ * Compares this list view item to i using the column col in ascending order. Returns <0 if this item is less than i,
+ * 0 if they are equal and >0 if this item is greater than i. The parameter ascneding will be ignored.
+ * @param i pointer to the second view item
+ * @param col number of the sorted column
+ * @param ascending ignored
+ */
+ virtual int compare( QListViewItem* i, int col, bool ascending ) const;
+
+ /**
+ * Returns the date of sent
+ * @return date of sent
+ */
+ QDateTime getDate();
+
+
+ private:
+
+ /**
+ * sent date and time
+ */
+ QDateTime date;
+
+ /**
+ * sender of the mail
+ */
+ QString sender;
+
+ /**
+ * Account
+ */
+ QString account;
+
+ /**
+ * mail subject
+ */
+ QString subject;
+};
+
+#endif
diff --git a/kshowmail/filterlogviewmoveditem.cpp b/kshowmail/filterlogviewmoveditem.cpp
new file mode 100644
index 0000000..80b02ba
--- /dev/null
+++ b/kshowmail/filterlogviewmoveditem.cpp
@@ -0,0 +1,58 @@
+//
+// C++ Implementation: filterlogviewmoveditem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filterlogviewmoveditem.h"
+
+FilterLogViewMovedItem::FilterLogViewMovedItem( KListView * parent )
+ : KListViewItem( parent )
+{
+}
+
+
+FilterLogViewMovedItem::~FilterLogViewMovedItem()
+{
+}
+
+void FilterLogViewMovedItem::setValues( QDateTime date, QString sender, QString account, QString mailbox, QString subject )
+{
+ //store values
+ this->date = date;
+ this->sender = sender;
+ this->account = account;
+ this->mailbox = mailbox;
+ this->subject = subject;
+
+ //set column text
+ setText( ColDate, date.toString( Qt::LocalDate ) );
+ setText( ColSender, sender );
+ setText( ColAccount, account );
+ setText( ColMailbox, mailbox );
+ setText( ColSubject, subject );
+}
+
+int FilterLogViewMovedItem::compare( QListViewItem * i, int col, bool ascending ) const
+{
+ if( col == ColDate )
+ {
+ if( this->date < ((FilterLogViewMovedItem*)i)->getDate() ) return -1;
+ if( this->date > ((FilterLogViewMovedItem*)i)->getDate() ) return 1;
+ else return 0;
+ }
+ else
+ return key( col, ascending ).compare( i->key( col, ascending) );
+
+}
+
+QDateTime FilterLogViewMovedItem::getDate( )
+{
+ return date;
+}
+
diff --git a/kshowmail/filterlogviewmoveditem.h b/kshowmail/filterlogviewmoveditem.h
new file mode 100644
index 0000000..9a7a7f8
--- /dev/null
+++ b/kshowmail/filterlogviewmoveditem.h
@@ -0,0 +1,101 @@
+//
+// C++ Interface: filterlogviewmoveditem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERLOGVIEWMOVEDITEM_H
+#define FILTERLOGVIEWMOVEDITEM_H
+
+//Qt Headers
+#include <qdatetime.h>
+
+//KDE headers
+#include <klistview.h>
+
+/**
+ * @brief Item of the filter log view of moved mails
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterLogViewMovedItem : public KListViewItem
+{
+
+ public:
+
+ /**
+ * Column Numbers.
+ */
+ enum Column{ ColDate = 0, ColSender = 1, ColAccount = 2, ColMailbox = 3, ColSubject = 4 };
+
+ /**
+ * Constructor
+ * @param parent the log view of this items
+ */
+ FilterLogViewMovedItem( KListView* parent);
+
+ /**
+ * Destructor
+ */
+ ~FilterLogViewMovedItem();
+
+ /**
+ * Sets the column values.
+ * @param date date and time at which the mail was sent
+ * @param sender sender of the mail
+ * @param account account
+ * @param mailbox mailbox to which the mail was moved
+ * @param subject mail subject
+ */
+ void setValues( QDateTime date, QString sender, QString account, QString mailbox, QString subject );
+
+ /**
+ * Reimplemantation of QListViewItem::compare.
+ * Compares this list view item to i using the column col in ascending order. Returns <0 if this item is less than i,
+ * 0 if they are equal and >0 if this item is greater than i. The parameter ascneding will be ignored.
+ * @param i pointer to the second view item
+ * @param col number of the sorted column
+ * @param ascending ignored
+ */
+ virtual int compare( QListViewItem* i, int col, bool ascending ) const;
+
+ /**
+ * Returns the date of sent
+ * @return date of sent
+ */
+ QDateTime getDate();
+
+
+ private:
+
+ /**
+ * sent date and time
+ */
+ QDateTime date;
+
+ /**
+ * sender of the mail
+ */
+ QString sender;
+
+ /**
+ * Account
+ */
+ QString account;
+
+ /**
+ * mail subject
+ */
+ QString subject;
+
+ /**
+ * mailbox
+ */
+ QString mailbox;
+};
+
+#endif
diff --git a/kshowmail/headerfilter.cpp b/kshowmail/headerfilter.cpp
new file mode 100644
index 0000000..10bedf0
--- /dev/null
+++ b/kshowmail/headerfilter.cpp
@@ -0,0 +1,151 @@
+//
+// C++ Implementation: headerfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "headerfilter.h"
+
+HeaderFilter::HeaderFilter()
+{
+ //get the application config object
+ config = KApplication::kApplication()->config();
+
+ //the filter list shall delete all filters if it will be deleted itself
+ filters.setAutoDelete( true );
+
+ //load settings
+ load();
+}
+
+
+HeaderFilter::~HeaderFilter()
+{
+}
+
+FilterAction_Type HeaderFilter::check( QString from, QString to, uint size, QString subject, QString header, QString account, QString& mailboxName ) const
+{
+ //return PASS, if filter is not active
+ if( !active )
+ return FActPass;
+
+ //check for matching with blacklist or whitelist
+ FilterAction_Type action = senderlist.check( from );
+ if( action != FActNone ) return action;
+
+ //check for matching with filters
+ QPtrListIterator<FilterItem> it( filters );
+ FilterItem* filter;
+ while( ( filter = it.current() ) != NULL )
+ {
+ ++it;
+ action = filter->check( from, to, size, subject, header, account, mailboxName );
+
+ if( action != FActNone ) return action;
+ }
+
+ //no matching; return default action
+ if( defaultAction == FActMove )
+ {
+ mailboxName.remove( 0, mailboxName.length() );
+ mailboxName.append( mailbox );
+ }
+ return defaultAction;
+
+}
+
+void HeaderFilter::load( )
+{
+ //order sender list to load its settings
+ senderlist.load();
+
+ //set group
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //get filter active state
+ active = config->readBoolEntry( CONFIG_ENTRY_FILTER_ACTIVE, DEFAULT_FILTER_ACTIVE );
+
+ //get number of filter items
+ numberFilterItems = config->readNumEntry( CONFIG_ENTRY_FILTER_NUMBER_OF_FILTERS, 0 );
+
+ //get default action
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, DEFAULT_FILTER_OTHERS_ACTION ) )
+ {
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS : defaultAction = FActPass; break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE : defaultAction = FActDelete; break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK : defaultAction = FActMark; break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE : defaultAction = FActMove; break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE : defaultAction = FActIgnore; break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK : defaultAction = FActSpamcheck; break;
+ default : kdError() << "Header Filter: Unknown default filter action. Set PASS." << endl;
+ defaultAction = FActPass;
+ break;
+ }
+
+ //get mailbox name if default action is MOVE
+ if( defaultAction == FActMove )
+ mailbox = config->readEntry( CONFIG_ENTRY_FILTER_OTHERS_MAILBOX, DEFAULT_FILTER_ACTION_MOVE_MAILBOX );
+
+ //now we get the filters
+ //first clear the list
+ filters.clear();
+
+ for( uint filterNr = 1; filterNr <= numberFilterItems; filterNr++ )
+ {
+ filters.append( new FilterItem( filterNr ) ); //a new created filter item loads its settings itself
+ }
+}
+
+void HeaderFilter::print( )
+{
+ kdDebug() << "Header Filter Settings:" << endl;
+ kdDebug() << "-----------------------" << endl;
+
+ //print active state
+ if( active )
+ kdDebug() << "Header filter is active." << endl;
+ else
+ kdDebug() << "Header filter is not active." << endl;
+
+ //print settings of black and white list
+ senderlist.print();
+
+ //print filters
+ kdDebug() << endl;
+ kdDebug() << "Number of filters: " << numberFilterItems << endl << endl;
+
+ QPtrListIterator<FilterItem> it( filters );
+ FilterItem* filter;
+ while( ( filter = it.current() ) != NULL )
+ {
+ ++it;
+ filter->print();
+ kdDebug() << endl;
+ }
+
+ //print default action for not matched mails
+ switch( defaultAction )
+ {
+ case FActPass : kdDebug() << "Default action for other mails: PASS" << endl; break;
+ case FActDelete : kdDebug() << "Default action for other mails: DELETE" << endl; break;
+ case FActMark : kdDebug() << "Default action for other mails: MARK" << endl; break;
+ case FActIgnore : kdDebug() << "Default action for other mails: IGNORE" << endl;
+ case FActMove : kdDebug() << "Default action for other mails: MOVE to " << mailbox << endl; break;
+ case FActSpamcheck : kdDebug() << "Default action for other mails: SPAMCHECK" << endl; break;
+ default : kdDebug() << "Unknown default action for other mails" << endl; break;
+ }
+
+
+}
+
+bool HeaderFilter::isActive()
+{
+ return active;
+}
+
+
diff --git a/kshowmail/headerfilter.h b/kshowmail/headerfilter.h
new file mode 100644
index 0000000..c17a626
--- /dev/null
+++ b/kshowmail/headerfilter.h
@@ -0,0 +1,117 @@
+//
+// C++ Interface: headerfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef HEADERFILTER_H
+#define HEADERFILTER_H
+
+//Qt headers
+#include <qstring.h>
+#include <qptrlist.h>
+
+//KDE headers
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kconfig.h>
+
+//KShowmail headers
+#include "constants.h"
+#include "types.h"
+#include "filteritem.h"
+#include "senderlistfilter.h"
+
+/**
+ * @brief This is the mail header filter.
+ * Call check() with some header datas of the mail to get the configured action for this mail.
+ * If the settings was changed by the config GUI you have to call load().
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class HeaderFilter{
+
+ public:
+
+ /**
+ * Constructor
+ */
+ HeaderFilter();
+
+ /**
+ * Destructor
+ */
+ ~HeaderFilter();
+
+ /**
+ * Checks the given mail header.
+ * @param from Sender
+ * @param to Addressee
+ * @param size Size
+ * @param subject Subject
+ * @param header Header
+ * @param account Account
+ * @param mailboxName contains the mailbox name after call, if filter action is MOVE
+ * @return recommend action
+ */
+ FilterAction_Type check( QString from, QString to, uint size, QString subject, QString header, QString account, QString& mailboxName ) const;
+
+ /**
+ * Loads the settings from the application config file.
+ */
+ void load();
+
+ /**
+ * Prints the settings
+ */
+ void print();
+
+ /**
+ * Returns the filter active state.
+ * @return TRUE - filter is active
+ */
+ bool isActive();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * TRUE - filter is active
+ */
+ bool active;
+
+ /**
+ * Default action, if no filter matches
+ */
+ FilterAction_Type defaultAction;
+
+ /**
+ * mailbox name if default action is MOVE
+ */
+ QString mailbox;
+
+ /**
+ * Number of filter items
+ */
+ uint numberFilterItems;
+
+ /**
+ * Black and White lists
+ */
+ SenderListFilter senderlist;
+
+ /**
+ * This list holds the filter items
+ */
+ QPtrList<FilterItem> filters;
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/Makefile.am b/kshowmail/kcmconfigs/Makefile.am
new file mode 100644
index 0000000..94cd555
--- /dev/null
+++ b/kshowmail/kcmconfigs/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+kde_module_LTLIBRARIES = kcm_kshowmailconfigaccounts.la \
+ kcm_kshowmailconfigactions.la kcm_kshowmailconfigdisplay.la kcm_kshowmailconfigfilter.la \
+ kcm_kshowmailconfiggeneral.la kcm_kshowmailconfiglog.la kcm_kshowmailconfigspamcheck.la
+kcm_kshowmailconfigactions_la_LDFLAGS = -avoid-version -module $(all_libraries)
+noinst_HEADERS = accountsetupdialog.h accountsetupitem.h configaccounts.h \
+ configactions.h configdisplay.h configfilter.h configgeneral.h configlog.h \
+ configspamcheck.h encryption.h filtercriteriawidget.h filtersetupdialog.h \
+ filtersetupitem.h kwalletaccess.h mailboxwizard.h mailboxwizardlistitem.h \
+ senderlistdialog.h
+kcm_kshowmailconfigactions_la_SOURCES = configactions.cpp
+kde_services_DATA = kshowmailconfigaccounts.desktop \
+ kshowmailconfigactions.desktop kshowmailconfigdisplay.desktop kshowmailconfigfilter.desktop \
+ kshowmailconfiggeneral.desktop kshowmailconfiglog.desktop kshowmailconfigspamcheck.desktop
+kcm_kshowmailconfiggeneral_la_LDFLAGS = -avoid-version -module\
+ $(all_libraries)
+kcm_kshowmailconfiggeneral_la_SOURCES = configgeneral.cpp
+kcm_kshowmailconfigdisplay_la_LDFLAGS = -avoid-version -module\
+ $(all_libraries)
+kcm_kshowmailconfigdisplay_la_SOURCES = configdisplay.cpp
+kcm_kshowmailconfigaccounts_la_LDFLAGS = -avoid-version -module\
+ $(all_libraries)
+kcm_kshowmailconfigaccounts_la_SOURCES = configaccounts.cpp \
+ accountsetupitem.cpp accountsetupdialog.cpp encryption.cpp kwalletaccess.cpp
+kcm_kshowmailconfigfilter_la_LDFLAGS = -avoid-version -module\
+ $(all_libraries)
+kcm_kshowmailconfigfilter_la_SOURCES = configfilter.cpp senderlistdialog.cpp \
+ filtersetupitem.cpp filtersetupdialog.cpp filtercriteriawidget.cpp mailboxwizard.cpp \
+ mailboxwizardlistitem.cpp
+kcm_kshowmailconfiglog_la_LDFLAGS = $(all_libraries) -avoid-version -module
+kcm_kshowmailconfiglog_la_SOURCES = configlog.cpp
+kcm_kshowmailconfigspamcheck_la_LDFLAGS = $(all_libraries) -avoid-version \
+ -module
+kcm_kshowmailconfigspamcheck_la_SOURCES = configspamcheck.cpp mailboxwizard.cpp \
+ mailboxwizardlistitem.cpp
diff --git a/kshowmail/kcmconfigs/accountsetupdialog.cpp b/kshowmail/kcmconfigs/accountsetupdialog.cpp
new file mode 100644
index 0000000..6c6fe22
--- /dev/null
+++ b/kshowmail/kcmconfigs/accountsetupdialog.cpp
@@ -0,0 +1,362 @@
+//
+// C++ Implementation: accountsetupdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "accountsetupdialog.h"
+
+AccountSetupDialog::AccountSetupDialog( QWidget* parent, KListView* view, AccountSetupItem* item )
+ : KDialogBase( parent, "AccountSetupDialog", true, QString::null, Ok|Cancel, Ok, true )
+{
+ //save pointer to account and view
+ account = item;
+ ListView = view;
+
+ //tab widget
+ KTabWidget* tabs = new KTabWidget( this, "tabs" );
+ tabs->setMargin( 10 );
+
+ //pages
+ QWidget* pgGeneral = new QWidget( this );
+ QWidget* pgSecurity = new QWidget( this );
+ setMainWidget( tabs );
+
+ //layouts of general page
+ QVBoxLayout* layGeneral = new QVBoxLayout( pgGeneral, 0, spacingHint() );
+ QGridLayout* layTop = new QGridLayout( layGeneral, 5, 2 );
+
+ //layouts of security page
+ QVBoxLayout* laySecurity = new QVBoxLayout( pgSecurity, 0, spacingHint() );
+ laySecurity->setAlignment( Qt::AlignTop );
+
+ //upper items
+ QLabel* lblAccount = new QLabel( i18n( "Account:" ), pgGeneral, "lblAccount" );
+ txtAccount = new KLineEdit( pgGeneral, "txtAccount" );
+ txtAccount->setFocus();
+ QToolTip::add( lblAccount, i18n( "Unique Account Name" ) );
+ QToolTip::add( txtAccount, i18n( "Unique Account Name" ) );
+ layTop->addWidget( lblAccount, 0, 0 );
+ layTop->addWidget( txtAccount, 0, 1 );
+
+ QLabel* lblServer = new QLabel( i18n( "Server:" ), pgGeneral, "lblServer" );
+ txtServer = new KLineEdit( pgGeneral, "txtServer" );
+ QToolTip::add( lblServer, i18n( "Server Name" ) );
+ QToolTip::add( txtServer, i18n( "Server Name" ) );
+ layTop->addWidget( lblServer, 1, 0 );
+ layTop->addWidget( txtServer, 1, 1 );
+
+ QLabel* lblProtocol = new QLabel( i18n( "Protocol:" ), pgGeneral, "lblProtocol" );
+ cboProtocol = new KComboBox( pgGeneral, "cboProtocol" );
+ cboProtocol->insertItem( "POP3" ); //currently KShowmail just supports POP3
+ QToolTip::add( lblProtocol, i18n( "Protocol, which shall be used to get the mails from the server. Currently KShowmail just supports POP3.") );
+ QToolTip::add( cboProtocol, i18n( "Protocol, which shall be used to get the mails from the server. Currently KShowmail just supports POP3.") );
+ layTop->addWidget( lblProtocol, 2, 0 );
+ layTop->addWidget( cboProtocol, 2, 1 );
+
+ QLabel* lblPort = new QLabel( i18n( "Port:" ), pgGeneral, "lblPort" );
+ spbPort = new QSpinBox( 0, 65535, 1, pgGeneral, "spbPort" );
+ spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 );
+ QToolTip::add( lblPort, i18n( "Port Number. Normally POP3 uses port 110." ) );
+ QToolTip::add( spbPort, i18n( "Port Number. Normally POP3 uses port 110." ) );
+ layTop->addWidget( lblPort, 3, 0 );
+ layTop->addWidget( spbPort, 3, 1 );
+
+ QLabel* lblUser = new QLabel( i18n( "User:" ), pgGeneral, "lblUser" );
+ txtUser = new KLineEdit( pgGeneral, "txtUser" );
+ QToolTip::add( lblUser, i18n( "To authenticate to the mail server you need an user name." ) );
+ QToolTip::add( txtUser, i18n( "To authenticate to the mail server you need an user name." ) );
+ layTop->addWidget( lblUser, 4, 0 );
+ layTop->addWidget( txtUser, 4, 1 );
+
+ //password groupbox and layouts
+ QGroupBox* gboxPassword = new QGroupBox( 0, Qt::Horizontal, i18n( "Password" ), pgGeneral, "gboxPassword" );
+ layGeneral->addWidget( gboxPassword );
+
+ QVBoxLayout* layPassword = new QVBoxLayout( gboxPassword->layout(), spacingHint() );
+ QGridLayout* layPasswordStorage = new QGridLayout( layPassword, 2, 2, spacingHint() );
+
+
+ //radio buttons to set storage of the password
+ grpPasswordStorage = new QButtonGroup( NULL, "grpPasswordStorage" );
+ connect( grpPasswordStorage, SIGNAL( clicked( int ) ), this, SLOT( slotPasswordStorageChanged( int ) ) );
+
+ QRadioButton* btnPasswordDontSave = new QRadioButton( i18n( "Don't save" ), gboxPassword, "btnPasswordDontSave" );
+ QRadioButton* btnPasswordSaveFile = new QRadioButton( i18n( "Save password"), gboxPassword, "btnPasswordSaveFile" );
+ QRadioButton* btnPasswordSaveKWallet = new QRadioButton( i18n( "Use KWallet" ), gboxPassword, "btnPasswordSaveKWallet" );
+ grpPasswordStorage->insert( btnPasswordDontSave, ID_BUTTON_PASSWORD_DONT_SAVE );
+ grpPasswordStorage->insert( btnPasswordSaveFile, ID_BUTTON_PASSWORD_SAVE_FILE );
+ grpPasswordStorage->insert( btnPasswordSaveKWallet, ID_BUTTON_PASSWORD_SAVE_KWALLET );
+ QToolTip::add( btnPasswordDontSave, i18n( "Don't save password. KShowmail will ask you for it at first server connect." ) );
+ QToolTip::add( btnPasswordSaveFile, i18n( "Save password in the configuration file. Not recommended, because the password is just lightly encrypted" ) );
+ QToolTip::add( btnPasswordSaveKWallet, i18n( "Use KWallet to save the password. Maybe you have to type in the KWallet master password at first server connect." ) );
+ layPasswordStorage->addWidget( btnPasswordDontSave, 0, 0 );
+ layPasswordStorage->addWidget( btnPasswordSaveFile, 0, 1 );
+ layPasswordStorage->addWidget( btnPasswordSaveKWallet, 1, 0 );
+
+ //password edit line
+ txtPassword = new KPasswordEdit( gboxPassword, "txtUser" );
+ layPassword->addWidget( txtPassword );
+
+ //set password defaults
+ grpPasswordStorage->setButton( DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+ slotPasswordStorageChanged( DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+
+ //active check box
+ QGridLayout* layActive = new QGridLayout( layGeneral, 1, 1 );
+ layActive->setAlignment( Qt::AlignCenter );
+ chkActive = new QCheckBox( i18n( "Active"), pgGeneral, "chkActive" );
+ QToolTip::add( chkActive, i18n( "Select it to activate this account." ) );
+ layActive->addWidget( chkActive, 0, 0 );
+ chkActive->setChecked( DEFAULT_ACCOUNT_ACTIVE );
+
+ //secure transfer groupbox and layouts
+ QGroupBox* gboxSecureTransfer = new QGroupBox( 0, Qt::Horizontal, i18n( "Encryption" ), pgSecurity, "gboxSecureTransfer" );
+ gboxSecureTransfer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ) );
+ laySecurity->addWidget( gboxSecureTransfer );
+
+ QHBoxLayout* laySecureTransfer = new QHBoxLayout( gboxSecureTransfer->layout(), spacingHint() );
+
+ //radio buttons to set secure transfer
+ grpSecureTransfer = new QButtonGroup( NULL, "grpSecureTransfer" );
+ connect( grpSecureTransfer, SIGNAL( clicked( int ) ), this, SLOT( slotSecureTransferChanged ( int ) ) );
+
+ QRadioButton* btnSecureTransferNone = new QRadioButton( i18n( "None" ), gboxSecureTransfer, "btnSecureTransferNone" );
+ QRadioButton* btnSecureTransferSSL = new QRadioButton( i18n( "SSL"), gboxSecureTransfer, "btnSecureTransferSSL" );
+ QRadioButton* btnSecureTransferTLS = new QRadioButton( i18n( "TLS" ), gboxSecureTransfer, "btnSecureTransferTLS" );
+ grpSecureTransfer->insert( btnSecureTransferNone, ID_BUTTON_SECTRANSFER_NONE );
+ grpSecureTransfer->insert( btnSecureTransferSSL, ID_BUTTON_SECTRANSFER_SSL );
+ grpSecureTransfer->insert( btnSecureTransferTLS, ID_BUTTON_SECTRANSFER_TLS );
+ QToolTip::add( btnSecureTransferNone, i18n( "The download of the mail header and body will not be encrypted. Use this, if your provider doesn't make a secure transfer available." ) );
+ QToolTip::add( btnSecureTransferSSL, i18n( "Secure Sockets Layer (SSL), is a cryptographic protocol that provides secure communications on the Internet." ) );
+ QToolTip::add( btnSecureTransferTLS, i18n( "Transport Layer Security (TLS) is a cryptographic protocol that provides secure communications on the Internet. It is the successor of SSL." ) );
+ laySecureTransfer->addWidget( btnSecureTransferNone );
+ laySecureTransfer->addWidget( btnSecureTransferSSL );
+ laySecureTransfer->addWidget( btnSecureTransferTLS );
+
+ grpSecureTransfer->setButton( DEFAULT_ACCOUNT_SECTRANSFER );
+
+ //set pages to tab widget
+ tabs->addTab( pgGeneral, i18n( "General" ) );
+ tabs->addTab( pgSecurity, i18n( "Security" ) );
+
+ //set caption
+ if( item == NULL )
+ setCaption( i18n( "New account" ) );
+ else
+ setCaption( i18n( "Edit account" ) );
+
+ //write values of the given account into the dialog items
+ if( account != NULL )
+ fillDialog();
+
+
+}
+
+
+AccountSetupDialog::~AccountSetupDialog()
+{
+}
+
+void AccountSetupDialog::slotPasswordStorageChanged( int id )
+{
+ if( id == ID_BUTTON_PASSWORD_DONT_SAVE )
+ {
+ txtPassword->setEnabled( false );
+ txtPassword->clear();
+ }
+ else
+ txtPassword->setEnabled( true );
+}
+
+void AccountSetupDialog::slotOk( )
+{
+ //check for necessary values
+ if( txtAccount->text() == "" )
+ {
+ KMessageBox::error( this, i18n( "Please enter an account name." ) );
+ return;
+ }
+ if( txtServer->text() == "" )
+ {
+ KMessageBox::error( this, i18n( "Please enter an server." ) );
+ return;
+ }
+
+ if( txtUser->text() == "" )
+ {
+ KMessageBox::error( this, i18n( "Please enter an user name." ) );
+ return;
+ }
+
+ //test for unique account name
+ //we will only test if the account is new or if the
+ //name in the dialog is different from the name of the account object
+ bool test = false;
+ if( account == NULL )
+ test = true;
+ else if( account != NULL && account->getAccountName() != txtAccount->text() )
+ test = true;
+ else
+ test = false;
+
+ if( test )
+ {
+ //OK, we want to test
+ AccountSetupItem* item = NULL;
+ int index = 0;
+ bool equality = false;
+
+ do
+ {
+ item = (AccountSetupItem*)( ListView->itemAtIndex( index ) );
+ if( item != NULL )
+ {
+ index++;
+ equality = item->getAccountName() == txtAccount->text();
+ }
+ } while( item != NULL && !equality );
+
+ //exit method if we have found an account with the same name
+ if( equality )
+ {
+ KMessageBox::error( this, i18n( "There is already an account named %1. Please choose another name." ).arg( txtAccount->text() ) );
+ return;
+ }
+
+ }
+
+
+ //create a new account item if necessary
+ if( account == NULL )
+ account = new AccountSetupItem( ListView );
+
+ //show a warning if the account name was changend
+ if( account->getAccountName() != DEFAULT_ACCOUNT_NAME && account->getAccountName() != txtAccount->text() )
+ KMessageBox::information( this, i18n( "You have changed the account name. The account will lose all downloaded mail headers. Please perform a refresh." ) );
+
+ //set column text
+ account->setText( 0, txtAccount->text() );
+
+ //write values into account item
+ account->setAccountName( txtAccount->text() );
+ account->setServer( txtServer->text() );
+ account->setProtocol( cboProtocol->currentText() );
+ account->setPort( spbPort->value() );
+ account->setUser( txtUser->text() );
+
+ //get the password
+ //the class KPasswordEdit doesn't have a method to set the password
+ //therefore we use setText(). But if we use this method, KPasswordEdit::password()
+ //will return an empty string. If the user has typed in a new password, KPasswordEdit::password()
+ //will return the correct password
+ QString pass;
+ if( txtPassword->password() == "" || txtPassword->password() == QString::null )
+ pass = txtPassword->text();
+ else
+ pass = txtPassword->password();
+
+ switch( grpPasswordStorage->selectedId() )
+ {
+ case ID_BUTTON_PASSWORD_DONT_SAVE : account->setPasswordStorageType( CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE );
+ account->setPassword( QString::null );
+ break;
+ case ID_BUTTON_PASSWORD_SAVE_FILE : account->setPasswordStorageType( CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE );
+ account->setPassword( pass );
+ break;
+ case ID_BUTTON_PASSWORD_SAVE_KWALLET : account->setPasswordStorageType( CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET );
+ account->setPassword( pass );
+ break;
+ default : account->setPasswordStorageType( -1 );
+ account->setPassword( QString::null );
+ }
+
+ account->setActive( chkActive->isChecked() );
+
+ switch( grpSecureTransfer->selectedId() )
+ {
+ case ID_BUTTON_SECTRANSFER_NONE : account->setTransferSecurity( CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE ); break;
+ case ID_BUTTON_SECTRANSFER_SSL : account->setTransferSecurity( CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL ); break;
+ case ID_BUTTON_SECTRANSFER_TLS : account->setTransferSecurity( CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS ); break;
+ default : account->setTransferSecurity( DEFAULT_ACCOUNT_SECTRANSFER ); break;
+ }
+
+ //call slot of super class to close the dialog
+ KDialogBase::slotOk();
+}
+
+void AccountSetupDialog::fillDialog( )
+{
+ //check for valid account pointer
+ if( account == NULL )
+ {
+ kdError() << "AccountSetupDialog::fillDialog: invalid pointer to account item." << endl;
+ return;
+ }
+
+ txtAccount->setText( account->getAccountName() );
+ txtServer->setText( account->getServer() );
+ cboProtocol->setCurrentText( account->getProtocol().upper() );
+
+ if( account->getPort() >= 0 && account->getPort() <= 65535 )
+ spbPort->setValue( account->getPort() );
+ else
+ spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 );
+
+ txtUser->setText( account->getUser() );
+
+ int type = account->getPasswordStorageType();
+ if( type != CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE && type != CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE && type != CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ type = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+
+ switch( type )
+ {
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_DONT_SAVE );
+ txtPassword->setEnabled( false );
+ txtPassword->clear();
+ break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_SAVE_FILE );
+ txtPassword->setEnabled( true );
+ txtPassword->setText( account->getPassword() );
+ break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_SAVE_KWALLET );
+ txtPassword->setEnabled( true );
+ txtPassword->setText( account->getPassword() );
+ break;
+ default : grpPasswordStorage->setButton( 1 );
+ txtPassword->clear();
+ }
+
+ chkActive->setChecked( account->getActive() );
+
+ int transferSecurity = account->getTransferSecurity();
+ if( transferSecurity != CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE && transferSecurity != CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL && transferSecurity != CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS )
+ transferSecurity = DEFAULT_ACCOUNT_SECTRANSFER;
+
+ switch( transferSecurity )
+ {
+ case CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE : grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_NONE ); break;
+ case CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL : grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_SSL ); break;
+ case CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS : grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_TLS ); break;
+ default : grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_NONE ); break;
+ }
+}
+
+void AccountSetupDialog::slotSecureTransferChanged( int id )
+{
+ switch( id )
+ {
+ case ID_BUTTON_SECTRANSFER_NONE : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 ); break;
+ case ID_BUTTON_SECTRANSFER_SSL : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3SSL ); break;
+ case ID_BUTTON_SECTRANSFER_TLS : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 ); break;
+ }
+}
+
+
+
+#include "accountsetupdialog.moc"
diff --git a/kshowmail/kcmconfigs/accountsetupdialog.h b/kshowmail/kcmconfigs/accountsetupdialog.h
new file mode 100644
index 0000000..756f51e
--- /dev/null
+++ b/kshowmail/kcmconfigs/accountsetupdialog.h
@@ -0,0 +1,165 @@
+//
+// C++ Interface: accountsetupdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef ACCOUNTSETUPDIALOG_H
+#define ACCOUNTSETUPDIALOG_H
+
+//Qt headers
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qspinbox.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kpassdlg.h>
+#include <ktabwidget.h>
+
+//KShowmail headers
+#include "accountsetupitem.h"
+#include "../constants.h"
+
+//radio button IDs
+#define ID_BUTTON_PASSWORD_DONT_SAVE 1
+#define ID_BUTTON_PASSWORD_SAVE_FILE 2
+#define ID_BUTTON_PASSWORD_SAVE_KWALLET 3
+#define ID_BUTTON_SECLOGIN_NONE 1
+#define ID_BUTTON_SECLOGIN_APOP 2
+#define ID_BUTTON_SECLOGIN_SASL 3
+#define ID_BUTTON_SECTRANSFER_NONE 1
+#define ID_BUTTON_SECTRANSFER_SSL 2
+#define ID_BUTTON_SECTRANSFER_TLS 3
+
+/**
+ * @brief Dialog to setup an account.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class AccountSetupDialog : public KDialogBase
+{
+Q_OBJECT
+
+ public:
+
+ /**
+ * General constructor
+ * @param parent parent of the dialog
+ * @param view view which shows the items
+ * @param item account to setup; if NULL, a new item will be created
+ */
+ AccountSetupDialog( QWidget* parent, KListView* view, AccountSetupItem* item = NULL );
+
+ /**
+ * Destructor
+ */
+ ~AccountSetupDialog();
+
+ private:
+
+ /**
+ * account to setup
+ */
+ AccountSetupItem* account;
+
+ /**
+ * View which shows the account items.
+ */
+ KListView* ListView;
+
+ /**
+ * Edit line which contains the unique account name.
+ */
+ KLineEdit* txtAccount;
+
+ /**
+ * Edit line which contains the server name.
+ */
+ KLineEdit* txtServer;
+
+ /**
+ * Combo box to choose the protocol.
+ */
+ KComboBox* cboProtocol;
+
+ /**
+ * Spinbox to choose the tcp port.
+ */
+ QSpinBox* spbPort;
+
+ /**
+ * Edit line which contains the user name.
+ */
+ KLineEdit* txtUser;
+
+ /**
+ * Edit line which contains the password.
+ */
+ KPasswordEdit* txtPassword;
+
+ /**
+ * Check box to select whether the account is active or not.
+ */
+ QCheckBox* chkActive;
+
+ /**
+ * Combines the radio buttons of password storage.
+ */
+ QButtonGroup* grpPasswordStorage;
+
+ /**
+ * Combines the radio buttons of secure transfer.
+ */
+ QButtonGroup* grpSecureTransfer;
+
+ protected slots:
+
+ /**
+ * Connected with the password button group.
+ * Enabled or disabled the password edit line.
+ * @param id button identifier
+ */
+ void slotPasswordStorageChanged( int id );
+
+ /**
+ * Connected with the secure transfer button group.
+ * Changes the port number.
+ * @param id button identifier
+ */
+ void slotSecureTransferChanged( int id );
+
+ /**
+ * Overwritten method of KDialogBase.
+ * Called if OK was clicked.
+ * Stores the entered values into the given account item.
+ * If no item was given it creates a new one.
+ * After then it invokes slotOk() of KDialogBase.
+ */
+ void slotOk();
+
+ protected:
+
+ /**
+ * Writes the values of the account into the dialog items.
+ */
+ void fillDialog();
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/accountsetupitem.cpp b/kshowmail/kcmconfigs/accountsetupitem.cpp
new file mode 100644
index 0000000..f9f8431
--- /dev/null
+++ b/kshowmail/kcmconfigs/accountsetupitem.cpp
@@ -0,0 +1,207 @@
+//
+// C++ Implementation: accountsetupitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "accountsetupitem.h"
+
+AccountSetupItem::AccountSetupItem( KListView* parent )
+ : KListViewItem( parent )
+{
+ init();
+
+}
+
+AccountSetupItem::AccountSetupItem( KListView * parent, QString & name )
+ : KListViewItem( parent )
+{
+ init();
+
+ //save account name
+ _account = name;
+
+ //set column text
+ setText( 0, getAccountName() );
+}
+
+AccountSetupItem::~AccountSetupItem()
+{
+}
+
+void AccountSetupItem::init( )
+{
+ //set default values
+ _account = DEFAULT_ACCOUNT_NAME;
+ _server = DEFAULT_ACCOUNT_SERVER;
+ _protocol = DEFAULT_ACCOUNT_PROTOCOL;
+ _port = DEFAULT_ACCOUNT_PORT_POP3;
+ _user = DEFAULT_ACCOUNT_USER;
+ _password = DEFAULT_ACCOUNT_PASSWORD;
+ _passwordStorage = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+ _active = DEFAULT_ACCOUNT_ACTIVE;
+ _transferSecurity = DEFAULT_ACCOUNT_SECTRANSFER;
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+}
+
+void AccountSetupItem::setAccountName( const QString & name )
+{
+ _account = name;
+}
+
+QString AccountSetupItem::getAccountName( ) const
+{
+ return _account;
+}
+
+void AccountSetupItem::setServer( const QString & server )
+{
+ _server = server;
+}
+
+QString AccountSetupItem::getServer( ) const
+{
+ return _server;
+}
+
+void AccountSetupItem::setProtocol( const QString & protocol )
+{
+ _protocol = protocol;
+}
+
+QString AccountSetupItem::getProtocol( ) const
+{
+ return _protocol;
+}
+
+void AccountSetupItem::setPort( int port )
+{
+ if( port >= 0 && port <= 65535 )
+ _port = port;
+ else
+ _port = DEFAULT_ACCOUNT_PORT_POP3;
+}
+
+int AccountSetupItem::getPort( ) const
+{
+ return _port;
+}
+
+void AccountSetupItem::setUser( const QString & user )
+{
+ _user = user;
+}
+
+QString AccountSetupItem::getUser( ) const
+{
+ return _user;
+}
+
+void AccountSetupItem::setPassword( const QString & password )
+{
+ _password = password;
+}
+
+QString AccountSetupItem::getPassword( ) const
+{
+ return _password;
+}
+
+void AccountSetupItem::setPasswordStorageType( int type )
+{
+ if( type == CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE || type == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE || type == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ _passwordStorage = type;
+ else
+ _passwordStorage = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+}
+
+int AccountSetupItem::getPasswordStorageType( ) const
+{
+ return _passwordStorage;
+}
+
+void AccountSetupItem::setActive( bool active )
+{
+ _active = active;
+}
+
+bool AccountSetupItem::getActive( ) const
+{
+ return _active;
+}
+
+void AccountSetupItem::save() const
+{
+ config->setGroup( getAccountName() );
+
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_NAME, getAccountName() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_SERVER, getServer() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PROTOCOL, getProtocol().upper() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PORT, getPort() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_USER, getUser() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, getPasswordStorageType() );
+
+ //save crypted password
+ KURL url;
+ url.setUser( getUser() );
+ url.setHost( getServer() );
+ url.setPass( getPassword() );
+
+ if( getPasswordStorageType() == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE )
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, crypt( url ) );
+ else
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, QString::null );
+
+ //save password in KWallet if desired
+ if( getPasswordStorageType() == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ KWalletAccess::savePassword( getAccountName(), getPassword() );
+
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, getActive() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, getTransferSecurity() );
+
+}
+
+void AccountSetupItem::load( )
+{
+ config->setGroup( getAccountName() );
+
+ _server = config->readEntry( CONFIG_ENTRY_ACCOUNT_SERVER, DEFAULT_ACCOUNT_SERVER );
+ _protocol = config->readEntry( CONFIG_ENTRY_ACCOUNT_PROTOCOL, DEFAULT_ACCOUNT_PROTOCOL );
+ _port = config->readNumEntry( CONFIG_ENTRY_ACCOUNT_PORT, DEFAULT_ACCOUNT_PORT_POP3 );
+ _user = config->readEntry( CONFIG_ENTRY_ACCOUNT_USER, DEFAULT_ACCOUNT_USER );
+ _passwordStorage = config->readNumEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+
+ if( _passwordStorage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE )
+ _password = decrypt( config->readEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, DEFAULT_ACCOUNT_PASSWORD ) );
+ else if( _passwordStorage == CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ _password = KWalletAccess::getPassword( getAccountName() );
+ else
+ _password = QString::null;
+
+ _active = config->readBoolEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, DEFAULT_ACCOUNT_ACTIVE );
+ _transferSecurity = config->readNumEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, DEFAULT_ACCOUNT_SECTRANSFER );
+}
+
+void AccountSetupItem::setTransferSecurity( int type )
+{
+ if( type == CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE || type == CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL || type == CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS )
+ _transferSecurity = type;
+ else
+ _transferSecurity = DEFAULT_ACCOUNT_SECTRANSFER;
+}
+
+int AccountSetupItem::getTransferSecurity( ) const
+{
+ return _transferSecurity;
+}
+
+
+
+
diff --git a/kshowmail/kcmconfigs/accountsetupitem.h b/kshowmail/kcmconfigs/accountsetupitem.h
new file mode 100644
index 0000000..fe85eee
--- /dev/null
+++ b/kshowmail/kcmconfigs/accountsetupitem.h
@@ -0,0 +1,242 @@
+//
+// C++ Interface: accountsetupitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef ACCOUNTSETUPITEM_H
+#define ACCOUNTSETUPITEM_H
+
+//KDE headers
+#include <klistview.h>
+#include <kconfig.h>
+#include <kurl.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include "../constants.h"
+#include "encryption.h"
+#include "kwalletaccess.h"
+
+using namespace Encryption;
+
+/**
+ * @brief This class is used in ConfigAccounts to show the available accounts in the list view and to store an account setup.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class AccountSetupItem : public KListViewItem
+{
+ public:
+
+ /**
+ * General Constructor
+ * @param parent the list view
+ */
+ AccountSetupItem( KListView* parent );
+
+ /**
+ * Constructor
+ * @param parent the list view
+ * @param name account name
+ */
+ AccountSetupItem( KListView* parent, QString& name );
+
+ /**
+ * Destructor
+ */
+ ~AccountSetupItem();
+
+ /**
+ * Sets account name
+ * @param name account name
+ */
+ void setAccountName( const QString& name );
+
+ /**
+ * Returns the account name.
+ * @return account name
+ */
+ QString getAccountName() const;
+
+ /**
+ * Sets the server.
+ * @param server server
+ */
+ void setServer( const QString& server );
+
+ /**
+ * Returns the server.
+ * @return server
+ */
+ QString getServer() const;
+
+ /**
+ * Sets the protocol.
+ * @param protocol protocol
+ */
+ void setProtocol( const QString& protocol );
+
+ /**
+ * Returns the protocol.
+ * @return protocol
+ */
+ QString getProtocol() const;
+
+ /**
+ * Sets the port number.
+ * @param port port number
+ */
+ void setPort( int port );
+
+ /**
+ * Returns the port number.
+ * @return port number (0..65535)
+ */
+ int getPort() const;
+
+ /**
+ * Sets the user name.
+ * @param user user name
+ */
+ void setUser( const QString& user );
+
+ /**
+ * Returns the user name.
+ * @return user name
+ */
+ QString getUser() const;
+
+ /**
+ * Sets the password.
+ * @param password password
+ */
+ void setPassword( const QString& password );
+
+ /**
+ * Returns the password.
+ * @return password
+ */
+ QString getPassword() const;
+
+ /**
+ * Sets the password storage type.
+ * See constants.h for valid values
+ * @param type password storage type (CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE or CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET)
+ */
+ void setPasswordStorageType( int type );
+
+ /**
+ * Returns the password storage type.
+ * See constants.h for valid values (CONFIG_VALUE_ACCOUNT_PASSWORD_...)
+ * @return storage type
+ */
+ int getPasswordStorageType() const;
+
+ /**
+ * Sets whether the account is active.
+ * @param active TRUE - account is active; FALSE - account is not active
+ */
+ void setActive( bool active );
+
+ /**
+ * Returns whether the account is active.
+ * @return TRUE - account is active
+ * @return FALSE - account is not active
+ */
+ bool getActive() const;
+
+ /**
+ * Sets the transfer security.
+ * See constants.h for valid values.
+ * @param type transfer security type (CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE, CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL, CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS)
+ */
+ void setTransferSecurity( int type );
+
+ /**
+ * Returns the transfer security.
+ * seee constants.h for valid values (CONFIG_VALUE_ACCOUNT_SECTRANSFER_...)
+ * @return transfer security
+ */
+ int getTransferSecurity() const;
+
+ /**
+ * Saves this account into applications config.
+ * All values are placed in a group called like the account name.
+ */
+ void save() const;
+
+ /**
+ * Loads the options of this account from the application config.
+ */
+ void load();
+
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Account name
+ */
+ QString _account;
+
+ /**
+ * Server
+ */
+ QString _server;
+
+ /**
+ * Protocol
+ */
+ QString _protocol;
+
+ /**
+ * Port
+ */
+ int _port;
+
+ /**
+ * User Name
+ */
+ QString _user;
+
+ /**
+ * Password
+ */
+ QString _password;
+
+ /**
+ * TRUE - account is active
+ */
+ bool _active;
+
+ /**
+ * password storage type
+ * Values are defined in constants.h (CONFIG_VALUE_ACCOUNT_PASSWORD_...)
+ */
+ int _passwordStorage;
+
+ /**
+ * transfer security
+ * Values are defined in constants.h (CONFIG_VALUE_ACCOUNT_SECTRANSFER_...)
+ */
+ int _transferSecurity;
+
+ protected:
+
+ /**
+ * Initializes the object.
+ */
+ void init();
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configaccounts.cpp b/kshowmail/kcmconfigs/configaccounts.cpp
new file mode 100644
index 0000000..3cb6d6c
--- /dev/null
+++ b/kshowmail/kcmconfigs/configaccounts.cpp
@@ -0,0 +1,203 @@
+//
+// C++ Implementation: configaccounts
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configaccounts.h"
+
+typedef KGenericFactory<ConfigAccounts, QWidget> ConfigAccountsFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfigaccounts, ConfigAccountsFactory(
+ "kcm_kshowmailconfigaccounts" ) );
+
+ConfigAccounts::ConfigAccounts( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigAccountsFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configaccounts" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QHBoxLayout* layMain = new QHBoxLayout( this, 0, 10 );
+
+ //account list view
+ AccountListView = new KListView( this, "AccountListView" );
+ AccountListView->addColumn( i18n( "Name" ) );
+ AccountListView->setColumnWidthMode( 0, QListView::Maximum );
+ AccountListView->setResizeMode( QListView::LastColumn );
+
+ layMain->addWidget( AccountListView );
+
+ //button layout
+ QVBoxLayout* layButtons = new QVBoxLayout( layMain );
+
+ //Buttons
+ btnAdd = new KPushButton( KStdGuiItem::add(), this, "btnAdd" );
+ layButtons->addWidget( btnAdd );
+ btnAdd->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ connect( btnAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
+
+ btnEdit = new KPushButton( KStdGuiItem::configure(), this, "btnEdit" );
+ layButtons->addWidget( btnEdit );
+ btnEdit->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ connect( btnEdit, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
+
+ btnRemove = new KPushButton( KStdGuiItem::remove(), this, "btnRemove" );
+ layButtons->addWidget( btnRemove );
+ btnRemove->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ connect( btnRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) );
+
+ layButtons->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configured values
+ load();
+
+}
+
+ConfigAccounts::~ConfigAccounts()
+{
+}
+
+void ConfigAccounts::load()
+{
+ //get list of account names
+ config->setGroup( CONFIG_GROUP_ACCOUNTS );
+ QStringList accounts = config->readListEntry( CONFIG_ENTRY_ACCOUNTS_LIST, QStringList() );
+
+ //create list view items and order accounts to load their config
+ for( QStringList::Iterator it = accounts.begin(); it != accounts.end(); ++it )
+ {
+ //create item
+ AccountSetupItem* item = new AccountSetupItem( AccountListView, *it );
+
+ //load item config
+ item->load();
+
+ }
+}
+
+void ConfigAccounts::save()
+{
+ config->setGroup( CONFIG_GROUP_ACCOUNTS );
+
+ //get old account list from config file to remove old account entries
+ QStringList oldList = config->readListEntry( CONFIG_ENTRY_ACCOUNTS_LIST, QStringList() );
+
+ //remove all account entries
+ for( QStringList::Iterator it = oldList.begin(); it != oldList.end(); ++it )
+ {
+ config->deleteGroup( *it );
+ }
+
+
+ //write a list with all account names into the config
+ QStringList accounts; //list of all account names
+ AccountSetupItem* item = NULL;
+ int index = 0;
+
+ do //get all account names
+ {
+ item = (AccountSetupItem*)( AccountListView->itemAtIndex( index ) );
+ if( item != NULL )
+ {
+ index++;
+ accounts.append( item->getAccountName() );
+ }
+ } while( item != NULL );
+
+ config->writeEntry( CONFIG_ENTRY_ACCOUNTS_LIST, accounts ); //write list of account names
+
+ //order the items to save their configuration
+ index = 0;
+ item = NULL;
+ do
+ {
+ item = (AccountSetupItem*)( AccountListView->itemAtIndex( index ) );
+ if( item != NULL )
+ {
+ index++;
+ item->save();
+ }
+ } while( item != NULL );
+
+ //write configuration to disk
+ config->sync();
+}
+
+void ConfigAccounts::defaults()
+{
+}
+
+void ConfigAccounts::slotChanged( )
+{
+ KCModule::changed();
+}
+
+void ConfigAccounts::slotAdd( )
+{
+ //open setup dialog
+ AccountSetupDialog* dlg = new AccountSetupDialog( this, AccountListView, NULL );
+ int res = dlg->exec();
+
+ //inform application setup dialog about changes
+ if( res == KDialogBase::Accepted )
+ slotChanged();
+
+ //delete dialog
+ delete dlg;
+}
+
+void ConfigAccounts::slotEdit( )
+{
+ //get selected item
+ AccountSetupItem* account = (AccountSetupItem*)( AccountListView->selectedItem() );
+
+ //test item
+ if( account == NULL )
+ return;
+
+ //open dialog
+ AccountSetupDialog* dlg = new AccountSetupDialog( this, AccountListView, account );
+ int res = dlg->exec();
+
+ //inform application setup dialog about changes
+ if( res == KDialogBase::Accepted )
+ slotChanged();
+
+ //delete dialog
+ delete dlg;
+}
+
+void ConfigAccounts::slotRemove( )
+{
+ //get selected item
+ AccountSetupItem* account = (AccountSetupItem*)( AccountListView->selectedItem() );
+
+ //test item
+ if( account == NULL )
+ return;
+
+ //remove item
+ int result = KMessageBox::questionYesNo( this, i18n( "Do you really want to remove account %1?").arg( account->getAccountName() ) );
+ if( result == KMessageBox::Yes )
+ {
+ delete account;
+ slotChanged();
+ }
+}
+
+
+#include "configaccounts.moc"
diff --git a/kshowmail/kcmconfigs/configaccounts.h b/kshowmail/kcmconfigs/configaccounts.h
new file mode 100644
index 0000000..e2f4e53
--- /dev/null
+++ b/kshowmail/kcmconfigs/configaccounts.h
@@ -0,0 +1,131 @@
+//
+// C++ Interface: configaccounts
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGACCOUNTS_H
+#define CONFIGACCOUNTS_H
+
+//Qt headers
+#include <qlayout.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <klistview.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#include <kmessagebox.h>
+
+//kshowmail headers
+#include "../constants.h"
+#include "accountsetupdialog.h"
+#include "accountsetupitem.h"
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the accounts.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigAccounts : public KCModule
+{
+Q_OBJECT
+
+ public:
+
+ /**
+ * Generic Constructor
+ */
+ ConfigAccounts( QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigAccounts();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Account List View
+ */
+ KListView* AccountListView;
+
+ /**
+ * Button to add a new account
+ */
+ KPushButton* btnAdd;
+
+ /**
+ * Button to edit an account
+ */
+ KPushButton* btnEdit;
+
+ /**
+ * Button to remove an account
+ */
+ KPushButton* btnRemove;
+
+ private slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+
+ /**
+ * Connected with button btnAdd.
+ * Opens the account setup dialog with an account item pointer of NULL.
+ * If the user has clicked OK, the dialog will create a new account item with
+ * the entered values and adds it to the list view.
+ */
+ void slotAdd();
+
+ /**
+ * Connected with button btnEdit.
+ * Opens the account setup with the selected account item.
+ */
+ void slotEdit();
+
+ /**
+ * Connected with button btnRemove.
+ * Removes the selected item.
+ */
+ void slotRemove();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configactions.cpp b/kshowmail/kcmconfigs/configactions.cpp
new file mode 100644
index 0000000..583d767
--- /dev/null
+++ b/kshowmail/kcmconfigs/configactions.cpp
@@ -0,0 +1,267 @@
+//
+// C++ Implementation: configactions
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configactions.h"
+
+typedef KGenericFactory<ConfigActions, QWidget> ConfigActionsFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfigactions, ConfigActionsFactory(
+ "kcm_kshowmailconfigactions" ) );
+
+ConfigActions::ConfigActions( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigActionsFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configactions" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //two boxes to seperate the action if new mail or if no new mail
+ QGroupBox* gboxNewMails = new QGroupBox( 0, Qt::Horizontal, i18n( "Action if new &mail" ), this, "gboxNewMails" );
+ QGroupBox* gboxNoNewMails = new QGroupBox( 2, Qt::Vertical, i18n( "Action if &no mail" ), this, "gboxNoNewMails" );
+ gboxNoNewMails->layout()->setSpacing( 20 );
+ layMain->addWidget( gboxNewMails );
+ layMain->addWidget( gboxNoNewMails );
+
+ //layouts for the upper group box
+ QVBoxLayout* layMainNewMails = new QVBoxLayout( gboxNewMails->layout(), 10 );
+ QGridLayout* layMainNewMailsTop = new QGridLayout( layMainNewMails, 2, 2, 10 );
+ QGridLayout* layMainNewMailsDown = new QGridLayout( layMainNewMails, 2, 4, 10 );
+
+ //items for the upper group box
+ chkNewMailsAlertWindow = new QCheckBox( i18n( "Show message box" ), gboxNewMails, "chkNewMailsAlertWindow" );
+ QToolTip::add( chkNewMailsAlertWindow, i18n( "Show message if new mail arrives" ) );
+ layMainNewMailsTop->addWidget( chkNewMailsAlertWindow, 0, 0 );
+
+ chkNewMailsMainWindow = new QCheckBox( i18n( "Show main window" ), gboxNewMails, "chkNewMailsMainWindow" );
+ QToolTip::add( chkNewMailsMainWindow, i18n( "Show main window if new mail arrives" ) );
+ layMainNewMailsTop->addWidget( chkNewMailsMainWindow, 0, 1 );
+
+ chkNewMailsBeep = new QCheckBox( i18n( "&Beep" ), gboxNewMails, "chkNewMailsBeep" );
+ QToolTip::add( chkNewMailsBeep, i18n( "Beeps the internal speaker if new mail" ) );
+ layMainNewMailsTop->addWidget( chkNewMailsBeep, 1, 0 );
+
+ chkNewMailsSound = new QCheckBox( i18n( "Sound:" ), gboxNewMails, "chkNewMailsSound" );
+ QToolTip::add( chkNewMailsSound, i18n( "Plays sound if new mail" ) );
+ layMainNewMailsDown->addWidget( chkNewMailsSound, 0, 0 );
+
+ btnNewMailsPlaySound = new KPushButton( KGuiItem( QString(), QString( "player_play" ), i18n( "Play the selected sound file" ), i18n( "Play the selected sound file" ) ), gboxNewMails, "btnNewMailsPlaySound" );
+ layMainNewMailsDown->addWidget( btnNewMailsPlaySound, 0, 1 );
+
+ txtNewMailsSound = new KLineEdit( gboxNewMails, "txtNewMailsSound" );
+ layMainNewMailsDown->addWidget( txtNewMailsSound, 0, 2 );
+
+ btnNewMailsChooseSound = new KPushButton( KGuiItem( QString(), QString( "folder" ), i18n( "Press to select sound file" ), i18n( "Press to select sound file" ) ), gboxNewMails, "btnNewMailsChooseSound" );
+ layMainNewMailsDown->addWidget( btnNewMailsChooseSound, 0, 3 );
+
+ chkNewMailsCommand = new QCheckBox( i18n( "Command:" ), gboxNewMails, "chkNewMailsCommand" );
+ QToolTip::add( chkNewMailsCommand, i18n( "Starts external program if new mail" ) );
+ layMainNewMailsDown->addWidget( chkNewMailsCommand, 1, 0 );
+
+ btnNewMailsExecCommand = new KPushButton( KGuiItem( QString(), QString( "exec" ), i18n( "Start the selected program" ), i18n( "Start the selected program" ) ), gboxNewMails, "btnNewMailsExecCommand" );
+ layMainNewMailsDown->addWidget( btnNewMailsExecCommand, 1, 1 );
+
+ txtNewMailsCommand = new KLineEdit( gboxNewMails, "txtNewMailsCommand" );
+ layMainNewMailsDown->addWidget( txtNewMailsCommand, 1, 2 );
+
+ btnNewMailsChooseCommand = new KPushButton( KGuiItem( QString(), QString( "folder" ), i18n( "Select external command" ), i18n( "Select external command" ) ), gboxNewMails, "btnNewMailsChooseCommand" );
+ layMainNewMailsDown->addWidget( btnNewMailsChooseCommand, 1, 3 );
+
+ //items for the lower group box
+ chkNoNewMailsMinimize = new QCheckBox( i18n( "Minimi&ze" ), gboxNoNewMails, "chkNoNewMailsMinimize" );
+ QToolTip::add( chkNoNewMailsMinimize, i18n( "Minimize window if no new mail" ) );
+
+ chkNoNewMailsTerminate = new QCheckBox( i18n( "Terminate" ), gboxNoNewMails, "chkNoNewMailsTerminate" );
+ QToolTip::add( chkNoNewMailsTerminate, i18n( "Terminate kshowmail if no new mail" ) );
+
+ //connect file choose buttons
+ connect( btnNewMailsChooseSound, SIGNAL( clicked() ), this, SLOT( slotChooseSound() ) );
+ connect( btnNewMailsChooseCommand, SIGNAL( clicked() ), this, SLOT( slotChooseCommand() ) );
+
+ //connect test buttons
+ connect( btnNewMailsPlaySound, SIGNAL( clicked() ), this, SLOT( slotPlaySound() ) );
+ connect( btnNewMailsExecCommand, SIGNAL( clicked() ), this, SLOT( slotExecuteCommand() ) );
+
+ //connect sound and command check boxes to enable or disable the configuration items
+ connect( chkNewMailsSound, SIGNAL( toggled( bool ) ), this, SLOT( slotSoundToggled( bool ) ) );
+ connect( chkNewMailsCommand, SIGNAL( toggled( bool ) ), this, SLOT( slotCommandToggled( bool ) ) );
+
+ //connect all configuration items with slot changed() to notify the dialog about changes
+ connect( chkNewMailsAlertWindow, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkNewMailsMainWindow, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkNewMailsBeep, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkNewMailsSound, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkNewMailsCommand, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( txtNewMailsSound, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotChanged() ) );
+ connect( txtNewMailsCommand, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotChanged() ) );
+ connect( chkNoNewMailsMinimize, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkNoNewMailsTerminate, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+
+
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configured values
+ load();
+
+}
+
+
+ConfigActions::~ConfigActions()
+{
+}
+
+void ConfigActions::load( )
+{
+ config->setGroup( CONFIG_GROUP_ACTIONS );
+
+ chkNewMailsAlertWindow->setChecked( config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_ALERTWINDOW, DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW ) );
+ chkNewMailsMainWindow->setChecked( config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_MAINWINDOW, DEFAULT_ACTION_NEW_MAIL_MAINWINDOW ) );
+ chkNewMailsBeep->setChecked( config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_BEEP, DEFAULT_ACTION_NEW_MAIL_BEEP ) );
+ chkNewMailsSound->setChecked( config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_SOUND, DEFAULT_ACTION_NEW_MAIL_SOUND ) );
+ chkNewMailsCommand->setChecked( config->readBoolEntry( CONFIG_ENTRY_NEW_MAIL_COMMAND, DEFAULT_ACTION_NEW_MAIL_COMMAND ) );
+ chkNoNewMailsTerminate->setChecked( config->readBoolEntry( CONFIG_ENTRY_NO_NEW_MAIL_TERMINATE, DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE ) );
+ chkNoNewMailsMinimize->setChecked( config->readBoolEntry( CONFIG_ENTRY_NO_NEW_MAIL_MINIMIZE, DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE ) );
+
+ txtNewMailsSound->setText( config->readEntry( CONFIG_ENTRY_NEW_MAIL_SOUNDPATH ) );
+ txtNewMailsCommand->setText( config->readEntry( CONFIG_ENTRY_NEW_MAIL_COMMANDPATH ) );
+
+ //enable or disable configuration items of sound and command
+ slotSoundToggled( chkNewMailsSound->isChecked() );
+ slotCommandToggled( chkNewMailsCommand->isChecked() );
+}
+
+void ConfigActions::defaults( )
+{
+ chkNewMailsAlertWindow->setChecked( DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW );
+ chkNewMailsMainWindow->setChecked( DEFAULT_ACTION_NEW_MAIL_MAINWINDOW );
+ chkNewMailsBeep->setChecked( DEFAULT_ACTION_NEW_MAIL_BEEP );
+ chkNewMailsSound->setChecked( DEFAULT_ACTION_NEW_MAIL_SOUND );
+ chkNewMailsCommand->setChecked( DEFAULT_ACTION_NEW_MAIL_COMMAND );
+ chkNoNewMailsTerminate->setChecked( DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE );
+ chkNoNewMailsMinimize->setChecked( DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE );
+
+ //enable or disable configuration items of sound and command
+ slotSoundToggled( chkNewMailsSound->isChecked() );
+ slotCommandToggled( chkNewMailsCommand->isChecked() );
+}
+
+void ConfigActions::save( )
+{
+ config->setGroup( CONFIG_GROUP_ACTIONS );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_ALERTWINDOW, chkNewMailsAlertWindow->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_MAINWINDOW, chkNewMailsMainWindow->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_BEEP, chkNewMailsBeep->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_SOUND, chkNewMailsSound->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_SOUNDPATH, txtNewMailsSound->text() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_COMMAND, chkNewMailsCommand->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NEW_MAIL_COMMANDPATH, txtNewMailsCommand->text() );
+ config->writeEntry( CONFIG_ENTRY_NO_NEW_MAIL_TERMINATE, chkNoNewMailsTerminate->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_NO_NEW_MAIL_MINIMIZE, chkNoNewMailsMinimize->isChecked() );
+
+ //write configuration to disk
+ config->sync();
+}
+
+void ConfigActions::slotChooseSound( )
+{
+ QString startPath; //start path of the file dialog
+
+ //get sounds directory of kshowmail
+ KStandardDirs stdDirs;
+ QString soundPath = stdDirs.findResource( "data", "kshowmail/sounds/" );
+
+ //get start path of the file dialog
+ if( txtNewMailsSound->text() != "" )
+ {
+ startPath = txtNewMailsSound->text();
+ }
+ else if( soundPath != QString::null )
+ {
+ startPath = soundPath;
+ }
+ else
+ {
+ startPath = QString::null;
+ }
+
+ //open file dialog
+ QString path = KFileDialog::getOpenFileName( startPath, "*.wav *.ogg|" + i18n( "Sound files (*.wav, *.ogg)" ) + "\n*.*|" + i18n( "All files (*)" ), this, i18n("Select Sound File") );
+
+ //write selected path into the edit line
+ if( path != QString::null )
+ txtNewMailsSound->setText( path );
+}
+
+void ConfigActions::slotChooseCommand( )
+{
+ //open file dialog
+ QString path = KFileDialog::getOpenFileName( QString::null, "", this, i18n("Select external command") );
+
+ //write selected path into the edit line
+ if( path != QString::null )
+ txtNewMailsCommand->setText( path );
+}
+
+void ConfigActions::slotPlaySound( )
+{
+ QString path = txtNewMailsSound->text();
+
+ if( path != QString::null )
+ KAudioPlayer::play( path );
+}
+
+void ConfigActions::slotExecuteCommand( )
+{
+ QString path = txtNewMailsCommand->text();
+
+ if( path != QString::null )
+ {
+ KShellProcess proc; //process handler to execute the binary
+
+ proc << path;
+
+ proc.start( KShellProcess::DontCare );
+ }
+}
+
+void ConfigActions::slotSoundToggled( bool on )
+{
+ btnNewMailsPlaySound->setEnabled( on );
+ txtNewMailsSound->setEnabled( on );
+ btnNewMailsChooseSound->setEnabled( on );
+}
+
+void ConfigActions::slotCommandToggled( bool on )
+{
+ btnNewMailsExecCommand->setEnabled( on );
+ txtNewMailsCommand->setEnabled( on );
+ btnNewMailsChooseCommand->setEnabled( on );
+}
+
+void ConfigActions::slotChanged( )
+{
+ KCModule::changed();
+}
+
+
+#include "configactions.moc"
+
+
+
+
+
diff --git a/kshowmail/kcmconfigs/configactions.h b/kshowmail/kcmconfigs/configactions.h
new file mode 100644
index 0000000..901984f
--- /dev/null
+++ b/kshowmail/kcmconfigs/configactions.h
@@ -0,0 +1,202 @@
+//
+// C++ Interface: configactions
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGACTIONS_H
+#define CONFIGACTIONS_H
+
+#include <string.h>
+
+//QT headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qtooltip.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kgenericfactory.h>
+#include <kpushbutton.h>
+#include <klineedit.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kfiledialog.h>
+#include <kaudioplayer.h>
+#include <kprocess.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+
+//kshowmail headers
+#include "../constants.h"
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the actions.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigActions : public KCModule
+{
+Q_OBJECT
+
+ public:
+ /**
+ * Generic Constructor
+ */
+ ConfigActions( QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigActions();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Check box to select whether an alert message will be shown if a new mail is arrived.
+ */
+ QCheckBox* chkNewMailsAlertWindow;
+
+ /**
+ * Check box to select whether the main window will be shown if a new mail is arrived.
+ */
+ QCheckBox* chkNewMailsMainWindow;
+
+ /**
+ * Check box to select whether the system beep will be played if a new mail is arrived.
+ */
+ QCheckBox* chkNewMailsBeep;
+
+ /**
+ * Check box to select whether a sound will be played if a new mail is arrived.
+ */
+ QCheckBox* chkNewMailsSound;
+
+ /**
+ * Check box to select whether a command will be executed if a new mail is arrived.
+ */
+ QCheckBox* chkNewMailsCommand;
+
+ /**
+ * Button to test the sound which will be played if a new mail is arrived.
+ */
+ KPushButton* btnNewMailsPlaySound;
+
+ /**
+ * Button to test the command which will be executed if a new mail is arrived.
+ */
+ KPushButton* btnNewMailsExecCommand;
+
+ /**
+ * Edit line which contains the path to the sound file which will be played if a new mail is arrived.
+ */
+ KLineEdit* txtNewMailsSound;
+
+ /**
+ * Edit line which contains the path to the command which will be executed if a new mail is arrived.
+ */
+ KLineEdit* txtNewMailsCommand;
+
+ /**
+ * Button to open a file dialog to choose the sound file which will be played if a new is arrived.
+ */
+ KPushButton* btnNewMailsChooseSound;
+
+ /**
+ * Button to open a file dialog to choose the command which will be executed if a new mail is arrived.
+ */
+ KPushButton* btnNewMailsChooseCommand;
+
+ /**
+ * Check box to select whether the main window will be minimized if no new mail is arrived.
+ */
+ QCheckBox* chkNoNewMailsMinimize;
+
+ /**
+ * Check box to select whether the application will be terminated if no new mail is arrived.
+ */
+ QCheckBox* chkNoNewMailsTerminate;
+
+ private slots:
+
+ /**
+ * Connected with button btnNewMailsChooseSound.
+ * Opens a file dialog to choose the sound file which will be played.
+ * Writes the chosen path into the edit line txtNewMailsSound.
+ */
+ void slotChooseSound();
+
+ /**
+ * Connected with button btnNewMailsChooseCommand.
+ * Opens a file dialog to choose the command which shall be executed.
+ * Writes the chosen path into the edit line txtNewMailsCommand.
+ */
+ void slotChooseCommand();
+
+ /**
+ * Connected with button btnNewMailsPlaySound.
+ * Plays the sound.
+ */
+ void slotPlaySound();
+
+ /**
+ * Connected with button btnNewMailsExecCommand.
+ * Executes the coommand.
+ */
+ void slotExecuteCommand();
+
+ /**
+ * Connected with check box chkNewMailsSound.
+ * Enable or disable the sound configuration items.
+ * @param on TRUE - box is checked; FALSE - box is not checked
+ */
+ void slotSoundToggled( bool on );
+
+ /**
+ * Connected with check box chkNewMailsCommand.
+ * Enable or disable the command configuration items.
+ * @param on TRUE - box is checked; FALSE - box is not checked
+ */
+ void slotCommandToggled( bool on );
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configdisplay.cpp b/kshowmail/kcmconfigs/configdisplay.cpp
new file mode 100644
index 0000000..e93027c
--- /dev/null
+++ b/kshowmail/kcmconfigs/configdisplay.cpp
@@ -0,0 +1,221 @@
+//
+// C++ Implementation: configdisplay
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configdisplay.h"
+
+typedef KGenericFactory<ConfigDisplay, QWidget> ConfigDisplayFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfigdisplay, ConfigDisplayFactory(
+ "kcm_kshowmailconfigdisplay" ) );
+
+ConfigDisplay::ConfigDisplay( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigDisplayFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configdisplay" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //group boxes
+ QGroupBox* gboxAccountlist = new QGroupBox( 0, Qt::Horizontal, i18n( "Account list" ), this, "gboxAccountlist" );
+ layMain->addWidget( gboxAccountlist );
+ QGroupBox* gboxMessagelist = new QGroupBox( 0, Qt::Horizontal, i18n( "Mail list" ), this, "gboxMessagelist" );
+ layMain->addWidget( gboxMessagelist );
+ QGroupBox* gboxMessageContent = new QGroupBox( 0, Qt::Horizontal, i18n( "Mail content" ), this, "gboxMessageContent" );
+ layMain->addWidget( gboxMessageContent );
+
+ //group box layouts
+ QGridLayout* layAccountlist = new QGridLayout( gboxAccountlist->layout(), 3, 2, 10 );
+ QGridLayout* layMessagelist = new QGridLayout( gboxMessagelist->layout(), 5, 2, 10 );
+ QGridLayout* layMessageContent = new QGridLayout( gboxMessageContent->layout(), 1, 1, 10 );
+
+ //create items
+ chkAccountlistActive = new QCheckBox( i18n( "Active" ), gboxAccountlist, "chkAccountlistActive" );
+ QToolTip::add( chkAccountlistActive, i18n( "To switch on/off the 'Active' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistActive, 0, 0 );
+
+ chkAccountlistAccount = new QCheckBox( i18n( "Account" ), gboxAccountlist, "chkAccountlistAccount" );
+ QToolTip::add( chkAccountlistAccount, i18n( "To switch on/off the 'Account' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistAccount, 0, 1 );
+
+ chkAccountlistServer = new QCheckBox( i18n( "Server" ), gboxAccountlist, "chkAccountlistServer" );
+ QToolTip::add( chkAccountlistServer, i18n( "To switch on/off the 'Server' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistServer, 1, 0 );
+
+ chkAccountlistUser = new QCheckBox( i18n( "User" ), gboxAccountlist, "chkAccountlistUser" );
+ QToolTip::add( chkAccountlistUser, i18n( "To switch on/off the 'User' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistUser, 1, 1 );
+
+ chkAccountlistMessages = new QCheckBox( i18n( "Messages" ), gboxAccountlist, "chkAccountlistMessages" );
+ QToolTip::add( chkAccountlistMessages, i18n( "To switch on/off the 'Messages' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistMessages, 2, 0 );
+
+ chkAccountlistSize = new QCheckBox( i18n( "Si&ze" ), gboxAccountlist, "chkAccountlistSize" );
+ QToolTip::add( chkAccountlistSize, i18n( "To switch on/off the 'Size' column in the account list" ) );
+ layAccountlist->addWidget( chkAccountlistSize, 2, 1 );
+
+ chkMessagelistNumber = new QCheckBox( i18n( "Number" ), gboxMessagelist, "chkMessagelistNumber" );
+ QToolTip::add( chkMessagelistNumber, i18n( "To switch on/off the 'Number' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistNumber, 0, 0 );
+
+ chkMessagelistAccount = new QCheckBox( i18n( "Account" ), gboxMessagelist, "chkMessagelistAccount" );
+ QToolTip::add( chkMessagelistAccount, i18n( "To switch on/off the 'Account' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistAccount, 0, 1 );
+
+ chkMessagelistFrom = new QCheckBox( i18n( "From" ), gboxMessagelist, "chkMessagelistFrom" );
+ QToolTip::add( chkMessagelistFrom, i18n( "To switch on/off the 'From' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistFrom, 1, 0 );
+
+ chkMessagelistTo = new QCheckBox( i18n( "To" ), gboxMessagelist, "chkMessagelistTo" );
+ QToolTip::add( chkMessagelistTo, i18n( "To switch on/off the 'To' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistTo, 1, 1 );
+
+ chkMessagelistSubject = new QCheckBox( i18n( "Su&bject" ), gboxMessagelist, "chkMessagelistSubject" );
+ QToolTip::add( chkMessagelistSubject, i18n( "To switch on/off the 'Subject' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistSubject, 2, 0 );
+
+ chkMessagelistDate = new QCheckBox( i18n( "Date" ), gboxMessagelist, "chkMessagelistDate" );
+ QToolTip::add( chkMessagelistDate, i18n( "To switch on/off the 'Date' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistDate, 2, 1 );
+
+ chkMessagelistSize = new QCheckBox( i18n( "Size" ), gboxMessagelist, "chkMessagelistSize" );
+ QToolTip::add( chkMessagelistSize, i18n( "To switch on/off the 'Size' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistSize, 3, 0 );
+
+ chkMessagelistContent = new QCheckBox( i18n( "Content" ), gboxMessagelist, "chkMessagelistContent" );
+ QToolTip::add( chkMessagelistContent, i18n( "To switch on/off the 'Content' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistContent, 3, 1 );
+
+ chkMessagelistState = new QCheckBox( i18n( "State" ), gboxMessagelist, "chkMessagelistState" );
+ QToolTip::add( chkMessagelistState, i18n( "To switch on/off the 'State' column in the message list" ) );
+ layMessagelist->addWidget( chkMessagelistState, 4, 0 );
+
+ chkAllowHTML = new QCheckBox( i18n( "Allow HTML" ), gboxMessageContent, "chkAllowHTML" );
+ QToolTip::add( chkAllowHTML, i18n( "To switch on/off HTML in the message view") );
+ layMessageContent->addWidget( chkAllowHTML, 0, 0 );
+
+ //connect all configuration itmes with slot changed() to notify the dialog about changes
+ connect( chkAccountlistActive, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAccountlistAccount, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAccountlistServer, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAccountlistUser, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAccountlistMessages, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAccountlistSize, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistNumber, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistAccount, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistFrom, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistTo, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistSubject, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistDate, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistSize, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistContent, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMessagelistState, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkAllowHTML, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configurated values
+ load();
+}
+
+ConfigDisplay::~ConfigDisplay()
+{
+}
+
+void ConfigDisplay::slotChanged( )
+{
+ KCModule::changed();
+}
+
+void ConfigDisplay::load( )
+{
+ config->setGroup( CONFIG_GROUP_ACCOUNT_LIST );
+ chkAccountlistActive->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_ACTIVE, DEFAULT_DISPLAY_ACCOUNT_ACTIVE ) );
+ chkAccountlistAccount->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_ACCOUNT, DEFAULT_DISPLAY_ACCOUNT_ACCOUNT ) );
+ chkAccountlistServer->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_SERVER, DEFAULT_DISPLAY_ACCOUNT_SERVER ) );
+ chkAccountlistUser->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_USER, DEFAULT_DISPLAY_ACCOUNT_USER ) );
+ chkAccountlistMessages->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_MESSAGES, DEFAULT_DISPLAY_ACCOUNT_MESSAGES ) );
+ chkAccountlistSize->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_SIZE, DEFAULT_DISPLAY_ACCOUNT_SIZE ) );
+
+ config->setGroup( CONFIG_GROUP_MESSAGE_LIST );
+ chkMessagelistNumber->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_NUMBER, DEFAULT_DISPLAY_MESSAGE_NUMBER ) );
+ chkMessagelistAccount->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_ACCOUNT, DEFAULT_DISPLAY_MESSAGE_ACCOUNT ) );
+ chkMessagelistFrom->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_FROM, DEFAULT_DISPLAY_MESSAGE_FROM ) );
+ chkMessagelistTo->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_TO, DEFAULT_DISPLAY_MESSAGE_TO ) );
+ chkMessagelistSubject->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_SUBJECT, DEFAULT_DISPLAY_MESSAGE_SUBJECT ) );
+ chkMessagelistDate->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_DATE, DEFAULT_DISPLAY_MESSAGE_DATE ) );
+ chkMessagelistSize->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_SIZE, DEFAULT_DISPLAY_MESSAGE_SIZE ) );
+ chkMessagelistContent->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_CONTENT, DEFAULT_DISPLAY_MESSAGE_CONTENT ) );
+ chkMessagelistState->setChecked( config->readBoolEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_STATE, DEFAULT_DISPLAY_MESSAGE_STATE ) );
+
+ config->setGroup( CONFIG_GROUP_VIEW );
+ chkAllowHTML->setChecked( config->readBoolEntry( CONFIG_ENTRY_VIEW_USE_HTML, DEFAULT_VIEW_USE_HTML ) );
+
+}
+
+void ConfigDisplay::save()
+{
+ config->setGroup( CONFIG_GROUP_ACCOUNT_LIST );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_ACTIVE, chkAccountlistActive->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_ACCOUNT, chkAccountlistAccount->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_SERVER, chkAccountlistServer->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_USER, chkAccountlistUser->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_MESSAGES, chkAccountlistMessages->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_ACCOUNT_SIZE, chkAccountlistSize->isChecked() );
+
+ config->setGroup( CONFIG_GROUP_MESSAGE_LIST );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_NUMBER, chkMessagelistNumber->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_ACCOUNT, chkMessagelistAccount->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_FROM, chkMessagelistFrom->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_TO, chkMessagelistTo->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_SUBJECT, chkMessagelistSubject->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_DATE, chkMessagelistDate->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_SIZE, chkMessagelistSize->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_CONTENT, chkMessagelistContent->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_DISPLAY_MESSAGE_STATE, chkMessagelistState->isChecked() );
+
+ config->setGroup( CONFIG_GROUP_VIEW );
+ config->writeEntry( CONFIG_ENTRY_VIEW_USE_HTML, chkAllowHTML->isChecked() );
+
+ //write configuration to disk
+ config->sync();
+}
+
+void ConfigDisplay::defaults()
+{
+ chkAccountlistActive->setChecked( DEFAULT_DISPLAY_ACCOUNT_ACTIVE );
+ chkAccountlistAccount->setChecked( DEFAULT_DISPLAY_ACCOUNT_ACCOUNT );
+ chkAccountlistServer->setChecked( DEFAULT_DISPLAY_ACCOUNT_SERVER );
+ chkAccountlistUser->setChecked( DEFAULT_DISPLAY_ACCOUNT_USER );
+ chkAccountlistMessages->setChecked( DEFAULT_DISPLAY_ACCOUNT_MESSAGES );
+ chkAccountlistSize->setChecked( DEFAULT_DISPLAY_ACCOUNT_SIZE );
+
+ chkMessagelistNumber->setChecked( DEFAULT_DISPLAY_MESSAGE_NUMBER );
+ chkMessagelistAccount->setChecked( DEFAULT_DISPLAY_MESSAGE_ACCOUNT );
+ chkMessagelistFrom->setChecked( DEFAULT_DISPLAY_MESSAGE_FROM );
+ chkMessagelistTo->setChecked( DEFAULT_DISPLAY_MESSAGE_TO );
+ chkMessagelistSubject->setChecked( DEFAULT_DISPLAY_MESSAGE_SUBJECT );
+ chkMessagelistDate->setChecked( DEFAULT_DISPLAY_MESSAGE_DATE );
+ chkMessagelistSize->setChecked( DEFAULT_DISPLAY_MESSAGE_SIZE );
+ chkMessagelistContent->setChecked( DEFAULT_DISPLAY_MESSAGE_CONTENT );
+ chkMessagelistState->setChecked( DEFAULT_DISPLAY_MESSAGE_STATE );
+
+ chkAllowHTML->setChecked( DEFAULT_VIEW_USE_HTML );
+
+}
+#include "configdisplay.moc"
diff --git a/kshowmail/kcmconfigs/configdisplay.h b/kshowmail/kcmconfigs/configdisplay.h
new file mode 100644
index 0000000..847b20b
--- /dev/null
+++ b/kshowmail/kcmconfigs/configdisplay.h
@@ -0,0 +1,169 @@
+//
+// C++ Interface: configdisplay
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGDISPLAY_H
+#define CONFIGDISPLAY_H
+
+//Qt headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include <../constants.h>
+
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the display.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigDisplay : public KCModule
+{
+Q_OBJECT
+
+ public:
+ /**
+ * Generic Constructor
+ */
+ ConfigDisplay( QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigDisplay();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Check box to switch on/off the "Active" column in the account list.
+ */
+ QCheckBox* chkAccountlistActive;
+
+ /**
+ * Check box to switch on/off the "Account" column in the account list.
+ */
+ QCheckBox* chkAccountlistAccount;
+
+ /**
+ * Check box to switch on/off the "Server" column in the account list.
+ */
+ QCheckBox* chkAccountlistServer;
+
+ /**
+ * Check box to switch on/off the "User" column in the account list.
+ */
+ QCheckBox* chkAccountlistUser;
+
+ /**
+ * Check box to switch on/off the "Messages" column in the account list.
+ */
+ QCheckBox* chkAccountlistMessages;
+
+ /**
+ * Check box to switch on/off the "Size" column in the account list.
+ */
+ QCheckBox* chkAccountlistSize;
+
+ /**
+ * Check box to switch on/off the "Number" column in the message list.
+ */
+ QCheckBox* chkMessagelistNumber;
+
+ /**
+ * Check box to switch on/off the "Account" column in the message list.
+ */
+ QCheckBox* chkMessagelistAccount;
+
+ /**
+ * Check box to switch on/off the "From" column in the message list.
+ */
+ QCheckBox* chkMessagelistFrom;
+
+ /**
+ * Check box to switch on/off the "To" column in the message list.
+ */
+ QCheckBox* chkMessagelistTo;
+
+ /**
+ * Check box to switch on/off the "Subject" column in the message list.
+ */
+ QCheckBox* chkMessagelistSubject;
+
+ /**
+ * Check box to switch on/off the "Date" column in the message list.
+ */
+ QCheckBox* chkMessagelistDate;
+
+ /**
+ * Check box to switch on/off the "Size" column in the message list.
+ */
+ QCheckBox* chkMessagelistSize;
+
+ /**
+ * Check box to switch on/off the "Content" column in the message list.
+ */
+ QCheckBox* chkMessagelistContent;
+
+ /**
+ * Check box to switch on/off the "State" column in the message list.
+ */
+ QCheckBox* chkMessagelistState;
+
+ /**
+ * Check box to switch on/off HTML in the message view.
+ */
+ QCheckBox* chkAllowHTML;
+
+ public slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configfilter.cpp b/kshowmail/kcmconfigs/configfilter.cpp
new file mode 100644
index 0000000..c999361
--- /dev/null
+++ b/kshowmail/kcmconfigs/configfilter.cpp
@@ -0,0 +1,613 @@
+//
+// C++ Implementation: configfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configfilter.h"
+
+typedef KGenericFactory<ConfigFilter, QWidget> ConfigFilterFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfigfilter, ConfigFilterFactory(
+ "kcm_kshowmailconfigfilter" ) );
+
+ConfigFilter::ConfigFilter( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigFilterFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configfilter" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //check box to activate the filter
+ chkActivateFilter = new QCheckBox( i18n( "Activate Filter" ), this, "chkActivateFilter" );
+ layMain->addWidget( chkActivateFilter );
+ QToolTip::add( chkActivateFilter, i18n( "Check to activate the header filter." ) );
+ connect( chkActivateFilter, SIGNAL( toggled( bool ) ), this, SLOT( slotFilterActiveToggled( bool ) ) );
+ connect( chkActivateFilter, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+
+ //GUI of sender lists
+ //-------------------
+ gboxSenderLists = new QGroupBox( 0, Qt::Horizontal, i18n( "First Check: Sender Lists" ), this, "gboxSenderLists" );
+ QHBoxLayout* laySender = new QHBoxLayout( gboxSenderLists->layout(), 10 );
+ layMain->addWidget( gboxSenderLists );
+
+ btnOpenWhitelist = new KPushButton( KGuiItem( QString( i18n( "Whitelist") ), QString( "mail_forward" ) ), gboxSenderLists, "btnOpenWhitelist" );
+ QToolTip::add( btnOpenWhitelist, i18n( "Click here to edit the list of senders whose mails shall pass the filter." ) );
+ laySender->addWidget( btnOpenWhitelist );
+ laySender->setStretchFactor( btnOpenWhitelist, 3 );
+ btnOpenWhitelist->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ connect( btnOpenWhitelist, SIGNAL( clicked() ), this, SLOT( slotOpenWhitelist() ) );
+
+ btnOpenBlacklist = new KPushButton( KGuiItem( QString( i18n( "Blacklist" ) ), QString( "mail_delete" ) ), gboxSenderLists, "btnOpenBlacklist" );
+ QToolTip::add( btnOpenBlacklist, i18n( "Click here to edit the list of senders whose mails shall be deleted or marked." ) );
+ laySender->addWidget( btnOpenBlacklist );
+ laySender->setStretchFactor( btnOpenBlacklist, 3 );
+ btnOpenBlacklist->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ connect( btnOpenBlacklist, SIGNAL( clicked() ), this, SLOT( slotOpenBlacklist() ) );
+
+ laySender->insertStretch( 0, 2 );
+ laySender->insertStretch( 2, 2 );
+ laySender->insertStretch( 4, 2 );
+
+ //GUI of filters
+ //--------------
+ gboxFilters = new QGroupBox( 0, Qt::Horizontal, i18n( "Second Check: Filters" ), this, "gboxFilters" );
+ QHBoxLayout* layFilters = new QHBoxLayout( gboxFilters->layout(), 10 );
+ layMain->addWidget( gboxFilters );
+
+ listFilters = new KListView( gboxFilters, "listFilters" );
+ listFilters->addColumn( i18n( "No." ) );
+ listFilters->addColumn( i18n( "Name" ) );
+ listFilters->addColumn( i18n( "Action" ) );
+ layFilters->addWidget( listFilters );
+ listFilters->setColumnWidthMode( 0, QListView::Maximum );
+ listFilters->setColumnWidthMode( 1, QListView::Maximum );
+ listFilters->setColumnWidthMode( 2, QListView::Maximum );
+ listFilters->setResizeMode( QListView::LastColumn );
+ listFilters->setColumnAlignment( 0, Qt::AlignHCenter );
+ listFilters->setSorting( 0 ); //the list is sorted by filter number
+ listFilters->setAllColumnsShowFocus( true );
+
+ QVBoxLayout* layFiltersButtons = new QVBoxLayout( layFilters, 10 );
+ btnAdd = new KPushButton( KStdGuiItem::add(), gboxFilters, "btnAdd" );
+ btnEdit = new KPushButton( KStdGuiItem::configure(), gboxFilters, "btnEdit" );
+ btnRemove = new KPushButton( KStdGuiItem::remove(), gboxFilters, "btnRemove" );
+ btnMoveTop = new KPushButton( KGuiItem( "", "top", i18n( "Moves the selected filter at the top" ) ), gboxFilters, "btnMoveTop" );
+ btnMoveUp = new KPushButton( KGuiItem( "", "up", i18n( "Moves the selected filter up" ) ), gboxFilters, "btnMoveUp" );
+ btnMoveDown = new KPushButton( KGuiItem( "", "down", i18n( "Moves the selected filter down" ) ), gboxFilters, "btnMoveDown" );
+ btnMoveBottom = new KPushButton( KGuiItem( "", "bottom", i18n( "Moves the selected filter at the bottm" ) ), gboxFilters, "btnMoveBottom" );
+ btnAdd->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnEdit->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnRemove->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnMoveTop->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnMoveUp->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnMoveDown->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ btnMoveBottom->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ layFiltersButtons->addWidget( btnAdd );
+ layFiltersButtons->addWidget( btnEdit );
+ layFiltersButtons->addWidget( btnRemove );
+ layFiltersButtons->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+ layFiltersButtons->addWidget( btnMoveTop );
+ layFiltersButtons->addWidget( btnMoveUp );
+ layFiltersButtons->addWidget( btnMoveDown );
+ layFiltersButtons->addWidget( btnMoveBottom );
+ connect( btnAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
+ connect( btnEdit, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
+ connect( btnRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) );
+ connect( btnMoveTop, SIGNAL( clicked() ), this, SLOT( slotMoveTop() ) );
+ connect( btnMoveBottom, SIGNAL( clicked() ), this, SLOT( slotMoveBottom() ) );
+ connect( btnMoveUp, SIGNAL( clicked() ), this, SLOT( slotMoveUp() ) );
+ connect( btnMoveDown, SIGNAL( clicked() ), this, SLOT( slotMoveDown() ) );
+
+
+ //GUI of Others
+ //-------------
+ gboxOthers = new QGroupBox( 0, Qt::Horizontal, i18n( "Third Check: Action for all others" ), this, "gboxOthers" );
+ QHBoxLayout* layOthers = new QHBoxLayout( gboxOthers->layout(), 10 );
+ layMain->addWidget( gboxOthers );
+
+ //create combobox to select action
+ cmbActionOthers = new KComboBox( gboxOthers, "cmbActionOthers" );
+ layOthers->addWidget( cmbActionOthers );
+ QToolTip::add( cmbActionOthers, i18n( "Choose the action for all mails which are not filtered by the steps before." ) );
+ connect( cmbActionOthers, SIGNAL( activated( int ) ), this, SLOT( slotOtherActionChanged( int ) ) );
+ connect( cmbActionOthers, SIGNAL( activated( int ) ), this, SLOT( slotChanged() ) );
+
+ //insert items
+ cmbActionOthers->insertItem( i18n( "Show" ), ID_COMBO_FILTER_OTHERS_ACTION_PASS );
+ cmbActionOthers->insertItem( i18n( "Delete" ), ID_COMBO_FILTER_OTHERS_ACTION_DELETE );
+ cmbActionOthers->insertItem( i18n( "Mark" ), ID_COMBO_FILTER_OTHERS_ACTION_MARK );
+ cmbActionOthers->insertItem( i18n( "Move" ), ID_COMBO_FILTER_OTHERS_ACTION_MOVE );
+ cmbActionOthers->insertItem( i18n( "Spamcheck" ), ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK );
+ cmbActionOthers->insertItem( i18n( "Ignore" ), ID_COMBO_FILTER_OTHERS_ACTION_IGNORE );
+
+ //create edit line to defined the mailbox for move
+ txtMailbox = new KLineEdit( gboxOthers );
+ layOthers->addWidget( txtMailbox );
+ connect( txtMailbox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotChanged() ) );
+
+ //create wizard button to configure mailbox
+ btnMailboxWizard= new KPushButton( KGuiItem( QString::null, "wizard" ), gboxOthers );
+ layOthers->addWidget( btnMailboxWizard );
+ QToolTip::add( btnMailboxWizard, i18n( "Choose the mailbox" ) );
+ connect( btnMailboxWizard, SIGNAL( clicked() ), this, SLOT( slotOpenMailBoxWizard() ) );
+
+ //set defaults
+ switch( DEFAULT_FILTER_OTHERS_ACTION )
+ {
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_IGNORE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK ); break;
+ }
+ chkActivateFilter->setChecked( DEFAULT_FILTER_ACTIVE );
+
+ //enable or disable widgets
+ slotOtherActionChanged( cmbActionOthers->currentItem() );
+ slotFilterActiveToggled( DEFAULT_FILTER_ACTIVE );
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //init counter for filter item numbering. This variable contains the last assigned number of a filter setup item.
+ //Because it is initialized with zero, the first filter number is 1.
+ lastFilterNumber = 0;
+
+ //load configured values
+ load();
+}
+
+
+ConfigFilter::~ConfigFilter()
+{
+}
+
+void ConfigFilter::load( )
+{
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //load filter active state
+ chkActivateFilter->setChecked( config->readBoolEntry( CONFIG_ENTRY_FILTER_ACTIVE, DEFAULT_FILTER_ACTIVE ) );
+ slotFilterActiveToggled( chkActivateFilter->isOn() );
+
+ //load other action
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, DEFAULT_FILTER_OTHERS_ACTION ) )
+ {
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_IGNORE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK ); break;
+ }
+
+ //get mailbox name
+ if( config->readNumEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, DEFAULT_FILTER_OTHERS_ACTION ) == CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE )
+ txtMailbox->setText( config->readEntry( CONFIG_ENTRY_FILTER_OTHERS_MAILBOX, DEFAULT_FILTER_ACTION_MOVE_MAILBOX ) );
+ else
+ txtMailbox->clear();
+
+ //enable or disable widgets for other action
+ slotOtherActionChanged( cmbActionOthers->currentItem() );
+
+ //get number of filters
+ uint numFilters = config->readNumEntry( CONFIG_ENTRY_FILTER_NUMBER_OF_FILTERS, 0 );
+
+ //create filter setup items and load theirs settings
+ for( uint ctr = 1; ctr <= numFilters; ctr++ )
+ {
+ //create filter item
+ FilterSetupItem* item = new FilterSetupItem( listFilters, ctr );
+
+ //load settings
+ item->load();
+ }
+
+ //set filter index counter
+ lastFilterNumber = numFilters;
+}
+
+void ConfigFilter::defaults( )
+{
+ switch( DEFAULT_FILTER_OTHERS_ACTION )
+ {
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_IGNORE ); break;
+ case CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK : cmbActionOthers->setCurrentItem( ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK ); break;
+ }
+
+ if( DEFAULT_FILTER_OTHERS_ACTION == CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE )
+ txtMailbox->setText( QString( DEFAULT_FILTER_ACTION_MOVE_MAILBOX ) );
+ else
+ txtMailbox->clear();
+
+ //enable or disable widgets for other action
+ slotOtherActionChanged( cmbActionOthers->currentItem() );
+
+ slotChanged();
+}
+
+void ConfigFilter::save( )
+{
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //save filter active state
+ config->writeEntry( CONFIG_ENTRY_FILTER_ACTIVE, chkActivateFilter->isOn() );
+
+ //save other action
+ switch( cmbActionOthers->currentItem() )
+ {
+ case ID_COMBO_FILTER_OTHERS_ACTION_PASS : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_PASS ); break;
+ case ID_COMBO_FILTER_OTHERS_ACTION_DELETE : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_DELETE ); break;
+ case ID_COMBO_FILTER_OTHERS_ACTION_MARK : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_MARK ); break;
+ case ID_COMBO_FILTER_OTHERS_ACTION_MOVE : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_MOVE ); break;
+ case ID_COMBO_FILTER_OTHERS_ACTION_IGNORE : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_IGNORE ); break;
+ case ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, CONFIG_VALUE_FILTER_OTHERS_ACTION_SPAMCHECK ); break;
+ default : config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_ACTION, DEFAULT_FILTER_OTHERS_ACTION ); break;
+ }
+
+ //save mailbox name
+ if( cmbActionOthers->currentItem() == ID_COMBO_FILTER_OTHERS_ACTION_MOVE )
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_OTHERS_MAILBOX, txtMailbox->text() );
+ }
+ else
+ {
+ config->deleteEntry( CONFIG_ENTRY_FILTER_OTHERS_MAILBOX );
+ }
+
+ //get old number of filters
+ uint oldNumFilter = config->readNumEntry( CONFIG_ENTRY_FILTER_NUMBER_OF_FILTERS, 0 );
+
+ //save current number of filters
+ config->writeEntry( CONFIG_ENTRY_FILTER_NUMBER_OF_FILTERS, lastFilterNumber );
+
+ //delete surplus filter configurations
+ if( oldNumFilter > lastFilterNumber )
+ {
+ for( uint ctr = lastFilterNumber + 1; ctr <= oldNumFilter; ctr++ )
+ {
+ config->deleteGroup( QString( "%1%2" ).arg( CONFIG_GROUP_FILTER ).arg( ctr ) );
+ }
+ }
+
+ //save the filters
+ QListViewItemIterator it( listFilters );
+
+ while( it.current() )
+ {
+ ( (FilterSetupItem*)it.current() )->save();
+
+ //get next item
+ ++it;
+ }
+
+
+ config->sync();
+}
+
+void ConfigFilter::slotChanged( )
+{
+ KCModule::changed();
+}
+
+void ConfigFilter::slotOpenWhitelist( )
+{
+ //open list dialog
+ SenderListDialog* dlg = new SenderListDialog( this, SenderListDialog::White, "dlgWhiteList" );
+ dlg->exec();
+
+ //delete dialog
+ delete dlg;
+}
+
+void ConfigFilter::slotOpenBlacklist( )
+{
+ //open list dialog
+ SenderListDialog* dlg = new SenderListDialog( this, SenderListDialog::Black, "dlgBlackList" );
+ dlg->exec();
+
+ //delete dialog
+ delete dlg;
+}
+
+void ConfigFilter::slotAdd( )
+{
+ //create a new filter setup item
+ FilterSetupItem* item = new FilterSetupItem( listFilters , lastFilterNumber + 1 );
+
+ //open setup dialog
+ FilterSetupDialog* dlg = new FilterSetupDialog( this, item );
+ int res = dlg->exec();
+
+ if( res == KDialogBase::Accepted )
+ {
+ //inform application setup dialog about changes
+ slotChanged();
+
+ //increase variable for the last assigned filter number
+ lastFilterNumber++;
+ }
+ else
+ //delete new item because the user don't want it
+ delete item;
+
+ //delete dialog
+ delete dlg;
+}
+
+void ConfigFilter::slotEdit( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ //return if no item selected
+ if( item == NULL ) return;
+
+ //open setup dialog
+ FilterSetupDialog* dlg = new FilterSetupDialog( this, item );
+ int res = dlg->exec();
+
+ //inform application setup dialog about changes
+ if( res == KDialogBase::Accepted )
+ slotChanged();
+
+ //delete dialog
+ delete dlg;
+
+}
+
+void ConfigFilter::slotRemove( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ if( item != NULL )
+ {
+ //get number of the item
+ uint num = item->getNumber();
+
+ //delete item
+ delete item;
+
+ //decrease the number of all filter items after the removed one
+ decreaseNumbers( num + 1 );
+
+ //decrease last assigned number
+ lastFilterNumber--;
+
+ //inform application setup dialog about changes
+ slotChanged();
+ }
+}
+
+void ConfigFilter::slotOtherActionChanged( int index )
+{
+ switch( index )
+ {
+ case ID_COMBO_FILTER_OTHERS_ACTION_MOVE : txtMailbox->setEnabled( true );
+ if( txtMailbox->text() == "" ) txtMailbox->setText( DEFAULT_FILTER_ACTION_MOVE_MAILBOX );
+ btnMailboxWizard->setHidden( false );
+ break;
+ default : txtMailbox->setEnabled( false );
+ btnMailboxWizard->setHidden( true );
+ break;
+ }
+}
+
+void ConfigFilter::decreaseNumbers( uint number )
+{
+ //get an iterator of the list view
+ QListViewItemIterator it( listFilters );
+
+ //iterate over the filter list
+ while( it.current() )
+ {
+ //get number of current filter item
+ uint curNumber = ( (FilterSetupItem*)it.current() )->getNumber();
+
+ //decrease current number, if the given number is lesser or equals
+ if( curNumber >= number && curNumber > 0 )
+ ( (FilterSetupItem*)it.current() )->setNumber( curNumber - 1 );
+
+ //get next item
+ ++it;
+ }
+}
+
+void ConfigFilter::slotMoveTop( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ if( item != NULL )
+ {
+ //get number of the item
+ uint num = item->getNumber();
+
+ if( num > 1 )
+ {
+ //set number of the selected to zero, this will move it at the top
+ item->setNumber( 0 );
+
+ //now we move all items after the old position one step up
+ decreaseNumbers( num + 1 );
+
+ //at last we add one to all numbers
+ QListViewItemIterator it( listFilters );
+
+ while( it.current() )
+ {
+ uint curNumber = ( (FilterSetupItem*)it.current() )->getNumber();
+ ( (FilterSetupItem*)it.current() )->setNumber( curNumber + 1 );
+
+ ++it;
+ }
+
+ //refresh list view
+ listFilters->sort();
+
+ //inform application setup dialog about changes
+ slotChanged();
+
+ }
+ }
+
+
+}
+
+void ConfigFilter::slotMoveBottom( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ if( item != NULL )
+ {
+ //get number of the item
+ uint num = item->getNumber();
+
+ if( num < lastFilterNumber )
+ {
+ //move the selected item at the bottom
+ item->setNumber( lastFilterNumber + 1 );
+
+ //move all items after the old position one step up (decrease number)
+ decreaseNumbers( num + 1 );
+
+ //refresh list view
+ listFilters->sort();
+
+ //inform application setup dialog about changes
+ slotChanged();
+ }
+
+ }
+}
+
+void ConfigFilter::slotMoveUp( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ if( item != NULL )
+ {
+ //get number of the item
+ uint num = item->getNumber();
+
+ if( num > 1 )
+ {
+ //get item before the selected one
+ FilterSetupItem* itemBefore = getFilterItem( num - 1 );
+
+ if( itemBefore != NULL )
+ {
+ //swap numbers
+ item->setNumber( num - 1 );
+ itemBefore->setNumber( num );
+
+ //inform application setup dialog about changes
+ slotChanged();
+
+ }
+ }
+ //refresh list view
+ listFilters->sort();
+ }
+}
+
+void ConfigFilter::slotMoveDown( )
+{
+ //get selected item
+ FilterSetupItem* item = (FilterSetupItem*)listFilters->selectedItem();
+
+ if( item != NULL )
+ {
+ //get number of the item
+ uint num = item->getNumber();
+
+ if( num < lastFilterNumber )
+ {
+ //get item behind the selected one
+ FilterSetupItem* itemBehind = getFilterItem( num + 1 );
+
+ if( itemBehind != NULL )
+ {
+ //swap numbers
+ item->setNumber( num + 1 );
+ itemBehind->setNumber( num );
+
+ //inform application setup dialog about changes
+ slotChanged();
+
+ }
+ }
+ //refresh list view
+ listFilters->sort();
+ }
+}
+
+FilterSetupItem* ConfigFilter::getFilterItem( uint num )
+{
+ FilterSetupItem* foundItem = NULL;
+ bool found = false;
+
+ //get Iterator
+ QListViewItemIterator it( listFilters );
+
+ //iterate over th elist to look for the item
+ while( it.current() && !found )
+ {
+ //get current number
+ uint curNumber = ( (FilterSetupItem*)it.current() )->getNumber();
+
+ //have we found it?
+ if( curNumber == num )
+ {
+ foundItem = (FilterSetupItem*)it.current();
+
+ found = true;
+ }
+
+ ++it;
+ }
+
+ return foundItem;
+}
+
+void ConfigFilter::slotFilterActiveToggled( bool filterOn )
+{
+ gboxSenderLists->setEnabled( filterOn );
+ gboxFilters->setEnabled( filterOn );
+ gboxOthers->setEnabled( filterOn );
+}
+
+void ConfigFilter::slotOpenMailBoxWizard( )
+{
+ MailBoxWizard wizard( this, "malboxwizard" );
+ wizard.setCaption( i18n( "Mailbox Select" ) );
+ int res = wizard.exec();
+
+ if( res == QDialog::Accepted )
+ txtMailbox->setText( wizard.getPath() );
+
+}
+
+
+
+#include "configfilter.moc"
diff --git a/kshowmail/kcmconfigs/configfilter.h b/kshowmail/kcmconfigs/configfilter.h
new file mode 100644
index 0000000..9d37c82
--- /dev/null
+++ b/kshowmail/kcmconfigs/configfilter.h
@@ -0,0 +1,288 @@
+//
+// C++ Interface: configfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGFILTER_H
+#define CONFIGFILTER_H
+
+//QT headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qtooltip.h>
+#include <qcheckbox.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+#include <klistview.h>
+#include <kpushbutton.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+
+//Kshowmail headers
+#include "../constants.h"
+#include "senderlistdialog.h"
+#include "filtersetupdialog.h"
+#include "mailboxwizard.h"
+
+//radio button IDs
+#define ID_COMBO_FILTER_OTHERS_ACTION_PASS 0
+#define ID_COMBO_FILTER_OTHERS_ACTION_DELETE 1
+#define ID_COMBO_FILTER_OTHERS_ACTION_MARK 2
+#define ID_COMBO_FILTER_OTHERS_ACTION_MOVE 3
+#define ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK 4
+#define ID_COMBO_FILTER_OTHERS_ACTION_IGNORE 5
+
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the filter.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigFilter : public KCModule
+{
+Q_OBJECT
+
+ public:
+
+ /**
+ * Generic constructor
+ */
+ ConfigFilter( QWidget* parent = 0, const char* name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigFilter();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Check box to activate the filter
+ */
+ QCheckBox* chkActivateFilter;
+
+ /**
+ * Group box for sender lists.
+ */
+ QGroupBox* gboxSenderLists;
+
+ /**
+ * Group box for filter items.
+ */
+ QGroupBox* gboxFilters;
+
+ /**
+ * Group box for other action.
+ */
+ QGroupBox* gboxOthers;
+
+ /**
+ * Button to open the Blacklist.
+ */
+ KPushButton* btnOpenBlacklist;
+
+ /**
+ * Button to open the Whitelist.
+ */
+ KPushButton* btnOpenWhitelist;
+
+ /**
+ * List of filters
+ */
+ KListView* listFilters;
+
+ /**
+ * Button to move a filter at top.
+ */
+ KPushButton* btnMoveTop;
+
+ /**
+ * Button to move a filter at bottom.
+ */
+ KPushButton* btnMoveBottom;
+
+ /**
+ * Button to move a filter up.
+ */
+ KPushButton* btnMoveUp;
+
+ /**
+ * Button to move a filter down.
+ */
+ KPushButton* btnMoveDown;
+
+ /**
+ * Button to add a new filter.
+ */
+ KPushButton* btnAdd;
+
+ /**
+ * Button to edit a filter.
+ */
+ KPushButton* btnEdit;
+
+ /**
+ * Button to remove a filter.
+ */
+ KPushButton* btnRemove;
+
+ /**
+ * Combobox to select the action for the rest of mails.
+ */
+ KComboBox* cmbActionOthers;
+
+ /**
+ * If selected, the other mails will be moved to the mailbox which is written in this edit line.
+ */
+ KLineEdit* txtMailbox;
+
+ /**
+ * This button opens a wizard which will help to get the right mailbox
+ */
+ KPushButton* btnMailboxWizard;
+
+ /**
+ * The last assigned number of a filter setup item.
+ * It is set to zero by the constructor. Therefore the first filter number is 1.
+ */
+ uint lastFilterNumber;
+
+ private slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+
+ /**
+ * Connected with the button btnOpenWhitelist.
+ * Creates and opens a dialog to edit the whitelist.
+ */
+ void slotOpenWhitelist();
+
+ /**
+ * Connected with the button btnOpenBlacklist.
+ * Creates and opens a dialog to edit the blacklist.
+ */
+ void slotOpenBlacklist();
+
+ /**
+ * Connected with button btnAdd.
+ * Opens the account setup dialog with an account item pointer of NULL.
+ * If the user has clicked OK, the dialog will create a new account item with
+ * the entered values and adds it to the list view.
+ */
+ void slotAdd();
+
+ /**
+ * Connected with button btnEdit.
+ * Opens the account setup with the selected account item.
+ */
+ void slotEdit();
+
+ /**
+ * Connected with button btnRemove.
+ * Removes the selected item.
+ */
+ void slotRemove();
+
+ /**
+ * Connected with combobox cmbActionOthers.
+ * Enables or disables additional widgets for action configuration.
+ * @param index position (index) of the selected action
+ */
+ void slotOtherActionChanged( int index );
+
+ /**
+ * Connected with button btnMoveTop.
+ * Moves the selected filter item at the top of the list, i.e. the number of this item will be the least one.
+ */
+ void slotMoveTop();
+
+ /**
+ * Connected with button btnMoveBottom.
+ * Moves the selected filter item at the bottom of the list, i.e. the number of this item will be the greatest one.
+ */
+ void slotMoveBottom();
+
+ /**
+ * Connected with button btnMoveUp.
+ * Moves the selected filter item up, i.e. the number of this item will be decreased.
+ */
+ void slotMoveUp();
+
+ /**
+ * Connected with button btnMoveDown.
+ * Moves the selected filter item down, i.e. the number of this item will be increased.
+ */
+ void slotMoveDown();
+
+ /**
+ * Connected with chkActivateFilter, signal toggled().
+ * Enabled or disabled the other widget of this GUI.
+ * @param filterOn TRUE - filter is active; FALSE - filter is not active
+ */
+ void slotFilterActiveToggled( bool filterOn );
+
+ /**
+ * Connected with button btnMailboxWizard.
+ * Opens a wizard to configure the mailbox
+ */
+ void slotOpenMailBoxWizard();
+
+
+ protected:
+
+ /**
+ * Decrease the numbers of these filter setup items whose number is greater than or equals num.
+ * @param number start number of renumbering
+ */
+ void decreaseNumbers( uint number );
+
+ /**
+ * Returns the pointer to the filter setup item with number num. Returns 0 if no item found.
+ * @param num number of the searched filter item
+ * @return pointer to the found item
+ */
+ FilterSetupItem* getFilterItem( uint num );
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configgeneral.cpp b/kshowmail/kcmconfigs/configgeneral.cpp
new file mode 100644
index 0000000..0bffeca
--- /dev/null
+++ b/kshowmail/kcmconfigs/configgeneral.cpp
@@ -0,0 +1,181 @@
+//
+// C++ Implementation: configgeneral
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configgeneral.h"
+
+typedef KGenericFactory<ConfigGeneral, QWidget> ConfigGeneralFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfiggeneral, ConfigGeneralFactory(
+ "kcm_kshowmailconfiggeneral" ) );
+
+ConfigGeneral::ConfigGeneral( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigGeneralFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configgeneral" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //layout for check buttons (upper half)
+ QGridLayout* layMainTop = new QGridLayout( layMain, 4, 2, 15 );
+ layMainTop->setMargin( 20 );
+
+ //group box for timers
+ QGroupBox* gboxTimers = new QGroupBox( 0, Qt::Horizontal, i18n( "&Timers" ), this, "gboxTimers" );
+ layMain->addWidget( gboxTimers );
+
+ //layouts for timers
+ QGridLayout* layTimers = new QGridLayout( gboxTimers->layout(),3, 3, 20 );
+
+ //create items
+ chkConfirmClose = new QCheckBox( i18n( "Confirm Close" ), this, "chkConfirmClose" );
+ QToolTip::add( chkConfirmClose, i18n( "If checked, window close must be confirmed" ) );
+ layMainTop->addWidget( chkConfirmClose, 0, 0 );
+
+ chkConfirmDelete = new QCheckBox( i18n( "Confirm delete" ), this, "chkConfirmDelete" );
+ QToolTip::add( chkConfirmDelete, i18n( "If checked, message delete must be confirmed" ) );
+ layMainTop->addWidget( chkConfirmDelete, 0, 1 );
+
+ chkStartMinimized = new QCheckBox( i18n( "Start Minimi&zed" ), this, "chkStartMinimized" );
+ QToolTip::add( chkStartMinimized, i18n( "Application is started as icon" ) );
+ layMainTop->addWidget( chkStartMinimized, 1, 0 );
+
+ chkCloseToTray = new QCheckBox( i18n( "Close to tray" ), this, "chkCloseToTray" );
+ QToolTip::add( chkCloseToTray, i18n( "Close button leaves the application running in tray" ) );
+ layMainTop->addWidget( chkCloseToTray, 1, 1 );
+
+ chkMinimizeToTray = new QCheckBox( i18n( "Minimize to tray" ), this, "chkMinimizeToTray" );
+ QToolTip::add( chkMinimizeToTray, i18n( "Minimizes to the tray rather than to the taskbar" ) );
+ layMainTop->addWidget( chkMinimizeToTray, 2, 0 );
+
+ chkShowConnectionErrors = new QCheckBox( i18n( "Show Connection Errors during refresh" ), this, "chkShowConnectionErrors" );
+ QToolTip::add( chkShowConnectionErrors, i18n( "If a connection error occurs during refresh (e.g. unknown server), an error message will be shown. During other actions, this error always will be shown" ) );
+ layMainTop->addWidget( chkShowConnectionErrors, 2, 1 );
+
+ chkKeepNew = new QCheckBox( i18n( "&Keep mail as new" ), this, "chkKeepNew" );
+ QToolTip::add( chkKeepNew, i18n( "Keep mail as new until termination" ) );
+ layMainTop->addWidget( chkKeepNew, 3, 0 );
+
+ QLabel* lblTimerInitial = new QLabel( i18n( "Initial Timer:" ), gboxTimers, "lblTimerInitial" );
+ QLabel* lblInitialUnit = new QLabel( i18n( "[Seconds]" ), gboxTimers, "lblInitialUnit" );
+ spbInitial = new QSpinBox( 0, 99999, 1, gboxTimers, "spbInitial" );
+ QToolTip::add( spbInitial, i18n( "Seconds until first automatic logon (0 = no automatic)" ) );
+ QToolTip::add( lblTimerInitial, i18n( "Seconds until first automatic logon (0 = no automatic)" ) );
+ layTimers->addWidget( lblTimerInitial, 0, 0 );
+ layTimers->addWidget( spbInitial, 0, 1 );
+ layTimers->addWidget( lblInitialUnit, 0, 2 );
+
+ QLabel* lblTimerInterval = new QLabel( i18n( "Interval Timer:" ), gboxTimers, "lblTimerInterval" );
+ QLabel* lblIntervalUnit = new QLabel( i18n( "[Minutes]" ), gboxTimers, "lblIntervalUnit" );
+ spbInterval = new QSpinBox( 0, 99999, 1, gboxTimers, "spbInterval" );
+ QToolTip::add( spbInterval, i18n( "Minutes between automatic logon (0 = no automatic)" ) );
+ QToolTip::add( lblTimerInterval, i18n( "Minutes between automatic logon (0 = no automatic)" ) );
+ layTimers->addWidget( lblTimerInterval, 1, 0 );
+ layTimers->addWidget( spbInterval, 1, 1 );
+ layTimers->addWidget( lblIntervalUnit, 1, 2 );
+
+ QLabel* lblTimerTimeout = new QLabel( i18n( "Timeout:" ), gboxTimers, "lblTimerTimeout" );
+ QLabel* lblTimeoutUnit = new QLabel( i18n( "[Seconds]" ), gboxTimers, "lblTimeoutUnit" );
+ spbTimeout = new QSpinBox( MINIMUM_TIMEOUT_TIME, 99999, 1, gboxTimers, "spbTimeout" );
+ QToolTip::add( spbTimeout, i18n( "Seconds until a server connect will be canceled" ) );
+ QToolTip::add( lblTimerTimeout, i18n( "Seconds until a server connect will be canceled" ) );
+ layTimers->addWidget( lblTimerTimeout, 2, 0 );
+ layTimers->addWidget( spbTimeout, 2, 1 );
+ layTimers->addWidget( lblTimeoutUnit, 2, 2 );
+
+
+ //connect all configuration itmes with slot changed() to notify the dialog about changes
+ connect( chkConfirmClose, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkConfirmDelete, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkStartMinimized, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkCloseToTray, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkMinimizeToTray, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkShowConnectionErrors, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkKeepNew, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( spbInitial, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
+ connect( spbInterval, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
+ connect( spbTimeout, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
+
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configurated values
+ load();
+
+}
+
+ConfigGeneral::~ConfigGeneral()
+{
+}
+
+void ConfigGeneral::load( )
+{
+ config->setGroup( CONFIG_GROUP_GENERAL );
+
+ chkConfirmClose->setChecked( config->readBoolEntry( CONFIG_ENTRY_CONFIRM_CLOSE, DEFAULT_CONFIRM_CLOSE ) );
+ chkConfirmDelete->setChecked( config->readBoolEntry( CONFIG_ENTRY_CONFIRM_DELETE, DEFAULT_CONFIRM_DELETE ) );
+ chkStartMinimized->setChecked( config->readBoolEntry( CONFIG_ENTRY_START_MINIMIZED, DEFAULT_START_MINIMIZED ) );
+ chkCloseToTray->setChecked( config->readBoolEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, DEFAULT_CLOSE_TO_TRAY ) );
+ chkMinimizeToTray->setChecked( config->readBoolEntry( CONFIG_ENTRY_MINIMIZE_TO_TRAY, DEFAULT_MINIMIZE_TO_TRAY ) );
+ chkShowConnectionErrors->setChecked( config->readBoolEntry( CONFIG_ENTRY_SHOW_CONNECTION_ERRORS, DEFAULT_SHOW_CONNECTION_ERRORS ) );
+ chkKeepNew->setChecked( config->readBoolEntry( CONFIG_ENTRY_KEEP_NEW, DEFAULT_KEEP_NEW ) );
+
+ spbInitial->setValue( config->readNumEntry( CONFIG_ENTRY_INITIAL_TIME, DEFAULT_INITIAL_TIME ) );
+ spbInterval->setValue( config->readNumEntry( CONFIG_ENTRY_INTERVAL_TIME, DEFAULT_INTERVAL_TIME) );
+ spbTimeout->setValue( config->readNumEntry( CONFIG_ENTRY_TIMEOUT_TIME, DEFAULT_TIMEOUT_TIME) );
+}
+
+void ConfigGeneral::defaults( )
+{
+ chkConfirmClose->setChecked( DEFAULT_CONFIRM_CLOSE );
+ chkConfirmDelete->setChecked( DEFAULT_CONFIRM_DELETE );
+ chkStartMinimized->setChecked( DEFAULT_START_MINIMIZED );
+ chkCloseToTray->setChecked( DEFAULT_CLOSE_TO_TRAY );
+ chkMinimizeToTray->setChecked( DEFAULT_MINIMIZE_TO_TRAY );
+ chkShowConnectionErrors->setChecked( DEFAULT_SHOW_CONNECTION_ERRORS );
+ chkKeepNew->setChecked( DEFAULT_KEEP_NEW );
+
+ spbInitial->setValue( DEFAULT_INITIAL_TIME );
+ spbInterval->setValue( DEFAULT_INTERVAL_TIME );
+ spbTimeout->setValue( DEFAULT_TIMEOUT_TIME );
+}
+
+void ConfigGeneral::save( )
+{
+ config->setGroup( CONFIG_GROUP_GENERAL );
+
+ config->writeEntry( CONFIG_ENTRY_CONFIRM_CLOSE, chkConfirmClose->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_CONFIRM_DELETE, chkConfirmDelete->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_START_MINIMIZED, chkStartMinimized->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, chkCloseToTray->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_MINIMIZE_TO_TRAY, chkMinimizeToTray->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_SHOW_CONNECTION_ERRORS, chkShowConnectionErrors->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_KEEP_NEW, chkKeepNew->isChecked() );
+ config->writeEntry( CONFIG_ENTRY_INITIAL_TIME, spbInitial->value() );
+ config->writeEntry( CONFIG_ENTRY_INTERVAL_TIME, spbInterval->value() );
+ config->writeEntry( CONFIG_ENTRY_TIMEOUT_TIME, spbTimeout->value() );
+
+ //write configuration to disk
+ config->sync();
+}
+
+void ConfigGeneral::slotChanged( )
+{
+ KCModule::changed();
+}
+
+#include "configgeneral.moc"
diff --git a/kshowmail/kcmconfigs/configgeneral.h b/kshowmail/kcmconfigs/configgeneral.h
new file mode 100644
index 0000000..c61ef67
--- /dev/null
+++ b/kshowmail/kcmconfigs/configgeneral.h
@@ -0,0 +1,141 @@
+//
+// C++ Interface: configgeneral
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGGENERAL_H
+#define CONFIGGENERAL_H
+
+//Qt headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qtooltip.h>
+#include <qlabel.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include <../constants.h>
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure general things.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigGeneral : public KCModule
+{
+Q_OBJECT
+
+ public:
+
+ /**
+ * Generic Constructor
+ */
+ ConfigGeneral( QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigGeneral();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Check box to select whether window closing must be confirmed.
+ */
+ QCheckBox* chkConfirmClose;
+
+ /**
+ * Check box to select whether deleting must be confirmed.
+ */
+ QCheckBox* chkConfirmDelete;
+
+ /**
+ * Check box to select whether the main window will be minimized at start.
+ */
+ QCheckBox* chkStartMinimized;
+
+ /**
+ * Check box to select whether the close button leave the application running in tray.
+ */
+ QCheckBox* chkCloseToTray;
+
+ /**
+ * Check box to select whether minimizes to the tray rather than to the taskbar.
+ */
+ QCheckBox* chkMinimizeToTray;
+
+ /**
+ * Check box to select whether connection errors will be shown.
+ */
+ QCheckBox* chkShowConnectionErrors;
+
+ /**
+ * Check box to select whether mails will be kept as new until termination.
+ */
+ QCheckBox* chkKeepNew;
+
+ /**
+ * Spin box to set the initial timer.
+ */
+ QSpinBox* spbInitial;
+
+ /**
+ * Spin box to set the interval timer.
+ */
+ QSpinBox* spbInterval;
+
+ /**
+ * Spin box to set the time out timer.
+ */
+ QSpinBox* spbTimeout;
+
+ public slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configlog.cpp b/kshowmail/kcmconfigs/configlog.cpp
new file mode 100644
index 0000000..e7eb51d
--- /dev/null
+++ b/kshowmail/kcmconfigs/configlog.cpp
@@ -0,0 +1,255 @@
+//
+// C++ Implementation: configlog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configlog.h"
+
+typedef KGenericFactory<ConfigLog, QWidget> ConfigLogFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfiglog, ConfigLogFactory(
+ "kcm_kshowmailconfiglog" ) );
+
+ConfigLog::ConfigLog( QWidget * parent, const char * name, const QStringList & args )
+ : KCModule( ConfigLogFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configlog" );
+
+ //build GUI
+ //---------
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //widgets for deleted mails log
+ QVBoxLayout* layDelMails = new QVBoxLayout( layMain, 10, "layDelMails" );
+
+ chkLogDeletedMails = new QCheckBox( i18n( "Log mails deleted by filter" ), this, "chkLogDeletedMails" );
+ layDelMails->addWidget( chkLogDeletedMails );
+ QToolTip::add( chkLogDeletedMails, i18n( "Check to activate the log of mails deleted by filter." ) );
+ connect( chkLogDeletedMails, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkLogDeletedMails, SIGNAL( toggled( bool ) ), this, SLOT( slotChangeItems() ) );
+
+ QVBoxLayout* layDelMailsConfig = new QVBoxLayout( layDelMails, 10, "layDelMailsConfig" );
+ layDelMailsConfig->setMargin( 10 );
+
+ grpDelMailsRemove = new QButtonGroup( NULL, "grpDelMailsRemove" );
+ connect( grpDelMailsRemove, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
+ connect( grpDelMailsRemove, SIGNAL( clicked( int ) ), this, SLOT( slotChangeItems() ) );
+ btnDelMailsRemoveExit = new QRadioButton( i18n( "Remove log entries at exit" ), this, "btnDelMailsRemoveExit" );
+ grpDelMailsRemove->insert( btnDelMailsRemoveExit, ID_BUTTON_REMOVE_AT_EXIT );
+ layDelMailsConfig->addWidget( btnDelMailsRemoveExit );
+
+ QHBoxLayout* layDelMailsConfigDays = new QHBoxLayout( layDelMailsConfig, 0, "layDelMailsConfigDays" );
+ layDelMailsConfigDays->setAlignment( Qt::AlignLeft );
+ btnDelMailsRemoveDays = new QRadioButton( i18n( "Remove log entries after" ), this, "btnDelMailsRemoveDays" );
+ grpDelMailsRemove->insert( btnDelMailsRemoveDays, ID_BUTTON_REMOVE_AFTER_DAYS );
+ layDelMailsConfigDays->addWidget( btnDelMailsRemoveDays );
+ spbDelDays = new QSpinBox( 1, 999999, 1, this, "spbDelDays" );
+ connect( spbDelDays, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
+ connect( spbDelDays, SIGNAL( valueChanged( int ) ), this, SLOT( slotChangeItems() ) );
+ spbDelDays->setSuffix( i18n( " Days" ) );
+ spbDelDays->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum );
+ layDelMailsConfigDays->addWidget( spbDelDays );
+
+
+ //widgets for moved mails log
+ QVBoxLayout* layMovMails = new QVBoxLayout( layMain, 10, "layMovMails" );
+
+ chkLogMovedMails = new QCheckBox( i18n( "Log mails moved by filter" ), this, "chkLogMovedMails" );
+ layMovMails->addWidget( chkLogMovedMails );
+ QToolTip::add( chkLogMovedMails, i18n( "Check to activate the log of mails moved by filter." ) );
+ connect( chkLogMovedMails, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
+ connect( chkLogMovedMails, SIGNAL( toggled( bool ) ), this, SLOT( slotChangeItems() ) );
+
+ QVBoxLayout* layMovMailsConfig = new QVBoxLayout( layMovMails, 10, "layMovMailsConfig" );
+ layMovMailsConfig->setMargin( 10 );
+
+ grpMovMailsRemove = new QButtonGroup( NULL, "grpMovMailsRemove" );
+ connect( grpMovMailsRemove, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
+ connect( grpMovMailsRemove, SIGNAL( clicked( int ) ), this, SLOT( slotChangeItems() ) );
+ btnMovMailsRemoveExit = new QRadioButton( i18n( "Remove log entries at exit" ), this, "btnMovMailsRemoveExit" );
+ grpMovMailsRemove->insert( btnMovMailsRemoveExit, ID_BUTTON_REMOVE_AT_EXIT );
+ layMovMailsConfig->addWidget( btnMovMailsRemoveExit );
+
+ QHBoxLayout* layMovMailsConfigDays = new QHBoxLayout( layMovMailsConfig, 0, "layMovMailsConfigDays" );
+ layMovMailsConfigDays->setAlignment( Qt::AlignLeft );
+ btnMovMailsRemoveDays = new QRadioButton( i18n( "Remove log entries after" ), this, "btnMovMailsRemoveDays" );
+ grpMovMailsRemove->insert( btnMovMailsRemoveDays, ID_BUTTON_REMOVE_AFTER_DAYS );
+ layMovMailsConfigDays->addWidget( btnMovMailsRemoveDays );
+ spbMovDays = new QSpinBox( 1, 999999, 1, this, "spbMovDays" );
+ connect( spbMovDays, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
+ connect( spbMovDays, SIGNAL( valueChanged( int ) ), this, SLOT( slotChangeItems() ) );
+ spbMovDays->setSuffix( i18n( " Days" ) );
+ spbMovDays->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum );
+ layMovMailsConfigDays->addWidget( spbMovDays );
+
+ //the log of moved mails is not saved yet, maybe later...
+ btnMovMailsRemoveExit->setHidden( true );
+ btnMovMailsRemoveDays->setHidden( true );
+ spbMovDays->setHidden( true );
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configured values
+ load();
+}
+
+ConfigLog::~ConfigLog()
+{
+}
+
+void ConfigLog::load()
+{
+ //set group
+ config->setGroup( CONFIG_GROUP_LOG );
+
+ //load settings
+ chkLogDeletedMails->setChecked( config->readBoolEntry( CONFIG_ENTRY_LOG_LOG_DELETED_MAILS, DEFAULT_LOG_LOG_DELETED_MAILS ) );
+ chkLogMovedMails->setChecked( config->readBoolEntry( CONFIG_ENTRY_LOG_LOG_MOVED_MAILS, DEFAULT_LOG_LOG_MOVED_MAILS ) );
+
+ if( config->readEntry( CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, DEFAULT_LOG_REMOVE_DELETED_MAILS ) == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else if( config->readEntry( CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, DEFAULT_LOG_REMOVE_DELETED_MAILS ) == CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS )
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+ else
+ if( DEFAULT_LOG_REMOVE_DELETED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+
+ if( config->readEntry( CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS, DEFAULT_LOG_REMOVE_MOVED_MAILS ) == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else if( config->readEntry( CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS, DEFAULT_LOG_REMOVE_MOVED_MAILS ) == CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS )
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+ else
+ if( DEFAULT_LOG_REMOVE_MOVED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+
+ spbDelDays->setValue( config->readNumEntry( CONFIG_ENTRY_LOG_HOLDDAYS_DELETED_MAILS, DEFAULT_LOG_HOLDDAYS_DELETED_MAILS ) );
+ spbMovDays->setValue( config->readNumEntry( CONFIG_ENTRY_LOG_HOLDDAYS_MOVED_MAILS, DEFAULT_LOG_HOLDDAYS_MOVED_MAILS ) );
+
+ //enable or disable Items
+ slotChangeItems();
+}
+
+void ConfigLog::defaults()
+{
+ if( DEFAULT_LOG_LOG_DELETED_MAILS )
+ chkLogDeletedMails->setChecked( true );
+ else
+ chkLogMovedMails->setChecked( false );
+
+ if( DEFAULT_LOG_LOG_MOVED_MAILS )
+ chkLogMovedMails->setChecked( true );
+ else
+ chkLogMovedMails->setChecked( false );
+
+ if( DEFAULT_LOG_REMOVE_DELETED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else if( DEFAULT_LOG_REMOVE_DELETED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS )
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+ else
+ grpDelMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+
+ if( DEFAULT_LOG_REMOVE_MOVED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT )
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AT_EXIT );
+ else if( DEFAULT_LOG_REMOVE_MOVED_MAILS == CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS )
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+ else
+ grpMovMailsRemove->setButton( ID_BUTTON_REMOVE_AFTER_DAYS );
+
+ spbDelDays->setValue( DEFAULT_LOG_HOLDDAYS_DELETED_MAILS );
+ spbMovDays->setValue( DEFAULT_LOG_HOLDDAYS_MOVED_MAILS );
+
+ //enable or disable Items
+ slotChangeItems();
+
+ slotChanged();
+}
+
+void ConfigLog::save()
+{
+ //set group
+ config->setGroup( CONFIG_GROUP_LOG );
+
+ //write settings
+ config->writeEntry( CONFIG_ENTRY_LOG_LOG_DELETED_MAILS, chkLogDeletedMails->isOn() );
+ config->writeEntry( CONFIG_ENTRY_LOG_LOG_MOVED_MAILS, chkLogMovedMails->isOn() );
+
+ switch( grpDelMailsRemove->selectedId() )
+ {
+ case ID_BUTTON_REMOVE_AT_EXIT : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT ); break;
+ case ID_BUTTON_REMOVE_AFTER_DAYS : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS ); break;
+ default : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_DELETED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS ); break;
+ }
+
+ switch( grpMovMailsRemove->selectedId() )
+ {
+ case ID_BUTTON_REMOVE_AT_EXIT : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT ); break;
+ case ID_BUTTON_REMOVE_AFTER_DAYS : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AFTER_DAYS ); break;
+ default : config->writeEntry( CONFIG_ENTRY_LOG_REMOVE_MOVED_MAILS, CONFIG_VALUE_LOG_REMOVE_MAILS_AT_EXIT ); break;
+ }
+
+ config->writeEntry( CONFIG_ENTRY_LOG_HOLDDAYS_DELETED_MAILS, spbDelDays->value() );
+ config->writeEntry( CONFIG_ENTRY_LOG_HOLDDAYS_MOVED_MAILS, spbMovDays->value() );
+}
+
+void ConfigLog::slotChanged()
+{
+ KCModule::changed();
+}
+
+void ConfigLog::slotChangeItems()
+{
+ if( chkLogDeletedMails->isChecked() )
+ {
+ btnDelMailsRemoveExit->setEnabled( true );
+ btnDelMailsRemoveDays->setEnabled( true );
+ spbDelDays->setEnabled( true );
+ switch( grpDelMailsRemove->selectedId() )
+ {
+ case ID_BUTTON_REMOVE_AFTER_DAYS : spbDelDays->setEnabled( true ); break;
+ case ID_BUTTON_REMOVE_AT_EXIT : spbDelDays->setEnabled( false ); break;
+ default : spbDelDays->setEnabled( true ); break;
+ }
+ }
+ else
+ {
+ btnDelMailsRemoveExit->setEnabled( false );
+ btnDelMailsRemoveDays->setEnabled( false );
+ spbDelDays->setEnabled( false );
+ }
+
+ if( chkLogMovedMails->isChecked() )
+ {
+ btnMovMailsRemoveExit->setEnabled( true );
+ btnMovMailsRemoveDays->setEnabled( true );
+ spbMovDays->setEnabled( true );
+ switch( grpMovMailsRemove->selectedId() )
+ {
+ case ID_BUTTON_REMOVE_AFTER_DAYS : spbMovDays->setEnabled( true ); break;
+ case ID_BUTTON_REMOVE_AT_EXIT : spbMovDays->setEnabled( false ); break;
+ default : spbMovDays->setEnabled( true ); break;
+ }
+ }
+ else
+ {
+ btnMovMailsRemoveExit->setEnabled( false );
+ btnMovMailsRemoveDays->setEnabled( false );
+ spbMovDays->setEnabled( false );
+ }
+}
+
+
+#include "configlog.moc"
diff --git a/kshowmail/kcmconfigs/configlog.h b/kshowmail/kcmconfigs/configlog.h
new file mode 100644
index 0000000..84e6fd4
--- /dev/null
+++ b/kshowmail/kcmconfigs/configlog.h
@@ -0,0 +1,152 @@
+//
+// C++ Interface: configlog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGLOG_H
+#define CONFIGLOG_H
+
+//button IDs
+#define ID_BUTTON_REMOVE_AT_EXIT 1
+#define ID_BUTTON_REMOVE_AFTER_DAYS 2
+
+//qt headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qtooltip.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qspinbox.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+
+//Kshowmail headers
+#include "../constants.h"
+
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the log.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigLog : public KCModule
+{
+Q_OBJECT
+
+ public:
+
+ /**
+ * Generic constructor
+ */
+ ConfigLog( QWidget* parent = 0, const char* name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigLog();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Checkbox to activate log of deleted mails
+ */
+ QCheckBox* chkLogDeletedMails;
+
+ /**
+ * Checkbox to activate log of moved mails
+ */
+ QCheckBox* chkLogMovedMails;
+
+ /**
+ * Combines the radio buttons to select the kind of removing log entries of deleted mails
+ */
+ QButtonGroup* grpDelMailsRemove;
+
+ /**
+ * Combines the radio buttons to select the kind of removing log entries of moved mails
+ */
+ QButtonGroup* grpMovMailsRemove;
+
+ /**
+ * Spinbox to select the number of days to remove.
+ */
+ QSpinBox* spbDelDays;
+
+ /**
+ * Spinbox to select the number of days to remove.
+ */
+ QSpinBox* spbMovDays;
+
+ /**
+ * Radio button to select the removing of entries about deleted mails at application exit.
+ */
+ QRadioButton* btnDelMailsRemoveExit;
+
+ /**
+ * Radio button to select the removing of entries about deleted mails after some days.
+ */
+ QRadioButton* btnDelMailsRemoveDays;
+
+ /**
+ * Radio button to select the removing of entries about moved mails at application exit.
+ */
+ QRadioButton* btnMovMailsRemoveExit;
+
+ /**
+ * Radio button to select the removing of entries about moved mails after some days.
+ */
+ QRadioButton* btnMovMailsRemoveDays;
+
+ private slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+
+ /**
+ * Connected with the checkboxes and radiobuttons.
+ * Enables or disables the dialog items.
+ */
+ void slotChangeItems();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/configspamcheck.cpp b/kshowmail/kcmconfigs/configspamcheck.cpp
new file mode 100644
index 0000000..44f7ef7
--- /dev/null
+++ b/kshowmail/kcmconfigs/configspamcheck.cpp
@@ -0,0 +1,236 @@
+//
+// C++ Implementation: configspamcheck
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "configspamcheck.h"
+
+
+typedef KGenericFactory<ConfigSpamcheck, QWidget> ConfigSpamcheckFactory;
+
+K_EXPORT_COMPONENT_FACTORY( kcm_kshowmailconfigspamcheck, ConfigSpamcheckFactory(
+ "kcm_kshowmailconfigspamcheck" ) );
+
+
+ConfigSpamcheck::ConfigSpamcheck(QWidget * parent, const char * name, const QStringList & args)
+ : KCModule( ConfigSpamcheckFactory::instance(), parent, args )
+{
+ //set the module name
+ if ( !name )
+ setName( "configfilter" );
+
+ //build GUI
+ //---------
+
+ //main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, 10 );
+
+ //description
+ QLabel* lblDescription = new QLabel( this, "lblDescription" );
+ lblDescription->setAlignment( Qt::WordBreak );
+ lblDescription->setText( QString( "<i>%1</i>" ).arg( i18n( "KShowmail uses SpamAssassin to check the mails for spam. You have to install, configure and start the SpamAssassin daemon, before you can use this service." ) ) );
+ lblDescription->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
+ layMain->addWidget( lblDescription );
+
+ //Test button
+ btnTest = new KPushButton( KStdGuiItem::test(), this, "btnTest" );
+ btnTest->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
+ layMain->addWidget( btnTest );
+ connect( btnTest, SIGNAL( clicked() ), this, SLOT( slotTestSpamAssassin() ) );
+
+ //action
+ gboxAction = new QGroupBox( 0, Qt::Horizontal, i18n( "Action for Spam" ), this, "gboxAction" );
+ QHBoxLayout* layAction = new QHBoxLayout( gboxAction->layout(), 10 );
+ layMain->addWidget( gboxAction );
+
+ cmbAction = new KComboBox( gboxAction, "cmbAction" );
+ layAction->addWidget( cmbAction );
+ QToolTip::add( cmbAction, i18n( "Choose the action for spam mails." ) );
+ connect( cmbAction, SIGNAL( activated( int ) ), this, SLOT( slotActionChanged( int ) ) );
+ connect( cmbAction, SIGNAL( activated( int ) ), this, SLOT( slotChanged() ) );
+
+ //insert items
+ cmbAction->insertItem( i18n( "Delete" ), ID_SPAM_ACTION_BUTTONS_DELETE );
+ cmbAction->insertItem( i18n( "Mark" ), ID_SPAM_ACTION_BUTTONS_MARK );
+ cmbAction->insertItem( i18n( "Move" ), ID_SPAM_ACTION_BUTTONS_MOVE );
+
+ //create edit line to defined the mailbox for move
+ txtMailbox = new KLineEdit( gboxAction );
+ layAction->addWidget( txtMailbox );
+ connect( txtMailbox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotChanged() ) );
+
+ //create wizard button to configure mailbox
+ btnMailboxWizard= new KPushButton( KGuiItem( QString::null, "wizard" ), gboxAction );
+ layAction->addWidget( btnMailboxWizard );
+ QToolTip::add( btnMailboxWizard, i18n( "Choose the mailbox" ) );
+ connect( btnMailboxWizard, SIGNAL( clicked() ), this, SLOT( slotOpenMailBoxWizard() ) );
+
+ //set defaults
+ switch( DEFAULT_SPAMCHECK_ACTION )
+ {
+ case CONFIG_VALUE_SPAMCHECK_ACTION_DELETE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_DELETE ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MARK : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MARK ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MOVE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MOVE ); break;
+ }
+
+ txtMailbox->setText( DEFAULT_SPAMCHECK_ACTION_MOVE_MAILBOX );
+
+ //enable or disable widgets
+ slotActionChanged( cmbAction->currentItem() );
+ gboxAction->setEnabled( isSpamAssassinRunning() );
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load configured values
+ load();
+}
+
+ConfigSpamcheck::~ConfigSpamcheck()
+{
+}
+
+void ConfigSpamcheck::load()
+{
+ config->setGroup( CONFIG_GROUP_SPAMCHECK );
+
+ //load action
+ switch( config->readNumEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, DEFAULT_SPAMCHECK_ACTION ) )
+ {
+ case CONFIG_VALUE_SPAMCHECK_ACTION_DELETE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_DELETE ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MARK : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MARK ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MOVE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MOVE ); break;
+ }
+
+ //get mailbox name
+ if( config->readNumEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, DEFAULT_SPAMCHECK_ACTION ) == CONFIG_VALUE_SPAMCHECK_ACTION_MOVE )
+ txtMailbox->setText( config->readEntry( CONFIG_ENTRY_SPAMCHECK_MOVE_MAILBOX, DEFAULT_SPAMCHECK_ACTION_MOVE_MAILBOX ) );
+ else
+ txtMailbox->clear();
+
+ //enable or disable widgets for other action
+ slotActionChanged( cmbAction->currentItem() );
+}
+
+void ConfigSpamcheck::defaults()
+{
+ switch( DEFAULT_SPAMCHECK_ACTION )
+ {
+ case CONFIG_VALUE_SPAMCHECK_ACTION_DELETE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_DELETE ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MARK : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MARK ); break;
+ case CONFIG_VALUE_SPAMCHECK_ACTION_MOVE : cmbAction->setCurrentItem( ID_SPAM_ACTION_BUTTONS_MOVE ); break;
+ }
+
+ if( DEFAULT_SPAMCHECK_ACTION == CONFIG_VALUE_SPAMCHECK_ACTION_MOVE )
+ txtMailbox->setText( QString( DEFAULT_SPAMCHECK_ACTION_MOVE_MAILBOX ) );
+ else
+ txtMailbox->clear();
+
+ //enable or disable widgets for other action
+ slotActionChanged( cmbAction->currentItem() );
+
+ slotChanged();
+}
+
+void ConfigSpamcheck::save()
+{
+ config->setGroup( CONFIG_GROUP_SPAMCHECK );
+
+ //save action
+ switch( cmbAction->currentItem() )
+ {
+ case ID_SPAM_ACTION_BUTTONS_DELETE : config->writeEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, CONFIG_VALUE_SPAMCHECK_ACTION_DELETE ); break;
+ case ID_SPAM_ACTION_BUTTONS_MARK : config->writeEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, CONFIG_VALUE_SPAMCHECK_ACTION_MARK ); break;
+ case ID_SPAM_ACTION_BUTTONS_MOVE : config->writeEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, CONFIG_VALUE_SPAMCHECK_ACTION_MOVE ); break;
+ default : config->writeEntry( CONFIG_ENTRY_SPAMCHECK_ACTION, DEFAULT_SPAMCHECK_ACTION ); break;
+ }
+
+ //save mailbox name
+ if( cmbAction->currentItem() == ID_SPAM_ACTION_BUTTONS_MOVE )
+ {
+ config->writeEntry( CONFIG_ENTRY_SPAMCHECK_MOVE_MAILBOX, txtMailbox->text() );
+ }
+ else
+ {
+ config->deleteEntry( CONFIG_ENTRY_SPAMCHECK_MOVE_MAILBOX );
+ }
+
+ config->sync();
+}
+
+void ConfigSpamcheck::slotChanged()
+{
+ KCModule::changed();
+}
+
+void ConfigSpamcheck::slotActionChanged( int index )
+{
+ switch( index )
+ {
+ case ID_SPAM_ACTION_BUTTONS_MOVE : txtMailbox->setEnabled( true );
+ if( txtMailbox->text() == "" )
+ txtMailbox->setText( DEFAULT_FILTER_ACTION_MOVE_MAILBOX );
+ btnMailboxWizard->setHidden( false );
+ break;
+ default : txtMailbox->setEnabled( false );
+ btnMailboxWizard->setHidden( true );
+ break;
+ }
+}
+
+void ConfigSpamcheck::slotOpenMailBoxWizard( )
+{
+ MailBoxWizard wizard( this, "malboxwizard" );
+ wizard.setCaption( i18n( "Mailbox Select" ) );
+ int res = wizard.exec();
+
+ if( res == QDialog::Accepted )
+ txtMailbox->setText( wizard.getPath() );
+}
+
+bool ConfigSpamcheck::isSpamAssassinRunning( ) const
+{
+ FILE *read_fp;
+ char buffer[ BUFSIZ + 1 ];
+ int chars_read;
+ bool found = false;
+
+ memset( buffer, '\0', sizeof( buffer ) );
+ read_fp = popen( "ps -eo comm", "r" );
+ if( read_fp != NULL )
+ {
+ chars_read = fread( buffer, sizeof( char ), BUFSIZ, read_fp );
+ while( chars_read > 0 )
+ {
+ buffer[ chars_read - 1 ] = '\0';
+ QString output( buffer );
+ found = output.contains( NAME_SPAMASSASSIN_DAEMON ) > 0;
+ chars_read = fread( buffer, sizeof( char ), BUFSIZ, read_fp );
+ }
+ pclose( read_fp );
+ }
+
+ return found;
+}
+
+void ConfigSpamcheck::slotTestSpamAssassin( )
+{
+ if( isSpamAssassinRunning() )
+ {
+ KMessageBox::information( this, i18n( "SpamAssassin is running." ), i18n( "Check for SpamAssassin" ) );
+ gboxAction->setEnabled( true );
+ }
+ else
+ {
+ KMessageBox::information( this, i18n( "SpamAssassin is not running." ), i18n( "Check for SpamAssassin" ) );
+ gboxAction->setEnabled( false );
+ }
+}
+
+#include "configspamcheck.moc"
diff --git a/kshowmail/kcmconfigs/configspamcheck.h b/kshowmail/kcmconfigs/configspamcheck.h
new file mode 100644
index 0000000..d2af35c
--- /dev/null
+++ b/kshowmail/kcmconfigs/configspamcheck.h
@@ -0,0 +1,161 @@
+//
+// C++ Interface: configspamcheck
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CONFIGSPAMCHECK_H
+#define CONFIGSPAMCHECK_H
+
+//C-headers
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+//Qt headers
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qtooltip.h>
+
+//KDE headers
+#include <kcmodule.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+
+//Kshowmail headers
+#include "../constants.h"
+#include "mailboxwizard.h"
+
+//radio button IDs
+#define ID_SPAM_ACTION_BUTTONS_DELETE 0
+#define ID_SPAM_ACTION_BUTTONS_MARK 1
+#define ID_SPAM_ACTION_BUTTONS_MOVE 2
+
+
+/**
+ * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the spam check.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ConfigSpamcheck : public KCModule
+{
+
+Q_OBJECT
+
+
+ public:
+ /**
+ * Generic constructor
+ */
+ ConfigSpamcheck( QWidget* parent = 0, const char* name = 0, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ ~ConfigSpamcheck();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to reflect the current settings stored in the
+ * config file.
+ */
+ virtual void load();
+
+ /**
+ * Overloaded method of KCModule.
+ * Sets the user interface elements to default values.
+ * This method is called when the user clicks the "Default" button.
+ */
+ virtual void defaults();
+
+ /**
+ * Overloaded method of KCModule.
+ * Stores the config information as shown in the user interface in the
+ * config file.
+ * Is called when the user clicks "Apply" or "Ok".
+ */
+ virtual void save();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Button to test for a running SpamAssassin
+ */
+ KPushButton* btnTest;
+
+ /**
+ * Combobox to select the action for spam.
+ */
+ KComboBox* cmbAction;
+
+ /**
+ * If selected, the spam mails will be moved to the mailbox which is written in this edit line.
+ */
+ KLineEdit* txtMailbox;
+
+ /**
+ * This button opens a wizard which will help to get the right mailbox
+ */
+ KPushButton* btnMailboxWizard;
+
+ /**
+ * Contains the widgets of action configuration.
+ */
+ QGroupBox* gboxAction;
+
+ private slots:
+
+ /**
+ * Connected with the configuration items.
+ * Calls the slot changed() of KCModule to notify the dialog about the change.
+ */
+ void slotChanged();
+
+ /**
+ * Connected with combobox cmbAction.
+ * Enables or disables additional widgets for action configuration.
+ * @param index position (index) of the selected action
+ */
+ void slotActionChanged( int index );
+
+ /**
+ * Connected with button btnMailboxWizard.
+ * Opens a wizard to configure the mailbox
+ */
+ void slotOpenMailBoxWizard();
+
+ /**
+ * Connected with btnTest.
+ * Tests whether SpamAssassin is running and shows a message box containing the result.
+ * Enables or disables the action widgets.
+ */
+ void slotTestSpamAssassin();
+
+ protected:
+
+ /**
+ * Looks for a running spamd daemon of SpamAssassin.
+ * @return TRUE - SpamAssassin is running
+ */
+ bool isSpamAssassinRunning() const;
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/encryption.cpp b/kshowmail/kcmconfigs/encryption.cpp
new file mode 100644
index 0000000..dd3bcec
--- /dev/null
+++ b/kshowmail/kcmconfigs/encryption.cpp
@@ -0,0 +1,85 @@
+//
+// C++ Implementation: encryption
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "encryption.h"
+
+//used in crypt() and decrypt()
+static const char scramble1 [50] = "C6FDC7A1EDFBB6FEE3DBF5BEBAEFDDF7ABC6FDC7A1EDFBB6";
+static const char hexstr [17] = "0123456789ABCDEF";
+
+int Encryption::hexbyt( const char c )
+{
+ if( c >= '0' && c <= '9' )
+ return c - '0';
+ else
+ return c - 'A' + 10;
+}
+
+const QString Encryption::crypt( const KURL& url )
+{
+ char result[50];
+ char scramble2[50];
+ QString hexresult;
+
+ memset (result, 0, 50);
+ memset (scramble2, 0, 50);
+ int pos = url.pass().length () + 1;
+ unsigned int free = 50 - pos;
+
+ if( url.user().length() <= free )
+ {
+ strcpy( &scramble2[pos], url.user() );
+ pos += url.user().length();
+ free -= url.user().length();
+ }
+ else
+ {
+ memcpy( &scramble2[pos], url.user().latin1(), free );
+ free = 0;
+ }
+
+ if( url.host().length() <= free )
+ {
+ strcpy( &scramble2[pos], url.host() );
+ pos += url.host().length();
+ free -= url.host().length();
+ }
+ else
+ {
+ memcpy( &scramble2[pos], url.host().latin1(), free );
+ free = 0;
+ }
+
+ memcpy( result, url.pass().latin1(), url.pass().length() );
+ for (int i = 0; i <= 31; i++)
+ {
+ result[i] = (char)( result[i] ^ ( scramble1[i] ^ scramble2[i] ) );
+ hexresult += hexstr[ result[i] / 16 ];
+ hexresult += hexstr[ result[i] % 16 ];
+ }
+
+ return hexresult;
+}
+
+const QString Encryption::decrypt( const QString& pass )
+{
+ char result[50];
+
+ memset( result, 0, 50 );
+ int i;
+ for( i = 0; i <= 31; i++ )
+ {
+ result[i] = (char)hexbyt( pass[ i * 2 ] ) * 16 + hexbyt( pass[ i * 2 + 1 ] );
+ result[i] = (char)( result[i] ^ scramble1[i] );
+ }
+
+ return result;
+}
diff --git a/kshowmail/kcmconfigs/encryption.h b/kshowmail/kcmconfigs/encryption.h
new file mode 100644
index 0000000..376cc26
--- /dev/null
+++ b/kshowmail/kcmconfigs/encryption.h
@@ -0,0 +1,46 @@
+//
+// C++ Interface: encryption
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+//Qt headers
+#include <qstring.h>
+
+//KDE headers
+#include <kurl.h>
+
+/**
+ * @brief Provides functions to crypt and decrypt a password.
+ */
+namespace Encryption
+{
+ /**
+ * Transforms the given hex numeric character to integer.
+ * For example: a given '2' will transformed to 2; 'B' to 12.
+ * @param c character to transform [0..9, 'A'..'F']; no lower case letters
+ * @return integer value of the given character
+ */
+ int hexbyt( const char c );
+
+ /**
+ * Encrypts the the password in the given url and returns it.
+ * The encryption algorithm uses host and user name to crypt the password.
+ * @param url the url with password, host and user name
+ * @return encrypted password
+ */
+ const QString crypt( const KURL& url );
+
+ /**
+ * Decrypts the given encrypted password.
+ * @param pass encrypted password
+ * @return decrypted password
+ */
+ const QString decrypt( const QString& pass );
+}
diff --git a/kshowmail/kcmconfigs/filtercriteriawidget.cpp b/kshowmail/kcmconfigs/filtercriteriawidget.cpp
new file mode 100644
index 0000000..c7ea8c5
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtercriteriawidget.cpp
@@ -0,0 +1,338 @@
+//
+// C++ Implementation: filtercriteriawidget
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filtercriteriawidget.h"
+
+FilterCriteriaWidget::FilterCriteriaWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ //this is the main layout
+ QVBoxLayout* layMain = new QVBoxLayout( this, 0, KDialog::spacingHint(), "layMain" );
+
+ //and now the layouts of the first and second line
+ QHBoxLayout* layLine1 = new QHBoxLayout( layMain, KDialog::spacingHint(), "layLine1" );
+ QHBoxLayout* layLine2 = new QHBoxLayout( layMain, KDialog::spacingHint(), "layLine2" );
+
+ //Source Select
+ cmbSource = new KComboBox( this, "cmbSource" );
+ cmbSource->insertItem( i18n( "From" ), ID_COMBO_SOURCE_FROM );
+ cmbSource->insertItem( i18n( "To" ), ID_COMBO_SOURCE_TO );
+ cmbSource->insertItem( i18n( "Size (Bytes)" ), ID_COMBO_SOURCE_SIZE );
+ cmbSource->insertItem( i18n( "Subject" ), ID_COMBO_SOURCE_SUBJECT );
+ cmbSource->insertItem( i18n( "Header" ), ID_COMBO_SOURCE_HEADER );
+ cmbSource->insertItem( i18n( "Account" ), ID_COMBO_SOURCE_ACCOUNT );
+ layLine1->addWidget( cmbSource );
+ connect( cmbSource, SIGNAL( activated( int ) ), this, SLOT( slotSetWidgets() ) );
+
+ switch( DEFAULT_FILTER_CRITERIA_SOURCE )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM : cmbSource->setCurrentItem( ID_COMBO_SOURCE_FROM ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO : cmbSource->setCurrentItem( ID_COMBO_SOURCE_TO ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : cmbSource->setCurrentItem( ID_COMBO_SOURCE_SIZE ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT : cmbSource->setCurrentItem( ID_COMBO_SOURCE_SUBJECT ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER : cmbSource->setCurrentItem( ID_COMBO_SOURCE_HEADER ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT : cmbSource->setCurrentItem( ID_COMBO_SOURCE_ACCOUNT ); break;
+ default : cmbSource->setCurrentItem( ID_COMBO_SOURCE_FROM ); break;
+ }
+
+ //Comboboxes to select the condition between source and value
+ cmbConditionText = new KComboBox( this, "cmbConditionText" );
+ cmbConditionText->insertItem( i18n( "contains" ), ID_COMBO_COND_TEXT_CONTAINS );
+ cmbConditionText->insertItem( i18n( "does not contain" ), ID_COMBO_COND_TEXT_NOT_CONTAINS );
+ cmbConditionText->insertItem( i18n( "equals" ), ID_COMBO_COND_TEXT_EQUALS );
+ cmbConditionText->insertItem( i18n( "does not equal" ), ID_COMBO_COND_TEXT_NOT_EQUALS );
+ cmbConditionText->insertItem( i18n( "matches regular expression" ), ID_COMBO_COND_TEXT_REGEXPR );
+ cmbConditionText->insertItem( i18n( "does not match reg. expr." ), ID_COMBO_COND_TEXT_NOT_REGEXPR );
+ layLine1->addWidget( cmbConditionText );
+ connect( cmbConditionText, SIGNAL( activated( int ) ), this, SLOT( slotSetWidgets() ) );
+
+ switch( DEFAULT_FILTER_CRITERIA_COND_TEXT )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_CONTAINS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_CONTAINS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_EQUALS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_EQUALS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_REGEXPR );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_REGEXPR );break;
+ default : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_CONTAINS ); break;
+ }
+
+ cmbConditionNum = new KComboBox( this, "cmbConditionNum" );
+ cmbConditionNum->insertItem( i18n( "is equal to" ), ID_COMBO_COND_NUM_EQUAL );
+ cmbConditionNum->insertItem( i18n( "is not equal to" ), ID_COMBO_COND_NUM_NOT_EQUAL );
+ cmbConditionNum->insertItem( i18n( "is greater than" ), ID_COMBO_COND_NUM_GREATER );
+ cmbConditionNum->insertItem( i18n( "is greater than or equal to" ), ID_COMBO_COND_NUM_GREATER_EQUAL );
+ cmbConditionNum->insertItem( i18n( "is less than" ), ID_COMBO_COND_NUM_LESS );
+ cmbConditionNum->insertItem( i18n( "is less than or equal to" ), ID_COMBO_COND_NUM_LESS_EQUAL );
+ layLine1->addWidget( cmbConditionNum );
+
+ switch( DEFAULT_FILTER_CRITERIA_COND_NUM )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_NOT_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_GREATER ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_GREATER_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_LESS ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_LESS_EQUAL ); break;
+ default : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_EQUAL ); break;
+ }
+
+ //edit line and spin box which hold the comparation values
+ txtCompValueText = new KLineEdit( this, "txtCompValueText" );
+ txtCompValueText->setMinimumWidth( WIDTH_FILTER_TEXT_VALUE_LINE );
+ layLine1->addWidget( txtCompValueText );
+
+ spbCompValueNum = new KIntNumInput( DEFAULT_FILTER_CRITERIA_SIZE, this, 10, "spbCompValueNum" );
+ spbCompValueNum->setMinValue( 0 );
+ spbCompValueNum->setSuffix( " Bytes" );
+ layLine1->addWidget( spbCompValueNum );
+
+ //Button to open the regular expression editor
+ btnOpenRegExpEditor = new KPushButton( KGuiItem( "", "edit", "Edit Regualar Expression" ), this, "btnOpenRegExpEditor" );
+ layLine1->addWidget( btnOpenRegExpEditor );
+ connect( btnOpenRegExpEditor, SIGNAL( clicked() ), this, SLOT( slotOpenRegExpEditor() ) );
+
+ //check whether the KRegExpEditor is available
+ kRegExpEditorAvailable = !KTrader::self()->query( "KRegExpEditor/KRegExpEditor" ).isEmpty();
+
+ //checkbox to select case sensitve
+ chkCaseSensitive = new QCheckBox( i18n( "Case sensitive" ), this, "chkCaseSensitive" );
+ chkCaseSensitive->setChecked( DEFAULT_FILTER_CRITERIA_CASE_SENSITIVE ); //set default
+ layLine2->addWidget( chkCaseSensitive );
+
+ //separator to the next criteria widget
+ layMain->addWidget( new KSeparator( this ) );
+
+ //set widgets dependent on criteria source
+ slotSetWidgets();
+}
+
+
+FilterCriteriaWidget::~FilterCriteriaWidget()
+{
+}
+
+void FilterCriteriaWidget::slotSetWidgets( )
+{
+ switch( cmbSource->currentItem() )
+ {
+ case ID_COMBO_SOURCE_FROM : cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ case ID_COMBO_SOURCE_TO : cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ case ID_COMBO_SOURCE_SIZE : cmbConditionNum->setHidden( false );
+ spbCompValueNum->setHidden( false );
+ cmbConditionText->setHidden( true );
+ txtCompValueText->setHidden( true );
+ chkCaseSensitive->setHidden( true );
+ break;
+ case ID_COMBO_SOURCE_SUBJECT : cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ case ID_COMBO_SOURCE_HEADER : cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ case ID_COMBO_SOURCE_ACCOUNT : cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ default: cmbConditionNum->setHidden( true );
+ spbCompValueNum->setHidden( true );
+ cmbConditionText->setHidden( false );
+ txtCompValueText->setHidden( false );
+ chkCaseSensitive->setHidden( false );
+ break;
+ }
+
+ //show or hide widgets of regular expressions
+ if( !cmbConditionText->isHidden() && ( cmbConditionText->currentItem() == ID_COMBO_COND_TEXT_REGEXPR || cmbConditionText->currentItem() == ID_COMBO_COND_TEXT_NOT_REGEXPR ) )
+ {
+ if( kRegExpEditorAvailable )
+ btnOpenRegExpEditor->setHidden( false );
+
+ //we don't need case sensitve for regular expressions
+ chkCaseSensitive->setHidden( true );
+ }
+ else
+ {
+ btnOpenRegExpEditor->setHidden( true );
+ }
+}
+
+void FilterCriteriaWidget::slotOpenRegExpEditor( )
+{
+ QDialog* editorDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor" );
+
+ if( editorDialog != NULL )
+ {
+ //kdeutils was installed, so the dialog was found fetch the editor interface
+ KRegExpEditorInterface* editor = static_cast<KRegExpEditorInterface*>( editorDialog->qt_cast( "KRegExpEditorInterface" ) );
+ if( editor == NULL )
+ {
+ KMessageBox::error( this, i18n( "The Regular Expression Editor could not be initilized." ) );
+ return;
+ }
+
+ //use the editor.
+ editor->setRegExp( txtCompValueText->text() );
+
+ //exec the dialog
+ if( editorDialog->exec() == QDialog::Accepted )
+ txtCompValueText->setText( editor->regExp() );
+
+ //delete dialog
+ delete editorDialog;
+ }
+ else
+ KMessageBox::error( this, i18n( "The Regular Expression Editor is not available." ) );
+
+}
+
+void FilterCriteriaWidget::setNumCriteria( int source, int condition, uint value )
+{
+ //set source
+ switch( source )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : cmbSource->setCurrentItem( ID_COMBO_SOURCE_SIZE ); break;
+ default : kdError() << "FilterCriteriaWidget::setNumCriteria: invalid source parameter." << endl;
+ return;
+ }
+
+ //show or hide widgets
+ slotSetWidgets();
+
+ //set condition
+ switch( condition )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_NOT_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_GREATER ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_GREATER_EQUAL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_LESS ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_LESS_EQUAL ); break;
+ default : cmbConditionNum->setCurrentItem( ID_COMBO_COND_NUM_EQUAL ); break;
+ }
+
+ //set comparison value
+ spbCompValueNum->setValue( value );
+
+ //show or hide widgets
+ slotSetWidgets();
+}
+
+void FilterCriteriaWidget::setTextCriteria( int source, int condition, QString value, bool cs )
+{
+ //set source
+ switch( source )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM : cmbSource->setCurrentItem( ID_COMBO_SOURCE_FROM ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO : cmbSource->setCurrentItem( ID_COMBO_SOURCE_TO ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT : cmbSource->setCurrentItem( ID_COMBO_SOURCE_SUBJECT ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER : cmbSource->setCurrentItem( ID_COMBO_SOURCE_HEADER ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT : cmbSource->setCurrentItem( ID_COMBO_SOURCE_ACCOUNT ); break;
+ default : kdError() << "FilterCriteriaWidget::setTextCriteria: invalid source parameter." << endl;
+ return;
+ }
+
+ //set condition
+ switch( condition )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_CONTAINS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_CONTAINS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_EQUALS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_EQUALS );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_REGEXPR );break;
+ case CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_NOT_REGEXPR );break;
+ default : cmbConditionText->setCurrentItem( ID_COMBO_COND_TEXT_CONTAINS ); break;
+ }
+
+ //set value
+ txtCompValueText->setText( value );
+
+ //set case sensitve
+ chkCaseSensitive->setChecked( cs );
+
+ //show or hide widgets
+ slotSetWidgets();
+
+}
+
+FilterCriteria_Type FilterCriteriaWidget::getValues()
+{
+ FilterCriteria_Type crit; //return value
+
+ switch( cmbSource->currentItem() )
+ {
+ case ID_COMBO_SOURCE_FROM : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM; break;
+ case ID_COMBO_SOURCE_TO : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO; break;
+ case ID_COMBO_SOURCE_SIZE : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE; break;
+ case ID_COMBO_SOURCE_SUBJECT : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT; break;
+ case ID_COMBO_SOURCE_HEADER : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER; break;
+ case ID_COMBO_SOURCE_ACCOUNT : crit.source = CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT; break;
+ default : crit.source = 99; break;
+ }
+
+ if( crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM ||
+ crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO ||
+ crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT ||
+ crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER ||
+ crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT )
+ {
+ switch( cmbConditionText->currentItem() )
+ {
+ case ID_COMBO_COND_TEXT_CONTAINS : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS; break;
+ case ID_COMBO_COND_TEXT_NOT_CONTAINS : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS; break;
+ case ID_COMBO_COND_TEXT_EQUALS : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS; break;
+ case ID_COMBO_COND_TEXT_NOT_EQUALS : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS; break;
+ case ID_COMBO_COND_TEXT_REGEXPR : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR; break;
+ case ID_COMBO_COND_TEXT_NOT_REGEXPR : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR; break;
+ default : crit.condition = 99; break;
+ }
+ } else if ( crit.source == CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE )
+ {
+ switch( cmbConditionNum->currentItem() )
+ {
+ case ID_COMBO_COND_NUM_EQUAL : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL; break;
+ case ID_COMBO_COND_NUM_NOT_EQUAL : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL; break;
+ case ID_COMBO_COND_NUM_GREATER : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER; break;
+ case ID_COMBO_COND_NUM_GREATER_EQUAL : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL; break;
+ case ID_COMBO_COND_NUM_LESS : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS; break;
+ case ID_COMBO_COND_NUM_LESS_EQUAL : crit.condition = CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL; break;
+ default : crit.condition = 99;
+ }
+ } else
+ crit.condition = 99;
+
+ crit.txtValue = txtCompValueText->text();
+ crit.numValue = spbCompValueNum->value();
+ crit.cs = chkCaseSensitive->isChecked();
+
+ return crit;
+}
+
+
+#include "filtercriteriawidget.moc"
diff --git a/kshowmail/kcmconfigs/filtercriteriawidget.h b/kshowmail/kcmconfigs/filtercriteriawidget.h
new file mode 100644
index 0000000..14721c2
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtercriteriawidget.h
@@ -0,0 +1,163 @@
+//
+// C++ Interface: filtercriteriawidget
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERCRITERIAWIDGET_H
+#define FILTERCRITERIAWIDGET_H
+
+//Qt headers
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+//KDE headers
+#include <klineedit.h>
+#include <kseparator.h>
+#include <kdialog.h>
+#include <kcombobox.h>
+#include <klocale.h>
+#include <knuminput.h>
+#include <kpushbutton.h>
+#include <kregexpeditorinterface.h>
+#include <ktrader.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kparts/componentfactory.h>
+
+//KShowmail headers
+#include <../constants.h>
+#include <../types.h>
+
+//ComboBox IDs
+#define ID_COMBO_SOURCE_FROM 0
+#define ID_COMBO_SOURCE_TO 1
+#define ID_COMBO_SOURCE_SIZE 2
+#define ID_COMBO_SOURCE_SUBJECT 3
+#define ID_COMBO_SOURCE_HEADER 4
+#define ID_COMBO_SOURCE_ACCOUNT 5
+
+#define ID_COMBO_COND_TEXT_CONTAINS 0
+#define ID_COMBO_COND_TEXT_NOT_CONTAINS 1
+#define ID_COMBO_COND_TEXT_EQUALS 2
+#define ID_COMBO_COND_TEXT_NOT_EQUALS 3
+#define ID_COMBO_COND_TEXT_REGEXPR 4
+#define ID_COMBO_COND_TEXT_NOT_REGEXPR 5
+
+#define ID_COMBO_COND_NUM_EQUAL 0
+#define ID_COMBO_COND_NUM_NOT_EQUAL 1
+#define ID_COMBO_COND_NUM_GREATER 2
+#define ID_COMBO_COND_NUM_GREATER_EQUAL 3
+#define ID_COMBO_COND_NUM_LESS 4
+#define ID_COMBO_COND_NUM_LESS_EQUAL 5
+
+using namespace Types;
+
+/**
+ * @brief Part of the filter setup dialog (class FilterSetupDialog) to show a criteria of the selected filter.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterCriteriaWidget : public QWidget
+{
+
+Q_OBJECT
+
+ public:
+
+ /**
+ * Constructor
+ */
+ FilterCriteriaWidget( QWidget *parent = 0, const char *name = 0 );
+
+ /**
+ * Destructor
+ */
+ ~FilterCriteriaWidget();
+
+ /**
+ * Sets the values of a numeric criteria.
+ * @param source Object of Comparison (see constants.h for valid values)
+ * @param condition Condition of the comparison (see constants.h for valid values)
+ * @param value comparison value
+ */
+ void setNumCriteria( int source, int condition, uint value );
+
+ /**
+ * Sets the values of a text criteria.
+ * @param source Object of Comparison (see constants.h for valid values)
+ * @param condition Condition of the comparison (see constants.h for valid values)
+ * @param value comparison string
+ * @param cs TRUE - comparison is case sensitive; FALSE - comparison is not case sensitive
+ */
+ void setTextCriteria( int source, int condition, QString value, bool cs );
+
+ /**
+ * Returns the values of the criteria.
+ * @return criteria values
+ */
+ FilterCriteria_Type getValues();
+
+ private:
+
+ /**
+ * Combobox to select the source of the criteria.
+ */
+ KComboBox* cmbSource;
+
+ /**
+ * Combobox to select the condition of a text source (From, To, ...)
+ */
+ KComboBox* cmbConditionText;
+
+ /**
+ * Combobox to select the condition of a numeric source (Size, ...)
+ */
+ KComboBox* cmbConditionNum;
+
+ /**
+ * Line for a text comparative value.
+ */
+ KLineEdit* txtCompValueText;
+
+ /**
+ * Spin Box for a numeric comparative value.
+ */
+ KIntNumInput* spbCompValueNum;
+
+ /**
+ * Checkbox to select case sensitive.
+ */
+ QCheckBox* chkCaseSensitive;
+
+ /**
+ * Button to open the regular expression editor.
+ */
+ KPushButton* btnOpenRegExpEditor;
+
+ /**
+ * TRUE - KRegExpEditor is installed and available.
+ */
+ bool kRegExpEditorAvailable;
+
+
+ private slots:
+
+ /**
+ * Connected with combobox cmbSource.
+ * Hides or shows the widgets dependent on the criteria source (text or numeric).
+ */
+ void slotSetWidgets();
+
+ /**
+ * Opens the editor for regular expressions.
+ */
+ void slotOpenRegExpEditor();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/filtersetupdialog.cpp b/kshowmail/kcmconfigs/filtersetupdialog.cpp
new file mode 100644
index 0000000..58e390b
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtersetupdialog.cpp
@@ -0,0 +1,451 @@
+//
+// C++ Implementation: filtersetupdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filtersetupdialog.h"
+
+FilterSetupDialog::FilterSetupDialog( QWidget* parent, FilterSetupItem* item )
+ : KDialogBase( parent, "FilterSetupDialog", true, QString::null, Ok|Cancel, Ok, true )
+{
+ //save pointer to account and view
+ filter = item;
+
+ //set caption
+ if( item != NULL )
+ if( item->getName() == DEFAULT_FILTER_NAME )
+ setCaption( i18n( "New filter" ) );
+ else
+ setCaption( i18n( "Edit filter" ) );
+
+ //create main widget and layout
+ QWidget* pgMain = new QWidget( this );
+ setMainWidget( pgMain );
+ QVBoxLayout* layMain = new QVBoxLayout( pgMain, 0, spacingHint() );
+
+ //create filter name widgets
+ QHBoxLayout* layName = new QHBoxLayout( layMain, spacingHint() );
+ QLabel* lblName = new QLabel( i18n( "Name:" ), pgMain, "lblName" );
+ layName->addWidget( lblName );
+ txtName = new KLineEdit( pgMain, "txtName" );
+ layName->addWidget( txtName );
+
+ //create group boxes and layouts for rules and action
+ QGroupBox* gboxCriteria = new QGroupBox( 0, Qt::Horizontal, i18n( "Filter Criterias" ), pgMain, "gboxCriteria" );
+ QVBoxLayout* layCriteria = new QVBoxLayout( gboxCriteria->layout(), spacingHint() );
+ layMain->addWidget( gboxCriteria );
+
+ QGroupBox* gboxAction = new QGroupBox( 0, Qt::Horizontal, i18n( "Filter Action" ), pgMain, "gboxAction" );
+ QHBoxLayout* layAction = new QHBoxLayout( gboxAction->layout(), spacingHint() );
+ layMain->addWidget( gboxAction );
+
+ //radio buttons to select the kind of linkage between filter criterias
+ QHBoxLayout* layLinkage = new QHBoxLayout( layCriteria, spacingHint(), "layLinkage" );
+ grpLinkage = new QButtonGroup( NULL, "grpLinkage" );
+
+ QRadioButton* btnMatchAll = new QRadioButton( i18n( "Match all of the following" ), gboxCriteria, "btnMatchAll" );
+ QRadioButton* btnMatchAny = new QRadioButton( i18n( "Match any of the following" ), gboxCriteria, "btnMatchAny" );
+ grpLinkage->insert( btnMatchAll, ID_BUTTON_LINKAGE_MATCH_ALL );
+ grpLinkage->insert( btnMatchAny, ID_BUTTON_LINKAGE_MATCH_ANY );
+ layLinkage->addWidget( btnMatchAll );
+ layLinkage->addWidget( btnMatchAny );
+
+ switch( DEFAULT_FILTER_CRITERIA_LINKAGE )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ALL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ANY ); break;
+ default : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ALL ); break;
+ }
+
+ //this widget holds one or more criterias (class FilterCriteriaWidget)
+ wdgCriteriasHolding = new QWidget( gboxCriteria, "gboxCriteria" );
+ layCriteriasHolding = new QVBoxLayout( wdgCriteriasHolding, 0, spacingHint(), "layCriteriasHolding" );
+ layCriteria->addWidget( wdgCriteriasHolding );
+
+ //buttons to add or remove criterias
+ QHBoxLayout* layButtons = new QHBoxLayout( layCriteria, spacingHint(), "layButtons" );
+ btnAddCriteria = new KPushButton( KGuiItem( i18n( "More" ), "button_more", i18n( "Add a further criteria." ) ), gboxCriteria, "btnAddCriteria" );
+ btnRemoveCriteria = new KPushButton( KGuiItem( i18n( "Fewer" ), "button_fewer", i18n( "Remove the last criteria." ) ), gboxCriteria, "btnRemoveCriteria" );
+ btnAddCriteria->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ btnRemoveCriteria->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ layButtons->addWidget( btnAddCriteria );
+ layButtons->addWidget( btnRemoveCriteria );
+ layButtons->addStretch();
+ connect( btnAddCriteria, SIGNAL( clicked() ), this, SLOT( slotAddCriteriaWidget() ) );
+ connect( btnRemoveCriteria, SIGNAL( clicked() ), this, SLOT( slotRemoveCriteriaWidget() ) );
+
+ //create combobox to select action
+ cmbAction = new KComboBox( gboxAction, "cmbAction" );
+ layAction->addWidget( cmbAction );
+ QToolTip::add( cmbAction, i18n( "Choose the action for all mails which are filtered by this filter." ) );
+ connect( cmbAction, SIGNAL( activated( int ) ), this, SLOT( slotActionChanged( int ) ) );
+
+ //insert items
+ cmbAction->insertItem( i18n( "Show" ), ID_COMBO_FILTER_ACTION_PASS );
+ cmbAction->insertItem( i18n( "Delete" ), ID_COMBO_FILTER_ACTION_DELETE );
+ cmbAction->insertItem( i18n( "Mark" ), ID_COMBO_FILTER_ACTION_MARK );
+ cmbAction->insertItem( i18n( "Move" ), ID_COMBO_FILTER_ACTION_MOVE );
+ cmbAction->insertItem( i18n( "Spamcheck" ), ID_COMBO_FILTER_ACTION_SPAMCHECK );
+ cmbAction->insertItem( i18n( "Ignore" ), ID_COMBO_FILTER_ACTION_IGNORE );
+
+ //create edit line to defined the mailbox for move
+ txtMailbox = new KLineEdit( gboxAction );
+ layAction->addWidget( txtMailbox );
+
+ //create wizard button to configure mailbox
+ btnMailboxWizard= new KPushButton( KGuiItem( QString::null, "wizard" ), gboxAction );
+ layAction->addWidget( btnMailboxWizard );
+ QToolTip::add( btnMailboxWizard, i18n( "Choose the mailbox" ) );
+ connect( btnMailboxWizard, SIGNAL( clicked() ), this, SLOT( slotOpenMailBoxWizard() ) );
+
+ //set default action
+ switch( DEFAULT_FILTER_ACTION )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_PASS : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_ACTION_DELETE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MARK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_SPAMCHECK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_SPAMCHECK ); break;
+ case CONFIG_VALUE_FILTER_ACTION_IGNORE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_IGNORE ); break;
+ }
+
+ //enable or disable action widgets
+ slotActionChanged( cmbAction->currentItem() );
+
+ //this adds a first empty criteria widget at the dialog if the given setup item pointer is null
+ //(this means we want to create a new filter)
+ if( item == NULL )
+ {
+ slotAddCriteriaWidget();
+ }
+
+ //write values of the given filter into the dialog items
+ if( filter != NULL )
+ fillDialog();
+}
+
+
+FilterSetupDialog::~FilterSetupDialog()
+{
+}
+
+void FilterSetupDialog::fillDialog( )
+{
+ //check for valid pointer to the setup item
+ if( filter == NULL )
+ {
+ kdError() << "FilterSetupDialog::fillDialog: The given pointer to the filter setup item is NULL." << endl;
+ return;
+ }
+
+ //set filter name
+ txtName->setText( filter->getName() );
+
+ //set linkage
+ switch( filter->getCriteriaLinkage() )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ALL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ANY ); break;
+ default : kdError() << "FilterSetupDialog::fillDialog: The Filter Setup Item of filter " << filter->getName() << " has returned an invalid linkage value. Set default value." << endl;
+ switch( DEFAULT_FILTER_CRITERIA_LINKAGE )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ALL ); break;
+ case CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY : grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ANY ); break;
+ default: kdError() << "FilterSetupDialog::fillDialog: The default value DEFAULT_FILTER_CRITERIA_LINKAGE in constants.h is also invalid. Set linkage to ALL." << endl;
+ grpLinkage->setButton( ID_BUTTON_LINKAGE_MATCH_ALL );
+ break;
+ }
+ break;
+ }
+
+ //set criterias
+ FilterCriteriaList_Type criteriaList = filter->getCriteriaList();
+
+ if( !criteriaList.empty() )
+ {
+ FilterCriteriaList_Type::iterator it;
+ for( it = criteriaList.begin(); it != criteriaList.end(); ++it )
+ {
+ //get source and condition
+ int source = (*it).source;
+ int condition = (*it).condition;
+
+ //depend on the source we add a numeric or text criteria
+ switch( source )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT : addCriteriaWidget( source, condition, (*it).txtValue, (*it).cs ); break;
+
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : addCriteriaWidget( source, condition, (*it).numValue ); break;
+ default : kdError() << "FilterSetupDialog::fillDialog: The Filter Setup Item of filter " << filter->getName() << " has returned an invalid criteria. Add an empty criteria." << endl;
+ break;
+ }
+ }
+ }
+ else
+ //just add a empty criteria widget
+ slotAddCriteriaWidget();
+
+
+ //set action
+ switch( filter->getAction() )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_PASS : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_ACTION_DELETE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MARK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_IGNORE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_IGNORE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_SPAMCHECK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_SPAMCHECK ); break;
+ default : kdError() << "FilterSetupDialog:: fillDialog: The Filter Setup Item of filter " << filter->getName() << " has returned an invalid action value. Set default value." << endl;
+ switch( DEFAULT_FILTER_ACTION )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_PASS : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_PASS ); break;
+ case CONFIG_VALUE_FILTER_ACTION_DELETE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_DELETE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MARK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MARK ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_MOVE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_IGNORE : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_IGNORE ); break;
+ case CONFIG_VALUE_FILTER_ACTION_SPAMCHECK : cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_SPAMCHECK ); break;
+ default: kdError() << "FilterSetupDialog::fillDialog: The default value DEFAULT_FILTER_ACTION in constants.h is also invalid. Set action to PASS." << endl;
+ cmbAction->setCurrentItem( ID_COMBO_FILTER_ACTION_PASS );
+ break;
+ }
+ }
+
+ //set mailbox name if action is MOVE
+ if( filter->getAction() == CONFIG_VALUE_FILTER_ACTION_MOVE )
+ txtMailbox->setText( filter->getMailBox() );
+
+ //enable or disable action widgets
+ slotActionChanged( cmbAction->currentItem() );
+
+}
+
+FilterCriteriaWidget* FilterSetupDialog::slotAddCriteriaWidget( )
+{
+ //create a new widget
+ FilterCriteriaWidget* crit = new FilterCriteriaWidget( wdgCriteriasHolding );
+ crit->setHidden( false ); //the new widgets are hidden by default
+
+ //insert it into the layout
+ layCriteriasHolding->addWidget( crit );
+
+ //hide remove button if necessary
+ const QObjectList* critList = wdgCriteriasHolding->children();
+
+ if( critList != NULL )
+ {
+ if( critList->count() <= 2 )
+ btnRemoveCriteria->setEnabled( false );
+ else
+ btnRemoveCriteria->setEnabled( true );
+ }
+
+
+
+ return crit;
+}
+
+void FilterSetupDialog::slotRemoveCriteriaWidget( )
+{
+ //get a list of all criteria widgets
+ const QObjectList* critList = wdgCriteriasHolding->children();
+
+ //return, if the pointer to the list is invalid
+ if( critList == NULL )
+ {
+ kdError() << "FilterSetupDialog::slotRemoveCriteriaWidget: No object found in the criteria widget holding." << endl;;
+ return;
+ }
+
+ //return, if the holding widget doesn't contain a criteria widget
+ //the count of children has to be greater than 2, because the layout is the first child
+ //and one criteria must always be present.
+ if( critList->count() <= 2 ) return;
+
+ //get iterator
+ QObjectListIterator it( *critList );
+
+ //get last child
+ QObject* obj = it.toLast();
+
+ //remove last child
+ if( obj->isA( "FilterCriteriaWidget" ) )
+ {
+ ((QWidget*)obj)->setHidden( true );
+ layCriteriasHolding->remove( (QWidget*)obj );
+ wdgCriteriasHolding->removeChild( obj );
+ }
+ else
+ kdError() << "FilterSetupDialog::slotRemoveCriteriaWidget: the last object of the criteria widget holding is not a criteria widget." << endl;
+
+ //hide remove button if necessary
+ if( critList->count() <= 2 )
+ btnRemoveCriteria->setEnabled( false );
+ else
+ btnRemoveCriteria->setEnabled( true );
+
+}
+
+void FilterSetupDialog::addCriteriaWidget( int source, int condition, uint value )
+{
+ //check source and condition
+ if( source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE )
+ {
+ kdError() << "FilterSetupDialog::addCriteriaWidget: invalid source parameter." << endl;
+ return;
+ }
+
+ if( condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL )
+ {
+ kdError() << "FilterSetupDialog::addCriteriaWidget: invalid condition parameter." << endl;
+ return;
+ }
+
+ //create widget
+ FilterCriteriaWidget* crit = slotAddCriteriaWidget();
+
+ //set values
+ crit->setNumCriteria( source, condition, value );
+}
+
+void FilterSetupDialog::addCriteriaWidget( int source, int condition, QString value, bool cs )
+{
+ //check source and condition
+ if( source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM &&
+ source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO &&
+ source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT &&
+ source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER &&
+ source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT )
+ {
+ kdError() << "FilterSetupDialog::addCriteriaWidget: invalid source parameter." << endl;
+ return;
+ }
+
+ if( condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR &&
+ condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR )
+ {
+ kdError() << "FilterSetupDialog::addCriteriaWidget: invalid condition parameter." << endl;
+ return;
+ }
+
+ //create widget
+ FilterCriteriaWidget* crit = slotAddCriteriaWidget();
+
+ //set values
+ crit->setTextCriteria( source, condition, value, cs );
+
+}
+
+void FilterSetupDialog::slotOk()
+{
+
+ //here we write the settings back to the filter setup item
+
+ //filter name
+ filter->setName( txtName->text() );
+
+ //linkage
+ switch( grpLinkage->selectedId() )
+ {
+ case ID_BUTTON_LINKAGE_MATCH_ALL : filter->setCriteriaLinkage( CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL ); break;
+ case ID_BUTTON_LINKAGE_MATCH_ANY : filter->setCriteriaLinkage( CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY ); break;
+ default : kdDebug() << "FilterSetupDialog::slotOk: Invalid linkage value. Set default value." << endl;
+ filter->setCriteriaLinkage( DEFAULT_FILTER_CRITERIA_LINKAGE ); break;
+ }
+
+ //action
+ switch( cmbAction->currentItem() )
+ {
+ case ID_COMBO_FILTER_ACTION_PASS : filter->setAction( CONFIG_VALUE_FILTER_ACTION_PASS ); break;
+ case ID_COMBO_FILTER_ACTION_DELETE : filter->setAction( CONFIG_VALUE_FILTER_ACTION_DELETE ); break;
+ case ID_COMBO_FILTER_ACTION_MARK : filter->setAction( CONFIG_VALUE_FILTER_ACTION_MARK ); break;
+ case ID_COMBO_FILTER_ACTION_MOVE : filter->setAction( CONFIG_VALUE_FILTER_ACTION_MOVE ); break;
+ case ID_COMBO_FILTER_ACTION_IGNORE : filter->setAction( CONFIG_VALUE_FILTER_ACTION_IGNORE ); break;
+ case ID_COMBO_FILTER_ACTION_SPAMCHECK : filter->setAction( CONFIG_VALUE_FILTER_ACTION_SPAMCHECK ); break;
+ default : kdDebug() << "FilterSetupDialog::slotOk: Invalid action value. Set default value." << endl;
+ filter->setAction( DEFAULT_FILTER_ACTION ); break;
+ }
+
+ //mailbox name if action is MOVE
+ if( cmbAction->currentItem() == ID_COMBO_FILTER_ACTION_MOVE )
+ filter->setMailBox( txtMailbox->text() );
+
+ //criteria widgets
+
+ //get list of all children of the criterias holding widget
+ const QObjectList* children = wdgCriteriasHolding->children();
+
+ //get iterator of the list
+ QObjectListIterator it( *children );
+
+ QObject* obj; //current child object
+ FilterCriteriaList_Type critList; //list of criterias; will be give to the filter setup item
+
+ //iterate over the children list
+ while ( ( obj = it.current() ) != NULL )
+ {
+ //get next child
+ ++it;
+
+ if( obj->isA( "FilterCriteriaWidget" ) ) //check for criteria object
+ {
+ //get the values of the criteria
+ FilterCriteria_Type crit = ( (FilterCriteriaWidget*)obj )->getValues();
+
+ //append the new criteria at the end of the criteria list
+ critList.push_back( crit );
+ }
+ }
+
+ //pass criteria list to filter setup item
+ filter->setCriteriaList( critList );
+
+ //call slot of super class to close the dialog
+ KDialogBase::slotOk();
+}
+
+void FilterSetupDialog::slotActionChanged( int index )
+{
+ switch( index )
+ {
+ case ID_COMBO_FILTER_ACTION_MOVE : txtMailbox->setEnabled( true );
+ if( txtMailbox->text() == "" ) txtMailbox->setText( DEFAULT_FILTER_ACTION_MOVE_MAILBOX );
+ btnMailboxWizard->setHidden( false );
+ break;
+ default : txtMailbox->setEnabled( false );
+ btnMailboxWizard->setHidden( true );
+ break;
+ }
+}
+
+void FilterSetupDialog::slotOpenMailBoxWizard( )
+{
+ MailBoxWizard wizard( this, "malboxwizard" );
+ wizard.setCaption( i18n( "Mailbox Select" ) );
+ int res = wizard.exec();
+
+ if( res == QDialog::Accepted )
+ txtMailbox->setText( wizard.getPath() );
+
+}
+
+
+#include "filtersetupdialog.moc"
diff --git a/kshowmail/kcmconfigs/filtersetupdialog.h b/kshowmail/kcmconfigs/filtersetupdialog.h
new file mode 100644
index 0000000..a9fd761
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtersetupdialog.h
@@ -0,0 +1,191 @@
+//
+// C++ Interface: filtersetupdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERSETUPDIALOG_H
+#define FILTERSETUPDIALOG_H
+
+//button IDs
+#define ID_BUTTON_LINKAGE_MATCH_ALL 1
+#define ID_BUTTON_LINKAGE_MATCH_ANY 2
+
+//Qt headers
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qvbox.h>
+#include <qobjectlist.h>
+#include <qtooltip.h>
+#include <qlabel.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+
+//KShowmail headers
+#include "filtersetupitem.h"
+#include "filtercriteriawidget.h"
+#include "../constants.h"
+#include "mailboxwizard.h"
+
+//IDs of the action combo box
+#define ID_COMBO_FILTER_ACTION_PASS 0
+#define ID_COMBO_FILTER_ACTION_DELETE 1
+#define ID_COMBO_FILTER_ACTION_MARK 2
+#define ID_COMBO_FILTER_ACTION_MOVE 3
+#define ID_COMBO_FILTER_ACTION_SPAMCHECK 4
+#define ID_COMBO_FILTER_ACTION_IGNORE 5
+
+/**
+ * @brief Dialog to setup a filter.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterSetupDialog : public KDialogBase
+{
+
+ Q_OBJECT
+
+ public:
+ /**
+ * General constructor
+ * @param parent parent of the dialog
+ * @param item filter to setup;
+ */
+ FilterSetupDialog( QWidget* parent, FilterSetupItem* item = NULL );
+
+ /**
+ * Destructor
+ */
+ ~FilterSetupDialog();
+
+ private:
+
+ /**
+ * filter to setup
+ */
+ FilterSetupItem* filter;
+
+ /**
+ * View which shows the filter items.
+ */
+ KListView* ListView;
+
+ /**
+ * Contains the filter name.
+ */
+ KLineEdit* txtName;
+
+ /**
+ * Combines the radio buttons to select the kind of linkage between the criterias.
+ */
+ QButtonGroup* grpLinkage;
+
+ /**
+ * This widget holds one ore more filter criteria dialogs (class FilterCriteriaWidget).
+ */
+ QWidget* wdgCriteriasHolding;
+
+ /**
+ * Layout for wdgCriterias.
+ */
+ QVBoxLayout* layCriteriasHolding;
+
+ /**
+ * Button to add a criteria dialog.
+ */
+ KPushButton* btnAddCriteria;
+
+ /**
+ * Button to remove the last criteria.
+ */
+ KPushButton* btnRemoveCriteria;
+
+ /**
+ * Combobox to select the action.
+ */
+ KComboBox* cmbAction;
+
+ /**
+ * If selected, the mails will be moved to the mailbox which is written in this edit line.
+ */
+ KLineEdit* txtMailbox;
+
+ /**
+ * This button opens a wizard which will help to get the right mailbox
+ */
+ KPushButton* btnMailboxWizard;
+
+
+ protected:
+
+ /**
+ * Writes the values of the given filter into the dialog items.
+ */
+ void fillDialog();
+
+ /**
+ * Adds a criteria widget dialog with values for numeric comparison.
+ * @param source Object of Comparison. It accepts only numeric objects (e.g. Size) (see constants.h for valid values)
+ * @param condition Condition of the comparison (see constants.h for valid values)
+ * @param value comparison value
+ */
+ void addCriteriaWidget( int source, int condition, uint value );
+
+ /**
+ * Adds a criteria widget dialog with values for text comparison.
+ * @param source Object of Comparison. It accepts only text objects (e.g. Subject) (see constants.h for valid values)
+ * @param condition Condition of the comparison (see constants.h for valid values)
+ * @param value comparison string
+ * @param cs TRUE - comparison is case sensitive; FALSE - comparison is not case sensitive
+ */
+ void addCriteriaWidget( int source, int condition, QString value, bool cs );
+
+
+ protected slots:
+
+ /**
+ * Overwritten method of KDialogBase.
+ * Called if OK was clicked.
+ * Stores the entered values into the given account item.
+ * If no item was given it creates a new one.
+ * After then it invokes slotOk() of KDialogBase.
+ */
+ void slotOk();
+
+ /**
+ * Connected with combobox cmbAction.
+ * Enables or disables additional widgets for action configuration.
+ * @param index position (index) of the selected action
+ */
+ void slotActionChanged( int index );
+
+ /**
+ * Adds a empty critera dialog widget.
+ * @return Pointer to the new widget
+ */
+ FilterCriteriaWidget* slotAddCriteriaWidget();
+
+ /**
+ * Removes the last criteria dialog widget.
+ */
+ void slotRemoveCriteriaWidget();
+
+ /**
+ * Connected with button btnMailboxWizard.
+ * Opens a wizard to configure the mailbox
+ */
+ void slotOpenMailBoxWizard();
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/filtersetupitem.cpp b/kshowmail/kcmconfigs/filtersetupitem.cpp
new file mode 100644
index 0000000..ef16a53
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtersetupitem.cpp
@@ -0,0 +1,347 @@
+//
+// C++ Implementation: filtersetupitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "filtersetupitem.h"
+
+FilterSetupItem::FilterSetupItem( KListView* parent )
+ : KListViewItem( parent )
+{
+ //set default number
+ number = 0;
+
+ init();
+}
+
+FilterSetupItem::FilterSetupItem( KListView* parent, uint num )
+ : KListViewItem( parent )
+{
+ //store the given filter number
+ number = num;
+
+ init();
+}
+
+FilterSetupItem::~FilterSetupItem()
+{
+}
+
+void FilterSetupItem::init( )
+{
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //set default values
+ setName( i18n( DEFAULT_FILTER_NAME ) );
+ setCriteriaLinkage( DEFAULT_FILTER_CRITERIA_LINKAGE );
+ setAction( DEFAULT_FILTER_ACTION );
+
+ //show number in column
+ setText( ColNumber, QString("%1").arg( number ) );
+}
+
+void FilterSetupItem::setName( QString name )
+{
+ this->name = name;
+
+ //show name in the list view
+ setText( ColName, name );
+}
+
+QString FilterSetupItem::getName( ) const
+{
+ return name;
+}
+
+void FilterSetupItem::setNumber( uint number )
+{
+ this->number = number;
+
+ //show number in column
+ setText( ColNumber, QString("%1").arg( number ) );
+}
+
+void FilterSetupItem::setAction( int action )
+{
+ if( action == CONFIG_VALUE_FILTER_ACTION_PASS ||
+ action == CONFIG_VALUE_FILTER_ACTION_DELETE ||
+ action == CONFIG_VALUE_FILTER_ACTION_MARK ||
+ action == CONFIG_VALUE_FILTER_ACTION_MOVE ||
+ action == CONFIG_VALUE_FILTER_ACTION_IGNORE ||
+ action == CONFIG_VALUE_FILTER_ACTION_SPAMCHECK )
+ {
+ this->action = action;
+ }
+ else
+ {
+ kdError() << "FilterSetupItem::setAction: Invalid parameter for action given. Parameter: " << action << endl;
+ this->action = DEFAULT_FILTER_ACTION;
+ return;
+ }
+
+ //update the text of the rule column
+ updateActionColumn();
+}
+
+void FilterSetupItem::save( )
+{
+ //build group name
+ QString group;
+ group = QString( "%1%2" ).arg( CONFIG_GROUP_FILTER ).arg( number );
+
+ //first delete the group to clear it of old criteria entries
+ config->deleteGroup( group );
+
+ //set group
+ config->setGroup( group );
+
+ //write entries
+ config->writeEntry( CONFIG_ENTRY_FILTER_NAME, name );
+
+ if( linkage == CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL ||
+ linkage == CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY )
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_CRITERIA_LINKAGE, linkage );
+ }
+ else
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_CRITERIA_LINKAGE, DEFAULT_FILTER_CRITERIA_LINKAGE );
+ }
+
+ if( action == CONFIG_VALUE_FILTER_ACTION_PASS ||
+ action == CONFIG_VALUE_FILTER_ACTION_DELETE ||
+ action == CONFIG_VALUE_FILTER_ACTION_MARK ||
+ action == CONFIG_VALUE_FILTER_ACTION_MOVE ||
+ action == CONFIG_VALUE_FILTER_ACTION_IGNORE ||
+ action == CONFIG_VALUE_FILTER_ACTION_SPAMCHECK )
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_ACTION, action );
+ }
+ else
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_ACTION, DEFAULT_FILTER_ACTION );
+ }
+
+ //write action parameter
+ switch( action )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_MOVE :
+ config->writeEntry( CONFIG_ENTRY_FILTER_MOVE_MAILBOX, mailbox );
+ break;
+
+ default: break;
+ }
+
+ //write criteria list and number of criterias
+ if( !criteriaList.empty() )
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_CRITERIA_NUMBER, criteriaList.size() );
+
+ int ctr = 0; //number of the current criteria
+ FilterCriteriaList_Type::iterator it;
+ for( it = criteriaList.begin(); it != criteriaList.end(); ++it )
+ {
+ ctr++;
+
+ config->writeEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_SOURCE ).arg( ctr ), (*it).source );
+ config->writeEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CONDITION ).arg( ctr ), (*it).condition );
+
+ switch( (*it).source )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER :
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT : config->writeEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( ctr ), (*it).txtValue );
+ config->writeEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CASESENSITIVE ).arg( ctr ), (*it).cs );
+ break;
+
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : config->writeEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( ctr ), (*it).numValue );
+ break;
+ }
+ }
+ }
+ else
+ {
+ config->writeEntry( CONFIG_ENTRY_FILTER_CRITERIA_NUMBER, 0 );
+ }
+
+}
+
+void FilterSetupItem::setCriteriaLinkage( int linkage )
+{
+ if( linkage == CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL ||
+ linkage == CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY )
+ {
+ this->linkage = linkage;
+ }
+ else
+ {
+ kdError() << "FilterSetupItem::setCriteriaLinkage: Invalid parameter for criteria linkage given. Parameter: " << linkage << endl;
+ this->linkage = DEFAULT_FILTER_CRITERIA_LINKAGE;
+ return;
+ }
+
+}
+
+void FilterSetupItem::setCriteriaList( FilterCriteriaList_Type list )
+{
+ criteriaList = list;
+}
+
+void FilterSetupItem::setMailBox( QString mailbox )
+{
+ this->mailbox = mailbox;
+
+ //update the text of the rule column
+ updateActionColumn();
+}
+
+int FilterSetupItem::getCriteriaLinkage( ) const
+{
+ return linkage;
+}
+
+int FilterSetupItem::getAction( ) const
+{
+ return action;
+}
+
+QString FilterSetupItem::getMailBox( ) const
+{
+ if( action == CONFIG_VALUE_FILTER_ACTION_MOVE )
+ return mailbox;
+ else
+ return QString( "" );
+}
+
+FilterCriteriaList_Type FilterSetupItem::getCriteriaList( ) const
+{
+ return criteriaList;
+}
+
+uint FilterSetupItem::getNumber( ) const
+{
+ return number;
+}
+
+int FilterSetupItem::compare( QListViewItem * i, int col, bool ascending ) const
+{
+ if( col == ColNumber )
+ {
+ return text( ColNumber ).toInt() - i->text( ColNumber ).toInt();
+ }
+ else
+ return key( col, ascending ).compare( i->key( col, ascending) );
+
+}
+
+void FilterSetupItem::updateActionColumn( )
+{
+ QString strAction; //filter action
+
+ //build action
+ switch( action )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_PASS : strAction = i18n( "Show" ); break;
+ case CONFIG_VALUE_FILTER_ACTION_DELETE : strAction = i18n( "Delete" ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MARK : strAction = i18n( "Mark" ); break;
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : strAction = i18n( "Move to %1").arg( mailbox ); break;
+ case CONFIG_VALUE_FILTER_ACTION_IGNORE : strAction = i18n( "Ignore"); break;
+ case CONFIG_VALUE_FILTER_ACTION_SPAMCHECK : strAction = i18n( "Check for spam" ); break;
+ default : strAction = i18n( "Unknown action" ); break;
+ }
+
+ //set text
+ setText( ColAction, QString( " %1" ).arg( strAction ) );
+}
+
+void FilterSetupItem::load( )
+{
+ //set group
+ config->setGroup( QString( "%1%2" ).arg( CONFIG_GROUP_FILTER ).arg( number ) );
+
+ //get name
+ setName( config->readEntry( CONFIG_ENTRY_FILTER_NAME, DEFAULT_FILTER_NAME ) );
+
+ //get linkage
+ setCriteriaLinkage( config->readNumEntry( CONFIG_ENTRY_FILTER_CRITERIA_LINKAGE, DEFAULT_FILTER_CRITERIA_LINKAGE ) );
+ if( linkage != CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL && linkage != CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY )
+ setCriteriaLinkage( DEFAULT_FILTER_CRITERIA_LINKAGE );
+
+ //get action
+ setAction( config->readNumEntry( CONFIG_ENTRY_FILTER_ACTION, DEFAULT_FILTER_ACTION ) );
+ if( action != CONFIG_VALUE_FILTER_ACTION_PASS &&
+ action != CONFIG_VALUE_FILTER_ACTION_DELETE &&
+ action != CONFIG_VALUE_FILTER_ACTION_MARK &&
+ action != CONFIG_VALUE_FILTER_ACTION_MOVE &&
+ action != CONFIG_VALUE_FILTER_ACTION_IGNORE &&
+ action != CONFIG_VALUE_FILTER_ACTION_SPAMCHECK )
+ setAction( DEFAULT_FILTER_ACTION );
+
+ //get action parameter
+ switch( action )
+ {
+ case CONFIG_VALUE_FILTER_ACTION_MOVE : setMailBox( config->readEntry( CONFIG_ENTRY_FILTER_MOVE_MAILBOX, DEFAULT_FILTER_ACTION_MOVE_MAILBOX ) ); break;
+ default : setMailBox( QString::null );
+ }
+
+ //get number of criterias
+ uint numCrit = config->readNumEntry( CONFIG_ENTRY_FILTER_CRITERIA_NUMBER, 0 );
+
+ //get criterias
+ for( uint ctr = 1; ctr <= numCrit; ctr++ )
+ {
+ struct FilterCriteria_Type crit;
+
+ crit.source = config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_SOURCE ).arg( ctr ), DEFAULT_FILTER_CRITERIA_SOURCE );
+ if( crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_FROM &&
+ crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_TO &&
+ crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SUBJECT &&
+ crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_HEADER &&
+ crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_ACCOUNT &&
+ crit.source != CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE )
+ crit.source = DEFAULT_FILTER_CRITERIA_SOURCE;
+
+ switch( crit.source )
+ {
+ case CONFIG_VALUE_FILTER_CRITERIA_SOURCE_SIZE : crit.condition = config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CONDITION ).arg( ctr ), DEFAULT_FILTER_CRITERIA_COND_NUM );
+ if( crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_EQUAL &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_NOT_EQUAL &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_GREATER_EQUAL &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_NUM_LESS_EQUAL )
+ crit.condition = DEFAULT_FILTER_CRITERIA_COND_NUM;
+ crit.numValue = config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( ctr ), DEFAULT_FILTER_CRITERIA_SIZE );
+ break;
+
+ default : crit.condition = config->readNumEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CONDITION ).arg( ctr ), DEFAULT_FILTER_CRITERIA_COND_TEXT );
+ if( crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_CONTAINS &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_CONTAINS &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_EQUALS &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_EQUALS &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_REGEXPR &&
+ crit.condition != CONFIG_VALUE_FILTER_CRITERIA_COND_TEXT_NOT_REGEXPR )
+ crit.condition = DEFAULT_FILTER_CRITERIA_COND_TEXT;
+ crit.txtValue = config->readEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_VALUE ).arg( ctr ) );
+ crit.cs = config->readBoolEntry( QString( "%1%2" ).arg( CONFIG_ENTRY_FILTER_CRITERIA_CASESENSITIVE ).arg( ctr ), DEFAULT_FILTER_CRITERIA_CASE_SENSITIVE );
+ break;
+ }
+
+ criteriaList.push_back( crit );
+
+ }
+
+
+}
+
+
+
diff --git a/kshowmail/kcmconfigs/filtersetupitem.h b/kshowmail/kcmconfigs/filtersetupitem.h
new file mode 100644
index 0000000..1d1bf02
--- /dev/null
+++ b/kshowmail/kcmconfigs/filtersetupitem.h
@@ -0,0 +1,240 @@
+//
+// C++ Interface: filtersetupitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FILTERSETUPITEM_H
+#define FILTERSETUPITEM_H
+
+//KDE headers
+#include <klistview.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+//KShowmail headers
+#include "../constants.h"
+#include "../types.h"
+
+using namespace Types;
+
+/**
+ * @brief This class is used in ConfigFilter to show the available filters in the list view and to store a filter setup.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class FilterSetupItem : public KListViewItem
+{
+
+ public:
+
+ /**
+ * Column Numbers.
+ */
+ enum Column{ ColNumber = 0, ColName = 1, ColAction = 2 };
+
+ /**
+ * General Constructor
+ * @param parent the list view
+ */
+ FilterSetupItem( KListView* parent );
+
+ /**
+ * Constructor
+ * @param parent the list view
+ * @param num filter number
+ */
+ FilterSetupItem( KListView* parent, uint num );
+
+ /**
+ * Destructor
+ */
+ ~FilterSetupItem();
+
+ /**
+ * Sets the filter name.
+ * @param name filter name
+ * @see name
+ * @see getName
+ */
+ void setName( QString name );
+
+ /**
+ * Returns the name of this filter.
+ * @return filter name
+ * @see name
+ * @see setName
+ */
+ QString getName() const;
+
+ /**
+ * Sets the filter number.
+ * @param number filter number.
+ * @see number
+ * @see getNumber
+ */
+ void setNumber( uint number );
+
+ /**
+ * Returns the filter number.
+ * @return filter number
+ * @see number
+ * @see setNumber
+ */
+ uint getNumber() const;
+
+ /**
+ * Sets the action. See constants.h for valid values (CONFIG_VALUE_FILTER_ACTION...).
+ * @param action
+ * @see getAction
+ * @see action
+ */
+ void setAction( int action );
+
+ /**
+ * Returns the action of this filter.
+ * See constants.h for possible values (CONFIG_VALUE_FILTER_ACTION...).
+ * @return action code
+ * @see setAction
+ * @see action
+ */
+ int getAction() const;
+
+ /**
+ * Sets the mailbox of a move action.
+ * @param mailbox name of the mailbox
+ * @see setMailBox
+ * @see mailbox
+ */
+ void setMailBox( QString mailbox );
+
+ /**
+ * Returns the mailbox name of a move action if this action is selected. Otherwise it returns an empty string.
+ * @return mailbox name
+ * @see setMailBox
+ * @see mailbox
+ */
+ QString getMailBox() const;
+
+ /**
+ * Sets the criteria linkage.
+ * Valid values are CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL (all criterias have to satisy) or CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY (at least one criteria has to satisy ).
+ * @param linkage criteria linkage
+ * @see linkage
+ */
+ void setCriteriaLinkage( int linkage );
+
+ /**
+ * Returns the criteria linkage.
+ * Possible values are CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL (all criterias have to satisy) or CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY (at least one criteria has to satisy ).
+ * @return criteria linkage
+ * @see setCriteriaLinkage
+ * @see linkage
+ */
+ int getCriteriaLinkage() const;
+
+ /**
+ * Sets the criteria list.
+ * @param list criteria list
+ * @see criteriaList
+ * @see getCriteriaList
+ * @see Types::FilterCriteriaList_Type
+ */
+ void setCriteriaList( FilterCriteriaList_Type list );
+
+ /**
+ * Returns the criteria list.
+ * @return criteria list
+ * @see criteriaList
+ * @see setCriteriaList
+ * @see Types::FilterCriteriaList_Type
+ */
+ FilterCriteriaList_Type getCriteriaList() const;
+
+ /**
+ * Saves the settings to the configuration file.
+ * The group is named CONFIG_GROUP_FILTER + filter number, e.g. Filter12.
+ */
+ void save();
+
+ /**
+ * Reimplemantation of QListViewItem::compare.
+ * Compares this list view item to i using the column col in ascending order. Reutrns <0 if this item is less than i,
+ * 0 if they are equal and >0 if this item is greater than i. The parameter ascneding will be ignored.
+ * @param i pointer to the second view item
+ * @param col number of the sorted column
+ * @param ascending ignored
+ */
+ virtual int compare( QListViewItem* i, int col, bool ascending ) const;
+
+ /**
+ * Reads the settings from the config file.
+ * The group is named CONFIG_GROUP_FILTER + filter number, e.g. Filter12.
+ */
+ void load();
+
+
+ private:
+
+ /**
+ * filter name
+ */
+ QString name;
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * List of filter criterias.
+ */
+ FilterCriteriaList_Type criteriaList;
+
+ /**
+ * Filter Action
+ * See constants.h for valid values (CONFIG_VALUE_FILTER_ACTION...).
+ */
+ int action;
+
+ /**
+ * Contains the mailbox name if the move action is selected.
+ */
+ QString mailbox;
+
+ /**
+ * Filter Number.
+ * The filters will be showed and run through in ascending order. The first number is "0".
+ */
+ uint number;
+
+ /**
+ * Criteria Linkage.
+ * Valid values are CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ALL (all criterias have to satisy) or CONFIG_VALUE_FILTER_CRITERIA_LINKAGE_MATCH_ANY (at least one criteria has to satisy ).
+ */
+ int linkage;
+
+ protected:
+
+ /**
+ * Initializes the object.
+ */
+ void init();
+
+ /**
+ * Updates the text of the rule column.
+ */
+ void updateActionColumn();
+
+
+
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/kshowmailconfigaccounts.desktop b/kshowmail/kcmconfigs/kshowmailconfigaccounts.desktop
new file mode 100644
index 0000000..e8da1f9
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfigaccounts.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Accounts
+Name[de]=Konten
+Name[es]=Cuentas
+Comment=Accounts
+Comment[de]=Konten
+Comment[es]=Cuentas
+Icon=network
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfigaccounts
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfigaccounts
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=5
+X-KDE-ParentApp=kshowmail
diff --git a/kshowmail/kcmconfigs/kshowmailconfigactions.desktop b/kshowmail/kcmconfigs/kshowmailconfigactions.desktop
new file mode 100644
index 0000000..a925df8
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfigactions.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Actions
+Name[de]=Aktionen
+Name[es]=Acciones
+Comment=actions
+Comment[de]=Aktionen
+Comment[es]=Acciones
+Icon=launch
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfigactions
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfigactions
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=2
+X-KDE-ParentApp=kshowmail
diff --git a/kshowmail/kcmconfigs/kshowmailconfigdisplay.desktop b/kshowmail/kcmconfigs/kshowmailconfigdisplay.desktop
new file mode 100644
index 0000000..ac5e02b
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfigdisplay.desktop
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Display
+Name[de]=Erscheinungsbild
+Name[es]=Visualización
+Comment=Display Options
+Comment[de]=Erscheinungsbild
+Comment[es]=Opciones de visualización
+Icon=looknfeel
+ServiceTypes=KCModule
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfigdisplay
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfigdisplay
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=3
+X-KDE-ParentApp=kshowmail \ No newline at end of file
diff --git a/kshowmail/kcmconfigs/kshowmailconfigfilter.desktop b/kshowmail/kcmconfigs/kshowmailconfigfilter.desktop
new file mode 100644
index 0000000..cd6b801
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfigfilter.desktop
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Type=Service
+Name=Filter
+Name[de]=Filter
+Name[es]=Filtro
+Comment=Filter
+Comment[de]=Filter
+Comment[es]=Filtro
+Icon=filter
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfigfilter
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfigfilter
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=6
+X-KDE-ParentApp=kshowmail
diff --git a/kshowmail/kcmconfigs/kshowmailconfiggeneral.desktop b/kshowmail/kcmconfigs/kshowmailconfiggeneral.desktop
new file mode 100644
index 0000000..1f4db6d
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfiggeneral.desktop
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=General
+Name[de]=Allgemeines
+Name[es]=General
+Comment=General Options
+Comment[de]=Allgemeine Einstellungen
+Comment[es]=Opciones generales
+Icon=exec
+ServiceTypes=KCModule
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfiggeneral
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfiggeneral
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=4
+X-KDE-ParentApp=kshowmail \ No newline at end of file
diff --git a/kshowmail/kcmconfigs/kshowmailconfiglog.desktop b/kshowmail/kcmconfigs/kshowmailconfiglog.desktop
new file mode 100644
index 0000000..4a5dc5f
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfiglog.desktop
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Log
+Name[de]=Log
+Name[es]=Registro
+Comment=Log
+Comment[de]=Log
+Comment[es]=Registro
+Icon=kedit
+ServiceTypes=KCModule
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfiglog
+X-KDE-FactoryName=kshowmailconfiglog
+X-KDE-Weight=7
+X-KDE-ParentApp=kshowmail
diff --git a/kshowmail/kcmconfigs/kshowmailconfigspamcheck.desktop b/kshowmail/kcmconfigs/kshowmailconfigspamcheck.desktop
new file mode 100644
index 0000000..5f6cb3b
--- /dev/null
+++ b/kshowmail/kcmconfigs/kshowmailconfigspamcheck.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Type=Service
+Name=Spam Checking
+Name[de]=Spam-Prüfung
+Name[es]=Análisis de spam
+Comment=Checking for Spam
+Comment[de]=Prüfung auf Spam
+Comment[es]=Analizar el spam
+Icon=kfind
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kshowmailconfigspamcheck
+X-KDE-CfgDlgHierarchy=
+X-KDE-FactoryName=kshowmailconfigspamcheck
+X-KDE-IsHiddenByDefault=
+X-KDE-RootOnly=
+X-KDE-Weight=6
+X-KDE-ParentApp=kshowmail
+
diff --git a/kshowmail/kcmconfigs/kwalletaccess.cpp b/kshowmail/kcmconfigs/kwalletaccess.cpp
new file mode 100644
index 0000000..20dccc6
--- /dev/null
+++ b/kshowmail/kcmconfigs/kwalletaccess.cpp
@@ -0,0 +1,137 @@
+//
+// C++ Implementation: kwalletaccess
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "kwalletaccess.h"
+
+
+bool KWalletAccess::savePassword( const QString & account, const QString & password )
+{
+ //check for enabled KWallet
+ if( !KWallet::Wallet::isEnabled() )
+ {
+ KMessageBox::error( NULL, i18n( "KWallet is not available." ) );
+ return false;
+ }
+
+ //get wallet name for network data
+ QString name = KWallet::Wallet::NetworkWallet();
+ if( name == "" || name == QString::null )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get wallet name for network datas from KWallet." ) );
+ return false;
+ }
+
+ //open wallet
+ //we want to create a connection object just at first call of this function
+ static KWallet::Wallet* wallet;
+
+ if( wallet == NULL )
+ {
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+ else if( !wallet->isOpen() )
+ {
+ delete wallet;
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+
+ if( wallet == NULL )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open KWallet." ) );
+ return false;
+ }
+
+ //create kshowmail folder if it does not exist
+ if( !wallet->hasFolder( "KShowmail" ) )
+ {
+ bool createFolderSuccess = wallet->createFolder( "KShowmail" );
+
+ if( !createFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not create folder for KShowmail in KWallet." ) );
+ return false;
+ }
+ }
+
+ //set folder
+ bool setFolderSuccess = wallet->setFolder( "KShowmail" );
+ if( !setFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open folder for KShowmail in KWallet." ) );
+ return false;
+ }
+
+ //write password
+ int writePasswordSuccess = wallet->writePassword( account, password );
+ if( writePasswordSuccess != 0 )
+ {
+ KMessageBox::error( NULL, i18n( "Could not save password in KWallet." ) );
+ return false;
+ }
+
+
+ return true;
+}
+
+QString KWalletAccess::getPassword( const QString & account )
+{
+ //check for enabled KWallet
+ if( !KWallet::Wallet::isEnabled() )
+ {
+ KMessageBox::error( NULL, i18n( "KWallet is not available." ) );
+ return QString::null;
+ }
+
+ //get wallet name for network data
+ QString name = KWallet::Wallet::NetworkWallet();
+ if( name == "" || name == QString::null )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get wallet name for network datas from KWallet." ) );
+ return QString::null;
+ }
+
+ //open wallet
+ //we want to create a connection object just at first call of this function
+ static KWallet::Wallet* wallet;
+
+ if( wallet == NULL )
+ {
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+ else if( !wallet->isOpen() )
+ {
+ delete wallet;
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+
+ if( wallet == NULL )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open KWallet." ) );
+ return QString::null;
+ }
+
+ //set folder
+ bool setFolderSuccess = wallet->setFolder( "KShowmail" );
+ if( !setFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open folder for KShowmail in KWallet." ) );
+ return QString::null;
+ }
+
+ //read password
+ QString password;
+
+ int readPasswordSuccess = wallet->readPassword( account, password );
+ if( readPasswordSuccess != 0 )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get password of account %1 from KWallet." ).arg( account) );
+ return QString::null;
+ }
+
+ return password;
+}
diff --git a/kshowmail/kcmconfigs/kwalletaccess.h b/kshowmail/kcmconfigs/kwalletaccess.h
new file mode 100644
index 0000000..8e9c537
--- /dev/null
+++ b/kshowmail/kcmconfigs/kwalletaccess.h
@@ -0,0 +1,45 @@
+//
+// C++ Interface: kwalletaccess
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KWALLETACCESS_H
+#define KWALLETACCESS_H
+
+//Qt headers
+#include <qstring.h>
+
+//KDE headers
+#include <kwallet.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+/**
+ * @brief Provides routines to save and read passwords using KWallet.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+namespace KWalletAccess
+{
+
+ /**
+ * Saves the given password into KWallet.
+ * @param account account name
+ * @param password the password
+ * @return TRUE - password successfully saved
+ * @return FALSE - password could not be saved
+ */
+ bool savePassword( const QString& account, const QString& password );
+
+ /**
+ * Returns the password of the given account.
+ * @param account account name
+ * @return the password or QString::null, if the sought password is not stored in KWallet.
+ */
+ QString getPassword( const QString& account );
+}
+
+#endif
diff --git a/kshowmail/kcmconfigs/mailboxwizard.cpp b/kshowmail/kcmconfigs/mailboxwizard.cpp
new file mode 100644
index 0000000..d6ab904
--- /dev/null
+++ b/kshowmail/kcmconfigs/mailboxwizard.cpp
@@ -0,0 +1,164 @@
+//
+// C++ Implementation: mailboxwizard
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "mailboxwizard.h"
+
+MailBoxWizard::MailBoxWizard( QWidget* parent, const char* name )
+ : QWizard( parent, name, true )
+{
+
+ //this is page one
+ //in this the user can chosse his mail directory
+ //----------------------------------------------
+ QWidget* page1 = new QWidget( this, "page1" );
+ QHBoxLayout* layMain1 = new QHBoxLayout( page1, 0, 10 );
+
+ txtMailDir = new KLineEdit( page1, "txtMailDir" );
+ layMain1->addWidget( txtMailDir );
+
+ btnMailDir = new KPushButton( KGuiItem( QString(), QString( "folder" ), i18n( "Press to choose the mail directory" ), i18n( "Press to choose the mail directory" ) ), page1, "btnMailDir" );
+ btnMailDir->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
+ layMain1->addWidget( btnMailDir );
+ connect( btnMailDir, SIGNAL( clicked() ), this, SLOT( slotOpenDirDialog() ) );
+
+ title1 = i18n( "Please choose the path to the mailboxes.\nKShowmail supports only MailDir boxes." );
+ addPage( page1, title1 );
+
+
+ //this is page two
+ //in this the user can choose the mailbox
+ //---------------------------------------
+ QWidget* page2 = new QWidget( this, "page2" );
+ QHBoxLayout* layMain2 = new QHBoxLayout( page2, 0, 10 );
+
+ lstMailboxes = new KListView( page2, "lstMailboxes" );
+ lstMailboxes->addColumn( "Mailbox" );
+ lstMailboxes->setRootIsDecorated( true );
+ layMain2->addWidget( lstMailboxes );
+
+ title2 = i18n( "Please choose the mailbox" );
+ addPage( page2, title2 );
+ setFinishEnabled( page2, true );
+
+ connect( this, SIGNAL( selected( const QString& ) ), this, SLOT( slotPageChanged( const QString& ) ) );
+}
+
+
+MailBoxWizard::~MailBoxWizard()
+{
+}
+
+void MailBoxWizard::slotOpenDirDialog( )
+{
+ //save old path
+ QString oldPath = txtMailDir->text();
+
+ //get new path
+ QString path = KFileDialog::getExistingDirectory( oldPath, this, i18n( "Choose the mailbox directory") );
+
+ //put new or old path in the edit line
+ if( path == QString::null )
+ txtMailDir->setText( oldPath );
+ else
+ txtMailDir->setText( path );
+}
+
+void MailBoxWizard::slotPageChanged( const QString& pageTitle )
+{
+ //just we looking for mailboxes if the page 2 was opened
+ if( pageTitle == title2 )
+ {
+ //clear all entries
+ lstMailboxes->clear();
+
+ //create an directory object to browse the given directory
+ QDir mailDir( txtMailDir->text() );
+ if( mailDir.isReadable() ) //is the dir readable?
+ {
+ //get a list of all entries in this directory
+ const QStringList entries = mailDir.entryList( QDir::Dirs | QDir::Readable | QDir::Writable | QDir::Hidden, QDir::Name | QDir::IgnoreCase | QDir::LocaleAware );
+
+ for( QStringList::const_iterator it = entries.begin(); it != entries.end(); ++it )
+ {
+ //add an entry to the mailbox list
+ QDir newMailDir( mailDir );
+ newMailDir.cd( (*it) );
+ if( (*it) != ".." && (*it) != "." && isMailDir( newMailDir ) )
+ addMailBoxListItem( *it, mailDir );
+ }
+ }
+ }
+
+}
+
+bool MailBoxWizard::isMailDir( const QDir & path )
+{
+ //get a list of all subdirectories in this directory
+ const QStringList entries = path.entryList( QDir::Dirs | QDir::Readable | QDir::Writable | QDir::Hidden, QDir::Name | QDir::IgnoreCase | QDir::LocaleAware );
+
+ //a maildir folder must contains the folders "cur", "new" and "tmp"
+ bool curFound = false;
+ bool newFound = false;
+ bool tmpFound = false;
+
+ //iterate over all directories and look for the three necessary dirs
+ QStringList::const_iterator it = entries.begin();
+ while( it != entries.end() && !( curFound && newFound && tmpFound ) )
+ {
+ if( *it == "tmp" )
+ tmpFound = true;
+ else if( *it == "cur" )
+ curFound = true;
+ else if( *it == "new" )
+ newFound = true;
+
+ ++it;
+ }
+
+ return curFound && newFound && tmpFound;
+}
+
+void MailBoxWizard::addMailBoxListItem( QString boxname, QDir path )
+{
+ //translate some default mailboxes
+ QString boxnameTrans;
+ if( boxname.lower() == "inbox" )
+ boxnameTrans = i18n( "Inbox" );
+ else if( boxname.lower() == "outbox" )
+ boxnameTrans = i18n( "Outbox" );
+ else if( boxname.lower() == "drafts" )
+ boxnameTrans = i18n( "Drafts" );
+ else if( boxname.lower() == "sent-mail" )
+ boxnameTrans = i18n( "sent-mail" );
+ else if( boxname.lower() == "trash" )
+ boxnameTrans = i18n( "Trash" );
+ else
+ boxnameTrans = boxname;
+
+ //create item
+ MailBoxWizardListItem* newItem;
+ newItem = new MailBoxWizardListItem( lstMailboxes, boxnameTrans, path.absPath() + "/" + boxname + "/" );
+
+
+}
+
+QString MailBoxWizard::getPath( )
+{
+ MailBoxWizardListItem* item = (MailBoxWizardListItem*)lstMailboxes->selectedItem();
+
+ QString path = QString::null;
+ if( item != NULL )
+ path = item->getPath();
+
+ return path;
+}
+
+#include "mailboxwizard.moc"
diff --git a/kshowmail/kcmconfigs/mailboxwizard.h b/kshowmail/kcmconfigs/mailboxwizard.h
new file mode 100644
index 0000000..2c32b7a
--- /dev/null
+++ b/kshowmail/kcmconfigs/mailboxwizard.h
@@ -0,0 +1,131 @@
+//
+// C++ Interface: mailboxwizard
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef MAILBOXWIZARD_H
+#define MAILBOXWIZARD_H
+
+//C-headers
+#include <stdlib.h>
+
+//Qt headers
+#include <qwizard.h>
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qdir.h>
+#include <qregexp.h>
+#include <qfileinfo.h>
+#include <qmap.h>
+
+//KDE headers
+#include <klocale.h>
+#include <klineedit.h>
+#include <kpushbutton.h>
+#include <kfiledialog.h>
+#include <klistview.h>
+#include <kstandarddirs.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+//Kshowmail headers
+#include "../constants.h"
+#include "mailboxwizardlistitem.h"
+
+/**
+ * Wizard to configure the mailbox to which a filteres mail shall be moved.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class MailBoxWizard : public QWizard
+{
+
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Constructor
+ */
+ MailBoxWizard( QWidget* parent = 0, const char* name = 0 );
+
+ /**
+ * Destructor
+ */
+ ~MailBoxWizard();
+
+ /**
+ * Returns the absolute path of the selected mailbox.
+ * @return the path
+ */
+ QString getPath();
+
+ private:
+
+ /**
+ * This contains the path to the mail directory
+ */
+ KLineEdit* txtMailDir;
+
+ /**
+ * This button opens a file dialog to slecht the mail directory
+ */
+ KPushButton* btnMailDir;
+
+ /**
+ * This view shows the available mailboxes in the selected directory
+ */
+ KListView* lstMailboxes;
+
+ /**
+ * Title of page 1.
+ * Set by constructor
+ */
+ QString title1;
+
+ /**
+ * Title of page 2.
+ * Set by Constructor.
+ */
+ QString title2;
+
+ /**
+ * Returns whether the given directory is a maildir directory
+ * @param path the directory for test
+ * @return TRUE - directory is a maildir directory
+ */
+ bool isMailDir( const QDir& path );
+
+ /**
+ * Adds a new mailbox list view item to the mailbox list or to a given parent item.
+ * @param boxname name of the mailbox
+ * @param path path to the directory of this mailbox
+ */
+ void addMailBoxListItem( QString boxname, QDir path );
+
+
+
+ private slots:
+
+ /**
+ * Connected with btnMailDir.
+ * Opens a file dialog to choose the mail directory.
+ */
+ void slotOpenDirDialog();
+
+ /**
+ * Connected with the signal selected of this wizard.
+ * Searchs for mailboxes inside the path typed in page1.
+ * @param pageTitle title of the selected page
+ */
+ void slotPageChanged( const QString& pageTitle );
+
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/mailboxwizardlistitem.cpp b/kshowmail/kcmconfigs/mailboxwizardlistitem.cpp
new file mode 100644
index 0000000..4afdc2a
--- /dev/null
+++ b/kshowmail/kcmconfigs/mailboxwizardlistitem.cpp
@@ -0,0 +1,28 @@
+//
+// C++ Implementation: mailboxwizardlistitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "mailboxwizardlistitem.h"
+
+MailBoxWizardListItem::~MailBoxWizardListItem()
+{
+}
+
+MailBoxWizardListItem::MailBoxWizardListItem( QListView* parent, QString label, QString path )
+ : KListViewItem( parent, label )
+{
+ this->path = path;
+}
+
+QString MailBoxWizardListItem::getPath( )
+{
+ return path;
+}
+
diff --git a/kshowmail/kcmconfigs/mailboxwizardlistitem.h b/kshowmail/kcmconfigs/mailboxwizardlistitem.h
new file mode 100644
index 0000000..603a9c8
--- /dev/null
+++ b/kshowmail/kcmconfigs/mailboxwizardlistitem.h
@@ -0,0 +1,61 @@
+//
+// C++ Interface: mailboxwizardlistitem
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef MAILBOXWIZARDLISTITEM_H
+#define MAILBOXWIZARDLISTITEM_H
+
+//Qt-Headers
+#include <qlistview.h>
+
+//KDE-Headers
+#include <klistview.h>
+
+/**
+ * This is a list item in the mailbox list of the mailbox wizard
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class MailBoxWizardListItem : public KListViewItem
+{
+
+ public:
+
+ /**
+ * Constructor
+ * Constructs a new top-level entry in the mailbox list.
+ * @param parent pointer to mailbox list.
+ * @param label column content
+ * @param path the absolute path to this mailbox
+ */
+ MailBoxWizardListItem( QListView* parent, QString label, QString path );
+
+ /**
+ * Destructor
+ */
+ ~MailBoxWizardListItem();
+
+ /**
+ * Returns the path to this mailbox.
+ * @return path to this mailbox
+ */
+ QString getPath();
+
+ private:
+
+ /**
+ * The path to this mailbox
+ */
+ QString path;
+
+
+
+};
+
+#endif
diff --git a/kshowmail/kcmconfigs/senderlistdialog.cpp b/kshowmail/kcmconfigs/senderlistdialog.cpp
new file mode 100644
index 0000000..c30804c
--- /dev/null
+++ b/kshowmail/kcmconfigs/senderlistdialog.cpp
@@ -0,0 +1,151 @@
+//
+// C++ Implementation: senderlistdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "senderlistdialog.h"
+
+SenderListDialog::SenderListDialog(QWidget *parent, ListType list, const char *name)
+ : KDialogBase( parent, name, true, QString::null, Ok|Cancel, Ok, true )
+{
+ //save list type
+ this->list = list;
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //set caption
+ if( list == White )
+ setCaption( "Whitelist" );
+ else
+ setCaption( "Blacklist" );
+
+ //build GUI
+ //---------
+
+ //main widget and layout
+ QWidget* wdgMain = new QWidget( this );
+ setMainWidget( wdgMain );
+ QVBoxLayout* layMain = new QVBoxLayout( wdgMain, 0, spacingHint() );
+
+ //edit frame
+ editFrame = new KEditListBox( wdgMain, "editFrame", true, KEditListBox::Add | KEditListBox::Remove );
+ editFrame->setTitle( i18n( "List" ) );
+ if( list == White )
+ QToolTip::add( editFrame->listBox(), i18n( "A mail whose sender is listed here will pass the filter.\nA mail will be accepted, if its From line incloses a list entry.\nE.g. a line of\n\"Ulrich Weigelt\" <ulrich.weigelt@gmx.de> is accepted by the entries\nUlrich Weigelt\nulrich.weigelt@gmx.de\n\"Ulrich Weigelt\" <ulrich.weigelt@gmx.de>" ) );
+ else
+ QToolTip::add( editFrame->listBox(), i18n( "A mail whose sender is listed here will be hold up by the filter.\nA mail will be stopped, if its From line incloses a list entry.\nE.g. a line of\n\"Ulrich Weigelt\" <ulrich.weigelt@gmx.de> is filtered by the entries\nUlrich Weigelt\nulrich.weigelt@gmx.de\n\"Ulrich Weigelt\" <ulrich.weigelt@gmx.de>" ) );
+
+ layMain->addWidget( editFrame );
+
+ connect( editFrame->addButton(), SIGNAL( clicked() ), this, SLOT( slotSort() ) );
+ connect( editFrame->lineEdit(), SIGNAL( returnPressed( const QString & ) ), this, SLOT( slotSort() ) );
+
+ //this radio buttons we just need in the blacklist
+ if( list == Black )
+ {
+ QGroupBox* gboxAction = new QGroupBox( 0, Qt::Horizontal, i18n( "Action" ), wdgMain, "gboxAction" );
+ QHBoxLayout* layAction = new QHBoxLayout( gboxAction->layout(), 10 );
+ layMain->addWidget( gboxAction );
+
+ grpAction = new QButtonGroup( NULL, "grpAction" );
+ QRadioButton* btnDelete = new QRadioButton( i18n( "Delete"), gboxAction, "btnDelete" );
+ QRadioButton* btnMark = new QRadioButton( i18n( "Mark" ), gboxAction, "btnMark" );
+
+ grpAction->insert( btnDelete, ID_BUTTON_FILTER_SENDERLIST_DELETE );
+ grpAction->insert( btnMark, ID_BUTTON_FILTER_SENDERLIST_MARK );
+
+ QToolTip::add( btnDelete, i18n( "The mails will be deleted." ) );
+ QToolTip::add( btnMark, i18n( "The mails will be marked." ) );
+
+ layAction->addWidget( btnDelete );
+ layAction->addWidget( btnMark );
+
+ //set default
+ switch( DEFAULT_FILTER_BLACKLIST_ACTION )
+ {
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_DELETE ); break;
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_MARK ); break;
+ default : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_DELETE ); break;
+ }
+ }
+ //set size
+ setGeometry( 50, 50, (int)( this->width() / 2 ), this->height() );
+
+ //get values
+ fillDialog();
+}
+
+
+SenderListDialog::~SenderListDialog()
+{
+}
+
+void SenderListDialog::slotSort( )
+{
+ editFrame->listBox()->sort();
+}
+
+void SenderListDialog::slotOk( )
+{
+ //set config group
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //save the list of senders
+ if( list == Black )
+ config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST, editFrame->items() );
+ else
+ config->writeEntry( CONFIG_ENTRY_FILTER_WHITELIST, editFrame->items() );
+
+ //save blacklist action
+ if( list == Black )
+ {
+ int action = grpAction->selectedId();
+ if( action != ID_BUTTON_FILTER_SENDERLIST_DELETE && action != ID_BUTTON_FILTER_SENDERLIST_MARK )
+ action = DEFAULT_FILTER_BLACKLIST_ACTION;
+
+ switch( action )
+ {
+ case ID_BUTTON_FILTER_SENDERLIST_DELETE : config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST_ACTION, CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE ); break;
+ case ID_BUTTON_FILTER_SENDERLIST_MARK : config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST_ACTION, CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK ); break;
+ default : config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST_ACTION, CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE ); break;
+ }
+ }
+
+ config->sync();
+
+ //call slot of super class to close the dialog
+ KDialogBase::slotOk();
+}
+
+void SenderListDialog::fillDialog( )
+{
+ //set config group
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //get list of senders
+ if( list == Black )
+ editFrame->setItems( config->readListEntry( CONFIG_ENTRY_FILTER_BLACKLIST ) );
+ else
+ editFrame->setItems( config->readListEntry( CONFIG_ENTRY_FILTER_WHITELIST ) );
+
+ //get blacklist action
+ if( list == Black )
+ {
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_BLACKLIST_ACTION, DEFAULT_FILTER_BLACKLIST_ACTION ) )
+ {
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_DELETE ); break;
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_MARK ); break;
+ default : grpAction->setButton( ID_BUTTON_FILTER_SENDERLIST_DELETE ); break;
+ }
+ }
+}
+
+
+#include "senderlistdialog.moc"
diff --git a/kshowmail/kcmconfigs/senderlistdialog.h b/kshowmail/kcmconfigs/senderlistdialog.h
new file mode 100644
index 0000000..eeb0661
--- /dev/null
+++ b/kshowmail/kcmconfigs/senderlistdialog.h
@@ -0,0 +1,112 @@
+//
+// C++ Interface: senderlistdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef SENDERLISTDIALOG_H
+#define SENDERLISTDIALOG_H
+
+//Qt headers
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qpushbutton.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <kapplication.h>
+#include <keditlistbox.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <kconfig.h>
+
+//KShowmail headers
+#include "../constants.h"
+
+//Button IDs
+#define ID_BUTTON_FILTER_SENDERLIST_DELETE 1
+#define ID_BUTTON_FILTER_SENDERLIST_MARK 2
+
+/**
+ * @brief This is a dialog to edit the blacklist and whitelist. It is used by the class ConfigFilter.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class SenderListDialog : public KDialogBase
+{
+
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Type of list.
+ */
+ enum ListType { Black, White };
+
+ /**
+ * Constructor
+ * @param parent parent widget
+ * @param list list which shall be opened
+ * @param name widget name
+ */
+ SenderListDialog( QWidget *parent = 0, ListType list = Black, const char *name = 0 );
+
+ /**
+ * Destructor
+ */
+ ~SenderListDialog();
+
+ private:
+
+ /**
+ * list which shall be opened
+ */
+ ListType list;
+
+ /**
+ * Application Config Object
+ */
+ KConfig* config;
+
+ /**
+ * Edit Frame
+ */
+ KEditListBox* editFrame;
+
+ /**
+ * Combines the action radio buttons for the blacklist.
+ */
+ QButtonGroup* grpAction;
+
+ /**
+ * Reads the entries for the dialog from the config file fill them in it.
+ */
+ void fillDialog();
+
+ private slots:
+
+ /**
+ * Connected with add button of the edit frame.
+ * Sorts the content of the list box.
+ */
+ void slotSort();
+
+ /**
+ * Overwritten method of KDialogBase.
+ * Called if OK was clicked.
+ * Stores the entered values.
+ * After then it invokes slotOk() of KDialogBase.
+ */
+ void slotOk();
+
+
+};
+
+#endif
diff --git a/kshowmail/kfeedback.cpp b/kshowmail/kfeedback.cpp
new file mode 100644
index 0000000..daadfe8
--- /dev/null
+++ b/kshowmail/kfeedback.cpp
@@ -0,0 +1,504 @@
+
+/*
+ * File name: kfeedback.cpp
+ * Summary: User feedback form
+ * License: LGPL - See file COPYING.LIB for details.
+ * Author: Stefan Hundhammer <sh@suse.de>
+ * modified by Eggert Ehmke <eggert.ehmke@berlin.de>
+ *
+ * Updated: 2002-02-24
+ *
+ * $Id: kfeedback.cpp,v 1.3 2007/03/18 15:05:39 kuddel-fl Exp $
+ *
+ */
+
+
+#include <qheader.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qmultilineedit.h>
+#include <qhbox.h>
+
+#include <kglobal.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kaboutdata.h>
+#include <kiconloader.h>
+#include <kurl.h>
+#include <kdeversion.h>
+
+#include "kfeedback.h"
+
+
+KFeedbackDialog::KFeedbackDialog( const QString & feedbackMailAddress, const QString & helpTopic )
+ : KDialogBase( Plain, i18n( "Feedback" ), Apply | ( helpTopic.isEmpty() ? Cancel : Cancel | Help ), Apply )
+{
+ QVBoxLayout * layout = new QVBoxLayout( plainPage(), 0, spacingHint() );
+ // setButtonApplyText( i18n( "&Mail this..." ) ); deprecated
+ setButtonApply(KGuiItem (i18n( "&Mail this..." )));
+
+ if ( ! helpTopic.isEmpty() )
+ setHelp( helpTopic );
+
+ _form = new KFeedbackForm( feedbackMailAddress, plainPage() );
+ CHECK_PTR( _form );
+
+ layout->addWidget( _form );
+ checkSendButton();
+
+ connect( this, SIGNAL( applyClicked() ),
+ _form, SLOT ( sendMail() ) );
+
+ connect( _form, SIGNAL( mailSent() ),
+ this, SLOT ( hide() ) );
+
+ connect( _form, SIGNAL( mailSent() ),
+ this, SIGNAL( mailSent() ) );
+
+ connect( _form, SIGNAL( checkComplete() ),
+ this, SLOT ( checkSendButton() ) );
+}
+
+
+KFeedbackDialog::~KFeedbackDialog()
+{
+ // NOP
+}
+
+
+void
+KFeedbackDialog::checkSendButton()
+{
+ enableButtonApply( _form->readyToSend() );
+}
+
+
+
+
+
+KFeedbackForm::KFeedbackForm( const QString & feedbackMailAddress,
+ QWidget * parent )
+ : QVBox( parent )
+ , _feedbackMailAddress( feedbackMailAddress )
+{
+ //
+ // Explanation above the question list
+ //
+
+ QLabel * label = new QLabel( i18n( "<p><b>Please tell us your opinion about this program.</b></p>"
+ "<p>You will be able to review everything in your mailer "
+ "before any mail is sent.<br>"
+ "Nothing will be sent behind your back.</p>"
+ ), this );
+ //
+ // Question list
+ //
+
+ _questionList = new KFeedbackQuestionList( this );
+ CHECK_PTR( _questionList );
+
+ connect( _questionList, SIGNAL( checkComplete() ),
+ this, SLOT ( slotCheckComplete() ) );
+
+
+ //
+ // Explanation below the question list
+ //
+
+ QHBox * hbox = new QHBox( this );
+ CHECK_PTR( hbox );
+
+ QSizePolicy pol( QSizePolicy::Fixed, QSizePolicy::Fixed ); // hor / vert
+
+ label = new QLabel( i18n( "Questions marked with " ), hbox );
+ CHECK_PTR( label );
+ label->setSizePolicy( pol );
+
+ label = new QLabel( hbox );
+ CHECK_PTR( label );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "edit", KIcon::Small ) );
+ label->setSizePolicy( pol );
+
+ label = new QLabel( i18n( " must be answered before a mail can be sent.") , hbox );
+ CHECK_PTR( label );
+ label->setSizePolicy( pol );
+
+ new QWidget( hbox ); // Fill any leftover space to the right.
+
+
+ //
+ // Free-text comment field
+ //
+
+ label = new QLabel( "\n" + i18n( "&Additional comments:" ), this ); CHECK_PTR( label );
+ _comment = new QMultiLineEdit( this ); CHECK_PTR( _comment );
+
+ label->setBuddy( _comment );
+#if (QT_VERSION < 300)
+ _comment->setFixedVisibleLines( 5 );
+#endif
+ _comment->setWordWrap( QMultiLineEdit::FixedColumnWidth );
+ _comment->setWrapColumnOrWidth( 70 );
+}
+
+
+KFeedbackForm::~KFeedbackForm()
+{
+ // NOP
+}
+
+
+void
+KFeedbackForm::sendMail()
+{
+ //
+ // Build mail subject
+ //
+
+ QString subject;
+
+ const KAboutData * aboutData = KGlobal::instance()->aboutData();
+
+ if ( aboutData )
+ subject = aboutData->programName() + "-" + aboutData->version();
+ else
+ subject = kapp->name();
+
+ subject += " user feedback";
+
+
+ //
+ // Build mail body
+ //
+
+ QString body = subject + "\n\n"
+ + formatComment()
+ + _questionList->result();
+
+
+ //
+ // Build "mailto:" URL from all this
+ //
+
+ KURL mail;
+ mail.setProtocol( "mailto" );
+ mail.setPath( _feedbackMailAddress );
+ mail.setQuery( "?subject=" + KURL::encode_string( subject ) +
+ "&body=" + KURL::encode_string( body ) );
+
+ // TODO: Check for maximum command line length.
+ //
+ // The hard part with this is how to get this from all that 'autoconf'
+ // stuff into 'config.h' or some other include file without hardcoding
+ // anything - this is too system dependent.
+
+
+ //
+ // Actually send mail
+ //
+
+ kapp->invokeMailer( mail );
+
+ emit mailSent();
+}
+
+
+void
+KFeedbackForm::slotCheckComplete()
+{
+ emit checkComplete();
+}
+
+
+QString
+KFeedbackForm::formatComment()
+{
+ QString result = _comment->text();
+
+ if ( ! result.isEmpty() )
+ {
+ result = "<comment>\n" + result + "\n</comment>\n\n";
+ }
+
+ return result;
+}
+
+
+bool
+KFeedbackForm::readyToSend()
+{
+ return _questionList->isComplete();
+}
+
+
+
+
+
+
+KFeedbackQuestionList::KFeedbackQuestionList( QWidget *parent )
+ : QListView( parent )
+{
+ addColumn( "" );
+ header()->hide();
+}
+
+
+KFeedbackQuestionList::~KFeedbackQuestionList()
+{
+ // NOP
+}
+
+
+bool
+KFeedbackQuestionList::isComplete()
+{
+ KFeedbackQuestion * question = firstQuestion();
+
+ while ( question )
+ {
+ if ( question->isRequired() && ! question->isAnswered() )
+ return false;
+
+ question = question->nextQuestion();
+ }
+
+ return true;
+}
+
+
+QString KFeedbackQuestionList::result()
+{
+ QString res;
+ KFeedbackQuestion * question = firstQuestion();
+
+ while ( question )
+ {
+ res += question->result();
+
+ question = question->nextQuestion();
+ }
+ res += "Compiled on KDE version: ";
+ res += KDE_VERSION_STRING;
+
+ return res;
+}
+
+
+KFeedbackQuestion* KFeedbackQuestionList::addQuestion( const QString & text,
+ const QString & id,
+ bool exclusiveAnswer,
+ bool required )
+{
+ KFeedbackQuestion * question = new KFeedbackQuestion( this, text, id,
+ exclusiveAnswer,
+ required );
+ CHECK_PTR( question );
+
+ return question;
+}
+
+
+void
+KFeedbackQuestionList::addYesNoQuestion( const QString & text,
+ const QString & id,
+ bool required )
+{
+
+ KFeedbackQuestion * question = new KFeedbackQuestion( this, text, id,
+ true, // exclusive
+ required );
+ CHECK_PTR( question );
+ question->addAnswer( i18n( "yes" ), "yes" );
+ question->addAnswer( i18n( "no" ), "no" );
+}
+
+
+void
+KFeedbackQuestionList::questionAnswered()
+{
+ emit checkComplete();
+}
+
+void
+KFeedbackQuestionList::questionAdded( KFeedbackQuestion * question)
+{
+ if ( question->isRequired() )
+ emit checkComplete();
+}
+
+
+
+
+
+static int nextNo = 0;
+
+KFeedbackQuestion::KFeedbackQuestion( KFeedbackQuestionList * parent,
+ const QString & text,
+ const QString & id,
+ bool exclusiveAnswer,
+ bool required,
+ bool open )
+ : QCheckListItem( parent, text )
+ , _id( id )
+ , _exclusiveAnswer( exclusiveAnswer )
+ , _required( required )
+{
+ if ( required )
+ {
+ setPixmap( 0, KGlobal::iconLoader()->loadIcon( "edit", KIcon::Small ) );
+ }
+
+ setOpen( open );
+ _no = nextNo++;
+
+ parent->questionAdded( this );
+}
+
+
+void
+KFeedbackQuestion::addAnswer( const QString & text,
+ const QString & id )
+{
+ new KFeedbackAnswer( this, text, id, _exclusiveAnswer );
+}
+
+
+bool
+KFeedbackQuestion::isAnswered()
+{
+ if ( ! _exclusiveAnswer )
+ {
+ /**
+ * If any number of answers is permitted for this question, this
+ * question is always considered to be answered.
+ **/
+
+ return true;
+ }
+
+
+ /**
+ * If this question requires an exclusive answer, exactly one of them
+ * should be checked. We don't need to bother about more than one being
+ * checked here - QListView does that for us.
+ **/
+
+ KFeedbackAnswer *answer = firstAnswer();
+
+ while ( answer )
+ {
+ if ( answer->isChecked() )
+ return true;
+
+ answer = answer->nextAnswer();
+ }
+
+ return false;
+}
+
+
+QString
+KFeedbackQuestion::result()
+{
+ QString res;
+ int answers = 0;
+
+ KFeedbackAnswer *answer = firstAnswer();
+
+ while ( answer )
+ {
+ if ( answer->isChecked() )
+ {
+ res += _id + "=\"" + answer->id() + "\"\n";
+ answers++;
+ }
+
+ answer = answer->nextAnswer();
+ }
+
+ if ( answers > 1 )
+ {
+ res = "\n" + res + "\n";
+ }
+
+ return res;
+}
+
+
+QString
+KFeedbackQuestion::text()
+{
+ return QCheckListItem::text(0);
+}
+
+
+QString
+KFeedbackQuestion::key( int, bool ) const
+{
+ QString no;
+ no.sprintf( "%08d", _no );
+
+ return no;
+}
+
+
+KFeedbackQuestionList *
+KFeedbackQuestion::questionList() const
+{
+ return dynamic_cast<KFeedbackQuestionList *>( listView() );
+}
+
+
+
+
+
+
+
+KFeedbackAnswer::KFeedbackAnswer( KFeedbackQuestion * parent,
+ const QString & text,
+ const QString & id,
+ bool exclusive )
+ : QCheckListItem( parent,
+ text,
+ exclusive
+ ? QCheckListItem::RadioButton
+ : QCheckListItem::CheckBox )
+ , _id( id )
+{
+ _no = nextNo++;
+}
+
+
+QString
+KFeedbackAnswer::text()
+{
+ return QCheckListItem::text(0);
+}
+
+
+QString
+KFeedbackAnswer::key( int, bool ) const
+{
+ QString no;
+ no.sprintf( "%08d", _no );
+
+ return no;
+}
+
+
+void
+KFeedbackAnswer::stateChange( bool newState )
+{
+ if ( newState && question()->isRequired() )
+ {
+ KFeedbackQuestionList * list = question()->questionList();
+
+ if ( list )
+ list->questionAnswered();
+ }
+}
+
+
+
+// EOF
diff --git a/kshowmail/kfeedback.h b/kshowmail/kfeedback.h
new file mode 100644
index 0000000..620ace7
--- /dev/null
+++ b/kshowmail/kfeedback.h
@@ -0,0 +1,463 @@
+/*
+ * File name: kfeedback.h
+ * Summary: User feedback form and mailing utilities
+ * License: LGPL - See file COPYING.LIB for details.
+ * Author: Stefan Hundhammer <sh@suse.de>
+ *
+ * Updated: 2002-02-24
+ *
+ * $Id: kfeedback.h,v 1.2 2007/03/18 15:05:39 kuddel-fl Exp $
+ *
+ */
+
+
+#ifndef KFeedback_h
+#define KFeedback_h
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qlistview.h>
+#include <qvbox.h>
+#include <kdialogbase.h>
+
+
+#ifndef NOT_USED
+# define NOT_USED(PARAM) ( (void) (PARAM) )
+#endif
+
+
+class KFeedbackForm;
+class KFeedbackQuestionList;
+class KFeedbackQuestion;
+class KFeedbackAnswer;
+class QMultiLineEdit;
+
+
+/**
+ * Dialog containing a @ref KFeedbackForm and all the infrastructure for
+ * sending a mail etc.
+ **/
+class KFeedbackDialog: public KDialogBase
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * Constructor.
+ **/
+ KFeedbackDialog( const QString & feedbackMailAddress,
+ const QString & helpTopic = QString::null );
+
+
+ /**
+ * Destructor.
+ **/
+ virtual ~KFeedbackDialog();
+
+
+ /**
+ * Returns the internal @KFeedbackForm
+ **/
+ KFeedbackForm *form() { return _form; }
+
+
+public slots:
+
+ /**
+ * Check if sufficient information is available to send a mail now and
+ * enable / disable the "send mail" button accordingly.
+ **/
+ void checkSendButton();
+
+
+signals:
+ /**
+ * Emitted when the user has sent the feedback mail - i.e. when he clicked
+ * on the "Send mail" button and the mail has successfully been forwarded
+ * to the mailer. He can still choose not to send the mail from within the
+ * mailer, though.
+ **/
+ void mailSent();
+
+
+protected:
+
+ KFeedbackForm * _form;
+};
+
+
+/**
+ * User feedback form:
+ *
+ * User is asked a list of questions, the answers of which will be sent via
+ * mail back to a feedback mail address.
+ **/
+class KFeedbackForm: public QVBox
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor.
+ **/
+ KFeedbackForm( const QString & feedbackMailAddress,
+ QWidget * parent );
+
+ /**
+ * Destructor.
+ **/
+ virtual ~KFeedbackForm();
+
+
+public slots:
+
+ /**
+ * Compose a mail from the user's answers and send it to the feedback mail
+ * address passed to the constructor.
+ *
+ * This method will check with @ref readyToSend() if the mail can be sent
+ * with the questions answered until now and prompt the user to answer more
+ * questions if not.
+ *
+ * Connect the @ref mailSent() signal if you are interested when exactly
+ * all this was successful.
+ **/
+ virtual void sendMail();
+
+
+public:
+
+ /**
+ * Checks if the mail is ready to send, i.e. if all required fields are
+ * filled.
+ **/
+ virtual bool readyToSend();
+
+ /**
+ * Returns the @ref KFeedbackQuestionList .
+ **/
+ KFeedbackQuestionList * questionList() { return _questionList; }
+
+
+signals:
+ /**
+ * Emitted when the user has sent the feedback mail - i.e. when he clicked
+ * on the "Send mail" button and the mail has successfully been forwarded
+ * to the mailer. He can still choose not to send the mail from within the
+ * mailer, though.
+ **/
+ void mailSent();
+
+ /**
+ * Emitted when it is time to check for completeness of all information in
+ * this form: Either when a new question is added or when a question is
+ * answered.
+ **/
+ void checkComplete();
+
+
+protected slots:
+ /**
+ * Check for completeness of this form.
+ **/
+ void slotCheckComplete();
+
+
+protected:
+
+ /**
+ * Format the "personal comments" field for sending mail.
+ **/
+ QString formatComment();
+
+
+ QString _feedbackMailAddress;
+ KFeedbackQuestionList * _questionList;
+ QMultiLineEdit * _comment;
+};
+
+
+
+/**
+ * List of feedback questions presented in a @ref QListView widget.
+ **/
+class KFeedbackQuestionList: public QListView
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * Constructor.
+ **/
+ KFeedbackQuestionList( QWidget *parent );
+
+ /**
+ * Destructor.
+ **/
+ virtual ~KFeedbackQuestionList();
+
+ /**
+ * Returns whether or not this question list is answered satisfactorily,
+ * i.e. if all questions marked as "required" are answered.
+ **/
+ virtual bool isComplete();
+
+ /**
+ * The result of all answered questions in ASCII.
+ **/
+ QString result();
+
+ /**
+ * Add a yes/no question to the list.
+ *
+ * 'text' is the text the user will see (in his native language).
+ *
+ * 'id' is what will be sent with the feedback mail, thus it should be
+ * unique within the application, yet human readable (preferably English)
+ * and not contain any weird characters that might confuse scripts that are
+ * later used to automatically parse those mails.
+ * Examples: "would_recommend_to_a_friend"
+ *
+ * Set 'required' to 'true' if answering this question is required to
+ * successfully complete this form.
+ *
+ * Returns a pointer to this question so you can add answers.
+ **/
+
+ KFeedbackQuestion * addQuestion( const QString & text,
+ const QString & id,
+ bool exclusiveAnswer = true,
+ bool required = false );
+
+ /**
+ * Add a yes/no question to the list.
+ **/
+ void addYesNoQuestion( const QString & text,
+ const QString & id,
+ bool required = false );
+
+ /**
+ * Returns the first question of that list.
+ * Use @ref KFeedbackQuestion::next() to get the next one.
+ **/
+ KFeedbackQuestion * firstQuestion() const
+ { return (KFeedbackQuestion *) QListView::firstChild(); }
+
+ /**
+ * Notify the list that another question has been answered.
+ * Emits the @ref checkComplete() signal when all required questions are
+ * answered.
+ **/
+ void questionAnswered();
+
+ /**
+ * Notify the list that another question has been added.
+ * Emits the @ref checkComplete() signal when a required question is
+ * added.
+ **/
+ void questionAdded( KFeedbackQuestion * question );
+
+signals:
+ /**
+ * Emitted when all required questions are answered.
+ **/
+ void checkComplete();
+};
+
+
+/**
+ * A user feedback question to be inserted into a @ref KFeedbackQuestionList.
+ **/
+class KFeedbackQuestion: public QCheckListItem
+{
+public:
+
+ /**
+ * Constructor.
+ *
+ * The parent @ref KFeedbackQuestionList assumes ownership of this object,
+ * so don't delete it unless you want to delete it from the question list
+ * as well.
+ *
+ * 'text' is the text the user will see (in his native language).
+ *
+ * 'id' is what will be sent with the feedback mail, thus it should be
+ * unique within the application, yet human readable (preferably English)
+ * and not contain any weird characters that might confuse scripts that are
+ * later used to automatically parse those mails.
+ * Examples: "features_not_liked", "stability"
+ *
+ * Set 'required' to 'true' if answering this question is required to
+ * successfully complete this form.
+ *
+ * Set 'exclusiveAnswer' to 'true' if only one of all answers may be
+ * checked at any one time, to 'false' if multiple answers are allowed.
+ **/
+ KFeedbackQuestion( KFeedbackQuestionList * parent,
+ const QString & text,
+ const QString & id,
+ bool exclusiveAnswer = true,
+ bool required = false,
+ bool open = true );
+
+ /**
+ * Add an answer to this question. Again, 'text' is what the user will see
+ * (translated to his native language), 'id' is what you will get back with
+ * the mail. The answer IDs need only be unique for that question; answers
+ * to other questions may have the same ID.
+ **/
+ void addAnswer( const QString & text,
+ const QString & id );
+
+ /**
+ * Returns if answering this question is required.
+ **/
+ bool isRequired() { return _required; }
+
+ /**
+ * Returns if this question is answered satisfactorily.
+ **/
+ bool isAnswered();
+
+ /**
+ * The result of this question in ASCII, e.g.
+ * recommend="yes"
+ * or
+ * features_i_like="builtin_tetris"
+ * features_i_like="pink_elephant"
+ * features_i_like="studlycapslyfier"
+ **/
+ QString result();
+
+ /**
+ * Return this question's ID.
+ **/
+ QString id() { return _id; }
+
+ /**
+ * Return this question's text.
+ **/
+ QString text();
+
+ /**
+ * Returns whether or not this question requires an exclusive answer.
+ **/
+ bool exclusiveAnswer() { return _exclusiveAnswer; }
+
+
+ /**
+ * Returns the sort key.
+ *
+ * Reimplemented from @ref QListViewItem to maintain insertion order.
+ **/
+ virtual QString key( int column, bool ascending ) const;
+
+ /**
+ * Returns the next question or 0 if there is no more.
+ **/
+ KFeedbackQuestion * nextQuestion() const
+ { return (KFeedbackQuestion *) QListViewItem::nextSibling(); }
+
+ /**
+ * Returns the first possible answer to this question.
+ * Use @ref KFeedbackAnswer::nextAnswer() to get the next one.
+ **/
+ KFeedbackAnswer * firstAnswer() const
+ { return (KFeedbackAnswer *) QListViewItem::firstChild(); }
+
+ /**
+ * Returns the @ref KFeedbackQuestionList this question belongs to or 0 if
+ * the parent is no @ref KFeedbackQuestionList.
+ **/
+ KFeedbackQuestionList * questionList() const;
+
+
+protected:
+
+ QString _id;
+ bool _exclusiveAnswer;
+ bool _required;
+ int _no;
+};
+
+
+class KFeedbackAnswer: public QCheckListItem
+{
+public:
+ /**
+ * Constructor.
+ *
+ * 'exclusive' tells the type of answer: One of many allowed or any number
+ * of many.
+ **/
+ KFeedbackAnswer( KFeedbackQuestion * parent,
+ const QString & text,
+ const QString & id,
+ bool exclusive = true );
+
+ /**
+ * Return this answer's ID.
+ **/
+ QString id() { return _id; }
+
+ /**
+ * Return this answer's text.
+ **/
+ QString text();
+
+ /**
+ * Returns whether or not this is an exclusive answer.
+ **/
+ bool isExclusive() { return _exclusive; }
+
+ /**
+ * Returns whether or not this answer is checked.
+ **/
+ bool isChecked() { return QCheckListItem::isOn(); }
+
+ /**
+ * Returns the next possible answer or 0 if there is no more.
+ **/
+ KFeedbackAnswer * nextAnswer() const
+ { return (KFeedbackAnswer *) QListViewItem::nextSibling(); }
+
+ /**
+ * Returns the question to this answer.
+ **/
+ KFeedbackQuestion * question() const
+ { return (KFeedbackQuestion *) QListViewItem::parent(); }
+
+ /**
+ * Returns the sort key.
+ *
+ * Reimplemented from @ref QListViewItem to maintain insertion order.
+ **/
+ virtual QString key( int column, bool ascending ) const;
+
+
+ /**
+ * On/off change.
+ *
+ * Reimplemented from @ref QCheckListItem to monitor answering required
+ * questions. This method notifies the @ref KFeedbackQuestionList whenever
+ * a required question is being answered.
+ **/
+ virtual void stateChange( bool newState );
+
+protected:
+
+ QString _id;
+ bool _exclusive;
+ int _no;
+};
+
+
+
+#endif // KFeedback_h
+
+
+// EOF
diff --git a/kshowmail/kshowmail.cpp b/kshowmail/kshowmail.cpp
new file mode 100644
index 0000000..16e9db6
--- /dev/null
+++ b/kshowmail/kshowmail.cpp
@@ -0,0 +1,861 @@
+/***************************************************************************
+ kshowmail.cpp - description
+ -------------------
+ begin : Sat May 6 12:13:57 MEST 2000
+ copyright : (C) 2000-2002 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+
+ 26 Sep 2002 - Allow for columns to be hidden. Allistar Melville
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "kshowmail.h"
+
+using namespace KIO;
+
+KAboutData* KShowMailApp::m_pAbout;
+
+KShowMailApp::KShowMailApp()
+{
+ //set up actions
+ initActions();
+
+ // create GUI from ui resource file
+ setXMLFile( "kshowmailui.rc", true );
+ createGUI();
+
+ //the main window settings will be saved automatically
+ setAutoSaveSettings();
+
+ //initiate GUI parts
+ initStatusBar();
+ initDocument();
+ initView();
+
+ //the application is idle at beginning
+ m_state = idle;
+
+ //the setup dialog will be created in slotSetup() at first use
+ SetupDialog = NULL;
+
+ m_pTimer = new QTimer (this);
+ m_pAlertDialog = NULL;
+ m_pDockWindow = new KShowMailDock (this, m_actionRefresh);
+ m_bForceClose = false;
+
+
+ //read the setup
+ m_ConfigList.refreshSetup( m_pView->m_pListAccounts );
+
+ //load stored mails
+ m_ConfigList.readStoredMails();
+
+ //connect signals with slots
+
+ connect (m_pDockWindow, SIGNAL (quitSelected ()), SLOT (slotForceClose ()));
+ connect (m_pTimer, SIGNAL (timeout ()), SLOT (slotRefresh ()));
+ connect (m_pView->m_pListAccounts, SIGNAL (currentChanged(QListViewItem*)), SLOT(slotAccountActivated(QListViewItem*)));
+ connect (m_pView, SIGNAL (signalActiveChanged()), SLOT (slotRefreshView()));
+
+ connect( &m_ConfigList, SIGNAL( sigDeleteReady() ), this, SLOT( slotDeletionReady() ) );
+ connect( &m_ConfigList, SIGNAL( sigShowBodiesReady() ), this, SLOT( slotShowMessageReady() ) );
+ connect( &m_ConfigList, SIGNAL( sigMessageWindowOpened() ), this, SLOT( slotNormalCursor() ) );
+ connect( &m_ConfigList, SIGNAL( sigAllMessageWindowsClosed() ), this, SLOT( slotWaitingCursor() ) );
+ connect( &m_ConfigList, SIGNAL( sigRefreshReady() ), this, SLOT( slotRefreshReady() ) );
+
+ //show welcome message
+ KMessageBox::information( NULL, i18n( "Thank You for using KShowmail.\nPlease use the feedback dialog to tell us your experience with this program." ), i18n("Welcome"), "WelcomeMessage" );
+
+ // this starts the one-second-interval timer
+ // this is a QObject method
+ startTimer (1000);
+
+ //we are ready to take off! Lets initiate the first refresh (if desired)
+ initFirstRefresh();
+}
+
+KShowMailApp::~KShowMailApp()
+{
+ kdDebug() << "cleaning up" << endl;
+ delete m_pTimer;
+ delete m_pDockWindow;
+ kdDebug() << "cleanup finished" << endl;
+}
+
+/**
+ * This is reimplemented from QObject
+ */
+void KShowMailApp::timerEvent (QTimerEvent *)
+{
+ if (m_nSecondsToGo)
+ {
+ QTime time;
+ time = time.addSecs (m_nSecondsToGo--);
+ QCString msg (i18n("Autorefresh: %1").arg (time.toString()));
+ statusBar()->changeItem( msg, STATUSBAR_FIELD_NEXT_REFRESH );
+ }
+ else
+ statusBar()->changeItem( "", STATUSBAR_FIELD_NEXT_REFRESH );
+
+ // if busy, animate the traybar
+ if ( m_state == refreshing || m_state == deleting )
+ {
+ static int color = 0;
+ color = (color+1)%2;
+ switch (color)
+ {
+ case 0:
+ m_pDockWindow->clear ();
+ break;
+ default:
+ m_pDockWindow->drawText ("?", Qt::red);
+ }
+ }
+}
+
+
+
+void KShowMailApp::initActions ()
+{
+ // file menu
+ KStdAction::quit( this, SLOT( slotFileQuit() ), actionCollection() );
+
+ // action menu
+ m_actionRefresh = new KAction( i18n( "&Refresh messages" ), "reload", Key_F5, this, SLOT( slotRefresh() ), actionCollection(), "refresh" );
+ new KAction( i18n( "Show &header of highlighted messages" ), "letter-closed", Key_F2, this, SLOT( slotShowHeader() ), actionCollection(), "show_header" );
+ new KAction( i18n( "Show &complete highlighted messages" ), "letter-open", Key_F3, this, SLOT( slotShowMessage() ), actionCollection(), "show_complete" );
+ new KAction( i18n( "&Delete highlighted messages" ), "eraser", Key_Delete, this, SLOT( slotDelete() ), actionCollection(), "delete" );
+ new KAction( i18n( "S&top current transfer" ), "stop", 0, this, SLOT( slotStop() ), actionCollection(), "stop" );
+ new KAction( i18n( "Show Filter Log" ), "log", Key_F4, this, SLOT( slotShowFilterLog() ), actionCollection(), "show_filterlog" );
+ new KAction( i18n( "Add sender to whitelist" ), "add_user", 0, this, SLOT( slotAddToWhitelist() ), actionCollection(), "addWhitelist" );
+ new KAction( i18n( "Add sender to blacklist" ), "delete_user", 0, this, SLOT( slotAddToBlacklist() ), actionCollection(), "addBlacklist" );
+
+ // setup menu
+ KStdAction::preferences( this, SLOT( slotSetup() ), actionCollection() );
+ KStdAction::configureToolbars( this, SLOT( slotEditToolbars() ), actionCollection() );
+
+ //create menu items for toggle tool and status bar
+ setStandardToolBarMenuEnabled( true );
+ createStandardStatusBarAction();
+
+ //help menu
+ new KAction( i18n( "Send &Feedback Mail" ), "email", 0, this, SLOT( slotSendFeedbackMail() ),actionCollection(), "sendFeedback" );
+
+ //for account context menu
+ new KAction(i18n( "Setup &account" ), "tool", 0, this, SLOT( slotSetupAccount() ), actionCollection(), "setupAccount" );
+}
+
+
+void KShowMailApp::initStatusBar()
+{
+ statusBar()->insertItem( i18n( "Ready." ), STATUSBAR_FIELD_STATE );
+ statusBar()->insertItem( "", STATUSBAR_FIELD_FILTER, 1 );
+ statusBar()->setItemAlignment( STATUSBAR_FIELD_FILTER, AlignLeft | AlignVCenter );
+ statusBar()->insertItem( "", STATUSBAR_FIELD_NEXT_REFRESH );
+ statusBar()->insertItem( "", STATUSBAR_FIELD_LAST_REFRESH );
+
+ QToolTip::add( statusBar(), i18n( "Shows the number of deleted, moved or ignored mails by the filter.\nThe positions denotes:\nby last refresh / since application start / listed by the log" ) );
+
+ refreshFilterStatusBar();
+}
+
+void KShowMailApp::initDocument()
+{
+ m_pDoc = new KshowmailDoc(this);
+ m_pDoc->newDocument();
+}
+
+void KShowMailApp::initView()
+{
+ ////////////////////////////////////////////////////////////////////
+ // create the main widget here that is managed by KMainWindow's view-region and
+ // connect the widget to your document to display document contents.
+
+ m_pView = new KshowmailView(this);
+ m_pDoc->addView(m_pView);
+ setCentralWidget(m_pView);
+}
+
+void KShowMailApp::slotSaveOptions()
+{
+ KConfig* config = KGlobal::config();
+
+ //order application parts to save their setup
+ m_pView->saveOptions( config );
+ m_ConfigList.saveOptions ();
+ fLog.save();
+
+ //save config to file
+ config->sync ();
+
+}
+
+bool KShowMailApp::queryClose()
+{
+ bool result;
+ kdDebug() << "KShowMailApp::queryClose()" << endl;
+
+ if (m_bForceClose) {
+ // We are forced to close app - so just do it
+ kdDebug() << "forced exit" << endl;
+ result = true;
+ } else if( m_ConfigList.closeToTray() ) {
+ // Don't close - close button must minimize the window
+ result = false;
+ kdDebug() << "ignoring close request and minimizing the window" << endl;
+ KMainWindow* w = memberList->first();
+ w->hide();
+ } else {
+ // Need to ask user first
+ result = askCloseConfirmation();
+ }
+ return result;
+}
+
+bool KShowMailApp::queryExit()
+{
+ kdDebug() << "KShowMailApp::queryExit()" << endl;
+ slotSaveOptions ();
+
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// SLOT IMPLEMENTATION
+/////////////////////////////////////////////////////////////////////
+
+void KShowMailApp::slotFileQuit()
+{
+ kdDebug () << "KShowMailApp::slotFileQuit()" << endl;
+ if(memberList && askCloseConfirmation())
+ {
+ m_bForceClose = true; // Forcing the closing
+ KMainWindow* w = memberList->first();
+ w->close();
+ }
+}
+
+
+void KShowMailApp::slotSetupAccount()
+{
+ //just open the dialog, if the app is idle
+ if (m_state != idle)
+ {
+ kapp->beep();
+ return;
+ }
+
+ //set application state
+ m_state = configure;
+
+ //stop the refresh timer
+ stopRefreshTimer();
+
+ //get account to configure
+ ConfigElem* pConfig = m_ConfigList.getSelectedAccount();
+
+ if( pConfig != NULL )
+ {
+ //open dialog
+ //the dialog sets the new options directly in the account
+ ServerDialog dlg( this, pConfig );
+
+ if( dlg.exec() == QDialog::Accepted )
+ {
+ //if OK was clicked, refresh the account list view
+ slotConfChanged();
+ }
+ }
+
+ //we are ready, set application state to idle and initiate next refresh
+ m_state = idle;
+ initNextRefresh();
+}
+
+void KShowMailApp::slotAccountActivated (QListViewItem* pItem)
+{
+ QPtrListIterator<ConfigElem> it(m_ConfigList);
+ // this is = not == !!!
+ while (ConfigElem* pConfig = it())
+ {
+ if (pConfig->getListViewItem() == pItem)
+ {
+ setCaption (pConfig->getAccountName());
+ return;
+ }
+ }
+}
+
+void KShowMailApp::slotAlertDestroyed()
+{
+ m_pAlertDialog = NULL;
+}
+
+void KShowMailApp::slotAlertOk ()
+{
+ //switch main window to normal view
+ showNormal();
+ raise();
+}
+
+void KShowMailApp::slotRefresh()
+{
+ //return, if the app is not idle
+ if ( m_state != idle )
+ {
+ kapp->beep();
+ initNextRefresh();
+ return;
+ }
+
+ //stop the refresh timer
+ stopRefreshTimer();
+
+ //set the state
+ m_state = refreshing;
+
+ //show status message
+ slotStatusMsg( i18n( "Refreshing ..." ) );
+
+ //set waiting cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ //order the account list to refresh its mail lists
+ m_ConfigList.refreshMailLists( &fLog );
+
+ return;
+}
+
+void KShowMailApp::slotStop ()
+{
+ if (m_state == idle)
+ {
+ kapp->beep ();
+ return;
+ }
+ kdDebug() << "KShowMailApp::slotStop" << endl;
+
+ //kill all running pop3 jobs
+ m_ConfigList.killPOP3Jobs();
+
+ slotRefreshView ();
+
+ // make sure the view is refreshed before the state gets idle again
+ // bug #853651
+
+ //set state to idle
+ m_state = idle;
+
+ //set normal cursor
+ //might be more than one override cursor ...
+ while (QApplication::overrideCursor())
+ QApplication::restoreOverrideCursor ();
+
+ //print status message
+ slotStatusMsg(i18n("Job was stopped"));
+}
+
+void KShowMailApp::slotRefreshView ()
+{
+
+ //clear mail list view
+ m_pView->clearMailListView();
+
+ //fill mail list view
+ m_ConfigList.fillMailListView( m_pView );
+
+ //refresh account list
+ m_ConfigList.refreshAccountList();
+
+ //get some informations
+ int numberMails = m_ConfigList.getNumberMails();
+ bool hasNewMails = m_ConfigList.getNumberNewMails() > 0;
+
+ //draw number of mails into dock
+ if( hasNewMails )
+ //draw red number, because we have new mails
+ m_pDockWindow->drawNumber( numberMails, Qt::red );
+ else
+ //we haven't new mails, draw black
+ m_pDockWindow->drawNumber( numberMails, Qt::black );
+
+ //show message in status bar
+ long totalSize = m_ConfigList.getTotalSize();
+ slotStatusMsg( i18n( "%1 message(s) with a total of %2 bytes are waiting" ).arg( numberMails ).arg( totalSize ) );
+
+ //refresh filter view in the status bar
+ refreshFilterStatusBar();
+}
+
+void KShowMailApp::slotDelete()
+{
+ //just delete, if no operation is running
+ if( m_state != idle )
+ {
+ kapp->beep();
+ return;
+ }
+
+ //return, if no mails are selected
+ if( !m_ConfigList.hasSelectedMails() )
+ return;
+
+ //confirm deletion if required
+ if( m_ConfigList.confirmDeletion() )
+ {
+ //get subjects off all selected mails
+ QStringList subjects = m_ConfigList.getSelectedSubjects();
+
+ //show question
+ int answer = KMessageBox::questionYesNoList( this, i18n( "Do you want to delete these mails?"), subjects, i18n( "Delete?" ) );
+
+ if( answer == KMessageBox::No )
+ return;
+ }
+
+ //set the state
+ m_state = deleting;
+
+ //show status message
+ slotStatusMsg( i18n( "Deleting Mail(s) ..." ) );
+
+ //set waiting cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ //order the account list to delete the selected mails
+ //test!
+ m_ConfigList.deleteSelectedMails();
+}
+
+void KShowMailApp::slotShowHeader ()
+{
+ //only show headers, if the app is idle
+ if( m_state != idle )
+ {
+ kapp->beep ();
+ return;
+ }
+
+ //show the headers
+ m_ConfigList.showSelectedHeaders();
+
+}
+
+void KShowMailApp::slotShowMessage ()
+{
+ //return, if application is not idle
+ if( m_state != idle )
+ {
+ kapp->beep ();
+ return;
+ }
+
+ //return, if no mails are selected
+ if( !m_ConfigList.hasSelectedMails() )
+ return;
+
+ //set the state
+ m_state = showing;
+
+ //show status message
+ slotStatusMsg( i18n( "Downloading ..." ) );
+
+ //set waiting cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ //order the account list to show the selected mails
+ m_ConfigList.showSelectedMails();
+}
+
+void KShowMailApp::slotStatusMsg(const QString& text)
+{
+ //get current time
+ // added by Gustavo Zamorano to include time
+ QString sTime = QTime::currentTime ().toString ();
+
+ //clear status bar
+ statusBar()->clear();
+
+ //set given text
+ statusBar()->changeItem( text, STATUSBAR_FIELD_STATE );
+
+ //set current time
+ statusBar()->changeItem( i18n( "Last Refresh: %1" ).arg( sTime ), STATUSBAR_FIELD_LAST_REFRESH );
+}
+
+void KShowMailApp::slotStatusHelpMsg(const QString &text)
+{
+ statusBar()->message(text, 2000);
+}
+
+
+
+
+bool KShowMailApp::event(QEvent *e)
+{
+ // to hide the taskbar button; any better solution ??
+ if ((e->type() == QEvent::Hide) && m_ConfigList.minimizesToTray() ) {
+ hide ();
+ }
+
+ return(KMainWindow::event(e));
+}
+
+void KShowMailApp::slotForceClose()
+{
+ m_bForceClose = true;
+}
+
+bool KShowMailApp::askCloseConfirmation()
+{
+ bool result;
+
+ if( m_ConfigList.confirmClose() ) {
+ // Need to ask user
+ result = (KMessageBox::questionYesNo (this, i18n ("KShowmail will be closed.\n"
+ "Are you sure?")) == KMessageBox::Yes);
+ } else {
+ // User doesn't want to be asked - just close it
+ result = true;
+ }
+
+ return result;
+}
+
+void KShowMailApp::slotDeletionReady( )
+{
+ //set state to idle
+ m_state = idle;
+
+ //set normal cursor
+ while( QApplication::overrideCursor() )
+ QApplication::restoreOverrideCursor();
+
+ //show status message
+ slotStatusMsg( i18n( "Ready." ) );
+
+ //refresh mail list
+ slotRefresh();
+}
+
+void KShowMailApp::slotShowMessageReady( )
+{
+ //set state to idle
+ m_state = idle;
+
+ //set normal cursor
+ while( QApplication::overrideCursor() )
+ QApplication::restoreOverrideCursor();
+
+ //show status message
+ slotStatusMsg( i18n( "Ready." ) );
+
+
+}
+
+void KShowMailApp::slotNormalCursor( )
+{
+ //set normal cursor
+ while( QApplication::overrideCursor() )
+ QApplication::restoreOverrideCursor();
+
+}
+
+void KShowMailApp::slotWaitingCursor( )
+{
+ //set waiting cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+}
+
+void KShowMailApp::slotRefreshReady( )
+{
+ //set state to idle
+ m_state = idle;
+
+ //set normal cursor
+ while( QApplication::overrideCursor() )
+ QApplication::restoreOverrideCursor();
+
+ //refresh mail list view
+ slotRefreshView();
+
+ //inform the user about new mails
+ bool hasNewMails = m_ConfigList.getNumberNewMails() > 0;
+ if ( hasNewMails )
+ {
+ //show main window if desired
+ if( m_ConfigList.showMainWindowForNewMails() )
+ {
+ showNormal();
+ raise();
+ }
+
+ //get out some sounds
+ m_ConfigList.beep();
+ m_ConfigList.playSound();
+
+ //execute a command
+ m_ConfigList.executeNewMailCommand();
+
+ //show alert message if desired
+ if( m_ConfigList.showAlertMessageForNewMails() )
+ {
+ //have we created one already?
+ if( m_pAlertDialog != NULL )
+ {
+ //yes, we have one
+ m_pAlertDialog->show();
+ m_pAlertDialog->raise();
+ }
+ else
+ {
+ //create a message dialog
+ m_pAlertDialog = new AlertDialog( this );
+ connect( m_pAlertDialog, SIGNAL( destroyed() ), SLOT( slotAlertDestroyed() ) );
+ connect( m_pAlertDialog, SIGNAL( signalOk() ), SLOT( slotAlertOk() ) );
+ }
+ }
+
+ }
+ else
+ {
+ //no new mails was received
+ //perform configured actions
+
+ //terminate app if desired
+ if( m_ConfigList.quitNoNewMails() )
+ slotFileQuit();
+ else if( m_ConfigList.minimizeMainWindowNoNewMails() )
+ {
+ showMinimized();
+ hide();
+ }
+ }
+
+ //show status message
+ slotStatusMsg( i18n( "Ready." ) );
+
+
+ //prepare next refresh cycle
+ initNextRefresh();
+}
+
+void KShowMailApp::initFirstRefresh( )
+{
+ //is auto refresh on? if not, we do nothing
+ if( m_ConfigList.AutoRefreshOn() )
+ {
+ //is an initial time configured? if not, we refresh immediately
+ if( m_ConfigList.hasInitTime() )
+ {
+ //starts refresh timer with the configured initial time to first refresh
+ m_pTimer->start( m_ConfigList.getInitTime() * 1000, true );
+ m_nSecondsToGo = m_ConfigList.getInitTime();
+ }
+ else
+ {
+ //just to set a defined state
+ m_pTimer->stop();
+ m_nSecondsToGo = 0;
+
+ //start refresh cycle
+ slotRefresh();
+ }
+ }
+ else
+ {
+ //set a defined state
+ m_pTimer->stop();
+ m_nSecondsToGo = 0;
+ }
+}
+
+void KShowMailApp::stopRefreshTimer( )
+{
+ m_pTimer->stop();
+ m_nSecondsToGo = 0;
+}
+
+void KShowMailApp::initNextRefresh( )
+{
+ if( m_ConfigList.AutoRefreshOn() )
+ {
+ //auto refresh is activated
+ //restart the refresh timer
+ m_pTimer->start( m_ConfigList.getRefreshTimeInterval() * 60000, true );
+ m_nSecondsToGo = m_ConfigList.getRefreshTimeInterval() * 60;
+ }
+ else
+ {
+ //auto refresh is not activated
+ //set a defined state of the refresh timer
+ m_pTimer->stop();
+ m_nSecondsToGo = 0;
+ }
+}
+
+void KShowMailApp::delayNextRefresh( )
+{
+ const unsigned long DELAY_TIME = 60;
+
+ //delay only if the timer is active and the remaining time is less than one minute
+ if( m_pTimer->isActive() )
+ {
+ if( m_nSecondsToGo < DELAY_TIME )
+ {
+ m_pTimer->start( DELAY_TIME * 1000, true );
+ m_nSecondsToGo = DELAY_TIME;
+ }
+ }
+}
+
+void KShowMailApp::slotEditToolbars()
+{
+ //create the toolbar config dialog
+ KEditToolbar *dlg = new KEditToolbar(guiFactory());
+ if( dlg->exec() )
+ {
+ //if dialog closed by OK, create the GUI new
+ //the dialog has changed the kshowmailui.rc file
+ createGUI();
+ }
+
+ //destruct dialog
+ delete dlg;
+}
+
+void KShowMailApp::slotSetup( )
+{
+ //just open the dialog, if the app is idle
+ if (m_state != idle)
+ {
+ kapp->beep();
+ return;
+ }
+
+ //set application state
+ m_state = configure;
+
+ //stop the refresh timer
+ stopRefreshTimer();
+
+ if ( SetupDialog == NULL )
+ {
+ //if no preferences dialog was created as yet, create one
+ SetupDialog = new KCMultiDialog( KCMultiDialog::IconList, i18n( "Options" ), this, "SetupDialog" );
+ SetupDialog->addModule( "kshowmailconfigaccounts.desktop" );
+ SetupDialog->addModule( "kshowmailconfiggeneral.desktop" );
+ SetupDialog->addModule( "kshowmailconfigdisplay.desktop" );
+ SetupDialog->addModule( "kshowmailconfigactions.desktop" );
+ SetupDialog->addModule( "kshowmailconfigfilter.desktop" );
+ SetupDialog->addModule( "kshowmailconfigspamcheck.desktop" );
+ SetupDialog->addModule( "kshowmailconfiglog.desktop" );
+
+ //If the configuration was changed, it will call slotConfChanged
+ connect( SetupDialog, SIGNAL( configCommitted() ), this, SLOT( slotConfChanged() ) );
+ }
+
+ //execute preferences dialog
+ SetupDialog->exec();
+
+ //we are ready, set application state to idle and initiate next refresh
+ m_state = idle;
+ initNextRefresh();
+
+}
+
+void KShowMailApp::slotConfChanged( )
+{
+ //read the new setup
+ m_ConfigList.refreshSetup( m_pView->m_pListAccounts );
+ m_pView->refreshSetup();
+ fLog.loadSetup();
+
+}
+
+void KShowMailApp::slotShowFilterLog( )
+{
+ //open dialog
+ FilterLogView view( this, &fLog );
+ view.exec();
+
+ refreshFilterStatusBar();
+}
+
+void KShowMailApp::refreshFilterStatusBar( )
+{
+ int numberDeletedLastRefresh = m_ConfigList.numberDeletedMailsLastRefresh();
+ int numberDeletedSinceStart = m_ConfigList.numberDeletedMailsStart();
+ int numberDeletedLog = fLog.numberDeletedMails();
+
+ int numberMovedLastRefresh = m_ConfigList.numberMovedMailsLastRefresh();
+ int numberMovedSinceStart = m_ConfigList.numberMovedMailsStart();
+ int numberMovedLog = fLog.numberMovedMails();
+
+ int numberIgnored = m_ConfigList.numberIgnoredMails();
+
+ statusBar()->changeItem( i18n( "Filter: Deleted: %1/%2/%3; Moved: %4/%5/%6; Ignored: %7" ).arg( numberDeletedLastRefresh ).arg( numberDeletedSinceStart ).arg( numberDeletedLog ).arg( numberMovedLastRefresh ).arg( numberMovedSinceStart ).arg( numberMovedLog ).arg( numberIgnored ), STATUSBAR_FIELD_FILTER );
+}
+
+void KShowMailApp::slotAddToWhitelist( )
+{
+ //get new entries
+ QStringList newEntries = m_ConfigList.getSelectedSenders();
+
+ //get previous whitelist from config
+ KConfig* config = KApplication::kApplication()->config();
+ config->setGroup( CONFIG_GROUP_FILTER );
+ QStringList whiteList = config->readListEntry( CONFIG_ENTRY_FILTER_WHITELIST );
+
+ //append new entries
+ for( QStringList::Iterator it = newEntries.begin(); it != newEntries.end(); ++it )
+ {
+ if( whiteList.contains( *it ) == 0 )
+ {
+ whiteList.append( *it );
+ }
+ }
+
+ //write extended whitelist back
+ config->writeEntry( CONFIG_ENTRY_FILTER_WHITELIST, whiteList );
+ config->sync();
+
+ //load new config
+ m_ConfigList.refreshFilterSetup();
+}
+
+void KShowMailApp::slotAddToBlacklist( )
+{
+ //get new entries
+ QStringList newEntries = m_ConfigList.getSelectedSenders();
+
+ //get previous blacklist from config
+ KConfig* config = KApplication::kApplication()->config();
+ config->setGroup( CONFIG_GROUP_FILTER );
+ QStringList blackList = config->readListEntry( CONFIG_ENTRY_FILTER_BLACKLIST );
+
+ //append new entries
+ for( QStringList::Iterator it = newEntries.begin(); it != newEntries.end(); ++it )
+ {
+ if( blackList.contains( *it ) == 0 )
+ {
+ blackList.append( *it );
+ }
+ }
+
+ //write extended whitelist back
+ config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST, blackList );
+ config->sync();
+
+ //load new config
+ m_ConfigList.refreshFilterSetup();
+}
+
diff --git a/kshowmail/kshowmail.desktop b/kshowmail/kshowmail.desktop
new file mode 100644
index 0000000..54c5651
--- /dev/null
+++ b/kshowmail/kshowmail.desktop
@@ -0,0 +1,13 @@
+# KDE Config File
+[KDE Desktop Entry]
+Name=Kshowmail
+Encoding=UTF-8
+Type=Application
+Exec=kshowmail
+Icon=kshowmail
+DocPath=kshowmail/index.html
+Comment=A powerful POP3 mail checker
+Comment[de]=Ein leistungsf�higer POP3 Mailchecker
+Comment[en]=A powerful POP3 mail checker
+Terminal=0
+StartupNotify=true
diff --git a/kshowmail/kshowmail.h b/kshowmail/kshowmail.h
new file mode 100644
index 0000000..0d8dccb
--- /dev/null
+++ b/kshowmail/kshowmail.h
@@ -0,0 +1,424 @@
+/***************************************************************************
+ kshowmail.h - description
+ -------------------
+ begin : Sat May 6 12:13:57 MEST 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSHOWMAIL_H
+#define KSHOWMAIL_H
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// include files for KDE
+#include <kapplication.h>
+#include <kmainwindow.h>
+#include <kuniqueapplication.h>
+#include <kaction.h>
+#include <kstdaction.h>
+#include <klocale.h>
+#include <kstatusbar.h>
+#include <krun.h>
+#include <kpassdlg.h>
+#include <kdebug.h>
+#include <kedittoolbar.h>
+#include <kcmultidialog.h>
+
+
+//include files for KShowMail
+#include "configlist.h"
+#include "alertdialog.h"
+#include "showrecord.h"
+#include "showlistviewitem.h"
+#include "kshowmaildock.h"
+#include "kfeedback.h"
+#include "types.h"
+#include "kshowmailview.h"
+#include "kshowmaildoc.h"
+#include "serverdialog.h"
+#include "filterlog.h"
+#include "filterlogview.h"
+
+
+// forward declaration of the Kshowmail classes
+class KshowmailDoc;
+class KshowmailView;
+
+using namespace Types;
+
+/**
+ * The base class for Kshowmail application windows. It sets up the main
+ * window and reads the config file as well as providing a menubar, toolbar
+ * and statusbar. An instance of KshowmailView creates your center view, which is connected
+ * to the window's Doc object.
+ * KShowMailApp reimplements the methods that KMainWindow provides for main window handling and supports
+ * full session management as well as keyboard accelerator configuration by using KAccel.
+ * @see KMainWindow
+ * @see KApplication
+ * @see KConfig
+ * @see KAccel
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @version KDevelop version 0.4 code generation
+ */
+class KShowMailApp : public KMainWindow
+{
+ Q_OBJECT
+
+ friend class KshowmailView;
+ friend class KshowmailDock;
+ friend class UniqueApp;
+
+
+ private:
+
+ /**
+ * The central document of our application. Just contains the view (m_pView).
+ */
+ KshowmailDoc* m_pDoc;
+
+ /**
+ * Contains the account and messages list views.
+ */
+ KshowmailView *m_pView;
+
+ /**
+ * The setup dialog. Created and used by slotSetup().
+ */
+ KCMultiDialog* SetupDialog;
+
+ /**
+ * refresh messages action; connected with slotRefresh()
+ */
+ KAction* m_actionRefresh;
+
+ /**
+ * Contains the application and account settings. The account
+ * settings are stored in ConfigElem objects.
+ */
+ ConfigList m_ConfigList;
+
+ /**
+ * Message box which will be shown, when new mail has arrived.
+ */
+ AlertDialog* m_pAlertDialog;
+
+ /**
+ * The window into the system tray.
+ */
+ KShowMailDock* m_pDockWindow;
+
+ /**
+ * The refresh timer. Its timeout signal is connected with slotRefresh().
+ */
+ QTimer* m_pTimer;
+
+ /**
+ * Application state during the run time. Shows what KShowMail is doing :-) .
+ */
+ Types::State_Type m_state;
+
+ /**
+ * Number of seconds until the next refresh
+ */
+ unsigned long m_nSecondsToGo;
+
+ /**
+ * The filter log.
+ */
+ FilterLog fLog;
+
+
+ public:
+ /**
+ * Constructor of KShowMailApp, calls all init functions to create the application.
+ * @see initMenuBar initToolBar
+ */
+ KShowMailApp();
+
+ /**
+ * Destructor
+ */
+ ~KShowMailApp();
+
+ /**
+ * Contains information about KShowMail, including author, license, version etc.
+ * This is accessed in main() when calling KShowMailApp::initMenuBar() to create the help menu.
+ */
+ static KAboutData* m_pAbout;
+
+ /**
+ * Delays the next refresh for one minute.
+ */
+ void delayNextRefresh();
+
+
+ protected:
+
+ /**
+ * sets up the statusbar for the main window by initialzing a statuslabel.
+ */
+ void initStatusBar();
+
+ /**
+ * sets up the actions.
+ */
+ void initActions();
+
+ /**
+ * initializes the document object of the main window that is connected to the view in initView().
+ * @see initView();
+ */
+ void initDocument();
+
+ /**
+ * creates the centerwidget of the KMainWindow instance and sets it as the view
+ */
+ void initView();
+
+ /**
+ * queryClose is called by KMainWindow on each closeEvent of a window. Against the
+ * default implementation (only returns true), this calles saveModified() on the document object to ask
+ * if the document should be saved if Modified; on cancel the closeEvent is rejected.
+ * @see KMainWindow#queryClose
+ * @see KMainWindow#closeEvent
+ */
+ virtual bool queryClose();
+
+ /**
+ * queryExit is called by KMainWindow when the last window of the app is going to be closed during the closeEvent().
+ * Against the default implementation that just returns true, this calls saveOptions() to save the settings of
+ * the last window's properties.
+ * @see KMainWindow#queryExit
+ * @see KMainWindow#closeEvent
+ */
+ virtual bool queryExit();
+
+ /**
+ * overwrite method of QObject; will be invoked by the internal QObject-Timer
+ * the timer is set to 1 second in the construtor;
+ * this method sets the time to the next refresh in the statusbar and
+ * animates the "?" in the traybar, when the refresh is working
+ */
+ virtual void timerEvent( QTimerEvent * );
+
+ /**
+ * overwrite method of QWidget;
+ * to hide the taskbar button
+ */
+ virtual bool event(QEvent *e);
+
+ /**
+ * Starts the first refresh or starts the refresh timer
+ * with the configured init time.
+ */
+ void initFirstRefresh();
+
+ /**
+ * Stops the refresh timer.
+ */
+ void stopRefreshTimer();
+
+ /**
+ * Starts the refresh timer for the next refresh.
+ */
+ void initNextRefresh();
+
+ /**
+ * Refreshes the status bar filter field.
+ */
+ void refreshFilterStatusBar();
+
+ protected slots:
+
+ /**
+ * Changes the status message of the whole statusbar for two seconds,
+ * then restores the last status. This is used to display
+ * statusbar messages that give information about actions for toolbar
+ * icons and menu entries.
+ * @param text the text that is displayed in the statusbar
+ */
+ void slotStatusHelpMsg(const QString &text);
+
+ /**
+ * Changes the contents in the left status bar item permanently,
+ * used to indicate current actions. And sets the current time
+ * in the right item.
+ * @param text the text that is displayed in the statusbar
+ */
+ void slotStatusMsg(const QString &text);
+
+ /**
+ * Connected with the setup dialog.
+ * Reloads the configuration, if it was changed from the dialog.
+ */
+ void slotConfChanged();
+
+ /**
+ * Connected with action m_actionDelete.
+ * Deletes all selected mails.
+ */
+ void slotDelete();
+
+ /**
+ * Connected with signal sigDeleteReady of m_ConfigList.
+ * This signal will be emitted when one or many accounts have
+ * ended a deletion.
+ * This slot refreshes the view, sets the state to idle and sets
+ * a normal cursor.
+ */
+ void slotDeletionReady();
+
+ /**
+ * Connected with action m_actionShowMessage.
+ * Shows all selected mails.
+ */
+ void slotShowMessage();
+
+ /**
+ * Connected with signal sigShowBodiesReady of m_ConfigList.
+ * This signal will be emitted when all accounts have downloaded
+ * and shown the selected messages.
+ * This slot sets the state to idle and sets a normal cursor.
+ */
+ void slotShowMessageReady();
+
+ /**
+ * Connected with signal sigMessageWindowOpened of m_ConfigList.
+ * This signal will be emitted when a window to show a mail body
+ * was opened.
+ * Switches the cursor to normal view.
+ */
+ void slotNormalCursor();
+
+ /**
+ * Connected with signal sigAllMessageWindowsClosed of m_ConfigList.
+ * This signal will be emitted when all windows to show a mail body
+ * have been closed.
+ * Switches the cursor to waiting view.
+ */
+ void slotWaitingCursor();
+
+ /**
+ * Connected with m_actionRefresh.
+ * Refreshes the mail list.
+ */
+ void slotRefresh();
+
+ /**
+ * Connected with signal sigRefreshReady of m_ConfigList.
+ * This signal will be emitted when all accounts have refreshed
+ * their mail list.
+ * This slot refreshes the mail view.
+ */
+ void slotRefreshReady();
+
+ /**
+ * Connected with signal destroyed of the alert message dialog.
+ * Sets m_pAlertDialog to NULL, if the dialog was destroyed.
+ * If m_pAlertDialog == NULL, slotRefreshReady will create a new instance of it.
+ * @see m_pAlertDialog
+ * @see slotRefreshReady()
+ */
+ void slotAlertDestroyed();
+
+ /**
+ * Connected with signal signalOk of the alert message dialog.
+ * Switches the main window to normal view.
+ * @see m_pAlertDialog;
+ */
+ void slotAlertOk ();
+
+ /**
+ * Refreshes the account and messages list view.
+ */
+ void slotRefreshView ();
+
+ /**
+ * If the application state is not "idle" it will stop all current running POP3 jobs.
+ * Connected with m_actionStop().
+ */
+ void slotStop ();
+
+ /**
+ * Shows the headers of all selected mails.
+ * Connected with action m_actionShowHeader.
+ */
+ void slotShowHeader();
+
+ /**
+ * Connected with standard action configureToolbars.
+ * Opens a dialog to configure the icons of the toolbar.
+ */
+ void slotEditToolbars();
+
+ /**
+ * Saves GUI options, account and filter settings to the configuration file.
+ */
+ void slotSaveOptions();
+
+ /**
+ * Calls the close() method of KShowMailApp to exit the application. Uses askCloseConfirmation() to ask
+ * the user (if configured). Sets m_bForceClose to TRUE, therefore queryClose() will be passed without
+ * anything to do. After that in queryExit() slotSaveOptions() will be invoked.
+ */
+ void slotFileQuit();
+
+ /**
+ * Opens the setup dialog for the highlighted account. Connected with m_actionSetupAccount.
+ */
+ void slotSetupAccount();
+
+ /**
+ * Connected with the standard setup action.
+ * If the application state is "idle" (m_state == idle) it will open the configuration dialog.
+ */
+ void slotSetup();
+
+ /**
+ * Shows the filter log.
+ */
+ void slotShowFilterLog();
+
+ /**
+ * Adds the sender of the selected mails to the whitelist
+ */
+ void slotAddToWhitelist();
+
+ /**
+ * Adds the sender of the selected mails to the blacklist
+ */
+ void slotAddToBlacklist();
+
+ void slotAccountActivated(QListViewItem*);
+ void slotSendFeedbackMail();
+ void slotForceClose();
+
+
+
+
+private:
+
+ bool m_bForceClose;
+
+
+ protected:
+ void addFeatureList(KFeedbackQuestion * question);
+ bool askCloseConfirmation();
+
+};
+
+#endif // KSHOWMAIL_H
diff --git a/kshowmail/kshowmaildoc.cpp b/kshowmail/kshowmaildoc.cpp
new file mode 100644
index 0000000..05516ac
--- /dev/null
+++ b/kshowmail/kshowmaildoc.cpp
@@ -0,0 +1,81 @@
+/***************************************************************************
+ kshowmaildoc.cpp - description
+ -------------------
+ begin : Fre Sep 28 23:29:54 CEST 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+// include files for Qt
+#include <qdir.h>
+#include <qwidget.h>
+
+// include files for KDE
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kio/job.h>
+#include <kio/netaccess.h>
+
+// application specific includes
+#include "kshowmaildoc.h"
+#include "kshowmail.h"
+#include "kshowmailview.h"
+
+KshowmailView *KshowmailDoc::pView = 0L;
+
+KshowmailDoc::KshowmailDoc(QWidget *parent, const char *name) : QObject(parent, name)
+{
+}
+
+KshowmailDoc::~KshowmailDoc()
+{
+}
+
+void KshowmailDoc::addView(KshowmailView *view)
+{
+ pView = view;
+}
+
+void KshowmailDoc::removeView(KshowmailView*)
+{
+ delete pView;
+}
+
+void KshowmailDoc::setURL(const KURL &url)
+{
+ doc_url=url;
+}
+
+const KURL& KshowmailDoc::URL() const
+{
+ return doc_url;
+}
+
+// this could be deleted; perhaps we build a tree view sometime ?
+void KshowmailDoc::slotUpdateAllViews(KshowmailView *sender)
+{
+ if(pView)
+ {
+ if(pView!=sender)
+ pView->repaint();
+ }
+}
+
+bool KshowmailDoc::newDocument()
+{
+ /////////////////////////////////////////////////
+ // TODO: Add your document initialization code here
+ /////////////////////////////////////////////////
+ doc_url.setFileName(i18n("Untitled"));
+
+ return true;
+}
diff --git a/kshowmail/kshowmaildoc.h b/kshowmail/kshowmaildoc.h
new file mode 100644
index 0000000..7f9a541
--- /dev/null
+++ b/kshowmail/kshowmaildoc.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ kshowmaildoc.h - description
+ -------------------
+ begin : Fre Sep 28 23:29:54 CEST 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSHOWMAILDOC_H
+#define KSHOWMAILDOC_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// include files for QT
+#include <qobject.h>
+#include <qstring.h>
+
+// include files for KDE
+#include <kurl.h>
+
+// forward declaration of the Kshowmail classes
+class KshowmailView;
+
+/** KshowmailDoc provides a document object for a document-view model.
+ *
+ * The KshowmailDoc class provides a document object that can be used in conjunction with the classes KshowmailApp and KshowmailView
+ * to create a document-view model for standard KDE applications based on KApplication and KMainWindow. Thereby, the document object
+ * is created by the KshowmailApp instance and contains the document structure with the according methods for manipulation of the document
+ * data by KshowmailView objects. Also, KshowmailDoc contains the methods for serialization of the document data from and to files.
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @version KDevelop version 1.2 code generation
+ */
+class KshowmailDoc : public QObject
+{
+ Q_OBJECT
+ public:
+ /** Constructor for the fileclass of the application */
+ KshowmailDoc(QWidget *parent, const char *name=0);
+ /** Destructor for the fileclass of the application */
+ ~KshowmailDoc();
+
+ /** adds a view to the document which represents the document contents. Usually this is your main view. */
+ void addView(KshowmailView *view);
+ /** removes a view from the list of currently connected views */
+ void removeView(KshowmailView *view);
+ /** initializes the document generally */
+ bool newDocument();
+ /** returns the KURL of the document */
+ const KURL& URL() const;
+ /** sets the URL of the document */
+ void setURL(const KURL& url);
+
+ public slots:
+ /** calls repaint() on all views connected to the document object and is called by the view by which the document has been changed.
+ * As this view normally repaints itself, it is excluded from the paintEvent.
+ */
+ void slotUpdateAllViews(KshowmailView *sender);
+
+ public:
+ /** the list of the views currently connected to the document */
+ // no List; just one view
+ static KshowmailView *pView;
+
+ private:
+ /** the modified flag of the current document */
+ KURL doc_url;
+};
+
+#endif // KSHOWMAILDOC_H
diff --git a/kshowmail/kshowmaildock.cpp b/kshowmail/kshowmaildock.cpp
new file mode 100644
index 0000000..c5eaa97
--- /dev/null
+++ b/kshowmail/kshowmaildock.cpp
@@ -0,0 +1,83 @@
+/***************************************************************************
+ kshowmaildock.cpp - description
+ -------------------
+ begin : Wed Jan 3 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <qpixmap.h>
+#include <qpainter.h>
+#include <qtooltip.h>
+
+#include <kpopupmenu.h>
+#include <kstandarddirs.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "kshowmail.h"
+#include "kshowmaildock.h"
+
+KShowMailDock::KShowMailDock(QWidget* parent, KAction *actionRefresh )
+: KSystemTray (parent, 0),
+ m_background (QPixmap(::locate ("data", "kshowmail/pics/kshowmail24.png")))
+{
+// kdDebug () << "KShowMailDock::KShowMailDock" << endl;
+ drawText ("?", Qt::red);
+ QToolTip::add (this, i18n("KShowmail: a powerful pop3 email checker"));
+
+ show();
+
+ actionRefresh->plug( contextMenu() );
+ //((KShowMailApp*)parent)->m_actionRefresh->plug (contextMenu());
+ connect (contextMenu(),SIGNAL(activated(int)),this, SIGNAL(sigActivated(int)));
+ connect (contextMenu(),SIGNAL(highlighted(int)),this, SIGNAL(sigHighlighted(int)));
+}
+
+void KShowMailDock::drawText (const QString str, const QColor& color)
+{
+ setPixmap (m_background);
+ QPixmap* pix = pixmap ();
+ if (pix && !pix->isNull ())
+ {
+ QPainter p (pix);
+// p.setFont (KGlobalSettings::toolBarFont());
+ p.setFont (KGlobalSettings::windowTitleFont());
+ p.setPen (color);
+ p.drawText (0,0,24,24,QPainter::AlignCenter,str,str.length());
+ }
+ else
+ kdError () << "No pixmap for traybar !" << endl;
+}
+
+void KShowMailDock::drawNumber (int n, const QColor& color)
+{
+ setPixmap (m_background);
+ QPixmap* pix = pixmap ();
+ if (pix && !pix->isNull ())
+ {
+ QString num (QString::number(n));
+ QPainter p (pix);
+ p.setFont (KGlobalSettings::toolBarFont());
+ p.setPen (color);
+ p.drawText (0,0,24,24,QPainter::AlignCenter,num,num.length());
+ }
+ else
+ kdError () << "No pixmap for traybar !" << endl;
+}
+
+void KShowMailDock::clear ()
+{
+ setPixmap (m_background);
+}
+
diff --git a/kshowmail/kshowmaildock.h b/kshowmail/kshowmaildock.h
new file mode 100644
index 0000000..bc84f5b
--- /dev/null
+++ b/kshowmail/kshowmaildock.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ kshowmaildock.h - description
+ -------------------
+ begin : Wed Jan 3 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSHOWMAILDOCK_H
+#define KSHOWMAILDOCK_H
+
+#include <qwidget.h>
+#include <qpixmap.h>
+#include <ksystemtray.h>
+#include <kaction.h>
+
+/**
+ *@author Eggert Ehmke
+ */
+
+class KShowMailDock : public KSystemTray
+{
+ Q_OBJECT
+public:
+ KShowMailDock(QWidget*, KAction *actionRefresh );
+ ~KShowMailDock() {};
+ void drawText (const QString str, const QColor& color);
+ void drawNumber (int n, const QColor& color);
+ void clear ();
+signals:
+ void sigActivated(int);
+ void sigHighlighted(int);
+private:
+ QPixmap m_background;
+};
+
+#endif
diff --git a/kshowmail/kshowmailfeedback.cpp b/kshowmail/kshowmailfeedback.cpp
new file mode 100644
index 0000000..b1fe297
--- /dev/null
+++ b/kshowmail/kshowmailfeedback.cpp
@@ -0,0 +1,159 @@
+/*
+ * File name: kshowmailfeedback.cpp
+ * Summary: User feedback questions for KShowmail
+ * License: GPL - See file COPYING for details.
+ *
+ * Author: Stefan Hundhammer <sh@suse.de>
+ * Eggert Ehmke <eggert.ehmke@berlin.de>
+ *
+ * Updated: 2002-05-30
+ *
+ * $Id: kshowmailfeedback.cpp,v 1.8 2008/04/17 20:13:20 kuddel-fl Exp $
+ *
+ */
+
+
+#include <klocale.h>
+
+#include "kshowmail.h"
+#include "kfeedback.h"
+
+
+
+void KShowMailApp::slotSendFeedbackMail()
+{
+ KFeedbackDialog* feedbackDialog = new KFeedbackDialog( "eggert.ehmke@berlin.de, ulrich.weigelt@gmx.de", "feedback_mail" );
+ CHECK_PTR( feedbackDialog );
+
+ KFeedbackQuestionList * list = feedbackDialog->form()->questionList();
+
+ KFeedbackQuestion * question =
+ list->addQuestion( i18n( "What is your general opinion about this program?" ), "general_opinion", true, true );
+
+ question->addAnswer( i18n( "It's one of my favourites"), "1/8_favourite");
+ question->addAnswer( i18n( "I like it"), "2/8_like_it");
+ question->addAnswer( i18n( "It's sometimes useful"), "3/8_sometimes_useful");
+ question->addAnswer( i18n( "It's average"), "4/8_average");
+ question->addAnswer( i18n( "Nice try, but this could be done better"), "5/8_nice_try");
+ question->addAnswer( i18n( "It's poor"), "6/8_poor");
+ question->addAnswer( i18n( "It's useless"), "7/8_useless");
+ question->addAnswer( i18n( "It's crap"), "8/8_crap");
+
+ question = list->addQuestion( i18n( "Which features of this program do you like?" ), "features_liked", false );
+ addFeatureList( question );
+
+ question = list->addQuestion( i18n( "What is your favourite feature?" ), "favourite_feature", true );
+ addFeatureList( question );
+
+ question = list->addQuestion( i18n( "Which features don't you like?" ), "features_not_liked", false );
+ addFeatureList( question );
+
+ question = list->addQuestion( i18n( "Which features do you never use?" ), "features_never_used", false );
+ addFeatureList( question );
+
+ question = list->addQuestion( i18n( "Are there features you are missing?" ), "features_missing", true );
+ question->addAnswer( i18n( "Yes, a lot! (please add comment below)" ), "1/4_lots" );
+ question->addAnswer( i18n( "Some (please add comment below)" ), "2/4_some" );
+ question->addAnswer( i18n( "None" ), "3/4_none" );
+ question->addAnswer( i18n( "It has too many features already!" ), "4/4_too_many_already" );
+
+ question = list->addQuestion( i18n( "How do you rate the stability of this program?" ), "stability", true, true );
+ question->addAnswer( i18n( "Rock solid"), "1/5_rock_solid" );
+ question->addAnswer( i18n( "Good"), "2/5_good");
+ question->addAnswer( i18n( "Average"), "3/5_average");
+ question->addAnswer( i18n( "Poor"), "4/5_poor" );
+ question->addAnswer( i18n( "It keeps crashing all the time"), "5/5_keeps_crashing" );
+
+ question = list->addQuestion( i18n( "How do you rate the performance of this program?" ), "performance", true );
+ question->addAnswer( i18n( "Great"), "1/5_great");
+ question->addAnswer( i18n( "Good"), "2/5_good");
+ question->addAnswer( i18n( "Average"), "3/5_average");
+ question->addAnswer( i18n( "Poor"), "4/5_poor");
+ question->addAnswer( i18n( "It's so slow it drives me nuts"), "5/5_drives_me_nuts");
+
+ question = list->addQuestion( i18n( "What is your experience with computers in general?" ), "computer_experience", true );
+ question->addAnswer( i18n( "Expert" ), "1/5_expert" );
+ question->addAnswer( i18n( "Fair" ), "2/5_fair" );
+ question->addAnswer( i18n( "Average" ), "3/5_average" );
+ question->addAnswer( i18n( "Learning" ), "4/5_learning" );
+ question->addAnswer( i18n( "Newbie" ), "5/5_newbie" );
+
+ question = list->addQuestion( i18n( "What is your experience with Unix/Linux systems?" ), "unix_experience", true );
+ question->addAnswer( i18n( "Expert" ), "1/5_expert" );
+ question->addAnswer( i18n( "Fair" ), "2/5_fair" );
+ question->addAnswer( i18n( "Average" ), "3/5_average" );
+ question->addAnswer( i18n( "Learning" ), "4/5_learning" );
+ question->addAnswer( i18n( "Newbie" ), "5/5_newbie" );
+
+ question = list->addQuestion( i18n( "Did you have trouble figuring out how to work with this program?" ),
+ "learning_curve", true, true );
+ question->addAnswer( i18n( "No problem" ), "1/5_no_problem" );
+ question->addAnswer( i18n( "Some" ), "2/5_some_problems" );
+ question->addAnswer( i18n( "I'm still learning" ), "3/5_still_learing" );
+ question->addAnswer( i18n( "I didn't have a clue what to do at first" ), "4/5_no_clue_at_first" );
+ question->addAnswer( i18n( "I still don't have a clue what to do" ), "5/5_still_no_clue" );
+
+ question = list->addQuestion( i18n( "Where do you use this program most?" ), "usage_where", true );
+ question->addAnswer( i18n( "At work" ), "at_work" );
+ question->addAnswer( i18n( "At home" ), "at_home" );
+ question->addAnswer( i18n( "At university / school" ), "university" );
+
+ question = list->addQuestion( i18n( "What is your primary role there?" ), "primary_role", true );
+ question->addAnswer( i18n( "Home user" ), "home_user" );
+ question->addAnswer( i18n( "Student" ), "student" );
+ question->addAnswer( i18n( "Educational (teacher / professor)" ), "educational" );
+ question->addAnswer( i18n( "Non-computer related work" ), "non_computer" );
+ question->addAnswer( i18n( "Developer" ), "developer" );
+ question->addAnswer( i18n( "System administrator" ), "sysadmin" );
+
+ question = list->addQuestion( i18n( "Do you have any other roles there?" ), "other_roles", false );
+ question->addAnswer( i18n( "Home user" ), "home_user" );
+ question->addAnswer( i18n( "Student" ), "student" );
+ question->addAnswer( i18n( "Educational (teacher / professor)" ), "educational" );
+ question->addAnswer( i18n( "Non-computer related work" ), "non_computer" );
+ question->addAnswer( i18n( "Developer" ), "developer" );
+ question->addAnswer( i18n( "System administrator" ), "sysadmin" );
+
+ question = list->addQuestion( i18n( "How did you get to know this program?" ), "first_contact", true );
+ question->addAnswer( i18n( "In a menu on my machine" ), "menu" );
+ question->addAnswer( i18n( "Somebody told me about it" ), "told" );
+ question->addAnswer( i18n( "On the internet" ), "internet" );
+ question->addAnswer( i18n( "Printed magazine / book" ), "print_media" );
+ question->addAnswer( i18n( "Other (please add comment below)" ), "other" );
+
+ list->addYesNoQuestion( i18n( "Would you recommend this program to a friend?" ), "recommend", true );
+
+ feedbackDialog->show();
+}
+
+
+void KShowMailApp::addFeatureList( KFeedbackQuestion * question )
+{
+ question->addAnswer( i18n( "The message list display in general"), "message_list" );
+ question->addAnswer( i18n( "Display of message headers" ), "message_header" );
+ question->addAnswer( i18n( "Display of complete messages"), "complete_message" );
+
+ question->addAnswer( i18n( "Filters" ), "filters" );
+ question->addAnswer( i18n( "Manual delete of unwanted messages"), "manual_delete_messages" );
+ question->addAnswer( i18n( "Automatic move of filtered messages" ), "move_messages" );
+ question->addAnswer( i18n( "Automatic delete of filtered messages" ), "delete_messages" );
+ question->addAnswer( i18n( "Automatic mark of filtered messages" ), "mark_messages" );
+ question->addAnswer( i18n( "Ignoring of filtered messages" ), "ignoring_messages" );
+ question->addAnswer( i18n( "Integration of SpamAssassin" ), "SpamAssassin_Integration" );
+ question->addAnswer( i18n( "White- and Blacklist" ), "white_blacklist" );
+ question->addAnswer( i18n( "Filter Log" ), "filter_log" );
+ question->addAnswer( i18n( "Filter messages by regular expressions"), "filter_messages_by regular_expression" );
+
+
+ question->addAnswer( i18n( "Sorting of messages by size, date etc." ), "sorting" );
+
+ question->addAnswer( i18n( "Play sound"), "play_sound" );
+ question->addAnswer( i18n( "Play beep"), "play_beep" );
+ question->addAnswer( i18n( "Initial timer"), "initial_timer" );
+ question->addAnswer( i18n( "Interval timer"), "interval_timer" );
+ question->addAnswer( i18n( "This feedback survey :-)"), "feedback" );
+}
+
+
+
+// EOF
diff --git a/kshowmail/kshowmailui.rc b/kshowmail/kshowmailui.rc
new file mode 100644
index 0000000..ace6ca4
--- /dev/null
+++ b/kshowmail/kshowmailui.rc
@@ -0,0 +1,45 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kshowmail" version="3">
+ <MenuBar>
+ <Menu name="actions"><text>&amp;Actions</text>
+ <Action name="refresh"/>
+ <Action name="stop"/>
+ <Separator/>
+ <Action name="show_header"/>
+ <Action name="show_complete"/>
+ <Action name="delete"/>
+ <Separator/>
+ <Action name="addWhitelist"/>
+ <Action name="addBlacklist"/>
+ <Separator/>
+ <Action name="show_filterlog"/>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Merge name="StandardToolBarMenuHandler" />
+ </Menu>
+ <Menu name="help"><text>&amp;Help</text>
+ <Action name="sendFeedback"/>
+ </Menu>
+ </MenuBar>
+
+ <Menu name="mail_context_popup">
+ <Action name="show_header"/>
+ <Action name="show_complete"/>
+ <Action name="delete"/>
+ <Separator/>
+ <Action name="addWhitelist"/>
+ <Action name="addBlacklist"/>
+ </Menu>
+
+ <Menu name="account_context_popup">
+ <Action name="refresh"/>
+ <Action name="setupAccount"/>
+ </Menu>
+
+ <ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
+ <Action name="refresh"/>
+ <Action name="delete"/>
+ <Action name="options_configure"/>
+ <Action name="file_quit" />
+ </ToolBar>
+</kpartgui> \ No newline at end of file
diff --git a/kshowmail/kshowmailview.cpp b/kshowmail/kshowmailview.cpp
new file mode 100644
index 0000000..d7fb3a5
--- /dev/null
+++ b/kshowmail/kshowmailview.cpp
@@ -0,0 +1,449 @@
+/***************************************************************************
+ kshowmailview.cpp - description
+ -------------------
+ begin : Sat May 6 12:13:57 MEST 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+
+ 26 Sep 2002 - Allow for columns to be hidden. Allistar Melville
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+// include files for Qt
+#include <qprinter.h>
+#include <qpainter.h>
+#include <qmessagebox.h>
+#include <qkeycode.h>
+#include <qvaluelist.h>
+
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+// application specific includes
+#include "kshowmailview.h"
+#include "kshowmaildoc.h"
+#include "kshowmail.h"
+
+KshowmailView::KshowmailView(QWidget *parent, const char *name):
+ QSplitter(Vertical, parent, name)
+{
+ setBackgroundMode( PaletteBase );
+ setFocusPolicy( QWidget::StrongFocus );
+
+ //get application config object (kshowmailrc)
+ config = KApplication::kApplication()->config();
+
+ //load active pic for the account list
+ m_pixOk = new QPixmap( ::locate( "data", "kshowmail/pics/ok.png" ) );
+
+ //create account list
+ m_pListAccounts = new KListView( this, "accounts" );
+ m_pListAccounts->setSelectionMode( QListView::Extended );
+ m_pListAccounts->setSorting( 1 ); // sort account column
+ m_pListAccounts->setShowSortIndicator( true );
+ m_pListAccounts->addColumn( i18n( "Active" ), DEFAULT_WIDTH_ACCOUNT_ACTIVE );
+ m_pListAccounts->addColumn( i18n( "Account" ), DEFAULT_WIDTH_ACCOUNT_ACCOUNT );
+ m_pListAccounts->addColumn( i18n( "Server" ), DEFAULT_WIDTH_ACCOUNT_SERVER );
+ m_pListAccounts->addColumn( i18n( "User" ), DEFAULT_WIDTH_ACCOUNT_USER );
+ m_pListAccounts->addColumn( i18n( "Messages" ), DEFAULT_WIDTH_ACCOUNT_MESSAGES );
+ m_pListAccounts->addColumn( i18n( "Size" ), DEFAULT_WIDTH_ACCOUNT_SIZE );
+ m_pListAccounts->setAllColumnsShowFocus( true );
+ connect( m_pListAccounts, SIGNAL( rightButtonClicked( QListViewItem*, const QPoint &, int ) ), SLOT( slotAccountContext( QListViewItem*, const QPoint &, int ) ) );
+ connect( m_pListAccounts, SIGNAL( clicked( QListViewItem*, const QPoint &, int) ), SLOT( slotAccountClicked( QListViewItem*, const QPoint &, int ) ) );
+
+ //create message list
+ m_pListMessages = new KListView( this, "messages" );
+ m_pListMessages->setSelectionMode( QListView::Extended );
+ m_pListMessages->setAllColumnsShowFocus( true );
+ m_pListMessages->setSorting( ShowListViewItem::_colNumber ); // sort number column
+ m_pListMessages->setShowSortIndicator( true );
+ m_pListMessages->addColumn( i18n( "Number" ), DEFAULT_WIDTH_MESSAGE_NUMBER );
+ m_pListMessages->addColumn( i18n( "Account" ), DEFAULT_WIDTH_MESSAGE_ACCOUNT );
+ m_pListMessages->addColumn( i18n( "From" ), DEFAULT_WIDTH_MESSAGE_FROM );
+ m_pListMessages->addColumn( i18n( "To" ), DEFAULT_WIDTH_MESSAGE_TO );
+ m_pListMessages->addColumn( i18n( "Subject" ), DEFAULT_WIDTH_MESSAGE_SUBJECT );
+ m_pListMessages->addColumn( i18n( "Date" ), DEFAULT_WIDTH_MESSAGE_DATE );
+ m_pListMessages->addColumn( i18n( "Size" ), DEFAULT_WIDTH_MESSAGE_SIZE );
+ m_pListMessages->addColumn( i18n( "Content" ), DEFAULT_WIDTH_MESSAGE_CONTENT );
+ m_pListMessages->addColumn( i18n( "State" ), DEFAULT_WIDTH_MESSAGE_STATE );
+ connect( m_pListMessages, SIGNAL( rightButtonClicked( QListViewItem*, const QPoint &, int) ), SLOT( slotMessageContext( QListViewItem*, const QPoint &, int ) ) );
+ connect( m_pListMessages, SIGNAL( doubleClicked( QListViewItem* ) ), SLOT( slotMessageDoubleClicked( QListViewItem* ) ) );
+ connect( m_pListMessages, SIGNAL( clicked( QListViewItem* ) ), SLOT( slotMessageClicked( QListViewItem* ) ) );
+
+ //read the geometry from the application config file
+ readOptions();
+
+
+}
+
+KshowmailView::~KshowmailView()
+{
+ delete m_pListAccounts;
+ delete m_pListMessages;
+}
+
+void KshowmailView::readOptions()
+{
+ //read splitter geometry
+ config->setGroup ("Display Options");
+ QValueList<int> size;
+ size.append (config->readNumEntry ("sizeaccounts", 40));
+ size.append (config->readNumEntry ("sizemessages", 50));
+ setSizes (size);
+
+ // read layout of the list views
+ m_pListAccounts->restoreLayout( config, CONFIG_GROUP_ACCOUNT_LIST );
+ m_pListMessages->restoreLayout( config, CONFIG_GROUP_MESSAGE_LIST );
+}
+
+void KshowmailView::saveOptions (KConfig* config)
+{
+// kdDebug () << "KshowmailView::saveOptions" << endl;
+ config->setGroup("Display Options");
+ //splitter
+ QValueList<int> size = sizes ();
+ config->writeEntry ("sizeaccounts", size [0]);
+ config->writeEntry ("sizemessages", size [1]);
+ // layout
+ m_pListAccounts->saveLayout ( config, CONFIG_GROUP_ACCOUNT_LIST );
+ m_pListMessages->saveLayout (config, CONFIG_GROUP_MESSAGE_LIST );
+}
+
+
+void KshowmailView::slotMessageContext( QListViewItem* pItem, const QPoint&, int )
+{
+ if( pItem != NULL )
+ {
+ //get pointer to the main widget
+ KShowMailApp* theApp = ( KShowMailApp * )parentWidget();
+
+ //create and show popup menu
+ QWidget* w = theApp->factory()->container( "mail_context_popup", theApp );
+ QPopupMenu* popup = static_cast<QPopupMenu*>( w );
+ popup->exec( QCursor::pos() );
+
+ //select clicked item
+ m_pListMessages->setSelected (pItem, true);
+ }
+}
+
+void KshowmailView::slotAccountContext( QListViewItem* pItem, const QPoint&, int )
+{
+ if ( pItem != NULL )
+ {
+ //get pointer to the main widget
+ KShowMailApp* theApp = ( KShowMailApp * )parentWidget();
+
+ //create and show popup menu
+ QWidget* w = theApp->factory()->container( "account_context_popup", theApp );
+ QPopupMenu* popup = static_cast<QPopupMenu*>( w );
+ popup->exec( QCursor::pos() );
+
+ //select clicked item
+ m_pListAccounts->setSelected( pItem, true );
+ }
+}
+
+void KshowmailView::slotAccountClicked( QListViewItem* pItem, const QPoint&, int col )
+{
+
+ //get application config object (kshowmailrc)
+ KConfig* config = KApplication::kApplication()->config();
+
+ if( col == 0 )
+ {
+ KShowMailApp *theApp = (KShowMailApp *)parentWidget();
+ ConfigElem* pElem = theApp->m_ConfigList.getSelectedAccount();
+
+ if( pElem != NULL )
+ {
+ //get account name
+ QString name = pElem->getAccountName();
+
+ //set config group
+ config->setGroup( name );
+
+ //toggle account active state
+ pElem->setActive( !pElem->isActive() );
+
+ if( pElem->isActive() )
+ {
+ //set active picture
+ pItem->setPixmap( 0, *m_pixOk );
+
+ //write active state into config file
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, true );
+ config->sync();
+ }
+ else
+ {
+ //remove active picture
+ pItem->setPixmap( 0, 0 );
+
+ //write active state into config file
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, false );
+ config->sync();
+ }
+
+ emit signalActiveChanged ();
+ }
+ }
+}
+
+void KshowmailView::slotMessageDoubleClicked (QListViewItem* pItem)
+{
+ if (pItem)
+ {
+// m_pListMessages->setSelected (pItem, true);
+
+ KShowMailApp *theApp=(KShowMailApp *) parentWidget();
+ theApp->slotShowHeader ();
+ }
+}
+
+void KshowmailView::slotMessageClicked (QListViewItem* pItem)
+{
+ if (pItem)
+ {
+// m_pListMessages->setSelected (pItem, true);
+
+ KShowMailApp *theApp=(KShowMailApp *) parentWidget();
+ theApp->delayNextRefresh();
+ }
+}
+
+void KshowmailView::clearMailListView( )
+{
+ m_pListMessages->clear();
+}
+
+ShowListViewItem* KshowmailView::insertMail( QString& number, QString& account, QString& from, QString& to, QString& subject, QString& date, QString& size, QString& content, QString& state, QString& time )
+{
+ //create item
+ ShowListViewItem* item = new ShowListViewItem( m_pListMessages );
+
+ //set content
+ item->setNumber( number );
+ item->setAccount( account );
+ item->setFrom( from );
+ item->setTo( to );
+ item->setSubject( subject );
+ item->setDate( date );
+ item->setSize( size );
+ item->setContent( content );
+ item->setState( state );
+ item->setTime( time );
+
+ return item;
+}
+
+void KshowmailView::refreshSetup( )
+{
+ QString ConfigEntryDisplay; //entry of the config about show or hide column
+ QString ConfigEntrySavedWidth; //entry of the config about saved width
+ int DefaultWidth = 100; //default width of the proceeded column
+ bool DefaultDisplay = true; //default show or hide of the proceeded column
+
+ //set columns of the account list
+ config->setGroup( CONFIG_GROUP_ACCOUNT_LIST );
+ for( int column = 0; column <= 5; column++ ) //iterate over all columns
+ {
+ //get config entries and defaults of the proceeded column from the constants header
+ switch( column )
+ {
+ case 0: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_ACTIVE;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_ACTIVE;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_ACTIVE;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_ACTIVE;
+ break;
+
+ case 1: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_ACCOUNT;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_ACCOUNT;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_ACCOUNT;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_ACCOUNT;
+ break;
+
+ case 2: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_SERVER;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_SERVER;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_SERVER;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_SERVER;
+ break;
+
+ case 3: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_USER;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_USER;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_USER;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_USER;
+ break;
+
+ case 4: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_MESSAGES;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_MESSAGES;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_MESSAGES;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_MESSAGES;
+ break;
+
+ case 5: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_ACCOUNT_SIZE;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_ACCOUNT_SIZE;
+ DefaultWidth = DEFAULT_WIDTH_ACCOUNT_SIZE;
+ DefaultDisplay = DEFAULT_DISPLAY_ACCOUNT_SIZE;
+ break;
+ } //end select
+
+ //get desired column state
+ bool showColumn = config->readBoolEntry( ConfigEntryDisplay, DefaultDisplay );
+
+ //get currently column state
+ bool curShowed = m_pListAccounts->columnWidth( column ) > 0;
+
+ if( showColumn )
+ {
+ //column will be shown
+
+ if( !curShowed )
+ {
+ //the column is currently not be shown
+
+ //get saved width or take default width
+ int savedWidth = config->readNumEntry( ConfigEntrySavedWidth, DefaultWidth );
+
+ //set column width
+ m_pListAccounts->setColumnWidth( column, savedWidth );
+ }
+ //else: the column is currently shown; do nothing
+ }
+ else
+ {
+ //column will not be shown
+
+ if( curShowed )
+ {
+ //the column is currently shown
+
+ //save current width
+ config->writeEntry( ConfigEntrySavedWidth, m_pListAccounts->columnWidth( column ) );
+
+ //hide column
+ m_pListAccounts->hideColumn( column );
+ }
+ //else: the column is already hidden; do nothing
+ }
+
+ } //end column loop
+
+ //set columns of the message list
+ config->setGroup( CONFIG_GROUP_MESSAGE_LIST );
+ for( int column = 0; column <= 8; column++ ) //iterate over all columns
+ {
+ //get config entries and defaults of the proceeded column from the constants header
+ switch( column )
+ {
+ case 0: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_NUMBER;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_NUMBER;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_NUMBER;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_NUMBER;
+ break;
+
+ case 1: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_ACCOUNT;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_ACCOUNT;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_ACCOUNT;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_ACCOUNT;
+ break;
+
+ case 2: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_FROM;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_FROM;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_FROM;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_FROM;
+ break;
+
+ case 3: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_TO;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_TO;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_TO;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_TO;
+ break;
+
+ case 4: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_SUBJECT;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_SUBJECT;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_SUBJECT;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_SUBJECT;
+ break;
+
+ case 5: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_DATE;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_DATE;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_DATE;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_DATE;
+ break;
+
+ case 6: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_SIZE;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_SIZE;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_SIZE;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_SIZE;
+ break;
+
+ case 7: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_CONTENT;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_CONTENT;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_CONTENT;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_CONTENT;
+ break;
+
+ case 8: ConfigEntryDisplay = CONFIG_ENTRY_DISPLAY_MESSAGE_STATE;
+ ConfigEntrySavedWidth = CONFIG_ENTRY_OLD_WIDTH_MESSAGE_STATE;
+ DefaultWidth = DEFAULT_WIDTH_MESSAGE_STATE;
+ DefaultDisplay = DEFAULT_DISPLAY_MESSAGE_STATE;
+ break;
+
+ } //end select
+
+ //get desired column state
+ bool showColumn = config->readBoolEntry( ConfigEntryDisplay, DefaultDisplay );
+
+ //get currently column state
+ bool curShowed = m_pListMessages->columnWidth( column ) > 0;
+
+ if( showColumn )
+ {
+ //column will be shown
+
+ if( !curShowed )
+ {
+ //the column is currently not be shown
+
+ //get saved width or take default width
+ int savedWidth = config->readNumEntry( ConfigEntrySavedWidth, DefaultWidth );
+
+ //set column width
+ m_pListMessages->setColumnWidth( column, savedWidth );
+ }
+ //else: the column is currently shown; do nothing
+ }
+ else
+ {
+ //column will not be shown
+
+ if( curShowed )
+ {
+ //the column is currently shown
+
+ //save current width
+ config->writeEntry( ConfigEntrySavedWidth, m_pListMessages->columnWidth( column ) );
+
+ //hide column
+ m_pListMessages->hideColumn( column );
+ }
+ //else: the column is already hidden; do nothing
+ }
+
+ } //end column loop
+
+ //save current layout
+ m_pListAccounts->saveLayout( config, CONFIG_GROUP_ACCOUNT_LIST );
+ m_pListMessages->saveLayout( config, CONFIG_GROUP_MESSAGE_LIST );
+ config->sync();
+}
diff --git a/kshowmail/kshowmailview.h b/kshowmail/kshowmailview.h
new file mode 100644
index 0000000..e417e2e
--- /dev/null
+++ b/kshowmail/kshowmailview.h
@@ -0,0 +1,157 @@
+/***************************************************************************
+ kshowmailview.h - description
+ -------------------
+ begin : Sat May 6 12:13:57 MEST 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+
+ 26 Sep 2002 - Allow for columns to be hidden. Allistar Melville
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSHOWMAILVIEW_H
+#define KSHOWMAILVIEW_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+//Qt headers
+#include <qwidget.h>
+#include <qsplitter.h>
+#include <qcursor.h>
+#include <qpopupmenu.h>
+
+//KDE headers
+#include <klistview.h>
+#include <kconfig.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include "configlist.h"
+#include "showlistviewitem.h"
+
+
+
+class ConfigList;
+class KshowmailDoc;
+
+/** The KshowmailView class provides the view widget for the KShowMailApp instance.
+ * The View instance inherits QWidget as a base class and represents the view object of a KMainWindow.
+ * As KshowmailView is part of the document-view model, it needs a reference to the document object
+ * connected with it by the KShowMailApp class to manipulate and display
+ * the document structure provided by the KshowmailDoc class.
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ * @version KDevelop version 0.4 code generation
+ */
+class KshowmailView : public QSplitter
+{
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Constructor for the main view
+ */
+ KshowmailView(QWidget *parent = 0, const char *name=0);
+
+
+ /**
+ * Destructor for the main view
+ */
+ ~KshowmailView();
+
+ /**
+ * Saves the options
+ */
+ void saveOptions( KConfig* config );
+
+ /**
+ * Clears the mail list view.
+ */
+ void clearMailListView();
+
+ /**
+ * Creates a mail list view item with the given content and
+ * inserts it into the mail list view.
+ * @param number mail number
+ * @param account account name
+ * @param from sender of the mail
+ * @param to recipient of the mail
+ * @param subject mail subject
+ * @param date date on which the mail was sent, formated to the current locale's conventions.
+ * @param size size of the mail
+ * @param content content type
+ * @param state new or old
+ * @param time send date, formated to the ISO 8601 extended specification (YYYY-MM-DDTHH:MM:SS)
+ * @return pointer to the created list view item
+ */
+ ShowListViewItem* insertMail( QString& number, QString& account, QString& from, QString& to, QString& subject, QString& date, QString& size, QString& content, QString& state, QString& time );
+
+ /**
+ * Refreshes the geometry.
+ * Reads from the config file the properties about show or hide columns.
+ * If a shown column should be hidden, the current width will be saved and the column will be hidden.
+ * If a hidden column should be shown, it will be set to the old saved width.
+ */
+ void refreshSetup();
+
+ KListView* m_pListAccounts;
+ KListView* m_pListMessages;
+
+ private:
+
+ QPixmap* m_pixOk;
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * Reads the some geometry options from the application config file.
+ */
+ void readOptions();
+
+private slots:
+
+ /**
+ * Connected with signal rightButtonClicked of m_pListMessages.
+ * Invoked, when the user has clicked on a list item with the right mouse button.
+ * Selects the clicked item and shows the popup menu mail_context_popup defined in
+ * kshowmailui.rc.
+ */
+ void slotMessageContext( QListViewItem*, const QPoint&, int );
+
+ void slotMessageDoubleClicked (QListViewItem*);
+ void slotMessageClicked (QListViewItem*);
+
+ /**
+ * Connected with signal rightButtonClicked of m_pListAccounts.
+ * Invoked, when the user has clicked on a list item with the right mouse button.
+ * Selects the clicked item and shows the popup menu account_context_popup defined in
+ * kshowmailui.rc.
+ */
+ void slotAccountContext( QListViewItem*, const QPoint &, int );
+
+ /**
+ * Connected with signal clicked of the account list.
+ * Activate or deactivate the account, if the user has clicked in the first column
+ */
+ void slotAccountClicked( QListViewItem*, const QPoint& point, int col );
+
+signals:
+ void signalActiveChanged ();
+};
+
+#endif // KSHOWMAILVIEW_H
diff --git a/kshowmail/kwalletaccess.cpp b/kshowmail/kwalletaccess.cpp
new file mode 100644
index 0000000..20dccc6
--- /dev/null
+++ b/kshowmail/kwalletaccess.cpp
@@ -0,0 +1,137 @@
+//
+// C++ Implementation: kwalletaccess
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "kwalletaccess.h"
+
+
+bool KWalletAccess::savePassword( const QString & account, const QString & password )
+{
+ //check for enabled KWallet
+ if( !KWallet::Wallet::isEnabled() )
+ {
+ KMessageBox::error( NULL, i18n( "KWallet is not available." ) );
+ return false;
+ }
+
+ //get wallet name for network data
+ QString name = KWallet::Wallet::NetworkWallet();
+ if( name == "" || name == QString::null )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get wallet name for network datas from KWallet." ) );
+ return false;
+ }
+
+ //open wallet
+ //we want to create a connection object just at first call of this function
+ static KWallet::Wallet* wallet;
+
+ if( wallet == NULL )
+ {
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+ else if( !wallet->isOpen() )
+ {
+ delete wallet;
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+
+ if( wallet == NULL )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open KWallet." ) );
+ return false;
+ }
+
+ //create kshowmail folder if it does not exist
+ if( !wallet->hasFolder( "KShowmail" ) )
+ {
+ bool createFolderSuccess = wallet->createFolder( "KShowmail" );
+
+ if( !createFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not create folder for KShowmail in KWallet." ) );
+ return false;
+ }
+ }
+
+ //set folder
+ bool setFolderSuccess = wallet->setFolder( "KShowmail" );
+ if( !setFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open folder for KShowmail in KWallet." ) );
+ return false;
+ }
+
+ //write password
+ int writePasswordSuccess = wallet->writePassword( account, password );
+ if( writePasswordSuccess != 0 )
+ {
+ KMessageBox::error( NULL, i18n( "Could not save password in KWallet." ) );
+ return false;
+ }
+
+
+ return true;
+}
+
+QString KWalletAccess::getPassword( const QString & account )
+{
+ //check for enabled KWallet
+ if( !KWallet::Wallet::isEnabled() )
+ {
+ KMessageBox::error( NULL, i18n( "KWallet is not available." ) );
+ return QString::null;
+ }
+
+ //get wallet name for network data
+ QString name = KWallet::Wallet::NetworkWallet();
+ if( name == "" || name == QString::null )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get wallet name for network datas from KWallet." ) );
+ return QString::null;
+ }
+
+ //open wallet
+ //we want to create a connection object just at first call of this function
+ static KWallet::Wallet* wallet;
+
+ if( wallet == NULL )
+ {
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+ else if( !wallet->isOpen() )
+ {
+ delete wallet;
+ wallet = KWallet::Wallet::openWallet( name );
+ }
+
+ if( wallet == NULL )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open KWallet." ) );
+ return QString::null;
+ }
+
+ //set folder
+ bool setFolderSuccess = wallet->setFolder( "KShowmail" );
+ if( !setFolderSuccess )
+ {
+ KMessageBox::error( NULL, i18n( "Could not open folder for KShowmail in KWallet." ) );
+ return QString::null;
+ }
+
+ //read password
+ QString password;
+
+ int readPasswordSuccess = wallet->readPassword( account, password );
+ if( readPasswordSuccess != 0 )
+ {
+ KMessageBox::error( NULL, i18n( "Could not get password of account %1 from KWallet." ).arg( account) );
+ return QString::null;
+ }
+
+ return password;
+}
diff --git a/kshowmail/kwalletaccess.h b/kshowmail/kwalletaccess.h
new file mode 100644
index 0000000..8e9c537
--- /dev/null
+++ b/kshowmail/kwalletaccess.h
@@ -0,0 +1,45 @@
+//
+// C++ Interface: kwalletaccess
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KWALLETACCESS_H
+#define KWALLETACCESS_H
+
+//Qt headers
+#include <qstring.h>
+
+//KDE headers
+#include <kwallet.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+/**
+ * @brief Provides routines to save and read passwords using KWallet.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+namespace KWalletAccess
+{
+
+ /**
+ * Saves the given password into KWallet.
+ * @param account account name
+ * @param password the password
+ * @return TRUE - password successfully saved
+ * @return FALSE - password could not be saved
+ */
+ bool savePassword( const QString& account, const QString& password );
+
+ /**
+ * Returns the password of the given account.
+ * @param account account name
+ * @return the password or QString::null, if the sought password is not stored in KWallet.
+ */
+ QString getPassword( const QString& account );
+}
+
+#endif
diff --git a/kshowmail/main.cpp b/kshowmail/main.cpp
new file mode 100644
index 0000000..a28067a
--- /dev/null
+++ b/kshowmail/main.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Fre Sep 28 23:29:54 CEST 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+//KDE-Header
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <kuniqueapplication.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+//KShowmail-Header
+#include "uniqueapp.h"
+#include "kshowmail.h"
+#include "constants.h"
+
+using namespace Constants;
+
+//description of the application
+static const char *description = I18N_NOOP("A powerful pop3 mail checker");
+
+//the command line options
+//see constants.h
+static KCmdLineOptions kshowmailOptions[] =
+ {
+ { CMDLINE_REFRESH_SHORT, 0, 0},
+ { CMDLINE_REFRESH, I18N_NOOP("Refresh messages now"), 0 },
+ { CMDLINE_CONFIG_SHORT, 0, 0},
+ { CMDLINE_CONFIG, I18N_NOOP("Launch configure dialog"), 0 },
+ KCmdLineLastOption
+ };
+
+int main(int argc, char *argv[])
+{
+ //create datas for the about box
+ KShowMailApp::m_pAbout = new KAboutData (
+ /*appName */ "kshowmail",
+ /*programName*/ "KShowmail",
+ /*version */ VERSION,
+ /*description*/ description,
+ /*license */ KAboutData::License_GPL_V2,
+ /*copyright */ "(C) 2000-2005, Eggert Ehmke",
+ /*text */ 0,
+ /*homepage */ "http://sourceforge.net/projects/kshowmail",
+ /*bug email */ "eggert.ehmke@berlin.de");
+
+ //add authors
+ KShowMailApp::m_pAbout->addAuthor ("Eggert Ehmke", 0, "eggert.ehmke@berlin.de", "http://kshowmail.sourceforge.net");
+ KShowMailApp::m_pAbout->addAuthor ("Allistar Melville", 0, "allistar@silvermoon.co.nz", 0);
+ KShowMailApp::m_pAbout->addAuthor ("Oleg Ivanov", 0, "saruman@unigsm.com", 0);
+ KShowMailApp::m_pAbout->addAuthor( "Ulrich Weigelt", 0, "ulrich.weigelt@gmx.de", 0 );
+ KShowMailApp::m_pAbout->setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names") ,I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
+
+ //Initialize command line arguments
+ KCmdLineArgs::init(argc, argv, KShowMailApp::m_pAbout);
+ //add the special command line options of kshowmail which was specified above
+ KCmdLineArgs::addCmdLineOptions(kshowmailOptions);
+
+ // when released, this must be 0!
+#if 0
+
+ kdDebug () << "KShowmail running in debug mode" << endl;
+ KApplication::addCmdLineOptions();
+
+ KApplication app;
+ KShowMailApp* kshow = new KShowMailApp ();
+ kshow->show();
+ app.exec();
+
+#else
+
+ //print debug message about run mode
+ kdDebug () << "KShowmail running in normal mode" << endl;
+
+ //add special command line options for unique KDE applications
+ KUniqueApplication::addCmdLineOptions();
+
+ //test whether the new application to start is unique
+ if (KUniqueApplication::start())
+ {
+ //yes, wa can start a unique kshowmail instance
+
+ //create a new unique appliction
+ //UniqueApp is a inherited class of KUniqueApplication
+ //see uniqueapp.h
+ UniqueApp* app = new UniqueApp ();
+
+ //start the application
+ app->exec ();
+ }
+ else
+ {
+ //kshowmail is already running
+ kdWarning() << I18N_NOOP ("Kshowmail is already running!") << endl;
+ }
+
+#endif
+
+ return 0;
+}
+
diff --git a/kshowmail/senderlistfilter.cpp b/kshowmail/senderlistfilter.cpp
new file mode 100644
index 0000000..fcb4e6d
--- /dev/null
+++ b/kshowmail/senderlistfilter.cpp
@@ -0,0 +1,102 @@
+//
+// C++ Implementation: senderlistfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "senderlistfilter.h"
+
+SenderListFilter::SenderListFilter()
+{
+
+ //get the application config object
+ config = KApplication::kApplication()->config();
+
+ //load the setup
+ load();
+
+}
+
+
+SenderListFilter::~SenderListFilter()
+{
+}
+
+FilterAction_Type SenderListFilter::check( QString sender ) const
+{
+ //return with none action if the given string is empty
+ if( sender.isEmpty() ) return FActNone;
+
+ //check the whitelist first
+ if( search( whitelist, sender ) ) return FActPass;
+
+ //check blacklist
+ if( search( blacklist, sender ) ) return blacklistAction;
+
+ //this is the default
+ return FActNone;
+}
+
+void SenderListFilter::load( )
+{
+ //set group
+ config->setGroup( CONFIG_GROUP_FILTER );
+
+ //get lists
+ blacklist = config->readListEntry( CONFIG_ENTRY_FILTER_BLACKLIST );
+ whitelist = config->readListEntry( CONFIG_ENTRY_FILTER_WHITELIST );
+
+ //get blacklist action
+ switch( config->readNumEntry( CONFIG_ENTRY_FILTER_BLACKLIST_ACTION, DEFAULT_FILTER_BLACKLIST_ACTION ) )
+ {
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE : blacklistAction = FActDelete; break;
+ case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK : blacklistAction = FActMark; break;
+ default : blacklistAction = FActMark; break;
+ }
+}
+
+bool SenderListFilter::search( QStringList list, QString sender ) const
+{
+ //return with FALSE if the list or the search string are empty
+ if( list.isEmpty() || sender.isEmpty() ) return false;
+
+ //iterate over the list to search for the sender
+ bool found = false;
+ for( QStringList::Iterator it = list.begin(); it != list.end() && found == false; ++it )
+ {
+ if( sender.contains( *it, false ) || (*it).contains( sender, false ) )
+ found = true;
+ }
+
+ return found;
+}
+
+void SenderListFilter::print( )
+{
+ kdDebug() << "Blacklist:" << endl;
+ for( QStringList::Iterator it = blacklist.begin(); it != blacklist.end(); ++it )
+ {
+ kdDebug() << *it << endl;
+ }
+
+ switch( blacklistAction )
+ {
+ case FActDelete : kdDebug() << "Blacklist Action: DELETE" << endl; break;
+ case FActMark : kdDebug() << "Blacklist Action: MARK " << endl; break;
+ default : kdDebug() << "Blacklist Action: Unknown" << endl; break;
+ }
+
+ kdDebug() << endl;
+
+ kdDebug() << "Whitelist:" << endl;
+ for( QStringList::Iterator it = whitelist.begin(); it != whitelist.end(); ++it )
+ {
+ kdDebug() << *it << endl;
+ }
+
+}
diff --git a/kshowmail/senderlistfilter.h b/kshowmail/senderlistfilter.h
new file mode 100644
index 0000000..d54237f
--- /dev/null
+++ b/kshowmail/senderlistfilter.h
@@ -0,0 +1,113 @@
+//
+// C++ Interface: senderlistfilter
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef SENDERLISTFILTER_H
+#define SENDERLISTFILTER_H
+
+//Qt headers
+#include <qstring.h>
+#include <qstringlist.h>
+
+//KDE headers
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+//Kshowmail headers
+#include "types.h"
+#include "constants.h"
+
+using namespace Types;
+
+/**
+ * @brief This class represents both the blacklist and the whitelist.
+ * For using create an object of it and call check() to test a sender address.
+ * You have to call load() after the settings in the config file was changed.
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+
+class SenderListFilter{
+
+ public:
+
+ /**
+ * Constructor
+ */
+ SenderListFilter();
+
+ /**
+ * Destructor
+ */
+ ~SenderListFilter();
+
+ /**
+ * Checks the given sender whether it is listed in the blacklist or whitelist.
+ * @param sender sender which shall be checked
+ * @return appointed action (FActPass, FActDelete, FActMark, FActNone)
+ */
+ FilterAction_Type check( QString sender ) const;
+
+ /**
+ * Loads the setup from the application config file.
+ */
+ void load();
+
+ /**
+ * Prints the settings.
+ */
+ void print();
+
+ private:
+
+ /**
+ * Connector to the configuration file
+ */
+ KConfig* config;
+
+ /**
+ * blacklisted addresses
+ */
+ QStringList blacklist;
+
+ /**
+ * whitelisted addresses
+ */
+ QStringList whitelist;
+
+ /**
+ * appointed action of the blacklist.
+ */
+ FilterAction_Type blacklistAction;
+
+ protected:
+
+ /**
+ * Returns TRUE if the given list contains the sender or a part of it.
+ * e.g.: The list contains:
+ * Ulrich Weigelt
+ * spam@spamhouse.com
+ * "Lara Croft" <lara.croft@tombraider.com>
+ *
+ * This sender strings will cause a return value of TRUE:
+ * "Ulrich Weigelt" <ulrich.weigelt@gmx.de>
+ * "Spam King" <spam@spamhouse.com>
+ * spam@spamhouse.com
+ * lara.croft@tombraider.com
+ * "Lara Croft" <lara.croft@tombraider.com>
+ *
+ * @param list blacklist or whitelist
+ * @param sender searched sender name
+ * @return TRUE - the given sender name is listed. FALSE - is not listed
+ */
+ bool search( QStringList list, QString sender ) const;
+};
+
+#endif
diff --git a/kshowmail/serverdialog.cpp b/kshowmail/serverdialog.cpp
new file mode 100644
index 0000000..b61aa25
--- /dev/null
+++ b/kshowmail/serverdialog.cpp
@@ -0,0 +1,336 @@
+/***************************************************************************
+ serverdialog.cpp - description
+ -------------------
+ begin : Sun Oct 28 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "serverdialog.h"
+
+ServerDialog::ServerDialog( QWidget* parent, ConfigElem* item )
+ : KDialogBase( parent, "ServerDialog", true, QString::null, Ok|Cancel, Ok, true )
+{
+ //save pointer to account and view
+ account = item;
+
+ //tab widget
+ KTabWidget* tabs = new KTabWidget( this, "tabs" );
+ tabs->setMargin( 10 );
+
+ //pages
+ QWidget* pgGeneral = new QWidget( this );
+ QWidget* pgSecurity = new QWidget( this );
+ setMainWidget( tabs );
+
+ //layouts of general page
+ QVBoxLayout* layGeneral = new QVBoxLayout( pgGeneral, 0, spacingHint() );
+ QGridLayout* layTop = new QGridLayout( layGeneral, 5, 2 );
+
+ //layouts of security page
+ QVBoxLayout* laySecurity = new QVBoxLayout( pgSecurity, 0, spacingHint() );
+ laySecurity->setAlignment( Qt::AlignTop );
+
+ //upper items
+ QLabel* lblAccount = new QLabel( i18n( "Account:" ), pgGeneral, "lblAccount" );
+ txtAccount = new KLineEdit( pgGeneral, "txtAccount" );
+ txtAccount->setEnabled( false );
+ QToolTip::add( lblAccount, i18n( "Unique Account Name" ) );
+ QToolTip::add( txtAccount, i18n( "Unique Account Name" ) );
+ layTop->addWidget( lblAccount, 0, 0 );
+ layTop->addWidget( txtAccount, 0, 1 );
+
+ QLabel* lblServer = new QLabel( i18n( "Server:" ), pgGeneral, "lblServer" );
+ txtServer = new KLineEdit( pgGeneral, "txtServer" );
+ txtServer->setFocus();
+ QToolTip::add( lblServer, i18n( "Server Name" ) );
+ QToolTip::add( txtAccount, i18n( "Server Name" ) );
+ layTop->addWidget( lblServer, 1, 0 );
+ layTop->addWidget( txtServer, 1, 1 );
+
+ QLabel* lblProtocol = new QLabel( i18n( "Protocol:" ), pgGeneral, "lblProtocol" );
+ cboProtocol = new KComboBox( pgGeneral, "cboProtocol" );
+ cboProtocol->insertItem( "POP3" ); //currently KShowmail just supports POP3
+ QToolTip::add( lblProtocol, i18n( "Protocol, which shall be used to get the mails from the server. Currently KShowmail just supports POP3.") );
+ QToolTip::add( cboProtocol, i18n( "Protocol, which shall be used to get the mails from the server. Currently KShowmail just supports POP3.") );
+ layTop->addWidget( lblProtocol, 2, 0 );
+ layTop->addWidget( cboProtocol, 2, 1 );
+
+ QLabel* lblPort = new QLabel( i18n( "Port:" ), pgGeneral, "lblPort" );
+ spbPort = new QSpinBox( 0, 65535, 1, pgGeneral, "spbPort" );
+ spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 );
+ QToolTip::add( lblPort, i18n( "Port Number. Normally POP3 uses port 110." ) );
+ QToolTip::add( spbPort, i18n( "Port Number. Normally POP3 uses port 110." ) );
+ layTop->addWidget( lblPort, 3, 0 );
+ layTop->addWidget( spbPort, 3, 1 );
+
+ QLabel* lblUser = new QLabel( i18n( "User:" ), pgGeneral, "lblUser" );
+ txtUser = new KLineEdit( pgGeneral, "txtUser" );
+ QToolTip::add( lblUser, i18n( "To authenticate to the mail server you need an user name." ) );
+ QToolTip::add( txtUser, i18n( "To authenticate to the mail server you need an user name." ) );
+ layTop->addWidget( lblUser, 4, 0 );
+ layTop->addWidget( txtUser, 4, 1 );
+
+ //password groupbox and layouts
+ QGroupBox* gboxPassword = new QGroupBox( 0, Qt::Horizontal, i18n( "Password" ), pgGeneral, "gboxPassword" );
+ layGeneral->addWidget( gboxPassword );
+
+ QVBoxLayout* layPassword = new QVBoxLayout( gboxPassword->layout(), spacingHint() );
+ QGridLayout* layPasswordStorage = new QGridLayout( layPassword, 2, 2, spacingHint() );
+
+
+ //radio buttons to set storage of the password
+ grpPasswordStorage = new QButtonGroup( NULL, "grpPasswordStorage" );
+ connect( grpPasswordStorage, SIGNAL( clicked( int ) ), this, SLOT( slotPasswordStorageChanged( int ) ) );
+
+ QRadioButton* btnPasswordDontSave = new QRadioButton( i18n( "Don't save" ), gboxPassword, "btnPasswordDontSave" );
+ QRadioButton* btnPasswordSaveFile = new QRadioButton( i18n( "Save password"), gboxPassword, "btnPasswordSaveFile" );
+ QRadioButton* btnPasswordSaveKWallet = new QRadioButton( i18n( "Use KWallet" ), gboxPassword, "btnPasswordSaveKWallet" );
+ grpPasswordStorage->insert( btnPasswordDontSave, ID_BUTTON_PASSWORD_DONT_SAVE );
+ grpPasswordStorage->insert( btnPasswordSaveFile, ID_BUTTON_PASSWORD_SAVE_FILE );
+ grpPasswordStorage->insert( btnPasswordSaveKWallet, ID_BUTTON_PASSWORD_SAVE_KWALLET );
+ QToolTip::add( btnPasswordDontSave, i18n( "Don't save password. KShowmail will ask you for it at first server connect." ) );
+ QToolTip::add( btnPasswordSaveFile, i18n( "Save password in the configuration file. Not recommended, because the password is just lightly encrypted" ) );
+ QToolTip::add( btnPasswordSaveKWallet, i18n( "Use KWallet to save the password. Maybe you have to type in the KWallet master password at first server connect." ) );
+ layPasswordStorage->addWidget( btnPasswordDontSave, 0, 0 );
+ layPasswordStorage->addWidget( btnPasswordSaveFile, 0, 1 );
+ layPasswordStorage->addWidget( btnPasswordSaveKWallet, 1, 0 );
+
+ //password edit line
+ txtPassword = new KPasswordEdit( gboxPassword, "txtUser" );
+ layPassword->addWidget( txtPassword );
+
+ //set password defaults
+ grpPasswordStorage->setButton( DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+ slotPasswordStorageChanged( DEFAULT_ACCOUNT_PASSWORD_STORAGE );
+
+ //active check box
+ QGridLayout* layActive = new QGridLayout( layGeneral, 1, 1 );
+ layActive->setAlignment( Qt::AlignCenter );
+ chkActive = new QCheckBox( i18n( "Active"), pgGeneral, "chkActive" );
+ QToolTip::add( chkActive, i18n( "Select it to activate this account." ) );
+ layActive->addWidget( chkActive, 0, 0 );
+ chkActive->setChecked( DEFAULT_ACCOUNT_ACTIVE );
+
+ //secure transfer groupbox and layouts
+ QGroupBox* gboxSecureTransfer = new QGroupBox( 0, Qt::Horizontal, i18n( "Encryption" ), pgSecurity, "gboxSecureTransfer" );
+ gboxSecureTransfer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ) );
+ laySecurity->addWidget( gboxSecureTransfer );
+
+ QHBoxLayout* laySecureTransfer = new QHBoxLayout( gboxSecureTransfer->layout(), spacingHint() );
+
+ //radio buttons to set secure transfer
+ grpSecureTransfer = new QButtonGroup( NULL, "grpSecureTransfer" );
+ connect( grpSecureTransfer, SIGNAL( clicked( int ) ), this, SLOT( slotSecureTransferChanged ( int ) ) );
+
+ QRadioButton* btnSecureTransferNone = new QRadioButton( i18n( "None" ), gboxSecureTransfer, "btnSecureTransferNone" );
+ QRadioButton* btnSecureTransferSSL = new QRadioButton( i18n( "SSL"), gboxSecureTransfer, "btnSecureTransferSSL" );
+ QRadioButton* btnSecureTransferTLS = new QRadioButton( i18n( "TLS" ), gboxSecureTransfer, "btnSecureTransferTLS" );
+ grpSecureTransfer->insert( btnSecureTransferNone, ID_BUTTON_SECTRANSFER_NONE );
+ grpSecureTransfer->insert( btnSecureTransferSSL, ID_BUTTON_SECTRANSFER_SSL );
+ grpSecureTransfer->insert( btnSecureTransferTLS, ID_BUTTON_SECTRANSFER_TLS );
+ QToolTip::add( btnSecureTransferNone, i18n( "The download of the mail header and body will not be encrypted. Use this, if your provider doesn't make a secure transfer available." ) );
+ QToolTip::add( btnSecureTransferSSL, i18n( "Secure Sockets Layer (SSL), is a cryptographic protocol that provides secure communications on the Internet." ) );
+ QToolTip::add( btnSecureTransferTLS, i18n( "Transport Layer Security (TLS) is a cryptographic protocol that provides secure communications on the Internet. It is the successor of SSL." ) );
+ laySecureTransfer->addWidget( btnSecureTransferNone );
+ laySecureTransfer->addWidget( btnSecureTransferSSL );
+ laySecureTransfer->addWidget( btnSecureTransferTLS );
+
+ grpSecureTransfer->setButton( DEFAULT_ACCOUNT_SECTRANSFER );
+
+
+ //set pages to tab widget
+ tabs->addTab( pgGeneral, i18n( "General" ) );
+ tabs->addTab( pgSecurity, i18n( "Security" ) );
+
+ //set caption
+ if( item == NULL )
+ setCaption( i18n( "New account" ) );
+ else
+ setCaption( i18n( "Edit account" ) );
+
+ //write values of the given account into the dialog items
+ if( account != NULL )
+ fillDialog();
+
+
+}
+
+
+ServerDialog::~ServerDialog()
+{
+}
+
+void ServerDialog::slotPasswordStorageChanged( int id )
+{
+ if( id == ID_BUTTON_PASSWORD_DONT_SAVE )
+ {
+ txtPassword->setEnabled( false );
+ txtPassword->clear();
+ }
+ else
+ txtPassword->setEnabled( true );
+}
+
+void ServerDialog::slotOk( )
+{
+ //check for necessary values
+ if( account == NULL )
+ {
+ kdError() << "ServerDialog::slotOk: Given account pointer is Null." << endl;
+ return;
+ }
+ if( txtServer->text() == "" )
+ {
+ KMessageBox::error( this, i18n( "Please enter an server." ) );
+ return;
+ }
+
+ if( txtUser->text() == "" )
+ {
+ KMessageBox::error( this, i18n( "Please enter an user name." ) );
+ return;
+ }
+
+ //get application config object (kshowmailrc)
+ KConfig* config = KApplication::kApplication()->config();
+
+ config->setGroup( txtAccount->text() );
+
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_SERVER, txtServer->text() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PROTOCOL, cboProtocol->currentText().upper() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PORT, spbPort->value() );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_USER, txtUser->text() );
+
+ //get the password
+ //the class KPasswordEdit doesn't have a method to set the password
+ //therefore we use setText(). But if we use this method, KPasswordEdit::password()
+ //will return an empty string. If the user has typed in a new password, KPasswordEdit::password()
+ //will return the correct password
+ QString pass;
+ if( txtPassword->password() == "" || txtPassword->password() == QString::null )
+ pass = txtPassword->text();
+ else
+ pass = txtPassword->password();
+
+ //used to encrypt password
+ KURL url;
+ url.setUser( txtUser->text() );
+ url.setHost( txtServer->text() );
+ url.setPass( pass );
+
+ //save password (or not)
+ switch( grpPasswordStorage->selectedId() )
+ {
+ case ID_BUTTON_PASSWORD_DONT_SAVE : config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, QString::null );
+ break;
+ case ID_BUTTON_PASSWORD_SAVE_FILE : config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, crypt( url ) );
+ break;
+ case ID_BUTTON_PASSWORD_SAVE_KWALLET : config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, QString::null );
+ KWalletAccess::savePassword( txtAccount->text(), pass );
+ break;
+ default : config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD_STORAGE, CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE );
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_PASSWORD, QString::null );
+ }
+
+ config->writeEntry( CONFIG_ENTRY_ACCOUNT_ACTIVE, chkActive->isChecked() );
+
+ switch( grpSecureTransfer->selectedId() )
+ {
+ case ID_BUTTON_SECTRANSFER_NONE : config->writeEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, CONFIG_VALUE_ACCOUNT_SECTRANSFER_NONE ); break;
+ case ID_BUTTON_SECTRANSFER_SSL : config->writeEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, CONFIG_VALUE_ACCOUNT_SECTRANSFER_SSL ); break;
+ case ID_BUTTON_SECTRANSFER_TLS : config->writeEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, CONFIG_VALUE_ACCOUNT_SECTRANSFER_TLS ); break;
+ default : config->writeEntry( CONFIG_ENTRY_ACCOUNT_SECTRANSFER, DEFAULT_ACCOUNT_SECTRANSFER ); break;
+ }
+
+ //save config to file
+ config->sync();
+
+ //call slot of super class to close the dialog
+ KDialogBase::slotOk();
+}
+
+void ServerDialog::fillDialog( )
+{
+ //check for valid account pointer
+ if( account == NULL )
+ {
+ kdError() << "ServerDialog::fillDialog: invalid pointer to account item." << endl;
+ return;
+ }
+
+ txtAccount->setText( account->getAccountName() );
+ txtServer->setText( account->getHost() );
+
+ QString proto = account->getProtocol( true );
+ bool tls = account->getTLS();
+
+ if( proto == "POP3S" )
+ {
+ cboProtocol->setCurrentText( "POP3" );
+ grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_SSL );
+ }
+ else if( tls )
+ {
+ cboProtocol->setCurrentText( proto );
+ grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_TLS );
+ }
+ else
+ {
+ cboProtocol->setCurrentText( proto );
+ grpSecureTransfer->setButton( ID_BUTTON_SECTRANSFER_NONE );
+ }
+
+ spbPort->setValue( account->getPort() );
+ txtUser->setText( account->getUser() );
+
+ int type = account->getPasswordStorage();
+ if( type != CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE && type != CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE && type != CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET )
+ type = DEFAULT_ACCOUNT_PASSWORD_STORAGE;
+
+ switch( type )
+ {
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_DONT_SAVE : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_DONT_SAVE );
+ txtPassword->setEnabled( false );
+ txtPassword->clear();
+ break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_FILE : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_SAVE_FILE );
+ txtPassword->setEnabled( true );
+ txtPassword->setText( account->getPassword() );
+ break;
+ case CONFIG_VALUE_ACCOUNT_PASSWORD_SAVE_KWALLET : grpPasswordStorage->setButton( ID_BUTTON_PASSWORD_SAVE_KWALLET );
+ txtPassword->setEnabled( true );
+ txtPassword->setText( account->getPassword() );
+ break;
+ default : grpPasswordStorage->setButton( 1 );
+ txtPassword->clear();
+ }
+
+ chkActive->setChecked( account->isActive() );
+
+
+}
+
+void ServerDialog::slotSecureTransferChanged( int id )
+{
+ switch( id )
+ {
+ case ID_BUTTON_SECTRANSFER_NONE : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 ); break;
+ case ID_BUTTON_SECTRANSFER_SSL : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3SSL ); break;
+ case ID_BUTTON_SECTRANSFER_TLS : spbPort->setValue( DEFAULT_ACCOUNT_PORT_POP3 ); break;
+ }
+}
+
+#include "serverdialog.moc"
diff --git a/kshowmail/serverdialog.h b/kshowmail/serverdialog.h
new file mode 100644
index 0000000..2168003
--- /dev/null
+++ b/kshowmail/serverdialog.h
@@ -0,0 +1,168 @@
+/***************************************************************************
+ serverdialog.h - description
+ -------------------
+ begin : Sun Oct 28 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef SERVERDIALOG_H
+#define SERVERDIALOG_H
+
+//Qt headers
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qspinbox.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kpassdlg.h>
+
+//KShowmail headers
+#include "configelem.h"
+#include "constants.h"
+#include "encryption.h"
+#include "kwalletaccess.h"
+#include <ktabwidget.h>
+
+//radio button IDs
+#define ID_BUTTON_PASSWORD_DONT_SAVE 1
+#define ID_BUTTON_PASSWORD_SAVE_FILE 2
+#define ID_BUTTON_PASSWORD_SAVE_KWALLET 3
+#define ID_BUTTON_SECLOGIN_NONE 1
+#define ID_BUTTON_SECLOGIN_APOP 2
+#define ID_BUTTON_SECLOGIN_SASL 3
+#define ID_BUTTON_SECTRANSFER_NONE 1
+#define ID_BUTTON_SECTRANSFER_SSL 2
+#define ID_BUTTON_SECTRANSFER_TLS 3
+
+/**
+ * @brief Dialog to edit account options. You can not create a new account or edit the account name.
+ * @author Eggert Ehmke
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+
+class ServerDialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+
+ public:
+
+ /**
+ * General constructor
+ * @param parent parent of the dialog
+ * @param item account to setup
+ */
+ ServerDialog( QWidget* parent, ConfigElem* item = NULL );
+
+ /**
+ * Destructor
+ */
+ ~ServerDialog();
+
+ private:
+
+ /**
+ * account to setup
+ */
+ ConfigElem* account;
+
+ /**
+ * Edit line which contains the unique account name.
+ */
+ KLineEdit* txtAccount;
+
+ /**
+ * Edit line which contains the server name.
+ */
+ KLineEdit* txtServer;
+
+ /**
+ * Combo box to choose the protocol.
+ */
+ KComboBox* cboProtocol;
+
+ /**
+ * Spinbox to choose the tcp port.
+ */
+ QSpinBox* spbPort;
+
+ /**
+ * Edit line which contains the user name.
+ */
+ KLineEdit* txtUser;
+
+ /**
+ * Edit line which contains the password.
+ */
+ KPasswordEdit* txtPassword;
+
+ /**
+ * Check box to select whether the account is active or not.
+ */
+ QCheckBox* chkActive;
+
+ /**
+ * Combines the radio buttons of password storage.
+ */
+ QButtonGroup* grpPasswordStorage;
+
+ /**
+ * Combines the radio buttons of secure transfer.
+ */
+ QButtonGroup* grpSecureTransfer;
+
+ protected slots:
+
+ /**
+ * Connected with the password button group.
+ * Enabled or disabled the password edit line.
+ * @param id button identifier
+ */
+ void slotPasswordStorageChanged( int id );
+
+ /**
+ * Connected with the secure transfer button group.
+ * Changes the port number.
+ * @param id button identifier
+ */
+ void slotSecureTransferChanged( int id );
+
+ /**
+ * Overwritten methode of KDialogBase.
+ * Called if OK was clicked.
+ * Stores the entered values into the given account item.
+ * If no item was given, it creates a new one.
+ * After then it invokes slotOk() of KDialogBase.
+ */
+ void slotOk();
+
+ protected:
+
+ /**
+ * Writes the values of the account into the dialog items.
+ */
+ void fillDialog();
+};
+
+#endif
diff --git a/kshowmail/showheaderdialog.cpp b/kshowmail/showheaderdialog.cpp
new file mode 100644
index 0000000..829fa98
--- /dev/null
+++ b/kshowmail/showheaderdialog.cpp
@@ -0,0 +1,52 @@
+//
+// C++ Implementation: showheaderdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "showheaderdialog.h"
+
+ShowHeaderDialog::ShowHeaderDialog( QWidget * parent, QString & caption, QString & subject, QString header ) :
+ KDialogBase( parent, "showheaderdialog", true, caption, KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true )
+{
+ //create main widget
+ QWidget* mainWidget = new QWidget( this );
+ setMainWidget( mainWidget );
+
+ //this layout seperates meta data area (subject) from the mail header area
+ QVBoxLayout* layMain = new QVBoxLayout( mainWidget, 0, spacingHint() );
+
+ //this layout arranges the labels and lines for the meta datas
+ QHBoxLayout* layMetaDatas = new QHBoxLayout( layMain, spacingHint() );
+
+ //create label for subject
+ QLabel* lblSubject = new QLabel( i18n( "Subject:" ), mainWidget, "lblSubject" );
+ layMetaDatas->addWidget( lblSubject );
+
+ //create line edit for subject
+ KLineEdit* liSubject = new KLineEdit( subject, mainWidget, "liSubject" );
+ liSubject->setReadOnly( true );
+ layMetaDatas->addWidget( liSubject );
+
+ //create text edit for the header
+ KTextEdit* txtHeader = new KTextEdit( mainWidget );
+
+ txtHeader->setText( header );
+ txtHeader->setMinimumSize( WIDTH_VIEW_MAILHEADER, HEIGHT_VIEW_MAILHEADER );
+
+ layMain->addWidget( txtHeader );
+}
+
+
+
+ShowHeaderDialog::~ShowHeaderDialog()
+{
+}
+
+
+#include "showheaderdialog.moc"
diff --git a/kshowmail/showheaderdialog.h b/kshowmail/showheaderdialog.h
new file mode 100644
index 0000000..c337c8b
--- /dev/null
+++ b/kshowmail/showheaderdialog.h
@@ -0,0 +1,53 @@
+//
+// C++ Interface: showheaderdialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef SHOWHEADERDIALOG_H
+#define SHOWHEADERDIALOG_H
+
+//QT headers
+#include <qlayout.h>
+#include <qlabel.h>
+
+//KDE headers
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <ktextedit.h>
+
+//KShowmail headers
+#include "constants.h"
+
+/**
+ * Used in ShowRecordElem to show the mail header.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+ */
+class ShowHeaderDialog : public KDialogBase
+{
+Q_OBJECT
+
+ public:
+ /**
+ * Generic constructor.
+ * @param parent parent of the dialog
+ * @param caption the dialog caption
+ * @param subject mail subject
+ * @param header mail header
+ */
+ ShowHeaderDialog( QWidget* parent, QString& caption, QString& subject, QString header );
+
+ /**
+ * Destructor
+ */
+ ~ShowHeaderDialog();
+};
+
+#endif
diff --git a/kshowmail/showlistviewitem.cpp b/kshowmail/showlistviewitem.cpp
new file mode 100644
index 0000000..e95ce94
--- /dev/null
+++ b/kshowmail/showlistviewitem.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ showlistviewitem.cpp - description
+ -------------------
+ begin : Son Apr 21 2002
+ copyright : (C) 2002 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "showlistviewitem.h"
+
+ShowListViewItem::ShowListViewItem (QListView * parent,
+ ShowListViewItem* after):
+QListViewItem (parent, after)
+{}
+
+ShowListViewItem::ShowListViewItem( QListView * parent ) :
+ QListViewItem( parent )
+{
+}
+
+ShowListViewItem::~ShowListViewItem()
+{}
+
+QString ShowListViewItem::key (int column, bool /*ascending*/) const
+{
+ switch (column)
+ {
+ case _colNumber:
+ return text (_colAccount) + text (_colNumber);
+ case _colDate:
+ return m_time;
+ default:
+ return text (column);
+ }
+}
+
+/**
+ * reimplement compare to solve bug #856005
+ * standard compare is locale dependant
+ */
+int ShowListViewItem::compare( QListViewItem *i, int col,
+ bool ascending ) const
+{
+ if( col == _colNumber )
+ {
+ return text( _colNumber ).toInt() - i->text( _colNumber ).toInt();
+ }
+ else if( col == _colSize )
+ {
+ return text( _colSize ).toInt() - i->text( _colSize ).toInt();
+ }
+ else
+ return key( col, ascending ).compare( i->key( col, ascending) );
+}
+
+void ShowListViewItem::setNumber (const QString& number)
+{
+ setText (_colNumber, number);
+}
+
+void ShowListViewItem::setAccount(const QString& account)
+{
+ setText (_colAccount, account);
+}
+
+void ShowListViewItem::setFrom(const QString& from)
+{
+ setText (_colFrom, from);
+}
+
+void ShowListViewItem::setTo(const QString& to)
+{
+ setText (_colTo, to);
+}
+
+void ShowListViewItem::setSubject(const QString& subject)
+{
+ setText (_colSubject, subject);
+}
+
+void ShowListViewItem::setDate(const QString& date)
+{
+ setText (_colDate, date);
+}
+
+void ShowListViewItem::setSize(const QString& size)
+{
+ setText (_colSize, size);
+}
+
+void ShowListViewItem::setContent(const QString& content)
+{
+ setText (_colContent, content);
+}
+
+void ShowListViewItem::setState(const QString& state)
+{
+ setText (_colState, state);
+}
+
+void ShowListViewItem::setTime (const QString& time)
+{
+ m_time = time;
+}
+
diff --git a/kshowmail/showlistviewitem.h b/kshowmail/showlistviewitem.h
new file mode 100644
index 0000000..0f56f1b
--- /dev/null
+++ b/kshowmail/showlistviewitem.h
@@ -0,0 +1,69 @@
+/***************************************************************************
+ showlistviewitem.h - description
+ -------------------
+ begin : Son Apr 21 2002
+ copyright : (C) 2002 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef SHOWLISTVIEWITEM_H
+#define SHOWLISTVIEWITEM_H
+
+#include <qlistview.h>
+
+/**
+ *@author Eggert Ehmke
+ */
+
+class ShowListViewItem : public QListViewItem
+{
+public:
+
+ /**
+ * Constructor
+ * @param parent mail list view
+ * @param after insert the new item after this item
+ */
+ ShowListViewItem (QListView * parent, ShowListViewItem * after);
+
+ /**
+ * Constructor
+ * @param parent mail list view
+ */
+ ShowListViewItem( QListView* parent );
+
+
+ virtual ~ShowListViewItem();
+ virtual QString key (int column, bool ascending) const;
+ /**
+ * reimplement compare to solve bug #856005
+ * standard compare is locale dependant
+ */
+ virtual int compare( QListViewItem *i, int col, bool ascending ) const;
+ void setNumber (const QString&);
+ void setAccount(const QString&);
+ void setFrom(const QString&);
+ void setTo(const QString&);
+ void setSubject(const QString&);
+ void setDate(const QString&);
+ void setSize(const QString&);
+ void setContent(const QString&);
+ void setState(const QString&);
+ void setTime (const QString&);
+ enum {_colNumber, _colAccount, _colFrom, _colTo, _colSubject, _colDate,
+ _colSize, _colContent, _colState};
+private:
+ QString m_time;
+};
+
+
+#endif
diff --git a/kshowmail/showmaildialog.cpp b/kshowmail/showmaildialog.cpp
new file mode 100644
index 0000000..1d911db
--- /dev/null
+++ b/kshowmail/showmaildialog.cpp
@@ -0,0 +1,101 @@
+//
+// C++ Implementation: showmaildialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "showmaildialog.h"
+
+ShowMailDialog::ShowMailDialog( QWidget * parent, QString & caption, bool allowHTML, QString & sender, QString & date, QString & size, QString & subject, QString & body ) :
+ KDialogBase( parent, "showmaildialog", true, caption, KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::User1, KDialogBase::Ok, true, KGuiItem( i18n( "Reply" ), "mail_reply" ) )
+{
+ //create main widget
+ QWidget* mainWidget = new QWidget( this );
+ setMainWidget( mainWidget );
+
+ //this layout seperates meta data area (date, subject, and so on) from the mail body area
+ QVBoxLayout* layMain = new QVBoxLayout( mainWidget, 0, spacingHint() );
+
+ //this layouts arranges the labels and lines for the meta data
+ QHBoxLayout* layMetaDatas = new QHBoxLayout( layMain, spacingHint() );
+ QVBoxLayout* layLabels = new QVBoxLayout( layMetaDatas, spacingHint() );
+ QVBoxLayout* layLines = new QVBoxLayout( layMetaDatas, spacingHint() );
+
+ //create labels for meta data
+ QLabel* lblSender = new QLabel( i18n( "Sender:" ), mainWidget, "lblSender" );
+ layLabels->addWidget( lblSender );
+
+ QLabel* lblDate = new QLabel( i18n( "Date:" ), mainWidget, "lblDate" );
+ layLabels->addWidget( lblDate );
+
+ QLabel* lblSize = new QLabel( i18n( "Size:" ), mainWidget, "lblSize" );
+ layLabels->addWidget( lblSize );
+
+ QLabel* lblSubject = new QLabel( i18n( "Subject:" ), mainWidget, "lblSubject" );
+ layLabels->addWidget( lblSubject );
+
+ //create edit lines to show the meta data
+ KLineEdit* liSender = new KLineEdit( sender, mainWidget, "liSender" );
+ liSender->setReadOnly( true );
+ layLines->addWidget( liSender );
+
+ KLineEdit* liDate = new KLineEdit( date, mainWidget, "liDate" );
+ liDate->setReadOnly( true );
+ layLines->addWidget( liDate );
+
+ KLineEdit* liSize = new KLineEdit( size, mainWidget, "liSize" );
+ liSize->setReadOnly( true );
+ layLines->addWidget( liSize );
+
+ KLineEdit* liSubject = new KLineEdit( subject, mainWidget, "liSubject" );
+ liSubject->setReadOnly( true );
+ layLines->addWidget( liSubject );
+
+ //create text browser for the mail body
+ KTextBrowser* txtBody = new KTextBrowser( mainWidget );
+ txtBody->setReadOnly( true );
+
+ if( !allowHTML ) //set HTML view or not
+ txtBody->setTextFormat( KTextBrowser::PlainText );
+
+ txtBody->setText( body );
+ txtBody->setMinimumSize( WIDTH_VIEW_MAILBODY, HEIGHT_VIEW_MAILBODY );
+
+ layMain->addWidget( txtBody );
+
+ //store body, subject and sender for reply (slotUser1())
+ m_body = body;
+ m_subject = subject;
+ m_sender = sender;
+}
+
+ShowMailDialog::~ShowMailDialog()
+{
+}
+
+void ShowMailDialog::slotUser1( )
+{
+ //make copy of body to manipulate
+ QString body = m_body;
+
+ //add '>' at front of every line
+ body.insert( 0, "> " );
+ body.replace( "\n", "\n> " );
+
+ //set data of the answer mail
+ KURL mail;
+ mail.setProtocol( "mailto" );
+ mail.setPath( m_sender );
+ mail.setQuery( "?subject=" + KURL::encode_string( "Re: " + m_subject ) + "&body=" + KURL::encode_string( body ) );
+
+ //invoke mailer
+ kapp->invokeMailer( mail );
+}
+
+
+#include "showmaildialog.moc"
diff --git a/kshowmail/showmaildialog.h b/kshowmail/showmaildialog.h
new file mode 100644
index 0000000..39890b0
--- /dev/null
+++ b/kshowmail/showmaildialog.h
@@ -0,0 +1,90 @@
+//
+// C++ Interface: showmaildialog
+//
+// Description:
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef SHOWMAILDIALOG_H
+#define SHOWMAILDIALOG_H
+
+//QT headers
+#include <qlayout.h>
+#include <qlabel.h>
+
+//KDE headers
+#include <klocale.h>
+#include <kdialogbase.h>
+#include <klineedit.h>
+#include <kdebug.h>
+#include <ktextbrowser.h>
+#include <kurl.h>
+#include <kapplication.h>
+
+//KShowmail headers
+#include "constants.h"
+
+/**
+ * This dialog is used in ConfigElem to show a downloaded mail.
+ *
+ * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
+*/
+class ShowMailDialog : public KDialogBase
+{
+
+Q_OBJECT
+
+public:
+
+ /**
+ * generic constructor
+ * @param parent parent of the dialog
+ * @param caption the dialog caption
+ * @param allowHTML TRUE - allow the dialog to use the HTML in the mail body; FALSE - don't allow
+ * @param sender mail sender
+ * @param date date of send
+ * @param size mail size
+ * @param subject mail subject
+ * @param body mail body
+ */
+ ShowMailDialog( QWidget* parent, QString& caption, bool allowHTML, QString& sender, QString& date, QString& size, QString& subject, QString& body );
+
+ /**
+ * Destructor
+ */
+ ~ShowMailDialog();
+
+private:
+
+ /**
+ * mail subject
+ * Stored by constructor and used by slotUser1.
+ */
+ QString m_subject;
+
+ /**
+ * mail body
+ * Stored by constructor and used by slotUser1.
+ */
+ QString m_body;
+
+ /**
+ * mail sender
+ * Stored by constructor and used by slotUser1.
+ */
+ QString m_sender;
+
+ /**
+ * Overloaded methode of KDialogBase.
+ * Will be invoked, when reply button was clicked.
+ * Starts the composer of the preset mail application which contains
+ * the necessary data for a reply.
+ */
+ void slotUser1();
+};
+
+#endif
diff --git a/kshowmail/showrecord.cpp b/kshowmail/showrecord.cpp
new file mode 100644
index 0000000..b5df70a
--- /dev/null
+++ b/kshowmail/showrecord.cpp
@@ -0,0 +1,669 @@
+/***************************************************************************
+ showrecord.cpp - description
+ -------------------
+ begin : Mon Dec 3 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "showrecord.h"
+
+int const ShowRecord::continueShowHeaders( 0 );
+int const ShowRecord::cancelShowHeaders( 1 );
+
+ShowRecord::ShowRecord()
+{
+ //set auto delete to true. This is a function of the parent class, which deletes
+ //all items when the list is deleted or cleared.
+ setAutoDelete( true );
+}
+
+ShowRecord::~ShowRecord()
+{
+}
+
+void ShowRecord::saveOptions( QDomDocument& doc, QDomElement& parent )
+{
+ //Loop over all mail items
+ for( ShowRecordElem* pElem = first(); pElem; pElem = next() )
+ {
+ //call the method of the mail to save it
+ pElem->saveOptions( doc, parent );
+ }
+}
+
+void ShowRecord::readStoredMails( QDomElement& parent )
+{
+ //clear the list
+ clear();
+
+ //get first DOM node (mail)
+ QDomNode n = parent.firstChild();
+
+ //iterate over all mail items stored in the given account
+ while( !n.isNull() )
+ {
+ //get element of the current node
+ QDomElement e = n.toElement();
+
+ //create mail object
+ ShowRecordElem* pElem = new ShowRecordElem();
+
+ //store the currently read mail data in the new object
+ pElem->readOptions( e );
+
+ //store the new mail object in this list
+ append( pElem );
+
+ //get next DOM node
+ n = n.nextSibling();
+ }
+}
+
+bool ShowRecord::hasSelectedMails( )
+{
+ bool selected = false; //TRUE when a selected mail was found
+ ShowRecordElem* mail; //mail which we want to check
+
+ //get first mail
+ mail = first();
+
+ //iterate over all mails until we have found a selected mail
+ while( mail != NULL && !selected )
+ {
+ //check the current mail
+ selected = mail->isSelected();
+
+ //get next mail
+ mail = next();
+ }
+
+ return selected;
+}
+
+MailNumberList_Type ShowRecord::getSelectedMails( )
+{
+ MailNumberList_Type list; //contains the numbers of selected mails
+ ShowRecordElem* mail; //mail from which we want to get the number (if selected)
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+
+ //iterate over all mails
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if current mail is selected append its number to the mail number list
+ if( mail->isSelected() )
+ list.append( mail->number() );
+ }
+
+ return list;
+}
+
+void ShowRecord::removeMail( int number )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, remove it
+ if( mail->number() == number )
+ remove( mail );
+ }
+}
+
+QStringList ShowRecord::getSelectedSubjects( ) const
+{
+ QStringList subjects; //contains the subjects
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+
+ //iterate over all mails
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the mail is selected, append subject to list
+ if( mail->isSelected() )
+ subjects.append( mail->subject() );
+ }
+
+ return subjects;
+}
+
+QString ShowRecord::getSenderOf( int number ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString sender; //sender of the wanted mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, remove it
+ if( mail->number() == number )
+ {
+ sender = mail->from();
+ found = true;
+ }
+ }
+ return sender;
+}
+
+QString ShowRecord::getDateOf( int number ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString date; //sent date of the wanted mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, remove it
+ if( mail->number() == number )
+ {
+ date = mail->date();
+ found = true;
+ }
+ }
+ return date;
+
+}
+
+QString ShowRecord::getSizeOf( int number ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString size; //size of the wanted mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, remove it
+ if( mail->number() == number )
+ {
+ size = mail->strSizePrefix();
+ found = true;
+ }
+ }
+ return size;
+
+}
+
+QString ShowRecord::getSubjectOf( int number ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString subject; //subject of the wanted mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, get the subject
+ if( mail->number() == number )
+ {
+ subject = mail->subject();
+ found = true;
+ }
+ }
+ return subject;
+
+}
+
+QString ShowRecord::decodeMailBody( QByteArray body, int number, bool preferHTML ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString mailbody; //decoded mail
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, decode the mail
+ if( mail->number() == number )
+ {
+ mailbody = mail->decodeMailBody( body, preferHTML );
+ found = true;
+ }
+ }
+ return mailbody;
+
+}
+
+bool ShowRecord::hasMail( QString uid )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //compare the uid
+ if( mail->uidl() == uid )
+ {
+ found = true;
+ }
+ }
+ return found;
+}
+
+void ShowRecord::appendNewMail( int number, QString uid, bool isNew )
+{
+ //create new mail
+ ShowRecordElem* newMail = new ShowRecordElem( number, uid, isNew );
+
+ //append new mail
+ if( newMail != NULL )
+ append( newMail );
+}
+
+void ShowRecord::printMailList( )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+
+ while( ( mail = it.current() ) )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //print mail
+ cout << mail->number() << " - UID: " << mail->uidl() << "; Size: " << mail->size() << "; Subject: " << mail->subject() << "; New: " << mail->isNew() << endl;
+ }
+
+}
+
+void ShowRecord::setSize( int number, long size )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, decode the mail
+ if( mail->number() == number )
+ {
+ mail->setSize( size );
+ found = true;
+ }
+ }
+}
+
+Types::MailNumberList_Type ShowRecord::getNewMails( )
+{
+ MailNumberList_Type list; //contains the numbers of the new mails
+ ShowRecordElem* mail; //mail from which we want to get the number (if new)
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+
+ //iterate over all mails
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if current mail is new append its number to the mail number list
+ if( mail->isNew() )
+ list.append( mail->number() );
+ }
+
+ return list;
+}
+
+void ShowRecord::setHeader( int number, QString header )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, set the header
+ if( mail->number() == number )
+ {
+ mail->setHeader( header );
+ found = true;
+ }
+ }
+}
+
+QStringList ShowRecord::getUIDsOfOldMails( )
+{
+ QStringList list; //contains the UIDs of the old mails
+ ShowRecordElem* mail; //mail from which we want to get the uid (if old)
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+
+ //iterate over all mails
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if current mail is new append its number to the mail number list
+ if( !mail->isNew() )
+ list.append( mail->uidl() );
+ }
+
+ return list;
+}
+
+QString ShowRecord::getHeaderOf( QString uid )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ QString header; //header of the wanted mail
+
+ //looking for the mail with the UID 'uid'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given uid, get the header
+ if( mail->uidl() == uid )
+ {
+ header = mail->header();
+ found = true;
+ }
+ }
+ return header;
+}
+
+void ShowRecord::setHeader( QString uid, QString header )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the UID 'uid'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given UID, set the header
+ if( mail->uidl() == uid )
+ {
+ mail->setHeader( header );
+ found = true;
+ }
+ }
+}
+
+int ShowRecord::getNumberNewMails( )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ int number = 0; //number of new mails
+
+ while( ( mail = it.current() ) )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //increment number, if this mail is new
+ if( mail->isNew() )
+ number++;
+ }
+
+ return number;
+}
+
+int ShowRecord::getNumberMails( )
+{
+ return count();
+}
+
+long ShowRecord::getTotalSize( )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ long size = 0; //total size of all mails
+
+ while( ( mail = it.current() ) )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ size += mail->size();
+ }
+
+ return size;
+}
+
+void ShowRecord::fillMailListView( KshowmailView * view, QString & account )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+
+ //iterate over all mails and order the mail to create a list view item
+ while( ( mail = it.current() ) )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //insert list view item
+ QString number = QString( "%1" ).arg( mail->number() );
+ QString from = mail->from();
+ QString to = mail->to();
+ QString subject = mail->subject();
+ QString date = mail->date();
+ QString size = QString( "%1" ).arg( mail->size() );
+ QString content = mail->content();
+ QString state = mail->state();
+ QString time = mail->strUnixTime();
+ mail->setViewItem( view->insertMail( number, account, from, to, subject, date, size, content, state, time ) );
+ }
+
+}
+
+int ShowRecord::showSelectedHeaders( QString& account )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ int showNextHeader = ShowRecordElem::continueShowHeaders; //return value of ShowRecordElem::showHeader()
+
+ while( ( mail = it.current() ) && showNextHeader == ShowRecordElem::continueShowHeaders )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //order the mail to show its header
+ if( mail->isSelected() )
+ showNextHeader = mail->showHeader( account );
+ }
+
+ return showNextHeader == ShowRecordElem::continueShowHeaders ? ShowRecord::continueShowHeaders : ShowRecord::cancelShowHeaders;
+}
+
+bool ShowRecord::isNew( QString uid ) const
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+ bool newMail = false; //at time we have not found it, therefore the return value is false
+
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //compare the uid
+ if( mail->uidl() == uid )
+ {
+ found = true;
+ newMail = mail->isNew();
+ }
+ }
+
+ return newMail;
+}
+
+void ShowRecord::applyHeaderFilter( HeaderFilter * filter, QString account, MailNumberList_Type& deleteList, MailToDownloadMap_Type& downloadList, int& nmbIgnoredMails, FilterLog* log )
+{
+
+ MailNumberList_Type mailsToIgnore; //this list holds the numbers of all mails, which shall be ignored
+
+ //Loop over all mails in this list
+ for( ShowRecordElem* pElem = first(); pElem; pElem = next() )
+ {
+ //apply the filters to the current mail
+ QString mailbox;
+ FilterAction_Type action = pElem->applyHeaderFilter( filter, account, mailbox, log );
+
+ //do recommend action
+ //we don't need to do everything for action MARK, because ShowRecordElem::applyHeaderFilter() marks the mail entry itself
+ struct DownloadActionParams_Type params;
+ switch( action )
+ {
+ case FActDelete : deleteList.append( pElem->number() ); break;
+ case FActMove : params.action = FActMove;
+ params.mailbox = mailbox;
+ downloadList.insert( pElem->number(), params );
+ break;
+ case FActIgnore : mailsToIgnore.append( pElem->number() ); break;
+ case FActSpamcheck : params.action = FActSpamcheck;
+ downloadList.insert( pElem->number(), params );
+ default : break;
+ }
+ }
+
+ //remove all mails which shall be ignored from the mail list
+ nmbIgnoredMails = mailsToIgnore.count();
+ MailNumberList_Type::iterator it;
+ for ( it = mailsToIgnore.begin(); it != mailsToIgnore.end(); ++it )
+ removeMail( *it );
+
+
+}
+
+void ShowRecord::writeToMoveLog( FilterLog * log, int number, QString account, QString mailbox )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, set the header
+ if( mail->number() == number )
+ {
+ mail->writeToMoveLog( log, account, mailbox );
+ found = true;
+ }
+ }
+}
+
+void ShowRecord::writeToDeleteLog( FilterLog * log, int number, QString account )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, set the header
+ if( mail->number() == number )
+ {
+ mail->writeToDeleteLog( log, account );
+ found = true;
+ }
+ }
+}
+
+void ShowRecord::setMarkAtNextViewRefresh( int number )
+{
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+ bool found = false; //True, when the wanted mail was found
+
+ //looking for the mail with the number 'number'
+ while( ( mail = it.current() ) != NULL && !found )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the current mail has the given number, set the header
+ if( mail->number() == number )
+ {
+ mail->setMarkAtNextViewRefresh();
+ found = true;
+ }
+ }
+}
+
+QStringList ShowRecord::getSelectedSenders( ) const
+{
+ QStringList senders; //contains the senders
+ QPtrListIterator<ShowRecordElem> it( *this ); //iterator for the mail list
+ ShowRecordElem* mail; //current mail
+
+ //iterate over all mails
+ while( ( mail = it.current() ) != NULL )
+ {
+ //increment iterator to next mail
+ ++it;
+
+ //if the mail is selected, append subject to list
+ if( mail->isSelected() )
+ senders.append( mail->from() );
+ }
+
+ return senders;
+}
diff --git a/kshowmail/showrecord.h b/kshowmail/showrecord.h
new file mode 100644
index 0000000..db783f2
--- /dev/null
+++ b/kshowmail/showrecord.h
@@ -0,0 +1,314 @@
+/***************************************************************************
+ showrecord.h - description
+ -------------------
+ begin : Mon Dec 3 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef SHOWRECORD_H
+#define SHOWRECORD_H
+
+//C++ header
+#include <iostream>
+
+//Qt headers
+#include <qdom.h>
+#include <qptrlist.h>
+
+//KDE headers
+#include <kstandarddirs.h>
+#include <kdebug.h>
+
+//KShowmail headers
+#include "kshowmailview.h"
+#include "showrecordelem.h"
+#include "types.h"
+#include "headerfilter.h"
+#include "filterlog.h"
+
+using namespace Types;
+using namespace std;
+
+//forward class declarations
+class ShowRecordElem;
+class KshowmailView;
+
+/**
+ * @short List which contains all mails of an account.
+ *
+ * The mails are objects of ShowRecordElem.
+ * Inherits QPtrList.
+ *
+ * @see ShowRecordElem
+ * @author Eggert Ehmke
+ * @author Ulrich Weigelt
+ */
+class ShowRecord: public QPtrList<ShowRecordElem>
+{
+
+ public:
+
+ /**
+ * Returned by showSelectedHeaders() if the user has
+ * always clicked OK.
+ */
+ static const int continueShowHeaders;
+
+ /**
+ * Returned by showSelectedHeaders() if the user has
+ * clicked Cancel.
+ */
+ static const int cancelShowHeaders;
+
+ /**
+ * Constructor
+ */
+ ShowRecord();
+
+ /**
+ * Destructor
+ * Does nothing.
+ */
+ ~ShowRecord();
+
+ /**
+ * Saves all stored mails into the given DOM document inside the
+ * given account element.
+ * @param doc DOM document in that all options are stored
+ * @param parent account element
+ */
+ void saveOptions( QDomDocument& doc, QDomElement& parent );
+
+ /**
+ * Reads out all mails stored inside the given account element,
+ * creates objects from class ShowRecordElem and stores them in
+ * this list. All old items will be removed.
+ * @param parent account element (DOM element)
+ */
+ void readStoredMails( QDomElement& parent );
+
+ /**
+ * Apply the filters to the mails in this list.
+ * @param filter pointer to the header filter
+ * @param account name of this account
+ * @param deleteList reference to a list in which this methode writes the numbers of mails to delete
+ * @param downloadList reference to a list in which this methode writes the number of mails to download
+ * @param nmbIgnoredMails reference to an integer in which it writes the number of ignored mails
+ * @param log pointer to the filter log
+ */
+ void applyHeaderFilter( HeaderFilter* filter, QString account, MailNumberList_Type& deleteList, MailToDownloadMap_Type& downloadList, int& nmbIgnoredMails, FilterLog* log = NULL );
+
+
+ /**
+ * Returns whether there are mails in this list which are selected
+ * in the list view.
+ * @return TRUE - there are selected mails
+ * @return FALSE - there aren't selected mails
+ */
+ bool hasSelectedMails();
+
+ /**
+ * Returns the numbers of all selected mails.
+ * @return numbers of selected mails.
+ */
+ Types::MailNumberList_Type getSelectedMails();
+
+ /**
+ * Removes the mail which has the given number.
+ * @param number number of the mail which will be removed
+ */
+ void removeMail( int number );
+
+ /**
+ * Returns the subjects of the selected mails.
+ * @return subjects of selected mails
+ */
+ QStringList getSelectedSubjects() const;
+
+ /**
+ * Returns the sender of the mail with the given number.
+ * @param number mail number
+ * @return sender
+ */
+ QString getSenderOf( int number ) const;
+
+ /**
+ * Returns the date of sent of the mail with the given number.
+ * @param number mail number
+ * @return date
+ */
+ QString getDateOf( int number ) const;
+
+ /**
+ * Returns the size of the mail with the given number.
+ * @param number mail number
+ * @return size
+ */
+ QString getSizeOf( int number ) const;
+
+ /**
+ * Returns the subject of the mail with the given number.
+ * @param number mail number
+ * @return subject
+ */
+ QString getSubjectOf( int number ) const;
+
+ /**
+ * Decodes the given mail body by the appropriate mail object.
+ * The mail object (ShowRecordElem) has to do this job, because
+ * it has stored the mail header and therefore it knows the content
+ * type and encoding of the mail.
+ * It decodes just the text or html part of the body. The rest of it
+ * will be rejected.
+ * @param body the encoded mail (including header)
+ * @param number number of the downloaded mail
+ * @param preferHTML decode HTML part if present
+ * @return decoded mail body
+ */
+ QString decodeMailBody( QByteArray body, int number, bool preferHTML ) const;
+
+ /**
+ * Returns whether there is mail with the given uid in the list.
+ * @param uid UID of the mail
+ * @return TRUE - mail is in the list
+ * @return FALSE - mail is not in the list
+ */
+ bool hasMail( QString uid );
+
+ /**
+ * Returns whether the given mail is new.
+ * @param uid UID of the mail
+ * @return TRUE - mail is new
+ * @return FALSE - mail is not new or mail doesn't exist
+ */
+ bool isNew( QString uid ) const;
+
+ /**
+ * Appends a new mail to the list.
+ * @param number number of the mail on the server
+ * @param uid Unique ID of the mail
+ * @param isNew TRUE - mail is new; FALSE - mail is not new
+ */
+ void appendNewMail( int number, QString uid, bool isNew );
+
+ /**
+ * Just for debugging.
+ * Prints a list of all contained mails to stdout.
+ */
+ void printMailList();
+
+ /**
+ * Sets the size of a mail.
+ * @param number number of the mail
+ * @param size mail size
+ */
+ void setSize( int number, long size );
+
+ /**
+ * Returns the numbers of mails which are marked as new.
+ * @return numbers of the new mails
+ */
+ Types::MailNumberList_Type getNewMails();
+
+ /**
+ * Sets the header of the given mail.
+ * @param number number of the mail
+ * @param header the header
+ */
+ void setHeader( int number, QString header );
+
+ /**
+ * Returns a list of the UIDs of all old mails.
+ * @return UIDs of all old mails
+ */
+ QStringList getUIDsOfOldMails();
+
+ /**
+ * Returns the header of the mail with the given UID.
+ * @param uid UID
+ * @return mail header
+ */
+ QString getHeaderOf( QString uid );
+
+ /**
+ * Sets the header of the mail with the given UID.
+ * @param uid UID
+ * @param header mail header
+ */
+ void setHeader( QString uid, QString header );
+
+ /**
+ * Returns the number of new mails.
+ * @return number of new mails
+ */
+ int getNumberNewMails();
+
+ /**
+ * Returns the number of mails.
+ * @return number of mails
+ */
+ int getNumberMails();
+
+ /**
+ * Returns the total size of all mails.
+ * @return total size
+ */
+ long getTotalSize();
+
+ /**
+ * Creates for every mail a list view item and insert it
+ * into the mail list view.
+ * @param view pointer to the application view
+ * @param account account name
+ */
+ void fillMailListView( KshowmailView* view, QString& account );
+
+ /**
+ * Shows the headers of all selected mails.
+ * @param account account name
+ * @return continueShowHeaders - the user has always clicked OK. The invoking function will show the next header
+ * @return cancelShowHeaders - the user has clicked Cancel. The invoking function will not show the next header.
+ */
+ int showSelectedHeaders( QString& account );
+
+ /**
+ * Writes the mail into the Move Log.
+ * @param log pointer to the log
+ * @param number number of the mail
+ * @param account name of the account
+ * @param mailbox name of the mailbox
+ */
+ void writeToMoveLog( FilterLog* log, int number, QString account, QString mailbox );
+
+ /**
+ * Writes the mail into the Delete Log.
+ * @param log pointer to the log
+ * @param number number of the mail
+ * @param account name of the account
+ */
+ void writeToDeleteLog( FilterLog* log, int number, QString account );
+
+ /**
+ * The given mail will be marked at the next view refresh.
+ * @param number number of the mail
+ */
+ void setMarkAtNextViewRefresh( int number );
+
+ /**
+ * Returns the senders of the selected mails
+ * @return senders of the selected mails
+ */
+ QStringList getSelectedSenders() const;
+};
+
+#endif
diff --git a/kshowmail/showrecordelem.cpp b/kshowmail/showrecordelem.cpp
new file mode 100644
index 0000000..63f5157
--- /dev/null
+++ b/kshowmail/showrecordelem.cpp
@@ -0,0 +1,632 @@
+/***************************************************************************
+ showrecord.cpp - description
+ -------------------
+ begin : Thu Dec 28 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+
+
+
+#include "showrecordelem.h"
+
+int const ShowRecordElem::continueShowHeaders( 0 );
+int const ShowRecordElem::cancelShowHeaders( 1 );
+
+ShowRecordElem::ShowRecordElem ()
+{
+ //set default values
+ m_from = "???";
+ m_subject = "???";
+ m_size = 0;
+ m_pItem = NULL;
+ m_new = false;
+ markAtViewRefresh = false;
+}
+
+ShowRecordElem::ShowRecordElem( int number, QString& uid, bool isNew )
+{
+ //set default values
+ m_from = "???";
+ m_subject = "???";
+ m_size = 0;
+ m_pItem = NULL;
+ markAtViewRefresh = false;
+
+ //set given values
+ m_nNumber = number;
+ m_uid = uid;
+ m_new = isNew;
+}
+
+
+QCString ShowRecordElem::scanHeader( const QString& item ) const
+{
+ QCString headerline( "" ); //found header line
+
+ //get e.g. the "From:" line, starting with cr,lf,"From:" and ending
+ //with a carriage return
+
+ //build the search string
+ QString searchstring( QString( "\r\n%1:" ).arg( item ) );
+
+ //searching...
+ int pos1 = m_header.find( searchstring, 0, FALSE );
+ int pos2 = m_header.find( '\r', pos1 + 2 );
+
+ //cut out the interesting content, if we have found a matching line
+ //if we have found nothing, the returned string will be ""
+ if( pos1 >= 0 )
+ {
+ headerline = m_header.mid( pos1 + searchstring.length(), pos2 - pos1 - searchstring.length() );
+ }
+
+ return headerline;
+}
+
+void ShowRecordElem::setHeader( const QString& header )
+{
+ //store given header
+ m_header = header.ascii();
+
+ //extract sender and store it
+ QCString from = scanHeader( "From" );
+ from = from.simplifyWhiteSpace();
+ setFrom( from );
+
+ //extract addressee and store it
+ QCString to = scanHeader( "To" );
+ to = to.simplifyWhiteSpace();
+ setTo (to);
+
+ //extract subject and store it
+ QCString subject = scanHeader( "Subject" );
+ subject = subject.simplifyWhiteSpace();
+ setSubject( subject );
+
+ //extract date and store it
+ QCString date = scanHeader( "Date" );
+ setDate( date );
+
+ //extract content type
+ QCString content = scanHeader( "Content-Type" );
+ content = content.simplifyWhiteSpace ();
+
+ //remove the stuff after the content type; see RFC 2045
+ int posSemicolon = content.find( ';' );
+ if( posSemicolon != -1 )
+ {
+ content.remove( posSemicolon, content.length() - posSemicolon );
+ }
+
+ //store content type
+ setContent (content);
+}
+
+void ShowRecordElem::setDate( const QCString& date )
+{
+ DwDateTime dwDate; //this class represents an RFC-822 date-time;
+ //see mimelib/datetime.h
+
+ //convert and store the date-time
+ dwDate.FromString( date );
+ dwDate.Parse();
+ m_unixDate.setTime_t( dwDate.AsUnixTime() );
+}
+
+QString ShowRecordElem::from() const
+{
+ return Codecs::decodeRFC2047( m_from );
+}
+
+QString ShowRecordElem::to() const
+{
+ return Codecs::decodeRFC2047( m_to );
+}
+
+QString ShowRecordElem::subject() const
+{
+ return Codecs::decodeRFC2047( m_subject );
+}
+
+QString ShowRecordElem::date() const
+{
+ return KGlobal::locale()->formatDateTime( m_unixDate, true, true );
+}
+
+QString ShowRecordElem::strUnixTime() const
+{
+ return m_unixDate.toString( Qt::ISODate );
+}
+
+QString ShowRecordElem::strSize() const
+{
+ return QString( "%1" ).arg( m_size, 8 );
+}
+
+QString ShowRecordElem::state() const
+{
+ if( m_new )
+ return i18n( "new" );
+ else
+ return i18n( "old" );
+}
+
+void ShowRecordElem::saveOptions( QDomDocument& doc, QDomElement& parent )
+{
+ //build item tag of this mail( with mail number)
+ QString hdr = QString( ITEM_MESSAGE );
+ hdr.append( "%1" );
+ hdr = hdr.arg( m_nNumber );
+
+ //create a new element and store the mail meta data in it
+ QDomElement elem = doc.createElement( hdr );
+ elem.setAttribute( ATTRIBUTE_MAIL_NUMBER, m_nNumber );
+ elem.setAttribute( ATTRIBUTE_MAIL_SIZE, m_size );
+ elem.setAttribute( ATTRIBUTE_MAIL_UID, m_uid );
+
+ //create a sub element for the mail header in store the header in it
+ QDomElement subelem = doc.createElement( ITEM_MAIL_HEADER );
+ subelem.appendChild( doc.createTextNode( m_header ) );
+
+ //add header element to the mail element
+ elem.appendChild( subelem );
+
+ //add mail element to the account (parent) element
+ parent.appendChild( elem );
+}
+
+void ShowRecordElem::readOptions( QDomElement& elem )
+{
+ //get number, size and uid
+ setNumber( elem.attribute( ATTRIBUTE_MAIL_NUMBER ).toInt() );
+ setSize( elem.attribute( ATTRIBUTE_MAIL_SIZE ).toInt() );
+ setUIDL( elem.attribute( ATTRIBUTE_MAIL_UID ) );
+
+ //search for the header item and read it
+ QDomElement subelem = elem.namedItem( ITEM_MAIL_HEADER ).toElement();
+ setHeader( subelem.text() );
+
+ //the mail is not new
+ setNew( false );
+}
+
+
+void ShowRecordElem::setFrom( const QCString & from )
+{
+ m_from = from;
+}
+
+void ShowRecordElem::setTo( const QCString & to )
+{
+ m_to = to;
+}
+
+void ShowRecordElem::setSubject( const QCString & subject )
+{
+ m_subject = subject;
+}
+
+void ShowRecordElem::setContent( const QCString& content )
+{
+ m_content = content;
+}
+
+QString ShowRecordElem::header( ) const
+{
+ return QString( m_header );
+}
+
+void ShowRecordElem::setUIDL( const QString & uid )
+{
+ m_uid = uid;
+}
+
+QString ShowRecordElem::uidl( ) const
+{
+ return m_uid;
+}
+
+void ShowRecordElem::setSize( int size )
+{
+ m_size = size;
+}
+
+int ShowRecordElem::size( ) const
+{
+ return m_size;
+}
+
+void ShowRecordElem::setNew( bool isnew )
+{
+ m_new = isnew;
+}
+
+bool ShowRecordElem::isNew( ) const
+{
+ return m_new;
+}
+
+void ShowRecordElem::setNumber( int n )
+{
+ m_nNumber = n;
+}
+
+int ShowRecordElem::number( ) const
+{
+ return m_nNumber;
+}
+
+QString ShowRecordElem::content( ) const
+{
+ return m_content;
+}
+
+void ShowRecordElem::setViewItem( ShowListViewItem* item )
+{
+ m_pItem = item;
+
+ //marks the new entry if recommend by the filter
+ if( markAtViewRefresh )
+ {
+ //mark entry
+ item->setSelected( true );
+
+ //delete flag
+ markAtViewRefresh = false;
+ }
+}
+
+ShowListViewItem * ShowRecordElem::viewItem( ) const
+{
+ return m_pItem;
+}
+
+bool ShowRecordElem::isSelected( ) const
+{
+ if( m_pItem != NULL )
+ return m_pItem->isSelected();
+ else
+ return false;
+}
+
+QString ShowRecordElem::strSizePrefix( ) const
+{
+ QString size;
+
+ if( m_size >= 1024 * 1024 )
+ {
+ //prefix is mega
+ size = QString( "%L1M" ).arg( ( (double)m_size / ( 1024 * 1024 ) ), 0, 'f', 1 );
+ }
+ else if( m_size >= 1024 )
+ {
+ //prefix is kilo
+ size = QString( "%L1K" ).arg( ( (double)m_size / 1024 ), 0, 'f', 1 );
+ }
+ else
+ //no prefix
+ size = QString( "%L1" ).arg( m_size );
+
+ return size;
+}
+
+QString ShowRecordElem::decodeMailBody( QByteArray body, bool preferHTML ) const
+{
+ QString charset; //charset of the content
+ QString encoding; //content transfer encoding
+
+ //cast given body to a QCString
+ //class QCString needs a null terminated char array to create
+ //an object. Therefore we append an null byte to the given mail body
+ body.resize( body.size() + 1 );
+ body[ body.size() - 1 ] = '\0';
+ QCString strBody( (char *)body.data() );
+
+ //normalize line ends; remove all \r characters
+ for( uint i = 0; i < strBody.size(); i++ )
+ if( strBody[ i ] == '\r' )
+ strBody.remove( i, 1 );
+
+ //get boundary that is separating the parts of a multipart message
+ //if the header doesn't contain a boundary attribute, this messsage
+ //has just one part
+ QString boundary = getBoundary();
+
+ //process body subject to it is a multipart messsage or not
+ if( boundary == "" )
+ {
+ //the message has just one body part
+
+ //get the position of the first blank line
+ int posBlankLine = strBody.find( "\n\n" );
+
+ //truncate body; the found blank line is separating the
+ //header from the message
+ strBody = strBody.mid( posBlankLine + 2 );
+ if( !strBody.isEmpty() ) //fixed bug 1773636
+ while( strBody[ 0 ] == '\n')
+ strBody.remove( 0, 1 );
+
+
+ //get charset of the message; it is behind the
+ //content type attribute in the header
+ charset = getCharset();
+
+ //get transfer encoding type from the header
+ encoding = getTransferEncoding();
+ }
+ else
+ {
+ //the message has multiple parts
+
+ //get positions of a plain text and html flag (value of the content type attribute)
+ int posPlainFlag = strBody.find( "text/plain", 0, false );
+ int posHTMLFlag = strBody.find( "text/html", 0, false );
+
+ //just decode the body, if a plain text or a HTML part is available
+ if( posPlainFlag != -1 || posHTMLFlag != -1 )
+ {
+ //do we want to take the HTML part?
+ bool hasHTML = posHTMLFlag != -1;
+ bool takeHTML = ( hasHTML && preferHTML ) || posPlainFlag == -1;
+
+ //now we want to extract the designated part
+ //While the (truncated) mail text (or the header at the first pass)
+ //contains a boundary attribute we will extract the designated part
+ //between the boundaries
+ int posInside; //a position inside the designated part
+ while( boundary != "" )
+ {
+ //get a position inside the designated part
+ if( takeHTML )
+ posInside = strBody.find( "text/html", 0, false );
+ else
+ posInside = strBody.find( "text/plain", 0, false );
+
+ //get length of the boundary
+ int lengthBoundary = boundary.length();
+
+ //calculate the begin and end of the part to extract
+ int beginPart = strBody.findRev( boundary.ascii(), posInside ) + lengthBoundary + 1;
+ int lengthPart = strBody.findRev( '\n', strBody.find( boundary.ascii(), posInside ) ) - beginPart;
+
+ strBody = strBody.mid( beginPart, lengthPart );
+
+ //looking for a further boundary attribute
+ //get the position of the first occurance of "boundary="
+ int posBoundary = strBody.find( "boundary=", 0, false );
+
+ if( posBoundary >= 0 )
+ {
+ //calculate positon of the first quote
+ int posFirstQuote = posBoundary + 9;
+
+ //get the position of closing quote
+ int posSecondQuote = strBody.find( '"', posFirstQuote + 1 );
+
+ //get boundary string
+ boundary.append( strBody.mid( posFirstQuote + 1, posSecondQuote - posFirstQuote - 1 ) );
+ }
+ else
+ boundary = "";
+ }
+
+ //now we get charset and transfer encoding if available in the extracted
+ //part
+
+ //get the position of the first occurance of "charset="
+ int posCharset = strBody.find( "charset=", 0, false );
+
+ //continue, if a charset attribute was found
+ if( posCharset >= 0 )
+ {
+ //calculate positon of the value
+ int posBeginValue = posCharset + 8;
+
+ //get end of the value
+ int posEndValue = strBody.find( '\n', posBeginValue ) - 1;
+
+ //get charset
+ charset.append( strBody.mid( posBeginValue, posEndValue - posBeginValue + 1 ) );
+
+ //remove quotes
+ charset.remove( '"' );
+ //remove all content after the first semicolon (inclusive)
+ int posSemicolon = charset.find( ';' );
+ charset = charset.left( posSemicolon );
+ }
+
+ //get the position of the first occurance of "charset="
+ int posEncoding = strBody.find( "Content-Transfer-Encoding:", 0, false );
+
+ //continue, if a charset attribute was found
+ if( posEncoding >= 0 )
+ {
+ //calculate positon of the value
+ int posBeginValue = posEncoding + 26;
+
+ //get end of the value
+ int posEndValue = strBody.find( '\n', posBeginValue ) - 1;
+
+ //get charset
+ encoding.append( strBody.mid( posBeginValue, posEndValue - posBeginValue + 1 ) );
+
+ //remove quotes and spaces
+ encoding = encoding.stripWhiteSpace();
+ encoding.remove( '"' );
+ }
+
+ //cut off the part header; the found blank line is separating the
+ //part header from the message
+ if( posCharset != -1 || posEncoding != -1 )
+ {
+ int posBlankLine = strBody.find( "\n\n" );
+ strBody = strBody.mid( posBlankLine + 2 );
+ if( !strBody.isEmpty() ) //fixed bug 1773636
+ while( strBody[ 0 ] == '\n')
+ strBody.remove( 0, 1 );
+ }
+ }
+ }
+
+ //Good things come to those who wait. We have extract the message.
+ //Now we have to decode the message, if it is encoded
+ if( encoding == "quoted-printable" && !strBody.isEmpty() ) //fixed bug 1773636
+ {
+ strBody = KCodecs::quotedPrintableDecode( strBody );
+ }
+
+ return QString( strBody );
+}
+
+QString ShowRecordElem::getBoundary( ) const
+{
+ QString boundary;
+
+ //check, whether it is a multipart message
+ if( m_content.contains( "multipart", false ) )
+ {
+ //it is a multipart message
+
+ //get the position of the first occurance of "boundary="
+ int posBoundary = m_header.find( "boundary=", 0, false );
+
+ //continue, if a boundary attribute was found
+ if( posBoundary >= 0 )
+ {
+ //calculate positon of the first quote
+ int posFirstQuote = posBoundary + 9;
+
+ //get the position of closing quote
+ int posSecondQuote = m_header.find( '"', posFirstQuote + 1 );
+
+ //get boundary string
+ boundary.append( m_header.mid( posFirstQuote + 1, posSecondQuote - posFirstQuote - 1 ) );
+ }
+ }
+
+ return boundary;
+}
+
+QString ShowRecordElem::getCharset( ) const
+{
+ QString charset;
+
+ //get the position of the first occurance of "charset="
+ int posCharset = m_header.find( "charset=", 0, false );
+
+ //continue, if a charset attribute was found
+ if( posCharset >= 0 )
+ {
+ //calculate positon of the value
+ int posBeginValue = posCharset + 8;
+
+ //get end of the value
+ int posEndValue = m_header.find( '\r', posBeginValue ) - 1;
+
+ //get charset
+ charset.append( m_header.mid( posBeginValue, posEndValue - posBeginValue + 1 ) );
+
+ //remove quotes
+ charset.remove( '"' );
+ //remove all content after the first semicolon (inclusive)
+ int posSemicolon = charset.find( ';' );
+ charset = charset.left( posSemicolon );
+ }
+
+ return QString( charset );
+}
+
+QString ShowRecordElem::getTransferEncoding( ) const
+{
+ QString encoding;
+
+ //get the position of the first occurance of "charset="
+ int posEncoding = m_header.find( "Content-Transfer-Encoding:", 0, false );
+
+ //continue, if a charset attribute was found
+ if( posEncoding >= 0 )
+ {
+ //calculate positon of the value
+ int posBeginValue = posEncoding + 26;
+
+ //get end of the value
+ int posEndValue = m_header.find( '\r', posBeginValue ) - 1;
+
+ //get charset
+ encoding.append( m_header.mid( posBeginValue, posEndValue - posBeginValue + 1 ) );
+
+ //remove quotes and spaces
+ encoding = encoding.stripWhiteSpace();
+ encoding.remove( '"' );
+ }
+
+ return QString( encoding );
+
+}
+
+int ShowRecordElem::showHeader( QString& account )
+{
+ //show header
+ QString tsubject = subject();
+ QString tmailheader = header();
+
+ //create and open the window
+ ShowHeaderDialog dlg( kapp->mainWidget(), account, tsubject, tmailheader );
+ int ret = dlg.exec();
+
+ //returns the matching value
+ return ret == QDialog::Accepted ? ShowRecordElem::continueShowHeaders : ShowRecordElem::cancelShowHeaders;
+}
+
+FilterAction_Type ShowRecordElem::applyHeaderFilter( HeaderFilter* filter, QString account, QString& mailbox, FilterLog* log )
+{
+ FilterAction_Type action = filter->check( from(), to(), size(), subject(), header(), account, mailbox );
+
+ //if the action is MARK, the related view entry shall be marked at the next view refresh
+ if( action == FActMark ) markAtViewRefresh = true;
+
+ //if the action is DELETE, we add a entry to the log
+ if( log == NULL )
+ kdError( "ShowRecordElem::applyHeaderFilter: Pointer to the filter log is NULL. Can't write to log." );
+ if( action == FActDelete && log != NULL )
+ log->addDeletedMail( sentDateTime(), from(), account, subject() );
+ if( action == FActMove && log != NULL )
+ log->addMovedMail( sentDateTime(), from(), account, subject(), mailbox );
+
+
+ return action;
+}
+
+QDateTime ShowRecordElem::sentDateTime() const
+{
+ return m_unixDate;
+}
+
+void ShowRecordElem::writeToMoveLog( FilterLog * log, QString account, QString mailbox )
+{
+ log->addMovedMail( sentDateTime(), from(), account, subject(), mailbox );
+}
+
+void ShowRecordElem::writeToDeleteLog( FilterLog * log, QString account )
+{
+ log->addDeletedMail( sentDateTime(), from(), account, subject() );
+}
+
+void ShowRecordElem::setMarkAtNextViewRefresh( )
+{
+ markAtViewRefresh = true;
+}
+
+
diff --git a/kshowmail/showrecordelem.h b/kshowmail/showrecordelem.h
new file mode 100644
index 0000000..3d5e9f6
--- /dev/null
+++ b/kshowmail/showrecordelem.h
@@ -0,0 +1,447 @@
+/***************************************************************************
+ showrecord.h - description
+ -------------------
+ begin : Thu Dec 28 2000
+ copyright : (C) 2000-2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef SHOWRECORDELEM_H
+#define SHOWRECORDELEM_H
+
+//Qt headers
+#include <qdom.h>
+#include <qstring.h>
+#include <qlistview.h>
+#include <qdatetime.h>
+
+//KDE headers
+#include <klocale.h>
+#include <kglobal.h>
+#include <kdebug.h>
+#include <mimelib/datetime.h>
+#include <kmdcodec.h>
+
+//KShowmail headers
+#include "showlistviewitem.h"
+#include "decodeRFC2047.h"
+#include "constants.h"
+#include "kshowmailview.h"
+#include "showheaderdialog.h"
+#include "headerfilter.h"
+#include "filterlog.h"
+
+using namespace Constants;
+
+//forward class declarations
+class KshowmailView;
+class FilterElem;
+
+/**
+ * @short Represents a mail.
+ *
+ * It contains UID, Subject, From, To and date of the mail. Subject, From and To
+ * will be read out from the given header. It also contains pointer to the
+ * corresponding list view entry and maybe to a matching filter.
+ * All mail objects are held by ShowRecord.
+ * @see ShowRecord
+ * @see ConfigElem
+ * @author Eggert Ehmke
+ */
+
+class ShowRecordElem
+{
+
+ public:
+
+ /**
+ * Returned by showHeader(), if the user has
+ * clicked OK.
+ */
+ static const int continueShowHeaders;
+
+ /**
+ * Returned by showHeader(), if the user has
+ * clicked Cancel.
+ */
+ static const int cancelShowHeaders;
+
+ /**
+ * Constructor
+ */
+ ShowRecordElem ();
+
+ /**
+ * Constructor
+ * @param number number of the mail on the server
+ * @param uid Unique ID of the mail
+ * @param isNew TRUE - mail is new; FALSE - mail is not new
+ */
+ ShowRecordElem( int number, QString& uid, bool isNew );
+
+ /**
+ * Sets the mail header and extracts From, To, Subject, Date and Content Type.
+ * All parts of the header are coded according RFC 2047.
+ * @param header the mail header
+ */
+ void setHeader( const QString& header );
+
+ /**
+ * Returns the whole header.
+ * @return the mail header
+ */
+ QString header() const;
+
+ /**
+ * Returns the sender address.
+ * @return sender address
+ */
+ QString from() const;
+
+ /**
+ * Returns the addressee.
+ * @return the addressee
+ */
+ QString to() const;
+
+ /**
+ * Returns the subject.
+ * @return mail subject
+ */
+ QString subject() const;
+
+ /**
+ * Returns the stored content type.
+ * @return content type
+ */
+ QString content() const;
+
+
+ /**
+ * Returns the date on which the mail was sent, formated to the current
+ * locale's conventions.
+ * @return the date
+ */
+ QString date() const;
+
+ /**
+ * Returns the date on which the mail was sent.
+ * The format corresponds to the ISO 8601 extended specification for
+ * representations of dates and times, which is YYYY-MM-DDTHH:MM:SS
+ * @return the date
+ */
+ QString strUnixTime () const;
+
+ /**
+ * Returns the date and time on which the mail was sent.
+ * @return the date
+ */
+ QDateTime sentDateTime() const;
+
+ /**
+ * Sets the unique mail ID.
+ * @param uid the ID
+ */
+ void setUIDL( const QString& uid );
+
+ /**
+ * Returns the unique ID of this mail.
+ * @return UID
+ */
+ QString uidl() const;
+
+ /**
+ * Sets the size of the mail.
+ * @param size Size
+ */
+ void setSize( int size );
+
+ /**
+ * Returns the mail size as numeric value.
+ * @return size of the mail
+ */
+ int size() const;
+
+ /**
+ * Returns the mail size as string.
+ * The String has a length of 8 and the number is right-aligned to allow sorting.
+ */
+ QString strSize () const;
+
+ /**
+ * Returns the mails size as string with prefix
+ */
+ QString strSizePrefix() const;
+
+ /**
+ * Sets whether the mail is new or not.
+ * @param isnew TRUE - mail is new; FALSE - mail is not new
+ */
+ void setNew( bool isnew );
+
+ /**
+ * Returns whether the mail is new or not.
+ * @return TRUE - mail is new
+ * @return FALSE - mail is not new
+ */
+ bool isNew() const;
+
+ /**
+ * Returns whether the mail is new or not.
+ * @return localized String "new", if the mail is new
+ * @return localized String "old", if the mail is not new
+ */
+ QString state() const;
+
+ /**
+ * Sets the number of this mail.
+ * @param n mail number
+ */
+ void setNumber( int n );
+
+ /**
+ * Returns the number of this mail.
+ * @return mail number
+ */
+ int number() const;
+
+ /**
+ * Sets the pointer to the corresponding list view item.
+ * @see m_pItem
+ * @see ShowListViewItem
+ * @param item pointer to the corresponding item
+ */
+ void setViewItem( ShowListViewItem* item );
+
+ /**
+ * Returns the pointer to the corresponding list view item.
+ * @see m_pItem
+ * @see ShowListViewItem
+ * @return pointer to the item
+ */
+ ShowListViewItem* viewItem() const;
+
+ /**
+ * Looks for a filter matching the mail header and returns the action recommend by this filter.
+ * If the action is MARK, it set markAtViewRefresh to True so the related view entry will be marked
+ * at the next view refresh.
+ * @param filter pointer to the header filter
+ * @param account name of the account
+ * @param mailbox reference to a QString object in which the mailbox name shall be written if the action is MOVE
+ * @param log pointer to the filter log
+ * @return recommend action
+ * @see FilterAction_Type
+ * @see HeaderFilter
+ * @see markAtViewRefresh
+ */
+ FilterAction_Type applyHeaderFilter( HeaderFilter* filter, QString account, QString& mailbox, FilterLog* log = NULL );
+
+ /**
+ * Read a mail (header, size, uid and number) from the given DOM element
+ * and store it in this mail object.
+ * The element has to contains the attributes "uidl", "size", "number" and
+ * a child node called "header".
+ * @param elem a DOM element which contains a mail
+ */
+ void readOptions( QDomElement& elem );
+
+ /**
+ * Creates a new DOM element in the given DOM document and add it to given
+ * DOM parent element
+ * @param doc the DOM document in that all options are stored
+ * @param parent the parent element (account) of the mail
+ */
+ void saveOptions( QDomDocument& doc, QDomElement& parent );
+
+ /**
+ * Returns whether the mail is selected in the list view.
+ * @return TRUE - mail is selected
+ * @return FALSE - mail is not selected
+ */
+ bool isSelected() const;
+
+ /**
+ * Decodes the given mail body.
+ * The mail object has to do this job, because
+ * it has stored the mail header and therefore it knows the content
+ * type and encoding of the mail.
+ * It decodes just the text or html part of the body. The rest of it
+ * will be rejected.
+ * @param body the encoded mail (including header)
+ * @param preferHTML decode HTML part if present
+ * @return decoded mail body
+ */
+ QString decodeMailBody( QByteArray body, bool preferHTML ) const;
+
+ /**
+ * Shows the header in a dialog box.
+ * @param account account name
+ * @return continueShowHeaders - the user has OK clicked. The invoking function will show the next header
+ * @return cancelShowHeaders - the user has Cancel clicked. The invoking function will not show the next header.
+ */
+ int showHeader( QString& account );
+
+ /**
+ * Writes this mail into the Move Log.
+ * @param log pointer to the log
+ * @param account name of the account
+ * @param mailbox name of the mailbox
+ */
+ void writeToMoveLog( FilterLog* log, QString account, QString mailbox );
+
+ /**
+ * Writes this mail into the Delete Log.
+ * @param log pointer to the log
+ * @param account name of the account
+ */
+ void writeToDeleteLog( FilterLog* log, QString account );
+
+ /**
+ * The mail will be marked at the next view refresh.
+ */
+ void setMarkAtNextViewRefresh();
+
+ private:
+
+ /**
+ * Mail header; coded according RFC 2047
+ */
+ QCString m_header;
+
+ /**
+ * The sender address; coded according RFC 2047
+ */
+ QCString m_from;
+
+ /**
+ * The addressee; coded according RFC 2047
+ */
+ QCString m_to;
+
+ /**
+ * The subject; coded according RFC 2047
+ */
+ QCString m_subject;
+
+ /**
+ * The date on which the mail was sent
+ */
+ QDateTime m_unixDate;
+
+ /**
+ * The content type
+ */
+ QCString m_content;
+
+ /**
+ * The unique ID of the mail.
+ */
+ QString m_uid;
+
+ /**
+ * Size of the mail
+ */
+ int m_size;
+
+ /**
+ * It is set to TRUE when the mail is new.
+ */
+ bool m_new;
+
+ /**
+ * The mail number of the account
+ */
+ int m_nNumber;
+
+ /**
+ * TRUE - the mail shall be marked at the next mail view refresh.
+ * It will be set to True by applyHeaderFilter() if the recommend filter action is MARK.
+ * It is used by setViewItem(). This methode marks the related list entry and after then it set
+ * this variable to False.
+ */
+ bool markAtViewRefresh;
+
+ /**
+ * Pointer to the corresponding list view entry. Used to check
+ * whether the entry is highlighted and we have to process this mail.
+ * @see ShowListViewItem
+ */
+ ShowListViewItem* m_pItem;
+
+ /**
+ * Searches in the header for a line which starts with the
+ * given item.
+ * For example:
+ * scanHeader( "From") will find the line
+ * "From: Ulrich Weigelt <ulrich.weigelt@gmx.de>"
+ * and returns "Ulrich Weigelt <ulrich.weigelt@gmx.de>"
+ * Returns an empty string (""), if nothing was found.
+ * @param item the search item
+ * @return the content of the found line
+ */
+ QCString scanHeader( const QString& item ) const;
+
+ /**
+ * Sets the given string as sender address
+ * @param from sender address
+ */
+ void setFrom( const QCString& from );
+
+ /**
+ * Sets the given string as recipient address
+ * @param to recipient address
+ */
+ void setTo( const QCString& to );
+
+ /**
+ * Sets the given string as subject
+ * @param subject the mail subject
+ */
+ void setSubject( const QCString& subject );
+
+ /**
+ * Converts the given string to a date-time value and stores it.
+ * @param date the date
+ */
+ void setDate( const QCString& date );
+
+ /**
+ * Sets the given string as content type.
+ * @param content the content type
+ */
+ void setContent( const QCString& content );
+
+ /**
+ * Returns the boundary, if the mail has a multi part body.
+ * Otherwise it returns an empty string.
+ * @return boundary
+ */
+ QString getBoundary() const;
+
+ /**
+ * Returns the char set of the content (e.g. iso-8859-1).
+ * If no char set is denoted, it will returns an empty string.
+ * @return charset
+ */
+ QString getCharset() const;
+
+ /**
+ * Returns the content transfer encoding of the content
+ * (e.g. quoted-printable).
+ * If no encoding is denoted, it will returns an empty string.
+ * @return content transfer encoding
+ */
+ QString getTransferEncoding() const;
+
+};
+
+#endif
diff --git a/kshowmail/templates/cpp_template b/kshowmail/templates/cpp_template
new file mode 100644
index 0000000..6afef5d
--- /dev/null
+++ b/kshowmail/templates/cpp_template
@@ -0,0 +1,16 @@
+/***************************************************************************
+ |FILENAME| - description
+ -------------------
+ begin : |DATE|
+ copyright : (C) |YEAR| by |AUTHOR|
+ email : |EMAIL|
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
diff --git a/kshowmail/templates/header_template b/kshowmail/templates/header_template
new file mode 100644
index 0000000..6afef5d
--- /dev/null
+++ b/kshowmail/templates/header_template
@@ -0,0 +1,16 @@
+/***************************************************************************
+ |FILENAME| - description
+ -------------------
+ begin : |DATE|
+ copyright : (C) |YEAR| by |AUTHOR|
+ email : |EMAIL|
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
diff --git a/kshowmail/types.h b/kshowmail/types.h
new file mode 100644
index 0000000..defe2c2
--- /dev/null
+++ b/kshowmail/types.h
@@ -0,0 +1,122 @@
+//
+// C++ Interface: types
+//
+// Description:
+// All specail types for KShowMail
+//
+//
+// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef TYPES_H
+#define TYPES_H
+
+//Qt headers
+#include <qvaluelist.h>
+#include <qmap.h>
+#include <qstring.h>
+
+using namespace std;
+
+/**
+ * All special types for KShowMail.
+ */
+namespace Types
+{
+ /**
+ * State of the application during running time.
+ */
+ enum State_Type {idle, /**<it's doing nothing*/
+
+ deleting, /**<it's deleting a message on the server*/
+
+ configure, /**<the user is configuring the application or
+ * the mail or just the header of the mail is
+ * being shown*/
+
+ executing, /**<a command on the command list is being executed*/
+
+ showing, /**<it's downloading and showing a mail*/
+
+ refreshing /**<it's refreshing the mail lists*/
+ };
+
+ /**
+ * State of an account.
+ */
+ enum AccountState_Type
+ {
+ AccountIdle, /**<it's doing nothing*/
+
+ AccountDeleting, /**<a deletion is running*/
+
+ AccountDownloading, /**<the account is downloading mail bodies*/
+
+ AccountRefreshing /**<the account is refreshing its mail list*/
+ };
+
+ /**
+ * List of mail numbers. It is a QValueList of integers.
+ */
+ typedef QValueList<int> MailNumberList_Type;
+
+ /**
+ * Map to notice which accounts need to get an order to do a task.
+ * The Key is the account name and the data a boolean.
+ * TRUE means the task was ordered, FALSE the task was ended.
+ */
+ typedef QMap<QString, bool> AccountTaskMap_Type;
+
+ /**
+ * Actions returned by filters.
+ */
+ enum FilterAction_Type
+ {
+ FActPass, /**<Mail has passed the filter check. It can showed in the list.*/
+ FActDelete, /**<Undesirable mail. Delete it.*/
+ FActMark, /**<Probably undesirable mail. Mark it in the mail list.*/
+ FActMove, /**<Move the mail to a certain mail box. The name of the box will returned by a further parameter.*/
+ FActSpamcheck, /**<This mail shall be forwared to a spam filter, which checks the whole mail including body.*/
+ FActIgnore, /**<This mail shall not be shown.*/
+ FActNone /**<The mail doesn't match up with the filter. Perform the next one.*/
+ };
+
+ /**
+ * This struct is for use in MailToDownloadMap_Type and holds some parameters about the mail for
+ * downloading.
+ */
+ struct DownloadActionParams_Type
+ {
+ FilterAction_Type action; /**<the filter action*/
+ QString mailbox; /**<name of the mailbox if action is MOVE*/
+ };
+
+ /**
+ * This map is used by ConfigElem and ShowRecord to hold a list of mail numbers which shall be downloaded for
+ * some filter actions; at time for moving and spam check
+ */
+ typedef QMap<int, DownloadActionParams_Type> MailToDownloadMap_Type;
+
+ /**
+ * Contains all values of a filter criteria.
+ */
+ struct FilterCriteria_Type
+ {
+ int source; /**<Object of comparison; see constants.h for valid values. (CONFIG_VALUE_FILTER_CRITERIA_SOURCE...)*/
+ int condition; /**<Condition of the comparison. see constants.h for valid values. (CONFIG_VALUE_FILTER_CRITERIA_COND...)*/
+ uint numValue; /**<Value of a numeric criteria, e.g. Size*/
+ QString txtValue; /**<Value of a text criteria, e.g. Subject*/
+ bool cs; /**<TRUE - Comparison is case sensitive. Just used for numeric criteria.*/
+ };
+
+ /**
+ * List of filter criterias.
+ */
+ typedef list<FilterCriteria_Type> FilterCriteriaList_Type;
+
+}
+
+#endif
diff --git a/kshowmail/uniqueapp.cpp b/kshowmail/uniqueapp.cpp
new file mode 100644
index 0000000..822c877
--- /dev/null
+++ b/kshowmail/uniqueapp.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ uniqueapp.cpp - description
+ -------------------
+ begin : Mon Nov 19 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "uniqueapp.h"
+#include <iostream>
+
+
+UniqueApp::UniqueApp()
+{
+ m_pApp = NULL;
+}
+
+UniqueApp::~UniqueApp()
+{}
+
+int UniqueApp::newInstance ()
+{
+ //start our application
+ //---------------------
+
+ //at the first invoke of newInstance() create a new instance of kshowmail
+ if (m_pApp == NULL)
+ {
+ m_pApp = new KShowMailApp ();
+ }
+//TODO: write english comments
+
+ //frage das ConfigList-Objekt, ob die KShowMail beim Starten
+ //normal oder nur in der Taskleiste gezeigt werden soll
+ if( m_pApp->m_ConfigList.startMinimized() )
+ {
+ //lege die App auf die Taskleiste
+ m_pApp->showMinimized ();
+ m_pApp->hide();
+ }
+ else
+ {
+ //zeige das Hauptfenster
+ m_pApp->showNormal ();
+ m_pApp->raise();
+ }
+
+ //Kommandozeile-Argumente auswerten
+ //---------------------------------
+
+ //die in main() eingelesenen Kommandozeile-Argumente in ein
+ //KCmdLineArgs-Objekt ablegen
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ //wenn als Kommandozeilen-Argument "config" übergeben wurde,
+ //starte jetzt den Konfigurationsdialog
+ if ( args->isSet( CMDLINE_CONFIG ) )
+ m_pApp->slotSetup();
+
+ //wenn als Kommandozeile-Argument "refresh" übergeben wurde,
+ //schaue sofort nach neue Mails
+ if ( args->isSet ( CMDLINE_REFRESH ) )
+ m_pApp->slotRefresh();
+
+ //lösche alle Kommandozeilen-Argumente im Objekt
+ args->clear ();
+
+ return 0;
+}
diff --git a/kshowmail/uniqueapp.h b/kshowmail/uniqueapp.h
new file mode 100644
index 0000000..4c19dab
--- /dev/null
+++ b/kshowmail/uniqueapp.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ uniqueapp.h - description
+ -------------------
+ begin : Mon Nov 19 2001
+ copyright : (C) 2001 by Eggert Ehmke
+ email : eggert.ehmke@berlin.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef UNIQUEAPP_H
+#define UNIQUEAPP_H
+
+//KDE-Header
+#include <kwin.h>
+#include <kcmdlineargs.h>
+#include <kuniqueapplication.h>
+
+//KShowMail-Header
+#include "kshowmail.h"
+#include "constants.h"
+
+using namespace Constants;
+
+/**
+ * @short Creates a unique instance of kshowmail
+ * @author Eggert Ehmke
+ */
+
+class UniqueApp : public KUniqueApplication {
+
+public:
+
+ /**
+ * Constructor
+ */
+ UniqueApp();
+
+ /**
+ * Destructor
+ */
+ ~UniqueApp();
+
+ /**
+ * overloaded method of KUniqueApplication. Creates a new instance of kshowmail.
+ */
+ virtual int newInstance ();
+
+
+private:
+
+ /**
+ * the kshowmail instance
+ */
+ KShowMailApp* m_pApp;
+};
+
+#endif