[gvfs/wip/oholy/ci-glib-master] daemon: Don't use deprecated private structure APIs
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/ci-glib-master] daemon: Don't use deprecated private structure APIs
- Date: Tue, 10 Jul 2018 13:57:42 +0000 (UTC)
commit 5e276b2c92015f8c6eff42be99eafc8d54b570a7
Author: Ondrej Holy <oholy redhat com>
Date: Tue Jul 10 14:59:21 2018 +0200
daemon: Don't use deprecated private structure APIs
g_type_class_add_private and G_TYPE_INSTANCE_GET_PRIVATE have been
recently deprecated. Let's use rather G_DEFINE_TYPE_WITH_PRIVATE
and _get_instance_private() instead in order to prevent deprecation
warnings.
daemon/gvfsafpconnection.c | 10 +++-------
daemon/gvfsafpserver.c | 13 +++++--------
daemon/gvfsafpvolume.c | 12 ++++--------
daemon/gvfsbackend.c | 9 ++++-----
daemon/gvfschannel.c | 15 ++++++---------
daemon/gvfshttpinputstream.c | 43 ++++++++++++++++++++-----------------------
daemon/gvfshttpinputstream.h | 2 ++
daemon/gvfsjob.c | 8 +++-----
daemon/gvfsjobprogress.c | 6 ++----
daemon/gvfsmonitor.c | 12 ++++--------
10 files changed, 53 insertions(+), 77 deletions(-)
---
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index b3ef1928..5eceabd2 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -624,8 +624,6 @@ enum {
static guint signals[LAST_SIGNAL] = {0,};
-G_DEFINE_TYPE (GVfsAfpConnection, g_vfs_afp_connection, G_TYPE_OBJECT);
-
typedef struct {
guint8 flags;
guint8 command;
@@ -680,6 +678,8 @@ struct _GVfsAfpConnectionPrivate
GSList *pending_closes;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsAfpConnection, g_vfs_afp_connection, G_TYPE_OBJECT);
+
typedef enum
{
DSI_CLOSE_SESSION = 1,
@@ -797,9 +797,7 @@ g_vfs_afp_connection_init (GVfsAfpConnection *afp_connection)
{
GVfsAfpConnectionPrivate *priv;
- afp_connection->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (afp_connection,
- G_VFS_TYPE_AFP_CONNECTION,
- GVfsAfpConnectionPrivate);
+ afp_connection->priv = priv = g_vfs_afp_connection_get_instance_private (afp_connection);
priv->kRequestQuanta = -1;
priv->kServerReplayCacheSize = -1;
@@ -833,8 +831,6 @@ g_vfs_afp_connection_class_init (GVfsAfpConnectionClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsAfpConnectionPrivate));
-
object_class->finalize = g_vfs_afp_connection_finalize;
signals[ATTENTION] =
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index c802fa3d..18eb874c 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -35,8 +35,6 @@
#include "gvfsafpserver.h"
-G_DEFINE_TYPE (GVfsAfpServer, g_vfs_afp_server, G_TYPE_OBJECT);
-
struct _GvfsAfpServerPrivate
{
GNetworkAddress *addr;
@@ -50,6 +48,8 @@ struct _GvfsAfpServerPrivate
guint64 uuid;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsAfpServer, g_vfs_afp_server, G_TYPE_OBJECT);
+
#define AFP_UAM_NO_USER "No User Authent"
#define AFP_UAM_DHX "DHCAST128"
#define AFP_UAM_DHX2 "DHX2"
@@ -70,10 +70,9 @@ static void
g_vfs_afp_server_init (GVfsAfpServer *server)
{
GVfsAfpServerPrivate *priv;
-
- server->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (server, G_VFS_TYPE_AFP_SERVER,
- GVfsAfpServerPrivate);
-
+
+ server->priv = priv = g_vfs_afp_server_get_instance_private (server);
+
priv->info.machine_type = NULL;
priv->info.server_name = NULL;
priv->info.utf8_server_name = NULL;
@@ -105,8 +104,6 @@ g_vfs_afp_server_class_init (GVfsAfpServerClass *klass)
GObjectClass* object_class = G_OBJECT_CLASS (klass);
object_class->finalize = g_vfs_afp_server_finalize;
-
- g_type_class_add_private (klass, sizeof (GVfsAfpServerPrivate));
}
static const char *
diff --git a/daemon/gvfsafpvolume.c b/daemon/gvfsafpvolume.c
index d680d5f1..3f306f4b 100644
--- a/daemon/gvfsafpvolume.c
+++ b/daemon/gvfsafpvolume.c
@@ -27,9 +27,6 @@
#include "gvfsafpvolume.h"
-
-G_DEFINE_TYPE (GVfsAfpVolume, g_vfs_afp_volume, G_TYPE_OBJECT);
-
struct _GVfsAfpVolumePrivate
{
GVfsAfpServer *server;
@@ -40,6 +37,8 @@ struct _GVfsAfpVolumePrivate
guint16 volume_id;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsAfpVolume, g_vfs_afp_volume, G_TYPE_OBJECT);
+
static void
attention_cb (GVfsAfpConnection *conn, guint attention, GVfsAfpVolume *volume);
@@ -47,9 +46,8 @@ static void
g_vfs_afp_volume_init (GVfsAfpVolume *volume)
{
GVfsAfpVolumePrivate *priv;
-
- volume->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (volume, G_VFS_TYPE_AFP_VOLUME,
- GVfsAfpVolumePrivate);
+
+ volume->priv = priv = g_vfs_afp_volume_get_instance_private (volume);
priv->mounted = FALSE;
}
@@ -72,8 +70,6 @@ g_vfs_afp_volume_class_init (GVfsAfpVolumeClass *klass)
GObjectClass* object_class = G_OBJECT_CLASS (klass);
object_class->finalize = g_vfs_afp_volume_finalize;
-
- g_type_class_add_private (klass, sizeof (GVfsAfpVolumePrivate));
}
GVfsAfpVolume *
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index a622f6e3..673070fa 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -101,8 +101,9 @@ static GObject* g_vfs_backend_constructor (GType
G_DEFINE_TYPE_WITH_CODE (GVfsBackend, g_vfs_backend, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_VFS_TYPE_JOB_SOURCE,
- g_vfs_backend_job_source_iface_init))
+ G_ADD_PRIVATE (GVfsBackend)
+ G_IMPLEMENT_INTERFACE (G_VFS_TYPE_JOB_SOURCE,
+ g_vfs_backend_job_source_iface_init))
static GHashTable *registered_backends = NULL;
@@ -169,8 +170,6 @@ g_vfs_backend_class_init (GVfsBackendClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsBackendPrivate));
-
gobject_class->constructor = g_vfs_backend_constructor;
gobject_class->finalize = g_vfs_backend_finalize;
gobject_class->set_property = g_vfs_backend_set_property;
@@ -197,7 +196,7 @@ g_vfs_backend_class_init (GVfsBackendClass *klass)
static void
g_vfs_backend_init (GVfsBackend *backend)
{
- backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (backend, G_VFS_TYPE_BACKEND, GVfsBackendPrivate);
+ backend->priv = g_vfs_backend_get_instance_private (backend);
backend->priv->icon = NULL;
backend->priv->symbolic_icon = NULL;
backend->priv->prefered_filename_encoding = g_strdup ("");
diff --git a/daemon/gvfschannel.c b/daemon/gvfschannel.c
index c3586603..cc079883 100644
--- a/daemon/gvfschannel.c
+++ b/daemon/gvfschannel.c
@@ -45,10 +45,6 @@
static void g_vfs_channel_job_source_iface_init (GVfsJobSourceIface *iface);
-G_DEFINE_TYPE_WITH_CODE (GVfsChannel, g_vfs_channel, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_VFS_TYPE_JOB_SOURCE,
- g_vfs_channel_job_source_iface_init))
-
/* TODO: Real P_() */
#define P_(_x) (_x)
@@ -108,6 +104,11 @@ struct _GVfsChannelPrivate
gsize output_data_pos;
};
+G_DEFINE_TYPE_WITH_CODE (GVfsChannel, g_vfs_channel, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GVfsChannel)
+ G_IMPLEMENT_INTERFACE (G_VFS_TYPE_JOB_SOURCE,
+ g_vfs_channel_job_source_iface_init))
+
static void start_request_reader (GVfsChannel *channel);
static void g_vfs_channel_get_property (GObject *object,
guint prop_id,
@@ -162,8 +163,6 @@ g_vfs_channel_class_init (GVfsChannelClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsChannelPrivate));
-
gobject_class->finalize = g_vfs_channel_finalize;
gobject_class->set_property = g_vfs_channel_set_property;
gobject_class->get_property = g_vfs_channel_get_property;
@@ -195,9 +194,7 @@ g_vfs_channel_init (GVfsChannel *channel)
int socket_fds[2];
int ret;
- channel->priv = G_TYPE_INSTANCE_GET_PRIVATE (channel,
- G_VFS_TYPE_CHANNEL,
- GVfsChannelPrivate);
+ channel->priv = g_vfs_channel_get_instance_private (channel);
channel->priv->remote_fd = -1;
ret = socketpair (AF_UNIX, SOCK_STREAM, 0, socket_fds);
diff --git a/daemon/gvfshttpinputstream.c b/daemon/gvfshttpinputstream.c
index 1c6c11ad..82f9164d 100644
--- a/daemon/gvfshttpinputstream.c
+++ b/daemon/gvfshttpinputstream.c
@@ -32,11 +32,7 @@
static void g_vfs_http_input_stream_seekable_iface_init (GSeekableIface *seekable_iface);
-G_DEFINE_TYPE_WITH_CODE (GVfsHttpInputStream, g_vfs_http_input_stream, G_TYPE_INPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- g_vfs_http_input_stream_seekable_iface_init))
-
-typedef struct {
+struct GVfsHttpInputStreamPrivate {
SoupURI *uri;
SoupSession *session;
SoupRequest *req;
@@ -46,21 +42,24 @@ typedef struct {
char *range;
goffset request_offset;
goffset offset;
+};
-} GVfsHttpInputStreamPrivate;
-#define G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
G_VFS_TYPE_HTTP_INPUT_STREAM, GVfsHttpInputStreamPrivate))
+G_DEFINE_TYPE_WITH_CODE (GVfsHttpInputStream, g_vfs_http_input_stream, G_TYPE_INPUT_STREAM,
+ G_ADD_PRIVATE (GVfsHttpInputStream)
+ G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
+ g_vfs_http_input_stream_seekable_iface_init))
static void
g_vfs_http_input_stream_init (GVfsHttpInputStream *stream)
{
- ;
+ stream->priv = g_vfs_http_input_stream_get_instance_private (stream);
}
static void
g_vfs_http_input_stream_finalize (GObject *object)
{
GVfsHttpInputStream *stream = G_VFS_HTTP_INPUT_STREAM (object);
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ GVfsHttpInputStreamPrivate *priv = stream->priv;
g_clear_pointer (&priv->uri, soup_uri_free);
g_clear_object (&priv->session);
@@ -96,7 +95,7 @@ g_vfs_http_input_stream_new (SoupSession *session,
GVfsHttpInputStreamPrivate *priv;
stream = g_object_new (G_VFS_TYPE_HTTP_INPUT_STREAM, NULL);
- priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ priv = stream->priv;
priv->session = g_object_ref (session);
priv->uri = soup_uri_copy (uri);
@@ -107,7 +106,7 @@ g_vfs_http_input_stream_new (SoupSession *session,
static SoupRequest *
g_vfs_http_input_stream_ensure_request (GInputStream *stream)
{
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (stream)->priv;
if (!priv->req)
{
@@ -132,7 +131,7 @@ send_callback (GObject *object,
{
GTask *task = user_data;
GInputStream *http_stream = g_task_get_source_object (task);
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (http_stream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (http_stream)->priv;
GError *error = NULL;
g_input_stream_clear_pending (http_stream);
@@ -170,7 +169,7 @@ g_vfs_http_input_stream_send_async (GInputStream *stream,
GTask *task;
g_return_if_fail (G_VFS_IS_HTTP_INPUT_STREAM (stream));
- priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ priv = G_VFS_HTTP_INPUT_STREAM (stream)->priv;
task = g_task_new (stream, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
@@ -223,7 +222,7 @@ read_callback (GObject *object,
{
GTask *task = user_data;
GInputStream *vfsstream = g_task_get_source_object (task);
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (vfsstream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (vfsstream)->priv;
GError *error = NULL;
gssize nread;
@@ -250,7 +249,7 @@ read_send_callback (GObject *object,
{
GTask *task = user_data;
GInputStream *vfsstream = g_task_get_source_object (task);
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (vfsstream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (vfsstream)->priv;
ReadAfterSendData *rasd = g_task_get_task_data (task);
GError *error = NULL;
@@ -311,7 +310,7 @@ g_vfs_http_input_stream_read_async (GInputStream *stream,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (stream)->priv;
GTask *task;
task = g_task_new (stream, cancellable, callback, user_data);
@@ -368,7 +367,7 @@ g_vfs_http_input_stream_close_async (GInputStream *stream,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (stream)->priv;
GTask *task;
task = g_task_new (stream, cancellable, callback, user_data);
@@ -397,7 +396,7 @@ g_vfs_http_input_stream_close_finish (GInputStream *stream,
static goffset
g_vfs_http_input_stream_tell (GSeekable *seekable)
{
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (seekable);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (seekable)->priv;
return priv->offset;
}
@@ -416,7 +415,7 @@ g_vfs_http_input_stream_seek (GSeekable *seekable,
GError **error)
{
GInputStream *stream = G_INPUT_STREAM (seekable);
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (seekable);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (seekable)->priv;
if (type == G_SEEK_END && priv->msg)
{
@@ -497,7 +496,7 @@ g_vfs_http_input_stream_truncate (GSeekable *seekable,
SoupMessage *
g_vfs_http_input_stream_get_message (GInputStream *stream)
{
- GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
+ GVfsHttpInputStreamPrivate *priv = G_VFS_HTTP_INPUT_STREAM (stream)->priv;
g_vfs_http_input_stream_ensure_request (stream);
return g_object_ref (priv->msg);
@@ -509,9 +508,7 @@ g_vfs_http_input_stream_class_init (GVfsHttpInputStreamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GVfsHttpInputStreamPrivate));
-
+
gobject_class->finalize = g_vfs_http_input_stream_finalize;
stream_class->read_async = g_vfs_http_input_stream_read_async;
diff --git a/daemon/gvfshttpinputstream.h b/daemon/gvfshttpinputstream.h
index bce0c88e..93f919ee 100644
--- a/daemon/gvfshttpinputstream.h
+++ b/daemon/gvfshttpinputstream.h
@@ -32,12 +32,14 @@ G_BEGIN_DECLS
#define G_VFS_HTTP_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_VFS_TYPE_HTTP_INPUT_STREAM,
GVfsHttpInputStreamClass))
typedef struct GVfsHttpInputStream GVfsHttpInputStream;
+typedef struct GVfsHttpInputStreamPrivate GVfsHttpInputStreamPrivate;
typedef struct GVfsHttpInputStreamClass GVfsHttpInputStreamClass;
struct GVfsHttpInputStream
{
GInputStream parent;
+ GVfsHttpInputStreamPrivate *priv;
};
struct GVfsHttpInputStreamClass
diff --git a/daemon/gvfsjob.c b/daemon/gvfsjob.c
index 53e38725..36d25fdc 100644
--- a/daemon/gvfsjob.c
+++ b/daemon/gvfsjob.c
@@ -33,8 +33,6 @@
#include "gvfsjob.h"
#include "gvfsjobsource.h"
-G_DEFINE_TYPE (GVfsJob, g_vfs_job, G_TYPE_OBJECT)
-
/* TODO: Real P_() */
#define P_(_x) (_x)
@@ -55,6 +53,8 @@ struct _GVfsJobPrivate
int dummy;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsJob, g_vfs_job, G_TYPE_OBJECT)
+
static guint signals[LAST_SIGNAL] = { 0 };
static void g_vfs_job_get_property (GObject *object,
@@ -90,8 +90,6 @@ g_vfs_job_class_init (GVfsJobClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsJobPrivate));
-
gobject_class->finalize = g_vfs_job_finalize;
gobject_class->set_property = g_vfs_job_set_property;
gobject_class->get_property = g_vfs_job_get_property;
@@ -133,7 +131,7 @@ g_vfs_job_class_init (GVfsJobClass *klass)
static void
g_vfs_job_init (GVfsJob *job)
{
- job->priv = G_TYPE_INSTANCE_GET_PRIVATE (job, G_VFS_TYPE_JOB, GVfsJobPrivate);
+ job->priv = g_vfs_job_get_instance_private (job);
job->cancellable = g_cancellable_new ();
diff --git a/daemon/gvfsjobprogress.c b/daemon/gvfsjobprogress.c
index 592d2beb..c6880375 100644
--- a/daemon/gvfsjobprogress.c
+++ b/daemon/gvfsjobprogress.c
@@ -37,7 +37,7 @@ struct _GVfsJobProgressPrivate
gint64 last_time;
};
-G_DEFINE_TYPE (GVfsJobProgress, g_vfs_job_progress, G_VFS_TYPE_JOB_DBUS)
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsJobProgress, g_vfs_job_progress, G_VFS_TYPE_JOB_DBUS)
static void
g_vfs_job_progress_finalize (GObject *object)
@@ -58,15 +58,13 @@ g_vfs_job_progress_class_init (GVfsJobProgressClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsJobProgressPrivate));
-
gobject_class->finalize = g_vfs_job_progress_finalize;
}
static void
g_vfs_job_progress_init (GVfsJobProgress *job)
{
- job->priv = G_TYPE_INSTANCE_GET_PRIVATE (job, G_VFS_TYPE_JOB_PROGRESS, GVfsJobProgressPrivate);
+ job->priv = g_vfs_job_progress_get_instance_private (job);
}
void
diff --git a/daemon/gvfsmonitor.c b/daemon/gvfsmonitor.c
index cdf0dc2a..b03f7fcd 100644
--- a/daemon/gvfsmonitor.c
+++ b/daemon/gvfsmonitor.c
@@ -62,7 +62,7 @@ struct _GVfsMonitorPrivate
/* atomic */
static volatile gint path_counter = 1;
-G_DEFINE_TYPE (GVfsMonitor, g_vfs_monitor, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GVfsMonitor, g_vfs_monitor, G_TYPE_OBJECT)
static void unsubscribe (Subscriber *subscriber);
@@ -118,8 +118,6 @@ g_vfs_monitor_class_init (GVfsMonitorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GVfsMonitorPrivate));
-
gobject_class->finalize = g_vfs_monitor_finalize;
}
@@ -127,11 +125,9 @@ static void
g_vfs_monitor_init (GVfsMonitor *monitor)
{
gint id;
-
- monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor,
- G_TYPE_VFS_MONITOR,
- GVfsMonitorPrivate);
-
+
+ monitor->priv = g_vfs_monitor_get_instance_private (monitor);
+
id = g_atomic_int_add (&path_counter, 1);
monitor->priv->object_path = g_strdup_printf (OBJ_PATH_PREFIX"%d", id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]