33 #include <config-kleopatra.h> 
   39 #include <KLocalizedString> 
   47 #include <sys/types.h> 
   48 #include <sys/socket.h> 
   55 using namespace boost;
 
   58 QString UiServer::Private::systemErrorString() {
 
   59     return QString::fromLocal8Bit( strerror(errno) );
 
   62 void UiServer::Private::doMakeListeningSocket( 
const QByteArray & encodedFileName ) {
 
   64 #if defined(HAVE_ASSUAN2) || HAVE_ASSUAN_SOCK_GET_NONCE 
   65     const assuan_fd_t sock = assuan_sock_new( AF_UNIX, SOCK_STREAM, 0 );
 
   67     const assuan_fd_t sock = ::socket( AF_UNIX, SOCK_STREAM, 0 );
 
   70         throw_<std::runtime_error>( i18n( 
"Could not create socket: %1", systemErrorString() ) );
 
   74         struct sockaddr_un sa;
 
   75         std::memset( &sa, 0, 
sizeof(sa) );
 
   76         sa.sun_family = AF_UNIX;
 
   77         std::strncpy( sa.sun_path, encodedFileName.constData(), 
sizeof( sa.sun_path ) - 1 );
 
   78 #if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_SOCK_GET_NONCE) 
   79         if ( assuan_sock_bind( sock, (
struct sockaddr*)&sa, 
sizeof( sa ) ) )
 
   81         if ( ::bind( sock, (
struct sockaddr*)&sa, 
sizeof( sa ) ) )
 
   83             throw_<std::runtime_error>( i18n( 
"Could not bind to socket: %1", systemErrorString() ) );
 
   87 #if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_SOCK_GET_NONCE) 
   88         if ( assuan_sock_get_nonce( (
struct sockaddr*)&sa, 
sizeof( sa ), &nonce ) )
 
   89             throw_<std::runtime_error>( i18n(
"Could not get socket nonce: %1", systemErrorString() ) );
 
   93         if ( ::listen( sock, SOMAXCONN ) )
 
   94             throw_<std::runtime_error>( i18n( 
"Could not listen to socket: %1", systemErrorString() ) );
 
   96         if ( !setSocketDescriptor( sock ) )
 
   97             throw_<std::runtime_error>( i18n( 
"Could not pass socket to Qt: %1. This should not happen, please report this bug.", errorString() ) );
 
#define ASSUAN_INVALID_FD