Commit b0f97c23 authored by Tom Albers's avatar Tom Albers

Keep lines <= 80, krazy issues and move to debug area.

svn path=/trunk/KDE/kdepimlibs/; revision=656826
parent 06f0bf9b
......@@ -30,7 +30,8 @@ namespace MailTransport {
class ConfigModule : public KCModule
{
public:
ConfigModule( QWidget *parent = 0, const QStringList &args = QStringList() );
explicit ConfigModule( QWidget *parent = 0,
const QStringList &args = QStringList() );
};
}
......
......@@ -36,7 +36,8 @@ PrecommandJob::PrecommandJob(const QString & precommand, QObject * parent) :
mProcess = new K3Process( this );
mProcess->setUseShell( true );
*mProcess << precommand;
connect( mProcess, SIGNAL(processExited(K3Process*)), SLOT(processExited(K3Process*)) );
connect( mProcess, SIGNAL(processExited(K3Process*)),
SLOT(processExited(K3Process*)) );
}
PrecommandJob::~ PrecommandJob()
......@@ -70,12 +71,14 @@ void PrecommandJob::processExited(K3Process *process)
if ( mProcess->normalExit() ) {
if ( mProcess->exitStatus() ) {
setError( UserDefinedError );
setErrorText( i18n("The precommand exited with code %1.", mProcess->exitStatus()) );
setErrorText( i18n("The precommand exited with code %1.",
mProcess->exitStatus()) );
}
}
if ( mProcess->signalled() ) {
setError( UserDefinedError );
setErrorText( i18n("The precommand was terminated by signal %1", mProcess->exitSignal() ) );
setErrorText( i18n("The precommand was terminated by signal %1",
mProcess->exitSignal() ) );
}
emitResult();
}
......
......@@ -69,7 +69,8 @@ SmtpJob::~SmtpJob()
{
slavePoolRef--;
if ( slavePoolRef == 0 ) {
kDebug() << k_funcinfo << "clearing SMTP slave pool " << slavePool.count() << endl;
kDebug(5324) << k_funcinfo << "clearing SMTP slave pool "
<< slavePool.count() << endl;
foreach ( KIO::Slave *slave, slavePool.values() )
KIO::Scheduler::disconnectSlave( slave );
slavePool.clear();
......@@ -78,7 +79,8 @@ SmtpJob::~SmtpJob()
void SmtpJob::doStart()
{
if ( slavePool.contains( transport()->id() ) || transport()->precommand().isEmpty() ) {
if ( slavePool.contains( transport()->id() ) ||
transport()->precommand().isEmpty() ) {
state = Smtp;
startSmtpJob();
} else {
......@@ -107,7 +109,8 @@ void SmtpJob::startSmtpJob()
destination.addQueryItem( QLatin1String("bcc"), str );
if ( transport()->specifyHostname() )
destination.addQueryItem( QLatin1String("hostname"), transport()->localHostname() );
destination.addQueryItem( QLatin1String("hostname"),
transport()->localHostname() );
#ifdef __GNUC__
#warning Argh!
......@@ -117,7 +120,8 @@ void SmtpJob::startSmtpJob()
if ( transport()->requiresAuthentication() ) {
if( (transport()->userName().isEmpty() || transport()->password().isEmpty())
&& transport()->authenticationType() != Transport::EnumAuthenticationType::GSSAPI )
&& transport()->authenticationType() !=
Transport::EnumAuthenticationType::GSSAPI )
{
QString user = transport()->userName();
QString passwd = transport()->password();
......@@ -130,7 +134,8 @@ void SmtpJob::startSmtpJob()
// KCursorSaver idle( KBusyPtr::idle() );
result = KIO::PasswordDialog::getNameAndPassword(
user, passwd, &keep,
i18n("You need to supply a username and a password to use this SMTP server."),
i18n("You need to supply a username and a password to use this "
"SMTP server."),
false, QString(), transport()->name(), QString() );
if ( result != QDialog::Accepted ) {
......@@ -151,22 +156,25 @@ void SmtpJob::startSmtpJob()
if ( !data().isEmpty() )
// allow +5% for subsequent LF->CRLF and dotstuffing (an average
// over 2G-lines gives an average line length of 42-43):
destination.addQueryItem( QLatin1String("size"), QString::number( qRound( data().length() * 1.05 ) ) );
destination.addQueryItem( QLatin1String("size"),
QString::number( qRound( data().length() * 1.05 ) ) );
destination.setPath( QLatin1String("/send") );
mSlave = slavePool.value( transport()->id() );
if ( !mSlave ) {
kDebug() << k_funcinfo << "creating new SMTP slave" << endl;
kDebug(5324) << k_funcinfo << "creating new SMTP slave" << endl;
KIO::MetaData slaveConfig;
slaveConfig.insert( QLatin1String("tls"), (transport()->encryption() == Transport::EnumEncryption::TLS)
slaveConfig.insert( QLatin1String("tls"),
(transport()->encryption() == Transport::EnumEncryption::TLS)
? QLatin1String("on") : QLatin1String("off") );
if ( transport()->requiresAuthentication() )
slaveConfig.insert( QLatin1String("sasl"), transport()->authenticationTypeString() );
slaveConfig.insert( QLatin1String("sasl"),
transport()->authenticationTypeString() );
mSlave = KIO::Scheduler::getConnectedSlave( destination, slaveConfig );
slavePool.insert( transport()->id(), mSlave );
} else {
kDebug() << k_funcinfo << "re-using existing slave" << endl;
kDebug(5324) << k_funcinfo << "re-using existing slave" << endl;
}
KIO::TransferJob *job = KIO::put( destination, -1, false, false, false );
......@@ -178,7 +186,8 @@ void SmtpJob::startSmtpJob()
}
job->addMetaData( QLatin1String("lf2crlf+dotstuff"), QLatin1String("slave") );
connect( job, SIGNAL(dataReq(KIO::Job*,QByteArray&)), SLOT(dataRequest(KIO::Job*,QByteArray&)) );
connect( job, SIGNAL(dataReq(KIO::Job*,QByteArray&)),
SLOT(dataRequest(KIO::Job*,QByteArray&)) );
addSubjob( job );
KIO::Scheduler::assignJobToSlave( mSlave, job );
......@@ -227,7 +236,8 @@ void SmtpJob::dataRequest(KIO::Job * job, QByteArray & data)
setProcessedAmount( KJob::Bytes, buffer()->pos() );
}
void SmtpJob::slaveError(KIO::Slave * slave, int errorCode, const QString & errorMsg)
void SmtpJob::slaveError(KIO::Slave * slave, int errorCode,
const QString & errorMsg)
{
removeSlaveFromPool( slave, errorCode != KIO::ERR_SLAVE_DIED );
if ( mSlave == slave ) {
......
......@@ -40,7 +40,7 @@ Transport::Transport( const QString &cfgGroup ) :
mNeedsWalletMigration( false ),
mIsAdHoc( false )
{
kDebug() << k_funcinfo << cfgGroup << endl;
kDebug(5324) << k_funcinfo << cfgGroup << endl;
readConfig();
}
......@@ -51,7 +51,8 @@ bool Transport::isValid() const
QString Transport::password()
{
if ( !mPasswordLoaded && requiresAuthentication() && storePassword() && mPassword.isEmpty() )
if ( !mPasswordLoaded && requiresAuthentication() && storePassword() &&
mPassword.isEmpty() )
TransportManager::self()->loadPasswords();
return mPassword;
}
......@@ -159,17 +160,20 @@ void Transport::readPassword()
// check wether there is a chance to find our password at all
if ( Wallet::folderDoesNotExist(Wallet::NetworkWallet(), WALLET_FOLDER) ||
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), WALLET_FOLDER, QString::number(id())) )
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), WALLET_FOLDER,
QString::number(id())) )
{
// try migrating password from kmail
if ( Wallet::folderDoesNotExist(Wallet::NetworkWallet(), KMAIL_WALLET_FOLDER ) ||
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), KMAIL_WALLET_FOLDER, QString::fromLatin1("transport-%1").arg( id() ) ) )
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), KMAIL_WALLET_FOLDER,
QString::fromLatin1("transport-%1").arg( id() ) ) )
return;
kDebug() << k_funcinfo << "migrating password from kmail wallet" << endl;
kDebug(5324) << k_funcinfo << "migrating password from kmail wallet" << endl;
KWallet::Wallet *wallet = TransportManager::self()->wallet();
if ( wallet ) {
wallet->setFolder( KMAIL_WALLET_FOLDER );
wallet->readPassword( QString::fromLatin1("transport-%1").arg( id() ), mPassword );
wallet->readPassword( QString::fromLatin1("transport-%1").arg( id() ),
mPassword );
wallet->removeEntry( QString::fromLatin1("transport-%1").arg( id() ) );
wallet->setFolder( WALLET_FOLDER );
mPasswordDirty = true;
......@@ -191,7 +195,7 @@ bool Transport::needsWalletMigration() const
void Transport::migrateToWallet()
{
kDebug() << k_funcinfo << "migrating " << id() << " to wallet" << endl;
kDebug(5324) << k_funcinfo << "migrating " << id() << " to wallet" << endl;
mNeedsWalletMigration = false;
KConfigGroup group( config(), currentGroup() );
group.deleteEntry( "password" );
......
......@@ -31,7 +31,8 @@ TransportComboBox::TransportComboBox(QWidget * parent) :
KComboBox( parent )
{
fillComboBox();
connect( TransportManager::self(), SIGNAL(transportsChanged()), SLOT(fillComboBox()) );
connect( TransportManager::self(), SIGNAL(transportsChanged()),
SLOT(fillComboBox()) );
}
int TransportComboBox::currentTransportId() const
......
......@@ -86,7 +86,8 @@ class MailTransport::TransportConfigDialog::Private
}
};
TransportConfigDialog::TransportConfigDialog( Transport* transport, QWidget * parent) :
TransportConfigDialog::TransportConfigDialog( Transport* transport,
QWidget * parent) :
KDialog( parent ),
d( new Private )
{
......@@ -101,7 +102,8 @@ TransportConfigDialog::TransportConfigDialog( Transport* transport, QWidget * pa
setButtons( Ok|Cancel );
connect( this, SIGNAL(okClicked()), SLOT(save()) );
connect( TransportManager::self(), SIGNAL(passwordsChanged()), SLOT(passwordsLoaded()) );
connect( TransportManager::self(), SIGNAL(passwordsChanged()),
SLOT(passwordsLoaded()) );
switch ( transport->type() ) {
case Transport::EnumType::SMTP:
......@@ -127,17 +129,22 @@ TransportConfigDialog::TransportConfigDialog( Transport* transport, QWidget * pa
d->smtp.gssapi->hide();
}
connect( d->smtp.checkCapabilities, SIGNAL(clicked()), SLOT(checkSmtpCapabilities()) );
connect( d->smtp.kcfg_host, SIGNAL(textChanged(QString)), SLOT(hostNameChanged(QString)) );
connect( d->smtp.kcfg_encryption, SIGNAL(clicked(int)), SLOT(encryptionChanged(int)) );
connect( d->smtp.checkCapabilities, SIGNAL(clicked()),
SLOT(checkSmtpCapabilities()) );
connect( d->smtp.kcfg_host, SIGNAL(textChanged(QString)),
SLOT(hostNameChanged(QString)) );
connect( d->smtp.kcfg_encryption, SIGNAL(clicked(int)),
SLOT(encryptionChanged(int)) );
break;
}
case Transport::EnumType::Sendmail:
{
d->sendmail.setupUi( mainWidget() );
connect( d->sendmail.chooseButton, SIGNAL(clicked()), SLOT(chooseSendmail()) );
connect( d->sendmail.kcfg_host, SIGNAL(textChanged(QString)), SLOT(hostNameChanged(QString)) );
connect( d->sendmail.chooseButton, SIGNAL(clicked()),
SLOT(chooseSendmail()) );
connect( d->sendmail.kcfg_host, SIGNAL(textChanged(QString)),
SLOT(hostNameChanged(QString)) );
}
}
......@@ -165,7 +172,8 @@ void TransportConfigDialog::checkSmtpCapabilities()
Q_ASSERT( d->transport->type() == Transport::EnumType::SMTP );
delete d->serverTest;
d->serverTest = new KPIM::ServerTest( SMTP_PROTOCOL, d->smtp.kcfg_host->text(), d->smtp.kcfg_port->value() );
d->serverTest = new KPIM::ServerTest( SMTP_PROTOCOL, d->smtp.kcfg_host->text(),
d->smtp.kcfg_port->value() );
connect( d->serverTest,
SIGNAL( capabilities(QStringList,QStringList,QString,QString,QString)),
SLOT( smtpCapabilities(QStringList,QStringList,QString,QString,QString)) );
......@@ -186,8 +194,8 @@ void TransportConfigDialog::save()
int suffix = 1;
QString origName = d->transport->name();
while ( existingNames.contains( d->transport->name() ) ) {
d->transport->setName( i18nc("%1: name; %2: number appended to it to make it unique among a list of names", "%1 %2",
origName, suffix ) );
d->transport->setName( i18nc("%1: name; %2: number appended to it to make "
"it unique among a list of names", "%1 %2", origName, suffix ) );
++suffix;
}
......@@ -251,7 +259,8 @@ static QList<int> authMethodsFromStringList( const QStringList &list )
static QList<int> authMethodsFromString( const QString &s )
{
QStringList list;
foreach ( QString tmp, s.toUpper().split( QLatin1Char('\n'), QString::SkipEmptyParts ) )
foreach ( QString tmp, s.toUpper().split( QLatin1Char('\n'),
QString::SkipEmptyParts ) )
list << tmp.remove( QLatin1String("SASL/") );
return authMethodsFromStringList( list );
}
......@@ -269,8 +278,11 @@ static void checkHighestEnabledButton( QButtonGroup *group )
}
}
void TransportConfigDialog::smtpCapabilities( const QStringList &capaNormal, const QStringList &capaSSL,
const QString &authNone, const QString &authSSL, const QString &authTLS )
void TransportConfigDialog::smtpCapabilities( const QStringList &capaNormal,
const QStringList &capaSSL,
const QString &authNone,
const QString &authSSL,
const QString &authTLS )
{
d->smtp.checkCapabilities->setEnabled( true );
......@@ -282,7 +294,8 @@ void TransportConfigDialog::smtpCapabilities( const QStringList &capaNormal, con
// authentication methods
if ( authNone.isEmpty() && authSSL.isEmpty() && authTLS.isEmpty() ) {
// slave doesn't seem to support "* AUTH METHODS" metadata (or server can't do AUTH)
// slave doesn't seem to support "* AUTH METHODS" metadata
// (or server can't do AUTH)
d->noEncCapa = authMethodsFromStringList( capaNormal );
if ( d->smtp.tls->isEnabled() )
d->tlsCapa = d->noEncCapa;
......@@ -305,14 +318,15 @@ void TransportConfigDialog::hostNameChanged( const QString &text )
{
d->resetAuthCapabilities();
enableButton( Ok, !text.isEmpty() );
for ( int i = 0; d->encryptionGroup && i < d->encryptionGroup->buttons().count(); i++ )
for ( int i = 0;
d->encryptionGroup && i < d->encryptionGroup->buttons().count(); i++ )
d->encryptionGroup->buttons().at( i )->setEnabled( true );
}
void TransportConfigDialog::encryptionChanged(int enc)
{
Q_ASSERT( d->transport->type() == Transport::EnumType::SMTP );
kDebug() << k_funcinfo << enc << endl;
kDebug(5324) << k_funcinfo << enc << endl;
// adjust port
if ( enc == Transport::EnumEncryption::SSL ) {
......
......@@ -17,8 +17,8 @@
02110-1301, USA.
*/
#include "transport.h"
#include "transportjob.h"
#include "transport.h"
#include <klocale.h>
......@@ -121,7 +121,8 @@ void TransportJob::start()
{
if ( !transport()->isValid() ) {
setError( UserDefinedError );
setErrorText( i18n("The mail transport \"%1\" is not correcty configured.", transport()->name() ) );
setErrorText( i18n("The mail transport \"%1\" is not correcty configured.",
transport()->name() ) );
emitResult();
return;
}
......
......@@ -40,9 +40,10 @@ TransportManagementWidget::TransportManagementWidget(QWidget * parent) :
{
d->ui.setupUi( this );
d->ui.transportList->setHeaderLabels( QStringList() << i18n("Name") << i18n("Type") );
connect( d->ui.transportList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
SLOT(updateButtonState()) );
d->ui.transportList->setHeaderLabels(
QStringList() << i18n("Name") << i18n("Type") );
connect( d->ui.transportList, SIGNAL(currentItemChanged(QTreeWidgetItem*,
QTreeWidgetItem*)), SLOT(updateButtonState()) );
connect( d->ui.transportList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
SLOT(editClicked()) );
connect( d->ui.addButton, SIGNAL(clicked()), SLOT(addClicked()) );
......@@ -51,7 +52,8 @@ TransportManagementWidget::TransportManagementWidget(QWidget * parent) :
connect( d->ui.defaultButton, SIGNAL(clicked()), SLOT(defaultClicked()) );
fillTransportList();
connect( TransportManager::self(), SIGNAL(transportsChanged()), SLOT(fillTransportList()) );
connect( TransportManager::self(), SIGNAL(transportsChanged()),
SLOT(fillTransportList()) );
}
TransportManagementWidget::~TransportManagementWidget()
......@@ -149,14 +151,16 @@ void TransportManagementWidget::removeClicked()
{
Q_ASSERT( d->ui.transportList->currentItem() );
TransportManager::self()->removeTransport( d->ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
TransportManager::self()->removeTransport(
d->ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
}
void TransportManagementWidget::defaultClicked()
{
Q_ASSERT( d->ui.transportList->currentItem() );
TransportManager::self()->setDefaultTransport( d->ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
TransportManager::self()->setDefaultTransport(
d->ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
}
#include "transportmanagementwidget.moc"
......@@ -17,9 +17,9 @@
02110-1301, USA.
*/
#include "transportmanager.h"
#include "mailtransport_defs.h"
#include "transport.h"
#include "transportmanager.h"
#include "smtpjob.h"
#include "sendmailjob.h"
......@@ -57,13 +57,17 @@ TransportManager::TransportManager() :
mConfig = new KConfig( QLatin1String("mailtransports") );
QDBusConnection::sessionBus().registerObject( DBUS_OBJECT_PATH, this,
QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableSignals );
QDBusConnection::ExportScriptableSlots |
QDBusConnection::ExportScriptableSignals );
QDBusConnection::sessionBus().connect( QString(), QString(), DBUS_INTERFACE_NAME, DBUS_CHANGE_SIGNAL,
this, SLOT(slotTransportsChanged()) );
QDBusConnection::sessionBus().connect( QString(), QString(),
DBUS_INTERFACE_NAME, DBUS_CHANGE_SIGNAL,
this, SLOT(slotTransportsChanged()) );
mIsMainInstance = QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
mIsMainInstance =
QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
connect( QDBusConnection::sessionBus().interface(),
SIGNAL(serviceOwnerChanged(QString,QString,QString)),
SLOT(dbusServiceOwnerChanged(QString,QString,QString)) );
}
......@@ -130,7 +134,7 @@ void TransportManager::schedule(TransportJob * job)
// check if the job is waiting for the wallet
if ( !job->transport()->isComplete() ) {
kDebug() << k_funcinfo << "job waits for wallet: " << job << endl;
kDebug(5324) << k_funcinfo << " job waits for wallet: " << job << endl;
mWalletQueue << job;
loadPasswordsAsync();
return;
......@@ -149,7 +153,8 @@ void TransportManager::createDefaultTransport()
t->writeConfig();
addTransport( t );
} else
kWarning() << k_funcinfo << "KEMailSettings does not contain a vaild transport setting." << endl;
kWarning() << k_funcinfo
<< "KEMailSettings does not contain a valid transport." << endl;
}
TransportJob* TransportManager::createTransportJob( int transportId )
......@@ -297,7 +302,8 @@ void TransportManager::readConfig()
// see if we happen to have that one already
foreach ( Transport *old, oldTransports ) {
if ( old->currentGroup() == QLatin1String("Transport ") + re.cap( 1 ) ) {
kDebug() << k_funcinfo << "reloading existing transport: " << s << endl;
kDebug(5324) << k_funcinfo
<< " reloading existing transport: " << s << endl;
t = old;
t->readConfig();
oldTransports.removeAll( old );
......@@ -357,7 +363,7 @@ void TransportManager::slotTransportsChanged()
return;
}
kDebug() << k_funcinfo << endl;
kDebug(5324) << k_funcinfo << endl;
mConfig->reparseConfiguration();
// FIXME: this deletes existing transport objects!
readConfig();
......@@ -428,7 +434,7 @@ void TransportManager::loadPasswords()
void TransportManager::loadPasswordsAsync()
{
kDebug() << k_funcinfo << endl;
kDebug(5324) << k_funcinfo << endl;
// check if there is anything to do at all
bool found = false;
......@@ -448,7 +454,8 @@ void TransportManager::loadPasswordsAsync()
window = qApp->activeWindow()->winId();
else if ( qApp->mainWidget() )
window = qApp->mainWidget()->topLevelWidget()->winId();
mWallet = Wallet::openWallet( Wallet::NetworkWallet(), window, Wallet::Asynchronous );
mWallet = Wallet::openWallet( Wallet::NetworkWallet(), window,
Wallet::Asynchronous );
if ( mWallet ) {
connect( mWallet, SIGNAL(walletOpened(bool)), SLOT(slotWalletOpened(bool)) );
mWalletAsyncOpen = true;
......@@ -465,7 +472,7 @@ void TransportManager::loadPasswordsAsync()
void TransportManager::slotWalletOpened( bool success )
{
kDebug() << k_funcinfo << endl;
kDebug(5324) << k_funcinfo << endl;
mWalletAsyncOpen = false;
if ( !success ) {
mWalletOpenFailed = true;
......@@ -511,8 +518,9 @@ void TransportManager::migrateToWallet()
// ask user if he wants to migrate
int result = KMessageBox::questionYesNoList( 0,
i18n("The following mail transports store passwords in the configuration file instead in KWallet.\n"
"It is recommended to use KWallet for password storage for security reasons.\n"
i18n("The following mail transports store passwords in the configuration "
"file instead in KWallet.\nIt is recommended to use KWallet for "
"password storage for security reasons.\n"
"Do you want to migrate your passwords to KWallet?"),
names );
if ( result != KMessageBox::Yes )
......
......@@ -220,7 +220,9 @@ class MAILTRANSPORT_EXPORT TransportManager : public QObject
private slots:
void slotTransportsChanged();
void slotWalletOpened( bool success );
void dbusServiceOwnerChanged( const QString &service, const QString &oldOwner, const QString &newOwner );
void dbusServiceOwnerChanged( const QString &service,
const QString &oldOwner,
const QString &newOwner );
void jobResult( KJob* job );
private:
......
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