Commit 7188e7e1 authored by Laurent Montel's avatar Laurent Montel 😁

Fix coding style

parent f1313b97
/*
Copyright (c) 2013 Laurent Montel <montel@kde.org>
Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
Based on MailTransport code by:
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
Copyright (c) 2007 KovoKs <kovoks@kovoks.nl>
Based on KMail code by:
Copyright (c) 2001-2002 Michael Haeckel <haeckel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "sendmailconfigwidget.h"
#include "transportconfigwidget_p.h"
#include "ui_sendmailsettings.h"
#include <KStandardDirs>
#include <KLineEdit>
using namespace MailTransport;
class MailTransport::SendmailConfigWidgetPrivate : public TransportConfigWidgetPrivate
{
public:
::Ui::SendmailSettings ui;
};
SendmailConfigWidget::SendmailConfigWidget(Transport *transport, QWidget *parent)
: TransportConfigWidget(*new SendmailConfigWidgetPrivate, transport, parent)
{
init();
}
SendmailConfigWidget::SendmailConfigWidget(SendmailConfigWidgetPrivate &dd, Transport *transport, QWidget *parent)
: TransportConfigWidget(dd, transport, parent)
{
init();
}
void SendmailConfigWidget::init()
{
Q_D(SendmailConfigWidget);
d->ui.setupUi(this);
d->ui.kcfg_host->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
d->ui.kcfg_host->setFocus();
d->manager->addWidget(this); // otherwise it doesn't find out about these widgets
d->manager->updateWidgets();
if (d->ui.kcfg_host->url().isEmpty()) {
// Locate sendmail.
// This is imperfect, because it shows the standard path if an empty path
// is saved in the config.
d->ui.kcfg_host->setText(KStandardDirs::findExe(QLatin1String("sendmail")));
}
connect(d->ui.kcfg_host->lineEdit(), SIGNAL(textChanged(QString)),
SLOT(slotTextChanged(QString)));
slotTextChanged(d->ui.kcfg_host->text());
}
void SendmailConfigWidget::slotTextChanged(const QString &text)
{
Q_EMIT enableButtonOk(!text.isEmpty());
}
bool SendmailConfigWidget::pathIsEmpty() const
{
Q_D(const SendmailConfigWidget);
return d->ui.kcfg_host->text().isEmpty();
}
/*
Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
Based on MailTransport code by:
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
Based on KMail code by:
Copyright (c) 2001-2002 Michael Haeckel <haeckel@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 MAILTRANSPORT_SENDMAILCONFIGWIDGET_H
#define MAILTRANSPORT_SENDMAILCONFIGWIDGET_H
#include "transportconfigwidget.h"
namespace MailTransport {
class Transport;
/**
@internal
*/
class SendmailConfigWidgetPrivate;
/**
@internal
Configuration widget for a Sendmail transport.
*/
class SendmailConfigWidget : public TransportConfigWidget
{
Q_OBJECT
public:
explicit SendmailConfigWidget(Transport *transport, QWidget *parent = 0);
bool pathIsEmpty() const;
Q_SIGNALS:
void enableButtonOk(bool);
private Q_SLOTS:
void slotTextChanged(const QString &text);
protected:
SendmailConfigWidget(SendmailConfigWidgetPrivate &dd, Transport *transport, QWidget *parent);
private:
Q_DECLARE_PRIVATE(SendmailConfigWidget)
void init();
};
} // namespace MailTransport
#endif // MAILTRANSPORT_SENDMAILCONFIGWIDGET_H
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
Copyright (c) 2007 KovoKs <kovoks@kovoks.nl>
Based on KMail code by:
Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "sendmailjob.h"
#include "transport.h"
#include <KLocalizedString>
#include <QtCore/QProcess>
#include <QtCore/QBuffer>
using namespace MailTransport;
/**
* Private class that helps to provide binary compatibility between releases.
* @internal
*/
class SendMailJobPrivate
{
public:
QProcess *process;
QString lastError;
};
SendmailJob::SendmailJob(Transport *transport, QObject *parent)
: TransportJob(transport, parent)
, d(new SendMailJobPrivate)
{
d->process = new QProcess(this);
connect(d->process,
SIGNAL(finished(int,QProcess::ExitStatus)),
SLOT(sendmailExited(int,QProcess::ExitStatus)));
connect(d->process, SIGNAL(error(QProcess::ProcessError)),
SLOT(receivedError()));
connect(d->process, SIGNAL(readyReadStandardError()),
SLOT(receivedStdErr()));
}
SendmailJob::~SendmailJob()
{
delete d;
}
void SendmailJob::doStart()
{
QStringList arguments;
arguments << QLatin1String("-i") << QLatin1String("-f")
<< sender() << to() << cc() << bcc();
d->process->start(transport()->host(), arguments);
if (!d->process->waitForStarted()) {
setError(UserDefinedError);
setErrorText(i18n("Failed to execute mailer program %1", transport()->host()));
emitResult();
} else {
d->process->write(buffer()->readAll());
d->process->closeWriteChannel();
}
}
void SendmailJob::sendmailExited(int exitCode, QProcess::ExitStatus exitStatus)
{
if (exitStatus != 0 || exitCode != 0) {
setError(UserDefinedError);
if (d->lastError.isEmpty()) {
setErrorText(i18n("Sendmail exited abnormally."));
} else {
setErrorText(i18n("Sendmail exited abnormally: %1", d->lastError));
}
}
emitResult();
}
void SendmailJob::receivedError()
{
d->lastError += d->process->errorString();
}
void SendmailJob::receivedStdErr()
{
d->lastError += QLatin1String(d->process->readAllStandardError());
}
bool SendmailJob::doKill()
{
delete d->process;
d->process = 0;
return true;
}
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
Copyright (c) 2007 KovoKs <kovoks@kovoks.nl>
Based on KMail code by:
Copyright (c) 1996-1998 Stefan Taferner <taferner@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 MAILTRANSPORT_SENDMAILJOB_H
#define MAILTRANSPORT_SENDMAILJOB_H
#include <mailtransport/transportjob.h>
#include <QtCore/QProcess>
class SendMailJobPrivate;
namespace MailTransport {
/**
Mail transport job for sendmail.
@deprecated Use MessageQueueJob for sending e-mail.
*/
class MAILTRANSPORT_DEPRECATED_EXPORT SendmailJob : public TransportJob
{
Q_OBJECT
public:
/**
Creates a SendmailJob.
@param transport The transport settings.
@param parent The parent object.
*/
explicit SendmailJob(Transport *transport, QObject *parent = 0);
/**
Destroys this job.
*/
virtual ~SendmailJob();
protected:
virtual void doStart();
virtual bool doKill();
private Q_SLOTS:
void sendmailExited(int, QProcess::ExitStatus);
void receivedError();
void receivedStdErr();
private:
SendMailJobPrivate *const d;
};
} // namespace MailTransport
#endif // MAILTRANSPORT_SENDMAILJOB_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Volker Krause &lt;vkrause@kde.org&gt;</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>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Sendmail &amp;Location:</string>
</property>
<property name="buddy">
<cstring>kcfg_host</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KUrlRequester" name="kcfg_host">
<property name="kcfg_property" stdset="0">
<cstring>text</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -27,20 +27,18 @@ K_PLUGIN_FACTORY_WITH_JSON(SendMailTransportPluginFactory, "sendmailtransport.js
SendMailTransportPlugin::SendMailTransportPlugin(QObject *parent, const QList<QVariant> &)
: MailTransport::TransportAbstractPlugin(parent)
{
}
SendMailTransportPlugin::~SendMailTransportPlugin()
{
}
QVector<MailTransport::TransportAbstractPluginInfo> SendMailTransportPlugin::names() const
{
MailTransport::TransportAbstractPluginInfo info;
info.name = i18nc( "@option sendmail transport", "Sendmail" );
info.name = i18nc("@option sendmail transport", "Sendmail");
info.identifier = QStringLiteral("sendmail");
info.description = i18n( "A local sendmail installation" );
info.description = i18n("A local sendmail installation");
return QVector<MailTransport::TransportAbstractPluginInfo>() << info;
}
......@@ -57,5 +55,3 @@ void SendMailTransportPlugin::cleanUp(const QString &identifier)
}
#include "sendmailtransportplugin.moc"
......@@ -27,7 +27,9 @@ class SendMailTransportPlugin : public MailTransport::TransportAbstractPlugin
{
Q_OBJECT
public:
explicit SendMailTransportPlugin(QObject *parent = nullptr, const QList<QVariant> & = {});
explicit SendMailTransportPlugin(QObject *parent = nullptr, const QList<QVariant> & =
{
});
~SendMailTransportPlugin();
void cleanUp(const QString &identifier) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment