33 #include <config-kleopatra.h>
39 #include <KLocalizedString>
54 using namespace boost;
57 QString UiServer::Private::systemErrorString() {
61 void UiServer::Private::doMakeListeningSocket(
const QByteArray & encodedFileName ) {
63 const assuan_fd_t sock = assuan_sock_new( AF_UNIX, SOCK_STREAM, 0 );
65 throw_<std::runtime_error>( i18n(
"Could not create socket: %1", systemErrorString() ) );
69 struct sockaddr_un sa;
70 std::memset( &sa, 0,
sizeof(sa) );
71 sa.sun_family = AF_UNIX;
72 std::strncpy( sa.sun_path, encodedFileName.
constData(),
sizeof( sa.sun_path ) - 1 );
73 if ( assuan_sock_bind( sock, (
struct sockaddr*)&sa,
sizeof( sa ) ) )
74 throw_<std::runtime_error>( i18n(
"Could not bind to socket: %1", systemErrorString() ) );
76 if ( assuan_sock_get_nonce( (
struct sockaddr*)&sa,
sizeof( sa ), &nonce ) )
77 throw_<std::runtime_error>( i18n(
"Could not get socket nonce: %1", systemErrorString() ) );
80 if ( ::listen( (SOCKET)sock, SOMAXCONN ) )
81 throw_<std::runtime_error>( i18n(
"Could not listen to socket: %1", systemErrorString() ) );
83 if ( !setSocketDescriptor( (intptr_t)sock ) )
84 throw_<std::runtime_error>( i18n(
"Could not pass socket to Qt: %1. This should not happen, please report this bug.", errorString() ) );
87 assuan_sock_close( sock );
QString fromLocal8Bit(const char *str, int size)
#define ASSUAN_INVALID_FD
const char * constData() const