diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e464d69d..ee7080cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ project(kmail) +check_include_files(fcntl.h HAVE_FCNTL_H) +check_include_files(byteswap.h HAVE_BYTESWAP_H) configure_file(config-kmail.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kmail.h ) diff --git a/configuredialog.cpp b/configuredialog.cpp index 33669476e..68d9bb6b7 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -91,6 +91,7 @@ using KMime::DateFormatter; #include #include #include +#include // Qt headers: #include @@ -1035,18 +1036,8 @@ void AccountsPage::SendingTab::doLoadOther() { mConfirmSendCheck->setChecked( composer.readEntry( "confirm-before-send", false ) ); QString str = general.readEntry( "Default domain" ); - if( str.isEmpty() ) - { - //### FIXME: Use the global convenience function instead of the homebrewed - // solution once we can rely on HEAD kdelibs. - //str = KGlobal::hostname(); ??????? - char buffer[256]; - if ( !gethostname( buffer, 255 ) ) - // buffer need not be NUL-terminated if it has full length - buffer[255] = 0; - else - buffer[0] = 0; - str = QString::fromLatin1( *buffer ? buffer : "localhost" ); + if( str.isEmpty() ) { + str = KNetwork::KResolver::localHostName(); } mDefaultDomainEdit->setText( str ); } diff --git a/keyresolver.cpp b/keyresolver.cpp index 31f332187..0b7b561e8 100644 --- a/keyresolver.cpp +++ b/keyresolver.cpp @@ -389,9 +389,7 @@ static QString canonicalAddress( const QString & _address ) { const QString address = EmailAddressTools::extractEmailAddress( _address ); if ( !address.contains('@') ) { // local address - //char hostname[1024]; - //gethostname(hostname,1024); - //return address + '@' + hostname; + //return address + '@' + KNetwork::KResolver::localHostName(); return address + "@localdomain"; } else diff --git a/kmmessage.cpp b/kmmessage.cpp index 80e20f6ec..6295292d6 100644 --- a/kmmessage.cpp +++ b/kmmessage.cpp @@ -40,6 +40,7 @@ using KMail::HeaderStrategy; #include #include #include +#include #include #include @@ -3740,15 +3741,9 @@ QString KMMessage::guessEmailAddressFromLoginName( const QString& loginName ) if ( loginName.isEmpty() ) return QString(); - char hostnameC[256]; - // null terminate this C string - hostnameC[255] = '\0'; - // set the string to 0 length if gethostname fails - if ( gethostname( hostnameC, 255 ) ) - hostnameC[0] = '\0'; QString address = loginName; address += '@'; - address += QString::fromLocal8Bit( hostnameC ); + address += KNetwork::KResolver::localHostName(); // try to determine the real name const KUser user( loginName ); diff --git a/kmstartup.cpp b/kmstartup.cpp index c025544c7..a623c1754 100644 --- a/kmstartup.cpp +++ b/kmstartup.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -77,18 +78,6 @@ void kmsetSignalHandler(void (*handler)(int)) } //----------------------------------------------------------------------------- -namespace { - QString getMyHostName() { - char hostNameC[256]; - // null terminate this C string - hostNameC[255] = 0; - // set the string to 0 length if gethostname fails - if(gethostname(hostNameC, 255)) - hostNameC[0] = 0; - return QString::fromLocal8Bit(hostNameC); - } -} // anon namespace - namespace KMail { void checkConfigUpdates() { @@ -149,7 +138,7 @@ void lockOrDie() { const QString oldHostName = config.readEntry("hostname"); const QString oldAppName = config.readEntry( "appName", appName ); const QString oldProgramName = config.readEntry( "programName", programName ); - const QString hostName = getMyHostName(); + const QString hostName = KNetwork::KResolver::localHostName(); bool first_instance = false; if ( oldPid == -1 ) first_instance = true;