From 110bd9800bb9cb3afdd724e4e4a3292d29c817a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <github@kempniu.pl>
Date: Thu, 27 Sep 2018 21:29:29 +0200
Subject: [PATCH] Move away from g_type_class_add_private()

g_type_class_add_private() will be deprecated in GLib 2.58.  Replace:

  - g_type_class_add_private() with G_DEFINE_TYPE_WITH_PRIVATE()
  - G_TYPE_INSTANCE_GET_PRIVATE() with *_get_instance_private()
---
 loudmouth/lm-blocking-resolver.c | 17 +++++++----------
 loudmouth/lm-feature-ping.c      | 22 ++++++++++------------
 loudmouth/lm-resolver.c          | 28 +++++++++++++---------------
 3 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/loudmouth/lm-blocking-resolver.c b/loudmouth/lm-blocking-resolver.c
index 5a25061..d980d24 100644
--- a/loudmouth/lm-blocking-resolver.c
+++ b/loudmouth/lm-blocking-resolver.c
@@ -38,10 +38,10 @@
 
 #define SRV_LEN 8192
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_BLOCKING_RESOLVER, LmBlockingResolverPriv))
+#define GET_PRIV(obj) (lm_blocking_resolver_get_instance_private (LM_BLOCKING_RESOLVER(obj)))
 
-typedef struct LmBlockingResolverPriv LmBlockingResolverPriv;
-struct LmBlockingResolverPriv {
+typedef struct LmBlockingResolverPrivate LmBlockingResolverPrivate;
+struct LmBlockingResolverPrivate {
     GSource *idle_source;
 };
 
@@ -49,7 +49,7 @@ static void     blocking_resolver_dispose     (GObject       *object);
 static void     blocking_resolver_lookup      (LmResolver    *resolver);
 static void     blocking_resolver_cancel      (LmResolver    *resolver);
 
-G_DEFINE_TYPE (LmBlockingResolver, lm_blocking_resolver, LM_TYPE_RESOLVER)
+G_DEFINE_TYPE_WITH_PRIVATE (LmBlockingResolver, lm_blocking_resolver, LM_TYPE_RESOLVER)
 
 static void
 lm_blocking_resolver_class_init (LmBlockingResolverClass *class)
@@ -61,9 +61,6 @@ lm_blocking_resolver_class_init (LmBlockingResolverClass *class)
 
     resolver_class->lookup = blocking_resolver_lookup;
     resolver_class->cancel = blocking_resolver_cancel;
-
-    g_type_class_add_private (object_class,
-                              sizeof (LmBlockingResolverPriv));
 }
 
 static void
@@ -194,7 +191,7 @@ blocking_resolver_lookup_service (LmBlockingResolver *resolver)
 static gboolean
 blocking_resolver_idle_lookup (LmBlockingResolver *resolver)
 {
-    LmBlockingResolverPriv *priv = GET_PRIV (resolver);
+    LmBlockingResolverPrivate *priv = GET_PRIV (resolver);
     gint                    type;
 
     /* Start the DNS querying */
@@ -219,7 +216,7 @@ blocking_resolver_idle_lookup (LmBlockingResolver *resolver)
 static void
 blocking_resolver_lookup (LmResolver *resolver)
 {
-    LmBlockingResolverPriv *priv;
+    LmBlockingResolverPrivate *priv;
     GMainContext           *context;
 
     g_return_if_fail (LM_IS_BLOCKING_RESOLVER (resolver));
@@ -236,7 +233,7 @@ blocking_resolver_lookup (LmResolver *resolver)
 static void
 blocking_resolver_cancel (LmResolver *resolver)
 {
-    LmBlockingResolverPriv *priv;
+    LmBlockingResolverPrivate *priv;
 
     g_return_if_fail (LM_IS_BLOCKING_RESOLVER (resolver));
 
diff --git a/loudmouth/lm-feature-ping.c b/loudmouth/lm-feature-ping.c
index b2dd439..bfd1e6d 100644
--- a/loudmouth/lm-feature-ping.c
+++ b/loudmouth/lm-feature-ping.c
@@ -28,10 +28,10 @@
 
 #define XMPP_NS_PING "urn:xmpp:ping"
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_FEATURE_PING, LmFeaturePingPriv))
+#define GET_PRIV(obj) (lm_feature_ping_get_instance_private (LM_FEATURE_PING(obj)))
 
-typedef struct LmFeaturePingPriv LmFeaturePingPriv;
-struct LmFeaturePingPriv {
+typedef struct LmFeaturePingPrivate LmFeaturePingPrivate;
+struct LmFeaturePingPrivate {
     LmConnection *connection;
     guint         keep_alive_rate;
     GSource      *keep_alive_source;
@@ -55,7 +55,7 @@ feature_ping_keep_alive_reply                    (LmMessageHandler *handler,
                                                   gpointer          user_data);
 static gboolean feature_ping_send_keep_alive     (LmFeaturePing    *fp);
 
-G_DEFINE_TYPE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
 
 enum {
     PROP_0,
@@ -103,8 +103,6 @@ lm_feature_ping_class_init (LmFeaturePingClass *class)
                       NULL, NULL,
                       _lm_marshal_VOID__VOID,
                       G_TYPE_NONE, 0);
-
-    g_type_class_add_private (object_class, sizeof (LmFeaturePingPriv));
 }
 
 static void
@@ -127,7 +125,7 @@ feature_ping_get_property (GObject    *object,
                            GValue     *value,
                            GParamSpec *pspec)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
 
     priv = GET_PRIV (object);
 
@@ -147,7 +145,7 @@ feature_ping_set_property (GObject      *object,
                            const GValue *value,
                            GParamSpec   *pspec)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
 
     priv = GET_PRIV (object);
 
@@ -171,7 +169,7 @@ feature_ping_keep_alive_reply (LmMessageHandler *handler,
                                LmMessage        *m,
                                gpointer          user_data)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
 
     priv = GET_PRIV (user_data);
 
@@ -183,7 +181,7 @@ feature_ping_keep_alive_reply (LmMessageHandler *handler,
 static gboolean
 feature_ping_send_keep_alive (LmFeaturePing *fp)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
     LmMessage         *ping;
     LmMessageNode     *ping_node;
     LmMessageHandler  *keep_alive_handler;
@@ -237,7 +235,7 @@ feature_ping_send_keep_alive (LmFeaturePing *fp)
 void
 lm_feature_ping_start (LmFeaturePing *fp)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
 
     g_return_if_fail (LM_IS_FEATURE_PING (fp));
 
@@ -260,7 +258,7 @@ lm_feature_ping_start (LmFeaturePing *fp)
 void
 lm_feature_ping_stop (LmFeaturePing *fp)
 {
-    LmFeaturePingPriv *priv;
+    LmFeaturePingPrivate *priv;
 
     g_return_if_fail (LM_IS_FEATURE_PING (fp));
 
diff --git a/loudmouth/lm-resolver.c b/loudmouth/lm-resolver.c
index b9d7762..a0500ef 100644
--- a/loudmouth/lm-resolver.c
+++ b/loudmouth/lm-resolver.c
@@ -36,10 +36,10 @@
 #include "lm-marshal.h"
 #include "lm-resolver.h"
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_RESOLVER, LmResolverPriv))
+#define GET_PRIV(obj) (lm_resolver_get_instance_private (LM_RESOLVER(obj)))
 
-typedef struct LmResolverPriv LmResolverPriv;
-struct LmResolverPriv {
+typedef struct LmResolverPrivate LmResolverPrivate;
+struct LmResolverPrivate {
     GMainContext       *context;
 
     LmResolverCallback  callback;
@@ -71,7 +71,7 @@ static void     resolver_set_property        (GObject           *object,
                                               const GValue      *value,
                                               GParamSpec        *pspec);
 
-G_DEFINE_TYPE (LmResolver, lm_resolver, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (LmResolver, lm_resolver, G_TYPE_OBJECT)
 
 enum {
     PROP_0,
@@ -151,8 +151,6 @@ lm_resolver_class_init (LmResolverClass *class)
                                                           "Protocol for SRV lookup",
                                                           NULL,
                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-    g_type_class_add_private (object_class, sizeof (LmResolverPriv));
 }
 
 static void
@@ -164,7 +162,7 @@ lm_resolver_init (LmResolver *resolver)
 static void
 resolver_finalize (GObject *object)
 {
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     priv = GET_PRIV (object);
 
@@ -190,7 +188,7 @@ resolver_get_property (GObject    *object,
                        GValue     *value,
                        GParamSpec *pspec)
 {
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     priv = GET_PRIV (object);
 
@@ -228,7 +226,7 @@ resolver_set_property (GObject      *object,
                        const GValue *value,
                        GParamSpec   *pspec)
 {
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     priv = GET_PRIV (object);
 
@@ -301,7 +299,7 @@ lm_resolver_new_for_host (const gchar        *host,
                           gpointer            user_data)
 {
     LmResolver     *resolver;
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     g_return_val_if_fail (host != NULL, NULL);
     g_return_val_if_fail (callback != NULL, NULL);
@@ -327,7 +325,7 @@ lm_resolver_new_for_service (const gchar        *domain,
                              gpointer            user_data)
 {
     LmResolver     *resolver;
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     g_return_val_if_fail (domain != NULL, NULL);
     g_return_val_if_fail (service != NULL, NULL);
@@ -373,7 +371,7 @@ lm_resolver_cancel (LmResolver *resolver)
 struct addrinfo *
 lm_resolver_results_get_next (LmResolver *resolver)
 {
-    LmResolverPriv  *priv;
+    LmResolverPrivate  *priv;
     struct addrinfo *ret_val;
 
     g_return_val_if_fail (LM_IS_RESOLVER (resolver), NULL);
@@ -401,7 +399,7 @@ skipresult:
 void
 lm_resolver_results_reset (LmResolver *resolver)
 {
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     g_return_if_fail (LM_IS_RESOLVER (resolver));
 
@@ -427,7 +425,7 @@ _lm_resolver_set_result (LmResolver       *resolver,
                          LmResolverResult  result,
                          struct addrinfo  *results)
 {
-    LmResolverPriv *priv;
+    LmResolverPrivate *priv;
 
     g_return_if_fail (LM_IS_RESOLVER (resolver));
 
