You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

277 lines
9.5 KiB

  1. From 110bd9800bb9cb3afdd724e4e4a3292d29c817a1 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <github@kempniu.pl>
  3. Date: Thu, 27 Sep 2018 21:29:29 +0200
  4. Subject: [PATCH] Move away from g_type_class_add_private()
  5. g_type_class_add_private() will be deprecated in GLib 2.58. Replace:
  6. - g_type_class_add_private() with G_DEFINE_TYPE_WITH_PRIVATE()
  7. - G_TYPE_INSTANCE_GET_PRIVATE() with *_get_instance_private()
  8. ---
  9. loudmouth/lm-blocking-resolver.c | 17 +++++++----------
  10. loudmouth/lm-feature-ping.c | 22 ++++++++++------------
  11. loudmouth/lm-resolver.c | 28 +++++++++++++---------------
  12. 3 files changed, 30 insertions(+), 37 deletions(-)
  13. diff --git a/loudmouth/lm-blocking-resolver.c b/loudmouth/lm-blocking-resolver.c
  14. index 5a25061..d980d24 100644
  15. --- a/loudmouth/lm-blocking-resolver.c
  16. +++ b/loudmouth/lm-blocking-resolver.c
  17. @@ -38,10 +38,10 @@
  18. #define SRV_LEN 8192
  19. -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_BLOCKING_RESOLVER, LmBlockingResolverPriv))
  20. +#define GET_PRIV(obj) (lm_blocking_resolver_get_instance_private (LM_BLOCKING_RESOLVER(obj)))
  21. -typedef struct LmBlockingResolverPriv LmBlockingResolverPriv;
  22. -struct LmBlockingResolverPriv {
  23. +typedef struct LmBlockingResolverPrivate LmBlockingResolverPrivate;
  24. +struct LmBlockingResolverPrivate {
  25. GSource *idle_source;
  26. };
  27. @@ -49,7 +49,7 @@ static void blocking_resolver_dispose (GObject *object);
  28. static void blocking_resolver_lookup (LmResolver *resolver);
  29. static void blocking_resolver_cancel (LmResolver *resolver);
  30. -G_DEFINE_TYPE (LmBlockingResolver, lm_blocking_resolver, LM_TYPE_RESOLVER)
  31. +G_DEFINE_TYPE_WITH_PRIVATE (LmBlockingResolver, lm_blocking_resolver, LM_TYPE_RESOLVER)
  32. static void
  33. lm_blocking_resolver_class_init (LmBlockingResolverClass *class)
  34. @@ -61,9 +61,6 @@ lm_blocking_resolver_class_init (LmBlockingResolverClass *class)
  35. resolver_class->lookup = blocking_resolver_lookup;
  36. resolver_class->cancel = blocking_resolver_cancel;
  37. -
  38. - g_type_class_add_private (object_class,
  39. - sizeof (LmBlockingResolverPriv));
  40. }
  41. static void
  42. @@ -194,7 +191,7 @@ blocking_resolver_lookup_service (LmBlockingResolver *resolver)
  43. static gboolean
  44. blocking_resolver_idle_lookup (LmBlockingResolver *resolver)
  45. {
  46. - LmBlockingResolverPriv *priv = GET_PRIV (resolver);
  47. + LmBlockingResolverPrivate *priv = GET_PRIV (resolver);
  48. gint type;
  49. /* Start the DNS querying */
  50. @@ -219,7 +216,7 @@ blocking_resolver_idle_lookup (LmBlockingResolver *resolver)
  51. static void
  52. blocking_resolver_lookup (LmResolver *resolver)
  53. {
  54. - LmBlockingResolverPriv *priv;
  55. + LmBlockingResolverPrivate *priv;
  56. GMainContext *context;
  57. g_return_if_fail (LM_IS_BLOCKING_RESOLVER (resolver));
  58. @@ -236,7 +233,7 @@ blocking_resolver_lookup (LmResolver *resolver)
  59. static void
  60. blocking_resolver_cancel (LmResolver *resolver)
  61. {
  62. - LmBlockingResolverPriv *priv;
  63. + LmBlockingResolverPrivate *priv;
  64. g_return_if_fail (LM_IS_BLOCKING_RESOLVER (resolver));
  65. diff --git a/loudmouth/lm-feature-ping.c b/loudmouth/lm-feature-ping.c
  66. index b2dd439..bfd1e6d 100644
  67. --- a/loudmouth/lm-feature-ping.c
  68. +++ b/loudmouth/lm-feature-ping.c
  69. @@ -28,10 +28,10 @@
  70. #define XMPP_NS_PING "urn:xmpp:ping"
  71. -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_FEATURE_PING, LmFeaturePingPriv))
  72. +#define GET_PRIV(obj) (lm_feature_ping_get_instance_private (LM_FEATURE_PING(obj)))
  73. -typedef struct LmFeaturePingPriv LmFeaturePingPriv;
  74. -struct LmFeaturePingPriv {
  75. +typedef struct LmFeaturePingPrivate LmFeaturePingPrivate;
  76. +struct LmFeaturePingPrivate {
  77. LmConnection *connection;
  78. guint keep_alive_rate;
  79. GSource *keep_alive_source;
  80. @@ -55,7 +55,7 @@ feature_ping_keep_alive_reply (LmMessageHandler *handler,
  81. gpointer user_data);
  82. static gboolean feature_ping_send_keep_alive (LmFeaturePing *fp);
  83. -G_DEFINE_TYPE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
  84. +G_DEFINE_TYPE_WITH_PRIVATE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
  85. enum {
  86. PROP_0,
  87. @@ -103,8 +103,6 @@ lm_feature_ping_class_init (LmFeaturePingClass *class)
  88. NULL, NULL,
  89. _lm_marshal_VOID__VOID,
  90. G_TYPE_NONE, 0);
  91. -
  92. - g_type_class_add_private (object_class, sizeof (LmFeaturePingPriv));
  93. }
  94. static void
  95. @@ -127,7 +125,7 @@ feature_ping_get_property (GObject *object,
  96. GValue *value,
  97. GParamSpec *pspec)
  98. {
  99. - LmFeaturePingPriv *priv;
  100. + LmFeaturePingPrivate *priv;
  101. priv = GET_PRIV (object);
  102. @@ -147,7 +145,7 @@ feature_ping_set_property (GObject *object,
  103. const GValue *value,
  104. GParamSpec *pspec)
  105. {
  106. - LmFeaturePingPriv *priv;
  107. + LmFeaturePingPrivate *priv;
  108. priv = GET_PRIV (object);
  109. @@ -171,7 +169,7 @@ feature_ping_keep_alive_reply (LmMessageHandler *handler,
  110. LmMessage *m,
  111. gpointer user_data)
  112. {
  113. - LmFeaturePingPriv *priv;
  114. + LmFeaturePingPrivate *priv;
  115. priv = GET_PRIV (user_data);
  116. @@ -183,7 +181,7 @@ feature_ping_keep_alive_reply (LmMessageHandler *handler,
  117. static gboolean
  118. feature_ping_send_keep_alive (LmFeaturePing *fp)
  119. {
  120. - LmFeaturePingPriv *priv;
  121. + LmFeaturePingPrivate *priv;
  122. LmMessage *ping;
  123. LmMessageNode *ping_node;
  124. LmMessageHandler *keep_alive_handler;
  125. @@ -237,7 +235,7 @@ feature_ping_send_keep_alive (LmFeaturePing *fp)
  126. void
  127. lm_feature_ping_start (LmFeaturePing *fp)
  128. {
  129. - LmFeaturePingPriv *priv;
  130. + LmFeaturePingPrivate *priv;
  131. g_return_if_fail (LM_IS_FEATURE_PING (fp));
  132. @@ -260,7 +258,7 @@ lm_feature_ping_start (LmFeaturePing *fp)
  133. void
  134. lm_feature_ping_stop (LmFeaturePing *fp)
  135. {
  136. - LmFeaturePingPriv *priv;
  137. + LmFeaturePingPrivate *priv;
  138. g_return_if_fail (LM_IS_FEATURE_PING (fp));
  139. diff --git a/loudmouth/lm-resolver.c b/loudmouth/lm-resolver.c
  140. index b9d7762..a0500ef 100644
  141. --- a/loudmouth/lm-resolver.c
  142. +++ b/loudmouth/lm-resolver.c
  143. @@ -36,10 +36,10 @@
  144. #include "lm-marshal.h"
  145. #include "lm-resolver.h"
  146. -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_RESOLVER, LmResolverPriv))
  147. +#define GET_PRIV(obj) (lm_resolver_get_instance_private (LM_RESOLVER(obj)))
  148. -typedef struct LmResolverPriv LmResolverPriv;
  149. -struct LmResolverPriv {
  150. +typedef struct LmResolverPrivate LmResolverPrivate;
  151. +struct LmResolverPrivate {
  152. GMainContext *context;
  153. LmResolverCallback callback;
  154. @@ -71,7 +71,7 @@ static void resolver_set_property (GObject *object,
  155. const GValue *value,
  156. GParamSpec *pspec);
  157. -G_DEFINE_TYPE (LmResolver, lm_resolver, G_TYPE_OBJECT)
  158. +G_DEFINE_TYPE_WITH_PRIVATE (LmResolver, lm_resolver, G_TYPE_OBJECT)
  159. enum {
  160. PROP_0,
  161. @@ -151,8 +151,6 @@ lm_resolver_class_init (LmResolverClass *class)
  162. "Protocol for SRV lookup",
  163. NULL,
  164. G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
  165. -
  166. - g_type_class_add_private (object_class, sizeof (LmResolverPriv));
  167. }
  168. static void
  169. @@ -164,7 +162,7 @@ lm_resolver_init (LmResolver *resolver)
  170. static void
  171. resolver_finalize (GObject *object)
  172. {
  173. - LmResolverPriv *priv;
  174. + LmResolverPrivate *priv;
  175. priv = GET_PRIV (object);
  176. @@ -190,7 +188,7 @@ resolver_get_property (GObject *object,
  177. GValue *value,
  178. GParamSpec *pspec)
  179. {
  180. - LmResolverPriv *priv;
  181. + LmResolverPrivate *priv;
  182. priv = GET_PRIV (object);
  183. @@ -228,7 +226,7 @@ resolver_set_property (GObject *object,
  184. const GValue *value,
  185. GParamSpec *pspec)
  186. {
  187. - LmResolverPriv *priv;
  188. + LmResolverPrivate *priv;
  189. priv = GET_PRIV (object);
  190. @@ -301,7 +299,7 @@ lm_resolver_new_for_host (const gchar *host,
  191. gpointer user_data)
  192. {
  193. LmResolver *resolver;
  194. - LmResolverPriv *priv;
  195. + LmResolverPrivate *priv;
  196. g_return_val_if_fail (host != NULL, NULL);
  197. g_return_val_if_fail (callback != NULL, NULL);
  198. @@ -327,7 +325,7 @@ lm_resolver_new_for_service (const gchar *domain,
  199. gpointer user_data)
  200. {
  201. LmResolver *resolver;
  202. - LmResolverPriv *priv;
  203. + LmResolverPrivate *priv;
  204. g_return_val_if_fail (domain != NULL, NULL);
  205. g_return_val_if_fail (service != NULL, NULL);
  206. @@ -373,7 +371,7 @@ lm_resolver_cancel (LmResolver *resolver)
  207. struct addrinfo *
  208. lm_resolver_results_get_next (LmResolver *resolver)
  209. {
  210. - LmResolverPriv *priv;
  211. + LmResolverPrivate *priv;
  212. struct addrinfo *ret_val;
  213. g_return_val_if_fail (LM_IS_RESOLVER (resolver), NULL);
  214. @@ -401,7 +399,7 @@ skipresult:
  215. void
  216. lm_resolver_results_reset (LmResolver *resolver)
  217. {
  218. - LmResolverPriv *priv;
  219. + LmResolverPrivate *priv;
  220. g_return_if_fail (LM_IS_RESOLVER (resolver));
  221. @@ -427,7 +425,7 @@ _lm_resolver_set_result (LmResolver *resolver,
  222. LmResolverResult result,
  223. struct addrinfo *results)
  224. {
  225. - LmResolverPriv *priv;
  226. + LmResolverPrivate *priv;
  227. g_return_if_fail (LM_IS_RESOLVER (resolver));