[gnome-session] xsmp-server: Modernise GObject private data handling
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] xsmp-server: Modernise GObject private data handling
- Date: Fri, 10 Dec 2021 14:53:56 +0000 (UTC)
commit 98f328d71d45c00662d42289362d15b2f684fb03
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Nov 15 11:51:42 2021 +0000
xsmp-server: Modernise GObject private data handling
Use `G_DECLARE_FINAL_TYPE` and `G_DEFINE_TYPE_WITH_PRIVATE`.
This introduces no functional changes, but removes a few GLib
deprecation warnings.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gnome-session/gsm-xsmp-server.c | 86 ++++++++++++++++++++---------------------
gnome-session/gsm-xsmp-server.h | 21 +---------
2 files changed, 43 insertions(+), 64 deletions(-)
---
diff --git a/gnome-session/gsm-xsmp-server.c b/gnome-session/gsm-xsmp-server.c
index d558f9b2..e05c6d77 100644
--- a/gnome-session/gsm-xsmp-server.c
+++ b/gnome-session/gsm-xsmp-server.c
@@ -61,8 +61,10 @@
#define GSM_XSMP_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_XSMP_SERVER,
GsmXsmpServerPrivate))
-struct GsmXsmpServerPrivate
+struct _GsmXsmpServer
{
+ GObject parent_instance;
+
GsmStore *client_store;
IceListenObj *xsmp_sockets;
@@ -227,14 +229,14 @@ gsm_xsmp_server_start (GsmXsmpServer *server)
GIOChannel *channel;
int i;
- for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) {
+ for (i = 0; i < server->num_local_xsmp_sockets; i++) {
GsmIceConnectionData *data;
data = g_new0 (GsmIceConnectionData, 1);
data->server = server;
- data->listener = server->priv->xsmp_sockets[i];
+ data->listener = server->xsmp_sockets[i];
- channel = g_io_channel_unix_new (IceGetListenConnectionNumber
(server->priv->xsmp_sockets[i]));
+ channel = g_io_channel_unix_new (IceGetListenConnectionNumber (server->xsmp_sockets[i]));
g_io_add_watch_full (channel,
G_PRIORITY_DEFAULT,
G_IO_IN | G_IO_HUP | G_IO_ERR,
@@ -250,7 +252,7 @@ gsm_xsmp_server_stop_accepting_new_clients (GsmXsmpServer *server)
{
g_return_if_fail (GSM_IS_XSMP_SERVER (server));
g_debug ("gsm_xsmp_server_stop_accepting_new_clients");
- server->priv->stopping = TRUE;
+ server->stopping = TRUE;
}
void
@@ -258,7 +260,7 @@ gsm_xsmp_server_start_accepting_new_clients (GsmXsmpServer *server)
{
g_return_if_fail (GSM_IS_XSMP_SERVER (server));
g_debug ("gsm_xsmp_server_start");
- server->priv->stopping = FALSE;
+ server->stopping = FALSE;
}
static void
@@ -271,11 +273,11 @@ gsm_xsmp_server_set_client_store (GsmXsmpServer *xsmp_server,
g_object_ref (store);
}
- if (xsmp_server->priv->client_store != NULL) {
- g_object_unref (xsmp_server->priv->client_store);
+ if (xsmp_server->client_store != NULL) {
+ g_object_unref (xsmp_server->client_store);
}
- xsmp_server->priv->client_store = store;
+ xsmp_server->client_store = store;
}
static void
@@ -310,7 +312,7 @@ gsm_xsmp_server_get_property (GObject *object,
switch (prop_id) {
case PROP_CLIENT_STORE:
- g_value_set_object (value, self->priv->client_store);
+ g_value_set_object (value, self->client_store);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -332,7 +334,7 @@ accept_xsmp_connection (SmsConn sms_conn,
GsmClient *client;
GsmIceConnectionWatch *data;
- if (server->priv->stopping) {
+ if (server->stopping) {
g_debug ("GsmXsmpServer: In shutdown, rejecting new client");
*failure_reason_ret = strdup (_("Refusing new client connection because the session is
currently being shut down\n"));
@@ -347,7 +349,7 @@ accept_xsmp_connection (SmsConn sms_conn,
client = gsm_xsmp_client_new (ice_conn);
- gsm_store_add (server->priv->client_store, gsm_client_peek_id (client), G_OBJECT (client));
+ gsm_store_add (server->client_store, gsm_client_peek_id (client), G_OBJECT (client));
/* the store will own the ref */
g_object_unref (client);
@@ -468,9 +470,9 @@ update_iceauthority (GsmXsmpServer *server,
return FALSE;
}
- our_network_ids = g_malloc (server->priv->num_local_xsmp_sockets * sizeof (char *));
- for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) {
- our_network_ids[i] = IceGetListenConnectionString (server->priv->xsmp_sockets[i]);
+ our_network_ids = g_malloc (server->num_local_xsmp_sockets * sizeof (char *));
+ for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+ our_network_ids[i] = IceGetListenConnectionString (server->xsmp_sockets[i]);
}
entries = NULL;
@@ -489,13 +491,13 @@ update_iceauthority (GsmXsmpServer *server,
continue;
}
- for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) {
+ for (i = 0; i < server->num_local_xsmp_sockets; i++) {
if (!strcmp (auth_entry->network_id, our_network_ids[i])) {
IceFreeAuthFileEntry (auth_entry);
break;
}
}
- if (i != server->priv->num_local_xsmp_sockets) {
+ if (i != server->num_local_xsmp_sockets) {
continue;
}
@@ -523,7 +525,7 @@ update_iceauthority (GsmXsmpServer *server,
}
if (adding) {
- for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) {
+ for (i = 0; i < server->num_local_xsmp_sockets; i++) {
entries = g_slist_append (entries,
auth_entry_new ("ICE", our_network_ids[i]));
entries = g_slist_prepend (entries,
@@ -543,7 +545,7 @@ update_iceauthority (GsmXsmpServer *server,
cleanup:
IceUnlockAuthFile (filename);
- for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) {
+ for (i = 0; i < server->num_local_xsmp_sockets; i++) {
free (our_network_ids[i]);
}
g_free (our_network_ids);
@@ -597,8 +599,8 @@ setup_listener (GsmXsmpServer *server)
*/
saved_umask = umask (0);
umask (saved_umask);
- res = IceListenForConnections (&server->priv->num_xsmp_sockets,
- &server->priv->xsmp_sockets,
+ res = IceListenForConnections (&server->num_xsmp_sockets,
+ &server->xsmp_sockets,
sizeof (error),
error);
if (! res) {
@@ -610,27 +612,27 @@ setup_listener (GsmXsmpServer *server)
/* Find the local sockets in the returned socket list and move them
* to the start of the list.
*/
- for (i = server->priv->num_local_xsmp_sockets = 0; i < server->priv->num_xsmp_sockets; i++) {
- char *id = IceGetListenConnectionString (server->priv->xsmp_sockets[i]);
+ for (i = server->num_local_xsmp_sockets = 0; i < server->num_xsmp_sockets; i++) {
+ char *id = IceGetListenConnectionString (server->xsmp_sockets[i]);
if (!strncmp (id, "local/", sizeof ("local/") - 1) ||
!strncmp (id, "unix/", sizeof ("unix/") - 1)) {
- if (i > server->priv->num_local_xsmp_sockets) {
+ if (i > server->num_local_xsmp_sockets) {
IceListenObj tmp;
- tmp = server->priv->xsmp_sockets[i];
- server->priv->xsmp_sockets[i] =
server->priv->xsmp_sockets[server->priv->num_local_xsmp_sockets];
- server->priv->xsmp_sockets[server->priv->num_local_xsmp_sockets] = tmp;
+ tmp = server->xsmp_sockets[i];
+ server->xsmp_sockets[i] =
server->xsmp_sockets[server->num_local_xsmp_sockets];
+ server->xsmp_sockets[server->num_local_xsmp_sockets] = tmp;
}
- server->priv->num_local_xsmp_sockets++;
+ server->num_local_xsmp_sockets++;
}
free (id);
}
- if (server->priv->num_local_xsmp_sockets == 0) {
+ if (server->num_local_xsmp_sockets == 0) {
gsm_util_init_error (TRUE, "IceListenForConnections did not return a local listener!");
}
- if (server->priv->num_local_xsmp_sockets != server->priv->num_xsmp_sockets) {
+ if (server->num_local_xsmp_sockets != server->num_xsmp_sockets) {
/* Xtrans was apparently compiled with support for some
* non-local transport besides TCP (which we disabled above); we
* won't create IO watches on those extra sockets, so
@@ -641,10 +643,10 @@ setup_listener (GsmXsmpServer *server)
* stop it, the fix is to add additional _IceTransNoListen()
* calls above.
*/
- network_id_list = IceComposeNetworkIdList (server->priv->num_xsmp_sockets -
server->priv->num_local_xsmp_sockets,
- server->priv->xsmp_sockets +
server->priv->num_local_xsmp_sockets);
+ network_id_list = IceComposeNetworkIdList (server->num_xsmp_sockets -
server->num_local_xsmp_sockets,
+ server->xsmp_sockets +
server->num_local_xsmp_sockets);
g_warning ("IceListenForConnections returned %d non-local listeners: %s",
- server->priv->num_xsmp_sockets - server->priv->num_local_xsmp_sockets,
+ server->num_xsmp_sockets - server->num_local_xsmp_sockets,
network_id_list);
free (network_id_list);
}
@@ -657,8 +659,8 @@ setup_listener (GsmXsmpServer *server)
IceAuthFileName ());
}
- network_id_list = IceComposeNetworkIdList (server->priv->num_local_xsmp_sockets,
- server->priv->xsmp_sockets);
+ network_id_list = IceComposeNetworkIdList (server->num_local_xsmp_sockets,
+ server->xsmp_sockets);
gsm_util_setenv ("SESSION_MANAGER", network_id_list);
g_debug ("GsmXsmpServer: SESSION_MANAGER=%s\n", network_id_list);
@@ -697,15 +699,11 @@ gsm_xsmp_server_class_init (GsmXsmpServerClass *klass)
NULL,
GSM_TYPE_STORE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_type_class_add_private (klass, sizeof (GsmXsmpServerPrivate));
}
static void
gsm_xsmp_server_init (GsmXsmpServer *xsmp_server)
{
- xsmp_server->priv = GSM_XSMP_SERVER_GET_PRIVATE (xsmp_server);
-
}
static void
@@ -718,13 +716,13 @@ gsm_xsmp_server_finalize (GObject *object)
xsmp_server = GSM_XSMP_SERVER (object);
- g_return_if_fail (xsmp_server->priv != NULL);
+ g_return_if_fail (xsmp_server != NULL);
- IceFreeListenObjs (xsmp_server->priv->num_xsmp_sockets,
- xsmp_server->priv->xsmp_sockets);
+ IceFreeListenObjs (xsmp_server->num_xsmp_sockets,
+ xsmp_server->xsmp_sockets);
- if (xsmp_server->priv->client_store != NULL) {
- g_object_unref (xsmp_server->priv->client_store);
+ if (xsmp_server->client_store != NULL) {
+ g_object_unref (xsmp_server->client_store);
}
G_OBJECT_CLASS (gsm_xsmp_server_parent_class)->finalize (object);
diff --git a/gnome-session/gsm-xsmp-server.h b/gnome-session/gsm-xsmp-server.h
index ae9188cb..95d704dc 100644
--- a/gnome-session/gsm-xsmp-server.h
+++ b/gnome-session/gsm-xsmp-server.h
@@ -28,26 +28,7 @@
G_BEGIN_DECLS
#define GSM_TYPE_XSMP_SERVER (gsm_xsmp_server_get_type ())
-#define GSM_XSMP_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_XSMP_SERVER, GsmXsmpServer))
-#define GSM_XSMP_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_XSMP_SERVER, GsmXsmpServerClass))
-#define GSM_IS_XSMP_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_XSMP_SERVER))
-#define GSM_IS_XSMP_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_XSMP_SERVER))
-#define GSM_XSMP_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_XSMP_SERVER,
GsmXsmpServerClass))
-
-typedef struct GsmXsmpServerPrivate GsmXsmpServerPrivate;
-
-typedef struct
-{
- GObject parent;
- GsmXsmpServerPrivate *priv;
-} GsmXsmpServer;
-
-typedef struct
-{
- GObjectClass parent_class;
-} GsmXsmpServerClass;
-
-GType gsm_xsmp_server_get_type (void);
+G_DECLARE_FINAL_TYPE (GsmXsmpServer, gsm_xsmp_server, GSM, XSMP_SERVER, GObject)
GsmXsmpServer * gsm_xsmp_server_new (GsmStore *client_store);
void gsm_xsmp_server_start (GsmXsmpServer *server);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]