Commit 38f21c4d authored by Volker Krause's avatar Volker Krause

We have at least four diffrent applications in kdepim which send mails

in one way or another (KMail, KNode, KOrganizer, KAlarm), so let's try
to unify this a bit by sharing code and settings :)

So far we have:
- shared settings (synchronized via D-Bus), including password caching
  and async wallet handling (which are currently missing in KMail)
- config widgets
- basic migration of KDE3 kmail transport settings (hard to test given
  that KWallet stores data rather non-persistent here...)
- D-Bus interface
- a lot less handwritten code than currently in KMail thanks to
  KConfigXt and Qt Designer

Still todo:
- complete config migration
- mail sending job class
- port applications

svn path=/trunk/KDE/kdepim/mailtransport/; revision=614956
parents
add_subdirectory( kconf_update )
add_subdirectory( tests )
set(mailtransport_lib_srcs
transport.cpp
transportcombobox.cpp
transportconfigdialog.cpp
transportmanager.cpp
transportmanagementwidget.cpp
transporttypedialog.cpp
)
kde4_automoc(${mailtransport_lib_srcs})
kde4_add_ui_files(mailtransport_lib_srcs
smtpsettings.ui
sendmailsettings.ui
transportmanagementwidget.ui
transporttypedialog.ui
)
kde4_add_kcfg_files(mailtransport_lib_srcs transportbase.kcfgc)
kde4_add_library(mailtransport SHARED ${mailtransport_lib_srcs})
target_link_libraries(mailtransport ${KDE4_KIO_LIBS} kwalletclient kdepim)
set_target_properties(mailtransport PROPERTIES VERSION 1.0.0 SOVERSION 1)
install(TARGETS mailtransport DESTINATION ${LIB_INSTALL_DIR})
install(FILES mailtransport.kcfg DESTINATION ${KCFG_INSTALL_DIR})
/**
@mainpage Mail Transport Service
@section Overview
The mailtransport module provides the following functionality:
- Shared mail transport settings
- GUI elements to configure mail transport settings (implementation incomplete)
- Job classes for mail sending (not yet implemented)
The mailtransport module consists of the following components:
- a shared library containing the above listed functionality
- a KCModule which can be embedded into your application to provide mail transport configuration (not yet implemented)
- a KDED module which provides a D-Bus interface to mail transport settings and mail sending (not yet implemented)
*/
// DOXYGEN_REFERENCES = kdecore kdeui
Mail Transport TODO
~~~~~~~~~~~~~~~~~~~
General
-------
- use own namespace?
- message sending job classes
Migration
---------
- migration from kmail and knode config files
- password migration within kwallet (for kmail and knode), requires KWallet to
be fixed first
- convert enum valus (eg '-' is not supported by kcfg)
- reading passwords from config file still using legacy encryption
TransportManager
----------------
- deletetion of Transport objects during reload is a problem
(create a copy for edit?)
- load passwords if another instance opens the wallet
TransportComboBox
-----------------
- select item by transport id
- handle ad-hoc transports (see identity dialog)
- keep selection on update if possible
TransportConfigDialog
---------------------
- enforce unique name
- SMTP auth method discovery (kio_smtp needs to fixed first)
- Sanity checks as in kmtransport
Transport
---------
- fallback to config file password storage
#install(FILES mailtransports.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR})
install(PROGRAMS migrate-transports.pl DESTINATION ${KCONF_UPDATE_INSTALL_DIR})
# Migrate kmail's transport settings
Id=initial-kmail-migration
File=kmailrc,mailtransports
ScriptArguments=kmail
Script=migrate-transports.pl,perl
#!/usr/bin/perl
#
# Copyright (c) 2006 Volker Krause <vkrause@kde.org>
# based on kmail-3.3-move-identities.pl by David Faure <faure@kde.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
#
$currentGroup = "";
while (<STDIN>) {
next if /^$/;
# recognize groups:
if ( /^\[(.+)\]$/ ) {
$currentGroup = $1;
if ( $currentGroup =~ /^Transport/ ) {
print "# DELETEGROUP [$currentGroup]\n";
print "[$currentGroup]\n";
}
next;
};
# Move over keys from the transport groups
if ( $currentGroup =~ /^Transport/ ) {
print;
}
# Move over the key for the default transport
elsif ( $currentGroup eq 'Composer' ) {
($key,$value) = split /=/;
chomp $value;
if ( $key eq 'default-transport' ) {
print "[General]\n$key=$value\n";
#print "# DELETE [$currentGroup]$key\n";
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="mailtransports">
<parameter name="transportId" />
</kcfgfile>
<group name="Transport $(transportId)">
<entry name="id" type="Int">
<label>Unique identifier</label>
<default>0</default>
</entry>
<entry name="name" type="String">
<label>User visible transport name</label>
<whatsthis>The name that will be used when referring to this server.</whatsthis>
<default code="true">i18n("Unnamed")</default>
</entry>
<entry name="type" type="Enum">
<choices>
<choice name="SMTP">
<label>SMTP Server</label>
</choice>
<choice name="Sendmail">
<label>Local sendmail</label>
</choice>
</choices>
<label>Transport type</label>
<default>SMTP</default>
</entry>
<entry name="host" type="String">
<label>Host name of the server</label>
<whatsthis>The domain name or numerical address of the SMTP server.</whatsthis>
</entry>
<entry name="port" type="String">
<label>Port number of the server</label>
<whatsthis>The port number that the SMTP server is listening on. The default port is 25.</whatsthis>
<default>25</default>
</entry>
<entry name="userName" type="String" key="user">
<label>User name needed for login</label>
<whatsthis>The user name to send to the server for authorization.</whatsthis>
</entry>
<entry name="precommand" type="String">
<label>Command to execute before sending a mail</label>
<whatsthis>
A command to run locally, prior to sending email.
This can be used to set up SSH tunnels, for example.
Leave it empty if no command should be run.
</whatsthis>
</entry>
<entry name="requiresAuthentication" type="Bool" key="auth">
<label>Server requires authentication</label>
<whatsthis>
Check this option if your SMTP server requires authentication before accepting mail.
This is known as 'Authenticated SMTP' or simply ASMTP.
</whatsthis>
<default>false</default>
</entry>
<entry name="storePassword" type="Bool" key="storepass">
<label>Store password</label>
<whatsthis>
Check this option to have your password stored.
\nIf KWallet is available the password will be stored there which is considered safe.\n
However, if KWallet is not available, the password will be stored in the configuration file.
The password is stored in an obfuscated format, but should not be considered secure from decryption efforts if access to the configuration file is obtained.
</whatsthis>
<default>false</default>
</entry>
<entry name="encryption" type="Enum">
<label>Encryption method used for communication</label>
<choices>
<choice name="None">
<label>No encryption</label>
</choice>
<choice name="SSL">
<label>SSL encryption</label>
</choice>
<choice name="TLS">
<label>TLS encryption</label>
</choice>
</choices>
</entry>
<entry name="authenticationType" type="Enum" key="authtype">
<label>Authentification method</label>
<choices>
<!-- TODO - -> _ conversion? -->
<choice name="LOGIN"/>
<choice name="PLAIN"/>
<choice name="CRAM_MD5"/>
<choice name="DIGEST_MD5"/>
<choice name="NTLM"/>
<choice name="GSSAPI"/>
</choices>
</entry>
<entry name="specifyHostname" type="Bool">
<label><!-- TODO --></label>
<whatsthis>
Check this option to use a custom hostname when identifying to the mail server.
<p/>This is useful when your system's hostname may not be set correctly or to mask your system's true hostname.
</whatsthis>
<default>false</default>
</entry>
<entry name="localHostname" type="String">
<label><!-- TODO --></label>
<whatsthis>Enter the hostname that should be used when identifying to the server.</whatsthis>
</entry>
</group>
</kcfg>
/*
Copyright (c) 2006 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef KPIM_MAILTRANSPORT_DEFS_H
#define KPIM_MAILTRANSPORT_DEFS_H
/**
@file mailtransport_defs.h
Internal file containing constant definitions etc.
*/
#define WALLET_FOLDER "mailtransports"
#define DBUS_INTERFACE_NAME "org.kde.pim.TransportManager"
#define DBUS_OBJECT_PATH "/TransportManager"
#endif
/*
Copyright (c) 2006 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef KPIM_MAILTRANSPORT_EXPORT_H
#define KPIM_MAILTRANSPORT_EXPORT_H
#include <kdemacros.h>
#if defined(_WIN32) || defined(_WIN64)
#ifdef MAKE_MAILTRANSPORT_LIB
#define MAILTRANSPORT_EXPORT KDE_EXPORT
#else
#define MAILTRANSPORT_EXPORT KDE_IMPORT
#endif
#else
#define MAILTRANSPORT_EXPORT KDE_EXPORT
#endif
#endif
<ui version="4.0" >
<author>Volker Krause &lt;vkrause@kde.org></author>
<class>SendmailSettings</class>
<widget class="QWidget" name="SendmailSettings" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>159</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="4" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4" >
<widget class="KSeparator" name="kseparator" />
</item>
<item row="0" column="0" colspan="3" >
<widget class="QLabel" name="titleLabel" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Transport: Sendmail</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>&amp;Location:</string>
</property>
<property name="buddy" >
<cstring>kcfg_host</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="nameLabel" >
<property name="text" >
<string>&amp;Name:</string>
</property>
<property name="buddy" >
<cstring>kcfg_name</cstring>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="KPushButton" name="chooseButton" >
<property name="text" >
<string>Choos&amp;e...</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KLineEdit" name="kcfg_host" />
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="kcfg_name" />
</item>
</layout>
</widget>
<layoutfunction spacing="KDialog::spacingHint()" margin="KDialog::marginHint()" />
<customwidgets>
<customwidget>
<class>KSeparator</class>
<extends>QFrame</extends>
<header>kseparator.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<ui version="4.0" >
<author>Volker Krause &lt;vkrause@kde.org></author>
<class>SMTPSettings</class>
<widget class="QWidget" name="SMTPSettings" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>524</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="titleLabel" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Transport: SMTP</string>
</property>
</widget>
</item>
<item>
<widget class="KSeparator" name="kseparator" />
</item>
<item>
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="smptTab" >
<attribute name="title" >
<string>&amp;General</string>
</attribute>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="12" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="0" >
<widget class="QLabel" name="hostnameLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Hos&amp;tname:</string>
</property>
<property name="buddy" >
<cstring>kcfg_localHostname</cstring>
</property>
</widget>
</item>
<item row="11" column="1" >
<widget class="KLineEdit" name="kcfg_localHostname" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="nameLabel" >
<property name="text" >
<string>&amp;Name:</string>
</property>
<property name="buddy" >
<cstring>kcfg_name</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="hostLabel" >
<property name="text" >
<string>&amp;Host:</string>
</property>
<property name="buddy" >
<cstring>kcfg_host</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="kcfg_name" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="portLabel" >
<property name="text" >
<string>&amp;Port:</string>
</property>
<property name="buddy" >
<cstring>kcfg_port</cstring>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="precommandLabel" >
<property name="text" >
<string>Preco&amp;mmand:</string>
</property>
<property name="buddy" >
<cstring>kcfg_precommand</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="kcfg_host" />
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="kcfg_port" />
</item>
<item row="3" column="1" >
<widget class="KLineEdit" name="kcfg_precommand" />
</item>
<item row="6" column="1" >
<widget class="KLineEdit" name="kcfg_userName" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="usernameLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>&amp;Login:</string>
</property>
<property name="buddy" >
<cstring>kcfg_userName</cstring>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="passwordLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>P&amp;assword:</string>
</property>
<property name="buddy" >
<cstring>password</cstring>
</property>
</widget>
</item>
<item row="7" column="1" >
<widget class="KLineEdit" name="password" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>The password to send to the server for authorization.</string>
</property>
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2" >
<widget class="QCheckBox" name="kcfg_storePassword" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>&amp;Store SMTP password</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2" >
<widget class="KSeparator" name="kseparator_2" />
</item>
<item row="9" column="0" colspan="2" >
<widget class="KSeparator" name="kseparator_3" />
</item>
<item row="5" column="0" colspan="2" >
<widget class="QCheckBox" name="kcfg_requiresAuthentication" >
<property name="text" >
<string>Server &amp;requires authentication</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2" >
<widget class="QCheckBox" name="kcfg_specifyHostname" >
<property name="text" >
<string>Sen&amp;d custom hostname to server</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="securityTab" >
<attribute name="title" >
<string>S&amp;ecurity</string>
</attribute>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>