mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
gio: compile GUnixConnection on all platforms
On !UNIX, return an error for send_fd() & receive_fd(). (the unixfdmessage unit is not compiled on !UNIX) The header is installed under the common GIO include directory. Ensure G_TYPE_UNIX_CONNECTION is registered on all platforms. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
af1777d3d3
commit
83d45c4f35
@ -108,7 +108,6 @@ if get_option('gtk_doc')
|
||||
if host_system == 'windows'
|
||||
ignore_headers += [
|
||||
'gfiledescriptorbased.h',
|
||||
'gunixconnection.h',
|
||||
'gunixmounts.h',
|
||||
'gunixfdlist.h',
|
||||
'gunixfdmessage.h',
|
||||
|
@ -615,9 +615,7 @@ g_socket_connection_factory_register_type (GType g_type,
|
||||
static void
|
||||
init_builtin_types (void)
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
g_type_ensure (G_TYPE_UNIX_CONNECTION);
|
||||
#endif
|
||||
g_type_ensure (G_TYPE_TCP_CONNECTION);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SECTION:gunixconnection
|
||||
@ -39,9 +41,12 @@
|
||||
* It contains functions to do some of the UNIX socket specific
|
||||
* functionality like passing file descriptors.
|
||||
*
|
||||
* Note that `<gio/gunixconnection.h>` belongs to the UNIX-specific
|
||||
* GIO interfaces, thus you have to use the `gio-unix-2.0.pc`
|
||||
* pkg-config file when using it.
|
||||
* Since GLib 2.72, #GUnixConnection is available on all platforms. It requires
|
||||
* underlying system support (such as Windows 10 with `AF_UNIX`) at run time.
|
||||
*
|
||||
* Before GLib 2.72, `<gio/gunixconnection.h>` belonged to the UNIX-specific GIO
|
||||
* interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
|
||||
* using it. This is no longer necessary since GLib 2.72.
|
||||
*
|
||||
* Since: 2.22
|
||||
*/
|
||||
@ -86,6 +91,7 @@ g_unix_connection_send_fd (GUnixConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_OS_UNIX
|
||||
GSocketControlMessage *scm;
|
||||
GSocket *socket;
|
||||
|
||||
@ -114,6 +120,11 @@ g_unix_connection_send_fd (GUnixConnection *connection,
|
||||
g_object_unref (scm);
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Sending FD is not supported"));
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,6 +150,7 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_OS_UNIX
|
||||
GSocketControlMessage **scms;
|
||||
gint *fds, nfd, fd, nscm;
|
||||
GUnixFDMessage *fdmsg;
|
||||
@ -221,6 +233,11 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
|
||||
}
|
||||
|
||||
return fd;
|
||||
#else
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Receiving FD is not supported"));
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -346,7 +346,6 @@ if host_system != 'windows'
|
||||
unix_sources = files(
|
||||
'gfiledescriptorbased.c',
|
||||
'giounix-private.c',
|
||||
'gunixconnection.c',
|
||||
'gunixfdlist.c',
|
||||
'gunixfdmessage.c',
|
||||
'gunixmount.c',
|
||||
@ -374,7 +373,6 @@ if host_system != 'windows'
|
||||
|
||||
gio_unix_include_headers = files(
|
||||
'gfiledescriptorbased.h',
|
||||
'gunixconnection.h',
|
||||
'gunixmounts.h',
|
||||
'gunixfdlist.h',
|
||||
'gunixfdmessage.h',
|
||||
@ -565,6 +563,7 @@ gio_sources = files(
|
||||
'gdtlsclientconnection.c',
|
||||
'gdtlsserverconnection.c',
|
||||
'gunionvolumemonitor.c',
|
||||
'gunixconnection.c',
|
||||
'gunixcredentialsmessage.c',
|
||||
'gunixsocketaddress.c',
|
||||
'gvfs.c',
|
||||
@ -702,6 +701,7 @@ gio_headers = files(
|
||||
'gdtlsconnection.h',
|
||||
'gdtlsclientconnection.h',
|
||||
'gdtlsserverconnection.h',
|
||||
'gunixconnection.h',
|
||||
'gunixcredentialsmessage.h',
|
||||
'gunixsocketaddress.h',
|
||||
'gvfs.h',
|
||||
|
Loading…
Reference in New Issue
Block a user