33 #include <config-kleopatra.h> 
   39 #include <KLocalizedString> 
   43 #include <QTextStream> 
   57 using namespace boost;
 
   60 QString UiServer::Private::systemErrorString() {
 
   62     return QString::fromLocal8Bit( strerror(errno) );
 
   68 void UiServer::Private::doMakeListeningSocket( 
const QByteArray & encodedFileName ) {
 
   70     const assuan_fd_t sock = assuan_sock_new( AF_UNIX, SOCK_STREAM, 0 );
 
   72         throw_<std::runtime_error>( i18n( 
"Could not create socket: %1", systemErrorString() ) );
 
   76         struct sockaddr_un sa;
 
   77         std::memset( &sa, 0, 
sizeof(sa) );
 
   78         sa.sun_family = AF_UNIX;
 
   79         std::strncpy( sa.sun_path, encodedFileName.constData(), 
sizeof( sa.sun_path ) - 1 );
 
   80         if ( assuan_sock_bind( sock, (
struct sockaddr*)&sa, 
sizeof( sa ) ) )
 
   81             throw_<std::runtime_error>( i18n( 
"Could not bind to socket: %1", systemErrorString() ) );
 
   83         if ( assuan_sock_get_nonce( (
struct sockaddr*)&sa, 
sizeof( sa ), &nonce ) )
 
   84             throw_<std::runtime_error>( i18n(
"Could not get socket nonce: %1", systemErrorString() ) );
 
   87         if ( ::listen( (SOCKET)sock, SOMAXCONN ) )
 
   88             throw_<std::runtime_error>( i18n( 
"Could not listen to socket: %1", systemErrorString() ) );
 
   90         if ( !setSocketDescriptor( (intptr_t)sock  ) )
 
   91             throw_<std::runtime_error>( i18n( 
"Could not pass socket to Qt: %1. This should not happen, please report this bug.", errorString() ) );
 
   94         assuan_sock_close( sock );
 
#define ASSUAN_INVALID_FD