1/*
2 Copyright (c) 2013 Laurent Montel <montel@kde.org>
3 Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
4
5 Based on MailTransport code by:
6 Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
7 Copyright (c) 2007 KovoKs <kovoks@kovoks.nl>
8
9 Based on KMail code by:
10 Copyright (c) 2001-2002 Michael Haeckel <haeckel@kde.org>
11
12 This library is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Library General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or (at your
15 option) any later version.
16
17 This library is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 License for more details.
21
22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to the
24 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 02110-1301, USA.
26*/
27
28#include "sendmailconfigwidget.h"
29#include "transportconfigwidget_p.h"
30#include "ui_sendmailsettings.h"
31
32#include <KStandardDirs>
33#include <KLineEdit>
34
35using namespace MailTransport;
36
37class MailTransport::SendmailConfigWidgetPrivate : public TransportConfigWidgetPrivate
38{
39 public:
40 ::Ui::SendmailSettings ui;
41
42};
43
44SendmailConfigWidget::SendmailConfigWidget( Transport *transport, QWidget *parent )
45 : TransportConfigWidget( *new SendmailConfigWidgetPrivate, transport, parent )
46{
47 init();
48}
49
50SendmailConfigWidget::SendmailConfigWidget( SendmailConfigWidgetPrivate &dd,
51 Transport *transport, QWidget *parent )
52 : TransportConfigWidget( dd, transport, parent )
53{
54 init();
55}
56
57void SendmailConfigWidget::init()
58{
59 Q_D( SendmailConfigWidget );
60
61 d->ui.setupUi( this );
62 d->ui.kcfg_host->setMode( KFile::File|KFile::ExistingOnly|KFile::LocalOnly );
63 d->ui.kcfg_host->setFocus();
64 d->manager->addWidget( this ); // otherwise it doesn't find out about these widgets
65 d->manager->updateWidgets();
66
67 if ( d->ui.kcfg_host->url().isEmpty() ) {
68 // Locate sendmail.
69 // This is imperfect, because it shows the standard path if an empty path
70 // is saved in the config.
71 d->ui.kcfg_host->setText( KStandardDirs::findExe( QLatin1String( "sendmail" ) ) );
72 }
73 connect( d->ui.kcfg_host->lineEdit(), SIGNAL(textChanged(QString)),
74 SLOT(slotTextChanged(QString)) );
75 slotTextChanged( d->ui.kcfg_host->text() );
76}
77
78void SendmailConfigWidget::slotTextChanged( const QString &text )
79{
80 Q_EMIT enableButtonOk( !text.isEmpty() );
81}
82
83bool SendmailConfigWidget::pathIsEmpty() const
84{
85 Q_D( const SendmailConfigWidget );
86 return d->ui.kcfg_host->text().isEmpty();
87}
88