Commit 8b842dc0 authored by Volker Krause's avatar Volker Krause
Browse files

No implicit ascii casts, mostly harmless stuff but better be on the safe side.

svn path=/trunk/KDE/kdepim/mailtransport/; revision=620595
parent 5045e043
......@@ -2,6 +2,8 @@
add_subdirectory( kconf_update )
add_subdirectory( tests )
add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
set(mailtransport_lib_srcs
transport.cpp
transportcombobox.cpp
......
......@@ -4,7 +4,7 @@ Mail Transport TODO
General
-------
- use own namespace
- compile with QT_NO_ASCII_CAST and without QT3_SUPPORT
- compile without QT3_SUPPORT
- fix license/copyright, some of the code is taken from KMail/KNode
Migration
......
......@@ -40,7 +40,7 @@ QString Legacy::decryptKNode(const QString & data)
val = data[i].toLatin1();
val -= ' ';
val = (255-' ') - val;
result += (char)(val + ' ');
result += QLatin1Char( (char)(val + ' ') );
}
return result;
......
......@@ -25,14 +25,16 @@
Internal file containing constant definitions etc.
*/
#define WALLET_FOLDER "mailtransports"
#define WALLET_FOLDER QLatin1String("mailtransports")
#define KMAIL_WALLET_FOLDER QLatin1String("kmail")
#define DBUS_SERVICE_NAME "org.kde.pim.TransportManager"
#define DBUS_INTERFACE_NAME "org.kde.pim.TransportManager"
#define DBUS_OBJECT_PATH "/TransportManager"
#define DBUS_SERVICE_NAME QLatin1String("org.kde.pim.TransportManager")
#define DBUS_INTERFACE_NAME QLatin1String("org.kde.pim.TransportManager")
#define DBUS_OBJECT_PATH QLatin1String("/TransportManager")
#define DBUS_CHANGE_SIGNAL QLatin1String("changesCommitted")
#define SMTP_PROTOCOL "smtp"
#define SMTPS_PROTOCOL "smtps"
#define SMTP_PROTOCOL QLatin1String("smtp")
#define SMTPS_PROTOCOL QLatin1String("smtps")
#define SMTP_PORT 25
#define SMTPS_PORT 465
......
......@@ -88,29 +88,28 @@ void SmtpJob::doStart()
void SmtpJob::startSmtpJob()
{
QString query = "headers=0&from=";
query += KUrl::toPercentEncoding( sender() );
KUrl destination;
destination.setProtocol( (transport()->encryption() == Transport::EnumEncryption::SSL) ? SMTPS_PROTOCOL : SMTP_PROTOCOL );
destination.setHost( transport()->host() );
destination.setPort( transport()->port() );
destination.addQueryItem( QLatin1String("headers"), QLatin1String("0") );
destination.addQueryItem( QLatin1String("from"), sender() );
foreach ( QString str, to() )
query += "&to=" + KUrl::toPercentEncoding( str );
destination.addQueryItem( QLatin1String("to"), str );
foreach ( QString str, cc() )
query += "&cc=" + KUrl::toPercentEncoding( str );
destination.addQueryItem( QLatin1String("cc"), str );
foreach ( QString str, bcc() )
query += "&bcc=" + KUrl::toPercentEncoding( str );
destination.addQueryItem( QLatin1String("bcc"), str );
if ( transport()->specifyHostname() )
query += "&hostname=" + KUrl::toPercentEncoding( transport()->localHostname() );
destination.addQueryItem( QLatin1String("hostname"), transport()->localHostname() );
#warning Argh!
// if ( !kmkernel->msgSender()->sendQuotedPrintable() )
// query += "&body=8bit";
KUrl destination;
destination.setProtocol( (transport()->encryption() == Transport::EnumEncryption::SSL) ? SMTPS_PROTOCOL : SMTP_PROTOCOL );
destination.setHost( transport()->host() );
destination.setPort( transport()->port() );
if ( transport()->requiresAuthentication() ) {
if( (transport()->userName().isEmpty() || transport()->password().isEmpty())
&& transport()->authenticationType() != Transport::EnumAuthenticationType::GSSAPI )
......@@ -145,18 +144,18 @@ 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):
query += "&size=" + QString::number( qRound( data().length() * 1.05 ) );
destination.addQueryItem( QLatin1String("size"), QString::number( qRound( data().length() * 1.05 ) ) );
destination.setPath("/send");
destination.setQuery( query );
destination.setPath( QLatin1String("/send") );
mSlave = slavePool.value( transport()->id() );
if ( !mSlave ) {
kDebug() << k_funcinfo << "creating new SMTP slave" << endl;
KIO::MetaData slaveConfig;
slaveConfig.insert( "tls", (transport()->encryption() == Transport::EnumEncryption::TLS) ? "on" : "off" );
slaveConfig.insert( QLatin1String("tls"), (transport()->encryption() == Transport::EnumEncryption::TLS)
? QLatin1String("on") : QLatin1String("off") );
if ( transport()->requiresAuthentication() )
slaveConfig.insert( "sasl", transport()->authenticationTypeString() );
slaveConfig.insert( QLatin1String("sasl"), transport()->authenticationTypeString() );
mSlave = KIO::Scheduler::getConnectedSlave( destination, slaveConfig );
slavePool.insert( transport()->id(), mSlave );
} else {
......@@ -171,7 +170,7 @@ void SmtpJob::startSmtpJob()
return;
}
job->addMetaData( "lf2crlf+dotstuff", "slave" );
job->addMetaData( QLatin1String("lf2crlf+dotstuff"), QLatin1String("slave") );
connect( job, SIGNAL(dataReq(KIO::Job*,QByteArray&)), SLOT(dataRequest(KIO::Job*,QByteArray&)) );
addSubjob( job );
......
......@@ -161,13 +161,13 @@ void Transport::readPassword()
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), WALLET_FOLDER, QString::number(id())) )
{
// try migrating password from kmail
if ( Wallet::folderDoesNotExist(Wallet::NetworkWallet(), "kmail") ||
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), "kmail", QString::fromLatin1("transport-%1").arg( id() ) ) )
if ( Wallet::folderDoesNotExist(Wallet::NetworkWallet(), KMAIL_WALLET_FOLDER ) ||
Wallet::keyDoesNotExist(Wallet::NetworkWallet(), KMAIL_WALLET_FOLDER, QString::fromLatin1("transport-%1").arg( id() ) ) )
return;
kDebug() << k_funcinfo << "migrating password from kmail wallet" << endl;
KWallet::Wallet *wallet = TransportManager::self()->wallet();
if ( wallet ) {
wallet->setFolder( "kmail" );
wallet->setFolder( KMAIL_WALLET_FOLDER );
wallet->readPassword( QString::fromLatin1("transport-%1").arg( id() ), mPassword );
wallet->removeEntry( QString::fromLatin1("transport-%1").arg( id() ) );
wallet->setFolder( WALLET_FOLDER );
......
......@@ -119,7 +119,7 @@ TransportConfigDialog::TransportConfigDialog( Transport* transport, QWidget * pa
d->authGroup->addButton( d->smtp.ntlm );
d->authGroup->addButton( d->smtp.gssapi );
if ( KProtocolInfo::capabilities(SMTP_PROTOCOL).contains("SASL") == 0 ) {
if ( KProtocolInfo::capabilities(SMTP_PROTOCOL).contains( QLatin1String("SASL") ) == 0 ) {
d->smtp.ntlm->hide();
d->smtp.gssapi->hide();
}
......@@ -222,17 +222,17 @@ static QList<int> authMethodsFromStringList( const QStringList &list )
{
QList<int> result;
for ( QStringList::ConstIterator it = list.begin() ; it != list.end() ; ++it ) {
if ( *it == "LOGIN" )
if ( *it == QLatin1String("LOGIN") )
result << Transport::EnumAuthenticationType::LOGIN;
else if ( *it == "PLAIN" )
else if ( *it == QLatin1String("PLAIN") )
result << Transport::EnumAuthenticationType::PLAIN;
else if ( *it == "CRAM-MD5" )
else if ( *it == QLatin1String("CRAM-MD5") )
result << Transport::EnumAuthenticationType::CRAM_MD5;
else if ( *it == "DIGEST-MD5" )
else if ( *it == QLatin1String("DIGEST-MD5") )
result << Transport::EnumAuthenticationType::DIGEST_MD5;
else if ( *it == "NTLM" )
else if ( *it == QLatin1String("NTLM") )
result << Transport::EnumAuthenticationType::NTLM;
else if ( *it == "GSSAPI" )
else if ( *it == QLatin1String("GSSAPI") )
result << Transport::EnumAuthenticationType::GSSAPI;
}
......@@ -248,8 +248,8 @@ static QList<int> authMethodsFromStringList( const QStringList &list )
static QList<int> authMethodsFromString( const QString &s )
{
QStringList list;
foreach ( QString tmp, s.toUpper().split( '\n', QString::SkipEmptyParts ) )
list << tmp.remove( "SASL/" );
foreach ( QString tmp, s.toUpper().split( QLatin1Char('\n'), QString::SkipEmptyParts ) )
list << tmp.remove( QLatin1String("SASL/") );
return authMethodsFromStringList( list );
}
......@@ -274,7 +274,7 @@ void TransportConfigDialog::smtpCapabilities( const QStringList &capaNormal, con
// encryption method
d->smtp.none->setEnabled( !capaNormal.isEmpty() );
d->smtp.ssl->setEnabled( !capaSSL.isEmpty() );
d->smtp.tls->setEnabled( capaNormal.indexOf("STARTTLS") != -1 );
d->smtp.tls->setEnabled( capaNormal.indexOf( QLatin1String("STARTTLS") ) != -1 );
checkHighestEnabledButton( d->encryptionGroup );
// authentication methods
......
......@@ -116,7 +116,7 @@ void TransportManagementWidget::addClicked()
Transport *t = TransportManager::self()->createTransport();
t->setType( tdd.transportType() );
if ( t->type() == Transport::EnumType::Sendmail )
t->setHost( "/usr/sbin/sendmail" );
t->setHost( QLatin1String("/usr/sbin/sendmail") );
// configure transport
TransportConfigDialog tcd( t, this );
......
......@@ -52,12 +52,12 @@ TransportManager::TransportManager() :
mWalletAsyncOpen( false ),
mDefaultTransportId( -1 )
{
mConfig = new KConfig( "mailtransports" );
mConfig = new KConfig( QLatin1String("mailtransports") );
QDBusConnection::sessionBus().registerObject( DBUS_OBJECT_PATH, this,
QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableSignals );
QDBusConnection::sessionBus().connect( QString(), QString(), DBUS_INTERFACE_NAME, "changesCommitted",
QDBusConnection::sessionBus().connect( QString(), QString(), DBUS_INTERFACE_NAME, DBUS_CHANGE_SIGNAL,
this, SLOT(slotTransportsChanged()) );
mIsMainInstance = QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
......@@ -171,7 +171,7 @@ TransportJob* TransportManager::createTransportJob(const QString & transport)
if ( !url.isValid() )
return 0;
t = new Transport( "adhoc" );
t = new Transport( QLatin1String("adhoc") );
t->setDefaults();
t->setName( transport );
t->setAdHoc( true );
......@@ -183,7 +183,7 @@ TransportJob* TransportManager::createTransportJob(const QString & transport)
t->setEncryption( Transport::EnumEncryption::SSL );
t->setPort( SMTPS_PORT );
}
if ( url.hasPort() )
if ( url.port() != -1 )
t->setPort( url.port() );
if ( url.hasUser() ) {
t->setRequiresAuthentication( true );
......@@ -191,7 +191,7 @@ TransportJob* TransportManager::createTransportJob(const QString & transport)
}
}
else if ( url.protocol() == "file" ) {
else if ( url.protocol() == QLatin1String("file") ) {
t->setType( Transport::EnumType::Sendmail );
t->setHost( url.path( KUrl::RemoveTrailingSlash ) );
}
......@@ -273,7 +273,7 @@ void TransportManager::readConfig()
QList<Transport*> oldTransports = mTransports;
mTransports.clear();
QRegExp re( "^Transport (.+)$" );
QRegExp re( QLatin1String("^Transport (.+)$") );
QStringList groups = mConfig->groupList().filter( re );
foreach ( QString s, groups ) {
re.indexIn( s );
......@@ -281,7 +281,7 @@ void TransportManager::readConfig()
// see if we happen to have that one already
foreach ( Transport *old, oldTransports ) {
if ( old->currentGroup() == "Transport " + re.cap( 1 ) ) {
if ( old->currentGroup() == QLatin1String("Transport ") + re.cap( 1 ) ) {
kDebug() << k_funcinfo << "reloading existing transport: " << s << endl;
t = old;
t->readConfig();
......
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