nm: Replace deprecated g_type_class_add_private()
authorTobias Brunner <tobias@strongswan.org>
Mon, 16 Dec 2019 12:55:39 +0000 (13:55 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 5 Feb 2020 09:54:37 +0000 (10:54 +0100)
Fixes #2765, #3197.

src/charon-nm/nm/nm_service.c
src/frontends/gnome/properties/nm-strongswan.c

index 1b07230..ca608b1 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <stdio.h>
 
-G_DEFINE_TYPE(NMStrongswanPlugin, nm_strongswan_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
-
 /**
  * Private data of NMStrongswanPlugin
  */
@@ -46,9 +44,11 @@ typedef struct {
        char *name;
 } NMStrongswanPluginPrivate;
 
+G_DEFINE_TYPE_WITH_PRIVATE(NMStrongswanPlugin, nm_strongswan_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
+
 #define NM_STRONGSWAN_PLUGIN_GET_PRIVATE(o) \
-                       (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
-                               NM_TYPE_STRONGSWAN_PLUGIN, NMStrongswanPluginPrivate))
+                       ((NMStrongswanPluginPrivate*) \
+                               nm_strongswan_plugin_get_instance_private (o))
 
 /**
  * Convert an address chunk to a GValue
@@ -111,7 +111,8 @@ static GVariant* handler_to_variant(nm_handler_t *handler, char *variant_type,
 static void signal_ip_config(NMVpnServicePlugin *plugin,
                                                         ike_sa_t *ike_sa, child_sa_t *child_sa)
 {
-       NMStrongswanPluginPrivate *priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
+       NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
+       NMStrongswanPluginPrivate *priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub);
        GVariantBuilder builder, ip4builder, ip6builder;
        GVariant *ip4config, *ip6config;
        enumerator_t *enumerator;
@@ -239,7 +240,8 @@ static void signal_ip_config(NMVpnServicePlugin *plugin,
  */
 static void signal_failure(NMVpnServicePlugin *plugin, NMVpnPluginFailure failure)
 {
-       nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
+       NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
+       nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub)->handler;
 
        handler->reset(handler);
 
@@ -376,6 +378,7 @@ static identification_t *find_smartcard_key(NMStrongswanPluginPrivate *priv,
 static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
                                                 GError **err)
 {
+       NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
        NMStrongswanPluginPrivate *priv;
        NMSettingConnection *conn;
        NMSettingVpn *vpn;
@@ -423,7 +426,7 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
        /**
         * Read parameters
         */
-       priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
+       priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub);
        conn = NM_SETTING_CONNECTION(nm_connection_get_setting(connection,
                                                                                                NM_TYPE_SETTING_CONNECTION));
        vpn = NM_SETTING_VPN(nm_connection_get_setting(connection,
@@ -901,8 +904,6 @@ static void nm_strongswan_plugin_class_init(
 {
        NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS(strongswan_class);
 
-       g_type_class_add_private(G_OBJECT_CLASS(strongswan_class),
-                                                        sizeof(NMStrongswanPluginPrivate));
        parent_class->connect = connect_;
        parent_class->need_secrets = need_secrets;
        parent_class->disconnect = disconnect;
index de15c42..d261dcb 100644 (file)
@@ -64,17 +64,17 @@ G_DEFINE_TYPE_EXTENDED (StrongswanPluginUi, strongswan_plugin_ui, G_TYPE_OBJECT,
 
 static void strongswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class);
 
-G_DEFINE_TYPE_EXTENDED (StrongswanPluginUiWidget, strongswan_plugin_ui_widget, G_TYPE_OBJECT, 0,
-                                               G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
-                                                                                          strongswan_plugin_ui_widget_interface_init))
-
-#define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetPrivate))
-
 typedef struct {
        GtkBuilder *builder;
        GtkWidget *widget;
 } StrongswanPluginUiWidgetPrivate;
 
+G_DEFINE_TYPE_EXTENDED (StrongswanPluginUiWidget, strongswan_plugin_ui_widget, G_TYPE_OBJECT, 0,
+                                               G_ADD_PRIVATE (StrongswanPluginUiWidget)
+                                               G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
+                                                                                          strongswan_plugin_ui_widget_interface_init))
+
+#define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) ((StrongswanPluginUiWidgetPrivate*)strongswan_plugin_ui_widget_get_instance_private(o))
 
 #define STRONGSWAN_PLUGIN_UI_ERROR strongswan_plugin_ui_error_quark ()
 
@@ -586,7 +586,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
                return NULL;
        }
 
-       priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (object);
+       priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE ((StrongswanPluginUiWidget*)object);
        ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-strongswan-dialog.ui");
        priv->builder = gtk_builder_new ();
 
@@ -644,8 +644,6 @@ strongswan_plugin_ui_widget_class_init (StrongswanPluginUiWidgetClass *req_class
 {
        GObjectClass *object_class = G_OBJECT_CLASS (req_class);
 
-       g_type_class_add_private (req_class, sizeof (StrongswanPluginUiWidgetPrivate));
-
        object_class->dispose = dispose;
 }