GDBus: Hide instance structures for classes we don't want to be subclassed

This also allows us to nuke the priv-> pointers and save a couple of
indirections.

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen 2010-07-07 16:35:17 -04:00
parent 32ce3e051a
commit abc65b233c
10 changed files with 459 additions and 530 deletions

View File

@ -100,6 +100,8 @@
* </programlisting></example>
*/
typedef struct _GDBusAuthObserverClass GDBusAuthObserverClass;
/**
* GDBusAuthObserverClass:
* @authorize_authenticated_peer: Signal class handler for the #GDBusAuthObserver::authorize-authenticated-peer signal.
@ -121,9 +123,17 @@ struct _GDBusAuthObserverClass
GCredentials *credentials);
};
struct _GDBusAuthObserverPrivate
/**
* GDBusAuthObserver:
*
* The #GDBusAuthObserver structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusAuthObserver
{
gint foo;
GObject parent_instance;
};
enum
@ -202,18 +212,11 @@ g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
2,
G_TYPE_IO_STREAM,
G_TYPE_CREDENTIALS);
g_type_class_add_private (klass, sizeof (GDBusAuthObserverPrivate));
}
static void
g_dbus_auth_observer_init (GDBusAuthObserver *observer)
{
/* not used for now */
observer->priv = G_TYPE_INSTANCE_GET_PRIVATE (observer,
G_TYPE_DBUS_AUTH_OBSERVER,
GDBusAuthObserverPrivate);
}
/**

View File

@ -33,27 +33,7 @@ G_BEGIN_DECLS
#define G_TYPE_DBUS_AUTH_OBSERVER (g_dbus_auth_observer_get_type ())
#define G_DBUS_AUTH_OBSERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_AUTH_OBSERVER, GDBusAuthObserver))
#define G_DBUS_AUTH_OBSERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_AUTH_OBSERVER, GDBusAuthObserverClass))
#define G_DBUS_AUTH_OBSERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_AUTH_OBSERVER, GDBusAuthObserverClass))
#define G_IS_DBUS_AUTH_OBSERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_AUTH_OBSERVER))
#define G_IS_DBUS_AUTH_OBSERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_AUTH_OBSERVER))
typedef struct _GDBusAuthObserverClass GDBusAuthObserverClass;
typedef struct _GDBusAuthObserverPrivate GDBusAuthObserverPrivate;
/**
* GDBusAuthObserver:
*
* The #GDBusAuthObserver structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusAuthObserver
{
GObject parent_instance;
GDBusAuthObserverPrivate *priv;
};
GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST;
GDBusAuthObserver *g_dbus_auth_observer_new (void);

File diff suppressed because it is too large Load Diff

View File

@ -33,28 +33,7 @@ G_BEGIN_DECLS
#define G_TYPE_DBUS_CONNECTION (g_dbus_connection_get_type ())
#define G_DBUS_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_CONNECTION, GDBusConnection))
#define G_DBUS_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_CONNECTION, GDBusConnectionClass))
#define G_DBUS_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_CONNECTION, GDBusConnectionClass))
#define G_IS_DBUS_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_CONNECTION))
#define G_IS_DBUS_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_CONNECTION))
typedef struct _GDBusConnectionClass GDBusConnectionClass;
typedef struct _GDBusConnectionPrivate GDBusConnectionPrivate;
/**
* GDBusConnection:
*
* The #GDBusConnection structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusConnection
{
/*< private >*/
GObject parent_instance;
GDBusConnectionPrivate *priv;
};
GType g_dbus_connection_get_type (void) G_GNUC_CONST;

View File

@ -63,6 +63,7 @@
* on a #GDBusConnection.
*/
typedef struct _GDBusMessageClass GDBusMessageClass;
/**
* GDBusMessageClass:
@ -77,8 +78,19 @@ struct _GDBusMessageClass
GObjectClass parent_class;
};
struct _GDBusMessagePrivate
/**
* GDBusMessage:
*
* The #GDBusMessage structure contains only private data and should
* only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusMessage
{
/*< private >*/
GObject parent_instance;
GDBusMessageType type;
GDBusMessageFlags flags;
guchar major_protocol_version;
@ -97,13 +109,13 @@ g_dbus_message_finalize (GObject *object)
{
GDBusMessage *message = G_DBUS_MESSAGE (object);
if (message->priv->headers != NULL)
g_hash_table_unref (message->priv->headers);
if (message->priv->body != NULL)
g_variant_unref (message->priv->body);
if (message->headers != NULL)
g_hash_table_unref (message->headers);
if (message->body != NULL)
g_variant_unref (message->body);
#ifdef G_OS_UNIX
if (message->priv->fd_list != NULL)
g_object_unref (message->priv->fd_list);
if (message->fd_list != NULL)
g_object_unref (message->fd_list);
#endif
if (G_OBJECT_CLASS (g_dbus_message_parent_class)->finalize != NULL)
@ -115,8 +127,6 @@ g_dbus_message_class_init (GDBusMessageClass *klass)
{
GObjectClass *gobject_class;
g_type_class_add_private (klass, sizeof (GDBusMessagePrivate));
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_dbus_message_finalize;
@ -125,12 +135,10 @@ g_dbus_message_class_init (GDBusMessageClass *klass)
static void
g_dbus_message_init (GDBusMessage *message)
{
message->priv = G_TYPE_INSTANCE_GET_PRIVATE (message, G_TYPE_DBUS_MESSAGE, GDBusMessagePrivate);
message->priv->headers = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_variant_unref);
message->headers = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_variant_unref);
}
/**
@ -175,7 +183,7 @@ g_dbus_message_new_method_call (const gchar *name,
g_return_val_if_fail (interface_ == NULL || g_dbus_is_interface_name (interface_), NULL);
message = g_dbus_message_new ();
message->priv->type = G_DBUS_MESSAGE_TYPE_METHOD_CALL;
message->type = G_DBUS_MESSAGE_TYPE_METHOD_CALL;
if (name != NULL)
g_dbus_message_set_destination (message, name);
@ -211,8 +219,8 @@ g_dbus_message_new_signal (const gchar *path,
g_return_val_if_fail (interface_ == NULL || g_dbus_is_interface_name (interface_), NULL);
message = g_dbus_message_new ();
message->priv->type = G_DBUS_MESSAGE_TYPE_SIGNAL;
message->priv->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
message->type = G_DBUS_MESSAGE_TYPE_SIGNAL;
message->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
g_dbus_message_set_path (message, path);
g_dbus_message_set_member (message, signal);
@ -246,8 +254,8 @@ g_dbus_message_new_method_reply (GDBusMessage *method_call_message)
g_return_val_if_fail (g_dbus_message_get_serial (method_call_message) != 0, NULL);
message = g_dbus_message_new ();
message->priv->type = G_DBUS_MESSAGE_TYPE_METHOD_RETURN;
message->priv->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
message->type = G_DBUS_MESSAGE_TYPE_METHOD_RETURN;
message->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
g_dbus_message_set_reply_serial (message, g_dbus_message_get_serial (method_call_message));
sender = g_dbus_message_get_sender (method_call_message);
@ -318,8 +326,8 @@ g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message,
g_return_val_if_fail (error_message != NULL, NULL);
message = g_dbus_message_new ();
message->priv->type = G_DBUS_MESSAGE_TYPE_ERROR;
message->priv->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
message->type = G_DBUS_MESSAGE_TYPE_ERROR;
message->flags = G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
g_dbus_message_set_reply_serial (message, g_dbus_message_get_serial (method_call_message));
g_dbus_message_set_error_name (message, error_name);
@ -380,7 +388,7 @@ GDBusMessageType
g_dbus_message_get_message_type (GDBusMessage *message)
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), G_DBUS_MESSAGE_TYPE_INVALID);
return message->priv->type;
return message->type;
}
/**
@ -398,7 +406,7 @@ g_dbus_message_set_message_type (GDBusMessage *message,
{
g_return_if_fail (G_IS_DBUS_MESSAGE (message));
g_return_if_fail (type >=0 && type < 256);
message->priv->type = type;
message->type = type;
}
/* ---------------------------------------------------------------------------------------------------- */
@ -419,7 +427,7 @@ GDBusMessageFlags
g_dbus_message_get_flags (GDBusMessage *message)
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), G_DBUS_MESSAGE_FLAGS_NONE);
return message->priv->flags;
return message->flags;
}
/**
@ -438,7 +446,7 @@ g_dbus_message_set_flags (GDBusMessage *message,
{
g_return_if_fail (G_IS_DBUS_MESSAGE (message));
g_return_if_fail (flags >=0 && flags < 256);
message->priv->flags = flags;
message->flags = flags;
}
/* ---------------------------------------------------------------------------------------------------- */
@ -457,7 +465,7 @@ guint32
g_dbus_message_get_serial (GDBusMessage *message)
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), 0);
return message->priv->serial;
return message->serial;
}
/**
@ -474,7 +482,7 @@ g_dbus_message_set_serial (GDBusMessage *message,
guint32 serial)
{
g_return_if_fail (G_IS_DBUS_MESSAGE (message));
message->priv->serial = serial;
message->serial = serial;
}
/* ---------------------------------------------------------------------------------------------------- */
@ -499,7 +507,7 @@ g_dbus_message_get_header (GDBusMessage *message,
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
g_return_val_if_fail (header_field >=0 && header_field < 256, NULL);
return g_hash_table_lookup (message->priv->headers, GUINT_TO_POINTER (header_field));
return g_hash_table_lookup (message->headers, GUINT_TO_POINTER (header_field));
}
/**
@ -523,11 +531,11 @@ g_dbus_message_set_header (GDBusMessage *message,
g_return_if_fail (header_field >=0 && header_field < 256);
if (value == NULL)
{
g_hash_table_remove (message->priv->headers, GUINT_TO_POINTER (header_field));
g_hash_table_remove (message->headers, GUINT_TO_POINTER (header_field));
}
else
{
g_hash_table_insert (message->priv->headers, GUINT_TO_POINTER (header_field), g_variant_ref_sink (value));
g_hash_table_insert (message->headers, GUINT_TO_POINTER (header_field), g_variant_ref_sink (value));
}
}
@ -554,7 +562,7 @@ g_dbus_message_get_header_fields (GDBusMessage *message)
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
keys = g_hash_table_get_keys (message->priv->headers);
keys = g_hash_table_get_keys (message->headers);
num_keys = g_list_length (keys);
ret = g_new (guchar, num_keys + 1);
for (l = keys, n = 0; l != NULL; l = l->next, n++)
@ -582,7 +590,7 @@ GVariant *
g_dbus_message_get_body (GDBusMessage *message)
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
return message->priv->body;
return message->body;
}
/**
@ -605,11 +613,11 @@ g_dbus_message_set_body (GDBusMessage *message,
g_return_if_fail (G_IS_DBUS_MESSAGE (message));
g_return_if_fail ((body == NULL) || g_variant_is_of_type (body, G_VARIANT_TYPE_TUPLE));
if (message->priv->body != NULL)
g_variant_unref (message->priv->body);
if (message->body != NULL)
g_variant_unref (message->body);
if (body == NULL)
{
message->priv->body = NULL;
message->body = NULL;
g_dbus_message_set_signature (message, NULL);
}
else
@ -618,7 +626,7 @@ g_dbus_message_set_body (GDBusMessage *message,
gsize type_string_len;
gchar *signature;
message->priv->body = g_variant_ref_sink (body);
message->body = g_variant_ref_sink (body);
type_string = g_variant_get_type_string (body);
type_string_len = strlen (type_string);
@ -649,7 +657,7 @@ GUnixFDList *
g_dbus_message_get_unix_fd_list (GDBusMessage *message)
{
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
return message->priv->fd_list;
return message->fd_list;
}
/**
@ -672,16 +680,16 @@ g_dbus_message_set_unix_fd_list (GDBusMessage *message,
{
g_return_if_fail (G_IS_DBUS_MESSAGE (message));
g_return_if_fail (fd_list == NULL || G_IS_UNIX_FD_LIST (fd_list));
if (message->priv->fd_list != NULL)
g_object_unref (message->priv->fd_list);
if (message->fd_list != NULL)
g_object_unref (message->fd_list);
if (fd_list != NULL)
{
message->priv->fd_list = g_object_ref (fd_list);
message->fd_list = g_object_ref (fd_list);
g_dbus_message_set_num_unix_fds (message, g_unix_fd_list_get_length (fd_list));
}
else
{
message->priv->fd_list = NULL;
message->fd_list = NULL;
g_dbus_message_set_num_unix_fds (message, 0);
}
}
@ -1405,8 +1413,8 @@ g_dbus_message_new_from_blob (guchar *blob,
}
g_data_input_stream_set_byte_order (dis, byte_order);
message->priv->type = g_data_input_stream_read_byte (dis, NULL, NULL);
message->priv->flags = g_data_input_stream_read_byte (dis, NULL, NULL);
message->type = g_data_input_stream_read_byte (dis, NULL, NULL);
message->flags = g_data_input_stream_read_byte (dis, NULL, NULL);
major_protocol_version = g_data_input_stream_read_byte (dis, NULL, NULL);
if (major_protocol_version != 1)
{
@ -1418,7 +1426,7 @@ g_dbus_message_new_from_blob (guchar *blob,
goto out;
}
message_body_len = g_data_input_stream_read_uint32 (dis, NULL, NULL);
message->priv->serial = g_data_input_stream_read_uint32 (dis, NULL, NULL);
message->serial = g_data_input_stream_read_uint32 (dis, NULL, NULL);
#ifdef DEBUG_SERIALIZER
g_print ("Parsing blob (blob_len = 0x%04x bytes)\n", (gint) blob_len);
@ -1494,14 +1502,14 @@ g_dbus_message_new_from_blob (guchar *blob,
#ifdef DEBUG_SERIALIZER
g_print ("Parsing body (blob_len = 0x%04x bytes)\n", (gint) blob_len);
#endif /* DEBUG_SERIALIZER */
message->priv->body = parse_value_from_blob (mis,
dis,
variant_type,
FALSE,
2,
error);
message->body = parse_value_from_blob (mis,
dis,
variant_type,
FALSE,
2,
error);
g_variant_type_free (variant_type);
if (message->priv->body == NULL)
if (message->body == NULL)
goto out;
}
}
@ -1944,18 +1952,18 @@ g_dbus_message_to_blob (GDBusMessage *message,
/* Core header */
g_data_output_stream_put_byte (dos, byte_order == G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN ? 'l' : 'B', NULL, NULL);
g_data_output_stream_put_byte (dos, message->priv->type, NULL, NULL);
g_data_output_stream_put_byte (dos, message->priv->flags, NULL, NULL);
g_data_output_stream_put_byte (dos, message->type, NULL, NULL);
g_data_output_stream_put_byte (dos, message->flags, NULL, NULL);
g_data_output_stream_put_byte (dos, 1, NULL, NULL); /* major protocol version */
body_len_offset = g_memory_output_stream_get_data_size (mos);
/* body length - will be filled in later */
g_data_output_stream_put_uint32 (dos, 0xF00DFACE, NULL, NULL);
g_data_output_stream_put_uint32 (dos, message->priv->serial, NULL, NULL);
g_data_output_stream_put_uint32 (dos, message->serial, NULL, NULL);
num_fds_in_message = 0;
#ifdef G_OS_UNIX
if (message->priv->fd_list != NULL)
num_fds_in_message = g_unix_fd_list_get_length (message->priv->fd_list);
if (message->fd_list != NULL)
num_fds_in_message = g_unix_fd_list_get_length (message->fd_list);
#endif
num_fds_according_to_header = g_dbus_message_get_num_unix_fds (message);
/* TODO: check we have all the right header fields and that they are the correct value etc etc */
@ -1971,7 +1979,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
}
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{yv}"));
g_hash_table_iter_init (&hash_iter, message->priv->headers);
g_hash_table_iter_init (&hash_iter, message->headers);
while (g_hash_table_iter_next (&hash_iter, &key, (gpointer) &header_value))
{
g_variant_builder_add (&builder,
@ -2001,7 +2009,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
signature_str = NULL;
if (signature != NULL)
signature_str = g_variant_get_string (signature, NULL);
if (message->priv->body != NULL)
if (message->body != NULL)
{
gchar *tupled_signature_str;
tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
@ -2015,18 +2023,18 @@ g_dbus_message_to_blob (GDBusMessage *message,
g_free (tupled_signature_str);
goto out;
}
else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->priv->body)) != 0)
else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Message body has type signature `%s' but signature in the header field is `%s'"),
tupled_signature_str, g_variant_get_type_string (message->priv->body));
tupled_signature_str, g_variant_get_type_string (message->body));
g_free (tupled_signature_str);
goto out;
}
g_free (tupled_signature_str);
if (!append_body_to_blob (message->priv->body, mos, dos, error))
if (!append_body_to_blob (message->body, mos, dos, error))
goto out;
}
else
@ -2071,7 +2079,7 @@ get_uint32_header (GDBusMessage *message,
guint32 ret;
ret = 0;
value = g_hash_table_lookup (message->priv->headers, GUINT_TO_POINTER (header_field));
value = g_hash_table_lookup (message->headers, GUINT_TO_POINTER (header_field));
if (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32))
ret = g_variant_get_uint32 (value);
@ -2086,7 +2094,7 @@ get_string_header (GDBusMessage *message,
const gchar *ret;
ret = NULL;
value = g_hash_table_lookup (message->priv->headers, GUINT_TO_POINTER (header_field));
value = g_hash_table_lookup (message->headers, GUINT_TO_POINTER (header_field));
if (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
ret = g_variant_get_string (value, NULL);
@ -2101,7 +2109,7 @@ get_object_path_header (GDBusMessage *message,
const gchar *ret;
ret = NULL;
value = g_hash_table_lookup (message->priv->headers, GUINT_TO_POINTER (header_field));
value = g_hash_table_lookup (message->headers, GUINT_TO_POINTER (header_field));
if (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_OBJECT_PATH))
ret = g_variant_get_string (value, NULL);
@ -2116,7 +2124,7 @@ get_signature_header (GDBusMessage *message,
const gchar *ret;
ret = NULL;
value = g_hash_table_lookup (message->priv->headers, GUINT_TO_POINTER (header_field));
value = g_hash_table_lookup (message->headers, GUINT_TO_POINTER (header_field));
if (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_SIGNATURE))
ret = g_variant_get_string (value, NULL);
@ -2486,10 +2494,10 @@ g_dbus_message_get_arg0 (GDBusMessage *message)
ret = NULL;
if (message->priv->body != NULL && g_variant_is_of_type (message->priv->body, G_VARIANT_TYPE_TUPLE))
if (message->body != NULL && g_variant_is_of_type (message->body, G_VARIANT_TYPE_TUPLE))
{
GVariant *item;
item = g_variant_get_child_value (message->priv->body, 0);
item = g_variant_get_child_value (message->body, 0);
if (g_variant_is_of_type (item, G_VARIANT_TYPE_STRING))
ret = g_variant_get_string (item, NULL);
g_variant_unref (item);
@ -2563,7 +2571,7 @@ g_dbus_message_to_gerror (GDBusMessage *message,
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), FALSE);
ret = FALSE;
if (message->priv->type != G_DBUS_MESSAGE_TYPE_ERROR)
if (message->type != G_DBUS_MESSAGE_TYPE_ERROR)
goto out;
error_name = g_dbus_message_get_error_name (message);
@ -2720,17 +2728,17 @@ g_dbus_message_print (GDBusMessage *message,
str = g_string_new (NULL);
s = _g_dbus_enum_to_string (G_TYPE_DBUS_MESSAGE_TYPE, message->priv->type);
s = _g_dbus_enum_to_string (G_TYPE_DBUS_MESSAGE_TYPE, message->type);
g_string_append_printf (str, "%*sType: %s\n", indent, "", s);
g_free (s);
s = flags_to_string (G_TYPE_DBUS_MESSAGE_FLAGS, message->priv->flags);
s = flags_to_string (G_TYPE_DBUS_MESSAGE_FLAGS, message->flags);
g_string_append_printf (str, "%*sFlags: %s\n", indent, "", s);
g_free (s);
g_string_append_printf (str, "%*sVersion: %d\n", indent, "", message->priv->major_protocol_version);
g_string_append_printf (str, "%*sSerial: %d\n", indent, "", message->priv->serial);
g_string_append_printf (str, "%*sVersion: %d\n", indent, "", message->major_protocol_version);
g_string_append_printf (str, "%*sSerial: %d\n", indent, "", message->serial);
g_string_append_printf (str, "%*sHeaders:\n", indent, "");
keys = g_hash_table_get_keys (message->priv->headers);
keys = g_hash_table_get_keys (message->headers);
keys = g_list_sort (keys, _sort_keys_func);
if (keys != NULL)
{
@ -2740,7 +2748,7 @@ g_dbus_message_print (GDBusMessage *message,
GVariant *value;
gchar *value_str;
value = g_hash_table_lookup (message->priv->headers, l->data);
value = g_hash_table_lookup (message->headers, l->data);
g_assert (value != NULL);
s = _g_dbus_enum_to_string (G_TYPE_DBUS_MESSAGE_HEADER_FIELD, key);
@ -2755,9 +2763,9 @@ g_dbus_message_print (GDBusMessage *message,
g_string_append_printf (str, "%*s (none)\n", indent, "");
}
g_string_append_printf (str, "%*sBody: ", indent, "");
if (message->priv->body != NULL)
if (message->body != NULL)
{
g_variant_print_string (message->priv->body,
g_variant_print_string (message->body,
str,
TRUE);
}
@ -2768,13 +2776,13 @@ g_dbus_message_print (GDBusMessage *message,
g_string_append (str, "\n");
#ifdef G_OS_UNIX
g_string_append_printf (str, "%*sUNIX File Descriptors:\n", indent, "");
if (message->priv->fd_list != NULL)
if (message->fd_list != NULL)
{
gint num_fds;
const gint *fds;
gint n;
fds = g_unix_fd_list_peek_fds (message->priv->fd_list, &num_fds);
fds = g_unix_fd_list_peek_fds (message->fd_list, &num_fds);
if (num_fds > 0)
{
for (n = 0; n < num_fds; n++)

View File

@ -33,28 +33,7 @@ G_BEGIN_DECLS
#define G_TYPE_DBUS_MESSAGE (g_dbus_message_get_type ())
#define G_DBUS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_MESSAGE, GDBusMessage))
#define G_DBUS_MESSAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_MESSAGE, GDBusMessageClass))
#define G_DBUS_MESSAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_MESSAGE, GDBusMessageClass))
#define G_IS_DBUS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_MESSAGE))
#define G_IS_DBUS_MESSAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_MESSAGE))
typedef struct _GDBusMessageClass GDBusMessageClass;
typedef struct _GDBusMessagePrivate GDBusMessagePrivate;
/**
* GDBusMessage:
*
* The #GDBusMessage structure contains only private data and should
* only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusMessage
{
/*< private >*/
GObject parent_instance;
GDBusMessagePrivate *priv;
};
GType g_dbus_message_get_type (void) G_GNUC_CONST;
GDBusMessage *g_dbus_message_new (void);

View File

@ -49,6 +49,8 @@
* #GDBusInterfaceVTable that was passed to g_dbus_connection_register_object().
*/
typedef struct _GDBusMethodInvocationClass GDBusMethodInvocationClass;
/**
* GDBusMethodInvocationClass:
*
@ -62,8 +64,19 @@ struct _GDBusMethodInvocationClass
GObjectClass parent_class;
};
struct _GDBusMethodInvocationPrivate
/**
* GDBusMethodInvocation:
*
* The #GDBusMethodInvocation structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusMethodInvocation
{
/*< private >*/
GObject parent_instance;
/* construct-only properties */
gchar *sender;
gchar *object_path;
@ -83,13 +96,13 @@ g_dbus_method_invocation_finalize (GObject *object)
{
GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (object);
g_free (invocation->priv->sender);
g_free (invocation->priv->object_path);
g_free (invocation->priv->interface_name);
g_free (invocation->priv->method_name);
g_object_unref (invocation->priv->connection);
g_object_unref (invocation->priv->message);
g_variant_unref (invocation->priv->parameters);
g_free (invocation->sender);
g_free (invocation->object_path);
g_free (invocation->interface_name);
g_free (invocation->method_name);
g_object_unref (invocation->connection);
g_object_unref (invocation->message);
g_variant_unref (invocation->parameters);
G_OBJECT_CLASS (g_dbus_method_invocation_parent_class)->finalize (object);
}
@ -100,16 +113,11 @@ g_dbus_method_invocation_class_init (GDBusMethodInvocationClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_dbus_method_invocation_finalize;
g_type_class_add_private (klass, sizeof (GDBusMethodInvocationPrivate));
}
static void
g_dbus_method_invocation_init (GDBusMethodInvocation *invocation)
{
invocation->priv = G_TYPE_INSTANCE_GET_PRIVATE (invocation,
G_TYPE_DBUS_METHOD_INVOCATION,
GDBusMethodInvocationPrivate);
}
/**
@ -126,7 +134,7 @@ const gchar *
g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->sender;
return invocation->sender;
}
/**
@ -143,7 +151,7 @@ const gchar *
g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->object_path;
return invocation->object_path;
}
/**
@ -160,7 +168,7 @@ const gchar *
g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->interface_name;
return invocation->interface_name;
}
/**
@ -177,7 +185,7 @@ const GDBusMethodInfo *
g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->method_info;
return invocation->method_info;
}
/**
@ -194,7 +202,7 @@ const gchar *
g_dbus_method_invocation_get_method_name (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->method_name;
return invocation->method_name;
}
/**
@ -211,7 +219,7 @@ GDBusConnection *
g_dbus_method_invocation_get_connection (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->connection;
return invocation->connection;
}
/**
@ -235,7 +243,7 @@ GDBusMessage *
g_dbus_method_invocation_get_message (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->message;
return invocation->message;
}
/**
@ -252,7 +260,7 @@ GVariant *
g_dbus_method_invocation_get_parameters (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->parameters;
return invocation->parameters;
}
/**
@ -269,7 +277,7 @@ gpointer
g_dbus_method_invocation_get_user_data (GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL);
return invocation->priv->user_data;
return invocation->user_data;
}
/**
@ -302,7 +310,6 @@ g_dbus_method_invocation_new (const gchar *sender,
gpointer user_data)
{
GDBusMethodInvocation *invocation;
GDBusMethodInvocationPrivate *priv;
g_return_val_if_fail (sender == NULL || g_dbus_is_name (sender), NULL);
g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
@ -313,17 +320,15 @@ g_dbus_method_invocation_new (const gchar *sender,
g_return_val_if_fail (g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE), NULL);
invocation = G_DBUS_METHOD_INVOCATION (g_object_new (G_TYPE_DBUS_METHOD_INVOCATION, NULL));
priv = invocation->priv;
priv->sender = g_strdup (sender);
priv->object_path = g_strdup (object_path);
priv->interface_name = g_strdup (interface_name);
priv->method_name = g_strdup (method_name);
priv->method_info = g_dbus_method_info_ref ((GDBusMethodInfo *)method_info);
priv->connection = g_object_ref (connection);
priv->message = g_object_ref (message);
priv->parameters = g_variant_ref (parameters);
priv->user_data = user_data;
invocation->sender = g_strdup (sender);
invocation->object_path = g_strdup (object_path);
invocation->interface_name = g_strdup (interface_name);
invocation->method_name = g_strdup (method_name);
invocation->method_info = g_dbus_method_info_ref ((GDBusMethodInfo *)method_info);
invocation->connection = g_object_ref (connection);
invocation->message = g_object_ref (message);
invocation->parameters = g_variant_ref (parameters);
invocation->user_data = user_data;
return invocation;
}
@ -358,11 +363,11 @@ g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation,
parameters = g_variant_new_tuple (NULL, 0);
/* if we have introspection data, check that the signature of @parameters is correct */
if (invocation->priv->method_info != NULL)
if (invocation->method_info != NULL)
{
GVariantType *type;
type = _g_dbus_compute_complete_signature (invocation->priv->method_info->out_args);
type = _g_dbus_compute_complete_signature (invocation->method_info->out_args);
if (!g_variant_is_of_type (parameters, type))
{
@ -377,7 +382,7 @@ g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation,
g_variant_type_free (type);
}
reply = g_dbus_message_new_method_reply (invocation->priv->message);
reply = g_dbus_message_new_method_reply (invocation->message);
g_dbus_message_set_body (reply, parameters);
error = NULL;
if (!g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, NULL, &error))
@ -556,7 +561,7 @@ g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation,
g_return_if_fail (error_name != NULL && g_dbus_is_name (error_name));
g_return_if_fail (error_message != NULL);
reply = g_dbus_message_new_method_error_literal (invocation->priv->message,
reply = g_dbus_message_new_method_error_literal (invocation->message,
error_name,
error_message);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, NULL, NULL);

View File

@ -33,28 +33,7 @@ G_BEGIN_DECLS
#define G_TYPE_DBUS_METHOD_INVOCATION (g_dbus_method_invocation_get_type ())
#define G_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocation))
#define G_DBUS_METHOD_INVOCATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocationClass))
#define G_DBUS_METHOD_INVOCATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocationClass))
#define G_IS_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_METHOD_INVOCATION))
#define G_IS_DBUS_METHOD_INVOCATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_METHOD_INVOCATION))
typedef struct _GDBusMethodInvocationClass GDBusMethodInvocationClass;
typedef struct _GDBusMethodInvocationPrivate GDBusMethodInvocationPrivate;
/**
* GDBusMethodInvocation:
*
* The #GDBusMethodInvocation structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusMethodInvocation
{
/*< private >*/
GObject parent_instance;
GDBusMethodInvocationPrivate *priv;
};
GType g_dbus_method_invocation_get_type (void) G_GNUC_CONST;
GDBusMethodInvocation *g_dbus_method_invocation_new (const gchar *sender,

View File

@ -70,26 +70,18 @@
*/
/**
* GDBusServerClass:
* @new_connection: Signal class handler for the #GDBusServer::new-connection signal.
* GDBusServer:
*
* Class structure for #GDBusServer.
* The #GDBusServer structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusServerClass
struct _GDBusServer
{
/*< private >*/
GObjectClass parent_class;
GObject parent_instance;
/*< public >*/
/* Signals */
void (*new_connection) (GDBusServer *server,
GDBusConnection *connection);
};
struct _GDBusServerPrivate
{
GDBusServerFlags flags;
gchar *address;
gchar *guid;
@ -113,6 +105,27 @@ struct _GDBusServerPrivate
GDBusAuthObserver *authentication_observer;
};
typedef struct _GDBusServerClass GDBusServerClass;
/**
* GDBusServerClass:
* @new_connection: Signal class handler for the #GDBusServer::new-connection signal.
*
* Class structure for #GDBusServer.
*
* Since: 2.26
*/
struct _GDBusServerClass
{
/*< private >*/
GObjectClass parent_class;
/*< public >*/
/* Signals */
void (*new_connection) (GDBusServer *server,
GDBusConnection *connection);
};
enum
{
PROP_0,
@ -143,27 +156,27 @@ g_dbus_server_finalize (GObject *object)
{
GDBusServer *server = G_DBUS_SERVER (object);
if (server->priv->authentication_observer != NULL)
g_object_unref (server->priv->authentication_observer);
if (server->authentication_observer != NULL)
g_object_unref (server->authentication_observer);
if (server->priv->listener != NULL)
g_object_unref (server->priv->listener);
if (server->listener != NULL)
g_object_unref (server->listener);
g_free (server->priv->address);
g_free (server->priv->guid);
g_free (server->priv->client_address);
if (server->priv->nonce != NULL)
g_free (server->address);
g_free (server->guid);
g_free (server->client_address);
if (server->nonce != NULL)
{
memset (server->priv->nonce, '\0', 16);
g_free (server->priv->nonce);
memset (server->nonce, '\0', 16);
g_free (server->nonce);
}
/* we could unlink the nonce file but I don't
* think it's really worth the effort/risk
*/
g_free (server->priv->nonce_file);
g_free (server->nonce_file);
if (server->priv->main_context_at_construction != NULL)
g_main_context_unref (server->priv->main_context_at_construction);
if (server->main_context_at_construction != NULL)
g_main_context_unref (server->main_context_at_construction);
G_OBJECT_CLASS (g_dbus_server_parent_class)->finalize (object);
}
@ -179,27 +192,27 @@ g_dbus_server_get_property (GObject *object,
switch (prop_id)
{
case PROP_FLAGS:
g_value_set_flags (value, server->priv->flags);
g_value_set_flags (value, server->flags);
break;
case PROP_GUID:
g_value_set_string (value, server->priv->guid);
g_value_set_string (value, server->guid);
break;
case PROP_ADDRESS:
g_value_set_string (value, server->priv->address);
g_value_set_string (value, server->address);
break;
case PROP_CLIENT_ADDRESS:
g_value_set_string (value, server->priv->client_address);
g_value_set_string (value, server->client_address);
break;
case PROP_ACTIVE:
g_value_set_boolean (value, server->priv->active);
g_value_set_boolean (value, server->active);
break;
case PROP_AUTHENTICATION_OBSERVER:
g_value_set_object (value, server->priv->authentication_observer);
g_value_set_object (value, server->authentication_observer);
break;
default:
@ -219,19 +232,19 @@ g_dbus_server_set_property (GObject *object,
switch (prop_id)
{
case PROP_FLAGS:
server->priv->flags = g_value_get_flags (value);
server->flags = g_value_get_flags (value);
break;
case PROP_GUID:
server->priv->guid = g_value_dup_string (value);
server->guid = g_value_dup_string (value);
break;
case PROP_ADDRESS:
server->priv->address = g_value_dup_string (value);
server->address = g_value_dup_string (value);
break;
case PROP_AUTHENTICATION_OBSERVER:
server->priv->authentication_observer = g_value_dup_object (value);
server->authentication_observer = g_value_dup_object (value);
break;
default:
@ -403,19 +416,14 @@ g_dbus_server_class_init (GDBusServerClass *klass)
G_TYPE_NONE,
1,
G_TYPE_DBUS_CONNECTION);
g_type_class_add_private (klass, sizeof (GDBusServerPrivate));
}
static void
g_dbus_server_init (GDBusServer *server)
{
server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, G_TYPE_DBUS_SERVER, GDBusServerPrivate);
server->priv->main_context_at_construction = g_main_context_get_thread_default ();
if (server->priv->main_context_at_construction != NULL)
g_main_context_ref (server->priv->main_context_at_construction);
server->main_context_at_construction = g_main_context_get_thread_default ();
if (server->main_context_at_construction != NULL)
g_main_context_ref (server->main_context_at_construction);
}
static gboolean
@ -481,8 +489,8 @@ g_dbus_server_new_sync (const gchar *address,
if (server != NULL)
{
/* Right now we don't have any transport not using the listener... */
g_assert (server->priv->is_using_listener);
g_signal_connect (G_SOCKET_SERVICE (server->priv->listener),
g_assert (server->is_using_listener);
g_signal_connect (G_SOCKET_SERVICE (server->listener),
"run",
G_CALLBACK (on_run),
server);
@ -507,7 +515,7 @@ const gchar *
g_dbus_server_get_client_address (GDBusServer *server)
{
g_return_val_if_fail (G_IS_DBUS_SERVER (server), NULL);
return server->priv->client_address;
return server->client_address;
}
/**
@ -524,7 +532,7 @@ const gchar *
g_dbus_server_get_guid (GDBusServer *server)
{
g_return_val_if_fail (G_IS_DBUS_SERVER (server), NULL);
return server->priv->guid;
return server->guid;
}
/**
@ -541,7 +549,7 @@ GDBusServerFlags
g_dbus_server_get_flags (GDBusServer *server)
{
g_return_val_if_fail (G_IS_DBUS_SERVER (server), G_DBUS_SERVER_FLAGS_NONE);
return server->priv->flags;
return server->flags;
}
/**
@ -558,7 +566,7 @@ gboolean
g_dbus_server_is_active (GDBusServer *server)
{
g_return_val_if_fail (G_IS_DBUS_SERVER (server), G_DBUS_SERVER_FLAGS_NONE);
return server->priv->active;
return server->active;
}
/**
@ -573,12 +581,12 @@ void
g_dbus_server_start (GDBusServer *server)
{
g_return_if_fail (G_IS_DBUS_SERVER (server));
if (server->priv->active)
if (server->active)
return;
/* Right now we don't have any transport not using the listener... */
g_assert (server->priv->is_using_listener);
g_socket_service_start (G_SOCKET_SERVICE (server->priv->listener));
server->priv->active = TRUE;
g_assert (server->is_using_listener);
g_socket_service_start (G_SOCKET_SERVICE (server->listener));
server->active = TRUE;
g_object_notify (G_OBJECT (server), "active");
}
@ -594,12 +602,12 @@ void
g_dbus_server_stop (GDBusServer *server)
{
g_return_if_fail (G_IS_DBUS_SERVER (server));
if (!server->priv->active)
if (!server->active)
return;
/* Right now we don't have any transport not using the listener... */
g_assert (server->priv->is_using_listener);
g_socket_service_stop (G_SOCKET_SERVICE (server->priv->listener));
server->priv->active = FALSE;
g_assert (server->is_using_listener);
g_socket_service_stop (G_SOCKET_SERVICE (server->listener));
server->active = FALSE;
g_object_notify (G_OBJECT (server), "active");
}
@ -667,7 +675,7 @@ try_unix (GDBusServer *server,
g_string_free (s, TRUE);
local_error = NULL;
if (!g_socket_listener_add_address (server->priv->listener,
if (!g_socket_listener_add_address (server->listener,
address,
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_DEFAULT,
@ -705,7 +713,7 @@ try_unix (GDBusServer *server,
g_assert_not_reached ();
}
if (!g_socket_listener_add_address (server->priv->listener,
if (!g_socket_listener_add_address (server->listener,
address,
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_DEFAULT,
@ -723,18 +731,18 @@ try_unix (GDBusServer *server,
/* Fill out client_address if the connection attempt worked */
if (ret)
{
server->priv->is_using_listener = TRUE;
server->is_using_listener = TRUE;
switch (g_unix_socket_address_get_address_type (G_UNIX_SOCKET_ADDRESS (address)))
{
case G_UNIX_SOCKET_ADDRESS_ABSTRACT:
server->priv->client_address = g_strdup_printf ("unix:abstract=%s",
g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)));
server->client_address = g_strdup_printf ("unix:abstract=%s",
g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)));
break;
case G_UNIX_SOCKET_ADDRESS_PATH:
server->priv->client_address = g_strdup_printf ("unix:path=%s",
g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)));
server->client_address = g_strdup_printf ("unix:path=%s",
g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)));
break;
default:
@ -809,7 +817,7 @@ try_tcp (GDBusServer *server,
GSocketAddress *effective_address;
socket_address = g_inet_socket_address_new (address, port_num);
if (!g_socket_listener_add_address (server->priv->listener,
if (!g_socket_listener_add_address (server->listener,
socket_address,
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_TCP,
@ -835,15 +843,15 @@ try_tcp (GDBusServer *server,
gsize bytes_written;
gsize bytes_remaining;
server->priv->nonce = g_new0 (guchar, 16);
server->nonce = g_new0 (guchar, 16);
for (n = 0; n < 16; n++)
server->priv->nonce[n] = g_random_int_range (0, 256);
server->nonce[n] = g_random_int_range (0, 256);
fd = g_file_open_tmp ("gdbus-nonce-file-XXXXXX",
&server->priv->nonce_file,
&server->nonce_file,
error);
if (fd == -1)
{
g_socket_listener_close (server->priv->listener);
g_socket_listener_close (server->listener);
goto out;
}
again:
@ -852,7 +860,7 @@ try_tcp (GDBusServer *server,
while (bytes_remaining > 0)
{
gssize ret;
ret = write (fd, server->priv->nonce + bytes_written, bytes_remaining);
ret = write (fd, server->nonce + bytes_written, bytes_remaining);
if (ret == -1)
{
if (errno == EINTR)
@ -861,7 +869,7 @@ try_tcp (GDBusServer *server,
G_IO_ERROR,
g_io_error_from_errno (errno),
_("Error writing nonce file at `%s': %s"),
server->priv->nonce_file,
server->nonce_file,
strerror (errno));
goto out;
}
@ -869,16 +877,16 @@ try_tcp (GDBusServer *server,
bytes_remaining -= ret;
}
close (fd);
server->priv->client_address = g_strdup_printf ("nonce-tcp:host=%s,port=%d,noncefile=%s",
host,
port_num,
server->priv->nonce_file);
server->client_address = g_strdup_printf ("nonce-tcp:host=%s,port=%d,noncefile=%s",
host,
port_num,
server->nonce_file);
}
else
{
server->priv->client_address = g_strdup_printf ("tcp:host=%s,port=%d", host, port_num);
server->client_address = g_strdup_printf ("tcp:host=%s,port=%d", host, port_num);
}
server->priv->is_using_listener = TRUE;
server->is_using_listener = TRUE;
ret = TRUE;
out:
@ -930,7 +938,7 @@ on_run (GSocketService *service,
GDBusConnection *connection;
GDBusConnectionFlags connection_flags;
if (server->priv->nonce != NULL)
if (server->nonce != NULL)
{
gchar buf[16];
gsize bytes_read;
@ -946,26 +954,26 @@ on_run (GSocketService *service,
if (bytes_read != 16)
goto out;
if (memcmp (buf, server->priv->nonce, 16) != 0)
if (memcmp (buf, server->nonce, 16) != 0)
goto out;
}
connection_flags =
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER |
G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING;
if (server->priv->flags & G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS)
if (server->flags & G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS)
connection_flags |= G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS;
connection = g_dbus_connection_new_sync (G_IO_STREAM (socket_connection),
server->priv->guid,
server->guid,
connection_flags,
server->priv->authentication_observer,
server->authentication_observer,
NULL, /* GCancellable */
NULL); /* GError */
if (connection == NULL)
goto out;
if (server->priv->flags & G_DBUS_SERVER_FLAGS_RUN_IN_THREAD)
if (server->flags & G_DBUS_SERVER_FLAGS_RUN_IN_THREAD)
{
g_signal_emit (server,
_signals[NEW_CONNECTION_SIGNAL],
@ -989,7 +997,7 @@ on_run (GSocketService *service,
emit_new_connection_in_idle,
data,
(GDestroyNotify) emit_idle_data_free);
g_source_attach (idle_source, server->priv->main_context_at_construction);
g_source_attach (idle_source, server->main_context_at_construction);
g_source_unref (idle_source);
}
@ -1011,19 +1019,19 @@ initable_init (GInitable *initable,
ret = FALSE;
last_error = NULL;
if (!g_dbus_is_guid (server->priv->guid))
if (!g_dbus_is_guid (server->guid))
{
g_set_error (&last_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("The string `%s' is not a valid D-Bus GUID"),
server->priv->guid);
server->guid);
goto out;
}
server->priv->listener = G_SOCKET_LISTENER (g_threaded_socket_service_new (-1));
server->listener = G_SOCKET_LISTENER (g_threaded_socket_service_new (-1));
addr_array = g_strsplit (server->priv->address, ";", 0);
addr_array = g_strsplit (server->address, ";", 0);
last_error = NULL;
for (n = 0; addr_array != NULL && addr_array[n] != NULL; n++)
{

View File

@ -33,28 +33,7 @@ G_BEGIN_DECLS
#define G_TYPE_DBUS_SERVER (g_dbus_server_get_type ())
#define G_DBUS_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_SERVER, GDBusServer))
#define G_DBUS_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_SERVER, GDBusServerClass))
#define G_DBUS_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_SERVER, GDBusServerClass))
#define G_IS_DBUS_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_SERVER))
#define G_IS_DBUS_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_SERVER))
typedef struct _GDBusServerClass GDBusServerClass;
typedef struct _GDBusServerPrivate GDBusServerPrivate;
/**
* GDBusServer:
*
* The #GDBusServer structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.26
*/
struct _GDBusServer
{
/*< private >*/
GObject parent_instance;
GDBusServerPrivate *priv;
};
GType g_dbus_server_get_type (void) G_GNUC_CONST;
GDBusServer *g_dbus_server_new_sync (const gchar *address,